@rohal12/spindle 0.59.15 → 0.59.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/pkg/format.js +1 -1
- package/dist/pkg/headless.js +354 -109
- package/dist/pkg/story-variables.js +36 -3
- package/package.json +1 -1
- package/src/components/macros/For.tsx +16 -9
- package/src/components/macros/PassageDisplay.tsx +9 -1
- package/src/components/macros/Repeat.tsx +6 -1
- package/src/components/macros/Timed.tsx +5 -1
- package/src/components/macros/Watch.tsx +24 -4
- package/src/components/macros/detached-body.tsx +31 -9
- package/src/define-macro.ts +21 -4
- package/src/hooks/use-modal-focus.ts +2 -0
- package/src/hooks/use-story-fields.ts +8 -0
- package/src/runtime-errors.ts +4 -8
- package/src/saves/save-manager.ts +63 -0
- package/src/store.ts +42 -8
- package/src/story-api.ts +4 -3
- package/src/story-variables.ts +15 -3
- package/src/structural.ts +46 -13
- package/src/triggers.ts +17 -0
- package/src/utils/control-edits.ts +81 -30
- package/src/utils/listeners.ts +23 -0
- package/src/utils/object-path.ts +31 -8
- package/src/utils/stable-key.ts +73 -44
- package/types/index.d.ts +4 -1
- package/types/tooling.d.ts +5 -1
package/dist/pkg/format.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
window.storyFormat({"name":"spindle","version":"0.59.15","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=[],j=r,Se=j.__b,Ce=j.__r,we=j.diffed,Te=j.__c,Ee=j.unmount,De=j.__;function Oe(e,t){j.__h&&j.__h(A,e,be||t),be=0;var n=A.__H||(A.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function ke(e){return be=1,Ae(He,e)}function Ae(e,t,n){var r=Oe(_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 je(e,t){var n=Oe(_e++,3);!j.__s&&Ve(n.__H,t)&&(n.__=e,n.u=t,A.__H.__h.push(n))}function Me(e,t){var n=Oe(_e++,4);!j.__s&&Ve(n.__H,t)&&(n.__=e,n.u=t,A.__h.push(n))}function M(e){return be=5,Ne(function(){return{current:e}},[])}function Ne(e,t){var n=Oe(_e++,7);return Ve(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function Pe(e,t){return be=8,Ne(function(){return e},t)}function Fe(e){var t=A.context[e.__c],n=Oe(_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=[],j.__e(n,e.__v)}}}j.__b=function(e){A=null,Se&&Se(e)},j.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),De&&De(e,t)},j.__r=function(e){Ce&&Ce(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},j.diffed=function(e){we&&we(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(xe.push(t)!==1&&ye===j.requestAnimationFrame||((ye=j.requestAnimationFrame)||Re)(Ie)),t.__H.__.some(function(e){e.u&&(e.__H=e.u),e.u=void 0})),ve=A=null},j.__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=[],j.__e(n,e.__v)}}),Te&&Te(e,t)},j.unmount=function(e){Ee&&Ee(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&&j.__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=ke({t:{__:n,u:t}}),i=r[0].t,a=r[1];return Me(function(){i.__=n,i.u=t,Ke(i)&&a({t:i})},[e,n,t]),je(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=Pe(()=>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)||Ht(e)||!!e[xt]||!!e[Tt]?.[xt]||Ut(e)||Wt(e):!1}var Nt=Ct[Et][Tt].toString(),Pt=new WeakMap;function Ft(e){if(!e||!Gt(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(!Kt(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,t,n=!0){Lt(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 Lt(e){let t=e[N];return t?t.type_:Ht(e)?1:Ut(e)?2:Wt(e)?3:0}var Rt=(e,t,n=Lt(e))=>n===2?e.has(t):Ct[Et].hasOwnProperty.call(e,t),zt=(e,t,n=Lt(e))=>n===2?e.get(t):e[t],Bt=(e,t,n,r=Lt(e))=>{r===2?e.set(t,n):r===3?e.add(n):e[t]=n};function Vt(e,t){return e===t?e!==0||1/e==1/t:e!==e&&t!==t}var Ht=Array.isArray,Ut=e=>e instanceof Map,Wt=e=>e instanceof Set,Gt=e=>typeof e==`object`,Kt=e=>typeof e==`function`,qt=e=>typeof e==`boolean`;function Jt(e){let t=+e;return Number.isInteger(t)&&String(t)===e}var Yt=e=>Gt(e)?e?.[N]:null,Xt=e=>e.copy_||e.base_,Zt=e=>{let t=Yt(e);return t?t.copy_??t.base_:e},Qt=e=>e.modified_?e.copy_:e.base_;function $t(e,t){if(Ut(e))return new Map(e);if(Wt(e))return new Set(e);if(Ht(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 en(e,t=!1){return rn(e)||jt(e)||!Mt(e)?e:(Lt(e)>1&&Ct.defineProperties(e,{set:nn,add:nn,clear:nn,delete:nn}),Ct.freeze(e),t&&It(e,(e,t)=>{en(t,!0)},!1),e)}function tn(){St(2)}var nn={[At]:tn};function rn(e){return e===null||!Gt(e)?!0:Ct.isFrozen(e)}var an=`MapSet`,on=`Patches`,sn=`ArrayMethods`,cn={};function ln(e){let t=cn[e];return t||St(0,e),t}var un=e=>!!cn[e];function dn(e,t){cn[e]||(cn[e]=t)}var fn,pn=()=>fn,P=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:un(an)?ln(an):void 0,arrayMethodsPlugin_:un(sn)?ln(sn):void 0});function F(e,t){t&&(e.patchPlugin_=ln(on),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function mn(e){hn(e),e.drafts_.forEach(I),e.drafts_=null}function hn(e){e===fn&&(fn=e.parent_)}var gn=e=>fn=P(fn,e);function I(e){let t=e[N];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function _n(e,t){t.unfinalizedDrafts_=t.drafts_.length;let n=t.drafts_[0];if(e!==void 0&&e!==n){n[N].modified_&&(mn(t),St(4)),Mt(e)&&(e=vn(t,e));let{patchPlugin_:r}=t;r&&r.generateReplacementPatches_(n[N].base_,e,t)}else e=vn(t,n);return yn(t,e,!0),mn(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e===bt?void 0:e}function vn(e,t){if(rn(t))return t;let n=t[N];if(!n)return Dn(t,e.handledSet_,e);if(!xn(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);Tn(n,e)}return n.copy_}function yn(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&en(t,n)}function bn(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var xn=(e,t)=>e.scope_===t,Sn=[];function Cn(e,t,n,r){let i=Xt(e),a=e.type_;if(r!==void 0&&zt(i,r,a)===t){Bt(i,r,n,a);return}if(!e.draftLocations_){let t=e.draftLocations_=new Map;It(i,(e,n)=>{if(jt(n)){let r=t.get(n)||[];r.push(e),t.set(n,r)}})}let o=e.draftLocations_.get(t)??Sn;for(let e of o)Bt(i,e,n,a)}function wn(e,t,n){e.callbacks_.push(function(r){let i=t;if(!i||!xn(i,r))return;r.mapSetPlugin_?.fixSetContents(i);let a=Qt(i);Cn(e,i.draft_??i,a,n),Tn(i,r)})}function Tn(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)}bn(e)}}function En(e,t,n){let{scope_:r}=e;if(jt(n)){let i=n[N];xn(i,r)&&i.callbacks_.push(function(){Pn(e),Cn(e,n,Qt(i),t)})}else Mt(n)&&e.callbacks_.push(function(){let i=Xt(e);e.type_===3?i.has(n)&&Dn(n,r.handledSet_,r):zt(i,t,e.type_)===n&&r.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&Dn(zt(e.copy_,t,e.type_),r.handledSet_,r)})}function Dn(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||jt(e)||t.has(e)||!Mt(e)||rn(e)?e:(t.add(e),It(e,(r,i)=>{if(jt(i)){let t=i[N];xn(t,n)&&(Bt(e,r,Qt(t),e.type_),bn(t))}else Mt(i)&&Dn(i,t,n)}),e)}function L(e,t){let n=Ht(e),r={type_:n?1:0,scope_:t?t.scope_:pn(),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=Xt(e);if(!Rt(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)&&Jt(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 Xt(e)},ownKeys(e){return Reflect.ownKeys(Xt(e))},set(e,t,n){let r=Mn(Xt(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){let r=An(Xt(e),t),i=r?.[N];if(i&&i.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(Vt(n,r)&&(n!==void 0||Rt(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),En(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=Xt(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?Xt(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_=$t(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(Kt(e)&&!Kt(t)){let n=t;t=e;let r=this;return function(e=n,...i){return r.produce(e,e=>t.call(this,e,...i))}}Kt(t)||St(6),n!==void 0&&!Kt(n)&&St(7);let r;if(Mt(e)){let i=gn(this),a=In(i,e,void 0),o=!0;try{r=t(a),o=!1}finally{o?mn(i):hn(i)}return F(i,n),_n(r,i)}else if(!e||!Gt(e)){if(r=t(e),r===void 0&&(r=e),r===bt&&(r=void 0),this.autoFreeze_&&en(r,!0),n){let t=[],i=[];ln(on).generateReplacementPatches_(e,r,{patches_:t,inversePatches_:i}),n(t,i)}return r}else St(1,e)},this.produceWithPatches=(e,t)=>{if(Kt(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]},qt(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),qt(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),qt(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Mt(e)||St(8),jt(e)&&(e=Ln(e));let t=gn(this),n=In(t,e,void 0);return n[N].isManual_=!0,hn(t),n}finishDraft(e,t){let n=e&&e[N];(!n||!n.isManual_)&&St(9);let{scope_:r}=n;return F(r,t),_n(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=ln(on).applyPatches_;return jt(e)?r(e,t):this.produce(e,e=>r(e,t))}};function In(e,t,n,r){let[i,a]=Ut(t)?ln(an).proxyMap_(t,n):Wt(t)?ln(an).proxySet_(t,n):L(t,n);return(n?.scope_??pn()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?wn(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)||rn(e))return e;let t=e[N],n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=$t(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=$t(e,!0);return It(n,(e,t)=>{Bt(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=Yt(zt(e,n.key_)),i=zt(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||Rt(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=zt(n,r),!Gt(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;It(e.assigned_,(e,l)=>{let u=zt(o,e,c),f=zt(s,e,c),p=l?Rt(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=Lt(o),n=i[e];typeof n!=`string`&&typeof n!=`number`&&(n=``+n),(t===0||t===1)&&(n===`__proto__`||n===Tt)&&St(19),Kt(o)&&n===Et&&St(19),o=zt(o,n),Gt(o)||St(18,i.join(`/`))}let s=Lt(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(Ht(e))return e.map(u);if(Ut(e))return new Map(Array.from(e.entries()).map(([e,t])=>[e,u(t)]));if(Wt(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 Rt(e,xt)&&(t[xt]=e[xt]),t}function d(e){return jt(e)?u(e):e}dn(on,{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_:pn(),modified_:!1,finalized_:!1,copy_:void 0,assigned_:void 0,base_:e,draft_:this,isManual_:!1,revoked_:!1,callbacks_:[]}}get size(){return Xt(this[N]).size}has(e){return Xt(this[N]).has(e)}set(e,t){let r=this[N];return o(r),(!Xt(r).has(e)||Xt(r).get(e)!==t)&&(n(r),Nn(r),r.assigned_.set(e,!0),r.copy_.set(e,t),r.assigned_.set(e,!0),En(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),Xt(e).size&&(n(e),Nn(e),e.assigned_=new Map,It(e.base_,t=>{e.assigned_.set(t,!1)}),e.copy_.clear())}forEach(e,t){let n=this[N];Xt(n).forEach((n,r,i)=>{e.call(t,this.get(r),r,this)})}get(e){let t=this[N];o(t);let r=Xt(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 Xt(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_:pn(),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 Xt(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),En(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),Xt(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(Xt(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(Zt(t))})}}dn(an,{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=new Set([`if`,`switch`,`timed`]),nr=[[`|`,!1],[`->`,!1],[`<-`,!0]],rr={},ir=/^<[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 ar(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 nr){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 or(e){return`\"`+e.replace(/[\\\\\"]/g,`\\\\$&`)+`\"`}function sr(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 cr(e){return e.lex===`html`?(e.isClose?`</`:`<`)+e.tag+`>`:Yn+(e.isClose?`/`:``)+e.name+Xn}function lr(e){return e.lex===`html`?`</`+e.tag+`>`:Yn+`/`+e.name+Xn}function ur(e){return`line `+e.start.line+`, column `+e.start.column}function dr(e,t){return e.lex===t.lex&&e.lower===t.lower}function fr(e,t,n){return n.lex=e,n.start=t.start.offset,n.end=t.end.offset,n.loc=t,n}function pr(e){switch(e.lex){case`text`:return{type:`text`,value:e.value};case`link`:return Qn({type:`macro`,name:`link`,rawArgs:or(e.display)+` `+or(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);default:return e}}function mr(e){let t={start:e.start,end:e.end};switch(e.lex){case`text`:return{type:`text`,value:e.value,...t};case`link`:return Qn({type:`link`,display:e.display,target:e.target,targetStart:e.targetStart,targetEnd:e.targetEnd,...t},e);case`variable`:return Qn({type:`variable`,name:e.name,scope:e.scope,...t},e);case`expression`:return Qn({type:`expression`,expression:e.expression,...t},e);case`macro`:return Qn({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 hr(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&&r&&r.lex===`text`&&!r.escape&&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 gr=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 _r(e,t){t=t===void 0?{}:t;let n={},r=t.grammarSource,i={Markup:An,Tokens:Hn,SelectorsPrefix:yr},a=An,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=wn(),D=Cn([`\\\\`,`{`,`[`,`<`],!0,!1,!1),O=Sn(`\\x3C!--`,!1),te=Sn(`>`,!1),ne=Sn(`->`,!1),re=Sn(`-->`,!1),k=Sn(`\\\\`,!1),ie=Cn([`{`,`}`],!1,!1,!1),ae=Sn(`{`,!1),oe=Cn([`$`,`_`,`@`,`%`,`(`,`!`,`/`,[`a`,`z`],[`A`,`Z`]],!1,!1,!1),se=Sn(`<`,!1),ce=Sn(`[`,!1),le=Sn(`[[`,!1),ue=Sn(`]]`,!1),de=Sn(` `,!1),fe=Cn([`.`,`#`],!1,!1,!1),pe=Cn([[`a`,`z`],[`A`,`Z`],[`0`,`9`],`_`,`-`],!1,!1,!1),me=Cn([`$`,`_`,`@`,`%`],!1,!1,!1),he=Cn([[`a`,`z`],[`A`,`Z`],[`0`,`9`],`_`,`.`],!1,!1,!1),ge=Sn(`}`,!1),_e=Cn([`$`,`_`,`@`,`%`,`(`,`!`],!1,!1,!1),A=Sn(`/`,!1),ve=Cn([[`a`,`z`],[`A`,`Z`]],!1,!1,!1),ye=Cn([` `,`\t`,`\n`,`\\r`,`\\v`,`\\f`,`\\xA0`,` `,[` `,` `],`\\u2028`,`\\u2029`,` `,` `,` `,``,`}`],!0,!1,!1),be=Cn([[`a`,`z`],[`A`,`Z`],[`0`,`9`],`.`,`!`,`#`,`$`,`%`,`&`,`'`,`*`,`+`,`/`,`=`,`?`,`^`,`_`,\"`\",`|`,`~`,`-`],!1,!1,!1),xe=Sn(`@`,!1),j=Cn([[`a`,`z`],[`A`,`Z`],[`0`,`9`],`.`,`-`],!1,!1,!1),Se=Cn([[`\t`,`\\r`],` `,`/`,`>`,`\\xA0`,` `,[` `,` `],[`\\u2028`,`\\u2029`],` `,` `,` `,``],!1,!1,!1),Ce=Sn(`</`,!1),we=Cn([[`a`,`z`],[`A`,`Z`],[`0`,`9`],`-`],!1,!1,!1),Te=Cn([[`\t`,`\\r`],` `,`\"`,`'`,`/`,[`<`,`>`],`{`,`}`,`\\xA0`,` `,[` `,` `],[`\\u2028`,`\\u2029`],` `,` `,` `,``],!1,!1,!1),Ee=Sn(`=`,!1),De=Sn(`\"`,!1),Oe=Cn([`\"`],!0,!1,!1),ke=Sn(`'`,!1),Ae=Cn([`'`],!0,!1,!1),je=Cn([`\"`,`'`],!1,!1,!1),Me=Cn([` `,`\t`,`\n`,`\\r`,`\\v`,`\\f`,`\\xA0`,` `,[` `,` `],`\\u2028`,`\\u2029`,` `,` `,` `,``,`>`],!0,!1,!1),M=Cn([` `,`\t`,`\n`,`\\r`,`\\v`,`\\f`,`\\xA0`,` `,[` `,` `],`\\u2028`,`\\u2029`,` `,` `,` `,``],!1,!1,!1);function Ne(e){return e}function Pe(e){B(cr(e)+` must be directly inside {`+er[e.lower]+Xn,e.loc)}function Fe(e){B(cr(e)+` closes nothing: no `+(e.lex===`html`?`<`+e.tag+`>`:Yn+e.name+Xn)+` is open here`,e.loc)}function Ie(e){return hr(e,pr)}function Le(e){return e.kind===`open`}function Re(e){return zr=e.lower,Ir.isRaw(zr)}function ze(e,t){return t}function Be(e){return Ir.isBlock(e.lower)}function Ve(e,t){return t}function He(e){return null}function Ue(e,t){return Hr(e,t)}function We(){return!R}function Ge(e){return!e.isSelfClose}function Ke(e,t){return t}function qe(e,t){let n={type:`html`,tag:e.tag,attributes:e.attributes,children:[]};return t&&(Vr(e,t),n.children=t.children),n}function Je(e,t,n){return{children:e,branches:t,end:n}}function Ye(e,t){return{tag:e,children:t}}function Xe(){return null}function Ze(e){return e.kind===`branch`}function Qe(e){return e}function $e(e){return e.kind===`close`}function et(e){return e}function tt(){return!R}function nt(e){return e}function rt(t){return z(Ir.rawBodyEnd(e,t,zr))}function it(e){return Lr-vn()}function at(e,t,n){return{children:t?[{type:`text`,value:t}]:[],branches:[],end:n}}function ot(){return{children:[],branches:[],end:null}}function st(e){return hr(e,mr)}function ct(){return!R}function lt(e){return e}function ut(){return!R}function dt(e){return $n.has(e.lower)?null:e}function ft(e){return zr=e.lower,e.kind===`open`&&Ir.isRaw(zr)}function pt(e,t){return t}function mt(e,t){return t?[e,t]:e}function ht(t){return z(Ir.rawBodyEnd(e,t,zr))}function gt(e){return Lr-vn()}function _t(e,t,n){let r={start:{offset:e},end:{offset:e+t.length}};return[t?fr(`text`,r,{value:t}):null,n]}function vt(){return vn()}function yt(e){return fr(`text`,yn(),{value:e})}function bt(e){return fr(`text`,yn(),{value:e})}function xt(e){return e.length%2==1}function N(e,t){return t}function St(t,n){let r=yn(),i=e.charAt(r.end.offset);if(R){if(!n&&i!==Yn&&i!==Xn)return fr(`text`,r,{value:t});let e=fr(`text`,r,{value:`\\\\`.repeat(t.length>>1)+(n||``)});return e.escape=!0,e}if(!n)return fr(`text`,r,{value:t});let a=fr(`text`,r,{value:t.slice(1)});a.end=r.end.offset-2;let o=fr(`text`,r,{value:n});return o.start=r.end.offset-2,o.escape=!0,t.length>1?[a,o]:o}function Ct(){return fr(`text`,yn(),{value:Yn})}function wt(){return!R}function Tt(){return fr(`text`,yn(),{value:`<`})}function Et(){return fr(`text`,yn(),{value:`[`})}function Dt(){return!R}function Ot(e,t,n){return Qn(fr(`link`,yn(),ar(n,t)),e)}function kt(){return!R}function At(){B(`Unclosed link: [[ without ]]`,yn())}function jt(e){return sr(e)}function Mt(){return rr}function Nt(e,t){return{...e,end:t}}function Pt(e,t){return[e,t]}function Ft(e,t,n){return Qn(fr(`variable`,yn(),{name:n,scope:Zn[t]}),e)}function It(e,t){return Qn(fr(`expression`,yn(),{expression:t}),e)}function Lt(){B(`Unclosed `+Yn+e.substr(yn().end.offset,1)+`…: no } ends it`,yn())}function Rt(t){return z(Ir.closeBrace(e,t,t))}function zt(e){return Lr-vn()}function Bt(e,t){return t}function Vt(t,n,r,i,a){return z(Ir.closeBrace(e,a,n))}function Ht(e,t,n,r,i){return Lr-vn()}function Ut(e,t,n,r,i,a){return a}function Wt(e,t,n,r,i,a){let o=yn(),s=r.toLowerCase(),c=fr(`macro`,o,{name:r,lower:s,rawArgs:``,isClose:!!n});return a===null&&B(`Unclosed `+Yn+(n?`/`:``)+r+`…: no } ends the macro`,o),c.rawArgs=a.trim(),n?(e!==rr&&B(`A closing tag takes no selectors: `+cr(c),o),c.rawArgs&&B(`A closing tag takes no arguments: `+Yn+`/`+r+` `+c.rawArgs+Xn,o),c.kind=`close`):(Qn(c,e),c.kind=Object.prototype.hasOwnProperty.call(er,s)?`branch`:`open`),c}function Gt(e){B(`A closing tag starts with a letter after `+Yn+`/`,yn())}function Kt(e){return ir.test(e)}function qt(e){return fr(`text`,yn(),{value:e})}function Jt(){return!R}function Yt(e){return $n.has(e.lower)}function Xt(e){return null}function Zt(e,t,n){let r=e.toLowerCase();return fr(`html`,yn(),{tag:e,lower:r,attributes:Br(t),isClose:!1,isSelfClose:!!n||$n.has(r)})}function Qt(t,n){let r=e.charAt(n);r||B(`Unclosed tag <`+t+`: no > ends it (write < for a < that starts no tag)`,yn());let i={source:yn().source,start:{offset:n,line:0,column:0},end:{offset:n+1,line:0,column:0}};B(`Unexpected `+JSON.stringify(r)+` in the tag <`+t+`>: expected an attribute, or > to end the tag`,i)}function $t(e){return fr(`html`,yn(),{tag:e,lower:e.toLowerCase(),attributes:{},isClose:!0,isSelfClose:!1})}function en(e){return Rr=Ir.isCodeAttribute(e),!0}function tn(e,t){return t}function nn(e,t){return[e,t??``]}function rn(e){return e}function an(e){return e}function on(e){B(`Unclosed attribute value: the `+e+` here has no closing `+e,yn())}function sn(){return!Rr}function cn(e){return e.length%2==1}function ln(){return!Rr}function un(t,n){return z(Ir.closeBrace(e,n,t))}function dn(e,t){return Lr-vn()}function fn(){return!Rr}function pn(){return Rr}let P=t.peg$currPos|0,F=P,mn=[{line:1,column:1}],hn=P,gn=t.peg$maxFailExpected||[],I=t.peg$silentFails|0,_n;if(t.startRule){if(!(t.startRule in i))throw Error(`Can't start parsing from rule \"`+t.startRule+`\".`);a=i[t.startRule]}function vn(){return F}function yn(){return Dn(F,P)}function bn(e,t){throw t=t===void 0?Dn(F,P):t,On(e,t)}function xn(t=P){let n=e.codePointAt(t);return n===void 0?``:String.fromCodePoint(n)}function Sn(e,t){return{type:`literal`,text:e,ignoreCase:t}}function Cn(e,t,n,r){return{type:`class`,parts:e,inverted:t,ignoreCase:n,unicode:r}}function wn(){return{type:`any`}}function Tn(){return{type:`end`}}function En(t){let n=mn[t],r;if(n)return n;if(t>=mn.length)r=mn.length-1;else for(r=t;!mn[--r];);for(n=mn[r],n={line:n.line,column:n.column};r<t;)e.charCodeAt(r)===10?(n.line++,n.column=1):n.column++,r++;return mn[t]=n,n}function Dn(e,t,n){let i=En(e),a=En(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<hn||(P>hn&&(hn=P,gn=[]),gn.push(e))}function On(e,t){return new gr(e,null,null,t)}function kn(e,t,n){return new gr(gr.buildMessage(e,t),e,t,n)}function An(){let e,t,r;return e=P,t=Mn(),r=jn(),r===n?(P=e,e=n):(F=e,e=Ne(t)),e}function jn(){let t,r;return t=P,I++,e.length>P?(r=e.charAt(P),P++):(r=n,I===0&&L(E)),I--,r===n?t=void 0:(P=t,t=n),t===n&&(t=P,r=zn(),r!==n&&(F=t,r=Pe(r)),t=r,t===n&&(t=P,r=Bn(),r!==n&&(F=t,r=Fe(r)),t=r)),t}function Mn(){let e,t,r;for(e=P,t=[],r=Nn();r!==n;)t.push(r),r=Nn();return F=e,t=Ie(t),e=t,e}function Nn(){let e;return e=Kn(),e===n&&(e=Jn(),e===n&&(e=qn(),e===n&&(e=or(),e===n&&(e=Er(),e===n&&(e=Fn(),e===n&&(e=Dr(),e===n&&(e=Sr(),e===n&&(e=Pn(),e===n&&(e=nr()))))))))),e}function Pn(){let e,t,r,i,a,o;return e=P,t=wr(),t===n?(P=e,e=n):(F=P,r=Le(t),r=r?void 0:n,r===n?(P=e,e=n):(i=P,F=P,a=Re(t),a=a?void 0:n,a===n?(P=i,i=n):(o=Vn(),o===n?(P=i,i=n):(F=i,i=ze(t,o))),i===n&&(i=P,F=P,a=Be(t),a=a?void 0:n,a===n?(P=i,i=n):(o=In(),o===n?(P=i,i=n):(F=i,i=Ve(t,o))),i===n&&(i=P,a=``,F=i,a=He(t),i=a)),i===n?(P=e,e=n):(F=e,e=Ue(t,i)))),e}function Fn(){let e,t,r,i,a,o;return e=P,F=P,t=We(),t=t?void 0:n,t===n?(P=e,e=n):(r=Or(),r===n?(P=e,e=n):(i=P,F=P,a=Ge(r),a=a?void 0:n,a===n?(P=i,i=n):(o=In(),o===n?(P=i,i=n):(F=i,i=Ke(r,o))),i===n&&(i=null),F=e,e=qe(r,i))),e}function In(){let e,t,r,i;if(e=P,t=Mn(),t!==n){for(r=[],i=Ln();i!==n;)r.push(i),i=Ln();i=Rn(),i===n?(P=e,e=n):(F=e,e=Je(t,r,i))}else P=e,e=n;return e}function Ln(){let e,t,r;return e=P,t=zn(),t===n?(P=e,e=n):(r=Mn(),r===n?(P=e,e=n):(F=e,e=Ye(t,r))),e}function Rn(){let t,r,i;return t=Bn(),t===n&&(t=P,r=P,I++,e.length>P?(i=e.charAt(P),P++):(i=n,I===0&&L(E)),I--,i===n?r=void 0:(P=r,r=n),r!==n&&(F=t,r=Xe()),t=r),t}function zn(){let e,t,r;return e=P,t=wr(),t===n?(P=e,e=n):(F=P,r=Ze(t),r=r?void 0:n,r===n?(P=e,e=n):(F=e,e=Qe(t))),e}function Bn(){let e,t,r;return e=P,t=wr(),t===n?(P=e,e=n):(F=P,r=$e(t),r=r?void 0:n,r===n?(P=e,e=n):(F=e,e=et(t))),e===n&&(e=P,F=P,t=tt(),t=t?void 0:n,t===n?(P=e,e=n):(r=kr(),r===n?(P=e,e=n):(F=e,e=nt(r)))),e}function Vn(){let t,r,i,a,o,s,c,l;if(t=P,r=Gn(),F=P,i=rt(r),i=i?void 0:n,i!==n){for(a=P,o=it(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=Bn(),o===n?(P=t,t=n):(F=t,t=at(r,a,o)))}else P=t,t=n;return t===n&&(t=P,r=``,F=t,r=ot(),t=r),t}function Hn(){let e,t,r;for(e=P,t=[],r=Un();r!==n;)t.push(r),r=Un();return F=e,t=st(t),e=t,e}function Un(){let e,t,r,i,a;return e=Kn(),e===n&&(e=Jn(),e===n&&(e=qn(),e===n&&(e=or(),e===n&&(e=Er(),e===n&&(e=P,F=P,t=ct(),t=t?void 0:n,t===n?(P=e,e=n):(r=Or(),r===n?(P=e,e=n):(F=e,e=lt(r))),e===n&&(e=P,F=P,t=ut(),t=t?void 0:n,t===n?(P=e,e=n):(r=kr(),r===n?(P=e,e=n):(F=e,e=dt(r))),e===n&&(e=Sr(),e===n&&(e=P,t=wr(),t===n?(P=e,e=n):(r=P,F=P,i=ft(t),i=i?void 0:n,i===n?(P=r,r=n):(a=Wn(),a===n?(P=r,r=n):(F=r,r=pt(t,a))),r===n&&(r=null),F=e,e=mt(t,r)),e===n&&(e=nr()))))))))),e}function Wn(){let t,r,i,a,o,s,c,l;if(t=P,r=Gn(),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):(o=Bn(),o===n?(P=t,t=n):(F=t,t=_t(r,a,o)))}else P=t,t=n;return t}function Gn(){let e,t;return e=P,t=``,F=e,t=vt(),e=t,e}function Kn(){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=yt(r)),t=r,t}function qn(){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=bt(r)),t=r,t}function Jn(){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=xt(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=N(r,o))),i===n&&(i=null),F=t,t=St(r,i)),t}function nr(){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=vr(),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=Ct())),t===n&&(t=P,r=P,I++,i=P,F=P,a=wt(),a=a?void 0:n,a===n?(P=i,i=n):(o=kr(),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=Tt())),t===n&&(t=P,e.charCodeAt(P)===91?(r=`[`,P++):(r=n,I===0&&L(ce)),r!==n&&(F=t,r=Et()),t=r)),t}function or(){let t,r,i,a,o,s,c;return t=P,F=P,r=Dt(),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=vr(),a===n?(P=t,t=n):(o=Gn(),s=P,c=_r(),s=e.substring(s,P),e.substr(P,2)===`]]`?(c=`]]`,P+=2):(c=n,I===0&&L(ue)),c===n?(P=t,t=n):(F=t,t=Ot(a,o,s))))),t===n&&(t=P,F=P,r=kt(),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=At()))),t}function _r(){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 vr(){let t,r,i;if(t=P,r=[],i=br(),i!==n)for(;i!==n;)r.push(i),i=br();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=jt(r)),t===n&&(t=P,r=``,F=t,r=Mt(),t=r),t}function yr(){let t,r,i,a,o;if(t=P,r=vr(),r!==n){for(i=Gn(),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=Nt(r,i)}else P=t,t=n;return t}function br(){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=xr();o!==n;)a.push(o),o=xr();i=e.substring(i,P),F=t,t=Pt(r,i)}else P=t,t=n;return t}function xr(){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 Sr(){let t,r,i,a,o,s,c;if(t=P,e.charCodeAt(P)===123?(r=`{`,P++):(r=n,I===0&&L(ae)),r!==n)if(i=vr(),i!==n)if(a=e.charAt(P),f.test(a)?P++:(a=n,I===0&&L(me)),a!==n){for(o=P,s=[],c=e.charAt(P),p.test(c)?P++:(c=n,I===0&&L(he));c!==n;)s.push(c),c=e.charAt(P),p.test(c)?P++:(c=n,I===0&&L(he));o=e.substring(o,P),e.charCodeAt(P)===125?(s=`}`,P++):(s=n,I===0&&L(ge)),s===n?(P=t,t=n):(F=t,t=Ft(i,a,o))}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=vr(),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):(o=Cr(),o===n?(P=t,t=n):(e.charCodeAt(P)===125?(s=`}`,P++):(s=n,I===0&&L(ge)),s===n?(P=t,t=n):(F=t,t=It(i,o)))))),t===n&&(t=P,e.charCodeAt(P)===123?(r=`{`,P++):(r=n,I===0&&L(ae)),r===n?(P=t,t=n):(i=vr(),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=Lt()))))),t}function Cr(){let t,r,i,a,o,s,c,l;if(t=P,r=Gn(),F=P,i=Rt(r),i=i?void 0:n,i!==n){for(a=P,o=zt(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=Bt(r,a))}else P=t,t=n;return t}function wr(){let t,r,i,a,o,s,c,l,u,d,f,p,m,h;if(t=P,e.charCodeAt(P)===123?(r=`{`,P++):(r=n,I===0&&L(ae)),r!==n)if(i=vr(),i!==n)if(a=Gn(),e.charCodeAt(P)===47?(o=`/`,P++):(o=n,I===0&&L(A)),o===n&&(o=null),s=Tr(),s!==n){if(c=Gn(),l=P,F=P,u=Vt(i,a,o,s,c),u=u?void 0:n,u!==n){for(d=P,f=Ht(i,a,o,s,c),p=P,m=[],m.length>=(f|0)?h=n:e.length>P?(h=e.charAt(P),P++):(h=n,I===0&&L(E));h!==n;)m.push(h),m.length>=(f|0)?h=n:e.length>P?(h=e.charAt(P),P++):(h=n,I===0&&L(E));m.length<(f|0)?(P=p,p=n):p=m,f=p,d=f===n?f:e.substring(d,P),d===n?(P=l,l=n):(e.charCodeAt(P)===125?(f=`}`,P++):(f=n,I===0&&L(ge)),f===n?(P=l,l=n):(F=l,l=Ut(i,a,o,s,c,d)))}else P=l,l=n;l===n&&(l=null),F=t,t=Wt(i,a,o,s,c,l)}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=vr(),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=Gt(i))))),t}function Tr(){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 Er(){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(j)),l!==n)for(;l!==n;)c.push(l),l=e.charAt(P),v.test(l)?P++:(l=n,I===0&&L(j));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=Kt(r),i=i?void 0:n,i===n?(P=t,t=n):(F=t,t=qt(r))),t}function Dr(){let e,t,r,i;return e=P,F=P,t=Jt(),t=t?void 0:n,t===n?(P=e,e=n):(r=kr(),r===n?(P=e,e=n):(F=P,i=Yt(r),i=i?void 0:n,i===n?(P=e,e=n):(F=e,e=Xt(r)))),e}function Or(){let t,r,i,a,o,s,c;if(t=P,e.charCodeAt(P)===60?(r=`<`,P++):(r=n,I===0&&L(se)),r!==n)if(i=Ar(),i!==n){for(a=[],o=jr();o!==n;)a.push(o),o=jr();o=Pr(),e.charCodeAt(P)===47?(s=`/`,P++):(s=n,I===0&&L(A)),s===n&&(s=null),e.charCodeAt(P)===62?(c=`>`,P++):(c=n,I===0&&L(te)),c===n?(P=t,t=n):(F=t,t=Zt(i,a,s))}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=Ar(),i!==n)if(a=P,I++,o=e.charAt(P),y.test(o)?P++:(o=n,I===0&&L(Se)),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=jr();s!==n;)o.push(s),s=jr();s=Pr(),c=Gn(),F=t,t=Qt(i,c)}else P=t,t=n;else P=t,t=n;else P=t,t=n;return t}function kr(){let t,r,i,a;return t=P,e.substr(P,2)===`</`?(r=`</`,P+=2):(r=n,I===0&&L(Ce)),r===n?(P=t,t=n):(i=Ar(),i===n?(P=t,t=n):(Pr(),e.charCodeAt(P)===62?(a=`>`,P++):(a=n,I===0&&L(te)),a===n?(P=t,t=n):(F=t,t=$t(i)))),t}function Ar(){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(we));o!==n;)a.push(o),o=e.charAt(P),b.test(o)?P++:(o=n,I===0&&L(we));i=[i,a],r=i}else P=r,r=n;return t=r===n?r:e.substring(t,P),t}function jr(){let t,r,i,a,o,s,c;if(t=P,Pr(),r=P,i=[],a=P,o=P,I++,s=e.charAt(P),x.test(s)?P++:(s=n,I===0&&L(Te)),I--,s===n?o=void 0:(P=o,o=n),o===n?(P=a,a=n):(e.length>P?(s=e.charAt(P),P++):(s=n,I===0&&L(E)),s===n?(P=a,a=n):(o=[o,s],a=o)),a!==n)for(;a!==n;)i.push(a),a=P,o=P,I++,s=e.charAt(P),x.test(s)?P++:(s=n,I===0&&L(Te)),I--,s===n?o=void 0:(P=o,o=n),o===n?(P=a,a=n):(e.length>P?(s=e.charAt(P),P++):(s=n,I===0&&L(E)),s===n?(P=a,a=n):(o=[o,s],a=o));else i=n;return r=i===n?i:e.substring(r,P),r===n?(P=t,t=n):(F=P,i=en(r),i=i?void 0:n,i===n?(P=t,t=n):(a=P,o=Pr(),e.charCodeAt(P)===61?(s=`=`,P++):(s=n,I===0&&L(Ee)),s===n?(P=a,a=n):(Pr(),c=Mr(),c===n?(P=a,a=n):(F=a,a=tn(r,c))),a===n&&(a=null),F=t,t=nn(r,a))),t}function Mr(){let t,r,i,a,o;if(t=P,e.charCodeAt(P)===34?(r=`\"`,P++):(r=n,I===0&&L(De)),r!==n){for(i=P,a=[],o=Nr(),o===n&&(o=e.charAt(P),S.test(o)?P++:(o=n,I===0&&L(Oe)));o!==n;)a.push(o),o=Nr(),o===n&&(o=e.charAt(P),S.test(o)?P++:(o=n,I===0&&L(Oe)));i=e.substring(i,P),e.charCodeAt(P)===34?(a=`\"`,P++):(a=n,I===0&&L(De)),a===n?(P=t,t=n):(F=t,t=rn(i))}else P=t,t=n;if(t===n){if(t=P,e.charCodeAt(P)===39?(r=`'`,P++):(r=n,I===0&&L(ke)),r!==n){for(i=P,a=[],o=Nr(),o===n&&(o=e.charAt(P),C.test(o)?P++:(o=n,I===0&&L(Ae)));o!==n;)a.push(o),o=Nr(),o===n&&(o=e.charAt(P),C.test(o)?P++:(o=n,I===0&&L(Ae)));i=e.substring(i,P),e.charCodeAt(P)===39?(a=`'`,P++):(a=n,I===0&&L(ke)),a===n?(P=t,t=n):(F=t,t=an(i))}else P=t,t=n;if(t===n&&(t=P,r=e.charAt(P),w.test(r)?P++:(r=n,I===0&&L(je)),r!==n&&(F=t,r=on(r)),t=r,t===n)){for(t=P,r=[],i=e.charAt(P),T.test(i)?P++:(i=n,I===0&&L(Me));i!==n;)r.push(i),i=e.charAt(P),T.test(i)?P++:(i=n,I===0&&L(Me));t=e.substring(t,P)}}return t}function Nr(){let t,r,i,a,o,s,l,u,d,p,m,g,_,v;if(t=P,F=P,r=sn(),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=cn(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=ln(),r=r?void 0:n,r!==n)if(e.charCodeAt(P)===123?(i=`{`,P++):(i=n,I===0&&L(ae)),i!==n)if(a=vr(),a!==n)if(o=Gn(),e.charCodeAt(P)===47?(s=`/`,P++):(s=n,I===0&&L(A)),s===n&&(s=null),l=Tr(),l!==n)if(u=Gn(),F=P,d=un(o,u),d=d?void 0:n,d!==n){for(p=P,m=dn(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=fn(),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=vr(),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=Cr(),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=pn(),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=Cr(),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 Pr(){let e,t;for(e=[],t=Fr();t!==n;)e.push(t),t=Fr();return e}function Fr(){let t;return t=e.charAt(P),ee.test(t)?P++:(t=n,I===0&&L(M)),t}let R=t.text===!0,Ir=t.hooks,Lr=-1,Rr=!1,zr=``;function z(e){return Lr=e,e>=0}function B(e,t){bn(e,t)}function Br(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 Vr(e,t){for(let n of t.branches){let t=er[n.tag.lower];(e.lex!==`macro`||e.lower!==t)&&B(cr(n.tag)+` must be directly inside {`+t+Xn+`, not inside `+cr(e),n.tag.loc)}t.end||B(`Unclosed `+cr(e)+`: no `+lr(e)+` closes it`,e.loc),dr(e,t.end)||B(cr(t.end)+` found where `+lr(e)+` should close the `+cr(e)+` opened at `+ur(e.loc),t.end.loc)}function Hr(e,t){let n={type:`macro`,name:e.lower,rawArgs:e.rawArgs,children:[]};if(!t)return Qn(n,e);if(Vr(e,t),n.children=t.children,tr.has(e.lower)){n.branches=[Qn({rawArgs:e.rawArgs,children:t.children},e)];for(let e of t.branches)n.branches.push(Qn({rawArgs:e.tag.rawArgs,children:e.children},e.tag));n.children=[]}else Qn(n,e);return n}_n=a();let Ur=_n!==n&&P===e.length;function Wr(){throw _n!==n&&P<e.length&&L(Tn()),kn(gn,hn<e.length?xn(hn):null,hn<e.length?Dn(hn,hn+1):Dn(hn,hn))}if(t.peg$library)return{peg$result:_n,peg$currPos:P,peg$FAILED:n,peg$maxFailExpected:gn,peg$maxFailPos:hn,peg$success:Ur,peg$throw:Ur?void 0:Wr};if(Ur)return _n;Wr()}var vr=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())}},yr=class{constructor(e=[]){this.names=new vr;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)}},br=new yr([`if`,`for`,`do`,`button`,`link`,`listbox`,`cycle`,`switch`,`timed`,`repeat`,`type`,`widget`,`span`,`nobr`]);function xr(e){return br.has(e)}function Sr(e){br.add(e)}var Cr=[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],wr=[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],Tr=`·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄ-ؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߽߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛-࢟࣊-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯৾ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍-ୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఄ఼ా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ೳഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ඁ-ඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ຼ່-໎໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜕ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠏-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᪿ-ᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭᳴᳷-᳹᷀-᷿‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯・꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧ꠬ꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱ꣿ-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_・`,Er=`ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙՠ-ֈא-תׯ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࡰ-ࢇࢉ-ࢠ-ࣉऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౝౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽ-ೞೠೡೱೲഄ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄຆ-ຊຌ-ຣລວ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜑᜟ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡸᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭌᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-Ა-ᲺᲽ-Ჿᳩ-ᳬᳮ-ᳳᳵᳶᳺᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿ-ℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆿㇰ-ㇿ㐀-䶿一-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ--ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꣾꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭩꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ`,Dr={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`},Or=`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`,kr={5:Or,\"5module\":Or+` export import`,6:Or+` const class extends export import super`},Ar=/^in(stanceof)?$/,jr=RegExp(`[`+Er+`]`),Mr=RegExp(`[`+Er+Tr+`]`);function Nr(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 Pr(e,t){return e<65?e===36:e<91?!0:e<97?e===95:e<123?!0:e<=65535?e>=170&&jr.test(String.fromCharCode(e)):t===!1?!1:Nr(e,wr)}function Fr(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&&Mr.test(String.fromCharCode(e)):t===!1?!1:Nr(e,wr)||Nr(e,Cr)}var R=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 Ir(e,t){return new R(e,{beforeExpr:!0,binop:t})}var Lr={beforeExpr:!0},Rr={startsExpr:!0},zr={};function z(e,t){return t===void 0&&(t={}),t.keyword=e,zr[e]=new R(e,t)}var B={num:new R(`num`,Rr),regexp:new R(`regexp`,Rr),string:new R(`string`,Rr),name:new R(`name`,Rr),privateId:new R(`privateId`,Rr),eof:new R(`eof`),bracketL:new R(`[`,{beforeExpr:!0,startsExpr:!0}),bracketR:new R(`]`),braceL:new R(`{`,{beforeExpr:!0,startsExpr:!0}),braceR:new R(`}`),parenL:new R(`(`,{beforeExpr:!0,startsExpr:!0}),parenR:new R(`)`),comma:new R(`,`,Lr),semi:new R(`;`,Lr),colon:new R(`:`,Lr),dot:new R(`.`),question:new R(`?`,Lr),questionDot:new R(`?.`),arrow:new R(`=>`,Lr),template:new R(`template`),invalidTemplate:new R(`invalidTemplate`),ellipsis:new R(`...`,Lr),backQuote:new R(\"`\",Rr),dollarBraceL:new R(\"${\",{beforeExpr:!0,startsExpr:!0}),eq:new R(`=`,{beforeExpr:!0,isAssign:!0}),assign:new R(`_=`,{beforeExpr:!0,isAssign:!0}),incDec:new R(`++/--`,{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new R(`!/~`,{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:Ir(`||`,1),logicalAND:Ir(`&&`,2),bitwiseOR:Ir(`|`,3),bitwiseXOR:Ir(`^`,4),bitwiseAND:Ir(`&`,5),equality:Ir(`==/!=/===/!==`,6),relational:Ir(`</>/<=/>=`,7),bitShift:Ir(`<</>>/>>>`,8),plusMin:new R(`+/-`,{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:Ir(`%`,10),star:Ir(`*`,10),slash:Ir(`/`,10),starstar:new R(`**`,{beforeExpr:!0}),coalesce:Ir(`??`,1),_break:z(`break`),_case:z(`case`,Lr),_catch:z(`catch`),_continue:z(`continue`),_debugger:z(`debugger`),_default:z(`default`,Lr),_do:z(`do`,{isLoop:!0,beforeExpr:!0}),_else:z(`else`,Lr),_finally:z(`finally`),_for:z(`for`,{isLoop:!0}),_function:z(`function`,Rr),_if:z(`if`),_return:z(`return`,Lr),_switch:z(`switch`),_throw:z(`throw`,Lr),_try:z(`try`),_var:z(`var`),_const:z(`const`),_while:z(`while`,{isLoop:!0}),_with:z(`with`),_new:z(`new`,{beforeExpr:!0,startsExpr:!0}),_this:z(`this`,Rr),_super:z(`super`,Rr),_class:z(`class`,Rr),_extends:z(`extends`,Lr),_export:z(`export`),_import:z(`import`,Rr),_null:z(`null`,Rr),_true:z(`true`,Rr),_false:z(`false`,Rr),_in:z(`in`,{beforeExpr:!0,binop:7}),_instanceof:z(`instanceof`,{beforeExpr:!0,binop:7}),_typeof:z(`typeof`,{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:z(`void`,{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:z(`delete`,{beforeExpr:!0,prefix:!0,startsExpr:!0})},Br=/\\r\\n?|\\n|\\u2028|\\u2029/,Vr=new RegExp(Br.source,`g`);function Hr(e){return e===10||e===13||e===8232||e===8233}function Ur(e,t,n){n===void 0&&(n=e.length);for(var r=t;r<n;r++){var i=e.charCodeAt(r);if(Hr(i))return r<n-1&&i===13&&e.charCodeAt(r+1)===10?r+2:r+1}return-1}var Wr=/[\\u1680\\u2000-\\u200a\\u202f\\u205f\\u3000\\ufeff]/,Gr=/(?:\\s|\\/\\/.*|\\/\\*[^]*?\\*\\/)*/g,Kr=Object.prototype,qr=Kr.hasOwnProperty,Jr=Kr.toString,Yr=Object.hasOwn||(function(e,t){return qr.call(e,t)}),Xr=Array.isArray||(function(e){return Jr.call(e)===`[object Array]`}),Zr=Object.create(null);function Qr(e){return Zr[e]||(Zr[e]=RegExp(`^(?:`+e.replace(/ /g,`|`)+`)$`))}function $r(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}var ei=/(?:[\\uD800-\\uDBFF](?![\\uDC00-\\uDFFF])|(?:[^\\uD800-\\uDBFF]|^)[\\uDC00-\\uDFFF])/,ti=function(e,t){this.line=e,this.column=t};ti.prototype.offset=function(e){return new ti(this.line,this.column+e)};var ni=function(e,t,n){this.start=t,this.end=n,e.sourceFile!==null&&(this.source=e.sourceFile)};function ri(e,t){for(var n=1,r=0;;){var i=Ur(e,r,t);if(i<0)return new ti(n,t-r);++n,r=i}}var ii={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},ai=!1;function oi(e){var t={};for(var n in ii)t[n]=e&&Yr(e,n)?e[n]:ii[n];if(t.ecmaVersion===`latest`?t.ecmaVersion=1e8:t.ecmaVersion==null?(!ai&&typeof console==`object`&&console.warn&&(ai=!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),Xr(t.onToken)){var r=t.onToken;t.onToken=function(e){return r.push(e)}}if(Xr(t.onComment)&&(t.onComment=si(t,t.onComment)),t.sourceType===`commonjs`&&t.allowAwaitOutsideFunction)throw Error(`Cannot use allowAwaitOutsideFunction with sourceType: commonjs`);return t}function si(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 ni(this,o,s)),e.ranges&&(c.range=[i,a]),t.push(c)}}var ci=1,li=2,ui=4,di=8,fi=16,pi=32,mi=64,hi=128,gi=256,_i=512,vi=1024,yi=ci|li|gi;function bi(e,t){return li|(e?ui:0)|(t?di:0)}var xi=0,Si=1,Ci=2,wi=3,Ti=4,Ei=5,Di=function(e,t,n){this.options=e=oi(e),this.sourceFile=e.sourceFile,this.keywords=Qr(kr[e.ecmaVersion>=6?6:e.sourceType===`module`?`5module`:5]);var r=``;e.allowReserved!==!0&&(r=Dr[e.ecmaVersion>=6?6:e.ecmaVersion===5?5:3],e.sourceType===`module`&&(r+=` await`)),this.reservedWords=Qr(r);var i=(r?r+` `:``)+Dr.strict;this.reservedWordsStrict=Qr(i),this.reservedWordsStrictBind=Qr(i+` `+Dr.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(Br).length)):this.lineStart=0,this.type=B.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`?li:ci),this.regexpState=null,this.privateNameStack=[]},Oi={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}};Di.prototype.parse=function(){var e=this,t=this.options.program||this.startNode();return this.nextToken(),this.catchStackOverflow(function(){return e.parseTopLevel(t)})},Oi.inFunction.get=function(){return(this.currentVarScope().flags&li)>0},Oi.inGenerator.get=function(){return(this.currentVarScope().flags&di)>0},Oi.inAsync.get=function(){return(this.currentVarScope().flags&ui)>0},Oi.canAwait.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e].flags;if(t&(gi|_i))return!1;if(t&li)return(t&ui)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction},Oi.allowReturn.get=function(){return!!(this.inFunction||this.options.allowReturnOutsideFunction&&this.currentVarScope().flags&ci)},Oi.allowSuper.get=function(){return(this.currentThisScope().flags&mi)>0||this.options.allowSuperOutsideMethod},Oi.allowDirectSuper.get=function(){return(this.currentThisScope().flags&hi)>0},Oi.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())},Oi.allowNewDotTarget.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e].flags;if(t&(gi|_i)||t&li&&!(t&fi))return!0}return!1},Oi.allowUsing.get=function(){var e=this.currentScope().flags;return!(e&vi||!this.inModule&&e&ci)},Oi.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&gi)>0},Di.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},Di.parse=function(e,t){return new this(t,e).parse()},Di.parseExpressionAt=function(e,t,n){var r=new this(n,e,t);return r.nextToken(),r.parseExpression()},Di.tokenizer=function(e,t){return new this(t,e)},Object.defineProperties(Di.prototype,Oi);var ki=Di.prototype,Ai=/^(?:'((?:\\\\[^]|[^'\\\\])*?)'|\"((?:\\\\[^]|[^\"\\\\])*?)\")/;ki.strictDirective=function(e){if(this.options.ecmaVersion<5)return!1;for(;;){Gr.lastIndex=e,e+=Gr.exec(this.input)[0].length;var t=Ai.exec(this.input.slice(e));if(!t)return!1;if((t[1]||t[2])===`use strict`){Gr.lastIndex=e+t[0].length;var n=Gr.exec(this.input),r=n.index+n[0].length,i=this.input.charAt(r);return i===`;`||i===`}`||Br.test(n[0])&&!(/[(`.[+\\-/*%<>=,?^&]/.test(i)||i===`!`&&this.input.charAt(r+1)===`=`||i===`i`&&ji(this,r))}e+=t[0].length,Gr.lastIndex=e,e+=Gr.exec(this.input)[0].length,this.input[e]===`;`&&e++}};function ji(e,t){for(var n=t+1,r=Math.min(e.input.length,t+11);n<r;){var i=e.fullCharCodeAt(n);if(!Fr(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`}ki.eat=function(e){return this.type===e?(this.next(),!0):!1},ki.isContextual=function(e){return this.type===B.name&&this.value===e&&!this.containsEsc},ki.eatContextual=function(e){return this.isContextual(e)?(this.next(),!0):!1},ki.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}},ki.expectContextual=function(e){this.eatContextual(e)||this.unexpected()},ki.canInsertSemicolon=function(){return this.type===B.eof||this.type===B.braceR||Br.test(this.input.slice(this.lastTokEnd,this.start))},ki.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0},ki.semicolon=function(){!this.eat(B.semi)&&!this.insertSemicolon()&&this.unexpected()},ki.afterTrailingComma=function(e,t){if(this.type===e)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),t||this.next(),!0},ki.expect=function(e){this.eat(e)||this.unexpected()},ki.unexpected=function(e){this.raise(e??this.start,`Unexpected token`)};var Mi=function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};ki.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`)}},ki.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`)},ki.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`)},ki.isSimpleAssignTarget=function(e){return e.type===`ParenthesizedExpression`?this.isSimpleAssignTarget(e.expression):e.type===`Identifier`||e.type===`MemberExpression`};var V=Di.prototype;V.parseTopLevel=function(e){var t=Object.create(null);for(e.body||(e.body=[]);this.type!==B.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 Ni={kind:`loop`},Pi={kind:`switch`};V.isLet=function(e){if(this.options.ecmaVersion<6||!this.isContextual(`let`))return!1;Gr.lastIndex=this.pos;var t=Gr.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(Pr(r)){var i=n;do n+=r<=65535?1:2;while(Fr(r=this.fullCharCodeAt(n)));if(r===92)return!0;var a=this.input.slice(i,n);if(!Ar.test(a))return!0}return!1},V.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual(`async`))return!1;Gr.lastIndex=this.pos;var e=Gr.exec(this.input),t=this.pos+e[0].length,n;return!Br.test(this.input.slice(this.pos,t))&&this.input.slice(t,t+8)===`function`&&(t+8===this.input.length||!(Fr(n=this.fullCharCodeAt(t+8))||n===92))},V.isUsingKeyword=function(e,t){if(this.options.ecmaVersion<17||!this.isContextual(e?`await`:`using`))return!1;Gr.lastIndex=this.pos;var n=Gr.exec(this.input),r=this.pos+n[0].length;if(Br.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||Fr(a=this.fullCharCodeAt(i))||a===92)return!1;Gr.lastIndex=i;var o=Gr.exec(this.input);if(r=i+o[0].length,o&&Br.test(this.input.slice(i,r)))return!1}var s=this.fullCharCodeAt(r);if(!Pr(s)&&s!==92)return!1;var c=r;do r+=s<=65535?1:2;while(Fr(s=this.fullCharCodeAt(r)));if(s===92)return!0;var l=this.input.slice(c,r);if(Ar.test(l))return!1;if(t&&!e&&l===`of`){Gr.lastIndex=r;var u=Gr.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},V.isAwaitUsing=function(e){return this.isUsingKeyword(!0,e)},V.isUsing=function(e){return this.isUsingKeyword(!1,e)},V.parseStatement=function(e,t,n){var r=this.type,i=this.startNode(),a;switch(this.isLet(e)&&(r=B._var,a=`let`),r){case B._break:case B._continue:return this.parseBreakContinueStatement(i,r.keyword);case B._debugger:return this.parseDebuggerStatement(i);case B._do:return this.parseDoStatement(i);case B._for:return this.parseForStatement(i);case B._function:return e&&(this.strict||e!==`if`&&e!==`label`)&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(i,!1,!e);case B._class:return e&&this.unexpected(),this.parseClass(i,!0);case B._if:return this.parseIfStatement(i);case B._return:return this.parseReturnStatement(i);case B._switch:return this.parseSwitchStatement(i);case B._throw:return this.parseThrowStatement(i);case B._try:return this.parseTryStatement(i);case B._const:case B._var:return a=a||this.value,e&&a!==`var`&&this.unexpected(),this.parseVarStatement(i,a);case B._while:return this.parseWhileStatement(i);case B._with:return this.parseWithStatement(i);case B.braceL:return this.parseBlock(!0,i);case B.semi:return this.parseEmptyStatement(i);case B._export:case B._import:if(this.options.ecmaVersion>10&&r===B._import){Gr.lastIndex=this.pos;var o=Gr.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===B._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===B.name&&d.type===`Identifier`&&this.eat(B.colon)?this.parseLabeledStatement(i,u,d,e):this.parseExpressionStatement(i,d)}},V.parseBreakContinueStatement=function(e,t){var n=t===`break`;this.next(),this.eat(B.semi)||this.insertSemicolon()?e.label=null:this.type===B.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`)},V.parseDebuggerStatement=function(e){return this.next(),this.semicolon(),this.finishNode(e,`DebuggerStatement`)},V.parseDoStatement=function(e){return this.next(),this.labels.push(Ni),e.body=this.parseStatement(`do`),this.labels.pop(),this.expect(B._while),e.test=this.parseParenExpression(),this.options.ecmaVersion>=6?this.eat(B.semi):this.semicolon(),this.finishNode(e,`DoWhileStatement`)},V.parseForStatement=function(e){this.next();var t=this.options.ecmaVersion>=9&&this.canAwait&&this.eatContextual(`await`)?this.lastTokStart:-1;if(this.labels.push(Ni),this.enterScope(0),this.expect(B.parenL),this.type===B.semi)return t>-1&&this.unexpected(t),this.parseFor(e,null);var n=this.isLet();if(this.type===B._var||this.type===B._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 Mi,d=this.start,f=t>-1?this.parseExprSubscripts(u,`await`):this.parseExpression(!0,u);return this.type===B._in||(o=this.options.ecmaVersion>=6&&this.isContextual(`of`))?(t>-1?(this.type===B._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))},V.parseForAfterInit=function(e,t,n){return(this.type===B._in||this.options.ecmaVersion>=6&&this.isContextual(`of`))&&t.declarations.length===1?(this.type===B._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))},V.parseFunctionStatement=function(e,t,n){return this.next(),this.parseFunction(e,Ii|(n?0:Li),!1,t)},V.parseIfStatement=function(e){return this.next(),e.test=this.parseParenExpression(),e.consequent=this.parseStatement(`if`),e.alternate=this.eat(B._else)?this.parseStatement(`if`):null,this.finishNode(e,`IfStatement`)},V.parseReturnStatement=function(e){return this.allowReturn||this.raise(this.start,`'return' outside of function`),this.next(),this.eat(B.semi)||this.insertSemicolon()?e.argument=null:(e.argument=this.parseExpression(),this.semicolon()),this.finishNode(e,`ReturnStatement`)},V.parseSwitchStatement=function(e){this.next(),e.discriminant=this.parseParenExpression(),e.cases=[],this.expect(B.braceL),this.labels.push(Pi),this.enterScope(vi);for(var t,n=!1;this.type!==B.braceR;)if(this.type===B._case||this.type===B._default){var r=this.type===B._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(B.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`)},V.parseThrowStatement=function(e){return this.next(),Br.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 Fi=[];V.parseCatchClauseParam=function(){var e=this.parseBindingAtom(),t=e.type===`Identifier`;return this.enterScope(t?pi:0),this.checkLValPattern(e,t?Ti:Ci),this.expect(B.parenR),e},V.parseTryStatement=function(e){if(this.next(),e.block=this.parseBlock(),e.handler=null,this.type===B._catch){var t=this.startNode();this.next(),this.eat(B.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(B._finally)?this.parseBlock():null,!e.handler&&!e.finalizer&&this.raise(e.start,`Missing catch or finally clause`),this.finishNode(e,`TryStatement`)},V.parseVarStatement=function(e,t,n){return this.next(),this.parseVar(e,!1,t,n),this.semicolon(),this.finishNode(e,`VariableDeclaration`)},V.parseWhileStatement=function(e){return this.next(),e.test=this.parseParenExpression(),this.labels.push(Ni),e.body=this.parseStatement(`while`),this.labels.pop(),this.finishNode(e,`WhileStatement`)},V.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`)},V.parseEmptyStatement=function(e){return this.next(),this.finishNode(e,`EmptyStatement`)},V.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===B._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`)},V.parseExpressionStatement=function(e,t){return e.expression=t,this.semicolon(),this.finishNode(e,`ExpressionStatement`)},V.parseBlock=function(e,t,n){for(e===void 0&&(e=!0),t===void 0&&(t=this.startNode()),t.body=[],this.expect(B.braceL),e&&this.enterScope(0);this.type!==B.braceR;){var r=this.parseStatement(null);t.body.push(r)}return n&&(this.strict=!1),this.next(),e&&this.exitScope(),this.finishNode(t,`BlockStatement`)},V.parseFor=function(e,t){return e.init=t,this.expect(B.semi),e.test=this.type===B.semi?null:this.parseExpression(),this.expect(B.semi),e.update=this.type===B.parenR?null:this.parseExpression(),this.expect(B.parenR),e.body=this.parseStatement(`for`),this.exitScope(),this.labels.pop(),this.finishNode(e,`ForStatement`)},V.parseForIn=function(e,t){var n=this.type===B._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(B.parenR),e.body=this.parseStatement(`for`),this.exitScope(),this.labels.pop(),this.finishNode(e,n?`ForInStatement`:`ForOfStatement`)},V.parseVar=function(e,t,n,r){for(e.declarations=[],e.kind=n;;){var i=this.startNode();if(this.parseVarId(i,n),this.eat(B.eq)?i.init=this.parseMaybeAssign(t):!r&&n===`const`&&!(this.type===B._in||this.options.ecmaVersion>=6&&this.isContextual(`of`))?this.unexpected():!r&&(n===`using`||n===`await using`)&&this.options.ecmaVersion>=17&&this.type!==B._in&&!this.isContextual(`of`)?this.raise(this.lastTokEnd,`Missing initializer in `+n+` declaration`):!r&&i.id.type!==`Identifier`&&!(t&&(this.type===B._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(B.comma))break}return e},V.parseVarId=function(e,t){e.id=t===`using`||t===`await using`?this.parseIdent():this.parseBindingAtom(),this.checkLValPattern(e.id,t===`var`?Si:Ci,!1)};var Ii=1,Li=2,Ri=4;V.parseFunction=function(e,t,n,r,i){this.initFunction(e),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!r)&&(this.type===B.star&&t&Li&&this.unexpected(),e.generator=this.eat(B.star)),this.options.ecmaVersion>=8&&(e.async=!!r),t&Ii&&(e.id=t&Ri&&this.type!==B.name?null:this.parseIdent(),e.id&&!(t&Li)&&this.checkLValSimple(e.id,this.strict||e.generator||e.async?this.treatFunctionsAsVar?Si:Ci:wi));var a=this.yieldPos,o=this.awaitPos,s=this.awaitIdentPos;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(bi(e.async,e.generator)),t&Ii||(e.id=this.type===B.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&Ii?`FunctionDeclaration`:`FunctionExpression`)},V.parseFunctionParams=function(e){this.expect(B.parenL),e.params=this.parseBindingList(B.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()},V.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(B.braceL);this.type!==B.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`)},V.parseClassElement=function(e){if(this.eat(B.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(B.braceL))return this.parseClassStaticBlock(n),n;this.isClassElementNameStart()||this.type===B.star?s=!0:r=`static`}if(n.static=s,!r&&t>=8&&this.eatContextual(`async`)&&((this.isClassElementNameStart()||this.type===B.star)&&!this.canInsertSemicolon()?a=!0:r=`async`),!r&&(t>=9||!a)&&this.eat(B.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===B.parenL||o!==`method`||i||a){var l=!n.static&&Bi(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},V.isClassElementNameStart=function(){return this.type===B.name||this.type===B.privateId||this.type===B.num||this.type===B.string||this.type===B.bracketL||this.type.keyword},V.parseClassElementName=function(e){this.type===B.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)},V.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&&Bi(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`)},V.parseClassField=function(e){return Bi(e,`constructor`)?this.raise(e.key.start,`Classes can't have a field named 'constructor'`):e.static&&Bi(e,`prototype`)&&this.raise(e.key.start,`Classes can't have a static field named 'prototype'`),this.eat(B.eq)?(this.enterScope(_i|mi),e.value=this.parseMaybeAssign(),this.exitScope()):e.value=null,this.semicolon(),this.finishNode(e,`PropertyDefinition`)},V.parseClassStaticBlock=function(e){e.body=[];var t=this.labels;for(this.labels=[],this.enterScope(gi|mi);this.type!==B.braceR;){var n=this.parseStatement(null);e.body.push(n)}return this.next(),this.exitScope(),this.labels=t,this.finishNode(e,`StaticBlock`)},V.parseClassId=function(e,t){this.type===B.name?(e.id=this.parseIdent(),t&&this.checkLValSimple(e.id,Ci,!1)):(t===!0&&this.unexpected(),e.id=null)},V.parseClassSuper=function(e){e.superClass=this.eat(B._extends)?this.parseExprSubscripts(null,!1):null},V.enterClassBody=function(){var e={declared:Object.create(null),used:[]};return this.privateNameStack.push(e),e.declared},V.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];Yr(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 Bi(e,t){var n=e.computed,r=e.key;return!n&&(r.type===`Identifier`&&r.name===t||r.type===`Literal`&&r.value===t)}V.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!==B.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,`ExportAllDeclaration`)},V.parseExport=function(e,t){if(this.next(),this.eat(B.star))return this.parseExportAllDeclaration(e,t);if(this.eat(B._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!==B.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`)},V.parseExportDeclaration=function(e){return this.parseStatement(null)},V.parseExportDefaultDeclaration=function(){var e;if(this.type===B._function||(e=this.isAsyncFunction())){var t=this.startNode();return this.next(),e&&this.next(),this.parseFunction(t,Ii|Ri,!1,e)}else if(this.type===B._class){var n=this.startNode();return this.parseClass(n,`nullableID`)}else{var r=this.parseMaybeAssign();return this.semicolon(),r}},V.checkExport=function(e,t,n){e&&(typeof t!=`string`&&(t=t.type===`Identifier`?t.name:t.value),Yr(e,t)&&this.raiseRecoverable(n,`Duplicate export '`+t+`'`),e[t]=!0)},V.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)},V.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)}},V.shouldParseExportStatement=function(){return this.type.keyword===`var`||this.type.keyword===`const`||this.type.keyword===`class`||this.type.keyword===`function`||this.isLet()||this.isAsyncFunction()},V.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`)},V.parseExportSpecifiers=function(e){var t=[],n=!0;for(this.expect(B.braceL);!this.eat(B.braceR);){if(n)n=!1;else if(this.expect(B.comma),this.afterTrailingComma(B.braceR))break;t.push(this.parseExportSpecifier(e))}return t},V.parseImport=function(e){return this.next(),this.type===B.string?(e.specifiers=Fi,e.source=this.parseExprAtom()):(e.specifiers=this.parseImportSpecifiers(),this.expectContextual(`from`),e.source=this.type===B.string?this.parseExprAtom():this.unexpected()),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,`ImportDeclaration`)},V.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,Ci),this.finishNode(e,`ImportSpecifier`)},V.parseImportDefaultSpecifier=function(){var e=this.startNode();return e.local=this.parseIdent(),this.checkLValSimple(e.local,Ci),this.finishNode(e,`ImportDefaultSpecifier`)},V.parseImportNamespaceSpecifier=function(){var e=this.startNode();return this.next(),this.expectContextual(`as`),e.local=this.parseIdent(),this.checkLValSimple(e.local,Ci),this.finishNode(e,`ImportNamespaceSpecifier`)},V.parseImportSpecifiers=function(){var e=[],t=!0;if(this.type===B.name&&(e.push(this.parseImportDefaultSpecifier()),!this.eat(B.comma)))return e;if(this.type===B.star)return e.push(this.parseImportNamespaceSpecifier()),e;for(this.expect(B.braceL);!this.eat(B.braceR);){if(t)t=!1;else if(this.expect(B.comma),this.afterTrailingComma(B.braceR))break;e.push(this.parseImportSpecifier())}return e},V.parseWithClause=function(){var e=[];if(!this.eat(B._with))return e;this.expect(B.braceL);for(var t={},n=!0;!this.eat(B.braceR);){if(n)n=!1;else if(this.expect(B.comma),this.afterTrailingComma(B.braceR))break;var r=this.parseImportAttribute(),i=r.key.type===`Identifier`?r.key.name:r.key.value;Yr(t,i)&&this.raiseRecoverable(r.key.start,`Duplicate attribute key '`+i+`'`),t[i]=!0,e.push(r)}return e},V.parseImportAttribute=function(){var e=this.startNode();return e.key=this.type===B.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!==`never`),this.expect(B.colon),this.type!==B.string&&this.unexpected(),e.value=this.parseExprAtom(),this.finishNode(e,`ImportAttribute`)},V.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===B.string){var e=this.parseLiteral(this.value);return ei.test(e.value)&&this.raise(e.start,`An export name cannot include a lone surrogate.`),e}return this.parseIdent(!0)},V.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)},V.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 Vi=Di.prototype;Vi.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},Vi.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},Vi.parseSpread=function(e){var t=this.startNode();return this.next(),t.argument=this.parseMaybeAssign(!1,e),this.finishNode(t,`SpreadElement`)},Vi.parseRestBinding=function(){var e=this.startNode();return this.next(),this.options.ecmaVersion===6&&this.type!==B.name&&this.unexpected(),e.argument=this.parseBindingAtom(),this.finishNode(e,`RestElement`)},Vi.parseBindingAtom=function(){if(this.options.ecmaVersion>=6)switch(this.type){case B.bracketL:var e=this.startNode();return this.next(),e.elements=this.parseBindingList(B.bracketR,!0,!0),this.finishNode(e,`ArrayPattern`);case B.braceL:return this.parseObj(!0)}return this.parseIdent()},Vi.parseBindingList=function(e,t,n,r){for(var i=[],a=!0;!this.eat(e);)if(a?a=!1:this.expect(B.comma),t&&this.type===B.comma)i.push(null);else if(n&&this.afterTrailingComma(e))break;else if(this.type===B.ellipsis){var o=this.parseRestBinding();this.parseBindingListItem(o),i.push(o),this.type===B.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},Vi.parseAssignableListItem=function(e){var t=this.parseMaybeDefault(this.start,this.startLoc);return this.parseBindingListItem(t),t},Vi.parseBindingListItem=function(e){return e},Vi.parseMaybeDefault=function(e,t,n){if(n=n||this.parseBindingAtom(),this.options.ecmaVersion<6||!this.eat(B.eq))return n;var r=this.startNodeAt(e,t);return r.left=n,r.right=this.parseMaybeAssign(),this.finishNode(r,`AssignmentPattern`)},Vi.checkLValSimple=function(e,t,n){t===void 0&&(t=xi);var r=t!==xi;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===Ci&&e.name===`let`&&this.raiseRecoverable(e.start,`let is disallowed as a lexically bound name`),n&&(Yr(n,e.name)&&this.raiseRecoverable(e.start,`Argument name clash`),n[e.name]=!0),t!==Ei&&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`)}},Vi.checkLValPattern=function(e,t,n){switch(t===void 0&&(t=xi),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)}},Vi.checkLValInnerPattern=function(e,t,n){switch(t===void 0&&(t=xi),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 Hi=function(e,t,n,r,i){this.token=e,this.isExpr=!!t,this.preserveSpace=!!n,this.override=r,this.generator=!!i},H={b_stat:new Hi(`{`,!1),b_expr:new Hi(`{`,!0),b_tmpl:new Hi(\"${\",!1),p_stat:new Hi(`(`,!1),p_expr:new Hi(`(`,!0),q_tmpl:new Hi(\"`\",!0,!0,function(e){return e.tryReadTemplateToken()}),f_stat:new Hi(`function`,!1),f_expr:new Hi(`function`,!0),f_expr_gen:new Hi(`function`,!0,!1,null,!0),f_gen:new Hi(`function`,!1,!1,null,!0)},Ui=Di.prototype;Ui.initialContext=function(){return[H.b_stat]},Ui.curContext=function(){return this.context[this.context.length-1]},Ui.braceIsBlock=function(e){var t=this.curContext();return t===H.f_expr||t===H.f_stat?!0:e===B.colon&&(t===H.b_stat||t===H.b_expr)?!t.isExpr:e===B._return||e===B.name&&this.exprAllowed?Br.test(this.input.slice(this.lastTokEnd,this.start)):e===B._else||e===B.semi||e===B.eof||e===B.parenR||e===B.arrow?!0:e===B.braceL?t===H.b_stat:e===B._var||e===B._const||e===B.name?!1:!this.exprAllowed},Ui.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},Ui.updateContext=function(e){var t,n=this.type;n.keyword&&e===B.dot?this.exprAllowed=!1:(t=n.updateContext)?t.call(this,e):this.exprAllowed=n.beforeExpr},Ui.overrideContext=function(e){this.curContext()!==e&&(this.context[this.context.length-1]=e)},B.parenR.updateContext=B.braceR.updateContext=function(){if(this.context.length===1){this.exprAllowed=!0;return}var e=this.context.pop();e===H.b_stat&&this.curContext().token===`function`&&(e=this.context.pop()),this.exprAllowed=!e.isExpr},B.braceL.updateContext=function(e){this.context.push(this.braceIsBlock(e)?H.b_stat:H.b_expr),this.exprAllowed=!0},B.dollarBraceL.updateContext=function(){this.context.push(H.b_tmpl),this.exprAllowed=!0},B.parenL.updateContext=function(e){var t=e===B._if||e===B._for||e===B._with||e===B._while;this.context.push(t?H.p_stat:H.p_expr),this.exprAllowed=!0},B.incDec.updateContext=function(){},B._function.updateContext=B._class.updateContext=function(e){e.beforeExpr&&e!==B._else&&!(e===B.semi&&this.curContext()!==H.p_stat)&&!(e===B._return&&Br.test(this.input.slice(this.lastTokEnd,this.start)))&&!((e===B.colon||e===B.braceL)&&this.curContext()===H.b_stat)?this.context.push(H.f_expr):this.context.push(H.f_stat),this.exprAllowed=!1},B.colon.updateContext=function(){this.curContext().token===`function`&&this.context.pop(),this.exprAllowed=!0},B.backQuote.updateContext=function(){this.curContext()===H.q_tmpl?this.context.pop():this.context.push(H.q_tmpl),this.exprAllowed=!1},B.star.updateContext=function(e){if(e===B._function){var t=this.context.length-1;this.context[t]===H.f_expr?this.context[t]=H.f_expr_gen:this.context[t]=H.f_gen}this.exprAllowed=!0},B.name.updateContext=function(e){var t=!1;this.options.ecmaVersion>=6&&e!==B.dot&&(this.value===`of`&&!this.exprAllowed||this.value===`yield`&&this.inGeneratorContext())&&(t=!0),this.exprAllowed=t};var U=Di.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===B.comma){var o=n.startNodeAt(r,i);for(o.expressions=[a];n.eat(B.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 Mi,r=!0);var s=this.start,c=this.startLoc;(this.type===B.parenL||this.type===B.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===B.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===B.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(B.question)){var a=this.startNodeAt(n,r);return a.test=i,a.consequent=this.parseMaybeAssign(),this.expect(B.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!==B._in)&&a>r){var o=this.type===B.logicalOR||this.type===B.logicalAND,s=this.type===B.coalesce;s&&(a=B.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===B.coalesce||s&&(this.type===B.logicalOR||this.type===B.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===B.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`&&Wi(s.argument)?this.raiseRecoverable(s.start,`Deleting local variable in strict mode`):s.operator===`delete`&&Gi(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===B.privateId)(r||this.privateNameStack.length===0)&&this.options.checkPrivateFields&&this.unexpected(),o=this.parsePrivateIdent(),this.type!==B._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(B.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 Wi(e){return e.type===`Identifier`||e.type===`ParenthesizedExpression`&&Wi(e.expression)}function Gi(e){return e.type===`MemberExpression`&&e.property.type===`PrivateIdentifier`||e.type===`ChainExpression`&&Gi(e.expression)||e.type===`ParenthesizedExpression`&&Gi(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(B.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(B.questionDot);r&&c&&this.raise(this.lastTokStart,`Optional chaining cannot appear in the callee of new expressions`);var l=this.eat(B.bracketL);if(l||c&&this.type!==B.parenL&&this.type!==B.backQuote||this.eat(B.dot)){var u=this.startNodeAt(t,n);u.object=e,l?(u.property=this.parseExpression(),this.expect(B.bracketR)):this.type===B.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(B.parenL)){var d=new Mi,f=this.yieldPos,p=this.awaitPos,m=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var h=this.parseExprList(B.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===B.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===B.slash&&this.readRegexp();var r,i=this.potentialArrowAt===this.start;switch(this.type){case B._super:return this.allowSuper||this.raise(this.start,`'super' keyword outside a method`),r=this.startNode(),this.next(),this.type===B.parenL&&!this.allowDirectSuper&&this.raise(r.start,`super() call outside constructor of a subclass`),this.type!==B.dot&&this.type!==B.bracketL&&this.type!==B.parenL&&this.unexpected(),this.finishNode(r,`Super`);case B._this:return r=this.startNode(),this.next(),this.finishNode(r,`ThisExpression`);case B.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(B._function))return this.overrideContext(H.f_expr),this.parseFunction(this.startNodeAt(a,o),0,!1,!0,t);if(i&&!this.canInsertSemicolon()){if(this.eat(B.arrow))return this.parseArrowExpression(this.startNodeAt(a,o),[c],!1,t);if(this.options.ecmaVersion>=8&&c.name===`async`&&this.type===B.name&&!s&&(!this.potentialArrowInForAwait||this.value!==`of`||this.containsEsc))return c=this.parseIdent(!1),(this.canInsertSemicolon()||!this.eat(B.arrow))&&this.unexpected(),this.parseArrowExpression(this.startNodeAt(a,o),[c],!0,t)}return c;case B.regexp:var l=this.value;return r=this.parseLiteral(l.value),r.regex={pattern:l.pattern,flags:l.flags},r;case B.num:case B.string:return this.parseLiteral(this.value);case B._null:case B._true:case B._false:return r=this.startNode(),r.value=this.type===B._null?null:this.type===B._true,r.raw=this.type.keyword,this.next(),this.finishNode(r,`Literal`);case B.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 B.bracketL:return r=this.startNode(),this.next(),r.elements=this.parseExprList(B.bracketR,!0,!0,e),this.finishNode(r,`ArrayExpression`);case B.braceL:return this.overrideContext(H.b_expr),this.parseObj(!1,e);case B._function:return r=this.startNode(),this.next(),this.parseFunction(r,0);case B._class:return this.parseClass(this.startNode(),!1);case B._new:return this.parseNew();case B.backQuote:return this.parseTemplate();case B._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===B.parenL&&!e)return this.parseDynamicImport(t);if(this.type===B.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(B.parenR)?e.options=null:(this.expect(B.comma),this.afterTrailingComma(B.parenR)?e.options=null:(e.options=this.parseMaybeAssign(),this.eat(B.parenR)||(this.expect(B.comma),this.afterTrailingComma(B.parenR)||this.unexpected())));else if(!this.eat(B.parenR)){var t=this.start;this.eat(B.comma)&&this.eat(B.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(B.parenL);var e=this.parseExpression();return this.expect(B.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 Mi,f=this.yieldPos,p=this.awaitPos,m;for(this.yieldPos=0,this.awaitPos=0;this.type!==B.parenR;)if(l?l=!1:this.expect(B.comma),a&&this.afterTrailingComma(B.parenR,!0)){u=!0;break}else if(this.type===B.ellipsis){m=this.start,c.push(this.parseParenItem(this.parseRestBinding())),this.type===B.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(B.parenR),e&&this.shouldParseArrow(c)&&this.eat(B.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 Ki=[];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===B.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(B.parenL)?e.arguments=this.parseExprList(B.parenR,this.options.ecmaVersion>=8,!1):e.arguments=Ki,this.finishNode(e,`NewExpression`)},U.parseTemplateElement=function(e){var t=e.isTagged,n=this.startNode();return this.type===B.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===B.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===B.eof&&this.raise(this.pos,`Unterminated template literal`),this.expect(B.dollarBraceL),n.expressions.push(this.parseExpression()),this.expect(B.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===B.name||this.type===B.num||this.type===B.string||this.type===B.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===B.star)&&!Br.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(B.braceR);){if(r)r=!1;else if(this.expect(B.comma),this.options.ecmaVersion>=5&&this.afterTrailingComma(B.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(B.ellipsis))return e?(n.argument=this.parseIdent(!1),this.type===B.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===B.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(B.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(B.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===B.colon&&this.unexpected(),this.eat(B.colon)?(e.value=t?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,o),e.kind=`init`):this.options.ecmaVersion>=6&&this.type===B.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!==B.comma&&this.type!==B.braceR&&this.type!==B.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===B.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(B.bracketL))return e.computed=!0,e.key=this.parseMaybeAssign(),this.expect(B.bracketR),e.key;e.computed=!1}return e.key=this.type===B.num||this.type===B.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(bi(t,r.generator)|mi|(n?hi:0)),this.expect(B.parenL),r.params=this.parseBindingList(B.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(bi(n,!1)|fi),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!==B.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,Ei),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,Si,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(B.comma),t&&this.afterTrailingComma(e))break;var o=void 0;n&&this.type===B.comma?o=null:this.type===B.ellipsis?(o=this.parseSpread(r),r&&this.type===B.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&yi)&&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===B.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=B.name):this.unexpected(),e},U.parsePrivateIdent=function(){var e=this.startNode();return this.type===B.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===B.semi||this.canInsertSemicolon()||this.type!==B.star&&!this.type.startsExpr?(t.delegate=!1,t.argument=null):(t.delegate=this.eat(B.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 qi=Di.prototype;qi.raise=function(e,t){var n=ri(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},qi.raiseRecoverable=qi.raise,qi.curPosition=function(){if(this.options.locations)return new ti(this.curLine,this.pos-this.lineStart)};var Ji=Di.prototype,Yi=function(e){this.flags=e,this.var=[],this.lexical=[],this.functions=[]};Ji.enterScope=function(e){this.scopeStack.push(new Yi(e))},Ji.exitScope=function(){this.scopeStack.pop()},Ji.treatFunctionsAsVarInScope=function(e){return e.flags&li||!this.inModule&&e.flags&ci},Ji.declareName=function(e,t,n){var r=!1;if(t===Ci){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&ci&&delete this.undefinedExports[e]}else if(t===Ti)this.currentScope().lexical.push(e);else if(t===wi){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&pi&&s.lexical[0]===e)||!this.treatFunctionsAsVarInScope(s)&&s.functions.indexOf(e)>-1){r=!0;break}if(s.var.push(e),this.inModule&&s.flags&ci&&delete this.undefinedExports[e],s.flags&yi)break}r&&this.raiseRecoverable(n,`Identifier '`+e+`' has already been declared`)},Ji.checkLocalExport=function(e){this.scopeStack[0].lexical.indexOf(e.name)===-1&&this.scopeStack[0].var.indexOf(e.name)===-1&&(this.undefinedExports[e.name]=e)},Ji.currentScope=function(){return this.scopeStack[this.scopeStack.length-1]},Ji.currentVarScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&(yi|_i|gi))return t}},Ji.currentThisScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&(yi|_i|gi)&&!(t.flags&fi))return t}};var Xi=function(e,t,n){this.type=``,this.start=t,this.end=0,e.options.locations&&(this.loc=new ni(e,n)),e.options.directSourceFile&&(this.sourceFile=e.options.directSourceFile),e.options.ranges&&(this.range=[t,0])},Zi=Di.prototype;Zi.startNode=function(){return new Xi(this,this.start,this.startLoc)},Zi.startNodeAt=function(e,t){return new Xi(this,e,t)};function Qi(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}Zi.finishNode=function(e,t){return Qi.call(this,e,t,this.lastTokEnd,this.lastTokEndLoc)},Zi.finishNodeAt=function(e,t,n,r){return Qi.call(this,e,t,n,r)},Zi.copyNode=function(e){var t=new Xi(this,e.start,this.startLoc);for(var n in e)t[n]=e[n];return t};var $i=`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`,ea=`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`,ta=ea+` Extended_Pictographic`,na=ta,ra=na+` EBase EComp EMod EPres ExtPict`,ia=ra,aa=ia,oa={9:ea,10:ta,11:na,12:ra,13:ia,14:aa},sa=`Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji`,ca={9:``,10:``,11:``,12:``,13:``,14:sa},la=`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`,ua=`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`,da=ua+` Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd`,fa=da+` Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho`,pa=fa+` Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi`,ma=pa+` Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith`,ha=ma+` `+$i,ga={9:ua,10:da,11:fa,12:pa,13:ma,14:ha},_a={};function va(e){var t=_a[e]={binary:Qr(oa[e]+` `+la),binaryOfStrings:Qr(ca[e]),nonBinary:{General_Category:Qr(la),Script:Qr(ga[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 ya=0,ba=[9,10,11,12,13,14];ya<ba.length;ya+=1){var xa=ba[ya];va(xa)}var W=Di.prototype,Sa=function(e,t){this.parent=e,this.base=t||this};Sa.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},Sa.prototype.sibling=function(){return new Sa(this.parent,this.base)};var Ca=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=_a[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};Ca.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)},Ca.prototype.raise=function(e){this.parser.raiseRecoverable(this.start,`Invalid regular expression: /`+this.source+`/: `+e)},Ca.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},Ca.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},Ca.prototype.current=function(e){return e===void 0&&(e=!1),this.at(this.pos,e)},Ca.prototype.lookahead=function(e){return e===void 0&&(e=!1),this.at(this.nextIndex(this.pos,e),e)},Ca.prototype.advance=function(e){e===void 0&&(e=!1),this.pos=this.nextIndex(this.pos,e)},Ca.prototype.eat=function(e,t){return t===void 0&&(t=!1),this.current(t)===e?(this.advance(t),!0):!1},Ca.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 wa(e){for(var t in e)return!0;return!1}W.validateRegExpPattern=function(e){this.regexp_pattern(e),!e.switchN&&this.options.ecmaVersion>=9&&wa(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 Sa(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&&Ta(n);)t+=$r(n),e.advance();return t};function Ta(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 Ea(t)?(e.lastIntValue=t,e.advance(),!0):!1};function Ea(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&&!Ea(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+=$r(e.lastIntValue);this.regexp_eatRegExpIdentifierPart(e);)e.lastStringValue+=$r(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),Da(r)?(e.lastIntValue=r,!0):(e.pos=t,!1)};function Da(e){return Pr(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),Oa(r)?(e.lastIntValue=r,!0):(e.pos=t,!1)};function Oa(e){return Fr(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&&!Ba(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 ka(t)?(e.lastIntValue=t%32,e.advance(),!0):!1};function ka(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)&&Aa(e.lastIntValue))return!0;r&&e.raise(`Invalid unicode escape`),e.pos=n}return!1};function Aa(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 ja=0,Ma=1,Na=2;W.regexp_eatCharacterClassEscape=function(e){var t=e.current();if(Pa(t))return e.lastIntValue=-1,e.advance(),Ma;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===Na&&e.raise(`Invalid property name`),r;e.raise(`Invalid property name`)}return ja};function Pa(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),Ma}}if(e.pos=t,this.regexp_eatLoneUnicodePropertyNameOrValue(e)){var i=e.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(e,i)}return ja},W.regexp_validateUnicodePropertyNameAndValue=function(e,t,n){Yr(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 Ma;if(e.switchV&&e.unicodeProperties.binaryOfStrings.test(t))return Na;e.raise(`Invalid property name`)},W.regexp_eatUnicodePropertyName=function(e){var t=0;for(e.lastStringValue=``;Fa(t=e.current());)e.lastStringValue+=$r(t),e.advance();return e.lastStringValue!==``};function Fa(e){return ka(e)||e===95}W.regexp_eatUnicodePropertyValue=function(e){var t=0;for(e.lastStringValue=``;Ia(t=e.current());)e.lastStringValue+=$r(t),e.advance();return e.lastStringValue!==``};function Ia(e){return Fa(e)||Ba(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===Na&&e.raise(`Negated character class may contain strings`),!0}return!1},W.regexp_classContents=function(e){return e.current()===93?Ma:e.switchV?this.regexp_classSetExpression(e):(this.regexp_nonEmptyClassRanges(e),Ma)},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||Ua(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=Ma,n;if(!this.regexp_eatClassSetRange(e))if(n=this.regexp_eatClassSetOperand(e)){n===Na&&(t=Na);for(var r=e.pos;e.eatChars([38,38]);){if(e.current()!==38&&(n=this.regexp_eatClassSetOperand(e))){n!==Na&&(t=Ma);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===Na&&(t=Na)}},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)?Ma: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===Na&&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)===Na&&(t=Na);return t},W.regexp_classString=function(e){for(var t=0;this.regexp_eatClassSetCharacter(e);)t++;return t===1?Ma:Na},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()&&La(n)||Ra(n)?!1:(e.advance(),e.lastIntValue=n,!0)};function La(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 Ra(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 za(t)?(e.lastIntValue=t,e.advance(),!0):!1};function za(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 Ba(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;Ba(n=e.current());)e.lastIntValue=10*e.lastIntValue+(n-48),e.advance();return e.pos!==t};function Ba(e){return e>=48&&e<=57}W.regexp_eatHexDigits=function(e){var t=e.pos,n=0;for(e.lastIntValue=0;Va(n=e.current());)e.lastIntValue=16*e.lastIntValue+Ha(n),e.advance();return e.pos!==t};function Va(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function Ha(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 Ua(t)?(e.lastIntValue=t-48,e.advance(),!0):(e.lastIntValue=0,!1)};function Ua(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(!Va(i))return e.pos=n,!1;e.lastIntValue=16*e.lastIntValue+Ha(i),e.advance()}return!0};var Wa=function(e){this.type=e.type,this.value=e.value,this.start=e.start,this.end=e.end,e.options.locations&&(this.loc=new ni(e,e.startLoc,e.endLoc)),e.options.ranges&&(this.range=[e.start,e.end])},G=Di.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 Wa(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 Wa(this)},typeof Symbol<`u`&&(G[Symbol.iterator]=function(){var e=this;return{next:function(){var t=e.getToken();return{done:t.type===B.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(B.eof);if(e.override)return e.override(this);this.readToken(this.fullCharCodeAtPos())},G.readToken=function(e){return Pr(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=Ur(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&&!Hr(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&&Wr.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(B.ellipsis)):(++this.pos,this.finishToken(B.dot))},G.readToken_slash=function(){var e=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):e===61?this.finishOp(B.assign,2):this.finishOp(B.slash,1)},G.readToken_mult_modulo_exp=function(e){var t=this.input.charCodeAt(this.pos+1),n=1,r=e===42?B.star:B.modulo;return this.options.ecmaVersion>=7&&e===42&&t===42&&(++n,r=B.starstar,t=this.input.charCodeAt(this.pos+2)),t===61?this.finishOp(B.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(B.assign,3):this.finishOp(e===124?B.logicalOR:B.logicalAND,2):t===61?this.finishOp(B.assign,2):this.finishOp(e===124?B.bitwiseOR:B.bitwiseAND,1)},G.readToken_caret=function(){return this.input.charCodeAt(this.pos+1)===61?this.finishOp(B.assign,2):this.finishOp(B.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||Br.test(this.input.slice(this.lastTokEnd,this.pos)))?(this.skipLineComment(3),this.skipSpace(),this.nextToken()):this.finishOp(B.incDec,2):t===61?this.finishOp(B.assign,2):this.finishOp(B.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(B.assign,n+1):this.finishOp(B.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(B.relational,n))},G.readToken_eq_excl=function(e){var t=this.input.charCodeAt(this.pos+1);return t===61?this.finishOp(B.equality,this.input.charCodeAt(this.pos+2)===61?3:2):e===61&&t===62&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(B.arrow)):this.finishOp(e===61?B.eq:B.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(B.questionDot,2)}if(t===63)return e>=12&&this.input.charCodeAt(this.pos+2)===61?this.finishOp(B.assign,3):this.finishOp(B.coalesce,2)}return this.finishOp(B.question,1)},G.readToken_numberSign=function(){var e=this.options.ecmaVersion,t=35;if(e>=13&&(++this.pos,t=this.fullCharCodeAtPos(),Pr(t,!0)||t===92))return this.finishToken(B.privateId,this.readWord1());this.raise(this.pos,`Unexpected character '`+$r(t)+`'`)},G.getTokenFromCode=function(e){switch(e){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(B.parenL);case 41:return++this.pos,this.finishToken(B.parenR);case 59:return++this.pos,this.finishToken(B.semi);case 44:return++this.pos,this.finishToken(B.comma);case 91:return++this.pos,this.finishToken(B.bracketL);case 93:return++this.pos,this.finishToken(B.bracketR);case 123:return++this.pos,this.finishToken(B.braceL);case 125:return++this.pos,this.finishToken(B.braceR);case 58:return++this.pos,this.finishToken(B.colon);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(B.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(B.prefix,1);case 35:return this.readToken_numberSign()}this.raise(this.pos,`Unexpected character '`+$r(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(Br.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 Ca(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(B.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 Ga(e,t){return t?parseInt(e,8):parseFloat(e.replace(/_/g,``))}function Ka(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=Ka(this.input.slice(t,this.pos)),++this.pos):Pr(this.fullCharCodeAtPos())&&this.raise(this.pos,`Identifier directly after number`),this.finishToken(B.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=Ka(this.input.slice(t,this.pos));return++this.pos,Pr(this.fullCharCodeAtPos())&&this.raise(this.pos,`Identifier directly after number`),this.finishToken(B.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`)),Pr(this.fullCharCodeAtPos())&&this.raise(this.pos,`Identifier directly after number`);var a=Ga(this.input.slice(t,this.pos),n);return this.finishToken(B.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)):(Hr(r)&&this.raise(this.start,`Unterminated string constant`),++this.pos)}return t+=this.input.slice(n,this.pos++),this.finishToken(B.string,t)};var qa={};G.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(e){if(e===qa)this.readInvalidTemplateToken();else throw e}this.inTemplateElement=!1},G.invalidStringToken=function(e,t){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw qa;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===B.template||this.type===B.invalidTemplate)?n===36?(this.pos+=2,this.finishToken(B.dollarBraceL)):(++this.pos,this.finishToken(B.backQuote)):(e+=this.input.slice(t,this.pos),this.finishToken(B.template,e));if(n===92)e+=this.input.slice(t,this.pos),e+=this.readEscapedChar(!0),t=this.pos;else if(Hr(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(B.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 $r(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 Hr(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(Fr(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?Pr:Fr)(o,r)||this.invalidStringToken(a,`Invalid Unicode escape`),e+=$r(o),n=this.pos}else break;t=!1}return e+this.input.slice(n,this.pos)},G.readWord=function(){var e=this.readWord1(),t=B.name;return this.keywords.test(e)&&(t=zr[e]),this.finishToken(t,e)},Di.acorn={Parser:Di,version:`8.19.0`,defaultOptions:ii,Position:ti,SourceLocation:ni,getLineInfo:ri,Node:Xi,TokenType:R,tokTypes:B,keywordTypes:zr,TokContext:Hi,tokContexts:H,isIdentifierChar:Fr,isIdentifierStart:Pr,Token:Wa,isNewLine:Hr,lineBreak:Br,lineBreakG:Vr,nonASCIIwhitespace:Wr};var Ja={ecmaVersion:`latest`,sourceType:`script`,allowReturnOutsideFunction:!0},Ya=/\\w+(?![\\p{ID_Continue}$\\u200c\\u200d])/uy,Xa=/[A-Za-z_]\\w*(?![\\p{ID_Continue}$\\u200c\\u200d])/uy,Za=/^[$_]\\w+$/,Qa=/[\\n\\r\\u2028\\u2029]/,$a=/\\s*(?:[;},:)]|=(?![=>]))/y;function eo(e,t){return $a.lastIndex=t,$a.test(e)}var to=new Set([B.name,B.num,B.string,B.regexp,B.backQuote,B.bracketR,B.braceR,B.parenR,B.incDec,B._this,B._null,B._true,B._false]),no=class extends Di{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=B.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=Qa.test(t.input.slice(t.end,t.pos)),e===64||e===37){let n=t.pos,r=e===64?Ya:Xa;r.lastIndex=n+1;let i=r.exec(t.input)?.[0];if(i){let r=n+1+i.length,a=t.type===B.incDec&&(this.operandBeforeLast||this.breakBeforeLast),o=e===37?this.percentAt?.get(n):void 0;if(e===64||(o??(t.exprAllowed||a||this.lookahead&&ro(t,r)))){e===37&&this.transientsRead?.add(n),t.pos=r,t.finishToken(B.name,t.input.charAt(n)+i);return}}}super.readToken(e)}finishToken(e,t){let{context:n}=this,r=n.length;if(e===B.braceR){let e=n[r-1];this.closedBlock=e.token===`{`&&!e.isExpr}else if(e===B.question)this.ternaries[r]=(this.ternaries[r]??0)+1;else if(e===B.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===B.dot||a===B.questionDot)||(e===B._function||e===B._class)&&eo(i.input,i.pos);if(!o&&(e===B._function||e===B._class)){let t=e===B._function&&a===B.name&&this.prevValue===`async`&&!this.breakHere?this.typeBeforeLast:a;i.type=t===B.colon&&this.colonEndsTernary?B.parenL:t}this.typeBeforeLast=a,super.finishToken(o?B.name:e,t),e===B.name&&t===`of`&&(a===B._const||a===B._var||this.prevValue===`let`)&&(i.exprAllowed=!1)}braceIsBlock(e){if(e===B.colon&&this.colonEndsTernary)return!1;if(e===B.braceR&&this.closedBlock||e===B.name&&this.prevValue===`static`)return!0;if(this.breakHere&&to.has(e)){let{context:e}=this,t=e[e.length-1];if(t.token===`{`&&!t.isExpr)return!0}return super.braceIsBlock(e)}};function ro(e,t){if(!Qa.test(e.input.slice(e.end,e.pos)))return!1;let n=oo(e.input,t,`statements`,{afterOperand:!0});n.lookahead=!1;let r=0;try{for(;;){n.nextToken();let e=n.type;if(e===B.eof)return!1;if(r>0)io.has(e)?r++:ao.has(e)&&r--;else if(e===B.bracketL)r=1;else if(e===B.dot){if(n.nextToken(),n.type!==B.name&&!n.type.keyword)return!1}else return e===B.eq||e===B.assign}}catch{return!1}}var io=new Set([B.parenL,B.bracketL,B.braceL,B.dollarBraceL]),ao=new Set([B.parenR,B.bracketR,B.braceR]);function oo(e,t,n,{onComment:r,afterOperand:i=!1}={}){let a=new no(r?{...Ja,onComment:r}:Ja,e,t);return n===`expression`&&(a.type=B.parenL),i&&(a.exprAllowed=!1),a}var so=class extends SyntaxError{constructor(e,t,n,r){super(`${e} ${uo(t,n)}`+co(r,e=>lo(t,e))),this.reason=e,this.source=t,this.pos=n,this.bracket=r,this.name=`SyntaxError`}reasonIn(e,t){return this.reason+co(this.bracket,n=>{let{line:r,column:i}=ri(e,t+n);return`at line ${r}, column ${i+1}`})}};function co(e,t){return e?` (missing \"${e.closer}\" for the \"${e.open}\" ${t(e.pos)})`:``}function lo(e,t){let{line:n,column:r}=ri(e,t);return Qa.test(e)?`at line ${n}, column ${r+1}`:`at column ${r+1}`}function uo(e,t){let{column:n}=ri(e,t),r=t-n,i=e.slice(r).search(Qa),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`${lo(e,t)}: ${c.trim()}`}var fo=e=>e[e.length-1],po={\"(\":`)`,\"[\":`]`,\"{\":`}`,\"${\":`}`};function mo(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}=ho(e,n),o=n>=e.length||a===``,s=!1;r===`Unexpected token`?(r=o?`Unexpected end of code`:`Unexpected \"${a}\"`,s=!!i&&po[i.text]!==a&&(o||[`)`,`]`,`}`,`;`,`{`].includes(a))):r.startsWith(`Unterminated template`)&&(s=i?.text===\"${\");let c=s&&i?{open:i.text,closer:po[i.text],pos:i.pos}:void 0;return new so(r,e,n,c)}function ho(e,t){let n=[];for(let r of ko(e,0,`statements`)){if(`error`in r)break;if(r.start>=t||r.type===B.eof)return{open:fo(n),token:e.slice(r.start,r.end)};let i=e.slice(r.start,r.end);i in po?n.push({text:i,pos:r.start}):n.length&&po[fo(n).text]===i&&n.pop()}return{open:fo(n),token:e.charAt(t)}}function go(e,t=`expression`){let n=new Map;for(;;){let r=new Set;try{let i=_o(e,t,n,r),a={refs:[],strings:[]};return So(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)||(Xa.lastIndex=i+1,e.charAt(i)!==`%`||!Xa.test(e)))throw t;n.set(i,!r.has(i))}}}function _o(e,t,n,r){try{let i=oo(e,0,t);if(i.percentAt=n,i.transientsRead=r,t===`statements`)return i.parse();i.nextToken();let a=i.parseExpression();if(i.type!==B.eof)throw Object.assign(SyntaxError(`Unexpected token`),{pos:i.start});return a}catch(t){throw mo(e,t)}}var vo=e=>typeof e==`object`&&!!e&&typeof e.type==`string`,yo={$:`story`,_:`temporary`,\"@\":`local`,\"%\":`transient`};function bo(e,t){let n=e.name,r=t.charAt(e.start);return r===n.charAt(0)&&(r===`@`||r===`%`||(r===`$`||r===`_`)&&Za.test(n))?[r,n.slice(1)]:null}function xo(e,t){if(!vo(e)||e.type!==`Identifier`)return;let n=t.charAt(e.start);if(n===`@`||n===`%`)throw new so(`\"${e.name}\" can't be a property name`,t,e.start)}function So(e,t,n,r,i){if(Array.isArray(e)){for(let i of e)So(i,t,n,r,!1);return}if(!vo(e))return;let a=(e,r=!1,i=!1)=>So(e,t,n,r,i);switch(e.type){case`Identifier`:{let a=bo(e,t);if(!a)return;if(r)throw new so(`\"${e.name}\" is a ${yo[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):xo(e.property,t);return;case`Property`:if(e.computed?a(e.key):e.shorthand||xo(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):xo(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 Co=/[\\p{ID_Continue}$.]*/uy,wo=/[\\p{ID_Continue}$]*/uy,To=new Set([`of`,`get`,`set`,`static`,`async`]);function Eo(e,t,{goal:n=`expression`,stop:r}={}){let i=Oo(e,t,n,r);return i<0&&!r?Do(e,t,n):i}function Do(e,t,n){let r=oo(e,t,n);try{if(n===`statements`)r.parse();else if(r.nextToken(),r.parseExpression(),r.type===B.braceR)return r.start}catch(t){let n=t.pos??-1;if(e.charAt(n)===`}`)return n}return-1}function Oo(e,t,n,r){let i=[],a=-1,o=!1,s=t,c=!1,l=!1;for(;;){let t=-1;for(let u of ko(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===B.eof||n===B.string&&o&&u.start===a)return-1;if(o=n===B.name&&!To.has(u.value)||n===B.num,a=u.end,n===B.braceL){if(r?.(u.start))return u.start;i.push(`{`)}else if(n===B.dollarBraceL)i.push(\"${\");else if(n===B.parenL)i.push(`(`);else if(n===B.bracketL)i.push(`[`);else if(n===B.parenR||n===B.bracketR)fo(i)===(n===B.parenR?`(`:`[`)&&i.pop();else if(n===B.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*ko(e,t,n,r={}){let i=oo(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=oo(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}=Io(e,n);if(r){yield o(B.string,n,t);continue}}else if(!c&&i.start<=n&&(s===`\"`||s===`'`)){let{end:t,closed:n}=Io(e,i.start);if(n){yield o(B.string,i.start,t);continue}}else if(!c&&i.start<=n&&s===`/`){let t=Po(e,i.start);if(t>0){yield o(B.regexp,i.start,t);continue}}else if(!c&&i.start<=n&&/[\\d.]/.test(s)&&/\\d/.test(e.slice(i.start,i.start+2))){Co.lastIndex=i.start,Co.test(e),yield o(B.num,i.start,Co.lastIndex);continue}yield{error:t,pos:n};return}if(yield{type:i.type,start:i.start,end:i.end,value:i.value},i.type===B.eof)return}}function Ao(e,t,n=`expression`){return jo(e,0,t,0,n,!1)}function jo(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=ko(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=ko(e,m,i,{onComment:s}),h=void 0;continue}let o=t.type;if(o===B.eof)return u(m,e.length),e.length;if(u(m,t.start),o===B.name){let i=Mo(e,t.start,t.value),a=h===B.dot||h===B.questionDot||(i===`$`||i===`_`)&&No(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===B.string||o===B.regexp||o===B.template||o===B.invalidTemplate)l(t.start,t.end);else if(o===B.backQuote)if(l(t.start,t.end),h===B.template||h===B.invalidTemplate){if(f--,a&&f===0)return t.end}else f++;else o===B.dollarBraceL?(l(t.start,t.end),d.push(\"${\"),r++):o===B.braceR&&fo(d)===\"${\"?(d.pop(),r--,l(t.start,t.end)):(o===B.braceL||o===B.parenL||o===B.bracketL?d.push(e.charAt(t.start)):(o===B.braceR||o===B.parenR||o===B.bracketR)&&d.length&&fo(d)!==\"${\"&&d.pop(),c(t.start,t.end));h=o,m=t.end}}function Mo(e,t,n){let r=e.charAt(t);return(r===`@`||r===`%`)&&n.charAt(0)===r||(r===`$`||r===`_`)&&Za.test(n)?r:null}function No(e,t,n){if(n!==B.braceL&&n!==B.comma)return!1;let r=/\\S/g;r.lastIndex=t;let i=r.exec(e)?.[0];return i===`:`||i===`(`}function Po(e,t){let n=!1;for(let r=t+1;r<e.length;r++){let t=e.charAt(r);if(Qa.test(t))return-1;if(t===`\\\\`)r++;else if(t===`[`)n=!0;else if(t===`]`)n=!1;else if(t===`/`&&!n)return wo.lastIndex=r+1,wo.test(e),wo.lastIndex}return-1}function Fo(e){if(e[0]!==`\"`&&e[0]!==`'`)return null;try{let t=oo(e,0,`expression`);return t.nextToken(),t.type===B.string&&t.end===e.length?t.value:null}catch{return null}}function Io(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 Lo=/[\\p{L}\\p{N}_\\\\]/u;function Ro(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=zo(e,i+2);if(t===-1)return-1;i=t+1}else i++}return-1}function zo(e,t){Bo!==e&&(Bo=e,Vo.clear());let n=Vo.get(t);return n===void 0&&(n=Ho(e,t),Vo.set(t,n)),n}var Bo=``,Vo=new Map;function Ho(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&&Lo.test(e[t-1]))){let n=Ro(e,t);t=n===-1?t+1:n}else t++}return-1}var Uo={closeBrace(e,t,n){let r=Eo(e,t);return r===-1?zo(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=Eo(e,t,{goal:`statements`,stop:t=>(o.lastIndex=t,o.test(e))});return s===-1?a:s}};function Wo(e){let t=e.toLowerCase();return t.startsWith(`on`)||t===`pattern`||t===`srcdoc`}function Go(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])?Uo.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 Ko=new Set([`do`]),qo={...Uo,isBlock:xr,isRaw:e=>Ko.has(e),isCodeAttribute:Wo},Jo=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 Yo(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 Xo(e,t,n){let r=n.hooks?{...qo,...n.hooks}:qo;try{return _r(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}=Yo(e,r);throw new Jo(t.message,r,i,a)}throw t}}function Zo(e,t={}){return Xo(e,`Markup`,t)}function Qo(e,t={}){return Xo(e,`Tokens`,t)}function $o(e,t={}){let n=[],r=[],i=e.lastIndexOf(`}`),{closeBrace:a}={...qo,...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 Qo(e,{...t,hooks:r}).map(e=>es(e,n))}catch(e){if(!(e instanceof Jo))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}=Yo(e,a);r.push(new Jo(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 es(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 ts=`__proto__`;function ns(e,t=e){return e===`__proto__`?`\"${t}\" cannot be used as a variable name (${ts} is reserved)`:void 0}function rs(e,t=e){let n=ns(e,t);if(n)throw TypeError(`spindle: ${n}`)}var K=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),is=(e,t)=>e&&K(e,t)?e[t]:void 0;function as(e,t,n){t===`__proto__`?Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0,configurable:!0}):e[t]=n}function os(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)=>os(e),ss=e=>Object.getPrototypeOf(e)===null,cs=e=>ss(e)?e:q(e);function ls(e,t,n){let r=q(e);return r[t]=n,r}var us=Object.freeze(q());function ds(e,t){return[...new Set([...Object.keys(e),...Object.keys(t)])].filter(n=>is(e,n)!==is(t,n))}var fs=e=>typeof e==`number`&&Number.isInteger(e)&&e>=0;function ps(e,t){let n=is(e,t);return fs(n)?n:0}function ms(e,t){let n=os([e],fs);return t!==void 0&&(n[t]=ps(e,t)+1),n}var hs=new vr;function gs(e,t,n,r=!1){let i=n.filter(e=>e!==`@children`);for(let e of i)e.startsWith(`@`)&&rs(e.slice(1),e);hs.set(e,{body:t,params:i,isBlock:r})}function _s(e){return hs.get(e)}function vs(e){for(let t of e){if(t.type===`variable`&&t.scope===`local`&&t.name===`children`||t.type===`html`&&vs(t.children))return!0;if(t.type===`macro`){if(vs(t.children))return!0;if(t.branches){for(let e of t.branches)if(vs(e.children))return!0}}}return!1}function ys(e,t){return e instanceof Error?e.message||t||String(e):typeof e==`string`&&e!==``?e:t??String(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)}var xs=[],Ss=1,Cs=new Set;function ws(e){xs=e;for(let e of Cs)e()}function Ts(e,t){let n=ys(t).replace(/^spindle: /,``),r=xs.find(t=>t.context===e&&t.message===n);ws(r?xs.map(e=>e===r?{...e,count:e.count+1}:e):[...xs,{id:Ss++,context:e,message:n,count:1}])}function Es(e,t){return Error(`No passage named ${JSON.stringify(e)} (in passage ${JSON.stringify(t)})`)}function Ds(e){ws(xs.filter(t=>t.id!==e))}function Os(){return xs}function ks(e){return Cs.add(e),()=>{Cs.delete(e)}}function As(e){return/\\s/.test(e)}function js(e){return e===`(`||e===`[`||e===`{`}function Ms(e){return e===`)`||e===`]`||e===`}`}function Ns(e){return e.replace(/\\\\([\"'\\\\])/g,`$1`)}function Ps(e,t){let n=e[t];if(n!==`\"`&&n!==`'`)return null;let{end:r,closed:i}=Io(e,t);return i?{value:Ns(e.slice(t+1,r-1)),end:r}:null}function Fs(e){let t=Ps(e,0);return t&&t.end===e.length?t.value:null}function Is(e){return/^[\"']?(.+?)[\"']?$/s.exec(e)?.[1]??e}var Ls=/(?:[-+*/%&|^!~=<>?:,.]|(?:^|[^\\w$@.])(?:typeof|void|new|delete|in|instanceof|await|yield))$/;function Rs(e){let t=-1;if(Ao(e,{code(e,n,r){r===0&&!As(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:Ls.test(n)}function zs(e,t){let n=[],r=0;return Ao(e,{code(e,i,a){a>0||(js(e)?r++:Ms(e)?r--:r===0&&t(e)&&n.push(i))}}),n}function Bs(e,t){let n=[],r=0;for(let i of zs(e,t))n.push(e.slice(r,i)),r=i+1;return n.push(e.slice(r)),n}function Vs(e){return Hs(e)&&!Rs(e)}function Hs(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 Us(e){let t=Bs(e,As).filter(Boolean);if(t.length<2)return null;for(let e of t)if(!Vs(e))return null;return t}function Ws(e){let t=Bs(e,e=>e===`,`).map(e=>e.trim()),n=t.length>1;if(t[t.length-1]===``&&t.pop(),!n&&t.length===1){let e=Us(t[0]);if(e)return e}return t}function Gs(e){let t=[],n=0;for(let r of[...zs(e,As),e.length])r>n&&t.push([n,r]),n=r+1;return t}var Ks=(e,[t,n])=>e.slice(t,n);function qs(e){return Fs(e)??Is(e)}var Js=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 Ys(e,t,n){switch(n.spans?.set(e,[n.at,n.at+t.length]),e.type){case`string`:{let n=Fs(t);if(n===null)throw new Js(e,t);return n}case`text`:return qs(t);case`names`:return t.split(`,`).map(e=>e.trim());case`delay`:return bs(t);case`number`:return Number(t);case`options`:return tc(e.parameters??[],t,n);default:return t}}function Xs(e){return e.type===`flag`||e.type===`separator`?!1:e.type===`options`?{}:void 0}var Zs=/\\w+/y,Qs=/[-+]?(?:\\d+\\.?\\d*|\\.\\d+)/y,$s=/\\S+/y;function ec(e,t,n){return e.lastIndex=n,e.exec(t)?.[0]??null}function tc(e,t,{at:n,spans:r}){let i={},a=0;for(;a<t.length;){let o=ec(Zs,t,a);if(!o){a=Ps(t,a)?.end??a+1;continue}a+=o.length;let s,c=a;for(;c<t.length&&As(t[c]);)c++;let l=Ps(t,c),u=l||c===a?null:ec(Qs,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 Js(d,ec($s,t,c)??``);d?.type===`flag`?i[o]=!0:d?.type===`number`?i[o]=Number(s??0):d&&(i[o]=s)}return i}var nc=/^(?:[-+*/&|^=<>?:,.]|%(?![A-Za-z_]))/;function rc(e,t){let n=Gs(e);if(n.length<2)return null;if(Ks(e,n[n.length-1])===t){let t=[0,n[n.length-2][1]];if(!Rs(Ks(e,t)))return t}if(Ks(e,n[0])===t){let t=[n[1][0],e.length];if(!nc.test(Ks(e,t)))return t}return null}function ic(e,t){if(t===`=`){let t=zs(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=Gs(e);for(let r=1;r<n.length-1;r++)if(Ks(e,n[r])===t)return[n[r-1][1],n[r+1][0]];return null}var ac=e=>e.type===`expression`||e.type===`statements`||e.type===`passage`||e.type===`text`;function oc(e,t){let n=e.trim();return[n,n?t+e.indexOf(n):t]}function sc(e,t,n,{at:r,spans:i}){let[a,o]=oc(t??``,r);for(let r of e.filter(e=>e.type===`flag`)){let e=t===null?null:rc(a,r.name);n[r.name]=e!==null,e&&([a,o]=oc(Ks(a,e),o+e[0]))}let s=e.filter(e=>e.type!==`flag`);if(s.length===0)return;let c=s.findIndex((e,t)=>ac(e)&&!s.slice(t+1).some(ac)),l=c<0?s.length-1:c,u=(e,[t,n])=>t===n?Xs(e):Ys(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=Gs(a),f=0,p=d.length;for(let e of s.slice(0,l))n[e.name]=f<p?u(e,d[f++]):Xs(e);let m=(e,t)=>{try{return u(e,t)}catch(e){if(e instanceof Js)return;throw e}};for(let e of s.slice(l+1).reverse()){let t=f<p&&!Rs(a.slice(0,d[p-1][0]))?m(e,d[p-1]):void 0;n[e.name]=t??Xs(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]]):Xs(h)}var cc={name:`delay`,type:`delay`,required:!0};function lc(e,t,n){let r={},[i,a]=oc(e,0),o=0;return t.forEach((e,s)=>{if(e.type!==`separator`)return;let c=i===null?null:ic(i,e.name);r[e.name]=c!==null;let l=c?i.slice(0,c[0]):i;sc(t.slice(o,s),l,r,{at:a,spans:n}),i=c?i.slice(c[1]):null,c&&(a+=c[1]),o=s+1}),sc(t.slice(o),i,r,{at:a,spans:n}),r}function uc(e){let t=e.trim(),n=Fo(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 Es(i,r);return i}function fc(e){let t=e.trim(),n=Gs(t)[0];return n?Ks(t,n):``}var pc=[{name:`name`,type:`text`,holds:`text`,required:!0},{name:`parameters`,type:`text`,holds:`text`}];function mc({name:e=``,parameters:t=``}){return{name:e,params:t.split(/\\s+/).filter(e=>e.startsWith(`@`))}}function hc(e){return mc(lc(e,pc))}function gc(e){let t=[];for(let n of e){if(n.name!==`StoryInit`&&!n.tags?.includes(`widget`))continue;let e=[];for(let r of $o(n.content).tokens)if(r.type===`macro`&&r.name.toLowerCase()===`widget`){if(!r.isClose){e.push({rawArgs:r.rawArgs,isBlock:!1});continue}let n=e.pop();if(!n?.isBlock)continue;try{t.push(hc(n.rawArgs).name)}catch{}}else r.type===`variable`&&r.scope===`local`&&r.name===`children`&&e.length>0&&(e[e.length-1].isBlock=!0)}return t}function _c({name:e,params:t},n){let r=vs(n);gs(e,n,t,r),r&&Sr(e)}function vc(e,t){for(let n of e)if(n.type===`macro`&&n.name===`widget`&&n.rawArgs){let e=hc(n.rawArgs);try{_c(e,n.children)}catch(n){console.error(`spindle: widget \"${e.name}\" in passage \"${t}\" was not registered: ${ys(n)}`)}}}var yc=e=>Symbol.iterator in e,bc=e=>`entries`in e,xc=(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},Sc=(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 Cc(e,t){return Object.is(e,t)?!0:typeof e!=`object`||!e||typeof t!=`object`||!t||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:yc(e)&&yc(t)?bc(e)&&bc(t)?xc(e,t):Sc(e,t):xc({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}var wc=ge(null);function Tc(...e){let t=M(),n=Fe(wc);return Q(r=>{if(t.current&&n?.(r))return t.current;let i={};for(let t of e)i[t]=r[t];return Cc(t.current,i)?t.current:t.current=i})}function Ec(){let{variables:e,temporary:t,transient:n,renderCounts:r}=Tc(`variables`,`temporary`,`transient`,`renderCounts`),i=Fe(Sp);return Ne(()=>[e,t,i,n],[e,t,i,n,r])}var Dc=1831565813;function Oc(e){let t=e|0;return()=>{t=t+Dc|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 kc(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t}var Ac=!1,jc=``,Mc=0,Nc=null,Pc=0;function Fc(e,t=!0){let n;n=e===void 0?String(Date.now())+String(Math.random()):t?e+`|`+Date.now()+`|`+Math.random():e,jc=n,Mc=0,Nc=Oc(kc(n)),Ac=!0,Pc++}function Ic(e,t){Pc++,Lc(e,t)}function Lc(e,t){jc=e;let n=Math.imul(t%4294967296,Dc);Nc=Oc(kc(e)+n|0),Ac=!0,Mc=t}function Rc(){Pc++,Ac=!1,jc=``,Mc=0,Nc=null}function zc(e){let t={generation:Pc,seed:jc,pull:Mc};try{return e()}finally{Ac&&Pc===t.generation&&Mc!==t.pull&&Lc(t.seed,t.pull)}}function Bc(){return Ac?{seed:jc,pull:Mc}:null}function Vc(){return!Ac||!Nc?Math.random():(Mc++,Nc())}function Hc(e,t){return e>t&&([e,t]=[t,e]),Math.floor(Vc()*(t-e+1))+e}function Uc(){return Ac}function Wc(){return jc}function Gc(){return Mc}var Kc=500,qc={$:`variables`,_:`temporary`,\"@\":`locals`,\"%\":`transient`},Jc=/[\\p{ID_Continue}$\\u200c\\u200d]$/u;function Yc(e,t=`expression`){let n=t===`statements`?`s`+e:`e`+e,r=Xc.get(n);if(r!==void 0)return r;let{refs:i}=go(e,t),a=``,o=0;for(let t of i){let n=ns(t.name,t.sigil+t.name);if(n)throw SyntaxError(`spindle: ${n}`);a+=e.slice(o,t.start),t.shorthand?a+=`${t.name}: `:Jc.test(a.slice(-2))&&(a+=` `),a+=`${qc[t.sigil]}[\"${t.name}\"]`,o=t.end}return a+=e.slice(o),Xc.size>=Kc&&Xc.delete(Xc.keys().next().value),Xc.set(n,a),a}var Xc=new Map,Zc=500,Qc=new Map,$c=`const {currentPassage,previousPassage,visited,hasVisited,hasVisitedAny,hasVisitedAll,rendered,hasRendered,hasRenderedAny,hasRenderedAll,random,randomInt}=__fns;`;function el(e,t){let n=Qc.get(e);if(n)return Qc.delete(e),Qc.set(e,n),n;let r=Function(`variables`,`temporary`,`locals`,`__fns`,`transient`,$c+t);if(Qc.set(e,r),Qc.size>Zc){let e=Qc.keys().next().value;e!==void 0&&Qc.delete(e)}return r}function tl(){let e=Q.getState();return e.storyData?.passages.get(e.currentPassage)}function nl(){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 rl(e){let t=t=>ps(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 il(e,t){let n=rl(e),r=rl(t);return{currentPassage:tl,previousPassage:nl,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 al=null;function ol(){return al??(al={...il(()=>Q.getState().visitCounts,()=>Q.getState().renderCounts),random:Vc,randomInt:Hc}),al}function sl(e){return ss(e)?e:Object.isExtensible(e)?(Object.setPrototypeOf(e,null),e):cs(e)}function cl(e,...[t,n,r=us,i=us]){return e(sl(t),sl(n),sl(r),ol(),sl(i))}function ll(e,...t){let n=`return (${Yc(e)}\\n);`;return cl(el(n,n),...t)}function ul(e,...t){let n=Yc(e,`statements`);cl(el(`exec:`+n,n),...t)}var dl=new vr;function fl(e,t){dl.set(e,t)}function pl(e){return dl.get(e)}var ml=new vr;function hl(e,t){t?ml.set(e,t):ml.delete(e)}function gl(e){return ml.get(e)}var _l=new yr;function vl(e){_l.add(e)}function yl(e){return _l.has(e)}var bl=[`expression`,`statements`,`passage`,`variable`,`string`,`text`,`names`,`delay`,`number`,`flag`,`separator`,`options`],xl=[`markup`,`text`,`passage`,`expression`,`statements`];function Sl(e,t){let n=`Give a \\`string\\` or \\`text\\` parameter one of ${xl.join(`, `)} to hold (see docs/custom-macros.md#what-a-string-holds).`;for(let r of t){let t=r.type;if(!bl.includes(t))throw Cl(e,r,t===void 0?`has no type`:`has the unknown type ${JSON.stringify(t)}`,`Give it one of the types ${bl.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 Cl(e,r,`is of the type ${t}, which holds what it is`,n);if(i!==void 0&&!xl.includes(i))throw Cl(e,r,`holds the unknown ${JSON.stringify(i)}`,n);r.parameters&&Sl(e,r.parameters)}}function Cl(e,t,n,r){return Error(`spindle: The parameter \"${t.name}\" of the macro {${e}} ${n}. ${r}`)}var wl=new vr;function Tl(e,t){wl.set(e,t)}function El(e){return wl.get(e)?.parameters}function Dl(){return Array.from(wl.values())}function Ol(e){return e==null?``:String(e)}function kl(e,t,n){return e||t?b(`span`,{id:t,class:e},n):b(S,null,n)}function Al(e){return e.includes(`{`)||e.includes(`}`)}function jl(e,t){return e?.length?{nodes:e,outer:t??null}:null}var Ml=new Map,Nl=2e3;function Pl(e){let t=Ml.get(e);if(t===void 0){try{t={nodes:Zo(e,{text:!0})}}catch(e){t={error:e}}Ml.size>=Nl&&Ml.clear(),Ml.set(e,t)}return t}function Fl(e,t){return e.map(e=>{switch(e.type){case`text`:return{type:`text`,value:t(e.value)};case`html`:return{...e,children:Fl(e.children,t)};case`macro`:{let n={...e,children:Fl(e.children,t)};return e.branches&&(n.branches=e.branches.map(e=>({...e,children:Fl(e.children,t)}))),n}default:return e}})}var Il=100;function Ll(e,t,n){let r=n.split(`.`),i=r[0];rs(i,Wn[t]+i);let a=is(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 Rl(e,t){return ll(e,t.variables,t.temporary,t.locals,t.transient)}var zl=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 Ol(Rl(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 Ol(Ll(n,e,t))}catch(n){return this.errors.push({macro:Wn[e]+t,error:n}),``}}nested(e,t,n,r,i={}){return r>=Il?(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(yl(e.name))return``;let r=_s(e.name);if(r){let i=t.locals;if(r.params.length>0){let n=e.rawArgs?Ws(e.rawArgs):[];i=q(t.locals),r.params.forEach((e,r)=>{let a,o=n[r];if(o!==void 0)try{a=Rl(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:jl(e.children,t.widgetChildren)})}let i=gl(e.name);if(!i){let t=pl(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=>Rl(e,t),renderText:(r,i)=>this.nested(e.name,r,t,n,i?{locals:Bl(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 Bl(e,t){for(let e of Object.keys(t))rs(e,`@${e}`);return q(e,t)}function Vl(e,t){let n=new zl;return{text:n.nodes(e,t,0),errors:n.errors}}function Hl(e,t){if(!Al(e))return{text:e,errors:[]};let n=Pl(e);return`error`in n?{text:e,errors:[{macro:`markup`,error:n.error}]}:Vl(n.nodes,t)}function Ul(e,t,n){let r=[],i=``;for(let a of Go(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+=Ol(Ll(t,e,a.expr.slice(1)))}catch(e){r.push({macro:a.expr,error:e})}}else try{i+=Ol(Rl(a.expr,t))}catch(e){r.push({macro:`expression`,error:e})}return{text:i,errors:r}}function Wl(){let[e,t,n,r]=Ec(),i=Fe(Np);return Ne(()=>({variables:e,temporary:t,locals:n,transient:r,widgetChildren:i}),[e,t,n,r,i])}function Gl(){let e=Wl();return Pe(t=>{if(t===void 0||!Al(t))return t;let{text:n,errors:r}=Hl(t,e);for(let{macro:e,error:n}of r)console.error(`spindle: {${e}} error in \"${t}\": ${ys(n)}`);return n},[e])}var Kl=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:--Kl,__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 ql={variable:`variables`,temporary:`temporary`,transient:`transient`};function Jl({node:e}){let{name:t,scope:n}=e,r=Gl(),i=r(e.className),a=r(e.id),o=Fe(Sp),s=t.split(`.`),c=s[0],l=Q(e=>n===`local`?void 0:is(e[ql[n]],c)),u=Wn[n],d=ns(c,u+c);if(d)return J(`span`,{class:`error`,children:`{${u}${t} error: ${d}}`});let f;f=n===`local`?is(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 kl(i,a,Ol(f))}function Yl({node:e}){let{expression:t}=e,n=Gl(),r=n(e.className),i=n(e.id),[a,o,s,c]=Ec(),l;try{l=Ol(ll(t,a,o,s,c))}catch{l=`{error: ${t}}`}return kl(r,i,l)}function Xl(){return{nobr:Fe(wp),inline:Fe(Tp),raw:Fe(Ep),locals:Fe(Sp)}}function Zl({body:e,parentValues:t,ownKeys:n}){let r=Xl(),[i,a]=ke({}),o=Ne(()=>q(t,n,i),[t,n,i]),s=M(o);s.current=o;let c=Pe(()=>s.current,[]),l=Pe((e,t)=>{rs(e,`@${e}`),s.current=ls(s.current,e,t),a(n=>({...n,[e]:t}))},[]),u=Ne(()=>({update:l,getValues:c}),[l,c]);return J(Cp.Provider,{value:u,children:J(Sp.Provider,{value:o,children:Em(e,{...r,locals:o})})})}function Ql(e){let t=Gl();return kl(t(e.className),t(e.id),J($l,{...e}))}function $l({body:e,params:t,rawArgs:n,invocationChildren:r}){let i=Xl().locals,[a,o,s,c]=Ec(),l=Fe(Np),u=Ne(()=>jl(r,l),[r,l]),d=n?Ws(n):[],f=[];for(let e=0;e<t.length;e++){let t=d[e],n;if(t!==void 0)try{n=ll(t,a,o,s,c)}catch{n=void 0}f.push(n)}let p=Ne(()=>{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(Np.Provider,{value:u,children:J(Zl,{body:e,parentValues:i,ownKeys:p})})}var eu=document.createElement(`i`);function tu(e){let t=`&`+e+`;`;eu.innerHTML=t;let n=eu.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`||n===t?!1:n}function nu(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 ru(e,t){return e.length>0?(nu(e,e.length,0,t),e):t}var iu={}.hasOwnProperty;function au(e){let t={},n=-1;for(;++n<e.length;)ou(t,e[n]);return t}function ou(e,t){let n;for(n in t){let r=(iu.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){iu.call(r,a)||(r[a]=[]);let e=i[a];su(r[a],Array.isArray(e)?e:e?[e]:[])}}}function su(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);nu(e,0,0,r)}function cu(e){let t={},n=-1;for(;++n<e.length;)lu(t,e[n]);return t}function lu(e,t){let n;for(n in t){let r=(iu.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i)r[a]=i[a]}}function uu(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 du={'\"':`quot`,\"&\":`amp`,\"<\":`lt`,\">\":`gt`};function fu(e){return e.replace(/[\"&<>]/g,t);function t(e){return`&`+du[e]+`;`}}function pu(e){return e.replace(/[\\t\\n\\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var mu=wu(/[A-Za-z]/),hu=wu(/[\\dA-Za-z]/),gu=wu(/[#-'*+\\--9=?A-Z^-~]/);function _u(e){return e!==null&&(e<32||e===127)}var vu=wu(/\\d/),yu=wu(/[\\dA-Fa-f]/),bu=wu(/[!-/:-@[-`{-~]/);function Y(e){return e!==null&&e<-2}function xu(e){return e!==null&&(e<0||e===32)}function X(e){return e===-2||e===-1||e===32}var Su=wu(/\\p{P}|\\p{S}/u),Cu=wu(/\\s/);function wu(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function Tu(e,t){let n=fu(Eu(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 Eu(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&hu(e.charCodeAt(n+1))&&hu(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 Du={}.hasOwnProperty,Ou=/^(https?|ircs?|mailto|xmpp)$/i,ku=/^https?$/i;function Au(e){let t=e||{},n=!0,r={},i=[[]],a=[],o=[],s=cu([{enter:{blockQuote:te,codeFenced:ie,codeFencedFenceInfo:h,codeFencedFenceMeta:h,codeIndented:se,codeText:Re,content:Ce,definition:ve,definitionDestinationString:be,definitionLabelString:h,definitionTitleString:h,emphasis:Ie,htmlFlow:Ne,htmlText:Fe,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:Te,strong:Le},exit:{atxHeading:De,atxHeadingSequence:we,autolinkEmail:Ke,autolinkProtocol:Ge,blockQuote:ne,characterEscapeValue:Ae,characterReferenceMarkerHexadecimal:Ue,characterReferenceMarkerNumeric:Ue,characterReferenceValue:We,codeFenced:ce,codeFencedFence:oe,codeFencedFenceInfo:ae,codeFencedFenceMeta:S,codeFlowValue:Me,codeIndented:ce,codeText:ze,codeTextData:Ae,data:Ae,definition:Se,definitionDestinationString:xe,definitionLabelString:ye,definitionTitleString:j,emphasis:Be,hardBreakEscape:M,hardBreakTrailing:M,htmlFlow:Pe,htmlFlowData:Ae,htmlText:Pe,htmlTextData:Ae,image:A,label:fe,labelText:de,lineEnding:je,link:A,listOrdered:E,listUnordered:D,paragraph:k,reference:S,referenceString:pe,resource:S,resourceDestinationString:ge,resourceTitleString:_e,setextHeading:ke,setextHeadingLineSequence:Oe,setextHeadingText:Ee,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=ru(o,e.slice(n,t)),n=t):(a=ru(a,e.slice(n,t+1)),n=t+1));a=ru(a,o),a=ru(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];Du.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:fu(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[pu(o)]:i;for(n=!0;e--;)if(a[e].image){n=void 0;break}i.image?(_(`<img src=\"`+Tu(s.destination,t.allowDangerousProtocol?void 0:ku)+`\" alt=\"`),v(i.label),_(`\"`)):_(`<a href=\"`+Tu(s.destination,t.allowDangerousProtocol?void 0:Ou)+`\"`),_(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 j(){a[a.length-1].title=g()}function Se(){let e=a[a.length-1],t=pu(e.labelId);g(),Du.call(r,t)||(r[t]=a[a.length-1]),a.pop()}function Ce(){p(`slurpAllLineEndings`,!0)}function we(e){m(`headingRank`)||(p(`headingRank`,this.sliceSerialize(e).length),b(),_(`<h`+m(`headingRank`)+`>`))}function Te(){h(),p(`slurpAllLineEndings`)}function Ee(){p(`slurpAllLineEndings`,!0)}function De(){_(`</h`+m(`headingRank`)+`>`),p(`headingRank`)}function Oe(e){p(`headingRank`,this.sliceSerialize(e).charCodeAt(0)===61?1:2)}function ke(){let e=g();b(),_(`<h`+m(`headingRank`)+`>`),v(e),_(`</h`+m(`headingRank`)+`>`),p(`slurpAllLineEndings`),p(`headingRank`)}function Ae(e){v(x(this.sliceSerialize(e)))}function je(e){if(!m(`slurpAllLineEndings`)){if(m(`slurpOneLineEnding`)){p(`slurpOneLineEnding`);return}if(m(`inCodeText`)){v(` `);return}v(x(this.sliceSerialize(e)))}}function Me(e){v(x(this.sliceSerialize(e))),p(`flowCodeSeenData`,!0)}function M(){_(`<br />`)}function Ne(){b(),Fe()}function Pe(){p(`ignoreEncode`)}function Fe(){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`)?uu(t,m(`characterReferenceType`)===`characterReferenceMarkerNumeric`?10:16):tu(t))),p(`characterReferenceType`)}function Ge(e){let n=this.sliceSerialize(e);_(`<a href=\"`+Tu(n,t.allowDangerousProtocol?void 0:Ou)+`\">`),v(x(n)),_(`</a>`)}function Ke(e){let t=this.sliceSerialize(e);_(`<a href=\"`+Tu(`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 ju={tokenize:Mu};function Mu(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 Nu={tokenize:Fu},Pu={tokenize:Iu};function Fu(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 nu(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(Pu,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(Pu,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++;nu(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 Iu(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 Lu(e){if(e===null||xu(e)||Cu(e))return 1;if(Su(e))return 2}function Ru(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 zu={name:`attention`,resolveAll:Bu,tokenize:Vu};function Bu(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};Hu(d,-c),Hu(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=ru(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=ru(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=ru(l,Ru(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=ru(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=ru(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,nu(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 Vu(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Lu(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=Lu(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 Hu(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var Uu={name:`autolink`,tokenize:Wu};function Wu(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 mu(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||hu(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||hu(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||_u(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):gu(t)?(e.consume(t),l):n(t)}function u(e){return hu(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||hu(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var Gu={partial:!0,tokenize:Ku};function Ku(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 qu={continuation:{tokenize:Yu},exit:Xu,name:`blockQuote`,tokenize:Ju};function Ju(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 Yu(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(qu,t,n)(r)}}function Xu(e){e.exit(`blockQuote`)}var Zu={name:`characterEscape`,tokenize:Qu};function Qu(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 bu(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var $u={name:`characterReference`,tokenize:ed};function ed(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=hu,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=yu,u):(e.enter(`characterReferenceValue`),a=7,o=vu,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===hu&&!tu(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 td={partial:!0,tokenize:id},nd={concrete:!0,name:`codeFenced`,tokenize:rd};function rd(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(td,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(td,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 id(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:sd},od={partial:!0,tokenize:cd};function sd(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(od,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 cd(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 ld={name:`codeText`,previous:dd,resolve:ud,tokenize:fd};function ud(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 dd(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function fd(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 pd=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&&md(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),md(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),md(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);md(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);md(this.left,t.reverse())}}};function md(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 hd(e){let t={},n=-1,r,i,a,o,s,c,l,u=new pd(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,gd(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 nu(e,0,1/0,u.slice(0)),!l}function gd(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 _d={resolve:yd,tokenize:bd},vd={partial:!0,tokenize:xd};function yd(e){return hd(e),e}function bd(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(vd,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 xd(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 Sd(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||_u(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||xu(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||_u(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 Cd(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 wd(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 Td(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 Ed={name:`definition`,tokenize:Od},Dd={partial:!0,tokenize:kd};function Od(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return Cd.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=pu(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 xu(t)?Td(e,l)(t):l(t)}function l(t){return Sd(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(Dd,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 kd(e,t,n){return r;function r(t){return xu(t)?Td(e,i)(t):n(t)}function i(t){return wd(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 Ad={name:`hardBreakEscape`,tokenize:jd};function jd(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 Md={name:`headingAtx`,resolve:Nd,tokenize:Pd};function Nd(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`},nu(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function Pd(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||xu(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||xu(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var Fd=`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(`.`),Id=[`pre`,`script`,`style`,`textarea`],Ld={concrete:!0,name:`htmlFlow`,resolveTo:Bd,tokenize:Vd},Rd={partial:!0,tokenize:Ud},zd={partial:!0,tokenize:Hd};function Bd(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 Vd(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):mu(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):mu(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 mu(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||xu(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&Id.includes(l)?(i=1,r.interrupt?t(s):D(s)):Fd.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||hu(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||mu(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||hu(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||xu(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(Rd,ce,O)(t)):t===null||Y(t)?(e.exit(`htmlFlowData`),O(t)):(e.consume(t),D)}function O(t){return e.check(zd,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 Id.includes(n)?(e.consume(t),se):D(t)}return mu(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 Hd(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 Ud(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(Gu,t,n)}}var Wd={name:`htmlText`,tokenize:Gd};function Gd(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):mu(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):mu(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 mu(t)?(e.consume(t),S):n(t)}function S(t){return t===45||hu(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||hu(t)?(e.consume(t),w):t===47||t===62||xu(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),re):t===58||t===95||mu(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||hu(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||xu(t)?T(t):(e.consume(t),te)}function ne(e){return e===47||e===62||xu(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 Kd={name:`labelEnd`,resolveAll:Xd,resolveTo:Zd,tokenize:Qd},qd={tokenize:$d},Jd={tokenize:ef},Yd={tokenize:tf};function Xd(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&&nu(e,0,e.length,n),e}function Zd(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=ru(s,e.slice(a+1,a+r+3)),s=ru(s,[[`enter`,u,t]]),s=ru(s,Ru(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=ru(s,[[`exit`,u,t],e[o-2],e[o-1],[`exit`,l,t]]),s=ru(s,e.slice(o+1)),s=ru(s,[[`exit`,c,t]]),nu(e,a,e.length,s),e}function Qd(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(pu(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(qd,u,o?u:d)(t):t===91?e.attempt(Jd,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(Yd,u,d)(t)}function u(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}function $d(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 xu(t)?Td(e,a)(t):a(t)}function a(t){return t===41?u(t):Sd(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return xu(t)?Td(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?wd(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return xu(t)?Td(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 Cd.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(pu(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function tf(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 nf={name:`labelStartImage`,resolveAll:Kd.resolveAll,tokenize:rf};function rf(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:Kd.resolveAll,tokenize:of};function of(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 sf={name:`lineEnding`,tokenize:cf};function cf(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),Z(e,t,`linePrefix`)}}var lf={name:`thematicBreak`,tokenize:uf};function uf(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 df={continuation:{tokenize:hf},exit:_f,name:`list`,tokenize:mf},ff={partial:!0,tokenize:vf},pf={partial:!0,tokenize:gf};function mf(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:vu(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(lf,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 vu(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(Gu,r.interrupt?n:u,e.attempt(ff,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 hf(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(Gu,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(pf,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,Z(e,e.attempt(df,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function gf(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 _f(e){e.exit(this.containerState.type)}function vf(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 yf={name:`setextUnderline`,resolveTo:bf,tokenize:xf};function bf(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 xf(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 Sf={tokenize:Cf};function Cf(e){let t=this,n=e.attempt(Gu,r,e.attempt(this.parser.constructs.flowInitial,i,Z(e,e.attempt(this.parser.constructs.flow,i,e.attempt(_d,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 wf={resolveAll:Of()},Tf=Df(`string`),Ef=Df(`text`);function Df(e){return{resolveAll:Of(e===`text`?kf: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 Of(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 kf(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 Af=t({attentionMarkers:()=>Rf,contentInitial:()=>Mf,disable:()=>zf,document:()=>jf,flow:()=>Pf,flowInitial:()=>Nf,insideSpan:()=>Lf,string:()=>Ff,text:()=>If}),jf={42:df,43:df,45:df,48:df,49:df,50:df,51:df,52:df,53:df,54:df,55:df,56:df,57:df,62:qu},Mf={91:Ed},Nf={[-2]:ad,[-1]:ad,32:ad},Pf={35:Md,42:lf,45:[yf,lf],60:Ld,61:yf,95:lf,96:nd,126:nd},Ff={38:$u,92:Zu},If={[-5]:sf,[-4]:sf,[-3]:sf,33:nf,38:$u,42:zu,60:[Uu,Wd],91:af,92:[Ad,Zu],93:Kd,95:zu,96:ld},Lf={null:[zu,wf]},Rf={null:[42,95]},zf={null:[]};function Bf(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=ru(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=Ru(a,l.events,l),l.events):[]}function f(e,t){return Hf(p(e),t)}function p(e){return Vf(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&&nu(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 Vf(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 Hf(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 Uf(e){let t={constructs:au([Af,...(e||{}).extensions||[]]),content:n(ju),defined:[],document:n(Nu),flow:n(Sf),lazy:{},string:n(Tf),text:n(Ef)};return t;function n(e){return n;function n(n){return Bf(t,e,n)}}}function Wf(e){for(;!hd(e););return e}var Gf=/[\\0\\t\\n\\r]/g;function Kf(){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(Gf.lastIndex=u,c=Gf.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 qf(e,t,n){return typeof t!=`string`&&(n=t,t=void 0),Au(n)(Wf(Uf(n).document().write(Kf()(e,t,!0))))}var Jf={none:``,left:` align=\"left\"`,right:` align=\"right\"`,center:` align=\"center\"`};function Yf(){return{enter:{table(e){let t=e._align;this.lineEndingIfNeeded(),this.tag(`<table>`),this.setData(`tableAlign`,t)},tableBody(){this.tag(`<tbody>`)},tableData(){let e=Jf[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=Jf[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,Xf)),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`+Jf[e[t]]+`></td>`),t++;this.setData(`tableColumn`,t),this.lineEndingIfNeeded(),this.tag(`</tr>`)}}}}function Xf(e,t){return t===`|`?t:e}var Zf=class{constructor(){this.map=[]}add(e,t,n){Qf(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 Qf(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function $f(e,t){let n=!1,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 ep(){return{flow:{null:{name:`table`,tokenize:tp,resolveAll:np}}}}function tp(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||xu(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||xu(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 np(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 Zf;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(ip(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=rp(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=rp(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=rp(f,t,o,i,n,d)):(o[0]=o[1],d=rp(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&ip(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=$f(t.events,n))}return e}function rp(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 ip(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 op(){return{enter:{strikethrough(){this.tag(`<del>`)}},exit:{strikethrough(){this.tag(`</del>`)}}}}function sp(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&&nu(o,o.length,0,Ru(s,e.slice(r+1,n),t)),nu(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),nu(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=Lu(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=Lu(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}function cp(e){let t=[`codeIndented`];return e?.inline&&t.push(`list`,`headingAtx`,`setextUnderline`,`thematicBreak`,`blockQuote`,`codeFenced`,`table`),{allowDangerousHtml:!0,extensions:[ep(),sp(),{disable:{null:t}}],htmlExtensions:[Yf(),op()]}}function lp(e,t){let n=cp(t);return qf(e,{...n,extensions:[...n.extensions??[],hp(e),dp]})}var up=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},dp={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:up}}},fp=/[#-'*+\\--9=?A-Z^-~]/,pp=/[0-9A-Za-z]/,mp=/[A-Za-z]/;function hp(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]===`!`&&mp.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(;fp.test(e[n]??``);)n++;if(e[n]!==`@`)return!1;n++;let r=0,i=`atSignOrDot`;for(;;){let t=e[n]??``;if(i===`atSignOrDot`){if(!pp.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===`-`||pp.test(t))&&r++<63))return!1;n++,i=t===`-`?`value`:`label`}}}let c={name:`unclosedHtml`,resolveTo:up,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 gp(e){let t=e.metadata[`data-source-file`],n=e.metadata[`data-source-line`];return t?n?` (${t}:${n})`:` (${t})`:``}function _p(){let e=Q.getState();if(!e.storyData)return``;let t=e.storyData.passages.get(e.currentPassage);return t?gp(t):``}function vp({macro:e,error:t}){return J(`span`,{class:`error`,title:String(t),children:`{${e} error${_p()}: ${ys(t)}}`})}function yp(e,t,n=_p()){console.error(`spindle: Error in {${e}}${n}:`,t)}function bp(e,t,n){let r=M();if(r.current===void 0){r.current=null;let i=_p();try{n()}catch(n){r.current={error:n},yp(`${e} ${t}`.trim(),n,i)}}return r.current?J(vp,{macro:e,error:r.current.error}):null}var xp={update:e=>{throw Error(`Cannot set @${e} — local variables require a {for}, widget, {link}, or {button} scope`)},getValues:()=>us},Sp=ge(us),Cp=ge(xp),wp=ge(!1),Tp=ge(!1),Ep=ge(!1),Dp=ge(``),Op=0;function kp(){return ke(()=>`v${++Op}`)[0]}var Ap=ge(!1),jp=`http://www.w3.org/2000/svg`,Mp=new Set([`pre`,`textarea`,`style`]),Np=ge(null);function Pp(e,t){return`<span data-tw=${e}:${t}></span>`}var Fp=/(?:(?<=\\\\)\\uE000)?<span data-tw=([0-9a-z]+):(\\d+)><\\/span>/g,Ip=``;function Lp(e,t){if(!e.includes(`<span data-tw=`))return[e];let n=[],r=0;for(let i of e.matchAll(Fp))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 Rp(e,t){return Lp(e,t).map(e=>typeof e==`number`?t.components[e]:e)}function zp({tag:e,attributes:t,placeholders:n,svg:r,children:i}){let a=Wl(),o=[],{props:s,direct:c}=Qp(t.map(([e,t,r])=>{let i=n[e];if(!i)return[e,t,r];let s=Vl(i,a);for(let t of s.errors)o.push([e,t]);return[e,s.text,r]}),r),l=$p(c);return Vp(o,b(e,l?{...s,ref:l}:s,...i))}function Bp({tag:e,props:t,direct:n,children:r}){let i=$p(n);return b(e,{...t,ref:i},...r)}function Vp(e,t){return e.length===0?t:J(S,{children:[e.map(([e,{macro:t,error:n}],r)=>J(vp,{macro:t,error:Error(`in attribute \"${e}\": ${ys(n)}`)},r)),t]})}function Hp(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 Up(e){let t=document.createElement(`template`);return t.innerHTML=e,t.content}function Wp(e,t,n=!1){let r=Up(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)=>Gp(e,n,t))})}function Gp(e,t,n){if(e.nodeType===Node.TEXT_NODE){let t=e.textContent??``;t.endsWith(`\\\\${Ip}`)&&Hp(e.nextSibling,n)!==-1&&(t=t.slice(0,-1));let r=Rp(t,n);return r.length===1?r[0]:r}if(e.nodeType===Node.ELEMENT_NODE){let r=e,i=r.localName,a=Hp(r,n);if(a!==-1)return n.components[a];let o=r.namespaceURI===jp,s=[],c;for(let{name:e,value:t}of Array.from(r.attributes)){s.push([e,t,t]);let r=Lp(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)=>Gp(e,t,n));if(c)return J(zp,{tag:i,attributes:s,placeholders:c,svg:o,children:l},t);let{props:u,direct:d}=Qp(s,o);return d.length>0?J(Bp,{tag:i,props:u,direct:d,children:l},t):b(i,{...u,key:t},...l)}return null}var Kp=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(`.`)),qp=new Set([`value`,`checked`,`selected`,`muted`]),Jp=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`]),Yp=new Set([...new Set([`key`,`ref`,`children`,`dangerouslySetInnerHTML`]),`class`,`className`]),Xp=/^[A-Za-z_:][\\w:.-]*$/;function Zp(e,t,n){if(Xp.test(t)){e.setAttribute(t,n);return}let r=Up(`<i ${t}=\"\"></i>`).firstChild.attributes[0];if(!r)return;let i=r.cloneNode();i.value=n,e.setAttributeNode(i)}function Qp(e,t){let n={},r=[];for(let[i,a,o]of e){let e=i.toLowerCase();Jp.has(e)&&o!==``&&a===``||(!t&&qp.has(e)?n[e]=e!==`value`&&o===``?!0:a:!Xp.test(i)||e.startsWith(`on`)||e===`translate`||t&&(Yp.has(i)||i===`__proto__`)?r.push([i,a]):n[t?i:i.toUpperCase()]=a)}return{props:n,direct:r}}function $p(e){let t=M(null);return Me(()=>{let n=t.current;if(!(!n||e.length===0)){for(let[t,r]of e)Zp(n,t,r);return()=>{for(let[t]of e)n.removeAttribute(t)}}},[JSON.stringify(e)]),e.length>0?t:void 0}var em=new Map,tm=new Map;function nm(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 rm(e){return nm(e,tm,e=>Up(`<i title=\"${e.replace(/\"/g,`"`)}\"></i>`).firstChild.getAttribute(`title`))}function im(e){return nm(e,em,e=>Up(`<i>${e.replace(/</g,`<`)}</i>`).firstChild.textContent)}var am=/\\{[$_@%]\\w/,om=new Map,sm=2e3;function cm(e){let t=om.get(e);return t===void 0&&(t=Pl(e),`nodes`in t&&e.includes(`&`)&&(t={nodes:Fl(t.nodes,rm)}),om.size>=sm&&om.clear(),om.set(e,t)),t}function lm(e,t,n,r){if(Wo(e)){if(!t.includes(`&`)&&!am.test(t))return t;let i=Ul(t,n,rm);for(let t of i.errors)r.push([e,t]);return i.text}if(!Al(t))return rm(t);let i=cm(t);if(`error`in i)return r.push([e,{macro:`markup`,error:i.error}]),rm(t);let a=Vl(i.nodes,n);for(let t of a.errors)r.push([e,t]);return a.text}function um(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 dm({node:e}){let t=Wl(),{nobr:n,locals:r,raw:i,inline:a}=Xl(),o=Fe(Ap),s=e.tag.toLowerCase(),c=s===`svg`,l=!i&&(c||Mp.has(s)),u=[],{props:d,direct:f}=Qp(Object.entries(e.attributes).map(([e,n])=>[e,lm(e,n,t,u),n]),o||c),p=$p(f);p&&(d.ref=p);let m=Kp.has(s),h;if(e.children.length>0)if(i||l)h=vm(e.children);else{let t=s===`details`?um(e.children):-1,i=e=>Em(e,{nobr:n,locals:r,inline:m});h=t===-1?i(e.children):J(S,{children:[i(e.children.slice(0,t)),_m(e.children[t]),i(e.children.slice(t+1))]}),m!==a&&(h=J(Tp.Provider,{value:m,children:h}))}let g=b(e.tag,d,h);return c&&!o&&(g=J(Ap.Provider,{value:!0,children:g})),Vp(u,l?J(Ep.Provider,{value:!0,children:g}):g)}function fm(){let e=Fe(Np),t=Xl();return e?J(Np.Provider,{value:e.outer,children:Em(e.nodes,t)}):null}var pm=new WeakMap,mm=0;function hm(e){let t=pm.get(e);return t===void 0&&(t=`n${mm++}`,pm.set(e,t)),t}function gm(e,t){if(yl(e.name))return null;let n={rawArgs:e.rawArgs,className:e.className,id:e.id},r=_s(e.name);if(r)return J(Ql,{...n,body:r.body,params:r.params,invocationChildren:e.children},t);let i=pl(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 _m(e){if(e.type===`text`)return im(e.value);let t=hm(e);switch(e.type){case`variable`:return e.scope===`local`&&e.name===`children`?J(fm,{},t):J(Jl,{node:e},t);case`expression`:return J(Yl,{node:e},t);case`macro`:return gm(e,t);case`html`:return J(dm,{node:e},t);default:return e}}function vm(e){return e.length===0?null:e.map(e=>_m(e))}var ym=/[*_`#|~\\[>\\\\\\-+=\\r]|!\\[|\\d+[.)]|&#?[a-zA-Z0-9]+;| {2}\\n|<[!?]/,bm=/(?:\\r\\n|\\r(?!\\n)|\\n)\\s*[\\r\\n]/,xm=/<span data-tw=[0-9a-z]+:\\d+><\\/span>/g,Sm=` \t\\r\n`;function Cm(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 wm(e){return e.includes(`\n`)?e.split(`\n`).map((e,t,n)=>{let r=t===0?0:Cm(e,0,1,` \t`),i=t===n.length-1?e.length:Cm(e,e.length,-1,` \t`);return e.slice(r,Math.max(r,i))}).join(`\n`):e}function Tm(e,t,n){let r=Rp(wm(e),t).filter(e=>e!==``);return n?J(S,{children:r}):b(`p`,null,...r)}function Em(e,t){if(e.length===0)return null;if(t?.raw)return vm(e);if(!e.some(e=>e.type===`text`&&(e.value.trim()!==``||bm.test(e.value))))return e.map(e=>_m(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(_m(a)),r.nodes.push(a),i.endsWith(`\\\\`)&&(i+=Ip),i+=Pp(r.nonce,o)}let a=!!(t?.nobr||t?.inline),o=i.slice(0,Cm(i,0,1,Sm)),s=o.length===i.length?``:i.slice(Cm(i,i.length,-1,Sm)),c=i.slice(o.length,i.length-s.length),l=e=>a&&(o||s)?J(S,{children:[o,e,s]}):e,u=i.replace(xm,``);return!ym.test(u)&&!bm.test(u)?l(Tm(c,r,a)):l(Wp(lp(i,{inline:t?.inline}),r,a))}var Dm=2**32-1,Om=Dm-1,km=class extends Error{constructor(e,t,n,r){super(e),this.name=`DevalueError`,this.path=t.join(``),this.value=n,this.root=r}},Am=Symbol();function jm(e,t){let n=[];for(let r=0;r<e.length;r+=1){let i=e[r];i===Am?n.push(`.get(${t(e[++r])})`):typeof i==`number`?n.push(`[${i}]`):n.push(Wm(i))}return n}var Mm=Object.getOwnPropertyNames(Object.prototype).sort().join(`\\0`);function Nm(e){let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null||Object.getPrototypeOf(t)===null||Object.getOwnPropertyNames(t).sort().join(`\\0`)===Mm}function Pm(e){return Object.prototype.toString.call(e).slice(8,-1)}function Fm(e){return typeof Buffer<`u`&&Buffer.isBuffer(e)}function Im(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 Lm=/[\"<\\\\\\u0000-\\u001f\\u2028\\u2029]/;function Rm(e){if(!Lm.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=Im(e[i]);o&&(t+=e.slice(n,i)+o,n=i+1)}return`\"${n===0?e:t+e.slice(n)}\"`}var zm=64,Bm=new Map;function Vm(e){if(e.length>zm)return Rm(e);let t=Bm.get(e);return t===void 0&&(Bm.size>=1024&&Bm.clear(),t=Rm(e),Bm.set(e,t)),t}function Hm(e){let t=Object.getOwnPropertySymbols(e);return t.length===0?t:t.filter(t=>Object.getOwnPropertyDescriptor(e,t)?.enumerable)}var Um=/^[a-zA-Z_$][a-zA-Z_$0-9]*$/;function Wm(e){return Um.test(e)?`.`+e:`[`+JSON.stringify(e)+`]`}function Gm(e){return!(!Number.isInteger(e)||e<0||e>Om)}function Km(e){return!(!Number.isInteger(e)||e<0||e>Dm)}function qm(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 Gm(+e)}function Jm(e){for(var t=e.length-1;t>=0&&!qm(e[t]);t--);return t+1}function Ym(e){let t=Object.keys(e);return t.length=Jm(t),t}function Xm(e){return new Uint8Array(e).toBase64()}function Zm(e){return Uint8Array.fromBase64(e).buffer}function Qm(e){return Buffer.from(e).toString(`base64`)}function $m(e){return Uint8Array.from(Buffer.from(e,`base64`)).buffer}function eh(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 th(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 nh=typeof Uint8Array.fromBase64==`function`,rh=typeof process==`object`&&process.versions?.node!==void 0,ih=nh?Xm:rh?Qm:eh,ah=nh?Zm:rh?$m:th;function oh(e,t){if(!t)return e;let n={};for(let r of Object.keys(e))n[r]=t[r]??e[r];return n}var sh=Object.freeze({kind:`not-plain`}),ch=Object.freeze({kind:`symbol-keys`}),lh=Object.freeze({identify:e=>e,typeOf:e=>e===null?`null`:typeof e,toPrimitive:e=>e,tagOf:e=>Pm(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=>(Fm(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=>Ym(e),shapeOf:e=>Nm(e)?Hm(e).length>0?ch:{kind:Object.getPrototypeOf(e)===null?`null-proto`:`plain`,keys:Object.keys(e)}:sh,get:(e,t)=>e[t]}),uh=Object.getOwnPropertyDescriptor(ArrayBuffer.prototype,`byteLength`)?.get,dh=typeof SharedArrayBuffer>`u`?void 0:Object.getOwnPropertyDescriptor(SharedArrayBuffer.prototype,`byteLength`)?.get,fh=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{uh.call(t)}catch(e){if(!dh)throw e;dh.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[Om]=void 0,delete t[Om],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 ph(){throw Error(`Invalid input`)}function mh(e,t,n){return hh(JSON.parse(e),t,n)}function hh(e,t,n){let r=oh(fh,n?.operations);if(typeof e==`number`)return c(e,!0);(!Array.isArray(e)||e.length===0)&&ph();let i=e,a=Array(i.length),o=null;function s(e){return(!Gm(e)||e>=i.length)&&ph(),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`)&&ph(),e in a)return a[e];e>=i.length&&ph();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&&ph()}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`)&&ph();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(ah(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];Km(t)||ph();let n=r.createSparseArray(t);a[e]=n;for(let e=2;e<l.length;e+=2){let i=l[e];(!Gm(i)||i>=t)&&ph(),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 gh(e,t,n){let r=_h(!1,e,t,n);return typeof r==`string`?r:`[${r.join(`,`)}]`}function _h(e,t,n,r){let i=oh(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 km(e,jm(c,e=>{let t=i.typeOf(e);return t!==`object`&&t!==`function`&&t!==`symbol`?vh(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=vh(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\",${Rm(i.toStringValue(t))}]`;break;case`URLSearchParams`:m=`[\"URLSearchParams\",${Rm(i.toStringValue(t))}]`;break;case`RegExp`:let{source:n,flags:r}=i.regExpInfo(t);m=r?`[\"RegExp\",${Rm(n)},\"${r}\"]`:`[\"RegExp\",${Rm(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(Am,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\",\"${ih(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}\",${Rm(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+=`,${Vm(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+=`${Vm(r)}:${d(i.get(t,r))}`,c.pop();m+=`}`}}}}return a[n]=m,n}let f=d(t);return f<0?`${f}`:a}function vh(e){let t=typeof e;return t===`string`?Rm(e):e===void 0?`-1`:e===0&&1/e<0?`-6`:t===`bigint`?`[\"BigInt\",\"${e}\"]`:String(e)}var yh=e=>Object.prototype.toString.call(e).slice(8,-1),bh=e=>yh(e).startsWith(`Temporal.`),xh=e=>e instanceof Number||e instanceof String||e instanceof Boolean||yh(e)===`BigInt`;function Sh(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||xh(e)||bh(e)}function Ch(e){if(!Sh(e))return;let t=e instanceof Error?`Error`:yh(e);return`${/^[AEIOU]/.test(t)?`an`:`a`} ${t}`}var wh=e=>e!==`4294967295`&&String(Number(e)>>>0)===e;function Th(e){let t=Object.keys(e);return Array.isArray(e)?t.filter(e=>!wh(e)):t}function Eh(e){return jt(e)?e.entries():Map.prototype.entries.call(e)}function Dh(e){return jt(e)?e.values():Set.prototype.values.call(e)}function Oh(e){if(jt(e))return e.size;let t=e instanceof Map?Map.prototype:Set.prototype;return Reflect.get(t,`size`,e)}function kh(e,t){return jt(e)?e.get(t):Map.prototype.get.call(e,t)}function Ah(e,t,n){jt(e)?e.set(t,n):Map.prototype.set.call(e,t,n)}var jh=new Map,Mh=new Map,Nh=[ArrayBuffer,DataView,Object.getPrototypeOf(Int8Array),URL,URLSearchParams,Number,String,Boolean,Promise,WeakMap,WeakSet,Function];function Ph(e,t){let n=typeof t==`function`?Nh.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)`);jh.set(e,t),Mh.set(t,e)}function Fh(e){let t=Object.getPrototypeOf(e);return t===null?void 0:Mh.get(t.constructor)}var Ih=`c:`,Lh=`E:`,Rh=`S`,zh=`K`,Bh=`R`,Vh=new Map([Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError,globalThis.AggregateError].map(e=>[e.prototype,e.name])),Hh=new Map([...Vh].map(([e,t])=>[t,e.constructor])),Uh=[`message`,`cause`,`errors`],Wh=e=>typeof e==`object`&&!!e,Gh=e=>Wh(e)&&Object.getPrototypeOf(e)===Object.prototype,Kh=e=>TypeError(`spindle: Malformed data for class \"${e}\"`),qh=(e,t,n)=>{Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0,configurable:!0})};function Jh(e){if(Object.getOwnPropertySymbols(e).length>0)throw TypeError(`spindle: Cannot save an object with symbol keys`)}function Yh(e,t=Object.keys(e)){Jh(e);let n={};if(e instanceof Error)for(let t of Uh)K(e,t)&&qh(n,t,e[t]);for(let r of t)qh(n,r,e[r]);return n}var Xh={Array,Map,Set,Date,RegExp};function Zh(e){let t=()=>Yh(e,Th(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(Eh(e)),t()]:e instanceof Set?[`Set`,Array.from(Dh(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()]:Yh(e)}function Qh(e){for(let t of Uh)K(e,t)&&Object.defineProperty(e,t,{enumerable:!1})}var $h=e=>e.length===1&&JSON.stringify(e).length>3;function eg(){let e={};for(let[t,n]of jh)e[Ih+t]=e=>Wh(e)&&Object.getPrototypeOf(e)===n.prototype&&Zh(e);for(let[t,n]of Vh)e[Lh+n]=e=>Wh(e)&&Object.getPrototypeOf(e)===t&&Yh(e);return e[Rh]=e=>{if(typeof e!=`symbol`)return!1;let t=Symbol.keyFor(e);return t!==void 0&&[t]},e[Bh]=e=>e instanceof RegExp&&e.lastIndex!==0&&[e.source,e.flags,e.lastIndex],e[zh]=e=>{if(!Gh(e))return!1;let t=Object.keys(e);if(!t.some($h))return!1;if(Jh(e),t.includes(`__proto__`))throw TypeError(`spindle: Cannot save a property named \"__proto__\"`);return t.flatMap(t=>[t,e[t]])},e}function tg(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`?tg(t):typeof t==`number`?new Date(t):void 0}var rg=new WeakMap;function ig(e,t,n){let[r,i,a]=n,o=typeof r==`string`&&K(Xh,r)?Xh[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)&&!Gh(a))throw Kh(e);let c=rg.get(n);if(!c){let a=s?ng(r,i):new o;if(!a)throw Kh(e);c=Object.setPrototypeOf(a,t.prototype),rg.set(n,c)}if(!s&&Array.isArray(i)&&ag(c,i),Gh(a))for(let e of Object.keys(a))qh(c,e,a[e]);return c}function ag(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 og(e){return t=>{if(Array.isArray(t))return ig(e,sg(e),t);if(!Gh(t)){if(Wh(t)&&Fh(t)===e)return t;throw Kh(e)}let n=sg(e);if(Object.values(Xh).some(e=>n.prototype instanceof e))throw Kh(e);return Object.setPrototypeOf(t,n.prototype),t instanceof Error&&Qh(t),t}}function sg(e){let t=jh.get(e);if(!t)throw TypeError(`spindle: The save holds an instance of class \"${e}\", which is not registered`);return t}function cg(e){let t=Hh.get(e);if(t)return n=>{if(Object.getPrototypeOf(n)===t.prototype)return n;if(!Gh(n))throw TypeError(`spindle: Malformed data for \"${e}\"`);return Object.setPrototypeOf(n,t.prototype),Qh(n),n}}var lg=new WeakMap;function ug(e){if(!Array.isArray(e)||e.length%2!=0)throw TypeError(`spindle: Malformed object entries`);let t=lg.get(e);t||lg.set(e,t={});for(let n=0;n<e.length&&K(e,n);n+=2){let r=e[n];if(typeof r!=`string`||r===`__proto__`)throw TypeError(`spindle: Malformed object entries`);qh(t,r,K(e,n+1)?e[n+1]:void 0)}return t}var dg=new Proxy({},{getOwnPropertyDescriptor(e,t){let n=fg(t);return n&&{value:n,enumerable:!0,configurable:!0}},get:(e,t)=>fg(t)});function fg(e){if(typeof e==`string`){if(e===Rh)return e=>{if(!Array.isArray(e)||typeof e[0]!=`string`)throw TypeError(`spindle: Malformed symbol`);return Symbol.for(e[0])};if(e===zh)return ug;if(e===Bh)return e=>{let t=tg(e);if(!t)throw TypeError(`spindle: Malformed regular expression`);return t};if(e.startsWith(Ih))return og(e.slice(2));if(e.startsWith(Lh))return cg(e.slice(2))}}function pg(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`:Wh(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 mg(e){try{return gh(e,eg())}catch(t){throw pg(t,e)}}function hg(e){return mh(e,dg)}var gg=class extends Error{constructor(){super(`This save was made by an incompatible version of Spindle`),this.name=`IncompatibleSaveError`}},_g={};function vg(e){if(typeof e!=`number`||!Number.isInteger(e)||e<1||e>1)throw new gg}function yg(e,t){vg(e);let n=t;for(let t=e;t<1;t++){let e=_g[t];if(!e)throw new gg;n=e(n)}return n}var bg=e=>e&&new Map(Object.entries(e));function xg(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 Sg(e){try{return{formatVersion:1,data:mg({...e,visitCounts:bg(e.visitCounts),renderCounts:bg(e.renderCounts)})}}catch(e){throw xg(e)}}var Cg=()=>Error(`Invalid save data`);function wg(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function Tg(e){return e==null?!0:wg(e)&&typeof e.seed==`string`&&typeof e.pull==`number`&&Number.isInteger(e.pull)&&e.pull>=0}var Eg=e=>wg(e)&&typeof e.passage==`string`&&wg(e.variables)&&typeof e.timestamp==`number`&&Tg(e.prng),Dg=e=>e===void 0||Array.isArray(e)&&Array.from(e).every(e=>wg(e)&&typeof e.condition==`string`&&wg(e.options)),Og=e=>e===void 0||e instanceof Map&&[...e.keys()].every(e=>typeof e==`string`);function kg(e){if(!wg(e)||typeof e.passage!=`string`||!wg(e.variables))return!1;let{history:t,historyIndex:n}=e;return!Array.isArray(t)||t.length===0||!Array.from(t).every(Eg)||typeof n!=`number`||!Number.isInteger(n)||n<0||n>=t.length||t[n].passage!==e.passage?!1:Og(e.visitCounts)&&Og(e.renderCounts)&&Tg(e.prng)&&Dg(e.watchers)}var Ag=e=>e instanceof Map?ms(Object.fromEntries(e)):void 0;function jg(e){if(typeof e!=`object`||!e)throw Cg();let{formatVersion:t,data:n}=e;if(vg(t),typeof n!=`string`)throw Cg();let r=hg(yg(t,n));if(!kg(r))throw Cg();let i={...r,visitCounts:Ag(r.visitCounts),renderCounts:Ag(r.renderCounts)};return i.visitCounts===void 0&&delete i.visitCounts,i.renderCounts===void 0&&delete i.renderCounts,i}var Mg=`Invalid save file format`;function Ng(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Pg=[`id`,`passage`,`ifid`,`playthroughId`,`createdAt`,`updatedAt`,`title`];function Fg(e){let t=console.warn;console.warn=()=>{};try{jg(e)}finally{console.warn=t}}function Ig(e){if(!Ng(e))throw Error(Mg);if(!K(e,`formatVersion`))throw e.version===1?new gg:Error(Mg);if(vg(e.formatVersion),typeof e.ifid!=`string`)throw Error(Mg);let t=e.save;if(!Ng(t)||!Ng(t.meta))throw Error(Mg);let n=t.meta;if(Pg.some(e=>typeof n[e]!=`string`))throw Error(Mg);try{Fg(t.payload)}catch(e){throw e instanceof gg?e:Error(Mg)}}function Lg(e){try{return Ig(e),!0}catch{return!1}}function Rg(e){return JSON.stringify(e).length}function zg(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 Bg={autosave:`autosave.`,slot:`slot.`,slotIndex:`slotIndex.`,playthroughCount:`playthroughCount.`,currentPlaythrough:`currentPlaythroughId.`};function Vg(e,t){let{slot:n,...r}=Bg;return Object.values(r).some(n=>e===n+t)||e.startsWith(n)&&e.endsWith(`.${t}`)}function Hg(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=>Vg(t,e)),getAllMetaKeys:()=>r.keys(),destroy:i}}function Ug(){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 Hg(`memory`,zg(n),async()=>{for(let e of t)e.clear()})}var Wg={saves:`spindle.save.`,playthroughs:`spindle.pt.`,meta:`spindle.meta.`},Gg={\"saves.ifid\":`spindle.idx.saves.`,\"saves.playthroughId\":`spindle.idx.saves-pt.`,\"playthroughs.ifid\":`spindle.idx.pt.`};function Kg(e){let t=localStorage.getItem(e);if(t!==null)try{return JSON.parse(t)}catch{return}}function qg(e,t){localStorage.setItem(e,JSON.stringify(t))}function Jg(e){localStorage.removeItem(e)}function Yg(e){return Kg(e)??[]}function Xg(e,t){let n=Yg(e);n.includes(t)||(n.push(t),qg(e,n))}function Zg(e,t){let n=Yg(e).filter(e=>e!==t);n.length>0?qg(e,n):Jg(e)}var Qg=e=>Object.keys(localStorage).filter(t=>t.startsWith(e));function $g(){function e(e,t){let n=Wg[e],r=Object.entries(t).map(([t,n])=>({field:t,read:n,prefix:Gg[`${e}.${t}`]})),i=e=>r.map(t=>`${t.prefix}${t.read(e)}`);return{get:async e=>Kg(`${n}${e}`),async put(e,t){let r=Kg(`${n}${e}`),a=i(t);if(r!==void 0)for(let t of i(r))a.includes(t)||Zg(t,e);qg(`${n}${e}`,t);for(let t of a)Xg(t,e)},async delete(e){let t=Kg(`${n}${e}`);if(t!==void 0)for(let n of i(t))Zg(n,e);Jg(`${n}${e}`)},async find(e,t){let i=r.find(t=>t.field===e),a=[];for(let e of Yg(`${i.prefix}${t}`)){let t=Kg(`${n}${e}`);t!==void 0&&a.push(t)}return a},keys:async()=>Qg(n).map(e=>e.slice(n.length))}}return Hg(`localstorage`,zg(e),async()=>{for(let e of Qg(`spindle.`))Jg(e)})}var e_=`spindle`,t_=1,n_={saves:{keyPath:`meta.id`,indexes:{ifid:`meta.ifid`,playthroughId:`meta.playthroughId`}},playthroughs:{keyPath:`id`,indexes:{ifid:`ifid`}},meta:{keyPath:`key`,indexes:{}}};function r_(){let e=null;function t(){return e||(e=new Promise((t,n)=>{let r=indexedDB.open(e_,t_);r.onupgradeneeded=()=>{let e=r.result;for(let[t,{keyPath:n,indexes:r}]of Object.entries(n_)){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 Hg(`indexeddb`,zg(r),async()=>{(await t()).close(),e=null,await new Promise((e,t)=>{let n=indexedDB.deleteDatabase(e_);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 a_(){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)}),r_()}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 $g()}}catch{}return Ug()}var o_=null;function s_(){if(i_)return Promise.resolve(i_);if(!o_){let e=a_().then(t=>(o_===e&&(i_=t),t));o_=e}return o_}function c_(){i_=null,o_=null}function l_(){return i_?.type??`memory`}function u_(e,t){let n=e;for(let e of t){if(n==null||e in Object.prototype&&!K(Object(n),e))return;n=n[e]}return n}var d_=e=>e===`length`||/^(0|[1-9]\\d*)$/.test(e),f_=Ch;function p_(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 m_(e,t,n,r={}){let i=v_(e,t,r.createMissing??!1);i[t[t.length-1]]=n}function h_(e,t){let n=t[t.length-1];g_(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=v_(e,t,!1);if(Array.isArray(i)&&jt(i)&&t.length>1){let r=Ln(i).slice();delete r[Number(n)];let a=v_(e,t.slice(0,-1),!1);a[t[t.length-2]]=r;return}delete i[n]}function g_(e){if(e.includes(`__proto__`))throw TypeError(`spindle: Cannot use \"__proto__\" in a variable path (\"${e.join(`.`)}\")`)}function __(e,t,n,r){let i=f_(e)??(Array.isArray(e)&&!d_(t)?`an array`:``);if(i)throw TypeError(`spindle: Cannot set property \"${t}\" on ${i} (at \"${n.slice(0,r).join(`.`)}\")`)}function v_(e,t,n){g_(t);let r=jt(e),i=e;for(let e=0;e<t.length-1;e++){let a=t[e];__(i,a,t,e);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)&&!f_(o)&&(o=p_(o),i[a]=o);i=o}return __(i,t[t.length-1],t,t.length-1),i}function y_(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function b_(e,t,n,r){if(n(t),Fh(e)===void 0)return t;Object.setPrototypeOf(t,Object.getPrototypeOf(e));for(let n of Th(e))as(t,n,r(n));return t}var x_=[`message`,`cause`,`errors`];function S_(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))as(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(xh(e))return r(e,Object(e.valueOf()));if(bh(e))return e;if(e instanceof Error){let t=r(e,Object.create(Object.getPrototypeOf(e)));for(let n of[...x_,`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&&O_(e)&&O_(n)?r(e,n):e}let s=(e,t)=>b_(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 Eh(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 Dh(e))Set.prototype.add.call(t,o(c(n),n));return t}let u=a(l);if(u!==void 0)return u;let d=Fh(l)!==void 0||y_(e);return!d&&t.keepUnregistered?e:i(l,r(l,d?Object.create(Object.getPrototypeOf(l)):{}))}return c(e)}function C_(e,t){return P_(e,t,w_())}function w_(){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 T_(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 E_(e,t){return P_(e,t,T_())}function D_(e,t){if(!O_(e)||!O_(t))return t;let n=new Map,r=new Map,i=e=>O_(e)?S_(e,{keepUnregistered:!0,seen:n}):e;function a(e,t){let i=T_(r,n);if(P_(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(!O_(t))return t;let r=n.get(t);if(r!==void 0)return r;if(!O_(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=>b_(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 Eh(t))Map.prototype.set.call(n,i(r),o(kh(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(I_(e,t,!1)){let e=Object.create(Object.getPrototypeOf(t));n.set(t,e);for(let t of Object.keys(c))as(e,t,l(t));return e}return i(t)}return o(e,t)}var O_=e=>typeof e==`object`&&!!e;function k_(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 A_(e,t,n){if(e instanceof Date){let r=Date.prototype.getTime;return Object.is(r.call(e),r.call(t))&&N_(e,t,n)}if(e instanceof RegExp){let r=RegExp.prototype.toString;return r.call(e)===r.call(t)&&e.lastIndex===t.lastIndex&&N_(e,t,n)}if(ArrayBuffer.isView(e)){let r=t;return e.byteOffset===r.byteOffset&&e.byteLength===r.byteLength&&P_(e.buffer,r.buffer,n)}if(e instanceof ArrayBuffer)return k_(e,t);if(e instanceof URL||e instanceof URLSearchParams)return String(e)===String(t);if(xh(e))return Object.is(e.valueOf(),t.valueOf());if(bh(e))return String(e)===String(t);if(e instanceof Error)return x_.every(r=>K(e,r)===K(t,r)&&P_(e[r],t[r],n))&&j_(e,t,n)}function j_(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)||!P_(i[e],a[e],n))return!1;return!0}var M_=new Set([Array.prototype,Map.prototype,Set.prototype,Date.prototype,RegExp.prototype]);function N_(e,t,n){return M_.has(Object.getPrototypeOf(e))||j_(e,t,n,Th)}function P_(e,t,n){if(Object.is(e,t)&&!(n.strict&&O_(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(Oh(e)!==Oh(r))return!1;let i=e instanceof Map?Eh(e):Dh(e),a=r instanceof Map?Eh(r):Dh(r);for(let e=i.next(),t=a.next();!e.done;e=i.next(),t=a.next())if(!P_(e.value,t.value,n))return!1;return N_(e,t,n)}let i=A_(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||!P_(e[t],r[t],n))return!1;return N_(e,t,n)}return j_(e,t,n)}function F_(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&!Sh(e)}function I_(e,t,n){return n&&(Array.isArray(e)||Array.isArray(t))?Array.isArray(e)&&Array.isArray(t)&&Object.getPrototypeOf(e)===Object.getPrototypeOf(t):F_(e)&&F_(t)&&Object.getPrototypeOf(e)===Object.getPrototypeOf(t)}function L_(e,t,n){let r=[],i=(e,t,i)=>{Object.is(t,i)||(I_(t,i,n)?r.push({key:e,kind:`nested`,before:t,after:i}):C_(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 R_(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 L_(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 z_=e=>JSON.stringify(e);function B_(e,t){for(let n=1;n<=e.length;n++)if(t.has(z_(e.slice(0,n))))return!0;return!1}var V_=(e,t)=>`\\0${e}${t}`,H_=e=>e.startsWith(`\\0`);function U_(e){let t=[];if(e instanceof Map){let n=0;for(let[r,i]of Eh(e))t.push([V_(`k`,n),r],[V_(`v`,n),i]),n++}else if(e instanceof Set){let n=0;for(let r of Dh(e))t.push([V_(`s`,n++),r])}else if(e instanceof Error)for(let n of[`cause`,`errors`])K(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 W_(e,t){let n=e,r=0;for(let e=0;e<t.length;e++)if(H_(t[e])){if(n=u_(n,t.slice(r,e)),!O_(n))return;n=U_(n)?.find(([n])=>n===t[e])?.[1],r=e+1}return r===t.length?n:u_(n,t.slice(r))}function G_(e,t,n){let r=W_(e,t.slice(0,-1)),i=/^\\0v(\\d+)$/.exec(t[t.length-1]);if(!(r instanceof Map)||!i)return!1;let a=[...Eh(r)][Number(i[1])];return a?(Ah(r,a[0],n),!0):!1}function K_(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]),F_(e)||Array.isArray(e)?o(e,t):n&&U_(e)&&i.push([e,t])}function o(e,n){for(let r of Object.keys(e)){let i=e[r];if(!O_(i))continue;let o=[...n,r];t.has(z_(o))||a(i,o)}}o(e,[]);for(let[e,t]of i)for(let[n,r]of U_(e))O_(r)&&a(r,[...t,n]);return r}function q_(e,t,n){return new Map([...K_(e,t,n)].map(([e,t])=>[e,t[0]]))}function J_(e){return[...K_(e,void 0,!0).values()].filter(e=>e.length>1)}function Y_(e,t,n,r,i){let a=[],o=U_(e),s=U_(t);if(o&&s){if(Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;if(e instanceof Map||e instanceof Set){let n=Oh(t);if(Oh(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)])}else if((F_(e)||Array.isArray(e))&&I_(e,t,!0))for(let n of Object.keys(t))K(e,n)&&a.push([n,e[n],t[n]]);return a.some(([e,t,a])=>{if(!O_(t)||!O_(a))return!1;let o=[...n,e],s=i.get(a);return z_(r.get(t))!==z_(s)||z_(s)===z_(o)&&Y_(t,a,o,r,i)})}function X_(e,t){let n=q_(e,void 0,!0),r=q_(t,void 0,!0),i=[];return(function e(t,a,o){for(let s of Object.keys(a)){if(!K(t,s))continue;let c=t[s],l=a[s];if(!O_(c)||!O_(l))continue;let u=[...o,s],d=n.get(c),f=r.get(l),p=z_(u);z_(d)===z_(f)?z_(f)===p&&U_(c)&&Y_(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}),(F_(c)||Array.isArray(c))&&I_(c,l,!0)&&z_(f)===p&&z_(d)===p&&e(c,l,u)}})(e,t,[]),i}function Z_(e,t,n=!1){let r=R_(e,t,n),i=new Set(r.map(e=>z_(e.path))),a=[];for(let n of X_(e,t))B_(n.path,i)||(i.add(z_(n.path)),a.push(n));return[...a,...r]}function Q_(e,t){return q_(e,new Set(t.map(e=>z_(e.path))),!0)}function $_(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=W_(t,r);return O_(i)&&(Array.isArray(i)?Array.isArray(n):Object.getPrototypeOf(i)===Object.getPrototypeOf(n))?(super.set(n,i),!0):!1}}}function ev(e,t){let n=u_(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&&C_(n[r],t.value):t.deleted}function tv(e,t,n){t.some(H_)?G_(e,t,n):m_(e,t,n)}function nv(e,t){let n=e;t.deleted?h_(n,t.path):m_(n,t.path,t.value)}var rv=new Set([`storyinit`,`beforerestart`,`actionsChanged`,`variableChanged`,`beforesave`,`aftersave`,`beforeload`,`afterload`,`beforenavigate`,`afternavigate`,`passagerender`,`dialogrender`]),iv=new Map;function av(e,t){if(!rv.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 ov(e,t){let n=iv.get(e);if(n)for(let e of[...n])t(e)}function sv(e,...t){ov(e,e=>e(...t))}function cv(e,...t){ov(e,n=>{try{n(...t)}catch(t){console.error(`spindle: Error in ${e} handler:`,t)}})}var lv=null,uv=null;function dv(e){lv=e}function fv(e){uv=e}function pv(e){return zc(()=>mv(e))}function mv(e){if(uv)try{let t=Function(`passage`,`variables`,uv)(e.passage,e.variables);if(typeof t==`string`&&t.trim())return t.trim()}catch{}if(lv)try{let t=lv(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 hv=Promise.resolve();function gv(e){let t=hv.then(e);return hv=t.catch(()=>{}),t}function _v(e){return(...t)=>gv(()=>e(...t))}var vv=e=>_v(async t=>e(await(await s_()).getSave(t))),yv=e=>_v(async(t,n)=>e(await Zv(t,n))),bv=_v(xv);async function xv(e,t=yt()){let n=await s_();return await qv(`spindle-playthrough-count:${e}`,async()=>{let r=await wv(e),i={id:t,ifid:e,createdAt:new Date().toISOString(),label:`Playthrough ${r}`};await n.putPlaythrough(i),await n.setMeta(Cv(e),r)}),await n.setMeta(Tv(e),t),_y(e,t),t}var Sv=/^Playthrough (\\d+)$/;function Cv(e){return`${Bg.playthroughCount}${e}`}async function wv(e){let t=await s_(),n=await t.getMeta(Cv(e))??0;for(let r of await t.getPlaythroughsByIfid(e)){let e=Sv.exec(r.label);e&&(n=Math.max(n,Number(e[1])))}return n+1}function Tv(e){return`${Bg.currentPlaythrough}${e}`}var Ev=_v(Dv);async function Dv(e,t){let n=await s_();await Ov(e,t,new Date().toISOString());let r=Tv(e);await n.getMeta(r)!==t&&await n.setMeta(r,t),_y(e,t)}async function Ov(e,t,n){let r=await s_();(await r.getPlaythroughsByIfid(e)).some(e=>e.id===t)||await r.putPlaythrough({id:t,ifid:e,createdAt:n,label:`Imported`})}function kv(e){return gv(async()=>{let t=await s_(),n=vy(e),r=n!==void 0&&(await t.getPlaythroughsByIfid(e)).some(e=>e.id===n)?n:await t.getMeta(Tv(e))??await xv(e);return _y(e,r),{id:r,knownSaves:await sy(e)}})}function Av(e,t,n,r){try{let i=n();return zc(()=>sv(`beforesave`,e,t)),r(i()).then(t=>(zc(()=>sv(`aftersave`,e)),t))}catch(e){return Promise.reject(e)}}function jv(e,t){let n=Sg(t);return{meta:{...e,estimatedBytes:Rg(n)},payload:n}}var Mv=_v(Nv);async function Nv(e,t,n,r={}){let i=await t;if(!i)throw Error(`No playthrough`);let a=new Date().toISOString(),o=jv({id:yt(),ifid:e,playthroughId:i,createdAt:a,updatedAt:a,title:pv(n),passage:n.passage,custom:r},n);return await(await s_()).putSave(o),o}var Pv=_v(Fv);async function Fv(e,t,n,r){let i=await r,a=await s_(),o=await a.getSave(e);if(!o)return;let s=jv({...o.meta,...i?{playthroughId:i}:{},updatedAt:new Date().toISOString(),title:o.meta.userTitle===!0?o.meta.title:pv(t),passage:t.passage,...n==null?{}:{custom:{...o.meta.custom,...n}}},t);return await a.putSave(s),s}var Iv=e=>e&&jg(e.payload),Lv=e=>jg(e);vv(Iv);function Rv(e){return gv(async()=>{let t=await s_(),n=await t.getSave(e);await t.deleteSave(e),n&&await ey(n.meta.ifid,t=>t===e)})}function zv(e,t){return gv(async()=>{let n=await s_(),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 Bv=_v(async function(e){let t=await s_(),[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}),Vv=Bg.autosave,Hv=Bg.slot,Uv=Bg.slotIndex;function Wv(e){return e!=null&&e!==``}function Gv(e,t){return Wv(t)?`${Hv}${t}.${e}`:`${Vv}${e}`}var Kv=e=>`${Uv}${e}`;async function qv(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 Jv(e,t){let n=await s_();await qv(`spindle-slot-index:${e}`,async()=>{let r=await n.getMeta(Kv(e))??[],i=t(r);i!==r&&await n.setMeta(Kv(e),i)})}async function Yv(e){return[void 0,...(await(await s_()).getMeta(Kv(e))??[]).filter(Wv)]}async function Xv(e,t){return(await s_()).getMeta(Gv(e,t))}async function Zv(e,t){let n=await Xv(e,t);return n?(await s_()).getSave(n):void 0}async function Qv(e,t,n){await(await s_()).setMeta(Gv(e,t),n),Wv(t)&&await Jv(e,e=>e.includes(t)?e:[...e,t])}async function $v(e,t){await(await s_()).deleteMeta(Gv(e,t)),Wv(t)&&await Jv(e,e=>e.filter(e=>e!==t))}async function ey(e,t){for(let n of await Yv(e)){let r=await Xv(e,n);r&&t(r)&&await $v(e,n)}}var ty=e=>({isAutosave:!Wv(e),...Wv(e)?{slot:e}:{}});function ny(e,t){return{slot:Wv(t)?t:``,title:e.meta.title,passage:e.meta.passage,createdAt:e.meta.createdAt,updatedAt:e.meta.updatedAt,custom:e.meta.custom??{}}}function ry(e,t,n,r,i){return gv(async()=>{let a=await t,o=await Xv(e,r);if(o){let e=await Fv(o,n,i,a);if(e)return e}let s=await Nv(e,a,n,{...ty(r),...i});return await Qv(e,r,s.meta.id),s})}async function iy(e,t){return await Zv(e,t)!==void 0}yv(Iv);function ay(e,t,n){return gv(async()=>{let r=await Zv(e,t);if(!r)return;let i=jg(r.payload);n?.(i);let{playthroughId:a}=r.meta;return a&&await Dv(e,a),{payload:i,playthroughId:a}})}var oy=_v(sy);async function sy(e){let t=Object.create(null);for(let n of await Yv(e))await iy(e,n)&&(t[n??``]=!0);return t}var cy=_v(ly);async function ly(e,t){let n=await Zv(e,t);return n?ny(n,t):null}var uy=_v(async e=>{let t=[];for(let n of await Yv(e)){let r=await ly(e,n);r&&t.push(r)}return t}),dy=_v(async(e,t)=>{let n=await Xv(e,t);n&&(await(await s_()).deleteSave(n),await $v(e,t))}),fy=`spindle.session.`;function py(e,t){let n=JSON.stringify(Sg(t));try{sessionStorage.setItem(`${fy}${e}`,n)}catch(e){return{error:e}}}function my(e){try{let t=sessionStorage.getItem(`${fy}${e}`);return t?jg(JSON.parse(t)):void 0}catch(t){t instanceof gg&&(console.warn(`spindle: ${t.message}; the session was not restored.`),hy(e));return}}function hy(e){try{sessionStorage.removeItem(`${fy}${e}`)}catch{}}var gy=`${fy}playthrough.`;function _y(e,t){try{sessionStorage.setItem(`${gy}${e}`,t)}catch{}}function vy(e){try{return sessionStorage.getItem(`${gy}${e}`)||void 0}catch{return}}function yy(e){if(e)return{formatVersion:1,ifid:e.meta.ifid,exportedAt:new Date().toISOString(),save:e}}var by=vv(yy);async function xy(e,t){if(Ig(e),e.ifid!==t)throw Error(`Save is from a different story (expected IFID ${t}, got ${e.ifid})`);let n=S_(e.save);return n.meta.id=yt(),n.meta.updatedAt=new Date().toISOString(),n.meta.ifid=t,await Ov(t,n.meta.playthroughId,n.meta.createdAt),n}function Sy(e,t){return gv(async()=>{let n=await xy(e,t);return await(await s_()).putSave(n),n})}var Cy=yv(yy);function wy(e,t,n){return gv(async()=>{let r=await xy(e,t),{slot:i,...a}=r.meta.custom??{};r.meta.custom={...a,...ty(n)};let o=await s_(),s=await Xv(t,n);return await o.putSave(r),await Qv(t,n,r.meta.id),s&&await o.deleteSave(s),ny(r,n)})}var Ty=_v(async function(e){let t=await s_(),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=Rg(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 Ey(e){return gv(async()=>{let t=await s_();await t.deleteSavesByIfid(e),await t.deletePlaythroughsByIfid(e),await t.deleteMetaByIfid(e),hy(e)})}var Dy=_v(Oy);async function Oy(){await(await s_()).destroy(),c_();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{}}function ky(e,t,n){return gv(async()=>{let r=await s_(),i=await r.deleteSavesByPlaythrough(t);await r.deletePlaythroughById(t);let a=new Set(i);if(await ey(e,e=>a.has(e)),n&&await n.current===t)return await xv(e,n.id),!0;let o=Tv(e);return await r.getMeta(o)===t&&await r.deleteMeta(o),!1})}var Ay=null;function jy(){Ay&&(he(null,Ay),Ay.remove(),Ay=null)}function My(){jy();let e=Q.getState();if(!e.storyData)return;let t=e.storyData.passages.get(`StoryInit`);if(t){let e=Zo(t.content);vc(e,`StoryInit`);let n=document.createElement(`div`);n.style.display=`none`,document.body.appendChild(n),Ay=n,he(b(()=>Em(e),null),n),mx()}let n=e.storyData.passages.get(`SaveTitle`);n&&fv(n.content)}function Ny(e){My();let t=e?Vx(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),sv(`storyinit`),e||mx()}var Py=[`variables`,`temporary`,`transient`],Fy=[];function Iy(){return Fy[Fy.length-1]?.work}function Ly(){let e=Q.getState(),t=Iy();return t?{...e,...t}:e}var Ry=e=>S_(e,{keepUnregistered:!0});function zy(e,t){let n=t?$_(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(H_)||m_(e,a,o),n.set(i,o),o};return e=>S_(e,{keepUnregistered:!0,seen:n,settle:r})}var By=e=>{let t=new Map;return n=>{let r=t.get(n);return r||(r=zy(n,e?.(n)),t.set(n,r)),r}};function Vy(e){return en(Ry(e),!0)}function Hy(e,t=new Set){if(typeof e!=`object`||!e||t.has(e)||ArrayBuffer.isView(e)||e instanceof ArrayBuffer)return!0;if(!Object.isFrozen(e))return!1;if(t.add(e),e instanceof Map){for(let[n,r]of Eh(e))if(!Hy(n,t)||!Hy(r,t))return!1}else if(e instanceof Set){for(let n of Dh(e))if(!Hy(n,t))return!1}return Reflect.ownKeys(e).every(n=>{let r=Object.getOwnPropertyDescriptor(e,n);return!r||!(`value`in r)||Hy(r.value,t)})}function Uy(e){return Hy(e)?e:Vy(e)}function Wy(e,t,n=Fy,r=Gy){let[i,a]=t.path;for(let o of n)for(let n of[o.work,o.base])try{nv(n,t.deleted?t:{...t,value:r(n)(t.value)})}catch{let t=e[i][a];K(e[i],a)?n[i][a]=Ry(jt(t)?Ln(t):t):delete n[i][a]}}var Gy=e=>zy(e),Ky=new Set(Py),qy=new Fn({autoFreeze:!1}),Jy=!1;function Yy(e,t){let n=[],r=e;for(let e of t){if(!F_(r))break;let t=String(e);n.push(t),r=K(r,t)?r[t]:void 0}return n}function Xy(e,t){let n=u_(e,t.slice(0,-1)),r=t[t.length-1];return F_(n)&&K(n,r)?{path:t,deleted:!1,value:n[r]}:{path:t,deleted:!0}}function Zy(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=>Xy(t,[e]));let r=new Set,i=[];for(let e of n){let n=Yy(t,e.path.slice(1)),a=JSON.stringify(n);r.has(a)||(r.add(a),i.push(Xy(t,n)))}return i}function Qy(e){if(Jy){Jy=!1;return}if(Fy.length===0)return;nb(ib());let t=Fy[Fy.length-1],n={...Q.getState(),variables:t.work.variables,temporary:t.work.temporary,transient:t.work.transient},[r,i]=qy.produceWithPatches(n,e),a=Py.flatMap(e=>{let t=i.filter(t=>t.path[0]===e);return t.length?Zy(n[e],r[e],t).map(t=>({...t,path:[e,...t.path]})):[]}),o=Q_(tb(t.work),a),s=By(()=>o),c=(e,t)=>e.deleted?e:{...e,value:s(t)(e.value)};for(let e of a)nv(t.work,c(e,t.work));return e=>{let i=e;for(let e of Object.keys(r)){let t=r[e];!Ky.has(e)&&t!==n[e]&&(i[e]=t)}let o=e;for(let e of a){let[n,r]=e.path;try{nv(o,c(e,o))}catch{K(t.work[n],r)?o[n][r]=Ry(t.work[n][r]):delete o[n][r]}Wy(o,e,Fy,s)}}}function $y(e,t,n){let r=n.map(e=>z_(e.path).slice(0,-1));for(let[n,...i]of J_(t)){let t=[n,...i].map(e=>z_(e).slice(0,-1));if(r.some(e=>t.some(t=>e.startsWith(t))))try{let t=W_(e,n);if(typeof t!=`object`||!t)continue;for(let n of i)tv(e,n,t)}catch{}}}function eb(e){let t=new Map;return{variables:S_(e.variables,{keepUnregistered:!0,seen:t}),temporary:S_(e.temporary,{keepUnregistered:!0,seen:t}),transient:S_(e.transient,{keepUnregistered:!0,seen:t})}}var tb=e=>({variables:e.variables,temporary:e.temporary,transient:e.transient});function nb(e){let t=e.map(({scope:e,keepRunning:t})=>({scope:e,keepRunning:t,changes:rb(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=eb(e.work));Jy=!0;try{Q.getState().updateVariables(r)}finally{Jy=!1}function r(e){t.forEach(({scope:n,changes:r},i)=>{let a=Q_(n.work,r),o=zy(e,a),s=t.slice(0,i).map(e=>e.scope),c=By(()=>a),l=new Set;for(let t of r){let[r,i]=t.path,a=z_([r,i]);if(!l.has(a))try{if(t.deleted){ev(e,t)||nv(e,t);continue}let n=t.alias?o(t.value):void 0;if(t.alias?Object.is(u_(e,t.path),n):ev(e,t))continue;nv(e,{...t,value:t.alias?n:o(t.value)})}catch{e[r][i]=o(n.work[r][i]),l.add(a)}}$y(e,n.work,r);for(let t of r)Wy(e,t,s,c)})}}var rb=(e,t)=>Z_(e,t),ib=()=>Fy.map(e=>({scope:e,keepRunning:!0}));function ab(e){let t=Q.getState(),n=tb(t),r=Z_(e.base,n),i=zy(e.work,Q_(n,r));for(let t of r)try{nv(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=eb(t)}function ob(e){if(Fy.length===0)return e();nb(ib());let t=Fy.splice(0);try{return e()}finally{Fy.push(...t);for(let e of t)ab(e)}}function sb(e){nb(ib());let t=Q_(tb(Iy()??Q.getState()),[]),n=cb(),r=zy(n.work,t);try{e(n.work,r)}finally{Fy.pop()}nb([...ib(),{scope:n,keepRunning:!1}])}function cb(){let e=Iy()??Q.getState(),t={work:eb(e),base:eb(e)};return Fy.push(t),t}function lb(e,t,n){let r=cs(S_(t,{keepUnregistered:!0})),i=cb();try{ul(e,i.work.variables,i.work.temporary,r,i.work.transient)}finally{Fy.pop()}nb([...ib(),{scope:i,keepRunning:!1}]);let a=new Set(Z_(t,r,!0).map(e=>e.path[0]));for(let e of J_(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 ub=[],db=!1,fb=[],pb=null,mb=null;function hb(e){let t=Ly();try{return!!ll(e,t.variables,t.temporary,{},t.transient)}catch{return!1}}function gb(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:hb(e),priority:i?.priority??0,macroKey:n};return ub.push(o),ub.sort((e,t)=>t.priority-e.priority),()=>{ub=ub.filter(e=>e!==o)}}function _b(e,t){return gb(e,t)}function vb(e,t){let n=Object.fromEntries(Object.entries(t).sort(([e],[t])=>e<t?-1:1)),r=JSON.stringify([e,n]);ub.some(e=>e.macroKey===r)||gb(e,t,r)}function yb(){return ub.filter(e=>e.macroKey!==void 0&&e.options).map(e=>({condition:e.condition,options:{...e.options}}))}function bb(e){ub=ub.filter(e=>e.macroKey===void 0);for(let{condition:t,options:n}of e)vb(t,n)}function xb(e){ub=ub.filter(t=>t.name!==e)}function Sb(e){let{callback:t,options:n}=e;if(t){t();return}if(n){if(n.run)try{lb(n.run,{},()=>{})}catch(t){console.error(`spindle: Error in watch run action for \"${e.condition}\":`,t)}n.dialog&&(fb.push({passageName:n.dialog}),pb?.()),n.goto&&Q.getState().navigate(n.goto)}}var Cb=10;function wb(){for(let e=0;e<Cb;e++){let e=!1,t=[...ub];for(let n of t){if(!ub.includes(n))continue;let t=hb(n.condition),r=!n.lastResult;n.lastResult=t,t&&r&&(e=!0,n.options?.once&&(ub=ub.filter(e=>e!==n)),Sb(n))}if(!e)break}}function Tb(){if(!db){db=!0;try{wb()}finally{db=!1}}}var Eb=0;function Db(){if(Eb===0)return;let e=db;db=!0;try{wb()}finally{db=e}}function Ob(){let e=Q.getState();Eb++;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||Tb())}),n=!0;return()=>{n&&(n=!1,Eb--,t())}}function kb(){for(let e of ub)e.lastResult=hb(e.condition)}function Ab(){ub=[],Bb()}function jb(e){return pb=e,fb.length>0&&e(),()=>{pb===e&&(pb=null)}}function Mb(){return fb.shift()}function Nb(){return fb.length}function Pb(e){mb?mb.push(e):(fb.push(e),pb?.())}function Fb(){fb=[]}function Ib(e){return mb=e,()=>{mb===e&&(mb=null)}}var Lb=[];function Rb(e){return Lb.push(e),()=>{let t=Lb.lastIndexOf(e);t>=0&&Lb.splice(t,1)}}function zb(){let e=Lb[Lb.length-1];e?e():mb?.close()}function Bb(){Fb();for(let e of[...Lb].reverse())e();mb?.closeAll()}function Vb(){return Lb.length>0||(mb?.isOpen()??!1)}zn(),Bn();var Hb=new Set([`StoryInit`,`StoryInterface`,`StoryVariables`,`StoryTransients`,`StoryLoading`,`SaveTitle`,`PassageReady`,`PassageHeader`,`PassageFooter`,`PassageDone`]),Ub=q(),Wb=[],Gb=q();function Kb(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:S_(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(S_(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 qb(e,t){let n=Object.create(Object.getPrototypeOf(e));for(let t of Object.keys(e))as(n,t,e[t]);for(let e of t)e.deleted?delete n[e.key]:as(n,e.key,e.value);return n}function Jb(e){let t=Wb.length-1;t<0?Ub=e:Wb[t]=Kb(Zb(t),e)}function Yb(e,t){let n=Ub;for(let r=0;r<e;r++)r>0&&(n=qb(n,Wb[r-1].forward)),t(n,r)}function Xb(e,t){return{passage:e.passage,variables:t,timestamp:e.timestamp,prng:e.prng}}function Zb(e){let t=Ub;for(let n=0;n<e;n++)t=qb(t,Wb[n].forward);return t}var Qb=[];function $b(e){let{storyData:t,currentPassage:n,variables:r,history:i,historyIndex:a,visitCounts:o,renderCounts:s}=e();if(t){if(Qb.length>i.length&&(Qb.length=i.length),Qb.length<i.length)if(i.length-Qb.length===1){let e=i.length-1;Qb[e]=Xb(i[e],r)}else Yb(i.length,(e,t)=>{t>=Qb.length&&(Qb[t]=Xb(i[t],e))});return py(t.ifid,{passage:n,variables:r,history:Qb,historyIndex:a,visitCounts:o,renderCounts:s,prng:Bc(),watchers:yb()})}}var ex=`The game could not be saved for a page reload; a reload goes back to the last passage it could save:`,tx=`The story could not go to another passage:`;function nx(e,t){let n;try{let t=$b(e);t&&Ts(ex,t.error)}catch(e){n={error:e},Ts(ex,e)}try{t?.()}finally{if(n)throw n.error}}function rx(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++)Ub=qb(Ub,Wb[e].forward);return e.history=e.history.slice(n,r),Wb=Wb.slice(n,r-1),Qb=Qb.slice(n,r),e.historyIndex-=n,!0}var ix=!1,ax=[],ox=null;function sx(e,t){let n=ox;if(ox=null,!n||e().navigationId!==n.navigationId)return;e().variables!==n.variables&&Jb(e().variables),Gb=e().variables;let r=Bc(),i=e().history[e().historyIndex].prng;(r?.seed!==i?.seed||r?.pull!==i?.pull)&&t(e=>{e.history[e.historyIndex].prng=r})}var cx=e=>({...e});function lx(e){Ub=e,Wb=[],Gb=e,Qb=[]}function ux(e){let t=q(S_(e));return lx(S_(t)),t}function dx(e){return q(S_(e,{keepUnregistered:!0}))}function fx(e,t,n,r){e.currentPassage=t,e.navigationId++,e.variables=n,e.transient=dx(r),e.temporary=q(),e.history=[{passage:t,timestamp:Date.now()}],e.historyIndex=0}function px(e,t,n){let{historyIndex:r,history:i}=e(),a=r+n;if(a<0||a>=i.length)return;sx(e,t);let o=e().currentPassage,s=i[a].passage;sv(`beforenavigate`,s);let c=S_(Zb(a));t(e=>{e.historyIndex+=n,e.currentPassage=e.history[e.historyIndex].passage,e.navigationId++,e.variables=c,e.temporary=q()}),kb(),Gb=e().variables,Bx(e().history[e().historyIndex]),nx(e,()=>sv(`afternavigate`,s,o))}function mx(){let{history:e,historyIndex:t,variables:n}=Q.getState();if(e.length!==1||t!==0)return;lx(n);let r=Bc();Q.setState(e=>{e.history[0].prng=r})}var hx=Promise.resolve(``),gx=0,_x=!1;function vx(){return _x?``:Q.getState().playthroughId}function yx(){let e=vx();return hx.then(t=>e||t)}function bx(e){Q.getState().playthroughId!==e&&Q.setState(t=>{t.playthroughId=e})}function xx(e){let t=++gx;return _x=!0,hx=e.then(e=>(t===gx&&(_x=!1,bx(e)),e)),hx}function Sx(e,t){++gx,_x=!1,hx=t.then(()=>e,()=>e),bx(e)}function Cx(e){let t=yt();Sx(t,bv(e,t).catch(e=>{console.error(`spindle: failed to start new playthrough`,e)}))}function wx(e,t){vx()!==t&&Sx(t,Ev(e,t).catch(e=>{console.error(`spindle: failed to switch to the loaded playthrough`,e)}))}var Tx=0,Ex=0,Dx=null;function Ox(){Ex=++Tx}var kx=[],Ax=!1;function jx(e){Ax&&kx.push(e)}function Mx(){Ax=!0}function Nx(){for(let e of kx)e();kx=[],Ax=!1}function Px(e){return typeof e==`string`&&e!==``?e:null}function Fx(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 Ix(e,t,n){let r=e.history[e.historyIndex];if(!r)return;let i=Z_(t,n,!0);if(i.length===0)return;let a=S_(r.variables),o=$_(Q_(n,i),a),s=e=>S_(e,{seen:o});for(let e of i)Lx(a,n,e,s);r.variables=D_(r.variables,a)}function Lx(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=u_(t,i.slice(0,o+1));if(!I_(n,s,!0)){Rx(a,e,r(s));return}a=n}let s=i[o];n.deleted?Rx(a,s,void 0,n):Rx(a,s,r(n.value),n)}function Rx(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]:as(e,t,n)}function zx(e){e?Ic(e.seed,e.pull):Rc()}function Bx(e){e&&zx(e.prng)}function Vx(e,t){if(e)return[t.passage,...t.history.map(e=>e.passage)].find(t=>!e.passages.has(t))}function Hx(e,t){let n=Vx(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 Ux=[`variables`,`temporary`,`transient`];function Wx(e){for(let t of Ux){let n=e[t];ss(n)||(e[t]=q(jt(n)?Ln(n):n))}}var Gx=[`navigate`,`goBack`,`goForward`,`restart`,`save`,`load`,`getSavePayload`,`loadFromPayload`];function Kx(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=Qy(r);t(e=>{(i??r)(e),Wx(e)})});r.setState=i;let a=e(i,n,r);for(let e of Gx){let t=a[e];a[e]=(...e)=>ob(()=>t(...e))}return a}}var qx=e=>Hn(Kx(e));function Jx(e){return e.catch(()=>{}),e}function Yx(e,t,n){return Jx(e.catch(e=>{throw console.error(t,e),n?.(e),e}))}function Xx(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 Zx(e,t,n,r){let i=n.then(()=>{t(e=>{e.knownSaves={}})});return e().restart(),Yx(i,r)}var Q=vt()(qx((e,t)=>({storyData:null,currentPassage:``,navigationId:0,variables:q(),variableDefaults:{},transient:q(),transientDefaults:{},temporary:q(),history:[],historyIndex:-1,visitCounts:ms(),renderCounts:ms(),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=rx(e)}),r&&nx(t)},setQuickSaveKey:t=>{e(e=>{e.quickSaveKey=Px(t)})},setQuickLoadKey:t=>{e(e=>{e.quickLoadKey=Px(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=ux(r);e(e=>{e.storyData=n,e.playthroughId=``,e.variableDefaults=r,e.transientDefaults=i,fx(e,a.name,o,i),e.visitCounts=ms(null,a.name),e.renderCounts=ms(null,a.name)}),Gb=t().variables,Ox(),xx(kv(n.ifid).then(({id:t,knownSaves:n})=>(e(e=>{e.knownSaves=n}),t)).catch(e=>(console.error(`spindle: failed to init save system`,e),``)))},navigate:n=>{if(ix){ax.push(n);return}let{storyData:r}=t();if(!r)return;if(Hb.has(n)){console.error(`spindle: Cannot navigate to special passage \"${n}\".`);return}if(!r.passages.has(n)){let e=Es(n,t().currentPassage);console.error(`spindle: ${e.message}`),Ts(tx,e);return}let i=t().currentPassage;sv(`beforenavigate`,n);let a=Kb(Gb,t().variables);e(e=>{e.temporary=q(),e.currentPassage=n,e.navigationId++,e.history=e.history.slice(0,e.historyIndex+1),Wb.length=e.historyIndex,Qb.length>e.historyIndex+1&&(Qb.length=e.historyIndex+1),Wb.push(a),e.history.push({passage:n,timestamp:Date.now(),prng:Bc()}),e.historyIndex=e.history.length-1,rx(e),e.visitCounts=ms(e.visitCounts,n),e.renderCounts=ms(e.renderCounts,n)}),ox={navigationId:t().navigationId,variables:t().variables},ix=!0;try{Db()}finally{ix=!1}let o=ax;ax=[],sx(t,e),nx(t,()=>{sv(`afternavigate`,n,i);for(let e of o)t().navigate(e)})},goBack:()=>px(t,e,-1),goForward:()=>px(t,e,1),setVariable:(t,n)=>{e(e=>{rs(t,`$${t}`),e.variables[t]=n})},setTemporary:(t,n)=>{e(e=>{rs(t,`_${t}`),e.temporary[t]=n})},deleteVariable:t=>{e(e=>{rs(t,`$${t}`),delete e.variables[t]})},deleteTemporary:t=>{e(e=>{rs(t,`_${t}`),delete e.temporary[t]})},setTransient:(t,n)=>{e(e=>{rs(t,`%${t}`),e.transient[t]=n})},deleteTransient:t=>{e(e=>{rs(t,`%${t}`),delete e.transient[t]})},updateVariables:t=>{e(e=>{t(e)})},trackRender:t=>{e(e=>{e.renderCounts=ms(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}),sv(`beforerestart`),Cx(n.ifid),Ox();let o=t().renderDeferred;Nx(),Rc(),Ab();let s=ux(r);e(e=>{fx(e,a.name,s,i),e.visitCounts=ms(null,a.name),e.renderCounts=ms(null,a.name),o||(e.renderDeferred=!1)}),Gb=t().variables,Mx(),My(),hy(n.ifid),sv(`storyinit`),mx()},save:(n,r)=>{let{storyData:i}=t();if(!i)return Promise.resolve();let a=yx();return Yx(Av(n,r,t().beginSave,async t=>{e(e=>{e.saveError=null}),await ry(i.ifid,a,t,n,r),Xx(e,n,!0)}),`spindle: failed to save`,t=>e(e=>{e.saveError=ys(t,`Failed to save`)}))},load:n=>{let{storyData:r}=t();if(!r)return Promise.resolve();e(e=>{e.loadError=null});let i=yx(),a=ay(r.ifid,n,e=>Hx(r,e)),o=xx(Promise.all([i,a.catch(()=>void 0)]).then(([e,t])=>t?.playthroughId||e)),s=++Tx;return Yx(a.then(async e=>{await o,e&&(Ex>s||(Dx=s,t().loadFromPayload(e.payload,n)))}),`spindle: failed to load save`,t=>e(e=>{e.loadError=ys(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?cy(n.ifid,e):null},listSaves:async()=>{let{storyData:e}=t();return e?uy(e.ifid):[]},deleteSave:n=>{let{storyData:r}=t();return r?Yx(dy(r.ifid,n).then(()=>Xx(e,n,!1)),`spindle: failed to delete save`):Promise.resolve()},exportSave:async e=>{let{storyData:n}=t();return n?await Cy(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 wy(n,i.ifid,r);return Xx(e,r,!0),a},clearGameData:()=>{let{storyData:n}=t();return n?Zx(t,e,Ey(n.ifid),`spindle: failed to clear game data`):Promise.resolve()},clearAllData:()=>Zx(t,e,Dy(),`spindle: failed to clear all data`),deletePlaythrough:n=>{let{storyData:r}=t();if(!r)return Promise.resolve();let i=r.ifid,a=vx(),o=hx,s=yt(),c=ky(i,n,{current:a||o,id:s});return n!==``&&n===a?Sx(s,c):a===``&&xx(c.then(e=>e?s:o,()=>o)),Yx(c.then(async()=>{let t=await oy(r.ifid);e(e=>{e.knownSaves=t})}),`spindle: failed to delete playthrough`)},getSavePayload:()=>{let{currentPassage:e,variables:n,history:r,historyIndex:i,visitCounts:a,renderCounts:o}=t(),s=[];return Yb(r.length,(e,t)=>{let n=cx(e);s.push(Xb(r[t],t===0?n:D_(s[t-1].variables,n)))}),{passage:e,variables:D_(s[i]?.variables,cx(n)),history:s,historyIndex:i,visitCounts:{...a},renderCounts:{...o},prng:Bc(),watchers:yb()}},beginSave:()=>{let e=t().variables;return()=>{let n=t().getSavePayload();return Ix(n,e,t().variables),n}},loadFromPayload:(n,r,i)=>{let a=Dx;Dx=null;let o=a??++Tx;if(n.history.length===0){console.warn(`loadFromPayload: rejecting payload with empty history`);return}Hx(t().storyData,n),Ex=o,sv(`beforeload`,r);let s=t().storyData?.ifid;i&&s&&wx(s,i);let c=Fx(n),l=S_(n.history.map(e=>e.variables)).map(e=>q(e));Ub=S_(l[0]),Wb=l.slice(1).map((e,t)=>Kb(l[t],e)),Qb=n.history.map((e,t)=>Xb(e,l[t])),e(e=>{e.currentPassage=n.passage,e.navigationId++,e.variables=q(S_(c?.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)),rx(e),e.visitCounts=ms(n.visitCounts),e.renderCounts=ms(n.renderCounts),e.temporary=q(),e.transient=dx(t().transientDefaults)}),n.watchers&&bb(n.watchers),kb(),Gb=Zb(t().historyIndex),zx(c?.prng===void 0?n.prng:c.prng),nx(t,()=>zc(()=>sv(`afterload`,r)))},getHistoryVariables:e=>S_(Zb(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})}}))),Qx=`<header class=\"story-menubar\">{story-title}{back}{forward}{restart}{quicksave}{quickload}{saves}{settings}</header>\n{passage}`;function $x(){let{storyData:e}=Tc(`storyData`),t=e?.passages.get(`StoryInterface`),n=t===void 0?Qx:t.content,r=t?.tags.includes(`nobr`)??!1,i=Ne(()=>{try{return J(S,{children:vm(Zo(n))})}catch(e){return J(`span`,{class:`error`,children:[`Error in StoryInterface: `,ys(e)]})}},[n]);return r?J(wp.Provider,{value:!0,children:i}):i}var eS=[`a[href]`,`area[href]`,`button:not([disabled])`,`input:not([disabled]):not([type=\"hidden\"])`,`select:not([disabled])`,`textarea:not([disabled])`,`iframe`,`summary`,`[contenteditable]`,`[tabindex]`].join(`,`);function tS(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 nS(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!tS(e)}function rS(e){return!e.hidden&&!e.closest(`[hidden], [inert]`)&&!e.matches(`:disabled`)&&nS(e)}function iS(e){let t=e.getAttribute(`tabindex`);return t===null||!/^\\s*[+-]?\\d+\\s*$/.test(t)?null:parseInt(t,10)}function aS(e){let t=iS(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&&(iS(t)??0)>=0&&rS(t));return e===(t.find(e=>e.checked)??t[0])}return!0}function oS(e){let t=Array.from(e.querySelectorAll(eS)).filter(e=>rS(e)&&aS(e)),n=e=>Math.max(iS(e)??0,0);return[...t.filter(e=>n(e)>0).sort((e,t)=>n(e)-n(t)),...t.filter(e=>n(e)===0)]}var sS=[];function cS(e,t,n,r){Me(()=>{let n=e.current;if(!n)return;let r=document.activeElement instanceof HTMLElement?document.activeElement:null,i={panel:n};sS.push(i);let a=n.querySelector(t)??n;return(n.querySelector(`[autofocus]`)??oS(a)[0]??n).focus(),()=>{let e=sS.indexOf(i);e!==-1&&sS.splice(e,1);let t=document.activeElement;(!t||t===document.body||n.contains(t))&&r?.isConnected&&r.focus()}},[]),Me(()=>{let t=e.current;if(!t)return;let i=e=>{if(sS[sS.length-1]?.panel!==t)return;if(e.key===`Escape`){if(!n)return;e.preventDefault(),e.stopPropagation(),r();return}if(e.key!==`Tab`)return;let i=oS(t),a=i[0],o=i[i.length-1],s=document.activeElement,c=s!==t&&t.contains(s);!a||!o?(e.preventDefault(),t.focus()):e.shiftKey&&(s===a||!c)?(e.preventDefault(),o.focus()):!e.shiftKey&&(s===o||!c)&&(e.preventDefault(),a.focus())};return document.addEventListener(`keydown`,i),()=>document.removeEventListener(`keydown`,i)},[n,r])}var lS=ge(null);function uS({passageName:e,fallbackMarkup:t,panelClass:n,onClose:r,dismissible:i=!0,showCloseButton:a=i}){let o=M(r);o.current=r;let s=Pe(()=>o.current(),[]),{storyData:c}=Tc(`storyData`),l=e?c?.passages.get(e):void 0,u=l?.content??t,d=l?.tags.includes(`nobr`)??!1,f=Ne(()=>{if(!u)return J(`div`,{class:`error`,children:`Dialog: no content available`});try{let e=Em(Zo(u),d?{nobr:!0}:void 0);return d?J(wp.Provider,{value:!0,children:e}):e}catch(e){return J(`div`,{class:`error`,children:[`Error in dialog: `,ys(e)]})}},[u,d]),p=M(null),m=kp();cS(p,`.dialog-body`,i,s),Me(()=>Rb(s),[s]),Me(()=>{p.current&&cv(`dialogrender`,e??``,p.current)},[]);let h=e=>{i&&e.target===e.currentTarget&&s()},g=n?`dialog-panel ${n}`:`dialog-panel`;return J(lS.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(Dp.Provider,{value:m,children:f})})]})})})}function dS(){let[e,t]=ke([]),n=M(e);n.current=e;let r=Pe(e=>{t(t=>[...t,e])},[]),i=Pe(()=>{t(e=>e.slice(0,-1))},[]),a=Pe(()=>{t([])},[]);return je(()=>Ib({close:i,closeAll:a,push:r,isOpen:()=>n.current.length>0}),[i,a,r]),je(()=>jb(()=>{let e=[];for(;Nb()>0;){let t=Mb();t&&e.push(t)}e.length>0&&t(t=>[...t,...e])}),[]),e.length===0?null:J(S,{children:e.map((e,t)=>J(uS,{passageName:e.passageName,panelClass:e.panelClass,onClose:i,showCloseButton:e.showCloseButton,dismissible:e.dismissible},`${e.passageName}-${t}`))})}function fS(){let[e,t]=ke(Os);return je(()=>(t(Os()),ks(()=>t(Os()))),[]),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:()=>Ds(e.id),children:`✕`})]},e.id))})}async function pS(){try{await Q.getState().save()}catch(e){Ts(`The game could not be saved:`,e)}}async function mS(){try{await Q.getState().load()}catch(e){Ts(`The saved game could not be loaded:`,e)}}function hS(){let{storyData:e,currentPassage:t,nobr:n}=Tc(`storyData`,`currentPassage`,`nobr`);if(je(()=>{let e=e=>{let{quickSaveKey:t,quickLoadKey:n}=Q.getState();t!==null&&e.key===t?(e.preventDefault(),pS()):n!==null&&e.key===n&&(e.preventDefault(),mS())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[]),!e||!t)return J(`div`,{class:`loading`,children:`Loading...`});let r=J(S,{children:[J($x,{}),J(dS,{}),J(fS,{})]});return J(wp.Provider,{value:n,children:r})}var gS=`http://www.w3.org/1999/xhtml`,_S=new Set([`area`,`base`,`basefont`,`bgsound`,`br`,`col`,`embed`,`frame`,`hr`,`img`,`input`,`keygen`,`link`,`meta`,`param`,`source`,`track`,`wbr`]);function vS(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+=yS(n));return t}function yS(e){let t=e.localName,n=`<${t}`;for(let t of Array.from(e.attributes))n+=` ${t.name}=${bS(t.name,t.value)}`;if(n+=`>`,e.namespaceURI===gS&&_S.has(t))return n;let r=t===`template`?e.content:e;return`${n}${vS(r)}</${t}>`}function bS(e,t){let n=Wo(e),r=n?`on`:`a`;return[`\"${t}\"`,`'${t}'`].find(e=>{let t;try{t=Qo(`<i ${r}=${e}>`)}catch(e){if(e instanceof Jo)return!1;throw e}let n=t[0];return t.length===1&&n?.type===`html`&&n.attributes[r]===e.slice(1,-1)})??`\"${xS(t,n)}\"`}function xS(e,t){let n=e=>e.replace(/\"/g,`"`);if(t)return Go(e).map(e=>`text`in e?n(e.text):`expr`in e?`{${e.expr}}`:e.verbatim).join(``);let r;try{r=Qo(e,{text:!0})}catch(t){if(t instanceof Jo)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 SS(){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=vS(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 CS=new Map,wS=q(),TS=!1,ES=null;function DS(){return`spindle.${Q.getState().storyData?.ifid||`unknown`}.settings`}function OS(){try{localStorage.setItem(DS(),JSON.stringify(wS))}catch{}}function kS(){if(!TS){if(!Q.getState().storyData?.ifid){ES||(ES=Q.subscribe(e=>{e.storyData?.ifid&&(ES?.(),ES=null,kS())}));return}TS=!0;try{let e=localStorage.getItem(DS());if(e){let t=JSON.parse(e);typeof t==`object`&&t&&!Array.isArray(t)&&(wS=q(wS,t))}}catch{}}}function AS(e,t){CS.set(e,t),K(wS,e)||(wS[e]=t.config.default),kS()}function jS(e,t){let n=is(wS,e);return typeof n==typeof t?n:t}var MS={addToggle(e,t){AS(e,{type:`toggle`,config:t})},addList(e,t){AS(e,{type:`list`,config:t})},addRange(e,t){AS(e,{type:`range`,config:t})},get(e){return is(wS,e)},getToggle(e){return jS(e,!1)},getList(e){return jS(e,``)},getRange(e){return jS(e,0)},set(e,t){wS[e]=t,OS()},getAll(){return{...wS}},getDefinitions(){return CS},hasAny(){return CS.size>0}},NS=0,PS=256,FS=[];function IS(e){FS.push({version:++NS,segments:e}),FS.length>PS&&FS.shift()}function LS(){return NS}function RS(e,t,n,r,i){return FS.some(({version:a,segments:o})=>a<=e?!1:typeof r==`object`&&r?o.some((e,n)=>u_(t,o.slice(0,n+1))===r):o[o.length-1]===String(i)&&u_(t,o.slice(0,-1))===n)}var zS=[`target`,`variable`,`options`,`value`,`disabled`],BS=new Map,VS=new Map;function HS(e,t,n){if(n)return n;let r=`${e}:${t}`,i=VS.get(r)??0,a;do i++,a=i===1?r:`${r}:${i}`;while(BS.has(a));return VS.set(r,i),a}function US(e){let t=e.id,n={action:e},r=BS.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)):BS.set(t,[n]),JS(),{update(e){let r=BS.get(t);r?.includes(n)&&(n.action=e,r[r.length-1]===n&&JS())},unregister(){let e=BS.get(t),r=e?e.indexOf(n):-1;!e||r===-1||(e.splice(r,1),e.length===0&&BS.delete(t),r===e.length&&JS())}}}function WS(){return Array.from(BS.values(),KS)}function GS(e){let t=BS.get(e);return t&&KS(t)}function KS(e){return e[e.length-1].action}function qS(){VS.clear()}function JS(){sv(`actionsChanged`)}function YS(e){let t=M(``),n=M(e.perform);n.current=e.perform,t.current||(t.current=HS(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 zS)e[n]!==void 0&&Object.assign(t,{[n]:e[n]});return t},a=M(null);Me(()=>{let e=US(i());return a.current=e,()=>e.unregister()},[r]);let o=M(!1);return Me(()=>{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 XS(e){return e.map(e=>e.type===`text`?e.value:``).join(``)}function ZS(e){let{variable:t=``,placeholder:n=``}=lc(e,[{name:`variable`,type:`variable`},{name:`placeholder`,type:`string`}]);return{varName:t.replace(/[\"']/g,``),placeholder:n}}var QS=[{name:`value`,type:`string`,holds:`text`,required:!0}],$S=new Map([[`option`,QS]]);function eC(e){return $S.get(e.toLowerCase())}function tC(e){let t=[];for(let n of e)if(n.type===`macro`&&n.name===`option`){let{value:e}=lc(n.rawArgs,QS);t.push(e??``)}return t}function nC(e,t){let n=`macro-${e}`;return t?`${n} ${t}`:n}var rC={useState:ke,useRef:M,useEffect:je,useLayoutEffect:Me,useCallback:Pe,useMemo:Ne,useContext:Fe};function $(e,t=`builtin`){let n=e.parameters??[];Sl(e.name,n);function r(t){let r=t.className,i=t.id,a;e.interpolate&&(a=Gl(),r=a(r),i=a(i));let{update:o,getValues:s}=Fe(Cp),c=Xl(),l=(e,t)=>Em(e,{...c,...t}),u;try{u=lc(t.rawArgs,n)}catch(t){if(t instanceof Js)return b(vp,{macro:e.name,error:t});throw t}let d={args:u,collectText:XS,sourceLocation:_p,parseVarArgs:ZS,extractOptions:tC,h:b,renderNodes:l,renderInlineNodes:vm,hooks:rC,useAction:YS,className:r,id:i,resolve:a,cls:nC(e.name,r),mutate:e=>lb(e,s(),o),update:o,getValues:s,wrap:e=>kl(r,i,e)};if(e.merged){d.merged=Ec();let e=d.merged;d.evaluate=t=>ll(t,e[0],e[1],e[2],e[3])}if(e.storeVar){let n=fc(t.rawArgs).replace(/[\"']/g,``);if(n.startsWith(`%`))return b(`span`,{class:`error`},`{${e.name}}: transient variables (%${n.slice(1)}) cannot be bound to input macros`);let r=n.replace(/[\"']/g,``).replace(/^\\$/,``),i=r.split(`.`);if(i.includes(`__proto__`))return b(`span`,{class:`error`},`{${e.name}}: \"$${r}\" cannot be bound: ${ts} is reserved`);d.varName=r,d.value=Q(e=>u_(e.variables,i)),d.getValue=()=>u_(Ly().variables,i),d.setValue=e=>{IS(i),sb((t,n)=>{m_(t.variables,i,n(e),{createMissing:!0})})}}try{return e.render(t,d)}catch(t){if(t instanceof Js)return b(vp,{macro:e.name,error:t});throw t}}fl(e.name,r);let i=e.text;hl(e.name,i&&((e,t)=>i(e,{...t,args:lc(e.rawArgs,n)})));let a=e.block===!0||e.block!==!1&&(e.subMacros?.length??0)>0;if(Tl(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)vl(t);a&&Sr(e.name)}var iC=null;function aC(e){iC=e}function oC(){return iC}var sC=null,cC=null;function lC(){return cC}var uC=!1;function dC(){if(uC)return;uC=!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:is(e,i),to:is(t,i)}};i(e,n.variables,``),i(t,n.transient,`%`),e=n.variables,t=n.transient,Object.keys(r).length>0&&sv(`variableChanged`,r)})}var fC=null,pC=null,mC=new Set;function hC(e,t=[]){fC=new Set(e),pC=new Set(t),mC.clear()}function gC(e){let t=e.startsWith(`%`),n=t||e.startsWith(`$`)?e.slice(1):e;return rs(n.split(`.`)[0],e),{isTransient:t,key:n}}function _C(e,t){let n=e?pC:fC;if(!n)return;let r=t.split(`.`)[0];if(n.has(r))return;let i=(e?`%`:`$`)+r;mC.has(i)||(mC.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 vC(e,t,n){let{isTransient:r,key:i}=gC(t),a=r?e.transient:e.variables;i.includes(`.`)?m_(a,i.split(`.`),n):a[i]=n}function yC(e){return((...t)=>Q.getState()[e](...t))}function bC(){return{get(e){let{isTransient:t,key:n}=gC(e),r=Iy(),i=r??Q.getState(),a=t?i.transient:i.variables,o=n.includes(`.`)?u_(a,n.split(`.`)):is(a,n);return r?Vy(o):Uy(o)},set(e,t){let n=typeof e==`string`?[[e,t]]:Object.entries(e);for(let[e]of n){let{isTransient:t,key:n}=gC(e);_C(t,n)}if(n.some(([e])=>e.includes(`.`))){sb((e,t)=>{for(let[r,i]of n)vC(e,r,t(i))});return}Q.getState().updateVariables(e=>{for(let[t,r]of n)vC(e,t,r)})},goto:yC(`navigate`),back:yC(`goBack`),forward:yC(`goForward`),restart:yC(`restart`),save:yC(`save`),load:yC(`load`),hasSave:yC(`hasSave`),getSaveInfo:yC(`getSaveInfo`),listSaves:yC(`listSaves`),deleteSave:yC(`deleteSave`),exportSave:yC(`exportSave`),importSave:yC(`importSave`),...il(()=>Q.getState().visitCounts,()=>Q.getState().renderCounts),get title(){return Q.getState().storyData?.name||``},get passage(){return Q.getState().currentPassage},settings:MS,registerClass(e,t){Ph(e,t)},defineMacro(e){$(e,`user`)},getMacroRegistry(){return Dl()},saves:{setTitleGenerator(e){dv(e)}},storage:{async getInfo(){let e=Q.getState().storyData?.ifid;return e?Ty(e):{saveCount:0,playthroughCount:0,totalBytes:0,backend:l_()}},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:yC(`clearGameData`),clearAllData:yC(`clearAllData`),deletePlaythrough:yC(`deletePlaythrough`),get backend(){return l_()}},getActions(){return WS()},performAction(e,t){let n=GS(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`&&dC();let n=av(e,t);return jx(n),n},async waitForActions(){await new Promise(e=>{requestAnimationFrame(()=>requestAnimationFrame(()=>e()))});let e=()=>oC()===Q.getState().navigationId;return oC()!==null&&!e()&&!Q.getState().renderDeferred&&await new Promise(t=>{let n=av(`passagerender`,()=>{e()&&(n(),t())})}),WS()},watch(e,t){return _b(e,t)},unwatch(e){xb(e)},openDialog(e,t){Pb({passageName:e,panelClass:t?.panelClass,showCloseButton:t?.showCloseButton,dismissible:t?.dismissible})},closeDialog(){zb()},closeAllDialogs(){Bb()},isDialogOpen(){return Vb()},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(),cC=new Promise(e=>{sC=e})},ready(){sC&&(Q.getState().clearDeferredRender(),sC(),sC=null,cC=null)},random(){return Vc()},randomInt(e,t){return Hc(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){Fc(e,t);let{historyIndex:n}=Q.getState();Q.setState(e=>{let t=e.history[n];t&&(t.prng=Bc())})},isEnabled(){return Uc()},get seed(){return Wc()},get pull(){return Gc()}}}}function xC(){window.Story=bC()}var SC=null;function CC(e){let t=SC;SC=new Map;try{return e()}finally{SC=t}}function wC(e,t){let n=t[0]+e,r=SC?.get(n);if(r)return r;try{r=go(e,t)}catch(e){if(!(e instanceof so))throw e;r=e}return SC?.set(n,r),r}var TC=new Set([`if`,`elseif`,`case`]),EC=new Set([`dialog`]);function DC(e,t){return e.map(e=>e.parameters?{...e,parameters:DC(e.parameters,t)}:(e.type===`string`||e.type===`text`)&&!e.holds?{...e,holds:t}:e)}function OC(e){let t=new vr;for(let{name:n,parameters:r,interpolate:i}of e)r&&t.set(n,DC(r,kC(i)));return e=>{let n=t.get(e);if(!n){let r=eC(e);r&&t.set(e,n=DC(r,`text`))}return n}}var kC=e=>e?`markup`:`text`;function AC(e){if(e.type===`expression`||e.type===`passage`)return`expression`;if(e.type===`statements`)return`statements`}function jC(e){if(!(e.type!==`string`&&e.type!==`text`))return e.holds??`markup`}function*MC(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:PC(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=PC(e,r,t);if(t=i+r.length,!Wo(n)){yield{kind:`text`,text:r,offset:i,where:`In the ${n} attribute of <${a.tag}>: `};continue}let o=0;for(let e of Go(r)){if(!(`expr`in e))continue;let t=PC(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(EC.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(TC.has(o)){yield{kind:`code`,code:s,offset:u,goal:`expression`,label:c};continue}let d=n(o);d&&(yield*NC(s,u,d,a.name,c))}}}function*NC(e,t,n,r,i){let a,o=new Map;try{a=lc(e,n,o)}catch(e){if(!(e instanceof Js))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=AC(l);if(l.type===`passage`){let e=uc(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),_=jC(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 PC(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 FC=new Set([`StoryVariables`,`StoryTransients`,`SaveTitle`]),IC=[`script`,`stylesheet`],LC=new Set([`elseif`,`else`,`case`,`default`,`next`]);function RC(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 zC(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 BC(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=zC(r,e.toLowerCase());t<a&&(i=e,a=t)}return i?` Did you mean ${n(i)}?`:``}var VC=` (a passage name is a quoted string or an expression)`,HC=/^[A-Za-z][\\w$]*$/;function UC(e){try{return hc(e).name.toLowerCase()||void 0}catch{return}}function WC(e,t){let n=[],r=t.isBlockMacro?{isBlock:t.isBlockMacro}:void 0,i=(e,t,r)=>{let{line:i,column:a}=Yo(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),FC.has(n.name)||n.tags?.some(e=>IC.includes(e)))continue;let e=!t.only||t.only(n);try{let t=Qo(n.content);for(let e of t){if(e.type!==`macro`||e.isClose||e.name.toLowerCase()!==`widget`)continue;let t=UC(e.rawArgs);t&&o.add(t)}if(!e)continue;Zo(n.content,{hooks:r}),a.push([n,t])}catch(t){if(!(t instanceof Jo))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();LC.has(n)||o.has(n)||t.isKnownMacro(n)||i(e,r+s.start,`${a}Unknown macro {${s.name}}.${BC(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 MC(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=BC(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=wC(l.code,l.goal),r=l.code.trim();if(t instanceof so){let r=t.reasonIn(e.content,n);i(e,n+t.pos,`${c}${r} in ${l.label}`+(l.passage?VC:``))}else l.passage&&HC.test(r)&&i(e,n,`${c}Unquoted passage name in ${l.label}: write ${JSON.stringify(r)}${VC}`);continue}if(l.text.includes(`{`))try{Zo(l.text,{text:!0,hooks:r});let t=Qo(l.text,{text:!0});d(e,l.text,t,n,l.where)}catch(t){if(!(t instanceof Jo))throw t;i(e,n+t.offset,l.where+t.reason)}}};for(let[e,t]of a)CC(()=>d(e,e.content,t,0,``));return n}function GC(e,t){try{return Qo(e,{text:t})}catch(e){if(e instanceof Jo)return[];throw e}}function KC(e){let t=e.replace(/[.*+?^${}()|[\\]\\\\]/g,`\\\\$&`);return RegExp(`^${t}(\\\\w+)\\\\s*=\\\\s*(.+)$`)}var qC=/\\$(\\w+(?:\\.\\w+)*)/y,JC=/^[\"']\\$(\\w+(?:\\.\\w+)*)[\"']?$/,YC=new Set([`number`,`string`,`boolean`]),XC={string:Object(``),number:Object(0),boolean:Object(!1)};function ZC(e){if(Array.isArray(e))return{type:`array`};if(e===null)return{type:`null`};if(typeof e==`object`){let t=new Map;for(let[n,r]of Object.entries(e))t.set(n,ZC(r));return{type:`object`,fields:t}}let t=typeof e;if(!YC.has(t))throw Error(`Unsupported type \"${t}\" for value ${String(e)}. Expected number, string, boolean, array, or object.`);return{type:t}}function QC(e,t=`$`){let n=new Map,r=KC(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=ns(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}\": ${ys(e)}`)}let d;try{d=ZC(u)}catch(e){throw Error(`${i}: ${ys(e)}`)}n.set(s,{...d,name:s,default:u})}return n}function $C(e,t){let n=e.split(`.`),r=n[0],i=ns(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=XC[o.type];if(r&&t in r){let e=typeof r[t];if(!YC.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 ew=[`checkbox`,`cycle`,`listbox`,`numberbox`,`radiobutton`,`textarea`,`textbox`],tw=new Set;function nw(e,t){for(let n of Go(e))`expr`in n&&iw(n.expr,t)}function rw(e,t,n=tw){e.includes(`{`)&&cw(e,GC(e,!0),n,t)}function iw(e,t,n=`expression`){let r=wC(e,n);if(r instanceof so){aw(e,t,n);return}for(let n of r.refs)n.sigil===`$`&&(qC.lastIndex=n.start,t(qC.exec(e)[1]))}function aw(e,t,n){Ao(e,{variable(n,r,i){n===`$`&&(qC.lastIndex=i,t(qC.exec(e)[1]))},literal(){}},n)}function ow(e,t,n,r){CC(()=>cw(e,GC(e,!1),t,n,r))}function sw(e,t,n){if(e.rawArgs){if(t){let r=[...NC(e.rawArgs,0,t,e.name,``)];if(!r.some(e=>e.kind===`argument-error`)){for(let e of r)e.kind===`code`?iw(e.code,n,e.goal):e.kind===`text`&&rw(e.text,n);return}}iw(e.rawArgs,n)}}function cw(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`)rw(o.display,r);else if(o.type===`expression`)iw(o.expression,r);else if(o.type===`html`)for(let[e,t]of Object.entries(o.attributes))Wo(e)?nw(t,r):rw(t,r,n);else if(o.type===`macro`&&!o.isClose){if(sw(o,i(o.name),r),o.className&&rw(o.className,r),o.id&&rw(o.id,r),n.has(o.name.toLowerCase())){let e=o.rawArgs.trim().split(/\\s+/)[0]??``,t=JC.exec(e);t?r(t[1]):/^[\"'`]/.test(e)||iw(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&&(iw(e.slice(o.end,t[n].start),r,`statements`),a=n)}}}}function lw(e,t,n=ew,r=El){let i=[],a=new Set(Array.from(n,e=>e.toLowerCase()));for(let[n,o]of e)FC.has(n)||ow(o.content,a,e=>{let r=$C(e,t);r&&i.push(`Passage \"${n}\": ${r}`)},r);return i}function uw(e){let t=q();for(let[n,r]of e)t[n]=r.default;return t}$({name:`set`,parameters:[{name:`code`,type:`statements`,required:!0}],render({rawArgs:e},t){return bp(`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(Ol(t.evaluate(e)))}catch(e){return J(vp,{macro:`print`,error:e})}},text({rawArgs:e},t){return Ol(t.evaluate(e))}});var dw=Symbol(`unset`);function fw(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 rs(n.slice(1),n),{target:n,expr:r}}function pw(e,t,n,r,i,a,o,s,c){let l=_p(),u,d=o.current,f=!1,{navigationId:p}=Q.getState();try{let{variables:a,temporary:o,transient:c}=Ly();r||(d=is(n?o:a,t),f=p!==s.current),u=ll(e,a,o,i(),c)}catch(e){yp(`computed ${a}`,e,l);return}if(s.current=p,!E_(o.current,u)||f&&!E_(d,u))if(o.current=u,r)try{c(t,u)}catch(e){yp(`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}=fw(e,t.args))}catch(e){return J(vp,{macro:`computed`,error:e})}let i=n.startsWith(`@`),a=n.startsWith(`_`),o=n.slice(1),s=i?t.update:null,c=t.hooks.useRef(dw),l=t.hooks.useRef(-1),u=()=>pw(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 mw(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 hw(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}=mw({...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=hw(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(vp,{macro:`meter`,error:e})}}});function gw(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 _w(e,t){return kl(t.resolve(e.className),t.resolve(e.id),t.renderNodes(e.children))}function vw(e,t){let n=e.findIndex(e=>e.rawArgs===``);return gw(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=vw(e,t.evaluate)}catch(e){return J(vp,{macro:`if`,error:e})}return n?_w(n,t):null},text({branches:e=[]},t){let n=vw(e,t.evaluate);return n?t.renderText(n.children):``}});function yw(e){try{return bw(e,[])}catch{return`<unkeyable>`}}function bw(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.indexOf(n);if(r!==-1)return`<cycle ${t.length-r}>`;if(e instanceof Date)return`Date(${Date.prototype.getTime.call(e)})`;if(e instanceof RegExp)return`RegExp(${RegExp.prototype.toString.call(e)}@${e.lastIndex})`;t.push(n);try{if(Array.isArray(e))return`[${Array.from(e,e=>bw(e,t)).join(`,`)}]`;if(e instanceof Map)return`Map[${[...Eh(e)].map(([e,n])=>`[${bw(e,t)},${bw(n,t)}]`).join(`,`)}]`;if(e instanceof Set)return`Set[${[...Dh(e)].map(e=>bw(e,t)).join(`,`)}]`;let r=n,i=Object.keys(r).map(e=>`${JSON.stringify(e)}:${bw(r[e],t)}`).join(`,`),a=Fh(n);return a===void 0?`{${i}}`:`Class(${JSON.stringify(a)}){${i}}`}finally{t.pop()}}function xw(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 rs(n.slice(1),n),r&&rs(r.slice(1),r),{itemVar:n.slice(1),indexVar:r?r.slice(1):null,listExpr:i}}function Sw({parentValues:e,itemVar:t,itemValue:n,indexVar:r,indexValue:i,children:a}){return J(Zl,{body:a,parentValues:e,ownKeys:Ne(()=>({[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=Fe(Sp),i=n.hooks.useRef({contents:[],generations:[],next:0,edits:LS()}).current,a,o;try{a=xw(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(vp,{macro:`for`,error:e})}let{itemVar:s,indexVar:c}=a,l=i.edits,{variables:u}=Ly();i.edits=LS();let d=o.map((e,t)=>{let n=yw(e);return(i.generations[t]===void 0||n!==i.contents[t]&&!RS(l,u,o,e,t))&&(i.generations[t]=i.next++),i.contents[t]=n,i.generations[t]});i.contents.length=i.generations.length=o.length;let f=o.map((e,n)=>J(Sw,{parentValues:r,itemVar:s,itemValue:e,indexVar:c,indexValue:n,children:t},`${n}-${d[n]}`));return n.wrap(f)},text({rawArgs:e,children:t=[]},n){let{itemVar:r,indexVar:i,listExpr:a}=xw(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 bp(`do`,``,()=>t.mutate(n))}});function Cw(e){return new Proxy(q(),{get:(t,n)=>typeof n==`string`?is(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 ww=ge({stop:()=>{}});$({name:`repeat`,block:!0,interpolate:!0,parameters:[cc],render({children:e=[]},t){let{useState:n,useEffect:r,useCallback:i}=t.hooks,a=t.args.delay??0,[o,s]=n(0),[c,l]=n(!1),u=i(()=>l(!0),[]);if(r(()=>{if(c)return;let e=setInterval(()=>{s(e=>e+1)},a);return()=>clearInterval(e)},[a,c]),o===0&&!c)return null;let d=J(ww.Provider,{value:{stop:u},children:J(`span`,{children:t.renderNodes(e)},o)});return t.className||t.id?J(`span`,{id:t.id,class:t.cls,children:d}):d}});var Tw=()=>!0;function Ew(){let e=Fe(Cp),{nobr:t,inline:n}=Xl(),r=Fe(Np),i=Fe(ww),a=Fe(lS),o=M([]);je(()=>()=>{for(let e of o.current.splice(0))he(null,e)},[]);let s=s=>{let c=Cw(e.getValues),l=document.createElement(`div`);he(J(wc.Provider,{value:Tw,children:J(Cp.Provider,{value:e,children:J(Sp.Provider,{value:c,children:J(wp.Provider,{value:t,children:J(Tp.Provider,{value:n,children:J(Np.Provider,{value:r,children:J(ww.Provider,{value:i,children:J(lS.Provider,{value:a,children:Em(s,{nobr:t,inline:n,locals:c})})})})})})})})}),l),o.current.push(l)};return e=>ob(()=>s(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=Ew(),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=Ew(),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(vp,{macro:`link`,error:i.error}):J(`a`,{id:t.id,class:t.cls,href:`#`,onClick:e=>{e.preventDefault(),o()},children:n})}});function Dw(e,t,n){return gw(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(vp,{macro:`switch`,error:e})}let i;try{i=Dw(r,t,n.evaluate)}catch(e){return J(vp,{macro:`case`,error:e})}return i?_w(i,n):null},text({rawArgs:e,branches:t=[]},n){let r=Dw(n.evaluate(e),t,n.evaluate);return r?n.renderText(r.children):``}});var Ow=[cc];$({name:`timed`,subMacros:[`next`],interpolate:!0,parameters:Ow,render({branches:e=[]},t){let{useState:n,useEffect:r,useMemo:i}=t.hooks,a=i(()=>e.map(e=>({delay:lc(e.rawArgs,Ow).delay??0,nodes:e.children,className:e.className,id:e.id})),[e]),[o,s]=n(-1);if(r(()=>{if(o>=a.length-1)return;let e=o+1,t=a[e].delay,n=setTimeout(()=>{s(e)},t);return()=>clearTimeout(n)},[o,a]),o<0)return t.wrap(null);let c=a[o];return t.wrap(kl(t.resolve(c.className),t.resolve(c.id),t.renderNodes(c.nodes)))}}),$({name:`stop`,render(e,t){let{stop:n}=t.hooks.useContext(ww);return t.hooks.useLayoutEffect(()=>{n()},[n]),null}});function kw(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:[cc],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(kw(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:pc,render({children:e=[]},t){let n,r;try{let e=mc(t.args);for(let t of e.params)rs(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&&_c(n,e)},[i,o,s]),r?J(vp,{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 Aw(e,t){return t?`${e} (${t})`:e}function jw(e){$({name:e.name,render(t,n){if(e.hidden?.())return null;let[r,i]=ke(!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(uS,{passageName:e.dialog.passageName,fallbackMarkup:e.dialog.fallbackMarkup,panelClass:e.dialog.panelClass,onClose:()=>i(!1),showCloseButton:e.dialog.showCloseButton})]})}})}jw({name:`back`,label:`← Back`,actionType:`back`,setup:()=>({perform:Q(e=>e.goBack),disabled:!Q(e=>e.historyIndex>0)})}),jw({name:`forward`,label:`Forward →`,actionType:`forward`,setup:()=>({perform:Q(e=>e.goForward),disabled:!Q(e=>e.historyIndex<e.history.length-1)})}),jw({name:`quicksave`,label:`QuickSave`,actionType:`save`,setup:()=>{let{quickSaveKey:e}=Tc(`quickSaveKey`);return{perform:pS,title:Aw(`Quick Save`,e)}}}),jw({name:`quickload`,label:`QuickLoad`,actionType:`load`,confirm:`Load saved game? Current progress will be lost.`,setup:()=>{let{hasSave:e,quickLoadKey:t}=Tc(`hasSave`,`quickLoadKey`,`knownSaves`);return{perform:mS,disabled:!e(),title:Aw(`Quick Load`,t)}}}),jw({name:`restart`,label:`↺ Restart`,actionType:`restart`,confirm:`Restart the story? All progress will be lost.`,setup:()=>({perform:Q(e=>e.restart)})}),jw({name:`saves`,label:`Saves`,actionType:`dialog`,dialog:{passageName:`SaveLoad`,fallbackMarkup:`{save-manager}`,panelClass:`dialog-saves`}}),jw({name:`settings`,label:`Settings`,actionType:`dialog`,hidden:()=>!MS.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(uS,{passageName:o,onClose:()=>r(!1),showCloseButton:!i})]})}});function Mw(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 Nw(e){return new Date(e).toLocaleDateString(void 0,{month:`short`,day:`numeric`,year:`numeric`})}function Pw(){let[e,t]=ke(`load`),[n,r]=ke([]),[i,a]=ke(!0),[o,s]=ke(null),[c,l]=ke(()=>new Set),[u,d]=ke(null),f=M(!1),[p,m]=ke(``),h=M(null),g=M(null),_=Fe(lS),{storyData:v,playthroughId:y,beginSave:b,loadFromPayload:x}=Tc(`storyData`,`playthroughId`,`beginSave`,`loadFromPayload`),S=v?.ifid??``,[C,w]=ke(!1),T=Pe(async()=>{if(!S)return;let e=await Bv(S);w(l_()===`memory`),r(e),a(!1)},[S]);je(()=>{T()},[T]),je(()=>{u&&h.current&&(h.current.focus(),h.current.select())},[u]);let ee=M(!0),E=M(),D=M(),O=(e,t=`success`)=>{ee.current&&(clearTimeout(E.current),s({text:e,type:t}),E.current=window.setTimeout(()=>s(null),3e3))};je(()=>(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=yx();try{await Av(void 0,void 0,b,async t=>Mv(S,e,t)),O(C?`Save created (temporary)`:`Save created`),await T()}catch{O(`Failed to create save`,`error`)}},re=async e=>{let t=yx();try{await Av(void 0,void 0,b,async n=>{if(!await Pv(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=>{try{x(Lv(e.payload),void 0,e.meta.playthroughId),O(`Game loaded`),_&&(D.current=window.setTimeout(_,500)),await T()}catch{O(`Failed to load save`,`error`)}},ie=async e=>{if(confirm(`Delete this save?`))try{await Rv(e);let t=await oy(S);Q.setState(e=>{e.knownSaves=t}),O(`Save deleted`),await T()}catch{O(`Failed to delete save`,`error`)}},ae=e=>{f.current=!1,d(e.meta.id),m(e.meta.title)},oe=async()=>{if(!(!u||!p.trim()))try{await zv(u,p.trim()),d(null),O(`Save renamed`),await T()}catch{O(`Failed to rename`,`error`)}},se=e=>{e.key===`Enter`?oe():e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),f.current=!0,d(null))},ce=()=>{f.current||oe()},le=async e=>{try{let t=await by(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`)}},ue=()=>{g.current?.click()},de=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(!Lg(t))throw Error(`Invalid save file format`);await Sy(t,S),O(`Save imported`),await T()}catch(e){O(ys(e,`Failed to import save`),`error`)}}},fe=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:ue,children:`Import`}),J(`input`,{ref:g,type:`file`,accept:`.json`,style:`display:none`,onChange:de})]}),J(`div`,{class:`saves-body`,children:[i?J(`div`,{class:`saves-empty`,children:`Loading...`}):fe===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:Nw(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:se,onBlur:ce}):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:Mw(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:()=>ae(t),children:`Rename`}),J(`button`,{type:`button`,class:`save-slot-action`,onClick:()=>le(t.meta.id),children:`Export`}),J(`button`,{type:`button`,class:`save-slot-action danger`,onClick:()=>ie(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(Pw,{})}});function Fw({name:e,def:t}){let[n,r]=ke(()=>MS.get(e)),i=t=>{r(t),MS.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 Iw(){let e=MS.getDefinitions();return J(`div`,{class:`settings-controls`,children:Array.from(e.entries()).map(([e,t])=>J(Fw,{name:e,def:t},e))})}$({name:`settings-controls`,render(){return J(Iw,{})}}),$({name:`include`,interpolate:!0,merged:!0,parameters:[{name:`inline`,type:`flag`},{name:`passage`,type:`passage`,required:!0}],render(e,t){let{storyData:n}=Tc(`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?Zo(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(vp,{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(wp.Provider,{value:!0},u)):t.wrap(u)}}),$({name:`nobr`,block:!0,render({children:e=[]},t){return t.wrap(t.h(wp.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){yp(`goto`,t,e),r({error:t})}},[]),n?J(vp,{macro:`goto`,error:n.error}):null}}),$({name:`unset`,parameters:[{name:`variable`,type:`variable`,required:!0}],render({rawArgs:e},t){return bp(`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 Lw={name:`variable`,type:`variable`,required:!0};function Rw(e,t){return e.useAction({key:`$${e.varName}`,authorId:e.id,variable:e.varName,value:e.value,...t})}function zw(e,t,n=e=>e===void 0?``:String(e)){$({name:e,storeVar:!0,parameters:[Lw,{name:`placeholder`,type:`string`,holds:`text`}],render(r,i){let a=i.args.placeholder??``;Rw(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:Ol(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))}})}})}zw(`textbox`,`text`),zw(`numberbox`,`number`,e=>e===void 0?0:Number(e)),zw(`textarea`),$({name:`checkbox`,storeVar:!0,parameters:[Lw,{name:`label`,type:`text`,holds:`text`}],render(e,t){let n=t.args.label??``;return Rw(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:[Lw,{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(Dp);return Rw(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:[Lw],render({children:e=[]},t){let n=t.extractOptions(e);return Rw(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:Ol(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:[Lw],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 Rw(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)});var Bw=new WeakMap;function Vw(e){let t=Bw.get(e);if(t&&t.content===e.content)return t.ast;let n=Zo(e.content);return Bw.set(e,{content:e.content,ast:n}),n}function Hw(e){return Em(Vw(e),e.tags.includes(`nobr`)?{nobr:!0}:void 0)}function Uw(e){if(!e)return null;try{return Hw(e)}catch(t){return console.error(`spindle: Error in ${e.name}:`,t),null}}var Ww=new Set([`PassageReady`,`PassageHeader`,`PassageFooter`,`PassageDone`]);function Gw({passage:e,dataTransition:t,navigationId:n}){let{storyData:r}=Tc(`storyData`),i=Ww.has(e.name),[a,o]=ke(!1),s=Ne(()=>{try{return Hw(e)}catch(t){return J(`div`,{class:`error`,children:[`Error parsing passage “`,e.name,`”`,gp(e),`: `,ys(t)]})}},[e.content,e.name]),c=e=>i?void 0:r?.passages.get(e),l=c(`PassageHeader`),u=c(`PassageFooter`),d=c(`PassageDone`),f=Ne(()=>Uw(l),[l?.content]),p=Ne(()=>Uw(u),[u?.content]);je(()=>(d&&o(!0),()=>o(!1)),[e.name]);let m=Ne(()=>a?Uw(d):null,[a,d?.content]),h=M(null);Me(()=>{n!==void 0&&aC(n),h.current&&cv(`passagerender`,e.name,h.current)},[e.name,n]);let g=e.tags.includes(`nobr`),_=kp(),v=J(Dp.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(wp.Provider,{value:!0,children:v}):v}var Kw=new Set([`none`,`fade`,`fade-through`,`crossfade`]),qw={type:`fade-through`,duration:300,pause:50};function Jw(e){let t=e.find(e=>e.startsWith(`transition:`));if(!t)return null;let n=t.slice(11);if(!Kw.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 Yw(e){return{type:e.type,duration:e.duration??qw.duration,pause:e.pause??qw.pause}}function Xw(e,t,n){let r=Jw(e);return r?Yw(r):t?Yw(t):n?Yw(n):{...qw}}function Zw(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 Qw(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 $w(e,t){if(!e)return null;Qw(e,t);let n=e.querySelector(`.passage`);return n?Zw(n,t.type):null}function eT(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()}function tT(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}=Tc(`currentPassage`,`navigationId`,`storyData`,`renderDeferred`),[o,s]=ke({passage:n,id:r}),c=o.passage,l=e=>s({passage:e,id:r}),u=M(`fade`),d=M(0),f=o.id,p=Pe(e=>e.navigationId!==f,[f]),m=M(null),h=M(null),g=M([]),_=Pe(()=>{for(let e of g.current)clearTimeout(e);g.current=[],eT(h.current)},[]);je(()=>_,[_]),je(()=>{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,v=t.length>1&&a===t.length-1&&f>1&&Math.abs(t.length-f)>1;if(r===o.id)return;let y=e.consumeNextTransition();_();let b=i?.passages.get(n);if(!b){u.current=`none`,l(n);return}if(p||m||v){u.current=`fade`,l(n);return}let x=tT(Xw(b.tags,y,s));u.current=x.type;let S=h.current;if(x.type===`none`){l(n);return}if(x.type===`fade`){S&&Qw(S,x),l(n);return}let C=x.type===`fade-through`||x.type===`crossfade`?$w(S,x):null;if(!S||!C){l(n);return}if(x.type===`fade-through`){S.appendChild(C),l(``);let e=x.duration+x.pause,t=setTimeout(()=>{l(n)},e),r=e+x.duration;g.current=[t,setTimeout(()=>{eT(S)},r)];return}S.classList.add(`passage-container--crossfading`),S.appendChild(C),l(n),g.current=[setTimeout(()=>{eT(S)},x.duration)]},[r]);let v=c&&!a?o.id:null,y=M(v);Me(()=>{if(v===null)return;let e=y.current;if(y.current=v,e===null||e===v)return;let t=h.current?.querySelector(`.passage`);t&&t.getBoundingClientRect().top<0&&t.scrollIntoView?.({block:`start`})},[v]);let b=a?i?.passages.get(`StoryLoading`)??null:c?i?.passages.get(c):null;if(!b&&c&&!a)return J(`div`,{class:`error`,children:[`Error: Passage “`,c,`” not found.`]});let x=i?.passages.get(`PassageReady`),S=!a&&o.id!==r&&m.current?m.current:b&&J(Gw,{passage:b,dataTransition:a?`none`:u.current,navigationId:a?void 0:o.id},a?`loading`:`nav-${o.id}`);return m.current=S||null,J(`div`,{id:t.id??`story`,class:t.className??`story`,children:[!a&&x&&J(`div`,{hidden:!0,children:Hw(x)},`ready-${r}`),J(`div`,{class:`passage-container`,ref:h,children:S&&J(wc.Provider,{value:p,children:S})})]})}}),$({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.useRef(!1);return a.current||(a.current=!0,vb(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,xb(n)),null}});var nT=`*,: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}.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 rT(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 iT(e){let t=document.getElementById(`root`);throw t&&rT(t,e),Error(`spindle: ${e.length} validation error(s):\\n${e.join(`\n`)}`)}function aT(e,t){let n=Dl().filter(e=>e.storeVar).map(e=>e.name);return lw(e.passages,t,n)}function oT(e,t){let n=Dl();return WC(e.passages.values(),{isKnownMacro:e=>!!pl(e)||yl(e)||!!_s(e),macroNames:n.map(e=>e.name),parametersOf:OC(n),only:t}).map(RC)}function sT(){let e=SS(),t=document.createElement(`style`);if(t.id=`spindle-styles`,t.textContent=nT,document.head.appendChild(t),xC(),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&&rT(t,[e]),Error(`spindle: ${e}`)}let i=QC(r.content);for(let t of gc(e.passages.values()))Sr(t);let a=aT(e,i);a.push(...oT(e,e=>e.name===`StoryInit`));let o={},s=e.passages.get(`StoryTransients`);if(s){let e=QC(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=uw(e)}a.length>0&&iT(a),n=uw(i),hC(Object.keys(n),Object.keys(o)),Q.getState().init(e,n,o),Mx();for(let[,t]of e.passages)t.tags.includes(`widget`)&&vc(Zo(t.content),t.name);Ny(my(e.ifid));let c=[...aT(e,i),...oT(e,e=>e.name!==`StoryInit`)];c.length>0&&iT(c);let l=Q.getState().navigationId;Q.subscribe(e=>{e.navigationId!==l&&(l=e.navigationId,qS())}),Ob();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(hS,{}),d);let f=lC();f?f.then(()=>{document.dispatchEvent(new CustomEvent(`:storyready`))}):document.dispatchEvent(new CustomEvent(`:storyready`))}document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,sT):sT();</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.17","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)||Ut(e)||!!e[xt]||!!e[Tt]?.[xt]||Wt(e)||Gt(e):!1}var Nt=Ct[Et][Tt].toString(),Pt=new WeakMap;function Ft(e){if(!e||!Kt(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(!qt(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_:Ut(e)?1:Wt(e)?2:Gt(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],Vt=(e,t,n,r=Rt(e))=>{r===2?e.set(t,n):r===3?e.add(n):e[t]=n};function Ht(e,t){return e===t?e!==0||1/e==1/t:e!==e&&t!==t}var Ut=Array.isArray,Wt=e=>e instanceof Map,Gt=e=>e instanceof Set,Kt=e=>typeof e==`object`,qt=e=>typeof e==`function`,Jt=e=>typeof e==`boolean`;function Yt(e){let t=+e;return Number.isInteger(t)&&String(t)===e}var Xt=e=>Kt(e)?e?.[N]:null,Zt=e=>e.copy_||e.base_,Qt=e=>{let t=Xt(e);return t?t.copy_??t.base_:e},$t=e=>e.modified_?e.copy_:e.base_;function en(e,t){if(Wt(e))return new Map(e);if(Gt(e))return new Set(e);if(Ut(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 tn(e,t=!1){return an(e)||jt(e)||!Mt(e)?e:(Rt(e)>1&&Ct.defineProperties(e,{set:rn,add:rn,clear:rn,delete:rn}),Ct.freeze(e),t&&Lt(e,(e,t)=>{tn(t,!0)},!1),e)}function nn(){St(2)}var rn={[At]:nn};function an(e){return e===null||!Kt(e)?!0:Ct.isFrozen(e)}var on=`MapSet`,sn=`Patches`,cn=`ArrayMethods`,ln={};function un(e){let t=ln[e];return t||St(0,e),t}var dn=e=>!!ln[e];function fn(e,t){ln[e]||(ln[e]=t)}var pn,P=()=>pn,F=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:dn(on)?un(on):void 0,arrayMethodsPlugin_:dn(cn)?un(cn):void 0});function mn(e,t){t&&(e.patchPlugin_=un(sn),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function hn(e){gn(e),e.drafts_.forEach(_n),e.drafts_=null}function gn(e){e===pn&&(pn=e.parent_)}var I=e=>pn=F(pn,e);function _n(e){let t=e[N];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function vn(e,t){t.unfinalizedDrafts_=t.drafts_.length;let n=t.drafts_[0];if(e!==void 0&&e!==n){n[N].modified_&&(hn(t),St(4)),Mt(e)&&(e=yn(t,e));let{patchPlugin_:r}=t;r&&r.generateReplacementPatches_(n[N].base_,e,t)}else e=yn(t,n);return bn(t,e,!0),hn(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e===bt?void 0:e}function yn(e,t){if(an(t))return t;let n=t[N];if(!n)return L(t,e.handledSet_,e);if(!Sn(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);En(n,e)}return n.copy_}function bn(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&tn(t,n)}function xn(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var Sn=(e,t)=>e.scope_===t,Cn=[];function wn(e,t,n,r){let i=Zt(e),a=e.type_;if(r!==void 0&&Bt(i,r,a)===t){Vt(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)??Cn;for(let e of o)Vt(i,e,n,a)}function Tn(e,t,n){e.callbacks_.push(function(r){let i=t;if(!i||!Sn(i,r))return;r.mapSetPlugin_?.fixSetContents(i);let a=$t(i);wn(e,i.draft_??i,a,n),En(i,r)})}function En(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)}xn(e)}}function Dn(e,t,n){let{scope_:r}=e;if(jt(n)){let i=n[N];Sn(i,r)&&i.callbacks_.push(function(){Fn(e),wn(e,n,$t(i),t)})}else Mt(n)&&e.callbacks_.push(function(){let i=Zt(e);e.type_===3?i.has(n)&&L(n,r.handledSet_,r):Bt(i,t,e.type_)===n&&r.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&L(Bt(e.copy_,t,e.type_),r.handledSet_,r)})}function L(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||jt(e)||t.has(e)||!Mt(e)||an(e)?e:(t.add(e),Lt(e,(r,i)=>{if(jt(i)){let t=i[N];Sn(t,n)&&(Vt(e,r,$t(t),e.type_),xn(t))}else Mt(i)&&L(i,t,n)}),e)}function On(e,t){let n=Ut(e),r={type_:n?1:0,scope_:t?t.scope_:P(),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=kn;n&&(i=[r],a=An);let{revoke:o,proxy:s}=Proxy.revocable(i,a);return r.draft_=s,r.revoke_=o,[s,r]}var kn={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=Zt(e);if(!zt(i,t,e.type_))return Mn(e,i,t);let a=i[t];if(e.finalized_||!Mt(a)||r&&e.operationMethod&&n?.isMutatingArrayMethod(e.operationMethod)&&Yt(t))return a;if(a===jn(e.base_,t)){Fn(e);let n=e.type_===1?+t:t,r=Ln(e.scope_,a,e,n);return e.copy_[n]=r}return a},has(e,t){return t in Zt(e)},ownKeys(e){return Reflect.ownKeys(Zt(e))},set(e,t,n){let r=Nn(Zt(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){let r=jn(Zt(e),t),i=r?.[N];if(i&&i.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(Ht(n,r)&&(n!==void 0||zt(e.base_,t,e.type_)))return!0;Fn(e),Pn(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),Dn(e,t,n),!0)},deleteProperty(e,t){return Fn(e),jn(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),Pn(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let n=Zt(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)}},An={};for(let e in kn){let t=kn[e];An[e]=function(){let e=arguments;return e[0]=e[0][0],t.apply(this,e)}}An.deleteProperty=function(e,t){return An.set.call(this,e,t,void 0)},An.set=function(e,t,n){return kn.set.call(this,e[0],t,n,e[0])};function jn(e,t){let n=e[N];return(n?Zt(n):e)[t]}function Mn(e,t,n){let r=Nn(t,n);return r?At in r?r[At]:r.get?.call(e.draft_):void 0}function Nn(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 Pn(e){e.modified_||(e.modified_=!0,e.parent_&&Pn(e.parent_))}function Fn(e){e.copy_||(e.assigned_=new Map,e.copy_=en(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var In=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(e,t,n)=>{if(qt(e)&&!qt(t)){let n=t;t=e;let r=this;return function(e=n,...i){return r.produce(e,e=>t.call(this,e,...i))}}qt(t)||St(6),n!==void 0&&!qt(n)&&St(7);let r;if(Mt(e)){let i=I(this),a=Ln(i,e,void 0),o=!0;try{r=t(a),o=!1}finally{o?hn(i):gn(i)}return mn(i,n),vn(r,i)}else if(!e||!Kt(e)){if(r=t(e),r===void 0&&(r=e),r===bt&&(r=void 0),this.autoFreeze_&&tn(r,!0),n){let t=[],i=[];un(sn).generateReplacementPatches_(e,r,{patches_:t,inversePatches_:i}),n(t,i)}return r}else St(1,e)},this.produceWithPatches=(e,t)=>{if(qt(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]},Jt(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),Jt(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),Jt(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Mt(e)||St(8),jt(e)&&(e=Rn(e));let t=I(this),n=Ln(t,e,void 0);return n[N].isManual_=!0,gn(t),n}finishDraft(e,t){let n=e&&e[N];(!n||!n.isManual_)&&St(9);let{scope_:r}=n;return mn(r,t),vn(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=un(sn).applyPatches_;return jt(e)?r(e,t):this.produce(e,e=>r(e,t))}};function Ln(e,t,n,r){let[i,a]=Wt(t)?un(on).proxyMap_(t,n):Gt(t)?un(on).proxySet_(t,n):On(t,n);return(n?.scope_??P()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?Tn(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 Rn(e){return jt(e)||St(10,e),zn(e)}function zn(e){if(!Mt(e)||an(e))return e;let t=e[N],n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=en(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=en(e,!0);return Lt(n,(e,t)=>{Vt(n,e,zn(t))},r),t&&(t.finalized_=!1),n}function Bn(){function e(n,r=[]){if(n.key_!==void 0){let e=n.parent_.copy_??n.parent_.base_,t=Xt(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),!Kt(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),qt(o)&&n===Et&&St(19),o=Bt(o,n),Kt(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(Ut(e))return e.map(u);if(Wt(e))return new Map(Array.from(e.entries()).map(([e,t])=>[e,u(t)]));if(Gt(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}fn(sn,{applyPatches_:l,generatePatches_:i,generateReplacementPatches_:c,getPath:e})}function Vn(){class e extends Map{constructor(e,t){super(),this[N]={type_:2,parent_:t,scope_:t?t.scope_:P(),modified_:!1,finalized_:!1,copy_:void 0,assigned_:void 0,base_:e,draft_:this,isManual_:!1,revoked_:!1,callbacks_:[]}}get size(){return Zt(this[N]).size}has(e){return Zt(this[N]).has(e)}set(e,t){let r=this[N];return o(r),(!Zt(r).has(e)||Zt(r).get(e)!==t)&&(n(r),Pn(r),r.assigned_.set(e,!0),r.copy_.set(e,t),r.assigned_.set(e,!0),Dn(r,e,t)),this}delete(e){if(!this.has(e))return!1;let t=this[N];return o(t),n(t),Pn(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),Zt(e).size&&(n(e),Pn(e),e.assigned_=new Map,Lt(e.base_,t=>{e.assigned_.set(t,!1)}),e.copy_.clear())}forEach(e,t){let n=this[N];Zt(n).forEach((n,r,i)=>{e.call(t,this.get(r),r,this)})}get(e){let t=this[N];o(t);let r=Zt(t).get(e);if(t.finalized_||!Mt(r)||r!==t.base_.get(e))return r;let i=Ln(t.scope_,r,t,e);return n(t),t.copy_.set(e,i),i}keys(){return Zt(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_:P(),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 Zt(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),Pn(t),t.copy_.add(e),Dn(t,e,e)),this}delete(e){if(!this.has(e))return!1;let t=this[N];return o(t),a(t),Pn(t),t.copy_.delete(e)||(t.drafts_.has(e)?t.copy_.delete(t.drafts_.get(e)):!1)}clear(){let e=this[N];o(e),Zt(e).size&&(a(e),Pn(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=Ln(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(Zt(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(Qt(t))})}}fn(on,{proxyMap_:t,proxySet_:i,fixSetContents:s})}var Hn=new In().produce,Un=e=>(t,n,r)=>(r.setState=(e,n,...r)=>t(typeof e==`function`?Hn(e):e,n,...r),e(r.setState,n,r)),Wn={$:`variable`,_:`temporary`,\"@\":`local`,\"%\":`transient`},Gn=Object.fromEntries(Object.entries(Wn).map(([e,t])=>[t,e])),Kn=new Set(Object.keys(Wn));function qn(e){return e!==void 0&&Kn.has(e)}function Jn(e,t){return t.className&&(e.className=t.className),t.id&&(e.id=t.id),e}var Yn={SIGIL_SCOPES:Wn,withSelectors:Jn},Xn=`{`,Zn=`}`,{SIGIL_SCOPES:Qn,withSelectors:$n}=Yn,er=new Set([`area`,`base`,`br`,`col`,`embed`,`hr`,`img`,`input`,`link`,`meta`,`param`,`source`,`track`,`wbr`]),tr={elseif:`if`,else:`if`,case:`switch`,default:`switch`,next:`timed`},nr=new Set([`if`,`switch`,`timed`]),rr=[[`|`,!1],[`->`,!1],[`<-`,!0]],ir={},ar=/^<[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 or(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 rr){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 sr(e){return`\"`+e.replace(/[\\\\\"]/g,`\\\\$&`)+`\"`}function cr(e){let t=[],n=``;for(let[r,i]of e)i&&(r===`.`?t.push(i):n=i);return $n({},{className:t.join(` `),id:n})}function lr(e){return e.lex===`html`?(e.isClose?`</`:`<`)+e.tag+`>`:Xn+(e.isClose?`/`:``)+e.name+Zn}function ur(e){return e.lex===`html`?`</`+e.tag+`>`:Xn+`/`+e.name+Zn}function dr(e){return`line `+e.start.line+`, column `+e.start.column}function fr(e,t){return e.lex===t.lex&&e.lower===t.lower}function pr(e,t,n){return n.lex=e,n.start=t.start.offset,n.end=t.end.offset,n.loc=t,n}function mr(e){switch(e.lex){case`text`:return{type:`text`,value:e.value};case`link`:return $n({type:`macro`,name:`link`,rawArgs:sr(e.display)+` `+sr(e.target),children:[]},e);case`variable`:return $n({type:`variable`,name:e.name,scope:e.scope},e);case`expression`:return $n({type:`expression`,expression:e.expression},e);default:return e}}function hr(e){let t={start:e.start,end:e.end};switch(e.lex){case`text`:return{type:`text`,value:e.value,...t};case`link`:return $n({type:`link`,display:e.display,target:e.target,targetStart:e.targetStart,targetEnd:e.targetEnd,...t},e);case`variable`:return $n({type:`variable`,name:e.name,scope:e.scope,...t},e);case`expression`:return $n({type:`expression`,expression:e.expression,...t},e);case`macro`:return $n({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 gr(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&&r&&r.lex===`text`&&!r.escape&&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 _r=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 vr(e,t){t=t===void 0?{}:t;let n={},r=t.grammarSource,i={Markup:An,Tokens:Hn,SelectorsPrefix:yr},a=An,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=wn(),D=Cn([`\\\\`,`{`,`[`,`<`],!0,!1,!1),O=Sn(`\\x3C!--`,!1),te=Sn(`>`,!1),ne=Sn(`->`,!1),re=Sn(`-->`,!1),k=Sn(`\\\\`,!1),ie=Cn([`{`,`}`],!1,!1,!1),ae=Sn(`{`,!1),oe=Cn([`$`,`_`,`@`,`%`,`(`,`!`,`/`,[`a`,`z`],[`A`,`Z`]],!1,!1,!1),se=Sn(`<`,!1),ce=Sn(`[`,!1),le=Sn(`[[`,!1),ue=Sn(`]]`,!1),de=Sn(` `,!1),fe=Cn([`.`,`#`],!1,!1,!1),pe=Cn([[`a`,`z`],[`A`,`Z`],[`0`,`9`],`_`,`-`],!1,!1,!1),me=Cn([`$`,`_`,`@`,`%`],!1,!1,!1),he=Cn([[`a`,`z`],[`A`,`Z`],[`0`,`9`],`_`,`.`],!1,!1,!1),ge=Sn(`}`,!1),_e=Cn([`$`,`_`,`@`,`%`,`(`,`!`],!1,!1,!1),A=Sn(`/`,!1),ve=Cn([[`a`,`z`],[`A`,`Z`]],!1,!1,!1),ye=Cn([` `,`\t`,`\n`,`\\r`,`\\v`,`\\f`,`\\xA0`,` `,[` `,` `],`\\u2028`,`\\u2029`,` `,` `,` `,``,`}`],!0,!1,!1),be=Cn([[`a`,`z`],[`A`,`Z`],[`0`,`9`],`.`,`!`,`#`,`$`,`%`,`&`,`'`,`*`,`+`,`/`,`=`,`?`,`^`,`_`,\"`\",`|`,`~`,`-`],!1,!1,!1),xe=Sn(`@`,!1),Se=Cn([[`a`,`z`],[`A`,`Z`],[`0`,`9`],`.`,`-`],!1,!1,!1),Ce=Cn([[`\t`,`\\r`],` `,`/`,`>`,`\\xA0`,` `,[` `,` `],[`\\u2028`,`\\u2029`],` `,` `,` `,``],!1,!1,!1),we=Sn(`</`,!1),Te=Cn([[`a`,`z`],[`A`,`Z`],[`0`,`9`],`-`],!1,!1,!1),Ee=Cn([[`\t`,`\\r`],` `,`\"`,`'`,`/`,[`<`,`>`],`{`,`}`,`\\xA0`,` `,[` `,` `],[`\\u2028`,`\\u2029`],` `,` `,` `,``],!1,!1,!1),De=Sn(`=`,!1),Oe=Sn(`\"`,!1),ke=Cn([`\"`],!0,!1,!1),Ae=Sn(`'`,!1),je=Cn([`'`],!0,!1,!1),Me=Cn([`\"`,`'`],!1,!1,!1),Ne=Cn([` `,`\t`,`\n`,`\\r`,`\\v`,`\\f`,`\\xA0`,` `,[` `,` `],`\\u2028`,`\\u2029`,` `,` `,` `,``,`>`],!0,!1,!1),j=Cn([` `,`\t`,`\n`,`\\r`,`\\v`,`\\f`,`\\xA0`,` `,[` `,` `],`\\u2028`,`\\u2029`,` `,` `,` `,``],!1,!1,!1);function Pe(e){return e}function Fe(e){z(lr(e)+` must be directly inside {`+tr[e.lower]+Zn,e.loc)}function M(e){z(lr(e)+` closes nothing: no `+(e.lex===`html`?`<`+e.tag+`>`:Xn+e.name+Zn)+` is open here`,e.loc)}function Ie(e){return gr(e,mr)}function Le(e){return e.kind===`open`}function Re(e){return zr=e.lower,R.isRaw(zr)}function ze(e,t){return t}function Be(e){return R.isBlock(e.lower)}function Ve(e,t){return t}function He(e){return null}function Ue(e,t){return Hr(e,t)}function We(){return!Ir}function Ge(e){return!e.isSelfClose}function Ke(e,t){return t}function qe(e,t){let n={type:`html`,tag:e.tag,attributes:e.attributes,children:[]};return t&&(Vr(e,t),n.children=t.children),n}function Je(e,t,n){return{children:e,branches:t,end:n}}function Ye(e,t){return{tag:e,children:t}}function Xe(){return null}function Ze(e){return e.kind===`branch`}function Qe(e){return e}function $e(e){return e.kind===`close`}function et(e){return e}function tt(){return!Ir}function nt(e){return e}function rt(t){return Br(R.rawBodyEnd(e,t,zr))}function it(e){return Lr-vn()}function at(e,t,n){return{children:t?[{type:`text`,value:t}]:[],branches:[],end:n}}function ot(){return{children:[],branches:[],end:null}}function st(e){return gr(e,hr)}function ct(){return!Ir}function lt(e){return e}function ut(){return!Ir}function dt(e){return er.has(e.lower)?null:e}function ft(e){return zr=e.lower,e.kind===`open`&&R.isRaw(zr)}function pt(e,t){return t}function mt(e,t){return t?[e,t]:e}function ht(t){return Br(R.rawBodyEnd(e,t,zr))}function gt(e){return Lr-vn()}function _t(e,t,n){let r={start:{offset:e},end:{offset:e+t.length}};return[t?pr(`text`,r,{value:t}):null,n]}function vt(){return vn()}function yt(e){return pr(`text`,yn(),{value:e})}function bt(e){return pr(`text`,yn(),{value:e})}function xt(e){return e.length%2==1}function N(e,t){return t}function St(t,n){let r=yn(),i=e.charAt(r.end.offset);if(Ir){if(!n&&i!==Xn&&i!==Zn)return pr(`text`,r,{value:t});let e=pr(`text`,r,{value:`\\\\`.repeat(t.length>>1)+(n||``)});return e.escape=!0,e}if(!n)return pr(`text`,r,{value:t});let a=pr(`text`,r,{value:t.slice(1)});a.end=r.end.offset-2;let o=pr(`text`,r,{value:n});return o.start=r.end.offset-2,o.escape=!0,t.length>1?[a,o]:o}function Ct(){return pr(`text`,yn(),{value:Xn})}function wt(){return!Ir}function Tt(){return pr(`text`,yn(),{value:`<`})}function Et(){return pr(`text`,yn(),{value:`[`})}function Dt(){return!Ir}function Ot(e,t,n){return $n(pr(`link`,yn(),or(n,t)),e)}function kt(){return!Ir}function At(){z(`Unclosed link: [[ without ]]`,yn())}function jt(e){return cr(e)}function Mt(){return ir}function Nt(e,t){return{...e,end:t}}function Pt(e,t){return[e,t]}function Ft(e,t,n){return $n(pr(`variable`,yn(),{name:n,scope:Qn[t]}),e)}function It(e,t){return $n(pr(`expression`,yn(),{expression:t}),e)}function Lt(){z(`Unclosed `+Xn+e.substr(yn().end.offset,1)+`…: no } ends it`,yn())}function Rt(t){return Br(R.closeBrace(e,t,t))}function zt(e){return Lr-vn()}function Bt(e,t){return t}function Vt(t,n,r,i,a){return Br(R.closeBrace(e,a,n))}function Ht(e,t,n,r,i){return Lr-vn()}function Ut(e,t,n,r,i,a){return a}function Wt(e,t,n,r,i,a){let o=yn(),s=r.toLowerCase(),c=pr(`macro`,o,{name:r,lower:s,rawArgs:``,isClose:!!n});return a===null&&z(`Unclosed `+Xn+(n?`/`:``)+r+`…: no } ends the macro`,o),c.rawArgs=a.trim(),n?(e!==ir&&z(`A closing tag takes no selectors: `+lr(c),o),c.rawArgs&&z(`A closing tag takes no arguments: `+Xn+`/`+r+` `+c.rawArgs+Zn,o),c.kind=`close`):($n(c,e),c.kind=Object.prototype.hasOwnProperty.call(tr,s)?`branch`:`open`),c}function Gt(e){z(`A closing tag starts with a letter after `+Xn+`/`,yn())}function Kt(e){return ar.test(e)}function qt(e){return pr(`text`,yn(),{value:e})}function Jt(){return!Ir}function Yt(e){return er.has(e.lower)}function Xt(e){return null}function Zt(e,t,n){let r=e.toLowerCase();return pr(`html`,yn(),{tag:e,lower:r,attributes:B(t),isClose:!1,isSelfClose:!!n||er.has(r)})}function Qt(t,n){let r=e.charAt(n);r||z(`Unclosed tag <`+t+`: no > ends it (write < for a < that starts no tag)`,yn());let i={source:yn().source,start:{offset:n,line:0,column:0},end:{offset:n+1,line:0,column:0}};z(`Unexpected `+JSON.stringify(r)+` in the tag <`+t+`>: expected an attribute, or > to end the tag`,i)}function $t(e){return pr(`html`,yn(),{tag:e,lower:e.toLowerCase(),attributes:{},isClose:!0,isSelfClose:!1})}function en(e){return Rr=R.isCodeAttribute(e),!0}function tn(e,t){return t}function nn(e,t){return[e,t??``]}function rn(e){return e}function an(e){return e}function on(e){z(`Unclosed attribute value: the `+e+` here has no closing `+e,yn())}function sn(){return!Rr}function cn(e){return e.length%2==1}function ln(){return!Rr}function un(t,n){return Br(R.closeBrace(e,n,t))}function dn(e,t){return Lr-vn()}function fn(){return!Rr}function pn(){return Rr}let P=t.peg$currPos|0,F=P,mn=[{line:1,column:1}],hn=P,gn=t.peg$maxFailExpected||[],I=t.peg$silentFails|0,_n;if(t.startRule){if(!(t.startRule in i))throw Error(`Can't start parsing from rule \"`+t.startRule+`\".`);a=i[t.startRule]}function vn(){return F}function yn(){return Dn(F,P)}function bn(e,t){throw t=t===void 0?Dn(F,P):t,On(e,t)}function xn(t=P){let n=e.codePointAt(t);return n===void 0?``:String.fromCodePoint(n)}function Sn(e,t){return{type:`literal`,text:e,ignoreCase:t}}function Cn(e,t,n,r){return{type:`class`,parts:e,inverted:t,ignoreCase:n,unicode:r}}function wn(){return{type:`any`}}function Tn(){return{type:`end`}}function En(t){let n=mn[t],r;if(n)return n;if(t>=mn.length)r=mn.length-1;else for(r=t;!mn[--r];);for(n=mn[r],n={line:n.line,column:n.column};r<t;)e.charCodeAt(r)===10?(n.line++,n.column=1):n.column++,r++;return mn[t]=n,n}function Dn(e,t,n){let i=En(e),a=En(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<hn||(P>hn&&(hn=P,gn=[]),gn.push(e))}function On(e,t){return new _r(e,null,null,t)}function kn(e,t,n){return new _r(_r.buildMessage(e,t),e,t,n)}function An(){let e,t,r;return e=P,t=Mn(),r=jn(),r===n?(P=e,e=n):(F=e,e=Pe(t)),e}function jn(){let t,r;return t=P,I++,e.length>P?(r=e.charAt(P),P++):(r=n,I===0&&L(E)),I--,r===n?t=void 0:(P=t,t=n),t===n&&(t=P,r=zn(),r!==n&&(F=t,r=Fe(r)),t=r,t===n&&(t=P,r=Bn(),r!==n&&(F=t,r=M(r)),t=r)),t}function Mn(){let e,t,r;for(e=P,t=[],r=Nn();r!==n;)t.push(r),r=Nn();return F=e,t=Ie(t),e=t,e}function Nn(){let e;return e=Kn(),e===n&&(e=Jn(),e===n&&(e=qn(),e===n&&(e=rr(),e===n&&(e=Er(),e===n&&(e=Fn(),e===n&&(e=Dr(),e===n&&(e=Sr(),e===n&&(e=Pn(),e===n&&(e=Yn()))))))))),e}function Pn(){let e,t,r,i,a,o;return e=P,t=wr(),t===n?(P=e,e=n):(F=P,r=Le(t),r=r?void 0:n,r===n?(P=e,e=n):(i=P,F=P,a=Re(t),a=a?void 0:n,a===n?(P=i,i=n):(o=Vn(),o===n?(P=i,i=n):(F=i,i=ze(t,o))),i===n&&(i=P,F=P,a=Be(t),a=a?void 0:n,a===n?(P=i,i=n):(o=In(),o===n?(P=i,i=n):(F=i,i=Ve(t,o))),i===n&&(i=P,a=``,F=i,a=He(t),i=a)),i===n?(P=e,e=n):(F=e,e=Ue(t,i)))),e}function Fn(){let e,t,r,i,a,o;return e=P,F=P,t=We(),t=t?void 0:n,t===n?(P=e,e=n):(r=Or(),r===n?(P=e,e=n):(i=P,F=P,a=Ge(r),a=a?void 0:n,a===n?(P=i,i=n):(o=In(),o===n?(P=i,i=n):(F=i,i=Ke(r,o))),i===n&&(i=null),F=e,e=qe(r,i))),e}function In(){let e,t,r,i;if(e=P,t=Mn(),t!==n){for(r=[],i=Ln();i!==n;)r.push(i),i=Ln();i=Rn(),i===n?(P=e,e=n):(F=e,e=Je(t,r,i))}else P=e,e=n;return e}function Ln(){let e,t,r;return e=P,t=zn(),t===n?(P=e,e=n):(r=Mn(),r===n?(P=e,e=n):(F=e,e=Ye(t,r))),e}function Rn(){let t,r,i;return t=Bn(),t===n&&(t=P,r=P,I++,e.length>P?(i=e.charAt(P),P++):(i=n,I===0&&L(E)),I--,i===n?r=void 0:(P=r,r=n),r!==n&&(F=t,r=Xe()),t=r),t}function zn(){let e,t,r;return e=P,t=wr(),t===n?(P=e,e=n):(F=P,r=Ze(t),r=r?void 0:n,r===n?(P=e,e=n):(F=e,e=Qe(t))),e}function Bn(){let e,t,r;return e=P,t=wr(),t===n?(P=e,e=n):(F=P,r=$e(t),r=r?void 0:n,r===n?(P=e,e=n):(F=e,e=et(t))),e===n&&(e=P,F=P,t=tt(),t=t?void 0:n,t===n?(P=e,e=n):(r=kr(),r===n?(P=e,e=n):(F=e,e=nt(r)))),e}function Vn(){let t,r,i,a,o,s,c,l;if(t=P,r=Gn(),F=P,i=rt(r),i=i?void 0:n,i!==n){for(a=P,o=it(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=Bn(),o===n?(P=t,t=n):(F=t,t=at(r,a,o)))}else P=t,t=n;return t===n&&(t=P,r=``,F=t,r=ot(),t=r),t}function Hn(){let e,t,r;for(e=P,t=[],r=Un();r!==n;)t.push(r),r=Un();return F=e,t=st(t),e=t,e}function Un(){let e,t,r,i,a;return e=Kn(),e===n&&(e=Jn(),e===n&&(e=qn(),e===n&&(e=rr(),e===n&&(e=Er(),e===n&&(e=P,F=P,t=ct(),t=t?void 0:n,t===n?(P=e,e=n):(r=Or(),r===n?(P=e,e=n):(F=e,e=lt(r))),e===n&&(e=P,F=P,t=ut(),t=t?void 0:n,t===n?(P=e,e=n):(r=kr(),r===n?(P=e,e=n):(F=e,e=dt(r))),e===n&&(e=Sr(),e===n&&(e=P,t=wr(),t===n?(P=e,e=n):(r=P,F=P,i=ft(t),i=i?void 0:n,i===n?(P=r,r=n):(a=Wn(),a===n?(P=r,r=n):(F=r,r=pt(t,a))),r===n&&(r=null),F=e,e=mt(t,r)),e===n&&(e=Yn()))))))))),e}function Wn(){let t,r,i,a,o,s,c,l;if(t=P,r=Gn(),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):(o=Bn(),o===n?(P=t,t=n):(F=t,t=_t(r,a,o)))}else P=t,t=n;return t}function Gn(){let e,t;return e=P,t=``,F=e,t=vt(),e=t,e}function Kn(){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=yt(r)),t=r,t}function qn(){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=bt(r)),t=r,t}function Jn(){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=xt(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=N(r,o))),i===n&&(i=null),F=t,t=St(r,i)),t}function Yn(){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=vr(),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=Ct())),t===n&&(t=P,r=P,I++,i=P,F=P,a=wt(),a=a?void 0:n,a===n?(P=i,i=n):(o=kr(),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=Tt())),t===n&&(t=P,e.charCodeAt(P)===91?(r=`[`,P++):(r=n,I===0&&L(ce)),r!==n&&(F=t,r=Et()),t=r)),t}function rr(){let t,r,i,a,o,s,c;return t=P,F=P,r=Dt(),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=vr(),a===n?(P=t,t=n):(o=Gn(),s=P,c=sr(),s=e.substring(s,P),e.substr(P,2)===`]]`?(c=`]]`,P+=2):(c=n,I===0&&L(ue)),c===n?(P=t,t=n):(F=t,t=Ot(a,o,s))))),t===n&&(t=P,F=P,r=kt(),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=At()))),t}function sr(){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 vr(){let t,r,i;if(t=P,r=[],i=br(),i!==n)for(;i!==n;)r.push(i),i=br();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=jt(r)),t===n&&(t=P,r=``,F=t,r=Mt(),t=r),t}function yr(){let t,r,i,a,o;if(t=P,r=vr(),r!==n){for(i=Gn(),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=Nt(r,i)}else P=t,t=n;return t}function br(){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=xr();o!==n;)a.push(o),o=xr();i=e.substring(i,P),F=t,t=Pt(r,i)}else P=t,t=n;return t}function xr(){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 Sr(){let t,r,i,a,o,s,c;if(t=P,e.charCodeAt(P)===123?(r=`{`,P++):(r=n,I===0&&L(ae)),r!==n)if(i=vr(),i!==n)if(a=e.charAt(P),f.test(a)?P++:(a=n,I===0&&L(me)),a!==n){for(o=P,s=[],c=e.charAt(P),p.test(c)?P++:(c=n,I===0&&L(he));c!==n;)s.push(c),c=e.charAt(P),p.test(c)?P++:(c=n,I===0&&L(he));o=e.substring(o,P),e.charCodeAt(P)===125?(s=`}`,P++):(s=n,I===0&&L(ge)),s===n?(P=t,t=n):(F=t,t=Ft(i,a,o))}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=vr(),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):(o=Cr(),o===n?(P=t,t=n):(e.charCodeAt(P)===125?(s=`}`,P++):(s=n,I===0&&L(ge)),s===n?(P=t,t=n):(F=t,t=It(i,o)))))),t===n&&(t=P,e.charCodeAt(P)===123?(r=`{`,P++):(r=n,I===0&&L(ae)),r===n?(P=t,t=n):(i=vr(),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=Lt()))))),t}function Cr(){let t,r,i,a,o,s,c,l;if(t=P,r=Gn(),F=P,i=Rt(r),i=i?void 0:n,i!==n){for(a=P,o=zt(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=Bt(r,a))}else P=t,t=n;return t}function wr(){let t,r,i,a,o,s,c,l,u,d,f,p,m,h;if(t=P,e.charCodeAt(P)===123?(r=`{`,P++):(r=n,I===0&&L(ae)),r!==n)if(i=vr(),i!==n)if(a=Gn(),e.charCodeAt(P)===47?(o=`/`,P++):(o=n,I===0&&L(A)),o===n&&(o=null),s=Tr(),s!==n){if(c=Gn(),l=P,F=P,u=Vt(i,a,o,s,c),u=u?void 0:n,u!==n){for(d=P,f=Ht(i,a,o,s,c),p=P,m=[],m.length>=(f|0)?h=n:e.length>P?(h=e.charAt(P),P++):(h=n,I===0&&L(E));h!==n;)m.push(h),m.length>=(f|0)?h=n:e.length>P?(h=e.charAt(P),P++):(h=n,I===0&&L(E));m.length<(f|0)?(P=p,p=n):p=m,f=p,d=f===n?f:e.substring(d,P),d===n?(P=l,l=n):(e.charCodeAt(P)===125?(f=`}`,P++):(f=n,I===0&&L(ge)),f===n?(P=l,l=n):(F=l,l=Ut(i,a,o,s,c,d)))}else P=l,l=n;l===n&&(l=null),F=t,t=Wt(i,a,o,s,c,l)}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=vr(),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=Gt(i))))),t}function Tr(){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 Er(){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=Kt(r),i=i?void 0:n,i===n?(P=t,t=n):(F=t,t=qt(r))),t}function Dr(){let e,t,r,i;return e=P,F=P,t=Jt(),t=t?void 0:n,t===n?(P=e,e=n):(r=kr(),r===n?(P=e,e=n):(F=P,i=Yt(r),i=i?void 0:n,i===n?(P=e,e=n):(F=e,e=Xt(r)))),e}function Or(){let t,r,i,a,o,s,c;if(t=P,e.charCodeAt(P)===60?(r=`<`,P++):(r=n,I===0&&L(se)),r!==n)if(i=Ar(),i!==n){for(a=[],o=jr();o!==n;)a.push(o),o=jr();o=Pr(),e.charCodeAt(P)===47?(s=`/`,P++):(s=n,I===0&&L(A)),s===n&&(s=null),e.charCodeAt(P)===62?(c=`>`,P++):(c=n,I===0&&L(te)),c===n?(P=t,t=n):(F=t,t=Zt(i,a,s))}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=Ar(),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=jr();s!==n;)o.push(s),s=jr();s=Pr(),c=Gn(),F=t,t=Qt(i,c)}else P=t,t=n;else P=t,t=n;else P=t,t=n;return t}function kr(){let t,r,i,a;return t=P,e.substr(P,2)===`</`?(r=`</`,P+=2):(r=n,I===0&&L(we)),r===n?(P=t,t=n):(i=Ar(),i===n?(P=t,t=n):(Pr(),e.charCodeAt(P)===62?(a=`>`,P++):(a=n,I===0&&L(te)),a===n?(P=t,t=n):(F=t,t=$t(i)))),t}function Ar(){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 jr(){let t,r,i,a,o,s,c;if(t=P,Pr(),r=P,i=[],a=P,o=P,I++,s=e.charAt(P),x.test(s)?P++:(s=n,I===0&&L(Ee)),I--,s===n?o=void 0:(P=o,o=n),o===n?(P=a,a=n):(e.length>P?(s=e.charAt(P),P++):(s=n,I===0&&L(E)),s===n?(P=a,a=n):(o=[o,s],a=o)),a!==n)for(;a!==n;)i.push(a),a=P,o=P,I++,s=e.charAt(P),x.test(s)?P++:(s=n,I===0&&L(Ee)),I--,s===n?o=void 0:(P=o,o=n),o===n?(P=a,a=n):(e.length>P?(s=e.charAt(P),P++):(s=n,I===0&&L(E)),s===n?(P=a,a=n):(o=[o,s],a=o));else i=n;return r=i===n?i:e.substring(r,P),r===n?(P=t,t=n):(F=P,i=en(r),i=i?void 0:n,i===n?(P=t,t=n):(a=P,o=Pr(),e.charCodeAt(P)===61?(s=`=`,P++):(s=n,I===0&&L(De)),s===n?(P=a,a=n):(Pr(),c=Mr(),c===n?(P=a,a=n):(F=a,a=tn(r,c))),a===n&&(a=null),F=t,t=nn(r,a))),t}function Mr(){let t,r,i,a,o;if(t=P,e.charCodeAt(P)===34?(r=`\"`,P++):(r=n,I===0&&L(Oe)),r!==n){for(i=P,a=[],o=Nr(),o===n&&(o=e.charAt(P),S.test(o)?P++:(o=n,I===0&&L(ke)));o!==n;)a.push(o),o=Nr(),o===n&&(o=e.charAt(P),S.test(o)?P++:(o=n,I===0&&L(ke)));i=e.substring(i,P),e.charCodeAt(P)===34?(a=`\"`,P++):(a=n,I===0&&L(Oe)),a===n?(P=t,t=n):(F=t,t=rn(i))}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=P,a=[],o=Nr(),o===n&&(o=e.charAt(P),C.test(o)?P++:(o=n,I===0&&L(je)));o!==n;)a.push(o),o=Nr(),o===n&&(o=e.charAt(P),C.test(o)?P++:(o=n,I===0&&L(je)));i=e.substring(i,P),e.charCodeAt(P)===39?(a=`'`,P++):(a=n,I===0&&L(Ae)),a===n?(P=t,t=n):(F=t,t=an(i))}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=on(r)),t=r,t===n)){for(t=P,r=[],i=e.charAt(P),T.test(i)?P++:(i=n,I===0&&L(Ne));i!==n;)r.push(i),i=e.charAt(P),T.test(i)?P++:(i=n,I===0&&L(Ne));t=e.substring(t,P)}}return t}function Nr(){let t,r,i,a,o,s,l,u,d,p,m,g,_,v;if(t=P,F=P,r=sn(),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=cn(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=ln(),r=r?void 0:n,r!==n)if(e.charCodeAt(P)===123?(i=`{`,P++):(i=n,I===0&&L(ae)),i!==n)if(a=vr(),a!==n)if(o=Gn(),e.charCodeAt(P)===47?(s=`/`,P++):(s=n,I===0&&L(A)),s===n&&(s=null),l=Tr(),l!==n)if(u=Gn(),F=P,d=un(o,u),d=d?void 0:n,d!==n){for(p=P,m=dn(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=fn(),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=vr(),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=Cr(),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=pn(),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=Cr(),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 Pr(){let e,t;for(e=[],t=Fr();t!==n;)e.push(t),t=Fr();return e}function Fr(){let t;return t=e.charAt(P),ee.test(t)?P++:(t=n,I===0&&L(j)),t}let Ir=t.text===!0,R=t.hooks,Lr=-1,Rr=!1,zr=``;function Br(e){return Lr=e,e>=0}function z(e,t){bn(e,t)}function B(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 Vr(e,t){for(let n of t.branches){let t=tr[n.tag.lower];(e.lex!==`macro`||e.lower!==t)&&z(lr(n.tag)+` must be directly inside {`+t+Zn+`, not inside `+lr(e),n.tag.loc)}t.end||z(`Unclosed `+lr(e)+`: no `+ur(e)+` closes it`,e.loc),fr(e,t.end)||z(lr(t.end)+` found where `+ur(e)+` should close the `+lr(e)+` opened at `+dr(e.loc),t.end.loc)}function Hr(e,t){let n={type:`macro`,name:e.lower,rawArgs:e.rawArgs,children:[]};if(!t)return $n(n,e);if(Vr(e,t),n.children=t.children,nr.has(e.lower)){n.branches=[$n({rawArgs:e.rawArgs,children:t.children},e)];for(let e of t.branches)n.branches.push($n({rawArgs:e.tag.rawArgs,children:e.children},e.tag));n.children=[]}else $n(n,e);return n}_n=a();let Ur=_n!==n&&P===e.length;function Wr(){throw _n!==n&&P<e.length&&L(Tn()),kn(gn,hn<e.length?xn(hn):null,hn<e.length?Dn(hn,hn+1):Dn(hn,hn))}if(t.peg$library)return{peg$result:_n,peg$currPos:P,peg$FAILED:n,peg$maxFailExpected:gn,peg$maxFailPos:hn,peg$success:Ur,peg$throw:Ur?void 0:Wr};if(Ur)return _n;Wr()}var yr=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())}},br=class{constructor(e=[]){this.names=new yr;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)}},xr=new br([`if`,`for`,`do`,`button`,`link`,`listbox`,`cycle`,`switch`,`timed`,`repeat`,`type`,`widget`,`span`,`nobr`]);function Sr(e){return xr.has(e)}function Cr(e){xr.add(e)}var wr=[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],Tr=[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],Er=`·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄ-ؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߽߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛-࢟࣊-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯৾ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍-ୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఄ఼ా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ೳഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ඁ-ඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ຼ່-໎໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜕ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠏-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᪿ-ᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭᳴᳷-᳹᷀-᷿‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯・꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧ꠬ꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱ꣿ-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_・`,Dr=`ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙՠ-ֈא-תׯ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࡰ-ࢇࢉ-ࢠ-ࣉऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౝౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽ-ೞೠೡೱೲഄ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄຆ-ຊຌ-ຣລວ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜑᜟ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡸᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭌᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-Ა-ᲺᲽ-Ჿᳩ-ᳬᳮ-ᳳᳵᳶᳺᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿ-ℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆿㇰ-ㇿ㐀-䶿一-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ--ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꣾꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭩꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ`,Or={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`},kr=`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`,Ar={5:kr,\"5module\":kr+` export import`,6:kr+` const class extends export import super`},jr=/^in(stanceof)?$/,Mr=RegExp(`[`+Dr+`]`),Nr=RegExp(`[`+Dr+Er+`]`);function Pr(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 Fr(e,t){return e<65?e===36:e<91?!0:e<97?e===95:e<123?!0:e<=65535?e>=170&&Mr.test(String.fromCharCode(e)):t===!1?!1:Pr(e,Tr)}function Ir(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&&Nr.test(String.fromCharCode(e)):t===!1?!1:Pr(e,Tr)||Pr(e,wr)}var R=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 Lr(e,t){return new R(e,{beforeExpr:!0,binop:t})}var Rr={beforeExpr:!0},zr={startsExpr:!0},Br={};function z(e,t){return t===void 0&&(t={}),t.keyword=e,Br[e]=new R(e,t)}var B={num:new R(`num`,zr),regexp:new R(`regexp`,zr),string:new R(`string`,zr),name:new R(`name`,zr),privateId:new R(`privateId`,zr),eof:new R(`eof`),bracketL:new R(`[`,{beforeExpr:!0,startsExpr:!0}),bracketR:new R(`]`),braceL:new R(`{`,{beforeExpr:!0,startsExpr:!0}),braceR:new R(`}`),parenL:new R(`(`,{beforeExpr:!0,startsExpr:!0}),parenR:new R(`)`),comma:new R(`,`,Rr),semi:new R(`;`,Rr),colon:new R(`:`,Rr),dot:new R(`.`),question:new R(`?`,Rr),questionDot:new R(`?.`),arrow:new R(`=>`,Rr),template:new R(`template`),invalidTemplate:new R(`invalidTemplate`),ellipsis:new R(`...`,Rr),backQuote:new R(\"`\",zr),dollarBraceL:new R(\"${\",{beforeExpr:!0,startsExpr:!0}),eq:new R(`=`,{beforeExpr:!0,isAssign:!0}),assign:new R(`_=`,{beforeExpr:!0,isAssign:!0}),incDec:new R(`++/--`,{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new R(`!/~`,{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:Lr(`||`,1),logicalAND:Lr(`&&`,2),bitwiseOR:Lr(`|`,3),bitwiseXOR:Lr(`^`,4),bitwiseAND:Lr(`&`,5),equality:Lr(`==/!=/===/!==`,6),relational:Lr(`</>/<=/>=`,7),bitShift:Lr(`<</>>/>>>`,8),plusMin:new R(`+/-`,{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:Lr(`%`,10),star:Lr(`*`,10),slash:Lr(`/`,10),starstar:new R(`**`,{beforeExpr:!0}),coalesce:Lr(`??`,1),_break:z(`break`),_case:z(`case`,Rr),_catch:z(`catch`),_continue:z(`continue`),_debugger:z(`debugger`),_default:z(`default`,Rr),_do:z(`do`,{isLoop:!0,beforeExpr:!0}),_else:z(`else`,Rr),_finally:z(`finally`),_for:z(`for`,{isLoop:!0}),_function:z(`function`,zr),_if:z(`if`),_return:z(`return`,Rr),_switch:z(`switch`),_throw:z(`throw`,Rr),_try:z(`try`),_var:z(`var`),_const:z(`const`),_while:z(`while`,{isLoop:!0}),_with:z(`with`),_new:z(`new`,{beforeExpr:!0,startsExpr:!0}),_this:z(`this`,zr),_super:z(`super`,zr),_class:z(`class`,zr),_extends:z(`extends`,Rr),_export:z(`export`),_import:z(`import`,zr),_null:z(`null`,zr),_true:z(`true`,zr),_false:z(`false`,zr),_in:z(`in`,{beforeExpr:!0,binop:7}),_instanceof:z(`instanceof`,{beforeExpr:!0,binop:7}),_typeof:z(`typeof`,{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:z(`void`,{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:z(`delete`,{beforeExpr:!0,prefix:!0,startsExpr:!0})},Vr=/\\r\\n?|\\n|\\u2028|\\u2029/,Hr=new RegExp(Vr.source,`g`);function Ur(e){return e===10||e===13||e===8232||e===8233}function Wr(e,t,n){n===void 0&&(n=e.length);for(var r=t;r<n;r++){var i=e.charCodeAt(r);if(Ur(i))return r<n-1&&i===13&&e.charCodeAt(r+1)===10?r+2:r+1}return-1}var Gr=/[\\u1680\\u2000-\\u200a\\u202f\\u205f\\u3000\\ufeff]/,Kr=/(?:\\s|\\/\\/.*|\\/\\*[^]*?\\*\\/)*/g,qr=Object.prototype,Jr=qr.hasOwnProperty,Yr=qr.toString,Xr=Object.hasOwn||(function(e,t){return Jr.call(e,t)}),Zr=Array.isArray||(function(e){return Yr.call(e)===`[object Array]`}),Qr=Object.create(null);function $r(e){return Qr[e]||(Qr[e]=RegExp(`^(?:`+e.replace(/ /g,`|`)+`)$`))}function ei(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}var ti=/(?:[\\uD800-\\uDBFF](?![\\uDC00-\\uDFFF])|(?:[^\\uD800-\\uDBFF]|^)[\\uDC00-\\uDFFF])/,ni=function(e,t){this.line=e,this.column=t};ni.prototype.offset=function(e){return new ni(this.line,this.column+e)};var ri=function(e,t,n){this.start=t,this.end=n,e.sourceFile!==null&&(this.source=e.sourceFile)};function ii(e,t){for(var n=1,r=0;;){var i=Wr(e,r,t);if(i<0)return new ni(n,t-r);++n,r=i}}var ai={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},oi=!1;function si(e){var t={};for(var n in ai)t[n]=e&&Xr(e,n)?e[n]:ai[n];if(t.ecmaVersion===`latest`?t.ecmaVersion=1e8:t.ecmaVersion==null?(!oi&&typeof console==`object`&&console.warn&&(oi=!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),Zr(t.onToken)){var r=t.onToken;t.onToken=function(e){return r.push(e)}}if(Zr(t.onComment)&&(t.onComment=ci(t,t.onComment)),t.sourceType===`commonjs`&&t.allowAwaitOutsideFunction)throw Error(`Cannot use allowAwaitOutsideFunction with sourceType: commonjs`);return t}function ci(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 ri(this,o,s)),e.ranges&&(c.range=[i,a]),t.push(c)}}var li=1,ui=2,di=4,fi=8,pi=16,mi=32,hi=64,gi=128,_i=256,vi=512,yi=1024,bi=li|ui|_i;function xi(e,t){return ui|(e?di:0)|(t?fi:0)}var Si=0,Ci=1,wi=2,Ti=3,Ei=4,Di=5,Oi=function(e,t,n){this.options=e=si(e),this.sourceFile=e.sourceFile,this.keywords=$r(Ar[e.ecmaVersion>=6?6:e.sourceType===`module`?`5module`:5]);var r=``;e.allowReserved!==!0&&(r=Or[e.ecmaVersion>=6?6:e.ecmaVersion===5?5:3],e.sourceType===`module`&&(r+=` await`)),this.reservedWords=$r(r);var i=(r?r+` `:``)+Or.strict;this.reservedWordsStrict=$r(i),this.reservedWordsStrictBind=$r(i+` `+Or.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(Vr).length)):this.lineStart=0,this.type=B.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`?ui:li),this.regexpState=null,this.privateNameStack=[]},ki={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}};Oi.prototype.parse=function(){var e=this,t=this.options.program||this.startNode();return this.nextToken(),this.catchStackOverflow(function(){return e.parseTopLevel(t)})},ki.inFunction.get=function(){return(this.currentVarScope().flags&ui)>0},ki.inGenerator.get=function(){return(this.currentVarScope().flags&fi)>0},ki.inAsync.get=function(){return(this.currentVarScope().flags&di)>0},ki.canAwait.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e].flags;if(t&(_i|vi))return!1;if(t&ui)return(t&di)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction},ki.allowReturn.get=function(){return!!(this.inFunction||this.options.allowReturnOutsideFunction&&this.currentVarScope().flags&li)},ki.allowSuper.get=function(){return(this.currentThisScope().flags&hi)>0||this.options.allowSuperOutsideMethod},ki.allowDirectSuper.get=function(){return(this.currentThisScope().flags&gi)>0},ki.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())},ki.allowNewDotTarget.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e].flags;if(t&(_i|vi)||t&ui&&!(t&pi))return!0}return!1},ki.allowUsing.get=function(){var e=this.currentScope().flags;return!(e&yi||!this.inModule&&e&li)},ki.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&_i)>0},Oi.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},Oi.parse=function(e,t){return new this(t,e).parse()},Oi.parseExpressionAt=function(e,t,n){var r=new this(n,e,t);return r.nextToken(),r.parseExpression()},Oi.tokenizer=function(e,t){return new this(t,e)},Object.defineProperties(Oi.prototype,ki);var Ai=Oi.prototype,ji=/^(?:'((?:\\\\[^]|[^'\\\\])*?)'|\"((?:\\\\[^]|[^\"\\\\])*?)\")/;Ai.strictDirective=function(e){if(this.options.ecmaVersion<5)return!1;for(;;){Kr.lastIndex=e,e+=Kr.exec(this.input)[0].length;var t=ji.exec(this.input.slice(e));if(!t)return!1;if((t[1]||t[2])===`use strict`){Kr.lastIndex=e+t[0].length;var n=Kr.exec(this.input),r=n.index+n[0].length,i=this.input.charAt(r);return i===`;`||i===`}`||Vr.test(n[0])&&!(/[(`.[+\\-/*%<>=,?^&]/.test(i)||i===`!`&&this.input.charAt(r+1)===`=`||i===`i`&&Mi(this,r))}e+=t[0].length,Kr.lastIndex=e,e+=Kr.exec(this.input)[0].length,this.input[e]===`;`&&e++}};function Mi(e,t){for(var n=t+1,r=Math.min(e.input.length,t+11);n<r;){var i=e.fullCharCodeAt(n);if(!Ir(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`}Ai.eat=function(e){return this.type===e?(this.next(),!0):!1},Ai.isContextual=function(e){return this.type===B.name&&this.value===e&&!this.containsEsc},Ai.eatContextual=function(e){return this.isContextual(e)?(this.next(),!0):!1},Ai.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}},Ai.expectContextual=function(e){this.eatContextual(e)||this.unexpected()},Ai.canInsertSemicolon=function(){return this.type===B.eof||this.type===B.braceR||Vr.test(this.input.slice(this.lastTokEnd,this.start))},Ai.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0},Ai.semicolon=function(){!this.eat(B.semi)&&!this.insertSemicolon()&&this.unexpected()},Ai.afterTrailingComma=function(e,t){if(this.type===e)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),t||this.next(),!0},Ai.expect=function(e){this.eat(e)||this.unexpected()},Ai.unexpected=function(e){this.raise(e??this.start,`Unexpected token`)};var Ni=function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};Ai.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`)}},Ai.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`)},Ai.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`)},Ai.isSimpleAssignTarget=function(e){return e.type===`ParenthesizedExpression`?this.isSimpleAssignTarget(e.expression):e.type===`Identifier`||e.type===`MemberExpression`};var V=Oi.prototype;V.parseTopLevel=function(e){var t=Object.create(null);for(e.body||(e.body=[]);this.type!==B.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 Pi={kind:`loop`},Fi={kind:`switch`};V.isLet=function(e){if(this.options.ecmaVersion<6||!this.isContextual(`let`))return!1;Kr.lastIndex=this.pos;var t=Kr.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(Fr(r)){var i=n;do n+=r<=65535?1:2;while(Ir(r=this.fullCharCodeAt(n)));if(r===92)return!0;var a=this.input.slice(i,n);if(!jr.test(a))return!0}return!1},V.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual(`async`))return!1;Kr.lastIndex=this.pos;var e=Kr.exec(this.input),t=this.pos+e[0].length,n;return!Vr.test(this.input.slice(this.pos,t))&&this.input.slice(t,t+8)===`function`&&(t+8===this.input.length||!(Ir(n=this.fullCharCodeAt(t+8))||n===92))},V.isUsingKeyword=function(e,t){if(this.options.ecmaVersion<17||!this.isContextual(e?`await`:`using`))return!1;Kr.lastIndex=this.pos;var n=Kr.exec(this.input),r=this.pos+n[0].length;if(Vr.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||Ir(a=this.fullCharCodeAt(i))||a===92)return!1;Kr.lastIndex=i;var o=Kr.exec(this.input);if(r=i+o[0].length,o&&Vr.test(this.input.slice(i,r)))return!1}var s=this.fullCharCodeAt(r);if(!Fr(s)&&s!==92)return!1;var c=r;do r+=s<=65535?1:2;while(Ir(s=this.fullCharCodeAt(r)));if(s===92)return!0;var l=this.input.slice(c,r);if(jr.test(l))return!1;if(t&&!e&&l===`of`){Kr.lastIndex=r;var u=Kr.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},V.isAwaitUsing=function(e){return this.isUsingKeyword(!0,e)},V.isUsing=function(e){return this.isUsingKeyword(!1,e)},V.parseStatement=function(e,t,n){var r=this.type,i=this.startNode(),a;switch(this.isLet(e)&&(r=B._var,a=`let`),r){case B._break:case B._continue:return this.parseBreakContinueStatement(i,r.keyword);case B._debugger:return this.parseDebuggerStatement(i);case B._do:return this.parseDoStatement(i);case B._for:return this.parseForStatement(i);case B._function:return e&&(this.strict||e!==`if`&&e!==`label`)&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(i,!1,!e);case B._class:return e&&this.unexpected(),this.parseClass(i,!0);case B._if:return this.parseIfStatement(i);case B._return:return this.parseReturnStatement(i);case B._switch:return this.parseSwitchStatement(i);case B._throw:return this.parseThrowStatement(i);case B._try:return this.parseTryStatement(i);case B._const:case B._var:return a=a||this.value,e&&a!==`var`&&this.unexpected(),this.parseVarStatement(i,a);case B._while:return this.parseWhileStatement(i);case B._with:return this.parseWithStatement(i);case B.braceL:return this.parseBlock(!0,i);case B.semi:return this.parseEmptyStatement(i);case B._export:case B._import:if(this.options.ecmaVersion>10&&r===B._import){Kr.lastIndex=this.pos;var o=Kr.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===B._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===B.name&&d.type===`Identifier`&&this.eat(B.colon)?this.parseLabeledStatement(i,u,d,e):this.parseExpressionStatement(i,d)}},V.parseBreakContinueStatement=function(e,t){var n=t===`break`;this.next(),this.eat(B.semi)||this.insertSemicolon()?e.label=null:this.type===B.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`)},V.parseDebuggerStatement=function(e){return this.next(),this.semicolon(),this.finishNode(e,`DebuggerStatement`)},V.parseDoStatement=function(e){return this.next(),this.labels.push(Pi),e.body=this.parseStatement(`do`),this.labels.pop(),this.expect(B._while),e.test=this.parseParenExpression(),this.options.ecmaVersion>=6?this.eat(B.semi):this.semicolon(),this.finishNode(e,`DoWhileStatement`)},V.parseForStatement=function(e){this.next();var t=this.options.ecmaVersion>=9&&this.canAwait&&this.eatContextual(`await`)?this.lastTokStart:-1;if(this.labels.push(Pi),this.enterScope(0),this.expect(B.parenL),this.type===B.semi)return t>-1&&this.unexpected(t),this.parseFor(e,null);var n=this.isLet();if(this.type===B._var||this.type===B._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 Ni,d=this.start,f=t>-1?this.parseExprSubscripts(u,`await`):this.parseExpression(!0,u);return this.type===B._in||(o=this.options.ecmaVersion>=6&&this.isContextual(`of`))?(t>-1?(this.type===B._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))},V.parseForAfterInit=function(e,t,n){return(this.type===B._in||this.options.ecmaVersion>=6&&this.isContextual(`of`))&&t.declarations.length===1?(this.type===B._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))},V.parseFunctionStatement=function(e,t,n){return this.next(),this.parseFunction(e,Li|(n?0:Ri),!1,t)},V.parseIfStatement=function(e){return this.next(),e.test=this.parseParenExpression(),e.consequent=this.parseStatement(`if`),e.alternate=this.eat(B._else)?this.parseStatement(`if`):null,this.finishNode(e,`IfStatement`)},V.parseReturnStatement=function(e){return this.allowReturn||this.raise(this.start,`'return' outside of function`),this.next(),this.eat(B.semi)||this.insertSemicolon()?e.argument=null:(e.argument=this.parseExpression(),this.semicolon()),this.finishNode(e,`ReturnStatement`)},V.parseSwitchStatement=function(e){this.next(),e.discriminant=this.parseParenExpression(),e.cases=[],this.expect(B.braceL),this.labels.push(Fi),this.enterScope(yi);for(var t,n=!1;this.type!==B.braceR;)if(this.type===B._case||this.type===B._default){var r=this.type===B._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(B.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`)},V.parseThrowStatement=function(e){return this.next(),Vr.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 Ii=[];V.parseCatchClauseParam=function(){var e=this.parseBindingAtom(),t=e.type===`Identifier`;return this.enterScope(t?mi:0),this.checkLValPattern(e,t?Ei:wi),this.expect(B.parenR),e},V.parseTryStatement=function(e){if(this.next(),e.block=this.parseBlock(),e.handler=null,this.type===B._catch){var t=this.startNode();this.next(),this.eat(B.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(B._finally)?this.parseBlock():null,!e.handler&&!e.finalizer&&this.raise(e.start,`Missing catch or finally clause`),this.finishNode(e,`TryStatement`)},V.parseVarStatement=function(e,t,n){return this.next(),this.parseVar(e,!1,t,n),this.semicolon(),this.finishNode(e,`VariableDeclaration`)},V.parseWhileStatement=function(e){return this.next(),e.test=this.parseParenExpression(),this.labels.push(Pi),e.body=this.parseStatement(`while`),this.labels.pop(),this.finishNode(e,`WhileStatement`)},V.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`)},V.parseEmptyStatement=function(e){return this.next(),this.finishNode(e,`EmptyStatement`)},V.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===B._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`)},V.parseExpressionStatement=function(e,t){return e.expression=t,this.semicolon(),this.finishNode(e,`ExpressionStatement`)},V.parseBlock=function(e,t,n){for(e===void 0&&(e=!0),t===void 0&&(t=this.startNode()),t.body=[],this.expect(B.braceL),e&&this.enterScope(0);this.type!==B.braceR;){var r=this.parseStatement(null);t.body.push(r)}return n&&(this.strict=!1),this.next(),e&&this.exitScope(),this.finishNode(t,`BlockStatement`)},V.parseFor=function(e,t){return e.init=t,this.expect(B.semi),e.test=this.type===B.semi?null:this.parseExpression(),this.expect(B.semi),e.update=this.type===B.parenR?null:this.parseExpression(),this.expect(B.parenR),e.body=this.parseStatement(`for`),this.exitScope(),this.labels.pop(),this.finishNode(e,`ForStatement`)},V.parseForIn=function(e,t){var n=this.type===B._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(B.parenR),e.body=this.parseStatement(`for`),this.exitScope(),this.labels.pop(),this.finishNode(e,n?`ForInStatement`:`ForOfStatement`)},V.parseVar=function(e,t,n,r){for(e.declarations=[],e.kind=n;;){var i=this.startNode();if(this.parseVarId(i,n),this.eat(B.eq)?i.init=this.parseMaybeAssign(t):!r&&n===`const`&&!(this.type===B._in||this.options.ecmaVersion>=6&&this.isContextual(`of`))?this.unexpected():!r&&(n===`using`||n===`await using`)&&this.options.ecmaVersion>=17&&this.type!==B._in&&!this.isContextual(`of`)?this.raise(this.lastTokEnd,`Missing initializer in `+n+` declaration`):!r&&i.id.type!==`Identifier`&&!(t&&(this.type===B._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(B.comma))break}return e},V.parseVarId=function(e,t){e.id=t===`using`||t===`await using`?this.parseIdent():this.parseBindingAtom(),this.checkLValPattern(e.id,t===`var`?Ci:wi,!1)};var Li=1,Ri=2,zi=4;V.parseFunction=function(e,t,n,r,i){this.initFunction(e),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!r)&&(this.type===B.star&&t&Ri&&this.unexpected(),e.generator=this.eat(B.star)),this.options.ecmaVersion>=8&&(e.async=!!r),t&Li&&(e.id=t&zi&&this.type!==B.name?null:this.parseIdent(),e.id&&!(t&Ri)&&this.checkLValSimple(e.id,this.strict||e.generator||e.async?this.treatFunctionsAsVar?Ci:wi:Ti));var a=this.yieldPos,o=this.awaitPos,s=this.awaitIdentPos;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(xi(e.async,e.generator)),t&Li||(e.id=this.type===B.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&Li?`FunctionDeclaration`:`FunctionExpression`)},V.parseFunctionParams=function(e){this.expect(B.parenL),e.params=this.parseBindingList(B.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()},V.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(B.braceL);this.type!==B.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`&&Bi(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`)},V.parseClassElement=function(e){if(this.eat(B.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(B.braceL))return this.parseClassStaticBlock(n),n;this.isClassElementNameStart()||this.type===B.star?s=!0:r=`static`}if(n.static=s,!r&&t>=8&&this.eatContextual(`async`)&&((this.isClassElementNameStart()||this.type===B.star)&&!this.canInsertSemicolon()?a=!0:r=`async`),!r&&(t>=9||!a)&&this.eat(B.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===B.parenL||o!==`method`||i||a){var l=!n.static&&Vi(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},V.isClassElementNameStart=function(){return this.type===B.name||this.type===B.privateId||this.type===B.num||this.type===B.string||this.type===B.bracketL||this.type.keyword},V.parseClassElementName=function(e){this.type===B.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)},V.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&&Vi(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`)},V.parseClassField=function(e){return Vi(e,`constructor`)?this.raise(e.key.start,`Classes can't have a field named 'constructor'`):e.static&&Vi(e,`prototype`)&&this.raise(e.key.start,`Classes can't have a static field named 'prototype'`),this.eat(B.eq)?(this.enterScope(vi|hi),e.value=this.parseMaybeAssign(),this.exitScope()):e.value=null,this.semicolon(),this.finishNode(e,`PropertyDefinition`)},V.parseClassStaticBlock=function(e){e.body=[];var t=this.labels;for(this.labels=[],this.enterScope(_i|hi);this.type!==B.braceR;){var n=this.parseStatement(null);e.body.push(n)}return this.next(),this.exitScope(),this.labels=t,this.finishNode(e,`StaticBlock`)},V.parseClassId=function(e,t){this.type===B.name?(e.id=this.parseIdent(),t&&this.checkLValSimple(e.id,wi,!1)):(t===!0&&this.unexpected(),e.id=null)},V.parseClassSuper=function(e){e.superClass=this.eat(B._extends)?this.parseExprSubscripts(null,!1):null},V.enterClassBody=function(){var e={declared:Object.create(null),used:[]};return this.privateNameStack.push(e),e.declared},V.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];Xr(t,o.name)||(i?i.used.push(o):this.raiseRecoverable(o.start,`Private field '#`+o.name+`' must be declared in an enclosing class`))}};function Bi(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 Vi(e,t){var n=e.computed,r=e.key;return!n&&(r.type===`Identifier`&&r.name===t||r.type===`Literal`&&r.value===t)}V.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!==B.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,`ExportAllDeclaration`)},V.parseExport=function(e,t){if(this.next(),this.eat(B.star))return this.parseExportAllDeclaration(e,t);if(this.eat(B._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!==B.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`)},V.parseExportDeclaration=function(e){return this.parseStatement(null)},V.parseExportDefaultDeclaration=function(){var e;if(this.type===B._function||(e=this.isAsyncFunction())){var t=this.startNode();return this.next(),e&&this.next(),this.parseFunction(t,Li|zi,!1,e)}else if(this.type===B._class){var n=this.startNode();return this.parseClass(n,`nullableID`)}else{var r=this.parseMaybeAssign();return this.semicolon(),r}},V.checkExport=function(e,t,n){e&&(typeof t!=`string`&&(t=t.type===`Identifier`?t.name:t.value),Xr(e,t)&&this.raiseRecoverable(n,`Duplicate export '`+t+`'`),e[t]=!0)},V.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)},V.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)}},V.shouldParseExportStatement=function(){return this.type.keyword===`var`||this.type.keyword===`const`||this.type.keyword===`class`||this.type.keyword===`function`||this.isLet()||this.isAsyncFunction()},V.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`)},V.parseExportSpecifiers=function(e){var t=[],n=!0;for(this.expect(B.braceL);!this.eat(B.braceR);){if(n)n=!1;else if(this.expect(B.comma),this.afterTrailingComma(B.braceR))break;t.push(this.parseExportSpecifier(e))}return t},V.parseImport=function(e){return this.next(),this.type===B.string?(e.specifiers=Ii,e.source=this.parseExprAtom()):(e.specifiers=this.parseImportSpecifiers(),this.expectContextual(`from`),e.source=this.type===B.string?this.parseExprAtom():this.unexpected()),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,`ImportDeclaration`)},V.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,wi),this.finishNode(e,`ImportSpecifier`)},V.parseImportDefaultSpecifier=function(){var e=this.startNode();return e.local=this.parseIdent(),this.checkLValSimple(e.local,wi),this.finishNode(e,`ImportDefaultSpecifier`)},V.parseImportNamespaceSpecifier=function(){var e=this.startNode();return this.next(),this.expectContextual(`as`),e.local=this.parseIdent(),this.checkLValSimple(e.local,wi),this.finishNode(e,`ImportNamespaceSpecifier`)},V.parseImportSpecifiers=function(){var e=[],t=!0;if(this.type===B.name&&(e.push(this.parseImportDefaultSpecifier()),!this.eat(B.comma)))return e;if(this.type===B.star)return e.push(this.parseImportNamespaceSpecifier()),e;for(this.expect(B.braceL);!this.eat(B.braceR);){if(t)t=!1;else if(this.expect(B.comma),this.afterTrailingComma(B.braceR))break;e.push(this.parseImportSpecifier())}return e},V.parseWithClause=function(){var e=[];if(!this.eat(B._with))return e;this.expect(B.braceL);for(var t={},n=!0;!this.eat(B.braceR);){if(n)n=!1;else if(this.expect(B.comma),this.afterTrailingComma(B.braceR))break;var r=this.parseImportAttribute(),i=r.key.type===`Identifier`?r.key.name:r.key.value;Xr(t,i)&&this.raiseRecoverable(r.key.start,`Duplicate attribute key '`+i+`'`),t[i]=!0,e.push(r)}return e},V.parseImportAttribute=function(){var e=this.startNode();return e.key=this.type===B.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!==`never`),this.expect(B.colon),this.type!==B.string&&this.unexpected(),e.value=this.parseExprAtom(),this.finishNode(e,`ImportAttribute`)},V.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===B.string){var e=this.parseLiteral(this.value);return ti.test(e.value)&&this.raise(e.start,`An export name cannot include a lone surrogate.`),e}return this.parseIdent(!0)},V.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)},V.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 Hi=Oi.prototype;Hi.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},Hi.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},Hi.parseSpread=function(e){var t=this.startNode();return this.next(),t.argument=this.parseMaybeAssign(!1,e),this.finishNode(t,`SpreadElement`)},Hi.parseRestBinding=function(){var e=this.startNode();return this.next(),this.options.ecmaVersion===6&&this.type!==B.name&&this.unexpected(),e.argument=this.parseBindingAtom(),this.finishNode(e,`RestElement`)},Hi.parseBindingAtom=function(){if(this.options.ecmaVersion>=6)switch(this.type){case B.bracketL:var e=this.startNode();return this.next(),e.elements=this.parseBindingList(B.bracketR,!0,!0),this.finishNode(e,`ArrayPattern`);case B.braceL:return this.parseObj(!0)}return this.parseIdent()},Hi.parseBindingList=function(e,t,n,r){for(var i=[],a=!0;!this.eat(e);)if(a?a=!1:this.expect(B.comma),t&&this.type===B.comma)i.push(null);else if(n&&this.afterTrailingComma(e))break;else if(this.type===B.ellipsis){var o=this.parseRestBinding();this.parseBindingListItem(o),i.push(o),this.type===B.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},Hi.parseAssignableListItem=function(e){var t=this.parseMaybeDefault(this.start,this.startLoc);return this.parseBindingListItem(t),t},Hi.parseBindingListItem=function(e){return e},Hi.parseMaybeDefault=function(e,t,n){if(n=n||this.parseBindingAtom(),this.options.ecmaVersion<6||!this.eat(B.eq))return n;var r=this.startNodeAt(e,t);return r.left=n,r.right=this.parseMaybeAssign(),this.finishNode(r,`AssignmentPattern`)},Hi.checkLValSimple=function(e,t,n){t===void 0&&(t=Si);var r=t!==Si;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===wi&&e.name===`let`&&this.raiseRecoverable(e.start,`let is disallowed as a lexically bound name`),n&&(Xr(n,e.name)&&this.raiseRecoverable(e.start,`Argument name clash`),n[e.name]=!0),t!==Di&&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`)}},Hi.checkLValPattern=function(e,t,n){switch(t===void 0&&(t=Si),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)}},Hi.checkLValInnerPattern=function(e,t,n){switch(t===void 0&&(t=Si),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 Ui=function(e,t,n,r,i){this.token=e,this.isExpr=!!t,this.preserveSpace=!!n,this.override=r,this.generator=!!i},H={b_stat:new Ui(`{`,!1),b_expr:new Ui(`{`,!0),b_tmpl:new Ui(\"${\",!1),p_stat:new Ui(`(`,!1),p_expr:new Ui(`(`,!0),q_tmpl:new Ui(\"`\",!0,!0,function(e){return e.tryReadTemplateToken()}),f_stat:new Ui(`function`,!1),f_expr:new Ui(`function`,!0),f_expr_gen:new Ui(`function`,!0,!1,null,!0),f_gen:new Ui(`function`,!1,!1,null,!0)},Wi=Oi.prototype;Wi.initialContext=function(){return[H.b_stat]},Wi.curContext=function(){return this.context[this.context.length-1]},Wi.braceIsBlock=function(e){var t=this.curContext();return t===H.f_expr||t===H.f_stat?!0:e===B.colon&&(t===H.b_stat||t===H.b_expr)?!t.isExpr:e===B._return||e===B.name&&this.exprAllowed?Vr.test(this.input.slice(this.lastTokEnd,this.start)):e===B._else||e===B.semi||e===B.eof||e===B.parenR||e===B.arrow?!0:e===B.braceL?t===H.b_stat:e===B._var||e===B._const||e===B.name?!1:!this.exprAllowed},Wi.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},Wi.updateContext=function(e){var t,n=this.type;n.keyword&&e===B.dot?this.exprAllowed=!1:(t=n.updateContext)?t.call(this,e):this.exprAllowed=n.beforeExpr},Wi.overrideContext=function(e){this.curContext()!==e&&(this.context[this.context.length-1]=e)},B.parenR.updateContext=B.braceR.updateContext=function(){if(this.context.length===1){this.exprAllowed=!0;return}var e=this.context.pop();e===H.b_stat&&this.curContext().token===`function`&&(e=this.context.pop()),this.exprAllowed=!e.isExpr},B.braceL.updateContext=function(e){this.context.push(this.braceIsBlock(e)?H.b_stat:H.b_expr),this.exprAllowed=!0},B.dollarBraceL.updateContext=function(){this.context.push(H.b_tmpl),this.exprAllowed=!0},B.parenL.updateContext=function(e){var t=e===B._if||e===B._for||e===B._with||e===B._while;this.context.push(t?H.p_stat:H.p_expr),this.exprAllowed=!0},B.incDec.updateContext=function(){},B._function.updateContext=B._class.updateContext=function(e){e.beforeExpr&&e!==B._else&&!(e===B.semi&&this.curContext()!==H.p_stat)&&!(e===B._return&&Vr.test(this.input.slice(this.lastTokEnd,this.start)))&&!((e===B.colon||e===B.braceL)&&this.curContext()===H.b_stat)?this.context.push(H.f_expr):this.context.push(H.f_stat),this.exprAllowed=!1},B.colon.updateContext=function(){this.curContext().token===`function`&&this.context.pop(),this.exprAllowed=!0},B.backQuote.updateContext=function(){this.curContext()===H.q_tmpl?this.context.pop():this.context.push(H.q_tmpl),this.exprAllowed=!1},B.star.updateContext=function(e){if(e===B._function){var t=this.context.length-1;this.context[t]===H.f_expr?this.context[t]=H.f_expr_gen:this.context[t]=H.f_gen}this.exprAllowed=!0},B.name.updateContext=function(e){var t=!1;this.options.ecmaVersion>=6&&e!==B.dot&&(this.value===`of`&&!this.exprAllowed||this.value===`yield`&&this.inGeneratorContext())&&(t=!0),this.exprAllowed=t};var U=Oi.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===B.comma){var o=n.startNodeAt(r,i);for(o.expressions=[a];n.eat(B.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 Ni,r=!0);var s=this.start,c=this.startLoc;(this.type===B.parenL||this.type===B.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===B.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===B.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(B.question)){var a=this.startNodeAt(n,r);return a.test=i,a.consequent=this.parseMaybeAssign(),this.expect(B.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!==B._in)&&a>r){var o=this.type===B.logicalOR||this.type===B.logicalAND,s=this.type===B.coalesce;s&&(a=B.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===B.coalesce||s&&(this.type===B.logicalOR||this.type===B.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===B.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`&&Gi(s.argument)?this.raiseRecoverable(s.start,`Deleting local variable in strict mode`):s.operator===`delete`&&Ki(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===B.privateId)(r||this.privateNameStack.length===0)&&this.options.checkPrivateFields&&this.unexpected(),o=this.parsePrivateIdent(),this.type!==B._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(B.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 Gi(e){return e.type===`Identifier`||e.type===`ParenthesizedExpression`&&Gi(e.expression)}function Ki(e){return e.type===`MemberExpression`&&e.property.type===`PrivateIdentifier`||e.type===`ChainExpression`&&Ki(e.expression)||e.type===`ParenthesizedExpression`&&Ki(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(B.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(B.questionDot);r&&c&&this.raise(this.lastTokStart,`Optional chaining cannot appear in the callee of new expressions`);var l=this.eat(B.bracketL);if(l||c&&this.type!==B.parenL&&this.type!==B.backQuote||this.eat(B.dot)){var u=this.startNodeAt(t,n);u.object=e,l?(u.property=this.parseExpression(),this.expect(B.bracketR)):this.type===B.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(B.parenL)){var d=new Ni,f=this.yieldPos,p=this.awaitPos,m=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var h=this.parseExprList(B.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===B.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===B.slash&&this.readRegexp();var r,i=this.potentialArrowAt===this.start;switch(this.type){case B._super:return this.allowSuper||this.raise(this.start,`'super' keyword outside a method`),r=this.startNode(),this.next(),this.type===B.parenL&&!this.allowDirectSuper&&this.raise(r.start,`super() call outside constructor of a subclass`),this.type!==B.dot&&this.type!==B.bracketL&&this.type!==B.parenL&&this.unexpected(),this.finishNode(r,`Super`);case B._this:return r=this.startNode(),this.next(),this.finishNode(r,`ThisExpression`);case B.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(B._function))return this.overrideContext(H.f_expr),this.parseFunction(this.startNodeAt(a,o),0,!1,!0,t);if(i&&!this.canInsertSemicolon()){if(this.eat(B.arrow))return this.parseArrowExpression(this.startNodeAt(a,o),[c],!1,t);if(this.options.ecmaVersion>=8&&c.name===`async`&&this.type===B.name&&!s&&(!this.potentialArrowInForAwait||this.value!==`of`||this.containsEsc))return c=this.parseIdent(!1),(this.canInsertSemicolon()||!this.eat(B.arrow))&&this.unexpected(),this.parseArrowExpression(this.startNodeAt(a,o),[c],!0,t)}return c;case B.regexp:var l=this.value;return r=this.parseLiteral(l.value),r.regex={pattern:l.pattern,flags:l.flags},r;case B.num:case B.string:return this.parseLiteral(this.value);case B._null:case B._true:case B._false:return r=this.startNode(),r.value=this.type===B._null?null:this.type===B._true,r.raw=this.type.keyword,this.next(),this.finishNode(r,`Literal`);case B.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 B.bracketL:return r=this.startNode(),this.next(),r.elements=this.parseExprList(B.bracketR,!0,!0,e),this.finishNode(r,`ArrayExpression`);case B.braceL:return this.overrideContext(H.b_expr),this.parseObj(!1,e);case B._function:return r=this.startNode(),this.next(),this.parseFunction(r,0);case B._class:return this.parseClass(this.startNode(),!1);case B._new:return this.parseNew();case B.backQuote:return this.parseTemplate();case B._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===B.parenL&&!e)return this.parseDynamicImport(t);if(this.type===B.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(B.parenR)?e.options=null:(this.expect(B.comma),this.afterTrailingComma(B.parenR)?e.options=null:(e.options=this.parseMaybeAssign(),this.eat(B.parenR)||(this.expect(B.comma),this.afterTrailingComma(B.parenR)||this.unexpected())));else if(!this.eat(B.parenR)){var t=this.start;this.eat(B.comma)&&this.eat(B.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(B.parenL);var e=this.parseExpression();return this.expect(B.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 Ni,f=this.yieldPos,p=this.awaitPos,m;for(this.yieldPos=0,this.awaitPos=0;this.type!==B.parenR;)if(l?l=!1:this.expect(B.comma),a&&this.afterTrailingComma(B.parenR,!0)){u=!0;break}else if(this.type===B.ellipsis){m=this.start,c.push(this.parseParenItem(this.parseRestBinding())),this.type===B.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(B.parenR),e&&this.shouldParseArrow(c)&&this.eat(B.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 qi=[];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===B.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(B.parenL)?e.arguments=this.parseExprList(B.parenR,this.options.ecmaVersion>=8,!1):e.arguments=qi,this.finishNode(e,`NewExpression`)},U.parseTemplateElement=function(e){var t=e.isTagged,n=this.startNode();return this.type===B.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===B.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===B.eof&&this.raise(this.pos,`Unterminated template literal`),this.expect(B.dollarBraceL),n.expressions.push(this.parseExpression()),this.expect(B.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===B.name||this.type===B.num||this.type===B.string||this.type===B.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===B.star)&&!Vr.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(B.braceR);){if(r)r=!1;else if(this.expect(B.comma),this.options.ecmaVersion>=5&&this.afterTrailingComma(B.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(B.ellipsis))return e?(n.argument=this.parseIdent(!1),this.type===B.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===B.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(B.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(B.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===B.colon&&this.unexpected(),this.eat(B.colon)?(e.value=t?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,o),e.kind=`init`):this.options.ecmaVersion>=6&&this.type===B.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!==B.comma&&this.type!==B.braceR&&this.type!==B.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===B.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(B.bracketL))return e.computed=!0,e.key=this.parseMaybeAssign(),this.expect(B.bracketR),e.key;e.computed=!1}return e.key=this.type===B.num||this.type===B.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(xi(t,r.generator)|hi|(n?gi:0)),this.expect(B.parenL),r.params=this.parseBindingList(B.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(xi(n,!1)|pi),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!==B.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,Di),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,Ci,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(B.comma),t&&this.afterTrailingComma(e))break;var o=void 0;n&&this.type===B.comma?o=null:this.type===B.ellipsis?(o=this.parseSpread(r),r&&this.type===B.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&bi)&&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===B.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=B.name):this.unexpected(),e},U.parsePrivateIdent=function(){var e=this.startNode();return this.type===B.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===B.semi||this.canInsertSemicolon()||this.type!==B.star&&!this.type.startsExpr?(t.delegate=!1,t.argument=null):(t.delegate=this.eat(B.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 Ji=Oi.prototype;Ji.raise=function(e,t){var n=ii(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},Ji.raiseRecoverable=Ji.raise,Ji.curPosition=function(){if(this.options.locations)return new ni(this.curLine,this.pos-this.lineStart)};var Yi=Oi.prototype,Xi=function(e){this.flags=e,this.var=[],this.lexical=[],this.functions=[]};Yi.enterScope=function(e){this.scopeStack.push(new Xi(e))},Yi.exitScope=function(){this.scopeStack.pop()},Yi.treatFunctionsAsVarInScope=function(e){return e.flags&ui||!this.inModule&&e.flags&li},Yi.declareName=function(e,t,n){var r=!1;if(t===wi){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&li&&delete this.undefinedExports[e]}else if(t===Ei)this.currentScope().lexical.push(e);else if(t===Ti){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&mi&&s.lexical[0]===e)||!this.treatFunctionsAsVarInScope(s)&&s.functions.indexOf(e)>-1){r=!0;break}if(s.var.push(e),this.inModule&&s.flags&li&&delete this.undefinedExports[e],s.flags&bi)break}r&&this.raiseRecoverable(n,`Identifier '`+e+`' has already been declared`)},Yi.checkLocalExport=function(e){this.scopeStack[0].lexical.indexOf(e.name)===-1&&this.scopeStack[0].var.indexOf(e.name)===-1&&(this.undefinedExports[e.name]=e)},Yi.currentScope=function(){return this.scopeStack[this.scopeStack.length-1]},Yi.currentVarScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&(bi|vi|_i))return t}},Yi.currentThisScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&(bi|vi|_i)&&!(t.flags&pi))return t}};var Zi=function(e,t,n){this.type=``,this.start=t,this.end=0,e.options.locations&&(this.loc=new ri(e,n)),e.options.directSourceFile&&(this.sourceFile=e.options.directSourceFile),e.options.ranges&&(this.range=[t,0])},Qi=Oi.prototype;Qi.startNode=function(){return new Zi(this,this.start,this.startLoc)},Qi.startNodeAt=function(e,t){return new Zi(this,e,t)};function $i(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}Qi.finishNode=function(e,t){return $i.call(this,e,t,this.lastTokEnd,this.lastTokEndLoc)},Qi.finishNodeAt=function(e,t,n,r){return $i.call(this,e,t,n,r)},Qi.copyNode=function(e){var t=new Zi(this,e.start,this.startLoc);for(var n in e)t[n]=e[n];return t};var ea=`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`,ta=`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`,na=ta+` Extended_Pictographic`,ra=na,ia=ra+` EBase EComp EMod EPres ExtPict`,aa=ia,oa=aa,sa={9:ta,10:na,11:ra,12:ia,13:aa,14:oa},ca=`Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji`,la={9:``,10:``,11:``,12:``,13:``,14:ca},ua=`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`,da=`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`,fa=da+` Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd`,pa=fa+` Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho`,ma=pa+` Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi`,ha=ma+` Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith`,ga=ha+` `+ea,_a={9:da,10:fa,11:pa,12:ma,13:ha,14:ga},va={};function ya(e){var t=va[e]={binary:$r(sa[e]+` `+ua),binaryOfStrings:$r(la[e]),nonBinary:{General_Category:$r(ua),Script:$r(_a[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 ba=0,xa=[9,10,11,12,13,14];ba<xa.length;ba+=1){var Sa=xa[ba];ya(Sa)}var W=Oi.prototype,Ca=function(e,t){this.parent=e,this.base=t||this};Ca.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},Ca.prototype.sibling=function(){return new Ca(this.parent,this.base)};var wa=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=va[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};wa.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)},wa.prototype.raise=function(e){this.parser.raiseRecoverable(this.start,`Invalid regular expression: /`+this.source+`/: `+e)},wa.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},wa.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},wa.prototype.current=function(e){return e===void 0&&(e=!1),this.at(this.pos,e)},wa.prototype.lookahead=function(e){return e===void 0&&(e=!1),this.at(this.nextIndex(this.pos,e),e)},wa.prototype.advance=function(e){e===void 0&&(e=!1),this.pos=this.nextIndex(this.pos,e)},wa.prototype.eat=function(e,t){return t===void 0&&(t=!1),this.current(t)===e?(this.advance(t),!0):!1},wa.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 Ta(e){for(var t in e)return!0;return!1}W.validateRegExpPattern=function(e){this.regexp_pattern(e),!e.switchN&&this.options.ecmaVersion>=9&&Ta(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 Ca(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&&Ea(n);)t+=ei(n),e.advance();return t};function Ea(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 Da(t)?(e.lastIntValue=t,e.advance(),!0):!1};function Da(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&&!Da(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+=ei(e.lastIntValue);this.regexp_eatRegExpIdentifierPart(e);)e.lastStringValue+=ei(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),Oa(r)?(e.lastIntValue=r,!0):(e.pos=t,!1)};function Oa(e){return Fr(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),ka(r)?(e.lastIntValue=r,!0):(e.pos=t,!1)};function ka(e){return Ir(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&&!Va(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 Aa(t)?(e.lastIntValue=t%32,e.advance(),!0):!1};function Aa(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)&&ja(e.lastIntValue))return!0;r&&e.raise(`Invalid unicode escape`),e.pos=n}return!1};function ja(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 Ma=0,Na=1,Pa=2;W.regexp_eatCharacterClassEscape=function(e){var t=e.current();if(Fa(t))return e.lastIntValue=-1,e.advance(),Na;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===Pa&&e.raise(`Invalid property name`),r;e.raise(`Invalid property name`)}return Ma};function Fa(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),Na}}if(e.pos=t,this.regexp_eatLoneUnicodePropertyNameOrValue(e)){var i=e.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(e,i)}return Ma},W.regexp_validateUnicodePropertyNameAndValue=function(e,t,n){Xr(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 Na;if(e.switchV&&e.unicodeProperties.binaryOfStrings.test(t))return Pa;e.raise(`Invalid property name`)},W.regexp_eatUnicodePropertyName=function(e){var t=0;for(e.lastStringValue=``;Ia(t=e.current());)e.lastStringValue+=ei(t),e.advance();return e.lastStringValue!==``};function Ia(e){return Aa(e)||e===95}W.regexp_eatUnicodePropertyValue=function(e){var t=0;for(e.lastStringValue=``;La(t=e.current());)e.lastStringValue+=ei(t),e.advance();return e.lastStringValue!==``};function La(e){return Ia(e)||Va(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===Pa&&e.raise(`Negated character class may contain strings`),!0}return!1},W.regexp_classContents=function(e){return e.current()===93?Na:e.switchV?this.regexp_classSetExpression(e):(this.regexp_nonEmptyClassRanges(e),Na)},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||Wa(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=Na,n;if(!this.regexp_eatClassSetRange(e))if(n=this.regexp_eatClassSetOperand(e)){n===Pa&&(t=Pa);for(var r=e.pos;e.eatChars([38,38]);){if(e.current()!==38&&(n=this.regexp_eatClassSetOperand(e))){n!==Pa&&(t=Na);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===Pa&&(t=Pa)}},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)?Na: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===Pa&&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)===Pa&&(t=Pa);return t},W.regexp_classString=function(e){for(var t=0;this.regexp_eatClassSetCharacter(e);)t++;return t===1?Na:Pa},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()&&Ra(n)||za(n)?!1:(e.advance(),e.lastIntValue=n,!0)};function Ra(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 Ba(t)?(e.lastIntValue=t,e.advance(),!0):!1};function Ba(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 Va(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;Va(n=e.current());)e.lastIntValue=10*e.lastIntValue+(n-48),e.advance();return e.pos!==t};function Va(e){return e>=48&&e<=57}W.regexp_eatHexDigits=function(e){var t=e.pos,n=0;for(e.lastIntValue=0;Ha(n=e.current());)e.lastIntValue=16*e.lastIntValue+Ua(n),e.advance();return e.pos!==t};function Ha(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function Ua(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 Wa(t)?(e.lastIntValue=t-48,e.advance(),!0):(e.lastIntValue=0,!1)};function Wa(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(!Ha(i))return e.pos=n,!1;e.lastIntValue=16*e.lastIntValue+Ua(i),e.advance()}return!0};var Ga=function(e){this.type=e.type,this.value=e.value,this.start=e.start,this.end=e.end,e.options.locations&&(this.loc=new ri(e,e.startLoc,e.endLoc)),e.options.ranges&&(this.range=[e.start,e.end])},G=Oi.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 Ga(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 Ga(this)},typeof Symbol<`u`&&(G[Symbol.iterator]=function(){var e=this;return{next:function(){var t=e.getToken();return{done:t.type===B.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(B.eof);if(e.override)return e.override(this);this.readToken(this.fullCharCodeAtPos())},G.readToken=function(e){return Fr(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=Wr(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&&!Ur(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&&Gr.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(B.ellipsis)):(++this.pos,this.finishToken(B.dot))},G.readToken_slash=function(){var e=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):e===61?this.finishOp(B.assign,2):this.finishOp(B.slash,1)},G.readToken_mult_modulo_exp=function(e){var t=this.input.charCodeAt(this.pos+1),n=1,r=e===42?B.star:B.modulo;return this.options.ecmaVersion>=7&&e===42&&t===42&&(++n,r=B.starstar,t=this.input.charCodeAt(this.pos+2)),t===61?this.finishOp(B.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(B.assign,3):this.finishOp(e===124?B.logicalOR:B.logicalAND,2):t===61?this.finishOp(B.assign,2):this.finishOp(e===124?B.bitwiseOR:B.bitwiseAND,1)},G.readToken_caret=function(){return this.input.charCodeAt(this.pos+1)===61?this.finishOp(B.assign,2):this.finishOp(B.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||Vr.test(this.input.slice(this.lastTokEnd,this.pos)))?(this.skipLineComment(3),this.skipSpace(),this.nextToken()):this.finishOp(B.incDec,2):t===61?this.finishOp(B.assign,2):this.finishOp(B.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(B.assign,n+1):this.finishOp(B.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(B.relational,n))},G.readToken_eq_excl=function(e){var t=this.input.charCodeAt(this.pos+1);return t===61?this.finishOp(B.equality,this.input.charCodeAt(this.pos+2)===61?3:2):e===61&&t===62&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(B.arrow)):this.finishOp(e===61?B.eq:B.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(B.questionDot,2)}if(t===63)return e>=12&&this.input.charCodeAt(this.pos+2)===61?this.finishOp(B.assign,3):this.finishOp(B.coalesce,2)}return this.finishOp(B.question,1)},G.readToken_numberSign=function(){var e=this.options.ecmaVersion,t=35;if(e>=13&&(++this.pos,t=this.fullCharCodeAtPos(),Fr(t,!0)||t===92))return this.finishToken(B.privateId,this.readWord1());this.raise(this.pos,`Unexpected character '`+ei(t)+`'`)},G.getTokenFromCode=function(e){switch(e){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(B.parenL);case 41:return++this.pos,this.finishToken(B.parenR);case 59:return++this.pos,this.finishToken(B.semi);case 44:return++this.pos,this.finishToken(B.comma);case 91:return++this.pos,this.finishToken(B.bracketL);case 93:return++this.pos,this.finishToken(B.bracketR);case 123:return++this.pos,this.finishToken(B.braceL);case 125:return++this.pos,this.finishToken(B.braceR);case 58:return++this.pos,this.finishToken(B.colon);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(B.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(B.prefix,1);case 35:return this.readToken_numberSign()}this.raise(this.pos,`Unexpected character '`+ei(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(Vr.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 wa(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(B.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 Ka(e,t){return t?parseInt(e,8):parseFloat(e.replace(/_/g,``))}function qa(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=qa(this.input.slice(t,this.pos)),++this.pos):Fr(this.fullCharCodeAtPos())&&this.raise(this.pos,`Identifier directly after number`),this.finishToken(B.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=qa(this.input.slice(t,this.pos));return++this.pos,Fr(this.fullCharCodeAtPos())&&this.raise(this.pos,`Identifier directly after number`),this.finishToken(B.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`)),Fr(this.fullCharCodeAtPos())&&this.raise(this.pos,`Identifier directly after number`);var a=Ka(this.input.slice(t,this.pos),n);return this.finishToken(B.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)):(Ur(r)&&this.raise(this.start,`Unterminated string constant`),++this.pos)}return t+=this.input.slice(n,this.pos++),this.finishToken(B.string,t)};var Ja={};G.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(e){if(e===Ja)this.readInvalidTemplateToken();else throw e}this.inTemplateElement=!1},G.invalidStringToken=function(e,t){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw Ja;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===B.template||this.type===B.invalidTemplate)?n===36?(this.pos+=2,this.finishToken(B.dollarBraceL)):(++this.pos,this.finishToken(B.backQuote)):(e+=this.input.slice(t,this.pos),this.finishToken(B.template,e));if(n===92)e+=this.input.slice(t,this.pos),e+=this.readEscapedChar(!0),t=this.pos;else if(Ur(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(B.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 ei(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 Ur(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(Ir(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?Fr:Ir)(o,r)||this.invalidStringToken(a,`Invalid Unicode escape`),e+=ei(o),n=this.pos}else break;t=!1}return e+this.input.slice(n,this.pos)},G.readWord=function(){var e=this.readWord1(),t=B.name;return this.keywords.test(e)&&(t=Br[e]),this.finishToken(t,e)},Oi.acorn={Parser:Oi,version:`8.19.0`,defaultOptions:ai,Position:ni,SourceLocation:ri,getLineInfo:ii,Node:Zi,TokenType:R,tokTypes:B,keywordTypes:Br,TokContext:Ui,tokContexts:H,isIdentifierChar:Ir,isIdentifierStart:Fr,Token:Ga,isNewLine:Ur,lineBreak:Vr,lineBreakG:Hr,nonASCIIwhitespace:Gr};var Ya={ecmaVersion:`latest`,sourceType:`script`,allowReturnOutsideFunction:!0},Xa=/\\w+(?![\\p{ID_Continue}$\\u200c\\u200d])/uy,Za=/[A-Za-z_]\\w*(?![\\p{ID_Continue}$\\u200c\\u200d])/uy,Qa=/^[$_]\\w+$/,$a=/[\\n\\r\\u2028\\u2029]/,eo=/\\s*(?:[;},:)]|=(?![=>]))/y;function to(e,t){return eo.lastIndex=t,eo.test(e)}var no=new Set([B.name,B.num,B.string,B.regexp,B.backQuote,B.bracketR,B.braceR,B.parenR,B.incDec,B._this,B._null,B._true,B._false]),ro=class extends Oi{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=B.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=$a.test(t.input.slice(t.end,t.pos)),e===64||e===37){let n=t.pos,r=e===64?Xa:Za;r.lastIndex=n+1;let i=r.exec(t.input)?.[0];if(i){let r=n+1+i.length,a=t.type===B.incDec&&(this.operandBeforeLast||this.breakBeforeLast),o=e===37?this.percentAt?.get(n):void 0;if(e===64||(o??(t.exprAllowed||a||this.lookahead&&io(t,r)))){e===37&&this.transientsRead?.add(n),t.pos=r,t.finishToken(B.name,t.input.charAt(n)+i);return}}}super.readToken(e)}finishToken(e,t){let{context:n}=this,r=n.length;if(e===B.braceR){let e=n[r-1];this.closedBlock=e.token===`{`&&!e.isExpr}else if(e===B.question)this.ternaries[r]=(this.ternaries[r]??0)+1;else if(e===B.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===B.dot||a===B.questionDot)||(e===B._function||e===B._class)&&to(i.input,i.pos);if(!o&&(e===B._function||e===B._class)){let t=e===B._function&&a===B.name&&this.prevValue===`async`&&!this.breakHere?this.typeBeforeLast:a;i.type=t===B.colon&&this.colonEndsTernary?B.parenL:t}this.typeBeforeLast=a,super.finishToken(o?B.name:e,t),e===B.name&&t===`of`&&(a===B._const||a===B._var||this.prevValue===`let`)&&(i.exprAllowed=!1)}braceIsBlock(e){if(e===B.colon&&this.colonEndsTernary)return!1;if(e===B.braceR&&this.closedBlock||e===B.name&&this.prevValue===`static`)return!0;if(this.breakHere&&no.has(e)){let{context:e}=this,t=e[e.length-1];if(t.token===`{`&&!t.isExpr)return!0}return super.braceIsBlock(e)}};function io(e,t){if(!$a.test(e.input.slice(e.end,e.pos)))return!1;let n=so(e.input,t,`statements`,{afterOperand:!0});n.lookahead=!1;let r=0;try{for(;;){n.nextToken();let e=n.type;if(e===B.eof)return!1;if(r>0)ao.has(e)?r++:oo.has(e)&&r--;else if(e===B.bracketL)r=1;else if(e===B.dot){if(n.nextToken(),n.type!==B.name&&!n.type.keyword)return!1}else return e===B.eq||e===B.assign}}catch{return!1}}var ao=new Set([B.parenL,B.bracketL,B.braceL,B.dollarBraceL]),oo=new Set([B.parenR,B.bracketR,B.braceR]);function so(e,t,n,{onComment:r,afterOperand:i=!1}={}){let a=new ro(r?{...Ya,onComment:r}:Ya,e,t);return n===`expression`&&(a.type=B.parenL),i&&(a.exprAllowed=!1),a}var co=class extends SyntaxError{constructor(e,t,n,r){super(`${e} ${fo(t,n)}`+lo(r,e=>uo(t,e))),this.reason=e,this.source=t,this.pos=n,this.bracket=r,this.name=`SyntaxError`}reasonIn(e,t){return this.reason+lo(this.bracket,n=>{let{line:r,column:i}=ii(e,t+n);return`at line ${r}, column ${i+1}`})}};function lo(e,t){return e?` (missing \"${e.closer}\" for the \"${e.open}\" ${t(e.pos)})`:``}function uo(e,t){let{line:n,column:r}=ii(e,t);return $a.test(e)?`at line ${n}, column ${r+1}`:`at column ${r+1}`}function fo(e,t){let{column:n}=ii(e,t),r=t-n,i=e.slice(r).search($a),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`${uo(e,t)}: ${c.trim()}`}var po=e=>e[e.length-1],mo={\"(\":`)`,\"[\":`]`,\"{\":`}`,\"${\":`}`};function ho(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}=go(e,n),o=n>=e.length||a===``,s=!1;r===`Unexpected token`?(r=o?`Unexpected end of code`:`Unexpected \"${a}\"`,s=!!i&&mo[i.text]!==a&&(o||[`)`,`]`,`}`,`;`,`{`].includes(a))):r.startsWith(`Unterminated template`)&&(s=i?.text===\"${\");let c=s&&i?{open:i.text,closer:mo[i.text],pos:i.pos}:void 0;return new co(r,e,n,c)}function go(e,t){let n=[];for(let r of Ao(e,0,`statements`)){if(`error`in r)break;if(r.start>=t||r.type===B.eof)return{open:po(n),token:e.slice(r.start,r.end)};let i=e.slice(r.start,r.end);i in mo?n.push({text:i,pos:r.start}):n.length&&mo[po(n).text]===i&&n.pop()}return{open:po(n),token:e.charAt(t)}}function _o(e,t=`expression`){let n=new Map;for(;;){let r=new Set;try{let i=vo(e,t,n,r),a={refs:[],strings:[]};return Co(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)||(Za.lastIndex=i+1,e.charAt(i)!==`%`||!Za.test(e)))throw t;n.set(i,!r.has(i))}}}function vo(e,t,n,r){try{let i=so(e,0,t);if(i.percentAt=n,i.transientsRead=r,t===`statements`)return i.parse();i.nextToken();let a=i.parseExpression();if(i.type!==B.eof)throw Object.assign(SyntaxError(`Unexpected token`),{pos:i.start});return a}catch(t){throw ho(e,t)}}var yo=e=>typeof e==`object`&&!!e&&typeof e.type==`string`,bo={$:`story`,_:`temporary`,\"@\":`local`,\"%\":`transient`};function xo(e,t){let n=e.name,r=t.charAt(e.start);return r===n.charAt(0)&&(r===`@`||r===`%`||(r===`$`||r===`_`)&&Qa.test(n))?[r,n.slice(1)]:null}function So(e,t){if(!yo(e)||e.type!==`Identifier`)return;let n=t.charAt(e.start);if(n===`@`||n===`%`)throw new co(`\"${e.name}\" can't be a property name`,t,e.start)}function Co(e,t,n,r,i){if(Array.isArray(e)){for(let i of e)Co(i,t,n,r,!1);return}if(!yo(e))return;let a=(e,r=!1,i=!1)=>Co(e,t,n,r,i);switch(e.type){case`Identifier`:{let a=xo(e,t);if(!a)return;if(r)throw new co(`\"${e.name}\" is a ${bo[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):So(e.property,t);return;case`Property`:if(e.computed?a(e.key):e.shorthand||So(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):So(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 wo=/[\\p{ID_Continue}$.]*/uy,To=/[\\p{ID_Continue}$]*/uy,Eo=new Set([`of`,`get`,`set`,`static`,`async`]);function Do(e,t,{goal:n=`expression`,stop:r}={}){let i=ko(e,t,n,r);return i<0&&!r?Oo(e,t,n):i}function Oo(e,t,n){let r=so(e,t,n);try{if(n===`statements`)r.parse();else if(r.nextToken(),r.parseExpression(),r.type===B.braceR)return r.start}catch(t){let n=t.pos??-1;if(e.charAt(n)===`}`)return n}return-1}function ko(e,t,n,r){let i=[],a=-1,o=!1,s=t,c=!1,l=!1;for(;;){let t=-1;for(let u of Ao(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===B.eof||n===B.string&&o&&u.start===a)return-1;if(o=n===B.name&&!Eo.has(u.value)||n===B.num,a=u.end,n===B.braceL){if(r?.(u.start))return u.start;i.push(`{`)}else if(n===B.dollarBraceL)i.push(\"${\");else if(n===B.parenL)i.push(`(`);else if(n===B.bracketL)i.push(`[`);else if(n===B.parenR||n===B.bracketR)po(i)===(n===B.parenR?`(`:`[`)&&i.pop();else if(n===B.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*Ao(e,t,n,r={}){let i=so(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=so(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}=Lo(e,n);if(r){yield o(B.string,n,t);continue}}else if(!c&&i.start<=n&&(s===`\"`||s===`'`)){let{end:t,closed:n}=Lo(e,i.start);if(n){yield o(B.string,i.start,t);continue}}else if(!c&&i.start<=n&&s===`/`){let t=Fo(e,i.start);if(t>0){yield o(B.regexp,i.start,t);continue}}else if(!c&&i.start<=n&&/[\\d.]/.test(s)&&/\\d/.test(e.slice(i.start,i.start+2))){wo.lastIndex=i.start,wo.test(e),yield o(B.num,i.start,wo.lastIndex);continue}yield{error:t,pos:n};return}if(yield{type:i.type,start:i.start,end:i.end,value:i.value},i.type===B.eof)return}}function jo(e,t,n=`expression`){return Mo(e,0,t,0,n,!1)}function Mo(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=Ao(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=Ao(e,m,i,{onComment:s}),h=void 0;continue}let o=t.type;if(o===B.eof)return u(m,e.length),e.length;if(u(m,t.start),o===B.name){let i=No(e,t.start,t.value),a=h===B.dot||h===B.questionDot||(i===`$`||i===`_`)&&Po(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===B.string||o===B.regexp||o===B.template||o===B.invalidTemplate)l(t.start,t.end);else if(o===B.backQuote)if(l(t.start,t.end),h===B.template||h===B.invalidTemplate){if(f--,a&&f===0)return t.end}else f++;else o===B.dollarBraceL?(l(t.start,t.end),d.push(\"${\"),r++):o===B.braceR&&po(d)===\"${\"?(d.pop(),r--,l(t.start,t.end)):(o===B.braceL||o===B.parenL||o===B.bracketL?d.push(e.charAt(t.start)):(o===B.braceR||o===B.parenR||o===B.bracketR)&&d.length&&po(d)!==\"${\"&&d.pop(),c(t.start,t.end));h=o,m=t.end}}function No(e,t,n){let r=e.charAt(t);return(r===`@`||r===`%`)&&n.charAt(0)===r||(r===`$`||r===`_`)&&Qa.test(n)?r:null}function Po(e,t,n){if(n!==B.braceL&&n!==B.comma)return!1;let r=/\\S/g;r.lastIndex=t;let i=r.exec(e)?.[0];return i===`:`||i===`(`}function Fo(e,t){let n=!1;for(let r=t+1;r<e.length;r++){let t=e.charAt(r);if($a.test(t))return-1;if(t===`\\\\`)r++;else if(t===`[`)n=!0;else if(t===`]`)n=!1;else if(t===`/`&&!n)return To.lastIndex=r+1,To.test(e),To.lastIndex}return-1}function Io(e){if(e[0]!==`\"`&&e[0]!==`'`)return null;try{let t=so(e,0,`expression`);return t.nextToken(),t.type===B.string&&t.end===e.length?t.value:null}catch{return null}}function Lo(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 Ro=/[\\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=Bo(e,i+2);if(t===-1)return-1;i=t+1}else i++}return-1}function Bo(e,t){Vo!==e&&(Vo=e,Ho.clear());let n=Ho.get(t);return n===void 0&&(n=Uo(e,t),Ho.set(t,n)),n}var Vo=``,Ho=new Map;function Uo(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&&Ro.test(e[t-1]))){let n=zo(e,t);t=n===-1?t+1:n}else t++}return-1}var Wo={closeBrace(e,t,n){let r=Do(e,t);return r===-1?Bo(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=Do(e,t,{goal:`statements`,stop:t=>(o.lastIndex=t,o.test(e))});return s===-1?a:s}};function Go(e){let t=e.toLowerCase();return t.startsWith(`on`)||t===`pattern`||t===`srcdoc`}function Ko(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=qn(e[r])?Wo.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 qo=new Set([`do`]),Jo={...Wo,isBlock:Sr,isRaw:e=>qo.has(e),isCodeAttribute:Go},Yo=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 Xo(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 Zo(e,t,n){let r=n.hooks?{...Jo,...n.hooks}:Jo;try{return vr(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}=Xo(e,r);throw new Yo(t.message,r,i,a)}throw t}}function Qo(e,t={}){return Zo(e,`Markup`,t)}function $o(e,t={}){return Zo(e,`Tokens`,t)}function es(e,t={}){let n=[],r=[],i=e.lastIndexOf(`}`),{closeBrace:a}={...Jo,...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 $o(e,{...t,hooks:r}).map(e=>ts(e,n))}catch(e){if(!(e instanceof Yo))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}=Xo(e,a);r.push(new Yo(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 ts(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 ns=`__proto__`;function rs(e,t=e){return e===`__proto__`?`\"${t}\" cannot be used as a variable name (${ns} is reserved)`:void 0}function is(e,t=e){let n=rs(e,t);if(n)throw TypeError(`spindle: ${n}`)}var K=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),as=(e,t)=>e&&K(e,t)?e[t]:void 0;function os(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,ls=e=>cs(e)?e:q(e);function us(e,t,n){let r=q(e);return r[t]=n,r}var ds=Object.freeze(q());function fs(e,t){return[...new Set([...Object.keys(e),...Object.keys(t)])].filter(n=>as(e,n)!==as(t,n))}var ps=e=>typeof e==`number`&&Number.isInteger(e)&&e>=0;function ms(e,t){let n=as(e,t);return ps(n)?n:0}function hs(e,t){let n=ss([e],ps);return t!==void 0&&(n[t]=ms(e,t)+1),n}var gs=new yr;function _s(e,t,n,r=!1){let i=n.filter(e=>e!==`@children`);for(let e of i)e.startsWith(`@`)&&is(e.slice(1),e);gs.set(e,{body:t,params:i,isBlock:r})}function vs(e){return gs.get(e)}function ys(e){for(let t of e){if(t.type===`variable`&&t.scope===`local`&&t.name===`children`||t.type===`html`&&ys(t.children))return!0;if(t.type===`macro`){if(ys(t.children))return!0;if(t.branches){for(let e of t.branches)if(ys(e.children))return!0}}}return!1}function bs(e,t){return e instanceof Error?e.message||t||String(e):typeof e==`string`&&e!==``?e:t??String(e)}function xs(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 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=bs(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}=Lo(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(jo(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 jo(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 xs(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=Io(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):``}var hc=[{name:`name`,type:`text`,holds:`text`,required:!0},{name:`parameters`,type:`text`,holds:`text`}];function gc({name:e=``,parameters:t=``}){return{name:e,params:t.split(/\\s+/).filter(e=>e.startsWith(`@`))}}function _c(e){return gc(dc(e,hc))}function vc(e){let t=[];for(let n of e){if(n.name!==`StoryInit`&&!n.tags?.includes(`widget`))continue;let e=[];for(let r of es(n.content).tokens)if(r.type===`macro`&&r.name.toLowerCase()===`widget`){if(!r.isClose){e.push({rawArgs:r.rawArgs,isBlock:!1});continue}let n=e.pop();if(!n?.isBlock)continue;try{t.push(_c(n.rawArgs).name)}catch{}}else r.type===`variable`&&r.scope===`local`&&r.name===`children`&&e.length>0&&(e[e.length-1].isBlock=!0)}return t}function yc({name:e,params:t},n){let r=ys(n);_s(e,n,t,r),r&&Cr(e)}function bc(e,t){for(let n of e)if(n.type===`macro`&&n.name===`widget`&&n.rawArgs){let e=_c(n.rawArgs);try{yc(e,n.children)}catch(n){console.error(`spindle: widget \"${e.name}\" in passage \"${t}\" was not registered: ${bs(n)}`)}}}var xc=e=>Symbol.iterator in e,Sc=e=>`entries`in e,Cc=(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},wc=(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 Tc(e,t){return Object.is(e,t)?!0:typeof e!=`object`||!e||typeof t!=`object`||!t||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:xc(e)&&xc(t)?Sc(e)&&Sc(t)?Cc(e,t):wc(e,t):Cc({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}var Ec=ge(null),Dc=ge(null);function Oc(...e){let t=j(),n=M(Ec);return Q(r=>{if(t.current&&n?.(r))return t.current;let i={};for(let t of e)i[t]=r[t];return Tc(t.current,i)?t.current:t.current=i})}function kc(){let{variables:e,temporary:t,transient:n,renderCounts:r}=Oc(`variables`,`temporary`,`transient`,`renderCounts`),i=M(Tp);return Pe(()=>[e,t,i,n],[e,t,i,n,r])}var Ac=1831565813;function jc(e){let t=e|0;return()=>{t=t+Ac|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 Mc(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t}var Nc=!1,Pc=``,Fc=0,Ic=null,Lc=0;function Rc(e,t=!0){let n;n=e===void 0?String(Date.now())+String(Math.random()):t?e+`|`+Date.now()+`|`+Math.random():e,Pc=n,Fc=0,Ic=jc(Mc(n)),Nc=!0,Lc++}function zc(e,t){Lc++,Bc(e,t)}function Bc(e,t){Pc=e;let n=Math.imul(t%4294967296,Ac);Ic=jc(Mc(e)+n|0),Nc=!0,Fc=t}function Vc(){Lc++,Nc=!1,Pc=``,Fc=0,Ic=null}function Hc(e){let t={generation:Lc,seed:Pc,pull:Fc};try{return e()}finally{Nc&&Lc===t.generation&&Fc!==t.pull&&Bc(t.seed,t.pull)}}function Uc(){return Nc?{seed:Pc,pull:Fc}:null}function Wc(){return!Nc||!Ic?Math.random():(Fc++,Ic())}function Gc(e,t){return e>t&&([e,t]=[t,e]),Math.floor(Wc()*(t-e+1))+e}function Kc(){return Nc}function qc(){return Pc}function Jc(){return Fc}var Yc=500,Xc={$:`variables`,_:`temporary`,\"@\":`locals`,\"%\":`transient`},Zc=/[\\p{ID_Continue}$\\u200c\\u200d]$/u;function Qc(e,t=`expression`){let n=t===`statements`?`s`+e:`e`+e,r=$c.get(n);if(r!==void 0)return r;let{refs:i}=_o(e,t),a=``,o=0;for(let t of i){let n=rs(t.name,t.sigil+t.name);if(n)throw SyntaxError(`spindle: ${n}`);a+=e.slice(o,t.start),t.shorthand?a+=`${t.name}: `:Zc.test(a.slice(-2))&&(a+=` `),a+=`${Xc[t.sigil]}[\"${t.name}\"]`,o=t.end}return a+=e.slice(o),$c.size>=Yc&&$c.delete($c.keys().next().value),$c.set(n,a),a}var $c=new Map,el=500,tl=new Map,nl=`const {currentPassage,previousPassage,visited,hasVisited,hasVisitedAny,hasVisitedAll,rendered,hasRendered,hasRenderedAny,hasRenderedAll,random,randomInt}=__fns;`;function rl(e,t){let n=tl.get(e);if(n)return tl.delete(e),tl.set(e,n),n;let r=Function(`variables`,`temporary`,`locals`,`__fns`,`transient`,nl+t);if(tl.set(e,r),tl.size>el){let e=tl.keys().next().value;e!==void 0&&tl.delete(e)}return r}function il(){let e=Q.getState();return e.storyData?.passages.get(e.currentPassage)}function al(){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 ol(e){let t=t=>ms(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 sl(e,t){let n=ol(e),r=ol(t);return{currentPassage:il,previousPassage:al,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 cl=null;function ll(){return cl??(cl={...sl(()=>Q.getState().visitCounts,()=>Q.getState().renderCounts),random:Wc,randomInt:Gc}),cl}function ul(e){return cs(e)?e:Object.isExtensible(e)?(Object.setPrototypeOf(e,null),e):ls(e)}function dl(e,...[t,n,r=ds,i=ds]){return e(ul(t),ul(n),ul(r),ll(),ul(i))}function fl(e,...t){let n=`return (${Qc(e)}\\n);`;return dl(rl(n,n),...t)}function pl(e,...t){let n=Qc(e,`statements`);dl(rl(`exec:`+n,n),...t)}var ml=new yr;function hl(e,t){ml.set(e,t)}function gl(e){return ml.get(e)}var _l=new yr;function vl(e,t){t?_l.set(e,t):_l.delete(e)}function yl(e){return _l.get(e)}var bl=new br;function xl(e){bl.add(e)}function Sl(e){return bl.has(e)}var Cl=[`expression`,`statements`,`passage`,`variable`,`string`,`text`,`names`,`delay`,`number`,`flag`,`separator`,`options`],wl=[`markup`,`text`,`passage`,`expression`,`statements`];function Tl(e,t){let n=`Give a \\`string\\` or \\`text\\` parameter one of ${wl.join(`, `)} to hold (see docs/custom-macros.md#what-a-string-holds).`;for(let r of t){let t=r.type;if(!Cl.includes(t))throw El(e,r,t===void 0?`has no type`:`has the unknown type ${JSON.stringify(t)}`,`Give it one of the types ${Cl.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 El(e,r,`is of the type ${t}, which holds what it is`,n);if(i!==void 0&&!wl.includes(i))throw El(e,r,`holds the unknown ${JSON.stringify(i)}`,n);r.parameters&&Tl(e,r.parameters)}}function El(e,t,n,r){return Error(`spindle: The parameter \"${t.name}\" of the macro {${e}} ${n}. ${r}`)}var Dl=new yr;function Ol(e,t){Dl.set(e,t)}function kl(e){return Dl.get(e)?.parameters}function Al(){return Array.from(Dl.values())}function jl(e){return e==null?``:String(e)}function Ml(e,t,n){return e||t?b(`span`,{id:t,class:e},n):b(S,null,n)}function Nl(e){return e.includes(`{`)||e.includes(`}`)}function Pl(e,t){return e?.length?{nodes:e,outer:t??null}:null}var Fl=new Map,Il=2e3;function Ll(e){let t=Fl.get(e);if(t===void 0){try{t={nodes:Qo(e,{text:!0})}}catch(e){t={error:e}}Fl.size>=Il&&Fl.clear(),Fl.set(e,t)}return t}function Rl(e,t){return e.map(e=>{switch(e.type){case`text`:return{type:`text`,value:t(e.value)};case`html`:return{...e,children:Rl(e.children,t)};case`macro`:{let n={...e,children:Rl(e.children,t)};return e.branches&&(n.branches=e.branches.map(e=>({...e,children:Rl(e.children,t)}))),n}default:return e}})}var zl=100;function Bl(e,t,n){let r=n.split(`.`),i=r[0];is(i,Gn[t]+i);let a=as(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 Vl(e,t){return fl(e,t.variables,t.temporary,t.locals,t.transient)}var Hl=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 jl(Vl(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 jl(Bl(n,e,t))}catch(n){return this.errors.push({macro:Gn[e]+t,error:n}),``}}nested(e,t,n,r,i={}){return r>=zl?(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(Sl(e.name))return``;let r=vs(e.name);if(r){let i=t.locals;if(r.params.length>0){let n=e.rawArgs?Ks(e.rawArgs):[];i=q(t.locals),r.params.forEach((e,r)=>{let a,o=n[r];if(o!==void 0)try{a=Vl(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:Pl(e.children,t.widgetChildren)})}let i=yl(e.name);if(!i){let t=gl(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=>Vl(e,t),renderText:(r,i)=>this.nested(e.name,r,t,n,i?{locals:Ul(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 Ul(e,t){for(let e of Object.keys(t))is(e,`@${e}`);return q(e,t)}function Wl(e,t){let n=new Hl;return{text:n.nodes(e,t,0),errors:n.errors}}function Gl(e,t){if(!Nl(e))return{text:e,errors:[]};let n=Ll(e);return`error`in n?{text:e,errors:[{macro:`markup`,error:n.error}]}:Wl(n.nodes,t)}function Kl(e,t,n){let r=[],i=``;for(let a of Ko(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=Wn[a.expr[0]];try{i+=jl(Bl(t,e,a.expr.slice(1)))}catch(e){r.push({macro:a.expr,error:e})}}else try{i+=jl(Vl(a.expr,t))}catch(e){r.push({macro:`expression`,error:e})}return{text:i,errors:r}}function ql(){let[e,t,n,r]=kc(),i=M(Ip);return Pe(()=>({variables:e,temporary:t,locals:n,transient:r,widgetChildren:i}),[e,t,n,r,i])}function Jl(){let e=ql();return Fe(t=>{if(t===void 0||!Nl(t))return t;let{text:n,errors:r}=Gl(t,e);for(let{macro:e,error:n}of r)console.error(`spindle: {${e}} error in \"${t}\": ${bs(n)}`);return n},[e])}var Yl=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:--Yl,__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 Xl={variable:`variables`,temporary:`temporary`,transient:`transient`};function Zl({node:e}){let{name:t,scope:n}=e,r=Jl(),i=r(e.className),a=r(e.id),o=M(Tp),s=t.split(`.`),c=s[0],l=Q(e=>n===`local`?void 0:as(e[Xl[n]],c)),u=Gn[n],d=rs(c,u+c);if(d)return J(`span`,{class:`error`,children:`{${u}${t} error: ${d}}`});let f;f=n===`local`?as(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 Ml(i,a,jl(f))}function Ql({node:e}){let{expression:t}=e,n=Jl(),r=n(e.className),i=n(e.id),[a,o,s,c]=kc(),l;try{l=jl(fl(t,a,o,s,c))}catch{l=`{error: ${t}}`}return Ml(r,i,l)}function $l(){return{nobr:M(Dp),inline:M(Op),raw:M(kp),locals:M(Tp)}}function eu({body:e,parentValues:t,ownKeys:n}){let r=$l(),[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)=>{is(e,`@${e}`),s.current=us(s.current,e,t),a(n=>({...n,[e]:t}))},[]),u=Pe(()=>({update:l,getValues:c}),[l,c]);return J(Ep.Provider,{value:u,children:J(Tp.Provider,{value:o,children:km(e,{...r,locals:o})})})}function tu(e){let t=Jl();return Ml(t(e.className),t(e.id),J(nu,{...e}))}function nu({body:e,params:t,rawArgs:n,invocationChildren:r}){let i=$l().locals,[a,o,s,c]=kc(),l=M(Ip),u=Pe(()=>Pl(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=fl(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(Ip.Provider,{value:u,children:J(eu,{body:e,parentValues:i,ownKeys:p})})}var ru=document.createElement(`i`);function iu(e){let t=`&`+e+`;`;ru.innerHTML=t;let n=ru.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`||n===t?!1:n}function au(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?(au(e,e.length,0,t),e):t}var su={}.hasOwnProperty;function cu(e){let t={},n=-1;for(;++n<e.length;)lu(t,e[n]);return t}function lu(e,t){let n;for(n in t){let r=(su.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){su.call(r,a)||(r[a]=[]);let e=i[a];uu(r[a],Array.isArray(e)?e:e?[e]:[])}}}function uu(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);au(e,0,0,r)}function du(e){let t={},n=-1;for(;++n<e.length;)fu(t,e[n]);return t}function fu(e,t){let n;for(n in t){let r=(su.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i)r[a]=i[a]}}function pu(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 mu={'\"':`quot`,\"&\":`amp`,\"<\":`lt`,\">\":`gt`};function hu(e){return e.replace(/[\"&<>]/g,t);function t(e){return`&`+mu[e]+`;`}}function gu(e){return e.replace(/[\\t\\n\\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var _u=Du(/[A-Za-z]/),vu=Du(/[\\dA-Za-z]/),yu=Du(/[#-'*+\\--9=?A-Z^-~]/);function bu(e){return e!==null&&(e<32||e===127)}var xu=Du(/\\d/),Su=Du(/[\\dA-Fa-f]/),Cu=Du(/[!-/:-@[-`{-~]/);function Y(e){return e!==null&&e<-2}function wu(e){return e!==null&&(e<0||e===32)}function X(e){return e===-2||e===-1||e===32}var Tu=Du(/\\p{P}|\\p{S}/u),Eu=Du(/\\s/);function Du(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function Ou(e,t){let n=hu(ku(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 ku(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&vu(e.charCodeAt(n+1))&&vu(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 Au={}.hasOwnProperty,ju=/^(https?|ircs?|mailto|xmpp)$/i,Mu=/^https?$/i;function Nu(e){let t=e||{},n=!0,r={},i=[[]],a=[],o=[],s=du([{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=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];Au.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:hu(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[gu(o)]:i;for(n=!0;e--;)if(a[e].image){n=void 0;break}i.image?(_(`<img src=\"`+Ou(s.destination,t.allowDangerousProtocol?void 0:Mu)+`\" alt=\"`),v(i.label),_(`\"`)):_(`<a href=\"`+Ou(s.destination,t.allowDangerousProtocol?void 0:ju)+`\"`),_(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=gu(e.labelId);g(),Au.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`)?pu(t,m(`characterReferenceType`)===`characterReferenceMarkerNumeric`?10:16):iu(t))),p(`characterReferenceType`)}function Ge(e){let n=this.sliceSerialize(e);_(`<a href=\"`+Ou(n,t.allowDangerousProtocol?void 0:ju)+`\">`),v(x(n)),_(`</a>`)}function Ke(e){let t=this.sliceSerialize(e);_(`<a href=\"`+Ou(`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 Pu={tokenize:Fu};function Fu(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 Iu={tokenize:Ru},Lu={tokenize:zu};function Ru(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 au(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(Lu,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(Lu,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++;au(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 zu(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 Bu(e){if(e===null||wu(e)||Eu(e))return 1;if(Tu(e))return 2}function Vu(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 Hu={name:`attention`,resolveAll:Uu,tokenize:Wu};function Uu(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};Gu(d,-c),Gu(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,Vu(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,au(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 Wu(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Bu(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=Bu(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 Gu(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var Ku={name:`autolink`,tokenize:qu};function qu(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 _u(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||vu(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||vu(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||bu(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):yu(t)?(e.consume(t),l):n(t)}function u(e){return vu(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||vu(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var Ju={partial:!0,tokenize:Yu};function Yu(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 Xu={continuation:{tokenize:Qu},exit:$u,name:`blockQuote`,tokenize:Zu};function Zu(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 Qu(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(Xu,t,n)(r)}}function $u(e){e.exit(`blockQuote`)}var ed={name:`characterEscape`,tokenize:td};function td(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 Cu(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var nd={name:`characterReference`,tokenize:rd};function rd(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=vu,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=Su,u):(e.enter(`characterReferenceValue`),a=7,o=xu,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===vu&&!iu(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 id={partial:!0,tokenize:sd},ad={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`),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(id,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(id,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 sd(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 cd={name:`codeIndented`,tokenize:ud},ld={partial:!0,tokenize:dd};function ud(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(ld,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 dd(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 fd={name:`codeText`,previous:md,resolve:pd,tokenize:hd};function pd(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 md(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function hd(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 gd=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&&_d(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),_d(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),_d(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);_d(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);_d(this.left,t.reverse())}}};function _d(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 vd(e){let t={},n=-1,r,i,a,o,s,c,l,u=new gd(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,yd(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 au(e,0,1/0,u.slice(0)),!l}function yd(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 bd={resolve:Sd,tokenize:Cd},xd={partial:!0,tokenize:wd};function Sd(e){return vd(e),e}function Cd(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(xd,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 wd(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 Td(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||bu(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||wu(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||bu(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 Ed(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 Dd(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 Od(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 kd={name:`definition`,tokenize:jd},Ad={partial:!0,tokenize:Md};function jd(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return Ed.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=gu(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 wu(t)?Od(e,l)(t):l(t)}function l(t){return Td(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(Ad,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 Md(e,t,n){return r;function r(t){return wu(t)?Od(e,i)(t):n(t)}function i(t){return Dd(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 Nd={name:`hardBreakEscape`,tokenize:Pd};function Pd(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 Fd={name:`headingAtx`,resolve:Id,tokenize:Ld};function Id(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`},au(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function Ld(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||wu(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||wu(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var Rd=`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(`.`),zd=[`pre`,`script`,`style`,`textarea`],Bd={concrete:!0,name:`htmlFlow`,resolveTo:Ud,tokenize:Wd},Vd={partial:!0,tokenize:Kd},Hd={partial:!0,tokenize:Gd};function Ud(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 Wd(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):_u(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):_u(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 _u(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||wu(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&zd.includes(l)?(i=1,r.interrupt?t(s):D(s)):Rd.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||vu(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||_u(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||vu(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||wu(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(Vd,ce,O)(t)):t===null||Y(t)?(e.exit(`htmlFlowData`),O(t)):(e.consume(t),D)}function O(t){return e.check(Hd,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 zd.includes(n)?(e.consume(t),se):D(t)}return _u(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 Gd(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 Kd(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(Ju,t,n)}}var qd={name:`htmlText`,tokenize:Jd};function Jd(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):_u(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):_u(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 _u(t)?(e.consume(t),S):n(t)}function S(t){return t===45||vu(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||vu(t)?(e.consume(t),w):t===47||t===62||wu(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),re):t===58||t===95||_u(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||vu(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||wu(t)?T(t):(e.consume(t),te)}function ne(e){return e===47||e===62||wu(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 Yd={name:`labelEnd`,resolveAll:$d,resolveTo:ef,tokenize:tf},Xd={tokenize:nf},Zd={tokenize:rf},Qd={tokenize:af};function $d(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&&au(e,0,e.length,n),e}function ef(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,Vu(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]]),au(e,a,e.length,s),e}function tf(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(gu(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(Xd,u,o?u:d)(t):t===91?e.attempt(Zd,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(Qd,u,d)(t)}function u(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}function nf(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 wu(t)?Od(e,a)(t):a(t)}function a(t){return t===41?u(t):Td(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return wu(t)?Od(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?Dd(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return wu(t)?Od(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 rf(e,t,n){let r=this;return i;function i(t){return Ed.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(gu(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function af(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:Yd.resolveAll,tokenize:sf};function sf(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 cf={name:`labelStartLink`,resolveAll:Yd.resolveAll,tokenize:lf};function lf(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 uf={name:`lineEnding`,tokenize:df};function df(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),Z(e,t,`linePrefix`)}}var ff={name:`thematicBreak`,tokenize:pf};function pf(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 mf={continuation:{tokenize:vf},exit:bf,name:`list`,tokenize:_f},hf={partial:!0,tokenize:xf},gf={partial:!0,tokenize:yf};function _f(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:xu(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(ff,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 xu(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(Ju,r.interrupt?n:u,e.attempt(hf,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 vf(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(Ju,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(gf,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,Z(e,e.attempt(mf,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function yf(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 bf(e){e.exit(this.containerState.type)}function xf(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 Sf={name:`setextUnderline`,resolveTo:Cf,tokenize:wf};function Cf(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 wf(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 Tf={tokenize:Ef};function Ef(e){let t=this,n=e.attempt(Ju,r,e.attempt(this.parser.constructs.flowInitial,i,Z(e,e.attempt(this.parser.constructs.flow,i,e.attempt(bd,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 Df={resolveAll:jf()},Of=Af(`string`),kf=Af(`text`);function Af(e){return{resolveAll:jf(e===`text`?Mf: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 jf(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 Mf(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 Nf=t({attentionMarkers:()=>Vf,contentInitial:()=>Ff,disable:()=>Hf,document:()=>Pf,flow:()=>Lf,flowInitial:()=>If,insideSpan:()=>Bf,string:()=>Rf,text:()=>zf}),Pf={42:mf,43:mf,45:mf,48:mf,49:mf,50:mf,51:mf,52:mf,53:mf,54:mf,55:mf,56:mf,57:mf,62:Xu},Ff={91:kd},If={[-2]:cd,[-1]:cd,32:cd},Lf={35:Fd,42:ff,45:[Sf,ff],60:Bd,61:Sf,95:ff,96:ad,126:ad},Rf={38:nd,92:ed},zf={[-5]:uf,[-4]:uf,[-3]:uf,33:of,38:nd,42:Hu,60:[Ku,qd],91:cf,92:[Nd,ed],93:Yd,95:Hu,96:fd},Bf={null:[Hu,Df]},Vf={null:[42,95]},Hf={null:[]};function Uf(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=Vu(a,l.events,l),l.events):[]}function f(e,t){return Gf(p(e),t)}function p(e){return Wf(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&&au(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 Wf(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 Gf(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 Kf(e){let t={constructs:cu([Nf,...(e||{}).extensions||[]]),content:n(Pu),defined:[],document:n(Iu),flow:n(Tf),lazy:{},string:n(Of),text:n(kf)};return t;function n(e){return n;function n(n){return Uf(t,e,n)}}}function qf(e){for(;!vd(e););return e}var Jf=/[\\0\\t\\n\\r]/g;function Yf(){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(Jf.lastIndex=u,c=Jf.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 Xf(e,t,n){return typeof t!=`string`&&(n=t,t=void 0),Nu(n)(qf(Kf(n).document().write(Yf()(e,t,!0))))}var Zf={none:``,left:` align=\"left\"`,right:` align=\"right\"`,center:` align=\"center\"`};function Qf(){return{enter:{table(e){let t=e._align;this.lineEndingIfNeeded(),this.tag(`<table>`),this.setData(`tableAlign`,t)},tableBody(){this.tag(`<tbody>`)},tableData(){let e=Zf[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=Zf[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,$f)),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`+Zf[e[t]]+`></td>`),t++;this.setData(`tableColumn`,t),this.lineEndingIfNeeded(),this.tag(`</tr>`)}}}}function $f(e,t){return t===`|`?t:e}var ep=class{constructor(){this.map=[]}add(e,t,n){tp(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 tp(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 np(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 rp(){return{flow:{null:{name:`table`,tokenize:ip,resolveAll:ap}}}}function ip(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||wu(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||wu(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 ap(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 ep;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(sp(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&&sp(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=np(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({},cp(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=cp(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=cp(t.events,n[2]),a=cp(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({},cp(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function sp(e,t,n,r,i){let a=[],o=cp(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 cp(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}function lp(){return{enter:{strikethrough(){this.tag(`<del>`)}},exit:{strikethrough(){this.tag(`</del>`)}}}}function up(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&&au(o,o.length,0,Vu(s,e.slice(r+1,n),t)),au(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),au(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=Bu(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=Bu(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}function dp(e){let t=[`codeIndented`];return e?.inline&&t.push(`list`,`headingAtx`,`setextUnderline`,`thematicBreak`,`blockQuote`,`codeFenced`,`table`),{allowDangerousHtml:!0,extensions:[rp(),up(),{disable:{null:t}}],htmlExtensions:[Qf(),lp()]}}function fp(e,t){let n=dp(t);return Xf(e,{...n,extensions:[...n.extensions??[],vp(e),mp]})}var pp=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},mp={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:pp}}},hp=/[#-'*+\\--9=?A-Z^-~]/,gp=/[0-9A-Za-z]/,_p=/[A-Za-z]/;function vp(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]===`!`&&_p.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(;hp.test(e[n]??``);)n++;if(e[n]!==`@`)return!1;n++;let r=0,i=`atSignOrDot`;for(;;){let t=e[n]??``;if(i===`atSignOrDot`){if(!gp.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===`-`||gp.test(t))&&r++<63))return!1;n++,i=t===`-`?`value`:`label`}}}let c={name:`unclosedHtml`,resolveTo:pp,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 yp(e){let t=e.metadata[`data-source-file`],n=e.metadata[`data-source-line`];return t?n?` (${t}:${n})`:` (${t})`:``}function bp(){let e=Q.getState();if(!e.storyData)return``;let t=e.storyData.passages.get(e.currentPassage);return t?yp(t):``}function xp({macro:e,error:t}){return J(`span`,{class:`error`,title:String(t),children:`{${e} error${bp()}: ${bs(t)}}`})}function Sp(e,t,n=bp()){console.error(`spindle: Error in {${e}}${n}:`,t)}function Cp(e,t,n){let r=j();if(r.current===void 0){r.current=null;let i=bp();try{n()}catch(n){r.current={error:n},Sp(`${e} ${t}`.trim(),n,i)}}return r.current?J(xp,{macro:e,error:r.current.error}):null}var wp={update:e=>{throw Error(`Cannot set @${e} — local variables require a {for}, widget, {link}, or {button} scope`)},getValues:()=>ds},Tp=ge(ds),Ep=ge(wp),Dp=ge(!1),Op=ge(!1),kp=ge(!1),Ap=ge(``),jp=0;function Mp(){return Ae(()=>`v${++jp}`)[0]}var Np=ge(!1),Pp=`http://www.w3.org/2000/svg`,Fp=new Set([`pre`,`textarea`,`style`]),Ip=ge(null);function Lp(e,t){return`<span data-tw=${e}:${t}></span>`}var Rp=/(?:(?<=\\\\)\\uE000)?<span data-tw=([0-9a-z]+):(\\d+)><\\/span>/g,zp=``;function Bp(e,t){if(!e.includes(`<span data-tw=`))return[e];let n=[],r=0;for(let i of e.matchAll(Rp))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 Vp(e,t){return Bp(e,t).map(e=>typeof e==`number`?t.components[e]:e)}function Hp({tag:e,attributes:t,placeholders:n,svg:r,children:i}){let a=ql(),o=[],{props:s,direct:c}=tm(t.map(([e,t,r])=>{let i=n[e];if(!i)return[e,t,r];let s=Wl(i,a);for(let t of s.errors)o.push([e,t]);return[e,s.text,r]}),r),l=nm(c);return Wp(o,b(e,l?{...s,ref:l}:s,...i))}function Up({tag:e,props:t,direct:n,children:r}){let i=nm(n);return b(e,{...t,ref:i},...r)}function Wp(e,t){return e.length===0?t:J(S,{children:[e.map(([e,{macro:t,error:n}],r)=>J(xp,{macro:t,error:Error(`in attribute \"${e}\": ${bs(n)}`)},r)),t]})}function Gp(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 Kp(e){let t=document.createElement(`template`);return t.innerHTML=e,t.content}function qp(e,t,n=!1){let r=Kp(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)=>Jp(e,n,t))})}function Jp(e,t,n){if(e.nodeType===Node.TEXT_NODE){let t=e.textContent??``;t.endsWith(`\\\\${zp}`)&&Gp(e.nextSibling,n)!==-1&&(t=t.slice(0,-1));let r=Vp(t,n);return r.length===1?r[0]:r}if(e.nodeType===Node.ELEMENT_NODE){let r=e,i=r.localName,a=Gp(r,n);if(a!==-1)return n.components[a];let o=r.namespaceURI===Pp,s=[],c;for(let{name:e,value:t}of Array.from(r.attributes)){s.push([e,t,t]);let r=Bp(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)=>Jp(e,t,n));if(c)return J(Hp,{tag:i,attributes:s,placeholders:c,svg:o,children:l},t);let{props:u,direct:d}=tm(s,o);return d.length>0?J(Up,{tag:i,props:u,direct:d,children:l},t):b(i,{...u,key:t},...l)}return null}var Yp=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(`.`)),Xp=new Set([`value`,`checked`,`selected`,`muted`]),Zp=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`]),Qp=new Set([...new Set([`key`,`ref`,`children`,`dangerouslySetInnerHTML`]),`class`,`className`]),$p=/^[A-Za-z_:][\\w:.-]*$/;function em(e,t,n){if($p.test(t)){e.setAttribute(t,n);return}let r=Kp(`<i ${t}=\"\"></i>`).firstChild.attributes[0];if(!r)return;let i=r.cloneNode();i.value=n,e.setAttributeNode(i)}function tm(e,t){let n={},r=[];for(let[i,a,o]of e){let e=i.toLowerCase();Zp.has(e)&&o!==``&&a===``||(!t&&Xp.has(e)?n[e]=e!==`value`&&o===``?!0:a:!$p.test(i)||e.startsWith(`on`)||e===`translate`||t&&(Qp.has(i)||i===`__proto__`)?r.push([i,a]):n[t?i:i.toUpperCase()]=a)}return{props:n,direct:r}}function nm(e){let t=j(null);return Ne(()=>{let n=t.current;if(!(!n||e.length===0)){for(let[t,r]of e)em(n,t,r);return()=>{for(let[t]of e)n.removeAttribute(t)}}},[JSON.stringify(e)]),e.length>0?t:void 0}var rm=new Map,im=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 om(e){return am(e,im,e=>Kp(`<i title=\"${e.replace(/\"/g,`"`)}\"></i>`).firstChild.getAttribute(`title`))}function sm(e){return am(e,rm,e=>Kp(`<i>${e.replace(/</g,`<`)}</i>`).firstChild.textContent)}var cm=/\\{[$_@%]\\w/,lm=new Map,um=2e3;function dm(e){let t=lm.get(e);return t===void 0&&(t=Ll(e),`nodes`in t&&e.includes(`&`)&&(t={nodes:Rl(t.nodes,om)}),lm.size>=um&&lm.clear(),lm.set(e,t)),t}function fm(e,t,n,r){if(Go(e)){if(!t.includes(`&`)&&!cm.test(t))return t;let i=Kl(t,n,om);for(let t of i.errors)r.push([e,t]);return i.text}if(!Nl(t))return om(t);let i=dm(t);if(`error`in i)return r.push([e,{macro:`markup`,error:i.error}]),om(t);let a=Wl(i.nodes,n);for(let t of a.errors)r.push([e,t]);return a.text}function pm(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 mm({node:e}){let t=ql(),{nobr:n,locals:r,raw:i,inline:a}=$l(),o=M(Np),s=e.tag.toLowerCase(),c=s===`svg`,l=!i&&(c||Fp.has(s)),u=[],{props:d,direct:f}=tm(Object.entries(e.attributes).map(([e,n])=>[e,fm(e,n,t,u),n]),o||c),p=nm(f);p&&(d.ref=p);let m=Yp.has(s),h;if(e.children.length>0)if(i||l)h=xm(e.children);else{let t=s===`details`?pm(e.children):-1,i=e=>km(e,{nobr:n,locals:r,inline:m});h=t===-1?i(e.children):J(S,{children:[i(e.children.slice(0,t)),bm(e.children[t]),i(e.children.slice(t+1))]}),m!==a&&(h=J(Op.Provider,{value:m,children:h}))}let g=b(e.tag,d,h);return c&&!o&&(g=J(Np.Provider,{value:!0,children:g})),Wp(u,l?J(kp.Provider,{value:!0,children:g}):g)}function hm(){let e=M(Ip),t=$l();return e?J(Ip.Provider,{value:e.outer,children:km(e.nodes,t)}):null}var gm=new WeakMap,_m=0;function vm(e){let t=gm.get(e);return t===void 0&&(t=`n${_m++}`,gm.set(e,t)),t}function ym(e,t){if(Sl(e.name))return null;let n={rawArgs:e.rawArgs,className:e.className,id:e.id},r=vs(e.name);if(r)return J(tu,{...n,body:r.body,params:r.params,invocationChildren:e.children},t);let i=gl(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 bm(e){if(e.type===`text`)return sm(e.value);let t=vm(e);switch(e.type){case`variable`:return e.scope===`local`&&e.name===`children`?J(hm,{},t):J(Zl,{node:e},t);case`expression`:return J(Ql,{node:e},t);case`macro`:return ym(e,t);case`html`:return J(mm,{node:e},t);default:return e}}function xm(e){return e.length===0?null:e.map(e=>bm(e))}var Sm=/[*_`#|~\\[>\\\\\\-+=\\r]|!\\[|\\d+[.)]|&#?[a-zA-Z0-9]+;| {2}\\n|<[!?]/,Cm=/(?:\\r\\n|\\r(?!\\n)|\\n)\\s*[\\r\\n]/,wm=/<span data-tw=[0-9a-z]+:\\d+><\\/span>/g,Tm=` \t\\r\n`;function Em(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 Dm(e){return e.includes(`\n`)?e.split(`\n`).map((e,t,n)=>{let r=t===0?0:Em(e,0,1,` \t`),i=t===n.length-1?e.length:Em(e,e.length,-1,` \t`);return e.slice(r,Math.max(r,i))}).join(`\n`):e}function Om(e,t,n){let r=Vp(Dm(e),t).filter(e=>e!==``);return n?J(S,{children:r}):b(`p`,null,...r)}function km(e,t){if(e.length===0)return null;if(t?.raw)return xm(e);if(!e.some(e=>e.type===`text`&&(e.value.trim()!==``||Cm.test(e.value))))return e.map(e=>bm(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(bm(a)),r.nodes.push(a),i.endsWith(`\\\\`)&&(i+=zp),i+=Lp(r.nonce,o)}let a=!!(t?.nobr||t?.inline),o=i.slice(0,Em(i,0,1,Tm)),s=o.length===i.length?``:i.slice(Em(i,i.length,-1,Tm)),c=i.slice(o.length,i.length-s.length),l=e=>a&&(o||s)?J(S,{children:[o,e,s]}):e,u=i.replace(wm,``);return!Sm.test(u)&&!Cm.test(u)?l(Om(c,r,a)):l(qp(fp(i,{inline:t?.inline}),r,a))}var Am=2**32-1,jm=Am-1,Mm=class extends Error{constructor(e,t,n,r){super(e),this.name=`DevalueError`,this.path=t.join(``),this.value=n,this.root=r}},Nm=Symbol();function Pm(e,t){let n=[];for(let r=0;r<e.length;r+=1){let i=e[r];i===Nm?n.push(`.get(${t(e[++r])})`):typeof i==`number`?n.push(`[${i}]`):n.push(qm(i))}return n}var Fm=Object.getOwnPropertyNames(Object.prototype).sort().join(`\\0`);function Im(e){let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null||Object.getPrototypeOf(t)===null||Object.getOwnPropertyNames(t).sort().join(`\\0`)===Fm}function Lm(e){return Object.prototype.toString.call(e).slice(8,-1)}function Rm(e){return typeof Buffer<`u`&&Buffer.isBuffer(e)}function zm(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 Bm=/[\"<\\\\\\u0000-\\u001f\\u2028\\u2029]/;function Vm(e){if(!Bm.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=zm(e[i]);o&&(t+=e.slice(n,i)+o,n=i+1)}return`\"${n===0?e:t+e.slice(n)}\"`}var Hm=64,Um=new Map;function Wm(e){if(e.length>Hm)return Vm(e);let t=Um.get(e);return t===void 0&&(Um.size>=1024&&Um.clear(),t=Vm(e),Um.set(e,t)),t}function Gm(e){let t=Object.getOwnPropertySymbols(e);return t.length===0?t:t.filter(t=>Object.getOwnPropertyDescriptor(e,t)?.enumerable)}var Km=/^[a-zA-Z_$][a-zA-Z_$0-9]*$/;function qm(e){return Km.test(e)?`.`+e:`[`+JSON.stringify(e)+`]`}function Jm(e){return!(!Number.isInteger(e)||e<0||e>jm)}function Ym(e){return!(!Number.isInteger(e)||e<0||e>Am)}function Xm(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 Jm(+e)}function Zm(e){for(var t=e.length-1;t>=0&&!Xm(e[t]);t--);return t+1}function Qm(e){let t=Object.keys(e);return t.length=Zm(t),t}function $m(e){return new Uint8Array(e).toBase64()}function eh(e){return Uint8Array.fromBase64(e).buffer}function th(e){return Buffer.from(e).toString(`base64`)}function nh(e){return Uint8Array.from(Buffer.from(e,`base64`)).buffer}function rh(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 ih(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`,oh=typeof process==`object`&&process.versions?.node!==void 0,sh=ah?$m:oh?th:rh,ch=ah?eh:oh?nh:ih;function lh(e,t){if(!t)return e;let n={};for(let r of Object.keys(e))n[r]=t[r]??e[r];return n}var uh=Object.freeze({kind:`not-plain`}),dh=Object.freeze({kind:`symbol-keys`}),fh=Object.freeze({identify:e=>e,typeOf:e=>e===null?`null`:typeof e,toPrimitive:e=>e,tagOf:e=>Lm(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=>(Rm(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=>Qm(e),shapeOf:e=>Im(e)?Gm(e).length>0?dh:{kind:Object.getPrototypeOf(e)===null?`null-proto`:`plain`,keys:Object.keys(e)}:uh,get:(e,t)=>e[t]}),ph=Object.getOwnPropertyDescriptor(ArrayBuffer.prototype,`byteLength`)?.get,mh=typeof SharedArrayBuffer>`u`?void 0:Object.getOwnPropertyDescriptor(SharedArrayBuffer.prototype,`byteLength`)?.get,hh=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{ph.call(t)}catch(e){if(!mh)throw e;mh.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[jm]=void 0,delete t[jm],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 gh(){throw Error(`Invalid input`)}function _h(e,t,n){return vh(JSON.parse(e),t,n)}function vh(e,t,n){let r=lh(hh,n?.operations);if(typeof e==`number`)return c(e,!0);(!Array.isArray(e)||e.length===0)&&gh();let i=e,a=Array(i.length),o=null;function s(e){return(!Jm(e)||e>=i.length)&&gh(),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`)&&gh(),e in a)return a[e];e>=i.length&&gh();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&&gh()}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`)&&gh();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(ch(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];Ym(t)||gh();let n=r.createSparseArray(t);a[e]=n;for(let e=2;e<l.length;e+=2){let i=l[e];(!Jm(i)||i>=t)&&gh(),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 yh(e,t,n){let r=bh(!1,e,t,n);return typeof r==`string`?r:`[${r.join(`,`)}]`}function bh(e,t,n,r){let i=lh(fh,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 Mm(e,Pm(c,e=>{let t=i.typeOf(e);return t!==`object`&&t!==`function`&&t!==`symbol`?xh(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=xh(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\",${Vm(i.toStringValue(t))}]`;break;case`URLSearchParams`:m=`[\"URLSearchParams\",${Vm(i.toStringValue(t))}]`;break;case`RegExp`:let{source:n,flags:r}=i.regExpInfo(t);m=r?`[\"RegExp\",${Vm(n)},\"${r}\"]`:`[\"RegExp\",${Vm(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(Nm,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\",\"${sh(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}\",${Vm(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+=`,${Wm(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+=`${Wm(r)}:${d(i.get(t,r))}`,c.pop();m+=`}`}}}}return a[n]=m,n}let f=d(t);return f<0?`${f}`:a}function xh(e){let t=typeof e;return t===`string`?Vm(e):e===void 0?`-1`:e===0&&1/e<0?`-6`:t===`bigint`?`[\"BigInt\",\"${e}\"]`:String(e)}var Sh=e=>Object.prototype.toString.call(e).slice(8,-1),Ch=e=>Sh(e).startsWith(`Temporal.`),wh=e=>e instanceof Number||e instanceof String||e instanceof Boolean||Sh(e)===`BigInt`;function Th(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||wh(e)||Ch(e)}function Eh(e){if(!Th(e))return;let t=e instanceof Error?`Error`:Sh(e);return`${/^[AEIOU]/.test(t)?`an`:`a`} ${t}`}var Dh=e=>e!==`4294967295`&&String(Number(e)>>>0)===e;function Oh(e){let t=Object.keys(e);return Array.isArray(e)?t.filter(e=>!Dh(e)):t}function kh(e){return jt(e)?e.entries():Map.prototype.entries.call(e)}function Ah(e){return jt(e)?e.values():Set.prototype.values.call(e)}function jh(e){if(jt(e))return e.size;let t=e instanceof Map?Map.prototype:Set.prototype;return Reflect.get(t,`size`,e)}function Mh(e,t){return jt(e)?e.get(t):Map.prototype.get.call(e,t)}function Nh(e,t,n){jt(e)?e.set(t,n):Map.prototype.set.call(e,t,n)}var Ph=new Map,Fh=new Map,Ih=[ArrayBuffer,DataView,Object.getPrototypeOf(Int8Array),URL,URLSearchParams,Number,String,Boolean,Promise,WeakMap,WeakSet,Function];function Lh(e,t){let n=typeof t==`function`?Ih.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)`);Ph.set(e,t),Fh.set(t,e)}function Rh(e){let t=Object.getPrototypeOf(e);return t===null?void 0:Fh.get(t.constructor)}var zh=`c:`,Bh=`E:`,Vh=`S`,Hh=`K`,Uh=`R`,Wh=new Map([Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError,globalThis.AggregateError].map(e=>[e.prototype,e.name])),Gh=new Map([...Wh].map(([e,t])=>[t,e.constructor])),Kh=[`message`,`cause`,`errors`],qh=e=>typeof e==`object`&&!!e,Jh=e=>qh(e)&&Object.getPrototypeOf(e)===Object.prototype,Yh=e=>TypeError(`spindle: Malformed data for class \"${e}\"`),Xh=(e,t,n)=>{Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0,configurable:!0})};function Zh(e){if(Object.getOwnPropertySymbols(e).length>0)throw TypeError(`spindle: Cannot save an object with symbol keys`)}function Qh(e,t=Object.keys(e)){Zh(e);let n={};if(e instanceof Error)for(let t of Kh)K(e,t)&&Xh(n,t,e[t]);for(let r of t)Xh(n,r,e[r]);return n}var $h={Array,Map,Set,Date,RegExp};function eg(e){let t=()=>Qh(e,Oh(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(kh(e)),t()]:e instanceof Set?[`Set`,Array.from(Ah(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()]:Qh(e)}function tg(e){for(let t of Kh)K(e,t)&&Object.defineProperty(e,t,{enumerable:!1})}var ng=e=>e.length===1&&JSON.stringify(e).length>3;function rg(){let e={};for(let[t,n]of Ph)e[zh+t]=e=>qh(e)&&Object.getPrototypeOf(e)===n.prototype&&eg(e);for(let[t,n]of Wh)e[Bh+n]=e=>qh(e)&&Object.getPrototypeOf(e)===t&&Qh(e);return e[Vh]=e=>{if(typeof e!=`symbol`)return!1;let t=Symbol.keyFor(e);return t!==void 0&&[t]},e[Uh]=e=>e instanceof RegExp&&e.lastIndex!==0&&[e.source,e.flags,e.lastIndex],e[Hh]=e=>{if(!Jh(e))return!1;let t=Object.keys(e);if(!t.some(ng))return!1;if(Zh(e),t.includes(`__proto__`))throw TypeError(`spindle: Cannot save a property named \"__proto__\"`);return t.flatMap(t=>[t,e[t]])},e}function ig(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 ag(e,t){return e===`RegExp`?ig(t):typeof t==`number`?new Date(t):void 0}var og=new WeakMap;function sg(e,t,n){let[r,i,a]=n,o=typeof r==`string`&&K($h,r)?$h[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)&&!Jh(a))throw Yh(e);let c=og.get(n);if(!c){let a=s?ag(r,i):new o;if(!a)throw Yh(e);c=Object.setPrototypeOf(a,t.prototype),og.set(n,c)}if(!s&&Array.isArray(i)&&cg(c,i),Jh(a))for(let e of Object.keys(a))Xh(c,e,a[e]);return c}function cg(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 lg(e){return t=>{if(Array.isArray(t))return sg(e,ug(e),t);if(!Jh(t)){if(qh(t)&&Rh(t)===e)return t;throw Yh(e)}let n=ug(e);if(Object.values($h).some(e=>n.prototype instanceof e))throw Yh(e);return Object.setPrototypeOf(t,n.prototype),t instanceof Error&&tg(t),t}}function ug(e){let t=Ph.get(e);if(!t)throw TypeError(`spindle: The save holds an instance of class \"${e}\", which is not registered`);return t}function dg(e){let t=Gh.get(e);if(t)return n=>{if(Object.getPrototypeOf(n)===t.prototype)return n;if(!Jh(n))throw TypeError(`spindle: Malformed data for \"${e}\"`);return Object.setPrototypeOf(n,t.prototype),tg(n),n}}var fg=new WeakMap;function pg(e){if(!Array.isArray(e)||e.length%2!=0)throw TypeError(`spindle: Malformed object entries`);let t=fg.get(e);t||fg.set(e,t={});for(let n=0;n<e.length&&K(e,n);n+=2){let r=e[n];if(typeof r!=`string`||r===`__proto__`)throw TypeError(`spindle: Malformed object entries`);Xh(t,r,K(e,n+1)?e[n+1]:void 0)}return t}var mg=new Proxy({},{getOwnPropertyDescriptor(e,t){let n=hg(t);return n&&{value:n,enumerable:!0,configurable:!0}},get:(e,t)=>hg(t)});function hg(e){if(typeof e==`string`){if(e===Vh)return e=>{if(!Array.isArray(e)||typeof e[0]!=`string`)throw TypeError(`spindle: Malformed symbol`);return Symbol.for(e[0])};if(e===Hh)return pg;if(e===Uh)return e=>{let t=ig(e);if(!t)throw TypeError(`spindle: Malformed regular expression`);return t};if(e.startsWith(zh))return lg(e.slice(2));if(e.startsWith(Bh))return dg(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`:qh(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 _g(e){try{return yh(e,rg())}catch(t){throw gg(t,e)}}function vg(e){return _h(e,mg)}var yg=class extends Error{constructor(){super(`This save was made by an incompatible version of Spindle`),this.name=`IncompatibleSaveError`}},bg={};function xg(e){if(typeof e!=`number`||!Number.isInteger(e)||e<1||e>1)throw new yg}function Sg(e,t){xg(e);let n=t;for(let t=e;t<1;t++){let e=bg[t];if(!e)throw new yg;n=e(n)}return n}var Cg=e=>e&&new Map(Object.entries(e));function wg(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 Tg(e){try{return{formatVersion:1,data:_g({...e,visitCounts:Cg(e.visitCounts),renderCounts:Cg(e.renderCounts)})}}catch(e){throw wg(e)}}var Eg=()=>Error(`Invalid save data`);function Dg(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function Og(e){return e==null?!0:Dg(e)&&typeof e.seed==`string`&&typeof e.pull==`number`&&Number.isInteger(e.pull)&&e.pull>=0}var kg=e=>Dg(e)&&typeof e.passage==`string`&&Dg(e.variables)&&typeof e.timestamp==`number`&&Og(e.prng),Ag=e=>e===void 0||Array.isArray(e)&&Array.from(e).every(e=>Dg(e)&&typeof e.condition==`string`&&Dg(e.options)),jg=e=>e===void 0||e instanceof Map&&[...e.keys()].every(e=>typeof e==`string`);function Mg(e){if(!Dg(e)||typeof e.passage!=`string`||!Dg(e.variables))return!1;let{history:t,historyIndex:n}=e;return!Array.isArray(t)||t.length===0||!Array.from(t).every(kg)||typeof n!=`number`||!Number.isInteger(n)||n<0||n>=t.length||t[n].passage!==e.passage?!1:jg(e.visitCounts)&&jg(e.renderCounts)&&Og(e.prng)&&Ag(e.watchers)}var Ng=e=>e instanceof Map?hs(Object.fromEntries(e)):void 0;function Pg(e){if(typeof e!=`object`||!e)throw Eg();let{formatVersion:t,data:n}=e;if(xg(t),typeof n!=`string`)throw Eg();let r=vg(Sg(t,n));if(!Mg(r))throw Eg();let i={...r,visitCounts:Ng(r.visitCounts),renderCounts:Ng(r.renderCounts)};return i.visitCounts===void 0&&delete i.visitCounts,i.renderCounts===void 0&&delete i.renderCounts,i}var Fg=`Invalid save file format`;function Ig(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Lg=[`id`,`passage`,`ifid`,`playthroughId`,`createdAt`,`updatedAt`,`title`];function Rg(e){let t=console.warn;console.warn=()=>{};try{Pg(e)}finally{console.warn=t}}function zg(e){if(!Ig(e))throw Error(Fg);if(!K(e,`formatVersion`))throw e.version===1?new yg:Error(Fg);if(xg(e.formatVersion),typeof e.ifid!=`string`)throw Error(Fg);let t=e.save;if(!Ig(t)||!Ig(t.meta))throw Error(Fg);let n=t.meta;if(Lg.some(e=>typeof n[e]!=`string`))throw Error(Fg);try{Rg(t.payload)}catch(e){throw e instanceof yg?e:Error(Fg)}}function Bg(e){try{return zg(e),!0}catch{return!1}}function Vg(e){return JSON.stringify(e).length}function Hg(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 Ug={autosave:`autosave.`,slot:`slot.`,slotIndex:`slotIndex.`,playthroughCount:`playthroughCount.`,currentPlaythrough:`currentPlaythroughId.`};function Wg(e,t){let{slot:n,...r}=Ug;return Object.values(r).some(n=>e===n+t)||e.startsWith(n)&&e.endsWith(`.${t}`)}function Gg(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=>Wg(t,e)),getAllMetaKeys:()=>r.keys(),destroy:i}}function Kg(){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 Gg(`memory`,Hg(n),async()=>{for(let e of t)e.clear()})}var qg={saves:`spindle.save.`,playthroughs:`spindle.pt.`,meta:`spindle.meta.`},Jg={\"saves.ifid\":`spindle.idx.saves.`,\"saves.playthroughId\":`spindle.idx.saves-pt.`,\"playthroughs.ifid\":`spindle.idx.pt.`};function Yg(e){let t=localStorage.getItem(e);if(t!==null)try{return JSON.parse(t)}catch{return}}function Xg(e,t){localStorage.setItem(e,JSON.stringify(t))}function Zg(e){localStorage.removeItem(e)}function Qg(e){return Yg(e)??[]}function $g(e,t){let n=Qg(e);n.includes(t)||(n.push(t),Xg(e,n))}function e_(e,t){let n=Qg(e).filter(e=>e!==t);n.length>0?Xg(e,n):Zg(e)}var t_=e=>Object.keys(localStorage).filter(t=>t.startsWith(e));function n_(){function e(e,t){let n=qg[e],r=Object.entries(t).map(([t,n])=>({field:t,read:n,prefix:Jg[`${e}.${t}`]})),i=e=>r.map(t=>`${t.prefix}${t.read(e)}`);return{get:async e=>Yg(`${n}${e}`),async put(e,t){let r=Yg(`${n}${e}`),a=i(t);if(r!==void 0)for(let t of i(r))a.includes(t)||e_(t,e);Xg(`${n}${e}`,t);for(let t of a)$g(t,e)},async delete(e){let t=Yg(`${n}${e}`);if(t!==void 0)for(let n of i(t))e_(n,e);Zg(`${n}${e}`)},async find(e,t){let i=r.find(t=>t.field===e),a=[];for(let e of Qg(`${i.prefix}${t}`)){let t=Yg(`${n}${e}`);t!==void 0&&a.push(t)}return a},keys:async()=>t_(n).map(e=>e.slice(n.length))}}return Gg(`localstorage`,Hg(e),async()=>{for(let e of t_(`spindle.`))Zg(e)})}var r_=`spindle`,i_=1,a_={saves:{keyPath:`meta.id`,indexes:{ifid:`meta.ifid`,playthroughId:`meta.playthroughId`}},playthroughs:{keyPath:`id`,indexes:{ifid:`ifid`}},meta:{keyPath:`key`,indexes:{}}};function o_(){let e=null;function t(){return e||(e=new Promise((t,n)=>{let r=indexedDB.open(r_,i_);r.onupgradeneeded=()=>{let e=r.result;for(let[t,{keyPath:n,indexes:r}]of Object.entries(a_)){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 Gg(`indexeddb`,Hg(r),async()=>{(await t()).close(),e=null,await new Promise((e,t)=>{let n=indexedDB.deleteDatabase(r_);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 s_=null;async function c_(){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)}),o_()}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 n_()}}catch{}return Kg()}var l_=null;function u_(){if(s_)return Promise.resolve(s_);if(!l_){let e=c_().then(t=>(l_===e&&(s_=t),t));l_=e}return l_}function d_(){s_=null,l_=null}function f_(){return s_?.type??`memory`}function p_(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 m_=e=>e===`length`||/^(0|[1-9]\\d*)$/.test(e),h_=Eh;function g_(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 __(e,t,n,r={}){let i=x_(e,t,r.createMissing??!1);i[t[t.length-1]]=n}function v_(e,t){let n=t[t.length-1];y_(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=x_(e,t,!1);if(Array.isArray(i)&&jt(i)&&t.length>1){let r=Rn(i).slice();delete r[Number(n)];let a=x_(e,t.slice(0,-1),!1);a[t[t.length-2]]=r;return}delete i[n]}function y_(e){if(e.includes(`__proto__`))throw TypeError(`spindle: Cannot use \"__proto__\" in a variable path (\"${e.join(`.`)}\")`)}function b_(e,t,n,r,i){if(i&&Rh(e)!==void 0)return;let a=h_(e)??(Array.isArray(e)&&!m_(t)?`an array`:``);if(a)throw TypeError(`spindle: Cannot set property \"${t}\" on ${a} (at \"${n.slice(0,r).join(`.`)}\")`)}function x_(e,t,n){y_(t);let r=jt(e),i=e;for(let e=0;e<t.length-1;e++){let a=t[e];b_(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)&&!h_(o)&&(o=g_(o),i[a]=o);i=o}return b_(i,t[t.length-1],t,t.length-1,!r),i}function S_(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function C_(e,t,n,r){if(n(t),Rh(e)===void 0)return t;Object.setPrototypeOf(t,Object.getPrototypeOf(e));for(let n of Oh(e))os(t,n,r(n));return t}var w_=[`message`,`cause`,`errors`];function T_(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))os(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(wh(e))return r(e,Object(e.valueOf()));if(Ch(e))return e;if(e instanceof Error){let t=r(e,Object.create(Object.getPrototypeOf(e)));for(let n of[...w_,`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&&j_(e)&&j_(n)?r(e,n):e}let s=(e,t)=>C_(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 kh(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 Ah(e))Set.prototype.add.call(t,o(c(n),n));return t}let u=a(l);if(u!==void 0)return u;let d=Rh(l)!==void 0||S_(e);return!d&&t.keepUnregistered?e:i(l,r(l,d?Object.create(Object.getPrototypeOf(l)):{}))}return c(e)}function E_(e,t){return L_(e,t,D_())}function D_(){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 O_(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 k_(e,t){return L_(e,t,O_())}function A_(e,t){if(!j_(e)||!j_(t))return t;let n=new Map,r=new Map,i=e=>j_(e)?T_(e,{keepUnregistered:!0,seen:n}):e;function a(e,t){let i=O_(r,n);if(L_(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(!j_(t))return t;let r=n.get(t);if(r!==void 0)return r;if(!j_(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=>C_(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 kh(t))Map.prototype.set.call(n,i(r),o(Mh(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(z_(e,t,!1)){let e=Object.create(Object.getPrototypeOf(t));n.set(t,e);for(let t of Object.keys(c))os(e,t,l(t));return e}return i(t)}return o(e,t)}var j_=e=>typeof e==`object`&&!!e;function M_(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 N_(e,t,n){if(e instanceof Date){let r=Date.prototype.getTime;return Object.is(r.call(e),r.call(t))&&I_(e,t,n)}if(e instanceof RegExp){let r=RegExp.prototype.toString;return r.call(e)===r.call(t)&&e.lastIndex===t.lastIndex&&I_(e,t,n)}if(ArrayBuffer.isView(e)){let r=t;return e.byteOffset===r.byteOffset&&e.byteLength===r.byteLength&&L_(e.buffer,r.buffer,n)}if(e instanceof ArrayBuffer)return M_(e,t);if(e instanceof URL||e instanceof URLSearchParams)return String(e)===String(t);if(wh(e))return Object.is(e.valueOf(),t.valueOf());if(Ch(e))return String(e)===String(t);if(e instanceof Error)return w_.every(r=>K(e,r)===K(t,r)&&L_(e[r],t[r],n))&&P_(e,t,n)}function P_(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)||!L_(i[e],a[e],n))return!1;return!0}var F_=new Set([Array.prototype,Map.prototype,Set.prototype,Date.prototype,RegExp.prototype]);function I_(e,t,n){return F_.has(Object.getPrototypeOf(e))||P_(e,t,n,Oh)}function L_(e,t,n){if(Object.is(e,t)&&!(n.strict&&j_(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(jh(e)!==jh(r))return!1;let i=e instanceof Map?kh(e):Ah(e),a=r instanceof Map?kh(r):Ah(r);for(let e=i.next(),t=a.next();!e.done;e=i.next(),t=a.next())if(!L_(e.value,t.value,n))return!1;return I_(e,t,n)}let i=N_(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||!L_(e[t],r[t],n))return!1;return I_(e,t,n)}return P_(e,t,n)}function R_(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&!Th(e)}function z_(e,t,n){return n&&(Array.isArray(e)||Array.isArray(t))?Array.isArray(e)&&Array.isArray(t)&&Object.getPrototypeOf(e)===Object.getPrototypeOf(t):R_(e)&&R_(t)&&Object.getPrototypeOf(e)===Object.getPrototypeOf(t)}function B_(e,t,n){let r=[],i=(e,t,i)=>{Object.is(t,i)||(z_(t,i,n)?r.push({key:e,kind:`nested`,before:t,after:i}):E_(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 V_(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 B_(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 H_=e=>JSON.stringify(e);function U_(e,t){for(let n=1;n<=e.length;n++)if(t.has(H_(e.slice(0,n))))return!0;return!1}var W_=(e,t)=>`\\0${e}${t}`,G_=e=>e.startsWith(`\\0`);function K_(e){let t=[];if(e instanceof Map){let n=0;for(let[r,i]of kh(e))t.push([W_(`k`,n),r],[W_(`v`,n),i]),n++}else if(e instanceof Set){let n=0;for(let r of Ah(e))t.push([W_(`s`,n++),r])}else if(e instanceof Error)for(let n of[`cause`,`errors`])K(e,n)&&t.push([W_(n===`cause`?`c`:`e`,0),e[n]]);else if(ArrayBuffer.isView(e))t.push([W_(`b`,0),e.buffer]);else return;return t}function q_(e,t){let n=e,r=0;for(let e=0;e<t.length;e++)if(G_(t[e])){if(n=p_(n,t.slice(r,e)),!j_(n))return;n=K_(n)?.find(([n])=>n===t[e])?.[1],r=e+1}return r===t.length?n:p_(n,t.slice(r))}function J_(e,t,n){let r=q_(e,t.slice(0,-1)),i=/^\\0v(\\d+)$/.exec(t[t.length-1]);if(!(r instanceof Map)||!i)return!1;let a=[...kh(r)][Number(i[1])];return a?(Nh(r,a[0],n),!0):!1}function Y_(e){return e instanceof Map||e instanceof Set||e instanceof Date||e instanceof RegExp?Oh(e):[]}function X_(e,t){return Object.getPrototypeOf(e)===Object.getPrototypeOf(t)&&(Y_(e).length>0||Y_(t).length>0)}function Z_(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]),R_(e)||Array.isArray(e)?o(e,t):(o(e,t,Y_(e)),n&&K_(e)&&i.push([e,t]))}function o(e,n,r=Object.keys(e)){for(let i of r){let r=e[i];if(!j_(r))continue;let o=[...n,i];t.has(H_(o))||a(r,o)}}o(e,[]);for(let[e,t]of i)for(let[n,r]of K_(e))j_(r)&&a(r,[...t,n]);return r}function Q_(e,t,n){return new Map([...Z_(e,t,n)].map(([e,t])=>[e,t[0]]))}function $_(e){return[...Z_(e,void 0,!0).values()].filter(e=>e.length>1)}function ev(e,t,n,r,i){let a=[],o=K_(e),s=K_(t);if(o&&s){if(Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;if(e instanceof Map||e instanceof Set){let n=jh(t);if(jh(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=z_(e,t,!0)?Object.keys(t):X_(e,t)?Y_(t):[];for(let n of c)K(e,n)&&a.push([n,e[n],t[n]]);return a.some(([e,t,a])=>{if(!j_(t)||!j_(a))return!1;let o=[...n,e],s=i.get(a);return H_(r.get(t))!==H_(s)||H_(s)===H_(o)&&ev(t,a,o,r,i)})}function tv(e,t){let n=Q_(e,void 0,!0),r=Q_(t,void 0,!0),i=[];return(function e(t,a,o){for(let s of Array.isArray(a)||R_(a)?Object.keys(a):Y_(a)){if(!K(t,s))continue;let c=t[s],l=a[s];if(!j_(c)||!j_(l))continue;let u=[...o,s],d=n.get(c),f=r.get(l),p=H_(u);H_(d)===H_(f)?H_(f)===p&&K_(c)&&ev(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}),((R_(c)||Array.isArray(c))&&z_(c,l,!0)||X_(c,l))&&H_(f)===p&&H_(d)===p&&e(c,l,u)}})(e,t,[]),i}function nv(e,t,n=!1){let r=V_(e,t,n),i=new Set(r.map(e=>H_(e.path))),a=[];for(let n of tv(e,t))U_(n.path,i)||(i.add(H_(n.path)),a.push(n));return[...a,...r]}function rv(e,t){return Q_(e,new Set(t.map(e=>H_(e.path))),!0)}function iv(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=q_(t,r);return j_(i)&&(Array.isArray(i)?Array.isArray(n):Object.getPrototypeOf(i)===Object.getPrototypeOf(n))?(super.set(n,i),!0):!1}}}function av(e,t){let n=p_(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&&E_(n[r],t.value):t.deleted}function ov(e,t,n){t.some(G_)?J_(e,t,n):__(e,t,n)}function sv(e,t){let n=e;t.deleted?v_(n,t.path):__(n,t.path,t.value)}var cv=new Set([`storyinit`,`beforerestart`,`actionsChanged`,`variableChanged`,`beforesave`,`aftersave`,`beforeload`,`afterload`,`beforenavigate`,`afternavigate`,`passagerender`,`dialogrender`]),lv=new Map;function uv(e,t){if(!cv.has(e))throw Error(`spindle: Unknown event \"${e}\".`);let n=lv.get(e);return n||(n=new Set,lv.set(e,n)),n.add(t),()=>{n.delete(t)}}function dv(e,t){let n=lv.get(e);if(n)for(let e of[...n])t(e)}function fv(e,...t){dv(e,e=>e(...t))}function pv(e,...t){dv(e,n=>{try{n(...t)}catch(t){console.error(`spindle: Error in ${e} handler:`,t)}})}var mv=null,hv=null;function gv(e){mv=e}function _v(e){hv=e}function vv(e){return Hc(()=>yv(e))}function yv(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(mv)try{let t=mv(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 bv=Promise.resolve();function xv(e){let t=bv.then(e);return bv=t.catch(()=>{}),t}function Sv(e){return(...t)=>xv(()=>e(...t))}var Cv=e=>Sv(async t=>e(await(await u_()).getSave(t))),wv=e=>Sv(async(t,n)=>e(await ny(t,n))),Tv=Sv(Ev);async function Ev(e,t=yt()){let n=await u_();return await Qv(`spindle-playthrough-count:${e}`,async()=>{let r=await kv(e),i={id:t,ifid:e,createdAt:new Date().toISOString(),label:`Playthrough ${r}`};await n.putPlaythrough(i),await n.setMeta(Ov(e),r)}),await n.setMeta(Av(e),t),Oy(e,t),t}var Dv=/^Playthrough (\\d+)$/;function Ov(e){return`${Ug.playthroughCount}${e}`}async function kv(e){let t=await u_(),n=await t.getMeta(Ov(e))??0;for(let r of await t.getPlaythroughsByIfid(e)){let e=Dv.exec(r.label);e&&(n=Math.max(n,Number(e[1])))}return n+1}function Av(e){return`${Ug.currentPlaythrough}${e}`}var jv=Sv(Mv);async function Mv(e,t){let n=await u_();await Nv(e,t,new Date().toISOString());let r=Av(e);await n.getMeta(r)!==t&&await n.setMeta(r,t),Oy(e,t)}async function Nv(e,t,n){let r=await u_();(await r.getPlaythroughsByIfid(e)).some(e=>e.id===t)||await r.putPlaythrough({id:t,ifid:e,createdAt:n,label:`Imported`})}function Pv(e){return xv(async()=>{let t=await u_(),n=ky(e),r=n!==void 0&&(await t.getPlaythroughsByIfid(e)).some(e=>e.id===n)?n:await t.getMeta(Av(e))??await Ev(e);return Oy(e,r),{id:r,knownSaves:await vy(e)}})}function Fv(e,t,n,r){try{let i=n();return Hc(()=>fv(`beforesave`,e,t)),r(i()).then(t=>(Hc(()=>fv(`aftersave`,e)),t))}catch(e){return Promise.reject(e)}}function Iv(e,t){let n=Tg(t);return{meta:{...e,estimatedBytes:Vg(n)},payload:n}}var Lv=Sv(Rv);async function Rv(e,t,n,r={}){let i=await t;if(!i)throw Error(`No playthrough`);let a=new Date().toISOString(),o=Iv({id:yt(),ifid:e,playthroughId:i,createdAt:a,updatedAt:a,title:vv(n),passage:n.passage,custom:r},n);return await(await u_()).putSave(o),o}var zv=Sv(Bv);async function Bv(e,t,n,r){let i=await r,a=await u_(),o=await a.getSave(e);if(!o)return;let s=Iv({...o.meta,...i?{playthroughId:i}:{},updatedAt:new Date().toISOString(),title:o.meta.userTitle===!0?o.meta.title:vv(t),passage:t.passage,...n==null?{}:{custom:{...o.meta.custom,...n}}},t);return await a.putSave(s),s}var Vv=e=>e&&Pg(e.payload),Hv=e=>Pg(e);Cv(Vv);function Uv(e){return xv(async()=>{let t=await u_(),n=await t.getSave(e);await t.deleteSave(e),n&&await ay(n.meta.ifid,t=>t===e)})}function Wv(e,t){return xv(async()=>{let n=await u_(),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 Gv=Sv(async function(e){let t=await u_(),[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}),Kv=Ug.autosave,qv=Ug.slot,Jv=Ug.slotIndex;function Yv(e){return e!=null&&e!==``}function Xv(e,t){return Yv(t)?`${qv}${t}.${e}`:`${Kv}${e}`}var Zv=e=>`${Jv}${e}`;async function Qv(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 $v(e,t){let n=await u_();await Qv(`spindle-slot-index:${e}`,async()=>{let r=await n.getMeta(Zv(e))??[],i=t(r);i!==r&&await n.setMeta(Zv(e),i)})}async function ey(e){return[void 0,...(await(await u_()).getMeta(Zv(e))??[]).filter(Yv)]}async function ty(e,t){return(await u_()).getMeta(Xv(e,t))}async function ny(e,t){let n=await ty(e,t);return n?(await u_()).getSave(n):void 0}async function ry(e,t,n){await(await u_()).setMeta(Xv(e,t),n),Yv(t)&&await $v(e,e=>e.includes(t)?e:[...e,t]),uy(e)}async function iy(e,t){await(await u_()).deleteMeta(Xv(e,t)),Yv(t)&&await $v(e,e=>e.filter(e=>e!==t)),uy(e)}async function ay(e,t){for(let n of await ey(e)){let r=await ty(e,n);r&&t(r)&&await iy(e,n)}}var oy=`spindle.slots`,sy=`*`,cy;function ly(){if(cy===void 0)try{cy=new BroadcastChannel(oy),cy.unref?.()}catch{cy=null}return cy}function uy(e){try{ly()?.postMessage(e)}catch{}}function dy(e,t){let n=ly(),r=n=>{(n.data===e||n.data===sy)&&t()},i=()=>{document.visibilityState===`visible`&&t()},a=typeof document>`u`?void 0:document;return n?.addEventListener(`message`,r),a?.addEventListener(`visibilitychange`,i),()=>{n?.removeEventListener(`message`,r),a?.removeEventListener(`visibilitychange`,i)}}var fy=e=>({isAutosave:!Yv(e),...Yv(e)?{slot:e}:{}});function py(e,t){return{slot:Yv(t)?t:``,title:e.meta.title,passage:e.meta.passage,createdAt:e.meta.createdAt,updatedAt:e.meta.updatedAt,custom:e.meta.custom??{}}}function my(e,t,n,r,i){return xv(async()=>{let a=await t,o=await ty(e,r);if(o){let e=await Bv(o,n,i,a);if(e)return e}let s=await Rv(e,a,n,{...fy(r),...i});return await ry(e,r,s.meta.id),s})}async function hy(e,t){return await ny(e,t)!==void 0}wv(Vv);function gy(e,t,n){return xv(async()=>{let r=await ny(e,t);if(!r)return;let i=Pg(r.payload);n?.(i);let{playthroughId:a}=r.meta;return a&&await Mv(e,a),{payload:i,playthroughId:a}})}var _y=Sv(vy);async function vy(e){let t=Object.create(null);for(let n of await ey(e))await hy(e,n)&&(t[n??``]=!0);return t}var yy=Sv(by);async function by(e,t){let n=await ny(e,t);return n?py(n,t):null}var xy=Sv(async e=>{let t=[];for(let n of await ey(e)){let r=await by(e,n);r&&t.push(r)}return t}),Sy=Sv(async(e,t)=>{let n=await ty(e,t);n&&(await(await u_()).deleteSave(n),await iy(e,t))}),Cy=`spindle.session.`;function wy(e,t){let n=JSON.stringify(Tg(t));try{sessionStorage.setItem(`${Cy}${e}`,n)}catch(e){return{error:e}}}function Ty(e){try{let t=sessionStorage.getItem(`${Cy}${e}`);return t?Pg(JSON.parse(t)):void 0}catch(t){t instanceof yg&&(console.warn(`spindle: ${t.message}; the session was not restored.`),Ey(e));return}}function Ey(e){try{sessionStorage.removeItem(`${Cy}${e}`)}catch{}}var Dy=`${Cy}playthrough.`;function Oy(e,t){try{sessionStorage.setItem(`${Dy}${e}`,t)}catch{}}function ky(e){try{return sessionStorage.getItem(`${Dy}${e}`)||void 0}catch{return}}function Ay(e){if(e)return{formatVersion:1,ifid:e.meta.ifid,exportedAt:new Date().toISOString(),save:e}}var jy=Cv(Ay);async function My(e,t){if(zg(e),e.ifid!==t)throw Error(`Save is from a different story (expected IFID ${t}, got ${e.ifid})`);let n=T_(e.save);return n.meta.id=yt(),n.meta.updatedAt=new Date().toISOString(),n.meta.ifid=t,await Nv(t,n.meta.playthroughId,n.meta.createdAt),n}function Ny(e,t){return xv(async()=>{let n=await My(e,t);return await(await u_()).putSave(n),n})}var Py=wv(Ay);function Fy(e,t,n){return xv(async()=>{let r=await My(e,t),{slot:i,...a}=r.meta.custom??{};r.meta.custom={...a,...fy(n)};let o=await u_(),s=await ty(t,n);return await o.putSave(r),await ry(t,n,r.meta.id),s&&await o.deleteSave(s),py(r,n)})}var Iy=Sv(async function(e){let t=await u_(),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=Vg(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 Ly(e){return xv(async()=>{let t=await u_();await t.deleteSavesByIfid(e),await t.deletePlaythroughsByIfid(e),await t.deleteMetaByIfid(e),Ey(e),uy(e)})}var Ry=Sv(zy);async function zy(){await(await u_()).destroy(),d_();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{}uy(sy)}function By(e,t,n){return xv(async()=>{let r=await u_(),i=await r.deleteSavesByPlaythrough(t);await r.deletePlaythroughById(t);let a=new Set(i);if(await ay(e,e=>a.has(e)),n&&await n.current===t)return await Ev(e,n.id),!0;let o=Av(e);return await r.getMeta(o)===t&&await r.deleteMeta(o),!1})}var Vy=null;function Hy(){Vy&&(he(null,Vy),Vy.remove(),Vy=null)}function Uy(){Hy();let e=Q.getState();if(!e.storyData)return;let t=e.storyData.passages.get(`StoryInit`);if(t){let e=Qo(t.content);bc(e,`StoryInit`);let n=document.createElement(`div`);n.style.display=`none`,document.body.appendChild(n),Vy=n,he(b(()=>km(e),null),n),kx()}let n=e.storyData.passages.get(`SaveTitle`);n&&_v(n.content)}function Wy(e){Uy();let t=e?aS(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),fv(`storyinit`),e||kx()}var Gy=[`variables`,`temporary`,`transient`],Ky=[];function qy(){return Ky[Ky.length-1]?.work}function Jy(){let e=Q.getState(),t=qy();return t?{...e,...t}:e}var Yy=e=>T_(e,{keepUnregistered:!0});function Xy(e,t){let n=t?iv(t,e):new Map,r=(r,i)=>{let a=t?.get(i);if(!a||!jt(r))return r;let o=Rn(r);return a.some(G_)||__(e,a,o),n.set(i,o),o};return e=>T_(e,{keepUnregistered:!0,seen:n,settle:r})}var Zy=e=>{let t=new Map;return n=>{let r=t.get(n);return r||(r=Xy(n,e?.(n)),t.set(n,r)),r}};function Qy(e){return tn(Yy(e),!0)}function $y(e,t=new Set){if(typeof e!=`object`||!e||t.has(e)||ArrayBuffer.isView(e)||e instanceof ArrayBuffer)return!0;if(!Object.isFrozen(e))return!1;if(t.add(e),e instanceof Map){for(let[n,r]of kh(e))if(!$y(n,t)||!$y(r,t))return!1}else if(e instanceof Set){for(let n of Ah(e))if(!$y(n,t))return!1}return Reflect.ownKeys(e).every(n=>{let r=Object.getOwnPropertyDescriptor(e,n);return!r||!(`value`in r)||$y(r.value,t)})}function eb(e){return $y(e)?e:Qy(e)}function tb(e,t,n=Ky,r=nb){let[i,a]=t.path;for(let o of n)for(let n of[o.work,o.base])try{sv(n,t.deleted?t:{...t,value:r(n)(t.value)})}catch{let t=e[i][a];K(e[i],a)?n[i][a]=Yy(jt(t)?Rn(t):t):delete n[i][a]}}var nb=e=>Xy(e),rb=new Set(Gy),ib=new In({autoFreeze:!1}),ab=!1;function ob(e,t){let n=[],r=e;for(let e of t){if(!R_(r))break;let t=String(e);n.push(t),r=K(r,t)?r[t]:void 0}return n}function sb(e,t){let n=p_(e,t.slice(0,-1)),r=t[t.length-1];return R_(n)&&K(n,r)?{path:t,deleted:!1,value:n[r]}:{path:t,deleted:!0}}function cb(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=>sb(t,[e]));let r=new Set,i=[];for(let e of n){let n=ob(t,e.path.slice(1)),a=JSON.stringify(n);r.has(a)||(r.add(a),i.push(sb(t,n)))}return i}function lb(e){if(ab){ab=!1;return}if(Ky.length===0)return;pb(hb());let t=Ky[Ky.length-1],n={...Q.getState(),variables:t.work.variables,temporary:t.work.temporary,transient:t.work.transient},[r,i]=ib.produceWithPatches(n,e),a=Gy.flatMap(e=>{let t=i.filter(t=>t.path[0]===e);return t.length?cb(n[e],r[e],t).map(t=>({...t,path:[e,...t.path]})):[]}),o=rv(fb(t.work),a),s=Zy(()=>o),c=(e,t)=>e.deleted?e:{...e,value:s(t)(e.value)};for(let e of a)sv(t.work,c(e,t.work));return e=>{let i=e;for(let e of Object.keys(r)){let t=r[e];!rb.has(e)&&t!==n[e]&&(i[e]=t)}let o=e;for(let e of a){let[n,r]=e.path;try{sv(o,c(e,o))}catch{K(t.work[n],r)?o[n][r]=Yy(t.work[n][r]):delete o[n][r]}tb(o,e,Ky,s)}}}function ub(e,t,n){let r=n.map(e=>H_(e.path).slice(0,-1));for(let[n,...i]of $_(t)){let t=[n,...i].map(e=>H_(e).slice(0,-1));if(r.some(e=>t.some(t=>e.startsWith(t))))try{let t=q_(e,n);if(typeof t!=`object`||!t)continue;for(let n of i)ov(e,n,t)}catch{}}}function db(e){let t=new Map;return{variables:T_(e.variables,{keepUnregistered:!0,seen:t}),temporary:T_(e.temporary,{keepUnregistered:!0,seen:t}),transient:T_(e.transient,{keepUnregistered:!0,seen:t})}}var fb=e=>({variables:e.variables,temporary:e.temporary,transient:e.transient});function pb(e){let t=e.map(({scope:e,keepRunning:t})=>({scope:e,keepRunning:t,changes:mb(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=db(e.work));ab=!0;try{Q.getState().updateVariables(r)}finally{ab=!1}function r(e){t.forEach(({scope:n,changes:r},i)=>{let a=rv(n.work,r),o=Xy(e,a),s=t.slice(0,i).map(e=>e.scope),c=Zy(()=>a),l=new Set;for(let t of r){let[r,i]=t.path,a=H_([r,i]);if(!l.has(a))try{if(t.deleted){av(e,t)||sv(e,t);continue}let n=t.alias?o(t.value):void 0;if(t.alias?Object.is(p_(e,t.path),n):av(e,t))continue;sv(e,{...t,value:t.alias?n:o(t.value)})}catch{e[r][i]=o(n.work[r][i]),l.add(a)}}ub(e,n.work,r);for(let t of r)tb(e,t,s,c)})}}var mb=(e,t)=>nv(e,t),hb=()=>Ky.map(e=>({scope:e,keepRunning:!0}));function gb(e){let t=Q.getState(),n=fb(t),r=nv(e.base,n),i=Xy(e.work,rv(n,r));for(let t of r)try{sv(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=db(t)}function _b(e){if(Ky.length===0)return e();pb(hb());let t=Ky.splice(0);try{return e()}finally{Ky.push(...t);for(let e of t)gb(e)}}function vb(e){pb(hb());let t=rv(fb(qy()??Q.getState()),[]),n=yb(),r=Xy(n.work,t);try{e(n.work,r)}finally{Ky.pop()}pb([...hb(),{scope:n,keepRunning:!1}])}function yb(){let e=qy()??Q.getState(),t={work:db(e),base:db(e)};return Ky.push(t),t}function bb(e,t,n){let r=ls(T_(t,{keepUnregistered:!0})),i=yb();try{pl(e,i.work.variables,i.work.temporary,r,i.work.transient)}finally{Ky.pop()}pb([...hb(),{scope:i,keepRunning:!1}]);let a=new Set(nv(t,r,!0).map(e=>e.path[0]));for(let e of $_(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 xb=[],Sb=!1,Cb=[],wb=null,Tb=null;function Eb(e){let t=Jy();try{return!!fl(e,t.variables,t.temporary,{},t.transient)}catch{return!1}}function Db(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:Eb(e),priority:i?.priority??0,macroKey:n};return xb.push(o),xb.sort((e,t)=>t.priority-e.priority),()=>{xb=xb.filter(e=>e!==o)}}function Ob(e,t){return Db(e,t)}function kb(e,t){let n=Object.fromEntries(Object.entries(t).sort(([e],[t])=>e<t?-1:1)),r=JSON.stringify([e,n]);xb.some(e=>e.macroKey===r)||Db(e,t,r)}function Ab(){return xb.filter(e=>e.macroKey!==void 0&&e.options).map(e=>({condition:e.condition,options:{...e.options}}))}function jb(e){xb=xb.filter(e=>e.macroKey===void 0);for(let{condition:t,options:n}of e)kb(t,n)}function Mb(e){xb=xb.filter(t=>t.name!==e)}function Nb(e){let{callback:t,options:n}=e;if(t){t();return}if(n){if(n.run)try{bb(n.run,{},()=>{})}catch(t){console.error(`spindle: Error in watch run action for \"${e.condition}\":`,t)}n.dialog&&(Cb.push({passageName:n.dialog}),wb?.()),n.goto&&Q.getState().navigate(n.goto)}}var Pb=10;function Fb(){for(let e=0;e<Pb;e++){let e=!1,t=[...xb];for(let n of t){if(!xb.includes(n))continue;let t=Eb(n.condition),r=!n.lastResult;n.lastResult=t,t&&r&&(e=!0,n.options?.once&&(xb=xb.filter(e=>e!==n)),Nb(n))}if(!e)break}}function Ib(){if(!Sb){Sb=!0;try{Fb()}finally{Sb=!1}}}var Lb=0;function Rb(){if(Lb===0)return;let e=Sb;Sb=!0;try{Fb()}finally{Sb=e}}function zb(){let e=Q.getState();Lb++;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||Ib())}),n=!0;return()=>{n&&(n=!1,Lb--,t())}}function Bb(){for(let e of xb)e.lastResult=Eb(e.condition)}function Vb(){xb=[],Hb++,tx(),Ub.notify()}var Hb=0,Ub=Ss();function Wb(){return Hb}var Gb=Ub.subscribe;function Kb(e){return wb=e,Cb.length>0&&e(),()=>{wb===e&&(wb=null)}}function qb(){return Cb.shift()}function Jb(){return Cb.length}function Yb(e){Tb?Tb.push(e):(Cb.push(e),wb?.())}function Xb(){Cb=[]}function Zb(e){return Tb=e,()=>{Tb===e&&(Tb=null)}}var Qb=[];function $b(e){return Qb.push(e),()=>{let t=Qb.lastIndexOf(e);t>=0&&Qb.splice(t,1)}}function ex(){let e=Qb[Qb.length-1];e?e():Tb?.close()}function tx(){Xb();for(let e of[...Qb].reverse())e();Tb?.closeAll()}function nx(){return Qb.length>0||(Tb?.isOpen()??!1)}Bn(),Vn();var rx=new Set([`StoryInit`,`StoryInterface`,`StoryVariables`,`StoryTransients`,`StoryLoading`,`SaveTitle`,`PassageReady`,`PassageHeader`,`PassageFooter`,`PassageDone`]),ix=q(),ax=[],ox=q();function sx(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:T_(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(T_(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 cx(e,t){let n=Object.create(Object.getPrototypeOf(e));for(let t of Object.keys(e))os(n,t,e[t]);for(let e of t)e.deleted?delete n[e.key]:os(n,e.key,e.value);return n}function lx(e){let t=ax.length-1;t<0?ix=e:ax[t]=sx(fx(t),e)}function ux(e,t){let n=ix;for(let r=0;r<e;r++)r>0&&(n=cx(n,ax[r-1].forward)),t(n,r)}function dx(e,t){return{passage:e.passage,variables:t,timestamp:e.timestamp,prng:e.prng}}function fx(e){let t=ix;for(let n=0;n<e;n++)t=cx(t,ax[n].forward);return t}var px=[];function mx(e){let{storyData:t,currentPassage:n,variables:r,history:i,historyIndex:a,visitCounts:o,renderCounts:s}=e();if(t){if(px.length>i.length&&(px.length=i.length),px.length<i.length)if(i.length-px.length===1){let e=i.length-1;px[e]=dx(i[e],r)}else ux(i.length,(e,t)=>{t>=px.length&&(px[t]=dx(i[t],e))});return wy(t.ifid,{passage:n,variables:r,history:px,historyIndex:a,visitCounts:o,renderCounts:s,prng:Uc(),watchers:Ab()})}}var hx=`The game could not be saved for a page reload; a reload goes back to the last passage it could save:`,gx=`The story could not go to another passage:`;function _x(e,t){let n;try{let t=mx(e);t&&Ds(hx,t.error)}catch(e){n={error:e},Ds(hx,e)}try{t?.()}finally{if(n)throw n.error}}function vx(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++)ix=cx(ix,ax[e].forward);return e.history=e.history.slice(n,r),ax=ax.slice(n,r-1),px=px.slice(n,r),e.historyIndex-=n,!0}var yx=!1,bx=[],xx=null;function Sx(e,t){let n=xx;if(xx=null,!n||e().navigationId!==n.navigationId)return;e().variables!==n.variables&&lx(e().variables),ox=e().variables;let r=Uc(),i=e().history[e().historyIndex].prng;(r?.seed!==i?.seed||r?.pull!==i?.pull)&&t(e=>{e.history[e.historyIndex].prng=r})}var Cx=e=>({...e});function wx(e){ix=e,ax=[],ox=e,px=[]}function Tx(e){let t=q(T_(e));return wx(T_(t)),t}function Ex(e){return q(T_(e,{keepUnregistered:!0}))}function Dx(e,t,n,r){e.currentPassage=t,e.navigationId++,e.variables=n,e.transient=Ex(r),e.temporary=q(),e.history=[{passage:t,timestamp:Date.now()}],e.historyIndex=0}function Ox(e,t,n){let{historyIndex:r,history:i}=e(),a=r+n;if(a<0||a>=i.length)return;Sx(e,t);let o=e().currentPassage,s=i[a].passage;fv(`beforenavigate`,s);let c=T_(fx(a));t(e=>{e.historyIndex+=n,e.currentPassage=e.history[e.historyIndex].passage,e.navigationId++,e.variables=c,e.temporary=q()}),Bb(),ox=e().variables,iS(e().history[e().historyIndex]),_x(e,()=>fv(`afternavigate`,s,o))}function kx(){let{history:e,historyIndex:t,variables:n}=Q.getState();if(e.length!==1||t!==0)return;wx(n);let r=Uc();Q.setState(e=>{e.history[0].prng=r})}var Ax=Promise.resolve(``),jx=0,Mx=!1;function Nx(){return Mx?``:Q.getState().playthroughId}function Px(){let e=Nx();return Ax.then(t=>e||t)}function Fx(e){Q.getState().playthroughId!==e&&Q.setState(t=>{t.playthroughId=e})}function Ix(e){let t=++jx;return Mx=!0,Ax=e.then(e=>(t===jx&&(Mx=!1,Fx(e)),e)),Ax}function Lx(e,t){++jx,Mx=!1,Ax=t.then(()=>e,()=>e),Fx(e)}function Rx(e){let t=yt();Lx(t,Tv(e,t).catch(e=>{console.error(`spindle: failed to start new playthrough`,e)}))}function zx(e,t){Nx()!==t&&Lx(t,jv(e,t).catch(e=>{console.error(`spindle: failed to switch to the loaded playthrough`,e)}))}var Bx=0,Vx=0,Hx=null;function Ux(){Gx(++Bx)}var Wx=Ss();function Gx(e){Vx=e,Wx.notify()}var Kx=Wx.subscribe,qx=[],Jx=!1;function Yx(e){Jx&&qx.push(e)}function Xx(){Jx=!0}function Zx(){for(let e of qx)e();qx=[],Jx=!1}function Qx(e){return typeof e==`string`&&e!==``?e:null}function $x(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 eS(e,t,n){let r=e.history[e.historyIndex];if(!r)return;let i=nv(t,n,!0);if(i.length===0)return;let a=T_(r.variables),o=iv(rv(n,i),a),s=e=>T_(e,{seen:o});for(let e of i)tS(a,n,e,s);r.variables=A_(r.variables,a)}function tS(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=p_(t,i.slice(0,o+1));if(!z_(n,s,!0)){nS(a,e,r(s));return}a=n}let s=i[o];n.deleted?nS(a,s,void 0,n):nS(a,s,r(n.value),n)}function nS(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]:os(e,t,n)}function rS(e){e?zc(e.seed,e.pull):Vc()}function iS(e){e&&rS(e.prng)}function aS(e,t){if(e)return[t.passage,...t.history.map(e=>e.passage)].find(t=>!e.passages.has(t))}function oS(e,t){let n=aS(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 sS=[`variables`,`temporary`,`transient`];function cS(e){for(let t of sS){let n=e[t];cs(n)||(e[t]=q(jt(n)?Rn(n):n))}}var lS=[`navigate`,`goBack`,`goForward`,`restart`,`save`,`load`,`getSavePayload`,`loadFromPayload`];function uS(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=lb(r);t(e=>{(i??r)(e),cS(e)})});r.setState=i;let a=e(i,n,r);for(let e of lS){let t=a[e];a[e]=(...e)=>_b(()=>t(...e))}return a}}var dS=e=>Un(uS(e));function fS(e){return e.catch(()=>{}),e}function pS(e,t,n){return fS(e.catch(e=>{throw console.error(t,e),n?.(e),e}))}function mS(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 hS(e,t){return _y(t).then(t=>{e(e=>{e.knownSaves=t})})}var gS;function _S(e,t,n,r){let i=n.then(()=>{t(e=>{e.knownSaves={}})});return e().restart(),pS(i,r)}var Q=vt()(dS((e,t)=>({storyData:null,currentPassage:``,navigationId:0,variables:q(),variableDefaults:{},transient:q(),transientDefaults:{},temporary:q(),history:[],historyIndex:-1,visitCounts:hs(),renderCounts:hs(),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=vx(e)}),r&&_x(t)},setQuickSaveKey:t=>{e(e=>{e.quickSaveKey=Qx(t)})},setQuickLoadKey:t=>{e(e=>{e.quickLoadKey=Qx(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=Tx(r);e(e=>{e.storyData=n,e.playthroughId=``,e.variableDefaults=r,e.transientDefaults=i,Dx(e,a.name,o,i),e.visitCounts=hs(null,a.name),e.renderCounts=hs(null,a.name)}),ox=t().variables,Ux(),Ix(Pv(n.ifid).then(({id:t,knownSaves:n})=>(e(e=>{e.knownSaves=n}),t)).catch(e=>(console.error(`spindle: failed to init save system`,e),``))),gS?.(),gS=dy(n.ifid,()=>{hS(e,n.ifid).catch(()=>{})})},navigate:n=>{if(yx){bx.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(gx,e);return}let i=t().currentPassage;fv(`beforenavigate`,n);let a=sx(ox,t().variables);e(e=>{e.temporary=q(),e.currentPassage=n,e.navigationId++,e.history=e.history.slice(0,e.historyIndex+1),ax.length=e.historyIndex,px.length>e.historyIndex+1&&(px.length=e.historyIndex+1),ax.push(a),e.history.push({passage:n,timestamp:Date.now(),prng:Uc()}),e.historyIndex=e.history.length-1,vx(e),e.visitCounts=hs(e.visitCounts,n),e.renderCounts=hs(e.renderCounts,n)}),xx={navigationId:t().navigationId,variables:t().variables},yx=!0;try{Rb()}finally{yx=!1}let o=bx;bx=[],Sx(t,e),_x(t,()=>{fv(`afternavigate`,n,i);for(let e of o)t().navigate(e)})},goBack:()=>Ox(t,e,-1),goForward:()=>Ox(t,e,1),setVariable:(t,n)=>{e(e=>{is(t,`$${t}`),e.variables[t]=n})},setTemporary:(t,n)=>{e(e=>{is(t,`_${t}`),e.temporary[t]=n})},deleteVariable:t=>{e(e=>{is(t,`$${t}`),delete e.variables[t]})},deleteTemporary:t=>{e(e=>{is(t,`_${t}`),delete e.temporary[t]})},setTransient:(t,n)=>{e(e=>{is(t,`%${t}`),e.transient[t]=n})},deleteTransient:t=>{e(e=>{is(t,`%${t}`),delete e.transient[t]})},updateVariables:t=>{e(e=>{t(e)})},trackRender:t=>{e(e=>{e.renderCounts=hs(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}),fv(`beforerestart`),Rx(n.ifid),Ux();let o=t().renderDeferred;Zx(),Vc(),Vb();let s=Tx(r);e(e=>{Dx(e,a.name,s,i),e.visitCounts=hs(null,a.name),e.renderCounts=hs(null,a.name),o||(e.renderDeferred=!1)}),ox=t().variables,Xx(),Uy(),Ey(n.ifid),fv(`storyinit`),kx()},save:(n,r)=>{let{storyData:i}=t();if(!i)return Promise.resolve();let a=Px();return pS(Fv(n,r,t().beginSave,async t=>{e(e=>{e.saveError=null}),await my(i.ifid,a,t,n,r),mS(e,n,!0)}),`spindle: failed to save`,t=>e(e=>{e.saveError=bs(t,`Failed to save`)}))},load:n=>{let{storyData:r}=t();if(!r)return Promise.resolve();e(e=>{e.loadError=null});let i=Px(),a=gy(r.ifid,n,e=>oS(r,e)),o=Ix(Promise.all([i,a.catch(()=>void 0)]).then(([e,t])=>t?.playthroughId||e)),s=++Bx;return pS(a.then(async e=>{await o,e&&(Vx>s||(Hx=s,t().loadFromPayload(e.payload,n)))}),`spindle: failed to load save`,t=>e(e=>{e.loadError=bs(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?yy(n.ifid,e):null},listSaves:async()=>{let{storyData:e}=t();return e?xy(e.ifid):[]},deleteSave:n=>{let{storyData:r}=t();return r?pS(Sy(r.ifid,n).then(()=>mS(e,n,!1)),`spindle: failed to delete save`):Promise.resolve()},exportSave:async e=>{let{storyData:n}=t();return n?await Py(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 Fy(n,i.ifid,r);return mS(e,r,!0),a},clearGameData:()=>{let{storyData:n}=t();return n?_S(t,e,Ly(n.ifid),`spindle: failed to clear game data`):Promise.resolve()},clearAllData:()=>_S(t,e,Ry(),`spindle: failed to clear all data`),deletePlaythrough:n=>{let{storyData:r}=t();if(!r)return Promise.resolve();let i=r.ifid,a=Nx(),o=Ax,s=yt(),c=By(i,n,{current:a||o,id:s});return n!==``&&n===a?Lx(s,c):a===``&&Ix(c.then(e=>e?s:o,()=>o)),pS(c.then(()=>hS(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 ux(r.length,(e,t)=>{let n=Cx(e);s.push(dx(r[t],t===0?n:A_(s[t-1].variables,n)))}),{passage:e,variables:A_(s[i]?.variables,Cx(n)),history:s,historyIndex:i,visitCounts:{...a},renderCounts:{...o},prng:Uc(),watchers:Ab()}},beginSave:()=>{let e=t().variables;return()=>{let n=t().getSavePayload();return eS(n,e,t().variables),n}},loadFromPayload:(n,r,i)=>{let a=Hx;Hx=null;let o=a??++Bx;if(n.history.length===0){console.warn(`loadFromPayload: rejecting payload with empty history`);return}oS(t().storyData,n),Gx(o),fv(`beforeload`,r);let s=t().storyData?.ifid;i&&s&&zx(s,i);let c=$x(n),l=T_(n.history.map(e=>e.variables)).map(e=>q(e));ix=T_(l[0]),ax=l.slice(1).map((e,t)=>sx(l[t],e)),px=n.history.map((e,t)=>dx(e,l[t])),e(e=>{e.currentPassage=n.passage,e.navigationId++,e.variables=q(T_(c?.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)),vx(e),e.visitCounts=hs(n.visitCounts),e.renderCounts=hs(n.renderCounts),e.temporary=q(),e.transient=Ex(t().transientDefaults)}),n.watchers&&jb(n.watchers),Bb(),ox=fx(t().historyIndex),rS(c?.prng===void 0?n.prng:c.prng),_x(t,()=>Hc(()=>fv(`afterload`,r)))},getHistoryVariables:e=>T_(fx(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})}}))),vS=`<header class=\"story-menubar\">{story-title}{back}{forward}{restart}{quicksave}{quickload}{saves}{settings}</header>\n{passage}`;function yS(){let{storyData:e}=Oc(`storyData`),t=e?.passages.get(`StoryInterface`),n=t===void 0?vS:t.content,r=t?.tags.includes(`nobr`)??!1,i=Pe(()=>{try{return J(S,{children:xm(Qo(n))})}catch(e){return J(`span`,{class:`error`,children:[`Error in StoryInterface: `,bs(e)]})}},[n]);return r?J(Dp.Provider,{value:!0,children:i}):i}var bS=[`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 xS(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 SS(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!xS(e)}function CS(e){return!e.hidden&&!e.closest(`[hidden], [inert]`)&&!e.matches(`:disabled`)&&SS(e)}function wS(e){let t=e.getAttribute(`tabindex`);return t===null||!/^\\s*[+-]?\\d+\\s*$/.test(t)?null:parseInt(t,10)}function TS(e){let t=wS(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&&(wS(t)??0)>=0&&CS(t));return e===(t.find(e=>e.checked)??t[0])}return!0}function ES(e){let t=Array.from(e.querySelectorAll(bS)).filter(e=>CS(e)&&TS(e)),n=e=>Math.max(wS(e)??0,0);return[...t.filter(e=>n(e)>0).sort((e,t)=>n(e)-n(t)),...t.filter(e=>n(e)===0)]}var DS=[];function OS(e,t,n,r){Ne(()=>{let n=e.current;if(!n)return;let r=document.activeElement instanceof HTMLElement?document.activeElement:null,i={panel:n};DS.push(i);let a=n.querySelector(t)??n;return(n.querySelector(`[autofocus]`)??ES(a)[0]??n).focus(),()=>{let e=DS.indexOf(i);e!==-1&&DS.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=e=>{if(DS[DS.length-1]?.panel!==t)return;if(e.key===`Escape`){if(!n)return;e.preventDefault(),e.stopPropagation(),r();return}if(e.key!==`Tab`)return;let i=ES(t),a=i[0],o=i[i.length-1],s=document.activeElement,c=s!==t&&t.contains(s);!a||!o?(e.preventDefault(),t.focus()):e.shiftKey&&(s===a||!c)?(e.preventDefault(),o.focus()):!e.shiftKey&&(s===o||!c)&&(e.preventDefault(),a.focus())};return document.addEventListener(`keydown`,i),()=>document.removeEventListener(`keydown`,i)},[n,r])}var kS=ge(null);function AS({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}=Oc(`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=km(Qo(u),d?{nobr:!0}:void 0);return d?J(Dp.Provider,{value:!0,children:e}):e}catch(e){return J(`div`,{class:`error`,children:[`Error in dialog: `,bs(e)]})}},[u,d]),p=j(null),m=Mp();OS(p,`.dialog-body`,i,s),Ne(()=>$b(s),[s]),Ne(()=>{p.current&&pv(`dialogrender`,e??``,p.current)},[]);let h=e=>{i&&e.target===e.currentTarget&&s()},g=n?`dialog-panel ${n}`:`dialog-panel`;return J(kS.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(Ap.Provider,{value:m,children:f})})]})})})}function jS(){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(()=>Zb({close:i,closeAll:a,push:r,isOpen:()=>n.current.length>0}),[i,a,r]),Me(()=>Kb(()=>{let e=[];for(;Jb()>0;){let t=qb();t&&e.push(t)}e.length>0&&t(t=>[...t,...e])}),[]),e.length===0?null:J(S,{children:e.map((e,t)=>J(AS,{passageName:e.passageName,panelClass:e.panelClass,onClose:i,showCloseButton:e.showCloseButton,dismissible:e.dismissible},`${e.passageName}-${t}`))})}function MS(){let[e,t]=Ae(As);return Me(()=>(t(As()),js(()=>t(As()))),[]),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:()=>ks(e.id),children:`✕`})]},e.id))})}async function NS(){try{await Q.getState().save()}catch(e){Ds(`The game could not be saved:`,e)}}async function PS(){try{await Q.getState().load()}catch(e){Ds(`The saved game could not be loaded:`,e)}}function FS(){let{storyData:e,currentPassage:t,nobr:n}=Oc(`storyData`,`currentPassage`,`nobr`);if(Me(()=>{let e=e=>{let{quickSaveKey:t,quickLoadKey:n}=Q.getState();t!==null&&e.key===t?(e.preventDefault(),NS()):n!==null&&e.key===n&&(e.preventDefault(),PS())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[]),!e||!t)return J(`div`,{class:`loading`,children:`Loading...`});let r=J(S,{children:[J(yS,{}),J(jS,{}),J(MS,{})]});return J(Dp.Provider,{value:n,children:r})}var IS=`http://www.w3.org/1999/xhtml`,LS=new Set([`area`,`base`,`basefont`,`bgsound`,`br`,`col`,`embed`,`frame`,`hr`,`img`,`input`,`keygen`,`link`,`meta`,`param`,`source`,`track`,`wbr`]);function RS(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+=zS(n));return t}function zS(e){let t=e.localName,n=`<${t}`;for(let t of Array.from(e.attributes))n+=` ${t.name}=${BS(t.name,t.value)}`;if(n+=`>`,e.namespaceURI===IS&&LS.has(t))return n;let r=t===`template`?e.content:e;return`${n}${RS(r)}</${t}>`}function BS(e,t){let n=Go(e),r=n?`on`:`a`;return[`\"${t}\"`,`'${t}'`].find(e=>{let t;try{t=$o(`<i ${r}=${e}>`)}catch(e){if(e instanceof Yo)return!1;throw e}let n=t[0];return t.length===1&&n?.type===`html`&&n.attributes[r]===e.slice(1,-1)})??`\"${VS(t,n)}\"`}function VS(e,t){let n=e=>e.replace(/\"/g,`"`);if(t)return Ko(e).map(e=>`text`in e?n(e.text):`expr`in e?`{${e.expr}}`:e.verbatim).join(``);let r;try{r=$o(e,{text:!0})}catch(t){if(t instanceof Yo)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 HS(){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=RS(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 US=new Map,WS=q(),GS=!1,KS=null;function qS(){return`spindle.${Q.getState().storyData?.ifid||`unknown`}.settings`}function JS(){try{localStorage.setItem(qS(),JSON.stringify(WS))}catch{}}function YS(){if(!GS){if(!Q.getState().storyData?.ifid){KS||(KS=Q.subscribe(e=>{e.storyData?.ifid&&(KS?.(),KS=null,YS())}));return}GS=!0;try{let e=localStorage.getItem(qS());if(e){let t=JSON.parse(e);typeof t==`object`&&t&&!Array.isArray(t)&&(WS=q(WS,t))}}catch{}}}function XS(e,t){US.set(e,t),K(WS,e)||(WS[e]=t.config.default),YS()}function ZS(e,t){let n=as(WS,e);return typeof n==typeof t?n:t}var QS={addToggle(e,t){XS(e,{type:`toggle`,config:t})},addList(e,t){XS(e,{type:`list`,config:t})},addRange(e,t){XS(e,{type:`range`,config:t})},get(e){return as(WS,e)},getToggle(e){return ZS(e,!1)},getList(e){return ZS(e,``)},getRange(e){return ZS(e,0)},set(e,t){WS[e]=t,JS()},getAll(){return{...WS}},getDefinitions(){return US},hasAny(){return US.size>0}},$S=0,eC=4096,tC=[];function nC(e){tC.push({version:++$S,path:e}),tC.length>eC&&tC.shift()}function rC(e){nC([`variables`,...e])}var iC=ge(!1),aC=[`variables`,`temporary`,`transient`];function oC(e){let t=Jy();try{e()}finally{let e=Jy();for(let n of aC)if(t[n]!==e[n])for(let{path:r}of V_(t[n],e[n],!0))nC([n,...r])}}function sC(){return $S}function cC(e,t){let n=new Set,r=new Map;for(let i=tC.length-1;i>=0&&tC[i].version>e;i--){let{path:e}=tC[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?p_(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 lC=[`target`,`variable`,`options`,`value`,`disabled`],uC=new Map,dC=new Map;function fC(e,t,n){if(n)return n;let r=`${e}:${t}`,i=dC.get(r)??0,a;do i++,a=i===1?r:`${r}:${i}`;while(uC.has(a));return dC.set(r,i),a}function pC(e){let t=e.id,n={action:e},r=uC.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)):uC.set(t,[n]),vC(),{update(e){let r=uC.get(t);r?.includes(n)&&(n.action=e,r[r.length-1]===n&&vC())},unregister(){let e=uC.get(t),r=e?e.indexOf(n):-1;!e||r===-1||(e.splice(r,1),e.length===0&&uC.delete(t),r===e.length&&vC())}}}function mC(){return Array.from(uC.values(),gC)}function hC(e){let t=uC.get(e);return t&&gC(t)}function gC(e){return e[e.length-1].action}function _C(){dC.clear()}function vC(){fv(`actionsChanged`)}function yC(e){let t=j(``),n=j(e.perform);n.current=e.perform,t.current||(t.current=fC(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 lC)e[n]!==void 0&&Object.assign(t,{[n]:e[n]});return t},a=j(null);Ne(()=>{let e=pC(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 bC(e){return e.map(e=>e.type===`text`?e.value:``).join(``)}function xC(e){let{variable:t=``,placeholder:n=``}=dc(e,[{name:`variable`,type:`variable`},{name:`placeholder`,type:`string`}]);return{varName:t.replace(/[\"']/g,``),placeholder:n}}var SC=[{name:`value`,type:`string`,holds:`text`,required:!0}],CC=new Map([[`option`,SC]]);function wC(e){return CC.get(e.toLowerCase())}function TC(e){let t=[];for(let n of e)if(n.type===`macro`&&n.name===`option`){let{value:e}=dc(n.rawArgs,SC);t.push(e??``)}return t}function EC(e,t){let n=`macro-${e}`;return t?`${n} ${t}`:n}var DC={useState:Ae,useRef:j,useEffect:Me,useLayoutEffect:Ne,useCallback:Fe,useMemo:Pe,useContext:M};function $(e,t=`builtin`){let n=e.parameters??[];Tl(e.name,n);function r(t){let r=t.className,i=t.id,a;e.interpolate&&(a=Jl(),r=a(r),i=a(i));let{update:o,getValues:s}=M(Ep),c=M(iC),l=$l(),u=(e,t)=>km(e,{...l,...t}),d;try{d=dc(t.rawArgs,n)}catch(t){if(t instanceof Xs)return b(xp,{macro:e.name,error:t});throw t}let f={args:d,collectText:bC,sourceLocation:bp,parseVarArgs:xC,extractOptions:TC,h:b,renderNodes:u,renderInlineNodes:xm,hooks:DC,useAction:yC,className:r,id:i,resolve:a,cls:EC(e.name,r),mutate:c?e=>oC(()=>bb(e,s(),o)):e=>bb(e,s(),o),update:o,getValues:s,wrap:e=>Ml(r,i,e)};if(e.merged){f.merged=kc();let e=f.merged;f.evaluate=t=>fl(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: ${ns} is reserved`);f.varName=i,f.value=Q(e=>p_(e.variables,a)),f.getValue=()=>p_(Jy().variables,a),f.setValue=e=>{rC(a),vb((t,n)=>{__(t.variables,a,n(e),{createMissing:!0})})}}try{return e.render(t,f)}catch(t){if(t instanceof Xs)return b(xp,{macro:e.name,error:t});throw t}}hl(e.name,r);let i=e.text;vl(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(Ol(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)xl(t);a&&Cr(e.name)}var OC=null;function kC(e){OC=e}function AC(){return OC}var jC=null,MC=null;function NC(){return MC}var PC=!1;function FC(){if(PC)return;PC=!0;let e=Q.getState().variables,t=Q.getState().transient;Q.subscribe(n=>{let r={},i=(e,t,n)=>{for(let i of fs(e,t))r[n+i]={from:as(e,i),to:as(t,i)}};i(e,n.variables,``),i(t,n.transient,`%`),e=n.variables,t=n.transient,Object.keys(r).length>0&&fv(`variableChanged`,r)})}var IC=null,LC=null,RC=new Set;function zC(e,t=[]){IC=new Set(e),LC=new Set(t),RC.clear()}function BC(e){let t=e.startsWith(`%`),n=t||e.startsWith(`$`)?e.slice(1):e;return is(n.split(`.`)[0],e),{isTransient:t,key:n}}function VC(e,t){let n=e?LC:IC;if(!n)return;let r=t.split(`.`)[0];if(n.has(r))return;let i=(e?`%`:`$`)+r;RC.has(i)||(RC.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 HC(e,t,n){let{isTransient:r,key:i}=BC(t),a=r?e.transient:e.variables;i.includes(`.`)?__(a,i.split(`.`),n):a[i]=n}function UC(e){return((...t)=>Q.getState()[e](...t))}function WC(){return{get(e){let{isTransient:t,key:n}=BC(e),r=qy(),i=r??Q.getState(),a=t?i.transient:i.variables,o=n.includes(`.`)?p_(a,n.split(`.`)):as(a,n);return r?Qy(o):eb(o)},set(e,t){let n=typeof e==`string`?[[e,t]]:Object.entries(e);for(let[e]of n){let{isTransient:t,key:n}=BC(e);VC(t,n)}if(n.some(([e])=>e.includes(`.`))){vb((e,t)=>{for(let[r,i]of n)HC(e,r,t(i))});return}Q.getState().updateVariables(e=>{for(let[t,r]of n)HC(e,t,r)})},goto:UC(`navigate`),back:UC(`goBack`),forward:UC(`goForward`),restart:UC(`restart`),save:UC(`save`),load:UC(`load`),hasSave:UC(`hasSave`),getSaveInfo:UC(`getSaveInfo`),listSaves:UC(`listSaves`),deleteSave:UC(`deleteSave`),exportSave:UC(`exportSave`),importSave:UC(`importSave`),...sl(()=>Q.getState().visitCounts,()=>Q.getState().renderCounts),get title(){return Q.getState().storyData?.name||``},get passage(){return Q.getState().currentPassage},settings:QS,registerClass(e,t){Lh(e,t)},defineMacro(e){$(e,`user`)},getMacroRegistry(){return Al()},saves:{setTitleGenerator(e){gv(e)}},storage:{async getInfo(){let e=Q.getState().storyData?.ifid;return e?Iy(e):{saveCount:0,playthroughCount:0,totalBytes:0,backend:f_()}},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:UC(`clearGameData`),clearAllData:UC(`clearAllData`),deletePlaythrough:UC(`deletePlaythrough`),get backend(){return f_()}},getActions(){return mC()},performAction(e,t){let n=hC(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`&&FC();let n=uv(e,t);return Yx(n),n},async waitForActions(){await new Promise(e=>{requestAnimationFrame(()=>requestAnimationFrame(()=>e()))});let e=()=>AC()===Q.getState().navigationId;return AC()!==null&&!e()&&!Q.getState().renderDeferred&&await new Promise(t=>{let n=uv(`passagerender`,()=>{e()&&(n(),t())})}),mC()},watch(e,t){return Ob(e,t)},unwatch(e){Mb(e)},openDialog(e,t){Yb({passageName:e,panelClass:t?.panelClass,showCloseButton:t?.showCloseButton,dismissible:t?.dismissible})},closeDialog(){ex()},closeAllDialogs(){tx()},isDialogOpen(){return nx()},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(),MC??(MC=new Promise(e=>{jC=e}))},ready(){jC&&(Q.getState().clearDeferredRender(),jC(),jC=null,MC=null)},random(){return Wc()},randomInt(e,t){return Gc(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){Rc(e,t);let{historyIndex:n}=Q.getState();Q.setState(e=>{let t=e.history[n];t&&(t.prng=Uc())})},isEnabled(){return Kc()},get seed(){return qc()},get pull(){return Jc()}}}}function GC(){window.Story=WC()}var KC=null;function qC(e){let t=KC;KC=new Map;try{return e()}finally{KC=t}}function JC(e,t){let n=t[0]+e,r=KC?.get(n);if(r)return r;try{r=_o(e,t)}catch(e){if(!(e instanceof co))throw e;r=e}return KC?.set(n,r),r}var YC=new Set([`if`,`elseif`,`case`]),XC=new Set([`dialog`]);function ZC(e,t){return e.map(e=>e.parameters?{...e,parameters:ZC(e.parameters,t)}:(e.type===`string`||e.type===`text`)&&!e.holds?{...e,holds:t}:e)}function QC(e){let t=new yr;for(let{name:n,parameters:r,interpolate:i}of e)r&&t.set(n,ZC(r,$C(i)));return e=>{let n=t.get(e);if(!n){let r=wC(e);r&&t.set(e,n=ZC(r,`text`))}return n}}var $C=e=>e?`markup`:`text`;function ew(e){if(e.type===`expression`||e.type===`passage`)return`expression`;if(e.type===`statements`)return`statements`}function tw(e){if(!(e.type!==`string`&&e.type!==`text`))return e.holds??`markup`}function*nw(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:iw(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=iw(e,r,t);if(t=i+r.length,!Go(n)){yield{kind:`text`,text:r,offset:i,where:`In the ${n} attribute of <${a.tag}>: `};continue}let o=0;for(let e of Ko(r)){if(!(`expr`in e))continue;let t=iw(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(XC.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(YC.has(o)){yield{kind:`code`,code:s,offset:u,goal:`expression`,label:c};continue}let d=n(o);d&&(yield*rw(s,u,d,a.name,c))}}}function*rw(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=ew(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),_=tw(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 iw(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 aw=new Set([`StoryVariables`,`StoryTransients`,`SaveTitle`]),ow=[`script`,`stylesheet`],sw=new Set([`elseif`,`else`,`case`,`default`,`next`]);function cw(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 lw(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 uw(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=lw(r,e.toLowerCase());t<a&&(i=e,a=t)}return i?` Did you mean ${n(i)}?`:``}var dw=` (a passage name is a quoted string or an expression)`,fw=/^[A-Za-z][\\w$]*$/;function pw(e){try{return _c(e).name.toLowerCase()||void 0}catch{return}}function mw(e,t){let n=[],r=t.isBlockMacro?{isBlock:t.isBlockMacro}:void 0,i=(e,t,r)=>{let{line:i,column:a}=Xo(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),aw.has(n.name)||n.tags?.some(e=>ow.includes(e)))continue;let e=!t.only||t.only(n);try{let t=$o(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;Qo(n.content,{hooks:r}),a.push([n,t])}catch(t){if(!(t instanceof Yo))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();sw.has(n)||o.has(n)||t.isKnownMacro(n)||i(e,r+s.start,`${a}Unknown macro {${s.name}}.${uw(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 nw(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=uw(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=JC(l.code,l.goal),r=l.code.trim();if(t instanceof co){let r=t.reasonIn(e.content,n);i(e,n+t.pos,`${c}${r} in ${l.label}`+(l.passage?dw:``))}else l.passage&&fw.test(r)&&i(e,n,`${c}Unquoted passage name in ${l.label}: write ${JSON.stringify(r)}${dw}`);continue}if(l.text.includes(`{`))try{Qo(l.text,{text:!0,hooks:r});let t=$o(l.text,{text:!0});d(e,l.text,t,n,l.where)}catch(t){if(!(t instanceof Yo))throw t;i(e,n+t.offset,l.where+t.reason)}}};for(let[e,t]of a)qC(()=>d(e,e.content,t,0,``));return n}function hw(e,t){try{return $o(e,{text:t})}catch(e){if(e instanceof Yo)return[];throw e}}function gw(e){let t=e.replace(/[.*+?^${}()|[\\]\\\\]/g,`\\\\$&`);return RegExp(`^${t}(\\\\w+)\\\\s*=\\\\s*(.+)$`)}var _w=/\\$(\\w+(?:\\.\\w+)*)/y,vw=/^[\"']\\$(\\w+(?:\\.\\w+)*)[\"']?$/,yw=new Set([`number`,`string`,`boolean`]),bw={string:Object(``),number:Object(0),boolean:Object(!1)};function xw(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,xw(i,t));return i}let n=typeof e;if(!yw.has(n))throw Error(`Unsupported type \"${n}\" for value ${String(e)}. Expected number, string, boolean, array, or object.`);return{type:n}}function Sw(e,t=`$`){let n=new Map,r=gw(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=rs(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}\": ${bs(e)}`)}let d;try{d=xw(u)}catch(e){throw Error(`${i}: ${bs(e)}`)}n.set(s,{...d,name:s,default:u})}return n}function Cw(e,t){let n=e.split(`.`),r=n[0],i=rs(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=bw[o.type];if(r&&t in r){let e=typeof r[t];if(!yw.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 ww=[`checkbox`,`cycle`,`listbox`,`numberbox`,`radiobutton`,`textarea`,`textbox`],Tw=new Set;function Ew(e,t){for(let n of Ko(e))`expr`in n&&Ow(n.expr,t)}function Dw(e,t,n=Tw){e.includes(`{`)&&Mw(e,hw(e,!0),n,t)}function Ow(e,t,n=`expression`){let r=JC(e,n);if(r instanceof co){kw(e,t,n);return}for(let n of r.refs)n.sigil===`$`&&(_w.lastIndex=n.start,t(_w.exec(e)[1]))}function kw(e,t,n){jo(e,{variable(n,r,i){n===`$`&&(_w.lastIndex=i,t(_w.exec(e)[1]))},literal(){}},n)}function Aw(e,t,n,r){qC(()=>Mw(e,hw(e,!1),t,n,r))}function jw(e,t,n){if(e.rawArgs){if(t){let r=[...rw(e.rawArgs,0,t,e.name,``)];if(!r.some(e=>e.kind===`argument-error`)){for(let e of r)e.kind===`code`?Ow(e.code,n,e.goal):e.kind===`text`&&Dw(e.text,n);return}}Ow(e.rawArgs,n)}}function Mw(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`)Dw(o.display,r);else if(o.type===`expression`)Ow(o.expression,r);else if(o.type===`html`)for(let[e,t]of Object.entries(o.attributes))Go(e)?Ew(t,r):Dw(t,r,n);else if(o.type===`macro`&&!o.isClose){if(jw(o,i(o.name),r),o.className&&Dw(o.className,r),o.id&&Dw(o.id,r),n.has(o.name.toLowerCase())){let e=o.rawArgs.trim().split(/\\s+/)[0]??``,t=vw.exec(e);t?r(t[1]):/^[\"'`]/.test(e)||Ow(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&&(Ow(e.slice(o.end,t[n].start),r,`statements`),a=n)}}}}function Nw(e,t,n=ww,r=kl){let i=[],a=new Set(Array.from(n,e=>e.toLowerCase()));for(let[n,o]of e)aw.has(n)||Aw(o.content,a,e=>{let r=Cw(e,t);r&&i.push(`Passage \"${n}\": ${r}`)},r);return i}function Pw(e){let t=q();for(let[n,r]of e)t[n]=r.default;return t}$({name:`set`,parameters:[{name:`code`,type:`statements`,required:!0}],render({rawArgs:e},t){return Cp(`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(jl(t.evaluate(e)))}catch(e){return J(xp,{macro:`print`,error:e})}},text({rawArgs:e},t){return jl(t.evaluate(e))}});var Fw=Symbol(`unset`);function Iw(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 is(n.slice(1),n),{target:n,expr:r}}function Lw(e,t,n,r,i,a,o,s,c){let l=bp(),u,d=o.current,f=!1,{navigationId:p}=Q.getState();try{let{variables:a,temporary:o,transient:c}=Jy();r||(d=as(n?o:a,t),f=p!==s.current),u=fl(e,a,o,i(),c)}catch(e){Sp(`computed ${a}`,e,l);return}if(s.current=p,!k_(o.current,u)||f&&!k_(d,u))if(o.current=u,r)try{c(t,u)}catch(e){Sp(`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}=Iw(e,t.args))}catch(e){return J(xp,{macro:`computed`,error:e})}let i=n.startsWith(`@`),a=n.startsWith(`_`),o=n.slice(1),s=i?t.update:null,c=t.hooks.useRef(Fw),l=t.hooks.useRef(-1),u=()=>Lw(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 Rw(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 zw(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}=Rw({...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=zw(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(xp,{macro:`meter`,error:e})}}});function Bw(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 Vw(e,t){return Ml(t.resolve(e.className),t.resolve(e.id),t.renderNodes(e.children))}function Hw(e,t){let n=e.findIndex(e=>e.rawArgs===``);return Bw(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=Hw(e,t.evaluate)}catch(e){return J(xp,{macro:`if`,error:e})}return n?Vw(n,t):null},text({branches:e=[]},t){let n=Hw(e,t.evaluate);return n?t.renderText(n.children):``}});function Uw(e){try{return Ww(e,new Map)}catch{return`<unkeyable>`}}function Ww(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=Rh(n),a=e=>i===void 0?e:`Class(${JSON.stringify(i)})${e}`,o=e=>{let r=i===void 0?[]:Oh(n);return a(r.length?`${e}${Gw(n,r,t)}`:e)};return e instanceof Date||e instanceof RegExp?(i!==void 0&&Oh(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})`)):(t.set(n,t.size),Array.isArray(e)?o(`[${Array.from(e,e=>Ww(e,t)).join(`,`)}]`):e instanceof Map?o(`Map[${Array.from(kh(e),([e,n])=>`[${Ww(e,t)},${Ww(n,t)}]`).join(`,`)}]`):e instanceof Set?o(`Set[${Array.from(Ah(e),e=>Ww(e,t)).join(`,`)}]`):a(Gw(n,Object.keys(n),t)))}function Gw(e,t,n){let r=e;return`{${t.map(e=>`${JSON.stringify(e)}:${Ww(r[e],n)}`).join(`,`)}}`}function Kw(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 is(n.slice(1),n),r&&is(r.slice(1),r),{itemVar:n.slice(1),indexVar:r?r.slice(1):null,listExpr:i}}function qw({parentValues:e,itemVar:t,itemValue:n,indexVar:r,indexValue:i,children:a}){return J(eu,{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(Tp),i=n.hooks.useRef({contents:[],generations:[],next:0,edits:sC()}).current,a,o;try{a=Kw(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(xp,{macro:`for`,error:e})}let{itemVar:s,indexVar:c}=a,l=cC(i.edits,Jy());i.edits=sC();let u=o.map((e,t)=>{let n=Uw(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(qw,{parentValues:r,itemVar:s,itemValue:e,indexVar:c,indexValue:n,children:t},`${n}-${u[n]}`));return n.wrap(J(iC.Provider,{value:!0,children:d}))},text({rawArgs:e,children:t=[]},n){let{itemVar:r,indexVar:i,listExpr:a}=Kw(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 Cp(`do`,``,()=>t.mutate(n))}});function Jw(e){return new Proxy(q(),{get:(t,n)=>typeof n==`string`?as(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 Yw=ge({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(Dc),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(Yw.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 Xw=()=>!0;function Zw(){let e=M(Ep),{nobr:t,inline:n}=$l(),r=M(Ip),i=M(Yw),a=M(kS),o=M(iC),s=M(Dc),c=j([]);Me(()=>{let e=Kx(()=>{let e=c.current.splice(0);queueMicrotask(()=>{for(let t of e)he(null,t)})});return()=>{e();for(let e of c.current.splice(0))he(null,e)}},[]);let l=l=>{let u=Jw(e.getValues),d=document.createElement(`div`);he(J(Ec.Provider,{value:Xw,children:J(Ep.Provider,{value:e,children:J(Tp.Provider,{value:u,children:J(Dp.Provider,{value:t,children:J(Op.Provider,{value:n,children:J(Ip.Provider,{value:r,children:J(Yw.Provider,{value:i,children:J(kS.Provider,{value:a,children:J(iC.Provider,{value:o,children:J(Dc.Provider,{value:s,children:km(l,{nobr:t,inline:n,locals:u})})})})})})})})})})}),d),c.current.push(d)};return e=>_b(()=>l(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=Zw(),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=pc(t.args.passage,t.evaluate,Q.getState())}catch(e){i={error:e}}let a=Zw(),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(xp,{macro:`link`,error:i.error}):J(`a`,{id:t.id,class:t.cls,href:`#`,onClick:e=>{e.preventDefault(),o()},children:n})}});function Qw(e,t,n){return Bw(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(xp,{macro:`switch`,error:e})}let i;try{i=Qw(r,t,n.evaluate)}catch(e){return J(xp,{macro:`case`,error:e})}return i?Vw(i,n):null},text({rawArgs:e,branches:t=[]},n){let r=Qw(n.evaluate(e),t,n.evaluate);return r?n.renderText(r.children):``}});var $w=[uc];$({name:`timed`,subMacros:[`next`],interpolate:!0,parameters:$w,render({branches:e=[]},t){let{useState:n,useEffect:r,useMemo:i,useContext:a}=t.hooks,o=a(Dc),s=i(()=>e.map(e=>({delay:dc(e.rawArgs,$w).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(Ml(t.resolve(u.className),t.resolve(u.id),t.renderNodes(u.nodes)))}}),$({name:`stop`,render(e,t){let{stop:n}=t.hooks.useContext(Yw);return t.hooks.useLayoutEffect(()=>{n()},[n]),null}});function eT(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(eT(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:hc,render({children:e=[]},t){let n,r;try{let e=gc(t.args);for(let t of e.params)is(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&&yc(n,e)},[i,o,s]),r?J(xp,{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 tT(e,t){return t?`${e} (${t})`:e}function nT(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(AS,{passageName:e.dialog.passageName,fallbackMarkup:e.dialog.fallbackMarkup,panelClass:e.dialog.panelClass,onClose:()=>i(!1),showCloseButton:e.dialog.showCloseButton})]})}})}nT({name:`back`,label:`← Back`,actionType:`back`,setup:()=>({perform:Q(e=>e.goBack),disabled:!Q(e=>e.historyIndex>0)})}),nT({name:`forward`,label:`Forward →`,actionType:`forward`,setup:()=>({perform:Q(e=>e.goForward),disabled:!Q(e=>e.historyIndex<e.history.length-1)})}),nT({name:`quicksave`,label:`QuickSave`,actionType:`save`,setup:()=>{let{quickSaveKey:e}=Oc(`quickSaveKey`);return{perform:NS,title:tT(`Quick Save`,e)}}}),nT({name:`quickload`,label:`QuickLoad`,actionType:`load`,confirm:`Load saved game? Current progress will be lost.`,setup:()=>{let{hasSave:e,quickLoadKey:t}=Oc(`hasSave`,`quickLoadKey`,`knownSaves`);return{perform:PS,disabled:!e(),title:tT(`Quick Load`,t)}}}),nT({name:`restart`,label:`↺ Restart`,actionType:`restart`,confirm:`Restart the story? All progress will be lost.`,setup:()=>({perform:Q(e=>e.restart)})}),nT({name:`saves`,label:`Saves`,actionType:`dialog`,dialog:{passageName:`SaveLoad`,fallbackMarkup:`{save-manager}`,panelClass:`dialog-saves`}}),nT({name:`settings`,label:`Settings`,actionType:`dialog`,hidden:()=>!QS.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(AS,{passageName:o,onClose:()=>r(!1),showCloseButton:!i})]})}});function rT(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 iT(e){return new Date(e).toLocaleDateString(void 0,{month:`short`,day:`numeric`,year:`numeric`})}function aT(){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(kS),{storyData:v,playthroughId:y,beginSave:b,loadFromPayload:x}=Oc(`storyData`,`playthroughId`,`beginSave`,`loadFromPayload`),S=v?.ifid??``,[C,w]=Ae(!1),T=Fe(async()=>{if(!S)return;let e=await Gv(S);w(f_()===`memory`),r(e),a(!1)},[S]);Me(()=>{T()},[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=Px();try{await Fv(void 0,void 0,b,async t=>Lv(S,e,t)),O(C?`Save created (temporary)`:`Save created`),await T()}catch{O(`Failed to create save`,`error`)}},re=async e=>{let t=Px();try{await Fv(void 0,void 0,b,async n=>{if(!await zv(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=>{try{x(Hv(e.payload),void 0,e.meta.playthroughId),O(`Game loaded`),_&&(D.current=window.setTimeout(_,500)),await T()}catch{O(`Failed to load save`,`error`)}},ie=async e=>{if(confirm(`Delete this save?`))try{await Uv(e);let t=await _y(S);Q.setState(e=>{e.knownSaves=t}),O(`Save deleted`),await T()}catch{O(`Failed to delete save`,`error`)}},ae=e=>{f.current=!1,d(e.meta.id),m(e.meta.title)},oe=async()=>{if(!(!u||!p.trim()))try{await Wv(u,p.trim()),d(null),O(`Save renamed`),await T()}catch{O(`Failed to rename`,`error`)}},se=e=>{e.key===`Enter`?oe():e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),f.current=!0,d(null))},ce=()=>{f.current||oe()},le=async e=>{try{let t=await jy(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`)}},ue=()=>{g.current?.click()},de=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(!Bg(t))throw Error(`Invalid save file format`);await Ny(t,S),O(`Save imported`),await T()}catch(e){O(bs(e,`Failed to import save`),`error`)}}},fe=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:ue,children:`Import`}),J(`input`,{ref:g,type:`file`,accept:`.json`,style:`display:none`,onChange:de})]}),J(`div`,{class:`saves-body`,children:[i?J(`div`,{class:`saves-empty`,children:`Loading...`}):fe===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:iT(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:se,onBlur:ce}):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:rT(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:()=>ae(t),children:`Rename`}),J(`button`,{type:`button`,class:`save-slot-action`,onClick:()=>le(t.meta.id),children:`Export`}),J(`button`,{type:`button`,class:`save-slot-action danger`,onClick:()=>ie(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(aT,{})}});function oT({name:e,def:t}){let[n,r]=Ae(()=>QS.get(e)),i=t=>{r(t),QS.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 sT(){let e=QS.getDefinitions();return J(`div`,{class:`settings-controls`,children:Array.from(e.entries()).map(([e,t])=>J(oT,{name:e,def:t},e))})}$({name:`settings-controls`,render(){return J(sT,{})}}),$({name:`include`,interpolate:!0,merged:!0,parameters:[{name:`inline`,type:`flag`},{name:`passage`,type:`passage`,required:!0}],render(e,t){let{storyData:n}=Oc(`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?Qo(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(xp,{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(Dp.Provider,{value:!0},u)):t.wrap(u)}}),$({name:`nobr`,block:!0,render({children:e=[]},t){return t.wrap(t.h(Dp.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){Sp(`goto`,t,e),r({error:t})}},[]),n?J(xp,{macro:`goto`,error:n.error}):null}}),$({name:`unset`,parameters:[{name:`variable`,type:`variable`,required:!0}],render({rawArgs:e},t){return Cp(`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 cT={name:`variable`,type:`variable`,required:!0};function lT(e,t){return e.useAction({key:`$${e.varName}`,authorId:e.id,variable:e.varName,value:e.value,...t})}function uT(e,t,n=e=>e===void 0?``:String(e)){$({name:e,storeVar:!0,parameters:[cT,{name:`placeholder`,type:`string`,holds:`text`}],render(r,i){let a=i.args.placeholder??``;lT(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:jl(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))}})}})}uT(`textbox`,`text`),uT(`numberbox`,`number`,e=>e===void 0?0:Number(e)),uT(`textarea`),$({name:`checkbox`,storeVar:!0,parameters:[cT,{name:`label`,type:`text`,holds:`text`}],render(e,t){let n=t.args.label??``;return lT(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:[cT,{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(Ap);return lT(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:[cT],render({children:e=[]},t){let n=t.extractOptions(e);return lT(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:jl(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:[cT],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 lT(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)});var dT=new WeakMap;function fT(e){let t=dT.get(e);if(t&&t.content===e.content)return t.ast;let n=Qo(e.content);return dT.set(e,{content:e.content,ast:n}),n}function pT(e){return km(fT(e),e.tags.includes(`nobr`)?{nobr:!0}:void 0)}function mT(e){if(!e)return null;try{return pT(e)}catch(t){return console.error(`spindle: Error in ${e.name}:`,t),null}}var hT=new Set([`PassageReady`,`PassageHeader`,`PassageFooter`,`PassageDone`]);function gT({passage:e,dataTransition:t,navigationId:n}){let{storyData:r}=Oc(`storyData`),i=hT.has(e.name),[a,o]=Ae(!1),s=Pe(()=>{try{return pT(e)}catch(t){return J(`div`,{class:`error`,children:[`Error parsing passage “`,e.name,`”`,yp(e),`: `,bs(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(()=>mT(l),[l?.content]),p=Pe(()=>mT(u),[u?.content]);Me(()=>(d&&o(!0),()=>o(!1)),[e.name]);let m=Pe(()=>a?mT(d):null,[a,d?.content]),h=j(null);Ne(()=>{n!==void 0&&kC(n),h.current&&pv(`passagerender`,e.name,h.current)},[e.name,n]);let g=e.tags.includes(`nobr`),_=Mp(),v=J(Ap.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(Dp.Provider,{value:!0,children:v}):v}var _T=new Set([`none`,`fade`,`fade-through`,`crossfade`]),vT={type:`fade-through`,duration:300,pause:50};function yT(e){let t=e.find(e=>e.startsWith(`transition:`));if(!t)return null;let n=t.slice(11);if(!_T.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 bT(e){return{type:e.type,duration:e.duration??vT.duration,pause:e.pause??vT.pause}}function xT(e,t,n){let r=yT(e);return r?bT(r):t?bT(t):n?bT(n):{...vT}}function ST(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 CT(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 wT(e,t){if(!e)return null;CT(e,t);let n=e.querySelector(`.passage`);return n?ST(n,t.type):null}function TT(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()}function ET(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}=Oc(`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=Fe(()=>{for(let e of _.current)clearTimeout(e);_.current=[],TT(g.current)},[]);Me(()=>v,[v]),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 y=e.consumeNextTransition();v();let b=i?.passages.get(n);if(!b){u.current=`none`,l(n);return}if(p||m||h){u.current=`fade`,l(n);return}let x=ET(xT(b.tags,y,s));u.current=x.type;let S=g.current;if(x.type===`none`){l(n);return}if(x.type===`fade`){S&&CT(S,x),l(n);return}let C=x.type===`fade-through`||x.type===`crossfade`?wT(S,x):null;if(!S||!C){l(n);return}if(x.type===`fade-through`){S.appendChild(C),l(``);let e=x.duration+x.pause,t=setTimeout(()=>{l(n)},e),r=e+x.duration;_.current=[t,setTimeout(()=>{TT(S)},r)];return}S.classList.add(`passage-container--crossfading`),S.appendChild(C),l(n),_.current=[setTimeout(()=>{TT(S)},x.duration)]},[r]);let y=c&&!a?o.id:null,b=j(y);Ne(()=>{if(y===null)return;let e=b.current;if(b.current=y,e===null||e===y)return;let t=g.current?.querySelector(`.passage`);t&&t.getBoundingClientRect().top<0&&t.scrollIntoView?.({block:`start`})},[y]);let x=a?i?.passages.get(`StoryLoading`)??null:c?i?.passages.get(c):null;if(!x&&c&&!a)return J(`div`,{class:`error`,children:[`Error: Passage “`,c,`” not found.`]});let S=i?.passages.get(`PassageReady`),C=!a&&o.id!==r&&h.current?h.current:x&&J(gT,{passage:x,dataTransition:a?`none`:u.current,navigationId:a?void 0:o.id},a?`loading`:`nav-${o.id}`);return h.current=C||null,J(`div`,{id:t.id??`story`,class:t.className??`story`,children:[!a&&S&&J(`div`,{hidden:!0,children:pT(S)},`ready-${r}`),J(`div`,{class:`passage-container`,ref:g,children:C&&J(Ec.Provider,{value:p,children:J(Dc.Provider,{value:m,children:C})})})]})}}),$({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(Ec),[,o]=n.useState(0);n.useEffect(()=>Gb(()=>o(e=>e+1)),[]);let s=n.useRef(null);return(s.current===null||s.current!==Wb()&&!a?.(Q.getState()))&&(s.current=Wb(),kb(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,Mb(n)),null}});var DT=`*,: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}.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 OT(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 kT(e){let t=document.getElementById(`root`);throw t&&OT(t,e),Error(`spindle: ${e.length} validation error(s):\\n${e.join(`\n`)}`)}function AT(e,t){let n=Al().filter(e=>e.storeVar).map(e=>e.name);return Nw(e.passages,t,n)}function jT(e,t){let n=Al();return mw(e.passages.values(),{isKnownMacro:e=>!!gl(e)||Sl(e)||!!vs(e),macroNames:n.map(e=>e.name),parametersOf:QC(n),only:t}).map(cw)}function MT(){let e=HS(),t=document.createElement(`style`);if(t.id=`spindle-styles`,t.textContent=DT,document.head.appendChild(t),GC(),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&&OT(t,[e]),Error(`spindle: ${e}`)}let i=Sw(r.content);for(let t of vc(e.passages.values()))Cr(t);let a=AT(e,i);a.push(...jT(e,e=>e.name===`StoryInit`));let o={},s=e.passages.get(`StoryTransients`);if(s){let e=Sw(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=Pw(e)}a.length>0&&kT(a),n=Pw(i),zC(Object.keys(n),Object.keys(o)),Q.getState().init(e,n,o),Xx();for(let[,t]of e.passages)t.tags.includes(`widget`)&&bc(Qo(t.content),t.name);Wy(Ty(e.ifid));let c=[...AT(e,i),...jT(e,e=>e.name!==`StoryInit`)];c.length>0&&kT(c);let l=Q.getState().navigationId;Q.subscribe(e=>{e.navigationId!==l&&(l=e.navigationId,_C())}),zb();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(FS,{}),d);let f=NC();f?f.then(()=>{document.dispatchEvent(new CustomEvent(`:storyready`))}):document.dispatchEvent(new CustomEvent(`:storyready`))}document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,MT):MT();</script>\n </head>\n <body>\n <div id=\"root\"></div>\n {{STORY_DATA}}\n </body>\n</html>\n"})
|