@rohal12/spindle 0.59.21 → 0.59.23

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.59.21","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>var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r};(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel=\"modulepreload\"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var n,r,i,a,o,s,c,l,u,d,f,p,m={},h=[],g=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,_=Array.isArray;function v(e,t){for(var n in t)e[n]=t[n];return e}function y(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function b(e,t,r){var i,a,o,s={};for(o in t)o==`key`?i=t[o]:o==`ref`?a=t[o]:s[o]=t[o];if(arguments.length>2&&(s.children=arguments.length>3?n.call(arguments,2):r),typeof e==`function`&&e.defaultProps!=null)for(o in e.defaultProps)s[o]===void 0&&(s[o]=e.defaultProps[o]);return x(e,s,i,a,null)}function x(e,t,n,a,o){var s={type:e,props:t,key:n,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:o??++i,__i:-1,__u:0};return o==null&&r.vnode!=null&&r.vnode(s),s}function S(e){return e.children}function C(e,t){this.props=e,this.context=t}function w(e,t){if(t==null)return e.__?w(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`?w(e):null}function T(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,i=[],a=[],o=v({},t);o.__v=t.__v+1,r.vnode&&r.vnode(o),ce(e.__P,o,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,i,n??w(t),!!(32&t.__u),a),o.__v=t.__v,o.__.__k[o.__i]=o,ue(i,o,a),t.__e=t.__=null,o.__e!=n&&ee(o)}}function ee(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}),ee(e)}function E(e){(!e.__d&&(e.__d=!0)&&a.push(e)&&!D.__r++||o!=r.debounceRendering)&&((o=r.debounceRendering)||s)(D)}function D(){try{for(var e,t=1;a.length;)a.length>t&&a.sort(c),e=a.shift(),t=a.length,T(e)}finally{a.length=D.__r=0}}function te(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,g,_,v,y,b=r&&r.__k||h,x=t.length;for(c=ne(n,t,b,c,x),d=0;d<x;d++)(p=n.__k[d])!=null&&(f=p.__i!=-1&&b[p.__i]||m,p.__i=d,v=ce(e,p,f,i,a,o,s,c,l,u),g=p.__e,p.ref&&f.ref!=p.ref&&(f.ref&&pe(f.ref,null,p),u.push(p.ref,p.__c||g,p)),_==null&&g!=null&&(_=g),(y=!!(4&p.__u))||f.__k===p.__k?c=re(p,c,e,y):typeof p.type==`function`&&v!==void 0?c=v:g&&(c=g.nextSibling),p.__u&=-7);return n.__e=_,c}function ne(e,t,n,r,i){var a,o,s,c,l,u=n.length,d=u,f=0;for(e.__k=Array(i),a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(typeof o==`string`||typeof o==`number`||typeof o==`bigint`||o.constructor==String?o=e.__k[a]=x(null,o,null,null,null):_(o)?o=e.__k[a]=x(S,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=x(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,c=a+f,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=O(o,n,c,d))!=-1&&(d--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>u?f--:i<u&&f++),typeof o.type!=`function`&&(o.__u|=4)):l!=c&&(l==c-1?f--:l==c+1?f++:(l>c?f--:f++,o.__u|=4))):e.__k[a]=null;if(d)for(a=0;a<u;a++)(s=n[a])!=null&&!(2&s.__u)&&(s.__e==r&&(r=w(s)),me(s,s));return r}function re(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=re(i[a],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=w(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function ie(e,t){return t=t||[],e==null||typeof e==`boolean`||(_(e)?e.some(function(e){ie(e,t)}):t.push(e)),t}function O(e,t,n,r){var i,a,o,s=e.key,c=e.type,l=t[n],u=l!=null&&(2&l.__u)==0;if(l===null&&s==null||u&&s==l.key&&c==l.type)return n;if(r>(u?1:0)){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])!=null&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function ae(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n==null?``:typeof n!=`number`||g.test(t)?n:n+`px`}function oe(e,t,n,r,i){var a,o;n: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||ae(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||ae(e.style,t,n[t])}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(l,`$1`)),o=t.toLowerCase(),t=o in e||t==`onFocusOut`||t==`onFocusIn`?o.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+a]=n,n?r?n.u=r.u:(n.u=u,e.addEventListener(t,a?f:d,a)):e.removeEventListener(t,a?f:d,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 n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function se(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t.t==null)t.t=u++;else if(t.t<n.u)return;return n(r.event?r.event(t):t)}}}function ce(e,t,n,i,a,o,s,c,l,u){var d,f,p,m,g,b,x,w,T,ee,E,D,ne,re,ie,O=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(l=!!(32&n.__u),o=[c=t.__e=n.__e]),(d=r.__b)&&d(t);n:if(typeof O==`function`)try{if(w=t.props,T=O.prototype&&O.prototype.render,ee=(d=O.contextType)&&i[d.__c],E=d?ee?ee.props.value:d.__:i,n.__c?x=(f=t.__c=n.__c).__=f.__E:(T?t.__c=f=new O(w,E):(t.__c=f=new C(w,E),f.constructor=O,f.render=he),ee&&ee.sub(f),f.state||(f.state={}),f.__n=i,p=f.__d=!0,f.__h=[],f._sb=[]),T&&f.__s==null&&(f.__s=f.state),T&&O.getDerivedStateFromProps!=null&&(f.__s==f.state&&(f.__s=v({},f.__s)),v(f.__s,O.getDerivedStateFromProps(w,f.__s))),m=f.props,g=f.state,f.__v=t,p)T&&O.getDerivedStateFromProps==null&&f.componentWillMount!=null&&f.componentWillMount(),T&&f.componentDidMount!=null&&f.__h.push(f.componentDidMount);else{if(T&&O.getDerivedStateFromProps==null&&w!==m&&f.componentWillReceiveProps!=null&&f.componentWillReceiveProps(w,E),t.__v==n.__v||!f.__e&&f.shouldComponentUpdate!=null&&!1===f.shouldComponentUpdate(w,f.__s,E)){t.__v!=n.__v&&(f.props=w,f.state=f.__s,f.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(e){e&&(e.__=t)}),h.push.apply(f.__h,f._sb),f._sb=[],f.__h.length&&s.push(f);break n}f.componentWillUpdate!=null&&f.componentWillUpdate(w,f.__s,E),T&&f.componentDidUpdate!=null&&f.__h.push(function(){f.componentDidUpdate(m,g,b)})}if(f.context=E,f.props=w,f.__P=e,f.__e=!1,D=r.__r,ne=0,T)f.state=f.__s,f.__d=!1,D&&D(t),d=f.render(f.props,f.state,f.context),h.push.apply(f.__h,f._sb),f._sb=[];else do f.__d=!1,D&&D(t),d=f.render(f.props,f.state,f.context),f.state=f.__s;while(f.__d&&++ne<25);f.state=f.__s,f.getChildContext!=null&&(i=v(v({},i),f.getChildContext())),T&&!p&&f.getSnapshotBeforeUpdate!=null&&(b=f.getSnapshotBeforeUpdate(m,g)),re=d!=null&&d.type===S&&d.key==null?de(d.props.children):d,c=te(e,_(re)?re:[re],t,n,i,a,o,s,c,l,u),f.base=t.__e,t.__u&=-161,f.__h.length&&s.push(f),x&&(f.__E=f.__=null)}catch(e){if(t.__v=null,l||o!=null)if(e.then){for(t.__u|=l?160:128;c&&c.nodeType==8&&c.nextSibling;)c=c.nextSibling;o[o.indexOf(c)]=null,t.__e=c}else{for(ie=o.length;ie--;)y(o[ie]);le(t)}else t.__e=n.__e,t.__k=n.__k,e.then||le(t);r.__e(e,t,n)}else o==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):c=t.__e=fe(n.__e,t,n,i,a,o,s,l,u);return(d=r.diffed)&&d(t),128&t.__u?void 0:c}function le(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(le))}function ue(e,t,n){for(var i=0;i<n.length;i++)pe(n[i],n[++i],n[++i]);r.__c&&r.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){r.__e(e,t.__v)}})}function de(e){return typeof e!=`object`||!e||e.__b>0?e:_(e)?e.map(de):v({},e)}function fe(e,t,i,a,o,s,c,l,u){var d,f,p,h,g,v,b,x=i.props||m,S=t.props,C=t.type;if(C==`svg`?o=`http://www.w3.org/2000/svg`:C==`math`?o=`http://www.w3.org/1998/Math/MathML`:o||(o=`http://www.w3.org/1999/xhtml`),s!=null){for(d=0;d<s.length;d++)if((g=s[d])&&`setAttribute`in g==!!C&&(C?g.localName==C:g.nodeType==3)){e=g,s[d]=null;break}}if(e==null){if(C==null)return document.createTextNode(S);e=document.createElementNS(o,C,S.is&&S),l&&(r.__m&&r.__m(t,s),l=!1),s=null}if(C==null)x===S||l&&e.data==S||(e.data=S);else{if(s=s&&n.call(e.childNodes),!l&&s!=null)for(x={},d=0;d<e.attributes.length;d++)x[(g=e.attributes[d]).name]=g.value;for(d in x)g=x[d],d==`dangerouslySetInnerHTML`?p=g:d==`children`||d in S||d==`value`&&`defaultValue`in S||d==`checked`&&`defaultChecked`in S||oe(e,d,null,g,o);for(d in S)g=S[d],d==`children`?h=g:d==`dangerouslySetInnerHTML`?f=g:d==`value`?v=g:d==`checked`?b=g:l&&typeof g!=`function`||x[d]===g||oe(e,d,g,x[d],o);if(f)l||p&&(f.__html==p.__html||f.__html==e.innerHTML)||(e.innerHTML=f.__html),t.__k=[];else if(p&&(e.innerHTML=``),te(t.type==`template`?e.content:e,_(h)?h:[h],t,i,a,C==`foreignObject`?`http://www.w3.org/1999/xhtml`:o,s,c,s?s[0]:i.__k&&w(i,0),l,u),s!=null)for(d=s.length;d--;)y(s[d]);l||(d=`value`,C==`progress`&&v==null?e.removeAttribute(`value`):v!=null&&(v!==e[d]||C==`progress`&&!v||C==`option`&&v!=x[d])&&oe(e,d,v,x[d],o),d=`checked`,b!=null&&b!=e[d]&&oe(e,d,b,x[d],o))}return e}function pe(e,t,n){try{if(typeof e==`function`){var i=typeof e.__u==`function`;i&&e.__u(),i&&t==null||(e.__u=e(t))}else e.current=t}catch(e){r.__e(e,n)}}function me(e,t,n){var i,a;if(r.unmount&&r.unmount(e),(i=e.ref)&&(i.current&&i.current!=e.__e||pe(i,null,t)),(i=e.__c)!=null){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(e){r.__e(e,t)}i.base=i.__P=null}if(i=e.__k)for(a=0;a<i.length;a++)i[a]&&me(i[a],t,n||typeof e.type!=`function`);n||y(e.__e),e.__c=e.__=e.__e=void 0}function he(e,t,n){return this.constructor(e,n)}function ge(e,t,i){var a,o,s,c;t==document&&(t=document.documentElement),r.__&&r.__(e,t),o=(a=typeof i==`function`)?null:i&&i.__k||t.__k,s=[],c=[],ce(t,e=(!a&&i||t).__k=b(S,null,[e]),o||m,m,t.namespaceURI,!a&&i?[i]:o?null:t.firstChild?n.call(t.childNodes):null,s,!a&&i?i:o?o.__e:t.firstChild,a,c),ue(s,e,c)}function _e(e){function t(e){var n,r;return this.getChildContext||(n=new Set,(r={})[t.__c]=this,this.getChildContext=function(){return r},this.componentWillUnmount=function(){n=null},this.shouldComponentUpdate=function(e){this.props.value!=e.value&&n.forEach(function(e){e.__e=!0,E(e)})},this.sub=function(e){n.add(e);var t=e.componentWillUnmount;e.componentWillUnmount=function(){n&&n.delete(e),t&&t.call(e)}}),e.children}return t.__c=`__cC`+ p++,t.__=e,t.Provider=t.__l=(t.Consumer=function(e,t){return e.children(t)}).contextType=t,t}n=h.slice,r={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!i.__)try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),o=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),o=i.__d),o)return i.__E=i}catch(t){e=t}throw e}},i=0,C.prototype.setState=function(e,t){var n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=v({},this.state);typeof e==`function`&&(e=e(v({},n),this.props)),e&&v(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),E(this))},C.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),E(this))},C.prototype.render=S,a=[],s=typeof Promise==`function`?Promise.prototype.then.bind(Promise.resolve()):setTimeout,c=function(e,t){return e.__v.__b-t.__v.__b},D.__r=0,l=/(PointerCapture)$|Capture$/i,u=0,d=se(!1),f=se(!0),p=0;var ve,k,ye,be,xe=0,Se=[],Ce=r,we=Ce.__b,Te=Ce.__r,Ee=Ce.diffed,De=Ce.__c,Oe=Ce.unmount,ke=Ce.__;function Ae(e,t){Ce.__h&&Ce.__h(k,e,xe||t),xe=0;var n=k.__H||(k.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function je(e){return xe=1,Me(Ue,e)}function Me(e,t,n){var r=Ae(ve++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Ue(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);t!==n&&(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=k,!k.__f)){var i=function(e,t,n){if(!r.__c.__H)return!0;var i=r.__c.__H.__.filter(function(e){return e.__c});if(i.every(function(e){return!e.__N}))return!a||a.call(this,e,t,n);var o=r.__c.props!==e;return i.some(function(e){if(e.__N){var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(o=!0)}}),a&&a.call(this,e,t,n)||o};k.__f=!0;var a=k.shouldComponentUpdate,o=k.componentWillUpdate;k.componentWillUpdate=function(e,t,n){if(this.__e){var r=a;a=void 0,i(e,t,n),a=r}o&&o.call(this,e,t,n)},k.shouldComponentUpdate=i}return r.__N||r.__}function Ne(e,t){var n=Ae(ve++,3);!Ce.__s&&He(n.__H,t)&&(n.__=e,n.u=t,k.__H.__h.push(n))}function Pe(e,t){var n=Ae(ve++,4);!Ce.__s&&He(n.__H,t)&&(n.__=e,n.u=t,k.__h.push(n))}function A(e){return xe=5,Fe(function(){return{current:e}},[])}function Fe(e,t){var n=Ae(ve++,7);return He(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function Ie(e,t){return xe=8,Fe(function(){return e},t)}function j(e){var t=k.context[e.__c],n=Ae(ve++,9);return n.c=e,t?(n.__??(n.__=!0,t.sub(k)),t.props.value):e.__}function Le(){for(var e;e=Se.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(Be),t.__h.some(Ve),t.__h=[]}catch(n){t.__h=[],Ce.__e(n,e.__v)}}}Ce.__b=function(e){k=null,we&&we(e)},Ce.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),ke&&ke(e,t)},Ce.__r=function(e){Te&&Te(e),ve=0;var t=(k=e.__c).__H;t&&(ye===k?(t.__h=[],k.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.some(Be),t.__h.some(Ve),t.__h=[],ve=0)),ye=k},Ce.diffed=function(e){Ee&&Ee(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Se.push(t)!==1&&be===Ce.requestAnimationFrame||((be=Ce.requestAnimationFrame)||ze)(Le)),t.__H.__.some(function(e){e.u&&(e.__H=e.u),e.u=void 0})),ye=k=null},Ce.__c=function(e,t){t.some(function(e){try{e.__h.some(Be),e.__h=e.__h.filter(function(e){return!e.__||Ve(e)})}catch(n){t.some(function(e){e.__h&&(e.__h=[])}),t=[],Ce.__e(n,e.__v)}}),De&&De(e,t)},Ce.unmount=function(e){Oe&&Oe(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(e){try{Be(e)}catch(e){t=e}}),n.__H=void 0,t&&Ce.__e(t,n.__v))};var Re=typeof requestAnimationFrame==`function`;function ze(e){var t,n=function(){clearTimeout(r),Re&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);Re&&(t=requestAnimationFrame(n))}function Be(e){var t=k,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),k=t}function Ve(e){var t=k;e.__c=e.__(),k=t}function He(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}function Ue(e,t){return typeof t==`function`?t(e):t}function We(e,t){for(var n in t)e[n]=t[n];return e}function Ge(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 Ke(e,t){var n=t(),r=je({t:{__:n,u:t}}),i=r[0].t,a=r[1];return Pe(function(){i.__=n,i.u=t,qe(i)&&a({t:i})},[e,n,t]),Ne(function(){return qe(i)&&a({t:i}),e(function(){qe(i)&&a({t:i})})},[e]),n}function qe(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 Je(e,t){this.props=e,this.context=t}(Je.prototype=new C).isPureReactComponent=!0,Je.prototype.shouldComponentUpdate=function(e,t){return Ge(this.props,e)||Ge(this.state,t)};var Ye=r.__b;r.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),Ye&&Ye(e)},typeof Symbol<`u`&&Symbol.for;var Xe=r.__e;r.__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??(t.__e=n.__e,t.__k=n.__k),i.__c(e,t)}Xe(e,t,n,r)};var Ze=r.unmount;function Qe(e,t,n){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach(function(e){typeof e.__c==`function`&&e.__c()}),e.__c.__H=null),(e=We({},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(e){return Qe(e,t,n)})),e}function $e(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(e){return $e(e,t,n)}),e.__c&&e.__c.__P===t&&(e.__e&&n.appendChild(e.__e),e.__c.__e=!0,e.__c.__P=n)),e}function et(){this.__u=0,this.o=null,this.__b=null}function tt(e){var t=e.__&&e.__.__c;return t&&t.__a&&t.__a(e)}function nt(){this.i=null,this.l=null}r.unmount=function(e){var t=e.__c;t&&(t.__z=!0),t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),Ze&&Ze(e)},(et.prototype=new C).__c=function(e,t){var n=t.__c,r=this;r.o??(r.o=[]),r.o.push(n);var i=tt(r.__v),a=!1,o=function(){a||r.__z||(a=!0,n.__R=null,i?i(c):c())};n.__R=o;var s=n.__P;n.__P=null;var c=function(){if(!--r.__u){if(r.state.__a){var e=r.state.__a;r.__v.__k[0]=$e(e,e.__c.__P,e.__c.__O)}var t;for(r.setState({__a:r.__b=null});t=r.o.pop();)t.__P=s,t.forceUpdate()}};r.__u++||32&t.__u||r.setState({__a:r.__b=r.__v.__k[0]}),e.then(o,o)},et.prototype.componentWillUnmount=function(){this.o=[]},et.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]=Qe(this.__b,n,r.__O=r.__P)}this.__b=null}var i=t.__a&&b(S,null,e.fallback);return i&&(i.__u&=-33),[b(S,null,t.__a?null:e.children),i]};var rt=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]}};(nt.prototype=new C).__a=function(e){var t=this,n=tt(t.__v),r=t.l.get(e);return r[0]++,function(i){var a=function(){t.props.revealOrder?(r.push(i),rt(t,e,r)):i()};n?n(a):a()}},nt.prototype.render=function(e){this.i=null,this.l=new Map;var t=ie(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},nt.prototype.componentDidUpdate=nt.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,n){rt(e,n,t)})};var it=typeof Symbol<`u`&&Symbol.for&&Symbol.for(`react.element`)||60103,at=/^(?: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]/,ot=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,st=/[A-Z0-9]/g,ct=typeof document<`u`,lt=function(e){return(typeof Symbol<`u`&&typeof Symbol()==`symbol`?/fil|che|rad/:/fil|che|ra/).test(e)};C.prototype.isReactComponent=!0,[`componentWillMount`,`componentWillReceiveProps`,`componentWillUpdate`].forEach(function(e){Object.defineProperty(C.prototype,e,{configurable:!0,get:function(){return this[`UNSAFE_`+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var ut=r.event;r.event=function(e){return ut&&(e=ut(e)),e.persist=function(){},e.isPropagationStopped=function(){return this.cancelBubble},e.isDefaultPrevented=function(){return this.defaultPrevented},e.nativeEvent=e};var dt={configurable:!0,get:function(){return this.class}},ft=r.vnode;r.vnode=function(e){typeof e.type==`string`&&function(e){var t=e.props,n=e.type,r={},i=n.indexOf(`-`)==-1;for(var a in t){var o=t[a];if(!(a===`value`&&`defaultValue`in t&&o==null||ct&&a===`children`&&n===`noscript`||a===`class`||a===`className`)){var s=a.toLowerCase();a===`defaultValue`&&`value`in t&&t.value==null?a=`value`:a===`download`&&!0===o?o=``:s===`translate`&&o===`no`?o=!1:s[0]===`o`&&s[1]===`n`?s===`ondoubleclick`?a=`ondblclick`:s!==`onchange`||n!==`input`&&n!==`textarea`||lt(t.type)?s===`onfocus`?a=`onfocusin`:s===`onblur`?a=`onfocusout`:ot.test(a)&&(a=s):s=a=`oninput`:i&&at.test(a)?a=a.replace(st,`-$&`).toLowerCase():o===null&&(o=void 0),s===`oninput`&&r[a=s]&&(a=`oninputCapture`),r[a]=o}}n==`select`&&(r.multiple&&Array.isArray(r.value)&&(r.value=ie(t.children).forEach(function(e){e.props.selected=r.value.indexOf(e.props.value)!=-1})),r.defaultValue!=null&&(r.value=ie(t.children).forEach(function(e){e.props.selected=r.multiple?r.defaultValue.indexOf(e.props.value)!=-1:r.defaultValue==e.props.value}))),t.class&&!t.className?(r.class=t.class,Object.defineProperty(r,`className`,dt)):t.className&&(r.class=r.className=t.className),e.props=r}(e),e.$$typeof=it,ft&&ft(e)};var pt=r.__r;r.__r=function(e){pt&&pt(e),e.__c};var mt=r.diffed;r.diffed=function(e){mt&&mt(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)};var ht=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e))},o=t=e(r,i,a);return a},gt=(e=>e?ht(e):ht),_t=e=>e;function vt(e){function t(t=_t){let n=Ie(()=>t(e.getState()),[t]);return Ke(e.subscribe,n)}return Object.assign(t,e)}function yt(){return e=>vt(gt()(e))}function bt(){if(typeof crypto.randomUUID==`function`)return crypto.randomUUID();let e=crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e,e=>e.toString(16).padStart(2,`0`));return[t.slice(0,4).join(``),t.slice(4,6).join(``),t.slice(6,8).join(``),t.slice(8,10).join(``),t.slice(10).join(``)].join(`-`)}var xt=Symbol.for(`immer-nothing`),St=Symbol.for(`immer-draftable`),M=Symbol.for(`immer-state`);function Ct(e,...t){throw Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var wt=Object,Tt=wt.getPrototypeOf,Et=`constructor`,Dt=`prototype`,Ot=`configurable`,kt=`enumerable`,At=`writable`,jt=`value`,Mt=e=>!!e&&!!e[M];function Nt(e){return e?It(e)||Wt(e)||!!e[St]||!!e[Et]?.[St]||Gt(e)||Kt(e):!1}var Pt=wt[Dt][Et].toString(),Ft=new WeakMap;function It(e){if(!e||!qt(e))return!1;let t=Tt(e);if(t===null||t===wt[Dt])return!0;let n=wt.hasOwnProperty.call(t,Et)&&t[Et];if(n===Object)return!0;if(!Jt(n))return!1;let r=Ft.get(n);return r===void 0&&(r=Function.toString.call(n),Ft.set(n,r)),r===Pt}function Lt(e){return Mt(e)||Ct(15,e),e[M].base_}function Rt(e,t,n=!0){zt(e)===0?(n?Reflect.ownKeys(e):wt.keys(e)).forEach(n=>{t(n,e[n],e)}):e.forEach((n,r)=>t(r,n,e))}function zt(e){let t=e[M];return t?t.type_:Wt(e)?1:Gt(e)?2:Kt(e)?3:0}var Bt=(e,t,n=zt(e))=>n===2?e.has(t):wt[Dt].hasOwnProperty.call(e,t),Vt=(e,t,n=zt(e))=>n===2?e.get(t):e[t],Ht=(e,t,n,r=zt(e))=>{r===2?e.set(t,n):r===3?e.add(n):e[t]=n};function Ut(e,t){return e===t?e!==0||1/e==1/t:e!==e&&t!==t}var Wt=Array.isArray,Gt=e=>e instanceof Map,Kt=e=>e instanceof Set,qt=e=>typeof e==`object`,Jt=e=>typeof e==`function`,Yt=e=>typeof e==`boolean`;function Xt(e){let t=+e;return Number.isInteger(t)&&String(t)===e}var Zt=e=>qt(e)?e?.[M]:null,Qt=e=>e.copy_||e.base_,$t=e=>{let t=Zt(e);return t?t.copy_??t.base_:e},en=e=>e.modified_?e.copy_:e.base_;function tn(e,t){if(Gt(e))return new Map(e);if(Kt(e))return new Set(e);if(Wt(e))return Array[Dt].slice.call(e);let n=It(e);if(t===!0||t===`class_only`&&!n){let t=wt.getOwnPropertyDescriptors(e);delete t[M];let n=Reflect.ownKeys(t);for(let r=0;r<n.length;r++){let i=n[r],a=t[i];a[At]===!1&&(a[At]=!0,a[Ot]=!0),(a.get||a.set)&&(t[i]={[Ot]:!0,[At]:!0,[kt]:a[kt],[jt]:e[i]})}return wt.create(Tt(e),t)}else{let t=Tt(e);if(t!==null&&n)return{...e};let r=wt.create(t);return wt.assign(r,e)}}function nn(e,t=!1){return on(e)||Mt(e)||!Nt(e)?e:(zt(e)>1&&wt.defineProperties(e,{set:an,add:an,clear:an,delete:an}),wt.freeze(e),t&&Rt(e,(e,t)=>{nn(t,!0)},!1),e)}function rn(){Ct(2)}var an={[jt]:rn};function on(e){return e===null||!qt(e)?!0:wt.isFrozen(e)}var sn=`MapSet`,cn=`Patches`,ln=`ArrayMethods`,un={};function dn(e){let t=un[e];return t||Ct(0,e),t}var fn=e=>!!un[e];function pn(e,t){un[e]||(un[e]=t)}var mn,N=()=>mn,P=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:fn(sn)?dn(sn):void 0,arrayMethodsPlugin_:fn(ln)?dn(ln):void 0});function hn(e,t){t&&(e.patchPlugin_=dn(cn),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function gn(e){_n(e),e.drafts_.forEach(vn),e.drafts_=null}function _n(e){e===mn&&(mn=e.parent_)}var F=e=>mn=P(mn,e);function vn(e){let t=e[M];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function yn(e,t){t.unfinalizedDrafts_=t.drafts_.length;let n=t.drafts_[0];if(e!==void 0&&e!==n){n[M].modified_&&(gn(t),Ct(4)),Nt(e)&&(e=bn(t,e));let{patchPlugin_:r}=t;r&&r.generateReplacementPatches_(n[M].base_,e,t)}else e=bn(t,n);return xn(t,e,!0),gn(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e===xt?void 0:e}function bn(e,t){if(on(t))return t;let n=t[M];if(!n)return I(t,e.handledSet_,e);if(!Cn(n,e))return t;if(!n.modified_)return n.base_;if(!n.finalized_){let{callbacks_:t}=n;if(t)for(;t.length>0;)t.pop()(e);Dn(n,e)}return n.copy_}function xn(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&nn(t,n)}function Sn(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var Cn=(e,t)=>e.scope_===t,wn=[];function Tn(e,t,n,r){let i=Qt(e),a=e.type_;if(r!==void 0&&Vt(i,r,a)===t){Ht(i,r,n,a);return}if(!e.draftLocations_){let t=e.draftLocations_=new Map;Rt(i,(e,n)=>{if(Mt(n)){let r=t.get(n)||[];r.push(e),t.set(n,r)}})}let o=e.draftLocations_.get(t)??wn;for(let e of o)Ht(i,e,n,a)}function En(e,t,n){e.callbacks_.push(function(r){let i=t;if(!i||!Cn(i,r))return;r.mapSetPlugin_?.fixSetContents(i);let a=en(i);Tn(e,i.draft_??i,a,n),Dn(i,r)})}function Dn(e,t){if(e.modified_&&!e.finalized_&&(e.type_===3||e.type_===1&&e.allIndicesReassigned_||(e.assigned_?.size??0)>0)){let{patchPlugin_:n}=t;if(n){let r=n.getPath(e);r&&n.generatePatches_(e,r,t)}Sn(e)}}function On(e,t,n){let{scope_:r}=e;if(Mt(n)){let i=n[M];Cn(i,r)&&i.callbacks_.push(function(){In(e),Tn(e,n,en(i),t)})}else Nt(n)&&e.callbacks_.push(function(){let i=Qt(e);e.type_===3?i.has(n)&&I(n,r.handledSet_,r):Vt(i,t,e.type_)===n&&r.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&I(Vt(e.copy_,t,e.type_),r.handledSet_,r)})}function I(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||Mt(e)||t.has(e)||!Nt(e)||on(e)?e:(t.add(e),Rt(e,(r,i)=>{if(Mt(i)){let t=i[M];Cn(t,n)&&(Ht(e,r,en(t),e.type_),Sn(t))}else Nt(i)&&I(i,t,n)}),e)}function kn(e,t){let n=Wt(e),r={type_:n?1:0,scope_:t?t.scope_:N(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0},i=r,a=An;n&&(i=[r],a=jn);let{revoke:o,proxy:s}=Proxy.revocable(i,a);return r.draft_=s,r.revoke_=o,[s,r]}var An={get(e,t){if(t===M)return e;let n=e.scope_.arrayMethodsPlugin_,r=e.type_===1&&typeof t==`string`;if(r&&n?.isArrayOperationMethod(t))return n.createMethodInterceptor(e,t);let i=Qt(e);if(!Bt(i,t,e.type_))return Nn(e,i,t);let a=i[t];if(e.finalized_||!Nt(a)||r&&e.operationMethod&&n?.isMutatingArrayMethod(e.operationMethod)&&Xt(t))return a;if(a===Mn(e.base_,t)){In(e);let n=e.type_===1?+t:t,r=Rn(e.scope_,a,e,n);return e.copy_[n]=r}return a},has(e,t){return t in Qt(e)},ownKeys(e){return Reflect.ownKeys(Qt(e))},set(e,t,n){let r=Pn(Qt(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){let r=Mn(Qt(e),t),i=r?.[M];if(i&&i.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(Ut(n,r)&&(n!==void 0||Bt(e.base_,t,e.type_)))return!0;In(e),Fn(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])?!0:(e.copy_[t]=n,e.assigned_.set(t,!0),On(e,t,n),!0)},deleteProperty(e,t){return In(e),Mn(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),Fn(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let n=Qt(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{[At]:!0,[Ot]:e.type_!==1||t!==`length`,[kt]:r[kt],[jt]:n[t]}},defineProperty(){Ct(11)},getPrototypeOf(e){return Tt(e.base_)},setPrototypeOf(){Ct(12)}},jn={};for(let e in An){let t=An[e];jn[e]=function(){let e=arguments;return e[0]=e[0][0],t.apply(this,e)}}jn.deleteProperty=function(e,t){return jn.set.call(this,e,t,void 0)},jn.set=function(e,t,n){return An.set.call(this,e[0],t,n,e[0])};function Mn(e,t){let n=e[M];return(n?Qt(n):e)[t]}function Nn(e,t,n){let r=Pn(t,n);return r?jt in r?r[jt]:r.get?.call(e.draft_):void 0}function Pn(e,t){if(!(t in e))return;let n=Tt(e);for(;n;){let e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=Tt(n)}}function Fn(e){e.modified_||(e.modified_=!0,e.parent_&&Fn(e.parent_))}function In(e){e.copy_||(e.assigned_=new Map,e.copy_=tn(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Ln=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(e,t,n)=>{if(Jt(e)&&!Jt(t)){let n=t;t=e;let r=this;return function(e=n,...i){return r.produce(e,e=>t.call(this,e,...i))}}Jt(t)||Ct(6),n!==void 0&&!Jt(n)&&Ct(7);let r;if(Nt(e)){let i=F(this),a=Rn(i,e,void 0),o=!0;try{r=t(a),o=!1}finally{o?gn(i):_n(i)}return hn(i,n),yn(r,i)}else if(!e||!qt(e)){if(r=t(e),r===void 0&&(r=e),r===xt&&(r=void 0),this.autoFreeze_&&nn(r,!0),n){let t=[],i=[];dn(cn).generateReplacementPatches_(e,r,{patches_:t,inversePatches_:i}),n(t,i)}return r}else Ct(1,e)},this.produceWithPatches=(e,t)=>{if(Jt(e))return(t,...n)=>this.produceWithPatches(t,t=>e(t,...n));let n,r;return[this.produce(e,t,(e,t)=>{n=e,r=t}),n,r]},Yt(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),Yt(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),Yt(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Nt(e)||Ct(8),Mt(e)&&(e=zn(e));let t=F(this),n=Rn(t,e,void 0);return n[M].isManual_=!0,_n(t),n}finishDraft(e,t){let n=e&&e[M];(!n||!n.isManual_)&&Ct(9);let{scope_:r}=n;return hn(r,t),yn(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--){let r=t[n];if(r.path.length===0&&r.op===`replace`){e=r.value;break}}n>-1&&(t=t.slice(n+1));let r=dn(cn).applyPatches_;return Mt(e)?r(e,t):this.produce(e,e=>r(e,t))}};function Rn(e,t,n,r){let[i,a]=Gt(t)?dn(sn).proxyMap_(t,n):Kt(t)?dn(sn).proxySet_(t,n):kn(t,n);return(n?.scope_??N()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?En(n,a,r):a.callbacks_.push(function(e){e.mapSetPlugin_?.fixSetContents(a);let{patchPlugin_:t}=e;a.modified_&&t&&t.generatePatches_(a,[],e)}),i}function zn(e){return Mt(e)||Ct(10,e),Bn(e)}function Bn(e){if(!Nt(e)||on(e))return e;let t=e[M],n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=tn(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=tn(e,!0);return Rt(n,(e,t)=>{Ht(n,e,Bn(t))},r),t&&(t.finalized_=!1),n}function Vn(){function e(n,r=[]){if(n.key_!==void 0){let e=n.parent_.copy_??n.parent_.base_,t=Zt(Vt(e,n.key_)),i=Vt(e,n.key_);if(i===void 0||i!==n.draft_&&i!==n.base_&&i!==n.copy_||t!=null&&t.base_!==n.base_)return null;let a=n.parent_.type_===3,o;if(a){let e=n.parent_;o=Array.from(e.drafts_.keys()).indexOf(n.key_)}else o=n.key_;if(!(a&&e.size>o||Bt(e,o)))return null;r.push(o)}if(n.parent_)return e(n.parent_,r);r.reverse();try{t(n.copy_,r)}catch{return null}return r}function t(e,t){let n=e;for(let e=0;e<t.length-1;e++){let r=t[e];if(n=Vt(n,r),!qt(n)||n===null)throw Error(`Cannot resolve path at '${t.join(`/`)}'`)}return n}let n=`replace`,r=`remove`;function i(e,t,n){if(e.scope_.processedForPatches_.has(e))return;e.scope_.processedForPatches_.add(e);let{patches_:r,inversePatches_:i}=n;switch(e.type_){case 0:case 2:return o(e,t,r,i);case 1:return a(e,t,r,i);case 3:return s(e,t,r,i)}}function a(e,t,i,a){let{base_:o,assigned_:s}=e,c=e.copy_;c.length<o.length&&([o,c]=[c,o],[i,a]=[a,i]);let l=e.allIndicesReassigned_===!0;for(let e=0;e<o.length;e++){let r=c[e],u=o[e];if((l||s?.get(e.toString()))&&r!==u){let o=r?.[M];if(o&&o.modified_)continue;let s=t.concat([e]);i.push({op:n,path:s,value:d(r)}),a.push({op:n,path:s,value:d(u)})}}for(let e=o.length;e<c.length;e++){let n=t.concat([e]);i.push({op:`add`,path:n,value:d(c[e])})}for(let e=c.length-1;o.length<=e;--e){let n=t.concat([e]);a.push({op:r,path:n})}}function o(e,t,i,a){let{base_:o,copy_:s,type_:c}=e;Rt(e.assigned_,(e,l)=>{let u=Vt(o,e,c),f=Vt(s,e,c),p=l?Bt(o,e)?n:`add`:r;if(u===f&&p===n)return;let m=t.concat(e);i.push(p===r?{op:p,path:m}:{op:p,path:m,value:d(f)}),a.push(p===`add`?{op:r,path:m}:p===r?{op:`add`,path:m,value:d(u)}:{op:n,path:m,value:d(u)})})}function s(e,t,n,i){let{base_:a,copy_:o}=e,s=0;a.forEach(e=>{if(!o.has(e)){let a=t.concat([s]);n.push({op:r,path:a,value:e}),i.unshift({op:`add`,path:a,value:e})}s++}),s=0,o.forEach(e=>{if(!a.has(e)){let a=t.concat([s]);n.push({op:`add`,path:a,value:e}),i.unshift({op:r,path:a,value:e})}s++})}function c(e,t,r){let{patches_:i,inversePatches_:a}=r;i.push({op:n,path:[],value:t===xt?void 0:t}),a.push({op:n,path:[],value:e})}function l(e,t){return t.forEach(t=>{let{path:i,op:a}=t,o=e;for(let e=0;e<i.length-1;e++){let t=zt(o),n=i[e];typeof n!=`string`&&typeof n!=`number`&&(n=``+n),(t===0||t===1)&&(n===`__proto__`||n===Et)&&Ct(19),Jt(o)&&n===Dt&&Ct(19),o=Vt(o,n),qt(o)||Ct(18,i.join(`/`))}let s=zt(o),c=u(t.value),l=i[i.length-1];switch(a){case n:switch(s){case 2:return o.set(l,c);case 3:Ct(16);default:return o[l]=c}case`add`:switch(s){case 1:return l===`-`?o.push(c):o.splice(l,0,c);case 2:return o.set(l,c);case 3:return o.add(c);default:return o[l]=c}case r:switch(s){case 1:return o.splice(l,1);case 2:return o.delete(l);case 3:return o.delete(t.value);default:return delete o[l]}default:Ct(17,a)}}),e}function u(e){if(!Nt(e))return e;if(Wt(e))return e.map(u);if(Gt(e))return new Map(Array.from(e.entries()).map(([e,t])=>[e,u(t)]));if(Kt(e))return new Set(Array.from(e).map(u));let t=Object.create(Tt(e));for(let n in e)t[n]=u(e[n]);return Bt(e,St)&&(t[St]=e[St]),t}function d(e){return Mt(e)?u(e):e}pn(cn,{applyPatches_:l,generatePatches_:i,generateReplacementPatches_:c,getPath:e})}function Hn(){class e extends Map{constructor(e,t){super(),this[M]={type_:2,parent_:t,scope_:t?t.scope_:N(),modified_:!1,finalized_:!1,copy_:void 0,assigned_:void 0,base_:e,draft_:this,isManual_:!1,revoked_:!1,callbacks_:[]}}get size(){return Qt(this[M]).size}has(e){return Qt(this[M]).has(e)}set(e,t){let r=this[M];return o(r),(!Qt(r).has(e)||Qt(r).get(e)!==t)&&(n(r),Fn(r),r.assigned_.set(e,!0),r.copy_.set(e,t),r.assigned_.set(e,!0),On(r,e,t)),this}delete(e){if(!this.has(e))return!1;let t=this[M];return o(t),n(t),Fn(t),t.base_.has(e)?t.assigned_.set(e,!1):t.assigned_.delete(e),t.copy_.delete(e),!0}clear(){let e=this[M];o(e),Qt(e).size&&(n(e),Fn(e),e.assigned_=new Map,Rt(e.base_,t=>{e.assigned_.set(t,!1)}),e.copy_.clear())}forEach(e,t){let n=this[M];Qt(n).forEach((n,r,i)=>{e.call(t,this.get(r),r,this)})}get(e){let t=this[M];o(t);let r=Qt(t).get(e);if(t.finalized_||!Nt(r)||r!==t.base_.get(e))return r;let i=Rn(t.scope_,r,t,e);return n(t),t.copy_.set(e,i),i}keys(){return Qt(this[M]).keys()}values(){let e=this.keys();return{[Symbol.iterator]:()=>this.values(),next:()=>{let t=e.next();return t.done?t:{done:!1,value:this.get(t.value)}}}}entries(){let e=this.keys();return{[Symbol.iterator]:()=>this.entries(),next:()=>{let t=e.next();if(t.done)return t;let n=this.get(t.value);return{done:!1,value:[t.value,n]}}}}[Symbol.iterator](){return this.entries()}}function t(t,n){let r=new e(t,n);return[r,r[M]]}function n(e){e.copy_||(e.assigned_=new Map,e.copy_=new Map(e.base_))}class r extends Set{constructor(e,t){super(),this[M]={type_:3,parent_:t,scope_:t?t.scope_:N(),modified_:!1,finalized_:!1,copy_:void 0,base_:e,draft_:this,drafts_:new Map,revoked_:!1,isManual_:!1,assigned_:void 0,callbacks_:[]}}get size(){return Qt(this[M]).size}has(e){let t=this[M];return o(t),t.copy_?!!(t.copy_.has(e)||t.drafts_.has(e)&&t.copy_.has(t.drafts_.get(e))):t.base_.has(e)}add(e){let t=this[M];return o(t),this.has(e)||(a(t),Fn(t),t.copy_.add(e),On(t,e,e)),this}delete(e){if(!this.has(e))return!1;let t=this[M];return o(t),a(t),Fn(t),t.copy_.delete(e)||(t.drafts_.has(e)?t.copy_.delete(t.drafts_.get(e)):!1)}clear(){let e=this[M];o(e),Qt(e).size&&(a(e),Fn(e),e.copy_.clear())}values(){let e=this[M];return o(e),a(e),e.copy_.values()}entries(){let e=this[M];return o(e),a(e),e.copy_.entries()}keys(){return this.values()}[Symbol.iterator](){return this.values()}forEach(e,t){let n=this.values(),r=n.next();for(;!r.done;)e.call(t,r.value,r.value,this),r=n.next()}}function i(e,t){let n=new r(e,t);return[n,n[M]]}function a(e){e.copy_||(e.copy_=new Set,e.base_.forEach(t=>{if(Nt(t)){let n=Rn(e.scope_,t,e,t);e.drafts_.set(t,n),e.copy_.add(n)}else e.copy_.add(t)}))}function o(e){e.revoked_&&Ct(3,JSON.stringify(Qt(e)))}function s(e){if(e.type_===3&&e.copy_){let t=new Set(e.copy_);e.copy_.clear(),t.forEach(t=>{e.copy_.add($t(t))})}}pn(sn,{proxyMap_:t,proxySet_:i,fixSetContents:s})}var Un=new Ln().produce,Wn=e=>(t,n,r)=>(r.setState=(e,n,...r)=>t(typeof e==`function`?Un(e):e,n,...r),e(r.setState,n,r)),Gn={$:`variable`,_:`temporary`,\"@\":`local`,\"%\":`transient`},Kn=Object.fromEntries(Object.entries(Gn).map(([e,t])=>[t,e])),qn=new Set(Object.keys(Gn));function Jn(e){return e!==void 0&&qn.has(e)}function Yn(e,t){return t.className&&(e.className=t.className),t.id&&(e.id=t.id),e}var Xn={SIGIL_SCOPES:Gn,withSelectors:Yn},Zn=`{`,Qn=`}`,{SIGIL_SCOPES:$n,withSelectors:er}=Xn,tr=new Set([`area`,`base`,`br`,`col`,`embed`,`hr`,`img`,`input`,`link`,`meta`,`param`,`source`,`track`,`wbr`]),nr={elseif:`if`,else:`if`,case:`switch`,default:`switch`,next:`timed`},rr=new Set([`if`,`switch`,`timed`]),ir=[[`|`,!1],[`->`,!1],[`<-`,!0]],ar={},or=/^<[a-zA-Z0-9.!#$%&'*+/=?^_`|~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*>$/;function sr(e,t){let n=(n,r)=>{let i=e.slice(n,r),a=i.trim(),o=t+n+(a?i.indexOf(a):0);return{value:a,start:o,end:o+a.length}};for(let[t,r]of ir){let i=e.indexOf(t);if(i===-1)continue;let a=n(0,i),o=n(i+t.length,e.length),[s,c]=r?[o,a]:[a,o];return{display:s.value,target:c.value,targetStart:c.start,targetEnd:c.end}}let r=n(0,e.length);return{display:r.value,target:r.value,targetStart:r.start,targetEnd:r.end}}function cr(e){return`\"`+e.replace(/[\\\\\"]/g,`\\\\$&`)+`\"`}function lr(e){let t=[],n=``;for(let[r,i]of e)i&&(r===`.`?t.push(i):n=i);return er({},{className:t.join(` `),id:n})}function ur(e){return e.lex===`html`?(e.isClose?`</`:`<`)+e.tag+`>`:Zn+(e.isClose?`/`:``)+e.name+Qn}function dr(e){return e.lex===`html`?`</`+e.tag+`>`:Zn+`/`+e.name+Qn}function fr(e){return`line `+e.start.line+`, column `+e.start.column}function pr(e,t){return e.lex===t.lex&&e.lower===t.lower}function mr(e,t,n){return n.lex=e,n.start=t.start.offset,n.end=t.end.offset,n.loc=t,n}function hr(e){switch(e.lex){case`text`:return e.comment?{type:`text`,value:e.value,comment:!0}:{type:`text`,value:e.value};case`link`:return er({type:`macro`,name:`link`,rawArgs:cr(e.display)+` `+cr(e.target),children:[]},e);case`variable`:return er({type:`variable`,name:e.name,scope:e.scope},e);case`expression`:return er({type:`expression`,expression:e.expression},e);default:return e}}function gr(e){let t={start:e.start,end:e.end};switch(e.lex){case`text`:return{type:`text`,value:e.value,...t};case`link`:return er({type:`link`,display:e.display,target:e.target,targetStart:e.targetStart,targetEnd:e.targetEnd,...t},e);case`variable`:return er({type:`variable`,name:e.name,scope:e.scope,...t},e);case`expression`:return er({type:`expression`,expression:e.expression,...t},e);case`macro`:return er({type:`macro`,name:e.name,rawArgs:e.rawArgs,isClose:e.isClose,...t},e);case`html`:return{type:`html`,tag:e.tag,attributes:e.attributes,isClose:e.isClose,isSelfClose:e.isSelfClose,...t}}}function _r(e,t){let n=[],r=null,i=e=>{if(e!=null){if(Array.isArray(e))return e.forEach(i);if(e.lex===`text`&&!e.escape&&!e.comment&&r&&r.lex===`text`&&!r.escape&&!r.comment&&r.end===e.start){r.value+=e.value,r.end=e.end;return}n.push(e),r=e}};return i(e),t?n.map(t):n}var vr=class extends SyntaxError{constructor(e,t,n,r){super(e),this.expected=t,this.found=n,this.location=r,this.name=`SyntaxError`}format(e){let t=`Error: `+this.message;if(this.location){let n=null,r=e.find(e=>e.source===this.location.source);r&&(n=r.text.split(/\\r\\n|\\n|\\r/g));let i=this.location.start,a=this.location.source&&typeof this.location.source.offset==`function`?this.location.source.offset(i):i,o=this.location.source+`:`+a.line+`:`+a.column;if(n){let e=this.location.end,r=``.padEnd(a.line.toString().length,` `),s=n[i.line-1],c=(i.line===e.line?e.column:s.length+1)-i.column||1;t+=`\n --> `+o+`\n`+r+` |\n`+a.line+` | `+s+`\n`+r+` | `+``.padEnd(i.column-1,` `)+``.padEnd(c,`^`)}else t+=`\n at `+o}return t}static buildMessage(e,t){function n(e){return e.codePointAt(0).toString(16).toUpperCase()}let r=Object.prototype.hasOwnProperty.call(RegExp.prototype,`unicode`)?RegExp(`[\\\\p{C}\\\\p{Mn}\\\\p{Mc}]`,`gu`):null;function i(e){return r?e.replace(r,e=>`\\\\u{`+n(e)+`}`):e}function a(e){return i(e.replace(/\\\\/g,`\\\\\\\\`).replace(/\"/g,`\\\\\"`).replace(/\\0/g,`\\\\0`).replace(/\\t/g,`\\\\t`).replace(/\\n/g,`\\\\n`).replace(/\\r/g,`\\\\r`).replace(/[\\x00-\\x0F]/g,e=>`\\\\x0`+n(e)).replace(/[\\x10-\\x1F\\x7F-\\x9F]/g,e=>`\\\\x`+n(e)))}function o(e){return i(e.replace(/\\\\/g,`\\\\\\\\`).replace(/\\]/g,`\\\\]`).replace(/\\^/g,`\\\\^`).replace(/-/g,`\\\\-`).replace(/\\0/g,`\\\\0`).replace(/\\t/g,`\\\\t`).replace(/\\n/g,`\\\\n`).replace(/\\r/g,`\\\\r`).replace(/[\\x00-\\x0F]/g,e=>`\\\\x0`+n(e)).replace(/[\\x10-\\x1F\\x7F-\\x9F]/g,e=>`\\\\x`+n(e)))}let s={literal(e){return`\"`+a(e.text)+`\"`},class(e){let t=e.parts.map(e=>Array.isArray(e)?o(e[0])+`-`+o(e[1]):o(e));return`[`+(e.inverted?`^`:``)+t.join(``)+`]`+(e.unicode?`u`:``)},any(){return`any character`},end(){return`end of input`},other(e){return e.description}};function c(e){return s[e.type](e)}function l(e){let t=e.map(c);if(t.sort(),t.length>0){let e=1;for(let n=1;n<t.length;n++)t[n-1]!==t[n]&&(t[e]=t[n],e++);t.length=e}switch(t.length){case 1:return t[0];case 2:return t[0]+` or `+t[1];default:return t.slice(0,-1).join(`, `)+`, or `+t[t.length-1]}}function u(e){return e?`\"`+a(e)+`\"`:`end of input`}return`Expected `+l(e)+` but `+u(t)+` found.`}};function yr(e,t){t=t===void 0?{}:t;let n={},r=t.grammarSource,i={Markup:jn,Tokens:Un,SelectorsPrefix:br},a=jn,o=`\\x3C!--`,s=/^[^\\\\{[<]/,c=/^[{}]/,l=/^[$_@%(!\\/a-zA-Z]/,u=/^[.#]/,d=/^[a-zA-Z0-9_\\-]/,f=/^[$_@%]/,p=/^[a-zA-Z0-9_.]/,m=/^[$_@%(!]/,h=/^[a-zA-Z]/,g=/^[^ \\t\\n\\r\\v\\f\\xA0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000\\uFEFF}]/,_=/^[a-zA-Z0-9.!#$%&'*+\\/=?\\^_`|~\\-]/,v=/^[a-zA-Z0-9.\\-]/,y=/^[\\t-\\r \\/>\\xA0\\u1680\\u2000-\\u200A\\u2028-\\u2029\\u202F\\u205F\\u3000\\uFEFF]/,b=/^[a-zA-Z0-9\\-]/,x=/^[\\t-\\r \"'\\/<->{}\\xA0\\u1680\\u2000-\\u200A\\u2028-\\u2029\\u202F\\u205F\\u3000\\uFEFF]/,S=/^[^\"]/,C=/^[^']/,w=/^[\"']/,T=/^[^ \\t\\n\\r\\v\\f\\xA0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000\\uFEFF>]/,ee=/^[ \\t\\n\\r\\v\\f\\xA0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000\\uFEFF]/,E=Tn(),D=wn([`\\\\`,`{`,`[`,`<`],!0,!1,!1),te=Cn(`\\x3C!--`,!1),ne=Cn(`>`,!1),re=Cn(`->`,!1),ie=Cn(`-->`,!1),O=Cn(`\\\\`,!1),ae=wn([`{`,`}`],!1,!1,!1),oe=Cn(`{`,!1),se=wn([`$`,`_`,`@`,`%`,`(`,`!`,`/`,[`a`,`z`],[`A`,`Z`]],!1,!1,!1),ce=Cn(`<`,!1),le=Cn(`[`,!1),ue=Cn(`[[`,!1),de=Cn(`]]`,!1),fe=Cn(` `,!1),pe=wn([`.`,`#`],!1,!1,!1),me=wn([[`a`,`z`],[`A`,`Z`],[`0`,`9`],`_`,`-`],!1,!1,!1),he=wn([`$`,`_`,`@`,`%`],!1,!1,!1),ge=wn([[`a`,`z`],[`A`,`Z`],[`0`,`9`],`_`,`.`],!1,!1,!1),_e=Cn(`}`,!1),ve=wn([`$`,`_`,`@`,`%`,`(`,`!`],!1,!1,!1),k=Cn(`/`,!1),ye=wn([[`a`,`z`],[`A`,`Z`]],!1,!1,!1),be=wn([` `,`\t`,`\n`,`\\r`,`\\v`,`\\f`,`\\xA0`,` `,[` `,` `],`\\u2028`,`\\u2029`,` `,` `,` `,``,`}`],!0,!1,!1),xe=wn([[`a`,`z`],[`A`,`Z`],[`0`,`9`],`.`,`!`,`#`,`$`,`%`,`&`,`'`,`*`,`+`,`/`,`=`,`?`,`^`,`_`,\"`\",`|`,`~`,`-`],!1,!1,!1),Se=Cn(`@`,!1),Ce=wn([[`a`,`z`],[`A`,`Z`],[`0`,`9`],`.`,`-`],!1,!1,!1),we=wn([[`\t`,`\\r`],` `,`/`,`>`,`\\xA0`,` `,[` `,` `],[`\\u2028`,`\\u2029`],` `,` `,` `,``],!1,!1,!1),Te=Cn(`</`,!1),Ee=wn([[`a`,`z`],[`A`,`Z`],[`0`,`9`],`-`],!1,!1,!1),De=wn([[`\t`,`\\r`],` `,`\"`,`'`,`/`,[`<`,`>`],`{`,`}`,`\\xA0`,` `,[` `,` `],[`\\u2028`,`\\u2029`],` `,` `,` `,``],!1,!1,!1),Oe=Cn(`=`,!1),ke=Cn(`\"`,!1),Ae=wn([`\"`],!0,!1,!1),je=Cn(`'`,!1),Me=wn([`'`],!0,!1,!1),Ne=wn([`\"`,`'`],!1,!1,!1),Pe=wn([` `,`\t`,`\n`,`\\r`,`\\v`,`\\f`,`\\xA0`,` `,[` `,` `],`\\u2028`,`\\u2029`,` `,` `,` `,``,`>`],!0,!1,!1),A=wn([` `,`\t`,`\n`,`\\r`,`\\v`,`\\f`,`\\xA0`,` `,[` `,` `],`\\u2028`,`\\u2029`,` `,` `,` `,``],!1,!1,!1);function Fe(e){return e}function Ie(e){R(ur(e)+` must be directly inside {`+nr[e.lower]+Qn,e.loc)}function j(e){R(ur(e)+` closes nothing: no `+(e.lex===`html`?`<`+e.tag+`>`:Zn+e.name+Qn)+` is open here`,e.loc)}function Le(e){return _r(e,hr)}function Re(e){return e.kind===`open`}function ze(e){return Br=e.lower,L.isRaw(Br)}function Be(e,t){return t}function Ve(e){return L.isBlock(e.lower)}function He(e,t){return t}function Ue(e){return null}function We(e,t){return Ur(e,t)}function Ge(){return!Lr}function Ke(e){return!e.isSelfClose}function qe(e,t){return t}function Je(e,t){let n={type:`html`,tag:e.tag,attributes:e.attributes,children:[]};return t&&(Hr(e,t),n.children=t.children),n}function Ye(e,t,n){return{children:e,branches:t,end:n}}function Xe(e,t){return{tag:e,children:t}}function Ze(){return null}function Qe(e){return e.kind===`branch`}function $e(e){return e}function et(e){return e.kind===`close`}function tt(e){return e}function nt(){return!Lr}function rt(e){return e}function it(t){return Vr(L.rawBodyEnd(e,t,Br))}function at(e){return Rr-yn()}function ot(e,t,n){return{children:t?[{type:`text`,value:t}]:[],branches:[],end:n}}function st(){return{children:[],branches:[],end:null}}function ct(e){return _r(e,gr)}function lt(){return!Lr}function ut(e){return e}function dt(){return!Lr}function ft(e){return tr.has(e.lower)?null:e}function pt(e){return Br=e.lower,e.kind===`open`&&L.isRaw(Br)}function mt(e,t){return t}function ht(e,t){return t?[e,t]:e}function gt(t){return Vr(L.rawBodyEnd(e,t,Br))}function _t(e){return Rr-yn()}function vt(e,t,n){let r={start:{offset:e},end:{offset:e+t.length}};return[t?mr(`text`,r,{value:t}):null,n]}function yt(){return yn()}function bt(e){return mr(`text`,bn(),{value:e})}function xt(e){let t=mr(`text`,bn(),{value:e});return t.comment=!0,t}function St(e){return e.length%2==1}function M(e,t){return t}function Ct(t,n){let r=bn(),i=e.charAt(r.end.offset);if(Lr){if(!n&&i!==Zn&&i!==Qn)return mr(`text`,r,{value:t});let e=mr(`text`,r,{value:`\\\\`.repeat(t.length>>1)+(n||``)});return e.escape=!0,e}if(!n)return mr(`text`,r,{value:t});let a=mr(`text`,r,{value:t.slice(1)});a.end=r.end.offset-2;let o=mr(`text`,r,{value:n});return o.start=r.end.offset-2,o.escape=!0,t.length>1?[a,o]:o}function wt(){return mr(`text`,bn(),{value:Zn})}function Tt(){return!Lr}function Et(){return mr(`text`,bn(),{value:`<`})}function Dt(){return mr(`text`,bn(),{value:`[`})}function Ot(){return!Lr}function kt(e,t,n){return er(mr(`link`,bn(),sr(n,t)),e)}function At(){return!Lr}function jt(){R(`Unclosed link: [[ without ]]`,bn())}function Mt(e){return lr(e)}function Nt(){return ar}function Pt(e,t){return{...e,end:t}}function Ft(e,t){return[e,t]}function It(e,t,n){return er(mr(`variable`,bn(),{name:n,scope:$n[t]}),e)}function Lt(e,t){return er(mr(`expression`,bn(),{expression:t}),e)}function Rt(){R(`Unclosed `+Zn+e.substr(bn().end.offset,1)+`…: no } ends it`,bn())}function zt(t){return Vr(L.closeBrace(e,t,t))}function Bt(e){return Rr-yn()}function Vt(e,t){return t}function Ht(t,n,r,i,a){return Vr(L.closeBrace(e,a,n))}function Ut(e,t,n,r,i){return Rr-yn()}function Wt(e,t,n,r,i,a){return a}function Gt(e,t,n,r,i,a){let o=bn(),s=r.toLowerCase(),c=mr(`macro`,o,{name:r,lower:s,rawArgs:``,isClose:!!n});return a===null&&R(`Unclosed `+Zn+(n?`/`:``)+r+`…: no } ends the macro`,o),c.rawArgs=a.trim(),n?(e!==ar&&R(`A closing tag takes no selectors: `+ur(c),o),c.rawArgs&&R(`A closing tag takes no arguments: `+Zn+`/`+r+` `+c.rawArgs+Qn,o),c.kind=`close`):(er(c,e),c.kind=Object.prototype.hasOwnProperty.call(nr,s)?`branch`:`open`),c}function Kt(e){R(`A closing tag starts with a letter after `+Zn+`/`,bn())}function qt(e){return or.test(e)}function Jt(e){return mr(`text`,bn(),{value:e})}function Yt(){return!Lr}function Xt(e){return tr.has(e.lower)}function Zt(e){return null}function Qt(e,t,n){let r=e.toLowerCase();return mr(`html`,bn(),{tag:e,lower:r,attributes:z(t),isClose:!1,isSelfClose:!!n||tr.has(r)})}function $t(t,n){let r=e.charAt(n);r||R(`Unclosed tag <`+t+`: no > ends it (write &lt; for a < that starts no tag)`,bn());let i={source:bn().source,start:{offset:n,line:0,column:0},end:{offset:n+1,line:0,column:0}};R(`Unexpected `+JSON.stringify(r)+` in the tag <`+t+`>: expected an attribute, or > to end the tag`,i)}function en(e){return mr(`html`,bn(),{tag:e,lower:e.toLowerCase(),attributes:{},isClose:!0,isSelfClose:!1})}function tn(e){return zr=L.isCodeAttribute(e),!0}function nn(e,t){return t}function rn(e,t){return[e,t??``]}function an(e){return e}function on(e){return e}function sn(e){R(`Unclosed attribute value: the `+e+` here has no closing `+e,bn())}function cn(){return!zr}function ln(e){return e.length%2==1}function un(){return!zr}function dn(t,n){return Vr(L.closeBrace(e,n,t))}function fn(e,t){return Rr-yn()}function pn(){return!zr}function mn(){return zr}let N=t.peg$currPos|0,P=N,hn=[{line:1,column:1}],gn=N,_n=t.peg$maxFailExpected||[],F=t.peg$silentFails|0,vn;if(t.startRule){if(!(t.startRule in i))throw Error(`Can't start parsing from rule \"`+t.startRule+`\".`);a=i[t.startRule]}function yn(){return P}function bn(){return On(P,N)}function xn(e,t){throw t=t===void 0?On(P,N):t,kn(e,t)}function Sn(t=N){let n=e.codePointAt(t);return n===void 0?``:String.fromCodePoint(n)}function Cn(e,t){return{type:`literal`,text:e,ignoreCase:t}}function wn(e,t,n,r){return{type:`class`,parts:e,inverted:t,ignoreCase:n,unicode:r}}function Tn(){return{type:`any`}}function En(){return{type:`end`}}function Dn(t){let n=hn[t],r;if(n)return n;if(t>=hn.length)r=hn.length-1;else for(r=t;!hn[--r];);for(n=hn[r],n={line:n.line,column:n.column};r<t;)e.charCodeAt(r)===10?(n.line++,n.column=1):n.column++,r++;return hn[t]=n,n}function On(e,t,n){let i=Dn(e),a=Dn(t),o={source:r,start:{offset:e,line:i.line,column:i.column},end:{offset:t,line:a.line,column:a.column}};return n&&r&&typeof r.offset==`function`&&(o.start=r.offset(o.start),o.end=r.offset(o.end)),o}function I(e){N<gn||(N>gn&&(gn=N,_n=[]),_n.push(e))}function kn(e,t){return new vr(e,null,null,t)}function An(e,t,n){return new vr(vr.buildMessage(e,t),e,t,n)}function jn(){let e,t,r;return e=N,t=Nn(),r=Mn(),r===n?(N=e,e=n):(P=e,e=Fe(t)),e}function Mn(){let t,r;return t=N,F++,e.length>N?(r=e.charAt(N),N++):(r=n,F===0&&I(E)),F--,r===n?t=void 0:(N=t,t=n),t===n&&(t=N,r=Bn(),r!==n&&(P=t,r=Ie(r)),t=r,t===n&&(t=N,r=Vn(),r!==n&&(P=t,r=j(r)),t=r)),t}function Nn(){let e,t,r;for(e=N,t=[],r=Pn();r!==n;)t.push(r),r=Pn();return P=e,t=Le(t),e=t,e}function Pn(){let e;return e=qn(),e===n&&(e=Yn(),e===n&&(e=Jn(),e===n&&(e=ir(),e===n&&(e=Dr(),e===n&&(e=In(),e===n&&(e=Or(),e===n&&(e=Cr(),e===n&&(e=Fn(),e===n&&(e=Xn()))))))))),e}function Fn(){let e,t,r,i,a,o;return e=N,t=Tr(),t===n?(N=e,e=n):(P=N,r=Re(t),r=r?void 0:n,r===n?(N=e,e=n):(i=N,P=N,a=ze(t),a=a?void 0:n,a===n?(N=i,i=n):(o=Hn(),o===n?(N=i,i=n):(P=i,i=Be(t,o))),i===n&&(i=N,P=N,a=Ve(t),a=a?void 0:n,a===n?(N=i,i=n):(o=Ln(),o===n?(N=i,i=n):(P=i,i=He(t,o))),i===n&&(i=N,a=``,P=i,a=Ue(t),i=a)),i===n?(N=e,e=n):(P=e,e=We(t,i)))),e}function In(){let e,t,r,i,a,o;return e=N,P=N,t=Ge(),t=t?void 0:n,t===n?(N=e,e=n):(r=kr(),r===n?(N=e,e=n):(i=N,P=N,a=Ke(r),a=a?void 0:n,a===n?(N=i,i=n):(o=Ln(),o===n?(N=i,i=n):(P=i,i=qe(r,o))),i===n&&(i=null),P=e,e=Je(r,i))),e}function Ln(){let e,t,r,i;if(e=N,t=Nn(),t!==n){for(r=[],i=Rn();i!==n;)r.push(i),i=Rn();i=zn(),i===n?(N=e,e=n):(P=e,e=Ye(t,r,i))}else N=e,e=n;return e}function Rn(){let e,t,r;return e=N,t=Bn(),t===n?(N=e,e=n):(r=Nn(),r===n?(N=e,e=n):(P=e,e=Xe(t,r))),e}function zn(){let t,r,i;return t=Vn(),t===n&&(t=N,r=N,F++,e.length>N?(i=e.charAt(N),N++):(i=n,F===0&&I(E)),F--,i===n?r=void 0:(N=r,r=n),r!==n&&(P=t,r=Ze()),t=r),t}function Bn(){let e,t,r;return e=N,t=Tr(),t===n?(N=e,e=n):(P=N,r=Qe(t),r=r?void 0:n,r===n?(N=e,e=n):(P=e,e=$e(t))),e}function Vn(){let e,t,r;return e=N,t=Tr(),t===n?(N=e,e=n):(P=N,r=et(t),r=r?void 0:n,r===n?(N=e,e=n):(P=e,e=tt(t))),e===n&&(e=N,P=N,t=nt(),t=t?void 0:n,t===n?(N=e,e=n):(r=Ar(),r===n?(N=e,e=n):(P=e,e=rt(r)))),e}function Hn(){let t,r,i,a,o,s,c,l;if(t=N,r=Kn(),P=N,i=it(r),i=i?void 0:n,i!==n){for(a=N,o=at(r),s=N,c=[],c.length>=(o|0)?l=n:e.length>N?(l=e.charAt(N),N++):(l=n,F===0&&I(E));l!==n;)c.push(l),c.length>=(o|0)?l=n:e.length>N?(l=e.charAt(N),N++):(l=n,F===0&&I(E));c.length<(o|0)?(N=s,s=n):s=c,o=s,a=o===n?o:e.substring(a,N),a===n?(N=t,t=n):(o=Vn(),o===n?(N=t,t=n):(P=t,t=ot(r,a,o)))}else N=t,t=n;return t===n&&(t=N,r=``,P=t,r=st(),t=r),t}function Un(){let e,t,r;for(e=N,t=[],r=Wn();r!==n;)t.push(r),r=Wn();return P=e,t=ct(t),e=t,e}function Wn(){let e,t,r,i,a;return e=qn(),e===n&&(e=Yn(),e===n&&(e=Jn(),e===n&&(e=ir(),e===n&&(e=Dr(),e===n&&(e=N,P=N,t=lt(),t=t?void 0:n,t===n?(N=e,e=n):(r=kr(),r===n?(N=e,e=n):(P=e,e=ut(r))),e===n&&(e=N,P=N,t=dt(),t=t?void 0:n,t===n?(N=e,e=n):(r=Ar(),r===n?(N=e,e=n):(P=e,e=ft(r))),e===n&&(e=Cr(),e===n&&(e=N,t=Tr(),t===n?(N=e,e=n):(r=N,P=N,i=pt(t),i=i?void 0:n,i===n?(N=r,r=n):(a=Gn(),a===n?(N=r,r=n):(P=r,r=mt(t,a))),r===n&&(r=null),P=e,e=ht(t,r)),e===n&&(e=Xn()))))))))),e}function Gn(){let t,r,i,a,o,s,c,l;if(t=N,r=Kn(),P=N,i=gt(r),i=i?void 0:n,i!==n){for(a=N,o=_t(r),s=N,c=[],c.length>=(o|0)?l=n:e.length>N?(l=e.charAt(N),N++):(l=n,F===0&&I(E));l!==n;)c.push(l),c.length>=(o|0)?l=n:e.length>N?(l=e.charAt(N),N++):(l=n,F===0&&I(E));c.length<(o|0)?(N=s,s=n):s=c,o=s,a=o===n?o:e.substring(a,N),a===n?(N=t,t=n):(o=Vn(),o===n?(N=t,t=n):(P=t,t=vt(r,a,o)))}else N=t,t=n;return t}function Kn(){let e,t;return e=N,t=``,P=e,t=yt(),e=t,e}function qn(){let t,r,i,a;if(t=N,r=N,i=[],a=e.charAt(N),s.test(a)?N++:(a=n,F===0&&I(D)),a!==n)for(;a!==n;)i.push(a),a=e.charAt(N),s.test(a)?N++:(a=n,F===0&&I(D));else i=n;return r=i===n?i:e.substring(r,N),r!==n&&(P=t,r=bt(r)),t=r,t}function Jn(){let t,r,i,a,s,c,l,u,d;if(t=N,r=N,i=N,e.substr(N,4)===o?(a=o,N+=4):(a=n,F===0&&I(te)),a!==n){if(e.charCodeAt(N)===62?(s=`>`,N++):(s=n,F===0&&I(ne)),s===n&&(e.substr(N,2)===`->`?(s=`->`,N+=2):(s=n,F===0&&I(re)),s===n)){for(s=N,c=[],l=N,u=N,F++,e.substr(N,3)===`-->`?(d=`-->`,N+=3):(d=n,F===0&&I(ie)),F--,d===n?u=void 0:(N=u,u=n),u===n?(N=l,l=n):(e.length>N?(d=e.charAt(N),N++):(d=n,F===0&&I(E)),d===n?(N=l,l=n):(u=[u,d],l=u));l!==n;)c.push(l),l=N,u=N,F++,e.substr(N,3)===`-->`?(d=`-->`,N+=3):(d=n,F===0&&I(ie)),F--,d===n?u=void 0:(N=u,u=n),u===n?(N=l,l=n):(e.length>N?(d=e.charAt(N),N++):(d=n,F===0&&I(E)),d===n?(N=l,l=n):(u=[u,d],l=u));e.substr(N,3)===`-->`?(l=`-->`,N+=3):(l=n,F===0&&I(ie)),l===n?(N=s,s=n):(c=[c,l],s=c)}s===n?(N=i,i=n):(a=[a,s],i=a)}else N=i,i=n;return r=i===n?i:e.substring(r,N),r!==n&&(P=t,r=xt(r)),t=r,t}function Yn(){let t,r,i,a,o;if(t=N,r=N,i=[],e.charCodeAt(N)===92?(a=`\\\\`,N++):(a=n,F===0&&I(O)),a!==n)for(;a!==n;)i.push(a),e.charCodeAt(N)===92?(a=`\\\\`,N++):(a=n,F===0&&I(O));else i=n;return r=i===n?i:e.substring(r,N),r===n?(N=t,t=n):(i=N,P=N,a=St(r),a=a?void 0:n,a===n?(N=i,i=n):(o=e.charAt(N),c.test(o)?N++:(o=n,F===0&&I(ae)),o===n?(N=i,i=n):(P=i,i=M(r,o))),i===n&&(i=null),P=t,t=Ct(r,i)),t}function Xn(){let t,r,i,a,o,s;return t=N,e.charCodeAt(N)===123?(r=`{`,N++):(r=n,F===0&&I(oe)),r===n?(N=t,t=n):(i=N,F++,a=N,o=yr(),o===n?(N=a,a=n):(s=e.charAt(N),l.test(s)?N++:(s=n,F===0&&I(se)),s===n?(N=a,a=n):(o=[o,s],a=o)),F--,a===n?i=void 0:(N=i,i=n),i===n?(N=t,t=n):(P=t,t=wt())),t===n&&(t=N,r=N,F++,i=N,P=N,a=Tt(),a=a?void 0:n,a===n?(N=i,i=n):(o=Ar(),o===n?(N=i,i=n):(a=[a,o],i=a)),F--,i===n?r=void 0:(N=r,r=n),r===n?(N=t,t=n):(e.charCodeAt(N)===60?(i=`<`,N++):(i=n,F===0&&I(ce)),i===n?(N=t,t=n):(P=t,t=Et())),t===n&&(t=N,e.charCodeAt(N)===91?(r=`[`,N++):(r=n,F===0&&I(le)),r!==n&&(P=t,r=Dt()),t=r)),t}function ir(){let t,r,i,a,o,s,c;return t=N,P=N,r=Ot(),r=r?void 0:n,r===n?(N=t,t=n):(e.substr(N,2)===`[[`?(i=`[[`,N+=2):(i=n,F===0&&I(ue)),i===n?(N=t,t=n):(a=yr(),a===n?(N=t,t=n):(o=Kn(),s=N,c=cr(),s=e.substring(s,N),e.substr(N,2)===`]]`?(c=`]]`,N+=2):(c=n,F===0&&I(de)),c===n?(N=t,t=n):(P=t,t=kt(a,o,s))))),t===n&&(t=N,P=N,r=At(),r=r?void 0:n,r===n?(N=t,t=n):(e.substr(N,2)===`[[`?(i=`[[`,N+=2):(i=n,F===0&&I(ue)),i===n?(N=t,t=n):(P=t,t=jt()))),t}function cr(){let t,r,i,a;for(t=[],r=N,i=N,F++,e.substr(N,2)===`]]`?(a=`]]`,N+=2):(a=n,F===0&&I(de)),a===n&&(e.substr(N,2)===`[[`?(a=`[[`,N+=2):(a=n,F===0&&I(ue))),F--,a===n?i=void 0:(N=i,i=n),i===n?(N=r,r=n):(e.length>N?(a=e.charAt(N),N++):(a=n,F===0&&I(E)),a===n?(N=r,r=n):(i=[i,a],r=i));r!==n;)t.push(r),r=N,i=N,F++,e.substr(N,2)===`]]`?(a=`]]`,N+=2):(a=n,F===0&&I(de)),a===n&&(e.substr(N,2)===`[[`?(a=`[[`,N+=2):(a=n,F===0&&I(ue))),F--,a===n?i=void 0:(N=i,i=n),i===n?(N=r,r=n):(e.length>N?(a=e.charAt(N),N++):(a=n,F===0&&I(E)),a===n?(N=r,r=n):(i=[i,a],r=i));return t}function yr(){let t,r,i;if(t=N,r=[],i=xr(),i!==n)for(;i!==n;)r.push(i),i=xr();else r=n;return r===n?(N=t,t=n):(e.charCodeAt(N)===32?(i=` `,N++):(i=n,F===0&&I(fe)),i===n&&(i=null),P=t,t=Mt(r)),t===n&&(t=N,r=``,P=t,r=Nt(),t=r),t}function br(){let t,r,i,a,o;if(t=N,r=yr(),r!==n){for(i=Kn(),a=[],e.length>N?(o=e.charAt(N),N++):(o=n,F===0&&I(E));o!==n;)a.push(o),e.length>N?(o=e.charAt(N),N++):(o=n,F===0&&I(E));P=t,t=Pt(r,i)}else N=t,t=n;return t}function xr(){let t,r,i,a,o;if(t=N,r=e.charAt(N),u.test(r)?N++:(r=n,F===0&&I(pe)),r!==n){for(i=N,a=[],o=Sr();o!==n;)a.push(o),o=Sr();i=e.substring(i,N),P=t,t=Ft(r,i)}else N=t,t=n;return t}function Sr(){let t,r,i,a,o;if(t=e.charAt(N),d.test(t)?N++:(t=n,F===0&&I(me)),t===n)if(t=N,e.charCodeAt(N)===123?(r=`{`,N++):(r=n,F===0&&I(oe)),r!==n)if(i=e.charAt(N),f.test(i)?N++:(i=n,F===0&&I(he)),i!==n){for(a=[],o=e.charAt(N),p.test(o)?N++:(o=n,F===0&&I(ge));o!==n;)a.push(o),o=e.charAt(N),p.test(o)?N++:(o=n,F===0&&I(ge));e.charCodeAt(N)===125?(o=`}`,N++):(o=n,F===0&&I(_e)),o===n?(N=t,t=n):(r=[r,i,a,o],t=r)}else N=t,t=n;else N=t,t=n;return t}function Cr(){let t,r,i,a,o,s,c;if(t=N,e.charCodeAt(N)===123?(r=`{`,N++):(r=n,F===0&&I(oe)),r!==n)if(i=yr(),i!==n)if(a=e.charAt(N),f.test(a)?N++:(a=n,F===0&&I(he)),a!==n){for(o=N,s=[],c=e.charAt(N),p.test(c)?N++:(c=n,F===0&&I(ge));c!==n;)s.push(c),c=e.charAt(N),p.test(c)?N++:(c=n,F===0&&I(ge));o=e.substring(o,N),e.charCodeAt(N)===125?(s=`}`,N++):(s=n,F===0&&I(_e)),s===n?(N=t,t=n):(P=t,t=It(i,a,o))}else N=t,t=n;else N=t,t=n;else N=t,t=n;return t===n&&(t=N,e.charCodeAt(N)===123?(r=`{`,N++):(r=n,F===0&&I(oe)),r===n?(N=t,t=n):(i=yr(),i===n?(N=t,t=n):(a=N,F++,o=e.charAt(N),m.test(o)?N++:(o=n,F===0&&I(ve)),F--,o===n?a=n:(N=a,a=void 0),a===n?(N=t,t=n):(o=wr(),o===n?(N=t,t=n):(e.charCodeAt(N)===125?(s=`}`,N++):(s=n,F===0&&I(_e)),s===n?(N=t,t=n):(P=t,t=Lt(i,o)))))),t===n&&(t=N,e.charCodeAt(N)===123?(r=`{`,N++):(r=n,F===0&&I(oe)),r===n?(N=t,t=n):(i=yr(),i===n?(N=t,t=n):(a=N,F++,o=e.charAt(N),m.test(o)?N++:(o=n,F===0&&I(ve)),F--,o===n?a=n:(N=a,a=void 0),a===n?(N=t,t=n):(P=t,t=Rt()))))),t}function wr(){let t,r,i,a,o,s,c,l;if(t=N,r=Kn(),P=N,i=zt(r),i=i?void 0:n,i!==n){for(a=N,o=Bt(r),s=N,c=[],c.length>=(o|0)?l=n:e.length>N?(l=e.charAt(N),N++):(l=n,F===0&&I(E));l!==n;)c.push(l),c.length>=(o|0)?l=n:e.length>N?(l=e.charAt(N),N++):(l=n,F===0&&I(E));c.length<(o|0)?(N=s,s=n):s=c,o=s,a=o===n?o:e.substring(a,N),a===n?(N=t,t=n):(P=t,t=Vt(r,a))}else N=t,t=n;return t}function Tr(){let t,r,i,a,o,s,c,l,u,d,f,p,m,h;if(t=N,e.charCodeAt(N)===123?(r=`{`,N++):(r=n,F===0&&I(oe)),r!==n)if(i=yr(),i!==n)if(a=Kn(),e.charCodeAt(N)===47?(o=`/`,N++):(o=n,F===0&&I(k)),o===n&&(o=null),s=Er(),s!==n){if(c=Kn(),l=N,P=N,u=Ht(i,a,o,s,c),u=u?void 0:n,u!==n){for(d=N,f=Ut(i,a,o,s,c),p=N,m=[],m.length>=(f|0)?h=n:e.length>N?(h=e.charAt(N),N++):(h=n,F===0&&I(E));h!==n;)m.push(h),m.length>=(f|0)?h=n:e.length>N?(h=e.charAt(N),N++):(h=n,F===0&&I(E));m.length<(f|0)?(N=p,p=n):p=m,f=p,d=f===n?f:e.substring(d,N),d===n?(N=l,l=n):(e.charCodeAt(N)===125?(f=`}`,N++):(f=n,F===0&&I(_e)),f===n?(N=l,l=n):(P=l,l=Wt(i,a,o,s,c,d)))}else N=l,l=n;l===n&&(l=null),P=t,t=Gt(i,a,o,s,c,l)}else N=t,t=n;else N=t,t=n;else N=t,t=n;return t===n&&(t=N,e.charCodeAt(N)===123?(r=`{`,N++):(r=n,F===0&&I(oe)),r===n?(N=t,t=n):(i=yr(),i===n?(N=t,t=n):(e.charCodeAt(N)===47?(a=`/`,N++):(a=n,F===0&&I(k)),a===n?(N=t,t=n):(P=t,t=Kt(i))))),t}function Er(){let t,r,i,a,o;if(t=N,r=N,i=e.charAt(N),h.test(i)?N++:(i=n,F===0&&I(ye)),i!==n){for(a=[],o=e.charAt(N),g.test(o)?N++:(o=n,F===0&&I(be));o!==n;)a.push(o),o=e.charAt(N),g.test(o)?N++:(o=n,F===0&&I(be));i=[i,a],r=i}else N=r,r=n;return t=r===n?r:e.substring(t,N),t}function Dr(){let t,r,i,a,o,s,c,l;if(t=N,r=N,i=N,e.charCodeAt(N)===60?(a=`<`,N++):(a=n,F===0&&I(ce)),a!==n){if(o=[],s=e.charAt(N),_.test(s)?N++:(s=n,F===0&&I(xe)),s!==n)for(;s!==n;)o.push(s),s=e.charAt(N),_.test(s)?N++:(s=n,F===0&&I(xe));else o=n;if(o!==n)if(e.charCodeAt(N)===64?(s=`@`,N++):(s=n,F===0&&I(Se)),s!==n){if(c=[],l=e.charAt(N),v.test(l)?N++:(l=n,F===0&&I(Ce)),l!==n)for(;l!==n;)c.push(l),l=e.charAt(N),v.test(l)?N++:(l=n,F===0&&I(Ce));else c=n;c===n?(N=i,i=n):(e.charCodeAt(N)===62?(l=`>`,N++):(l=n,F===0&&I(ne)),l===n?(N=i,i=n):(a=[a,o,s,c,l],i=a))}else N=i,i=n;else N=i,i=n}else N=i,i=n;return r=i===n?i:e.substring(r,N),r===n?(N=t,t=n):(P=N,i=qt(r),i=i?void 0:n,i===n?(N=t,t=n):(P=t,t=Jt(r))),t}function Or(){let e,t,r,i;return e=N,P=N,t=Yt(),t=t?void 0:n,t===n?(N=e,e=n):(r=Ar(),r===n?(N=e,e=n):(P=N,i=Xt(r),i=i?void 0:n,i===n?(N=e,e=n):(P=e,e=Zt(r)))),e}function kr(){let t,r,i,a,o,s,c;if(t=N,e.charCodeAt(N)===60?(r=`<`,N++):(r=n,F===0&&I(ce)),r!==n)if(i=jr(),i!==n){for(a=[],o=Mr();o!==n;)a.push(o),o=Mr();o=Fr(),e.charCodeAt(N)===47?(s=`/`,N++):(s=n,F===0&&I(k)),s===n&&(s=null),e.charCodeAt(N)===62?(c=`>`,N++):(c=n,F===0&&I(ne)),c===n?(N=t,t=n):(P=t,t=Qt(i,a,s))}else N=t,t=n;else N=t,t=n;if(t===n)if(t=N,e.charCodeAt(N)===60?(r=`<`,N++):(r=n,F===0&&I(ce)),r!==n)if(i=jr(),i!==n)if(a=N,F++,o=e.charAt(N),y.test(o)?N++:(o=n,F===0&&I(we)),o===n&&(o=N,F++,e.length>N?(s=e.charAt(N),N++):(s=n,F===0&&I(E)),F--,s===n?o=void 0:(N=o,o=n)),F--,o===n?a=n:(N=a,a=void 0),a!==n){for(o=[],s=Mr();s!==n;)o.push(s),s=Mr();s=Fr(),c=Kn(),P=t,t=$t(i,c)}else N=t,t=n;else N=t,t=n;else N=t,t=n;return t}function Ar(){let t,r,i,a;return t=N,e.substr(N,2)===`</`?(r=`</`,N+=2):(r=n,F===0&&I(Te)),r===n?(N=t,t=n):(i=jr(),i===n?(N=t,t=n):(Fr(),e.charCodeAt(N)===62?(a=`>`,N++):(a=n,F===0&&I(ne)),a===n?(N=t,t=n):(P=t,t=en(i)))),t}function jr(){let t,r,i,a,o;if(t=N,r=N,i=e.charAt(N),h.test(i)?N++:(i=n,F===0&&I(ye)),i!==n){for(a=[],o=e.charAt(N),b.test(o)?N++:(o=n,F===0&&I(Ee));o!==n;)a.push(o),o=e.charAt(N),b.test(o)?N++:(o=n,F===0&&I(Ee));i=[i,a],r=i}else N=r,r=n;return t=r===n?r:e.substring(t,N),t}function Mr(){let t,r,i,a,o,s,c;if(t=N,Fr(),r=N,i=[],a=N,o=N,F++,s=e.charAt(N),x.test(s)?N++:(s=n,F===0&&I(De)),F--,s===n?o=void 0:(N=o,o=n),o===n?(N=a,a=n):(e.length>N?(s=e.charAt(N),N++):(s=n,F===0&&I(E)),s===n?(N=a,a=n):(o=[o,s],a=o)),a!==n)for(;a!==n;)i.push(a),a=N,o=N,F++,s=e.charAt(N),x.test(s)?N++:(s=n,F===0&&I(De)),F--,s===n?o=void 0:(N=o,o=n),o===n?(N=a,a=n):(e.length>N?(s=e.charAt(N),N++):(s=n,F===0&&I(E)),s===n?(N=a,a=n):(o=[o,s],a=o));else i=n;return r=i===n?i:e.substring(r,N),r===n?(N=t,t=n):(P=N,i=tn(r),i=i?void 0:n,i===n?(N=t,t=n):(a=N,o=Fr(),e.charCodeAt(N)===61?(s=`=`,N++):(s=n,F===0&&I(Oe)),s===n?(N=a,a=n):(Fr(),c=Nr(),c===n?(N=a,a=n):(P=a,a=nn(r,c))),a===n&&(a=null),P=t,t=rn(r,a))),t}function Nr(){let t,r,i,a,o;if(t=N,e.charCodeAt(N)===34?(r=`\"`,N++):(r=n,F===0&&I(ke)),r!==n){for(i=N,a=[],o=Pr(),o===n&&(o=e.charAt(N),S.test(o)?N++:(o=n,F===0&&I(Ae)));o!==n;)a.push(o),o=Pr(),o===n&&(o=e.charAt(N),S.test(o)?N++:(o=n,F===0&&I(Ae)));i=e.substring(i,N),e.charCodeAt(N)===34?(a=`\"`,N++):(a=n,F===0&&I(ke)),a===n?(N=t,t=n):(P=t,t=an(i))}else N=t,t=n;if(t===n){if(t=N,e.charCodeAt(N)===39?(r=`'`,N++):(r=n,F===0&&I(je)),r!==n){for(i=N,a=[],o=Pr(),o===n&&(o=e.charAt(N),C.test(o)?N++:(o=n,F===0&&I(Me)));o!==n;)a.push(o),o=Pr(),o===n&&(o=e.charAt(N),C.test(o)?N++:(o=n,F===0&&I(Me)));i=e.substring(i,N),e.charCodeAt(N)===39?(a=`'`,N++):(a=n,F===0&&I(je)),a===n?(N=t,t=n):(P=t,t=on(i))}else N=t,t=n;if(t===n&&(t=N,r=e.charAt(N),w.test(r)?N++:(r=n,F===0&&I(Ne)),r!==n&&(P=t,r=sn(r)),t=r,t===n)){for(t=N,r=[],i=e.charAt(N),T.test(i)?N++:(i=n,F===0&&I(Pe));i!==n;)r.push(i),i=e.charAt(N),T.test(i)?N++:(i=n,F===0&&I(Pe));t=e.substring(t,N)}}return t}function Pr(){let t,r,i,a,o,s,l,u,d,p,m,g,_,v;if(t=N,P=N,r=cn(),r=r?void 0:n,r!==n){if(i=N,a=[],e.charCodeAt(N)===92?(o=`\\\\`,N++):(o=n,F===0&&I(O)),o!==n)for(;o!==n;)a.push(o),e.charCodeAt(N)===92?(o=`\\\\`,N++):(o=n,F===0&&I(O));else a=n;i=a===n?a:e.substring(i,N),i===n?(N=t,t=n):(a=N,P=N,o=ln(i),o=o?void 0:n,o===n?(N=a,a=n):(s=e.charAt(N),c.test(s)?N++:(s=n,F===0&&I(ae)),s===n?(N=a,a=n):(o=[o,s],a=o)),a===n&&(a=null),r=[r,i,a],t=r)}else N=t,t=n;if(t===n){if(t=N,P=N,r=un(),r=r?void 0:n,r!==n)if(e.charCodeAt(N)===123?(i=`{`,N++):(i=n,F===0&&I(oe)),i!==n)if(a=yr(),a!==n)if(o=Kn(),e.charCodeAt(N)===47?(s=`/`,N++):(s=n,F===0&&I(k)),s===n&&(s=null),l=Er(),l!==n)if(u=Kn(),P=N,d=dn(o,u),d=d?void 0:n,d!==n){for(p=N,m=fn(o,u),g=N,_=[],_.length>=(m|0)?v=n:e.length>N?(v=e.charAt(N),N++):(v=n,F===0&&I(E));v!==n;)_.push(v),_.length>=(m|0)?v=n:e.length>N?(v=e.charAt(N),N++):(v=n,F===0&&I(E));_.length<(m|0)?(N=g,g=n):g=_,m=g,p=m===n?m:e.substring(p,N),p===n?(N=t,t=n):(e.charCodeAt(N)===125?(m=`}`,N++):(m=n,F===0&&I(_e)),m===n?(N=t,t=n):(r=[r,i,a,o,s,l,u,d,p,m],t=r))}else N=t,t=n;else N=t,t=n;else N=t,t=n;else N=t,t=n;else N=t,t=n;t===n&&(t=N,P=N,r=pn(),r=r?void 0:n,r===n?(N=t,t=n):(e.charCodeAt(N)===123?(i=`{`,N++):(i=n,F===0&&I(oe)),i===n?(N=t,t=n):(a=yr(),a===n?(N=t,t=n):(o=N,F++,s=N,e.charCodeAt(N)===47?(l=`/`,N++):(l=n,F===0&&I(k)),l===n&&(l=null),u=e.charAt(N),h.test(u)?N++:(u=n,F===0&&I(ye)),u===n?(N=s,s=n):(l=[l,u],s=l),F--,s===n?o=void 0:(N=o,o=n),o===n?(N=t,t=n):(s=wr(),s===n?(N=t,t=n):(e.charCodeAt(N)===125?(l=`}`,N++):(l=n,F===0&&I(_e)),l===n?(N=t,t=n):(r=[r,i,a,o,s,l],t=r)))))),t===n&&(t=N,P=N,r=mn(),r=r?void 0:n,r===n?(N=t,t=n):(e.charCodeAt(N)===123?(i=`{`,N++):(i=n,F===0&&I(oe)),i===n?(N=t,t=n):(a=N,F++,o=e.charAt(N),f.test(o)?N++:(o=n,F===0&&I(he)),F--,o===n?a=n:(N=a,a=void 0),a===n?(N=t,t=n):(o=wr(),o===n?(N=t,t=n):(e.charCodeAt(N)===125?(s=`}`,N++):(s=n,F===0&&I(_e)),s===n?(N=t,t=n):(r=[r,i,a,o,s],t=r)))))))}return t}function Fr(){let e,t;for(e=[],t=Ir();t!==n;)e.push(t),t=Ir();return e}function Ir(){let t;return t=e.charAt(N),ee.test(t)?N++:(t=n,F===0&&I(A)),t}let Lr=t.text===!0,L=t.hooks,Rr=-1,zr=!1,Br=``;function Vr(e){return Rr=e,e>=0}function R(e,t){xn(e,t)}function z(e){let t={},n=new Set;for(let[r,i]of e){let e=r.toLowerCase();n.has(e)||(n.add(e),Object.defineProperty(t,r,{value:i,enumerable:!0,writable:!0,configurable:!0}))}return t}function Hr(e,t){for(let n of t.branches){let t=nr[n.tag.lower];(e.lex!==`macro`||e.lower!==t)&&R(ur(n.tag)+` must be directly inside {`+t+Qn+`, not inside `+ur(e),n.tag.loc)}t.end||R(`Unclosed `+ur(e)+`: no `+dr(e)+` closes it`,e.loc),pr(e,t.end)||R(ur(t.end)+` found where `+dr(e)+` should close the `+ur(e)+` opened at `+fr(e.loc),t.end.loc)}function Ur(e,t){let n={type:`macro`,name:e.lower,rawArgs:e.rawArgs,children:[]};if(!t)return er(n,e);if(Hr(e,t),n.children=t.children,rr.has(e.lower)){n.branches=[er({rawArgs:e.rawArgs,children:t.children},e)];for(let e of t.branches)n.branches.push(er({rawArgs:e.tag.rawArgs,children:e.children},e.tag));n.children=[]}else er(n,e);return n}vn=a();let Wr=vn!==n&&N===e.length;function Gr(){throw vn!==n&&N<e.length&&I(En()),An(_n,gn<e.length?Sn(gn):null,gn<e.length?On(gn,gn+1):On(gn,gn))}if(t.peg$library)return{peg$result:vn,peg$currPos:N,peg$FAILED:n,peg$maxFailExpected:_n,peg$maxFailPos:gn,peg$success:Wr,peg$throw:Wr?void 0:Gr};if(Wr)return vn;Gr()}var br=class extends Map{get(e){return super.get(e.toLowerCase())}set(e,t){return super.set(e.toLowerCase(),t)}has(e){return super.has(e.toLowerCase())}delete(e){return super.delete(e.toLowerCase())}},xr=class{constructor(e=[]){this.names=new br;for(let t of e)this.add(t)}add(e){this.names.set(e,!0)}has(e){return this.names.has(e)}delete(e){this.names.delete(e)}},Sr=new xr([`if`,`for`,`do`,`button`,`link`,`listbox`,`cycle`,`switch`,`timed`,`repeat`,`type`,`widget`,`span`,`nobr`]);function Cr(e){return Sr.has(e)}function wr(e){Sr.add(e)}var Tr=[509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,7,9,32,4,318,1,31,4,33,15,71,10,50,3,123,2,54,14,32,10,3,1,11,3,46,10,8,0,46,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,2,11,83,11,7,0,3,0,158,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,68,8,2,0,3,0,2,3,2,4,2,0,15,1,83,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,7,19,58,14,5,9,243,14,166,9,71,5,2,1,3,3,2,0,2,1,13,9,120,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,199,7,137,9,54,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,55,9,7,0,259,3,10,1,2,0,49,6,4,4,14,10,5350,0,7,14,11465,27,2343,9,87,9,39,4,60,6,26,9,535,9,470,0,2,54,8,3,82,0,12,1,19628,1,4178,9,519,45,3,22,481,1,61,4,4,5,9,7,3,6,31,3,149,2,12,2,9,1,3,0,33,1,1357,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,101,0,161,6,10,9,357,0,62,13,499,13,245,1,2,9,233,0,3,0,8,1,6,0,475,6,110,6,6,9,4759,9,787719,239],Er=[0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,13,10,2,14,2,6,2,1,2,10,2,14,2,6,2,1,4,51,13,310,10,21,11,7,25,5,2,41,2,13,65,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,7,25,39,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,39,27,10,22,251,41,7,1,17,5,18,21,18,28,11,0,9,21,43,17,47,20,28,22,13,52,58,1,3,0,14,44,33,24,27,35,30,0,3,0,9,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,20,1,64,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,31,9,2,0,3,0,2,37,2,0,26,0,2,0,45,52,19,3,21,2,31,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,38,6,186,43,117,63,32,7,3,0,3,7,2,1,2,23,16,0,2,0,95,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,19,72,18,0,182,32,32,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,24,43,22,0,239,18,16,0,2,12,2,33,125,0,80,921,103,111,6,206,13,310,2314,96,16,1071,18,5,26,3994,6,582,6842,29,1763,568,8,30,18,78,18,29,19,47,17,3,32,20,6,18,433,44,212,63,33,24,3,24,45,74,6,0,67,12,65,1,2,0,15,4,10,7386,37,33,96,114,14,913,15,50,7710,3,2,6,2,1,2,296,10,0,30,2,3,0,15,4,8,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,340,2,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,1845,129,15,6,55,50,49,61,147,44,11,6,17,0,322,29,19,43,485,27,229,29,3,0,208,30,2,2,2,1,2,6,3,4,10,1,225,6,2,3,2,1,2,14,2,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42719,33,4382,2,5773,3,7472,16,621,2467,541,1507,4938,6,8489,39815,11327],Dr=`‌‍·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄ-׉ؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߽߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛ࢗ-࢟࣊-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯৾ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍୓-ୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఄ఼ా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ೳഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ඁ-ඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ຼ່-໎໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜕ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠏-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᪿ-᫰ᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭᳴᳷-᳹᷀-᷿‌‍‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯・꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧ꠬ꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱ꣿ-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_・`,Or=`ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆ՘ՙՠ-ֈ֋֌א-תׯ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࡰ-ࢇࢉ-࢏ࢠ-ࣉऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚ౜ౝౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽ೜-ೞೠೡೱೲഄ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄຆ-ຊຌ-ຣລວ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜑᜟ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡸᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭌᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-ᲊᲐ-ᲺᲽ-Ჿᳩ-ᳬᳮ-ᳳᳵᳶᳺᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿ₏-₟ℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆿㇰ-ㇿ㐀-䶿一-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-꟝꟢꟱-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꣾꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭩ꭬꭭ꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ`,kr={3:`abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile`,5:`class enum extends super const export import`,6:`enum`,strict:`implements interface let package private protected public static yield`,strictBind:`eval arguments`},Ar=`break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this`,jr={5:Ar,\"5module\":Ar+` export import`,6:Ar+` const class extends export import super`},Mr=/^in(stanceof)?$/,Nr=RegExp(`[`+Or+`]`),Pr=RegExp(`[`+Or+Dr+`]`);function Fr(e,t){for(var n=65536,r=0;r<t.length;r+=2){if(n+=t[r],n>e)return!1;if(n+=t[r+1],n>=e)return!0}return!1}function Ir(e,t){return e<65?e===36:e<91?!0:e<97?e===95:e<123?!0:e<=65535?e>=170&&Nr.test(String.fromCharCode(e)):t===!1?!1:Fr(e,Er)}function Lr(e,t){return e<48?e===36:e<58?!0:e<65?!1:e<91?!0:e<97?e===95:e<123?!0:e<=65535?e>=170&&Pr.test(String.fromCharCode(e)):t===!1?!1:Fr(e,Er)||Fr(e,Tr)}var L=function(e,t){t===void 0&&(t={}),this.label=e,this.keyword=t.keyword,this.beforeExpr=!!t.beforeExpr,this.startsExpr=!!t.startsExpr,this.isLoop=!!t.isLoop,this.isAssign=!!t.isAssign,this.prefix=!!t.prefix,this.postfix=!!t.postfix,this.binop=t.binop||null,this.updateContext=null};function Rr(e,t){return new L(e,{beforeExpr:!0,binop:t})}var zr={beforeExpr:!0},Br={startsExpr:!0},Vr={};function R(e,t){return t===void 0&&(t={}),t.keyword=e,Vr[e]=new L(e,t)}var z={num:new L(`num`,Br),regexp:new L(`regexp`,Br),string:new L(`string`,Br),name:new L(`name`,Br),privateId:new L(`privateId`,Br),eof:new L(`eof`),bracketL:new L(`[`,{beforeExpr:!0,startsExpr:!0}),bracketR:new L(`]`),braceL:new L(`{`,{beforeExpr:!0,startsExpr:!0}),braceR:new L(`}`),parenL:new L(`(`,{beforeExpr:!0,startsExpr:!0}),parenR:new L(`)`),comma:new L(`,`,zr),semi:new L(`;`,zr),colon:new L(`:`,zr),dot:new L(`.`),question:new L(`?`,zr),questionDot:new L(`?.`),arrow:new L(`=>`,zr),template:new L(`template`),invalidTemplate:new L(`invalidTemplate`),ellipsis:new L(`...`,zr),backQuote:new L(\"`\",Br),dollarBraceL:new L(\"${\",{beforeExpr:!0,startsExpr:!0}),eq:new L(`=`,{beforeExpr:!0,isAssign:!0}),assign:new L(`_=`,{beforeExpr:!0,isAssign:!0}),incDec:new L(`++/--`,{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new L(`!/~`,{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:Rr(`||`,1),logicalAND:Rr(`&&`,2),bitwiseOR:Rr(`|`,3),bitwiseXOR:Rr(`^`,4),bitwiseAND:Rr(`&`,5),equality:Rr(`==/!=/===/!==`,6),relational:Rr(`</>/<=/>=`,7),bitShift:Rr(`<</>>/>>>`,8),plusMin:new L(`+/-`,{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:Rr(`%`,10),star:Rr(`*`,10),slash:Rr(`/`,10),starstar:new L(`**`,{beforeExpr:!0}),coalesce:Rr(`??`,1),_break:R(`break`),_case:R(`case`,zr),_catch:R(`catch`),_continue:R(`continue`),_debugger:R(`debugger`),_default:R(`default`,zr),_do:R(`do`,{isLoop:!0,beforeExpr:!0}),_else:R(`else`,zr),_finally:R(`finally`),_for:R(`for`,{isLoop:!0}),_function:R(`function`,Br),_if:R(`if`),_return:R(`return`,zr),_switch:R(`switch`),_throw:R(`throw`,zr),_try:R(`try`),_var:R(`var`),_const:R(`const`),_while:R(`while`,{isLoop:!0}),_with:R(`with`),_new:R(`new`,{beforeExpr:!0,startsExpr:!0}),_this:R(`this`,Br),_super:R(`super`,Br),_class:R(`class`,Br),_extends:R(`extends`,zr),_export:R(`export`),_import:R(`import`,Br),_null:R(`null`,Br),_true:R(`true`,Br),_false:R(`false`,Br),_in:R(`in`,{beforeExpr:!0,binop:7}),_instanceof:R(`instanceof`,{beforeExpr:!0,binop:7}),_typeof:R(`typeof`,{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:R(`void`,{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:R(`delete`,{beforeExpr:!0,prefix:!0,startsExpr:!0})},Hr=/\\r\\n?|\\n|\\u2028|\\u2029/,Ur=new RegExp(Hr.source,`g`);function Wr(e){return e===10||e===13||e===8232||e===8233}function Gr(e,t,n){n===void 0&&(n=e.length);for(var r=t;r<n;r++){var i=e.charCodeAt(r);if(Wr(i))return r<n-1&&i===13&&e.charCodeAt(r+1)===10?r+2:r+1}return-1}var Kr=/[\\u1680\\u2000-\\u200a\\u202f\\u205f\\u3000\\ufeff]/,qr=/(?:\\s|\\/\\/.*|\\/\\*[^]*?\\*\\/)*/g,Jr=Object.prototype,Yr=Jr.hasOwnProperty,Xr=Jr.toString,Zr=Object.hasOwn||(function(e,t){return Yr.call(e,t)}),Qr=Array.isArray||(function(e){return Xr.call(e)===`[object Array]`}),$r=Object.create(null);function ei(e){return $r[e]||($r[e]=RegExp(`^(?:`+e.replace(/ /g,`|`)+`)$`))}function ti(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}var ni=/(?:[\\uD800-\\uDBFF](?![\\uDC00-\\uDFFF])|(?:[^\\uD800-\\uDBFF]|^)[\\uDC00-\\uDFFF])/,ri=function(e,t){this.line=e,this.column=t};ri.prototype.offset=function(e){return new ri(this.line,this.column+e)};var ii=function(e,t,n){this.start=t,this.end=n,e.sourceFile!==null&&(this.source=e.sourceFile)};function ai(e,t){for(var n=1,r=0;;){var i=Gr(e,r,t);if(i<0)return new ri(n,t-r);++n,r=i}}var oi={ecmaVersion:null,sourceType:`script`,strict:!1,onInsertedSemicolon:null,onTrailingComma:null,allowReserved:null,allowReturnOutsideFunction:!1,allowImportExportEverywhere:!1,allowAwaitOutsideFunction:null,allowSuperOutsideMethod:null,allowHashBang:!1,checkPrivateFields:!0,locations:!1,startLocation:null,onToken:null,onComment:null,ranges:!1,program:null,sourceFile:null,directSourceFile:null,preserveParens:!1},si=!1;function ci(e){var t={};for(var n in oi)t[n]=e&&Zr(e,n)?e[n]:oi[n];if(t.ecmaVersion===`latest`?t.ecmaVersion=1e8:t.ecmaVersion==null?(!si&&typeof console==`object`&&console.warn&&(si=!0,console.warn(`Since Acorn 8.0.0, options.ecmaVersion is required.\nDefaulting to 2020, but this will stop working in the future.`)),t.ecmaVersion=11):t.ecmaVersion>=2015&&(t.ecmaVersion-=2009),t.allowReserved??(t.allowReserved=t.ecmaVersion<5),(!e||e.allowHashBang==null)&&(t.allowHashBang=t.ecmaVersion>=14),Qr(t.onToken)){var r=t.onToken;t.onToken=function(e){return r.push(e)}}if(Qr(t.onComment)&&(t.onComment=li(t,t.onComment)),t.sourceType===`commonjs`&&t.allowAwaitOutsideFunction)throw Error(`Cannot use allowAwaitOutsideFunction with sourceType: commonjs`);return t}function li(e,t){return function(n,r,i,a,o,s){var c={type:n?`Block`:`Line`,value:r,start:i,end:a};e.locations&&(c.loc=new ii(this,o,s)),e.ranges&&(c.range=[i,a]),t.push(c)}}var ui=1,di=2,fi=4,pi=8,mi=16,hi=32,gi=64,_i=128,vi=256,yi=512,bi=1024,xi=ui|di|vi;function Si(e,t){return di|(e?fi:0)|(t?pi:0)}var Ci=0,wi=1,Ti=2,Ei=3,Di=4,Oi=5,ki=function(e,t,n){this.options=e=ci(e),this.sourceFile=e.sourceFile,this.keywords=ei(jr[e.ecmaVersion>=6?6:e.sourceType===`module`?`5module`:5]);var r=``;e.allowReserved!==!0&&(r=kr[e.ecmaVersion>=6?6:e.ecmaVersion===5?5:3],e.sourceType===`module`&&(r+=` await`)),this.reservedWords=ei(r);var i=(r?r+` `:``)+kr.strict;this.reservedWordsStrict=ei(i),this.reservedWordsStrictBind=ei(i+` `+kr.strictBind),this.input=String(t),this.containsEsc=!1,this.pos=n||0,this.curLine=1,e.startLocation?(this.lineStart=this.pos-e.startLocation.column,this.curLine=e.startLocation.line):n?(this.lineStart=this.input.lastIndexOf(`\n`,n-1)+1,this.options.locations&&(this.curLine=this.input.slice(0,this.lineStart).split(Hr).length)):this.lineStart=0,this.type=z.eof,this.value=null,this.start=this.end=this.pos,this.startLoc=this.endLoc=this.curPosition(),this.lastTokEndLoc=this.lastTokStartLoc=null,this.lastTokStart=this.lastTokEnd=this.pos,this.context=this.initialContext(),this.exprAllowed=!0,this.inModule=e.sourceType===`module`,this.strict=this.inModule||e.strict===!0||this.strictDirective(this.pos),this.potentialArrowAt=-1,this.potentialArrowInForAwait=!1,this.yieldPos=this.awaitPos=this.awaitIdentPos=0,this.labels=[],this.undefinedExports=Object.create(null),this.pos===0&&e.allowHashBang&&this.input.slice(0,2)===`#!`&&this.skipLineComment(2),this.scopeStack=[],this.enterScope(this.options.sourceType===`commonjs`?di:ui),this.regexpState=null,this.privateNameStack=[]},Ai={inFunction:{configurable:!0},inGenerator:{configurable:!0},inAsync:{configurable:!0},canAwait:{configurable:!0},allowReturn:{configurable:!0},allowSuper:{configurable:!0},allowDirectSuper:{configurable:!0},treatFunctionsAsVar:{configurable:!0},allowNewDotTarget:{configurable:!0},allowUsing:{configurable:!0},inClassStaticBlock:{configurable:!0}};ki.prototype.parse=function(){var e=this,t=this.options.program||this.startNode();return this.nextToken(),this.catchStackOverflow(function(){return e.parseTopLevel(t)})},Ai.inFunction.get=function(){return(this.currentVarScope().flags&di)>0},Ai.inGenerator.get=function(){return(this.currentVarScope().flags&pi)>0},Ai.inAsync.get=function(){return(this.currentVarScope().flags&fi)>0},Ai.canAwait.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e].flags;if(t&(vi|yi))return!1;if(t&di)return(t&fi)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction},Ai.allowReturn.get=function(){return!!(this.inFunction||this.options.allowReturnOutsideFunction&&this.currentVarScope().flags&ui)},Ai.allowSuper.get=function(){return(this.currentThisScope().flags&gi)>0||this.options.allowSuperOutsideMethod},Ai.allowDirectSuper.get=function(){return(this.currentThisScope().flags&_i)>0},Ai.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())},Ai.allowNewDotTarget.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e].flags;if(t&(vi|yi)||t&di&&!(t&mi))return!0}return!1},Ai.allowUsing.get=function(){var e=this.currentScope().flags;return!(e&bi||!this.inModule&&e&ui)},Ai.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&vi)>0},ki.extend=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];for(var n=this,r=0;r<e.length;r++)n=e[r](n);return n},ki.parse=function(e,t){return new this(t,e).parse()},ki.parseExpressionAt=function(e,t,n){var r=new this(n,e,t);return r.nextToken(),r.parseExpression()},ki.tokenizer=function(e,t){return new this(t,e)},Object.defineProperties(ki.prototype,Ai);var ji=ki.prototype,Mi=/^(?:'((?:\\\\[^]|[^'\\\\])*?)'|\"((?:\\\\[^]|[^\"\\\\])*?)\")/;ji.strictDirective=function(e){if(this.options.ecmaVersion<5)return!1;for(;;){qr.lastIndex=e,e+=qr.exec(this.input)[0].length;var t=Mi.exec(this.input.slice(e));if(!t)return!1;if((t[1]||t[2])===`use strict`){qr.lastIndex=e+t[0].length;var n=qr.exec(this.input),r=n.index+n[0].length,i=this.input.charAt(r);return i===`;`||i===`}`||Hr.test(n[0])&&!(/[(`.[+\\-/*%<>=,?^&]/.test(i)||i===`!`&&this.input.charAt(r+1)===`=`||i===`i`&&Ni(this,r))}e+=t[0].length,qr.lastIndex=e,e+=qr.exec(this.input)[0].length,this.input[e]===`;`&&e++}};function Ni(e,t){for(var n=t+1,r=Math.min(e.input.length,t+11);n<r;){var i=e.fullCharCodeAt(n);if(!Lr(i,!0))break;n+=i<=65535?1:2}return n===t+2&&e.input.slice(t,n)===`in`||n===t+10&&e.input.slice(t,n)===`instanceof`}ji.eat=function(e){return this.type===e?(this.next(),!0):!1},ji.isContextual=function(e){return this.type===z.name&&this.value===e&&!this.containsEsc},ji.eatContextual=function(e){return this.isContextual(e)?(this.next(),!0):!1},ji.catchStackOverflow=function(e){try{return e()}catch(e){if(e instanceof Error&&(/\\bstack\\b.*\\b(exceeded|overflow)\\b/i.test(e.message)||/\\btoo much recursion\\b/i.test(e.message)))this.raise(this.start,`Not enough stack space to parse input`);else throw e}},ji.expectContextual=function(e){this.eatContextual(e)||this.unexpected()},ji.canInsertSemicolon=function(){return this.type===z.eof||this.type===z.braceR||Hr.test(this.input.slice(this.lastTokEnd,this.start))},ji.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0},ji.semicolon=function(){!this.eat(z.semi)&&!this.insertSemicolon()&&this.unexpected()},ji.afterTrailingComma=function(e,t){if(this.type===e)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),t||this.next(),!0},ji.expect=function(e){this.eat(e)||this.unexpected()},ji.unexpected=function(e){this.raise(e??this.start,`Unexpected token`)};var Pi=function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};ji.checkPatternErrors=function(e,t){if(e){e.trailingComma>-1&&this.raiseRecoverable(e.trailingComma,`Comma is not permitted after the rest element`);var n=t?e.parenthesizedAssign:e.parenthesizedBind;n>-1&&this.raiseRecoverable(n,t?`Assigning to rvalue`:`Parenthesized pattern`)}},ji.checkExpressionErrors=function(e,t){if(!e)return!1;var n=e.shorthandAssign,r=e.doubleProto;if(!t)return n>=0||r>=0;n>=0&&this.raise(n,`Shorthand property assignments are valid only in destructuring patterns`),r>=0&&this.raiseRecoverable(r,`Redefinition of __proto__ property`)},ji.checkYieldAwaitInDefaultParams=function(){this.yieldPos&&(!this.awaitPos||this.yieldPos<this.awaitPos)&&this.raise(this.yieldPos,`Yield expression cannot be a default value`),this.awaitPos&&this.raise(this.awaitPos,`Await expression cannot be a default value`)},ji.isSimpleAssignTarget=function(e){return e.type===`ParenthesizedExpression`?this.isSimpleAssignTarget(e.expression):e.type===`Identifier`||e.type===`MemberExpression`};var B=ki.prototype;B.parseTopLevel=function(e){var t=Object.create(null);for(e.body||(e.body=[]);this.type!==z.eof;){var n=this.parseStatement(null,!0,t);e.body.push(n)}if(this.inModule)for(var r=0,i=Object.keys(this.undefinedExports);r<i.length;r+=1){var a=i[r];this.raiseRecoverable(this.undefinedExports[a].start,`Export '`+a+`' is not defined`)}return this.adaptDirectivePrologue(e.body),this.next(),e.sourceType=this.options.sourceType===`commonjs`?`script`:this.options.sourceType,this.finishNode(e,`Program`)};var Fi={kind:`loop`},Ii={kind:`switch`};B.isLet=function(e){if(this.options.ecmaVersion<6||!this.isContextual(`let`))return!1;qr.lastIndex=this.pos;var t=qr.exec(this.input),n=this.pos+t[0].length,r=this.fullCharCodeAt(n);if(r===91||r===92)return!0;if(e)return!1;if(r===123)return!0;if(Ir(r)){var i=n;do n+=r<=65535?1:2;while(Lr(r=this.fullCharCodeAt(n)));if(r===92)return!0;var a=this.input.slice(i,n);if(!Mr.test(a))return!0}return!1},B.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual(`async`))return!1;qr.lastIndex=this.pos;var e=qr.exec(this.input),t=this.pos+e[0].length,n;return!Hr.test(this.input.slice(this.pos,t))&&this.input.slice(t,t+8)===`function`&&(t+8===this.input.length||!(Lr(n=this.fullCharCodeAt(t+8))||n===92))},B.isUsingKeyword=function(e,t){if(this.options.ecmaVersion<17||!this.isContextual(e?`await`:`using`))return!1;qr.lastIndex=this.pos;var n=qr.exec(this.input),r=this.pos+n[0].length;if(Hr.test(this.input.slice(this.pos,r)))return!1;if(e){var i=r+5,a;if(this.input.slice(r,i)!==`using`||i===this.input.length||Lr(a=this.fullCharCodeAt(i))||a===92)return!1;qr.lastIndex=i;var o=qr.exec(this.input);if(r=i+o[0].length,o&&Hr.test(this.input.slice(i,r)))return!1}var s=this.fullCharCodeAt(r);if(!Ir(s)&&s!==92)return!1;var c=r;do r+=s<=65535?1:2;while(Lr(s=this.fullCharCodeAt(r)));if(s===92)return!0;var l=this.input.slice(c,r);if(Mr.test(l))return!1;if(t&&!e&&l===`of`){qr.lastIndex=r;var u=qr.exec(this.input);if(r+=u[0].length,this.input.charCodeAt(r)!==61||(s=this.input.charCodeAt(r+1))===61||s===62)return!1}return!0},B.isAwaitUsing=function(e){return this.isUsingKeyword(!0,e)},B.isUsing=function(e){return this.isUsingKeyword(!1,e)},B.parseStatement=function(e,t,n){var r=this.type,i=this.startNode(),a;switch(this.isLet(e)&&(r=z._var,a=`let`),r){case z._break:case z._continue:return this.parseBreakContinueStatement(i,r.keyword);case z._debugger:return this.parseDebuggerStatement(i);case z._do:return this.parseDoStatement(i);case z._for:return this.parseForStatement(i);case z._function:return e&&(this.strict||e!==`if`&&e!==`label`)&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(i,!1,!e);case z._class:return e&&this.unexpected(),this.parseClass(i,!0);case z._if:return this.parseIfStatement(i);case z._return:return this.parseReturnStatement(i);case z._switch:return this.parseSwitchStatement(i);case z._throw:return this.parseThrowStatement(i);case z._try:return this.parseTryStatement(i);case z._const:case z._var:return a=a||this.value,e&&a!==`var`&&this.unexpected(),this.parseVarStatement(i,a);case z._while:return this.parseWhileStatement(i);case z._with:return this.parseWithStatement(i);case z.braceL:return this.parseBlock(!0,i);case z.semi:return this.parseEmptyStatement(i);case z._export:case z._import:if(this.options.ecmaVersion>10&&r===z._import){qr.lastIndex=this.pos;var o=qr.exec(this.input),s=this.pos+o[0].length,c=this.input.charCodeAt(s);if(c===40||c===46)return this.parseExpressionStatement(i,this.parseExpression())}return this.options.allowImportExportEverywhere||(t||this.raise(this.start,`'import' and 'export' may only appear at the top level`),this.inModule||this.raise(this.start,`'import' and 'export' may appear only with 'sourceType: module'`)),r===z._import?this.parseImport(i):this.parseExport(i,n);default:if(this.isAsyncFunction())return e&&this.unexpected(),this.next(),this.parseFunctionStatement(i,!0,!e);var l=this.isAwaitUsing(!1)?`await using`:this.isUsing(!1)?`using`:null;if(l)return this.allowUsing||this.raise(this.start,\"Using declaration cannot appear in the top level when source type is `script` or in the bare case statement\"),e&&this.raise(this.start,`Using declaration is not allowed in single-statement positions`),l===`await using`&&(this.canAwait||this.raise(this.start,`Await using cannot appear outside of async function`),this.next()),this.next(),this.parseVar(i,!1,l),this.semicolon(),this.finishNode(i,`VariableDeclaration`);var u=this.value,d=this.parseExpression();return r===z.name&&d.type===`Identifier`&&this.eat(z.colon)?this.parseLabeledStatement(i,u,d,e):this.parseExpressionStatement(i,d)}},B.parseBreakContinueStatement=function(e,t){var n=t===`break`;this.next(),this.eat(z.semi)||this.insertSemicolon()?e.label=null:this.type===z.name?(e.label=this.parseIdent(),this.semicolon()):this.unexpected();for(var r=0;r<this.labels.length;++r){var i=this.labels[r];if((e.label==null||i.name===e.label.name)&&(i.kind!=null&&(n||i.kind===`loop`)||e.label&&n))break}return r===this.labels.length&&this.raise(e.start,`Unsyntactic `+t),this.finishNode(e,n?`BreakStatement`:`ContinueStatement`)},B.parseDebuggerStatement=function(e){return this.next(),this.semicolon(),this.finishNode(e,`DebuggerStatement`)},B.parseDoStatement=function(e){return this.next(),this.labels.push(Fi),e.body=this.parseStatement(`do`),this.labels.pop(),this.expect(z._while),e.test=this.parseParenExpression(),this.options.ecmaVersion>=6?this.eat(z.semi):this.semicolon(),this.finishNode(e,`DoWhileStatement`)},B.parseForStatement=function(e){this.next();var t=this.options.ecmaVersion>=9&&this.canAwait&&this.eatContextual(`await`)?this.lastTokStart:-1;if(this.labels.push(Fi),this.enterScope(0),this.expect(z.parenL),this.type===z.semi)return t>-1&&this.unexpected(t),this.parseFor(e,null);var n=this.isLet();if(this.type===z._var||this.type===z._const||n){var r=this.startNode(),i=n?`let`:this.value;return this.next(),this.parseVar(r,!0,i),this.finishNode(r,`VariableDeclaration`),this.parseForAfterInit(e,r,t)}var a=this.isContextual(`let`),o=!1,s=this.isUsing(!0)?`using`:this.isAwaitUsing(!0)?`await using`:null;if(s){var c=this.startNode();return this.next(),s===`await using`&&(this.canAwait||this.raise(this.start,`Await using cannot appear outside of async function`),this.next()),this.parseVar(c,!0,s),this.finishNode(c,`VariableDeclaration`),this.parseForAfterInit(e,c,t)}var l=this.containsEsc,u=new Pi,d=this.start,f=t>-1?this.parseExprSubscripts(u,`await`):this.parseExpression(!0,u);return this.type===z._in||(o=this.options.ecmaVersion>=6&&this.isContextual(`of`))?(t>-1?(this.type===z._in&&this.unexpected(t),e.await=!0):o&&this.options.ecmaVersion>=8&&(f.start===d&&!l&&f.type===`Identifier`&&f.name===`async`?this.unexpected():this.options.ecmaVersion>=9&&(e.await=!1)),a&&o&&this.raise(f.start,`The left-hand side of a for-of loop may not start with 'let'.`),this.toAssignable(f,!1,u),this.checkLValPattern(f),this.parseForIn(e,f)):(this.checkExpressionErrors(u,!0),t>-1&&this.unexpected(t),this.parseFor(e,f))},B.parseForAfterInit=function(e,t,n){return(this.type===z._in||this.options.ecmaVersion>=6&&this.isContextual(`of`))&&t.declarations.length===1?(this.type===z._in?((t.kind===`using`||t.kind===`await using`)&&!t.declarations[0].init&&this.raise(this.start,`Using declaration is not allowed in for-in loops`),this.options.ecmaVersion>=9&&n>-1&&this.unexpected(n)):this.options.ecmaVersion>=9&&(e.await=n>-1),this.parseForIn(e,t)):(n>-1&&this.unexpected(n),this.parseFor(e,t))},B.parseFunctionStatement=function(e,t,n){return this.next(),this.parseFunction(e,Ri|(n?0:zi),!1,t)},B.parseIfStatement=function(e){return this.next(),e.test=this.parseParenExpression(),e.consequent=this.parseStatement(`if`),e.alternate=this.eat(z._else)?this.parseStatement(`if`):null,this.finishNode(e,`IfStatement`)},B.parseReturnStatement=function(e){return this.allowReturn||this.raise(this.start,`'return' outside of function`),this.next(),this.eat(z.semi)||this.insertSemicolon()?e.argument=null:(e.argument=this.parseExpression(),this.semicolon()),this.finishNode(e,`ReturnStatement`)},B.parseSwitchStatement=function(e){this.next(),e.discriminant=this.parseParenExpression(),e.cases=[],this.expect(z.braceL),this.labels.push(Ii),this.enterScope(bi);for(var t,n=!1;this.type!==z.braceR;)if(this.type===z._case||this.type===z._default){var r=this.type===z._case;t&&this.finishNode(t,`SwitchCase`),e.cases.push(t=this.startNode()),t.consequent=[],this.next(),r?t.test=this.parseExpression():(n&&this.raiseRecoverable(this.lastTokStart,`Multiple default clauses`),n=!0,t.test=null),this.expect(z.colon)}else t||this.unexpected(),t.consequent.push(this.parseStatement(null));return this.exitScope(),t&&this.finishNode(t,`SwitchCase`),this.next(),this.labels.pop(),this.finishNode(e,`SwitchStatement`)},B.parseThrowStatement=function(e){return this.next(),Hr.test(this.input.slice(this.lastTokEnd,this.start))&&this.raise(this.lastTokEnd,`Illegal newline after throw`),e.argument=this.parseExpression(),this.semicolon(),this.finishNode(e,`ThrowStatement`)};var Li=[];B.parseCatchClauseParam=function(){var e=this.parseBindingAtom(),t=e.type===`Identifier`;return this.enterScope(t?hi:0),this.checkLValPattern(e,t?Di:Ti),this.expect(z.parenR),e},B.parseTryStatement=function(e){if(this.next(),e.block=this.parseBlock(),e.handler=null,this.type===z._catch){var t=this.startNode();this.next(),this.eat(z.parenL)?t.param=this.parseCatchClauseParam():(this.options.ecmaVersion<10&&this.unexpected(),t.param=null,this.enterScope(0)),t.body=this.parseBlock(!1),this.exitScope(),e.handler=this.finishNode(t,`CatchClause`)}return e.finalizer=this.eat(z._finally)?this.parseBlock():null,!e.handler&&!e.finalizer&&this.raise(e.start,`Missing catch or finally clause`),this.finishNode(e,`TryStatement`)},B.parseVarStatement=function(e,t,n){return this.next(),this.parseVar(e,!1,t,n),this.semicolon(),this.finishNode(e,`VariableDeclaration`)},B.parseWhileStatement=function(e){return this.next(),e.test=this.parseParenExpression(),this.labels.push(Fi),e.body=this.parseStatement(`while`),this.labels.pop(),this.finishNode(e,`WhileStatement`)},B.parseWithStatement=function(e){return this.strict&&this.raise(this.start,`'with' in strict mode`),this.next(),e.object=this.parseParenExpression(),e.body=this.parseStatement(`with`),this.finishNode(e,`WithStatement`)},B.parseEmptyStatement=function(e){return this.next(),this.finishNode(e,`EmptyStatement`)},B.parseLabeledStatement=function(e,t,n,r){for(var i=0,a=this.labels;i<a.length;i+=1)a[i].name===t&&this.raise(n.start,`Label '`+t+`' is already declared`);for(var o=this.type.isLoop?`loop`:this.type===z._switch?`switch`:null,s=this.labels.length-1;s>=0;s--){var c=this.labels[s];if(c.statementStart===e.start)c.statementStart=this.start,c.kind=o;else break}return this.labels.push({name:t,kind:o,statementStart:this.start}),e.body=this.parseStatement(r?r.indexOf(`label`)===-1?r+`label`:r:`label`),this.labels.pop(),e.label=n,this.finishNode(e,`LabeledStatement`)},B.parseExpressionStatement=function(e,t){return e.expression=t,this.semicolon(),this.finishNode(e,`ExpressionStatement`)},B.parseBlock=function(e,t,n){for(e===void 0&&(e=!0),t===void 0&&(t=this.startNode()),t.body=[],this.expect(z.braceL),e&&this.enterScope(0);this.type!==z.braceR;){var r=this.parseStatement(null);t.body.push(r)}return n&&(this.strict=!1),this.next(),e&&this.exitScope(),this.finishNode(t,`BlockStatement`)},B.parseFor=function(e,t){return e.init=t,this.expect(z.semi),e.test=this.type===z.semi?null:this.parseExpression(),this.expect(z.semi),e.update=this.type===z.parenR?null:this.parseExpression(),this.expect(z.parenR),e.body=this.parseStatement(`for`),this.exitScope(),this.labels.pop(),this.finishNode(e,`ForStatement`)},B.parseForIn=function(e,t){var n=this.type===z._in;return this.next(),t.type===`VariableDeclaration`&&t.declarations[0].init!=null&&(!n||this.options.ecmaVersion<8||this.strict||t.kind!==`var`||t.declarations[0].id.type!==`Identifier`)&&this.raise(t.start,(n?`for-in`:`for-of`)+` loop variable declaration may not have an initializer`),e.left=t,e.right=n?this.parseExpression():this.parseMaybeAssign(),this.expect(z.parenR),e.body=this.parseStatement(`for`),this.exitScope(),this.labels.pop(),this.finishNode(e,n?`ForInStatement`:`ForOfStatement`)},B.parseVar=function(e,t,n,r){for(e.declarations=[],e.kind=n;;){var i=this.startNode();if(this.parseVarId(i,n),this.eat(z.eq)?i.init=this.parseMaybeAssign(t):!r&&n===`const`&&!(this.type===z._in||this.options.ecmaVersion>=6&&this.isContextual(`of`))?this.unexpected():!r&&(n===`using`||n===`await using`)&&this.options.ecmaVersion>=17&&this.type!==z._in&&!this.isContextual(`of`)?this.raise(this.lastTokEnd,`Missing initializer in `+n+` declaration`):!r&&i.id.type!==`Identifier`&&!(t&&(this.type===z._in||this.isContextual(`of`)))?this.raise(this.lastTokEnd,`Complex binding patterns require an initialization value`):i.init=null,e.declarations.push(this.finishNode(i,`VariableDeclarator`)),!this.eat(z.comma))break}return e},B.parseVarId=function(e,t){e.id=t===`using`||t===`await using`?this.parseIdent():this.parseBindingAtom(),this.checkLValPattern(e.id,t===`var`?wi:Ti,!1)};var Ri=1,zi=2,Bi=4;B.parseFunction=function(e,t,n,r,i){this.initFunction(e),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!r)&&(this.type===z.star&&t&zi&&this.unexpected(),e.generator=this.eat(z.star)),this.options.ecmaVersion>=8&&(e.async=!!r),t&Ri&&(e.id=t&Bi&&this.type!==z.name?null:this.parseIdent(),e.id&&!(t&zi)&&this.checkLValSimple(e.id,this.strict||e.generator||e.async?this.treatFunctionsAsVar?wi:Ti:Ei));var a=this.yieldPos,o=this.awaitPos,s=this.awaitIdentPos;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(Si(e.async,e.generator)),t&Ri||(e.id=this.type===z.name?this.parseIdent():null),this.parseFunctionParams(e),this.parseFunctionBody(e,n,!1,i),this.yieldPos=a,this.awaitPos=o,this.awaitIdentPos=s,this.finishNode(e,t&Ri?`FunctionDeclaration`:`FunctionExpression`)},B.parseFunctionParams=function(e){this.expect(z.parenL),e.params=this.parseBindingList(z.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()},B.parseClass=function(e,t){this.next();var n=this.strict;this.strict=!0,this.parseClassId(e,t),this.parseClassSuper(e);var r=this.enterClassBody(),i=this.startNode(),a=!1;for(i.body=[],this.expect(z.braceL);this.type!==z.braceR;){var o=this.parseClassElement(e.superClass!==null);o&&(i.body.push(o),o.type===`MethodDefinition`&&o.kind===`constructor`?(a&&this.raiseRecoverable(o.start,`Duplicate constructor in the same class`),a=!0):o.key&&o.key.type===`PrivateIdentifier`&&Vi(r,o)&&this.raiseRecoverable(o.key.start,`Identifier '#`+o.key.name+`' has already been declared`))}return this.strict=n,this.next(),e.body=this.finishNode(i,`ClassBody`),this.exitClassBody(),this.finishNode(e,t?`ClassDeclaration`:`ClassExpression`)},B.parseClassElement=function(e){if(this.eat(z.semi))return null;var t=this.options.ecmaVersion,n=this.startNode(),r=``,i=!1,a=!1,o=`method`,s=!1;if(this.eatContextual(`static`)){if(t>=13&&this.eat(z.braceL))return this.parseClassStaticBlock(n),n;this.isClassElementNameStart()||this.type===z.star?s=!0:r=`static`}if(n.static=s,!r&&t>=8&&this.eatContextual(`async`)&&((this.isClassElementNameStart()||this.type===z.star)&&!this.canInsertSemicolon()?a=!0:r=`async`),!r&&(t>=9||!a)&&this.eat(z.star)&&(i=!0),!r&&!a&&!i){var c=this.value;(this.eatContextual(`get`)||this.eatContextual(`set`))&&(this.isClassElementNameStart()?o=c:r=c)}if(r?(n.computed=!1,n.key=this.startNodeAt(this.lastTokStart,this.lastTokStartLoc),n.key.name=r,this.finishNode(n.key,`Identifier`)):this.parseClassElementName(n),t<13||this.type===z.parenL||o!==`method`||i||a){var l=!n.static&&Hi(n,`constructor`),u=l&&e;l&&o!==`method`&&this.raise(n.key.start,`Constructor can't have get/set modifier`),n.kind=l?`constructor`:o,this.parseClassMethod(n,i,a,u)}else this.parseClassField(n);return n},B.isClassElementNameStart=function(){return this.type===z.name||this.type===z.privateId||this.type===z.num||this.type===z.string||this.type===z.bracketL||this.type.keyword},B.parseClassElementName=function(e){this.type===z.privateId?(this.value===`constructor`&&this.raise(this.start,`Classes can't have an element named '#constructor'`),e.computed=!1,e.key=this.parsePrivateIdent()):this.parsePropertyName(e)},B.parseClassMethod=function(e,t,n,r){var i=e.key;e.kind===`constructor`?(t&&this.raise(i.start,`Constructor can't be a generator`),n&&this.raise(i.start,`Constructor can't be an async method`)):e.static&&Hi(e,`prototype`)&&this.raise(i.start,`Classes may not have a static property named prototype`);var a=e.value=this.parseMethod(t,n,r);return e.kind===`get`&&a.params.length!==0&&this.raiseRecoverable(a.start,`getter should have no params`),e.kind===`set`&&a.params.length!==1&&this.raiseRecoverable(a.start,`setter should have exactly one param`),e.kind===`set`&&a.params[0].type===`RestElement`&&this.raiseRecoverable(a.params[0].start,`Setter cannot use rest params`),this.finishNode(e,`MethodDefinition`)},B.parseClassField=function(e){return Hi(e,`constructor`)?this.raise(e.key.start,`Classes can't have a field named 'constructor'`):e.static&&Hi(e,`prototype`)&&this.raise(e.key.start,`Classes can't have a static field named 'prototype'`),this.eat(z.eq)?(this.enterScope(yi|gi),e.value=this.parseMaybeAssign(),this.exitScope()):e.value=null,this.semicolon(),this.finishNode(e,`PropertyDefinition`)},B.parseClassStaticBlock=function(e){e.body=[];var t=this.labels;for(this.labels=[],this.enterScope(vi|gi);this.type!==z.braceR;){var n=this.parseStatement(null);e.body.push(n)}return this.next(),this.exitScope(),this.labels=t,this.finishNode(e,`StaticBlock`)},B.parseClassId=function(e,t){this.type===z.name?(e.id=this.parseIdent(),t&&this.checkLValSimple(e.id,Ti,!1)):(t===!0&&this.unexpected(),e.id=null)},B.parseClassSuper=function(e){e.superClass=this.eat(z._extends)?this.parseExprSubscripts(null,!1):null},B.enterClassBody=function(){var e={declared:Object.create(null),used:[]};return this.privateNameStack.push(e),e.declared},B.exitClassBody=function(){var e=this.privateNameStack.pop(),t=e.declared,n=e.used;if(this.options.checkPrivateFields)for(var r=this.privateNameStack.length,i=r===0?null:this.privateNameStack[r-1],a=0;a<n.length;++a){var o=n[a];Zr(t,o.name)||(i?i.used.push(o):this.raiseRecoverable(o.start,`Private field '#`+o.name+`' must be declared in an enclosing class`))}};function Vi(e,t){var n=t.key.name,r=e[n],i=`true`;return t.type===`MethodDefinition`&&(t.kind===`get`||t.kind===`set`)&&(i=(t.static?`s`:`i`)+t.kind),r===`iget`&&i===`iset`||r===`iset`&&i===`iget`||r===`sget`&&i===`sset`||r===`sset`&&i===`sget`?(e[n]=`true`,!1):r?!0:(e[n]=i,!1)}function Hi(e,t){var n=e.computed,r=e.key;return!n&&(r.type===`Identifier`&&r.name===t||r.type===`Literal`&&r.value===t)}B.parseExportAllDeclaration=function(e,t){return this.options.ecmaVersion>=11&&(this.eatContextual(`as`)?(e.exported=this.parseModuleExportName(),this.checkExport(t,e.exported,this.lastTokStart)):e.exported=null),this.expectContextual(`from`),this.type!==z.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,`ExportAllDeclaration`)},B.parseExport=function(e,t){if(this.next(),this.eat(z.star))return this.parseExportAllDeclaration(e,t);if(this.eat(z._default))return this.checkExport(t,`default`,this.lastTokStart),e.declaration=this.parseExportDefaultDeclaration(),this.finishNode(e,`ExportDefaultDeclaration`);if(this.shouldParseExportStatement())e.declaration=this.parseExportDeclaration(e),e.declaration.type===`VariableDeclaration`?this.checkVariableExport(t,e.declaration.declarations):this.checkExport(t,e.declaration.id,e.declaration.id.start),e.specifiers=[],e.source=null,this.options.ecmaVersion>=16&&(e.attributes=[]);else{if(e.declaration=null,e.specifiers=this.parseExportSpecifiers(t),this.eatContextual(`from`))this.type!==z.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause());else{for(var n=0,r=e.specifiers;n<r.length;n+=1){var i=r[n];this.checkUnreserved(i.local),this.checkLocalExport(i.local),i.local.type===`Literal`&&this.raise(i.local.start,\"A string literal cannot be used as an exported binding without `from`.\")}e.source=null,this.options.ecmaVersion>=16&&(e.attributes=[])}this.semicolon()}return this.finishNode(e,`ExportNamedDeclaration`)},B.parseExportDeclaration=function(e){return this.parseStatement(null)},B.parseExportDefaultDeclaration=function(){var e;if(this.type===z._function||(e=this.isAsyncFunction())){var t=this.startNode();return this.next(),e&&this.next(),this.parseFunction(t,Ri|Bi,!1,e)}else if(this.type===z._class){var n=this.startNode();return this.parseClass(n,`nullableID`)}else{var r=this.parseMaybeAssign();return this.semicolon(),r}},B.checkExport=function(e,t,n){e&&(typeof t!=`string`&&(t=t.type===`Identifier`?t.name:t.value),Zr(e,t)&&this.raiseRecoverable(n,`Duplicate export '`+t+`'`),e[t]=!0)},B.checkPatternExport=function(e,t){var n=t.type;if(n===`Identifier`)this.checkExport(e,t,t.start);else if(n===`ObjectPattern`)for(var r=0,i=t.properties;r<i.length;r+=1){var a=i[r];this.checkPatternExport(e,a)}else if(n===`ArrayPattern`)for(var o=0,s=t.elements;o<s.length;o+=1){var c=s[o];c&&this.checkPatternExport(e,c)}else n===`Property`?this.checkPatternExport(e,t.value):n===`AssignmentPattern`?this.checkPatternExport(e,t.left):n===`RestElement`&&this.checkPatternExport(e,t.argument)},B.checkVariableExport=function(e,t){if(e)for(var n=0,r=t;n<r.length;n+=1){var i=r[n];this.checkPatternExport(e,i.id)}},B.shouldParseExportStatement=function(){return this.type.keyword===`var`||this.type.keyword===`const`||this.type.keyword===`class`||this.type.keyword===`function`||this.isLet()||this.isAsyncFunction()},B.parseExportSpecifier=function(e){var t=this.startNode();return t.local=this.parseModuleExportName(),t.exported=this.eatContextual(`as`)?this.parseModuleExportName():t.local,this.checkExport(e,t.exported,t.exported.start),this.finishNode(t,`ExportSpecifier`)},B.parseExportSpecifiers=function(e){var t=[],n=!0;for(this.expect(z.braceL);!this.eat(z.braceR);){if(n)n=!1;else if(this.expect(z.comma),this.afterTrailingComma(z.braceR))break;t.push(this.parseExportSpecifier(e))}return t},B.parseImport=function(e){return this.next(),this.type===z.string?(e.specifiers=Li,e.source=this.parseExprAtom()):(e.specifiers=this.parseImportSpecifiers(),this.expectContextual(`from`),e.source=this.type===z.string?this.parseExprAtom():this.unexpected()),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,`ImportDeclaration`)},B.parseImportSpecifier=function(){var e=this.startNode();return e.imported=this.parseModuleExportName(),this.eatContextual(`as`)?e.local=this.parseIdent():(this.checkUnreserved(e.imported),e.local=e.imported),this.checkLValSimple(e.local,Ti),this.finishNode(e,`ImportSpecifier`)},B.parseImportDefaultSpecifier=function(){var e=this.startNode();return e.local=this.parseIdent(),this.checkLValSimple(e.local,Ti),this.finishNode(e,`ImportDefaultSpecifier`)},B.parseImportNamespaceSpecifier=function(){var e=this.startNode();return this.next(),this.expectContextual(`as`),e.local=this.parseIdent(),this.checkLValSimple(e.local,Ti),this.finishNode(e,`ImportNamespaceSpecifier`)},B.parseImportSpecifiers=function(){var e=[],t=!0;if(this.type===z.name&&(e.push(this.parseImportDefaultSpecifier()),!this.eat(z.comma)))return e;if(this.type===z.star)return e.push(this.parseImportNamespaceSpecifier()),e;for(this.expect(z.braceL);!this.eat(z.braceR);){if(t)t=!1;else if(this.expect(z.comma),this.afterTrailingComma(z.braceR))break;e.push(this.parseImportSpecifier())}return e},B.parseWithClause=function(){var e=[];if(!this.eat(z._with))return e;this.expect(z.braceL);for(var t={},n=!0;!this.eat(z.braceR);){if(n)n=!1;else if(this.expect(z.comma),this.afterTrailingComma(z.braceR))break;var r=this.parseImportAttribute(),i=r.key.type===`Identifier`?r.key.name:r.key.value;Zr(t,i)&&this.raiseRecoverable(r.key.start,`Duplicate attribute key '`+i+`'`),t[i]=!0,e.push(r)}return e},B.parseImportAttribute=function(){var e=this.startNode();return e.key=this.type===z.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!==`never`),this.expect(z.colon),this.type!==z.string&&this.unexpected(),e.value=this.parseExprAtom(),this.finishNode(e,`ImportAttribute`)},B.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===z.string){var e=this.parseLiteral(this.value);return ni.test(e.value)&&this.raise(e.start,`An export name cannot include a lone surrogate.`),e}return this.parseIdent(!0)},B.adaptDirectivePrologue=function(e){for(var t=0;t<e.length&&this.isDirectiveCandidate(e[t]);++t)e[t].directive=e[t].expression.raw.slice(1,-1)},B.isDirectiveCandidate=function(e){return this.options.ecmaVersion>=5&&e.type===`ExpressionStatement`&&e.expression.type===`Literal`&&typeof e.expression.value==`string`&&(this.input[e.start]===`\"`||this.input[e.start]===`'`)};var Ui=ki.prototype;Ui.toAssignable=function(e,t,n){if(this.options.ecmaVersion>=6&&e)switch(e.type){case`Identifier`:this.inAsync&&e.name===`await`&&this.raise(e.start,`Cannot use 'await' as identifier inside an async function`);break;case`ObjectPattern`:case`ArrayPattern`:case`AssignmentPattern`:case`RestElement`:break;case`ObjectExpression`:e.type=`ObjectPattern`,n&&this.checkPatternErrors(n,!0);for(var r=0,i=e.properties;r<i.length;r+=1){var a=i[r];this.toAssignable(a,t),a.type===`RestElement`&&(a.argument.type===`ArrayPattern`||a.argument.type===`ObjectPattern`)&&this.raise(a.argument.start,`Unexpected token`)}break;case`Property`:e.kind!==`init`&&this.raise(e.key.start,`Object pattern can't contain getter or setter`),this.toAssignable(e.value,t);break;case`ArrayExpression`:e.type=`ArrayPattern`,n&&this.checkPatternErrors(n,!0),this.toAssignableList(e.elements,t);break;case`SpreadElement`:e.type=`RestElement`,this.toAssignable(e.argument,t),e.argument.type===`AssignmentPattern`&&this.raise(e.argument.start,`Rest elements cannot have a default value`);break;case`AssignmentExpression`:e.operator!==`=`&&this.raise(e.left.end,`Only '=' operator can be used for specifying default value.`),e.type=`AssignmentPattern`,delete e.operator,this.toAssignable(e.left,t);break;case`ParenthesizedExpression`:this.toAssignable(e.expression,t,n);break;case`ChainExpression`:this.raiseRecoverable(e.start,`Optional chaining cannot appear in left-hand side`);break;case`MemberExpression`:if(!t)break;default:this.raise(e.start,`Assigning to rvalue`)}else n&&this.checkPatternErrors(n,!0);return e},Ui.toAssignableList=function(e,t){for(var n=e.length,r=0;r<n;r++){var i=e[r];i&&this.toAssignable(i,t)}if(n){var a=e[n-1];this.options.ecmaVersion===6&&t&&a&&a.type===`RestElement`&&a.argument.type!==`Identifier`&&this.unexpected(a.argument.start)}return e},Ui.parseSpread=function(e){var t=this.startNode();return this.next(),t.argument=this.parseMaybeAssign(!1,e),this.finishNode(t,`SpreadElement`)},Ui.parseRestBinding=function(){var e=this.startNode();return this.next(),this.options.ecmaVersion===6&&this.type!==z.name&&this.unexpected(),e.argument=this.parseBindingAtom(),this.finishNode(e,`RestElement`)},Ui.parseBindingAtom=function(){if(this.options.ecmaVersion>=6)switch(this.type){case z.bracketL:var e=this.startNode();return this.next(),e.elements=this.parseBindingList(z.bracketR,!0,!0),this.finishNode(e,`ArrayPattern`);case z.braceL:return this.parseObj(!0)}return this.parseIdent()},Ui.parseBindingList=function(e,t,n,r){for(var i=[],a=!0;!this.eat(e);)if(a?a=!1:this.expect(z.comma),t&&this.type===z.comma)i.push(null);else if(n&&this.afterTrailingComma(e))break;else if(this.type===z.ellipsis){var o=this.parseRestBinding();this.parseBindingListItem(o),i.push(o),this.type===z.comma&&this.raiseRecoverable(this.start,`Comma is not permitted after the rest element`),this.expect(e);break}else i.push(this.parseAssignableListItem(r));return i},Ui.parseAssignableListItem=function(e){var t=this.parseMaybeDefault(this.start,this.startLoc);return this.parseBindingListItem(t),t},Ui.parseBindingListItem=function(e){return e},Ui.parseMaybeDefault=function(e,t,n){if(n=n||this.parseBindingAtom(),this.options.ecmaVersion<6||!this.eat(z.eq))return n;var r=this.startNodeAt(e,t);return r.left=n,r.right=this.parseMaybeAssign(),this.finishNode(r,`AssignmentPattern`)},Ui.checkLValSimple=function(e,t,n){t===void 0&&(t=Ci);var r=t!==Ci;switch(e.type){case`Identifier`:this.strict&&this.reservedWordsStrictBind.test(e.name)&&this.raiseRecoverable(e.start,(r?`Binding `:`Assigning to `)+e.name+` in strict mode`),r&&(t===Ti&&e.name===`let`&&this.raiseRecoverable(e.start,`let is disallowed as a lexically bound name`),n&&(Zr(n,e.name)&&this.raiseRecoverable(e.start,`Argument name clash`),n[e.name]=!0),t!==Oi&&this.declareName(e.name,t,e.start));break;case`ChainExpression`:this.raiseRecoverable(e.start,`Optional chaining cannot appear in left-hand side`);break;case`MemberExpression`:r&&this.raiseRecoverable(e.start,`Binding member expression`);break;case`ParenthesizedExpression`:return r&&this.raiseRecoverable(e.start,`Binding parenthesized expression`),this.checkLValSimple(e.expression,t,n);default:this.raise(e.start,(r?`Binding`:`Assigning to`)+` rvalue`)}},Ui.checkLValPattern=function(e,t,n){switch(t===void 0&&(t=Ci),e.type){case`ObjectPattern`:for(var r=0,i=e.properties;r<i.length;r+=1){var a=i[r];this.checkLValInnerPattern(a,t,n)}break;case`ArrayPattern`:for(var o=0,s=e.elements;o<s.length;o+=1){var c=s[o];c&&this.checkLValInnerPattern(c,t,n)}break;default:this.checkLValSimple(e,t,n)}},Ui.checkLValInnerPattern=function(e,t,n){switch(t===void 0&&(t=Ci),e.type){case`Property`:this.checkLValInnerPattern(e.value,t,n);break;case`AssignmentPattern`:this.checkLValPattern(e.left,t,n);break;case`RestElement`:this.checkLValPattern(e.argument,t,n);break;default:this.checkLValPattern(e,t,n)}};var Wi=function(e,t,n,r,i){this.token=e,this.isExpr=!!t,this.preserveSpace=!!n,this.override=r,this.generator=!!i},V={b_stat:new Wi(`{`,!1),b_expr:new Wi(`{`,!0),b_tmpl:new Wi(\"${\",!1),p_stat:new Wi(`(`,!1),p_expr:new Wi(`(`,!0),q_tmpl:new Wi(\"`\",!0,!0,function(e){return e.tryReadTemplateToken()}),f_stat:new Wi(`function`,!1),f_expr:new Wi(`function`,!0),f_expr_gen:new Wi(`function`,!0,!1,null,!0),f_gen:new Wi(`function`,!1,!1,null,!0)},Gi=ki.prototype;Gi.initialContext=function(){return[V.b_stat]},Gi.curContext=function(){return this.context[this.context.length-1]},Gi.braceIsBlock=function(e){var t=this.curContext();return t===V.f_expr||t===V.f_stat?!0:e===z.colon&&(t===V.b_stat||t===V.b_expr)?!t.isExpr:e===z._return||e===z.name&&this.exprAllowed?Hr.test(this.input.slice(this.lastTokEnd,this.start)):e===z._else||e===z.semi||e===z.eof||e===z.parenR||e===z.arrow?!0:e===z.braceL?t===V.b_stat:e===z._var||e===z._const||e===z.name?!1:!this.exprAllowed},Gi.inGeneratorContext=function(){for(var e=this.context.length-1;e>=1;e--){var t=this.context[e];if(t.token===`function`)return t.generator}return!1},Gi.updateContext=function(e){var t,n=this.type;n.keyword&&e===z.dot?this.exprAllowed=!1:(t=n.updateContext)?t.call(this,e):this.exprAllowed=n.beforeExpr},Gi.overrideContext=function(e){this.curContext()!==e&&(this.context[this.context.length-1]=e)},z.parenR.updateContext=z.braceR.updateContext=function(){if(this.context.length===1){this.exprAllowed=!0;return}var e=this.context.pop();e===V.b_stat&&this.curContext().token===`function`&&(e=this.context.pop()),this.exprAllowed=!e.isExpr},z.braceL.updateContext=function(e){this.context.push(this.braceIsBlock(e)?V.b_stat:V.b_expr),this.exprAllowed=!0},z.dollarBraceL.updateContext=function(){this.context.push(V.b_tmpl),this.exprAllowed=!0},z.parenL.updateContext=function(e){var t=e===z._if||e===z._for||e===z._with||e===z._while;this.context.push(t?V.p_stat:V.p_expr),this.exprAllowed=!0},z.incDec.updateContext=function(){},z._function.updateContext=z._class.updateContext=function(e){e.beforeExpr&&e!==z._else&&!(e===z.semi&&this.curContext()!==V.p_stat)&&!(e===z._return&&Hr.test(this.input.slice(this.lastTokEnd,this.start)))&&!((e===z.colon||e===z.braceL)&&this.curContext()===V.b_stat)?this.context.push(V.f_expr):this.context.push(V.f_stat),this.exprAllowed=!1},z.colon.updateContext=function(){this.curContext().token===`function`&&this.context.pop(),this.exprAllowed=!0},z.backQuote.updateContext=function(){this.curContext()===V.q_tmpl?this.context.pop():this.context.push(V.q_tmpl),this.exprAllowed=!1},z.star.updateContext=function(e){if(e===z._function){var t=this.context.length-1;this.context[t]===V.f_expr?this.context[t]=V.f_expr_gen:this.context[t]=V.f_gen}this.exprAllowed=!0},z.name.updateContext=function(e){var t=!1;this.options.ecmaVersion>=6&&e!==z.dot&&(this.value===`of`&&!this.exprAllowed||this.value===`yield`&&this.inGeneratorContext())&&(t=!0),this.exprAllowed=t};var H=ki.prototype;H.checkPropClash=function(e,t,n){if(!(this.options.ecmaVersion>=9&&e.type===`SpreadElement`)&&!(this.options.ecmaVersion>=6&&(e.computed||e.method||e.shorthand))){var r=e.key,i;switch(r.type){case`Identifier`:i=r.name;break;case`Literal`:i=String(r.value);break;default:return}var a=e.kind;if(this.options.ecmaVersion>=6){i===`__proto__`&&a===`init`&&(t.proto&&(n?n.doubleProto<0&&(n.doubleProto=r.start):this.raiseRecoverable(r.start,`Redefinition of __proto__ property`)),t.proto=!0);return}i=`$`+i;var o=t[i];o?(a===`init`?this.strict&&o.init||o.get||o.set:o.init||o[a])&&this.raiseRecoverable(r.start,`Redefinition of property`):o=t[i]={init:!1,get:!1,set:!1},o[a]=!0}},H.parseExpression=function(e,t){var n=this;return this.catchStackOverflow(function(){var r=n.start,i=n.startLoc,a=n.parseMaybeAssign(e,t);if(n.type===z.comma){var o=n.startNodeAt(r,i);for(o.expressions=[a];n.eat(z.comma);)o.expressions.push(n.parseMaybeAssign(e,t));return n.finishNode(o,`SequenceExpression`)}return a})},H.parseMaybeAssign=function(e,t,n){if(this.isContextual(`yield`)){if(this.inGenerator)return this.parseYield(e);this.exprAllowed=!1}var r=!1,i=-1,a=-1,o=-1;t?(i=t.parenthesizedAssign,a=t.trailingComma,o=t.doubleProto,t.parenthesizedAssign=t.trailingComma=-1):(t=new Pi,r=!0);var s=this.start,c=this.startLoc;(this.type===z.parenL||this.type===z.name)&&(this.potentialArrowAt=this.start,this.potentialArrowInForAwait=e===`await`);var l=this.parseMaybeConditional(e,t);if(n&&(l=n.call(this,l,s,c)),this.type.isAssign){var u=this.startNodeAt(s,c);return u.operator=this.value,this.type===z.eq&&(l=this.toAssignable(l,!1,t)),r||(t.parenthesizedAssign=t.trailingComma=-1,t.shorthandAssign>=l.start&&(t.shorthandAssign=-1),t.doubleProto>=l.start&&(t.doubleProto=-1)),this.type===z.eq?this.checkLValPattern(l):this.checkLValSimple(l),u.left=l,this.next(),u.right=this.parseMaybeAssign(e),o>-1&&(t.doubleProto=o),this.finishNode(u,`AssignmentExpression`)}else r&&this.checkExpressionErrors(t,!0);return i>-1&&(t.parenthesizedAssign=i),a>-1&&(t.trailingComma=a),l},H.parseMaybeConditional=function(e,t){var n=this.start,r=this.startLoc,i=this.parseExprOps(e,t);if(this.checkExpressionErrors(t))return i;if(!(i.type===`ArrowFunctionExpression`&&i.start===n)&&this.eat(z.question)){var a=this.startNodeAt(n,r);return a.test=i,a.consequent=this.parseMaybeAssign(),this.expect(z.colon),a.alternate=this.parseMaybeAssign(e),this.finishNode(a,`ConditionalExpression`)}return i},H.parseExprOps=function(e,t){var n=this.start,r=this.startLoc,i=this.parseMaybeUnary(t,!1,!1,e);return this.checkExpressionErrors(t)||i.start===n&&i.type===`ArrowFunctionExpression`?i:this.parseExprOp(i,n,r,-1,e)},H.parseExprOp=function(e,t,n,r,i){var a=this.type.binop;if(a!=null&&(!i||this.type!==z._in)&&a>r){var o=this.type===z.logicalOR||this.type===z.logicalAND,s=this.type===z.coalesce;s&&(a=z.logicalAND.binop);var c=this.value;this.next();var l=this.start,u=this.startLoc,d=this.parseExprOp(this.parseMaybeUnary(null,!1,!1,i),l,u,a,i),f=this.buildBinary(t,n,e,d,c,o||s);return(o&&this.type===z.coalesce||s&&(this.type===z.logicalOR||this.type===z.logicalAND))&&this.raiseRecoverable(this.start,`Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses`),this.parseExprOp(f,t,n,r,i)}return e},H.buildBinary=function(e,t,n,r,i,a){r.type===`PrivateIdentifier`&&this.raise(r.start,`Private identifier can only be left side of binary expression`);var o=this.startNodeAt(e,t);return o.left=n,o.operator=i,o.right=r,this.finishNode(o,a?`LogicalExpression`:`BinaryExpression`)},H.parseMaybeUnary=function(e,t,n,r){var i=this.start,a=this.startLoc,o;if(this.isContextual(`await`)&&this.canAwait)o=this.parseAwait(r),t=!0;else if(this.type.prefix){var s=this.startNode(),c=this.type===z.incDec;s.operator=this.value,s.prefix=!0,this.next(),s.argument=this.parseMaybeUnary(null,!0,c,r),this.checkExpressionErrors(e,!0),c?this.checkLValSimple(s.argument):this.strict&&s.operator===`delete`&&Ki(s.argument)?this.raiseRecoverable(s.start,`Deleting local variable in strict mode`):s.operator===`delete`&&qi(s.argument)?this.raiseRecoverable(s.start,`Private fields can not be deleted`):t=!0,o=this.finishNode(s,c?`UpdateExpression`:`UnaryExpression`)}else if(!t&&this.type===z.privateId)(r||this.privateNameStack.length===0)&&this.options.checkPrivateFields&&this.unexpected(),o=this.parsePrivateIdent(),this.type!==z._in&&this.unexpected();else{if(o=this.parseExprSubscripts(e,r),this.checkExpressionErrors(e))return o;for(;this.type.postfix&&!this.canInsertSemicolon();){var l=this.startNodeAt(i,a);l.operator=this.value,l.prefix=!1,l.argument=o,this.checkLValSimple(o),this.next(),o=this.finishNode(l,`UpdateExpression`)}}if(!n&&!(o.type===`ArrowFunctionExpression`&&o.start===i)&&this.eat(z.starstar))if(t)this.unexpected(this.lastTokStart);else return this.buildBinary(i,a,o,this.parseMaybeUnary(null,!1,!1,r),`**`,!1);else return o};function Ki(e){return e.type===`Identifier`||e.type===`ParenthesizedExpression`&&Ki(e.expression)}function qi(e){return e.type===`MemberExpression`&&e.property.type===`PrivateIdentifier`||e.type===`ChainExpression`&&qi(e.expression)||e.type===`ParenthesizedExpression`&&qi(e.expression)}H.parseExprSubscripts=function(e,t){var n=this.start,r=this.startLoc,i=-1,a=-1;e&&(i=e.doubleProto,a=e.shorthandAssign,e.doubleProto=e.shorthandAssign=-1);var o=this.parseExprAtom(e,t);if(o.type===`ArrowFunctionExpression`&&this.input.slice(this.lastTokStart,this.lastTokEnd)!==`)`)return o;var s=this.parseSubscripts(o,n,r,!1,t);return e&&(s.end>o.end&&(this.checkExpressionErrors(e,!0),e.parenthesizedAssign>=s.start&&(e.parenthesizedAssign=-1),e.parenthesizedBind>=s.start&&(e.parenthesizedBind=-1),e.trailingComma>=s.start&&(e.trailingComma=-1)),i>-1&&(e.doubleProto=i),a>-1&&(e.shorthandAssign=a)),s},H.parseSubscripts=function(e,t,n,r,i){for(var a=this.options.ecmaVersion>=8&&e.type===`Identifier`&&e.name===`async`&&this.lastTokEnd===e.end&&!this.canInsertSemicolon()&&e.end-e.start===5&&this.potentialArrowAt===e.start,o=!1;;){var s=this.parseSubscript(e,t,n,r,a,o,i);if(s.optional&&(o=!0),s.end===e.end||s.type===`ArrowFunctionExpression`){if(o){var c=this.startNodeAt(t,n);c.expression=s,s=this.finishNode(c,`ChainExpression`)}return s}e=s,a=!1}},H.shouldParseAsyncArrow=function(){return!this.canInsertSemicolon()&&this.eat(z.arrow)},H.parseSubscriptAsyncArrow=function(e,t,n,r){return this.parseArrowExpression(this.startNodeAt(e,t),n,!0,r)},H.parseSubscript=function(e,t,n,r,i,a,o){var s=this.options.ecmaVersion>=11,c=s&&this.eat(z.questionDot);r&&c&&this.raise(this.lastTokStart,`Optional chaining cannot appear in the callee of new expressions`);var l=this.eat(z.bracketL);if(l||c&&this.type!==z.parenL&&this.type!==z.backQuote||this.eat(z.dot)){var u=this.startNodeAt(t,n);u.object=e,l?(u.property=this.parseExpression(),this.expect(z.bracketR)):this.type===z.privateId&&e.type!==`Super`?u.property=this.parsePrivateIdent():u.property=this.parseIdent(this.options.allowReserved!==`never`),u.computed=!!l,s&&(u.optional=c),e=this.finishNode(u,`MemberExpression`)}else if(!r&&this.eat(z.parenL)){var d=new Pi,f=this.yieldPos,p=this.awaitPos,m=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var h=this.parseExprList(z.parenR,this.options.ecmaVersion>=8,!1,d);if(i&&!c&&this.shouldParseAsyncArrow())return this.checkPatternErrors(d,!1),this.checkYieldAwaitInDefaultParams(),this.awaitIdentPos>0&&this.raise(this.awaitIdentPos,`Cannot use 'await' as identifier inside an async function`),this.yieldPos=f,this.awaitPos=p,this.awaitIdentPos=m,this.parseSubscriptAsyncArrow(t,n,h,o);this.checkExpressionErrors(d,!0),this.yieldPos=f||this.yieldPos,this.awaitPos=p||this.awaitPos,this.awaitIdentPos=m||this.awaitIdentPos;var g=this.startNodeAt(t,n);g.callee=e,g.arguments=h,s&&(g.optional=c),e=this.finishNode(g,`CallExpression`)}else if(this.type===z.backQuote){(c||a)&&this.raise(this.start,`Optional chaining cannot appear in the tag of tagged template expressions`);var _=this.startNodeAt(t,n);_.tag=e,_.quasi=this.parseTemplate({isTagged:!0}),e=this.finishNode(_,`TaggedTemplateExpression`)}return e},H.parseExprAtom=function(e,t,n){this.type===z.slash&&this.readRegexp();var r,i=this.potentialArrowAt===this.start;switch(this.type){case z._super:return this.allowSuper||this.raise(this.start,`'super' keyword outside a method`),r=this.startNode(),this.next(),this.type===z.parenL&&!this.allowDirectSuper&&this.raise(r.start,`super() call outside constructor of a subclass`),this.type!==z.dot&&this.type!==z.bracketL&&this.type!==z.parenL&&this.unexpected(),this.finishNode(r,`Super`);case z._this:return r=this.startNode(),this.next(),this.finishNode(r,`ThisExpression`);case z.name:var a=this.start,o=this.startLoc,s=this.containsEsc,c=this.parseIdent(!1);if(this.options.ecmaVersion>=8&&!s&&c.name===`async`&&!this.canInsertSemicolon()&&this.eat(z._function))return this.overrideContext(V.f_expr),this.parseFunction(this.startNodeAt(a,o),0,!1,!0,t);if(i&&!this.canInsertSemicolon()){if(this.eat(z.arrow))return this.parseArrowExpression(this.startNodeAt(a,o),[c],!1,t);if(this.options.ecmaVersion>=8&&c.name===`async`&&this.type===z.name&&!s&&(!this.potentialArrowInForAwait||this.value!==`of`||this.containsEsc))return c=this.parseIdent(!1),(this.canInsertSemicolon()||!this.eat(z.arrow))&&this.unexpected(),this.parseArrowExpression(this.startNodeAt(a,o),[c],!0,t)}return c;case z.regexp:var l=this.value;return r=this.parseLiteral(l.value),r.regex={pattern:l.pattern,flags:l.flags},r;case z.num:case z.string:return this.parseLiteral(this.value);case z._null:case z._true:case z._false:return r=this.startNode(),r.value=this.type===z._null?null:this.type===z._true,r.raw=this.type.keyword,this.next(),this.finishNode(r,`Literal`);case z.parenL:var u=this.start,d=this.parseParenAndDistinguishExpression(i,t);return e&&(e.parenthesizedAssign<0&&!this.isSimpleAssignTarget(d)&&(e.parenthesizedAssign=u),e.parenthesizedBind<0&&(e.parenthesizedBind=u)),d;case z.bracketL:return r=this.startNode(),this.next(),r.elements=this.parseExprList(z.bracketR,!0,!0,e),this.finishNode(r,`ArrayExpression`);case z.braceL:return this.overrideContext(V.b_expr),this.parseObj(!1,e);case z._function:return r=this.startNode(),this.next(),this.parseFunction(r,0);case z._class:return this.parseClass(this.startNode(),!1);case z._new:return this.parseNew();case z.backQuote:return this.parseTemplate();case z._import:return this.options.ecmaVersion>=11?this.parseExprImport(n):this.unexpected();default:return this.parseExprAtomDefault()}},H.parseExprAtomDefault=function(){this.unexpected()},H.parseExprImport=function(e){var t=this.startNode();if(this.containsEsc&&this.raiseRecoverable(this.start,`Escape sequence in keyword import`),this.next(),this.type===z.parenL&&!e)return this.parseDynamicImport(t);if(this.type===z.dot){var n=this.startNodeAt(t.start,t.loc&&t.loc.start);return n.name=`import`,t.meta=this.finishNode(n,`Identifier`),this.parseImportMeta(t)}else this.unexpected()},H.parseDynamicImport=function(e){if(this.next(),e.source=this.parseMaybeAssign(),this.options.ecmaVersion>=16)this.eat(z.parenR)?e.options=null:(this.expect(z.comma),this.afterTrailingComma(z.parenR)?e.options=null:(e.options=this.parseMaybeAssign(),this.eat(z.parenR)||(this.expect(z.comma),this.afterTrailingComma(z.parenR)||this.unexpected())));else if(!this.eat(z.parenR)){var t=this.start;this.eat(z.comma)&&this.eat(z.parenR)?this.raiseRecoverable(t,`Trailing comma is not allowed in import()`):this.unexpected(t)}return this.finishNode(e,`ImportExpression`)},H.parseImportMeta=function(e){this.next();var t=this.containsEsc;return e.property=this.parseIdent(!0),e.property.name!==`meta`&&this.raiseRecoverable(e.property.start,`The only valid meta property for import is 'import.meta'`),t&&this.raiseRecoverable(e.start,`'import.meta' must not contain escaped characters`),this.options.sourceType!==`module`&&!this.options.allowImportExportEverywhere&&this.raiseRecoverable(e.start,`Cannot use 'import.meta' outside a module`),this.finishNode(e,`MetaProperty`)},H.parseLiteral=function(e){var t=this.startNode();return t.value=e,t.raw=this.input.slice(this.start,this.end),t.raw.charCodeAt(t.raw.length-1)===110&&(t.bigint=t.value==null?t.raw.slice(0,-1).replace(/_/g,``):t.value.toString()),this.next(),this.finishNode(t,`Literal`)},H.parseParenExpression=function(){this.expect(z.parenL);var e=this.parseExpression();return this.expect(z.parenR),e},H.shouldParseArrow=function(e){return!this.canInsertSemicolon()},H.parseParenAndDistinguishExpression=function(e,t){var n=this.start,r=this.startLoc,i,a=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var o=this.start,s=this.startLoc,c=[],l=!0,u=!1,d=new Pi,f=this.yieldPos,p=this.awaitPos,m;for(this.yieldPos=0,this.awaitPos=0;this.type!==z.parenR;)if(l?l=!1:this.expect(z.comma),a&&this.afterTrailingComma(z.parenR,!0)){u=!0;break}else if(this.type===z.ellipsis){m=this.start,c.push(this.parseParenItem(this.parseRestBinding())),this.type===z.comma&&this.raiseRecoverable(this.start,`Comma is not permitted after the rest element`);break}else c.push(this.parseMaybeAssign(!1,d,this.parseParenItem));var h=this.lastTokEnd,g=this.lastTokEndLoc;if(this.expect(z.parenR),e&&this.shouldParseArrow(c)&&this.eat(z.arrow))return this.checkPatternErrors(d,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=f,this.awaitPos=p,this.parseParenArrowList(n,r,c,t);(!c.length||u)&&this.unexpected(this.lastTokStart),m&&this.unexpected(m),this.checkExpressionErrors(d,!0),this.yieldPos=f||this.yieldPos,this.awaitPos=p||this.awaitPos,c.length>1?(i=this.startNodeAt(o,s),i.expressions=c,this.finishNodeAt(i,`SequenceExpression`,h,g)):i=c[0]}else i=this.parseParenExpression();if(this.options.preserveParens){var _=this.startNodeAt(n,r);return _.expression=i,this.finishNode(_,`ParenthesizedExpression`)}else return i},H.parseParenItem=function(e){return e},H.parseParenArrowList=function(e,t,n,r){return this.parseArrowExpression(this.startNodeAt(e,t),n,!1,r)};var Ji=[];H.parseNew=function(){this.containsEsc&&this.raiseRecoverable(this.start,`Escape sequence in keyword new`);var e=this.startNode();if(this.next(),this.options.ecmaVersion>=6&&this.type===z.dot){var t=this.startNodeAt(e.start,e.loc&&e.loc.start);t.name=`new`,e.meta=this.finishNode(t,`Identifier`),this.next();var n=this.containsEsc;return e.property=this.parseIdent(!0),e.property.name!==`target`&&this.raiseRecoverable(e.property.start,`The only valid meta property for new is 'new.target'`),n&&this.raiseRecoverable(e.start,`'new.target' must not contain escaped characters`),this.allowNewDotTarget||this.raiseRecoverable(e.start,`'new.target' can only be used in functions and class static block`),this.finishNode(e,`MetaProperty`)}var r=this.start,i=this.startLoc;return e.callee=this.parseSubscripts(this.parseExprAtom(null,!1,!0),r,i,!0,!1),e.callee.type===`Super`&&this.raiseRecoverable(r,`Invalid use of 'super'`),this.eat(z.parenL)?e.arguments=this.parseExprList(z.parenR,this.options.ecmaVersion>=8,!1):e.arguments=Ji,this.finishNode(e,`NewExpression`)},H.parseTemplateElement=function(e){var t=e.isTagged,n=this.startNode();return this.type===z.invalidTemplate?(t||this.raiseRecoverable(this.start,`Bad escape sequence in untagged template literal`),n.value={raw:this.value.replace(/\\r\\n?/g,`\n`),cooked:null}):n.value={raw:this.input.slice(this.start,this.end).replace(/\\r\\n?/g,`\n`),cooked:this.value},this.next(),n.tail=this.type===z.backQuote,this.finishNode(n,`TemplateElement`)},H.parseTemplate=function(e){e===void 0&&(e={});var t=e.isTagged;t===void 0&&(t=!1);var n=this.startNode();this.next(),n.expressions=[];var r=this.parseTemplateElement({isTagged:t});for(n.quasis=[r];!r.tail;)this.type===z.eof&&this.raise(this.pos,`Unterminated template literal`),this.expect(z.dollarBraceL),n.expressions.push(this.parseExpression()),this.expect(z.braceR),n.quasis.push(r=this.parseTemplateElement({isTagged:t}));return this.next(),this.finishNode(n,`TemplateLiteral`)},H.isAsyncProp=function(e){return!e.computed&&e.key.type===`Identifier`&&e.key.name===`async`&&(this.type===z.name||this.type===z.num||this.type===z.string||this.type===z.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===z.star)&&!Hr.test(this.input.slice(this.lastTokEnd,this.start))},H.parseObj=function(e,t){var n=this.startNode(),r=!0,i={};for(n.properties=[],this.next();!this.eat(z.braceR);){if(r)r=!1;else if(this.expect(z.comma),this.options.ecmaVersion>=5&&this.afterTrailingComma(z.braceR))break;var a=this.parseProperty(e,t);e||this.checkPropClash(a,i,t),n.properties.push(a)}return this.finishNode(n,e?`ObjectPattern`:`ObjectExpression`)},H.parseProperty=function(e,t){var n=this.startNode(),r,i,a,o;if(this.options.ecmaVersion>=9&&this.eat(z.ellipsis))return e?(n.argument=this.parseIdent(!1),this.type===z.comma&&this.raiseRecoverable(this.start,`Comma is not permitted after the rest element`),this.finishNode(n,`RestElement`)):(n.argument=this.parseMaybeAssign(!1,t),this.type===z.comma&&t&&t.trailingComma<0&&(t.trailingComma=this.start),this.finishNode(n,`SpreadElement`));this.options.ecmaVersion>=6&&(n.method=!1,n.shorthand=!1,(e||t)&&(a=this.start,o=this.startLoc),e||(r=this.eat(z.star)));var s=this.containsEsc;return this.parsePropertyName(n),!e&&!s&&this.options.ecmaVersion>=8&&!r&&this.isAsyncProp(n)?(i=!0,r=this.options.ecmaVersion>=9&&this.eat(z.star),this.parsePropertyName(n)):i=!1,this.parsePropertyValue(n,e,r,i,a,o,t,s),this.finishNode(n,`Property`)},H.parseGetterSetter=function(e){var t=e.key.name;this.parsePropertyName(e),e.value=this.parseMethod(!1),e.kind=t;var n=e.kind===`get`?0:1;if(e.value.params.length!==n){var r=e.value.start;e.kind===`get`?this.raiseRecoverable(r,`getter should have no params`):this.raiseRecoverable(r,`setter should have exactly one param`)}else e.kind===`set`&&e.value.params[0].type===`RestElement`&&this.raiseRecoverable(e.value.params[0].start,`Setter cannot use rest params`)},H.parsePropertyValue=function(e,t,n,r,i,a,o,s){(n||r)&&this.type===z.colon&&this.unexpected(),this.eat(z.colon)?(e.value=t?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,o),e.kind=`init`):this.options.ecmaVersion>=6&&this.type===z.parenL?(t&&this.unexpected(),e.method=!0,e.value=this.parseMethod(n,r),e.kind=`init`):!t&&!s&&this.options.ecmaVersion>=5&&!e.computed&&e.key.type===`Identifier`&&(e.key.name===`get`||e.key.name===`set`)&&this.type!==z.comma&&this.type!==z.braceR&&this.type!==z.eq?((n||r)&&this.unexpected(),this.parseGetterSetter(e)):this.options.ecmaVersion>=6&&!e.computed&&e.key.type===`Identifier`?((n||r)&&this.unexpected(),this.checkUnreserved(e.key),e.key.name===`await`&&!this.awaitIdentPos&&(this.awaitIdentPos=i),t?e.value=this.parseMaybeDefault(i,a,this.copyNode(e.key)):this.type===z.eq&&o?(o.shorthandAssign<0&&(o.shorthandAssign=this.start),e.value=this.parseMaybeDefault(i,a,this.copyNode(e.key))):e.value=this.copyNode(e.key),e.kind=`init`,e.shorthand=!0):this.unexpected()},H.parsePropertyName=function(e){if(this.options.ecmaVersion>=6){if(this.eat(z.bracketL))return e.computed=!0,e.key=this.parseMaybeAssign(),this.expect(z.bracketR),e.key;e.computed=!1}return e.key=this.type===z.num||this.type===z.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!==`never`)},H.initFunction=function(e){e.id=null,this.options.ecmaVersion>=6&&(e.generator=e.expression=!1),this.options.ecmaVersion>=8&&(e.async=!1)},H.parseMethod=function(e,t,n){var r=this.startNode(),i=this.yieldPos,a=this.awaitPos,o=this.awaitIdentPos;return this.initFunction(r),this.options.ecmaVersion>=6&&(r.generator=e),this.options.ecmaVersion>=8&&(r.async=!!t),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(Si(t,r.generator)|gi|(n?_i:0)),this.expect(z.parenL),r.params=this.parseBindingList(z.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(r,!1,!0,!1),this.yieldPos=i,this.awaitPos=a,this.awaitIdentPos=o,this.finishNode(r,`FunctionExpression`)},H.parseArrowExpression=function(e,t,n,r){var i=this.yieldPos,a=this.awaitPos,o=this.awaitIdentPos;return this.enterScope(Si(n,!1)|mi),this.initFunction(e),this.options.ecmaVersion>=8&&(e.async=!!n),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,e.params=this.toAssignableList(t,!0),this.parseFunctionBody(e,!0,!1,r),this.yieldPos=i,this.awaitPos=a,this.awaitIdentPos=o,this.finishNode(e,`ArrowFunctionExpression`)},H.parseFunctionBody=function(e,t,n,r){var i=t&&this.type!==z.braceL,a=this.strict,o=!1;if(i)e.body=this.parseMaybeAssign(r),e.expression=!0,this.checkParams(e,!1);else{var s=this.options.ecmaVersion>=7&&!this.isSimpleParamList(e.params);(!a||s)&&(o=this.strictDirective(this.end),o&&s&&this.raiseRecoverable(e.start,`Illegal 'use strict' directive in function with non-simple parameter list`));var c=this.labels;this.labels=[],o&&(this.strict=!0),this.checkParams(e,!a&&!o&&!t&&!n&&this.isSimpleParamList(e.params)),this.strict&&e.id&&this.checkLValSimple(e.id,Oi),e.body=this.parseBlock(!1,void 0,o&&!a),e.expression=!1,this.adaptDirectivePrologue(e.body.body),this.labels=c}this.exitScope()},H.isSimpleParamList=function(e){for(var t=0,n=e;t<n.length;t+=1)if(n[t].type!==`Identifier`)return!1;return!0},H.checkParams=function(e,t){for(var n=Object.create(null),r=0,i=e.params;r<i.length;r+=1){var a=i[r];this.checkLValInnerPattern(a,wi,t?null:n)}},H.parseExprList=function(e,t,n,r){for(var i=[],a=!0;!this.eat(e);){if(a)a=!1;else if(this.expect(z.comma),t&&this.afterTrailingComma(e))break;var o=void 0;n&&this.type===z.comma?o=null:this.type===z.ellipsis?(o=this.parseSpread(r),r&&this.type===z.comma&&r.trailingComma<0&&(r.trailingComma=this.start)):o=this.parseMaybeAssign(!1,r),i.push(o)}return i},H.checkUnreserved=function(e){var t=e.start,n=e.end,r=e.name;this.inGenerator&&r===`yield`&&this.raiseRecoverable(t,`Cannot use 'yield' as identifier inside a generator`),this.inAsync&&r===`await`&&this.raiseRecoverable(t,`Cannot use 'await' as identifier inside an async function`),!(this.currentThisScope().flags&xi)&&r===`arguments`&&this.raiseRecoverable(t,`Cannot use 'arguments' in class field initializer`),this.inClassStaticBlock&&(r===`arguments`||r===`await`)&&this.raise(t,`Cannot use `+r+` in class static initialization block`),this.keywords.test(r)&&this.raise(t,`Unexpected keyword '`+r+`'`),!(this.options.ecmaVersion<6&&this.input.slice(t,n).indexOf(`\\\\`)!==-1)&&(this.strict?this.reservedWordsStrict:this.reservedWords).test(r)&&(!this.inAsync&&r===`await`&&this.raiseRecoverable(t,`Cannot use keyword 'await' outside an async function`),this.raiseRecoverable(t,`The keyword '`+r+`' is reserved`))},H.parseIdent=function(e){var t=this.parseIdentNode();return this.next(!!e),this.finishNode(t,`Identifier`),e||(this.checkUnreserved(t),t.name===`await`&&!this.awaitIdentPos&&(this.awaitIdentPos=t.start)),t},H.parseIdentNode=function(){var e=this.startNode();return this.type===z.name?e.name=this.value:this.type.keyword?(e.name=this.type.keyword,(e.name===`class`||e.name===`function`)&&(this.lastTokEnd!==this.lastTokStart+1||this.input.charCodeAt(this.lastTokStart)!==46)&&this.context.pop(),this.type=z.name):this.unexpected(),e},H.parsePrivateIdent=function(){var e=this.startNode();return this.type===z.privateId?e.name=this.value:this.unexpected(),this.next(),this.finishNode(e,`PrivateIdentifier`),this.options.checkPrivateFields&&(this.privateNameStack.length===0?this.raise(e.start,`Private field '#`+e.name+`' must be declared in an enclosing class`):this.privateNameStack[this.privateNameStack.length-1].used.push(e)),e},H.parseYield=function(e){this.yieldPos||(this.yieldPos=this.start);var t=this.startNode();return this.next(),this.type===z.semi||this.canInsertSemicolon()||this.type!==z.star&&!this.type.startsExpr?(t.delegate=!1,t.argument=null):(t.delegate=this.eat(z.star),t.argument=this.parseMaybeAssign(e)),this.finishNode(t,`YieldExpression`)},H.parseAwait=function(e){this.awaitPos||(this.awaitPos=this.start);var t=this.startNode();return this.next(),t.argument=this.parseMaybeUnary(null,!0,!1,e),this.finishNode(t,`AwaitExpression`)};var Yi=ki.prototype;Yi.raise=function(e,t){var n=ai(this.input,e);t+=` (`+n.line+`:`+n.column+`)`,this.sourceFile&&(t+=` in `+this.sourceFile);var r=SyntaxError(t);throw r.pos=e,r.loc=n,r.raisedAt=this.pos,r},Yi.raiseRecoverable=Yi.raise,Yi.curPosition=function(){if(this.options.locations)return new ri(this.curLine,this.pos-this.lineStart)};var Xi=ki.prototype,Zi=function(e){this.flags=e,this.var=[],this.lexical=[],this.functions=[]};Xi.enterScope=function(e){this.scopeStack.push(new Zi(e))},Xi.exitScope=function(){this.scopeStack.pop()},Xi.treatFunctionsAsVarInScope=function(e){return e.flags&di||!this.inModule&&e.flags&ui},Xi.declareName=function(e,t,n){var r=!1;if(t===Ti){var i=this.currentScope();r=i.lexical.indexOf(e)>-1||i.functions.indexOf(e)>-1||i.var.indexOf(e)>-1,i.lexical.push(e),this.inModule&&i.flags&ui&&delete this.undefinedExports[e]}else if(t===Di)this.currentScope().lexical.push(e);else if(t===Ei){var a=this.currentScope();r=this.treatFunctionsAsVar?a.lexical.indexOf(e)>-1:a.lexical.indexOf(e)>-1||a.var.indexOf(e)>-1,a.functions.push(e)}else for(var o=this.scopeStack.length-1;o>=0;--o){var s=this.scopeStack[o];if(s.lexical.indexOf(e)>-1&&!(s.flags&hi&&s.lexical[0]===e)||!this.treatFunctionsAsVarInScope(s)&&s.functions.indexOf(e)>-1){r=!0;break}if(s.var.push(e),this.inModule&&s.flags&ui&&delete this.undefinedExports[e],s.flags&xi)break}r&&this.raiseRecoverable(n,`Identifier '`+e+`' has already been declared`)},Xi.checkLocalExport=function(e){this.scopeStack[0].lexical.indexOf(e.name)===-1&&this.scopeStack[0].var.indexOf(e.name)===-1&&(this.undefinedExports[e.name]=e)},Xi.currentScope=function(){return this.scopeStack[this.scopeStack.length-1]},Xi.currentVarScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&(xi|yi|vi))return t}},Xi.currentThisScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&(xi|yi|vi)&&!(t.flags&mi))return t}};var Qi=function(e,t,n){this.type=``,this.start=t,this.end=0,e.options.locations&&(this.loc=new ii(e,n)),e.options.directSourceFile&&(this.sourceFile=e.options.directSourceFile),e.options.ranges&&(this.range=[t,0])},$i=ki.prototype;$i.startNode=function(){return new Qi(this,this.start,this.startLoc)},$i.startNodeAt=function(e,t){return new Qi(this,e,t)};function ea(e,t,n,r){return e.type=t,e.end=n,this.options.locations&&(e.loc.end=r),this.options.ranges&&(e.range[1]=n),e}$i.finishNode=function(e,t){return ea.call(this,e,t,this.lastTokEnd,this.lastTokEndLoc)},$i.finishNodeAt=function(e,t,n,r){return ea.call(this,e,t,n,r)},$i.copyNode=function(e){var t=new Qi(this,e.start,this.startLoc);for(var n in e)t[n]=e[n];return t};var ta=`Berf Beria_Erfe Gara Garay Gukh Gurung_Khema Hrkt Katakana_Or_Hiragana Kawi Kirat_Rai Krai Nag_Mundari Nagm Ol_Onal Onao Sidetic Sidt Sunu Sunuwar Tai_Yo Tayo Todhri Todr Tolong_Siki Tols Tulu_Tigalari Tutg Unknown Zzzz`,na=`ASCII ASCII_Hex_Digit AHex Alphabetic Alpha Any Assigned Bidi_Control Bidi_C Bidi_Mirrored Bidi_M Case_Ignorable CI Cased Changes_When_Casefolded CWCF Changes_When_Casemapped CWCM Changes_When_Lowercased CWL Changes_When_NFKC_Casefolded CWKCF Changes_When_Titlecased CWT Changes_When_Uppercased CWU Dash Default_Ignorable_Code_Point DI Deprecated Dep Diacritic Dia Emoji Emoji_Component Emoji_Modifier Emoji_Modifier_Base Emoji_Presentation Extender Ext Grapheme_Base Gr_Base Grapheme_Extend Gr_Ext Hex_Digit Hex IDS_Binary_Operator IDSB IDS_Trinary_Operator IDST ID_Continue IDC ID_Start IDS Ideographic Ideo Join_Control Join_C Logical_Order_Exception LOE Lowercase Lower Math Noncharacter_Code_Point NChar Pattern_Syntax Pat_Syn Pattern_White_Space Pat_WS Quotation_Mark QMark Radical Regional_Indicator RI Sentence_Terminal STerm Soft_Dotted SD Terminal_Punctuation Term Unified_Ideograph UIdeo Uppercase Upper Variation_Selector VS White_Space space XID_Continue XIDC XID_Start XIDS`,ra=na+` Extended_Pictographic`,ia=ra,aa=ia+` EBase EComp EMod EPres ExtPict`,oa=aa,sa=oa,ca={9:na,10:ra,11:ia,12:aa,13:oa,14:sa},la=`Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji`,ua={9:``,10:``,11:``,12:``,13:``,14:la},da=`Cased_Letter LC Close_Punctuation Pe Connector_Punctuation Pc Control Cc cntrl Currency_Symbol Sc Dash_Punctuation Pd Decimal_Number Nd digit Enclosing_Mark Me Final_Punctuation Pf Format Cf Initial_Punctuation Pi Letter L Letter_Number Nl Line_Separator Zl Lowercase_Letter Ll Mark M Combining_Mark Math_Symbol Sm Modifier_Letter Lm Modifier_Symbol Sk Nonspacing_Mark Mn Number N Open_Punctuation Ps Other C Other_Letter Lo Other_Number No Other_Punctuation Po Other_Symbol So Paragraph_Separator Zp Private_Use Co Punctuation P punct Separator Z Space_Separator Zs Spacing_Mark Mc Surrogate Cs Symbol S Titlecase_Letter Lt Unassigned Cn Uppercase_Letter Lu`,fa=`Adlam Adlm Ahom Anatolian_Hieroglyphs Hluw Arabic Arab Armenian Armn Avestan Avst Balinese Bali Bamum Bamu Bassa_Vah Bass Batak Batk Bengali Beng Bhaiksuki Bhks Bopomofo Bopo Brahmi Brah Braille Brai Buginese Bugi Buhid Buhd Canadian_Aboriginal Cans Carian Cari Caucasian_Albanian Aghb Chakma Cakm Cham Cham Cherokee Cher Common Zyyy Coptic Copt Qaac Cuneiform Xsux Cypriot Cprt Cyrillic Cyrl Deseret Dsrt Devanagari Deva Duployan Dupl Egyptian_Hieroglyphs Egyp Elbasan Elba Ethiopic Ethi Georgian Geor Glagolitic Glag Gothic Goth Grantha Gran Greek Grek Gujarati Gujr Gurmukhi Guru Han Hani Hangul Hang Hanunoo Hano Hatran Hatr Hebrew Hebr Hiragana Hira Imperial_Aramaic Armi Inherited Zinh Qaai Inscriptional_Pahlavi Phli Inscriptional_Parthian Prti Javanese Java Kaithi Kthi Kannada Knda Katakana Kana Kayah_Li Kali Kharoshthi Khar Khmer Khmr Khojki Khoj Khudawadi Sind Lao Laoo Latin Latn Lepcha Lepc Limbu Limb Linear_A Lina Linear_B Linb Lisu Lisu Lycian Lyci Lydian Lydi Mahajani Mahj Malayalam Mlym Mandaic Mand Manichaean Mani Marchen Marc Masaram_Gondi Gonm Meetei_Mayek Mtei Mende_Kikakui Mend Meroitic_Cursive Merc Meroitic_Hieroglyphs Mero Miao Plrd Modi Mongolian Mong Mro Mroo Multani Mult Myanmar Mymr Nabataean Nbat New_Tai_Lue Talu Newa Newa Nko Nkoo Nushu Nshu Ogham Ogam Ol_Chiki Olck Old_Hungarian Hung Old_Italic Ital Old_North_Arabian Narb Old_Permic Perm Old_Persian Xpeo Old_South_Arabian Sarb Old_Turkic Orkh Oriya Orya Osage Osge Osmanya Osma Pahawh_Hmong Hmng Palmyrene Palm Pau_Cin_Hau Pauc Phags_Pa Phag Phoenician Phnx Psalter_Pahlavi Phlp Rejang Rjng Runic Runr Samaritan Samr Saurashtra Saur Sharada Shrd Shavian Shaw Siddham Sidd SignWriting Sgnw Sinhala Sinh Sora_Sompeng Sora Soyombo Soyo Sundanese Sund Syloti_Nagri Sylo Syriac Syrc Tagalog Tglg Tagbanwa Tagb Tai_Le Tale Tai_Tham Lana Tai_Viet Tavt Takri Takr Tamil Taml Tangut Tang Telugu Telu Thaana Thaa Thai Thai Tibetan Tibt Tifinagh Tfng Tirhuta Tirh Ugaritic Ugar Vai Vaii Warang_Citi Wara Yi Yiii Zanabazar_Square Zanb`,pa=fa+` Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd`,ma=pa+` Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho`,ha=ma+` Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi`,ga=ha+` Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith`,_a=ga+` `+ta,va={9:fa,10:pa,11:ma,12:ha,13:ga,14:_a},ya={};function ba(e){var t=ya[e]={binary:ei(ca[e]+` `+da),binaryOfStrings:ei(ua[e]),nonBinary:{General_Category:ei(da),Script:ei(va[e])}};t.nonBinary.Script_Extensions=t.nonBinary.Script,t.nonBinary.gc=t.nonBinary.General_Category,t.nonBinary.sc=t.nonBinary.Script,t.nonBinary.scx=t.nonBinary.Script_Extensions}for(var xa=0,Sa=[9,10,11,12,13,14];xa<Sa.length;xa+=1){var Ca=Sa[xa];ba(Ca)}var U=ki.prototype,wa=function(e,t){this.parent=e,this.base=t||this};wa.prototype.separatedFrom=function(e){for(var t=this;t;t=t.parent)for(var n=e;n;n=n.parent)if(t.base===n.base&&t!==n)return!0;return!1},wa.prototype.sibling=function(){return new wa(this.parent,this.base)};var Ta=function(e){this.parser=e,this.validFlags=`gim`+(e.options.ecmaVersion>=6?`uy`:``)+(e.options.ecmaVersion>=9?`s`:``)+(e.options.ecmaVersion>=13?`d`:``)+(e.options.ecmaVersion>=15?`v`:``),this.unicodeProperties=ya[e.options.ecmaVersion>=14?14:e.options.ecmaVersion],this.source=``,this.flags=``,this.start=0,this.switchU=!1,this.switchV=!1,this.switchN=!1,this.pos=0,this.lastIntValue=0,this.lastStringValue=``,this.lastAssertionIsQuantifiable=!1,this.numCapturingParens=0,this.maxBackReference=0,this.groupNames=Object.create(null),this.backReferenceNames=[],this.branchID=null};Ta.prototype.reset=function(e,t,n){var r=n.indexOf(`v`)!==-1,i=n.indexOf(`u`)!==-1;this.start=e|0,this.source=t+``,this.flags=n,r&&this.parser.options.ecmaVersion>=15?(this.switchU=!0,this.switchV=!0,this.switchN=!0):(this.switchU=i&&this.parser.options.ecmaVersion>=6,this.switchV=!1,this.switchN=i&&this.parser.options.ecmaVersion>=9)},Ta.prototype.raise=function(e){this.parser.raiseRecoverable(this.start,`Invalid regular expression: /`+this.source+`/: `+e)},Ta.prototype.at=function(e,t){t===void 0&&(t=!1);var n=this.source,r=n.length;if(e>=r)return-1;var i=n.charCodeAt(e);if(!(t||this.switchU)||i<=55295||i>=57344||e+1>=r)return i;var a=n.charCodeAt(e+1);return a>=56320&&a<=57343?(i<<10)+a-56613888:i},Ta.prototype.nextIndex=function(e,t){t===void 0&&(t=!1);var n=this.source,r=n.length;if(e>=r)return r;var i=n.charCodeAt(e),a;return!(t||this.switchU)||i<=55295||i>=57344||e+1>=r||(a=n.charCodeAt(e+1))<56320||a>57343?e+1:e+2},Ta.prototype.current=function(e){return e===void 0&&(e=!1),this.at(this.pos,e)},Ta.prototype.lookahead=function(e){return e===void 0&&(e=!1),this.at(this.nextIndex(this.pos,e),e)},Ta.prototype.advance=function(e){e===void 0&&(e=!1),this.pos=this.nextIndex(this.pos,e)},Ta.prototype.eat=function(e,t){return t===void 0&&(t=!1),this.current(t)===e?(this.advance(t),!0):!1},Ta.prototype.eatChars=function(e,t){t===void 0&&(t=!1);for(var n=this.pos,r=0,i=e;r<i.length;r+=1){var a=i[r],o=this.at(n,t);if(o===-1||o!==a)return!1;n=this.nextIndex(n,t)}return this.pos=n,!0},U.validateRegExpFlags=function(e){for(var t=e.validFlags,n=e.flags,r=!1,i=!1,a=0;a<n.length;a++){var o=n.charAt(a);t.indexOf(o)===-1&&this.raise(e.start,`Invalid regular expression flag`),n.indexOf(o,a+1)>-1&&this.raise(e.start,`Duplicate regular expression flag`),o===`u`&&(r=!0),o===`v`&&(i=!0)}this.options.ecmaVersion>=15&&r&&i&&this.raise(e.start,`Invalid regular expression flag`)};function Ea(e){for(var t in e)return!0;return!1}U.validateRegExpPattern=function(e){this.regexp_pattern(e),!e.switchN&&this.options.ecmaVersion>=9&&Ea(e.groupNames)&&(e.switchN=!0,this.regexp_pattern(e))},U.regexp_pattern=function(e){e.pos=0,e.lastIntValue=0,e.lastStringValue=``,e.lastAssertionIsQuantifiable=!1,e.numCapturingParens=0,e.maxBackReference=0,e.groupNames=Object.create(null),e.backReferenceNames.length=0,e.branchID=null,this.regexp_disjunction(e),e.pos!==e.source.length&&(e.eat(41)&&e.raise(`Unmatched ')'`),(e.eat(93)||e.eat(125))&&e.raise(`Lone quantifier brackets`)),e.maxBackReference>e.numCapturingParens&&e.raise(`Invalid escape`);for(var t=0,n=e.backReferenceNames;t<n.length;t+=1){var r=n[t];e.groupNames[r]||e.raise(`Invalid named capture referenced`)}},U.regexp_disjunction=function(e){var t=this.options.ecmaVersion>=16;for(t&&(e.branchID=new wa(e.branchID,null)),this.regexp_alternative(e);e.eat(124);)t&&(e.branchID=e.branchID.sibling()),this.regexp_alternative(e);t&&(e.branchID=e.branchID.parent),this.regexp_eatQuantifier(e,!0)&&e.raise(`Nothing to repeat`),e.eat(123)&&e.raise(`Lone quantifier brackets`)},U.regexp_alternative=function(e){for(;e.pos<e.source.length&&this.regexp_eatTerm(e););},U.regexp_eatTerm=function(e){return this.regexp_eatAssertion(e)?(e.lastAssertionIsQuantifiable&&this.regexp_eatQuantifier(e)&&e.switchU&&e.raise(`Invalid quantifier`),!0):(e.switchU?this.regexp_eatAtom(e):this.regexp_eatExtendedAtom(e))?(this.regexp_eatQuantifier(e),!0):!1},U.regexp_eatAssertion=function(e){var t=e.pos;if(e.lastAssertionIsQuantifiable=!1,e.eat(94)||e.eat(36))return!0;if(e.eat(92)){if(e.eat(66)||e.eat(98))return!0;e.pos=t}if(e.eat(40)&&e.eat(63)){var n=!1;if(this.options.ecmaVersion>=9&&(n=e.eat(60)),e.eat(61)||e.eat(33))return this.regexp_disjunction(e),e.eat(41)||e.raise(`Unterminated group`),e.lastAssertionIsQuantifiable=!n,!0}return e.pos=t,!1},U.regexp_eatQuantifier=function(e,t){return t===void 0&&(t=!1),this.regexp_eatQuantifierPrefix(e,t)?(e.eat(63),!0):!1},U.regexp_eatQuantifierPrefix=function(e,t){return e.eat(42)||e.eat(43)||e.eat(63)||this.regexp_eatBracedQuantifier(e,t)},U.regexp_eatBracedQuantifier=function(e,t){var n=e.pos;if(e.eat(123)){var r=0,i=-1;if(this.regexp_eatDecimalDigits(e)&&(r=e.lastIntValue,e.eat(44)&&this.regexp_eatDecimalDigits(e)&&(i=e.lastIntValue),e.eat(125)))return i!==-1&&i<r&&!t&&e.raise(`numbers out of order in {} quantifier`),!0;e.switchU&&!t&&e.raise(`Incomplete quantifier`),e.pos=n}return!1},U.regexp_eatAtom=function(e){return this.regexp_eatPatternCharacters(e)||e.eat(46)||this.regexp_eatReverseSolidusAtomEscape(e)||this.regexp_eatCharacterClass(e)||this.regexp_eatUncapturingGroup(e)||this.regexp_eatCapturingGroup(e)},U.regexp_eatReverseSolidusAtomEscape=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatAtomEscape(e))return!0;e.pos=t}return!1},U.regexp_eatUncapturingGroup=function(e){var t=e.pos;if(e.eat(40)){if(e.eat(63)){if(this.options.ecmaVersion>=16){var n=this.regexp_eatModifiers(e),r=e.eat(45);if(n||r){for(var i=0;i<n.length;i++){var a=n.charAt(i);n.indexOf(a,i+1)>-1&&e.raise(`Duplicate regular expression modifiers`)}if(r){var o=this.regexp_eatModifiers(e);!n&&!o&&e.current()===58&&e.raise(`Invalid regular expression modifiers`);for(var s=0;s<o.length;s++){var c=o.charAt(s);(o.indexOf(c,s+1)>-1||n.indexOf(c)>-1)&&e.raise(`Duplicate regular expression modifiers`)}}}}if(e.eat(58)){if(this.regexp_disjunction(e),e.eat(41))return!0;e.raise(`Unterminated group`)}}e.pos=t}return!1},U.regexp_eatCapturingGroup=function(e){if(e.eat(40)){if(this.options.ecmaVersion>=9?this.regexp_groupSpecifier(e):e.current()===63&&e.raise(`Invalid group`),this.regexp_disjunction(e),e.eat(41))return e.numCapturingParens+=1,!0;e.raise(`Unterminated group`)}return!1},U.regexp_eatModifiers=function(e){for(var t=``,n=0;(n=e.current())!==-1&&Da(n);)t+=ti(n),e.advance();return t};function Da(e){return e===105||e===109||e===115}U.regexp_eatExtendedAtom=function(e){return e.eat(46)||this.regexp_eatReverseSolidusAtomEscape(e)||this.regexp_eatCharacterClass(e)||this.regexp_eatUncapturingGroup(e)||this.regexp_eatCapturingGroup(e)||this.regexp_eatInvalidBracedQuantifier(e)||this.regexp_eatExtendedPatternCharacter(e)},U.regexp_eatInvalidBracedQuantifier=function(e){return this.regexp_eatBracedQuantifier(e,!0)&&e.raise(`Nothing to repeat`),!1},U.regexp_eatSyntaxCharacter=function(e){var t=e.current();return Oa(t)?(e.lastIntValue=t,e.advance(),!0):!1};function Oa(e){return e===36||e>=40&&e<=43||e===46||e===63||e>=91&&e<=94||e>=123&&e<=125}U.regexp_eatPatternCharacters=function(e){for(var t=e.pos,n=0;(n=e.current())!==-1&&!Oa(n);)e.advance();return e.pos!==t},U.regexp_eatExtendedPatternCharacter=function(e){var t=e.current();return t!==-1&&t!==36&&!(t>=40&&t<=43)&&t!==46&&t!==63&&t!==91&&t!==94&&t!==124?(e.advance(),!0):!1},U.regexp_groupSpecifier=function(e){if(e.eat(63)){this.regexp_eatGroupName(e)||e.raise(`Invalid group`);var t=this.options.ecmaVersion>=16,n=e.groupNames[e.lastStringValue];if(n)if(t)for(var r=0,i=n;r<i.length;r+=1)i[r].separatedFrom(e.branchID)||e.raise(`Duplicate capture group name`);else e.raise(`Duplicate capture group name`);t?(n||(e.groupNames[e.lastStringValue]=[])).push(e.branchID):e.groupNames[e.lastStringValue]=!0}},U.regexp_eatGroupName=function(e){if(e.lastStringValue=``,e.eat(60)){if(this.regexp_eatRegExpIdentifierName(e)&&e.eat(62))return!0;e.raise(`Invalid capture group name`)}return!1},U.regexp_eatRegExpIdentifierName=function(e){if(e.lastStringValue=``,this.regexp_eatRegExpIdentifierStart(e)){for(e.lastStringValue+=ti(e.lastIntValue);this.regexp_eatRegExpIdentifierPart(e);)e.lastStringValue+=ti(e.lastIntValue);return!0}return!1},U.regexp_eatRegExpIdentifierStart=function(e){var t=e.pos,n=this.options.ecmaVersion>=11,r=e.current(n);return e.advance(n),r===92&&this.regexp_eatRegExpUnicodeEscapeSequence(e,n)&&(r=e.lastIntValue),ka(r)?(e.lastIntValue=r,!0):(e.pos=t,!1)};function ka(e){return Ir(e,!0)||e===36||e===95}U.regexp_eatRegExpIdentifierPart=function(e){var t=e.pos,n=this.options.ecmaVersion>=11,r=e.current(n);return e.advance(n),r===92&&this.regexp_eatRegExpUnicodeEscapeSequence(e,n)&&(r=e.lastIntValue),Aa(r)?(e.lastIntValue=r,!0):(e.pos=t,!1)};function Aa(e){return Lr(e,!0)||e===36||e===95||e===8204||e===8205}U.regexp_eatAtomEscape=function(e){return this.regexp_eatBackReference(e)||this.regexp_eatCharacterClassEscape(e)||this.regexp_eatCharacterEscape(e)||e.switchN&&this.regexp_eatKGroupName(e)?!0:(e.switchU&&(e.current()===99&&e.raise(`Invalid unicode escape`),e.raise(`Invalid escape`)),!1)},U.regexp_eatBackReference=function(e){var t=e.pos;if(this.regexp_eatDecimalEscape(e)){var n=e.lastIntValue;if(e.switchU)return n>e.maxBackReference&&(e.maxBackReference=n),!0;if(n<=e.numCapturingParens)return!0;e.pos=t}return!1},U.regexp_eatKGroupName=function(e){if(e.eat(107)){if(this.regexp_eatGroupName(e))return e.backReferenceNames.push(e.lastStringValue),!0;e.raise(`Invalid named reference`)}return!1},U.regexp_eatCharacterEscape=function(e){return this.regexp_eatControlEscape(e)||this.regexp_eatCControlLetter(e)||this.regexp_eatZero(e)||this.regexp_eatHexEscapeSequence(e)||this.regexp_eatRegExpUnicodeEscapeSequence(e,!1)||!e.switchU&&this.regexp_eatLegacyOctalEscapeSequence(e)||this.regexp_eatIdentityEscape(e)},U.regexp_eatCControlLetter=function(e){var t=e.pos;if(e.eat(99)){if(this.regexp_eatControlLetter(e))return!0;e.pos=t}return!1},U.regexp_eatZero=function(e){return e.current()===48&&!Ha(e.lookahead())?(e.lastIntValue=0,e.advance(),!0):!1},U.regexp_eatControlEscape=function(e){var t=e.current();return t===116?(e.lastIntValue=9,e.advance(),!0):t===110?(e.lastIntValue=10,e.advance(),!0):t===118?(e.lastIntValue=11,e.advance(),!0):t===102?(e.lastIntValue=12,e.advance(),!0):t===114?(e.lastIntValue=13,e.advance(),!0):!1},U.regexp_eatControlLetter=function(e){var t=e.current();return ja(t)?(e.lastIntValue=t%32,e.advance(),!0):!1};function ja(e){return e>=65&&e<=90||e>=97&&e<=122}U.regexp_eatRegExpUnicodeEscapeSequence=function(e,t){t===void 0&&(t=!1);var n=e.pos,r=t||e.switchU;if(e.eat(117)){if(this.regexp_eatFixedHexDigits(e,4)){var i=e.lastIntValue;if(r&&i>=55296&&i<=56319){var a=e.pos;if(e.eat(92)&&e.eat(117)&&this.regexp_eatFixedHexDigits(e,4)){var o=e.lastIntValue;if(o>=56320&&o<=57343)return e.lastIntValue=(i-55296)*1024+(o-56320)+65536,!0}e.pos=a,e.lastIntValue=i}return!0}if(r&&e.eat(123)&&this.regexp_eatHexDigits(e)&&e.eat(125)&&Ma(e.lastIntValue))return!0;r&&e.raise(`Invalid unicode escape`),e.pos=n}return!1};function Ma(e){return e>=0&&e<=1114111}U.regexp_eatIdentityEscape=function(e){if(e.switchU)return this.regexp_eatSyntaxCharacter(e)?!0:e.eat(47)?(e.lastIntValue=47,!0):!1;var t=e.current();return t!==99&&(!e.switchN||t!==107)?(e.lastIntValue=t,e.advance(),!0):!1},U.regexp_eatDecimalEscape=function(e){e.lastIntValue=0;var t=e.current();if(t>=49&&t<=57){do e.lastIntValue=10*e.lastIntValue+(t-48),e.advance();while((t=e.current())>=48&&t<=57);return!0}return!1};var Na=0,Pa=1,Fa=2;U.regexp_eatCharacterClassEscape=function(e){var t=e.current();if(Ia(t))return e.lastIntValue=-1,e.advance(),Pa;var n=!1;if(e.switchU&&this.options.ecmaVersion>=9&&((n=t===80)||t===112)){e.lastIntValue=-1,e.advance();var r;if(e.eat(123)&&(r=this.regexp_eatUnicodePropertyValueExpression(e))&&e.eat(125))return n&&r===Fa&&e.raise(`Invalid property name`),r;e.raise(`Invalid property name`)}return Na};function Ia(e){return e===100||e===68||e===115||e===83||e===119||e===87}U.regexp_eatUnicodePropertyValueExpression=function(e){var t=e.pos;if(this.regexp_eatUnicodePropertyName(e)&&e.eat(61)){var n=e.lastStringValue;if(this.regexp_eatUnicodePropertyValue(e)){var r=e.lastStringValue;return this.regexp_validateUnicodePropertyNameAndValue(e,n,r),Pa}}if(e.pos=t,this.regexp_eatLoneUnicodePropertyNameOrValue(e)){var i=e.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(e,i)}return Na},U.regexp_validateUnicodePropertyNameAndValue=function(e,t,n){Zr(e.unicodeProperties.nonBinary,t)||e.raise(`Invalid property name`),e.unicodeProperties.nonBinary[t].test(n)||e.raise(`Invalid property value`)},U.regexp_validateUnicodePropertyNameOrValue=function(e,t){if(e.unicodeProperties.binary.test(t))return Pa;if(e.switchV&&e.unicodeProperties.binaryOfStrings.test(t))return Fa;e.raise(`Invalid property name`)},U.regexp_eatUnicodePropertyName=function(e){var t=0;for(e.lastStringValue=``;La(t=e.current());)e.lastStringValue+=ti(t),e.advance();return e.lastStringValue!==``};function La(e){return ja(e)||e===95}U.regexp_eatUnicodePropertyValue=function(e){var t=0;for(e.lastStringValue=``;Ra(t=e.current());)e.lastStringValue+=ti(t),e.advance();return e.lastStringValue!==``};function Ra(e){return La(e)||Ha(e)}U.regexp_eatLoneUnicodePropertyNameOrValue=function(e){return this.regexp_eatUnicodePropertyValue(e)},U.regexp_eatCharacterClass=function(e){if(e.eat(91)){var t=e.eat(94),n=this.regexp_classContents(e);return e.eat(93)||e.raise(`Unterminated character class`),t&&n===Fa&&e.raise(`Negated character class may contain strings`),!0}return!1},U.regexp_classContents=function(e){return e.current()===93?Pa:e.switchV?this.regexp_classSetExpression(e):(this.regexp_nonEmptyClassRanges(e),Pa)},U.regexp_nonEmptyClassRanges=function(e){for(;this.regexp_eatClassAtom(e);){var t=e.lastIntValue;if(e.eat(45)&&this.regexp_eatClassAtom(e)){var n=e.lastIntValue;e.switchU&&(t===-1||n===-1)&&e.raise(`Invalid character class`),t!==-1&&n!==-1&&t>n&&e.raise(`Range out of order in character class`)}}},U.regexp_eatClassAtom=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatClassEscape(e))return!0;if(e.switchU){var n=e.current();(n===99||Ga(n))&&e.raise(`Invalid class escape`),e.raise(`Invalid escape`)}e.pos=t}var r=e.current();return r===93?!1:(e.lastIntValue=r,e.advance(),!0)},U.regexp_eatClassEscape=function(e){var t=e.pos;if(e.eat(98))return e.lastIntValue=8,!0;if(e.switchU&&e.eat(45))return e.lastIntValue=45,!0;if(!e.switchU&&e.eat(99)){if(this.regexp_eatClassControlLetter(e))return!0;e.pos=t}return this.regexp_eatCharacterClassEscape(e)||this.regexp_eatCharacterEscape(e)},U.regexp_classSetExpression=function(e){var t=Pa,n;if(!this.regexp_eatClassSetRange(e))if(n=this.regexp_eatClassSetOperand(e)){n===Fa&&(t=Fa);for(var r=e.pos;e.eatChars([38,38]);){if(e.current()!==38&&(n=this.regexp_eatClassSetOperand(e))){n!==Fa&&(t=Pa);continue}e.raise(`Invalid character in character class`)}if(r!==e.pos)return t;for(;e.eatChars([45,45]);)this.regexp_eatClassSetOperand(e)||e.raise(`Invalid character in character class`);if(r!==e.pos)return t}else e.raise(`Invalid character in character class`);for(;;)if(!this.regexp_eatClassSetRange(e)){if(n=this.regexp_eatClassSetOperand(e),!n)return t;n===Fa&&(t=Fa)}},U.regexp_eatClassSetRange=function(e){var t=e.pos;if(this.regexp_eatClassSetCharacter(e)){var n=e.lastIntValue;if(e.eat(45)&&this.regexp_eatClassSetCharacter(e)){var r=e.lastIntValue;return n!==-1&&r!==-1&&n>r&&e.raise(`Range out of order in character class`),!0}e.pos=t}return!1},U.regexp_eatClassSetOperand=function(e){return this.regexp_eatClassSetCharacter(e)?Pa:this.regexp_eatClassStringDisjunction(e)||this.regexp_eatNestedClass(e)},U.regexp_eatNestedClass=function(e){var t=e.pos;if(e.eat(91)){var n=e.eat(94),r=this.regexp_classContents(e);if(e.eat(93))return n&&r===Fa&&e.raise(`Negated character class may contain strings`),r;e.pos=t}if(e.eat(92)){var i=this.regexp_eatCharacterClassEscape(e);if(i)return i;e.pos=t}return null},U.regexp_eatClassStringDisjunction=function(e){var t=e.pos;if(e.eatChars([92,113])){if(e.eat(123)){var n=this.regexp_classStringDisjunctionContents(e);if(e.eat(125))return n}else e.raise(`Invalid escape`);e.pos=t}return null},U.regexp_classStringDisjunctionContents=function(e){for(var t=this.regexp_classString(e);e.eat(124);)this.regexp_classString(e)===Fa&&(t=Fa);return t},U.regexp_classString=function(e){for(var t=0;this.regexp_eatClassSetCharacter(e);)t++;return t===1?Pa:Fa},U.regexp_eatClassSetCharacter=function(e){var t=e.pos;if(e.eat(92))return this.regexp_eatCharacterEscape(e)||this.regexp_eatClassSetReservedPunctuator(e)?!0:e.eat(98)?(e.lastIntValue=8,!0):(e.pos=t,!1);var n=e.current();return n<0||n===e.lookahead()&&za(n)||Ba(n)?!1:(e.advance(),e.lastIntValue=n,!0)};function za(e){return e===33||e>=35&&e<=38||e>=42&&e<=44||e===46||e>=58&&e<=64||e===94||e===96||e===126}function Ba(e){return e===40||e===41||e===45||e===47||e>=91&&e<=93||e>=123&&e<=125}U.regexp_eatClassSetReservedPunctuator=function(e){var t=e.current();return Va(t)?(e.lastIntValue=t,e.advance(),!0):!1};function Va(e){return e===33||e===35||e===37||e===38||e===44||e===45||e>=58&&e<=62||e===64||e===96||e===126}U.regexp_eatClassControlLetter=function(e){var t=e.current();return Ha(t)||t===95?(e.lastIntValue=t%32,e.advance(),!0):!1},U.regexp_eatHexEscapeSequence=function(e){var t=e.pos;if(e.eat(120)){if(this.regexp_eatFixedHexDigits(e,2))return!0;e.switchU&&e.raise(`Invalid escape`),e.pos=t}return!1},U.regexp_eatDecimalDigits=function(e){var t=e.pos,n=0;for(e.lastIntValue=0;Ha(n=e.current());)e.lastIntValue=10*e.lastIntValue+(n-48),e.advance();return e.pos!==t};function Ha(e){return e>=48&&e<=57}U.regexp_eatHexDigits=function(e){var t=e.pos,n=0;for(e.lastIntValue=0;Ua(n=e.current());)e.lastIntValue=16*e.lastIntValue+Wa(n),e.advance();return e.pos!==t};function Ua(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function Wa(e){return e>=65&&e<=70?10+(e-65):e>=97&&e<=102?10+(e-97):e-48}U.regexp_eatLegacyOctalEscapeSequence=function(e){if(this.regexp_eatOctalDigit(e)){var t=e.lastIntValue;if(this.regexp_eatOctalDigit(e)){var n=e.lastIntValue;t<=3&&this.regexp_eatOctalDigit(e)?e.lastIntValue=t*64+n*8+e.lastIntValue:e.lastIntValue=t*8+n}else e.lastIntValue=t;return!0}return!1},U.regexp_eatOctalDigit=function(e){var t=e.current();return Ga(t)?(e.lastIntValue=t-48,e.advance(),!0):(e.lastIntValue=0,!1)};function Ga(e){return e>=48&&e<=55}U.regexp_eatFixedHexDigits=function(e,t){var n=e.pos;e.lastIntValue=0;for(var r=0;r<t;++r){var i=e.current();if(!Ua(i))return e.pos=n,!1;e.lastIntValue=16*e.lastIntValue+Wa(i),e.advance()}return!0};var Ka=function(e){this.type=e.type,this.value=e.value,this.start=e.start,this.end=e.end,e.options.locations&&(this.loc=new ii(e,e.startLoc,e.endLoc)),e.options.ranges&&(this.range=[e.start,e.end])},W=ki.prototype;W.next=function(e){!e&&this.type.keyword&&this.containsEsc&&this.raiseRecoverable(this.start,`Escape sequence in keyword `+this.type.keyword),this.options.onToken&&this.options.onToken(new Ka(this)),this.lastTokEnd=this.end,this.lastTokStart=this.start,this.lastTokEndLoc=this.endLoc,this.lastTokStartLoc=this.startLoc,this.nextToken()},W.getToken=function(){return this.next(),new Ka(this)},typeof Symbol<`u`&&(W[Symbol.iterator]=function(){var e=this;return{next:function(){var t=e.getToken();return{done:t.type===z.eof,value:t}}}}),W.nextToken=function(){var e=this.curContext();if((!e||!e.preserveSpace)&&this.skipSpace(),this.start=this.pos,this.options.locations&&(this.startLoc=this.curPosition()),this.pos>=this.input.length)return this.finishToken(z.eof);if(e.override)return e.override(this);this.readToken(this.fullCharCodeAtPos())},W.readToken=function(e){return Ir(e,this.options.ecmaVersion>=6)||e===92?this.readWord():this.getTokenFromCode(e)},W.fullCharCodeAt=function(e){var t=this.input.charCodeAt(e);if(t<=55295||t>=56320)return t;var n=this.input.charCodeAt(e+1);return n<=56319||n>=57344?t:(t<<10)+n-56613888},W.fullCharCodeAtPos=function(){return this.fullCharCodeAt(this.pos)},W.skipBlockComment=function(){var e=this.options.onComment&&this.curPosition(),t=this.pos,n=this.input.indexOf(`*/`,this.pos+=2);if(n===-1&&this.raise(this.pos-2,`Unterminated comment`),this.pos=n+2,this.options.locations)for(var r=void 0,i=t;(r=Gr(this.input,i,this.pos))>-1;)++this.curLine,i=this.lineStart=r;this.options.onComment&&this.options.onComment(!0,this.input.slice(t+2,n),t,this.pos,e,this.curPosition())},W.skipLineComment=function(e){for(var t=this.pos,n=this.options.onComment&&this.curPosition(),r=this.input.charCodeAt(this.pos+=e);this.pos<this.input.length&&!Wr(r);)r=this.input.charCodeAt(++this.pos);this.options.onComment&&this.options.onComment(!1,this.input.slice(t+e,this.pos),t,this.pos,n,this.curPosition())},W.skipSpace=function(){loop:for(;this.pos<this.input.length;){var e=this.input.charCodeAt(this.pos);switch(e){case 32:case 160:++this.pos;break;case 13:this.input.charCodeAt(this.pos+1)===10&&++this.pos;case 10:case 8232:case 8233:++this.pos,this.options.locations&&(++this.curLine,this.lineStart=this.pos);break;case 47:switch(this.input.charCodeAt(this.pos+1)){case 42:this.skipBlockComment();break;case 47:this.skipLineComment(2);break;default:break loop}break;default:if(e>8&&e<14||e>=5760&&Kr.test(String.fromCharCode(e)))++this.pos;else break loop}}},W.finishToken=function(e,t){this.end=this.pos,this.options.locations&&(this.endLoc=this.curPosition());var n=this.type;this.type=e,this.value=t,this.updateContext(n)},W.readToken_dot=function(){var e=this.input.charCodeAt(this.pos+1);if(e>=48&&e<=57)return this.readNumber(!0);var t=this.input.charCodeAt(this.pos+2);return this.options.ecmaVersion>=6&&e===46&&t===46?(this.pos+=3,this.finishToken(z.ellipsis)):(++this.pos,this.finishToken(z.dot))},W.readToken_slash=function(){var e=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):e===61?this.finishOp(z.assign,2):this.finishOp(z.slash,1)},W.readToken_mult_modulo_exp=function(e){var t=this.input.charCodeAt(this.pos+1),n=1,r=e===42?z.star:z.modulo;return this.options.ecmaVersion>=7&&e===42&&t===42&&(++n,r=z.starstar,t=this.input.charCodeAt(this.pos+2)),t===61?this.finishOp(z.assign,n+1):this.finishOp(r,n)},W.readToken_pipe_amp=function(e){var t=this.input.charCodeAt(this.pos+1);return t===e?this.options.ecmaVersion>=12&&this.input.charCodeAt(this.pos+2)===61?this.finishOp(z.assign,3):this.finishOp(e===124?z.logicalOR:z.logicalAND,2):t===61?this.finishOp(z.assign,2):this.finishOp(e===124?z.bitwiseOR:z.bitwiseAND,1)},W.readToken_caret=function(){return this.input.charCodeAt(this.pos+1)===61?this.finishOp(z.assign,2):this.finishOp(z.bitwiseXOR,1)},W.readToken_plus_min=function(e){var t=this.input.charCodeAt(this.pos+1);return t===e?t===45&&!this.inModule&&this.input.charCodeAt(this.pos+2)===62&&(this.lastTokEnd===0||Hr.test(this.input.slice(this.lastTokEnd,this.pos)))?(this.skipLineComment(3),this.skipSpace(),this.nextToken()):this.finishOp(z.incDec,2):t===61?this.finishOp(z.assign,2):this.finishOp(z.plusMin,1)},W.readToken_lt_gt=function(e){var t=this.input.charCodeAt(this.pos+1),n=1;return t===e?(n=e===62&&this.input.charCodeAt(this.pos+2)===62?3:2,this.input.charCodeAt(this.pos+n)===61?this.finishOp(z.assign,n+1):this.finishOp(z.bitShift,n)):t===33&&e===60&&!this.inModule&&this.input.charCodeAt(this.pos+2)===45&&this.input.charCodeAt(this.pos+3)===45?(this.skipLineComment(4),this.skipSpace(),this.nextToken()):(t===61&&(n=2),this.finishOp(z.relational,n))},W.readToken_eq_excl=function(e){var t=this.input.charCodeAt(this.pos+1);return t===61?this.finishOp(z.equality,this.input.charCodeAt(this.pos+2)===61?3:2):e===61&&t===62&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(z.arrow)):this.finishOp(e===61?z.eq:z.prefix,1)},W.readToken_question=function(){var e=this.options.ecmaVersion;if(e>=11){var t=this.input.charCodeAt(this.pos+1);if(t===46){var n=this.input.charCodeAt(this.pos+2);if(n<48||n>57)return this.finishOp(z.questionDot,2)}if(t===63)return e>=12&&this.input.charCodeAt(this.pos+2)===61?this.finishOp(z.assign,3):this.finishOp(z.coalesce,2)}return this.finishOp(z.question,1)},W.readToken_numberSign=function(){var e=this.options.ecmaVersion,t=35;if(e>=13&&(++this.pos,t=this.fullCharCodeAtPos(),Ir(t,!0)||t===92))return this.finishToken(z.privateId,this.readWord1());this.raise(this.pos,`Unexpected character '`+ti(t)+`'`)},W.getTokenFromCode=function(e){switch(e){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(z.parenL);case 41:return++this.pos,this.finishToken(z.parenR);case 59:return++this.pos,this.finishToken(z.semi);case 44:return++this.pos,this.finishToken(z.comma);case 91:return++this.pos,this.finishToken(z.bracketL);case 93:return++this.pos,this.finishToken(z.bracketR);case 123:return++this.pos,this.finishToken(z.braceL);case 125:return++this.pos,this.finishToken(z.braceR);case 58:return++this.pos,this.finishToken(z.colon);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(z.backQuote);case 48:var t=this.input.charCodeAt(this.pos+1);if(t===120||t===88)return this.readRadixNumber(16);if(this.options.ecmaVersion>=6){if(t===111||t===79)return this.readRadixNumber(8);if(t===98||t===66)return this.readRadixNumber(2)}case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.readNumber(!1);case 34:case 39:return this.readString(e);case 47:return this.readToken_slash();case 37:case 42:return this.readToken_mult_modulo_exp(e);case 124:case 38:return this.readToken_pipe_amp(e);case 94:return this.readToken_caret();case 43:case 45:return this.readToken_plus_min(e);case 60:case 62:return this.readToken_lt_gt(e);case 61:case 33:return this.readToken_eq_excl(e);case 63:return this.readToken_question();case 126:return this.finishOp(z.prefix,1);case 35:return this.readToken_numberSign()}this.raise(this.pos,`Unexpected character '`+ti(e)+`'`)},W.finishOp=function(e,t){var n=this.input.slice(this.pos,this.pos+t);return this.pos+=t,this.finishToken(e,n)},W.readRegexp=function(){for(var e,t,n=this.pos;;){this.pos>=this.input.length&&this.raise(n,`Unterminated regular expression`);var r=this.input.charAt(this.pos);if(Hr.test(r)&&this.raise(n,`Unterminated regular expression`),e)e=!1;else{if(r===`[`)t=!0;else if(r===`]`&&t)t=!1;else if(r===`/`&&!t)break;e=r===`\\\\`}++this.pos}var i=this.input.slice(n,this.pos);++this.pos;var a=this.pos,o=this.readWord1();this.containsEsc&&this.unexpected(a);var s=this.regexpState||(this.regexpState=new Ta(this));s.reset(n,i,o),this.validateRegExpFlags(s),this.validateRegExpPattern(s);var c=null;try{c=new RegExp(i,o)}catch{}return this.finishToken(z.regexp,{pattern:i,flags:o,value:c})},W.readInt=function(e,t,n){for(var r=this.options.ecmaVersion>=12&&t===void 0,i=n&&this.input.charCodeAt(this.pos)===48,a=this.pos,o=0,s=0,c=0,l=t??1/0;c<l;++c,++this.pos){var u=this.input.charCodeAt(this.pos),d=void 0;if(r&&u===95){i&&this.raiseRecoverable(this.pos,`Numeric separator is not allowed in legacy octal numeric literals`),s===95&&this.raiseRecoverable(this.pos,`Numeric separator must be exactly one underscore`),c===0&&this.raiseRecoverable(this.pos,`Numeric separator is not allowed at the first of digits`),s=u;continue}if(d=u>=97?u-97+10:u>=65?u-65+10:u>=48&&u<=57?u-48:1/0,d>=e)break;s=u,o=o*e+d}return r&&s===95&&this.raiseRecoverable(this.pos-1,`Numeric separator is not allowed at the last of digits`),this.pos===a||t!=null&&this.pos-a!==t?null:o};function qa(e,t){return t?parseInt(e,8):parseFloat(e.replace(/_/g,``))}function Ja(e){return typeof BigInt==`function`?BigInt(e.replace(/_/g,``)):null}W.readRadixNumber=function(e){var t=this.pos;this.pos+=2;var n=this.readInt(e);return n??this.raise(this.start+2,`Expected number in radix `+e),this.options.ecmaVersion>=11&&this.input.charCodeAt(this.pos)===110?(n=Ja(this.input.slice(t,this.pos)),++this.pos):Ir(this.fullCharCodeAtPos())&&this.raise(this.pos,`Identifier directly after number`),this.finishToken(z.num,n)},W.readNumber=function(e){var t=this.pos;!e&&this.readInt(10,void 0,!0)===null&&this.raise(t,`Invalid number`);var n=this.pos-t>=2&&this.input.charCodeAt(t)===48;n&&this.strict&&this.raise(t,`Invalid number`);var r=this.input.charCodeAt(this.pos);if(!n&&!e&&this.options.ecmaVersion>=11&&r===110){var i=Ja(this.input.slice(t,this.pos));return++this.pos,Ir(this.fullCharCodeAtPos())&&this.raise(this.pos,`Identifier directly after number`),this.finishToken(z.num,i)}n&&/[89]/.test(this.input.slice(t,this.pos))&&(n=!1),r===46&&!n&&(++this.pos,this.readInt(10),r=this.input.charCodeAt(this.pos)),(r===69||r===101)&&!n&&(r=this.input.charCodeAt(++this.pos),(r===43||r===45)&&++this.pos,this.readInt(10)===null&&this.raise(t,`Invalid number`)),Ir(this.fullCharCodeAtPos())&&this.raise(this.pos,`Identifier directly after number`);var a=qa(this.input.slice(t,this.pos),n);return this.finishToken(z.num,a)},W.readCodePoint=function(){var e=this.input.charCodeAt(this.pos),t;if(e===123){this.options.ecmaVersion<6&&this.unexpected();var n=++this.pos;t=this.readHexChar(this.input.indexOf(`}`,this.pos)-this.pos),++this.pos,t>1114111&&this.invalidStringToken(n,`Code point out of bounds`)}else t=this.readHexChar(4);return t},W.readString=function(e){for(var t=``,n=++this.pos;;){this.pos>=this.input.length&&this.raise(this.start,`Unterminated string constant`);var r=this.input.charCodeAt(this.pos);if(r===e)break;r===92?(t+=this.input.slice(n,this.pos),t+=this.readEscapedChar(!1),n=this.pos):r===8232||r===8233?(this.options.ecmaVersion<10&&this.raise(this.start,`Unterminated string constant`),++this.pos,this.options.locations&&(this.curLine++,this.lineStart=this.pos)):(Wr(r)&&this.raise(this.start,`Unterminated string constant`),++this.pos)}return t+=this.input.slice(n,this.pos++),this.finishToken(z.string,t)};var Ya={};W.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(e){if(e===Ya)this.readInvalidTemplateToken();else throw e}this.inTemplateElement=!1},W.invalidStringToken=function(e,t){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw Ya;this.raise(e,t)},W.readTmplToken=function(){for(var e=``,t=this.pos;;){this.pos>=this.input.length&&this.raise(this.start,`Unterminated template`);var n=this.input.charCodeAt(this.pos);if(n===96||n===36&&this.input.charCodeAt(this.pos+1)===123)return this.pos===this.start&&(this.type===z.template||this.type===z.invalidTemplate)?n===36?(this.pos+=2,this.finishToken(z.dollarBraceL)):(++this.pos,this.finishToken(z.backQuote)):(e+=this.input.slice(t,this.pos),this.finishToken(z.template,e));if(n===92)e+=this.input.slice(t,this.pos),e+=this.readEscapedChar(!0),t=this.pos;else if(Wr(n)){switch(e+=this.input.slice(t,this.pos),++this.pos,n){case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:e+=`\n`;break;default:e+=String.fromCharCode(n);break}this.options.locations&&(++this.curLine,this.lineStart=this.pos),t=this.pos}else ++this.pos}},W.readInvalidTemplateToken=function(){for(;this.pos<this.input.length;this.pos++)switch(this.input[this.pos]){case`\\\\`:++this.pos;break;case`$`:if(this.input[this.pos+1]!==`{`)break;case\"`\":return this.finishToken(z.invalidTemplate,this.input.slice(this.start,this.pos));case`\\r`:this.input[this.pos+1]===`\n`&&++this.pos;case`\n`:case`\\u2028`:case`\\u2029`:++this.curLine,this.lineStart=this.pos+1;break}this.raise(this.start,`Unterminated template`)},W.readEscapedChar=function(e){var t=this.input.charCodeAt(++this.pos);switch(++this.pos,t){case 110:return`\n`;case 114:return`\\r`;case 120:return String.fromCharCode(this.readHexChar(2));case 117:return ti(this.readCodePoint());case 116:return`\t`;case 98:return`\\b`;case 118:return`\\v`;case 102:return`\\f`;case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:return this.options.locations&&(this.lineStart=this.pos,++this.curLine),``;case 56:case 57:if(this.strict&&this.invalidStringToken(this.pos-1,`Invalid escape sequence`),e){var n=this.pos-1;this.invalidStringToken(n,`Invalid escape sequence in template string`)}default:if(t>=48&&t<=55){var r=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],i=parseInt(r,8);return i>255&&(r=r.slice(0,-1),i=parseInt(r,8)),this.pos+=r.length-1,t=this.input.charCodeAt(this.pos),(r!==`0`||t===56||t===57)&&(this.strict||e)&&this.invalidStringToken(this.pos-1-r.length,e?`Octal literal in template string`:`Octal literal in strict mode`),String.fromCharCode(i)}return Wr(t)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),``):String.fromCharCode(t)}},W.readHexChar=function(e){var t=this.pos,n=this.readInt(16,e);return n===null&&this.invalidStringToken(t,`Bad character escape sequence`),n},W.readWord1=function(){this.containsEsc=!1;for(var e=``,t=!0,n=this.pos,r=this.options.ecmaVersion>=6;this.pos<this.input.length;){var i=this.fullCharCodeAtPos();if(Lr(i,r))this.pos+=i<=65535?1:2;else if(i===92){this.containsEsc=!0,e+=this.input.slice(n,this.pos);var a=this.pos;this.input.charCodeAt(++this.pos)!==117&&this.invalidStringToken(this.pos,`Expecting Unicode escape sequence \\\\uXXXX`),++this.pos;var o=this.readCodePoint();(t?Ir:Lr)(o,r)||this.invalidStringToken(a,`Invalid Unicode escape`),e+=ti(o),n=this.pos}else break;t=!1}return e+this.input.slice(n,this.pos)},W.readWord=function(){var e=this.readWord1(),t=z.name;return this.keywords.test(e)&&(t=Vr[e]),this.finishToken(t,e)},ki.acorn={Parser:ki,version:`8.19.0`,defaultOptions:oi,Position:ri,SourceLocation:ii,getLineInfo:ai,Node:Qi,TokenType:L,tokTypes:z,keywordTypes:Vr,TokContext:Wi,tokContexts:V,isIdentifierChar:Lr,isIdentifierStart:Ir,Token:Ka,isNewLine:Wr,lineBreak:Hr,lineBreakG:Ur,nonASCIIwhitespace:Kr};var Xa={ecmaVersion:`latest`,sourceType:`script`,allowReturnOutsideFunction:!0},Za=/\\w+(?![\\p{ID_Continue}$\\u200c\\u200d])/uy,Qa=/[A-Za-z_]\\w*(?![\\p{ID_Continue}$\\u200c\\u200d])/uy,$a=/^[$_]\\w+$/,eo=/[\\n\\r\\u2028\\u2029]/,to=/\\s*(?:[;},:)]|=(?![=>]))/y;function no(e,t){return to.lastIndex=t,to.test(e)}var ro=new Set([z.name,z.num,z.string,z.regexp,z.backQuote,z.bracketR,z.braceR,z.parenR,z.incDec,z._this,z._null,z._true,z._false]),io=class extends ki{constructor(...e){super(...e),this.operandBeforeLast=!0,this.operandHere=!0,this.breakBeforeLast=!1,this.breakHere=!1,this.ternaries=[],this.colonEndsTernary=!1,this.closedBlock=!1,this.typeBeforeLast=z.eof,this.lookahead=!0}readToken(e){let t=this;if(t.lastTokEnd=t.end,this.operandBeforeLast=this.operandHere,this.operandHere=t.exprAllowed,this.breakBeforeLast=this.breakHere,this.breakHere=eo.test(t.input.slice(t.end,t.pos)),e===64||e===37){let n=t.pos,r=e===64?Za:Qa;r.lastIndex=n+1;let i=r.exec(t.input)?.[0];if(i){let r=n+1+i.length,a=t.type===z.incDec&&(this.operandBeforeLast||this.breakBeforeLast),o=e===37?this.percentAt?.get(n):void 0;if(e===64||(o??(t.exprAllowed||a||this.lookahead&&ao(t,r)))){e===37&&this.transientsRead?.add(n),t.pos=r,t.finishToken(z.name,t.input.charAt(n)+i);return}}}super.readToken(e)}finishToken(e,t){let{context:n}=this,r=n.length;if(e===z.braceR){let e=n[r-1];this.closedBlock=e.token===`{`&&!e.isExpr}else if(e===z.question)this.ternaries[r]=(this.ternaries[r]??0)+1;else if(e===z.colon){let e=this.ternaries[r]??0;this.colonEndsTernary=e>0,e>0&&(this.ternaries[r]=e-1)}let i=this,a=i.type;this.prevValue=i.value;let o=e.keyword!==void 0&&(a===z.dot||a===z.questionDot)||(e===z._function||e===z._class)&&no(i.input,i.pos);if(!o&&(e===z._function||e===z._class)){let t=e===z._function&&a===z.name&&this.prevValue===`async`&&!this.breakHere?this.typeBeforeLast:a;i.type=t===z.colon&&this.colonEndsTernary?z.parenL:t}this.typeBeforeLast=a,super.finishToken(o?z.name:e,t),e===z.name&&t===`of`&&(a===z._const||a===z._var||this.prevValue===`let`)&&(i.exprAllowed=!1)}braceIsBlock(e){if(e===z.colon&&this.colonEndsTernary)return!1;if(e===z.braceR&&this.closedBlock||e===z.name&&this.prevValue===`static`)return!0;if(this.breakHere&&ro.has(e)){let{context:e}=this,t=e[e.length-1];if(t.token===`{`&&!t.isExpr)return!0}return super.braceIsBlock(e)}};function ao(e,t){if(!eo.test(e.input.slice(e.end,e.pos)))return!1;let n=co(e.input,t,`statements`,{afterOperand:!0});n.lookahead=!1;let r=0;try{for(;;){n.nextToken();let e=n.type;if(e===z.eof)return!1;if(r>0)oo.has(e)?r++:so.has(e)&&r--;else if(e===z.bracketL)r=1;else if(e===z.dot){if(n.nextToken(),n.type!==z.name&&!n.type.keyword)return!1}else return e===z.eq||e===z.assign}}catch{return!1}}var oo=new Set([z.parenL,z.bracketL,z.braceL,z.dollarBraceL]),so=new Set([z.parenR,z.bracketR,z.braceR]);function co(e,t,n,{onComment:r,afterOperand:i=!1}={}){let a=new io(r?{...Xa,onComment:r}:Xa,e,t);return n===`expression`&&(a.type=z.parenL),i&&(a.exprAllowed=!1),a}var lo=class extends SyntaxError{constructor(e,t,n,r){super(`${e} ${po(t,n)}`+uo(r,e=>fo(t,e))),this.reason=e,this.source=t,this.pos=n,this.bracket=r,this.name=`SyntaxError`}reasonIn(e,t){return this.reason+uo(this.bracket,n=>{let{line:r,column:i}=ai(e,t+n);return`at line ${r}, column ${i+1}`})}};function uo(e,t){return e?` (missing \"${e.closer}\" for the \"${e.open}\" ${t(e.pos)})`:``}function fo(e,t){let{line:n,column:r}=ai(e,t);return eo.test(e)?`at line ${n}, column ${r+1}`:`at column ${r+1}`}function po(e,t){let{column:n}=ai(e,t),r=t-n,i=e.slice(r).search(eo),a=i<0?e.length:r+i,o=Math.max(r,t-30),s=Math.min(a,t+30),c=(o>r?`…`:``)+e.slice(o,t)+`▶`+e.slice(t,s)+(s<a?`…`:``);return`${fo(e,t)}: ${c.trim()}`}var mo=e=>e[e.length-1],ho={\"(\":`)`,\"[\":`]`,\"{\":`}`,\"${\":`}`};function go(e,t){if(!(t instanceof SyntaxError)||!(`pos`in t))throw t;let n=t.pos,r=t.message.replace(/ \\(\\d+:\\d+\\)$/,``),{open:i,token:a}=_o(e,n),o=n>=e.length||a===``,s=!1;r===`Unexpected token`?(r=o?`Unexpected end of code`:`Unexpected \"${a}\"`,s=!!i&&ho[i.text]!==a&&(o||[`)`,`]`,`}`,`;`,`{`].includes(a))):r.startsWith(`Unterminated template`)&&(s=i?.text===\"${\");let c=s&&i?{open:i.text,closer:ho[i.text],pos:i.pos}:void 0;return new lo(r,e,n,c)}function _o(e,t){let n=[];for(let r of jo(e,0,`statements`)){if(`error`in r)break;if(r.start>=t||r.type===z.eof)return{open:mo(n),token:e.slice(r.start,r.end)};let i=e.slice(r.start,r.end);i in ho?n.push({text:i,pos:r.start}):n.length&&ho[mo(n).text]===i&&n.pop()}return{open:mo(n),token:e.charAt(t)}}function vo(e,t=`expression`){let n=new Map;for(;;){let r=new Set;try{let i=yo(e,t,n,r),a={refs:[],strings:[]};return wo(i,e,a,!1,!1),a.refs.sort((e,t)=>e.start-t.start),a}catch(t){let i=t.pos??-1;if(!(t instanceof SyntaxError)||n.has(i)||(Qa.lastIndex=i+1,e.charAt(i)!==`%`||!Qa.test(e)))throw t;n.set(i,!r.has(i))}}}function yo(e,t,n,r){try{let i=co(e,0,t);if(i.percentAt=n,i.transientsRead=r,t===`statements`)return i.parse();i.nextToken();let a=i.parseExpression();if(i.type!==z.eof)throw Object.assign(SyntaxError(`Unexpected token`),{pos:i.start});return a}catch(t){throw go(e,t)}}var bo=e=>typeof e==`object`&&!!e&&typeof e.type==`string`,xo={$:`story`,_:`temporary`,\"@\":`local`,\"%\":`transient`};function So(e,t){let n=e.name,r=t.charAt(e.start);return r===n.charAt(0)&&(r===`@`||r===`%`||(r===`$`||r===`_`)&&$a.test(n))?[r,n.slice(1)]:null}function Co(e,t){if(!bo(e)||e.type!==`Identifier`)return;let n=t.charAt(e.start);if(n===`@`||n===`%`)throw new lo(`\"${e.name}\" can't be a property name`,t,e.start)}function wo(e,t,n,r,i){if(Array.isArray(e)){for(let i of e)wo(i,t,n,r,!1);return}if(!bo(e))return;let a=(e,r=!1,i=!1)=>wo(e,t,n,r,i);switch(e.type){case`Identifier`:{let a=So(e,t);if(!a)return;if(r)throw new lo(`\"${e.name}\" is a ${xo[a[0]]} variable and can't be declared`,t,e.start);n.refs.push({sigil:a[0],name:a[1],start:e.start,end:e.end,shorthand:i});return}case`Literal`:typeof e.value==`string`&&n.strings.push(t.slice(e.start+1,e.end-1));return;case`TemplateElement`:n.strings.push(e.value.raw);return;case`MemberExpression`:a(e.object),e.computed?a(e.property):Co(e.property,t);return;case`Property`:if(e.computed?a(e.key):e.shorthand||Co(e.key,t),e.shorthand){let t=e.value;t.type===`AssignmentPattern`?(a(t.left,r,!0),a(t.right)):a(t,r,!0)}else a(e.value,r);return;case`MethodDefinition`:case`PropertyDefinition`:e.computed?a(e.key):Co(e.key,t),a(e.value);return;case`LabeledStatement`:a(e.body);return;case`BreakStatement`:case`ContinueStatement`:case`MetaProperty`:case`PrivateIdentifier`:return;case`VariableDeclarator`:a(e.id,!0),a(e.init);return;case`FunctionDeclaration`:case`FunctionExpression`:case`ArrowFunctionExpression`:a(e.id,!0);for(let t of e.params)a(t,!0);a(e.body);return;case`ClassDeclaration`:case`ClassExpression`:a(e.id,!0),a(e.superClass),a(e.body);return;case`CatchClause`:a(e.param,!0),a(e.body);return;case`AssignmentPattern`:a(e.left,r),a(e.right);return;case`ObjectPattern`:case`ArrayPattern`:case`RestElement`:for(let t of[`properties`,`elements`,`argument`])a(e[t],r);return;default:for(let t in e){if(t===`type`||t===`start`||t===`end`)continue;let n=e[t];typeof n==`object`&&n&&a(n)}}}var To=/[\\p{ID_Continue}$.]*/uy,Eo=/[\\p{ID_Continue}$]*/uy,Do=new Set([`of`,`get`,`set`,`static`,`async`]);function Oo(e,t,{goal:n=`expression`,stop:r}={}){let i=Ao(e,t,n,r);return i<0&&!r?ko(e,t,n):i}function ko(e,t,n){let r=co(e,t,n);try{if(n===`statements`)r.parse();else if(r.nextToken(),r.parseExpression(),r.type===z.braceR)return r.start}catch(t){let n=t.pos??-1;if(e.charAt(n)===`}`)return n}return-1}function Ao(e,t,n,r){let i=[],a=-1,o=!1,s=t,c=!1,l=!1;for(;;){let t=-1;for(let u of jo(e,s,n,{afterOperand:c})){if(`error`in u){let{message:n}=u.error,a=i.includes(\"${\");if(!/^Unterminated/.test(n)&&!a){if(t=Math.max(u.pos,s)+1,c=!1,t>=e.length)return-1;break}let o=i.lastIndexOf(\"${\");if(!/^Unterminated template/.test(n)||o<0||l||r)return-1;l=!0,i.length=o,t=u.pos,c=!0;break}if(u.restarted&&i.includes(\"${\"))return-1;let n=u.type;if(n===z.eof||n===z.string&&o&&u.start===a)return-1;if(o=n===z.name&&!Do.has(u.value)||n===z.num,a=u.end,n===z.braceL){if(r?.(u.start))return u.start;i.push(`{`)}else if(n===z.dollarBraceL)i.push(\"${\");else if(n===z.parenL)i.push(`(`);else if(n===z.bracketL)i.push(`[`);else if(n===z.parenR||n===z.bracketR)mo(i)===(n===z.parenR?`(`:`[`)&&i.pop();else if(n===z.braceR){let e=Math.max(i.lastIndexOf(`{`),i.lastIndexOf(\"${\"));if(e>=0)i.length=e;else if(!r)return u.start}}s=t,o=!1}}function*jo(e,t,n,r={}){let i=co(e,t,n,r);for(;;){try{i.nextToken()}catch(t){let n=Math.min(t.pos??i.pos,e.length),a=t.message,o=(t,n,a)=>(i=co(e,a,`statements`,{onComment:r.onComment,afterOperand:!0}),{type:t,start:n,end:a,value:void 0,restarted:!0}),s=e.charAt(i.start),c=/^Unterminated/.test(a);if(/^Unterminated string/.test(a)){let{end:t,closed:r}=Ro(e,n);if(r){yield o(z.string,n,t);continue}}else if(!c&&i.start<=n&&(s===`\"`||s===`'`)){let{end:t,closed:n}=Ro(e,i.start);if(n){yield o(z.string,i.start,t);continue}}else if(!c&&i.start<=n&&s===`/`){let t=Io(e,i.start);if(t>0){yield o(z.regexp,i.start,t);continue}}else if(!c&&i.start<=n&&/[\\d.]/.test(s)&&/\\d/.test(e.slice(i.start,i.start+2))){To.lastIndex=i.start,To.test(e),yield o(z.num,i.start,To.lastIndex);continue}yield{error:t,pos:n};return}if(yield{type:i.type,start:i.start,end:i.end,value:i.value},i.type===z.eof)return}}function Mo(e,t,n=`expression`){return No(e,0,t,0,n,!1)}function No(e,t,n,r,i,a){let o=[],s=(e,t,n,r)=>{o.push([n,r])},c=(t,i)=>{for(let a=t;a<i;a++)n.code?.(e.charAt(a),a,r)},l=(t,i)=>{i>t&&n.literal?.(e.slice(t,i),t,r)},u=(e,t)=>{for(let[n,r]of o)r<=e||n>=t||(c(e,n),l(n,r),e=r);o.length=0,c(e,t)},d=[],f=0,p=jo(e,t,i,{onComment:s}),m=t,h;for(;;){let t=p.next().value;if(`error`in t){let n=Math.max(m,t.pos);if(u(m,n),n>=e.length)return e.length;if(/^Unterminated/.test(t.error.message))return l(n,e.length),e.length;c(n,n+1),m=n+1,p=jo(e,m,i,{onComment:s}),h=void 0;continue}let o=t.type;if(o===z.eof)return u(m,e.length),e.length;if(u(m,t.start),o===z.name){let i=Po(e,t.start,t.value),a=h===z.dot||h===z.questionDot||(i===`$`||i===`_`)&&Fo(e,t.end,h);i&&!a?n.variable?.(i,e.slice(t.start+1,t.end),t.start,r):c(t.start,t.end)}else if(o===z.string||o===z.regexp||o===z.template||o===z.invalidTemplate)l(t.start,t.end);else if(o===z.backQuote)if(l(t.start,t.end),h===z.template||h===z.invalidTemplate){if(f--,a&&f===0)return t.end}else f++;else o===z.dollarBraceL?(l(t.start,t.end),d.push(\"${\"),r++):o===z.braceR&&mo(d)===\"${\"?(d.pop(),r--,l(t.start,t.end)):(o===z.braceL||o===z.parenL||o===z.bracketL?d.push(e.charAt(t.start)):(o===z.braceR||o===z.parenR||o===z.bracketR)&&d.length&&mo(d)!==\"${\"&&d.pop(),c(t.start,t.end));h=o,m=t.end}}function Po(e,t,n){let r=e.charAt(t);return(r===`@`||r===`%`)&&n.charAt(0)===r||(r===`$`||r===`_`)&&$a.test(n)?r:null}function Fo(e,t,n){if(n!==z.braceL&&n!==z.comma)return!1;let r=/\\S/g;r.lastIndex=t;let i=r.exec(e)?.[0];return i===`:`||i===`(`}function Io(e,t){let n=!1;for(let r=t+1;r<e.length;r++){let t=e.charAt(r);if(eo.test(t))return-1;if(t===`\\\\`)r++;else if(t===`[`)n=!0;else if(t===`]`)n=!1;else if(t===`/`&&!n)return Eo.lastIndex=r+1,Eo.test(e),Eo.lastIndex}return-1}function Lo(e){if(e[0]!==`\"`&&e[0]!==`'`)return null;try{let t=co(e,0,`expression`);return t.nextToken(),t.type===z.string&&t.end===e.length?t.value:null}catch{return null}}function Ro(e,t){let n=e.charAt(t),r=t+1;for(;r<e.length;){let t=e.charAt(r);if(t===`\\\\`)r+=2;else if(t===n)return{end:r+1,closed:!0};else r++}return{end:e.length,closed:!1}}var zo=/[\\p{L}\\p{N}_\\\\]/u;function Bo(e,t){let n=e[t],r=n===\"`\";for(let i=t+1;i<e.length;){let t=e[i];if(t===`\\\\`)i+=2;else if(t===n)return i+1;else if(!r&&t===`\n`)return-1;else if(r&&t===`$`&&e[i+1]===`{`){let t=Vo(e,i+2);if(t===-1)return-1;i=t+1}else i++}return-1}function Vo(e,t){Ho!==e&&(Ho=e,Uo.clear());let n=Uo.get(t);return n===void 0&&(n=Wo(e,t),Uo.set(t,n)),n}var Ho=``,Uo=new Map;function Wo(e,t){let n=0;for(;t<e.length;){let r=e[t];if(r===`{`)n++,t++;else if(r===`}`){if(n===0)return t;n--,t++}else if(r===\"`\"||(r===`\"`||r===`'`)&&!(t>0&&zo.test(e[t-1]))){let n=Bo(e,t);t=n===-1?t+1:n}else t++}return-1}var Go={closeBrace(e,t,n){let r=Oo(e,t);return r===-1?Vo(e,n):r},rawBodyEnd(e,t,n){let r=`\\\\{/${n}\\\\s*\\\\}`,i=new RegExp(r,`gi`);i.lastIndex=t;let a=i.exec(e)?.index??-1;if(a===-1)return-1;let o=new RegExp(r,`iy`),s=Oo(e,t,{goal:`statements`,stop:t=>(o.lastIndex=t,o.test(e))});return s===-1?a:s}};function Ko(e){let t=e.toLowerCase();return t.startsWith(`on`)||t===`pattern`||t===`srcdoc`}function qo(e){let t=[],n=``,r=0;for(;r<e.length;){let i=e.indexOf(`{`,r);if(i===-1){n+=e.slice(r);break}n+=e.slice(r,i),r=i+1;let a=Jn(e[r])?Go.closeBrace(e,r,r):-1;if(a===-1){n+=`{`;continue}n&&t.push({text:n}),n=``;let o=e.slice(r,a);t.push(/^.\\w/.test(o)?{expr:o}:{verbatim:`{${o}}`}),r=a+1}return n&&t.push({text:n}),t}var Jo=new Set([`do`]),Yo={...Go,isBlock:Cr,isRaw:e=>Jo.has(e),isCodeAttribute:Ko},Xo=class extends Error{constructor(e,t,n,r){super(`${e} (line ${n}, column ${r})`),this.reason=e,this.offset=t,this.line=n,this.column=r,this.name=`MarkupError`}};function Zo(e,t){let n=1,r=0;for(let i=e.indexOf(`\n`);i!==-1&&i<t;)n++,r=i+1,i=e.indexOf(`\n`,r);return{line:n,column:t-r+1}}function Qo(e,t,n){let r=n.hooks?{...Yo,...n.hooks}:Yo;try{return yr(e,{startRule:t,text:n.text===!0,hooks:r})}catch(t){let n=t.location;if(t instanceof Error&&t.name===`SyntaxError`&&n){let{offset:r}=n.start,{line:i,column:a}=Zo(e,r);throw new Xo(t.message,r,i,a)}throw t}}function $o(e,t={}){return Qo(e,`Markup`,t)}function es(e,t={}){return Qo(e,`Tokens`,t)}function ts(e,t={}){let n=[],r=[],i=e.lastIndexOf(`}`),{closeBrace:a}={...Yo,...t.hooks},o=(e,n)=>{let r={...t.hooks,closeBrace:(e,t,r)=>n+Math.min(t,r)>i?-1:a(e,t,r)};try{return es(e,{...t,hooks:r}).map(e=>ns(e,n))}catch(e){if(!(e instanceof Xo))throw e;return e}},s=0;for(;s<=e.length;){let t=e.slice(s),i=o(t,s);if(Array.isArray(i)){n.push(...i);break}let a=s+i.offset,{line:c,column:l}=Zo(e,a);r.push(new Xo(i.reason,a,c,l));let u=i.offset,d=o(t.slice(0,u),s);for(;!Array.isArray(d);)u=d.offset,d=o(t.slice(0,u),s);if(n.push(...d),u<t.length){let e=s+u;n.push({type:`text`,value:t[u],start:e,end:e+1})}s+=u+1}return{tokens:n,errors:r}}function ns(e,t){if(t===0)return e;let n={...e,start:e.start+t,end:e.end+t};return n.type===`link`&&(n.targetStart+=t,n.targetEnd+=t),n}var rs=`__proto__`;function is(e,t=e){return e===`__proto__`?`\"${t}\" cannot be used as a variable name (${rs} is reserved)`:void 0}function as(e,t=e){let n=is(e,t);if(n)throw TypeError(`spindle: ${n}`)}var G=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),os=(e,t)=>e&&G(e,t)?e[t]:void 0;function ss(e,t,n){t===`__proto__`?Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0,configurable:!0}):e[t]=n}function cs(e,t=()=>!0){let n=Object.create(null);for(let r of e)if(r)for(let e of Object.keys(r)){let i=r[e];t(i)&&(n[e]=i)}return n}var K=(...e)=>cs(e),ls=e=>Object.getPrototypeOf(e)===null,us=e=>ls(e)?e:K(e);function ds(e,t,n){let r=K(e);return r[t]=n,r}var fs=Object.freeze(K());function ps(e,t){return[...new Set([...Object.keys(e),...Object.keys(t)])].filter(n=>os(e,n)!==os(t,n))}var ms=e=>typeof e==`number`&&Number.isInteger(e)&&e>=0;function hs(e,t){let n=os(e,t);return ms(n)?n:0}function gs(e,t){let n=cs([e],ms);return t!==void 0&&(n[t]=hs(e,t)+1),n}var _s=new br;function vs(e,t,n,r=!1){let i=n.filter(e=>e!==`@children`);for(let e of i)e.startsWith(`@`)&&as(e.slice(1),e);_s.set(e,{body:t,params:i,isBlock:r})}function ys(e){return _s.get(e)}function bs(e){let t=e.trim();return t.endsWith(`ms`)?parseFloat(t.slice(0,-2)):t.endsWith(`s`)?parseFloat(t.slice(0,-1))*1e3:parseFloat(t)}function xs(e,t){return e instanceof Error?e.message||t||String(e):typeof e==`string`&&e!==``?e:t??String(e)}function Ss(){let e=new Set;return{subscribe(t){return e.add(t),()=>{e.delete(t)}},notify(){for(let t of[...e])t()}}}var Cs=[],ws=1,Ts=Ss();function Es(e){Cs=e,Ts.notify()}function Ds(e,t){let n=xs(t).replace(/^spindle: /,``),r=Cs.find(t=>t.context===e&&t.message===n);Es(r?Cs.map(e=>e===r?{...e,count:e.count+1}:e):[...Cs,{id:ws++,context:e,message:n,count:1}])}function Os(e,t){return Error(`No passage named ${JSON.stringify(e)} (in passage ${JSON.stringify(t)})`)}function ks(e){Es(Cs.filter(t=>t.id!==e))}function As(){return Cs}var js=Ts.subscribe;function Ms(e){return/\\s/.test(e)}function Ns(e){return e===`(`||e===`[`||e===`{`}function Ps(e){return e===`)`||e===`]`||e===`}`}function Fs(e){return e.replace(/\\\\([\"'\\\\])/g,`$1`)}function Is(e,t){let n=e[t];if(n!==`\"`&&n!==`'`)return null;let{end:r,closed:i}=Ro(e,t);return i?{value:Fs(e.slice(t+1,r-1)),end:r}:null}function Ls(e){let t=Is(e,0);return t&&t.end===e.length?t.value:null}function Rs(e){return/^[\"']?(.+?)[\"']?$/s.exec(e)?.[1]??e}var zs=/(?:[-+*/%&|^!~=<>?:,.]|(?:^|[^\\w$@.])(?:typeof|void|new|delete|in|instanceof|await|yield))$/;function Bs(e){let t=-1;if(Mo(e,{code(e,n,r){r===0&&!Ms(e)&&(t=n+1)},literal(e,n,r){let i=e.startsWith(`//`)||e.startsWith(`/*`);r===0&&!i&&(t=-1)},variable(e,n,r,i){i===0&&(t=-1)}}),t<0)return!1;let n=e.slice(0,t);return/(?:\\+\\+|--)$/.test(n)?!1:zs.test(n)}function Vs(e,t){let n=[],r=0;return Mo(e,{code(e,i,a){a>0||(Ns(e)?r++:Ps(e)?r--:r===0&&t(e)&&n.push(i))}}),n}function Hs(e,t){let n=[],r=0;for(let i of Vs(e,t))n.push(e.slice(r,i)),r=i+1;return n.push(e.slice(r)),n}function Us(e){return Ws(e)&&!Bs(e)}function Ws(e){let t=e[0];return!!(t===`\"`||t===`'`||t===\"`\"||/^[$_@]\\w|^%[A-Za-z_]/.test(e)||/\\d/.test(t)||(t===`-`||t===`+`)&&e.length>1&&/\\d/.test(e[1])||t===`(`||t===`[`||t===`{`||/^(?:true|false|null|undefined)(?![\\w$])/.test(e)||t===`!`&&e.length>1&&e[1]!==`=`)}function Gs(e){let t=Hs(e,Ms).filter(Boolean);if(t.length<2)return null;for(let e of t)if(!Us(e))return null;return t}function Ks(e){let t=Hs(e,e=>e===`,`).map(e=>e.trim()),n=t.length>1;if(t[t.length-1]===``&&t.pop(),!n&&t.length===1){let e=Gs(t[0]);if(e)return e}return t}function qs(e){let t=[],n=0;for(let r of[...Vs(e,Ms),e.length])r>n&&t.push([n,r]),n=r+1;return t}var Js=(e,[t,n])=>e.slice(t,n);function Ys(e){return Ls(e)??Rs(e)}var Xs=class extends Error{constructor(e,t){super(`The ${e.name} must be a quoted string (\"…\" or '…'), ${t?`not ${t}`:`but it has no value`}`),this.name=`MacroArgumentError`}};function Zs(e,t,n){switch(n.spans?.set(e,[n.at,n.at+t.length]),e.type){case`string`:{let n=Ls(t);if(n===null)throw new Xs(e,t);return n}case`text`:return Ys(t);case`names`:return t.split(`,`).map(e=>e.trim());case`delay`:return bs(t);case`number`:return Number(t);case`options`:return rc(e.parameters??[],t,n);default:return t}}function Qs(e){return e.type===`flag`||e.type===`separator`?!1:e.type===`options`?{}:void 0}var $s=/\\w+/y,ec=/[-+]?(?:\\d+\\.?\\d*|\\.\\d+)/y,tc=/\\S+/y;function nc(e,t,n){return e.lastIndex=n,e.exec(t)?.[0]??null}function rc(e,t,{at:n,spans:r}){let i={},a=0;for(;a<t.length;){let o=nc($s,t,a);if(!o){a=Is(t,a)?.end??a+1;continue}a+=o.length;let s,c=a;for(;c<t.length&&Ms(t[c]);)c++;let l=Is(t,c),u=l||c===a?null:nc(ec,t,c);l?(s=l.value,a=l.end):u&&(s=u,a=c+u.length);let d=e.find(e=>e.name===o);if(d&&d.type!==`flag`&&s!==void 0&&r?.set(d,[n+c,n+a]),d?.type===`string`&&!l)throw new Xs(d,nc(tc,t,c)??``);d?.type===`flag`?i[o]=!0:d?.type===`number`?i[o]=Number(s??0):d&&(i[o]=s)}return i}var ic=/^(?:[-+*/&|^=<>?:,.]|%(?![A-Za-z_]))/;function ac(e,t){let n=qs(e);if(n.length<2)return null;if(Js(e,n[n.length-1])===t){let t=[0,n[n.length-2][1]];if(!Bs(Js(e,t)))return t}if(Js(e,n[0])===t){let t=[n[1][0],e.length];if(!ic.test(Js(e,t)))return t}return null}function oc(e,t){if(t===`=`){let t=Vs(e,e=>e===`=`);for(let n=0;n<t.length;n++){let r=t[n];if(e[r+1]===`=`){n++;continue}if(e[r-1]!==`!`)return[r,r+1]}return null}let n=qs(e);for(let r=1;r<n.length-1;r++)if(Js(e,n[r])===t)return[n[r-1][1],n[r+1][0]];return null}var sc=e=>e.type===`expression`||e.type===`statements`||e.type===`passage`||e.type===`text`;function cc(e,t){let n=e.trim();return[n,n?t+e.indexOf(n):t]}function lc(e,t,n,{at:r,spans:i}){let[a,o]=cc(t??``,r);for(let r of e.filter(e=>e.type===`flag`)){let e=t===null?null:ac(a,r.name);n[r.name]=e!==null,e&&([a,o]=cc(Js(a,e),o+e[0]))}let s=e.filter(e=>e.type!==`flag`);if(s.length===0)return;let c=s.findIndex((e,t)=>sc(e)&&!s.slice(t+1).some(sc)),l=c<0?s.length-1:c,u=(e,[t,n])=>t===n?Qs(e):Zs(e,a.slice(t,n),{at:o+t,spans:i});if(s.length===1){n[s[0].name]=u(s[0],[0,a.length]);return}let d=qs(a),f=0,p=d.length;for(let e of s.slice(0,l))n[e.name]=f<p?u(e,d[f++]):Qs(e);let m=(e,t)=>{try{return u(e,t)}catch(e){if(e instanceof Xs)return;throw e}};for(let e of s.slice(l+1).reverse()){let t=f<p&&!Bs(a.slice(0,d[p-1][0]))?m(e,d[p-1]):void 0;n[e.name]=t??Qs(e),t===void 0?i?.delete(e):p--}let h=s[l];n[h.name]=f<p?u(h,[d[f][0],d[p-1][1]]):Qs(h)}var uc={name:`delay`,type:`delay`,required:!0};function dc(e,t,n){let r={},[i,a]=cc(e,0),o=0;return t.forEach((e,s)=>{if(e.type!==`separator`)return;let c=i===null?null:oc(i,e.name);r[e.name]=c!==null;let l=c?i.slice(0,c[0]):i;lc(t.slice(o,s),l,r,{at:a,spans:n}),i=c?i.slice(c[1]):null,c&&(a+=c[1]),o=s+1}),lc(t.slice(o),i,r,{at:a,spans:n}),r}function fc(e){let t=e.trim(),n=Lo(t);return n===null?{kind:`expression`,expression:t}:{kind:`name`,name:n}}function pc(e,t,{storyData:n,currentPassage:r}){let i=String(t(e??``));if(n&&!n.passages.has(i))throw Os(i,r);return i}function mc(e){let t=e.trim(),n=qs(t)[0];return n?Js(t,n):``}function hc(e){let{variable:t=``,placeholder:n=``}=dc(e,[{name:`variable`,type:`variable`},{name:`placeholder`,type:`string`}]);return{varName:t.replace(/[\"']/g,``),placeholder:n}}var gc=[{name:`value`,type:`string`,holds:`text`,required:!0}],_c=new Map([[`option`,gc]]);function vc(e){return _c.get(e.toLowerCase())}function yc(e){let t=[];for(let n of e)if(n.type===`macro`&&n.name===`option`){let{value:e}=dc(n.rawArgs,gc);t.push(e??``)}return t}var bc=null;function xc(e){let t=bc;bc=new Map;try{return e()}finally{bc=t}}function Sc(e,t){let n=t[0]+e,r=bc?.get(n);if(r)return r;try{r=vo(e,t)}catch(e){if(!(e instanceof lo))throw e;r=e}return bc?.set(n,r),r}var Cc=new Set([`if`,`elseif`,`case`]),wc=new Set([`dialog`]);function Tc(e,t){return e.map(e=>e.parameters?{...e,parameters:Tc(e.parameters,t)}:(e.type===`string`||e.type===`text`)&&!e.holds?{...e,holds:t}:e)}function Ec(e){let t=new br;for(let{name:n,parameters:r,interpolate:i}of e)r&&t.set(n,Tc(r,Dc(i)));return e=>{let n=t.get(e);if(!n){let r=vc(e);r&&t.set(e,n=Tc(r,`text`))}return n}}var Dc=e=>e?`markup`:`text`;function Oc(e){if(e.type===`expression`||e.type===`passage`)return`expression`;if(e.type===`statements`)return`statements`}function kc(e){if(!(e.type!==`string`&&e.type!==`text`))return e.holds??`markup`}function*Ac(e,t,n){let r=(e,n)=>t.findIndex((t,r)=>r>e&&t.type===`macro`&&t.isClose&&t.name.toLowerCase()===n);for(let i=0;i<t.length;i++){let a=t[i];if(a.type===`link`)yield{kind:`passage`,name:a.target,offset:a.targetStart,length:a.targetEnd-a.targetStart,macro:`link`,label:e.slice(a.start,a.end)},a.display.includes(`{`)&&(yield{kind:`text`,text:a.display,offset:Mc(e,a.display,a.start),where:`In the label of a link: `});else if(a.type===`expression`)yield{kind:`code`,code:a.expression,offset:a.end-1-a.expression.length,goal:`expression`,label:`{${a.expression}}`};else if(a.type===`html`){let t=a.start;for(let[n,r]of Object.entries(a.attributes)){let i=Mc(e,r,t);if(t=i+r.length,!Ko(n)){yield{kind:`text`,text:r,offset:i,where:`In the ${n} attribute of <${a.tag}>: `};continue}let o=0;for(let e of qo(r)){if(!(`expr`in e))continue;let t=Mc(r,e.expr,o);o=t+e.expr.length,yield{kind:`code`,code:e.expr,offset:i+t,goal:`expression`,label:`{${e.expr}} in the ${n} attribute of <${a.tag}>`}}}}else if(a.type===`macro`&&!a.isClose){let o=a.name.toLowerCase();if(o===`do`){let n=r(i,o);if(n<0)continue;yield{kind:`code`,code:e.slice(a.end,t[n].start),offset:a.end,goal:`statements`,label:`{do}`},i=n;continue}let s=a.rawArgs;if(wc.has(o)){let n=r(i,o),s=t.slice(i+1,n);if(n>i+1&&s.every(e=>e.type===`text`)){let r=e.slice(a.end,t[n].start),i=r.trim();yield{kind:`passage`,name:i.replace(/^[\"']|[\"']$/g,``),offset:a.end+r.indexOf(i),length:i.length,macro:o,label:e.slice(a.start,a.end)}}}if(!s)continue;let c=`{${a.name} ${s}}`,l=e.slice(a.start,a.end-1),u=a.start+l.trimEnd().length-s.length;if(Cc.has(o)){yield{kind:`code`,code:s,offset:u,goal:`expression`,label:c};continue}let d=n(o);d&&(yield*jc(s,u,d,a.name,c))}}}function*jc(e,t,n,r,i){let a,o=new Map;try{a=dc(e,n,o)}catch(e){if(!(e instanceof Xs))throw e;yield{kind:`argument-error`,message:e.message,offset:t,label:i};return}let s=r.toLowerCase();function*c(n,a){for(let l of n){let n=a[l.name];if(l.type===`options`&&l.parameters){yield*c(l.parameters,n??{});continue}let u=o.get(l);if(typeof n!=`string`||!n.trim()||!u)continue;let[d,f]=u,p=e.slice(d,f),m=e=>({kind:`passage`,name:e,offset:t+d,length:f-d,macro:s,label:i}),h=Oc(l);if(l.type===`passage`){let e=fc(n);if(e.kind===`name`){yield m(e.name);continue}}if(h){let e={kind:`code`,code:n,offset:t+d,goal:h,label:i};l.type===`passage`&&(e.passage=!0,e.macro=s),yield e;continue}let g=t+d+(n!==p&&/^[\"']/.test(p)?1:0),_=kc(l);_===`expression`||_===`statements`?yield{kind:`code`,code:n,offset:g,goal:_,label:i,inString:!0}:_===`passage`?yield m(n):_===`markup`&&(yield{kind:`text`,text:n,offset:g,where:`In the ${l.name} of {${r}}: `})}}yield*[...c(n,a)].sort((e,t)=>e.offset-t.offset)}function Mc(e,t,n){let r=e.indexOf(t,n);if(r>=0)return r;let i=e.indexOf(t);return i>=0?i:n}var Nc=new br;function Pc(e,t){Nc.set(e,t)}function Fc(e){return Nc.get(e)}var Ic=new br;function Lc(e,t){t?Ic.set(e,t):Ic.delete(e)}function Rc(e){return Ic.get(e)}var zc=new xr;function Bc(e){zc.add(e)}function Vc(e){return zc.has(e)}var Hc=[`expression`,`statements`,`passage`,`variable`,`string`,`text`,`names`,`delay`,`number`,`flag`,`separator`,`options`],Uc=[`markup`,`text`,`passage`,`expression`,`statements`];function Wc(e,t){let n=`Give a \\`string\\` or \\`text\\` parameter one of ${Uc.join(`, `)} to hold (see docs/custom-macros.md#what-a-string-holds).`;for(let r of t){let t=r.type;if(!Hc.includes(t))throw Gc(e,r,t===void 0?`has no type`:`has the unknown type ${JSON.stringify(t)}`,`Give it one of the types ${Hc.join(`, `)} (see docs/custom-macros.md#parameter-types), or declare no parameters and read props.rawArgs.`);let i=r.holds;if(i!==void 0&&t!==`string`&&t!==`text`)throw Gc(e,r,`is of the type ${t}, which holds what it is`,n);if(i!==void 0&&!Uc.includes(i))throw Gc(e,r,`holds the unknown ${JSON.stringify(i)}`,n);r.parameters&&Wc(e,r.parameters)}}function Gc(e,t,n,r){return Error(`spindle: The parameter \"${t.name}\" of the macro {${e}} ${n}. ${r}`)}var Kc=new br;function qc(e,t){Kc.set(e,t)}function Jc(e){return Kc.get(e)?.parameters}function Yc(){return Array.from(Kc.values())}var Xc=e=>Ec(Yc())(e);function Zc(e,t){if(!e.includes(`{`))return!1;let n;try{n=$o(e,{text:!0})}catch{return!1}return $c(n,t)}function Qc(e,t=Xc){for(let n of Ac(``,[e],t))if(n.kind===`text`&&Zc(n.text,t))return!0;return!1}function $c(e,t=Xc){for(let n of e){if(n.type===`variable`&&n.scope===`local`&&n.name===`children`)return!0;if(n.type===`html`){let e={start:0,end:0};if(Qc({isClose:!1,isSelfClose:!1,...n,...e},t)||$c(n.children,t))return!0}if(n.type===`macro`){let e={start:0,end:0};if(Qc({isClose:!1,...n,...e},t)||$c(n.children,t))return!0;if(n.branches){for(let e of n.branches)if($c(e.children,t))return!0}}}return!1}var el=[{name:`name`,type:`text`,holds:`text`,required:!0},{name:`parameters`,type:`text`,holds:`text`}];function tl({name:e=``,parameters:t=``}){return{name:e,params:t.split(/\\s+/).filter(e=>e.startsWith(`@`))}}function nl(e){return tl(dc(e,el))}function rl(e,t=Xc){let n=[];for(let r of e){if(r.name!==`StoryInit`&&!r.tags?.includes(`widget`))continue;let e=[];for(let i of ts(r.content).tokens)if(i.type===`macro`&&i.name.toLowerCase()===`widget`){if(!i.isClose){e.push({rawArgs:i.rawArgs,isBlock:!1});continue}let t=e.pop();if(!t?.isBlock)continue;try{n.push(nl(t.rawArgs).name)}catch{}}else e.length>0&&(i.type===`variable`&&i.scope===`local`&&i.name===`children`||Qc(i,t))&&(e[e.length-1].isBlock=!0)}return n}function il({name:e,params:t},n){let r=$c(n);vs(e,n,t,r),r&&wr(e)}function al(e,t){for(let n of e)if(n.type===`macro`&&n.name===`widget`&&n.rawArgs){let e=nl(n.rawArgs);try{il(e,n.children)}catch(n){console.error(`spindle: widget \"${e.name}\" in passage \"${t}\" was not registered: ${xs(n)}`)}}}var ol=e=>Symbol.iterator in e,sl=e=>`entries`in e,cl=(e,t)=>{let n=e instanceof Map?e:new Map(e.entries()),r=t instanceof Map?t:new Map(t.entries());if(n.size!==r.size)return!1;for(let[e,t]of n)if(!r.has(e)||!Object.is(t,r.get(e)))return!1;return!0},ll=(e,t)=>{let n=e[Symbol.iterator](),r=t[Symbol.iterator](),i=n.next(),a=r.next();for(;!i.done&&!a.done;){if(!Object.is(i.value,a.value))return!1;i=n.next(),a=r.next()}return!!i.done&&!!a.done};function ul(e,t){return Object.is(e,t)?!0:typeof e!=`object`||!e||typeof t!=`object`||!t||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:ol(e)&&ol(t)?sl(e)&&sl(t)?cl(e,t):ll(e,t):cl({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}var dl=_e(null),fl=_e(null);function pl(...e){let t=A(),n=j(dl);return Q(r=>{if(t.current&&n?.(r))return t.current;let i={};for(let t of e)i[t]=r[t];return ul(t.current,i)?t.current:t.current=i})}function ml(){let{variables:e,temporary:t,transient:n,renderCounts:r}=pl(`variables`,`temporary`,`transient`,`renderCounts`),i=j(qp);return Fe(()=>[e,t,i,n],[e,t,i,n,r])}var hl=1831565813;function gl(e){let t=e|0;return()=>{t=t+hl|0;let e=Math.imul(t^t>>>15,t|1);return e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}}function _l(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t}var vl=!1,yl=``,bl=0,xl=null,Sl=0;function Cl(e,t=!0){let n;n=e===void 0?String(Date.now())+String(Math.random()):t?e+`|`+Date.now()+`|`+Math.random():e,yl=n,bl=0,xl=gl(_l(n)),vl=!0,Sl++}function wl(e,t){Sl++,Tl(e,t)}function Tl(e,t){yl=e;let n=Math.imul(t%4294967296,hl);xl=gl(_l(e)+n|0),vl=!0,bl=t}function El(){Sl++,vl=!1,yl=``,bl=0,xl=null}function Dl(e){let t={generation:Sl,seed:yl,pull:bl};try{return e()}finally{vl&&Sl===t.generation&&bl!==t.pull&&Tl(t.seed,t.pull)}}function Ol(){return vl?{seed:yl,pull:bl}:null}function kl(){return!vl||!xl?Math.random():(bl++,xl())}function Al(e,t){return e>t&&([e,t]=[t,e]),Math.floor(kl()*(t-e+1))+e}function jl(){return vl}function Ml(){return yl}function Nl(){return bl}var Pl=500,Fl={$:`variables`,_:`temporary`,\"@\":`locals`,\"%\":`transient`},Il=/[\\p{ID_Continue}$\\u200c\\u200d]$/u;function Ll(e,t=`expression`){let n=t===`statements`?`s`+e:`e`+e,r=Rl.get(n);if(r!==void 0)return r;let{refs:i}=vo(e,t),a=``,o=0;for(let t of i){let n=is(t.name,t.sigil+t.name);if(n)throw SyntaxError(`spindle: ${n}`);a+=e.slice(o,t.start),t.shorthand?a+=`${t.name}: `:Il.test(a.slice(-2))&&(a+=` `),a+=`${Fl[t.sigil]}[\"${t.name}\"]`,o=t.end}return a+=e.slice(o),Rl.size>=Pl&&Rl.delete(Rl.keys().next().value),Rl.set(n,a),a}var Rl=new Map,zl=500,Bl=new Map,Vl=`const {currentPassage,previousPassage,visited,hasVisited,hasVisitedAny,hasVisitedAll,rendered,hasRendered,hasRenderedAny,hasRenderedAll,random,randomInt}=__fns;`;function Hl(e,t){let n=Bl.get(e);if(n)return Bl.delete(e),Bl.set(e,n),n;let r=Function(`variables`,`temporary`,`locals`,`__fns`,`transient`,Vl+t);if(Bl.set(e,r),Bl.size>zl){let e=Bl.keys().next().value;e!==void 0&&Bl.delete(e)}return r}function Ul(){let e=Q.getState();return e.storyData?.passages.get(e.currentPassage)}function Wl(){let e=Q.getState();if(e.historyIndex<=0)return;let t=e.history[e.historyIndex-1]?.passage;return t?e.storyData?.passages.get(t):void 0}function Gl(e){let t=t=>hs(e(),t??Q.getState().currentPassage);return{count:t,has:e=>t(e)>0,any:(...e)=>e.some(e=>t(e)>0),all:(...e)=>e.every(e=>t(e)>0)}}function Kl(e,t){let n=Gl(e),r=Gl(t);return{currentPassage:Ul,previousPassage:Wl,visited:n.count,hasVisited:n.has,hasVisitedAny:n.any,hasVisitedAll:n.all,rendered:r.count,hasRendered:r.has,hasRenderedAny:r.any,hasRenderedAll:r.all}}var ql=null;function Jl(){return ql??(ql={...Kl(()=>Q.getState().visitCounts,()=>Q.getState().renderCounts),random:kl,randomInt:Al}),ql}function Yl(e){return ls(e)?e:Object.isExtensible(e)?(Object.setPrototypeOf(e,null),e):us(e)}function Xl(e,...[t,n,r=fs,i=fs]){return e(Yl(t),Yl(n),Yl(r),Jl(),Yl(i))}function Zl(e,...t){let n=`return (${Ll(e)}\\n);`;return Xl(Hl(n,n),...t)}function Ql(e,...t){let n=Ll(e,`statements`);Xl(Hl(`exec:`+n,n),...t)}function $l(e){return e==null?``:String(e)}function eu(e,t,n){return e||t?b(`span`,{id:t,class:e},n):b(S,null,n)}function tu(e){return e.includes(`{`)||e.includes(`}`)}function nu(e,t){return e?.length?{nodes:e,outer:t??null}:null}var ru=new Map,iu=2e3;function au(e){let t=ru.get(e);if(t===void 0){try{t={nodes:$o(e,{text:!0})}}catch(e){t={error:e}}ru.size>=iu&&ru.clear(),ru.set(e,t)}return t}function ou(e,t){return e.map(e=>{switch(e.type){case`text`:return{type:`text`,value:t(e.value)};case`html`:return{...e,children:ou(e.children,t)};case`macro`:{let n={...e,children:ou(e.children,t)};return e.branches&&(n.branches=e.branches.map(e=>({...e,children:ou(e.children,t)}))),n}default:return e}})}var su=100;function cu(e,t,n){let r=n.split(`.`),i=r[0];as(i,Kn[t]+i);let a=os(t===`variable`?e.variables:t===`temporary`?e.temporary:t===`transient`?e.transient:e.locals,i);for(let e=1;e<r.length;e++){if(a==null)return;a=a[r[e]]}return a}function lu(e,t){return Zl(e,t.variables,t.temporary,t.locals,t.transient)}var uu=class{constructor(){this.errors=[]}nodes(e,t,n){let r=``;for(let i of e)r+=this.node(i,t,n);return r}node(e,t,n){switch(e.type){case`text`:return e.value;case`variable`:if(e.scope===`local`&&e.name===`children`){let e=t.widgetChildren;return e?this.nested(`children`,e.nodes,t,n,{widgetChildren:e.outer}):``}return this.variable(e.scope,e.name,t);case`expression`:try{return $l(lu(e.expression,t))}catch(e){return this.errors.push({macro:`expression`,error:e}),``}case`html`:return this.nodes(e.children,t,n);case`macro`:return this.macro(e,t,n);default:return e}}variable(e,t,n){try{return $l(cu(n,e,t))}catch(n){return this.errors.push({macro:Kn[e]+t,error:n}),``}}nested(e,t,n,r,i={}){return r>=su?(this.errors.push({macro:e,error:Error(`markup nested too deeply (a widget using itself?)`)}),``):this.nodes(t,{...n,...i},r+1)}macro(e,t,n){if(Vc(e.name))return``;let r=ys(e.name);if(r){let i=t.locals;if(r.params.length>0){let n=e.rawArgs?Ks(e.rawArgs):[];i=K(t.locals),r.params.forEach((e,r)=>{let a,o=n[r];if(o!==void 0)try{a=lu(o,t)}catch{a=void 0}i[e.startsWith(`@`)?e.slice(1):e]=a})}return this.nested(e.name,r.body,t,n,{locals:i,widgetChildren:nu(e.children,t.widgetChildren)})}let i=Rc(e.name);if(!i){let t=Fc(e.name)?`{${e.name}} has no text form, so it can't be used in an attribute value or label`:`unknown macro {${e.name}}`;return this.errors.push({macro:e.name,error:Error(t)}),``}let a={evaluate:e=>lu(e,t),renderText:(r,i)=>this.nested(e.name,r,t,n,i?{locals:du(t.locals,i)}:{})};try{return i({rawArgs:e.rawArgs,className:e.className,id:e.id,children:e.children,branches:e.branches},a)}catch(t){return this.errors.push({macro:e.name,error:t}),``}}};function du(e,t){for(let e of Object.keys(t))as(e,`@${e}`);return K(e,t)}function fu(e,t){let n=new uu;return{text:n.nodes(e,t,0),errors:n.errors}}function pu(e,t){if(!tu(e))return{text:e,errors:[]};let n=au(e);return`error`in n?{text:e,errors:[{macro:`markup`,error:n.error}]}:fu(n.nodes,t)}function mu(e,t,n){let r=[],i=``;for(let a of qo(e))if(`text`in a)i+=n?n(a.text):a.text;else if(`verbatim`in a)i+=a.verbatim;else if(/^[$_@%][\\w.]+$/.test(a.expr)){let e=Gn[a.expr[0]];try{i+=$l(cu(t,e,a.expr.slice(1)))}catch(e){r.push({macro:a.expr,error:e})}}else try{i+=$l(lu(a.expr,t))}catch(e){r.push({macro:`expression`,error:e})}return{text:i,errors:r}}function hu(){let[e,t,n,r]=ml(),i=j(sm);return Fe(()=>({variables:e,temporary:t,locals:n,transient:r,widgetChildren:i}),[e,t,n,r,i])}function gu(){let e=hu();return Ie(t=>{if(t===void 0||!tu(t))return t;let{text:n,errors:r}=pu(t,e);for(let{macro:e,error:n}of r)console.error(`spindle: {${e}} error in \"${t}\": ${xs(n)}`);return n},[e])}var _u=0;Array.isArray;function q(e,t,n,i,a,o){t||(t={});var s,c,l=t;if(`ref`in l)for(c in l={},t)c==`ref`?s=t[c]:l[c]=t[c];var u={type:e,props:l,key:n,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--_u,__i:-1,__u:0,__source:a,__self:o};if(typeof e==`function`&&(s=e.defaultProps))for(c in s)l[c]===void 0&&(l[c]=s[c]);return r.vnode&&r.vnode(u),u}var vu={variable:`variables`,temporary:`temporary`,transient:`transient`};function yu({node:e}){let{name:t,scope:n}=e,r=gu(),i=r(e.className),a=r(e.id),o=j(qp),s=t.split(`.`),c=s[0],l=Q(e=>n===`local`?void 0:os(e[vu[n]],c)),u=Kn[n],d=is(c,u+c);if(d)return q(`span`,{class:`error`,children:`{${u}${t} error: ${d}}`});let f;f=n===`local`?os(o,c):l;for(let e=1;e<s.length;e++){if(f==null){f=void 0;break}let t=s[e];f=f[t]}return eu(i,a,$l(f))}function bu({node:e}){let{expression:t}=e,n=gu(),r=n(e.className),i=n(e.id),[a,o,s,c]=ml(),l;try{l=$l(Zl(t,a,o,s,c))}catch{l=`{error: ${t}}`}return eu(r,i,l)}function xu(){return{nobr:j(Yp),inline:j(Zp),raw:j($p),structural:j(Qp),locals:j(qp)}}function Su({body:e,parentValues:t,ownKeys:n}){let r=xu(),[i,a]=je({}),o=Fe(()=>K(t,n,i),[t,n,i]),s=A(o);s.current=o;let c=Ie(()=>s.current,[]),l=Ie((e,t)=>{as(e,`@${e}`),s.current=ds(s.current,e,t),a(n=>({...n,[e]:t}))},[]),u=Fe(()=>({update:l,getValues:c}),[l,c]);return q(Jp.Provider,{value:u,children:q(qp.Provider,{value:o,children:eh(e,{...r,locals:o})})})}function Cu(e){let t=gu();return eu(t(e.className),t(e.id),q(wu,{...e}))}function wu({body:e,params:t,rawArgs:n,invocationChildren:r}){let i=xu().locals,[a,o,s,c]=ml(),l=j(sm),u=Fe(()=>nu(r,l),[r,l]),d=n?Ks(n):[],f=[];for(let e=0;e<t.length;e++){let t=d[e],n;if(t!==void 0)try{n=Zl(t,a,o,s,c)}catch{n=void 0}f.push(n)}let p=Fe(()=>{let e=K();for(let n=0;n<t.length;n++)e[t[n].startsWith(`@`)?t[n].slice(1):t[n]]=f[n];return e},f);return q(sm.Provider,{value:u,children:q(Su,{body:e,parentValues:i,ownKeys:p})})}var Tu=document.createElement(`i`);function Eu(e){let t=`&`+e+`;`;Tu.innerHTML=t;let n=Tu.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`||n===t?!1:n}function Du(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function Ou(e,t){return e.length>0?(Du(e,e.length,0,t),e):t}var ku={}.hasOwnProperty;function Au(e){let t={},n=-1;for(;++n<e.length;)ju(t,e[n]);return t}function ju(e,t){let n;for(n in t){let r=(ku.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){ku.call(r,a)||(r[a]=[]);let e=i[a];Mu(r[a],Array.isArray(e)?e:e?[e]:[])}}}function Mu(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);Du(e,0,0,r)}function Nu(e){let t={},n=-1;for(;++n<e.length;)Pu(t,e[n]);return t}function Pu(e,t){let n;for(n in t){let r=(ku.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i)r[a]=i[a]}}function Fu(e,t){let 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)}var Iu={'\"':`quot`,\"&\":`amp`,\"<\":`lt`,\">\":`gt`};function Lu(e){return e.replace(/[\"&<>]/g,t);function t(e){return`&`+Iu[e]+`;`}}function Ru(e){return e.replace(/[\\t\\n\\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var zu=Yu(/[A-Za-z]/),Bu=Yu(/[\\dA-Za-z]/),Vu=Yu(/[#-'*+\\--9=?A-Z^-~]/);function Hu(e){return e!==null&&(e<32||e===127)}var Uu=Yu(/\\d/),Wu=Yu(/[\\dA-Fa-f]/),Gu=Yu(/[!-/:-@[-`{-~]/);function J(e){return e!==null&&e<-2}function Ku(e){return e!==null&&(e<0||e===32)}function Y(e){return e===-2||e===-1||e===32}var qu=Yu(/\\p{P}|\\p{S}/u),Ju=Yu(/\\s/);function Yu(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function Xu(e,t){let n=Lu(Zu(e||``));if(!t)return n;let r=n.indexOf(`:`),i=n.indexOf(`?`),a=n.indexOf(`#`),o=n.indexOf(`/`);return r<0||o>-1&&r>o||i>-1&&r>i||a>-1&&r>a||t.test(n.slice(0,r))?n:``}function Zu(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&Bu(e.charCodeAt(n+1))&&Bu(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),i=1):o=`�`}else o=String.fromCharCode(a);o&&(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,o=``),i&&(n+=i,i=0)}return t.join(``)+e.slice(r)}var Qu={}.hasOwnProperty,$u=/^(https?|ircs?|mailto|xmpp)$/i,ed=/^https?$/i;function td(e){let t=e||{},n=!0,r={},i=[[]],a=[],o=[],s=Nu([{enter:{blockQuote:ne,codeFenced:ae,codeFencedFenceInfo:h,codeFencedFenceMeta:h,codeIndented:ce,codeText:ze,content:Te,definition:ye,definitionDestinationString:xe,definitionLabelString:h,definitionTitleString:h,emphasis:Le,htmlFlow:Fe,htmlText:j,image:ue,label:h,link:de,listItemMarker:ee,listItemValue:T,listOrdered:C,listUnordered:w,paragraph:ie,reference:h,resource:he,resourceDestinationString:ge,resourceTitleString:h,setextHeading:De,strong:Re},exit:{atxHeading:ke,atxHeadingSequence:Ee,autolinkEmail:qe,autolinkProtocol:Ke,blockQuote:re,characterEscapeValue:Me,characterReferenceMarkerHexadecimal:We,characterReferenceMarkerNumeric:We,characterReferenceValue:Ge,codeFenced:le,codeFencedFence:se,codeFencedFenceInfo:oe,codeFencedFenceMeta:S,codeFlowValue:Pe,codeIndented:le,codeText:Be,codeTextData:Me,data:Me,definition:we,definitionDestinationString:Se,definitionLabelString:be,definitionTitleString:Ce,emphasis:Ve,hardBreakEscape:A,hardBreakTrailing:A,htmlFlow:Ie,htmlFlowData:Me,htmlText:Ie,htmlTextData:Me,image:k,label:pe,labelText:fe,lineEnding:Ne,link:k,listOrdered:E,listUnordered:D,paragraph:O,reference:S,referenceString:me,resource:S,resourceDestinationString:_e,resourceTitleString:ve,setextHeading:je,setextHeadingLineSequence:Ae,setextHeadingText:Oe,strong:He,thematicBreak:Ue}},...t.htmlExtensions||[]]),c={definitions:r,tightStack:o},l={buffer:h,encode:x,getData:m,lineEndingIfNeeded:b,options:t,raw:v,resume:g,setData:p,tag:_},u=t.defaultLineEnding;return d;function d(e){let t=-1,n=0,r=[],a=[],o=[];for(;++t<e.length;)!u&&(e[t][1].type===`lineEnding`||e[t][1].type===`lineEndingBlank`)&&(u=e[t][2].sliceSerialize(e[t][1])),(e[t][1].type===`listOrdered`||e[t][1].type===`listUnordered`)&&(e[t][0]===`enter`?r.push(t):f(e.slice(r.pop(),t))),e[t][1].type===`definition`&&(e[t][0]===`enter`?(o=Ou(o,e.slice(n,t)),n=t):(a=Ou(a,e.slice(n,t+1)),n=t+1));a=Ou(a,o),a=Ou(a,e.slice(n)),t=-1;let c=a;for(s.enter.null&&s.enter.null.call(l);++t<e.length;){let e=s[c[t][0]],n=c[t][1].type,r=e[n];Qu.call(e,n)&&r&&r.call({sliceSerialize:c[t][2].sliceSerialize,...l},c[t][1])}return s.exit.null&&s.exit.null.call(l),i[0].join(``)}function f(e){let t=e.length,n=0,r=0,i=!1,a;for(;++n<t;){let t=e[n];if(t[1]._container)a=void 0,t[0]===`enter`?r++:r--;else switch(t[1].type){case`listItemPrefix`:t[0]===`exit`&&(a=!0);break;case`linePrefix`:break;case`lineEndingBlank`:t[0]===`enter`&&!r&&(a?a=void 0:i=!0);break;default:a=void 0}}e[0][1]._loose=i}function p(e,t){c[e]=t}function m(e){return c[e]}function h(){i.push([])}function g(){return i.pop().join(``)}function _(e){n&&(p(`lastWasTag`,!0),i[i.length-1].push(e))}function v(e){p(`lastWasTag`),i[i.length-1].push(e)}function y(){v(u||`\n`)}function b(){let e=i[i.length-1],t=e[e.length-1],n=t?t.charCodeAt(t.length-1):null;n===10||n===13||n===null||y()}function x(e){return m(`ignoreEncode`)?e:Lu(e)}function S(){g()}function C(e){o.push(!e._loose),b(),_(`<ol`),p(`expectFirstItem`,!0)}function w(e){o.push(!e._loose),b(),_(`<ul`),p(`expectFirstItem`,!0)}function T(e){if(m(`expectFirstItem`)){let t=Number.parseInt(this.sliceSerialize(e),10);t!==1&&_(` start=\"`+x(String(t))+`\"`)}}function ee(){m(`expectFirstItem`)?_(`>`):te(),b(),_(`<li>`),p(`expectFirstItem`),p(`lastWasTag`)}function E(){te(),o.pop(),y(),_(`</ol>`)}function D(){te(),o.pop(),y(),_(`</ul>`)}function te(){m(`lastWasTag`)&&!m(`slurpAllLineEndings`)&&b(),_(`</li>`),p(`slurpAllLineEndings`)}function ne(){o.push(!1),b(),_(`<blockquote>`)}function re(){o.pop(),b(),_(`</blockquote>`),p(`slurpAllLineEndings`)}function ie(){o[o.length-1]||(b(),_(`<p>`)),p(`slurpAllLineEndings`)}function O(){o[o.length-1]?p(`slurpAllLineEndings`,!0):_(`</p>`)}function ae(){b(),_(`<pre><code`),p(`fencesCount`,0)}function oe(){_(` class=\"language-`+g()+`\"`)}function se(){let e=m(`fencesCount`)||0;e||(_(`>`),p(`slurpOneLineEnding`,!0)),p(`fencesCount`,e+1)}function ce(){b(),_(`<pre><code>`)}function le(){let e=m(`fencesCount`);e!==void 0&&e<2&&c.tightStack.length>0&&!m(`lastWasTag`)&&y(),m(`flowCodeSeenData`)&&b(),_(`</code></pre>`),e!==void 0&&e<2&&b(),p(`flowCodeSeenData`),p(`fencesCount`),p(`slurpOneLineEnding`)}function ue(){a.push({image:!0}),n=void 0}function de(){a.push({})}function fe(e){a[a.length-1].labelId=this.sliceSerialize(e)}function pe(){a[a.length-1].label=g()}function me(e){a[a.length-1].referenceId=this.sliceSerialize(e)}function he(){h(),a[a.length-1].destination=``}function ge(){h(),p(`ignoreEncode`,!0)}function _e(){a[a.length-1].destination=g(),p(`ignoreEncode`)}function ve(){a[a.length-1].title=g()}function k(){let e=a.length-1,i=a[e],o=i.referenceId||i.labelId,s=i.destination===void 0?r[Ru(o)]:i;for(n=!0;e--;)if(a[e].image){n=void 0;break}i.image?(_(`<img src=\"`+Xu(s.destination,t.allowDangerousProtocol?void 0:ed)+`\" alt=\"`),v(i.label),_(`\"`)):_(`<a href=\"`+Xu(s.destination,t.allowDangerousProtocol?void 0:$u)+`\"`),_(s.title?` title=\"`+s.title+`\"`:``),i.image?_(` />`):(_(`>`),v(i.label),_(`</a>`)),a.pop()}function ye(){h(),a.push({})}function be(e){g(),a[a.length-1].labelId=this.sliceSerialize(e)}function xe(){h(),p(`ignoreEncode`,!0)}function Se(){a[a.length-1].destination=g(),p(`ignoreEncode`)}function Ce(){a[a.length-1].title=g()}function we(){let e=a[a.length-1],t=Ru(e.labelId);g(),Qu.call(r,t)||(r[t]=a[a.length-1]),a.pop()}function Te(){p(`slurpAllLineEndings`,!0)}function Ee(e){m(`headingRank`)||(p(`headingRank`,this.sliceSerialize(e).length),b(),_(`<h`+m(`headingRank`)+`>`))}function De(){h(),p(`slurpAllLineEndings`)}function Oe(){p(`slurpAllLineEndings`,!0)}function ke(){_(`</h`+m(`headingRank`)+`>`),p(`headingRank`)}function Ae(e){p(`headingRank`,this.sliceSerialize(e).charCodeAt(0)===61?1:2)}function je(){let e=g();b(),_(`<h`+m(`headingRank`)+`>`),v(e),_(`</h`+m(`headingRank`)+`>`),p(`slurpAllLineEndings`),p(`headingRank`)}function Me(e){v(x(this.sliceSerialize(e)))}function Ne(e){if(!m(`slurpAllLineEndings`)){if(m(`slurpOneLineEnding`)){p(`slurpOneLineEnding`);return}if(m(`inCodeText`)){v(` `);return}v(x(this.sliceSerialize(e)))}}function Pe(e){v(x(this.sliceSerialize(e))),p(`flowCodeSeenData`,!0)}function A(){_(`<br />`)}function Fe(){b(),j()}function Ie(){p(`ignoreEncode`)}function j(){t.allowDangerousHtml&&p(`ignoreEncode`,!0)}function Le(){_(`<em>`)}function Re(){_(`<strong>`)}function ze(){p(`inCodeText`,!0),_(`<code>`)}function Be(){p(`inCodeText`),_(`</code>`)}function Ve(){_(`</em>`)}function He(){_(`</strong>`)}function Ue(){b(),_(`<hr />`)}function We(e){p(`characterReferenceType`,e.type)}function Ge(e){let t=this.sliceSerialize(e);v(x(m(`characterReferenceType`)?Fu(t,m(`characterReferenceType`)===`characterReferenceMarkerNumeric`?10:16):Eu(t))),p(`characterReferenceType`)}function Ke(e){let n=this.sliceSerialize(e);_(`<a href=\"`+Xu(n,t.allowDangerousProtocol?void 0:$u)+`\">`),v(x(n)),_(`</a>`)}function qe(e){let t=this.sliceSerialize(e);_(`<a href=\"`+Xu(`mailto:`+t)+`\">`),v(x(t)),_(`</a>`)}}function X(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return Y(r)?(e.enter(n),s(r)):t(r)}function s(r){return Y(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}var nd={tokenize:rd};function rd(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null){e.consume(n);return}return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),X(e,t,`linePrefix`)}function i(t){return e.enter(`paragraph`),a(t)}function a(t){let r=e.enter(`chunkText`,{contentType:`text`,previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){if(t===null){e.exit(`chunkText`),e.exit(`paragraph`),e.consume(t);return}return J(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var id={tokenize:od},ad={tokenize:sd};function od(e){let t=this,n=[],r=0,i,a,o;return s;function s(i){if(r<n.length){let a=n[r];return t.containerState=a[1],e.attempt(a[0].continuation,c,l)(i)}return l(i)}function c(e){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();let n=t.events.length,a=n,o;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){o=t.events[a][1].end;break}_(r);let s=n;for(;s<t.events.length;)t.events[s][1].end={...o},s++;return Du(t.events,a+1,0,t.events.slice(n)),t.events.length=s,l(e)}return s(e)}function l(a){if(r===n.length){if(!i)return f(a);if(i.currentConstruct&&i.currentConstruct.concrete)return m(a);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(ad,u,d)(a)}function u(e){return i&&v(),_(r),f(e)}function d(e){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(e)}function f(n){return t.containerState={},e.attempt(ad,p,m)(n)}function p(e){return r++,n.push([t.currentConstruct,t.containerState]),f(e)}function m(n){if(n===null){i&&v(),_(0),e.consume(n);return}return i=i||t.parser.flow(t.now()),e.enter(`chunkFlow`,{_tokenizer:i,contentType:`flow`,previous:a}),h(n)}function h(n){if(n===null){g(e.exit(`chunkFlow`),!0),_(0),e.consume(n);return}return J(n)?(e.consume(n),g(e.exit(`chunkFlow`)),r=0,t.interrupt=void 0,s):(e.consume(n),h)}function g(e,n){let s=t.sliceStream(e);if(n&&s.push(null),e.previous=a,a&&(a.next=e),a=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(_(r),e=n;e<t.events.length;)t.events[e][1].end={...c},e++;Du(t.events,a+1,0,t.events.slice(n)),t.events.length=e}}function _(r){let i=n.length;for(;i-- >r;){let r=n[i];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function sd(e,t,n){return X(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function cd(e){if(e===null||Ku(e)||Ju(e))return 1;if(qu(e))return 2}function ld(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}var ud={name:`attention`,resolveAll:dd,tokenize:fd};function dd(e,t){let n=-1,r,i,a,o,s,c,l,u;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;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;let d={...e[r][1].end},f={...e[n][1].start};pd(d,-c),pd(f,c),o={type:c>1?`strongSequence`:`emphasisSequence`,start:d,end:{...e[r][1].end}},s={type:c>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:f},a={type:c>1?`strongText`:`emphasisText`,start:{...e[r][1].end},end:{...e[n][1].start}},i={type:c>1?`strong`:`emphasis`,start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=Ou(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=Ou(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=Ou(l,ld(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=Ou(l,[[`exit`,a,t],[`enter`,s,t],[`exit`,s,t],[`exit`,i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,l=Ou(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,Du(e,r-1,n-r+3,l),n=r+l.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function fd(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=cd(r),a;return o;function o(t){return a=t,e.enter(`attentionSequence`),s(t)}function s(o){if(o===a)return e.consume(o),s;let c=e.exit(`attentionSequence`),l=cd(o),u=!l||l===2&&i||n.includes(o),d=!i||i===2&&l||n.includes(r);return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function pd(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var md={name:`autolink`,tokenize:hd};function hd(e,t,n){let r=0;return i;function i(t){return e.enter(`autolink`),e.enter(`autolinkMarker`),e.consume(t),e.exit(`autolinkMarker`),e.enter(`autolinkProtocol`),a}function a(t){return zu(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||Bu(e)?(r=1,s(e)):l(e)}function s(t){return t===58?(e.consume(t),r=0,c):(t===43||t===45||t===46||Bu(t))&&r++<32?(e.consume(t),s):(r=0,l(t))}function c(r){return r===62?(e.exit(`autolinkProtocol`),e.enter(`autolinkMarker`),e.consume(r),e.exit(`autolinkMarker`),e.exit(`autolink`),t):r===null||r===32||r===60||Hu(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):Vu(t)?(e.consume(t),l):n(t)}function u(e){return Bu(e)?d(e):n(e)}function d(n){return n===46?(e.consume(n),r=0,u):n===62?(e.exit(`autolinkProtocol`).type=`autolinkEmail`,e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.exit(`autolink`),t):f(n)}function f(t){if((t===45||Bu(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var gd={partial:!0,tokenize:_d};function _d(e,t,n){return r;function r(t){return Y(t)?X(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||J(e)?t(e):n(e)}}var vd={continuation:{tokenize:bd},exit:xd,name:`blockQuote`,tokenize:yd};function yd(e,t,n){let r=this;return i;function i(t){if(t===62){let n=r.containerState;return n.open||(e.enter(`blockQuote`,{_container:!0}),n.open=!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return Y(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function bd(e,t,n){let r=this;return i;function i(t){return Y(t)?X(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(vd,t,n)(r)}}function xd(e){e.exit(`blockQuote`)}var Sd={name:`characterEscape`,tokenize:Cd};function Cd(e,t,n){return r;function r(t){return e.enter(`characterEscape`),e.enter(`escapeMarker`),e.consume(t),e.exit(`escapeMarker`),i}function i(r){return Gu(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var wd={name:`characterReference`,tokenize:Td};function Td(e,t,n){let r=this,i=0,a,o;return s;function s(t){return e.enter(`characterReference`),e.enter(`characterReferenceMarker`),e.consume(t),e.exit(`characterReferenceMarker`),c}function c(t){return t===35?(e.enter(`characterReferenceMarkerNumeric`),e.consume(t),e.exit(`characterReferenceMarkerNumeric`),l):(e.enter(`characterReferenceValue`),a=31,o=Bu,u(t))}function l(t){return t===88||t===120?(e.enter(`characterReferenceMarkerHexadecimal`),e.consume(t),e.exit(`characterReferenceMarkerHexadecimal`),e.enter(`characterReferenceValue`),a=6,o=Wu,u):(e.enter(`characterReferenceValue`),a=7,o=Uu,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===Bu&&!Eu(r.sliceSerialize(i))?n(s):(e.enter(`characterReferenceMarker`),e.consume(s),e.exit(`characterReferenceMarker`),e.exit(`characterReference`),t)}return o(s)&&i++<a?(e.consume(s),u):n(s)}}var Ed={partial:!0,tokenize:kd},Dd={concrete:!0,name:`codeFenced`,tokenize:Od};function Od(e,t,n){let r=this,i={partial:!0,tokenize:x},a=0,o=0,s;return c;function c(e){return l(e)}function l(t){let n=r.events[r.events.length-1];return a=n&&n[1].type===`linePrefix`?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),u(t)}function u(t){return t===s?(o++,e.consume(t),u):o<3?n(t):(e.exit(`codeFencedFenceSequence`),Y(t)?X(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||J(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(Ed,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||J(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):Y(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),X(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||J(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||J(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),d(t)):t===96&&t===s?n(t):(e.consume(t),m)}function h(t){return e.attempt(i,b,g)(t)}function g(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_}function _(t){return a>0&&Y(t)?X(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||J(t)?e.check(Ed,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||J(t)?(e.exit(`codeFlowValue`),v(t)):(e.consume(t),y)}function b(n){return e.exit(`codeFenced`),t(n)}function x(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),Y(t)?X(e,l,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter(`codeFencedFenceSequence`),u(t)):n(t)}function u(t){return t===s?(i++,e.consume(t),u):i>=o?(e.exit(`codeFencedFenceSequence`),Y(t)?X(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||J(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}function kd(e,t,n){let r=this;return i;function i(t){return t===null?n(t):(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}var Ad={name:`codeIndented`,tokenize:Md},jd={partial:!0,tokenize:Nd};function Md(e,t,n){let r=this;return i;function i(t){return e.enter(`codeIndented`),X(e,a,`linePrefix`,5)(t)}function a(e){let t=r.events[r.events.length-1];return t&&t[1].type===`linePrefix`&&t[2].sliceSerialize(t[1],!0).length>=4?o(e):n(e)}function o(t){return t===null?c(t):J(t)?e.attempt(jd,o,c)(t):(e.enter(`codeFlowValue`),s(t))}function s(t){return t===null||J(t)?(e.exit(`codeFlowValue`),o(t)):(e.consume(t),s)}function c(n){return e.exit(`codeIndented`),t(n)}}function Nd(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):J(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),i):X(e,a,`linePrefix`,5)(t)}function a(e){let a=r.events[r.events.length-1];return a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(e):J(e)?i(e):n(e)}}var Pd={name:`codeText`,previous:Id,resolve:Fd,tokenize:Ld};function Fd(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 Id(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function Ld(e,t,n){let r=0,i,a;return o;function o(t){return e.enter(`codeText`),e.enter(`codeTextSequence`),s(t)}function s(t){return t===96?(e.consume(t),r++,s):(e.exit(`codeTextSequence`),c(t))}function c(t){return t===null?n(t):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),c):t===96?(a=e.enter(`codeTextSequence`),i=0,u(t)):J(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c):(e.enter(`codeTextData`),l(t))}function l(t){return t===null||t===32||t===96||J(t)?(e.exit(`codeTextData`),c(t)):(e.consume(t),l)}function u(n){return n===96?(e.consume(n),i++,u):i===r?(e.exit(`codeTextSequence`),e.exit(`codeText`),t(n)):(a.type=`codeTextData`,l(n))}}var Rd=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError(\"Cannot access index `\"+e+\"` in a splice buffer of size `\"+(this.left.length+this.right.length)+\"`\");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=t??1/0;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&zd(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),zd(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),zd(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0))if(e<this.left.length){let t=this.left.splice(e,1/0);zd(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);zd(this.left,t.reverse())}}};function zd(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 Bd(e){let t={},n=-1,r,i,a,o,s,c,l,u=new Rd(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type===`chunkFlow`&&u.get(n-1)[1].type===`listItemPrefix`&&(c=r[1]._tokenizer.events,a=0,a<c.length&&c[a][1].type===`lineEndingBlank`&&(a+=2),a<c.length&&c[a][1].type===`content`))for(;++a<c.length&&c[a][1].type!==`content`;)c[a][1].type===`chunkText`&&(c[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===`enter`)r[1].contentType&&(Object.assign(t,Vd(u,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type===`lineEnding`||o[1].type===`lineEndingBlank`)o[0]===`enter`&&(i&&(u.get(i)[1].type=`lineEndingBlank`),o[1].type=`lineEnding`,i=a);else if(!(o[1].type===`linePrefix`||o[1].type===`listItemIndent`))break;i&&(r[1].end={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return Du(e,0,1/0,u.slice(0)),!l}function Vd(e,t){let n=e.get(t)[1],r=e.get(t)[2],i=t-1,a=[],o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let s=o.events,c=[],l={},u,d,f=-1,p=n,m=0,h=0,g=[h];for(;p;){for(;e.get(++i)[1]!==p;);a.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<s.length;)s[f][0]===`exit`&&s[f-1][0]===`enter`&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=s.slice(g[f],g[f+1]),n=a.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)l[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return l}var Hd={resolve:Wd,tokenize:Gd},Ud={partial:!0,tokenize:Kd};function Wd(e){return Bd(e),e}function Gd(e,t){let n;return r;function r(t){return e.enter(`content`),n=e.enter(`chunkContent`,{contentType:`content`}),i(t)}function i(t){return t===null?a(t):J(t)?e.check(Ud,o,a)(t):(e.consume(t),i)}function a(n){return e.exit(`chunkContent`),e.exit(`content`),t(n)}function o(t){return e.consume(t),e.exit(`chunkContent`),n.next=e.enter(`chunkContent`,{contentType:`content`,previous:n}),n=n.next,i}}function Kd(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),X(e,a,`linePrefix`)}function a(i){if(i===null||J(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(`codeIndented`)&&a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function qd(e,t,n,r,i,a,o,s,c){let l=c||1/0,u=0;return d;function d(t){return t===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),f):t===null||t===32||t===41||Hu(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter(`chunkString`,{contentType:`string`}),h(t))}function f(n){return n===62?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(`chunkString`,{contentType:`string`}),p(n))}function p(t){return t===62?(e.exit(`chunkString`),e.exit(s),f(t)):t===null||t===60||J(t)?n(t):(e.consume(t),t===92?m:p)}function m(t){return t===60||t===62||t===92?(e.consume(t),p):p(t)}function h(i){return!u&&(i===null||i===41||Ku(i))?(e.exit(`chunkString`),e.exit(s),e.exit(o),e.exit(r),t(i)):u<l&&i===40?(e.consume(i),u++,h):i===41?(e.consume(i),u--,h):i===null||i===32||i===40||Hu(i)?n(i):(e.consume(i),i===92?g:h)}function g(t){return t===40||t===41||t===92?(e.consume(t),h):h(t)}}function Jd(e,t,n,r,i,a){let o=this,s=0,c;return l;function l(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),u}function u(l){return s>999||l===null||l===91||l===93&&!c||l===94&&!s&&`_hiddenFootnoteSupport`in o.parser.constructs?n(l):l===93?(e.exit(a),e.enter(i),e.consume(l),e.exit(i),e.exit(r),t):J(l)?(e.enter(`lineEnding`),e.consume(l),e.exit(`lineEnding`),u):(e.enter(`chunkString`,{contentType:`string`}),d(l))}function d(t){return t===null||t===91||t===93||J(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||(c=!Y(t)),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function Yd(e,t,n,r,i,a){let o;return s;function s(t){return t===34||t===39||t===40?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=t===40?41:t,c):n(t)}function c(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){return t===o?(e.exit(a),c(o)):t===null?n(t):J(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),X(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||J(t)?(e.exit(`chunkString`),l(t)):(e.consume(t),t===92?d:u)}function d(t){return t===o||t===92?(e.consume(t),u):u(t)}}function Xd(e,t){let n;return r;function r(i){return J(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):Y(i)?X(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var Zd={name:`definition`,tokenize:$d},Qd={partial:!0,tokenize:ef};function $d(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return Jd.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=Ru(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),c):n(t)}function c(t){return Ku(t)?Xd(e,l)(t):l(t)}function l(t){return qd(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(Qd,d,d)(t)}function d(t){return Y(t)?X(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||J(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function ef(e,t,n){return r;function r(t){return Ku(t)?Xd(e,i)(t):n(t)}function i(t){return Yd(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return Y(t)?X(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||J(e)?t(e):n(e)}}var tf={name:`hardBreakEscape`,tokenize:nf};function nf(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return J(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var rf={name:`headingAtx`,resolve:af,tokenize:of};function af(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`},Du(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function of(e,t,n){let r=0;return i;function i(t){return e.enter(`atxHeading`),a(t)}function a(t){return e.enter(`atxHeadingSequence`),o(t)}function o(t){return t===35&&r++<6?(e.consume(t),o):t===null||Ku(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||J(n)?(e.exit(`atxHeading`),t(n)):Y(n)?X(e,s,`whitespace`)(n):(e.enter(`atxHeadingText`),l(n))}function c(t){return t===35?(e.consume(t),c):(e.exit(`atxHeadingSequence`),s(t))}function l(t){return t===null||t===35||Ku(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var sf=`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`.split(`.`),cf=[`pre`,`script`,`style`,`textarea`],lf={concrete:!0,name:`htmlFlow`,resolveTo:ff,tokenize:pf},uf={partial:!0,tokenize:hf},df={partial:!0,tokenize:mf};function ff(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 pf(e,t,n){let r=this,i,a,o,s,c;return l;function l(e){return u(e)}function u(t){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(t),d}function d(s){return s===33?(e.consume(s),f):s===47?(e.consume(s),a=!0,h):s===63?(e.consume(s),i=3,r.interrupt?t:se):zu(s)?(e.consume(s),o=String.fromCharCode(s),g):n(s)}function f(a){return a===45?(e.consume(a),i=2,p):a===91?(e.consume(a),i=5,s=0,m):zu(a)?(e.consume(a),i=4,r.interrupt?t:se):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:se):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:D:m):n(i)}function h(t){return zu(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||Ku(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&cf.includes(l)?(i=1,r.interrupt?t(s):D(s)):sf.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):D(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||Bu(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:D):n(i)}function v(t){return Y(t)?(e.consume(t),v):ee(t)}function y(t){return t===47?(e.consume(t),ee):t===58||t===95||zu(t)?(e.consume(t),b):Y(t)?(e.consume(t),y):ee(t)}function b(t){return t===45||t===46||t===58||t===95||Bu(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):Y(t)?(e.consume(t),x):y(t)}function S(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),c=t,C):Y(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||J(t)?n(t):(e.consume(t),C)}function w(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||Ku(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||Y(e)?y(e):n(e)}function ee(t){return t===62?(e.consume(t),E):n(t)}function E(t){return t===null||J(t)?D(t):Y(t)?(e.consume(t),E):n(t)}function D(t){return t===45&&i===2?(e.consume(t),ie):t===60&&i===1?(e.consume(t),O):t===62&&i===4?(e.consume(t),ce):t===63&&i===3?(e.consume(t),se):t===93&&i===5?(e.consume(t),oe):J(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(uf,le,te)(t)):t===null||J(t)?(e.exit(`htmlFlowData`),te(t)):(e.consume(t),D)}function te(t){return e.check(df,ne,le)(t)}function ne(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),re}function re(t){return t===null||J(t)?te(t):(e.enter(`htmlFlowData`),D(t))}function ie(t){return t===45?(e.consume(t),se):D(t)}function O(t){return t===47?(e.consume(t),o=``,ae):D(t)}function ae(t){if(t===62){let n=o.toLowerCase();return cf.includes(n)?(e.consume(t),ce):D(t)}return zu(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),ae):D(t)}function oe(t){return t===93?(e.consume(t),se):D(t)}function se(t){return t===62?(e.consume(t),ce):t===45&&i===2?(e.consume(t),se):D(t)}function ce(t){return t===null||J(t)?(e.exit(`htmlFlowData`),le(t)):(e.consume(t),ce)}function le(n){return e.exit(`htmlFlow`),t(n)}}function mf(e,t,n){let r=this;return i;function i(t){return J(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a):n(t)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}function hf(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(gd,t,n)}}var gf={name:`htmlText`,tokenize:_f};function _f(e,t,n){let r=this,i,a,o;return s;function s(t){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(t),c}function c(t){return t===33?(e.consume(t),l):t===47?(e.consume(t),x):t===63?(e.consume(t),y):zu(t)?(e.consume(t),w):n(t)}function l(t){return t===45?(e.consume(t),u):t===91?(e.consume(t),a=0,m):zu(t)?(e.consume(t),v):n(t)}function u(t){return t===45?(e.consume(t),p):n(t)}function d(t){return t===null?n(t):t===45?(e.consume(t),f):J(t)?(o=d,O(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?ie(e):e===45?f(e):d(e)}function m(t){return t===`CDATA[`.charCodeAt(a++)?(e.consume(t),a===6?h:m):n(t)}function h(t){return t===null?n(t):t===93?(e.consume(t),g):J(t)?(o=h,O(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?ie(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?ie(t):J(t)?(o=v,O(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):J(t)?(o=y,O(t)):(e.consume(t),y)}function b(e){return e===62?ie(e):y(e)}function x(t){return zu(t)?(e.consume(t),S):n(t)}function S(t){return t===45||Bu(t)?(e.consume(t),S):C(t)}function C(t){return J(t)?(o=C,O(t)):Y(t)?(e.consume(t),C):ie(t)}function w(t){return t===45||Bu(t)?(e.consume(t),w):t===47||t===62||Ku(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),ie):t===58||t===95||zu(t)?(e.consume(t),ee):J(t)?(o=T,O(t)):Y(t)?(e.consume(t),T):ie(t)}function ee(t){return t===45||t===46||t===58||t===95||Bu(t)?(e.consume(t),ee):E(t)}function E(t){return t===61?(e.consume(t),D):J(t)?(o=E,O(t)):Y(t)?(e.consume(t),E):T(t)}function D(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,te):J(t)?(o=D,O(t)):Y(t)?(e.consume(t),D):(e.consume(t),ne)}function te(t){return t===i?(e.consume(t),i=void 0,re):t===null?n(t):J(t)?(o=te,O(t)):(e.consume(t),te)}function ne(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||Ku(t)?T(t):(e.consume(t),ne)}function re(e){return e===47||e===62||Ku(e)?T(e):n(e)}function ie(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function O(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),ae}function ae(t){return Y(t)?X(e,oe,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):oe(t)}function oe(t){return e.enter(`htmlTextData`),o(t)}}var vf={name:`labelEnd`,resolveAll:Sf,resolveTo:Cf,tokenize:wf},yf={tokenize:Tf},bf={tokenize:Ef},xf={tokenize:Df};function Sf(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type===`labelImage`||r.type===`labelLink`||r.type===`labelEnd`){let e=r.type===`labelImage`?4:2;r.type=`data`,t+=e}}return e.length!==n.length&&Du(e,0,e.length,n),e}function Cf(e,t){let n=e.length,r=0,i,a,o,s;for(;n--;)if(i=e[n][1],a){if(i.type===`link`||i.type===`labelLink`&&i._inactive)break;e[n][0]===`enter`&&i.type===`labelLink`&&(i._inactive=!0)}else if(o){if(e[n][0]===`enter`&&(i.type===`labelImage`||i.type===`labelLink`)&&!i._balanced&&(a=n,i.type!==`labelLink`)){r=2;break}}else i.type===`labelEnd`&&(o=n);let c={type:e[a][1].type===`labelLink`?`link`:`image`,start:{...e[a][1].start},end:{...e[e.length-1][1].end}},l={type:`label`,start:{...e[a][1].start},end:{...e[o][1].end}},u={type:`labelText`,start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[[`enter`,c,t],[`enter`,l,t]],s=Ou(s,e.slice(a+1,a+r+3)),s=Ou(s,[[`enter`,u,t]]),s=Ou(s,ld(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=Ou(s,[[`exit`,u,t],e[o-2],e[o-1],[`exit`,l,t]]),s=Ou(s,e.slice(o+1)),s=Ou(s,[[`exit`,c,t]]),Du(e,a,e.length,s),e}function wf(e,t,n){let r=this,i=r.events.length,a,o;for(;i--;)if((r.events[i][1].type===`labelImage`||r.events[i][1].type===`labelLink`)&&!r.events[i][1]._balanced){a=r.events[i][1];break}return s;function s(t){return a?a._inactive?d(t):(o=r.parser.defined.includes(Ru(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(`labelEnd`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelEnd`),c):n(t)}function c(t){return t===40?e.attempt(yf,u,o?u:d)(t):t===91?e.attempt(bf,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(xf,u,d)(t)}function u(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}function Tf(e,t,n){return r;function r(t){return e.enter(`resource`),e.enter(`resourceMarker`),e.consume(t),e.exit(`resourceMarker`),i}function i(t){return Ku(t)?Xd(e,a)(t):a(t)}function a(t){return t===41?u(t):qd(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return Ku(t)?Xd(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?Yd(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return Ku(t)?Xd(e,u)(t):u(t)}function u(r){return r===41?(e.enter(`resourceMarker`),e.consume(r),e.exit(`resourceMarker`),e.exit(`resource`),t):n(r)}}function Ef(e,t,n){let r=this;return i;function i(t){return Jd.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(Ru(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function Df(e,t,n){return r;function r(t){return e.enter(`reference`),e.enter(`referenceMarker`),e.consume(t),e.exit(`referenceMarker`),i}function i(r){return r===93?(e.enter(`referenceMarker`),e.consume(r),e.exit(`referenceMarker`),e.exit(`reference`),t):n(r)}}var Of={name:`labelStartImage`,resolveAll:vf.resolveAll,tokenize:kf};function kf(e,t,n){let r=this;return i;function i(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),a}function a(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelImage`),o):n(t)}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var Af={name:`labelStartLink`,resolveAll:vf.resolveAll,tokenize:jf};function jf(e,t,n){let r=this;return i;function i(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelLink`),a}function a(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var Mf={name:`lineEnding`,tokenize:Nf};function Nf(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),X(e,t,`linePrefix`)}}var Pf={name:`thematicBreak`,tokenize:Ff};function Ff(e,t,n){let r=0,i;return a;function a(t){return e.enter(`thematicBreak`),o(t)}function o(e){return i=e,s(e)}function s(a){return a===i?(e.enter(`thematicBreakSequence`),c(a)):r>=3&&(a===null||J(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),Y(t)?X(e,s,`whitespace`)(t):s(t))}}var If={continuation:{tokenize:Bf},exit:Hf,name:`list`,tokenize:zf},Lf={partial:!0,tokenize:Uf},Rf={partial:!0,tokenize:Vf};function zf(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){let i=r.containerState.type||(t===42||t===43||t===45?`listUnordered`:`listOrdered`);if(i===`listUnordered`?!r.containerState.marker||t===r.containerState.marker:Uu(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),i===`listUnordered`)return e.enter(`listItemPrefix`),t===42||t===45?e.check(Pf,n,l)(t):l(t);if(!r.interrupt||t===49)return e.enter(`listItemPrefix`),e.enter(`listItemValue`),c(t)}return n(t)}function c(t){return Uu(t)&&++o<10?(e.consume(t),c):(!r.interrupt||o<2)&&(r.containerState.marker?t===r.containerState.marker:t===41||t===46)?(e.exit(`listItemValue`),l(t)):n(t)}function l(t){return e.enter(`listItemMarker`),e.consume(t),e.exit(`listItemMarker`),r.containerState.marker=r.containerState.marker||t,e.check(gd,r.interrupt?n:u,e.attempt(Lf,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return Y(t)?(e.enter(`listItemPrefixWhitespace`),e.consume(t),e.exit(`listItemPrefixWhitespace`),f):n(t)}function f(n){return r.containerState.size=a+r.sliceSerialize(e.exit(`listItemPrefix`),!0).length,t(n)}}function Bf(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(gd,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,X(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!Y(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(Rf,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,X(e,e.attempt(If,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function Vf(e,t,n){let r=this;return X(e,i,`listItemIndent`,r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`listItemIndent`&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function Hf(e){e.exit(this.containerState.type)}function Uf(e,t,n){let r=this;return X(e,i,`listItemPrefixWhitespace`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function i(e){let i=r.events[r.events.length-1];return!Y(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var Wf={name:`setextUnderline`,resolveTo:Gf,tokenize:Kf};function Gf(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);let o={type:`setextHeading`,start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type=`setextHeadingText`,a?(e.splice(i,0,[`enter`,o,t]),e.splice(a+1,0,[`exit`,e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push([`exit`,o,t]),e}function Kf(e,t,n){let r=this,i;return a;function a(t){let a=r.events.length,s;for(;a--;)if(r.events[a][1].type!==`lineEnding`&&r.events[a][1].type!==`linePrefix`&&r.events[a][1].type!==`content`){s=r.events[a][1].type===`paragraph`;break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter(`setextHeadingLine`),i=t,o(t)):n(t)}function o(t){return e.enter(`setextHeadingLineSequence`),s(t)}function s(t){return t===i?(e.consume(t),s):(e.exit(`setextHeadingLineSequence`),Y(t)?X(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||J(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var qf={tokenize:Jf};function Jf(e){let t=this,n=e.attempt(gd,r,e.attempt(this.parser.constructs.flowInitial,i,X(e,e.attempt(this.parser.constructs.flow,i,e.attempt(Hd,i)),`linePrefix`)));return n;function r(r){if(r===null){e.consume(r);return}return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null){e.consume(r);return}return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}var Yf={resolveAll:$f()},Xf=Qf(`string`),Zf=Qf(`text`);function Qf(e){return{resolveAll:$f(e===`text`?ep:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return c(e)?i(e):o(e)}function o(e){if(e===null){t.consume(e);return}return t.enter(`data`),t.consume(e),s}function s(e){return c(e)?(t.exit(`data`),i(e)):(t.consume(e),s)}function c(e){if(e===null)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}function $f(e){return t;function t(t,n){let r=-1,i;for(;++r<=t.length;)i===void 0?t[r]&&t[r][1].type===`data`&&(i=r,r++):(!t[r]||t[r][1].type!==`data`)&&(r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),r=i+2),i=void 0);return e?e(t,n):t}}function ep(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===`lineEnding`)&&e[n-1][1].type===`data`){let r=e[n-1][1],i=t.sliceStream(r),a=i.length,o=-1,s=0,c;for(;a--;){let e=i[a];if(typeof e==`string`){for(o=e.length;e.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(e===-2)c=!0,s++;else if(e!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){let i={type:n===e.length||c||s<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:a?o:r.start._bufferIndex+o,_index:r.start._index+a,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...i.start},r.start.offset===r.end.offset?Object.assign(r,i):(e.splice(n,0,[`enter`,i,t],[`exit`,i,t]),n+=2)}n++}return e}var tp=t({attentionMarkers:()=>lp,contentInitial:()=>rp,disable:()=>up,document:()=>np,flow:()=>ap,flowInitial:()=>ip,insideSpan:()=>cp,string:()=>op,text:()=>sp}),np={42:If,43:If,45:If,48:If,49:If,50:If,51:If,52:If,53:If,54:If,55:If,56:If,57:If,62:vd},rp={91:Zd},ip={[-2]:Ad,[-1]:Ad,32:Ad},ap={35:rf,42:Pf,45:[Wf,Pf],60:lf,61:Wf,95:Pf,96:Dd,126:Dd},op={38:wd,92:Sd},sp={[-5]:Mf,[-4]:Mf,[-3]:Mf,33:Of,38:wd,42:ud,60:[md,gf],91:Af,92:[tf,Sd],93:vf,95:ud,96:Pd},cp={null:[ud,Yf]},lp={null:[42,95]},up={null:[]};function dp(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],c={attempt:C(x),check:C(S),consume:v,enter:y,exit:b,interrupt:C(S,{interrupt:!0})},l={code:null,containerState:{},defineSkip:h,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d},u=t.tokenize.call(l,c);return t.resolveAll&&a.push(t),l;function d(e){return o=Ou(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=ld(a,l.events,l),l.events):[]}function f(e,t){return pp(p(e),t)}function p(e){return fp(o,e)}function m(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function h(e){i[e.line]=e.column,ee()}function g(){let e;for(;r._index<o.length;){let t=o[r._index];if(typeof t==`string`)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<t.length;)_(t.charCodeAt(r._bufferIndex));else _(t)}}function _(e){u=u(e)}function v(e){J(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,ee()):e!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=e}function y(e,t){let n=t||{};return n.type=e,n.start=m(),l.events.push([`enter`,n,l]),s.push(n),n}function b(e){let t=s.pop();return t.end=m(),l.events.push([`exit`,t,l]),t}function x(e,t){w(e,t.from)}function S(e,t){t.restore()}function C(e,t){return n;function n(n,r,i){let a,o,s,u;return Array.isArray(n)?f(n):`tokenize`in n?f([n]):d(n);function d(e){return t;function t(t){let n=t!==null&&e[t],r=t!==null&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return a=e,o=0,e.length===0?i:p(e[o])}function p(e){return n;function n(n){return u=T(),s=e,e.partial||(l.currentConstruct=e),e.name&&l.parser.constructs.disable.null.includes(e.name)?h(n):e.tokenize.call(t?Object.assign(Object.create(l),t):l,c,m,h)(n)}}function m(t){return e(s,u),r}function h(e){return u.restore(),++o<a.length?p(a[o]):i}}}function w(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&Du(l.events,t,l.events.length-t,e.resolve(l.events.slice(t),l)),e.resolveTo&&(l.events=e.resolveTo(l.events,l))}function T(){let e=m(),t=l.previous,n=l.currentConstruct,i=l.events.length,a=Array.from(s);return{from:i,restore:o};function o(){r=e,l.previous=t,l.currentConstruct=n,l.events.length=i,s=a,ee()}}function ee(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function fp(e,t){let n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex,o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){let e=o[0];typeof e==`string`?o[0]=e.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function pp(e,t){let n=-1,r=[],i;for(;++n<e.length;){let a=e[n],o;if(typeof a==`string`)o=a;else switch(a){case-5:o=`\\r`;break;case-4:o=`\n`;break;case-3:o=`\\r\n`;break;case-2:o=t?` `:`\t`;break;case-1:if(!t&&i)continue;o=` `;break;default:o=String.fromCharCode(a)}i=a===-2,r.push(o)}return r.join(``)}function mp(e){let t={constructs:Au([tp,...(e||{}).extensions||[]]),content:n(nd),defined:[],document:n(id),flow:n(qf),lazy:{},string:n(Xf),text:n(Zf)};return t;function n(e){return n;function n(n){return dp(t,e,n)}}}function hp(e){for(;!Bd(e););return e}var gp=/[\\0\\t\\n\\r]/g;function _p(){let e=1,t=``,n=!0,r;return i;function i(i,a,o){let s=[],c,l,u,d,f;for(i=t+(typeof i==`string`?i.toString():new TextDecoder(a||void 0).decode(i)),u=0,t=``,n&&(i.charCodeAt(0)===65279&&u++,n=void 0);u<i.length;){if(gp.lastIndex=u,c=gp.exec(i),d=c&&c.index!==void 0?c.index:i.length,f=i.charCodeAt(d),!c){t=i.slice(u);break}if(f===10&&u===d&&r)s.push(-3),r=void 0;else switch(r&&(s.push(-5),r=void 0),u<d&&(s.push(i.slice(u,d)),e+=d-u),f){case 0:s.push(65533),e++;break;case 9:for(l=Math.ceil(e/4)*4,s.push(-2);e++<l;)s.push(-1);break;case 10:s.push(-4),e=1;break;default:r=!0,e=1}u=d+1}return o&&(r&&s.push(-5),t&&s.push(t),s.push(null)),s}}function vp(e,t,n){return typeof t!=`string`&&(n=t,t=void 0),td(n)(hp(mp(n).document().write(_p()(e,t,!0))))}var yp={none:``,left:` align=\"left\"`,right:` align=\"right\"`,center:` align=\"center\"`};function bp(){return{enter:{table(e){let t=e._align;this.lineEndingIfNeeded(),this.tag(`<table>`),this.setData(`tableAlign`,t)},tableBody(){this.tag(`<tbody>`)},tableData(){let e=yp[this.getData(`tableAlign`)[this.getData(`tableColumn`)]];e===void 0?this.buffer():(this.lineEndingIfNeeded(),this.tag(`<td`+e+`>`))},tableHead(){this.lineEndingIfNeeded(),this.tag(`<thead>`)},tableHeader(){let e=yp[this.getData(`tableAlign`)[this.getData(`tableColumn`)]];this.lineEndingIfNeeded(),this.tag(`<th`+e+`>`)},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,xp)),this.raw(this.encode(t))},table(){this.setData(`tableAlign`),this.setData(`slurpAllLineEndings`),this.lineEndingIfNeeded(),this.tag(`</table>`)},tableBody(){this.lineEndingIfNeeded(),this.tag(`</tbody>`)},tableData(){let 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(){let e=this.getData(`tableColumn`);this.tag(`</th>`),this.setData(`tableColumn`,e+1)},tableRow(){let e=this.getData(`tableAlign`),t=this.getData(`tableColumn`);for(;t<e.length;)this.lineEndingIfNeeded(),this.tag(`<td`+yp[e[t]]+`></td>`),t++;this.setData(`tableColumn`,t),this.lineEndingIfNeeded(),this.tag(`</tr>`)}}}}function xp(e,t){return t===`|`?t:e}var Sp=class{constructor(){this.map=[]}add(e,t,n){Cp(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0}};function Cp(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 wp(e,t){let n=!1,r=[];for(;t<e.length;){let 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`){let e=r.length-1;r[e]=r[e]===`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 Tp(){return{flow:{null:{name:`table`,tokenize:Ep,resolveAll:Dp}}}}function Ep(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let e=r.events[t][1].type;if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):J(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):Y(t)?X(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||Ku(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,Y(t)?X(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return Y(t)?X(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||J(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return Y(t)?X(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||J(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||J(n)?(e.exit(`tableRow`),t(n)):Y(n)?X(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||Ku(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function Dp(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new Sp;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(kp(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=Op(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=Op(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=Op(f,t,o,i,n,d)):(o[0]=o[1],d=Op(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&kp(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=wp(t.events,n))}return e}function Op(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},Ap(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=Ap(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=Ap(t.events,n[2]),a=Ap(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},Ap(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function kp(e,t,n,r,i){let a=[],o=Ap(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function Ap(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}function jp(){return{enter:{strikethrough(){this.tag(`<del>`)}},exit:{strikethrough(){this.tag(`</del>`)}}}}function Mp(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??(t=!0),{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&Du(o,o.length,0,ld(s,e.slice(r+1,n),t)),Du(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),Du(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=cd(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=cd(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}function Np(e){let t=[`codeIndented`];return e?.inline&&t.push(`list`,`headingAtx`,`setextUnderline`,`thematicBreak`,`blockQuote`,`codeFenced`,`table`),{allowDangerousHtml:!0,extensions:[Tp(),Mp(),{disable:{null:t}}],htmlExtensions:[bp(),jp()]}}function Pp(e,t){let n=Np(t);return vp(e,{...n,extensions:[...n.extensions??[],Bp(e),Ip]})}var Fp=e=>{let t=e.length-2,n=e[t-1];return n&&n[0]===`exit`&&n[1].type===`data`&&(n[1].end=e[t][1].end,e.length=t),e},Ip={text:{null:{name:`textData`,tokenize(e,t){let n=this,r=this.parser.constructs.text;function i(e){if(e===null)return!0;let t=r[e]??[];return(Array.isArray(t)?t:[t]).some(e=>!e.previous||e.previous.call(n,n.previous))}function a(n){return i(n)?(e.exit(`data`),t(n)):(e.consume(n),a)}return t=>(e.enter(`data`),e.consume(t),a)},resolveTo:Fp}}},Lp=/[#-'*+\\--9=?A-Z^-~]/,Rp=/[0-9A-Za-z]/,zp=/[A-Za-z]/;function Bp(e){let t=e.charCodeAt(0)===65279?1:0,n=e.lastIndexOf(`-->`),r=e.lastIndexOf(`?>`),i=e.lastIndexOf(`]]>`),a=e.lastIndexOf(`>`);function o(t){return e[t]===`<`?e.startsWith(`\\x3C!--`,t)?n<t+2:e.startsWith(`<![CDATA[`,t)?i<t+9:e[t+1]===`!`&&zp.test(e[t+2]??``)?a<t+3:e[t+1]===`?`?r<t+2&&!s(t):!1:!1}function s(t){let n=t+1;for(;Lp.test(e[n]??``);)n++;if(e[n]!==`@`)return!1;n++;let r=0,i=`atSignOrDot`;for(;;){let t=e[n]??``;if(i===`atSignOrDot`){if(!Rp.test(t))return!1;i=`label`}else if(i===`label`){if(t===`>`)return!0;t===`.`?(n++,r=0,i=`atSignOrDot`):i=`value`}else{if(!((t===`-`||Rp.test(t))&&r++<63))return!1;n++,i=t===`-`?`value`:`label`}}}let c={name:`unclosedHtml`,resolveTo:Fp,tokenize(e,n,r){let i=this.now().offset+t;return t=>t!==60||!o(i)?r(t):(e.enter(`data`),e.consume(t),e.exit(`data`),n)}};return{text:{60:c}}}function Vp(e){let t=e.metadata[`data-source-file`],n=e.metadata[`data-source-line`];return t?n?` (${t}:${n})`:` (${t})`:``}function Hp(){let e=Q.getState();if(!e.storyData)return``;let t=e.storyData.passages.get(e.currentPassage);return t?Vp(t):``}function Up({macro:e,error:t}){return q(`span`,{class:`error`,title:String(t),children:`{${e} error${Hp()}: ${xs(t)}}`})}function Wp(e,t,n=Hp()){console.error(`spindle: Error in {${e}}${n}:`,t)}function Gp(e,t,n){let r=A();if(r.current===void 0){r.current=null;let i=Hp();try{n()}catch(n){r.current={error:n},Wp(`${e} ${t}`.trim(),n,i)}}return r.current?q(Up,{macro:e,error:r.current.error}):null}var Kp={update:e=>{throw Error(`Cannot set @${e} — local variables require a {for}, widget, {link}, or {button} scope`)},getValues:()=>fs},qp=_e(fs),Jp=_e(Kp),Yp=_e(!1),Xp=_e(!1),Zp=_e(!1),Qp=_e(!1),$p=_e(!1),em=_e(``),tm=0;function nm(){return je(()=>`v${++tm}`)[0]}var rm=_e(!1),im=`http://www.w3.org/2000/svg`,am=new Set([`table`,`thead`,`tbody`,`tfoot`,`tr`,`colgroup`,`ul`,`ol`,`menu`,`dl`,`select`,`optgroup`,`datalist`]),om=new Set([`pre`,`textarea`,`style`]),sm=_e(null);function cm(e,t){return`<span data-tw=${e}:${t}></span>`}var lm=/(?:(?<=\\\\)\\uE000)?<span data-tw=([0-9a-z]+):(\\d+)><\\/span>/g,um=``;function dm(e,t){if(!e.includes(`<span data-tw=`))return[e];let n=[],r=0;for(let i of e.matchAll(lm))i[1]===t.nonce&&(i.index>r&&n.push(e.slice(r,i.index)),n.push(parseInt(i[2],10)),r=i.index+i[0].length);return r<e.length&&n.push(e.slice(r)),n}function fm(e,t){return dm(e,t).map(e=>typeof e==`number`?t.components[e]:e)}function pm({tag:e,attributes:t,placeholders:n,svg:r,children:i}){let a=hu(),o=[],{props:s,direct:c}=Em(t.map(([e,t,r])=>{let i=n[e];if(!i)return[e,t,r];let s=fu(i,a);for(let t of s.errors)o.push([e,t]);return[e,s.text,r]}),r),l=Dm(c);return hm(o,b(e,l?{...s,ref:l}:s,...i))}function mm({tag:e,props:t,direct:n,children:r}){let i=Dm(n);return b(e,{...t,ref:i},...r)}function hm(e,t){return e.length===0?t:q(S,{children:[e.map(([e,{macro:t,error:n}],r)=>q(Up,{macro:t,error:Error(`in attribute \"${e}\": ${xs(n)}`)},r)),t]})}function gm(e,t){if(e==null||e.nodeType!==Node.ELEMENT_NODE)return-1;let n=e.getAttribute(`data-tw`),r=`${t.nonce}:`;return n==null||!n.startsWith(r)?-1:parseInt(n.slice(r.length),10)}function _m(e){let t=document.createElement(`template`);return t.innerHTML=e,t.content}function vm(e,t,n=!1){let r=_m(e.trim());if(n)for(let e of Array.from(r.childNodes))e.nodeType===Node.ELEMENT_NODE&&e.nodeName===`P`&&e.replaceWith(...Array.from(e.childNodes));return q(S,{children:Array.from(r.childNodes).map((e,n)=>ym(e,n,t))})}function ym(e,t,n){if(e.nodeType===Node.TEXT_NODE){let t=e.textContent??``;t.endsWith(`\\\\${um}`)&&gm(e.nextSibling,n)!==-1&&(t=t.slice(0,-1));let r=fm(t,n);return r.length===1?r[0]:r}if(e.nodeType===Node.ELEMENT_NODE){let r=e,i=r.localName,a=gm(r,n);if(a!==-1)return n.components[a];let o=r.namespaceURI===im,s=[],c;for(let{name:e,value:t}of Array.from(r.attributes)){s.push([e,t,t]);let r=dm(t,n);r.every(e=>typeof e==`string`)||(c??(c={}),c[e]=r.map(e=>typeof e==`string`?{type:`text`,value:e}:n.nodes[e]))}let l=Array.from(r.childNodes).map((e,t)=>ym(e,t,n));if(c)return q(pm,{tag:i,attributes:s,placeholders:c,svg:o,children:l},t);let{props:u,direct:d}=Em(s,o);return d.length>0?q(mm,{tag:i,props:u,direct:d,children:l},t):b(i,{...u,key:t},...l)}return null}var bm=new Set(`a.abbr.b.bdi.bdo.br.button.cite.code.data.dfn.em.i.h1.h2.h3.h4.h5.h6.kbd.label.legend.mark.meter.option.output.p.progress.q.rp.rt.ruby.s.samp.small.span.strong.sub.summary.sup.time.u.var.wbr`.split(`.`)),xm=new Set([`value`,`checked`,`selected`,`muted`]),Sm=new Set([`allowfullscreen`,`async`,`autofocus`,`autoplay`,`checked`,`controls`,`default`,`defer`,`disabled`,`formnovalidate`,`hidden`,`inert`,`ismap`,`itemscope`,`loop`,`multiple`,`muted`,`nomodule`,`novalidate`,`open`,`playsinline`,`readonly`,`required`,`reversed`,`selected`]),Cm=new Set([...new Set([`key`,`ref`,`children`,`dangerouslySetInnerHTML`]),`class`,`className`]),wm=/^[A-Za-z_:][\\w:.-]*$/;function Tm(e,t,n){if(wm.test(t)){e.setAttribute(t,n);return}let r=_m(`<i ${t}=\"\"></i>`).firstChild.attributes[0];if(!r)return;let i=r.cloneNode();i.value=n,e.setAttributeNode(i)}function Em(e,t){let n={},r=[];for(let[i,a,o]of e){let e=i.toLowerCase();Sm.has(e)&&o!==``&&a===``||(!t&&xm.has(e)?n[e]=e!==`value`&&o===``?!0:a:!wm.test(i)||e.startsWith(`on`)||e===`translate`||t&&(Cm.has(i)||i===`__proto__`)?r.push([i,a]):n[t?i:i.toUpperCase()]=a)}return{props:n,direct:r}}function Dm(e){let t=A(null);return Pe(()=>{let n=t.current;if(!(!n||e.length===0)){for(let[t,r]of e)Tm(n,t,r);return()=>{for(let[t]of e)n.removeAttribute(t)}}},[JSON.stringify(e)]),e.length>0?t:void 0}var Om=new Map,km=new Map;function Am(e,t,n){if(!e.includes(`&`))return e;let r=t.get(e);return r===void 0&&(r=n(e)??e,t.set(e,r)),r}function jm(e){return Am(e,km,e=>_m(`<i title=\"${e.replace(/\"/g,`&quot;`)}\"></i>`).firstChild.getAttribute(`title`))}function Mm(e){return Am(e,Om,e=>_m(`<i>${e.replace(/</g,`&lt;`)}</i>`).firstChild.textContent)}var Nm=/\\{[$_@%]\\w/,Pm=new Map,Fm=2e3;function Im(e){let t=Pm.get(e);return t===void 0&&(t=au(e),`nodes`in t&&e.includes(`&`)&&(t={nodes:ou(t.nodes,jm)}),Pm.size>=Fm&&Pm.clear(),Pm.set(e,t)),t}function Lm(e,t,n,r){if(Ko(e)){if(!t.includes(`&`)&&!Nm.test(t))return t;let i=mu(t,n,jm);for(let t of i.errors)r.push([e,t]);return i.text}if(!tu(t))return jm(t);let i=Im(t);if(`error`in i)return r.push([e,{macro:`markup`,error:i.error}]),jm(t);let a=fu(i.nodes,n);for(let t of a.errors)r.push([e,t]);return a.text}function Rm(e){let t=e.findIndex(e=>e.type!==`text`||e.value.trim()!==``),n=e[t];return n?.type===`html`&&n.tag.toLowerCase()===`summary`?t:-1}function zm({node:e}){let t=hu(),{nobr:n,locals:r,raw:i,inline:a,structural:o}=xu(),s=j(rm),c=e.tag.toLowerCase(),l=c===`svg`,u=!i&&(l||om.has(c)),d=[],{props:f,direct:p}=Em(Object.entries(e.attributes).map(([e,n])=>[e,Lm(e,n,t,d),n]),s||l),m=Dm(p);m&&(f.ref=m);let h=bm.has(c),g,_=!1;if(e.children.length>0)if(i||u)g=Km(e.children);else{let t=c===`details`?Rm(e.children):-1,i=e=>eh(e,{nobr:n,locals:r,inline:h});_=am.has(c)&&e.children.every(e=>e.type!==`text`||e.value.trim()===``),g=_?e.children.filter(e=>e.type!==`text`).map(e=>Gm(e)):t===-1?i(e.children):q(S,{children:[i(e.children.slice(0,t)),Gm(e.children[t]),i(e.children.slice(t+1))]}),h!==a&&(g=q(Zp.Provider,{value:h,children:g})),_!==o&&(g=q(Qp.Provider,{value:_,children:g}))}s&&c===`foreignobject`&&g&&(g=q(rm.Provider,{value:!1,children:g}));let v=b(e.tag,f,g);return l&&!s&&(v=q(rm.Provider,{value:!0,children:v})),hm(d,u?q($p.Provider,{value:!0,children:v}):v)}function Bm(){let e=j(sm),t=xu();return e?q(sm.Provider,{value:e.outer,children:eh(e.nodes,t)}):null}var Vm=new WeakMap,Hm=0;function Um(e){let t=Vm.get(e);return t===void 0&&(t=`n${Hm++}`,Vm.set(e,t)),t}function Wm(e,t){if(Vc(e.name))return null;let n={rawArgs:e.rawArgs,className:e.className,id:e.id},r=ys(e.name);if(r)return q(Cu,{...n,body:r.body,params:r.params,invocationChildren:e.children},t);let i=Fc(e.name);return i?q(i,{...n,children:e.children,branches:e.branches},t):q(`span`,{class:`error`,children:`{unknown macro: ${e.name}}`},t)}function Gm(e){if(e.type===`text`)return e.comment?null:Mm(e.value);let t=Um(e);switch(e.type){case`variable`:return e.scope===`local`&&e.name===`children`?q(Bm,{},t):q(yu,{node:e},t);case`expression`:return q(bu,{node:e},t);case`macro`:return Wm(e,t);case`html`:return q(zm,{node:e},t);default:return e}}function Km(e){return e.length===0?null:e.map(e=>Gm(e))}var qm=/[*_`#|~\\[>\\\\\\-+=\\r]|!\\[|\\d+[.)]|&#?[a-zA-Z0-9]+;| {2}\\n|<[!?]/,Jm=/(?:\\r\\n|\\r(?!\\n)|\\n)\\s*[\\r\\n]/,Ym=/<span data-tw=[0-9a-z]+:\\d+><\\/span>/g,Xm=` \t\\r\n`;function Zm(e,t,n,r){let i=t;if(n===1)for(;i<e.length&&r.includes(e[i]);)i++;else for(;i>0&&r.includes(e[i-1]);)i--;return i}function Qm(e){return e.includes(`\n`)?e.split(`\n`).map((e,t,n)=>{let r=t===0?0:Zm(e,0,1,` \t`),i=t===n.length-1?e.length:Zm(e,e.length,-1,` \t`);return e.slice(r,Math.max(r,i))}).join(`\n`):e}function $m(e,t,n){let r=fm(Qm(e),t).filter(e=>e!==``);return n?q(S,{children:r}):b(`p`,null,...r)}function eh(e,t){if(e.length===0)return null;if(t?.raw)return Km(e);if(t?.structural&&e.every(e=>e.type!==`text`||e.value.trim()===``))return e.filter(e=>e.type!==`text`).map(Gm);if(!e.some(e=>e.type===`text`&&(e.value.trim()!==``||Jm.test(e.value))))return e.map(e=>Gm(e));let n=[],r={nonce:Math.random().toString(36).slice(2,10)||`0`,components:n,nodes:[]},i=``;for(let t=0;t<e.length;t++){let a=e[t];if(a.type===`text`){i+=a.value;continue}let o=n.length;n.push(Gm(a)),r.nodes.push(a),i.endsWith(`\\\\`)&&(i+=um),i+=cm(r.nonce,o)}let a=!!(t?.nobr||t?.inline),o=i.slice(0,Zm(i,0,1,Xm)),s=o.length===i.length?``:i.slice(Zm(i,i.length,-1,Xm)),c=i.slice(o.length,i.length-s.length),l=e=>a&&(o||s)?q(S,{children:[o,e,s]}):e,u=i.replace(Ym,``);return!qm.test(u)&&!Jm.test(u)?l($m(c,r,a)):l(vm(Pp(i,{inline:t?.inline}),r,a))}var th=2**32-1,nh=th-1,rh=class extends Error{constructor(e,t,n,r){super(e),this.name=`DevalueError`,this.path=t.join(``),this.value=n,this.root=r}},ih=Symbol();function ah(e,t){let n=[];for(let r=0;r<e.length;r+=1){let i=e[r];i===ih?n.push(`.get(${t(e[++r])})`):typeof i==`number`?n.push(`[${i}]`):n.push(vh(i))}return n}var oh=Object.getOwnPropertyNames(Object.prototype).sort().join(`\\0`);function sh(e){let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null||Object.getPrototypeOf(t)===null||Object.getOwnPropertyNames(t).sort().join(`\\0`)===oh}function ch(e){return Object.prototype.toString.call(e).slice(8,-1)}function lh(e){return typeof Buffer<`u`&&Buffer.isBuffer(e)}function uh(e){switch(e){case`\"`:return`\\\\\"`;case`<`:return`\\\\u003C`;case`\\\\`:return`\\\\\\\\`;case`\n`:return`\\\\n`;case`\\r`:return`\\\\r`;case`\t`:return`\\\\t`;case`\\b`:return`\\\\b`;case`\\f`:return`\\\\f`;case`\\u2028`:return`\\\\u2028`;case`\\u2029`:return`\\\\u2029`;default:return e<` `?`\\\\u${e.charCodeAt(0).toString(16).padStart(4,`0`)}`:``}}var dh=/[\"<\\\\\\u0000-\\u001f\\u2028\\u2029]/;function fh(e){if(!dh.test(e)&&e.isWellFormed())return`\"${e}\"`;let t=``,n=0,r=e.length;for(let i=0;i<r;i+=1){let a=e.charCodeAt(i);if(a>=55296&&a<=57343){if(a<=56319&&i+1<r&&(e.charCodeAt(i+1)&64512)==56320){i+=1;continue}t+=e.slice(n,i)+`\\\\u${a.toString(16)}`,n=i+1;continue}let o=uh(e[i]);o&&(t+=e.slice(n,i)+o,n=i+1)}return`\"${n===0?e:t+e.slice(n)}\"`}var ph=64,mh=new Map;function hh(e){if(e.length>ph)return fh(e);let t=mh.get(e);return t===void 0&&(mh.size>=1024&&mh.clear(),t=fh(e),mh.set(e,t)),t}function gh(e){let t=Object.getOwnPropertySymbols(e);return t.length===0?t:t.filter(t=>Object.getOwnPropertyDescriptor(e,t)?.enumerable)}var _h=/^[a-zA-Z_$][a-zA-Z_$0-9]*$/;function vh(e){return _h.test(e)?`.`+e:`[`+JSON.stringify(e)+`]`}function yh(e){return!(!Number.isInteger(e)||e<0||e>nh)}function bh(e){return!(!Number.isInteger(e)||e<0||e>th)}function xh(e){if(e.length===0||e.length>1&&e.charCodeAt(0)===48)return!1;for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n<48||n>57)return!1}return yh(+e)}function Sh(e){for(var t=e.length-1;t>=0&&!xh(e[t]);t--);return t+1}function Ch(e){let t=Object.keys(e);return t.length=Sh(t),t}function wh(e){return new Uint8Array(e).toBase64()}function Th(e){return Uint8Array.fromBase64(e).buffer}function Eh(e){return Buffer.from(e).toString(`base64`)}function Dh(e){return Uint8Array.from(Buffer.from(e,`base64`)).buffer}function Oh(e){let t=new Uint8Array(e),n=``,r=32768;for(let e=0;e<t.length;e+=r){let i=t.subarray(e,e+r);n+=String.fromCharCode.apply(null,i)}return btoa(n)}function kh(e){let t=atob(e),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.charCodeAt(e);return r.buffer}var Ah=typeof Uint8Array.fromBase64==`function`,jh=typeof process==`object`&&process.versions?.node!==void 0,Mh=Ah?wh:jh?Eh:Oh,Nh=Ah?Th:jh?Dh:kh;function Ph(e,t){if(!t)return e;let n={};for(let r of Object.keys(e))n[r]=t[r]??e[r];return n}var Fh=Object.freeze({kind:`not-plain`}),Ih=Object.freeze({kind:`symbol-keys`}),Lh=Object.freeze({identify:e=>e,typeOf:e=>e===null?`null`:typeof e,toPrimitive:e=>e,tagOf:e=>ch(e),isThenable:e=>typeof e.then==`function`,toPromise:e=>Promise.resolve(e),unbox:e=>e.valueOf(),toISOString:e=>isNaN(e.getDate())?``:e.toISOString(),toStringValue:e=>e.toString(),regExpInfo:e=>({source:e.source,flags:e.flags}),valuesOf:e=>e,entriesOf:e=>e,viewInfo:e=>(lh(e)&&(e=new Uint8Array(e)),{buffer:e.buffer,byteOffset:e.byteOffset,byteLength:e.byteLength,length:e.length,bufferByteLength:e.buffer.byteLength}),toArrayBuffer:e=>e,lengthOf:e=>e.length,hasOwn:(e,t)=>Object.hasOwn(e,t),indicesOf:e=>Ch(e),shapeOf:e=>sh(e)?gh(e).length>0?Ih:{kind:Object.getPrototypeOf(e)===null?`null-proto`:`plain`,keys:Object.keys(e)}:Fh,get:(e,t)=>e[t]}),Rh=Object.getOwnPropertyDescriptor(ArrayBuffer.prototype,`byteLength`)?.get,zh=typeof SharedArrayBuffer>`u`?void 0:Object.getOwnPropertyDescriptor(SharedArrayBuffer.prototype,`byteLength`)?.get,Bh=Object.freeze({fromPrimitive:e=>e,fromISOString:e=>new Date(e),fromStringValue:(e,t)=>e===`URL`?new URL(t):e===`URLSearchParams`?new URLSearchParams(t):Temporal[e.slice(9)].from(t),fromArrayBuffer:e=>e,fromRegExpInfo:(e,t)=>new RegExp(e,t),fromViewInfo:(e,t,n,r)=>{try{Rh.call(t)}catch(e){if(!zh)throw e;zh.call(t)}let i=globalThis[e];return n===void 0?new i(t):new i(t,n,r)},box:e=>Object(e),createArray:e=>Array(e),createSparseArray:e=>{let t=[];return t[nh]=void 0,delete t[nh],t.length=e,t},createObject:()=>({}),createNullPrototypeObject:()=>Object.create(null),createSet:()=>new Set,createMap:()=>new Map,set:(e,t,n)=>{e[t]=n},addValue:(e,t)=>{e.add(t)},addEntry:(e,t,n)=>{e.set(t,n)}});function Vh(){throw Error(`Invalid input`)}function Hh(e,t,n){return Uh(JSON.parse(e),t,n)}function Uh(e,t,n){let r=Ph(Bh,n?.operations);if(typeof e==`number`)return c(e,!0);(!Array.isArray(e)||e.length===0)&&Vh();let i=e,a=Array(i.length),o=null;function s(e){return(!yh(e)||e>=i.length)&&Vh(),i[e]}function c(e,n=!1){if(e===-1)return r.fromPrimitive(void 0);if(e===-3)return r.fromPrimitive(NaN);if(e===-4)return r.fromPrimitive(1/0);if(e===-5)return r.fromPrimitive(-1/0);if(e===-6)return r.fromPrimitive(-0);if((n||typeof e!=`number`)&&Vh(),e in a)return a[e];e>=i.length&&Vh();let l=i[e];if(!l||typeof l!=`object`)a[e]=r.fromPrimitive(l);else if(Array.isArray(l))if(typeof l[0]==`string`){let n=l[0],u=t&&Object.hasOwn(t,n)?t[n]:void 0;if(u){let t=l[1];if(typeof t!=`number`&&(t=i.push(l[1])-1),Object.hasOwn(a,t))return a[e]=u(a[t]);if(o??(o=new Set),o.has(t))throw Error(`Invalid circular reference`);return o.add(t),a[e]=u(c(t)),o.delete(t),a[e]}switch(n){case`Date`:a[e]=r.fromISOString(l[1]);break;case`Set`:let t=r.createSet();a[e]=t;for(let e=1;e<l.length;e+=1)r.addValue(t,c(l[e]));break;case`Map`:let i=r.createMap();a[e]=i;for(let e=1;e<l.length;e+=2)r.addEntry(i,c(l[e]),c(l[e+1]));break;case`RegExp`:a[e]=r.fromRegExpInfo(l[1],l[2]);break;case`Object`:{let t=l[1];if(!(t===-3||t===-4||t===-5||t===-6)){let e=s(t),n=Array.isArray(e)&&e[0]===`BigInt`;(e===void 0||typeof e==`object`)&&!n&&Vh()}a[e]=r.box(c(t));break}case`BigInt`:a[e]=r.fromPrimitive(BigInt(l[1]));break;case`null`:let o=r.createNullPrototypeObject();a[e]=o;for(let e=1;e<l.length;e+=2){let t=l[e];if(typeof t!=`string`)throw Error(`Cannot parse an object with a non-string key`);if(t===`__proto__`)throw Error(\"Cannot parse an object with a `__proto__` property\");r.set(o,t,c(l[e+1]))}break;case`Int8Array`:case`Uint8Array`:case`Uint8ClampedArray`:case`Int16Array`:case`Uint16Array`:case`Float16Array`:case`Int32Array`:case`Uint32Array`:case`Float32Array`:case`Float64Array`:case`BigInt64Array`:case`BigUint64Array`:case`DataView`:{let t=l[1],i=s(t);(!Array.isArray(i)||i[0]!==`ArrayBuffer`)&&Vh();let o=c(t);a[e]=r.fromViewInfo(n,o,l[2],l[3]);break}case`ArrayBuffer`:{let t=l[1];if(typeof t!=`string`)throw Error(`Invalid ArrayBuffer encoding`);a[e]=r.fromArrayBuffer(Nh(t));break}case`URL`:case`URLSearchParams`:case`Temporal.Duration`:case`Temporal.Instant`:case`Temporal.PlainDate`:case`Temporal.PlainTime`:case`Temporal.PlainDateTime`:case`Temporal.PlainMonthDay`:case`Temporal.PlainYearMonth`:case`Temporal.ZonedDateTime`:a[e]=r.fromStringValue(n,l[1]);break;default:throw Error(`Unknown type ${n}`)}}else if(l[0]===-7){let t=l[1];bh(t)||Vh();let n=r.createSparseArray(t);a[e]=n;for(let e=2;e<l.length;e+=2){let i=l[e];(!yh(i)||i>=t)&&Vh(),r.set(n,i,c(l[e+1]))}}else{let t=r.createArray(l.length);a[e]=t;for(let e=0;e<l.length;e+=1){let n=l[e];n!==-2&&r.set(t,e,c(n))}}else{let t=r.createObject();a[e]=t;for(let e of Object.keys(l)){if(e===`__proto__`)throw Error(\"Cannot parse an object with a `__proto__` property\");r.set(t,e,c(l[e]))}}return a[e]}return c(0)}function Wh(e,t,n){let r=Gh(!1,e,t,n);return typeof r==`string`?r:`[${r.join(`,`)}]`}function Gh(e,t,n,r){let i=Ph(Lh,r?.operations),a=[],o=new Map,s=[];if(n)for(let e of Object.getOwnPropertyNames(n))s.push({key:e,fn:n[e]});let c=[],l=0;function u(e,n){throw new rh(e,ah(c,e=>{let t=i.typeOf(e);return t!==`object`&&t!==`function`&&t!==`symbol`?Kh(i.toPrimitive(e)):`...`}),n,t)}function d(t,n){let r=i.typeOf(t);if(r===`undefined`)return-1;let f;if(r===`number`){if(f=i.toPrimitive(t),Number.isNaN(f))return-3;if(f===1/0)return-4;if(f===-1/0)return-5;if(f===0&&1/f<0)return-6}let p=i.identify(t);if(o.has(p))return o.get(p);n??(n=l++),o.set(p,n);for(let{key:e,fn:r}of s){let i=r(t);if(i)return a[n]=`[\"${e}\",${d(i)}]`,n}r===`function`?u(`Cannot stringify a function`,t):r===`symbol`&&u(`Cannot stringify a Symbol primitive`,t);let m=``;if(r!==`object`)m=Kh(r===`number`?f:i.toPrimitive(t));else if(i.isThenable(t)){e||u(`Cannot stringify a Promise or thenable — use stringifyAsync instead`,t);let r=c.slice();m=i.toPromise(t).then(e=>{c=r;let t=d(e,n);t<0&&(a[n]=t)}),m.catch(()=>{})}else{let e=i.tagOf(t);switch(e){case`Number`:case`String`:case`Boolean`:case`BigInt`:m=`[\"Object\",${d(i.unbox(t))}]`;break;case`Date`:m=`[\"Date\",\"${i.toISOString(t)}\"]`;break;case`URL`:m=`[\"URL\",${fh(i.toStringValue(t))}]`;break;case`URLSearchParams`:m=`[\"URLSearchParams\",${fh(i.toStringValue(t))}]`;break;case`RegExp`:let{source:n,flags:r}=i.regExpInfo(t);m=r?`[\"RegExp\",${fh(n)},\"${r}\"]`:`[\"RegExp\",${fh(n)}]`;break;case`Array`:{let e=!1,n=i.lengthOf(t);m=`[`;for(let r=0;r<n;r+=1)if(r>0&&(m+=`,`),i.hasOwn(t,r))c.push(r),m+=d(i.get(t,r)),c.pop();else if(e)m+=-2;else{let r=i.indicesOf(t),a=r.length,o=String(n).length;if((n-a)*3>4+o+a*(o+1)){m=`[-7,`+n;for(let e=0;e<r.length;e++){let n=r[e];c.push(+n),m+=`,`+n+`,`+d(i.get(t,n)),c.pop()}break}else e=!0,m+=-2}m+=`]`;break}case`Set`:m=`[\"Set\"`;for(let e of i.valuesOf(t))m+=`,${d(e)}`;m+=`]`;break;case`Map`:m=`[\"Map\"`;for(let[e,n]of i.entriesOf(t))c.push(ih,e),m+=`,${d(e)},${d(n)}`,c.pop(),c.pop();m+=`]`;break;case`Int8Array`:case`Uint8Array`:case`Uint8ClampedArray`:case`Int16Array`:case`Uint16Array`:case`Float16Array`:case`Int32Array`:case`Uint32Array`:case`Float32Array`:case`Float64Array`:case`BigInt64Array`:case`BigUint64Array`:{let n=i.viewInfo(t);m=`[\"`+e+`\",`+d(n.buffer),n.byteLength!==n.bufferByteLength&&(m+=`,${n.byteOffset},${n.length}`),m+=`]`;break}case`DataView`:{let n=i.viewInfo(t);m=`[\"`+e+`\",`+d(n.buffer),n.byteLength!==n.bufferByteLength&&(m+=`,${n.byteOffset},${n.byteLength}`),m+=`]`;break}case`ArrayBuffer`:m=`[\"ArrayBuffer\",\"${Mh(i.toArrayBuffer(t))}\"]`;break;case`Temporal.Duration`:case`Temporal.Instant`:case`Temporal.PlainDate`:case`Temporal.PlainTime`:case`Temporal.PlainDateTime`:case`Temporal.PlainMonthDay`:case`Temporal.PlainYearMonth`:case`Temporal.ZonedDateTime`:m=`[\"${e}\",${fh(i.toStringValue(t))}]`;break;default:{let e=i.shapeOf(t);if(e.kind===`not-plain`&&u(`Cannot stringify arbitrary non-POJOs`,t),e.kind===`symbol-keys`&&u(`Cannot stringify POJOs with symbolic keys`,t),e.kind===`null-proto`){m=`[\"null\"`;for(let n of e.keys)n===`__proto__`&&u(`Cannot stringify objects with __proto__ keys`,t),c.push(n),m+=`,${hh(n)},${d(i.get(t,n))}`,c.pop();m+=`]`}else{m=`{`;let n=!1;for(let r of e.keys)r===`__proto__`&&u(`Cannot stringify objects with __proto__ keys`,t),n&&(m+=`,`),n=!0,c.push(r),m+=`${hh(r)}:${d(i.get(t,r))}`,c.pop();m+=`}`}}}}return a[n]=m,n}let f=d(t);return f<0?`${f}`:a}function Kh(e){let t=typeof e;return t===`string`?fh(e):e===void 0?`-1`:e===0&&1/e<0?`-6`:t===`bigint`?`[\"BigInt\",\"${e}\"]`:String(e)}var qh=e=>Object.prototype.toString.call(e).slice(8,-1),Jh=e=>qh(e).startsWith(`Temporal.`),Yh=e=>e instanceof Number||e instanceof String||e instanceof Boolean||qh(e)===`BigInt`;function Xh(e){return e instanceof Date||e instanceof RegExp||e instanceof Map||e instanceof Set||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof URL||e instanceof URLSearchParams||e instanceof Error||Yh(e)||Jh(e)}function Zh(e){if(!Xh(e))return;let t=e instanceof Error?`Error`:qh(e);return`${/^[AEIOU]/.test(t)?`an`:`a`} ${t}`}var Qh=[`message`,`cause`,`errors`],$h=e=>e!==`4294967295`&&String(Number(e)>>>0)===e;function eg(e){let t=Object.keys(e);return Array.isArray(e)?t.filter(e=>!$h(e)):t}function tg(e){return Mt(e)?e.entries():Map.prototype.entries.call(e)}function ng(e){return Mt(e)?e.values():Set.prototype.values.call(e)}function rg(e){if(Mt(e))return e.size;let t=e instanceof Map?Map.prototype:Set.prototype;return Reflect.get(t,`size`,e)}function ig(e,t){return Mt(e)?e.get(t):Map.prototype.get.call(e,t)}function ag(e,t,n){Mt(e)?e.set(t,n):Map.prototype.set.call(e,t,n)}var og=new Map,sg=new Map,cg=[ArrayBuffer,DataView,Object.getPrototypeOf(Int8Array),URL,URLSearchParams,Number,String,Boolean,Promise,WeakMap,WeakSet,Function];function lg(e,t){let n=typeof t==`function`?cg.find(e=>t.prototype instanceof e):void 0;if(n)throw TypeError(`spindle: Cannot register class \"${e}\": it extends ${n.name}, whose instances cannot be saved (a registered class may extend Array, Map, Set, Date, RegExp or Error)`);og.set(e,t),sg.set(t,e)}function ug(e){let t=Object.getPrototypeOf(e);return t===null?void 0:sg.get(t.constructor)}var dg=`c:`,fg=`E:`,pg=`S`,mg=`K`,hg=`R`,gg=new Map([Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError,globalThis.AggregateError].map(e=>[e.prototype,e.name])),_g=new Map([...gg].map(([e,t])=>[t,e.constructor])),vg=[`message`,`cause`,`errors`],yg=e=>typeof e==`object`&&!!e,bg=e=>yg(e)&&Object.getPrototypeOf(e)===Object.prototype,xg=e=>TypeError(`spindle: Malformed data for class \"${e}\"`),Sg=(e,t,n)=>{Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0,configurable:!0})};function Cg(e){if(Object.getOwnPropertySymbols(e).length>0)throw TypeError(`spindle: Cannot save an object with symbol keys`)}function wg(e,t=Object.keys(e)){Cg(e);let n={};if(e instanceof Error)for(let t of vg)G(e,t)&&Sg(n,t,e[t]);for(let r of t)Sg(n,r,e[r]);return n}var Tg={Array,Map,Set,Date,RegExp};function Eg(e){let t=()=>wg(e,eg(e));if(Array.isArray(e)){let n=Array(e.length);for(let t=0;t<e.length;t++)t in e&&(n[t]=e[t]);return[`Array`,n,t()]}return e instanceof Map?[`Map`,Array.from(tg(e)),t()]:e instanceof Set?[`Set`,Array.from(ng(e)),t()]:e instanceof Date?[`Date`,Date.prototype.getTime.call(e),t()]:e instanceof RegExp?[`RegExp`,[Reflect.get(RegExp.prototype,`source`,e),Reflect.get(RegExp.prototype,`flags`,e),e.lastIndex],t()]:Ag(wg(e))}function Dg(e){for(let t of vg)G(e,t)&&Object.defineProperty(e,t,{enumerable:!1})}var Og=e=>e.length===1&&JSON.stringify(e).length>3;function kg(e){let t=Object.keys(e);if(!t.some(Og))return!1;if(Cg(e),t.includes(`__proto__`))throw TypeError(`spindle: Cannot save a property named \"__proto__\"`);return t.flatMap(t=>[t,e[t]])}function Ag(e){let t=kg(e);return t?[mg,...t]:e}function jg(){let e={};for(let[t,n]of og)e[dg+t]=e=>yg(e)&&Object.getPrototypeOf(e)===n.prototype&&Eg(e);for(let[t,n]of gg)e[fg+n]=e=>yg(e)&&Object.getPrototypeOf(e)===t&&Ag(wg(e));return e[pg]=e=>{if(typeof e!=`symbol`)return!1;let t=Symbol.keyFor(e);return t!==void 0&&[t]},e[hg]=e=>e instanceof RegExp&&e.lastIndex!==0&&[e.source,e.flags,e.lastIndex],e[mg]=e=>bg(e)&&kg(e),e}function Mg(e){if(!Array.isArray(e)||typeof e[0]!=`string`||typeof e[1]!=`string`||!Number.isSafeInteger(e[2]))return;let t=new RegExp(e[0],e[1]);return t.lastIndex=e[2],t}function Ng(e,t){return e===`RegExp`?Mg(t):typeof t==`number`?new Date(t):void 0}var Pg=new WeakMap;function Fg(e,t,n){let[r,i,a]=n,o=typeof r==`string`&&G(Tg,r)?Tg[r]:void 0,s=r===`Date`||r===`RegExp`;if(n.length!==3||!o||!(t.prototype instanceof o)||!s&&G(n,1)&&!Array.isArray(i)||G(n,2)&&!bg(a))throw xg(e);let c=Pg.get(n);if(!c){let a=s?Ng(r,i):new o;if(!a)throw xg(e);c=Object.setPrototypeOf(a,t.prototype),Pg.set(n,c)}if(!s&&Array.isArray(i)&&Ig(c,i),bg(a))for(let e of Object.keys(a))Sg(c,e,a[e]);return c}function Ig(e,t){if(Array.isArray(e)){e.length=t.length;for(let n=0;n<t.length;n++)G(t,n)?e[n]=t[n]:delete e[n]}else if(e instanceof Map){Map.prototype.clear.call(e);for(let n of t){if(!Array.isArray(n)||n.length!==2)throw TypeError(`spindle: Malformed map entries`);Map.prototype.set.call(e,n[0],n[1])}}else{Set.prototype.clear.call(e);for(let n of t)Set.prototype.add.call(e,n)}}function Lg(e){return Array.isArray(e)&&e[0]===mg?Hg(e,1):e}function Rg(e){return t=>{if(t=Lg(t),Array.isArray(t))return Fg(e,zg(e),t);if(!bg(t)){if(yg(t)&&ug(t)===e)return t;throw xg(e)}let n=zg(e);if(Object.values(Tg).some(e=>n.prototype instanceof e))throw xg(e);return Object.setPrototypeOf(t,n.prototype),t instanceof Error&&Dg(t),t}}function zg(e){let t=og.get(e);if(!t)throw TypeError(`spindle: The save holds an instance of class \"${e}\", which is not registered`);return t}function Bg(e){let t=_g.get(e);if(t)return n=>{if(n=Lg(n),Object.getPrototypeOf(n)===t.prototype)return n;if(!bg(n))throw TypeError(`spindle: Malformed data for \"${e}\"`);return Object.setPrototypeOf(n,t.prototype),Dg(n),n}}var Vg=new WeakMap;function Hg(e,t=0){if(!Array.isArray(e)||(e.length-t)%2!=0)throw TypeError(`spindle: Malformed object entries`);let n=Vg.get(e);n||Vg.set(e,n={});for(let r=t;r<e.length&&G(e,r);r+=2){let t=e[r];if(typeof t!=`string`||t===`__proto__`)throw TypeError(`spindle: Malformed object entries`);Sg(n,t,G(e,r+1)?e[r+1]:void 0)}return n}var Ug=new Proxy({},{getOwnPropertyDescriptor(e,t){let n=Wg(t);return n&&{value:n,enumerable:!0,configurable:!0}},get:(e,t)=>Wg(t)});function Wg(e){if(typeof e==`string`){if(e===pg)return e=>{if(!Array.isArray(e)||typeof e[0]!=`string`)throw TypeError(`spindle: Malformed symbol`);return Symbol.for(e[0])};if(e===mg)return Hg;if(e===hg)return e=>{let t=Mg(e);if(!t)throw TypeError(`spindle: Malformed regular expression`);return t};if(e.startsWith(dg))return Rg(e.slice(2));if(e.startsWith(fg))return Bg(e.slice(2))}}function Gg(e,t){if(!(e instanceof Error)||e.name!==`DevalueError`)return e instanceof Error?e:Error(String(e));let{path:n,value:r}=e,i=n?` (at ${n})`:``,a=e.message;return typeof r==`function`?a=`Cannot save a function`:yg(r)&&/non-POJO/.test(e.message)?a=`Cannot save an instance of class \"${Object.getPrototypeOf(r)?.constructor?.name??`?`}\", which is not registered (see Story.registerClass)`:typeof r==`symbol`?a=`Cannot save a unique symbol (only Symbol.for() symbols)`:/symbolic keys/.test(e.message)?a=`Cannot save an object with symbol keys`:/__proto__/.test(e.message)&&(a=`Cannot save a property named \"__proto__\"`),TypeError(`spindle: ${a}${i}`)}function Kg(e){try{return Wh(e,jg())}catch(t){throw Gg(t,e)}}function qg(e){return Hh(e,Ug)}var Jg=class extends Error{constructor(){super(`This save was made by an incompatible version of Spindle`),this.name=`IncompatibleSaveError`}},Yg={};function Xg(e){if(typeof e!=`number`||!Number.isInteger(e)||e<1||e>1)throw new Jg}function Zg(e,t){Xg(e);let n=t;for(let t=e;t<1;t++){let e=Yg[t];if(!e)throw new Jg;n=e(n)}return n}var Qg=e=>e&&new Map(Object.entries(e));function $g(e){if(!(e instanceof TypeError))return e;let t=e.message.replace(/\\(at \\.variables(?=[.[]|\\))/,`(at $`).replace(/\\(at \\.history\\[(\\d+)\\]\\.variables(.*)\\)$/,(e,t,n)=>`(at $${n} in history moment ${t})`).replace(/\\(at \\$\\.?/,`(at $`);return t===e.message?e:TypeError(t)}function e_(e){try{return{formatVersion:1,data:Kg({...e,visitCounts:Qg(e.visitCounts),renderCounts:Qg(e.renderCounts)})}}catch(e){throw $g(e)}}var t_=()=>Error(`Invalid save data`);function n_(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function r_(e){return e==null?!0:n_(e)&&typeof e.seed==`string`&&typeof e.pull==`number`&&Number.isInteger(e.pull)&&e.pull>=0}var i_=e=>n_(e)&&typeof e.passage==`string`&&n_(e.variables)&&typeof e.timestamp==`number`&&r_(e.prng),a_=e=>e===void 0||Array.isArray(e)&&Array.from(e).every(e=>n_(e)&&typeof e.condition==`string`&&n_(e.options)),o_=e=>e===void 0||e instanceof Map&&[...e.keys()].every(e=>typeof e==`string`);function s_(e){if(!n_(e)||typeof e.passage!=`string`||!n_(e.variables))return!1;let{history:t,historyIndex:n}=e;return!Array.isArray(t)||t.length===0||!Array.from(t).every(i_)||typeof n!=`number`||!Number.isInteger(n)||n<0||n>=t.length||t[n].passage!==e.passage?!1:o_(e.visitCounts)&&o_(e.renderCounts)&&r_(e.prng)&&a_(e.watchers)&&(e.interfaceWatchers===void 0||typeof e.interfaceWatchers==`boolean`)}var c_=e=>e instanceof Map?gs(Object.fromEntries(e)):void 0;function l_(e){if(typeof e!=`object`||!e)throw t_();let{formatVersion:t,data:n}=e;if(Xg(t),typeof n!=`string`)throw t_();let r=qg(Zg(t,n));if(!s_(r))throw t_();let i={...r,visitCounts:c_(r.visitCounts),renderCounts:c_(r.renderCounts)};return i.visitCounts===void 0&&delete i.visitCounts,i.renderCounts===void 0&&delete i.renderCounts,i}var u_=`Invalid save file format`;function d_(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var f_=[`id`,`passage`,`ifid`,`playthroughId`,`createdAt`,`updatedAt`,`title`];function p_(e){let t=console.warn;console.warn=()=>{};try{l_(e)}finally{console.warn=t}}function m_(e){if(!d_(e))throw Error(u_);if(!G(e,`formatVersion`))throw e.version===1?new Jg:Error(u_);if(Xg(e.formatVersion),typeof e.ifid!=`string`)throw Error(u_);let t=e.save;if(!d_(t)||!d_(t.meta))throw Error(u_);let n=t.meta;if(f_.some(e=>typeof n[e]!=`string`))throw Error(u_);try{p_(t.payload)}catch(e){throw e instanceof Jg?e:Error(u_)}}function h_(e){try{return m_(e),!0}catch{return!1}}function g_(e){return JSON.stringify(e).length}function __(e){return{saves:e(`saves`,{ifid:e=>e.meta.ifid,playthroughId:e=>e.meta.playthroughId}),playthroughs:e(`playthroughs`,{ifid:e=>e.ifid}),meta:e(`meta`,{})}}var v_={autosave:`autosave.`,slot:`slot.`,slotIndex:`slotIndex.`,playthroughCount:`playthroughCount.`,currentPlaythrough:`currentPlaythroughId.`};function y_(e,t){let{slot:n,...r}=v_;return Object.values(r).some(n=>e===n+t)||e.startsWith(n)&&e.endsWith(`.${t}`)}function b_(e,{saves:t,playthroughs:n,meta:r},i){async function a(e,t,n,r){let i=(await e.find(n,r)).map(t);for(let t of i)await e.delete(t);return i}async function o(e){for(let t of await r.keys())e(t)&&await r.delete(t)}let s=e=>e.meta.id,c=e=>e.id;return{type:e,putSave:e=>t.put(e.meta.id,e),getSave:e=>t.get(e),deleteSave:e=>t.delete(e),getSavesByIfid:e=>t.find(`ifid`,e),deleteSavesByIfid:async e=>{await a(t,s,`ifid`,e)},deleteSavesByPlaythrough:e=>a(t,s,`playthroughId`,e),putPlaythrough:e=>n.put(e.id,e),getPlaythroughsByIfid:e=>n.find(`ifid`,e),deletePlaythroughsByIfid:async e=>{await a(n,c,`ifid`,e)},deletePlaythroughById:e=>n.delete(e),getMeta:e=>r.get(e),setMeta:(e,t)=>r.put(e,t),deleteMeta:e=>r.delete(e),deleteMetaByPrefix:e=>o(t=>t.startsWith(e)),deleteMetaByIfid:e=>o(t=>y_(t,e)),getAllMetaKeys:()=>r.keys(),destroy:i}}function x_(){let e=e=>structuredClone(e),t=[];function n(n,r){let i=new Map;return t.push(i),{get:async t=>e(i.get(t)),put:async(t,n)=>{i.set(t,e(n))},delete:async e=>{i.delete(e)},find:async(t,n)=>[...i.values()].filter(e=>r[t](e)===n).map(e),keys:async()=>[...i.keys()]}}return b_(`memory`,__(n),async()=>{for(let e of t)e.clear()})}var S_={saves:`spindle.save.`,playthroughs:`spindle.pt.`,meta:`spindle.meta.`},C_={\"saves.ifid\":`spindle.idx.saves.`,\"saves.playthroughId\":`spindle.idx.saves-pt.`,\"playthroughs.ifid\":`spindle.idx.pt.`};function w_(e){let t=localStorage.getItem(e);if(t!==null)try{return JSON.parse(t)}catch{return}}function T_(e,t){localStorage.setItem(e,JSON.stringify(t))}function E_(e){localStorage.removeItem(e)}function D_(e){return w_(e)??[]}function O_(e,t){let n=D_(e);n.includes(t)||(n.push(t),T_(e,n))}function k_(e,t){let n=D_(e).filter(e=>e!==t);n.length>0?T_(e,n):E_(e)}var A_=e=>Object.keys(localStorage).filter(t=>t.startsWith(e));function j_(){function e(e,t){let n=S_[e],r=Object.entries(t).map(([t,n])=>({field:t,read:n,prefix:C_[`${e}.${t}`]})),i=e=>r.map(t=>`${t.prefix}${t.read(e)}`);return{get:async e=>w_(`${n}${e}`),async put(e,t){let r=w_(`${n}${e}`),a=i(t);if(r!==void 0)for(let t of i(r))a.includes(t)||k_(t,e);T_(`${n}${e}`,t);for(let t of a)O_(t,e)},async delete(e){let t=w_(`${n}${e}`);if(t!==void 0)for(let n of i(t))k_(n,e);E_(`${n}${e}`)},async find(e,t){let i=r.find(t=>t.field===e),a=[];for(let e of D_(`${i.prefix}${t}`)){let t=w_(`${n}${e}`);t!==void 0&&a.push(t)}return a},keys:async()=>A_(n).map(e=>e.slice(n.length))}}return b_(`localstorage`,__(e),async()=>{for(let e of A_(`spindle.`))E_(e)})}var M_=`spindle`,N_=1,P_={saves:{keyPath:`meta.id`,indexes:{ifid:`meta.ifid`,playthroughId:`meta.playthroughId`}},playthroughs:{keyPath:`id`,indexes:{ifid:`ifid`}},meta:{keyPath:`key`,indexes:{}}};function F_(){let e=null;function t(){return e||(e=new Promise((t,n)=>{let r=indexedDB.open(M_,N_);r.onupgradeneeded=()=>{let e=r.result;for(let[t,{keyPath:n,indexes:r}]of Object.entries(P_)){if(e.objectStoreNames.contains(t))continue;let i=e.createObjectStore(t,{keyPath:n});for(let[e,t]of Object.entries(r))i.createIndex(e,t,{unique:!1})}},r.onsuccess=()=>{let n=r.result;n.onversionchange=()=>{n.close(),e=null},t(n)},r.onerror=()=>n(r.error)}),e)}function n(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)})}function r(e){let r=e===`meta`,i=async(r,i)=>{let a=(await t()).transaction(e,r),o=n(i(a.objectStore(e)));if(r===`readonly`)return o;let s=new Promise((e,t)=>{a.oncomplete=()=>e(),a.onabort=()=>t(a.error??new DOMException(`Transaction aborted`,`AbortError`))}),[c]=await Promise.all([o,s]);return c};return{async get(e){let t=await i(`readonly`,t=>t.get(e));return r?t?.value:t},async put(e,t){await i(`readwrite`,n=>n.put(r?{key:e,value:t}:t))},async delete(e){await i(`readwrite`,t=>t.delete(e))},async find(e,t){return await i(`readonly`,n=>n.index(e).getAll(t))??[]},keys:async()=>await i(`readonly`,e=>e.getAllKeys())}}return b_(`indexeddb`,__(r),async()=>{(await t()).close(),e=null,await new Promise((e,t)=>{let n=indexedDB.deleteDatabase(M_);n.onsuccess=()=>e(),n.onerror=()=>t(n.error),n.onblocked=()=>t(Error(`Cannot clear the saved data: another tab or window of this site still has it open. Close the other tabs and try again.`))})})}var I_=null;async function L_(){try{if(typeof indexedDB<`u`)return await new Promise((e,t)=>{let n=indexedDB.open(`__spindle_probe__`,1);n.onsuccess=()=>{n.result.close(),indexedDB.deleteDatabase(`__spindle_probe__`),e()},n.onerror=()=>t(n.error)}),F_()}catch{}try{if(typeof localStorage<`u`){let e=`__spindle_probe__`;localStorage.setItem(e,`1`);let t=localStorage.getItem(e);if(localStorage.removeItem(e),t===`1`)return j_()}}catch{}return x_()}var R_=null;function Z(){if(I_)return Promise.resolve(I_);if(!R_){let e=L_().then(t=>(R_===e&&(I_=t),t));R_=e}return R_}function z_(){I_=null,R_=null}function B_(){return I_?.type??`memory`}function V_(e,t){let n=e;for(let e of t){if(n==null||e in Object.prototype&&!G(Object(n),e))return;let t=n;if(n=t[e],n===void 0&&Mt(t)&&(t instanceof Map||t instanceof Set)){let r=Lt(t);r&&G(r,e)&&(n=r[e])}}return n}var H_=e=>e===`length`||/^(0|[1-9]\\d*)$/.test(e),U_=Zh;function W_(e){let t=Array.isArray(e)?Array(e.length):Object.create(Object.getPrototypeOf(e));for(let n of Object.keys(e))Object.defineProperty(t,n,{value:e[n],enumerable:!0,writable:!0,configurable:!0});return t}function G_(e,t,n,r={}){let i=Y_(e,t,r.createMissing??!1);i[t[t.length-1]]=n}function K_(e,t){let n=t[t.length-1];q_(t);let r=e;for(let e of t.slice(0,-1)){if(typeof r!=`object`||!r||!G(r,e))return;r=r[e]}if(typeof r!=`object`||!r||!G(r,n))return;let i=Y_(e,t,!1);if(Array.isArray(i)&&Mt(i)&&t.length>1){let r=zn(i).slice();delete r[Number(n)];let a=Y_(e,t.slice(0,-1),!1);a[t[t.length-2]]=r;return}delete i[n]}function q_(e){if(e.includes(`__proto__`))throw TypeError(`spindle: Cannot use \"__proto__\" in a variable path (\"${e.join(`.`)}\")`)}function J_(e,t,n,r,i){if(i&&ug(e)!==void 0)return;let a=U_(e)??(Array.isArray(e)&&!H_(t)?`an array`:``);if(a)throw TypeError(`spindle: Cannot set property \"${t}\" on ${a} (at \"${n.slice(0,r).join(`.`)}\")`)}function Y_(e,t,n){q_(t);let r=Mt(e),i=e;for(let e=0;e<t.length-1;e++){let a=t[e];J_(i,a,t,e,!r);let o=G(i,a)?i[a]:void 0;if(typeof o!=`object`||!o){if(!n)throw TypeError(`spindle: Cannot set property \"${t[e+1]}\" on ${o===null?`null`:typeof o} (at \"${t.slice(0,e+1).join(`.`)}\")`);o={},i[a]=o}else r&&!Mt(o)&&!U_(o)&&(o=W_(o),i[a]=o);i=o}return J_(i,t[t.length-1],t,t.length-1,!r),i}function X_(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function Z_(e,t,n,r){if(n(t),ug(e)===void 0)return t;Object.setPrototypeOf(t,Object.getPrototypeOf(e));for(let n of eg(e))ss(t,n,r(n));return t}function Q_(e,t={}){let n=t.seen??new Map,r=(e,t)=>(n.set(e,t),t);function i(e,t){for(let n of Object.keys(e))ss(t,n,c(e[n]));for(let n of Object.getOwnPropertySymbols(e))Object.prototype.propertyIsEnumerable.call(e,n)&&(t[n]=c(e[n]));return t}function a(e){if(e instanceof Date)return s(e,new Date(Date.prototype.getTime.call(e)));if(e instanceof RegExp){let t=new RegExp(Reflect.get(RegExp.prototype,`source`,e),Reflect.get(RegExp.prototype,`flags`,e));return t.lastIndex=e.lastIndex,s(e,t)}if(e instanceof ArrayBuffer)return r(e,e.slice(0));if(ArrayBuffer.isView(e)){let t=c(e.buffer);if(e instanceof DataView)return r(e,new DataView(t,e.byteOffset,e.byteLength));let n=e.constructor,i=e.length;return r(e,new n(t,e.byteOffset,i))}if(e instanceof URL)return r(e,new URL(e.href));if(e instanceof URLSearchParams)return r(e,new URLSearchParams(e));if(Yh(e))return r(e,Object(e.valueOf()));if(Jh(e))return e;if(e instanceof Error){let t=r(e,Object.create(Object.getPrototypeOf(e)));for(let n of[...Qh,`stack`])if(G(e,n)){let r=e[n];Object.defineProperty(t,n,{value:o(c(r),r),writable:!0,configurable:!0})}return i(e,t)}}function o(e,n){let r=t.settle;return r&&iv(e)&&iv(n)?r(e,n):e}let s=(e,t)=>Z_(e,t,t=>r(e,t),t=>c(e[t]));function c(e){if(typeof e!=`object`||!e)return e;let l=e;if(n.has(l))return n.get(l);if(Array.isArray(e)){let t=s(l,Array(e.length));for(let n=0;n<e.length;n++)n in e&&(t[n]=c(e[n]));return t}if(e instanceof Map){let t=s(l,new Map);for(let[n,r]of tg(e))Map.prototype.set.call(t,o(c(n),n),c(r));return t}if(e instanceof Set){let t=s(l,new Set);for(let n of ng(e))Set.prototype.add.call(t,o(c(n),n));return t}let u=a(l);if(u!==void 0)return u;let d=ug(l)!==void 0||X_(e);return!d&&t.keepUnregistered?e:i(l,r(l,d?Object.create(Object.getPrototypeOf(l)):{}))}return c(e)}function $_(e,t){return uv(e,t,ev())}function ev(){let e=new Map;return(t,n)=>{let r=e.get(t);if(r?.has(n))return!0;r?r.add(n):e.set(t,new Set([n]))}}function tv(e=new Map,t=new Map){let n=[],r=((r,i)=>{let a=e.get(r);if(a!==void 0)return a===i;if(t.has(i))return!1;e.set(r,i),t.set(i,r),n.push([r,i])});return r.strict=!0,r.added=n,r}function nv(e,t){return uv(e,t,tv())}function rv(e,t){if(!iv(e)||!iv(t))return t;let n=new Map,r=new Map,i=e=>iv(e)?Q_(e,{keepUnregistered:!0,seen:n}):e;function a(e,t){let i=tv(r,n);if(uv(e,t,i))return!0;for(let[e,t]of i.added)r.delete(e),n.delete(t);return!1}function o(e,t){if(!iv(t))return t;let r=n.get(t);if(r!==void 0)return r;if(!iv(e))return i(t);if(a(e,t))return e;let s=e,c=t,l=e=>o(G(s,e)?s[e]:void 0,c[e]),u=e=>Z_(t,e,e=>n.set(t,e),l);if(t instanceof Map&&e instanceof Map){let n=u(new Map);for(let[r,a]of tg(t))Map.prototype.set.call(n,i(r),o(ig(e,r),a));return n}if(Array.isArray(t)&&Array.isArray(e)){let n=u(Array(t.length));for(let r=0;r<t.length;r++)r in t&&(n[r]=o(e[r],t[r]));return n}if(fv(e,t,!1)){let e=Object.create(Object.getPrototypeOf(t));n.set(t,e);for(let t of Object.keys(c))ss(e,t,l(t));return e}return i(t)}return o(e,t)}var iv=e=>typeof e==`object`&&!!e;function av(e,t){let n=ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e),r=ArrayBuffer.isView(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):new Uint8Array(t);if(n.length!==r.length)return!1;for(let e=0;e<n.length;e++)if(n[e]!==r[e])return!1;return!0}function ov(e,t,n){if(e instanceof Date){let r=Date.prototype.getTime;return Object.is(r.call(e),r.call(t))&&lv(e,t,n)}if(e instanceof RegExp){let r=RegExp.prototype.toString;return r.call(e)===r.call(t)&&e.lastIndex===t.lastIndex&&lv(e,t,n)}if(ArrayBuffer.isView(e)){let r=t;return e.byteOffset===r.byteOffset&&e.byteLength===r.byteLength&&uv(e.buffer,r.buffer,n)}if(e instanceof ArrayBuffer)return av(e,t);if(e instanceof URL||e instanceof URLSearchParams)return String(e)===String(t);if(Yh(e))return Object.is(e.valueOf(),t.valueOf());if(Jh(e))return String(e)===String(t);if(e instanceof Error)return Qh.every(r=>G(e,r)===G(t,r)&&uv(e[r],t[r],n))&&sv(e,t,n)}function sv(e,t,n,r=Object.keys){let i=e,a=t,o=r(i);if(o.length!==r(a).length)return!1;for(let e of o)if(!G(a,e)||!uv(i[e],a[e],n))return!1;return!0}var cv=new Set([Array.prototype,Map.prototype,Set.prototype,Date.prototype,RegExp.prototype]);function lv(e,t,n){return cv.has(Object.getPrototypeOf(e))||sv(e,t,n,eg)}function uv(e,t,n){if(Object.is(e,t)&&!(n.strict&&iv(e)))return!0;if(e===null||t===null||typeof e!=`object`||typeof t!=`object`||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;let r=n(e,t);if(r!==void 0)return r;if(e instanceof Map||e instanceof Set){let r=t;if(rg(e)!==rg(r))return!1;let i=e instanceof Map?tg(e):ng(e),a=r instanceof Map?tg(r):ng(r);for(let e=i.next(),t=a.next();!e.done;e=i.next(),t=a.next())if(!uv(e.value,t.value,n))return!1;return lv(e,t,n)}let i=ov(e,t,n);if(i!==void 0)return i;if(Array.isArray(e)){let r=t;if(e.length!==r.length)return!1;for(let t=0;t<e.length;t++)if(t in e!=t in r||!uv(e[t],r[t],n))return!1;return lv(e,t,n)}return sv(e,t,n)}function dv(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&!Xh(e)}function fv(e,t,n){return n&&(Array.isArray(e)||Array.isArray(t))?Array.isArray(e)&&Array.isArray(t)&&Object.getPrototypeOf(e)===Object.getPrototypeOf(t):dv(e)&&dv(t)&&Object.getPrototypeOf(e)===Object.getPrototypeOf(t)}function pv(e,t,n){let r=[],i=(e,t,i)=>{Object.is(t,i)||(fv(t,i,n)?r.push({key:e,kind:`nested`,before:t,after:i}):$_(t,i)||r.push({key:e,kind:`changed`,after:i}))};if(Array.isArray(t)){let n=e,a=t;for(let e=0;e<Math.min(n.length,a.length);e++){let t=String(e);e in n&&e in a?i(t,n[e],a[e]):e in n?r.push({key:t,kind:`deleted`,hole:!0}):e in a&&r.push({key:t,kind:`added`,after:a[e]})}let o=n.length;for(let e=n.length;e<a.length;e++){if(!(e in a))continue;let t=e-o;r.push({key:String(e),kind:`added`,after:a[e],...t?{gap:t}:{}}),o=e+1}for(let e=a.length;e<n.length;e++)r.push({key:String(e),kind:`deleted`});return a.length>o&&r.push({key:`length`,kind:`holes`,after:a.length-o}),r}for(let n of Object.keys(t))G(e,n)?i(n,e[n],t[n]):r.push({key:n,kind:`added`,after:t[n]});for(let n of Object.keys(e))G(t,n)||r.push({key:n,kind:`deleted`});return r}function mv(e,t,n=!1){let r=[],i=new Set,a=new WeakMap,o=0;return(function e(t,s,c){if(i.has(s)){o++;return}if(a.get(s)?.has(t))return;i.add(s);let l=r.length,u=o;for(let i of pv(t,s,n)){let n=[...c,i.key];i.kind===`nested`?e(i.before,i.after,n):r.push(i.kind===`deleted`?{path:n,deleted:!0,...i.hole?{hole:!0}:{}}:{path:n,deleted:!1,value:i.after,...i.kind===`added`&&Array.isArray(s)&&Number(i.key)>=t.length?{appended:!0,...i.gap?{gap:i.gap}:{}}:{}})}if(r.length===l&&o===u){let e=a.get(s)??new Set;e.add(t),a.set(s,e)}i.delete(s)})(e,t,[]),r}var hv=e=>JSON.stringify(e);function gv(e,t){for(let n=1;n<=e.length;n++)if(t.has(hv(e.slice(0,n))))return!0;return!1}var _v=(e,t)=>`\\0${e}${t}`,vv=e=>e.startsWith(`\\0`);function yv(e){let t=[];if(e instanceof Map){let n=0;for(let[r,i]of tg(e))t.push([_v(`k`,n),r],[_v(`v`,n),i]),n++}else if(e instanceof Set){let n=0;for(let r of ng(e))t.push([_v(`s`,n++),r])}else if(e instanceof Error)for(let n of[`cause`,`errors`])G(e,n)&&t.push([_v(n===`cause`?`c`:`e`,0),e[n]]);else if(ArrayBuffer.isView(e))t.push([_v(`b`,0),e.buffer]);else return;return t}function bv(e,t){let n=e,r=0;for(let e=0;e<t.length;e++)if(vv(t[e])){if(n=V_(n,t.slice(r,e)),!iv(n))return;n=yv(n)?.find(([n])=>n===t[e])?.[1],r=e+1}return r===t.length?n:V_(n,t.slice(r))}function xv(e,t,n){let r=bv(e,t.slice(0,-1)),i=/^\\0v(\\d+)$/.exec(t[t.length-1]);if(!(r instanceof Map)||!i)return!1;let a=[...tg(r)][Number(i[1])];return a?(ag(r,a[0],n),!0):!1}function Sv(e){return e instanceof Map||e instanceof Set||e instanceof Date||e instanceof RegExp?eg(e):[]}function Cv(e,t){return Object.getPrototypeOf(e)===Object.getPrototypeOf(t)&&(Sv(e).length>0||Sv(t).length>0)}function wv(e,t=new Set,n=!1){let r=new Map,i=[];function a(e,t){let a=r.get(e);if(a){a.push(t);return}r.set(e,[t]),dv(e)||Array.isArray(e)?o(e,t):(o(e,t,Sv(e)),n&&yv(e)&&i.push([e,t]))}function o(e,n,r=Object.keys(e)){for(let i of r){let r=e[i];if(!iv(r))continue;let o=[...n,i];t.has(hv(o))||a(r,o)}}o(e,[]);for(let[e,t]of i)for(let[n,r]of yv(e))iv(r)&&a(r,[...t,n]);return r}function Tv(e,t,n){return new Map([...wv(e,t,n)].map(([e,t])=>[e,t[0]]))}function Ev(e){return[...wv(e,void 0,!0).values()].filter(e=>e.length>1)}function Dv(e,t,n,r,i){let a=[],o=yv(e),s=yv(t);if(o&&s){if(Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;if(e instanceof Map||e instanceof Set){let n=rg(t);if(rg(e)!==n)return!1}let n=new Map(s);for(let[e,t]of o)n.has(e)&&a.push([e,t,n.get(e)])}let c=fv(e,t,!0)?Object.keys(t):Cv(e,t)?Sv(t):[];for(let n of c)G(e,n)&&a.push([n,e[n],t[n]]);return a.some(([e,t,a])=>{if(!iv(t)||!iv(a))return!1;let o=[...n,e],s=i.get(a);return hv(r.get(t))!==hv(s)||hv(s)===hv(o)&&Dv(t,a,o,r,i)})}function Ov(e,t){let n=Tv(e,void 0,!0),r=Tv(t,void 0,!0),i=[];return(function e(t,a,o){for(let s of Array.isArray(a)||dv(a)?Object.keys(a):Sv(a)){if(!G(t,s))continue;let c=t[s],l=a[s];if(!iv(c)||!iv(l))continue;let u=[...o,s],d=n.get(c),f=r.get(l),p=hv(u);hv(d)===hv(f)?hv(f)===p&&yv(c)&&Dv(c,l,u,n,r)&&i.push({path:u,deleted:!1,value:l,alias:!0}):i.push({path:u,deleted:!1,value:l,alias:!0}),((dv(c)||Array.isArray(c))&&fv(c,l,!0)||Cv(c,l))&&hv(f)===p&&hv(d)===p&&e(c,l,u)}})(e,t,[]),i}function kv(e,t,n=!1){let r=mv(e,t,n),i=new Set(r.map(e=>hv(e.path))),a=[];for(let n of Ov(e,t))gv(n.path,i)||(i.add(hv(n.path)),a.push(n));return[...a,...r]}function Av(e,t){return Tv(e,new Set(t.map(e=>hv(e.path))),!0)}function jv(e,t){return new class extends Map{has(n){if(super.has(n))return!0;let r=e.get(n);if(!r)return!1;let i=bv(t,r);return iv(i)&&(Array.isArray(i)?Array.isArray(n):Object.getPrototypeOf(i)===Object.getPrototypeOf(n))?(super.set(n,i),!0):!1}}}function Mv(e,t){let n=V_(e,t.path.slice(0,-1));if(typeof n!=`object`||!n)return t.deleted;let r=t.path[t.path.length-1];return G(n,r)?!t.deleted&&$_(n[r],t.value):t.deleted}function Nv(e,t,n){t.some(vv)?xv(e,t,n):G_(e,t,n)}function Pv(e,t){let n=e;t.deleted?K_(n,t.path):G_(n,t.path,t.value)}var Fv=new Set([`storyinit`,`beforerestart`,`actionsChanged`,`variableChanged`,`beforesave`,`aftersave`,`beforeload`,`afterload`,`beforenavigate`,`afternavigate`,`passagerender`,`dialogrender`]),Iv=new Map;function Lv(e,t){if(!Fv.has(e))throw Error(`spindle: Unknown event \"${e}\".`);let n=Iv.get(e);return n||(n=new Set,Iv.set(e,n)),n.add(t),()=>{n.delete(t)}}function Rv(e,t){let n=Iv.get(e);if(n)for(let e of[...n])t(e)}function zv(e,...t){Rv(e,e=>e(...t))}function Bv(e,...t){Rv(e,n=>{try{n(...t)}catch(t){console.error(`spindle: Error in ${e} handler:`,t)}})}var Vv=null,Hv=null;function Uv(e){Vv=e}function Wv(e){Hv=e}function Gv(e){return Dl(()=>Kv(e))}function Kv(e){if(Hv)try{let t=Function(`passage`,`variables`,Hv)(e.passage,e.variables);if(typeof t==`string`&&t.trim())return t.trim()}catch{}if(Vv)try{let t=Vv(e);if(typeof t==`string`&&t.trim())return t.trim()}catch{}let t=new Date().toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`});return`${e.passage} - ${t}`}var qv=`spindle-saves`,Jv=Promise.resolve();function Yv(e){let t=Jv.then(()=>Dy(qv,e));return Jv=t.catch(()=>{}),t}function Xv(e){return(...t)=>Yv(()=>e(...t))}var Zv=e=>Xv(async t=>e(await(await Z()).getSave(t))),Qv=e=>Xv(async(t,n)=>e(await jy(t,n))),$v=Xv(ey);async function ey(e,t=bt()){let n=await Z();return await Dy(`spindle-playthrough-count:${e}`,async()=>{let r=await ry(e),i={id:t,ifid:e,createdAt:new Date().toISOString(),label:`Playthrough ${r}`};await n.putPlaythrough(i),await n.setMeta(ny(e),r)}),await n.setMeta(iy(e),t),ib(e,t),t}var ty=/^Playthrough (\\d+)$/;function ny(e){return`${v_.playthroughCount}${e}`}async function ry(e){let t=await Z(),n=await t.getMeta(ny(e))??0;for(let r of await t.getPlaythroughsByIfid(e)){let e=ty.exec(r.label);e&&(n=Math.max(n,Number(e[1])))}return n+1}function iy(e){return`${v_.currentPlaythrough}${e}`}var ay=Xv(oy);async function oy(e,t){let n=await Z();await sy(e,t,new Date().toISOString());let r=iy(e);await n.getMeta(r)!==t&&await n.setMeta(r,t),ib(e,t)}async function sy(e,t,n){let r=await Z();(await r.getPlaythroughsByIfid(e)).some(e=>e.id===t)||await r.putPlaythrough({id:t,ifid:e,createdAt:n,label:`Imported`})}function cy(e){return Yv(async()=>{let t=await Z(),n=ab(e),r=n!==void 0&&(await t.getPlaythroughsByIfid(e)).some(e=>e.id===n)?n:await t.getMeta(iy(e))??await ey(e);return ib(e,r),{id:r,knownSaves:await Jy(e)}})}function ly(e,t,n,r){try{let i=n();return Dl(()=>zv(`beforesave`,e,t)),r(i()).then(t=>(Dl(()=>zv(`aftersave`,e)),t))}catch(e){return Promise.reject(e)}}function uy(e,t){let n=e_(t);return{meta:{...e,estimatedBytes:g_(n)},payload:n}}var dy=Xv(fy);async function fy(e,t,n,r={}){let i=await t;if(!i)throw Error(`No playthrough`);let a=new Date().toISOString(),o=uy({id:bt(),ifid:e,playthroughId:i,createdAt:a,updatedAt:a,title:Gv(n),passage:n.passage,custom:r},n);return await(await Z()).putSave(o),o}var py=Xv(my);async function my(e,t,n,r){let i=await r,a=await Z(),o=await a.getSave(e);if(!o)return;let s=uy({...o.meta,...i?{playthroughId:i}:{},updatedAt:new Date().toISOString(),title:o.meta.userTitle===!0?o.meta.title:Gv(t),passage:t.passage,...n==null?{}:{custom:{...o.meta.custom,...n}}},t);return await a.putSave(s),By(s.meta.ifid),s}var hy=e=>e&&l_(e.payload),gy=e=>l_(e);Zv(hy);var _y=Zv(e=>e);function vy(e){return Yv(async()=>{let t=await Z(),n=await t.getSave(e);await t.deleteSave(e),n&&await Py(n.meta.ifid,t=>t===e)})}function yy(e,t){return Yv(async()=>{let n=await Z(),r=await n.getSave(e);if(!r)return;let i={...r,meta:{...r.meta,title:t,userTitle:!0,updatedAt:new Date().toISOString()}};await n.putSave(i)})}var by=Xv(async function(e){let t=await Z(),[n,r]=await Promise.all([t.getSavesByIfid(e),t.getPlaythroughsByIfid(e)]),i=new Map;for(let e of r)i.set(e.id,e);let a=new Map;for(let e of n){let t=e.meta.playthroughId,n=a.get(t);n?n.push(e):a.set(t,[e])}for(let e of a.values())e.sort((e,t)=>new Date(t.meta.updatedAt).getTime()-new Date(e.meta.updatedAt).getTime());let o=[],s=[...i.values()].sort((e,t)=>new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime());for(let e of s){let t=a.get(e.id)??[];o.push({playthrough:e,saves:t})}for(let[t,n]of a)i.has(t)||o.push({playthrough:{id:t,ifid:e,createdAt:n[0]?.meta.createdAt??new Date().toISOString(),label:`Unknown Playthrough`},saves:n});return o}),xy=v_.autosave,Sy=v_.slot,Cy=v_.slotIndex;function wy(e){return e!=null&&e!==``}function Ty(e,t){return wy(t)?`${Sy}${t}.${e}`:`${xy}${e}`}var Ey=e=>`${Cy}${e}`;async function Dy(e,t){let n;try{n=navigator.locks}catch{}if(!n)return t();let r=!1;try{return await n.request(e,()=>(r=!0,t()))}catch(e){if(r)throw e;return t()}}async function Oy(e,t){let n=await Z();await Dy(`spindle-slot-index:${e}`,async()=>{let r=await n.getMeta(Ey(e))??[],i=t(r);i!==r&&await n.setMeta(Ey(e),i)})}async function ky(e){return[void 0,...(await(await Z()).getMeta(Ey(e))??[]).filter(wy)]}async function Ay(e,t){return(await Z()).getMeta(Ty(e,t))}async function jy(e,t){let n=await Ay(e,t);return n?(await Z()).getSave(n):void 0}async function My(e,t,n){await(await Z()).setMeta(Ty(e,t),n),wy(t)&&await Oy(e,e=>e.includes(t)?e:[...e,t]),By(e)}async function Ny(e,t){await(await Z()).deleteMeta(Ty(e,t)),wy(t)&&await Oy(e,e=>e.filter(e=>e!==t)),By(e)}async function Py(e,t){for(let n of await ky(e)){let r=await Ay(e,n);r&&t(r)&&await Ny(e,n)}}var Fy=`spindle.slots`,Iy=`*`,Ly;function Ry(){if(Ly===void 0)try{Ly=new BroadcastChannel(Fy),Ly.unref?.()}catch{Ly=null}return Ly}var zy=new Set;function By(e){for(let t of[...zy])(e===Iy||t.ifid===e)&&t.onChange();try{Ry()?.postMessage(e)}catch{}}function Vy(e,t,n=!1){let r={ifid:e,onChange:t};n&&zy.add(r);let i=Ry(),a=n=>{(n.data===e||n.data===Iy)&&t()},o=()=>{document.visibilityState===`visible`&&t()},s=typeof document>`u`?void 0:document;return i?.addEventListener(`message`,a),s?.addEventListener(`visibilitychange`,o),()=>{zy.delete(r),i?.removeEventListener(`message`,a),s?.removeEventListener(`visibilitychange`,o)}}var Hy=e=>({isAutosave:!wy(e),...wy(e)?{slot:e}:{}});function Uy(e,t){return{slot:wy(t)?t:``,title:e.meta.title,passage:e.meta.passage,createdAt:e.meta.createdAt,updatedAt:e.meta.updatedAt,custom:e.meta.custom??{}}}function Wy(e,t,n,r,i){return Yv(async()=>{let a=await t,o=await Ay(e,r);if(o){let e=await my(o,n,i,a);if(e)return e}let s=await fy(e,a,n,{...Hy(r),...i});return await My(e,r,s.meta.id),s})}async function Gy(e,t){return await jy(e,t)!==void 0}Qv(hy);function Ky(e,t,n){return Yv(async()=>{let r=await jy(e,t);if(!r)return;let i=l_(r.payload);n?.(i);let{playthroughId:a}=r.meta;return a&&await oy(e,a),{payload:i,playthroughId:a}})}var qy=Xv(Jy);async function Jy(e){let t=Object.create(null);for(let n of await ky(e))await Gy(e,n)&&(t[n??``]=!0);return t}var Yy=Xv(Xy);async function Xy(e,t){let n=await jy(e,t);return n?Uy(n,t):null}var Zy=Xv(async e=>{let t=[];for(let n of await ky(e)){let r=await Xy(e,n);r&&t.push(r)}return t}),Qy=Xv(async(e,t)=>{let n=await Ay(e,t);n&&(await(await Z()).deleteSave(n),await Ny(e,t))}),$y=`spindle.session.`;function eb(e,t){let n=JSON.stringify(e_(t));try{sessionStorage.setItem(`${$y}${e}`,n)}catch(e){return{error:e}}}function tb(e){try{let t=sessionStorage.getItem(`${$y}${e}`);return t?l_(JSON.parse(t)):void 0}catch(t){t instanceof Jg&&(console.warn(`spindle: ${t.message}; the session was not restored.`),nb(e));return}}function nb(e){try{sessionStorage.removeItem(`${$y}${e}`)}catch{}}var rb=`${$y}playthrough.`;function ib(e,t){try{sessionStorage.setItem(`${rb}${e}`,t)}catch{}}function ab(e){try{return sessionStorage.getItem(`${rb}${e}`)||void 0}catch{return}}function ob(e){if(e)return{formatVersion:1,ifid:e.meta.ifid,exportedAt:new Date().toISOString(),save:e}}var sb=Zv(ob);async function cb(e,t){if(m_(e),e.ifid!==t)throw Error(`Save is from a different story (expected IFID ${t}, got ${e.ifid})`);let n=Q_(e.save);return n.meta.id=bt(),n.meta.updatedAt=new Date().toISOString(),n.meta.ifid=t,await sy(t,n.meta.playthroughId,n.meta.createdAt),n}function lb(e,t){return Yv(async()=>{let n=await cb(e,t);return await(await Z()).putSave(n),n})}var ub=Qv(ob);function db(e,t,n){return Yv(async()=>{let r=await cb(e,t),{slot:i,...a}=r.meta.custom??{};r.meta.custom={...a,...Hy(n)};let o=await Z(),s=await Ay(t,n);return await o.putSave(r),await My(t,n,r.meta.id),s&&await o.deleteSave(s),Uy(r,n)})}var fb=Xv(async function(e){let t=await Z(),n=await t.getSavesByIfid(e),r=await t.getPlaythroughsByIfid(e),i=0;for(let e of n)if(e.meta.estimatedBytes!=null)i+=e.meta.estimatedBytes;else{let n=g_(e.payload);e.meta.estimatedBytes=n,await t.putSave(e),i+=n}return{saveCount:n.length,playthroughCount:r.length,totalBytes:i,backend:t.type}});function pb(e){return Yv(async()=>{let t=await Z();await t.deleteSavesByIfid(e),await t.deletePlaythroughsByIfid(e),await t.deleteMetaByIfid(e),nb(e),By(e)})}var mb=Xv(hb);async function hb(){await(await Z()).destroy(),z_();try{let e=[];for(let t=0;t<sessionStorage.length;t++){let n=sessionStorage.key(t);n?.startsWith(`spindle.session.`)&&e.push(n)}for(let t of e)sessionStorage.removeItem(t)}catch{}By(Iy)}function gb(e,t,n){return Yv(async()=>{let r=await Z(),i=await r.deleteSavesByPlaythrough(t);await r.deletePlaythroughById(t);let a=new Set(i);if(await Py(e,e=>a.has(e)),n&&await n.current===t)return await ey(e,n.id),!0;let o=iy(e);return await r.getMeta(o)===t&&await r.deleteMeta(o),!1})}var _b=null;function vb(){_b&&(ge(null,_b),_b.remove(),_b=null)}function yb(){vb();let e=Q.getState();if(!e.storyData)return;let t=e.storyData.passages.get(`StoryInit`);if(t){let e=$o(t.content);al(e,`StoryInit`);let n=document.createElement(`div`);n.style.display=`none`,document.body.appendChild(n),_b=n,ge(b(()=>eh(e),null),n),uS()}let n=e.storyData.passages.get(`SaveTitle`);n&&Wv(n.content)}function bb(e){yb();let t=e?WS(Q.getState().storyData,e):void 0;t!==void 0&&(console.warn(`spindle: discarding the saved session: the story no longer has the passage \"${t}\"`),e=void 0),e&&Q.getState().loadFromPayload(e),zv(`storyinit`),e||uS()}var xb=[`variables`,`temporary`,`transient`],Sb=[];function Cb(){return Sb[Sb.length-1]?.work}function wb(){let e=Q.getState(),t=Cb();return t?{...e,...t}:e}var Tb=e=>Q_(e,{keepUnregistered:!0});function Eb(e,t){let n=t?jv(t,e):new Map,r=(r,i)=>{let a=t?.get(i);if(!a||!Mt(r))return r;let o=zn(r);return a.some(vv)||G_(e,a,o),n.set(i,o),o};return e=>Q_(e,{keepUnregistered:!0,seen:n,settle:r})}var Db=e=>{let t=new Map;return n=>{let r=t.get(n);return r||(r=Eb(n,e?.(n)),t.set(n,r)),r}};function Ob(e){return nn(Tb(e),!0)}function kb(e,t=new Set){if(typeof e!=`object`||!e||t.has(e))return!0;if(ArrayBuffer.isView(e)||e instanceof ArrayBuffer||!Object.isFrozen(e))return!1;if(t.add(e),e instanceof Map){for(let[n,r]of tg(e))if(!kb(n,t)||!kb(r,t))return!1}else if(e instanceof Set){for(let n of ng(e))if(!kb(n,t))return!1}return Reflect.ownKeys(e).every(n=>{let r=Object.getOwnPropertyDescriptor(e,n);return!r||!(`value`in r)||kb(r.value,t)})}function Ab(e){return kb(e)?e:Ob(e)}function jb(e,t,n=Sb,r=Mb){let[i,a]=t.path;for(let o of n)for(let n of[o.work,o.base])try{Pv(n,t.deleted?t:{...t,value:r(n)(t.value)})}catch{let t=e[i][a];G(e[i],a)?n[i][a]=Tb(Mt(t)?zn(t):t):delete n[i][a]}}var Mb=e=>Eb(e),Nb=new Set(xb),Pb=new Ln({autoFreeze:!1}),Fb=!1;function Ib(e,t){let n=[],r=e;for(let e of t){if(!dv(r))break;let t=String(e);n.push(t),r=G(r,t)?r[t]:void 0}return n}function Lb(e,t){let n=V_(e,t.slice(0,-1)),r=t[t.length-1];return dv(n)&&G(n,r)?{path:t,deleted:!1,value:n[r]}:{path:t,deleted:!0}}function Rb(e,t,n){if(n.some(e=>e.path.length===1))return[...new Set([...Object.keys(e),...Object.keys(t)])].filter(n=>!G(e,n)||e[n]!==t[n]).map(e=>Lb(t,[e]));let r=new Set,i=[];for(let e of n){let n=Ib(t,e.path.slice(1)),a=JSON.stringify(n);r.has(a)||(r.add(a),i.push(Lb(t,n)))}return i}function zb(e){if(Fb){Fb=!1;return}if(Sb.length===0)return;Ub(Gb());let t=Sb[Sb.length-1],n={...Q.getState(),variables:t.work.variables,temporary:t.work.temporary,transient:t.work.transient},[r,i]=Pb.produceWithPatches(n,e),a=xb.flatMap(e=>{let t=i.filter(t=>t.path[0]===e);return t.length?Rb(n[e],r[e],t).map(t=>({...t,path:[e,...t.path]})):[]}),o=Av(Hb(t.work),a),s=Db(()=>o),c=(e,t)=>e.deleted?e:{...e,value:s(t)(e.value)};for(let e of a)Pv(t.work,c(e,t.work));return e=>{let i=e;for(let e of Object.keys(r)){let t=r[e];!Nb.has(e)&&t!==n[e]&&(i[e]=t)}let o=e;for(let e of a){let[n,r]=e.path;try{Pv(o,c(e,o))}catch{G(t.work[n],r)?o[n][r]=Tb(t.work[n][r]):delete o[n][r]}jb(o,e,Sb,s)}}}function Bb(e,t,n){let r=n.map(e=>hv(e.path).slice(0,-1));for(let[n,...i]of Ev(t)){let t=[n,...i].map(e=>hv(e).slice(0,-1));if(r.some(e=>t.some(t=>e.startsWith(t))))try{let t=bv(e,n);if(typeof t!=`object`||!t)continue;for(let n of i)Nv(e,n,t)}catch{}}}function Vb(e){let t=new Map;return{variables:Q_(e.variables,{keepUnregistered:!0,seen:t}),temporary:Q_(e.temporary,{keepUnregistered:!0,seen:t}),transient:Q_(e.transient,{keepUnregistered:!0,seen:t})}}var Hb=e=>({variables:e.variables,temporary:e.temporary,transient:e.transient});function Ub(e){let t=e.map(({scope:e,keepRunning:t})=>({scope:e,keepRunning:t,changes:Wb(e.base,e.work)})),n=t.filter(({changes:e})=>e.length>0);if(n.length===0)return;for(let{scope:e,keepRunning:t}of n)t&&(e.base=Vb(e.work));Fb=!0;try{Q.getState().updateVariables(r)}finally{Fb=!1}function r(e){t.forEach(({scope:n,changes:r},i)=>{let a=Av(n.work,r),o=Eb(e,a),s=t.slice(0,i).map(e=>e.scope),c=Db(()=>a),l=new Set;for(let t of r){let[r,i]=t.path,a=hv([r,i]);if(!l.has(a))try{if(t.deleted){Mv(e,t)||Pv(e,t);continue}let n=t.alias?o(t.value):void 0;if(t.alias?Object.is(V_(e,t.path),n):Mv(e,t))continue;Pv(e,{...t,value:t.alias?n:o(t.value)})}catch{e[r][i]=o(n.work[r][i]),l.add(a)}}Bb(e,n.work,r);for(let t of r)jb(e,t,s,c)})}}var Wb=(e,t)=>kv(e,t),Gb=()=>Sb.map(e=>({scope:e,keepRunning:!0}));function Kb(e){let t=Q.getState(),n=Hb(t),r=kv(e.base,n),i=Eb(e.work,Av(n,r));for(let t of r)try{Pv(e.work,t.deleted?t:{...t,value:i(t.value)})}catch{let[r,a]=t.path;G(n[r],a)?e.work[r][a]=i(n[r][a]):delete e.work[r][a]}e.base=Vb(t)}function qb(e){if(Sb.length===0)return e();Ub(Gb());let t=Sb.splice(0);try{return e()}finally{Sb.push(...t);for(let e of t)Kb(e)}}function Jb(e){Ub(Gb());let t=Av(Hb(Cb()??Q.getState()),[]),n=Yb(),r=Eb(n.work,t);try{e(n.work,r)}finally{Sb.pop()}Ub([...Gb(),{scope:n,keepRunning:!1}])}function Yb(){let e=Cb()??Q.getState(),t={work:Vb(e),base:Vb(e)};return Sb.push(t),t}function Xb(e,t,n){let r=us(Q_(t,{keepUnregistered:!0})),i=Yb();try{Ql(e,i.work.variables,i.work.temporary,r,i.work.transient)}finally{Sb.pop()}Ub([...Gb(),{scope:i,keepRunning:!1}]);let a=new Set(kv(t,r,!0).map(e=>e.path[0]));for(let e of Ev(r))if(e.some(e=>a.has(e[0])))for(let n of e)r[n[0]]!==t[n[0]]&&a.add(n[0]);for(let e of Object.keys(r))a.has(e)&&n(e,r[e]);for(let e of Object.keys(t))G(r,e)||n(e,void 0)}var Zb=[],Qb=!1,$b=[],ex=null,tx=null;function nx(e){let t=wb();try{return!!Zl(e,t.variables,t.temporary,{},t.transient)}catch{return!1}}function rx(e,t,n){let r=typeof t==`function`,i=r?void 0:t,a=r?t:void 0,o={name:i?.name,condition:e,callback:a,options:i,lastResult:nx(e),priority:i?.priority??0,macroKey:n};return Zb.push(o),Zb.sort((e,t)=>t.priority-e.priority),()=>{Zb=Zb.filter(e=>e!==o)}}function ix(e,t){return rx(e,t)}function ax(e,t){let n=Object.fromEntries(Object.entries(t).sort(([e],[t])=>e<t?-1:1)),r=JSON.stringify([e,n]);Zb.some(e=>e.macroKey===r)||rx(e,t,r)}function ox(){return Zb.filter(e=>e.macroKey!==void 0&&e.options).map(e=>({condition:e.condition,options:{...e.options}}))}var sx=new Set,cx=0;function lx(e,t){let n={condition:e,options:t};return sx.add(n),()=>{sx.delete(n)}}function ux(){return cx++,()=>{cx--}}function dx(){return cx>0}function fx(e,t){Zb=Zb.filter(e=>e.macroKey===void 0);for(let{condition:t,options:n}of e)ax(t,n);if(t===!1)for(let{condition:e,options:t}of sx)ax(e,t)}function px(e){Zb=Zb.filter(t=>t.name!==e)}function mx(e){let{callback:t,options:n}=e;if(t){t();return}if(n){if(n.run)try{Xb(n.run,{},()=>{})}catch(t){console.error(`spindle: Error in watch run action for \"${e.condition}\":`,t)}n.dialog&&($b.push({passageName:n.dialog}),ex?.()),n.goto&&Q.getState().navigate(n.goto)}}var hx=10;function gx(){for(let e=0;e<hx;e++){let e=!1,t=[...Zb];for(let n of t){if(!Zb.includes(n))continue;let t=nx(n.condition),r=!n.lastResult;n.lastResult=t,t&&r&&(e=!0,n.options?.once&&(Zb=Zb.filter(e=>e!==n)),mx(n))}if(!e)break}}function _x(){if(!Qb){Qb=!0;try{gx()}finally{Qb=!1}}}var vx=0;function yx(){if(vx===0)return;let e=Qb;Qb=!0;try{gx()}finally{Qb=e}}function bx(){let e=Q.getState();vx++;let t=Q.subscribe(t=>{let n=e;e=t,t.navigationId===n.navigationId&&(t.variables===n.variables&&t.temporary===n.temporary&&t.transient===n.transient&&t.renderCounts===n.renderCounts||_x())}),n=!0;return()=>{n&&(n=!1,vx--,t())}}function xx(){for(let e of Zb)e.lastResult=nx(e.condition)}function Sx(){Zb=[],Cx++,Ix(),wx.notify()}var Cx=0,wx=Ss();function Tx(){return Cx}var Ex=wx.subscribe;function Dx(e){return ex=e,$b.length>0&&e(),()=>{ex===e&&(ex=null)}}function Ox(){return $b.shift()}function kx(){return $b.length}function Ax(e){tx?tx.push(e):($b.push(e),ex?.())}function jx(){$b=[]}function Mx(e){return tx=e,()=>{tx===e&&(tx=null)}}var Nx=[];function Px(e){return Nx.push(e),()=>{let t=Nx.lastIndexOf(e);t>=0&&Nx.splice(t,1)}}function Fx(){let e=Nx[Nx.length-1];e?e():tx?.close()}function Ix(){jx();for(let e of[...Nx].reverse())e();tx?.closeAll()}function Lx(){return Nx.length>0||(tx?.isOpen()??!1)}Vn(),Hn();var Rx=new Set([`StoryInit`,`StoryInterface`,`StoryVariables`,`StoryTransients`,`StoryLoading`,`SaveTitle`,`PassageReady`,`PassageHeader`,`PassageFooter`,`PassageDone`]),zx=K(),Bx=[],Vx=K();function Hx(e,t){let n=[];for(let r of Object.keys(e))G(t,r)||n.push({key:r,deleted:!0});let r=new Map,i=e=>n.push({key:e,deleted:!1,value:Q_(t[e],{keepUnregistered:!0,seen:r})}),a=[];for(let n of Object.keys(t))!G(e,n)||!Object.is(e[n],t[n])?i(n):typeof t[n]==`object`&&t[n]!==null&&a.push(n);for(let e=r.size>0;e;){e=!1;for(let n of a){let o=new Map;if(Q_(t[n],{keepUnregistered:!0,seen:o}),[...o.keys()].some(e=>r.has(e))){i(n),a.splice(a.indexOf(n),1),e=!0;break}}}return{forward:n}}function Ux(e,t){let n=Object.create(Object.getPrototypeOf(e));for(let t of Object.keys(e))ss(n,t,e[t]);for(let e of t)e.deleted?delete n[e.key]:ss(n,e.key,e.value);return n}function Wx(e){let t=Bx.length-1;t<0?zx=e:Bx[t]=Hx(qx(t),e)}function Gx(e,t){let n=zx;for(let r=0;r<e;r++)r>0&&(n=Ux(n,Bx[r-1].forward)),t(n,r)}function Kx(e,t){return{passage:e.passage,variables:t,timestamp:e.timestamp,prng:e.prng}}function qx(e){let t=zx;for(let n=0;n<e;n++)t=Ux(t,Bx[n].forward);return t}var Jx=[];function Yx(e){let{storyData:t,currentPassage:n,variables:r,history:i,historyIndex:a,visitCounts:o,renderCounts:s}=e();if(t){if(Jx.length>i.length&&(Jx.length=i.length),Jx.length<i.length)if(i.length-Jx.length===1){let e=i.length-1;Jx[e]=Kx(i[e],r)}else Gx(i.length,(e,t)=>{t>=Jx.length&&(Jx[t]=Kx(i[t],e))});return eb(t.ifid,{passage:n,variables:r,history:Jx,historyIndex:a,visitCounts:o,renderCounts:s,prng:Ol(),watchers:ox(),interfaceWatchers:dx()})}}var Xx=`The game could not be saved for a page reload; a reload goes back to the last passage it could save:`,Zx=`The story could not go to another passage:`;function Qx(e,t){let n;try{let t=Yx(e);t&&Ds(Xx,t.error)}catch(e){n={error:e},Ds(Xx,e)}try{t?.()}finally{if(n)throw n.error}}function $x(e){let t=e.history.length-e.maxHistory;if(t<=0)return!1;let n=Math.min(e.historyIndex,t),r=n+e.maxHistory;for(let e=0;e<n;e++)zx=Ux(zx,Bx[e].forward);return e.history=e.history.slice(n,r),Bx=Bx.slice(n,r-1),Jx=Jx.slice(n,r),e.historyIndex-=n,!0}var eS=!1,tS=[],nS=null;function rS(e,t){let n=nS;if(nS=null,!n||e().navigationId!==n.navigationId)return;e().variables!==n.variables&&Wx(e().variables),Vx=e().variables;let r=Ol(),i=e().history[e().historyIndex].prng;(r?.seed!==i?.seed||r?.pull!==i?.pull)&&t(e=>{e.history[e.historyIndex].prng=r})}var iS=e=>({...e});function aS(e){zx=e,Bx=[],Vx=e,Jx=[]}function oS(e){let t=K(Q_(e));return aS(Q_(t)),t}function sS(e){return K(Q_(e,{keepUnregistered:!0}))}function cS(e,t,n,r){e.currentPassage=t,e.navigationId++,e.variables=n,e.transient=sS(r),e.temporary=K(),e.history=[{passage:t,timestamp:Date.now()}],e.historyIndex=0}function lS(e,t,n){let{historyIndex:r,history:i}=e(),a=r+n;if(a<0||a>=i.length)return;rS(e,t);let o=e().currentPassage,s=i[a].passage;zv(`beforenavigate`,s);let c=Q_(qx(a));t(e=>{e.historyIndex+=n,e.currentPassage=e.history[e.historyIndex].passage,e.navigationId++,e.variables=c,e.temporary=K()}),xx(),Vx=e().variables,US(e().history[e().historyIndex]),Qx(e,()=>zv(`afternavigate`,s,o))}function uS(){let{history:e,historyIndex:t,variables:n}=Q.getState();if(e.length!==1||t!==0)return;aS(n);let r=Ol();Q.setState(e=>{e.history[0].prng=r})}var dS=Promise.resolve(``),fS=0,pS=!1;function mS(){return pS?``:Q.getState().playthroughId}function hS(){if(gS)return gS;let e=mS();return dS.then(t=>e||t)}var gS=null;function _S(e){Q.getState().playthroughId!==e&&Q.setState(t=>{t.playthroughId=e})}function vS(e){let t=++fS;return pS=!0,dS=e.then(e=>(t===fS&&(pS=!1,_S(e)),e)),dS}function yS(e,t){++fS,pS=!1,dS=t.then(()=>e,()=>e),_S(e)}function bS(e){let t=bt();yS(t,$v(e,t).catch(e=>{console.error(`spindle: failed to start new playthrough`,e)}))}function xS(e,t){mS()!==t&&yS(t,ay(e,t).catch(e=>{console.error(`spindle: failed to switch to the loaded playthrough`,e)}))}var SS=0,CS=0,wS=null,TS=null;function ES(){return++SS}function DS(e){return CS>e}function OS(){AS(++SS)}var kS=Ss();function AS(e){CS=e,kS.notify()}var jS=kS.subscribe,MS=[],NS=!1;function PS(e){NS&&MS.push(e)}function FS(){NS=!0}function IS(){for(let e of MS)e();MS=[],NS=!1}function LS(e){return typeof e==`string`&&e!==``?e:null}function RS(e){let{history:t,historyIndex:n}=e;if(!Number.isInteger(n))return;let r=t[n];if(!(!r||r.passage!==e.passage)&&!(typeof r.variables!=`object`||r.variables===null))return r}function zS(e,t,n){let r=e.history[e.historyIndex];if(!r)return;let i=kv(t,n,!0);if(i.length===0)return;let a=Q_(r.variables),o=jv(Av(n,i),a),s=e=>Q_(e,{seen:o});for(let e of i)BS(a,n,e,s);r.variables=rv(r.variables,a)}function BS(e,t,n,r){let{path:i}=n,a=e,o=0;for(;o<i.length-1;o++){let e=i[o],n=G(a,e)?a[e]:void 0,s=V_(t,i.slice(0,o+1));if(!fv(n,s,!0)){VS(a,e,r(s));return}a=n}let s=i[o];n.deleted?VS(a,s,void 0,n):VS(a,s,r(n.value),n)}function VS(e,t,n,r){let i=r?.deleted??!1;if(Array.isArray(e)){let a=Number(t);i?r&&`hole`in r?delete e[a]:e.length=Math.min(e.length,a):r&&`appended`in r?(e.length+=r.gap??0,e.push(n)):t===`length`&&r?e.length+=n:a<e.length&&(e[a]=n)}else i?delete e[t]:ss(e,t,n)}function HS(e){e?wl(e.seed,e.pull):El()}function US(e){e&&HS(e.prng)}function WS(e,t){if(e)return[t.passage,...t.history.map(e=>e.passage)].find(t=>!e.passages.has(t))}function GS(e,t){let n=WS(e,t);if(n!==void 0)throw Error(`The save refers to the passage \"${n}\", which this version of the story does not have`)}var KS=[`variables`,`temporary`,`transient`];function qS(e){for(let t of KS){let n=e[t];ls(n)||(e[t]=K(Mt(n)?zn(n):n))}}var JS=[`navigate`,`goBack`,`goForward`,`restart`,`save`,`load`,`getSavePayload`,`loadFromPayload`];function YS(e){return(t,n,r)=>{let i=((e,n)=>{if(n){t(e,!0);return}let r=typeof e==`function`?e:t=>{Object.assign(t,e)},i=zb(r);t(e=>{(i??r)(e),qS(e)})});r.setState=i;let a=e(i,n,r);for(let e of JS){let t=a[e];a[e]=(...e)=>qb(()=>t(...e))}return a}}var XS=e=>Wn(YS(e));function ZS(e){return e.catch(()=>{}),e}function QS(e,t,n){return ZS(e.catch(e=>{throw console.error(t,e),n?.(e),e}))}function $S(e,t,n){e(e=>{let r=t??``;if(n)e.knownSaves={...e.knownSaves,[r]:!0};else{let{[r]:t,...n}=e.knownSaves;e.knownSaves=n}})}function eC(e,t){return qy(t).then(t=>{e(e=>{e.knownSaves=t})})}var tC;function nC(e,t,n,r){let i=n.then(()=>{t(e=>{e.knownSaves={}})});return e().restart(),QS(i,r)}var Q=yt()(XS((e,t)=>({storyData:null,currentPassage:``,navigationId:0,variables:K(),variableDefaults:{},transient:K(),transientDefaults:{},temporary:K(),history:[],historyIndex:-1,visitCounts:gs(),renderCounts:gs(),knownSaves:{},playthroughId:``,maxHistory:40,quickSaveKey:`F6`,quickLoadKey:`F9`,saveError:null,loadError:null,transitionConfig:null,nextTransition:null,nobr:!1,renderDeferred:!1,setMaxHistory:n=>{let r=!1;e(e=>{e.maxHistory=Math.max(1,Math.round(n)),r=$x(e)}),r&&Qx(t)},setQuickSaveKey:t=>{e(e=>{e.quickSaveKey=LS(t)})},setQuickLoadKey:t=>{e(e=>{e.quickLoadKey=LS(t)})},init:(n,r={},i={})=>{let a=n.passagesById.get(n.startNode);if(!a)throw Error(`spindle: Start passage (pid=${n.startNode}) not found.`);let o=oS(r);e(e=>{e.storyData=n,e.playthroughId=``,e.variableDefaults=r,e.transientDefaults=i,cS(e,a.name,o,i),e.visitCounts=gs(null,a.name),e.renderCounts=gs(null,a.name)}),Vx=t().variables,OS(),vS(cy(n.ifid).then(({id:t,knownSaves:n})=>(e(e=>{e.knownSaves=n}),t)).catch(e=>(console.error(`spindle: failed to init save system`,e),``))),tC?.(),tC=Vy(n.ifid,()=>{eC(e,n.ifid).catch(()=>{})})},navigate:n=>{if(eS){tS.push(n);return}let{storyData:r}=t();if(!r)return;if(Rx.has(n)){console.error(`spindle: Cannot navigate to special passage \"${n}\".`);return}if(!r.passages.has(n)){let e=Os(n,t().currentPassage);console.error(`spindle: ${e.message}`),Ds(Zx,e);return}let i=t().currentPassage;zv(`beforenavigate`,n);let a=Hx(Vx,t().variables);e(e=>{e.temporary=K(),e.currentPassage=n,e.navigationId++,e.history=e.history.slice(0,e.historyIndex+1),Bx.length=e.historyIndex,Jx.length>e.historyIndex+1&&(Jx.length=e.historyIndex+1),Bx.push(a),e.history.push({passage:n,timestamp:Date.now(),prng:Ol()}),e.historyIndex=e.history.length-1,$x(e),e.visitCounts=gs(e.visitCounts,n),e.renderCounts=gs(e.renderCounts,n)}),nS={navigationId:t().navigationId,variables:t().variables},eS=!0;try{yx()}finally{eS=!1}let o=tS;tS=[],rS(t,e),Qx(t,()=>{zv(`afternavigate`,n,i);for(let e of o)t().navigate(e)})},goBack:()=>lS(t,e,-1),goForward:()=>lS(t,e,1),setVariable:(t,n)=>{e(e=>{as(t,`$${t}`),e.variables[t]=n})},setTemporary:(t,n)=>{e(e=>{as(t,`_${t}`),e.temporary[t]=n})},deleteVariable:t=>{e(e=>{as(t,`$${t}`),delete e.variables[t]})},deleteTemporary:t=>{e(e=>{as(t,`_${t}`),delete e.temporary[t]})},setTransient:(t,n)=>{e(e=>{as(t,`%${t}`),e.transient[t]=n})},deleteTransient:t=>{e(e=>{as(t,`%${t}`),delete e.transient[t]})},updateVariables:t=>{e(e=>{t(e)})},trackRender:t=>{e(e=>{e.renderCounts=gs(e.renderCounts,t)})},restart:()=>{let{storyData:n,variableDefaults:r,transientDefaults:i}=t();if(!n)return;let a=n.passagesById.get(n.startNode);if(!a)return;e(e=>{e.renderDeferred=!1}),zv(`beforerestart`),bS(n.ifid),OS();let o=t().renderDeferred;IS(),El(),Sx();let s=oS(r);e(e=>{cS(e,a.name,s,i),e.visitCounts=gs(null,a.name),e.renderCounts=gs(null,a.name),o||(e.renderDeferred=!1)}),Vx=t().variables,FS(),yb(),nb(n.ifid),zv(`storyinit`),uS()},save:(n,r)=>{let{storyData:i}=t();if(!i)return Promise.resolve();let a=hS();return QS(ly(n,r,t().beginSave,async t=>{e(e=>{e.saveError=null}),await Wy(i.ifid,a,t,n,r),$S(e,n,!0)}),`spindle: failed to save`,t=>e(e=>{e.saveError=xs(t,`Failed to save`)}))},load:n=>{let{storyData:r}=t();if(!r)return Promise.resolve();e(e=>{e.loadError=null});let i=hS(),a=Ky(r.ifid,n,e=>GS(r,e)),o=vS(Promise.all([i,a.catch(()=>void 0)]).then(([e,t])=>t?.playthroughId||e)),s=++SS;return QS(a.then(async e=>{await o,e&&(CS>s||(wS=s,TS=i,t().loadFromPayload(e.payload,n)))}),`spindle: failed to load save`,t=>e(e=>{e.loadError=xs(t,`Failed to load`)}))},hasSave:e=>{let{storyData:n,knownSaves:r}=t();return n?G(r,e??``):!1},getSaveInfo:async e=>{let{storyData:n}=t();return n?Yy(n.ifid,e):null},listSaves:async()=>{let{storyData:e}=t();return e?Zy(e.ifid):[]},deleteSave:n=>{let{storyData:r}=t();return r?QS(Qy(r.ifid,n).then(()=>$S(e,n,!1)),`spindle: failed to delete save`):Promise.resolve()},exportSave:async e=>{let{storyData:n}=t();return n?await ub(n.ifid,e)??null:null},importSave:async(n,r)=>{let{storyData:i}=t();if(!i)throw Error(`spindle: Story is not initialized.`);let a=await db(n,i.ifid,r);return $S(e,r,!0),a},clearGameData:()=>{let{storyData:n}=t();return n?nC(t,e,pb(n.ifid),`spindle: failed to clear game data`):Promise.resolve()},clearAllData:()=>nC(t,e,mb(),`spindle: failed to clear all data`),deletePlaythrough:n=>{let{storyData:r}=t();if(!r)return Promise.resolve();let i=r.ifid,a=mS(),o=dS,s=bt(),c=gb(i,n,{current:a||o,id:s});return n!==``&&n===a?yS(s,c):a===``&&vS(c.then(e=>e?s:o,()=>o)),QS(c.then(()=>eC(e,r.ifid)),`spindle: failed to delete playthrough`)},getSavePayload:()=>{let{currentPassage:e,variables:n,history:r,historyIndex:i,visitCounts:a,renderCounts:o}=t(),s=[];return Gx(r.length,(e,t)=>{let n=iS(e);s.push(Kx(r[t],t===0?n:rv(s[t-1].variables,n)))}),{passage:e,variables:rv(s[i]?.variables,iS(n)),history:s,historyIndex:i,visitCounts:{...a},renderCounts:{...o},prng:Ol(),watchers:ox(),interfaceWatchers:dx()}},beginSave:()=>{let e=t().variables;return()=>{let n=t().getSavePayload();return zS(n,e,t().variables),n}},loadFromPayload:(n,r,i)=>{let a=wS;wS=null;let o=TS;TS=null;let s=a??++SS;if(n.history.length===0){console.warn(`loadFromPayload: rejecting payload with empty history`);return}GS(t().storyData,n),AS(s),gS=o;try{zv(`beforeload`,r)}finally{gS=null}let c=t().storyData?.ifid;i&&c&&xS(c,i);let l=RS(n),u=Q_(n.history.map(e=>e.variables)).map(e=>K(e));zx=Q_(u[0]),Bx=u.slice(1).map((e,t)=>Hx(u[t],e)),Jx=n.history.map((e,t)=>Kx(e,u[t])),e(e=>{e.currentPassage=n.passage,e.navigationId++,e.variables=K(Q_(l?.variables??n.variables)),e.history=n.history.map(e=>({passage:e.passage,timestamp:e.timestamp,prng:e.prng})),e.historyIndex=Math.max(0,Math.min(n.historyIndex,e.history.length-1)),$x(e),e.visitCounts=gs(n.visitCounts),e.renderCounts=gs(n.renderCounts),e.temporary=K(),e.transient=sS(t().transientDefaults)}),n.watchers&&fx(n.watchers,n.interfaceWatchers),xx(),Vx=qx(t().historyIndex),HS(l?.prng===void 0?n.prng:l.prng),Qx(t,()=>Dl(()=>zv(`afterload`,r)))},getHistoryVariables:e=>Q_(qx(e)),setTransition:t=>{e(e=>{e.transitionConfig=t})},setNextTransition:t=>{e(e=>{e.nextTransition=t})},consumeNextTransition:()=>{let n=t().nextTransition;return n!==null&&e(e=>{e.nextTransition=null}),n},deferRender:()=>{e(e=>{e.renderDeferred=!0})},clearDeferredRender:()=>{e(e=>{e.renderDeferred=!1})}}))),rC=`<header class=\"story-menubar\">{story-title}{back}{forward}{restart}{quicksave}{quickload}{saves}{settings}</header>\n{passage}`;function iC(){let{storyData:e}=pl(`storyData`),t=e?.passages.get(`StoryInterface`),n=t===void 0?rC:t.content,r=t?.tags.includes(`nobr`)??!1,i=Fe(()=>{try{return q(S,{children:Km($o(n))})}catch(e){return q(`span`,{class:`error`,children:[`Error in StoryInterface: `,xs(e)]})}},[n]);return Pe(ux,[]),q(Xp.Provider,{value:!0,children:r?q(Yp.Provider,{value:!0,children:i}):i})}var aC=[`a[href]`,`area[href]`,`button:not([disabled])`,`input:not([disabled]):not([type=\"hidden\"])`,`select:not([disabled])`,`textarea:not([disabled])`,`iframe`,`audio[controls]`,`video[controls]`,`summary`,`[contenteditable]`,`[tabindex]`].join(`,`);function oC(e){for(let t=e.parentElement;t;t=t.parentElement)if(!(t.localName!==`details`||t.hasAttribute(`open`))&&!Array.from(t.children).find(e=>e.localName===`summary`)?.contains(e))return!0;return!1}function sC(e){let{visibility:t}=getComputedStyle(e);if(t===`hidden`||t===`collapse`)return!1;for(let t=e;t;t=t.parentElement)if(getComputedStyle(t).display===`none`)return!1;return!oC(e)}function cC(e){return!e.hidden&&!e.closest(`[hidden], [inert]`)&&!e.matches(`:disabled`)&&sC(e)}function lC(e){let t=e.getAttribute(`tabindex`);return t===null||!/^\\s*[+-]?\\d+\\s*$/.test(t)?null:parseInt(t,10)}function uC(e){let t=lC(e);if(t!==null&&t<0||e.hasAttribute(`contenteditable`)&&!e.matches(`a[href], button, input, select, textarea, iframe, summary`)&&(!e.isContentEditable||e.parentElement?.isContentEditable))return!1;if(e.localName===`summary`){let n=e.parentElement;if(n?.localName!==`details`||Array.from(n.children).find(e=>e.localName===`summary`)!==e)return t!==null}if(e instanceof HTMLInputElement&&e.type===`radio`&&e.name){let t=Array.from((e.form??e.getRootNode()).querySelectorAll(`input[type=\"radio\"]`)).filter(t=>t.name===e.name&&t.form===e.form&&(lC(t)??0)>=0&&cC(t));return e===(t.find(e=>e.checked)??t[0])}return!0}function dC(e){let t=Array.from(e.querySelectorAll(aC)).filter(e=>cC(e)&&uC(e)),n=e=>Math.max(lC(e)??0,0);return[...t.filter(e=>n(e)>0).sort((e,t)=>n(e)-n(t)),...t.filter(e=>n(e)===0)]}var fC=[];function pC(e,t,n,r){Pe(()=>{let n=e.current;if(!n)return;let r=document.activeElement instanceof HTMLElement?document.activeElement:null,i={panel:n};fC.push(i);let a=n.querySelector(t)??n;return(Array.from(n.querySelectorAll(`[autofocus]`)).find(cC)??dC(a)[0]??n).focus(),()=>{let e=fC.indexOf(i);e!==-1&&fC.splice(e,1);let t=document.activeElement;(!t||t===document.body||n.contains(t))&&r?.isConnected&&r.focus()}},[]),Pe(()=>{let t=e.current;if(!t)return;let i=()=>fC[fC.length-1]?.panel===t,a=(e,n)=>{let r=dC(t),i=r[0],a=r[r.length-1];if(!i||!a){t.focus();return}let o=e?r.indexOf(e):-1,s;if(o!==-1)s=r[o+(n?-1:1)];else if(e&&e!==t&&t.contains(e)){let t=t=>!!(e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING);s=n?r.filter(e=>!t(e)).pop():r.find(t)}else s=n?a:i;(s??(n?a:i)).focus()},o=e=>{if(i()){if(e.key===`Escape`){if(!n)return;e.preventDefault(),e.stopPropagation(),r();return}e.key===`Tab`&&(e.preventDefault(),a(document.activeElement,e.shiftKey))}},s=new AbortController,{signal:c}=s,l=new Map,u=e=>{let t=null;try{t=e.contentDocument}catch{}!t||l.get(e)===t||(l.set(e,t),t.addEventListener(`keydown`,n=>{if(!i())return;if(n.key!==`Tab`)return o(n);let r=Array.from(t.querySelectorAll(aC)).filter(e=>cC(e)&&uC(e)),s=t.activeElement,c=n.shiftKey?r[0]:r[r.length-1];(!c||s===c||s===t.body)&&(n.preventDefault(),a(e,n.shiftKey))},{signal:c}))},d=()=>{t.querySelectorAll(`iframe`).forEach(u)};t.addEventListener(`load`,e=>{e.target instanceof HTMLIFrameElement&&u(e.target)},{capture:!0,signal:c});let f=new MutationObserver(d);return f.observe(t,{childList:!0,subtree:!0}),d(),document.addEventListener(`keydown`,o,{signal:c}),document.addEventListener(`focusin`,e=>{let n=e.target;!i()||!(n instanceof Node)||t.contains(n)||n===document.body||n===document.documentElement||a(null,!1)},{signal:c}),()=>{s.abort(),f.disconnect()}},[n,r])}var mC=_e(null);function hC({passageName:e,fallbackMarkup:t,panelClass:n,onClose:r,dismissible:i=!0,showCloseButton:a=i}){let o=A(r);o.current=r;let s=Ie(()=>o.current(),[]),{storyData:c}=pl(`storyData`),l=e?c?.passages.get(e):void 0,u=l?.content??t,d=l?.tags.includes(`nobr`)??!1,f=Fe(()=>{if(!u)return q(`div`,{class:`error`,children:`Dialog: no content available`});try{let e=eh($o(u),d?{nobr:!0}:void 0);return d?q(Yp.Provider,{value:!0,children:e}):e}catch(e){return q(`div`,{class:`error`,children:[`Error in dialog: `,xs(e)]})}},[u,d]),p=A(null),m=nm();pC(p,`.dialog-body`,i,s),Pe(()=>Px(s),[s]),Pe(()=>{p.current&&Bv(`dialogrender`,e??``,p.current)},[]);let h=e=>{i&&e.target===e.currentTarget&&s()},g=n?`dialog-panel ${n}`:`dialog-panel`;return q(mC.Provider,{value:s,children:q(`div`,{class:`dialog-overlay`,onClick:h,children:q(`div`,{ref:p,class:g,role:`dialog`,\"aria-modal\":`true`,tabIndex:-1,children:[a&&q(`button`,{type:`button`,class:`dialog-close`,\"aria-label\":`Close`,onClick:s,children:`✕`}),q(`div`,{class:`dialog-body`,children:q(em.Provider,{value:m,children:f})})]})})})}function gC(){let[e,t]=je([]),n=A(e);n.current=e;let r=Ie(e=>{t(t=>[...t,e])},[]),i=Ie(()=>{t(e=>e.slice(0,-1))},[]),a=Ie(()=>{t([])},[]);return Ne(()=>Mx({close:i,closeAll:a,push:r,isOpen:()=>n.current.length>0}),[i,a,r]),Ne(()=>Dx(()=>{let e=[];for(;kx()>0;){let t=Ox();t&&e.push(t)}e.length>0&&t(t=>[...t,...e])}),[]),e.length===0?null:q(S,{children:e.map((e,t)=>q(hC,{passageName:e.passageName,panelClass:e.panelClass,onClose:i,showCloseButton:e.showCloseButton,dismissible:e.dismissible},`${e.passageName}-${t}`))})}function _C(){let[e,t]=je(As);return Ne(()=>(t(As()),js(()=>t(As()))),[]),e.length===0?null:q(`div`,{class:`spindle-error-banners`,children:e.map(e=>q(`div`,{class:`spindle-error-banner`,role:`alert`,children:[q(`span`,{class:`spindle-error-banner-context`,children:e.context}),` `,q(`span`,{class:`spindle-error-banner-message`,children:e.message}),e.count>1&&q(`span`,{class:`spindle-error-banner-count`,children:` (×${e.count})`}),q(`button`,{type:`button`,class:`spindle-error-banner-dismiss`,\"aria-label\":`Dismiss`,onClick:()=>ks(e.id),children:`✕`})]},e.id))})}async function vC(){try{await Q.getState().save()}catch(e){Ds(`The game could not be saved:`,e)}}async function yC(){try{await Q.getState().load()}catch(e){Ds(`The saved game could not be loaded:`,e)}}function bC(){let{storyData:e,currentPassage:t,nobr:n}=pl(`storyData`,`currentPassage`,`nobr`);if(Ne(()=>{let e=e=>{let{quickSaveKey:t,quickLoadKey:n}=Q.getState();t!==null&&e.key===t?(e.preventDefault(),vC()):n!==null&&e.key===n&&(e.preventDefault(),yC())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[]),!e||!t)return q(`div`,{class:`loading`,children:`Loading...`});let r=q(S,{children:[q(iC,{}),q(gC,{}),q(_C,{})]});return q(Yp.Provider,{value:n,children:r})}var xC=`http://www.w3.org/1999/xhtml`,SC=new Set([`area`,`base`,`basefont`,`bgsound`,`br`,`col`,`embed`,`frame`,`hr`,`img`,`input`,`keygen`,`link`,`meta`,`param`,`source`,`track`,`wbr`]);function CC(e){let t=``;for(let n of Array.from(e.childNodes))n.nodeType===Node.TEXT_NODE?t+=n.data:n.nodeType===Node.COMMENT_NODE?t+=`\\x3C!--${n.data}-->`:n.nodeType===Node.ELEMENT_NODE&&(t+=wC(n));return t}function wC(e){let t=e.localName,n=`<${t}`;for(let t of Array.from(e.attributes))n+=` ${t.name}=${TC(t.name,t.value)}`;if(n+=`>`,e.namespaceURI===xC&&SC.has(t))return n;let r=t===`template`?e.content:e;return`${n}${CC(r)}</${t}>`}function TC(e,t){let n=Ko(e),r=n?`on`:`a`;return[`\"${t}\"`,`'${t}'`].find(e=>{let t;try{t=es(`<i ${r}=${e}>`)}catch(e){if(e instanceof Xo)return!1;throw e}let n=t[0];return t.length===1&&n?.type===`html`&&n.attributes[r]===e.slice(1,-1)})??`\"${EC(t,n)}\"`}function EC(e,t){let n=e=>e.replace(/\"/g,`&quot;`);if(t)return qo(e).map(e=>`text`in e?n(e.text):`expr`in e?`{${e.expr}}`:e.verbatim).join(``);let r;try{r=es(e,{text:!0})}catch(t){if(t instanceof Xo)return n(e);throw t}return r.map(t=>{let r=e.slice(t.start,t.end);return t.type===`text`?n(r):r}).join(``)}function DC(){let e=document.querySelector(`tw-storydata`);if(!e)throw Error(`spindle: No <tw-storydata> element found in the document.`);let 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||``,s=e.querySelector(`[type=\"text/twine-javascript\"]`)?.textContent||``,c=new Map,l=new Map;for(let t of e.querySelectorAll(`tw-passagedata`)){let e=parseInt(t.getAttribute(`pid`)||`0`,10),n=t.getAttribute(`name`)||``,r=(t.getAttribute(`tags`)||``).split(/\\s+/).filter(e=>e.length>0),i=CC(t),a={},o=new Set([`pid`,`name`,`tags`]);for(let e of t.attributes)o.has(e.name)||(a[e.name]=e.value);let s={pid:e,name:n,tags:r,metadata:a,content:i};c.set(n,s),l.set(e,s)}return{name:t,startNode:n,ifid:r,format:i,formatVersion:a,passages:c,passagesById:l,userCSS:o,userScript:s}}var OC=new Map,kC=K(),AC=!1,jC=null;function MC(){return`spindle.${Q.getState().storyData?.ifid||`unknown`}.settings`}function NC(){try{localStorage.setItem(MC(),JSON.stringify(kC))}catch{}}function PC(){if(!AC){if(!Q.getState().storyData?.ifid){jC||(jC=Q.subscribe(e=>{e.storyData?.ifid&&(jC?.(),jC=null,PC())}));return}AC=!0;try{let e=localStorage.getItem(MC());if(e){let t=JSON.parse(e);typeof t==`object`&&t&&!Array.isArray(t)&&(kC=K(kC,t))}}catch{}}}function FC(e,t){OC.set(e,t),G(kC,e)||(kC[e]=t.config.default),PC()}function IC(e,t){let n=os(kC,e);return typeof n==typeof t?n:t}var LC={addToggle(e,t){FC(e,{type:`toggle`,config:t})},addList(e,t){FC(e,{type:`list`,config:t})},addRange(e,t){FC(e,{type:`range`,config:t})},get(e){return os(kC,e)},getToggle(e){return IC(e,!1)},getList(e){return IC(e,``)},getRange(e){return IC(e,0)},set(e,t){kC[e]=t,NC()},getAll(){return{...kC}},getDefinitions(){return OC},hasAny(){return OC.size>0}},RC=0,zC=4096,BC=[];function VC(e){BC.push({version:++RC,path:e}),BC.length>zC&&BC.shift()}function HC(e){VC([`variables`,...e])}var UC=_e(!1),WC=[`variables`,`temporary`,`transient`];function GC(e){let t=wb();try{e()}finally{let e=wb();for(let n of WC)if(t[n]!==e[n])for(let{path:r}of mv(t[n],e[n],!0))VC([n,...r])}}function KC(){return RC}function qC(e,t){let n=new Set,r=new Map;for(let i=BC.length-1;i>=0&&BC[i].version>e;i--){let{path:e}=BC[i],a=t;e.forEach((t,i)=>{if(i===e.length-1&&typeof a==`object`&&a){let e=r.get(a)??new Set;e.add(t),r.set(a,e)}a=typeof a==`object`&&a?V_(a,[t]):void 0,typeof a==`object`&&a&&n.add(a)})}return(e,t,i)=>typeof t==`object`&&t?n.has(t):r.get(e)?.has(String(i))===!0}var JC=[`target`,`variable`,`options`,`value`,`disabled`],YC=new Map,XC=new Map;function ZC(e,t,n){if(n)return n;let r=`${e}:${t}`,i=XC.get(r)??0,a;do i++,a=i===1?r:`${r}:${i}`;while(YC.has(a));return XC.set(r,i),a}function QC(e){let t=e.id,n={action:e},r=YC.get(t);return r?(console.warn(`spindle: two mounted controls share the action ID \"${t}\"; Story.getActions() lists only the newer one.`),r.push(n)):YC.set(t,[n]),rw(),{update(e){let r=YC.get(t);r?.includes(n)&&(n.action=e,r[r.length-1]===n&&rw())},unregister(){let e=YC.get(t),r=e?e.indexOf(n):-1;!e||r===-1||(e.splice(r,1),e.length===0&&YC.delete(t),r===e.length&&rw())}}}function $C(){return Array.from(YC.values(),tw)}function ew(e){let t=YC.get(e);return t&&tw(t)}function tw(e){return e[e.length-1].action}function nw(){XC.clear()}function rw(){zv(`actionsChanged`)}function iw(e){let t=A(``),n=A(e.perform);n.current=e.perform,t.current||(t.current=ZC(e.type,e.key,e.authorId));let r=t.current,i=()=>{let t={id:r,type:e.type,label:e.label,perform:(...e)=>n.current(...e)};for(let n of JC)e[n]!==void 0&&Object.assign(t,{[n]:e[n]});return t},a=A(null);Pe(()=>{let e=QC(i());return a.current=e,()=>e.unregister()},[r]);let o=A(!1);return Pe(()=>{if(!o.current){o.current=!0;return}a.current?.update(i())},[e.type,e.label,e.target,e.variable,e.disabled,e.value,JSON.stringify(e.options)]),r}function aw(e){return e.map(e=>e.type===`text`?e.value:``).join(``)}function ow(e,t){let n=`macro-${e}`;return t?`${n} ${t}`:n}var sw={useState:je,useRef:A,useEffect:Ne,useLayoutEffect:Pe,useCallback:Ie,useMemo:Fe,useContext:j};function $(e,t=`builtin`){let n=e.parameters??[];Wc(e.name,n);function r(t){let r=t.className,i=t.id,a;e.interpolate&&(a=gu(),r=a(r),i=a(i));let{update:o,getValues:s}=j(Jp),c=j(UC),l=xu(),u=(e,t)=>eh(e,{...l,...t}),d;try{d=dc(t.rawArgs,n)}catch(t){if(t instanceof Xs)return b(Up,{macro:e.name,error:t});throw t}let f={args:d,collectText:aw,sourceLocation:Hp,parseVarArgs:hc,extractOptions:yc,h:b,renderNodes:u,renderInlineNodes:Km,hooks:sw,useAction:iw,className:r,id:i,resolve:a,cls:ow(e.name,r),mutate:c?e=>GC(()=>Xb(e,s(),o)):e=>Xb(e,s(),o),update:o,getValues:s,wrap:e=>eu(r,i,e)};if(e.merged){f.merged=ml();let e=f.merged;f.evaluate=t=>Zl(t,e[0],e[1],e[2],e[3])}if(e.storeVar){let n=mc(t.rawArgs).replace(/[\"']/g,``),r={\"%\":`transient variables`,_:`temporary variables`,\"@\":`locals`}[n.charAt(0)];if(r)return b(`span`,{class:`error`},`{${e.name}}: ${r} (${n}) cannot be bound to input macros`);let i=n.replace(/[\"']/g,``).replace(/^\\$/,``),a=i.split(`.`);if(a.includes(`__proto__`))return b(`span`,{class:`error`},`{${e.name}}: \"$${i}\" cannot be bound: ${rs} is reserved`);f.varName=i,f.value=Q(e=>V_(e.variables,a)),f.getValue=()=>V_(wb().variables,a),f.setValue=e=>{HC(a),Jb((t,n)=>{G_(t.variables,a,n(e),{createMissing:!0})})}}try{return e.render(t,f)}catch(t){if(t instanceof Xs)return b(Up,{macro:e.name,error:t});throw t}}Pc(e.name,r);let i=e.text;Lc(e.name,i&&((e,t)=>i(e,{...t,args:dc(e.rawArgs,n)})));let a=e.block===!0||e.block!==!1&&(e.subMacros?.length??0)>0;if(qc(e.name,{name:e.name,block:a,subMacros:e.subMacros??[],storeVar:e.storeVar,interpolate:e.interpolate,merged:e.merged,description:e.description,parameters:e.parameters&&[...e.parameters],source:t}),e.subMacros)for(let t of e.subMacros)Bc(t);a&&wr(e.name)}var cw=null;function lw(e){cw=e}function uw(){return cw}var dw=null,fw=null;function pw(){return fw}var mw=!1;function hw(){if(mw)return;mw=!0;let e=Q.getState().variables,t=Q.getState().transient;Q.subscribe(n=>{let r={},i=(e,t,n)=>{for(let i of ps(e,t))r[n+i]={from:os(e,i),to:os(t,i)}};i(e,n.variables,``),i(t,n.transient,`%`),e=n.variables,t=n.transient,Object.keys(r).length>0&&zv(`variableChanged`,r)})}var gw=null,_w=null,vw=new Set;function yw(e,t=[]){gw=new Set(e),_w=new Set(t),vw.clear()}function bw(e){let t=e.startsWith(`%`),n=t||e.startsWith(`$`)?e.slice(1):e;return as(n.split(`.`)[0],e),{isTransient:t,key:n}}function xw(e,t){let n=e?_w:gw;if(!n)return;let r=t.split(`.`)[0];if(n.has(r))return;let i=(e?`%`:`$`)+r;vw.has(i)||(vw.add(i),console.warn(`spindle: Story.set() wrote ${i}, which is not declared in ${e?`StoryTransients`:`StoryVariables`}. Passages cannot reference it; check the name or declare it.`))}function Sw(e,t,n){let{isTransient:r,key:i}=bw(t),a=r?e.transient:e.variables;i.includes(`.`)?G_(a,i.split(`.`),n):a[i]=n}function Cw(e){return((...t)=>Q.getState()[e](...t))}function ww(){return{get(e){let{isTransient:t,key:n}=bw(e),r=Cb(),i=r??Q.getState(),a=t?i.transient:i.variables,o=n.includes(`.`)?V_(a,n.split(`.`)):os(a,n);return r?Ob(o):Ab(o)},set(e,t){let n=typeof e==`string`?[[e,t]]:Object.entries(e);for(let[e]of n){let{isTransient:t,key:n}=bw(e);xw(t,n)}if(n.some(([e])=>e.includes(`.`))){Jb((e,t)=>{for(let[r,i]of n)Sw(e,r,t(i))});return}Q.getState().updateVariables(e=>{for(let[t,r]of n)Sw(e,t,r)})},goto:Cw(`navigate`),back:Cw(`goBack`),forward:Cw(`goForward`),restart:Cw(`restart`),save:Cw(`save`),load:Cw(`load`),hasSave:Cw(`hasSave`),getSaveInfo:Cw(`getSaveInfo`),listSaves:Cw(`listSaves`),deleteSave:Cw(`deleteSave`),exportSave:Cw(`exportSave`),importSave:Cw(`importSave`),...Kl(()=>Q.getState().visitCounts,()=>Q.getState().renderCounts),get title(){return Q.getState().storyData?.name||``},get passage(){return Q.getState().currentPassage},settings:LC,registerClass(e,t){lg(e,t)},defineMacro(e){$(e,`user`)},getMacroRegistry(){return Yc()},saves:{setTitleGenerator(e){Uv(e)}},storage:{async getInfo(){let e=Q.getState().storyData?.ifid;return e?fb(e):{saveCount:0,playthroughCount:0,totalBytes:0,backend:B_()}},async getQuota(){if(typeof navigator<`u`&&navigator.storage?.estimate)try{let e=await navigator.storage.estimate();return{usage:e.usage??0,quota:e.quota??0,estimateSupported:!0}}catch{}return{usage:0,quota:0,estimateSupported:!1}},clearGameData:Cw(`clearGameData`),clearAllData:Cw(`clearAllData`),deletePlaythrough:Cw(`deletePlaythrough`),get backend(){return B_()}},getActions(){return $C()},performAction(e,t){let n=ew(e);if(!n)throw Error(`spindle: Action \"${e}\" not found.`);if(n.disabled)throw Error(`spindle: Action \"${e}\" is disabled.`);n.perform(t)},on(e,t){e===`variableChanged`&&hw();let n=Lv(e,t);return PS(n),n},async waitForActions(){await new Promise(e=>{requestAnimationFrame(()=>requestAnimationFrame(()=>e()))});let e=()=>uw()===Q.getState().navigationId;return uw()!==null&&!e()&&!Q.getState().renderDeferred&&await new Promise(t=>{let n=Lv(`passagerender`,()=>{e()&&(n(),t())})}),$C()},watch(e,t){return ix(e,t)},unwatch(e){px(e)},openDialog(e,t){Ax({passageName:e,panelClass:t?.panelClass,showCloseButton:t?.showCloseButton,dismissible:t?.dismissible})},closeDialog(){Fx()},closeAllDialogs(){Ix()},isDialogOpen(){return Lx()},setNobr(e){Q.setState({nobr:e})},setCSS(e){let t=document.getElementById(`spindle-styles`);t&&(t.disabled=!e)},setTransition(e){Q.getState().setTransition(e)},setNextTransition(e){Q.getState().setNextTransition(e)},deferRender(){Q.getState().deferRender(),fw??(fw=new Promise(e=>{dw=e}))},ready(){dw&&(Q.getState().clearDeferredRender(),dw(),dw=null,fw=null)},random(){return kl()},randomInt(e,t){return Al(e,t)},config:{get maxHistory(){return Q.getState().maxHistory},set maxHistory(e){Q.getState().setMaxHistory(e)},get quickSaveKey(){return Q.getState().quickSaveKey},set quickSaveKey(e){Q.getState().setQuickSaveKey(e)},get quickLoadKey(){return Q.getState().quickLoadKey},set quickLoadKey(e){Q.getState().setQuickLoadKey(e)}},prng:{init(e,t){Cl(e,t);let{historyIndex:n}=Q.getState();Q.setState(e=>{let t=e.history[n];t&&(t.prng=Ol())})},isEnabled(){return jl()},get seed(){return Ml()},get pull(){return Nl()}}}}function Tw(){window.Story=ww()}var Ew=new Set([`StoryVariables`,`StoryTransients`,`SaveTitle`]),Dw=[`script`,`stylesheet`],Ow=new Set([`elseif`,`else`,`case`,`default`,`next`]);function kw(e){let t=e.file?` (${e.file}${e.fileLine?`:${e.fileLine}`:``})`:``;return`Passage \"${e.passage}\", line ${e.line}, column ${e.column}${t}: ${e.message}`}function Aw(e,t){let n=Array.from({length:t.length+1},(e,t)=>t);for(let r=1;r<=e.length;r++){let i=[r];for(let a=1;a<=t.length;a++)i[a]=Math.min(n[a]+1,i[a-1]+1,n[a-1]+(e[r-1]===t[a-1]?0:1));n=i}return n[t.length]}function jw(e,t,n){let r=e.toLowerCase(),i=``,a=Math.max(2,Math.floor(r.length/3))+1;for(let e of t){let t=Aw(r,e.toLowerCase());t<a&&(i=e,a=t)}return i?` Did you mean ${n(i)}?`:``}var Mw=` (a passage name is a quoted string or an expression)`,Nw=/^[A-Za-z][\\w$]*$/;function Pw(e){try{return nl(e).name.toLowerCase()||void 0}catch{return}}function Fw(e,t){let n=[],r=t.isBlockMacro?{isBlock:t.isBlockMacro}:void 0,i=(e,t,r)=>{let{line:i,column:a}=Zo(e.content,t),o={passage:e.name,line:i,column:a,message:r},s=e.metadata?.[`data-source-file`];if(s){o.file=s;let t=Number(e.metadata?.[`data-source-line`]);t&&(o.fileLine=t+i)}n.push(o)},a=[],o=new Set,s=new Set;for(let n of e){if(s.add(n.name),Ew.has(n.name)||n.tags?.some(e=>Dw.includes(e)))continue;let e=!t.only||t.only(n);try{let t=es(n.content);for(let e of t){if(e.type!==`macro`||e.isClose||e.name.toLowerCase()!==`widget`)continue;let t=Pw(e.rawArgs);t&&o.add(t)}if(!e)continue;$o(n.content,{hooks:r}),a.push([n,t])}catch(t){if(!(t instanceof Xo))throw t;e&&i(n,t.offset,t.reason)}}let c=[...t.macroNames??[],...o],l=(e,n,r,a)=>{for(let s of n){if(s.type!==`macro`||s.isClose)continue;let n=s.name.toLowerCase();Ow.has(n)||o.has(n)||t.isKnownMacro(n)||i(e,r+s.start,`${a}Unknown macro {${s.name}}.${jw(s.name,c,e=>`{${e}}`)}`)}},u=t.parametersOf??(()=>void 0),d=(e,n,a,o,c)=>{l(e,a,o,c);for(let l of Ac(n,a,u)){let n=o+l.offset;if(l.kind===`argument-error`){i(e,n,`${c}${l.message} in ${l.label}`);continue}if(l.kind===`passage`){if(t.checkPassageNames!==!1&&!s.has(l.name)){let t=jw(l.name,s,JSON.stringify);i(e,n,`${c}No passage named ${JSON.stringify(l.name)} in ${l.label}.${t}`)}continue}if(l.kind===`code`){let t=Sc(l.code,l.goal),r=l.code.trim();if(t instanceof lo){let r=t.reasonIn(e.content,n);i(e,n+t.pos,`${c}${r} in ${l.label}`+(l.passage?Mw:``))}else l.passage&&Nw.test(r)&&i(e,n,`${c}Unquoted passage name in ${l.label}: write ${JSON.stringify(r)}${Mw}`);continue}if(l.text.includes(`{`))try{$o(l.text,{text:!0,hooks:r});let t=es(l.text,{text:!0});d(e,l.text,t,n,l.where)}catch(t){if(!(t instanceof Xo))throw t;i(e,n+t.offset,l.where+t.reason)}}};for(let[e,t]of a)xc(()=>d(e,e.content,t,0,``));return n}function Iw(e,t){try{return es(e,{text:t})}catch(e){if(e instanceof Xo)return[];throw e}}function Lw(e){let t=e.replace(/[.*+?^${}()|[\\]\\\\]/g,`\\\\$&`);return RegExp(`^${t}(\\\\w+)\\\\s*=\\\\s*(.+)$`)}var Rw=/\\$(\\w+(?:\\.\\w+)*)/y,zw=/^[\"']\\$(\\w+(?:\\.\\w+)*)[\"']?$/,Bw=new Set([`number`,`string`,`boolean`]),Vw={string:Object(``),number:Object(0),boolean:Object(!1)};function Hw(e,t=new Map){if(Array.isArray(e))return{type:`array`};if(e===null)return{type:`null`};if(typeof e==`object`){let n=t.get(e);if(n)return n;let r=new Map,i={type:`object`,fields:r};t.set(e,i);for(let[n,i]of Object.entries(e))r.set(n,Hw(i,t));return i}let n=typeof e;if(!Bw.has(n))throw Error(`Unsupported type \"${n}\" for value ${String(e)}. Expected number, string, boolean, array, or object.`);return{type:n}}function Uw(e,t=`$`){let n=new Map,r=Lw(t),i=t===`%`?`StoryTransients`:`StoryVariables`;for(let a of e.split(`\n`)){let e=a.trim();if(!e)continue;let o=e.match(r);if(!o)throw Error(`${i}: Invalid declaration: \"${e}\". Expected: ${t}name = value`);let[,s,c]=o,l=is(s,t+s);if(l)throw Error(`${i}: ${l}`);let u;try{u=Function(`return (`+c+`)`)()}catch(e){throw Error(`${i}: Failed to evaluate \"${t}${s} = ${c}\": ${xs(e)}`)}let d;try{d=Hw(u)}catch(e){throw Error(`${i}: ${xs(e)}`)}n.set(s,{...d,name:s,default:u})}return n}function Ww(e,t){let n=e.split(`.`),r=n[0],i=is(r,`$`+r);if(i)return i;let a=t.get(r);if(!a)return`Undeclared variable: $${e}`;let o=a;for(let e=1;e<n.length;e++){let t=n[e];if(o.type===`array`||o.type===`null`)return null;let r=Vw[o.type];if(r&&t in r){let e=typeof r[t];if(!Bw.has(e))return null;o={type:e};continue}if(o.type!==`object`||!o.fields)return`Cannot access field \"${t}\" on $${n.slice(0,e).join(`.`)} (type: ${o.type})`;let i=o.fields.get(t);if(!i)return null;o=i}return null}var Gw=[`checkbox`,`cycle`,`listbox`,`numberbox`,`radiobutton`,`textarea`,`textbox`],Kw=new Set;function qw(e,t){for(let n of qo(e))`expr`in n&&Yw(n.expr,t)}function Jw(e,t,n=Kw){e.includes(`{`)&&$w(e,Iw(e,!0),n,t)}function Yw(e,t,n=`expression`){let r=Sc(e,n);if(r instanceof lo){Xw(e,t,n);return}for(let n of r.refs)n.sigil===`$`&&(Rw.lastIndex=n.start,t(Rw.exec(e)[1]))}function Xw(e,t,n){Mo(e,{variable(n,r,i){n===`$`&&(Rw.lastIndex=i,t(Rw.exec(e)[1]))},literal(){}},n)}function Zw(e,t,n,r){xc(()=>$w(e,Iw(e,!1),t,n,r))}function Qw(e,t,n){if(e.rawArgs){if(t){let r=[...jc(e.rawArgs,0,t,e.name,``)];if(!r.some(e=>e.kind===`argument-error`)){for(let e of r)e.kind===`code`?Yw(e.code,n,e.goal):e.kind===`text`&&Jw(e.text,n);return}}Yw(e.rawArgs,n)}}function $w(e,t,n,r,i=()=>void 0){for(let a=0;a<t.length;a++){let o=t[a];if(o.type===`variable`)o.scope===`variable`&&o.name&&r(o.name);else if(o.type===`link`)Jw(o.display,r);else if(o.type===`expression`)Yw(o.expression,r);else if(o.type===`html`)for(let[e,t]of Object.entries(o.attributes))Ko(e)?qw(t,r):Jw(t,r,n);else if(o.type===`macro`&&!o.isClose){if(Qw(o,i(o.name),r),o.className&&Jw(o.className,r),o.id&&Jw(o.id,r),n.has(o.name.toLowerCase())){let e=o.rawArgs.trim().split(/\\s+/)[0]??``,t=zw.exec(e);t?r(t[1]):/^[\"'`]/.test(e)||Yw(e,r)}if(o.name.toLowerCase()===`do`){let n=a+1;for(;n<t.length;){let e=t[n];if(e.type===`macro`&&e.isClose&&e.name.toLowerCase()===`do`)break;n++}n<t.length&&(Yw(e.slice(o.end,t[n].start),r,`statements`),a=n)}}}}function eT(e,t,n=Gw,r=Jc){let i=[],a=new Set(Array.from(n,e=>e.toLowerCase()));for(let[n,o]of e)Ew.has(n)||Zw(o.content,a,e=>{let r=Ww(e,t);r&&i.push(`Passage \"${n}\": ${r}`)},r);return i}function tT(e){let t=K();for(let[n,r]of e)t[n]=r.default;return t}var nT=new WeakMap;function rT(e){let t=nT.get(e);if(t&&t.content===e.content)return t.ast;let n=$o(e.content);return nT.set(e,{content:e.content,ast:n}),n}function iT(e){return eh(rT(e),e.tags.includes(`nobr`)?{nobr:!0}:void 0)}function aT(e){if(!e)return null;try{return iT(e)}catch(t){return console.error(`spindle: Error in ${e.name}:`,t),null}}var oT=new Set([`PassageReady`,`PassageHeader`,`PassageFooter`,`PassageDone`]);function sT({passage:e,dataTransition:t,navigationId:n}){let{storyData:r}=pl(`storyData`),i=oT.has(e.name),[a,o]=je(!1),s=Fe(()=>{try{return iT(e)}catch(t){return q(`div`,{class:`error`,children:[`Error parsing passage “`,e.name,`”`,Vp(e),`: `,xs(t)]})}},[e.content,e.name]),c=e=>i?void 0:r?.passages.get(e),l=c(`PassageHeader`),u=c(`PassageFooter`),d=c(`PassageDone`),f=Fe(()=>aT(l),[l?.content]),p=Fe(()=>aT(u),[u?.content]);Ne(()=>(d&&o(!0),()=>o(!1)),[e.name]);let m=Fe(()=>a?aT(d):null,[a,d?.content]),h=A(null);Pe(()=>{n!==void 0&&lw(n),h.current&&Bv(`passagerender`,e.name,h.current)},[e.name,n]);let g=e.tags.includes(`nobr`),_=nm(),v=q(em.Provider,{value:_,children:q(`div`,{ref:h,class:`passage`,\"data-passage\":e.name,\"data-tags\":e.tags.join(` `),\"data-transition\":t,children:[f&&q(`div`,{class:`passage-header`,children:f}),s,p&&q(`div`,{class:`passage-footer`,children:p}),m&&q(`div`,{hidden:!0,children:m})]})});return g?q(Yp.Provider,{value:!0,children:v}):v}var cT=new Set([`none`,`fade`,`fade-through`,`crossfade`]),lT={type:`fade-through`,duration:300,pause:50};function uT(e){let t=e.find(e=>e.startsWith(`transition:`));if(!t)return null;let n=t.slice(11);if(!cT.has(n))return console.warn(`Unknown transition type: \"${n}\"`),null;let r={type:n};for(let t of e)if(t.startsWith(`duration:`)){let e=Number(t.slice(9));Number.isNaN(e)||(r.duration=e)}else if(t.startsWith(`pause:`)){let e=Number(t.slice(6));Number.isNaN(e)||(r.pause=e)}return r}function dT(e){return{type:e.type,duration:e.duration??lT.duration,pause:e.pause??lT.pause}}function fT(e,t,n){let r=uT(e);return r?dT(r):t?dT(t):n?dT(n):{...lT}}function pT(e,t){let n=e.cloneNode(!0);n.removeAttribute(`id`);let r=n.querySelectorAll(`[id]`);for(let e=0;e<r.length;e++)r[e].removeAttribute(`id`);n.style.pointerEvents=`none`,n.style.userSelect=`none`,n.setAttribute(`inert`,``),n.setAttribute(`aria-hidden`,`true`);let i=n.querySelectorAll(`audio, video`);for(let e=0;e<i.length;e++){let t=i[e];t.pause?.(),t.muted=!0}return n.classList.remove(`passage`),n.classList.add(`passage-snapshot`),n.setAttribute(`data-transition`,t),n}function mT(e,t){e.style.setProperty(`--passage-in-duration`,`${t.duration/1e3}s`),e.style.setProperty(`--passage-out-duration`,`${t.duration/1e3}s`),e.style.setProperty(`--passage-pause`,`${t.pause/1e3}s`)}function hT(e,t){if(!e)return null;mT(e,t);let n=e.querySelector(`.passage`);return n?pT(n,t.type):null}function gT(e){if(!e)return;e.classList.remove(`passage-container--crossfading`);let t=e.querySelectorAll(`.passage-snapshot`);for(let e=0;e<t.length;e++)t[e].remove()}var _T=new Map,vT=new Set;function yT(){let e=()=>{let{navigationId:e,renderDeferred:t}=Q.getState();return!t&&[..._T.values()].every(t=>t===e)};return e()?Promise.resolve():new Promise(t=>{let n=()=>{e()&&(vT.delete(n),t())};vT.add(n)})}function bT(e){let t=e?.querySelector(`.passage`);t&&t.getBoundingClientRect().top<0&&t.scrollIntoView?.({block:`start`})}function xT(e){return window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches?{...e,duration:Math.min(e.duration,10),pause:0}:e}$({name:`passage`,interpolate:!0,render(e,t){let{currentPassage:n,navigationId:r,storyData:i,renderDeferred:a}=pl(`currentPassage`,`navigationId`,`storyData`,`renderDeferred`),[o,s]=je({passage:n,id:r}),c=o.passage,l=e=>s({passage:e,id:r}),u=A(`fade`),d=A(0),f=o.id,p=Ie(e=>e.navigationId!==f,[f]),m=Ie(()=>p(Q.getState()),[p]),h=A(null),g=A(null),_=A([]),v=A(!1),y=Ie(()=>{for(let e of _.current)clearTimeout(e);_.current=[],v.current=!1,gT(g.current)},[]);Ne(()=>y,[y]),Ne(()=>{let e=Q.getState(),{history:t,historyIndex:a,transitionConfig:s}=e,f=d.current;d.current=t.length;let p=!c,m=t.length===1&&a===0&&f>1,h=t.length>1&&a===t.length-1&&f>1&&Math.abs(t.length-f)>1;if(r===o.id)return;let b=e.consumeNextTransition();y();let x=i?.passages.get(n);if(!x){u.current=`none`,l(n);return}if(p||m||h){u.current=`fade`,l(n);return}let S=xT(fT(x.tags,b,s));u.current=S.type;let C=g.current;if(S.type===`none`){l(n);return}if(S.type===`fade`){C&&mT(C,S),l(n);return}let w=S.type===`fade-through`||S.type===`crossfade`?hT(C,S):null;if(!C||!w){l(n);return}if(S.type===`fade-through`){C.appendChild(w),l(``);let e=S.duration+S.pause,t=setTimeout(()=>{l(n)},e),r=e+S.duration;_.current=[t,setTimeout(()=>{gT(C),v.current&&bT(C),v.current=!1},r)];return}C.classList.add(`passage-container--crossfading`),C.appendChild(w),l(n),_.current=[setTimeout(()=>{gT(C)},S.duration)]},[r]);let b=c&&!a?o.id:null,x=A(b);Pe(()=>{if(b===null)return;let e=x.current;if(x.current=b,e===null||e===b)return;let t=g.current;v.current=!!t?.querySelector(`.passage-snapshot`)&&!t.classList.contains(`passage-container--crossfading`),v.current||bT(t)},[b]);let S=A(Symbol(`passage-display`)).current;Pe(()=>{_T.set(S,b),[...vT].forEach(e=>e())},[b]),Pe(()=>()=>{_T.delete(S),[...vT].forEach(e=>e())},[]);let C=a?i?.passages.get(`StoryLoading`)??null:c?i?.passages.get(c):null;if(!C&&c&&!a)return q(`div`,{class:`error`,children:[`Error: Passage “`,c,`” not found.`]});let w=i?.passages.get(`PassageReady`),T=!a&&o.id!==r&&h.current?h.current:C&&q(sT,{passage:C,dataTransition:a?`none`:u.current,navigationId:a?void 0:o.id},a?`loading`:`nav-${o.id}`);return h.current=T||null,q(`div`,{id:t.id??`story`,class:t.className??`story`,children:[!a&&w&&q(`div`,{hidden:!0,children:iT(w)},`ready-${r}`),q(`div`,{class:`passage-container`,ref:g,children:T&&q(dl.Provider,{value:p,children:q(fl.Provider,{value:m,children:T})})})]})}}),$({name:`set`,parameters:[{name:`code`,type:`statements`,required:!0}],render({rawArgs:e},t){return Gp(`set`,e,()=>t.mutate(e))}}),$({name:`print`,parameters:[{name:`expression`,type:`expression`,required:!0}],interpolate:!0,merged:!0,render({rawArgs:e},t){try{return t.wrap($l(t.evaluate(e)))}catch(e){return q(Up,{macro:`print`,error:e})}},text({rawArgs:e},t){return $l(t.evaluate(e))}});var ST=Symbol(`unset`);function CT(e,t){if(!t[`=`])throw Error(`{computed}: expected \"target = expression\", got \"${e}\"`);let{target:n=``,expression:r=``}=t;if(!n.match(/^[$_@]\\w+$/))throw Error(`{computed}: target must be $name, _name, or @name, got \"${n}\"`);return as(n.slice(1),n),{target:n,expr:r}}function wT(e,t,n,r,i,a,o,s,c){let l=Hp(),u,d=o.current,f=!1,{navigationId:p}=Q.getState();try{let{variables:a,temporary:o,transient:c}=wb();r||(d=os(n?o:a,t),f=p!==s.current),u=Zl(e,a,o,i(),c)}catch(e){Wp(`computed ${a}`,e,l);return}if(s.current=p,!nv(o.current,u)||f&&!nv(d,u))if(o.current=u,r)try{c(t,u)}catch(e){Wp(`computed ${a}`,e,l)}else{let e=Q.getState();n?e.setTemporary(t,u):e.setVariable(t,u)}}$({name:`computed`,merged:!0,parameters:[{name:`target`,type:`variable`,required:!0},{name:`=`,type:`separator`},{name:`expression`,type:`expression`,required:!0}],render({rawArgs:e},t){let n,r;try{({target:n,expr:r}=CT(e,t.args))}catch(e){return q(Up,{macro:`computed`,error:e})}let i=n.startsWith(`@`),a=n.startsWith(`_`),o=n.slice(1),s=i?t.update:null,c=t.hooks.useRef(ST),l=t.hooks.useRef(-1),u=()=>wT(r,o,a,i,t.getValues,e,c,l,s),d=t.hooks.useRef(!1);return d.current||(d.current=!0,u()),t.hooks.useLayoutEffect(u,[t.merged]),null}});function TT(e){if(e.current===void 0||e.max===void 0)throw Error(`meter requires two arguments: {meter currentExpr maxExpr}`);return{currentExpr:e.current,maxExpr:e.max,labelMode:e.label??``}}function ET(e,t,n){return n===`none`?null:n===`%`?`${t===0?0:Math.round(e/t*100)}%`:n?`${e} ${n} / ${t} ${n}`:`${e} / ${t}`}$({name:`meter`,interpolate:!0,merged:!0,parameters:[{name:`current`,type:`expression`,required:!0},{name:`max`,type:`expression`,required:!0},{name:`label`,type:`string`,holds:`markup`}],render(e,t){try{let{currentExpr:e,maxExpr:n,labelMode:r}=TT({...t.args,label:t.resolve?.(t.args.label)}),i=Number(t.evaluate(e)),a=Number(t.evaluate(n)),o=a===0?0:Math.max(0,Math.min(100,i/a*100)),s=ET(i,a,r),c=t.cls;return q(`div`,{class:c,id:t.id,children:[q(`div`,{class:`macro-meter-fill`,style:`width: ${o}%`}),s!=null&&q(`span`,{class:`macro-meter-label`,children:s})]})}catch(e){return q(Up,{macro:`meter`,error:e})}}});function DT(e,t){let n=null;for(let r of e)if(r.rawArgs===``)n=r;else if(t(r.rawArgs))return r;return n}function OT(e,t){return eu(t.resolve(e.className),t.resolve(e.id),t.renderNodes(e.children))}function kT(e,t){let n=e.findIndex(e=>e.rawArgs===``);return DT(n<0?e:e.slice(0,n+1),e=>!!t(e))}$({name:`if`,block:!0,interpolate:!0,merged:!0,render({branches:e=[]},t){let n;try{n=kT(e,t.evaluate)}catch(e){return q(Up,{macro:`if`,error:e})}return n?OT(n,t):null},text({branches:e=[]},t){let n=kT(e,t.evaluate);return n?t.renderText(n.children):``}});function AT(e){try{return jT(e,new Map)}catch{return`<unkeyable>`}}function jT(e,t){switch(typeof e){case`string`:return JSON.stringify(e);case`number`:return Number.isFinite(e)?JSON.stringify(e):String(e);case`boolean`:return String(e);case`bigint`:return`${e}n`;case`undefined`:return`undefined`;case`symbol`:return e.description===void 0?`Symbol()`:`Symbol(${JSON.stringify(e.description)})`;case`function`:return`<function ${JSON.stringify(e.name)}>`}if(e===null)return`null`;let n=e,r=t.get(n);if(r!==void 0)return`<ref ${r}>`;let i=ug(n),a=e=>i===void 0?e:`Class(${JSON.stringify(i)})${e}`,o=e=>{let r=i===void 0?[]:eg(n);return a(r.length?`${e}${NT(n,r,t)}`:e)};if(e instanceof Date||e instanceof RegExp)return i!==void 0&&eg(n).length&&t.set(n,t.size),o(e instanceof Date?`Date(${Date.prototype.getTime.call(e)})`:`RegExp(${RegExp.prototype.toString.call(e)}@${e.lastIndex})`);if(t.set(n,t.size),Array.isArray(e))return o(`[${Array.from(e,e=>jT(e,t)).join(`,`)}]`);let s=MT(n,t);return s===void 0?e instanceof Map?o(`Map[${Array.from(tg(e),([e,n])=>`[${jT(e,t)},${jT(n,t)}]`).join(`,`)}]`):e instanceof Set?o(`Set[${Array.from(ng(e),e=>jT(e,t)).join(`,`)}]`):a(NT(n,Object.keys(n),t)):a(s)}function MT(e,t){if(e instanceof ArrayBuffer)return`ArrayBuffer[${new Uint8Array(e).join(`,`)}]`;if(ArrayBuffer.isView(e))return`${qh(e)}(${e.byteOffset},${e.byteLength},${jT(e.buffer,t)})`;let n;if(e instanceof URL)n=`URL(${JSON.stringify(Object.getOwnPropertyDescriptor(URL.prototype,`href`).get.call(e))})`;else if(e instanceof URLSearchParams)n=`URLSearchParams(${JSON.stringify(URLSearchParams.prototype.toString.call(e))})`;else if(Yh(e))n=`${qh(e)}(${jT(e.valueOf(),t)})`;else if(Jh(e))n=`${qh(e)}(${JSON.stringify(String(e))})`;else if(e instanceof Error){let r=e,i=Qh.filter(t=>G(e,t)).map(e=>`${e}:${jT(r[e],t)}`),a=Object.getPrototypeOf(e)?.constructor,o=typeof a==`function`?a.name:``;n=`Error(${JSON.stringify(o)},${i.join(`,`)})`}else return;let r=Object.keys(e);return r.length?`${n}${NT(e,r,t)}`:n}function NT(e,t,n){let r=e;return`{${t.map(e=>`${JSON.stringify(e)}:${jT(r[e],n)}`).join(`,`)}}`}function PT(e,t){if(!t.of)throw Error(`{for} requires \"of\" keyword: {for ${e}}`);let[n=``,r=null]=t.variables??[],i=t.list??``;if(!n.startsWith(`@`))throw Error(`{for} loop variable must use @ prefix: got \"${n}\"`);if(r&&!r.startsWith(`@`))throw Error(`{for} index variable must use @ prefix: got \"${r}\"`);return as(n.slice(1),n),r&&as(r.slice(1),r),{itemVar:n.slice(1),indexVar:r?r.slice(1):null,listExpr:i}}function FT({parentValues:e,itemVar:t,itemValue:n,indexVar:r,indexValue:i,children:a}){return q(Su,{body:a,parentValues:e,ownKeys:Fe(()=>({[t]:n,...r?{[r]:i}:void 0}),[t,n,r,i])})}$({name:`for`,block:!0,interpolate:!0,merged:!0,parameters:[{name:`variables`,type:`names`,required:!0},{name:`of`,type:`separator`},{name:`list`,type:`expression`,required:!0}],render({rawArgs:e,children:t=[]},n){let r=j(qp),i=n.hooks.useRef({contents:[],generations:[],next:0,edits:KC()}).current,a,o;try{a=PT(e,n.args);let t=n.evaluate(a.listExpr);if(!Array.isArray(t))return q(`span`,{class:`error`,children:`{for error: expression did not evaluate to an array}`});o=t}catch(e){return q(Up,{macro:`for`,error:e})}let{itemVar:s,indexVar:c}=a,l=qC(i.edits,wb());i.edits=KC();let u=o.map((e,t)=>{let n=AT(e);return(i.generations[t]===void 0||n!==i.contents[t]&&!l(o,e,t))&&(i.generations[t]=i.next++),i.contents[t]=n,i.generations[t]});i.contents.length=i.generations.length=o.length;let d=o.map((e,n)=>q(FT,{parentValues:r,itemVar:s,itemValue:e,indexVar:c,indexValue:n,children:t},`${n}-${u[n]}`));return n.wrap(q(UC.Provider,{value:!0,children:d}))},text({rawArgs:e,children:t=[]},n){let{itemVar:r,indexVar:i,listExpr:a}=PT(e,n.args),o=n.evaluate(a);if(!Array.isArray(o))throw Error(`expression did not evaluate to an array`);return o.map((e,a)=>n.renderText(t,{[r]:e,...i?{[i]:a}:void 0})).join(``)}}),$({name:`do`,block:!0,render({children:e=[]},t){let n=t.collectText(e);return Gp(`do`,``,()=>t.mutate(n))}});function IT(e){return new Proxy(K(),{get:(t,n)=>typeof n==`string`?os(e(),n):void 0,has:(t,n)=>typeof n==`string`&&G(e(),n),ownKeys:()=>Reflect.ownKeys(e()),getOwnPropertyDescriptor:(t,n)=>{let r=Object.getOwnPropertyDescriptor(e(),n);return r?{...r,configurable:!0}:void 0}})}var LT=_e({stop:()=>{}});$({name:`repeat`,block:!0,interpolate:!0,parameters:[uc],render({children:e=[]},t){let{useState:n,useEffect:r,useCallback:i,useContext:a}=t.hooks,o=t.args.delay??0,[s,c]=n(0),[l,u]=n(!1),d=a(fl),f=i(()=>u(!0),[]);if(r(()=>{if(l)return;let e=setInterval(()=>{d?.()||c(e=>e+1)},o);return()=>clearInterval(e)},[o,l]),s===0&&!l)return null;let p=q(LT.Provider,{value:{stop:f},children:q(`span`,{children:t.renderNodes(e)},s)});return t.className||t.id?q(`span`,{id:t.id,class:t.cls,children:p}):p}});var RT=()=>!0;function zT(){let e=j(Jp),{nobr:t,inline:n,structural:r}=xu(),i=j(sm),a=j(LT),o=j(mC),s=j(UC),c=j(fl),l=A([]);Ne(()=>{let e=jS(()=>{let e=l.current.splice(0);queueMicrotask(()=>{for(let t of e)ge(null,t)})});return()=>{e();for(let e of l.current.splice(0))ge(null,e)}},[]);let u=u=>{let d=IT(e.getValues),f=document.createElement(`div`);ge(q(dl.Provider,{value:RT,children:q(Jp.Provider,{value:e,children:q(qp.Provider,{value:d,children:q(Yp.Provider,{value:t,children:q(Zp.Provider,{value:n,children:q(Qp.Provider,{value:r,children:q(sm.Provider,{value:i,children:q(LT.Provider,{value:a,children:q(mC.Provider,{value:o,children:q(UC.Provider,{value:s,children:q(fl.Provider,{value:c,children:eh(u,{nobr:t,inline:n,structural:r,locals:d})})})})})})})})})})})}),f),l.current.push(f)};return e=>qb(()=>u(e))}$({name:`button`,block:!0,interpolate:!0,parameters:[{name:`label`,type:`text`,holds:`markup`,required:!0}],render({rawArgs:e,children:t=[]},n){let r=n.resolve?.(n.args.label??``)??e,i=zT(),a=()=>i(t);return n.useAction({type:`button`,key:e,authorId:n.id,label:r,perform:a}),q(`button`,{type:`button`,id:n.id,class:n.cls,onClick:a,children:r})}}),$({name:`link`,block:!0,interpolate:!0,merged:!0,parameters:[{name:`text`,type:`string`,holds:`markup`,required:!0},{name:`passage`,type:`passage`}],render({children:e=[]},t){let n=t.resolve?.(t.args.text??``)??``,r=null,i;if(t.args.passage!==void 0)try{r=pc(t.args.passage,t.evaluate,Q.getState())}catch(e){i={error:e}}let a=zT(),o=()=>{i||(a(e),r&&Q.getState().navigate(r))};return t.useAction({type:`link`,key:r||n,authorId:t.id,label:n,target:r??void 0,disabled:i?!0:void 0,perform:o}),i?q(Up,{macro:`link`,error:i.error}):q(`a`,{id:t.id,class:t.cls,href:`#`,onClick:e=>{e.preventDefault(),o()},children:n})}});function BT(e,t,n){return DT(t.slice(1),t=>e===n(t))}$({name:`switch`,subMacros:[`case`,`default`],parameters:[{name:`expression`,type:`expression`,required:!0}],interpolate:!0,merged:!0,render({rawArgs:e,branches:t=[]},n){let r;try{r=n.evaluate(e)}catch(e){return q(Up,{macro:`switch`,error:e})}let i;try{i=BT(r,t,n.evaluate)}catch(e){return q(Up,{macro:`case`,error:e})}return i?OT(i,n):null},text({rawArgs:e,branches:t=[]},n){let r=BT(n.evaluate(e),t,n.evaluate);return r?n.renderText(r.children):``}});var VT=[uc];$({name:`timed`,subMacros:[`next`],interpolate:!0,parameters:VT,render({branches:e=[]},t){let{useState:n,useEffect:r,useMemo:i,useContext:a}=t.hooks,o=a(fl),s=i(()=>e.map(e=>({delay:dc(e.rawArgs,VT).delay??0,nodes:e.children,className:e.className,id:e.id})),[e]),[c,l]=n(-1);if(r(()=>{if(c>=s.length-1)return;let e=c+1,t=s[e].delay,n=setTimeout(()=>{o?.()||l(e)},t);return()=>clearTimeout(n)},[c,s]),c<0)return t.wrap(null);let u=s[c];return t.wrap(eu(t.resolve(u.className),t.resolve(u.id),t.renderNodes(u.nodes)))}}),$({name:`stop`,render(e,t){let{stop:n}=t.hooks.useContext(LT);return t.hooks.useLayoutEffect(()=>{n()},[n]),null}});function HT(e,t,n){let r=document.createRange();if(!r.getClientRects)return;let i=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),a=n,o;for(let e=i.nextNode();e&&a>0;e=i.nextNode()){let t=e.nodeValue?.length??0;o={node:e,offset:Math.min(a,t)},a-=t}if(!o)return`inset(0 100% 0 0)`;r.setStart(e,0),r.setEnd(o.node,o.offset);let s=r.getClientRects();if(s.length===0)return;let c=t.getBoundingClientRect(),l=``;for(let e of Array.from(s)){if(e.width===0&&e.height===0)continue;let t=(e.left-c.left).toFixed(2),n=(e.top-c.top).toFixed(2);l+=`M${t} ${n}h${e.width.toFixed(2)}v${e.height.toFixed(2)}h-${e.width.toFixed(2)}z`}return l?`path(\"${l}\")`:void 0}$({name:`type`,block:!0,interpolate:!0,parameters:[uc],render({children:e=[]},t){let{useState:n,useEffect:r,useLayoutEffect:i,useRef:a}=t.hooks,o=t.args.delay??0,s=a(null),c=a(null),[l,u]=n(),[d,f]=n(null),p=d??0,[m,h]=n(0),g=a(0);g.current=m,r(()=>{s.current&&f((s.current.textContent||``).length)}),r(()=>{if(p===0||g.current>=p)return;let e=setInterval(()=>{h(t=>t>=p?(clearInterval(e),t):t+1)},o);return()=>clearInterval(e)},[p,o]);let _=d!==null&&m>=p;i(()=>{let e=s.current,t=c.current;if(!e||!t||p===0||_){u(void 0);return}let n=()=>u(HT(e,t,m));return n(),window.addEventListener(`resize`,n),()=>window.removeEventListener(`resize`,n)},[m,p,_]);let v=[`macro-type`,_?`macro-type-done`:``,t.className||``].filter(Boolean).join(` `);return q(`span`,{id:t.id,class:v,ref:s,children:[q(`span`,{ref:c,class:`macro-type-inner`,style:{display:`inline`,visibility:d===null?`hidden`:`visible`,clipPath:l},children:t.renderInlineNodes(e)}),!_&&p>0&&q(`span`,{class:`macro-type-cursor`})]})}}),$({name:`widget`,block:!0,parameters:el,render({children:e=[]},t){let n,r;try{let e=tl(t.args);for(let t of e.params)as(t.slice(1),t);n=e}catch(e){r=e}let{name:i,params:a}=n??{name:``,params:[]},o=JSON.stringify(e),s=a.join(`,`);return t.hooks.useLayoutEffect(()=>{n&&il(n,e)},[i,o,s]),r?q(Up,{macro:`widget`,error:r}):null}}),$({name:`story-title`,render(e,t){let n=Q(e=>e.storyData?.name||``),r=t.className?`story-title ${t.className}`:`story-title`;return q(`span`,{id:t.id,class:r,children:n})},text:()=>Q.getState().storyData?.name||``});function UT(e,t){return t?`${e} (${t})`:e}function WT(e){$({name:e.name,render(t,n){if(e.hidden?.())return null;let[r,i]=je(!1),a=e.setup?.()??{perform:()=>{}},{disabled:o,title:s=e.title}=a,c=n.className?`menubar-button ${n.className}`:`menubar-button`,l=e.dialog?()=>i(!0):e.confirm?()=>{confirm(e.confirm)&&a.perform()}:a.perform;return n.useAction({type:e.actionType,key:e.name,authorId:n.id,label:typeof e.label==`string`?e.label:e.name,disabled:o,perform:e.dialog?()=>i(!0):a.perform}),q(S,{children:[q(`button`,{type:`button`,id:n.id,class:c,onClick:l,disabled:o,title:s,children:e.label}),e.dialog&&r&&q(hC,{passageName:e.dialog.passageName,fallbackMarkup:e.dialog.fallbackMarkup,panelClass:e.dialog.panelClass,onClose:()=>i(!1),showCloseButton:e.dialog.showCloseButton})]})}})}WT({name:`back`,label:`← Back`,actionType:`back`,setup:()=>({perform:Q(e=>e.goBack),disabled:!Q(e=>e.historyIndex>0)})}),WT({name:`forward`,label:`Forward →`,actionType:`forward`,setup:()=>({perform:Q(e=>e.goForward),disabled:!Q(e=>e.historyIndex<e.history.length-1)})}),WT({name:`quicksave`,label:`QuickSave`,actionType:`save`,setup:()=>{let{quickSaveKey:e}=pl(`quickSaveKey`);return{perform:vC,title:UT(`Quick Save`,e)}}}),WT({name:`quickload`,label:`QuickLoad`,actionType:`load`,confirm:`Load saved game? Current progress will be lost.`,setup:()=>{let{hasSave:e,quickLoadKey:t}=pl(`hasSave`,`quickLoadKey`,`knownSaves`);return{perform:yC,disabled:!e(),title:UT(`Quick Load`,t)}}}),WT({name:`restart`,label:`↺ Restart`,actionType:`restart`,confirm:`Restart the story? All progress will be lost.`,setup:()=>({perform:Q(e=>e.restart)})}),WT({name:`saves`,label:`Saves`,actionType:`dialog`,dialog:{passageName:`SaveLoad`,fallbackMarkup:`{save-manager}`,panelClass:`dialog-saves`}}),WT({name:`settings`,label:`Settings`,actionType:`dialog`,hidden:()=>!LC.hasAny(),dialog:{passageName:`Settings`,fallbackMarkup:`{settings-controls}`,panelClass:`dialog-settings`}}),$({name:`dialog`,block:!0,interpolate:!0,parameters:[{name:`label`,type:`text`,holds:`markup`,required:!0},{name:`noclose`,type:`flag`}],render({children:e=[]},t){let[n,r]=t.hooks.useState(!1),{noclose:i}=t.args,a=t.resolve(t.args.label??``),o=t.collectText(e).trim().replace(/^[\"']|[\"']$/g,``);return q(S,{children:[q(`button`,{type:`button`,id:t.id,class:t.cls,onClick:()=>r(!0),children:a}),n&&q(hC,{passageName:o,onClose:()=>r(!1),showCloseButton:!i})]})}});function GT(e){let t=Date.now()-new Date(e).getTime(),n=Math.floor(t/1e3);if(n<60)return`just now`;let r=Math.floor(n/60);if(r<60)return`${r}m ago`;let i=Math.floor(r/60);if(i<24)return`${i}h ago`;let a=Math.floor(i/24);return a<30?`${a}d ago`:new Date(e).toLocaleDateString()}function KT(e){return new Date(e).toLocaleDateString(void 0,{month:`short`,day:`numeric`,year:`numeric`})}function qT(){let[e,t]=je(`load`),[n,r]=je([]),[i,a]=je(!0),[o,s]=je(null),[c,l]=je(()=>new Set),[u,d]=je(null),f=A(!1),[p,m]=je(``),h=A(null),g=A(null),_=j(mC),{storyData:v,playthroughId:y,beginSave:b,loadFromPayload:x}=pl(`storyData`,`playthroughId`,`beginSave`,`loadFromPayload`),S=v?.ifid??``,[C,w]=je(!1),T=Ie(async()=>{if(!S)return;let e=await by(S);w(B_()===`memory`),r(e),a(!1)},[S]);Ne(()=>{T()},[T]),Ne(()=>S?Vy(S,T,!0):void 0,[S,T]),Ne(()=>{u&&h.current&&(h.current.focus(),h.current.select())},[u]);let ee=A(!0),E=A(),D=A(),te=(e,t=`success`)=>{ee.current&&(clearTimeout(E.current),s({text:e,type:t}),E.current=window.setTimeout(()=>s(null),3e3))};Ne(()=>(ee.current=!0,()=>{ee.current=!1,clearTimeout(E.current),clearTimeout(D.current)}),[]);let ne=e=>{l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},re=async()=>{if(!S)return;let e=hS();try{await ly(void 0,void 0,b,async t=>dy(S,e,t)),te(C?`Save created (temporary)`:`Save created`),await T()}catch{te(`Failed to create save`,`error`)}},ie=async e=>{let t=hS();try{await ly(void 0,void 0,b,async n=>{if(!await py(e,n,void 0,t))throw Error(`Save not found`)}),te(`Save overwritten`),await T()}catch{te(`Failed to overwrite save`,`error`)}},O=async e=>{let t=ES();try{let n=await _y(e.meta.id)??e;if(DS(t))return;x(gy(n.payload),void 0,n.meta.playthroughId),te(`Game loaded`),_&&(D.current=window.setTimeout(_,500)),await T()}catch{te(`Failed to load save`,`error`)}},ae=async(e,t,n)=>{try{await n(),te(e),await T()}catch{te(t,`error`)}},oe=async e=>{confirm(`Delete this save?`)&&await ae(`Save deleted`,`Failed to delete save`,async()=>{await vy(e);let t=await qy(S);Q.setState(e=>{e.knownSaves=t})})},se=e=>{f.current=!1,d(e.meta.id),m(e.meta.title)},ce=async()=>{let e=u;!e||!p.trim()||await ae(`Save renamed`,`Failed to rename`,async()=>{await yy(e,p.trim()),d(t=>t===e?null:t)})},le=e=>{e.key===`Enter`?ce():e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),f.current=!0,d(null))},ue=()=>{f.current||ce()},de=async e=>{try{let t=await sb(e);if(!t)return;let n=new Blob([JSON.stringify(t,null,2)],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`save-${t.save.meta.title.replace(/[^a-z0-9]/gi,`_`)}.json`,i.click(),URL.revokeObjectURL(r),te(`Save exported`)}catch{te(`Failed to export save`,`error`)}},fe=()=>{g.current?.click()},pe=async e=>{let t=e.target,n=t.files?.[0];if(n){t.value=``;try{let e=await n.text(),t=JSON.parse(e);if(!h_(t))throw Error(`Invalid save file format`);await lb(t,S),te(`Save imported`),await T()}catch(e){te(xs(e,`Failed to import save`),`error`)}}},me=n.reduce((e,t)=>e+t.saves.length,0);return q(`div`,{class:`save-manager`,children:[q(`div`,{class:`saves-header`,children:q(`div`,{class:`saves-header-left`,children:q(`div`,{class:`saves-mode-toggle`,children:[q(`button`,{type:`button`,class:e===`save`?`active`:``,onClick:()=>t(`save`),children:`Save`}),q(`button`,{type:`button`,class:e===`load`?`active`:``,onClick:()=>t(`load`),children:`Load`})]})})}),C&&q(`div`,{class:`saves-notice`,role:`status`,children:`Saves can not be kept in this browser: they are lost when the page is reloaded or closed. Export a save to keep it.`}),q(`div`,{class:`saves-toolbar`,children:[q(`button`,{type:`button`,class:`saves-toolbar-button`,onClick:fe,children:`Import`}),q(`input`,{ref:g,type:`file`,accept:`.json`,style:`display:none`,onChange:pe})]}),q(`div`,{class:`saves-body`,children:[i?q(`div`,{class:`saves-empty`,children:`Loading...`}):me===0&&e===`load`?q(`div`,{class:`saves-empty`,children:`No saves yet`}):n.map(t=>{let n=c.has(t.playthrough.id),r=t.playthrough.id===y;return e===`save`&&!r||e===`load`&&t.saves.length===0&&!r?null:q(`div`,{class:`playthrough-group`,children:[q(`button`,{type:`button`,class:`playthrough-header`,\"aria-expanded\":!n,onClick:()=>ne(t.playthrough.id),children:[q(`span`,{class:`playthrough-chevron ${n?``:`open`}`,\"aria-hidden\":`true`,children:`▶`}),q(`span`,{class:`playthrough-label`,children:[t.playthrough.label,r?` (current)`:``]}),q(`span`,{class:`playthrough-date`,children:KT(t.playthrough.createdAt)})]}),!n&&q(`div`,{class:`playthrough-saves`,children:[t.saves.map(t=>q(`div`,{class:`save-slot`,children:[q(`div`,{class:`save-slot-info`,children:[u===t.meta.id?q(`input`,{ref:h,class:`save-rename-input`,value:p,onInput:e=>m(e.target.value),onKeyDown:le,onBlur:ue}):q(`div`,{class:`save-slot-title`,children:t.meta.title}),q(`div`,{class:`save-slot-meta`,children:[q(`span`,{children:t.meta.passage}),q(`span`,{children:GT(t.meta.updatedAt)})]})]}),q(`div`,{class:`save-slot-actions`,children:[e===`save`?q(`button`,{type:`button`,class:`save-slot-action primary`,onClick:()=>ie(t.meta.id),children:`Save Here`}):q(`button`,{type:`button`,class:`save-slot-action primary`,onClick:()=>O(t),children:`Load`}),q(`button`,{type:`button`,class:`save-slot-action`,onClick:()=>se(t),children:`Rename`}),q(`button`,{type:`button`,class:`save-slot-action`,onClick:()=>de(t.meta.id),children:`Export`}),q(`button`,{type:`button`,class:`save-slot-action danger`,onClick:()=>oe(t.meta.id),children:`Delete`})]})]},t.meta.id)),e===`save`&&r&&q(`button`,{type:`button`,class:`save-slot-new`,onClick:re,children:`+ New Save`})]})]},t.playthrough.id)}),e===`save`&&!i&&!n.some(e=>e.playthrough.id===y)&&q(`div`,{class:`playthrough-group`,children:q(`div`,{class:`playthrough-saves`,children:q(`button`,{type:`button`,class:`save-slot-new`,onClick:re,children:`+ New Save`})})})]}),o&&q(`div`,{class:`saves-status ${o.type===`error`?`error`:``}`,children:o.text})]})}$({name:`save-manager`,render(){return q(qT,{})}});function JT({name:e,def:t}){let[n,r]=je(()=>LC.get(e)),i=t=>{r(t),LC.set(e,t)};switch(t.type){case`toggle`:return q(`label`,{class:`settings-row`,children:[q(`span`,{children:t.config.label}),q(`input`,{type:`checkbox`,checked:!!n,onChange:e=>i(e.target.checked)})]});case`list`:return q(`label`,{class:`settings-row`,children:[q(`span`,{children:t.config.label}),q(`select`,{value:String(n),onChange:e=>i(e.target.value),children:t.config.options.map(e=>q(`option`,{value:e,children:e},e))})]});case`range`:return q(`label`,{class:`settings-row`,children:[q(`span`,{children:[t.config.label,`: `,String(n)]}),q(`input`,{type:`range`,min:t.config.min,max:t.config.max,step:t.config.step,value:Number(n),onInput:e=>i(parseFloat(e.target.value))})]})}}function YT(){let e=LC.getDefinitions();return q(`div`,{class:`settings-controls`,children:Array.from(e.entries()).map(([e,t])=>q(JT,{name:e,def:t},e))})}$({name:`settings-controls`,render(){return q(YT,{})}}),$({name:`include`,interpolate:!0,merged:!0,parameters:[{name:`inline`,type:`flag`},{name:`passage`,type:`passage`,required:!0}],render(e,t){let{storyData:n}=pl(`storyData`),{inline:r}=t.args,i=``,a;try{i=pc(t.args.passage,t.evaluate,Q.getState())}catch(e){a={error:e}}let o=n?.passages.get(i),s=t.hooks.useMemo(()=>o?$o(o.content):null,[o]),c=!a&&!!o;if(t.hooks.useEffect(()=>{c&&Q.getState().trackRender(i)},[c,i]),!n)return null;if(a)return q(Up,{macro:`include`,error:a.error});if(!o||!s)return null;let l=o.tags.includes(`nobr`),u=r?t.renderInlineNodes(s):t.renderNodes(s,l?{nobr:!0}:void 0);return l?t.wrap(t.h(Yp.Provider,{value:!0},u)):t.wrap(u)}}),$({name:`nobr`,block:!0,render({children:e=[]},t){return t.wrap(t.h(Yp.Provider,{value:!0},t.renderNodes(e,{nobr:!0})))},text:({children:e=[]},t)=>t.renderText(e)}),$({name:`goto`,merged:!0,parameters:[{name:`passage`,type:`passage`,required:!0}],render(e,t){let[n,r]=t.hooks.useState();return t.hooks.useLayoutEffect(()=>{let e=t.sourceLocation();try{let e=Q.getState();e.navigate(pc(t.args.passage,t.evaluate,e))}catch(t){Wp(`goto`,t,e),r({error:t})}},[]),n?q(Up,{macro:`goto`,error:n.error}):null}}),$({name:`unset`,parameters:[{name:`variable`,type:`variable`,required:!0}],render({rawArgs:e},t){return Gp(`unset`,e,()=>{let e=Q.getState(),n=t.args.variable??``;if(/^[$_%@][^.]*\\./.test(n))t.mutate(`delete ${n}`);else if(n.startsWith(`$`))e.deleteVariable(n.slice(1));else if(n.startsWith(`_`))e.deleteTemporary(n.slice(1));else if(n.startsWith(`%`))e.deleteTransient(n.slice(1));else if(n.startsWith(`@`))t.update(n.slice(1),void 0);else throw Error(`{unset} expects a variable ($name, _name, %name, or @name), got \"${n}\"`)})}});var XT={name:`variable`,type:`variable`,required:!0};function ZT(e,t){return e.useAction({key:`$${e.varName}`,authorId:e.id,variable:e.varName,value:e.value,...t})}function QT(e,t,n=e=>e===void 0?``:String(e)){$({name:e,storeVar:!0,parameters:[XT,{name:`placeholder`,type:`string`,holds:`text`}],render(r,i){let a=i.args.placeholder??``;ZT(i,{type:e,label:a||i.varName,perform:e=>i.setValue(n(e))});let o=i.hooks.useRef(null),s=o.current!==null&&n(o.current)===i.value&&t===`number`?o.current:$l(i.value);return b(t?`input`:`textarea`,{type:t,id:i.id,class:i.cls,value:s,placeholder:a,onInput:e=>{let t=e.target.value;o.current=t,i.setValue(n(t))}})}})}QT(`textbox`,`text`),QT(`numberbox`,`number`,e=>e===void 0?0:Number(e)),QT(`textarea`),$({name:`checkbox`,storeVar:!0,parameters:[XT,{name:`label`,type:`text`,holds:`text`}],render(e,t){let n=t.args.label??``;return ZT(t,{type:`checkbox`,label:n||t.varName||``,value:!!t.value,perform:e=>t.setValue(e===void 0?!t.value:!!e)}),q(`label`,{id:t.id,class:t.cls,children:[q(`input`,{type:`checkbox`,checked:!!t.value,onChange:()=>t.setValue(!t.value)}),n?` ${n}`:null]})}}),$({name:`radiobutton`,storeVar:!0,parameters:[XT,{name:`value`,type:`text`,holds:`text`,required:!0},{name:`label`,type:`text`,holds:`text`}],render(e,t){let n=t.args.value??``,r=t.args.label??``,i=t.hooks.useContext(em);return ZT(t,{type:`radiobutton`,key:`$${t.varName}:${n}`,label:r||n,perform:()=>t.setValue(n)}),q(`label`,{id:t.id,class:t.cls,children:[q(`input`,{type:`radio`,name:i?`radio-${i}-${t.varName}`:`radio-${t.varName}`,checked:t.value===n,onChange:()=>t.setValue(n)}),r?` ${r}`:null]})}}),$({name:`listbox`,subMacros:[`option`],storeVar:!0,parameters:[XT],render({children:e=[]},t){let n=t.extractOptions(e);return ZT(t,{type:`listbox`,label:t.varName,options:n,perform:e=>{e!==void 0&&t.setValue(String(e))}}),q(`select`,{id:t.id,class:t.cls,value:$l(t.value),onChange:e=>t.setValue(e.target.value),children:n.map(e=>q(`option`,{value:e,children:e},e))})}}),$({name:`cycle`,block:!0,storeVar:!0,parameters:[XT],render({children:e=[]},t){let n=t.extractOptions(e),r=()=>{if(n.length===0)return;let e=t.getValue(),r=(n.indexOf(String(e))+1)%n.length;t.setValue(n[r])};return ZT(t,{type:`cycle`,label:t.value==null?n[0]||``:String(t.value),options:n,perform:e=>{e===void 0?r():t.setValue(e)}}),q(`button`,{type:`button`,id:t.id,class:t.cls,onClick:r,children:t.value==null?n[0]||``:String(t.value)})}}),$({name:`span`,block:!0,render({children:e=[]},t){return t.wrap(t.renderNodes(e))},text:({children:e=[]},t)=>t.renderText(e)}),$({name:`watch`,parameters:[{name:`condition`,type:`string`,holds:`expression`,required:!0},{name:`options`,type:`options`,parameters:[{name:`goto`,type:`string`,holds:`passage`},{name:`dialog`,type:`string`,holds:`passage`},{name:`run`,type:`string`,holds:`statements`},{name:`name`,type:`string`,holds:`text`},{name:`priority`,type:`number`},{name:`once`,type:`flag`}]}],render(e,t){let{hooks:n}=t,{condition:r,options:i}=t.args;if(r===void 0)return null;let a=n.useContext(dl),[,o]=n.useState(0);n.useEffect(()=>Ex(()=>o(e=>e+1)),[]);let s=n.useContext(Xp),c=JSON.stringify([r,i]);n.useLayoutEffect(()=>s?lx(r,i):void 0,[s,c]);let l=n.useRef(null);return(l.current===null||l.current!==Tx()&&!a?.(Q.getState()))&&(l.current=Tx(),ax(r,i)),null}}),$({name:`unwatch`,parameters:[{name:`name`,type:`text`,holds:`text`,required:!0}],render(e,t){let n=t.args.name??``,r=t.hooks.useRef(!1);return r.current||(r.current=!0,px(n)),null}});var $T=`*,:before,:after{box-sizing:border-box}html{-webkit-text-size-adjust:100%;font-size:16px}body{color:#e0e0e0;background-color:#1a1a2e;min-height:100vh;margin:0;padding:0;font-family:Georgia,Times New Roman,serif;line-height:1.75}tw-storydata{display:none!important}#story{max-width:42em;margin:0 auto;padding:2em 1.5em}.passage-container{position:relative}.passage-container--crossfading{display:grid}.passage-container--crossfading>*{grid-area:1/1}.passage{animation:passage-fade-in var(--passage-in-duration,.3s) ease}.passage[data-transition=none]{animation:none}.passage-snapshot{animation:passage-fade-out var(--passage-out-duration,.3s) ease forwards;pointer-events:none;-webkit-user-select:none;user-select:none}@keyframes passage-fade-in{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}@keyframes passage-fade-out{0%{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(-8px)}}@media (prefers-reduced-motion:reduce){.passage,.passage-snapshot{animation-duration:10ms!important}}.macro-button{color:#64b5f6;font:inherit;cursor:pointer;background:#64b5f626;border:1px solid #64b5f666;border-radius:4px;padding:.25em .75em;font-size:.95em;transition:background .2s,border-color .2s}.macro-button:hover{background:#64b5f640;border-color:#90caf9}.macro-button:active{background:#64b5f659}.error{color:#ef5350;background:#ef53501a;border:1px solid #ef5350;border-radius:4px;padding:1em;font-family:monospace}.spindle-error-banners{z-index:300;flex-direction:column;gap:.5em;width:min(42em,100% - 1.5em);display:flex;position:fixed;top:.75em;left:50%;transform:translate(-50%)}.spindle-error-banner{color:#ffcdd2;background:#2b1a1e;border:1px solid #ef5350;border-radius:4px;padding:.75em 2.75em .75em 1em;font-size:.9em;line-height:1.5;position:relative;box-shadow:0 2px 12px #00000080}.spindle-error-banner-message{color:#ef9a9a;font-family:monospace}.spindle-error-banner-dismiss{color:inherit;cursor:pointer;background:0 0;border:none;font-size:1em;position:absolute;top:.5em;right:.5em}.spindle-error-banner-dismiss:hover{color:#fff}.loading{text-align:center;opacity:.6;padding:2em}.story-menubar{z-index:100;background:#16213e;border-bottom:1px solid #ffffff14;align-items:center;gap:.5em;padding:.5em 1.5em;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Noto Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;font-size:.9em;display:flex;position:sticky;top:0}@media (max-width:600px){.story-menubar{flex-wrap:wrap;padding:.5em .75em}.story-menubar .story-title{flex:100%}}.story-title{color:#e0e0e0;white-space:nowrap;text-overflow:ellipsis;flex:1;font-weight:600;overflow:hidden}.menubar-button{color:#9e9e9e;cursor:pointer;font:inherit;background:0 0;border:1px solid #0000;border-radius:4px;padding:.35em .7em;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:0 0}.dialog-overlay{z-index:200;background:#0009;justify-content:center;align-items:center;display:flex;position:fixed;top:0;bottom:0;left:0;right:0}.dialog-panel{color:#e0e0e0;background:#16213e;border:1px solid #ffffff1a;border-radius:8px;flex-direction:column;width:90%;max-width:500px;max-height:80vh;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Noto Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;display:flex;position:relative}.dialog-panel:focus{outline:none}.dialog-saves{max-width:550px}.dialog-settings{max-width:400px}.dialog-settings .dialog-body{padding-top:2.25em}.dialog-close{z-index:1;color:#9e9e9e;cursor:pointer;background:0 0;border:none;padding:.25em;font-size:1.1em;line-height:1;position:absolute;top:.75em;right:.75em}.dialog-close:hover{color:#e0e0e0}.dialog-body{flex:1;min-height:0;overflow-y:auto}.settings-controls{flex-direction:column;gap:1em;padding:1em 1.25em;display:flex}.settings-row{justify-content:space-between;align-items:center;gap:1em;display:flex}.settings-row select,.settings-row input[type=range]{accent-color:#64b5f6}.settings-row select{color:#e0e0e0;font:inherit;background:#1a1a2e;border:1px solid #ffffff26;border-radius:4px;padding:.3em .5em}.settings-row input[type=checkbox]{accent-color:#64b5f6;width:1.1em;height:1.1em}.save-manager{flex-direction:column;flex:1;min-height:0;display:flex}.saves-header{border-bottom:1px solid #ffffff14;flex-shrink:0;justify-content:space-between;align-items:center;padding:1em 3em 1em 1.25em;font-weight:600;display:flex}.saves-header-left{align-items:center;gap:.75em;display:flex}.saves-mode-toggle{border:1px solid #ffffff26;border-radius:4px;gap:0;display:flex;overflow:hidden}.saves-mode-toggle button{color:#9e9e9e;font:inherit;cursor:pointer;background:0 0;border:none;padding:.3em .8em;font-size:.85em;font-weight:600;transition:background .2s,color .2s}.saves-mode-toggle button.active{color:#64b5f6;background:#64b5f633}.saves-mode-toggle button:hover:not(.active){color:#e0e0e0}.saves-body{flex:1;min-height:0;padding:.75em 1.25em;overflow-y:auto}.saves-empty{text-align:center;opacity:.5;padding:2em 1em;font-size:.9em}.saves-toolbar{border-bottom:1px solid #ffffff14;flex-shrink:0;gap:.5em;padding:.5em 1.25em;display:flex}.saves-toolbar-button{color:#9e9e9e;font:inherit;cursor:pointer;background:#ffffff0d;border:1px solid #ffffff1a;border-radius:4px;padding:.3em .7em;font-size:.8em;transition:background .2s,color .2s}.saves-toolbar-button:hover{color:#e0e0e0;background:#ffffff1a}.playthrough-group{margin-bottom:.75em}.playthrough-header{text-align:left;cursor:pointer;-webkit-user-select:none;user-select:none;color:#9e9e9e;background:0 0;border:0;align-items:center;gap:.5em;width:100%;padding:.4em 0;font-family:inherit;font-size:.85em;transition:color .2s;display:flex}.playthrough-header:hover{color:#e0e0e0}.playthrough-chevron{font-size:.7em;transition:transform .2s;display:inline-block}.playthrough-chevron.open{transform:rotate(90deg)}.playthrough-label{font-weight:600}.playthrough-date{opacity:.6;font-size:.9em}.playthrough-saves{flex-direction:column;gap:.4em;padding-left:.25em;display:flex}.save-slot{background:#ffffff08;border:1px solid #ffffff0f;border-radius:6px;align-items:center;gap:.75em;padding:.5em .6em;transition:background .15s;display:flex}.save-slot:hover{background:#ffffff0f}.save-slot-info{flex:1;min-width:0}.save-slot-title{white-space:nowrap;text-overflow:ellipsis;font-size:.9em;font-weight:500;overflow:hidden}.save-slot-meta{color:#9e9e9e;gap:.75em;font-size:.75em;display:flex}.save-slot-actions{flex-shrink:0;gap:.3em;display:flex}.save-slot-action{color:#9e9e9e;font:inherit;cursor:pointer;white-space:nowrap;background:0 0;border:1px solid #0000;border-radius:3px;padding:.2em .5em;font-size:.75em;transition:color .2s,background .2s}.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{color:#9e9e9e;font:inherit;cursor:pointer;background:0 0;border:1px dashed #ffffff1f;border-radius:6px;justify-content:center;align-items:center;width:100%;margin-top:.25em;padding:.5em;font-size:.8em;transition:color .2s,border-color .2s,background .2s;display:flex}.save-slot-new:hover{color:#64b5f6;background:#64b5f60d;border-color:#64b5f64d}.saves-notice{color:#ffb74d;background:#ffb74d14;border-bottom:1px solid #ffb74d4d;flex-shrink:0;padding:.5em 1.25em;font-size:.8em}.saves-status{color:#81c784;text-align:center;border-top:1px solid #ffffff14;flex-shrink:0;padding:.5em 1.25em;font-size:.8em}.saves-status.error{color:#ef5350;background:0 0;border:none;border-radius:0;padding:.5em 1.25em;font-family:inherit}.save-rename-input{color:#e0e0e0;font:inherit;background:#1a1a2e;border:1px solid #64b5f666;border-radius:3px;width:100%;padding:.15em .4em;font-size:.9em}.save-rename-input:focus{border-color:#64b5f6;outline:none}.macro-link{color:#64b5f6;cursor:pointer;border-bottom:1px solid #64b5f64d;text-decoration:none;transition:color .2s,border-color .2s}.macro-link:hover{color:#90caf9;border-bottom-color:#90caf9}.macro-link:active{color:#42a5f5}.macro-textbox,.macro-numberbox,.macro-textarea{color:#e0e0e0;font:inherit;background:#1a1a2e;border:1px solid #ffffff26;border-radius:4px;padding:.3em .5em}.macro-textbox:focus,.macro-numberbox:focus,.macro-textarea:focus{border-color:#64b5f6;outline:none}.macro-textarea{resize:vertical;min-height:3em}.macro-checkbox,.macro-radiobutton{cursor:pointer;align-items:center;gap:.3em;display:inline-flex}.macro-checkbox input,.macro-radiobutton input{accent-color:#64b5f6}.macro-listbox{color:#e0e0e0;font:inherit;background:#1a1a2e;border:1px solid #ffffff26;border-radius:4px;padding:.3em .5em}.macro-cycle{color:#64b5f6;font:inherit;cursor:pointer;background:#64b5f626;border:1px solid #64b5f666;border-radius:4px;padding:.25em .75em;transition:background .2s,border-color .2s}.macro-cycle:hover{background:#64b5f640;border-color:#90caf9}.macro-meter{background:#2a2a3e;border:1px solid #444;border-radius:.3em;width:100%;height:1.4em;position:relative;overflow:hidden}.macro-meter-fill{background:#64b5f6;height:100%;transition:width .3s}.macro-meter-label{color:#e0e0e0;text-shadow:0 1px 2px #000c;pointer-events:none;justify-content:center;align-items:center;font-size:.85em;display:flex;position:absolute;top:0;bottom:0;left:0;right:0}.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{color:#f0f0f0;margin:1em 0 .4em;line-height:1.3}.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{opacity:.8;font-size:.9em}.passage code{background:#ffffff14;border-radius:3px;padding:.15em .35em;font-family:Fira Code,Cascadia Code,Consolas,monospace;font-size:.9em}.passage pre{background:#0000004d;border:1px solid #ffffff14;border-radius:6px;margin:.8em 0;padding:1em;overflow-x:auto}.passage pre code{background:0 0;border-radius:0;padding:0;font-size:.85em}.passage blockquote{color:#b0b0b0;border-left:3px solid #64b5f680;margin:.8em 0;padding:.4em 1em}.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 #ffffff1f;margin:1.2em 0}.passage table{border-collapse:collapse;width:100%;margin:.8em 0}.passage th,.passage td{text-align:left;border:1px solid #ffffff1f;padding:.5em .75em}.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:\"█\";color:#64b5f6;animation:.7s step-end infinite type-blink}.macro-type-done .macro-type-cursor:after{display:none}@keyframes type-blink{50%{opacity:0}}`;function eE(e,t){e.innerHTML=``;let n=document.createElement(`div`);n.style.cssText=`font-family:monospace;padding:2rem;max-width:60rem;margin:0 auto`;let r=document.createElement(`h1`);r.style.color=`#c00`,r.textContent=`Story Validation Errors`,n.appendChild(r);let i=document.createElement(`ul`);i.style.cssText=`line-height:1.6`;for(let e of t){let t=document.createElement(`li`);t.textContent=e,i.appendChild(t)}n.appendChild(i),e.appendChild(n)}function tE(e){let t=document.getElementById(`root`);throw t&&eE(t,e),Error(`spindle: ${e.length} validation error(s):\\n${e.join(`\n`)}`)}function nE(e,t){let n=Yc().filter(e=>e.storeVar).map(e=>e.name);return eT(e.passages,t,n)}function rE(e,t){let n=Yc();return Fw(e.passages.values(),{isKnownMacro:e=>!!Fc(e)||Vc(e)||!!ys(e),macroNames:n.map(e=>e.name),parametersOf:Ec(n),only:t}).map(kw)}function iE(){let e=DC(),t=document.createElement(`style`);if(t.id=`spindle-styles`,t.textContent=$T,document.head.appendChild(t),Tw(),e.userCSS){let t=document.createElement(`style`);t.textContent=e.userCSS,document.head.appendChild(t)}if(e.userScript)try{Function(e.userScript)()}catch(e){console.error(`spindle: Error in story JavaScript:`,e)}document.dispatchEvent(new CustomEvent(`:storystartup`));let n={},r=e.passages.get(`StoryVariables`);if(!r){let e=`Missing StoryVariables passage. Add a :: StoryVariables passage to declare your variables.`,t=document.getElementById(`root`);throw t&&eE(t,[e]),Error(`spindle: ${e}`)}let i=Uw(r.content);for(let t of rl(e.passages.values()))wr(t);let a=nE(e,i);a.push(...rE(e,e=>e.name===`StoryInit`));let o={},s=e.passages.get(`StoryTransients`);if(s){let e=Uw(s.content,`%`);for(let t of e.keys())i.has(t)&&a.push(`StoryTransients: Variable \"${t}\" is already declared in StoryVariables. Names must be unique across scopes.`);o=tT(e)}a.length>0&&tE(a),n=tT(i),yw(Object.keys(n),Object.keys(o)),Q.getState().init(e,n,o),FS();for(let[,t]of e.passages)t.tags.includes(`widget`)&&al($o(t.content),t.name);bb(tb(e.ifid));let c=[...nE(e,i),...rE(e,e=>e.name!==`StoryInit`)];c.length>0&&tE(c);let l=Q.getState().navigationId;Q.subscribe(e=>{e.navigationId!==l&&(l=e.navigationId,nw())}),bx();let u=e.passages.get(`StoryInterface`);u&&!u.content.includes(`{passage}`)&&console.warn(`spindle: StoryInterface passage does not contain {passage}. The current passage will not be displayed.`);let d=document.getElementById(`root`);if(!d)throw Error(`spindle: No <div id=\"root\"> element found.`);ge(q(bC,{}),d);let f=pw();f?f.then(yT).then(()=>{document.dispatchEvent(new CustomEvent(`:storyready`))}):document.dispatchEvent(new CustomEvent(`:storyready`))}document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,iE):iE();</script>\n </head>\n <body>\n <div id=\"root\"></div>\n {{STORY_DATA}}\n </body>\n</html>\n"})
1
+ window.storyFormat({"name":"spindle","version":"0.59.23","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>var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r};(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel=\"modulepreload\"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var n,r,i,a,o,s,c,l,u,d,f,p,m={},h=[],g=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,_=Array.isArray;function v(e,t){for(var n in t)e[n]=t[n];return e}function y(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function b(e,t,r){var i,a,o,s={};for(o in t)o==`key`?i=t[o]:o==`ref`?a=t[o]:s[o]=t[o];if(arguments.length>2&&(s.children=arguments.length>3?n.call(arguments,2):r),typeof e==`function`&&e.defaultProps!=null)for(o in e.defaultProps)s[o]===void 0&&(s[o]=e.defaultProps[o]);return x(e,s,i,a,null)}function x(e,t,n,a,o){var s={type:e,props:t,key:n,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:o??++i,__i:-1,__u:0};return o==null&&r.vnode!=null&&r.vnode(s),s}function S(e){return e.children}function C(e,t){this.props=e,this.context=t}function w(e,t){if(t==null)return e.__?w(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`?w(e):null}function T(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,i=[],a=[],o=v({},t);o.__v=t.__v+1,r.vnode&&r.vnode(o),se(e.__P,o,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,i,n??w(t),!!(32&t.__u),a),o.__v=t.__v,o.__.__k[o.__i]=o,le(i,o,a),t.__e=t.__=null,o.__e!=n&&ee(o)}}function ee(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}),ee(e)}function E(e){(!e.__d&&(e.__d=!0)&&a.push(e)&&!D.__r++||o!=r.debounceRendering)&&((o=r.debounceRendering)||s)(D)}function D(){try{for(var e,t=1;a.length;)a.length>t&&a.sort(c),e=a.shift(),t=a.length,T(e)}finally{a.length=D.__r=0}}function O(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,g,_,v,y,b=r&&r.__k||h,x=t.length;for(c=te(n,t,b,c,x),d=0;d<x;d++)(p=n.__k[d])!=null&&(f=p.__i!=-1&&b[p.__i]||m,p.__i=d,v=se(e,p,f,i,a,o,s,c,l,u),g=p.__e,p.ref&&f.ref!=p.ref&&(f.ref&&fe(f.ref,null,p),u.push(p.ref,p.__c||g,p)),_==null&&g!=null&&(_=g),(y=!!(4&p.__u))||f.__k===p.__k?c=ne(p,c,e,y):typeof p.type==`function`&&v!==void 0?c=v:g&&(c=g.nextSibling),p.__u&=-7);return n.__e=_,c}function te(e,t,n,r,i){var a,o,s,c,l,u=n.length,d=u,f=0;for(e.__k=Array(i),a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(typeof o==`string`||typeof o==`number`||typeof o==`bigint`||o.constructor==String?o=e.__k[a]=x(null,o,null,null,null):_(o)?o=e.__k[a]=x(S,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=x(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,c=a+f,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=k(o,n,c,d))!=-1&&(d--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>u?f--:i<u&&f++),typeof o.type!=`function`&&(o.__u|=4)):l!=c&&(l==c-1?f--:l==c+1?f++:(l>c?f--:f++,o.__u|=4))):e.__k[a]=null;if(d)for(a=0;a<u;a++)(s=n[a])!=null&&!(2&s.__u)&&(s.__e==r&&(r=w(s)),pe(s,s));return r}function ne(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=ne(i[a],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=w(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function re(e,t){return t=t||[],e==null||typeof e==`boolean`||(_(e)?e.some(function(e){re(e,t)}):t.push(e)),t}function k(e,t,n,r){var i,a,o,s=e.key,c=e.type,l=t[n],u=l!=null&&(2&l.__u)==0;if(l===null&&s==null||u&&s==l.key&&c==l.type)return n;if(r>(u?1:0)){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])!=null&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function ie(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n==null?``:typeof n!=`number`||g.test(t)?n:n+`px`}function ae(e,t,n,r,i){var a,o;n: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||ie(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||ie(e.style,t,n[t])}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(l,`$1`)),o=t.toLowerCase(),t=o in e||t==`onFocusOut`||t==`onFocusIn`?o.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+a]=n,n?r?n.u=r.u:(n.u=u,e.addEventListener(t,a?f:d,a)):e.removeEventListener(t,a?f:d,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 n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function oe(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t.t==null)t.t=u++;else if(t.t<n.u)return;return n(r.event?r.event(t):t)}}}function se(e,t,n,i,a,o,s,c,l,u){var d,f,p,m,g,b,x,w,T,ee,E,D,te,ne,re,k=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(l=!!(32&n.__u),o=[c=t.__e=n.__e]),(d=r.__b)&&d(t);n:if(typeof k==`function`)try{if(w=t.props,T=k.prototype&&k.prototype.render,ee=(d=k.contextType)&&i[d.__c],E=d?ee?ee.props.value:d.__:i,n.__c?x=(f=t.__c=n.__c).__=f.__E:(T?t.__c=f=new k(w,E):(t.__c=f=new C(w,E),f.constructor=k,f.render=me),ee&&ee.sub(f),f.state||(f.state={}),f.__n=i,p=f.__d=!0,f.__h=[],f._sb=[]),T&&f.__s==null&&(f.__s=f.state),T&&k.getDerivedStateFromProps!=null&&(f.__s==f.state&&(f.__s=v({},f.__s)),v(f.__s,k.getDerivedStateFromProps(w,f.__s))),m=f.props,g=f.state,f.__v=t,p)T&&k.getDerivedStateFromProps==null&&f.componentWillMount!=null&&f.componentWillMount(),T&&f.componentDidMount!=null&&f.__h.push(f.componentDidMount);else{if(T&&k.getDerivedStateFromProps==null&&w!==m&&f.componentWillReceiveProps!=null&&f.componentWillReceiveProps(w,E),t.__v==n.__v||!f.__e&&f.shouldComponentUpdate!=null&&!1===f.shouldComponentUpdate(w,f.__s,E)){t.__v!=n.__v&&(f.props=w,f.state=f.__s,f.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(e){e&&(e.__=t)}),h.push.apply(f.__h,f._sb),f._sb=[],f.__h.length&&s.push(f);break n}f.componentWillUpdate!=null&&f.componentWillUpdate(w,f.__s,E),T&&f.componentDidUpdate!=null&&f.__h.push(function(){f.componentDidUpdate(m,g,b)})}if(f.context=E,f.props=w,f.__P=e,f.__e=!1,D=r.__r,te=0,T)f.state=f.__s,f.__d=!1,D&&D(t),d=f.render(f.props,f.state,f.context),h.push.apply(f.__h,f._sb),f._sb=[];else do f.__d=!1,D&&D(t),d=f.render(f.props,f.state,f.context),f.state=f.__s;while(f.__d&&++te<25);f.state=f.__s,f.getChildContext!=null&&(i=v(v({},i),f.getChildContext())),T&&!p&&f.getSnapshotBeforeUpdate!=null&&(b=f.getSnapshotBeforeUpdate(m,g)),ne=d!=null&&d.type===S&&d.key==null?ue(d.props.children):d,c=O(e,_(ne)?ne:[ne],t,n,i,a,o,s,c,l,u),f.base=t.__e,t.__u&=-161,f.__h.length&&s.push(f),x&&(f.__E=f.__=null)}catch(e){if(t.__v=null,l||o!=null)if(e.then){for(t.__u|=l?160:128;c&&c.nodeType==8&&c.nextSibling;)c=c.nextSibling;o[o.indexOf(c)]=null,t.__e=c}else{for(re=o.length;re--;)y(o[re]);ce(t)}else t.__e=n.__e,t.__k=n.__k,e.then||ce(t);r.__e(e,t,n)}else o==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):c=t.__e=de(n.__e,t,n,i,a,o,s,l,u);return(d=r.diffed)&&d(t),128&t.__u?void 0:c}function ce(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(ce))}function le(e,t,n){for(var i=0;i<n.length;i++)fe(n[i],n[++i],n[++i]);r.__c&&r.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){r.__e(e,t.__v)}})}function ue(e){return typeof e!=`object`||!e||e.__b>0?e:_(e)?e.map(ue):v({},e)}function de(e,t,i,a,o,s,c,l,u){var d,f,p,h,g,v,b,x=i.props||m,S=t.props,C=t.type;if(C==`svg`?o=`http://www.w3.org/2000/svg`:C==`math`?o=`http://www.w3.org/1998/Math/MathML`:o||(o=`http://www.w3.org/1999/xhtml`),s!=null){for(d=0;d<s.length;d++)if((g=s[d])&&`setAttribute`in g==!!C&&(C?g.localName==C:g.nodeType==3)){e=g,s[d]=null;break}}if(e==null){if(C==null)return document.createTextNode(S);e=document.createElementNS(o,C,S.is&&S),l&&(r.__m&&r.__m(t,s),l=!1),s=null}if(C==null)x===S||l&&e.data==S||(e.data=S);else{if(s=s&&n.call(e.childNodes),!l&&s!=null)for(x={},d=0;d<e.attributes.length;d++)x[(g=e.attributes[d]).name]=g.value;for(d in x)g=x[d],d==`dangerouslySetInnerHTML`?p=g:d==`children`||d in S||d==`value`&&`defaultValue`in S||d==`checked`&&`defaultChecked`in S||ae(e,d,null,g,o);for(d in S)g=S[d],d==`children`?h=g:d==`dangerouslySetInnerHTML`?f=g:d==`value`?v=g:d==`checked`?b=g:l&&typeof g!=`function`||x[d]===g||ae(e,d,g,x[d],o);if(f)l||p&&(f.__html==p.__html||f.__html==e.innerHTML)||(e.innerHTML=f.__html),t.__k=[];else if(p&&(e.innerHTML=``),O(t.type==`template`?e.content:e,_(h)?h:[h],t,i,a,C==`foreignObject`?`http://www.w3.org/1999/xhtml`:o,s,c,s?s[0]:i.__k&&w(i,0),l,u),s!=null)for(d=s.length;d--;)y(s[d]);l||(d=`value`,C==`progress`&&v==null?e.removeAttribute(`value`):v!=null&&(v!==e[d]||C==`progress`&&!v||C==`option`&&v!=x[d])&&ae(e,d,v,x[d],o),d=`checked`,b!=null&&b!=e[d]&&ae(e,d,b,x[d],o))}return e}function fe(e,t,n){try{if(typeof e==`function`){var i=typeof e.__u==`function`;i&&e.__u(),i&&t==null||(e.__u=e(t))}else e.current=t}catch(e){r.__e(e,n)}}function pe(e,t,n){var i,a;if(r.unmount&&r.unmount(e),(i=e.ref)&&(i.current&&i.current!=e.__e||fe(i,null,t)),(i=e.__c)!=null){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(e){r.__e(e,t)}i.base=i.__P=null}if(i=e.__k)for(a=0;a<i.length;a++)i[a]&&pe(i[a],t,n||typeof e.type!=`function`);n||y(e.__e),e.__c=e.__=e.__e=void 0}function me(e,t,n){return this.constructor(e,n)}function he(e,t,i){var a,o,s,c;t==document&&(t=document.documentElement),r.__&&r.__(e,t),o=(a=typeof i==`function`)?null:i&&i.__k||t.__k,s=[],c=[],se(t,e=(!a&&i||t).__k=b(S,null,[e]),o||m,m,t.namespaceURI,!a&&i?[i]:o?null:t.firstChild?n.call(t.childNodes):null,s,!a&&i?i:o?o.__e:t.firstChild,a,c),le(s,e,c)}function ge(e){function t(e){var n,r;return this.getChildContext||(n=new Set,(r={})[t.__c]=this,this.getChildContext=function(){return r},this.componentWillUnmount=function(){n=null},this.shouldComponentUpdate=function(e){this.props.value!=e.value&&n.forEach(function(e){e.__e=!0,E(e)})},this.sub=function(e){n.add(e);var t=e.componentWillUnmount;e.componentWillUnmount=function(){n&&n.delete(e),t&&t.call(e)}}),e.children}return t.__c=`__cC`+ p++,t.__=e,t.Provider=t.__l=(t.Consumer=function(e,t){return e.children(t)}).contextType=t,t}n=h.slice,r={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!i.__)try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),o=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),o=i.__d),o)return i.__E=i}catch(t){e=t}throw e}},i=0,C.prototype.setState=function(e,t){var n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=v({},this.state);typeof e==`function`&&(e=e(v({},n),this.props)),e&&v(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),E(this))},C.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),E(this))},C.prototype.render=S,a=[],s=typeof Promise==`function`?Promise.prototype.then.bind(Promise.resolve()):setTimeout,c=function(e,t){return e.__v.__b-t.__v.__b},D.__r=0,l=/(PointerCapture)$|Capture$/i,u=0,d=oe(!1),f=oe(!0),p=0;var _e,A,ve,ye,be=0,xe=[],Se=r,Ce=Se.__b,we=Se.__r,Te=Se.diffed,Ee=Se.__c,De=Se.unmount,Oe=Se.__;function ke(e,t){Se.__h&&Se.__h(A,e,be||t),be=0;var n=A.__H||(A.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function Ae(e){return be=1,je(He,e)}function je(e,t,n){var r=ke(_e++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):He(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);t!==n&&(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=A,!A.__f)){var i=function(e,t,n){if(!r.__c.__H)return!0;var i=r.__c.__H.__.filter(function(e){return e.__c});if(i.every(function(e){return!e.__N}))return!a||a.call(this,e,t,n);var o=r.__c.props!==e;return i.some(function(e){if(e.__N){var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(o=!0)}}),a&&a.call(this,e,t,n)||o};A.__f=!0;var a=A.shouldComponentUpdate,o=A.componentWillUpdate;A.componentWillUpdate=function(e,t,n){if(this.__e){var r=a;a=void 0,i(e,t,n),a=r}o&&o.call(this,e,t,n)},A.shouldComponentUpdate=i}return r.__N||r.__}function Me(e,t){var n=ke(_e++,3);!Se.__s&&Ve(n.__H,t)&&(n.__=e,n.u=t,A.__H.__h.push(n))}function Ne(e,t){var n=ke(_e++,4);!Se.__s&&Ve(n.__H,t)&&(n.__=e,n.u=t,A.__h.push(n))}function j(e){return be=5,Pe(function(){return{current:e}},[])}function Pe(e,t){var n=ke(_e++,7);return Ve(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function Fe(e,t){return be=8,Pe(function(){return e},t)}function M(e){var t=A.context[e.__c],n=ke(_e++,9);return n.c=e,t?(n.__??(n.__=!0,t.sub(A)),t.props.value):e.__}function Ie(){for(var e;e=xe.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(ze),t.__h.some(Be),t.__h=[]}catch(n){t.__h=[],Se.__e(n,e.__v)}}}Se.__b=function(e){A=null,Ce&&Ce(e)},Se.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Oe&&Oe(e,t)},Se.__r=function(e){we&&we(e),_e=0;var t=(A=e.__c).__H;t&&(ve===A?(t.__h=[],A.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.some(ze),t.__h.some(Be),t.__h=[],_e=0)),ve=A},Se.diffed=function(e){Te&&Te(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(xe.push(t)!==1&&ye===Se.requestAnimationFrame||((ye=Se.requestAnimationFrame)||Re)(Ie)),t.__H.__.some(function(e){e.u&&(e.__H=e.u),e.u=void 0})),ve=A=null},Se.__c=function(e,t){t.some(function(e){try{e.__h.some(ze),e.__h=e.__h.filter(function(e){return!e.__||Be(e)})}catch(n){t.some(function(e){e.__h&&(e.__h=[])}),t=[],Se.__e(n,e.__v)}}),Ee&&Ee(e,t)},Se.unmount=function(e){De&&De(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(e){try{ze(e)}catch(e){t=e}}),n.__H=void 0,t&&Se.__e(t,n.__v))};var Le=typeof requestAnimationFrame==`function`;function Re(e){var t,n=function(){clearTimeout(r),Le&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);Le&&(t=requestAnimationFrame(n))}function ze(e){var t=A,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),A=t}function Be(e){var t=A;e.__c=e.__(),A=t}function Ve(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}function He(e,t){return typeof t==`function`?t(e):t}function Ue(e,t){for(var n in t)e[n]=t[n];return e}function We(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 Ge(e,t){var n=t(),r=Ae({t:{__:n,u:t}}),i=r[0].t,a=r[1];return Ne(function(){i.__=n,i.u=t,Ke(i)&&a({t:i})},[e,n,t]),Me(function(){return Ke(i)&&a({t:i}),e(function(){Ke(i)&&a({t:i})})},[e]),n}function Ke(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 qe(e,t){this.props=e,this.context=t}(qe.prototype=new C).isPureReactComponent=!0,qe.prototype.shouldComponentUpdate=function(e,t){return We(this.props,e)||We(this.state,t)};var Je=r.__b;r.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),Je&&Je(e)},typeof Symbol<`u`&&Symbol.for;var Ye=r.__e;r.__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??(t.__e=n.__e,t.__k=n.__k),i.__c(e,t)}Ye(e,t,n,r)};var Xe=r.unmount;function Ze(e,t,n){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach(function(e){typeof e.__c==`function`&&e.__c()}),e.__c.__H=null),(e=Ue({},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(e){return Ze(e,t,n)})),e}function Qe(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(e){return Qe(e,t,n)}),e.__c&&e.__c.__P===t&&(e.__e&&n.appendChild(e.__e),e.__c.__e=!0,e.__c.__P=n)),e}function $e(){this.__u=0,this.o=null,this.__b=null}function et(e){var t=e.__&&e.__.__c;return t&&t.__a&&t.__a(e)}function tt(){this.i=null,this.l=null}r.unmount=function(e){var t=e.__c;t&&(t.__z=!0),t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),Xe&&Xe(e)},($e.prototype=new C).__c=function(e,t){var n=t.__c,r=this;r.o??(r.o=[]),r.o.push(n);var i=et(r.__v),a=!1,o=function(){a||r.__z||(a=!0,n.__R=null,i?i(c):c())};n.__R=o;var s=n.__P;n.__P=null;var c=function(){if(!--r.__u){if(r.state.__a){var e=r.state.__a;r.__v.__k[0]=Qe(e,e.__c.__P,e.__c.__O)}var t;for(r.setState({__a:r.__b=null});t=r.o.pop();)t.__P=s,t.forceUpdate()}};r.__u++||32&t.__u||r.setState({__a:r.__b=r.__v.__k[0]}),e.then(o,o)},$e.prototype.componentWillUnmount=function(){this.o=[]},$e.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]=Ze(this.__b,n,r.__O=r.__P)}this.__b=null}var i=t.__a&&b(S,null,e.fallback);return i&&(i.__u&=-33),[b(S,null,t.__a?null:e.children),i]};var nt=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]}};(tt.prototype=new C).__a=function(e){var t=this,n=et(t.__v),r=t.l.get(e);return r[0]++,function(i){var a=function(){t.props.revealOrder?(r.push(i),nt(t,e,r)):i()};n?n(a):a()}},tt.prototype.render=function(e){this.i=null,this.l=new Map;var t=re(e.children);e.revealOrder&&e.revealOrder[0]===`b`&&t.reverse();for(var n=t.length;n--;)this.l.set(t[n],this.i=[1,0,this.i]);return e.children},tt.prototype.componentDidUpdate=tt.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,n){nt(e,n,t)})};var rt=typeof Symbol<`u`&&Symbol.for&&Symbol.for(`react.element`)||60103,it=/^(?: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]/,at=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,ot=/[A-Z0-9]/g,st=typeof document<`u`,ct=function(e){return(typeof Symbol<`u`&&typeof Symbol()==`symbol`?/fil|che|rad/:/fil|che|ra/).test(e)};C.prototype.isReactComponent=!0,[`componentWillMount`,`componentWillReceiveProps`,`componentWillUpdate`].forEach(function(e){Object.defineProperty(C.prototype,e,{configurable:!0,get:function(){return this[`UNSAFE_`+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var lt=r.event;r.event=function(e){return lt&&(e=lt(e)),e.persist=function(){},e.isPropagationStopped=function(){return this.cancelBubble},e.isDefaultPrevented=function(){return this.defaultPrevented},e.nativeEvent=e};var ut={configurable:!0,get:function(){return this.class}},dt=r.vnode;r.vnode=function(e){typeof e.type==`string`&&function(e){var t=e.props,n=e.type,r={},i=n.indexOf(`-`)==-1;for(var a in t){var o=t[a];if(!(a===`value`&&`defaultValue`in t&&o==null||st&&a===`children`&&n===`noscript`||a===`class`||a===`className`)){var s=a.toLowerCase();a===`defaultValue`&&`value`in t&&t.value==null?a=`value`:a===`download`&&!0===o?o=``:s===`translate`&&o===`no`?o=!1:s[0]===`o`&&s[1]===`n`?s===`ondoubleclick`?a=`ondblclick`:s!==`onchange`||n!==`input`&&n!==`textarea`||ct(t.type)?s===`onfocus`?a=`onfocusin`:s===`onblur`?a=`onfocusout`:at.test(a)&&(a=s):s=a=`oninput`:i&&it.test(a)?a=a.replace(ot,`-$&`).toLowerCase():o===null&&(o=void 0),s===`oninput`&&r[a=s]&&(a=`oninputCapture`),r[a]=o}}n==`select`&&(r.multiple&&Array.isArray(r.value)&&(r.value=re(t.children).forEach(function(e){e.props.selected=r.value.indexOf(e.props.value)!=-1})),r.defaultValue!=null&&(r.value=re(t.children).forEach(function(e){e.props.selected=r.multiple?r.defaultValue.indexOf(e.props.value)!=-1:r.defaultValue==e.props.value}))),t.class&&!t.className?(r.class=t.class,Object.defineProperty(r,`className`,ut)):t.className&&(r.class=r.className=t.className),e.props=r}(e),e.$$typeof=rt,dt&&dt(e)};var ft=r.__r;r.__r=function(e){ft&&ft(e),e.__c};var pt=r.diffed;r.diffed=function(e){pt&&pt(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)};var mt=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e))},o=t=e(r,i,a);return a},ht=(e=>e?mt(e):mt),gt=e=>e;function _t(e){function t(t=gt){let n=Fe(()=>t(e.getState()),[t]);return Ge(e.subscribe,n)}return Object.assign(t,e)}function vt(){return e=>_t(ht()(e))}function yt(){if(typeof crypto.randomUUID==`function`)return crypto.randomUUID();let e=crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e,e=>e.toString(16).padStart(2,`0`));return[t.slice(0,4).join(``),t.slice(4,6).join(``),t.slice(6,8).join(``),t.slice(8,10).join(``),t.slice(10).join(``)].join(`-`)}var bt=Symbol.for(`immer-nothing`),xt=Symbol.for(`immer-draftable`),N=Symbol.for(`immer-state`);function St(e,...t){throw Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var Ct=Object,wt=Ct.getPrototypeOf,Tt=`constructor`,Et=`prototype`,Dt=`configurable`,Ot=`enumerable`,kt=`writable`,At=`value`,jt=e=>!!e&&!!e[N];function Mt(e){return e?Ft(e)||Vt(e)||!!e[xt]||!!e[Tt]?.[xt]||Ht(e)||Ut(e):!1}var Nt=Ct[Et][Tt].toString(),Pt=new WeakMap;function Ft(e){if(!e||!I(e))return!1;let t=wt(e);if(t===null||t===Ct[Et])return!0;let n=Ct.hasOwnProperty.call(t,Tt)&&t[Tt];if(n===Object)return!0;if(!Wt(n))return!1;let r=Pt.get(n);return r===void 0&&(r=Function.toString.call(n),Pt.set(n,r)),r===Nt}function It(e){return jt(e)||St(15,e),e[N].base_}function Lt(e,t,n=!0){Rt(e)===0?(n?Reflect.ownKeys(e):Ct.keys(e)).forEach(n=>{t(n,e[n],e)}):e.forEach((n,r)=>t(r,n,e))}function Rt(e){let t=e[N];return t?t.type_:Vt(e)?1:Ht(e)?2:Ut(e)?3:0}var zt=(e,t,n=Rt(e))=>n===2?e.has(t):Ct[Et].hasOwnProperty.call(e,t),Bt=(e,t,n=Rt(e))=>n===2?e.get(t):e[t],P=(e,t,n,r=Rt(e))=>{r===2?e.set(t,n):r===3?e.add(n):e[t]=n};function F(e,t){return e===t?e!==0||1/e==1/t:e!==e&&t!==t}var Vt=Array.isArray,Ht=e=>e instanceof Map,Ut=e=>e instanceof Set,I=e=>typeof e==`object`,Wt=e=>typeof e==`function`,Gt=e=>typeof e==`boolean`;function Kt(e){let t=+e;return Number.isInteger(t)&&String(t)===e}var qt=e=>I(e)?e?.[N]:null,Jt=e=>e.copy_||e.base_,Yt=e=>{let t=qt(e);return t?t.copy_??t.base_:e},Xt=e=>e.modified_?e.copy_:e.base_;function Zt(e,t){if(Ht(e))return new Map(e);if(Ut(e))return new Set(e);if(Vt(e))return Array[Et].slice.call(e);let n=Ft(e);if(t===!0||t===`class_only`&&!n){let t=Ct.getOwnPropertyDescriptors(e);delete t[N];let n=Reflect.ownKeys(t);for(let r=0;r<n.length;r++){let i=n[r],a=t[i];a[kt]===!1&&(a[kt]=!0,a[Dt]=!0),(a.get||a.set)&&(t[i]={[Dt]:!0,[kt]:!0,[Ot]:a[Ot],[At]:e[i]})}return Ct.create(wt(e),t)}else{let t=wt(e);if(t!==null&&n)return{...e};let r=Ct.create(t);return Ct.assign(r,e)}}function Qt(e,t=!1){return L(e)||jt(e)||!Mt(e)?e:(Rt(e)>1&&Ct.defineProperties(e,{set:en,add:en,clear:en,delete:en}),Ct.freeze(e),t&&Lt(e,(e,t)=>{Qt(t,!0)},!1),e)}function $t(){St(2)}var en={[At]:$t};function L(e){return e===null||!I(e)?!0:Ct.isFrozen(e)}var tn=`MapSet`,nn=`Patches`,rn=`ArrayMethods`,an={};function on(e){let t=an[e];return t||St(0,e),t}var sn=e=>!!an[e];function R(e,t){an[e]||(an[e]=t)}var cn,ln=()=>cn,un=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:sn(tn)?on(tn):void 0,arrayMethodsPlugin_:sn(rn)?on(rn):void 0});function dn(e,t){t&&(e.patchPlugin_=on(nn),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function fn(e){pn(e),e.drafts_.forEach(hn),e.drafts_=null}function pn(e){e===cn&&(cn=e.parent_)}var mn=e=>cn=un(cn,e);function hn(e){let t=e[N];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function gn(e,t){t.unfinalizedDrafts_=t.drafts_.length;let n=t.drafts_[0];if(e!==void 0&&e!==n){n[N].modified_&&(fn(t),St(4)),Mt(e)&&(e=_n(t,e));let{patchPlugin_:r}=t;r&&r.generateReplacementPatches_(n[N].base_,e,t)}else e=_n(t,n);return vn(t,e,!0),fn(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e===bt?void 0:e}function _n(e,t){if(L(t))return t;let n=t[N];if(!n)return En(t,e.handledSet_,e);if(!bn(n,e))return t;if(!n.modified_)return n.base_;if(!n.finalized_){let{callbacks_:t}=n;if(t)for(;t.length>0;)t.pop()(e);wn(n,e)}return n.copy_}function vn(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Qt(t,n)}function yn(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var bn=(e,t)=>e.scope_===t,xn=[];function Sn(e,t,n,r){let i=Jt(e),a=e.type_;if(r!==void 0&&Bt(i,r,a)===t){P(i,r,n,a);return}if(!e.draftLocations_){let t=e.draftLocations_=new Map;Lt(i,(e,n)=>{if(jt(n)){let r=t.get(n)||[];r.push(e),t.set(n,r)}})}let o=e.draftLocations_.get(t)??xn;for(let e of o)P(i,e,n,a)}function Cn(e,t,n){e.callbacks_.push(function(r){let i=t;if(!i||!bn(i,r))return;r.mapSetPlugin_?.fixSetContents(i);let a=Xt(i);Sn(e,i.draft_??i,a,n),wn(i,r)})}function wn(e,t){if(e.modified_&&!e.finalized_&&(e.type_===3||e.type_===1&&e.allIndicesReassigned_||(e.assigned_?.size??0)>0)){let{patchPlugin_:n}=t;if(n){let r=n.getPath(e);r&&n.generatePatches_(e,r,t)}yn(e)}}function Tn(e,t,n){let{scope_:r}=e;if(jt(n)){let i=n[N];bn(i,r)&&i.callbacks_.push(function(){Pn(e),Sn(e,n,Xt(i),t)})}else Mt(n)&&e.callbacks_.push(function(){let i=Jt(e);e.type_===3?i.has(n)&&En(n,r.handledSet_,r):Bt(i,t,e.type_)===n&&r.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&En(Bt(e.copy_,t,e.type_),r.handledSet_,r)})}function En(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||jt(e)||t.has(e)||!Mt(e)||L(e)?e:(t.add(e),Lt(e,(r,i)=>{if(jt(i)){let t=i[N];bn(t,n)&&(P(e,r,Xt(t),e.type_),yn(t))}else Mt(i)&&En(i,t,n)}),e)}function Dn(e,t){let n=Vt(e),r={type_:n?1:0,scope_:t?t.scope_:ln(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0},i=r,a=On;n&&(i=[r],a=kn);let{revoke:o,proxy:s}=Proxy.revocable(i,a);return r.draft_=s,r.revoke_=o,[s,r]}var On={get(e,t){if(t===N)return e;let n=e.scope_.arrayMethodsPlugin_,r=e.type_===1&&typeof t==`string`;if(r&&n?.isArrayOperationMethod(t))return n.createMethodInterceptor(e,t);let i=Jt(e);if(!zt(i,t,e.type_))return jn(e,i,t);let a=i[t];if(e.finalized_||!Mt(a)||r&&e.operationMethod&&n?.isMutatingArrayMethod(e.operationMethod)&&Kt(t))return a;if(a===An(e.base_,t)){Pn(e);let n=e.type_===1?+t:t,r=In(e.scope_,a,e,n);return e.copy_[n]=r}return a},has(e,t){return t in Jt(e)},ownKeys(e){return Reflect.ownKeys(Jt(e))},set(e,t,n){let r=Mn(Jt(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){let r=An(Jt(e),t),i=r?.[N];if(i&&i.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(F(n,r)&&(n!==void 0||zt(e.base_,t,e.type_)))return!0;Pn(e),Nn(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])?!0:(e.copy_[t]=n,e.assigned_.set(t,!0),Tn(e,t,n),!0)},deleteProperty(e,t){return Pn(e),An(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),Nn(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let n=Jt(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{[kt]:!0,[Dt]:e.type_!==1||t!==`length`,[Ot]:r[Ot],[At]:n[t]}},defineProperty(){St(11)},getPrototypeOf(e){return wt(e.base_)},setPrototypeOf(){St(12)}},kn={};for(let e in On){let t=On[e];kn[e]=function(){let e=arguments;return e[0]=e[0][0],t.apply(this,e)}}kn.deleteProperty=function(e,t){return kn.set.call(this,e,t,void 0)},kn.set=function(e,t,n){return On.set.call(this,e[0],t,n,e[0])};function An(e,t){let n=e[N];return(n?Jt(n):e)[t]}function jn(e,t,n){let r=Mn(t,n);return r?At in r?r[At]:r.get?.call(e.draft_):void 0}function Mn(e,t){if(!(t in e))return;let n=wt(e);for(;n;){let e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=wt(n)}}function Nn(e){e.modified_||(e.modified_=!0,e.parent_&&Nn(e.parent_))}function Pn(e){e.copy_||(e.assigned_=new Map,e.copy_=Zt(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Fn=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(e,t,n)=>{if(Wt(e)&&!Wt(t)){let n=t;t=e;let r=this;return function(e=n,...i){return r.produce(e,e=>t.call(this,e,...i))}}Wt(t)||St(6),n!==void 0&&!Wt(n)&&St(7);let r;if(Mt(e)){let i=mn(this),a=In(i,e,void 0),o=!0;try{r=t(a),o=!1}finally{o?fn(i):pn(i)}return dn(i,n),gn(r,i)}else if(!e||!I(e)){if(r=t(e),r===void 0&&(r=e),r===bt&&(r=void 0),this.autoFreeze_&&Qt(r,!0),n){let t=[],i=[];on(nn).generateReplacementPatches_(e,r,{patches_:t,inversePatches_:i}),n(t,i)}return r}else St(1,e)},this.produceWithPatches=(e,t)=>{if(Wt(e))return(t,...n)=>this.produceWithPatches(t,t=>e(t,...n));let n,r;return[this.produce(e,t,(e,t)=>{n=e,r=t}),n,r]},Gt(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),Gt(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),Gt(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Mt(e)||St(8),jt(e)&&(e=Ln(e));let t=mn(this),n=In(t,e,void 0);return n[N].isManual_=!0,pn(t),n}finishDraft(e,t){let n=e&&e[N];(!n||!n.isManual_)&&St(9);let{scope_:r}=n;return dn(r,t),gn(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--){let r=t[n];if(r.path.length===0&&r.op===`replace`){e=r.value;break}}n>-1&&(t=t.slice(n+1));let r=on(nn).applyPatches_;return jt(e)?r(e,t):this.produce(e,e=>r(e,t))}};function In(e,t,n,r){let[i,a]=Ht(t)?on(tn).proxyMap_(t,n):Ut(t)?on(tn).proxySet_(t,n):Dn(t,n);return(n?.scope_??ln()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?Cn(n,a,r):a.callbacks_.push(function(e){e.mapSetPlugin_?.fixSetContents(a);let{patchPlugin_:t}=e;a.modified_&&t&&t.generatePatches_(a,[],e)}),i}function Ln(e){return jt(e)||St(10,e),Rn(e)}function Rn(e){if(!Mt(e)||L(e))return e;let t=e[N],n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Zt(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=Zt(e,!0);return Lt(n,(e,t)=>{P(n,e,Rn(t))},r),t&&(t.finalized_=!1),n}function zn(){function e(n,r=[]){if(n.key_!==void 0){let e=n.parent_.copy_??n.parent_.base_,t=qt(Bt(e,n.key_)),i=Bt(e,n.key_);if(i===void 0||i!==n.draft_&&i!==n.base_&&i!==n.copy_||t!=null&&t.base_!==n.base_)return null;let a=n.parent_.type_===3,o;if(a){let e=n.parent_;o=Array.from(e.drafts_.keys()).indexOf(n.key_)}else o=n.key_;if(!(a&&e.size>o||zt(e,o)))return null;r.push(o)}if(n.parent_)return e(n.parent_,r);r.reverse();try{t(n.copy_,r)}catch{return null}return r}function t(e,t){let n=e;for(let e=0;e<t.length-1;e++){let r=t[e];if(n=Bt(n,r),!I(n)||n===null)throw Error(`Cannot resolve path at '${t.join(`/`)}'`)}return n}let n=`replace`,r=`remove`;function i(e,t,n){if(e.scope_.processedForPatches_.has(e))return;e.scope_.processedForPatches_.add(e);let{patches_:r,inversePatches_:i}=n;switch(e.type_){case 0:case 2:return o(e,t,r,i);case 1:return a(e,t,r,i);case 3:return s(e,t,r,i)}}function a(e,t,i,a){let{base_:o,assigned_:s}=e,c=e.copy_;c.length<o.length&&([o,c]=[c,o],[i,a]=[a,i]);let l=e.allIndicesReassigned_===!0;for(let e=0;e<o.length;e++){let r=c[e],u=o[e];if((l||s?.get(e.toString()))&&r!==u){let o=r?.[N];if(o&&o.modified_)continue;let s=t.concat([e]);i.push({op:n,path:s,value:d(r)}),a.push({op:n,path:s,value:d(u)})}}for(let e=o.length;e<c.length;e++){let n=t.concat([e]);i.push({op:`add`,path:n,value:d(c[e])})}for(let e=c.length-1;o.length<=e;--e){let n=t.concat([e]);a.push({op:r,path:n})}}function o(e,t,i,a){let{base_:o,copy_:s,type_:c}=e;Lt(e.assigned_,(e,l)=>{let u=Bt(o,e,c),f=Bt(s,e,c),p=l?zt(o,e)?n:`add`:r;if(u===f&&p===n)return;let m=t.concat(e);i.push(p===r?{op:p,path:m}:{op:p,path:m,value:d(f)}),a.push(p===`add`?{op:r,path:m}:p===r?{op:`add`,path:m,value:d(u)}:{op:n,path:m,value:d(u)})})}function s(e,t,n,i){let{base_:a,copy_:o}=e,s=0;a.forEach(e=>{if(!o.has(e)){let a=t.concat([s]);n.push({op:r,path:a,value:e}),i.unshift({op:`add`,path:a,value:e})}s++}),s=0,o.forEach(e=>{if(!a.has(e)){let a=t.concat([s]);n.push({op:`add`,path:a,value:e}),i.unshift({op:r,path:a,value:e})}s++})}function c(e,t,r){let{patches_:i,inversePatches_:a}=r;i.push({op:n,path:[],value:t===bt?void 0:t}),a.push({op:n,path:[],value:e})}function l(e,t){return t.forEach(t=>{let{path:i,op:a}=t,o=e;for(let e=0;e<i.length-1;e++){let t=Rt(o),n=i[e];typeof n!=`string`&&typeof n!=`number`&&(n=``+n),(t===0||t===1)&&(n===`__proto__`||n===Tt)&&St(19),Wt(o)&&n===Et&&St(19),o=Bt(o,n),I(o)||St(18,i.join(`/`))}let s=Rt(o),c=u(t.value),l=i[i.length-1];switch(a){case n:switch(s){case 2:return o.set(l,c);case 3:St(16);default:return o[l]=c}case`add`:switch(s){case 1:return l===`-`?o.push(c):o.splice(l,0,c);case 2:return o.set(l,c);case 3:return o.add(c);default:return o[l]=c}case r:switch(s){case 1:return o.splice(l,1);case 2:return o.delete(l);case 3:return o.delete(t.value);default:return delete o[l]}default:St(17,a)}}),e}function u(e){if(!Mt(e))return e;if(Vt(e))return e.map(u);if(Ht(e))return new Map(Array.from(e.entries()).map(([e,t])=>[e,u(t)]));if(Ut(e))return new Set(Array.from(e).map(u));let t=Object.create(wt(e));for(let n in e)t[n]=u(e[n]);return zt(e,xt)&&(t[xt]=e[xt]),t}function d(e){return jt(e)?u(e):e}R(nn,{applyPatches_:l,generatePatches_:i,generateReplacementPatches_:c,getPath:e})}function Bn(){class e extends Map{constructor(e,t){super(),this[N]={type_:2,parent_:t,scope_:t?t.scope_:ln(),modified_:!1,finalized_:!1,copy_:void 0,assigned_:void 0,base_:e,draft_:this,isManual_:!1,revoked_:!1,callbacks_:[]}}get size(){return Jt(this[N]).size}has(e){return Jt(this[N]).has(e)}set(e,t){let r=this[N];return o(r),(!Jt(r).has(e)||Jt(r).get(e)!==t)&&(n(r),Nn(r),r.assigned_.set(e,!0),r.copy_.set(e,t),r.assigned_.set(e,!0),Tn(r,e,t)),this}delete(e){if(!this.has(e))return!1;let t=this[N];return o(t),n(t),Nn(t),t.base_.has(e)?t.assigned_.set(e,!1):t.assigned_.delete(e),t.copy_.delete(e),!0}clear(){let e=this[N];o(e),Jt(e).size&&(n(e),Nn(e),e.assigned_=new Map,Lt(e.base_,t=>{e.assigned_.set(t,!1)}),e.copy_.clear())}forEach(e,t){let n=this[N];Jt(n).forEach((n,r,i)=>{e.call(t,this.get(r),r,this)})}get(e){let t=this[N];o(t);let r=Jt(t).get(e);if(t.finalized_||!Mt(r)||r!==t.base_.get(e))return r;let i=In(t.scope_,r,t,e);return n(t),t.copy_.set(e,i),i}keys(){return Jt(this[N]).keys()}values(){let e=this.keys();return{[Symbol.iterator]:()=>this.values(),next:()=>{let t=e.next();return t.done?t:{done:!1,value:this.get(t.value)}}}}entries(){let e=this.keys();return{[Symbol.iterator]:()=>this.entries(),next:()=>{let t=e.next();if(t.done)return t;let n=this.get(t.value);return{done:!1,value:[t.value,n]}}}}[Symbol.iterator](){return this.entries()}}function t(t,n){let r=new e(t,n);return[r,r[N]]}function n(e){e.copy_||(e.assigned_=new Map,e.copy_=new Map(e.base_))}class r extends Set{constructor(e,t){super(),this[N]={type_:3,parent_:t,scope_:t?t.scope_:ln(),modified_:!1,finalized_:!1,copy_:void 0,base_:e,draft_:this,drafts_:new Map,revoked_:!1,isManual_:!1,assigned_:void 0,callbacks_:[]}}get size(){return Jt(this[N]).size}has(e){let t=this[N];return o(t),t.copy_?!!(t.copy_.has(e)||t.drafts_.has(e)&&t.copy_.has(t.drafts_.get(e))):t.base_.has(e)}add(e){let t=this[N];return o(t),this.has(e)||(a(t),Nn(t),t.copy_.add(e),Tn(t,e,e)),this}delete(e){if(!this.has(e))return!1;let t=this[N];return o(t),a(t),Nn(t),t.copy_.delete(e)||(t.drafts_.has(e)?t.copy_.delete(t.drafts_.get(e)):!1)}clear(){let e=this[N];o(e),Jt(e).size&&(a(e),Nn(e),e.copy_.clear())}values(){let e=this[N];return o(e),a(e),e.copy_.values()}entries(){let e=this[N];return o(e),a(e),e.copy_.entries()}keys(){return this.values()}[Symbol.iterator](){return this.values()}forEach(e,t){let n=this.values(),r=n.next();for(;!r.done;)e.call(t,r.value,r.value,this),r=n.next()}}function i(e,t){let n=new r(e,t);return[n,n[N]]}function a(e){e.copy_||(e.copy_=new Set,e.base_.forEach(t=>{if(Mt(t)){let n=In(e.scope_,t,e,t);e.drafts_.set(t,n),e.copy_.add(n)}else e.copy_.add(t)}))}function o(e){e.revoked_&&St(3,JSON.stringify(Jt(e)))}function s(e){if(e.type_===3&&e.copy_){let t=new Set(e.copy_);e.copy_.clear(),t.forEach(t=>{e.copy_.add(Yt(t))})}}R(tn,{proxyMap_:t,proxySet_:i,fixSetContents:s})}var Vn=new Fn().produce,Hn=e=>(t,n,r)=>(r.setState=(e,n,...r)=>t(typeof e==`function`?Vn(e):e,n,...r),e(r.setState,n,r)),Un={$:`variable`,_:`temporary`,\"@\":`local`,\"%\":`transient`},Wn=Object.fromEntries(Object.entries(Un).map(([e,t])=>[t,e])),Gn=new Set(Object.keys(Un));function Kn(e){return e!==void 0&&Gn.has(e)}function qn(e,t){return t.className&&(e.className=t.className),t.id&&(e.id=t.id),e}var Jn={SIGIL_SCOPES:Un,withSelectors:qn},Yn=`{`,Xn=`}`,{SIGIL_SCOPES:Zn,withSelectors:Qn}=Jn,$n=new Set([`area`,`base`,`br`,`col`,`embed`,`hr`,`img`,`input`,`link`,`meta`,`param`,`source`,`track`,`wbr`]),er={elseif:`if`,else:`if`,case:`switch`,default:`switch`,next:`timed`},tr=[[`|`,!1],[`->`,!1],[`<-`,!0]],nr={},rr=/^<[a-zA-Z0-9.!#$%&'*+/=?^_`|~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*>$/;function ir(e,t,n){let r=(n,r)=>{let i=e.slice(n,r),a=i.trim(),o=t+n+(a?i.indexOf(a):0);return{value:a,start:o,end:o+a.length}};for(let[t,i]of tr){let a=n(t);if(a===-1)continue;let o=r(0,a),s=r(a+t.length,e.length),[c,l]=i?[s,o]:[o,s];return{display:c.value,displayStart:c.start,displayEnd:c.end,target:l.value,targetStart:l.start,targetEnd:l.end}}let i=r(0,e.length);return{display:i.value,displayStart:i.start,displayEnd:i.end,target:i.value,targetStart:i.start,targetEnd:i.end}}function ar(e){let t=[],n=``;for(let[r,i]of e)i&&(r===`.`?t.push(i):n=i);return Qn({},{className:t.join(` `),id:n})}function or(e){return e.lex===`html`?(e.isClose?`</`:`<`)+e.tag+`>`:Yn+(e.isClose?`/`:``)+e.name+Xn}function sr(e,t,n){return n.lex=e,n.start=t.start.offset,n.end=t.end.offset,n.loc=t,n}function cr(e){let t={start:e.start,end:e.end};switch(e.lex){case`text`:return e.comment?{type:`text`,value:e.value,comment:!0,...t}:{type:`text`,value:e.value,...t};case`link`:return Qn({type:`link`,display:e.display,displayStart:e.displayStart,displayEnd:e.displayEnd,target:e.target,targetStart:e.targetStart,targetEnd:e.targetEnd,...e.selectorSpan,...t},e);case`variable`:return Qn({type:`variable`,name:e.name,nameStart:e.nameStart,nameEnd:e.nameEnd,scope:e.scope,...e.selectorSpan,...t},e);case`expression`:return Qn({type:`expression`,expression:e.expression,expressionStart:e.expressionStart,expressionEnd:e.expressionEnd,...e.selectorSpan,...t},e);case`macro`:return Qn({type:`macro`,name:e.name,nameStart:e.nameStart,nameEnd:e.nameEnd,rawArgs:e.rawArgs,argsStart:e.argsStart,argsEnd:e.argsEnd,isClose:e.isClose,...e.selectorSpan,...t},e);case`html`:return{type:`html`,tag:e.tag,tagNameStart:e.tagNameStart,tagNameEnd:e.tagNameEnd,attributes:e.attributes,attributeSpans:e.attributeSpans,isClose:e.isClose,isSelfClose:e.isSelfClose,...t}}}function lr(e){let t=[],n=null,r=e=>{if(e!=null){if(Array.isArray(e))return e.forEach(r);if(e.lex===`text`&&!e.escape&&!e.comment&&n&&n.lex===`text`&&!n.escape&&!n.comment&&n.end===e.start){n.value+=e.value,n.end=e.end;return}t.push(e),n=e}};return r(e),t.map(cr)}var ur=class extends SyntaxError{constructor(e,t,n,r){super(e),this.expected=t,this.found=n,this.location=r,this.name=`SyntaxError`}format(e){let t=`Error: `+this.message;if(this.location){let n=null,r=e.find(e=>e.source===this.location.source);r&&(n=r.text.split(/\\r\\n|\\n|\\r/g));let i=this.location.start,a=this.location.source&&typeof this.location.source.offset==`function`?this.location.source.offset(i):i,o=this.location.source+`:`+a.line+`:`+a.column;if(n){let e=this.location.end,r=``.padEnd(a.line.toString().length,` `),s=n[i.line-1],c=(i.line===e.line?e.column:s.length+1)-i.column||1;t+=`\n --> `+o+`\n`+r+` |\n`+a.line+` | `+s+`\n`+r+` | `+``.padEnd(i.column-1,` `)+``.padEnd(c,`^`)}else t+=`\n at `+o}return t}static buildMessage(e,t){function n(e){return e.codePointAt(0).toString(16).toUpperCase()}let r=Object.prototype.hasOwnProperty.call(RegExp.prototype,`unicode`)?RegExp(`[\\\\p{C}\\\\p{Mn}\\\\p{Mc}]`,`gu`):null;function i(e){return r?e.replace(r,e=>`\\\\u{`+n(e)+`}`):e}function a(e){return i(e.replace(/\\\\/g,`\\\\\\\\`).replace(/\"/g,`\\\\\"`).replace(/\\0/g,`\\\\0`).replace(/\\t/g,`\\\\t`).replace(/\\n/g,`\\\\n`).replace(/\\r/g,`\\\\r`).replace(/[\\x00-\\x0F]/g,e=>`\\\\x0`+n(e)).replace(/[\\x10-\\x1F\\x7F-\\x9F]/g,e=>`\\\\x`+n(e)))}function o(e){return i(e.replace(/\\\\/g,`\\\\\\\\`).replace(/\\]/g,`\\\\]`).replace(/\\^/g,`\\\\^`).replace(/-/g,`\\\\-`).replace(/\\0/g,`\\\\0`).replace(/\\t/g,`\\\\t`).replace(/\\n/g,`\\\\n`).replace(/\\r/g,`\\\\r`).replace(/[\\x00-\\x0F]/g,e=>`\\\\x0`+n(e)).replace(/[\\x10-\\x1F\\x7F-\\x9F]/g,e=>`\\\\x`+n(e)))}let s={literal(e){return`\"`+a(e.text)+`\"`},class(e){let t=e.parts.map(e=>Array.isArray(e)?o(e[0])+`-`+o(e[1]):o(e));return`[`+(e.inverted?`^`:``)+t.join(``)+`]`+(e.unicode?`u`:``)},any(){return`any character`},end(){return`end of input`},other(e){return e.description}};function c(e){return s[e.type](e)}function l(e){let t=e.map(c);if(t.sort(),t.length>0){let e=1;for(let n=1;n<t.length;n++)t[n-1]!==t[n]&&(t[e]=t[n],e++);t.length=e}switch(t.length){case 1:return t[0];case 2:return t[0]+` or `+t[1];default:return t.slice(0,-1).join(`, `)+`, or `+t[t.length-1]}}function u(e){return e?`\"`+a(e)+`\"`:`end of input`}return`Expected `+l(e)+` but `+u(t)+` found.`}};function dr(e,t){t=t===void 0?{}:t;let n={},r=t.grammarSource,i={Tokens:rn,SelectorsPrefix:hn},a=rn,o=`\\x3C!--`,s=/^[^\\\\{[<]/,c=/^[{}]/,l=/^[$_@%(!\\/a-zA-Z]/,u=/^[.#]/,d=/^[a-zA-Z0-9_\\-]/,f=/^[$_@%]/,p=/^[a-zA-Z0-9_.]/,m=/^[$_@%(!]/,h=/^[a-zA-Z]/,g=/^[^ \\t\\n\\r\\v\\f\\xA0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000\\uFEFF}]/,_=/^[a-zA-Z0-9.!#$%&'*+\\/=?\\^_`|~\\-]/,v=/^[a-zA-Z0-9.\\-]/,y=/^[\\t-\\r \\/>\\xA0\\u1680\\u2000-\\u200A\\u2028-\\u2029\\u202F\\u205F\\u3000\\uFEFF]/,b=/^[a-zA-Z0-9\\-]/,x=/^[\\t-\\r \"'\\/<->{}\\xA0\\u1680\\u2000-\\u200A\\u2028-\\u2029\\u202F\\u205F\\u3000\\uFEFF]/,S=/^[^\"]/,C=/^[^']/,w=/^[\"']/,T=/^[^ \\t\\n\\r\\v\\f\\xA0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000\\uFEFF>]/,ee=/^[ \\t\\n\\r\\v\\f\\xA0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000\\uFEFF]/,E=Zt(),D=Xt([`\\\\`,`{`,`[`,`<`],!0,!1,!1),O=Yt(`\\x3C!--`,!1),te=Yt(`>`,!1),ne=Yt(`->`,!1),re=Yt(`-->`,!1),k=Yt(`\\\\`,!1),ie=Xt([`{`,`}`],!1,!1,!1),ae=Yt(`{`,!1),oe=Xt([`$`,`_`,`@`,`%`,`(`,`!`,`/`,[`a`,`z`],[`A`,`Z`]],!1,!1,!1),se=Yt(`<`,!1),ce=Yt(`[`,!1),le=Yt(`[[`,!1),ue=Yt(`]]`,!1),de=Yt(` `,!1),fe=Xt([`.`,`#`],!1,!1,!1),pe=Xt([[`a`,`z`],[`A`,`Z`],[`0`,`9`],`_`,`-`],!1,!1,!1),me=Xt([`$`,`_`,`@`,`%`],!1,!1,!1),he=Xt([[`a`,`z`],[`A`,`Z`],[`0`,`9`],`_`,`.`],!1,!1,!1),ge=Yt(`}`,!1),_e=Xt([`$`,`_`,`@`,`%`,`(`,`!`],!1,!1,!1),A=Yt(`/`,!1),ve=Xt([[`a`,`z`],[`A`,`Z`]],!1,!1,!1),ye=Xt([` `,`\t`,`\n`,`\\r`,`\\v`,`\\f`,`\\xA0`,` `,[` `,` `],`\\u2028`,`\\u2029`,` `,` `,` `,``,`}`],!0,!1,!1),be=Xt([[`a`,`z`],[`A`,`Z`],[`0`,`9`],`.`,`!`,`#`,`$`,`%`,`&`,`'`,`*`,`+`,`/`,`=`,`?`,`^`,`_`,\"`\",`|`,`~`,`-`],!1,!1,!1),xe=Yt(`@`,!1),Se=Xt([[`a`,`z`],[`A`,`Z`],[`0`,`9`],`.`,`-`],!1,!1,!1),Ce=Xt([[`\t`,`\\r`],` `,`/`,`>`,`\\xA0`,` `,[` `,` `],[`\\u2028`,`\\u2029`],` `,` `,` `,``],!1,!1,!1),we=Yt(`</`,!1),Te=Xt([[`a`,`z`],[`A`,`Z`],[`0`,`9`],`-`],!1,!1,!1),Ee=Xt([[`\t`,`\\r`],` `,`\"`,`'`,`/`,[`<`,`>`],`{`,`}`,`\\xA0`,` `,[` `,` `],[`\\u2028`,`\\u2029`],` `,` `,` `,``],!1,!1,!1),De=Yt(`=`,!1),Oe=Yt(`\"`,!1),ke=Xt([`\"`],!0,!1,!1),Ae=Yt(`'`,!1),je=Xt([`'`],!0,!1,!1),Me=Xt([`\"`,`'`],!1,!1,!1),Ne=Xt([` `,`\t`,`\n`,`\\r`,`\\v`,`\\f`,`\\xA0`,` `,[` `,` `],`\\u2028`,`\\u2029`,` `,` `,` `,``,`>`],!0,!1,!1),j=Xt([` `,`\t`,`\n`,`\\r`,`\\v`,`\\f`,`\\xA0`,` `,[` `,` `],`\\u2028`,`\\u2029`,` `,` `,` `,``],!1,!1,!1);function Pe(e){return lr(e)}function Fe(){return!jn}function M(e){return e}function Ie(){return!jn}function Le(e){return $n.has(e.lower)?null:e}function Re(e){return Fn=e.lower,e.kind===`open`&&Mn.isRaw(Fn)}function ze(e,t){return t}function Be(e,t){return t?[e,t]:e}function Ve(e){return e.kind===`close`}function He(e){return e}function Ue(){return!jn}function We(e){return e}function Ge(t){return Rn(Mn.rawBodyEnd(e,t,Fn))}function Ke(e){return Nn-Gt()}function qe(e,t,n){let r={start:{offset:e},end:{offset:e+t.length}};return[t?sr(`text`,r,{value:t}):null,n]}function Je(){return Gt()}function Ye(e){return sr(`text`,Kt(),{value:e})}function Xe(e){let t=sr(`text`,Kt(),{value:e});return t.comment=!0,t}function Ze(e){return e.length%2==1}function Qe(e,t){return t}function $e(t,n){let r=Kt(),i=e.charAt(r.end.offset);if(jn){if(!n&&i!==Yn&&i!==Xn)return sr(`text`,r,{value:t});let e=sr(`text`,r,{value:`\\\\`.repeat(t.length>>1)+(n||``)});return e.escape=!0,e}if(!n)return sr(`text`,r,{value:t});let a=sr(`text`,r,{value:t.slice(1)});a.end=r.end.offset-2;let o=sr(`text`,r,{value:n});return o.start=r.end.offset-2,o.escape=!0,t.length>1?[a,o]:o}function et(){return sr(`text`,Kt(),{value:Yn})}function tt(){return!jn}function nt(){return sr(`text`,Kt(),{value:`<`})}function rt(){return sr(`text`,Kt(),{value:`[`})}function it(){return!jn}function at(e,t,n,r){let i=sr(`link`,Kt(),ir(r,n,e=>In(r,n,e)));return i.selectorSpan=Ln(t,e,n),Qn(i,t)}function ot(){return!jn}function st(){zn(`Unclosed link: [[ without ]]`,Kt(),`unclosed-link`)}function ct(e){return ar(e)}function lt(){return nr}function ut(e,t){return{...e,end:t}}function dt(e,t){return[e,t]}function ft(e,t,n,r,i){let a=sr(`variable`,Kt(),{name:i,nameStart:r,nameEnd:r+i.length,scope:Zn[n]});return a.selectorSpan=Ln(t,e,r-1),Qn(a,t)}function pt(e,t,n,r){let i=sr(`expression`,Kt(),{expression:r,expressionStart:n,expressionEnd:n+r.length});return i.selectorSpan=Ln(t,e,n),Qn(i,t)}function mt(){zn(`Unclosed `+Yn+e.substr(Kt().end.offset,1)+`…: no } ends it`,Kt(),`unclosed-expression`)}function ht(t){return Rn(Mn.closeBrace(e,t,t))}function gt(e){return Nn-Gt()}function _t(e,t){return t}function vt(t,n,r,i,a,o){return Rn(Mn.closeBrace(e,o,r))}function yt(e,t,n,r,i,a){return Nn-Gt()}function bt(e,t,n,r,i,a,o){return o}function xt(e,t,n,r,i,a,o){let s=Kt(),c=i.toLowerCase(),l=sr(`macro`,s,{name:i,lower:c,rawArgs:``,isClose:!!r});return l.nameStart=a-i.length,l.nameEnd=a,l.selectorSpan=Ln(t,e,n),o===null&&zn(`Unclosed `+Yn+(r?`/`:``)+i+`…: no } ends the macro`,s,`unclosed-macro`),l.rawArgs=o.trim(),l.argsStart=l.rawArgs?a+o.length-o.trimStart().length:a,l.argsEnd=l.argsStart+l.rawArgs.length,r?(t!==nr&&zn(`A closing tag takes no selectors: `+or(l),s,`closer-with-selectors`),l.rawArgs&&zn(`A closing tag takes no arguments: `+Yn+`/`+i+` `+l.rawArgs+Xn,s,`closer-with-arguments`),l.kind=`close`):(Qn(l,t),l.kind=Object.prototype.hasOwnProperty.call(er,c)?`branch`:`open`),l}function N(e){zn(`A closing tag starts with a letter after `+Yn+`/`,Kt(),`invalid-closer`)}function St(e){return rr.test(e)}function Ct(e){return sr(`text`,Kt(),{value:e})}function wt(e,t,n,r){let i=t.toLowerCase();return sr(`html`,Kt(),{tag:t,lower:i,tagNameStart:e,tagNameEnd:e+t.length,attributes:Bn(n),attributeSpans:n,isClose:!1,isSelfClose:!!r||$n.has(i)})}function Tt(t,n){let r=e.charAt(n);r||zn(`Unclosed tag <`+t+`: no > ends it (write &lt; for a < that starts no tag)`,Kt(),`unclosed-tag`);let i={source:Kt().source,start:{offset:n,line:0,column:0},end:{offset:n+1,line:0,column:0}};zn(`Unexpected `+JSON.stringify(r)+` in the tag <`+t+`>: expected an attribute, or > to end the tag`,i,`unexpected-character`)}function Et(e,t){return sr(`html`,Kt(),{tag:t,lower:t.toLowerCase(),tagNameStart:e,tagNameEnd:e+t.length,attributes:{},attributeSpans:[],isClose:!0,isSelfClose:!1})}function Dt(e,t){return Pn=Mn.isCodeAttribute(t),!0}function Ot(e,t,n){return n}function kt(e,t,n){let r={name:t,value:n?n.value:``,nameStart:e,nameEnd:e+t.length};return n&&(r.valueStart=n.start,r.valueEnd=n.end,n.quote&&(r.quote=n.quote)),r}function At(e,t,n){return{value:t,start:e,end:n,quote:`\"`}}function jt(e,t,n){return{value:t,start:e,end:n,quote:`'`}}function Mt(e){zn(`Unclosed attribute value: the `+e+` here has no closing `+e,Kt(),`unclosed-attribute`)}function Nt(e,t,n){return{value:t,start:e,end:n}}function Pt(){return!Pn}function Ft(e){return e.length%2==1}function It(){return!Pn}function Lt(t,n){return Rn(Mn.closeBrace(e,n,t))}function Rt(e,t){return Nn-Gt()}function zt(){return!Pn}function Bt(){return Pn}let P=t.peg$currPos|0,F=P,Vt=[{line:1,column:1}],Ht=P,Ut=t.peg$maxFailExpected||[],I=t.peg$silentFails|0,Wt;if(t.startRule){if(!(t.startRule in i))throw Error(`Can't start parsing from rule \"`+t.startRule+`\".`);a=i[t.startRule]}function Gt(){return F}function Kt(){return en(F,P)}function qt(e,t){throw t=t===void 0?en(F,P):t,tn(e,t)}function Jt(t=P){let n=e.codePointAt(t);return n===void 0?``:String.fromCodePoint(n)}function Yt(e,t){return{type:`literal`,text:e,ignoreCase:t}}function Xt(e,t,n,r){return{type:`class`,parts:e,inverted:t,ignoreCase:n,unicode:r}}function Zt(){return{type:`any`}}function Qt(){return{type:`end`}}function $t(t){let n=Vt[t],r;if(n)return n;if(t>=Vt.length)r=Vt.length-1;else for(r=t;!Vt[--r];);for(n=Vt[r],n={line:n.line,column:n.column};r<t;)e.charCodeAt(r)===10?(n.line++,n.column=1):n.column++,r++;return Vt[t]=n,n}function en(e,t,n){let i=$t(e),a=$t(t),o={source:r,start:{offset:e,line:i.line,column:i.column},end:{offset:t,line:a.line,column:a.column}};return n&&r&&typeof r.offset==`function`&&(o.start=r.offset(o.start),o.end=r.offset(o.end)),o}function L(e){P<Ht||(P>Ht&&(Ht=P,Ut=[]),Ut.push(e))}function tn(e,t){return new ur(e,null,null,t)}function nn(e,t,n){return new ur(ur.buildMessage(e,t),e,t,n)}function rn(){let e,t,r;for(e=P,t=[],r=an();r!==n;)t.push(r),r=an();return F=e,t=Pe(t),e=t,e}function an(){let e,t,r,i,a;return e=cn(),e===n&&(e=un(),e===n&&(e=ln(),e===n&&(e=fn(),e===n&&(e=Sn(),e===n&&(e=P,F=P,t=Fe(),t=t?void 0:n,t===n?(P=e,e=n):(r=Cn(),r===n?(P=e,e=n):(F=e,e=M(r))),e===n&&(e=P,F=P,t=Ie(),t=t?void 0:n,t===n?(P=e,e=n):(r=wn(),r===n?(P=e,e=n):(F=e,e=Le(r))),e===n&&(e=vn(),e===n&&(e=P,t=bn(),t===n?(P=e,e=n):(r=P,F=P,i=Re(t),i=i?void 0:n,i===n?(P=r,r=n):(a=sn(),a===n?(P=r,r=n):(F=r,r=ze(t,a))),r===n&&(r=null),F=e,e=Be(t,r)),e===n&&(e=dn()))))))))),e}function on(){let e,t,r;return e=P,t=bn(),t===n?(P=e,e=n):(F=P,r=Ve(t),r=r?void 0:n,r===n?(P=e,e=n):(F=e,e=He(t))),e===n&&(e=P,F=P,t=Ue(),t=t?void 0:n,t===n?(P=e,e=n):(r=wn(),r===n?(P=e,e=n):(F=e,e=We(r)))),e}function sn(){let t,r,i,a,o,s,c,l;if(t=P,r=R(),F=P,i=Ge(r),i=i?void 0:n,i!==n){for(a=P,o=Ke(r),s=P,c=[],c.length>=(o|0)?l=n:e.length>P?(l=e.charAt(P),P++):(l=n,I===0&&L(E));l!==n;)c.push(l),c.length>=(o|0)?l=n:e.length>P?(l=e.charAt(P),P++):(l=n,I===0&&L(E));c.length<(o|0)?(P=s,s=n):s=c,o=s,a=o===n?o:e.substring(a,P),a===n?(P=t,t=n):(o=on(),o===n?(P=t,t=n):(F=t,t=qe(r,a,o)))}else P=t,t=n;return t}function R(){let e,t;return e=P,t=``,F=e,t=Je(),e=t,e}function cn(){let t,r,i,a;if(t=P,r=P,i=[],a=e.charAt(P),s.test(a)?P++:(a=n,I===0&&L(D)),a!==n)for(;a!==n;)i.push(a),a=e.charAt(P),s.test(a)?P++:(a=n,I===0&&L(D));else i=n;return r=i===n?i:e.substring(r,P),r!==n&&(F=t,r=Ye(r)),t=r,t}function ln(){let t,r,i,a,s,c,l,u,d;if(t=P,r=P,i=P,e.substr(P,4)===o?(a=o,P+=4):(a=n,I===0&&L(O)),a!==n){if(e.charCodeAt(P)===62?(s=`>`,P++):(s=n,I===0&&L(te)),s===n&&(e.substr(P,2)===`->`?(s=`->`,P+=2):(s=n,I===0&&L(ne)),s===n)){for(s=P,c=[],l=P,u=P,I++,e.substr(P,3)===`-->`?(d=`-->`,P+=3):(d=n,I===0&&L(re)),I--,d===n?u=void 0:(P=u,u=n),u===n?(P=l,l=n):(e.length>P?(d=e.charAt(P),P++):(d=n,I===0&&L(E)),d===n?(P=l,l=n):(u=[u,d],l=u));l!==n;)c.push(l),l=P,u=P,I++,e.substr(P,3)===`-->`?(d=`-->`,P+=3):(d=n,I===0&&L(re)),I--,d===n?u=void 0:(P=u,u=n),u===n?(P=l,l=n):(e.length>P?(d=e.charAt(P),P++):(d=n,I===0&&L(E)),d===n?(P=l,l=n):(u=[u,d],l=u));e.substr(P,3)===`-->`?(l=`-->`,P+=3):(l=n,I===0&&L(re)),l===n?(P=s,s=n):(c=[c,l],s=c)}s===n?(P=i,i=n):(a=[a,s],i=a)}else P=i,i=n;return r=i===n?i:e.substring(r,P),r!==n&&(F=t,r=Xe(r)),t=r,t}function un(){let t,r,i,a,o;if(t=P,r=P,i=[],e.charCodeAt(P)===92?(a=`\\\\`,P++):(a=n,I===0&&L(k)),a!==n)for(;a!==n;)i.push(a),e.charCodeAt(P)===92?(a=`\\\\`,P++):(a=n,I===0&&L(k));else i=n;return r=i===n?i:e.substring(r,P),r===n?(P=t,t=n):(i=P,F=P,a=Ze(r),a=a?void 0:n,a===n?(P=i,i=n):(o=e.charAt(P),c.test(o)?P++:(o=n,I===0&&L(ie)),o===n?(P=i,i=n):(F=i,i=Qe(r,o))),i===n&&(i=null),F=t,t=$e(r,i)),t}function dn(){let t,r,i,a,o,s;return t=P,e.charCodeAt(P)===123?(r=`{`,P++):(r=n,I===0&&L(ae)),r===n?(P=t,t=n):(i=P,I++,a=P,o=mn(),o===n?(P=a,a=n):(s=e.charAt(P),l.test(s)?P++:(s=n,I===0&&L(oe)),s===n?(P=a,a=n):(o=[o,s],a=o)),I--,a===n?i=void 0:(P=i,i=n),i===n?(P=t,t=n):(F=t,t=et())),t===n&&(t=P,r=P,I++,i=P,F=P,a=tt(),a=a?void 0:n,a===n?(P=i,i=n):(o=wn(),o===n?(P=i,i=n):(a=[a,o],i=a)),I--,i===n?r=void 0:(P=r,r=n),r===n?(P=t,t=n):(e.charCodeAt(P)===60?(i=`<`,P++):(i=n,I===0&&L(se)),i===n?(P=t,t=n):(F=t,t=nt())),t===n&&(t=P,e.charCodeAt(P)===91?(r=`[`,P++):(r=n,I===0&&L(ce)),r!==n&&(F=t,r=rt()),t=r)),t}function fn(){let t,r,i,a,o,s,c,l;return t=P,F=P,r=it(),r=r?void 0:n,r===n?(P=t,t=n):(e.substr(P,2)===`[[`?(i=`[[`,P+=2):(i=n,I===0&&L(le)),i===n?(P=t,t=n):(a=R(),o=mn(),o===n?(P=t,t=n):(s=R(),c=P,l=pn(),c=e.substring(c,P),e.substr(P,2)===`]]`?(l=`]]`,P+=2):(l=n,I===0&&L(ue)),l===n?(P=t,t=n):(F=t,t=at(a,o,s,c))))),t===n&&(t=P,F=P,r=ot(),r=r?void 0:n,r===n?(P=t,t=n):(e.substr(P,2)===`[[`?(i=`[[`,P+=2):(i=n,I===0&&L(le)),i===n?(P=t,t=n):(F=t,t=st()))),t}function pn(){let t,r,i,a;for(t=[],r=P,i=P,I++,e.substr(P,2)===`]]`?(a=`]]`,P+=2):(a=n,I===0&&L(ue)),a===n&&(e.substr(P,2)===`[[`?(a=`[[`,P+=2):(a=n,I===0&&L(le))),I--,a===n?i=void 0:(P=i,i=n),i===n?(P=r,r=n):(e.length>P?(a=e.charAt(P),P++):(a=n,I===0&&L(E)),a===n?(P=r,r=n):(i=[i,a],r=i));r!==n;)t.push(r),r=P,i=P,I++,e.substr(P,2)===`]]`?(a=`]]`,P+=2):(a=n,I===0&&L(ue)),a===n&&(e.substr(P,2)===`[[`?(a=`[[`,P+=2):(a=n,I===0&&L(le))),I--,a===n?i=void 0:(P=i,i=n),i===n?(P=r,r=n):(e.length>P?(a=e.charAt(P),P++):(a=n,I===0&&L(E)),a===n?(P=r,r=n):(i=[i,a],r=i));return t}function mn(){let t,r,i;if(t=P,r=[],i=gn(),i!==n)for(;i!==n;)r.push(i),i=gn();else r=n;return r===n?(P=t,t=n):(e.charCodeAt(P)===32?(i=` `,P++):(i=n,I===0&&L(de)),i===n&&(i=null),F=t,t=ct(r)),t===n&&(t=P,r=``,F=t,r=lt(),t=r),t}function hn(){let t,r,i,a,o;if(t=P,r=mn(),r!==n){for(i=R(),a=[],e.length>P?(o=e.charAt(P),P++):(o=n,I===0&&L(E));o!==n;)a.push(o),e.length>P?(o=e.charAt(P),P++):(o=n,I===0&&L(E));F=t,t=ut(r,i)}else P=t,t=n;return t}function gn(){let t,r,i,a,o;if(t=P,r=e.charAt(P),u.test(r)?P++:(r=n,I===0&&L(fe)),r!==n){for(i=P,a=[],o=_n();o!==n;)a.push(o),o=_n();i=e.substring(i,P),F=t,t=dt(r,i)}else P=t,t=n;return t}function _n(){let t,r,i,a,o;if(t=e.charAt(P),d.test(t)?P++:(t=n,I===0&&L(pe)),t===n)if(t=P,e.charCodeAt(P)===123?(r=`{`,P++):(r=n,I===0&&L(ae)),r!==n)if(i=e.charAt(P),f.test(i)?P++:(i=n,I===0&&L(me)),i!==n){for(a=[],o=e.charAt(P),p.test(o)?P++:(o=n,I===0&&L(he));o!==n;)a.push(o),o=e.charAt(P),p.test(o)?P++:(o=n,I===0&&L(he));e.charCodeAt(P)===125?(o=`}`,P++):(o=n,I===0&&L(ge)),o===n?(P=t,t=n):(r=[r,i,a,o],t=r)}else P=t,t=n;else P=t,t=n;return t}function vn(){let t,r,i,a,o,s,c,l,u;if(t=P,e.charCodeAt(P)===123?(r=`{`,P++):(r=n,I===0&&L(ae)),r!==n)if(i=R(),a=mn(),a!==n)if(o=e.charAt(P),f.test(o)?P++:(o=n,I===0&&L(me)),o!==n){for(s=R(),c=P,l=[],u=e.charAt(P),p.test(u)?P++:(u=n,I===0&&L(he));u!==n;)l.push(u),u=e.charAt(P),p.test(u)?P++:(u=n,I===0&&L(he));c=e.substring(c,P),e.charCodeAt(P)===125?(l=`}`,P++):(l=n,I===0&&L(ge)),l===n?(P=t,t=n):(F=t,t=ft(i,a,o,s,c))}else P=t,t=n;else P=t,t=n;else P=t,t=n;return t===n&&(t=P,e.charCodeAt(P)===123?(r=`{`,P++):(r=n,I===0&&L(ae)),r===n?(P=t,t=n):(i=R(),a=mn(),a===n?(P=t,t=n):(o=R(),s=P,I++,c=e.charAt(P),m.test(c)?P++:(c=n,I===0&&L(_e)),I--,c===n?s=n:(P=s,s=void 0),s===n?(P=t,t=n):(c=yn(),c===n?(P=t,t=n):(e.charCodeAt(P)===125?(l=`}`,P++):(l=n,I===0&&L(ge)),l===n?(P=t,t=n):(F=t,t=pt(i,a,o,c)))))),t===n&&(t=P,e.charCodeAt(P)===123?(r=`{`,P++):(r=n,I===0&&L(ae)),r===n?(P=t,t=n):(i=mn(),i===n?(P=t,t=n):(a=P,I++,o=e.charAt(P),m.test(o)?P++:(o=n,I===0&&L(_e)),I--,o===n?a=n:(P=a,a=void 0),a===n?(P=t,t=n):(F=t,t=mt()))))),t}function yn(){let t,r,i,a,o,s,c,l;if(t=P,r=R(),F=P,i=ht(r),i=i?void 0:n,i!==n){for(a=P,o=gt(r),s=P,c=[],c.length>=(o|0)?l=n:e.length>P?(l=e.charAt(P),P++):(l=n,I===0&&L(E));l!==n;)c.push(l),c.length>=(o|0)?l=n:e.length>P?(l=e.charAt(P),P++):(l=n,I===0&&L(E));c.length<(o|0)?(P=s,s=n):s=c,o=s,a=o===n?o:e.substring(a,P),a===n?(P=t,t=n):(F=t,t=_t(r,a))}else P=t,t=n;return t}function bn(){let t,r,i,a,o,s,c,l,u,d,f,p,m,h,g;if(t=P,e.charCodeAt(P)===123?(r=`{`,P++):(r=n,I===0&&L(ae)),r!==n)if(i=R(),a=mn(),a!==n)if(o=R(),e.charCodeAt(P)===47?(s=`/`,P++):(s=n,I===0&&L(A)),s===n&&(s=null),c=xn(),c!==n){if(l=R(),u=P,F=P,d=vt(i,a,o,s,c,l),d=d?void 0:n,d!==n){for(f=P,p=yt(i,a,o,s,c,l),m=P,h=[],h.length>=(p|0)?g=n:e.length>P?(g=e.charAt(P),P++):(g=n,I===0&&L(E));g!==n;)h.push(g),h.length>=(p|0)?g=n:e.length>P?(g=e.charAt(P),P++):(g=n,I===0&&L(E));h.length<(p|0)?(P=m,m=n):m=h,p=m,f=p===n?p:e.substring(f,P),f===n?(P=u,u=n):(e.charCodeAt(P)===125?(p=`}`,P++):(p=n,I===0&&L(ge)),p===n?(P=u,u=n):(F=u,u=bt(i,a,o,s,c,l,f)))}else P=u,u=n;u===n&&(u=null),F=t,t=xt(i,a,o,s,c,l,u)}else P=t,t=n;else P=t,t=n;else P=t,t=n;return t===n&&(t=P,e.charCodeAt(P)===123?(r=`{`,P++):(r=n,I===0&&L(ae)),r===n?(P=t,t=n):(i=mn(),i===n?(P=t,t=n):(e.charCodeAt(P)===47?(a=`/`,P++):(a=n,I===0&&L(A)),a===n?(P=t,t=n):(F=t,t=N(i))))),t}function xn(){let t,r,i,a,o;if(t=P,r=P,i=e.charAt(P),h.test(i)?P++:(i=n,I===0&&L(ve)),i!==n){for(a=[],o=e.charAt(P),g.test(o)?P++:(o=n,I===0&&L(ye));o!==n;)a.push(o),o=e.charAt(P),g.test(o)?P++:(o=n,I===0&&L(ye));i=[i,a],r=i}else P=r,r=n;return t=r===n?r:e.substring(t,P),t}function Sn(){let t,r,i,a,o,s,c,l;if(t=P,r=P,i=P,e.charCodeAt(P)===60?(a=`<`,P++):(a=n,I===0&&L(se)),a!==n){if(o=[],s=e.charAt(P),_.test(s)?P++:(s=n,I===0&&L(be)),s!==n)for(;s!==n;)o.push(s),s=e.charAt(P),_.test(s)?P++:(s=n,I===0&&L(be));else o=n;if(o!==n)if(e.charCodeAt(P)===64?(s=`@`,P++):(s=n,I===0&&L(xe)),s!==n){if(c=[],l=e.charAt(P),v.test(l)?P++:(l=n,I===0&&L(Se)),l!==n)for(;l!==n;)c.push(l),l=e.charAt(P),v.test(l)?P++:(l=n,I===0&&L(Se));else c=n;c===n?(P=i,i=n):(e.charCodeAt(P)===62?(l=`>`,P++):(l=n,I===0&&L(te)),l===n?(P=i,i=n):(a=[a,o,s,c,l],i=a))}else P=i,i=n;else P=i,i=n}else P=i,i=n;return r=i===n?i:e.substring(r,P),r===n?(P=t,t=n):(F=P,i=St(r),i=i?void 0:n,i===n?(P=t,t=n):(F=t,t=Ct(r))),t}function Cn(){let t,r,i,a,o,s,c,l;if(t=P,e.charCodeAt(P)===60?(r=`<`,P++):(r=n,I===0&&L(se)),r!==n)if(i=R(),a=Tn(),a!==n){for(o=[],s=En();s!==n;)o.push(s),s=En();s=kn(),e.charCodeAt(P)===47?(c=`/`,P++):(c=n,I===0&&L(A)),c===n&&(c=null),e.charCodeAt(P)===62?(l=`>`,P++):(l=n,I===0&&L(te)),l===n?(P=t,t=n):(F=t,t=wt(i,a,o,c))}else P=t,t=n;else P=t,t=n;if(t===n)if(t=P,e.charCodeAt(P)===60?(r=`<`,P++):(r=n,I===0&&L(se)),r!==n)if(i=Tn(),i!==n)if(a=P,I++,o=e.charAt(P),y.test(o)?P++:(o=n,I===0&&L(Ce)),o===n&&(o=P,I++,e.length>P?(s=e.charAt(P),P++):(s=n,I===0&&L(E)),I--,s===n?o=void 0:(P=o,o=n)),I--,o===n?a=n:(P=a,a=void 0),a!==n){for(o=[],s=En();s!==n;)o.push(s),s=En();s=kn(),c=R(),F=t,t=Tt(i,c)}else P=t,t=n;else P=t,t=n;else P=t,t=n;return t}function wn(){let t,r,i,a,o;return t=P,e.substr(P,2)===`</`?(r=`</`,P+=2):(r=n,I===0&&L(we)),r===n?(P=t,t=n):(i=R(),a=Tn(),a===n?(P=t,t=n):(kn(),e.charCodeAt(P)===62?(o=`>`,P++):(o=n,I===0&&L(te)),o===n?(P=t,t=n):(F=t,t=Et(i,a)))),t}function Tn(){let t,r,i,a,o;if(t=P,r=P,i=e.charAt(P),h.test(i)?P++:(i=n,I===0&&L(ve)),i!==n){for(a=[],o=e.charAt(P),b.test(o)?P++:(o=n,I===0&&L(Te));o!==n;)a.push(o),o=e.charAt(P),b.test(o)?P++:(o=n,I===0&&L(Te));i=[i,a],r=i}else P=r,r=n;return t=r===n?r:e.substring(t,P),t}function En(){let t,r,i,a,o,s,c,l;if(t=P,kn(),r=R(),i=P,a=[],o=P,s=P,I++,c=e.charAt(P),x.test(c)?P++:(c=n,I===0&&L(Ee)),I--,c===n?s=void 0:(P=s,s=n),s===n?(P=o,o=n):(e.length>P?(c=e.charAt(P),P++):(c=n,I===0&&L(E)),c===n?(P=o,o=n):(s=[s,c],o=s)),o!==n)for(;o!==n;)a.push(o),o=P,s=P,I++,c=e.charAt(P),x.test(c)?P++:(c=n,I===0&&L(Ee)),I--,c===n?s=void 0:(P=s,s=n),s===n?(P=o,o=n):(e.length>P?(c=e.charAt(P),P++):(c=n,I===0&&L(E)),c===n?(P=o,o=n):(s=[s,c],o=s));else a=n;return i=a===n?a:e.substring(i,P),i===n?(P=t,t=n):(F=P,a=Dt(r,i),a=a?void 0:n,a===n?(P=t,t=n):(o=P,s=kn(),e.charCodeAt(P)===61?(c=`=`,P++):(c=n,I===0&&L(De)),c===n?(P=o,o=n):(kn(),l=Dn(),l===n?(P=o,o=n):(F=o,o=Ot(r,i,l))),o===n&&(o=null),F=t,t=kt(r,i,o))),t}function Dn(){let t,r,i,a,o,s;if(t=P,e.charCodeAt(P)===34?(r=`\"`,P++):(r=n,I===0&&L(Oe)),r!==n){for(i=R(),a=P,o=[],s=On(),s===n&&(s=e.charAt(P),S.test(s)?P++:(s=n,I===0&&L(ke)));s!==n;)o.push(s),s=On(),s===n&&(s=e.charAt(P),S.test(s)?P++:(s=n,I===0&&L(ke)));a=e.substring(a,P),o=R(),e.charCodeAt(P)===34?(s=`\"`,P++):(s=n,I===0&&L(Oe)),s===n?(P=t,t=n):(F=t,t=At(i,a,o))}else P=t,t=n;if(t===n){if(t=P,e.charCodeAt(P)===39?(r=`'`,P++):(r=n,I===0&&L(Ae)),r!==n){for(i=R(),a=P,o=[],s=On(),s===n&&(s=e.charAt(P),C.test(s)?P++:(s=n,I===0&&L(je)));s!==n;)o.push(s),s=On(),s===n&&(s=e.charAt(P),C.test(s)?P++:(s=n,I===0&&L(je)));a=e.substring(a,P),o=R(),e.charCodeAt(P)===39?(s=`'`,P++):(s=n,I===0&&L(Ae)),s===n?(P=t,t=n):(F=t,t=jt(i,a,o))}else P=t,t=n;if(t===n&&(t=P,r=e.charAt(P),w.test(r)?P++:(r=n,I===0&&L(Me)),r!==n&&(F=t,r=Mt(r)),t=r,t===n)){for(t=P,r=R(),i=P,a=[],o=e.charAt(P),T.test(o)?P++:(o=n,I===0&&L(Ne));o!==n;)a.push(o),o=e.charAt(P),T.test(o)?P++:(o=n,I===0&&L(Ne));i=e.substring(i,P),a=R(),F=t,t=Nt(r,i,a)}}return t}function On(){let t,r,i,a,o,s,l,u,d,p,m,g,_,v;if(t=P,F=P,r=Pt(),r=r?void 0:n,r!==n){if(i=P,a=[],e.charCodeAt(P)===92?(o=`\\\\`,P++):(o=n,I===0&&L(k)),o!==n)for(;o!==n;)a.push(o),e.charCodeAt(P)===92?(o=`\\\\`,P++):(o=n,I===0&&L(k));else a=n;i=a===n?a:e.substring(i,P),i===n?(P=t,t=n):(a=P,F=P,o=Ft(i),o=o?void 0:n,o===n?(P=a,a=n):(s=e.charAt(P),c.test(s)?P++:(s=n,I===0&&L(ie)),s===n?(P=a,a=n):(o=[o,s],a=o)),a===n&&(a=null),r=[r,i,a],t=r)}else P=t,t=n;if(t===n){if(t=P,F=P,r=It(),r=r?void 0:n,r!==n)if(e.charCodeAt(P)===123?(i=`{`,P++):(i=n,I===0&&L(ae)),i!==n)if(a=mn(),a!==n)if(o=R(),e.charCodeAt(P)===47?(s=`/`,P++):(s=n,I===0&&L(A)),s===n&&(s=null),l=xn(),l!==n)if(u=R(),F=P,d=Lt(o,u),d=d?void 0:n,d!==n){for(p=P,m=Rt(o,u),g=P,_=[],_.length>=(m|0)?v=n:e.length>P?(v=e.charAt(P),P++):(v=n,I===0&&L(E));v!==n;)_.push(v),_.length>=(m|0)?v=n:e.length>P?(v=e.charAt(P),P++):(v=n,I===0&&L(E));_.length<(m|0)?(P=g,g=n):g=_,m=g,p=m===n?m:e.substring(p,P),p===n?(P=t,t=n):(e.charCodeAt(P)===125?(m=`}`,P++):(m=n,I===0&&L(ge)),m===n?(P=t,t=n):(r=[r,i,a,o,s,l,u,d,p,m],t=r))}else P=t,t=n;else P=t,t=n;else P=t,t=n;else P=t,t=n;else P=t,t=n;t===n&&(t=P,F=P,r=zt(),r=r?void 0:n,r===n?(P=t,t=n):(e.charCodeAt(P)===123?(i=`{`,P++):(i=n,I===0&&L(ae)),i===n?(P=t,t=n):(a=mn(),a===n?(P=t,t=n):(o=P,I++,s=P,e.charCodeAt(P)===47?(l=`/`,P++):(l=n,I===0&&L(A)),l===n&&(l=null),u=e.charAt(P),h.test(u)?P++:(u=n,I===0&&L(ve)),u===n?(P=s,s=n):(l=[l,u],s=l),I--,s===n?o=void 0:(P=o,o=n),o===n?(P=t,t=n):(s=yn(),s===n?(P=t,t=n):(e.charCodeAt(P)===125?(l=`}`,P++):(l=n,I===0&&L(ge)),l===n?(P=t,t=n):(r=[r,i,a,o,s,l],t=r)))))),t===n&&(t=P,F=P,r=Bt(),r=r?void 0:n,r===n?(P=t,t=n):(e.charCodeAt(P)===123?(i=`{`,P++):(i=n,I===0&&L(ae)),i===n?(P=t,t=n):(a=P,I++,o=e.charAt(P),f.test(o)?P++:(o=n,I===0&&L(me)),I--,o===n?a=n:(P=a,a=void 0),a===n?(P=t,t=n):(o=yn(),o===n?(P=t,t=n):(e.charCodeAt(P)===125?(s=`}`,P++):(s=n,I===0&&L(ge)),s===n?(P=t,t=n):(r=[r,i,a,o,s],t=r)))))))}return t}function kn(){let e,t;for(e=[],t=An();t!==n;)e.push(t),t=An();return e}function An(){let t;return t=e.charAt(P),ee.test(t)?P++:(t=n,I===0&&L(j)),t}let jn=t.text===!0,Mn=t.hooks,Nn=-1,Pn=!1,Fn=``;function In(t,n,r){for(let i=0;i<t.length;i++){let a=t.charAt(i);if(a===`\\\\`&&/[{}]/.test(t.charAt(i+1)))i++;else if(a===Yn){let r=/^(?:[.#][\\w-]*)* ?(\\/?[a-zA-Z][\\w-]*|(?=[$_@%(!]))/.exec(t.slice(i+1));if(!r)continue;let a=Mn.closeBrace(e,n+i+1+r[0].length,n+i+1);a!==-1&&a<n+t.length&&(i=a-n)}else if(t.startsWith(r,i))return i}return-1}function Ln(t,n,r){return t===nr?{}:{selectorsStart:n,selectorsEnd:e.charAt(r-1)===` `?r-1:r}}function Rn(e){return Nn=e,e>=0}function zn(e,t,n){try{qt(e,t)}catch(e){throw e.code=n,e}}function Bn(e){let t={},n=new Set;for(let{name:r,value:i}of e){let e=r.toLowerCase();n.has(e)||(n.add(e),Object.defineProperty(t,r,{value:i,enumerable:!0,writable:!0,configurable:!0}))}return t}Wt=a();let Vn=Wt!==n&&P===e.length;function Hn(){throw Wt!==n&&P<e.length&&L(Qt()),nn(Ut,Ht<e.length?Jt(Ht):null,Ht<e.length?en(Ht,Ht+1):en(Ht,Ht))}if(t.peg$library)return{peg$result:Wt,peg$currPos:P,peg$FAILED:n,peg$maxFailExpected:Ut,peg$maxFailPos:Ht,peg$success:Vn,peg$throw:Vn?void 0:Hn};if(Vn)return Wt;Hn()}var fr=class extends Map{get(e){return super.get(e.toLowerCase())}set(e,t){return super.set(e.toLowerCase(),t)}has(e){return super.has(e.toLowerCase())}delete(e){return super.delete(e.toLowerCase())}},pr=class{constructor(e=[]){this.names=new fr;for(let t of e)this.add(t)}add(e){this.names.set(e,!0)}has(e){return this.names.has(e)}delete(e){this.names.delete(e)}},mr=new pr([`if`,`for`,`do`,`button`,`link`,`listbox`,`cycle`,`switch`,`timed`,`repeat`,`type`,`widget`,`span`,`nobr`]),hr=new Set([`do`]);function gr(e){return hr.has(e)}function _r(e){return mr.has(e)}function vr(e){mr.add(e)}var yr=new Set([`if`,`switch`,`timed`]),br=e=>`\"${e.replace(/[\\\\\"]/g,`\\\\$&`)}\"`;function xr(e){return e.map(Sr)}function Sr({token:e,body:t}){switch(e.type){case`text`:return e.comment?{type:`text`,value:e.value,comment:!0}:{type:`text`,value:e.value};case`link`:return qn({type:`macro`,name:`link`,rawArgs:`${br(e.display)} ${br(e.target)}`,children:[]},e);case`variable`:return qn({type:`variable`,name:e.name,scope:e.scope},e);case`expression`:return qn({type:`expression`,expression:e.expression},e);case`html`:return{type:`html`,tag:e.tag,attributes:e.attributes,children:t?xr(t.children):[]};case`macro`:{let n=e.name.toLowerCase(),r={type:`macro`,name:n,rawArgs:e.rawArgs,children:[]};if(!t)return qn(r,e);let i=xr(t.children);if(!yr.has(n))return r.children=i,qn(r,e);let a=(e,t)=>qn({rawArgs:e.rawArgs,children:t},e);return r.branches=[a(e,i),...t.branches.map(({tag:e,children:t})=>a(e,xr(t)))],r}}}function Cr(e,t){let n=1,r=0;for(let i=e.indexOf(`\n`);i!==-1&&i<t;)n++,r=i+1,i=e.indexOf(`\n`,r);return{line:n,column:t-r+1}}var wr=e=>e[e.length-1],Tr={elseif:`if`,else:`if`,case:`switch`,default:`switch`,next:`timed`},Er=e=>e.type===`macro`&&!e.isClose&&Object.prototype.hasOwnProperty.call(Tr,e.name.toLowerCase()),Dr=e=>Or(e).toLowerCase(),Or=e=>e.type===`macro`?e.name:e.tag;function kr(e){return e.type===`html`?`${e.isClose?`</`:`<`}${e.tag}>`:`{${e.isClose?`/`:``}${e.name}}`}var Ar=e=>e.type===`html`?`</${e.tag}>`:`{/${e.name}}`,jr=(e,t)=>e.type===t.type&&Dr(e)===Dr(t);function Mr(e,t={}){let n=t.isBlock??_r,r=t.isRaw??gr,i=[],a=(e[e.length-1]?.end??0)+1,o=e=>{if(t.source===void 0)return`offset ${e}`;let{line:n,column:r}=Cr(t.source,e);return`line ${n}, column ${r}`},s=(e,t,n,r,a)=>{i.push({code:e,message:n,start:t.start,end:t.end,noticedAt:r,data:a})},c=(e,t,n)=>{let r=Tr[e.name.toLowerCase()],i=t?`, not inside ${kr(t)}`:``;s(`misplaced-branch`,e,`${kr(e)} must be directly inside {${r}}${i}`,n,{name:e.name,parent:r,...t&&{inside:Or(t)}})},l=[],u=[],d=e=>(wr(u)?.into??l).push(e),f=(e,t,n=e===`closed`)=>{let{node:r,body:i}=u.pop(),l=r.token,f=t?t.end:a;for(let{tag:e}of i.branches){let t=Tr[e.name.toLowerCase()];(l.type!==`macro`||Dr(l)!==t)&&c(e,l,f)}e===`unclosed`?s(`unclosed-block`,l,`Unclosed ${kr(l)}: no ${Ar(l)} closes it`,f,{name:Or(l)}):e===`mismatch`&&s(`mismatched-closer`,t,`${kr(t)} found where ${Ar(l)} should close the ${kr(l)} opened at ${o(l.start)}`,f,{name:Or(l),closer:Or(t)}),n&&(i.close=t),r.end=i.close?.end??Pr(i)??l.end,d(r)};for(let t=0;t<e.length;t++){let i=e[t];if((i.type===`macro`||i.type===`html`)&&i.isClose){let e=wr(u);if(!e)s(`stray-closer`,i,`${kr(i)} closes nothing: no ${i.type===`html`?`<${i.tag}>`:`{${i.name}}`} is open here`,i.start,{name:Or(i)});else if(jr(e.node.token,i))f(`closed`,i);else{let e=u.length-1;for(;e>=0&&!jr(u[e].node.token,i);)e--;if(f(`mismatch`,i,e===-1),e!==-1){for(;u.length>e+1;)f(`cut`,i);f(`closed`,i)}}continue}if(Er(i)){let e=i,t=wr(u);if(!t){c(e,void 0,e.start);continue}let n={tag:e,children:[]};t.body.branches.push(n),t.into=n.children;continue}let a={token:i,start:i.start,end:i.end},o=i.type===`html`?!i.isSelfClose:i.type===`macro`&&n(i.name.toLowerCase());if(o&&i.type===`macro`&&r(i.name.toLowerCase())&&!Nr(i,e[t+1],e[t+2])){s(`unclosed-block`,i,`Unclosed ${kr(i)}: no ${Ar(i)} closes it`,i.end,{name:Or(i)}),d(a);continue}if(!o){d(a);continue}let l={children:[],branches:[]};a.body=l,u.push({node:a,body:l,into:l.children})}for(;u.length>0;)f(`unclosed`);return{nodes:l,errors:i}}function Nr(e,t,n){let r=t=>t?.type===`macro`&&t.isClose&&jr(e,t);return r(t)||t?.type===`text`&&r(n)}function Pr(e){let t=wr(e.branches);return wr(t?.children??e.children)?.end??t?.tag.end}var Fr=[509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,7,9,32,4,318,1,31,4,33,15,71,10,50,3,123,2,54,14,32,10,3,1,11,3,46,10,8,0,46,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,2,11,83,11,7,0,3,0,158,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,68,8,2,0,3,0,2,3,2,4,2,0,15,1,83,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,7,19,58,14,5,9,243,14,166,9,71,5,2,1,3,3,2,0,2,1,13,9,120,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,199,7,137,9,54,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,55,9,7,0,259,3,10,1,2,0,49,6,4,4,14,10,5350,0,7,14,11465,27,2343,9,87,9,39,4,60,6,26,9,535,9,470,0,2,54,8,3,82,0,12,1,19628,1,4178,9,519,45,3,22,481,1,61,4,4,5,9,7,3,6,31,3,149,2,12,2,9,1,3,0,33,1,1357,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,101,0,161,6,10,9,357,0,62,13,499,13,245,1,2,9,233,0,3,0,8,1,6,0,475,6,110,6,6,9,4759,9,787719,239],Ir=[0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,13,10,2,14,2,6,2,1,2,10,2,14,2,6,2,1,4,51,13,310,10,21,11,7,25,5,2,41,2,13,65,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,7,25,39,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,39,27,10,22,251,41,7,1,17,5,18,21,18,28,11,0,9,21,43,17,47,20,28,22,13,52,58,1,3,0,14,44,33,24,27,35,30,0,3,0,9,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,20,1,64,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,31,9,2,0,3,0,2,37,2,0,26,0,2,0,45,52,19,3,21,2,31,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,38,6,186,43,117,63,32,7,3,0,3,7,2,1,2,23,16,0,2,0,95,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,19,72,18,0,182,32,32,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,24,43,22,0,239,18,16,0,2,12,2,33,125,0,80,921,103,111,6,206,13,310,2314,96,16,1071,18,5,26,3994,6,582,6842,29,1763,568,8,30,18,78,18,29,19,47,17,3,32,20,6,18,433,44,212,63,33,24,3,24,45,74,6,0,67,12,65,1,2,0,15,4,10,7386,37,33,96,114,14,913,15,50,7710,3,2,6,2,1,2,296,10,0,30,2,3,0,15,4,8,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,340,2,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,1845,129,15,6,55,50,49,61,147,44,11,6,17,0,322,29,19,43,485,27,229,29,3,0,208,30,2,2,2,1,2,6,3,4,10,1,225,6,2,3,2,1,2,14,2,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42719,33,4382,2,5773,3,7472,16,621,2467,541,1507,4938,6,8489,39815,11327],Lr=`‌‍·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄ-׉ؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߽߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛ࢗ-࢟࣊-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯৾ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍୓-ୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఄ఼ా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ೳഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ඁ-ඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ຼ່-໎໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜕ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠏-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᪿ-᫰ᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭᳴᳷-᳹᷀-᷿‌‍‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯・꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧ꠬ꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱ꣿ-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_・`,Rr=`ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆ՘ՙՠ-ֈ֋֌א-תׯ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࡰ-ࢇࢉ-࢏ࢠ-ࣉऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚ౜ౝౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽ೜-ೞೠೡೱೲഄ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄຆ-ຊຌ-ຣລວ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜑᜟ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡸᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭌᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-ᲊᲐ-ᲺᲽ-Ჿᳩ-ᳬᳮ-ᳳᳵᳶᳺᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿ₏-₟ℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆿㇰ-ㇿ㐀-䶿一-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-꟝꟢꟱-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꣾꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭩ꭬꭭ꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ`,zr={3:`abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile`,5:`class enum extends super const export import`,6:`enum`,strict:`implements interface let package private protected public static yield`,strictBind:`eval arguments`},Br=`break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this`,Vr={5:Br,\"5module\":Br+` export import`,6:Br+` const class extends export import super`},Hr=/^in(stanceof)?$/,Ur=RegExp(`[`+Rr+`]`),Wr=RegExp(`[`+Rr+Lr+`]`);function Gr(e,t){for(var n=65536,r=0;r<t.length;r+=2){if(n+=t[r],n>e)return!1;if(n+=t[r+1],n>=e)return!0}return!1}function Kr(e,t){return e<65?e===36:e<91?!0:e<97?e===95:e<123?!0:e<=65535?e>=170&&Ur.test(String.fromCharCode(e)):t===!1?!1:Gr(e,Ir)}function qr(e,t){return e<48?e===36:e<58?!0:e<65?!1:e<91?!0:e<97?e===95:e<123?!0:e<=65535?e>=170&&Wr.test(String.fromCharCode(e)):t===!1?!1:Gr(e,Ir)||Gr(e,Fr)}var z=function(e,t){t===void 0&&(t={}),this.label=e,this.keyword=t.keyword,this.beforeExpr=!!t.beforeExpr,this.startsExpr=!!t.startsExpr,this.isLoop=!!t.isLoop,this.isAssign=!!t.isAssign,this.prefix=!!t.prefix,this.postfix=!!t.postfix,this.binop=t.binop||null,this.updateContext=null};function Jr(e,t){return new z(e,{beforeExpr:!0,binop:t})}var Yr={beforeExpr:!0},Xr={startsExpr:!0},Zr={};function B(e,t){return t===void 0&&(t={}),t.keyword=e,Zr[e]=new z(e,t)}var V={num:new z(`num`,Xr),regexp:new z(`regexp`,Xr),string:new z(`string`,Xr),name:new z(`name`,Xr),privateId:new z(`privateId`,Xr),eof:new z(`eof`),bracketL:new z(`[`,{beforeExpr:!0,startsExpr:!0}),bracketR:new z(`]`),braceL:new z(`{`,{beforeExpr:!0,startsExpr:!0}),braceR:new z(`}`),parenL:new z(`(`,{beforeExpr:!0,startsExpr:!0}),parenR:new z(`)`),comma:new z(`,`,Yr),semi:new z(`;`,Yr),colon:new z(`:`,Yr),dot:new z(`.`),question:new z(`?`,Yr),questionDot:new z(`?.`),arrow:new z(`=>`,Yr),template:new z(`template`),invalidTemplate:new z(`invalidTemplate`),ellipsis:new z(`...`,Yr),backQuote:new z(\"`\",Xr),dollarBraceL:new z(\"${\",{beforeExpr:!0,startsExpr:!0}),eq:new z(`=`,{beforeExpr:!0,isAssign:!0}),assign:new z(`_=`,{beforeExpr:!0,isAssign:!0}),incDec:new z(`++/--`,{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new z(`!/~`,{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:Jr(`||`,1),logicalAND:Jr(`&&`,2),bitwiseOR:Jr(`|`,3),bitwiseXOR:Jr(`^`,4),bitwiseAND:Jr(`&`,5),equality:Jr(`==/!=/===/!==`,6),relational:Jr(`</>/<=/>=`,7),bitShift:Jr(`<</>>/>>>`,8),plusMin:new z(`+/-`,{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:Jr(`%`,10),star:Jr(`*`,10),slash:Jr(`/`,10),starstar:new z(`**`,{beforeExpr:!0}),coalesce:Jr(`??`,1),_break:B(`break`),_case:B(`case`,Yr),_catch:B(`catch`),_continue:B(`continue`),_debugger:B(`debugger`),_default:B(`default`,Yr),_do:B(`do`,{isLoop:!0,beforeExpr:!0}),_else:B(`else`,Yr),_finally:B(`finally`),_for:B(`for`,{isLoop:!0}),_function:B(`function`,Xr),_if:B(`if`),_return:B(`return`,Yr),_switch:B(`switch`),_throw:B(`throw`,Yr),_try:B(`try`),_var:B(`var`),_const:B(`const`),_while:B(`while`,{isLoop:!0}),_with:B(`with`),_new:B(`new`,{beforeExpr:!0,startsExpr:!0}),_this:B(`this`,Xr),_super:B(`super`,Xr),_class:B(`class`,Xr),_extends:B(`extends`,Yr),_export:B(`export`),_import:B(`import`,Xr),_null:B(`null`,Xr),_true:B(`true`,Xr),_false:B(`false`,Xr),_in:B(`in`,{beforeExpr:!0,binop:7}),_instanceof:B(`instanceof`,{beforeExpr:!0,binop:7}),_typeof:B(`typeof`,{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:B(`void`,{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:B(`delete`,{beforeExpr:!0,prefix:!0,startsExpr:!0})},Qr=/\\r\\n?|\\n|\\u2028|\\u2029/,$r=new RegExp(Qr.source,`g`);function ei(e){return e===10||e===13||e===8232||e===8233}function ti(e,t,n){n===void 0&&(n=e.length);for(var r=t;r<n;r++){var i=e.charCodeAt(r);if(ei(i))return r<n-1&&i===13&&e.charCodeAt(r+1)===10?r+2:r+1}return-1}var ni=/[\\u1680\\u2000-\\u200a\\u202f\\u205f\\u3000\\ufeff]/,ri=/(?:\\s|\\/\\/.*|\\/\\*[^]*?\\*\\/)*/g,ii=Object.prototype,ai=ii.hasOwnProperty,oi=ii.toString,si=Object.hasOwn||(function(e,t){return ai.call(e,t)}),ci=Array.isArray||(function(e){return oi.call(e)===`[object Array]`}),li=Object.create(null);function ui(e){return li[e]||(li[e]=RegExp(`^(?:`+e.replace(/ /g,`|`)+`)$`))}function di(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}var fi=/(?:[\\uD800-\\uDBFF](?![\\uDC00-\\uDFFF])|(?:[^\\uD800-\\uDBFF]|^)[\\uDC00-\\uDFFF])/,pi=function(e,t){this.line=e,this.column=t};pi.prototype.offset=function(e){return new pi(this.line,this.column+e)};var mi=function(e,t,n){this.start=t,this.end=n,e.sourceFile!==null&&(this.source=e.sourceFile)};function hi(e,t){for(var n=1,r=0;;){var i=ti(e,r,t);if(i<0)return new pi(n,t-r);++n,r=i}}var gi={ecmaVersion:null,sourceType:`script`,strict:!1,onInsertedSemicolon:null,onTrailingComma:null,allowReserved:null,allowReturnOutsideFunction:!1,allowImportExportEverywhere:!1,allowAwaitOutsideFunction:null,allowSuperOutsideMethod:null,allowHashBang:!1,checkPrivateFields:!0,locations:!1,startLocation:null,onToken:null,onComment:null,ranges:!1,program:null,sourceFile:null,directSourceFile:null,preserveParens:!1},_i=!1;function vi(e){var t={};for(var n in gi)t[n]=e&&si(e,n)?e[n]:gi[n];if(t.ecmaVersion===`latest`?t.ecmaVersion=1e8:t.ecmaVersion==null?(!_i&&typeof console==`object`&&console.warn&&(_i=!0,console.warn(`Since Acorn 8.0.0, options.ecmaVersion is required.\nDefaulting to 2020, but this will stop working in the future.`)),t.ecmaVersion=11):t.ecmaVersion>=2015&&(t.ecmaVersion-=2009),t.allowReserved??(t.allowReserved=t.ecmaVersion<5),(!e||e.allowHashBang==null)&&(t.allowHashBang=t.ecmaVersion>=14),ci(t.onToken)){var r=t.onToken;t.onToken=function(e){return r.push(e)}}if(ci(t.onComment)&&(t.onComment=yi(t,t.onComment)),t.sourceType===`commonjs`&&t.allowAwaitOutsideFunction)throw Error(`Cannot use allowAwaitOutsideFunction with sourceType: commonjs`);return t}function yi(e,t){return function(n,r,i,a,o,s){var c={type:n?`Block`:`Line`,value:r,start:i,end:a};e.locations&&(c.loc=new mi(this,o,s)),e.ranges&&(c.range=[i,a]),t.push(c)}}var bi=1,xi=2,Si=4,Ci=8,wi=16,Ti=32,Ei=64,Di=128,Oi=256,ki=512,Ai=1024,ji=bi|xi|Oi;function Mi(e,t){return xi|(e?Si:0)|(t?Ci:0)}var Ni=0,Pi=1,Fi=2,Ii=3,Li=4,Ri=5,zi=function(e,t,n){this.options=e=vi(e),this.sourceFile=e.sourceFile,this.keywords=ui(Vr[e.ecmaVersion>=6?6:e.sourceType===`module`?`5module`:5]);var r=``;e.allowReserved!==!0&&(r=zr[e.ecmaVersion>=6?6:e.ecmaVersion===5?5:3],e.sourceType===`module`&&(r+=` await`)),this.reservedWords=ui(r);var i=(r?r+` `:``)+zr.strict;this.reservedWordsStrict=ui(i),this.reservedWordsStrictBind=ui(i+` `+zr.strictBind),this.input=String(t),this.containsEsc=!1,this.pos=n||0,this.curLine=1,e.startLocation?(this.lineStart=this.pos-e.startLocation.column,this.curLine=e.startLocation.line):n?(this.lineStart=this.input.lastIndexOf(`\n`,n-1)+1,this.options.locations&&(this.curLine=this.input.slice(0,this.lineStart).split(Qr).length)):this.lineStart=0,this.type=V.eof,this.value=null,this.start=this.end=this.pos,this.startLoc=this.endLoc=this.curPosition(),this.lastTokEndLoc=this.lastTokStartLoc=null,this.lastTokStart=this.lastTokEnd=this.pos,this.context=this.initialContext(),this.exprAllowed=!0,this.inModule=e.sourceType===`module`,this.strict=this.inModule||e.strict===!0||this.strictDirective(this.pos),this.potentialArrowAt=-1,this.potentialArrowInForAwait=!1,this.yieldPos=this.awaitPos=this.awaitIdentPos=0,this.labels=[],this.undefinedExports=Object.create(null),this.pos===0&&e.allowHashBang&&this.input.slice(0,2)===`#!`&&this.skipLineComment(2),this.scopeStack=[],this.enterScope(this.options.sourceType===`commonjs`?xi:bi),this.regexpState=null,this.privateNameStack=[]},Bi={inFunction:{configurable:!0},inGenerator:{configurable:!0},inAsync:{configurable:!0},canAwait:{configurable:!0},allowReturn:{configurable:!0},allowSuper:{configurable:!0},allowDirectSuper:{configurable:!0},treatFunctionsAsVar:{configurable:!0},allowNewDotTarget:{configurable:!0},allowUsing:{configurable:!0},inClassStaticBlock:{configurable:!0}};zi.prototype.parse=function(){var e=this,t=this.options.program||this.startNode();return this.nextToken(),this.catchStackOverflow(function(){return e.parseTopLevel(t)})},Bi.inFunction.get=function(){return(this.currentVarScope().flags&xi)>0},Bi.inGenerator.get=function(){return(this.currentVarScope().flags&Ci)>0},Bi.inAsync.get=function(){return(this.currentVarScope().flags&Si)>0},Bi.canAwait.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e].flags;if(t&(Oi|ki))return!1;if(t&xi)return(t&Si)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction},Bi.allowReturn.get=function(){return!!(this.inFunction||this.options.allowReturnOutsideFunction&&this.currentVarScope().flags&bi)},Bi.allowSuper.get=function(){return(this.currentThisScope().flags&Ei)>0||this.options.allowSuperOutsideMethod},Bi.allowDirectSuper.get=function(){return(this.currentThisScope().flags&Di)>0},Bi.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())},Bi.allowNewDotTarget.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e].flags;if(t&(Oi|ki)||t&xi&&!(t&wi))return!0}return!1},Bi.allowUsing.get=function(){var e=this.currentScope().flags;return!(e&Ai||!this.inModule&&e&bi)},Bi.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&Oi)>0},zi.extend=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];for(var n=this,r=0;r<e.length;r++)n=e[r](n);return n},zi.parse=function(e,t){return new this(t,e).parse()},zi.parseExpressionAt=function(e,t,n){var r=new this(n,e,t);return r.nextToken(),r.parseExpression()},zi.tokenizer=function(e,t){return new this(t,e)},Object.defineProperties(zi.prototype,Bi);var Vi=zi.prototype,Hi=/^(?:'((?:\\\\[^]|[^'\\\\])*?)'|\"((?:\\\\[^]|[^\"\\\\])*?)\")/;Vi.strictDirective=function(e){if(this.options.ecmaVersion<5)return!1;for(;;){ri.lastIndex=e,e+=ri.exec(this.input)[0].length;var t=Hi.exec(this.input.slice(e));if(!t)return!1;if((t[1]||t[2])===`use strict`){ri.lastIndex=e+t[0].length;var n=ri.exec(this.input),r=n.index+n[0].length,i=this.input.charAt(r);return i===`;`||i===`}`||Qr.test(n[0])&&!(/[(`.[+\\-/*%<>=,?^&]/.test(i)||i===`!`&&this.input.charAt(r+1)===`=`||i===`i`&&Ui(this,r))}e+=t[0].length,ri.lastIndex=e,e+=ri.exec(this.input)[0].length,this.input[e]===`;`&&e++}};function Ui(e,t){for(var n=t+1,r=Math.min(e.input.length,t+11);n<r;){var i=e.fullCharCodeAt(n);if(!qr(i,!0))break;n+=i<=65535?1:2}return n===t+2&&e.input.slice(t,n)===`in`||n===t+10&&e.input.slice(t,n)===`instanceof`}Vi.eat=function(e){return this.type===e?(this.next(),!0):!1},Vi.isContextual=function(e){return this.type===V.name&&this.value===e&&!this.containsEsc},Vi.eatContextual=function(e){return this.isContextual(e)?(this.next(),!0):!1},Vi.catchStackOverflow=function(e){try{return e()}catch(e){if(e instanceof Error&&(/\\bstack\\b.*\\b(exceeded|overflow)\\b/i.test(e.message)||/\\btoo much recursion\\b/i.test(e.message)))this.raise(this.start,`Not enough stack space to parse input`);else throw e}},Vi.expectContextual=function(e){this.eatContextual(e)||this.unexpected()},Vi.canInsertSemicolon=function(){return this.type===V.eof||this.type===V.braceR||Qr.test(this.input.slice(this.lastTokEnd,this.start))},Vi.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0},Vi.semicolon=function(){!this.eat(V.semi)&&!this.insertSemicolon()&&this.unexpected()},Vi.afterTrailingComma=function(e,t){if(this.type===e)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),t||this.next(),!0},Vi.expect=function(e){this.eat(e)||this.unexpected()},Vi.unexpected=function(e){this.raise(e??this.start,`Unexpected token`)};var Wi=function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};Vi.checkPatternErrors=function(e,t){if(e){e.trailingComma>-1&&this.raiseRecoverable(e.trailingComma,`Comma is not permitted after the rest element`);var n=t?e.parenthesizedAssign:e.parenthesizedBind;n>-1&&this.raiseRecoverable(n,t?`Assigning to rvalue`:`Parenthesized pattern`)}},Vi.checkExpressionErrors=function(e,t){if(!e)return!1;var n=e.shorthandAssign,r=e.doubleProto;if(!t)return n>=0||r>=0;n>=0&&this.raise(n,`Shorthand property assignments are valid only in destructuring patterns`),r>=0&&this.raiseRecoverable(r,`Redefinition of __proto__ property`)},Vi.checkYieldAwaitInDefaultParams=function(){this.yieldPos&&(!this.awaitPos||this.yieldPos<this.awaitPos)&&this.raise(this.yieldPos,`Yield expression cannot be a default value`),this.awaitPos&&this.raise(this.awaitPos,`Await expression cannot be a default value`)},Vi.isSimpleAssignTarget=function(e){return e.type===`ParenthesizedExpression`?this.isSimpleAssignTarget(e.expression):e.type===`Identifier`||e.type===`MemberExpression`};var H=zi.prototype;H.parseTopLevel=function(e){var t=Object.create(null);for(e.body||(e.body=[]);this.type!==V.eof;){var n=this.parseStatement(null,!0,t);e.body.push(n)}if(this.inModule)for(var r=0,i=Object.keys(this.undefinedExports);r<i.length;r+=1){var a=i[r];this.raiseRecoverable(this.undefinedExports[a].start,`Export '`+a+`' is not defined`)}return this.adaptDirectivePrologue(e.body),this.next(),e.sourceType=this.options.sourceType===`commonjs`?`script`:this.options.sourceType,this.finishNode(e,`Program`)};var Gi={kind:`loop`},Ki={kind:`switch`};H.isLet=function(e){if(this.options.ecmaVersion<6||!this.isContextual(`let`))return!1;ri.lastIndex=this.pos;var t=ri.exec(this.input),n=this.pos+t[0].length,r=this.fullCharCodeAt(n);if(r===91||r===92)return!0;if(e)return!1;if(r===123)return!0;if(Kr(r)){var i=n;do n+=r<=65535?1:2;while(qr(r=this.fullCharCodeAt(n)));if(r===92)return!0;var a=this.input.slice(i,n);if(!Hr.test(a))return!0}return!1},H.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual(`async`))return!1;ri.lastIndex=this.pos;var e=ri.exec(this.input),t=this.pos+e[0].length,n;return!Qr.test(this.input.slice(this.pos,t))&&this.input.slice(t,t+8)===`function`&&(t+8===this.input.length||!(qr(n=this.fullCharCodeAt(t+8))||n===92))},H.isUsingKeyword=function(e,t){if(this.options.ecmaVersion<17||!this.isContextual(e?`await`:`using`))return!1;ri.lastIndex=this.pos;var n=ri.exec(this.input),r=this.pos+n[0].length;if(Qr.test(this.input.slice(this.pos,r)))return!1;if(e){var i=r+5,a;if(this.input.slice(r,i)!==`using`||i===this.input.length||qr(a=this.fullCharCodeAt(i))||a===92)return!1;ri.lastIndex=i;var o=ri.exec(this.input);if(r=i+o[0].length,o&&Qr.test(this.input.slice(i,r)))return!1}var s=this.fullCharCodeAt(r);if(!Kr(s)&&s!==92)return!1;var c=r;do r+=s<=65535?1:2;while(qr(s=this.fullCharCodeAt(r)));if(s===92)return!0;var l=this.input.slice(c,r);if(Hr.test(l))return!1;if(t&&!e&&l===`of`){ri.lastIndex=r;var u=ri.exec(this.input);if(r+=u[0].length,this.input.charCodeAt(r)!==61||(s=this.input.charCodeAt(r+1))===61||s===62)return!1}return!0},H.isAwaitUsing=function(e){return this.isUsingKeyword(!0,e)},H.isUsing=function(e){return this.isUsingKeyword(!1,e)},H.parseStatement=function(e,t,n){var r=this.type,i=this.startNode(),a;switch(this.isLet(e)&&(r=V._var,a=`let`),r){case V._break:case V._continue:return this.parseBreakContinueStatement(i,r.keyword);case V._debugger:return this.parseDebuggerStatement(i);case V._do:return this.parseDoStatement(i);case V._for:return this.parseForStatement(i);case V._function:return e&&(this.strict||e!==`if`&&e!==`label`)&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(i,!1,!e);case V._class:return e&&this.unexpected(),this.parseClass(i,!0);case V._if:return this.parseIfStatement(i);case V._return:return this.parseReturnStatement(i);case V._switch:return this.parseSwitchStatement(i);case V._throw:return this.parseThrowStatement(i);case V._try:return this.parseTryStatement(i);case V._const:case V._var:return a=a||this.value,e&&a!==`var`&&this.unexpected(),this.parseVarStatement(i,a);case V._while:return this.parseWhileStatement(i);case V._with:return this.parseWithStatement(i);case V.braceL:return this.parseBlock(!0,i);case V.semi:return this.parseEmptyStatement(i);case V._export:case V._import:if(this.options.ecmaVersion>10&&r===V._import){ri.lastIndex=this.pos;var o=ri.exec(this.input),s=this.pos+o[0].length,c=this.input.charCodeAt(s);if(c===40||c===46)return this.parseExpressionStatement(i,this.parseExpression())}return this.options.allowImportExportEverywhere||(t||this.raise(this.start,`'import' and 'export' may only appear at the top level`),this.inModule||this.raise(this.start,`'import' and 'export' may appear only with 'sourceType: module'`)),r===V._import?this.parseImport(i):this.parseExport(i,n);default:if(this.isAsyncFunction())return e&&this.unexpected(),this.next(),this.parseFunctionStatement(i,!0,!e);var l=this.isAwaitUsing(!1)?`await using`:this.isUsing(!1)?`using`:null;if(l)return this.allowUsing||this.raise(this.start,\"Using declaration cannot appear in the top level when source type is `script` or in the bare case statement\"),e&&this.raise(this.start,`Using declaration is not allowed in single-statement positions`),l===`await using`&&(this.canAwait||this.raise(this.start,`Await using cannot appear outside of async function`),this.next()),this.next(),this.parseVar(i,!1,l),this.semicolon(),this.finishNode(i,`VariableDeclaration`);var u=this.value,d=this.parseExpression();return r===V.name&&d.type===`Identifier`&&this.eat(V.colon)?this.parseLabeledStatement(i,u,d,e):this.parseExpressionStatement(i,d)}},H.parseBreakContinueStatement=function(e,t){var n=t===`break`;this.next(),this.eat(V.semi)||this.insertSemicolon()?e.label=null:this.type===V.name?(e.label=this.parseIdent(),this.semicolon()):this.unexpected();for(var r=0;r<this.labels.length;++r){var i=this.labels[r];if((e.label==null||i.name===e.label.name)&&(i.kind!=null&&(n||i.kind===`loop`)||e.label&&n))break}return r===this.labels.length&&this.raise(e.start,`Unsyntactic `+t),this.finishNode(e,n?`BreakStatement`:`ContinueStatement`)},H.parseDebuggerStatement=function(e){return this.next(),this.semicolon(),this.finishNode(e,`DebuggerStatement`)},H.parseDoStatement=function(e){return this.next(),this.labels.push(Gi),e.body=this.parseStatement(`do`),this.labels.pop(),this.expect(V._while),e.test=this.parseParenExpression(),this.options.ecmaVersion>=6?this.eat(V.semi):this.semicolon(),this.finishNode(e,`DoWhileStatement`)},H.parseForStatement=function(e){this.next();var t=this.options.ecmaVersion>=9&&this.canAwait&&this.eatContextual(`await`)?this.lastTokStart:-1;if(this.labels.push(Gi),this.enterScope(0),this.expect(V.parenL),this.type===V.semi)return t>-1&&this.unexpected(t),this.parseFor(e,null);var n=this.isLet();if(this.type===V._var||this.type===V._const||n){var r=this.startNode(),i=n?`let`:this.value;return this.next(),this.parseVar(r,!0,i),this.finishNode(r,`VariableDeclaration`),this.parseForAfterInit(e,r,t)}var a=this.isContextual(`let`),o=!1,s=this.isUsing(!0)?`using`:this.isAwaitUsing(!0)?`await using`:null;if(s){var c=this.startNode();return this.next(),s===`await using`&&(this.canAwait||this.raise(this.start,`Await using cannot appear outside of async function`),this.next()),this.parseVar(c,!0,s),this.finishNode(c,`VariableDeclaration`),this.parseForAfterInit(e,c,t)}var l=this.containsEsc,u=new Wi,d=this.start,f=t>-1?this.parseExprSubscripts(u,`await`):this.parseExpression(!0,u);return this.type===V._in||(o=this.options.ecmaVersion>=6&&this.isContextual(`of`))?(t>-1?(this.type===V._in&&this.unexpected(t),e.await=!0):o&&this.options.ecmaVersion>=8&&(f.start===d&&!l&&f.type===`Identifier`&&f.name===`async`?this.unexpected():this.options.ecmaVersion>=9&&(e.await=!1)),a&&o&&this.raise(f.start,`The left-hand side of a for-of loop may not start with 'let'.`),this.toAssignable(f,!1,u),this.checkLValPattern(f),this.parseForIn(e,f)):(this.checkExpressionErrors(u,!0),t>-1&&this.unexpected(t),this.parseFor(e,f))},H.parseForAfterInit=function(e,t,n){return(this.type===V._in||this.options.ecmaVersion>=6&&this.isContextual(`of`))&&t.declarations.length===1?(this.type===V._in?((t.kind===`using`||t.kind===`await using`)&&!t.declarations[0].init&&this.raise(this.start,`Using declaration is not allowed in for-in loops`),this.options.ecmaVersion>=9&&n>-1&&this.unexpected(n)):this.options.ecmaVersion>=9&&(e.await=n>-1),this.parseForIn(e,t)):(n>-1&&this.unexpected(n),this.parseFor(e,t))},H.parseFunctionStatement=function(e,t,n){return this.next(),this.parseFunction(e,Ji|(n?0:Yi),!1,t)},H.parseIfStatement=function(e){return this.next(),e.test=this.parseParenExpression(),e.consequent=this.parseStatement(`if`),e.alternate=this.eat(V._else)?this.parseStatement(`if`):null,this.finishNode(e,`IfStatement`)},H.parseReturnStatement=function(e){return this.allowReturn||this.raise(this.start,`'return' outside of function`),this.next(),this.eat(V.semi)||this.insertSemicolon()?e.argument=null:(e.argument=this.parseExpression(),this.semicolon()),this.finishNode(e,`ReturnStatement`)},H.parseSwitchStatement=function(e){this.next(),e.discriminant=this.parseParenExpression(),e.cases=[],this.expect(V.braceL),this.labels.push(Ki),this.enterScope(Ai);for(var t,n=!1;this.type!==V.braceR;)if(this.type===V._case||this.type===V._default){var r=this.type===V._case;t&&this.finishNode(t,`SwitchCase`),e.cases.push(t=this.startNode()),t.consequent=[],this.next(),r?t.test=this.parseExpression():(n&&this.raiseRecoverable(this.lastTokStart,`Multiple default clauses`),n=!0,t.test=null),this.expect(V.colon)}else t||this.unexpected(),t.consequent.push(this.parseStatement(null));return this.exitScope(),t&&this.finishNode(t,`SwitchCase`),this.next(),this.labels.pop(),this.finishNode(e,`SwitchStatement`)},H.parseThrowStatement=function(e){return this.next(),Qr.test(this.input.slice(this.lastTokEnd,this.start))&&this.raise(this.lastTokEnd,`Illegal newline after throw`),e.argument=this.parseExpression(),this.semicolon(),this.finishNode(e,`ThrowStatement`)};var qi=[];H.parseCatchClauseParam=function(){var e=this.parseBindingAtom(),t=e.type===`Identifier`;return this.enterScope(t?Ti:0),this.checkLValPattern(e,t?Li:Fi),this.expect(V.parenR),e},H.parseTryStatement=function(e){if(this.next(),e.block=this.parseBlock(),e.handler=null,this.type===V._catch){var t=this.startNode();this.next(),this.eat(V.parenL)?t.param=this.parseCatchClauseParam():(this.options.ecmaVersion<10&&this.unexpected(),t.param=null,this.enterScope(0)),t.body=this.parseBlock(!1),this.exitScope(),e.handler=this.finishNode(t,`CatchClause`)}return e.finalizer=this.eat(V._finally)?this.parseBlock():null,!e.handler&&!e.finalizer&&this.raise(e.start,`Missing catch or finally clause`),this.finishNode(e,`TryStatement`)},H.parseVarStatement=function(e,t,n){return this.next(),this.parseVar(e,!1,t,n),this.semicolon(),this.finishNode(e,`VariableDeclaration`)},H.parseWhileStatement=function(e){return this.next(),e.test=this.parseParenExpression(),this.labels.push(Gi),e.body=this.parseStatement(`while`),this.labels.pop(),this.finishNode(e,`WhileStatement`)},H.parseWithStatement=function(e){return this.strict&&this.raise(this.start,`'with' in strict mode`),this.next(),e.object=this.parseParenExpression(),e.body=this.parseStatement(`with`),this.finishNode(e,`WithStatement`)},H.parseEmptyStatement=function(e){return this.next(),this.finishNode(e,`EmptyStatement`)},H.parseLabeledStatement=function(e,t,n,r){for(var i=0,a=this.labels;i<a.length;i+=1)a[i].name===t&&this.raise(n.start,`Label '`+t+`' is already declared`);for(var o=this.type.isLoop?`loop`:this.type===V._switch?`switch`:null,s=this.labels.length-1;s>=0;s--){var c=this.labels[s];if(c.statementStart===e.start)c.statementStart=this.start,c.kind=o;else break}return this.labels.push({name:t,kind:o,statementStart:this.start}),e.body=this.parseStatement(r?r.indexOf(`label`)===-1?r+`label`:r:`label`),this.labels.pop(),e.label=n,this.finishNode(e,`LabeledStatement`)},H.parseExpressionStatement=function(e,t){return e.expression=t,this.semicolon(),this.finishNode(e,`ExpressionStatement`)},H.parseBlock=function(e,t,n){for(e===void 0&&(e=!0),t===void 0&&(t=this.startNode()),t.body=[],this.expect(V.braceL),e&&this.enterScope(0);this.type!==V.braceR;){var r=this.parseStatement(null);t.body.push(r)}return n&&(this.strict=!1),this.next(),e&&this.exitScope(),this.finishNode(t,`BlockStatement`)},H.parseFor=function(e,t){return e.init=t,this.expect(V.semi),e.test=this.type===V.semi?null:this.parseExpression(),this.expect(V.semi),e.update=this.type===V.parenR?null:this.parseExpression(),this.expect(V.parenR),e.body=this.parseStatement(`for`),this.exitScope(),this.labels.pop(),this.finishNode(e,`ForStatement`)},H.parseForIn=function(e,t){var n=this.type===V._in;return this.next(),t.type===`VariableDeclaration`&&t.declarations[0].init!=null&&(!n||this.options.ecmaVersion<8||this.strict||t.kind!==`var`||t.declarations[0].id.type!==`Identifier`)&&this.raise(t.start,(n?`for-in`:`for-of`)+` loop variable declaration may not have an initializer`),e.left=t,e.right=n?this.parseExpression():this.parseMaybeAssign(),this.expect(V.parenR),e.body=this.parseStatement(`for`),this.exitScope(),this.labels.pop(),this.finishNode(e,n?`ForInStatement`:`ForOfStatement`)},H.parseVar=function(e,t,n,r){for(e.declarations=[],e.kind=n;;){var i=this.startNode();if(this.parseVarId(i,n),this.eat(V.eq)?i.init=this.parseMaybeAssign(t):!r&&n===`const`&&!(this.type===V._in||this.options.ecmaVersion>=6&&this.isContextual(`of`))?this.unexpected():!r&&(n===`using`||n===`await using`)&&this.options.ecmaVersion>=17&&this.type!==V._in&&!this.isContextual(`of`)?this.raise(this.lastTokEnd,`Missing initializer in `+n+` declaration`):!r&&i.id.type!==`Identifier`&&!(t&&(this.type===V._in||this.isContextual(`of`)))?this.raise(this.lastTokEnd,`Complex binding patterns require an initialization value`):i.init=null,e.declarations.push(this.finishNode(i,`VariableDeclarator`)),!this.eat(V.comma))break}return e},H.parseVarId=function(e,t){e.id=t===`using`||t===`await using`?this.parseIdent():this.parseBindingAtom(),this.checkLValPattern(e.id,t===`var`?Pi:Fi,!1)};var Ji=1,Yi=2,Xi=4;H.parseFunction=function(e,t,n,r,i){this.initFunction(e),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!r)&&(this.type===V.star&&t&Yi&&this.unexpected(),e.generator=this.eat(V.star)),this.options.ecmaVersion>=8&&(e.async=!!r),t&Ji&&(e.id=t&Xi&&this.type!==V.name?null:this.parseIdent(),e.id&&!(t&Yi)&&this.checkLValSimple(e.id,this.strict||e.generator||e.async?this.treatFunctionsAsVar?Pi:Fi:Ii));var a=this.yieldPos,o=this.awaitPos,s=this.awaitIdentPos;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(Mi(e.async,e.generator)),t&Ji||(e.id=this.type===V.name?this.parseIdent():null),this.parseFunctionParams(e),this.parseFunctionBody(e,n,!1,i),this.yieldPos=a,this.awaitPos=o,this.awaitIdentPos=s,this.finishNode(e,t&Ji?`FunctionDeclaration`:`FunctionExpression`)},H.parseFunctionParams=function(e){this.expect(V.parenL),e.params=this.parseBindingList(V.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()},H.parseClass=function(e,t){this.next();var n=this.strict;this.strict=!0,this.parseClassId(e,t),this.parseClassSuper(e);var r=this.enterClassBody(),i=this.startNode(),a=!1;for(i.body=[],this.expect(V.braceL);this.type!==V.braceR;){var o=this.parseClassElement(e.superClass!==null);o&&(i.body.push(o),o.type===`MethodDefinition`&&o.kind===`constructor`?(a&&this.raiseRecoverable(o.start,`Duplicate constructor in the same class`),a=!0):o.key&&o.key.type===`PrivateIdentifier`&&Zi(r,o)&&this.raiseRecoverable(o.key.start,`Identifier '#`+o.key.name+`' has already been declared`))}return this.strict=n,this.next(),e.body=this.finishNode(i,`ClassBody`),this.exitClassBody(),this.finishNode(e,t?`ClassDeclaration`:`ClassExpression`)},H.parseClassElement=function(e){if(this.eat(V.semi))return null;var t=this.options.ecmaVersion,n=this.startNode(),r=``,i=!1,a=!1,o=`method`,s=!1;if(this.eatContextual(`static`)){if(t>=13&&this.eat(V.braceL))return this.parseClassStaticBlock(n),n;this.isClassElementNameStart()||this.type===V.star?s=!0:r=`static`}if(n.static=s,!r&&t>=8&&this.eatContextual(`async`)&&((this.isClassElementNameStart()||this.type===V.star)&&!this.canInsertSemicolon()?a=!0:r=`async`),!r&&(t>=9||!a)&&this.eat(V.star)&&(i=!0),!r&&!a&&!i){var c=this.value;(this.eatContextual(`get`)||this.eatContextual(`set`))&&(this.isClassElementNameStart()?o=c:r=c)}if(r?(n.computed=!1,n.key=this.startNodeAt(this.lastTokStart,this.lastTokStartLoc),n.key.name=r,this.finishNode(n.key,`Identifier`)):this.parseClassElementName(n),t<13||this.type===V.parenL||o!==`method`||i||a){var l=!n.static&&Qi(n,`constructor`),u=l&&e;l&&o!==`method`&&this.raise(n.key.start,`Constructor can't have get/set modifier`),n.kind=l?`constructor`:o,this.parseClassMethod(n,i,a,u)}else this.parseClassField(n);return n},H.isClassElementNameStart=function(){return this.type===V.name||this.type===V.privateId||this.type===V.num||this.type===V.string||this.type===V.bracketL||this.type.keyword},H.parseClassElementName=function(e){this.type===V.privateId?(this.value===`constructor`&&this.raise(this.start,`Classes can't have an element named '#constructor'`),e.computed=!1,e.key=this.parsePrivateIdent()):this.parsePropertyName(e)},H.parseClassMethod=function(e,t,n,r){var i=e.key;e.kind===`constructor`?(t&&this.raise(i.start,`Constructor can't be a generator`),n&&this.raise(i.start,`Constructor can't be an async method`)):e.static&&Qi(e,`prototype`)&&this.raise(i.start,`Classes may not have a static property named prototype`);var a=e.value=this.parseMethod(t,n,r);return e.kind===`get`&&a.params.length!==0&&this.raiseRecoverable(a.start,`getter should have no params`),e.kind===`set`&&a.params.length!==1&&this.raiseRecoverable(a.start,`setter should have exactly one param`),e.kind===`set`&&a.params[0].type===`RestElement`&&this.raiseRecoverable(a.params[0].start,`Setter cannot use rest params`),this.finishNode(e,`MethodDefinition`)},H.parseClassField=function(e){return Qi(e,`constructor`)?this.raise(e.key.start,`Classes can't have a field named 'constructor'`):e.static&&Qi(e,`prototype`)&&this.raise(e.key.start,`Classes can't have a static field named 'prototype'`),this.eat(V.eq)?(this.enterScope(ki|Ei),e.value=this.parseMaybeAssign(),this.exitScope()):e.value=null,this.semicolon(),this.finishNode(e,`PropertyDefinition`)},H.parseClassStaticBlock=function(e){e.body=[];var t=this.labels;for(this.labels=[],this.enterScope(Oi|Ei);this.type!==V.braceR;){var n=this.parseStatement(null);e.body.push(n)}return this.next(),this.exitScope(),this.labels=t,this.finishNode(e,`StaticBlock`)},H.parseClassId=function(e,t){this.type===V.name?(e.id=this.parseIdent(),t&&this.checkLValSimple(e.id,Fi,!1)):(t===!0&&this.unexpected(),e.id=null)},H.parseClassSuper=function(e){e.superClass=this.eat(V._extends)?this.parseExprSubscripts(null,!1):null},H.enterClassBody=function(){var e={declared:Object.create(null),used:[]};return this.privateNameStack.push(e),e.declared},H.exitClassBody=function(){var e=this.privateNameStack.pop(),t=e.declared,n=e.used;if(this.options.checkPrivateFields)for(var r=this.privateNameStack.length,i=r===0?null:this.privateNameStack[r-1],a=0;a<n.length;++a){var o=n[a];si(t,o.name)||(i?i.used.push(o):this.raiseRecoverable(o.start,`Private field '#`+o.name+`' must be declared in an enclosing class`))}};function Zi(e,t){var n=t.key.name,r=e[n],i=`true`;return t.type===`MethodDefinition`&&(t.kind===`get`||t.kind===`set`)&&(i=(t.static?`s`:`i`)+t.kind),r===`iget`&&i===`iset`||r===`iset`&&i===`iget`||r===`sget`&&i===`sset`||r===`sset`&&i===`sget`?(e[n]=`true`,!1):r?!0:(e[n]=i,!1)}function Qi(e,t){var n=e.computed,r=e.key;return!n&&(r.type===`Identifier`&&r.name===t||r.type===`Literal`&&r.value===t)}H.parseExportAllDeclaration=function(e,t){return this.options.ecmaVersion>=11&&(this.eatContextual(`as`)?(e.exported=this.parseModuleExportName(),this.checkExport(t,e.exported,this.lastTokStart)):e.exported=null),this.expectContextual(`from`),this.type!==V.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,`ExportAllDeclaration`)},H.parseExport=function(e,t){if(this.next(),this.eat(V.star))return this.parseExportAllDeclaration(e,t);if(this.eat(V._default))return this.checkExport(t,`default`,this.lastTokStart),e.declaration=this.parseExportDefaultDeclaration(),this.finishNode(e,`ExportDefaultDeclaration`);if(this.shouldParseExportStatement())e.declaration=this.parseExportDeclaration(e),e.declaration.type===`VariableDeclaration`?this.checkVariableExport(t,e.declaration.declarations):this.checkExport(t,e.declaration.id,e.declaration.id.start),e.specifiers=[],e.source=null,this.options.ecmaVersion>=16&&(e.attributes=[]);else{if(e.declaration=null,e.specifiers=this.parseExportSpecifiers(t),this.eatContextual(`from`))this.type!==V.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause());else{for(var n=0,r=e.specifiers;n<r.length;n+=1){var i=r[n];this.checkUnreserved(i.local),this.checkLocalExport(i.local),i.local.type===`Literal`&&this.raise(i.local.start,\"A string literal cannot be used as an exported binding without `from`.\")}e.source=null,this.options.ecmaVersion>=16&&(e.attributes=[])}this.semicolon()}return this.finishNode(e,`ExportNamedDeclaration`)},H.parseExportDeclaration=function(e){return this.parseStatement(null)},H.parseExportDefaultDeclaration=function(){var e;if(this.type===V._function||(e=this.isAsyncFunction())){var t=this.startNode();return this.next(),e&&this.next(),this.parseFunction(t,Ji|Xi,!1,e)}else if(this.type===V._class){var n=this.startNode();return this.parseClass(n,`nullableID`)}else{var r=this.parseMaybeAssign();return this.semicolon(),r}},H.checkExport=function(e,t,n){e&&(typeof t!=`string`&&(t=t.type===`Identifier`?t.name:t.value),si(e,t)&&this.raiseRecoverable(n,`Duplicate export '`+t+`'`),e[t]=!0)},H.checkPatternExport=function(e,t){var n=t.type;if(n===`Identifier`)this.checkExport(e,t,t.start);else if(n===`ObjectPattern`)for(var r=0,i=t.properties;r<i.length;r+=1){var a=i[r];this.checkPatternExport(e,a)}else if(n===`ArrayPattern`)for(var o=0,s=t.elements;o<s.length;o+=1){var c=s[o];c&&this.checkPatternExport(e,c)}else n===`Property`?this.checkPatternExport(e,t.value):n===`AssignmentPattern`?this.checkPatternExport(e,t.left):n===`RestElement`&&this.checkPatternExport(e,t.argument)},H.checkVariableExport=function(e,t){if(e)for(var n=0,r=t;n<r.length;n+=1){var i=r[n];this.checkPatternExport(e,i.id)}},H.shouldParseExportStatement=function(){return this.type.keyword===`var`||this.type.keyword===`const`||this.type.keyword===`class`||this.type.keyword===`function`||this.isLet()||this.isAsyncFunction()},H.parseExportSpecifier=function(e){var t=this.startNode();return t.local=this.parseModuleExportName(),t.exported=this.eatContextual(`as`)?this.parseModuleExportName():t.local,this.checkExport(e,t.exported,t.exported.start),this.finishNode(t,`ExportSpecifier`)},H.parseExportSpecifiers=function(e){var t=[],n=!0;for(this.expect(V.braceL);!this.eat(V.braceR);){if(n)n=!1;else if(this.expect(V.comma),this.afterTrailingComma(V.braceR))break;t.push(this.parseExportSpecifier(e))}return t},H.parseImport=function(e){return this.next(),this.type===V.string?(e.specifiers=qi,e.source=this.parseExprAtom()):(e.specifiers=this.parseImportSpecifiers(),this.expectContextual(`from`),e.source=this.type===V.string?this.parseExprAtom():this.unexpected()),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,`ImportDeclaration`)},H.parseImportSpecifier=function(){var e=this.startNode();return e.imported=this.parseModuleExportName(),this.eatContextual(`as`)?e.local=this.parseIdent():(this.checkUnreserved(e.imported),e.local=e.imported),this.checkLValSimple(e.local,Fi),this.finishNode(e,`ImportSpecifier`)},H.parseImportDefaultSpecifier=function(){var e=this.startNode();return e.local=this.parseIdent(),this.checkLValSimple(e.local,Fi),this.finishNode(e,`ImportDefaultSpecifier`)},H.parseImportNamespaceSpecifier=function(){var e=this.startNode();return this.next(),this.expectContextual(`as`),e.local=this.parseIdent(),this.checkLValSimple(e.local,Fi),this.finishNode(e,`ImportNamespaceSpecifier`)},H.parseImportSpecifiers=function(){var e=[],t=!0;if(this.type===V.name&&(e.push(this.parseImportDefaultSpecifier()),!this.eat(V.comma)))return e;if(this.type===V.star)return e.push(this.parseImportNamespaceSpecifier()),e;for(this.expect(V.braceL);!this.eat(V.braceR);){if(t)t=!1;else if(this.expect(V.comma),this.afterTrailingComma(V.braceR))break;e.push(this.parseImportSpecifier())}return e},H.parseWithClause=function(){var e=[];if(!this.eat(V._with))return e;this.expect(V.braceL);for(var t={},n=!0;!this.eat(V.braceR);){if(n)n=!1;else if(this.expect(V.comma),this.afterTrailingComma(V.braceR))break;var r=this.parseImportAttribute(),i=r.key.type===`Identifier`?r.key.name:r.key.value;si(t,i)&&this.raiseRecoverable(r.key.start,`Duplicate attribute key '`+i+`'`),t[i]=!0,e.push(r)}return e},H.parseImportAttribute=function(){var e=this.startNode();return e.key=this.type===V.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!==`never`),this.expect(V.colon),this.type!==V.string&&this.unexpected(),e.value=this.parseExprAtom(),this.finishNode(e,`ImportAttribute`)},H.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===V.string){var e=this.parseLiteral(this.value);return fi.test(e.value)&&this.raise(e.start,`An export name cannot include a lone surrogate.`),e}return this.parseIdent(!0)},H.adaptDirectivePrologue=function(e){for(var t=0;t<e.length&&this.isDirectiveCandidate(e[t]);++t)e[t].directive=e[t].expression.raw.slice(1,-1)},H.isDirectiveCandidate=function(e){return this.options.ecmaVersion>=5&&e.type===`ExpressionStatement`&&e.expression.type===`Literal`&&typeof e.expression.value==`string`&&(this.input[e.start]===`\"`||this.input[e.start]===`'`)};var $i=zi.prototype;$i.toAssignable=function(e,t,n){if(this.options.ecmaVersion>=6&&e)switch(e.type){case`Identifier`:this.inAsync&&e.name===`await`&&this.raise(e.start,`Cannot use 'await' as identifier inside an async function`);break;case`ObjectPattern`:case`ArrayPattern`:case`AssignmentPattern`:case`RestElement`:break;case`ObjectExpression`:e.type=`ObjectPattern`,n&&this.checkPatternErrors(n,!0);for(var r=0,i=e.properties;r<i.length;r+=1){var a=i[r];this.toAssignable(a,t),a.type===`RestElement`&&(a.argument.type===`ArrayPattern`||a.argument.type===`ObjectPattern`)&&this.raise(a.argument.start,`Unexpected token`)}break;case`Property`:e.kind!==`init`&&this.raise(e.key.start,`Object pattern can't contain getter or setter`),this.toAssignable(e.value,t);break;case`ArrayExpression`:e.type=`ArrayPattern`,n&&this.checkPatternErrors(n,!0),this.toAssignableList(e.elements,t);break;case`SpreadElement`:e.type=`RestElement`,this.toAssignable(e.argument,t),e.argument.type===`AssignmentPattern`&&this.raise(e.argument.start,`Rest elements cannot have a default value`);break;case`AssignmentExpression`:e.operator!==`=`&&this.raise(e.left.end,`Only '=' operator can be used for specifying default value.`),e.type=`AssignmentPattern`,delete e.operator,this.toAssignable(e.left,t);break;case`ParenthesizedExpression`:this.toAssignable(e.expression,t,n);break;case`ChainExpression`:this.raiseRecoverable(e.start,`Optional chaining cannot appear in left-hand side`);break;case`MemberExpression`:if(!t)break;default:this.raise(e.start,`Assigning to rvalue`)}else n&&this.checkPatternErrors(n,!0);return e},$i.toAssignableList=function(e,t){for(var n=e.length,r=0;r<n;r++){var i=e[r];i&&this.toAssignable(i,t)}if(n){var a=e[n-1];this.options.ecmaVersion===6&&t&&a&&a.type===`RestElement`&&a.argument.type!==`Identifier`&&this.unexpected(a.argument.start)}return e},$i.parseSpread=function(e){var t=this.startNode();return this.next(),t.argument=this.parseMaybeAssign(!1,e),this.finishNode(t,`SpreadElement`)},$i.parseRestBinding=function(){var e=this.startNode();return this.next(),this.options.ecmaVersion===6&&this.type!==V.name&&this.unexpected(),e.argument=this.parseBindingAtom(),this.finishNode(e,`RestElement`)},$i.parseBindingAtom=function(){if(this.options.ecmaVersion>=6)switch(this.type){case V.bracketL:var e=this.startNode();return this.next(),e.elements=this.parseBindingList(V.bracketR,!0,!0),this.finishNode(e,`ArrayPattern`);case V.braceL:return this.parseObj(!0)}return this.parseIdent()},$i.parseBindingList=function(e,t,n,r){for(var i=[],a=!0;!this.eat(e);)if(a?a=!1:this.expect(V.comma),t&&this.type===V.comma)i.push(null);else if(n&&this.afterTrailingComma(e))break;else if(this.type===V.ellipsis){var o=this.parseRestBinding();this.parseBindingListItem(o),i.push(o),this.type===V.comma&&this.raiseRecoverable(this.start,`Comma is not permitted after the rest element`),this.expect(e);break}else i.push(this.parseAssignableListItem(r));return i},$i.parseAssignableListItem=function(e){var t=this.parseMaybeDefault(this.start,this.startLoc);return this.parseBindingListItem(t),t},$i.parseBindingListItem=function(e){return e},$i.parseMaybeDefault=function(e,t,n){if(n=n||this.parseBindingAtom(),this.options.ecmaVersion<6||!this.eat(V.eq))return n;var r=this.startNodeAt(e,t);return r.left=n,r.right=this.parseMaybeAssign(),this.finishNode(r,`AssignmentPattern`)},$i.checkLValSimple=function(e,t,n){t===void 0&&(t=Ni);var r=t!==Ni;switch(e.type){case`Identifier`:this.strict&&this.reservedWordsStrictBind.test(e.name)&&this.raiseRecoverable(e.start,(r?`Binding `:`Assigning to `)+e.name+` in strict mode`),r&&(t===Fi&&e.name===`let`&&this.raiseRecoverable(e.start,`let is disallowed as a lexically bound name`),n&&(si(n,e.name)&&this.raiseRecoverable(e.start,`Argument name clash`),n[e.name]=!0),t!==Ri&&this.declareName(e.name,t,e.start));break;case`ChainExpression`:this.raiseRecoverable(e.start,`Optional chaining cannot appear in left-hand side`);break;case`MemberExpression`:r&&this.raiseRecoverable(e.start,`Binding member expression`);break;case`ParenthesizedExpression`:return r&&this.raiseRecoverable(e.start,`Binding parenthesized expression`),this.checkLValSimple(e.expression,t,n);default:this.raise(e.start,(r?`Binding`:`Assigning to`)+` rvalue`)}},$i.checkLValPattern=function(e,t,n){switch(t===void 0&&(t=Ni),e.type){case`ObjectPattern`:for(var r=0,i=e.properties;r<i.length;r+=1){var a=i[r];this.checkLValInnerPattern(a,t,n)}break;case`ArrayPattern`:for(var o=0,s=e.elements;o<s.length;o+=1){var c=s[o];c&&this.checkLValInnerPattern(c,t,n)}break;default:this.checkLValSimple(e,t,n)}},$i.checkLValInnerPattern=function(e,t,n){switch(t===void 0&&(t=Ni),e.type){case`Property`:this.checkLValInnerPattern(e.value,t,n);break;case`AssignmentPattern`:this.checkLValPattern(e.left,t,n);break;case`RestElement`:this.checkLValPattern(e.argument,t,n);break;default:this.checkLValPattern(e,t,n)}};var ea=function(e,t,n,r,i){this.token=e,this.isExpr=!!t,this.preserveSpace=!!n,this.override=r,this.generator=!!i},ta={b_stat:new ea(`{`,!1),b_expr:new ea(`{`,!0),b_tmpl:new ea(\"${\",!1),p_stat:new ea(`(`,!1),p_expr:new ea(`(`,!0),q_tmpl:new ea(\"`\",!0,!0,function(e){return e.tryReadTemplateToken()}),f_stat:new ea(`function`,!1),f_expr:new ea(`function`,!0),f_expr_gen:new ea(`function`,!0,!1,null,!0),f_gen:new ea(`function`,!1,!1,null,!0)},na=zi.prototype;na.initialContext=function(){return[ta.b_stat]},na.curContext=function(){return this.context[this.context.length-1]},na.braceIsBlock=function(e){var t=this.curContext();return t===ta.f_expr||t===ta.f_stat?!0:e===V.colon&&(t===ta.b_stat||t===ta.b_expr)?!t.isExpr:e===V._return||e===V.name&&this.exprAllowed?Qr.test(this.input.slice(this.lastTokEnd,this.start)):e===V._else||e===V.semi||e===V.eof||e===V.parenR||e===V.arrow?!0:e===V.braceL?t===ta.b_stat:e===V._var||e===V._const||e===V.name?!1:!this.exprAllowed},na.inGeneratorContext=function(){for(var e=this.context.length-1;e>=1;e--){var t=this.context[e];if(t.token===`function`)return t.generator}return!1},na.updateContext=function(e){var t,n=this.type;n.keyword&&e===V.dot?this.exprAllowed=!1:(t=n.updateContext)?t.call(this,e):this.exprAllowed=n.beforeExpr},na.overrideContext=function(e){this.curContext()!==e&&(this.context[this.context.length-1]=e)},V.parenR.updateContext=V.braceR.updateContext=function(){if(this.context.length===1){this.exprAllowed=!0;return}var e=this.context.pop();e===ta.b_stat&&this.curContext().token===`function`&&(e=this.context.pop()),this.exprAllowed=!e.isExpr},V.braceL.updateContext=function(e){this.context.push(this.braceIsBlock(e)?ta.b_stat:ta.b_expr),this.exprAllowed=!0},V.dollarBraceL.updateContext=function(){this.context.push(ta.b_tmpl),this.exprAllowed=!0},V.parenL.updateContext=function(e){var t=e===V._if||e===V._for||e===V._with||e===V._while;this.context.push(t?ta.p_stat:ta.p_expr),this.exprAllowed=!0},V.incDec.updateContext=function(){},V._function.updateContext=V._class.updateContext=function(e){e.beforeExpr&&e!==V._else&&!(e===V.semi&&this.curContext()!==ta.p_stat)&&!(e===V._return&&Qr.test(this.input.slice(this.lastTokEnd,this.start)))&&!((e===V.colon||e===V.braceL)&&this.curContext()===ta.b_stat)?this.context.push(ta.f_expr):this.context.push(ta.f_stat),this.exprAllowed=!1},V.colon.updateContext=function(){this.curContext().token===`function`&&this.context.pop(),this.exprAllowed=!0},V.backQuote.updateContext=function(){this.curContext()===ta.q_tmpl?this.context.pop():this.context.push(ta.q_tmpl),this.exprAllowed=!1},V.star.updateContext=function(e){if(e===V._function){var t=this.context.length-1;this.context[t]===ta.f_expr?this.context[t]=ta.f_expr_gen:this.context[t]=ta.f_gen}this.exprAllowed=!0},V.name.updateContext=function(e){var t=!1;this.options.ecmaVersion>=6&&e!==V.dot&&(this.value===`of`&&!this.exprAllowed||this.value===`yield`&&this.inGeneratorContext())&&(t=!0),this.exprAllowed=t};var U=zi.prototype;U.checkPropClash=function(e,t,n){if(!(this.options.ecmaVersion>=9&&e.type===`SpreadElement`)&&!(this.options.ecmaVersion>=6&&(e.computed||e.method||e.shorthand))){var r=e.key,i;switch(r.type){case`Identifier`:i=r.name;break;case`Literal`:i=String(r.value);break;default:return}var a=e.kind;if(this.options.ecmaVersion>=6){i===`__proto__`&&a===`init`&&(t.proto&&(n?n.doubleProto<0&&(n.doubleProto=r.start):this.raiseRecoverable(r.start,`Redefinition of __proto__ property`)),t.proto=!0);return}i=`$`+i;var o=t[i];o?(a===`init`?this.strict&&o.init||o.get||o.set:o.init||o[a])&&this.raiseRecoverable(r.start,`Redefinition of property`):o=t[i]={init:!1,get:!1,set:!1},o[a]=!0}},U.parseExpression=function(e,t){var n=this;return this.catchStackOverflow(function(){var r=n.start,i=n.startLoc,a=n.parseMaybeAssign(e,t);if(n.type===V.comma){var o=n.startNodeAt(r,i);for(o.expressions=[a];n.eat(V.comma);)o.expressions.push(n.parseMaybeAssign(e,t));return n.finishNode(o,`SequenceExpression`)}return a})},U.parseMaybeAssign=function(e,t,n){if(this.isContextual(`yield`)){if(this.inGenerator)return this.parseYield(e);this.exprAllowed=!1}var r=!1,i=-1,a=-1,o=-1;t?(i=t.parenthesizedAssign,a=t.trailingComma,o=t.doubleProto,t.parenthesizedAssign=t.trailingComma=-1):(t=new Wi,r=!0);var s=this.start,c=this.startLoc;(this.type===V.parenL||this.type===V.name)&&(this.potentialArrowAt=this.start,this.potentialArrowInForAwait=e===`await`);var l=this.parseMaybeConditional(e,t);if(n&&(l=n.call(this,l,s,c)),this.type.isAssign){var u=this.startNodeAt(s,c);return u.operator=this.value,this.type===V.eq&&(l=this.toAssignable(l,!1,t)),r||(t.parenthesizedAssign=t.trailingComma=-1,t.shorthandAssign>=l.start&&(t.shorthandAssign=-1),t.doubleProto>=l.start&&(t.doubleProto=-1)),this.type===V.eq?this.checkLValPattern(l):this.checkLValSimple(l),u.left=l,this.next(),u.right=this.parseMaybeAssign(e),o>-1&&(t.doubleProto=o),this.finishNode(u,`AssignmentExpression`)}else r&&this.checkExpressionErrors(t,!0);return i>-1&&(t.parenthesizedAssign=i),a>-1&&(t.trailingComma=a),l},U.parseMaybeConditional=function(e,t){var n=this.start,r=this.startLoc,i=this.parseExprOps(e,t);if(this.checkExpressionErrors(t))return i;if(!(i.type===`ArrowFunctionExpression`&&i.start===n)&&this.eat(V.question)){var a=this.startNodeAt(n,r);return a.test=i,a.consequent=this.parseMaybeAssign(),this.expect(V.colon),a.alternate=this.parseMaybeAssign(e),this.finishNode(a,`ConditionalExpression`)}return i},U.parseExprOps=function(e,t){var n=this.start,r=this.startLoc,i=this.parseMaybeUnary(t,!1,!1,e);return this.checkExpressionErrors(t)||i.start===n&&i.type===`ArrowFunctionExpression`?i:this.parseExprOp(i,n,r,-1,e)},U.parseExprOp=function(e,t,n,r,i){var a=this.type.binop;if(a!=null&&(!i||this.type!==V._in)&&a>r){var o=this.type===V.logicalOR||this.type===V.logicalAND,s=this.type===V.coalesce;s&&(a=V.logicalAND.binop);var c=this.value;this.next();var l=this.start,u=this.startLoc,d=this.parseExprOp(this.parseMaybeUnary(null,!1,!1,i),l,u,a,i),f=this.buildBinary(t,n,e,d,c,o||s);return(o&&this.type===V.coalesce||s&&(this.type===V.logicalOR||this.type===V.logicalAND))&&this.raiseRecoverable(this.start,`Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses`),this.parseExprOp(f,t,n,r,i)}return e},U.buildBinary=function(e,t,n,r,i,a){r.type===`PrivateIdentifier`&&this.raise(r.start,`Private identifier can only be left side of binary expression`);var o=this.startNodeAt(e,t);return o.left=n,o.operator=i,o.right=r,this.finishNode(o,a?`LogicalExpression`:`BinaryExpression`)},U.parseMaybeUnary=function(e,t,n,r){var i=this.start,a=this.startLoc,o;if(this.isContextual(`await`)&&this.canAwait)o=this.parseAwait(r),t=!0;else if(this.type.prefix){var s=this.startNode(),c=this.type===V.incDec;s.operator=this.value,s.prefix=!0,this.next(),s.argument=this.parseMaybeUnary(null,!0,c,r),this.checkExpressionErrors(e,!0),c?this.checkLValSimple(s.argument):this.strict&&s.operator===`delete`&&ra(s.argument)?this.raiseRecoverable(s.start,`Deleting local variable in strict mode`):s.operator===`delete`&&ia(s.argument)?this.raiseRecoverable(s.start,`Private fields can not be deleted`):t=!0,o=this.finishNode(s,c?`UpdateExpression`:`UnaryExpression`)}else if(!t&&this.type===V.privateId)(r||this.privateNameStack.length===0)&&this.options.checkPrivateFields&&this.unexpected(),o=this.parsePrivateIdent(),this.type!==V._in&&this.unexpected();else{if(o=this.parseExprSubscripts(e,r),this.checkExpressionErrors(e))return o;for(;this.type.postfix&&!this.canInsertSemicolon();){var l=this.startNodeAt(i,a);l.operator=this.value,l.prefix=!1,l.argument=o,this.checkLValSimple(o),this.next(),o=this.finishNode(l,`UpdateExpression`)}}if(!n&&!(o.type===`ArrowFunctionExpression`&&o.start===i)&&this.eat(V.starstar))if(t)this.unexpected(this.lastTokStart);else return this.buildBinary(i,a,o,this.parseMaybeUnary(null,!1,!1,r),`**`,!1);else return o};function ra(e){return e.type===`Identifier`||e.type===`ParenthesizedExpression`&&ra(e.expression)}function ia(e){return e.type===`MemberExpression`&&e.property.type===`PrivateIdentifier`||e.type===`ChainExpression`&&ia(e.expression)||e.type===`ParenthesizedExpression`&&ia(e.expression)}U.parseExprSubscripts=function(e,t){var n=this.start,r=this.startLoc,i=-1,a=-1;e&&(i=e.doubleProto,a=e.shorthandAssign,e.doubleProto=e.shorthandAssign=-1);var o=this.parseExprAtom(e,t);if(o.type===`ArrowFunctionExpression`&&this.input.slice(this.lastTokStart,this.lastTokEnd)!==`)`)return o;var s=this.parseSubscripts(o,n,r,!1,t);return e&&(s.end>o.end&&(this.checkExpressionErrors(e,!0),e.parenthesizedAssign>=s.start&&(e.parenthesizedAssign=-1),e.parenthesizedBind>=s.start&&(e.parenthesizedBind=-1),e.trailingComma>=s.start&&(e.trailingComma=-1)),i>-1&&(e.doubleProto=i),a>-1&&(e.shorthandAssign=a)),s},U.parseSubscripts=function(e,t,n,r,i){for(var a=this.options.ecmaVersion>=8&&e.type===`Identifier`&&e.name===`async`&&this.lastTokEnd===e.end&&!this.canInsertSemicolon()&&e.end-e.start===5&&this.potentialArrowAt===e.start,o=!1;;){var s=this.parseSubscript(e,t,n,r,a,o,i);if(s.optional&&(o=!0),s.end===e.end||s.type===`ArrowFunctionExpression`){if(o){var c=this.startNodeAt(t,n);c.expression=s,s=this.finishNode(c,`ChainExpression`)}return s}e=s,a=!1}},U.shouldParseAsyncArrow=function(){return!this.canInsertSemicolon()&&this.eat(V.arrow)},U.parseSubscriptAsyncArrow=function(e,t,n,r){return this.parseArrowExpression(this.startNodeAt(e,t),n,!0,r)},U.parseSubscript=function(e,t,n,r,i,a,o){var s=this.options.ecmaVersion>=11,c=s&&this.eat(V.questionDot);r&&c&&this.raise(this.lastTokStart,`Optional chaining cannot appear in the callee of new expressions`);var l=this.eat(V.bracketL);if(l||c&&this.type!==V.parenL&&this.type!==V.backQuote||this.eat(V.dot)){var u=this.startNodeAt(t,n);u.object=e,l?(u.property=this.parseExpression(),this.expect(V.bracketR)):this.type===V.privateId&&e.type!==`Super`?u.property=this.parsePrivateIdent():u.property=this.parseIdent(this.options.allowReserved!==`never`),u.computed=!!l,s&&(u.optional=c),e=this.finishNode(u,`MemberExpression`)}else if(!r&&this.eat(V.parenL)){var d=new Wi,f=this.yieldPos,p=this.awaitPos,m=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var h=this.parseExprList(V.parenR,this.options.ecmaVersion>=8,!1,d);if(i&&!c&&this.shouldParseAsyncArrow())return this.checkPatternErrors(d,!1),this.checkYieldAwaitInDefaultParams(),this.awaitIdentPos>0&&this.raise(this.awaitIdentPos,`Cannot use 'await' as identifier inside an async function`),this.yieldPos=f,this.awaitPos=p,this.awaitIdentPos=m,this.parseSubscriptAsyncArrow(t,n,h,o);this.checkExpressionErrors(d,!0),this.yieldPos=f||this.yieldPos,this.awaitPos=p||this.awaitPos,this.awaitIdentPos=m||this.awaitIdentPos;var g=this.startNodeAt(t,n);g.callee=e,g.arguments=h,s&&(g.optional=c),e=this.finishNode(g,`CallExpression`)}else if(this.type===V.backQuote){(c||a)&&this.raise(this.start,`Optional chaining cannot appear in the tag of tagged template expressions`);var _=this.startNodeAt(t,n);_.tag=e,_.quasi=this.parseTemplate({isTagged:!0}),e=this.finishNode(_,`TaggedTemplateExpression`)}return e},U.parseExprAtom=function(e,t,n){this.type===V.slash&&this.readRegexp();var r,i=this.potentialArrowAt===this.start;switch(this.type){case V._super:return this.allowSuper||this.raise(this.start,`'super' keyword outside a method`),r=this.startNode(),this.next(),this.type===V.parenL&&!this.allowDirectSuper&&this.raise(r.start,`super() call outside constructor of a subclass`),this.type!==V.dot&&this.type!==V.bracketL&&this.type!==V.parenL&&this.unexpected(),this.finishNode(r,`Super`);case V._this:return r=this.startNode(),this.next(),this.finishNode(r,`ThisExpression`);case V.name:var a=this.start,o=this.startLoc,s=this.containsEsc,c=this.parseIdent(!1);if(this.options.ecmaVersion>=8&&!s&&c.name===`async`&&!this.canInsertSemicolon()&&this.eat(V._function))return this.overrideContext(ta.f_expr),this.parseFunction(this.startNodeAt(a,o),0,!1,!0,t);if(i&&!this.canInsertSemicolon()){if(this.eat(V.arrow))return this.parseArrowExpression(this.startNodeAt(a,o),[c],!1,t);if(this.options.ecmaVersion>=8&&c.name===`async`&&this.type===V.name&&!s&&(!this.potentialArrowInForAwait||this.value!==`of`||this.containsEsc))return c=this.parseIdent(!1),(this.canInsertSemicolon()||!this.eat(V.arrow))&&this.unexpected(),this.parseArrowExpression(this.startNodeAt(a,o),[c],!0,t)}return c;case V.regexp:var l=this.value;return r=this.parseLiteral(l.value),r.regex={pattern:l.pattern,flags:l.flags},r;case V.num:case V.string:return this.parseLiteral(this.value);case V._null:case V._true:case V._false:return r=this.startNode(),r.value=this.type===V._null?null:this.type===V._true,r.raw=this.type.keyword,this.next(),this.finishNode(r,`Literal`);case V.parenL:var u=this.start,d=this.parseParenAndDistinguishExpression(i,t);return e&&(e.parenthesizedAssign<0&&!this.isSimpleAssignTarget(d)&&(e.parenthesizedAssign=u),e.parenthesizedBind<0&&(e.parenthesizedBind=u)),d;case V.bracketL:return r=this.startNode(),this.next(),r.elements=this.parseExprList(V.bracketR,!0,!0,e),this.finishNode(r,`ArrayExpression`);case V.braceL:return this.overrideContext(ta.b_expr),this.parseObj(!1,e);case V._function:return r=this.startNode(),this.next(),this.parseFunction(r,0);case V._class:return this.parseClass(this.startNode(),!1);case V._new:return this.parseNew();case V.backQuote:return this.parseTemplate();case V._import:return this.options.ecmaVersion>=11?this.parseExprImport(n):this.unexpected();default:return this.parseExprAtomDefault()}},U.parseExprAtomDefault=function(){this.unexpected()},U.parseExprImport=function(e){var t=this.startNode();if(this.containsEsc&&this.raiseRecoverable(this.start,`Escape sequence in keyword import`),this.next(),this.type===V.parenL&&!e)return this.parseDynamicImport(t);if(this.type===V.dot){var n=this.startNodeAt(t.start,t.loc&&t.loc.start);return n.name=`import`,t.meta=this.finishNode(n,`Identifier`),this.parseImportMeta(t)}else this.unexpected()},U.parseDynamicImport=function(e){if(this.next(),e.source=this.parseMaybeAssign(),this.options.ecmaVersion>=16)this.eat(V.parenR)?e.options=null:(this.expect(V.comma),this.afterTrailingComma(V.parenR)?e.options=null:(e.options=this.parseMaybeAssign(),this.eat(V.parenR)||(this.expect(V.comma),this.afterTrailingComma(V.parenR)||this.unexpected())));else if(!this.eat(V.parenR)){var t=this.start;this.eat(V.comma)&&this.eat(V.parenR)?this.raiseRecoverable(t,`Trailing comma is not allowed in import()`):this.unexpected(t)}return this.finishNode(e,`ImportExpression`)},U.parseImportMeta=function(e){this.next();var t=this.containsEsc;return e.property=this.parseIdent(!0),e.property.name!==`meta`&&this.raiseRecoverable(e.property.start,`The only valid meta property for import is 'import.meta'`),t&&this.raiseRecoverable(e.start,`'import.meta' must not contain escaped characters`),this.options.sourceType!==`module`&&!this.options.allowImportExportEverywhere&&this.raiseRecoverable(e.start,`Cannot use 'import.meta' outside a module`),this.finishNode(e,`MetaProperty`)},U.parseLiteral=function(e){var t=this.startNode();return t.value=e,t.raw=this.input.slice(this.start,this.end),t.raw.charCodeAt(t.raw.length-1)===110&&(t.bigint=t.value==null?t.raw.slice(0,-1).replace(/_/g,``):t.value.toString()),this.next(),this.finishNode(t,`Literal`)},U.parseParenExpression=function(){this.expect(V.parenL);var e=this.parseExpression();return this.expect(V.parenR),e},U.shouldParseArrow=function(e){return!this.canInsertSemicolon()},U.parseParenAndDistinguishExpression=function(e,t){var n=this.start,r=this.startLoc,i,a=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var o=this.start,s=this.startLoc,c=[],l=!0,u=!1,d=new Wi,f=this.yieldPos,p=this.awaitPos,m;for(this.yieldPos=0,this.awaitPos=0;this.type!==V.parenR;)if(l?l=!1:this.expect(V.comma),a&&this.afterTrailingComma(V.parenR,!0)){u=!0;break}else if(this.type===V.ellipsis){m=this.start,c.push(this.parseParenItem(this.parseRestBinding())),this.type===V.comma&&this.raiseRecoverable(this.start,`Comma is not permitted after the rest element`);break}else c.push(this.parseMaybeAssign(!1,d,this.parseParenItem));var h=this.lastTokEnd,g=this.lastTokEndLoc;if(this.expect(V.parenR),e&&this.shouldParseArrow(c)&&this.eat(V.arrow))return this.checkPatternErrors(d,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=f,this.awaitPos=p,this.parseParenArrowList(n,r,c,t);(!c.length||u)&&this.unexpected(this.lastTokStart),m&&this.unexpected(m),this.checkExpressionErrors(d,!0),this.yieldPos=f||this.yieldPos,this.awaitPos=p||this.awaitPos,c.length>1?(i=this.startNodeAt(o,s),i.expressions=c,this.finishNodeAt(i,`SequenceExpression`,h,g)):i=c[0]}else i=this.parseParenExpression();if(this.options.preserveParens){var _=this.startNodeAt(n,r);return _.expression=i,this.finishNode(_,`ParenthesizedExpression`)}else return i},U.parseParenItem=function(e){return e},U.parseParenArrowList=function(e,t,n,r){return this.parseArrowExpression(this.startNodeAt(e,t),n,!1,r)};var aa=[];U.parseNew=function(){this.containsEsc&&this.raiseRecoverable(this.start,`Escape sequence in keyword new`);var e=this.startNode();if(this.next(),this.options.ecmaVersion>=6&&this.type===V.dot){var t=this.startNodeAt(e.start,e.loc&&e.loc.start);t.name=`new`,e.meta=this.finishNode(t,`Identifier`),this.next();var n=this.containsEsc;return e.property=this.parseIdent(!0),e.property.name!==`target`&&this.raiseRecoverable(e.property.start,`The only valid meta property for new is 'new.target'`),n&&this.raiseRecoverable(e.start,`'new.target' must not contain escaped characters`),this.allowNewDotTarget||this.raiseRecoverable(e.start,`'new.target' can only be used in functions and class static block`),this.finishNode(e,`MetaProperty`)}var r=this.start,i=this.startLoc;return e.callee=this.parseSubscripts(this.parseExprAtom(null,!1,!0),r,i,!0,!1),e.callee.type===`Super`&&this.raiseRecoverable(r,`Invalid use of 'super'`),this.eat(V.parenL)?e.arguments=this.parseExprList(V.parenR,this.options.ecmaVersion>=8,!1):e.arguments=aa,this.finishNode(e,`NewExpression`)},U.parseTemplateElement=function(e){var t=e.isTagged,n=this.startNode();return this.type===V.invalidTemplate?(t||this.raiseRecoverable(this.start,`Bad escape sequence in untagged template literal`),n.value={raw:this.value.replace(/\\r\\n?/g,`\n`),cooked:null}):n.value={raw:this.input.slice(this.start,this.end).replace(/\\r\\n?/g,`\n`),cooked:this.value},this.next(),n.tail=this.type===V.backQuote,this.finishNode(n,`TemplateElement`)},U.parseTemplate=function(e){e===void 0&&(e={});var t=e.isTagged;t===void 0&&(t=!1);var n=this.startNode();this.next(),n.expressions=[];var r=this.parseTemplateElement({isTagged:t});for(n.quasis=[r];!r.tail;)this.type===V.eof&&this.raise(this.pos,`Unterminated template literal`),this.expect(V.dollarBraceL),n.expressions.push(this.parseExpression()),this.expect(V.braceR),n.quasis.push(r=this.parseTemplateElement({isTagged:t}));return this.next(),this.finishNode(n,`TemplateLiteral`)},U.isAsyncProp=function(e){return!e.computed&&e.key.type===`Identifier`&&e.key.name===`async`&&(this.type===V.name||this.type===V.num||this.type===V.string||this.type===V.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===V.star)&&!Qr.test(this.input.slice(this.lastTokEnd,this.start))},U.parseObj=function(e,t){var n=this.startNode(),r=!0,i={};for(n.properties=[],this.next();!this.eat(V.braceR);){if(r)r=!1;else if(this.expect(V.comma),this.options.ecmaVersion>=5&&this.afterTrailingComma(V.braceR))break;var a=this.parseProperty(e,t);e||this.checkPropClash(a,i,t),n.properties.push(a)}return this.finishNode(n,e?`ObjectPattern`:`ObjectExpression`)},U.parseProperty=function(e,t){var n=this.startNode(),r,i,a,o;if(this.options.ecmaVersion>=9&&this.eat(V.ellipsis))return e?(n.argument=this.parseIdent(!1),this.type===V.comma&&this.raiseRecoverable(this.start,`Comma is not permitted after the rest element`),this.finishNode(n,`RestElement`)):(n.argument=this.parseMaybeAssign(!1,t),this.type===V.comma&&t&&t.trailingComma<0&&(t.trailingComma=this.start),this.finishNode(n,`SpreadElement`));this.options.ecmaVersion>=6&&(n.method=!1,n.shorthand=!1,(e||t)&&(a=this.start,o=this.startLoc),e||(r=this.eat(V.star)));var s=this.containsEsc;return this.parsePropertyName(n),!e&&!s&&this.options.ecmaVersion>=8&&!r&&this.isAsyncProp(n)?(i=!0,r=this.options.ecmaVersion>=9&&this.eat(V.star),this.parsePropertyName(n)):i=!1,this.parsePropertyValue(n,e,r,i,a,o,t,s),this.finishNode(n,`Property`)},U.parseGetterSetter=function(e){var t=e.key.name;this.parsePropertyName(e),e.value=this.parseMethod(!1),e.kind=t;var n=e.kind===`get`?0:1;if(e.value.params.length!==n){var r=e.value.start;e.kind===`get`?this.raiseRecoverable(r,`getter should have no params`):this.raiseRecoverable(r,`setter should have exactly one param`)}else e.kind===`set`&&e.value.params[0].type===`RestElement`&&this.raiseRecoverable(e.value.params[0].start,`Setter cannot use rest params`)},U.parsePropertyValue=function(e,t,n,r,i,a,o,s){(n||r)&&this.type===V.colon&&this.unexpected(),this.eat(V.colon)?(e.value=t?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,o),e.kind=`init`):this.options.ecmaVersion>=6&&this.type===V.parenL?(t&&this.unexpected(),e.method=!0,e.value=this.parseMethod(n,r),e.kind=`init`):!t&&!s&&this.options.ecmaVersion>=5&&!e.computed&&e.key.type===`Identifier`&&(e.key.name===`get`||e.key.name===`set`)&&this.type!==V.comma&&this.type!==V.braceR&&this.type!==V.eq?((n||r)&&this.unexpected(),this.parseGetterSetter(e)):this.options.ecmaVersion>=6&&!e.computed&&e.key.type===`Identifier`?((n||r)&&this.unexpected(),this.checkUnreserved(e.key),e.key.name===`await`&&!this.awaitIdentPos&&(this.awaitIdentPos=i),t?e.value=this.parseMaybeDefault(i,a,this.copyNode(e.key)):this.type===V.eq&&o?(o.shorthandAssign<0&&(o.shorthandAssign=this.start),e.value=this.parseMaybeDefault(i,a,this.copyNode(e.key))):e.value=this.copyNode(e.key),e.kind=`init`,e.shorthand=!0):this.unexpected()},U.parsePropertyName=function(e){if(this.options.ecmaVersion>=6){if(this.eat(V.bracketL))return e.computed=!0,e.key=this.parseMaybeAssign(),this.expect(V.bracketR),e.key;e.computed=!1}return e.key=this.type===V.num||this.type===V.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!==`never`)},U.initFunction=function(e){e.id=null,this.options.ecmaVersion>=6&&(e.generator=e.expression=!1),this.options.ecmaVersion>=8&&(e.async=!1)},U.parseMethod=function(e,t,n){var r=this.startNode(),i=this.yieldPos,a=this.awaitPos,o=this.awaitIdentPos;return this.initFunction(r),this.options.ecmaVersion>=6&&(r.generator=e),this.options.ecmaVersion>=8&&(r.async=!!t),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(Mi(t,r.generator)|Ei|(n?Di:0)),this.expect(V.parenL),r.params=this.parseBindingList(V.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(r,!1,!0,!1),this.yieldPos=i,this.awaitPos=a,this.awaitIdentPos=o,this.finishNode(r,`FunctionExpression`)},U.parseArrowExpression=function(e,t,n,r){var i=this.yieldPos,a=this.awaitPos,o=this.awaitIdentPos;return this.enterScope(Mi(n,!1)|wi),this.initFunction(e),this.options.ecmaVersion>=8&&(e.async=!!n),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,e.params=this.toAssignableList(t,!0),this.parseFunctionBody(e,!0,!1,r),this.yieldPos=i,this.awaitPos=a,this.awaitIdentPos=o,this.finishNode(e,`ArrowFunctionExpression`)},U.parseFunctionBody=function(e,t,n,r){var i=t&&this.type!==V.braceL,a=this.strict,o=!1;if(i)e.body=this.parseMaybeAssign(r),e.expression=!0,this.checkParams(e,!1);else{var s=this.options.ecmaVersion>=7&&!this.isSimpleParamList(e.params);(!a||s)&&(o=this.strictDirective(this.end),o&&s&&this.raiseRecoverable(e.start,`Illegal 'use strict' directive in function with non-simple parameter list`));var c=this.labels;this.labels=[],o&&(this.strict=!0),this.checkParams(e,!a&&!o&&!t&&!n&&this.isSimpleParamList(e.params)),this.strict&&e.id&&this.checkLValSimple(e.id,Ri),e.body=this.parseBlock(!1,void 0,o&&!a),e.expression=!1,this.adaptDirectivePrologue(e.body.body),this.labels=c}this.exitScope()},U.isSimpleParamList=function(e){for(var t=0,n=e;t<n.length;t+=1)if(n[t].type!==`Identifier`)return!1;return!0},U.checkParams=function(e,t){for(var n=Object.create(null),r=0,i=e.params;r<i.length;r+=1){var a=i[r];this.checkLValInnerPattern(a,Pi,t?null:n)}},U.parseExprList=function(e,t,n,r){for(var i=[],a=!0;!this.eat(e);){if(a)a=!1;else if(this.expect(V.comma),t&&this.afterTrailingComma(e))break;var o=void 0;n&&this.type===V.comma?o=null:this.type===V.ellipsis?(o=this.parseSpread(r),r&&this.type===V.comma&&r.trailingComma<0&&(r.trailingComma=this.start)):o=this.parseMaybeAssign(!1,r),i.push(o)}return i},U.checkUnreserved=function(e){var t=e.start,n=e.end,r=e.name;this.inGenerator&&r===`yield`&&this.raiseRecoverable(t,`Cannot use 'yield' as identifier inside a generator`),this.inAsync&&r===`await`&&this.raiseRecoverable(t,`Cannot use 'await' as identifier inside an async function`),!(this.currentThisScope().flags&ji)&&r===`arguments`&&this.raiseRecoverable(t,`Cannot use 'arguments' in class field initializer`),this.inClassStaticBlock&&(r===`arguments`||r===`await`)&&this.raise(t,`Cannot use `+r+` in class static initialization block`),this.keywords.test(r)&&this.raise(t,`Unexpected keyword '`+r+`'`),!(this.options.ecmaVersion<6&&this.input.slice(t,n).indexOf(`\\\\`)!==-1)&&(this.strict?this.reservedWordsStrict:this.reservedWords).test(r)&&(!this.inAsync&&r===`await`&&this.raiseRecoverable(t,`Cannot use keyword 'await' outside an async function`),this.raiseRecoverable(t,`The keyword '`+r+`' is reserved`))},U.parseIdent=function(e){var t=this.parseIdentNode();return this.next(!!e),this.finishNode(t,`Identifier`),e||(this.checkUnreserved(t),t.name===`await`&&!this.awaitIdentPos&&(this.awaitIdentPos=t.start)),t},U.parseIdentNode=function(){var e=this.startNode();return this.type===V.name?e.name=this.value:this.type.keyword?(e.name=this.type.keyword,(e.name===`class`||e.name===`function`)&&(this.lastTokEnd!==this.lastTokStart+1||this.input.charCodeAt(this.lastTokStart)!==46)&&this.context.pop(),this.type=V.name):this.unexpected(),e},U.parsePrivateIdent=function(){var e=this.startNode();return this.type===V.privateId?e.name=this.value:this.unexpected(),this.next(),this.finishNode(e,`PrivateIdentifier`),this.options.checkPrivateFields&&(this.privateNameStack.length===0?this.raise(e.start,`Private field '#`+e.name+`' must be declared in an enclosing class`):this.privateNameStack[this.privateNameStack.length-1].used.push(e)),e},U.parseYield=function(e){this.yieldPos||(this.yieldPos=this.start);var t=this.startNode();return this.next(),this.type===V.semi||this.canInsertSemicolon()||this.type!==V.star&&!this.type.startsExpr?(t.delegate=!1,t.argument=null):(t.delegate=this.eat(V.star),t.argument=this.parseMaybeAssign(e)),this.finishNode(t,`YieldExpression`)},U.parseAwait=function(e){this.awaitPos||(this.awaitPos=this.start);var t=this.startNode();return this.next(),t.argument=this.parseMaybeUnary(null,!0,!1,e),this.finishNode(t,`AwaitExpression`)};var oa=zi.prototype;oa.raise=function(e,t){var n=hi(this.input,e);t+=` (`+n.line+`:`+n.column+`)`,this.sourceFile&&(t+=` in `+this.sourceFile);var r=SyntaxError(t);throw r.pos=e,r.loc=n,r.raisedAt=this.pos,r},oa.raiseRecoverable=oa.raise,oa.curPosition=function(){if(this.options.locations)return new pi(this.curLine,this.pos-this.lineStart)};var sa=zi.prototype,ca=function(e){this.flags=e,this.var=[],this.lexical=[],this.functions=[]};sa.enterScope=function(e){this.scopeStack.push(new ca(e))},sa.exitScope=function(){this.scopeStack.pop()},sa.treatFunctionsAsVarInScope=function(e){return e.flags&xi||!this.inModule&&e.flags&bi},sa.declareName=function(e,t,n){var r=!1;if(t===Fi){var i=this.currentScope();r=i.lexical.indexOf(e)>-1||i.functions.indexOf(e)>-1||i.var.indexOf(e)>-1,i.lexical.push(e),this.inModule&&i.flags&bi&&delete this.undefinedExports[e]}else if(t===Li)this.currentScope().lexical.push(e);else if(t===Ii){var a=this.currentScope();r=this.treatFunctionsAsVar?a.lexical.indexOf(e)>-1:a.lexical.indexOf(e)>-1||a.var.indexOf(e)>-1,a.functions.push(e)}else for(var o=this.scopeStack.length-1;o>=0;--o){var s=this.scopeStack[o];if(s.lexical.indexOf(e)>-1&&!(s.flags&Ti&&s.lexical[0]===e)||!this.treatFunctionsAsVarInScope(s)&&s.functions.indexOf(e)>-1){r=!0;break}if(s.var.push(e),this.inModule&&s.flags&bi&&delete this.undefinedExports[e],s.flags&ji)break}r&&this.raiseRecoverable(n,`Identifier '`+e+`' has already been declared`)},sa.checkLocalExport=function(e){this.scopeStack[0].lexical.indexOf(e.name)===-1&&this.scopeStack[0].var.indexOf(e.name)===-1&&(this.undefinedExports[e.name]=e)},sa.currentScope=function(){return this.scopeStack[this.scopeStack.length-1]},sa.currentVarScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&(ji|ki|Oi))return t}},sa.currentThisScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&(ji|ki|Oi)&&!(t.flags&wi))return t}};var la=function(e,t,n){this.type=``,this.start=t,this.end=0,e.options.locations&&(this.loc=new mi(e,n)),e.options.directSourceFile&&(this.sourceFile=e.options.directSourceFile),e.options.ranges&&(this.range=[t,0])},ua=zi.prototype;ua.startNode=function(){return new la(this,this.start,this.startLoc)},ua.startNodeAt=function(e,t){return new la(this,e,t)};function da(e,t,n,r){return e.type=t,e.end=n,this.options.locations&&(e.loc.end=r),this.options.ranges&&(e.range[1]=n),e}ua.finishNode=function(e,t){return da.call(this,e,t,this.lastTokEnd,this.lastTokEndLoc)},ua.finishNodeAt=function(e,t,n,r){return da.call(this,e,t,n,r)},ua.copyNode=function(e){var t=new la(this,e.start,this.startLoc);for(var n in e)t[n]=e[n];return t};var fa=`Berf Beria_Erfe Gara Garay Gukh Gurung_Khema Hrkt Katakana_Or_Hiragana Kawi Kirat_Rai Krai Nag_Mundari Nagm Ol_Onal Onao Sidetic Sidt Sunu Sunuwar Tai_Yo Tayo Todhri Todr Tolong_Siki Tols Tulu_Tigalari Tutg Unknown Zzzz`,pa=`ASCII ASCII_Hex_Digit AHex Alphabetic Alpha Any Assigned Bidi_Control Bidi_C Bidi_Mirrored Bidi_M Case_Ignorable CI Cased Changes_When_Casefolded CWCF Changes_When_Casemapped CWCM Changes_When_Lowercased CWL Changes_When_NFKC_Casefolded CWKCF Changes_When_Titlecased CWT Changes_When_Uppercased CWU Dash Default_Ignorable_Code_Point DI Deprecated Dep Diacritic Dia Emoji Emoji_Component Emoji_Modifier Emoji_Modifier_Base Emoji_Presentation Extender Ext Grapheme_Base Gr_Base Grapheme_Extend Gr_Ext Hex_Digit Hex IDS_Binary_Operator IDSB IDS_Trinary_Operator IDST ID_Continue IDC ID_Start IDS Ideographic Ideo Join_Control Join_C Logical_Order_Exception LOE Lowercase Lower Math Noncharacter_Code_Point NChar Pattern_Syntax Pat_Syn Pattern_White_Space Pat_WS Quotation_Mark QMark Radical Regional_Indicator RI Sentence_Terminal STerm Soft_Dotted SD Terminal_Punctuation Term Unified_Ideograph UIdeo Uppercase Upper Variation_Selector VS White_Space space XID_Continue XIDC XID_Start XIDS`,ma=pa+` Extended_Pictographic`,ha=ma,ga=ha+` EBase EComp EMod EPres ExtPict`,_a=ga,va=_a,ya={9:pa,10:ma,11:ha,12:ga,13:_a,14:va},ba=`Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji`,xa={9:``,10:``,11:``,12:``,13:``,14:ba},Sa=`Cased_Letter LC Close_Punctuation Pe Connector_Punctuation Pc Control Cc cntrl Currency_Symbol Sc Dash_Punctuation Pd Decimal_Number Nd digit Enclosing_Mark Me Final_Punctuation Pf Format Cf Initial_Punctuation Pi Letter L Letter_Number Nl Line_Separator Zl Lowercase_Letter Ll Mark M Combining_Mark Math_Symbol Sm Modifier_Letter Lm Modifier_Symbol Sk Nonspacing_Mark Mn Number N Open_Punctuation Ps Other C Other_Letter Lo Other_Number No Other_Punctuation Po Other_Symbol So Paragraph_Separator Zp Private_Use Co Punctuation P punct Separator Z Space_Separator Zs Spacing_Mark Mc Surrogate Cs Symbol S Titlecase_Letter Lt Unassigned Cn Uppercase_Letter Lu`,Ca=`Adlam Adlm Ahom Anatolian_Hieroglyphs Hluw Arabic Arab Armenian Armn Avestan Avst Balinese Bali Bamum Bamu Bassa_Vah Bass Batak Batk Bengali Beng Bhaiksuki Bhks Bopomofo Bopo Brahmi Brah Braille Brai Buginese Bugi Buhid Buhd Canadian_Aboriginal Cans Carian Cari Caucasian_Albanian Aghb Chakma Cakm Cham Cham Cherokee Cher Common Zyyy Coptic Copt Qaac Cuneiform Xsux Cypriot Cprt Cyrillic Cyrl Deseret Dsrt Devanagari Deva Duployan Dupl Egyptian_Hieroglyphs Egyp Elbasan Elba Ethiopic Ethi Georgian Geor Glagolitic Glag Gothic Goth Grantha Gran Greek Grek Gujarati Gujr Gurmukhi Guru Han Hani Hangul Hang Hanunoo Hano Hatran Hatr Hebrew Hebr Hiragana Hira Imperial_Aramaic Armi Inherited Zinh Qaai Inscriptional_Pahlavi Phli Inscriptional_Parthian Prti Javanese Java Kaithi Kthi Kannada Knda Katakana Kana Kayah_Li Kali Kharoshthi Khar Khmer Khmr Khojki Khoj Khudawadi Sind Lao Laoo Latin Latn Lepcha Lepc Limbu Limb Linear_A Lina Linear_B Linb Lisu Lisu Lycian Lyci Lydian Lydi Mahajani Mahj Malayalam Mlym Mandaic Mand Manichaean Mani Marchen Marc Masaram_Gondi Gonm Meetei_Mayek Mtei Mende_Kikakui Mend Meroitic_Cursive Merc Meroitic_Hieroglyphs Mero Miao Plrd Modi Mongolian Mong Mro Mroo Multani Mult Myanmar Mymr Nabataean Nbat New_Tai_Lue Talu Newa Newa Nko Nkoo Nushu Nshu Ogham Ogam Ol_Chiki Olck Old_Hungarian Hung Old_Italic Ital Old_North_Arabian Narb Old_Permic Perm Old_Persian Xpeo Old_South_Arabian Sarb Old_Turkic Orkh Oriya Orya Osage Osge Osmanya Osma Pahawh_Hmong Hmng Palmyrene Palm Pau_Cin_Hau Pauc Phags_Pa Phag Phoenician Phnx Psalter_Pahlavi Phlp Rejang Rjng Runic Runr Samaritan Samr Saurashtra Saur Sharada Shrd Shavian Shaw Siddham Sidd SignWriting Sgnw Sinhala Sinh Sora_Sompeng Sora Soyombo Soyo Sundanese Sund Syloti_Nagri Sylo Syriac Syrc Tagalog Tglg Tagbanwa Tagb Tai_Le Tale Tai_Tham Lana Tai_Viet Tavt Takri Takr Tamil Taml Tangut Tang Telugu Telu Thaana Thaa Thai Thai Tibetan Tibt Tifinagh Tfng Tirhuta Tirh Ugaritic Ugar Vai Vaii Warang_Citi Wara Yi Yiii Zanabazar_Square Zanb`,wa=Ca+` Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd`,Ta=wa+` Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho`,Ea=Ta+` Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi`,Da=Ea+` Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith`,Oa=Da+` `+fa,ka={9:Ca,10:wa,11:Ta,12:Ea,13:Da,14:Oa},Aa={};function ja(e){var t=Aa[e]={binary:ui(ya[e]+` `+Sa),binaryOfStrings:ui(xa[e]),nonBinary:{General_Category:ui(Sa),Script:ui(ka[e])}};t.nonBinary.Script_Extensions=t.nonBinary.Script,t.nonBinary.gc=t.nonBinary.General_Category,t.nonBinary.sc=t.nonBinary.Script,t.nonBinary.scx=t.nonBinary.Script_Extensions}for(var Ma=0,Na=[9,10,11,12,13,14];Ma<Na.length;Ma+=1){var Pa=Na[Ma];ja(Pa)}var W=zi.prototype,Fa=function(e,t){this.parent=e,this.base=t||this};Fa.prototype.separatedFrom=function(e){for(var t=this;t;t=t.parent)for(var n=e;n;n=n.parent)if(t.base===n.base&&t!==n)return!0;return!1},Fa.prototype.sibling=function(){return new Fa(this.parent,this.base)};var Ia=function(e){this.parser=e,this.validFlags=`gim`+(e.options.ecmaVersion>=6?`uy`:``)+(e.options.ecmaVersion>=9?`s`:``)+(e.options.ecmaVersion>=13?`d`:``)+(e.options.ecmaVersion>=15?`v`:``),this.unicodeProperties=Aa[e.options.ecmaVersion>=14?14:e.options.ecmaVersion],this.source=``,this.flags=``,this.start=0,this.switchU=!1,this.switchV=!1,this.switchN=!1,this.pos=0,this.lastIntValue=0,this.lastStringValue=``,this.lastAssertionIsQuantifiable=!1,this.numCapturingParens=0,this.maxBackReference=0,this.groupNames=Object.create(null),this.backReferenceNames=[],this.branchID=null};Ia.prototype.reset=function(e,t,n){var r=n.indexOf(`v`)!==-1,i=n.indexOf(`u`)!==-1;this.start=e|0,this.source=t+``,this.flags=n,r&&this.parser.options.ecmaVersion>=15?(this.switchU=!0,this.switchV=!0,this.switchN=!0):(this.switchU=i&&this.parser.options.ecmaVersion>=6,this.switchV=!1,this.switchN=i&&this.parser.options.ecmaVersion>=9)},Ia.prototype.raise=function(e){this.parser.raiseRecoverable(this.start,`Invalid regular expression: /`+this.source+`/: `+e)},Ia.prototype.at=function(e,t){t===void 0&&(t=!1);var n=this.source,r=n.length;if(e>=r)return-1;var i=n.charCodeAt(e);if(!(t||this.switchU)||i<=55295||i>=57344||e+1>=r)return i;var a=n.charCodeAt(e+1);return a>=56320&&a<=57343?(i<<10)+a-56613888:i},Ia.prototype.nextIndex=function(e,t){t===void 0&&(t=!1);var n=this.source,r=n.length;if(e>=r)return r;var i=n.charCodeAt(e),a;return!(t||this.switchU)||i<=55295||i>=57344||e+1>=r||(a=n.charCodeAt(e+1))<56320||a>57343?e+1:e+2},Ia.prototype.current=function(e){return e===void 0&&(e=!1),this.at(this.pos,e)},Ia.prototype.lookahead=function(e){return e===void 0&&(e=!1),this.at(this.nextIndex(this.pos,e),e)},Ia.prototype.advance=function(e){e===void 0&&(e=!1),this.pos=this.nextIndex(this.pos,e)},Ia.prototype.eat=function(e,t){return t===void 0&&(t=!1),this.current(t)===e?(this.advance(t),!0):!1},Ia.prototype.eatChars=function(e,t){t===void 0&&(t=!1);for(var n=this.pos,r=0,i=e;r<i.length;r+=1){var a=i[r],o=this.at(n,t);if(o===-1||o!==a)return!1;n=this.nextIndex(n,t)}return this.pos=n,!0},W.validateRegExpFlags=function(e){for(var t=e.validFlags,n=e.flags,r=!1,i=!1,a=0;a<n.length;a++){var o=n.charAt(a);t.indexOf(o)===-1&&this.raise(e.start,`Invalid regular expression flag`),n.indexOf(o,a+1)>-1&&this.raise(e.start,`Duplicate regular expression flag`),o===`u`&&(r=!0),o===`v`&&(i=!0)}this.options.ecmaVersion>=15&&r&&i&&this.raise(e.start,`Invalid regular expression flag`)};function La(e){for(var t in e)return!0;return!1}W.validateRegExpPattern=function(e){this.regexp_pattern(e),!e.switchN&&this.options.ecmaVersion>=9&&La(e.groupNames)&&(e.switchN=!0,this.regexp_pattern(e))},W.regexp_pattern=function(e){e.pos=0,e.lastIntValue=0,e.lastStringValue=``,e.lastAssertionIsQuantifiable=!1,e.numCapturingParens=0,e.maxBackReference=0,e.groupNames=Object.create(null),e.backReferenceNames.length=0,e.branchID=null,this.regexp_disjunction(e),e.pos!==e.source.length&&(e.eat(41)&&e.raise(`Unmatched ')'`),(e.eat(93)||e.eat(125))&&e.raise(`Lone quantifier brackets`)),e.maxBackReference>e.numCapturingParens&&e.raise(`Invalid escape`);for(var t=0,n=e.backReferenceNames;t<n.length;t+=1){var r=n[t];e.groupNames[r]||e.raise(`Invalid named capture referenced`)}},W.regexp_disjunction=function(e){var t=this.options.ecmaVersion>=16;for(t&&(e.branchID=new Fa(e.branchID,null)),this.regexp_alternative(e);e.eat(124);)t&&(e.branchID=e.branchID.sibling()),this.regexp_alternative(e);t&&(e.branchID=e.branchID.parent),this.regexp_eatQuantifier(e,!0)&&e.raise(`Nothing to repeat`),e.eat(123)&&e.raise(`Lone quantifier brackets`)},W.regexp_alternative=function(e){for(;e.pos<e.source.length&&this.regexp_eatTerm(e););},W.regexp_eatTerm=function(e){return this.regexp_eatAssertion(e)?(e.lastAssertionIsQuantifiable&&this.regexp_eatQuantifier(e)&&e.switchU&&e.raise(`Invalid quantifier`),!0):(e.switchU?this.regexp_eatAtom(e):this.regexp_eatExtendedAtom(e))?(this.regexp_eatQuantifier(e),!0):!1},W.regexp_eatAssertion=function(e){var t=e.pos;if(e.lastAssertionIsQuantifiable=!1,e.eat(94)||e.eat(36))return!0;if(e.eat(92)){if(e.eat(66)||e.eat(98))return!0;e.pos=t}if(e.eat(40)&&e.eat(63)){var n=!1;if(this.options.ecmaVersion>=9&&(n=e.eat(60)),e.eat(61)||e.eat(33))return this.regexp_disjunction(e),e.eat(41)||e.raise(`Unterminated group`),e.lastAssertionIsQuantifiable=!n,!0}return e.pos=t,!1},W.regexp_eatQuantifier=function(e,t){return t===void 0&&(t=!1),this.regexp_eatQuantifierPrefix(e,t)?(e.eat(63),!0):!1},W.regexp_eatQuantifierPrefix=function(e,t){return e.eat(42)||e.eat(43)||e.eat(63)||this.regexp_eatBracedQuantifier(e,t)},W.regexp_eatBracedQuantifier=function(e,t){var n=e.pos;if(e.eat(123)){var r=0,i=-1;if(this.regexp_eatDecimalDigits(e)&&(r=e.lastIntValue,e.eat(44)&&this.regexp_eatDecimalDigits(e)&&(i=e.lastIntValue),e.eat(125)))return i!==-1&&i<r&&!t&&e.raise(`numbers out of order in {} quantifier`),!0;e.switchU&&!t&&e.raise(`Incomplete quantifier`),e.pos=n}return!1},W.regexp_eatAtom=function(e){return this.regexp_eatPatternCharacters(e)||e.eat(46)||this.regexp_eatReverseSolidusAtomEscape(e)||this.regexp_eatCharacterClass(e)||this.regexp_eatUncapturingGroup(e)||this.regexp_eatCapturingGroup(e)},W.regexp_eatReverseSolidusAtomEscape=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatAtomEscape(e))return!0;e.pos=t}return!1},W.regexp_eatUncapturingGroup=function(e){var t=e.pos;if(e.eat(40)){if(e.eat(63)){if(this.options.ecmaVersion>=16){var n=this.regexp_eatModifiers(e),r=e.eat(45);if(n||r){for(var i=0;i<n.length;i++){var a=n.charAt(i);n.indexOf(a,i+1)>-1&&e.raise(`Duplicate regular expression modifiers`)}if(r){var o=this.regexp_eatModifiers(e);!n&&!o&&e.current()===58&&e.raise(`Invalid regular expression modifiers`);for(var s=0;s<o.length;s++){var c=o.charAt(s);(o.indexOf(c,s+1)>-1||n.indexOf(c)>-1)&&e.raise(`Duplicate regular expression modifiers`)}}}}if(e.eat(58)){if(this.regexp_disjunction(e),e.eat(41))return!0;e.raise(`Unterminated group`)}}e.pos=t}return!1},W.regexp_eatCapturingGroup=function(e){if(e.eat(40)){if(this.options.ecmaVersion>=9?this.regexp_groupSpecifier(e):e.current()===63&&e.raise(`Invalid group`),this.regexp_disjunction(e),e.eat(41))return e.numCapturingParens+=1,!0;e.raise(`Unterminated group`)}return!1},W.regexp_eatModifiers=function(e){for(var t=``,n=0;(n=e.current())!==-1&&Ra(n);)t+=di(n),e.advance();return t};function Ra(e){return e===105||e===109||e===115}W.regexp_eatExtendedAtom=function(e){return e.eat(46)||this.regexp_eatReverseSolidusAtomEscape(e)||this.regexp_eatCharacterClass(e)||this.regexp_eatUncapturingGroup(e)||this.regexp_eatCapturingGroup(e)||this.regexp_eatInvalidBracedQuantifier(e)||this.regexp_eatExtendedPatternCharacter(e)},W.regexp_eatInvalidBracedQuantifier=function(e){return this.regexp_eatBracedQuantifier(e,!0)&&e.raise(`Nothing to repeat`),!1},W.regexp_eatSyntaxCharacter=function(e){var t=e.current();return za(t)?(e.lastIntValue=t,e.advance(),!0):!1};function za(e){return e===36||e>=40&&e<=43||e===46||e===63||e>=91&&e<=94||e>=123&&e<=125}W.regexp_eatPatternCharacters=function(e){for(var t=e.pos,n=0;(n=e.current())!==-1&&!za(n);)e.advance();return e.pos!==t},W.regexp_eatExtendedPatternCharacter=function(e){var t=e.current();return t!==-1&&t!==36&&!(t>=40&&t<=43)&&t!==46&&t!==63&&t!==91&&t!==94&&t!==124?(e.advance(),!0):!1},W.regexp_groupSpecifier=function(e){if(e.eat(63)){this.regexp_eatGroupName(e)||e.raise(`Invalid group`);var t=this.options.ecmaVersion>=16,n=e.groupNames[e.lastStringValue];if(n)if(t)for(var r=0,i=n;r<i.length;r+=1)i[r].separatedFrom(e.branchID)||e.raise(`Duplicate capture group name`);else e.raise(`Duplicate capture group name`);t?(n||(e.groupNames[e.lastStringValue]=[])).push(e.branchID):e.groupNames[e.lastStringValue]=!0}},W.regexp_eatGroupName=function(e){if(e.lastStringValue=``,e.eat(60)){if(this.regexp_eatRegExpIdentifierName(e)&&e.eat(62))return!0;e.raise(`Invalid capture group name`)}return!1},W.regexp_eatRegExpIdentifierName=function(e){if(e.lastStringValue=``,this.regexp_eatRegExpIdentifierStart(e)){for(e.lastStringValue+=di(e.lastIntValue);this.regexp_eatRegExpIdentifierPart(e);)e.lastStringValue+=di(e.lastIntValue);return!0}return!1},W.regexp_eatRegExpIdentifierStart=function(e){var t=e.pos,n=this.options.ecmaVersion>=11,r=e.current(n);return e.advance(n),r===92&&this.regexp_eatRegExpUnicodeEscapeSequence(e,n)&&(r=e.lastIntValue),Ba(r)?(e.lastIntValue=r,!0):(e.pos=t,!1)};function Ba(e){return Kr(e,!0)||e===36||e===95}W.regexp_eatRegExpIdentifierPart=function(e){var t=e.pos,n=this.options.ecmaVersion>=11,r=e.current(n);return e.advance(n),r===92&&this.regexp_eatRegExpUnicodeEscapeSequence(e,n)&&(r=e.lastIntValue),Va(r)?(e.lastIntValue=r,!0):(e.pos=t,!1)};function Va(e){return qr(e,!0)||e===36||e===95||e===8204||e===8205}W.regexp_eatAtomEscape=function(e){return this.regexp_eatBackReference(e)||this.regexp_eatCharacterClassEscape(e)||this.regexp_eatCharacterEscape(e)||e.switchN&&this.regexp_eatKGroupName(e)?!0:(e.switchU&&(e.current()===99&&e.raise(`Invalid unicode escape`),e.raise(`Invalid escape`)),!1)},W.regexp_eatBackReference=function(e){var t=e.pos;if(this.regexp_eatDecimalEscape(e)){var n=e.lastIntValue;if(e.switchU)return n>e.maxBackReference&&(e.maxBackReference=n),!0;if(n<=e.numCapturingParens)return!0;e.pos=t}return!1},W.regexp_eatKGroupName=function(e){if(e.eat(107)){if(this.regexp_eatGroupName(e))return e.backReferenceNames.push(e.lastStringValue),!0;e.raise(`Invalid named reference`)}return!1},W.regexp_eatCharacterEscape=function(e){return this.regexp_eatControlEscape(e)||this.regexp_eatCControlLetter(e)||this.regexp_eatZero(e)||this.regexp_eatHexEscapeSequence(e)||this.regexp_eatRegExpUnicodeEscapeSequence(e,!1)||!e.switchU&&this.regexp_eatLegacyOctalEscapeSequence(e)||this.regexp_eatIdentityEscape(e)},W.regexp_eatCControlLetter=function(e){var t=e.pos;if(e.eat(99)){if(this.regexp_eatControlLetter(e))return!0;e.pos=t}return!1},W.regexp_eatZero=function(e){return e.current()===48&&!$a(e.lookahead())?(e.lastIntValue=0,e.advance(),!0):!1},W.regexp_eatControlEscape=function(e){var t=e.current();return t===116?(e.lastIntValue=9,e.advance(),!0):t===110?(e.lastIntValue=10,e.advance(),!0):t===118?(e.lastIntValue=11,e.advance(),!0):t===102?(e.lastIntValue=12,e.advance(),!0):t===114?(e.lastIntValue=13,e.advance(),!0):!1},W.regexp_eatControlLetter=function(e){var t=e.current();return Ha(t)?(e.lastIntValue=t%32,e.advance(),!0):!1};function Ha(e){return e>=65&&e<=90||e>=97&&e<=122}W.regexp_eatRegExpUnicodeEscapeSequence=function(e,t){t===void 0&&(t=!1);var n=e.pos,r=t||e.switchU;if(e.eat(117)){if(this.regexp_eatFixedHexDigits(e,4)){var i=e.lastIntValue;if(r&&i>=55296&&i<=56319){var a=e.pos;if(e.eat(92)&&e.eat(117)&&this.regexp_eatFixedHexDigits(e,4)){var o=e.lastIntValue;if(o>=56320&&o<=57343)return e.lastIntValue=(i-55296)*1024+(o-56320)+65536,!0}e.pos=a,e.lastIntValue=i}return!0}if(r&&e.eat(123)&&this.regexp_eatHexDigits(e)&&e.eat(125)&&Ua(e.lastIntValue))return!0;r&&e.raise(`Invalid unicode escape`),e.pos=n}return!1};function Ua(e){return e>=0&&e<=1114111}W.regexp_eatIdentityEscape=function(e){if(e.switchU)return this.regexp_eatSyntaxCharacter(e)?!0:e.eat(47)?(e.lastIntValue=47,!0):!1;var t=e.current();return t!==99&&(!e.switchN||t!==107)?(e.lastIntValue=t,e.advance(),!0):!1},W.regexp_eatDecimalEscape=function(e){e.lastIntValue=0;var t=e.current();if(t>=49&&t<=57){do e.lastIntValue=10*e.lastIntValue+(t-48),e.advance();while((t=e.current())>=48&&t<=57);return!0}return!1};var Wa=0,Ga=1,Ka=2;W.regexp_eatCharacterClassEscape=function(e){var t=e.current();if(qa(t))return e.lastIntValue=-1,e.advance(),Ga;var n=!1;if(e.switchU&&this.options.ecmaVersion>=9&&((n=t===80)||t===112)){e.lastIntValue=-1,e.advance();var r;if(e.eat(123)&&(r=this.regexp_eatUnicodePropertyValueExpression(e))&&e.eat(125))return n&&r===Ka&&e.raise(`Invalid property name`),r;e.raise(`Invalid property name`)}return Wa};function qa(e){return e===100||e===68||e===115||e===83||e===119||e===87}W.regexp_eatUnicodePropertyValueExpression=function(e){var t=e.pos;if(this.regexp_eatUnicodePropertyName(e)&&e.eat(61)){var n=e.lastStringValue;if(this.regexp_eatUnicodePropertyValue(e)){var r=e.lastStringValue;return this.regexp_validateUnicodePropertyNameAndValue(e,n,r),Ga}}if(e.pos=t,this.regexp_eatLoneUnicodePropertyNameOrValue(e)){var i=e.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(e,i)}return Wa},W.regexp_validateUnicodePropertyNameAndValue=function(e,t,n){si(e.unicodeProperties.nonBinary,t)||e.raise(`Invalid property name`),e.unicodeProperties.nonBinary[t].test(n)||e.raise(`Invalid property value`)},W.regexp_validateUnicodePropertyNameOrValue=function(e,t){if(e.unicodeProperties.binary.test(t))return Ga;if(e.switchV&&e.unicodeProperties.binaryOfStrings.test(t))return Ka;e.raise(`Invalid property name`)},W.regexp_eatUnicodePropertyName=function(e){var t=0;for(e.lastStringValue=``;Ja(t=e.current());)e.lastStringValue+=di(t),e.advance();return e.lastStringValue!==``};function Ja(e){return Ha(e)||e===95}W.regexp_eatUnicodePropertyValue=function(e){var t=0;for(e.lastStringValue=``;Ya(t=e.current());)e.lastStringValue+=di(t),e.advance();return e.lastStringValue!==``};function Ya(e){return Ja(e)||$a(e)}W.regexp_eatLoneUnicodePropertyNameOrValue=function(e){return this.regexp_eatUnicodePropertyValue(e)},W.regexp_eatCharacterClass=function(e){if(e.eat(91)){var t=e.eat(94),n=this.regexp_classContents(e);return e.eat(93)||e.raise(`Unterminated character class`),t&&n===Ka&&e.raise(`Negated character class may contain strings`),!0}return!1},W.regexp_classContents=function(e){return e.current()===93?Ga:e.switchV?this.regexp_classSetExpression(e):(this.regexp_nonEmptyClassRanges(e),Ga)},W.regexp_nonEmptyClassRanges=function(e){for(;this.regexp_eatClassAtom(e);){var t=e.lastIntValue;if(e.eat(45)&&this.regexp_eatClassAtom(e)){var n=e.lastIntValue;e.switchU&&(t===-1||n===-1)&&e.raise(`Invalid character class`),t!==-1&&n!==-1&&t>n&&e.raise(`Range out of order in character class`)}}},W.regexp_eatClassAtom=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatClassEscape(e))return!0;if(e.switchU){var n=e.current();(n===99||no(n))&&e.raise(`Invalid class escape`),e.raise(`Invalid escape`)}e.pos=t}var r=e.current();return r===93?!1:(e.lastIntValue=r,e.advance(),!0)},W.regexp_eatClassEscape=function(e){var t=e.pos;if(e.eat(98))return e.lastIntValue=8,!0;if(e.switchU&&e.eat(45))return e.lastIntValue=45,!0;if(!e.switchU&&e.eat(99)){if(this.regexp_eatClassControlLetter(e))return!0;e.pos=t}return this.regexp_eatCharacterClassEscape(e)||this.regexp_eatCharacterEscape(e)},W.regexp_classSetExpression=function(e){var t=Ga,n;if(!this.regexp_eatClassSetRange(e))if(n=this.regexp_eatClassSetOperand(e)){n===Ka&&(t=Ka);for(var r=e.pos;e.eatChars([38,38]);){if(e.current()!==38&&(n=this.regexp_eatClassSetOperand(e))){n!==Ka&&(t=Ga);continue}e.raise(`Invalid character in character class`)}if(r!==e.pos)return t;for(;e.eatChars([45,45]);)this.regexp_eatClassSetOperand(e)||e.raise(`Invalid character in character class`);if(r!==e.pos)return t}else e.raise(`Invalid character in character class`);for(;;)if(!this.regexp_eatClassSetRange(e)){if(n=this.regexp_eatClassSetOperand(e),!n)return t;n===Ka&&(t=Ka)}},W.regexp_eatClassSetRange=function(e){var t=e.pos;if(this.regexp_eatClassSetCharacter(e)){var n=e.lastIntValue;if(e.eat(45)&&this.regexp_eatClassSetCharacter(e)){var r=e.lastIntValue;return n!==-1&&r!==-1&&n>r&&e.raise(`Range out of order in character class`),!0}e.pos=t}return!1},W.regexp_eatClassSetOperand=function(e){return this.regexp_eatClassSetCharacter(e)?Ga:this.regexp_eatClassStringDisjunction(e)||this.regexp_eatNestedClass(e)},W.regexp_eatNestedClass=function(e){var t=e.pos;if(e.eat(91)){var n=e.eat(94),r=this.regexp_classContents(e);if(e.eat(93))return n&&r===Ka&&e.raise(`Negated character class may contain strings`),r;e.pos=t}if(e.eat(92)){var i=this.regexp_eatCharacterClassEscape(e);if(i)return i;e.pos=t}return null},W.regexp_eatClassStringDisjunction=function(e){var t=e.pos;if(e.eatChars([92,113])){if(e.eat(123)){var n=this.regexp_classStringDisjunctionContents(e);if(e.eat(125))return n}else e.raise(`Invalid escape`);e.pos=t}return null},W.regexp_classStringDisjunctionContents=function(e){for(var t=this.regexp_classString(e);e.eat(124);)this.regexp_classString(e)===Ka&&(t=Ka);return t},W.regexp_classString=function(e){for(var t=0;this.regexp_eatClassSetCharacter(e);)t++;return t===1?Ga:Ka},W.regexp_eatClassSetCharacter=function(e){var t=e.pos;if(e.eat(92))return this.regexp_eatCharacterEscape(e)||this.regexp_eatClassSetReservedPunctuator(e)?!0:e.eat(98)?(e.lastIntValue=8,!0):(e.pos=t,!1);var n=e.current();return n<0||n===e.lookahead()&&Xa(n)||Za(n)?!1:(e.advance(),e.lastIntValue=n,!0)};function Xa(e){return e===33||e>=35&&e<=38||e>=42&&e<=44||e===46||e>=58&&e<=64||e===94||e===96||e===126}function Za(e){return e===40||e===41||e===45||e===47||e>=91&&e<=93||e>=123&&e<=125}W.regexp_eatClassSetReservedPunctuator=function(e){var t=e.current();return Qa(t)?(e.lastIntValue=t,e.advance(),!0):!1};function Qa(e){return e===33||e===35||e===37||e===38||e===44||e===45||e>=58&&e<=62||e===64||e===96||e===126}W.regexp_eatClassControlLetter=function(e){var t=e.current();return $a(t)||t===95?(e.lastIntValue=t%32,e.advance(),!0):!1},W.regexp_eatHexEscapeSequence=function(e){var t=e.pos;if(e.eat(120)){if(this.regexp_eatFixedHexDigits(e,2))return!0;e.switchU&&e.raise(`Invalid escape`),e.pos=t}return!1},W.regexp_eatDecimalDigits=function(e){var t=e.pos,n=0;for(e.lastIntValue=0;$a(n=e.current());)e.lastIntValue=10*e.lastIntValue+(n-48),e.advance();return e.pos!==t};function $a(e){return e>=48&&e<=57}W.regexp_eatHexDigits=function(e){var t=e.pos,n=0;for(e.lastIntValue=0;eo(n=e.current());)e.lastIntValue=16*e.lastIntValue+to(n),e.advance();return e.pos!==t};function eo(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function to(e){return e>=65&&e<=70?10+(e-65):e>=97&&e<=102?10+(e-97):e-48}W.regexp_eatLegacyOctalEscapeSequence=function(e){if(this.regexp_eatOctalDigit(e)){var t=e.lastIntValue;if(this.regexp_eatOctalDigit(e)){var n=e.lastIntValue;t<=3&&this.regexp_eatOctalDigit(e)?e.lastIntValue=t*64+n*8+e.lastIntValue:e.lastIntValue=t*8+n}else e.lastIntValue=t;return!0}return!1},W.regexp_eatOctalDigit=function(e){var t=e.current();return no(t)?(e.lastIntValue=t-48,e.advance(),!0):(e.lastIntValue=0,!1)};function no(e){return e>=48&&e<=55}W.regexp_eatFixedHexDigits=function(e,t){var n=e.pos;e.lastIntValue=0;for(var r=0;r<t;++r){var i=e.current();if(!eo(i))return e.pos=n,!1;e.lastIntValue=16*e.lastIntValue+to(i),e.advance()}return!0};var ro=function(e){this.type=e.type,this.value=e.value,this.start=e.start,this.end=e.end,e.options.locations&&(this.loc=new mi(e,e.startLoc,e.endLoc)),e.options.ranges&&(this.range=[e.start,e.end])},G=zi.prototype;G.next=function(e){!e&&this.type.keyword&&this.containsEsc&&this.raiseRecoverable(this.start,`Escape sequence in keyword `+this.type.keyword),this.options.onToken&&this.options.onToken(new ro(this)),this.lastTokEnd=this.end,this.lastTokStart=this.start,this.lastTokEndLoc=this.endLoc,this.lastTokStartLoc=this.startLoc,this.nextToken()},G.getToken=function(){return this.next(),new ro(this)},typeof Symbol<`u`&&(G[Symbol.iterator]=function(){var e=this;return{next:function(){var t=e.getToken();return{done:t.type===V.eof,value:t}}}}),G.nextToken=function(){var e=this.curContext();if((!e||!e.preserveSpace)&&this.skipSpace(),this.start=this.pos,this.options.locations&&(this.startLoc=this.curPosition()),this.pos>=this.input.length)return this.finishToken(V.eof);if(e.override)return e.override(this);this.readToken(this.fullCharCodeAtPos())},G.readToken=function(e){return Kr(e,this.options.ecmaVersion>=6)||e===92?this.readWord():this.getTokenFromCode(e)},G.fullCharCodeAt=function(e){var t=this.input.charCodeAt(e);if(t<=55295||t>=56320)return t;var n=this.input.charCodeAt(e+1);return n<=56319||n>=57344?t:(t<<10)+n-56613888},G.fullCharCodeAtPos=function(){return this.fullCharCodeAt(this.pos)},G.skipBlockComment=function(){var e=this.options.onComment&&this.curPosition(),t=this.pos,n=this.input.indexOf(`*/`,this.pos+=2);if(n===-1&&this.raise(this.pos-2,`Unterminated comment`),this.pos=n+2,this.options.locations)for(var r=void 0,i=t;(r=ti(this.input,i,this.pos))>-1;)++this.curLine,i=this.lineStart=r;this.options.onComment&&this.options.onComment(!0,this.input.slice(t+2,n),t,this.pos,e,this.curPosition())},G.skipLineComment=function(e){for(var t=this.pos,n=this.options.onComment&&this.curPosition(),r=this.input.charCodeAt(this.pos+=e);this.pos<this.input.length&&!ei(r);)r=this.input.charCodeAt(++this.pos);this.options.onComment&&this.options.onComment(!1,this.input.slice(t+e,this.pos),t,this.pos,n,this.curPosition())},G.skipSpace=function(){loop:for(;this.pos<this.input.length;){var e=this.input.charCodeAt(this.pos);switch(e){case 32:case 160:++this.pos;break;case 13:this.input.charCodeAt(this.pos+1)===10&&++this.pos;case 10:case 8232:case 8233:++this.pos,this.options.locations&&(++this.curLine,this.lineStart=this.pos);break;case 47:switch(this.input.charCodeAt(this.pos+1)){case 42:this.skipBlockComment();break;case 47:this.skipLineComment(2);break;default:break loop}break;default:if(e>8&&e<14||e>=5760&&ni.test(String.fromCharCode(e)))++this.pos;else break loop}}},G.finishToken=function(e,t){this.end=this.pos,this.options.locations&&(this.endLoc=this.curPosition());var n=this.type;this.type=e,this.value=t,this.updateContext(n)},G.readToken_dot=function(){var e=this.input.charCodeAt(this.pos+1);if(e>=48&&e<=57)return this.readNumber(!0);var t=this.input.charCodeAt(this.pos+2);return this.options.ecmaVersion>=6&&e===46&&t===46?(this.pos+=3,this.finishToken(V.ellipsis)):(++this.pos,this.finishToken(V.dot))},G.readToken_slash=function(){var e=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):e===61?this.finishOp(V.assign,2):this.finishOp(V.slash,1)},G.readToken_mult_modulo_exp=function(e){var t=this.input.charCodeAt(this.pos+1),n=1,r=e===42?V.star:V.modulo;return this.options.ecmaVersion>=7&&e===42&&t===42&&(++n,r=V.starstar,t=this.input.charCodeAt(this.pos+2)),t===61?this.finishOp(V.assign,n+1):this.finishOp(r,n)},G.readToken_pipe_amp=function(e){var t=this.input.charCodeAt(this.pos+1);return t===e?this.options.ecmaVersion>=12&&this.input.charCodeAt(this.pos+2)===61?this.finishOp(V.assign,3):this.finishOp(e===124?V.logicalOR:V.logicalAND,2):t===61?this.finishOp(V.assign,2):this.finishOp(e===124?V.bitwiseOR:V.bitwiseAND,1)},G.readToken_caret=function(){return this.input.charCodeAt(this.pos+1)===61?this.finishOp(V.assign,2):this.finishOp(V.bitwiseXOR,1)},G.readToken_plus_min=function(e){var t=this.input.charCodeAt(this.pos+1);return t===e?t===45&&!this.inModule&&this.input.charCodeAt(this.pos+2)===62&&(this.lastTokEnd===0||Qr.test(this.input.slice(this.lastTokEnd,this.pos)))?(this.skipLineComment(3),this.skipSpace(),this.nextToken()):this.finishOp(V.incDec,2):t===61?this.finishOp(V.assign,2):this.finishOp(V.plusMin,1)},G.readToken_lt_gt=function(e){var t=this.input.charCodeAt(this.pos+1),n=1;return t===e?(n=e===62&&this.input.charCodeAt(this.pos+2)===62?3:2,this.input.charCodeAt(this.pos+n)===61?this.finishOp(V.assign,n+1):this.finishOp(V.bitShift,n)):t===33&&e===60&&!this.inModule&&this.input.charCodeAt(this.pos+2)===45&&this.input.charCodeAt(this.pos+3)===45?(this.skipLineComment(4),this.skipSpace(),this.nextToken()):(t===61&&(n=2),this.finishOp(V.relational,n))},G.readToken_eq_excl=function(e){var t=this.input.charCodeAt(this.pos+1);return t===61?this.finishOp(V.equality,this.input.charCodeAt(this.pos+2)===61?3:2):e===61&&t===62&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(V.arrow)):this.finishOp(e===61?V.eq:V.prefix,1)},G.readToken_question=function(){var e=this.options.ecmaVersion;if(e>=11){var t=this.input.charCodeAt(this.pos+1);if(t===46){var n=this.input.charCodeAt(this.pos+2);if(n<48||n>57)return this.finishOp(V.questionDot,2)}if(t===63)return e>=12&&this.input.charCodeAt(this.pos+2)===61?this.finishOp(V.assign,3):this.finishOp(V.coalesce,2)}return this.finishOp(V.question,1)},G.readToken_numberSign=function(){var e=this.options.ecmaVersion,t=35;if(e>=13&&(++this.pos,t=this.fullCharCodeAtPos(),Kr(t,!0)||t===92))return this.finishToken(V.privateId,this.readWord1());this.raise(this.pos,`Unexpected character '`+di(t)+`'`)},G.getTokenFromCode=function(e){switch(e){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(V.parenL);case 41:return++this.pos,this.finishToken(V.parenR);case 59:return++this.pos,this.finishToken(V.semi);case 44:return++this.pos,this.finishToken(V.comma);case 91:return++this.pos,this.finishToken(V.bracketL);case 93:return++this.pos,this.finishToken(V.bracketR);case 123:return++this.pos,this.finishToken(V.braceL);case 125:return++this.pos,this.finishToken(V.braceR);case 58:return++this.pos,this.finishToken(V.colon);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(V.backQuote);case 48:var t=this.input.charCodeAt(this.pos+1);if(t===120||t===88)return this.readRadixNumber(16);if(this.options.ecmaVersion>=6){if(t===111||t===79)return this.readRadixNumber(8);if(t===98||t===66)return this.readRadixNumber(2)}case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.readNumber(!1);case 34:case 39:return this.readString(e);case 47:return this.readToken_slash();case 37:case 42:return this.readToken_mult_modulo_exp(e);case 124:case 38:return this.readToken_pipe_amp(e);case 94:return this.readToken_caret();case 43:case 45:return this.readToken_plus_min(e);case 60:case 62:return this.readToken_lt_gt(e);case 61:case 33:return this.readToken_eq_excl(e);case 63:return this.readToken_question();case 126:return this.finishOp(V.prefix,1);case 35:return this.readToken_numberSign()}this.raise(this.pos,`Unexpected character '`+di(e)+`'`)},G.finishOp=function(e,t){var n=this.input.slice(this.pos,this.pos+t);return this.pos+=t,this.finishToken(e,n)},G.readRegexp=function(){for(var e,t,n=this.pos;;){this.pos>=this.input.length&&this.raise(n,`Unterminated regular expression`);var r=this.input.charAt(this.pos);if(Qr.test(r)&&this.raise(n,`Unterminated regular expression`),e)e=!1;else{if(r===`[`)t=!0;else if(r===`]`&&t)t=!1;else if(r===`/`&&!t)break;e=r===`\\\\`}++this.pos}var i=this.input.slice(n,this.pos);++this.pos;var a=this.pos,o=this.readWord1();this.containsEsc&&this.unexpected(a);var s=this.regexpState||(this.regexpState=new Ia(this));s.reset(n,i,o),this.validateRegExpFlags(s),this.validateRegExpPattern(s);var c=null;try{c=new RegExp(i,o)}catch{}return this.finishToken(V.regexp,{pattern:i,flags:o,value:c})},G.readInt=function(e,t,n){for(var r=this.options.ecmaVersion>=12&&t===void 0,i=n&&this.input.charCodeAt(this.pos)===48,a=this.pos,o=0,s=0,c=0,l=t??1/0;c<l;++c,++this.pos){var u=this.input.charCodeAt(this.pos),d=void 0;if(r&&u===95){i&&this.raiseRecoverable(this.pos,`Numeric separator is not allowed in legacy octal numeric literals`),s===95&&this.raiseRecoverable(this.pos,`Numeric separator must be exactly one underscore`),c===0&&this.raiseRecoverable(this.pos,`Numeric separator is not allowed at the first of digits`),s=u;continue}if(d=u>=97?u-97+10:u>=65?u-65+10:u>=48&&u<=57?u-48:1/0,d>=e)break;s=u,o=o*e+d}return r&&s===95&&this.raiseRecoverable(this.pos-1,`Numeric separator is not allowed at the last of digits`),this.pos===a||t!=null&&this.pos-a!==t?null:o};function io(e,t){return t?parseInt(e,8):parseFloat(e.replace(/_/g,``))}function ao(e){return typeof BigInt==`function`?BigInt(e.replace(/_/g,``)):null}G.readRadixNumber=function(e){var t=this.pos;this.pos+=2;var n=this.readInt(e);return n??this.raise(this.start+2,`Expected number in radix `+e),this.options.ecmaVersion>=11&&this.input.charCodeAt(this.pos)===110?(n=ao(this.input.slice(t,this.pos)),++this.pos):Kr(this.fullCharCodeAtPos())&&this.raise(this.pos,`Identifier directly after number`),this.finishToken(V.num,n)},G.readNumber=function(e){var t=this.pos;!e&&this.readInt(10,void 0,!0)===null&&this.raise(t,`Invalid number`);var n=this.pos-t>=2&&this.input.charCodeAt(t)===48;n&&this.strict&&this.raise(t,`Invalid number`);var r=this.input.charCodeAt(this.pos);if(!n&&!e&&this.options.ecmaVersion>=11&&r===110){var i=ao(this.input.slice(t,this.pos));return++this.pos,Kr(this.fullCharCodeAtPos())&&this.raise(this.pos,`Identifier directly after number`),this.finishToken(V.num,i)}n&&/[89]/.test(this.input.slice(t,this.pos))&&(n=!1),r===46&&!n&&(++this.pos,this.readInt(10),r=this.input.charCodeAt(this.pos)),(r===69||r===101)&&!n&&(r=this.input.charCodeAt(++this.pos),(r===43||r===45)&&++this.pos,this.readInt(10)===null&&this.raise(t,`Invalid number`)),Kr(this.fullCharCodeAtPos())&&this.raise(this.pos,`Identifier directly after number`);var a=io(this.input.slice(t,this.pos),n);return this.finishToken(V.num,a)},G.readCodePoint=function(){var e=this.input.charCodeAt(this.pos),t;if(e===123){this.options.ecmaVersion<6&&this.unexpected();var n=++this.pos;t=this.readHexChar(this.input.indexOf(`}`,this.pos)-this.pos),++this.pos,t>1114111&&this.invalidStringToken(n,`Code point out of bounds`)}else t=this.readHexChar(4);return t},G.readString=function(e){for(var t=``,n=++this.pos;;){this.pos>=this.input.length&&this.raise(this.start,`Unterminated string constant`);var r=this.input.charCodeAt(this.pos);if(r===e)break;r===92?(t+=this.input.slice(n,this.pos),t+=this.readEscapedChar(!1),n=this.pos):r===8232||r===8233?(this.options.ecmaVersion<10&&this.raise(this.start,`Unterminated string constant`),++this.pos,this.options.locations&&(this.curLine++,this.lineStart=this.pos)):(ei(r)&&this.raise(this.start,`Unterminated string constant`),++this.pos)}return t+=this.input.slice(n,this.pos++),this.finishToken(V.string,t)};var oo={};G.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(e){if(e===oo)this.readInvalidTemplateToken();else throw e}this.inTemplateElement=!1},G.invalidStringToken=function(e,t){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw oo;this.raise(e,t)},G.readTmplToken=function(){for(var e=``,t=this.pos;;){this.pos>=this.input.length&&this.raise(this.start,`Unterminated template`);var n=this.input.charCodeAt(this.pos);if(n===96||n===36&&this.input.charCodeAt(this.pos+1)===123)return this.pos===this.start&&(this.type===V.template||this.type===V.invalidTemplate)?n===36?(this.pos+=2,this.finishToken(V.dollarBraceL)):(++this.pos,this.finishToken(V.backQuote)):(e+=this.input.slice(t,this.pos),this.finishToken(V.template,e));if(n===92)e+=this.input.slice(t,this.pos),e+=this.readEscapedChar(!0),t=this.pos;else if(ei(n)){switch(e+=this.input.slice(t,this.pos),++this.pos,n){case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:e+=`\n`;break;default:e+=String.fromCharCode(n);break}this.options.locations&&(++this.curLine,this.lineStart=this.pos),t=this.pos}else ++this.pos}},G.readInvalidTemplateToken=function(){for(;this.pos<this.input.length;this.pos++)switch(this.input[this.pos]){case`\\\\`:++this.pos;break;case`$`:if(this.input[this.pos+1]!==`{`)break;case\"`\":return this.finishToken(V.invalidTemplate,this.input.slice(this.start,this.pos));case`\\r`:this.input[this.pos+1]===`\n`&&++this.pos;case`\n`:case`\\u2028`:case`\\u2029`:++this.curLine,this.lineStart=this.pos+1;break}this.raise(this.start,`Unterminated template`)},G.readEscapedChar=function(e){var t=this.input.charCodeAt(++this.pos);switch(++this.pos,t){case 110:return`\n`;case 114:return`\\r`;case 120:return String.fromCharCode(this.readHexChar(2));case 117:return di(this.readCodePoint());case 116:return`\t`;case 98:return`\\b`;case 118:return`\\v`;case 102:return`\\f`;case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:return this.options.locations&&(this.lineStart=this.pos,++this.curLine),``;case 56:case 57:if(this.strict&&this.invalidStringToken(this.pos-1,`Invalid escape sequence`),e){var n=this.pos-1;this.invalidStringToken(n,`Invalid escape sequence in template string`)}default:if(t>=48&&t<=55){var r=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],i=parseInt(r,8);return i>255&&(r=r.slice(0,-1),i=parseInt(r,8)),this.pos+=r.length-1,t=this.input.charCodeAt(this.pos),(r!==`0`||t===56||t===57)&&(this.strict||e)&&this.invalidStringToken(this.pos-1-r.length,e?`Octal literal in template string`:`Octal literal in strict mode`),String.fromCharCode(i)}return ei(t)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),``):String.fromCharCode(t)}},G.readHexChar=function(e){var t=this.pos,n=this.readInt(16,e);return n===null&&this.invalidStringToken(t,`Bad character escape sequence`),n},G.readWord1=function(){this.containsEsc=!1;for(var e=``,t=!0,n=this.pos,r=this.options.ecmaVersion>=6;this.pos<this.input.length;){var i=this.fullCharCodeAtPos();if(qr(i,r))this.pos+=i<=65535?1:2;else if(i===92){this.containsEsc=!0,e+=this.input.slice(n,this.pos);var a=this.pos;this.input.charCodeAt(++this.pos)!==117&&this.invalidStringToken(this.pos,`Expecting Unicode escape sequence \\\\uXXXX`),++this.pos;var o=this.readCodePoint();(t?Kr:qr)(o,r)||this.invalidStringToken(a,`Invalid Unicode escape`),e+=di(o),n=this.pos}else break;t=!1}return e+this.input.slice(n,this.pos)},G.readWord=function(){var e=this.readWord1(),t=V.name;return this.keywords.test(e)&&(t=Zr[e]),this.finishToken(t,e)},zi.acorn={Parser:zi,version:`8.19.0`,defaultOptions:gi,Position:pi,SourceLocation:mi,getLineInfo:hi,Node:la,TokenType:z,tokTypes:V,keywordTypes:Zr,TokContext:ea,tokContexts:ta,isIdentifierChar:qr,isIdentifierStart:Kr,Token:ro,isNewLine:ei,lineBreak:Qr,lineBreakG:$r,nonASCIIwhitespace:ni};var so={ecmaVersion:`latest`,sourceType:`script`,allowReturnOutsideFunction:!0},co=/\\w+(?![\\p{ID_Continue}$\\u200c\\u200d])/uy,lo=/[A-Za-z_]\\w*(?![\\p{ID_Continue}$\\u200c\\u200d])/uy,uo=/^[$_]\\w+$/,fo=/[\\n\\r\\u2028\\u2029]/,po=/\\s*(?:[;},:)]|=(?![=>]))/y;function mo(e,t){return po.lastIndex=t,po.test(e)}var ho=new Set([V.name,V.num,V.string,V.regexp,V.backQuote,V.bracketR,V.braceR,V.parenR,V.incDec,V._this,V._null,V._true,V._false]),go=class extends zi{constructor(...e){super(...e),this.operandBeforeLast=!0,this.operandHere=!0,this.breakBeforeLast=!1,this.breakHere=!1,this.ternaries=[],this.colonEndsTernary=!1,this.closedBlock=!1,this.typeBeforeLast=V.eof,this.lookahead=!0}readToken(e){let t=this;if(t.lastTokEnd=t.end,this.operandBeforeLast=this.operandHere,this.operandHere=t.exprAllowed,this.breakBeforeLast=this.breakHere,this.breakHere=fo.test(t.input.slice(t.end,t.pos)),e===64||e===37){let n=t.pos,r=e===64?co:lo;r.lastIndex=n+1;let i=r.exec(t.input)?.[0];if(i){let r=n+1+i.length,a=t.type===V.incDec&&(this.operandBeforeLast||this.breakBeforeLast),o=e===37?this.percentAt?.get(n):void 0;if(e===64||(o??(t.exprAllowed||a||this.lookahead&&_o(t,r)))){e===37&&this.transientsRead?.add(n),t.pos=r,t.finishToken(V.name,t.input.charAt(n)+i);return}}}super.readToken(e)}finishToken(e,t){let{context:n}=this,r=n.length;if(e===V.braceR){let e=n[r-1];this.closedBlock=e.token===`{`&&!e.isExpr}else if(e===V.question)this.ternaries[r]=(this.ternaries[r]??0)+1;else if(e===V.colon){let e=this.ternaries[r]??0;this.colonEndsTernary=e>0,e>0&&(this.ternaries[r]=e-1)}let i=this,a=i.type;this.prevValue=i.value;let o=e.keyword!==void 0&&(a===V.dot||a===V.questionDot)||(e===V._function||e===V._class)&&mo(i.input,i.pos);if(!o&&(e===V._function||e===V._class)){let t=e===V._function&&a===V.name&&this.prevValue===`async`&&!this.breakHere?this.typeBeforeLast:a;i.type=t===V.colon&&this.colonEndsTernary?V.parenL:t}this.typeBeforeLast=a,super.finishToken(o?V.name:e,t),e===V.name&&t===`of`&&(a===V._const||a===V._var||this.prevValue===`let`)&&(i.exprAllowed=!1)}braceIsBlock(e){if(e===V.colon&&this.colonEndsTernary)return!1;if(e===V.braceR&&this.closedBlock||e===V.name&&this.prevValue===`static`)return!0;if(this.breakHere&&ho.has(e)){let{context:e}=this,t=e[e.length-1];if(t.token===`{`&&!t.isExpr)return!0}return super.braceIsBlock(e)}};function _o(e,t){if(!fo.test(e.input.slice(e.end,e.pos)))return!1;let n=bo(e.input,t,`statements`,{afterOperand:!0});n.lookahead=!1;let r=0;try{for(;;){n.nextToken();let e=n.type;if(e===V.eof)return!1;if(r>0)vo.has(e)?r++:yo.has(e)&&r--;else if(e===V.bracketL)r=1;else if(e===V.dot){if(n.nextToken(),n.type!==V.name&&!n.type.keyword)return!1}else return e===V.eq||e===V.assign}}catch{return!1}}var vo=new Set([V.parenL,V.bracketL,V.braceL,V.dollarBraceL]),yo=new Set([V.parenR,V.bracketR,V.braceR]);function bo(e,t,n,{onComment:r,afterOperand:i=!1}={}){let a=new go(r?{...so,onComment:r}:so,e,t);return n===`expression`&&(a.type=V.parenL),i&&(a.exprAllowed=!1),a}var xo=class extends SyntaxError{constructor(e,t,n,r){super(`${e} ${wo(t,n)}`+So(r,e=>Co(t,e))),this.reason=e,this.source=t,this.pos=n,this.bracket=r,this.name=`SyntaxError`}reasonIn(e,t){return this.reason+So(this.bracket,n=>{let{line:r,column:i}=hi(e,t+n);return`at line ${r}, column ${i+1}`})}};function So(e,t){return e?` (missing \"${e.closer}\" for the \"${e.open}\" ${t(e.pos)})`:``}function Co(e,t){let{line:n,column:r}=hi(e,t);return fo.test(e)?`at line ${n}, column ${r+1}`:`at column ${r+1}`}function wo(e,t){let{column:n}=hi(e,t),r=t-n,i=e.slice(r).search(fo),a=i<0?e.length:r+i,o=Math.max(r,t-30),s=Math.min(a,t+30),c=(o>r?`…`:``)+e.slice(o,t)+`▶`+e.slice(t,s)+(s<a?`…`:``);return`${Co(e,t)}: ${c.trim()}`}var To=e=>e[e.length-1],Eo={\"(\":`)`,\"[\":`]`,\"{\":`}`,\"${\":`}`};function Do(e,t){if(!(t instanceof SyntaxError)||!(`pos`in t))throw t;let n=t.pos,r=t.message.replace(/ \\(\\d+:\\d+\\)$/,``),{open:i,token:a}=Oo(e,n),o=n>=e.length||a===``,s=!1;r===`Unexpected token`?(r=o?`Unexpected end of code`:`Unexpected \"${a}\"`,s=!!i&&Eo[i.text]!==a&&(o||[`)`,`]`,`}`,`;`,`{`].includes(a))):r.startsWith(`Unterminated template`)&&(s=i?.text===\"${\");let c=s&&i?{open:i.text,closer:Eo[i.text],pos:i.pos}:void 0;return new xo(r,e,n,c)}function Oo(e,t){let n=[];for(let r of Ho(e,0,`statements`)){if(`error`in r)break;if(r.start>=t||r.type===V.eof)return{open:To(n),token:e.slice(r.start,r.end)};let i=e.slice(r.start,r.end);i in Eo?n.push({text:i,pos:r.start}):n.length&&Eo[To(n).text]===i&&n.pop()}return{open:To(n),token:e.charAt(t)}}function ko(e,t=`expression`){let n=new Map;for(;;){let r=new Set;try{let i=Ao(e,t,n,r),a={refs:[],strings:[]};return Fo(i,e,a,!1,!1),a.refs.sort((e,t)=>e.start-t.start),a}catch(t){let i=t.pos??-1;if(!(t instanceof SyntaxError)||n.has(i)||(lo.lastIndex=i+1,e.charAt(i)!==`%`||!lo.test(e)))throw t;n.set(i,!r.has(i))}}}function Ao(e,t,n,r){try{let i=bo(e,0,t);if(i.percentAt=n,i.transientsRead=r,t===`statements`)return i.parse();i.nextToken();let a=i.parseExpression();if(i.type!==V.eof)throw Object.assign(SyntaxError(`Unexpected token`),{pos:i.start});return a}catch(t){throw Do(e,t)}}var jo=e=>typeof e==`object`&&!!e&&typeof e.type==`string`,Mo={$:`story`,_:`temporary`,\"@\":`local`,\"%\":`transient`};function No(e,t){let n=e.name,r=t.charAt(e.start);return r===n.charAt(0)&&(r===`@`||r===`%`||(r===`$`||r===`_`)&&uo.test(n))?[r,n.slice(1)]:null}function Po(e,t){if(!jo(e)||e.type!==`Identifier`)return;let n=t.charAt(e.start);if(n===`@`||n===`%`)throw new xo(`\"${e.name}\" can't be a property name`,t,e.start)}function Fo(e,t,n,r,i){if(Array.isArray(e)){for(let i of e)Fo(i,t,n,r,!1);return}if(!jo(e))return;let a=(e,r=!1,i=!1)=>Fo(e,t,n,r,i);switch(e.type){case`Identifier`:{let a=No(e,t);if(!a)return;if(r)throw new xo(`\"${e.name}\" is a ${Mo[a[0]]} variable and can't be declared`,t,e.start);n.refs.push({sigil:a[0],name:a[1],start:e.start,end:e.end,shorthand:i});return}case`Literal`:typeof e.value==`string`&&n.strings.push(t.slice(e.start+1,e.end-1));return;case`TemplateElement`:n.strings.push(e.value.raw);return;case`MemberExpression`:a(e.object),e.computed?a(e.property):Po(e.property,t);return;case`Property`:if(e.computed?a(e.key):e.shorthand||Po(e.key,t),e.shorthand){let t=e.value;t.type===`AssignmentPattern`?(a(t.left,r,!0),a(t.right)):a(t,r,!0)}else a(e.value,r);return;case`MethodDefinition`:case`PropertyDefinition`:e.computed?a(e.key):Po(e.key,t),a(e.value);return;case`LabeledStatement`:a(e.body);return;case`BreakStatement`:case`ContinueStatement`:case`MetaProperty`:case`PrivateIdentifier`:return;case`VariableDeclarator`:a(e.id,!0),a(e.init);return;case`FunctionDeclaration`:case`FunctionExpression`:case`ArrowFunctionExpression`:a(e.id,!0);for(let t of e.params)a(t,!0);a(e.body);return;case`ClassDeclaration`:case`ClassExpression`:a(e.id,!0),a(e.superClass),a(e.body);return;case`CatchClause`:a(e.param,!0),a(e.body);return;case`AssignmentPattern`:a(e.left,r),a(e.right);return;case`ObjectPattern`:case`ArrayPattern`:case`RestElement`:for(let t of[`properties`,`elements`,`argument`])a(e[t],r);return;default:for(let t in e){if(t===`type`||t===`start`||t===`end`)continue;let n=e[t];typeof n==`object`&&n&&a(n)}}}var Io=/[\\p{ID_Continue}$.]*/uy,Lo=/[\\p{ID_Continue}$]*/uy,Ro=new Set([`of`,`get`,`set`,`static`,`async`]);function zo(e,t,{goal:n=`expression`,stop:r}={}){let i=Vo(e,t,n,r);return i<0&&!r?Bo(e,t,n):i}function Bo(e,t,n){let r=bo(e,t,n);try{if(n===`statements`)r.parse();else if(r.nextToken(),r.parseExpression(),r.type===V.braceR)return r.start}catch(t){let n=t.pos??-1;if(e.charAt(n)===`}`)return n}return-1}function Vo(e,t,n,r){let i=[],a=-1,o=!1,s=t,c=!1,l=!1;for(;;){let t=-1;for(let u of Ho(e,s,n,{afterOperand:c})){if(`error`in u){let{message:n}=u.error,a=i.includes(\"${\");if(!/^Unterminated/.test(n)&&!a){if(t=Math.max(u.pos,s)+1,c=!1,t>=e.length)return-1;break}let o=i.lastIndexOf(\"${\");if(!/^Unterminated template/.test(n)||o<0||l||r)return-1;l=!0,i.length=o,t=u.pos,c=!0;break}if(u.restarted&&i.includes(\"${\"))return-1;let n=u.type;if(n===V.eof||n===V.string&&o&&u.start===a)return-1;if(o=n===V.name&&!Ro.has(u.value)||n===V.num,a=u.end,n===V.braceL){if(r?.(u.start))return u.start;i.push(`{`)}else if(n===V.dollarBraceL)i.push(\"${\");else if(n===V.parenL)i.push(`(`);else if(n===V.bracketL)i.push(`[`);else if(n===V.parenR||n===V.bracketR)To(i)===(n===V.parenR?`(`:`[`)&&i.pop();else if(n===V.braceR){let e=Math.max(i.lastIndexOf(`{`),i.lastIndexOf(\"${\"));if(e>=0)i.length=e;else if(!r)return u.start}}s=t,o=!1}}function*Ho(e,t,n,r={}){let i=bo(e,t,n,r);for(;;){try{i.nextToken()}catch(t){let n=Math.min(t.pos??i.pos,e.length),a=t.message,o=(t,n,a)=>(i=bo(e,a,`statements`,{onComment:r.onComment,afterOperand:!0}),{type:t,start:n,end:a,value:void 0,restarted:!0}),s=e.charAt(i.start),c=/^Unterminated/.test(a);if(/^Unterminated string/.test(a)){let{end:t,closed:r}=Yo(e,n);if(r){yield o(V.string,n,t);continue}}else if(!c&&i.start<=n&&(s===`\"`||s===`'`)){let{end:t,closed:n}=Yo(e,i.start);if(n){yield o(V.string,i.start,t);continue}}else if(!c&&i.start<=n&&s===`/`){let t=qo(e,i.start);if(t>0){yield o(V.regexp,i.start,t);continue}}else if(!c&&i.start<=n&&/[\\d.]/.test(s)&&/\\d/.test(e.slice(i.start,i.start+2))){Io.lastIndex=i.start,Io.test(e),yield o(V.num,i.start,Io.lastIndex);continue}yield{error:t,pos:n};return}if(yield{type:i.type,start:i.start,end:i.end,value:i.value},i.type===V.eof)return}}function Uo(e,t,n=`expression`){return Wo(e,0,t,0,n,!1)}function Wo(e,t,n,r,i,a){let o=[],s=(e,t,n,r)=>{o.push([n,r])},c=(t,i)=>{for(let a=t;a<i;a++)n.code?.(e.charAt(a),a,r)},l=(t,i)=>{i>t&&n.literal?.(e.slice(t,i),t,r)},u=(e,t)=>{for(let[n,r]of o)r<=e||n>=t||(c(e,n),l(n,r),e=r);o.length=0,c(e,t)},d=[],f=0,p=Ho(e,t,i,{onComment:s}),m=t,h;for(;;){let t=p.next().value;if(`error`in t){let n=Math.max(m,t.pos);if(u(m,n),n>=e.length)return e.length;if(/^Unterminated/.test(t.error.message))return l(n,e.length),e.length;c(n,n+1),m=n+1,p=Ho(e,m,i,{onComment:s}),h=void 0;continue}let o=t.type;if(o===V.eof)return u(m,e.length),e.length;if(u(m,t.start),o===V.name){let i=Go(e,t.start,t.value),a=h===V.dot||h===V.questionDot||(i===`$`||i===`_`)&&Ko(e,t.end,h);i&&!a?n.variable?.(i,e.slice(t.start+1,t.end),t.start,r):c(t.start,t.end)}else if(o===V.string||o===V.regexp||o===V.template||o===V.invalidTemplate)l(t.start,t.end);else if(o===V.backQuote)if(l(t.start,t.end),h===V.template||h===V.invalidTemplate){if(f--,a&&f===0)return t.end}else f++;else o===V.dollarBraceL?(l(t.start,t.end),d.push(\"${\"),r++):o===V.braceR&&To(d)===\"${\"?(d.pop(),r--,l(t.start,t.end)):(o===V.braceL||o===V.parenL||o===V.bracketL?d.push(e.charAt(t.start)):(o===V.braceR||o===V.parenR||o===V.bracketR)&&d.length&&To(d)!==\"${\"&&d.pop(),c(t.start,t.end));h=o,m=t.end}}function Go(e,t,n){let r=e.charAt(t);return(r===`@`||r===`%`)&&n.charAt(0)===r||(r===`$`||r===`_`)&&uo.test(n)?r:null}function Ko(e,t,n){if(n!==V.braceL&&n!==V.comma)return!1;let r=/\\S/g;r.lastIndex=t;let i=r.exec(e)?.[0];return i===`:`||i===`(`}function qo(e,t){let n=!1;for(let r=t+1;r<e.length;r++){let t=e.charAt(r);if(fo.test(t))return-1;if(t===`\\\\`)r++;else if(t===`[`)n=!0;else if(t===`]`)n=!1;else if(t===`/`&&!n)return Lo.lastIndex=r+1,Lo.test(e),Lo.lastIndex}return-1}function Jo(e){if(e[0]!==`\"`&&e[0]!==`'`)return null;try{let t=bo(e,0,`expression`);return t.nextToken(),t.type===V.string&&t.end===e.length?t.value:null}catch{return null}}function Yo(e,t){let n=e.charAt(t),r=t+1;for(;r<e.length;){let t=e.charAt(r);if(t===`\\\\`)r+=2;else if(t===n)return{end:r+1,closed:!0};else r++}return{end:e.length,closed:!1}}var Xo=/[\\p{L}\\p{N}_\\\\]/u;function Zo(e,t){let n=e[t],r=n===\"`\";for(let i=t+1;i<e.length;){let t=e[i];if(t===`\\\\`)i+=2;else if(t===n)return i+1;else if(!r&&t===`\n`)return-1;else if(r&&t===`$`&&e[i+1]===`{`){let t=Qo(e,i+2);if(t===-1)return-1;i=t+1}else i++}return-1}function Qo(e,t){$o!==e&&($o=e,es.clear());let n=es.get(t);return n===void 0&&(n=ts(e,t),es.set(t,n)),n}var $o=``,es=new Map;function ts(e,t){let n=0;for(;t<e.length;){let r=e[t];if(r===`{`)n++,t++;else if(r===`}`){if(n===0)return t;n--,t++}else if(r===\"`\"||(r===`\"`||r===`'`)&&!(t>0&&Xo.test(e[t-1]))){let n=Zo(e,t);t=n===-1?t+1:n}else t++}return-1}var ns={closeBrace(e,t,n){let r=zo(e,t);return r===-1?Qo(e,n):r},rawBodyEnd(e,t,n){let r=`\\\\{/${n}\\\\s*\\\\}`,i=new RegExp(r,`gi`);i.lastIndex=t;let a=i.exec(e)?.index??-1;if(a===-1)return-1;let o=new RegExp(r,`iy`),s=zo(e,t,{goal:`statements`,stop:t=>(o.lastIndex=t,o.test(e))});return s===-1?a:s}};function rs(e){let t=e.toLowerCase();return t.startsWith(`on`)||t===`pattern`||t===`srcdoc`}function is(e){let t=[],n=``,r=0;for(;r<e.length;){let i=e.indexOf(`{`,r);if(i===-1){n+=e.slice(r);break}n+=e.slice(r,i),r=i+1;let a=Kn(e[r])?ns.closeBrace(e,r,r):-1;if(a===-1){n+=`{`;continue}n&&t.push({text:n}),n=``;let o=e.slice(r,a);t.push(/^.\\w/.test(o)?{expr:o}:{verbatim:`{${o}}`}),r=a+1}return n&&t.push({text:n}),t}var as={...ns,isBlock:_r,isRaw:gr,isCodeAttribute:rs},os=class extends Error{constructor(e,t,n,r,i=`syntax`,a=t,o={}){super(`${e} (line ${n}, column ${r})`),this.reason=e,this.offset=t,this.line=n,this.column=r,this.code=i,this.end=a,this.data=o,this.name=`MarkupError`}};function ss(e,t,n){let r=n.hooks?{...as,...n.hooks}:as;try{return dr(e,{startRule:t,text:n.text===!0,hooks:r})}catch(t){let{location:n,code:r}=t;if(t instanceof Error&&t.name===`SyntaxError`&&n){let{offset:i}=n.start,{line:a,column:o}=Cr(e,i);throw new os(t.message,i,a,o,r,n.end.offset)}throw t}}function cs(e,t={}){let{tokens:n,errors:r,damage:i}=ps(e,t),a={...as,...t.hooks},o=Mr(n,{isBlock:a.isBlock,isRaw:a.isRaw,source:e});if(r.length===0&&o.errors.length===0)return{tokens:n,nodes:o.nodes,errors:r};let s=e=>r.some((t,n)=>e>=i[n]&&e<=t.offset),c=r.map((e,t)=>[i[t]+.5,e]);for(let t of o.errors)s(t.start)||c.push([t.noticedAt,us(e,t)]);return c.sort((e,t)=>e[0]-t[0]),{tokens:n,nodes:o.nodes,errors:c.map(([,e])=>e)}}function ls(e,t={}){let{nodes:n,errors:r}=cs(e,t);if(r.length>0)throw r[0];return xr(n)}function us(e,t){let{line:n,column:r}=Cr(e,t.start);return new os(t.message,t.start,n,r,t.code,t.end,t.data)}function ds(e,t={}){return ss(e,`Tokens`,t)}function fs(e,t={}){let{tokens:n,errors:r}=ps(e,t);return{tokens:n,errors:r}}function ps(e,t){let n=[],r=[],i=[],a=e.lastIndexOf(`}`),{closeBrace:o}={...as,...t.hooks},s=(e,n)=>{let r={...t.hooks,closeBrace:(e,t,r)=>n+Math.min(t,r)>a?-1:o(e,t,r)};try{return ds(e,{...t,hooks:r}).map(e=>gs(e,n))}catch(e){if(!(e instanceof os))throw e;return e}},c=0;for(;c<=e.length;){let t=e.slice(c),a=s(t,c);if(Array.isArray(a)){n.push(...a);break}let o=c+a.offset,{line:l,column:u}=Cr(e,o);r.push(new os(a.reason,o,l,u,a.code,c+a.end));let d=a.offset,f=s(t.slice(0,d),c);for(;!Array.isArray(f);)d=f.offset,f=s(t.slice(0,d),c);if(n.push(...f),i.push(c+d),d<t.length){let e=c+d;n.push({type:`text`,value:t[d],start:e,end:e+1})}c+=d+1}return{tokens:n,errors:r,damage:i}}var ms=/^(start|end|[A-Za-z]*(Start|End))$/;function hs(e,t){let n={...e};for(let[e,r]of Object.entries(n))typeof r==`number`&&ms.test(e)?n[e]=t(r):e===`attributeSpans`&&(n[e]=r.map(e=>hs(e,t)));return n}function gs(e,t){return t===0?e:hs(e,e=>e+t)}var _s=`__proto__`;function vs(e,t=e){return e===`__proto__`?`\"${t}\" cannot be used as a variable name (${_s} is reserved)`:void 0}function ys(e,t=e){let n=vs(e,t);if(n)throw TypeError(`spindle: ${n}`)}var K=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),bs=(e,t)=>e&&K(e,t)?e[t]:void 0;function xs(e,t,n){t===`__proto__`?Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0,configurable:!0}):e[t]=n}function Ss(e,t=()=>!0){let n=Object.create(null);for(let r of e)if(r)for(let e of Object.keys(r)){let i=r[e];t(i)&&(n[e]=i)}return n}var q=(...e)=>Ss(e),Cs=e=>Object.getPrototypeOf(e)===null,ws=e=>Cs(e)?e:q(e);function Ts(e,t,n){let r=q(e);return r[t]=n,r}var Es=Object.freeze(q());function Ds(e,t){return[...new Set([...Object.keys(e),...Object.keys(t)])].filter(n=>bs(e,n)!==bs(t,n))}var Os=e=>typeof e==`number`&&Number.isInteger(e)&&e>=0;function ks(e,t){let n=bs(e,t);return Os(n)?n:0}function As(e,t){let n=Ss([e],Os);return t!==void 0&&(n[t]=ks(e,t)+1),n}var js=new fr;function Ms(e,t,n,r=!1){let i=n.filter(e=>e!==`@children`);for(let e of i)e.startsWith(`@`)&&ys(e.slice(1),e);js.set(e,{body:t,params:i,isBlock:r})}function Ns(e){return js.get(e)}function Ps(e){let t=e.trim();return t.endsWith(`ms`)?parseFloat(t.slice(0,-2)):t.endsWith(`s`)?parseFloat(t.slice(0,-1))*1e3:parseFloat(t)}function Fs(e,t){return e instanceof Error?e.message||t||String(e):typeof e==`string`&&e!==``?e:t??String(e)}function Is(){let e=new Set;return{subscribe(t){return e.add(t),()=>{e.delete(t)}},notify(){for(let t of[...e])t()}}}var Ls=[],Rs=1,zs=Is();function Bs(e){Ls=e,zs.notify()}function Vs(e,t){let n=Fs(t).replace(/^spindle: /,``),r=Ls.find(t=>t.context===e&&t.message===n);Bs(r?Ls.map(e=>e===r?{...e,count:e.count+1}:e):[...Ls,{id:Rs++,context:e,message:n,count:1}])}function Hs(e,t){return Error(`No passage named ${JSON.stringify(e)} (in passage ${JSON.stringify(t)})`)}function Us(e){Bs(Ls.filter(t=>t.id!==e))}function Ws(){return Ls}var Gs=zs.subscribe;function Ks(e){return/\\s/.test(e)}function qs(e){return e===`(`||e===`[`||e===`{`}function Js(e){return e===`)`||e===`]`||e===`}`}function Ys(e){return e.replace(/\\\\([\"'\\\\])/g,`$1`)}function Xs(e,t){let n=e[t];if(n!==`\"`&&n!==`'`)return null;let{end:r,closed:i}=Yo(e,t);return i?{value:Ys(e.slice(t+1,r-1)),end:r}:null}function Zs(e){let t=Xs(e,0);return t&&t.end===e.length?t.value:null}function Qs(e){return/^[\"']?(.+?)[\"']?$/s.exec(e)?.[1]??e}var $s=/(?:[-+*/%&|^!~=<>?:,.]|(?:^|[^\\w$@.])(?:typeof|void|new|delete|in|instanceof|await|yield))$/;function ec(e){let t=-1;if(Uo(e,{code(e,n,r){r===0&&!Ks(e)&&(t=n+1)},literal(e,n,r){let i=e.startsWith(`//`)||e.startsWith(`/*`);r===0&&!i&&(t=-1)},variable(e,n,r,i){i===0&&(t=-1)}}),t<0)return!1;let n=e.slice(0,t);return/(?:\\+\\+|--)$/.test(n)?!1:$s.test(n)}function tc(e,t){let n=[],r=0;return Uo(e,{code(e,i,a){a>0||(qs(e)?r++:Js(e)?r--:r===0&&t(e)&&n.push(i))}}),n}function nc(e,t){let n=[],r=0;for(let i of tc(e,t))n.push(e.slice(r,i)),r=i+1;return n.push(e.slice(r)),n}function rc(e){return ic(e)&&!ec(e)}function ic(e){let t=e[0];return!!(t===`\"`||t===`'`||t===\"`\"||/^[$_@]\\w|^%[A-Za-z_]/.test(e)||/\\d/.test(t)||(t===`-`||t===`+`)&&e.length>1&&/\\d/.test(e[1])||t===`(`||t===`[`||t===`{`||/^(?:true|false|null|undefined)(?![\\w$])/.test(e)||t===`!`&&e.length>1&&e[1]!==`=`)}function ac(e){let t=nc(e,Ks).filter(Boolean);if(t.length<2)return null;for(let e of t)if(!rc(e))return null;return t}function oc(e){let t=nc(e,e=>e===`,`).map(e=>e.trim()),n=t.length>1;if(t[t.length-1]===``&&t.pop(),!n&&t.length===1){let e=ac(t[0]);if(e)return e}return t}function sc(e){let t=[],n=0;for(let r of[...tc(e,Ks),e.length])r>n&&t.push([n,r]),n=r+1;return t}var cc=(e,[t,n])=>e.slice(t,n);function lc(e){return Zs(e)??Qs(e)}var uc=class extends Error{constructor(e,t){super(`The ${e.name} must be a quoted string (\"…\" or '…'), ${t?`not ${t}`:`but it has no value`}`),this.name=`MacroArgumentError`}};function dc(e,t,n){switch(n.spans?.set(e,[n.at,n.at+t.length]),e.type){case`string`:{let n=Zs(t);if(n===null)throw new uc(e,t);return n}case`text`:return lc(t);case`names`:return t.split(`,`).map(e=>e.trim());case`delay`:return Ps(t);case`number`:return Number(t);case`options`:return _c(e.parameters??[],t,n);default:return t}}function fc(e){return e.type===`flag`||e.type===`separator`?!1:e.type===`options`?{}:void 0}var pc=/\\w+/y,mc=/[-+]?(?:\\d+\\.?\\d*|\\.\\d+)/y,hc=/\\S+/y;function gc(e,t,n){return e.lastIndex=n,e.exec(t)?.[0]??null}function _c(e,t,{at:n,spans:r}){let i={},a=0;for(;a<t.length;){let o=gc(pc,t,a);if(!o){a=Xs(t,a)?.end??a+1;continue}a+=o.length;let s,c=a;for(;c<t.length&&Ks(t[c]);)c++;let l=Xs(t,c),u=l||c===a?null:gc(mc,t,c);l?(s=l.value,a=l.end):u&&(s=u,a=c+u.length);let d=e.find(e=>e.name===o);if(d&&d.type!==`flag`&&s!==void 0&&r?.set(d,[n+c,n+a]),d?.type===`string`&&!l)throw new uc(d,gc(hc,t,c)??``);d?.type===`flag`?i[o]=!0:d?.type===`number`?i[o]=Number(s??0):d&&(i[o]=s)}return i}var vc=/^(?:[-+*/&|^=<>?:,.]|%(?![A-Za-z_]))/;function yc(e,t){let n=sc(e);if(n.length<2)return null;if(cc(e,n[n.length-1])===t){let t=[0,n[n.length-2][1]];if(!ec(cc(e,t)))return t}if(cc(e,n[0])===t){let t=[n[1][0],e.length];if(!vc.test(cc(e,t)))return t}return null}function bc(e,t){if(t===`=`){let t=tc(e,e=>e===`=`);for(let n=0;n<t.length;n++){let r=t[n];if(e[r+1]===`=`){n++;continue}if(e[r-1]!==`!`)return[r,r+1]}return null}let n=sc(e);for(let r=1;r<n.length-1;r++)if(cc(e,n[r])===t)return[n[r-1][1],n[r+1][0]];return null}var xc=e=>e.type===`expression`||e.type===`statements`||e.type===`passage`||e.type===`text`;function Sc(e,t){let n=e.trim();return[n,n?t+e.indexOf(n):t]}function Cc(e,t,n,{at:r,spans:i}){let[a,o]=Sc(t??``,r);for(let r of e.filter(e=>e.type===`flag`)){let e=t===null?null:yc(a,r.name);n[r.name]=e!==null,e&&([a,o]=Sc(cc(a,e),o+e[0]))}let s=e.filter(e=>e.type!==`flag`);if(s.length===0)return;let c=s.findIndex((e,t)=>xc(e)&&!s.slice(t+1).some(xc)),l=c<0?s.length-1:c,u=(e,[t,n])=>t===n?fc(e):dc(e,a.slice(t,n),{at:o+t,spans:i});if(s.length===1){n[s[0].name]=u(s[0],[0,a.length]);return}let d=sc(a),f=0,p=d.length;for(let e of s.slice(0,l))n[e.name]=f<p?u(e,d[f++]):fc(e);let m=(e,t)=>{try{return u(e,t)}catch(e){if(e instanceof uc)return;throw e}};for(let e of s.slice(l+1).reverse()){let t=f<p&&!ec(a.slice(0,d[p-1][0]))?m(e,d[p-1]):void 0;n[e.name]=t??fc(e),t===void 0?i?.delete(e):p--}let h=s[l];n[h.name]=f<p?u(h,[d[f][0],d[p-1][1]]):fc(h)}var wc={name:`delay`,type:`delay`,required:!0};function Tc(e,t,n){let r={},[i,a]=Sc(e,0),o=0;return t.forEach((e,s)=>{if(e.type!==`separator`)return;let c=i===null?null:bc(i,e.name);r[e.name]=c!==null;let l=c?i.slice(0,c[0]):i;Cc(t.slice(o,s),l,r,{at:a,spans:n}),i=c?i.slice(c[1]):null,c&&(a+=c[1]),o=s+1}),Cc(t.slice(o),i,r,{at:a,spans:n}),r}function Ec(e){let t=e.trim(),n=Jo(t);return n===null?{kind:`expression`,expression:t}:{kind:`name`,name:n}}function Dc(e,t,{storyData:n,currentPassage:r}){let i=String(t(e??``));if(n&&!n.passages.has(i))throw Hs(i,r);return i}function Oc(e){let t=e.trim(),n=sc(t)[0];return n?cc(t,n):``}function kc(e){let{variable:t=``,placeholder:n=``}=Tc(e,[{name:`variable`,type:`variable`},{name:`placeholder`,type:`string`}]);return{varName:t.replace(/[\"']/g,``),placeholder:n}}var Ac=[{name:`value`,type:`string`,holds:`text`,required:!0}],jc=new Map([[`option`,Ac]]);function Mc(e){return jc.get(e.toLowerCase())}function Nc(e){let t=[];for(let n of e)if(n.type===`macro`&&n.name===`option`){let{value:e}=Tc(n.rawArgs,Ac);t.push(e??``)}return t}var Pc=null;function Fc(e){let t=Pc;Pc=new Map;try{return e()}finally{Pc=t}}function Ic(e,t){let n=t[0]+e,r=Pc?.get(n);if(r)return r;try{r=ko(e,t)}catch(e){if(!(e instanceof xo))throw e;r=e}return Pc?.set(n,r),r}function Lc(e,t){return e.sourceOffsets?.[t]??e.offset+t}function Rc(e){return e.kind===`code`?e.code.length:e.kind===`text`?e.text.length:e.length}var zc=new Set([`if`,`elseif`,`case`]),Bc=new Set([`dialog`]);function Vc(e,t){return e.map(e=>e.parameters?{...e,parameters:Vc(e.parameters,t)}:(e.type===`string`||e.type===`text`)&&!e.holds?{...e,holds:t}:e)}function Hc(e){let t=new fr;for(let{name:n,parameters:r,interpolate:i}of e)r&&t.set(n,Vc(r,Uc(i)));return e=>{let n=t.get(e);if(!n){let r=Mc(e);r&&t.set(e,n=Vc(r,`text`))}return n}}var Uc=e=>e?`markup`:`text`;function Wc(e){if(e.type===`expression`||e.type===`passage`)return`expression`;if(e.type===`statements`)return`statements`}function Gc(e){if(!(e.type!==`string`&&e.type!==`text`))return e.holds??`markup`}function*Kc(e,t,n){let r=(e,n)=>t.findIndex((t,r)=>r>e&&t.type===`macro`&&t.isClose&&t.name.toLowerCase()===n);for(let i=0;i<t.length;i++){let a=t[i];if(a.type===`link`)yield{kind:`passage`,name:a.target,offset:a.targetStart,length:a.targetEnd-a.targetStart,macro:`link`,label:e.slice(a.start,a.end)},a.display.includes(`{`)&&(yield Qc(a.display,a.displayStart,`In the label of a link: `));else if(a.type===`expression`)yield{kind:`code`,code:a.expression,offset:a.expressionStart,goal:`expression`,label:`{${a.expression}}`};else if(a.type===`html`)for(let{name:t,value:n,at:r}of $c(e,a)){if(!rs(t)){yield Qc(n,r,`In the ${t} attribute of <${a.tag}>: `);continue}let e=0;for(let i of is(n)){if(!(`expr`in i))continue;let o=el(n,i.expr,e);e=o+i.expr.length,yield{kind:`code`,code:i.expr,offset:r+o,goal:`expression`,label:`{${i.expr}} in the ${t} attribute of <${a.tag}>`}}}else if(a.type===`macro`&&!a.isClose){let o=a.name.toLowerCase();if(o===`do`){let n=r(i,o);if(n<0)continue;yield{kind:`code`,code:e.slice(a.end,t[n].start),offset:a.end,goal:`statements`,label:`{do}`},i=n;continue}let s=a.rawArgs;if(Bc.has(o)){let n=r(i,o),s=t.slice(i+1,n);if(n>i+1&&s.every(e=>e.type===`text`)){let r=e.slice(a.end,t[n].start),i=r.trim();yield{kind:`passage`,name:i.replace(/^[\"']|[\"']$/g,``),offset:a.end+r.indexOf(i),length:i.length,macro:o,label:e.slice(a.start,a.end)}}}if(!s)continue;let c=`{${a.name} ${s}}`,l=a.argsStart;if(zc.has(o)){yield{kind:`code`,code:s,offset:l,goal:`expression`,label:c};continue}let u=n(o);u&&(yield*Zc(s,l,u,a.name,c))}}}function*qc(e,t,n,r={}){yield*Jc(e,e,t,n,r,e=>e,void 0)}function*Jc(e,t,n,r,i,a,o){for(let s of Kc(t,n,r)){let t=o?Yc(s,a,o):s;if(s.kind!==`text`||!s.text.includes(`{`)){yield t;continue}let n=e=>a(Lc(s,e)),c=cs(s.text,{text:!0,hooks:i.isBlock&&{isBlock:i.isBlock}});yield{...t,tokens:c.tokens.map(e=>hs(e,n)),errors:c.errors.map(t=>{let{line:r,column:i}=Cr(e,n(t.offset));return new os(t.reason,n(t.offset),r,i,t.code,n(t.end),t.data)})},yield*Jc(e,s.text,c.tokens,r,i,n,s.where)}}function Yc(e,t,n){let r=t(e.offset),i={offset:r,nested:!0,where:n};if(e.kind===`passage`||e.kind===`argument-error`){let n=t(e.offset+e.length)-r;return{...e,...i,length:n}}let a=Rc(e),o=e.sourceOffsets?e.sourceOffsets.map(t):t(e.offset+a)-r===a?void 0:Array.from({length:a+1},(n,r)=>t(e.offset+r));return o?{...e,...i,sourceOffsets:o}:{...e,...i}}function Xc(e,t,n){let r=[],i=!1,a=0;for(;r.length<n.length;){if(a>=e.length)return;r.push(t+a),e[a]===`\\\\`&&/[\"'\\\\]/.test(e.charAt(a+1))?(i=!0,a+=2):a++}return r.push(t+a),i?r:void 0}function*Zc(e,t,n,r,i){let a=r.toLowerCase(),o,s=new Map;try{o=Tc(e,n,s)}catch(n){if(!(n instanceof uc))throw n;yield{kind:`argument-error`,message:n.message,offset:t,length:e.length,label:i,macro:a};return}function*c(n,o){for(let l of n){let n=o[l.name];if(l.type===`options`&&l.parameters){yield*c(l.parameters,n??{});continue}let u=s.get(l);if(typeof n!=`string`||!n.trim()||!u)continue;let[d,f]=u,p=e.slice(d,f),m=e=>({kind:`passage`,name:e,offset:t+d,length:f-d,macro:a,label:i}),h=Wc(l);if(l.type===`passage`){let e=Ec(n);if(e.kind===`name`){yield m(e.name);continue}}if(h){let e={kind:`code`,code:n,offset:t+d,goal:h,label:i};l.type===`passage`&&(e.passage=!0,e.macro=a),yield e;continue}let g=t+d+(n!==p&&/^[\"']/.test(p)?1:0),_=Gc(l),v=Xc(e.slice(g-t),g,n);if(_===`expression`||_===`statements`){let e={kind:`code`,code:n,offset:g,goal:_,label:i,inString:!0};v&&(e.sourceOffsets=v),yield e}else if(_===`passage`)yield m(n);else if(_===`markup`){let e=Qc(n,g,`In the ${l.name} of {${r}}: `);v&&(e.sourceOffsets=v),yield e}}}yield*[...c(n,o)].sort((e,t)=>e.offset-t.offset)}var Qc=(e,t,n)=>({kind:`text`,text:e,offset:t,where:n,tokens:[],errors:[]});function $c(e,t){if(t.attributeSpans.length===0){let n=t.start;return Object.entries(t.attributes).map(([t,r])=>{let i=el(e,r,n);return n=i+r.length,{name:t,value:r,at:i}})}let n=new Set,r=[];for(let i of t.attributeSpans){let t=i.name.toLowerCase();n.has(t)||(n.add(t),i.valueStart!==void 0&&r.push({name:i.name,value:e.slice(i.valueStart,i.valueEnd),at:i.valueStart}))}return r}function el(e,t,n){let r=e.indexOf(t,n);if(r>=0)return r;let i=e.indexOf(t);return i>=0?i:n}var tl=new fr;function nl(e,t){tl.set(e,t)}function rl(e){return tl.get(e)}var il=new fr;function al(e,t){t?il.set(e,t):il.delete(e)}function ol(e){return il.get(e)}var sl=new pr;function cl(e){sl.add(e)}function ll(e){return sl.has(e)}var ul=[`expression`,`statements`,`passage`,`variable`,`string`,`text`,`names`,`delay`,`number`,`flag`,`separator`,`options`],dl=[`markup`,`text`,`passage`,`expression`,`statements`];function fl(e,t){let n=`Give a \\`string\\` or \\`text\\` parameter one of ${dl.join(`, `)} to hold (see docs/custom-macros.md#what-a-string-holds).`;for(let r of t){let t=r.type;if(!ul.includes(t))throw pl(e,r,t===void 0?`has no type`:`has the unknown type ${JSON.stringify(t)}`,`Give it one of the types ${ul.join(`, `)} (see docs/custom-macros.md#parameter-types), or declare no parameters and read props.rawArgs.`);let i=r.holds;if(i!==void 0&&t!==`string`&&t!==`text`)throw pl(e,r,`is of the type ${t}, which holds what it is`,n);if(i!==void 0&&!dl.includes(i))throw pl(e,r,`holds the unknown ${JSON.stringify(i)}`,n);r.parameters&&fl(e,r.parameters)}}function pl(e,t,n,r){return Error(`spindle: The parameter \"${t.name}\" of the macro {${e}} ${n}. ${r}`)}var ml=new fr;function hl(e,t){ml.set(e,t)}function gl(e){return ml.get(e)?.parameters}function _l(){return Array.from(ml.values())}var vl=e=>Hc(_l())(e);function yl(e,t){if(!e.includes(`{`))return!1;let n;try{n=ls(e,{text:!0})}catch{return!1}return xl(n,t)}function bl(e,t=vl){for(let n of Kc(``,[e],t))if(n.kind===`text`&&yl(n.text,t))return!0;return!1}function xl(e,t=vl){for(let n of e){if(n.type===`variable`&&n.scope===`local`&&n.name===`children`||n.type===`html`&&(bl({isClose:!1,isSelfClose:!1,tagNameStart:0,tagNameEnd:0,attributeSpans:[],...n,start:0,end:0},t)||xl(n.children,t)))return!0;if(n.type===`macro`){if(bl({isClose:!1,nameStart:0,nameEnd:0,argsStart:0,argsEnd:0,...n,start:0,end:0},t)||xl(n.children,t))return!0;if(n.branches){for(let e of n.branches)if(xl(e.children,t))return!0}}}return!1}var Sl=[{name:`name`,type:`text`,holds:`text`,required:!0},{name:`parameters`,type:`text`,holds:`text`}];function Cl({name:e=``,parameters:t=``}){return{name:e,params:t.split(/\\s+/).filter(e=>e.startsWith(`@`))}}function wl(e){return Cl(Tc(e,Sl))}function Tl(e,t=vl){let n=[];for(let r of e){if(r.name!==`StoryInit`&&!r.tags?.includes(`widget`))continue;let e=[];for(let i of fs(r.content).tokens)if(i.type===`macro`&&i.name.toLowerCase()===`widget`){if(!i.isClose){e.push({rawArgs:i.rawArgs,isBlock:!1});continue}let t=e.pop();if(!t?.isBlock)continue;try{n.push(wl(t.rawArgs).name)}catch{}}else e.length>0&&(i.type===`variable`&&i.scope===`local`&&i.name===`children`||bl(i,t))&&(e[e.length-1].isBlock=!0)}return n}function El({name:e,params:t},n){let r=xl(n);Ms(e,n,t,r),r&&vr(e)}function Dl(e,t){for(let n of e)if(n.type===`macro`&&n.name===`widget`&&n.rawArgs){let e=wl(n.rawArgs);try{El(e,n.children)}catch(n){console.error(`spindle: widget \"${e.name}\" in passage \"${t}\" was not registered: ${Fs(n)}`)}}}var Ol=e=>Symbol.iterator in e,kl=e=>`entries`in e,Al=(e,t)=>{let n=e instanceof Map?e:new Map(e.entries()),r=t instanceof Map?t:new Map(t.entries());if(n.size!==r.size)return!1;for(let[e,t]of n)if(!r.has(e)||!Object.is(t,r.get(e)))return!1;return!0},jl=(e,t)=>{let n=e[Symbol.iterator](),r=t[Symbol.iterator](),i=n.next(),a=r.next();for(;!i.done&&!a.done;){if(!Object.is(i.value,a.value))return!1;i=n.next(),a=r.next()}return!!i.done&&!!a.done};function Ml(e,t){return Object.is(e,t)?!0:typeof e!=`object`||!e||typeof t!=`object`||!t||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:Ol(e)&&Ol(t)?kl(e)&&kl(t)?Al(e,t):jl(e,t):Al({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}var Nl=ge(null),Pl=ge(null);function Fl(...e){let t=j(),n=M(Nl);return Q(r=>{if(t.current&&n?.(r))return t.current;let i={};for(let t of e)i[t]=r[t];return Ml(t.current,i)?t.current:t.current=i})}function Il(){let{variables:e,temporary:t,transient:n,renderCounts:r}=Fl(`variables`,`temporary`,`transient`,`renderCounts`),i=M(hm);return Pe(()=>[e,t,i,n],[e,t,i,n,r])}var Ll=1831565813;function Rl(e){let t=e|0;return()=>{t=t+Ll|0;let e=Math.imul(t^t>>>15,t|1);return e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}}function zl(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t}var Bl=!1,Vl=``,Hl=0,Ul=null,Wl=0;function Gl(e,t=!0){let n;n=e===void 0?String(Date.now())+String(Math.random()):t?e+`|`+Date.now()+`|`+Math.random():e,Vl=n,Hl=0,Ul=Rl(zl(n)),Bl=!0,Wl++}function Kl(e,t){Wl++,ql(e,t)}function ql(e,t){Vl=e;let n=Math.imul(t%4294967296,Ll);Ul=Rl(zl(e)+n|0),Bl=!0,Hl=t}function Jl(){Wl++,Bl=!1,Vl=``,Hl=0,Ul=null}function Yl(e){let t={generation:Wl,seed:Vl,pull:Hl};try{return e()}finally{Bl&&Wl===t.generation&&Hl!==t.pull&&ql(t.seed,t.pull)}}function Xl(){return Bl?{seed:Vl,pull:Hl}:null}function Zl(){return!Bl||!Ul?Math.random():(Hl++,Ul())}function Ql(e,t){return e>t&&([e,t]=[t,e]),Math.floor(Zl()*(t-e+1))+e}function $l(){return Bl}function eu(){return Vl}function tu(){return Hl}var nu=500,ru={$:`variables`,_:`temporary`,\"@\":`locals`,\"%\":`transient`},iu=/[\\p{ID_Continue}$\\u200c\\u200d]$/u;function au(e,t=`expression`){let n=t===`statements`?`s`+e:`e`+e,r=ou.get(n);if(r!==void 0)return r;let{refs:i}=ko(e,t),a=``,o=0;for(let t of i){let n=vs(t.name,t.sigil+t.name);if(n)throw SyntaxError(`spindle: ${n}`);a+=e.slice(o,t.start),t.shorthand?a+=`${t.name}: `:iu.test(a.slice(-2))&&(a+=` `),a+=`${ru[t.sigil]}[\"${t.name}\"]`,o=t.end}return a+=e.slice(o),ou.size>=nu&&ou.delete(ou.keys().next().value),ou.set(n,a),a}var ou=new Map,su=500,cu=new Map,lu=`const {currentPassage,previousPassage,visited,hasVisited,hasVisitedAny,hasVisitedAll,rendered,hasRendered,hasRenderedAny,hasRenderedAll,random,randomInt}=__fns;`;function uu(e,t){let n=cu.get(e);if(n)return cu.delete(e),cu.set(e,n),n;let r=Function(`variables`,`temporary`,`locals`,`__fns`,`transient`,lu+t);if(cu.set(e,r),cu.size>su){let e=cu.keys().next().value;e!==void 0&&cu.delete(e)}return r}function du(){let e=Q.getState();return e.storyData?.passages.get(e.currentPassage)}function fu(){let e=Q.getState();if(e.historyIndex<=0)return;let t=e.history[e.historyIndex-1]?.passage;return t?e.storyData?.passages.get(t):void 0}function pu(e){let t=t=>ks(e(),t??Q.getState().currentPassage);return{count:t,has:e=>t(e)>0,any:(...e)=>e.some(e=>t(e)>0),all:(...e)=>e.every(e=>t(e)>0)}}function mu(e,t){let n=pu(e),r=pu(t);return{currentPassage:du,previousPassage:fu,visited:n.count,hasVisited:n.has,hasVisitedAny:n.any,hasVisitedAll:n.all,rendered:r.count,hasRendered:r.has,hasRenderedAny:r.any,hasRenderedAll:r.all}}var hu=null;function gu(){return hu??(hu={...mu(()=>Q.getState().visitCounts,()=>Q.getState().renderCounts),random:Zl,randomInt:Ql}),hu}function _u(e){return Cs(e)?e:Object.isExtensible(e)?(Object.setPrototypeOf(e,null),e):ws(e)}function vu(e,...[t,n,r=Es,i=Es]){return e(_u(t),_u(n),_u(r),gu(),_u(i))}function yu(e,...t){let n=`return (${au(e)}\\n);`;return vu(uu(n,n),...t)}function bu(e,...t){let n=au(e,`statements`);vu(uu(`exec:`+n,n),...t)}function xu(e){return e==null?``:String(e)}function Su(e,t,n){return e||t?b(`span`,{id:t,class:e},n):b(S,null,n)}function Cu(e){return e.includes(`{`)||e.includes(`}`)}function wu(e,t){return e?.length?{nodes:e,outer:t??null}:null}var Tu=new Map,Eu=2e3;function Du(e){let t=Tu.get(e);if(t===void 0){try{t={nodes:ls(e,{text:!0})}}catch(e){t={error:e}}Tu.size>=Eu&&Tu.clear(),Tu.set(e,t)}return t}function Ou(e,t){return e.map(e=>{switch(e.type){case`text`:return{type:`text`,value:t(e.value)};case`html`:return{...e,children:Ou(e.children,t)};case`macro`:{let n={...e,children:Ou(e.children,t)};return e.branches&&(n.branches=e.branches.map(e=>({...e,children:Ou(e.children,t)}))),n}default:return e}})}var ku=100;function Au(e,t,n){let r=n.split(`.`),i=r[0];ys(i,Wn[t]+i);let a=bs(t===`variable`?e.variables:t===`temporary`?e.temporary:t===`transient`?e.transient:e.locals,i);for(let e=1;e<r.length;e++){if(a==null)return;a=a[r[e]]}return a}function ju(e,t){return yu(e,t.variables,t.temporary,t.locals,t.transient)}var Mu=class{constructor(){this.errors=[]}nodes(e,t,n){let r=``;for(let i of e)r+=this.node(i,t,n);return r}node(e,t,n){switch(e.type){case`text`:return e.value;case`variable`:if(e.scope===`local`&&e.name===`children`){let e=t.widgetChildren;return e?this.nested(`children`,e.nodes,t,n,{widgetChildren:e.outer}):``}return this.variable(e.scope,e.name,t);case`expression`:try{return xu(ju(e.expression,t))}catch(e){return this.errors.push({macro:`expression`,error:e}),``}case`html`:return this.nodes(e.children,t,n);case`macro`:return this.macro(e,t,n);default:return e}}variable(e,t,n){try{return xu(Au(n,e,t))}catch(n){return this.errors.push({macro:Wn[e]+t,error:n}),``}}nested(e,t,n,r,i={}){return r>=ku?(this.errors.push({macro:e,error:Error(`markup nested too deeply (a widget using itself?)`)}),``):this.nodes(t,{...n,...i},r+1)}macro(e,t,n){if(ll(e.name))return``;let r=Ns(e.name);if(r){let i=t.locals;if(r.params.length>0){let n=e.rawArgs?oc(e.rawArgs):[];i=q(t.locals),r.params.forEach((e,r)=>{let a,o=n[r];if(o!==void 0)try{a=ju(o,t)}catch{a=void 0}i[e.startsWith(`@`)?e.slice(1):e]=a})}return this.nested(e.name,r.body,t,n,{locals:i,widgetChildren:wu(e.children,t.widgetChildren)})}let i=ol(e.name);if(!i){let t=rl(e.name)?`{${e.name}} has no text form, so it can't be used in an attribute value or label`:`unknown macro {${e.name}}`;return this.errors.push({macro:e.name,error:Error(t)}),``}let a={evaluate:e=>ju(e,t),renderText:(r,i)=>this.nested(e.name,r,t,n,i?{locals:Nu(t.locals,i)}:{})};try{return i({rawArgs:e.rawArgs,className:e.className,id:e.id,children:e.children,branches:e.branches},a)}catch(t){return this.errors.push({macro:e.name,error:t}),``}}};function Nu(e,t){for(let e of Object.keys(t))ys(e,`@${e}`);return q(e,t)}function Pu(e,t){let n=new Mu;return{text:n.nodes(e,t,0),errors:n.errors}}function Fu(e,t){if(!Cu(e))return{text:e,errors:[]};let n=Du(e);return`error`in n?{text:e,errors:[{macro:`markup`,error:n.error}]}:Pu(n.nodes,t)}function Iu(e,t,n){let r=[],i=``;for(let a of is(e))if(`text`in a)i+=n?n(a.text):a.text;else if(`verbatim`in a)i+=a.verbatim;else if(/^[$_@%][\\w.]+$/.test(a.expr)){let e=Un[a.expr[0]];try{i+=xu(Au(t,e,a.expr.slice(1)))}catch(e){r.push({macro:a.expr,error:e})}}else try{i+=xu(ju(a.expr,t))}catch(e){r.push({macro:`expression`,error:e})}return{text:i,errors:r}}function Lu(){let[e,t,n,r]=Il(),i=M(km);return Pe(()=>({variables:e,temporary:t,locals:n,transient:r,widgetChildren:i}),[e,t,n,r,i])}function Ru(){let e=Lu();return Fe(t=>{if(t===void 0||!Cu(t))return t;let{text:n,errors:r}=Fu(t,e);for(let{macro:e,error:n}of r)console.error(`spindle: {${e}} error in \"${t}\": ${Fs(n)}`);return n},[e])}var zu=0;Array.isArray;function J(e,t,n,i,a,o){t||(t={});var s,c,l=t;if(`ref`in l)for(c in l={},t)c==`ref`?s=t[c]:l[c]=t[c];var u={type:e,props:l,key:n,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--zu,__i:-1,__u:0,__source:a,__self:o};if(typeof e==`function`&&(s=e.defaultProps))for(c in s)l[c]===void 0&&(l[c]=s[c]);return r.vnode&&r.vnode(u),u}var Bu={variable:`variables`,temporary:`temporary`,transient:`transient`};function Vu({node:e}){let{name:t,scope:n}=e,r=Ru(),i=r(e.className),a=r(e.id),o=M(hm),s=t.split(`.`),c=s[0],l=Q(e=>n===`local`?void 0:bs(e[Bu[n]],c)),u=Wn[n],d=vs(c,u+c);if(d)return J(`span`,{class:`error`,children:`{${u}${t} error: ${d}}`});let f;f=n===`local`?bs(o,c):l;for(let e=1;e<s.length;e++){if(f==null){f=void 0;break}let t=s[e];f=f[t]}return Su(i,a,xu(f))}function Hu({node:e}){let{expression:t}=e,n=Ru(),r=n(e.className),i=n(e.id),[a,o,s,c]=Il(),l;try{l=xu(yu(t,a,o,s,c))}catch{l=`{error: ${t}}`}return Su(r,i,l)}function Uu(){return{nobr:M(_m),inline:M(ym),raw:M(xm),structural:M(bm),locals:M(hm)}}function Wu({body:e,parentValues:t,ownKeys:n}){let r=Uu(),[i,a]=Ae({}),o=Pe(()=>q(t,n,i),[t,n,i]),s=j(o);s.current=o;let c=Fe(()=>s.current,[]),l=Fe((e,t)=>{ys(e,`@${e}`),s.current=Ts(s.current,e,t),a(n=>({...n,[e]:t}))},[]),u=Pe(()=>({update:l,getValues:c}),[l,c]);return J(gm.Provider,{value:u,children:J(hm.Provider,{value:o,children:Sh(e,{...r,locals:o})})})}function Gu(e){let t=Ru();return Su(t(e.className),t(e.id),J(Ku,{...e}))}function Ku({body:e,params:t,rawArgs:n,invocationChildren:r}){let i=Uu().locals,[a,o,s,c]=Il(),l=M(km),u=Pe(()=>wu(r,l),[r,l]),d=n?oc(n):[],f=[];for(let e=0;e<t.length;e++){let t=d[e],n;if(t!==void 0)try{n=yu(t,a,o,s,c)}catch{n=void 0}f.push(n)}let p=Pe(()=>{let e=q();for(let n=0;n<t.length;n++)e[t[n].startsWith(`@`)?t[n].slice(1):t[n]]=f[n];return e},f);return J(km.Provider,{value:u,children:J(Wu,{body:e,parentValues:i,ownKeys:p})})}var qu=document.createElement(`i`);function Ju(e){let t=`&`+e+`;`;qu.innerHTML=t;let n=qu.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`||n===t?!1:n}function Yu(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function Xu(e,t){return e.length>0?(Yu(e,e.length,0,t),e):t}var Zu={}.hasOwnProperty;function Qu(e){let t={},n=-1;for(;++n<e.length;)$u(t,e[n]);return t}function $u(e,t){let n;for(n in t){let r=(Zu.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){Zu.call(r,a)||(r[a]=[]);let e=i[a];ed(r[a],Array.isArray(e)?e:e?[e]:[])}}}function ed(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);Yu(e,0,0,r)}function td(e){let t={},n=-1;for(;++n<e.length;)nd(t,e[n]);return t}function nd(e,t){let n;for(n in t){let r=(Zu.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i)r[a]=i[a]}}function rd(e,t){let 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)}var id={'\"':`quot`,\"&\":`amp`,\"<\":`lt`,\">\":`gt`};function ad(e){return e.replace(/[\"&<>]/g,t);function t(e){return`&`+id[e]+`;`}}function od(e){return e.replace(/[\\t\\n\\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var sd=_d(/[A-Za-z]/),cd=_d(/[\\dA-Za-z]/),ld=_d(/[#-'*+\\--9=?A-Z^-~]/);function ud(e){return e!==null&&(e<32||e===127)}var dd=_d(/\\d/),fd=_d(/[\\dA-Fa-f]/),pd=_d(/[!-/:-@[-`{-~]/);function Y(e){return e!==null&&e<-2}function md(e){return e!==null&&(e<0||e===32)}function X(e){return e===-2||e===-1||e===32}var hd=_d(/\\p{P}|\\p{S}/u),gd=_d(/\\s/);function _d(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function vd(e,t){let n=ad(yd(e||``));if(!t)return n;let r=n.indexOf(`:`),i=n.indexOf(`?`),a=n.indexOf(`#`),o=n.indexOf(`/`);return r<0||o>-1&&r>o||i>-1&&r>i||a>-1&&r>a||t.test(n.slice(0,r))?n:``}function yd(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&cd(e.charCodeAt(n+1))&&cd(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),i=1):o=`�`}else o=String.fromCharCode(a);o&&(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,o=``),i&&(n+=i,i=0)}return t.join(``)+e.slice(r)}var bd={}.hasOwnProperty,xd=/^(https?|ircs?|mailto|xmpp)$/i,Sd=/^https?$/i;function Cd(e){let t=e||{},n=!0,r={},i=[[]],a=[],o=[],s=td([{enter:{blockQuote:te,codeFenced:ie,codeFencedFenceInfo:h,codeFencedFenceMeta:h,codeIndented:se,codeText:Re,content:we,definition:ve,definitionDestinationString:be,definitionLabelString:h,definitionTitleString:h,emphasis:Ie,htmlFlow:Pe,htmlText:M,image:le,label:h,link:ue,listItemMarker:ee,listItemValue:T,listOrdered:C,listUnordered:w,paragraph:re,reference:h,resource:me,resourceDestinationString:he,resourceTitleString:h,setextHeading:Ee,strong:Le},exit:{atxHeading:Oe,atxHeadingSequence:Te,autolinkEmail:Ke,autolinkProtocol:Ge,blockQuote:ne,characterEscapeValue:je,characterReferenceMarkerHexadecimal:Ue,characterReferenceMarkerNumeric:Ue,characterReferenceValue:We,codeFenced:ce,codeFencedFence:oe,codeFencedFenceInfo:ae,codeFencedFenceMeta:S,codeFlowValue:Ne,codeIndented:ce,codeText:ze,codeTextData:je,data:je,definition:Ce,definitionDestinationString:xe,definitionLabelString:ye,definitionTitleString:Se,emphasis:Be,hardBreakEscape:j,hardBreakTrailing:j,htmlFlow:Fe,htmlFlowData:je,htmlText:Fe,htmlTextData:je,image:A,label:fe,labelText:de,lineEnding:Me,link:A,listOrdered:E,listUnordered:D,paragraph:k,reference:S,referenceString:pe,resource:S,resourceDestinationString:ge,resourceTitleString:_e,setextHeading:Ae,setextHeadingLineSequence:ke,setextHeadingText:De,strong:Ve,thematicBreak:He}},...t.htmlExtensions||[]]),c={definitions:r,tightStack:o},l={buffer:h,encode:x,getData:m,lineEndingIfNeeded:b,options:t,raw:v,resume:g,setData:p,tag:_},u=t.defaultLineEnding;return d;function d(e){let t=-1,n=0,r=[],a=[],o=[];for(;++t<e.length;)!u&&(e[t][1].type===`lineEnding`||e[t][1].type===`lineEndingBlank`)&&(u=e[t][2].sliceSerialize(e[t][1])),(e[t][1].type===`listOrdered`||e[t][1].type===`listUnordered`)&&(e[t][0]===`enter`?r.push(t):f(e.slice(r.pop(),t))),e[t][1].type===`definition`&&(e[t][0]===`enter`?(o=Xu(o,e.slice(n,t)),n=t):(a=Xu(a,e.slice(n,t+1)),n=t+1));a=Xu(a,o),a=Xu(a,e.slice(n)),t=-1;let c=a;for(s.enter.null&&s.enter.null.call(l);++t<e.length;){let e=s[c[t][0]],n=c[t][1].type,r=e[n];bd.call(e,n)&&r&&r.call({sliceSerialize:c[t][2].sliceSerialize,...l},c[t][1])}return s.exit.null&&s.exit.null.call(l),i[0].join(``)}function f(e){let t=e.length,n=0,r=0,i=!1,a;for(;++n<t;){let t=e[n];if(t[1]._container)a=void 0,t[0]===`enter`?r++:r--;else switch(t[1].type){case`listItemPrefix`:t[0]===`exit`&&(a=!0);break;case`linePrefix`:break;case`lineEndingBlank`:t[0]===`enter`&&!r&&(a?a=void 0:i=!0);break;default:a=void 0}}e[0][1]._loose=i}function p(e,t){c[e]=t}function m(e){return c[e]}function h(){i.push([])}function g(){return i.pop().join(``)}function _(e){n&&(p(`lastWasTag`,!0),i[i.length-1].push(e))}function v(e){p(`lastWasTag`),i[i.length-1].push(e)}function y(){v(u||`\n`)}function b(){let e=i[i.length-1],t=e[e.length-1],n=t?t.charCodeAt(t.length-1):null;n===10||n===13||n===null||y()}function x(e){return m(`ignoreEncode`)?e:ad(e)}function S(){g()}function C(e){o.push(!e._loose),b(),_(`<ol`),p(`expectFirstItem`,!0)}function w(e){o.push(!e._loose),b(),_(`<ul`),p(`expectFirstItem`,!0)}function T(e){if(m(`expectFirstItem`)){let t=Number.parseInt(this.sliceSerialize(e),10);t!==1&&_(` start=\"`+x(String(t))+`\"`)}}function ee(){m(`expectFirstItem`)?_(`>`):O(),b(),_(`<li>`),p(`expectFirstItem`),p(`lastWasTag`)}function E(){O(),o.pop(),y(),_(`</ol>`)}function D(){O(),o.pop(),y(),_(`</ul>`)}function O(){m(`lastWasTag`)&&!m(`slurpAllLineEndings`)&&b(),_(`</li>`),p(`slurpAllLineEndings`)}function te(){o.push(!1),b(),_(`<blockquote>`)}function ne(){o.pop(),b(),_(`</blockquote>`),p(`slurpAllLineEndings`)}function re(){o[o.length-1]||(b(),_(`<p>`)),p(`slurpAllLineEndings`)}function k(){o[o.length-1]?p(`slurpAllLineEndings`,!0):_(`</p>`)}function ie(){b(),_(`<pre><code`),p(`fencesCount`,0)}function ae(){_(` class=\"language-`+g()+`\"`)}function oe(){let e=m(`fencesCount`)||0;e||(_(`>`),p(`slurpOneLineEnding`,!0)),p(`fencesCount`,e+1)}function se(){b(),_(`<pre><code>`)}function ce(){let e=m(`fencesCount`);e!==void 0&&e<2&&c.tightStack.length>0&&!m(`lastWasTag`)&&y(),m(`flowCodeSeenData`)&&b(),_(`</code></pre>`),e!==void 0&&e<2&&b(),p(`flowCodeSeenData`),p(`fencesCount`),p(`slurpOneLineEnding`)}function le(){a.push({image:!0}),n=void 0}function ue(){a.push({})}function de(e){a[a.length-1].labelId=this.sliceSerialize(e)}function fe(){a[a.length-1].label=g()}function pe(e){a[a.length-1].referenceId=this.sliceSerialize(e)}function me(){h(),a[a.length-1].destination=``}function he(){h(),p(`ignoreEncode`,!0)}function ge(){a[a.length-1].destination=g(),p(`ignoreEncode`)}function _e(){a[a.length-1].title=g()}function A(){let e=a.length-1,i=a[e],o=i.referenceId||i.labelId,s=i.destination===void 0?r[od(o)]:i;for(n=!0;e--;)if(a[e].image){n=void 0;break}i.image?(_(`<img src=\"`+vd(s.destination,t.allowDangerousProtocol?void 0:Sd)+`\" alt=\"`),v(i.label),_(`\"`)):_(`<a href=\"`+vd(s.destination,t.allowDangerousProtocol?void 0:xd)+`\"`),_(s.title?` title=\"`+s.title+`\"`:``),i.image?_(` />`):(_(`>`),v(i.label),_(`</a>`)),a.pop()}function ve(){h(),a.push({})}function ye(e){g(),a[a.length-1].labelId=this.sliceSerialize(e)}function be(){h(),p(`ignoreEncode`,!0)}function xe(){a[a.length-1].destination=g(),p(`ignoreEncode`)}function Se(){a[a.length-1].title=g()}function Ce(){let e=a[a.length-1],t=od(e.labelId);g(),bd.call(r,t)||(r[t]=a[a.length-1]),a.pop()}function we(){p(`slurpAllLineEndings`,!0)}function Te(e){m(`headingRank`)||(p(`headingRank`,this.sliceSerialize(e).length),b(),_(`<h`+m(`headingRank`)+`>`))}function Ee(){h(),p(`slurpAllLineEndings`)}function De(){p(`slurpAllLineEndings`,!0)}function Oe(){_(`</h`+m(`headingRank`)+`>`),p(`headingRank`)}function ke(e){p(`headingRank`,this.sliceSerialize(e).charCodeAt(0)===61?1:2)}function Ae(){let e=g();b(),_(`<h`+m(`headingRank`)+`>`),v(e),_(`</h`+m(`headingRank`)+`>`),p(`slurpAllLineEndings`),p(`headingRank`)}function je(e){v(x(this.sliceSerialize(e)))}function Me(e){if(!m(`slurpAllLineEndings`)){if(m(`slurpOneLineEnding`)){p(`slurpOneLineEnding`);return}if(m(`inCodeText`)){v(` `);return}v(x(this.sliceSerialize(e)))}}function Ne(e){v(x(this.sliceSerialize(e))),p(`flowCodeSeenData`,!0)}function j(){_(`<br />`)}function Pe(){b(),M()}function Fe(){p(`ignoreEncode`)}function M(){t.allowDangerousHtml&&p(`ignoreEncode`,!0)}function Ie(){_(`<em>`)}function Le(){_(`<strong>`)}function Re(){p(`inCodeText`,!0),_(`<code>`)}function ze(){p(`inCodeText`),_(`</code>`)}function Be(){_(`</em>`)}function Ve(){_(`</strong>`)}function He(){b(),_(`<hr />`)}function Ue(e){p(`characterReferenceType`,e.type)}function We(e){let t=this.sliceSerialize(e);v(x(m(`characterReferenceType`)?rd(t,m(`characterReferenceType`)===`characterReferenceMarkerNumeric`?10:16):Ju(t))),p(`characterReferenceType`)}function Ge(e){let n=this.sliceSerialize(e);_(`<a href=\"`+vd(n,t.allowDangerousProtocol?void 0:xd)+`\">`),v(x(n)),_(`</a>`)}function Ke(e){let t=this.sliceSerialize(e);_(`<a href=\"`+vd(`mailto:`+t)+`\">`),v(x(t)),_(`</a>`)}}function Z(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return X(r)?(e.enter(n),s(r)):t(r)}function s(r){return X(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}var wd={tokenize:Td};function Td(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null){e.consume(n);return}return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),Z(e,t,`linePrefix`)}function i(t){return e.enter(`paragraph`),a(t)}function a(t){let r=e.enter(`chunkText`,{contentType:`text`,previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){if(t===null){e.exit(`chunkText`),e.exit(`paragraph`),e.consume(t);return}return Y(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var Ed={tokenize:Od},Dd={tokenize:kd};function Od(e){let t=this,n=[],r=0,i,a,o;return s;function s(i){if(r<n.length){let a=n[r];return t.containerState=a[1],e.attempt(a[0].continuation,c,l)(i)}return l(i)}function c(e){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();let n=t.events.length,a=n,o;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){o=t.events[a][1].end;break}_(r);let s=n;for(;s<t.events.length;)t.events[s][1].end={...o},s++;return Yu(t.events,a+1,0,t.events.slice(n)),t.events.length=s,l(e)}return s(e)}function l(a){if(r===n.length){if(!i)return f(a);if(i.currentConstruct&&i.currentConstruct.concrete)return m(a);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Dd,u,d)(a)}function u(e){return i&&v(),_(r),f(e)}function d(e){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(e)}function f(n){return t.containerState={},e.attempt(Dd,p,m)(n)}function p(e){return r++,n.push([t.currentConstruct,t.containerState]),f(e)}function m(n){if(n===null){i&&v(),_(0),e.consume(n);return}return i=i||t.parser.flow(t.now()),e.enter(`chunkFlow`,{_tokenizer:i,contentType:`flow`,previous:a}),h(n)}function h(n){if(n===null){g(e.exit(`chunkFlow`),!0),_(0),e.consume(n);return}return Y(n)?(e.consume(n),g(e.exit(`chunkFlow`)),r=0,t.interrupt=void 0,s):(e.consume(n),h)}function g(e,n){let s=t.sliceStream(e);if(n&&s.push(null),e.previous=a,a&&(a.next=e),a=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(_(r),e=n;e<t.events.length;)t.events[e][1].end={...c},e++;Yu(t.events,a+1,0,t.events.slice(n)),t.events.length=e}}function _(r){let i=n.length;for(;i-- >r;){let r=n[i];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function kd(e,t,n){return Z(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function Ad(e){if(e===null||md(e)||gd(e))return 1;if(hd(e))return 2}function jd(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}var Md={name:`attention`,resolveAll:Nd,tokenize:Pd};function Nd(e,t){let n=-1,r,i,a,o,s,c,l,u;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;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;let d={...e[r][1].end},f={...e[n][1].start};Fd(d,-c),Fd(f,c),o={type:c>1?`strongSequence`:`emphasisSequence`,start:d,end:{...e[r][1].end}},s={type:c>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:f},a={type:c>1?`strongText`:`emphasisText`,start:{...e[r][1].end},end:{...e[n][1].start}},i={type:c>1?`strong`:`emphasis`,start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=Xu(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=Xu(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=Xu(l,jd(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=Xu(l,[[`exit`,a,t],[`enter`,s,t],[`exit`,s,t],[`exit`,i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,l=Xu(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,Yu(e,r-1,n-r+3,l),n=r+l.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function Pd(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Ad(r),a;return o;function o(t){return a=t,e.enter(`attentionSequence`),s(t)}function s(o){if(o===a)return e.consume(o),s;let c=e.exit(`attentionSequence`),l=Ad(o),u=!l||l===2&&i||n.includes(o),d=!i||i===2&&l||n.includes(r);return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function Fd(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var Id={name:`autolink`,tokenize:Ld};function Ld(e,t,n){let r=0;return i;function i(t){return e.enter(`autolink`),e.enter(`autolinkMarker`),e.consume(t),e.exit(`autolinkMarker`),e.enter(`autolinkProtocol`),a}function a(t){return sd(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||cd(e)?(r=1,s(e)):l(e)}function s(t){return t===58?(e.consume(t),r=0,c):(t===43||t===45||t===46||cd(t))&&r++<32?(e.consume(t),s):(r=0,l(t))}function c(r){return r===62?(e.exit(`autolinkProtocol`),e.enter(`autolinkMarker`),e.consume(r),e.exit(`autolinkMarker`),e.exit(`autolink`),t):r===null||r===32||r===60||ud(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):ld(t)?(e.consume(t),l):n(t)}function u(e){return cd(e)?d(e):n(e)}function d(n){return n===46?(e.consume(n),r=0,u):n===62?(e.exit(`autolinkProtocol`).type=`autolinkEmail`,e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.exit(`autolink`),t):f(n)}function f(t){if((t===45||cd(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var Rd={partial:!0,tokenize:zd};function zd(e,t,n){return r;function r(t){return X(t)?Z(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||Y(e)?t(e):n(e)}}var Bd={continuation:{tokenize:Hd},exit:Ud,name:`blockQuote`,tokenize:Vd};function Vd(e,t,n){let r=this;return i;function i(t){if(t===62){let n=r.containerState;return n.open||(e.enter(`blockQuote`,{_container:!0}),n.open=!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return X(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function Hd(e,t,n){let r=this;return i;function i(t){return X(t)?Z(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(Bd,t,n)(r)}}function Ud(e){e.exit(`blockQuote`)}var Wd={name:`characterEscape`,tokenize:Gd};function Gd(e,t,n){return r;function r(t){return e.enter(`characterEscape`),e.enter(`escapeMarker`),e.consume(t),e.exit(`escapeMarker`),i}function i(r){return pd(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var Kd={name:`characterReference`,tokenize:qd};function qd(e,t,n){let r=this,i=0,a,o;return s;function s(t){return e.enter(`characterReference`),e.enter(`characterReferenceMarker`),e.consume(t),e.exit(`characterReferenceMarker`),c}function c(t){return t===35?(e.enter(`characterReferenceMarkerNumeric`),e.consume(t),e.exit(`characterReferenceMarkerNumeric`),l):(e.enter(`characterReferenceValue`),a=31,o=cd,u(t))}function l(t){return t===88||t===120?(e.enter(`characterReferenceMarkerHexadecimal`),e.consume(t),e.exit(`characterReferenceMarkerHexadecimal`),e.enter(`characterReferenceValue`),a=6,o=fd,u):(e.enter(`characterReferenceValue`),a=7,o=dd,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===cd&&!Ju(r.sliceSerialize(i))?n(s):(e.enter(`characterReferenceMarker`),e.consume(s),e.exit(`characterReferenceMarker`),e.exit(`characterReference`),t)}return o(s)&&i++<a?(e.consume(s),u):n(s)}}var Jd={partial:!0,tokenize:Zd},Yd={concrete:!0,name:`codeFenced`,tokenize:Xd};function Xd(e,t,n){let r=this,i={partial:!0,tokenize:x},a=0,o=0,s;return c;function c(e){return l(e)}function l(t){let n=r.events[r.events.length-1];return a=n&&n[1].type===`linePrefix`?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),u(t)}function u(t){return t===s?(o++,e.consume(t),u):o<3?n(t):(e.exit(`codeFencedFenceSequence`),X(t)?Z(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||Y(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(Jd,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||Y(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):X(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),Z(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||Y(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||Y(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),d(t)):t===96&&t===s?n(t):(e.consume(t),m)}function h(t){return e.attempt(i,b,g)(t)}function g(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_}function _(t){return a>0&&X(t)?Z(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||Y(t)?e.check(Jd,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||Y(t)?(e.exit(`codeFlowValue`),v(t)):(e.consume(t),y)}function b(n){return e.exit(`codeFenced`),t(n)}function x(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),X(t)?Z(e,l,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter(`codeFencedFenceSequence`),u(t)):n(t)}function u(t){return t===s?(i++,e.consume(t),u):i>=o?(e.exit(`codeFencedFenceSequence`),X(t)?Z(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||Y(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}function Zd(e,t,n){let r=this;return i;function i(t){return t===null?n(t):(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}var Qd={name:`codeIndented`,tokenize:ef},$d={partial:!0,tokenize:tf};function ef(e,t,n){let r=this;return i;function i(t){return e.enter(`codeIndented`),Z(e,a,`linePrefix`,5)(t)}function a(e){let t=r.events[r.events.length-1];return t&&t[1].type===`linePrefix`&&t[2].sliceSerialize(t[1],!0).length>=4?o(e):n(e)}function o(t){return t===null?c(t):Y(t)?e.attempt($d,o,c)(t):(e.enter(`codeFlowValue`),s(t))}function s(t){return t===null||Y(t)?(e.exit(`codeFlowValue`),o(t)):(e.consume(t),s)}function c(n){return e.exit(`codeIndented`),t(n)}}function tf(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):Y(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),i):Z(e,a,`linePrefix`,5)(t)}function a(e){let a=r.events[r.events.length-1];return a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(e):Y(e)?i(e):n(e)}}var nf={name:`codeText`,previous:af,resolve:rf,tokenize:of};function rf(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 af(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function of(e,t,n){let r=0,i,a;return o;function o(t){return e.enter(`codeText`),e.enter(`codeTextSequence`),s(t)}function s(t){return t===96?(e.consume(t),r++,s):(e.exit(`codeTextSequence`),c(t))}function c(t){return t===null?n(t):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),c):t===96?(a=e.enter(`codeTextSequence`),i=0,u(t)):Y(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c):(e.enter(`codeTextData`),l(t))}function l(t){return t===null||t===32||t===96||Y(t)?(e.exit(`codeTextData`),c(t)):(e.consume(t),l)}function u(n){return n===96?(e.consume(n),i++,u):i===r?(e.exit(`codeTextSequence`),e.exit(`codeText`),t(n)):(a.type=`codeTextData`,l(n))}}var sf=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError(\"Cannot access index `\"+e+\"` in a splice buffer of size `\"+(this.left.length+this.right.length)+\"`\");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=t??1/0;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&cf(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),cf(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),cf(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0))if(e<this.left.length){let t=this.left.splice(e,1/0);cf(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);cf(this.left,t.reverse())}}};function cf(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 lf(e){let t={},n=-1,r,i,a,o,s,c,l,u=new sf(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type===`chunkFlow`&&u.get(n-1)[1].type===`listItemPrefix`&&(c=r[1]._tokenizer.events,a=0,a<c.length&&c[a][1].type===`lineEndingBlank`&&(a+=2),a<c.length&&c[a][1].type===`content`))for(;++a<c.length&&c[a][1].type!==`content`;)c[a][1].type===`chunkText`&&(c[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===`enter`)r[1].contentType&&(Object.assign(t,uf(u,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type===`lineEnding`||o[1].type===`lineEndingBlank`)o[0]===`enter`&&(i&&(u.get(i)[1].type=`lineEndingBlank`),o[1].type=`lineEnding`,i=a);else if(!(o[1].type===`linePrefix`||o[1].type===`listItemIndent`))break;i&&(r[1].end={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return Yu(e,0,1/0,u.slice(0)),!l}function uf(e,t){let n=e.get(t)[1],r=e.get(t)[2],i=t-1,a=[],o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let s=o.events,c=[],l={},u,d,f=-1,p=n,m=0,h=0,g=[h];for(;p;){for(;e.get(++i)[1]!==p;);a.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<s.length;)s[f][0]===`exit`&&s[f-1][0]===`enter`&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=s.slice(g[f],g[f+1]),n=a.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)l[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return l}var df={resolve:pf,tokenize:mf},ff={partial:!0,tokenize:hf};function pf(e){return lf(e),e}function mf(e,t){let n;return r;function r(t){return e.enter(`content`),n=e.enter(`chunkContent`,{contentType:`content`}),i(t)}function i(t){return t===null?a(t):Y(t)?e.check(ff,o,a)(t):(e.consume(t),i)}function a(n){return e.exit(`chunkContent`),e.exit(`content`),t(n)}function o(t){return e.consume(t),e.exit(`chunkContent`),n.next=e.enter(`chunkContent`,{contentType:`content`,previous:n}),n=n.next,i}}function hf(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),Z(e,a,`linePrefix`)}function a(i){if(i===null||Y(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(`codeIndented`)&&a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function gf(e,t,n,r,i,a,o,s,c){let l=c||1/0,u=0;return d;function d(t){return t===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),f):t===null||t===32||t===41||ud(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter(`chunkString`,{contentType:`string`}),h(t))}function f(n){return n===62?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(`chunkString`,{contentType:`string`}),p(n))}function p(t){return t===62?(e.exit(`chunkString`),e.exit(s),f(t)):t===null||t===60||Y(t)?n(t):(e.consume(t),t===92?m:p)}function m(t){return t===60||t===62||t===92?(e.consume(t),p):p(t)}function h(i){return!u&&(i===null||i===41||md(i))?(e.exit(`chunkString`),e.exit(s),e.exit(o),e.exit(r),t(i)):u<l&&i===40?(e.consume(i),u++,h):i===41?(e.consume(i),u--,h):i===null||i===32||i===40||ud(i)?n(i):(e.consume(i),i===92?g:h)}function g(t){return t===40||t===41||t===92?(e.consume(t),h):h(t)}}function _f(e,t,n,r,i,a){let o=this,s=0,c;return l;function l(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),u}function u(l){return s>999||l===null||l===91||l===93&&!c||l===94&&!s&&`_hiddenFootnoteSupport`in o.parser.constructs?n(l):l===93?(e.exit(a),e.enter(i),e.consume(l),e.exit(i),e.exit(r),t):Y(l)?(e.enter(`lineEnding`),e.consume(l),e.exit(`lineEnding`),u):(e.enter(`chunkString`,{contentType:`string`}),d(l))}function d(t){return t===null||t===91||t===93||Y(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||(c=!X(t)),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function vf(e,t,n,r,i,a){let o;return s;function s(t){return t===34||t===39||t===40?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=t===40?41:t,c):n(t)}function c(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){return t===o?(e.exit(a),c(o)):t===null?n(t):Y(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),Z(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||Y(t)?(e.exit(`chunkString`),l(t)):(e.consume(t),t===92?d:u)}function d(t){return t===o||t===92?(e.consume(t),u):u(t)}}function yf(e,t){let n;return r;function r(i){return Y(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):X(i)?Z(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var bf={name:`definition`,tokenize:Sf},xf={partial:!0,tokenize:Cf};function Sf(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return _f.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=od(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),c):n(t)}function c(t){return md(t)?yf(e,l)(t):l(t)}function l(t){return gf(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(xf,d,d)(t)}function d(t){return X(t)?Z(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||Y(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function Cf(e,t,n){return r;function r(t){return md(t)?yf(e,i)(t):n(t)}function i(t){return vf(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return X(t)?Z(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||Y(e)?t(e):n(e)}}var wf={name:`hardBreakEscape`,tokenize:Tf};function Tf(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return Y(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var Ef={name:`headingAtx`,resolve:Df,tokenize:Of};function Df(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`},Yu(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function Of(e,t,n){let r=0;return i;function i(t){return e.enter(`atxHeading`),a(t)}function a(t){return e.enter(`atxHeadingSequence`),o(t)}function o(t){return t===35&&r++<6?(e.consume(t),o):t===null||md(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||Y(n)?(e.exit(`atxHeading`),t(n)):X(n)?Z(e,s,`whitespace`)(n):(e.enter(`atxHeadingText`),l(n))}function c(t){return t===35?(e.consume(t),c):(e.exit(`atxHeadingSequence`),s(t))}function l(t){return t===null||t===35||md(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var kf=`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`.split(`.`),Af=[`pre`,`script`,`style`,`textarea`],jf={concrete:!0,name:`htmlFlow`,resolveTo:Pf,tokenize:Ff},Mf={partial:!0,tokenize:Lf},Nf={partial:!0,tokenize:If};function Pf(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 Ff(e,t,n){let r=this,i,a,o,s,c;return l;function l(e){return u(e)}function u(t){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(t),d}function d(s){return s===33?(e.consume(s),f):s===47?(e.consume(s),a=!0,h):s===63?(e.consume(s),i=3,r.interrupt?t:oe):sd(s)?(e.consume(s),o=String.fromCharCode(s),g):n(s)}function f(a){return a===45?(e.consume(a),i=2,p):a===91?(e.consume(a),i=5,s=0,m):sd(a)?(e.consume(a),i=4,r.interrupt?t:oe):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:oe):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:D:m):n(i)}function h(t){return sd(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||md(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&Af.includes(l)?(i=1,r.interrupt?t(s):D(s)):kf.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):D(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||cd(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:D):n(i)}function v(t){return X(t)?(e.consume(t),v):ee(t)}function y(t){return t===47?(e.consume(t),ee):t===58||t===95||sd(t)?(e.consume(t),b):X(t)?(e.consume(t),y):ee(t)}function b(t){return t===45||t===46||t===58||t===95||cd(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):X(t)?(e.consume(t),x):y(t)}function S(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),c=t,C):X(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||Y(t)?n(t):(e.consume(t),C)}function w(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||md(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||X(e)?y(e):n(e)}function ee(t){return t===62?(e.consume(t),E):n(t)}function E(t){return t===null||Y(t)?D(t):X(t)?(e.consume(t),E):n(t)}function D(t){return t===45&&i===2?(e.consume(t),re):t===60&&i===1?(e.consume(t),k):t===62&&i===4?(e.consume(t),se):t===63&&i===3?(e.consume(t),oe):t===93&&i===5?(e.consume(t),ae):Y(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(Mf,ce,O)(t)):t===null||Y(t)?(e.exit(`htmlFlowData`),O(t)):(e.consume(t),D)}function O(t){return e.check(Nf,te,ce)(t)}function te(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),ne}function ne(t){return t===null||Y(t)?O(t):(e.enter(`htmlFlowData`),D(t))}function re(t){return t===45?(e.consume(t),oe):D(t)}function k(t){return t===47?(e.consume(t),o=``,ie):D(t)}function ie(t){if(t===62){let n=o.toLowerCase();return Af.includes(n)?(e.consume(t),se):D(t)}return sd(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),ie):D(t)}function ae(t){return t===93?(e.consume(t),oe):D(t)}function oe(t){return t===62?(e.consume(t),se):t===45&&i===2?(e.consume(t),oe):D(t)}function se(t){return t===null||Y(t)?(e.exit(`htmlFlowData`),ce(t)):(e.consume(t),se)}function ce(n){return e.exit(`htmlFlow`),t(n)}}function If(e,t,n){let r=this;return i;function i(t){return Y(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a):n(t)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}function Lf(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(Rd,t,n)}}var Rf={name:`htmlText`,tokenize:zf};function zf(e,t,n){let r=this,i,a,o;return s;function s(t){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(t),c}function c(t){return t===33?(e.consume(t),l):t===47?(e.consume(t),x):t===63?(e.consume(t),y):sd(t)?(e.consume(t),w):n(t)}function l(t){return t===45?(e.consume(t),u):t===91?(e.consume(t),a=0,m):sd(t)?(e.consume(t),v):n(t)}function u(t){return t===45?(e.consume(t),p):n(t)}function d(t){return t===null?n(t):t===45?(e.consume(t),f):Y(t)?(o=d,k(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?re(e):e===45?f(e):d(e)}function m(t){return t===`CDATA[`.charCodeAt(a++)?(e.consume(t),a===6?h:m):n(t)}function h(t){return t===null?n(t):t===93?(e.consume(t),g):Y(t)?(o=h,k(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?re(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?re(t):Y(t)?(o=v,k(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):Y(t)?(o=y,k(t)):(e.consume(t),y)}function b(e){return e===62?re(e):y(e)}function x(t){return sd(t)?(e.consume(t),S):n(t)}function S(t){return t===45||cd(t)?(e.consume(t),S):C(t)}function C(t){return Y(t)?(o=C,k(t)):X(t)?(e.consume(t),C):re(t)}function w(t){return t===45||cd(t)?(e.consume(t),w):t===47||t===62||md(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),re):t===58||t===95||sd(t)?(e.consume(t),ee):Y(t)?(o=T,k(t)):X(t)?(e.consume(t),T):re(t)}function ee(t){return t===45||t===46||t===58||t===95||cd(t)?(e.consume(t),ee):E(t)}function E(t){return t===61?(e.consume(t),D):Y(t)?(o=E,k(t)):X(t)?(e.consume(t),E):T(t)}function D(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,O):Y(t)?(o=D,k(t)):X(t)?(e.consume(t),D):(e.consume(t),te)}function O(t){return t===i?(e.consume(t),i=void 0,ne):t===null?n(t):Y(t)?(o=O,k(t)):(e.consume(t),O)}function te(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||md(t)?T(t):(e.consume(t),te)}function ne(e){return e===47||e===62||md(e)?T(e):n(e)}function re(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function k(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),ie}function ie(t){return X(t)?Z(e,ae,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):ae(t)}function ae(t){return e.enter(`htmlTextData`),o(t)}}var Bf={name:`labelEnd`,resolveAll:Wf,resolveTo:Gf,tokenize:Kf},Vf={tokenize:qf},Hf={tokenize:Jf},Uf={tokenize:Yf};function Wf(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type===`labelImage`||r.type===`labelLink`||r.type===`labelEnd`){let e=r.type===`labelImage`?4:2;r.type=`data`,t+=e}}return e.length!==n.length&&Yu(e,0,e.length,n),e}function Gf(e,t){let n=e.length,r=0,i,a,o,s;for(;n--;)if(i=e[n][1],a){if(i.type===`link`||i.type===`labelLink`&&i._inactive)break;e[n][0]===`enter`&&i.type===`labelLink`&&(i._inactive=!0)}else if(o){if(e[n][0]===`enter`&&(i.type===`labelImage`||i.type===`labelLink`)&&!i._balanced&&(a=n,i.type!==`labelLink`)){r=2;break}}else i.type===`labelEnd`&&(o=n);let c={type:e[a][1].type===`labelLink`?`link`:`image`,start:{...e[a][1].start},end:{...e[e.length-1][1].end}},l={type:`label`,start:{...e[a][1].start},end:{...e[o][1].end}},u={type:`labelText`,start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[[`enter`,c,t],[`enter`,l,t]],s=Xu(s,e.slice(a+1,a+r+3)),s=Xu(s,[[`enter`,u,t]]),s=Xu(s,jd(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=Xu(s,[[`exit`,u,t],e[o-2],e[o-1],[`exit`,l,t]]),s=Xu(s,e.slice(o+1)),s=Xu(s,[[`exit`,c,t]]),Yu(e,a,e.length,s),e}function Kf(e,t,n){let r=this,i=r.events.length,a,o;for(;i--;)if((r.events[i][1].type===`labelImage`||r.events[i][1].type===`labelLink`)&&!r.events[i][1]._balanced){a=r.events[i][1];break}return s;function s(t){return a?a._inactive?d(t):(o=r.parser.defined.includes(od(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(`labelEnd`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelEnd`),c):n(t)}function c(t){return t===40?e.attempt(Vf,u,o?u:d)(t):t===91?e.attempt(Hf,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(Uf,u,d)(t)}function u(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}function qf(e,t,n){return r;function r(t){return e.enter(`resource`),e.enter(`resourceMarker`),e.consume(t),e.exit(`resourceMarker`),i}function i(t){return md(t)?yf(e,a)(t):a(t)}function a(t){return t===41?u(t):gf(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return md(t)?yf(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?vf(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return md(t)?yf(e,u)(t):u(t)}function u(r){return r===41?(e.enter(`resourceMarker`),e.consume(r),e.exit(`resourceMarker`),e.exit(`resource`),t):n(r)}}function Jf(e,t,n){let r=this;return i;function i(t){return _f.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(od(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function Yf(e,t,n){return r;function r(t){return e.enter(`reference`),e.enter(`referenceMarker`),e.consume(t),e.exit(`referenceMarker`),i}function i(r){return r===93?(e.enter(`referenceMarker`),e.consume(r),e.exit(`referenceMarker`),e.exit(`reference`),t):n(r)}}var Xf={name:`labelStartImage`,resolveAll:Bf.resolveAll,tokenize:Zf};function Zf(e,t,n){let r=this;return i;function i(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),a}function a(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelImage`),o):n(t)}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var Qf={name:`labelStartLink`,resolveAll:Bf.resolveAll,tokenize:$f};function $f(e,t,n){let r=this;return i;function i(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelLink`),a}function a(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var ep={name:`lineEnding`,tokenize:tp};function tp(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),Z(e,t,`linePrefix`)}}var np={name:`thematicBreak`,tokenize:rp};function rp(e,t,n){let r=0,i;return a;function a(t){return e.enter(`thematicBreak`),o(t)}function o(e){return i=e,s(e)}function s(a){return a===i?(e.enter(`thematicBreakSequence`),c(a)):r>=3&&(a===null||Y(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),X(t)?Z(e,s,`whitespace`)(t):s(t))}}var ip={continuation:{tokenize:cp},exit:up,name:`list`,tokenize:sp},ap={partial:!0,tokenize:dp},op={partial:!0,tokenize:lp};function sp(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){let i=r.containerState.type||(t===42||t===43||t===45?`listUnordered`:`listOrdered`);if(i===`listUnordered`?!r.containerState.marker||t===r.containerState.marker:dd(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),i===`listUnordered`)return e.enter(`listItemPrefix`),t===42||t===45?e.check(np,n,l)(t):l(t);if(!r.interrupt||t===49)return e.enter(`listItemPrefix`),e.enter(`listItemValue`),c(t)}return n(t)}function c(t){return dd(t)&&++o<10?(e.consume(t),c):(!r.interrupt||o<2)&&(r.containerState.marker?t===r.containerState.marker:t===41||t===46)?(e.exit(`listItemValue`),l(t)):n(t)}function l(t){return e.enter(`listItemMarker`),e.consume(t),e.exit(`listItemMarker`),r.containerState.marker=r.containerState.marker||t,e.check(Rd,r.interrupt?n:u,e.attempt(ap,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return X(t)?(e.enter(`listItemPrefixWhitespace`),e.consume(t),e.exit(`listItemPrefixWhitespace`),f):n(t)}function f(n){return r.containerState.size=a+r.sliceSerialize(e.exit(`listItemPrefix`),!0).length,t(n)}}function cp(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(Rd,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Z(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!X(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(op,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,Z(e,e.attempt(ip,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function lp(e,t,n){let r=this;return Z(e,i,`listItemIndent`,r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`listItemIndent`&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function up(e){e.exit(this.containerState.type)}function dp(e,t,n){let r=this;return Z(e,i,`listItemPrefixWhitespace`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function i(e){let i=r.events[r.events.length-1];return!X(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var fp={name:`setextUnderline`,resolveTo:pp,tokenize:mp};function pp(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);let o={type:`setextHeading`,start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type=`setextHeadingText`,a?(e.splice(i,0,[`enter`,o,t]),e.splice(a+1,0,[`exit`,e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push([`exit`,o,t]),e}function mp(e,t,n){let r=this,i;return a;function a(t){let a=r.events.length,s;for(;a--;)if(r.events[a][1].type!==`lineEnding`&&r.events[a][1].type!==`linePrefix`&&r.events[a][1].type!==`content`){s=r.events[a][1].type===`paragraph`;break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter(`setextHeadingLine`),i=t,o(t)):n(t)}function o(t){return e.enter(`setextHeadingLineSequence`),s(t)}function s(t){return t===i?(e.consume(t),s):(e.exit(`setextHeadingLineSequence`),X(t)?Z(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||Y(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var hp={tokenize:gp};function gp(e){let t=this,n=e.attempt(Rd,r,e.attempt(this.parser.constructs.flowInitial,i,Z(e,e.attempt(this.parser.constructs.flow,i,e.attempt(df,i)),`linePrefix`)));return n;function r(r){if(r===null){e.consume(r);return}return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null){e.consume(r);return}return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}var _p={resolveAll:xp()},vp=bp(`string`),yp=bp(`text`);function bp(e){return{resolveAll:xp(e===`text`?Sp:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return c(e)?i(e):o(e)}function o(e){if(e===null){t.consume(e);return}return t.enter(`data`),t.consume(e),s}function s(e){return c(e)?(t.exit(`data`),i(e)):(t.consume(e),s)}function c(e){if(e===null)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}function xp(e){return t;function t(t,n){let r=-1,i;for(;++r<=t.length;)i===void 0?t[r]&&t[r][1].type===`data`&&(i=r,r++):(!t[r]||t[r][1].type!==`data`)&&(r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),r=i+2),i=void 0);return e?e(t,n):t}}function Sp(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===`lineEnding`)&&e[n-1][1].type===`data`){let r=e[n-1][1],i=t.sliceStream(r),a=i.length,o=-1,s=0,c;for(;a--;){let e=i[a];if(typeof e==`string`){for(o=e.length;e.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(e===-2)c=!0,s++;else if(e!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){let i={type:n===e.length||c||s<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:a?o:r.start._bufferIndex+o,_index:r.start._index+a,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...i.start},r.start.offset===r.end.offset?Object.assign(r,i):(e.splice(n,0,[`enter`,i,t],[`exit`,i,t]),n+=2)}n++}return e}var Cp=t({attentionMarkers:()=>jp,contentInitial:()=>Tp,disable:()=>Mp,document:()=>wp,flow:()=>Dp,flowInitial:()=>Ep,insideSpan:()=>Ap,string:()=>Op,text:()=>kp}),wp={42:ip,43:ip,45:ip,48:ip,49:ip,50:ip,51:ip,52:ip,53:ip,54:ip,55:ip,56:ip,57:ip,62:Bd},Tp={91:bf},Ep={[-2]:Qd,[-1]:Qd,32:Qd},Dp={35:Ef,42:np,45:[fp,np],60:jf,61:fp,95:np,96:Yd,126:Yd},Op={38:Kd,92:Wd},kp={[-5]:ep,[-4]:ep,[-3]:ep,33:Xf,38:Kd,42:Md,60:[Id,Rf],91:Qf,92:[wf,Wd],93:Bf,95:Md,96:nf},Ap={null:[Md,_p]},jp={null:[42,95]},Mp={null:[]};function Np(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],c={attempt:C(x),check:C(S),consume:v,enter:y,exit:b,interrupt:C(S,{interrupt:!0})},l={code:null,containerState:{},defineSkip:h,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d},u=t.tokenize.call(l,c);return t.resolveAll&&a.push(t),l;function d(e){return o=Xu(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=jd(a,l.events,l),l.events):[]}function f(e,t){return Fp(p(e),t)}function p(e){return Pp(o,e)}function m(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function h(e){i[e.line]=e.column,ee()}function g(){let e;for(;r._index<o.length;){let t=o[r._index];if(typeof t==`string`)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<t.length;)_(t.charCodeAt(r._bufferIndex));else _(t)}}function _(e){u=u(e)}function v(e){Y(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,ee()):e!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=e}function y(e,t){let n=t||{};return n.type=e,n.start=m(),l.events.push([`enter`,n,l]),s.push(n),n}function b(e){let t=s.pop();return t.end=m(),l.events.push([`exit`,t,l]),t}function x(e,t){w(e,t.from)}function S(e,t){t.restore()}function C(e,t){return n;function n(n,r,i){let a,o,s,u;return Array.isArray(n)?f(n):`tokenize`in n?f([n]):d(n);function d(e){return t;function t(t){let n=t!==null&&e[t],r=t!==null&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return a=e,o=0,e.length===0?i:p(e[o])}function p(e){return n;function n(n){return u=T(),s=e,e.partial||(l.currentConstruct=e),e.name&&l.parser.constructs.disable.null.includes(e.name)?h(n):e.tokenize.call(t?Object.assign(Object.create(l),t):l,c,m,h)(n)}}function m(t){return e(s,u),r}function h(e){return u.restore(),++o<a.length?p(a[o]):i}}}function w(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&Yu(l.events,t,l.events.length-t,e.resolve(l.events.slice(t),l)),e.resolveTo&&(l.events=e.resolveTo(l.events,l))}function T(){let e=m(),t=l.previous,n=l.currentConstruct,i=l.events.length,a=Array.from(s);return{from:i,restore:o};function o(){r=e,l.previous=t,l.currentConstruct=n,l.events.length=i,s=a,ee()}}function ee(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function Pp(e,t){let n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex,o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){let e=o[0];typeof e==`string`?o[0]=e.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function Fp(e,t){let n=-1,r=[],i;for(;++n<e.length;){let a=e[n],o;if(typeof a==`string`)o=a;else switch(a){case-5:o=`\\r`;break;case-4:o=`\n`;break;case-3:o=`\\r\n`;break;case-2:o=t?` `:`\t`;break;case-1:if(!t&&i)continue;o=` `;break;default:o=String.fromCharCode(a)}i=a===-2,r.push(o)}return r.join(``)}function Ip(e){let t={constructs:Qu([Cp,...(e||{}).extensions||[]]),content:n(wd),defined:[],document:n(Ed),flow:n(hp),lazy:{},string:n(vp),text:n(yp)};return t;function n(e){return n;function n(n){return Np(t,e,n)}}}function Lp(e){for(;!lf(e););return e}var Rp=/[\\0\\t\\n\\r]/g;function zp(){let e=1,t=``,n=!0,r;return i;function i(i,a,o){let s=[],c,l,u,d,f;for(i=t+(typeof i==`string`?i.toString():new TextDecoder(a||void 0).decode(i)),u=0,t=``,n&&(i.charCodeAt(0)===65279&&u++,n=void 0);u<i.length;){if(Rp.lastIndex=u,c=Rp.exec(i),d=c&&c.index!==void 0?c.index:i.length,f=i.charCodeAt(d),!c){t=i.slice(u);break}if(f===10&&u===d&&r)s.push(-3),r=void 0;else switch(r&&(s.push(-5),r=void 0),u<d&&(s.push(i.slice(u,d)),e+=d-u),f){case 0:s.push(65533),e++;break;case 9:for(l=Math.ceil(e/4)*4,s.push(-2);e++<l;)s.push(-1);break;case 10:s.push(-4),e=1;break;default:r=!0,e=1}u=d+1}return o&&(r&&s.push(-5),t&&s.push(t),s.push(null)),s}}function Bp(e,t,n){return typeof t!=`string`&&(n=t,t=void 0),Cd(n)(Lp(Ip(n).document().write(zp()(e,t,!0))))}var Vp={none:``,left:` align=\"left\"`,right:` align=\"right\"`,center:` align=\"center\"`};function Hp(){return{enter:{table(e){let t=e._align;this.lineEndingIfNeeded(),this.tag(`<table>`),this.setData(`tableAlign`,t)},tableBody(){this.tag(`<tbody>`)},tableData(){let e=Vp[this.getData(`tableAlign`)[this.getData(`tableColumn`)]];e===void 0?this.buffer():(this.lineEndingIfNeeded(),this.tag(`<td`+e+`>`))},tableHead(){this.lineEndingIfNeeded(),this.tag(`<thead>`)},tableHeader(){let e=Vp[this.getData(`tableAlign`)[this.getData(`tableColumn`)]];this.lineEndingIfNeeded(),this.tag(`<th`+e+`>`)},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,Up)),this.raw(this.encode(t))},table(){this.setData(`tableAlign`),this.setData(`slurpAllLineEndings`),this.lineEndingIfNeeded(),this.tag(`</table>`)},tableBody(){this.lineEndingIfNeeded(),this.tag(`</tbody>`)},tableData(){let 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(){let e=this.getData(`tableColumn`);this.tag(`</th>`),this.setData(`tableColumn`,e+1)},tableRow(){let e=this.getData(`tableAlign`),t=this.getData(`tableColumn`);for(;t<e.length;)this.lineEndingIfNeeded(),this.tag(`<td`+Vp[e[t]]+`></td>`),t++;this.setData(`tableColumn`,t),this.lineEndingIfNeeded(),this.tag(`</tr>`)}}}}function Up(e,t){return t===`|`?t:e}var Wp=class{constructor(){this.map=[]}add(e,t,n){Gp(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0}};function Gp(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 Kp(e,t){let n=!1,r=[];for(;t<e.length;){let 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`){let e=r.length-1;r[e]=r[e]===`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 qp(){return{flow:{null:{name:`table`,tokenize:Jp,resolveAll:Yp}}}}function Jp(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let e=r.events[t][1].type;if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):Y(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):X(t)?Z(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||md(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,X(t)?Z(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return X(t)?Z(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||Y(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return X(t)?Z(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||Y(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||Y(n)?(e.exit(`tableRow`),t(n)):X(n)?Z(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||md(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function Yp(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new Wp;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(Zp(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=Xp(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=Xp(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=Xp(f,t,o,i,n,d)):(o[0]=o[1],d=Xp(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&Zp(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=Kp(t.events,n))}return e}function Xp(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},Qp(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=Qp(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=Qp(t.events,n[2]),a=Qp(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},Qp(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function Zp(e,t,n,r,i){let a=[],o=Qp(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function Qp(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}function $p(){return{enter:{strikethrough(){this.tag(`<del>`)}},exit:{strikethrough(){this.tag(`</del>`)}}}}function em(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??(t=!0),{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&Yu(o,o.length,0,jd(s,e.slice(r+1,n),t)),Yu(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),Yu(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=Ad(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=Ad(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}function tm(e){let t=[`codeIndented`];return e?.inline&&t.push(`list`,`headingAtx`,`setextUnderline`,`thematicBreak`,`blockQuote`,`codeFenced`,`table`),{allowDangerousHtml:!0,extensions:[qp(),em(),{disable:{null:t}}],htmlExtensions:[Hp(),$p()]}}function nm(e,t){let n=tm(t);return Bp(e,{...n,extensions:[...n.extensions??[],cm(e),im]})}var rm=e=>{let t=e.length-2,n=e[t-1];return n&&n[0]===`exit`&&n[1].type===`data`&&(n[1].end=e[t][1].end,e.length=t),e},im={text:{null:{name:`textData`,tokenize(e,t){let n=this,r=this.parser.constructs.text;function i(e){if(e===null)return!0;let t=r[e]??[];return(Array.isArray(t)?t:[t]).some(e=>!e.previous||e.previous.call(n,n.previous))}function a(n){return i(n)?(e.exit(`data`),t(n)):(e.consume(n),a)}return t=>(e.enter(`data`),e.consume(t),a)},resolveTo:rm}}},am=/[#-'*+\\--9=?A-Z^-~]/,om=/[0-9A-Za-z]/,sm=/[A-Za-z]/;function cm(e){let t=e.charCodeAt(0)===65279?1:0,n=e.lastIndexOf(`-->`),r=e.lastIndexOf(`?>`),i=e.lastIndexOf(`]]>`),a=e.lastIndexOf(`>`);function o(t){return e[t]===`<`?e.startsWith(`\\x3C!--`,t)?n<t+2:e.startsWith(`<![CDATA[`,t)?i<t+9:e[t+1]===`!`&&sm.test(e[t+2]??``)?a<t+3:e[t+1]===`?`?r<t+2&&!s(t):!1:!1}function s(t){let n=t+1;for(;am.test(e[n]??``);)n++;if(e[n]!==`@`)return!1;n++;let r=0,i=`atSignOrDot`;for(;;){let t=e[n]??``;if(i===`atSignOrDot`){if(!om.test(t))return!1;i=`label`}else if(i===`label`){if(t===`>`)return!0;t===`.`?(n++,r=0,i=`atSignOrDot`):i=`value`}else{if(!((t===`-`||om.test(t))&&r++<63))return!1;n++,i=t===`-`?`value`:`label`}}}let c={name:`unclosedHtml`,resolveTo:rm,tokenize(e,n,r){let i=this.now().offset+t;return t=>t!==60||!o(i)?r(t):(e.enter(`data`),e.consume(t),e.exit(`data`),n)}};return{text:{60:c}}}function lm(e){let t=e.metadata[`data-source-file`],n=e.metadata[`data-source-line`];return t?n?` (${t}:${n})`:` (${t})`:``}function um(){let e=Q.getState();if(!e.storyData)return``;let t=e.storyData.passages.get(e.currentPassage);return t?lm(t):``}function dm({macro:e,error:t}){return J(`span`,{class:`error`,title:String(t),children:`{${e} error${um()}: ${Fs(t)}}`})}function fm(e,t,n=um()){console.error(`spindle: Error in {${e}}${n}:`,t)}function pm(e,t,n){let r=j();if(r.current===void 0){r.current=null;let i=um();try{n()}catch(n){r.current={error:n},fm(`${e} ${t}`.trim(),n,i)}}return r.current?J(dm,{macro:e,error:r.current.error}):null}var mm={update:e=>{throw Error(`Cannot set @${e} — local variables require a {for}, widget, {link}, or {button} scope`)},getValues:()=>Es},hm=ge(Es),gm=ge(mm),_m=ge(!1),vm=ge(!1),ym=ge(!1),bm=ge(!1),xm=ge(!1),Sm=ge(``),Cm=0;function wm(){return Ae(()=>`v${++Cm}`)[0]}var Tm=ge(!1),Em=`http://www.w3.org/2000/svg`,Dm=new Set([`table`,`thead`,`tbody`,`tfoot`,`tr`,`colgroup`,`ul`,`ol`,`menu`,`dl`,`select`,`optgroup`,`datalist`]),Om=new Set([`pre`,`textarea`,`style`]),km=ge(null);function Am(e,t){return`<span data-tw=${e}:${t}></span>`}var jm=/(?:(?<=\\\\)\\uE000)?<span data-tw=([0-9a-z]+):(\\d+)><\\/span>/g,Mm=``;function Nm(e,t){if(!e.includes(`<span data-tw=`))return[e];let n=[],r=0;for(let i of e.matchAll(jm))i[1]===t.nonce&&(i.index>r&&n.push(e.slice(r,i.index)),n.push(parseInt(i[2],10)),r=i.index+i[0].length);return r<e.length&&n.push(e.slice(r)),n}function Pm(e,t){return Nm(e,t).map(e=>typeof e==`number`?t.components[e]:e)}function Fm({tag:e,attributes:t,placeholders:n,svg:r,children:i}){let a=Lu(),o=[],{props:s,direct:c}=Jm(t.map(([e,t,r])=>{let i=n[e];if(!i)return[e,t,r];let s=Pu(i,a);for(let t of s.errors)o.push([e,t]);return[e,s.text,r]}),r),l=Ym(c);return Lm(o,b(e,l?{...s,ref:l}:s,...i))}function Im({tag:e,props:t,direct:n,children:r}){let i=Ym(n);return b(e,{...t,ref:i},...r)}function Lm(e,t){return e.length===0?t:J(S,{children:[e.map(([e,{macro:t,error:n}],r)=>J(dm,{macro:t,error:Error(`in attribute \"${e}\": ${Fs(n)}`)},r)),t]})}function Rm(e,t){if(e==null||e.nodeType!==Node.ELEMENT_NODE)return-1;let n=e.getAttribute(`data-tw`),r=`${t.nonce}:`;return n==null||!n.startsWith(r)?-1:parseInt(n.slice(r.length),10)}function zm(e){let t=document.createElement(`template`);return t.innerHTML=e,t.content}function Bm(e,t,n=!1){let r=zm(e.trim());if(n)for(let e of Array.from(r.childNodes))e.nodeType===Node.ELEMENT_NODE&&e.nodeName===`P`&&e.replaceWith(...Array.from(e.childNodes));return J(S,{children:Array.from(r.childNodes).map((e,n)=>Vm(e,n,t))})}function Vm(e,t,n){if(e.nodeType===Node.TEXT_NODE){let t=e.textContent??``;t.endsWith(`\\\\${Mm}`)&&Rm(e.nextSibling,n)!==-1&&(t=t.slice(0,-1));let r=Pm(t,n);return r.length===1?r[0]:r}if(e.nodeType===Node.ELEMENT_NODE){let r=e,i=r.localName,a=Rm(r,n);if(a!==-1)return n.components[a];let o=r.namespaceURI===Em,s=[],c;for(let{name:e,value:t}of Array.from(r.attributes)){s.push([e,t,t]);let r=Nm(t,n);r.every(e=>typeof e==`string`)||(c??(c={}),c[e]=r.map(e=>typeof e==`string`?{type:`text`,value:e}:n.nodes[e]))}let l=Array.from(r.childNodes).map((e,t)=>Vm(e,t,n));if(c)return J(Fm,{tag:i,attributes:s,placeholders:c,svg:o,children:l},t);let{props:u,direct:d}=Jm(s,o);return d.length>0?J(Im,{tag:i,props:u,direct:d,children:l},t):b(i,{...u,key:t},...l)}return null}var Hm=new Set(`a.abbr.b.bdi.bdo.br.button.cite.code.data.dfn.em.i.h1.h2.h3.h4.h5.h6.kbd.label.legend.mark.meter.option.output.p.progress.q.rp.rt.ruby.s.samp.small.span.strong.sub.summary.sup.time.u.var.wbr`.split(`.`)),Um=new Set([`value`,`checked`,`selected`,`muted`]),Wm=new Set([`allowfullscreen`,`async`,`autofocus`,`autoplay`,`checked`,`controls`,`default`,`defer`,`disabled`,`formnovalidate`,`hidden`,`inert`,`ismap`,`itemscope`,`loop`,`multiple`,`muted`,`nomodule`,`novalidate`,`open`,`playsinline`,`readonly`,`required`,`reversed`,`selected`]),Gm=new Set([...new Set([`key`,`ref`,`children`,`dangerouslySetInnerHTML`]),`class`,`className`]),Km=/^[A-Za-z_:][\\w:.-]*$/;function qm(e,t,n){if(Km.test(t)){e.setAttribute(t,n);return}let r=zm(`<i ${t}=\"\"></i>`).firstChild.attributes[0];if(!r)return;let i=r.cloneNode();i.value=n,e.setAttributeNode(i)}function Jm(e,t){let n={},r=[];for(let[i,a,o]of e){let e=i.toLowerCase();Wm.has(e)&&o!==``&&a===``||(!t&&Um.has(e)?n[e]=e!==`value`&&o===``?!0:a:!Km.test(i)||e.startsWith(`on`)||e===`translate`||t&&(Gm.has(i)||i===`__proto__`)?r.push([i,a]):n[t?i:i.toUpperCase()]=a)}return{props:n,direct:r}}function Ym(e){let t=j(null);return Ne(()=>{let n=t.current;if(!(!n||e.length===0)){for(let[t,r]of e)qm(n,t,r);return()=>{for(let[t]of e)n.removeAttribute(t)}}},[JSON.stringify(e)]),e.length>0?t:void 0}var Xm=new Map,Zm=new Map;function Qm(e,t,n){if(!e.includes(`&`))return e;let r=t.get(e);return r===void 0&&(r=n(e)??e,t.set(e,r)),r}function $m(e){return Qm(e,Zm,e=>zm(`<i title=\"${e.replace(/\"/g,`&quot;`)}\"></i>`).firstChild.getAttribute(`title`))}function eh(e){return Qm(e,Xm,e=>zm(`<i>${e.replace(/</g,`&lt;`)}</i>`).firstChild.textContent)}var th=/\\{[$_@%]\\w/,nh=new Map,rh=2e3;function ih(e){let t=nh.get(e);return t===void 0&&(t=Du(e),`nodes`in t&&e.includes(`&`)&&(t={nodes:Ou(t.nodes,$m)}),nh.size>=rh&&nh.clear(),nh.set(e,t)),t}function ah(e,t,n,r){if(rs(e)){if(!t.includes(`&`)&&!th.test(t))return t;let i=Iu(t,n,$m);for(let t of i.errors)r.push([e,t]);return i.text}if(!Cu(t))return $m(t);let i=ih(t);if(`error`in i)return r.push([e,{macro:`markup`,error:i.error}]),$m(t);let a=Pu(i.nodes,n);for(let t of a.errors)r.push([e,t]);return a.text}function oh(e){let t=e.findIndex(e=>e.type!==`text`||e.value.trim()!==``),n=e[t];return n?.type===`html`&&n.tag.toLowerCase()===`summary`?t:-1}function sh({node:e}){let t=Lu(),{nobr:n,locals:r,raw:i,inline:a,structural:o}=Uu(),s=M(Tm),c=e.tag.toLowerCase(),l=c===`svg`,u=!i&&(l||Om.has(c)),d=[],{props:f,direct:p}=Jm(Object.entries(e.attributes).map(([e,n])=>[e,ah(e,n,t,d),n]),s||l),m=Ym(p);m&&(f.ref=m);let h=Hm.has(c),g,_=!1;if(e.children.length>0)if(i||u)g=mh(e.children);else{let t=c===`details`?oh(e.children):-1,i=e=>Sh(e,{nobr:n,locals:r,inline:h});_=Dm.has(c)&&e.children.every(e=>e.type!==`text`||e.value.trim()===``),g=_?e.children.filter(e=>e.type!==`text`).map(e=>ph(e)):t===-1?i(e.children):J(S,{children:[i(e.children.slice(0,t)),ph(e.children[t]),i(e.children.slice(t+1))]}),h!==a&&(g=J(ym.Provider,{value:h,children:g})),_!==o&&(g=J(bm.Provider,{value:_,children:g}))}s&&c===`foreignobject`&&g&&(g=J(Tm.Provider,{value:!1,children:g}));let v=b(e.tag,f,g);return l&&!s&&(v=J(Tm.Provider,{value:!0,children:v})),Lm(d,u?J(xm.Provider,{value:!0,children:v}):v)}function ch(){let e=M(km),t=Uu();return e?J(km.Provider,{value:e.outer,children:Sh(e.nodes,t)}):null}var lh=new WeakMap,uh=0;function dh(e){let t=lh.get(e);return t===void 0&&(t=`n${uh++}`,lh.set(e,t)),t}function fh(e,t){if(ll(e.name))return null;let n={rawArgs:e.rawArgs,className:e.className,id:e.id},r=Ns(e.name);if(r)return J(Gu,{...n,body:r.body,params:r.params,invocationChildren:e.children},t);let i=rl(e.name);return i?J(i,{...n,children:e.children,branches:e.branches},t):J(`span`,{class:`error`,children:`{unknown macro: ${e.name}}`},t)}function ph(e){if(e.type===`text`)return e.comment?null:eh(e.value);let t=dh(e);switch(e.type){case`variable`:return e.scope===`local`&&e.name===`children`?J(ch,{},t):J(Vu,{node:e},t);case`expression`:return J(Hu,{node:e},t);case`macro`:return fh(e,t);case`html`:return J(sh,{node:e},t);default:return e}}function mh(e){return e.length===0?null:e.map(e=>ph(e))}var hh=/[*_`#|~\\[>\\\\\\-+=\\r]|!\\[|\\d+[.)]|&#?[a-zA-Z0-9]+;| {2}\\n|<[!?]/,gh=/(?:\\r\\n|\\r(?!\\n)|\\n)\\s*[\\r\\n]/,_h=/<span data-tw=[0-9a-z]+:\\d+><\\/span>/g,vh=` \t\\r\n`;function yh(e,t,n,r){let i=t;if(n===1)for(;i<e.length&&r.includes(e[i]);)i++;else for(;i>0&&r.includes(e[i-1]);)i--;return i}function bh(e){return e.includes(`\n`)?e.split(`\n`).map((e,t,n)=>{let r=t===0?0:yh(e,0,1,` \t`),i=t===n.length-1?e.length:yh(e,e.length,-1,` \t`);return e.slice(r,Math.max(r,i))}).join(`\n`):e}function xh(e,t,n){let r=Pm(bh(e),t).filter(e=>e!==``);return n?J(S,{children:r}):b(`p`,null,...r)}function Sh(e,t){if(e.length===0)return null;if(t?.raw)return mh(e);if(t?.structural&&e.every(e=>e.type!==`text`||e.value.trim()===``))return e.filter(e=>e.type!==`text`).map(ph);if(!e.some(e=>e.type===`text`&&(e.value.trim()!==``||gh.test(e.value))))return e.map(e=>ph(e));let n=[],r={nonce:Math.random().toString(36).slice(2,10)||`0`,components:n,nodes:[]},i=``;for(let t=0;t<e.length;t++){let a=e[t];if(a.type===`text`){i+=a.value;continue}let o=n.length;n.push(ph(a)),r.nodes.push(a),i.endsWith(`\\\\`)&&(i+=Mm),i+=Am(r.nonce,o)}let a=!!(t?.nobr||t?.inline),o=i.slice(0,yh(i,0,1,vh)),s=o.length===i.length?``:i.slice(yh(i,i.length,-1,vh)),c=i.slice(o.length,i.length-s.length),l=e=>a&&(o||s)?J(S,{children:[o,e,s]}):e,u=i.replace(_h,``);return!hh.test(u)&&!gh.test(u)?l(xh(c,r,a)):l(Bm(nm(i,{inline:t?.inline}),r,a))}var Ch=2**32-1,wh=Ch-1,Th=class extends Error{constructor(e,t,n,r){super(e),this.name=`DevalueError`,this.path=t.join(``),this.value=n,this.root=r}},Eh=Symbol();function Dh(e,t){let n=[];for(let r=0;r<e.length;r+=1){let i=e[r];i===Eh?n.push(`.get(${t(e[++r])})`):typeof i==`number`?n.push(`[${i}]`):n.push(Bh(i))}return n}var Oh=Object.getOwnPropertyNames(Object.prototype).sort().join(`\\0`);function kh(e){let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null||Object.getPrototypeOf(t)===null||Object.getOwnPropertyNames(t).sort().join(`\\0`)===Oh}function Ah(e){return Object.prototype.toString.call(e).slice(8,-1)}function jh(e){return typeof Buffer<`u`&&Buffer.isBuffer(e)}function Mh(e){switch(e){case`\"`:return`\\\\\"`;case`<`:return`\\\\u003C`;case`\\\\`:return`\\\\\\\\`;case`\n`:return`\\\\n`;case`\\r`:return`\\\\r`;case`\t`:return`\\\\t`;case`\\b`:return`\\\\b`;case`\\f`:return`\\\\f`;case`\\u2028`:return`\\\\u2028`;case`\\u2029`:return`\\\\u2029`;default:return e<` `?`\\\\u${e.charCodeAt(0).toString(16).padStart(4,`0`)}`:``}}var Nh=/[\"<\\\\\\u0000-\\u001f\\u2028\\u2029]/;function Ph(e){if(!Nh.test(e)&&e.isWellFormed())return`\"${e}\"`;let t=``,n=0,r=e.length;for(let i=0;i<r;i+=1){let a=e.charCodeAt(i);if(a>=55296&&a<=57343){if(a<=56319&&i+1<r&&(e.charCodeAt(i+1)&64512)==56320){i+=1;continue}t+=e.slice(n,i)+`\\\\u${a.toString(16)}`,n=i+1;continue}let o=Mh(e[i]);o&&(t+=e.slice(n,i)+o,n=i+1)}return`\"${n===0?e:t+e.slice(n)}\"`}var Fh=64,Ih=new Map;function Lh(e){if(e.length>Fh)return Ph(e);let t=Ih.get(e);return t===void 0&&(Ih.size>=1024&&Ih.clear(),t=Ph(e),Ih.set(e,t)),t}function Rh(e){let t=Object.getOwnPropertySymbols(e);return t.length===0?t:t.filter(t=>Object.getOwnPropertyDescriptor(e,t)?.enumerable)}var zh=/^[a-zA-Z_$][a-zA-Z_$0-9]*$/;function Bh(e){return zh.test(e)?`.`+e:`[`+JSON.stringify(e)+`]`}function Vh(e){return!(!Number.isInteger(e)||e<0||e>wh)}function Hh(e){return!(!Number.isInteger(e)||e<0||e>Ch)}function Uh(e){if(e.length===0||e.length>1&&e.charCodeAt(0)===48)return!1;for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n<48||n>57)return!1}return Vh(+e)}function Wh(e){for(var t=e.length-1;t>=0&&!Uh(e[t]);t--);return t+1}function Gh(e){let t=Object.keys(e);return t.length=Wh(t),t}function Kh(e){return new Uint8Array(e).toBase64()}function qh(e){return Uint8Array.fromBase64(e).buffer}function Jh(e){return Buffer.from(e).toString(`base64`)}function Yh(e){return Uint8Array.from(Buffer.from(e,`base64`)).buffer}function Xh(e){let t=new Uint8Array(e),n=``,r=32768;for(let e=0;e<t.length;e+=r){let i=t.subarray(e,e+r);n+=String.fromCharCode.apply(null,i)}return btoa(n)}function Zh(e){let t=atob(e),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.charCodeAt(e);return r.buffer}var Qh=typeof Uint8Array.fromBase64==`function`,$h=typeof process==`object`&&process.versions?.node!==void 0,eg=Qh?Kh:$h?Jh:Xh,tg=Qh?qh:$h?Yh:Zh;function ng(e,t){if(!t)return e;let n={};for(let r of Object.keys(e))n[r]=t[r]??e[r];return n}var rg=Object.freeze({kind:`not-plain`}),ig=Object.freeze({kind:`symbol-keys`}),ag=Object.freeze({identify:e=>e,typeOf:e=>e===null?`null`:typeof e,toPrimitive:e=>e,tagOf:e=>Ah(e),isThenable:e=>typeof e.then==`function`,toPromise:e=>Promise.resolve(e),unbox:e=>e.valueOf(),toISOString:e=>isNaN(e.getDate())?``:e.toISOString(),toStringValue:e=>e.toString(),regExpInfo:e=>({source:e.source,flags:e.flags}),valuesOf:e=>e,entriesOf:e=>e,viewInfo:e=>(jh(e)&&(e=new Uint8Array(e)),{buffer:e.buffer,byteOffset:e.byteOffset,byteLength:e.byteLength,length:e.length,bufferByteLength:e.buffer.byteLength}),toArrayBuffer:e=>e,lengthOf:e=>e.length,hasOwn:(e,t)=>Object.hasOwn(e,t),indicesOf:e=>Gh(e),shapeOf:e=>kh(e)?Rh(e).length>0?ig:{kind:Object.getPrototypeOf(e)===null?`null-proto`:`plain`,keys:Object.keys(e)}:rg,get:(e,t)=>e[t]}),og=Object.getOwnPropertyDescriptor(ArrayBuffer.prototype,`byteLength`)?.get,sg=typeof SharedArrayBuffer>`u`?void 0:Object.getOwnPropertyDescriptor(SharedArrayBuffer.prototype,`byteLength`)?.get,cg=Object.freeze({fromPrimitive:e=>e,fromISOString:e=>new Date(e),fromStringValue:(e,t)=>e===`URL`?new URL(t):e===`URLSearchParams`?new URLSearchParams(t):Temporal[e.slice(9)].from(t),fromArrayBuffer:e=>e,fromRegExpInfo:(e,t)=>new RegExp(e,t),fromViewInfo:(e,t,n,r)=>{try{og.call(t)}catch(e){if(!sg)throw e;sg.call(t)}let i=globalThis[e];return n===void 0?new i(t):new i(t,n,r)},box:e=>Object(e),createArray:e=>Array(e),createSparseArray:e=>{let t=[];return t[wh]=void 0,delete t[wh],t.length=e,t},createObject:()=>({}),createNullPrototypeObject:()=>Object.create(null),createSet:()=>new Set,createMap:()=>new Map,set:(e,t,n)=>{e[t]=n},addValue:(e,t)=>{e.add(t)},addEntry:(e,t,n)=>{e.set(t,n)}});function lg(){throw Error(`Invalid input`)}function ug(e,t,n){return dg(JSON.parse(e),t,n)}function dg(e,t,n){let r=ng(cg,n?.operations);if(typeof e==`number`)return c(e,!0);(!Array.isArray(e)||e.length===0)&&lg();let i=e,a=Array(i.length),o=null;function s(e){return(!Vh(e)||e>=i.length)&&lg(),i[e]}function c(e,n=!1){if(e===-1)return r.fromPrimitive(void 0);if(e===-3)return r.fromPrimitive(NaN);if(e===-4)return r.fromPrimitive(1/0);if(e===-5)return r.fromPrimitive(-1/0);if(e===-6)return r.fromPrimitive(-0);if((n||typeof e!=`number`)&&lg(),e in a)return a[e];e>=i.length&&lg();let l=i[e];if(!l||typeof l!=`object`)a[e]=r.fromPrimitive(l);else if(Array.isArray(l))if(typeof l[0]==`string`){let n=l[0],u=t&&Object.hasOwn(t,n)?t[n]:void 0;if(u){let t=l[1];if(typeof t!=`number`&&(t=i.push(l[1])-1),Object.hasOwn(a,t))return a[e]=u(a[t]);if(o??(o=new Set),o.has(t))throw Error(`Invalid circular reference`);return o.add(t),a[e]=u(c(t)),o.delete(t),a[e]}switch(n){case`Date`:a[e]=r.fromISOString(l[1]);break;case`Set`:let t=r.createSet();a[e]=t;for(let e=1;e<l.length;e+=1)r.addValue(t,c(l[e]));break;case`Map`:let i=r.createMap();a[e]=i;for(let e=1;e<l.length;e+=2)r.addEntry(i,c(l[e]),c(l[e+1]));break;case`RegExp`:a[e]=r.fromRegExpInfo(l[1],l[2]);break;case`Object`:{let t=l[1];if(!(t===-3||t===-4||t===-5||t===-6)){let e=s(t),n=Array.isArray(e)&&e[0]===`BigInt`;(e===void 0||typeof e==`object`)&&!n&&lg()}a[e]=r.box(c(t));break}case`BigInt`:a[e]=r.fromPrimitive(BigInt(l[1]));break;case`null`:let o=r.createNullPrototypeObject();a[e]=o;for(let e=1;e<l.length;e+=2){let t=l[e];if(typeof t!=`string`)throw Error(`Cannot parse an object with a non-string key`);if(t===`__proto__`)throw Error(\"Cannot parse an object with a `__proto__` property\");r.set(o,t,c(l[e+1]))}break;case`Int8Array`:case`Uint8Array`:case`Uint8ClampedArray`:case`Int16Array`:case`Uint16Array`:case`Float16Array`:case`Int32Array`:case`Uint32Array`:case`Float32Array`:case`Float64Array`:case`BigInt64Array`:case`BigUint64Array`:case`DataView`:{let t=l[1],i=s(t);(!Array.isArray(i)||i[0]!==`ArrayBuffer`)&&lg();let o=c(t);a[e]=r.fromViewInfo(n,o,l[2],l[3]);break}case`ArrayBuffer`:{let t=l[1];if(typeof t!=`string`)throw Error(`Invalid ArrayBuffer encoding`);a[e]=r.fromArrayBuffer(tg(t));break}case`URL`:case`URLSearchParams`:case`Temporal.Duration`:case`Temporal.Instant`:case`Temporal.PlainDate`:case`Temporal.PlainTime`:case`Temporal.PlainDateTime`:case`Temporal.PlainMonthDay`:case`Temporal.PlainYearMonth`:case`Temporal.ZonedDateTime`:a[e]=r.fromStringValue(n,l[1]);break;default:throw Error(`Unknown type ${n}`)}}else if(l[0]===-7){let t=l[1];Hh(t)||lg();let n=r.createSparseArray(t);a[e]=n;for(let e=2;e<l.length;e+=2){let i=l[e];(!Vh(i)||i>=t)&&lg(),r.set(n,i,c(l[e+1]))}}else{let t=r.createArray(l.length);a[e]=t;for(let e=0;e<l.length;e+=1){let n=l[e];n!==-2&&r.set(t,e,c(n))}}else{let t=r.createObject();a[e]=t;for(let e of Object.keys(l)){if(e===`__proto__`)throw Error(\"Cannot parse an object with a `__proto__` property\");r.set(t,e,c(l[e]))}}return a[e]}return c(0)}function fg(e,t,n){let r=pg(!1,e,t,n);return typeof r==`string`?r:`[${r.join(`,`)}]`}function pg(e,t,n,r){let i=ng(ag,r?.operations),a=[],o=new Map,s=[];if(n)for(let e of Object.getOwnPropertyNames(n))s.push({key:e,fn:n[e]});let c=[],l=0;function u(e,n){throw new Th(e,Dh(c,e=>{let t=i.typeOf(e);return t!==`object`&&t!==`function`&&t!==`symbol`?mg(i.toPrimitive(e)):`...`}),n,t)}function d(t,n){let r=i.typeOf(t);if(r===`undefined`)return-1;let f;if(r===`number`){if(f=i.toPrimitive(t),Number.isNaN(f))return-3;if(f===1/0)return-4;if(f===-1/0)return-5;if(f===0&&1/f<0)return-6}let p=i.identify(t);if(o.has(p))return o.get(p);n??(n=l++),o.set(p,n);for(let{key:e,fn:r}of s){let i=r(t);if(i)return a[n]=`[\"${e}\",${d(i)}]`,n}r===`function`?u(`Cannot stringify a function`,t):r===`symbol`&&u(`Cannot stringify a Symbol primitive`,t);let m=``;if(r!==`object`)m=mg(r===`number`?f:i.toPrimitive(t));else if(i.isThenable(t)){e||u(`Cannot stringify a Promise or thenable — use stringifyAsync instead`,t);let r=c.slice();m=i.toPromise(t).then(e=>{c=r;let t=d(e,n);t<0&&(a[n]=t)}),m.catch(()=>{})}else{let e=i.tagOf(t);switch(e){case`Number`:case`String`:case`Boolean`:case`BigInt`:m=`[\"Object\",${d(i.unbox(t))}]`;break;case`Date`:m=`[\"Date\",\"${i.toISOString(t)}\"]`;break;case`URL`:m=`[\"URL\",${Ph(i.toStringValue(t))}]`;break;case`URLSearchParams`:m=`[\"URLSearchParams\",${Ph(i.toStringValue(t))}]`;break;case`RegExp`:let{source:n,flags:r}=i.regExpInfo(t);m=r?`[\"RegExp\",${Ph(n)},\"${r}\"]`:`[\"RegExp\",${Ph(n)}]`;break;case`Array`:{let e=!1,n=i.lengthOf(t);m=`[`;for(let r=0;r<n;r+=1)if(r>0&&(m+=`,`),i.hasOwn(t,r))c.push(r),m+=d(i.get(t,r)),c.pop();else if(e)m+=-2;else{let r=i.indicesOf(t),a=r.length,o=String(n).length;if((n-a)*3>4+o+a*(o+1)){m=`[-7,`+n;for(let e=0;e<r.length;e++){let n=r[e];c.push(+n),m+=`,`+n+`,`+d(i.get(t,n)),c.pop()}break}else e=!0,m+=-2}m+=`]`;break}case`Set`:m=`[\"Set\"`;for(let e of i.valuesOf(t))m+=`,${d(e)}`;m+=`]`;break;case`Map`:m=`[\"Map\"`;for(let[e,n]of i.entriesOf(t))c.push(Eh,e),m+=`,${d(e)},${d(n)}`,c.pop(),c.pop();m+=`]`;break;case`Int8Array`:case`Uint8Array`:case`Uint8ClampedArray`:case`Int16Array`:case`Uint16Array`:case`Float16Array`:case`Int32Array`:case`Uint32Array`:case`Float32Array`:case`Float64Array`:case`BigInt64Array`:case`BigUint64Array`:{let n=i.viewInfo(t);m=`[\"`+e+`\",`+d(n.buffer),n.byteLength!==n.bufferByteLength&&(m+=`,${n.byteOffset},${n.length}`),m+=`]`;break}case`DataView`:{let n=i.viewInfo(t);m=`[\"`+e+`\",`+d(n.buffer),n.byteLength!==n.bufferByteLength&&(m+=`,${n.byteOffset},${n.byteLength}`),m+=`]`;break}case`ArrayBuffer`:m=`[\"ArrayBuffer\",\"${eg(i.toArrayBuffer(t))}\"]`;break;case`Temporal.Duration`:case`Temporal.Instant`:case`Temporal.PlainDate`:case`Temporal.PlainTime`:case`Temporal.PlainDateTime`:case`Temporal.PlainMonthDay`:case`Temporal.PlainYearMonth`:case`Temporal.ZonedDateTime`:m=`[\"${e}\",${Ph(i.toStringValue(t))}]`;break;default:{let e=i.shapeOf(t);if(e.kind===`not-plain`&&u(`Cannot stringify arbitrary non-POJOs`,t),e.kind===`symbol-keys`&&u(`Cannot stringify POJOs with symbolic keys`,t),e.kind===`null-proto`){m=`[\"null\"`;for(let n of e.keys)n===`__proto__`&&u(`Cannot stringify objects with __proto__ keys`,t),c.push(n),m+=`,${Lh(n)},${d(i.get(t,n))}`,c.pop();m+=`]`}else{m=`{`;let n=!1;for(let r of e.keys)r===`__proto__`&&u(`Cannot stringify objects with __proto__ keys`,t),n&&(m+=`,`),n=!0,c.push(r),m+=`${Lh(r)}:${d(i.get(t,r))}`,c.pop();m+=`}`}}}}return a[n]=m,n}let f=d(t);return f<0?`${f}`:a}function mg(e){let t=typeof e;return t===`string`?Ph(e):e===void 0?`-1`:e===0&&1/e<0?`-6`:t===`bigint`?`[\"BigInt\",\"${e}\"]`:String(e)}var hg=e=>Object.prototype.toString.call(e).slice(8,-1),gg=e=>hg(e).startsWith(`Temporal.`),_g=e=>e instanceof Number||e instanceof String||e instanceof Boolean||hg(e)===`BigInt`;function vg(e){return e instanceof Date||e instanceof RegExp||e instanceof Map||e instanceof Set||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof URL||e instanceof URLSearchParams||e instanceof Error||_g(e)||gg(e)}function yg(e){if(!vg(e))return;let t=e instanceof Error?`Error`:hg(e);return`${/^[AEIOU]/.test(t)?`an`:`a`} ${t}`}var bg=[`message`,`cause`,`errors`],xg=e=>e!==`4294967295`&&String(Number(e)>>>0)===e;function Sg(e){let t=Object.keys(e);return Array.isArray(e)?t.filter(e=>!xg(e)):t}function Cg(e){return jt(e)?e.entries():Map.prototype.entries.call(e)}function wg(e){return jt(e)?e.values():Set.prototype.values.call(e)}function Tg(e){if(jt(e))return e.size;let t=e instanceof Map?Map.prototype:Set.prototype;return Reflect.get(t,`size`,e)}function Eg(e,t){return jt(e)?e.get(t):Map.prototype.get.call(e,t)}function Dg(e,t,n){jt(e)?e.set(t,n):Map.prototype.set.call(e,t,n)}var Og=new Map,kg=new Map,Ag=[ArrayBuffer,DataView,Object.getPrototypeOf(Int8Array),URL,URLSearchParams,Number,String,Boolean,Promise,WeakMap,WeakSet,Function];function jg(e,t){let n=typeof t==`function`?Ag.find(e=>t.prototype instanceof e):void 0;if(n)throw TypeError(`spindle: Cannot register class \"${e}\": it extends ${n.name}, whose instances cannot be saved (a registered class may extend Array, Map, Set, Date, RegExp or Error)`);Og.set(e,t),kg.set(t,e)}function Mg(e){let t=Object.getPrototypeOf(e);return t===null?void 0:kg.get(t.constructor)}var Ng=`c:`,Pg=`E:`,Fg=`S`,Ig=`K`,Lg=`R`,Rg=new Map([Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError,globalThis.AggregateError].map(e=>[e.prototype,e.name])),zg=new Map([...Rg].map(([e,t])=>[t,e.constructor])),Bg=[`message`,`cause`,`errors`],Vg=e=>typeof e==`object`&&!!e,Hg=e=>Vg(e)&&Object.getPrototypeOf(e)===Object.prototype,Ug=e=>TypeError(`spindle: Malformed data for class \"${e}\"`),Wg=(e,t,n)=>{Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0,configurable:!0})};function Gg(e){if(Object.getOwnPropertySymbols(e).length>0)throw TypeError(`spindle: Cannot save an object with symbol keys`)}function Kg(e,t=Object.keys(e)){Gg(e);let n={};if(e instanceof Error)for(let t of Bg)K(e,t)&&Wg(n,t,e[t]);for(let r of t)Wg(n,r,e[r]);return n}var qg={Array,Map,Set,Date,RegExp};function Jg(e){let t=()=>Kg(e,Sg(e));if(Array.isArray(e)){let n=Array(e.length);for(let t=0;t<e.length;t++)t in e&&(n[t]=e[t]);return[`Array`,n,t()]}return e instanceof Map?[`Map`,Array.from(Cg(e)),t()]:e instanceof Set?[`Set`,Array.from(wg(e)),t()]:e instanceof Date?[`Date`,Date.prototype.getTime.call(e),t()]:e instanceof RegExp?[`RegExp`,[Reflect.get(RegExp.prototype,`source`,e),Reflect.get(RegExp.prototype,`flags`,e),e.lastIndex],t()]:Qg(Kg(e))}function Yg(e){for(let t of Bg)K(e,t)&&Object.defineProperty(e,t,{enumerable:!1})}var Xg=e=>e.length===1&&JSON.stringify(e).length>3;function Zg(e){let t=Object.keys(e);if(!t.some(Xg))return!1;if(Gg(e),t.includes(`__proto__`))throw TypeError(`spindle: Cannot save a property named \"__proto__\"`);return t.flatMap(t=>[t,e[t]])}function Qg(e){let t=Zg(e);return t?[Ig,...t]:e}function $g(){let e={};for(let[t,n]of Og)e[Ng+t]=e=>Vg(e)&&Object.getPrototypeOf(e)===n.prototype&&Jg(e);for(let[t,n]of Rg)e[Pg+n]=e=>Vg(e)&&Object.getPrototypeOf(e)===t&&Qg(Kg(e));return e[Fg]=e=>{if(typeof e!=`symbol`)return!1;let t=Symbol.keyFor(e);return t!==void 0&&[t]},e[Lg]=e=>e instanceof RegExp&&e.lastIndex!==0&&[e.source,e.flags,e.lastIndex],e[Ig]=e=>Hg(e)&&Zg(e),e}function e_(e){if(!Array.isArray(e)||typeof e[0]!=`string`||typeof e[1]!=`string`||!Number.isSafeInteger(e[2]))return;let t=new RegExp(e[0],e[1]);return t.lastIndex=e[2],t}function t_(e,t){return e===`RegExp`?e_(t):typeof t==`number`?new Date(t):void 0}var n_=new WeakMap;function r_(e,t,n){let[r,i,a]=n,o=typeof r==`string`&&K(qg,r)?qg[r]:void 0,s=r===`Date`||r===`RegExp`;if(n.length!==3||!o||!(t.prototype instanceof o)||!s&&K(n,1)&&!Array.isArray(i)||K(n,2)&&!Hg(a))throw Ug(e);let c=n_.get(n);if(!c){let a=s?t_(r,i):new o;if(!a)throw Ug(e);c=Object.setPrototypeOf(a,t.prototype),n_.set(n,c)}if(!s&&Array.isArray(i)&&i_(c,i),Hg(a))for(let e of Object.keys(a))Wg(c,e,a[e]);return c}function i_(e,t){if(Array.isArray(e)){e.length=t.length;for(let n=0;n<t.length;n++)K(t,n)?e[n]=t[n]:delete e[n]}else if(e instanceof Map){Map.prototype.clear.call(e);for(let n of t){if(!Array.isArray(n)||n.length!==2)throw TypeError(`spindle: Malformed map entries`);Map.prototype.set.call(e,n[0],n[1])}}else{Set.prototype.clear.call(e);for(let n of t)Set.prototype.add.call(e,n)}}function a_(e){return Array.isArray(e)&&e[0]===Ig?u_(e,1):e}function o_(e){return t=>{if(t=a_(t),Array.isArray(t))return r_(e,s_(e),t);if(!Hg(t)){if(Vg(t)&&Mg(t)===e)return t;throw Ug(e)}let n=s_(e);if(Object.values(qg).some(e=>n.prototype instanceof e))throw Ug(e);return Object.setPrototypeOf(t,n.prototype),t instanceof Error&&Yg(t),t}}function s_(e){let t=Og.get(e);if(!t)throw TypeError(`spindle: The save holds an instance of class \"${e}\", which is not registered`);return t}function c_(e){let t=zg.get(e);if(t)return n=>{if(n=a_(n),Object.getPrototypeOf(n)===t.prototype)return n;if(!Hg(n))throw TypeError(`spindle: Malformed data for \"${e}\"`);return Object.setPrototypeOf(n,t.prototype),Yg(n),n}}var l_=new WeakMap;function u_(e,t=0){if(!Array.isArray(e)||(e.length-t)%2!=0)throw TypeError(`spindle: Malformed object entries`);let n=l_.get(e);n||l_.set(e,n={});for(let r=t;r<e.length&&K(e,r);r+=2){let t=e[r];if(typeof t!=`string`||t===`__proto__`)throw TypeError(`spindle: Malformed object entries`);Wg(n,t,K(e,r+1)?e[r+1]:void 0)}return n}var d_=new Proxy({},{getOwnPropertyDescriptor(e,t){let n=f_(t);return n&&{value:n,enumerable:!0,configurable:!0}},get:(e,t)=>f_(t)});function f_(e){if(typeof e==`string`){if(e===Fg)return e=>{if(!Array.isArray(e)||typeof e[0]!=`string`)throw TypeError(`spindle: Malformed symbol`);return Symbol.for(e[0])};if(e===Ig)return u_;if(e===Lg)return e=>{let t=e_(e);if(!t)throw TypeError(`spindle: Malformed regular expression`);return t};if(e.startsWith(Ng))return o_(e.slice(2));if(e.startsWith(Pg))return c_(e.slice(2))}}function p_(e,t){if(!(e instanceof Error)||e.name!==`DevalueError`)return e instanceof Error?e:Error(String(e));let{path:n,value:r}=e,i=n?` (at ${n})`:``,a=e.message;return typeof r==`function`?a=`Cannot save a function`:Vg(r)&&/non-POJO/.test(e.message)?a=`Cannot save an instance of class \"${Object.getPrototypeOf(r)?.constructor?.name??`?`}\", which is not registered (see Story.registerClass)`:typeof r==`symbol`?a=`Cannot save a unique symbol (only Symbol.for() symbols)`:/symbolic keys/.test(e.message)?a=`Cannot save an object with symbol keys`:/__proto__/.test(e.message)&&(a=`Cannot save a property named \"__proto__\"`),TypeError(`spindle: ${a}${i}`)}function m_(e){try{return fg(e,$g())}catch(t){throw p_(t,e)}}function h_(e){return ug(e,d_)}var g_=class extends Error{constructor(){super(`This save was made by an incompatible version of Spindle`),this.name=`IncompatibleSaveError`}},__={};function v_(e){if(typeof e!=`number`||!Number.isInteger(e)||e<1||e>1)throw new g_}function y_(e,t){v_(e);let n=t;for(let t=e;t<1;t++){let e=__[t];if(!e)throw new g_;n=e(n)}return n}var b_=e=>e&&new Map(Object.entries(e));function x_(e){if(!(e instanceof TypeError))return e;let t=e.message.replace(/\\(at \\.variables(?=[.[]|\\))/,`(at $`).replace(/\\(at \\.history\\[(\\d+)\\]\\.variables(.*)\\)$/,(e,t,n)=>`(at $${n} in history moment ${t})`).replace(/\\(at \\$\\.?/,`(at $`);return t===e.message?e:TypeError(t)}function S_(e){try{return{formatVersion:1,data:m_({...e,visitCounts:b_(e.visitCounts),renderCounts:b_(e.renderCounts)})}}catch(e){throw x_(e)}}var C_=()=>Error(`Invalid save data`);function w_(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function T_(e){return e==null?!0:w_(e)&&typeof e.seed==`string`&&typeof e.pull==`number`&&Number.isInteger(e.pull)&&e.pull>=0}var E_=e=>w_(e)&&typeof e.passage==`string`&&w_(e.variables)&&typeof e.timestamp==`number`&&T_(e.prng),D_=e=>e===void 0||Array.isArray(e)&&Array.from(e).every(e=>w_(e)&&typeof e.condition==`string`&&w_(e.options)),O_=e=>e===void 0||e instanceof Map&&[...e.keys()].every(e=>typeof e==`string`);function k_(e){if(!w_(e)||typeof e.passage!=`string`||!w_(e.variables))return!1;let{history:t,historyIndex:n}=e;return!Array.isArray(t)||t.length===0||!Array.from(t).every(E_)||typeof n!=`number`||!Number.isInteger(n)||n<0||n>=t.length||t[n].passage!==e.passage?!1:O_(e.visitCounts)&&O_(e.renderCounts)&&T_(e.prng)&&D_(e.watchers)&&(e.interfaceWatchers===void 0||typeof e.interfaceWatchers==`boolean`)}var A_=e=>e instanceof Map?As(Object.fromEntries(e)):void 0;function j_(e){if(typeof e!=`object`||!e)throw C_();let{formatVersion:t,data:n}=e;if(v_(t),typeof n!=`string`)throw C_();let r=h_(y_(t,n));if(!k_(r))throw C_();let i={...r,visitCounts:A_(r.visitCounts),renderCounts:A_(r.renderCounts)};return i.visitCounts===void 0&&delete i.visitCounts,i.renderCounts===void 0&&delete i.renderCounts,i}var M_=`Invalid save file format`;function N_(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var P_=[`id`,`passage`,`ifid`,`playthroughId`,`createdAt`,`updatedAt`,`title`];function F_(e){let t=console.warn;console.warn=()=>{};try{j_(e)}finally{console.warn=t}}function I_(e){if(!N_(e))throw Error(M_);if(!K(e,`formatVersion`))throw e.version===1?new g_:Error(M_);if(v_(e.formatVersion),typeof e.ifid!=`string`)throw Error(M_);let t=e.save;if(!N_(t)||!N_(t.meta))throw Error(M_);let n=t.meta;if(P_.some(e=>typeof n[e]!=`string`))throw Error(M_);try{F_(t.payload)}catch(e){throw e instanceof g_?e:Error(M_)}}function L_(e){try{return I_(e),!0}catch{return!1}}function R_(e){return JSON.stringify(e).length}function z_(e){return{saves:e(`saves`,{ifid:e=>e.meta.ifid,playthroughId:e=>e.meta.playthroughId}),playthroughs:e(`playthroughs`,{ifid:e=>e.ifid}),meta:e(`meta`,{})}}var B_={autosave:`autosave.`,slot:`slot.`,slotIndex:`slotIndex.`,playthroughCount:`playthroughCount.`,currentPlaythrough:`currentPlaythroughId.`};function V_(e,t){let{slot:n,...r}=B_;return Object.values(r).some(n=>e===n+t)||e.startsWith(n)&&e.endsWith(`.${t}`)}function H_(e,{saves:t,playthroughs:n,meta:r},i){async function a(e,t,n,r){let i=(await e.find(n,r)).map(t);for(let t of i)await e.delete(t);return i}async function o(e){for(let t of await r.keys())e(t)&&await r.delete(t)}let s=e=>e.meta.id,c=e=>e.id;return{type:e,putSave:e=>t.put(e.meta.id,e),getSave:e=>t.get(e),deleteSave:e=>t.delete(e),getSavesByIfid:e=>t.find(`ifid`,e),deleteSavesByIfid:async e=>{await a(t,s,`ifid`,e)},deleteSavesByPlaythrough:e=>a(t,s,`playthroughId`,e),putPlaythrough:e=>n.put(e.id,e),getPlaythroughsByIfid:e=>n.find(`ifid`,e),deletePlaythroughsByIfid:async e=>{await a(n,c,`ifid`,e)},deletePlaythroughById:e=>n.delete(e),getMeta:e=>r.get(e),setMeta:(e,t)=>r.put(e,t),deleteMeta:e=>r.delete(e),deleteMetaByPrefix:e=>o(t=>t.startsWith(e)),deleteMetaByIfid:e=>o(t=>V_(t,e)),getAllMetaKeys:()=>r.keys(),destroy:i}}function U_(){let e=e=>structuredClone(e),t=[];function n(n,r){let i=new Map;return t.push(i),{get:async t=>e(i.get(t)),put:async(t,n)=>{i.set(t,e(n))},delete:async e=>{i.delete(e)},find:async(t,n)=>[...i.values()].filter(e=>r[t](e)===n).map(e),keys:async()=>[...i.keys()]}}return H_(`memory`,z_(n),async()=>{for(let e of t)e.clear()})}var W_={saves:`spindle.save.`,playthroughs:`spindle.pt.`,meta:`spindle.meta.`},G_={\"saves.ifid\":`spindle.idx.saves.`,\"saves.playthroughId\":`spindle.idx.saves-pt.`,\"playthroughs.ifid\":`spindle.idx.pt.`};function K_(e){let t=localStorage.getItem(e);if(t!==null)try{return JSON.parse(t)}catch{return}}function q_(e,t){localStorage.setItem(e,JSON.stringify(t))}function J_(e){localStorage.removeItem(e)}function Y_(e,t){try{t===null?localStorage.removeItem(e):localStorage.setItem(e,t)}catch{}}function X_(e){return K_(e)??[]}function Z_(e,t){let n=X_(e);n.includes(t)||(n.push(t),q_(e,n))}function Q_(e,t){let n=X_(e).filter(e=>e!==t);n.length>0?q_(e,n):J_(e)}var $_=e=>Object.keys(localStorage).filter(t=>t.startsWith(e));function ev(){function e(e,t){let n=W_[e],r=Object.entries(t).map(([t,n])=>({field:t,read:n,prefix:G_[`${e}.${t}`]})),i=e=>r.map(t=>`${t.prefix}${t.read(e)}`);return{get:async e=>K_(`${n}${e}`),async put(e,t){let r=K_(`${n}${e}`),a=i(t),o=r===void 0?[]:i(r).filter(e=>!a.includes(e)),s=[`${n}${e}`,...o,...a],c=s.map(e=>localStorage.getItem(e));try{for(let t of o)Q_(t,e);q_(`${n}${e}`,t);for(let t of a)Z_(t,e)}catch(e){throw s.forEach((e,t)=>Y_(e,c[t]??null)),e}},async delete(e){let t=K_(`${n}${e}`);if(t!==void 0)for(let n of i(t))Q_(n,e);J_(`${n}${e}`)},async find(e,t){let i=r.find(t=>t.field===e),a=[];for(let e of X_(`${i.prefix}${t}`)){let t=K_(`${n}${e}`);t!==void 0&&a.push(t)}return a},keys:async()=>$_(n).map(e=>e.slice(n.length))}}return H_(`localstorage`,z_(e),async()=>{for(let e of $_(`spindle.`))J_(e)})}var tv=`spindle`,nv=1,rv={saves:{keyPath:`meta.id`,indexes:{ifid:`meta.ifid`,playthroughId:`meta.playthroughId`}},playthroughs:{keyPath:`id`,indexes:{ifid:`ifid`}},meta:{keyPath:`key`,indexes:{}}};function iv(){let e=null;function t(){return e||(e=new Promise((t,n)=>{let r=indexedDB.open(tv,nv);r.onupgradeneeded=()=>{let e=r.result;for(let[t,{keyPath:n,indexes:r}]of Object.entries(rv)){if(e.objectStoreNames.contains(t))continue;let i=e.createObjectStore(t,{keyPath:n});for(let[e,t]of Object.entries(r))i.createIndex(e,t,{unique:!1})}},r.onsuccess=()=>{let n=r.result;n.onversionchange=()=>{n.close(),e=null},t(n)},r.onerror=()=>n(r.error)}),e)}function n(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)})}function r(e){let r=e===`meta`,i=async(r,i)=>{let a=(await t()).transaction(e,r),o=n(i(a.objectStore(e)));if(r===`readonly`)return o;let s=new Promise((e,t)=>{a.oncomplete=()=>e(),a.onabort=()=>t(a.error??new DOMException(`Transaction aborted`,`AbortError`))}),[c]=await Promise.all([o,s]);return c};return{async get(e){let t=await i(`readonly`,t=>t.get(e));return r?t?.value:t},async put(e,t){await i(`readwrite`,n=>n.put(r?{key:e,value:t}:t))},async delete(e){await i(`readwrite`,t=>t.delete(e))},async find(e,t){return await i(`readonly`,n=>n.index(e).getAll(t))??[]},keys:async()=>await i(`readonly`,e=>e.getAllKeys())}}return H_(`indexeddb`,z_(r),async()=>{(await t()).close(),e=null,await new Promise((e,t)=>{let n=indexedDB.deleteDatabase(tv);n.onsuccess=()=>e(),n.onerror=()=>t(n.error),n.onblocked=()=>t(Error(`Cannot clear the saved data: another tab or window of this site still has it open. Close the other tabs and try again.`))})})}var av=null;async function ov(){try{if(typeof indexedDB<`u`)return await new Promise((e,t)=>{let n=indexedDB.open(`__spindle_probe__`,1);n.onsuccess=()=>{n.result.close(),indexedDB.deleteDatabase(`__spindle_probe__`),e()},n.onerror=()=>t(n.error)}),iv()}catch{}try{if(typeof localStorage<`u`){let e=`__spindle_probe__`;localStorage.setItem(e,`1`);let t=localStorage.getItem(e);if(localStorage.removeItem(e),t===`1`)return ev()}}catch{}return U_()}var sv=null;function cv(){if(av)return Promise.resolve(av);if(!sv){let e=ov().then(t=>(sv===e&&(av=t),t));sv=e}return sv}function lv(){av=null,sv=null}function uv(){return av?.type??`memory`}function dv(e,t){let n=e;for(let e of t){if(n==null||e in Object.prototype&&!K(Object(n),e))return;let t=n;if(n=t[e],n===void 0&&jt(t)&&(t instanceof Map||t instanceof Set)){let r=It(t);r&&K(r,e)&&(n=r[e])}}return n}var fv=e=>e===`length`||/^(0|[1-9]\\d*)$/.test(e),pv=yg;function mv(e){let t=Array.isArray(e)?Array(e.length):Object.create(Object.getPrototypeOf(e));for(let n of Object.keys(e))Object.defineProperty(t,n,{value:e[n],enumerable:!0,writable:!0,configurable:!0});return t}function hv(e,t,n,r={}){let i=yv(e,t,r.createMissing??!1);i[t[t.length-1]]=n}function gv(e,t){let n=t[t.length-1];_v(t);let r=e;for(let e of t.slice(0,-1)){if(typeof r!=`object`||!r||!K(r,e))return;r=r[e]}if(typeof r!=`object`||!r||!K(r,n))return;let i=yv(e,t,!1);if(Array.isArray(i)&&jt(i)&&t.length>1){let r=Ln(i).slice();delete r[Number(n)];let a=yv(e,t.slice(0,-1),!1);a[t[t.length-2]]=r;return}delete i[n]}function _v(e){if(e.includes(`__proto__`))throw TypeError(`spindle: Cannot use \"__proto__\" in a variable path (\"${e.join(`.`)}\")`)}function vv(e,t,n,r,i){if(i&&Mg(e)!==void 0)return;let a=pv(e)??(Array.isArray(e)&&!fv(t)?`an array`:``);if(a)throw TypeError(`spindle: Cannot set property \"${t}\" on ${a} (at \"${n.slice(0,r).join(`.`)}\")`)}function yv(e,t,n){_v(t);let r=jt(e),i=e;for(let e=0;e<t.length-1;e++){let a=t[e];vv(i,a,t,e,!r);let o=K(i,a)?i[a]:void 0;if(typeof o!=`object`||!o){if(!n)throw TypeError(`spindle: Cannot set property \"${t[e+1]}\" on ${o===null?`null`:typeof o} (at \"${t.slice(0,e+1).join(`.`)}\")`);o={},i[a]=o}else r&&!jt(o)&&!pv(o)&&(o=mv(o),i[a]=o);i=o}return vv(i,t[t.length-1],t,t.length-1,!r),i}function bv(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function xv(e,t,n,r){if(n(t),Mg(e)===void 0)return t;Object.setPrototypeOf(t,Object.getPrototypeOf(e));for(let n of Sg(e))xs(t,n,r(n));return t}function Sv(e,t={}){let n=t.seen??new Map,r=(e,t)=>(n.set(e,t),t);function i(e,t){for(let n of Object.keys(e))xs(t,n,c(e[n]));for(let n of Object.getOwnPropertySymbols(e))Object.prototype.propertyIsEnumerable.call(e,n)&&(t[n]=c(e[n]));return t}function a(e){if(e instanceof Date)return s(e,new Date(Date.prototype.getTime.call(e)));if(e instanceof RegExp){let t=new RegExp(Reflect.get(RegExp.prototype,`source`,e),Reflect.get(RegExp.prototype,`flags`,e));return t.lastIndex=e.lastIndex,s(e,t)}if(e instanceof ArrayBuffer)return r(e,e.slice(0));if(ArrayBuffer.isView(e)){let t=c(e.buffer);if(e instanceof DataView)return r(e,new DataView(t,e.byteOffset,e.byteLength));let n=e.constructor,i=e.length;return r(e,new n(t,e.byteOffset,i))}if(e instanceof URL)return r(e,new URL(e.href));if(e instanceof URLSearchParams)return r(e,new URLSearchParams(e));if(_g(e))return r(e,Object(e.valueOf()));if(gg(e))return e;if(e instanceof Error){let t=r(e,Object.create(Object.getPrototypeOf(e)));for(let n of[...bg,`stack`])if(K(e,n)){let r=e[n];Object.defineProperty(t,n,{value:o(c(r),r),writable:!0,configurable:!0})}return i(e,t)}}function o(e,n){let r=t.settle;return r&&Ov(e)&&Ov(n)?r(e,n):e}let s=(e,t)=>xv(e,t,t=>r(e,t),t=>c(e[t]));function c(e){if(typeof e!=`object`||!e)return e;let l=e;if(n.has(l))return n.get(l);if(Array.isArray(e)){let t=s(l,Array(e.length));for(let n=0;n<e.length;n++)n in e&&(t[n]=c(e[n]));return t}if(e instanceof Map){let t=s(l,new Map);for(let[n,r]of Cg(e))Map.prototype.set.call(t,o(c(n),n),c(r));return t}if(e instanceof Set){let t=s(l,new Set);for(let n of wg(e))Set.prototype.add.call(t,o(c(n),n));return t}let u=a(l);if(u!==void 0)return u;let d=Mg(l)!==void 0||bv(e);return!d&&t.keepUnregistered?e:i(l,r(l,d?Object.create(Object.getPrototypeOf(l)):{}))}return c(e)}function Cv(e,t){return Pv(e,t,wv())}function wv(){let e=new Map;return(t,n)=>{let r=e.get(t);if(r?.has(n))return!0;r?r.add(n):e.set(t,new Set([n]))}}function Tv(e=new Map,t=new Map){let n=[],r=((r,i)=>{let a=e.get(r);if(a!==void 0)return a===i;if(t.has(i))return!1;e.set(r,i),t.set(i,r),n.push([r,i])});return r.strict=!0,r.added=n,r}function Ev(e,t){return Pv(e,t,Tv())}function Dv(e,t){if(!Ov(e)||!Ov(t))return t;let n=new Map,r=new Map,i=e=>Ov(e)?Sv(e,{keepUnregistered:!0,seen:n}):e;function a(e,t){let i=Tv(r,n);if(Pv(e,t,i))return!0;for(let[e,t]of i.added)r.delete(e),n.delete(t);return!1}function o(e,t){if(!Ov(t))return t;let r=n.get(t);if(r!==void 0)return r;if(!Ov(e))return i(t);if(a(e,t))return e;let s=e,c=t,l=e=>o(K(s,e)?s[e]:void 0,c[e]),u=e=>xv(t,e,e=>n.set(t,e),l);if(t instanceof Map&&e instanceof Map){let n=u(new Map);for(let[r,a]of Cg(t))Map.prototype.set.call(n,i(r),o(Eg(e,r),a));return n}if(Array.isArray(t)&&Array.isArray(e)){let n=u(Array(t.length));for(let r=0;r<t.length;r++)r in t&&(n[r]=o(e[r],t[r]));return n}if(Iv(e,t,!1)){let e=Object.create(Object.getPrototypeOf(t));n.set(t,e);for(let t of Object.keys(c))xs(e,t,l(t));return e}return i(t)}return o(e,t)}var Ov=e=>typeof e==`object`&&!!e;function kv(e,t){let n=ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e),r=ArrayBuffer.isView(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):new Uint8Array(t);if(n.length!==r.length)return!1;for(let e=0;e<n.length;e++)if(n[e]!==r[e])return!1;return!0}function Av(e,t,n){if(e instanceof Date){let r=Date.prototype.getTime;return Object.is(r.call(e),r.call(t))&&Nv(e,t,n)}if(e instanceof RegExp){let r=RegExp.prototype.toString;return r.call(e)===r.call(t)&&e.lastIndex===t.lastIndex&&Nv(e,t,n)}if(ArrayBuffer.isView(e)){let r=t;return e.byteOffset===r.byteOffset&&e.byteLength===r.byteLength&&Pv(e.buffer,r.buffer,n)}if(e instanceof ArrayBuffer)return kv(e,t);if(e instanceof URL||e instanceof URLSearchParams)return String(e)===String(t);if(_g(e))return Object.is(e.valueOf(),t.valueOf());if(gg(e))return String(e)===String(t);if(e instanceof Error)return bg.every(r=>K(e,r)===K(t,r)&&Pv(e[r],t[r],n))&&jv(e,t,n)}function jv(e,t,n,r=Object.keys){let i=e,a=t,o=r(i);if(o.length!==r(a).length)return!1;for(let e of o)if(!K(a,e)||!Pv(i[e],a[e],n))return!1;return!0}var Mv=new Set([Array.prototype,Map.prototype,Set.prototype,Date.prototype,RegExp.prototype]);function Nv(e,t,n){return Mv.has(Object.getPrototypeOf(e))||jv(e,t,n,Sg)}function Pv(e,t,n){if(Object.is(e,t)&&!(n.strict&&Ov(e)))return!0;if(e===null||t===null||typeof e!=`object`||typeof t!=`object`||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;let r=n(e,t);if(r!==void 0)return r;if(e instanceof Map||e instanceof Set){let r=t;if(Tg(e)!==Tg(r))return!1;let i=e instanceof Map?Cg(e):wg(e),a=r instanceof Map?Cg(r):wg(r);for(let e=i.next(),t=a.next();!e.done;e=i.next(),t=a.next())if(!Pv(e.value,t.value,n))return!1;return Nv(e,t,n)}let i=Av(e,t,n);if(i!==void 0)return i;if(Array.isArray(e)){let r=t;if(e.length!==r.length)return!1;for(let t=0;t<e.length;t++)if(t in e!=t in r||!Pv(e[t],r[t],n))return!1;return Nv(e,t,n)}return jv(e,t,n)}function Fv(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&!vg(e)}function Iv(e,t,n){return n&&(Array.isArray(e)||Array.isArray(t))?Array.isArray(e)&&Array.isArray(t)&&Object.getPrototypeOf(e)===Object.getPrototypeOf(t):Fv(e)&&Fv(t)&&Object.getPrototypeOf(e)===Object.getPrototypeOf(t)}function Lv(e,t,n){let r=[],i=(e,t,i)=>{Object.is(t,i)||(Iv(t,i,n)?r.push({key:e,kind:`nested`,before:t,after:i}):Cv(t,i)||r.push({key:e,kind:`changed`,after:i}))};if(Array.isArray(t)){let n=e,a=t;for(let e=0;e<Math.min(n.length,a.length);e++){let t=String(e);e in n&&e in a?i(t,n[e],a[e]):e in n?r.push({key:t,kind:`deleted`,hole:!0}):e in a&&r.push({key:t,kind:`added`,after:a[e]})}let o=n.length;for(let e=n.length;e<a.length;e++){if(!(e in a))continue;let t=e-o;r.push({key:String(e),kind:`added`,after:a[e],...t?{gap:t}:{}}),o=e+1}for(let e=a.length;e<n.length;e++)r.push({key:String(e),kind:`deleted`});return a.length>o&&r.push({key:`length`,kind:`holes`,after:a.length-o}),r}for(let n of Object.keys(t))K(e,n)?i(n,e[n],t[n]):r.push({key:n,kind:`added`,after:t[n]});for(let n of Object.keys(e))K(t,n)||r.push({key:n,kind:`deleted`});return r}function Rv(e,t,n=!1){let r=[],i=new Set,a=new WeakMap,o=0;return(function e(t,s,c){if(i.has(s)){o++;return}if(a.get(s)?.has(t))return;i.add(s);let l=r.length,u=o;for(let i of Lv(t,s,n)){let n=[...c,i.key];i.kind===`nested`?e(i.before,i.after,n):r.push(i.kind===`deleted`?{path:n,deleted:!0,...i.hole?{hole:!0}:{}}:{path:n,deleted:!1,value:i.after,...i.kind===`added`&&Array.isArray(s)&&Number(i.key)>=t.length?{appended:!0,...i.gap?{gap:i.gap}:{}}:{}})}if(r.length===l&&o===u){let e=a.get(s)??new Set;e.add(t),a.set(s,e)}i.delete(s)})(e,t,[]),r}var zv=e=>JSON.stringify(e);function Bv(e,t){for(let n=1;n<=e.length;n++)if(t.has(zv(e.slice(0,n))))return!0;return!1}var Vv=(e,t)=>`\\0${e}${t}`,Hv=e=>e.startsWith(`\\0`);function Uv(e){let t=[];if(e instanceof Map){let n=0;for(let[r,i]of Cg(e))t.push([Vv(`k`,n),r],[Vv(`v`,n),i]),n++}else if(e instanceof Set){let n=0;for(let r of wg(e))t.push([Vv(`s`,n++),r])}else if(e instanceof Error)for(let n of[`cause`,`errors`])K(e,n)&&t.push([Vv(n===`cause`?`c`:`e`,0),e[n]]);else if(ArrayBuffer.isView(e))t.push([Vv(`b`,0),e.buffer]);else return;return t}function Wv(e,t){let n=e,r=0;for(let e=0;e<t.length;e++)if(Hv(t[e])){if(n=dv(n,t.slice(r,e)),!Ov(n))return;n=Uv(n)?.find(([n])=>n===t[e])?.[1],r=e+1}return r===t.length?n:dv(n,t.slice(r))}function Gv(e,t,n){let r=Wv(e,t.slice(0,-1)),i=/^\\0v(\\d+)$/.exec(t[t.length-1]);if(!(r instanceof Map)||!i)return!1;let a=[...Cg(r)][Number(i[1])];return a?(Dg(r,a[0],n),!0):!1}function Kv(e){return e instanceof Map||e instanceof Set||e instanceof Date||e instanceof RegExp?Sg(e):[]}function qv(e,t){return Object.getPrototypeOf(e)===Object.getPrototypeOf(t)&&(Kv(e).length>0||Kv(t).length>0)}function Jv(e,t=new Set,n=!1){let r=new Map,i=[];function a(e,t){let a=r.get(e);if(a){a.push(t);return}r.set(e,[t]),Fv(e)||Array.isArray(e)?o(e,t):(o(e,t,Kv(e)),n&&Uv(e)&&i.push([e,t]))}function o(e,n,r=Object.keys(e)){for(let i of r){let r=e[i];if(!Ov(r))continue;let o=[...n,i];t.has(zv(o))||a(r,o)}}o(e,[]);for(let[e,t]of i)for(let[n,r]of Uv(e))Ov(r)&&a(r,[...t,n]);return r}function Yv(e,t,n){return new Map([...Jv(e,t,n)].map(([e,t])=>[e,t[0]]))}function Xv(e){return[...Jv(e,void 0,!0).values()].filter(e=>e.length>1)}function Zv(e,t,n,r,i){let a=[],o=Uv(e),s=Uv(t);if(o&&s){if(Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;if(e instanceof Map||e instanceof Set){let n=Tg(t);if(Tg(e)!==n)return!1}let n=new Map(s);for(let[e,t]of o)n.has(e)&&a.push([e,t,n.get(e)])}let c=Iv(e,t,!0)?Object.keys(t):qv(e,t)?Kv(t):[];for(let n of c)K(e,n)&&a.push([n,e[n],t[n]]);return a.some(([e,t,a])=>{if(!Ov(t)||!Ov(a))return!1;let o=[...n,e],s=i.get(a);return zv(r.get(t))!==zv(s)||zv(s)===zv(o)&&Zv(t,a,o,r,i)})}function Qv(e,t){let n=Yv(e,void 0,!0),r=Yv(t,void 0,!0),i=[];return(function e(t,a,o){for(let s of Array.isArray(a)||Fv(a)?Object.keys(a):Kv(a)){if(!K(t,s))continue;let c=t[s],l=a[s];if(!Ov(c)||!Ov(l))continue;let u=[...o,s],d=n.get(c),f=r.get(l),p=zv(u);zv(d)===zv(f)?zv(f)===p&&Uv(c)&&Zv(c,l,u,n,r)&&i.push({path:u,deleted:!1,value:l,alias:!0}):i.push({path:u,deleted:!1,value:l,alias:!0}),((Fv(c)||Array.isArray(c))&&Iv(c,l,!0)||qv(c,l))&&zv(f)===p&&zv(d)===p&&e(c,l,u)}})(e,t,[]),i}function $v(e,t,n=!1){let r=Rv(e,t,n),i=new Set(r.map(e=>zv(e.path))),a=[];for(let n of Qv(e,t))Bv(n.path,i)||(i.add(zv(n.path)),a.push(n));return[...a,...r]}function ey(e,t){return Yv(e,new Set(t.map(e=>zv(e.path))),!0)}function ty(e,t){return new class extends Map{has(n){if(super.has(n))return!0;let r=e.get(n);if(!r)return!1;let i=Wv(t,r);return Ov(i)&&(Array.isArray(i)?Array.isArray(n):Object.getPrototypeOf(i)===Object.getPrototypeOf(n))?(super.set(n,i),!0):!1}}}function ny(e,t){let n=dv(e,t.path.slice(0,-1));if(typeof n!=`object`||!n)return t.deleted;let r=t.path[t.path.length-1];return K(n,r)?!t.deleted&&Cv(n[r],t.value):t.deleted}function ry(e,t,n){t.some(Hv)?Gv(e,t,n):hv(e,t,n)}function iy(e,t){let n=e;t.deleted?gv(n,t.path):hv(n,t.path,t.value)}var ay=new Set([`storyinit`,`beforerestart`,`actionsChanged`,`variableChanged`,`beforesave`,`aftersave`,`beforeload`,`afterload`,`beforenavigate`,`afternavigate`,`passagerender`,`dialogrender`]),oy=new Map;function sy(e,t){if(!ay.has(e))throw Error(`spindle: Unknown event \"${e}\".`);let n=oy.get(e);return n||(n=new Set,oy.set(e,n)),n.add(t),()=>{n.delete(t)}}function cy(e,t){let n=oy.get(e);if(n)for(let e of[...n])t(e)}function ly(e,...t){cy(e,e=>e(...t))}function uy(e,...t){cy(e,n=>{try{n(...t)}catch(t){console.error(`spindle: Error in ${e} handler:`,t)}})}var dy=null,fy=null;function py(e){dy=e}function my(e){fy=e}function hy(e){return Yl(()=>gy(e))}function gy(e){if(fy)try{let t=Function(`passage`,`variables`,fy)(e.passage,e.variables);if(typeof t==`string`&&t.trim())return t.trim()}catch{}if(dy)try{let t=dy(e);if(typeof t==`string`&&t.trim())return t.trim()}catch{}let t=new Date().toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`});return`${e.passage} - ${t}`}var _y=`spindle-saves`,vy=Promise.resolve();function yy(e){let t=vy.then(()=>Zy(_y,e));return vy=t.catch(()=>{}),t}function by(e){return(...t)=>yy(()=>e(...t))}var xy=e=>by(async t=>e(await(await cv()).getSave(t))),Sy=e=>by(async(t,n)=>e(await tb(t,n))),Cy=by(wy);async function wy(e,t=yt()){let n=await cv();return await Zy(`spindle-playthrough-count:${e}`,async()=>{let r=await Dy(e),i={id:t,ifid:e,createdAt:new Date().toISOString(),label:`Playthrough ${r}`};await n.putPlaythrough(i),await n.setMeta(Ey(e),r)}),await n.setMeta(Oy(e),t),Ob(e,t),t}var Ty=/^Playthrough (\\d+)$/;function Ey(e){return`${B_.playthroughCount}${e}`}async function Dy(e){let t=await cv(),n=await t.getMeta(Ey(e))??0;for(let r of await t.getPlaythroughsByIfid(e)){let e=Ty.exec(r.label);e&&(n=Math.max(n,Number(e[1])))}return n+1}function Oy(e){return`${B_.currentPlaythrough}${e}`}var ky=by(Ay);async function Ay(e,t){let n=await cv();await jy(e,t,new Date().toISOString());let r=Oy(e);await n.getMeta(r)!==t&&await n.setMeta(r,t),Ob(e,t)}async function jy(e,t,n){let r=await cv();(await r.getPlaythroughsByIfid(e)).some(e=>e.id===t)||await r.putPlaythrough({id:t,ifid:e,createdAt:n,label:`Imported`})}function My(e){return yy(async()=>{let t=await cv(),n=kb(e),r=n!==void 0&&(await t.getPlaythroughsByIfid(e)).some(e=>e.id===n)?n:await t.getMeta(Oy(e))??await wy(e);return Ob(e,r),{id:r,knownSaves:await vb(e)}})}function Ny(e,t,n,r){try{let i=n();return Yl(()=>ly(`beforesave`,e,t)),r(i()).then(t=>(Yl(()=>ly(`aftersave`,e)),t))}catch(e){return Promise.reject(e)}}function Py(e,t){let n=S_(t);return{meta:{...e,estimatedBytes:R_(n)},payload:n}}var Fy=by(Iy);async function Iy(e,t,n,r={}){let i=await t;if(!i)throw Error(`No playthrough`);let a=new Date().toISOString(),o=Py({id:yt(),ifid:e,playthroughId:i,createdAt:a,updatedAt:a,title:hy(n),passage:n.passage,custom:r},n);return await(await cv()).putSave(o),ub(e),o}var Ly=by(Ry);async function Ry(e,t,n,r){let i=await r,a=await cv(),o=await a.getSave(e);if(!o)return;let s=Py({...o.meta,...i?{playthroughId:i}:{},updatedAt:new Date().toISOString(),title:o.meta.userTitle===!0?o.meta.title:hy(t),passage:t.passage,...n==null?{}:{custom:{...o.meta.custom,...n}}},t);return await a.putSave(s),ub(s.meta.ifid),s}var zy=e=>e&&j_(e.payload),By=e=>j_(e);xy(zy);var Vy=xy(e=>e);function Hy(e){return yy(async()=>{let t=await cv(),n=await t.getSave(e);await t.deleteSave(e),n&&(await ib(n.meta.ifid,t=>t===e),ub(n.meta.ifid))})}function Uy(e,t){return yy(async()=>{let n=await cv(),r=await n.getSave(e);if(!r)return;let i={...r,meta:{...r.meta,title:t,userTitle:!0,updatedAt:new Date().toISOString()}};await n.putSave(i),ub(i.meta.ifid)})}var Wy=by(async function(e){let t=await cv(),[n,r]=await Promise.all([t.getSavesByIfid(e),t.getPlaythroughsByIfid(e)]),i=new Map;for(let e of r)i.set(e.id,e);let a=new Map;for(let e of n){let t=e.meta.playthroughId,n=a.get(t);n?n.push(e):a.set(t,[e])}for(let e of a.values())e.sort((e,t)=>new Date(t.meta.updatedAt).getTime()-new Date(e.meta.updatedAt).getTime());let o=[],s=[...i.values()].sort((e,t)=>new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime());for(let e of s){let t=a.get(e.id)??[];o.push({playthrough:e,saves:t})}for(let[t,n]of a)i.has(t)||o.push({playthrough:{id:t,ifid:e,createdAt:n[0]?.meta.createdAt??new Date().toISOString(),label:`Unknown Playthrough`},saves:n});return o}),Gy=B_.autosave,Ky=B_.slot,qy=B_.slotIndex;function Jy(e){return e!=null&&e!==``}function Yy(e,t){return Jy(t)?`${Ky}${t}.${e}`:`${Gy}${e}`}var Xy=e=>`${qy}${e}`;async function Zy(e,t){let n;try{n=navigator.locks}catch{}if(!n)return t();let r=!1;try{return await n.request(e,()=>(r=!0,t()))}catch(e){if(r)throw e;return t()}}async function Qy(e,t){let n=await cv();await Zy(`spindle-slot-index:${e}`,async()=>{let r=await n.getMeta(Xy(e))??[],i=t(r);i!==r&&await n.setMeta(Xy(e),i)})}async function $y(e){return[void 0,...(await(await cv()).getMeta(Xy(e))??[]).filter(Jy)]}async function eb(e,t){return(await cv()).getMeta(Yy(e,t))}async function tb(e,t){let n=await eb(e,t);return n?(await cv()).getSave(n):void 0}async function nb(e,t,n){await(await cv()).setMeta(Yy(e,t),n),Jy(t)&&await Qy(e,e=>e.includes(t)?e:[...e,t]),ub(e)}async function rb(e,t){await(await cv()).deleteMeta(Yy(e,t)),Jy(t)&&await Qy(e,e=>e.filter(e=>e!==t)),ub(e)}async function ib(e,t){for(let n of await $y(e)){let r=await eb(e,n);r&&t(r)&&await rb(e,n)}}var ab=`spindle.slots`,ob=`*`,sb;function cb(){if(sb===void 0)try{sb=new BroadcastChannel(ab),sb.unref?.()}catch{sb=null}return sb}var lb=new Set;function ub(e){for(let t of[...lb])(e===ob||t.ifid===e)&&t.onChange();try{cb()?.postMessage(e)}catch{}}function db(e,t,n=!1){let r={ifid:e,onChange:t};n&&lb.add(r);let i=cb(),a=n=>{(n.data===e||n.data===ob)&&t()},o=()=>{document.visibilityState===`visible`&&t()},s=typeof document>`u`?void 0:document;return i?.addEventListener(`message`,a),s?.addEventListener(`visibilitychange`,o),()=>{lb.delete(r),i?.removeEventListener(`message`,a),s?.removeEventListener(`visibilitychange`,o)}}var fb=e=>({isAutosave:!Jy(e),...Jy(e)?{slot:e}:{}});function pb(e,t){return{slot:Jy(t)?t:``,title:e.meta.title,passage:e.meta.passage,createdAt:e.meta.createdAt,updatedAt:e.meta.updatedAt,custom:e.meta.custom??{}}}function mb(e,t,n,r,i){return yy(async()=>{let a=await t,o=await eb(e,r);if(o){let e=await Ry(o,n,i,a);if(e)return e}let s=await Iy(e,a,n,{...fb(r),...i});return await nb(e,r,s.meta.id),s})}async function hb(e,t){return await tb(e,t)!==void 0}Sy(zy);function gb(e,t,n){return yy(async()=>{let r=await tb(e,t);if(!r)return;let i=j_(r.payload);n?.(i);let{playthroughId:a}=r.meta;return a&&await Ay(e,a),{payload:i,playthroughId:a}})}var _b=by(vb);async function vb(e){let t=Object.create(null);for(let n of await $y(e))await hb(e,n)&&(t[n??``]=!0);return t}var yb=by(bb);async function bb(e,t){let n=await tb(e,t);return n?pb(n,t):null}var xb=by(async e=>{let t=[];for(let n of await $y(e)){let r=await bb(e,n);r&&t.push(r)}return t}),Sb=by(async(e,t)=>{let n=await eb(e,t);n&&(await(await cv()).deleteSave(n),await rb(e,t))}),Cb=`spindle.session.`;function wb(e,t){let n=JSON.stringify(S_(t));try{sessionStorage.setItem(`${Cb}${e}`,n)}catch(e){return{error:e}}}function Tb(e){try{let t=sessionStorage.getItem(`${Cb}${e}`);return t?j_(JSON.parse(t)):void 0}catch(t){t instanceof g_&&(console.warn(`spindle: ${t.message}; the session was not restored.`),Eb(e));return}}function Eb(e){try{sessionStorage.removeItem(`${Cb}${e}`)}catch{}}var Db=`${Cb}playthrough.`;function Ob(e,t){try{sessionStorage.setItem(`${Db}${e}`,t)}catch{}}function kb(e){try{return sessionStorage.getItem(`${Db}${e}`)||void 0}catch{return}}function Ab(e){if(e)return{formatVersion:1,ifid:e.meta.ifid,exportedAt:new Date().toISOString(),save:e}}var jb=xy(Ab);async function Mb(e,t){if(I_(e),e.ifid!==t)throw Error(`Save is from a different story (expected IFID ${t}, got ${e.ifid})`);let n=Sv(e.save);return n.meta.id=yt(),n.meta.updatedAt=new Date().toISOString(),n.meta.ifid=t,await jy(t,n.meta.playthroughId,n.meta.createdAt),n}function Nb(e,t){return yy(async()=>{let n=await Mb(e,t);return await(await cv()).putSave(n),ub(t),n})}var Pb=Sy(Ab);function Fb(e,t,n){return yy(async()=>{let r=await Mb(e,t),{slot:i,...a}=r.meta.custom??{};r.meta.custom={...a,...fb(n)};let o=await cv(),s=await eb(t,n);return await o.putSave(r),await nb(t,n,r.meta.id),s&&await o.deleteSave(s),pb(r,n)})}var Ib=by(async function(e){let t=await cv(),n=await t.getSavesByIfid(e),r=await t.getPlaythroughsByIfid(e),i=0;for(let e of n)if(e.meta.estimatedBytes!=null)i+=e.meta.estimatedBytes;else{let n=R_(e.payload);e.meta.estimatedBytes=n,await t.putSave(e),i+=n}return{saveCount:n.length,playthroughCount:r.length,totalBytes:i,backend:t.type}});function Lb(e){return yy(async()=>{let t=await cv();await t.deleteSavesByIfid(e),await t.deletePlaythroughsByIfid(e),await t.deleteMetaByIfid(e),Eb(e),ub(e)})}var Rb=by(zb);async function zb(){await(await cv()).destroy(),lv();try{let e=[];for(let t=0;t<sessionStorage.length;t++){let n=sessionStorage.key(t);n?.startsWith(`spindle.session.`)&&e.push(n)}for(let t of e)sessionStorage.removeItem(t)}catch{}ub(ob)}function Bb(e,t,n){return yy(async()=>{let r=await cv(),i=await r.deleteSavesByPlaythrough(t);await r.deletePlaythroughById(t);let a=new Set(i);if(await ib(e,e=>a.has(e)),ub(e),n&&await n.current===t)return await wy(e,n.id),!0;let o=Oy(e);return await r.getMeta(o)===t&&await r.deleteMeta(o),!1})}var Vb=null;function Hb(){Vb&&(he(null,Vb),Vb.remove(),Vb=null)}function Ub(){Hb();let e=Q.getState();if(!e.storyData)return;let t=e.storyData.passages.get(`StoryInit`);if(t){let e=ls(t.content);Dl(e,`StoryInit`);let n=document.createElement(`div`);n.style.display=`none`,document.body.appendChild(n),Vb=n,he(b(()=>Sh(e),null),n),PS()}let n=e.storyData.passages.get(`SaveTitle`);n&&my(n.content)}function Wb(e){Ub();let t=e?mC(Q.getState().storyData,e):void 0;t!==void 0&&(console.warn(`spindle: discarding the saved session: the story no longer has the passage \"${t}\"`),e=void 0),e&&Q.getState().loadFromPayload(e),ly(`storyinit`),e||PS()}var Gb=[`variables`,`temporary`,`transient`],Kb=[];function qb(){return Kb[Kb.length-1]?.work}function Jb(){let e=Q.getState(),t=qb();return t?{...e,...t}:e}var Yb=e=>Sv(e,{keepUnregistered:!0});function Xb(e,t){let n=t?ty(t,e):new Map,r=(r,i)=>{let a=t?.get(i);if(!a||!jt(r))return r;let o=Ln(r);return a.some(Hv)||hv(e,a,o),n.set(i,o),o};return e=>Sv(e,{keepUnregistered:!0,seen:n,settle:r})}var Zb=e=>{let t=new Map;return n=>{let r=t.get(n);return r||(r=Xb(n,e?.(n)),t.set(n,r)),r}};function Qb(e){return Qt(Yb(e),!0)}function $b(e,t=new Set){if(typeof e!=`object`||!e||t.has(e))return!0;if(ArrayBuffer.isView(e)||e instanceof ArrayBuffer||!Object.isFrozen(e))return!1;if(t.add(e),e instanceof Map){for(let[n,r]of Cg(e))if(!$b(n,t)||!$b(r,t))return!1}else if(e instanceof Set){for(let n of wg(e))if(!$b(n,t))return!1}return Reflect.ownKeys(e).every(n=>{let r=Object.getOwnPropertyDescriptor(e,n);return!r||!(`value`in r)||$b(r.value,t)})}function ex(e){return $b(e)?e:Qb(e)}function tx(e,t,n=Kb,r=nx){let[i,a]=t.path;for(let o of n)for(let n of[o.work,o.base])try{iy(n,t.deleted?t:{...t,value:r(n)(t.value)})}catch{let t=e[i][a];K(e[i],a)?n[i][a]=Yb(jt(t)?Ln(t):t):delete n[i][a]}}var nx=e=>Xb(e),rx=new Set(Gb),ix=new Fn({autoFreeze:!1}),ax=!1;function ox(e,t){let n=[],r=e;for(let e of t){if(!Fv(r))break;let t=String(e);n.push(t),r=K(r,t)?r[t]:void 0}return n}function sx(e,t){let n=dv(e,t.slice(0,-1)),r=t[t.length-1];return Fv(n)&&K(n,r)?{path:t,deleted:!1,value:n[r]}:{path:t,deleted:!0}}function cx(e,t,n){if(n.some(e=>e.path.length===1))return[...new Set([...Object.keys(e),...Object.keys(t)])].filter(n=>!K(e,n)||e[n]!==t[n]).map(e=>sx(t,[e]));let r=new Set,i=[];for(let e of n){let n=ox(t,e.path.slice(1)),a=JSON.stringify(n);r.has(a)||(r.add(a),i.push(sx(t,n)))}return i}function lx(e){if(ax){ax=!1;return}if(Kb.length===0)return;px(hx());let t=Kb[Kb.length-1],n={...Q.getState(),variables:t.work.variables,temporary:t.work.temporary,transient:t.work.transient},[r,i]=ix.produceWithPatches(n,e),a=Gb.flatMap(e=>{let t=i.filter(t=>t.path[0]===e);return t.length?cx(n[e],r[e],t).map(t=>({...t,path:[e,...t.path]})):[]}),o=ey(fx(t.work),a),s=Zb(()=>o),c=(e,t)=>e.deleted?e:{...e,value:s(t)(e.value)};for(let e of a)iy(t.work,c(e,t.work));return e=>{let i=e;for(let e of Object.keys(r)){let t=r[e];!rx.has(e)&&t!==n[e]&&(i[e]=t)}let o=e;for(let e of a){let[n,r]=e.path;try{iy(o,c(e,o))}catch{K(t.work[n],r)?o[n][r]=Yb(t.work[n][r]):delete o[n][r]}tx(o,e,Kb,s)}}}function ux(e,t,n){let r=n.map(e=>zv(e.path).slice(0,-1));for(let[n,...i]of Xv(t)){let t=[n,...i].map(e=>zv(e).slice(0,-1));if(r.some(e=>t.some(t=>e.startsWith(t))))try{let t=Wv(e,n);if(typeof t!=`object`||!t)continue;for(let n of i)ry(e,n,t)}catch{}}}function dx(e){let t=new Map;return{variables:Sv(e.variables,{keepUnregistered:!0,seen:t}),temporary:Sv(e.temporary,{keepUnregistered:!0,seen:t}),transient:Sv(e.transient,{keepUnregistered:!0,seen:t})}}var fx=e=>({variables:e.variables,temporary:e.temporary,transient:e.transient});function px(e){let t=e.map(({scope:e,keepRunning:t})=>({scope:e,keepRunning:t,changes:mx(e.base,e.work)})),n=t.filter(({changes:e})=>e.length>0);if(n.length===0)return;for(let{scope:e,keepRunning:t}of n)t&&(e.base=dx(e.work));ax=!0;try{Q.getState().updateVariables(r)}finally{ax=!1}function r(e){t.forEach(({scope:n,changes:r},i)=>{let a=ey(n.work,r),o=Xb(e,a),s=t.slice(0,i).map(e=>e.scope),c=Zb(()=>a),l=new Set;for(let t of r){let[r,i]=t.path,a=zv([r,i]);if(!l.has(a))try{if(t.deleted){ny(e,t)||iy(e,t);continue}let n=t.alias?o(t.value):void 0;if(t.alias?Object.is(dv(e,t.path),n):ny(e,t))continue;iy(e,{...t,value:t.alias?n:o(t.value)})}catch{e[r][i]=o(n.work[r][i]),l.add(a)}}ux(e,n.work,r);for(let t of r)tx(e,t,s,c)})}}var mx=(e,t)=>$v(e,t),hx=()=>Kb.map(e=>({scope:e,keepRunning:!0}));function gx(e){let t=Q.getState(),n=fx(t),r=$v(e.base,n),i=Xb(e.work,ey(n,r));for(let t of r)try{iy(e.work,t.deleted?t:{...t,value:i(t.value)})}catch{let[r,a]=t.path;K(n[r],a)?e.work[r][a]=i(n[r][a]):delete e.work[r][a]}e.base=dx(t)}function _x(e){if(Kb.length===0)return e();px(hx());let t=Kb.splice(0);try{return e()}finally{Kb.push(...t);for(let e of t)gx(e)}}function vx(e){px(hx());let t=ey(fx(qb()??Q.getState()),[]),n=yx(),r=Xb(n.work,t);try{e(n.work,r)}finally{Kb.pop()}px([...hx(),{scope:n,keepRunning:!1}])}function yx(){let e=qb()??Q.getState(),t={work:dx(e),base:dx(e)};return Kb.push(t),t}function bx(e,t,n){let r=ws(Sv(t,{keepUnregistered:!0})),i=yx();try{bu(e,i.work.variables,i.work.temporary,r,i.work.transient)}finally{Kb.pop()}px([...hx(),{scope:i,keepRunning:!1}]);let a=new Set($v(t,r,!0).map(e=>e.path[0]));for(let e of Xv(r))if(e.some(e=>a.has(e[0])))for(let n of e)r[n[0]]!==t[n[0]]&&a.add(n[0]);for(let e of Object.keys(r))a.has(e)&&n(e,r[e]);for(let e of Object.keys(t))K(r,e)||n(e,void 0)}var xx=[],Sx=!1,Cx=[],wx=null,Tx=null;function Ex(e){let t=Jb();try{return!!yu(e,t.variables,t.temporary,{},t.transient)}catch{return!1}}function Dx(e,t,n){let r=typeof t==`function`,i=r?void 0:t,a=r?t:void 0,o={name:i?.name,condition:e,callback:a,options:i,lastResult:Ex(e),priority:i?.priority??0,macroKey:n};return xx.push(o),xx.sort((e,t)=>t.priority-e.priority),()=>{xx=xx.filter(e=>e!==o)}}function Ox(e,t){return Dx(e,t)}function kx(e,t){let n=Object.fromEntries(Object.entries(t).sort(([e],[t])=>e<t?-1:1)),r=JSON.stringify([e,n]);xx.some(e=>e.macroKey===r)||Dx(e,t,r)}function Ax(){return xx.filter(e=>e.macroKey!==void 0&&e.options).map(e=>({condition:e.condition,options:{...e.options}}))}var jx=new Set,Mx=0;function Nx(e,t){let n={condition:e,options:t};return jx.add(n),()=>{jx.delete(n)}}function Px(){return Mx++,()=>{Mx--}}function Fx(){return Mx>0}function Ix(e,t){xx=xx.filter(e=>e.macroKey===void 0);for(let{condition:t,options:n}of e)kx(t,n);if(t===!1)for(let{condition:e,options:t}of jx)kx(e,t)}function Lx(e){xx=xx.filter(t=>t.name!==e)}function Rx(e){let{callback:t,options:n}=e;if(t){t();return}if(n){if(n.run)try{bx(n.run,{},()=>{})}catch(t){console.error(`spindle: Error in watch run action for \"${e.condition}\":`,t)}n.dialog&&(Cx.push({passageName:n.dialog}),wx?.()),n.goto&&Q.getState().navigate(n.goto)}}var zx=10;function Bx(){for(let e=0;e<zx;e++){let e=!1,t=[...xx];for(let n of t){if(!xx.includes(n))continue;let t=Ex(n.condition),r=!n.lastResult;n.lastResult=t,t&&r&&(e=!0,n.options?.once&&(xx=xx.filter(e=>e!==n)),Rx(n))}if(!e)break}}function Vx(){if(!Sx){Sx=!0;try{Bx()}finally{Sx=!1}}}var Hx=0;function Ux(){if(Hx===0)return;let e=Sx;Sx=!0;try{Bx()}finally{Sx=e}}function Wx(){let e=Q.getState();Hx++;let t=Q.subscribe(t=>{let n=e;e=t,t.navigationId===n.navigationId&&(t.variables===n.variables&&t.temporary===n.temporary&&t.transient===n.transient&&t.renderCounts===n.renderCounts||Vx())}),n=!0;return()=>{n&&(n=!1,Hx--,t())}}function Gx(){for(let e of xx)e.lastResult=Ex(e.condition)}function Kx(){xx=[],qx++,oS(),Jx.notify()}var qx=0,Jx=Is();function Yx(){return qx}var Xx=Jx.subscribe;function Zx(e){return wx=e,Cx.length>0&&e(),()=>{wx===e&&(wx=null)}}function Qx(){return Cx.shift()}function $x(){return Cx.length}function eS(e){Tx?Tx.push(e):(Cx.push(e),wx?.())}function tS(){Cx=[]}function nS(e){return Tx=e,()=>{Tx===e&&(Tx=null)}}var rS=[];function iS(e){return rS.push(e),()=>{let t=rS.lastIndexOf(e);t>=0&&rS.splice(t,1)}}function aS(){let e=rS[rS.length-1];e?e():Tx?.close()}function oS(){tS();for(let e of[...rS].reverse())e();Tx?.closeAll()}function sS(){return rS.length>0||(Tx?.isOpen()??!1)}zn(),Bn();var cS=new Set([`StoryInit`,`StoryInterface`,`StoryVariables`,`StoryTransients`,`StoryLoading`,`SaveTitle`,`PassageReady`,`PassageHeader`,`PassageFooter`,`PassageDone`]),lS=q(),uS=[],dS=q();function fS(e,t){let n=[];for(let r of Object.keys(e))K(t,r)||n.push({key:r,deleted:!0});let r=new Map,i=e=>n.push({key:e,deleted:!1,value:Sv(t[e],{keepUnregistered:!0,seen:r})}),a=[];for(let n of Object.keys(t))!K(e,n)||!Object.is(e[n],t[n])?i(n):typeof t[n]==`object`&&t[n]!==null&&a.push(n);for(let e=r.size>0;e;){e=!1;for(let n of a){let o=new Map;if(Sv(t[n],{keepUnregistered:!0,seen:o}),[...o.keys()].some(e=>r.has(e))){i(n),a.splice(a.indexOf(n),1),e=!0;break}}}return{forward:n}}function pS(e,t){let n=Object.create(Object.getPrototypeOf(e));for(let t of Object.keys(e))xs(n,t,e[t]);for(let e of t)e.deleted?delete n[e.key]:xs(n,e.key,e.value);return n}function mS(e){let t=uS.length-1;t<0?lS=e:uS[t]=fS(_S(t),e)}function hS(e,t){let n=lS;for(let r=0;r<e;r++)r>0&&(n=pS(n,uS[r-1].forward)),t(n,r)}function gS(e,t){return{passage:e.passage,variables:t,timestamp:e.timestamp,prng:e.prng}}function _S(e){let t=lS;for(let n=0;n<e;n++)t=pS(t,uS[n].forward);return t}var vS=[];function yS(e){let{storyData:t,currentPassage:n,variables:r,history:i,historyIndex:a,visitCounts:o,renderCounts:s}=e();if(t){if(vS.length>i.length&&(vS.length=i.length),vS.length<i.length)if(i.length-vS.length===1){let e=i.length-1;vS[e]=gS(i[e],r)}else hS(i.length,(e,t)=>{t>=vS.length&&(vS[t]=gS(i[t],e))});return wb(t.ifid,{passage:n,variables:r,history:vS,historyIndex:a,visitCounts:o,renderCounts:s,prng:Xl(),watchers:Ax(),interfaceWatchers:Fx()})}}var bS=`The game could not be saved for a page reload; a reload goes back to the last passage it could save:`,xS=`The story could not go to another passage:`;function SS(e,t){let n;try{let t=yS(e);t&&Vs(bS,t.error)}catch(e){n={error:e},Vs(bS,e)}try{t?.()}finally{if(n)throw n.error}}function CS(e){let t=e.history.length-e.maxHistory;if(t<=0)return!1;let n=Math.min(e.historyIndex,t),r=n+e.maxHistory;for(let e=0;e<n;e++)lS=pS(lS,uS[e].forward);return e.history=e.history.slice(n,r),uS=uS.slice(n,r-1),vS=vS.slice(n,r),e.historyIndex-=n,!0}var wS=!1,TS=[],ES=null;function DS(e,t){let n=ES;if(ES=null,!n||e().navigationId!==n.navigationId)return;e().variables!==n.variables&&mS(e().variables),dS=e().variables;let r=Xl(),i=e().history[e().historyIndex].prng;(r?.seed!==i?.seed||r?.pull!==i?.pull)&&t(e=>{e.history[e.historyIndex].prng=r})}var OS=e=>({...e});function kS(e){lS=e,uS=[],dS=e,vS=[]}function AS(e){let t=q(Sv(e));return kS(Sv(t)),t}function jS(e){return q(Sv(e,{keepUnregistered:!0}))}function MS(e,t,n,r){e.currentPassage=t,e.navigationId++,e.variables=n,e.transient=jS(r),e.temporary=q(),e.history=[{passage:t,timestamp:Date.now()}],e.historyIndex=0}function NS(e,t,n){let{historyIndex:r,history:i}=e(),a=r+n;if(a<0||a>=i.length)return;DS(e,t);let o=e().currentPassage,s=i[a].passage;ly(`beforenavigate`,s);let c=Sv(_S(a));t(e=>{e.historyIndex+=n,e.currentPassage=e.history[e.historyIndex].passage,e.navigationId++,e.variables=c,e.temporary=q()}),Gx(),dS=e().variables,pC(e().history[e().historyIndex]),SS(e,()=>ly(`afternavigate`,s,o))}function PS(){let{history:e,historyIndex:t,variables:n}=Q.getState();if(e.length!==1||t!==0)return;kS(n);let r=Xl();Q.setState(e=>{e.history[0].prng=r})}var FS=Promise.resolve(``),IS=0,LS=!1;function RS(){return LS?``:Q.getState().playthroughId}function zS(){if(BS)return BS;let e=RS();return FS.then(t=>e||t)}var BS=null;function VS(e){Q.getState().playthroughId!==e&&Q.setState(t=>{t.playthroughId=e})}function HS(e){let t=++IS;return LS=!0,FS=e.then(e=>(t===IS&&(LS=!1,VS(e)),e)),FS}function US(e,t){++IS,LS=!1,FS=t.then(()=>e,()=>e),VS(e)}function WS(e){let t=yt();US(t,Cy(e,t).catch(e=>{console.error(`spindle: failed to start new playthrough`,e)}))}function GS(e,t){RS()!==t&&US(t,ky(e,t).catch(e=>{console.error(`spindle: failed to switch to the loaded playthrough`,e)}))}var KS=0,qS=0,JS=null,YS=null;function XS(){return++KS}function ZS(e){return qS>e}function QS(){eC(++KS)}var $S=Is();function eC(e){qS=e,$S.notify()}var tC=$S.subscribe,nC=[],rC=!1;function iC(e){rC&&nC.push(e)}function aC(){rC=!0}function oC(){for(let e of nC)e();nC=[],rC=!1}function sC(e){return typeof e==`string`&&e!==``?e:null}function cC(e){let{history:t,historyIndex:n}=e;if(!Number.isInteger(n))return;let r=t[n];if(!(!r||r.passage!==e.passage)&&!(typeof r.variables!=`object`||r.variables===null))return r}function lC(e,t,n){let r=e.history[e.historyIndex];if(!r)return;let i=$v(t,n,!0);if(i.length===0)return;let a=Sv(r.variables),o=ty(ey(n,i),a),s=e=>Sv(e,{seen:o});for(let e of i)uC(a,n,e,s);r.variables=Dv(r.variables,a)}function uC(e,t,n,r){let{path:i}=n,a=e,o=0;for(;o<i.length-1;o++){let e=i[o],n=K(a,e)?a[e]:void 0,s=dv(t,i.slice(0,o+1));if(!Iv(n,s,!0)){dC(a,e,r(s));return}a=n}let s=i[o];n.deleted?dC(a,s,void 0,n):dC(a,s,r(n.value),n)}function dC(e,t,n,r){let i=r?.deleted??!1;if(Array.isArray(e)){let a=Number(t);i?r&&`hole`in r?delete e[a]:e.length=Math.min(e.length,a):r&&`appended`in r?(e.length+=r.gap??0,e.push(n)):t===`length`&&r?e.length+=n:a<e.length&&(e[a]=n)}else i?delete e[t]:xs(e,t,n)}function fC(e){e?Kl(e.seed,e.pull):Jl()}function pC(e){e&&fC(e.prng)}function mC(e,t){if(e)return[t.passage,...t.history.map(e=>e.passage)].find(t=>!e.passages.has(t))}function hC(e,t){let n=mC(e,t);if(n!==void 0)throw Error(`The save refers to the passage \"${n}\", which this version of the story does not have`)}var gC=[`variables`,`temporary`,`transient`];function _C(e){for(let t of gC){let n=e[t];Cs(n)||(e[t]=q(jt(n)?Ln(n):n))}}var vC=[`navigate`,`goBack`,`goForward`,`restart`,`save`,`load`,`getSavePayload`,`loadFromPayload`];function yC(e){return(t,n,r)=>{let i=((e,n)=>{if(n){t(e,!0);return}let r=typeof e==`function`?e:t=>{Object.assign(t,e)},i=lx(r);t(e=>{(i??r)(e),_C(e)})});r.setState=i;let a=e(i,n,r);for(let e of vC){let t=a[e];a[e]=(...e)=>_x(()=>t(...e))}return a}}var bC=e=>Hn(yC(e));function xC(e){return e.catch(()=>{}),e}function SC(e,t,n){return xC(e.catch(e=>{throw console.error(t,e),n?.(e),e}))}function CC(e,t,n){e(e=>{let r=t??``;if(n)e.knownSaves={...e.knownSaves,[r]:!0};else{let{[r]:t,...n}=e.knownSaves;e.knownSaves=n}})}function wC(e,t){return _b(t).then(t=>{e(e=>{e.knownSaves=t})})}var TC;function EC(e,t,n,r){let i=n.then(()=>{t(e=>{e.knownSaves={}})});return e().restart(),SC(i,r)}var Q=vt()(bC((e,t)=>({storyData:null,currentPassage:``,navigationId:0,variables:q(),variableDefaults:{},transient:q(),transientDefaults:{},temporary:q(),history:[],historyIndex:-1,visitCounts:As(),renderCounts:As(),knownSaves:{},playthroughId:``,maxHistory:40,quickSaveKey:`F6`,quickLoadKey:`F9`,saveError:null,loadError:null,transitionConfig:null,nextTransition:null,nobr:!1,renderDeferred:!1,setMaxHistory:n=>{let r=!1;e(e=>{e.maxHistory=Math.max(1,Math.round(n)),r=CS(e)}),r&&SS(t)},setQuickSaveKey:t=>{e(e=>{e.quickSaveKey=sC(t)})},setQuickLoadKey:t=>{e(e=>{e.quickLoadKey=sC(t)})},init:(n,r={},i={})=>{let a=n.passagesById.get(n.startNode);if(!a)throw Error(`spindle: Start passage (pid=${n.startNode}) not found.`);let o=AS(r);e(e=>{e.storyData=n,e.playthroughId=``,e.variableDefaults=r,e.transientDefaults=i,MS(e,a.name,o,i),e.visitCounts=As(null,a.name),e.renderCounts=As(null,a.name)}),dS=t().variables,QS(),HS(My(n.ifid).then(({id:t,knownSaves:n})=>(e(e=>{e.knownSaves=n}),t)).catch(e=>(console.error(`spindle: failed to init save system`,e),``))),TC?.(),TC=db(n.ifid,()=>{wC(e,n.ifid).catch(()=>{})})},navigate:n=>{if(wS){TS.push(n);return}let{storyData:r}=t();if(!r)return;if(cS.has(n)){console.error(`spindle: Cannot navigate to special passage \"${n}\".`);return}if(!r.passages.has(n)){let e=Hs(n,t().currentPassage);console.error(`spindle: ${e.message}`),Vs(xS,e);return}let i=t().currentPassage;ly(`beforenavigate`,n);let a=fS(dS,t().variables);e(e=>{e.temporary=q(),e.currentPassage=n,e.navigationId++,e.history=e.history.slice(0,e.historyIndex+1),uS.length=e.historyIndex,vS.length>e.historyIndex+1&&(vS.length=e.historyIndex+1),uS.push(a),e.history.push({passage:n,timestamp:Date.now(),prng:Xl()}),e.historyIndex=e.history.length-1,CS(e),e.visitCounts=As(e.visitCounts,n),e.renderCounts=As(e.renderCounts,n)}),ES={navigationId:t().navigationId,variables:t().variables},wS=!0;try{Ux()}finally{wS=!1}let o=TS;TS=[],DS(t,e),SS(t,()=>{ly(`afternavigate`,n,i);for(let e of o)t().navigate(e)})},goBack:()=>NS(t,e,-1),goForward:()=>NS(t,e,1),setVariable:(t,n)=>{e(e=>{ys(t,`$${t}`),e.variables[t]=n})},setTemporary:(t,n)=>{e(e=>{ys(t,`_${t}`),e.temporary[t]=n})},deleteVariable:t=>{e(e=>{ys(t,`$${t}`),delete e.variables[t]})},deleteTemporary:t=>{e(e=>{ys(t,`_${t}`),delete e.temporary[t]})},setTransient:(t,n)=>{e(e=>{ys(t,`%${t}`),e.transient[t]=n})},deleteTransient:t=>{e(e=>{ys(t,`%${t}`),delete e.transient[t]})},updateVariables:t=>{e(e=>{t(e)})},trackRender:t=>{e(e=>{e.renderCounts=As(e.renderCounts,t)})},restart:()=>{let{storyData:n,variableDefaults:r,transientDefaults:i}=t();if(!n)return;let a=n.passagesById.get(n.startNode);if(!a)return;e(e=>{e.renderDeferred=!1}),ly(`beforerestart`),WS(n.ifid),QS();let o=t().renderDeferred;oC(),Jl(),Kx();let s=AS(r);e(e=>{MS(e,a.name,s,i),e.visitCounts=As(null,a.name),e.renderCounts=As(null,a.name),o||(e.renderDeferred=!1)}),dS=t().variables,aC(),Ub(),Eb(n.ifid),ly(`storyinit`),PS()},save:(n,r)=>{let{storyData:i}=t();if(!i)return Promise.resolve();let a=zS();return SC(Ny(n,r,t().beginSave,async t=>{e(e=>{e.saveError=null}),await mb(i.ifid,a,t,n,r),CC(e,n,!0)}),`spindle: failed to save`,t=>e(e=>{e.saveError=Fs(t,`Failed to save`)}))},load:n=>{let{storyData:r}=t();if(!r)return Promise.resolve();e(e=>{e.loadError=null});let i=zS(),a=gb(r.ifid,n,e=>hC(r,e)),o=HS(Promise.all([i,a.catch(()=>void 0)]).then(([e,t])=>t?.playthroughId||e)),s=++KS;return SC(a.then(async e=>{await o,e&&(qS>s||(JS=s,YS=i,t().loadFromPayload(e.payload,n)))}),`spindle: failed to load save`,t=>e(e=>{e.loadError=Fs(t,`Failed to load`)}))},hasSave:e=>{let{storyData:n,knownSaves:r}=t();return n?K(r,e??``):!1},getSaveInfo:async e=>{let{storyData:n}=t();return n?yb(n.ifid,e):null},listSaves:async()=>{let{storyData:e}=t();return e?xb(e.ifid):[]},deleteSave:n=>{let{storyData:r}=t();return r?SC(Sb(r.ifid,n).then(()=>CC(e,n,!1)),`spindle: failed to delete save`):Promise.resolve()},exportSave:async e=>{let{storyData:n}=t();return n?await Pb(n.ifid,e)??null:null},importSave:async(n,r)=>{let{storyData:i}=t();if(!i)throw Error(`spindle: Story is not initialized.`);let a=await Fb(n,i.ifid,r);return CC(e,r,!0),a},clearGameData:()=>{let{storyData:n}=t();return n?EC(t,e,Lb(n.ifid),`spindle: failed to clear game data`):Promise.resolve()},clearAllData:()=>EC(t,e,Rb(),`spindle: failed to clear all data`),deletePlaythrough:n=>{let{storyData:r}=t();if(!r)return Promise.resolve();let i=r.ifid,a=RS(),o=FS,s=yt(),c=Bb(i,n,{current:a||o,id:s});return n!==``&&n===a?US(s,c):a===``&&HS(c.then(e=>e?s:o,()=>o)),SC(c.then(()=>wC(e,r.ifid)),`spindle: failed to delete playthrough`)},getSavePayload:()=>{let{currentPassage:e,variables:n,history:r,historyIndex:i,visitCounts:a,renderCounts:o}=t(),s=[];return hS(r.length,(e,t)=>{let n=OS(e);s.push(gS(r[t],t===0?n:Dv(s[t-1].variables,n)))}),{passage:e,variables:Dv(s[i]?.variables,OS(n)),history:s,historyIndex:i,visitCounts:{...a},renderCounts:{...o},prng:Xl(),watchers:Ax(),interfaceWatchers:Fx()}},beginSave:()=>{let e=t().variables;return()=>{let n=t().getSavePayload();return lC(n,e,t().variables),n}},loadFromPayload:(n,r,i,a)=>{let o=JS??a;JS=null;let s=YS;YS=null;let c=o??++KS;if(n.history.length===0){console.warn(`loadFromPayload: rejecting payload with empty history`);return}hC(t().storyData,n),eC(c),BS=s;try{ly(`beforeload`,r)}finally{BS=null}let l=t().storyData?.ifid;i&&l&&GS(l,i);let u=cC(n),d=Sv(n.history.map(e=>e.variables)).map(e=>q(e));lS=Sv(d[0]),uS=d.slice(1).map((e,t)=>fS(d[t],e)),vS=n.history.map((e,t)=>gS(e,d[t])),e(e=>{e.currentPassage=n.passage,e.navigationId++,e.variables=q(Sv(u?.variables??n.variables)),e.history=n.history.map(e=>({passage:e.passage,timestamp:e.timestamp,prng:e.prng})),e.historyIndex=Math.max(0,Math.min(n.historyIndex,e.history.length-1)),CS(e),e.visitCounts=As(n.visitCounts),e.renderCounts=As(n.renderCounts),e.temporary=q(),e.transient=jS(t().transientDefaults)}),n.watchers&&Ix(n.watchers,n.interfaceWatchers),Gx(),dS=_S(t().historyIndex),fC(u?.prng===void 0?n.prng:u.prng),SS(t,()=>Yl(()=>ly(`afterload`,r)))},getHistoryVariables:e=>Sv(_S(e)),setTransition:t=>{e(e=>{e.transitionConfig=t})},setNextTransition:t=>{e(e=>{e.nextTransition=t})},consumeNextTransition:()=>{let n=t().nextTransition;return n!==null&&e(e=>{e.nextTransition=null}),n},deferRender:()=>{e(e=>{e.renderDeferred=!0})},clearDeferredRender:()=>{e(e=>{e.renderDeferred=!1})}}))),DC=`<header class=\"story-menubar\">{story-title}{back}{forward}{restart}{quicksave}{quickload}{saves}{settings}</header>\n{passage}`;function OC(){let{storyData:e}=Fl(`storyData`),t=e?.passages.get(`StoryInterface`),n=t===void 0?DC:t.content,r=t?.tags.includes(`nobr`)??!1,i=Pe(()=>{try{return J(S,{children:mh(ls(n))})}catch(e){return J(`span`,{class:`error`,children:[`Error in StoryInterface: `,Fs(e)]})}},[n]);return Ne(Px,[]),J(vm.Provider,{value:!0,children:r?J(_m.Provider,{value:!0,children:i}):i})}var kC=[`a[href]`,`area[href]`,`button:not([disabled])`,`input:not([disabled]):not([type=\"hidden\"])`,`select:not([disabled])`,`textarea:not([disabled])`,`iframe`,`audio[controls]`,`video[controls]`,`summary`,`[contenteditable]`,`[tabindex]`].join(`,`);function AC(e){for(let t=e.parentElement;t;t=t.parentElement)if(!(t.localName!==`details`||t.hasAttribute(`open`))&&!Array.from(t.children).find(e=>e.localName===`summary`)?.contains(e))return!0;return!1}function jC(e){let{visibility:t}=getComputedStyle(e);if(t===`hidden`||t===`collapse`)return!1;for(let t=e;t;t=t.parentElement)if(getComputedStyle(t).display===`none`)return!1;return!AC(e)}function MC(e){return!e.hidden&&!e.closest(`[hidden], [inert]`)&&!e.matches(`:disabled`)&&jC(e)}function NC(e){let t=e.getAttribute(`tabindex`);return t===null||!/^\\s*[+-]?\\d+\\s*$/.test(t)?null:parseInt(t,10)}function PC(e){let t=NC(e);if(t!==null&&t<0||e.hasAttribute(`contenteditable`)&&!e.matches(`a[href], button, input, select, textarea, iframe, summary`)&&(!e.isContentEditable||e.parentElement?.isContentEditable))return!1;if(e.localName===`summary`){let n=e.parentElement;if(n?.localName!==`details`||Array.from(n.children).find(e=>e.localName===`summary`)!==e)return t!==null}if(e instanceof HTMLInputElement&&e.type===`radio`&&e.name){let t=Array.from((e.form??e.getRootNode()).querySelectorAll(`input[type=\"radio\"]`)).filter(t=>t.name===e.name&&t.form===e.form&&(NC(t)??0)>=0&&MC(t));return e===(t.find(e=>e.checked)??t[0])}return!0}function FC(e){let t=Array.from(e.querySelectorAll(kC)).filter(e=>MC(e)&&PC(e)),n=e=>Math.max(NC(e)??0,0);return[...t.filter(e=>n(e)>0).sort((e,t)=>n(e)-n(t)),...t.filter(e=>n(e)===0)]}var IC=[];function LC(e,t,n,r){Ne(()=>{let n=e.current;if(!n)return;let r=document.activeElement instanceof HTMLElement?document.activeElement:null,i={panel:n};IC.push(i);let a=n.querySelector(t)??n;return(Array.from(n.querySelectorAll(`[autofocus]`)).find(MC)??FC(a)[0]??n).focus(),()=>{let e=IC.indexOf(i);e!==-1&&IC.splice(e,1);let t=document.activeElement;(!t||t===document.body||n.contains(t))&&r?.isConnected&&r.focus()}},[]),Ne(()=>{let t=e.current;if(!t)return;let i=()=>IC[IC.length-1]?.panel===t,a=(e,n)=>{let r=FC(t),i=r[0],a=r[r.length-1];if(!i||!a){t.focus();return}let o=e?r.indexOf(e):-1,s;if(o!==-1)s=r[o+(n?-1:1)];else if(e&&e!==t&&t.contains(e)){let t=t=>!!(e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING);s=n?r.filter(e=>!t(e)).pop():r.find(t)}else s=n?a:i;(s??(n?a:i)).focus()},o=null,s=e=>{if(!i())return;if(e.key===`Escape`){if(!n)return;e.preventDefault(),e.stopPropagation(),r();return}if(e.key!==`Tab`)return;let t=document.activeElement;if(t instanceof HTMLMediaElement&&t.controls){o={el:t,backwards:e.shiftKey};return}e.preventDefault(),a(t,e.shiftKey)},c=()=>{o=null},l=new AbortController,{signal:u}=l,d=new Map,f=e=>{let t=null;try{t=e.contentDocument}catch{}!t||d.get(e)===t||(d.set(e,t),t.addEventListener(`keydown`,n=>{if(!i())return;if(n.key!==`Tab`)return s(n);let r=Array.from(t.querySelectorAll(kC)).filter(e=>MC(e)&&PC(e)),o=t.activeElement,c=n.shiftKey?r[0]:r[r.length-1];(!c||o===c||o===t.body)&&(n.preventDefault(),a(e,n.shiftKey))},{signal:u}))},p=()=>{t.querySelectorAll(`iframe`).forEach(f)};t.addEventListener(`load`,e=>{e.target instanceof HTMLIFrameElement&&f(e.target)},{capture:!0,signal:u});let m=new MutationObserver(p);return m.observe(t,{childList:!0,subtree:!0}),p(),document.addEventListener(`keydown`,s,{signal:u}),document.addEventListener(`pointerdown`,c,{capture:!0,signal:u}),document.addEventListener(`focusout`,e=>{let t=o;!t||e.target!==t.el||e.relatedTarget||!i()||(o=null,a(t.el,t.backwards))},{signal:u}),document.addEventListener(`focusin`,e=>{let n=e.target;if(o&&n!==o.el&&i()){let{el:e,backwards:t}=o;o=null,a(e,t);return}!i()||!(n instanceof Node)||t.contains(n)||n===document.body||n===document.documentElement||a(null,!1)},{signal:u}),()=>{l.abort(),m.disconnect()}},[n,r])}var RC=ge(null);function zC({passageName:e,fallbackMarkup:t,panelClass:n,onClose:r,dismissible:i=!0,showCloseButton:a=i}){let o=j(r);o.current=r;let s=Fe(()=>o.current(),[]),{storyData:c}=Fl(`storyData`),l=e?c?.passages.get(e):void 0,u=l?.content??t,d=l?.tags.includes(`nobr`)??!1,f=Pe(()=>{if(!u)return J(`div`,{class:`error`,children:`Dialog: no content available`});try{let e=Sh(ls(u),d?{nobr:!0}:void 0);return d?J(_m.Provider,{value:!0,children:e}):e}catch(e){return J(`div`,{class:`error`,children:[`Error in dialog: `,Fs(e)]})}},[u,d]),p=j(null),m=wm();LC(p,`.dialog-body`,i,s),Ne(()=>iS(s),[s]),Ne(()=>{p.current&&uy(`dialogrender`,e??``,p.current)},[]);let h=e=>{i&&e.target===e.currentTarget&&s()},g=n?`dialog-panel ${n}`:`dialog-panel`;return J(RC.Provider,{value:s,children:J(`div`,{class:`dialog-overlay`,onClick:h,children:J(`div`,{ref:p,class:g,role:`dialog`,\"aria-modal\":`true`,tabIndex:-1,children:[a&&J(`button`,{type:`button`,class:`dialog-close`,\"aria-label\":`Close`,onClick:s,children:`✕`}),J(`div`,{class:`dialog-body`,children:J(Sm.Provider,{value:m,children:f})})]})})})}function BC(){let[e,t]=Ae([]),n=j(e);n.current=e;let r=Fe(e=>{t(t=>[...t,e])},[]),i=Fe(()=>{t(e=>e.slice(0,-1))},[]),a=Fe(()=>{t([])},[]);return Me(()=>nS({close:i,closeAll:a,push:r,isOpen:()=>n.current.length>0}),[i,a,r]),Me(()=>Zx(()=>{let e=[];for(;$x()>0;){let t=Qx();t&&e.push(t)}e.length>0&&t(t=>[...t,...e])}),[]),e.length===0?null:J(S,{children:e.map((e,t)=>J(zC,{passageName:e.passageName,panelClass:e.panelClass,onClose:i,showCloseButton:e.showCloseButton,dismissible:e.dismissible},`${e.passageName}-${t}`))})}function VC(){let[e,t]=Ae(Ws);return Me(()=>(t(Ws()),Gs(()=>t(Ws()))),[]),e.length===0?null:J(`div`,{class:`spindle-error-banners`,children:e.map(e=>J(`div`,{class:`spindle-error-banner`,role:`alert`,children:[J(`span`,{class:`spindle-error-banner-context`,children:e.context}),` `,J(`span`,{class:`spindle-error-banner-message`,children:e.message}),e.count>1&&J(`span`,{class:`spindle-error-banner-count`,children:` (×${e.count})`}),J(`button`,{type:`button`,class:`spindle-error-banner-dismiss`,\"aria-label\":`Dismiss`,onClick:()=>Us(e.id),children:`✕`})]},e.id))})}async function HC(){try{await Q.getState().save()}catch(e){Vs(`The game could not be saved:`,e)}}async function UC(){try{await Q.getState().load()}catch(e){Vs(`The saved game could not be loaded:`,e)}}function WC(){let{storyData:e,currentPassage:t,nobr:n}=Fl(`storyData`,`currentPassage`,`nobr`);if(Me(()=>{let e=e=>{let{quickSaveKey:t,quickLoadKey:n}=Q.getState();t!==null&&e.key===t?(e.preventDefault(),HC()):n!==null&&e.key===n&&(e.preventDefault(),UC())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[]),!e||!t)return J(`div`,{class:`loading`,children:`Loading...`});let r=J(S,{children:[J(OC,{}),J(BC,{}),J(VC,{})]});return J(_m.Provider,{value:n,children:r})}var GC=`http://www.w3.org/1999/xhtml`,KC=new Set([`area`,`base`,`basefont`,`bgsound`,`br`,`col`,`embed`,`frame`,`hr`,`img`,`input`,`keygen`,`link`,`meta`,`param`,`source`,`track`,`wbr`]);function qC(e){let t=``;for(let n of Array.from(e.childNodes))n.nodeType===Node.TEXT_NODE?t+=n.data:n.nodeType===Node.COMMENT_NODE?t+=`\\x3C!--${n.data}-->`:n.nodeType===Node.ELEMENT_NODE&&(t+=JC(n));return t}function JC(e){let t=e.localName,n=`<${t}`;for(let t of Array.from(e.attributes))n+=` ${t.name}=${YC(t.name,t.value)}`;if(n+=`>`,e.namespaceURI===GC&&KC.has(t))return n;let r=t===`template`?e.content:e;return`${n}${qC(r)}</${t}>`}function YC(e,t){let n=rs(e),r=n?`on`:`a`;return[`\"${t}\"`,`'${t}'`].find(e=>{let t;try{t=ds(`<i ${r}=${e}>`)}catch(e){if(e instanceof os)return!1;throw e}let n=t[0];return t.length===1&&n?.type===`html`&&n.attributes[r]===e.slice(1,-1)})??`\"${XC(t,n)}\"`}function XC(e,t){let n=e=>e.replace(/\"/g,`&quot;`);if(t)return is(e).map(e=>`text`in e?n(e.text):`expr`in e?`{${e.expr}}`:e.verbatim).join(``);let r;try{r=ds(e,{text:!0})}catch(t){if(t instanceof os)return n(e);throw t}return r.map(t=>{let r=e.slice(t.start,t.end);return t.type===`text`?n(r):r}).join(``)}function ZC(){let e=document.querySelector(`tw-storydata`);if(!e)throw Error(`spindle: No <tw-storydata> element found in the document.`);let 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||``,s=e.querySelector(`[type=\"text/twine-javascript\"]`)?.textContent||``,c=new Map,l=new Map;for(let t of e.querySelectorAll(`tw-passagedata`)){let e=parseInt(t.getAttribute(`pid`)||`0`,10),n=t.getAttribute(`name`)||``,r=(t.getAttribute(`tags`)||``).split(/\\s+/).filter(e=>e.length>0),i=qC(t),a={},o=new Set([`pid`,`name`,`tags`]);for(let e of t.attributes)o.has(e.name)||(a[e.name]=e.value);let s={pid:e,name:n,tags:r,metadata:a,content:i};c.set(n,s),l.set(e,s)}return{name:t,startNode:n,ifid:r,format:i,formatVersion:a,passages:c,passagesById:l,userCSS:o,userScript:s}}var QC=new Map,$C=q(),ew=!1,tw=null;function nw(){return`spindle.${Q.getState().storyData?.ifid||`unknown`}.settings`}function rw(){try{localStorage.setItem(nw(),JSON.stringify($C))}catch{}}function iw(){if(!ew){if(!Q.getState().storyData?.ifid){tw||(tw=Q.subscribe(e=>{e.storyData?.ifid&&(tw?.(),tw=null,iw())}));return}ew=!0;try{let e=localStorage.getItem(nw());if(e){let t=JSON.parse(e);typeof t==`object`&&t&&!Array.isArray(t)&&($C=q($C,t))}}catch{}}}function aw(e,t){QC.set(e,t),K($C,e)||($C[e]=t.config.default),iw()}function ow(e,t){let n=bs($C,e);return typeof n==typeof t?n:t}var sw={addToggle(e,t){aw(e,{type:`toggle`,config:t})},addList(e,t){aw(e,{type:`list`,config:t})},addRange(e,t){aw(e,{type:`range`,config:t})},get(e){return bs($C,e)},getToggle(e){return ow(e,!1)},getList(e){return ow(e,``)},getRange(e){return ow(e,0)},set(e,t){$C[e]=t,rw()},getAll(){return{...$C}},getDefinitions(){return QC},hasAny(){return QC.size>0}},cw=0,lw=4096,uw=[];function dw(e){uw.push({version:++cw,path:e}),uw.length>lw&&uw.shift()}function fw(e){dw([`variables`,...e])}var pw=ge(!1),mw=[`variables`,`temporary`,`transient`];function hw(e){let t=Jb();try{e()}finally{let e=Jb();for(let n of mw)if(t[n]!==e[n])for(let{path:r}of Rv(t[n],e[n],!0))dw([n,...r])}}function gw(){return cw}function _w(e,t){let n=new Set,r=new Map;for(let i=uw.length-1;i>=0&&uw[i].version>e;i--){let{path:e}=uw[i],a=t;e.forEach((t,i)=>{if(i===e.length-1&&typeof a==`object`&&a){let e=r.get(a)??new Set;e.add(t),r.set(a,e)}a=typeof a==`object`&&a?dv(a,[t]):void 0,typeof a==`object`&&a&&n.add(a)})}return(e,t,i)=>typeof t==`object`&&t?n.has(t):r.get(e)?.has(String(i))===!0}var vw=[`target`,`variable`,`options`,`value`,`disabled`],yw=new Map,bw=new Map;function xw(e,t,n){if(n)return n;let r=`${e}:${t}`,i=bw.get(r)??0,a;do i++,a=i===1?r:`${r}:${i}`;while(yw.has(a));return bw.set(r,i),a}function Sw(e){let t=e.id,n={action:e},r=yw.get(t);return r?(console.warn(`spindle: two mounted controls share the action ID \"${t}\"; Story.getActions() lists only the newer one.`),r.push(n)):yw.set(t,[n]),Dw(),{update(e){let r=yw.get(t);r?.includes(n)&&(n.action=e,r[r.length-1]===n&&Dw())},unregister(){let e=yw.get(t),r=e?e.indexOf(n):-1;!e||r===-1||(e.splice(r,1),e.length===0&&yw.delete(t),r===e.length&&Dw())}}}function Cw(){return Array.from(yw.values(),Tw)}function ww(e){let t=yw.get(e);return t&&Tw(t)}function Tw(e){return e[e.length-1].action}function Ew(){bw.clear()}function Dw(){ly(`actionsChanged`)}function Ow(e){let t=j(``),n=j(e.perform);n.current=e.perform,t.current||(t.current=xw(e.type,e.key,e.authorId));let r=t.current,i=()=>{let t={id:r,type:e.type,label:e.label,perform:(...e)=>n.current(...e)};for(let n of vw)e[n]!==void 0&&Object.assign(t,{[n]:e[n]});return t},a=j(null);Ne(()=>{let e=Sw(i());return a.current=e,()=>e.unregister()},[r]);let o=j(!1);return Ne(()=>{if(!o.current){o.current=!0;return}a.current?.update(i())},[e.type,e.label,e.target,e.variable,e.disabled,e.value,JSON.stringify(e.options)]),r}function kw(e){return e.map(e=>e.type===`text`?e.value:``).join(``)}function Aw(e,t){let n=`macro-${e}`;return t?`${n} ${t}`:n}var jw={useState:Ae,useRef:j,useEffect:Me,useLayoutEffect:Ne,useCallback:Fe,useMemo:Pe,useContext:M};function $(e,t=`builtin`){let n=e.parameters??[];fl(e.name,n);function r(t){let r=t.className,i=t.id,a;e.interpolate&&(a=Ru(),r=a(r),i=a(i));let{update:o,getValues:s}=M(gm),c=M(pw),l=Uu(),u=(e,t)=>Sh(e,{...l,...t}),d;try{d=Tc(t.rawArgs,n)}catch(t){if(t instanceof uc)return b(dm,{macro:e.name,error:t});throw t}let f={args:d,collectText:kw,sourceLocation:um,parseVarArgs:kc,extractOptions:Nc,h:b,renderNodes:u,renderInlineNodes:mh,hooks:jw,useAction:Ow,className:r,id:i,resolve:a,cls:Aw(e.name,r),mutate:c?e=>hw(()=>bx(e,s(),o)):e=>bx(e,s(),o),update:o,getValues:s,wrap:e=>Su(r,i,e)};if(e.merged){f.merged=Il();let e=f.merged;f.evaluate=t=>yu(t,e[0],e[1],e[2],e[3])}if(e.storeVar){let n=Oc(t.rawArgs).replace(/[\"']/g,``),r={\"%\":`transient variables`,_:`temporary variables`,\"@\":`locals`}[n.charAt(0)];if(r)return b(`span`,{class:`error`},`{${e.name}}: ${r} (${n}) cannot be bound to input macros`);let i=n.replace(/[\"']/g,``).replace(/^\\$/,``),a=i.split(`.`);if(a.includes(`__proto__`))return b(`span`,{class:`error`},`{${e.name}}: \"$${i}\" cannot be bound: ${_s} is reserved`);f.varName=i,f.value=Q(e=>dv(e.variables,a)),f.getValue=()=>dv(Jb().variables,a),f.setValue=e=>{fw(a),vx((t,n)=>{hv(t.variables,a,n(e),{createMissing:!0})})}}try{return e.render(t,f)}catch(t){if(t instanceof uc)return b(dm,{macro:e.name,error:t});throw t}}nl(e.name,r);let i=e.text;al(e.name,i&&((e,t)=>i(e,{...t,args:Tc(e.rawArgs,n)})));let a=e.block===!0||e.block!==!1&&(e.subMacros?.length??0)>0;if(hl(e.name,{name:e.name,block:a,subMacros:e.subMacros??[],storeVar:e.storeVar,interpolate:e.interpolate,merged:e.merged,description:e.description,parameters:e.parameters&&[...e.parameters],source:t}),e.subMacros)for(let t of e.subMacros)cl(t);a&&vr(e.name)}var Mw=null;function Nw(e){Mw=e}function Pw(){return Mw}var Fw=null,Iw=null;function Lw(){return Iw}var Rw=!1;function zw(){if(Rw)return;Rw=!0;let e=Q.getState().variables,t=Q.getState().transient;Q.subscribe(n=>{let r={},i=(e,t,n)=>{for(let i of Ds(e,t))r[n+i]={from:bs(e,i),to:bs(t,i)}};i(e,n.variables,``),i(t,n.transient,`%`),e=n.variables,t=n.transient,Object.keys(r).length>0&&ly(`variableChanged`,r)})}var Bw=null,Vw=null,Hw=new Set;function Uw(e,t=[]){Bw=new Set(e),Vw=new Set(t),Hw.clear()}function Ww(e){let t=e.startsWith(`%`),n=t||e.startsWith(`$`)?e.slice(1):e;return ys(n.split(`.`)[0],e),{isTransient:t,key:n}}function Gw(e,t){let n=e?Vw:Bw;if(!n)return;let r=t.split(`.`)[0];if(n.has(r))return;let i=(e?`%`:`$`)+r;Hw.has(i)||(Hw.add(i),console.warn(`spindle: Story.set() wrote ${i}, which is not declared in ${e?`StoryTransients`:`StoryVariables`}. Passages cannot reference it; check the name or declare it.`))}function Kw(e,t,n){let{isTransient:r,key:i}=Ww(t),a=r?e.transient:e.variables;i.includes(`.`)?hv(a,i.split(`.`),n):a[i]=n}function qw(e){return((...t)=>Q.getState()[e](...t))}function Jw(){return{get(e){let{isTransient:t,key:n}=Ww(e),r=qb(),i=r??Q.getState(),a=t?i.transient:i.variables,o=n.includes(`.`)?dv(a,n.split(`.`)):bs(a,n);return r?Qb(o):ex(o)},set(e,t){let n=typeof e==`string`?[[e,t]]:Object.entries(e);for(let[e]of n){let{isTransient:t,key:n}=Ww(e);Gw(t,n)}if(n.some(([e])=>e.includes(`.`))){vx((e,t)=>{for(let[r,i]of n)Kw(e,r,t(i))});return}Q.getState().updateVariables(e=>{for(let[t,r]of n)Kw(e,t,r)})},goto:qw(`navigate`),back:qw(`goBack`),forward:qw(`goForward`),restart:qw(`restart`),save:qw(`save`),load:qw(`load`),hasSave:qw(`hasSave`),getSaveInfo:qw(`getSaveInfo`),listSaves:qw(`listSaves`),deleteSave:qw(`deleteSave`),exportSave:qw(`exportSave`),importSave:qw(`importSave`),...mu(()=>Q.getState().visitCounts,()=>Q.getState().renderCounts),get title(){return Q.getState().storyData?.name||``},get passage(){return Q.getState().currentPassage},settings:sw,registerClass(e,t){jg(e,t)},defineMacro(e){$(e,`user`)},getMacroRegistry(){return _l()},saves:{setTitleGenerator(e){py(e)}},storage:{async getInfo(){let e=Q.getState().storyData?.ifid;return e?Ib(e):{saveCount:0,playthroughCount:0,totalBytes:0,backend:uv()}},async getQuota(){if(typeof navigator<`u`&&navigator.storage?.estimate)try{let e=await navigator.storage.estimate();return{usage:e.usage??0,quota:e.quota??0,estimateSupported:!0}}catch{}return{usage:0,quota:0,estimateSupported:!1}},clearGameData:qw(`clearGameData`),clearAllData:qw(`clearAllData`),deletePlaythrough:qw(`deletePlaythrough`),get backend(){return uv()}},getActions(){return Cw()},performAction(e,t){let n=ww(e);if(!n)throw Error(`spindle: Action \"${e}\" not found.`);if(n.disabled)throw Error(`spindle: Action \"${e}\" is disabled.`);n.perform(t)},on(e,t){e===`variableChanged`&&zw();let n=sy(e,t);return iC(n),n},async waitForActions(){await new Promise(e=>{requestAnimationFrame(()=>requestAnimationFrame(()=>e()))});let e=()=>Pw()===Q.getState().navigationId;return Pw()!==null&&!e()&&!Q.getState().renderDeferred&&await new Promise(t=>{let n=sy(`passagerender`,()=>{e()&&(n(),t())})}),Cw()},watch(e,t){return Ox(e,t)},unwatch(e){Lx(e)},openDialog(e,t){eS({passageName:e,panelClass:t?.panelClass,showCloseButton:t?.showCloseButton,dismissible:t?.dismissible})},closeDialog(){aS()},closeAllDialogs(){oS()},isDialogOpen(){return sS()},setNobr(e){Q.setState({nobr:e})},setCSS(e){let t=document.getElementById(`spindle-styles`);t&&(t.disabled=!e)},setTransition(e){Q.getState().setTransition(e)},setNextTransition(e){Q.getState().setNextTransition(e)},deferRender(){Q.getState().deferRender(),Iw??(Iw=new Promise(e=>{Fw=e}))},ready(){Fw&&(Q.getState().clearDeferredRender(),Fw(),Fw=null,Iw=null)},random(){return Zl()},randomInt(e,t){return Ql(e,t)},config:{get maxHistory(){return Q.getState().maxHistory},set maxHistory(e){Q.getState().setMaxHistory(e)},get quickSaveKey(){return Q.getState().quickSaveKey},set quickSaveKey(e){Q.getState().setQuickSaveKey(e)},get quickLoadKey(){return Q.getState().quickLoadKey},set quickLoadKey(e){Q.getState().setQuickLoadKey(e)}},prng:{init(e,t){Gl(e,t);let{historyIndex:n}=Q.getState();Q.setState(e=>{let t=e.history[n];t&&(t.prng=Xl())})},isEnabled(){return $l()},get seed(){return eu()},get pull(){return tu()}}}}function Yw(){window.Story=Jw()}var Xw=new Set([`StoryVariables`,`StoryTransients`,`SaveTitle`]),Zw=[`script`,`stylesheet`],Qw=new Set([`elseif`,`else`,`case`,`default`,`next`]);function $w(e){let t=e.file?` (${e.file}${e.fileLine?`:${e.fileLine}`:``})`:``;return`Passage \"${e.passage}\", line ${e.line}, column ${e.column}${t}: ${e.message}`}function eT(e,t){let n=Array.from({length:t.length+1},(e,t)=>t);for(let r=1;r<=e.length;r++){let i=[r];for(let a=1;a<=t.length;a++)i[a]=Math.min(n[a]+1,i[a-1]+1,n[a-1]+(e[r-1]===t[a-1]?0:1));n=i}return n[t.length]}function tT(e,t){let n=e.toLowerCase(),r,i=Math.max(2,Math.floor(n.length/3))+1;for(let e of t){let t=eT(n,e.toLowerCase());t<i&&(r=e,i=t)}return r}var nT=(e,t)=>e?` Did you mean ${t(e)}?`:``,rT=` (a passage name is a quoted string or an expression)`,iT=/^[A-Za-z][\\w$]*$/;function aT(e){try{return wl(e).name.toLowerCase()||void 0}catch{return}}function oT(e,t){let n=[],r=t.isBlockMacro?{isBlock:t.isBlockMacro}:void 0,i=(e,t,r,i,a,o)=>{let{line:s,column:c}=Cr(e.content,t),l={passage:e.name,line:s,column:c,message:a,code:i,start:t,end:r};o&&(l.data=o);let u=e.metadata?.[`data-source-file`];if(u){l.file=u;let t=Number(e.metadata?.[`data-source-line`]);t&&(l.fileLine=t+s)}n.push(l)},a=(e,t,n)=>i(e,t.offset,t.end,t.code,n+t.reason,t.data),o=[],s=new Set,c=new Set;for(let n of e){if(c.add(n.name),Xw.has(n.name)||n.tags?.some(e=>Zw.includes(e)))continue;let e=!t.only||t.only(n);try{let t=ds(n.content);for(let e of t){if(e.type!==`macro`||e.isClose||e.name.toLowerCase()!==`widget`)continue;let t=aT(e.rawArgs);t&&s.add(t)}if(!e)continue;ls(n.content,{hooks:r}),o.push([n,t])}catch(t){if(!(t instanceof os))throw t;e&&a(n,t,``)}}let l=[...t.macroNames??[],...s],u=(e,n,r)=>{for(let a of n){if(a.type!==`macro`||a.isClose)continue;let n=a.name.toLowerCase();if(Qw.has(n)||s.has(n)||t.isKnownMacro(n))continue;let o=tT(a.name,l);i(e,a.start,a.end,`unknown-macro`,`${r}Unknown macro {${a.name}}.${nT(o,e=>`{${e}}`)}`,{name:a.name,suggestions:o?[o]:[]})}},d=t.parametersOf??(()=>void 0),f=(e,n)=>{u(e,n,``);let r=0;for(let o of qc(e.content,n,d,{isBlock:t.isBlockMacro})){if(o.nested&&o.offset<r)continue;let n=o.offset,s=o.where&&o.nested?o.where:``;switch(o.kind){case`argument-error`:i(e,n,n+o.length,`argument-error`,`${s}${o.message} in ${o.label}`,{macro:o.macro});break;case`passage`:if(t.checkPassageNames!==!1&&!c.has(o.name)){let t=tT(o.name,c);i(e,n,n+o.length,`unknown-passage`,`${s}No passage named ${JSON.stringify(o.name)} in ${o.label}.${nT(t,JSON.stringify)}`,{name:o.name,macro:o.macro,suggestions:t?[t]:[]})}break;case`code`:p(e,o,s);break;case`text`:o.errors.length>0?(a(e,o.errors[0],o.where),r=Lc(o,o.text.length)):u(e,o.tokens,o.where)}}},p=(e,t,n)=>{let r=t.offset,a=Ic(t.code,t.goal),o=t.code.trim();if(a instanceof xo){let o=/^(?:[\\w$]+|\\S)/.exec(t.code.slice(a.pos));i(e,Lc(t,a.pos),Lc(t,a.pos+(o?.[0].length??0)),`code-syntax`,`${n}${a.reasonIn(e.content,r)} in ${t.label}`+(t.passage?rT:``),t.macro?{macro:t.macro}:void 0)}else if(t.passage&&iT.test(o)){let r=t.code.length-t.code.trimStart().length;i(e,Lc(t,r),Lc(t,r+o.length),`unquoted-passage-name`,`${n}Unquoted passage name in ${t.label}: write ${JSON.stringify(o)}${rT}`,{name:o,macro:t.macro??``})}};for(let[e,t]of o)Fc(()=>f(e,t));return n}var sT=/(?:0[xX][\\da-fA-F_]+|0[bB][01_]+|0[oO][0-7_]+|(?:\\d[\\d_]*\\.?[\\d_]*|\\.\\d[\\d_]*)(?:[eE][+-]?\\d+)?)(n?)/y,cT=/[A-Za-z_$][\\w$]*/y,lT=/(?:async\\s+)?(?:\\((?:[^()]|\\([^()]*\\))*\\)|[A-Za-z_$][\\w$]*)\\s*=>/y;function uT(e){let t=new dT(e),n=t.value();return t.space(),t.i===e.length?n:void 0}var dT=class{constructor(e){this.src=e,this.i=0}space(){let{src:e}=this;for(;;){for(;/\\s/.test(e.charAt(this.i));)this.i++;if(e.startsWith(`//`,this.i)){let t=e.indexOf(`\n`,this.i);this.i=t<0?e.length:t}else if(e.startsWith(`/*`,this.i)){let t=e.indexOf(`*/`,this.i+2);this.i=t<0?e.length:t+2}else return}}value(){let{src:e}=this;this.space();let t=e.charAt(this.i);if(t===`\"`||t===`'`)return this.string().closed?{shape:{type:`string`}}:void 0;if(t===\"`\")return this.template();if(t===`[`)return this.skipBalanced()?{shape:{type:`array`}}:void 0;if(t===`{`)return this.object();if(/[\\d.+-]/.test(t))return this.number();if(/[A-Za-z_$(]/.test(t))return this.word()}string(){let{end:e,closed:t}=Yo(this.src,this.i),n=this.src.slice(this.i+1,t?e-1:e);return this.i=e,{body:n,closed:t}}template(){let{src:e}=this;for(let t=this.i+1;t<e.length;t++){let n=e.charAt(t);if(n===`\\\\`)t++;else if(n===\"`\")return this.i=t+1,{shape:{type:`string`}};else if(n===`$`&&e.charAt(t+1)===`{`)return}}number(){let{src:e}=this,t=this.i;if(e.charAt(t)===`+`||e.charAt(t)===`-`)for(t++;/\\s/.test(e.charAt(t));)t++;sT.lastIndex=t;let n=sT.exec(e);if(n)return this.i=sT.lastIndex,n[1]?{unsupported:`bigint`}:{shape:{type:`number`}};if(cT.lastIndex=t,cT.exec(e)?.[0]===`Infinity`)return this.i=cT.lastIndex,{shape:{type:`number`}}}word(){let{src:e}=this;if(lT.lastIndex=this.i,lT.test(e))return this.function();cT.lastIndex=this.i;let t=cT.exec(e)?.[0];if(t===void 0)return;let n=cT.lastIndex;switch(t){case`true`:case`false`:return this.i=n,{shape:{type:`boolean`}};case`null`:return this.i=n,{shape:{type:`null`}};case`NaN`:return this.i=n,{shape:{type:`number`}};case`undefined`:return this.i=n,{unsupported:`undefined`};case`function`:case`class`:case`async`:return this.function()}}function(){return this.unsupported({unsupported:`function`})}unsupported(e){return this.i=this.src.length,e}object(){let{src:e}=this,t=new Map;for(this.i++;;){this.space();let n=e.charAt(this.i);if(n===`}`)return this.i++,{shape:{type:`object`,fields:t}};if(n===`,`){this.i++;continue}if(this.i>=e.length)return;let r=this.key();if(this.space(),r!==void 0&&e.charAt(this.i)===`:`){this.i++;let n=this.i,i=this.value();if(this.space(),i&&`unsupported`in i)return this.unsupported(i);if(i&&`,}`.includes(e.charAt(this.i))){t.set(r,i.shape);continue}this.i=n}else if(r!==void 0&&e.charAt(this.i)===`(`)return this.unsupported({unsupported:`function`});if(!this.skipMember())return}}key(){let{src:e}=this,t=e.charAt(this.i);if(t===`\"`||t===`'`){let{body:e,closed:t}=this.string();return t?e:void 0}let n=/[\\w$]+/y;n.lastIndex=this.i;let r=n.exec(e)?.[0];if(r!==void 0)return this.i=n.lastIndex,r}skipMember(){let{src:e}=this;for(;this.i<e.length;){let t=e.charAt(this.i);if(t===`,`||t===`}`)return!0;if(!this.skipOne())return!1}return!1}skipBalanced(){let{src:e}=this,t={\"[\":`]`,\"{\":`}`,\"(\":`)`}[e.charAt(this.i)];if(!t)return!1;for(this.i++;this.i<e.length;){if(e.charAt(this.i)===t)return this.i++,!0;if(!this.skipOne())return!1}return!1}skipOne(){let{src:e}=this,t=e.charAt(this.i);return t===`\"`||t===`'`?this.string().closed:t===\"`\"?this.skipTemplate():e.startsWith(`//`,this.i)||e.startsWith(`/*`,this.i)?(this.space(),!0):t===`[`||t===`{`||t===`(`?this.skipBalanced():t===`]`||t===`}`||t===`)`?!1:(this.i++,!0)}skipTemplate(){let{src:e}=this;for(this.i++;this.i<e.length;){let t=e.charAt(this.i);if(t===`\\\\`)this.i+=2;else if(t===\"`\")return this.i++,!0;else if(t===`$`&&e.charAt(this.i+1)===`{`){if(this.i++,!this.skipBalanced())return!1}else this.i++}return!1}};function fT(e,t){try{return ds(e,{text:t})}catch(e){if(e instanceof os)return[];throw e}}function pT(e){let t=e.replace(/[.*+?^${}()|[\\]\\\\]/g,`\\\\$&`);return RegExp(`^${t}(\\\\w+)\\\\s*=\\\\s*(.+)$`)}var mT=/\\$(\\w+(?:\\.\\w+)*)/y,hT=/^[\"']\\$(\\w+(?:\\.\\w+)*)[\"']?$/,gT=new Set([`number`,`string`,`boolean`]),_T={string:Object(``),number:Object(0),boolean:Object(!1)};function vT(e,t=new Map){if(Array.isArray(e))return{type:`array`};if(e===null)return{type:`null`};if(typeof e==`object`){let n=t.get(e);if(n)return n;let r=new Map,i={type:`object`,fields:r};t.set(e,i);for(let[n,i]of Object.entries(e))r.set(n,vT(i,t));return i}let n=typeof e;if(!gT.has(n))throw Error(`Unsupported type \"${n}\" for value ${String(e)}. Expected number, string, boolean, array, or object.`);return{type:n}}var yT=`Expected number, string, boolean, array, or object.`;function bT(e){if(!e.fields)return{type:e.type};let t=new Map;for(let[n,r]of e.fields)t.set(n,bT(r));return{type:e.type,fields:t}}function xT(e,t=`$`){let n=[],r=[],i=pT(t),a=new Set,o=0;for(let s of e.split(`\n`)){let e=o+s.length-s.trimStart().length;o+=s.length+1;let c=s.trim();if(!c)continue;let l=c.match(i),u=(e,t,n,i)=>r.push({code:e,offset:t,end:n,message:i});if(!l){u(`invalid-declaration`,e,e+c.length,`Invalid declaration: \"${c}\". Expected: ${t}name = value`);continue}let[,d,f]=l,p=e+t.length,m=p+d.length,h=vs(d,t+d);if(h){u(`invalid-name`,p,m,h);continue}let g=e+c.length,_={name:d,nameStart:p,nameEnd:m,valueStart:g-f.length,valueEnd:g};a.has(d)&&u(`duplicate-declaration`,p,m,`Duplicate declaration of ${t}${d}`),a.add(d);let v=uT(f);v&&`shape`in v?_.schema=bT(v.shape):v&&u(`unsupported-value`,_.valueStart,g,`Unsupported type \"${v.unsupported}\" for value ${f}. ${yT}`),n.push(_)}return{declarations:n,errors:r}}function ST(e,t=`$`){let n=new Map,r=t===`%`?`StoryTransients`:`StoryVariables`,{declarations:i,errors:a}=xT(e,t),o=[...a.filter(e=>e.code===`invalid-declaration`||e.code===`invalid-name`).map(e=>({at:e.offset,error:e})),...i.map(e=>({at:e.nameStart,declaration:e}))].sort((e,t)=>e.at-t.at);for(let i of o){if(`error`in i)throw Error(`${r}: ${i.error.message}`);let{name:a,valueStart:o,valueEnd:s}=i.declaration,c=e.slice(o,s),l;try{l=Function(`return (`+c+`)`)()}catch(e){throw Error(`${r}: Failed to evaluate \"${t}${a} = ${c}\": ${Fs(e)}`)}let u;try{u=vT(l)}catch(e){throw Error(`${r}: ${Fs(e)}`)}n.set(a,{...u,name:a,default:l})}return n}function CT(e,t){let n=e.split(`.`),r=n[0],i=vs(r,`$`+r);if(i)return i;let a=t.get(r);if(!a)return`Undeclared variable: $${e}`;let o=a;for(let e=1;e<n.length;e++){let t=n[e];if(o.type===`array`||o.type===`null`)return null;let r=_T[o.type];if(r&&t in r){let e=typeof r[t];if(!gT.has(e))return null;o={type:e};continue}if(o.type!==`object`||!o.fields)return`Cannot access field \"${t}\" on $${n.slice(0,e).join(`.`)} (type: ${o.type})`;let i=o.fields.get(t);if(!i)return null;o=i}return null}var wT=[`checkbox`,`cycle`,`listbox`,`numberbox`,`radiobutton`,`textarea`,`textbox`],TT=new Set;function ET(e,t){for(let n of is(e))`expr`in n&&OT(n.expr,t)}function DT(e,t,n=TT){e.includes(`{`)&&MT(e,fT(e,!0),n,t)}function OT(e,t,n=`expression`){let r=Ic(e,n);if(r instanceof xo){kT(e,t,n);return}for(let n of r.refs)n.sigil===`$`&&(mT.lastIndex=n.start,t(mT.exec(e)[1]))}function kT(e,t,n){Uo(e,{variable(n,r,i){n===`$`&&(mT.lastIndex=i,t(mT.exec(e)[1]))},literal(){}},n)}function AT(e,t,n,r){Fc(()=>MT(e,fT(e,!1),t,n,r))}function jT(e,t,n){if(e.rawArgs){if(t){let r=[...Zc(e.rawArgs,0,t,e.name,``)];if(!r.some(e=>e.kind===`argument-error`)){for(let e of r)e.kind===`code`?OT(e.code,n,e.goal):e.kind===`text`&&DT(e.text,n);return}}OT(e.rawArgs,n)}}function MT(e,t,n,r,i=()=>void 0){for(let a=0;a<t.length;a++){let o=t[a];if(o.type===`variable`)o.scope===`variable`&&o.name&&r(o.name);else if(o.type===`link`)DT(o.display,r);else if(o.type===`expression`)OT(o.expression,r);else if(o.type===`html`)for(let[e,t]of Object.entries(o.attributes))rs(e)?ET(t,r):DT(t,r,n);else if(o.type===`macro`&&!o.isClose){if(jT(o,i(o.name),r),o.className&&DT(o.className,r),o.id&&DT(o.id,r),n.has(o.name.toLowerCase())){let e=o.rawArgs.trim().split(/\\s+/)[0]??``,t=hT.exec(e);t?r(t[1]):/^[\"'`]/.test(e)||OT(e,r)}if(o.name.toLowerCase()===`do`){let n=a+1;for(;n<t.length;){let e=t[n];if(e.type===`macro`&&e.isClose&&e.name.toLowerCase()===`do`)break;n++}n<t.length&&(OT(e.slice(o.end,t[n].start),r,`statements`),a=n)}}}}function NT(e,t,n=wT,r=gl){let i=[],a=new Set(Array.from(n,e=>e.toLowerCase()));for(let[n,o]of e)Xw.has(n)||AT(o.content,a,e=>{let r=CT(e,t);r&&i.push(`Passage \"${n}\": ${r}`)},r);return i}function PT(e){let t=q();for(let[n,r]of e)t[n]=r.default;return t}var FT=new WeakMap;function IT(e){let t=FT.get(e);if(t&&t.content===e.content)return t.ast;let n=ls(e.content);return FT.set(e,{content:e.content,ast:n}),n}function LT(e){return Sh(IT(e),e.tags.includes(`nobr`)?{nobr:!0}:void 0)}function RT(e){if(!e)return null;try{return LT(e)}catch(t){return console.error(`spindle: Error in ${e.name}:`,t),null}}var zT=new Set([`PassageReady`,`PassageHeader`,`PassageFooter`,`PassageDone`]);function BT({passage:e,dataTransition:t,navigationId:n}){let{storyData:r}=Fl(`storyData`),i=zT.has(e.name),[a,o]=Ae(!1),s=Pe(()=>{try{return LT(e)}catch(t){return J(`div`,{class:`error`,children:[`Error parsing passage “`,e.name,`”`,lm(e),`: `,Fs(t)]})}},[e.content,e.name]),c=e=>i?void 0:r?.passages.get(e),l=c(`PassageHeader`),u=c(`PassageFooter`),d=c(`PassageDone`),f=Pe(()=>RT(l),[l?.content]),p=Pe(()=>RT(u),[u?.content]);Me(()=>(d&&o(!0),()=>o(!1)),[e.name]);let m=Pe(()=>a?RT(d):null,[a,d?.content]),h=j(null);Ne(()=>{n!==void 0&&Nw(n),h.current&&uy(`passagerender`,e.name,h.current)},[e.name,n]);let g=e.tags.includes(`nobr`),_=wm(),v=J(Sm.Provider,{value:_,children:J(`div`,{ref:h,class:`passage`,\"data-passage\":e.name,\"data-tags\":e.tags.join(` `),\"data-transition\":t,children:[f&&J(`div`,{class:`passage-header`,children:f}),s,p&&J(`div`,{class:`passage-footer`,children:p}),m&&J(`div`,{hidden:!0,children:m})]})});return g?J(_m.Provider,{value:!0,children:v}):v}var VT=new Set([`none`,`fade`,`fade-through`,`crossfade`]),HT={type:`fade-through`,duration:300,pause:50};function UT(e){let t=e.find(e=>e.startsWith(`transition:`));if(!t)return null;let n=t.slice(11);if(!VT.has(n))return console.warn(`Unknown transition type: \"${n}\"`),null;let r={type:n};for(let t of e)if(t.startsWith(`duration:`)){let e=Number(t.slice(9));Number.isNaN(e)||(r.duration=e)}else if(t.startsWith(`pause:`)){let e=Number(t.slice(6));Number.isNaN(e)||(r.pause=e)}return r}function WT(e){return{type:e.type,duration:e.duration??HT.duration,pause:e.pause??HT.pause}}function GT(e,t,n){let r=UT(e);return r?WT(r):t?WT(t):n?WT(n):{...HT}}function KT(e,t){let n=e.cloneNode(!0);n.removeAttribute(`id`);let r=n.querySelectorAll(`[id]`);for(let e=0;e<r.length;e++)r[e].removeAttribute(`id`);n.style.pointerEvents=`none`,n.style.userSelect=`none`,n.setAttribute(`inert`,``),n.setAttribute(`aria-hidden`,`true`);let i=n.querySelectorAll(`audio, video`);for(let e=0;e<i.length;e++){let t=i[e];t.pause?.(),t.muted=!0}return n.classList.remove(`passage`),n.classList.add(`passage-snapshot`),n.setAttribute(`data-transition`,t),n}function qT(e,t){e.style.setProperty(`--passage-in-duration`,`${t.duration/1e3}s`),e.style.setProperty(`--passage-out-duration`,`${t.duration/1e3}s`),e.style.setProperty(`--passage-pause`,`${t.pause/1e3}s`)}function JT(e,t){if(!e)return null;qT(e,t);let n=e.querySelector(`.passage`);return n?KT(n,t.type):null}function YT(e){if(!e)return;e.classList.remove(`passage-container--crossfading`);let t=e.querySelectorAll(`.passage-snapshot`);for(let e=0;e<t.length;e++)t[e].remove()}var XT=new Map,ZT=new Set;function QT(){let e=()=>{let{navigationId:e,renderDeferred:t}=Q.getState();return!t&&[...XT.values()].every(t=>t===e)};return e()?Promise.resolve():new Promise(t=>{let n=()=>{e()&&(ZT.delete(n),t())};ZT.add(n)})}function $T(e){let t=e?.querySelector(`.passage`);t&&t.getBoundingClientRect().top<0&&t.scrollIntoView?.({block:`start`})}function eE(e){return window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches?{...e,duration:Math.min(e.duration,10),pause:0}:e}$({name:`passage`,interpolate:!0,render(e,t){let{currentPassage:n,navigationId:r,storyData:i,renderDeferred:a}=Fl(`currentPassage`,`navigationId`,`storyData`,`renderDeferred`),[o,s]=Ae({passage:n,id:r}),c=o.passage,l=e=>s({passage:e,id:r}),u=j(`fade`),d=j(0),f=o.id,p=Fe(e=>e.navigationId!==f,[f]),m=Fe(()=>p(Q.getState()),[p]),h=j(null),g=j(null),_=j([]),v=j(!1),y=Fe(()=>{for(let e of _.current)clearTimeout(e);_.current=[],v.current=!1,YT(g.current)},[]);Me(()=>y,[y]),Me(()=>{let e=Q.getState(),{history:t,historyIndex:a,transitionConfig:s}=e,f=d.current;d.current=t.length;let p=!c,m=t.length===1&&a===0&&f>1,h=t.length>1&&a===t.length-1&&f>1&&Math.abs(t.length-f)>1;if(r===o.id)return;let b=e.consumeNextTransition();y();let x=i?.passages.get(n);if(!x){u.current=`none`,l(n);return}if(p||m||h){u.current=`fade`,l(n);return}let S=eE(GT(x.tags,b,s));u.current=S.type;let C=g.current;if(S.type===`none`){l(n);return}if(S.type===`fade`){C&&qT(C,S),l(n);return}let w=S.type===`fade-through`||S.type===`crossfade`?JT(C,S):null;if(!C||!w){l(n);return}if(S.type===`fade-through`){C.appendChild(w),l(``);let e=S.duration+S.pause,t=setTimeout(()=>{l(n)},e),r=e+S.duration;_.current=[t,setTimeout(()=>{YT(C),v.current&&$T(C),v.current=!1},r)];return}C.classList.add(`passage-container--crossfading`),C.appendChild(w),l(n),_.current=[setTimeout(()=>{YT(C)},S.duration)]},[r]);let b=c&&!a?o.id:null,x=j(b);Ne(()=>{if(b===null)return;let e=x.current;if(x.current=b,e===null||e===b)return;let t=g.current;v.current=!!t?.querySelector(`.passage-snapshot`)&&!t.classList.contains(`passage-container--crossfading`),v.current||$T(t)},[b]);let S=j(Symbol(`passage-display`)).current;Ne(()=>{XT.set(S,b),[...ZT].forEach(e=>e())},[b]),Ne(()=>()=>{XT.delete(S),[...ZT].forEach(e=>e())},[]);let C=a?i?.passages.get(`StoryLoading`)??null:c?i?.passages.get(c):null;if(!C&&c&&!a)return J(`div`,{class:`error`,children:[`Error: Passage “`,c,`” not found.`]});let w=i?.passages.get(`PassageReady`),T=!a&&o.id!==r&&h.current?h.current:C&&J(BT,{passage:C,dataTransition:a?`none`:u.current,navigationId:a?void 0:o.id},a?`loading`:`nav-${o.id}`);return h.current=T||null,J(`div`,{id:t.id??`story`,class:t.className??`story`,children:[!a&&w&&J(`div`,{hidden:!0,children:LT(w)},`ready-${r}`),J(`div`,{class:`passage-container`,ref:g,children:T&&J(Nl.Provider,{value:p,children:J(Pl.Provider,{value:m,children:T})})})]})}}),$({name:`set`,parameters:[{name:`code`,type:`statements`,required:!0}],render({rawArgs:e},t){return pm(`set`,e,()=>t.mutate(e))}}),$({name:`print`,parameters:[{name:`expression`,type:`expression`,required:!0}],interpolate:!0,merged:!0,render({rawArgs:e},t){try{return t.wrap(xu(t.evaluate(e)))}catch(e){return J(dm,{macro:`print`,error:e})}},text({rawArgs:e},t){return xu(t.evaluate(e))}});var tE=Symbol(`unset`);function nE(e,t){if(!t[`=`])throw Error(`{computed}: expected \"target = expression\", got \"${e}\"`);let{target:n=``,expression:r=``}=t;if(!n.match(/^[$_@]\\w+$/))throw Error(`{computed}: target must be $name, _name, or @name, got \"${n}\"`);return ys(n.slice(1),n),{target:n,expr:r}}function rE(e,t,n,r,i,a,o,s,c){let l=um(),u,d=o.current,f=!1,{navigationId:p}=Q.getState();try{let{variables:a,temporary:o,transient:c}=Jb();r||(d=bs(n?o:a,t),f=p!==s.current),u=yu(e,a,o,i(),c)}catch(e){fm(`computed ${a}`,e,l);return}if(s.current=p,!Ev(o.current,u)||f&&!Ev(d,u))if(o.current=u,r)try{c(t,u)}catch(e){fm(`computed ${a}`,e,l)}else{let e=Q.getState();n?e.setTemporary(t,u):e.setVariable(t,u)}}$({name:`computed`,merged:!0,parameters:[{name:`target`,type:`variable`,required:!0},{name:`=`,type:`separator`},{name:`expression`,type:`expression`,required:!0}],render({rawArgs:e},t){let n,r;try{({target:n,expr:r}=nE(e,t.args))}catch(e){return J(dm,{macro:`computed`,error:e})}let i=n.startsWith(`@`),a=n.startsWith(`_`),o=n.slice(1),s=i?t.update:null,c=t.hooks.useRef(tE),l=t.hooks.useRef(-1),u=()=>rE(r,o,a,i,t.getValues,e,c,l,s),d=t.hooks.useRef(!1);return d.current||(d.current=!0,u()),t.hooks.useLayoutEffect(u,[t.merged]),null}});function iE(e){if(e.current===void 0||e.max===void 0)throw Error(`meter requires two arguments: {meter currentExpr maxExpr}`);return{currentExpr:e.current,maxExpr:e.max,labelMode:e.label??``}}function aE(e,t,n){return n===`none`?null:n===`%`?`${t===0?0:Math.round(e/t*100)}%`:n?`${e} ${n} / ${t} ${n}`:`${e} / ${t}`}$({name:`meter`,interpolate:!0,merged:!0,parameters:[{name:`current`,type:`expression`,required:!0},{name:`max`,type:`expression`,required:!0},{name:`label`,type:`string`,holds:`markup`}],render(e,t){try{let{currentExpr:e,maxExpr:n,labelMode:r}=iE({...t.args,label:t.resolve?.(t.args.label)}),i=Number(t.evaluate(e)),a=Number(t.evaluate(n)),o=a===0?0:Math.max(0,Math.min(100,i/a*100)),s=aE(i,a,r),c=t.cls;return J(`div`,{class:c,id:t.id,children:[J(`div`,{class:`macro-meter-fill`,style:`width: ${o}%`}),s!=null&&J(`span`,{class:`macro-meter-label`,children:s})]})}catch(e){return J(dm,{macro:`meter`,error:e})}}});function oE(e,t){let n=null;for(let r of e)if(r.rawArgs===``)n=r;else if(t(r.rawArgs))return r;return n}function sE(e,t){return Su(t.resolve(e.className),t.resolve(e.id),t.renderNodes(e.children))}function cE(e,t){let n=e.findIndex(e=>e.rawArgs===``);return oE(n<0?e:e.slice(0,n+1),e=>!!t(e))}$({name:`if`,block:!0,interpolate:!0,merged:!0,render({branches:e=[]},t){let n;try{n=cE(e,t.evaluate)}catch(e){return J(dm,{macro:`if`,error:e})}return n?sE(n,t):null},text({branches:e=[]},t){let n=cE(e,t.evaluate);return n?t.renderText(n.children):``}});function lE(e){try{return uE(e,new Map)}catch{return`<unkeyable>`}}function uE(e,t){switch(typeof e){case`string`:return JSON.stringify(e);case`number`:return Number.isFinite(e)?JSON.stringify(e):String(e);case`boolean`:return String(e);case`bigint`:return`${e}n`;case`undefined`:return`undefined`;case`symbol`:return e.description===void 0?`Symbol()`:`Symbol(${JSON.stringify(e.description)})`;case`function`:return`<function ${JSON.stringify(e.name)}>`}if(e===null)return`null`;let n=e,r=t.get(n);if(r!==void 0)return`<ref ${r}>`;let i=Mg(n),a=e=>i===void 0?e:`Class(${JSON.stringify(i)})${e}`,o=e=>{let r=i===void 0?[]:Sg(n);return a(r.length?`${e}${fE(n,r,t)}`:e)};if(e instanceof Date||e instanceof RegExp)return i!==void 0&&Sg(n).length&&t.set(n,t.size),o(e instanceof Date?`Date(${Date.prototype.getTime.call(e)})`:`RegExp(${RegExp.prototype.toString.call(e)}@${e.lastIndex})`);if(t.set(n,t.size),Array.isArray(e))return o(`[${Array.from(e,e=>uE(e,t)).join(`,`)}]`);let s=dE(n,t);return s===void 0?e instanceof Map?o(`Map[${Array.from(Cg(e),([e,n])=>`[${uE(e,t)},${uE(n,t)}]`).join(`,`)}]`):e instanceof Set?o(`Set[${Array.from(wg(e),e=>uE(e,t)).join(`,`)}]`):a(fE(n,Object.keys(n),t)):a(s)}function dE(e,t){if(e instanceof ArrayBuffer)return`ArrayBuffer[${new Uint8Array(e).join(`,`)}]`;if(ArrayBuffer.isView(e))return`${hg(e)}(${e.byteOffset},${e.byteLength},${uE(e.buffer,t)})`;let n;if(e instanceof URL)n=`URL(${JSON.stringify(Object.getOwnPropertyDescriptor(URL.prototype,`href`).get.call(e))})`;else if(e instanceof URLSearchParams)n=`URLSearchParams(${JSON.stringify(URLSearchParams.prototype.toString.call(e))})`;else if(_g(e))n=`${hg(e)}(${uE(e.valueOf(),t)})`;else if(gg(e))n=`${hg(e)}(${JSON.stringify(String(e))})`;else if(e instanceof Error){let r=e,i=bg.filter(t=>K(e,t)).map(e=>`${e}:${uE(r[e],t)}`),a=Object.getPrototypeOf(e)?.constructor,o=typeof a==`function`?a.name:``;n=`Error(${JSON.stringify(o)},${i.join(`,`)})`}else return;let r=Object.keys(e);return r.length?`${n}${fE(e,r,t)}`:n}function fE(e,t,n){let r=e;return`{${t.map(e=>`${JSON.stringify(e)}:${uE(r[e],n)}`).join(`,`)}}`}function pE(e,t){if(!t.of)throw Error(`{for} requires \"of\" keyword: {for ${e}}`);let[n=``,r=null]=t.variables??[],i=t.list??``;if(!n.startsWith(`@`))throw Error(`{for} loop variable must use @ prefix: got \"${n}\"`);if(r&&!r.startsWith(`@`))throw Error(`{for} index variable must use @ prefix: got \"${r}\"`);return ys(n.slice(1),n),r&&ys(r.slice(1),r),{itemVar:n.slice(1),indexVar:r?r.slice(1):null,listExpr:i}}function mE({parentValues:e,itemVar:t,itemValue:n,indexVar:r,indexValue:i,children:a}){return J(Wu,{body:a,parentValues:e,ownKeys:Pe(()=>({[t]:n,...r?{[r]:i}:void 0}),[t,n,r,i])})}$({name:`for`,block:!0,interpolate:!0,merged:!0,parameters:[{name:`variables`,type:`names`,required:!0},{name:`of`,type:`separator`},{name:`list`,type:`expression`,required:!0}],render({rawArgs:e,children:t=[]},n){let r=M(hm),i=n.hooks.useRef({contents:[],generations:[],next:0,edits:gw()}).current,a,o;try{a=pE(e,n.args);let t=n.evaluate(a.listExpr);if(!Array.isArray(t))return J(`span`,{class:`error`,children:`{for error: expression did not evaluate to an array}`});o=t}catch(e){return J(dm,{macro:`for`,error:e})}let{itemVar:s,indexVar:c}=a,l=_w(i.edits,Jb());i.edits=gw();let u=o.map((e,t)=>{let n=lE(e);return(i.generations[t]===void 0||n!==i.contents[t]&&!l(o,e,t))&&(i.generations[t]=i.next++),i.contents[t]=n,i.generations[t]});i.contents.length=i.generations.length=o.length;let d=o.map((e,n)=>J(mE,{parentValues:r,itemVar:s,itemValue:e,indexVar:c,indexValue:n,children:t},`${n}-${u[n]}`));return n.wrap(J(pw.Provider,{value:!0,children:d}))},text({rawArgs:e,children:t=[]},n){let{itemVar:r,indexVar:i,listExpr:a}=pE(e,n.args),o=n.evaluate(a);if(!Array.isArray(o))throw Error(`expression did not evaluate to an array`);return o.map((e,a)=>n.renderText(t,{[r]:e,...i?{[i]:a}:void 0})).join(``)}}),$({name:`do`,block:!0,render({children:e=[]},t){let n=t.collectText(e);return pm(`do`,``,()=>t.mutate(n))}});function hE(e){return new Proxy(q(),{get:(t,n)=>typeof n==`string`?bs(e(),n):void 0,has:(t,n)=>typeof n==`string`&&K(e(),n),ownKeys:()=>Reflect.ownKeys(e()),getOwnPropertyDescriptor:(t,n)=>{let r=Object.getOwnPropertyDescriptor(e(),n);return r?{...r,configurable:!0}:void 0}})}var gE=ge({stop:()=>{}});$({name:`repeat`,block:!0,interpolate:!0,parameters:[wc],render({children:e=[]},t){let{useState:n,useEffect:r,useCallback:i,useContext:a}=t.hooks,o=t.args.delay??0,[s,c]=n(0),[l,u]=n(!1),d=a(Pl),f=i(()=>u(!0),[]);if(r(()=>{if(l)return;let e=setInterval(()=>{d?.()||c(e=>e+1)},o);return()=>clearInterval(e)},[o,l]),s===0&&!l)return null;let p=J(gE.Provider,{value:{stop:f},children:J(`span`,{children:t.renderNodes(e)},s)});return t.className||t.id?J(`span`,{id:t.id,class:t.cls,children:p}):p}});var _E=()=>!0;function vE(){let e=M(gm),{nobr:t,inline:n,structural:r}=Uu(),i=M(km),a=M(gE),o=M(RC),s=M(pw),c=M(Pl),l=j([]);Me(()=>{let e=tC(()=>{let e=l.current.splice(0);queueMicrotask(()=>{for(let t of e)he(null,t)})});return()=>{e();for(let e of l.current.splice(0))he(null,e)}},[]);let u=u=>{let d=hE(e.getValues),f=document.createElement(`div`);he(J(Nl.Provider,{value:_E,children:J(gm.Provider,{value:e,children:J(hm.Provider,{value:d,children:J(_m.Provider,{value:t,children:J(ym.Provider,{value:n,children:J(bm.Provider,{value:r,children:J(km.Provider,{value:i,children:J(gE.Provider,{value:a,children:J(RC.Provider,{value:o,children:J(pw.Provider,{value:s,children:J(Pl.Provider,{value:c,children:Sh(u,{nobr:t,inline:n,structural:r,locals:d})})})})})})})})})})})}),f),l.current.push(f)};return e=>_x(()=>u(e))}$({name:`button`,block:!0,interpolate:!0,parameters:[{name:`label`,type:`text`,holds:`markup`,required:!0}],render({rawArgs:e,children:t=[]},n){let r=n.resolve?.(n.args.label??``)??e,i=vE(),a=()=>i(t);return n.useAction({type:`button`,key:e,authorId:n.id,label:r,perform:a}),J(`button`,{type:`button`,id:n.id,class:n.cls,onClick:a,children:r})}}),$({name:`link`,block:!0,interpolate:!0,merged:!0,parameters:[{name:`text`,type:`string`,holds:`markup`,required:!0},{name:`passage`,type:`passage`}],render({children:e=[]},t){let n=t.resolve?.(t.args.text??``)??``,r=null,i;if(t.args.passage!==void 0)try{r=Dc(t.args.passage,t.evaluate,Q.getState())}catch(e){i={error:e}}let a=vE(),o=()=>{i||(a(e),r&&Q.getState().navigate(r))};return t.useAction({type:`link`,key:r||n,authorId:t.id,label:n,target:r??void 0,disabled:i?!0:void 0,perform:o}),i?J(dm,{macro:`link`,error:i.error}):J(`a`,{id:t.id,class:t.cls,href:`#`,onClick:e=>{e.preventDefault(),o()},children:n})}});function yE(e,t,n){return oE(t.slice(1),t=>e===n(t))}$({name:`switch`,subMacros:[`case`,`default`],parameters:[{name:`expression`,type:`expression`,required:!0}],interpolate:!0,merged:!0,render({rawArgs:e,branches:t=[]},n){let r;try{r=n.evaluate(e)}catch(e){return J(dm,{macro:`switch`,error:e})}let i;try{i=yE(r,t,n.evaluate)}catch(e){return J(dm,{macro:`case`,error:e})}return i?sE(i,n):null},text({rawArgs:e,branches:t=[]},n){let r=yE(n.evaluate(e),t,n.evaluate);return r?n.renderText(r.children):``}});var bE=[wc];$({name:`timed`,subMacros:[`next`],interpolate:!0,parameters:bE,render({branches:e=[]},t){let{useState:n,useEffect:r,useMemo:i,useContext:a}=t.hooks,o=a(Pl),s=i(()=>e.map(e=>({delay:Tc(e.rawArgs,bE).delay??0,nodes:e.children,className:e.className,id:e.id})),[e]),[c,l]=n(-1);if(r(()=>{if(c>=s.length-1)return;let e=c+1,t=s[e].delay,n=setTimeout(()=>{o?.()||l(e)},t);return()=>clearTimeout(n)},[c,s]),c<0)return t.wrap(null);let u=s[c];return t.wrap(Su(t.resolve(u.className),t.resolve(u.id),t.renderNodes(u.nodes)))}}),$({name:`stop`,render(e,t){let{stop:n}=t.hooks.useContext(gE);return t.hooks.useLayoutEffect(()=>{n()},[n]),null}});function xE(e,t,n){let r=document.createRange();if(!r.getClientRects)return;let i=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),a=n,o;for(let e=i.nextNode();e&&a>0;e=i.nextNode()){let t=e.nodeValue?.length??0;o={node:e,offset:Math.min(a,t)},a-=t}if(!o)return`inset(0 100% 0 0)`;r.setStart(e,0),r.setEnd(o.node,o.offset);let s=r.getClientRects();if(s.length===0)return;let c=t.getBoundingClientRect(),l=``;for(let e of Array.from(s)){if(e.width===0&&e.height===0)continue;let t=(e.left-c.left).toFixed(2),n=(e.top-c.top).toFixed(2);l+=`M${t} ${n}h${e.width.toFixed(2)}v${e.height.toFixed(2)}h-${e.width.toFixed(2)}z`}return l?`path(\"${l}\")`:void 0}$({name:`type`,block:!0,interpolate:!0,parameters:[wc],render({children:e=[]},t){let{useState:n,useEffect:r,useLayoutEffect:i,useRef:a}=t.hooks,o=t.args.delay??0,s=a(null),c=a(null),[l,u]=n(),[d,f]=n(null),p=d??0,[m,h]=n(0),g=a(0);g.current=m,r(()=>{s.current&&f((s.current.textContent||``).length)}),r(()=>{if(p===0||g.current>=p)return;let e=setInterval(()=>{h(t=>t>=p?(clearInterval(e),t):t+1)},o);return()=>clearInterval(e)},[p,o]);let _=d!==null&&m>=p;i(()=>{let e=s.current,t=c.current;if(!e||!t||p===0||_){u(void 0);return}let n=()=>u(xE(e,t,m));return n(),window.addEventListener(`resize`,n),()=>window.removeEventListener(`resize`,n)},[m,p,_]);let v=[`macro-type`,_?`macro-type-done`:``,t.className||``].filter(Boolean).join(` `);return J(`span`,{id:t.id,class:v,ref:s,children:[J(`span`,{ref:c,class:`macro-type-inner`,style:{display:`inline`,visibility:d===null?`hidden`:`visible`,clipPath:l},children:t.renderInlineNodes(e)}),!_&&p>0&&J(`span`,{class:`macro-type-cursor`})]})}}),$({name:`widget`,block:!0,parameters:Sl,render({children:e=[]},t){let n,r;try{let e=Cl(t.args);for(let t of e.params)ys(t.slice(1),t);n=e}catch(e){r=e}let{name:i,params:a}=n??{name:``,params:[]},o=JSON.stringify(e),s=a.join(`,`);return t.hooks.useLayoutEffect(()=>{n&&El(n,e)},[i,o,s]),r?J(dm,{macro:`widget`,error:r}):null}}),$({name:`story-title`,render(e,t){let n=Q(e=>e.storyData?.name||``),r=t.className?`story-title ${t.className}`:`story-title`;return J(`span`,{id:t.id,class:r,children:n})},text:()=>Q.getState().storyData?.name||``});function SE(e,t){return t?`${e} (${t})`:e}function CE(e){$({name:e.name,render(t,n){if(e.hidden?.())return null;let[r,i]=Ae(!1),a=e.setup?.()??{perform:()=>{}},{disabled:o,title:s=e.title}=a,c=n.className?`menubar-button ${n.className}`:`menubar-button`,l=e.dialog?()=>i(!0):e.confirm?()=>{confirm(e.confirm)&&a.perform()}:a.perform;return n.useAction({type:e.actionType,key:e.name,authorId:n.id,label:typeof e.label==`string`?e.label:e.name,disabled:o,perform:e.dialog?()=>i(!0):a.perform}),J(S,{children:[J(`button`,{type:`button`,id:n.id,class:c,onClick:l,disabled:o,title:s,children:e.label}),e.dialog&&r&&J(zC,{passageName:e.dialog.passageName,fallbackMarkup:e.dialog.fallbackMarkup,panelClass:e.dialog.panelClass,onClose:()=>i(!1),showCloseButton:e.dialog.showCloseButton})]})}})}CE({name:`back`,label:`← Back`,actionType:`back`,setup:()=>({perform:Q(e=>e.goBack),disabled:!Q(e=>e.historyIndex>0)})}),CE({name:`forward`,label:`Forward →`,actionType:`forward`,setup:()=>({perform:Q(e=>e.goForward),disabled:!Q(e=>e.historyIndex<e.history.length-1)})}),CE({name:`quicksave`,label:`QuickSave`,actionType:`save`,setup:()=>{let{quickSaveKey:e}=Fl(`quickSaveKey`);return{perform:HC,title:SE(`Quick Save`,e)}}}),CE({name:`quickload`,label:`QuickLoad`,actionType:`load`,confirm:`Load saved game? Current progress will be lost.`,setup:()=>{let{hasSave:e,quickLoadKey:t}=Fl(`hasSave`,`quickLoadKey`,`knownSaves`);return{perform:UC,disabled:!e(),title:SE(`Quick Load`,t)}}}),CE({name:`restart`,label:`↺ Restart`,actionType:`restart`,confirm:`Restart the story? All progress will be lost.`,setup:()=>({perform:Q(e=>e.restart)})}),CE({name:`saves`,label:`Saves`,actionType:`dialog`,dialog:{passageName:`SaveLoad`,fallbackMarkup:`{save-manager}`,panelClass:`dialog-saves`}}),CE({name:`settings`,label:`Settings`,actionType:`dialog`,hidden:()=>!sw.hasAny(),dialog:{passageName:`Settings`,fallbackMarkup:`{settings-controls}`,panelClass:`dialog-settings`}}),$({name:`dialog`,block:!0,interpolate:!0,parameters:[{name:`label`,type:`text`,holds:`markup`,required:!0},{name:`noclose`,type:`flag`}],render({children:e=[]},t){let[n,r]=t.hooks.useState(!1),{noclose:i}=t.args,a=t.resolve(t.args.label??``),o=t.collectText(e).trim().replace(/^[\"']|[\"']$/g,``);return J(S,{children:[J(`button`,{type:`button`,id:t.id,class:t.cls,onClick:()=>r(!0),children:a}),n&&J(zC,{passageName:o,onClose:()=>r(!1),showCloseButton:!i})]})}});function wE(e){let t=Date.now()-new Date(e).getTime(),n=Math.floor(t/1e3);if(n<60)return`just now`;let r=Math.floor(n/60);if(r<60)return`${r}m ago`;let i=Math.floor(r/60);if(i<24)return`${i}h ago`;let a=Math.floor(i/24);return a<30?`${a}d ago`:new Date(e).toLocaleDateString()}function TE(e){return new Date(e).toLocaleDateString(void 0,{month:`short`,day:`numeric`,year:`numeric`})}function EE(){let[e,t]=Ae(`load`),[n,r]=Ae([]),[i,a]=Ae(!0),[o,s]=Ae(null),[c,l]=Ae(()=>new Set),[u,d]=Ae(null),f=j(!1),[p,m]=Ae(``),h=j(null),g=j(null),_=M(RC),{storyData:v,playthroughId:y,beginSave:b,loadFromPayload:x}=Fl(`storyData`,`playthroughId`,`beginSave`,`loadFromPayload`),S=v?.ifid??``,[C,w]=Ae(!1),T=Fe(async()=>{if(!S)return;let e=await Wy(S);w(uv()===`memory`),r(e),a(!1)},[S]);Me(()=>{T()},[T]),Me(()=>S?db(S,T,!0):void 0,[S,T]),Me(()=>{u&&h.current&&(h.current.focus(),h.current.select())},[u]);let ee=j(!0),E=j(),D=j(),O=(e,t=`success`)=>{ee.current&&(clearTimeout(E.current),s({text:e,type:t}),E.current=window.setTimeout(()=>s(null),3e3))};Me(()=>(ee.current=!0,()=>{ee.current=!1,clearTimeout(E.current),clearTimeout(D.current)}),[]);let te=e=>{l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},ne=async()=>{if(!S)return;let e=zS();try{await Ny(void 0,void 0,b,async t=>Fy(S,e,t)),O(C?`Save created (temporary)`:`Save created`),await T()}catch{O(`Failed to create save`,`error`)}},re=async e=>{let t=zS();try{await Ny(void 0,void 0,b,async n=>{if(!await Ly(e,n,void 0,t))throw Error(`Save not found`)}),O(`Save overwritten`),await T()}catch{O(`Failed to overwrite save`,`error`)}},k=async e=>{let t=XS();try{let n=await Vy(e.meta.id)??e;if(ZS(t))return;x(By(n.payload),void 0,n.meta.playthroughId,t),O(`Game loaded`),_&&(D.current=window.setTimeout(_,500)),await T()}catch{O(`Failed to load save`,`error`)}},ie=async(e,t,n)=>{try{await n(),O(e),await T()}catch{O(t,`error`)}},ae=async e=>{confirm(`Delete this save?`)&&await ie(`Save deleted`,`Failed to delete save`,async()=>{await Hy(e);let t=await _b(S);Q.setState(e=>{e.knownSaves=t})})},oe=e=>{f.current=!1,d(e.meta.id),m(e.meta.title)},se=async()=>{let e=u;!e||!p.trim()||await ie(`Save renamed`,`Failed to rename`,async()=>{await Uy(e,p.trim()),d(t=>t===e?null:t)})},ce=e=>{e.key===`Enter`?se():e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),f.current=!0,d(null))},le=()=>{f.current||se()},ue=async e=>{try{let t=await jb(e);if(!t)return;let n=new Blob([JSON.stringify(t,null,2)],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`save-${t.save.meta.title.replace(/[^a-z0-9]/gi,`_`)}.json`,i.click(),URL.revokeObjectURL(r),O(`Save exported`)}catch{O(`Failed to export save`,`error`)}},de=()=>{g.current?.click()},fe=async e=>{let t=e.target,n=t.files?.[0];if(n){t.value=``;try{let e=await n.text(),t=JSON.parse(e);if(!L_(t))throw Error(`Invalid save file format`);await Nb(t,S),O(`Save imported`),await T()}catch(e){O(Fs(e,`Failed to import save`),`error`)}}},pe=n.reduce((e,t)=>e+t.saves.length,0);return J(`div`,{class:`save-manager`,children:[J(`div`,{class:`saves-header`,children:J(`div`,{class:`saves-header-left`,children:J(`div`,{class:`saves-mode-toggle`,children:[J(`button`,{type:`button`,class:e===`save`?`active`:``,onClick:()=>t(`save`),children:`Save`}),J(`button`,{type:`button`,class:e===`load`?`active`:``,onClick:()=>t(`load`),children:`Load`})]})})}),C&&J(`div`,{class:`saves-notice`,role:`status`,children:`Saves can not be kept in this browser: they are lost when the page is reloaded or closed. Export a save to keep it.`}),J(`div`,{class:`saves-toolbar`,children:[J(`button`,{type:`button`,class:`saves-toolbar-button`,onClick:de,children:`Import`}),J(`input`,{ref:g,type:`file`,accept:`.json`,style:`display:none`,onChange:fe})]}),J(`div`,{class:`saves-body`,children:[i?J(`div`,{class:`saves-empty`,children:`Loading...`}):pe===0&&e===`load`?J(`div`,{class:`saves-empty`,children:`No saves yet`}):n.map(t=>{let n=c.has(t.playthrough.id),r=t.playthrough.id===y;return e===`save`&&!r||e===`load`&&t.saves.length===0&&!r?null:J(`div`,{class:`playthrough-group`,children:[J(`button`,{type:`button`,class:`playthrough-header`,\"aria-expanded\":!n,onClick:()=>te(t.playthrough.id),children:[J(`span`,{class:`playthrough-chevron ${n?``:`open`}`,\"aria-hidden\":`true`,children:`▶`}),J(`span`,{class:`playthrough-label`,children:[t.playthrough.label,r?` (current)`:``]}),J(`span`,{class:`playthrough-date`,children:TE(t.playthrough.createdAt)})]}),!n&&J(`div`,{class:`playthrough-saves`,children:[t.saves.map(t=>J(`div`,{class:`save-slot`,children:[J(`div`,{class:`save-slot-info`,children:[u===t.meta.id?J(`input`,{ref:h,class:`save-rename-input`,value:p,onInput:e=>m(e.target.value),onKeyDown:ce,onBlur:le}):J(`div`,{class:`save-slot-title`,children:t.meta.title}),J(`div`,{class:`save-slot-meta`,children:[J(`span`,{children:t.meta.passage}),J(`span`,{children:wE(t.meta.updatedAt)})]})]}),J(`div`,{class:`save-slot-actions`,children:[e===`save`?J(`button`,{type:`button`,class:`save-slot-action primary`,onClick:()=>re(t.meta.id),children:`Save Here`}):J(`button`,{type:`button`,class:`save-slot-action primary`,onClick:()=>k(t),children:`Load`}),J(`button`,{type:`button`,class:`save-slot-action`,onClick:()=>oe(t),children:`Rename`}),J(`button`,{type:`button`,class:`save-slot-action`,onClick:()=>ue(t.meta.id),children:`Export`}),J(`button`,{type:`button`,class:`save-slot-action danger`,onClick:()=>ae(t.meta.id),children:`Delete`})]})]},t.meta.id)),e===`save`&&r&&J(`button`,{type:`button`,class:`save-slot-new`,onClick:ne,children:`+ New Save`})]})]},t.playthrough.id)}),e===`save`&&!i&&!n.some(e=>e.playthrough.id===y)&&J(`div`,{class:`playthrough-group`,children:J(`div`,{class:`playthrough-saves`,children:J(`button`,{type:`button`,class:`save-slot-new`,onClick:ne,children:`+ New Save`})})})]}),o&&J(`div`,{class:`saves-status ${o.type===`error`?`error`:``}`,children:o.text})]})}$({name:`save-manager`,render(){return J(EE,{})}});function DE({name:e,def:t}){let[n,r]=Ae(()=>sw.get(e)),i=t=>{r(t),sw.set(e,t)};switch(t.type){case`toggle`:return J(`label`,{class:`settings-row`,children:[J(`span`,{children:t.config.label}),J(`input`,{type:`checkbox`,checked:!!n,onChange:e=>i(e.target.checked)})]});case`list`:return J(`label`,{class:`settings-row`,children:[J(`span`,{children:t.config.label}),J(`select`,{value:String(n),onChange:e=>i(e.target.value),children:t.config.options.map(e=>J(`option`,{value:e,children:e},e))})]});case`range`:return J(`label`,{class:`settings-row`,children:[J(`span`,{children:[t.config.label,`: `,String(n)]}),J(`input`,{type:`range`,min:t.config.min,max:t.config.max,step:t.config.step,value:Number(n),onInput:e=>i(parseFloat(e.target.value))})]})}}function OE(){let e=sw.getDefinitions();return J(`div`,{class:`settings-controls`,children:Array.from(e.entries()).map(([e,t])=>J(DE,{name:e,def:t},e))})}$({name:`settings-controls`,render(){return J(OE,{})}}),$({name:`include`,interpolate:!0,merged:!0,parameters:[{name:`inline`,type:`flag`},{name:`passage`,type:`passage`,required:!0}],render(e,t){let{storyData:n}=Fl(`storyData`),{inline:r}=t.args,i=``,a;try{i=Dc(t.args.passage,t.evaluate,Q.getState())}catch(e){a={error:e}}let o=n?.passages.get(i),s=t.hooks.useMemo(()=>o?ls(o.content):null,[o]),c=!a&&!!o;if(t.hooks.useEffect(()=>{c&&Q.getState().trackRender(i)},[c,i]),!n)return null;if(a)return J(dm,{macro:`include`,error:a.error});if(!o||!s)return null;let l=o.tags.includes(`nobr`),u=r?t.renderInlineNodes(s):t.renderNodes(s,l?{nobr:!0}:void 0);return l?t.wrap(t.h(_m.Provider,{value:!0},u)):t.wrap(u)}}),$({name:`nobr`,block:!0,render({children:e=[]},t){return t.wrap(t.h(_m.Provider,{value:!0},t.renderNodes(e,{nobr:!0})))},text:({children:e=[]},t)=>t.renderText(e)}),$({name:`goto`,merged:!0,parameters:[{name:`passage`,type:`passage`,required:!0}],render(e,t){let[n,r]=t.hooks.useState();return t.hooks.useLayoutEffect(()=>{let e=t.sourceLocation();try{let e=Q.getState();e.navigate(Dc(t.args.passage,t.evaluate,e))}catch(t){fm(`goto`,t,e),r({error:t})}},[]),n?J(dm,{macro:`goto`,error:n.error}):null}}),$({name:`unset`,parameters:[{name:`variable`,type:`variable`,required:!0}],render({rawArgs:e},t){return pm(`unset`,e,()=>{let e=Q.getState(),n=t.args.variable??``;if(/^[$_%@][^.]*\\./.test(n))t.mutate(`delete ${n}`);else if(n.startsWith(`$`))e.deleteVariable(n.slice(1));else if(n.startsWith(`_`))e.deleteTemporary(n.slice(1));else if(n.startsWith(`%`))e.deleteTransient(n.slice(1));else if(n.startsWith(`@`))t.update(n.slice(1),void 0);else throw Error(`{unset} expects a variable ($name, _name, %name, or @name), got \"${n}\"`)})}});var kE={name:`variable`,type:`variable`,required:!0};function AE(e,t){return e.useAction({key:`$${e.varName}`,authorId:e.id,variable:e.varName,value:e.value,...t})}function jE(e,t,n=e=>e===void 0?``:String(e)){$({name:e,storeVar:!0,parameters:[kE,{name:`placeholder`,type:`string`,holds:`text`}],render(r,i){let a=i.args.placeholder??``;AE(i,{type:e,label:a||i.varName,perform:e=>i.setValue(n(e))});let o=i.hooks.useRef(null),s=o.current!==null&&n(o.current)===i.value&&t===`number`?o.current:xu(i.value);return b(t?`input`:`textarea`,{type:t,id:i.id,class:i.cls,value:s,placeholder:a,onInput:e=>{let t=e.target.value;o.current=t,i.setValue(n(t))}})}})}jE(`textbox`,`text`),jE(`numberbox`,`number`,e=>e===void 0?0:Number(e)),jE(`textarea`),$({name:`checkbox`,storeVar:!0,parameters:[kE,{name:`label`,type:`text`,holds:`text`}],render(e,t){let n=t.args.label??``;return AE(t,{type:`checkbox`,label:n||t.varName||``,value:!!t.value,perform:e=>t.setValue(e===void 0?!t.value:!!e)}),J(`label`,{id:t.id,class:t.cls,children:[J(`input`,{type:`checkbox`,checked:!!t.value,onChange:()=>t.setValue(!t.value)}),n?` ${n}`:null]})}}),$({name:`radiobutton`,storeVar:!0,parameters:[kE,{name:`value`,type:`text`,holds:`text`,required:!0},{name:`label`,type:`text`,holds:`text`}],render(e,t){let n=t.args.value??``,r=t.args.label??``,i=t.hooks.useContext(Sm);return AE(t,{type:`radiobutton`,key:`$${t.varName}:${n}`,label:r||n,perform:()=>t.setValue(n)}),J(`label`,{id:t.id,class:t.cls,children:[J(`input`,{type:`radio`,name:i?`radio-${i}-${t.varName}`:`radio-${t.varName}`,checked:t.value===n,onChange:()=>t.setValue(n)}),r?` ${r}`:null]})}}),$({name:`listbox`,subMacros:[`option`],storeVar:!0,parameters:[kE],render({children:e=[]},t){let n=t.extractOptions(e);return AE(t,{type:`listbox`,label:t.varName,options:n,perform:e=>{e!==void 0&&t.setValue(String(e))}}),J(`select`,{id:t.id,class:t.cls,value:xu(t.value),onChange:e=>t.setValue(e.target.value),children:n.map(e=>J(`option`,{value:e,children:e},e))})}}),$({name:`cycle`,block:!0,storeVar:!0,parameters:[kE],render({children:e=[]},t){let n=t.extractOptions(e),r=()=>{if(n.length===0)return;let e=t.getValue(),r=(n.indexOf(String(e))+1)%n.length;t.setValue(n[r])};return AE(t,{type:`cycle`,label:t.value==null?n[0]||``:String(t.value),options:n,perform:e=>{e===void 0?r():t.setValue(e)}}),J(`button`,{type:`button`,id:t.id,class:t.cls,onClick:r,children:t.value==null?n[0]||``:String(t.value)})}}),$({name:`span`,block:!0,render({children:e=[]},t){return t.wrap(t.renderNodes(e))},text:({children:e=[]},t)=>t.renderText(e)}),$({name:`watch`,parameters:[{name:`condition`,type:`string`,holds:`expression`,required:!0},{name:`options`,type:`options`,parameters:[{name:`goto`,type:`string`,holds:`passage`},{name:`dialog`,type:`string`,holds:`passage`},{name:`run`,type:`string`,holds:`statements`},{name:`name`,type:`string`,holds:`text`},{name:`priority`,type:`number`},{name:`once`,type:`flag`}]}],render(e,t){let{hooks:n}=t,{condition:r,options:i}=t.args;if(r===void 0)return null;let a=n.useContext(Nl),[,o]=n.useState(0);n.useEffect(()=>Xx(()=>o(e=>e+1)),[]);let s=n.useContext(vm),c=JSON.stringify([r,i]);n.useLayoutEffect(()=>s?Nx(r,i):void 0,[s,c]);let l=n.useRef(null);return(l.current===null||l.current!==Yx()&&!a?.(Q.getState()))&&(l.current=Yx(),kx(r,i)),null}}),$({name:`unwatch`,parameters:[{name:`name`,type:`text`,holds:`text`,required:!0}],render(e,t){let n=t.args.name??``,r=t.hooks.useRef(!1);return r.current||(r.current=!0,Lx(n)),null}});var ME=`*,:before,:after{box-sizing:border-box}html{-webkit-text-size-adjust:100%;font-size:16px}body{color:#e0e0e0;background-color:#1a1a2e;min-height:100vh;margin:0;padding:0;font-family:Georgia,Times New Roman,serif;line-height:1.75}tw-storydata{display:none!important}#story{max-width:42em;margin:0 auto;padding:2em 1.5em}.passage-container{position:relative}.passage-container--crossfading{display:grid}.passage-container--crossfading>*{grid-area:1/1}.passage{animation:passage-fade-in var(--passage-in-duration,.3s) ease}.passage[data-transition=none]{animation:none}.passage-snapshot{animation:passage-fade-out var(--passage-out-duration,.3s) ease forwards;pointer-events:none;-webkit-user-select:none;user-select:none}@keyframes passage-fade-in{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}@keyframes passage-fade-out{0%{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(-8px)}}@media (prefers-reduced-motion:reduce){.passage,.passage-snapshot{animation-duration:10ms!important}}.macro-button{color:#64b5f6;font:inherit;cursor:pointer;background:#64b5f626;border:1px solid #64b5f666;border-radius:4px;padding:.25em .75em;font-size:.95em;transition:background .2s,border-color .2s}.macro-button:hover{background:#64b5f640;border-color:#90caf9}.macro-button:active{background:#64b5f659}.error{color:#ef5350;background:#ef53501a;border:1px solid #ef5350;border-radius:4px;padding:1em;font-family:monospace}.spindle-error-banners{z-index:300;flex-direction:column;gap:.5em;width:min(42em,100% - 1.5em);display:flex;position:fixed;top:.75em;left:50%;transform:translate(-50%)}.spindle-error-banner{color:#ffcdd2;background:#2b1a1e;border:1px solid #ef5350;border-radius:4px;padding:.75em 2.75em .75em 1em;font-size:.9em;line-height:1.5;position:relative;box-shadow:0 2px 12px #00000080}.spindle-error-banner-message{color:#ef9a9a;font-family:monospace}.spindle-error-banner-dismiss{color:inherit;cursor:pointer;background:0 0;border:none;font-size:1em;position:absolute;top:.5em;right:.5em}.spindle-error-banner-dismiss:hover{color:#fff}.loading{text-align:center;opacity:.6;padding:2em}.story-menubar{z-index:100;background:#16213e;border-bottom:1px solid #ffffff14;align-items:center;gap:.5em;padding:.5em 1.5em;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Noto Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;font-size:.9em;display:flex;position:sticky;top:0}@media (max-width:600px){.story-menubar{flex-wrap:wrap;padding:.5em .75em}.story-menubar .story-title{flex:100%}}.story-title{color:#e0e0e0;white-space:nowrap;text-overflow:ellipsis;flex:1;font-weight:600;overflow:hidden}.menubar-button{color:#9e9e9e;cursor:pointer;font:inherit;background:0 0;border:1px solid #0000;border-radius:4px;padding:.35em .7em;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:0 0}.dialog-overlay{z-index:200;background:#0009;justify-content:center;align-items:center;display:flex;position:fixed;top:0;bottom:0;left:0;right:0}.dialog-panel{color:#e0e0e0;background:#16213e;border:1px solid #ffffff1a;border-radius:8px;flex-direction:column;width:90%;max-width:500px;max-height:80vh;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Noto Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;display:flex;position:relative}.dialog-panel:focus{outline:none}.dialog-saves{max-width:550px}.dialog-settings{max-width:400px}.dialog-settings .dialog-body{padding-top:2.25em}.dialog-close{z-index:1;color:#9e9e9e;cursor:pointer;background:0 0;border:none;padding:.25em;font-size:1.1em;line-height:1;position:absolute;top:.75em;right:.75em}.dialog-close:hover{color:#e0e0e0}.dialog-body{flex:1;min-height:0;overflow-y:auto}.settings-controls{flex-direction:column;gap:1em;padding:1em 1.25em;display:flex}.settings-row{justify-content:space-between;align-items:center;gap:1em;display:flex}.settings-row select,.settings-row input[type=range]{accent-color:#64b5f6}.settings-row select{color:#e0e0e0;font:inherit;background:#1a1a2e;border:1px solid #ffffff26;border-radius:4px;padding:.3em .5em}.settings-row input[type=checkbox]{accent-color:#64b5f6;width:1.1em;height:1.1em}.save-manager{flex-direction:column;flex:1;min-height:0;display:flex}.saves-header{border-bottom:1px solid #ffffff14;flex-shrink:0;justify-content:space-between;align-items:center;padding:1em 3em 1em 1.25em;font-weight:600;display:flex}.saves-header-left{align-items:center;gap:.75em;display:flex}.saves-mode-toggle{border:1px solid #ffffff26;border-radius:4px;gap:0;display:flex;overflow:hidden}.saves-mode-toggle button{color:#9e9e9e;font:inherit;cursor:pointer;background:0 0;border:none;padding:.3em .8em;font-size:.85em;font-weight:600;transition:background .2s,color .2s}.saves-mode-toggle button.active{color:#64b5f6;background:#64b5f633}.saves-mode-toggle button:hover:not(.active){color:#e0e0e0}.saves-body{flex:1;min-height:0;padding:.75em 1.25em;overflow-y:auto}.saves-empty{text-align:center;opacity:.5;padding:2em 1em;font-size:.9em}.saves-toolbar{border-bottom:1px solid #ffffff14;flex-shrink:0;gap:.5em;padding:.5em 1.25em;display:flex}.saves-toolbar-button{color:#9e9e9e;font:inherit;cursor:pointer;background:#ffffff0d;border:1px solid #ffffff1a;border-radius:4px;padding:.3em .7em;font-size:.8em;transition:background .2s,color .2s}.saves-toolbar-button:hover{color:#e0e0e0;background:#ffffff1a}.playthrough-group{margin-bottom:.75em}.playthrough-header{text-align:left;cursor:pointer;-webkit-user-select:none;user-select:none;color:#9e9e9e;background:0 0;border:0;align-items:center;gap:.5em;width:100%;padding:.4em 0;font-family:inherit;font-size:.85em;transition:color .2s;display:flex}.playthrough-header:hover{color:#e0e0e0}.playthrough-chevron{font-size:.7em;transition:transform .2s;display:inline-block}.playthrough-chevron.open{transform:rotate(90deg)}.playthrough-label{font-weight:600}.playthrough-date{opacity:.6;font-size:.9em}.playthrough-saves{flex-direction:column;gap:.4em;padding-left:.25em;display:flex}.save-slot{background:#ffffff08;border:1px solid #ffffff0f;border-radius:6px;align-items:center;gap:.75em;padding:.5em .6em;transition:background .15s;display:flex}.save-slot:hover{background:#ffffff0f}.save-slot-info{flex:1;min-width:0}.save-slot-title{white-space:nowrap;text-overflow:ellipsis;font-size:.9em;font-weight:500;overflow:hidden}.save-slot-meta{color:#9e9e9e;gap:.75em;font-size:.75em;display:flex}.save-slot-actions{flex-shrink:0;gap:.3em;display:flex}.save-slot-action{color:#9e9e9e;font:inherit;cursor:pointer;white-space:nowrap;background:0 0;border:1px solid #0000;border-radius:3px;padding:.2em .5em;font-size:.75em;transition:color .2s,background .2s}.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{color:#9e9e9e;font:inherit;cursor:pointer;background:0 0;border:1px dashed #ffffff1f;border-radius:6px;justify-content:center;align-items:center;width:100%;margin-top:.25em;padding:.5em;font-size:.8em;transition:color .2s,border-color .2s,background .2s;display:flex}.save-slot-new:hover{color:#64b5f6;background:#64b5f60d;border-color:#64b5f64d}.saves-notice{color:#ffb74d;background:#ffb74d14;border-bottom:1px solid #ffb74d4d;flex-shrink:0;padding:.5em 1.25em;font-size:.8em}.saves-status{color:#81c784;text-align:center;border-top:1px solid #ffffff14;flex-shrink:0;padding:.5em 1.25em;font-size:.8em}.saves-status.error{color:#ef5350;background:0 0;border:none;border-radius:0;padding:.5em 1.25em;font-family:inherit}.save-rename-input{color:#e0e0e0;font:inherit;background:#1a1a2e;border:1px solid #64b5f666;border-radius:3px;width:100%;padding:.15em .4em;font-size:.9em}.save-rename-input:focus{border-color:#64b5f6;outline:none}.macro-link{color:#64b5f6;cursor:pointer;border-bottom:1px solid #64b5f64d;text-decoration:none;transition:color .2s,border-color .2s}.macro-link:hover{color:#90caf9;border-bottom-color:#90caf9}.macro-link:active{color:#42a5f5}.macro-textbox,.macro-numberbox,.macro-textarea{color:#e0e0e0;font:inherit;background:#1a1a2e;border:1px solid #ffffff26;border-radius:4px;padding:.3em .5em}.macro-textbox:focus,.macro-numberbox:focus,.macro-textarea:focus{border-color:#64b5f6;outline:none}.macro-textarea{resize:vertical;min-height:3em}.macro-checkbox,.macro-radiobutton{cursor:pointer;align-items:center;gap:.3em;display:inline-flex}.macro-checkbox input,.macro-radiobutton input{accent-color:#64b5f6}.macro-listbox{color:#e0e0e0;font:inherit;background:#1a1a2e;border:1px solid #ffffff26;border-radius:4px;padding:.3em .5em}.macro-cycle{color:#64b5f6;font:inherit;cursor:pointer;background:#64b5f626;border:1px solid #64b5f666;border-radius:4px;padding:.25em .75em;transition:background .2s,border-color .2s}.macro-cycle:hover{background:#64b5f640;border-color:#90caf9}.macro-meter{background:#2a2a3e;border:1px solid #444;border-radius:.3em;width:100%;height:1.4em;position:relative;overflow:hidden}.macro-meter-fill{background:#64b5f6;height:100%;transition:width .3s}.macro-meter-label{color:#e0e0e0;text-shadow:0 1px 2px #000c;pointer-events:none;justify-content:center;align-items:center;font-size:.85em;display:flex;position:absolute;top:0;bottom:0;left:0;right:0}.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{color:#f0f0f0;margin:1em 0 .4em;line-height:1.3}.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{opacity:.8;font-size:.9em}.passage code{background:#ffffff14;border-radius:3px;padding:.15em .35em;font-family:Fira Code,Cascadia Code,Consolas,monospace;font-size:.9em}.passage pre{background:#0000004d;border:1px solid #ffffff14;border-radius:6px;margin:.8em 0;padding:1em;overflow-x:auto}.passage pre code{background:0 0;border-radius:0;padding:0;font-size:.85em}.passage blockquote{color:#b0b0b0;border-left:3px solid #64b5f680;margin:.8em 0;padding:.4em 1em}.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 #ffffff1f;margin:1.2em 0}.passage table{border-collapse:collapse;width:100%;margin:.8em 0}.passage th,.passage td{text-align:left;border:1px solid #ffffff1f;padding:.5em .75em}.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:\"█\";color:#64b5f6;animation:.7s step-end infinite type-blink}.macro-type-done .macro-type-cursor:after{display:none}@keyframes type-blink{50%{opacity:0}}`;function NE(e,t){e.innerHTML=``;let n=document.createElement(`div`);n.style.cssText=`font-family:monospace;padding:2rem;max-width:60rem;margin:0 auto`;let r=document.createElement(`h1`);r.style.color=`#c00`,r.textContent=`Story Validation Errors`,n.appendChild(r);let i=document.createElement(`ul`);i.style.cssText=`line-height:1.6`;for(let e of t){let t=document.createElement(`li`);t.textContent=e,i.appendChild(t)}n.appendChild(i),e.appendChild(n)}function PE(e){let t=document.getElementById(`root`);throw t&&NE(t,e),Error(`spindle: ${e.length} validation error(s):\\n${e.join(`\n`)}`)}function FE(e,t){let n=_l().filter(e=>e.storeVar).map(e=>e.name);return NT(e.passages,t,n)}function IE(e,t){let n=_l();return oT(e.passages.values(),{isKnownMacro:e=>!!rl(e)||ll(e)||!!Ns(e),macroNames:n.map(e=>e.name),parametersOf:Hc(n),only:t}).map($w)}function LE(){let e=ZC(),t=document.createElement(`style`);if(t.id=`spindle-styles`,t.textContent=ME,document.head.appendChild(t),Yw(),e.userCSS){let t=document.createElement(`style`);t.textContent=e.userCSS,document.head.appendChild(t)}if(e.userScript)try{Function(e.userScript)()}catch(e){console.error(`spindle: Error in story JavaScript:`,e)}document.dispatchEvent(new CustomEvent(`:storystartup`));let n={},r=e.passages.get(`StoryVariables`);if(!r){let e=`Missing StoryVariables passage. Add a :: StoryVariables passage to declare your variables.`,t=document.getElementById(`root`);throw t&&NE(t,[e]),Error(`spindle: ${e}`)}let i=ST(r.content);for(let t of Tl(e.passages.values()))vr(t);let a=FE(e,i);a.push(...IE(e,e=>e.name===`StoryInit`));let o={},s=e.passages.get(`StoryTransients`);if(s){let e=ST(s.content,`%`);for(let t of e.keys())i.has(t)&&a.push(`StoryTransients: Variable \"${t}\" is already declared in StoryVariables. Names must be unique across scopes.`);o=PT(e)}a.length>0&&PE(a),n=PT(i),Uw(Object.keys(n),Object.keys(o)),Q.getState().init(e,n,o),aC();for(let[,t]of e.passages)t.tags.includes(`widget`)&&Dl(ls(t.content),t.name);Wb(Tb(e.ifid));let c=[...FE(e,i),...IE(e,e=>e.name!==`StoryInit`)];c.length>0&&PE(c);let l=Q.getState().navigationId;Q.subscribe(e=>{e.navigationId!==l&&(l=e.navigationId,Ew())}),Wx();let u=e.passages.get(`StoryInterface`);u&&!u.content.includes(`{passage}`)&&console.warn(`spindle: StoryInterface passage does not contain {passage}. The current passage will not be displayed.`);let d=document.getElementById(`root`);if(!d)throw Error(`spindle: No <div id=\"root\"> element found.`);he(J(WC,{}),d);let f=Lw();f?f.then(QT).then(()=>{document.dispatchEvent(new CustomEvent(`:storyready`))}):document.dispatchEvent(new CustomEvent(`:storyready`))}document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,LE):LE();</script>\n </head>\n <body>\n <div id=\"root\"></div>\n {{STORY_DATA}}\n </body>\n</html>\n"})