@rohal12/spindle 0.59.30 → 0.59.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- window.storyFormat({"name":"spindle","version":"0.59.30","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),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`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=/^m(i|n|o|s|text|space)$/,g=Array.isArray,_=m.slice,v=Object.assign;function y(e){e&&e.parentNode&&e.remove()}function b(e,t,n){var r,i,a,o={},s=arguments.length;for(a in t)a==`key`?r=t[a]:a==`ref`&&typeof e!=`function`?i=t[a]:o[a]=t[a];return s>2&&(o.children=s>3?_.call(arguments,2):n),x(e,o,r,i,null)}function x(e,t,i,a,o){var s={type:e,props:t,key:i,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:o||++r,__i:-1,__u:0};return!o&&n.vnode&&n.vnode(s),s}function S(e){return e.children}function C(e,t){this.props=e,this.context=t,this.__g=0}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])&&n.__e)return n.__e;return typeof e.type!=`function`||e.props.__P?null:w(e)}function T(e){if((e=e.__)&&e.__c&&!e.props.__P)return e.__e=null,e.__k.some(function(t){return t&&(e.__e=t.__e)}),T(e)}function E(e){(8&e.__g||!(e.__g|=8)||!i.push(e)||o++)&&a==n.debounceRendering||((a=n.debounceRendering)||queueMicrotask)(D)}function D(){var e,t,r,a,c,l,u,d,f;try{for(t=1;i.length;)i.length>t&&i.sort(s),e=i.shift(),t=i.length,8&e.__g&&(a=void 0,c=void 0,l=(c=(r=e).__v).__e,u=[],d=[],(f=r.__P)&&((a=v({constructor:void 0},c)).__v=c.__v+1,n.vnode&&n.vnode(a),oe(f,a,c,r.__n,f.namespaceURI,32&c.__u?[l]:null,u,l||w(c),32&c.__u,d),a.__v=c.__v,a.__.__k[a.__i]=a,ce(u,a,d),c.__=c.__e=null,a.__e!=l&&T(a)))}finally{i.length=o=0}}function ee(e,t,n,r,i,a,o,s,c,l,u){var d,f,h,g,_,v,y=r.__k||m,b=t.length;for(c=O(n,t,y,c,b),d=0;d<b;d++)(h=n.__k[d])!=null&&(f=~h.__i&&y[h.__i]||p,h.__i=d,v=oe(e,h,f,i,a,o,s,c,l,u),g=h.__e,(f.ref!=h.ref||8&f.__u)&&(f.ref&&ue(f.ref,null,h,f),h.ref&&u.push(h.ref,h.__c||g,h)),_=_||g,4&h.__u?(c=te(h,c,e,!f.__v),f.__e&&(f.__e=null)):typeof h.type==`function`&&v!==void 0?c=v:g&&(c=g.nextSibling),h.__u&=-7);return n.__e=_,c}function O(e,t,n,r,i){var a,o,s,c,l,u,d,f,p,m,h=n.length,_=h,v=0,y=!1,b=e.__k=Array(i);for(a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(typeof o!=`object`||o.constructor==String?o=b[a]=x(null,o):g(o)?o=b[a]=x(S,{children:o}):o.constructor===void 0&&o.__b?o=b[a]=x(o.type,o.props,o.key,o.ref,o.__v):b[a]=o,c=a+v,o.__=e,o.__b=e.__b+1,s=null,~(l=o.__i=ne(o,n,c,_))&&(_--,(s=n[l])&&(s.__u|=2)),s&&s.__v?(o.__u|=2,l==c-1?v--:l==c+1?v++:l!=c&&(l>c?v--:v++,y=!0)):(~l||(i>h?v--:i<h&&v++),typeof o.type!=`function`&&(o.__u|=4))):b[a]=null;if(y){for(u=[],d=[],a=0;a<i;a++)if((o=b[a])&&2&o.__u){for(f=0,p=u.length;f<p;)u[m=f+p>>1]<o.__i?f=m+1:p=m;u[f]=o.__i,d[a]=f+1}for(v=u.length;a--;)d[a]&&(d[a]==v?v--:b[a].__u|=4)}if(_)for(a=0;a<h;a++)!(s=n[a])||2&s.__u||(s.__e==r&&(r=w(s)),de(s,s));return r}function te(e,t,n,r){var i,a,o;if(typeof e.type==`function`){if(e.props.__P)return t;if(i=e.__k)for(a=0;a<i.length;a++)i[a]&&(i[a].__=e,t=te(i[a],t,n,!1));return t}for(t&&!t.parentNode&&(t=w(e))&&!t.parentNode&&(t=null),o=t;o&&o.nodeType==8;)o=o.nextSibling;for(e.__e!=o&&(!r&&n.moveBefore&&e.__e.parentNode?n.moveBefore(e.__e,t):n.insertBefore(e.__e,t||null)),t=e.__e;(t=t&&t.nextSibling)&&t.nodeType==8;);return t}function k(e,t){return t=t||[],e!=null&&typeof e!=`boolean`&&(g(e)?e.some(function(e){k(e,t)}):t.push(e)),t}function ne(e,t,n,r){var i,a,o,s=e.key,c=e.type,l=t[n],u=l&&!(2&l.__u);if(l===null&&s==null||u&&s==l.key&&c==l.type)return n;if(r>+!!u){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function re(e,t,n){n??(n=``),t[0]==`-`?e.setProperty(t,n):e[t]=n}function ie(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||re(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||re(e.style,t,n[t])}}else if(t[0]==`o`&&t[1]==`n`)(e.__e||(e.__e={}))[t]=n,n&&r||(o=d[t]||(d[t]=ae(t)),(e.__a||(e.__a={}))[t]=u,a=t!=(t=t.replace(l,`$1`)),(t=t.slice(2))[0]<`a`&&(t=t.toLowerCase()),n?e.addEventListener(t,o,a):e.removeEventListener(t,o,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 ae(e){return function(t){if(this.__e){var r=this.__e[e];if(t[c]==null)t[c]=u++;else if(t[c]<this.__a[e])return;return r(n.event?n.event(t):t)}}}function oe(e,t,r,i,a,o,s,c,l,u){var d,f,p,h,_,b,x,T,E,D,O,te,k,ne,re,ie,ae,oe,ce,ue,pe=t.type;if(t.constructor!==void 0)return null;if(128&r.__u&&(l=32&r.__u,d=r.__c.__z)){if(t.__u|=l,f=o=[],d.nodeType==8)for(p=1,h=d.nextSibling;h;h=h.nextSibling){if(h.nodeType==8){if(h.data.startsWith(`$s`))p++;else if(h.data.startsWith(`/$s`)&&!--p)break}o.push(h)}else o.push(d);c=o[0]}(d=n.__b)&&d(t);n:if(typeof pe==`function`){_=s.length;try{if(D=t.props,O=(d=pe.prototype)&&d.render,te=(d=pe.contextType)&&i[d.__c],k=d?te?te.props.value:d.__:i,r.__c?2&(b=t.__c=r.__c).__g&&(b.__g|=1):(O?t.__c=b=new pe(D,k):(t.__c=b=new C(D,k),b.constructor=pe,b.render=fe),te&&te.sub(b),b.state||(b.state={}),b.__n=i,b.__g|=8,b.__h=[],b.__k=[]),O&&(b.__s||(b.__s=b.state),pe.getDerivedStateFromProps&&(b.__s==b.state&&(b.__s=v({},b.__s)),v(b.__s,pe.getDerivedStateFromProps(D,b.__s)))),x=b.props,T=b.state,b.__v=t,r.__c){if(O&&!pe.getDerivedStateFromProps&&D!==x&&b.componentWillReceiveProps&&b.componentWillReceiveProps(D,k),t.__v==r.__v&&!(8&b.__g)||!(4&b.__g)&&b.shouldComponentUpdate&&!1===b.shouldComponentUpdate(D,b.__s,k)){t.__v!=r.__v&&(b.props=D,b.state=b.__s,b.__g&=-9),t.__e=r.__e,t.__k=r.__k,t.__k.some(function(e){e&&(e.__=t)}),m.push.apply(b.__h,b.__k),b.__k=[],b.__h.length&&s.push(b),c=w(r);break n}b.componentWillUpdate&&b.componentWillUpdate(D,b.__s,k),O&&b.componentDidUpdate&&b.__h.push(function(){b.componentDidUpdate(x,T,E)})}else O&&!pe.getDerivedStateFromProps&&b.componentWillMount&&b.componentWillMount(),O&&b.componentDidMount&&b.__h.push(b.componentDidMount);if(b.context=k,b.props=D,b.__P=e,b.__g&=-5,ne=n.__r,re=0,O)b.state=b.__s,b.__g&=-9,ne&&ne(t),d=b.render(b.props,b.state,b.context),m.push.apply(b.__h,b.__k),b.__k=[];else do b.__g&=-9,ne&&ne(t),d=b.render(b.props,b.state,b.context),b.state=b.__s;while(8&b.__g&&++re<25);b.state=b.__s,b.getChildContext&&(i=v({},i,b.getChildContext())),O&&r.__c&&b.getSnapshotBeforeUpdate&&(E=b.getSnapshotBeforeUpdate(x,T)),ie=d&&d.type===S&&d.key==null?d.props.children:d,D.__P&&(d=c,a=(e=D.__P).namespaceURI,l=o=null,r.props&&r.props.__P!=e&&(r.__k.some(function(e){e&&de(e,e)}),r.__k=null),c=r.__k?w(r,0):null),c=ee(e,g(ie)?ie:[ie],t,r,i,a,o,s,c,l,u),D.__P&&(t.__e=null,c=d),t.__u&=-161,128&r.__u&&(b.__z=null),f&&f.some(y),b.__h.length&&s.push(b),1&b.__g&&(b.__g&=-4)}catch(e){if(s.length=_,t.__v=null,l||o){if(e.then){if(ae=0,t.__u|=l?160:128,o){for(~(ce=o.indexOf(c||void 0))||(ce=o.length);(ue=o[ce-1])&&ue.nodeType==8;)ce--;for(;ce<o.length;ce++)if(ue=o[ce]){if(o[ce]=null,ue.nodeType==8){if(ue.data.startsWith(`$s`))ae++||(oe=ue);else if(ae&&ue.data.startsWith(`/$s`)&&!--ae){c=ue;break}}else if(!ae)break}}if(!oe){for(;c&&c.nodeType==8&&c.nextSibling;)c=c.nextSibling;oe=c}t.__c.__z||(t.__c.__z=oe),t.__e=c}else o&&o.some(y)}else t.__e=r.__e;t.__k||(t.__k=r.__k||[]),e.then||se(t),n.__e(e,t,r)}}else c=t.__e=le(r.__e,t,r,i,a,o,s,l,u,e);return(d=n.diffed)&&d(t),128&t.__u?void 0:c}function se(e){e&&(e.__c&&(e.__c.__g|=4),e.__k&&e.__k.some(se))}function ce(e,t,r){for(var i=0;i<r.length;)ue(r[i++],r[i++],r[i++]);n.__c&&n.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){n.__e(e,t.__v)}})}function le(e,t,r,i,a,o,s,c,l,u){var d,f,m,v,b,x,S,C,T,E=r.props||p,D=t.props,O=t.type;if(O==`svg`?a=`http://www.w3.org/2000/svg`:O==`math`?a=`http://www.w3.org/1998/Math/MathML`:a||(a=`http://www.w3.org/1999/xhtml`),o){for(d=0;d<o.length;d++)if((b=o[d])&&(O?b.localName==O:b.nodeType==3)){e=b,o[d]=null;break}}if(!e){if(C=u.ownerDocument||document,!O)return C.createTextNode(D);e=C.createElementNS(a,O,D.is&&D),c&&(n.__m&&n.__m(t,o),c=!1),o=null}if(O){if(u=O==`template`?e.content:e,o=O==`textarea`&&D.defaultValue!=null?null:o&&_.call(u.childNodes),!c&&o)for(E={},d=0;d<e.attributes.length;d++)E[(b=e.attributes[d]).name]=b.value;for(d in E)b=E[d],d==`dangerouslySetInnerHTML`?m=b:d==`children`||d in D||d==`value`&&`defaultValue`in D||d==`checked`&&`defaultChecked`in D||ie(e,d,null,b,a);for(d in T=1&r.__u,D)b=D[d],d==`children`?v=b:d==`dangerouslySetInnerHTML`?f=b:d==`value`?x=b:d==`checked`?S=b:c&&typeof b!=`function`||!(E[d]!==b||T&&b!=null)||ie(e,d,b,E[d],a);f?(c||m&&(f.__html==m.__html||f.__html==e.innerHTML)||(e.innerHTML=f.__html),t.__k=[]):(m&&(e.textContent=``),(O==`foreignObject`||a==`http://www.w3.org/1998/Math/MathML`&&h.test(O))&&(a=`http://www.w3.org/1999/xhtml`),ee(u,g(v)?v:[v],t,r,i,a,o,s,o?o[0]:r.__k&&w(r,0),c,l),o&&o.some(y)),c&&O!=`textarea`||(d=`value`,O==`progress`&&x==null?e.removeAttribute(d):x==null||x===e[d]&&(O!=`progress`||x)||ie(e,d,x,E[d],a),d=`checked`,S!=null&&S!=e[d]&&ie(e,d,S,E[d],a))}else E===D||c&&e.data==D||(e.data=D);return e}function ue(e,t,r,i){try{typeof e==`function`?t?t.__x=e(t)||1:i&&(i=i.__c||i.__e)&&(t=i.__x)&&(i.__x=null,typeof t==`function`?t():e(null)):e.current=t}catch(e){n.__e(e,r)}}function de(e,t,r){var i,a;if(n.unmount&&n.unmount(e),!(i=e.ref)||i.current&&i.current!=e.__e||ue(i,null,t,e),i=e.__c){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(e){n.__e(e,t)}i.__P=i.__n=null}if(i=e.__k)for(a=0;a<i.length;a++)i[a]&&de(i[a],t,typeof e.type!=`function`||r&&!e.props.__P);(i=e.__e)&&(r||y(i),i.__e&&(i.__e=null)),e.__e=e.__c=e.__=null}function fe(e,t,n){return this.constructor(e,n)}function pe(e,t){var r,i,a,o;n.__&&n.__(e,t),t.nodeType==9&&(t=t.documentElement),i=(r=e&&32&e.__u)?null:t.__k,t.__k=x(S,{children:[e]}),a=[],o=[],oe(t,t.__k,i||p,p,t.namespaceURI,i?null:t.firstChild?_.call(t.childNodes):null,a,i?i.__e:t.firstChild,r,o),ce(a,t.__k,o),t.__k.props.children=null}function me(e){function t(e){var n,r;return this.getChildContext||(n=new Set,(r={})[t.__c]=this,this.getChildContext=function(){return r},this.shouldComponentUpdate=function(e){this.props.value!=e.value&&n.forEach(function(e){e.__g|=4,E(e)})},this.sub=function(e){n.add(e);var t=e.componentWillUnmount;e.componentWillUnmount=function(){n.delete(e),t&&t.call(e)}}),e.children}return t.__c=`__cC`+f++,t.__=e,t.Provider=(t.Consumer=function(e,t){return e.children(t)}).contextType=t,t}n={__e:function(e,t,n,r){for(var i,a,s;t=t.__;)if((i=t.__c)&&!(1&i.__g)){i.__g|=4;try{if((a=i.constructor)&&a.getDerivedStateFromError&&(i.setState(a.getDerivedStateFromError(e)),s=8&i.__g),i.componentDidCatch&&(i.componentDidCatch(e,r||{}),s=8&i.__g),s)return void(i.__g|=2)}catch(t){e=t,s=0}}throw o=0,e}},r=0,C.prototype.setState=function(e,t){var n=this.__s;n&&n!=this.state||(n=this.__s=v({},this.state)),typeof e==`function`&&(e=e(v({},n),this.props)),e&&(v(n,e),this.__v&&(t&&this.__k.push(t),E(this)))},C.prototype.forceUpdate=function(e){this.__v&&(this.__g|=4,e&&this.__h.push(e),E(this))},C.prototype.render=S,i=[],o=0,s=function(e,t){return e.__v.__b-t.__v.__b},c=Symbol(),l=/(PointerCapture)$|Capture$/i,u=0,d={},f=0;var he,A,ge,_e,ve=Object.is,ye=0,be=[],xe=[],Se=n,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,ye||t),ye=0;var n=A.__H||(A.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function Ae(e){return ye=1,je(We,e)}function je(e,t,n){var r=ke(he++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):We(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);ve(t,n)||(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=A,!A.__f)){A.__f=!0;var i=A.shouldComponentUpdate;A.shouldComponentUpdate=function(e,t,n){var r=this.__H;if(!r)return!0;var a=!1,o=this.props!=e;if(r.__.some(function(e){e.__N&&(a=!0,ve(e.__[0],e.__N[0])||(o=!0))}),i){var s=i.call(this,e,t,n);return a?s||o:s}return!a||o}}return r.__}function Me(e,t){var n=ke(he++,3);!Se.__s&&Ue(n.__H,t)&&(n.__P=!0,n.__=e,n.u=t,A.__H.__h.push(n))}function Ne(e,t){var n=ke(he++,4);!Se.__s&&Ue(n.__H,t)&&(n.__P=!1,n.__=e,n.u=t,A.__h.push(n))}function j(e){return ye=5,Pe(function(){return{current:e}},[])}function Pe(e,t){var n=ke(he++,7);return Ue(n.__H,t)&&(n.__=e(),n.__H=t),n.__}function Fe(e,t){return ye=8,Pe(function(){return e},t)}function M(e){var t=A.context[e.__c],n=ke(he++,9);return n.c=e,t?(n.__??(n.__=!0,t.sub(A)),t.props.value):e.__}function Ie(){var e=ke(he++,11);if(!e.__){for(var t=A.__v;!t.__m&&t.__;)t=t.__;var n=t.__m||(t.__m=[0,0]);e.__=`P`+n[0]+`-`+n[1]++}return e.__}function Le(){var e;do{for(;e=xe.shift();)try{Ve(e)}catch(t){Se.__e(t,{__:(e=e.__P)&&e.__v})}for(;e=be.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(Ve),t.__h.some(He),t.__h=[]}catch(n){t.__h=[],Se.__e(n,e.__v)}}}while(xe.length)}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),he=0;var t=(A=e.__c).__H;t&&(ge==A?A.__h=[]:(t.__h.some(Ve),t.__h.some(He),he=0),t.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})),ge=A},Se.diffed=function(e){Te&&Te(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&Be(be.push(t)),t.__H.__.some(function(e){e.u&&(e.__H=e.u)})),ge=A=null},Se.__c=function(e,t){t.some(function(e){try{e.__h.some(Ve),e.__h=e.__h.filter(function(e){return!e.__||He(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,r=e.__c;r&&r.__H&&(r.__H.__.some(function(r){try{if(r.__P&&r.__c){if(n===void 0){for(n=e.__;n&&(!n.__c||!n.__c.__P);)n=n.__;n=n&&n.__c}r.__P=n,Be(xe.push(r))}else Ve(r)}catch(e){t=e}}),r.__H=void 0,t&&Se.__e(t,r.__v))};var Re=typeof requestAnimationFrame==`function`;function ze(e){var t,n=function(){clearTimeout(r),Re&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);Re&&(t=requestAnimationFrame(n))}function Be(e){e!=1&&_e==Se.requestAnimationFrame||((_e=Se.requestAnimationFrame)||ze)(Le)}function Ve(e){var t=A,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),A=t}function He(e){var t=A;e.__c=e.__(),A=t}function Ue(e,t){return!e||e.length!=t.length||t.some(function(t,n){return!ve(t,e[n])})}function We(e,t){return typeof t==`function`?t(e):t}var Ge=Object.assign,Ke=/^(-|f[lo].*[^se]$|g.{5,}[^ps]$|z|o[pr]|(W.{5})?[lL]i.*(t|mp)$|an|(bo|s).{4}Im|sca|m.{6}[ds]|ta|c.*[st]$|wido|ini)/,qe,Je,Ye=Symbol.for(`react.element`),Xe=/^(?: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]/,Ze=/[A-Z0-9]/g,Qe=typeof document<`u`,$e=at(function(e,t,r){var i=n.__s||qe?(r||t)():t(),a=Ae({t:{__:i,u:t}}),o=a[0].t,s=a[1];return Ne(function(){o.__=i,o.u=t,et(o)&&s({t:o})},[e,i,t]),Me(function(){return et(o)&&s({t:o}),e(function(){et(o)&&s({t:o})})},[e]),i});function et(e){try{return!Object.is(e.__,e.u())}catch{return!0}}var tt=function(e){return/fil|che|rad/.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 nt=n.event;n.event=function(e){return nt&&(e=nt(e)),e.persist=function(){},e.isPropagationStopped=function(){return this.cancelBubble},e.isDefaultPrevented=function(){return this.defaultPrevented},e.nativeEvent=e};var rt={configurable:!0,get:function(){return this.class}},it=n.vnode;function at(e){if(!Je){Je=!0;var t=n.__r;n.__r=function(e){t&&t(e),32&e.__u&&(qe=e),e.__c};var r=n.diffed;n.diffed=function(e){r&&r(e),qe==e&&(qe=null)}}return e}n.vnode=function(e){if(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||Qe&&a==`children`&&n==`noscript`||a==`class`||a==`className`)){if(a==`style`&&typeof o==`object`){var s=void 0;for(var c in o)typeof o[c]!=`number`||Ke.test(c)||(s||(s=o=Ge({},o)),o[c]+=`px`)}else if(a==`defaultValue`&&`value`in t&&t.value==null)a=`value`;else if(a==`download`&&!0===o)o=``;else if(a==`translate`&&o===`no`)o=!1;else if(a[0]==`o`&&a[1]==`n`){var l=a.toLowerCase();l==`ondoubleclick`?a=`ondblclick`:l!=`onchange`||n!=`input`&&n!=`textarea`||tt(t.type)?l==`onfocus`?a=`onfocusin`:l==`onblur`&&(a=`onfocusout`):l=a=`oninput`,l==`oninput`&&r[a=l]&&(a=`oninputCapture`)}else i&&Xe.test(a)?a=a.replace(Ze,`-$&`).toLowerCase():o===null&&(o=void 0);r[a]=o}}n==`select`&&(r.multiple&&Array.isArray(r.value)&&(r.value=k(t.children).forEach(function(e){e.props.selected=r.value.indexOf(e.props.value)!=-1})),r.defaultValue!=null&&(r.value=k(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\",rt)):t.className&&(r.class=r.className=t.className),e.props=r})(e);else if(typeof e.type==`function`&&(`ref`in e.props&&`prototype`in e.type&&e.type.prototype.render&&(e.ref=e.props.ref,delete e.props.ref),e.type.defaultProps)){var t=Ge({},e.props);for(var n in e.type.defaultProps)t[n]===void 0&&(t[n]=e.type.defaultProps[n]);e.props=t}e.ref&&!(`ref`in e.props)&&Object.defineProperty(e.props,\"ref\",{value:e.ref,configurable:!0,writable:!0}),e.$$typeof=Ye,it&&it(e)};var ot=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},st=(e=>e?ot(e):ot),ct=e=>e;function lt(e){function t(t=ct){let n=Fe(()=>t(e.getState()),[t]);return $e(e.subscribe,n)}return Object.assign(t,e)}function ut(){return e=>lt(st()(e))}function dt(){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 ft=Symbol.for(`immer-nothing`),pt=Symbol.for(`immer-draftable`),N=Symbol.for(`immer-state`);function mt(e,...t){throw Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var ht=Object,gt=ht.getPrototypeOf,_t=`constructor`,vt=`prototype`,yt=`configurable`,bt=`enumerable`,xt=`writable`,St=`value`,Ct=e=>!!e&&!!e[N];function wt(e){return e?Dt(e)||Ft(e)||!!e[pt]||!!e[_t]?.[pt]||It(e)||Lt(e):!1}var Tt=ht[vt][_t].toString(),Et=new WeakMap;function Dt(e){if(!e||!Rt(e))return!1;let t=gt(e);if(t===null||t===ht[vt])return!0;let n=ht.hasOwnProperty.call(t,_t)&&t[_t];if(n===Object)return!0;if(!zt(n))return!1;let r=Et.get(n);return r===void 0&&(r=Function.toString.call(n),Et.set(n,r)),r===Tt}function Ot(e){return Ct(e)||mt(15,e),e[N].base_}function kt(e,t,n=!0){At(e)===0?(n?Reflect.ownKeys(e):ht.keys(e)).forEach(n=>{t(n,e[n],e)}):e.forEach((n,r)=>t(r,n,e))}function At(e){let t=e[N];return t?t.type_:Ft(e)?1:It(e)?2:Lt(e)?3:0}var jt=(e,t,n=At(e))=>n===2?e.has(t):ht[vt].hasOwnProperty.call(e,t),Mt=(e,t,n=At(e))=>n===2?e.get(t):e[t],Nt=(e,t,n,r=At(e))=>{r===2?e.set(t,n):r===3?e.add(n):e[t]=n};function Pt(e,t){return e===t?e!==0||1/e==1/t:e!==e&&t!==t}var Ft=Array.isArray,It=e=>e instanceof Map,Lt=e=>e instanceof Set,Rt=e=>typeof e==`object`,zt=e=>typeof e==`function`,Bt=e=>typeof e==`boolean`;function P(e){let t=+e;return Number.isInteger(t)&&String(t)===e}var F=e=>Rt(e)?e?.[N]:null,I=e=>e.copy_||e.base_,Vt=e=>{let t=F(e);return t?Ht(t):e},Ht=e=>e.modified_?e.copy_:e.base_;function L(e,t){if(It(e))return new Map(e);if(Lt(e))return new Set(e);if(Ft(e))return Array[vt].slice.call(e);let n=Dt(e);if(t===!0||t===`class_only`&&!n){let t=ht.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[xt]===!1&&(a[xt]=!0,a[yt]=!0),(a.get||a.set)&&(t[i]={[yt]:!0,[xt]:!0,[bt]:a[bt],[St]:e[i]})}return ht.create(gt(e),t)}{let t=gt(e);if(t!==null&&n)return{...e};let r=ht.create(t);return ht.assign(r,e)}}function Ut(e,t=!1){return Kt(e)||Ct(e)||!wt(e)||(At(e)>1&&ht.defineProperties(e,{set:Gt,add:Gt,clear:Gt,delete:Gt}),ht.freeze(e),t&&kt(e,(e,t)=>{Ut(t,!0)},!1)),e}function Wt(){mt(2)}var Gt={[St]:Wt};function Kt(e){return e===null||!Rt(e)||ht.isFrozen(e)}var qt=`MapSet`,Jt=`Patches`,Yt=`ArrayMethods`,Xt={};function Zt(e){let t=Xt[e];return t||mt(0,e),t}var Qt=e=>!!Xt[e];function $t(e,t){Xt[e]||(Xt[e]=t)}var R,en=()=>R,tn=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:Qt(qt)?Zt(qt):void 0,arrayMethodsPlugin_:Qt(Yt)?Zt(Yt):void 0});function nn(e,t){t&&(e.patchPlugin_=Zt(Jt),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function rn(e){an(e),e.drafts_.forEach(sn),e.drafts_=null}function an(e){e===R&&(R=e.parent_)}var on=e=>R=tn(R,e);function sn(e){let t=e[N];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function cn(e,t){t.unfinalizedDrafts_=t.drafts_.length;let n=t.drafts_[0];if(e!==void 0&&e!==n){n[N].modified_&&(rn(t),mt(4)),wt(e)&&(e=ln(t,e));let{patchPlugin_:r}=t;r&&r.generateReplacementPatches_(n[N].base_,e,t)}else e=ln(t,n);return un(t,e,!0),rn(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e===ft?void 0:e}function ln(e,t){if(Kt(t))return t;let n=t[N];if(!n)return vn(t,e.handledSet_,e);if(!fn(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);gn(n,e)}return n.copy_}function un(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Ut(t,n)}function dn(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var fn=(e,t)=>e.scope_===t,pn=[];function mn(e,t,n,r){let i=I(e),a=e.type_;if(r!==void 0&&Mt(i,r,a)===t){Nt(i,r,n,a);return}if(!e.draftLocations_){let t=e.draftLocations_=new Map;kt(i,(e,n)=>{if(Ct(n)){let r=t.get(n)||[];r.push(e),t.set(n,r)}})}let o=e.draftLocations_.get(t)??pn;for(let e of o)Nt(i,e,n,a)}function hn(e,t,n){e.callbacks_.push(function(r){let i=t;if(!i||!fn(i,r))return;r.mapSetPlugin_?.fixSetContents(i);let a=Ht(i);mn(e,i.draft_??i,a,n),gn(i,r)})}function gn(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)}dn(e)}}function _n(e,t,n){let{scope_:r}=e;if(Ct(n)){let i=n[N];fn(i,r)&&i.callbacks_.push(function(){Dn(e),mn(e,n,Ht(i),t)})}else wt(n)&&e.callbacks_.push(function(){let i=I(e);e.type_===3?i.has(n)&&vn(n,r.handledSet_,r):Mt(i,t,e.type_)===n&&r.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&vn(Mt(e.copy_,t,e.type_),r.handledSet_,r)})}function vn(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||Ct(e)||t.has(e)||!wt(e)||Kt(e)||(t.add(e),kt(e,(r,i)=>{if(Ct(i)){let t=i[N];fn(t,n)&&(Nt(e,r,Ht(t),e.type_),dn(t))}else wt(i)&&vn(i,t,n)})),e}function yn(e,t){let n=Ft(e),r={type_:+!!n,scope_:t?t.scope_:en(),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=bn;n&&(i=[r],a=xn);let{revoke:o,proxy:s}=Proxy.revocable(i,a);return r.draft_=s,r.revoke_=o,[s,r]}var bn={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=I(e);if(!jt(i,t,e.type_))return wn(e,i,t);let a=i[t];if(e.finalized_||!wt(a)||r&&e.operationMethod&&n?.isMutatingArrayMethod(e.operationMethod)&&P(t))return a;if(a===Sn(e.base_,t)||Cn(e,t,a)){Dn(e);let n=e.type_===1?+t:t,r=kn(e.scope_,a,e,n);return e.copy_[n]=r}return a},has(e,t){return t in I(e)},ownKeys(e){return Reflect.ownKeys(I(e))},set(e,t,n){let r=Tn(I(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){let r=Sn(I(e),t),i=r?.[N];if(i&&i.base_===n)return e.copy_[t]=n,e.assigned_.delete(t),!0;if(Pt(n,r)&&(n!==void 0||jt(e.base_,t,e.type_)))return!0;Dn(e),En(e)}return e.copy_[t]===n&&(n!==void 0||jt(e.copy_,t,e.type_))||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_.set(t,!0),_n(e,t,n)),!0},deleteProperty(e,t){return Dn(e),Sn(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),En(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let n=I(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{[xt]:!0,[yt]:e.type_!==1||t!==`length`,[bt]:r[bt],[St]:n[t]}},defineProperty(){mt(11)},getPrototypeOf(e){return gt(e.base_)},setPrototypeOf(){mt(12)}},xn={};for(let e in bn){let t=bn[e];xn[e]=function(){let e=arguments;return e[0]=e[0][0],t.apply(this,e)}}xn.deleteProperty=function(e,t){return xn.set.call(this,e,t,void 0)},xn.set=function(e,t,n){return bn.set.call(this,e[0],t,n,e[0])};function Sn(e,t){let n=e[N];return(n?I(n):e)[t]}function Cn(e,t,n){return e.type_!==1||!e.allIndicesReassigned_||e.assigned_?.get(t)||!wt(n)||n[N]?!1:e.baseRefs_.has(n)}function wn(e,t,n){let r=Tn(t,n);return r?St in r?r[St]:r.get?.call(e.draft_):void 0}function Tn(e,t){if(!(t in e))return;let n=gt(e);for(;n;){let e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=gt(n)}}function En(e){e.modified_||(e.modified_=!0,e.parent_&&En(e.parent_))}function Dn(e){e.copy_||(e.assigned_=new Map,e.copy_=L(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var On=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(e,t,n)=>{if(zt(e)&&!zt(t)){let n=t;t=e;let r=this;return function(e=n,...i){return r.produce(e,e=>t.call(this,e,...i))}}zt(t)||mt(6),n!==void 0&&!zt(n)&&mt(7);let r;if(wt(e)){let i=on(this),a=kn(i,e,void 0),o=!0;try{r=t(a),o=!1}finally{o?rn(i):an(i)}return nn(i,n),cn(r,i)}if(!e||!Rt(e)){if(r=t(e),r===void 0&&(r=e),r===ft&&(r=void 0),this.autoFreeze_&&Ut(r,!0),n){let t=[],i=[];Zt(Jt).generateReplacementPatches_(e,r,{patches_:t,inversePatches_:i}),n(t,i)}return r}mt(1,e)},this.produceWithPatches=(e,t)=>{if(zt(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]},Bt(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),Bt(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),Bt(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){wt(e)||mt(8),Ct(e)&&(e=An(e));let t=on(this),n=kn(t,e,void 0);return n[N].isManual_=!0,an(t),n}finishDraft(e,t){let n=e&&e[N];(!n||!n.isManual_)&&mt(9);let{scope_:r}=n;return nn(r,t),cn(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=Zt(Jt).applyPatches_;return Ct(e)?r(e,t):this.produce(e,e=>r(e,t))}};function kn(e,t,n,r){let[i,a]=It(t)?Zt(qt).proxyMap_(t,n):Lt(t)?Zt(qt).proxySet_(t,n):yn(t,n);return(n?.scope_??en()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?hn(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 An(e){return Ct(e)||mt(10,e),jn(e)}function jn(e){if(!wt(e)||Kt(e))return e;let t=e[N],n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=L(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=L(e,!0);return kt(n,(e,t)=>{Nt(n,e,jn(t))},r),t&&(t.finalized_=!1),n}function Mn(){function e(n,r=[]){if(n.key_!==void 0){let e=n.parent_.copy_??n.parent_.base_,t=F(Mt(e,n.key_)),i=Mt(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||jt(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=Mt(n,r),!Rt(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;kt(e.assigned_,(e,l)=>{let u=Mt(o,e,c),f=Mt(s,e,c),p=l?jt(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===ft?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=At(o),n=i[e];typeof n!=`string`&&typeof n!=`number`&&(n=``+n),(t===0||t===1)&&(n===`__proto__`||n===_t)&&mt(19),zt(o)&&n===vt&&mt(19),o=Mt(o,n),(o===null||!Rt(o))&&mt(18,i.join(`/`))}let s=At(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:mt(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:mt(17,a)}}),e}function u(e){if(!wt(e))return e;if(Ft(e))return e.map(u);if(It(e))return new Map(Array.from(e.entries()).map(([e,t])=>[e,u(t)]));if(Lt(e))return new Set(Array.from(e).map(u));let t=Object.create(gt(e));for(let n in e)t[n]=u(e[n]);return jt(e,pt)&&(t[pt]=e[pt]),t}function d(e){return Ct(e)?u(e):e}$t(Jt,{applyPatches_:l,generatePatches_:i,generateReplacementPatches_:c,getPath:e})}var Nn=globalThis.Iterator,Pn=typeof Nn?.from==`function`;function Fn(){class e extends Map{constructor(e,t){super(),this[N]={type_:2,parent_:t,scope_:t?t.scope_:en(),modified_:!1,finalized_:!1,copy_:void 0,assigned_:void 0,base_:e,draft_:this,isManual_:!1,revoked_:!1,callbacks_:[]}}get size(){let e=this[N];return s(e),I(e).size}has(e){let t=this[N];return s(t),I(t).has(e)}set(e,t){let n=this[N];return s(n),(!I(n).has(e)||I(n).get(e)!==t)&&(r(n),En(n),n.assigned_.set(e,!0),n.copy_.set(e,t),n.assigned_.set(e,!0),_n(n,e,t)),this}delete(e){if(!this.has(e))return!1;let t=this[N];return s(t),r(t),En(t),t.base_.has(e)?t.assigned_.set(e,!1):t.assigned_.delete(e),t.copy_.delete(e),!0}clear(){let e=this[N];s(e),I(e).size&&(r(e),En(e),e.assigned_=new Map,kt(e.base_,t=>{e.assigned_.set(t,!1)}),e.copy_.clear())}forEach(e,t){let n=this[N];s(n),I(n).forEach((n,r,i)=>{e.call(t,this.get(r),r,this)})}get(e){let t=this[N];s(t);let n=I(t).get(e);if(t.finalized_||!wt(n)||n!==t.base_.get(e))return n;let i=kn(t.scope_,n,t,e);return r(t),t.copy_.set(e,i),i}keys(){let e=this[N];return s(e),I(e).keys()}values(){let e=this.keys();return t({next:()=>{let t=e.next();return t.done?t:{done:!1,value:this.get(t.value)}}})}entries(){let e=this.keys();return t({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(e){if(Pn)return Nn.from(e);let t={...e,[Symbol.iterator]:()=>t};return t}function n(t,n){let r=new e(t,n);return[r,r[N]]}function r(e){e.copy_||(e.assigned_=new Map,e.copy_=new Map(e.base_))}class i extends Set{constructor(e,t){super(),this[N]={type_:3,parent_:t,scope_:t?t.scope_:en(),modified_:!1,finalized_:!1,copy_:void 0,base_:e,draft_:this,drafts_:new Map,revoked_:!1,isManual_:!1,assigned_:void 0,callbacks_:[]}}get size(){let e=this[N];return s(e),I(e).size}has(e){let t=this[N];return s(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 s(t),this.has(e)||(o(t),En(t),t.copy_.add(e),_n(t,e,e)),this}delete(e){if(!this.has(e))return!1;let t=this[N];return s(t),o(t),En(t),t.copy_.delete(e)||(t.drafts_.has(e)?t.copy_.delete(t.drafts_.get(e)):!1)}clear(){let e=this[N];s(e),I(e).size&&(o(e),En(e),e.copy_.clear())}values(){let e=this[N];return s(e),o(e),e.copy_.values()}entries(){let e=this[N];return s(e),o(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 a(e,t){let n=new i(e,t);return[n,n[N]]}function o(e){e.copy_||(e.copy_=new Set,e.base_.forEach(t=>{if(wt(t)){let n=kn(e.scope_,t,e,t);e.drafts_.set(t,n),e.copy_.add(n)}else e.copy_.add(t)}))}function s(e){e.revoked_&&mt(3,JSON.stringify(I(e)))}function c(e){if(e.type_===3&&e.copy_){let t=new Set(e.copy_);e.copy_.clear(),t.forEach(t=>{e.copy_.add(Vt(t))})}}$t(qt,{proxyMap_:n,proxySet_:a,fixSetContents:c})}var In=new On().produce,Ln=e=>(t,n,r)=>(r.setState=(e,n,...r)=>t(typeof e==`function`?In(e):e,n,...r),e(r.setState,n,r)),Rn={$:`variable`,_:`temporary`,\"@\":`local`,\"%\":`transient`},zn=Object.fromEntries(Object.entries(Rn).map(([e,t])=>[t,e])),Bn=new Set(Object.keys(Rn));function Vn(e){return e!==void 0&&Bn.has(e)}function Hn(e,t){return t.className&&(e.className=t.className),t.id&&(e.id=t.id),e}var Un={SIGIL_SCOPES:Rn,withSelectors:Hn},Wn=`{`,Gn=`}`,{SIGIL_SCOPES:Kn,withSelectors:qn}=Un,Jn=new Set([`area`,`base`,`br`,`col`,`embed`,`hr`,`img`,`input`,`link`,`meta`,`param`,`source`,`track`,`wbr`]),Yn={elseif:`if`,else:`if`,case:`switch`,default:`switch`,next:`timed`},Xn=[[`|`,!1],[`->`,!1],[`<-`,!0]],Zn={},Qn=/^<[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 $n(e,t,n){let r=(n,r)=>{let i=e.slice(n,r),a=i.trim(),o=t+n+(a?i.indexOf(a):0);return{value:a,start:o,end:o+a.length}};for(let[t,i]of Xn){let a=n(t);if(a===-1)continue;let o=r(0,a),s=r(a+t.length,e.length),[c,l]=i?[s,o]:[o,s];return{display:c.value,displayStart:c.start,displayEnd:c.end,target:l.value,targetStart:l.start,targetEnd:l.end}}let i=r(0,e.length);return{display:i.value,displayStart:i.start,displayEnd:i.end,target:i.value,targetStart:i.start,targetEnd:i.end}}function er(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 tr(e){return e.lex===`html`?(e.isClose?`</`:`<`)+e.tag+`>`:Wn+(e.isClose?`/`:``)+e.name+Gn}function nr(e,t,n){return n.lex=e,n.start=t.start.offset,n.end=t.end.offset,n.loc=t,n}function rr(e){let t={start:e.start,end:e.end};switch(e.lex){case`text`:return e.comment?{type:`text`,value:e.value,comment:!0,...t}:{type:`text`,value:e.value,...t};case`link`:return qn({type:`link`,display:e.display,displayStart:e.displayStart,displayEnd:e.displayEnd,target:e.target,targetStart:e.targetStart,targetEnd:e.targetEnd,...e.selectorSpan,...t},e);case`variable`:return qn({type:`variable`,name:e.name,nameStart:e.nameStart,nameEnd:e.nameEnd,scope:e.scope,...e.selectorSpan,...t},e);case`expression`:return qn({type:`expression`,expression:e.expression,expressionStart:e.expressionStart,expressionEnd:e.expressionEnd,...e.selectorSpan,...t},e);case`macro`:return qn({type:`macro`,name:e.name,nameStart:e.nameStart,nameEnd:e.nameEnd,rawArgs:e.rawArgs,argsStart:e.argsStart,argsEnd:e.argsEnd,isClose:e.isClose,...e.selectorSpan,...t},e);case`html`:return{type:`html`,tag:e.tag,tagNameStart:e.tagNameStart,tagNameEnd:e.tagNameEnd,attributes:e.attributes,attributeSpans:e.attributeSpans,isClose:e.isClose,isSelfClose:e.isSelfClose,...t}}}function ir(e){let t=[],n=null,r=e=>{if(e!=null){if(Array.isArray(e))return e.forEach(r);e.lex===`text`&&!e.escape&&!e.comment&&n&&n.lex===`text`&&!n.escape&&!n.comment&&n.end===e.start?(n.value+=e.value,n.end=e.end):(t.push(e),n=e)}};return r(e),t.map(rr)}var ar=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 or(e,t){t=t===void 0?{}:t;let n={},r=t.grammarSource,i={Tokens:nn,SelectorsPrefix:hn},a=nn,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>]/,E=/^[ \\t\\n\\r\\v\\f\\xA0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000\\uFEFF]/,D=Xt(),ee=Yt([`\\\\`,`{`,`[`,`<`],!0,!1,!1),O=Jt(`\\x3C!--`,!1),te=Jt(`>`,!1),k=Jt(`->`,!1),ne=Jt(`-->`,!1),re=Jt(`\\\\`,!1),ie=Yt([`{`,`}`],!1,!1,!1),ae=Jt(`{`,!1),oe=Yt([`$`,`_`,`@`,`%`,`(`,`!`,`/`,[`a`,`z`],[`A`,`Z`]],!1,!1,!1),se=Jt(`<`,!1),ce=Jt(`[`,!1),le=Jt(`[[`,!1),ue=Jt(`]]`,!1),de=Jt(` `,!1),fe=Yt([`.`,`#`],!1,!1,!1),pe=Yt([[`a`,`z`],[`A`,`Z`],[`0`,`9`],`_`,`-`],!1,!1,!1),me=Yt([`$`,`_`,`@`,`%`],!1,!1,!1),he=Yt([[`a`,`z`],[`A`,`Z`],[`0`,`9`],`_`,`.`],!1,!1,!1),A=Jt(`}`,!1),ge=Yt([`$`,`_`,`@`,`%`,`(`,`!`],!1,!1,!1),_e=Jt(`/`,!1),ve=Yt([[`a`,`z`],[`A`,`Z`]],!1,!1,!1),ye=Yt([` `,`\t`,`\n`,`\\r`,`\\v`,`\\f`,`\\xA0`,` `,[` `,` `],`\\u2028`,`\\u2029`,` `,` `,` `,``,`}`],!0,!1,!1),be=Yt([[`a`,`z`],[`A`,`Z`],[`0`,`9`],`.`,`!`,`#`,`$`,`%`,`&`,`'`,`*`,`+`,`/`,`=`,`?`,`^`,`_`,\"`\",`|`,`~`,`-`],!1,!1,!1),xe=Jt(`@`,!1),Se=Yt([[`a`,`z`],[`A`,`Z`],[`0`,`9`],`.`,`-`],!1,!1,!1),Ce=Yt([[`\t`,`\\r`],` `,`/`,`>`,`\\xA0`,` `,[` `,` `],[`\\u2028`,`\\u2029`],` `,` `,` `,``],!1,!1,!1),we=Jt(`</`,!1),Te=Yt([[`a`,`z`],[`A`,`Z`],[`0`,`9`],`-`],!1,!1,!1),Ee=Yt([[`\t`,`\\r`],` `,`\"`,`'`,`/`,[`<`,`>`],`{`,`}`,`\\xA0`,` `,[` `,` `],[`\\u2028`,`\\u2029`],` `,` `,` `,``],!1,!1,!1),De=Jt(`=`,!1),Oe=Jt(`\"`,!1),ke=Yt([`\"`],!0,!1,!1),Ae=Jt(`'`,!1),je=Yt([`'`],!0,!1,!1),Me=Yt([`\"`,`'`],!1,!1,!1),Ne=Yt([` `,`\t`,`\n`,`\\r`,`\\v`,`\\f`,`\\xA0`,` `,[` `,` `],`\\u2028`,`\\u2029`,` `,` `,` `,``,`>`],!0,!1,!1),j=Yt([` `,`\t`,`\n`,`\\r`,`\\v`,`\\f`,`\\xA0`,` `,[` `,` `],`\\u2028`,`\\u2029`,` `,` `,` `,``],!1,!1,!1);function Pe(e){return ir(e)}function Fe(){return!jn}function M(e){return e}function Ie(){return!jn}function Le(e){return Jn.has(e.lower)?null:e}function Re(e){return Fn=e.lower,e.kind===`open`&&Mn.isRaw(Fn)}function ze(e,t){return t}function Be(e,t){return t?[e,t]:e}function Ve(e){return e.kind===`close`}function He(e){return e}function Ue(){return!jn}function We(e){return e}function Ge(t){return Rn(Mn.rawBodyEnd(e,t,Fn))}function Ke(e){return Nn-Wt()}function qe(e,t,n){let r={start:{offset:e},end:{offset:e+t.length}};return[t?nr(`text`,r,{value:t}):null,n]}function Je(){return Wt()}function Ye(e){return nr(`text`,Gt(),{value:e})}function Xe(e){let t=nr(`text`,Gt(),{value:e});return t.comment=!0,t}function Ze(e){return e.length%2==1}function Qe(e,t){return t}function $e(t,n){let r=Gt(),i=e.charAt(r.end.offset);if(jn){if(!n&&i!==Wn&&i!==Gn)return nr(`text`,r,{value:t});let e=nr(`text`,r,{value:`\\\\`.repeat(t.length>>1)+(n||``)});return e.escape=!0,e}if(!n)return nr(`text`,r,{value:t});let a=nr(`text`,r,{value:t.slice(1)});a.end=r.end.offset-2;let o=nr(`text`,r,{value:n});return o.start=r.end.offset-2,o.escape=!0,t.length>1?[a,o]:o}function et(){return nr(`text`,Gt(),{value:Wn})}function tt(){return!jn}function nt(){return nr(`text`,Gt(),{value:`<`})}function rt(){return nr(`text`,Gt(),{value:`[`})}function it(){return!jn}function at(e,t,n,r){let i=nr(`link`,Gt(),$n(r,n,e=>In(r,n,e)));return i.selectorSpan=Ln(t,e,n),qn(i,t)}function ot(){return!jn}function st(){zn(`Unclosed link: [[ without ]]`,Gt(),`unclosed-link`)}function ct(e){return er(e)}function lt(){return Zn}function ut(e,t){return{...e,end:t}}function dt(e,t){return[e,t]}function ft(e,t,n,r,i){let a=nr(`variable`,Gt(),{name:i,nameStart:r,nameEnd:r+i.length,scope:Kn[n]});return a.selectorSpan=Ln(t,e,r-1),qn(a,t)}function pt(e,t,n,r){let i=nr(`expression`,Gt(),{expression:r,expressionStart:n,expressionEnd:n+r.length});return i.selectorSpan=Ln(t,e,n),qn(i,t)}function N(){zn(`Unclosed {`+e.substr(Gt().end.offset,1)+`…: no } ends it`,Gt(),`unclosed-expression`)}function mt(t){return Rn(Mn.closeBrace(e,t,t))}function ht(e){return Nn-Wt()}function gt(e,t){return t}function _t(t,n,r,i,a,o){return Rn(Mn.closeBrace(e,o,r))}function vt(e,t,n,r,i,a){return Nn-Wt()}function yt(e,t,n,r,i,a,o){return o}function bt(e,t,n,r,i,a,o){let s=Gt(),c=i.toLowerCase(),l=nr(`macro`,s,{name:i,lower:c,rawArgs:``,isClose:!!r});return l.nameStart=a-i.length,l.nameEnd=a,l.selectorSpan=Ln(t,e,n),o===null&&zn(`Unclosed {`+(r?`/`:``)+i+`…: no } ends the macro`,s,`unclosed-macro`),l.rawArgs=o.trim(),l.argsStart=l.rawArgs?a+o.length-o.trimStart().length:a,l.argsEnd=l.argsStart+l.rawArgs.length,r?(t!==Zn&&zn(`A closing tag takes no selectors: `+tr(l),s,`closer-with-selectors`),l.rawArgs&&zn(`A closing tag takes no arguments: {/`+i+` `+l.rawArgs+Gn,s,`closer-with-arguments`),l.kind=`close`):(qn(l,t),l.kind=Object.prototype.hasOwnProperty.call(Yn,c)?`branch`:`open`),l}function xt(e){zn(`A closing tag starts with a letter after {/`,Gt(),`invalid-closer`)}function St(e){return Qn.test(e)}function Ct(e){return nr(`text`,Gt(),{value:e})}function wt(e,t,n,r){let i=t.toLowerCase();return nr(`html`,Gt(),{tag:t,lower:i,tagNameStart:e,tagNameEnd:e+t.length,attributes:Bn(n),attributeSpans:n,isClose:!1,isSelfClose:!!r||Jn.has(i)})}function Tt(t,n){let r=e.charAt(n);r||zn(`Unclosed tag <`+t+`: no > ends it (write &lt; for a < that starts no tag)`,Gt(),`unclosed-tag`);let i={source:Gt().source,start:{offset:n,line:0,column:0},end:{offset:n+1,line:0,column:0}};zn(`Unexpected `+JSON.stringify(r)+` in the tag <`+t+`>: expected an attribute, or > to end the tag`,i,`unexpected-character`)}function Et(e,t){return nr(`html`,Gt(),{tag:t,lower:t.toLowerCase(),tagNameStart:e,tagNameEnd:e+t.length,attributes:{},attributeSpans:[],isClose:!0,isSelfClose:!1})}function Dt(e,t){return Pn=Mn.isCodeAttribute(t),!0}function Ot(e,t,n){return n}function kt(e,t,n){let r={name:t,value:n?n.value:``,nameStart:e,nameEnd:e+t.length};return n&&(r.valueStart=n.start,r.valueEnd=n.end,n.quote&&(r.quote=n.quote)),r}function At(e,t,n){return{value:t,start:e,end:n,quote:`\"`}}function jt(e,t,n){return{value:t,start:e,end:n,quote:`'`}}function Mt(e){zn(`Unclosed attribute value: the `+e+` here has no closing `+e,Gt(),`unclosed-attribute`)}function Nt(e,t,n){return{value:t,start:e,end:n}}function Pt(){return!Pn}function Ft(e){return e.length%2==1}function It(){return!Pn}function Lt(t,n){return Rn(Mn.closeBrace(e,n,t))}function Rt(e,t){return Nn-Wt()}function zt(){return!Pn}function Bt(){return Pn}let P=t.peg$currPos|0,F=P,I=[{line:1,column:1}],Vt=P,Ht=t.peg$maxFailExpected||[],L=t.peg$silentFails|0,Ut;if(t.startRule){if(!(t.startRule in i))throw Error(`Can't start parsing from rule \"`+t.startRule+`\".`);a=i[t.startRule]}function Wt(){return F}function Gt(){return $t(F,P)}function Kt(e,t){throw t=t===void 0?$t(F,P):t,en(e,t)}function qt(t=P){let n=e.codePointAt(t);return n===void 0?``:String.fromCodePoint(n)}function Jt(e,t){return{type:`literal`,text:e,ignoreCase:t}}function Yt(e,t,n,r){return{type:`class`,parts:e,inverted:t,ignoreCase:n,unicode:r}}function Xt(){return{type:`any`}}function Zt(){return{type:`end`}}function Qt(t){let n=I[t],r;if(n)return n;if(t>=I.length)r=I.length-1;else for(r=t;!I[--r];);for(n=I[r],n={line:n.line,column:n.column};r<t;)e.charCodeAt(r)===10?(n.line++,n.column=1):n.column++,r++;return I[t]=n,n}function $t(e,t,n){let i=Qt(e),a=Qt(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 R(e){P<Vt||(P>Vt&&(Vt=P,Ht=[]),Ht.push(e))}function en(e,t){return new ar(e,null,null,t)}function tn(e,t,n){return new ar(ar.buildMessage(e,t),e,t,n)}function nn(){let e,t,r;for(e=P,t=[],r=rn();r!==n;)t.push(r),r=rn();return F=e,t=Pe(t),e=t,e}function rn(){let e,t,r,i,a;return e=cn(),e===n&&(e=un(),e===n&&(e=ln(),e===n&&(e=fn(),e===n&&(e=Sn(),e===n&&(e=P,F=P,t=Fe(),t=t?void 0:n,t===n?(P=e,e=n):(r=Cn(),r===n?(P=e,e=n):(F=e,e=M(r))),e===n&&(e=P,F=P,t=Ie(),t=t?void 0:n,t===n?(P=e,e=n):(r=wn(),r===n?(P=e,e=n):(F=e,e=Le(r))),e===n&&(e=vn(),e===n&&(e=P,t=bn(),t===n?(P=e,e=n):(r=P,F=P,i=Re(t),i=i?void 0:n,i===n?(P=r,r=n):(a=on(),a===n?(P=r,r=n):(F=r,r=ze(t,a))),r===n&&(r=null),F=e,e=Be(t,r)),e===n&&(e=dn()))))))))),e}function an(){let e,t,r;return e=P,t=bn(),t===n?(P=e,e=n):(F=P,r=Ve(t),r=r?void 0:n,r===n?(P=e,e=n):(F=e,e=He(t))),e===n&&(e=P,F=P,t=Ue(),t=t?void 0:n,t===n?(P=e,e=n):(r=wn(),r===n?(P=e,e=n):(F=e,e=We(r)))),e}function on(){let t,r,i,a,o,s,c,l;if(t=P,r=sn(),F=P,i=Ge(r),i=i?void 0:n,i!==n){for(a=P,o=Ke(r),s=P,c=[],c.length>=(o|0)?l=n:e.length>P?(l=e.charAt(P),P++):(l=n,L===0&&R(D));l!==n;)c.push(l),c.length>=(o|0)?l=n:e.length>P?(l=e.charAt(P),P++):(l=n,L===0&&R(D));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=an(),o===n?(P=t,t=n):(F=t,t=qe(r,a,o)))}else P=t,t=n;return t}function sn(){let e,t;return e=P,t=``,F=e,t=Je(),e=t,e}function cn(){let t,r,i,a;if(t=P,r=P,i=[],a=e.charAt(P),s.test(a)?P++:(a=n,L===0&&R(ee)),a!==n)for(;a!==n;)i.push(a),a=e.charAt(P),s.test(a)?P++:(a=n,L===0&&R(ee));else i=n;return r=i===n?i:e.substring(r,P),r!==n&&(F=t,r=Ye(r)),t=r,t}function ln(){let t,r,i,a,s,c,l,u,d;if(t=P,r=P,i=P,e.substr(P,4)===o?(a=o,P+=4):(a=n,L===0&&R(O)),a!==n){if(e.charCodeAt(P)===62?(s=`>`,P++):(s=n,L===0&&R(te)),s===n&&(e.substr(P,2)===`->`?(s=`->`,P+=2):(s=n,L===0&&R(k)),s===n)){for(s=P,c=[],l=P,u=P,L++,e.substr(P,3)===`-->`?(d=`-->`,P+=3):(d=n,L===0&&R(ne)),L--,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,L===0&&R(D)),d===n?(P=l,l=n):(u=[u,d],l=u));l!==n;)c.push(l),l=P,u=P,L++,e.substr(P,3)===`-->`?(d=`-->`,P+=3):(d=n,L===0&&R(ne)),L--,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,L===0&&R(D)),d===n?(P=l,l=n):(u=[u,d],l=u));e.substr(P,3)===`-->`?(l=`-->`,P+=3):(l=n,L===0&&R(ne)),l===n?(P=s,s=n):(c=[c,l],s=c)}s===n?(P=i,i=n):(a=[a,s],i=a)}else P=i,i=n;return r=i===n?i:e.substring(r,P),r!==n&&(F=t,r=Xe(r)),t=r,t}function un(){let t,r,i,a,o;if(t=P,r=P,i=[],e.charCodeAt(P)===92?(a=`\\\\`,P++):(a=n,L===0&&R(re)),a!==n)for(;a!==n;)i.push(a),e.charCodeAt(P)===92?(a=`\\\\`,P++):(a=n,L===0&&R(re));else i=n;return r=i===n?i:e.substring(r,P),r===n?(P=t,t=n):(i=P,F=P,a=Ze(r),a=a?void 0:n,a===n?(P=i,i=n):(o=e.charAt(P),c.test(o)?P++:(o=n,L===0&&R(ie)),o===n?(P=i,i=n):(F=i,i=Qe(r,o))),i===n&&(i=null),F=t,t=$e(r,i)),t}function dn(){let t,r,i,a,o,s;return t=P,e.charCodeAt(P)===123?(r=`{`,P++):(r=n,L===0&&R(ae)),r===n?(P=t,t=n):(i=P,L++,a=P,o=mn(),o===n?(P=a,a=n):(s=e.charAt(P),l.test(s)?P++:(s=n,L===0&&R(oe)),s===n?(P=a,a=n):(o=[o,s],a=o)),L--,a===n?i=void 0:(P=i,i=n),i===n?(P=t,t=n):(F=t,t=et())),t===n&&(t=P,r=P,L++,i=P,F=P,a=tt(),a=a?void 0:n,a===n?(P=i,i=n):(o=wn(),o===n?(P=i,i=n):(a=[a,o],i=a)),L--,i===n?r=void 0:(P=r,r=n),r===n?(P=t,t=n):(e.charCodeAt(P)===60?(i=`<`,P++):(i=n,L===0&&R(se)),i===n?(P=t,t=n):(F=t,t=nt())),t===n&&(t=P,e.charCodeAt(P)===91?(r=`[`,P++):(r=n,L===0&&R(ce)),r!==n&&(F=t,r=rt()),t=r)),t}function fn(){let t,r,i,a,o,s,c,l;return t=P,F=P,r=it(),r=r?void 0:n,r===n?(P=t,t=n):(e.substr(P,2)===`[[`?(i=`[[`,P+=2):(i=n,L===0&&R(le)),i===n?(P=t,t=n):(a=sn(),o=mn(),o===n?(P=t,t=n):(s=sn(),c=P,l=pn(),c=e.substring(c,P),e.substr(P,2)===`]]`?(l=`]]`,P+=2):(l=n,L===0&&R(ue)),l===n?(P=t,t=n):(F=t,t=at(a,o,s,c))))),t===n&&(t=P,F=P,r=ot(),r=r?void 0:n,r===n?(P=t,t=n):(e.substr(P,2)===`[[`?(i=`[[`,P+=2):(i=n,L===0&&R(le)),i===n?(P=t,t=n):(F=t,t=st()))),t}function pn(){let t,r,i,a;for(t=[],r=P,i=P,L++,e.substr(P,2)===`]]`?(a=`]]`,P+=2):(a=n,L===0&&R(ue)),a===n&&(e.substr(P,2)===`[[`?(a=`[[`,P+=2):(a=n,L===0&&R(le))),L--,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,L===0&&R(D)),a===n?(P=r,r=n):(i=[i,a],r=i));r!==n;)t.push(r),r=P,i=P,L++,e.substr(P,2)===`]]`?(a=`]]`,P+=2):(a=n,L===0&&R(ue)),a===n&&(e.substr(P,2)===`[[`?(a=`[[`,P+=2):(a=n,L===0&&R(le))),L--,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,L===0&&R(D)),a===n?(P=r,r=n):(i=[i,a],r=i));return t}function mn(){let t,r,i;if(t=P,r=[],i=gn(),i!==n)for(;i!==n;)r.push(i),i=gn();else r=n;return r===n?(P=t,t=n):(e.charCodeAt(P)===32?(i=` `,P++):(i=n,L===0&&R(de)),i===n&&(i=null),F=t,t=ct(r)),t===n&&(t=P,r=``,F=t,r=lt(),t=r),t}function hn(){let t,r,i,a,o;if(t=P,r=mn(),r!==n){for(i=sn(),a=[],e.length>P?(o=e.charAt(P),P++):(o=n,L===0&&R(D));o!==n;)a.push(o),e.length>P?(o=e.charAt(P),P++):(o=n,L===0&&R(D));F=t,t=ut(r,i)}else P=t,t=n;return t}function gn(){let t,r,i,a,o;if(t=P,r=e.charAt(P),u.test(r)?P++:(r=n,L===0&&R(fe)),r!==n){for(i=P,a=[],o=_n();o!==n;)a.push(o),o=_n();i=e.substring(i,P),F=t,t=dt(r,i)}else P=t,t=n;return t}function _n(){let t,r,i,a,o;if(t=e.charAt(P),d.test(t)?P++:(t=n,L===0&&R(pe)),t===n){if(t=P,e.charCodeAt(P)===123?(r=`{`,P++):(r=n,L===0&&R(ae)),r!==n){if(i=e.charAt(P),f.test(i)?P++:(i=n,L===0&&R(me)),i!==n){for(a=[],o=e.charAt(P),p.test(o)?P++:(o=n,L===0&&R(he));o!==n;)a.push(o),o=e.charAt(P),p.test(o)?P++:(o=n,L===0&&R(he));e.charCodeAt(P)===125?(o=`}`,P++):(o=n,L===0&&R(A)),o===n?(P=t,t=n):(r=[r,i,a,o],t=r)}else P=t,t=n}else P=t,t=n}return t}function vn(){let t,r,i,a,o,s,c,l,u;if(t=P,e.charCodeAt(P)===123?(r=`{`,P++):(r=n,L===0&&R(ae)),r!==n){if(i=sn(),a=mn(),a!==n){if(o=e.charAt(P),f.test(o)?P++:(o=n,L===0&&R(me)),o!==n){for(s=sn(),c=P,l=[],u=e.charAt(P),p.test(u)?P++:(u=n,L===0&&R(he));u!==n;)l.push(u),u=e.charAt(P),p.test(u)?P++:(u=n,L===0&&R(he));c=e.substring(c,P),e.charCodeAt(P)===125?(l=`}`,P++):(l=n,L===0&&R(A)),l===n?(P=t,t=n):(F=t,t=ft(i,a,o,s,c))}else P=t,t=n}else P=t,t=n}else P=t,t=n;return t===n&&(t=P,e.charCodeAt(P)===123?(r=`{`,P++):(r=n,L===0&&R(ae)),r===n?(P=t,t=n):(i=sn(),a=mn(),a===n?(P=t,t=n):(o=sn(),s=P,L++,c=e.charAt(P),m.test(c)?P++:(c=n,L===0&&R(ge)),L--,c===n?s=n:(P=s,s=void 0),s===n?(P=t,t=n):(c=yn(),c===n?(P=t,t=n):(e.charCodeAt(P)===125?(l=`}`,P++):(l=n,L===0&&R(A)),l===n?(P=t,t=n):(F=t,t=pt(i,a,o,c)))))),t===n&&(t=P,e.charCodeAt(P)===123?(r=`{`,P++):(r=n,L===0&&R(ae)),r===n?(P=t,t=n):(i=mn(),i===n?(P=t,t=n):(a=P,L++,o=e.charAt(P),m.test(o)?P++:(o=n,L===0&&R(ge)),L--,o===n?a=n:(P=a,a=void 0),a===n?(P=t,t=n):(F=t,t=N()))))),t}function yn(){let t,r,i,a,o,s,c,l;if(t=P,r=sn(),F=P,i=mt(r),i=i?void 0:n,i!==n){for(a=P,o=ht(r),s=P,c=[],c.length>=(o|0)?l=n:e.length>P?(l=e.charAt(P),P++):(l=n,L===0&&R(D));l!==n;)c.push(l),c.length>=(o|0)?l=n:e.length>P?(l=e.charAt(P),P++):(l=n,L===0&&R(D));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=gt(r,a))}else P=t,t=n;return t}function bn(){let t,r,i,a,o,s,c,l,u,d,f,p,m,h,g;if(t=P,e.charCodeAt(P)===123?(r=`{`,P++):(r=n,L===0&&R(ae)),r!==n){if(i=sn(),a=mn(),a!==n){if(o=sn(),e.charCodeAt(P)===47?(s=`/`,P++):(s=n,L===0&&R(_e)),s===n&&(s=null),c=xn(),c!==n){if(l=sn(),u=P,F=P,d=_t(i,a,o,s,c,l),d=d?void 0:n,d!==n){for(f=P,p=vt(i,a,o,s,c,l),m=P,h=[],h.length>=(p|0)?g=n:e.length>P?(g=e.charAt(P),P++):(g=n,L===0&&R(D));g!==n;)h.push(g),h.length>=(p|0)?g=n:e.length>P?(g=e.charAt(P),P++):(g=n,L===0&&R(D));h.length<(p|0)?(P=m,m=n):m=h,p=m,f=p===n?p:e.substring(f,P),f===n?(P=u,u=n):(e.charCodeAt(P)===125?(p=`}`,P++):(p=n,L===0&&R(A)),p===n?(P=u,u=n):(F=u,u=yt(i,a,o,s,c,l,f)))}else P=u,u=n;u===n&&(u=null),F=t,t=bt(i,a,o,s,c,l,u)}else P=t,t=n}else P=t,t=n}else P=t,t=n;return t===n&&(t=P,e.charCodeAt(P)===123?(r=`{`,P++):(r=n,L===0&&R(ae)),r===n?(P=t,t=n):(i=mn(),i===n?(P=t,t=n):(e.charCodeAt(P)===47?(a=`/`,P++):(a=n,L===0&&R(_e)),a===n?(P=t,t=n):(F=t,t=xt(i))))),t}function xn(){let t,r,i,a,o;if(t=P,r=P,i=e.charAt(P),h.test(i)?P++:(i=n,L===0&&R(ve)),i!==n){for(a=[],o=e.charAt(P),g.test(o)?P++:(o=n,L===0&&R(ye));o!==n;)a.push(o),o=e.charAt(P),g.test(o)?P++:(o=n,L===0&&R(ye));i=[i,a],r=i}else P=r,r=n;return t=r===n?r:e.substring(t,P),t}function Sn(){let t,r,i,a,o,s,c,l;if(t=P,r=P,i=P,e.charCodeAt(P)===60?(a=`<`,P++):(a=n,L===0&&R(se)),a!==n){if(o=[],s=e.charAt(P),_.test(s)?P++:(s=n,L===0&&R(be)),s!==n)for(;s!==n;)o.push(s),s=e.charAt(P),_.test(s)?P++:(s=n,L===0&&R(be));else o=n;if(o!==n){if(e.charCodeAt(P)===64?(s=`@`,P++):(s=n,L===0&&R(xe)),s!==n){if(c=[],l=e.charAt(P),v.test(l)?P++:(l=n,L===0&&R(Se)),l!==n)for(;l!==n;)c.push(l),l=e.charAt(P),v.test(l)?P++:(l=n,L===0&&R(Se));else c=n;c===n?(P=i,i=n):(e.charCodeAt(P)===62?(l=`>`,P++):(l=n,L===0&&R(te)),l===n?(P=i,i=n):(a=[a,o,s,c,l],i=a))}else P=i,i=n}else P=i,i=n}else P=i,i=n;return r=i===n?i:e.substring(r,P),r===n?(P=t,t=n):(F=P,i=St(r),i=i?void 0:n,i===n?(P=t,t=n):(F=t,t=Ct(r))),t}function Cn(){let t,r,i,a,o,s,c,l;if(t=P,e.charCodeAt(P)===60?(r=`<`,P++):(r=n,L===0&&R(se)),r!==n){if(i=sn(),a=Tn(),a!==n){for(o=[],s=En();s!==n;)o.push(s),s=En();s=kn(),e.charCodeAt(P)===47?(c=`/`,P++):(c=n,L===0&&R(_e)),c===n&&(c=null),e.charCodeAt(P)===62?(l=`>`,P++):(l=n,L===0&&R(te)),l===n?(P=t,t=n):(F=t,t=wt(i,a,o,c))}else P=t,t=n}else P=t,t=n;if(t===n){if(t=P,e.charCodeAt(P)===60?(r=`<`,P++):(r=n,L===0&&R(se)),r!==n){if(i=Tn(),i!==n){if(a=P,L++,o=e.charAt(P),y.test(o)?P++:(o=n,L===0&&R(Ce)),o===n&&(o=P,L++,e.length>P?(s=e.charAt(P),P++):(s=n,L===0&&R(D)),L--,s===n?o=void 0:(P=o,o=n)),L--,o===n?a=n:(P=a,a=void 0),a!==n){for(o=[],s=En();s!==n;)o.push(s),s=En();s=kn(),c=sn(),F=t,t=Tt(i,c)}else P=t,t=n}else P=t,t=n}else P=t,t=n}return t}function wn(){let t,r,i,a,o;return t=P,e.substr(P,2)===`</`?(r=`</`,P+=2):(r=n,L===0&&R(we)),r===n?(P=t,t=n):(i=sn(),a=Tn(),a===n?(P=t,t=n):(kn(),e.charCodeAt(P)===62?(o=`>`,P++):(o=n,L===0&&R(te)),o===n?(P=t,t=n):(F=t,t=Et(i,a)))),t}function Tn(){let t,r,i,a,o;if(t=P,r=P,i=e.charAt(P),h.test(i)?P++:(i=n,L===0&&R(ve)),i!==n){for(a=[],o=e.charAt(P),b.test(o)?P++:(o=n,L===0&&R(Te));o!==n;)a.push(o),o=e.charAt(P),b.test(o)?P++:(o=n,L===0&&R(Te));i=[i,a],r=i}else P=r,r=n;return t=r===n?r:e.substring(t,P),t}function En(){let t,r,i,a,o,s,c,l;if(t=P,kn(),r=sn(),i=P,a=[],o=P,s=P,L++,c=e.charAt(P),x.test(c)?P++:(c=n,L===0&&R(Ee)),L--,c===n?s=void 0:(P=s,s=n),s===n?(P=o,o=n):(e.length>P?(c=e.charAt(P),P++):(c=n,L===0&&R(D)),c===n?(P=o,o=n):(s=[s,c],o=s)),o!==n)for(;o!==n;)a.push(o),o=P,s=P,L++,c=e.charAt(P),x.test(c)?P++:(c=n,L===0&&R(Ee)),L--,c===n?s=void 0:(P=s,s=n),s===n?(P=o,o=n):(e.length>P?(c=e.charAt(P),P++):(c=n,L===0&&R(D)),c===n?(P=o,o=n):(s=[s,c],o=s));else a=n;return i=a===n?a:e.substring(i,P),i===n?(P=t,t=n):(F=P,a=Dt(r,i),a=a?void 0:n,a===n?(P=t,t=n):(o=P,s=kn(),e.charCodeAt(P)===61?(c=`=`,P++):(c=n,L===0&&R(De)),c===n?(P=o,o=n):(kn(),l=Dn(),l===n?(P=o,o=n):(F=o,o=Ot(r,i,l))),o===n&&(o=null),F=t,t=kt(r,i,o))),t}function Dn(){let t,r,i,a,o,s;if(t=P,e.charCodeAt(P)===34?(r=`\"`,P++):(r=n,L===0&&R(Oe)),r!==n){for(i=sn(),a=P,o=[],s=On(),s===n&&(s=e.charAt(P),S.test(s)?P++:(s=n,L===0&&R(ke)));s!==n;)o.push(s),s=On(),s===n&&(s=e.charAt(P),S.test(s)?P++:(s=n,L===0&&R(ke)));a=e.substring(a,P),o=sn(),e.charCodeAt(P)===34?(s=`\"`,P++):(s=n,L===0&&R(Oe)),s===n?(P=t,t=n):(F=t,t=At(i,a,o))}else P=t,t=n;if(t===n){if(t=P,e.charCodeAt(P)===39?(r=`'`,P++):(r=n,L===0&&R(Ae)),r!==n){for(i=sn(),a=P,o=[],s=On(),s===n&&(s=e.charAt(P),C.test(s)?P++:(s=n,L===0&&R(je)));s!==n;)o.push(s),s=On(),s===n&&(s=e.charAt(P),C.test(s)?P++:(s=n,L===0&&R(je)));a=e.substring(a,P),o=sn(),e.charCodeAt(P)===39?(s=`'`,P++):(s=n,L===0&&R(Ae)),s===n?(P=t,t=n):(F=t,t=jt(i,a,o))}else P=t,t=n;if(t===n&&(t=P,r=e.charAt(P),w.test(r)?P++:(r=n,L===0&&R(Me)),r!==n&&(F=t,r=Mt(r)),t=r,t===n)){for(t=P,r=sn(),i=P,a=[],o=e.charAt(P),T.test(o)?P++:(o=n,L===0&&R(Ne));o!==n;)a.push(o),o=e.charAt(P),T.test(o)?P++:(o=n,L===0&&R(Ne));i=e.substring(i,P),a=sn(),F=t,t=Nt(r,i,a)}}return t}function On(){let t,r,i,a,o,s,l,u,d,p,m,g,_,v;if(t=P,F=P,r=Pt(),r=r?void 0:n,r!==n){if(i=P,a=[],e.charCodeAt(P)===92?(o=`\\\\`,P++):(o=n,L===0&&R(re)),o!==n)for(;o!==n;)a.push(o),e.charCodeAt(P)===92?(o=`\\\\`,P++):(o=n,L===0&&R(re));else a=n;i=a===n?a:e.substring(i,P),i===n?(P=t,t=n):(a=P,F=P,o=Ft(i),o=o?void 0:n,o===n?(P=a,a=n):(s=e.charAt(P),c.test(s)?P++:(s=n,L===0&&R(ie)),s===n?(P=a,a=n):(o=[o,s],a=o)),a===n&&(a=null),r=[r,i,a],t=r)}else P=t,t=n;if(t===n){if(t=P,F=P,r=It(),r=r?void 0:n,r!==n){if(e.charCodeAt(P)===123?(i=`{`,P++):(i=n,L===0&&R(ae)),i!==n){if(a=mn(),a!==n){if(o=sn(),e.charCodeAt(P)===47?(s=`/`,P++):(s=n,L===0&&R(_e)),s===n&&(s=null),l=xn(),l!==n){if(u=sn(),F=P,d=Lt(o,u),d=d?void 0:n,d!==n){for(p=P,m=Rt(o,u),g=P,_=[],_.length>=(m|0)?v=n:e.length>P?(v=e.charAt(P),P++):(v=n,L===0&&R(D));v!==n;)_.push(v),_.length>=(m|0)?v=n:e.length>P?(v=e.charAt(P),P++):(v=n,L===0&&R(D));_.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,L===0&&R(A)),m===n?(P=t,t=n):(r=[r,i,a,o,s,l,u,d,p,m],t=r))}else P=t,t=n}else P=t,t=n}else P=t,t=n}else P=t,t=n}else P=t,t=n;t===n&&(t=P,F=P,r=zt(),r=r?void 0:n,r===n?(P=t,t=n):(e.charCodeAt(P)===123?(i=`{`,P++):(i=n,L===0&&R(ae)),i===n?(P=t,t=n):(a=mn(),a===n?(P=t,t=n):(o=P,L++,s=P,e.charCodeAt(P)===47?(l=`/`,P++):(l=n,L===0&&R(_e)),l===n&&(l=null),u=e.charAt(P),h.test(u)?P++:(u=n,L===0&&R(ve)),u===n?(P=s,s=n):(l=[l,u],s=l),L--,s===n?o=void 0:(P=o,o=n),o===n?(P=t,t=n):(s=yn(),s===n?(P=t,t=n):(e.charCodeAt(P)===125?(l=`}`,P++):(l=n,L===0&&R(A)),l===n?(P=t,t=n):(r=[r,i,a,o,s,l],t=r)))))),t===n&&(t=P,F=P,r=Bt(),r=r?void 0:n,r===n?(P=t,t=n):(e.charCodeAt(P)===123?(i=`{`,P++):(i=n,L===0&&R(ae)),i===n?(P=t,t=n):(a=P,L++,o=e.charAt(P),f.test(o)?P++:(o=n,L===0&&R(me)),L--,o===n?a=n:(P=a,a=void 0),a===n?(P=t,t=n):(o=yn(),o===n?(P=t,t=n):(e.charCodeAt(P)===125?(s=`}`,P++):(s=n,L===0&&R(A)),s===n?(P=t,t=n):(r=[r,i,a,o,s],t=r)))))))}return t}function kn(){let e,t;for(e=[],t=An();t!==n;)e.push(t),t=An();return e}function An(){let t;return t=e.charAt(P),E.test(t)?P++:(t=n,L===0&&R(j)),t}let jn=t.text===!0,Mn=t.hooks,Nn=-1,Pn=!1,Fn=``;function In(t,n,r){for(let i=0;i<t.length;i++){let a=t.charAt(i);if(a===`\\\\`&&/[{}]/.test(t.charAt(i+1)))i++;else if(a===Wn){let r=/^(?:[.#][\\w-]*)* ?(\\/?[a-zA-Z][\\w-]*|(?=[$_@%(!]))/.exec(t.slice(i+1));if(!r)continue;let a=Mn.closeBrace(e,n+i+1+r[0].length,n+i+1);a!==-1&&a<n+t.length&&(i=a-n)}else if(t.startsWith(r,i))return i}return-1}function Ln(t,n,r){return t===Zn?{}:{selectorsStart:n,selectorsEnd:e.charAt(r-1)===` `?r-1:r}}function Rn(e){return Nn=e,e>=0}function zn(e,t,n){try{Kt(e,t)}catch(e){throw e.code=n,e}}function Bn(e){let t={},n=new Set;for(let{name:r,value:i}of e){let e=r.toLowerCase();n.has(e)||(n.add(e),Object.defineProperty(t,r,{value:i,enumerable:!0,writable:!0,configurable:!0}))}return t}Ut=a();let Vn=Ut!==n&&P===e.length;function Hn(){throw Ut!==n&&P<e.length&&R(Zt()),tn(Ht,Vt<e.length?qt(Vt):null,Vt<e.length?$t(Vt,Vt+1):$t(Vt,Vt))}if(t.peg$library)return{peg$result:Ut,peg$currPos:P,peg$FAILED:n,peg$maxFailExpected:Ht,peg$maxFailPos:Vt,peg$success:Vn,peg$throw:Vn?void 0:Hn};if(Vn)return Ut;Hn()}var sr=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())}},cr=class{constructor(e=[]){this.names=new sr;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)}},lr=new cr([`if`,`for`,`do`,`button`,`link`,`listbox`,`cycle`,`switch`,`timed`,`repeat`,`type`,`widget`,`span`,`nobr`]),ur=new Set([`do`]);function dr(e){return ur.has(e)}function fr(e){return lr.has(e)}function pr(e){lr.add(e)}var mr=new Set([`if`,`switch`,`timed`]),hr=e=>`\"${e.replace(/[\\\\\"]/g,`\\\\$&`)}\"`;function gr(e){return e.map(_r)}function _r({token:e,body:t}){switch(e.type){case`text`:return e.comment?{type:`text`,value:e.value,comment:!0}:{type:`text`,value:e.value};case`link`:return Hn({type:`macro`,name:`link`,rawArgs:`${hr(e.display)} ${hr(e.target)}`,children:[]},e);case`variable`:return Hn({type:`variable`,name:e.name,scope:e.scope},e);case`expression`:return Hn({type:`expression`,expression:e.expression},e);case`html`:return{type:`html`,tag:e.tag,attributes:e.attributes,children:t?gr(t.children):[]};case`macro`:{let n=e.name.toLowerCase(),r={type:`macro`,name:n,rawArgs:e.rawArgs,children:[]};if(!t)return Hn(r,e);let i=gr(t.children);if(!mr.has(n))return r.children=i,Hn(r,e);let a=(e,t)=>Hn({rawArgs:e.rawArgs,children:t},e);return r.branches=[a(e,i),...t.branches.map(({tag:e,children:t})=>a(e,gr(t)))],r}}}function vr(e,t){let n=1,r=0;for(let i=e.indexOf(`\n`);i!==-1&&i<t;)n++,r=i+1,i=e.indexOf(`\n`,r);return{line:n,column:t-r+1}}var yr=e=>e[e.length-1],br={elseif:`if`,else:`if`,case:`switch`,default:`switch`,next:`timed`},xr=e=>e.type===`macro`&&!e.isClose&&Object.prototype.hasOwnProperty.call(br,e.name.toLowerCase()),Sr=e=>Cr(e).toLowerCase(),Cr=e=>e.type===`macro`?e.name:e.tag;function wr(e){return e.type===`html`?`${e.isClose?`</`:`<`}${e.tag}>`:`{${e.isClose?`/`:``}${e.name}}`}var Tr=e=>e.type===`html`?`</${e.tag}>`:`{/${e.name}}`,Er=(e,t)=>e.type===t.type&&Sr(e)===Sr(t);function Dr(e,t={}){let n=t.isBlock??fr,r=t.isRaw??dr,i=[],a=(e[e.length-1]?.end??0)+1,o=e=>{if(t.source===void 0)return`offset ${e}`;let{line:n,column:r}=vr(t.source,e);return`line ${n}, column ${r}`},s=(e,t,n,r,a)=>{i.push({code:e,message:n,start:t.start,end:t.end,noticedAt:r,data:a})},c=(e,t,n)=>{let r=br[e.name.toLowerCase()],i=t?`, not inside ${wr(t)}`:``;s(`misplaced-branch`,e,`${wr(e)} must be directly inside {${r}}${i}`,n,{name:e.name,parent:r,...t&&{inside:Cr(t)}})},l=[],u=[],d=e=>(yr(u)?.into??l).push(e),f=(e,t,n=e===`closed`)=>{let{node:r,body:i}=u.pop(),l=r.token,f=t?t.end:a;for(let{tag:e}of i.branches){let t=br[e.name.toLowerCase()];(l.type!==`macro`||Sr(l)!==t)&&c(e,l,f)}e===`unclosed`?s(`unclosed-block`,l,`Unclosed ${wr(l)}: no ${Tr(l)} closes it`,f,{name:Cr(l)}):e===`mismatch`&&s(`mismatched-closer`,t,`${wr(t)} found where ${Tr(l)} should close the ${wr(l)} opened at ${o(l.start)}`,f,{name:Cr(l),closer:Cr(t)}),n&&(i.close=t),r.end=i.close?.end??kr(i)??l.end,d(r)};for(let t=0;t<e.length;t++){let i=e[t];if((i.type===`macro`||i.type===`html`)&&i.isClose){let e=yr(u);if(!e)s(`stray-closer`,i,`${wr(i)} closes nothing: no ${i.type===`html`?`<${i.tag}>`:`{${i.name}}`} is open here`,i.start,{name:Cr(i)});else if(Er(e.node.token,i))f(`closed`,i);else{let e=u.length-1;for(;e>=0&&!Er(u[e].node.token,i);)e--;if(f(`mismatch`,i,e===-1),e!==-1){for(;u.length>e+1;)f(`cut`,i);f(`closed`,i)}}continue}if(xr(i)){let e=i,t=yr(u);if(!t){c(e,void 0,e.start);continue}let n={tag:e,children:[]};t.body.branches.push(n),t.into=n.children;continue}let a={token:i,start:i.start,end:i.end},o=i.type===`html`?!i.isSelfClose:i.type===`macro`&&n(i.name.toLowerCase());if(o&&i.type===`macro`&&r(i.name.toLowerCase())&&!Or(i,e[t+1],e[t+2])){s(`unclosed-block`,i,`Unclosed ${wr(i)}: no ${Tr(i)} closes it`,i.end,{name:Cr(i)}),d(a);continue}if(!o){d(a);continue}let l={children:[],branches:[]};a.body=l,u.push({node:a,body:l,into:l.children})}for(;u.length>0;)f(`unclosed`);return{nodes:l,errors:i}}function Or(e,t,n){let r=t=>t?.type===`macro`&&t.isClose&&Er(e,t);return r(t)||t?.type===`text`&&r(n)}function kr(e){let t=yr(e.branches);return yr(t?.children??e.children)?.end??t?.tag.end}var Ar=[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],jr=[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],Mr=`‌‍·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄ-׉ؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߽߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛ࢗ-࢟࣊-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯৾ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍୓-ୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఄ఼ా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ೳഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ඁ-ඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ຼ່-໎໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜕ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠏-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᪿ-᫰ᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭᳴᳷-᳹᷀-᷿‌‍‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯・꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧ꠬ꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱ꣿ-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_・`,Nr=`ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆ՘ՙՠ-ֈ֋֌א-תׯ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࡰ-ࢇࢉ-࢏ࢠ-ࣉऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚ౜ౝౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽ೜-ೞೠೡೱೲഄ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄຆ-ຊຌ-ຣລວ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜑᜟ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡸᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭌᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-ᲊᲐ-ᲺᲽ-Ჿᳩ-ᳬᳮ-ᳳᳵᳶᳺᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿ₏-₟ℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆿㇰ-ㇿ㐀-䶿一-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-꟝꟢꟱-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꣾꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭩ꭬꭭ꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ`,Pr={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`},Fr=`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`,Ir={5:Fr,\"5module\":Fr+` export import`,6:Fr+` const class extends export import super`},Lr=/^in(stanceof)?$/,Rr=RegExp(`[`+Nr+`]`),zr=RegExp(`[`+Nr+Mr+`]`);function Br(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 Vr(e,t){return e<65?e===36:e<91?!0:e<97?e===95:e<123?!0:e<=65535?e>=170&&Rr.test(String.fromCharCode(e)):t!==!1&&Br(e,jr)}function Hr(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&&zr.test(String.fromCharCode(e)):t===!1?!1:Br(e,jr)||Br(e,Ar)}var z=function(e,t){t===void 0&&(t={}),this.label=e,this.keyword=t.keyword,this.beforeExpr=!!t.beforeExpr,this.startsExpr=!!t.startsExpr,this.isLoop=!!t.isLoop,this.isAssign=!!t.isAssign,this.prefix=!!t.prefix,this.postfix=!!t.postfix,this.binop=t.binop||null,this.updateContext=null};function Ur(e,t){return new z(e,{beforeExpr:!0,binop:t})}var Wr={beforeExpr:!0},Gr={startsExpr:!0},Kr={};function B(e,t){return t===void 0&&(t={}),t.keyword=e,Kr[e]=new z(e,t)}var V={num:new z(`num`,Gr),regexp:new z(`regexp`,Gr),string:new z(`string`,Gr),name:new z(`name`,Gr),privateId:new z(`privateId`,Gr),eof:new z(`eof`),bracketL:new z(`[`,{beforeExpr:!0,startsExpr:!0}),bracketR:new z(`]`),braceL:new z(`{`,{beforeExpr:!0,startsExpr:!0}),braceR:new z(`}`),parenL:new z(`(`,{beforeExpr:!0,startsExpr:!0}),parenR:new z(`)`),comma:new z(`,`,Wr),semi:new z(`;`,Wr),colon:new z(`:`,Wr),dot:new z(`.`),question:new z(`?`,Wr),questionDot:new z(`?.`),arrow:new z(`=>`,Wr),template:new z(`template`),invalidTemplate:new z(`invalidTemplate`),ellipsis:new z(`...`,Wr),backQuote:new z(\"`\",Gr),dollarBraceL:new z(\"${\",{beforeExpr:!0,startsExpr:!0}),eq:new z(`=`,{beforeExpr:!0,isAssign:!0}),assign:new z(`_=`,{beforeExpr:!0,isAssign:!0}),incDec:new z(`++/--`,{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new z(`!/~`,{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:Ur(`||`,1),logicalAND:Ur(`&&`,2),bitwiseOR:Ur(`|`,3),bitwiseXOR:Ur(`^`,4),bitwiseAND:Ur(`&`,5),equality:Ur(`==/!=/===/!==`,6),relational:Ur(`</>/<=/>=`,7),bitShift:Ur(`<</>>/>>>`,8),plusMin:new z(`+/-`,{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:Ur(`%`,10),star:Ur(`*`,10),slash:Ur(`/`,10),starstar:new z(`**`,{beforeExpr:!0}),coalesce:Ur(`??`,1),_break:B(`break`),_case:B(`case`,Wr),_catch:B(`catch`),_continue:B(`continue`),_debugger:B(`debugger`),_default:B(`default`,Wr),_do:B(`do`,{isLoop:!0,beforeExpr:!0}),_else:B(`else`,Wr),_finally:B(`finally`),_for:B(`for`,{isLoop:!0}),_function:B(`function`,Gr),_if:B(`if`),_return:B(`return`,Wr),_switch:B(`switch`),_throw:B(`throw`,Wr),_try:B(`try`),_var:B(`var`),_const:B(`const`),_while:B(`while`,{isLoop:!0}),_with:B(`with`),_new:B(`new`,{beforeExpr:!0,startsExpr:!0}),_this:B(`this`,Gr),_super:B(`super`,Gr),_class:B(`class`,Gr),_extends:B(`extends`,Wr),_export:B(`export`),_import:B(`import`,Gr),_null:B(`null`,Gr),_true:B(`true`,Gr),_false:B(`false`,Gr),_in:B(`in`,{beforeExpr:!0,binop:7}),_instanceof:B(`instanceof`,{beforeExpr:!0,binop:7}),_typeof:B(`typeof`,{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:B(`void`,{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:B(`delete`,{beforeExpr:!0,prefix:!0,startsExpr:!0})},qr=/\\r\\n?|\\n|\\u2028|\\u2029/,Jr=new RegExp(qr.source,`g`);function Yr(e){return e===10||e===13||e===8232||e===8233}function Xr(e,t,n){n===void 0&&(n=e.length);for(var r=t;r<n;r++){var i=e.charCodeAt(r);if(Yr(i))return r<n-1&&i===13&&e.charCodeAt(r+1)===10?r+2:r+1}return-1}var Zr=/[\\u1680\\u2000-\\u200a\\u202f\\u205f\\u3000\\ufeff]/,Qr=/(?:\\s|\\/\\/.*|\\/\\*[^]*?\\*\\/)*/g,$r=Object.prototype,ei=$r.hasOwnProperty,ti=$r.toString,ni=Object.hasOwn||(function(e,t){return ei.call(e,t)}),ri=Array.isArray||(function(e){return ti.call(e)===`[object Array]`}),ii=Object.create(null);function ai(e){return ii[e]||(ii[e]=RegExp(`^(?:`+e.replace(/ /g,`|`)+`)$`))}function oi(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}var si=/(?:[\\uD800-\\uDBFF](?![\\uDC00-\\uDFFF])|(?:[^\\uD800-\\uDBFF]|^)[\\uDC00-\\uDFFF])/,ci=function(e,t){this.line=e,this.column=t};ci.prototype.offset=function(e){return new ci(this.line,this.column+e)};var li=function(e,t,n){this.start=t,this.end=n,e.sourceFile!==null&&(this.source=e.sourceFile)};function ui(e,t){for(var n=1,r=0;;){var i=Xr(e,r,t);if(i<0)return new ci(n,t-r);++n,r=i}}var di={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},fi=!1;function pi(e){var t={};for(var n in di)t[n]=e&&ni(e,n)?e[n]:di[n];if(t.ecmaVersion===`latest`?t.ecmaVersion=1e8:t.ecmaVersion==null?(!fi&&typeof console==`object`&&console.warn&&(fi=!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),ri(t.onToken)){var r=t.onToken;t.onToken=function(e){return r.push(e)}}if(ri(t.onComment)&&(t.onComment=mi(t,t.onComment)),t.sourceType===`commonjs`&&t.allowAwaitOutsideFunction)throw Error(`Cannot use allowAwaitOutsideFunction with sourceType: commonjs`);return t}function mi(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 li(this,o,s)),e.ranges&&(c.range=[i,a]),t.push(c)}}var hi=1,gi=2,_i=4,vi=8,yi=16,bi=32,xi=64,Si=128,Ci=256,wi=512,Ti=1024,Ei=hi|gi|Ci;function Di(e,t){return gi|(e?_i:0)|(t?vi:0)}var Oi=0,ki=1,Ai=2,ji=3,Mi=4,Ni=5,Pi=function(e,t,n){this.options=e=pi(e),this.sourceFile=e.sourceFile,this.keywords=ai(Ir[e.ecmaVersion>=6?6:e.sourceType===`module`?`5module`:5]);var r=``;e.allowReserved!==!0&&(r=Pr[e.ecmaVersion>=6?6:e.ecmaVersion===5?5:3],e.sourceType===`module`&&(r+=` await`)),this.reservedWords=ai(r);var i=(r?r+` `:``)+Pr.strict;this.reservedWordsStrict=ai(i),this.reservedWordsStrictBind=ai(i+` `+Pr.strictBind),this.input=String(t),this.containsEsc=!1,this.pos=n||0,this.curLine=1,e.startLocation?(this.lineStart=this.pos-e.startLocation.column,this.curLine=e.startLocation.line):n?(this.lineStart=this.input.lastIndexOf(`\n`,n-1)+1,this.options.locations&&(this.curLine=this.input.slice(0,this.lineStart).split(qr).length)):this.lineStart=0,this.type=V.eof,this.value=null,this.start=this.end=this.pos,this.startLoc=this.endLoc=this.curPosition(),this.lastTokEndLoc=this.lastTokStartLoc=null,this.lastTokStart=this.lastTokEnd=this.pos,this.context=this.initialContext(),this.exprAllowed=!0,this.inModule=e.sourceType===`module`,this.strict=this.inModule||e.strict===!0||this.strictDirective(this.pos),this.potentialArrowAt=-1,this.potentialArrowInForAwait=!1,this.yieldPos=this.awaitPos=this.awaitIdentPos=0,this.labels=[],this.undefinedExports=Object.create(null),this.pos===0&&e.allowHashBang&&this.input.slice(0,2)===`#!`&&this.skipLineComment(2),this.scopeStack=[],this.enterScope(this.options.sourceType===`commonjs`?gi:hi),this.regexpState=null,this.privateNameStack=[]},Fi={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}};Pi.prototype.parse=function(){var e=this,t=this.options.program||this.startNode();return this.nextToken(),this.catchStackOverflow(function(){return e.parseTopLevel(t)})},Fi.inFunction.get=function(){return(this.currentVarScope().flags&gi)>0},Fi.inGenerator.get=function(){return(this.currentVarScope().flags&vi)>0},Fi.inAsync.get=function(){return(this.currentVarScope().flags&_i)>0},Fi.canAwait.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e].flags;if(t&(Ci|wi))return!1;if(t&gi)return(t&_i)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction},Fi.allowReturn.get=function(){return!!(this.inFunction||this.options.allowReturnOutsideFunction&&this.currentVarScope().flags&hi)},Fi.allowSuper.get=function(){return(this.currentThisScope().flags&xi)>0||this.options.allowSuperOutsideMethod},Fi.allowDirectSuper.get=function(){return(this.currentThisScope().flags&Si)>0},Fi.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())},Fi.allowNewDotTarget.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e].flags;if(t&(Ci|wi)||t&gi&&!(t&yi))return!0}return!1},Fi.allowUsing.get=function(){var e=this.currentScope().flags;return!(e&Ti||!this.inModule&&e&hi)},Fi.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&Ci)>0},Pi.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},Pi.parse=function(e,t){return new this(t,e).parse()},Pi.parseExpressionAt=function(e,t,n){var r=new this(n,e,t);return r.nextToken(),r.parseExpression()},Pi.tokenizer=function(e,t){return new this(t,e)},Object.defineProperties(Pi.prototype,Fi);var Ii=Pi.prototype,Li=/^(?:'((?:\\\\[^]|[^'\\\\])*?)'|\"((?:\\\\[^]|[^\"\\\\])*?)\")/;Ii.strictDirective=function(e){if(this.options.ecmaVersion<5)return!1;for(;;){Qr.lastIndex=e,e+=Qr.exec(this.input)[0].length;var t=Li.exec(this.input.slice(e));if(!t)return!1;if((t[1]||t[2])===`use strict`){Qr.lastIndex=e+t[0].length;var n=Qr.exec(this.input),r=n.index+n[0].length,i=this.input.charAt(r);return i===`;`||i===`}`||qr.test(n[0])&&!(/[(`.[+\\-/*%<>=,?^&]/.test(i)||i===`!`&&this.input.charAt(r+1)===`=`||i===`i`&&Ri(this,r))}e+=t[0].length,Qr.lastIndex=e,e+=Qr.exec(this.input)[0].length,this.input[e]===`;`&&e++}};function Ri(e,t){for(var n=t+1,r=Math.min(e.input.length,t+11);n<r;){var i=e.fullCharCodeAt(n);if(!Hr(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`}Ii.eat=function(e){return this.type===e&&(this.next(),!0)},Ii.isContextual=function(e){return this.type===V.name&&this.value===e&&!this.containsEsc},Ii.eatContextual=function(e){return this.isContextual(e)?(this.next(),!0):!1},Ii.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}},Ii.expectContextual=function(e){this.eatContextual(e)||this.unexpected()},Ii.canInsertSemicolon=function(){return this.type===V.eof||this.type===V.braceR||qr.test(this.input.slice(this.lastTokEnd,this.start))},Ii.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0},Ii.semicolon=function(){!this.eat(V.semi)&&!this.insertSemicolon()&&this.unexpected()},Ii.afterTrailingComma=function(e,t){if(this.type===e)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),t||this.next(),!0},Ii.expect=function(e){this.eat(e)||this.unexpected()},Ii.unexpected=function(e){this.raise(e??this.start,`Unexpected token`)};var zi=function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};Ii.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`)}},Ii.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`)},Ii.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`)},Ii.isSimpleAssignTarget=function(e){return e.type===`ParenthesizedExpression`?this.isSimpleAssignTarget(e.expression):e.type===`Identifier`||e.type===`MemberExpression`};var H=Pi.prototype;H.parseTopLevel=function(e){var t=Object.create(null);for(e.body||(e.body=[]);this.type!==V.eof;){var n=this.parseStatement(null,!0,t);e.body.push(n)}if(this.inModule)for(var r=0,i=Object.keys(this.undefinedExports);r<i.length;r+=1){var a=i[r];this.raiseRecoverable(this.undefinedExports[a].start,`Export '`+a+`' is not defined`)}return this.adaptDirectivePrologue(e.body),this.next(),e.sourceType=this.options.sourceType===`commonjs`?`script`:this.options.sourceType,this.finishNode(e,`Program`)};var Bi={kind:`loop`},Vi={kind:`switch`};H.isLet=function(e){if(this.options.ecmaVersion<6||!this.isContextual(`let`))return!1;Qr.lastIndex=this.pos;var t=Qr.exec(this.input),n=this.pos+t[0].length,r=this.fullCharCodeAt(n);if(r===91||r===92)return!0;if(e)return!1;if(r===123)return!0;if(Vr(r)){var i=n;do n+=r<=65535?1:2;while(Hr(r=this.fullCharCodeAt(n)));if(r===92)return!0;var a=this.input.slice(i,n);if(!Lr.test(a))return!0}return!1},H.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual(`async`))return!1;Qr.lastIndex=this.pos;var e=Qr.exec(this.input),t=this.pos+e[0].length,n;return!qr.test(this.input.slice(this.pos,t))&&this.input.slice(t,t+8)===`function`&&(t+8===this.input.length||!(Hr(n=this.fullCharCodeAt(t+8))||n===92))},H.isUsingKeyword=function(e,t){if(this.options.ecmaVersion<17||!this.isContextual(e?`await`:`using`))return!1;Qr.lastIndex=this.pos;var n=Qr.exec(this.input),r=this.pos+n[0].length;if(qr.test(this.input.slice(this.pos,r)))return!1;if(e){var i=r+5,a;if(this.input.slice(r,i)!==`using`||i===this.input.length||Hr(a=this.fullCharCodeAt(i))||a===92)return!1;Qr.lastIndex=i;var o=Qr.exec(this.input);if(r=i+o[0].length,o&&qr.test(this.input.slice(i,r)))return!1}var s=this.fullCharCodeAt(r);if(!Vr(s)&&s!==92)return!1;var c=r;do r+=s<=65535?1:2;while(Hr(s=this.fullCharCodeAt(r)));if(s===92)return!0;var l=this.input.slice(c,r);if(Lr.test(l))return!1;if(t&&!e&&l===`of`){Qr.lastIndex=r;var u=Qr.exec(this.input);if(r+=u[0].length,this.input.charCodeAt(r)!==61||(s=this.input.charCodeAt(r+1))===61||s===62)return!1}return!0},H.isAwaitUsing=function(e){return this.isUsingKeyword(!0,e)},H.isUsing=function(e){return this.isUsingKeyword(!1,e)},H.parseStatement=function(e,t,n){var r=this.type,i=this.startNode(),a;switch(this.isLet(e)&&(r=V._var,a=`let`),r){case V._break:case V._continue:return this.parseBreakContinueStatement(i,r.keyword);case V._debugger:return this.parseDebuggerStatement(i);case V._do:return this.parseDoStatement(i);case V._for:return this.parseForStatement(i);case V._function:return e&&(this.strict||e!==`if`&&e!==`label`)&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(i,!1,!e);case V._class:return e&&this.unexpected(),this.parseClass(i,!0);case V._if:return this.parseIfStatement(i);case V._return:return this.parseReturnStatement(i);case V._switch:return this.parseSwitchStatement(i);case V._throw:return this.parseThrowStatement(i);case V._try:return this.parseTryStatement(i);case V._const:case V._var:return a=a||this.value,e&&a!==`var`&&this.unexpected(),this.parseVarStatement(i,a);case V._while:return this.parseWhileStatement(i);case V._with:return this.parseWithStatement(i);case V.braceL:return this.parseBlock(!0,i);case V.semi:return this.parseEmptyStatement(i);case V._export:case V._import:if(this.options.ecmaVersion>10&&r===V._import){Qr.lastIndex=this.pos;var o=Qr.exec(this.input),s=this.pos+o[0].length,c=this.input.charCodeAt(s);if(c===40||c===46)return this.parseExpressionStatement(i,this.parseExpression())}return this.options.allowImportExportEverywhere||(t||this.raise(this.start,`'import' and 'export' may only appear at the top level`),this.inModule||this.raise(this.start,`'import' and 'export' may appear only with 'sourceType: module'`)),r===V._import?this.parseImport(i):this.parseExport(i,n);default:if(this.isAsyncFunction())return e&&this.unexpected(),this.next(),this.parseFunctionStatement(i,!0,!e);var l=this.isAwaitUsing(!1)?`await using`:this.isUsing(!1)?`using`:null;if(l)return this.allowUsing||this.raise(this.start,\"Using declaration cannot appear in the top level when source type is `script` or in the bare case statement\"),e&&this.raise(this.start,`Using declaration is not allowed in single-statement positions`),l===`await using`&&(this.canAwait||this.raise(this.start,`Await using cannot appear outside of async function`),this.next()),this.next(),this.parseVar(i,!1,l),this.semicolon(),this.finishNode(i,`VariableDeclaration`);var u=this.value,d=this.parseExpression();return r===V.name&&d.type===`Identifier`&&this.eat(V.colon)?this.parseLabeledStatement(i,u,d,e):this.parseExpressionStatement(i,d)}},H.parseBreakContinueStatement=function(e,t){var n=t===`break`;this.next(),this.eat(V.semi)||this.insertSemicolon()?e.label=null:this.type===V.name?(e.label=this.parseIdent(),this.semicolon()):this.unexpected();for(var r=0;r<this.labels.length;++r){var i=this.labels[r];if((e.label==null||i.name===e.label.name)&&(i.kind!=null&&(n||i.kind===`loop`)||e.label&&n))break}return r===this.labels.length&&this.raise(e.start,`Unsyntactic `+t),this.finishNode(e,n?`BreakStatement`:`ContinueStatement`)},H.parseDebuggerStatement=function(e){return this.next(),this.semicolon(),this.finishNode(e,`DebuggerStatement`)},H.parseDoStatement=function(e){return this.next(),this.labels.push(Bi),e.body=this.parseStatement(`do`),this.labels.pop(),this.expect(V._while),e.test=this.parseParenExpression(),this.options.ecmaVersion>=6?this.eat(V.semi):this.semicolon(),this.finishNode(e,`DoWhileStatement`)},H.parseForStatement=function(e){this.next();var t=this.options.ecmaVersion>=9&&this.canAwait&&this.eatContextual(`await`)?this.lastTokStart:-1;if(this.labels.push(Bi),this.enterScope(0),this.expect(V.parenL),this.type===V.semi)return t>-1&&this.unexpected(t),this.parseFor(e,null);var n=this.isLet();if(this.type===V._var||this.type===V._const||n){var r=this.startNode(),i=n?`let`:this.value;return this.next(),this.parseVar(r,!0,i),this.finishNode(r,`VariableDeclaration`),this.parseForAfterInit(e,r,t)}var a=this.isContextual(`let`),o=!1,s=this.isUsing(!0)?`using`:this.isAwaitUsing(!0)?`await using`:null;if(s){var c=this.startNode();return this.next(),s===`await using`&&(this.canAwait||this.raise(this.start,`Await using cannot appear outside of async function`),this.next()),this.parseVar(c,!0,s),this.finishNode(c,`VariableDeclaration`),this.parseForAfterInit(e,c,t)}var l=this.containsEsc,u=new zi,d=this.start,f=t>-1?this.parseExprSubscripts(u,`await`):this.parseExpression(!0,u);return this.type===V._in||(o=this.options.ecmaVersion>=6&&this.isContextual(`of`))?(t>-1?(this.type===V._in&&this.unexpected(t),e.await=!0):o&&this.options.ecmaVersion>=8&&(f.start===d&&!l&&f.type===`Identifier`&&f.name===`async`?this.unexpected():this.options.ecmaVersion>=9&&(e.await=!1)),a&&o&&this.raise(f.start,`The left-hand side of a for-of loop may not start with 'let'.`),this.toAssignable(f,!1,u),this.checkLValPattern(f),this.parseForIn(e,f)):(this.checkExpressionErrors(u,!0),t>-1&&this.unexpected(t),this.parseFor(e,f))},H.parseForAfterInit=function(e,t,n){return(this.type===V._in||this.options.ecmaVersion>=6&&this.isContextual(`of`))&&t.declarations.length===1?(this.type===V._in?((t.kind===`using`||t.kind===`await using`)&&!t.declarations[0].init&&this.raise(this.start,`Using declaration is not allowed in for-in loops`),this.options.ecmaVersion>=9&&n>-1&&this.unexpected(n)):this.options.ecmaVersion>=9&&(e.await=n>-1),this.parseForIn(e,t)):(n>-1&&this.unexpected(n),this.parseFor(e,t))},H.parseFunctionStatement=function(e,t,n){return this.next(),this.parseFunction(e,Ui|(n?0:Wi),!1,t)},H.parseIfStatement=function(e){return this.next(),e.test=this.parseParenExpression(),e.consequent=this.parseStatement(`if`),e.alternate=this.eat(V._else)?this.parseStatement(`if`):null,this.finishNode(e,`IfStatement`)},H.parseReturnStatement=function(e){return this.allowReturn||this.raise(this.start,`'return' outside of function`),this.next(),this.eat(V.semi)||this.insertSemicolon()?e.argument=null:(e.argument=this.parseExpression(),this.semicolon()),this.finishNode(e,`ReturnStatement`)},H.parseSwitchStatement=function(e){this.next(),e.discriminant=this.parseParenExpression(),e.cases=[],this.expect(V.braceL),this.labels.push(Vi),this.enterScope(Ti);for(var t,n=!1;this.type!==V.braceR;)if(this.type===V._case||this.type===V._default){var r=this.type===V._case;t&&this.finishNode(t,`SwitchCase`),e.cases.push(t=this.startNode()),t.consequent=[],this.next(),r?t.test=this.parseExpression():(n&&this.raiseRecoverable(this.lastTokStart,`Multiple default clauses`),n=!0,t.test=null),this.expect(V.colon)}else t||this.unexpected(),t.consequent.push(this.parseStatement(null));return this.exitScope(),t&&this.finishNode(t,`SwitchCase`),this.next(),this.labels.pop(),this.finishNode(e,`SwitchStatement`)},H.parseThrowStatement=function(e){return this.next(),qr.test(this.input.slice(this.lastTokEnd,this.start))&&this.raise(this.lastTokEnd,`Illegal newline after throw`),e.argument=this.parseExpression(),this.semicolon(),this.finishNode(e,`ThrowStatement`)};var Hi=[];H.parseCatchClauseParam=function(){var e=this.parseBindingAtom(),t=e.type===`Identifier`;return this.enterScope(t?bi:0),this.checkLValPattern(e,t?Mi:Ai),this.expect(V.parenR),e},H.parseTryStatement=function(e){if(this.next(),e.block=this.parseBlock(),e.handler=null,this.type===V._catch){var t=this.startNode();this.next(),this.eat(V.parenL)?t.param=this.parseCatchClauseParam():(this.options.ecmaVersion<10&&this.unexpected(),t.param=null,this.enterScope(0)),t.body=this.parseBlock(!1),this.exitScope(),e.handler=this.finishNode(t,`CatchClause`)}return e.finalizer=this.eat(V._finally)?this.parseBlock():null,!e.handler&&!e.finalizer&&this.raise(e.start,`Missing catch or finally clause`),this.finishNode(e,`TryStatement`)},H.parseVarStatement=function(e,t,n){return this.next(),this.parseVar(e,!1,t,n),this.semicolon(),this.finishNode(e,`VariableDeclaration`)},H.parseWhileStatement=function(e){return this.next(),e.test=this.parseParenExpression(),this.labels.push(Bi),e.body=this.parseStatement(`while`),this.labels.pop(),this.finishNode(e,`WhileStatement`)},H.parseWithStatement=function(e){return this.strict&&this.raise(this.start,`'with' in strict mode`),this.next(),e.object=this.parseParenExpression(),e.body=this.parseStatement(`with`),this.finishNode(e,`WithStatement`)},H.parseEmptyStatement=function(e){return this.next(),this.finishNode(e,`EmptyStatement`)},H.parseLabeledStatement=function(e,t,n,r){for(var i=0,a=this.labels;i<a.length;i+=1)a[i].name===t&&this.raise(n.start,`Label '`+t+`' is already declared`);for(var o=this.type.isLoop?`loop`:this.type===V._switch?`switch`:null,s=this.labels.length-1;s>=0;s--){var c=this.labels[s];if(c.statementStart===e.start)c.statementStart=this.start,c.kind=o;else break}return this.labels.push({name:t,kind:o,statementStart:this.start}),e.body=this.parseStatement(r?r.indexOf(`label`)===-1?r+`label`:r:`label`),this.labels.pop(),e.label=n,this.finishNode(e,`LabeledStatement`)},H.parseExpressionStatement=function(e,t){return e.expression=t,this.semicolon(),this.finishNode(e,`ExpressionStatement`)},H.parseBlock=function(e,t,n){for(e===void 0&&(e=!0),t===void 0&&(t=this.startNode()),t.body=[],this.expect(V.braceL),e&&this.enterScope(0);this.type!==V.braceR;){var r=this.parseStatement(null);t.body.push(r)}return n&&(this.strict=!1),this.next(),e&&this.exitScope(),this.finishNode(t,`BlockStatement`)},H.parseFor=function(e,t){return e.init=t,this.expect(V.semi),e.test=this.type===V.semi?null:this.parseExpression(),this.expect(V.semi),e.update=this.type===V.parenR?null:this.parseExpression(),this.expect(V.parenR),e.body=this.parseStatement(`for`),this.exitScope(),this.labels.pop(),this.finishNode(e,`ForStatement`)},H.parseForIn=function(e,t){var n=this.type===V._in;return this.next(),t.type===`VariableDeclaration`&&t.declarations[0].init!=null&&(!n||this.options.ecmaVersion<8||this.strict||t.kind!==`var`||t.declarations[0].id.type!==`Identifier`)&&this.raise(t.start,(n?`for-in`:`for-of`)+` loop variable declaration may not have an initializer`),e.left=t,e.right=n?this.parseExpression():this.parseMaybeAssign(),this.expect(V.parenR),e.body=this.parseStatement(`for`),this.exitScope(),this.labels.pop(),this.finishNode(e,n?`ForInStatement`:`ForOfStatement`)},H.parseVar=function(e,t,n,r){for(e.declarations=[],e.kind=n;;){var i=this.startNode();if(this.parseVarId(i,n),this.eat(V.eq)?i.init=this.parseMaybeAssign(t):!r&&n===`const`&&!(this.type===V._in||this.options.ecmaVersion>=6&&this.isContextual(`of`))?this.unexpected():!r&&(n===`using`||n===`await using`)&&this.options.ecmaVersion>=17&&this.type!==V._in&&!this.isContextual(`of`)?this.raise(this.lastTokEnd,`Missing initializer in `+n+` declaration`):!r&&i.id.type!==`Identifier`&&(!t||this.type!==V._in&&!this.isContextual(`of`))?this.raise(this.lastTokEnd,`Complex binding patterns require an initialization value`):i.init=null,e.declarations.push(this.finishNode(i,`VariableDeclarator`)),!this.eat(V.comma))break}return e},H.parseVarId=function(e,t){e.id=t===`using`||t===`await using`?this.parseIdent():this.parseBindingAtom(),this.checkLValPattern(e.id,t===`var`?ki:Ai,!1)};var Ui=1,Wi=2,Gi=4;H.parseFunction=function(e,t,n,r,i){this.initFunction(e),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!r)&&(this.type===V.star&&t&Wi&&this.unexpected(),e.generator=this.eat(V.star)),this.options.ecmaVersion>=8&&(e.async=!!r),t&Ui&&(e.id=t&Gi&&this.type!==V.name?null:this.parseIdent(),e.id&&!(t&Wi)&&this.checkLValSimple(e.id,this.strict||e.generator||e.async?this.treatFunctionsAsVar?ki:Ai:ji));var a=this.yieldPos,o=this.awaitPos,s=this.awaitIdentPos;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(Di(e.async,e.generator)),t&Ui||(e.id=this.type===V.name?this.parseIdent():null),this.parseFunctionParams(e),this.parseFunctionBody(e,n,!1,i),this.yieldPos=a,this.awaitPos=o,this.awaitIdentPos=s,this.finishNode(e,t&Ui?`FunctionDeclaration`:`FunctionExpression`)},H.parseFunctionParams=function(e){this.expect(V.parenL),e.params=this.parseBindingList(V.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()},H.parseClass=function(e,t){this.next();var n=this.strict;this.strict=!0,this.parseClassId(e,t),this.parseClassSuper(e);var r=this.enterClassBody(),i=this.startNode(),a=!1;for(i.body=[],this.expect(V.braceL);this.type!==V.braceR;){var o=this.parseClassElement(e.superClass!==null);o&&(i.body.push(o),o.type===`MethodDefinition`&&o.kind===`constructor`?(a&&this.raiseRecoverable(o.start,`Duplicate constructor in the same class`),a=!0):o.key&&o.key.type===`PrivateIdentifier`&&Ki(r,o)&&this.raiseRecoverable(o.key.start,`Identifier '#`+o.key.name+`' has already been declared`))}return this.strict=n,this.next(),e.body=this.finishNode(i,`ClassBody`),this.exitClassBody(),this.finishNode(e,t?`ClassDeclaration`:`ClassExpression`)},H.parseClassElement=function(e){if(this.eat(V.semi))return null;var t=this.options.ecmaVersion,n=this.startNode(),r=``,i=!1,a=!1,o=`method`,s=!1;if(this.eatContextual(`static`)){if(t>=13&&this.eat(V.braceL))return this.parseClassStaticBlock(n),n;this.isClassElementNameStart()||this.type===V.star?s=!0:r=`static`}if(n.static=s,!r&&t>=8&&this.eatContextual(`async`)&&((this.isClassElementNameStart()||this.type===V.star)&&!this.canInsertSemicolon()?a=!0:r=`async`),!r&&(t>=9||!a)&&this.eat(V.star)&&(i=!0),!r&&!a&&!i){var c=this.value;(this.eatContextual(`get`)||this.eatContextual(`set`))&&(this.isClassElementNameStart()?o=c:r=c)}if(r?(n.computed=!1,n.key=this.startNodeAt(this.lastTokStart,this.lastTokStartLoc),n.key.name=r,this.finishNode(n.key,`Identifier`)):this.parseClassElementName(n),t<13||this.type===V.parenL||o!==`method`||i||a){var l=!n.static&&qi(n,`constructor`),u=l&&e;l&&o!==`method`&&this.raise(n.key.start,`Constructor can't have get/set modifier`),n.kind=l?`constructor`:o,this.parseClassMethod(n,i,a,u)}else this.parseClassField(n);return n},H.isClassElementNameStart=function(){return this.type===V.name||this.type===V.privateId||this.type===V.num||this.type===V.string||this.type===V.bracketL||this.type.keyword},H.parseClassElementName=function(e){this.type===V.privateId?(this.value===`constructor`&&this.raise(this.start,`Classes can't have an element named '#constructor'`),e.computed=!1,e.key=this.parsePrivateIdent()):this.parsePropertyName(e)},H.parseClassMethod=function(e,t,n,r){var i=e.key;e.kind===`constructor`?(t&&this.raise(i.start,`Constructor can't be a generator`),n&&this.raise(i.start,`Constructor can't be an async method`)):e.static&&qi(e,`prototype`)&&this.raise(i.start,`Classes may not have a static property named prototype`);var a=e.value=this.parseMethod(t,n,r);return e.kind===`get`&&a.params.length!==0&&this.raiseRecoverable(a.start,`getter should have no params`),e.kind===`set`&&a.params.length!==1&&this.raiseRecoverable(a.start,`setter should have exactly one param`),e.kind===`set`&&a.params[0].type===`RestElement`&&this.raiseRecoverable(a.params[0].start,`Setter cannot use rest params`),this.finishNode(e,`MethodDefinition`)},H.parseClassField=function(e){return qi(e,`constructor`)?this.raise(e.key.start,`Classes can't have a field named 'constructor'`):e.static&&qi(e,`prototype`)&&this.raise(e.key.start,`Classes can't have a static field named 'prototype'`),this.eat(V.eq)?(this.enterScope(wi|xi),e.value=this.parseMaybeAssign(),this.exitScope()):e.value=null,this.semicolon(),this.finishNode(e,`PropertyDefinition`)},H.parseClassStaticBlock=function(e){e.body=[];var t=this.labels;for(this.labels=[],this.enterScope(Ci|xi);this.type!==V.braceR;){var n=this.parseStatement(null);e.body.push(n)}return this.next(),this.exitScope(),this.labels=t,this.finishNode(e,`StaticBlock`)},H.parseClassId=function(e,t){this.type===V.name?(e.id=this.parseIdent(),t&&this.checkLValSimple(e.id,Ai,!1)):(t===!0&&this.unexpected(),e.id=null)},H.parseClassSuper=function(e){e.superClass=this.eat(V._extends)?this.parseExprSubscripts(null,!1):null},H.enterClassBody=function(){var e={declared:Object.create(null),used:[]};return this.privateNameStack.push(e),e.declared},H.exitClassBody=function(){var e=this.privateNameStack.pop(),t=e.declared,n=e.used;if(this.options.checkPrivateFields)for(var r=this.privateNameStack.length,i=r===0?null:this.privateNameStack[r-1],a=0;a<n.length;++a){var o=n[a];ni(t,o.name)||(i?i.used.push(o):this.raiseRecoverable(o.start,`Private field '#`+o.name+`' must be declared in an enclosing class`))}};function Ki(e,t){var n=t.key.name,r=e[n],i=`true`;return t.type===`MethodDefinition`&&(t.kind===`get`||t.kind===`set`)&&(i=(t.static?`s`:`i`)+t.kind),r===`iget`&&i===`iset`||r===`iset`&&i===`iget`||r===`sget`&&i===`sset`||r===`sset`&&i===`sget`?(e[n]=`true`,!1):r?!0:(e[n]=i,!1)}function qi(e,t){var n=e.computed,r=e.key;return!n&&(r.type===`Identifier`&&r.name===t||r.type===`Literal`&&r.value===t)}H.parseExportAllDeclaration=function(e,t){return this.options.ecmaVersion>=11&&(this.eatContextual(`as`)?(e.exported=this.parseModuleExportName(),this.checkExport(t,e.exported,this.lastTokStart)):e.exported=null),this.expectContextual(`from`),this.type!==V.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,`ExportAllDeclaration`)},H.parseExport=function(e,t){if(this.next(),this.eat(V.star))return this.parseExportAllDeclaration(e,t);if(this.eat(V._default))return this.checkExport(t,`default`,this.lastTokStart),e.declaration=this.parseExportDefaultDeclaration(),this.finishNode(e,`ExportDefaultDeclaration`);if(this.shouldParseExportStatement())e.declaration=this.parseExportDeclaration(e),e.declaration.type===`VariableDeclaration`?this.checkVariableExport(t,e.declaration.declarations):this.checkExport(t,e.declaration.id,e.declaration.id.start),e.specifiers=[],e.source=null,this.options.ecmaVersion>=16&&(e.attributes=[]);else{if(e.declaration=null,e.specifiers=this.parseExportSpecifiers(t),this.eatContextual(`from`))this.type!==V.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause());else{for(var n=0,r=e.specifiers;n<r.length;n+=1){var i=r[n];this.checkUnreserved(i.local),this.checkLocalExport(i.local),i.local.type===`Literal`&&this.raise(i.local.start,\"A string literal cannot be used as an exported binding without `from`.\")}e.source=null,this.options.ecmaVersion>=16&&(e.attributes=[])}this.semicolon()}return this.finishNode(e,`ExportNamedDeclaration`)},H.parseExportDeclaration=function(e){return this.parseStatement(null)},H.parseExportDefaultDeclaration=function(){var e;if(this.type===V._function||(e=this.isAsyncFunction())){var t=this.startNode();return this.next(),e&&this.next(),this.parseFunction(t,Ui|Gi,!1,e)}if(this.type===V._class){var n=this.startNode();return this.parseClass(n,`nullableID`)}var r=this.parseMaybeAssign();return this.semicolon(),r},H.checkExport=function(e,t,n){e&&(typeof t!=`string`&&(t=t.type===`Identifier`?t.name:t.value),ni(e,t)&&this.raiseRecoverable(n,`Duplicate export '`+t+`'`),e[t]=!0)},H.checkPatternExport=function(e,t){var n=t.type;if(n===`Identifier`)this.checkExport(e,t,t.start);else if(n===`ObjectPattern`)for(var r=0,i=t.properties;r<i.length;r+=1){var a=i[r];this.checkPatternExport(e,a)}else if(n===`ArrayPattern`)for(var o=0,s=t.elements;o<s.length;o+=1){var c=s[o];c&&this.checkPatternExport(e,c)}else n===`Property`?this.checkPatternExport(e,t.value):n===`AssignmentPattern`?this.checkPatternExport(e,t.left):n===`RestElement`&&this.checkPatternExport(e,t.argument)},H.checkVariableExport=function(e,t){if(e)for(var n=0,r=t;n<r.length;n+=1){var i=r[n];this.checkPatternExport(e,i.id)}},H.shouldParseExportStatement=function(){return this.type.keyword===`var`||this.type.keyword===`const`||this.type.keyword===`class`||this.type.keyword===`function`||this.isLet()||this.isAsyncFunction()},H.parseExportSpecifier=function(e){var t=this.startNode();return t.local=this.parseModuleExportName(),t.exported=this.eatContextual(`as`)?this.parseModuleExportName():t.local,this.checkExport(e,t.exported,t.exported.start),this.finishNode(t,`ExportSpecifier`)},H.parseExportSpecifiers=function(e){var t=[],n=!0;for(this.expect(V.braceL);!this.eat(V.braceR);){if(n)n=!1;else if(this.expect(V.comma),this.afterTrailingComma(V.braceR))break;t.push(this.parseExportSpecifier(e))}return t},H.parseImport=function(e){return this.next(),this.type===V.string?(e.specifiers=Hi,e.source=this.parseExprAtom()):(e.specifiers=this.parseImportSpecifiers(),this.expectContextual(`from`),e.source=this.type===V.string?this.parseExprAtom():this.unexpected()),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,`ImportDeclaration`)},H.parseImportSpecifier=function(){var e=this.startNode();return e.imported=this.parseModuleExportName(),this.eatContextual(`as`)?e.local=this.parseIdent():(this.checkUnreserved(e.imported),e.local=e.imported),this.checkLValSimple(e.local,Ai),this.finishNode(e,`ImportSpecifier`)},H.parseImportDefaultSpecifier=function(){var e=this.startNode();return e.local=this.parseIdent(),this.checkLValSimple(e.local,Ai),this.finishNode(e,`ImportDefaultSpecifier`)},H.parseImportNamespaceSpecifier=function(){var e=this.startNode();return this.next(),this.expectContextual(`as`),e.local=this.parseIdent(),this.checkLValSimple(e.local,Ai),this.finishNode(e,`ImportNamespaceSpecifier`)},H.parseImportSpecifiers=function(){var e=[],t=!0;if(this.type===V.name&&(e.push(this.parseImportDefaultSpecifier()),!this.eat(V.comma)))return e;if(this.type===V.star)return e.push(this.parseImportNamespaceSpecifier()),e;for(this.expect(V.braceL);!this.eat(V.braceR);){if(t)t=!1;else if(this.expect(V.comma),this.afterTrailingComma(V.braceR))break;e.push(this.parseImportSpecifier())}return e},H.parseWithClause=function(){var e=[];if(!this.eat(V._with))return e;this.expect(V.braceL);for(var t={},n=!0;!this.eat(V.braceR);){if(n)n=!1;else if(this.expect(V.comma),this.afterTrailingComma(V.braceR))break;var r=this.parseImportAttribute(),i=r.key.type===`Identifier`?r.key.name:r.key.value;ni(t,i)&&this.raiseRecoverable(r.key.start,`Duplicate attribute key '`+i+`'`),t[i]=!0,e.push(r)}return e},H.parseImportAttribute=function(){var e=this.startNode();return e.key=this.type===V.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!==`never`),this.expect(V.colon),this.type!==V.string&&this.unexpected(),e.value=this.parseExprAtom(),this.finishNode(e,`ImportAttribute`)},H.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===V.string){var e=this.parseLiteral(this.value);return si.test(e.value)&&this.raise(e.start,`An export name cannot include a lone surrogate.`),e}return this.parseIdent(!0)},H.adaptDirectivePrologue=function(e){for(var t=0;t<e.length&&this.isDirectiveCandidate(e[t]);++t)e[t].directive=e[t].expression.raw.slice(1,-1)},H.isDirectiveCandidate=function(e){return this.options.ecmaVersion>=5&&e.type===`ExpressionStatement`&&e.expression.type===`Literal`&&typeof e.expression.value==`string`&&(this.input[e.start]===`\"`||this.input[e.start]===`'`)};var Ji=Pi.prototype;Ji.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},Ji.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},Ji.parseSpread=function(e){var t=this.startNode();return this.next(),t.argument=this.parseMaybeAssign(!1,e),this.finishNode(t,`SpreadElement`)},Ji.parseRestBinding=function(){var e=this.startNode();return this.next(),this.options.ecmaVersion===6&&this.type!==V.name&&this.unexpected(),e.argument=this.parseBindingAtom(),this.finishNode(e,`RestElement`)},Ji.parseBindingAtom=function(){if(this.options.ecmaVersion>=6)switch(this.type){case V.bracketL:var e=this.startNode();return this.next(),e.elements=this.parseBindingList(V.bracketR,!0,!0),this.finishNode(e,`ArrayPattern`);case V.braceL:return this.parseObj(!0)}return this.parseIdent()},Ji.parseBindingList=function(e,t,n,r){for(var i=[],a=!0;!this.eat(e);)if(a?a=!1:this.expect(V.comma),t&&this.type===V.comma)i.push(null);else if(n&&this.afterTrailingComma(e))break;else if(this.type===V.ellipsis){var o=this.parseRestBinding();this.parseBindingListItem(o),i.push(o),this.type===V.comma&&this.raiseRecoverable(this.start,`Comma is not permitted after the rest element`),this.expect(e);break}else i.push(this.parseAssignableListItem(r));return i},Ji.parseAssignableListItem=function(e){var t=this.parseMaybeDefault(this.start,this.startLoc);return this.parseBindingListItem(t),t},Ji.parseBindingListItem=function(e){return e},Ji.parseMaybeDefault=function(e,t,n){if(n=n||this.parseBindingAtom(),this.options.ecmaVersion<6||!this.eat(V.eq))return n;var r=this.startNodeAt(e,t);return r.left=n,r.right=this.parseMaybeAssign(),this.finishNode(r,`AssignmentPattern`)},Ji.checkLValSimple=function(e,t,n){t===void 0&&(t=Oi);var r=t!==Oi;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===Ai&&e.name===`let`&&this.raiseRecoverable(e.start,`let is disallowed as a lexically bound name`),n&&(ni(n,e.name)&&this.raiseRecoverable(e.start,`Argument name clash`),n[e.name]=!0),t!==Ni&&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`)}},Ji.checkLValPattern=function(e,t,n){switch(t===void 0&&(t=Oi),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)}},Ji.checkLValInnerPattern=function(e,t,n){switch(t===void 0&&(t=Oi),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 Yi=function(e,t,n,r,i){this.token=e,this.isExpr=!!t,this.preserveSpace=!!n,this.override=r,this.generator=!!i},Xi={b_stat:new Yi(`{`,!1),b_expr:new Yi(`{`,!0),b_tmpl:new Yi(\"${\",!1),p_stat:new Yi(`(`,!1),p_expr:new Yi(`(`,!0),q_tmpl:new Yi(\"`\",!0,!0,function(e){return e.tryReadTemplateToken()}),f_stat:new Yi(`function`,!1),f_expr:new Yi(`function`,!0),f_expr_gen:new Yi(`function`,!0,!1,null,!0),f_gen:new Yi(`function`,!1,!1,null,!0)},Zi=Pi.prototype;Zi.initialContext=function(){return[Xi.b_stat]},Zi.curContext=function(){return this.context[this.context.length-1]},Zi.braceIsBlock=function(e){var t=this.curContext();return t===Xi.f_expr||t===Xi.f_stat?!0:e===V.colon&&(t===Xi.b_stat||t===Xi.b_expr)?!t.isExpr:e===V._return||e===V.name&&this.exprAllowed?qr.test(this.input.slice(this.lastTokEnd,this.start)):e===V._else||e===V.semi||e===V.eof||e===V.parenR||e===V.arrow?!0:e===V.braceL?t===Xi.b_stat:e===V._var||e===V._const||e===V.name?!1:!this.exprAllowed},Zi.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},Zi.updateContext=function(e){var t,n=this.type;n.keyword&&e===V.dot?this.exprAllowed=!1:(t=n.updateContext)?t.call(this,e):this.exprAllowed=n.beforeExpr},Zi.overrideContext=function(e){this.curContext()!==e&&(this.context[this.context.length-1]=e)},V.parenR.updateContext=V.braceR.updateContext=function(){if(this.context.length===1)this.exprAllowed=!0;else{var e=this.context.pop();e===Xi.b_stat&&this.curContext().token===`function`&&(e=this.context.pop()),this.exprAllowed=!e.isExpr}},V.braceL.updateContext=function(e){this.context.push(this.braceIsBlock(e)?Xi.b_stat:Xi.b_expr),this.exprAllowed=!0},V.dollarBraceL.updateContext=function(){this.context.push(Xi.b_tmpl),this.exprAllowed=!0},V.parenL.updateContext=function(e){var t=e===V._if||e===V._for||e===V._with||e===V._while;this.context.push(t?Xi.p_stat:Xi.p_expr),this.exprAllowed=!0},V.incDec.updateContext=function(){},V._function.updateContext=V._class.updateContext=function(e){e.beforeExpr&&e!==V._else&&(e!==V.semi||this.curContext()===Xi.p_stat)&&!(e===V._return&&qr.test(this.input.slice(this.lastTokEnd,this.start)))&&(e!==V.colon&&e!==V.braceL||this.curContext()!==Xi.b_stat)?this.context.push(Xi.f_expr):this.context.push(Xi.f_stat),this.exprAllowed=!1},V.colon.updateContext=function(){this.curContext().token===`function`&&this.context.pop(),this.exprAllowed=!0},V.backQuote.updateContext=function(){this.curContext()===Xi.q_tmpl?this.context.pop():this.context.push(Xi.q_tmpl),this.exprAllowed=!1},V.star.updateContext=function(e){if(e===V._function){var t=this.context.length-1;this.context[t]===Xi.f_expr?this.context[t]=Xi.f_expr_gen:this.context[t]=Xi.f_gen}this.exprAllowed=!0},V.name.updateContext=function(e){var t=!1;this.options.ecmaVersion>=6&&e!==V.dot&&(this.value===`of`&&!this.exprAllowed||this.value===`yield`&&this.inGeneratorContext())&&(t=!0),this.exprAllowed=t};var U=Pi.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);else{i=`$`+i;var o=t[i];o?(a===`init`?this.strict&&o.init||o.get||o.set:o.init||o[a])&&this.raiseRecoverable(r.start,`Redefinition of property`):o=t[i]={init:!1,get:!1,set:!1},o[a]=!0}}},U.parseExpression=function(e,t){var n=this;return this.catchStackOverflow(function(){var r=n.start,i=n.startLoc,a=n.parseMaybeAssign(e,t);if(n.type===V.comma){var o=n.startNodeAt(r,i);for(o.expressions=[a];n.eat(V.comma);)o.expressions.push(n.parseMaybeAssign(e,t));return n.finishNode(o,`SequenceExpression`)}return a})},U.parseMaybeAssign=function(e,t,n){if(this.isContextual(`yield`)){if(this.inGenerator)return this.parseYield(e);this.exprAllowed=!1}var r=!1,i=-1,a=-1,o=-1;t?(i=t.parenthesizedAssign,a=t.trailingComma,o=t.doubleProto,t.parenthesizedAssign=t.trailingComma=-1):(t=new zi,r=!0);var s=this.start,c=this.startLoc;(this.type===V.parenL||this.type===V.name)&&(this.potentialArrowAt=this.start,this.potentialArrowInForAwait=e===`await`);var l=this.parseMaybeConditional(e,t);if(n&&(l=n.call(this,l,s,c)),this.type.isAssign){var u=this.startNodeAt(s,c);return u.operator=this.value,this.type===V.eq&&(l=this.toAssignable(l,!1,t)),r||(t.parenthesizedAssign=t.trailingComma=-1,t.shorthandAssign>=l.start&&(t.shorthandAssign=-1),t.doubleProto>=l.start&&(t.doubleProto=-1)),this.type===V.eq?this.checkLValPattern(l):this.checkLValSimple(l),u.left=l,this.next(),u.right=this.parseMaybeAssign(e),o>-1&&(t.doubleProto=o),this.finishNode(u,`AssignmentExpression`)}return r&&this.checkExpressionErrors(t,!0),i>-1&&(t.parenthesizedAssign=i),a>-1&&(t.trailingComma=a),l},U.parseMaybeConditional=function(e,t){var n=this.start,r=this.startLoc,i=this.parseExprOps(e,t);if(this.checkExpressionErrors(t))return i;if((i.type!==`ArrowFunctionExpression`||i.start!==n)&&this.eat(V.question)){var a=this.startNodeAt(n,r);return a.test=i,a.consequent=this.parseMaybeAssign(),this.expect(V.colon),a.alternate=this.parseMaybeAssign(e),this.finishNode(a,`ConditionalExpression`)}return i},U.parseExprOps=function(e,t){var n=this.start,r=this.startLoc,i=this.parseMaybeUnary(t,!1,!1,e);return this.checkExpressionErrors(t)||i.start===n&&i.type===`ArrowFunctionExpression`?i:this.parseExprOp(i,n,r,-1,e)},U.parseExprOp=function(e,t,n,r,i){var a=this.type.binop;if(a!=null&&(!i||this.type!==V._in)&&a>r){var o=this.type===V.logicalOR||this.type===V.logicalAND,s=this.type===V.coalesce;s&&(a=V.logicalAND.binop);var c=this.value;this.next();var l=this.start,u=this.startLoc,d=this.parseExprOp(this.parseMaybeUnary(null,!1,!1,i),l,u,a,i),f=this.buildBinary(t,n,e,d,c,o||s);return(o&&this.type===V.coalesce||s&&(this.type===V.logicalOR||this.type===V.logicalAND))&&this.raiseRecoverable(this.start,`Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses`),this.parseExprOp(f,t,n,r,i)}return e},U.buildBinary=function(e,t,n,r,i,a){r.type===`PrivateIdentifier`&&this.raise(r.start,`Private identifier can only be left side of binary expression`);var o=this.startNodeAt(e,t);return o.left=n,o.operator=i,o.right=r,this.finishNode(o,a?`LogicalExpression`:`BinaryExpression`)},U.parseMaybeUnary=function(e,t,n,r){var i=this.start,a=this.startLoc,o;if(this.isContextual(`await`)&&this.canAwait)o=this.parseAwait(r),t=!0;else if(this.type.prefix){var s=this.startNode(),c=this.type===V.incDec;s.operator=this.value,s.prefix=!0,this.next(),s.argument=this.parseMaybeUnary(null,!0,c,r),this.checkExpressionErrors(e,!0),c?this.checkLValSimple(s.argument):this.strict&&s.operator===`delete`&&Qi(s.argument)?this.raiseRecoverable(s.start,`Deleting local variable in strict mode`):s.operator===`delete`&&$i(s.argument)?this.raiseRecoverable(s.start,`Private fields can not be deleted`):t=!0,o=this.finishNode(s,c?`UpdateExpression`:`UnaryExpression`)}else if(!t&&this.type===V.privateId)(r||this.privateNameStack.length===0)&&this.options.checkPrivateFields&&this.unexpected(),o=this.parsePrivateIdent(),this.type!==V._in&&this.unexpected();else{if(o=this.parseExprSubscripts(e,r),this.checkExpressionErrors(e))return o;for(;this.type.postfix&&!this.canInsertSemicolon();){var l=this.startNodeAt(i,a);l.operator=this.value,l.prefix=!1,l.argument=o,this.checkLValSimple(o),this.next(),o=this.finishNode(l,`UpdateExpression`)}}if(!n&&(o.type!==`ArrowFunctionExpression`||o.start!==i)&&this.eat(V.starstar)){if(t)this.unexpected(this.lastTokStart);else return this.buildBinary(i,a,o,this.parseMaybeUnary(null,!1,!1,r),`**`,!1)}else return o};function Qi(e){return e.type===`Identifier`||e.type===`ParenthesizedExpression`&&Qi(e.expression)}function $i(e){return e.type===`MemberExpression`&&e.property.type===`PrivateIdentifier`||e.type===`ChainExpression`&&$i(e.expression)||e.type===`ParenthesizedExpression`&&$i(e.expression)}U.parseExprSubscripts=function(e,t){var n=this.start,r=this.startLoc,i=-1,a=-1;e&&(i=e.doubleProto,a=e.shorthandAssign,e.doubleProto=e.shorthandAssign=-1);var o=this.parseExprAtom(e,t);if(o.type===`ArrowFunctionExpression`&&this.input.slice(this.lastTokStart,this.lastTokEnd)!==`)`)return o;var s=this.parseSubscripts(o,n,r,!1,t);return e&&(s.end>o.end&&(this.checkExpressionErrors(e,!0),e.parenthesizedAssign>=s.start&&(e.parenthesizedAssign=-1),e.parenthesizedBind>=s.start&&(e.parenthesizedBind=-1),e.trailingComma>=s.start&&(e.trailingComma=-1)),i>-1&&(e.doubleProto=i),a>-1&&(e.shorthandAssign=a)),s},U.parseSubscripts=function(e,t,n,r,i){for(var a=this.options.ecmaVersion>=8&&e.type===`Identifier`&&e.name===`async`&&this.lastTokEnd===e.end&&!this.canInsertSemicolon()&&e.end-e.start===5&&this.potentialArrowAt===e.start,o=!1;;){var s=this.parseSubscript(e,t,n,r,a,o,i);if(s.optional&&(o=!0),s.end===e.end||s.type===`ArrowFunctionExpression`){if(o){var c=this.startNodeAt(t,n);c.expression=s,s=this.finishNode(c,`ChainExpression`)}return s}e=s,a=!1}},U.shouldParseAsyncArrow=function(){return!this.canInsertSemicolon()&&this.eat(V.arrow)},U.parseSubscriptAsyncArrow=function(e,t,n,r){return this.parseArrowExpression(this.startNodeAt(e,t),n,!0,r)},U.parseSubscript=function(e,t,n,r,i,a,o){var s=this.options.ecmaVersion>=11,c=s&&this.eat(V.questionDot);r&&c&&this.raise(this.lastTokStart,`Optional chaining cannot appear in the callee of new expressions`);var l=this.eat(V.bracketL);if(l||c&&this.type!==V.parenL&&this.type!==V.backQuote||this.eat(V.dot)){var u=this.startNodeAt(t,n);u.object=e,l?(u.property=this.parseExpression(),this.expect(V.bracketR)):u.property=this.type===V.privateId&&e.type!==`Super`?this.parsePrivateIdent():this.parseIdent(this.options.allowReserved!==`never`),u.computed=!!l,s&&(u.optional=c),e=this.finishNode(u,`MemberExpression`)}else if(!r&&this.eat(V.parenL)){var d=new zi,f=this.yieldPos,p=this.awaitPos,m=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var h=this.parseExprList(V.parenR,this.options.ecmaVersion>=8,!1,d);if(i&&!c&&this.shouldParseAsyncArrow())return this.checkPatternErrors(d,!1),this.checkYieldAwaitInDefaultParams(),this.awaitIdentPos>0&&this.raise(this.awaitIdentPos,`Cannot use 'await' as identifier inside an async function`),this.yieldPos=f,this.awaitPos=p,this.awaitIdentPos=m,this.parseSubscriptAsyncArrow(t,n,h,o);this.checkExpressionErrors(d,!0),this.yieldPos=f||this.yieldPos,this.awaitPos=p||this.awaitPos,this.awaitIdentPos=m||this.awaitIdentPos;var g=this.startNodeAt(t,n);g.callee=e,g.arguments=h,s&&(g.optional=c),e=this.finishNode(g,`CallExpression`)}else if(this.type===V.backQuote){(c||a)&&this.raise(this.start,`Optional chaining cannot appear in the tag of tagged template expressions`);var _=this.startNodeAt(t,n);_.tag=e,_.quasi=this.parseTemplate({isTagged:!0}),e=this.finishNode(_,`TaggedTemplateExpression`)}return e},U.parseExprAtom=function(e,t,n){this.type===V.slash&&this.readRegexp();var r,i=this.potentialArrowAt===this.start;switch(this.type){case V._super:return this.allowSuper||this.raise(this.start,`'super' keyword outside a method`),r=this.startNode(),this.next(),this.type===V.parenL&&!this.allowDirectSuper&&this.raise(r.start,`super() call outside constructor of a subclass`),this.type!==V.dot&&this.type!==V.bracketL&&this.type!==V.parenL&&this.unexpected(),this.finishNode(r,`Super`);case V._this:return r=this.startNode(),this.next(),this.finishNode(r,`ThisExpression`);case V.name:var a=this.start,o=this.startLoc,s=this.containsEsc,c=this.parseIdent(!1);if(this.options.ecmaVersion>=8&&!s&&c.name===`async`&&!this.canInsertSemicolon()&&this.eat(V._function))return this.overrideContext(Xi.f_expr),this.parseFunction(this.startNodeAt(a,o),0,!1,!0,t);if(i&&!this.canInsertSemicolon()){if(this.eat(V.arrow))return this.parseArrowExpression(this.startNodeAt(a,o),[c],!1,t);if(this.options.ecmaVersion>=8&&c.name===`async`&&this.type===V.name&&!s&&(!this.potentialArrowInForAwait||this.value!==`of`||this.containsEsc))return c=this.parseIdent(!1),(this.canInsertSemicolon()||!this.eat(V.arrow))&&this.unexpected(),this.parseArrowExpression(this.startNodeAt(a,o),[c],!0,t)}return c;case V.regexp:var l=this.value;return r=this.parseLiteral(l.value),r.regex={pattern:l.pattern,flags:l.flags},r;case V.num:case V.string:return this.parseLiteral(this.value);case V._null:case V._true:case V._false:return r=this.startNode(),r.value=this.type===V._null?null:this.type===V._true,r.raw=this.type.keyword,this.next(),this.finishNode(r,`Literal`);case V.parenL:var u=this.start,d=this.parseParenAndDistinguishExpression(i,t);return e&&(e.parenthesizedAssign<0&&!this.isSimpleAssignTarget(d)&&(e.parenthesizedAssign=u),e.parenthesizedBind<0&&(e.parenthesizedBind=u)),d;case V.bracketL:return r=this.startNode(),this.next(),r.elements=this.parseExprList(V.bracketR,!0,!0,e),this.finishNode(r,`ArrayExpression`);case V.braceL:return this.overrideContext(Xi.b_expr),this.parseObj(!1,e);case V._function:return r=this.startNode(),this.next(),this.parseFunction(r,0);case V._class:return this.parseClass(this.startNode(),!1);case V._new:return this.parseNew();case V.backQuote:return this.parseTemplate();case V._import:return this.options.ecmaVersion>=11?this.parseExprImport(n):this.unexpected();default:return this.parseExprAtomDefault()}},U.parseExprAtomDefault=function(){this.unexpected()},U.parseExprImport=function(e){var t=this.startNode();if(this.containsEsc&&this.raiseRecoverable(this.start,`Escape sequence in keyword import`),this.next(),this.type===V.parenL&&!e)return this.parseDynamicImport(t);if(this.type===V.dot){var n=this.startNodeAt(t.start,t.loc&&t.loc.start);return n.name=`import`,t.meta=this.finishNode(n,`Identifier`),this.parseImportMeta(t)}this.unexpected()},U.parseDynamicImport=function(e){if(this.next(),e.source=this.parseMaybeAssign(),this.options.ecmaVersion>=16)this.eat(V.parenR)?e.options=null:(this.expect(V.comma),this.afterTrailingComma(V.parenR)?e.options=null:(e.options=this.parseMaybeAssign(),this.eat(V.parenR)||(this.expect(V.comma),this.afterTrailingComma(V.parenR)||this.unexpected())));else if(!this.eat(V.parenR)){var t=this.start;this.eat(V.comma)&&this.eat(V.parenR)?this.raiseRecoverable(t,`Trailing comma is not allowed in import()`):this.unexpected(t)}return this.finishNode(e,`ImportExpression`)},U.parseImportMeta=function(e){this.next();var t=this.containsEsc;return e.property=this.parseIdent(!0),e.property.name!==`meta`&&this.raiseRecoverable(e.property.start,`The only valid meta property for import is 'import.meta'`),t&&this.raiseRecoverable(e.start,`'import.meta' must not contain escaped characters`),this.options.sourceType!==`module`&&!this.options.allowImportExportEverywhere&&this.raiseRecoverable(e.start,`Cannot use 'import.meta' outside a module`),this.finishNode(e,`MetaProperty`)},U.parseLiteral=function(e){var t=this.startNode();return t.value=e,t.raw=this.input.slice(this.start,this.end),t.raw.charCodeAt(t.raw.length-1)===110&&(t.bigint=t.value==null?t.raw.slice(0,-1).replace(/_/g,``):t.value.toString()),this.next(),this.finishNode(t,`Literal`)},U.parseParenExpression=function(){this.expect(V.parenL);var e=this.parseExpression();return this.expect(V.parenR),e},U.shouldParseArrow=function(e){return!this.canInsertSemicolon()},U.parseParenAndDistinguishExpression=function(e,t){var n=this.start,r=this.startLoc,i,a=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var o=this.start,s=this.startLoc,c=[],l=!0,u=!1,d=new zi,f=this.yieldPos,p=this.awaitPos,m;for(this.yieldPos=0,this.awaitPos=0;this.type!==V.parenR;){if(l?l=!1:this.expect(V.comma),a&&this.afterTrailingComma(V.parenR,!0)){u=!0;break}if(this.type===V.ellipsis){m=this.start,c.push(this.parseParenItem(this.parseRestBinding())),this.type===V.comma&&this.raiseRecoverable(this.start,`Comma is not permitted after the rest element`);break}c.push(this.parseMaybeAssign(!1,d,this.parseParenItem))}var h=this.lastTokEnd,g=this.lastTokEndLoc;if(this.expect(V.parenR),e&&this.shouldParseArrow(c)&&this.eat(V.arrow))return this.checkPatternErrors(d,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=f,this.awaitPos=p,this.parseParenArrowList(n,r,c,t);(!c.length||u)&&this.unexpected(this.lastTokStart),m&&this.unexpected(m),this.checkExpressionErrors(d,!0),this.yieldPos=f||this.yieldPos,this.awaitPos=p||this.awaitPos,c.length>1?(i=this.startNodeAt(o,s),i.expressions=c,this.finishNodeAt(i,`SequenceExpression`,h,g)):i=c[0]}else i=this.parseParenExpression();if(this.options.preserveParens){var _=this.startNodeAt(n,r);return _.expression=i,this.finishNode(_,`ParenthesizedExpression`)}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 ea=[];U.parseNew=function(){this.containsEsc&&this.raiseRecoverable(this.start,`Escape sequence in keyword new`);var e=this.startNode();if(this.next(),this.options.ecmaVersion>=6&&this.type===V.dot){var t=this.startNodeAt(e.start,e.loc&&e.loc.start);t.name=`new`,e.meta=this.finishNode(t,`Identifier`),this.next();var n=this.containsEsc;return e.property=this.parseIdent(!0),e.property.name!==`target`&&this.raiseRecoverable(e.property.start,`The only valid meta property for new is 'new.target'`),n&&this.raiseRecoverable(e.start,`'new.target' must not contain escaped characters`),this.allowNewDotTarget||this.raiseRecoverable(e.start,`'new.target' can only be used in functions and class static block`),this.finishNode(e,`MetaProperty`)}var r=this.start,i=this.startLoc;return e.callee=this.parseSubscripts(this.parseExprAtom(null,!1,!0),r,i,!0,!1),e.callee.type===`Super`&&this.raiseRecoverable(r,`Invalid use of 'super'`),e.arguments=this.eat(V.parenL)?this.parseExprList(V.parenR,this.options.ecmaVersion>=8,!1):ea,this.finishNode(e,`NewExpression`)},U.parseTemplateElement=function(e){var t=e.isTagged,n=this.startNode();return this.type===V.invalidTemplate?(t||this.raiseRecoverable(this.start,`Bad escape sequence in untagged template literal`),n.value={raw:this.value.replace(/\\r\\n?/g,`\n`),cooked:null}):n.value={raw:this.input.slice(this.start,this.end).replace(/\\r\\n?/g,`\n`),cooked:this.value},this.next(),n.tail=this.type===V.backQuote,this.finishNode(n,`TemplateElement`)},U.parseTemplate=function(e){e===void 0&&(e={});var t=e.isTagged;t===void 0&&(t=!1);var n=this.startNode();this.next(),n.expressions=[];var r=this.parseTemplateElement({isTagged:t});for(n.quasis=[r];!r.tail;)this.type===V.eof&&this.raise(this.pos,`Unterminated template literal`),this.expect(V.dollarBraceL),n.expressions.push(this.parseExpression()),this.expect(V.braceR),n.quasis.push(r=this.parseTemplateElement({isTagged:t}));return this.next(),this.finishNode(n,`TemplateLiteral`)},U.isAsyncProp=function(e){return!e.computed&&e.key.type===`Identifier`&&e.key.name===`async`&&(this.type===V.name||this.type===V.num||this.type===V.string||this.type===V.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===V.star)&&!qr.test(this.input.slice(this.lastTokEnd,this.start))},U.parseObj=function(e,t){var n=this.startNode(),r=!0,i={};for(n.properties=[],this.next();!this.eat(V.braceR);){if(r)r=!1;else if(this.expect(V.comma),this.options.ecmaVersion>=5&&this.afterTrailingComma(V.braceR))break;var a=this.parseProperty(e,t);e||this.checkPropClash(a,i,t),n.properties.push(a)}return this.finishNode(n,e?`ObjectPattern`:`ObjectExpression`)},U.parseProperty=function(e,t){var n=this.startNode(),r,i,a,o;if(this.options.ecmaVersion>=9&&this.eat(V.ellipsis))return e?(n.argument=this.parseIdent(!1),this.type===V.comma&&this.raiseRecoverable(this.start,`Comma is not permitted after the rest element`),this.finishNode(n,`RestElement`)):(n.argument=this.parseMaybeAssign(!1,t),this.type===V.comma&&t&&t.trailingComma<0&&(t.trailingComma=this.start),this.finishNode(n,`SpreadElement`));this.options.ecmaVersion>=6&&(n.method=!1,n.shorthand=!1,(e||t)&&(a=this.start,o=this.startLoc),e||(r=this.eat(V.star)));var s=this.containsEsc;return this.parsePropertyName(n),!e&&!s&&this.options.ecmaVersion>=8&&!r&&this.isAsyncProp(n)?(i=!0,r=this.options.ecmaVersion>=9&&this.eat(V.star),this.parsePropertyName(n)):i=!1,this.parsePropertyValue(n,e,r,i,a,o,t,s),this.finishNode(n,`Property`)},U.parseGetterSetter=function(e){var t=e.key.name;this.parsePropertyName(e),e.value=this.parseMethod(!1),e.kind=t;var n=e.kind===`get`?0:1;if(e.value.params.length!==n){var r=e.value.start;e.kind===`get`?this.raiseRecoverable(r,`getter should have no params`):this.raiseRecoverable(r,`setter should have exactly one param`)}else e.kind===`set`&&e.value.params[0].type===`RestElement`&&this.raiseRecoverable(e.value.params[0].start,`Setter cannot use rest params`)},U.parsePropertyValue=function(e,t,n,r,i,a,o,s){(n||r)&&this.type===V.colon&&this.unexpected(),this.eat(V.colon)?(e.value=t?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,o),e.kind=`init`):this.options.ecmaVersion>=6&&this.type===V.parenL?(t&&this.unexpected(),e.method=!0,e.value=this.parseMethod(n,r),e.kind=`init`):!t&&!s&&this.options.ecmaVersion>=5&&!e.computed&&e.key.type===`Identifier`&&(e.key.name===`get`||e.key.name===`set`)&&this.type!==V.comma&&this.type!==V.braceR&&this.type!==V.eq?((n||r)&&this.unexpected(),this.parseGetterSetter(e)):this.options.ecmaVersion>=6&&!e.computed&&e.key.type===`Identifier`?((n||r)&&this.unexpected(),this.checkUnreserved(e.key),e.key.name===`await`&&!this.awaitIdentPos&&(this.awaitIdentPos=i),t?e.value=this.parseMaybeDefault(i,a,this.copyNode(e.key)):this.type===V.eq&&o?(o.shorthandAssign<0&&(o.shorthandAssign=this.start),e.value=this.parseMaybeDefault(i,a,this.copyNode(e.key))):e.value=this.copyNode(e.key),e.kind=`init`,e.shorthand=!0):this.unexpected()},U.parsePropertyName=function(e){if(this.options.ecmaVersion>=6){if(this.eat(V.bracketL))return e.computed=!0,e.key=this.parseMaybeAssign(),this.expect(V.bracketR),e.key;e.computed=!1}return e.key=this.type===V.num||this.type===V.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!==`never`)},U.initFunction=function(e){e.id=null,this.options.ecmaVersion>=6&&(e.generator=e.expression=!1),this.options.ecmaVersion>=8&&(e.async=!1)},U.parseMethod=function(e,t,n){var r=this.startNode(),i=this.yieldPos,a=this.awaitPos,o=this.awaitIdentPos;return this.initFunction(r),this.options.ecmaVersion>=6&&(r.generator=e),this.options.ecmaVersion>=8&&(r.async=!!t),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(Di(t,r.generator)|xi|(n?Si:0)),this.expect(V.parenL),r.params=this.parseBindingList(V.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(r,!1,!0,!1),this.yieldPos=i,this.awaitPos=a,this.awaitIdentPos=o,this.finishNode(r,`FunctionExpression`)},U.parseArrowExpression=function(e,t,n,r){var i=this.yieldPos,a=this.awaitPos,o=this.awaitIdentPos;return this.enterScope(Di(n,!1)|yi),this.initFunction(e),this.options.ecmaVersion>=8&&(e.async=!!n),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,e.params=this.toAssignableList(t,!0),this.parseFunctionBody(e,!0,!1,r),this.yieldPos=i,this.awaitPos=a,this.awaitIdentPos=o,this.finishNode(e,`ArrowFunctionExpression`)},U.parseFunctionBody=function(e,t,n,r){var i=t&&this.type!==V.braceL,a=this.strict,o=!1;if(i)e.body=this.parseMaybeAssign(r),e.expression=!0,this.checkParams(e,!1);else{var s=this.options.ecmaVersion>=7&&!this.isSimpleParamList(e.params);(!a||s)&&(o=this.strictDirective(this.end),o&&s&&this.raiseRecoverable(e.start,`Illegal 'use strict' directive in function with non-simple parameter list`));var c=this.labels;this.labels=[],o&&(this.strict=!0),this.checkParams(e,!a&&!o&&!t&&!n&&this.isSimpleParamList(e.params)),this.strict&&e.id&&this.checkLValSimple(e.id,Ni),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,ki,t?null:n)}},U.parseExprList=function(e,t,n,r){for(var i=[],a=!0;!this.eat(e);){if(a)a=!1;else if(this.expect(V.comma),t&&this.afterTrailingComma(e))break;var o=void 0;n&&this.type===V.comma?o=null:this.type===V.ellipsis?(o=this.parseSpread(r),r&&this.type===V.comma&&r.trailingComma<0&&(r.trailingComma=this.start)):o=this.parseMaybeAssign(!1,r),i.push(o)}return i},U.checkUnreserved=function(e){var t=e.start,n=e.end,r=e.name;this.inGenerator&&r===`yield`&&this.raiseRecoverable(t,`Cannot use 'yield' as identifier inside a generator`),this.inAsync&&r===`await`&&this.raiseRecoverable(t,`Cannot use 'await' as identifier inside an async function`),!(this.currentThisScope().flags&Ei)&&r===`arguments`&&this.raiseRecoverable(t,`Cannot use 'arguments' in class field initializer`),this.inClassStaticBlock&&(r===`arguments`||r===`await`)&&this.raise(t,`Cannot use `+r+` in class static initialization block`),this.keywords.test(r)&&this.raise(t,`Unexpected keyword '`+r+`'`),!(this.options.ecmaVersion<6&&this.input.slice(t,n).indexOf(`\\\\`)!==-1)&&(this.strict?this.reservedWordsStrict:this.reservedWords).test(r)&&(!this.inAsync&&r===`await`&&this.raiseRecoverable(t,`Cannot use keyword 'await' outside an async function`),this.raiseRecoverable(t,`The keyword '`+r+`' is reserved`))},U.parseIdent=function(e){var t=this.parseIdentNode();return this.next(!!e),this.finishNode(t,`Identifier`),e||(this.checkUnreserved(t),t.name===`await`&&!this.awaitIdentPos&&(this.awaitIdentPos=t.start)),t},U.parseIdentNode=function(){var e=this.startNode();return this.type===V.name?e.name=this.value:this.type.keyword?(e.name=this.type.keyword,(e.name===`class`||e.name===`function`)&&(this.lastTokEnd!==this.lastTokStart+1||this.input.charCodeAt(this.lastTokStart)!==46)&&this.context.pop(),this.type=V.name):this.unexpected(),e},U.parsePrivateIdent=function(){var e=this.startNode();return this.type===V.privateId?e.name=this.value:this.unexpected(),this.next(),this.finishNode(e,`PrivateIdentifier`),this.options.checkPrivateFields&&(this.privateNameStack.length===0?this.raise(e.start,`Private field '#`+e.name+`' must be declared in an enclosing class`):this.privateNameStack[this.privateNameStack.length-1].used.push(e)),e},U.parseYield=function(e){this.yieldPos||(this.yieldPos=this.start);var t=this.startNode();return this.next(),this.type===V.semi||this.canInsertSemicolon()||this.type!==V.star&&!this.type.startsExpr?(t.delegate=!1,t.argument=null):(t.delegate=this.eat(V.star),t.argument=this.parseMaybeAssign(e)),this.finishNode(t,`YieldExpression`)},U.parseAwait=function(e){this.awaitPos||(this.awaitPos=this.start);var t=this.startNode();return this.next(),t.argument=this.parseMaybeUnary(null,!0,!1,e),this.finishNode(t,`AwaitExpression`)};var ta=Pi.prototype;ta.raise=function(e,t){var n=ui(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},ta.raiseRecoverable=ta.raise,ta.curPosition=function(){if(this.options.locations)return new ci(this.curLine,this.pos-this.lineStart)};var na=Pi.prototype,ra=function(e){this.flags=e,this.var=[],this.lexical=[],this.functions=[]};na.enterScope=function(e){this.scopeStack.push(new ra(e))},na.exitScope=function(){this.scopeStack.pop()},na.treatFunctionsAsVarInScope=function(e){return e.flags&gi||!this.inModule&&e.flags&hi},na.declareName=function(e,t,n){var r=!1;if(t===Ai){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&hi&&delete this.undefinedExports[e]}else if(t===Mi)this.currentScope().lexical.push(e);else if(t===ji){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&bi&&s.lexical[0]===e)||!this.treatFunctionsAsVarInScope(s)&&s.functions.indexOf(e)>-1){r=!0;break}if(s.var.push(e),this.inModule&&s.flags&hi&&delete this.undefinedExports[e],s.flags&Ei)break}r&&this.raiseRecoverable(n,`Identifier '`+e+`' has already been declared`)},na.checkLocalExport=function(e){this.scopeStack[0].lexical.indexOf(e.name)===-1&&this.scopeStack[0].var.indexOf(e.name)===-1&&(this.undefinedExports[e.name]=e)},na.currentScope=function(){return this.scopeStack[this.scopeStack.length-1]},na.currentVarScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&(Ei|wi|Ci))return t}},na.currentThisScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&(Ei|wi|Ci)&&!(t.flags&yi))return t}};var ia=function(e,t,n){this.type=``,this.start=t,this.end=0,e.options.locations&&(this.loc=new li(e,n)),e.options.directSourceFile&&(this.sourceFile=e.options.directSourceFile),e.options.ranges&&(this.range=[t,0])},aa=Pi.prototype;aa.startNode=function(){return new ia(this,this.start,this.startLoc)},aa.startNodeAt=function(e,t){return new ia(this,e,t)};function oa(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}aa.finishNode=function(e,t){return oa.call(this,e,t,this.lastTokEnd,this.lastTokEndLoc)},aa.finishNodeAt=function(e,t,n,r){return oa.call(this,e,t,n,r)},aa.copyNode=function(e){var t=new ia(this,e.start,this.startLoc);for(var n in e)t[n]=e[n];return t};var sa=`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`,ca=`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`,la=ca+` Extended_Pictographic`,ua=la,da=ua+` EBase EComp EMod EPres ExtPict`,fa=da,pa={9:ca,10:la,11:ua,12:da,13:fa,14:fa},ma={9:``,10:``,11:``,12:``,13:``,14:`Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji`},ha=`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`,ga=`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`,_a=ga+` Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd`,va=_a+` Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho`,ya=va+` Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi`,ba=ya+` Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith`,xa={9:ga,10:_a,11:va,12:ya,13:ba,14:ba+` `+sa},Sa={};function Ca(e){var t=Sa[e]={binary:ai(pa[e]+` `+ha),binaryOfStrings:ai(ma[e]),nonBinary:{General_Category:ai(ha),Script:ai(xa[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 wa=0,Ta=[9,10,11,12,13,14];wa<Ta.length;wa+=1){var Ea=Ta[wa];Ca(Ea)}var W=Pi.prototype,Da=function(e,t){this.parent=e,this.base=t||this};Da.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},Da.prototype.sibling=function(){return new Da(this.parent,this.base)};var Oa=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=Sa[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};Oa.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)},Oa.prototype.raise=function(e){this.parser.raiseRecoverable(this.start,`Invalid regular expression: /`+this.source+`/: `+e)},Oa.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},Oa.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},Oa.prototype.current=function(e){return e===void 0&&(e=!1),this.at(this.pos,e)},Oa.prototype.lookahead=function(e){return e===void 0&&(e=!1),this.at(this.nextIndex(this.pos,e),e)},Oa.prototype.advance=function(e){e===void 0&&(e=!1),this.pos=this.nextIndex(this.pos,e)},Oa.prototype.eat=function(e,t){return t===void 0&&(t=!1),this.current(t)===e&&(this.advance(t),!0)},Oa.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 ka(e){for(var t in e)return!0;return!1}W.validateRegExpPattern=function(e){this.regexp_pattern(e),!e.switchN&&this.options.ecmaVersion>=9&&ka(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 Da(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&&Aa(n);)t+=oi(n),e.advance();return t};function Aa(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 ja(t)?(e.lastIntValue=t,e.advance(),!0):!1};function ja(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&&!ja(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)},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+=oi(e.lastIntValue);this.regexp_eatRegExpIdentifierPart(e);)e.lastStringValue+=oi(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),Ma(r)?(e.lastIntValue=r,!0):(e.pos=t,!1)};function Ma(e){return Vr(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),Na(r)?(e.lastIntValue=r,!0):(e.pos=t,!1)};function Na(e){return Hr(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&&!Ga(e.lookahead())&&(e.lastIntValue=0,e.advance(),!0)},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)},W.regexp_eatControlLetter=function(e){var t=e.current();return Pa(t)?(e.lastIntValue=t%32,e.advance(),!0):!1};function Pa(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)&&Fa(e.lastIntValue))return!0;r&&e.raise(`Invalid unicode escape`),e.pos=n}return!1};function Fa(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)},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 Ia=0,La=1,Ra=2;W.regexp_eatCharacterClassEscape=function(e){var t=e.current();if(za(t))return e.lastIntValue=-1,e.advance(),La;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===Ra&&e.raise(`Invalid property name`),r;e.raise(`Invalid property name`)}return Ia};function za(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),La}}if(e.pos=t,this.regexp_eatLoneUnicodePropertyNameOrValue(e)){var i=e.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(e,i)}return Ia},W.regexp_validateUnicodePropertyNameAndValue=function(e,t,n){ni(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 La;if(e.switchV&&e.unicodeProperties.binaryOfStrings.test(t))return Ra;e.raise(`Invalid property name`)},W.regexp_eatUnicodePropertyName=function(e){var t=0;for(e.lastStringValue=``;Ba(t=e.current());)e.lastStringValue+=oi(t),e.advance();return e.lastStringValue!==``};function Ba(e){return Pa(e)||e===95}W.regexp_eatUnicodePropertyValue=function(e){var t=0;for(e.lastStringValue=``;Va(t=e.current());)e.lastStringValue+=oi(t),e.advance();return e.lastStringValue!==``};function Va(e){return Ba(e)||Ga(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===Ra&&e.raise(`Negated character class may contain strings`),!0}return!1},W.regexp_classContents=function(e){return e.current()===93?La:e.switchV?this.regexp_classSetExpression(e):(this.regexp_nonEmptyClassRanges(e),La)},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||Ja(n))&&e.raise(`Invalid class escape`),e.raise(`Invalid escape`)}e.pos=t}var r=e.current();return r!==93&&(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=La,n;if(!this.regexp_eatClassSetRange(e)){if(n=this.regexp_eatClassSetOperand(e)){n===Ra&&(t=Ra);for(var r=e.pos;e.eatChars([38,38]);)e.current()!==38&&(n=this.regexp_eatClassSetOperand(e))?n!==Ra&&(t=La):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===Ra&&(t=Ra)}},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)?La: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===Ra&&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)===Ra&&(t=Ra);return t},W.regexp_classString=function(e){for(var t=0;this.regexp_eatClassSetCharacter(e);)t++;return t===1?La:Ra},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()&&Ha(n)||Ua(n)?!1:(e.advance(),e.lastIntValue=n,!0)};function Ha(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 Ua(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 Wa(t)?(e.lastIntValue=t,e.advance(),!0):!1};function Wa(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 Ga(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;Ga(n=e.current());)e.lastIntValue=10*e.lastIntValue+(n-48),e.advance();return e.pos!==t};function Ga(e){return e>=48&&e<=57}W.regexp_eatHexDigits=function(e){var t=e.pos,n=0;for(e.lastIntValue=0;Ka(n=e.current());)e.lastIntValue=16*e.lastIntValue+qa(n),e.advance();return e.pos!==t};function Ka(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function qa(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;e.lastIntValue=t<=3&&this.regexp_eatOctalDigit(e)?t*64+n*8+e.lastIntValue:t*8+n}else e.lastIntValue=t;return!0}return!1},W.regexp_eatOctalDigit=function(e){var t=e.current();return Ja(t)?(e.lastIntValue=t-48,e.advance(),!0):(e.lastIntValue=0,!1)};function Ja(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(!Ka(i))return e.pos=n,!1;e.lastIntValue=16*e.lastIntValue+qa(i),e.advance()}return!0};var Ya=function(e){this.type=e.type,this.value=e.value,this.start=e.start,this.end=e.end,e.options.locations&&(this.loc=new li(e,e.startLoc,e.endLoc)),e.options.ranges&&(this.range=[e.start,e.end])},G=Pi.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 Ya(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 Ya(this)},typeof Symbol<`u`&&(G[Symbol.iterator]=function(){var e=this;return{next:function(){var t=e.getToken();return{done:t.type===V.eof,value:t}}}}),G.nextToken=function(){var e=this.curContext();if((!e||!e.preserveSpace)&&this.skipSpace(),this.start=this.pos,this.options.locations&&(this.startLoc=this.curPosition()),this.pos>=this.input.length)return this.finishToken(V.eof);if(e.override)return e.override(this);this.readToken(this.fullCharCodeAtPos())},G.readToken=function(e){return Vr(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=Xr(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&&!Yr(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&&Zr.test(String.fromCharCode(e)))++this.pos;else break loop}}},G.finishToken=function(e,t){this.end=this.pos,this.options.locations&&(this.endLoc=this.curPosition());var n=this.type;this.type=e,this.value=t,this.updateContext(n)},G.readToken_dot=function(){var e=this.input.charCodeAt(this.pos+1);if(e>=48&&e<=57)return this.readNumber(!0);var t=this.input.charCodeAt(this.pos+2);return this.options.ecmaVersion>=6&&e===46&&t===46?(this.pos+=3,this.finishToken(V.ellipsis)):(++this.pos,this.finishToken(V.dot))},G.readToken_slash=function(){var e=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):e===61?this.finishOp(V.assign,2):this.finishOp(V.slash,1)},G.readToken_mult_modulo_exp=function(e){var t=this.input.charCodeAt(this.pos+1),n=1,r=e===42?V.star:V.modulo;return this.options.ecmaVersion>=7&&e===42&&t===42&&(++n,r=V.starstar,t=this.input.charCodeAt(this.pos+2)),t===61?this.finishOp(V.assign,n+1):this.finishOp(r,n)},G.readToken_pipe_amp=function(e){var t=this.input.charCodeAt(this.pos+1);return t===e?this.options.ecmaVersion>=12&&this.input.charCodeAt(this.pos+2)===61?this.finishOp(V.assign,3):this.finishOp(e===124?V.logicalOR:V.logicalAND,2):t===61?this.finishOp(V.assign,2):this.finishOp(e===124?V.bitwiseOR:V.bitwiseAND,1)},G.readToken_caret=function(){return this.input.charCodeAt(this.pos+1)===61?this.finishOp(V.assign,2):this.finishOp(V.bitwiseXOR,1)},G.readToken_plus_min=function(e){var t=this.input.charCodeAt(this.pos+1);return t===e?t===45&&!this.inModule&&this.input.charCodeAt(this.pos+2)===62&&(this.lastTokEnd===0||qr.test(this.input.slice(this.lastTokEnd,this.pos)))?(this.skipLineComment(3),this.skipSpace(),this.nextToken()):this.finishOp(V.incDec,2):t===61?this.finishOp(V.assign,2):this.finishOp(V.plusMin,1)},G.readToken_lt_gt=function(e){var t=this.input.charCodeAt(this.pos+1),n=1;return t===e?(n=e===62&&this.input.charCodeAt(this.pos+2)===62?3:2,this.input.charCodeAt(this.pos+n)===61?this.finishOp(V.assign,n+1):this.finishOp(V.bitShift,n)):t===33&&e===60&&!this.inModule&&this.input.charCodeAt(this.pos+2)===45&&this.input.charCodeAt(this.pos+3)===45?(this.skipLineComment(4),this.skipSpace(),this.nextToken()):(t===61&&(n=2),this.finishOp(V.relational,n))},G.readToken_eq_excl=function(e){var t=this.input.charCodeAt(this.pos+1);return t===61?this.finishOp(V.equality,this.input.charCodeAt(this.pos+2)===61?3:2):e===61&&t===62&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(V.arrow)):this.finishOp(e===61?V.eq:V.prefix,1)},G.readToken_question=function(){var e=this.options.ecmaVersion;if(e>=11){var t=this.input.charCodeAt(this.pos+1);if(t===46){var n=this.input.charCodeAt(this.pos+2);if(n<48||n>57)return this.finishOp(V.questionDot,2)}if(t===63)return e>=12&&this.input.charCodeAt(this.pos+2)===61?this.finishOp(V.assign,3):this.finishOp(V.coalesce,2)}return this.finishOp(V.question,1)},G.readToken_numberSign=function(){var e=this.options.ecmaVersion,t=35;if(e>=13&&(++this.pos,t=this.fullCharCodeAtPos(),Vr(t,!0)||t===92))return this.finishToken(V.privateId,this.readWord1());this.raise(this.pos,`Unexpected character '`+oi(t)+`'`)},G.getTokenFromCode=function(e){switch(e){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(V.parenL);case 41:return++this.pos,this.finishToken(V.parenR);case 59:return++this.pos,this.finishToken(V.semi);case 44:return++this.pos,this.finishToken(V.comma);case 91:return++this.pos,this.finishToken(V.bracketL);case 93:return++this.pos,this.finishToken(V.bracketR);case 123:return++this.pos,this.finishToken(V.braceL);case 125:return++this.pos,this.finishToken(V.braceR);case 58:return++this.pos,this.finishToken(V.colon);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(V.backQuote);case 48:var t=this.input.charCodeAt(this.pos+1);if(t===120||t===88)return this.readRadixNumber(16);if(this.options.ecmaVersion>=6){if(t===111||t===79)return this.readRadixNumber(8);if(t===98||t===66)return this.readRadixNumber(2)}case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.readNumber(!1);case 34:case 39:return this.readString(e);case 47:return this.readToken_slash();case 37:case 42:return this.readToken_mult_modulo_exp(e);case 124:case 38:return this.readToken_pipe_amp(e);case 94:return this.readToken_caret();case 43:case 45:return this.readToken_plus_min(e);case 60:case 62:return this.readToken_lt_gt(e);case 61:case 33:return this.readToken_eq_excl(e);case 63:return this.readToken_question();case 126:return this.finishOp(V.prefix,1);case 35:return this.readToken_numberSign()}this.raise(this.pos,`Unexpected character '`+oi(e)+`'`)},G.finishOp=function(e,t){var n=this.input.slice(this.pos,this.pos+t);return this.pos+=t,this.finishToken(e,n)},G.readRegexp=function(){for(var e,t,n=this.pos;;){this.pos>=this.input.length&&this.raise(n,`Unterminated regular expression`);var r=this.input.charAt(this.pos);if(qr.test(r)&&this.raise(n,`Unterminated regular expression`),e)e=!1;else{if(r===`[`)t=!0;else if(r===`]`&&t)t=!1;else if(r===`/`&&!t)break;e=r===`\\\\`}++this.pos}var i=this.input.slice(n,this.pos);++this.pos;var a=this.pos,o=this.readWord1();this.containsEsc&&this.unexpected(a);var s=this.regexpState||(this.regexpState=new Oa(this));s.reset(n,i,o),this.validateRegExpFlags(s),this.validateRegExpPattern(s);var c=null;try{c=new RegExp(i,o)}catch{}return this.finishToken(V.regexp,{pattern:i,flags:o,value:c})},G.readInt=function(e,t,n){for(var r=this.options.ecmaVersion>=12&&t===void 0,i=n&&this.input.charCodeAt(this.pos)===48,a=this.pos,o=0,s=0,c=0,l=t??1/0;c<l;++c,++this.pos){var u=this.input.charCodeAt(this.pos),d=void 0;if(r&&u===95)i&&this.raiseRecoverable(this.pos,`Numeric separator is not allowed in legacy octal numeric literals`),s===95&&this.raiseRecoverable(this.pos,`Numeric separator must be exactly one underscore`),c===0&&this.raiseRecoverable(this.pos,`Numeric separator is not allowed at the first of digits`),s=u;else{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 Xa(e,t){return t?parseInt(e,8):parseFloat(e.replace(/_/g,``))}function Za(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=Za(this.input.slice(t,this.pos)),++this.pos):Vr(this.fullCharCodeAtPos())&&this.raise(this.pos,`Identifier directly after number`),this.finishToken(V.num,n)},G.readNumber=function(e){var t=this.pos;!e&&this.readInt(10,void 0,!0)===null&&this.raise(t,`Invalid number`);var n=this.pos-t>=2&&this.input.charCodeAt(t)===48;n&&this.strict&&this.raise(t,`Invalid number`);var r=this.input.charCodeAt(this.pos);if(!n&&!e&&this.options.ecmaVersion>=11&&r===110){var i=Za(this.input.slice(t,this.pos));return++this.pos,Vr(this.fullCharCodeAtPos())&&this.raise(this.pos,`Identifier directly after number`),this.finishToken(V.num,i)}n&&/[89]/.test(this.input.slice(t,this.pos))&&(n=!1),r===46&&!n&&(++this.pos,this.readInt(10),r=this.input.charCodeAt(this.pos)),(r===69||r===101)&&!n&&(r=this.input.charCodeAt(++this.pos),(r===43||r===45)&&++this.pos,this.readInt(10)===null&&this.raise(t,`Invalid number`)),Vr(this.fullCharCodeAtPos())&&this.raise(this.pos,`Identifier directly after number`);var a=Xa(this.input.slice(t,this.pos),n);return this.finishToken(V.num,a)},G.readCodePoint=function(){var e=this.input.charCodeAt(this.pos),t;if(e===123){this.options.ecmaVersion<6&&this.unexpected();var n=++this.pos;t=this.readHexChar(this.input.indexOf(`}`,this.pos)-this.pos),++this.pos,t>1114111&&this.invalidStringToken(n,`Code point out of bounds`)}else t=this.readHexChar(4);return t},G.readString=function(e){for(var t=``,n=++this.pos;;){this.pos>=this.input.length&&this.raise(this.start,`Unterminated string constant`);var r=this.input.charCodeAt(this.pos);if(r===e)break;r===92?(t+=this.input.slice(n,this.pos),t+=this.readEscapedChar(!1),n=this.pos):r===8232||r===8233?(this.options.ecmaVersion<10&&this.raise(this.start,`Unterminated string constant`),++this.pos,this.options.locations&&(this.curLine++,this.lineStart=this.pos)):(Yr(r)&&this.raise(this.start,`Unterminated string constant`),++this.pos)}return t+=this.input.slice(n,this.pos++),this.finishToken(V.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===V.template||this.type===V.invalidTemplate)?n===36?(this.pos+=2,this.finishToken(V.dollarBraceL)):(++this.pos,this.finishToken(V.backQuote)):(e+=this.input.slice(t,this.pos),this.finishToken(V.template,e));if(n===92)e+=this.input.slice(t,this.pos),e+=this.readEscapedChar(!0),t=this.pos;else if(Yr(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)}this.options.locations&&(++this.curLine,this.lineStart=this.pos),t=this.pos}else++this.pos}},G.readInvalidTemplateToken=function(){for(;this.pos<this.input.length;this.pos++)switch(this.input[this.pos]){case`\\\\`:++this.pos;break;case`$`:if(this.input[this.pos+1]!==`{`)break;case\"`\":return this.finishToken(V.invalidTemplate,this.input.slice(this.start,this.pos));case`\\r`:this.input[this.pos+1]===`\n`&&++this.pos;case`\n`:case`\\u2028`:case`\\u2029`:++this.curLine,this.lineStart=this.pos+1}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 oi(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 Yr(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(Hr(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?Vr:Hr)(o,r)||this.invalidStringToken(a,`Invalid Unicode escape`),e+=oi(o),n=this.pos}else break;t=!1}return e+this.input.slice(n,this.pos)},G.readWord=function(){var e=this.readWord1(),t=V.name;return this.keywords.test(e)&&(t=Kr[e]),this.finishToken(t,e)},Pi.acorn={Parser:Pi,version:`8.19.0`,defaultOptions:di,Position:ci,SourceLocation:li,getLineInfo:ui,Node:ia,TokenType:z,tokTypes:V,keywordTypes:Kr,TokContext:Yi,tokContexts:Xi,isIdentifierChar:Hr,isIdentifierStart:Vr,Token:Ya,isNewLine:Yr,lineBreak:qr,lineBreakG:Jr,nonASCIIwhitespace:Zr};function $a(e,t){return Pi.parse(e,t)}var eo={ecmaVersion:`latest`,sourceType:`script`,allowReturnOutsideFunction:!0},to=/\\w+(?![\\p{ID_Continue}$\\u200c\\u200d])/uy,no=/[A-Za-z_]\\w*(?![\\p{ID_Continue}$\\u200c\\u200d])/uy,ro=/^[$_]\\w+$/,io=/[\\n\\r\\u2028\\u2029]/,ao=/\\s*(?:[;},:)]|=(?![=>]))/y;function oo(e,t){return ao.lastIndex=t,ao.test(e)}var so=new Set([V.name,V.num,V.string,V.regexp,V.backQuote,V.bracketR,V.braceR,V.parenR,V.incDec,V._this,V._null,V._true,V._false]),co=class extends Pi{constructor(...e){super(...e),this.operandBeforeLast=!0,this.operandHere=!0,this.breakBeforeLast=!1,this.breakHere=!1,this.ternaries=[],this.colonEndsTernary=!1,this.closedBlock=!1,this.typeBeforeLast=V.eof,this.lookahead=!0}readToken(e){let t=this;if(t.lastTokEnd=t.end,this.operandBeforeLast=this.operandHere,this.operandHere=t.exprAllowed,this.breakBeforeLast=this.breakHere,this.breakHere=io.test(t.input.slice(t.end,t.pos)),e===64||e===37){let n=t.pos,r=e===64?to:no;r.lastIndex=n+1;let i=r.exec(t.input)?.[0];if(i){let r=n+1+i.length,a=t.type===V.incDec&&(this.operandBeforeLast||this.breakBeforeLast),o=e===37?this.percentAt?.get(n):void 0;if(e===64||(o??(t.exprAllowed||a||this.lookahead&&lo(t,r)))){e===37&&this.transientsRead?.add(n),t.pos=r,t.finishToken(V.name,t.input.charAt(n)+i);return}}}super.readToken(e)}finishToken(e,t){let{context:n}=this,r=n.length;if(e===V.braceR){let e=n[r-1];this.closedBlock=e.token===`{`&&!e.isExpr}else if(e===V.question)this.ternaries[r]=(this.ternaries[r]??0)+1;else if(e===V.colon){let e=this.ternaries[r]??0;this.colonEndsTernary=e>0,e>0&&(this.ternaries[r]=e-1)}let i=this,a=i.type;this.prevValue=i.value;let o=e.keyword!==void 0&&(a===V.dot||a===V.questionDot)||(e===V._function||e===V._class)&&oo(i.input,i.pos);if(!o&&(e===V._function||e===V._class)){let t=e===V._function&&a===V.name&&this.prevValue===`async`&&!this.breakHere?this.typeBeforeLast:a;i.type=t===V.colon&&this.colonEndsTernary?V.parenL:t}this.typeBeforeLast=a,super.finishToken(o?V.name:e,t),e===V.name&&t===`of`&&(a===V._const||a===V._var||this.prevValue===`let`)&&(i.exprAllowed=!1)}braceIsBlock(e){if(e===V.colon&&this.colonEndsTernary)return!1;if(e===V.braceR&&this.closedBlock||e===V.name&&this.prevValue===`static`)return!0;if(this.breakHere&&so.has(e)){let{context:e}=this,t=e[e.length-1];if(t.token===`{`&&!t.isExpr)return!0}return super.braceIsBlock(e)}};function lo(e,t){if(!io.test(e.input.slice(e.end,e.pos)))return!1;let n=po(e.input,t,`statements`,{afterOperand:!0});n.lookahead=!1;let r=0;try{for(;;){n.nextToken();let e=n.type;if(e===V.eof)return!1;if(r>0)uo.has(e)?r++:fo.has(e)&&r--;else if(e===V.bracketL)r=1;else if(e===V.dot){if(n.nextToken(),n.type!==V.name&&!n.type.keyword)return!1}else return e===V.eq||e===V.assign}}catch{return!1}}var uo=new Set([V.parenL,V.bracketL,V.braceL,V.dollarBraceL]),fo=new Set([V.parenR,V.bracketR,V.braceR]);function po(e,t,n,{onComment:r,afterOperand:i=!1}={}){let a=new co(r?{...eo,onComment:r}:eo,e,t);return n===`expression`&&(a.type=V.parenL),i&&(a.exprAllowed=!1),a}var mo=class extends SyntaxError{constructor(e,t,n,r){super(`${e} ${_o(t,n)}`+ho(r,e=>go(t,e))),this.reason=e,this.source=t,this.pos=n,this.bracket=r,this.name=`SyntaxError`}reasonIn(e,t){return this.reason+ho(this.bracket,n=>{let{line:r,column:i}=ui(e,t+n);return`at line ${r}, column ${i+1}`})}};function ho(e,t){return e?` (missing \"${e.closer}\" for the \"${e.open}\" ${t(e.pos)})`:``}function go(e,t){let{line:n,column:r}=ui(e,t);return io.test(e)?`at line ${n}, column ${r+1}`:`at column ${r+1}`}function _o(e,t){let{column:n}=ui(e,t),r=t-n,i=e.slice(r).search(io),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`${go(e,t)}: ${c.trim()}`}var vo=e=>e[e.length-1],yo={\"(\":`)`,\"[\":`]`,\"{\":`}`,\"${\":`}`};function bo(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}=xo(e,n),o=n>=e.length||a===``,s=!1;r===`Unexpected token`?(r=o?`Unexpected end of code`:`Unexpected \"${a}\"`,s=!!i&&yo[i.text]!==a&&(o||[`)`,`]`,`}`,`;`,`{`].includes(a))):r.startsWith(`Unterminated template`)&&(s=i?.text===\"${\");let c=s&&i?{open:i.text,closer:yo[i.text],pos:i.pos}:void 0;return new mo(r,e,n,c)}function xo(e,t){let n=[];for(let r of Fo(e,0,`statements`)){if(`error`in r)break;if(r.start>=t||r.type===V.eof)return{open:vo(n),token:e.slice(r.start,r.end)};let i=e.slice(r.start,r.end);i in yo?n.push({text:i,pos:r.start}):n.length&&yo[vo(n).text]===i&&n.pop()}return{open:vo(n),token:e.charAt(t)}}function So(e,t=`expression`){let n=new Map;for(;;){let r=new Set;try{let i=Co(e,t,n,r),a={refs:[],strings:[]};return Oo(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)||(no.lastIndex=i+1,e.charAt(i)!==`%`||!no.test(e)))throw t;n.set(i,!r.has(i))}}}function Co(e,t,n,r){try{let i=po(e,0,t);if(i.percentAt=n,i.transientsRead=r,t===`statements`)return i.parse();i.nextToken();let a=i.parseExpression();if(i.type!==V.eof)throw Object.assign(SyntaxError(`Unexpected token`),{pos:i.start});return a}catch(t){throw bo(e,t)}}var wo=e=>typeof e==`object`&&!!e&&typeof e.type==`string`,To={$:`story`,_:`temporary`,\"@\":`local`,\"%\":`transient`};function Eo(e,t){let n=e.name,r=t.charAt(e.start);return r===n.charAt(0)&&(r===`@`||r===`%`||(r===`$`||r===`_`)&&ro.test(n))?[r,n.slice(1)]:null}function Do(e,t){if(!wo(e)||e.type!==`Identifier`)return;let n=t.charAt(e.start);if(n===`@`||n===`%`)throw new mo(`\"${e.name}\" can't be a property name`,t,e.start)}function Oo(e,t,n,r,i){if(Array.isArray(e)){for(let i of e)Oo(i,t,n,r,!1);return}if(!wo(e))return;let a=(e,r=!1,i=!1)=>Oo(e,t,n,r,i);switch(e.type){case`Identifier`:{let a=Eo(e,t);if(!a)return;if(r)throw new mo(`\"${e.name}\" is a ${To[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):Do(e.property,t);return;case`Property`:if(e.computed?a(e.key):e.shorthand||Do(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):Do(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 ko=/[\\p{ID_Continue}$.]*/uy,Ao=/[\\p{ID_Continue}$]*/uy,jo=new Set([`of`,`get`,`set`,`static`,`async`]);function Mo(e,t,{goal:n=`expression`,stop:r}={}){let i=Po(e,t,n,r);return i<0&&!r?No(e,t,n):i}function No(e,t,n){let r=po(e,t,n);try{if(n===`statements`)r.parse();else if(r.nextToken(),r.parseExpression(),r.type===V.braceR)return r.start}catch(t){let n=t.pos??-1;if(e.charAt(n)===`}`)return n}return-1}function Po(e,t,n,r){let i=[],a=-1,o=!1,s=t,c=!1,l=!1;for(;;){let t=-1;for(let u of Fo(e,s,n,{afterOperand:c})){if(`error`in u){let{message:n}=u.error,a=i.includes(\"${\");if(!/^Unterminated/.test(n)&&!a){if(t=Math.max(u.pos,s)+1,c=!1,t>=e.length)return-1;break}let o=i.lastIndexOf(\"${\");if(!/^Unterminated template/.test(n)||o<0||l||r)return-1;l=!0,i.length=o,t=u.pos,c=!0;break}if(u.restarted&&i.includes(\"${\"))return-1;let n=u.type;if(n===V.eof||n===V.string&&o&&u.start===a)return-1;if(o=n===V.name&&!jo.has(u.value)||n===V.num,a=u.end,n===V.braceL){if(r?.(u.start))return u.start;i.push(`{`)}else if(n===V.dollarBraceL)i.push(\"${\");else if(n===V.parenL)i.push(`(`);else if(n===V.bracketL)i.push(`[`);else if(n===V.parenR||n===V.bracketR)vo(i)===(n===V.parenR?`(`:`[`)&&i.pop();else if(n===V.braceR){let e=Math.max(i.lastIndexOf(`{`),i.lastIndexOf(\"${\"));if(e>=0)i.length=e;else if(!r)return u.start}}s=t,o=!1}}function*Fo(e,t,n,r={}){let i=po(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=po(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}=Ho(e,n);if(r){yield o(V.string,n,t);continue}}else if(!c&&i.start<=n&&(s===`\"`||s===`'`)){let{end:t,closed:n}=Ho(e,i.start);if(n){yield o(V.string,i.start,t);continue}}else if(!c&&i.start<=n&&s===`/`){let t=Bo(e,i.start);if(t>0){yield o(V.regexp,i.start,t);continue}}else if(!c&&i.start<=n&&/[\\d.]/.test(s)&&/\\d/.test(e.slice(i.start,i.start+2))){ko.lastIndex=i.start,ko.test(e),yield o(V.num,i.start,ko.lastIndex);continue}yield{error:t,pos:n};return}if(yield{type:i.type,start:i.start,end:i.end,value:i.value},i.type===V.eof)return}}function Io(e,t,n=`expression`){return Lo(e,0,t,0,n,!1)}function Lo(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=Fo(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=Fo(e,m,i,{onComment:s}),h=void 0;continue}let o=t.type;if(o===V.eof)return u(m,e.length),e.length;if(u(m,t.start),o===V.name){let i=Ro(e,t.start,t.value),a=h===V.dot||h===V.questionDot||(i===`$`||i===`_`)&&zo(e,t.end,h);i&&!a?n.variable?.(i,t.value.slice(1),t.start,r,t.end):c(t.start,t.end)}else if(o===V.string||o===V.regexp||o===V.template||o===V.invalidTemplate)l(t.start,t.end);else if(o===V.backQuote){if(l(t.start,t.end),h===V.template||h===V.invalidTemplate){if(f--,a&&f===0)return t.end}else f++}else o===V.dollarBraceL?(l(t.start,t.end),d.push(\"${\"),r++):o===V.braceR&&vo(d)===\"${\"?(d.pop(),r--,l(t.start,t.end)):(o===V.braceL||o===V.parenL||o===V.bracketL?d.push(e.charAt(t.start)):(o===V.braceR||o===V.parenR||o===V.bracketR)&&d.length&&vo(d)!==\"${\"&&d.pop(),c(t.start,t.end));h=o,m=t.end}}function Ro(e,t,n){let r=e.charAt(t);return(r===`@`||r===`%`)&&n.charAt(0)===r||(r===`$`||r===`_`)&&ro.test(n)?r:null}function zo(e,t,n){if(n!==V.braceL&&n!==V.comma)return!1;let r=/\\S/g;r.lastIndex=t;let i=r.exec(e)?.[0];return i===`:`||i===`(`}function Bo(e,t){let n=!1;for(let r=t+1;r<e.length;r++){let t=e.charAt(r);if(io.test(t))return-1;if(t===`\\\\`)r++;else if(t===`[`)n=!0;else if(t===`]`)n=!1;else if(t===`/`&&!n)return Ao.lastIndex=r+1,Ao.test(e),Ao.lastIndex}return-1}function Vo(e){if(e[0]!==`\"`&&e[0]!==`'`)return null;try{let t=po(e,0,`expression`);return t.nextToken(),t.type===V.string&&t.end===e.length?t.value:null}catch{return null}}function Ho(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 Uo=/[\\p{L}\\p{N}_\\\\]/u;function Wo(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=Go(e,i+2);if(t===-1)return-1;i=t+1}else i++}return-1}function Go(e,t){Ko!==e&&(Ko=e,qo.clear());let n=qo.get(t);return n===void 0&&(n=Jo(e,t),qo.set(t,n)),n}var Ko=``,qo=new Map;function Jo(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&&Uo.test(e[t-1]))){let n=Wo(e,t);t=n===-1?t+1:n}else t++}return-1}var Yo={closeBrace(e,t,n){let r=Mo(e,t);return r===-1?Go(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=Mo(e,t,{goal:`statements`,stop:t=>(o.lastIndex=t,o.test(e))});return s===-1?a:s}};function Xo(e){let t=e.toLowerCase();return t.startsWith(`on`)||t===`pattern`||t===`srcdoc`}function Zo(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=Vn(e[r])?Yo.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={...Yo,isBlock:fr,isRaw:dr,isCodeAttribute:Xo},$o=class extends Error{constructor(e,t,n,r,i=`syntax`,a=t,o={}){super(`${e} (line ${n}, column ${r})`),this.reason=e,this.offset=t,this.line=n,this.column=r,this.code=i,this.end=a,this.data=o,this.name=`MarkupError`}};function es(e,t,n){let r=n.hooks?{...Qo,...n.hooks}:Qo;try{return or(e,{startRule:t,text:n.text===!0,hooks:r})}catch(t){let{location:n,code:r}=t;if(t instanceof Error&&t.name===`SyntaxError`&&n){let{offset:i}=n.start,{line:a,column:o}=vr(e,i);throw new $o(t.message,i,a,o,r,n.end.offset)}throw t}}function ts(e,t={}){let{tokens:n,errors:r,damage:i}=os(e,t),a={...Qo,...t.hooks},o=Dr(n,{isBlock:a.isBlock,isRaw:a.isRaw,source:e});if(r.length===0&&o.errors.length===0)return{tokens:n,nodes:o.nodes,errors:r};let s=e=>r.some((t,n)=>e>=i[n]&&e<=t.offset),c=r.map((e,t)=>[i[t]+.5,e]);for(let t of o.errors)s(t.start)||c.push([t.noticedAt,rs(e,t)]);return c.sort((e,t)=>e[0]-t[0]),{tokens:n,nodes:o.nodes,errors:c.map(([,e])=>e)}}function ns(e,t={}){let{nodes:n,errors:r}=ts(e,t);if(r.length>0)throw r[0];return gr(n)}function rs(e,t){let{line:n,column:r}=vr(e,t.start);return new $o(t.message,t.start,n,r,t.code,t.end,t.data)}function is(e,t={}){return es(e,`Tokens`,t)}function as(e,t={}){let{tokens:n,errors:r}=os(e,t);return{tokens:n,errors:r}}function os(e,t){let n=[],r=[],i=[],a=e.lastIndexOf(`}`),{closeBrace:o}={...Qo,...t.hooks},s=(e,n)=>{let r={...t.hooks,closeBrace:(e,t,r)=>n+Math.min(t,r)>a?-1:o(e,t,r)};try{return is(e,{...t,hooks:r}).map(e=>ls(e,n))}catch(e){if(!(e instanceof $o))throw e;return e}},c=0;for(;c<=e.length;){let t=e.slice(c),a=s(t,c);if(Array.isArray(a)){n.push(...a);break}let o=c+a.offset,{line:l,column:u}=vr(e,o);r.push(new $o(a.reason,o,l,u,a.code,c+a.end));let d=a.offset,f=s(t.slice(0,d),c);for(;!Array.isArray(f);)d=f.offset,f=s(t.slice(0,d),c);if(n.push(...f),i.push(c+d),d<t.length){let e=c+d;n.push({type:`text`,value:t[d],start:e,end:e+1})}c+=d+1}return{tokens:n,errors:r,damage:i}}var ss=/^(start|end|[A-Za-z]*(Start|End))$/;function cs(e,t){let n={...e};for(let[e,r]of Object.entries(n))typeof r==`number`&&ss.test(e)?n[e]=t(r):e===`attributeSpans`&&(n[e]=r.map(e=>cs(e,t)));return n}function ls(e,t){return t===0?e:cs(e,e=>e+t)}var us=`__proto__`;function ds(e,t=e){return e===`__proto__`?`\"${t}\" cannot be used as a variable name (${us} is reserved)`:void 0}function fs(e,t=e){let n=ds(e,t);if(n)throw TypeError(`spindle: ${n}`)}var ps=e=>/^(?:0|[1-9]\\d*)$/.test(e),K=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),ms=(e,t)=>e&&K(e,t)?e[t]:void 0;function hs(e,t,n){t===`__proto__`?Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0,configurable:!0}):e[t]=n}function gs(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)=>gs(e),_s=e=>Object.getPrototypeOf(e)===null,vs=e=>_s(e)?e:q(e);function ys(e,t,n){let r=q(e);return r[t]=n,r}var bs=Object.freeze(q());function xs(e,t){return[...new Set([...Object.keys(e),...Object.keys(t)])].filter(n=>ms(e,n)!==ms(t,n))}var Ss=e=>typeof e==`number`&&Number.isInteger(e)&&e>=0;function Cs(e,t){let n=ms(e,t);return Ss(n)?n:0}function ws(e,t){let n=gs([e],Ss);return t!==void 0&&(n[t]=Cs(e,t)+1),n}var Ts=new sr;function Es(e,t,n,r=!1,i={}){let a=n.filter(e=>e!==`@children`);for(let e of a)e.startsWith(`@`)&&fs(e.slice(1),e);Ts.set(e,{body:t,params:a,holds:i,isBlock:r})}function Ds(e){return Ts.get(e)}function Os(){return[...Ts].map(([e,{params:t,holds:n}])=>({name:e,widget:{params:t,holds:n}}))}function ks(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 As(e,t){return e instanceof Error?e.message||t||String(e):typeof e==`string`&&e!==``?e:t??String(e)}function js(){let e=new Set;return{subscribe(t){return e.add(t),()=>{e.delete(t)}},notify(){for(let t of[...e])t()}}}var Ms=[],Ns=1,Ps=js();function Fs(e){Ms=e,Ps.notify()}function Is(e,t){let n=As(t).replace(/^spindle: /,``),r=Ms.find(t=>t.context===e&&t.message===n);Fs(r?Ms.map(e=>e===r?{...e,count:e.count+1}:e):[...Ms,{id:Ns++,context:e,message:n,count:1}])}function Ls(e,t){return Error(`No passage named ${JSON.stringify(e)} (in passage ${JSON.stringify(t)})`)}function Rs(e){Fs(Ms.filter(t=>t.id!==e))}function zs(){return Ms}var Bs=Ps.subscribe;function Vs(e){return/\\s/.test(e)}function Hs(e){return e===`(`||e===`[`||e===`{`}function Us(e){return e===`)`||e===`]`||e===`}`}function Ws(e){return e.replace(/\\\\([\"'\\\\])/g,`$1`)}function Gs(e,t){let n=e[t];if(n!==`\"`&&n!==`'`)return null;let{end:r,closed:i}=Ho(e,t);return i?{value:Ws(e.slice(t+1,r-1)),end:r}:null}function Ks(e){let t=Gs(e,0);return t&&t.end===e.length?t.value:null}function qs(e){return/^[\"']?(.+?)[\"']?$/s.exec(e)?.[1]??e}var Js=/(?:[-+*/%&|^!~=<>?:,.]|(?:^|[^\\w$@.])(?:typeof|void|new|delete|in|instanceof|await|yield))$/;function Ys(e){let t=-1;if(Io(e,{code(e,n,r){r===0&&!Vs(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)&&Js.test(n)}function Xs(e,t){let n=[],r=0;return Io(e,{code(e,i,a){a>0||(Hs(e)?r++:Us(e)?r--:r===0&&t(e)&&n.push(i))}}),n}function Zs(e,t){let n=[],r=0;for(let i of Xs(e,t))n.push([r,i]),r=i+1;return n.push([r,e.length]),n}function Qs(e){return $s(e)&&!Ys(e)}function $s(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 ec(e){let t=Zs(e,Vs).filter(([e,t])=>t>e);if(t.length<2)return null;for(let[n,r]of t)if(!Qs(e.slice(n,r)))return null;return t}function tc(e,[t,n]){let r=e.slice(t,n),i=r.length-r.trimStart().length;return[t+i,Math.max(t+i,n-(r.length-r.trimEnd().length))]}function nc(e){let t=Zs(e,e=>e===`,`).map(t=>tc(e,t)),n=t.length>1,r=t[t.length-1];if(r[0]===r[1]&&t.pop(),!n&&t.length===1){let[n,r]=t[0],i=ec(e.slice(n,r));if(i)return i.map(([e,t])=>[n+e,n+t])}return t}function rc(e){return nc(e).map(([t,n])=>e.slice(t,n))}function ic(e){let t=[],n=0;for(let r of[...Xs(e,Vs),e.length])r>n&&t.push([n,r]),n=r+1;return t}var ac=(e,[t,n])=>e.slice(t,n);function oc(e){return Ks(e)??qs(e)}var sc=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 cc(e,t,n){switch(n.spans?.set(e,[n.at,n.at+t.length]),e.type){case`string`:{let n=Ks(t);if(n===null)throw new sc(e,t);return n}case`text`:return oc(t);case`names`:return t.split(`,`).map(e=>e.trim());case`delay`:return ks(t);case`number`:return Number(t);case`options`:return mc(e.parameters??[],t,n);default:return t}}function lc(e){return e.type===`flag`||e.type===`separator`?!1:e.type===`options`?{}:void 0}var uc=/\\w+/y,dc=/[-+]?(?:\\d+\\.?\\d*|\\.\\d+)/y,fc=/\\S+/y;function pc(e,t,n){return e.lastIndex=n,e.exec(t)?.[0]??null}function mc(e,t,{at:n,spans:r}){let i={},a=0;for(;a<t.length;){let o=pc(uc,t,a);if(!o){a=Gs(t,a)?.end??a+1;continue}a+=o.length;let s,c=a;for(;c<t.length&&Vs(t[c]);)c++;let l=Gs(t,c),u=l||c===a?null:pc(dc,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 sc(d,pc(fc,t,c)??``);d?.type===`flag`?i[o]=!0:d?.type===`number`?i[o]=Number(s??0):d&&(i[o]=s)}return i}var hc=/^(?:[-+*/&|^=<>?:,.]|%(?![A-Za-z_]))/;function gc(e,t,n){let r=ic(e);if(r.length===1)return n&&ac(e,r[0])===t?[e.length,e.length]:null;if(r.length<2)return null;if(ac(e,r[r.length-1])===t){let t=[0,r[r.length-2][1]];if(!Ys(ac(e,t)))return t}if(ac(e,r[0])===t){let t=[r[1][0],e.length];if(!hc.test(ac(e,t)))return t}return null}function _c(e,t){if(t===`=`){let t=Xs(e,e=>e===`=`);for(let n=0;n<t.length;n++){let r=t[n];if(e[r+1]===`=`)n++;else if(e[r-1]!==`!`)return[r,r+1]}return null}let n=ic(e);for(let r=1;r<n.length-1;r++)if(ac(e,n[r])===t)return[n[r-1][1],n[r+1][0]];return null}var vc=e=>e.type===`expression`||e.type===`statements`||e.type===`passage`||e.type===`text`;function yc(e,t){let n=e.trim();return[n,n?t+e.indexOf(n):t]}function bc(e,t,n,{at:r,spans:i}){let[a,o]=yc(t??``,r),s=!e.some(e=>e.type!==`flag`&&e.required);for(let r of e.filter(e=>e.type===`flag`)){let e=t===null?null:gc(a,r.name,s);n[r.name]=e!==null,e&&([a,o]=yc(ac(a,e),o+e[0]))}let c=e.filter(e=>e.type!==`flag`);if(c.length===0)return;let l=c.findIndex((e,t)=>vc(e)&&!c.slice(t+1).some(vc)),u=l<0?c.length-1:l,d=(e,[t,n])=>t===n?lc(e):cc(e,a.slice(t,n),{at:o+t,spans:i});if(c.length===1){n[c[0].name]=d(c[0],[0,a.length]);return}let f=ic(a),p=0,m=f.length;for(let e of c.slice(0,u))n[e.name]=p<m?d(e,f[p++]):lc(e);let h=(e,t)=>{try{return d(e,t)}catch(e){if(e instanceof sc)return;throw e}};for(let e of c.slice(u+1).reverse()){let t=p<m&&!Ys(a.slice(0,f[m-1][0]))?h(e,f[m-1]):void 0;n[e.name]=t??lc(e),t===void 0?i?.delete(e):m--}let g=c[u];n[g.name]=p<m?d(g,[f[p][0],f[m-1][1]]):lc(g)}var xc={name:`delay`,type:`delay`,required:!0};function Sc(e,t,n){let r={},[i,a]=yc(e,0),o=0;return t.forEach((e,s)=>{if(e.type!==`separator`)return;let c=i===null?null:_c(i,e.name);r[e.name]=c!==null;let l=c?i.slice(0,c[0]):i;bc(t.slice(o,s),l,r,{at:a,spans:n}),i=c?i.slice(c[1]):null,c&&(a+=c[1]),o=s+1}),bc(t.slice(o),i,r,{at:a,spans:n}),r}function Cc(e){let t=e.trim(),n=Vo(t);return n===null?{kind:`expression`,expression:t}:{kind:`name`,name:n}}function wc(e,t,{storyData:n,currentPassage:r}){let i=String(t(e??``));if(n&&!n.passages.has(i))throw Ls(i,r);return i}function Tc(e){let t=e.trim(),n=ic(t)[0];return n?ac(t,n):``}function Ec(e){let{variable:t=``,placeholder:n=``}=Sc(e,[{name:`variable`,type:`variable`},{name:`placeholder`,type:`string`}]);return{varName:t.replace(/[\"']/g,``),placeholder:n}}var Dc=[{name:`value`,type:`string`,holds:`text`,required:!0}],Oc=new Map([[`option`,Dc]]);function kc(e){return Oc.get(e.toLowerCase())}function Ac(e){let t=[];for(let n of e)if(n.type===`macro`&&n.name===`option`){let{value:e}=Sc(n.rawArgs,Dc);t.push(e??``)}return t}var jc=null;function Mc(e){let t=jc;jc=new Map;try{return e()}finally{jc=t}}function Nc(e,t){let n=t[0]+e,r=jc?.get(n);if(r)return r;try{r=So(e,t)}catch(e){if(!(e instanceof mo))throw e;r=e}return jc?.set(n,r),r}function Pc(e,t){return e.sourceOffsets?.[t]??e.offset+t}function Fc(e){return e.kind===`code`?e.code.length:e.kind===`text`?e.text.length:e.length}var Ic=new Set([`if`,`elseif`,`case`]),Lc=new Set([`dialog`]);function Rc(e,t={}){if(e.some(e=>K(t,e)))return e.map(e=>({name:e,...K(t,e)?{holds:t[e]}:{}}))}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 Bc(e){let t=new sr,n=new sr;for(let{name:r,parameters:i,interpolate:a,widget:o}of e){i&&t.set(r,zc(i,Vc(a)));let e=o&&Rc(o.params,o.holds);e&&n.set(r,e)}let r=e=>{let n=t.get(e);if(!n){let r=kc(e);r&&t.set(e,n=zc(r,`text`))}return n};return n.size>0&&(r.widget=e=>n.get(e)),r}var Vc=e=>e?`markup`:`text`;function Hc(e){if(e.type===`expression`||e.type===`passage`)return`expression`;if(e.type===`statements`)return`statements`}function Uc(e){if(e.type===`string`||e.type===`text`)return e.holds??`markup`}function*Wc(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 el(a.display,a.displayStart,`In the label of a link: `));else if(a.type===`expression`)yield{kind:`code`,code:a.expression,offset:a.expressionStart,goal:`expression`,label:`{${a.expression}}`};else if(a.type===`html`)for(let{name:t,value:n,at:r}of tl(e,a))if(!Xo(t))yield el(n,r,`In the ${t} attribute of <${a.tag}>: `);else for(let{expr:e,at:i}of nl(n))yield{kind:`code`,code:e,offset:r+i,goal:`expression`,label:`{${e}} in the ${t} attribute of <${a.tag}>`};else if(a.type===`macro`&&!a.isClose){let o=a.name.toLowerCase();if(o===`do`){let n=r(i,o);if(n<0)continue;yield{kind:`code`,code:e.slice(a.end,t[n].start),offset:a.end,goal:`statements`,label:`{do}`},i=n;continue}let s=a.rawArgs;if(Lc.has(o)){let n=r(i,o),s=t.slice(i+1,n);if(n>i+1&&s.every(e=>e.type===`text`)){let r=e.slice(a.end,t[n].start),i=r.trim();yield{kind:`passage`,name:i.replace(/^[\"']|[\"']$/g,``),offset:a.end+r.indexOf(i),length:i.length,macro:o,label:e.slice(a.start,a.end)}}}if(!s)continue;let c=`{${a.name} ${s}}`,l=a.argsStart;if(Ic.has(o)){yield{kind:`code`,code:s,offset:l,goal:`expression`,label:c};continue}let u=n(o);u&&(yield*Zc(s,l,u,a.name,c));let d=n.widget?.(o);d&&(yield*Qc(s,l,d,a.name,c))}}}function*Gc(e,t,n,r={}){yield*Kc(e,e,t,n,r,e=>e,void 0)}function*Kc(e,t,n,r,i,a,o){for(let s of Wc(t,n,r)){let t=o?qc(s,a,o):s;if(s.kind!==`text`||!s.text.includes(`{`)){yield t;continue}let n=e=>a(Pc(s,e)),c=ts(s.text,{text:!0,hooks:i.isBlock&&{isBlock:i.isBlock}});yield{...t,tokens:c.tokens.map(e=>cs(e,n)),errors:c.errors.map(t=>{let{line:r,column:i}=vr(e,n(t.offset));return new $o(t.reason,n(t.offset),r,i,t.code,n(t.end),t.data)})},yield*Kc(e,s.text,c.tokens,r,i,n,s.where)}}function qc(e,t,n){let r=t(e.offset),i={offset:r,nested:!0,where:n};if(e.kind===`passage`||e.kind===`argument-error`){let n=t(e.offset+e.length)-r;return{...e,...i,length:n}}let a=Fc(e),o=e.sourceOffsets?e.sourceOffsets.map(t):t(e.offset+a)-r===a?void 0:Array.from({length:a+1},(n,r)=>t(e.offset+r));return o?{...e,...i,sourceOffsets:o}:{...e,...i}}var Jc=/\\\\(?:u\\{[0-9a-fA-F]+\\}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{2}|[0-3][0-7]{0,2}|[4-7][0-7]?|\\r\\n|[^])/y;function Yc(e,t,n){if(n===`quotes`){let n=e.charAt(t+1);return/[\"'\\\\]/.test(n)?{length:2,text:n}:void 0}Jc.lastIndex=t;let r=Jc.exec(e)?.[0],i=r&&Vo(`\"${r}\"`);return typeof i==`string`?{length:r.length,text:i}:void 0}function Xc(e,t,n,r){let i=[],a=!1,o=0;for(;i.length<n.length;){if(o>=e.length)return;let s=e[o]===`\\\\`?Yc(e,o,r):void 0;if(!s)i.push(t+o++);else{if(!n.startsWith(s.text,i.length))return;for(let e=0;e<s.text.length;e++)i.push(t+o);a=!0,o+=s.length}}return i.push(t+o),a?i:void 0}function*Zc(e,t,n,r,i){let a,o=new Map;try{a=Sc(e,n,o)}catch(n){if(!(n instanceof sc))throw n;yield{kind:`argument-error`,message:n.message,offset:t,length:e.length,label:i,macro:r.toLowerCase()};return}yield*$c(e,t,n,a,o,r,i,`quotes`)}function*Qc(e,t,n,r,i){let a=nc(e),o=[],s={},c=new Map;n.forEach(({name:t,holds:n},r)=>{let i=a[r],l=i&&Vo(e.slice(...i));if(!n||l==null)return;let u={name:t,type:`string`,holds:n};o.push(u),s[t]=l,c.set(u,i)}),yield*$c(e,t,o,s,c,r,i,`javascript`)}function*$c(e,t,n,r,i,a,o,s){let c=a.toLowerCase();function*l(n,r){for(let u of n){let n=r[u.name];if(u.type===`options`&&u.parameters){yield*l(u.parameters,n??{});continue}let d=i.get(u);if(typeof n!=`string`||!n.trim()||!d)continue;let[f,p]=d,m=e.slice(f,p),h=e=>({kind:`passage`,name:e,offset:t+f,length:p-f,macro:c,label:o}),g=Hc(u);if(u.type===`passage`){let e=Cc(n);if(e.kind===`name`){yield h(e.name);continue}}if(g){let e={kind:`code`,code:n,offset:t+f,goal:g,label:o};u.type===`passage`&&(e.passage=!0,e.macro=c),yield e;continue}let _=t+f+(n!==m&&/^[\"']/.test(m)?1:0),v=Uc(u),y=Xc(e.slice(_-t),_,n,s);if(v===`expression`||v===`statements`){let e={kind:`code`,code:n,offset:_,goal:v,label:o,inString:!0};y&&(e.sourceOffsets=y),yield e}else if(v===`passage`)yield h(n);else if(v===`markup`){let e=el(n,_,`In the ${u.name} of {${a}}: `);y&&(e.sourceOffsets=y),yield e}}}yield*[...l(n,r)].sort((e,t)=>e.offset-t.offset)}var el=(e,t,n)=>({kind:`text`,text:e,offset:t,where:n,tokens:[],errors:[]});function tl(e,t){if(t.attributeSpans.length===0){let n=t.start;return Object.entries(t.attributes).map(([t,r])=>{let i=rl(e,r,n);return n=i+r.length,{name:t,value:r,at:i}})}let n=new Set,r=[];for(let i of t.attributeSpans){let t=i.name.toLowerCase();n.has(t)||(n.add(t),i.valueStart!==void 0&&r.push({name:i.name,value:e.slice(i.valueStart,i.valueEnd),at:i.valueStart}))}return r}function nl(e){let t=[],n=0;for(let r of Zo(e))`expr`in r?(t.push({expr:r.expr,at:n+1}),n+=r.expr.length+2):n+=(`text`in r?r.text:r.verbatim).length;return t}function rl(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 il=new sr;function al(e,t){il.set(e,t)}function ol(e){return il.get(e)}var sl=new sr;function cl(e,t){t?sl.set(e,t):sl.delete(e)}function ll(e){return sl.get(e)}var ul=new cr;function dl(e){ul.add(e)}function fl(e){return ul.has(e)}var pl=[`expression`,`statements`,`passage`,`variable`,`string`,`text`,`names`,`delay`,`number`,`flag`,`separator`,`options`],ml=[`markup`,`text`,`passage`,`expression`,`statements`];function hl(e,t){let n=`Give a \\`string\\` or \\`text\\` parameter one of ${ml.join(`, `)} to hold (see docs/custom-macros.md#what-a-string-holds).`;for(let r of t){let t=r.type;if(!pl.includes(t))throw gl(e,r,t===void 0?`has no type`:`has the unknown type ${JSON.stringify(t)}`,`Give it one of the types ${pl.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 gl(e,r,`is of the type ${t}, which holds what it is`,n);if(i!==void 0&&!ml.includes(i))throw gl(e,r,`holds the unknown ${JSON.stringify(i)}`,n);r.parameters&&hl(e,r.parameters)}}function gl(e,t,n,r){return Error(`spindle: The parameter \"${t.name}\" of the macro {${e}} ${n}. ${r}`)}var _l=new sr;function vl(e,t){_l.set(e,t)}function yl(e){return _l.get(e)?.parameters}function bl(){return Array.from(_l.values())}var xl=e=>Bc(bl())(e);function Sl(e,t){if(!e.includes(`{`))return!1;let n;try{n=ns(e,{text:!0})}catch{return!1}return wl(n,t)}function Cl(e,t=xl,n=``){for(let r of Wc(n,[e],t))if(r.kind===`text`&&Sl(r.text,t))return!0;return!1}function wl(e,t=xl){for(let n of e){if(n.type===`variable`&&n.scope===`local`&&n.name===`children`||n.type===`html`&&(Cl({isClose:!1,isSelfClose:!1,tagNameStart:0,tagNameEnd:0,attributeSpans:[],...n,start:0,end:0},t)||wl(n.children,t)))return!0;if(n.type===`macro`){if(Cl({isClose:!1,nameStart:0,nameEnd:0,argsStart:0,argsEnd:0,...n,start:0,end:0},t)||wl(n.children,t))return!0;if(n.branches){for(let e of n.branches)if(wl(e.children,t))return!0}}}return!1}var Tl=[{name:`name`,type:`text`,holds:`text`,required:!0},{name:`parameters`,type:`text`,holds:`text`}];function El({name:e=``,parameters:t=``}){let n=[],r={},i=[];for(let e of t.split(/[\\s,]+/)){if(!e.startsWith(`@`))continue;let[t=e,a]=e.split(/:(.*)/s);n.push(t),a!==void 0&&(ml.includes(a)?r[t]=a:i.push({param:t,written:a}))}return{name:e,params:n,...Object.keys(r).length>0?{holds:r}:{},...i.length>0?{badHolds:i}:{}}}function Dl({name:e,badHolds:t=[]}){let[n]=t;if(n)throw Error(`spindle: The widget parameter ${n.param} of {widget \"${e}\"} holds the unknown ${JSON.stringify(n.written)}. Write one of ${ml.join(`, `)} after the colon (see docs/widgets.md#what-an-argument-holds).`)}function Ol(e){return El(Sc(e,Tl))}function kl(e){let t=new Map;Sc(e,Tl,t);let[n,r]=t.get(Tl[0])??[0,0],i=e[n];return(i===`\"`||i===`'`)&&r-n>=2?[n+1,e[r-1]===i?r-1:r]:[n,r]}function Al(e,t=xl){let n=[];for(let r of e){if(r.name!==`StoryInit`&&!r.tags?.includes(`widget`))continue;let e=[],i=[];for(let n of as(r.content).tokens)if(n.type===`macro`&&n.name.toLowerCase()===`widget`){if(!n.isClose)e.push({token:n,isBlock:!1});else{let t=e.pop();t&&i.push({...t,closeStart:n.start})}}else e.length>0&&(n.type===`variable`&&n.scope===`local`&&n.name===`children`||Cl(n,t,r.content))&&(e[e.length-1].isBlock=!0);i.push(...e);let a=[];for(let{token:e,isBlock:t,closeStart:n}of i)try{let[i,o]=kl(e.rawArgs);a.push({...Ol(e.rawArgs),block:t,passage:r.name,start:e.start,end:e.end,nameStart:e.argsStart+i,nameEnd:e.argsStart+o,...n===void 0?{}:{closeStart:n}})}catch{}n.push(...a.sort((e,t)=>e.start-t.start))}return n}function jl(e,t=xl){return Al(e,t).filter(e=>e.block&&e.closeStart!==void 0).map(e=>e.name)}function Ml(e,t){Dl(e);let{name:n,params:r,holds:i}=e,a=wl(t);Es(n,t,r,a,i),a&&pr(n)}function Nl(e,t){for(let n of e)if(n.type===`macro`&&n.name===`widget`&&n.rawArgs){let e=Ol(n.rawArgs);try{Ml(e,n.children)}catch(n){console.error(`spindle: widget \"${e.name}\" in passage \"${t}\" was not registered: ${As(n)}`)}}}var Pl=e=>Symbol.iterator in e,Fl=e=>`entries`in e,Il=(e,t)=>{let n=e instanceof Map?e:new Map(e.entries()),r=t instanceof Map?t:new Map(t.entries());if(n.size!==r.size)return!1;for(let[e,t]of n)if(!r.has(e)||!Object.is(t,r.get(e)))return!1;return!0},Ll=(e,t)=>{let n=e[Symbol.iterator](),r=t[Symbol.iterator](),i=n.next(),a=r.next();for(;!i.done&&!a.done;){if(!Object.is(i.value,a.value))return!1;i=n.next(),a=r.next()}return!!i.done&&!!a.done};function Rl(e,t){return Object.is(e,t)?!0:typeof e!=`object`||!e||typeof t!=`object`||!t||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:Pl(e)&&Pl(t)?Fl(e)&&Fl(t)?Il(e,t):Ll(e,t):Il({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}var zl=me(null),Bl=me(null);function Vl(...e){let t=j(void 0),n=M(zl);return Q(r=>{if(t.current&&n?.(r))return t.current;let i={};for(let t of e)i[t]=r[t];return Rl(t.current,i)?t.current:t.current=i})}function Hl(e){return new Proxy(q(),{get:(t,n)=>typeof n==`string`?ms(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}})}function Ul(){let e=M(Dm),{getValues:t}=M(Om);return Pe(()=>Hl(t),[t,e])}function Wl(){let{variables:e,temporary:t,transient:n,renderCounts:r}=Vl(`variables`,`temporary`,`transient`,`renderCounts`),i=Ul();return Pe(()=>[e,t,i,n],[e,t,i,n,r])}var Gl=1831565813;function Kl(e){let t=e|0;return()=>{t=t+Gl|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 ql(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t}var Jl=!1,Yl=``,Xl=0,Zl=null,Ql=0;function $l(e,t=!0){let n;n=e===void 0?String(Date.now())+String(Math.random()):t?e+`|`+Date.now()+`|`+Math.random():e,Yl=n,Xl=0,Zl=Kl(ql(n)),Jl=!0,Ql++}function eu(e,t){Ql++,tu(e,t)}function tu(e,t){Yl=e;let n=Math.imul(t%4294967296,Gl);Zl=Kl(ql(e)+n|0),Jl=!0,Xl=t}function nu(){Ql++,Jl=!1,Yl=``,Xl=0,Zl=null}function ru(e){let t={generation:Ql,seed:Yl,pull:Xl};try{return e()}finally{Jl&&Ql===t.generation&&Xl!==t.pull&&tu(t.seed,t.pull)}}function iu(){return Jl?{seed:Yl,pull:Xl}:null}function au(){return!Jl||!Zl?Math.random():(Xl++,Zl())}function ou(e,t){return e>t&&([e,t]=[t,e]),Math.floor(au()*(t-e+1))+e}function su(){return Jl}function cu(){return Yl}function lu(){return Xl}var uu=500,du={$:`__variables`,_:`__temporary`,\"@\":`__locals`,\"%\":`__transient`},fu=`__fns`,pu=/[\\p{ID_Continue}$\\u200c\\u200d]$/u;function mu(e,t=`expression`){let n=t===`statements`?`s`+e:`e`+e,r=hu.get(n);if(r!==void 0)return r;let{refs:i}=So(e,t),a=``,o=0;for(let t of i){let n=ds(t.name,t.sigil+t.name);if(n)throw SyntaxError(`spindle: ${n}`);a+=e.slice(o,t.start),t.shorthand?a+=`${t.name}: `:pu.test(a.slice(-2))&&(a+=` `),a+=`${du[t.sigil]}[\"${t.name}\"]`,o=t.end}return a+=e.slice(o),hu.size>=uu&&hu.delete(hu.keys().next().value),hu.set(n,a),a}var hu=new Map,gu=500,_u=new Map,vu=`const {currentPassage,previousPassage,visited,hasVisited,hasVisitedAny,hasVisitedAll,rendered,hasRendered,hasRenderedAny,hasRenderedAll,random,randomInt}=${fu};`;function yu(e,t){let n=mu(e,t),r=t===`statements`?`{${n}\\n}`:`return (${n}\\n);`;return Function(du.$,du._,du[`@`],fu,du[`%`],vu+r)}function bu(e,t){let n=(t===`statements`?`s`:`e`)+e,r=_u.get(n);if(r)return _u.delete(n),_u.set(n,r),r;let i=yu(e,t);if(_u.set(n,i),_u.size>gu){let e=_u.keys().next().value;e!==void 0&&_u.delete(e)}return i}function xu(){let e=Q.getState();return e.storyData?.passages.get(e.currentPassage)}function Su(){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 Cu(e){let t=t=>Cs(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 wu(e,t){let n=Cu(e),r=Cu(t);return{currentPassage:xu,previousPassage:Su,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 Tu=null;function Eu(){return Tu??(Tu={...wu(()=>Q.getState().visitCounts,()=>Q.getState().renderCounts),random:au,randomInt:ou}),Tu}function Du(e){return _s(e)?e:Object.isExtensible(e)?(Object.setPrototypeOf(e,null),e):vs(e)}function Ou(e,...[t,n,r=bs,i=bs]){return e(Du(t),Du(n),Du(r),Eu(),Du(i))}function ku(e,...t){return Ou(bu(e,`expression`),...t)}function Au(e,...t){Ou(bu(e,`statements`),...t)}function ju(e){return e==null?``:String(e)}function Mu(e,t,n){return e||t?b(`span`,{id:t,class:e},n):b(S,null,n)}function Nu(e){return e.includes(`{`)||e.includes(`}`)}function Pu(e,t){return e?.length?{nodes:e,outer:t??null}:null}var Fu=new Map,Iu=2e3;function Lu(e){let t=Fu.get(e);if(t===void 0){try{t={nodes:ns(e,{text:!0})}}catch(e){t={error:e}}Fu.size>=Iu&&Fu.clear(),Fu.set(e,t)}return t}function Ru(e,t){return e.map(e=>{switch(e.type){case`text`:return{type:`text`,value:t(e.value)};case`html`:return{...e,children:Ru(e.children,t)};case`macro`:{let n={...e,children:Ru(e.children,t)};return e.branches&&(n.branches=e.branches.map(e=>({...e,children:Ru(e.children,t)}))),n}default:return e}})}var zu=100;function Bu(e,t,n){let r=n.split(`.`),i=r[0];fs(i,zn[t]+i);let a=ms(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 Vu(e,t){return ku(e,t.variables,t.temporary,t.locals,t.transient)}var Hu=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 ju(Vu(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 ju(Bu(n,e,t))}catch(n){return this.errors.push({macro:zn[e]+t,error:n}),``}}nested(e,t,n,r,i={}){return r>=zu?(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(fl(e.name))return``;let r=Ds(e.name);if(r){let i=t.locals;if(r.params.length>0){let n=e.rawArgs?rc(e.rawArgs):[];i=q(t.locals),r.params.forEach((e,r)=>{let a,o=n[r];if(o!==void 0)try{a=Vu(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:Pu(e.children,t.widgetChildren)})}let i=ll(e.name);if(!i){let t=ol(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=>Vu(e,t),renderText:(r,i)=>this.nested(e.name,r,t,n,i?{locals:Uu(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 Uu(e,t){for(let e of Object.keys(t))fs(e,`@${e}`);return q(e,t)}function Wu(e,t){let n=new Hu;return{text:n.nodes(e,t,0),errors:n.errors}}function Gu(e,t){if(!Nu(e))return{text:e,errors:[]};let n=Lu(e);return`error`in n?{text:e,errors:[{macro:`markup`,error:n.error}]}:Wu(n.nodes,t)}function Ku(e,t,n){let r=[],i=``;for(let a of Zo(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=Rn[a.expr[0]];try{i+=ju(Bu(t,e,a.expr.slice(1)))}catch(e){r.push({macro:a.expr,error:e})}}else try{i+=ju(Vu(a.expr,t))}catch(e){r.push({macro:`expression`,error:e})}return{text:i,errors:r}}function qu(){let[e,t,n,r]=Wl(),i=M(Vm);return Pe(()=>({variables:e,temporary:t,locals:n,transient:r,widgetChildren:i}),[e,t,n,r,i])}function Ju(){let e=qu();return Fe(t=>{if(t===void 0||!Nu(t))return t;let{text:n,errors:r}=Gu(t,e);for(let{macro:e,error:n}of r)console.error(`spindle: {${e}} error in \"${t}\": ${As(n)}`);return n},[e])}var Yu=0;Array.isArray;function J(e,t,r,i,a,o){t||(t={});var s,c,l=t;if(`ref`in l&&typeof e!=`function`)for(c in l={},t)c==`ref`?s=t[c]:l[c]=t[c];var u={type:e,props:l,key:r,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Yu,__i:-1,__u:0};return(a||o)&&(u.__source=a,u.__self=o),n.vnode&&n.vnode(u),u}var Xu={variable:`variables`,temporary:`temporary`,transient:`transient`};function Zu({node:e}){let{name:t,scope:n}=e,r=Ju(),i=r(e.className),a=r(e.id),o=Ul(),s=t.split(`.`),c=s[0],l=Q(e=>n===`local`?void 0:ms(e[Xu[n]],c)),u=zn[n],d=ds(c,u+c);if(d)return J(`span`,{class:`error`,children:`{${u}${t} error: ${d}}`});let f;f=n===`local`?ms(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 Mu(i,a,ju(f))}function Qu({node:e}){let{expression:t}=e,n=Ju(),r=n(e.className),i=n(e.id),[a,o,s,c]=Wl(),l;try{l=ju(ku(t,a,o,s,c))}catch{l=`{error: ${t}}`}return Mu(r,i,l)}function $u(){return{nobr:M(km),inline:M(jm),raw:M(Nm),structural:M(Mm),locals:M(Dm)}}function ed({body:e,ownKeys:t}){let n=$u(),[r,i]=Ae({}),a=M(Om).getValues(),o=Pe(()=>q(a,t,r),[a,M(Dm),t,r]),s=j(o);s.current=o;let c=Fe(()=>s.current,[]),l=Fe((e,t)=>{fs(e,`@${e}`),s.current=ys(s.current,e,t),i(n=>({...n,[e]:t}))},[]),u=Pe(()=>({update:l,getValues:c}),[l,c]);return J(Om.Provider,{value:u,children:J(Dm.Provider,{value:o,children:Ih(e,{...n,locals:o})})})}function td(e){let t=Ju();return Mu(t(e.className),t(e.id),J(nd,{...e}))}function nd({body:e,params:t,rawArgs:n,invocationChildren:r}){let[i,a,o,s]=Wl(),c=M(Vm),l=Pe(()=>Pu(r,c),[r,c]),u=n?rc(n):[],d=[];for(let e=0;e<t.length;e++){let t=u[e],n;if(t!==void 0)try{n=ku(t,i,a,o,s)}catch{n=void 0}d.push(n)}let f=Pe(()=>{let e=q();for(let n=0;n<t.length;n++)e[t[n].startsWith(`@`)?t[n].slice(1):t[n]]=d[n];return e},[t.join(` `),...d]);return J(Vm.Provider,{value:l,children:J(ed,{body:e,ownKeys:f})})}var rd=document.createElement(`i`);function id(e){let t=`&`+e+`;`;rd.innerHTML=t;let n=rd.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`?!1:n!==t&&n}function ad(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 od(e,t){return e.length>0?(ad(e,e.length,0,t),e):t}var sd={}.hasOwnProperty;function cd(e){let t={},n=-1;for(;++n<e.length;)ld(t,e[n]);return t}function ld(e,t){let n;for(n in t){let r=(sd.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){sd.call(r,a)||(r[a]=[]);let e=i[a];ud(r[a],Array.isArray(e)?e:e?[e]:[])}}}function ud(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);ad(e,0,0,r)}function dd(e){let t={},n=-1;for(;++n<e.length;)fd(t,e[n]);return t}function fd(e,t){let n;for(n in t){let r=(sd.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i)r[a]=i[a]}}function pd(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 md={'\"':`quot`,\"&\":`amp`,\"<\":`lt`,\">\":`gt`};function hd(e){return e.replace(/[\"&<>]/g,t);function t(e){return`&`+md[e]+`;`}}function gd(e){return e.replace(/[\\t\\n\\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var _d=Dd(/[A-Za-z]/),vd=Dd(/[\\dA-Za-z]/),yd=Dd(/[#-'*+\\--9=?A-Z^-~]/);function bd(e){return e!==null&&(e<32||e===127)}var xd=Dd(/\\d/),Sd=Dd(/[\\dA-Fa-f]/),Cd=Dd(/[!-/:-@[-`{-~]/);function Y(e){return e!==null&&e<-2}function wd(e){return e!==null&&(e<0||e===32)}function X(e){return e===-2||e===-1||e===32}var Td=Dd(/\\p{P}|\\p{S}/u),Ed=Dd(/\\s/);function Dd(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function Od(e,t){let n=hd(kd(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 kd(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&vd(e.charCodeAt(n+1))&&vd(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 Ad={}.hasOwnProperty,jd=/^(https?|ircs?|mailto|xmpp)$/i,Md=/^https?$/i;function Nd(e){let t=e||{},n=!0,r={},i=[[]],a=[],o=[],s=dd([{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:E,listItemValue:T,listOrdered:C,listUnordered:w,paragraph:ne,reference:h,resource:me,resourceDestinationString:he,resourceTitleString:h,setextHeading:Ee,strong:Le},exit:{atxHeading:Oe,atxHeadingSequence:Te,autolinkEmail:Ke,autolinkProtocol:Ge,blockQuote:k,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:_e,label:fe,labelText:de,lineEnding:Me,link:_e,listOrdered:D,listUnordered:ee,paragraph:re,reference:S,referenceString:pe,resource:S,resourceDestinationString:A,resourceTitleString:ge,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=od(o,e.slice(n,t)),n=t):(a=od(a,e.slice(n,t+1)),n=t+1));a=od(a,o),a=od(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];Ad.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:hd(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 E(){m(`expectFirstItem`)?_(`>`):O(),b(),_(`<li>`),p(`expectFirstItem`),p(`lastWasTag`)}function D(){O(),o.pop(),y(),_(`</ol>`)}function ee(){O(),o.pop(),y(),_(`</ul>`)}function O(){m(`lastWasTag`)&&!m(`slurpAllLineEndings`)&&b(),_(`</li>`),p(`slurpAllLineEndings`)}function te(){o.push(!1),b(),_(`<blockquote>`)}function k(){o.pop(),b(),_(`</blockquote>`),p(`slurpAllLineEndings`)}function ne(){o[o.length-1]||(b(),_(`<p>`)),p(`slurpAllLineEndings`)}function re(){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 A(){a[a.length-1].destination=g(),p(`ignoreEncode`)}function ge(){a[a.length-1].title=g()}function _e(){let e=a.length-1,i=a[e],o=i.referenceId||i.labelId,s=i.destination===void 0?r[gd(o)]:i;for(n=!0;e--;)if(a[e].image){n=void 0;break}i.image?(_(`<img src=\"`+Od(s.destination,t.allowDangerousProtocol?void 0:Md)+`\" alt=\"`),v(i.label),_(`\"`)):_(`<a href=\"`+Od(s.destination,t.allowDangerousProtocol?void 0:jd)+`\"`),_(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=gd(e.labelId);g(),Ad.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){m(`slurpAllLineEndings`)||(m(`slurpOneLineEnding`)?p(`slurpOneLineEnding`):m(`inCodeText`)?v(` `):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`)?pd(t,m(`characterReferenceType`)===`characterReferenceMarkerNumeric`?10:16):id(t))),p(`characterReferenceType`)}function Ge(e){let n=this.sliceSerialize(e);_(`<a href=\"`+Od(n,t.allowDangerousProtocol?void 0:jd)+`\">`),v(x(n)),_(`</a>`)}function Ke(e){let t=this.sliceSerialize(e);_(`<a href=\"`+Od(`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 Pd={tokenize:Fd};function Fd(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null)e.consume(n);else 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);else return Y(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var Id=class{constructor(){this.index=new Map,this.map=[]}add(e,t,n){Ld(this,e,t,n,!1)}addBefore(e,t,n){Ld(this,e,t,n,!0)}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,this.index.clear()}};function Ld(e,t,n,r,i){if(n===0&&r.length===0)return;let a=e.index.get(t);if(a){a[1]+=n,i?(r.push(...a[2]),a[2]=r):a[2].push(...r);return}let o=[t,n,r];e.map.push(o),e.index.set(t,o)}var Rd={tokenize:Bd},zd={tokenize:Vd};function Bd(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++;let c=new Id;return c.add(a+1,0,t.events.slice(n)),c.add(n,s-n,[]),c.consume(t.events),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(zd,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(zd,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);else 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);else 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++;let l=new Id;l.add(a+1,0,t.events.slice(n)),l.add(n,e-n,[]),l.consume(t.events)}}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 Vd(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 Hd(e){if(e===null||wd(e)||Ed(e))return 1;if(Td(e))return 2}function Ud(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 Wd={name:`attention`,resolveAll:Gd,tokenize:Kd};function Gd(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};qd(d,-c),qd(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=od(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=od(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=od(l,Ud(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=od(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=od(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,ad(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 Kd(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Hd(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=Hd(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 qd(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var Jd={name:`autolink`,tokenize:Yd};function Yd(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 _d(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||vd(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||vd(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||bd(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):yd(t)?(e.consume(t),l):n(t)}function u(e){return vd(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||vd(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var Xd={partial:!0,tokenize:Zd};function Zd(e,t,n){return r;function r(t){return X(t)?Z(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||Y(e)?t(e):n(e)}}var Qd={continuation:{tokenize:ef},exit:tf,name:`blockQuote`,tokenize:$d};function $d(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 ef(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(Qd,t,n)(r)}}function tf(e){e.exit(`blockQuote`)}var nf={name:`characterEscape`,tokenize:rf};function rf(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 Cd(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var af={name:`characterReference`,tokenize:of};function of(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=vd,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=Sd,u):(e.enter(`characterReferenceValue`),a=7,o=xd,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===vd&&!id(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 sf={partial:!0,tokenize:uf},cf={concrete:!0,name:`codeFenced`,tokenize:lf};function lf(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(sf,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(sf,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 uf(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 df={name:`codeIndented`,tokenize:pf},ff={partial:!0,tokenize:mf};function pf(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(ff,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 mf(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 hf={name:`codeText`,previous:_f,resolve:gf,tokenize:vf};function gf(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 _f(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function vf(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 yf=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&&bf(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),bf(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),bf(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);bf(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);bf(this.left,t.reverse())}}}};function bf(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 xf(e){let t={},n=-1,r,i,a,o,s,c,l,u=new yf(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,Sf(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 ad(e,0,1/0,u.slice(0)),!l}function Sf(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 Cf={resolve:Tf,tokenize:Ef},wf={partial:!0,tokenize:Df};function Tf(e){return xf(e),e}function Ef(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(wf,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 Df(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 Of(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||bd(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||wd(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||bd(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 kf(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 Af(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 jf(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 Mf={name:`definition`,tokenize:Pf},Nf={partial:!0,tokenize:Ff};function Pf(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return kf.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=gd(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 wd(t)?jf(e,l)(t):l(t)}function l(t){return Of(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(Nf,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 Ff(e,t,n){return r;function r(t){return wd(t)?jf(e,i)(t):n(t)}function i(t){return Af(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 If={name:`hardBreakEscape`,tokenize:Lf};function Lf(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 Rf={name:`headingAtx`,resolve:zf,tokenize:Bf};function zf(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`},ad(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function Bf(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||wd(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||wd(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var Vf=`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(`.`),Hf=[`pre`,`script`,`style`,`textarea`],Uf={concrete:!0,name:`htmlFlow`,resolveTo:Kf,tokenize:qf},Wf={partial:!0,tokenize:Yf},Gf={partial:!0,tokenize:Jf};function Kf(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 qf(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):_d(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):_d(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:ee:m):n(i)}function h(t){return _d(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||wd(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&Hf.includes(l)?(i=1,r.interrupt?t(s):ee(s)):Vf.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):ee(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||vd(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:ee):n(i)}function v(t){return X(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||_d(t)?(e.consume(t),b):X(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||vd(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||wd(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||X(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),D):n(t)}function D(t){return t===null||Y(t)?ee(t):X(t)?(e.consume(t),D):n(t)}function ee(t){return t===45&&i===2?(e.consume(t),ne):t===60&&i===1?(e.consume(t),re):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(Wf,ce,O)(t)):t===null||Y(t)?(e.exit(`htmlFlowData`),O(t)):(e.consume(t),ee)}function O(t){return e.check(Gf,te,ce)(t)}function te(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),k}function k(t){return t===null||Y(t)?O(t):(e.enter(`htmlFlowData`),ee(t))}function ne(t){return t===45?(e.consume(t),oe):ee(t)}function re(t){return t===47?(e.consume(t),o=``,ie):ee(t)}function ie(t){if(t===62){let n=o.toLowerCase();return Hf.includes(n)?(e.consume(t),se):ee(t)}return _d(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),ie):ee(t)}function ae(t){return t===93?(e.consume(t),oe):ee(t)}function oe(t){return t===62?(e.consume(t),se):t===45&&i===2?(e.consume(t),oe):ee(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 Jf(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 Yf(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(Xd,t,n)}}var Xf={name:`htmlText`,tokenize:Zf};function Zf(e,t,n){let r=this,i,a,o;return s;function s(t){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(t),c}function c(t){return t===33?(e.consume(t),l):t===47?(e.consume(t),x):t===63?(e.consume(t),y):_d(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):_d(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,re(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?ne(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,re(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?ne(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?ne(t):Y(t)?(o=v,re(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):Y(t)?(o=y,re(t)):(e.consume(t),y)}function b(e){return e===62?ne(e):y(e)}function x(t){return _d(t)?(e.consume(t),S):n(t)}function S(t){return t===45||vd(t)?(e.consume(t),S):C(t)}function C(t){return Y(t)?(o=C,re(t)):X(t)?(e.consume(t),C):ne(t)}function w(t){return t===45||vd(t)?(e.consume(t),w):t===47||t===62||wd(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),ne):t===58||t===95||_d(t)?(e.consume(t),E):Y(t)?(o=T,re(t)):X(t)?(e.consume(t),T):ne(t)}function E(t){return t===45||t===46||t===58||t===95||vd(t)?(e.consume(t),E):D(t)}function D(t){return t===61?(e.consume(t),ee):Y(t)?(o=D,re(t)):X(t)?(e.consume(t),D):T(t)}function ee(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=ee,re(t)):X(t)?(e.consume(t),ee):(e.consume(t),te)}function O(t){return t===i?(e.consume(t),i=void 0,k):t===null?n(t):Y(t)?(o=O,re(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||wd(t)?T(t):(e.consume(t),te)}function k(e){return e===47||e===62||wd(e)?T(e):n(e)}function ne(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function re(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 Qf={name:`labelEnd`,resolveAll:np,resolveTo:rp,tokenize:ip},$f={tokenize:ap},ep={tokenize:op},tp={tokenize:sp};function np(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&&ad(e,0,e.length,n),e}function rp(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=od(s,e.slice(a+1,a+r+3)),s=od(s,[[`enter`,u,t]]),s=od(s,Ud(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=od(s,[[`exit`,u,t],e[o-2],e[o-1],[`exit`,l,t]]),s=od(s,e.slice(o+1)),s=od(s,[[`exit`,c,t]]),ad(e,a,e.length,s),e}function ip(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(gd(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($f,u,o?u:d)(t):t===91?e.attempt(ep,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(tp,u,d)(t)}function u(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}function ap(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 wd(t)?jf(e,a)(t):a(t)}function a(t){return t===41?u(t):Of(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return wd(t)?jf(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?Af(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return wd(t)?jf(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 op(e,t,n){let r=this;return i;function i(t){return kf.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(gd(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function sp(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 cp={name:`labelStartImage`,resolveAll:Qf.resolveAll,tokenize:lp};function lp(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 up={name:`labelStartLink`,resolveAll:Qf.resolveAll,tokenize:dp};function dp(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 fp={name:`lineEnding`,tokenize:pp};function pp(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),Z(e,t,`linePrefix`)}}var mp={name:`thematicBreak`,tokenize:hp};function hp(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 gp={continuation:{tokenize:bp},exit:Sp,name:`list`,tokenize:yp},_p={partial:!0,tokenize:Cp},vp={partial:!0,tokenize:xp};function yp(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:xd(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(mp,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 xd(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(Xd,r.interrupt?n:u,e.attempt(_p,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 bp(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(Xd,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(vp,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,Z(e,e.attempt(gp,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function xp(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 Sp(e){e.exit(this.containerState.type)}function Cp(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 wp={name:`setextUnderline`,resolveTo:Tp,tokenize:Ep};function Tp(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 Ep(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 Dp={tokenize:Op};function Op(e){let t=this,n=e.attempt(Xd,r,e.attempt(this.parser.constructs.flowInitial,i,Z(e,e.attempt(this.parser.constructs.flow,i,e.attempt(Cf,i)),`linePrefix`)));return n;function r(r){if(r===null)e.consume(r);else return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null)e.consume(r);else return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}var kp={resolveAll:Np()},Ap=Mp(`string`),jp=Mp(`text`);function Mp(e){return{resolveAll:Np(e===`text`?Pp: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);else 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 Np(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 Pp(e,t){let n=new Id,r=0;for(;++r<=e.length;)if((r===e.length||e[r][1].type===`lineEnding`)&&e[r-1][1].type===`data`){let i=e[r-1][1],a=t.sliceStream(i),o=a.length,s=-1,c=0,l;for(;o--;){let e=a[o];if(typeof e==`string`){for(s=e.length;e.charCodeAt(s-1)===32;)c++,s--;if(s)break;s=-1}else if(e===-2)l=!0,c++;else if(e!==-1){o++;break}}if(t._contentTypeTextTrailing&&r===e.length&&(c=0),c){let a={type:r===e.length||l||c<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:o?s:i.start._bufferIndex+s,_index:i.start._index+o,line:i.end.line,column:i.end.column-c,offset:i.end.offset-c},end:{...i.end}};i.end={...a.start},i.start.offset===i.end.offset?Object.assign(i,a):n.add(r,0,[[`enter`,a,t],[`exit`,a,t]])}r++}return n.consume(e),e}var Fp=t({attentionMarkers:()=>Up,contentInitial:()=>Lp,disable:()=>Wp,document:()=>Ip,flow:()=>zp,flowInitial:()=>Rp,insideSpan:()=>Hp,string:()=>Bp,text:()=>Vp}),Ip={42:gp,43:gp,45:gp,48:gp,49:gp,50:gp,51:gp,52:gp,53:gp,54:gp,55:gp,56:gp,57:gp,62:Qd},Lp={91:Mf},Rp={[-2]:df,[-1]:df,32:df},zp={35:Rf,42:mp,45:[wp,mp],60:Uf,61:wp,95:mp,96:cf,126:cf},Bp={38:af,92:nf},Vp={[-5]:fp,[-4]:fp,[-3]:fp,33:cp,38:af,42:Wd,60:[Jd,Xf],91:up,92:[If,nf],93:Qf,95:Wd,96:hf},Hp={null:[Wd,kp]},Up={null:[42,95]},Wp={null:[]};function Gp(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=od(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=Ud(a,l.events,l),l.events):[]}function f(e,t){return qp(p(e),t)}function p(e){return Kp(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,E()}function g(){for(;r._index<o.length;){let e=o[r._index];if(typeof e==`string`){let t=r._index;for(r._bufferIndex<0&&(r._bufferIndex=0);r._index===t&&r._bufferIndex<e.length;)_(e.charCodeAt(r._bufferIndex))}else _(e)}}function _(e){u=u(e)}function v(e){Y(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,E()):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&&ad(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,E()}}function E(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function Kp(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 qp(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 Jp(e){let t={constructs:cd([Fp,...(e||{}).extensions||[]]),content:n(Pd),defined:[],document:n(Rd),flow:n(Dp),lazy:{},string:n(Ap),text:n(jp)};return t;function n(e){return n;function n(n){return Gp(t,e,n)}}}function Yp(e){for(;!xf(e););return e}var Xp=/[\\0\\t\\n\\r]/g;function Zp(){let e=1,t=``,n=!0,r;return i;function i(i,a,o){i=t+(typeof i==`string`?i.toString():new TextDecoder(a||void 0).decode(i));let s=[],c=0;for(t=``,n&&(i.charCodeAt(0)===65279&&c++,n=void 0);c<i.length;){Xp.lastIndex=c;let n=Xp.exec(i),a=n&&n.index!==void 0?n.index:i.length,o=i.charCodeAt(a);if(!n){t=i.slice(c);break}if(o===10&&c===a&&r)s.push(-3),r=void 0;else switch(r&&(s.push(-5),r=void 0),c<a&&(s.push(i.slice(c,a)),e+=a-c),o){case 0:s.push(65533),e++;break;case 9:{let t=Math.ceil(e/4)*4;for(s.push(-2);e++<t;)s.push(-1);break}case 10:s.push(-4),e=1;break;default:r=!0,e=1}c=a+1}return o&&(r&&s.push(-5),t&&s.push(t),s.push(null)),s}}function Qp(e,t,n){return typeof t!=`string`&&(n=t,t=void 0),Nd(n)(Yp(Jp(n).document().write(Zp()(e,t,!0))))}var $p={none:``,left:` align=\"left\"`,right:` align=\"right\"`,center:` align=\"center\"`};function em(){return{enter:{table(e){let t=e._align;this.lineEndingIfNeeded(),this.tag(`<table>`),this.setData(`tableAlign`,t)},tableBody(){this.tag(`<tbody>`)},tableData(){let e=$p[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=$p[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,tm)),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`+$p[e[t]]+`></td>`),t++;this.setData(`tableColumn`,t),this.lineEndingIfNeeded(),this.tag(`</tr>`)}}}}function tm(e,t){return t===`|`?t:e}var nm=class{constructor(){this.map=[],this.index=new Map}add(e,t,n){rm(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,this.index.clear()}};function rm(e,t,n,r){if(n===0&&r.length===0)return;let i=e.index.get(t);if(i){i[1]+=n,i[2].push(...r);return}let a=[t,n,r];e.map.push(a),e.index.set(t,a)}function im(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 am(){return{flow:{null:{name:`table`,tokenize:om,resolveAll:sm}}}}function om(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{type:e}=r.events[t][1];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||(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||wd(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||wd(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 sm(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 nm;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(lm(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=cm(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=cm(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=cm(f,t,o,i,n,d)):(o[0]=o[1],d=cm(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&lm(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=im(t.events,n))}return e}function cm(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},um(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=um(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=um(t.events,n[2]),a=um(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({},um(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function lm(e,t,n,r,i){let a=[],o=um(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 um(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}function dm(){return{enter:{strikethrough(){this.tag(`<del>`)}},exit:{strikethrough(){this.tag(`</del>`)}}}}function fm(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&&ad(o,o.length,0,Ud(s,e.slice(r+1,n),t)),ad(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),ad(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=Hd(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=Hd(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}function pm(e){let t=[`codeIndented`];return e?.inline&&t.push(`list`,`headingAtx`,`setextUnderline`,`thematicBreak`,`blockQuote`,`codeFenced`,`table`),{allowDangerousHtml:!0,extensions:[am(),fm(),{disable:{null:t}}],htmlExtensions:[em(),dm()]}}function mm(e,t){let n=pm(t);return Qp(e,{...n,extensions:[...n.extensions??[],bm(e),gm]})}var hm=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},gm={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:hm}}},_m=/[#-'*+\\--9=?A-Z^-~]/,vm=/[0-9A-Za-z]/,ym=/[A-Za-z]/;function bm(e){let t=+(e.charCodeAt(0)===65279),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]===`!`&&ym.test(e[t+2]??``)?a<t+3:e[t+1]===`?`&&r<t+2&&!s(t):!1}function s(t){let n=t+1;for(;_m.test(e[n]??``);)n++;if(e[n]!==`@`)return!1;n++;let r=0,i=`atSignOrDot`;for(;;){let t=e[n]??``;if(i===`atSignOrDot`){if(!vm.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===`-`||vm.test(t))&&r++<63))return!1;n++,i=t===`-`?`value`:`label`}}}return{text:{60:{name:`unclosedHtml`,resolveTo:hm,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)}}}}}function xm(e){let t=e.metadata[`data-source-file`],n=e.metadata[`data-source-line`];return t?n?` (${t}:${n})`:` (${t})`:``}function Sm(){let e=Q.getState();if(!e.storyData)return``;let t=e.storyData.passages.get(e.currentPassage);return t?xm(t):``}function Cm({macro:e,error:t}){return J(`span`,{class:`error`,title:String(t),children:`{${e} error${Sm()}: ${As(t)}}`})}function wm(e,t,n=Sm()){console.error(`spindle: Error in {${e}}${n}:`,t)}function Tm(e,t,n){let r=j(void 0);if(r.current===void 0){r.current=null;let i=Sm();try{n()}catch(n){r.current={error:n},wm(`${e} ${t}`.trim(),n,i)}}return r.current?J(Cm,{macro:e,error:r.current.error}):null}var Em={update:e=>{throw Error(`Cannot set @${e} — local variables require a {for}, widget, {link}, or {button} scope`)},getValues:()=>bs},Dm=me(bs),Om=me(Em),km=me(!1),Am=me(!1),jm=me(!1),Mm=me(!1),Nm=me(!1),Pm=me(``),Fm=0;function Im(){return Ae(()=>`v${++Fm}`)[0]}var Lm=me(!1),Rm=`http://www.w3.org/2000/svg`,zm=new Set([`table`,`thead`,`tbody`,`tfoot`,`tr`,`colgroup`,`ul`,`ol`,`menu`,`dl`,`select`,`optgroup`,`datalist`]),Bm=new Set([`pre`,`textarea`,`style`]),Vm=me(null);function Hm(e,t){return`<span data-tw=${e}:${t}></span>`}var Um=/(?:(?<=\\\\)\\uE000)?<span data-tw=([0-9a-z]+):(\\d+)><\\/span>/g,Wm=``;function Gm(e,t){if(!e.includes(`<span data-tw=`))return[e];let n=[],r=0;for(let i of e.matchAll(Um))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 Km(e,t){return Gm(e,t).map(e=>typeof e==`number`?t.components[e]:e)}function qm({tag:e,attributes:t,placeholders:n,svg:r,children:i}){let a=qu(),o=[],{props:s,direct:c}=oh(t.map(([e,t,r])=>{let i=n[e];if(!i)return[e,t,r];let s=Wu(i,a);for(let t of s.errors)o.push([e,t]);return[e,s.text,r]}),r),l=sh(c);return Ym(o,b(e,l?{...s,ref:l}:s,...i))}function Jm({tag:e,props:t,direct:n,children:r}){let i=sh(n);return b(e,{...t,ref:i},...r)}function Ym(e,t){return e.length===0?t:J(S,{children:[e.map(([e,{macro:t,error:n}],r)=>J(Cm,{macro:t,error:Error(`in attribute \"${e}\": ${As(n)}`)},r)),t]})}function Xm(e,t){if(e==null||e.nodeType!==Node.ELEMENT_NODE)return-1;let n=e.getAttribute(`data-tw`),r=`${t.nonce}:`;return n==null||!n.startsWith(r)?-1:parseInt(n.slice(r.length),10)}function Zm(e){let t=document.createElement(`template`);return t.innerHTML=e,t.content}function Qm(e,t,n=!1){let r=Zm(e.trim());if(n)for(let e of Array.from(r.childNodes))e.nodeType===Node.ELEMENT_NODE&&e.nodeName===`P`&&e.replaceWith(...Array.from(e.childNodes));return J(S,{children:Array.from(r.childNodes).map((e,n)=>$m(e,n,t))})}function $m(e,t,n){if(e.nodeType===Node.TEXT_NODE){let t=e.textContent??``;t.endsWith(`\\\\${Wm}`)&&Xm(e.nextSibling,n)!==-1&&(t=t.slice(0,-1));let r=Km(t,n);return r.length===1?r[0]:r}if(e.nodeType===Node.ELEMENT_NODE){let r=e,i=r.localName,a=Xm(r,n);if(a!==-1)return n.components[a];let o=r.namespaceURI===Rm,s=[],c;for(let{name:e,value:t}of Array.from(r.attributes)){s.push([e,t,t]);let r=Gm(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)=>$m(e,t,n));if(c)return J(qm,{tag:i,attributes:s,placeholders:c,svg:o,children:l},t);let{props:u,direct:d}=oh(s,o);return d.length>0?J(Jm,{tag:i,props:u,direct:d,children:l},t):b(i,{...u,key:t},...l)}return null}var eh=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(`.`)),th=new Set([`value`,`checked`,`selected`,`muted`]),nh=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`]),rh=new Set([...new Set([`key`,`ref`,`children`,`dangerouslySetInnerHTML`]),`class`,`className`]),ih=/^[A-Za-z_:][\\w:.-]*$/;function ah(e,t,n){if(ih.test(t)){e.setAttribute(t,n);return}let r=Zm(`<i ${t}=\"\"></i>`).firstChild.attributes[0];if(!r)return;let i=r.cloneNode();i.value=n,e.setAttributeNode(i)}function oh(e,t){let n={},r=[];for(let[i,a,o]of e){let e=i.toLowerCase();nh.has(e)&&o!==``&&a===``||(!t&&th.has(e)?n[e]=e!==`value`&&o===``||a:!ih.test(i)||e.startsWith(`on`)||e===`translate`||t&&(rh.has(i)||i===`__proto__`)?r.push([i,a]):n[t?i:i.toUpperCase()]=a)}return{props:n,direct:r}}function sh(e){let t=j(null);return Ne(()=>{let n=t.current;if(n&&e.length!==0){for(let[t,r]of e)ah(n,t,r);return()=>{for(let[t]of e)n.removeAttribute(t)}}},[JSON.stringify(e)]),e.length>0?t:void 0}var ch=new Map,lh=new Map;function uh(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 dh(e){return uh(e,lh,e=>Zm(`<i title=\"${e.replace(/\"/g,`&quot;`)}\"></i>`).firstChild.getAttribute(`title`))}function fh(e){return uh(e,ch,e=>Zm(`<i>${e.replace(/</g,`&lt;`)}</i>`).firstChild.textContent)}var ph=/\\{[$_@%]\\w/,mh=new Map,hh=2e3;function gh(e){let t=mh.get(e);return t===void 0&&(t=Lu(e),`nodes`in t&&e.includes(`&`)&&(t={nodes:Ru(t.nodes,dh)}),mh.size>=hh&&mh.clear(),mh.set(e,t)),t}function _h(e,t,n,r){if(Xo(e)){if(!t.includes(`&`)&&!ph.test(t))return t;let i=Ku(t,n,dh);for(let t of i.errors)r.push([e,t]);return i.text}if(!Nu(t))return dh(t);let i=gh(t);if(`error`in i)return r.push([e,{macro:`markup`,error:i.error}]),dh(t);let a=Wu(i.nodes,n);for(let t of a.errors)r.push([e,t]);return a.text}function vh(e){return e.type===`text`&&(e.comment===!0||e.value.trim()===``)}var yh={details:`summary`,fieldset:`legend`};function bh(e,t){let n=yh[e],r=t.findIndex(e=>!vh(e)),i=t[r];return n&&(i?.type===`macro`||i?.type===`html`&&i.tag.toLowerCase()===n)?r:-1}function xh({node:e}){let t=qu(),{nobr:n,locals:r,raw:i,inline:a,structural:o}=$u(),s=M(Lm),c=e.tag.toLowerCase(),l=c===`svg`,u=s&&c===`foreignobject`,d=i&&!u,f=!i&&(l||Bm.has(c)),p=[],{props:m,direct:h}=oh(Object.entries(e.attributes).map(([e,n])=>[e,_h(e,n,t,p),n]),s||l),g=sh(h);g&&(m.ref=g);let _=eh.has(c),v,y=!1;if(e.children.length>0){if(c===`style`)v=e.children.map(e=>e.type===`text`?e.value:Dh(e));else if(d||f)v=Oh(e.children);else{let t=bh(c,e.children),i=e=>Ih(e,{nobr:n,locals:r,inline:_});y=zm.has(c)&&e.children.every(e=>e.type!==`text`||vh(e)),v=y?e.children.filter(e=>e.type!==`text`).map(e=>Dh(e)):t===-1?i(e.children):J(S,{children:[i(e.children.slice(0,t)),Dh(e.children[t]),i(e.children.slice(t+1))]}),_!==a&&(v=J(jm.Provider,{value:_,children:v})),y!==o&&(v=J(Mm.Provider,{value:y,children:v}))}}u&&v&&(v=J(Lm.Provider,{value:!1,children:J(Nm.Provider,{value:!1,children:v})}));let x=b(e.tag,m,v);return l&&!s&&(x=J(Lm.Provider,{value:!0,children:x})),Ym(p,f?J(Nm.Provider,{value:!0,children:x}):x)}function Sh(){let e=M(Vm),t=$u();return e?J(Vm.Provider,{value:e.outer,children:Ih(e.nodes,t)}):null}var Ch=new WeakMap,wh=0;function Th(e){let t=Ch.get(e);return t===void 0&&(t=`n${wh++}`,Ch.set(e,t)),t}function Eh(e,t){if(fl(e.name))return null;let n={rawArgs:e.rawArgs,className:e.className,id:e.id},r=Ds(e.name);if(r)return J(td,{...n,body:r.body,params:r.params,invocationChildren:e.children},t);let i=ol(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 Dh(e){if(e.type===`text`)return e.comment?null:fh(e.value);let t=Th(e);switch(e.type){case`variable`:return e.scope===`local`&&e.name===`children`?J(Sh,{},t):J(Zu,{node:e},t);case`expression`:return J(Qu,{node:e},t);case`macro`:return Eh(e,t);case`html`:return J(xh,{node:e},t);default:return e}}function Oh(e){return e.length===0?null:e.map(e=>Dh(e))}var kh=/[*_`#|~\\[>\\\\\\-+=\\r]|!\\[|\\d+[.)]|&#?[a-zA-Z0-9]+;| {2}\\n|<[!?]/,Ah=/(?:\\r\\n|\\r(?!\\n)|\\n)\\s*[\\r\\n]/,jh=/<span data-tw=[0-9a-z]+:\\d+><\\/span>/g,Mh=` \t\\r\n`;function Nh(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 Ph(e){return e.includes(`\n`)?e.split(`\n`).map((e,t,n)=>{let r=t===0?0:Nh(e,0,1,` \t`),i=t===n.length-1?e.length:Nh(e,e.length,-1,` \t`);return e.slice(r,Math.max(r,i))}).join(`\n`):e}function Fh(e,t,n){let r=Km(Ph(e),t).filter(e=>e!==``);return n?J(S,{children:r}):b(`p`,null,...r)}function Ih(e,t){if(e.length===0)return null;if(t?.raw)return Oh(e);if(t?.structural&&e.every(e=>e.type!==`text`||vh(e)))return e.filter(e=>e.type!==`text`).map(Dh);if(!e.some(e=>e.type===`text`&&(e.value.trim()!==``||Ah.test(e.value))))return e.map(e=>Dh(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(Dh(a)),r.nodes.push(a),i.endsWith(`\\\\`)&&(i+=Wm),i+=Hm(r.nonce,o)}let a=!!(t?.nobr||t?.inline),o=i.slice(0,Nh(i,0,1,Mh)),s=o.length===i.length?``:i.slice(Nh(i,i.length,-1,Mh)),c=i.slice(o.length,i.length-s.length),l=e=>a&&(o||s)?J(S,{children:[o,e,s]}):e,u=i.replace(jh,``);return!kh.test(u)&&!Ah.test(u)?l(Fh(c,r,a)):l(Qm(mm(i,{inline:t?.inline}),r,a))}var Lh=2**32-1,Rh=Lh-1,zh=class extends Error{constructor(e,t,n,r){super(e),this.name=`DevalueError`,this.path=t.join(``),this.value=n,this.root=r}},Bh=Symbol();function Vh(e,t){let n=[];for(let r=0;r<e.length;r+=1){let i=e[r];i===Bh?n.push(`.get(${t(e[++r])})`):typeof i==`number`?n.push(`[${i}]`):n.push(eg(i))}return n}var Hh=Object.getOwnPropertyNames(Object.prototype).sort().join(`\\0`);function Uh(e){let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null||Object.getPrototypeOf(t)===null||Object.getOwnPropertyNames(t).sort().join(`\\0`)===Hh}function Wh(e){return Object.prototype.toString.call(e).slice(8,-1)}function Gh(e){return typeof Buffer<`u`&&Buffer.isBuffer(e)}function Kh(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 qh=/[\"<\\\\\\u0000-\\u001f\\u2028\\u2029]/;function Jh(e){if(!qh.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=Kh(e[i]);o&&(t+=e.slice(n,i)+o,n=i+1)}return`\"${n===0?e:t+e.slice(n)}\"`}var Yh=64,Xh=new Map;function Zh(e){if(e.length>Yh)return Jh(e);let t=Xh.get(e);return t===void 0&&(Xh.size>=1024&&Xh.clear(),t=Jh(e),Xh.set(e,t)),t}function Qh(e){let t=Object.getOwnPropertySymbols(e);return t.length===0?t:t.filter(t=>Object.getOwnPropertyDescriptor(e,t)?.enumerable)}var $h=/^[a-zA-Z_$][a-zA-Z_$0-9]*$/;function eg(e){return $h.test(e)?`.`+e:`[`+JSON.stringify(e)+`]`}function tg(e){return!(!Number.isInteger(e)||e<0||e>Rh)}function ng(e){return!(!Number.isInteger(e)||e<0||e>Lh)}function rg(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 tg(+e)}function ig(e){for(var t=e.length-1;t>=0&&!rg(e[t]);t--);return t+1}function ag(e){let t=Object.keys(e);return t.length=ig(t),t}function og(e){return new Uint8Array(e).toBase64()}function sg(e){return Uint8Array.fromBase64(e).buffer}function cg(e){return Buffer.from(e).toString(`base64`)}function lg(e){return Uint8Array.from(Buffer.from(e,`base64`)).buffer}function ug(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 dg(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 fg=typeof Uint8Array.fromBase64==`function`,pg=typeof process==`object`&&process.versions?.node!==void 0,mg=fg?og:pg?cg:ug,hg=fg?sg:pg?lg:dg;function gg(e,t){if(!t)return e;let n={};for(let r of Object.keys(e))n[r]=t[r]??e[r];return n}var _g=Object.freeze({kind:`not-plain`}),vg=Object.freeze({kind:`symbol-keys`}),yg=Object.freeze({identify:e=>e,typeOf:e=>e===null?`null`:typeof e,toPrimitive:e=>e,tagOf:e=>Wh(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=>(Gh(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=>ag(e),shapeOf:e=>Uh(e)?Qh(e).length>0?vg:{kind:Object.getPrototypeOf(e)===null?`null-proto`:`plain`,keys:Object.keys(e)}:_g,get:(e,t)=>e[t]}),bg=Object.getOwnPropertyDescriptor(ArrayBuffer.prototype,`byteLength`)?.get,xg=typeof SharedArrayBuffer>`u`?void 0:Object.getOwnPropertyDescriptor(SharedArrayBuffer.prototype,`byteLength`)?.get,Sg=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{bg.call(t)}catch(e){if(!xg)throw e;xg.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[Rh]=void 0,delete t[Rh],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 Cg(){throw Error(`Invalid input`)}function wg(e,t,n){return Tg(JSON.parse(e),t,n)}function Tg(e,t,n){let r=gg(Sg,n?.operations);if(typeof e==`number`)return c(e,!0);(!Array.isArray(e)||e.length===0)&&Cg();let i=e,a=Array(i.length),o=null;function s(e){return(!tg(e)||e>=i.length)&&Cg(),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`)&&Cg(),e in a)return a[e];e>=i.length&&Cg();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&&Cg()}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`)&&Cg();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(hg(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];ng(t)||Cg();let n=r.createSparseArray(t);a[e]=n;for(let e=2;e<l.length;e+=2){let i=l[e];(!tg(i)||i>=t)&&Cg(),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 Eg(e,t,n){let r=Dg(!1,e,t,n);return typeof r==`string`?r:`[${r.join(`,`)}]`}function Dg(e,t,n,r){let i=gg(yg,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 zh(e,Vh(c,e=>{let t=i.typeOf(e);return t!==`object`&&t!==`function`&&t!==`symbol`?Og(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=Og(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\",${Jh(i.toStringValue(t))}]`;break;case`URLSearchParams`:m=`[\"URLSearchParams\",${Jh(i.toStringValue(t))}]`;break;case`RegExp`:let{source:n,flags:r}=i.regExpInfo(t);m=r?`[\"RegExp\",${Jh(n)},\"${r}\"]`:`[\"RegExp\",${Jh(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}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(Bh,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\",\"${mg(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}\",${Jh(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+=`,${Zh(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+=`${Zh(r)}:${d(i.get(t,r))}`,c.pop();m+=`}`}}}}return a[n]=m,n}let f=d(t);return f<0?`${f}`:a}function Og(e){let t=typeof e;return t===`string`?Jh(e):e===void 0?`-1`:e===0&&1/e<0?`-6`:t===`bigint`?`[\"BigInt\",\"${e}\"]`:String(e)}var kg=e=>Object.prototype.toString.call(e).slice(8,-1),Ag=e=>kg(e).startsWith(`Temporal.`),jg=e=>e instanceof Number||e instanceof String||e instanceof Boolean||kg(e)===`BigInt`;function Mg(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||jg(e)||Ag(e)}function Ng(e){if(!Mg(e))return;let t=e instanceof Error?`Error`:kg(e);return`${/^[AEIOU]/.test(t)?`an`:`a`} ${t}`}var Pg=[`message`,`cause`,`errors`],Fg=e=>e!==`4294967295`&&String(Number(e)>>>0)===e;function Ig(e){let t=Object.keys(e);return Array.isArray(e)?t.filter(e=>!Fg(e)):t}var Lg=[[`hasIndices`,`d`],[`global`,`g`],[`ignoreCase`,`i`],[`multiline`,`m`],[`dotAll`,`s`],[`unicode`,`u`],[`unicodeSets`,`v`],[`sticky`,`y`]].flatMap(([e,t])=>{let n=Object.getOwnPropertyDescriptor(RegExp.prototype,e)?.get;return n?[[t,n]]:[]});function Rg(e){return[Reflect.get(RegExp.prototype,`source`,e),Lg.map(([t,n])=>n.call(e)?t:``).join(``)]}function zg(e){let[t,n]=Rg(e);return`/${t}/${n}`}function Bg(e){return Ct(e)?e.entries():Map.prototype.entries.call(e)}function Vg(e){return Ct(e)?e.values():Set.prototype.values.call(e)}function Hg(e){if(Ct(e))return e.size;let t=e instanceof Map?Map.prototype:Set.prototype;return Reflect.get(t,`size`,e)}function Ug(e,t){return Ct(e)?e.get(t):Map.prototype.get.call(e,t)}function Wg(e,t,n){Ct(e)?e.set(t,n):Map.prototype.set.call(e,t,n)}var Gg=new Map,Kg=new Map,qg=[ArrayBuffer,DataView,Object.getPrototypeOf(Int8Array),URL,URLSearchParams,Number,String,Boolean,Promise,WeakMap,WeakSet,Function];function Jg(e,t){let n=typeof t==`function`?qg.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)`);Gg.set(e,t),Kg.set(t,e)}function Yg(e){let t=Object.getPrototypeOf(e);return t===null?void 0:Kg.get(t.constructor)}var Xg=`c:`,Zg=`E:`,Qg=`S`,$g=`K`,e_=`R`,t_=new Map([Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError,globalThis.AggregateError].map(e=>[e.prototype,e.name])),n_=new Map([...t_].map(([e,t])=>[t,e.constructor])),r_=[`message`,`cause`,`errors`],i_=e=>typeof e==`object`&&!!e,a_=e=>i_(e)&&Object.getPrototypeOf(e)===Object.prototype,o_=e=>TypeError(`spindle: Malformed data for class \"${e}\"`),s_=(e,t,n)=>{Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0,configurable:!0})};function c_(e){if(Object.getOwnPropertySymbols(e).length>0)throw TypeError(`spindle: Cannot save an object with symbol keys`)}function l_(e,t=Object.keys(e)){c_(e);let n={};if(e instanceof Error)for(let t of r_)K(e,t)&&s_(n,t,e[t]);for(let r of t)s_(n,r,e[r]);return n}var u_={Array,Map,Set,Date,RegExp};function d_(e){let t=()=>l_(e,Ig(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(Bg(e)),t()]:e instanceof Set?[`Set`,Array.from(Vg(e)),t()]:e instanceof Date?[`Date`,Date.prototype.getTime.call(e),t()]:e instanceof RegExp?[`RegExp`,[...Rg(e),e.lastIndex],t()]:h_(l_(e))}function f_(e){for(let t of r_)K(e,t)&&Object.defineProperty(e,t,{enumerable:!1})}var p_=e=>e.length===1&&JSON.stringify(e).length>3;function m_(e){let t=Object.keys(e);if(!t.some(p_))return!1;if(c_(e),t.includes(`__proto__`))throw TypeError(`spindle: Cannot save a property named \"__proto__\"`);return t.flatMap(t=>[t,e[t]])}function h_(e){let t=m_(e);return t?[$g,...t]:e}function g_(){let e={};for(let[t,n]of Gg)e[Xg+t]=e=>i_(e)&&Object.getPrototypeOf(e)===n.prototype&&d_(e);for(let[t,n]of t_)e[Zg+n]=e=>i_(e)&&Object.getPrototypeOf(e)===t&&h_(l_(e));return e[Qg]=e=>{if(typeof e!=`symbol`)return!1;let t=Symbol.keyFor(e);return t!==void 0&&[t]},e[e_]=e=>e instanceof RegExp&&e.lastIndex!==0&&[...Rg(e),e.lastIndex],e[$g]=e=>a_(e)&&m_(e),e}function __(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 v_(e,t){return e===`RegExp`?__(t):typeof t==`number`?new Date(t):void 0}var y_=new WeakMap;function b_(e,t,n){let[r,i,a]=n,o=typeof r==`string`&&K(u_,r)?u_[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)&&!a_(a))throw o_(e);let c=y_.get(n);if(!c){let a=s?v_(r,i):new o;if(!a)throw o_(e);c=Object.setPrototypeOf(a,t.prototype),y_.set(n,c)}if(!s&&Array.isArray(i)&&x_(c,i),a_(a))for(let e of Object.keys(a))s_(c,e,a[e]);return c}function x_(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 S_(e){return Array.isArray(e)&&e[0]===$g?D_(e,1):e}function C_(e){return t=>{if(t=S_(t),Array.isArray(t))return b_(e,w_(e),t);if(!a_(t)){if(i_(t)&&Yg(t)===e)return t;throw o_(e)}let n=w_(e);if(Object.values(u_).some(e=>n.prototype instanceof e))throw o_(e);return Object.setPrototypeOf(t,n.prototype),t instanceof Error&&f_(t),t}}function w_(e){let t=Gg.get(e);if(!t)throw TypeError(`spindle: The save holds an instance of class \"${e}\", which is not registered`);return t}function T_(e){let t=n_.get(e);if(t)return n=>{if(n=S_(n),Object.getPrototypeOf(n)===t.prototype)return n;if(!a_(n))throw TypeError(`spindle: Malformed data for \"${e}\"`);return Object.setPrototypeOf(n,t.prototype),f_(n),n}}var E_=new WeakMap;function D_(e,t=0){if(!Array.isArray(e)||(e.length-t)%2!=0)throw TypeError(`spindle: Malformed object entries`);let n=E_.get(e);n||E_.set(e,n={});for(let r=t;r<e.length&&K(e,r);r+=2){let t=e[r];if(typeof t!=`string`||t===`__proto__`)throw TypeError(`spindle: Malformed object entries`);s_(n,t,K(e,r+1)?e[r+1]:void 0)}return n}var O_=new Proxy({},{getOwnPropertyDescriptor(e,t){let n=k_(t);return n&&{value:n,enumerable:!0,configurable:!0}},get:(e,t)=>k_(t)});function k_(e){if(typeof e==`string`){if(e===Qg)return e=>{if(!Array.isArray(e)||typeof e[0]!=`string`)throw TypeError(`spindle: Malformed symbol`);return Symbol.for(e[0])};if(e===$g)return D_;if(e===e_)return e=>{let t=__(e);if(!t)throw TypeError(`spindle: Malformed regular expression`);return t};if(e.startsWith(Xg))return C_(e.slice(2));if(e.startsWith(Zg))return T_(e.slice(2))}}function A_(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`:i_(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 j_(e){try{return Eg(e,g_())}catch(t){throw A_(t,e)}}function M_(e){return wg(e,O_)}var N_=class extends Error{constructor(){super(`This save was made by an incompatible version of Spindle`),this.name=`IncompatibleSaveError`}},P_={};function F_(e){if(typeof e!=`number`||!Number.isInteger(e)||e<1||e>1)throw new N_}function I_(e,t){F_(e);let n=t;for(let t=e;t<1;t++){let e=P_[t];if(!e)throw new N_;n=e(n)}return n}var L_=e=>e&&new Map(Object.entries(e));function R_(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 z_(e){try{return{formatVersion:1,data:j_({...e,visitCounts:L_(e.visitCounts),renderCounts:L_(e.renderCounts)})}}catch(e){throw R_(e)}}var B_=()=>Error(`Invalid save data`);function V_(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function H_(e){return e==null||V_(e)&&typeof e.seed==`string`&&typeof e.pull==`number`&&Number.isInteger(e.pull)&&e.pull>=0}var U_=e=>V_(e)&&typeof e.passage==`string`&&V_(e.variables)&&typeof e.timestamp==`number`&&H_(e.prng),W_=e=>e===void 0||Array.isArray(e)&&Array.from(e).every(e=>V_(e)&&typeof e.condition==`string`&&V_(e.options)),G_=e=>e===void 0||e instanceof Map&&[...e.keys()].every(e=>typeof e==`string`);function K_(e){if(!V_(e)||typeof e.passage!=`string`||!V_(e.variables))return!1;let{history:t,historyIndex:n}=e;return!Array.isArray(t)||t.length===0||!Array.from(t).every(U_)||typeof n!=`number`||!Number.isInteger(n)||n<0||n>=t.length||t[n].passage!==e.passage?!1:G_(e.visitCounts)&&G_(e.renderCounts)&&H_(e.prng)&&W_(e.watchers)&&(e.interfaceWatchers===void 0||typeof e.interfaceWatchers==`boolean`)}var q_=e=>e instanceof Map?ws(Object.fromEntries(e)):void 0;function J_(e){if(typeof e!=`object`||!e)throw B_();let{formatVersion:t,data:n}=e;if(F_(t),typeof n!=`string`)throw B_();let r=M_(I_(t,n));if(!K_(r))throw B_();let i={...r,visitCounts:q_(r.visitCounts),renderCounts:q_(r.renderCounts)};return i.visitCounts===void 0&&delete i.visitCounts,i.renderCounts===void 0&&delete i.renderCounts,i}var Y_=`Invalid save file format`;function X_(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Z_=[`id`,`passage`,`ifid`,`playthroughId`,`createdAt`,`updatedAt`,`title`];function Q_(e){let t=console.warn;console.warn=()=>{};try{J_(e)}finally{console.warn=t}}function $_(e){if(!X_(e))throw Error(Y_);if(!K(e,`formatVersion`))throw e.version===1?new N_:Error(Y_);if(F_(e.formatVersion),typeof e.ifid!=`string`)throw Error(Y_);let t=e.save;if(!X_(t)||!X_(t.meta))throw Error(Y_);let n=t.meta;if(Z_.some(e=>typeof n[e]!=`string`))throw Error(Y_);try{Q_(t.payload)}catch(e){throw e instanceof N_?e:Error(Y_)}}function ev(e){try{return $_(e),!0}catch{return!1}}function tv(e){return JSON.stringify(e).length}function nv(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 rv={autosave:`autosave.`,slot:`slot.`,slotIndex:`slotIndex.`,playthroughCount:`playthroughCount.`,currentPlaythrough:`currentPlaythroughId.`};function iv(e,t){let{slot:n,...r}=rv;return Object.values(r).some(n=>e===n+t)||e.startsWith(n)&&e.endsWith(`.${t}`)}function av(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=>iv(t,e)),getAllMetaKeys:()=>r.keys(),destroy:i}}function ov(){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 av(`memory`,nv(n),async()=>{for(let e of t)e.clear()})}var sv={saves:`spindle.save.`,playthroughs:`spindle.pt.`,meta:`spindle.meta.`},cv={\"saves.ifid\":`spindle.idx.saves.`,\"saves.playthroughId\":`spindle.idx.saves-pt.`,\"playthroughs.ifid\":`spindle.idx.pt.`};function lv(e){let t=localStorage.getItem(e);if(t!==null)try{return JSON.parse(t)}catch{return}}function uv(e,t){localStorage.setItem(e,JSON.stringify(t))}function dv(e){localStorage.removeItem(e)}function fv(e,t){try{t===null?localStorage.removeItem(e):localStorage.setItem(e,t)}catch{}}function pv(e){return lv(e)??[]}function mv(e,t){let n=pv(e);n.includes(t)||(n.push(t),uv(e,n))}function hv(e,t){let n=pv(e).filter(e=>e!==t);n.length>0?uv(e,n):dv(e)}var gv=e=>Object.keys(localStorage).filter(t=>t.startsWith(e));function _v(){function e(e,t){let n=sv[e],r=Object.entries(t).map(([t,n])=>({field:t,read:n,prefix:cv[`${e}.${t}`]})),i=e=>r.map(t=>`${t.prefix}${t.read(e)}`);return{get:async e=>lv(`${n}${e}`),async put(e,t){let r=lv(`${n}${e}`),a=i(t),o=r===void 0?[]:i(r).filter(e=>!a.includes(e)),s=[`${n}${e}`,...o,...a],c=s.map(e=>localStorage.getItem(e));try{for(let t of o)hv(t,e);uv(`${n}${e}`,t);for(let t of a)mv(t,e)}catch(e){throw s.forEach((e,t)=>fv(e,c[t]??null)),e}},async delete(e){let t=lv(`${n}${e}`);if(t!==void 0)for(let n of i(t))hv(n,e);dv(`${n}${e}`)},async find(e,t){let i=r.find(t=>t.field===e),a=[];for(let e of pv(`${i.prefix}${t}`)){let t=lv(`${n}${e}`);t!==void 0&&a.push(t)}return a},keys:async()=>gv(n).map(e=>e.slice(n.length))}}return av(`localstorage`,nv(e),async()=>{for(let e of gv(`spindle.`))dv(e)})}var vv=`spindle`,yv=1,bv={saves:{keyPath:`meta.id`,indexes:{ifid:`meta.ifid`,playthroughId:`meta.playthroughId`}},playthroughs:{keyPath:`id`,indexes:{ifid:`ifid`}},meta:{keyPath:`key`,indexes:{}}};function xv(){let e=null;function t(){return e||(e=new Promise((t,n)=>{let r=indexedDB.open(vv,yv);r.onupgradeneeded=()=>{let e=r.result;for(let[t,{keyPath:n,indexes:r}]of Object.entries(bv)){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 av(`indexeddb`,nv(r),async()=>{(await t()).close(),e=null,await new Promise((e,t)=>{let n=indexedDB.deleteDatabase(vv);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 Sv=null;async function Cv(){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)}),xv()}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 _v()}}catch{}return ov()}var wv=null;function Tv(){if(Sv)return Promise.resolve(Sv);if(!wv){let e=Cv().then(t=>(wv===e&&(Sv=t),t));wv=e}return wv}function Ev(){Sv=null,wv=null}function Dv(){return Sv?.type??`memory`}function Ov(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&&Ct(t)&&(t instanceof Map||t instanceof Set)){let r=Ot(t);r&&K(r,e)&&(n=r[e])}}return n}var kv=e=>e===`length`||ps(e),Av=Ng;function jv(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 Mv(e,t,n,r={}){let i=Iv(e,t,r.createMissing??!1);i[t[t.length-1]]=n}function Nv(e,t){let n=t[t.length-1];Pv(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=Iv(e,t,!1);if(Array.isArray(i)&&Ct(i)&&t.length>1){let r=An(i).slice();delete r[Number(n)];let a=Iv(e,t.slice(0,-1),!1);a[t[t.length-2]]=r}else delete i[n]}function Pv(e){if(e.includes(`__proto__`))throw TypeError(`spindle: Cannot use \"__proto__\" in a variable path (\"${e.join(`.`)}\")`)}function Fv(e,t,n,r,i){if(i&&Yg(e)!==void 0)return;let a=Av(e)??(Array.isArray(e)&&!kv(t)?`an array`:``);if(a)throw TypeError(`spindle: Cannot set property \"${t}\" on ${a} (at \"${n.slice(0,r).join(`.`)}\")`)}function Iv(e,t,n){Pv(t);let r=Ct(e),i=e;for(let e=0;e<t.length-1;e++){let a=t[e];Fv(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&&!Ct(o)&&!Av(o)&&(o=jv(o),i[a]=o);i=o}return Fv(i,t[t.length-1],t,t.length-1,!r),i}function Lv(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function Rv(e,t,n,r){if(n(t),Yg(e)===void 0)return t;Object.setPrototypeOf(t,Object.getPrototypeOf(e));for(let n of Ig(e))hs(t,n,r(n));return t}function zv(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))hs(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(...Rg(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(jg(e))return r(e,Object(e.valueOf()));if(Ag(e))return e;if(e instanceof Error){let t=r(e,Object.create(Object.getPrototypeOf(e)));for(let n of[...Pg,`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&&Gv(e)&&Gv(n)?r(e,n):e}let s=(e,t)=>Rv(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 Bg(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 Vg(e))Set.prototype.add.call(t,o(c(n),n));return t}let u=a(l);if(u!==void 0)return u;let d=Yg(l)!==void 0||Lv(e);return!d&&t.keepUnregistered?e:i(l,r(l,d?Object.create(Object.getPrototypeOf(l)):{}))}return c(e)}function Bv(e,t){return Qv(e,t,Vv())}function Vv(){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 Hv(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 Uv(e,t){return Qv(e,t,Hv())}function Wv(e,t){if(!Gv(e)||!Gv(t))return t;let n=new Map,r=new Map,i=e=>Gv(e)?zv(e,{keepUnregistered:!0,seen:n}):e;function a(e,t){let i=Hv(r,n);if(Qv(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(!Gv(t))return t;let r=n.get(t);if(r!==void 0)return r;if(!Gv(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=>Rv(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 Bg(t))Map.prototype.set.call(n,i(r),o(Ug(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(ey(e,t,!1)){let e=Object.create(Object.getPrototypeOf(t));n.set(t,e);for(let t of Object.keys(c))hs(e,t,l(t));return e}return i(t)}return o(e,t)}var Gv=e=>typeof e==`object`&&!!e;function Kv(e,t){let n=ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e),r=ArrayBuffer.isView(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):new Uint8Array(t);if(n.length!==r.length)return!1;for(let e=0;e<n.length;e++)if(n[e]!==r[e])return!1;return!0}function qv(e,t,n){if(e instanceof Date){let r=Date.prototype.getTime;return Object.is(r.call(e),r.call(t))&&Zv(e,t,n)}if(e instanceof RegExp)return zg(e)===zg(t)&&e.lastIndex===t.lastIndex&&Zv(e,t,n);if(ArrayBuffer.isView(e)){let r=t;return e.byteOffset===r.byteOffset&&e.byteLength===r.byteLength&&Qv(e.buffer,r.buffer,n)}if(e instanceof ArrayBuffer)return Kv(e,t);if(e instanceof URL||e instanceof URLSearchParams)return String(e)===String(t);if(jg(e))return Object.is(e.valueOf(),t.valueOf());if(Ag(e))return String(e)===String(t);if(e instanceof Error)return Pg.every(r=>K(e,r)===K(t,r)&&Qv(e[r],t[r],n))&&Jv(e,t,n)}function Jv(e,t,n,r=Object.keys){let i=e,a=t,o=r(i);if(o.length!==r(a).length)return!1;for(let e of o)if(!K(a,e)||!Qv(i[e],a[e],n))return!1;return!0}var Yv=new Set([Array.prototype,Map.prototype,Set.prototype,Date.prototype,RegExp.prototype]);function Xv(e){return Yv.has(Object.getPrototypeOf(e))?[]:Ig(e)}function Zv(e,t,n){return Jv(e,t,n,Xv)}function Qv(e,t,n){if(Object.is(e,t)&&!(n.strict&&Gv(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(Hg(e)!==Hg(r))return!1;let i=e instanceof Map?Bg(e):Vg(e),a=r instanceof Map?Bg(r):Vg(r);for(let e=i.next(),t=a.next();!e.done;e=i.next(),t=a.next())if(!Qv(e.value,t.value,n))return!1;return Zv(e,t,n)}let i=qv(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||!Qv(e[t],r[t],n))return!1;return Zv(e,t,n)}return Jv(e,t,n)}function $v(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&!Mg(e)}function ey(e,t,n){return n&&(Array.isArray(e)||Array.isArray(t))?Array.isArray(e)&&Array.isArray(t)&&Object.getPrototypeOf(e)===Object.getPrototypeOf(t):$v(e)&&$v(t)&&Object.getPrototypeOf(e)===Object.getPrototypeOf(t)}function ty(e,t,n){let r=[],i=(e,t,i)=>{Object.is(t,i)||(ey(t,i,n)?r.push({key:e,kind:`nested`,before:t,after:i}):Bv(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`});a.length>o&&r.push({key:`length`,kind:`holes`,after:a.length-o})}let a=Array.isArray(t)?Xv:Object.keys;for(let n of a(t))K(e,n)?i(n,e[n],t[n]):r.push({key:n,kind:`added`,after:t[n]});for(let n of a(e))K(t,n)||r.push({key:n,kind:`deleted`});return r}function ny(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 ty(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 ry=e=>JSON.stringify(e);function iy(e,t){for(let n=1;n<=e.length;n++)if(t.has(ry(e.slice(0,n))))return!0;return!1}var ay=(e,t)=>`\\0${e}${t}`,oy=e=>e.startsWith(`\\0`);function sy(e){let t=[];if(e instanceof Map){let n=0;for(let[r,i]of Bg(e))t.push([ay(`k`,n),r],[ay(`v`,n),i]),n++}else if(e instanceof Set){let n=0;for(let r of Vg(e))t.push([ay(`s`,n++),r])}else if(e instanceof Error)for(let n of[`cause`,`errors`])K(e,n)&&t.push([ay(n===`cause`?`c`:`e`,0),e[n]]);else if(ArrayBuffer.isView(e))t.push([ay(`b`,0),e.buffer]);else return;return t}function cy(e,t){let n=e,r=0;for(let e=0;e<t.length;e++)if(oy(t[e])){if(n=Ov(n,t.slice(r,e)),!Gv(n))return;n=sy(n)?.find(([n])=>n===t[e])?.[1],r=e+1}return r===t.length?n:Ov(n,t.slice(r))}function ly(e,t,n){let r=cy(e,t.slice(0,-1)),i=/^\\0v(\\d+)$/.exec(t[t.length-1]);if(!(r instanceof Map)||!i)return!1;let a=[...Bg(r)][Number(i[1])];return a?(Wg(r,a[0],n),!0):!1}function uy(e){return e instanceof Map||e instanceof Set||e instanceof Date||e instanceof RegExp?Ig(e):[]}function dy(e,t){return Object.getPrototypeOf(e)===Object.getPrototypeOf(t)&&(uy(e).length>0||uy(t).length>0)}function fy(e,t=new Set,n=!1){let r=new Map,i=[];function a(e,t){let a=r.get(e);a?a.push(t):(r.set(e,[t]),$v(e)||Array.isArray(e)?o(e,t):(o(e,t,uy(e)),n&&sy(e)&&i.push([e,t])))}function o(e,n,r=Object.keys(e)){for(let i of r){let r=e[i];if(!Gv(r))continue;let o=[...n,i];t.has(ry(o))||a(r,o)}}o(e,[]);for(let[e,t]of i)for(let[n,r]of sy(e))Gv(r)&&a(r,[...t,n]);return r}function py(e,t,n){return new Map([...fy(e,t,n)].map(([e,t])=>[e,t[0]]))}function my(e){return[...fy(e,void 0,!0).values()].filter(e=>e.length>1)}function hy(e,t,n,r,i){let a=[],o=sy(e),s=sy(t);if(o&&s){if(Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;if(e instanceof Map||e instanceof Set){let n=Hg(t);if(Hg(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=ey(e,t,!0)?Object.keys(t):dy(e,t)?uy(t):[];for(let n of c)K(e,n)&&a.push([n,e[n],t[n]]);return a.some(([e,t,a])=>{if(!Gv(t)||!Gv(a))return!1;let o=[...n,e],s=i.get(a);return ry(r.get(t))!==ry(s)||ry(s)===ry(o)&&hy(t,a,o,r,i)})}function gy(e,t){let n=py(e,void 0,!0),r=py(t,void 0,!0),i=[];return(function e(t,a,o){for(let s of Array.isArray(a)||$v(a)?Object.keys(a):uy(a)){if(!K(t,s))continue;let c=t[s],l=a[s];if(!Gv(c)||!Gv(l))continue;let u=[...o,s],d=n.get(c),f=r.get(l),p=ry(u);ry(d)===ry(f)?ry(f)===p&&sy(c)&&hy(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}),(($v(c)||Array.isArray(c))&&ey(c,l,!0)||dy(c,l))&&ry(f)===p&&ry(d)===p&&e(c,l,u)}})(e,t,[]),i}function _y(e,t,n=!1){let r=ny(e,t,n),i=new Set(r.map(e=>ry(e.path))),a=[];for(let n of gy(e,t))iy(n.path,i)||(i.add(ry(n.path)),a.push(n));return[...a,...r]}function vy(e,t){return py(e,new Set(t.map(e=>ry(e.path))),!0)}function yy(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=cy(t,r);return Gv(i)&&(Array.isArray(i)?Array.isArray(n):Object.getPrototypeOf(i)===Object.getPrototypeOf(n))?(super.set(n,i),!0):!1}}}function by(e,t){let n=Ov(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&&Bv(n[r],t.value):t.deleted}function xy(e,t,n){t.some(oy)?ly(e,t,n):Mv(e,t,n)}function Sy(e,t){let n=e;t.deleted?Nv(n,t.path):Mv(n,t.path,t.value)}var Cy=new Set([`storyinit`,`beforerestart`,`actionsChanged`,`variableChanged`,`beforesave`,`aftersave`,`beforeload`,`afterload`,`beforenavigate`,`afternavigate`,`passagerender`,`dialogrender`]),wy=new Map;function Ty(e,t){if(!Cy.has(e))throw Error(`spindle: Unknown event \"${e}\".`);let n=wy.get(e);return n||(n=new Set,wy.set(e,n)),n.add(t),()=>{n.delete(t)}}function Ey(e,t){let n=wy.get(e);if(n)for(let e of[...n])t(e)}function Dy(e,...t){Ey(e,e=>e(...t))}function Oy(e,...t){Ey(e,n=>{try{n(...t)}catch(t){console.error(`spindle: Error in ${e} handler:`,t)}})}var ky=null,Ay=null;function jy(e){ky=e}function My(e){Ay=e}function Ny(e){return ru(()=>Py(e))}function Py(e){if(Ay)try{let t=Function(`passage`,`variables`,Ay)(e.passage,e.variables);if(typeof t==`string`&&t.trim())return t.trim()}catch{}if(ky)try{let t=ky(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 Fy=`spindle-saves`,Iy=Promise.resolve();function Ly(e){let t=Iy.then(()=>hb(Fy,e));return Iy=t.catch(()=>{}),t}function Ry(e){return(...t)=>Ly(()=>e(...t))}var zy=e=>Ry(async t=>e(await(await Tv()).getSave(t))),By=e=>Ry(async(t,n)=>e(await yb(t,n))),Vy=Ry(Hy);async function Hy(e,t=dt()){let n=await Tv();return await hb(`spindle-playthrough-count:${e}`,async()=>{let r=await Gy(e),i={id:t,ifid:e,createdAt:new Date().toISOString(),label:`Playthrough ${r}`};await n.putPlaythrough(i),await n.setMeta(Wy(e),r)}),await n.setMeta(Ky(e),t),Kb(e,t),t}var Uy=/^Playthrough (\\d+)$/;function Wy(e){return`${rv.playthroughCount}${e}`}async function Gy(e){let t=await Tv(),n=await t.getMeta(Wy(e))??0;for(let r of await t.getPlaythroughsByIfid(e)){let e=Uy.exec(r.label);e&&(n=Math.max(n,Number(e[1])))}return n+1}function Ky(e){return`${rv.currentPlaythrough}${e}`}var qy=Ry(Jy);async function Jy(e,t){let n=await Tv();await Yy(e,t,new Date().toISOString());let r=Ky(e);await n.getMeta(r)!==t&&await n.setMeta(r,t),Kb(e,t)}async function Yy(e,t,n){let r=await Tv();(await r.getPlaythroughsByIfid(e)).some(e=>e.id===t)||await r.putPlaythrough({id:t,ifid:e,createdAt:n,label:`Imported`})}function Xy(e){return Ly(async()=>{let t=await Tv(),n=qb(e),r=n!==void 0&&(await t.getPlaythroughsByIfid(e)).some(e=>e.id===n)?n:await t.getMeta(Ky(e))??await Hy(e);return Kb(e,r),{id:r,knownSaves:await Ib(e)}})}function Zy(e,t,n,r){try{let i=n();return ru(()=>Dy(`beforesave`,e,t)),r(i()).then(t=>(ru(()=>Dy(`aftersave`,e)),t))}catch(e){return Promise.reject(e)}}function Qy(e,t){let n=z_(t);return{meta:{...e,estimatedBytes:tv(n)},payload:n}}var $y=Ry(eb);async function eb(e,t,n,r={}){let i=await t;if(!i)throw Error(`No playthrough`);let a=new Date().toISOString(),o=Qy({id:dt(),ifid:e,playthroughId:i,createdAt:a,updatedAt:a,title:Ny(n),passage:n.passage,custom:r},n);return await(await Tv()).putSave(o),Ob(e),o}var tb=Ry(nb);async function nb(e,t,n,r){let i=await r,a=await Tv(),o=await a.getSave(e);if(!o)return;let s=Qy({...o.meta,...i?{playthroughId:i}:{},updatedAt:new Date().toISOString(),title:o.meta.userTitle===!0?o.meta.title:Ny(t),passage:t.passage,...n==null?{}:{custom:{...o.meta.custom,...n}}},t);return await a.putSave(s),Ob(s.meta.ifid),s}var rb=e=>e&&J_(e.payload),ib=e=>J_(e);zy(rb);var ab=zy(e=>e);function ob(e){return Ly(async()=>{let t=await Tv(),n=await t.getSave(e);await t.deleteSave(e),n&&(await Sb(n.meta.ifid,t=>t===e),Ob(n.meta.ifid))})}function sb(e,t){return Ly(async()=>{let n=await Tv(),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),Ob(i.meta.ifid)})}var cb=Ry(async function(e){let t=await Tv(),[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}),lb=rv.autosave,ub=rv.slot,db=rv.slotIndex;function fb(e){return e!=null&&e!==``}function pb(e,t){return fb(t)?`${ub}${t}.${e}`:`${lb}${e}`}var mb=e=>`${db}${e}`;async function hb(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 gb(e,t){let n=await Tv();await hb(`spindle-slot-index:${e}`,async()=>{let r=await n.getMeta(mb(e))??[],i=t(r);i!==r&&await n.setMeta(mb(e),i)})}async function _b(e){return[void 0,...(await(await Tv()).getMeta(mb(e))??[]).filter(fb)]}async function vb(e,t){return(await Tv()).getMeta(pb(e,t))}async function yb(e,t){let n=await vb(e,t);return n?(await Tv()).getSave(n):void 0}async function bb(e,t,n){await(await Tv()).setMeta(pb(e,t),n),fb(t)&&await gb(e,e=>e.includes(t)?e:[...e,t]),Ob(e)}async function xb(e,t){await(await Tv()).deleteMeta(pb(e,t)),fb(t)&&await gb(e,e=>e.filter(e=>e!==t)),Ob(e)}async function Sb(e,t){for(let n of await _b(e)){let r=await vb(e,n);r&&t(r)&&await xb(e,n)}}var Cb=`spindle.slots`,wb=`*`,Tb;function Eb(){if(Tb===void 0)try{Tb=new BroadcastChannel(Cb),Tb.unref?.()}catch{Tb=null}return Tb}var Db=new Set;function Ob(e){for(let t of[...Db])(e===wb||t.ifid===e)&&t.onChange();try{Eb()?.postMessage(e)}catch{}}function kb(e,t,n=!1){let r={ifid:e,onChange:t};n&&Db.add(r);let i=Eb(),a=n=>{(n.data===e||n.data===wb)&&t()},o=()=>{document.visibilityState===`visible`&&t()},s=typeof document>`u`?void 0:document;return i?.addEventListener(`message`,a),s?.addEventListener(`visibilitychange`,o),()=>{Db.delete(r),i?.removeEventListener(`message`,a),s?.removeEventListener(`visibilitychange`,o)}}var Ab=e=>({isAutosave:!fb(e),...fb(e)?{slot:e}:{}});function jb(e,t){return{slot:fb(t)?t:``,title:e.meta.title,passage:e.meta.passage,createdAt:e.meta.createdAt,updatedAt:e.meta.updatedAt,custom:e.meta.custom??{}}}function Mb(e,t,n,r,i){return Ly(async()=>{let a=await t,o=await vb(e,r);if(o){let e=await nb(o,n,i,a);if(e)return e}let s=await eb(e,a,n,{...Ab(r),...i});return await bb(e,r,s.meta.id),s})}async function Nb(e,t){return await yb(e,t)!==void 0}By(rb);function Pb(e,t,n){return Ly(async()=>{let r=await yb(e,t);if(!r)return;let i=J_(r.payload);n?.(i);let{playthroughId:a}=r.meta;return a&&await Jy(e,a),{payload:i,playthroughId:a}})}var Fb=Ry(Ib);async function Ib(e){let t=Object.create(null);for(let n of await _b(e))await Nb(e,n)&&(t[n??``]=!0);return t}var Lb=Ry(Rb);async function Rb(e,t){let n=await yb(e,t);return n?jb(n,t):null}var zb=Ry(async e=>{let t=[];for(let n of await _b(e)){let r=await Rb(e,n);r&&t.push(r)}return t}),Bb=Ry(async(e,t)=>{let n=await vb(e,t);n&&(await(await Tv()).deleteSave(n),await xb(e,t))}),Vb=`spindle.session.`;function Hb(e,t){let n=JSON.stringify(z_(t));try{sessionStorage.setItem(`${Vb}${e}`,n)}catch(e){return{error:e}}}function Ub(e){try{let t=sessionStorage.getItem(`${Vb}${e}`);return t?J_(JSON.parse(t)):void 0}catch(t){t instanceof N_&&(console.warn(`spindle: ${t.message}; the session was not restored.`),Wb(e));return}}function Wb(e){try{sessionStorage.removeItem(`${Vb}${e}`)}catch{}}var Gb=`${Vb}playthrough.`;function Kb(e,t){try{sessionStorage.setItem(`${Gb}${e}`,t)}catch{}}function qb(e){try{return sessionStorage.getItem(`${Gb}${e}`)||void 0}catch{return}}function Jb(e){if(e)return{formatVersion:1,ifid:e.meta.ifid,exportedAt:new Date().toISOString(),save:e}}var Yb=zy(Jb);async function Xb(e,t){if($_(e),e.ifid!==t)throw Error(`Save is from a different story (expected IFID ${t}, got ${e.ifid})`);let n=zv(e.save);return n.meta.id=dt(),n.meta.updatedAt=new Date().toISOString(),n.meta.ifid=t,await Yy(t,n.meta.playthroughId,n.meta.createdAt),n}function Zb(e,t){return Ly(async()=>{let n=await Xb(e,t);return await(await Tv()).putSave(n),Ob(t),n})}var Qb=By(Jb);function $b(e,t,n){return Ly(async()=>{let r=await Xb(e,t),{slot:i,...a}=r.meta.custom??{};r.meta.custom={...a,...Ab(n)};let o=await Tv(),s=await vb(t,n);return await o.putSave(r),await bb(t,n,r.meta.id),s&&await o.deleteSave(s),jb(r,n)})}var ex=Ry(async function(e){let t=await Tv(),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=tv(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 tx(e){return Ly(async()=>{let t=await Tv();await t.deleteSavesByIfid(e),await t.deletePlaythroughsByIfid(e),await t.deleteMetaByIfid(e),Wb(e),Ob(e)})}var nx=Ry(rx);async function rx(){await(await Tv()).destroy(),Ev();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{}Ob(wb)}function ix(e,t,n){return Ly(async()=>{let r=await Tv(),i=await r.deleteSavesByPlaythrough(t);await r.deletePlaythroughById(t);let a=new Set(i);if(await Sb(e,e=>a.has(e)),Ob(e),n&&await n.current===t)return await Hy(e,n.id),!0;let o=Ky(e);return await r.getMeta(o)===t&&await r.deleteMeta(o),!1})}var ax=null;function ox(){ax&&(pe(null,ax),ax.remove(),ax=null)}function sx(){ox();let e=Q.getState();if(!e.storyData)return;let t=e.storyData.passages.get(`StoryInit`);if(t){let e=ns(t.content);Nl(e,`StoryInit`);let n=document.createElement(`div`);n.style.display=`none`,document.body.appendChild(n),ax=n,pe(b(()=>Ih(e),null),n),$S()}let n=e.storyData.passages.get(`SaveTitle`);n&&My(n.content)}function cx(e){sx();let t=e?FC(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),Dy(`storyinit`),e||$S()}var lx=[`variables`,`temporary`,`transient`],ux=[];function dx(){return ux[ux.length-1]?.work}function fx(){let e=Q.getState(),t=dx();return t?{...e,...t}:e}var px=e=>zv(e,{keepUnregistered:!0});function mx(e,t){let n=t?yy(t,e):new Map,r=(r,i)=>{let a=t?.get(i);if(!a||!Ct(r))return r;let o=An(r);return a.some(oy)||Mv(e,a,o),n.set(i,o),o};return e=>zv(e,{keepUnregistered:!0,seen:n,settle:r})}var hx=e=>{let t=new Map;return n=>{let r=t.get(n);return r||(r=mx(n,e?.(n)),t.set(n,r)),r}};function gx(e){return Ut(px(e),!0)}function _x(e){return e instanceof Map?!K(e,`set`):e instanceof Set?!K(e,`add`):e instanceof Date||e instanceof URL||e instanceof URLSearchParams}function vx(e,t=new Set){if(typeof e!=`object`||!e||t.has(e))return!0;if(ArrayBuffer.isView(e)||e instanceof ArrayBuffer||!Object.isFrozen(e)||_x(e))return!1;if(t.add(e),e instanceof Map){for(let[n,r]of Bg(e))if(!vx(n,t)||!vx(r,t))return!1}else if(e instanceof Set){for(let n of Vg(e))if(!vx(n,t))return!1}return Reflect.ownKeys(e).every(n=>{let r=Object.getOwnPropertyDescriptor(e,n);return!r||!(`value`in r)||vx(r.value,t)})}function yx(e){return vx(e)?e:gx(e)}function bx(e,t,n=ux,r=xx){let[i,a]=t.path;for(let o of n)for(let n of[o.work,o.base])try{Sy(n,t.deleted?t:{...t,value:r(n)(t.value)})}catch{let t=e[i][a];K(e[i],a)?n[i][a]=px(Ct(t)?An(t):t):delete n[i][a]}}var xx=e=>mx(e),Sx=new Set(lx),Cx=new On({autoFreeze:!1}),wx=!1;function Tx(e,t){let n=[],r=e;for(let e of t){if(!$v(r))break;let t=String(e);n.push(t),r=K(r,t)?r[t]:void 0}return n}function Ex(e,t){let n=Ov(e,t.slice(0,-1)),r=t[t.length-1];return $v(n)&&K(n,r)?{path:t,deleted:!1,value:n[r]}:{path:t,deleted:!0}}function Dx(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=>Ex(t,[e]));let r=new Set,i=[];for(let e of n){let n=Tx(t,e.path.slice(1)),a=JSON.stringify(n);r.has(a)||(r.add(a),i.push(Ex(t,n)))}return i}function Ox(e){if(wx){wx=!1;return}if(ux.length===0)return;Mx(Px());let t=ux[ux.length-1],n={...Q.getState(),variables:t.work.variables,temporary:t.work.temporary,transient:t.work.transient},[r,i]=Cx.produceWithPatches(n,e),a=lx.flatMap(e=>{let t=i.filter(t=>t.path[0]===e);return t.length?Dx(n[e],r[e],t).map(t=>({...t,path:[e,...t.path]})):[]}),o=vy(jx(t.work),a),s=hx(()=>o),c=(e,t)=>e.deleted?e:{...e,value:s(t)(e.value)};for(let e of a)Sy(t.work,c(e,t.work));return e=>{let i=e;for(let e of Object.keys(r)){let t=r[e];!Sx.has(e)&&t!==n[e]&&(i[e]=t)}let o=e;for(let e of a){let[n,r]=e.path;try{Sy(o,c(e,o))}catch{K(t.work[n],r)?o[n][r]=px(t.work[n][r]):delete o[n][r]}bx(o,e,ux,s)}}}function kx(e,t,n){let r=n.map(e=>ry(e.path).slice(0,-1));for(let[n,...i]of my(t)){let t=[n,...i].map(e=>ry(e).slice(0,-1));if(r.some(e=>t.some(t=>e.startsWith(t))))try{let t=cy(e,n);if(typeof t!=`object`||!t)continue;for(let n of i)xy(e,n,t)}catch{}}}function Ax(e){let t=new Map;return{variables:zv(e.variables,{keepUnregistered:!0,seen:t}),temporary:zv(e.temporary,{keepUnregistered:!0,seen:t}),transient:zv(e.transient,{keepUnregistered:!0,seen:t})}}var jx=e=>({variables:e.variables,temporary:e.temporary,transient:e.transient});function Mx(e){let t=e.map(({scope:e,keepRunning:t})=>({scope:e,keepRunning:t,changes:Nx(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=Ax(e.work));wx=!0;try{Q.getState().updateVariables(r)}finally{wx=!1}function r(e){t.forEach(({scope:n,changes:r},i)=>{let a=vy(n.work,r),o=mx(e,a),s=t.slice(0,i).map(e=>e.scope),c=hx(()=>a),l=new Set;for(let t of r){let[r,i]=t.path,a=ry([r,i]);if(!l.has(a))try{if(t.deleted){by(e,t)||Sy(e,t);continue}let n=t.alias?o(t.value):void 0;if(t.alias?Object.is(Ov(e,t.path),n):by(e,t))continue;Sy(e,{...t,value:t.alias?n:o(t.value)})}catch{e[r][i]=o(n.work[r][i]),l.add(a)}}kx(e,n.work,r);for(let t of r)bx(e,t,s,c)})}}var Nx=(e,t)=>_y(e,t),Px=()=>ux.map(e=>({scope:e,keepRunning:!0}));function Fx(e){let t=Q.getState(),n=jx(t),r=_y(e.base,n),i=mx(e.work,vy(n,r));for(let t of r)try{Sy(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=Ax(t)}function Ix(e){if(ux.length===0)return e();Mx(Px());let t=ux.splice(0);try{return e()}finally{ux.push(...t);for(let e of t)Fx(e)}}function Lx(e){Mx(Px());let t=vy(jx(dx()??Q.getState()),[]),n=Rx(),r=mx(n.work,t);try{e(n.work,r)}finally{ux.pop()}Mx([...Px(),{scope:n,keepRunning:!1}])}function Rx(){let e=dx()??Q.getState(),t={work:Ax(e),base:Ax(e)};return ux.push(t),t}function zx(e,t,n){let r=vs(zv(t,{keepUnregistered:!0})),i=Rx();try{Au(e,i.work.variables,i.work.temporary,r,i.work.transient)}finally{ux.pop()}Mx([...Px(),{scope:i,keepRunning:!1}]);let a=new Set(_y(t,r,!0).map(e=>e.path[0]));for(let e of my(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 Bx=[],Vx=!1,Hx=[],Ux=null,Wx=null;function Gx(e){let t=fx();try{return!!ku(e,t.variables,t.temporary,{},t.transient)}catch{return!1}}function Kx(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:Gx(e),priority:i?.priority??0,macroKey:n};return Bx.push(o),Bx.sort((e,t)=>t.priority-e.priority),()=>{Bx=Bx.filter(e=>e!==o)}}function qx(e,t){return Kx(e,t)}function Jx(e,t){let n=Object.fromEntries(Object.entries(t).sort(([e],[t])=>e<t?-1:1)),r=JSON.stringify([e,n]);Bx.some(e=>e.macroKey===r)||Kx(e,t,r)}function Yx(){return Bx.filter(e=>e.macroKey!==void 0&&e.options).map(e=>({condition:e.condition,options:{...e.options}}))}var Xx=new Set,Zx=0;function Qx(e,t){let n={condition:e,options:t};return Xx.add(n),()=>{Xx.delete(n)}}function $x(){return Zx++,()=>{Zx--}}function eS(){return Zx>0}function tS(e,t){Bx=Bx.filter(e=>e.macroKey===void 0);for(let{condition:t,options:n}of e)Jx(t,n);if(t===!1)for(let{condition:e,options:t}of Xx)Jx(e,t)}function nS(e){Bx=Bx.filter(t=>t.name!==e)}function rS(e){let{callback:t,options:n}=e;if(t)t();else if(n){if(n.run)try{zx(n.run,{},()=>{})}catch(t){console.error(`spindle: Error in watch run action for \"${e.condition}\":`,t)}n.dialog&&(Hx.push({passageName:n.dialog}),Ux?.()),n.goto&&Q.getState().navigate(n.goto)}}var iS=10;function aS(){for(let e=0;e<iS;e++){let e=!1,t=[...Bx];for(let n of t){if(!Bx.includes(n))continue;let t=Gx(n.condition),r=!n.lastResult;n.lastResult=t,t&&r&&(e=!0,n.options?.once&&(Bx=Bx.filter(e=>e!==n)),rS(n))}if(!e)break}}function oS(){if(!Vx){Vx=!0;try{aS()}finally{Vx=!1}}}var sS=0;function cS(){if(sS===0)return;let e=Vx;Vx=!0;try{aS()}finally{Vx=e}}function lS(){let e=Q.getState();sS++;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)&&oS()}),n=!0;return()=>{n&&(n=!1,sS--,t())}}function uS(){for(let e of Bx)e.lastResult=Gx(e.condition)}function dS(){Bx=[],fS++,TS(),pS.notify()}var fS=0,pS=js();function mS(){return fS}var hS=pS.subscribe;function gS(e){return Ux=e,Hx.length>0&&e(),()=>{Ux===e&&(Ux=null)}}function _S(){return Hx.shift()}function vS(){return Hx.length}function yS(e){Wx?Wx.push(e):(Hx.push(e),Ux?.())}function bS(){Hx=[]}function xS(e){return Wx=e,()=>{Wx===e&&(Wx=null)}}var SS=[];function CS(e){return SS.push(e),()=>{let t=SS.lastIndexOf(e);t>=0&&SS.splice(t,1)}}function wS(){let e=SS[SS.length-1];e?e():Wx?.close()}function TS(){bS();for(let e of[...SS].reverse())e();Wx?.closeAll()}function ES(){return SS.length>0||(Wx?.isOpen()??!1)}Mn(),Fn();var DS=new Set([`StoryInit`,`StoryInterface`,`StoryVariables`,`StoryTransients`,`StoryLoading`,`SaveTitle`,`PassageReady`,`PassageHeader`,`PassageFooter`,`PassageDone`]),OS=q(),kS=[],AS=q();function jS(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:zv(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(zv(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 MS(e,t){let n=Object.create(Object.getPrototypeOf(e));for(let t of Object.keys(e))hs(n,t,e[t]);for(let e of t)e.deleted?delete n[e.key]:hs(n,e.key,e.value);return n}function NS(e){let t=kS.length-1;t<0?OS=e:kS[t]=jS(IS(t),e)}function PS(e,t){let n=OS;for(let r=0;r<e;r++)r>0&&(n=MS(n,kS[r-1].forward)),t(n,r)}function FS(e,t){return{passage:e.passage,variables:t,timestamp:e.timestamp,prng:e.prng}}function IS(e){let t=OS;for(let n=0;n<e;n++)t=MS(t,kS[n].forward);return t}var LS=[];function RS(e){let{storyData:t,currentPassage:n,variables:r,history:i,historyIndex:a,visitCounts:o,renderCounts:s}=e();if(t){if(LS.length>i.length&&(LS.length=i.length),LS.length<i.length){if(i.length-LS.length===1){let e=i.length-1;LS[e]=FS(i[e],r)}else PS(i.length,(e,t)=>{t>=LS.length&&(LS[t]=FS(i[t],e))})}return Hb(t.ifid,{passage:n,variables:r,history:LS,historyIndex:a,visitCounts:o,renderCounts:s,prng:iu(),watchers:Yx(),interfaceWatchers:eS()})}}var zS=`The game could not be saved for a page reload; a reload goes back to the last passage it could save:`,BS=`The story could not go to another passage:`;function VS(e,t){let n;try{let t=RS(e);t&&Is(zS,t.error)}catch(e){n={error:e},Is(zS,e)}try{t?.()}finally{if(n)throw n.error}}function HS(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++)OS=MS(OS,kS[e].forward);return e.history=e.history.slice(n,r),kS=kS.slice(n,r-1),LS=LS.slice(n,r),e.historyIndex-=n,!0}var US=!1,WS=[],GS=null;function KS(e,t){let n=GS;if(GS=null,!n||e().navigationId!==n.navigationId)return;e().variables!==n.variables&&NS(e().variables),AS=e().variables;let r=iu(),i=e().history[e().historyIndex].prng;(r?.seed!==i?.seed||r?.pull!==i?.pull)&&t(e=>{e.history[e.historyIndex].prng=r})}var qS=e=>({...e});function JS(e){OS=e,kS=[],AS=e,LS=[]}function YS(e){let t=q(zv(e));return JS(zv(t)),t}function XS(e){return q(zv(e,{keepUnregistered:!0}))}function ZS(e,t,n,r){e.currentPassage=t,e.navigationId++,e.variables=n,e.transient=XS(r),e.temporary=q(),e.history=[{passage:t,timestamp:Date.now()}],e.historyIndex=0}function QS(e,t,n){let{historyIndex:r,history:i}=e(),a=r+n;if(a<0||a>=i.length)return;KS(e,t);let o=e().currentPassage,s=i[a].passage;Dy(`beforenavigate`,s);let c=zv(IS(a));t(e=>{e.historyIndex+=n,e.currentPassage=e.history[e.historyIndex].passage,e.navigationId++,e.variables=c,e.temporary=q()}),uS(),AS=e().variables,PC(e().history[e().historyIndex]),VS(e,()=>Dy(`afternavigate`,s,o))}function $S(){let{history:e,historyIndex:t,variables:n}=Q.getState();if(e.length!==1||t!==0)return;JS(n);let r=iu();Q.setState(e=>{e.history[0].prng=r})}var eC=Promise.resolve(``),tC=0,nC=!1;function rC(){return nC?``:Q.getState().playthroughId}function iC(){if(aC)return aC;let e=rC();return eC.then(t=>e||t)}var aC=null;function oC(e){Q.getState().playthroughId!==e&&Q.setState(t=>{t.playthroughId=e})}function sC(e){let t=++tC;return nC=!0,eC=e.then(e=>(t===tC&&(nC=!1,oC(e)),e)),eC}function cC(e,t){++tC,nC=!1,eC=t.then(()=>e,()=>e),oC(e)}function lC(e){let t=dt();cC(t,Vy(e,t).catch(e=>{console.error(`spindle: failed to start new playthrough`,e)}))}function uC(e,t){rC()!==t&&cC(t,qy(e,t).catch(e=>{console.error(`spindle: failed to switch to the loaded playthrough`,e)}))}var dC=0,fC=0,pC=null,mC=null;function hC(){return++dC}function gC(e){return fC>e}function _C(){yC(++dC)}var vC=js();function yC(e){fC=e,vC.notify()}var bC=vC.subscribe,xC=[],SC=!1;function CC(e){SC&&xC.push(e)}function wC(){SC=!0}function TC(){for(let e of xC)e();xC=[],SC=!1}function EC(e){return typeof e==`string`&&e!==``?e:null}function DC(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}var OC=null;function kC(e){OC?.set(ry(e),e)}function AC(e,t,n,r){let i=e.history[e.historyIndex];if(!i)return;let a=_y(t,n,!0),o=new Set(a.map(e=>ry(e.path)));for(let e of r){if(iy(e,o))continue;o.add(ry(e));let t=Ov(n,e);Bv(Ov(i.variables,e),t)||a.push({path:e,deleted:!1,value:t})}if(a.length===0)return;let s=zv(i.variables),c=yy(vy(n,a),s),l=e=>zv(e,{seen:c});for(let e of a)jC(s,n,e,l);i.variables=Wv(i.variables,s)}function jC(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=Ov(t,i.slice(0,o+1));if(!ey(n,s,!0)){MC(a,e,r(s));return}a=n}let s=i[o];n.deleted?MC(a,s,void 0,n):MC(a,s,r(n.value),n)}function MC(e,t,n,r){let i=r?.deleted??!1;if(Array.isArray(e)&&(t===`length`||Fg(t))){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]:hs(e,t,n)}function NC(e){e?eu(e.seed,e.pull):nu()}function PC(e){e&&NC(e.prng)}function FC(e,t){if(e)return[t.passage,...t.history.map(e=>e.passage)].find(t=>!e.passages.has(t))}function IC(e,t){let n=FC(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 LC=[`variables`,`temporary`,`transient`];function RC(e){for(let t of LC){let n=e[t];_s(n)||(e[t]=q(Ct(n)?An(n):n))}}var zC=[`navigate`,`goBack`,`goForward`,`restart`,`save`,`load`,`getSavePayload`,`loadFromPayload`];function BC(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=Ox(r);t(e=>{(i??r)(e),RC(e)})});r.setState=i;let a=e(i,n,r);for(let e of zC){let t=a[e];a[e]=(...e)=>Ix(()=>t(...e))}return a}}var VC=e=>Ln(BC(e));function HC(e){return e.catch(()=>{}),e}function UC(e,t,n){return HC(e.catch(e=>{throw console.error(t,e),n?.(e),e}))}function WC(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 GC(e,t){return Fb(t).then(t=>{e(e=>{e.knownSaves=t})})}var KC;function qC(e,t,n,r){let i=n.then(()=>{t(e=>{e.knownSaves={}})});return e().restart(),UC(i,r)}var Q=ut()(VC((e,t)=>({storyData:null,currentPassage:``,navigationId:0,variables:q(),variableDefaults:{},transient:q(),transientDefaults:{},temporary:q(),history:[],historyIndex:-1,visitCounts:ws(),renderCounts:ws(),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=HS(e)}),r&&VS(t)},setQuickSaveKey:t=>{e(e=>{e.quickSaveKey=EC(t)})},setQuickLoadKey:t=>{e(e=>{e.quickLoadKey=EC(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=YS(r);e(e=>{e.storyData=n,e.playthroughId=``,e.variableDefaults=r,e.transientDefaults=i,ZS(e,a.name,o,i),e.visitCounts=ws(null,a.name),e.renderCounts=ws(null,a.name)}),AS=t().variables,_C(),sC(Xy(n.ifid).then(({id:t,knownSaves:n})=>(e(e=>{e.knownSaves=n}),t)).catch(e=>(console.error(`spindle: failed to init save system`,e),``))),KC?.(),KC=kb(n.ifid,()=>{GC(e,n.ifid).catch(()=>{})})},navigate:n=>{if(US){WS.push(n);return}let{storyData:r}=t();if(!r)return;if(DS.has(n)){console.error(`spindle: Cannot navigate to special passage \"${n}\".`);return}if(!r.passages.has(n)){let e=Ls(n,t().currentPassage);console.error(`spindle: ${e.message}`),Is(BS,e);return}let i=t().currentPassage;Dy(`beforenavigate`,n);let a=jS(AS,t().variables);e(e=>{e.temporary=q(),e.currentPassage=n,e.navigationId++,e.history=e.history.slice(0,e.historyIndex+1),kS.length=e.historyIndex,LS.length>e.historyIndex+1&&(LS.length=e.historyIndex+1),kS.push(a),e.history.push({passage:n,timestamp:Date.now(),prng:iu()}),e.historyIndex=e.history.length-1,HS(e),e.visitCounts=ws(e.visitCounts,n),e.renderCounts=ws(e.renderCounts,n)}),GS={navigationId:t().navigationId,variables:t().variables},US=!0;try{cS()}finally{US=!1}let o=WS;WS=[],KS(t,e),VS(t,()=>{Dy(`afternavigate`,n,i);for(let e of o)t().navigate(e)})},goBack:()=>QS(t,e,-1),goForward:()=>QS(t,e,1),setVariable:(t,n)=>{e(e=>{fs(t,`$${t}`),e.variables[t]=n})},setTemporary:(t,n)=>{e(e=>{fs(t,`_${t}`),e.temporary[t]=n})},deleteVariable:t=>{e(e=>{fs(t,`$${t}`),delete e.variables[t]})},deleteTemporary:t=>{e(e=>{fs(t,`_${t}`),delete e.temporary[t]})},setTransient:(t,n)=>{e(e=>{fs(t,`%${t}`),e.transient[t]=n})},deleteTransient:t=>{e(e=>{fs(t,`%${t}`),delete e.transient[t]})},updateVariables:t=>{e(e=>{t(e)})},trackRender:t=>{e(e=>{e.renderCounts=ws(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}),Dy(`beforerestart`),lC(n.ifid),_C();let o=t().renderDeferred;TC(),nu(),dS();let s=YS(r);e(e=>{ZS(e,a.name,s,i),e.visitCounts=ws(null,a.name),e.renderCounts=ws(null,a.name),o||(e.renderDeferred=!1)}),AS=t().variables,wC(),sx(),Wb(n.ifid),Dy(`storyinit`),$S()},save:(n,r)=>{let{storyData:i}=t();if(!i)return Promise.resolve();let a=iC();return UC(Zy(n,r,t().beginSave,async t=>{e(e=>{e.saveError=null}),await Mb(i.ifid,a,t,n,r),WC(e,n,!0)}),`spindle: failed to save`,t=>e(e=>{e.saveError=As(t,`Failed to save`)}))},load:n=>{let{storyData:r}=t();if(!r)return Promise.resolve();e(e=>{e.loadError=null});let i=iC(),a=Pb(r.ifid,n,e=>IC(r,e)),o=sC(Promise.all([i,a.catch(()=>void 0)]).then(([e,t])=>t?.playthroughId||e)),s=++dC;return UC(a.then(async e=>{await o,e&&(fC>s||(pC=s,mC=i,t().loadFromPayload(e.payload,n)))}),`spindle: failed to load save`,t=>e(e=>{e.loadError=As(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?Lb(n.ifid,e):null},listSaves:async()=>{let{storyData:e}=t();return e?zb(e.ifid):[]},deleteSave:n=>{let{storyData:r}=t();return r?UC(Bb(r.ifid,n).then(()=>WC(e,n,!1)),`spindle: failed to delete save`):Promise.resolve()},exportSave:async e=>{let{storyData:n}=t();return n?await Qb(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 $b(n,i.ifid,r);return WC(e,r,!0),a},clearGameData:()=>{let{storyData:n}=t();return n?qC(t,e,tx(n.ifid),`spindle: failed to clear game data`):Promise.resolve()},clearAllData:()=>qC(t,e,nx(),`spindle: failed to clear all data`),deletePlaythrough:n=>{let{storyData:r}=t();if(!r)return Promise.resolve();let i=r.ifid,a=rC(),o=eC,s=dt(),c=ix(i,n,{current:a||o,id:s});return n!==``&&n===a?cC(s,c):a===``&&sC(c.then(e=>e?s:o,()=>o)),UC(c.then(()=>GC(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 PS(r.length,(e,t)=>{let n=qS(e);s.push(FS(r[t],t===0?n:Wv(s[t-1].variables,n)))}),{passage:e,variables:Wv(s[i]?.variables,qS(n)),history:s,historyIndex:i,visitCounts:{...a},renderCounts:{...o},prng:iu(),watchers:Yx(),interfaceWatchers:eS()}},beginSave:()=>{let e=t().variables,n=new Map;return OC=n,()=>{OC===n&&(OC=null);let r=t().getSavePayload();return AC(r,e,t().variables,[...n.values()]),r}},loadFromPayload:(n,r,i,a)=>{let o=pC??a;pC=null;let s=mC;mC=null;let c=o??++dC;if(n.history.length===0){console.warn(`loadFromPayload: rejecting payload with empty history`);return}IC(t().storyData,n),yC(c),aC=s;try{Dy(`beforeload`,r)}finally{aC=null}let l=t().storyData?.ifid;i&&l&&uC(l,i);let u=DC(n),d=zv(n.history.map(e=>e.variables)).map(e=>q(e));OS=zv(d[0]),kS=d.slice(1).map((e,t)=>jS(d[t],e)),LS=n.history.map((e,t)=>FS(e,d[t])),e(e=>{e.currentPassage=n.passage,e.navigationId++,e.variables=q(zv(u?.variables??n.variables)),e.history=n.history.map(e=>({passage:e.passage,timestamp:e.timestamp,prng:e.prng})),e.historyIndex=Math.max(0,Math.min(n.historyIndex,e.history.length-1)),HS(e),e.visitCounts=ws(n.visitCounts),e.renderCounts=ws(n.renderCounts),e.temporary=q(),e.transient=XS(t().transientDefaults)}),n.watchers&&tS(n.watchers,n.interfaceWatchers),uS(),AS=IS(t().historyIndex),NC(u?.prng===void 0?n.prng:u.prng),VS(t,()=>ru(()=>Dy(`afterload`,r)))},getHistoryVariables:e=>zv(IS(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})}}))),JC=`<header class=\"story-menubar\">{story-title}{back}{forward}{restart}{quicksave}{quickload}{saves}{settings}</header>\n{passage}`;function YC(){let{storyData:e}=Vl(`storyData`),t=e?.passages.get(`StoryInterface`),n=t===void 0?JC:t.content,r=t?.tags.includes(`nobr`)??!1,i=Pe(()=>{try{return J(S,{children:Oh(ns(n))})}catch(e){return J(`span`,{class:`error`,children:[`Error in StoryInterface: `,As(e)]})}},[n]);return Ne($x,[]),J(Am.Provider,{value:!0,children:r?J(km.Provider,{value:!0,children:i}):i})}var XC=[`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 ZC(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 QC(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!ZC(e)}function $C(e){return!e.hidden&&!e.closest(`[hidden], [inert]`)&&!e.matches(`:disabled`)&&QC(e)}function ew(e){let t=e.getAttribute(`tabindex`);return t===null||!/^\\s*[+-]?\\d+\\s*$/.test(t)?null:parseInt(t,10)}function tw(e){let t=ew(e);if(t!==null&&t<0||t===null&&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}let n=e;if(e.localName===`input`&&n.type===`radio`&&n.name){let t=Array.from((n.form??e.getRootNode()).querySelectorAll(`input[type=\"radio\"]`)).filter(e=>e.name===n.name&&e.form===n.form&&(ew(e)??0)>=0&&$C(e));return e===(t.find(e=>e.checked)??t[0])}return!0}function nw(e){let t=Array.from(e.querySelectorAll(XC)).filter(e=>$C(e)&&tw(e)),n=e=>Math.max(ew(e)??0,0);return[...t.filter(e=>n(e)>0).sort((e,t)=>n(e)-n(t)),...t.filter(e=>n(e)===0)]}var rw=[],iw=new Set([`date`,`time`,`datetime-local`,`month`,`week`]);function aw(e){if(!e)return!1;if(e.localName===`audio`||e.localName===`video`)return e.controls;let t=e;return e.localName===`input`&&iw.has(t.type)&&!t.readOnly}function ow(e){return e.localName===`iframe`}function sw(e){try{return e.contentDocument}catch{return null}}function cw(e){try{return e.defaultView?.frameElement}catch{return null}}function lw(e,t,n,r){let i=n?e.indexOf(n):-1;if(i!==-1)return e[i+(r?-1:1)];if(n&&n!==t&&t.contains(n)){let t=e=>!!(n.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_FOLLOWING);return r?e.filter(e=>!t(e)).pop():e.find(t)}return r?e[e.length-1]:e[0]}function uw(e,t,n,r){Ne(()=>{let n=e.current;if(!n)return;let r=document.activeElement,i=r instanceof HTMLElement||r instanceof SVGElement?r:null,a={panel:n};rw.push(a);let o=n.querySelector(t)??n;return(Array.from(n.querySelectorAll(`[autofocus]`)).find($C)??nw(o)[0]??n).focus(),()=>{let e=rw.indexOf(a);e!==-1&&rw.splice(e,1);let t=document.activeElement;(!t||t===document.body||n.contains(t))&&i?.isConnected&&i.focus()}},[]),Ne(()=>{let t=e.current;if(!t)return;let i=()=>rw[rw.length-1]?.panel===t,a=(e,t)=>{if(ow(e)){let n=sw(e),r=n?nw(n):[],i=t?r[r.length-1]:r[0];if(i)return a(i,t)}e.focus()},o=(e,n)=>{let r=e?.ownerDocument,i=r&&r!==document?cw(r):null;if(r&&i){let t=lw(nw(r),r,e,n);t?a(t,n):o(i,n);return}let s=nw(t),c=s[0],l=s[s.length-1];if(!c||!l){t.focus();return}let u=lw(s,t,e,n);a(u??(n?l:c),n)},s=null,c=(e,t)=>a=>{if(!i())return;if(a.key===`Escape`){if(!n)return;a.preventDefault(),a.stopPropagation(),r();return}if(a.key!==`Tab`)return;let c=e.activeElement;if(t){s=null;let t=nw(e),n=a.shiftKey?t[0]:t[t.length-1];if(n&&c!==n&&c!==e.body)return}aw(c)?s={el:c,from:t??c,backwards:a.shiftKey}:(a.preventDefault(),o(t??c,a.shiftKey))},l=()=>{s=null},u=e=>{let n=e.target;if(s&&n!==s.el&&i()){let{from:e,backwards:t}=s;s=null,o(e,t)}else i()&&n instanceof Node&&!t.contains(n)&&n!==document.body&&n!==document.documentElement&&o(null,!1)},d=e=>{let t=s;t&&e.target===t.el&&!e.relatedTarget&&i()&&(s=null,o(t.from,t.backwards))},f=new AbortController,{signal:p}=f,m=(e,t)=>{e.addEventListener(`keydown`,c(e,t),{signal:p}),e.addEventListener(`pointerdown`,l,{capture:!0,signal:p}),e.addEventListener(`focusout`,d,{signal:p})},h=new Map,g=[],_=e=>{let t=sw(e);t&&h.get(e)!==t&&(h.set(e,t),m(t,e),v(t))},v=e=>{let t=()=>e.querySelectorAll(`iframe`).forEach(_);e.addEventListener(`load`,e=>{e.target instanceof Node&&ow(e.target)&&_(e.target)},{capture:!0,signal:p});let n=new MutationObserver(t);n.observe(e,{childList:!0,subtree:!0}),g.push(n),t()};return v(t),m(document,null),document.addEventListener(`focusin`,u,{signal:p}),()=>{f.abort(),g.forEach(e=>e.disconnect())}},[n,r])}var dw=me(null);function fw({passageName:e,fallbackMarkup:t,panelClass:n,onClose:r,label:i,dismissible:a=!0,showCloseButton:o=a}){let s=j(r);s.current=r;let c=Fe(()=>s.current(),[]),{storyData:l}=Vl(`storyData`),u=e?l?.passages.get(e):void 0,d=u?.content??t,f=u?.tags.includes(`nobr`)??!1,p=Pe(()=>{if(!d)return J(`div`,{class:`error`,children:`Dialog: no content available`});try{let e=Ih(ns(d),f?{nobr:!0}:void 0);return f?J(km.Provider,{value:!0,children:e}):e}catch(e){return J(`div`,{class:`error`,children:[`Error in dialog: `,As(e)]})}},[d,f]),m=j(null),h=Ie(),g=Im();uw(m,`.dialog-body`,a,c),Ne(()=>CS(c),[c]),Ne(()=>{let e=m.current;if(!e||i)return;let t=e.querySelector(`.dialog-body :is(h1, h2, h3, h4, h5, h6)`);if(t)return t.id||(t.id=`${h}-heading`),e.setAttribute(`aria-labelledby`,t.id),()=>e.removeAttribute(`aria-labelledby`)},[i,d]),Ne(()=>{m.current&&Oy(`dialogrender`,e??``,m.current)},[]);let _=e=>{a&&e.target===e.currentTarget&&c()},v=n?`dialog-panel ${n}`:`dialog-panel`;return J(dw.Provider,{value:c,children:J(`div`,{class:`dialog-overlay`,onClick:_,children:J(`div`,{ref:m,class:v,role:`dialog`,\"aria-modal\":`true`,\"aria-label\":i??e,tabIndex:-1,children:[o&&J(`button`,{type:`button`,class:`dialog-close`,\"aria-label\":`Close`,onClick:c,children:`✕`}),J(`div`,{class:`dialog-body`,children:J(Pm.Provider,{value:g,children:p})})]})})})}function pw(){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(()=>xS({close:i,closeAll:a,push:r,isOpen:()=>n.current.length>0}),[i,a,r]),Me(()=>gS(()=>{let e=[];for(;vS()>0;){let t=_S();t&&e.push(t)}e.length>0&&t(t=>[...t,...e])}),[]),e.length===0?null:J(S,{children:e.map((e,t)=>J(fw,{passageName:e.passageName,panelClass:e.panelClass,onClose:i,showCloseButton:e.showCloseButton,dismissible:e.dismissible},`${e.passageName}-${t}`))})}function mw(){let[e,t]=Ae(zs);return Me(()=>(t(zs()),Bs(()=>t(zs()))),[]),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:()=>Rs(e.id),children:`✕`})]},e.id))})}async function hw(){try{await Q.getState().save()}catch(e){Is(`The game could not be saved:`,e)}}async function gw(){try{await Q.getState().load()}catch(e){Is(`The saved game could not be loaded:`,e)}}function _w(){let{storyData:e,currentPassage:t,nobr:n}=Vl(`storyData`,`currentPassage`,`nobr`);if(Me(()=>{let e=e=>{let{quickSaveKey:t,quickLoadKey:n}=Q.getState();t!==null&&e.key===t?(e.preventDefault(),hw()):n!==null&&e.key===n&&(e.preventDefault(),gw())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[]),!e||!t)return J(`div`,{class:`loading`,children:`Loading...`});let r=J(S,{children:[J(YC,{}),J(pw,{}),J(mw,{})]});return J(km.Provider,{value:n,children:r})}var vw=`http://www.w3.org/1999/xhtml`,yw=new Set([`area`,`base`,`basefont`,`bgsound`,`br`,`col`,`embed`,`frame`,`hr`,`img`,`input`,`keygen`,`link`,`meta`,`param`,`source`,`track`,`wbr`]);function bw(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+=xw(n));return t}function xw(e){let t=e.localName,n=`<${t}`;for(let t of Array.from(e.attributes))n+=` ${t.name}=${Sw(t.name,t.value)}`;if(n+=`>`,e.namespaceURI===vw&&yw.has(t))return n;let r=t===`template`?e.content:e;return`${n}${bw(r)}</${t}>`}function Sw(e,t){let n=Xo(e),r=n?`on`:`a`;return[`\"${t}\"`,`'${t}'`].find(e=>{let t;try{t=is(`<i ${r}=${e}>`)}catch(e){if(e instanceof $o)return!1;throw e}let n=t[0];return t.length===1&&n?.type===`html`&&n.attributes[r]===e.slice(1,-1)})??`\"${Cw(t,n)}\"`}function Cw(e,t){let n=e=>e.replace(/\"/g,`&quot;`);if(t)return Zo(e).map(e=>`text`in e?n(e.text):`expr`in e?`{${e.expr}}`:e.verbatim).join(``);let r;try{r=is(e,{text:!0})}catch(t){if(t instanceof $o)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 ww(){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=bw(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 Tw=new Map,Ew=q(),Dw=!1,Ow=null,kw=new Set;function Aw(e){return kw.add(e),()=>kw.delete(e)}function jw(){return`spindle.${Q.getState().storyData?.ifid||`unknown`}.settings`}function Mw(){try{localStorage.setItem(jw(),JSON.stringify(Ew))}catch{}}function Nw(){if(!Dw){if(!Q.getState().storyData?.ifid)Ow||(Ow=Q.subscribe(e=>{e.storyData?.ifid&&(Ow?.(),Ow=null,Nw())}));else{Dw=!0;try{let e=localStorage.getItem(jw());if(e){let t=JSON.parse(e);typeof t==`object`&&t&&!Array.isArray(t)&&(Ew=q(Ew,t))}}catch{}}}}function Pw(e,t){Tw.set(e,t),K(Ew,e)||(Ew[e]=t.config.default),Nw()}function Fw(e,t){let n=ms(Ew,e);return typeof n==typeof t?n:t}var Iw={addToggle(e,t){Pw(e,{type:`toggle`,config:t})},addList(e,t){Pw(e,{type:`list`,config:t})},addRange(e,t){Pw(e,{type:`range`,config:t})},get(e){return ms(Ew,e)},getToggle(e){return Fw(e,!1)},getList(e){return Fw(e,``)},getRange(e){return Fw(e,0)},set(e,t){Ew[e]=t,Mw();for(let e of[...kw])e()},getAll(){return{...Ew}},getDefinitions(){return Tw},hasAny(){return Tw.size>0}},Lw=0,Rw=4096,zw=[];function Bw(e){zw.push({version:++Lw,path:e}),zw.length>Rw&&zw.shift()}function Vw(e){Bw([`variables`,...e])}var Hw=me(!1),Uw=[`variables`,`temporary`,`transient`];function Ww(e){let t=fx();try{e()}finally{let e=fx();for(let n of Uw)if(t[n]!==e[n])for(let{path:r}of ny(t[n],e[n],!0))Bw([n,...r])}}function Gw(){return Lw}function Kw(e,t){let n=new Set,r=new Map;for(let i=zw.length-1;i>=0&&zw[i].version>e;i--){let{path:e}=zw[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?Ov(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 qw=[`target`,`variable`,`options`,`value`,`disabled`],Jw=new Map,Yw=new Map,Xw=new Set;function Zw(e,t,n){if(n)return Xw.add(n),n;let r=`${e}:${t}`,i=Yw.get(r)??0,a;do i++,a=i===1?r:`${r}:${i}`;while(Jw.has(a)||Xw.has(a));return Yw.set(r,i),Xw.add(a),a}function Qw(e){let t=e.id,n={action:e},r=Jw.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)):Jw.set(t,[n]),oT(),{update(e){let r=Jw.get(t);r?.includes(n)&&(n.action=e,r[r.length-1]===n&&oT())},unregister(){let e=Jw.get(t),r=e?e.indexOf(n):-1;e&&r!==-1&&(e.splice(r,1),e.length===0&&(Jw.delete(t),Xw.delete(t)),r===e.length&&oT())}}}var $w=new Set;function eT(e,t){let n=e.perform(t);if(!n||typeof n.then!=`function`)return n;let r=()=>void $w.delete(n);return $w.add(n),n.then(r,r),n.then(e=>e)}async function tT(){for(;$w.size>0;)await Promise.allSettled($w)}function nT(){return Array.from(Jw.values(),iT)}function rT(e){let t=Jw.get(e);return t&&iT(t)}function iT(e){return e[e.length-1].action}function aT(){Yw.clear();for(let e of Xw)Jw.has(e)||Xw.delete(e)}function oT(){Dy(`actionsChanged`)}function sT(e){let t=j(``),n=j(e.perform);n.current=e.perform,t.current||(t.current=Zw(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 qw)e[n]!==void 0&&Object.assign(t,{[n]:e[n]});return t},a=j(null);Ne(()=>{let e=Qw(i());return a.current=e,()=>e.unregister()},[r]);let o=j(!1);return Ne(()=>{o.current?a.current?.update(i()):o.current=!0},[e.type,e.label,e.target,e.variable,e.disabled,e.value,JSON.stringify(e.options)]),r}function cT(e){return e.map(e=>e.type===`text`?e.value:``).join(``)}function lT(e,t){let n=`macro-${e}`;return t?`${n} ${t}`:n}var uT={useState:Ae,useRef:j,useEffect:Me,useLayoutEffect:Ne,useCallback:Fe,useMemo:Pe,useContext:M};function $(e,t=`builtin`){let n=e.parameters??[];hl(e.name,n);function r(t){let r=t.className,i=t.id,a;e.interpolate&&(a=Ju(),r=a(r),i=a(i));let{update:o,getValues:s}=M(Om),c=M(Hw),l=$u(),u=(e,t)=>Ih(e,{...l,...t}),d;try{d=Sc(t.rawArgs,n)}catch(t){if(t instanceof sc)return b(Cm,{macro:e.name,error:t});throw t}let f={args:d,collectText:cT,sourceLocation:Sm,parseVarArgs:Ec,extractOptions:Ac,h:b,renderNodes:u,renderInlineNodes:Oh,hooks:uT,useAction:sT,className:r,id:i,resolve:a,cls:lT(e.name,r),mutate:c?e=>Ww(()=>zx(e,s(),o)):e=>zx(e,s(),o),update:o,getValues:s,wrap:e=>Mu(r,i,e)};if(e.merged){f.merged=Wl();let e=f.merged;f.evaluate=t=>ku(t,e[0],e[1],e[2],e[3])}if(e.storeVar){let n=Tc(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: ${us} is reserved`);f.varName=i,f.value=Q(e=>Ov(e.variables,a)),f.getValue=()=>Ov(fx().variables,a),f.setValue=e=>{Vw(a),Lx((t,n)=>{Mv(t.variables,a,n(e),{createMissing:!0})})}}try{return e.render(t,f)}catch(t){if(t instanceof sc)return b(Cm,{macro:e.name,error:t});throw t}}al(e.name,r);let i=e.text;cl(e.name,i&&((e,t)=>i(e,{...t,args:Sc(e.rawArgs,n)})));let a=e.block===!0||e.block!==!1&&(e.subMacros?.length??0)>0;if(vl(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)dl(t);a&&pr(e.name)}var dT=null;function fT(e){dT=e}function pT(){return dT}var mT=null,hT=null;function gT(){return hT}var _T=!1;function vT(){if(_T)return;_T=!0;let e=Q.getState().variables,t=Q.getState().transient;Q.subscribe(n=>{let r={},i=(e,t,n)=>{for(let i of xs(e,t))r[n+i]={from:ms(e,i),to:ms(t,i)}};i(e,n.variables,``),i(t,n.transient,`%`),e=n.variables,t=n.transient,Object.keys(r).length>0&&Dy(`variableChanged`,r)})}var yT=null,bT=null,xT=new Set;function ST(e,t=[]){yT=new Set(e),bT=new Set(t),xT.clear()}function CT(e){let t=e.startsWith(`%`),n=t||e.startsWith(`$`)?e.slice(1):e;return fs(n.split(`.`)[0],e),{isTransient:t,key:n}}function wT(e,t){let n=e?bT:yT;if(!n)return;let r=t.split(`.`)[0];if(n.has(r))return;let i=(e?`%`:`$`)+r;xT.has(i)||(xT.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 TT(e,t,n){let{isTransient:r,key:i}=CT(t),a=r?e.transient:e.variables;i.includes(`.`)?Mv(a,i.split(`.`),n):a[i]=n}function ET(e){return((...t)=>Q.getState()[e](...t))}function DT(){return{get(e){let{isTransient:t,key:n}=CT(e),r=dx(),i=r??Q.getState(),a=t?i.transient:i.variables,o=n.includes(`.`)?Ov(a,n.split(`.`)):ms(a,n);return r?gx(o):yx(o)},set(e,t){let n=typeof e==`string`?[[e,t]]:Object.entries(e);for(let[e]of n){let{isTransient:t,key:n}=CT(e);wT(t,n),t||kC(n.split(`.`))}n.some(([e])=>e.includes(`.`))?Lx((e,t)=>{for(let[r,i]of n)TT(e,r,t(i))}):Q.getState().updateVariables(e=>{for(let[t,r]of n)TT(e,t,r)})},goto:ET(`navigate`),back:ET(`goBack`),forward:ET(`goForward`),restart:ET(`restart`),save:ET(`save`),load:ET(`load`),hasSave:ET(`hasSave`),getSaveInfo:ET(`getSaveInfo`),listSaves:ET(`listSaves`),deleteSave:ET(`deleteSave`),exportSave:ET(`exportSave`),importSave:ET(`importSave`),...wu(()=>Q.getState().visitCounts,()=>Q.getState().renderCounts),get title(){return Q.getState().storyData?.name||``},get passage(){return Q.getState().currentPassage},settings:Iw,registerClass(e,t){Jg(e,t)},defineMacro(e){$(e,`user`)},getMacroRegistry(){return bl()},saves:{setTitleGenerator(e){jy(e)}},storage:{async getInfo(){let e=Q.getState().storyData?.ifid;return e?ex(e):{saveCount:0,playthroughCount:0,totalBytes:0,backend:Dv()}},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:ET(`clearGameData`),clearAllData:ET(`clearAllData`),deletePlaythrough:ET(`deletePlaythrough`),get backend(){return Dv()}},getActions(){return nT()},performAction(e,t){let n=rT(e);if(!n)throw Error(`spindle: Action \"${e}\" not found.`);if(n.disabled)throw Error(`spindle: Action \"${e}\" is disabled.`);return eT(n,t)},on(e,t){e===`variableChanged`&&vT();let n=Ty(e,t);return CC(n),n},async waitForActions(){await tT(),await new Promise(e=>{requestAnimationFrame(()=>requestAnimationFrame(()=>e()))});let e=()=>pT()===Q.getState().navigationId;return pT()!==null&&!e()&&!Q.getState().renderDeferred&&await new Promise(t=>{let n=Ty(`passagerender`,()=>{e()&&(n(),t())})}),nT()},watch(e,t){return qx(e,t)},unwatch(e){nS(e)},openDialog(e,t){yS({passageName:e,panelClass:t?.panelClass,showCloseButton:t?.showCloseButton,dismissible:t?.dismissible})},closeDialog(){wS()},closeAllDialogs(){TS()},isDialogOpen(){return ES()},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(),hT??(hT=new Promise(e=>{mT=e}))},ready(){mT&&(Q.getState().clearDeferredRender(),mT(),mT=null,hT=null)},random(){return au()},randomInt(e,t){return ou(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){$l(e,t);let{historyIndex:n}=Q.getState();Q.setState(e=>{let t=e.history[n];t&&(t.prng=iu())})},isEnabled(){return su()},get seed(){return cu()},get pull(){return lu()}}}}function OT(){window.Story=DT()}var kT=new Set([`StoryVariables`,`StoryTransients`,`SaveTitle`]),AT=[`script`,`stylesheet`],jT=new Set([`elseif`,`else`,`case`,`default`,`next`]);function MT(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 NT(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 PT(e,t){let n=e.toLowerCase(),r,i=Math.max(2,Math.floor(n.length/3))+1;for(let e of t){let t=NT(n,e.toLowerCase());t<i&&(r=e,i=t)}return r}var FT=(e,t)=>e?` Did you mean ${t(e)}?`:``,IT=` (a passage name is a quoted string or an expression)`,LT=/^[A-Za-z][\\w$]*$/;function RT(e){try{return Ol(e).name.toLowerCase()||void 0}catch{return}}function zT(e,t){let n=[],r=t.isBlockMacro?{isBlock:t.isBlockMacro}:void 0,i=(e,t,r,i,a,o)=>{let{line:s,column:c}=vr(e.content,t),l={passage:e.name,line:s,column:c,message:a,code:i,start:t,end:r};o&&(l.data=o);let u=e.metadata?.[`data-source-file`];if(u){l.file=u;let t=Number(e.metadata?.[`data-source-line`]);t&&(l.fileLine=t+s)}n.push(l)},a=(e,t,n)=>i(e,t.offset,t.end,t.code,n+t.reason,t.data),o=[],s=new Set,c=new Set,l=e=>{for(let t of e){if(t.type!==`macro`||t.isClose||t.name.toLowerCase()!==`widget`)continue;let e=RT(t.rawArgs);e&&s.add(e)}};for(let n of e){if(c.add(n.name),kT.has(n.name)||n.tags?.some(e=>AT.includes(e)))continue;let e=!t.only||t.only(n);if(t.tolerant){let{tokens:t,errors:i}=ts(n.content,{hooks:r});if(l(t),!e)continue;for(let e of i)a(n,e,``);o.push([n,t])}else try{let t=is(n.content);if(l(t),!e)continue;ns(n.content,{hooks:r}),o.push([n,t])}catch(t){if(!(t instanceof $o))throw t;e&&a(n,t,``)}}let u=[...t.macroNames??[],...s],d=(e,n,r)=>{for(let a of n){if(a.type!==`macro`||a.isClose)continue;let n=a.name.toLowerCase();if(jT.has(n)||s.has(n)||t.isKnownMacro(n))continue;let o=PT(a.name,u);i(e,a.start,a.end,`unknown-macro`,`${r}Unknown macro {${a.name}}.${FT(o,e=>`{${e}}`)}`,{name:a.name,suggestions:o?[o]:[]})}},f=t.parametersOf??(()=>void 0),p=(e,n)=>{d(e,n,``);let r=0;for(let o of Gc(e.content,n,f,{isBlock:t.isBlockMacro})){if(o.nested&&o.offset<r)continue;let n=o.offset,s=o.where&&o.nested?o.where:``;switch(o.kind){case`argument-error`:i(e,n,n+o.length,`argument-error`,`${s}${o.message} in ${o.label}`,{macro:o.macro});break;case`passage`:if(t.checkPassageNames!==!1&&!c.has(o.name)){let t=PT(o.name,c);i(e,n,n+o.length,`unknown-passage`,`${s}No passage named ${JSON.stringify(o.name)} in ${o.label}.${FT(t,JSON.stringify)}`,{name:o.name,macro:o.macro,suggestions:t?[t]:[]})}break;case`code`:m(e,o,s);break;case`text`:o.errors.length>0?(a(e,o.errors[0],o.where),r=Pc(o,o.text.length)):d(e,o.tokens,o.where)}}},m=(e,t,n)=>{let r=t.offset,a=Nc(t.code,t.goal),o=t.code.trim();if(a instanceof mo){let o=/^(?:[\\w$]+|\\S)/.exec(t.code.slice(a.pos));i(e,Pc(t,a.pos),Pc(t,a.pos+(o?.[0].length??0)),`code-syntax`,`${n}${a.reasonIn(e.content,r)} in ${t.label}`+(t.passage?IT:``),t.macro?{macro:t.macro}:void 0)}else if(t.passage&&LT.test(o)){let r=t.code.length-t.code.trimStart().length;i(e,Pc(t,r),Pc(t,r+o.length),`unquoted-passage-name`,`${n}Unquoted passage name in ${t.label}: write ${JSON.stringify(o)}${IT}`,{name:o,macro:t.macro??``})}};for(let[e,t]of o)Mc(()=>p(e,t));return n}var BT=/(?:0[xX][\\da-fA-F_]+|0[bB][01_]+|0[oO][0-7_]+|(?:\\d[\\d_]*\\.?[\\d_]*|\\.\\d[\\d_]*)(?:[eE][+-]?\\d[\\d_]*)?)(n?)/y,VT=/[A-Za-z_$][\\w$]*/y,HT=/[\\w$]+/y,UT=/(?:async\\s+)?(?:\\((?:[^()]|\\([^()]*\\))*\\)|[A-Za-z_$][\\w$]*)\\s*=>/y,WT=/[\\n\\r\\u2028\\u2029]/g,GT=/^(?:0|[1-9]\\d{0,8})$/,KT={unsupported:`undefined`,value:`undefined`};function qT(e){let t=new ZT(e),n=t.value();return t.space(),t.i===e.length?n:void 0}function JT(e){let t=[...e];return[...t.filter(e=>GT.test(e)).sort((e,t)=>Number(e)-Number(t)),...t.filter(e=>!GT.test(e))]}function YT(e,t=`expression`,n={}){let r=new Map;return Io(e,{...n,literal(e,t,i){e.charAt(0)===`/`&&!/^\\/[/*]/.test(e)&&r.set(t,t+e.length),n.literal?.(e,t,i)}},t),r}function XT(e){try{return BigInt(e.replace(/_/g,``)).toString()}catch{return}}var ZT=class{constructor(e,t={}){this.src=e,this.i=0,this.goal=t.goal??`expression`,this.regexes=t.regexes}space(){let{src:e}=this;for(;;){for(;/\\s/.test(e.charAt(this.i));)this.i++;if(e.startsWith(`//`,this.i))WT.lastIndex=this.i,this.i=WT.test(e)?WT.lastIndex-1:e.length;else if(e.startsWith(`/*`,this.i)){let t=e.indexOf(`*/`,this.i+2);this.i=t<0?e.length:t+2}else return}}value(){let{src:e}=this;this.space();let t=e.charAt(this.i);if(t===`\"`||t===`'`)return this.string().closed?{shape:{type:`string`}}:void 0;if(t===\"`\")return this.template();if(t===`[`)return this.skipBalanced()?{shape:{type:`array`}}:void 0;if(t===`{`)return this.object();if(/[\\d.+-]/.test(t))return this.number();if(/[A-Za-z_$(]/.test(t))return this.word()}string(){let{end:e,closed:t}=Ho(this.src,this.i),n=this.src.slice(this.i+1,t?e-1:e);return this.i=e,{body:n,closed:t}}stringValue(){let e=this.i,{closed:t}=this.string();return t?Vo(this.src.slice(e,this.i))??void 0:void 0}template(){let{src:e}=this;for(let t=this.i+1;t<e.length;t++){let n=e.charAt(t);if(n===`\\\\`)t++;else if(n===\"`\")return this.i=t+1,{shape:{type:`string`}};else if(n===`$`&&e.charAt(t+1)===`{`)return}}number(){let{src:e}=this,t=this.i,n=e.charAt(t);if(n===`+`||n===`-`)for(t++;/\\s/.test(e.charAt(t));)t++;let r=this.numberAt(t);if(r){if(this.i=t+r[0].length,!r[1])return{shape:{type:`number`}};if(n===`+`)return{throws:`Cannot convert a BigInt value to a number`};let e=XT(r[0].slice(0,-1));return e===void 0?void 0:{unsupported:`bigint`,value:n===`-`&&e!==`0`?`-${e}`:e}}VT.lastIndex=t;let i=VT.exec(e)?.[0];if(i===`Infinity`||i===`NaN`)return this.i=VT.lastIndex,{shape:{type:`number`}}}numberAt(e){return BT.lastIndex=e,BT.exec(this.src)}word(){let{src:e}=this,t=this.i,n=this.arrow();if(n!==void 0)return n?this.functionFrom(t):void 0;VT.lastIndex=this.i;let r=VT.exec(e)?.[0];if(r===void 0)return;let i=VT.lastIndex;switch(r){case`true`:case`false`:return this.i=i,{shape:{type:`boolean`}};case`null`:return this.i=i,{shape:{type:`null`}};case`NaN`:case`Infinity`:return this.i=i,{shape:{type:`number`}};case`undefined`:return this.i=i,KT;case`void`:{this.i=i;let e=this.value();return e&&!(`throws`in e)?KT:e}case`function`:case`class`:case`async`:return this.skipDeclaration(r)?this.functionFrom(t):void 0}}functionFrom(e){return{unsupported:`function`,value:this.src.slice(e,this.i).trimEnd()}}arrow(){let{src:e}=this;if(UT.lastIndex=this.i,UT.test(e)){if(this.i=UT.lastIndex,this.space(),e.charAt(this.i)===`{`)return this.skipBalanced();for(;this.i<e.length&&!`,}`.includes(e.charAt(this.i))&&this.skipOne(););return!0}}skipDeclaration(e){let{src:t}=this;if(this.i+=e.length,this.space(),e===`async`)return VT.lastIndex=this.i,VT.exec(t)?.[0]===`function`&&this.skipDeclaration(`function`);if(e===`function`){if(t.charAt(this.i)===`*`&&this.i++,this.space(),VT.lastIndex=this.i,VT.test(t)&&(this.i=VT.lastIndex),this.space(),t.charAt(this.i)!==`(`||!this.skipBalanced())return!1;this.space()}else for(;this.i<t.length&&t.charAt(this.i)!==`{`;)if(!this.skipOne())return!1;return t.charAt(this.i)===`{`&&this.skipBalanced()}object(){let{src:e}=this,t=new Map,n;for(this.i++;;){this.space();let r=e.charAt(this.i);if(r===`}`)return this.i++,n===void 0?this.objectOf(t):{throws:n};if(r===`,`){this.i++;continue}if(this.i>=e.length)return;let i=this.i,a=this.key();if(a===`__proto__`)return;this.space();let o=e.charAt(this.i);if(a!==void 0&&o===`:`){this.i++;let e=this.i,r=this.value();if(this.space(),r&&this.atMemberEnd()){`throws`in r?n??(n=r.throws):t.set(a,`shape`in r?r.shape:r);continue}t.set(a,null),this.i=e}else if(a!==void 0&&o===`(`){if(!this.skipBalanced())return;if(this.space(),e.charAt(this.i)===`{`&&this.skipBalanced()){t.set(a,{unsupported:`function`,value:e.slice(i,this.i)});continue}return}else if(a!==void 0&&(o===`,`||o===`}`)){t.set(a,null);continue}else t.clear();if(!this.skipMember())return}}atMemberEnd(){return this.i<this.src.length&&`,}`.includes(this.src.charAt(this.i))}objectOf(e){let t=new Map;for(let n of JT(e.keys())){let r=e.get(n);if(r){if(`unsupported`in r)return r;t.set(n,r)}}return{shape:{type:`object`,fields:t}}}key(){let{src:e}=this,t=e.charAt(this.i);if(t===`\"`||t===`'`)return this.stringValue();if(/[\\d.]/.test(t))return this.numberKey();HT.lastIndex=this.i;let n=HT.exec(e)?.[0];if(n!==void 0)return this.i=HT.lastIndex,n}numberKey(){let e=this.numberAt(this.i);if(!e||(this.i+=e[0].length,/[\\w$]/.test(this.src.charAt(this.i))))return;let t=e[0].replace(/_/g,``);if(/^0\\d/.test(t))return;if(e[1])return XT(t.slice(0,-1));let n=Number(t);return Number.isNaN(n)?void 0:String(n)}skipMember(){let{src:e}=this;for(;this.i<e.length;){let t=e.charAt(this.i);if(t===`,`||t===`}`)return!0;if(!this.skipOne())return!1}return!1}skipBalanced(){let{src:e}=this,t={\"[\":`]`,\"{\":`}`,\"(\":`)`}[e.charAt(this.i)];if(!t)return!1;for(this.i++;this.i<e.length;){if(e.charAt(this.i)===t)return this.i++,!0;if(!this.skipOne())return!1}return!1}skipOne(){let{src:e}=this,t=e.charAt(this.i);if(t===`\"`||t===`'`)return this.string().closed;if(t===\"`\")return this.skipTemplate();if(e.startsWith(`//`,this.i)||e.startsWith(`/*`,this.i))return this.space(),!0;if(t===`/`){this.regexes??(this.regexes=YT(e,this.goal));let t=this.regexes.get(this.i);if(t!==void 0)return this.i=t,!0}return t===`[`||t===`{`||t===`(`?this.skipBalanced():t===`]`||t===`}`||t===`)`?!1:(this.i++,!0)}skipTemplate(){let{src:e}=this;for(this.i++;this.i<e.length;){let t=e.charAt(this.i);if(t===`\\\\`)this.i+=2;else if(t===\"`\")return this.i++,!0;else if(t===`$`&&e.charAt(this.i+1)===`{`){if(this.i++,!this.skipBalanced())return!1}else this.i++}return!1}};function QT(e,t,{tolerant:n}={}){if(n)return as(e,{text:t}).tokens;try{return is(e,{text:t})}catch(e){if(e instanceof $o)return[];throw e}}function $T(e){let t=e.replace(/[.*+?^${}()|[\\]\\\\]/g,`\\\\$&`);return RegExp(`^${t}(\\\\w+)\\\\s*=\\\\s*(.+)$`)}var eE=/([$%])(\\w+(?:\\.\\w+)*)/y,tE=/^[\"']\\$(\\w+(?:\\.\\w+)*)[\"']?$/,nE=new Set([`number`,`string`,`boolean`]),rE={string:Object(``),number:Object(0),boolean:Object(!1)};function iE(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,iE(i,t));return i}let n=typeof e;if(!nE.has(n))throw Error(`Unsupported type \"${n}\" for value ${String(e)}. Expected number, string, boolean, array, or object.`);return{type:n}}var aE=`Expected number, string, boolean, array, or object.`;function oE(e){if(!e.fields)return{type:e.type};let t=new Map;for(let[n,r]of e.fields)t.set(n,oE(r));return{type:e.type,fields:t}}function sE(e){try{$a(`return (`+e+`)`,{ecmaVersion:`latest`,allowReturnOutsideFunction:!0})}catch(e){if(!(e instanceof SyntaxError))throw e;let{pos:t}=e;return{message:e.message.replace(/ \\(\\d+:\\d+\\)$/,``),pos:Math.max(0,t-8)}}}function cE(e,t=`$`){let n=[],r=[],i=$T(t),a=new Set,o=0;for(let s of e.split(`\n`)){let e=o+s.length-s.trimStart().length;o+=s.length+1;let c=s.trim();if(!c)continue;let l=c.match(i),u=(e,t,n,i)=>r.push({code:e,offset:t,end:n,message:i});if(!l){u(`invalid-declaration`,e,e+c.length,`Invalid declaration: \"${c}\". Expected: ${t}name = value`);continue}let[,d,f]=l,p=e+t.length,m=p+d.length,h=ds(d,t+d);if(h){u(`invalid-name`,p,m,h);continue}let g=e+c.length,_={name:d,nameStart:p,nameEnd:m,valueStart:g-f.length,valueEnd:g};a.has(d)&&u(`duplicate-declaration`,p,m,`Duplicate declaration of ${t}${d}`),a.add(d),n.push(_);let v=`Failed to evaluate \"${t}${d} = ${f}\"`,y=sE(f);if(y){let e=Math.min(y.pos,f.length-1);u(`syntax`,_.valueStart+e,_.valueStart+e+1,`${v}: ${y.message}`);continue}let b=qT(f);b&&(`shape`in b?_.schema=oE(b.shape):`throws`in b?u(`unsupported-value`,_.valueStart,g,`${v}: ${b.throws}`):u(`unsupported-value`,_.valueStart,g,`Unsupported type \"${b.unsupported}\" for value ${b.value}. ${aE}`))}return{declarations:n,errors:r}}function lE(e,t=`$`){let n=new Map,r=t===`%`?`StoryTransients`:`StoryVariables`,{declarations:i,errors:a}=cE(e,t),o=[...a.filter(e=>e.code===`invalid-declaration`||e.code===`invalid-name`).map(e=>({at:e.offset,error:e})),...i.map(e=>({at:e.nameStart,declaration:e}))].sort((e,t)=>e.at-t.at);for(let i of o){if(`error`in i)throw Error(`${r}: ${i.error.message}`);let{name:a,valueStart:o,valueEnd:s}=i.declaration,c=e.slice(o,s),l;try{l=Function(`return (`+c+`)`)()}catch(e){throw Error(`${r}: Failed to evaluate \"${t}${a} = ${c}\": ${As(e)}`)}let u;try{u=iE(l)}catch(e){throw Error(`${r}: ${As(e)}`)}n.set(a,{...u,name:a,default:l})}return n}function uE(e,t){let n=t=>e.sigil+[e.name,...t].join(`.`),r=ds(e.name,e.sigil+e.name);if(r)return{code:`reserved-name`,message:r};let i=e.sigil===`$`?t.variables:t.transients;if(!i)return null;if(!i.has(e.name))return e.sigil===`$`?{code:`undeclared-variable`,message:`Undeclared variable: ${n(e.path)}`}:{code:`undeclared-transient`,message:`Undeclared transient: ${n(e.path)}`};let a=i.get(e.name);for(let t=0;a&&t<e.path.length;t++){let r=e.path[t];if(a.type===`array`||a.type===`null`)return null;if(a.type===`string`&&ps(r))continue;let i=rE[a.type];if(i&&r in i){let e=typeof i[r];if(!nE.has(e))return null;a={type:e}}else{if(a.type!==`object`||!a.fields)return{code:`primitive-field`,message:`Cannot access field \"${r}\" on ${n(e.path.slice(0,t))} (type: ${a.type})`};a=a.fields.get(r)}}return null}var dE=[`checkbox`,`cycle`,`listbox`,`numberbox`,`radiobutton`,`textarea`,`textbox`],fE=new Set,pE=/(?:\\.\\w+)*/y;function mE(e,t,n,r,i,a){pE.lastIndex=i;let o=pE.exec(e)[0];return{sigil:t,name:n,path:o?o.slice(1).split(`.`):[],start:a(r),end:a(i+o.length)}}function hE(e,t,n){eE.lastIndex=t;let r=eE.exec(e);if(!r)return;let[i,...a]=r[2].split(`.`);return{sigil:r[1],name:i,path:a,start:n(t),end:n(t+r[0].length)}}function gE(e,t,n){for(let{expr:r,at:i}of nl(e))vE(r,e=>t(i+e),n)}function _E(e,t,n,r){e.includes(`{`)&&wE(e,QT(e,!0,r),t,n,r)}function vE(e,t,n,r=`expression`){let i=Nc(e,r);if(i instanceof mo)yE(e,t,n,r);else for(let r of i.refs)(r.sigil===`$`||r.sigil===`%`)&&n(mE(e,r.sigil,r.name,r.start,r.end,t))}function yE(e,t,n,r){Io(e,{variable(r,i,a,o,s){(r===`$`||r===`%`)&&n(mE(e,r,i,a,s,t))},literal(){}},r)}function bE(e,t,n,r){for(let i of e){let e=e=>t(Pc(i,e));i.kind===`code`?vE(i.code,e,n,i.goal):i.kind===`text`&&_E(i.text,e,n,{...r,storeVarMacros:fE})}}function xE(e,t,n,r,i){if(!e.rawArgs)return;let a=t(e.name),o=!1;if(a){i.all&&!i.storeVarMacros.has(e.name.toLowerCase())&&SE(e,a,n,r);let t=[...Zc(e.rawArgs,e.argsStart,a,e.name,``)];o=!t.some(e=>e.kind===`argument-error`),o&&bE(t,n,r,i)}o||vE(e.rawArgs,t=>n(e.argsStart+t),r);let s=t.widget?.(e.name);s&&bE(Qc(e.rawArgs,e.argsStart,s,e.name,``),n,r,i)}function SE(e,t,n,r){let i=new Map;try{Sc(e.rawArgs,t,i)}catch(e){if(e instanceof sc)return;throw e}for(let a of t){let t=i.get(a);if(a.type!==`variable`||!t)continue;let o=hE(e.rawArgs.slice(t[0],t[1]),0,r=>n(e.argsStart+t[0]+r));o&&r(o)}}function CE(e,t,n,r,i){if(!(`selectorsStart`in t)||t.selectorsStart===void 0||t.selectorsEnd===void 0)return;let a=t.selectorsStart;_E(e.slice(a,t.selectorsEnd),e=>n(a+e),r,{...i,storeVarMacros:fE})}function wE(e,t,n,r,i){let{storeVarMacros:a,parametersOf:o}=i;for(let s=0;s<t.length;s++){let c=t[s];if(i.all&&c.type!==`macro`&&c.type!==`html`&&c.type!==`text`&&CE(e,c,n,r,i),c.type===`variable`){if((c.scope===`variable`||c.scope===`transient`)&&c.name){let[e,...t]=c.name.split(`.`);r({sigil:c.scope===`variable`?`$`:`%`,name:e,path:t,start:n(c.nameStart-1),end:n(c.nameEnd)})}}else if(c.type===`link`)_E(c.display,e=>n(c.displayStart+e),r,{...i,storeVarMacros:fE});else if(c.type===`expression`)vE(c.expression,e=>n(c.expressionStart+e),r);else if(c.type===`html`)for(let{name:t,value:a,at:o}of tl(e,c)){let e=e=>n(o+e);Xo(t)?gE(a,e,r):_E(a,e,r,i)}else if(c.type===`macro`&&!c.isClose){if(xE(c,o,n,r,i),CE(e,c,n,r,i),a.has(c.name.toLowerCase())){let e=c.rawArgs.length-c.rawArgs.trimStart().length,t=c.rawArgs.trim().split(/\\s+/)[0]??``,i=tE.exec(t);if(i){let[t,...a]=i[1].split(`.`),o=c.argsStart+e+1;r({sigil:`$`,name:t,path:a,start:n(o),end:n(o+1+i[1].length)})}else/^[\"'`]/.test(t)||vE(t,t=>n(c.argsStart+e+t),r)}if(c.name.toLowerCase()===`do`){let i=s+1;for(;i<t.length;){let e=t[i];if(e.type===`macro`&&e.isClose&&e.name.toLowerCase()===`do`)break;i++}i<t.length&&(vE(e.slice(c.end,t[i].start),e=>n(c.end+e),r,`statements`),s=i)}}}}function TE(e,t){let n=[];return Mc(()=>wE(e,QT(e,!1,t),e=>e,e=>n.push(e),t)),n.sort((e,t)=>e.start-t.start)}function EE(e,t,n){let r=[];for(let i of e)if(!kT.has(i.name))for(let e of TE(i.content,n)){let n=uE(e,t);n&&r.push({passage:i.name,code:n.code,name:e.name,...e.path.length>0?{path:e.path}:{},start:e.start,end:e.end,message:n.message})}return r}function DE(e,t,n=dE,r=yl){return EE(e.values(),{variables:t},{storeVarMacros:new Set(Array.from(n,e=>e.toLowerCase())),parametersOf:r}).map(e=>`Passage \"${e.passage}\": ${e.message}`)}function OE(e){let t=q();for(let[n,r]of e)t[n]=r.default;return t}var kE=new WeakMap;function AE(e){let t=kE.get(e);if(t&&t.content===e.content)return t.ast;let n=ns(e.content);return kE.set(e,{content:e.content,ast:n}),n}function jE(e){return Ih(AE(e),e.tags.includes(`nobr`)?{nobr:!0}:void 0)}function ME(e){if(!e)return null;try{return jE(e)}catch(t){return console.error(`spindle: Error in ${e.name}:`,t),null}}var NE=new Set([`PassageReady`,`PassageHeader`,`PassageFooter`,`PassageDone`]);function PE({passage:e,dataTransition:t,navigationId:n}){let{storyData:r}=Vl(`storyData`),i=NE.has(e.name),[a,o]=Ae(!1),s=Pe(()=>{try{return jE(e)}catch(t){return J(`div`,{class:`error`,children:[`Error parsing passage “`,e.name,`”`,xm(e),`: `,As(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(()=>ME(l),[l?.content]),p=Pe(()=>ME(u),[u?.content]);Me(()=>(d&&o(!0),()=>o(!1)),[e.name]);let m=Pe(()=>a?ME(d):null,[a,d?.content]),h=j(null);Ne(()=>{n!==void 0&&fT(n),h.current&&Oy(`passagerender`,e.name,h.current)},[e.name,n]);let g=e.tags.includes(`nobr`),_=Im(),v=J(Pm.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(km.Provider,{value:!0,children:v}):v}var FE=new Set([`none`,`fade`,`fade-through`,`crossfade`]),IE={type:`fade-through`,duration:300,pause:50};function LE(e){let t=e.find(e=>e.startsWith(`transition:`));if(!t)return null;let n=t.slice(11);if(!FE.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 RE(e){return{type:e.type,duration:e.duration??IE.duration,pause:e.pause??IE.pause}}function zE(e,t,n){let r=LE(e);return r?RE(r):t?RE(t):n?RE(n):{...IE}}function BE(e,t){let n=(n,r)=>{let i=e.querySelectorAll(n),a=t.querySelectorAll(n);i.forEach((e,t)=>a[t]&&r(e,a[t]))};n(`canvas`,(e,t)=>{if(e.width&&e.height)try{t.width!==e.width&&(t.width=e.width),t.height!==e.height&&(t.height=e.height),t.getContext(`2d`)?.drawImage(e,0,0)}catch{}}),n(`input, textarea, select`,(e,t)=>{e instanceof HTMLInputElement&&t instanceof HTMLInputElement&&(t.checked=e.checked),e instanceof HTMLInputElement&&e.type===`file`||(t.value=e.value)})}function VE(e,t){let n=e.cloneNode(!0);BE(e,n),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 HE(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 UE(e,t){if(!e)return null;HE(e,t);let n=e.querySelector(`.passage`);return n?VE(n,t.type):null}function WE(e){if(!e)return;e.classList.remove(`passage-container--crossfading`);let t=e.querySelectorAll(`.passage-snapshot`);for(let e=0;e<t.length;e++)t[e].remove()}var GE=new Map,KE=new Set;function qE(){let e=()=>{let{navigationId:e,renderDeferred:t}=Q.getState();return!t&&[...GE.values()].every(t=>t===e)};return e()?Promise.resolve():new Promise(t=>{let n=()=>{e()&&(KE.delete(n),t())};KE.add(n)})}function JE(e){let t=e?.querySelector(`.passage`);t&&t.getBoundingClientRect().top<0&&t.scrollIntoView?.({block:`start`})}function YE(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}=Vl(`currentPassage`,`navigationId`,`storyData`,`renderDeferred`),[o,s]=Ae({passage:n,id:r}),c=o.passage,l=e=>s({passage:e,id:r}),u=j(`fade`),d=j(0),f=o.id,p=Fe(e=>e.navigationId!==f,[f]),m=Fe(()=>p(Q.getState()),[p]),h=j(null),g=j(null),_=j([]),v=j(!1),y=Fe(()=>{for(let e of _.current)clearTimeout(e);_.current=[],v.current=!1,WE(g.current)},[]);Me(()=>y,[y]),Me(()=>{let e=Q.getState(),{history:t,historyIndex:a,transitionConfig:s}=e,f=d.current;d.current=t.length;let p=!c,m=t.length===1&&a===0&&f>1,h=t.length>1&&a===t.length-1&&f>1&&Math.abs(t.length-f)>1;if(r===o.id)return;let b=e.consumeNextTransition();y();let x=i?.passages.get(n);if(!x){u.current=`none`,l(n);return}if(p||m||h){u.current=`fade`,l(n);return}let S=YE(zE(x.tags,b,s));u.current=S.type;let C=g.current;if(S.type===`none`){l(n);return}if(S.type===`fade`){C&&HE(C,S),l(n);return}let w=S.type===`fade-through`||S.type===`crossfade`?UE(C,S):null;if(!C||!w){l(n);return}if(S.type===`fade-through`){C.appendChild(w),l(``);let e=S.duration+S.pause,t=setTimeout(()=>{l(n)},e),r=e+S.duration,i=setTimeout(()=>{WE(C),v.current&&JE(C),v.current=!1},r);_.current=[t,i];return}C.classList.add(`passage-container--crossfading`),C.appendChild(w),l(n);let T=setTimeout(()=>{WE(C)},S.duration);_.current=[T]},[r]);let b=c&&!a?o.id:null,x=j(b);Ne(()=>{if(b===null)return;let e=x.current;if(x.current=b,e===null||e===b)return;let t=g.current;v.current=!!t?.querySelector(`.passage-snapshot`)&&!t.classList.contains(`passage-container--crossfading`),v.current||JE(t)},[b]);let S=j(Symbol(`passage-display`)).current;Ne(()=>{GE.set(S,b),[...KE].forEach(e=>e())},[b]),Ne(()=>()=>{GE.delete(S),[...KE].forEach(e=>e())},[]);let C=a?i?.passages.get(`StoryLoading`)??null:c?i?.passages.get(c):null;if(!C&&c&&!a)return J(`div`,{class:`error`,children:[`Error: Passage “`,c,`” not found.`]});let w=i?.passages.get(`PassageReady`),T=!a&&o.id!==r&&h.current?h.current:C&&J(PE,{passage:C,dataTransition:a?`none`:u.current,navigationId:a?void 0:o.id},a?`loading`:`nav-${o.id}`);return h.current=T||null,J(`div`,{id:t.id??`story`,class:t.className??`story`,children:[!a&&w&&J(`div`,{hidden:!0,children:jE(w)},`ready-${r}`),J(`div`,{class:`passage-container`,ref:g,children:T&&J(zl.Provider,{value:p,children:J(Bl.Provider,{value:m,children:T})})})]})}}),$({name:`set`,parameters:[{name:`code`,type:`statements`,required:!0}],render({rawArgs:e},t){return Tm(`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(ju(t.evaluate(e)))}catch(e){return J(Cm,{macro:`print`,error:e})}},text({rawArgs:e},t){return ju(t.evaluate(e))}});var XE=Symbol(`unset`);function ZE(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 fs(n.slice(1),n),{target:n,expr:r}}function QE(e,t,n,r,i,a,o,s,c){let l=Sm(),u,d=o.current,f=!1,{navigationId:p}=Q.getState();try{let{variables:a,temporary:o,transient:c}=fx();r||(d=ms(n?o:a,t),f=p!==s.current),u=ku(e,a,o,i(),c)}catch(e){wm(`computed ${a}`,e,l);return}if(s.current=p,!Uv(o.current,u)||f&&!Uv(d,u)){if(o.current=u,r)try{c(t,u)}catch(e){wm(`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}=ZE(e,t.args))}catch(e){return J(Cm,{macro:`computed`,error:e})}let i=n.startsWith(`@`),a=n.startsWith(`_`),o=n.slice(1),s=i?t.update:null,c=t.hooks.useRef(XE),l=t.hooks.useRef(-1),u=()=>QE(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 $E(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 eD(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}=$E({...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=eD(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(Cm,{macro:`meter`,error:e})}}});function tD(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 nD(e,t){return Mu(t.resolve(e.className),t.resolve(e.id),t.renderNodes(e.children))}function rD(e,t){let n=e.findIndex(e=>e.rawArgs===``);return tD(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=rD(e,t.evaluate)}catch(e){return J(Cm,{macro:`if`,error:e})}return n?nD(n,t):null},text({branches:e=[]},t){let n=rD(e,t.evaluate);return n?t.renderText(n.children):``}});function iD(e){try{return oD(e,new Map)}catch{return`<unkeyable>`}}var aD=`<hole>`;function oD(e,t){switch(typeof e){case`string`:return JSON.stringify(e);case`number`:return Object.is(e,-0)?`-0`: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=Yg(n),a=e=>i===void 0?e:`Class(${JSON.stringify(i)})${e}`,o=e=>{let r=i===void 0?[]:Ig(n);return a(r.length?`${e}${cD(n,r,t)}`:e)};if(e instanceof Date||e instanceof RegExp)return i!==void 0&&Ig(n).length&&t.set(n,t.size),o(e instanceof Date?`Date(${Date.prototype.getTime.call(e)})`:`RegExp(${zg(e)}@${e.lastIndex})`);if(t.set(n,t.size),Array.isArray(e)){let n=[];for(let r=0;r<e.length;r++)n.push(r in e?oD(e[r],t):aD);return o(`[${n.join(`,`)}]`)}let s=sD(n,t);return s===void 0?e instanceof Map?o(`Map[${Array.from(Bg(e),([e,n])=>`[${oD(e,t)},${oD(n,t)}]`).join(`,`)}]`):e instanceof Set?o(`Set[${Array.from(Vg(e),e=>oD(e,t)).join(`,`)}]`):a(cD(n,Object.keys(n),t)):a(s)}function sD(e,t){if(e instanceof ArrayBuffer)return`ArrayBuffer[${new Uint8Array(e).join(`,`)}]`;if(ArrayBuffer.isView(e))return`${kg(e)}(${e.byteOffset},${e.byteLength},${oD(e.buffer,t)})`;let n;if(e instanceof URL)n=`URL(${JSON.stringify(Object.getOwnPropertyDescriptor(URL.prototype,`href`).get.call(e))})`;else if(e instanceof URLSearchParams)n=`URLSearchParams(${JSON.stringify(URLSearchParams.prototype.toString.call(e))})`;else if(jg(e))n=`${kg(e)}(${oD(e.valueOf(),t)})`;else if(Ag(e))n=`${kg(e)}(${JSON.stringify(String(e))})`;else if(e instanceof Error){let r=e,i=Pg.filter(t=>K(e,t)).map(e=>`${e}:${oD(r[e],t)}`),a=Object.getPrototypeOf(e)?.constructor,o=typeof a==`function`?a.name:``;n=`Error(${JSON.stringify(o)},${i.join(`,`)})`}else return;let r=Object.keys(e);return r.length?`${n}${cD(e,r,t)}`:n}function cD(e,t,n){let r=e;return`{${t.map(e=>`${JSON.stringify(e)}:${oD(r[e],n)}`).join(`,`)}}`}function lD(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 fs(n.slice(1),n),r&&fs(r.slice(1),r),{itemVar:n.slice(1),indexVar:r?r.slice(1):null,listExpr:i}}function uD({itemVar:e,itemValue:t,indexVar:n,indexValue:r,children:i}){return J(ed,{body:i,ownKeys:Pe(()=>({[e]:t,...n?{[n]:r}:void 0}),[e,t,n,r])})}$({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=n.hooks.useRef({contents:[],generations:[],next:0,edits:Gw()}).current,i,a;try{i=lD(e,n.args);let t=n.evaluate(i.listExpr);if(!Array.isArray(t))return J(`span`,{class:`error`,children:`{for error: expression did not evaluate to an array}`});a=t}catch(e){return J(Cm,{macro:`for`,error:e})}let{itemVar:o,indexVar:s}=i,c=Kw(r.edits,fx());r.edits=Gw();let l=a.map((e,t)=>{let n=iD(e);return(r.generations[t]===void 0||n!==r.contents[t]&&!c(a,e,t))&&(r.generations[t]=r.next++),r.contents[t]=n,r.generations[t]});r.contents.length=r.generations.length=a.length;let u=a.map((e,n)=>J(uD,{itemVar:o,itemValue:e,indexVar:s,indexValue:n,children:t},`${n}-${l[n]}`));return n.wrap(J(Hw.Provider,{value:!0,children:u}))},text({rawArgs:e,children:t=[]},n){let{itemVar:r,indexVar:i,listExpr:a}=lD(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 Tm(`do`,``,()=>t.mutate(n))}});var dD=me({stop:()=>{}});$({name:`repeat`,block:!0,interpolate:!0,parameters:[xc],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(Bl),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(dD.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 fD=()=>!0,pD=new cr([`set`,`unset`,`if`,`for`,`switch`,`do`,`print`,`goto`,`nobr`,`span`]);function mD(e){return e.every(e=>{switch(e.type){case`macro`:return pD.has(e.name)&&mD(e.children)&&(e.branches??[]).every(e=>mD(e.children));case`html`:return mD(e.children);default:return!0}})}function hD({onSettled:e}){return Me(()=>{let t=setTimeout(e,0);return()=>clearTimeout(t)},[]),null}function gD(){let e=M(Om),{nobr:t,inline:n,structural:r}=$u(),i=M(Vm),a=M(dD),o=M(dw),s=M(Hw),c=M(Bl),l=j([]);Me(()=>{let e=bC(()=>{let e=l.current.splice(0);queueMicrotask(()=>{for(let t of e)pe(null,t)})});return()=>{e();for(let e of l.current.splice(0))pe(null,e)}},[]);let u=u=>{let d=Hl(e.getValues),f=document.createElement(`div`),p=mD(u)?()=>{let e=l.current.indexOf(f);e!==-1&&(l.current.splice(e,1),pe(null,f))}:null;pe(J(zl.Provider,{value:fD,children:J(Om.Provider,{value:e,children:J(Dm.Provider,{value:d,children:J(km.Provider,{value:t,children:J(jm.Provider,{value:n,children:J(Mm.Provider,{value:r,children:J(Vm.Provider,{value:i,children:J(dD.Provider,{value:a,children:J(dw.Provider,{value:o,children:J(Hw.Provider,{value:s,children:J(Bl.Provider,{value:c,children:[Ih(u,{nobr:t,inline:n,structural:r,locals:d}),p&&J(hD,{onSettled:p})]})})})})})})})})})})}),f),l.current.push(f)};return e=>Ix(()=>u(e))}$({name:`button`,block:!0,interpolate:!0,parameters:[{name:`label`,type:`text`,holds:`markup`,required:!0}],render({rawArgs:e,children:t=[]},n){let r=n.resolve?.(n.args.label??``)??e,i=gD(),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=wc(t.args.passage,t.evaluate,Q.getState())}catch(e){i={error:e}}let a=gD(),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(Cm,{macro:`link`,error:i.error}):J(`a`,{id:t.id,class:t.cls,href:`#`,onClick:e=>{e.preventDefault(),o()},children:n})}});function _D(e,t,n){return tD(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(Cm,{macro:`switch`,error:e})}let i;try{i=_D(r,t,n.evaluate)}catch(e){return J(Cm,{macro:`case`,error:e})}return i?nD(i,n):null},text({rawArgs:e,branches:t=[]},n){let r=_D(n.evaluate(e),t,n.evaluate);return r?n.renderText(r.children):``}});var vD=[xc];$({name:`timed`,subMacros:[`next`],interpolate:!0,parameters:vD,render({branches:e=[]},t){let{useState:n,useEffect:r,useMemo:i,useContext:a}=t.hooks,o=a(Bl),s=i(()=>e.map(e=>({delay:Sc(e.rawArgs,vD).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(Mu(t.resolve(u.className),t.resolve(u.id),t.renderNodes(u.nodes)))}}),$({name:`stop`,render(e,t){let{stop:n}=t.hooks.useContext(dD);return t.hooks.useLayoutEffect(()=>{n()},[n]),null}});function yD(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:[xc],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(()=>{if(s.current){let e=s.current.textContent||``;f(e.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(yD(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.renderNodes(e,{inline:!0})}),!_&&p>0&&J(`span`,{class:`macro-type-cursor`})]})}}),$({name:`widget`,block:!0,parameters:Tl,render({children:e=[]},t){let n,r;try{let e=El(t.args);for(let t of e.params)fs(t.slice(1),t);Dl(e),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&&Ml(n,e)},[i,o,s]),r?J(Cm,{macro:`widget`,error:r}):null}}),$({name:`story-title`,interpolate:!0,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 bD(e,t){return t?`${e} (${t})`:e}function xD(e){$({name:e.name,interpolate:!0,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(fw,{passageName:e.dialog.passageName,fallbackMarkup:e.dialog.fallbackMarkup,panelClass:e.dialog.panelClass,label:typeof e.label==`string`?e.label:e.name,onClose:()=>i(!1),showCloseButton:e.dialog.showCloseButton})]})}})}xD({name:`back`,label:`← Back`,actionType:`back`,setup:()=>({perform:Q(e=>e.goBack),disabled:!Q(e=>e.historyIndex>0)})}),xD({name:`forward`,label:`Forward →`,actionType:`forward`,setup:()=>({perform:Q(e=>e.goForward),disabled:!Q(e=>e.historyIndex<e.history.length-1)})}),xD({name:`quicksave`,label:`QuickSave`,actionType:`save`,setup:()=>{let{quickSaveKey:e}=Vl(`quickSaveKey`);return{perform:hw,title:bD(`Quick Save`,e)}}}),xD({name:`quickload`,label:`QuickLoad`,actionType:`load`,confirm:`Load saved game? Current progress will be lost.`,setup:()=>{let{hasSave:e,quickLoadKey:t}=Vl(`hasSave`,`quickLoadKey`,`knownSaves`);return{perform:gw,disabled:!e(),title:bD(`Quick Load`,t)}}}),xD({name:`restart`,label:`↺ Restart`,actionType:`restart`,confirm:`Restart the story? All progress will be lost.`,setup:()=>({perform:Q(e=>e.restart)})}),xD({name:`saves`,label:`Saves`,actionType:`dialog`,dialog:{passageName:`SaveLoad`,fallbackMarkup:`{save-manager}`,panelClass:`dialog-saves`}}),xD({name:`settings`,label:`Settings`,actionType:`dialog`,hidden:()=>!Iw.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(fw,{passageName:o,onClose:()=>r(!1),showCloseButton:!i})]})}});function SD(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 CD(e){return new Date(e).toLocaleDateString(void 0,{month:`short`,day:`numeric`,year:`numeric`})}function wD({className:e,id:t}){let[n,r]=Ae(`load`),[i,a]=Ae([]),[o,s]=Ae(!0),[c,l]=Ae(null),[u,d]=Ae(()=>new Set),[f,p]=Ae(null),m=j(!1),[h,g]=Ae(``),_=j(null),v=j(null),y=M(dw),{storyData:b,playthroughId:x,beginSave:S,loadFromPayload:C}=Vl(`storyData`,`playthroughId`,`beginSave`,`loadFromPayload`),w=b?.ifid??``,[T,E]=Ae(!1),D=Fe(async()=>{if(!w)return;let e=await cb(w);E(Dv()===`memory`),a(e),s(!1)},[w]);Me(()=>{D()},[D]),Me(()=>w?kb(w,D,!0):void 0,[w,D]),Me(()=>{f&&_.current&&(_.current.focus(),_.current.select())},[f]);let ee=j(!0),O=j(void 0),te=j(void 0),k=(e,t=`success`)=>{ee.current&&(clearTimeout(O.current),l({text:e,type:t}),O.current=window.setTimeout(()=>l(null),3e3))};Me(()=>(ee.current=!0,()=>{ee.current=!1,clearTimeout(O.current),clearTimeout(te.current)}),[]);let ne=e=>{d(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},re=async()=>{if(!w)return;let e=iC();try{await Zy(void 0,void 0,S,async t=>$y(w,e,t)),k(T?`Save created (temporary)`:`Save created`),await D()}catch{k(`Failed to create save`,`error`)}},ie=async e=>{let t=iC();try{await Zy(void 0,void 0,S,async n=>{if(!await tb(e,n,void 0,t))throw Error(`Save not found`)}),k(`Save overwritten`),await D()}catch{k(`Failed to overwrite save`,`error`)}},ae=async e=>{let t=hC();try{let n=await ab(e.meta.id)??e;if(gC(t))return;C(ib(n.payload),void 0,n.meta.playthroughId,t),k(`Game loaded`),y&&(te.current=window.setTimeout(y,500)),await D()}catch{k(`Failed to load save`,`error`)}},oe=async(e,t,n)=>{try{await n(),k(e),await D()}catch{k(t,`error`)}},se=async e=>{confirm(`Delete this save?`)&&await oe(`Save deleted`,`Failed to delete save`,async()=>{await ob(e);let t=await Fb(w);Q.setState(e=>{e.knownSaves=t})})},ce=e=>{m.current=!1,p(e.meta.id),g(e.meta.title)},le=async()=>{let e=f;e&&h.trim()&&await oe(`Save renamed`,`Failed to rename`,async()=>{await sb(e,h.trim()),p(t=>t===e?null:t)})},ue=e=>{e.key===`Enter`?le():e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),m.current=!0,p(null))},de=()=>{m.current||le()},fe=async e=>{try{let t=await Yb(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),k(`Save exported`)}catch{k(`Failed to export save`,`error`)}},pe=()=>{v.current?.click()},me=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(!ev(t))throw Error(`Invalid save file format`);await Zb(t,w),k(`Save imported`),await D()}catch(e){k(As(e,`Failed to import save`),`error`)}}},he=i.reduce((e,t)=>e+t.saves.length,0);return J(`div`,{id:t,class:e?`save-manager ${e}`:`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:n===`save`?`active`:``,onClick:()=>r(`save`),children:`Save`}),J(`button`,{type:`button`,class:n===`load`?`active`:``,onClick:()=>r(`load`),children:`Load`})]})})}),T&&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:pe,children:`Import`}),J(`input`,{ref:v,type:`file`,accept:`.json`,style:`display:none`,onChange:me})]}),J(`div`,{class:`saves-body`,children:[o?J(`div`,{class:`saves-empty`,children:`Loading...`}):he===0&&n===`load`?J(`div`,{class:`saves-empty`,children:`No saves yet`}):i.map(e=>{let t=u.has(e.playthrough.id),r=e.playthrough.id===x;return n===`save`&&!r||n===`load`&&e.saves.length===0&&!r?null:J(`div`,{class:`playthrough-group`,children:[J(`button`,{type:`button`,class:`playthrough-header`,\"aria-expanded\":!t,onClick:()=>ne(e.playthrough.id),children:[J(`span`,{class:`playthrough-chevron ${t?``:`open`}`,\"aria-hidden\":`true`,children:`▶`}),J(`span`,{class:`playthrough-label`,children:[e.playthrough.label,r?` (current)`:``]}),J(`span`,{class:`playthrough-date`,children:CD(e.playthrough.createdAt)})]}),!t&&J(`div`,{class:`playthrough-saves`,children:[e.saves.map(e=>J(`div`,{class:`save-slot`,children:[J(`div`,{class:`save-slot-info`,children:[f===e.meta.id?J(`input`,{ref:_,class:`save-rename-input`,value:h,onInput:e=>g(e.target.value),onKeyDown:ue,onBlur:de}):J(`div`,{class:`save-slot-title`,children:e.meta.title}),J(`div`,{class:`save-slot-meta`,children:[J(`span`,{children:e.meta.passage}),J(`span`,{children:SD(e.meta.updatedAt)})]})]}),J(`div`,{class:`save-slot-actions`,children:[n===`save`?J(`button`,{type:`button`,class:`save-slot-action primary`,onClick:()=>ie(e.meta.id),children:`Save Here`}):J(`button`,{type:`button`,class:`save-slot-action primary`,onClick:()=>ae(e),children:`Load`}),J(`button`,{type:`button`,class:`save-slot-action`,onClick:()=>ce(e),children:`Rename`}),J(`button`,{type:`button`,class:`save-slot-action`,onClick:()=>fe(e.meta.id),children:`Export`}),J(`button`,{type:`button`,class:`save-slot-action danger`,onClick:()=>se(e.meta.id),children:`Delete`})]})]},e.meta.id)),n===`save`&&r&&J(`button`,{type:`button`,class:`save-slot-new`,onClick:re,children:`+ New Save`})]})]},e.playthrough.id)}),n===`save`&&!o&&!i.some(e=>e.playthrough.id===x)&&J(`div`,{class:`playthrough-group`,children:J(`div`,{class:`playthrough-saves`,children:J(`button`,{type:`button`,class:`save-slot-new`,onClick:re,children:`+ New Save`})})})]}),c&&J(`div`,{class:`saves-status ${c.type===`error`?`error`:``}`,children:c.text})]})}$({name:`save-manager`,interpolate:!0,render(e,t){return J(wD,{className:t.className,id:t.id})}});function TD({name:e,def:t}){let[n,r]=Ae(()=>Iw.get(e));Me(()=>{let t=()=>r(Iw.get(e));return t(),Aw(t)},[e]);let i=t=>Iw.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 ED({className:e,id:t}){let n=Iw.getDefinitions();return J(`div`,{id:t,class:e?`settings-controls ${e}`:`settings-controls`,children:Array.from(n.entries()).map(([e,t])=>J(TD,{name:e,def:t},e))})}$({name:`settings-controls`,interpolate:!0,render(e,t){return J(ED,{className:t.className,id:t.id})}}),$({name:`include`,interpolate:!0,merged:!0,parameters:[{name:`inline`,type:`flag`},{name:`passage`,type:`passage`,required:!0}],render(e,t){let{storyData:n}=Vl(`storyData`),{inline:r}=t.args,i=``,a;try{i=wc(t.args.passage,t.evaluate,Q.getState())}catch(e){a={error:e}}let o=n?.passages.get(i),s=t.hooks.useMemo(()=>o?ns(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(Cm,{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(km.Provider,{value:!0},u)):t.wrap(u)}}),$({name:`nobr`,block:!0,interpolate:!0,render({children:e=[]},t){return t.wrap(t.h(km.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(wc(t.args.passage,t.evaluate,e))}catch(t){wm(`goto`,t,e),r({error:t})}},[]),n?J(Cm,{macro:`goto`,error:n.error}):null}}),$({name:`unset`,parameters:[{name:`variable`,type:`variable`,required:!0}],render({rawArgs:e},t){return Tm(`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 DD={name:`variable`,type:`variable`,required:!0};function OD(e,t){return e.useAction({key:`$${e.varName}`,authorId:e.id,variable:e.varName,value:e.value,...t})}function kD(e,t,n=e=>e===void 0?``:String(e)){$({name:e,interpolate:!0,storeVar:!0,parameters:[DD,{name:`placeholder`,type:`string`,holds:`text`}],render(r,i){let a=i.args.placeholder??``;OD(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:ju(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))}})}})}kD(`textbox`,`text`),kD(`numberbox`,`number`,e=>e===void 0?0:Number(e)),kD(`textarea`),$({name:`checkbox`,interpolate:!0,storeVar:!0,parameters:[DD,{name:`label`,type:`text`,holds:`text`}],render(e,t){let n=t.args.label??``;return OD(t,{type:`checkbox`,label:n||t.varName||``,value:!!t.value,perform:e=>t.setValue(e===void 0?!t.getValue():!!e)}),J(`label`,{id:t.id,class:t.cls,children:[J(`input`,{type:`checkbox`,checked:!!t.value,onChange:e=>t.setValue(e.target.checked)}),n?` ${n}`:null]})}}),$({name:`radiobutton`,interpolate:!0,storeVar:!0,parameters:[DD,{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(Pm);return OD(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`,interpolate:!0,subMacros:[`option`],storeVar:!0,parameters:[DD],render({children:e=[]},t){let n=t.extractOptions(e);return OD(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:ju(t.value),onChange:e=>t.setValue(e.target.value),children:n.map(e=>J(`option`,{value:e,children:e},e))})}}),$({name:`cycle`,block:!0,interpolate:!0,storeVar:!0,parameters:[DD],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 OD(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,interpolate:!0,render({children:e=[]},t){return t.wrap(t.renderNodes(e))},text:({children:e=[]},t)=>t.renderText(e)}),$({name:`watch`,parameters:[{name:`condition`,type:`string`,holds:`expression`,required:!0},{name:`options`,type:`options`,parameters:[{name:`goto`,type:`string`,holds:`passage`},{name:`dialog`,type:`string`,holds:`passage`},{name:`run`,type:`string`,holds:`statements`},{name:`name`,type:`string`,holds:`text`},{name:`priority`,type:`number`},{name:`once`,type:`flag`}]}],render(e,t){let{hooks:n}=t,{condition:r,options:i}=t.args;if(r===void 0)return null;let a=n.useContext(zl),[,o]=n.useState(0);n.useEffect(()=>hS(()=>o(e=>e+1)),[]);let s=n.useContext(Am),c=JSON.stringify([r,i]);n.useLayoutEffect(()=>s?Qx(r,i):void 0,[s,c]);let l=n.useRef(null);return(l.current===null||l.current!==mS()&&!a?.(Q.getState()))&&(l.current=mS(),Jx(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,nS(n)),null}});var AD=`*,:before,:after{box-sizing:border-box}html{-webkit-text-size-adjust:100%;font-size:16px}body{color:#e0e0e0;background-color:#1a1a2e;min-height:100vh;margin:0;padding:0;font-family:Georgia,Times New Roman,serif;line-height:1.75}tw-storydata{display:none!important}#story{max-width:42em;margin:0 auto;padding:2em 1.5em}.passage-container{position:relative}.passage-container--crossfading{display:grid}.passage-container--crossfading>*{grid-area:1/1}.passage{animation:passage-fade-in var(--passage-in-duration,.3s) ease}.passage[data-transition=none]{animation:none}.passage-snapshot{animation:passage-fade-out var(--passage-out-duration,.3s) ease forwards;pointer-events:none;-webkit-user-select:none;user-select:none}@keyframes passage-fade-in{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}@keyframes passage-fade-out{0%{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(-8px)}}@media (prefers-reduced-motion:reduce){.passage,.passage-snapshot{animation-duration:10ms!important}}.macro-button{color:#64b5f6;font:inherit;cursor:pointer;background:#64b5f626;border:1px solid #64b5f666;border-radius:4px;padding:.25em .75em;font-size:.95em;transition:background .2s,border-color .2s}.macro-button:hover{background:#64b5f640;border-color:#90caf9}.macro-button:active{background:#64b5f659}.error{color:#ef5350;background:#ef53501a;border:1px solid #ef5350;border-radius:4px;padding:1em;font-family:monospace}.spindle-error-banners{z-index:300;flex-direction:column;gap:.5em;width:min(42em,100% - 1.5em);display:flex;position:fixed;top:.75em;left:50%;transform:translate(-50%)}.spindle-error-banner{color:#ffcdd2;background:#2b1a1e;border:1px solid #ef5350;border-radius:4px;padding:.75em 2.75em .75em 1em;font-size:.9em;line-height:1.5;position:relative;box-shadow:0 2px 12px #00000080}.spindle-error-banner-message{color:#ef9a9a;font-family:monospace}.spindle-error-banner-dismiss{color:inherit;cursor:pointer;background:0 0;border:none;font-size:1em;position:absolute;top:.5em;right:.5em}.spindle-error-banner-dismiss:hover{color:#fff}.loading{text-align:center;opacity:.6;padding:2em}.story-menubar{z-index:100;background:#16213e;border-bottom:1px solid #ffffff14;align-items:center;gap:.5em;padding:.5em 1.5em;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Noto Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;font-size:.9em;display:flex;position:sticky;top:0}@media (max-width:600px){.story-menubar{flex-wrap:wrap;padding:.5em .75em}.story-menubar .story-title{flex:100%}}.story-title{color:#e0e0e0;white-space:nowrap;text-overflow:ellipsis;flex:1;font-weight:600;overflow:hidden}.menubar-button{color:#9e9e9e;cursor:pointer;font:inherit;background:0 0;border:1px solid #0000;border-radius:4px;padding:.35em .7em;transition:color .2s,background .2s}.menubar-button:hover{color:#e0e0e0;background:#ffffff14}.menubar-button:disabled{opacity:.4;cursor:default}.menubar-button:disabled:hover{color:#9e9e9e;background:0 0}.dialog-overlay{z-index:200;background:#0009;justify-content:center;align-items:center;display:flex;position:fixed;top:0;bottom:0;left:0;right:0}.dialog-panel{color:#e0e0e0;background:#16213e;border:1px solid #ffffff1a;border-radius:8px;flex-direction:column;width:90%;max-width:500px;max-height:80vh;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Noto Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;display:flex;position:relative}.dialog-panel:focus{outline:none}.dialog-saves{max-width:550px}.dialog-settings{max-width:400px}.dialog-settings .dialog-body{padding-top:2.25em}.dialog-close{z-index:1;color:#9e9e9e;cursor:pointer;background:0 0;border:none;padding:.25em;font-size:1.1em;line-height:1;position:absolute;top:.75em;right:.75em}.dialog-close:hover{color:#e0e0e0}.dialog-body{flex:1;min-height:0;overflow-y:auto}.settings-controls{flex-direction:column;gap:1em;padding:1em 1.25em;display:flex}.settings-row{justify-content:space-between;align-items:center;gap:1em;display:flex}.settings-row select,.settings-row input[type=range]{accent-color:#64b5f6}.settings-row select{color:#e0e0e0;font:inherit;background:#1a1a2e;border:1px solid #ffffff26;border-radius:4px;padding:.3em .5em}.settings-row input[type=checkbox]{accent-color:#64b5f6;width:1.1em;height:1.1em}.save-manager{flex-direction:column;flex:1;min-height:0;display:flex}.saves-header{border-bottom:1px solid #ffffff14;flex-shrink:0;justify-content:space-between;align-items:center;padding:1em 3em 1em 1.25em;font-weight:600;display:flex}.saves-header-left{align-items:center;gap:.75em;display:flex}.saves-mode-toggle{border:1px solid #ffffff26;border-radius:4px;gap:0;display:flex;overflow:hidden}.saves-mode-toggle button{color:#9e9e9e;font:inherit;cursor:pointer;background:0 0;border:none;padding:.3em .8em;font-size:.85em;font-weight:600;transition:background .2s,color .2s}.saves-mode-toggle button.active{color:#64b5f6;background:#64b5f633}.saves-mode-toggle button:hover:not(.active){color:#e0e0e0}.saves-body{flex:1;min-height:0;padding:.75em 1.25em;overflow-y:auto}.saves-empty{text-align:center;opacity:.5;padding:2em 1em;font-size:.9em}.saves-toolbar{border-bottom:1px solid #ffffff14;flex-shrink:0;gap:.5em;padding:.5em 1.25em;display:flex}.saves-toolbar-button{color:#9e9e9e;font:inherit;cursor:pointer;background:#ffffff0d;border:1px solid #ffffff1a;border-radius:4px;padding:.3em .7em;font-size:.8em;transition:background .2s,color .2s}.saves-toolbar-button:hover{color:#e0e0e0;background:#ffffff1a}.playthrough-group{margin-bottom:.75em}.playthrough-header{text-align:left;cursor:pointer;-webkit-user-select:none;user-select:none;color:#9e9e9e;background:0 0;border:0;align-items:center;gap:.5em;width:100%;padding:.4em 0;font-family:inherit;font-size:.85em;transition:color .2s;display:flex}.playthrough-header:hover{color:#e0e0e0}.playthrough-chevron{font-size:.7em;transition:transform .2s;display:inline-block}.playthrough-chevron.open{transform:rotate(90deg)}.playthrough-label{font-weight:600}.playthrough-date{opacity:.6;font-size:.9em}.playthrough-saves{flex-direction:column;gap:.4em;padding-left:.25em;display:flex}.save-slot{background:#ffffff08;border:1px solid #ffffff0f;border-radius:6px;align-items:center;gap:.75em;padding:.5em .6em;transition:background .15s;display:flex}.save-slot:hover{background:#ffffff0f}.save-slot-info{flex:1;min-width:0}.save-slot-title{white-space:nowrap;text-overflow:ellipsis;font-size:.9em;font-weight:500;overflow:hidden}.save-slot-meta{color:#9e9e9e;gap:.75em;font-size:.75em;display:flex}.save-slot-actions{flex-shrink:0;gap:.3em;display:flex}.save-slot-action{color:#9e9e9e;font:inherit;cursor:pointer;white-space:nowrap;background:0 0;border:1px solid #0000;border-radius:3px;padding:.2em .5em;font-size:.75em;transition:color .2s,background .2s}.save-slot-action:hover{color:#e0e0e0;background:#ffffff14}.save-slot-action.primary{color:#64b5f6;border-color:#64b5f64d}.save-slot-action.primary:hover{background:#64b5f626}.save-slot-action.danger:hover{color:#ef5350;background:#ef53501a}.save-slot-new{color:#9e9e9e;font:inherit;cursor:pointer;background:0 0;border:1px dashed #ffffff1f;border-radius:6px;justify-content:center;align-items:center;width:100%;margin-top:.25em;padding:.5em;font-size:.8em;transition:color .2s,border-color .2s,background .2s;display:flex}.save-slot-new:hover{color:#64b5f6;background:#64b5f60d;border-color:#64b5f64d}.saves-notice{color:#ffb74d;background:#ffb74d14;border-bottom:1px solid #ffb74d4d;flex-shrink:0;padding:.5em 1.25em;font-size:.8em}.saves-status{color:#81c784;text-align:center;border-top:1px solid #ffffff14;flex-shrink:0;padding:.5em 1.25em;font-size:.8em}.saves-status.error{color:#ef5350;background:0 0;border:none;border-radius:0;padding:.5em 1.25em;font-family:inherit}.save-rename-input{color:#e0e0e0;font:inherit;background:#1a1a2e;border:1px solid #64b5f666;border-radius:3px;width:100%;padding:.15em .4em;font-size:.9em}.save-rename-input:focus{border-color:#64b5f6;outline:none}.macro-link{color:#64b5f6;cursor:pointer;border-bottom:1px solid #64b5f64d;text-decoration:none;transition:color .2s,border-color .2s}.macro-link:hover{color:#90caf9;border-bottom-color:#90caf9}.macro-link:active{color:#42a5f5}.macro-textbox,.macro-numberbox,.macro-textarea{color:#e0e0e0;font:inherit;background:#1a1a2e;border:1px solid #ffffff26;border-radius:4px;padding:.3em .5em}.macro-textbox:focus,.macro-numberbox:focus,.macro-textarea:focus{border-color:#64b5f6;outline:none}.macro-textarea{resize:vertical;min-height:3em}.macro-checkbox,.macro-radiobutton{cursor:pointer;align-items:center;gap:.3em;display:inline-flex}.macro-checkbox input,.macro-radiobutton input{accent-color:#64b5f6}.macro-listbox{color:#e0e0e0;font:inherit;background:#1a1a2e;border:1px solid #ffffff26;border-radius:4px;padding:.3em .5em}.macro-cycle{color:#64b5f6;font:inherit;cursor:pointer;background:#64b5f626;border:1px solid #64b5f666;border-radius:4px;padding:.25em .75em;transition:background .2s,border-color .2s}.macro-cycle:hover{background:#64b5f640;border-color:#90caf9}.macro-meter{background:#2a2a3e;border:1px solid #444;border-radius:.3em;width:100%;height:1.4em;position:relative;overflow:hidden}.macro-meter-fill{background:#64b5f6;height:100%;transition:width .3s}.macro-meter-label{color:#e0e0e0;text-shadow:0 1px 2px #000c;pointer-events:none;justify-content:center;align-items:center;font-size:.85em;display:flex;position:absolute;top:0;bottom:0;left:0;right:0}.md{display:contents}.passage p{margin:.6em 0}.passage p:first-child{margin-top:0}.passage p:last-child{margin-bottom:0}.passage h1,.passage h2,.passage h3,.passage h4,.passage h5,.passage h6{color:#f0f0f0;margin:1em 0 .4em;line-height:1.3}.passage h1{font-size:1.8em}.passage h2{font-size:1.5em}.passage h3{font-size:1.25em}.passage h4{font-size:1.1em}.passage h5{font-size:1em}.passage h6{opacity:.8;font-size:.9em}.passage code{background:#ffffff14;border-radius:3px;padding:.15em .35em;font-family:Fira Code,Cascadia Code,Consolas,monospace;font-size:.9em}.passage pre{background:#0000004d;border:1px solid #ffffff14;border-radius:6px;margin:.8em 0;padding:1em;overflow-x:auto}.passage pre code{background:0 0;border-radius:0;padding:0;font-size:.85em}.passage blockquote{color:#b0b0b0;border-left:3px solid #64b5f680;margin:.8em 0;padding:.4em 1em}.passage blockquote p{margin:.3em 0}.passage ul,.passage ol{margin:.6em 0;padding-left:1.8em}.passage li{margin:.2em 0}.passage hr{border:none;border-top:1px solid #ffffff1f;margin:1.2em 0}.passage table{border-collapse:collapse;width:100%;margin:.8em 0}.passage th,.passage td{text-align:left;border:1px solid #ffffff1f;padding:.5em .75em}.passage th{background:#ffffff0f;font-weight:600}.passage tr:nth-child(2n){background:#ffffff05}.passage del{opacity:.5}.passage strong{color:#f0f0f0}.macro-type-cursor:after{content:\"█\";color:#64b5f6;animation:.7s step-end infinite type-blink}.macro-type-done .macro-type-cursor:after{display:none}@keyframes type-blink{50%{opacity:0}}`;function jD(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 MD(e){let t=document.getElementById(`root`);throw t&&jD(t,e),Error(`spindle: ${e.length} validation error(s):\\n${e.join(`\n`)}`)}function ND(e,t=``){try{return e()}catch(e){return MD([t+As(e)])}}function PD(){return Bc([...bl(),...Os()])}function FD(e,t){let n=bl().filter(e=>e.storeVar).map(e=>e.name);return DE(e.passages,t,n,PD())}function ID(e,t){return zT(e.passages.values(),{isKnownMacro:e=>!!ol(e)||fl(e)||!!Ds(e),macroNames:bl().map(e=>e.name),parametersOf:PD(),only:t}).map(MT)}function LD(){let e=ww(),t=document.createElement(`style`);if(t.id=`spindle-styles`,t.textContent=AD,document.head.appendChild(t),OT(),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&&jD(t,[e]),Error(`spindle: ${e}`)}let i=ND(()=>lE(r.content));for(let t of ND(()=>jl(e.passages.values())))pr(t);let a=FD(e,i);a.push(...ID(e,e=>e.name===`StoryInit`));let o={},s=e.passages.get(`StoryTransients`);if(s){let e=ND(()=>lE(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=OE(e)}a.length>0&&MD(a),n=OE(i),ST(Object.keys(n),Object.keys(o)),Q.getState().init(e,n,o),wC();for(let[,t]of e.passages)t.tags.includes(`widget`)&&ND(()=>Nl(ns(t.content),t.name),`Passage \"${t.name}\": `);cx(Ub(e.ifid));let c=[...FD(e,i),...ID(e,e=>e.name!==`StoryInit`)];c.length>0&&MD(c);let l=Q.getState().navigationId;Q.subscribe(e=>{e.navigationId!==l&&(l=e.navigationId,aT())}),lS();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.`);pe(J(_w,{}),d),(gT()??Promise.resolve()).then(qE).then(()=>{document.dispatchEvent(new CustomEvent(`:storyready`))})}document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,LD):LD();</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.32","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),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`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=/^m(i|n|o|s|text|space)$/,g=Array.isArray,_=m.slice,v=Object.assign;function y(e){e&&e.parentNode&&e.remove()}function b(e,t,n){var r,i,a,o={},s=arguments.length;for(a in t)a==`key`?r=t[a]:a==`ref`&&typeof e!=`function`?i=t[a]:o[a]=t[a];return s>2&&(o.children=s>3?_.call(arguments,2):n),x(e,o,r,i,null)}function x(e,t,i,a,o){var s={type:e,props:t,key:i,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:o||++r,__i:-1,__u:0};return!o&&n.vnode&&n.vnode(s),s}function S(e){return e.children}function C(e,t){this.props=e,this.context=t,this.__g=0}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])&&n.__e)return n.__e;return typeof e.type!=`function`||e.props.__P?null:w(e)}function T(e){if((e=e.__)&&e.__c&&!e.props.__P)return e.__e=null,e.__k.some(function(t){return t&&(e.__e=t.__e)}),T(e)}function ee(e){(8&e.__g||!(e.__g|=8)||!i.push(e)||o++)&&a==n.debounceRendering||((a=n.debounceRendering)||queueMicrotask)(E)}function E(){var e,t,r,a,c,l,u,d,f;try{for(t=1;i.length;)i.length>t&&i.sort(s),e=i.shift(),t=i.length,8&e.__g&&(a=void 0,c=void 0,l=(c=(r=e).__v).__e,u=[],d=[],(f=r.__P)&&((a=v({constructor:void 0},c)).__v=c.__v+1,n.vnode&&n.vnode(a),se(f,a,c,r.__n,f.namespaceURI,32&c.__u?[l]:null,u,l||w(c),32&c.__u,d),a.__v=c.__v,a.__.__k[a.__i]=a,le(u,a,d),c.__=c.__e=null,a.__e!=l&&T(a)))}finally{i.length=o=0}}function te(e,t,n,r,i,a,o,s,c,l,u){var d,f,h,g,_,v,y=r.__k||m,b=t.length;for(c=D(n,t,y,c,b),d=0;d<b;d++)(h=n.__k[d])!=null&&(f=~h.__i&&y[h.__i]||p,h.__i=d,v=se(e,h,f,i,a,o,s,c,l,u),g=h.__e,(f.ref!=h.ref||8&f.__u)&&(f.ref&&de(f.ref,null,h,f),h.ref&&u.push(h.ref,h.__c||g,h)),_=_||g,4&h.__u?(c=ne(h,c,e,!f.__v),f.__e&&(f.__e=null)):typeof h.type==`function`&&v!==void 0?c=v:g&&(c=g.nextSibling),h.__u&=-7);return n.__e=_,c}function D(e,t,n,r,i){var a,o,s,c,l,u,d,f,p,m,h=n.length,_=h,v=0,y=!1,b=e.__k=Array(i);for(a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(typeof o!=`object`||o.constructor==String?o=b[a]=x(null,o):g(o)?o=b[a]=x(S,{children:o}):o.constructor===void 0&&o.__b?o=b[a]=x(o.type,o.props,o.key,o.ref,o.__v):b[a]=o,c=a+v,o.__=e,o.__b=e.__b+1,s=null,~(l=o.__i=re(o,n,c,_))&&(_--,(s=n[l])&&(s.__u|=2)),s&&s.__v?(o.__u|=2,l==c-1?v--:l==c+1?v++:l!=c&&(l>c?v--:v++,y=!0)):(~l||(i>h?v--:i<h&&v++),typeof o.type!=`function`&&(o.__u|=4))):b[a]=null;if(y){for(u=[],d=[],a=0;a<i;a++)if((o=b[a])&&2&o.__u){for(f=0,p=u.length;f<p;)u[m=f+p>>1]<o.__i?f=m+1:p=m;u[f]=o.__i,d[a]=f+1}for(v=u.length;a--;)d[a]&&(d[a]==v?v--:b[a].__u|=4)}if(_)for(a=0;a<h;a++)!(s=n[a])||2&s.__u||(s.__e==r&&(r=w(s)),fe(s,s));return r}function ne(e,t,n,r){var i,a,o;if(typeof e.type==`function`){if(e.props.__P)return t;if(i=e.__k)for(a=0;a<i.length;a++)i[a]&&(i[a].__=e,t=ne(i[a],t,n,!1));return t}for(t&&!t.parentNode&&(t=w(e))&&!t.parentNode&&(t=null),o=t;o&&o.nodeType==8;)o=o.nextSibling;for(e.__e!=o&&(!r&&n.moveBefore&&e.__e.parentNode?n.moveBefore(e.__e,t):n.insertBefore(e.__e,t||null)),t=e.__e;(t=t&&t.nextSibling)&&t.nodeType==8;);return t}function O(e,t){return t=t||[],e!=null&&typeof e!=`boolean`&&(g(e)?e.some(function(e){O(e,t)}):t.push(e)),t}function re(e,t,n,r){var i,a,o,s=e.key,c=e.type,l=t[n],u=l&&!(2&l.__u);if(l===null&&s==null||u&&s==l.key&&c==l.type)return n;if(r>+!!u){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function ie(e,t,n){n??(n=``),t[0]==`-`?e.setProperty(t,n):e[t]=n}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`)(e.__e||(e.__e={}))[t]=n,n&&r||(o=d[t]||(d[t]=oe(t)),(e.__a||(e.__a={}))[t]=u,a=t!=(t=t.replace(l,`$1`)),(t=t.slice(2))[0]<`a`&&(t=t.toLowerCase()),n?e.addEventListener(t,o,a):e.removeEventListener(t,o,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.__e){var r=this.__e[e];if(t[c]==null)t[c]=u++;else if(t[c]<this.__a[e])return;return r(n.event?n.event(t):t)}}}function se(e,t,r,i,a,o,s,c,l,u){var d,f,p,h,_,b,x,T,ee,E,D,ne,O,re,ie,ae,oe,se,le,de,me=t.type;if(t.constructor!==void 0)return null;if(128&r.__u&&(l=32&r.__u,d=r.__c.__z)){if(t.__u|=l,f=o=[],d.nodeType==8)for(p=1,h=d.nextSibling;h;h=h.nextSibling){if(h.nodeType==8){if(h.data.startsWith(`$s`))p++;else if(h.data.startsWith(`/$s`)&&!--p)break}o.push(h)}else o.push(d);c=o[0]}(d=n.__b)&&d(t);n:if(typeof me==`function`){_=s.length;try{if(E=t.props,D=(d=me.prototype)&&d.render,ne=(d=me.contextType)&&i[d.__c],O=d?ne?ne.props.value:d.__:i,r.__c?2&(b=t.__c=r.__c).__g&&(b.__g|=1):(D?t.__c=b=new me(E,O):(t.__c=b=new C(E,O),b.constructor=me,b.render=pe),ne&&ne.sub(b),b.state||(b.state={}),b.__n=i,b.__g|=8,b.__h=[],b.__k=[]),D&&(b.__s||(b.__s=b.state),me.getDerivedStateFromProps&&(b.__s==b.state&&(b.__s=v({},b.__s)),v(b.__s,me.getDerivedStateFromProps(E,b.__s)))),x=b.props,T=b.state,b.__v=t,r.__c){if(D&&!me.getDerivedStateFromProps&&E!==x&&b.componentWillReceiveProps&&b.componentWillReceiveProps(E,O),t.__v==r.__v&&!(8&b.__g)||!(4&b.__g)&&b.shouldComponentUpdate&&!1===b.shouldComponentUpdate(E,b.__s,O)){t.__v!=r.__v&&(b.props=E,b.state=b.__s,b.__g&=-9),t.__e=r.__e,t.__k=r.__k,t.__k.some(function(e){e&&(e.__=t)}),m.push.apply(b.__h,b.__k),b.__k=[],b.__h.length&&s.push(b),c=w(r);break n}b.componentWillUpdate&&b.componentWillUpdate(E,b.__s,O),D&&b.componentDidUpdate&&b.__h.push(function(){b.componentDidUpdate(x,T,ee)})}else D&&!me.getDerivedStateFromProps&&b.componentWillMount&&b.componentWillMount(),D&&b.componentDidMount&&b.__h.push(b.componentDidMount);if(b.context=O,b.props=E,b.__P=e,b.__g&=-5,re=n.__r,ie=0,D)b.state=b.__s,b.__g&=-9,re&&re(t),d=b.render(b.props,b.state,b.context),m.push.apply(b.__h,b.__k),b.__k=[];else do b.__g&=-9,re&&re(t),d=b.render(b.props,b.state,b.context),b.state=b.__s;while(8&b.__g&&++ie<25);b.state=b.__s,b.getChildContext&&(i=v({},i,b.getChildContext())),D&&r.__c&&b.getSnapshotBeforeUpdate&&(ee=b.getSnapshotBeforeUpdate(x,T)),ae=d&&d.type===S&&d.key==null?d.props.children:d,E.__P&&(d=c,a=(e=E.__P).namespaceURI,l=o=null,r.props&&r.props.__P!=e&&(r.__k.some(function(e){e&&fe(e,e)}),r.__k=null),c=r.__k?w(r,0):null),c=te(e,g(ae)?ae:[ae],t,r,i,a,o,s,c,l,u),E.__P&&(t.__e=null,c=d),t.__u&=-161,128&r.__u&&(b.__z=null),f&&f.some(y),b.__h.length&&s.push(b),1&b.__g&&(b.__g&=-4)}catch(e){if(s.length=_,t.__v=null,l||o){if(e.then){if(oe=0,t.__u|=l?160:128,o){for(~(le=o.indexOf(c||void 0))||(le=o.length);(de=o[le-1])&&de.nodeType==8;)le--;for(;le<o.length;le++)if(de=o[le]){if(o[le]=null,de.nodeType==8){if(de.data.startsWith(`$s`))oe++||(se=de);else if(oe&&de.data.startsWith(`/$s`)&&!--oe){c=de;break}}else if(!oe)break}}if(!se){for(;c&&c.nodeType==8&&c.nextSibling;)c=c.nextSibling;se=c}t.__c.__z||(t.__c.__z=se),t.__e=c}else o&&o.some(y)}else t.__e=r.__e;t.__k||(t.__k=r.__k||[]),e.then||ce(t),n.__e(e,t,r)}}else c=t.__e=ue(r.__e,t,r,i,a,o,s,l,u,e);return(d=n.diffed)&&d(t),128&t.__u?void 0:c}function ce(e){e&&(e.__c&&(e.__c.__g|=4),e.__k&&e.__k.some(ce))}function le(e,t,r){for(var i=0;i<r.length;)de(r[i++],r[i++],r[i++]);n.__c&&n.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){n.__e(e,t.__v)}})}function ue(e,t,r,i,a,o,s,c,l,u){var d,f,m,v,b,x,S,C,T,ee=r.props||p,E=t.props,D=t.type;if(D==`svg`?a=`http://www.w3.org/2000/svg`:D==`math`?a=`http://www.w3.org/1998/Math/MathML`:a||(a=`http://www.w3.org/1999/xhtml`),o){for(d=0;d<o.length;d++)if((b=o[d])&&(D?b.localName==D:b.nodeType==3)){e=b,o[d]=null;break}}if(!e){if(C=u.ownerDocument||document,!D)return C.createTextNode(E);e=C.createElementNS(a,D,E.is&&E),c&&(n.__m&&n.__m(t,o),c=!1),o=null}if(D){if(u=D==`template`?e.content:e,o=D==`textarea`&&E.defaultValue!=null?null:o&&_.call(u.childNodes),!c&&o)for(ee={},d=0;d<e.attributes.length;d++)ee[(b=e.attributes[d]).name]=b.value;for(d in ee)b=ee[d],d==`dangerouslySetInnerHTML`?m=b:d==`children`||d in E||d==`value`&&`defaultValue`in E||d==`checked`&&`defaultChecked`in E||ae(e,d,null,b,a);for(d in T=1&r.__u,E)b=E[d],d==`children`?v=b:d==`dangerouslySetInnerHTML`?f=b:d==`value`?x=b:d==`checked`?S=b:c&&typeof b!=`function`||!(ee[d]!==b||T&&b!=null)||ae(e,d,b,ee[d],a);f?(c||m&&(f.__html==m.__html||f.__html==e.innerHTML)||(e.innerHTML=f.__html),t.__k=[]):(m&&(e.textContent=``),(D==`foreignObject`||a==`http://www.w3.org/1998/Math/MathML`&&h.test(D))&&(a=`http://www.w3.org/1999/xhtml`),te(u,g(v)?v:[v],t,r,i,a,o,s,o?o[0]:r.__k&&w(r,0),c,l),o&&o.some(y)),c&&D!=`textarea`||(d=`value`,D==`progress`&&x==null?e.removeAttribute(d):x==null||x===e[d]&&(D!=`progress`||x)||ae(e,d,x,ee[d],a),d=`checked`,S!=null&&S!=e[d]&&ae(e,d,S,ee[d],a))}else ee===E||c&&e.data==E||(e.data=E);return e}function de(e,t,r,i){try{typeof e==`function`?t?t.__x=e(t)||1:i&&(i=i.__c||i.__e)&&(t=i.__x)&&(i.__x=null,typeof t==`function`?t():e(null)):e.current=t}catch(e){n.__e(e,r)}}function fe(e,t,r){var i,a;if(n.unmount&&n.unmount(e),!(i=e.ref)||i.current&&i.current!=e.__e||de(i,null,t,e),i=e.__c){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(e){n.__e(e,t)}i.__P=i.__n=null}if(i=e.__k)for(a=0;a<i.length;a++)i[a]&&fe(i[a],t,typeof e.type!=`function`||r&&!e.props.__P);(i=e.__e)&&(r||y(i),i.__e&&(i.__e=null)),e.__e=e.__c=e.__=null}function pe(e,t,n){return this.constructor(e,n)}function me(e,t){var r,i,a,o;n.__&&n.__(e,t),t.nodeType==9&&(t=t.documentElement),i=(r=e&&32&e.__u)?null:t.__k,t.__k=x(S,{children:[e]}),a=[],o=[],se(t,t.__k,i||p,p,t.namespaceURI,i?null:t.firstChild?_.call(t.childNodes):null,a,i?i.__e:t.firstChild,r,o),le(a,t.__k,o),t.__k.props.children=null}function he(e){function t(e){var n,r;return this.getChildContext||(n=new Set,(r={})[t.__c]=this,this.getChildContext=function(){return r},this.shouldComponentUpdate=function(e){this.props.value!=e.value&&n.forEach(function(e){e.__g|=4,ee(e)})},this.sub=function(e){n.add(e);var t=e.componentWillUnmount;e.componentWillUnmount=function(){n.delete(e),t&&t.call(e)}}),e.children}return t.__c=`__cC`+f++,t.__=e,t.Provider=(t.Consumer=function(e,t){return e.children(t)}).contextType=t,t}n={__e:function(e,t,n,r){for(var i,a,s;t=t.__;)if((i=t.__c)&&!(1&i.__g)){i.__g|=4;try{if((a=i.constructor)&&a.getDerivedStateFromError&&(i.setState(a.getDerivedStateFromError(e)),s=8&i.__g),i.componentDidCatch&&(i.componentDidCatch(e,r||{}),s=8&i.__g),s)return void(i.__g|=2)}catch(t){e=t,s=0}}throw o=0,e}},r=0,C.prototype.setState=function(e,t){var n=this.__s;n&&n!=this.state||(n=this.__s=v({},this.state)),typeof e==`function`&&(e=e(v({},n),this.props)),e&&(v(n,e),this.__v&&(t&&this.__k.push(t),ee(this)))},C.prototype.forceUpdate=function(e){this.__v&&(this.__g|=4,e&&this.__h.push(e),ee(this))},C.prototype.render=S,i=[],o=0,s=function(e,t){return e.__v.__b-t.__v.__b},c=Symbol(),l=/(PointerCapture)$|Capture$/i,u=0,d={},f=0;var ge,k,_e,ve,ye=Object.is,be=0,xe=[],Se=[],Ce=n,we=Ce.__b,Te=Ce.__r,Ee=Ce.diffed,De=Ce.__c,Oe=Ce.unmount,ke=Ce.__;function Ae(e,t){Ce.__h&&Ce.__h(k,e,be||t),be=0;var n=k.__H||(k.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function je(e){return be=1,Me(Ge,e)}function Me(e,t,n){var r=Ae(ge++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Ge(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);ye(t,n)||(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=k,!k.__f)){k.__f=!0;var i=k.shouldComponentUpdate;k.shouldComponentUpdate=function(e,t,n){var r=this.__H;if(!r)return!0;var a=!1,o=this.props!=e;if(r.__.some(function(e){e.__N&&(a=!0,ye(e.__[0],e.__N[0])||(o=!0))}),i){var s=i.call(this,e,t,n);return a?s||o:s}return!a||o}}return r.__}function Ne(e,t){var n=Ae(ge++,3);!Ce.__s&&We(n.__H,t)&&(n.__P=!0,n.__=e,n.u=t,k.__H.__h.push(n))}function Pe(e,t){var n=Ae(ge++,4);!Ce.__s&&We(n.__H,t)&&(n.__P=!1,n.__=e,n.u=t,k.__h.push(n))}function A(e){return be=5,Fe(function(){return{current:e}},[])}function Fe(e,t){var n=Ae(ge++,7);return We(n.__H,t)&&(n.__=e(),n.__H=t),n.__}function Ie(e,t){return be=8,Fe(function(){return e},t)}function j(e){var t=k.context[e.__c],n=Ae(ge++,9);return n.c=e,t?(n.__??(n.__=!0,t.sub(k)),t.props.value):e.__}function Le(){var e=Ae(ge++,11);if(!e.__){for(var t=k.__v;!t.__m&&t.__;)t=t.__;var n=t.__m||(t.__m=[0,0]);e.__=`P`+n[0]+`-`+n[1]++}return e.__}function Re(){var e;do{for(;e=Se.shift();)try{He(e)}catch(t){Ce.__e(t,{__:(e=e.__P)&&e.__v})}for(;e=xe.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(He),t.__h.some(Ue),t.__h=[]}catch(n){t.__h=[],Ce.__e(n,e.__v)}}}while(Se.length)}Ce.__b=function(e){k=null,we&&we(e)},Ce.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),ke&&ke(e,t)},Ce.__r=function(e){Te&&Te(e),ge=0;var t=(k=e.__c).__H;t&&(_e==k?k.__h=[]:(t.__h.some(He),t.__h.some(Ue),ge=0),t.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})),_e=k},Ce.diffed=function(e){Ee&&Ee(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&Ve(xe.push(t)),t.__H.__.some(function(e){e.u&&(e.__H=e.u)})),_e=k=null},Ce.__c=function(e,t){t.some(function(e){try{e.__h.some(He),e.__h=e.__h.filter(function(e){return!e.__||Ue(e)})}catch(n){t.some(function(e){e.__h&&(e.__h=[])}),t=[],Ce.__e(n,e.__v)}}),De&&De(e,t)},Ce.unmount=function(e){Oe&&Oe(e);var t,n,r=e.__c;r&&r.__H&&(r.__H.__.some(function(r){try{if(r.__P&&r.__c){if(n===void 0){for(n=e.__;n&&(!n.__c||!n.__c.__P);)n=n.__;n=n&&n.__c}r.__P=n,Ve(Se.push(r))}else He(r)}catch(e){t=e}}),r.__H=void 0,t&&Ce.__e(t,r.__v))};var ze=typeof requestAnimationFrame==`function`;function Be(e){var t,n=function(){clearTimeout(r),ze&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);ze&&(t=requestAnimationFrame(n))}function Ve(e){e!=1&&ve==Ce.requestAnimationFrame||((ve=Ce.requestAnimationFrame)||Be)(Re)}function He(e){var t=k,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),k=t}function Ue(e){var t=k;e.__c=e.__(),k=t}function We(e,t){return!e||e.length!=t.length||t.some(function(t,n){return!ye(t,e[n])})}function Ge(e,t){return typeof t==`function`?t(e):t}var Ke=Object.assign,qe=/^(-|f[lo].*[^se]$|g.{5,}[^ps]$|z|o[pr]|(W.{5})?[lL]i.*(t|mp)$|an|(bo|s).{4}Im|sca|m.{6}[ds]|ta|c.*[st]$|wido|ini)/,Je,Ye,Xe=Symbol.for(`react.element`),Ze=/^(?: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]/,Qe=/[A-Z0-9]/g,$e=typeof document<`u`,et=ot(function(e,t,r){var i=n.__s||Je?(r||t)():t(),a=je({t:{__:i,u:t}}),o=a[0].t,s=a[1];return Pe(function(){o.__=i,o.u=t,tt(o)&&s({t:o})},[e,i,t]),Ne(function(){return tt(o)&&s({t:o}),e(function(){tt(o)&&s({t:o})})},[e]),i});function tt(e){try{return!Object.is(e.__,e.u())}catch{return!0}}var nt=function(e){return/fil|che|rad/.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 rt=n.event;n.event=function(e){return rt&&(e=rt(e)),e.persist=function(){},e.isPropagationStopped=function(){return this.cancelBubble},e.isDefaultPrevented=function(){return this.defaultPrevented},e.nativeEvent=e};var it={configurable:!0,get:function(){return this.class}},at=n.vnode;function ot(e){if(!Ye){Ye=!0;var t=n.__r;n.__r=function(e){t&&t(e),32&e.__u&&(Je=e),e.__c};var r=n.diffed;n.diffed=function(e){r&&r(e),Je==e&&(Je=null)}}return e}n.vnode=function(e){if(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||$e&&a==`children`&&n==`noscript`||a==`class`||a==`className`)){if(a==`style`&&typeof o==`object`){var s=void 0;for(var c in o)typeof o[c]!=`number`||qe.test(c)||(s||(s=o=Ke({},o)),o[c]+=`px`)}else if(a==`defaultValue`&&`value`in t&&t.value==null)a=`value`;else if(a==`download`&&!0===o)o=``;else if(a==`translate`&&o===`no`)o=!1;else if(a[0]==`o`&&a[1]==`n`){var l=a.toLowerCase();l==`ondoubleclick`?a=`ondblclick`:l!=`onchange`||n!=`input`&&n!=`textarea`||nt(t.type)?l==`onfocus`?a=`onfocusin`:l==`onblur`&&(a=`onfocusout`):l=a=`oninput`,l==`oninput`&&r[a=l]&&(a=`oninputCapture`)}else i&&Ze.test(a)?a=a.replace(Qe,`-$&`).toLowerCase():o===null&&(o=void 0);r[a]=o}}n==`select`&&(r.multiple&&Array.isArray(r.value)&&(r.value=O(t.children).forEach(function(e){e.props.selected=r.value.indexOf(e.props.value)!=-1})),r.defaultValue!=null&&(r.value=O(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\",it)):t.className&&(r.class=r.className=t.className),e.props=r})(e);else if(typeof e.type==`function`&&(`ref`in e.props&&`prototype`in e.type&&e.type.prototype.render&&(e.ref=e.props.ref,delete e.props.ref),e.type.defaultProps)){var t=Ke({},e.props);for(var n in e.type.defaultProps)t[n]===void 0&&(t[n]=e.type.defaultProps[n]);e.props=t}e.ref&&!(`ref`in e.props)&&Object.defineProperty(e.props,\"ref\",{value:e.ref,configurable:!0,writable:!0}),e.$$typeof=Xe,at&&at(e)};var st=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},ct=(e=>e?st(e):st),lt=e=>e;function ut(e){function t(t=lt){let n=Ie(()=>t(e.getState()),[t]);return et(e.subscribe,n)}return Object.assign(t,e)}function dt(){return e=>ut(ct()(e))}function ft(){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 pt=Symbol.for(`immer-nothing`),mt=Symbol.for(`immer-draftable`),M=Symbol.for(`immer-state`);function ht(e,...t){throw Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var gt=Object,_t=gt.getPrototypeOf,vt=`constructor`,yt=`prototype`,bt=`configurable`,xt=`enumerable`,St=`writable`,Ct=`value`,wt=e=>!!e&&!!e[M];function Tt(e){return e?Ot(e)||It(e)||!!e[mt]||!!e[vt]?.[mt]||Lt(e)||Rt(e):!1}var Et=gt[yt][vt].toString(),Dt=new WeakMap;function Ot(e){if(!e||!zt(e))return!1;let t=_t(e);if(t===null||t===gt[yt])return!0;let n=gt.hasOwnProperty.call(t,vt)&&t[vt];if(n===Object)return!0;if(!Bt(n))return!1;let r=Dt.get(n);return r===void 0&&(r=Function.toString.call(n),Dt.set(n,r)),r===Et}function kt(e){return wt(e)||ht(15,e),e[M].base_}function At(e,t,n=!0){jt(e)===0?(n?Reflect.ownKeys(e):gt.keys(e)).forEach(n=>{t(n,e[n],e)}):e.forEach((n,r)=>t(r,n,e))}function jt(e){let t=e[M];return t?t.type_:It(e)?1:Lt(e)?2:Rt(e)?3:0}var Mt=(e,t,n=jt(e))=>n===2?e.has(t):gt[yt].hasOwnProperty.call(e,t),Nt=(e,t,n=jt(e))=>n===2?e.get(t):e[t],Pt=(e,t,n,r=jt(e))=>{r===2?e.set(t,n):r===3?e.add(n):e[t]=n};function Ft(e,t){return e===t?e!==0||1/e==1/t:e!==e&&t!==t}var It=Array.isArray,Lt=e=>e instanceof Map,Rt=e=>e instanceof Set,zt=e=>typeof e==`object`,Bt=e=>typeof e==`function`,Vt=e=>typeof e==`boolean`;function N(e){let t=+e;return Number.isInteger(t)&&String(t)===e}var P=e=>zt(e)?e?.[M]:null,F=e=>e.copy_||e.base_,Ht=e=>{let t=P(e);return t?Ut(t):e},Ut=e=>e.modified_?e.copy_:e.base_;function I(e,t){if(Lt(e))return new Map(e);if(Rt(e))return new Set(e);if(It(e))return Array[yt].slice.call(e);let n=Ot(e);if(t===!0||t===`class_only`&&!n){let t=gt.getOwnPropertyDescriptors(e);delete t[M];let n=Reflect.ownKeys(t);for(let r=0;r<n.length;r++){let i=n[r],a=t[i];a[St]===!1&&(a[St]=!0,a[bt]=!0),(a.get||a.set)&&(t[i]={[bt]:!0,[St]:!0,[xt]:a[xt],[Ct]:e[i]})}return gt.create(_t(e),t)}{let t=_t(e);if(t!==null&&n)return{...e};let r=gt.create(t);return gt.assign(r,e)}}function Wt(e,t=!1){return qt(e)||wt(e)||!Tt(e)||(jt(e)>1&&gt.defineProperties(e,{set:Kt,add:Kt,clear:Kt,delete:Kt}),gt.freeze(e),t&&At(e,(e,t)=>{Wt(t,!0)},!1)),e}function Gt(){ht(2)}var Kt={[Ct]:Gt};function qt(e){return e===null||!zt(e)||gt.isFrozen(e)}var Jt=`MapSet`,Yt=`Patches`,Xt=`ArrayMethods`,Zt={};function Qt(e){let t=Zt[e];return t||ht(0,e),t}var $t=e=>!!Zt[e];function en(e,t){Zt[e]||(Zt[e]=t)}var L,tn=()=>L,nn=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:$t(Jt)?Qt(Jt):void 0,arrayMethodsPlugin_:$t(Xt)?Qt(Xt):void 0});function rn(e,t){t&&(e.patchPlugin_=Qt(Yt),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function an(e){on(e),e.drafts_.forEach(R),e.drafts_=null}function on(e){e===L&&(L=e.parent_)}var sn=e=>L=nn(L,e);function R(e){let t=e[M];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function cn(e,t){t.unfinalizedDrafts_=t.drafts_.length;let n=t.drafts_[0];if(e!==void 0&&e!==n){n[M].modified_&&(an(t),ht(4)),Tt(e)&&(e=ln(t,e));let{patchPlugin_:r}=t;r&&r.generateReplacementPatches_(n[M].base_,e,t)}else e=ln(t,n);return un(t,e,!0),an(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e===pt?void 0:e}function ln(e,t){if(qt(t))return t;let n=t[M];if(!n)return vn(t,e.handledSet_,e);if(!fn(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);gn(n,e)}return n.copy_}function un(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Wt(t,n)}function dn(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var fn=(e,t)=>e.scope_===t,pn=[];function mn(e,t,n,r){let i=F(e),a=e.type_;if(r!==void 0&&Nt(i,r,a)===t){Pt(i,r,n,a);return}if(!e.draftLocations_){let t=e.draftLocations_=new Map;At(i,(e,n)=>{if(wt(n)){let r=t.get(n)||[];r.push(e),t.set(n,r)}})}let o=e.draftLocations_.get(t)??pn;for(let e of o)Pt(i,e,n,a)}function hn(e,t,n){e.callbacks_.push(function(r){let i=t;if(!i||!fn(i,r))return;r.mapSetPlugin_?.fixSetContents(i);let a=Ut(i);mn(e,i.draft_??i,a,n),gn(i,r)})}function gn(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)}dn(e)}}function _n(e,t,n){let{scope_:r}=e;if(wt(n)){let i=n[M];fn(i,r)&&i.callbacks_.push(function(){Dn(e),mn(e,n,Ut(i),t)})}else Tt(n)&&e.callbacks_.push(function(){let i=F(e);e.type_===3?i.has(n)&&vn(n,r.handledSet_,r):Nt(i,t,e.type_)===n&&r.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&vn(Nt(e.copy_,t,e.type_),r.handledSet_,r)})}function vn(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||wt(e)||t.has(e)||!Tt(e)||qt(e)||(t.add(e),At(e,(r,i)=>{if(wt(i)){let t=i[M];fn(t,n)&&(Pt(e,r,Ut(t),e.type_),dn(t))}else Tt(i)&&vn(i,t,n)})),e}function yn(e,t){let n=It(e),r={type_:+!!n,scope_:t?t.scope_:tn(),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=bn;n&&(i=[r],a=xn);let{revoke:o,proxy:s}=Proxy.revocable(i,a);return r.draft_=s,r.revoke_=o,[s,r]}var bn={get(e,t){if(t===M)return e;let n=e.scope_.arrayMethodsPlugin_,r=e.type_===1&&typeof t==`string`;if(r&&n?.isArrayOperationMethod(t))return n.createMethodInterceptor(e,t);let i=F(e);if(!Mt(i,t,e.type_))return wn(e,i,t);let a=i[t];if(e.finalized_||!Tt(a)||r&&e.operationMethod&&n?.isMutatingArrayMethod(e.operationMethod)&&N(t))return a;if(a===Sn(e.base_,t)||Cn(e,t,a)){Dn(e);let n=e.type_===1?+t:t,r=kn(e.scope_,a,e,n);return e.copy_[n]=r}return a},has(e,t){return t in F(e)},ownKeys(e){return Reflect.ownKeys(F(e))},set(e,t,n){let r=Tn(F(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){let r=Sn(F(e),t),i=r?.[M];if(i&&i.base_===n)return e.copy_[t]=n,e.assigned_.delete(t),!0;if(Ft(n,r)&&(n!==void 0||Mt(e.base_,t,e.type_)))return!0;Dn(e),En(e)}return e.copy_[t]===n&&(n!==void 0||Mt(e.copy_,t,e.type_))||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_.set(t,!0),_n(e,t,n)),!0},deleteProperty(e,t){return Dn(e),Sn(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),En(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let n=F(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{[St]:!0,[bt]:e.type_!==1||t!==`length`,[xt]:r[xt],[Ct]:n[t]}},defineProperty(){ht(11)},getPrototypeOf(e){return _t(e.base_)},setPrototypeOf(){ht(12)}},xn={};for(let e in bn){let t=bn[e];xn[e]=function(){let e=arguments;return e[0]=e[0][0],t.apply(this,e)}}xn.deleteProperty=function(e,t){return xn.set.call(this,e,t,void 0)},xn.set=function(e,t,n){return bn.set.call(this,e[0],t,n,e[0])};function Sn(e,t){let n=e[M];return(n?F(n):e)[t]}function Cn(e,t,n){return e.type_!==1||!e.allIndicesReassigned_||e.assigned_?.get(t)||!Tt(n)||n[M]?!1:e.baseRefs_.has(n)}function wn(e,t,n){let r=Tn(t,n);return r?Ct in r?r[Ct]:r.get?.call(e.draft_):void 0}function Tn(e,t){if(!(t in e))return;let n=_t(e);for(;n;){let e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=_t(n)}}function En(e){e.modified_||(e.modified_=!0,e.parent_&&En(e.parent_))}function Dn(e){e.copy_||(e.assigned_=new Map,e.copy_=I(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var On=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(e,t,n)=>{if(Bt(e)&&!Bt(t)){let n=t;t=e;let r=this;return function(e=n,...i){return r.produce(e,e=>t.call(this,e,...i))}}Bt(t)||ht(6),n!==void 0&&!Bt(n)&&ht(7);let r;if(Tt(e)){let i=sn(this),a=kn(i,e,void 0),o=!0;try{r=t(a),o=!1}finally{o?an(i):on(i)}return rn(i,n),cn(r,i)}if(!e||!zt(e)){if(r=t(e),r===void 0&&(r=e),r===pt&&(r=void 0),this.autoFreeze_&&Wt(r,!0),n){let t=[],i=[];Qt(Yt).generateReplacementPatches_(e,r,{patches_:t,inversePatches_:i}),n(t,i)}return r}ht(1,e)},this.produceWithPatches=(e,t)=>{if(Bt(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]},Vt(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),Vt(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),Vt(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Tt(e)||ht(8),wt(e)&&(e=An(e));let t=sn(this),n=kn(t,e,void 0);return n[M].isManual_=!0,on(t),n}finishDraft(e,t){let n=e&&e[M];(!n||!n.isManual_)&&ht(9);let{scope_:r}=n;return rn(r,t),cn(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=Qt(Yt).applyPatches_;return wt(e)?r(e,t):this.produce(e,e=>r(e,t))}};function kn(e,t,n,r){let[i,a]=Lt(t)?Qt(Jt).proxyMap_(t,n):Rt(t)?Qt(Jt).proxySet_(t,n):yn(t,n);return(n?.scope_??tn()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?hn(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 An(e){return wt(e)||ht(10,e),jn(e)}function jn(e){if(!Tt(e)||qt(e))return e;let t=e[M],n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=I(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=I(e,!0);return At(n,(e,t)=>{Pt(n,e,jn(t))},r),t&&(t.finalized_=!1),n}function Mn(){function e(n,r=[]){if(n.key_!==void 0){let e=n.parent_.copy_??n.parent_.base_,t=P(Nt(e,n.key_)),i=Nt(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||Mt(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=Nt(n,r),!zt(n)||n===null)throw Error(`Cannot resolve path at '${t.join(`/`)}'`)}return n}let n=`replace`,r=`remove`;function i(e,t,n){if(e.scope_.processedForPatches_.has(e))return;e.scope_.processedForPatches_.add(e);let{patches_:r,inversePatches_:i}=n;switch(e.type_){case 0:case 2:return o(e,t,r,i);case 1:return a(e,t,r,i);case 3:return s(e,t,r,i)}}function a(e,t,i,a){let{base_:o,assigned_:s}=e,c=e.copy_;c.length<o.length&&([o,c]=[c,o],[i,a]=[a,i]);let l=e.allIndicesReassigned_===!0;for(let e=0;e<o.length;e++){let r=c[e],u=o[e];if((l||s?.get(e.toString()))&&r!==u){let o=r?.[M];if(o&&o.modified_)continue;let s=t.concat([e]);i.push({op:n,path:s,value:d(r)}),a.push({op:n,path:s,value:d(u)})}}for(let e=o.length;e<c.length;e++){let n=t.concat([e]);i.push({op:`add`,path:n,value:d(c[e])})}for(let e=c.length-1;o.length<=e;--e){let n=t.concat([e]);a.push({op:r,path:n})}}function o(e,t,i,a){let{base_:o,copy_:s,type_:c}=e;At(e.assigned_,(e,l)=>{let u=Nt(o,e,c),f=Nt(s,e,c),p=l?Mt(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===pt?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=jt(o),n=i[e];typeof n!=`string`&&typeof n!=`number`&&(n=``+n),(t===0||t===1)&&(n===`__proto__`||n===vt)&&ht(19),Bt(o)&&n===yt&&ht(19),o=Nt(o,n),(o===null||!zt(o))&&ht(18,i.join(`/`))}let s=jt(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:ht(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:ht(17,a)}}),e}function u(e){if(!Tt(e))return e;if(It(e))return e.map(u);if(Lt(e))return new Map(Array.from(e.entries()).map(([e,t])=>[e,u(t)]));if(Rt(e))return new Set(Array.from(e).map(u));let t=Object.create(_t(e));for(let n in e)t[n]=u(e[n]);return Mt(e,mt)&&(t[mt]=e[mt]),t}function d(e){return wt(e)?u(e):e}en(Yt,{applyPatches_:l,generatePatches_:i,generateReplacementPatches_:c,getPath:e})}var Nn=globalThis.Iterator,Pn=typeof Nn?.from==`function`;function Fn(){class e extends Map{constructor(e,t){super(),this[M]={type_:2,parent_:t,scope_:t?t.scope_:tn(),modified_:!1,finalized_:!1,copy_:void 0,assigned_:void 0,base_:e,draft_:this,isManual_:!1,revoked_:!1,callbacks_:[]}}get size(){let e=this[M];return s(e),F(e).size}has(e){let t=this[M];return s(t),F(t).has(e)}set(e,t){let n=this[M];return s(n),(!F(n).has(e)||F(n).get(e)!==t)&&(r(n),En(n),n.assigned_.set(e,!0),n.copy_.set(e,t),n.assigned_.set(e,!0),_n(n,e,t)),this}delete(e){if(!this.has(e))return!1;let t=this[M];return s(t),r(t),En(t),t.base_.has(e)?t.assigned_.set(e,!1):t.assigned_.delete(e),t.copy_.delete(e),!0}clear(){let e=this[M];s(e),F(e).size&&(r(e),En(e),e.assigned_=new Map,At(e.base_,t=>{e.assigned_.set(t,!1)}),e.copy_.clear())}forEach(e,t){let n=this[M];s(n),F(n).forEach((n,r,i)=>{e.call(t,this.get(r),r,this)})}get(e){let t=this[M];s(t);let n=F(t).get(e);if(t.finalized_||!Tt(n)||n!==t.base_.get(e))return n;let i=kn(t.scope_,n,t,e);return r(t),t.copy_.set(e,i),i}keys(){let e=this[M];return s(e),F(e).keys()}values(){let e=this.keys();return t({next:()=>{let t=e.next();return t.done?t:{done:!1,value:this.get(t.value)}}})}entries(){let e=this.keys();return t({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(e){if(Pn)return Nn.from(e);let t={...e,[Symbol.iterator]:()=>t};return t}function n(t,n){let r=new e(t,n);return[r,r[M]]}function r(e){e.copy_||(e.assigned_=new Map,e.copy_=new Map(e.base_))}class i extends Set{constructor(e,t){super(),this[M]={type_:3,parent_:t,scope_:t?t.scope_:tn(),modified_:!1,finalized_:!1,copy_:void 0,base_:e,draft_:this,drafts_:new Map,revoked_:!1,isManual_:!1,assigned_:void 0,callbacks_:[]}}get size(){let e=this[M];return s(e),F(e).size}has(e){let t=this[M];return s(t),t.copy_?!!(t.copy_.has(e)||t.drafts_.has(e)&&t.copy_.has(t.drafts_.get(e))):t.base_.has(e)}add(e){let t=this[M];return s(t),this.has(e)||(o(t),En(t),t.copy_.add(e),_n(t,e,e)),this}delete(e){if(!this.has(e))return!1;let t=this[M];return s(t),o(t),En(t),t.copy_.delete(e)||(t.drafts_.has(e)?t.copy_.delete(t.drafts_.get(e)):!1)}clear(){let e=this[M];s(e),F(e).size&&(o(e),En(e),e.copy_.clear())}values(){let e=this[M];return s(e),o(e),e.copy_.values()}entries(){let e=this[M];return s(e),o(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 a(e,t){let n=new i(e,t);return[n,n[M]]}function o(e){e.copy_||(e.copy_=new Set,e.base_.forEach(t=>{if(Tt(t)){let n=kn(e.scope_,t,e,t);e.drafts_.set(t,n),e.copy_.add(n)}else e.copy_.add(t)}))}function s(e){e.revoked_&&ht(3,JSON.stringify(F(e)))}function c(e){if(e.type_===3&&e.copy_){let t=new Set(e.copy_);e.copy_.clear(),t.forEach(t=>{e.copy_.add(Ht(t))})}}en(Jt,{proxyMap_:n,proxySet_:a,fixSetContents:c})}var In=new On().produce,Ln=e=>(t,n,r)=>(r.setState=(e,n,...r)=>t(typeof e==`function`?In(e):e,n,...r),e(r.setState,n,r)),Rn={$:`variable`,_:`temporary`,\"@\":`local`,\"%\":`transient`},zn=Object.fromEntries(Object.entries(Rn).map(([e,t])=>[t,e])),Bn=new Set(Object.keys(Rn));function Vn(e){return e!==void 0&&Bn.has(e)}function Hn(e,t){return t.className&&(e.className=t.className),t.id&&(e.id=t.id),e}var Un={SIGIL_SCOPES:Rn,withSelectors:Hn},Wn=`{`,Gn=`}`,{SIGIL_SCOPES:Kn,withSelectors:qn}=Un,Jn=new Set([`area`,`base`,`br`,`col`,`embed`,`hr`,`img`,`input`,`link`,`meta`,`param`,`source`,`track`,`wbr`]),Yn={elseif:`if`,else:`if`,case:`switch`,default:`switch`,next:`timed`},Xn=[[`|`,!1],[`->`,!1],[`<-`,!0]],Zn={},Qn=/^<[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 $n(e,t,n){let r=(n,r)=>{let i=e.slice(n,r),a=i.trim(),o=t+n+(a?i.indexOf(a):0);return{value:a,start:o,end:o+a.length}};for(let[t,i]of Xn){let a=n(t);if(a===-1)continue;let o=r(0,a),s=r(a+t.length,e.length),[c,l]=i?[s,o]:[o,s];return{display:c.value,displayStart:c.start,displayEnd:c.end,target:l.value,targetStart:l.start,targetEnd:l.end}}let i=r(0,e.length);return{display:i.value,displayStart:i.start,displayEnd:i.end,target:i.value,targetStart:i.start,targetEnd:i.end}}function er(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 tr(e){return e.lex===`html`?(e.isClose?`</`:`<`)+e.tag+`>`:Wn+(e.isClose?`/`:``)+e.name+Gn}function nr(e,t,n){return n.lex=e,n.start=t.start.offset,n.end=t.end.offset,n.loc=t,n}function rr(e){let t={start:e.start,end:e.end};switch(e.lex){case`text`:return e.comment?{type:`text`,value:e.value,comment:!0,...t}:{type:`text`,value:e.value,...t};case`link`:return qn({type:`link`,display:e.display,displayStart:e.displayStart,displayEnd:e.displayEnd,target:e.target,targetStart:e.targetStart,targetEnd:e.targetEnd,...e.selectorSpan,...t},e);case`variable`:return qn({type:`variable`,name:e.name,nameStart:e.nameStart,nameEnd:e.nameEnd,scope:e.scope,...e.selectorSpan,...t},e);case`expression`:return qn({type:`expression`,expression:e.expression,expressionStart:e.expressionStart,expressionEnd:e.expressionEnd,...e.selectorSpan,...t},e);case`macro`:return qn({type:`macro`,name:e.name,nameStart:e.nameStart,nameEnd:e.nameEnd,rawArgs:e.rawArgs,argsStart:e.argsStart,argsEnd:e.argsEnd,isClose:e.isClose,...e.selectorSpan,...t},e);case`html`:return{type:`html`,tag:e.tag,tagNameStart:e.tagNameStart,tagNameEnd:e.tagNameEnd,attributes:e.attributes,attributeSpans:e.attributeSpans,isClose:e.isClose,isSelfClose:e.isSelfClose,...t}}}function ir(e){let t=[],n=null,r=e=>{if(e!=null){if(Array.isArray(e))return e.forEach(r);e.lex===`text`&&!e.escape&&!e.comment&&n&&n.lex===`text`&&!n.escape&&!n.comment&&n.end===e.start?(n.value+=e.value,n.end=e.end):(t.push(e),n=e)}};return r(e),t.map(rr)}var ar=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 or(e,t){t=t===void 0?{}:t;let n={},r=t.grammarSource,i={Tokens:rn,SelectorsPrefix:hn},a=rn,o=`\\x3C!--`,s=/^[^\\\\{[<]/,c=/^[{}]/,l=/^[$_@%(!\\/a-zA-Z]/,u=/^[.#]/,d=/^[a-zA-Z0-9_\\-]/,f=/^[$_@%]/,p=/^[a-zA-Z0-9_.]/,m=/^[$_@%(!]/,h=/^[a-zA-Z]/,g=/^[^ \\t\\n\\r\\v\\f\\xA0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000\\uFEFF}]/,_=/^[a-zA-Z0-9.!#$%&'*+\\/=?\\^_`|~\\-]/,v=/^[a-zA-Z0-9.\\-]/,y=/^[\\t-\\r \\/>\\xA0\\u1680\\u2000-\\u200A\\u2028-\\u2029\\u202F\\u205F\\u3000\\uFEFF]/,b=/^[a-zA-Z0-9\\-]/,x=/^[\\t-\\r \"'\\/<->{}\\xA0\\u1680\\u2000-\\u200A\\u2028-\\u2029\\u202F\\u205F\\u3000\\uFEFF]/,S=/^[^\"]/,C=/^[^']/,w=/^[\"']/,T=/^[^ \\t\\n\\r\\v\\f\\xA0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000\\uFEFF>]/,ee=/^[ \\t\\n\\r\\v\\f\\xA0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000\\uFEFF]/,E=Zt(),te=Xt([`\\\\`,`{`,`[`,`<`],!0,!1,!1),D=Yt(`\\x3C!--`,!1),ne=Yt(`>`,!1),O=Yt(`->`,!1),re=Yt(`-->`,!1),ie=Yt(`\\\\`,!1),ae=Xt([`{`,`}`],!1,!1,!1),oe=Yt(`{`,!1),se=Xt([`$`,`_`,`@`,`%`,`(`,`!`,`/`,[`a`,`z`],[`A`,`Z`]],!1,!1,!1),ce=Yt(`<`,!1),le=Yt(`[`,!1),ue=Yt(`[[`,!1),de=Yt(`]]`,!1),fe=Yt(` `,!1),pe=Xt([`.`,`#`],!1,!1,!1),me=Xt([[`a`,`z`],[`A`,`Z`],[`0`,`9`],`_`,`-`],!1,!1,!1),he=Xt([`$`,`_`,`@`,`%`],!1,!1,!1),ge=Xt([[`a`,`z`],[`A`,`Z`],[`0`,`9`],`_`,`.`],!1,!1,!1),k=Yt(`}`,!1),_e=Xt([`$`,`_`,`@`,`%`,`(`,`!`],!1,!1,!1),ve=Yt(`/`,!1),ye=Xt([[`a`,`z`],[`A`,`Z`]],!1,!1,!1),be=Xt([` `,`\t`,`\n`,`\\r`,`\\v`,`\\f`,`\\xA0`,` `,[` `,` `],`\\u2028`,`\\u2029`,` `,` `,` `,``,`}`],!0,!1,!1),xe=Xt([[`a`,`z`],[`A`,`Z`],[`0`,`9`],`.`,`!`,`#`,`$`,`%`,`&`,`'`,`*`,`+`,`/`,`=`,`?`,`^`,`_`,\"`\",`|`,`~`,`-`],!1,!1,!1),Se=Yt(`@`,!1),Ce=Xt([[`a`,`z`],[`A`,`Z`],[`0`,`9`],`.`,`-`],!1,!1,!1),we=Xt([[`\t`,`\\r`],` `,`/`,`>`,`\\xA0`,` `,[` `,` `],[`\\u2028`,`\\u2029`],` `,` `,` `,``],!1,!1,!1),Te=Yt(`</`,!1),Ee=Xt([[`a`,`z`],[`A`,`Z`],[`0`,`9`],`-`],!1,!1,!1),De=Xt([[`\t`,`\\r`],` `,`\"`,`'`,`/`,[`<`,`>`],`{`,`}`,`\\xA0`,` `,[` `,` `],[`\\u2028`,`\\u2029`],` `,` `,` `,``],!1,!1,!1),Oe=Yt(`=`,!1),ke=Yt(`\"`,!1),Ae=Xt([`\"`],!0,!1,!1),je=Yt(`'`,!1),Me=Xt([`'`],!0,!1,!1),Ne=Xt([`\"`,`'`],!1,!1,!1),Pe=Xt([` `,`\t`,`\n`,`\\r`,`\\v`,`\\f`,`\\xA0`,` `,[` `,` `],`\\u2028`,`\\u2029`,` `,` `,` `,``,`>`],!0,!1,!1),A=Xt([` `,`\t`,`\n`,`\\r`,`\\v`,`\\f`,`\\xA0`,` `,[` `,` `],`\\u2028`,`\\u2029`,` `,` `,` `,``],!1,!1,!1);function Fe(e){return ir(e)}function Ie(){return!jn}function j(e){return e}function Le(){return!jn}function Re(e){return Jn.has(e.lower)?null:e}function ze(e){return Fn=e.lower,e.kind===`open`&&Mn.isRaw(Fn)}function Be(e,t){return t}function Ve(e,t){return t?[e,t]:e}function He(e){return e.kind===`close`}function Ue(e){return e}function We(){return!jn}function Ge(e){return e}function Ke(t){return Rn(Mn.rawBodyEnd(e,t,Fn))}function qe(e){return Nn-Gt()}function Je(e,t,n){let r={start:{offset:e},end:{offset:e+t.length}};return[t?nr(`text`,r,{value:t}):null,n]}function Ye(){return Gt()}function Xe(e){return nr(`text`,Kt(),{value:e})}function Ze(e){let t=nr(`text`,Kt(),{value:e});return t.comment=!0,t}function Qe(e){return e.length%2==1}function $e(e,t){return t}function et(t,n){let r=Kt(),i=e.charAt(r.end.offset);if(jn){if(!n&&i!==Wn&&i!==Gn)return nr(`text`,r,{value:t});let e=nr(`text`,r,{value:`\\\\`.repeat(t.length>>1)+(n||``)});return e.escape=!0,e}if(!n)return nr(`text`,r,{value:t});let a=nr(`text`,r,{value:t.slice(1)});a.end=r.end.offset-2;let o=nr(`text`,r,{value:n});return o.start=r.end.offset-2,o.escape=!0,t.length>1?[a,o]:o}function tt(){return nr(`text`,Kt(),{value:Wn})}function nt(){return!jn}function rt(){return nr(`text`,Kt(),{value:`<`})}function it(){return nr(`text`,Kt(),{value:`[`})}function at(){return!jn}function ot(e,t,n,r){let i=nr(`link`,Kt(),$n(r,n,e=>In(r,n,e)));return i.selectorSpan=Ln(t,e,n),qn(i,t)}function st(){return!jn}function ct(){zn(`Unclosed link: [[ without ]]`,Kt(),`unclosed-link`)}function lt(e){return er(e)}function ut(){return Zn}function dt(e,t){return{...e,end:t}}function ft(e,t){return[e,t]}function pt(e,t,n,r,i){let a=nr(`variable`,Kt(),{name:i,nameStart:r,nameEnd:r+i.length,scope:Kn[n]});return a.selectorSpan=Ln(t,e,r-1),qn(a,t)}function mt(e,t,n,r){let i=nr(`expression`,Kt(),{expression:r,expressionStart:n,expressionEnd:n+r.length});return i.selectorSpan=Ln(t,e,n),qn(i,t)}function M(){zn(`Unclosed {`+e.substr(Kt().end.offset,1)+`…: no } ends it`,Kt(),`unclosed-expression`)}function ht(t){return Rn(Mn.closeBrace(e,t,t))}function gt(e){return Nn-Gt()}function _t(e,t){return t}function vt(t,n,r,i,a,o){return Rn(Mn.closeBrace(e,o,r))}function yt(e,t,n,r,i,a){return Nn-Gt()}function bt(e,t,n,r,i,a,o){return o}function xt(e,t,n,r,i,a,o){let s=Kt(),c=i.toLowerCase(),l=nr(`macro`,s,{name:i,lower:c,rawArgs:``,isClose:!!r});return l.nameStart=a-i.length,l.nameEnd=a,l.selectorSpan=Ln(t,e,n),o===null&&zn(`Unclosed {`+(r?`/`:``)+i+`…: no } ends the macro`,s,`unclosed-macro`),l.rawArgs=o.trim(),l.argsStart=l.rawArgs?a+o.length-o.trimStart().length:a,l.argsEnd=l.argsStart+l.rawArgs.length,r?(t!==Zn&&zn(`A closing tag takes no selectors: `+tr(l),s,`closer-with-selectors`),l.rawArgs&&zn(`A closing tag takes no arguments: {/`+i+` `+l.rawArgs+Gn,s,`closer-with-arguments`),l.kind=`close`):(qn(l,t),l.kind=Object.prototype.hasOwnProperty.call(Yn,c)?`branch`:`open`),l}function St(e){zn(`A closing tag starts with a letter after {/`,Kt(),`invalid-closer`)}function Ct(e){return Qn.test(e)}function wt(e){return nr(`text`,Kt(),{value:e})}function Tt(e,t,n,r){let i=t.toLowerCase();return nr(`html`,Kt(),{tag:t,lower:i,tagNameStart:e,tagNameEnd:e+t.length,attributes:Bn(n),attributeSpans:n,isClose:!1,isSelfClose:!!r||Jn.has(i)})}function Et(t,n){let r=e.charAt(n);r||zn(`Unclosed tag <`+t+`: no > ends it (write &lt; for a < that starts no tag)`,Kt(),`unclosed-tag`);let i={source:Kt().source,start:{offset:n,line:0,column:0},end:{offset:n+1,line:0,column:0}};zn(`Unexpected `+JSON.stringify(r)+` in the tag <`+t+`>: expected an attribute, or > to end the tag`,i,`unexpected-character`)}function Dt(e,t){return nr(`html`,Kt(),{tag:t,lower:t.toLowerCase(),tagNameStart:e,tagNameEnd:e+t.length,attributes:{},attributeSpans:[],isClose:!0,isSelfClose:!1})}function Ot(e,t){return Pn=Mn.isCodeAttribute(t),!0}function kt(e,t,n){return n}function At(e,t,n){let r={name:t,value:n?n.value:``,nameStart:e,nameEnd:e+t.length};return n&&(r.valueStart=n.start,r.valueEnd=n.end,n.quote&&(r.quote=n.quote)),r}function jt(e,t,n){return{value:t,start:e,end:n,quote:`\"`}}function Mt(e,t,n){return{value:t,start:e,end:n,quote:`'`}}function Nt(e){zn(`Unclosed attribute value: the `+e+` here has no closing `+e,Kt(),`unclosed-attribute`)}function Pt(e,t,n){return{value:t,start:e,end:n}}function Ft(){return!Pn}function It(e){return e.length%2==1}function Lt(){return!Pn}function Rt(t,n){return Rn(Mn.closeBrace(e,n,t))}function zt(e,t){return Nn-Gt()}function Bt(){return!Pn}function Vt(){return Pn}let N=t.peg$currPos|0,P=N,F=[{line:1,column:1}],Ht=N,Ut=t.peg$maxFailExpected||[],I=t.peg$silentFails|0,Wt;if(t.startRule){if(!(t.startRule in i))throw Error(`Can't start parsing from rule \"`+t.startRule+`\".`);a=i[t.startRule]}function Gt(){return P}function Kt(){return en(P,N)}function qt(e,t){throw t=t===void 0?en(P,N):t,tn(e,t)}function Jt(t=N){let n=e.codePointAt(t);return n===void 0?``:String.fromCodePoint(n)}function Yt(e,t){return{type:`literal`,text:e,ignoreCase:t}}function Xt(e,t,n,r){return{type:`class`,parts:e,inverted:t,ignoreCase:n,unicode:r}}function Zt(){return{type:`any`}}function Qt(){return{type:`end`}}function $t(t){let n=F[t],r;if(n)return n;if(t>=F.length)r=F.length-1;else for(r=t;!F[--r];);for(n=F[r],n={line:n.line,column:n.column};r<t;)e.charCodeAt(r)===10?(n.line++,n.column=1):n.column++,r++;return F[t]=n,n}function en(e,t,n){let i=$t(e),a=$t(t),o={source:r,start:{offset:e,line:i.line,column:i.column},end:{offset:t,line:a.line,column:a.column}};return n&&r&&typeof r.offset==`function`&&(o.start=r.offset(o.start),o.end=r.offset(o.end)),o}function L(e){N<Ht||(N>Ht&&(Ht=N,Ut=[]),Ut.push(e))}function tn(e,t){return new ar(e,null,null,t)}function nn(e,t,n){return new ar(ar.buildMessage(e,t),e,t,n)}function rn(){let e,t,r;for(e=N,t=[],r=an();r!==n;)t.push(r),r=an();return P=e,t=Fe(t),e=t,e}function an(){let e,t,r,i,a;return e=cn(),e===n&&(e=un(),e===n&&(e=ln(),e===n&&(e=fn(),e===n&&(e=Sn(),e===n&&(e=N,P=N,t=Ie(),t=t?void 0:n,t===n?(N=e,e=n):(r=Cn(),r===n?(N=e,e=n):(P=e,e=j(r))),e===n&&(e=N,P=N,t=Le(),t=t?void 0:n,t===n?(N=e,e=n):(r=wn(),r===n?(N=e,e=n):(P=e,e=Re(r))),e===n&&(e=vn(),e===n&&(e=N,t=bn(),t===n?(N=e,e=n):(r=N,P=N,i=ze(t),i=i?void 0:n,i===n?(N=r,r=n):(a=sn(),a===n?(N=r,r=n):(P=r,r=Be(t,a))),r===n&&(r=null),P=e,e=Ve(t,r)),e===n&&(e=dn()))))))))),e}function on(){let e,t,r;return e=N,t=bn(),t===n?(N=e,e=n):(P=N,r=He(t),r=r?void 0:n,r===n?(N=e,e=n):(P=e,e=Ue(t))),e===n&&(e=N,P=N,t=We(),t=t?void 0:n,t===n?(N=e,e=n):(r=wn(),r===n?(N=e,e=n):(P=e,e=Ge(r)))),e}function sn(){let t,r,i,a,o,s,c,l;if(t=N,r=R(),P=N,i=Ke(r),i=i?void 0:n,i!==n){for(a=N,o=qe(r),s=N,c=[],c.length>=(o|0)?l=n:e.length>N?(l=e.charAt(N),N++):(l=n,I===0&&L(E));l!==n;)c.push(l),c.length>=(o|0)?l=n:e.length>N?(l=e.charAt(N),N++):(l=n,I===0&&L(E));c.length<(o|0)?(N=s,s=n):s=c,o=s,a=o===n?o:e.substring(a,N),a===n?(N=t,t=n):(o=on(),o===n?(N=t,t=n):(P=t,t=Je(r,a,o)))}else N=t,t=n;return t}function R(){let e,t;return e=N,t=``,P=e,t=Ye(),e=t,e}function cn(){let t,r,i,a;if(t=N,r=N,i=[],a=e.charAt(N),s.test(a)?N++:(a=n,I===0&&L(te)),a!==n)for(;a!==n;)i.push(a),a=e.charAt(N),s.test(a)?N++:(a=n,I===0&&L(te));else i=n;return r=i===n?i:e.substring(r,N),r!==n&&(P=t,r=Xe(r)),t=r,t}function ln(){let t,r,i,a,s,c,l,u,d;if(t=N,r=N,i=N,e.substr(N,4)===o?(a=o,N+=4):(a=n,I===0&&L(D)),a!==n){if(e.charCodeAt(N)===62?(s=`>`,N++):(s=n,I===0&&L(ne)),s===n&&(e.substr(N,2)===`->`?(s=`->`,N+=2):(s=n,I===0&&L(O)),s===n)){for(s=N,c=[],l=N,u=N,I++,e.substr(N,3)===`-->`?(d=`-->`,N+=3):(d=n,I===0&&L(re)),I--,d===n?u=void 0:(N=u,u=n),u===n?(N=l,l=n):(e.length>N?(d=e.charAt(N),N++):(d=n,I===0&&L(E)),d===n?(N=l,l=n):(u=[u,d],l=u));l!==n;)c.push(l),l=N,u=N,I++,e.substr(N,3)===`-->`?(d=`-->`,N+=3):(d=n,I===0&&L(re)),I--,d===n?u=void 0:(N=u,u=n),u===n?(N=l,l=n):(e.length>N?(d=e.charAt(N),N++):(d=n,I===0&&L(E)),d===n?(N=l,l=n):(u=[u,d],l=u));e.substr(N,3)===`-->`?(l=`-->`,N+=3):(l=n,I===0&&L(re)),l===n?(N=s,s=n):(c=[c,l],s=c)}s===n?(N=i,i=n):(a=[a,s],i=a)}else N=i,i=n;return r=i===n?i:e.substring(r,N),r!==n&&(P=t,r=Ze(r)),t=r,t}function un(){let t,r,i,a,o;if(t=N,r=N,i=[],e.charCodeAt(N)===92?(a=`\\\\`,N++):(a=n,I===0&&L(ie)),a!==n)for(;a!==n;)i.push(a),e.charCodeAt(N)===92?(a=`\\\\`,N++):(a=n,I===0&&L(ie));else i=n;return r=i===n?i:e.substring(r,N),r===n?(N=t,t=n):(i=N,P=N,a=Qe(r),a=a?void 0:n,a===n?(N=i,i=n):(o=e.charAt(N),c.test(o)?N++:(o=n,I===0&&L(ae)),o===n?(N=i,i=n):(P=i,i=$e(r,o))),i===n&&(i=null),P=t,t=et(r,i)),t}function dn(){let t,r,i,a,o,s;return t=N,e.charCodeAt(N)===123?(r=`{`,N++):(r=n,I===0&&L(oe)),r===n?(N=t,t=n):(i=N,I++,a=N,o=mn(),o===n?(N=a,a=n):(s=e.charAt(N),l.test(s)?N++:(s=n,I===0&&L(se)),s===n?(N=a,a=n):(o=[o,s],a=o)),I--,a===n?i=void 0:(N=i,i=n),i===n?(N=t,t=n):(P=t,t=tt())),t===n&&(t=N,r=N,I++,i=N,P=N,a=nt(),a=a?void 0:n,a===n?(N=i,i=n):(o=wn(),o===n?(N=i,i=n):(a=[a,o],i=a)),I--,i===n?r=void 0:(N=r,r=n),r===n?(N=t,t=n):(e.charCodeAt(N)===60?(i=`<`,N++):(i=n,I===0&&L(ce)),i===n?(N=t,t=n):(P=t,t=rt())),t===n&&(t=N,e.charCodeAt(N)===91?(r=`[`,N++):(r=n,I===0&&L(le)),r!==n&&(P=t,r=it()),t=r)),t}function fn(){let t,r,i,a,o,s,c,l;return t=N,P=N,r=at(),r=r?void 0:n,r===n?(N=t,t=n):(e.substr(N,2)===`[[`?(i=`[[`,N+=2):(i=n,I===0&&L(ue)),i===n?(N=t,t=n):(a=R(),o=mn(),o===n?(N=t,t=n):(s=R(),c=N,l=pn(),c=e.substring(c,N),e.substr(N,2)===`]]`?(l=`]]`,N+=2):(l=n,I===0&&L(de)),l===n?(N=t,t=n):(P=t,t=ot(a,o,s,c))))),t===n&&(t=N,P=N,r=st(),r=r?void 0:n,r===n?(N=t,t=n):(e.substr(N,2)===`[[`?(i=`[[`,N+=2):(i=n,I===0&&L(ue)),i===n?(N=t,t=n):(P=t,t=ct()))),t}function pn(){let t,r,i,a;for(t=[],r=N,i=N,I++,e.substr(N,2)===`]]`?(a=`]]`,N+=2):(a=n,I===0&&L(de)),a===n&&(e.substr(N,2)===`[[`?(a=`[[`,N+=2):(a=n,I===0&&L(ue))),I--,a===n?i=void 0:(N=i,i=n),i===n?(N=r,r=n):(e.length>N?(a=e.charAt(N),N++):(a=n,I===0&&L(E)),a===n?(N=r,r=n):(i=[i,a],r=i));r!==n;)t.push(r),r=N,i=N,I++,e.substr(N,2)===`]]`?(a=`]]`,N+=2):(a=n,I===0&&L(de)),a===n&&(e.substr(N,2)===`[[`?(a=`[[`,N+=2):(a=n,I===0&&L(ue))),I--,a===n?i=void 0:(N=i,i=n),i===n?(N=r,r=n):(e.length>N?(a=e.charAt(N),N++):(a=n,I===0&&L(E)),a===n?(N=r,r=n):(i=[i,a],r=i));return t}function mn(){let t,r,i;if(t=N,r=[],i=gn(),i!==n)for(;i!==n;)r.push(i),i=gn();else r=n;return r===n?(N=t,t=n):(e.charCodeAt(N)===32?(i=` `,N++):(i=n,I===0&&L(fe)),i===n&&(i=null),P=t,t=lt(r)),t===n&&(t=N,r=``,P=t,r=ut(),t=r),t}function hn(){let t,r,i,a,o;if(t=N,r=mn(),r!==n){for(i=R(),a=[],e.length>N?(o=e.charAt(N),N++):(o=n,I===0&&L(E));o!==n;)a.push(o),e.length>N?(o=e.charAt(N),N++):(o=n,I===0&&L(E));P=t,t=dt(r,i)}else N=t,t=n;return t}function gn(){let t,r,i,a,o;if(t=N,r=e.charAt(N),u.test(r)?N++:(r=n,I===0&&L(pe)),r!==n){for(i=N,a=[],o=_n();o!==n;)a.push(o),o=_n();i=e.substring(i,N),P=t,t=ft(r,i)}else N=t,t=n;return t}function _n(){let t,r,i,a,o;if(t=e.charAt(N),d.test(t)?N++:(t=n,I===0&&L(me)),t===n){if(t=N,e.charCodeAt(N)===123?(r=`{`,N++):(r=n,I===0&&L(oe)),r!==n){if(i=e.charAt(N),f.test(i)?N++:(i=n,I===0&&L(he)),i!==n){for(a=[],o=e.charAt(N),p.test(o)?N++:(o=n,I===0&&L(ge));o!==n;)a.push(o),o=e.charAt(N),p.test(o)?N++:(o=n,I===0&&L(ge));e.charCodeAt(N)===125?(o=`}`,N++):(o=n,I===0&&L(k)),o===n?(N=t,t=n):(r=[r,i,a,o],t=r)}else N=t,t=n}else N=t,t=n}return t}function vn(){let t,r,i,a,o,s,c,l,u;if(t=N,e.charCodeAt(N)===123?(r=`{`,N++):(r=n,I===0&&L(oe)),r!==n){if(i=R(),a=mn(),a!==n){if(o=e.charAt(N),f.test(o)?N++:(o=n,I===0&&L(he)),o!==n){for(s=R(),c=N,l=[],u=e.charAt(N),p.test(u)?N++:(u=n,I===0&&L(ge));u!==n;)l.push(u),u=e.charAt(N),p.test(u)?N++:(u=n,I===0&&L(ge));c=e.substring(c,N),e.charCodeAt(N)===125?(l=`}`,N++):(l=n,I===0&&L(k)),l===n?(N=t,t=n):(P=t,t=pt(i,a,o,s,c))}else N=t,t=n}else N=t,t=n}else N=t,t=n;return t===n&&(t=N,e.charCodeAt(N)===123?(r=`{`,N++):(r=n,I===0&&L(oe)),r===n?(N=t,t=n):(i=R(),a=mn(),a===n?(N=t,t=n):(o=R(),s=N,I++,c=e.charAt(N),m.test(c)?N++:(c=n,I===0&&L(_e)),I--,c===n?s=n:(N=s,s=void 0),s===n?(N=t,t=n):(c=yn(),c===n?(N=t,t=n):(e.charCodeAt(N)===125?(l=`}`,N++):(l=n,I===0&&L(k)),l===n?(N=t,t=n):(P=t,t=mt(i,a,o,c)))))),t===n&&(t=N,e.charCodeAt(N)===123?(r=`{`,N++):(r=n,I===0&&L(oe)),r===n?(N=t,t=n):(i=mn(),i===n?(N=t,t=n):(a=N,I++,o=e.charAt(N),m.test(o)?N++:(o=n,I===0&&L(_e)),I--,o===n?a=n:(N=a,a=void 0),a===n?(N=t,t=n):(P=t,t=M()))))),t}function yn(){let t,r,i,a,o,s,c,l;if(t=N,r=R(),P=N,i=ht(r),i=i?void 0:n,i!==n){for(a=N,o=gt(r),s=N,c=[],c.length>=(o|0)?l=n:e.length>N?(l=e.charAt(N),N++):(l=n,I===0&&L(E));l!==n;)c.push(l),c.length>=(o|0)?l=n:e.length>N?(l=e.charAt(N),N++):(l=n,I===0&&L(E));c.length<(o|0)?(N=s,s=n):s=c,o=s,a=o===n?o:e.substring(a,N),a===n?(N=t,t=n):(P=t,t=_t(r,a))}else N=t,t=n;return t}function bn(){let t,r,i,a,o,s,c,l,u,d,f,p,m,h,g;if(t=N,e.charCodeAt(N)===123?(r=`{`,N++):(r=n,I===0&&L(oe)),r!==n){if(i=R(),a=mn(),a!==n){if(o=R(),e.charCodeAt(N)===47?(s=`/`,N++):(s=n,I===0&&L(ve)),s===n&&(s=null),c=xn(),c!==n){if(l=R(),u=N,P=N,d=vt(i,a,o,s,c,l),d=d?void 0:n,d!==n){for(f=N,p=yt(i,a,o,s,c,l),m=N,h=[],h.length>=(p|0)?g=n:e.length>N?(g=e.charAt(N),N++):(g=n,I===0&&L(E));g!==n;)h.push(g),h.length>=(p|0)?g=n:e.length>N?(g=e.charAt(N),N++):(g=n,I===0&&L(E));h.length<(p|0)?(N=m,m=n):m=h,p=m,f=p===n?p:e.substring(f,N),f===n?(N=u,u=n):(e.charCodeAt(N)===125?(p=`}`,N++):(p=n,I===0&&L(k)),p===n?(N=u,u=n):(P=u,u=bt(i,a,o,s,c,l,f)))}else N=u,u=n;u===n&&(u=null),P=t,t=xt(i,a,o,s,c,l,u)}else N=t,t=n}else N=t,t=n}else N=t,t=n;return t===n&&(t=N,e.charCodeAt(N)===123?(r=`{`,N++):(r=n,I===0&&L(oe)),r===n?(N=t,t=n):(i=mn(),i===n?(N=t,t=n):(e.charCodeAt(N)===47?(a=`/`,N++):(a=n,I===0&&L(ve)),a===n?(N=t,t=n):(P=t,t=St(i))))),t}function xn(){let t,r,i,a,o;if(t=N,r=N,i=e.charAt(N),h.test(i)?N++:(i=n,I===0&&L(ye)),i!==n){for(a=[],o=e.charAt(N),g.test(o)?N++:(o=n,I===0&&L(be));o!==n;)a.push(o),o=e.charAt(N),g.test(o)?N++:(o=n,I===0&&L(be));i=[i,a],r=i}else N=r,r=n;return t=r===n?r:e.substring(t,N),t}function Sn(){let t,r,i,a,o,s,c,l;if(t=N,r=N,i=N,e.charCodeAt(N)===60?(a=`<`,N++):(a=n,I===0&&L(ce)),a!==n){if(o=[],s=e.charAt(N),_.test(s)?N++:(s=n,I===0&&L(xe)),s!==n)for(;s!==n;)o.push(s),s=e.charAt(N),_.test(s)?N++:(s=n,I===0&&L(xe));else o=n;if(o!==n){if(e.charCodeAt(N)===64?(s=`@`,N++):(s=n,I===0&&L(Se)),s!==n){if(c=[],l=e.charAt(N),v.test(l)?N++:(l=n,I===0&&L(Ce)),l!==n)for(;l!==n;)c.push(l),l=e.charAt(N),v.test(l)?N++:(l=n,I===0&&L(Ce));else c=n;c===n?(N=i,i=n):(e.charCodeAt(N)===62?(l=`>`,N++):(l=n,I===0&&L(ne)),l===n?(N=i,i=n):(a=[a,o,s,c,l],i=a))}else N=i,i=n}else N=i,i=n}else N=i,i=n;return r=i===n?i:e.substring(r,N),r===n?(N=t,t=n):(P=N,i=Ct(r),i=i?void 0:n,i===n?(N=t,t=n):(P=t,t=wt(r))),t}function Cn(){let t,r,i,a,o,s,c,l;if(t=N,e.charCodeAt(N)===60?(r=`<`,N++):(r=n,I===0&&L(ce)),r!==n){if(i=R(),a=Tn(),a!==n){for(o=[],s=En();s!==n;)o.push(s),s=En();s=kn(),e.charCodeAt(N)===47?(c=`/`,N++):(c=n,I===0&&L(ve)),c===n&&(c=null),e.charCodeAt(N)===62?(l=`>`,N++):(l=n,I===0&&L(ne)),l===n?(N=t,t=n):(P=t,t=Tt(i,a,o,c))}else N=t,t=n}else N=t,t=n;if(t===n){if(t=N,e.charCodeAt(N)===60?(r=`<`,N++):(r=n,I===0&&L(ce)),r!==n){if(i=Tn(),i!==n){if(a=N,I++,o=e.charAt(N),y.test(o)?N++:(o=n,I===0&&L(we)),o===n&&(o=N,I++,e.length>N?(s=e.charAt(N),N++):(s=n,I===0&&L(E)),I--,s===n?o=void 0:(N=o,o=n)),I--,o===n?a=n:(N=a,a=void 0),a!==n){for(o=[],s=En();s!==n;)o.push(s),s=En();s=kn(),c=R(),P=t,t=Et(i,c)}else N=t,t=n}else N=t,t=n}else N=t,t=n}return t}function wn(){let t,r,i,a,o;return t=N,e.substr(N,2)===`</`?(r=`</`,N+=2):(r=n,I===0&&L(Te)),r===n?(N=t,t=n):(i=R(),a=Tn(),a===n?(N=t,t=n):(kn(),e.charCodeAt(N)===62?(o=`>`,N++):(o=n,I===0&&L(ne)),o===n?(N=t,t=n):(P=t,t=Dt(i,a)))),t}function Tn(){let t,r,i,a,o;if(t=N,r=N,i=e.charAt(N),h.test(i)?N++:(i=n,I===0&&L(ye)),i!==n){for(a=[],o=e.charAt(N),b.test(o)?N++:(o=n,I===0&&L(Ee));o!==n;)a.push(o),o=e.charAt(N),b.test(o)?N++:(o=n,I===0&&L(Ee));i=[i,a],r=i}else N=r,r=n;return t=r===n?r:e.substring(t,N),t}function En(){let t,r,i,a,o,s,c,l;if(t=N,kn(),r=R(),i=N,a=[],o=N,s=N,I++,c=e.charAt(N),x.test(c)?N++:(c=n,I===0&&L(De)),I--,c===n?s=void 0:(N=s,s=n),s===n?(N=o,o=n):(e.length>N?(c=e.charAt(N),N++):(c=n,I===0&&L(E)),c===n?(N=o,o=n):(s=[s,c],o=s)),o!==n)for(;o!==n;)a.push(o),o=N,s=N,I++,c=e.charAt(N),x.test(c)?N++:(c=n,I===0&&L(De)),I--,c===n?s=void 0:(N=s,s=n),s===n?(N=o,o=n):(e.length>N?(c=e.charAt(N),N++):(c=n,I===0&&L(E)),c===n?(N=o,o=n):(s=[s,c],o=s));else a=n;return i=a===n?a:e.substring(i,N),i===n?(N=t,t=n):(P=N,a=Ot(r,i),a=a?void 0:n,a===n?(N=t,t=n):(o=N,s=kn(),e.charCodeAt(N)===61?(c=`=`,N++):(c=n,I===0&&L(Oe)),c===n?(N=o,o=n):(kn(),l=Dn(),l===n?(N=o,o=n):(P=o,o=kt(r,i,l))),o===n&&(o=null),P=t,t=At(r,i,o))),t}function Dn(){let t,r,i,a,o,s;if(t=N,e.charCodeAt(N)===34?(r=`\"`,N++):(r=n,I===0&&L(ke)),r!==n){for(i=R(),a=N,o=[],s=On(),s===n&&(s=e.charAt(N),S.test(s)?N++:(s=n,I===0&&L(Ae)));s!==n;)o.push(s),s=On(),s===n&&(s=e.charAt(N),S.test(s)?N++:(s=n,I===0&&L(Ae)));a=e.substring(a,N),o=R(),e.charCodeAt(N)===34?(s=`\"`,N++):(s=n,I===0&&L(ke)),s===n?(N=t,t=n):(P=t,t=jt(i,a,o))}else N=t,t=n;if(t===n){if(t=N,e.charCodeAt(N)===39?(r=`'`,N++):(r=n,I===0&&L(je)),r!==n){for(i=R(),a=N,o=[],s=On(),s===n&&(s=e.charAt(N),C.test(s)?N++:(s=n,I===0&&L(Me)));s!==n;)o.push(s),s=On(),s===n&&(s=e.charAt(N),C.test(s)?N++:(s=n,I===0&&L(Me)));a=e.substring(a,N),o=R(),e.charCodeAt(N)===39?(s=`'`,N++):(s=n,I===0&&L(je)),s===n?(N=t,t=n):(P=t,t=Mt(i,a,o))}else N=t,t=n;if(t===n&&(t=N,r=e.charAt(N),w.test(r)?N++:(r=n,I===0&&L(Ne)),r!==n&&(P=t,r=Nt(r)),t=r,t===n)){for(t=N,r=R(),i=N,a=[],o=e.charAt(N),T.test(o)?N++:(o=n,I===0&&L(Pe));o!==n;)a.push(o),o=e.charAt(N),T.test(o)?N++:(o=n,I===0&&L(Pe));i=e.substring(i,N),a=R(),P=t,t=Pt(r,i,a)}}return t}function On(){let t,r,i,a,o,s,l,u,d,p,m,g,_,v;if(t=N,P=N,r=Ft(),r=r?void 0:n,r!==n){if(i=N,a=[],e.charCodeAt(N)===92?(o=`\\\\`,N++):(o=n,I===0&&L(ie)),o!==n)for(;o!==n;)a.push(o),e.charCodeAt(N)===92?(o=`\\\\`,N++):(o=n,I===0&&L(ie));else a=n;i=a===n?a:e.substring(i,N),i===n?(N=t,t=n):(a=N,P=N,o=It(i),o=o?void 0:n,o===n?(N=a,a=n):(s=e.charAt(N),c.test(s)?N++:(s=n,I===0&&L(ae)),s===n?(N=a,a=n):(o=[o,s],a=o)),a===n&&(a=null),r=[r,i,a],t=r)}else N=t,t=n;if(t===n){if(t=N,P=N,r=Lt(),r=r?void 0:n,r!==n){if(e.charCodeAt(N)===123?(i=`{`,N++):(i=n,I===0&&L(oe)),i!==n){if(a=mn(),a!==n){if(o=R(),e.charCodeAt(N)===47?(s=`/`,N++):(s=n,I===0&&L(ve)),s===n&&(s=null),l=xn(),l!==n){if(u=R(),P=N,d=Rt(o,u),d=d?void 0:n,d!==n){for(p=N,m=zt(o,u),g=N,_=[],_.length>=(m|0)?v=n:e.length>N?(v=e.charAt(N),N++):(v=n,I===0&&L(E));v!==n;)_.push(v),_.length>=(m|0)?v=n:e.length>N?(v=e.charAt(N),N++):(v=n,I===0&&L(E));_.length<(m|0)?(N=g,g=n):g=_,m=g,p=m===n?m:e.substring(p,N),p===n?(N=t,t=n):(e.charCodeAt(N)===125?(m=`}`,N++):(m=n,I===0&&L(k)),m===n?(N=t,t=n):(r=[r,i,a,o,s,l,u,d,p,m],t=r))}else N=t,t=n}else N=t,t=n}else N=t,t=n}else N=t,t=n}else N=t,t=n;t===n&&(t=N,P=N,r=Bt(),r=r?void 0:n,r===n?(N=t,t=n):(e.charCodeAt(N)===123?(i=`{`,N++):(i=n,I===0&&L(oe)),i===n?(N=t,t=n):(a=mn(),a===n?(N=t,t=n):(o=N,I++,s=N,e.charCodeAt(N)===47?(l=`/`,N++):(l=n,I===0&&L(ve)),l===n&&(l=null),u=e.charAt(N),h.test(u)?N++:(u=n,I===0&&L(ye)),u===n?(N=s,s=n):(l=[l,u],s=l),I--,s===n?o=void 0:(N=o,o=n),o===n?(N=t,t=n):(s=yn(),s===n?(N=t,t=n):(e.charCodeAt(N)===125?(l=`}`,N++):(l=n,I===0&&L(k)),l===n?(N=t,t=n):(r=[r,i,a,o,s,l],t=r)))))),t===n&&(t=N,P=N,r=Vt(),r=r?void 0:n,r===n?(N=t,t=n):(e.charCodeAt(N)===123?(i=`{`,N++):(i=n,I===0&&L(oe)),i===n?(N=t,t=n):(a=N,I++,o=e.charAt(N),f.test(o)?N++:(o=n,I===0&&L(he)),I--,o===n?a=n:(N=a,a=void 0),a===n?(N=t,t=n):(o=yn(),o===n?(N=t,t=n):(e.charCodeAt(N)===125?(s=`}`,N++):(s=n,I===0&&L(k)),s===n?(N=t,t=n):(r=[r,i,a,o,s],t=r)))))))}return t}function kn(){let e,t;for(e=[],t=An();t!==n;)e.push(t),t=An();return e}function An(){let t;return t=e.charAt(N),ee.test(t)?N++:(t=n,I===0&&L(A)),t}let jn=t.text===!0,Mn=t.hooks,Nn=-1,Pn=!1,Fn=``;function In(t,n,r){for(let i=0;i<t.length;i++){let a=t.charAt(i);if(a===`\\\\`&&/[{}]/.test(t.charAt(i+1)))i++;else if(a===Wn){let r=/^(?:[.#][\\w-]*)* ?(\\/?[a-zA-Z][\\w-]*|(?=[$_@%(!]))/.exec(t.slice(i+1));if(!r)continue;let a=Mn.closeBrace(e,n+i+1+r[0].length,n+i+1);a!==-1&&a<n+t.length&&(i=a-n)}else if(t.startsWith(r,i))return i}return-1}function Ln(t,n,r){return t===Zn?{}:{selectorsStart:n,selectorsEnd:e.charAt(r-1)===` `?r-1:r}}function Rn(e){return Nn=e,e>=0}function zn(e,t,n){try{qt(e,t)}catch(e){throw e.code=n,e}}function Bn(e){let t={},n=new Set;for(let{name:r,value:i}of e){let e=r.toLowerCase();n.has(e)||(n.add(e),Object.defineProperty(t,r,{value:i,enumerable:!0,writable:!0,configurable:!0}))}return t}Wt=a();let Vn=Wt!==n&&N===e.length;function Hn(){throw Wt!==n&&N<e.length&&L(Qt()),nn(Ut,Ht<e.length?Jt(Ht):null,Ht<e.length?en(Ht,Ht+1):en(Ht,Ht))}if(t.peg$library)return{peg$result:Wt,peg$currPos:N,peg$FAILED:n,peg$maxFailExpected:Ut,peg$maxFailPos:Ht,peg$success:Vn,peg$throw:Vn?void 0:Hn};if(Vn)return Wt;Hn()}var sr=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())}},cr=class{constructor(e=[]){this.names=new sr;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)}clear(){this.names.clear()}},lr=new cr([`if`,`for`,`do`,`button`,`link`,`listbox`,`cycle`,`switch`,`timed`,`repeat`,`type`,`widget`,`span`,`nobr`]),ur=new cr,dr=new Set([`do`]);function fr(e){return dr.has(e)}function pr(e){return lr.has(e)||ur.has(e)}function mr(e){lr.add(e)}function hr(e,t){t?ur.add(e):ur.delete(e)}var gr=new Set([`if`,`switch`,`timed`]),_r=e=>`\"${e.replace(/[\\\\\"]/g,`\\\\$&`)}\"`;function vr(e){return e.map(yr)}function yr({token:e,body:t}){switch(e.type){case`text`:return e.comment?{type:`text`,value:e.value,comment:!0}:{type:`text`,value:e.value};case`link`:return Hn({type:`macro`,name:`link`,rawArgs:`${_r(e.display)} ${_r(e.target)}`,children:[]},e);case`variable`:return Hn({type:`variable`,name:e.name,scope:e.scope},e);case`expression`:return Hn({type:`expression`,expression:e.expression},e);case`html`:return{type:`html`,tag:e.tag,attributes:e.attributes,children:t?vr(t.children):[]};case`macro`:{let n=e.name.toLowerCase(),r={type:`macro`,name:n,rawArgs:e.rawArgs,children:[]};if(!t)return Hn(r,e);let i=vr(t.children);if(!gr.has(n))return r.children=i,Hn(r,e);let a=(e,t)=>Hn({rawArgs:e.rawArgs,children:t},e);return r.branches=[a(e,i),...t.branches.map(({tag:e,children:t})=>a(e,vr(t)))],r}}}function br(e,t){let n=1,r=0;for(let i=e.indexOf(`\n`);i!==-1&&i<t;)n++,r=i+1,i=e.indexOf(`\n`,r);return{line:n,column:t-r+1}}var xr=e=>e[e.length-1],Sr={elseif:`if`,else:`if`,case:`switch`,default:`switch`,next:`timed`},Cr=e=>e.type===`macro`&&!e.isClose&&Object.prototype.hasOwnProperty.call(Sr,e.name.toLowerCase()),wr=e=>Tr(e).toLowerCase(),Tr=e=>e.type===`macro`?e.name:e.tag;function Er(e){return e.type===`html`?`${e.isClose?`</`:`<`}${e.tag}>`:`{${e.isClose?`/`:``}${e.name}}`}var Dr=e=>e.type===`html`?`</${e.tag}>`:`{/${e.name}}`,Or=(e,t)=>e.type===t.type&&wr(e)===wr(t);function kr(e,t={}){let n=t.isBlock??pr,r=t.isRaw??fr,i=[],a=(e[e.length-1]?.end??0)+1,o=e=>{if(t.source===void 0)return`offset ${e}`;let{line:n,column:r}=br(t.source,e);return`line ${n}, column ${r}`},s=(e,t,n,r,a)=>{i.push({code:e,message:n,start:t.start,end:t.end,noticedAt:r,data:a})},c=(e,t,n)=>{let r=Sr[e.name.toLowerCase()],i=t?`, not inside ${Er(t)}`:``;s(`misplaced-branch`,e,`${Er(e)} must be directly inside {${r}}${i}`,n,{name:e.name,parent:r,...t&&{inside:Tr(t)}})},l=[],u=[],d=e=>(xr(u)?.into??l).push(e),f=(e,t,n=e===`closed`)=>{let{node:r,body:i}=u.pop(),l=r.token,f=t?t.end:a;for(let{tag:e}of i.branches){let t=Sr[e.name.toLowerCase()];(l.type!==`macro`||wr(l)!==t)&&c(e,l,f)}e===`unclosed`?s(`unclosed-block`,l,`Unclosed ${Er(l)}: no ${Dr(l)} closes it`,f,{name:Tr(l)}):e===`mismatch`&&s(`mismatched-closer`,t,`${Er(t)} found where ${Dr(l)} should close the ${Er(l)} opened at ${o(l.start)}`,f,{name:Tr(l),closer:Tr(t)}),n&&(i.close=t),r.end=i.close?.end??jr(i)??l.end,d(r)};for(let t=0;t<e.length;t++){let i=e[t];if((i.type===`macro`||i.type===`html`)&&i.isClose){let e=xr(u);if(!e)s(`stray-closer`,i,`${Er(i)} closes nothing: no ${i.type===`html`?`<${i.tag}>`:`{${i.name}}`} is open here`,i.start,{name:Tr(i)});else if(Or(e.node.token,i))f(`closed`,i);else{let e=u.length-1;for(;e>=0&&!Or(u[e].node.token,i);)e--;if(f(`mismatch`,i,e===-1),e!==-1){for(;u.length>e+1;)f(`cut`,i);f(`closed`,i)}}continue}if(Cr(i)){let e=i,t=xr(u);if(!t){c(e,void 0,e.start);continue}let n={tag:e,children:[]};t.body.branches.push(n),t.into=n.children;continue}let a={token:i,start:i.start,end:i.end},o=i.type===`html`?!i.isSelfClose:i.type===`macro`&&n(i.name.toLowerCase());if(o&&i.type===`macro`&&r(i.name.toLowerCase())&&!Ar(i,e[t+1],e[t+2])){s(`unclosed-block`,i,`Unclosed ${Er(i)}: no ${Dr(i)} closes it`,i.end,{name:Tr(i)}),d(a);continue}if(!o){d(a);continue}let l={children:[],branches:[]};a.body=l,u.push({node:a,body:l,into:l.children})}for(;u.length>0;)f(`unclosed`);return{nodes:l,errors:i}}function Ar(e,t,n){let r=t=>t?.type===`macro`&&t.isClose&&Or(e,t);return r(t)||t?.type===`text`&&r(n)}function jr(e){let t=xr(e.branches);return xr(t?.children??e.children)?.end??t?.tag.end}var Mr=[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],Nr=[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],Pr=`‌‍·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄ-׉ؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߽߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛ࢗ-࢟࣊-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯৾ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍୓-ୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఄ఼ా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ೳഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ඁ-ඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ຼ່-໎໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜕ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠏-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᪿ-᫰ᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭᳴᳷-᳹᷀-᷿‌‍‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯・꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧ꠬ꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱ꣿ-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_・`,Fr=`ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆ՘ՙՠ-ֈ֋֌א-תׯ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࡰ-ࢇࢉ-࢏ࢠ-ࣉऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚ౜ౝౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽ೜-ೞೠೡೱೲഄ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄຆ-ຊຌ-ຣລວ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜑᜟ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡸᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭌᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-ᲊᲐ-ᲺᲽ-Ჿᳩ-ᳬᳮ-ᳳᳵᳶᳺᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿ₏-₟ℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆿㇰ-ㇿ㐀-䶿一-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-꟝꟢꟱-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꣾꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭩ꭬꭭ꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ`,Ir={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`},Lr=`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`,Rr={5:Lr,\"5module\":Lr+` export import`,6:Lr+` const class extends export import super`},zr=/^in(stanceof)?$/,Br=RegExp(`[`+Fr+`]`),Vr=RegExp(`[`+Fr+Pr+`]`);function Hr(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 Ur(e,t){return e<65?e===36:e<91?!0:e<97?e===95:e<123?!0:e<=65535?e>=170&&Br.test(String.fromCharCode(e)):t!==!1&&Hr(e,Nr)}function Wr(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&&Vr.test(String.fromCharCode(e)):t===!1?!1:Hr(e,Nr)||Hr(e,Mr)}var z=function(e,t){t===void 0&&(t={}),this.label=e,this.keyword=t.keyword,this.beforeExpr=!!t.beforeExpr,this.startsExpr=!!t.startsExpr,this.isLoop=!!t.isLoop,this.isAssign=!!t.isAssign,this.prefix=!!t.prefix,this.postfix=!!t.postfix,this.binop=t.binop||null,this.updateContext=null};function Gr(e,t){return new z(e,{beforeExpr:!0,binop:t})}var Kr={beforeExpr:!0},qr={startsExpr:!0},Jr={};function B(e,t){return t===void 0&&(t={}),t.keyword=e,Jr[e]=new z(e,t)}var V={num:new z(`num`,qr),regexp:new z(`regexp`,qr),string:new z(`string`,qr),name:new z(`name`,qr),privateId:new z(`privateId`,qr),eof:new z(`eof`),bracketL:new z(`[`,{beforeExpr:!0,startsExpr:!0}),bracketR:new z(`]`),braceL:new z(`{`,{beforeExpr:!0,startsExpr:!0}),braceR:new z(`}`),parenL:new z(`(`,{beforeExpr:!0,startsExpr:!0}),parenR:new z(`)`),comma:new z(`,`,Kr),semi:new z(`;`,Kr),colon:new z(`:`,Kr),dot:new z(`.`),question:new z(`?`,Kr),questionDot:new z(`?.`),arrow:new z(`=>`,Kr),template:new z(`template`),invalidTemplate:new z(`invalidTemplate`),ellipsis:new z(`...`,Kr),backQuote:new z(\"`\",qr),dollarBraceL:new z(\"${\",{beforeExpr:!0,startsExpr:!0}),eq:new z(`=`,{beforeExpr:!0,isAssign:!0}),assign:new z(`_=`,{beforeExpr:!0,isAssign:!0}),incDec:new z(`++/--`,{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new z(`!/~`,{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:Gr(`||`,1),logicalAND:Gr(`&&`,2),bitwiseOR:Gr(`|`,3),bitwiseXOR:Gr(`^`,4),bitwiseAND:Gr(`&`,5),equality:Gr(`==/!=/===/!==`,6),relational:Gr(`</>/<=/>=`,7),bitShift:Gr(`<</>>/>>>`,8),plusMin:new z(`+/-`,{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:Gr(`%`,10),star:Gr(`*`,10),slash:Gr(`/`,10),starstar:new z(`**`,{beforeExpr:!0}),coalesce:Gr(`??`,1),_break:B(`break`),_case:B(`case`,Kr),_catch:B(`catch`),_continue:B(`continue`),_debugger:B(`debugger`),_default:B(`default`,Kr),_do:B(`do`,{isLoop:!0,beforeExpr:!0}),_else:B(`else`,Kr),_finally:B(`finally`),_for:B(`for`,{isLoop:!0}),_function:B(`function`,qr),_if:B(`if`),_return:B(`return`,Kr),_switch:B(`switch`),_throw:B(`throw`,Kr),_try:B(`try`),_var:B(`var`),_const:B(`const`),_while:B(`while`,{isLoop:!0}),_with:B(`with`),_new:B(`new`,{beforeExpr:!0,startsExpr:!0}),_this:B(`this`,qr),_super:B(`super`,qr),_class:B(`class`,qr),_extends:B(`extends`,Kr),_export:B(`export`),_import:B(`import`,qr),_null:B(`null`,qr),_true:B(`true`,qr),_false:B(`false`,qr),_in:B(`in`,{beforeExpr:!0,binop:7}),_instanceof:B(`instanceof`,{beforeExpr:!0,binop:7}),_typeof:B(`typeof`,{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:B(`void`,{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:B(`delete`,{beforeExpr:!0,prefix:!0,startsExpr:!0})},Yr=/\\r\\n?|\\n|\\u2028|\\u2029/,Xr=new RegExp(Yr.source,`g`);function Zr(e){return e===10||e===13||e===8232||e===8233}function Qr(e,t,n){n===void 0&&(n=e.length);for(var r=t;r<n;r++){var i=e.charCodeAt(r);if(Zr(i))return r<n-1&&i===13&&e.charCodeAt(r+1)===10?r+2:r+1}return-1}var $r=/[\\u1680\\u2000-\\u200a\\u202f\\u205f\\u3000\\ufeff]/,ei=/(?:\\s|\\/\\/.*|\\/\\*[^]*?\\*\\/)*/g,ti=Object.prototype,ni=ti.hasOwnProperty,ri=ti.toString,ii=Object.hasOwn||(function(e,t){return ni.call(e,t)}),ai=Array.isArray||(function(e){return ri.call(e)===`[object Array]`}),oi=Object.create(null);function si(e){return oi[e]||(oi[e]=RegExp(`^(?:`+e.replace(/ /g,`|`)+`)$`))}function ci(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}var li=/(?:[\\uD800-\\uDBFF](?![\\uDC00-\\uDFFF])|(?:[^\\uD800-\\uDBFF]|^)[\\uDC00-\\uDFFF])/,ui=function(e,t){this.line=e,this.column=t};ui.prototype.offset=function(e){return new ui(this.line,this.column+e)};var di=function(e,t,n){this.start=t,this.end=n,e.sourceFile!==null&&(this.source=e.sourceFile)};function fi(e,t){for(var n=1,r=0;;){var i=Qr(e,r,t);if(i<0)return new ui(n,t-r);++n,r=i}}var pi={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},mi=!1;function hi(e){var t={};for(var n in pi)t[n]=e&&ii(e,n)?e[n]:pi[n];if(t.ecmaVersion===`latest`?t.ecmaVersion=1e8:t.ecmaVersion==null?(!mi&&typeof console==`object`&&console.warn&&(mi=!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),ai(t.onToken)){var r=t.onToken;t.onToken=function(e){return r.push(e)}}if(ai(t.onComment)&&(t.onComment=gi(t,t.onComment)),t.sourceType===`commonjs`&&t.allowAwaitOutsideFunction)throw Error(`Cannot use allowAwaitOutsideFunction with sourceType: commonjs`);return t}function gi(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 di(this,o,s)),e.ranges&&(c.range=[i,a]),t.push(c)}}var _i=1,vi=2,yi=4,bi=8,xi=16,Si=32,Ci=64,wi=128,Ti=256,Ei=512,Di=1024,Oi=_i|vi|Ti;function ki(e,t){return vi|(e?yi:0)|(t?bi:0)}var Ai=0,ji=1,Mi=2,Ni=3,Pi=4,Fi=5,Ii=function(e,t,n){this.options=e=hi(e),this.sourceFile=e.sourceFile,this.keywords=si(Rr[e.ecmaVersion>=6?6:e.sourceType===`module`?`5module`:5]);var r=``;e.allowReserved!==!0&&(r=Ir[e.ecmaVersion>=6?6:e.ecmaVersion===5?5:3],e.sourceType===`module`&&(r+=` await`)),this.reservedWords=si(r);var i=(r?r+` `:``)+Ir.strict;this.reservedWordsStrict=si(i),this.reservedWordsStrictBind=si(i+` `+Ir.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(Yr).length)):this.lineStart=0,this.type=V.eof,this.value=null,this.start=this.end=this.pos,this.startLoc=this.endLoc=this.curPosition(),this.lastTokEndLoc=this.lastTokStartLoc=null,this.lastTokStart=this.lastTokEnd=this.pos,this.context=this.initialContext(),this.exprAllowed=!0,this.inModule=e.sourceType===`module`,this.strict=this.inModule||e.strict===!0||this.strictDirective(this.pos),this.potentialArrowAt=-1,this.potentialArrowInForAwait=!1,this.yieldPos=this.awaitPos=this.awaitIdentPos=0,this.labels=[],this.undefinedExports=Object.create(null),this.pos===0&&e.allowHashBang&&this.input.slice(0,2)===`#!`&&this.skipLineComment(2),this.scopeStack=[],this.enterScope(this.options.sourceType===`commonjs`?vi:_i),this.regexpState=null,this.privateNameStack=[]},Li={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}};Ii.prototype.parse=function(){var e=this,t=this.options.program||this.startNode();return this.nextToken(),this.catchStackOverflow(function(){return e.parseTopLevel(t)})},Li.inFunction.get=function(){return(this.currentVarScope().flags&vi)>0},Li.inGenerator.get=function(){return(this.currentVarScope().flags&bi)>0},Li.inAsync.get=function(){return(this.currentVarScope().flags&yi)>0},Li.canAwait.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e].flags;if(t&(Ti|Ei))return!1;if(t&vi)return(t&yi)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction},Li.allowReturn.get=function(){return!!(this.inFunction||this.options.allowReturnOutsideFunction&&this.currentVarScope().flags&_i)},Li.allowSuper.get=function(){return(this.currentThisScope().flags&Ci)>0||this.options.allowSuperOutsideMethod},Li.allowDirectSuper.get=function(){return(this.currentThisScope().flags&wi)>0},Li.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())},Li.allowNewDotTarget.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e].flags;if(t&(Ti|Ei)||t&vi&&!(t&xi))return!0}return!1},Li.allowUsing.get=function(){var e=this.currentScope().flags;return!(e&Di||!this.inModule&&e&_i)},Li.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&Ti)>0},Ii.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},Ii.parse=function(e,t){return new this(t,e).parse()},Ii.parseExpressionAt=function(e,t,n){var r=new this(n,e,t);return r.nextToken(),r.parseExpression()},Ii.tokenizer=function(e,t){return new this(t,e)},Object.defineProperties(Ii.prototype,Li);var Ri=Ii.prototype,zi=/^(?:'((?:\\\\[^]|[^'\\\\])*?)'|\"((?:\\\\[^]|[^\"\\\\])*?)\")/;Ri.strictDirective=function(e){if(this.options.ecmaVersion<5)return!1;for(;;){ei.lastIndex=e,e+=ei.exec(this.input)[0].length;var t=zi.exec(this.input.slice(e));if(!t)return!1;if((t[1]||t[2])===`use strict`){ei.lastIndex=e+t[0].length;var n=ei.exec(this.input),r=n.index+n[0].length,i=this.input.charAt(r);return i===`;`||i===`}`||Yr.test(n[0])&&!(/[(`.[+\\-/*%<>=,?^&]/.test(i)||i===`!`&&this.input.charAt(r+1)===`=`||i===`i`&&Bi(this,r))}e+=t[0].length,ei.lastIndex=e,e+=ei.exec(this.input)[0].length,this.input[e]===`;`&&e++}};function Bi(e,t){for(var n=t+1,r=Math.min(e.input.length,t+11);n<r;){var i=e.fullCharCodeAt(n);if(!Wr(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`}Ri.eat=function(e){return this.type===e&&(this.next(),!0)},Ri.isContextual=function(e){return this.type===V.name&&this.value===e&&!this.containsEsc},Ri.eatContextual=function(e){return this.isContextual(e)?(this.next(),!0):!1},Ri.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}},Ri.expectContextual=function(e){this.eatContextual(e)||this.unexpected()},Ri.canInsertSemicolon=function(){return this.type===V.eof||this.type===V.braceR||Yr.test(this.input.slice(this.lastTokEnd,this.start))},Ri.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0},Ri.semicolon=function(){!this.eat(V.semi)&&!this.insertSemicolon()&&this.unexpected()},Ri.afterTrailingComma=function(e,t){if(this.type===e)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),t||this.next(),!0},Ri.expect=function(e){this.eat(e)||this.unexpected()},Ri.unexpected=function(e){this.raise(e??this.start,`Unexpected token`)};var Vi=function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};Ri.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`)}},Ri.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`)},Ri.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`)},Ri.isSimpleAssignTarget=function(e){return e.type===`ParenthesizedExpression`?this.isSimpleAssignTarget(e.expression):e.type===`Identifier`||e.type===`MemberExpression`};var H=Ii.prototype;H.parseTopLevel=function(e){var t=Object.create(null);for(e.body||(e.body=[]);this.type!==V.eof;){var n=this.parseStatement(null,!0,t);e.body.push(n)}if(this.inModule)for(var r=0,i=Object.keys(this.undefinedExports);r<i.length;r+=1){var a=i[r];this.raiseRecoverable(this.undefinedExports[a].start,`Export '`+a+`' is not defined`)}return this.adaptDirectivePrologue(e.body),this.next(),e.sourceType=this.options.sourceType===`commonjs`?`script`:this.options.sourceType,this.finishNode(e,`Program`)};var Hi={kind:`loop`},Ui={kind:`switch`};H.isLet=function(e){if(this.options.ecmaVersion<6||!this.isContextual(`let`))return!1;ei.lastIndex=this.pos;var t=ei.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(Ur(r)){var i=n;do n+=r<=65535?1:2;while(Wr(r=this.fullCharCodeAt(n)));if(r===92)return!0;var a=this.input.slice(i,n);if(!zr.test(a))return!0}return!1},H.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual(`async`))return!1;ei.lastIndex=this.pos;var e=ei.exec(this.input),t=this.pos+e[0].length,n;return!Yr.test(this.input.slice(this.pos,t))&&this.input.slice(t,t+8)===`function`&&(t+8===this.input.length||!(Wr(n=this.fullCharCodeAt(t+8))||n===92))},H.isUsingKeyword=function(e,t){if(this.options.ecmaVersion<17||!this.isContextual(e?`await`:`using`))return!1;ei.lastIndex=this.pos;var n=ei.exec(this.input),r=this.pos+n[0].length;if(Yr.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||Wr(a=this.fullCharCodeAt(i))||a===92)return!1;ei.lastIndex=i;var o=ei.exec(this.input);if(r=i+o[0].length,o&&Yr.test(this.input.slice(i,r)))return!1}var s=this.fullCharCodeAt(r);if(!Ur(s)&&s!==92)return!1;var c=r;do r+=s<=65535?1:2;while(Wr(s=this.fullCharCodeAt(r)));if(s===92)return!0;var l=this.input.slice(c,r);if(zr.test(l))return!1;if(t&&!e&&l===`of`){ei.lastIndex=r;var u=ei.exec(this.input);if(r+=u[0].length,this.input.charCodeAt(r)!==61||(s=this.input.charCodeAt(r+1))===61||s===62)return!1}return!0},H.isAwaitUsing=function(e){return this.isUsingKeyword(!0,e)},H.isUsing=function(e){return this.isUsingKeyword(!1,e)},H.parseStatement=function(e,t,n){var r=this.type,i=this.startNode(),a;switch(this.isLet(e)&&(r=V._var,a=`let`),r){case V._break:case V._continue:return this.parseBreakContinueStatement(i,r.keyword);case V._debugger:return this.parseDebuggerStatement(i);case V._do:return this.parseDoStatement(i);case V._for:return this.parseForStatement(i);case V._function:return e&&(this.strict||e!==`if`&&e!==`label`)&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(i,!1,!e);case V._class:return e&&this.unexpected(),this.parseClass(i,!0);case V._if:return this.parseIfStatement(i);case V._return:return this.parseReturnStatement(i);case V._switch:return this.parseSwitchStatement(i);case V._throw:return this.parseThrowStatement(i);case V._try:return this.parseTryStatement(i);case V._const:case V._var:return a=a||this.value,e&&a!==`var`&&this.unexpected(),this.parseVarStatement(i,a);case V._while:return this.parseWhileStatement(i);case V._with:return this.parseWithStatement(i);case V.braceL:return this.parseBlock(!0,i);case V.semi:return this.parseEmptyStatement(i);case V._export:case V._import:if(this.options.ecmaVersion>10&&r===V._import){ei.lastIndex=this.pos;var o=ei.exec(this.input),s=this.pos+o[0].length,c=this.input.charCodeAt(s);if(c===40||c===46)return this.parseExpressionStatement(i,this.parseExpression())}return this.options.allowImportExportEverywhere||(t||this.raise(this.start,`'import' and 'export' may only appear at the top level`),this.inModule||this.raise(this.start,`'import' and 'export' may appear only with 'sourceType: module'`)),r===V._import?this.parseImport(i):this.parseExport(i,n);default:if(this.isAsyncFunction())return e&&this.unexpected(),this.next(),this.parseFunctionStatement(i,!0,!e);var l=this.isAwaitUsing(!1)?`await using`:this.isUsing(!1)?`using`:null;if(l)return this.allowUsing||this.raise(this.start,\"Using declaration cannot appear in the top level when source type is `script` or in the bare case statement\"),e&&this.raise(this.start,`Using declaration is not allowed in single-statement positions`),l===`await using`&&(this.canAwait||this.raise(this.start,`Await using cannot appear outside of async function`),this.next()),this.next(),this.parseVar(i,!1,l),this.semicolon(),this.finishNode(i,`VariableDeclaration`);var u=this.value,d=this.parseExpression();return r===V.name&&d.type===`Identifier`&&this.eat(V.colon)?this.parseLabeledStatement(i,u,d,e):this.parseExpressionStatement(i,d)}},H.parseBreakContinueStatement=function(e,t){var n=t===`break`;this.next(),this.eat(V.semi)||this.insertSemicolon()?e.label=null:this.type===V.name?(e.label=this.parseIdent(),this.semicolon()):this.unexpected();for(var r=0;r<this.labels.length;++r){var i=this.labels[r];if((e.label==null||i.name===e.label.name)&&(i.kind!=null&&(n||i.kind===`loop`)||e.label&&n))break}return r===this.labels.length&&this.raise(e.start,`Unsyntactic `+t),this.finishNode(e,n?`BreakStatement`:`ContinueStatement`)},H.parseDebuggerStatement=function(e){return this.next(),this.semicolon(),this.finishNode(e,`DebuggerStatement`)},H.parseDoStatement=function(e){return this.next(),this.labels.push(Hi),e.body=this.parseStatement(`do`),this.labels.pop(),this.expect(V._while),e.test=this.parseParenExpression(),this.options.ecmaVersion>=6?this.eat(V.semi):this.semicolon(),this.finishNode(e,`DoWhileStatement`)},H.parseForStatement=function(e){this.next();var t=this.options.ecmaVersion>=9&&this.canAwait&&this.eatContextual(`await`)?this.lastTokStart:-1;if(this.labels.push(Hi),this.enterScope(0),this.expect(V.parenL),this.type===V.semi)return t>-1&&this.unexpected(t),this.parseFor(e,null);var n=this.isLet();if(this.type===V._var||this.type===V._const||n){var r=this.startNode(),i=n?`let`:this.value;return this.next(),this.parseVar(r,!0,i),this.finishNode(r,`VariableDeclaration`),this.parseForAfterInit(e,r,t)}var a=this.isContextual(`let`),o=!1,s=this.isUsing(!0)?`using`:this.isAwaitUsing(!0)?`await using`:null;if(s){var c=this.startNode();return this.next(),s===`await using`&&(this.canAwait||this.raise(this.start,`Await using cannot appear outside of async function`),this.next()),this.parseVar(c,!0,s),this.finishNode(c,`VariableDeclaration`),this.parseForAfterInit(e,c,t)}var l=this.containsEsc,u=new Vi,d=this.start,f=t>-1?this.parseExprSubscripts(u,`await`):this.parseExpression(!0,u);return this.type===V._in||(o=this.options.ecmaVersion>=6&&this.isContextual(`of`))?(t>-1?(this.type===V._in&&this.unexpected(t),e.await=!0):o&&this.options.ecmaVersion>=8&&(f.start===d&&!l&&f.type===`Identifier`&&f.name===`async`?this.unexpected():this.options.ecmaVersion>=9&&(e.await=!1)),a&&o&&this.raise(f.start,`The left-hand side of a for-of loop may not start with 'let'.`),this.toAssignable(f,!1,u),this.checkLValPattern(f),this.parseForIn(e,f)):(this.checkExpressionErrors(u,!0),t>-1&&this.unexpected(t),this.parseFor(e,f))},H.parseForAfterInit=function(e,t,n){return(this.type===V._in||this.options.ecmaVersion>=6&&this.isContextual(`of`))&&t.declarations.length===1?(this.type===V._in?((t.kind===`using`||t.kind===`await using`)&&!t.declarations[0].init&&this.raise(this.start,`Using declaration is not allowed in for-in loops`),this.options.ecmaVersion>=9&&n>-1&&this.unexpected(n)):this.options.ecmaVersion>=9&&(e.await=n>-1),this.parseForIn(e,t)):(n>-1&&this.unexpected(n),this.parseFor(e,t))},H.parseFunctionStatement=function(e,t,n){return this.next(),this.parseFunction(e,Gi|(n?0:Ki),!1,t)},H.parseIfStatement=function(e){return this.next(),e.test=this.parseParenExpression(),e.consequent=this.parseStatement(`if`),e.alternate=this.eat(V._else)?this.parseStatement(`if`):null,this.finishNode(e,`IfStatement`)},H.parseReturnStatement=function(e){return this.allowReturn||this.raise(this.start,`'return' outside of function`),this.next(),this.eat(V.semi)||this.insertSemicolon()?e.argument=null:(e.argument=this.parseExpression(),this.semicolon()),this.finishNode(e,`ReturnStatement`)},H.parseSwitchStatement=function(e){this.next(),e.discriminant=this.parseParenExpression(),e.cases=[],this.expect(V.braceL),this.labels.push(Ui),this.enterScope(Di);for(var t,n=!1;this.type!==V.braceR;)if(this.type===V._case||this.type===V._default){var r=this.type===V._case;t&&this.finishNode(t,`SwitchCase`),e.cases.push(t=this.startNode()),t.consequent=[],this.next(),r?t.test=this.parseExpression():(n&&this.raiseRecoverable(this.lastTokStart,`Multiple default clauses`),n=!0,t.test=null),this.expect(V.colon)}else t||this.unexpected(),t.consequent.push(this.parseStatement(null));return this.exitScope(),t&&this.finishNode(t,`SwitchCase`),this.next(),this.labels.pop(),this.finishNode(e,`SwitchStatement`)},H.parseThrowStatement=function(e){return this.next(),Yr.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 Wi=[];H.parseCatchClauseParam=function(){var e=this.parseBindingAtom(),t=e.type===`Identifier`;return this.enterScope(t?Si:0),this.checkLValPattern(e,t?Pi:Mi),this.expect(V.parenR),e},H.parseTryStatement=function(e){if(this.next(),e.block=this.parseBlock(),e.handler=null,this.type===V._catch){var t=this.startNode();this.next(),this.eat(V.parenL)?t.param=this.parseCatchClauseParam():(this.options.ecmaVersion<10&&this.unexpected(),t.param=null,this.enterScope(0)),t.body=this.parseBlock(!1),this.exitScope(),e.handler=this.finishNode(t,`CatchClause`)}return e.finalizer=this.eat(V._finally)?this.parseBlock():null,!e.handler&&!e.finalizer&&this.raise(e.start,`Missing catch or finally clause`),this.finishNode(e,`TryStatement`)},H.parseVarStatement=function(e,t,n){return this.next(),this.parseVar(e,!1,t,n),this.semicolon(),this.finishNode(e,`VariableDeclaration`)},H.parseWhileStatement=function(e){return this.next(),e.test=this.parseParenExpression(),this.labels.push(Hi),e.body=this.parseStatement(`while`),this.labels.pop(),this.finishNode(e,`WhileStatement`)},H.parseWithStatement=function(e){return this.strict&&this.raise(this.start,`'with' in strict mode`),this.next(),e.object=this.parseParenExpression(),e.body=this.parseStatement(`with`),this.finishNode(e,`WithStatement`)},H.parseEmptyStatement=function(e){return this.next(),this.finishNode(e,`EmptyStatement`)},H.parseLabeledStatement=function(e,t,n,r){for(var i=0,a=this.labels;i<a.length;i+=1)a[i].name===t&&this.raise(n.start,`Label '`+t+`' is already declared`);for(var o=this.type.isLoop?`loop`:this.type===V._switch?`switch`:null,s=this.labels.length-1;s>=0;s--){var c=this.labels[s];if(c.statementStart===e.start)c.statementStart=this.start,c.kind=o;else break}return this.labels.push({name:t,kind:o,statementStart:this.start}),e.body=this.parseStatement(r?r.indexOf(`label`)===-1?r+`label`:r:`label`),this.labels.pop(),e.label=n,this.finishNode(e,`LabeledStatement`)},H.parseExpressionStatement=function(e,t){return e.expression=t,this.semicolon(),this.finishNode(e,`ExpressionStatement`)},H.parseBlock=function(e,t,n){for(e===void 0&&(e=!0),t===void 0&&(t=this.startNode()),t.body=[],this.expect(V.braceL),e&&this.enterScope(0);this.type!==V.braceR;){var r=this.parseStatement(null);t.body.push(r)}return n&&(this.strict=!1),this.next(),e&&this.exitScope(),this.finishNode(t,`BlockStatement`)},H.parseFor=function(e,t){return e.init=t,this.expect(V.semi),e.test=this.type===V.semi?null:this.parseExpression(),this.expect(V.semi),e.update=this.type===V.parenR?null:this.parseExpression(),this.expect(V.parenR),e.body=this.parseStatement(`for`),this.exitScope(),this.labels.pop(),this.finishNode(e,`ForStatement`)},H.parseForIn=function(e,t){var n=this.type===V._in;return this.next(),t.type===`VariableDeclaration`&&t.declarations[0].init!=null&&(!n||this.options.ecmaVersion<8||this.strict||t.kind!==`var`||t.declarations[0].id.type!==`Identifier`)&&this.raise(t.start,(n?`for-in`:`for-of`)+` loop variable declaration may not have an initializer`),e.left=t,e.right=n?this.parseExpression():this.parseMaybeAssign(),this.expect(V.parenR),e.body=this.parseStatement(`for`),this.exitScope(),this.labels.pop(),this.finishNode(e,n?`ForInStatement`:`ForOfStatement`)},H.parseVar=function(e,t,n,r){for(e.declarations=[],e.kind=n;;){var i=this.startNode();if(this.parseVarId(i,n),this.eat(V.eq)?i.init=this.parseMaybeAssign(t):!r&&n===`const`&&!(this.type===V._in||this.options.ecmaVersion>=6&&this.isContextual(`of`))?this.unexpected():!r&&(n===`using`||n===`await using`)&&this.options.ecmaVersion>=17&&this.type!==V._in&&!this.isContextual(`of`)?this.raise(this.lastTokEnd,`Missing initializer in `+n+` declaration`):!r&&i.id.type!==`Identifier`&&(!t||this.type!==V._in&&!this.isContextual(`of`))?this.raise(this.lastTokEnd,`Complex binding patterns require an initialization value`):i.init=null,e.declarations.push(this.finishNode(i,`VariableDeclarator`)),!this.eat(V.comma))break}return e},H.parseVarId=function(e,t){e.id=t===`using`||t===`await using`?this.parseIdent():this.parseBindingAtom(),this.checkLValPattern(e.id,t===`var`?ji:Mi,!1)};var Gi=1,Ki=2,qi=4;H.parseFunction=function(e,t,n,r,i){this.initFunction(e),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!r)&&(this.type===V.star&&t&Ki&&this.unexpected(),e.generator=this.eat(V.star)),this.options.ecmaVersion>=8&&(e.async=!!r),t&Gi&&(e.id=t&qi&&this.type!==V.name?null:this.parseIdent(),e.id&&!(t&Ki)&&this.checkLValSimple(e.id,this.strict||e.generator||e.async?this.treatFunctionsAsVar?ji:Mi:Ni));var a=this.yieldPos,o=this.awaitPos,s=this.awaitIdentPos;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(ki(e.async,e.generator)),t&Gi||(e.id=this.type===V.name?this.parseIdent():null),this.parseFunctionParams(e),this.parseFunctionBody(e,n,!1,i),this.yieldPos=a,this.awaitPos=o,this.awaitIdentPos=s,this.finishNode(e,t&Gi?`FunctionDeclaration`:`FunctionExpression`)},H.parseFunctionParams=function(e){this.expect(V.parenL),e.params=this.parseBindingList(V.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()},H.parseClass=function(e,t){this.next();var n=this.strict;this.strict=!0,this.parseClassId(e,t),this.parseClassSuper(e);var r=this.enterClassBody(),i=this.startNode(),a=!1;for(i.body=[],this.expect(V.braceL);this.type!==V.braceR;){var o=this.parseClassElement(e.superClass!==null);o&&(i.body.push(o),o.type===`MethodDefinition`&&o.kind===`constructor`?(a&&this.raiseRecoverable(o.start,`Duplicate constructor in the same class`),a=!0):o.key&&o.key.type===`PrivateIdentifier`&&Ji(r,o)&&this.raiseRecoverable(o.key.start,`Identifier '#`+o.key.name+`' has already been declared`))}return this.strict=n,this.next(),e.body=this.finishNode(i,`ClassBody`),this.exitClassBody(),this.finishNode(e,t?`ClassDeclaration`:`ClassExpression`)},H.parseClassElement=function(e){if(this.eat(V.semi))return null;var t=this.options.ecmaVersion,n=this.startNode(),r=``,i=!1,a=!1,o=`method`,s=!1;if(this.eatContextual(`static`)){if(t>=13&&this.eat(V.braceL))return this.parseClassStaticBlock(n),n;this.isClassElementNameStart()||this.type===V.star?s=!0:r=`static`}if(n.static=s,!r&&t>=8&&this.eatContextual(`async`)&&((this.isClassElementNameStart()||this.type===V.star)&&!this.canInsertSemicolon()?a=!0:r=`async`),!r&&(t>=9||!a)&&this.eat(V.star)&&(i=!0),!r&&!a&&!i){var c=this.value;(this.eatContextual(`get`)||this.eatContextual(`set`))&&(this.isClassElementNameStart()?o=c:r=c)}if(r?(n.computed=!1,n.key=this.startNodeAt(this.lastTokStart,this.lastTokStartLoc),n.key.name=r,this.finishNode(n.key,`Identifier`)):this.parseClassElementName(n),t<13||this.type===V.parenL||o!==`method`||i||a){var l=!n.static&&Yi(n,`constructor`),u=l&&e;l&&o!==`method`&&this.raise(n.key.start,`Constructor can't have get/set modifier`),n.kind=l?`constructor`:o,this.parseClassMethod(n,i,a,u)}else this.parseClassField(n);return n},H.isClassElementNameStart=function(){return this.type===V.name||this.type===V.privateId||this.type===V.num||this.type===V.string||this.type===V.bracketL||this.type.keyword},H.parseClassElementName=function(e){this.type===V.privateId?(this.value===`constructor`&&this.raise(this.start,`Classes can't have an element named '#constructor'`),e.computed=!1,e.key=this.parsePrivateIdent()):this.parsePropertyName(e)},H.parseClassMethod=function(e,t,n,r){var i=e.key;e.kind===`constructor`?(t&&this.raise(i.start,`Constructor can't be a generator`),n&&this.raise(i.start,`Constructor can't be an async method`)):e.static&&Yi(e,`prototype`)&&this.raise(i.start,`Classes may not have a static property named prototype`);var a=e.value=this.parseMethod(t,n,r);return e.kind===`get`&&a.params.length!==0&&this.raiseRecoverable(a.start,`getter should have no params`),e.kind===`set`&&a.params.length!==1&&this.raiseRecoverable(a.start,`setter should have exactly one param`),e.kind===`set`&&a.params[0].type===`RestElement`&&this.raiseRecoverable(a.params[0].start,`Setter cannot use rest params`),this.finishNode(e,`MethodDefinition`)},H.parseClassField=function(e){return Yi(e,`constructor`)?this.raise(e.key.start,`Classes can't have a field named 'constructor'`):e.static&&Yi(e,`prototype`)&&this.raise(e.key.start,`Classes can't have a static field named 'prototype'`),this.eat(V.eq)?(this.enterScope(Ei|Ci),e.value=this.parseMaybeAssign(),this.exitScope()):e.value=null,this.semicolon(),this.finishNode(e,`PropertyDefinition`)},H.parseClassStaticBlock=function(e){e.body=[];var t=this.labels;for(this.labels=[],this.enterScope(Ti|Ci);this.type!==V.braceR;){var n=this.parseStatement(null);e.body.push(n)}return this.next(),this.exitScope(),this.labels=t,this.finishNode(e,`StaticBlock`)},H.parseClassId=function(e,t){this.type===V.name?(e.id=this.parseIdent(),t&&this.checkLValSimple(e.id,Mi,!1)):(t===!0&&this.unexpected(),e.id=null)},H.parseClassSuper=function(e){e.superClass=this.eat(V._extends)?this.parseExprSubscripts(null,!1):null},H.enterClassBody=function(){var e={declared:Object.create(null),used:[]};return this.privateNameStack.push(e),e.declared},H.exitClassBody=function(){var e=this.privateNameStack.pop(),t=e.declared,n=e.used;if(this.options.checkPrivateFields)for(var r=this.privateNameStack.length,i=r===0?null:this.privateNameStack[r-1],a=0;a<n.length;++a){var o=n[a];ii(t,o.name)||(i?i.used.push(o):this.raiseRecoverable(o.start,`Private field '#`+o.name+`' must be declared in an enclosing class`))}};function Ji(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 Yi(e,t){var n=e.computed,r=e.key;return!n&&(r.type===`Identifier`&&r.name===t||r.type===`Literal`&&r.value===t)}H.parseExportAllDeclaration=function(e,t){return this.options.ecmaVersion>=11&&(this.eatContextual(`as`)?(e.exported=this.parseModuleExportName(),this.checkExport(t,e.exported,this.lastTokStart)):e.exported=null),this.expectContextual(`from`),this.type!==V.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,`ExportAllDeclaration`)},H.parseExport=function(e,t){if(this.next(),this.eat(V.star))return this.parseExportAllDeclaration(e,t);if(this.eat(V._default))return this.checkExport(t,`default`,this.lastTokStart),e.declaration=this.parseExportDefaultDeclaration(),this.finishNode(e,`ExportDefaultDeclaration`);if(this.shouldParseExportStatement())e.declaration=this.parseExportDeclaration(e),e.declaration.type===`VariableDeclaration`?this.checkVariableExport(t,e.declaration.declarations):this.checkExport(t,e.declaration.id,e.declaration.id.start),e.specifiers=[],e.source=null,this.options.ecmaVersion>=16&&(e.attributes=[]);else{if(e.declaration=null,e.specifiers=this.parseExportSpecifiers(t),this.eatContextual(`from`))this.type!==V.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause());else{for(var n=0,r=e.specifiers;n<r.length;n+=1){var i=r[n];this.checkUnreserved(i.local),this.checkLocalExport(i.local),i.local.type===`Literal`&&this.raise(i.local.start,\"A string literal cannot be used as an exported binding without `from`.\")}e.source=null,this.options.ecmaVersion>=16&&(e.attributes=[])}this.semicolon()}return this.finishNode(e,`ExportNamedDeclaration`)},H.parseExportDeclaration=function(e){return this.parseStatement(null)},H.parseExportDefaultDeclaration=function(){var e;if(this.type===V._function||(e=this.isAsyncFunction())){var t=this.startNode();return this.next(),e&&this.next(),this.parseFunction(t,Gi|qi,!1,e)}if(this.type===V._class){var n=this.startNode();return this.parseClass(n,`nullableID`)}var r=this.parseMaybeAssign();return this.semicolon(),r},H.checkExport=function(e,t,n){e&&(typeof t!=`string`&&(t=t.type===`Identifier`?t.name:t.value),ii(e,t)&&this.raiseRecoverable(n,`Duplicate export '`+t+`'`),e[t]=!0)},H.checkPatternExport=function(e,t){var n=t.type;if(n===`Identifier`)this.checkExport(e,t,t.start);else if(n===`ObjectPattern`)for(var r=0,i=t.properties;r<i.length;r+=1){var a=i[r];this.checkPatternExport(e,a)}else if(n===`ArrayPattern`)for(var o=0,s=t.elements;o<s.length;o+=1){var c=s[o];c&&this.checkPatternExport(e,c)}else n===`Property`?this.checkPatternExport(e,t.value):n===`AssignmentPattern`?this.checkPatternExport(e,t.left):n===`RestElement`&&this.checkPatternExport(e,t.argument)},H.checkVariableExport=function(e,t){if(e)for(var n=0,r=t;n<r.length;n+=1){var i=r[n];this.checkPatternExport(e,i.id)}},H.shouldParseExportStatement=function(){return this.type.keyword===`var`||this.type.keyword===`const`||this.type.keyword===`class`||this.type.keyword===`function`||this.isLet()||this.isAsyncFunction()},H.parseExportSpecifier=function(e){var t=this.startNode();return t.local=this.parseModuleExportName(),t.exported=this.eatContextual(`as`)?this.parseModuleExportName():t.local,this.checkExport(e,t.exported,t.exported.start),this.finishNode(t,`ExportSpecifier`)},H.parseExportSpecifiers=function(e){var t=[],n=!0;for(this.expect(V.braceL);!this.eat(V.braceR);){if(n)n=!1;else if(this.expect(V.comma),this.afterTrailingComma(V.braceR))break;t.push(this.parseExportSpecifier(e))}return t},H.parseImport=function(e){return this.next(),this.type===V.string?(e.specifiers=Wi,e.source=this.parseExprAtom()):(e.specifiers=this.parseImportSpecifiers(),this.expectContextual(`from`),e.source=this.type===V.string?this.parseExprAtom():this.unexpected()),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,`ImportDeclaration`)},H.parseImportSpecifier=function(){var e=this.startNode();return e.imported=this.parseModuleExportName(),this.eatContextual(`as`)?e.local=this.parseIdent():(this.checkUnreserved(e.imported),e.local=e.imported),this.checkLValSimple(e.local,Mi),this.finishNode(e,`ImportSpecifier`)},H.parseImportDefaultSpecifier=function(){var e=this.startNode();return e.local=this.parseIdent(),this.checkLValSimple(e.local,Mi),this.finishNode(e,`ImportDefaultSpecifier`)},H.parseImportNamespaceSpecifier=function(){var e=this.startNode();return this.next(),this.expectContextual(`as`),e.local=this.parseIdent(),this.checkLValSimple(e.local,Mi),this.finishNode(e,`ImportNamespaceSpecifier`)},H.parseImportSpecifiers=function(){var e=[],t=!0;if(this.type===V.name&&(e.push(this.parseImportDefaultSpecifier()),!this.eat(V.comma)))return e;if(this.type===V.star)return e.push(this.parseImportNamespaceSpecifier()),e;for(this.expect(V.braceL);!this.eat(V.braceR);){if(t)t=!1;else if(this.expect(V.comma),this.afterTrailingComma(V.braceR))break;e.push(this.parseImportSpecifier())}return e},H.parseWithClause=function(){var e=[];if(!this.eat(V._with))return e;this.expect(V.braceL);for(var t={},n=!0;!this.eat(V.braceR);){if(n)n=!1;else if(this.expect(V.comma),this.afterTrailingComma(V.braceR))break;var r=this.parseImportAttribute(),i=r.key.type===`Identifier`?r.key.name:r.key.value;ii(t,i)&&this.raiseRecoverable(r.key.start,`Duplicate attribute key '`+i+`'`),t[i]=!0,e.push(r)}return e},H.parseImportAttribute=function(){var e=this.startNode();return e.key=this.type===V.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!==`never`),this.expect(V.colon),this.type!==V.string&&this.unexpected(),e.value=this.parseExprAtom(),this.finishNode(e,`ImportAttribute`)},H.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===V.string){var e=this.parseLiteral(this.value);return li.test(e.value)&&this.raise(e.start,`An export name cannot include a lone surrogate.`),e}return this.parseIdent(!0)},H.adaptDirectivePrologue=function(e){for(var t=0;t<e.length&&this.isDirectiveCandidate(e[t]);++t)e[t].directive=e[t].expression.raw.slice(1,-1)},H.isDirectiveCandidate=function(e){return this.options.ecmaVersion>=5&&e.type===`ExpressionStatement`&&e.expression.type===`Literal`&&typeof e.expression.value==`string`&&(this.input[e.start]===`\"`||this.input[e.start]===`'`)};var Xi=Ii.prototype;Xi.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},Xi.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},Xi.parseSpread=function(e){var t=this.startNode();return this.next(),t.argument=this.parseMaybeAssign(!1,e),this.finishNode(t,`SpreadElement`)},Xi.parseRestBinding=function(){var e=this.startNode();return this.next(),this.options.ecmaVersion===6&&this.type!==V.name&&this.unexpected(),e.argument=this.parseBindingAtom(),this.finishNode(e,`RestElement`)},Xi.parseBindingAtom=function(){if(this.options.ecmaVersion>=6)switch(this.type){case V.bracketL:var e=this.startNode();return this.next(),e.elements=this.parseBindingList(V.bracketR,!0,!0),this.finishNode(e,`ArrayPattern`);case V.braceL:return this.parseObj(!0)}return this.parseIdent()},Xi.parseBindingList=function(e,t,n,r){for(var i=[],a=!0;!this.eat(e);)if(a?a=!1:this.expect(V.comma),t&&this.type===V.comma)i.push(null);else if(n&&this.afterTrailingComma(e))break;else if(this.type===V.ellipsis){var o=this.parseRestBinding();this.parseBindingListItem(o),i.push(o),this.type===V.comma&&this.raiseRecoverable(this.start,`Comma is not permitted after the rest element`),this.expect(e);break}else i.push(this.parseAssignableListItem(r));return i},Xi.parseAssignableListItem=function(e){var t=this.parseMaybeDefault(this.start,this.startLoc);return this.parseBindingListItem(t),t},Xi.parseBindingListItem=function(e){return e},Xi.parseMaybeDefault=function(e,t,n){if(n=n||this.parseBindingAtom(),this.options.ecmaVersion<6||!this.eat(V.eq))return n;var r=this.startNodeAt(e,t);return r.left=n,r.right=this.parseMaybeAssign(),this.finishNode(r,`AssignmentPattern`)},Xi.checkLValSimple=function(e,t,n){t===void 0&&(t=Ai);var r=t!==Ai;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===Mi&&e.name===`let`&&this.raiseRecoverable(e.start,`let is disallowed as a lexically bound name`),n&&(ii(n,e.name)&&this.raiseRecoverable(e.start,`Argument name clash`),n[e.name]=!0),t!==Fi&&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`)}},Xi.checkLValPattern=function(e,t,n){switch(t===void 0&&(t=Ai),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)}},Xi.checkLValInnerPattern=function(e,t,n){switch(t===void 0&&(t=Ai),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 Zi=function(e,t,n,r,i){this.token=e,this.isExpr=!!t,this.preserveSpace=!!n,this.override=r,this.generator=!!i},Qi={b_stat:new Zi(`{`,!1),b_expr:new Zi(`{`,!0),b_tmpl:new Zi(\"${\",!1),p_stat:new Zi(`(`,!1),p_expr:new Zi(`(`,!0),q_tmpl:new Zi(\"`\",!0,!0,function(e){return e.tryReadTemplateToken()}),f_stat:new Zi(`function`,!1),f_expr:new Zi(`function`,!0),f_expr_gen:new Zi(`function`,!0,!1,null,!0),f_gen:new Zi(`function`,!1,!1,null,!0)},$i=Ii.prototype;$i.initialContext=function(){return[Qi.b_stat]},$i.curContext=function(){return this.context[this.context.length-1]},$i.braceIsBlock=function(e){var t=this.curContext();return t===Qi.f_expr||t===Qi.f_stat?!0:e===V.colon&&(t===Qi.b_stat||t===Qi.b_expr)?!t.isExpr:e===V._return||e===V.name&&this.exprAllowed?Yr.test(this.input.slice(this.lastTokEnd,this.start)):e===V._else||e===V.semi||e===V.eof||e===V.parenR||e===V.arrow?!0:e===V.braceL?t===Qi.b_stat:e===V._var||e===V._const||e===V.name?!1:!this.exprAllowed},$i.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},$i.updateContext=function(e){var t,n=this.type;n.keyword&&e===V.dot?this.exprAllowed=!1:(t=n.updateContext)?t.call(this,e):this.exprAllowed=n.beforeExpr},$i.overrideContext=function(e){this.curContext()!==e&&(this.context[this.context.length-1]=e)},V.parenR.updateContext=V.braceR.updateContext=function(){if(this.context.length===1)this.exprAllowed=!0;else{var e=this.context.pop();e===Qi.b_stat&&this.curContext().token===`function`&&(e=this.context.pop()),this.exprAllowed=!e.isExpr}},V.braceL.updateContext=function(e){this.context.push(this.braceIsBlock(e)?Qi.b_stat:Qi.b_expr),this.exprAllowed=!0},V.dollarBraceL.updateContext=function(){this.context.push(Qi.b_tmpl),this.exprAllowed=!0},V.parenL.updateContext=function(e){var t=e===V._if||e===V._for||e===V._with||e===V._while;this.context.push(t?Qi.p_stat:Qi.p_expr),this.exprAllowed=!0},V.incDec.updateContext=function(){},V._function.updateContext=V._class.updateContext=function(e){e.beforeExpr&&e!==V._else&&(e!==V.semi||this.curContext()===Qi.p_stat)&&!(e===V._return&&Yr.test(this.input.slice(this.lastTokEnd,this.start)))&&(e!==V.colon&&e!==V.braceL||this.curContext()!==Qi.b_stat)?this.context.push(Qi.f_expr):this.context.push(Qi.f_stat),this.exprAllowed=!1},V.colon.updateContext=function(){this.curContext().token===`function`&&this.context.pop(),this.exprAllowed=!0},V.backQuote.updateContext=function(){this.curContext()===Qi.q_tmpl?this.context.pop():this.context.push(Qi.q_tmpl),this.exprAllowed=!1},V.star.updateContext=function(e){if(e===V._function){var t=this.context.length-1;this.context[t]===Qi.f_expr?this.context[t]=Qi.f_expr_gen:this.context[t]=Qi.f_gen}this.exprAllowed=!0},V.name.updateContext=function(e){var t=!1;this.options.ecmaVersion>=6&&e!==V.dot&&(this.value===`of`&&!this.exprAllowed||this.value===`yield`&&this.inGeneratorContext())&&(t=!0),this.exprAllowed=t};var U=Ii.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);else{i=`$`+i;var o=t[i];o?(a===`init`?this.strict&&o.init||o.get||o.set:o.init||o[a])&&this.raiseRecoverable(r.start,`Redefinition of property`):o=t[i]={init:!1,get:!1,set:!1},o[a]=!0}}},U.parseExpression=function(e,t){var n=this;return this.catchStackOverflow(function(){var r=n.start,i=n.startLoc,a=n.parseMaybeAssign(e,t);if(n.type===V.comma){var o=n.startNodeAt(r,i);for(o.expressions=[a];n.eat(V.comma);)o.expressions.push(n.parseMaybeAssign(e,t));return n.finishNode(o,`SequenceExpression`)}return a})},U.parseMaybeAssign=function(e,t,n){if(this.isContextual(`yield`)){if(this.inGenerator)return this.parseYield(e);this.exprAllowed=!1}var r=!1,i=-1,a=-1,o=-1;t?(i=t.parenthesizedAssign,a=t.trailingComma,o=t.doubleProto,t.parenthesizedAssign=t.trailingComma=-1):(t=new Vi,r=!0);var s=this.start,c=this.startLoc;(this.type===V.parenL||this.type===V.name)&&(this.potentialArrowAt=this.start,this.potentialArrowInForAwait=e===`await`);var l=this.parseMaybeConditional(e,t);if(n&&(l=n.call(this,l,s,c)),this.type.isAssign){var u=this.startNodeAt(s,c);return u.operator=this.value,this.type===V.eq&&(l=this.toAssignable(l,!1,t)),r||(t.parenthesizedAssign=t.trailingComma=-1,t.shorthandAssign>=l.start&&(t.shorthandAssign=-1),t.doubleProto>=l.start&&(t.doubleProto=-1)),this.type===V.eq?this.checkLValPattern(l):this.checkLValSimple(l),u.left=l,this.next(),u.right=this.parseMaybeAssign(e),o>-1&&(t.doubleProto=o),this.finishNode(u,`AssignmentExpression`)}return r&&this.checkExpressionErrors(t,!0),i>-1&&(t.parenthesizedAssign=i),a>-1&&(t.trailingComma=a),l},U.parseMaybeConditional=function(e,t){var n=this.start,r=this.startLoc,i=this.parseExprOps(e,t);if(this.checkExpressionErrors(t))return i;if((i.type!==`ArrowFunctionExpression`||i.start!==n)&&this.eat(V.question)){var a=this.startNodeAt(n,r);return a.test=i,a.consequent=this.parseMaybeAssign(),this.expect(V.colon),a.alternate=this.parseMaybeAssign(e),this.finishNode(a,`ConditionalExpression`)}return i},U.parseExprOps=function(e,t){var n=this.start,r=this.startLoc,i=this.parseMaybeUnary(t,!1,!1,e);return this.checkExpressionErrors(t)||i.start===n&&i.type===`ArrowFunctionExpression`?i:this.parseExprOp(i,n,r,-1,e)},U.parseExprOp=function(e,t,n,r,i){var a=this.type.binop;if(a!=null&&(!i||this.type!==V._in)&&a>r){var o=this.type===V.logicalOR||this.type===V.logicalAND,s=this.type===V.coalesce;s&&(a=V.logicalAND.binop);var c=this.value;this.next();var l=this.start,u=this.startLoc,d=this.parseExprOp(this.parseMaybeUnary(null,!1,!1,i),l,u,a,i),f=this.buildBinary(t,n,e,d,c,o||s);return(o&&this.type===V.coalesce||s&&(this.type===V.logicalOR||this.type===V.logicalAND))&&this.raiseRecoverable(this.start,`Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses`),this.parseExprOp(f,t,n,r,i)}return e},U.buildBinary=function(e,t,n,r,i,a){r.type===`PrivateIdentifier`&&this.raise(r.start,`Private identifier can only be left side of binary expression`);var o=this.startNodeAt(e,t);return o.left=n,o.operator=i,o.right=r,this.finishNode(o,a?`LogicalExpression`:`BinaryExpression`)},U.parseMaybeUnary=function(e,t,n,r){var i=this.start,a=this.startLoc,o;if(this.isContextual(`await`)&&this.canAwait)o=this.parseAwait(r),t=!0;else if(this.type.prefix){var s=this.startNode(),c=this.type===V.incDec;s.operator=this.value,s.prefix=!0,this.next(),s.argument=this.parseMaybeUnary(null,!0,c,r),this.checkExpressionErrors(e,!0),c?this.checkLValSimple(s.argument):this.strict&&s.operator===`delete`&&ea(s.argument)?this.raiseRecoverable(s.start,`Deleting local variable in strict mode`):s.operator===`delete`&&ta(s.argument)?this.raiseRecoverable(s.start,`Private fields can not be deleted`):t=!0,o=this.finishNode(s,c?`UpdateExpression`:`UnaryExpression`)}else if(!t&&this.type===V.privateId)(r||this.privateNameStack.length===0)&&this.options.checkPrivateFields&&this.unexpected(),o=this.parsePrivateIdent(),this.type!==V._in&&this.unexpected();else{if(o=this.parseExprSubscripts(e,r),this.checkExpressionErrors(e))return o;for(;this.type.postfix&&!this.canInsertSemicolon();){var l=this.startNodeAt(i,a);l.operator=this.value,l.prefix=!1,l.argument=o,this.checkLValSimple(o),this.next(),o=this.finishNode(l,`UpdateExpression`)}}if(!n&&(o.type!==`ArrowFunctionExpression`||o.start!==i)&&this.eat(V.starstar)){if(t)this.unexpected(this.lastTokStart);else return this.buildBinary(i,a,o,this.parseMaybeUnary(null,!1,!1,r),`**`,!1)}else return o};function ea(e){return e.type===`Identifier`||e.type===`ParenthesizedExpression`&&ea(e.expression)}function ta(e){return e.type===`MemberExpression`&&e.property.type===`PrivateIdentifier`||e.type===`ChainExpression`&&ta(e.expression)||e.type===`ParenthesizedExpression`&&ta(e.expression)}U.parseExprSubscripts=function(e,t){var n=this.start,r=this.startLoc,i=-1,a=-1;e&&(i=e.doubleProto,a=e.shorthandAssign,e.doubleProto=e.shorthandAssign=-1);var o=this.parseExprAtom(e,t);if(o.type===`ArrowFunctionExpression`&&this.input.slice(this.lastTokStart,this.lastTokEnd)!==`)`)return o;var s=this.parseSubscripts(o,n,r,!1,t);return e&&(s.end>o.end&&(this.checkExpressionErrors(e,!0),e.parenthesizedAssign>=s.start&&(e.parenthesizedAssign=-1),e.parenthesizedBind>=s.start&&(e.parenthesizedBind=-1),e.trailingComma>=s.start&&(e.trailingComma=-1)),i>-1&&(e.doubleProto=i),a>-1&&(e.shorthandAssign=a)),s},U.parseSubscripts=function(e,t,n,r,i){for(var a=this.options.ecmaVersion>=8&&e.type===`Identifier`&&e.name===`async`&&this.lastTokEnd===e.end&&!this.canInsertSemicolon()&&e.end-e.start===5&&this.potentialArrowAt===e.start,o=!1;;){var s=this.parseSubscript(e,t,n,r,a,o,i);if(s.optional&&(o=!0),s.end===e.end||s.type===`ArrowFunctionExpression`){if(o){var c=this.startNodeAt(t,n);c.expression=s,s=this.finishNode(c,`ChainExpression`)}return s}e=s,a=!1}},U.shouldParseAsyncArrow=function(){return!this.canInsertSemicolon()&&this.eat(V.arrow)},U.parseSubscriptAsyncArrow=function(e,t,n,r){return this.parseArrowExpression(this.startNodeAt(e,t),n,!0,r)},U.parseSubscript=function(e,t,n,r,i,a,o){var s=this.options.ecmaVersion>=11,c=s&&this.eat(V.questionDot);r&&c&&this.raise(this.lastTokStart,`Optional chaining cannot appear in the callee of new expressions`);var l=this.eat(V.bracketL);if(l||c&&this.type!==V.parenL&&this.type!==V.backQuote||this.eat(V.dot)){var u=this.startNodeAt(t,n);u.object=e,l?(u.property=this.parseExpression(),this.expect(V.bracketR)):u.property=this.type===V.privateId&&e.type!==`Super`?this.parsePrivateIdent():this.parseIdent(this.options.allowReserved!==`never`),u.computed=!!l,s&&(u.optional=c),e=this.finishNode(u,`MemberExpression`)}else if(!r&&this.eat(V.parenL)){var d=new Vi,f=this.yieldPos,p=this.awaitPos,m=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var h=this.parseExprList(V.parenR,this.options.ecmaVersion>=8,!1,d);if(i&&!c&&this.shouldParseAsyncArrow())return this.checkPatternErrors(d,!1),this.checkYieldAwaitInDefaultParams(),this.awaitIdentPos>0&&this.raise(this.awaitIdentPos,`Cannot use 'await' as identifier inside an async function`),this.yieldPos=f,this.awaitPos=p,this.awaitIdentPos=m,this.parseSubscriptAsyncArrow(t,n,h,o);this.checkExpressionErrors(d,!0),this.yieldPos=f||this.yieldPos,this.awaitPos=p||this.awaitPos,this.awaitIdentPos=m||this.awaitIdentPos;var g=this.startNodeAt(t,n);g.callee=e,g.arguments=h,s&&(g.optional=c),e=this.finishNode(g,`CallExpression`)}else if(this.type===V.backQuote){(c||a)&&this.raise(this.start,`Optional chaining cannot appear in the tag of tagged template expressions`);var _=this.startNodeAt(t,n);_.tag=e,_.quasi=this.parseTemplate({isTagged:!0}),e=this.finishNode(_,`TaggedTemplateExpression`)}return e},U.parseExprAtom=function(e,t,n){this.type===V.slash&&this.readRegexp();var r,i=this.potentialArrowAt===this.start;switch(this.type){case V._super:return this.allowSuper||this.raise(this.start,`'super' keyword outside a method`),r=this.startNode(),this.next(),this.type===V.parenL&&!this.allowDirectSuper&&this.raise(r.start,`super() call outside constructor of a subclass`),this.type!==V.dot&&this.type!==V.bracketL&&this.type!==V.parenL&&this.unexpected(),this.finishNode(r,`Super`);case V._this:return r=this.startNode(),this.next(),this.finishNode(r,`ThisExpression`);case V.name:var a=this.start,o=this.startLoc,s=this.containsEsc,c=this.parseIdent(!1);if(this.options.ecmaVersion>=8&&!s&&c.name===`async`&&!this.canInsertSemicolon()&&this.eat(V._function))return this.overrideContext(Qi.f_expr),this.parseFunction(this.startNodeAt(a,o),0,!1,!0,t);if(i&&!this.canInsertSemicolon()){if(this.eat(V.arrow))return this.parseArrowExpression(this.startNodeAt(a,o),[c],!1,t);if(this.options.ecmaVersion>=8&&c.name===`async`&&this.type===V.name&&!s&&(!this.potentialArrowInForAwait||this.value!==`of`||this.containsEsc))return c=this.parseIdent(!1),(this.canInsertSemicolon()||!this.eat(V.arrow))&&this.unexpected(),this.parseArrowExpression(this.startNodeAt(a,o),[c],!0,t)}return c;case V.regexp:var l=this.value;return r=this.parseLiteral(l.value),r.regex={pattern:l.pattern,flags:l.flags},r;case V.num:case V.string:return this.parseLiteral(this.value);case V._null:case V._true:case V._false:return r=this.startNode(),r.value=this.type===V._null?null:this.type===V._true,r.raw=this.type.keyword,this.next(),this.finishNode(r,`Literal`);case V.parenL:var u=this.start,d=this.parseParenAndDistinguishExpression(i,t);return e&&(e.parenthesizedAssign<0&&!this.isSimpleAssignTarget(d)&&(e.parenthesizedAssign=u),e.parenthesizedBind<0&&(e.parenthesizedBind=u)),d;case V.bracketL:return r=this.startNode(),this.next(),r.elements=this.parseExprList(V.bracketR,!0,!0,e),this.finishNode(r,`ArrayExpression`);case V.braceL:return this.overrideContext(Qi.b_expr),this.parseObj(!1,e);case V._function:return r=this.startNode(),this.next(),this.parseFunction(r,0);case V._class:return this.parseClass(this.startNode(),!1);case V._new:return this.parseNew();case V.backQuote:return this.parseTemplate();case V._import:return this.options.ecmaVersion>=11?this.parseExprImport(n):this.unexpected();default:return this.parseExprAtomDefault()}},U.parseExprAtomDefault=function(){this.unexpected()},U.parseExprImport=function(e){var t=this.startNode();if(this.containsEsc&&this.raiseRecoverable(this.start,`Escape sequence in keyword import`),this.next(),this.type===V.parenL&&!e)return this.parseDynamicImport(t);if(this.type===V.dot){var n=this.startNodeAt(t.start,t.loc&&t.loc.start);return n.name=`import`,t.meta=this.finishNode(n,`Identifier`),this.parseImportMeta(t)}this.unexpected()},U.parseDynamicImport=function(e){if(this.next(),e.source=this.parseMaybeAssign(),this.options.ecmaVersion>=16)this.eat(V.parenR)?e.options=null:(this.expect(V.comma),this.afterTrailingComma(V.parenR)?e.options=null:(e.options=this.parseMaybeAssign(),this.eat(V.parenR)||(this.expect(V.comma),this.afterTrailingComma(V.parenR)||this.unexpected())));else if(!this.eat(V.parenR)){var t=this.start;this.eat(V.comma)&&this.eat(V.parenR)?this.raiseRecoverable(t,`Trailing comma is not allowed in import()`):this.unexpected(t)}return this.finishNode(e,`ImportExpression`)},U.parseImportMeta=function(e){this.next();var t=this.containsEsc;return e.property=this.parseIdent(!0),e.property.name!==`meta`&&this.raiseRecoverable(e.property.start,`The only valid meta property for import is 'import.meta'`),t&&this.raiseRecoverable(e.start,`'import.meta' must not contain escaped characters`),this.options.sourceType!==`module`&&!this.options.allowImportExportEverywhere&&this.raiseRecoverable(e.start,`Cannot use 'import.meta' outside a module`),this.finishNode(e,`MetaProperty`)},U.parseLiteral=function(e){var t=this.startNode();return t.value=e,t.raw=this.input.slice(this.start,this.end),t.raw.charCodeAt(t.raw.length-1)===110&&(t.bigint=t.value==null?t.raw.slice(0,-1).replace(/_/g,``):t.value.toString()),this.next(),this.finishNode(t,`Literal`)},U.parseParenExpression=function(){this.expect(V.parenL);var e=this.parseExpression();return this.expect(V.parenR),e},U.shouldParseArrow=function(e){return!this.canInsertSemicolon()},U.parseParenAndDistinguishExpression=function(e,t){var n=this.start,r=this.startLoc,i,a=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var o=this.start,s=this.startLoc,c=[],l=!0,u=!1,d=new Vi,f=this.yieldPos,p=this.awaitPos,m;for(this.yieldPos=0,this.awaitPos=0;this.type!==V.parenR;){if(l?l=!1:this.expect(V.comma),a&&this.afterTrailingComma(V.parenR,!0)){u=!0;break}if(this.type===V.ellipsis){m=this.start,c.push(this.parseParenItem(this.parseRestBinding())),this.type===V.comma&&this.raiseRecoverable(this.start,`Comma is not permitted after the rest element`);break}c.push(this.parseMaybeAssign(!1,d,this.parseParenItem))}var h=this.lastTokEnd,g=this.lastTokEndLoc;if(this.expect(V.parenR),e&&this.shouldParseArrow(c)&&this.eat(V.arrow))return this.checkPatternErrors(d,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=f,this.awaitPos=p,this.parseParenArrowList(n,r,c,t);(!c.length||u)&&this.unexpected(this.lastTokStart),m&&this.unexpected(m),this.checkExpressionErrors(d,!0),this.yieldPos=f||this.yieldPos,this.awaitPos=p||this.awaitPos,c.length>1?(i=this.startNodeAt(o,s),i.expressions=c,this.finishNodeAt(i,`SequenceExpression`,h,g)):i=c[0]}else i=this.parseParenExpression();if(this.options.preserveParens){var _=this.startNodeAt(n,r);return _.expression=i,this.finishNode(_,`ParenthesizedExpression`)}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 na=[];U.parseNew=function(){this.containsEsc&&this.raiseRecoverable(this.start,`Escape sequence in keyword new`);var e=this.startNode();if(this.next(),this.options.ecmaVersion>=6&&this.type===V.dot){var t=this.startNodeAt(e.start,e.loc&&e.loc.start);t.name=`new`,e.meta=this.finishNode(t,`Identifier`),this.next();var n=this.containsEsc;return e.property=this.parseIdent(!0),e.property.name!==`target`&&this.raiseRecoverable(e.property.start,`The only valid meta property for new is 'new.target'`),n&&this.raiseRecoverable(e.start,`'new.target' must not contain escaped characters`),this.allowNewDotTarget||this.raiseRecoverable(e.start,`'new.target' can only be used in functions and class static block`),this.finishNode(e,`MetaProperty`)}var r=this.start,i=this.startLoc;return e.callee=this.parseSubscripts(this.parseExprAtom(null,!1,!0),r,i,!0,!1),e.callee.type===`Super`&&this.raiseRecoverable(r,`Invalid use of 'super'`),e.arguments=this.eat(V.parenL)?this.parseExprList(V.parenR,this.options.ecmaVersion>=8,!1):na,this.finishNode(e,`NewExpression`)},U.parseTemplateElement=function(e){var t=e.isTagged,n=this.startNode();return this.type===V.invalidTemplate?(t||this.raiseRecoverable(this.start,`Bad escape sequence in untagged template literal`),n.value={raw:this.value.replace(/\\r\\n?/g,`\n`),cooked:null}):n.value={raw:this.input.slice(this.start,this.end).replace(/\\r\\n?/g,`\n`),cooked:this.value},this.next(),n.tail=this.type===V.backQuote,this.finishNode(n,`TemplateElement`)},U.parseTemplate=function(e){e===void 0&&(e={});var t=e.isTagged;t===void 0&&(t=!1);var n=this.startNode();this.next(),n.expressions=[];var r=this.parseTemplateElement({isTagged:t});for(n.quasis=[r];!r.tail;)this.type===V.eof&&this.raise(this.pos,`Unterminated template literal`),this.expect(V.dollarBraceL),n.expressions.push(this.parseExpression()),this.expect(V.braceR),n.quasis.push(r=this.parseTemplateElement({isTagged:t}));return this.next(),this.finishNode(n,`TemplateLiteral`)},U.isAsyncProp=function(e){return!e.computed&&e.key.type===`Identifier`&&e.key.name===`async`&&(this.type===V.name||this.type===V.num||this.type===V.string||this.type===V.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===V.star)&&!Yr.test(this.input.slice(this.lastTokEnd,this.start))},U.parseObj=function(e,t){var n=this.startNode(),r=!0,i={};for(n.properties=[],this.next();!this.eat(V.braceR);){if(r)r=!1;else if(this.expect(V.comma),this.options.ecmaVersion>=5&&this.afterTrailingComma(V.braceR))break;var a=this.parseProperty(e,t);e||this.checkPropClash(a,i,t),n.properties.push(a)}return this.finishNode(n,e?`ObjectPattern`:`ObjectExpression`)},U.parseProperty=function(e,t){var n=this.startNode(),r,i,a,o;if(this.options.ecmaVersion>=9&&this.eat(V.ellipsis))return e?(n.argument=this.parseIdent(!1),this.type===V.comma&&this.raiseRecoverable(this.start,`Comma is not permitted after the rest element`),this.finishNode(n,`RestElement`)):(n.argument=this.parseMaybeAssign(!1,t),this.type===V.comma&&t&&t.trailingComma<0&&(t.trailingComma=this.start),this.finishNode(n,`SpreadElement`));this.options.ecmaVersion>=6&&(n.method=!1,n.shorthand=!1,(e||t)&&(a=this.start,o=this.startLoc),e||(r=this.eat(V.star)));var s=this.containsEsc;return this.parsePropertyName(n),!e&&!s&&this.options.ecmaVersion>=8&&!r&&this.isAsyncProp(n)?(i=!0,r=this.options.ecmaVersion>=9&&this.eat(V.star),this.parsePropertyName(n)):i=!1,this.parsePropertyValue(n,e,r,i,a,o,t,s),this.finishNode(n,`Property`)},U.parseGetterSetter=function(e){var t=e.key.name;this.parsePropertyName(e),e.value=this.parseMethod(!1),e.kind=t;var n=e.kind===`get`?0:1;if(e.value.params.length!==n){var r=e.value.start;e.kind===`get`?this.raiseRecoverable(r,`getter should have no params`):this.raiseRecoverable(r,`setter should have exactly one param`)}else e.kind===`set`&&e.value.params[0].type===`RestElement`&&this.raiseRecoverable(e.value.params[0].start,`Setter cannot use rest params`)},U.parsePropertyValue=function(e,t,n,r,i,a,o,s){(n||r)&&this.type===V.colon&&this.unexpected(),this.eat(V.colon)?(e.value=t?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,o),e.kind=`init`):this.options.ecmaVersion>=6&&this.type===V.parenL?(t&&this.unexpected(),e.method=!0,e.value=this.parseMethod(n,r),e.kind=`init`):!t&&!s&&this.options.ecmaVersion>=5&&!e.computed&&e.key.type===`Identifier`&&(e.key.name===`get`||e.key.name===`set`)&&this.type!==V.comma&&this.type!==V.braceR&&this.type!==V.eq?((n||r)&&this.unexpected(),this.parseGetterSetter(e)):this.options.ecmaVersion>=6&&!e.computed&&e.key.type===`Identifier`?((n||r)&&this.unexpected(),this.checkUnreserved(e.key),e.key.name===`await`&&!this.awaitIdentPos&&(this.awaitIdentPos=i),t?e.value=this.parseMaybeDefault(i,a,this.copyNode(e.key)):this.type===V.eq&&o?(o.shorthandAssign<0&&(o.shorthandAssign=this.start),e.value=this.parseMaybeDefault(i,a,this.copyNode(e.key))):e.value=this.copyNode(e.key),e.kind=`init`,e.shorthand=!0):this.unexpected()},U.parsePropertyName=function(e){if(this.options.ecmaVersion>=6){if(this.eat(V.bracketL))return e.computed=!0,e.key=this.parseMaybeAssign(),this.expect(V.bracketR),e.key;e.computed=!1}return e.key=this.type===V.num||this.type===V.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!==`never`)},U.initFunction=function(e){e.id=null,this.options.ecmaVersion>=6&&(e.generator=e.expression=!1),this.options.ecmaVersion>=8&&(e.async=!1)},U.parseMethod=function(e,t,n){var r=this.startNode(),i=this.yieldPos,a=this.awaitPos,o=this.awaitIdentPos;return this.initFunction(r),this.options.ecmaVersion>=6&&(r.generator=e),this.options.ecmaVersion>=8&&(r.async=!!t),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(ki(t,r.generator)|Ci|(n?wi:0)),this.expect(V.parenL),r.params=this.parseBindingList(V.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(r,!1,!0,!1),this.yieldPos=i,this.awaitPos=a,this.awaitIdentPos=o,this.finishNode(r,`FunctionExpression`)},U.parseArrowExpression=function(e,t,n,r){var i=this.yieldPos,a=this.awaitPos,o=this.awaitIdentPos;return this.enterScope(ki(n,!1)|xi),this.initFunction(e),this.options.ecmaVersion>=8&&(e.async=!!n),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,e.params=this.toAssignableList(t,!0),this.parseFunctionBody(e,!0,!1,r),this.yieldPos=i,this.awaitPos=a,this.awaitIdentPos=o,this.finishNode(e,`ArrowFunctionExpression`)},U.parseFunctionBody=function(e,t,n,r){var i=t&&this.type!==V.braceL,a=this.strict,o=!1;if(i)e.body=this.parseMaybeAssign(r),e.expression=!0,this.checkParams(e,!1);else{var s=this.options.ecmaVersion>=7&&!this.isSimpleParamList(e.params);(!a||s)&&(o=this.strictDirective(this.end),o&&s&&this.raiseRecoverable(e.start,`Illegal 'use strict' directive in function with non-simple parameter list`));var c=this.labels;this.labels=[],o&&(this.strict=!0),this.checkParams(e,!a&&!o&&!t&&!n&&this.isSimpleParamList(e.params)),this.strict&&e.id&&this.checkLValSimple(e.id,Fi),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,ji,t?null:n)}},U.parseExprList=function(e,t,n,r){for(var i=[],a=!0;!this.eat(e);){if(a)a=!1;else if(this.expect(V.comma),t&&this.afterTrailingComma(e))break;var o=void 0;n&&this.type===V.comma?o=null:this.type===V.ellipsis?(o=this.parseSpread(r),r&&this.type===V.comma&&r.trailingComma<0&&(r.trailingComma=this.start)):o=this.parseMaybeAssign(!1,r),i.push(o)}return i},U.checkUnreserved=function(e){var t=e.start,n=e.end,r=e.name;this.inGenerator&&r===`yield`&&this.raiseRecoverable(t,`Cannot use 'yield' as identifier inside a generator`),this.inAsync&&r===`await`&&this.raiseRecoverable(t,`Cannot use 'await' as identifier inside an async function`),!(this.currentThisScope().flags&Oi)&&r===`arguments`&&this.raiseRecoverable(t,`Cannot use 'arguments' in class field initializer`),this.inClassStaticBlock&&(r===`arguments`||r===`await`)&&this.raise(t,`Cannot use `+r+` in class static initialization block`),this.keywords.test(r)&&this.raise(t,`Unexpected keyword '`+r+`'`),!(this.options.ecmaVersion<6&&this.input.slice(t,n).indexOf(`\\\\`)!==-1)&&(this.strict?this.reservedWordsStrict:this.reservedWords).test(r)&&(!this.inAsync&&r===`await`&&this.raiseRecoverable(t,`Cannot use keyword 'await' outside an async function`),this.raiseRecoverable(t,`The keyword '`+r+`' is reserved`))},U.parseIdent=function(e){var t=this.parseIdentNode();return this.next(!!e),this.finishNode(t,`Identifier`),e||(this.checkUnreserved(t),t.name===`await`&&!this.awaitIdentPos&&(this.awaitIdentPos=t.start)),t},U.parseIdentNode=function(){var e=this.startNode();return this.type===V.name?e.name=this.value:this.type.keyword?(e.name=this.type.keyword,(e.name===`class`||e.name===`function`)&&(this.lastTokEnd!==this.lastTokStart+1||this.input.charCodeAt(this.lastTokStart)!==46)&&this.context.pop(),this.type=V.name):this.unexpected(),e},U.parsePrivateIdent=function(){var e=this.startNode();return this.type===V.privateId?e.name=this.value:this.unexpected(),this.next(),this.finishNode(e,`PrivateIdentifier`),this.options.checkPrivateFields&&(this.privateNameStack.length===0?this.raise(e.start,`Private field '#`+e.name+`' must be declared in an enclosing class`):this.privateNameStack[this.privateNameStack.length-1].used.push(e)),e},U.parseYield=function(e){this.yieldPos||(this.yieldPos=this.start);var t=this.startNode();return this.next(),this.type===V.semi||this.canInsertSemicolon()||this.type!==V.star&&!this.type.startsExpr?(t.delegate=!1,t.argument=null):(t.delegate=this.eat(V.star),t.argument=this.parseMaybeAssign(e)),this.finishNode(t,`YieldExpression`)},U.parseAwait=function(e){this.awaitPos||(this.awaitPos=this.start);var t=this.startNode();return this.next(),t.argument=this.parseMaybeUnary(null,!0,!1,e),this.finishNode(t,`AwaitExpression`)};var ra=Ii.prototype;ra.raise=function(e,t){var n=fi(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},ra.raiseRecoverable=ra.raise,ra.curPosition=function(){if(this.options.locations)return new ui(this.curLine,this.pos-this.lineStart)};var ia=Ii.prototype,aa=function(e){this.flags=e,this.var=[],this.lexical=[],this.functions=[]};ia.enterScope=function(e){this.scopeStack.push(new aa(e))},ia.exitScope=function(){this.scopeStack.pop()},ia.treatFunctionsAsVarInScope=function(e){return e.flags&vi||!this.inModule&&e.flags&_i},ia.declareName=function(e,t,n){var r=!1;if(t===Mi){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&_i&&delete this.undefinedExports[e]}else if(t===Pi)this.currentScope().lexical.push(e);else if(t===Ni){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&Si&&s.lexical[0]===e)||!this.treatFunctionsAsVarInScope(s)&&s.functions.indexOf(e)>-1){r=!0;break}if(s.var.push(e),this.inModule&&s.flags&_i&&delete this.undefinedExports[e],s.flags&Oi)break}r&&this.raiseRecoverable(n,`Identifier '`+e+`' has already been declared`)},ia.checkLocalExport=function(e){this.scopeStack[0].lexical.indexOf(e.name)===-1&&this.scopeStack[0].var.indexOf(e.name)===-1&&(this.undefinedExports[e.name]=e)},ia.currentScope=function(){return this.scopeStack[this.scopeStack.length-1]},ia.currentVarScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&(Oi|Ei|Ti))return t}},ia.currentThisScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&(Oi|Ei|Ti)&&!(t.flags&xi))return t}};var oa=function(e,t,n){this.type=``,this.start=t,this.end=0,e.options.locations&&(this.loc=new di(e,n)),e.options.directSourceFile&&(this.sourceFile=e.options.directSourceFile),e.options.ranges&&(this.range=[t,0])},sa=Ii.prototype;sa.startNode=function(){return new oa(this,this.start,this.startLoc)},sa.startNodeAt=function(e,t){return new oa(this,e,t)};function ca(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}sa.finishNode=function(e,t){return ca.call(this,e,t,this.lastTokEnd,this.lastTokEndLoc)},sa.finishNodeAt=function(e,t,n,r){return ca.call(this,e,t,n,r)},sa.copyNode=function(e){var t=new oa(this,e.start,this.startLoc);for(var n in e)t[n]=e[n];return t};var la=`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`,ua=`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`,da=ua+` Extended_Pictographic`,fa=da,pa=fa+` EBase EComp EMod EPres ExtPict`,ma=pa,ha={9:ua,10:da,11:fa,12:pa,13:ma,14:ma},ga={9:``,10:``,11:``,12:``,13:``,14:`Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji`},_a=`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`,va=`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`,ya=va+` Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd`,ba=ya+` Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho`,xa=ba+` Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi`,Sa=xa+` Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith`,Ca={9:va,10:ya,11:ba,12:xa,13:Sa,14:Sa+` `+la},wa={};function Ta(e){var t=wa[e]={binary:si(ha[e]+` `+_a),binaryOfStrings:si(ga[e]),nonBinary:{General_Category:si(_a),Script:si(Ca[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 Ea=0,Da=[9,10,11,12,13,14];Ea<Da.length;Ea+=1){var Oa=Da[Ea];Ta(Oa)}var W=Ii.prototype,ka=function(e,t){this.parent=e,this.base=t||this};ka.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},ka.prototype.sibling=function(){return new ka(this.parent,this.base)};var Aa=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=wa[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};Aa.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)},Aa.prototype.raise=function(e){this.parser.raiseRecoverable(this.start,`Invalid regular expression: /`+this.source+`/: `+e)},Aa.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},Aa.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},Aa.prototype.current=function(e){return e===void 0&&(e=!1),this.at(this.pos,e)},Aa.prototype.lookahead=function(e){return e===void 0&&(e=!1),this.at(this.nextIndex(this.pos,e),e)},Aa.prototype.advance=function(e){e===void 0&&(e=!1),this.pos=this.nextIndex(this.pos,e)},Aa.prototype.eat=function(e,t){return t===void 0&&(t=!1),this.current(t)===e&&(this.advance(t),!0)},Aa.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 ja(e){for(var t in e)return!0;return!1}W.validateRegExpPattern=function(e){this.regexp_pattern(e),!e.switchN&&this.options.ecmaVersion>=9&&ja(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 ka(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&&Ma(n);)t+=ci(n),e.advance();return t};function Ma(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 Na(t)?(e.lastIntValue=t,e.advance(),!0):!1};function Na(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&&!Na(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)},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+=ci(e.lastIntValue);this.regexp_eatRegExpIdentifierPart(e);)e.lastStringValue+=ci(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),Pa(r)?(e.lastIntValue=r,!0):(e.pos=t,!1)};function Pa(e){return Ur(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),Fa(r)?(e.lastIntValue=r,!0):(e.pos=t,!1)};function Fa(e){return Wr(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&&!qa(e.lookahead())&&(e.lastIntValue=0,e.advance(),!0)},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)},W.regexp_eatControlLetter=function(e){var t=e.current();return Ia(t)?(e.lastIntValue=t%32,e.advance(),!0):!1};function Ia(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)&&La(e.lastIntValue))return!0;r&&e.raise(`Invalid unicode escape`),e.pos=n}return!1};function La(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)},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 Ra=0,za=1,Ba=2;W.regexp_eatCharacterClassEscape=function(e){var t=e.current();if(Va(t))return e.lastIntValue=-1,e.advance(),za;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===Ba&&e.raise(`Invalid property name`),r;e.raise(`Invalid property name`)}return Ra};function Va(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),za}}if(e.pos=t,this.regexp_eatLoneUnicodePropertyNameOrValue(e)){var i=e.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(e,i)}return Ra},W.regexp_validateUnicodePropertyNameAndValue=function(e,t,n){ii(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 za;if(e.switchV&&e.unicodeProperties.binaryOfStrings.test(t))return Ba;e.raise(`Invalid property name`)},W.regexp_eatUnicodePropertyName=function(e){var t=0;for(e.lastStringValue=``;Ha(t=e.current());)e.lastStringValue+=ci(t),e.advance();return e.lastStringValue!==``};function Ha(e){return Ia(e)||e===95}W.regexp_eatUnicodePropertyValue=function(e){var t=0;for(e.lastStringValue=``;Ua(t=e.current());)e.lastStringValue+=ci(t),e.advance();return e.lastStringValue!==``};function Ua(e){return Ha(e)||qa(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===Ba&&e.raise(`Negated character class may contain strings`),!0}return!1},W.regexp_classContents=function(e){return e.current()===93?za:e.switchV?this.regexp_classSetExpression(e):(this.regexp_nonEmptyClassRanges(e),za)},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||Xa(n))&&e.raise(`Invalid class escape`),e.raise(`Invalid escape`)}e.pos=t}var r=e.current();return r!==93&&(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=za,n;if(!this.regexp_eatClassSetRange(e)){if(n=this.regexp_eatClassSetOperand(e)){n===Ba&&(t=Ba);for(var r=e.pos;e.eatChars([38,38]);)e.current()!==38&&(n=this.regexp_eatClassSetOperand(e))?n!==Ba&&(t=za):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===Ba&&(t=Ba)}},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)?za: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===Ba&&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)===Ba&&(t=Ba);return t},W.regexp_classString=function(e){for(var t=0;this.regexp_eatClassSetCharacter(e);)t++;return t===1?za:Ba},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()&&Wa(n)||Ga(n)?!1:(e.advance(),e.lastIntValue=n,!0)};function Wa(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 Ga(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 Ka(t)?(e.lastIntValue=t,e.advance(),!0):!1};function Ka(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 qa(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;qa(n=e.current());)e.lastIntValue=10*e.lastIntValue+(n-48),e.advance();return e.pos!==t};function qa(e){return e>=48&&e<=57}W.regexp_eatHexDigits=function(e){var t=e.pos,n=0;for(e.lastIntValue=0;Ja(n=e.current());)e.lastIntValue=16*e.lastIntValue+Ya(n),e.advance();return e.pos!==t};function Ja(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function Ya(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;e.lastIntValue=t<=3&&this.regexp_eatOctalDigit(e)?t*64+n*8+e.lastIntValue:t*8+n}else e.lastIntValue=t;return!0}return!1},W.regexp_eatOctalDigit=function(e){var t=e.current();return Xa(t)?(e.lastIntValue=t-48,e.advance(),!0):(e.lastIntValue=0,!1)};function Xa(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(!Ja(i))return e.pos=n,!1;e.lastIntValue=16*e.lastIntValue+Ya(i),e.advance()}return!0};var Za=function(e){this.type=e.type,this.value=e.value,this.start=e.start,this.end=e.end,e.options.locations&&(this.loc=new di(e,e.startLoc,e.endLoc)),e.options.ranges&&(this.range=[e.start,e.end])},G=Ii.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 Za(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 Za(this)},typeof Symbol<`u`&&(G[Symbol.iterator]=function(){var e=this;return{next:function(){var t=e.getToken();return{done:t.type===V.eof,value:t}}}}),G.nextToken=function(){var e=this.curContext();if((!e||!e.preserveSpace)&&this.skipSpace(),this.start=this.pos,this.options.locations&&(this.startLoc=this.curPosition()),this.pos>=this.input.length)return this.finishToken(V.eof);if(e.override)return e.override(this);this.readToken(this.fullCharCodeAtPos())},G.readToken=function(e){return Ur(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=Qr(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&&!Zr(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&&$r.test(String.fromCharCode(e)))++this.pos;else break loop}}},G.finishToken=function(e,t){this.end=this.pos,this.options.locations&&(this.endLoc=this.curPosition());var n=this.type;this.type=e,this.value=t,this.updateContext(n)},G.readToken_dot=function(){var e=this.input.charCodeAt(this.pos+1);if(e>=48&&e<=57)return this.readNumber(!0);var t=this.input.charCodeAt(this.pos+2);return this.options.ecmaVersion>=6&&e===46&&t===46?(this.pos+=3,this.finishToken(V.ellipsis)):(++this.pos,this.finishToken(V.dot))},G.readToken_slash=function(){var e=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):e===61?this.finishOp(V.assign,2):this.finishOp(V.slash,1)},G.readToken_mult_modulo_exp=function(e){var t=this.input.charCodeAt(this.pos+1),n=1,r=e===42?V.star:V.modulo;return this.options.ecmaVersion>=7&&e===42&&t===42&&(++n,r=V.starstar,t=this.input.charCodeAt(this.pos+2)),t===61?this.finishOp(V.assign,n+1):this.finishOp(r,n)},G.readToken_pipe_amp=function(e){var t=this.input.charCodeAt(this.pos+1);return t===e?this.options.ecmaVersion>=12&&this.input.charCodeAt(this.pos+2)===61?this.finishOp(V.assign,3):this.finishOp(e===124?V.logicalOR:V.logicalAND,2):t===61?this.finishOp(V.assign,2):this.finishOp(e===124?V.bitwiseOR:V.bitwiseAND,1)},G.readToken_caret=function(){return this.input.charCodeAt(this.pos+1)===61?this.finishOp(V.assign,2):this.finishOp(V.bitwiseXOR,1)},G.readToken_plus_min=function(e){var t=this.input.charCodeAt(this.pos+1);return t===e?t===45&&!this.inModule&&this.input.charCodeAt(this.pos+2)===62&&(this.lastTokEnd===0||Yr.test(this.input.slice(this.lastTokEnd,this.pos)))?(this.skipLineComment(3),this.skipSpace(),this.nextToken()):this.finishOp(V.incDec,2):t===61?this.finishOp(V.assign,2):this.finishOp(V.plusMin,1)},G.readToken_lt_gt=function(e){var t=this.input.charCodeAt(this.pos+1),n=1;return t===e?(n=e===62&&this.input.charCodeAt(this.pos+2)===62?3:2,this.input.charCodeAt(this.pos+n)===61?this.finishOp(V.assign,n+1):this.finishOp(V.bitShift,n)):t===33&&e===60&&!this.inModule&&this.input.charCodeAt(this.pos+2)===45&&this.input.charCodeAt(this.pos+3)===45?(this.skipLineComment(4),this.skipSpace(),this.nextToken()):(t===61&&(n=2),this.finishOp(V.relational,n))},G.readToken_eq_excl=function(e){var t=this.input.charCodeAt(this.pos+1);return t===61?this.finishOp(V.equality,this.input.charCodeAt(this.pos+2)===61?3:2):e===61&&t===62&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(V.arrow)):this.finishOp(e===61?V.eq:V.prefix,1)},G.readToken_question=function(){var e=this.options.ecmaVersion;if(e>=11){var t=this.input.charCodeAt(this.pos+1);if(t===46){var n=this.input.charCodeAt(this.pos+2);if(n<48||n>57)return this.finishOp(V.questionDot,2)}if(t===63)return e>=12&&this.input.charCodeAt(this.pos+2)===61?this.finishOp(V.assign,3):this.finishOp(V.coalesce,2)}return this.finishOp(V.question,1)},G.readToken_numberSign=function(){var e=this.options.ecmaVersion,t=35;if(e>=13&&(++this.pos,t=this.fullCharCodeAtPos(),Ur(t,!0)||t===92))return this.finishToken(V.privateId,this.readWord1());this.raise(this.pos,`Unexpected character '`+ci(t)+`'`)},G.getTokenFromCode=function(e){switch(e){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(V.parenL);case 41:return++this.pos,this.finishToken(V.parenR);case 59:return++this.pos,this.finishToken(V.semi);case 44:return++this.pos,this.finishToken(V.comma);case 91:return++this.pos,this.finishToken(V.bracketL);case 93:return++this.pos,this.finishToken(V.bracketR);case 123:return++this.pos,this.finishToken(V.braceL);case 125:return++this.pos,this.finishToken(V.braceR);case 58:return++this.pos,this.finishToken(V.colon);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(V.backQuote);case 48:var t=this.input.charCodeAt(this.pos+1);if(t===120||t===88)return this.readRadixNumber(16);if(this.options.ecmaVersion>=6){if(t===111||t===79)return this.readRadixNumber(8);if(t===98||t===66)return this.readRadixNumber(2)}case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.readNumber(!1);case 34:case 39:return this.readString(e);case 47:return this.readToken_slash();case 37:case 42:return this.readToken_mult_modulo_exp(e);case 124:case 38:return this.readToken_pipe_amp(e);case 94:return this.readToken_caret();case 43:case 45:return this.readToken_plus_min(e);case 60:case 62:return this.readToken_lt_gt(e);case 61:case 33:return this.readToken_eq_excl(e);case 63:return this.readToken_question();case 126:return this.finishOp(V.prefix,1);case 35:return this.readToken_numberSign()}this.raise(this.pos,`Unexpected character '`+ci(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(Yr.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 Aa(this));s.reset(n,i,o),this.validateRegExpFlags(s),this.validateRegExpPattern(s);var c=null;try{c=new RegExp(i,o)}catch{}return this.finishToken(V.regexp,{pattern:i,flags:o,value:c})},G.readInt=function(e,t,n){for(var r=this.options.ecmaVersion>=12&&t===void 0,i=n&&this.input.charCodeAt(this.pos)===48,a=this.pos,o=0,s=0,c=0,l=t??1/0;c<l;++c,++this.pos){var u=this.input.charCodeAt(this.pos),d=void 0;if(r&&u===95)i&&this.raiseRecoverable(this.pos,`Numeric separator is not allowed in legacy octal numeric literals`),s===95&&this.raiseRecoverable(this.pos,`Numeric separator must be exactly one underscore`),c===0&&this.raiseRecoverable(this.pos,`Numeric separator is not allowed at the first of digits`),s=u;else{if(d=u>=97?u-97+10:u>=65?u-65+10:u>=48&&u<=57?u-48:1/0,d>=e)break;s=u,o=o*e+d}}return r&&s===95&&this.raiseRecoverable(this.pos-1,`Numeric separator is not allowed at the last of digits`),this.pos===a||t!=null&&this.pos-a!==t?null:o};function Qa(e,t){return t?parseInt(e,8):parseFloat(e.replace(/_/g,``))}function $a(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=$a(this.input.slice(t,this.pos)),++this.pos):Ur(this.fullCharCodeAtPos())&&this.raise(this.pos,`Identifier directly after number`),this.finishToken(V.num,n)},G.readNumber=function(e){var t=this.pos;!e&&this.readInt(10,void 0,!0)===null&&this.raise(t,`Invalid number`);var n=this.pos-t>=2&&this.input.charCodeAt(t)===48;n&&this.strict&&this.raise(t,`Invalid number`);var r=this.input.charCodeAt(this.pos);if(!n&&!e&&this.options.ecmaVersion>=11&&r===110){var i=$a(this.input.slice(t,this.pos));return++this.pos,Ur(this.fullCharCodeAtPos())&&this.raise(this.pos,`Identifier directly after number`),this.finishToken(V.num,i)}n&&/[89]/.test(this.input.slice(t,this.pos))&&(n=!1),r===46&&!n&&(++this.pos,this.readInt(10),r=this.input.charCodeAt(this.pos)),(r===69||r===101)&&!n&&(r=this.input.charCodeAt(++this.pos),(r===43||r===45)&&++this.pos,this.readInt(10)===null&&this.raise(t,`Invalid number`)),Ur(this.fullCharCodeAtPos())&&this.raise(this.pos,`Identifier directly after number`);var a=Qa(this.input.slice(t,this.pos),n);return this.finishToken(V.num,a)},G.readCodePoint=function(){var e=this.input.charCodeAt(this.pos),t;if(e===123){this.options.ecmaVersion<6&&this.unexpected();var n=++this.pos;t=this.readHexChar(this.input.indexOf(`}`,this.pos)-this.pos),++this.pos,t>1114111&&this.invalidStringToken(n,`Code point out of bounds`)}else t=this.readHexChar(4);return t},G.readString=function(e){for(var t=``,n=++this.pos;;){this.pos>=this.input.length&&this.raise(this.start,`Unterminated string constant`);var r=this.input.charCodeAt(this.pos);if(r===e)break;r===92?(t+=this.input.slice(n,this.pos),t+=this.readEscapedChar(!1),n=this.pos):r===8232||r===8233?(this.options.ecmaVersion<10&&this.raise(this.start,`Unterminated string constant`),++this.pos,this.options.locations&&(this.curLine++,this.lineStart=this.pos)):(Zr(r)&&this.raise(this.start,`Unterminated string constant`),++this.pos)}return t+=this.input.slice(n,this.pos++),this.finishToken(V.string,t)};var eo={};G.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(e){if(e===eo)this.readInvalidTemplateToken();else throw e}this.inTemplateElement=!1},G.invalidStringToken=function(e,t){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw eo;this.raise(e,t)},G.readTmplToken=function(){for(var e=``,t=this.pos;;){this.pos>=this.input.length&&this.raise(this.start,`Unterminated template`);var n=this.input.charCodeAt(this.pos);if(n===96||n===36&&this.input.charCodeAt(this.pos+1)===123)return this.pos===this.start&&(this.type===V.template||this.type===V.invalidTemplate)?n===36?(this.pos+=2,this.finishToken(V.dollarBraceL)):(++this.pos,this.finishToken(V.backQuote)):(e+=this.input.slice(t,this.pos),this.finishToken(V.template,e));if(n===92)e+=this.input.slice(t,this.pos),e+=this.readEscapedChar(!0),t=this.pos;else if(Zr(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)}this.options.locations&&(++this.curLine,this.lineStart=this.pos),t=this.pos}else++this.pos}},G.readInvalidTemplateToken=function(){for(;this.pos<this.input.length;this.pos++)switch(this.input[this.pos]){case`\\\\`:++this.pos;break;case`$`:if(this.input[this.pos+1]!==`{`)break;case\"`\":return this.finishToken(V.invalidTemplate,this.input.slice(this.start,this.pos));case`\\r`:this.input[this.pos+1]===`\n`&&++this.pos;case`\n`:case`\\u2028`:case`\\u2029`:++this.curLine,this.lineStart=this.pos+1}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 ci(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 Zr(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(Wr(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?Ur:Wr)(o,r)||this.invalidStringToken(a,`Invalid Unicode escape`),e+=ci(o),n=this.pos}else break;t=!1}return e+this.input.slice(n,this.pos)},G.readWord=function(){var e=this.readWord1(),t=V.name;return this.keywords.test(e)&&(t=Jr[e]),this.finishToken(t,e)},Ii.acorn={Parser:Ii,version:`8.19.0`,defaultOptions:pi,Position:ui,SourceLocation:di,getLineInfo:fi,Node:oa,TokenType:z,tokTypes:V,keywordTypes:Jr,TokContext:Zi,tokContexts:Qi,isIdentifierChar:Wr,isIdentifierStart:Ur,Token:Za,isNewLine:Zr,lineBreak:Yr,lineBreakG:Xr,nonASCIIwhitespace:$r};function to(e,t){return Ii.parse(e,t)}var no={ecmaVersion:`latest`,sourceType:`script`,allowReturnOutsideFunction:!0},ro=/\\w+(?![\\p{ID_Continue}$\\u200c\\u200d])/uy,io=/[A-Za-z_]\\w*(?![\\p{ID_Continue}$\\u200c\\u200d])/uy,ao=/^[$_]\\w+$/,oo=/[\\n\\r\\u2028\\u2029]/,so=/\\s*(?:[;},:)]|=(?![=>]))/y;function co(e,t){return so.lastIndex=t,so.test(e)}var lo=new Set([V.name,V.num,V.string,V.regexp,V.backQuote,V.bracketR,V.braceR,V.parenR,V.incDec,V._this,V._null,V._true,V._false]),uo=class extends Ii{constructor(...e){super(...e),this.operandBeforeLast=!0,this.operandHere=!0,this.breakBeforeLast=!1,this.breakHere=!1,this.ternaries=[],this.colonEndsTernary=!1,this.closedBlock=!1,this.typeBeforeLast=V.eof,this.lookahead=!0}readToken(e){let t=this;if(t.lastTokEnd=t.end,this.operandBeforeLast=this.operandHere,this.operandHere=t.exprAllowed,this.breakBeforeLast=this.breakHere,this.breakHere=oo.test(t.input.slice(t.end,t.pos)),e===64||e===37){let n=t.pos,r=e===64?ro:io;r.lastIndex=n+1;let i=r.exec(t.input)?.[0];if(i){let r=n+1+i.length,a=t.type===V.incDec&&(this.operandBeforeLast||this.breakBeforeLast),o=e===37?this.percentAt?.get(n):void 0;if(e===64||(o??(t.exprAllowed||a||this.lookahead&&fo(t,r)))){e===37&&this.transientsRead?.add(n),t.pos=r,t.finishToken(V.name,t.input.charAt(n)+i);return}}}super.readToken(e)}finishToken(e,t){let{context:n}=this,r=n.length;if(e===V.braceR){let e=n[r-1];this.closedBlock=e.token===`{`&&!e.isExpr}else if(e===V.question)this.ternaries[r]=(this.ternaries[r]??0)+1;else if(e===V.colon){let e=this.ternaries[r]??0;this.colonEndsTernary=e>0,e>0&&(this.ternaries[r]=e-1)}let i=this,a=i.type;this.prevValue=po(this.typeBeforeLast)?void 0:i.value;let o=e.keyword!==void 0&&po(a)||(e===V._function||e===V._class)&&co(i.input,i.pos);if(!o&&(e===V._function||e===V._class)){let t=e===V._function&&a===V.name&&this.prevValue===`async`&&!this.breakHere?this.typeBeforeLast:a;i.type=t===V.colon&&this.colonEndsTernary?V.parenL:t}this.typeBeforeLast=a,super.finishToken(o?V.name:e,t),e===V.name&&(po(a)||t===`of`&&(a===V._const||a===V._var||this.prevValue===`let`))&&(i.exprAllowed=!1)}braceIsBlock(e){if(e===V.colon&&this.colonEndsTernary)return!1;if(e===V.braceR&&this.closedBlock||e===V.name&&this.prevValue===`static`)return!0;if(this.breakHere&&lo.has(e)){let{context:e}=this,t=e[e.length-1];if(t.token===`{`&&!t.isExpr)return!0}return super.braceIsBlock(e)}};function fo(e,t){if(!oo.test(e.input.slice(e.end,e.pos)))return!1;let n=go(e.input,t,`statements`,{afterOperand:!0});n.lookahead=!1;let r=0;try{for(;;){n.nextToken();let e=n.type;if(e===V.eof)return!1;if(r>0)mo.has(e)?r++:ho.has(e)&&r--;else if(e===V.bracketL)r=1;else if(e===V.dot){if(n.nextToken(),n.type!==V.name&&!n.type.keyword)return!1}else return e===V.eq||e===V.assign}}catch{return!1}}function po(e){return e===V.dot||e===V.questionDot}var mo=new Set([V.parenL,V.bracketL,V.braceL,V.dollarBraceL]),ho=new Set([V.parenR,V.bracketR,V.braceR]);function go(e,t,n,{onComment:r,afterOperand:i=!1}={}){let a=new uo(r?{...no,onComment:r}:no,e,t);return n===`expression`&&(a.type=V.parenL),i&&(a.exprAllowed=!1),a}var _o=class extends SyntaxError{constructor(e,t,n,r){super(`${e} ${bo(t,n)}`+vo(r,e=>yo(t,e))),this.reason=e,this.source=t,this.pos=n,this.bracket=r,this.name=`SyntaxError`}reasonIn(e,t){return this.reason+vo(this.bracket,n=>{let{line:r,column:i}=fi(e,t+n);return`at line ${r}, column ${i+1}`})}};function vo(e,t){return e?` (missing \"${e.closer}\" for the \"${e.open}\" ${t(e.pos)})`:``}function yo(e,t){let{line:n,column:r}=fi(e,t);return oo.test(e)?`at line ${n}, column ${r+1}`:`at column ${r+1}`}function bo(e,t){let{column:n}=fi(e,t),r=t-n,i=e.slice(r).search(oo),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`${yo(e,t)}: ${c.trim()}`}var xo=e=>e[e.length-1],So={\"(\":`)`,\"[\":`]`,\"{\":`}`,\"${\":`}`};function Co(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}=wo(e,n),o=n>=e.length||a===``,s=!1;r===`Unexpected token`?(r=o?`Unexpected end of code`:`Unexpected \"${a}\"`,s=!!i&&So[i.text]!==a&&(o||[`)`,`]`,`}`,`;`,`{`].includes(a))):r.startsWith(`Unterminated template`)&&(s=i?.text===\"${\");let c=s&&i?{open:i.text,closer:So[i.text],pos:i.pos}:void 0;return new _o(r,e,n,c)}function wo(e,t){let n=[];for(let r of Bo(e,0,`statements`)){if(`error`in r)break;if(r.start>=t||r.type===V.eof)return{open:xo(n),token:e.slice(r.start,r.end)};let i=e.slice(r.start,r.end);i in So?n.push({text:i,pos:r.start}):n.length&&So[xo(n).text]===i&&n.pop()}return{open:xo(n),token:e.charAt(t)}}function To(e,t=`expression`){return Eo(e,t).out}function Eo(e,t){let n=new Map;for(;;){let r=new Set;try{let i=Oo(e,t,n,r),a={refs:[],strings:[]};return No(i,e,a,!1,!1),a.refs.sort((e,t)=>e.start-t.start),{out:a,ast:i}}catch(t){let i=t.pos??-1;if(!(t instanceof SyntaxError)||n.has(i)||(io.lastIndex=i+1,e.charAt(i)!==`%`||!io.test(e)))throw t;n.set(i,!r.has(i))}}}function Do(e){let{ast:t}=Eo(e,`expression`),n=t.type===`ChainExpression`?t.expression:t,r=!1;for(;n.type===`MemberExpression`;)n=n.object,r=!0;if(n.type!==`Identifier`)return null;let i=jo(n,e);return!i||n.start!==0?null:{sigil:i[0],name:i[1],nested:r}}function Oo(e,t,n,r){try{let i=go(e,0,t);if(i.percentAt=n,i.transientsRead=r,t===`statements`)return i.parse();i.nextToken();let a=i.parseExpression();if(i.type!==V.eof)throw Object.assign(SyntaxError(`Unexpected token`),{pos:i.start});return a}catch(t){throw Co(e,t)}}var ko=e=>typeof e==`object`&&!!e&&typeof e.type==`string`,Ao={$:`story`,_:`temporary`,\"@\":`local`,\"%\":`transient`};function jo(e,t){let n=e.name,r=t.charAt(e.start);return r===n.charAt(0)&&(r===`@`||r===`%`||(r===`$`||r===`_`)&&ao.test(n))?[r,n.slice(1)]:null}function Mo(e,t){if(!ko(e)||e.type!==`Identifier`)return;let n=t.charAt(e.start);if(n===`@`||n===`%`)throw new _o(`\"${e.name}\" can't be a property name`,t,e.start)}function No(e,t,n,r,i){if(Array.isArray(e)){for(let i of e)No(i,t,n,r,!1);return}if(!ko(e))return;let a=(e,r=!1,i=!1)=>No(e,t,n,r,i);switch(e.type){case`Identifier`:{let a=jo(e,t);if(!a)return;if(r)throw new _o(`\"${e.name}\" is a ${Ao[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):Mo(e.property,t);return;case`Property`:if(e.computed?a(e.key):e.shorthand||Mo(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):Mo(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 Po=/[\\p{ID_Continue}$.]*/uy,Fo=/[\\p{ID_Continue}$]*/uy,Io=new Set([`of`,`get`,`set`,`static`,`async`]);function Lo(e,t,{goal:n=`expression`,stop:r}={}){let i=zo(e,t,n,r);return i<0&&!r?Ro(e,t,n):i}function Ro(e,t,n){let r=go(e,t,n);try{if(n===`statements`)r.parse();else if(r.nextToken(),r.parseExpression(),r.type===V.braceR)return r.start}catch(t){let n=t.pos??-1;if(e.charAt(n)===`}`)return n}return-1}function zo(e,t,n,r){let i=[],a=-1,o=!1,s=t,c=!1,l=!1;for(;;){let t=-1;for(let u of Bo(e,s,n,{afterOperand:c})){if(`error`in u){let{message:n}=u.error,a=i.includes(\"${\");if(!/^Unterminated/.test(n)&&!a){if(t=Math.max(u.pos,s)+1,c=!1,t>=e.length)return-1;break}let o=i.lastIndexOf(\"${\");if(!/^Unterminated template/.test(n)||o<0||l||r)return-1;l=!0,i.length=o,t=u.pos,c=!0;break}if(u.restarted&&i.includes(\"${\"))return-1;let n=u.type;if(n===V.eof||n===V.string&&o&&u.start===a)return-1;if(o=n===V.name&&!Io.has(u.value)||n===V.num,a=u.end,n===V.braceL){if(r?.(u.start))return u.start;i.push(`{`)}else if(n===V.dollarBraceL)i.push(\"${\");else if(n===V.parenL)i.push(`(`);else if(n===V.bracketL)i.push(`[`);else if(n===V.parenR||n===V.bracketR)xo(i)===(n===V.parenR?`(`:`[`)&&i.pop();else if(n===V.braceR){let e=Math.max(i.lastIndexOf(`{`),i.lastIndexOf(\"${\"));if(e>=0)i.length=e;else if(!r)return u.start}}s=t,o=!1}}function*Bo(e,t,n,r={}){let i=go(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=go(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}=qo(e,n);if(r){yield o(V.string,n,t);continue}}else if(!c&&i.start<=n&&(s===`\"`||s===`'`)){let{end:t,closed:n}=qo(e,i.start);if(n){yield o(V.string,i.start,t);continue}}else if(!c&&i.start<=n&&s===`/`){let t=Go(e,i.start);if(t>0){yield o(V.regexp,i.start,t);continue}}else if(!c&&i.start<=n&&/[\\d.]/.test(s)&&/\\d/.test(e.slice(i.start,i.start+2))){Po.lastIndex=i.start,Po.test(e),yield o(V.num,i.start,Po.lastIndex);continue}yield{error:t,pos:n};return}if(yield{type:i.type,start:i.start,end:i.end,value:i.value},i.type===V.eof)return}}function Vo(e,t,n=`expression`){return Ho(e,0,t,0,n,!1)}function Ho(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=Bo(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=Bo(e,m,i,{onComment:s}),h=void 0;continue}let o=t.type;if(o===V.eof)return u(m,e.length),e.length;if(u(m,t.start),o===V.name){let i=Uo(e,t.start,t.value),a=h===V.dot||h===V.questionDot||(i===`$`||i===`_`)&&Wo(e,t.end,h);i&&!a?n.variable?.(i,t.value.slice(1),t.start,r,t.end):c(t.start,t.end)}else if(o===V.string||o===V.regexp||o===V.template||o===V.invalidTemplate)l(t.start,t.end);else if(o===V.backQuote){if(l(t.start,t.end),h===V.template||h===V.invalidTemplate){if(f--,a&&f===0)return t.end}else f++}else o===V.dollarBraceL?(l(t.start,t.end),d.push(\"${\"),r++):o===V.braceR&&xo(d)===\"${\"?(d.pop(),r--,l(t.start,t.end)):(o===V.braceL||o===V.parenL||o===V.bracketL?d.push(e.charAt(t.start)):(o===V.braceR||o===V.parenR||o===V.bracketR)&&d.length&&xo(d)!==\"${\"&&d.pop(),c(t.start,t.end));h=o,m=t.end}}function Uo(e,t,n){let r=e.charAt(t);return(r===`@`||r===`%`)&&n.charAt(0)===r||(r===`$`||r===`_`)&&ao.test(n)?r:null}function Wo(e,t,n){if(n!==V.braceL&&n!==V.comma)return!1;let r=/\\S/g;r.lastIndex=t;let i=r.exec(e)?.[0];return i===`:`||i===`(`}function Go(e,t){let n=!1;for(let r=t+1;r<e.length;r++){let t=e.charAt(r);if(oo.test(t))return-1;if(t===`\\\\`)r++;else if(t===`[`)n=!0;else if(t===`]`)n=!1;else if(t===`/`&&!n)return Fo.lastIndex=r+1,Fo.test(e),Fo.lastIndex}return-1}function Ko(e){if(e[0]!==`\"`&&e[0]!==`'`)return null;try{let t=go(e,0,`expression`);return t.nextToken(),t.type===V.string&&t.end===e.length?t.value:null}catch{return null}}function qo(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 Jo=/[\\p{L}\\p{N}_\\\\]/u;function Yo(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=Xo(e,i+2);if(t===-1)return-1;i=t+1}else i++}return-1}function Xo(e,t){Zo!==e&&(Zo=e,Qo.clear());let n=Qo.get(t);return n===void 0&&(n=$o(e,t),Qo.set(t,n)),n}var Zo=``,Qo=new Map;function $o(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&&Jo.test(e[t-1]))){let n=Yo(e,t);t=n===-1?t+1:n}else t++}return-1}var es={closeBrace(e,t,n){let r=Lo(e,t);return r===-1?Xo(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=Lo(e,t,{goal:`statements`,stop:t=>(o.lastIndex=t,o.test(e))});return s===-1?a:s}};function ts(e){let t=e.toLowerCase();return t.startsWith(`on`)||t===`pattern`||t===`srcdoc`}function ns(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=Vn(e[r])?es.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 rs={...es,isBlock:pr,isRaw:fr,isCodeAttribute:ts},is=class extends Error{constructor(e,t,n,r,i=`syntax`,a=t,o={}){super(`${e} (line ${n}, column ${r})`),this.reason=e,this.offset=t,this.line=n,this.column=r,this.code=i,this.end=a,this.data=o,this.name=`MarkupError`}};function as(e,t,n){let r=n.hooks?{...rs,...n.hooks}:rs;try{return or(e,{startRule:t,text:n.text===!0,hooks:r})}catch(t){let{location:n,code:r}=t;if(t instanceof Error&&t.name===`SyntaxError`&&n){let{offset:i}=n.start,{line:a,column:o}=br(e,i);throw new is(t.message,i,a,o,r,n.end.offset)}throw t}}function os(e,t={}){let{tokens:n,errors:r,damage:i}=ds(e,t),a={...rs,...t.hooks},o=kr(n,{isBlock:a.isBlock,isRaw:a.isRaw,source:e});if(r.length===0&&o.errors.length===0)return{tokens:n,nodes:o.nodes,errors:r};let s=e=>r.some((t,n)=>e>=i[n]&&e<=t.offset),c=r.map((e,t)=>[i[t]+.5,e]);for(let t of o.errors)s(t.start)||c.push([t.noticedAt,cs(e,t)]);return c.sort((e,t)=>e[0]-t[0]),{tokens:n,nodes:o.nodes,errors:c.map(([,e])=>e)}}function ss(e,t={}){let{nodes:n,errors:r}=os(e,t);if(r.length>0)throw r[0];return vr(n)}function cs(e,t){let{line:n,column:r}=br(e,t.start);return new is(t.message,t.start,n,r,t.code,t.end,t.data)}function ls(e,t={}){return as(e,`Tokens`,t)}function us(e,t={}){let{tokens:n,errors:r}=ds(e,t);return{tokens:n,errors:r}}function ds(e,t){let n=[],r=[],i=[],a=e.lastIndexOf(`}`),{closeBrace:o}={...rs,...t.hooks},s=(e,n)=>{let r={...t.hooks,closeBrace:(e,t,r)=>n+Math.min(t,r)>a?-1:o(e,t,r)};try{return ls(e,{...t,hooks:r}).map(e=>ms(e,n))}catch(e){if(!(e instanceof is))throw e;return e}},c=0;for(;c<=e.length;){let t=e.slice(c),a=s(t,c);if(Array.isArray(a)){n.push(...a);break}let o=c+a.offset,{line:l,column:u}=br(e,o);r.push(new is(a.reason,o,l,u,a.code,c+a.end));let d=a.offset,f=s(t.slice(0,d),c);for(;!Array.isArray(f);)d=f.offset,f=s(t.slice(0,d),c);if(n.push(...f),i.push(c+d),d<t.length){let e=c+d;n.push({type:`text`,value:t[d],start:e,end:e+1})}c+=d+1}return{tokens:n,errors:r,damage:i}}var fs=/^(start|end|[A-Za-z]*(Start|End))$/;function ps(e,t){let n={...e};for(let[e,r]of Object.entries(n))typeof r==`number`&&fs.test(e)?n[e]=t(r):e===`attributeSpans`&&(n[e]=r.map(e=>ps(e,t)));return n}function ms(e,t){return t===0?e:ps(e,e=>e+t)}var hs=`__proto__`;function gs(e,t=e){return e===`__proto__`?`\"${t}\" cannot be used as a variable name (${hs} is reserved)`:void 0}function _s(e,t=e){let n=gs(e,t);if(n)throw TypeError(`spindle: ${n}`)}var vs=e=>/^(?:0|[1-9]\\d*)$/.test(e),K=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),ys=(e,t)=>e&&K(e,t)?e[t]:void 0;function bs(e,t,n){t===`__proto__`?Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0,configurable:!0}):e[t]=n}function xs(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 Ss=(...e)=>xs(e),Cs=e=>Object.getPrototypeOf(e)===null,ws=e=>Cs(e)?e:Ss(e);function Ts(e,t,n){let r=Ss(e);return r[t]=n,r}var Es=Object.freeze(Ss());function Ds(e,t){return[...new Set([...Object.keys(e),...Object.keys(t)])].filter(n=>K(e,n)!==K(t,n)||!Object.is(ys(e,n),ys(t,n)))}var Os=e=>typeof e==`number`&&Number.isInteger(e)&&e>=0;function ks(e,t){let n=ys(e,t);return Os(n)?n:0}function As(e,t){let n=xs([e],Os);return t!==void 0&&(n[t]=ks(e,t)+1),n}var js=new sr;function Ms(e,t,n,r=!1,i={}){let a=n.filter(e=>e!==`@children`);for(let e of a)e.startsWith(`@`)&&_s(e.slice(1),e);js.set(e,{body:t,params:a,holds:i,isBlock:r}),hr(e,r)}function Ns(e){return js.get(e)}function Ps(){return[...js].map(([e,{params:t,holds:n}])=>({name:e,widget:{params:t,holds:n}}))}function Fs(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 Is(e,t){return e instanceof Error?e.message||t||String(e):typeof e==`string`&&e!==``?e:t??String(e)}function Ls(){let e=new Set;return{subscribe(t){return e.add(t),()=>{e.delete(t)}},notify(){for(let t of[...e])t()}}}var Rs=[],zs=1,Bs=Ls();function Vs(e){Rs=e,Bs.notify()}function Hs(e,t){let n=Is(t).replace(/^spindle: /,``),r=Rs.find(t=>t.context===e&&t.message===n);Vs(r?Rs.map(e=>e===r?{...e,count:e.count+1}:e):[...Rs,{id:zs++,context:e,message:n,count:1}])}function Us(e,t){return Error(`No passage named ${JSON.stringify(e)} (in passage ${JSON.stringify(t)})`)}function Ws(e){Vs(Rs.filter(t=>t.id!==e))}function Gs(){return Rs}var Ks=Bs.subscribe;function qs(e){return/\\s/.test(e)}function Js(e){return e===`(`||e===`[`||e===`{`}function Ys(e){return e===`)`||e===`]`||e===`}`}function Xs(e){return e.replace(/\\\\([\"'\\\\])/g,`$1`)}function Zs(e,t){let n=e[t];if(n!==`\"`&&n!==`'`)return null;let{end:r,closed:i}=qo(e,t);return i?{value:Xs(e.slice(t+1,r-1)),end:r}:null}function Qs(e){let t=Zs(e,0);return t&&t.end===e.length?t.value:null}function $s(e){return/^[\"']?(.+?)[\"']?$/s.exec(e)?.[1]??e}var ec=/(?:[-+*/%&|^!~=<>?:,.]|(?:^|[^\\w$@.])(?:typeof|void|new|delete|in|instanceof|await|yield))$/;function tc(e){let t=-1;if(Vo(e,{code(e,n,r){r===0&&!qs(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)&&ec.test(n)}function nc(e,t){let n=[],r=0;return Vo(e,{code(e,i,a){a>0||(Js(e)?r++:Ys(e)?r--:r===0&&t(e)&&n.push(i))}}),n}function rc(e,t){let n=[],r=0;for(let i of nc(e,t))n.push([r,i]),r=i+1;return n.push([r,e.length]),n}function ic(e){return ac(e)&&!tc(e)}function ac(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 oc(e){let t=rc(e,qs).filter(([e,t])=>t>e);if(t.length<2)return null;for(let[n,r]of t)if(!ic(e.slice(n,r)))return null;return t}function sc(e,[t,n]){let r=e.slice(t,n),i=r.length-r.trimStart().length;return[t+i,Math.max(t+i,n-(r.length-r.trimEnd().length))]}function cc(e){let t=rc(e,e=>e===`,`).map(t=>sc(e,t)),n=t.length>1,r=t[t.length-1];if(r[0]===r[1]&&t.pop(),!n&&t.length===1){let[n,r]=t[0],i=oc(e.slice(n,r));if(i)return i.map(([e,t])=>[n+e,n+t])}return t}function lc(e){return cc(e).map(([t,n])=>e.slice(t,n))}function uc(e){let t=[],n=0;for(let r of[...nc(e,qs),e.length])r>n&&t.push([n,r]),n=r+1;return t}var dc=(e,[t,n])=>e.slice(t,n);function fc(e){return Qs(e)??$s(e)}var pc=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 mc(e,t,n){switch(n.spans?.set(e,[n.at,n.at+t.length]),e.type){case`string`:{let n=Qs(t);if(n===null)throw new pc(e,t);return n}case`text`:return fc(t);case`names`:return t.split(`,`).map(e=>e.trim());case`delay`:return Fs(t);case`number`:return Number(t);case`options`:return bc(e.parameters??[],t,n);default:return t}}function hc(e){return e.type===`flag`||e.type===`separator`?!1:e.type===`options`?{}:void 0}var gc=/\\w+/y,_c=/[-+]?(?:\\d+\\.?\\d*|\\.\\d+)/y,vc=/\\S+/y;function yc(e,t,n){return e.lastIndex=n,e.exec(t)?.[0]??null}function bc(e,t,{at:n,spans:r}){let i={},a=0;for(;a<t.length;){let o=yc(gc,t,a);if(!o){a=Zs(t,a)?.end??a+1;continue}a+=o.length;let s,c=a;for(;c<t.length&&qs(t[c]);)c++;let l=Zs(t,c),u=l||c===a?null:yc(_c,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 pc(d,yc(vc,t,c)??``);d?.type===`flag`?i[o]=!0:d?.type===`number`?i[o]=Number(s??0):d&&(i[o]=s)}return i}var xc=/^(?:[-+*/&|^=<>?:,.]|%(?![A-Za-z_]))/;function Sc(e,t,n){let r=uc(e);if(r.length===1)return n&&dc(e,r[0])===t?[e.length,e.length]:null;if(r.length<2)return null;if(dc(e,r[r.length-1])===t){let t=[0,r[r.length-2][1]];if(!tc(dc(e,t)))return t}if(dc(e,r[0])===t){let t=[r[1][0],e.length];if(!xc.test(dc(e,t)))return t}return null}function Cc(e,t){if(t===`=`){let t=nc(e,e=>e===`=`);for(let n=0;n<t.length;n++){let r=t[n];if(e[r+1]===`=`)n++;else if(e[r-1]!==`!`)return[r,r+1]}return null}let n=uc(e);for(let r=1;r<n.length-1;r++)if(dc(e,n[r])===t)return[n[r-1][1],n[r+1][0]];return null}var wc=e=>e.type===`expression`||e.type===`statements`||e.type===`passage`||e.type===`text`;function Tc(e,t){let n=e.trim();return[n,n?t+e.indexOf(n):t]}function Ec(e,t,n,{at:r,spans:i}){let[a,o]=Tc(t??``,r),s=!e.some(e=>e.type!==`flag`&&e.required);for(let r of e.filter(e=>e.type===`flag`)){let e=t===null?null:Sc(a,r.name,s);n[r.name]=e!==null,e&&([a,o]=Tc(dc(a,e),o+e[0]))}let c=e.filter(e=>e.type!==`flag`);if(c.length===0)return;let l=c.findIndex((e,t)=>wc(e)&&!c.slice(t+1).some(wc)),u=l<0?c.length-1:l,d=(e,[t,n])=>t===n?hc(e):mc(e,a.slice(t,n),{at:o+t,spans:i});if(c.length===1){n[c[0].name]=d(c[0],[0,a.length]);return}let f=uc(a),p=0,m=f.length;for(let e of c.slice(0,u))n[e.name]=p<m?d(e,f[p++]):hc(e);let h=(e,t)=>{try{return d(e,t)}catch(e){if(e instanceof pc)return;throw e}};for(let e of c.slice(u+1).reverse()){let t=p<m&&!tc(a.slice(0,f[m-1][0]))?h(e,f[m-1]):void 0;n[e.name]=t??hc(e),t===void 0?i?.delete(e):m--}let g=c[u];n[g.name]=p<m?d(g,[f[p][0],f[m-1][1]]):hc(g)}var Dc={name:`delay`,type:`delay`,required:!0};function Oc(e,t,n){let r={},[i,a]=Tc(e,0),o=0;return t.forEach((e,s)=>{if(e.type!==`separator`)return;let c=i===null?null:Cc(i,e.name);r[e.name]=c!==null;let l=c?i.slice(0,c[0]):i;Ec(t.slice(o,s),l,r,{at:a,spans:n}),i=c?i.slice(c[1]):null,c&&(a+=c[1]),o=s+1}),Ec(t.slice(o),i,r,{at:a,spans:n}),r}function kc(e){let t=e.trim(),n=Ko(t);return n===null?{kind:`expression`,expression:t}:{kind:`name`,name:n}}function Ac(e,t,{storyData:n,currentPassage:r}){let i=String(t(e??``));if(n&&!n.passages.has(i))throw Us(i,r);return i}function jc(e){let t=e.trim(),n=uc(t)[0];return n?dc(t,n):``}function Mc(e){let{variable:t=``,placeholder:n=``}=Oc(e,[{name:`variable`,type:`variable`},{name:`placeholder`,type:`string`}]);return{varName:t.replace(/[\"']/g,``),placeholder:n}}var Nc=[{name:`value`,type:`string`,holds:`text`,required:!0}],Pc=new Map([[`option`,Nc]]);function Fc(e){return Pc.get(e.toLowerCase())}function Ic(e){let t=[];for(let n of e)if(n.type===`macro`&&n.name===`option`){let{value:e}=Oc(n.rawArgs,Nc);t.push(e??``)}return t}var Lc=null;function Rc(e){let t=Lc;Lc=new Map;try{return e()}finally{Lc=t}}function zc(e,t){let n=t[0]+e,r=Lc?.get(n);if(r)return r;try{r=To(e,t)}catch(e){if(!(e instanceof _o))throw e;r=e}return Lc?.set(n,r),r}function Bc(e,t){return e.sourceOffsets?.[t]??e.offset+t}function Vc(e){return e.kind===`code`?e.code.length:e.kind===`text`?e.text.length:e.length}var Hc=new Set([`if`,`elseif`,`case`]),Uc=new Set([`dialog`]);function Wc(e,t={}){if(e.some(e=>K(t,e)))return e.map(e=>({name:e,...K(t,e)?{holds:t[e]}:{}}))}function Gc(e,t){return e.map(e=>e.parameters?{...e,parameters:Gc(e.parameters,t)}:(e.type===`string`||e.type===`text`)&&!e.holds?{...e,holds:t}:e)}function Kc(e){let t=new sr,n=new sr;for(let{name:r,parameters:i,interpolate:a,widget:o}of e){i&&t.set(r,Gc(i,qc(a)));let e=o&&Wc(o.params,o.holds);e&&n.set(r,e)}let r=e=>{let n=t.get(e);if(!n){let r=Fc(e);r&&t.set(e,n=Gc(r,`text`))}return n};return n.size>0&&(r.widget=e=>n.get(e)),r}var qc=e=>e?`markup`:`text`;function Jc(e){if(e.type===`expression`||e.type===`passage`)return`expression`;if(e.type===`statements`)return`statements`}function Yc(e){if(e.type===`string`||e.type===`text`)return e.holds??`markup`}function*Xc(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 ol(a.display,a.displayStart,`In the label of a link: `));else if(a.type===`expression`)yield{kind:`code`,code:a.expression,offset:a.expressionStart,goal:`expression`,label:`{${a.expression}}`};else if(a.type===`html`)for(let{name:t,value:n,at:r}of sl(e,a))if(!ts(t))yield ol(n,r,`In the ${t} attribute of <${a.tag}>: `);else for(let{expr:e,at:i}of cl(n))yield{kind:`code`,code:e,offset:r+i,goal:`expression`,label:`{${e}} in the ${t} attribute of <${a.tag}>`};else if(a.type===`macro`&&!a.isClose){let o=a.name.toLowerCase();if(o===`do`){let n=r(i,o);if(n<0)continue;yield{kind:`code`,code:e.slice(a.end,t[n].start),offset:a.end,goal:`statements`,label:`{do}`},i=n;continue}let s=a.rawArgs;if(Uc.has(o)){let n=r(i,o),s=t.slice(i+1,n);if(n>i+1&&s.every(e=>e.type===`text`)){let r=e.slice(a.end,t[n].start),i=r.trim();yield{kind:`passage`,name:i.replace(/^[\"']|[\"']$/g,``),offset:a.end+r.indexOf(i),length:i.length,macro:o,label:e.slice(a.start,a.end)}}}if(!s)continue;let c=`{${a.name} ${s}}`,l=a.argsStart;if(Hc.has(o)){yield{kind:`code`,code:s,offset:l,goal:`expression`,label:c};continue}let u=n(o);u&&(yield*rl(s,l,u,a.name,c));let d=n.widget?.(o);d&&(yield*il(s,l,d,a.name,c))}}}function*Zc(e,t,n,r={}){yield*Qc(e,e,t,n,r,e=>e,void 0)}function*Qc(e,t,n,r,i,a,o){for(let s of Xc(t,n,r)){let t=o?$c(s,a,o):s;if(s.kind!==`text`||!s.text.includes(`{`)){yield t;continue}let n=e=>a(Bc(s,e)),c=os(s.text,{text:!0,hooks:i.isBlock&&{isBlock:i.isBlock}});yield{...t,tokens:c.tokens.map(e=>ps(e,n)),errors:c.errors.map(t=>{let{line:r,column:i}=br(e,n(t.offset));return new is(t.reason,n(t.offset),r,i,t.code,n(t.end),t.data)})},yield*Qc(e,s.text,c.tokens,r,i,n,s.where)}}function $c(e,t,n){let r=t(e.offset),i={offset:r,nested:!0,where:n};if(e.kind===`passage`||e.kind===`argument-error`){let n=t(e.offset+e.length)-r;return{...e,...i,length:n}}let a=Vc(e),o=e.sourceOffsets?e.sourceOffsets.map(t):t(e.offset+a)-r===a?void 0:Array.from({length:a+1},(n,r)=>t(e.offset+r));return o?{...e,...i,sourceOffsets:o}:{...e,...i}}var el=/\\\\(?:u\\{[0-9a-fA-F]+\\}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{2}|[0-3][0-7]{0,2}|[4-7][0-7]?|\\r\\n|[^])/y;function tl(e,t,n){if(n===`quotes`){let n=e.charAt(t+1);return/[\"'\\\\]/.test(n)?{length:2,text:n}:void 0}el.lastIndex=t;let r=el.exec(e)?.[0],i=r&&Ko(`\"${r}\"`);return typeof i==`string`?{length:r.length,text:i}:void 0}function nl(e,t,n,r){let i=[],a=!1,o=0;for(;i.length<n.length;){if(o>=e.length)return;let s=e[o]===`\\\\`?tl(e,o,r):void 0;if(!s)i.push(t+o++);else{if(!n.startsWith(s.text,i.length))return;for(let e=0;e<s.text.length;e++)i.push(t+o);a=!0,o+=s.length}}return i.push(t+o),a?i:void 0}function*rl(e,t,n,r,i){let a,o=new Map;try{a=Oc(e,n,o)}catch(n){if(!(n instanceof pc))throw n;yield{kind:`argument-error`,message:n.message,offset:t,length:e.length,label:i,macro:r.toLowerCase()};return}yield*al(e,t,n,a,o,r,i,`quotes`)}function*il(e,t,n,r,i){let a=cc(e),o=[],s={},c=new Map;n.forEach(({name:t,holds:n},r)=>{let i=a[r],l=i&&Ko(e.slice(...i));if(!n||l==null)return;let u={name:t,type:`string`,holds:n};o.push(u),s[t]=l,c.set(u,i)}),yield*al(e,t,o,s,c,r,i,`javascript`)}function*al(e,t,n,r,i,a,o,s){let c=a.toLowerCase();function*l(n,r){for(let u of n){let n=r[u.name];if(u.type===`options`&&u.parameters){yield*l(u.parameters,n??{});continue}let d=i.get(u);if(typeof n!=`string`||!n.trim()||!d)continue;let[f,p]=d,m=e.slice(f,p),h=e=>({kind:`passage`,name:e,offset:t+f,length:p-f,macro:c,label:o}),g=Jc(u);if(u.type===`passage`){let e=kc(n);if(e.kind===`name`){yield h(e.name);continue}}if(g){let e={kind:`code`,code:n,offset:t+f,goal:g,label:o};u.type===`passage`&&(e.passage=!0,e.macro=c),yield e;continue}let _=t+f+(n!==m&&/^[\"']/.test(m)?1:0),v=Yc(u),y=nl(e.slice(_-t),_,n,s);if(v===`expression`||v===`statements`){let e={kind:`code`,code:n,offset:_,goal:v,label:o,inString:!0};y&&(e.sourceOffsets=y),yield e}else if(v===`passage`)yield h(n);else if(v===`markup`){let e=ol(n,_,`In the ${u.name} of {${a}}: `);y&&(e.sourceOffsets=y),yield e}}}yield*[...l(n,r)].sort((e,t)=>e.offset-t.offset)}var ol=(e,t,n)=>({kind:`text`,text:e,offset:t,where:n,tokens:[],errors:[]});function sl(e,t){if(t.attributeSpans.length===0){let n=t.start;return Object.entries(t.attributes).map(([t,r])=>{let i=ll(e,r,n);return n=i+r.length,{name:t,value:r,at:i}})}let n=new Set,r=[];for(let i of t.attributeSpans){let t=i.name.toLowerCase();n.has(t)||(n.add(t),i.valueStart!==void 0&&r.push({name:i.name,value:e.slice(i.valueStart,i.valueEnd),at:i.valueStart}))}return r}function cl(e){let t=[],n=0;for(let r of ns(e))`expr`in r?(t.push({expr:r.expr,at:n+1}),n+=r.expr.length+2):n+=(`text`in r?r.text:r.verbatim).length;return t}function ll(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 ul=new sr;function dl(e,t){ul.set(e,t)}function fl(e){return ul.get(e)}var pl=new sr;function ml(e,t){t?pl.set(e,t):pl.delete(e)}function hl(e){return pl.get(e)}var gl=new cr;function _l(e){gl.add(e)}function vl(e){return gl.has(e)}var yl=[`expression`,`statements`,`passage`,`variable`,`string`,`text`,`names`,`delay`,`number`,`flag`,`separator`,`options`],bl=[`markup`,`text`,`passage`,`expression`,`statements`];function xl(e,t){let n=`Give a \\`string\\` or \\`text\\` parameter one of ${bl.join(`, `)} to hold (see docs/custom-macros.md#what-a-string-holds).`;for(let r of t){let t=r.type;if(!yl.includes(t))throw Sl(e,r,t===void 0?`has no type`:`has the unknown type ${JSON.stringify(t)}`,`Give it one of the types ${yl.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 Sl(e,r,`is of the type ${t}, which holds what it is`,n);if(i!==void 0&&!bl.includes(i))throw Sl(e,r,`holds the unknown ${JSON.stringify(i)}`,n);r.parameters&&xl(e,r.parameters)}}function Sl(e,t,n,r){return Error(`spindle: The parameter \"${t.name}\" of the macro {${e}} ${n}. ${r}`)}var Cl=new sr;function wl(e,t){Cl.set(e,t)}function Tl(e){return Cl.get(e)?.parameters}function El(){return Array.from(Cl.values())}var Dl=e=>Kc(El())(e);function Ol(e,t){if(!e.includes(`{`))return!1;let n;try{n=ss(e,{text:!0})}catch{return!1}return Al(n,t)}function kl(e,t=Dl,n=``){for(let r of Xc(n,[e],t))if(r.kind===`text`&&Ol(r.text,t))return!0;return!1}function Al(e,t=Dl){for(let n of e){if(n.type===`variable`&&n.scope===`local`&&n.name===`children`||n.type===`html`&&(kl({isClose:!1,isSelfClose:!1,tagNameStart:0,tagNameEnd:0,attributeSpans:[],...n,start:0,end:0},t)||Al(n.children,t)))return!0;if(n.type===`macro`){if(n.name.toLowerCase()===`widget`)continue;if(kl({isClose:!1,nameStart:0,nameEnd:0,argsStart:0,argsEnd:0,...n,start:0,end:0},t)||Al(n.children,t))return!0;if(n.branches){for(let e of n.branches)if(Al(e.children,t))return!0}}}return!1}var jl=[{name:`name`,type:`text`,holds:`text`,required:!0},{name:`parameters`,type:`text`,holds:`text`}];function Ml({name:e=``,parameters:t=``}){let n=[],r={},i=[];for(let e of t.split(/[\\s,]+/)){if(!e.startsWith(`@`))continue;let[t=e,a]=e.split(/:(.*)/s);n.push(t),a!==void 0&&(bl.includes(a)?r[t]=a:i.push({param:t,written:a}))}return{name:e,params:n,...Object.keys(r).length>0?{holds:r}:{},...i.length>0?{badHolds:i}:{}}}function Nl({name:e,badHolds:t=[]}){let[n]=t;if(n)throw Error(`spindle: The widget parameter ${n.param} of {widget \"${e}\"} holds the unknown ${JSON.stringify(n.written)}. Write one of ${bl.join(`, `)} after the colon (see docs/widgets.md#what-an-argument-holds).`)}function Pl(e){return Ml(Oc(e,jl))}function Fl(e){let t=new Map;Oc(e,jl,t);let[n,r]=t.get(jl[0])??[0,0],i=e[n];return(i===`\"`||i===`'`)&&r-n>=2?[n+1,e[r-1]===i?r-1:r]:[n,r]}function Il(e,t=Dl){let n=[];for(let r of e){if(r.name!==`StoryInit`&&!r.tags?.includes(`widget`))continue;let e=[],i=[];for(let n of us(r.content).tokens)if(n.type===`macro`&&n.name.toLowerCase()===`widget`){if(!n.isClose)e.push({token:n,isBlock:!1});else{let t=e.pop();t&&i.push({...t,closeStart:n.start})}}else e.length>0&&(n.type===`variable`&&n.scope===`local`&&n.name===`children`||kl(n,t,r.content))&&(e[e.length-1].isBlock=!0);i.push(...e);let a=[];for(let{token:e,isBlock:t,closeStart:n}of i)try{let[i,o]=Fl(e.rawArgs);a.push({...Pl(e.rawArgs),block:t,passage:r.name,start:e.start,end:e.end,nameStart:e.argsStart+i,nameEnd:e.argsStart+o,...n===void 0?{}:{closeStart:n}})}catch{}n.push(...a.sort((e,t)=>e.start-t.start))}return n}function Ll(e){let t=e=>e.passage===`StoryInit`,n=new sr;for(let r of[...e.filter(e=>!t(e)),...e.filter(t)])r.closeStart!==void 0&&n.set(r.name,r);return[...n.values()]}function Rl(e,t=Dl){return Ll(Il(e,t))}function zl(e,t){Nl(e);let{name:n,params:r,holds:i}=e;Ms(n,t,r,Al(t),i)}function Bl(e,t){for(let n of e)if(n.type===`macro`&&n.name===`widget`&&n.rawArgs){let e=Pl(n.rawArgs);try{zl(e,n.children)}catch(n){console.error(`spindle: widget \"${e.name}\" in passage \"${t}\" was not registered: ${Is(n)}`)}}}var Vl=e=>Symbol.iterator in e,Hl=e=>`entries`in e,Ul=(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},Wl=(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 Gl(e,t){return Object.is(e,t)?!0:typeof e!=`object`||!e||typeof t!=`object`||!t||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:Vl(e)&&Vl(t)?Hl(e)&&Hl(t)?Ul(e,t):Wl(e,t):Ul({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}var Kl=he(null),ql=he(null);function Jl(...e){let t=A(void 0),n=j(Kl);return Q(r=>{if(t.current&&n?.(r))return t.current;let i={};for(let t of e)i[t]=r[t];return Gl(t.current,i)?t.current:t.current=i})}function Yl(e){return new Proxy(Ss(),{get:(t,n)=>typeof n==`string`?ys(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}})}function Xl(){let e=j(Im),{getValues:t}=j(Lm);return Fe(()=>Yl(t),[t,e])}function Zl(){let{variables:e,temporary:t,transient:n,renderCounts:r}=Jl(`variables`,`temporary`,`transient`,`renderCounts`),i=Xl();return Fe(()=>[e,t,i,n],[e,t,i,n,r])}var Ql=1831565813;function $l(e){let t=e|0;return()=>{t=t+Ql|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 eu(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t}var tu=!1,nu=``,ru=0,iu=null,au=0;function ou(e,t=!0){let n;n=e===void 0?String(Date.now())+String(Math.random()):t?e+`|`+Date.now()+`|`+Math.random():e,nu=n,ru=0,iu=$l(eu(n)),tu=!0,au++}function su(e,t){au++,cu(e,t)}function cu(e,t){nu=e;let n=Math.imul(t%4294967296,Ql);iu=$l(eu(e)+n|0),tu=!0,ru=t}function lu(){au++,tu=!1,nu=``,ru=0,iu=null}var uu=[];function du(e){let t={generation:au,seed:nu,pull:ru};uu.push(t);try{return e()}finally{uu.splice(uu.indexOf(t),1),tu&&au===t.generation&&ru!==t.pull&&cu(t.seed,t.pull)}}function fu(){for(let e of uu)e.generation=au,e.seed=nu,e.pull=ru}function pu(){return tu?{seed:nu,pull:ru}:null}function mu(){return!tu||!iu?Math.random():(ru++,iu())}function hu(e,t){return e>t&&([e,t]=[t,e]),Math.floor(mu()*(t-e+1))+e}function gu(){return tu}function _u(){return nu}function vu(){return ru}var yu=500,bu={$:`__variables`,_:`__temporary`,\"@\":`__locals`,\"%\":`__transient`},xu=`__fns`,Su=/[\\p{ID_Continue}$\\u200c\\u200d]$/u;function Cu(e,t=`expression`){let n=t===`statements`?`s`+e:`e`+e,r=wu.get(n);if(r!==void 0)return r;let{refs:i}=To(e,t),a=``,o=0;for(let t of i){let n=gs(t.name,t.sigil+t.name);if(n)throw SyntaxError(`spindle: ${n}`);a+=e.slice(o,t.start),t.shorthand?a+=`${t.name}: `:Su.test(a.slice(-2))&&(a+=` `),a+=`${bu[t.sigil]}[\"${t.name}\"]`,o=t.end}return a+=e.slice(o),wu.size>=yu&&wu.delete(wu.keys().next().value),wu.set(n,a),a}var wu=new Map,Tu=500,Eu=new Map,Du=`const {currentPassage,previousPassage,visited,hasVisited,hasVisitedAny,hasVisitedAll,rendered,hasRendered,hasRenderedAny,hasRenderedAll,random,randomInt}=${xu};`;function Ou(e,t){let n=Cu(e,t),r=t===`statements`?`{${n}\\n}`:`return (${n}\\n);`;return Function(bu.$,bu._,bu[`@`],xu,bu[`%`],Du+r)}function ku(e,t){let n=(t===`statements`?`s`:`e`)+e,r=Eu.get(n);if(r)return Eu.delete(n),Eu.set(n,r),r;let i=Ou(e,t);if(Eu.set(n,i),Eu.size>Tu){let e=Eu.keys().next().value;e!==void 0&&Eu.delete(e)}return i}function Au(){let e=Q.getState();return e.storyData?.passages.get(e.currentPassage)}function ju(){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 Mu(e){let t=t=>ks(e(),t??Q.getState().currentPassage);return{count:t,has:e=>t(e)>0,any:(...e)=>e.some(e=>t(e)>0),all:(...e)=>e.every(e=>t(e)>0)}}function Nu(e,t){let n=Mu(e),r=Mu(t);return{currentPassage:Au,previousPassage:ju,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 Pu=null;function Fu(){return Pu??(Pu={...Nu(()=>Q.getState().visitCounts,()=>Q.getState().renderCounts),random:mu,randomInt:hu}),Pu}function Iu(e){return Cs(e)?e:Object.isExtensible(e)?(Object.setPrototypeOf(e,null),e):ws(e)}function Lu(e,...[t,n,r=Es,i=Es]){return e(Iu(t),Iu(n),Iu(r),Fu(),Iu(i))}function Ru(e,...t){return Lu(ku(e,`expression`),...t)}function zu(e,...t){Lu(ku(e,`statements`),...t)}function Bu(e){return e==null?``:String(e)}function Vu(e,t,n){return e||t?b(`span`,{id:t,class:e},n):b(S,null,n)}function Hu(e){return e.includes(`{`)||e.includes(`}`)}function Uu(e,t){return e?.length?{nodes:e,outer:t??null}:null}var Wu=new Map,Gu=2e3;function Ku(e){let t=Wu.get(e);if(t===void 0){try{t={nodes:ss(e,{text:!0})}}catch(e){t={error:e}}Wu.size>=Gu&&Wu.clear(),Wu.set(e,t)}return t}function qu(e,t){return e.map(e=>{switch(e.type){case`text`:return{type:`text`,value:t(e.value)};case`html`:return{...e,children:qu(e.children,t)};case`macro`:{let n={...e,children:qu(e.children,t)};return e.branches&&(n.branches=e.branches.map(e=>({...e,children:qu(e.children,t)}))),n}default:return e}})}var Ju=100;function Yu(e,t,n){let r=n.split(`.`),i=r[0];_s(i,zn[t]+i);let a=ys(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 Xu(e,t){return Ru(e,t.variables,t.temporary,t.locals,t.transient)}var Zu=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 Bu(Xu(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 Bu(Yu(n,e,t))}catch(n){return this.errors.push({macro:zn[e]+t,error:n}),``}}nested(e,t,n,r,i={}){return r>=Ju?(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(vl(e.name))return``;let r=Ns(e.name);if(r){let i=t.locals;if(r.params.length>0){let n=e.rawArgs?lc(e.rawArgs):[];i=Ss(t.locals),r.params.forEach((e,r)=>{let a,o=n[r];if(o!==void 0)try{a=Xu(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:Uu(e.children,t.widgetChildren)})}let i=hl(e.name);if(!i){let t=fl(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=>Xu(e,t),renderText:(r,i)=>this.nested(e.name,r,t,n,i?{locals:Qu(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 Qu(e,t){for(let e of Object.keys(t))_s(e,`@${e}`);return Ss(e,t)}function $u(e,t){let n=new Zu;return{text:n.nodes(e,t,0),errors:n.errors}}function ed(e,t){if(!Hu(e))return{text:e,errors:[]};let n=Ku(e);return`error`in n?{text:e,errors:[{macro:`markup`,error:n.error}]}:$u(n.nodes,t)}function td(e,t,n){let r=[],i=``;for(let a of ns(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=Rn[a.expr[0]];try{i+=Bu(Yu(t,e,a.expr.slice(1)))}catch(e){r.push({macro:a.expr,error:e})}}else try{i+=Bu(Xu(a.expr,t))}catch(e){r.push({macro:`expression`,error:e})}return{text:i,errors:r}}function nd(){let[e,t,n,r]=Zl(),i=j(Xm);return Fe(()=>({variables:e,temporary:t,locals:n,transient:r,widgetChildren:i}),[e,t,n,r,i])}function rd(){let e=nd();return Ie(t=>{if(t===void 0||!Hu(t))return t;let{text:n,errors:r}=ed(t,e);for(let{macro:e,error:n}of r)console.error(`spindle: {${e}} error in \"${t}\": ${Is(n)}`);return n},[e])}var id=0;Array.isArray;function q(e,t,r,i,a,o){t||(t={});var s,c,l=t;if(`ref`in l&&typeof e!=`function`)for(c in l={},t)c==`ref`?s=t[c]:l[c]=t[c];var u={type:e,props:l,key:r,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--id,__i:-1,__u:0};return(a||o)&&(u.__source=a,u.__self=o),n.vnode&&n.vnode(u),u}var ad={variable:`variables`,temporary:`temporary`,transient:`transient`};function od({node:e}){let{name:t,scope:n}=e,r=rd(),i=r(e.className),a=r(e.id),o=Xl(),s=t.split(`.`),c=s[0],l=Q(e=>n===`local`?void 0:ys(e[ad[n]],c)),u=zn[n],d=gs(c,u+c);if(d)return q(`span`,{class:`error`,children:`{${u}${t} error: ${d}}`});let f;f=n===`local`?ys(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 Vu(i,a,Bu(f))}function sd({node:e}){let{expression:t}=e,n=rd(),r=n(e.className),i=n(e.id),[a,o,s,c]=Zl(),l;try{l=Bu(Ru(t,a,o,s,c))}catch{l=`{error: ${t}}`}return Vu(r,i,l)}function cd(){return{nobr:j(Rm),inline:j(Bm),raw:j(Hm),structural:j(Vm),locals:j(Im)}}function ld({body:e,ownKeys:t}){let n=cd(),[r,i]=je({}),a=j(Lm).getValues(),o=Fe(()=>Ss(a,t,r),[a,j(Im),t,r]),s=A(o);s.current=o;let c=Ie(()=>s.current,[]),l=Ie((e,t)=>{_s(e,`@${e}`),s.current=Ts(s.current,e,t),i(n=>({...n,[e]:t}))},[]),u=Fe(()=>({update:l,getValues:c}),[l,c]);return q(Lm.Provider,{value:u,children:q(Im.Provider,{value:o,children:Kh(e,{...n,locals:o})})})}function ud(e){let t=rd();return Vu(t(e.className),t(e.id),q(dd,{...e}))}function dd({body:e,params:t,rawArgs:n,invocationChildren:r}){let[i,a,o,s]=Zl(),c=j(Xm),l=Fe(()=>Uu(r,c),[r,c]),u=n?lc(n):[],d=[];for(let e=0;e<t.length;e++){let t=u[e],n;if(t!==void 0)try{n=Ru(t,i,a,o,s)}catch{n=void 0}d.push(n)}let f=Fe(()=>{let e=Ss();for(let n=0;n<t.length;n++)e[t[n].startsWith(`@`)?t[n].slice(1):t[n]]=d[n];return e},[t.join(` `),...d]);return q(Xm.Provider,{value:l,children:q(ld,{body:e,ownKeys:f})})}var fd=document.createElement(`i`);function pd(e){let t=`&`+e+`;`;fd.innerHTML=t;let n=fd.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`?!1:n!==t&&n}function md(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 hd(e,t){return e.length>0?(md(e,e.length,0,t),e):t}var gd={}.hasOwnProperty;function _d(e){let t={},n=-1;for(;++n<e.length;)vd(t,e[n]);return t}function vd(e,t){let n;for(n in t){let r=(gd.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){gd.call(r,a)||(r[a]=[]);let e=i[a];yd(r[a],Array.isArray(e)?e:e?[e]:[])}}}function yd(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);md(e,0,0,r)}function bd(e){let t={},n=-1;for(;++n<e.length;)xd(t,e[n]);return t}function xd(e,t){let n;for(n in t){let r=(gd.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i)r[a]=i[a]}}function Sd(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 Cd={'\"':`quot`,\"&\":`amp`,\"<\":`lt`,\">\":`gt`};function wd(e){return e.replace(/[\"&<>]/g,t);function t(e){return`&`+Cd[e]+`;`}}function Td(e){return e.replace(/[\\t\\n\\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var Ed=Id(/[A-Za-z]/),Dd=Id(/[\\dA-Za-z]/),Od=Id(/[#-'*+\\--9=?A-Z^-~]/);function kd(e){return e!==null&&(e<32||e===127)}var Ad=Id(/\\d/),jd=Id(/[\\dA-Fa-f]/),Md=Id(/[!-/:-@[-`{-~]/);function J(e){return e!==null&&e<-2}function Nd(e){return e!==null&&(e<0||e===32)}function Y(e){return e===-2||e===-1||e===32}var Pd=Id(/\\p{P}|\\p{S}/u),Fd=Id(/\\s/);function Id(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function Ld(e,t){let n=wd(Rd(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 Rd(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&Dd(e.charCodeAt(n+1))&&Dd(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 zd={}.hasOwnProperty,Bd=/^(https?|ircs?|mailto|xmpp)$/i,Vd=/^https?$/i;function Hd(e){let t=e||{},n=!0,r={},i=[[]],a=[],o=[],s=bd([{enter:{blockQuote:ne,codeFenced:ae,codeFencedFenceInfo:h,codeFencedFenceMeta:h,codeIndented:ce,codeText:ze,content:Te,definition:ye,definitionDestinationString:xe,definitionLabelString:h,definitionTitleString:h,emphasis:Le,htmlFlow:Fe,htmlText:j,image:ue,label:h,link:de,listItemMarker:ee,listItemValue:T,listOrdered:C,listUnordered:w,paragraph:re,reference:h,resource:he,resourceDestinationString:ge,resourceTitleString:h,setextHeading:De,strong:Re},exit:{atxHeading:ke,atxHeadingSequence:Ee,autolinkEmail:qe,autolinkProtocol:Ke,blockQuote:O,characterEscapeValue:Me,characterReferenceMarkerHexadecimal:We,characterReferenceMarkerNumeric:We,characterReferenceValue:Ge,codeFenced:le,codeFencedFence:se,codeFencedFenceInfo:oe,codeFencedFenceMeta:S,codeFlowValue:Pe,codeIndented:le,codeText:Be,codeTextData:Me,data:Me,definition:we,definitionDestinationString:Se,definitionLabelString:be,definitionTitleString:Ce,emphasis:Ve,hardBreakEscape:A,hardBreakTrailing:A,htmlFlow:Ie,htmlFlowData:Me,htmlText:Ie,htmlTextData:Me,image:ve,label:pe,labelText:fe,lineEnding:Ne,link:ve,listOrdered:E,listUnordered:te,paragraph:ie,reference:S,referenceString:me,resource:S,resourceDestinationString:k,resourceTitleString:_e,setextHeading:je,setextHeadingLineSequence:Ae,setextHeadingText:Oe,strong:He,thematicBreak:Ue}},...t.htmlExtensions||[]]),c={definitions:r,tightStack:o},l={buffer:h,encode:x,getData:m,lineEndingIfNeeded:b,options:t,raw:v,resume:g,setData:p,tag:_},u=t.defaultLineEnding;return d;function d(e){let t=-1,n=0,r=[],a=[],o=[];for(;++t<e.length;)!u&&(e[t][1].type===`lineEnding`||e[t][1].type===`lineEndingBlank`)&&(u=e[t][2].sliceSerialize(e[t][1])),(e[t][1].type===`listOrdered`||e[t][1].type===`listUnordered`)&&(e[t][0]===`enter`?r.push(t):f(e.slice(r.pop(),t))),e[t][1].type===`definition`&&(e[t][0]===`enter`?(o=hd(o,e.slice(n,t)),n=t):(a=hd(a,e.slice(n,t+1)),n=t+1));a=hd(a,o),a=hd(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];zd.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:wd(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`)?_(`>`):D(),b(),_(`<li>`),p(`expectFirstItem`),p(`lastWasTag`)}function E(){D(),o.pop(),y(),_(`</ol>`)}function te(){D(),o.pop(),y(),_(`</ul>`)}function D(){m(`lastWasTag`)&&!m(`slurpAllLineEndings`)&&b(),_(`</li>`),p(`slurpAllLineEndings`)}function ne(){o.push(!1),b(),_(`<blockquote>`)}function O(){o.pop(),b(),_(`</blockquote>`),p(`slurpAllLineEndings`)}function re(){o[o.length-1]||(b(),_(`<p>`)),p(`slurpAllLineEndings`)}function ie(){o[o.length-1]?p(`slurpAllLineEndings`,!0):_(`</p>`)}function ae(){b(),_(`<pre><code`),p(`fencesCount`,0)}function oe(){_(` class=\"language-`+g()+`\"`)}function se(){let e=m(`fencesCount`)||0;e||(_(`>`),p(`slurpOneLineEnding`,!0)),p(`fencesCount`,e+1)}function ce(){b(),_(`<pre><code>`)}function le(){let e=m(`fencesCount`);e!==void 0&&e<2&&c.tightStack.length>0&&!m(`lastWasTag`)&&y(),m(`flowCodeSeenData`)&&b(),_(`</code></pre>`),e!==void 0&&e<2&&b(),p(`flowCodeSeenData`),p(`fencesCount`),p(`slurpOneLineEnding`)}function ue(){a.push({image:!0}),n=void 0}function de(){a.push({})}function fe(e){a[a.length-1].labelId=this.sliceSerialize(e)}function pe(){a[a.length-1].label=g()}function me(e){a[a.length-1].referenceId=this.sliceSerialize(e)}function he(){h(),a[a.length-1].destination=``}function ge(){h(),p(`ignoreEncode`,!0)}function k(){a[a.length-1].destination=g(),p(`ignoreEncode`)}function _e(){a[a.length-1].title=g()}function ve(){let e=a.length-1,i=a[e],o=i.referenceId||i.labelId,s=i.destination===void 0?r[Td(o)]:i;for(n=!0;e--;)if(a[e].image){n=void 0;break}i.image?(_(`<img src=\"`+Ld(s.destination,t.allowDangerousProtocol?void 0:Vd)+`\" alt=\"`),v(i.label),_(`\"`)):_(`<a href=\"`+Ld(s.destination,t.allowDangerousProtocol?void 0:Bd)+`\"`),_(s.title?` title=\"`+s.title+`\"`:``),i.image?_(` />`):(_(`>`),v(i.label),_(`</a>`)),a.pop()}function ye(){h(),a.push({})}function be(e){g(),a[a.length-1].labelId=this.sliceSerialize(e)}function xe(){h(),p(`ignoreEncode`,!0)}function Se(){a[a.length-1].destination=g(),p(`ignoreEncode`)}function Ce(){a[a.length-1].title=g()}function we(){let e=a[a.length-1],t=Td(e.labelId);g(),zd.call(r,t)||(r[t]=a[a.length-1]),a.pop()}function Te(){p(`slurpAllLineEndings`,!0)}function Ee(e){m(`headingRank`)||(p(`headingRank`,this.sliceSerialize(e).length),b(),_(`<h`+m(`headingRank`)+`>`))}function De(){h(),p(`slurpAllLineEndings`)}function Oe(){p(`slurpAllLineEndings`,!0)}function ke(){_(`</h`+m(`headingRank`)+`>`),p(`headingRank`)}function Ae(e){p(`headingRank`,this.sliceSerialize(e).charCodeAt(0)===61?1:2)}function je(){let e=g();b(),_(`<h`+m(`headingRank`)+`>`),v(e),_(`</h`+m(`headingRank`)+`>`),p(`slurpAllLineEndings`),p(`headingRank`)}function Me(e){v(x(this.sliceSerialize(e)))}function Ne(e){m(`slurpAllLineEndings`)||(m(`slurpOneLineEnding`)?p(`slurpOneLineEnding`):m(`inCodeText`)?v(` `):v(x(this.sliceSerialize(e))))}function Pe(e){v(x(this.sliceSerialize(e))),p(`flowCodeSeenData`,!0)}function A(){_(`<br />`)}function Fe(){b(),j()}function Ie(){p(`ignoreEncode`)}function j(){t.allowDangerousHtml&&p(`ignoreEncode`,!0)}function Le(){_(`<em>`)}function Re(){_(`<strong>`)}function ze(){p(`inCodeText`,!0),_(`<code>`)}function Be(){p(`inCodeText`),_(`</code>`)}function Ve(){_(`</em>`)}function He(){_(`</strong>`)}function Ue(){b(),_(`<hr />`)}function We(e){p(`characterReferenceType`,e.type)}function Ge(e){let t=this.sliceSerialize(e);v(x(m(`characterReferenceType`)?Sd(t,m(`characterReferenceType`)===`characterReferenceMarkerNumeric`?10:16):pd(t))),p(`characterReferenceType`)}function Ke(e){let n=this.sliceSerialize(e);_(`<a href=\"`+Ld(n,t.allowDangerousProtocol?void 0:Bd)+`\">`),v(x(n)),_(`</a>`)}function qe(e){let t=this.sliceSerialize(e);_(`<a href=\"`+Ld(`mailto:`+t)+`\">`),v(x(t)),_(`</a>`)}}function X(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return Y(r)?(e.enter(n),s(r)):t(r)}function s(r){return Y(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}var Ud={tokenize:Wd};function Wd(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null)e.consume(n);else return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),X(e,t,`linePrefix`)}function i(t){return e.enter(`paragraph`),a(t)}function a(t){let r=e.enter(`chunkText`,{contentType:`text`,previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){if(t===null)e.exit(`chunkText`),e.exit(`paragraph`),e.consume(t);else return J(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var Gd=class{constructor(){this.index=new Map,this.map=[]}add(e,t,n){Kd(this,e,t,n,!1)}addBefore(e,t,n){Kd(this,e,t,n,!0)}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,this.index.clear()}};function Kd(e,t,n,r,i){if(n===0&&r.length===0)return;let a=e.index.get(t);if(a){a[1]+=n,i?(r.push(...a[2]),a[2]=r):a[2].push(...r);return}let o=[t,n,r];e.map.push(o),e.index.set(t,o)}var qd={tokenize:Yd},Jd={tokenize:Xd};function Yd(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++;let c=new Gd;return c.add(a+1,0,t.events.slice(n)),c.add(n,s-n,[]),c.consume(t.events),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(Jd,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(Jd,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);else 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);else return J(n)?(e.consume(n),g(e.exit(`chunkFlow`)),r=0,t.interrupt=void 0,s):(e.consume(n),h)}function g(e,n){let s=t.sliceStream(e);if(n&&s.push(null),e.previous=a,a&&(a.next=e),a=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(_(r),e=n;e<t.events.length;)t.events[e][1].end={...c},e++;let l=new Gd;l.add(a+1,0,t.events.slice(n)),l.add(n,e-n,[]),l.consume(t.events)}}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 Xd(e,t,n){return X(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function Zd(e){if(e===null||Nd(e)||Fd(e))return 1;if(Pd(e))return 2}function Qd(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 $d={name:`attention`,resolveAll:ef,tokenize:tf};function ef(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};nf(d,-c),nf(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=hd(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=hd(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=hd(l,Qd(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=hd(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=hd(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,md(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 tf(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Zd(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=Zd(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 nf(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var rf={name:`autolink`,tokenize:af};function af(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 Ed(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||Dd(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||Dd(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||kd(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):Od(t)?(e.consume(t),l):n(t)}function u(e){return Dd(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||Dd(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var of={partial:!0,tokenize:sf};function sf(e,t,n){return r;function r(t){return Y(t)?X(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||J(e)?t(e):n(e)}}var cf={continuation:{tokenize:uf},exit:df,name:`blockQuote`,tokenize:lf};function lf(e,t,n){let r=this;return i;function i(t){if(t===62){let n=r.containerState;return n.open||(e.enter(`blockQuote`,{_container:!0}),n.open=!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return Y(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function uf(e,t,n){let r=this;return i;function i(t){return Y(t)?X(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(cf,t,n)(r)}}function df(e){e.exit(`blockQuote`)}var ff={name:`characterEscape`,tokenize:pf};function pf(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 Md(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var mf={name:`characterReference`,tokenize:hf};function hf(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=Dd,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=jd,u):(e.enter(`characterReferenceValue`),a=7,o=Ad,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===Dd&&!pd(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 gf={partial:!0,tokenize:yf},_f={concrete:!0,name:`codeFenced`,tokenize:vf};function vf(e,t,n){let r=this,i={partial:!0,tokenize:x},a=0,o=0,s;return c;function c(e){return l(e)}function l(t){let n=r.events[r.events.length-1];return a=n&&n[1].type===`linePrefix`?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),u(t)}function u(t){return t===s?(o++,e.consume(t),u):o<3?n(t):(e.exit(`codeFencedFenceSequence`),Y(t)?X(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||J(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(gf,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||J(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):Y(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),X(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||J(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||J(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),d(t)):t===96&&t===s?n(t):(e.consume(t),m)}function h(t){return e.attempt(i,b,g)(t)}function g(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_}function _(t){return a>0&&Y(t)?X(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||J(t)?e.check(gf,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||J(t)?(e.exit(`codeFlowValue`),v(t)):(e.consume(t),y)}function b(n){return e.exit(`codeFenced`),t(n)}function x(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),Y(t)?X(e,l,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter(`codeFencedFenceSequence`),u(t)):n(t)}function u(t){return t===s?(i++,e.consume(t),u):i>=o?(e.exit(`codeFencedFenceSequence`),Y(t)?X(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||J(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}function yf(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 bf={name:`codeIndented`,tokenize:Sf},xf={partial:!0,tokenize:Cf};function Sf(e,t,n){let r=this;return i;function i(t){return e.enter(`codeIndented`),X(e,a,`linePrefix`,5)(t)}function a(e){let t=r.events[r.events.length-1];return t&&t[1].type===`linePrefix`&&t[2].sliceSerialize(t[1],!0).length>=4?o(e):n(e)}function o(t){return t===null?c(t):J(t)?e.attempt(xf,o,c)(t):(e.enter(`codeFlowValue`),s(t))}function s(t){return t===null||J(t)?(e.exit(`codeFlowValue`),o(t)):(e.consume(t),s)}function c(n){return e.exit(`codeIndented`),t(n)}}function Cf(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):J(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),i):X(e,a,`linePrefix`,5)(t)}function a(e){let a=r.events[r.events.length-1];return a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(e):J(e)?i(e):n(e)}}var wf={name:`codeText`,previous:Ef,resolve:Tf,tokenize:Df};function Tf(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 Ef(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function Df(e,t,n){let r=0,i,a;return o;function o(t){return e.enter(`codeText`),e.enter(`codeTextSequence`),s(t)}function s(t){return t===96?(e.consume(t),r++,s):(e.exit(`codeTextSequence`),c(t))}function c(t){return t===null?n(t):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),c):t===96?(a=e.enter(`codeTextSequence`),i=0,u(t)):J(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c):(e.enter(`codeTextData`),l(t))}function l(t){return t===null||t===32||t===96||J(t)?(e.exit(`codeTextData`),c(t)):(e.consume(t),l)}function u(n){return n===96?(e.consume(n),i++,u):i===r?(e.exit(`codeTextSequence`),e.exit(`codeText`),t(n)):(a.type=`codeTextData`,l(n))}}var Of=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&&kf(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),kf(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),kf(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);kf(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);kf(this.left,t.reverse())}}}};function kf(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 Af(e){let t={},n=-1,r,i,a,o,s,c,l,u=new Of(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,jf(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 md(e,0,1/0,u.slice(0)),!l}function jf(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 Mf={resolve:Pf,tokenize:Ff},Nf={partial:!0,tokenize:If};function Pf(e){return Af(e),e}function Ff(e,t){let n;return r;function r(t){return e.enter(`content`),n=e.enter(`chunkContent`,{contentType:`content`}),i(t)}function i(t){return t===null?a(t):J(t)?e.check(Nf,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 If(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),X(e,a,`linePrefix`)}function a(i){if(i===null||J(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(`codeIndented`)&&a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function Lf(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||kd(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter(`chunkString`,{contentType:`string`}),h(t))}function f(n){return n===62?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(`chunkString`,{contentType:`string`}),p(n))}function p(t){return t===62?(e.exit(`chunkString`),e.exit(s),f(t)):t===null||t===60||J(t)?n(t):(e.consume(t),t===92?m:p)}function m(t){return t===60||t===62||t===92?(e.consume(t),p):p(t)}function h(i){return!u&&(i===null||i===41||Nd(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||kd(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 Rf(e,t,n,r,i,a){let o=this,s=0,c;return l;function l(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),u}function u(l){return s>999||l===null||l===91||l===93&&!c||l===94&&!s&&`_hiddenFootnoteSupport`in o.parser.constructs?n(l):l===93?(e.exit(a),e.enter(i),e.consume(l),e.exit(i),e.exit(r),t):J(l)?(e.enter(`lineEnding`),e.consume(l),e.exit(`lineEnding`),u):(e.enter(`chunkString`,{contentType:`string`}),d(l))}function d(t){return t===null||t===91||t===93||J(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||(c=!Y(t)),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function zf(e,t,n,r,i,a){let o;return s;function s(t){return t===34||t===39||t===40?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=t===40?41:t,c):n(t)}function c(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){return t===o?(e.exit(a),c(o)):t===null?n(t):J(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),X(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||J(t)?(e.exit(`chunkString`),l(t)):(e.consume(t),t===92?d:u)}function d(t){return t===o||t===92?(e.consume(t),u):u(t)}}function Bf(e,t){let n;return r;function r(i){return J(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):Y(i)?X(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var Vf={name:`definition`,tokenize:Uf},Hf={partial:!0,tokenize:Wf};function Uf(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return Rf.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=Td(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 Nd(t)?Bf(e,l)(t):l(t)}function l(t){return Lf(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(Hf,d,d)(t)}function d(t){return Y(t)?X(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||J(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function Wf(e,t,n){return r;function r(t){return Nd(t)?Bf(e,i)(t):n(t)}function i(t){return zf(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return Y(t)?X(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||J(e)?t(e):n(e)}}var Gf={name:`hardBreakEscape`,tokenize:Kf};function Kf(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return J(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var qf={name:`headingAtx`,resolve:Jf,tokenize:Yf};function Jf(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`},md(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function Yf(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||Nd(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||J(n)?(e.exit(`atxHeading`),t(n)):Y(n)?X(e,s,`whitespace`)(n):(e.enter(`atxHeadingText`),l(n))}function c(t){return t===35?(e.consume(t),c):(e.exit(`atxHeadingSequence`),s(t))}function l(t){return t===null||t===35||Nd(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var Xf=`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(`.`),Zf=[`pre`,`script`,`style`,`textarea`],Qf={concrete:!0,name:`htmlFlow`,resolveTo:tp,tokenize:np},$f={partial:!0,tokenize:ip},ep={partial:!0,tokenize:rp};function tp(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 np(e,t,n){let r=this,i,a,o,s,c;return l;function l(e){return u(e)}function u(t){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(t),d}function d(s){return s===33?(e.consume(s),f):s===47?(e.consume(s),a=!0,h):s===63?(e.consume(s),i=3,r.interrupt?t:se):Ed(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):Ed(a)?(e.consume(a),i=4,r.interrupt?t:se):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:se):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:te:m):n(i)}function h(t){return Ed(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||Nd(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&Zf.includes(l)?(i=1,r.interrupt?t(s):te(s)):Xf.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):te(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||Dd(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:te):n(i)}function v(t){return Y(t)?(e.consume(t),v):ee(t)}function y(t){return t===47?(e.consume(t),ee):t===58||t===95||Ed(t)?(e.consume(t),b):Y(t)?(e.consume(t),y):ee(t)}function b(t){return t===45||t===46||t===58||t===95||Dd(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):Y(t)?(e.consume(t),x):y(t)}function S(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),c=t,C):Y(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||J(t)?n(t):(e.consume(t),C)}function w(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||Nd(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||Y(e)?y(e):n(e)}function ee(t){return t===62?(e.consume(t),E):n(t)}function E(t){return t===null||J(t)?te(t):Y(t)?(e.consume(t),E):n(t)}function te(t){return t===45&&i===2?(e.consume(t),re):t===60&&i===1?(e.consume(t),ie):t===62&&i===4?(e.consume(t),ce):t===63&&i===3?(e.consume(t),se):t===93&&i===5?(e.consume(t),oe):J(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check($f,le,D)(t)):t===null||J(t)?(e.exit(`htmlFlowData`),D(t)):(e.consume(t),te)}function D(t){return e.check(ep,ne,le)(t)}function ne(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),O}function O(t){return t===null||J(t)?D(t):(e.enter(`htmlFlowData`),te(t))}function re(t){return t===45?(e.consume(t),se):te(t)}function ie(t){return t===47?(e.consume(t),o=``,ae):te(t)}function ae(t){if(t===62){let n=o.toLowerCase();return Zf.includes(n)?(e.consume(t),ce):te(t)}return Ed(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),ae):te(t)}function oe(t){return t===93?(e.consume(t),se):te(t)}function se(t){return t===62?(e.consume(t),ce):t===45&&i===2?(e.consume(t),se):te(t)}function ce(t){return t===null||J(t)?(e.exit(`htmlFlowData`),le(t)):(e.consume(t),ce)}function le(n){return e.exit(`htmlFlow`),t(n)}}function rp(e,t,n){let r=this;return i;function i(t){return J(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a):n(t)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}function ip(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(of,t,n)}}var ap={name:`htmlText`,tokenize:op};function op(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):Ed(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):Ed(t)?(e.consume(t),v):n(t)}function u(t){return t===45?(e.consume(t),p):n(t)}function d(t){return t===null?n(t):t===45?(e.consume(t),f):J(t)?(o=d,ie(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):J(t)?(o=h,ie(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):J(t)?(o=v,ie(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):J(t)?(o=y,ie(t)):(e.consume(t),y)}function b(e){return e===62?re(e):y(e)}function x(t){return Ed(t)?(e.consume(t),S):n(t)}function S(t){return t===45||Dd(t)?(e.consume(t),S):C(t)}function C(t){return J(t)?(o=C,ie(t)):Y(t)?(e.consume(t),C):re(t)}function w(t){return t===45||Dd(t)?(e.consume(t),w):t===47||t===62||Nd(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),re):t===58||t===95||Ed(t)?(e.consume(t),ee):J(t)?(o=T,ie(t)):Y(t)?(e.consume(t),T):re(t)}function ee(t){return t===45||t===46||t===58||t===95||Dd(t)?(e.consume(t),ee):E(t)}function E(t){return t===61?(e.consume(t),te):J(t)?(o=E,ie(t)):Y(t)?(e.consume(t),E):T(t)}function te(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,D):J(t)?(o=te,ie(t)):Y(t)?(e.consume(t),te):(e.consume(t),ne)}function D(t){return t===i?(e.consume(t),i=void 0,O):t===null?n(t):J(t)?(o=D,ie(t)):(e.consume(t),D)}function ne(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||Nd(t)?T(t):(e.consume(t),ne)}function O(e){return e===47||e===62||Nd(e)?T(e):n(e)}function re(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function ie(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),ae}function ae(t){return Y(t)?X(e,oe,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):oe(t)}function oe(t){return e.enter(`htmlTextData`),o(t)}}var sp={name:`labelEnd`,resolveAll:dp,resolveTo:fp,tokenize:pp},cp={tokenize:mp},lp={tokenize:hp},up={tokenize:gp};function dp(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&&md(e,0,e.length,n),e}function fp(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=hd(s,e.slice(a+1,a+r+3)),s=hd(s,[[`enter`,u,t]]),s=hd(s,Qd(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=hd(s,[[`exit`,u,t],e[o-2],e[o-1],[`exit`,l,t]]),s=hd(s,e.slice(o+1)),s=hd(s,[[`exit`,c,t]]),md(e,a,e.length,s),e}function pp(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(Td(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(cp,u,o?u:d)(t):t===91?e.attempt(lp,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(up,u,d)(t)}function u(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}function mp(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 Nd(t)?Bf(e,a)(t):a(t)}function a(t){return t===41?u(t):Lf(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return Nd(t)?Bf(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?zf(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return Nd(t)?Bf(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 hp(e,t,n){let r=this;return i;function i(t){return Rf.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(Td(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function gp(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 _p={name:`labelStartImage`,resolveAll:sp.resolveAll,tokenize:vp};function vp(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 yp={name:`labelStartLink`,resolveAll:sp.resolveAll,tokenize:bp};function bp(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 xp={name:`lineEnding`,tokenize:Sp};function Sp(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),X(e,t,`linePrefix`)}}var Cp={name:`thematicBreak`,tokenize:wp};function wp(e,t,n){let r=0,i;return a;function a(t){return e.enter(`thematicBreak`),o(t)}function o(e){return i=e,s(e)}function s(a){return a===i?(e.enter(`thematicBreakSequence`),c(a)):r>=3&&(a===null||J(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),Y(t)?X(e,s,`whitespace`)(t):s(t))}}var Tp={continuation:{tokenize:kp},exit:jp,name:`list`,tokenize:Op},Ep={partial:!0,tokenize:Mp},Dp={partial:!0,tokenize:Ap};function Op(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:Ad(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(Cp,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 Ad(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(of,r.interrupt?n:u,e.attempt(Ep,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return Y(t)?(e.enter(`listItemPrefixWhitespace`),e.consume(t),e.exit(`listItemPrefixWhitespace`),f):n(t)}function f(n){return r.containerState.size=a+r.sliceSerialize(e.exit(`listItemPrefix`),!0).length,t(n)}}function kp(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(of,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,X(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!Y(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(Dp,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,X(e,e.attempt(Tp,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function Ap(e,t,n){let r=this;return X(e,i,`listItemIndent`,r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`listItemIndent`&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function jp(e){e.exit(this.containerState.type)}function Mp(e,t,n){let r=this;return X(e,i,`listItemPrefixWhitespace`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function i(e){let i=r.events[r.events.length-1];return!Y(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var Np={name:`setextUnderline`,resolveTo:Pp,tokenize:Fp};function Pp(e,t){let n=e.length,r,i,a;for(;n--;)if(e[n][0]===`enter`){if(e[n][1].type===`content`){r=n;break}e[n][1].type===`paragraph`&&(i=n)}else e[n][1].type===`content`&&e.splice(n,1),!a&&e[n][1].type===`definition`&&(a=n);let o={type:`setextHeading`,start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type=`setextHeadingText`,a?(e.splice(i,0,[`enter`,o,t]),e.splice(a+1,0,[`exit`,e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push([`exit`,o,t]),e}function Fp(e,t,n){let r=this,i;return a;function a(t){let a=r.events.length,s;for(;a--;)if(r.events[a][1].type!==`lineEnding`&&r.events[a][1].type!==`linePrefix`&&r.events[a][1].type!==`content`){s=r.events[a][1].type===`paragraph`;break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter(`setextHeadingLine`),i=t,o(t)):n(t)}function o(t){return e.enter(`setextHeadingLineSequence`),s(t)}function s(t){return t===i?(e.consume(t),s):(e.exit(`setextHeadingLineSequence`),Y(t)?X(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||J(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var Ip={tokenize:Lp};function Lp(e){let t=this,n=e.attempt(of,r,e.attempt(this.parser.constructs.flowInitial,i,X(e,e.attempt(this.parser.constructs.flow,i,e.attempt(Mf,i)),`linePrefix`)));return n;function r(r){if(r===null)e.consume(r);else return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null)e.consume(r);else return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}var Rp={resolveAll:Hp()},zp=Vp(`string`),Bp=Vp(`text`);function Vp(e){return{resolveAll:Hp(e===`text`?Up: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);else 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 Hp(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 Up(e,t){let n=new Gd,r=0;for(;++r<=e.length;)if((r===e.length||e[r][1].type===`lineEnding`)&&e[r-1][1].type===`data`){let i=e[r-1][1],a=t.sliceStream(i),o=a.length,s=-1,c=0,l;for(;o--;){let e=a[o];if(typeof e==`string`){for(s=e.length;e.charCodeAt(s-1)===32;)c++,s--;if(s)break;s=-1}else if(e===-2)l=!0,c++;else if(e!==-1){o++;break}}if(t._contentTypeTextTrailing&&r===e.length&&(c=0),c){let a={type:r===e.length||l||c<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:o?s:i.start._bufferIndex+s,_index:i.start._index+o,line:i.end.line,column:i.end.column-c,offset:i.end.offset-c},end:{...i.end}};i.end={...a.start},i.start.offset===i.end.offset?Object.assign(i,a):n.add(r,0,[[`enter`,a,t],[`exit`,a,t]])}r++}return n.consume(e),e}var Wp=t({attentionMarkers:()=>Qp,contentInitial:()=>Kp,disable:()=>$p,document:()=>Gp,flow:()=>Jp,flowInitial:()=>qp,insideSpan:()=>Zp,string:()=>Yp,text:()=>Xp}),Gp={42:Tp,43:Tp,45:Tp,48:Tp,49:Tp,50:Tp,51:Tp,52:Tp,53:Tp,54:Tp,55:Tp,56:Tp,57:Tp,62:cf},Kp={91:Vf},qp={[-2]:bf,[-1]:bf,32:bf},Jp={35:qf,42:Cp,45:[Np,Cp],60:Qf,61:Np,95:Cp,96:_f,126:_f},Yp={38:mf,92:ff},Xp={[-5]:xp,[-4]:xp,[-3]:xp,33:_p,38:mf,42:$d,60:[rf,ap],91:yp,92:[Gf,ff],93:sp,95:$d,96:wf},Zp={null:[$d,Rp]},Qp={null:[42,95]},$p={null:[]};function em(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=hd(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=Qd(a,l.events,l),l.events):[]}function f(e,t){return nm(p(e),t)}function p(e){return tm(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(){for(;r._index<o.length;){let e=o[r._index];if(typeof e==`string`){let t=r._index;for(r._bufferIndex<0&&(r._bufferIndex=0);r._index===t&&r._bufferIndex<e.length;)_(e.charCodeAt(r._bufferIndex))}else _(e)}}function _(e){u=u(e)}function v(e){J(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,ee()):e!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=e}function y(e,t){let n=t||{};return n.type=e,n.start=m(),l.events.push([`enter`,n,l]),s.push(n),n}function b(e){let t=s.pop();return t.end=m(),l.events.push([`exit`,t,l]),t}function x(e,t){w(e,t.from)}function S(e,t){t.restore()}function C(e,t){return n;function n(n,r,i){let a,o,s,u;return Array.isArray(n)?f(n):`tokenize`in n?f([n]):d(n);function d(e){return t;function t(t){let n=t!==null&&e[t],r=t!==null&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return a=e,o=0,e.length===0?i:p(e[o])}function p(e){return n;function n(n){return u=T(),s=e,e.partial||(l.currentConstruct=e),e.name&&l.parser.constructs.disable.null.includes(e.name)?h(n):e.tokenize.call(t?Object.assign(Object.create(l),t):l,c,m,h)(n)}}function m(t){return e(s,u),r}function h(e){return u.restore(),++o<a.length?p(a[o]):i}}}function w(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&md(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 tm(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 nm(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 rm(e){let t={constructs:_d([Wp,...(e||{}).extensions||[]]),content:n(Ud),defined:[],document:n(qd),flow:n(Ip),lazy:{},string:n(zp),text:n(Bp)};return t;function n(e){return n;function n(n){return em(t,e,n)}}}function im(e){for(;!Af(e););return e}var am=/[\\0\\t\\n\\r]/g;function om(){let e=1,t=``,n=!0,r;return i;function i(i,a,o){i=t+(typeof i==`string`?i.toString():new TextDecoder(a||void 0).decode(i));let s=[],c=0;for(t=``,n&&(i.charCodeAt(0)===65279&&c++,n=void 0);c<i.length;){am.lastIndex=c;let n=am.exec(i),a=n&&n.index!==void 0?n.index:i.length,o=i.charCodeAt(a);if(!n){t=i.slice(c);break}if(o===10&&c===a&&r)s.push(-3),r=void 0;else switch(r&&(s.push(-5),r=void 0),c<a&&(s.push(i.slice(c,a)),e+=a-c),o){case 0:s.push(65533),e++;break;case 9:{let t=Math.ceil(e/4)*4;for(s.push(-2);e++<t;)s.push(-1);break}case 10:s.push(-4),e=1;break;default:r=!0,e=1}c=a+1}return o&&(r&&s.push(-5),t&&s.push(t),s.push(null)),s}}function sm(e,t,n){return typeof t!=`string`&&(n=t,t=void 0),Hd(n)(im(rm(n).document().write(om()(e,t,!0))))}var cm={none:``,left:` align=\"left\"`,right:` align=\"right\"`,center:` align=\"center\"`};function lm(){return{enter:{table(e){let t=e._align;this.lineEndingIfNeeded(),this.tag(`<table>`),this.setData(`tableAlign`,t)},tableBody(){this.tag(`<tbody>`)},tableData(){let e=cm[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=cm[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,um)),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`+cm[e[t]]+`></td>`),t++;this.setData(`tableColumn`,t),this.lineEndingIfNeeded(),this.tag(`</tr>`)}}}}function um(e,t){return t===`|`?t:e}var dm=class{constructor(){this.map=[],this.index=new Map}add(e,t,n){fm(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,this.index.clear()}};function fm(e,t,n,r){if(n===0&&r.length===0)return;let i=e.index.get(t);if(i){i[1]+=n,i[2].push(...r);return}let a=[t,n,r];e.map.push(a),e.index.set(t,a)}function pm(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 mm(){return{flow:{null:{name:`table`,tokenize:hm,resolveAll:gm}}}}function hm(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{type:e}=r.events[t][1];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||(o=!0,a+=1),u(e)}function u(t){return t===null?n(t):J(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):Y(t)?X(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||Nd(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,Y(t)?X(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return Y(t)?X(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||J(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return Y(t)?X(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||J(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||J(n)?(e.exit(`tableRow`),t(n)):Y(n)?X(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||Nd(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 gm(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 dm;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(vm(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=_m(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=_m(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=_m(f,t,o,i,n,d)):(o[0]=o[1],d=_m(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&vm(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=pm(t.events,n))}return e}function _m(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},ym(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=ym(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=ym(t.events,n[2]),a=ym(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({},ym(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function vm(e,t,n,r,i){let a=[],o=ym(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 ym(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}function bm(){return{enter:{strikethrough(){this.tag(`<del>`)}},exit:{strikethrough(){this.tag(`</del>`)}}}}function xm(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&&md(o,o.length,0,Qd(s,e.slice(r+1,n),t)),md(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),md(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=Zd(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=Zd(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}function Sm(e){let t=[`codeIndented`];return e?.inline&&t.push(`list`,`headingAtx`,`setextUnderline`,`thematicBreak`,`blockQuote`,`codeFenced`,`table`),{allowDangerousHtml:!0,extensions:[mm(),xm(),{disable:{null:t}}],htmlExtensions:[lm(),bm()]}}function Cm(e,t){let n=Sm(t);return sm(e,{...n,extensions:[...n.extensions??[],km(e),Tm]})}var wm=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},Tm={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:wm}}},Em=/[#-'*+\\--9=?A-Z^-~]/,Dm=/[0-9A-Za-z]/,Om=/[A-Za-z]/;function km(e){let t=+(e.charCodeAt(0)===65279),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]===`!`&&Om.test(e[t+2]??``)?a<t+3:e[t+1]===`?`&&r<t+2&&!s(t):!1}function s(t){let n=t+1;for(;Em.test(e[n]??``);)n++;if(e[n]!==`@`)return!1;n++;let r=0,i=`atSignOrDot`;for(;;){let t=e[n]??``;if(i===`atSignOrDot`){if(!Dm.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===`-`||Dm.test(t))&&r++<63))return!1;n++,i=t===`-`?`value`:`label`}}}return{text:{60:{name:`unclosedHtml`,resolveTo:wm,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)}}}}}function Am(e){let t=e.metadata[`data-source-file`],n=e.metadata[`data-source-line`];return t?n?` (${t}:${n})`:` (${t})`:``}function jm(){let e=Q.getState();if(!e.storyData)return``;let t=e.storyData.passages.get(e.currentPassage);return t?Am(t):``}function Mm({macro:e,error:t}){return q(`span`,{class:`error`,title:String(t),children:`{${e} error${jm()}: ${Is(t)}}`})}function Nm(e,t,n=jm()){console.error(`spindle: Error in {${e}}${n}:`,t)}function Pm(e,t,n){let r=A(void 0);if(r.current===void 0){r.current=null;let i=jm();try{n()}catch(n){r.current={error:n},Nm(`${e} ${t}`.trim(),n,i)}}return r.current?q(Mm,{macro:e,error:r.current.error}):null}var Fm={update:e=>{throw Error(`Cannot set @${e} — local variables require a {for}, widget, {link}, or {button} scope`)},getValues:()=>Es},Im=he(Es),Lm=he(Fm),Rm=he(!1),zm=he(!1),Bm=he(!1),Vm=he(!1),Hm=he(!1),Um=he(``),Wm=0;function Gm(){return je(()=>`v${++Wm}`)[0]}var Km=he(!1),qm=`http://www.w3.org/2000/svg`,Jm=new Set([`table`,`thead`,`tbody`,`tfoot`,`tr`,`colgroup`,`ul`,`ol`,`menu`,`dl`,`select`,`optgroup`,`datalist`]),Ym=new Set([`pre`,`textarea`,`style`]),Xm=he(null);function Zm(e,t){return`<span data-tw=${e}:${t}></span>`}var Qm=/(?:(?<=\\\\)\\uE000)?<span data-tw=([0-9a-z]+):(\\d+)><\\/span>/g,$m=``;function eh(e,t){if(!e.includes(`<span data-tw=`))return[e];let n=[],r=0;for(let i of e.matchAll(Qm))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 th(e,t){return eh(e,t).map(e=>typeof e==`number`?t.components[e]:e)}function nh({tag:e,attributes:t,placeholders:n,svg:r,children:i}){let a=nd(),o=[],{props:s,direct:c}=gh(t.map(([e,t,r])=>{let i=n[e];if(!i)return[e,t,r,!1];let s=$u(i,a);for(let t of s.errors)o.push([e,t]);return[e,s.text,r,!0]}),r,e),l=_h(c);return ih(o,b(e,l?{...s,ref:l}:s,...i))}function rh({tag:e,props:t,direct:n,children:r}){let i=_h(n);return b(e,{...t,ref:i},...r)}function ih(e,t){return e.length===0?t:q(S,{children:[e.map(([e,{macro:t,error:n}],r)=>q(Mm,{macro:t,error:Error(`in attribute \"${e}\": ${Is(n)}`)},r)),t]})}function ah(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 oh(e){let t=document.createElement(`template`);return t.innerHTML=e,t.content}function sh(e,t,n=!1){let r=oh(e.trim());if(n)for(let e of Array.from(r.childNodes))e.nodeType===Node.ELEMENT_NODE&&e.nodeName===`P`&&e.replaceWith(...Array.from(e.childNodes));return q(S,{children:Array.from(r.childNodes).map((e,n)=>ch(e,n,t))})}function ch(e,t,n){if(e.nodeType===Node.TEXT_NODE){let t=e.textContent??``;t.endsWith(`\\\\${$m}`)&&ah(e.nextSibling,n)!==-1&&(t=t.slice(0,-1));let r=th(t,n);return r.length===1?r[0]:r}if(e.nodeType===Node.ELEMENT_NODE){let r=e,i=r.localName,a=ah(r,n);if(a!==-1)return n.components[a];let o=r.namespaceURI===qm,s=[],c;for(let{name:e,value:t}of Array.from(r.attributes)){s.push([e,t,t,!1]);let r=eh(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)=>ch(e,t,n));if(c)return q(nh,{tag:i,attributes:s,placeholders:c,svg:o,children:l},t);let{props:u,direct:d}=gh(s,o,i);return d.length>0?q(rh,{tag:i,props:u,direct:d,children:l},t):b(i,{...u,key:t},...l)}return null}var lh=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(`.`)),uh=new Set([`value`,`checked`,`selected`,`muted`]),dh=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`]),fh=new Set([...new Set([`key`,`ref`,`children`,`dangerouslySetInnerHTML`]),`class`,`className`]),ph=/^[A-Za-z_:][\\w:.-]*$/;function mh(e,t,n){if(ph.test(t)){e.setAttribute(t,n);return}let r=oh(`<i ${t}=\"\"></i>`).firstChild.attributes[0];if(!r)return;let i=r.cloneNode();i.value=n,e.setAttributeNode(i)}function hh(e,t){return t===`muted`?!1:t!==`value`||e!==`select`&&e!==`textarea`}function gh(e,t,n){let r={},i=[],a=[];for(let[o,s,c,l]of e){let e=o.toLowerCase();dh.has(e)&&c!==``&&s===``||(!t&&uh.has(e)?!l&&hh(n,e)?a.push([o.toUpperCase(),e===`value`?s:``]):r[e]=e!==`value`&&c===``||s:!ph.test(o)||e.startsWith(`on`)||e===`translate`||t&&(fh.has(o)||o===`__proto__`)?i.push([o,s]):r[t?o:o.toUpperCase()]=s)}for(let[e,t]of a)r[e]=t;return{props:r,direct:i}}function _h(e){let t=A(null);return Pe(()=>{let n=t.current;if(n&&e.length!==0){for(let[t,r]of e)mh(n,t,r);return()=>{for(let[t]of e)n.removeAttribute(t)}}},[JSON.stringify(e)]),e.length>0?t:void 0}var vh=new Map,yh=new Map;function bh(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 xh(e){return bh(e,yh,e=>oh(`<i title=\"${e.replace(/\"/g,`&quot;`)}\"></i>`).firstChild.getAttribute(`title`))}function Sh(e){return bh(e,vh,e=>oh(`<i>${e.replace(/</g,`&lt;`)}</i>`).firstChild.textContent)}var Ch=/\\{[$_@%]\\w/,wh=new Map,Th=2e3;function Eh(e){let t=wh.get(e);return t===void 0&&(t=Ku(e),`nodes`in t&&e.includes(`&`)&&(t={nodes:qu(t.nodes,xh)}),wh.size>=Th&&wh.clear(),wh.set(e,t)),t}function Dh(e,t,n,r){if(ts(e)){if(!t.includes(`&`)&&!Ch.test(t))return t;let i=td(t,n,xh);for(let t of i.errors)r.push([e,t]);return i.text}if(!Hu(t))return xh(t);let i=Eh(t);if(`error`in i)return r.push([e,{macro:`markup`,error:i.error}]),xh(t);let a=$u(i.nodes,n);for(let t of a.errors)r.push([e,t]);return a.text}function Oh(e){return e.type===`text`&&(e.comment===!0||e.value.trim()===``)}var kh={details:`summary`,fieldset:`legend`};function Ah(e,t){let n=kh[e],r=t.findIndex(e=>!Oh(e)),i=t[r];return n&&(i?.type===`macro`||i?.type===`html`&&i.tag.toLowerCase()===n)?r:-1}function jh({node:e}){let t=nd(),{nobr:n,locals:r,raw:i,inline:a,structural:o}=cd(),s=j(Km),c=e.tag.toLowerCase(),l=c===`svg`,u=s&&c===`foreignobject`,d=i&&!u,f=!i&&(l||Ym.has(c)),p=[],{props:m,direct:h}=gh(Object.entries(e.attributes).map(([e,n])=>[e,Dh(e,n,t,p),n,Hu(n)]),s||l,c),g=_h(h);g&&(m.ref=g);let _=lh.has(c),v,y=!1;if(e.children.length>0){if(c===`style`)v=e.children.map(e=>e.type===`text`?e.value:Lh(e));else if(d||f)v=Rh(e.children);else{let t=Ah(c,e.children),i=e=>Kh(e,{nobr:n,locals:r,inline:_});y=Jm.has(c)&&e.children.every(e=>e.type!==`text`||Oh(e)),v=y?e.children.filter(e=>e.type!==`text`).map(e=>Lh(e)):t===-1?i(e.children):q(S,{children:[i(e.children.slice(0,t)),Lh(e.children[t]),i(e.children.slice(t+1))]}),_!==a&&(v=q(Bm.Provider,{value:_,children:v})),y!==o&&(v=q(Vm.Provider,{value:y,children:v}))}}u&&v&&(v=q(Km.Provider,{value:!1,children:q(Hm.Provider,{value:!1,children:v})}));let x=b(e.tag,m,v);return l&&!s&&(x=q(Km.Provider,{value:!0,children:x})),ih(p,f?q(Hm.Provider,{value:!0,children:x}):x)}function Mh(){let e=j(Xm),t=cd();return e?q(Xm.Provider,{value:e.outer,children:Kh(e.nodes,t)}):null}var Nh=new WeakMap,Ph=0;function Fh(e){let t=Nh.get(e);return t===void 0&&(t=`n${Ph++}`,Nh.set(e,t)),t}function Ih(e,t){if(vl(e.name))return null;let n={rawArgs:e.rawArgs,className:e.className,id:e.id},r=Ns(e.name);if(r)return q(ud,{...n,body:r.body,params:r.params,invocationChildren:e.children},t);let i=fl(e.name);return i?q(i,{...n,children:e.children,branches:e.branches},t):q(`span`,{class:`error`,children:`{unknown macro: ${e.name}}`},t)}function Lh(e){if(e.type===`text`)return e.comment?null:Sh(e.value);let t=Fh(e);switch(e.type){case`variable`:return e.scope===`local`&&e.name===`children`?q(Mh,{},t):q(od,{node:e},t);case`expression`:return q(sd,{node:e},t);case`macro`:return Ih(e,t);case`html`:return q(jh,{node:e},t);default:return e}}function Rh(e){return e.length===0?null:e.map(e=>Lh(e))}var zh=/[*_`#|~\\[>\\\\\\-+=\\r]|!\\[|\\d+[.)]|&#?[a-zA-Z0-9]+;| {2}\\n|<[!?]/,Bh=/(?:\\r\\n|\\r(?!\\n)|\\n)\\s*[\\r\\n]/,Vh=/<span data-tw=[0-9a-z]+:\\d+><\\/span>/g,Hh=` \t\\r\n`;function Uh(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 Wh(e){return e.includes(`\n`)?e.split(`\n`).map((e,t,n)=>{let r=t===0?0:Uh(e,0,1,` \t`),i=t===n.length-1?e.length:Uh(e,e.length,-1,` \t`);return e.slice(r,Math.max(r,i))}).join(`\n`):e}function Gh(e,t,n){let r=th(Wh(e),t).filter(e=>e!==``);return n?q(S,{children:r}):b(`p`,null,...r)}function Kh(e,t){if(e.length===0)return null;if(t?.raw)return Rh(e);if(t?.structural&&e.every(e=>e.type!==`text`||Oh(e)))return e.filter(e=>e.type!==`text`).map(Lh);if(!e.some(e=>e.type===`text`&&(e.value.trim()!==``||Bh.test(e.value))))return e.map(e=>Lh(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(Lh(a)),r.nodes.push(a),i.endsWith(`\\\\`)&&(i+=$m),i+=Zm(r.nonce,o)}let a=!!(t?.nobr||t?.inline),o=i.slice(0,Uh(i,0,1,Hh)),s=o.length===i.length?``:i.slice(Uh(i,i.length,-1,Hh)),c=i.slice(o.length,i.length-s.length),l=e=>a&&(o||s)?q(S,{children:[o,e,s]}):e,u=i.replace(Vh,``);return!zh.test(u)&&!Bh.test(u)?l(Gh(c,r,a)):l(sh(Cm(i,{inline:t?.inline}),r,a))}var qh=2**32-1,Jh=qh-1,Yh=class extends Error{constructor(e,t,n,r){super(e),this.name=`DevalueError`,this.path=t.join(``),this.value=n,this.root=r}},Xh=Symbol();function Zh(e,t){let n=[];for(let r=0;r<e.length;r+=1){let i=e[r];i===Xh?n.push(`.get(${t(e[++r])})`):typeof i==`number`?n.push(`[${i}]`):n.push(ug(i))}return n}var Qh=Object.getOwnPropertyNames(Object.prototype).sort().join(`\\0`);function $h(e){let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null||Object.getPrototypeOf(t)===null||Object.getOwnPropertyNames(t).sort().join(`\\0`)===Qh}function eg(e){return Object.prototype.toString.call(e).slice(8,-1)}function tg(e){return typeof Buffer<`u`&&Buffer.isBuffer(e)}function ng(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 rg=/[\"<\\\\\\u0000-\\u001f\\u2028\\u2029]/;function ig(e){if(!rg.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=ng(e[i]);o&&(t+=e.slice(n,i)+o,n=i+1)}return`\"${n===0?e:t+e.slice(n)}\"`}var ag=64,og=new Map;function sg(e){if(e.length>ag)return ig(e);let t=og.get(e);return t===void 0&&(og.size>=1024&&og.clear(),t=ig(e),og.set(e,t)),t}function cg(e){let t=Object.getOwnPropertySymbols(e);return t.length===0?t:t.filter(t=>Object.getOwnPropertyDescriptor(e,t)?.enumerable)}var lg=/^[a-zA-Z_$][a-zA-Z_$0-9]*$/;function ug(e){return lg.test(e)?`.`+e:`[`+JSON.stringify(e)+`]`}function dg(e){return!(!Number.isInteger(e)||e<0||e>Jh)}function fg(e){return!(!Number.isInteger(e)||e<0||e>qh)}function pg(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 dg(+e)}function mg(e){for(var t=e.length-1;t>=0&&!pg(e[t]);t--);return t+1}function hg(e){let t=Object.keys(e);return t.length=mg(t),t}function gg(e){return new Uint8Array(e).toBase64()}function _g(e){return Uint8Array.fromBase64(e).buffer}function vg(e){return Buffer.from(e).toString(`base64`)}function yg(e){return Uint8Array.from(Buffer.from(e,`base64`)).buffer}function bg(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 xg(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 Sg=typeof Uint8Array.fromBase64==`function`,Cg=typeof process==`object`&&process.versions?.node!==void 0,wg=Sg?gg:Cg?vg:bg,Tg=Sg?_g:Cg?yg:xg;function Eg(e,t){if(!t)return e;let n={};for(let r of Object.keys(e))n[r]=t[r]??e[r];return n}var Dg=Object.freeze({kind:`not-plain`}),Og=Object.freeze({kind:`symbol-keys`}),kg=Object.freeze({identify:e=>e,typeOf:e=>e===null?`null`:typeof e,toPrimitive:e=>e,tagOf:e=>eg(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=>(tg(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=>hg(e),shapeOf:e=>$h(e)?cg(e).length>0?Og:{kind:Object.getPrototypeOf(e)===null?`null-proto`:`plain`,keys:Object.keys(e)}:Dg,get:(e,t)=>e[t]}),Ag=Object.getOwnPropertyDescriptor(ArrayBuffer.prototype,`byteLength`)?.get,jg=typeof SharedArrayBuffer>`u`?void 0:Object.getOwnPropertyDescriptor(SharedArrayBuffer.prototype,`byteLength`)?.get,Mg=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{Ag.call(t)}catch(e){if(!jg)throw e;jg.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[Jh]=void 0,delete t[Jh],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 Ng(){throw Error(`Invalid input`)}function Pg(e,t,n){return Fg(JSON.parse(e),t,n)}function Fg(e,t,n){let r=Eg(Mg,n?.operations);if(typeof e==`number`)return c(e,!0);(!Array.isArray(e)||e.length===0)&&Ng();let i=e,a=Array(i.length),o=null;function s(e){return(!dg(e)||e>=i.length)&&Ng(),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`)&&Ng(),e in a)return a[e];e>=i.length&&Ng();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&&Ng()}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`)&&Ng();let o=c(t);a[e]=r.fromViewInfo(n,o,l[2],l[3]);break}case`ArrayBuffer`:{let t=l[1];if(typeof t!=`string`)throw Error(`Invalid ArrayBuffer encoding`);a[e]=r.fromArrayBuffer(Tg(t));break}case`URL`:case`URLSearchParams`:case`Temporal.Duration`:case`Temporal.Instant`:case`Temporal.PlainDate`:case`Temporal.PlainTime`:case`Temporal.PlainDateTime`:case`Temporal.PlainMonthDay`:case`Temporal.PlainYearMonth`:case`Temporal.ZonedDateTime`:a[e]=r.fromStringValue(n,l[1]);break;default:throw Error(`Unknown type ${n}`)}}else if(l[0]===-7){let t=l[1];fg(t)||Ng();let n=r.createSparseArray(t);a[e]=n;for(let e=2;e<l.length;e+=2){let i=l[e];(!dg(i)||i>=t)&&Ng(),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 Ig(e,t,n){let r=Lg(!1,e,t,n);return typeof r==`string`?r:`[${r.join(`,`)}]`}function Lg(e,t,n,r){let i=Eg(kg,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 Yh(e,Zh(c,e=>{let t=i.typeOf(e);return t!==`object`&&t!==`function`&&t!==`symbol`?Rg(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=Rg(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\",${ig(i.toStringValue(t))}]`;break;case`URLSearchParams`:m=`[\"URLSearchParams\",${ig(i.toStringValue(t))}]`;break;case`RegExp`:let{source:n,flags:r}=i.regExpInfo(t);m=r?`[\"RegExp\",${ig(n)},\"${r}\"]`:`[\"RegExp\",${ig(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}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(Xh,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\",\"${wg(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}\",${ig(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+=`,${sg(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+=`${sg(r)}:${d(i.get(t,r))}`,c.pop();m+=`}`}}}}return a[n]=m,n}let f=d(t);return f<0?`${f}`:a}function Rg(e){let t=typeof e;return t===`string`?ig(e):e===void 0?`-1`:e===0&&1/e<0?`-6`:t===`bigint`?`[\"BigInt\",\"${e}\"]`:String(e)}var zg=e=>Object.prototype.toString.call(e).slice(8,-1),Bg=e=>zg(e).startsWith(`Temporal.`),Vg=e=>e instanceof Number||e instanceof String||e instanceof Boolean||zg(e)===`BigInt`;function Hg(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||Vg(e)||Bg(e)}function Ug(e){if(!Hg(e))return;let t=e instanceof Error?`Error`:zg(e);return`${/^[AEIOU]/.test(t)?`an`:`a`} ${t}`}var Wg=[`message`,`cause`,`errors`],Gg=e=>e!==`4294967295`&&String(Number(e)>>>0)===e;function Kg(e){let t=Object.keys(e);return Array.isArray(e)?t.filter(e=>!Gg(e)):t}var qg=[[`hasIndices`,`d`],[`global`,`g`],[`ignoreCase`,`i`],[`multiline`,`m`],[`dotAll`,`s`],[`unicode`,`u`],[`unicodeSets`,`v`],[`sticky`,`y`]].flatMap(([e,t])=>{let n=Object.getOwnPropertyDescriptor(RegExp.prototype,e)?.get;return n?[[t,n]]:[]});function Jg(e){return[Reflect.get(RegExp.prototype,`source`,e),qg.map(([t,n])=>n.call(e)?t:``).join(``)]}function Yg(e){let[t,n]=Jg(e);return`/${t}/${n}`}function Xg(e){return wt(e)?e.entries():Map.prototype.entries.call(e)}function Zg(e){return wt(e)?e.values():Set.prototype.values.call(e)}function Qg(e){if(wt(e))return e.size;let t=e instanceof Map?Map.prototype:Set.prototype;return Reflect.get(t,`size`,e)}function $g(e,t){return wt(e)?e.get(t):Map.prototype.get.call(e,t)}function e_(e,t,n){wt(e)?e.set(t,n):Map.prototype.set.call(e,t,n)}var t_=new Map,n_=new Map,r_=[ArrayBuffer,DataView,Object.getPrototypeOf(Int8Array),URL,URLSearchParams,Number,String,Boolean,Promise,WeakMap,WeakSet,Function];function i_(e,t){let n=typeof t==`function`?r_.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)`);t_.set(e,t),n_.set(t,e)}function a_(e){let t=Object.getPrototypeOf(e);return t===null?void 0:n_.get(t.constructor)}var o_=`c:`,s_=`E:`,c_=`S`,l_=`K`,u_=`R`,d_=new Map([Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError,globalThis.AggregateError].map(e=>[e.prototype,e.name])),f_=new Map([...d_].map(([e,t])=>[t,e.constructor])),p_=[`message`,`cause`,`errors`],m_=e=>typeof e==`object`&&!!e,h_=e=>m_(e)&&Object.getPrototypeOf(e)===Object.prototype,g_=e=>TypeError(`spindle: Malformed data for class \"${e}\"`),__=(e,t,n)=>{Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0,configurable:!0})};function v_(e){if(Object.getOwnPropertySymbols(e).length>0)throw TypeError(`spindle: Cannot save an object with symbol keys`)}function y_(e,t=Object.keys(e)){v_(e);let n={};if(e instanceof Error)for(let t of p_)K(e,t)&&__(n,t,e[t]);for(let r of t)__(n,r,e[r]);return n}var b_={Array,Map,Set,Date,RegExp};function x_(e){let t=()=>y_(e,Kg(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(Xg(e)),t()]:e instanceof Set?[`Set`,Array.from(Zg(e)),t()]:e instanceof Date?[`Date`,Date.prototype.getTime.call(e),t()]:e instanceof RegExp?[`RegExp`,[...Jg(e),e.lastIndex],t()]:T_(y_(e))}function S_(e){for(let t of p_)K(e,t)&&Object.defineProperty(e,t,{enumerable:!1})}var C_=e=>e.length===1&&JSON.stringify(e).length>3;function w_(e){let t=Object.keys(e);if(!t.some(C_))return!1;if(v_(e),t.includes(`__proto__`))throw TypeError(`spindle: Cannot save a property named \"__proto__\"`);return t.flatMap(t=>[t,e[t]])}function T_(e){let t=w_(e);return t?[l_,...t]:e}function E_(){let e={};for(let[t,n]of t_)e[o_+t]=e=>m_(e)&&Object.getPrototypeOf(e)===n.prototype&&x_(e);for(let[t,n]of d_)e[s_+n]=e=>m_(e)&&Object.getPrototypeOf(e)===t&&T_(y_(e));return e[c_]=e=>{if(typeof e!=`symbol`)return!1;let t=Symbol.keyFor(e);return t!==void 0&&[t]},e[u_]=e=>e instanceof RegExp&&e.lastIndex!==0&&[...Jg(e),e.lastIndex],e[l_]=e=>h_(e)&&w_(e),e}function D_(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 O_(e,t){return e===`RegExp`?D_(t):typeof t==`number`?new Date(t):void 0}var k_=new WeakMap;function A_(e,t,n){let[r,i,a]=n,o=typeof r==`string`&&K(b_,r)?b_[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)&&!h_(a))throw g_(e);let c=k_.get(n);if(!c){let a=s?O_(r,i):new o;if(!a)throw g_(e);c=Object.setPrototypeOf(a,t.prototype),k_.set(n,c)}if(!s&&Array.isArray(i)&&j_(c,i),h_(a))for(let e of Object.keys(a))__(c,e,a[e]);return c}function j_(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 M_(e){return Array.isArray(e)&&e[0]===l_?L_(e,1):e}function N_(e){return t=>{if(t=M_(t),Array.isArray(t))return A_(e,P_(e),t);if(!h_(t)){if(m_(t)&&a_(t)===e)return t;throw g_(e)}let n=P_(e);if(Object.values(b_).some(e=>n.prototype instanceof e))throw g_(e);return Object.setPrototypeOf(t,n.prototype),t instanceof Error&&S_(t),t}}function P_(e){let t=t_.get(e);if(!t)throw TypeError(`spindle: The save holds an instance of class \"${e}\", which is not registered`);return t}function F_(e){let t=f_.get(e);if(t)return n=>{if(n=M_(n),Object.getPrototypeOf(n)===t.prototype)return n;if(!h_(n))throw TypeError(`spindle: Malformed data for \"${e}\"`);return Object.setPrototypeOf(n,t.prototype),S_(n),n}}var I_=new WeakMap;function L_(e,t=0){if(!Array.isArray(e)||(e.length-t)%2!=0)throw TypeError(`spindle: Malformed object entries`);let n=I_.get(e);n||I_.set(e,n={});for(let r=t;r<e.length&&K(e,r);r+=2){let t=e[r];if(typeof t!=`string`||t===`__proto__`)throw TypeError(`spindle: Malformed object entries`);__(n,t,K(e,r+1)?e[r+1]:void 0)}return n}var R_=new Proxy({},{getOwnPropertyDescriptor(e,t){let n=z_(t);return n&&{value:n,enumerable:!0,configurable:!0}},get:(e,t)=>z_(t)});function z_(e){if(typeof e==`string`){if(e===c_)return e=>{if(!Array.isArray(e)||typeof e[0]!=`string`)throw TypeError(`spindle: Malformed symbol`);return Symbol.for(e[0])};if(e===l_)return L_;if(e===u_)return e=>{let t=D_(e);if(!t)throw TypeError(`spindle: Malformed regular expression`);return t};if(e.startsWith(o_))return N_(e.slice(2));if(e.startsWith(s_))return F_(e.slice(2))}}function B_(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`:m_(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 V_(e){try{return Ig(e,E_())}catch(t){throw B_(t,e)}}function H_(e){return Pg(e,R_)}var U_=class extends Error{constructor(){super(`This save was made by an incompatible version of Spindle`),this.name=`IncompatibleSaveError`}},W_={};function G_(e){if(typeof e!=`number`||!Number.isInteger(e)||e<1||e>1)throw new U_}function K_(e,t){G_(e);let n=t;for(let t=e;t<1;t++){let e=W_[t];if(!e)throw new U_;n=e(n)}return n}var q_=e=>e&&new Map(Object.entries(e));function J_(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 Y_(e){try{return{formatVersion:1,data:V_({...e,visitCounts:q_(e.visitCounts),renderCounts:q_(e.renderCounts)})}}catch(e){throw J_(e)}}var X_=()=>Error(`Invalid save data`);function Z_(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function Q_(e){return e==null||Z_(e)&&typeof e.seed==`string`&&typeof e.pull==`number`&&Number.isInteger(e.pull)&&e.pull>=0}var $_=e=>Z_(e)&&typeof e.passage==`string`&&Z_(e.variables)&&typeof e.timestamp==`number`&&Q_(e.prng),ev=e=>e===void 0||Array.isArray(e)&&Array.from(e).every(e=>Z_(e)&&typeof e.condition==`string`&&Z_(e.options)),tv=e=>e===void 0||e instanceof Map&&[...e.keys()].every(e=>typeof e==`string`);function nv(e){if(!Z_(e)||typeof e.passage!=`string`||!Z_(e.variables))return!1;let{history:t,historyIndex:n}=e;return!Array.isArray(t)||t.length===0||!Array.from(t).every($_)||typeof n!=`number`||!Number.isInteger(n)||n<0||n>=t.length||t[n].passage!==e.passage?!1:tv(e.visitCounts)&&tv(e.renderCounts)&&Q_(e.prng)&&ev(e.watchers)&&(e.interfaceWatchers===void 0||typeof e.interfaceWatchers==`boolean`)}var rv=e=>e instanceof Map?As(Object.fromEntries(e)):void 0;function iv(e){if(typeof e!=`object`||!e)throw X_();let{formatVersion:t,data:n}=e;if(G_(t),typeof n!=`string`)throw X_();let r=H_(K_(t,n));if(!nv(r))throw X_();let i={...r,visitCounts:rv(r.visitCounts),renderCounts:rv(r.renderCounts)};return i.visitCounts===void 0&&delete i.visitCounts,i.renderCounts===void 0&&delete i.renderCounts,i}var av=`Invalid save file format`;function ov(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var sv=[`id`,`passage`,`ifid`,`playthroughId`,`createdAt`,`updatedAt`,`title`];function cv(e){let t=console.warn;console.warn=()=>{};try{iv(e)}finally{console.warn=t}}function lv(e){if(!ov(e))throw Error(av);if(!K(e,`formatVersion`))throw e.version===1?new U_:Error(av);if(G_(e.formatVersion),typeof e.ifid!=`string`)throw Error(av);let t=e.save;if(!ov(t)||!ov(t.meta))throw Error(av);let n=t.meta;if(sv.some(e=>typeof n[e]!=`string`))throw Error(av);try{cv(t.payload)}catch(e){throw e instanceof U_?e:Error(av)}}function uv(e){try{return lv(e),!0}catch{return!1}}function dv(e){return JSON.stringify(e).length}function fv(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 pv={autosave:`autosave.`,slot:`slot.`,slotIndex:`slotIndex.`,playthroughCount:`playthroughCount.`,currentPlaythrough:`currentPlaythroughId.`};function mv(e,t){let{slot:n,...r}=pv;return Object.values(r).some(n=>e===n+t)||e.startsWith(n)&&e.endsWith(`.${t}`)}function hv(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=>mv(t,e)),getAllMetaKeys:()=>r.keys(),destroy:i}}function gv(){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 hv(`memory`,fv(n),async()=>{for(let e of t)e.clear()})}var _v={saves:`spindle.save.`,playthroughs:`spindle.pt.`,meta:`spindle.meta.`},vv={\"saves.ifid\":`spindle.idx.saves.`,\"saves.playthroughId\":`spindle.idx.saves-pt.`,\"playthroughs.ifid\":`spindle.idx.pt.`};function yv(e){let t=localStorage.getItem(e);if(t!==null)try{return JSON.parse(t)}catch{return}}function bv(e,t){localStorage.setItem(e,JSON.stringify(t))}function xv(e){localStorage.removeItem(e)}function Sv(e,t){try{t===null?localStorage.removeItem(e):localStorage.setItem(e,t)}catch{}}function Cv(e){return yv(e)??[]}function wv(e,t){let n=Cv(e);n.includes(t)||(n.push(t),bv(e,n))}function Tv(e,t){let n=Cv(e).filter(e=>e!==t);n.length>0?bv(e,n):xv(e)}var Ev=e=>Object.keys(localStorage).filter(t=>t.startsWith(e));function Dv(){function e(e,t){let n=_v[e],r=Object.entries(t).map(([t,n])=>({field:t,read:n,prefix:vv[`${e}.${t}`]})),i=e=>r.map(t=>`${t.prefix}${t.read(e)}`);return{get:async e=>yv(`${n}${e}`),async put(e,t){let r=yv(`${n}${e}`),a=i(t),o=r===void 0?[]:i(r).filter(e=>!a.includes(e)),s=[`${n}${e}`,...o,...a],c=s.map(e=>localStorage.getItem(e));try{for(let t of o)Tv(t,e);bv(`${n}${e}`,t);for(let t of a)wv(t,e)}catch(e){throw s.forEach((e,t)=>Sv(e,c[t]??null)),e}},async delete(e){let t=yv(`${n}${e}`);if(t!==void 0)for(let n of i(t))Tv(n,e);xv(`${n}${e}`)},async find(e,t){let i=r.find(t=>t.field===e),a=[];for(let e of Cv(`${i.prefix}${t}`)){let t=yv(`${n}${e}`);t!==void 0&&a.push(t)}return a},keys:async()=>Ev(n).map(e=>e.slice(n.length))}}return hv(`localstorage`,fv(e),async()=>{for(let e of Ev(`spindle.`))xv(e)})}var Ov=`spindle`,kv=1,Av={saves:{keyPath:`meta.id`,indexes:{ifid:`meta.ifid`,playthroughId:`meta.playthroughId`}},playthroughs:{keyPath:`id`,indexes:{ifid:`ifid`}},meta:{keyPath:`key`,indexes:{}}};function jv(){let e=null;function t(){return e||(e=new Promise((t,n)=>{let r=indexedDB.open(Ov,kv);r.onupgradeneeded=()=>{let e=r.result;for(let[t,{keyPath:n,indexes:r}]of Object.entries(Av)){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 hv(`indexeddb`,fv(r),async()=>{(await t()).close(),e=null,await new Promise((e,t)=>{let n=indexedDB.deleteDatabase(Ov);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 Mv=null;async function Nv(){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)}),jv()}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 Dv()}}catch{}return gv()}var Pv=null;function Z(){if(Mv)return Promise.resolve(Mv);if(!Pv){let e=Nv().then(t=>(Pv===e&&(Mv=t),t));Pv=e}return Pv}function Fv(){Mv=null,Pv=null}function Iv(){return Mv?.type??`memory`}function Lv(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&&wt(t)&&(t instanceof Map||t instanceof Set)){let r=kt(t);r&&K(r,e)&&(n=r[e])}}return n}var Rv=e=>e===`length`||vs(e),zv=Ug;function Bv(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 Vv(e,t,n,r={}){let i=Gv(e,t,r.createMissing??!1);i[t[t.length-1]]=n}function Hv(e,t){let n=t[t.length-1];Uv(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=Gv(e,t,!1);if(Array.isArray(i)&&wt(i)&&t.length>1){let r=An(i).slice();delete r[Number(n)];let a=Gv(e,t.slice(0,-1),!1);a[t[t.length-2]]=r}else delete i[n]}function Uv(e){if(e.includes(`__proto__`))throw TypeError(`spindle: Cannot use \"__proto__\" in a variable path (\"${e.join(`.`)}\")`)}function Wv(e,t,n,r,i){if(i&&a_(e)!==void 0)return;let a=zv(e)??(Array.isArray(e)&&!Rv(t)?`an array`:``);if(a)throw TypeError(`spindle: Cannot set property \"${t}\" on ${a} (at \"${n.slice(0,r).join(`.`)}\")`)}function Gv(e,t,n){Uv(t);let r=wt(e),i=e;for(let e=0;e<t.length-1;e++){let a=t[e];Wv(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&&!wt(o)&&!zv(o)&&(o=Bv(o),i[a]=o);i=o}return Wv(i,t[t.length-1],t,t.length-1,!r),i}function Kv(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function qv(e,t,n,r){if(n(t),a_(e)===void 0)return t;Object.setPrototypeOf(t,Object.getPrototypeOf(e));for(let n of Kg(e))bs(t,n,r(n));return t}function Jv(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))bs(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(...Jg(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(Vg(e))return r(e,Object(e.valueOf()));if(Bg(e))return e;if(e instanceof Error){let t=r(e,Object.create(Object.getPrototypeOf(e)));for(let n of[...Wg,`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&&ey(e)&&ey(n)?r(e,n):e}let s=(e,t)=>qv(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 Xg(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 Zg(e))Set.prototype.add.call(t,o(c(n),n));return t}let u=a(l);if(u!==void 0)return u;let d=a_(l)!==void 0||Kv(e);return!d&&t.keepUnregistered?e:i(l,r(l,d?Object.create(Object.getPrototypeOf(l)):{}))}return c(e)}function Yv(e,t){return sy(e,t,Xv())}function Xv(){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 Zv(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 Qv(e,t){return sy(e,t,Zv())}function $v(e,t){if(!ey(e)||!ey(t))return t;let n=new Map,r=new Map,i=e=>ey(e)?Jv(e,{keepUnregistered:!0,seen:n}):e;function a(e,t){let i=Zv(r,n);if(sy(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(!ey(t))return t;let r=n.get(t);if(r!==void 0)return r;if(!ey(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=>qv(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 Xg(t))Map.prototype.set.call(n,i(r),o($g(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(ly(e,t,!1)){let e=Object.create(Object.getPrototypeOf(t));n.set(t,e);for(let t of Object.keys(c))bs(e,t,l(t));return e}return i(t)}return o(e,t)}var ey=e=>typeof e==`object`&&!!e;function ty(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 ny(e,t,n){if(e instanceof Date){let r=Date.prototype.getTime;return Object.is(r.call(e),r.call(t))&&oy(e,t,n)}if(e instanceof RegExp)return Yg(e)===Yg(t)&&e.lastIndex===t.lastIndex&&oy(e,t,n);if(ArrayBuffer.isView(e)){let r=t;return e.byteOffset===r.byteOffset&&e.byteLength===r.byteLength&&sy(e.buffer,r.buffer,n)}if(e instanceof ArrayBuffer)return ty(e,t);if(e instanceof URL||e instanceof URLSearchParams)return String(e)===String(t);if(Vg(e))return Object.is(e.valueOf(),t.valueOf());if(Bg(e))return String(e)===String(t);if(e instanceof Error)return Wg.every(r=>K(e,r)===K(t,r)&&sy(e[r],t[r],n))&&ry(e,t,n)}function ry(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)||!sy(i[e],a[e],n))return!1;return!0}var iy=new Set([Array.prototype,Map.prototype,Set.prototype,Date.prototype,RegExp.prototype]);function ay(e){return iy.has(Object.getPrototypeOf(e))?[]:Kg(e)}function oy(e,t,n){return ry(e,t,n,ay)}function sy(e,t,n){if(Object.is(e,t)&&!(n.strict&&ey(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(Qg(e)!==Qg(r))return!1;let i=e instanceof Map?Xg(e):Zg(e),a=r instanceof Map?Xg(r):Zg(r);for(let e=i.next(),t=a.next();!e.done;e=i.next(),t=a.next())if(!sy(e.value,t.value,n))return!1;return oy(e,t,n)}let i=ny(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||!sy(e[t],r[t],n))return!1;return oy(e,t,n)}return ry(e,t,n)}function cy(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&!Hg(e)}function ly(e,t,n){return n&&(Array.isArray(e)||Array.isArray(t))?Array.isArray(e)&&Array.isArray(t)&&Object.getPrototypeOf(e)===Object.getPrototypeOf(t):cy(e)&&cy(t)&&Object.getPrototypeOf(e)===Object.getPrototypeOf(t)}function uy(e,t,n){let r=[],i=(e,t,i)=>{Object.is(t,i)||(ly(t,i,n)?r.push({key:e,kind:`nested`,before:t,after:i}):Yv(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`});a.length>o&&r.push({key:`length`,kind:`holes`,after:a.length-o})}let a=Array.isArray(t)?ay:Object.keys;for(let n of a(t))K(e,n)?i(n,e[n],t[n]):r.push({key:n,kind:`added`,after:t[n]});for(let n of a(e))K(t,n)||r.push({key:n,kind:`deleted`});return r}function dy(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 uy(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 fy=e=>JSON.stringify(e);function py(e,t){for(let n=1;n<=e.length;n++)if(t.has(fy(e.slice(0,n))))return!0;return!1}var my=(e,t)=>`\\0${e}${t}`,hy=e=>e.startsWith(`\\0`);function gy(e){let t=[];if(e instanceof Map){let n=0;for(let[r,i]of Xg(e))t.push([my(`k`,n),r],[my(`v`,n),i]),n++}else if(e instanceof Set){let n=0;for(let r of Zg(e))t.push([my(`s`,n++),r])}else if(e instanceof Error)for(let n of[`cause`,`errors`])K(e,n)&&t.push([my(n===`cause`?`c`:`e`,0),e[n]]);else if(ArrayBuffer.isView(e))t.push([my(`b`,0),e.buffer]);else return;return t}function _y(e,t){let n=e,r=0;for(let e=0;e<t.length;e++)if(hy(t[e])){if(n=Lv(n,t.slice(r,e)),!ey(n))return;n=gy(n)?.find(([n])=>n===t[e])?.[1],r=e+1}return r===t.length?n:Lv(n,t.slice(r))}function vy(e,t,n){let r=_y(e,t.slice(0,-1)),i=/^\\0v(\\d+)$/.exec(t[t.length-1]);if(!(r instanceof Map)||!i)return!1;let a=[...Xg(r)][Number(i[1])];return a?(e_(r,a[0],n),!0):!1}function yy(e){return e instanceof Map||e instanceof Set||e instanceof Date||e instanceof RegExp?Kg(e):[]}function by(e,t){return Object.getPrototypeOf(e)===Object.getPrototypeOf(t)&&(yy(e).length>0||yy(t).length>0)}function xy(e,t=new Set,n=!1){let r=new Map,i=[];function a(e,t){let a=r.get(e);a?a.push(t):(r.set(e,[t]),cy(e)||Array.isArray(e)?o(e,t):(o(e,t,yy(e)),n&&gy(e)&&i.push([e,t])))}function o(e,n,r=Object.keys(e)){for(let i of r){let r=e[i];if(!ey(r))continue;let o=[...n,i];t.has(fy(o))||a(r,o)}}o(e,[]);for(let[e,t]of i)for(let[n,r]of gy(e))ey(r)&&a(r,[...t,n]);return r}function Sy(e,t,n){return new Map([...xy(e,t,n)].map(([e,t])=>[e,t[0]]))}function Cy(e){return[...xy(e,void 0,!0).values()].filter(e=>e.length>1)}function wy(e,t,n,r,i){let a=[],o=gy(e),s=gy(t);if(o&&s){if(Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;if(e instanceof Map||e instanceof Set){let n=Qg(t);if(Qg(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=ly(e,t,!0)?Object.keys(t):by(e,t)?yy(t):[];for(let n of c)K(e,n)&&a.push([n,e[n],t[n]]);return a.some(([e,t,a])=>{if(!ey(t)||!ey(a))return!1;let o=[...n,e],s=i.get(a);return fy(r.get(t))!==fy(s)||fy(s)===fy(o)&&wy(t,a,o,r,i)})}function Ty(e,t){let n=Sy(e,void 0,!0),r=Sy(t,void 0,!0),i=[];return(function e(t,a,o){for(let s of Array.isArray(a)||cy(a)?Object.keys(a):yy(a)){if(!K(t,s))continue;let c=t[s],l=a[s];if(!ey(c)||!ey(l))continue;let u=[...o,s],d=n.get(c),f=r.get(l),p=fy(u);fy(d)===fy(f)?fy(f)===p&&gy(c)&&wy(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}),((cy(c)||Array.isArray(c))&&ly(c,l,!0)||by(c,l))&&fy(f)===p&&fy(d)===p&&e(c,l,u)}})(e,t,[]),i}function Ey(e,t,n=!1){let r=dy(e,t,n),i=new Set(r.map(e=>fy(e.path))),a=[];for(let n of Ty(e,t))py(n.path,i)||(i.add(fy(n.path)),a.push(n));return[...a,...r]}function Dy(e,t){return Sy(e,new Set(t.map(e=>fy(e.path))),!0)}function Oy(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=_y(t,r);return ey(i)&&(Array.isArray(i)?Array.isArray(n):Object.getPrototypeOf(i)===Object.getPrototypeOf(n))?(super.set(n,i),!0):!1}}}function ky(e,t){let n=Lv(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&&Yv(n[r],t.value):t.deleted}function Ay(e,t,n){t.some(hy)?vy(e,t,n):Vv(e,t,n)}function jy(e,t){let n=e;t.deleted?Hv(n,t.path):Vv(n,t.path,t.value)}var My=new Set([`storyinit`,`beforerestart`,`actionsChanged`,`variableChanged`,`beforesave`,`aftersave`,`beforeload`,`afterload`,`beforenavigate`,`afternavigate`,`passagerender`,`dialogrender`]),Ny=new Map;function Py(e,t){if(!My.has(e))throw Error(`spindle: Unknown event \"${e}\".`);let n=Ny.get(e);return n||(n=new Set,Ny.set(e,n)),n.add(t),()=>{n.delete(t)}}function Fy(e,t){let n=Ny.get(e);if(n)for(let e of[...n])t(e)}function Iy(e,...t){Fy(e,e=>e(...t))}function Ly(e,...t){Fy(e,n=>{try{n(...t)}catch(t){console.error(`spindle: Error in ${e} handler:`,t)}})}var Ry=null,zy=null;function By(e){Ry=e}function Vy(e){zy=e}function Hy(e){return du(()=>Uy(e))}function Uy(e){if(zy)try{let t=Function(`passage`,`variables`,zy)(e.passage,e.variables);if(typeof t==`string`&&t.trim())return t.trim()}catch{}if(Ry)try{let t=Ry(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 Wy=`spindle-saves`,Gy=Promise.resolve();function Ky(e){let t=Gy.then(()=>Eb(Wy,e));return Gy=t.catch(()=>{}),t}function qy(e){return(...t)=>Ky(()=>e(...t))}var Jy=e=>qy(async t=>e(await(await Z()).getSave(t))),Yy=e=>qy(async(t,n)=>e(await Ab(t,n))),Xy=qy(Zy);async function Zy(e,t=ft()){let n=await Z();return await Eb(`spindle-playthrough-count:${e}`,async()=>{let r=await eb(e),i={id:t,ifid:e,createdAt:new Date().toISOString(),label:`Playthrough ${r}`};await n.putPlaythrough(i),await n.setMeta($y(e),r)}),await n.setMeta(tb(e),t),rx(e,t),t}var Qy=/^Playthrough (\\d+)$/;function $y(e){return`${pv.playthroughCount}${e}`}async function eb(e){let t=await Z(),n=await t.getMeta($y(e))??0;for(let r of await t.getPlaythroughsByIfid(e)){let e=Qy.exec(r.label);e&&(n=Math.max(n,Number(e[1])))}return n+1}function tb(e){return`${pv.currentPlaythrough}${e}`}var nb=qy(rb);async function rb(e,t){let n=await Z();await ib(e,t,new Date().toISOString());let r=tb(e);await n.getMeta(r)!==t&&await n.setMeta(r,t),rx(e,t)}async function ib(e,t,n){await ab(e,t)||await(await Z()).putPlaythrough({id:t,ifid:e,createdAt:n,label:`Imported`})}async function ab(e,t){return(await(await Z()).getPlaythroughsByIfid(e)).some(e=>e.id===t)}async function ob(e,t){if(await ab(e,t))return t;let n=await(await Z()).getMeta(tb(e));return n&&await ab(e,n)?(rx(e,n),n):Zy(e)}function sb(e){return Ky(async()=>{let t=await Z(),n=ix(e),r=n!==void 0&&await ab(e,n)?n:await t.getMeta(tb(e))??await Zy(e);return rx(e,r),{id:r,knownSaves:await qb(e)}})}function cb(e,t,n,r){try{let i=n();return du(()=>Iy(`beforesave`,e,t)),r(i()).then(t=>(du(()=>Iy(`aftersave`,e)),t))}catch(e){return Promise.reject(e)}}function lb(e,t){let n=Y_(t);return{meta:{...e,estimatedBytes:dv(n)},payload:n}}var ub=qy(db);async function db(e,t,n,r={}){let i=await t;if(!i)throw Error(`No playthrough`);let a=await ob(e,i),o=new Date().toISOString(),s=lb({id:ft(),ifid:e,playthroughId:a,createdAt:o,updatedAt:o,title:Hy(n),passage:n.passage,custom:r},n);return await(await Z()).putSave(s),zb(e),s}var fb=qy(pb);async function pb(e,t,n,r){let i=await r,a=await Z(),o=await a.getSave(e);if(!o)return;let s=i?await ob(o.meta.ifid,i):void 0,c=lb({...o.meta,...s?{playthroughId:s}:{},updatedAt:new Date().toISOString(),title:o.meta.userTitle===!0?o.meta.title:Hy(t),passage:t.passage,...n==null?{}:{custom:{...o.meta.custom,...n}}},t);return await a.putSave(c),zb(c.meta.ifid),c}var mb=e=>e&&iv(e.payload),hb=e=>iv(e);Jy(mb);var gb=Jy(e=>e);function _b(e){return Ky(async()=>{let t=await Z(),n=await t.getSave(e);await t.deleteSave(e),n&&(await Nb(n.meta.ifid,t=>t===e),zb(n.meta.ifid))})}function vb(e,t){return Ky(async()=>{let n=await Z(),r=await n.getSave(e);if(!r)return;let i={...r,meta:{...r.meta,title:t,userTitle:!0,updatedAt:new Date().toISOString()}};await n.putSave(i),zb(i.meta.ifid)})}var yb=qy(async function(e){let t=await Z(),[n,r]=await Promise.all([t.getSavesByIfid(e),t.getPlaythroughsByIfid(e)]),i=new Map;for(let e of r)i.set(e.id,e);let a=new Map;for(let e of n){let t=e.meta.playthroughId,n=a.get(t);n?n.push(e):a.set(t,[e])}for(let e of a.values())e.sort((e,t)=>new Date(t.meta.updatedAt).getTime()-new Date(e.meta.updatedAt).getTime());let o=[],s=[...i.values()].sort((e,t)=>new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime());for(let e of s){let t=a.get(e.id)??[];o.push({playthrough:e,saves:t})}for(let[t,n]of a)i.has(t)||o.push({playthrough:{id:t,ifid:e,createdAt:n[0]?.meta.createdAt??new Date().toISOString(),label:`Unknown Playthrough`},saves:n});return o}),bb=pv.autosave,xb=pv.slot,Sb=pv.slotIndex;function Cb(e){return e!=null&&e!==``}function wb(e,t){return Cb(t)?`${xb}${t}.${e}`:`${bb}${e}`}var Tb=e=>`${Sb}${e}`;async function Eb(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 Db(e,t){let n=await Z();await Eb(`spindle-slot-index:${e}`,async()=>{let r=await n.getMeta(Tb(e))??[],i=t(r);i!==r&&await n.setMeta(Tb(e),i)})}async function Ob(e){return[void 0,...(await(await Z()).getMeta(Tb(e))??[]).filter(Cb)]}async function kb(e,t){return(await Z()).getMeta(wb(e,t))}async function Ab(e,t){let n=await kb(e,t);return n?(await Z()).getSave(n):void 0}async function jb(e,t,n){await(await Z()).setMeta(wb(e,t),n),Cb(t)&&await Db(e,e=>e.includes(t)?e:[...e,t]),zb(e)}async function Mb(e,t){await(await Z()).deleteMeta(wb(e,t)),Cb(t)&&await Db(e,e=>e.filter(e=>e!==t)),zb(e)}async function Nb(e,t){for(let n of await Ob(e)){let r=await kb(e,n);r&&t(r)&&await Mb(e,n)}}var Pb=`spindle.slots`,Fb=`*`,Ib;function Lb(){if(Ib===void 0)try{Ib=new BroadcastChannel(Pb),Ib.unref?.()}catch{Ib=null}return Ib}var Rb=new Set;function zb(e){for(let t of[...Rb])(e===Fb||t.ifid===e)&&t.onChange();try{Lb()?.postMessage(e)}catch{}}function Bb(e,t,n=!1){let r={ifid:e,onChange:t};n&&Rb.add(r);let i=Lb(),a=n=>{(n.data===e||n.data===Fb)&&t()},o=()=>{document.visibilityState===`visible`&&t()},s=typeof document>`u`?void 0:document;return i?.addEventListener(`message`,a),s?.addEventListener(`visibilitychange`,o),()=>{Rb.delete(r),i?.removeEventListener(`message`,a),s?.removeEventListener(`visibilitychange`,o)}}var Vb=e=>({isAutosave:!Cb(e),...Cb(e)?{slot:e}:{}});function Hb(e,t){return{slot:Cb(t)?t:``,title:e.meta.title,passage:e.meta.passage,createdAt:e.meta.createdAt,updatedAt:e.meta.updatedAt,custom:e.meta.custom??{}}}function Ub(e,t,n,r,i){return Ky(async()=>{let a=await t,o=await kb(e,r);if(o){let e=await pb(o,n,i,a);if(e)return e}let s=await db(e,a,n,{...Vb(r),...i});return await jb(e,r,s.meta.id),s})}async function Wb(e,t){return await Ab(e,t)!==void 0}Yy(mb);function Gb(e,t,n){return Ky(async()=>{let r=await Ab(e,t);if(!r)return;let i=iv(r.payload);n?.(i);let{playthroughId:a}=r.meta;return a&&await rb(e,a),{payload:i,playthroughId:a}})}var Kb=qy(qb);async function qb(e){let t=Object.create(null);for(let n of await Ob(e))await Wb(e,n)&&(t[n??``]=!0);return t}var Jb=qy(Yb);async function Yb(e,t){let n=await Ab(e,t);return n?Hb(n,t):null}var Xb=qy(async e=>{let t=[];for(let n of await Ob(e)){let r=await Yb(e,n);r&&t.push(r)}return t}),Zb=qy(async(e,t)=>{let n=await kb(e,t);n&&(await(await Z()).deleteSave(n),await Mb(e,t))}),Qb=`spindle.session.`;function $b(e,t){let n=JSON.stringify(Y_(t));try{sessionStorage.setItem(`${Qb}${e}`,n)}catch(e){return{error:e}}}function ex(e){try{let t=sessionStorage.getItem(`${Qb}${e}`);return t?iv(JSON.parse(t)):void 0}catch(t){t instanceof U_&&(console.warn(`spindle: ${t.message}; the session was not restored.`),tx(e));return}}function tx(e){try{sessionStorage.removeItem(`${Qb}${e}`)}catch{}}var nx=`${Qb}playthrough.`;function rx(e,t){try{sessionStorage.setItem(`${nx}${e}`,t)}catch{}}function ix(e){try{return sessionStorage.getItem(`${nx}${e}`)||void 0}catch{return}}function ax(e){if(e)return{formatVersion:1,ifid:e.meta.ifid,exportedAt:new Date().toISOString(),save:e}}var ox=Jy(ax);async function sx(e,t){if(lv(e),e.ifid!==t)throw Error(`Save is from a different story (expected IFID ${t}, got ${e.ifid})`);let n=Jv(e.save);return n.meta.id=ft(),n.meta.updatedAt=new Date().toISOString(),n.meta.ifid=t,await ib(t,n.meta.playthroughId,n.meta.createdAt),n}function cx(e,t){return Ky(async()=>{let n=await sx(e,t);return await(await Z()).putSave(n),zb(t),n})}var lx=Yy(ax);function ux(e,t,n){return Ky(async()=>{let r=await sx(e,t),{slot:i,...a}=r.meta.custom??{};r.meta.custom={...a,...Vb(n)};let o=await Z(),s=await kb(t,n);return await o.putSave(r),await jb(t,n,r.meta.id),s&&await o.deleteSave(s),Hb(r,n)})}var dx=qy(async function(e){let t=await Z(),n=await t.getSavesByIfid(e),r=await t.getPlaythroughsByIfid(e),i=0;for(let e of n)if(e.meta.estimatedBytes!=null)i+=e.meta.estimatedBytes;else{let n=dv(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 fx(e){return Ky(async()=>{let t=await Z();await t.deleteSavesByIfid(e),await t.deletePlaythroughsByIfid(e),await t.deleteMetaByIfid(e),tx(e),zb(e)})}var px=qy(mx);async function mx(){await(await Z()).destroy(),Fv();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{}zb(Fb)}function hx(e,t,n){return Ky(async()=>{let r=await Z(),i=await r.deleteSavesByPlaythrough(t);await r.deletePlaythroughById(t);let a=new Set(i);if(await Nb(e,e=>a.has(e)),zb(e),n&&await n.current===t)return await Zy(e,n.id),!0;let o=tb(e);return await r.getMeta(o)===t&&await r.deleteMeta(o),!1})}var gx=null;function _x(){gx&&(me(null,gx),gx.remove(),gx=null)}function vx(){_x();let e=Q.getState();if(!e.storyData)return;let t=e.storyData.passages.get(`StoryInit`);if(t){let e=ss(t.content);Bl(e,`StoryInit`);let n=document.createElement(`div`);n.style.display=`none`,document.body.appendChild(n),gx=n,me(b(()=>Kh(e),null),n),dC()}let n=e.storyData.passages.get(`SaveTitle`);n&&Vy(n.content)}function yx(e){vx();let t=e?JC(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),Iy(`storyinit`),e||dC()}var bx=[`variables`,`temporary`,`transient`],xx=[];function Sx(){return xx[xx.length-1]?.work}function Cx(){let e=Q.getState(),t=Sx();return t?{...e,...t}:e}var wx=e=>Jv(e,{keepUnregistered:!0});function Tx(e,t){let n=t?Oy(t,e):new Map,r=(r,i)=>{let a=t?.get(i);if(!a||!wt(r))return r;let o=An(r);return a.some(hy)||Vv(e,a,o),n.set(i,o),o};return e=>Jv(e,{keepUnregistered:!0,seen:n,settle:r})}var Ex=e=>{let t=new Map;return n=>{let r=t.get(n);return r||(r=Tx(n,e?.(n)),t.set(n,r)),r}};function Dx(e){return Wt(wx(e),!0)}function Ox(e){return e instanceof Map?!K(e,`set`):e instanceof Set?!K(e,`add`):e instanceof Date||e instanceof URL||e instanceof URLSearchParams}function kx(e,t=new Set){if(typeof e!=`object`||!e||t.has(e))return!0;if(ArrayBuffer.isView(e)||e instanceof ArrayBuffer||!Object.isFrozen(e)||Ox(e))return!1;if(t.add(e),e instanceof Map){for(let[n,r]of Xg(e))if(!kx(n,t)||!kx(r,t))return!1}else if(e instanceof Set){for(let n of Zg(e))if(!kx(n,t))return!1}return Reflect.ownKeys(e).every(n=>{let r=Object.getOwnPropertyDescriptor(e,n);return!r||!(`value`in r)||kx(r.value,t)})}function Ax(e){return kx(e)?e:Dx(e)}function jx(e,t,n=xx,r=Mx){let[i,a]=t.path;for(let o of n)for(let n of[o.work,o.base])try{jy(n,t.deleted?t:{...t,value:r(n)(t.value)})}catch{let t=e[i][a];K(e[i],a)?n[i][a]=wx(wt(t)?An(t):t):delete n[i][a]}}var Mx=e=>Tx(e),Nx=new Set(bx),Px=new On({autoFreeze:!1}),Fx=!1;function Ix(e,t){let n=[],r=e;for(let e of t){if(!cy(r))break;let t=String(e);n.push(t),r=K(r,t)?r[t]:void 0}return n}function Lx(e,t){let n=Lv(e,t.slice(0,-1)),r=t[t.length-1];return cy(n)&&K(n,r)?{path:t,deleted:!1,value:n[r]}:{path:t,deleted:!0}}function Rx(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=>Lx(t,[e]));let r=new Set,i=[];for(let e of n){let n=Ix(t,e.path.slice(1)),a=JSON.stringify(n);r.has(a)||(r.add(a),i.push(Lx(t,n)))}return i}function zx(e){if(Fx){Fx=!1;return}if(xx.length===0)return;Ux(Gx());let t=xx[xx.length-1],n={...Q.getState(),variables:t.work.variables,temporary:t.work.temporary,transient:t.work.transient},[r,i]=Px.produceWithPatches(n,e),a=bx.flatMap(e=>{let t=i.filter(t=>t.path[0]===e);return t.length?Rx(n[e],r[e],t).map(t=>({...t,path:[e,...t.path]})):[]}),o=Dy(Hx(t.work),a),s=Ex(()=>o),c=(e,t)=>e.deleted?e:{...e,value:s(t)(e.value)};for(let e of a)jy(t.work,c(e,t.work));return e=>{let i=e;for(let e of Object.keys(r)){let t=r[e];!Nx.has(e)&&t!==n[e]&&(i[e]=t)}let o=e;for(let e of a){let[n,r]=e.path;try{jy(o,c(e,o))}catch{K(t.work[n],r)?o[n][r]=wx(t.work[n][r]):delete o[n][r]}jx(o,e,xx,s)}}}function Bx(e,t,n){let r=n.map(e=>fy(e.path).slice(0,-1));for(let[n,...i]of Cy(t)){let t=[n,...i].map(e=>fy(e).slice(0,-1));if(r.some(e=>t.some(t=>e.startsWith(t))))try{let t=_y(e,n);if(typeof t!=`object`||!t)continue;for(let n of i)Ay(e,n,t)}catch{}}}function Vx(e){let t=new Map;return{variables:Jv(e.variables,{keepUnregistered:!0,seen:t}),temporary:Jv(e.temporary,{keepUnregistered:!0,seen:t}),transient:Jv(e.transient,{keepUnregistered:!0,seen:t})}}var Hx=e=>({variables:e.variables,temporary:e.temporary,transient:e.transient});function Ux(e){let t=e.map(({scope:e,keepRunning:t})=>({scope:e,keepRunning:t,changes:Wx(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=Vx(e.work));Fx=!0;try{Q.getState().updateVariables(r)}finally{Fx=!1}function r(e){t.forEach(({scope:n,changes:r},i)=>{let a=Dy(n.work,r),o=Tx(e,a),s=t.slice(0,i).map(e=>e.scope),c=Ex(()=>a),l=new Set;for(let t of r){let[r,i]=t.path,a=fy([r,i]);if(!l.has(a))try{if(t.deleted){ky(e,t)||jy(e,t);continue}let n=t.alias?o(t.value):void 0;if(t.alias?Object.is(Lv(e,t.path),n):ky(e,t))continue;jy(e,{...t,value:t.alias?n:o(t.value)})}catch{e[r][i]=o(n.work[r][i]),l.add(a)}}Bx(e,n.work,r);for(let t of r)jx(e,t,s,c)})}}var Wx=(e,t)=>Ey(e,t),Gx=()=>xx.map(e=>({scope:e,keepRunning:!0}));function Kx(e){let t=Q.getState(),n=Hx(t),r=Ey(e.base,n),i=Tx(e.work,Dy(n,r));for(let t of r)try{jy(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=Vx(t)}function qx(e){if(xx.length===0)return e();Ux(Gx());let t=xx.splice(0);try{return e()}finally{xx.push(...t);for(let e of t)Kx(e)}}function Jx(e){Ux(Gx());let t=Dy(Hx(Sx()??Q.getState()),[]),n=Yx(),r=Tx(n.work,t);try{e(n.work,r)}finally{xx.pop()}Ux([...Gx(),{scope:n,keepRunning:!1}])}function Yx(){let e=Sx()??Q.getState(),t={work:Vx(e),base:Vx(e)};return xx.push(t),t}function Xx(e,t,n){let r=ws(Jv(t,{keepUnregistered:!0})),i=Yx();try{zu(e,i.work.variables,i.work.temporary,r,i.work.transient)}finally{xx.pop()}Ux([...Gx(),{scope:i,keepRunning:!1}]);let a=new Set(Ey(t,r,!0).map(e=>e.path[0]));for(let e of Cy(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 Zx=[],Qx=!1,$x=[],eS=null,tS=null;function nS(e){let t=Cx();try{return!!Ru(e,t.variables,t.temporary,{},t.transient)}catch{return!1}}function rS(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:nS(e),priority:i?.priority??0,macroKey:n};return Zx.push(o),Zx.sort((e,t)=>t.priority-e.priority),()=>{Zx=Zx.filter(e=>e!==o)}}function iS(e,t){return rS(e,t)}function aS(e,t){let n=Object.fromEntries(Object.entries(t).sort(([e],[t])=>e<t?-1:1)),r=JSON.stringify([e,n]);Zx.some(e=>e.macroKey===r)||rS(e,t,r)}function oS(){return Zx.filter(e=>e.macroKey!==void 0&&e.options).map(e=>({condition:e.condition,options:{...e.options}}))}var sS=new Set,cS=0;function lS(e,t){let n={condition:e,options:t};return sS.add(n),()=>{sS.delete(n)}}function uS(){return cS++,()=>{cS--}}function dS(){return cS>0}function fS(e,t){Zx=Zx.filter(e=>e.macroKey===void 0);for(let{condition:t,options:n}of e)aS(t,n);if(t===!1)for(let{condition:e,options:t}of sS)aS(e,t)}function pS(e){Zx=Zx.filter(t=>t.name!==e)}function mS(e){let{callback:t,options:n}=e;if(t)t();else if(n){if(n.run)try{Xx(n.run,{},()=>{})}catch(t){console.error(`spindle: Error in watch run action for \"${e.condition}\":`,t)}n.dialog&&($x.push({passageName:n.dialog}),eS?.()),n.goto&&Q.getState().navigate(n.goto)}}var hS=10;function gS(){for(let e=0;e<hS;e++){let e=!1,t=[...Zx];for(let n of t){if(!Zx.includes(n))continue;let t=nS(n.condition),r=!n.lastResult;n.lastResult=t,t&&r&&(e=!0,n.options?.once&&(Zx=Zx.filter(e=>e!==n)),mS(n))}if(!e)break}}function _S(){if(!Qx){Qx=!0;try{gS()}finally{Qx=!1}}}var vS=0;function yS(){if(vS===0)return;let e=Qx;Qx=!0;try{gS()}finally{Qx=e}}function bS(){let e=Q.getState();vS++;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)&&_S()}),n=!0;return()=>{n&&(n=!1,vS--,t())}}function xS(){for(let e of Zx)e.lastResult=nS(e.condition)}function SS(){Zx=[],CS++,IS(),wS.notify()}var CS=0,wS=Ls();function TS(){return CS}var ES=wS.subscribe;function DS(e){return eS=e,$x.length>0&&e(),()=>{eS===e&&(eS=null)}}function OS(){return $x.shift()}function kS(){return $x.length}function AS(e){tS?tS.push(e):($x.push(e),eS?.())}function jS(){$x=[]}function MS(e){return tS=e,()=>{tS===e&&(tS=null)}}var NS=[];function PS(e){return NS.push(e),()=>{let t=NS.lastIndexOf(e);t>=0&&NS.splice(t,1)}}function FS(){let e=NS[NS.length-1];e?e():tS?.close()}function IS(){jS();for(let e of[...NS].reverse())e();tS?.closeAll()}function LS(){return NS.length>0||(tS?.isOpen()??!1)}Mn(),Fn();var RS=new Set([`StoryInit`,`StoryInterface`,`StoryVariables`,`StoryTransients`,`StoryLoading`,`SaveTitle`,`PassageReady`,`PassageHeader`,`PassageFooter`,`PassageDone`]),zS=Ss(),BS=[],VS=Ss();function HS(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:Jv(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(Jv(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 US(e,t){let n=Object.create(Object.getPrototypeOf(e));for(let t of Object.keys(e))bs(n,t,e[t]);for(let e of t)e.deleted?delete n[e.key]:bs(n,e.key,e.value);return n}function WS(e){let t=BS.length-1;t<0?zS=e:BS[t]=HS(qS(t),e)}function GS(e,t){let n=zS;for(let r=0;r<e;r++)r>0&&(n=US(n,BS[r-1].forward)),t(n,r)}function KS(e,t){return{passage:e.passage,variables:t,timestamp:e.timestamp,prng:e.prng}}function qS(e){let t=zS;for(let n=0;n<e;n++)t=US(t,BS[n].forward);return t}var JS=[];function YS(e){let{storyData:t,currentPassage:n,variables:r,history:i,historyIndex:a,visitCounts:o,renderCounts:s}=e();if(t){if(JS.length>i.length&&(JS.length=i.length),JS.length<i.length){if(i.length-JS.length===1){let e=i.length-1;JS[e]=KS(i[e],r)}else GS(i.length,(e,t)=>{t>=JS.length&&(JS[t]=KS(i[t],e))})}return $b(t.ifid,{passage:n,variables:r,history:JS,historyIndex:a,visitCounts:o,renderCounts:s,prng:pu(),watchers:oS(),interfaceWatchers:dS()})}}var XS=`The game could not be saved for a page reload; a reload goes back to the last passage it could save:`,ZS=`The story could not go to another passage:`;function QS(e,t){let n;try{let t=YS(e);t&&Hs(XS,t.error)}catch(e){n={error:e},Hs(XS,e)}try{t?.()}finally{if(n)throw n.error}}function $S(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++)zS=US(zS,BS[e].forward);return e.history=e.history.slice(n,r),BS=BS.slice(n,r-1),JS=JS.slice(n,r),e.historyIndex-=n,!0}var eC=!1,tC=[],nC=null;function rC(e,t){let n=nC;if(nC=null,!n||e().navigationId!==n.navigationId)return;e().variables!==n.variables&&WS(e().variables),VS=e().variables;let r=pu(),i=e().history[e().historyIndex].prng;(r?.seed!==i?.seed||r?.pull!==i?.pull)&&t(e=>{e.history[e.historyIndex].prng=r})}var iC=e=>({...e});function aC(e){zS=e,BS=[],VS=e,JS=[]}function oC(e){let t=Ss(Jv(e));return aC(Jv(t)),t}function sC(e){return Ss(Jv(e,{keepUnregistered:!0}))}function cC(e,t,n,r){e.currentPassage=t,e.navigationId++,e.variables=n,e.transient=sC(r),e.temporary=Ss(),e.history=[{passage:t,timestamp:Date.now()}],e.historyIndex=0}function lC(e){let t=TC;return e(),TC!==t}function uC(e,t,n){let{historyIndex:r,history:i}=e(),a=r+n;if(a<0||a>=i.length)return;rC(e,t);let o=e().currentPassage,s=i[a].passage,c=e().navigationId;if(Iy(`beforenavigate`,s),e().navigationId!==c)return;let l=Jv(qS(a));t(e=>{e.historyIndex+=n,e.currentPassage=e.history[e.historyIndex].passage,e.navigationId++,e.variables=l,e.temporary=Ss()}),xS(),VS=e().variables,qC(e().history[e().historyIndex]),fu(),QS(e,()=>Iy(`afternavigate`,s,o))}function dC(){let{history:e,historyIndex:t,variables:n}=Q.getState();if(e.length!==1||t!==0)return;aC(n);let r=pu();Q.setState(e=>{e.history[0].prng=r}),fu()}var fC=Promise.resolve(``),pC=0,mC=!1;function hC(){return mC?``:Q.getState().playthroughId}function gC(){if(_C)return _C;let e=hC();return fC.then(t=>e||t)}var _C=null;function vC(e){Q.getState().playthroughId!==e&&Q.setState(t=>{t.playthroughId=e})}function yC(e){let t=++pC;return mC=!0,fC=e.then(e=>(t===pC&&(mC=!1,vC(e)),e)),fC}function bC(e,t){++pC,mC=!1,fC=t.then(()=>e,()=>e),vC(e)}function xC(e){let t=ft();bC(t,Xy(e,t).catch(e=>{console.error(`spindle: failed to start new playthrough`,e)}))}function SC(e,t){hC()!==t&&bC(t,nb(e,t).catch(e=>{console.error(`spindle: failed to switch to the loaded playthrough`,e)}))}async function CC(e,t){let n=t?.meta.playthroughId,r=await e;n&&n!==r&&hC()===r&&bC(n,Promise.resolve())}var wC=0,TC=0,EC=null,DC=null;function OC(){return++wC}function kC(e){return TC>e}function AC(){MC(++wC)}var jC=Ls();function MC(e){TC=e,jC.notify()}var NC=jC.subscribe,PC=[],FC=!1;function IC(e){FC&&PC.push(e)}function LC(){FC=!0}function RC(){for(let e of PC)e();PC=[],FC=!1}function zC(e){return typeof e==`string`&&e!==``?e:null}function BC(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}var VC=null;function HC(e){VC?.set(fy(e),e)}function UC(e,t,n,r){let i=e.history[e.historyIndex];if(!i)return;let a=Ey(t,n,!0),o=new Set(a.map(e=>fy(e.path)));for(let e of r){if(py(e,o))continue;o.add(fy(e));let t=Lv(n,e);Yv(Lv(i.variables,e),t)||a.push({path:e,deleted:!1,value:t,absolute:!0})}if(a.length===0)return;let s=Jv(i.variables),c=Oy(Dy(n,a),s),l=e=>Jv(e,{seen:c});for(let e of a)WC(s,n,e,l);i.variables=$v(i.variables,s)}function WC(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=Lv(t,i.slice(0,o+1));if(!ly(n,s,!0)){GC(a,e,r(s));return}a=n}let s=i[o];n.deleted?GC(a,s,void 0,n):GC(a,s,r(n.value),n)}function GC(e,t,n,r){let i=r?.deleted??!1;if(Array.isArray(e)&&(t===`length`||Gg(t))){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)):r&&`absolute`in r?t===`length`?e.length=n:e[a]=n:t===`length`&&r?e.length+=n:a<e.length&&(e[a]=n)}else i?delete e[t]:bs(e,t,n)}function KC(e){e?su(e.seed,e.pull):lu()}function qC(e){e&&KC(e.prng)}function JC(e,t){if(e)return[t.passage,...t.history.map(e=>e.passage)].find(t=>!e.passages.has(t))}function YC(e,t){let n=JC(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 XC=[`variables`,`temporary`,`transient`];function ZC(e){for(let t of XC){let n=e[t];Cs(n)||(e[t]=Ss(wt(n)?An(n):n))}}var QC=[`navigate`,`goBack`,`goForward`,`restart`,`save`,`load`,`getSavePayload`,`loadFromPayload`];function $C(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=zx(r);t(e=>{(i??r)(e),ZC(e)})});r.setState=i;let a=e(i,n,r);for(let e of QC){let t=a[e];a[e]=(...e)=>qx(()=>t(...e))}return a}}var ew=e=>Ln($C(e));function tw(e){return e.catch(()=>{}),e}function nw(e,t,n){return tw(e.catch(e=>{throw console.error(t,e),n?.(e),e}))}function rw(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 iw(e,t){return Kb(t).then(t=>{e(e=>{e.knownSaves=t})})}var aw;function ow(e,t,n,r){let i=n.then(()=>{t(e=>{e.knownSaves={}})});return e().restart(),nw(i,r)}var Q=dt()(ew((e,t)=>({storyData:null,currentPassage:``,navigationId:0,variables:Ss(),variableDefaults:{},transient:Ss(),transientDefaults:{},temporary:Ss(),history:[],historyIndex:-1,visitCounts:As(),renderCounts:As(),knownSaves:{},playthroughId:``,maxHistory:40,quickSaveKey:`F6`,quickLoadKey:`F9`,saveError:null,loadError:null,transitionConfig:null,nextTransition:null,nobr:!1,renderDeferred:!1,setMaxHistory:n=>{let r=!1;e(e=>{e.maxHistory=Math.max(1,Math.round(n)),r=$S(e)}),r&&QS(t)},setQuickSaveKey:t=>{e(e=>{e.quickSaveKey=zC(t)})},setQuickLoadKey:t=>{e(e=>{e.quickLoadKey=zC(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=oC(r);e(e=>{e.storyData=n,e.playthroughId=``,e.variableDefaults=r,e.transientDefaults=i,cC(e,a.name,o,i),e.visitCounts=As(null,a.name),e.renderCounts=As(null,a.name)}),VS=t().variables,AC(),yC(sb(n.ifid).then(({id:t,knownSaves:n})=>(e(e=>{e.knownSaves=n}),t)).catch(e=>(console.error(`spindle: failed to init save system`,e),``))),aw?.(),aw=Bb(n.ifid,()=>{iw(e,n.ifid).catch(()=>{})})},navigate:n=>{if(eC){tC.push(n);return}let{storyData:r}=t();if(!r)return;if(RS.has(n)){console.error(`spindle: Cannot navigate to special passage \"${n}\".`);return}if(!r.passages.has(n)){let e=Us(n,t().currentPassage);console.error(`spindle: ${e.message}`),Hs(ZS,e);return}let i=t().currentPassage;if(lC(()=>Iy(`beforenavigate`,n)))return;let a=HS(VS,t().variables);e(e=>{e.temporary=Ss(),e.currentPassage=n,e.navigationId++,e.history=e.history.slice(0,e.historyIndex+1),BS.length=e.historyIndex,JS.length>e.historyIndex+1&&(JS.length=e.historyIndex+1),BS.push(a),e.history.push({passage:n,timestamp:Date.now(),prng:pu()}),e.historyIndex=e.history.length-1,$S(e),e.visitCounts=As(e.visitCounts,n),e.renderCounts=As(e.renderCounts,n)}),nC={navigationId:t().navigationId,variables:t().variables},eC=!0;try{yS()}finally{eC=!1}let o=tC;tC=[],rC(t,e),fu(),QS(t,()=>{if(!lC(()=>Iy(`afternavigate`,n,i)))for(let e of o)t().navigate(e)})},goBack:()=>uC(t,e,-1),goForward:()=>uC(t,e,1),setVariable:(t,n)=>{e(e=>{_s(t,`$${t}`),e.variables[t]=n})},setTemporary:(t,n)=>{e(e=>{_s(t,`_${t}`),e.temporary[t]=n})},deleteVariable:t=>{e(e=>{_s(t,`$${t}`),delete e.variables[t]})},deleteTemporary:t=>{e(e=>{_s(t,`_${t}`),delete e.temporary[t]})},setTransient:(t,n)=>{e(e=>{_s(t,`%${t}`),e.transient[t]=n})},deleteTransient:t=>{e(e=>{_s(t,`%${t}`),delete e.transient[t]})},updateVariables:t=>{e(e=>{t(e)})},trackRender:t=>{e(e=>{e.renderCounts=As(e.renderCounts,t)})},restart:()=>{let{storyData:n,variableDefaults:r,transientDefaults:i}=t();if(!n)return;let a=n.passagesById.get(n.startNode);if(!a)return;e(e=>{e.renderDeferred=!1}),Iy(`beforerestart`),xC(n.ifid),AC();let o=t().renderDeferred;RC(),lu(),SS();let s=oC(r);e(e=>{cC(e,a.name,s,i),e.visitCounts=As(null,a.name),e.renderCounts=As(null,a.name),o||(e.renderDeferred=!1)}),VS=t().variables,LC(),vx(),tx(n.ifid),Iy(`storyinit`),dC()},save:(n,r)=>{let{storyData:i}=t();if(!i)return Promise.resolve();let a=gC();return nw(cb(n,r,t().beginSave,async t=>{e(e=>{e.saveError=null});let o=await Ub(i.ifid,a,t,n,r);await CC(a,o),rw(e,n,!0)}),`spindle: failed to save`,t=>e(e=>{e.saveError=Is(t,`Failed to save`)}))},load:n=>{let{storyData:r}=t();if(!r)return Promise.resolve();e(e=>{e.loadError=null});let i=gC(),a=Gb(r.ifid,n,e=>YC(r,e)),o=yC(Promise.all([i,a.catch(()=>void 0)]).then(([e,t])=>t?.playthroughId||e)),s=++wC;return nw(a.then(async e=>{await o,e&&(TC>s||(EC=s,DC=i,t().loadFromPayload(e.payload,n)))}),`spindle: failed to load save`,t=>e(e=>{e.loadError=Is(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?Jb(n.ifid,e):null},listSaves:async()=>{let{storyData:e}=t();return e?Xb(e.ifid):[]},deleteSave:n=>{let{storyData:r}=t();return r?nw(Zb(r.ifid,n).then(()=>rw(e,n,!1)),`spindle: failed to delete save`):Promise.resolve()},exportSave:async e=>{let{storyData:n}=t();return n?await lx(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 ux(n,i.ifid,r);return rw(e,r,!0),a},clearGameData:()=>{let{storyData:n}=t();return n?ow(t,e,fx(n.ifid),`spindle: failed to clear game data`):Promise.resolve()},clearAllData:()=>ow(t,e,px(),`spindle: failed to clear all data`),deletePlaythrough:n=>{let{storyData:r}=t();if(!r)return Promise.resolve();let i=r.ifid,a=hC(),o=fC,s=ft(),c=hx(i,n,{current:a||o,id:s});return n!==``&&n===a?bC(s,c):a===``&&yC(c.then(e=>e?s:o,()=>o)),nw(c.then(()=>iw(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 GS(r.length,(e,t)=>{let n=iC(e);s.push(KS(r[t],t===0?n:$v(s[t-1].variables,n)))}),{passage:e,variables:$v(s[i]?.variables,iC(n)),history:s,historyIndex:i,visitCounts:{...a},renderCounts:{...o},prng:pu(),watchers:oS(),interfaceWatchers:dS()}},beginSave:()=>{let e=t().variables,n=TC,r=new Map;return VC=r,()=>{if(VC===r&&(VC=null),TC!==n)throw Error(`spindle: a beforesave handler restarted or loaded the game, so the save was not made`);let i=t().getSavePayload();return UC(i,e,t().variables,[...r.values()]),i}},loadFromPayload:(n,r,i,a)=>{let o=EC??a;EC=null;let s=DC;DC=null;let c=o??++wC;if(n.history.length===0){console.warn(`loadFromPayload: rejecting payload with empty history`);return}YC(t().storyData,n),MC(c),_C=s;try{Iy(`beforeload`,r)}finally{_C=null}if(TC!==c)return;let l=t().storyData?.ifid;i&&l&&SC(l,i);let u=BC(n),d=Jv(n.history.map(e=>e.variables)).map(e=>Ss(e));zS=Jv(d[0]),BS=d.slice(1).map((e,t)=>HS(d[t],e)),JS=n.history.map((e,t)=>KS(e,d[t])),e(e=>{e.currentPassage=n.passage,e.navigationId++,e.variables=Ss(Jv(u?.variables??n.variables)),e.history=n.history.map(e=>({passage:e.passage,timestamp:e.timestamp,prng:e.prng})),e.historyIndex=Math.max(0,Math.min(n.historyIndex,e.history.length-1)),$S(e),e.visitCounts=As(n.visitCounts),e.renderCounts=As(n.renderCounts),e.temporary=Ss(),e.transient=sC(t().transientDefaults)}),n.watchers&&fS(n.watchers,n.interfaceWatchers),xS(),VS=qS(t().historyIndex),KC(u?.prng===void 0?n.prng:u.prng),fu(),QS(t,()=>du(()=>Iy(`afterload`,r)))},getHistoryVariables:e=>Jv(qS(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})}}))),sw=`<header class=\"story-menubar\">{story-title}{back}{forward}{restart}{quicksave}{quickload}{saves}{settings}</header>\n{passage}`;function cw(){let{storyData:e}=Jl(`storyData`),t=e?.passages.get(`StoryInterface`),n=t===void 0?sw:t.content,r=t?.tags.includes(`nobr`)??!1,i=Fe(()=>{try{return q(S,{children:Rh(ss(n))})}catch(e){return q(`span`,{class:`error`,children:[`Error in StoryInterface: `,Is(e)]})}},[n]);return Pe(uS,[]),q(zm.Provider,{value:!0,children:r?q(Rm.Provider,{value:!0,children:i}):i})}var lw=[`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 uw(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 dw(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!uw(e)}function fw(e){return!e.hidden&&!e.closest(`[hidden], [inert]`)&&!e.matches(`:disabled`)&&dw(e)}function pw(e){let t=e.getAttribute(`tabindex`);return t===null||!/^\\s*[+-]?\\d+\\s*$/.test(t)?null:parseInt(t,10)}function mw(e){let t=pw(e);if(t!==null&&t<0||t===null&&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}let n=e;if(e.localName===`input`&&n.type===`radio`&&n.name){let t=Array.from((n.form??e.getRootNode()).querySelectorAll(`input[type=\"radio\"]`)).filter(e=>e.name===n.name&&e.form===n.form&&(pw(e)??0)>=0&&fw(e));return e===(t.find(e=>e.checked)??t[0])}return!0}function hw(e){let t=Array.from(e.querySelectorAll(lw)).filter(e=>fw(e)&&mw(e)),n=e=>Math.max(pw(e)??0,0);return[...t.filter(e=>n(e)>0).sort((e,t)=>n(e)-n(t)),...t.filter(e=>n(e)===0)]}var gw=[],_w=new Set([`date`,`time`,`datetime-local`,`month`,`week`]);function vw(e){if(!e)return!1;if(e.localName===`audio`||e.localName===`video`)return e.controls;let t=e;return e.localName===`input`&&_w.has(t.type)&&!t.readOnly}function yw(e){return e.localName===`iframe`}function bw(e){try{return e.contentDocument}catch{return null}}function xw(e){try{return e.defaultView?.frameElement}catch{return null}}function Sw(e,t,n,r){let i=n?e.indexOf(n):-1;if(i!==-1)return e[i+(r?-1:1)];if(n&&n!==t&&t.contains(n)){let t=e=>!!(n.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_FOLLOWING);return r?e.filter(e=>!t(e)).pop():e.find(t)}return r?e[e.length-1]:e[0]}function Cw(){let e=[],t=document;for(;t;){let n=t.activeElement;if(!n||e.length>0&&n===t.body||typeof n.focus!=`function`)break;e.push(n),t=yw(n)?bw(n):null}return e}function ww(e){return e.isConnected&&!!e.ownerDocument.defaultView}function Tw(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(ww(n)){n.focus();return}}}function Ew(e,t,n,r){Pe(()=>{let n=e.current;if(!n)return;let r={panel:n,opener:Cw()};gw.push(r);let i=n.querySelector(t)??n;return(Array.from(n.querySelectorAll(`[autofocus]`)).find(fw)??hw(i)[0]??n).focus(),()=>{let e=gw.indexOf(r);e!==-1&&gw.splice(e,1);for(let t of gw.slice(e===-1?gw.length:e)){let[e]=t.opener;(!e||n.contains(e)||!t.opener.some(ww))&&(t.opener=r.opener)}let t=document.activeElement;(!t||t===document.body||n.contains(t))&&Tw(r.opener)}},[]),Pe(()=>{let t=e.current;if(!t)return;let i=()=>gw[gw.length-1]?.panel===t,a=(e,t)=>{if(yw(e)){let n=bw(e),r=n?hw(n):[],i=t?r[r.length-1]:r[0];if(i)return a(i,t)}e.focus()},o=(e,n)=>{let r=e?.ownerDocument,i=r&&r!==document?xw(r):null;if(r&&i){let t=Sw(hw(r),r,e,n);t?a(t,n):o(i,n);return}let s=hw(t),c=s[0],l=s[s.length-1];if(!c||!l){t.focus();return}let u=Sw(s,t,e,n);a(u??(n?l:c),n)},s=null,c=(e,t)=>a=>{if(!i())return;if(a.key===`Escape`){if(!n)return;a.preventDefault(),a.stopPropagation(),r();return}if(a.key!==`Tab`)return;let c=e.activeElement;if(t){s=null;let t=hw(e),n=a.shiftKey?t[0]:t[t.length-1];if(n&&c!==n&&c!==e.body)return}vw(c)?s={el:c,from:t??c,backwards:a.shiftKey}:(a.preventDefault(),o(t??c,a.shiftKey))},l=()=>{s=null},u=e=>{let n=e.target;if(s&&n!==s.el&&i()){let{from:e,backwards:t}=s;s=null,o(e,t)}else i()&&n instanceof Node&&!t.contains(n)&&n!==document.body&&n!==document.documentElement&&o(null,!1)},d=e=>{let t=s;t&&e.target===t.el&&!e.relatedTarget&&i()&&(s=null,o(t.from,t.backwards))},f=new AbortController,{signal:p}=f,m=(e,t)=>{e.addEventListener(`keydown`,c(e,t),{signal:p}),e.addEventListener(`pointerdown`,l,{capture:!0,signal:p}),e.addEventListener(`focusout`,d,{signal:p})},h=new Map,g=[],_=e=>{let t=bw(e);t&&h.get(e)!==t&&(h.set(e,t),m(t,e),v(t))},v=e=>{let t=()=>e.querySelectorAll(`iframe`).forEach(_);e.addEventListener(`load`,e=>{e.target instanceof Node&&yw(e.target)&&_(e.target)},{capture:!0,signal:p});let n=new MutationObserver(t);n.observe(e,{childList:!0,subtree:!0}),g.push(n),t()};return v(t),m(document,null),document.addEventListener(`focusin`,u,{signal:p}),()=>{f.abort(),g.forEach(e=>e.disconnect())}},[n,r])}var Dw=[`target`,`variable`,`options`,`value`,`disabled`],Ow=new Map,kw=new Map,Aw=new Set;function jw(e,t,n){if(n)return Aw.add(n),n;let r=`${e}:${t}`,i=kw.get(r)??0,a;do i++,a=i===1?r:`${r}:${i}`;while(Ow.has(a)||Aw.has(a));return kw.set(r,i),Aw.add(a),a}function Mw(e){let t=e.id,n={action:e},r=Ow.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)):Ow.set(t,[n]),Bw(),{update(e){let r=Ow.get(t);r?.includes(n)&&(n.action=e,r[r.length-1]===n&&Bw())},unregister(){let e=Ow.get(t),r=e?e.indexOf(n):-1;e&&r!==-1&&(e.splice(r,1),e.length===0&&(Ow.delete(t),Aw.delete(t)),r===e.length&&Bw())}}}var Nw=new Set;function Pw(e,t){let n=e.perform(t);if(!n||typeof n.then!=`function`)return n;let r=()=>void Nw.delete(n);return Nw.add(n),n.then(r,r),n.then(e=>e)}async function Fw(){for(;Nw.size>0;)await Promise.allSettled(Nw)}function Iw(){return Array.from(Ow.values(),Rw)}function Lw(e){let t=Ow.get(e);return t&&Rw(t)}function Rw(e){return e[e.length-1].action}function zw(){kw.clear();for(let e of Aw)Ow.has(e)||Aw.delete(e)}function Bw(){Iy(`actionsChanged`)}function Vw(e){let t=A(``),n=A(e.perform);n.current=e.perform,t.current||(t.current=jw(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 Dw)e[n]!==void 0&&Object.assign(t,{[n]:e[n]});return t},a=A(null);Pe(()=>{let e=Mw(i());return a.current=e,()=>e.unregister()},[r]);let o=A(!1);return Pe(()=>{o.current?a.current?.update(i()):o.current=!0},[e.type,e.label,e.target,e.variable,e.disabled,e.value,JSON.stringify(e.options)]),r}var Hw=he(null);function Uw({passageName:e,fallbackMarkup:t,panelClass:n,onClose:r,label:i,dismissible:a=!0,showCloseButton:o=a}){let s=A(r);s.current=r;let c=Ie(()=>s.current(),[]),{storyData:l}=Jl(`storyData`),u=e?l?.passages.get(e):void 0,d=u?.content??t,f=u?.tags.includes(`nobr`)??!1,p=Fe(()=>{if(!d)return q(`div`,{class:`error`,children:`Dialog: no content available`});try{let e=Kh(ss(d),f?{nobr:!0}:void 0);return f?q(Rm.Provider,{value:!0,children:e}):e}catch(e){return q(`div`,{class:`error`,children:[`Error in dialog: `,Is(e)]})}},[d,f]),m=A(null),h=Le(),g=Gm();Ew(m,`.dialog-body`,a,c),Pe(()=>PS(c),[c]),Pe(()=>{let e=m.current;if(!e||i)return;let t=e.querySelector(`.dialog-body :is(h1, h2, h3, h4, h5, h6)`);if(t)return t.id||(t.id=`${h}-heading`),e.setAttribute(`aria-labelledby`,t.id),()=>e.removeAttribute(`aria-labelledby`)},[i,d]),Pe(()=>{m.current&&Ly(`dialogrender`,e??``,m.current)},[]);let _=e=>{a&&e.target===e.currentTarget&&c()},v=n?`dialog-panel ${n}`:`dialog-panel`;return q(Hw.Provider,{value:c,children:q(`div`,{class:`dialog-overlay`,onClick:_,children:q(`div`,{ref:m,class:v,role:`dialog`,\"aria-modal\":`true`,\"aria-label\":i??e,tabIndex:-1,children:[o&&q(Ww,{dialogName:e??i??`dialog`,passageName:e,onClose:c}),q(`div`,{class:`dialog-body`,children:q(Um.Provider,{value:g,children:p})})]})})})}function Ww({dialogName:e,passageName:t,onClose:n}){return Vw({type:`close-dialog`,key:e,label:`Close`,target:t,perform:n}),q(`button`,{type:`button`,class:`dialog-close`,\"aria-label\":`Close`,onClick:n,children:`✕`})}function Gw(){let[e,t]=je([]),n=A(e);n.current=e;let r=Ie(e=>{t(t=>[...t,e])},[]),i=Ie(()=>{t(e=>e.slice(0,-1))},[]),a=Ie(()=>{t([])},[]);return Ne(()=>MS({close:i,closeAll:a,push:r,isOpen:()=>n.current.length>0}),[i,a,r]),Ne(()=>DS(()=>{let e=[];for(;kS()>0;){let t=OS();t&&e.push(t)}e.length>0&&t(t=>[...t,...e])}),[]),e.length===0?null:q(S,{children:e.map((e,t)=>q(Uw,{passageName:e.passageName,panelClass:e.panelClass,onClose:i,showCloseButton:e.showCloseButton,dismissible:e.dismissible},`${e.passageName}-${t}`))})}function Kw(){let[e,t]=je(Gs);return Ne(()=>(t(Gs()),Ks(()=>t(Gs()))),[]),e.length===0?null:q(`div`,{class:`spindle-error-banners`,children:e.map(e=>q(`div`,{class:`spindle-error-banner`,role:`alert`,children:[q(`span`,{class:`spindle-error-banner-context`,children:e.context}),` `,q(`span`,{class:`spindle-error-banner-message`,children:e.message}),e.count>1&&q(`span`,{class:`spindle-error-banner-count`,children:` (×${e.count})`}),q(`button`,{type:`button`,class:`spindle-error-banner-dismiss`,\"aria-label\":`Dismiss`,onClick:()=>Ws(e.id),children:`✕`})]},e.id))})}async function qw(){try{await Q.getState().save()}catch(e){Hs(`The game could not be saved:`,e)}}async function Jw(){try{await Q.getState().load()}catch(e){Hs(`The saved game could not be loaded:`,e)}}function Yw(){let{storyData:e,currentPassage:t,nobr:n}=Jl(`storyData`,`currentPassage`,`nobr`);if(Ne(()=>{let e=e=>{let{quickSaveKey:t,quickLoadKey:n}=Q.getState();t!==null&&e.key===t?(e.preventDefault(),qw()):n!==null&&e.key===n&&(e.preventDefault(),Jw())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[]),!e||!t)return q(`div`,{class:`loading`,children:`Loading...`});let r=q(S,{children:[q(cw,{}),q(Gw,{}),q(Kw,{})]});return q(Rm.Provider,{value:n,children:r})}var Xw=`http://www.w3.org/1999/xhtml`,Zw=new Set([`area`,`base`,`basefont`,`bgsound`,`br`,`col`,`embed`,`frame`,`hr`,`img`,`input`,`keygen`,`link`,`meta`,`param`,`source`,`track`,`wbr`]);function Qw(e,t=!1){let n=t&&!iT(e),r=``;for(let t of Array.from(e.childNodes))if(t.nodeType===Node.TEXT_NODE){let{data:e}=t;r+=n?aT(e,!1,rT):e}else t.nodeType===Node.COMMENT_NODE?r+=`\\x3C!--${t.data}-->`:t.nodeType===Node.ELEMENT_NODE&&(r+=$w(t));return r}function $w(e){let t=e.localName,n=`<${t}`;for(let t of Array.from(e.attributes))n+=` ${t.name}=${eT(t.name,t.value)}`;if(n+=`>`,e.namespaceURI===Xw&&Zw.has(t))return n;let r=t===`template`?e.content:e;return`${n}${Qw(r,!0)}</${t}>`}function eT(e,t){let n=ts(e),r=n?`on`:`a`,i=e=>{let t;try{t=ls(`<i ${r}=${e}>`)}catch(e){if(e instanceof is)return!1;throw e}let n=t[0];return t.length===1&&n?.type===`html`&&n.attributes[r]===e.slice(1,-1)},a=aT(t,n,nT);return[`\"${a}\"`,`'${a}'`].find(i)??`\"${aT(a,n,tT)}\"`}var tT=e=>e.replace(/\"/g,`&quot;`),nT=e=>e.replace(/&/g,`&amp;`),rT=e=>nT(e).replace(/</g,`&lt;`);function iT(e){return e.localName===`style`&&e.namespaceURI===Xw}function aT(e,t,n){if(t)return ns(e).map(e=>`text`in e?n(e.text):`expr`in e?`{${e.expr}}`:e.verbatim).join(``);let r;try{r=ls(e,{text:!0})}catch(t){if(t instanceof is)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 oT(){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=Qw(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 sT=new Map,cT=Ss(),lT=!1,uT=null,dT=new Set;function fT(e){return dT.add(e),()=>dT.delete(e)}function pT(){return`spindle.${Q.getState().storyData?.ifid||`unknown`}.settings`}function mT(){try{localStorage.setItem(pT(),JSON.stringify(cT))}catch{}}function hT(){if(!lT){if(!Q.getState().storyData?.ifid)uT||(uT=Q.subscribe(e=>{e.storyData?.ifid&&(uT?.(),uT=null,hT())}));else{lT=!0;try{let e=localStorage.getItem(pT());if(e){let t=JSON.parse(e);typeof t==`object`&&t&&!Array.isArray(t)&&(cT=Ss(cT,t))}}catch{}}}}function gT(e,t){sT.set(e,t),K(cT,e)||(cT[e]=t.config.default),hT()}function _T(e,t){let n=ys(cT,e);return typeof n==typeof t?n:t}var vT={addToggle(e,t){gT(e,{type:`toggle`,config:t})},addList(e,t){gT(e,{type:`list`,config:t})},addRange(e,t){gT(e,{type:`range`,config:t})},get(e){return ys(cT,e)},getToggle(e){return _T(e,!1)},getList(e){return _T(e,``)},getRange(e){return _T(e,0)},set(e,t){cT[e]=t,mT();for(let e of[...dT])e()},getAll(){return{...cT}},getDefinitions(){return sT},hasAny(){return sT.size>0}},yT=0,bT=4096,xT=[];function ST(e){xT.push({version:++yT,path:e}),xT.length>bT&&xT.shift()}function CT(e){ST([`variables`,...e])}var wT=he(!1),TT=[`variables`,`temporary`,`transient`];function ET(e){let t=Cx();try{e()}finally{let e=Cx();for(let n of TT)if(t[n]!==e[n])for(let{path:r}of dy(t[n],e[n],!0))ST([n,...r])}}function DT(){return yT}function OT(e,t){let n=new Set,r=new Map;for(let i=xT.length-1;i>=0&&xT[i].version>e;i--){let{path:e}=xT[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?Lv(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}function kT(e){return e.map(e=>e.type===`text`?e.value:``).join(``)}function AT(e,t){let n=`macro-${e}`;return t?`${n} ${t}`:n}var jT={useState:je,useRef:A,useEffect:Ne,useLayoutEffect:Pe,useCallback:Ie,useMemo:Fe,useContext:j};function $(e,t=`builtin`){let n=e.parameters??[];xl(e.name,n);function r(t){let r=t.className,i=t.id,a;e.interpolate&&(a=rd(),r=a(r),i=a(i));let{update:o,getValues:s}=j(Lm),c=j(wT),l=cd(),u=(e,t)=>Kh(e,{...l,...t}),d;try{d=Oc(t.rawArgs,n)}catch(t){if(t instanceof pc)return b(Mm,{macro:e.name,error:t});throw t}let f={args:d,collectText:kT,sourceLocation:jm,parseVarArgs:Mc,extractOptions:Ic,h:b,renderNodes:u,renderInlineNodes:Rh,hooks:jT,useAction:Vw,className:r,id:i,resolve:a,cls:AT(e.name,r),mutate:c?e=>ET(()=>Xx(e,s(),o)):e=>Xx(e,s(),o),update:o,getValues:s,wrap:e=>Vu(r,i,e)};if(e.merged){f.merged=Zl();let e=f.merged;f.evaluate=t=>Ru(t,e[0],e[1],e[2],e[3])}if(e.storeVar){let n=jc(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: ${hs} is reserved`);f.varName=i,f.value=Q(e=>Lv(e.variables,a)),f.getValue=()=>Lv(Cx().variables,a),f.setValue=e=>{CT(a),Jx((t,n)=>{Vv(t.variables,a,n(e),{createMissing:!0})})}}try{return e.render(t,f)}catch(t){if(t instanceof pc)return b(Mm,{macro:e.name,error:t});throw t}}dl(e.name,r);let i=e.text;ml(e.name,i&&((e,t)=>i(e,{...t,args:Oc(e.rawArgs,n)})));let a=e.block===!0||e.block!==!1&&(e.subMacros?.length??0)>0;if(wl(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)_l(t);a&&mr(e.name)}var MT=null;function NT(e){MT=e}function PT(){return MT}var FT=null,IT=null;function LT(){return IT}var RT=!1;function zT(){if(RT)return;RT=!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:Ax(ys(e,i)),to:Ax(ys(t,i))}};i(e,n.variables,``),i(t,n.transient,`%`),e=n.variables,t=n.transient,Object.keys(r).length>0&&Iy(`variableChanged`,r)})}var BT=null,VT=null,HT=new Set;function UT(e,t=[]){BT=new Set(e),VT=new Set(t),HT.clear()}function WT(e){let t=e.startsWith(`%`),n=t||e.startsWith(`$`)?e.slice(1):e;return _s(n.split(`.`)[0],e),{isTransient:t,key:n}}function GT(e,t){let n=e?VT:BT;if(!n)return;let r=t.split(`.`)[0];if(n.has(r))return;let i=(e?`%`:`$`)+r;HT.has(i)||(HT.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 KT(e,t,n){let{isTransient:r,key:i}=WT(t),a=r?e.transient:e.variables;i.includes(`.`)?Vv(a,i.split(`.`),n):a[i]=n}function qT(e){return((...t)=>Q.getState()[e](...t))}function JT(){return{get(e){let{isTransient:t,key:n}=WT(e),r=Sx(),i=r??Q.getState(),a=t?i.transient:i.variables,o=n.includes(`.`)?Lv(a,n.split(`.`)):ys(a,n);return r?Dx(o):Ax(o)},set(e,t){let n=typeof e==`string`?[[e,t]]:Object.entries(e);for(let[e]of n){let{isTransient:t,key:n}=WT(e);GT(t,n),t||HC(n.split(`.`))}n.some(([e])=>e.includes(`.`))?Jx((e,t)=>{for(let[r,i]of n)KT(e,r,t(i))}):Q.getState().updateVariables(e=>{for(let[t,r]of n)KT(e,t,r)})},goto:qT(`navigate`),back:qT(`goBack`),forward:qT(`goForward`),restart:qT(`restart`),save:qT(`save`),load:qT(`load`),hasSave:qT(`hasSave`),getSaveInfo:qT(`getSaveInfo`),listSaves:qT(`listSaves`),deleteSave:qT(`deleteSave`),exportSave:qT(`exportSave`),importSave:qT(`importSave`),...Nu(()=>Q.getState().visitCounts,()=>Q.getState().renderCounts),get title(){return Q.getState().storyData?.name||``},get passage(){return Q.getState().currentPassage},settings:vT,registerClass(e,t){i_(e,t)},defineMacro(e){$(e,`user`)},getMacroRegistry(){return El()},saves:{setTitleGenerator(e){By(e)}},storage:{async getInfo(){let e=Q.getState().storyData?.ifid;return e?dx(e):{saveCount:0,playthroughCount:0,totalBytes:0,backend:Iv()}},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:qT(`clearGameData`),clearAllData:qT(`clearAllData`),deletePlaythrough:qT(`deletePlaythrough`),get backend(){return Iv()}},getActions(){return Iw()},performAction(e,t){let n=Lw(e);if(!n)throw Error(`spindle: Action \"${e}\" not found.`);if(n.disabled)throw Error(`spindle: Action \"${e}\" is disabled.`);return Pw(n,t)},on(e,t){e===`variableChanged`&&zT();let n=Py(e,t);return IC(n),n},async waitForActions(){await Fw(),await new Promise(e=>{requestAnimationFrame(()=>requestAnimationFrame(()=>e()))}),await new Promise(e=>setTimeout(e,0));let e=()=>PT()===Q.getState().navigationId;return PT()!==null&&!e()&&!Q.getState().renderDeferred&&await new Promise(t=>{let n=Py(`passagerender`,()=>{e()&&(n(),t())})}),Iw()},watch(e,t){return iS(e,t)},unwatch(e){pS(e)},openDialog(e,t){AS({passageName:e,panelClass:t?.panelClass,showCloseButton:t?.showCloseButton,dismissible:t?.dismissible})},closeDialog(){FS()},closeAllDialogs(){IS()},isDialogOpen(){return LS()},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(),IT??(IT=new Promise(e=>{FT=e}))},ready(){FT&&(Q.getState().clearDeferredRender(),FT(),FT=null,IT=null)},random(){return mu()},randomInt(e,t){return hu(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){ou(e,t);let{historyIndex:n}=Q.getState();Q.setState(e=>{let t=e.history[n];t&&(t.prng=pu())})},isEnabled(){return gu()},get seed(){return _u()},get pull(){return vu()}}}}function YT(){window.Story=JT()}var XT=new Set([`StoryVariables`,`StoryTransients`,`SaveTitle`]),ZT=[`script`,`stylesheet`],QT=new Set([`elseif`,`else`,`case`,`default`,`next`]);function $T(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 eE(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 tE(e,t){let n=e.toLowerCase(),r,i=Math.max(2,Math.floor(n.length/3))+1;for(let e of t){let t=eE(n,e.toLowerCase());t<i&&(r=e,i=t)}return r}var nE=(e,t)=>e?` Did you mean ${t(e)}?`:``,rE=` (a passage name is a quoted string or an expression)`,iE=/^[A-Za-z][\\w$]*$/;function aE(e){try{return Pl(e).name.toLowerCase()||void 0}catch{return}}function oE(e,t){let n=[],r=t.isBlockMacro?{isBlock:t.isBlockMacro}:void 0,i=(e,t,r,i,a,o)=>{let{line:s,column:c}=br(e.content,t),l={passage:e.name,line:s,column:c,message:a,code:i,start:t,end:r};o&&(l.data=o);let u=e.metadata?.[`data-source-file`];if(u){l.file=u;let t=Number(e.metadata?.[`data-source-line`]);t&&(l.fileLine=t+s)}n.push(l)},a=(e,t,n)=>i(e,t.offset,t.end,t.code,n+t.reason,t.data),o=[],s=new Set,c=new Set,l=e=>{for(let t of e){if(t.type!==`macro`||t.isClose||t.name.toLowerCase()!==`widget`)continue;let e=aE(t.rawArgs);e&&s.add(e)}};for(let n of e){if(c.add(n.name),XT.has(n.name)||n.tags?.some(e=>ZT.includes(e)))continue;let e=!t.only||t.only(n);if(t.tolerant){let{tokens:t,errors:i}=os(n.content,{hooks:r});if(l(t),!e)continue;for(let e of i)a(n,e,``);o.push([n,t])}else try{let t=ls(n.content);if(l(t),!e)continue;ss(n.content,{hooks:r}),o.push([n,t])}catch(t){if(!(t instanceof is))throw t;e&&a(n,t,``)}}let u=[...t.macroNames??[],...s],d=(e,n,r)=>{for(let a of n){if(a.type!==`macro`||a.isClose)continue;let n=a.name.toLowerCase();if(QT.has(n)||s.has(n)||t.isKnownMacro(n))continue;let o=tE(a.name,u);i(e,a.start,a.end,`unknown-macro`,`${r}Unknown macro {${a.name}}.${nE(o,e=>`{${e}}`)}`,{name:a.name,suggestions:o?[o]:[]})}},f=t.parametersOf??(()=>void 0),p=(e,n)=>{d(e,n,``);let r=0;for(let o of Zc(e.content,n,f,{isBlock:t.isBlockMacro})){if(o.nested&&o.offset<r)continue;let n=o.offset,s=o.where&&o.nested?o.where:``;switch(o.kind){case`argument-error`:i(e,n,n+o.length,`argument-error`,`${s}${o.message} in ${o.label}`,{macro:o.macro});break;case`passage`:if(t.checkPassageNames!==!1&&!c.has(o.name)){let t=tE(o.name,c);i(e,n,n+o.length,`unknown-passage`,`${s}No passage named ${JSON.stringify(o.name)} in ${o.label}.${nE(t,JSON.stringify)}`,{name:o.name,macro:o.macro,suggestions:t?[t]:[]})}break;case`code`:m(e,o,s);break;case`text`:o.errors.length>0?(a(e,o.errors[0],o.where),r=Bc(o,o.text.length)):d(e,o.tokens,o.where)}}},m=(e,t,n)=>{let r=t.offset,a=zc(t.code,t.goal),o=t.code.trim();if(a instanceof _o){let o=/^(?:[\\w$]+|\\S)/.exec(t.code.slice(a.pos));i(e,Bc(t,a.pos),Bc(t,a.pos+(o?.[0].length??0)),`code-syntax`,`${n}${a.reasonIn(e.content,r)} in ${t.label}`+(t.passage?rE:``),t.macro?{macro:t.macro}:void 0)}else if(t.passage&&iE.test(o)){let r=t.code.length-t.code.trimStart().length;i(e,Bc(t,r),Bc(t,r+o.length),`unquoted-passage-name`,`${n}Unquoted passage name in ${t.label}: write ${JSON.stringify(o)}${rE}`,{name:o,macro:t.macro??``})}};for(let[e,t]of o)Rc(()=>p(e,t));return n}var sE=/(?:0[xX][\\da-fA-F_]+|0[bB][01_]+|0[oO][0-7_]+|(?:\\d[\\d_]*\\.?[\\d_]*|\\.\\d[\\d_]*)(?:[eE][+-]?\\d[\\d_]*)?)(n?)/y,cE=/[A-Za-z_$][\\w$]*/y,lE=/[\\w$]+/y,uE=/(?:async\\s+)?(?:\\((?:[^()]|\\([^()]*\\))*\\)|[A-Za-z_$][\\w$]*)\\s*=>/y,dE=/[\\n\\r\\u2028\\u2029]/g,fE=/^(?:0|[1-9]\\d{0,8})$/,pE={unsupported:`undefined`,value:`undefined`};function mE(e){let t=new vE(e),n=t.value();return t.space(),t.i===e.length?n:void 0}function hE(e){let t=[...e];return[...t.filter(e=>fE.test(e)).sort((e,t)=>Number(e)-Number(t)),...t.filter(e=>!fE.test(e))]}function gE(e,t=`expression`,n={}){let r=new Map;return Vo(e,{...n,literal(e,t,i){e.charAt(0)===`/`&&!/^\\/[/*]/.test(e)&&r.set(t,t+e.length),n.literal?.(e,t,i)}},t),r}function _E(e){try{return BigInt(e.replace(/_/g,``)).toString()}catch{return}}var vE=class{constructor(e,t={}){this.src=e,this.i=0,this.goal=t.goal??`expression`,this.regexes=t.regexes}space(){let{src:e}=this;for(;;){for(;/\\s/.test(e.charAt(this.i));)this.i++;if(e.startsWith(`//`,this.i))dE.lastIndex=this.i,this.i=dE.test(e)?dE.lastIndex-1:e.length;else if(e.startsWith(`/*`,this.i)){let t=e.indexOf(`*/`,this.i+2);this.i=t<0?e.length:t+2}else return}}value(){let{src:e}=this;this.space();let t=e.charAt(this.i);if(t===`\"`||t===`'`)return this.string().closed?{shape:{type:`string`}}:void 0;if(t===\"`\")return this.template();if(t===`[`)return this.skipBalanced()?{shape:{type:`array`}}:void 0;if(t===`{`)return this.object();if(/[\\d.+-]/.test(t))return this.number();if(/[A-Za-z_$(]/.test(t))return this.word()}string(){let{end:e,closed:t}=qo(this.src,this.i),n=this.src.slice(this.i+1,t?e-1:e);return this.i=e,{body:n,closed:t}}stringValue(){let e=this.i,{closed:t}=this.string();return t?Ko(this.src.slice(e,this.i))??void 0:void 0}template(){let{src:e}=this;for(let t=this.i+1;t<e.length;t++){let n=e.charAt(t);if(n===`\\\\`)t++;else if(n===\"`\")return this.i=t+1,{shape:{type:`string`}};else if(n===`$`&&e.charAt(t+1)===`{`)return}}number(){let{src:e}=this,t=this.i,n=e.charAt(t);if(n===`+`||n===`-`)for(t++;/\\s/.test(e.charAt(t));)t++;let r=this.numberAt(t);if(r){if(this.i=t+r[0].length,!r[1])return{shape:{type:`number`}};if(n===`+`)return{throws:`Cannot convert a BigInt value to a number`};let e=_E(r[0].slice(0,-1));return e===void 0?void 0:{unsupported:`bigint`,value:n===`-`&&e!==`0`?`-${e}`:e}}cE.lastIndex=t;let i=cE.exec(e)?.[0];if(i===`Infinity`||i===`NaN`)return this.i=cE.lastIndex,{shape:{type:`number`}}}numberAt(e){return sE.lastIndex=e,sE.exec(this.src)}word(){let{src:e}=this,t=this.i,n=this.arrow();if(n!==void 0)return n?this.functionFrom(t):void 0;cE.lastIndex=this.i;let r=cE.exec(e)?.[0];if(r===void 0)return;let i=cE.lastIndex;switch(r){case`true`:case`false`:return this.i=i,{shape:{type:`boolean`}};case`null`:return this.i=i,{shape:{type:`null`}};case`NaN`:case`Infinity`:return this.i=i,{shape:{type:`number`}};case`undefined`:return this.i=i,pE;case`void`:{this.i=i;let e=this.value();return e&&!(`throws`in e)?pE:e}case`function`:case`class`:case`async`:return this.skipDeclaration(r)?this.functionFrom(t):void 0}}functionFrom(e){return{unsupported:`function`,value:this.src.slice(e,this.i).trimEnd()}}arrow(){let{src:e}=this;if(uE.lastIndex=this.i,uE.test(e)){if(this.i=uE.lastIndex,this.space(),e.charAt(this.i)===`{`)return this.skipBalanced();for(;this.i<e.length&&!`,}`.includes(e.charAt(this.i))&&this.skipOne(););return!0}}skipDeclaration(e){let{src:t}=this;if(this.i+=e.length,this.space(),e===`async`)return cE.lastIndex=this.i,cE.exec(t)?.[0]===`function`&&this.skipDeclaration(`function`);if(e===`function`){if(t.charAt(this.i)===`*`&&this.i++,this.space(),cE.lastIndex=this.i,cE.test(t)&&(this.i=cE.lastIndex),this.space(),t.charAt(this.i)!==`(`||!this.skipBalanced())return!1;this.space()}else for(;this.i<t.length&&t.charAt(this.i)!==`{`;)if(!this.skipOne())return!1;return t.charAt(this.i)===`{`&&this.skipBalanced()}object(){let{src:e}=this,t=new Map,n;for(this.i++;;){this.space();let r=e.charAt(this.i);if(r===`}`)return this.i++,n===void 0?this.objectOf(t):{throws:n};if(r===`,`){this.i++;continue}if(this.i>=e.length)return;let i=this.i,a=this.key();if(a===`__proto__`)return;this.space();let o=e.charAt(this.i);if(a!==void 0&&o===`:`){this.i++;let e=this.i,r=this.value();if(this.space(),r&&this.atMemberEnd()){`throws`in r?n??(n=r.throws):t.set(a,`shape`in r?r.shape:r);continue}t.set(a,null),this.i=e}else if(a!==void 0&&o===`(`){if(!this.skipBalanced())return;if(this.space(),e.charAt(this.i)===`{`&&this.skipBalanced()){t.set(a,{unsupported:`function`,value:e.slice(i,this.i)});continue}return}else if(a!==void 0&&(o===`,`||o===`}`)){t.set(a,null);continue}else t.clear();if(!this.skipMember())return}}atMemberEnd(){return this.i<this.src.length&&`,}`.includes(this.src.charAt(this.i))}objectOf(e){let t=new Map;for(let n of hE(e.keys())){let r=e.get(n);if(r){if(`unsupported`in r)return r;t.set(n,r)}}return{shape:{type:`object`,fields:t}}}key(){let{src:e}=this,t=e.charAt(this.i);if(t===`\"`||t===`'`)return this.stringValue();if(/[\\d.]/.test(t))return this.numberKey();lE.lastIndex=this.i;let n=lE.exec(e)?.[0];if(n!==void 0)return this.i=lE.lastIndex,n}numberKey(){let e=this.numberAt(this.i);if(!e||(this.i+=e[0].length,/[\\w$]/.test(this.src.charAt(this.i))))return;let t=e[0].replace(/_/g,``);if(/^0\\d/.test(t))return;if(e[1])return _E(t.slice(0,-1));let n=Number(t);return Number.isNaN(n)?void 0:String(n)}skipMember(){let{src:e}=this;for(;this.i<e.length;){let t=e.charAt(this.i);if(t===`,`||t===`}`)return!0;if(!this.skipOne())return!1}return!1}skipBalanced(){let{src:e}=this,t={\"[\":`]`,\"{\":`}`,\"(\":`)`}[e.charAt(this.i)];if(!t)return!1;for(this.i++;this.i<e.length;){if(e.charAt(this.i)===t)return this.i++,!0;if(!this.skipOne())return!1}return!1}skipOne(){let{src:e}=this,t=e.charAt(this.i);if(t===`\"`||t===`'`)return this.string().closed;if(t===\"`\")return this.skipTemplate();if(e.startsWith(`//`,this.i)||e.startsWith(`/*`,this.i))return this.space(),!0;if(t===`/`){this.regexes??(this.regexes=gE(e,this.goal));let t=this.regexes.get(this.i);if(t!==void 0)return this.i=t,!0}return t===`[`||t===`{`||t===`(`?this.skipBalanced():t===`]`||t===`}`||t===`)`?!1:(this.i++,!0)}skipTemplate(){let{src:e}=this;for(this.i++;this.i<e.length;){let t=e.charAt(this.i);if(t===`\\\\`)this.i+=2;else if(t===\"`\")return this.i++,!0;else if(t===`$`&&e.charAt(this.i+1)===`{`){if(this.i++,!this.skipBalanced())return!1}else this.i++}return!1}};function yE(e,t,{tolerant:n}={}){if(n)return us(e,{text:t}).tokens;try{return ls(e,{text:t})}catch(e){if(e instanceof is)return[];throw e}}function bE(e){let t=e.replace(/[.*+?^${}()|[\\]\\\\]/g,`\\\\$&`);return RegExp(`^${t}(\\\\w+)\\\\s*=\\\\s*(.+)$`)}var xE=/([$%])(\\w+(?:\\.\\w+)*)/y,SE=/^[\"']\\$(\\w+(?:\\.\\w+)*)[\"']?$/,CE=new Set([`number`,`string`,`boolean`]),wE={string:Object(``),number:Object(0),boolean:Object(!1)};function TE(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,TE(i,t));return i}let n=typeof e;if(!CE.has(n))throw Error(`Unsupported type \"${n}\" for value ${String(e)}. Expected number, string, boolean, array, or object.`);return{type:n}}var EE=`Expected number, string, boolean, array, or object.`;function DE(e){if(!e.fields)return{type:e.type};let t=new Map;for(let[n,r]of e.fields)t.set(n,DE(r));return{type:e.type,fields:t}}function OE(e){try{to(`return (`+e+`)`,{ecmaVersion:`latest`,allowReturnOutsideFunction:!0})}catch(e){if(!(e instanceof SyntaxError))throw e;let{pos:t}=e;return{message:e.message.replace(/ \\(\\d+:\\d+\\)$/,``),pos:Math.max(0,t-8)}}}function kE(e,t=`$`){let n=[],r=[],i=bE(t),a=new Set,o=0;for(let s of e.split(`\n`)){let e=o+s.length-s.trimStart().length;o+=s.length+1;let c=s.trim();if(!c)continue;let l=c.match(i),u=(e,t,n,i)=>r.push({code:e,offset:t,end:n,message:i});if(!l){u(`invalid-declaration`,e,e+c.length,`Invalid declaration: \"${c}\". Expected: ${t}name = value`);continue}let[,d,f]=l,p=e+t.length,m=p+d.length,h=gs(d,t+d);if(h){u(`invalid-name`,p,m,h);continue}let g=e+c.length,_={name:d,nameStart:p,nameEnd:m,valueStart:g-f.length,valueEnd:g};a.has(d)&&u(`duplicate-declaration`,p,m,`Duplicate declaration of ${t}${d}`),a.add(d),n.push(_);let v=`Failed to evaluate \"${t}${d} = ${f}\"`,y=OE(f);if(y){let e=Math.min(y.pos,f.length-1);u(`syntax`,_.valueStart+e,_.valueStart+e+1,`${v}: ${y.message}`);continue}let b=mE(f);b&&(`shape`in b?_.schema=DE(b.shape):`throws`in b?u(`unsupported-value`,_.valueStart,g,`${v}: ${b.throws}`):u(`unsupported-value`,_.valueStart,g,`Unsupported type \"${b.unsupported}\" for value ${b.value}. ${EE}`))}return{declarations:n,errors:r}}function AE(e,t=`$`){let n=new Map,r=t===`%`?`StoryTransients`:`StoryVariables`,{declarations:i,errors:a}=kE(e,t),o=[...a.filter(e=>e.code===`invalid-declaration`||e.code===`invalid-name`).map(e=>({at:e.offset,error:e})),...i.map(e=>({at:e.nameStart,declaration:e}))].sort((e,t)=>e.at-t.at);for(let i of o){if(`error`in i)throw Error(`${r}: ${i.error.message}`);let{name:a,valueStart:o,valueEnd:s}=i.declaration,c=e.slice(o,s),l;try{l=Function(`return (`+c+`)`)()}catch(e){throw Error(`${r}: Failed to evaluate \"${t}${a} = ${c}\": ${Is(e)}`)}let u;try{u=TE(l)}catch(e){throw Error(`${r}: ${Is(e)}`)}n.set(a,{...u,name:a,default:l})}return n}function jE(e,t){let n=t=>e.sigil+[e.name,...t].join(`.`),r=gs(e.name,e.sigil+e.name);if(r)return{code:`reserved-name`,message:r};let i=e.sigil===`$`?t.variables:t.transients;if(!i)return null;if(!i.has(e.name))return e.sigil===`$`?{code:`undeclared-variable`,message:`Undeclared variable: ${n(e.path)}`}:{code:`undeclared-transient`,message:`Undeclared transient: ${n(e.path)}`};let a=i.get(e.name);for(let t=0;a&&t<e.path.length;t++){let r=e.path[t];if(a.type===`array`||a.type===`null`)return null;if(a.type===`string`&&vs(r))continue;let i=wE[a.type];if(i&&r in i){let e=typeof i[r];if(!CE.has(e))return null;a={type:e}}else{if(a.type!==`object`||!a.fields)return{code:`primitive-field`,message:`Cannot access field \"${r}\" on ${n(e.path.slice(0,t))} (type: ${a.type})`};a=a.fields.get(r)}}return null}var ME=[`checkbox`,`cycle`,`listbox`,`numberbox`,`radiobutton`,`textarea`,`textbox`],NE=new Set,PE=/(?:\\.\\w+)*/y;function FE(e,t,n,r,i,a){PE.lastIndex=i;let o=PE.exec(e)[0];return{sigil:t,name:n,path:o?o.slice(1).split(`.`):[],start:a(r),end:a(i+o.length)}}function IE(e,t,n){xE.lastIndex=t;let r=xE.exec(e);if(!r)return;let[i,...a]=r[2].split(`.`);return{sigil:r[1],name:i,path:a,start:n(t),end:n(t+r[0].length)}}function LE(e,t,n){for(let{expr:r,at:i}of cl(e))zE(r,e=>t(i+e),n)}function RE(e,t,n,r){e.includes(`{`)&&GE(e,yE(e,!0,r),t,n,r)}function zE(e,t,n,r=`expression`){let i=zc(e,r);if(i instanceof _o)BE(e,t,n,r);else for(let r of i.refs)(r.sigil===`$`||r.sigil===`%`)&&n(FE(e,r.sigil,r.name,r.start,r.end,t))}function BE(e,t,n,r){Vo(e,{variable(r,i,a,o,s){(r===`$`||r===`%`)&&n(FE(e,r,i,a,s,t))},literal(){}},r)}function VE(e,t,n,r){for(let i of e){let e=e=>t(Bc(i,e));i.kind===`code`?zE(i.code,e,n,i.goal):i.kind===`text`&&RE(i.text,e,n,{...r,storeVarMacros:NE})}}function HE(e,t,n,r,i){if(!e.rawArgs)return;let a=t(e.name),o=!1;if(a){i.all&&!i.storeVarMacros.has(e.name.toLowerCase())&&UE(e,a,n,r);let t=[...rl(e.rawArgs,e.argsStart,a,e.name,``)];o=!t.some(e=>e.kind===`argument-error`),o&&VE(t,n,r,i)}o||zE(e.rawArgs,t=>n(e.argsStart+t),r);let s=t.widget?.(e.name);s&&VE(il(e.rawArgs,e.argsStart,s,e.name,``),n,r,i)}function UE(e,t,n,r){let i=new Map;try{Oc(e.rawArgs,t,i)}catch(e){if(e instanceof pc)return;throw e}for(let a of t){let t=i.get(a);if(a.type!==`variable`||!t)continue;let o=IE(e.rawArgs.slice(t[0],t[1]),0,r=>n(e.argsStart+t[0]+r));o&&r(o)}}function WE(e,t,n,r,i){if(!(`selectorsStart`in t)||t.selectorsStart===void 0||t.selectorsEnd===void 0)return;let a=t.selectorsStart;RE(e.slice(a,t.selectorsEnd),e=>n(a+e),r,{...i,storeVarMacros:NE})}function GE(e,t,n,r,i){let{storeVarMacros:a,parametersOf:o}=i;for(let s=0;s<t.length;s++){let c=t[s];if(i.all&&c.type!==`macro`&&c.type!==`html`&&c.type!==`text`&&WE(e,c,n,r,i),c.type===`variable`){if((c.scope===`variable`||c.scope===`transient`)&&c.name){let[e,...t]=c.name.split(`.`);r({sigil:c.scope===`variable`?`$`:`%`,name:e,path:t,start:n(c.nameStart-1),end:n(c.nameEnd)})}}else if(c.type===`link`)RE(c.display,e=>n(c.displayStart+e),r,{...i,storeVarMacros:NE});else if(c.type===`expression`)zE(c.expression,e=>n(c.expressionStart+e),r);else if(c.type===`html`)for(let{name:t,value:a,at:o}of sl(e,c)){let e=e=>n(o+e);ts(t)?LE(a,e,r):RE(a,e,r,i)}else if(c.type===`macro`&&!c.isClose){if(HE(c,o,n,r,i),WE(e,c,n,r,i),a.has(c.name.toLowerCase())){let e=c.rawArgs.length-c.rawArgs.trimStart().length,t=c.rawArgs.trim().split(/\\s+/)[0]??``,i=SE.exec(t);if(i){let[t,...a]=i[1].split(`.`),o=c.argsStart+e+1;r({sigil:`$`,name:t,path:a,start:n(o),end:n(o+1+i[1].length)})}else/^[\"'`]/.test(t)||zE(t,t=>n(c.argsStart+e+t),r)}if(c.name.toLowerCase()===`do`){let i=s+1;for(;i<t.length;){let e=t[i];if(e.type===`macro`&&e.isClose&&e.name.toLowerCase()===`do`)break;i++}i<t.length&&(zE(e.slice(c.end,t[i].start),e=>n(c.end+e),r,`statements`),s=i)}}}}function KE(e,t){let n=[];return Rc(()=>GE(e,yE(e,!1,t),e=>e,e=>n.push(e),t)),n.sort((e,t)=>e.start-t.start)}function qE(e,t,n){let r=[];for(let i of e)if(!XT.has(i.name))for(let e of KE(i.content,n)){let n=jE(e,t);n&&r.push({passage:i.name,code:n.code,name:e.name,...e.path.length>0?{path:e.path}:{},start:e.start,end:e.end,message:n.message})}return r}function JE(e,t,n=ME,r=Tl){return qE(e.values(),{variables:t},{storeVarMacros:new Set(Array.from(n,e=>e.toLowerCase())),parametersOf:r}).map(e=>`Passage \"${e.passage}\": ${e.message}`)}function YE(e){let t=Ss();for(let[n,r]of e)t[n]=r.default;return t}var XE=new WeakMap;function ZE(e){let t=XE.get(e);if(t&&t.content===e.content)return t.ast;let n=ss(e.content);return XE.set(e,{content:e.content,ast:n}),n}function QE(e){return Kh(ZE(e),e.tags.includes(`nobr`)?{nobr:!0}:void 0)}function $E(e){if(!e)return null;try{return QE(e)}catch(t){return console.error(`spindle: Error in ${e.name}:`,t),null}}var eD=new Set([`PassageReady`,`PassageHeader`,`PassageFooter`,`PassageDone`]);function tD({passage:e,dataTransition:t,navigationId:n}){let{storyData:r}=Jl(`storyData`),i=eD.has(e.name),[a,o]=je(!1),s=Fe(()=>{try{return QE(e)}catch(t){return q(`div`,{class:`error`,children:[`Error parsing passage “`,e.name,`”`,Am(e),`: `,Is(t)]})}},[e.content,e.name]),c=e=>i?void 0:r?.passages.get(e),l=c(`PassageHeader`),u=c(`PassageFooter`),d=c(`PassageDone`),f=Fe(()=>$E(l),[l?.content]),p=Fe(()=>$E(u),[u?.content]);Ne(()=>(d&&o(!0),()=>o(!1)),[e.name]);let m=Fe(()=>a?$E(d):null,[a,d?.content]),h=A(null);Pe(()=>{n!==void 0&&NT(n),h.current&&Ly(`passagerender`,e.name,h.current)},[e.name,n]);let g=e.tags.includes(`nobr`),_=Gm(),v=q(Um.Provider,{value:_,children:q(`div`,{ref:h,class:`passage`,\"data-passage\":e.name,\"data-tags\":e.tags.join(` `),\"data-transition\":t,children:[f&&q(`div`,{class:`passage-header`,children:f}),s,p&&q(`div`,{class:`passage-footer`,children:p}),m&&q(`div`,{hidden:!0,children:m})]})});return g?q(Rm.Provider,{value:!0,children:v}):v}var nD=new Set([`none`,`fade`,`fade-through`,`crossfade`]),rD={type:`fade-through`,duration:300,pause:50};function iD(e){let t=e.find(e=>e.startsWith(`transition:`));if(!t)return null;let n=t.slice(11);if(!nD.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 aD(e){return{type:e.type,duration:e.duration??rD.duration,pause:e.pause??rD.pause}}function oD(e,t,n){let r=iD(e);return r?aD(r):t?aD(t):n?aD(n):{...rD}}var sD=new Set([`checkbox`,`radio`,`file`,`hidden`,`button`,`submit`,`reset`,`image`]);function cD(e,t){let n=(n,r)=>{let i=e.querySelectorAll(n),a=t.querySelectorAll(n);i.forEach((e,t)=>a[t]&&r(e,a[t]))};n(`canvas`,(e,t)=>{if(e.width&&e.height)try{t.width!==e.width&&(t.width=e.width),t.height!==e.height&&(t.height=e.height),t.getContext(`2d`)?.drawImage(e,0,0)}catch{}}),n(`input, textarea, select`,(e,t)=>{if(e instanceof HTMLSelectElement){let n=t;if(!e.multiple)n.selectedIndex=e.selectedIndex;else for(let t=0;t<e.options.length;t++){let r=n.options[t];r&&(r.selected=e.options[t].selected)}}else if(e instanceof HTMLInputElement){let n=t;n.checked=e.checked,n.indeterminate=e.indeterminate,sD.has(e.type)||(n.value=e.value)}else t.value=e.value}),n(`audio, video`,(e,t)=>{t.pause?.(),t.muted=!0,t.removeAttribute(`autoplay`);try{t.currentTime=e.currentTime}catch{}if(e instanceof HTMLVideoElement&&t instanceof HTMLVideoElement&&!(e.readyState<2||!e.videoWidth||!e.videoHeight))try{let n=document.createElement(`canvas`);n.width=e.videoWidth,n.height=e.videoHeight,n.getContext(`2d`)?.drawImage(e,0,0),t.setAttribute(`poster`,n.toDataURL(`image/jpeg`,.92))}catch{}})}function lD(e,t){let n=[e,...e.querySelectorAll(`*`)],r=[t,...t.querySelectorAll(`*`)],i=[];return n.forEach((e,t)=>{r[t]&&(e.scrollTop||e.scrollLeft)&&i.push([r[t],e.scrollTop,e.scrollLeft])}),i}var uD=new WeakMap;function dD(e,t){e.appendChild(t);for(let[e,n,r]of uD.get(t)??[])e.scrollTop=n,e.scrollLeft=r;uD.delete(t)}function fD(e,t){let n=e.cloneNode(!0);cD(e,n),uD.set(n,lD(e,n)),n.removeAttribute(`id`);let r=n.querySelectorAll(`[id]`);for(let e=0;e<r.length;e++)r[e].removeAttribute(`id`);return n.style.pointerEvents=`none`,n.style.userSelect=`none`,n.setAttribute(`inert`,``),n.setAttribute(`aria-hidden`,`true`),n.classList.remove(`passage`),n.classList.add(`passage-snapshot`),n.setAttribute(`data-transition`,t),n}function pD(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 mD(e,t){if(!e)return null;pD(e,t);let n=e.querySelector(`.passage`);return n?fD(n,t.type):null}function hD(e){if(!e)return;e.classList.remove(`passage-container--crossfading`);let t=e.querySelectorAll(`.passage-snapshot`);for(let e=0;e<t.length;e++)t[e].remove()}var gD=new Map,_D=new Set;function vD(){let e=()=>{let{navigationId:e,renderDeferred:t}=Q.getState();return!t&&[...gD.values()].every(t=>t===e)};return e()?Promise.resolve():new Promise(t=>{let n=()=>{e()&&(_D.delete(n),t())};_D.add(n)})}function yD(e){let t=e?.querySelector(`.passage`);t&&t.getBoundingClientRect().top<0&&t.scrollIntoView?.({block:`start`})}function bD(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}=Jl(`currentPassage`,`navigationId`,`storyData`,`renderDeferred`),[o,s]=je({passage:n,id:r}),c=o.passage,l=e=>s({passage:e,id:r}),u=A(`fade`),d=A(0),f=o.id,p=Ie(e=>e.navigationId!==f,[f]),m=Ie(()=>p(Q.getState()),[p]),h=A(null),g=A(null),_=A([]),v=A(!1),y=Ie(()=>{for(let e of _.current)clearTimeout(e);_.current=[],v.current=!1,hD(g.current)},[]);Ne(()=>y,[y]),Ne(()=>{let e=Q.getState(),{history:t,historyIndex:a,transitionConfig:s}=e,f=d.current;d.current=t.length;let p=!c,m=t.length===1&&a===0&&f>1,h=t.length>1&&a===t.length-1&&f>1&&Math.abs(t.length-f)>1;if(r===o.id)return;let b=e.consumeNextTransition();y();let x=i?.passages.get(n);if(!x){u.current=`none`,l(n);return}if(p||m||h){u.current=`fade`,l(n);return}let S=bD(oD(x.tags,b,s));u.current=S.type;let C=g.current;if(S.type===`none`){l(n);return}if(S.type===`fade`){C&&pD(C,S),l(n);return}let w=S.type===`fade-through`||S.type===`crossfade`?mD(C,S):null;if(!C||!w){l(n);return}if(S.type===`fade-through`){dD(C,w),l(``);let e=S.duration+S.pause,t=setTimeout(()=>{l(n)},e),r=e+S.duration,i=setTimeout(()=>{hD(C),v.current&&yD(C),v.current=!1},r);_.current=[t,i];return}C.classList.add(`passage-container--crossfading`),dD(C,w),l(n);let T=setTimeout(()=>{hD(C)},S.duration);_.current=[T]},[r]);let b=c&&!a?o.id:null,x=A(b);Pe(()=>{if(b===null)return;let e=x.current;if(x.current=b,e===null||e===b)return;let t=g.current;v.current=!!t?.querySelector(`.passage-snapshot`)&&!t.classList.contains(`passage-container--crossfading`),v.current||yD(t)},[b]);let S=A(Symbol(`passage-display`)).current;Pe(()=>{gD.set(S,b),[..._D].forEach(e=>e())},[b]),Pe(()=>()=>{gD.delete(S),[..._D].forEach(e=>e())},[]);let C=a?i?.passages.get(`StoryLoading`)??null:c?i?.passages.get(c):null;if(!C&&c&&!a)return q(`div`,{class:`error`,children:[`Error: Passage “`,c,`” not found.`]});let w=i?.passages.get(`PassageReady`),T=!a&&o.id!==r&&h.current?h.current:C&&q(tD,{passage:C,dataTransition:a?`none`:u.current,navigationId:a?void 0:o.id},a?`loading`:`nav-${o.id}`);return h.current=T||null,q(`div`,{id:t.id??`story`,class:t.className??`story`,children:[!a&&w&&q(`div`,{hidden:!0,children:QE(w)},`ready-${r}`),q(`div`,{class:`passage-container`,ref:g,children:T&&q(Kl.Provider,{value:p,children:q(ql.Provider,{value:m,children:T})})})]})}}),$({name:`set`,parameters:[{name:`code`,type:`statements`,required:!0}],render({rawArgs:e},t){return Pm(`set`,e,()=>t.mutate(e))}}),$({name:`print`,parameters:[{name:`expression`,type:`expression`,required:!0}],interpolate:!0,merged:!0,render({rawArgs:e},t){try{return t.wrap(Bu(t.evaluate(e)))}catch(e){return q(Mm,{macro:`print`,error:e})}},text({rawArgs:e},t){return Bu(t.evaluate(e))}});var xD=Symbol(`unset`);function SD(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 _s(n.slice(1),n),{target:n,expr:r}}function CD(e,t,n,r,i,a,o,s,c){let l=jm(),u,d=o.current,f=!1,{navigationId:p}=Q.getState();try{let{variables:a,temporary:o,transient:c}=Cx();r||(d=ys(n?o:a,t),f=p!==s.current),u=Ru(e,a,o,i(),c)}catch(e){Nm(`computed ${a}`,e,l);return}if(s.current=p,!Qv(o.current,u)||f&&!Qv(d,u)){if(o.current=u,r)try{c(t,u)}catch(e){Nm(`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}=SD(e,t.args))}catch(e){return q(Mm,{macro:`computed`,error:e})}let i=n.startsWith(`@`),a=n.startsWith(`_`),o=n.slice(1),s=i?t.update:null,c=t.hooks.useRef(xD),l=t.hooks.useRef(-1),u=()=>CD(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 wD(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 TD(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}=wD({...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=TD(i,a,r),c=t.cls;return q(`div`,{class:c,id:t.id,children:[q(`div`,{class:`macro-meter-fill`,style:`width: ${o}%`}),s!=null&&q(`span`,{class:`macro-meter-label`,children:s})]})}catch(e){return q(Mm,{macro:`meter`,error:e})}}});function ED(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 DD(e,t){return Vu(t.resolve(e.className),t.resolve(e.id),t.renderNodes(e.children))}function OD(e,t){let n=e.findIndex(e=>e.rawArgs===``);return ED(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=OD(e,t.evaluate)}catch(e){return q(Mm,{macro:`if`,error:e})}return n?DD(n,t):null},text({branches:e=[]},t){let n=OD(e,t.evaluate);return n?t.renderText(n.children):``}});function kD(e){try{return jD(e,new Map)}catch{return`<unkeyable>`}}var AD=`<hole>`;function jD(e,t){switch(typeof e){case`string`:return JSON.stringify(e);case`number`:return Object.is(e,-0)?`-0`: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=a_(n),a=e=>i===void 0?e:`Class(${JSON.stringify(i)})${e}`,o=e=>{let r=i===void 0?[]:Kg(n);return a(r.length?`${e}${ND(n,r,t)}`:e)};if(e instanceof Date||e instanceof RegExp)return i!==void 0&&Kg(n).length&&t.set(n,t.size),o(e instanceof Date?`Date(${Date.prototype.getTime.call(e)})`:`RegExp(${Yg(e)}@${e.lastIndex})`);if(t.set(n,t.size),Array.isArray(e)){let n=[];for(let r=0;r<e.length;r++)n.push(r in e?jD(e[r],t):AD);return o(`[${n.join(`,`)}]`)}let s=MD(n,t);return s===void 0?e instanceof Map?o(`Map[${Array.from(Xg(e),([e,n])=>`[${jD(e,t)},${jD(n,t)}]`).join(`,`)}]`):e instanceof Set?o(`Set[${Array.from(Zg(e),e=>jD(e,t)).join(`,`)}]`):a(ND(n,Object.keys(n),t)):a(s)}function MD(e,t){if(e instanceof ArrayBuffer)return`ArrayBuffer[${new Uint8Array(e).join(`,`)}]`;if(ArrayBuffer.isView(e))return`${zg(e)}(${e.byteOffset},${e.byteLength},${jD(e.buffer,t)})`;let n;if(e instanceof URL)n=`URL(${JSON.stringify(Object.getOwnPropertyDescriptor(URL.prototype,`href`).get.call(e))})`;else if(e instanceof URLSearchParams)n=`URLSearchParams(${JSON.stringify(URLSearchParams.prototype.toString.call(e))})`;else if(Vg(e))n=`${zg(e)}(${jD(e.valueOf(),t)})`;else if(Bg(e))n=`${zg(e)}(${JSON.stringify(String(e))})`;else if(e instanceof Error){let r=e,i=Wg.filter(t=>K(e,t)).map(e=>`${e}:${jD(r[e],t)}`),a=Object.getPrototypeOf(e)?.constructor,o=typeof a==`function`?a.name:``;n=`Error(${JSON.stringify(o)},${i.join(`,`)})`}else return;let r=Object.keys(e);return r.length?`${n}${ND(e,r,t)}`:n}function ND(e,t,n){let r=e;return`{${t.map(e=>`${JSON.stringify(e)}:${jD(r[e],n)}`).join(`,`)}}`}function PD(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 _s(n.slice(1),n),r&&_s(r.slice(1),r),{itemVar:n.slice(1),indexVar:r?r.slice(1):null,listExpr:i}}function FD({itemVar:e,itemValue:t,indexVar:n,indexValue:r,children:i}){return q(ld,{body:i,ownKeys:Fe(()=>({[e]:t,...n?{[n]:r}:void 0}),[e,t,n,r])})}$({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=n.hooks.useRef({contents:[],generations:[],next:0,edits:DT()}).current,i,a;try{i=PD(e,n.args);let t=n.evaluate(i.listExpr);if(!Array.isArray(t))return q(`span`,{class:`error`,children:`{for error: expression did not evaluate to an array}`});a=t}catch(e){return q(Mm,{macro:`for`,error:e})}let{itemVar:o,indexVar:s}=i,c=OT(r.edits,Cx());r.edits=DT();let l=a.map((e,t)=>{let n=kD(e);return(r.generations[t]===void 0||n!==r.contents[t]&&!c(a,e,t))&&(r.generations[t]=r.next++),r.contents[t]=n,r.generations[t]});r.contents.length=r.generations.length=a.length;let u=a.map((e,n)=>q(FD,{itemVar:o,itemValue:e,indexVar:s,indexValue:n,children:t},`${n}-${l[n]}`));return n.wrap(q(wT.Provider,{value:!0,children:u}))},text({rawArgs:e,children:t=[]},n){let{itemVar:r,indexVar:i,listExpr:a}=PD(e,n.args),o=n.evaluate(a);if(!Array.isArray(o))throw Error(`expression did not evaluate to an array`);return o.map((e,a)=>n.renderText(t,{[r]:e,...i?{[i]:a}:void 0})).join(``)}}),$({name:`do`,block:!0,render({children:e=[]},t){let n=t.collectText(e);return Pm(`do`,``,()=>t.mutate(n))}});var ID=he({stop:()=>{}});$({name:`repeat`,block:!0,interpolate:!0,parameters:[Dc],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(ql),f=i(()=>u(!0),[]);if(r(()=>{if(l)return;let e=setInterval(()=>{d?.()||c(e=>e+1)},o);return()=>clearInterval(e)},[o,l]),s===0&&!l)return null;let p=q(ID.Provider,{value:{stop:f},children:q(S,{children:t.renderNodes(e)},s)});return t.className||t.id?q(`span`,{id:t.id,class:t.cls,children:p}):p}});var LD=()=>!0,RD=new cr([`set`,`unset`,`if`,`for`,`switch`,`do`,`print`,`goto`,`nobr`,`span`]);function zD(e){return e.every(e=>{switch(e.type){case`macro`:return RD.has(e.name)&&zD(e.children)&&(e.branches??[]).every(e=>zD(e.children));case`html`:return zD(e.children);default:return!0}})}function BD({onSettled:e}){return Ne(()=>{let t=setTimeout(e,0);return()=>clearTimeout(t)},[]),null}function VD(){let e=j(Lm),{nobr:t,inline:n,structural:r}=cd(),i=j(Xm),a=j(ID),o=j(Hw),s=j(wT),c=j(ql),l=A([]);Ne(()=>{let e=NC(()=>{let e=l.current.splice(0);queueMicrotask(()=>{for(let t of e)me(null,t)})});return()=>{e();for(let e of l.current.splice(0))me(null,e)}},[]);let u=u=>{let d=Yl(e.getValues),f=document.createElement(`div`),p=zD(u)?()=>{let e=l.current.indexOf(f);e!==-1&&(l.current.splice(e,1),me(null,f))}:null;me(q(Kl.Provider,{value:LD,children:q(Lm.Provider,{value:e,children:q(Im.Provider,{value:d,children:q(Rm.Provider,{value:t,children:q(Bm.Provider,{value:n,children:q(Vm.Provider,{value:r,children:q(Xm.Provider,{value:i,children:q(ID.Provider,{value:a,children:q(Hw.Provider,{value:o,children:q(wT.Provider,{value:s,children:q(ql.Provider,{value:c,children:[Kh(u,{nobr:t,inline:n,structural:r,locals:d}),p&&q(BD,{onSettled:p})]})})})})})})})})})})}),f),l.current.push(f)};return e=>qx(()=>u(e))}$({name:`button`,block:!0,interpolate:!0,parameters:[{name:`label`,type:`text`,holds:`markup`,required:!0}],render({rawArgs:e,children:t=[]},n){let r=n.resolve?.(n.args.label??``)??e,i=VD(),a=()=>i(t);return n.useAction({type:`button`,key:e,authorId:n.id,label:r,perform:a}),q(`button`,{type:`button`,id:n.id,class:n.cls,onClick:a,children:r})}}),$({name:`link`,block:!0,interpolate:!0,merged:!0,parameters:[{name:`text`,type:`string`,holds:`markup`,required:!0},{name:`passage`,type:`passage`}],render({children:e=[]},t){let n=t.resolve?.(t.args.text??``)??``,r=null,i;if(t.args.passage!==void 0)try{r=Ac(t.args.passage,t.evaluate,Q.getState())}catch(e){i={error:e}}let a=VD(),o=()=>{i||(a(e),r&&Q.getState().navigate(r))};return t.useAction({type:`link`,key:r||n,authorId:t.id,label:n,target:r??void 0,disabled:i?!0:void 0,perform:o}),i?q(Mm,{macro:`link`,error:i.error}):q(`a`,{id:t.id,class:t.cls,href:`#`,onClick:e=>{e.preventDefault(),o()},children:n})}});function HD(e,t,n){return ED(t.slice(1),t=>e===n(t))}$({name:`switch`,subMacros:[`case`,`default`],parameters:[{name:`expression`,type:`expression`,required:!0}],interpolate:!0,merged:!0,render({rawArgs:e,branches:t=[]},n){let r;try{r=n.evaluate(e)}catch(e){return q(Mm,{macro:`switch`,error:e})}let i;try{i=HD(r,t,n.evaluate)}catch(e){return q(Mm,{macro:`case`,error:e})}return i?DD(i,n):null},text({rawArgs:e,branches:t=[]},n){let r=HD(n.evaluate(e),t,n.evaluate);return r?n.renderText(r.children):``}});var UD=[Dc];$({name:`timed`,subMacros:[`next`],interpolate:!0,parameters:UD,render({branches:e=[]},t){let{useState:n,useEffect:r,useMemo:i,useContext:a}=t.hooks,o=a(ql),s=i(()=>e.map(e=>({delay:Oc(e.rawArgs,UD).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(Vu(t.resolve(u.className),t.resolve(u.id),t.renderNodes(u.nodes)))}}),$({name:`stop`,render(e,t){let{stop:n}=t.hooks.useContext(ID);return t.hooks.useLayoutEffect(()=>{n()},[n]),null}});function WD(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:[Dc],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(()=>{if(s.current){let e=s.current.textContent||``;f(e.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(WD(e,t,m));return n(),window.addEventListener(`resize`,n),()=>window.removeEventListener(`resize`,n)},[m,p,_]);let v=[`macro-type`,_?`macro-type-done`:``,t.className||``].filter(Boolean).join(` `);return q(`span`,{id:t.id,class:v,ref:s,children:[q(`span`,{ref:c,class:`macro-type-inner`,style:{display:`inline`,visibility:d===null?`hidden`:`visible`,clipPath:l},children:t.renderNodes(e,{inline:!0})}),!_&&p>0&&q(`span`,{class:`macro-type-cursor`})]})}}),$({name:`widget`,block:!0,parameters:jl,render({children:e=[]},t){let n,r;try{let e=Ml(t.args);for(let t of e.params)_s(t.slice(1),t);Nl(e),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&&zl(n,e)},[i,o,s]),r?q(Mm,{macro:`widget`,error:r}):null}}),$({name:`story-title`,interpolate:!0,render(e,t){let n=Q(e=>e.storyData?.name||``),r=t.className?`story-title ${t.className}`:`story-title`;return q(`span`,{id:t.id,class:r,children:n})},text:()=>Q.getState().storyData?.name||``});function GD(e,t){return t?`${e} (${t})`:e}function KD(e){$({name:e.name,interpolate:!0,render(t,n){if(e.hidden?.())return null;let[r,i]=je(!1),a=e.setup?.()??{perform:()=>{}},{disabled:o,title:s=e.title}=a,c=n.className?`menubar-button ${n.className}`:`menubar-button`,l=e.dialog?()=>i(!0):e.confirm?()=>{confirm(e.confirm)&&a.perform()}:a.perform;return n.useAction({type:e.actionType,key:e.name,authorId:n.id,label:typeof e.label==`string`?e.label:e.name,disabled:o,perform:e.dialog?()=>i(!0):a.perform}),q(S,{children:[q(`button`,{type:`button`,id:n.id,class:c,onClick:l,disabled:o,title:s,children:e.label}),e.dialog&&r&&q(Uw,{passageName:e.dialog.passageName,fallbackMarkup:e.dialog.fallbackMarkup,panelClass:e.dialog.panelClass,label:typeof e.label==`string`?e.label:e.name,onClose:()=>i(!1),showCloseButton:e.dialog.showCloseButton})]})}})}KD({name:`back`,label:`← Back`,actionType:`back`,setup:()=>({perform:Q(e=>e.goBack),disabled:!Q(e=>e.historyIndex>0)})}),KD({name:`forward`,label:`Forward →`,actionType:`forward`,setup:()=>({perform:Q(e=>e.goForward),disabled:!Q(e=>e.historyIndex<e.history.length-1)})}),KD({name:`quicksave`,label:`QuickSave`,actionType:`save`,setup:()=>{let{quickSaveKey:e}=Jl(`quickSaveKey`);return{perform:qw,title:GD(`Quick Save`,e)}}}),KD({name:`quickload`,label:`QuickLoad`,actionType:`load`,confirm:`Load saved game? Current progress will be lost.`,setup:()=>{let{hasSave:e,quickLoadKey:t}=Jl(`hasSave`,`quickLoadKey`,`knownSaves`);return{perform:Jw,disabled:!e(),title:GD(`Quick Load`,t)}}}),KD({name:`restart`,label:`↺ Restart`,actionType:`restart`,confirm:`Restart the story? All progress will be lost.`,setup:()=>({perform:Q(e=>e.restart)})}),KD({name:`saves`,label:`Saves`,actionType:`dialog`,dialog:{passageName:`SaveLoad`,fallbackMarkup:`{save-manager}`,panelClass:`dialog-saves`}}),KD({name:`settings`,label:`Settings`,actionType:`dialog`,hidden:()=>!vT.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({rawArgs:e,children:t=[]},n){let[r,i]=n.hooks.useState(!1),{noclose:a}=n.args,o=n.resolve(n.args.label??``)??``,s=n.collectText(t).trim().replace(/^[\"']|[\"']$/g,``),c=()=>i(!0);return n.useAction({type:`open-dialog`,key:e,authorId:n.id,label:o,target:s,perform:c}),q(S,{children:[q(`button`,{type:`button`,id:n.id,class:n.cls,onClick:c,children:o}),r&&q(Uw,{passageName:s,onClose:()=>i(!1),showCloseButton:!a})]})}});function qD(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 JD(e){return new Date(e).toLocaleDateString(void 0,{month:`short`,day:`numeric`,year:`numeric`})}function YD({className:e,id:t}){let[n,r]=je(`load`),[i,a]=je([]),[o,s]=je(!0),[c,l]=je(null),[u,d]=je(()=>new Set),[f,p]=je(null),m=A(!1),[h,g]=je(``),_=A(null),v=A(null),y=j(Hw),{storyData:b,playthroughId:x,beginSave:S,loadFromPayload:C}=Jl(`storyData`,`playthroughId`,`beginSave`,`loadFromPayload`),w=b?.ifid??``,[T,ee]=je(!1),E=Ie(async()=>{if(!w)return;let e=await yb(w);ee(Iv()===`memory`),a(e),s(!1)},[w]);Ne(()=>{E()},[E]),Ne(()=>w?Bb(w,E,!0):void 0,[w,E]),Ne(()=>{f&&_.current&&(_.current.focus(),_.current.select())},[f]);let te=A(!0),D=A(void 0),ne=A(void 0),O=(e,t=`success`)=>{te.current&&(clearTimeout(D.current),l({text:e,type:t}),D.current=window.setTimeout(()=>l(null),3e3))};Ne(()=>(te.current=!0,()=>{te.current=!1,clearTimeout(D.current),clearTimeout(ne.current)}),[]);let re=e=>{d(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},ie=async()=>{if(!w)return;let e=gC();try{await cb(void 0,void 0,S,async t=>{let n=await ub(w,e,t);await CC(e,n)}),O(T?`Save created (temporary)`:`Save created`),await E()}catch{O(`Failed to create save`,`error`)}},ae=async e=>{let t=gC();try{await cb(void 0,void 0,S,async n=>{let r=await fb(e,n,void 0,t);if(!r)throw Error(`Save not found`);await CC(t,r)}),O(`Save overwritten`),await E()}catch{O(`Failed to overwrite save`,`error`)}},oe=async e=>{let t=OC();try{let n=await gb(e.meta.id)??e;if(kC(t))return;C(hb(n.payload),void 0,n.meta.playthroughId,t),O(`Game loaded`),y&&(ne.current=window.setTimeout(y,500)),await E()}catch{O(`Failed to load save`,`error`)}},se=async(e,t,n)=>{try{await n(),O(e),await E()}catch{O(t,`error`)}},ce=async e=>{confirm(`Delete this save?`)&&await se(`Save deleted`,`Failed to delete save`,async()=>{await _b(e);let t=await Kb(w);Q.setState(e=>{e.knownSaves=t})})},le=e=>{m.current=!1,p(e.meta.id),g(e.meta.title)},ue=async()=>{let e=f;e&&h.trim()&&await se(`Save renamed`,`Failed to rename`,async()=>{await vb(e,h.trim()),p(t=>t===e?null:t)})},de=e=>{e.key===`Enter`?ue():e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),m.current=!0,p(null))},fe=()=>{m.current||ue()},pe=async e=>{try{let t=await ox(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`)}},me=()=>{v.current?.click()},he=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(!uv(t))throw Error(`Invalid save file format`);await cx(t,w),O(`Save imported`),await E()}catch(e){O(Is(e,`Failed to import save`),`error`)}}},ge=i.reduce((e,t)=>e+t.saves.length,0);return q(`div`,{id:t,class:e?`save-manager ${e}`:`save-manager`,children:[q(`div`,{class:`saves-header`,children:q(`div`,{class:`saves-header-left`,children:q(`div`,{class:`saves-mode-toggle`,children:[q(`button`,{type:`button`,class:n===`save`?`active`:``,onClick:()=>r(`save`),children:`Save`}),q(`button`,{type:`button`,class:n===`load`?`active`:``,onClick:()=>r(`load`),children:`Load`})]})})}),T&&q(`div`,{class:`saves-notice`,role:`status`,children:`Saves can not be kept in this browser: they are lost when the page is reloaded or closed. Export a save to keep it.`}),q(`div`,{class:`saves-toolbar`,children:[q(`button`,{type:`button`,class:`saves-toolbar-button`,onClick:me,children:`Import`}),q(`input`,{ref:v,type:`file`,accept:`.json`,style:`display:none`,onChange:he})]}),q(`div`,{class:`saves-body`,children:[o?q(`div`,{class:`saves-empty`,children:`Loading...`}):ge===0&&n===`load`?q(`div`,{class:`saves-empty`,children:`No saves yet`}):i.map(e=>{let t=u.has(e.playthrough.id),r=e.playthrough.id===x;return n===`save`&&!r||n===`load`&&e.saves.length===0&&!r?null:q(`div`,{class:`playthrough-group`,children:[q(`button`,{type:`button`,class:`playthrough-header`,\"aria-expanded\":!t,onClick:()=>re(e.playthrough.id),children:[q(`span`,{class:`playthrough-chevron ${t?``:`open`}`,\"aria-hidden\":`true`,children:`▶`}),q(`span`,{class:`playthrough-label`,children:[e.playthrough.label,r?` (current)`:``]}),q(`span`,{class:`playthrough-date`,children:JD(e.playthrough.createdAt)})]}),!t&&q(`div`,{class:`playthrough-saves`,children:[e.saves.map(e=>q(`div`,{class:`save-slot`,children:[q(`div`,{class:`save-slot-info`,children:[f===e.meta.id?q(`input`,{ref:_,class:`save-rename-input`,value:h,onInput:e=>g(e.target.value),onKeyDown:de,onBlur:fe}):q(`div`,{class:`save-slot-title`,children:e.meta.title}),q(`div`,{class:`save-slot-meta`,children:[q(`span`,{children:e.meta.passage}),q(`span`,{children:qD(e.meta.updatedAt)})]})]}),q(`div`,{class:`save-slot-actions`,children:[n===`save`?q(`button`,{type:`button`,class:`save-slot-action primary`,onClick:()=>ae(e.meta.id),children:`Save Here`}):q(`button`,{type:`button`,class:`save-slot-action primary`,onClick:()=>oe(e),children:`Load`}),q(`button`,{type:`button`,class:`save-slot-action`,onClick:()=>le(e),children:`Rename`}),q(`button`,{type:`button`,class:`save-slot-action`,onClick:()=>pe(e.meta.id),children:`Export`}),q(`button`,{type:`button`,class:`save-slot-action danger`,onClick:()=>ce(e.meta.id),children:`Delete`})]})]},e.meta.id)),n===`save`&&r&&q(`button`,{type:`button`,class:`save-slot-new`,onClick:ie,children:`+ New Save`})]})]},e.playthrough.id)}),n===`save`&&!o&&!i.some(e=>e.playthrough.id===x)&&q(`div`,{class:`playthrough-group`,children:q(`div`,{class:`playthrough-saves`,children:q(`button`,{type:`button`,class:`save-slot-new`,onClick:ie,children:`+ New Save`})})})]}),c&&q(`div`,{class:`saves-status ${c.type===`error`?`error`:``}`,children:c.text})]})}$({name:`save-manager`,interpolate:!0,render(e,t){return q(YD,{className:t.className,id:t.id})}});function XD({name:e,def:t}){let[n,r]=je(()=>vT.get(e));Ne(()=>{let t=()=>r(vT.get(e));return t(),fT(t)},[e]);let i=t=>vT.set(e,t);switch(t.type){case`toggle`:return q(`label`,{class:`settings-row`,children:[q(`span`,{children:t.config.label}),q(`input`,{type:`checkbox`,checked:!!n,onChange:e=>i(e.target.checked)})]});case`list`:return q(`label`,{class:`settings-row`,children:[q(`span`,{children:t.config.label}),q(`select`,{value:String(n),onChange:e=>i(e.target.value),children:t.config.options.map(e=>q(`option`,{value:e,children:e},e))})]});case`range`:return q(`label`,{class:`settings-row`,children:[q(`span`,{children:[t.config.label,`: `,String(n)]}),q(`input`,{type:`range`,min:t.config.min,max:t.config.max,step:t.config.step,value:Number(n),onInput:e=>i(parseFloat(e.target.value))})]})}}function ZD({className:e,id:t}){let n=vT.getDefinitions();return q(`div`,{id:t,class:e?`settings-controls ${e}`:`settings-controls`,children:Array.from(n.entries()).map(([e,t])=>q(XD,{name:e,def:t},e))})}$({name:`settings-controls`,interpolate:!0,render(e,t){return q(ZD,{className:t.className,id:t.id})}}),$({name:`include`,interpolate:!0,merged:!0,parameters:[{name:`inline`,type:`flag`},{name:`passage`,type:`passage`,required:!0}],render(e,t){let{storyData:n}=Jl(`storyData`),{inline:r}=t.args,i=``,a;try{i=Ac(t.args.passage,t.evaluate,Q.getState())}catch(e){a={error:e}}let o=n?.passages.get(i),s=t.hooks.useMemo(()=>o?ss(o.content):null,[o]),c=!a&&!!o;if(t.hooks.useEffect(()=>{c&&Q.getState().trackRender(i)},[c,i]),!n)return null;if(a)return q(Mm,{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(Rm.Provider,{value:!0},u)):t.wrap(u)}}),$({name:`nobr`,block:!0,interpolate:!0,render({children:e=[]},t){return t.wrap(t.h(Rm.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(Ac(t.args.passage,t.evaluate,e))}catch(t){Nm(`goto`,t,e),r({error:t})}},[]),n?q(Mm,{macro:`goto`,error:n.error}):null}});function QD(e){try{return Do(e)}catch(e){if(e instanceof _o)return null;throw e}}$({name:`unset`,parameters:[{name:`variable`,type:`variable`,required:!0}],render({rawArgs:e},t){return Pm(`unset`,e,()=>{let e=Q.getState(),n=t.args.variable??``,r=QD(n);if(r)r.nested?t.mutate(`delete ${n}`):r.sigil===`$`?e.deleteVariable(r.name):r.sigil===`_`?e.deleteTemporary(r.name):r.sigil===`%`?e.deleteTransient(r.name):t.update(r.name,void 0);else throw Error(`{unset} expects a variable ($name, _name, %name, or @name, or a field of one such as $name.field or $name[\"field\"]), got \"${n}\"`)})}});var $D={name:`variable`,type:`variable`,required:!0};function eO(e,t){return e.useAction({key:`$${e.varName}`,authorId:e.id,variable:e.varName,value:e.value,...t})}function tO(e,t,n=e=>e===void 0?``:String(e)){$({name:e,interpolate:!0,storeVar:!0,parameters:[$D,{name:`placeholder`,type:`string`,holds:`text`}],render(r,i){let a=i.args.placeholder??``;eO(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:Bu(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))}})}})}tO(`textbox`,`text`),tO(`numberbox`,`number`,e=>e===void 0?0:Number(e)),tO(`textarea`),$({name:`checkbox`,interpolate:!0,storeVar:!0,parameters:[$D,{name:`label`,type:`text`,holds:`text`}],render(e,t){let n=t.args.label??``;return eO(t,{type:`checkbox`,label:n||t.varName||``,value:!!t.value,perform:e=>t.setValue(e===void 0?!t.getValue():!!e)}),q(`label`,{id:t.id,class:t.cls,children:[q(`input`,{type:`checkbox`,checked:!!t.value,onChange:e=>t.setValue(e.target.checked)}),n?` ${n}`:null]})}}),$({name:`radiobutton`,interpolate:!0,storeVar:!0,parameters:[$D,{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(Um);return eO(t,{type:`radiobutton`,key:`$${t.varName}:${n}`,label:r||n,perform:()=>t.setValue(n)}),q(`label`,{id:t.id,class:t.cls,children:[q(`input`,{type:`radio`,name:i?`radio-${i}-${t.varName}`:`radio-${t.varName}`,checked:t.value===n,onChange:()=>t.setValue(n)}),r?` ${r}`:null]})}}),$({name:`listbox`,interpolate:!0,subMacros:[`option`],storeVar:!0,parameters:[$D],render({children:e=[]},t){let n=t.extractOptions(e);return eO(t,{type:`listbox`,label:t.varName,options:n,perform:e=>{e!==void 0&&t.setValue(String(e))}}),q(`select`,{id:t.id,class:t.cls,value:Bu(t.value),onChange:e=>t.setValue(e.target.value),children:n.map(e=>q(`option`,{value:e,children:e},e))})}}),$({name:`cycle`,block:!0,interpolate:!0,storeVar:!0,parameters:[$D],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 eO(t,{type:`cycle`,label:t.value==null?n[0]||``:String(t.value),options:n,perform:e=>{e===void 0?r():t.setValue(e)}}),q(`button`,{type:`button`,id:t.id,class:t.cls,onClick:r,children:t.value==null?n[0]||``:String(t.value)})}}),$({name:`span`,block:!0,interpolate:!0,render({children:e=[]},t){return t.wrap(t.renderNodes(e))},text:({children:e=[]},t)=>t.renderText(e)}),$({name:`watch`,parameters:[{name:`condition`,type:`string`,holds:`expression`,required:!0},{name:`options`,type:`options`,parameters:[{name:`goto`,type:`string`,holds:`passage`},{name:`dialog`,type:`string`,holds:`passage`},{name:`run`,type:`string`,holds:`statements`},{name:`name`,type:`string`,holds:`text`},{name:`priority`,type:`number`},{name:`once`,type:`flag`}]}],render(e,t){let{hooks:n}=t,{condition:r,options:i}=t.args;if(r===void 0)return null;let a=n.useContext(Kl),[,o]=n.useState(0);n.useEffect(()=>ES(()=>o(e=>e+1)),[]);let s=n.useContext(zm),c=JSON.stringify([r,i]);n.useLayoutEffect(()=>s?lS(r,i):void 0,[s,c]);let l=n.useRef(null);return(l.current===null||l.current!==TS()&&!a?.(Q.getState()))&&(l.current=TS(),aS(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,pS(n)),null}});var nO=`*,:before,:after{box-sizing:border-box}html{-webkit-text-size-adjust:100%;font-size:16px}body{color:#e0e0e0;background-color:#1a1a2e;min-height:100vh;margin:0;padding:0;font-family:Georgia,Times New Roman,serif;line-height:1.75}tw-storydata{display:none!important}#story{max-width:42em;margin:0 auto;padding:2em 1.5em}.passage-container{position:relative}.passage-container--crossfading{display:grid}.passage-container--crossfading>*{grid-area:1/1}.passage{animation:passage-fade-in var(--passage-in-duration,.3s) ease}.passage[data-transition=none]{animation:none}.passage-snapshot{animation:passage-fade-out var(--passage-out-duration,.3s) ease forwards;pointer-events:none;-webkit-user-select:none;user-select:none}@keyframes passage-fade-in{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}@keyframes passage-fade-out{0%{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(-8px)}}@media (prefers-reduced-motion:reduce){.passage,.passage-snapshot{animation-duration:10ms!important}}.macro-button{color:#64b5f6;font:inherit;cursor:pointer;background:#64b5f626;border:1px solid #64b5f666;border-radius:4px;padding:.25em .75em;font-size:.95em;transition:background .2s,border-color .2s}.macro-button:hover{background:#64b5f640;border-color:#90caf9}.macro-button:active{background:#64b5f659}.error{color:#ef5350;background:#ef53501a;border:1px solid #ef5350;border-radius:4px;padding:1em;font-family:monospace}.spindle-error-banners{z-index:300;flex-direction:column;gap:.5em;width:min(42em,100% - 1.5em);display:flex;position:fixed;top:.75em;left:50%;transform:translate(-50%)}.spindle-error-banner{color:#ffcdd2;background:#2b1a1e;border:1px solid #ef5350;border-radius:4px;padding:.75em 2.75em .75em 1em;font-size:.9em;line-height:1.5;position:relative;box-shadow:0 2px 12px #00000080}.spindle-error-banner-message{color:#ef9a9a;font-family:monospace}.spindle-error-banner-dismiss{color:inherit;cursor:pointer;background:0 0;border:none;font-size:1em;position:absolute;top:.5em;right:.5em}.spindle-error-banner-dismiss:hover{color:#fff}.loading{text-align:center;opacity:.6;padding:2em}.story-menubar{z-index:100;background:#16213e;border-bottom:1px solid #ffffff14;align-items:center;gap:.5em;padding:.5em 1.5em;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Noto Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;font-size:.9em;display:flex;position:sticky;top:0}@media (max-width:600px){.story-menubar{flex-wrap:wrap;padding:.5em .75em}.story-menubar .story-title{flex:100%}}.story-title{color:#e0e0e0;white-space:nowrap;text-overflow:ellipsis;flex:1;font-weight:600;overflow:hidden}.menubar-button{color:#9e9e9e;cursor:pointer;font:inherit;background:0 0;border:1px solid #0000;border-radius:4px;padding:.35em .7em;transition:color .2s,background .2s}.menubar-button:hover{color:#e0e0e0;background:#ffffff14}.menubar-button:disabled{opacity:.4;cursor:default}.menubar-button:disabled:hover{color:#9e9e9e;background:0 0}.dialog-overlay{z-index:200;background:#0009;justify-content:center;align-items:center;display:flex;position:fixed;top:0;bottom:0;left:0;right:0}.dialog-panel{color:#e0e0e0;background:#16213e;border:1px solid #ffffff1a;border-radius:8px;flex-direction:column;width:90%;max-width:500px;max-height:80vh;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Noto Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;display:flex;position:relative}.dialog-panel:focus{outline:none}.dialog-saves{max-width:550px}.dialog-settings{max-width:400px}.dialog-settings .dialog-body{padding-top:2.25em}.dialog-close{z-index:1;color:#9e9e9e;cursor:pointer;background:0 0;border:none;padding:.25em;font-size:1.1em;line-height:1;position:absolute;top:.75em;right:.75em}.dialog-close:hover{color:#e0e0e0}.dialog-body{flex:1;min-height:0;overflow-y:auto}.settings-controls{flex-direction:column;gap:1em;padding:1em 1.25em;display:flex}.settings-row{justify-content:space-between;align-items:center;gap:1em;display:flex}.settings-row select,.settings-row input[type=range]{accent-color:#64b5f6}.settings-row select{color:#e0e0e0;font:inherit;background:#1a1a2e;border:1px solid #ffffff26;border-radius:4px;padding:.3em .5em}.settings-row input[type=checkbox]{accent-color:#64b5f6;width:1.1em;height:1.1em}.save-manager{flex-direction:column;flex:1;min-height:0;display:flex}.saves-header{border-bottom:1px solid #ffffff14;flex-shrink:0;justify-content:space-between;align-items:center;padding:1em 3em 1em 1.25em;font-weight:600;display:flex}.saves-header-left{align-items:center;gap:.75em;display:flex}.saves-mode-toggle{border:1px solid #ffffff26;border-radius:4px;gap:0;display:flex;overflow:hidden}.saves-mode-toggle button{color:#9e9e9e;font:inherit;cursor:pointer;background:0 0;border:none;padding:.3em .8em;font-size:.85em;font-weight:600;transition:background .2s,color .2s}.saves-mode-toggle button.active{color:#64b5f6;background:#64b5f633}.saves-mode-toggle button:hover:not(.active){color:#e0e0e0}.saves-body{flex:1;min-height:0;padding:.75em 1.25em;overflow-y:auto}.saves-empty{text-align:center;opacity:.5;padding:2em 1em;font-size:.9em}.saves-toolbar{border-bottom:1px solid #ffffff14;flex-shrink:0;gap:.5em;padding:.5em 1.25em;display:flex}.saves-toolbar-button{color:#9e9e9e;font:inherit;cursor:pointer;background:#ffffff0d;border:1px solid #ffffff1a;border-radius:4px;padding:.3em .7em;font-size:.8em;transition:background .2s,color .2s}.saves-toolbar-button:hover{color:#e0e0e0;background:#ffffff1a}.playthrough-group{margin-bottom:.75em}.playthrough-header{text-align:left;cursor:pointer;-webkit-user-select:none;user-select:none;color:#9e9e9e;background:0 0;border:0;align-items:center;gap:.5em;width:100%;padding:.4em 0;font-family:inherit;font-size:.85em;transition:color .2s;display:flex}.playthrough-header:hover{color:#e0e0e0}.playthrough-chevron{font-size:.7em;transition:transform .2s;display:inline-block}.playthrough-chevron.open{transform:rotate(90deg)}.playthrough-label{font-weight:600}.playthrough-date{opacity:.6;font-size:.9em}.playthrough-saves{flex-direction:column;gap:.4em;padding-left:.25em;display:flex}.save-slot{background:#ffffff08;border:1px solid #ffffff0f;border-radius:6px;align-items:center;gap:.75em;padding:.5em .6em;transition:background .15s;display:flex}.save-slot:hover{background:#ffffff0f}.save-slot-info{flex:1;min-width:0}.save-slot-title{white-space:nowrap;text-overflow:ellipsis;font-size:.9em;font-weight:500;overflow:hidden}.save-slot-meta{color:#9e9e9e;gap:.75em;font-size:.75em;display:flex}.save-slot-actions{flex-shrink:0;gap:.3em;display:flex}.save-slot-action{color:#9e9e9e;font:inherit;cursor:pointer;white-space:nowrap;background:0 0;border:1px solid #0000;border-radius:3px;padding:.2em .5em;font-size:.75em;transition:color .2s,background .2s}.save-slot-action:hover{color:#e0e0e0;background:#ffffff14}.save-slot-action.primary{color:#64b5f6;border-color:#64b5f64d}.save-slot-action.primary:hover{background:#64b5f626}.save-slot-action.danger:hover{color:#ef5350;background:#ef53501a}.save-slot-new{color:#9e9e9e;font:inherit;cursor:pointer;background:0 0;border:1px dashed #ffffff1f;border-radius:6px;justify-content:center;align-items:center;width:100%;margin-top:.25em;padding:.5em;font-size:.8em;transition:color .2s,border-color .2s,background .2s;display:flex}.save-slot-new:hover{color:#64b5f6;background:#64b5f60d;border-color:#64b5f64d}.saves-notice{color:#ffb74d;background:#ffb74d14;border-bottom:1px solid #ffb74d4d;flex-shrink:0;padding:.5em 1.25em;font-size:.8em}.saves-status{color:#81c784;text-align:center;border-top:1px solid #ffffff14;flex-shrink:0;padding:.5em 1.25em;font-size:.8em}.saves-status.error{color:#ef5350;background:0 0;border:none;border-radius:0;padding:.5em 1.25em;font-family:inherit}.save-rename-input{color:#e0e0e0;font:inherit;background:#1a1a2e;border:1px solid #64b5f666;border-radius:3px;width:100%;padding:.15em .4em;font-size:.9em}.save-rename-input:focus{border-color:#64b5f6;outline:none}.macro-link{color:#64b5f6;cursor:pointer;border-bottom:1px solid #64b5f64d;text-decoration:none;transition:color .2s,border-color .2s}.macro-link:hover{color:#90caf9;border-bottom-color:#90caf9}.macro-link:active{color:#42a5f5}.macro-textbox,.macro-numberbox,.macro-textarea{color:#e0e0e0;font:inherit;background:#1a1a2e;border:1px solid #ffffff26;border-radius:4px;padding:.3em .5em}.macro-textbox:focus,.macro-numberbox:focus,.macro-textarea:focus{border-color:#64b5f6;outline:none}.macro-textarea{resize:vertical;min-height:3em}.macro-checkbox,.macro-radiobutton{cursor:pointer;align-items:center;gap:.3em;display:inline-flex}.macro-checkbox input,.macro-radiobutton input{accent-color:#64b5f6}.macro-listbox{color:#e0e0e0;font:inherit;background:#1a1a2e;border:1px solid #ffffff26;border-radius:4px;padding:.3em .5em}.macro-cycle{color:#64b5f6;font:inherit;cursor:pointer;background:#64b5f626;border:1px solid #64b5f666;border-radius:4px;padding:.25em .75em;transition:background .2s,border-color .2s}.macro-cycle:hover{background:#64b5f640;border-color:#90caf9}.macro-meter{background:#2a2a3e;border:1px solid #444;border-radius:.3em;width:100%;height:1.4em;position:relative;overflow:hidden}.macro-meter-fill{background:#64b5f6;height:100%;transition:width .3s}.macro-meter-label{color:#e0e0e0;text-shadow:0 1px 2px #000c;pointer-events:none;justify-content:center;align-items:center;font-size:.85em;display:flex;position:absolute;top:0;bottom:0;left:0;right:0}.md{display:contents}.passage p{margin:.6em 0}.passage p:first-child{margin-top:0}.passage p:last-child{margin-bottom:0}.passage h1,.passage h2,.passage h3,.passage h4,.passage h5,.passage h6{color:#f0f0f0;margin:1em 0 .4em;line-height:1.3}.passage h1{font-size:1.8em}.passage h2{font-size:1.5em}.passage h3{font-size:1.25em}.passage h4{font-size:1.1em}.passage h5{font-size:1em}.passage h6{opacity:.8;font-size:.9em}.passage code{background:#ffffff14;border-radius:3px;padding:.15em .35em;font-family:Fira Code,Cascadia Code,Consolas,monospace;font-size:.9em}.passage pre{background:#0000004d;border:1px solid #ffffff14;border-radius:6px;margin:.8em 0;padding:1em;overflow-x:auto}.passage pre code{background:0 0;border-radius:0;padding:0;font-size:.85em}.passage blockquote{color:#b0b0b0;border-left:3px solid #64b5f680;margin:.8em 0;padding:.4em 1em}.passage blockquote p{margin:.3em 0}.passage ul,.passage ol{margin:.6em 0;padding-left:1.8em}.passage li{margin:.2em 0}.passage hr{border:none;border-top:1px solid #ffffff1f;margin:1.2em 0}.passage table{border-collapse:collapse;width:100%;margin:.8em 0}.passage th,.passage td{text-align:left;border:1px solid #ffffff1f;padding:.5em .75em}.passage th{background:#ffffff0f;font-weight:600}.passage tr:nth-child(2n){background:#ffffff05}.passage del{opacity:.5}.passage strong{color:#f0f0f0}.macro-type-cursor:after{content:\"█\";color:#64b5f6;animation:.7s step-end infinite type-blink}.macro-type-done .macro-type-cursor:after{display:none}@keyframes type-blink{50%{opacity:0}}`;function rO(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 iO(e){let t=document.getElementById(`root`);throw t&&rO(t,e),Error(`spindle: ${e.length} validation error(s):\\n${e.join(`\n`)}`)}function aO(e,t=``){try{return e()}catch(e){return iO([t+Is(e)])}}function oO(){return Kc([...El(),...Ps()])}function sO(e,t){let n=El().filter(e=>e.storeVar).map(e=>e.name);return JE(e.passages,t,n,oO())}function cO(e,t){return oE(e.passages.values(),{isKnownMacro:e=>!!fl(e)||vl(e)||!!Ns(e),macroNames:El().map(e=>e.name),parametersOf:oO(),only:t}).map($T)}function lO(){let e=oT(),t=document.createElement(`style`);if(t.id=`spindle-styles`,t.textContent=nO,document.head.appendChild(t),YT(),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&&rO(t,[e]),Error(`spindle: ${e}`)}let i=aO(()=>AE(r.content));for(let{name:t,block:n}of aO(()=>Rl(e.passages.values())))hr(t,n);let a=sO(e,i);a.push(...cO(e,e=>e.name===`StoryInit`));let o={},s=e.passages.get(`StoryTransients`);if(s){let e=aO(()=>AE(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=YE(e)}a.length>0&&iO(a),n=YE(i),UT(Object.keys(n),Object.keys(o)),Q.getState().init(e,n,o),LC();for(let[,t]of e.passages)t.tags.includes(`widget`)&&aO(()=>Bl(ss(t.content),t.name),`Passage \"${t.name}\": `);yx(ex(e.ifid));let c=[...sO(e,i),...cO(e,e=>e.name!==`StoryInit`)];c.length>0&&iO(c);let l=Q.getState().navigationId;Q.subscribe(e=>{e.navigationId!==l&&(l=e.navigationId,zw())}),bS();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.`);me(q(Yw,{}),d),(LT()??Promise.resolve()).then(vD).then(()=>{document.dispatchEvent(new CustomEvent(`:storyready`))})}document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,lO):lO();</script>\n </head>\n <body>\n <div id=\"root\"></div>\n {{STORY_DATA}}\n </body>\n</html>\n"})