diff --git a/assets/index-b4f7f0ac.js b/assets/index-b4f7f0ac.js deleted file mode 100644 index 557d23d..0000000 --- a/assets/index-b4f7f0ac.js +++ /dev/null @@ -1,202 +0,0 @@ -var vs=(d,g)=>()=>(g||d((g={exports:{}}).exports,g),g.exports);var Es=vs((exports,module)=>{function _mergeNamespaces(d,g){for(var $=0;$b[j]})}}}return Object.freeze(Object.defineProperty(d,Symbol.toStringTag,{value:"Module"}))}(function(){const g=document.createElement("link").relList;if(g&&g.supports&&g.supports("modulepreload"))return;for(const j of document.querySelectorAll('link[rel="modulepreload"]'))b(j);new MutationObserver(j=>{for(const _e of j)if(_e.type==="childList")for(const et of _e.addedNodes)et.tagName==="LINK"&&et.rel==="modulepreload"&&b(et)}).observe(document,{childList:!0,subtree:!0});function $(j){const _e={};return j.integrity&&(_e.integrity=j.integrity),j.referrerpolicy&&(_e.referrerPolicy=j.referrerpolicy),j.crossorigin==="use-credentials"?_e.credentials="include":j.crossorigin==="anonymous"?_e.credentials="omit":_e.credentials="same-origin",_e}function b(j){if(j.ep)return;j.ep=!0;const _e=$(j);fetch(j.href,_e)}})();var commonjsGlobal=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function getDefaultExportFromCjs(d){return d&&d.__esModule&&Object.prototype.hasOwnProperty.call(d,"default")?d.default:d}var jsxRuntimeExports={},jsxRuntime={get exports(){return jsxRuntimeExports},set exports(d){jsxRuntimeExports=d}},reactJsxRuntime_production_min={},reactExports={},react={get exports(){return reactExports},set exports(d){reactExports=d}},react_production_min={};/** - * @license React - * react.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var l$2=Symbol.for("react.element"),n$2=Symbol.for("react.portal"),p$3=Symbol.for("react.fragment"),q$1=Symbol.for("react.strict_mode"),r$1=Symbol.for("react.profiler"),t$1=Symbol.for("react.provider"),u$1=Symbol.for("react.context"),v$2=Symbol.for("react.forward_ref"),w=Symbol.for("react.suspense"),x$1=Symbol.for("react.memo"),y$2=Symbol.for("react.lazy"),z$1=Symbol.iterator;function A$1(d){return d===null||typeof d!="object"?null:(d=z$1&&d[z$1]||d["@@iterator"],typeof d=="function"?d:null)}var B$1={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C$1=Object.assign,D$1={};function E$1(d,g,$){this.props=d,this.context=g,this.refs=D$1,this.updater=$||B$1}E$1.prototype.isReactComponent={};E$1.prototype.setState=function(d,g){if(typeof d!="object"&&typeof d!="function"&&d!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,d,g,"setState")};E$1.prototype.forceUpdate=function(d){this.updater.enqueueForceUpdate(this,d,"forceUpdate")};function F(){}F.prototype=E$1.prototype;function G$1(d,g,$){this.props=d,this.context=g,this.refs=D$1,this.updater=$||B$1}var H$1=G$1.prototype=new F;H$1.constructor=G$1;C$1(H$1,E$1.prototype);H$1.isPureReactComponent=!0;var I$1=Array.isArray,J=Object.prototype.hasOwnProperty,K$1={current:null},L$1={key:!0,ref:!0,__self:!0,__source:!0};function M$1(d,g,$){var b,j={},_e=null,et=null;if(g!=null)for(b in g.ref!==void 0&&(et=g.ref),g.key!==void 0&&(_e=""+g.key),g)J.call(g,b)&&!L$1.hasOwnProperty(b)&&(j[b]=g[b]);var tt=arguments.length-2;if(tt===1)j.children=$;else if(1"u")throw new Error(g)}function createKey(){return Math.random().toString(36).substr(2,8)}function getHistoryState(d,g){return{usr:d.state,key:d.key,idx:g}}function createLocation(d,g,$,b){return $===void 0&&($=null),_extends$2({pathname:typeof d=="string"?d:d.pathname,search:"",hash:""},typeof g=="string"?parsePath(g):g,{state:$,key:g&&g.key||b||createKey()})}function createPath(d){let{pathname:g="/",search:$="",hash:b=""}=d;return $&&$!=="?"&&(g+=$.charAt(0)==="?"?$:"?"+$),b&&b!=="#"&&(g+=b.charAt(0)==="#"?b:"#"+b),g}function parsePath(d){let g={};if(d){let $=d.indexOf("#");$>=0&&(g.hash=d.substr($),d=d.substr(0,$));let b=d.indexOf("?");b>=0&&(g.search=d.substr(b),d=d.substr(0,b)),d&&(g.pathname=d)}return g}function getUrlBasedHistory(d,g,$,b){b===void 0&&(b={});let{window:j=document.defaultView,v5Compat:_e=!1}=b,et=j.history,tt=Action.Pop,nt=null,rt=it();rt==null&&(rt=0,et.replaceState(_extends$2({},et.state,{idx:rt}),""));function it(){return(et.state||{idx:null}).idx}function st(){tt=Action.Pop;let vt=it(),ft=vt==null?null:vt-rt;rt=vt,nt&&nt({action:tt,location:ct.location,delta:ft})}function ut(vt,ft){tt=Action.Push;let gt=createLocation(ct.location,vt,ft);$&&$(gt,vt),rt=it()+1;let pt=getHistoryState(gt,rt),yt=ct.createHref(gt);try{et.pushState(pt,"",yt)}catch{j.location.assign(yt)}_e&&nt&&nt({action:tt,location:ct.location,delta:1})}function at(vt,ft){tt=Action.Replace;let gt=createLocation(ct.location,vt,ft);$&&$(gt,vt),rt=it();let pt=getHistoryState(gt,rt),yt=ct.createHref(gt);et.replaceState(pt,"",yt),_e&&nt&&nt({action:tt,location:ct.location,delta:0})}function ht(vt){let ft=j.location.origin!=="null"?j.location.origin:j.location.href,gt=typeof vt=="string"?vt:createPath(vt);return invariant(ft,"No window.location.(origin|href) available to create URL for href: "+gt),new URL(gt,ft)}let ct={get action(){return tt},get location(){return d(j,et)},listen(vt){if(nt)throw new Error("A history only accepts one active listener");return j.addEventListener(PopStateEventType,st),nt=vt,()=>{j.removeEventListener(PopStateEventType,st),nt=null}},createHref(vt){return g(j,vt)},createURL:ht,encodeLocation(vt){let ft=ht(vt);return{pathname:ft.pathname,search:ft.search,hash:ft.hash}},push:ut,replace:at,go(vt){return et.go(vt)}};return ct}var ResultType;(function(d){d.data="data",d.deferred="deferred",d.redirect="redirect",d.error="error"})(ResultType||(ResultType={}));function isIndexRoute(d){return d.index===!0}function convertRoutesToDataRoutes(d,g,$){return g===void 0&&(g=[]),$===void 0&&($=new Set),d.map((b,j)=>{let _e=[...g,j],et=typeof b.id=="string"?b.id:_e.join("-");return invariant(b.index!==!0||!b.children,"Cannot specify children on an index route"),invariant(!$.has(et),'Found a route id collision on id "'+et+`". Route id's must be globally unique within Data Router usages`),$.add(et),isIndexRoute(b)?_extends$2({},b,{id:et}):_extends$2({},b,{id:et,children:b.children?convertRoutesToDataRoutes(b.children,_e,$):void 0})})}function matchRoutes(d,g,$){$===void 0&&($="/");let b=typeof g=="string"?parsePath(g):g,j=stripBasename(b.pathname||"/",$);if(j==null)return null;let _e=flattenRoutes(d);rankRouteBranches(_e);let et=null;for(let tt=0;et==null&&tt<_e.length;++tt)et=matchRouteBranch(_e[tt],safelyDecodeURI(j));return et}function flattenRoutes(d,g,$,b){g===void 0&&(g=[]),$===void 0&&($=[]),b===void 0&&(b="");let j=(_e,et,tt)=>{let nt={relativePath:tt===void 0?_e.path||"":tt,caseSensitive:_e.caseSensitive===!0,childrenIndex:et,route:_e};nt.relativePath.startsWith("/")&&(invariant(nt.relativePath.startsWith(b),'Absolute route path "'+nt.relativePath+'" nested under path '+('"'+b+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),nt.relativePath=nt.relativePath.slice(b.length));let rt=joinPaths([b,nt.relativePath]),it=$.concat(nt);_e.children&&_e.children.length>0&&(invariant(_e.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+rt+'".')),flattenRoutes(_e.children,g,it,rt)),!(_e.path==null&&!_e.index)&&g.push({path:rt,score:computeScore(rt,_e.index),routesMeta:it})};return d.forEach((_e,et)=>{var tt;if(_e.path===""||!((tt=_e.path)!=null&&tt.includes("?")))j(_e,et);else for(let nt of explodeOptionalSegments(_e.path))j(_e,et,nt)}),g}function explodeOptionalSegments(d){let g=d.split("/");if(g.length===0)return[];let[$,...b]=g,j=$.endsWith("?"),_e=$.replace(/\?$/,"");if(b.length===0)return j?[_e,""]:[_e];let et=explodeOptionalSegments(b.join("/")),tt=[];return tt.push(...et.map(nt=>nt===""?_e:[_e,nt].join("/"))),j&&tt.push(...et),tt.map(nt=>d.startsWith("/")&&nt===""?"/":nt)}function rankRouteBranches(d){d.sort((g,$)=>g.score!==$.score?$.score-g.score:compareIndexes(g.routesMeta.map(b=>b.childrenIndex),$.routesMeta.map(b=>b.childrenIndex)))}const paramRe=/^:\w+$/,dynamicSegmentValue=3,indexRouteValue=2,emptySegmentValue=1,staticSegmentValue=10,splatPenalty=-2,isSplat=d=>d==="*";function computeScore(d,g){let $=d.split("/"),b=$.length;return $.some(isSplat)&&(b+=splatPenalty),g&&(b+=indexRouteValue),$.filter(j=>!isSplat(j)).reduce((j,_e)=>j+(paramRe.test(_e)?dynamicSegmentValue:_e===""?emptySegmentValue:staticSegmentValue),b)}function compareIndexes(d,g){return d.length===g.length&&d.slice(0,-1).every((b,j)=>b===g[j])?d[d.length-1]-g[g.length-1]:0}function matchRouteBranch(d,g){let{routesMeta:$}=d,b={},j="/",_e=[];for(let et=0;et<$.length;++et){let tt=$[et],nt=et===$.length-1,rt=j==="/"?g:g.slice(j.length)||"/",it=matchPath({path:tt.relativePath,caseSensitive:tt.caseSensitive,end:nt},rt);if(!it)return null;Object.assign(b,it.params);let st=tt.route;_e.push({params:b,pathname:joinPaths([j,it.pathname]),pathnameBase:normalizePathname(joinPaths([j,it.pathnameBase])),route:st}),it.pathnameBase!=="/"&&(j=joinPaths([j,it.pathnameBase]))}return _e}function matchPath(d,g){typeof d=="string"&&(d={path:d,caseSensitive:!1,end:!0});let[$,b]=compilePath(d.path,d.caseSensitive,d.end),j=g.match($);if(!j)return null;let _e=j[0],et=_e.replace(/(.)\/+$/,"$1"),tt=j.slice(1);return{params:b.reduce((rt,it,st)=>{if(it==="*"){let ut=tt[st]||"";et=_e.slice(0,_e.length-ut.length).replace(/(.)\/+$/,"$1")}return rt[it]=safelyDecodeURIComponent(tt[st]||"",it),rt},{}),pathname:_e,pathnameBase:et,pattern:d}}function compilePath(d,g,$){g===void 0&&(g=!1),$===void 0&&($=!0),warning(d==="*"||!d.endsWith("*")||d.endsWith("/*"),'Route path "'+d+'" will be treated as if it were '+('"'+d.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+d.replace(/\*$/,"/*")+'".'));let b=[],j="^"+d.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^$?{}|()[\]]/g,"\\$&").replace(/\/:(\w+)/g,(et,tt)=>(b.push(tt),"/([^\\/]+)"));return d.endsWith("*")?(b.push("*"),j+=d==="*"||d==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):$?j+="\\/*$":d!==""&&d!=="/"&&(j+="(?:(?=\\/|$))"),[new RegExp(j,g?void 0:"i"),b]}function safelyDecodeURI(d){try{return decodeURI(d)}catch(g){return warning(!1,'The URL path "'+d+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+g+").")),d}}function safelyDecodeURIComponent(d,g){try{return decodeURIComponent(d)}catch($){return warning(!1,'The value for the URL param "'+g+'" will not be decoded because'+(' the string "'+d+'" is a malformed URL segment. This is probably')+(" due to a bad percent encoding ("+$+").")),d}}function stripBasename(d,g){if(g==="/")return d;if(!d.toLowerCase().startsWith(g.toLowerCase()))return null;let $=g.endsWith("/")?g.length-1:g.length,b=d.charAt($);return b&&b!=="/"?null:d.slice($)||"/"}function warning(d,g){if(!d){typeof console<"u"&&console.warn(g);try{throw new Error(g)}catch{}}}function resolvePath(d,g){g===void 0&&(g="/");let{pathname:$,search:b="",hash:j=""}=typeof d=="string"?parsePath(d):d;return{pathname:$?$.startsWith("/")?$:resolvePathname($,g):g,search:normalizeSearch(b),hash:normalizeHash(j)}}function resolvePathname(d,g){let $=g.replace(/\/+$/,"").split("/");return d.split("/").forEach(j=>{j===".."?$.length>1&&$.pop():j!=="."&&$.push(j)}),$.length>1?$.join("/"):"/"}function getInvalidPathError(d,g,$,b){return"Cannot include a '"+d+"' character in a manually specified "+("`to."+g+"` field ["+JSON.stringify(b)+"]. Please separate it out to the ")+("`to."+$+"` field. Alternatively you may provide the full path as ")+'a string in and the router will parse it for you.'}function getPathContributingMatches(d){return d.filter((g,$)=>$===0||g.route.path&&g.route.path.length>0)}function resolveTo(d,g,$,b){b===void 0&&(b=!1);let j;typeof d=="string"?j=parsePath(d):(j=_extends$2({},d),invariant(!j.pathname||!j.pathname.includes("?"),getInvalidPathError("?","pathname","search",j)),invariant(!j.pathname||!j.pathname.includes("#"),getInvalidPathError("#","pathname","hash",j)),invariant(!j.search||!j.search.includes("#"),getInvalidPathError("#","search","hash",j)));let _e=d===""||j.pathname==="",et=_e?"/":j.pathname,tt;if(b||et==null)tt=$;else{let st=g.length-1;if(et.startsWith("..")){let ut=et.split("/");for(;ut[0]==="..";)ut.shift(),st-=1;j.pathname=ut.join("/")}tt=st>=0?g[st]:"/"}let nt=resolvePath(j,tt),rt=et&&et!=="/"&&et.endsWith("/"),it=(_e||et===".")&&$.endsWith("/");return!nt.pathname.endsWith("/")&&(rt||it)&&(nt.pathname+="/"),nt}const joinPaths=d=>d.join("/").replace(/\/\/+/g,"/"),normalizePathname=d=>d.replace(/\/+$/,"").replace(/^\/*/,"/"),normalizeSearch=d=>!d||d==="?"?"":d.startsWith("?")?d:"?"+d,normalizeHash=d=>!d||d==="#"?"":d.startsWith("#")?d:"#"+d;class AbortedDeferredError extends Error{}class DeferredData{constructor(g,$){this.pendingKeysSet=new Set,this.subscribers=new Set,this.deferredKeys=[],invariant(g&&typeof g=="object"&&!Array.isArray(g),"defer() only accepts plain objects");let b;this.abortPromise=new Promise((_e,et)=>b=et),this.controller=new AbortController;let j=()=>b(new AbortedDeferredError("Deferred data aborted"));this.unlistenAbortSignal=()=>this.controller.signal.removeEventListener("abort",j),this.controller.signal.addEventListener("abort",j),this.data=Object.entries(g).reduce((_e,et)=>{let[tt,nt]=et;return Object.assign(_e,{[tt]:this.trackPromise(tt,nt)})},{}),this.done&&this.unlistenAbortSignal(),this.init=$}trackPromise(g,$){if(!($ instanceof Promise))return $;this.deferredKeys.push(g),this.pendingKeysSet.add(g);let b=Promise.race([$,this.abortPromise]).then(j=>this.onSettle(b,g,null,j),j=>this.onSettle(b,g,j));return b.catch(()=>{}),Object.defineProperty(b,"_tracked",{get:()=>!0}),b}onSettle(g,$,b,j){return this.controller.signal.aborted&&b instanceof AbortedDeferredError?(this.unlistenAbortSignal(),Object.defineProperty(g,"_error",{get:()=>b}),Promise.reject(b)):(this.pendingKeysSet.delete($),this.done&&this.unlistenAbortSignal(),b?(Object.defineProperty(g,"_error",{get:()=>b}),this.emit(!1,$),Promise.reject(b)):(Object.defineProperty(g,"_data",{get:()=>j}),this.emit(!1,$),j))}emit(g,$){this.subscribers.forEach(b=>b(g,$))}subscribe(g){return this.subscribers.add(g),()=>this.subscribers.delete(g)}cancel(){this.controller.abort(),this.pendingKeysSet.forEach((g,$)=>this.pendingKeysSet.delete($)),this.emit(!0)}async resolveData(g){let $=!1;if(!this.done){let b=()=>this.cancel();g.addEventListener("abort",b),$=await new Promise(j=>{this.subscribe(_e=>{g.removeEventListener("abort",b),(_e||this.done)&&j(_e)})})}return $}get done(){return this.pendingKeysSet.size===0}get unwrappedData(){return invariant(this.data!==null&&this.done,"Can only unwrap data on initialized and settled deferreds"),Object.entries(this.data).reduce((g,$)=>{let[b,j]=$;return Object.assign(g,{[b]:unwrapTrackedPromise(j)})},{})}get pendingKeys(){return Array.from(this.pendingKeysSet)}}function isTrackedPromise(d){return d instanceof Promise&&d._tracked===!0}function unwrapTrackedPromise(d){if(!isTrackedPromise(d))return d;if(d._error)throw d._error;return d._data}const redirect=function(g,$){$===void 0&&($=302);let b=$;typeof b=="number"?b={status:b}:typeof b.status>"u"&&(b.status=302);let j=new Headers(b.headers);return j.set("Location",g),new Response(null,_extends$2({},b,{headers:j}))};class ErrorResponse{constructor(g,$,b,j){j===void 0&&(j=!1),this.status=g,this.statusText=$||"",this.internal=j,b instanceof Error?(this.data=b.toString(),this.error=b):this.data=b}}function isRouteErrorResponse(d){return d!=null&&typeof d.status=="number"&&typeof d.statusText=="string"&&typeof d.internal=="boolean"&&"data"in d}const validMutationMethodsArr=["post","put","patch","delete"],validMutationMethods=new Set(validMutationMethodsArr),validRequestMethodsArr=["get",...validMutationMethodsArr],validRequestMethods=new Set(validRequestMethodsArr),redirectStatusCodes=new Set([301,302,303,307,308]),redirectPreserveMethodStatusCodes=new Set([307,308]),IDLE_NAVIGATION={state:"idle",location:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0},IDLE_FETCHER={state:"idle",data:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0},IDLE_BLOCKER={state:"unblocked",proceed:void 0,reset:void 0,location:void 0},isBrowser$1=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",isServer=!isBrowser$1;function createRouter(d){invariant(d.routes.length>0,"You must provide a non-empty routes array to createRouter");let g=convertRoutesToDataRoutes(d.routes),$=null,b=new Set,j=null,_e=null,et=null,tt=d.hydrationData!=null,nt=matchRoutes(g,d.history.location,d.basename),rt=null;if(nt==null){let $t=getInternalRouterError(404,{pathname:d.history.location.pathname}),{matches:bt,route:Rt}=getShortCircuitMatches(g);nt=bt,rt={[Rt.id]:$t}}let it=!nt.some($t=>$t.route.loader)||d.hydrationData!=null,st,ut={historyAction:d.history.action,location:d.history.location,matches:nt,initialized:it,navigation:IDLE_NAVIGATION,restoreScrollPosition:d.hydrationData!=null?!1:null,preventScrollReset:!1,revalidation:"idle",loaderData:d.hydrationData&&d.hydrationData.loaderData||{},actionData:d.hydrationData&&d.hydrationData.actionData||null,errors:d.hydrationData&&d.hydrationData.errors||rt,fetchers:new Map,blockers:new Map},at=Action.Pop,ht=!1,ct,vt=!1,ft=!1,gt=[],pt=[],yt=new Map,At=0,Dt=-1,St=new Map,Bt=new Set,Ot=new Map,Ct=new Map,_t=null,Tt=new Map,kt=!1;function Mt(){return $=d.history.listen($t=>{let{action:bt,location:Rt,delta:Ut}=$t;if(kt){kt=!1;return}warning(_t!=null&&Ut===null,"You are trying to use a blocker on a POP navigation to a location that was not created by @remix-run/router. This will fail silently in production. This can happen if you are navigating outside the router via `window.history.pushState`/`window.location.hash` instead of using router navigation APIs. This can also happen if you are using createHashRouter and the user manually changes the URL.");let It=xn({currentLocation:ut.location,nextLocation:Rt,historyAction:bt});if(It&&Ut!=null){kt=!0,d.history.go(Ut*-1),Bn(It,{state:"blocked",location:Rt,proceed(){Bn(It,{state:"proceeding",proceed:void 0,reset:void 0,location:Rt}),d.history.go(Ut)},reset(){Tn(It),Xt({blockers:new Map(st.state.blockers)})}});return}return Yt(bt,Rt)}),ut.initialized||Yt(Action.Pop,ut.location),st}function Vt(){$&&$(),b.clear(),ct&&ct.abort(),ut.fetchers.forEach(($t,bt)=>On(bt)),ut.blockers.forEach(($t,bt)=>Tn(bt))}function Jt($t){return b.add($t),()=>b.delete($t)}function Xt($t){ut=_extends$2({},ut,$t),b.forEach(bt=>bt(ut))}function Nt($t,bt){var Rt,Ut;let It=ut.actionData!=null&&ut.navigation.formMethod!=null&&isMutationMethod(ut.navigation.formMethod)&&ut.navigation.state==="loading"&&((Rt=$t.state)==null?void 0:Rt._isRedirect)!==!0,Wt;bt.actionData?Object.keys(bt.actionData).length>0?Wt=bt.actionData:Wt=null:It?Wt=ut.actionData:Wt=null;let Gt=bt.loaderData?mergeLoaderData(ut.loaderData,bt.loaderData,bt.matches||[],bt.errors):ut.loaderData;for(let[Ht]of Tt)Tn(Ht);let Zt=ht===!0||ut.navigation.formMethod!=null&&isMutationMethod(ut.navigation.formMethod)&&((Ut=$t.state)==null?void 0:Ut._isRedirect)!==!0;Xt(_extends$2({},bt,{actionData:Wt,loaderData:Gt,historyAction:at,location:$t,initialized:!0,navigation:IDLE_NAVIGATION,revalidation:"idle",restoreScrollPosition:cn($t,bt.matches||ut.matches),preventScrollReset:Zt,blockers:new Map(ut.blockers)})),vt||at===Action.Pop||(at===Action.Push?d.history.push($t,$t.state):at===Action.Replace&&d.history.replace($t,$t.state)),at=Action.Pop,ht=!1,vt=!1,ft=!1,gt=[],pt=[]}async function Lt($t,bt){if(typeof $t=="number"){d.history.go($t);return}let{path:Rt,submission:Ut,error:It}=normalizeNavigateOptions($t,bt),Wt=ut.location,Gt=createLocation(ut.location,Rt,bt&&bt.state);Gt=_extends$2({},Gt,d.history.encodeLocation(Gt));let Zt=bt&&bt.replace!=null?bt.replace:void 0,Ht=Action.Push;Zt===!0?Ht=Action.Replace:Zt===!1||Ut!=null&&isMutationMethod(Ut.formMethod)&&Ut.formAction===ut.location.pathname+ut.location.search&&(Ht=Action.Replace);let sn=bt&&"preventScrollReset"in bt?bt.preventScrollReset===!0:void 0,qt=xn({currentLocation:Wt,nextLocation:Gt,historyAction:Ht});if(qt){Bn(qt,{state:"blocked",location:Gt,proceed(){Bn(qt,{state:"proceeding",proceed:void 0,reset:void 0,location:Gt}),Lt($t,bt)},reset(){Tn(qt),Xt({blockers:new Map(ut.blockers)})}});return}return await Yt(Ht,Gt,{submission:Ut,pendingError:It,preventScrollReset:sn,replace:bt&&bt.replace})}function jt(){if(Sn(),Xt({revalidation:"loading"}),ut.navigation.state!=="submitting"){if(ut.navigation.state==="idle"){Yt(ut.historyAction,ut.location,{startUninterruptedRevalidation:!0});return}Yt(at||ut.historyAction,ut.navigation.location,{overrideNavigation:ut.navigation})}}async function Yt($t,bt,Rt){ct&&ct.abort(),ct=null,at=$t,vt=(Rt&&Rt.startUninterruptedRevalidation)===!0,$n(ut.location,ut.matches),ht=(Rt&&Rt.preventScrollReset)===!0;let Ut=Rt&&Rt.overrideNavigation,It=matchRoutes(g,bt,d.basename);if(!It){let tn=getInternalRouterError(404,{pathname:bt.pathname}),{matches:dn,route:an}=getShortCircuitMatches(g);En(),Nt(bt,{matches:dn,loaderData:{},errors:{[an.id]:tn}});return}if(isHashChangeOnly(ut.location,bt)&&!(Rt&&Rt.submission&&isMutationMethod(Rt.submission.formMethod))){Nt(bt,{matches:It});return}ct=new AbortController;let Wt=createClientSideRequest(d.history,bt,ct.signal,Rt&&Rt.submission),Gt,Zt;if(Rt&&Rt.pendingError)Zt={[findNearestBoundary(It).route.id]:Rt.pendingError};else if(Rt&&Rt.submission&&isMutationMethod(Rt.submission.formMethod)){let tn=await Qt(Wt,bt,Rt.submission,It,{replace:Rt.replace});if(tn.shortCircuited)return;Gt=tn.pendingActionData,Zt=tn.pendingActionError,Ut=_extends$2({state:"loading",location:bt},Rt.submission),Wt=new Request(Wt.url,{signal:Wt.signal})}let{shortCircuited:Ht,loaderData:sn,errors:qt}=await on(Wt,bt,It,Ut,Rt&&Rt.submission,Rt&&Rt.replace,Gt,Zt);Ht||(ct=null,Nt(bt,_extends$2({matches:It},Gt?{actionData:Gt}:{},{loaderData:sn,errors:qt})))}async function Qt($t,bt,Rt,Ut,It){Sn();let Wt=_extends$2({state:"submitting",location:bt},Rt);Xt({navigation:Wt});let Gt,Zt=getTargetMatch(Ut,bt);if(!Zt.route.action)Gt={type:ResultType.error,error:getInternalRouterError(405,{method:$t.method,pathname:bt.pathname,routeId:Zt.route.id})};else if(Gt=await callLoaderOrAction("action",$t,Zt,Ut,st.basename),$t.signal.aborted)return{shortCircuited:!0};if(isRedirectResult(Gt)){let Ht;return It&&It.replace!=null?Ht=It.replace:Ht=Gt.location===ut.location.pathname+ut.location.search,await Dn(ut,Gt,{submission:Rt,replace:Ht}),{shortCircuited:!0}}if(isErrorResult(Gt)){let Ht=findNearestBoundary(Ut,Zt.route.id);return(It&&It.replace)!==!0&&(at=Action.Push),{pendingActionData:{},pendingActionError:{[Ht.route.id]:Gt.error}}}if(isDeferredResult(Gt))throw getInternalRouterError(400,{type:"defer-action"});return{pendingActionData:{[Zt.route.id]:Gt.data}}}async function on($t,bt,Rt,Ut,It,Wt,Gt,Zt){let Ht=Ut;Ht||(Ht=_extends$2({state:"loading",location:bt,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0},It));let sn=It||(Ht.formMethod&&Ht.formAction&&Ht.formData&&Ht.formEncType?{formMethod:Ht.formMethod,formAction:Ht.formAction,formData:Ht.formData,formEncType:Ht.formEncType}:void 0),[qt,tn]=getMatchesToLoad(d.history,ut,Rt,sn,bt,ft,gt,pt,Gt,Zt,Ot);if(En(fn=>!(Rt&&Rt.some(An=>An.route.id===fn))||qt&&qt.some(An=>An.route.id===fn)),qt.length===0&&tn.length===0)return Nt(bt,_extends$2({matches:Rt,loaderData:{},errors:Zt||null},Gt?{actionData:Gt}:{})),{shortCircuited:!0};if(!vt){tn.forEach(An=>{let kn=ut.fetchers.get(An.key),zn={state:"loading",data:kn&&kn.data,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0," _hasFetcherDoneAnything ":!0};ut.fetchers.set(An.key,zn)});let fn=Gt||ut.actionData;Xt(_extends$2({navigation:Ht},fn?Object.keys(fn).length===0?{actionData:null}:{actionData:fn}:{},tn.length>0?{fetchers:new Map(ut.fetchers)}:{}))}Dt=++At,tn.forEach(fn=>yt.set(fn.key,ct));let{results:dn,loaderResults:an,fetcherResults:gn}=await Vn(ut.matches,Rt,qt,tn,$t);if($t.signal.aborted)return{shortCircuited:!0};tn.forEach(fn=>yt.delete(fn.key));let _n=findRedirect(dn);if(_n)return await Dn(ut,_n,{replace:Wt}),{shortCircuited:!0};let{loaderData:bn,errors:rn}=processLoaderData(ut,Rt,qt,an,Zt,tn,gn,Ct);Ct.forEach((fn,An)=>{fn.subscribe(kn=>{(kn||fn.done)&&Ct.delete(An)})}),Ln();let Xn=Un(Dt);return _extends$2({loaderData:bn,errors:rn},Xn||tn.length>0?{fetchers:new Map(ut.fetchers)}:{})}function un($t){return ut.fetchers.get($t)||IDLE_FETCHER}function pn($t,bt,Rt,Ut){if(isServer)throw new Error("router.fetch() was called during the server render, but it shouldn't be. You are likely calling a useFetcher() method in the body of your component. Try moving it to a useEffect or a callback.");yt.has($t)&&Pn($t);let It=matchRoutes(g,Rt,d.basename);if(!It){Nn($t,bt,getInternalRouterError(404,{pathname:Rt}));return}let{path:Wt,submission:Gt}=normalizeNavigateOptions(Rt,Ut,!0),Zt=getTargetMatch(It,Wt);if(ht=(Ut&&Ut.preventScrollReset)===!0,Gt&&isMutationMethod(Gt.formMethod)){ln($t,bt,Wt,Zt,It,Gt);return}Ot.set($t,{routeId:bt,path:Wt,match:Zt,matches:It}),yn($t,bt,Wt,Zt,It,Gt)}async function ln($t,bt,Rt,Ut,It,Wt){if(Sn(),Ot.delete($t),!Ut.route.action){let Fn=getInternalRouterError(405,{method:Wt.formMethod,pathname:Rt,routeId:bt});Nn($t,bt,Fn);return}let Gt=ut.fetchers.get($t),Zt=_extends$2({state:"submitting"},Wt,{data:Gt&&Gt.data," _hasFetcherDoneAnything ":!0});ut.fetchers.set($t,Zt),Xt({fetchers:new Map(ut.fetchers)});let Ht=new AbortController,sn=createClientSideRequest(d.history,Rt,Ht.signal,Wt);yt.set($t,Ht);let qt=await callLoaderOrAction("action",sn,Ut,It,st.basename);if(sn.signal.aborted){yt.get($t)===Ht&&yt.delete($t);return}if(isRedirectResult(qt)){yt.delete($t),Bt.add($t);let Fn=_extends$2({state:"loading"},Wt,{data:void 0," _hasFetcherDoneAnything ":!0});return ut.fetchers.set($t,Fn),Xt({fetchers:new Map(ut.fetchers)}),Dn(ut,qt,{isFetchActionRedirect:!0})}if(isErrorResult(qt)){Nn($t,bt,qt.error);return}if(isDeferredResult(qt))throw getInternalRouterError(400,{type:"defer-action"});let tn=ut.navigation.location||ut.location,dn=createClientSideRequest(d.history,tn,Ht.signal),an=ut.navigation.state!=="idle"?matchRoutes(g,ut.navigation.location,d.basename):ut.matches;invariant(an,"Didn't find any matches after fetcher action");let gn=++At;St.set($t,gn);let _n=_extends$2({state:"loading",data:qt.data},Wt,{" _hasFetcherDoneAnything ":!0});ut.fetchers.set($t,_n);let[bn,rn]=getMatchesToLoad(d.history,ut,an,Wt,tn,ft,gt,pt,{[Ut.route.id]:qt.data},void 0,Ot);rn.filter(Fn=>Fn.key!==$t).forEach(Fn=>{let Kn=Fn.key,Jn=ut.fetchers.get(Kn),hr={state:"loading",data:Jn&&Jn.data,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0," _hasFetcherDoneAnything ":!0};ut.fetchers.set(Kn,hr),yt.set(Kn,Ht)}),Xt({fetchers:new Map(ut.fetchers)});let{results:Xn,loaderResults:fn,fetcherResults:An}=await Vn(ut.matches,an,bn,rn,dn);if(Ht.signal.aborted)return;St.delete($t),yt.delete($t),rn.forEach(Fn=>yt.delete(Fn.key));let kn=findRedirect(Xn);if(kn)return Dn(ut,kn);let{loaderData:zn,errors:Qn}=processLoaderData(ut,ut.matches,bn,fn,void 0,rn,An,Ct),dr={state:"idle",data:qt.data,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0," _hasFetcherDoneAnything ":!0};ut.fetchers.set($t,dr);let qn=Un(gn);ut.navigation.state==="loading"&&gn>Dt?(invariant(at,"Expected pending action"),ct&&ct.abort(),Nt(ut.navigation.location,{matches:an,loaderData:zn,errors:Qn,fetchers:new Map(ut.fetchers)})):(Xt(_extends$2({errors:Qn,loaderData:mergeLoaderData(ut.loaderData,zn,an,Qn)},qn?{fetchers:new Map(ut.fetchers)}:{})),ft=!1)}async function yn($t,bt,Rt,Ut,It,Wt){let Gt=ut.fetchers.get($t),Zt=_extends$2({state:"loading",formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0},Wt,{data:Gt&&Gt.data," _hasFetcherDoneAnything ":!0});ut.fetchers.set($t,Zt),Xt({fetchers:new Map(ut.fetchers)});let Ht=new AbortController,sn=createClientSideRequest(d.history,Rt,Ht.signal);yt.set($t,Ht);let qt=await callLoaderOrAction("loader",sn,Ut,It,st.basename);if(isDeferredResult(qt)&&(qt=await resolveDeferredData(qt,sn.signal,!0)||qt),yt.get($t)===Ht&&yt.delete($t),sn.signal.aborted)return;if(isRedirectResult(qt)){await Dn(ut,qt);return}if(isErrorResult(qt)){let dn=findNearestBoundary(ut.matches,bt);ut.fetchers.delete($t),Xt({fetchers:new Map(ut.fetchers),errors:{[dn.route.id]:qt.error}});return}invariant(!isDeferredResult(qt),"Unhandled fetcher deferred data");let tn={state:"idle",data:qt.data,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0," _hasFetcherDoneAnything ":!0};ut.fetchers.set($t,tn),Xt({fetchers:new Map(ut.fetchers)})}async function Dn($t,bt,Rt){var Ut;let{submission:It,replace:Wt,isFetchActionRedirect:Gt}=Rt===void 0?{}:Rt;bt.revalidate&&(ft=!0);let Zt=createLocation($t.location,bt.location,_extends$2({_isRedirect:!0},Gt?{_isFetchActionRedirect:!0}:{}));if(invariant(Zt,"Expected a location on the redirect navigation"),isBrowser$1&&typeof((Ut=window)==null?void 0:Ut.location)<"u"){let an=d.history.createURL(bt.location).origin;if(window.location.origin!==an){Wt?window.location.replace(bt.location):window.location.assign(bt.location);return}}ct=null;let Ht=Wt===!0?Action.Replace:Action.Push,{formMethod:sn,formAction:qt,formEncType:tn,formData:dn}=$t.navigation;!It&&sn&&qt&&dn&&tn&&(It={formMethod:sn,formAction:qt,formEncType:tn,formData:dn}),redirectPreserveMethodStatusCodes.has(bt.status)&&It&&isMutationMethod(It.formMethod)?await Yt(Ht,Zt,{submission:_extends$2({},It,{formAction:bt.location}),preventScrollReset:ht}):await Yt(Ht,Zt,{overrideNavigation:{state:"loading",location:Zt,formMethod:It?It.formMethod:void 0,formAction:It?It.formAction:void 0,formEncType:It?It.formEncType:void 0,formData:It?It.formData:void 0},preventScrollReset:ht})}async function Vn($t,bt,Rt,Ut,It){let Wt=await Promise.all([...Rt.map(Ht=>callLoaderOrAction("loader",It,Ht,bt,st.basename)),...Ut.map(Ht=>callLoaderOrAction("loader",createClientSideRequest(d.history,Ht.path,It.signal),Ht.match,Ht.matches,st.basename))]),Gt=Wt.slice(0,Rt.length),Zt=Wt.slice(Rt.length);return await Promise.all([resolveDeferredResults($t,Rt,Gt,It.signal,!1,ut.loaderData),resolveDeferredResults($t,Ut.map(Ht=>Ht.match),Zt,It.signal,!0)]),{results:Wt,loaderResults:Gt,fetcherResults:Zt}}function Sn(){ft=!0,gt.push(...En()),Ot.forEach(($t,bt)=>{yt.has(bt)&&(pt.push(bt),Pn(bt))})}function Nn($t,bt,Rt){let Ut=findNearestBoundary(ut.matches,bt);On($t),Xt({errors:{[Ut.route.id]:Rt},fetchers:new Map(ut.fetchers)})}function On($t){yt.has($t)&&Pn($t),Ot.delete($t),St.delete($t),Bt.delete($t),ut.fetchers.delete($t)}function Pn($t){let bt=yt.get($t);invariant(bt,"Expected fetch controller: "+$t),bt.abort(),yt.delete($t)}function Cn($t){for(let bt of $t){let Ut={state:"idle",data:un(bt).data,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0," _hasFetcherDoneAnything ":!0};ut.fetchers.set(bt,Ut)}}function Ln(){let $t=[];for(let bt of Bt){let Rt=ut.fetchers.get(bt);invariant(Rt,"Expected fetcher: "+bt),Rt.state==="loading"&&(Bt.delete(bt),$t.push(bt))}Cn($t)}function Un($t){let bt=[];for(let[Rt,Ut]of St)if(Ut<$t){let It=ut.fetchers.get(Rt);invariant(It,"Expected fetcher: "+Rt),It.state==="loading"&&(Pn(Rt),St.delete(Rt),bt.push(Rt))}return Cn(bt),bt.length>0}function Hn($t,bt){let Rt=ut.blockers.get($t)||IDLE_BLOCKER;return Tt.get($t)!==bt&&(Tt.set($t,bt),_t==null?_t=$t:$t!==_t&&warning(!1,"A router only supports one blocker at a time")),Rt}function Tn($t){ut.blockers.delete($t),Tt.delete($t),_t===$t&&(_t=null)}function Bn($t,bt){let Rt=ut.blockers.get($t)||IDLE_BLOCKER;invariant(Rt.state==="unblocked"&&bt.state==="blocked"||Rt.state==="blocked"&&bt.state==="blocked"||Rt.state==="blocked"&&bt.state==="proceeding"||Rt.state==="blocked"&&bt.state==="unblocked"||Rt.state==="proceeding"&&bt.state==="unblocked","Invalid blocker state transition: "+Rt.state+" -> "+bt.state),ut.blockers.set($t,bt),Xt({blockers:new Map(ut.blockers)})}function xn($t){let{currentLocation:bt,nextLocation:Rt,historyAction:Ut}=$t;if(_t==null)return;let It=Tt.get(_t);invariant(It,"Could not find a function for the active blocker");let Wt=ut.blockers.get(_t);if(!(Wt&&Wt.state==="proceeding")&&It({currentLocation:bt,nextLocation:Rt,historyAction:Ut}))return _t}function En($t){let bt=[];return Ct.forEach((Rt,Ut)=>{(!$t||$t(Ut))&&(Rt.cancel(),bt.push(Ut),Ct.delete(Ut))}),bt}function wn($t,bt,Rt){if(j=$t,et=bt,_e=Rt||(Ut=>Ut.key),!tt&&ut.navigation===IDLE_NAVIGATION){tt=!0;let Ut=cn(ut.location,ut.matches);Ut!=null&&Xt({restoreScrollPosition:Ut})}return()=>{j=null,et=null,_e=null}}function $n($t,bt){if(j&&_e&&et){let Rt=bt.map(It=>createUseMatchesMatch(It,ut.loaderData)),Ut=_e($t,Rt)||$t.key;j[Ut]=et()}}function cn($t,bt){if(j&&_e&&et){let Rt=bt.map(Wt=>createUseMatchesMatch(Wt,ut.loaderData)),Ut=_e($t,Rt)||$t.key,It=j[Ut];if(typeof It=="number")return It}return null}return st={get basename(){return d.basename},get state(){return ut},get routes(){return g},initialize:Mt,subscribe:Jt,enableScrollRestoration:wn,navigate:Lt,fetch:pn,revalidate:jt,createHref:$t=>d.history.createHref($t),encodeLocation:$t=>d.history.encodeLocation($t),getFetcher:un,deleteFetcher:On,dispose:Vt,getBlocker:Hn,deleteBlocker:Tn,_internalFetchControllers:yt,_internalActiveDeferreds:Ct},st}function isSubmissionNavigation(d){return d!=null&&"formData"in d}function normalizeNavigateOptions(d,g,$){$===void 0&&($=!1);let b=typeof d=="string"?d:createPath(d);if(!g||!isSubmissionNavigation(g))return{path:b};if(g.formMethod&&!isValidMethod(g.formMethod))return{path:b,error:getInternalRouterError(405,{method:g.formMethod})};let j;if(g.formData&&(j={formMethod:g.formMethod||"get",formAction:stripHashFromPath(b),formEncType:g&&g.formEncType||"application/x-www-form-urlencoded",formData:g.formData},isMutationMethod(j.formMethod)))return{path:b,submission:j};let _e=parsePath(b),et=convertFormDataToSearchParams(g.formData);return $&&_e.search&&hasNakedIndexQuery(_e.search)&&et.append("index",""),_e.search="?"+et,{path:createPath(_e),submission:j}}function getLoaderMatchesUntilBoundary(d,g){let $=d;if(g){let b=d.findIndex(j=>j.route.id===g);b>=0&&($=d.slice(0,b))}return $}function getMatchesToLoad(d,g,$,b,j,_e,et,tt,nt,rt,it){let st=rt?Object.values(rt)[0]:nt?Object.values(nt)[0]:void 0,ut=d.createURL(g.location),at=d.createURL(j),ht=_e||ut.toString()===at.toString()||ut.search!==at.search,ct=rt?Object.keys(rt)[0]:void 0,ft=getLoaderMatchesUntilBoundary($,ct).filter((pt,yt)=>{if(pt.route.loader==null)return!1;if(isNewLoader(g.loaderData,g.matches[yt],pt)||et.some(St=>St===pt.route.id))return!0;let At=g.matches[yt],Dt=pt;return shouldRevalidateLoader(pt,_extends$2({currentUrl:ut,currentParams:At.params,nextUrl:at,nextParams:Dt.params},b,{actionResult:st,defaultShouldRevalidate:ht||isNewRouteInstance(At,Dt)}))}),gt=[];return it&&it.forEach((pt,yt)=>{if($.some(At=>At.route.id===pt.routeId))tt.includes(yt)?gt.push(_extends$2({key:yt},pt)):shouldRevalidateLoader(pt.match,_extends$2({currentUrl:ut,currentParams:g.matches[g.matches.length-1].params,nextUrl:at,nextParams:$[$.length-1].params},b,{actionResult:st,defaultShouldRevalidate:ht}))&>.push(_extends$2({key:yt},pt));else return}),[ft,gt]}function isNewLoader(d,g,$){let b=!g||$.route.id!==g.route.id,j=d[$.route.id]===void 0;return b||j}function isNewRouteInstance(d,g){let $=d.route.path;return d.pathname!==g.pathname||$!=null&&$.endsWith("*")&&d.params["*"]!==g.params["*"]}function shouldRevalidateLoader(d,g){if(d.route.shouldRevalidate){let $=d.route.shouldRevalidate(g);if(typeof $=="boolean")return $}return g.defaultShouldRevalidate}async function callLoaderOrAction(d,g,$,b,j,_e,et,tt){j===void 0&&(j="/"),_e===void 0&&(_e=!1),et===void 0&&(et=!1);let nt,rt,it,st=new Promise((at,ht)=>it=ht),ut=()=>it();g.signal.addEventListener("abort",ut);try{let at=$.route[d];invariant(at,"Could not find the "+d+' to run on the "'+$.route.id+'" route'),rt=await Promise.race([at({request:g,params:$.params,context:tt}),st]),invariant(rt!==void 0,"You defined "+(d==="action"?"an action":"a loader")+" for route "+('"'+$.route.id+"\" but didn't return anything from your `"+d+"` ")+"function. Please return a value or `null`.")}catch(at){nt=ResultType.error,rt=at}finally{g.signal.removeEventListener("abort",ut)}if(isResponse(rt)){let at=rt.status;if(redirectStatusCodes.has(at)){let vt=rt.headers.get("Location");if(invariant(vt,"Redirects returned/thrown from loaders/actions must have a Location header"),/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i.test(vt)){if(!_e){let gt=new URL(g.url),pt=vt.startsWith("//")?new URL(gt.protocol+vt):new URL(vt);pt.origin===gt.origin&&(vt=pt.pathname+pt.search+pt.hash)}}else{let gt=b.slice(0,b.indexOf($)+1),pt=getPathContributingMatches(gt).map(At=>At.pathnameBase),yt=resolveTo(vt,pt,new URL(g.url).pathname);if(invariant(createPath(yt),"Unable to resolve redirect location: "+vt),j){let At=yt.pathname;yt.pathname=At==="/"?j:joinPaths([j,At])}vt=createPath(yt)}if(_e)throw rt.headers.set("Location",vt),rt;return{type:ResultType.redirect,status:at,location:vt,revalidate:rt.headers.get("X-Remix-Revalidate")!==null}}if(et)throw{type:nt||ResultType.data,response:rt};let ht,ct=rt.headers.get("Content-Type");return ct&&/\bapplication\/json\b/.test(ct)?ht=await rt.json():ht=await rt.text(),nt===ResultType.error?{type:nt,error:new ErrorResponse(at,rt.statusText,ht),headers:rt.headers}:{type:ResultType.data,data:ht,statusCode:rt.status,headers:rt.headers}}return nt===ResultType.error?{type:nt,error:rt}:rt instanceof DeferredData?{type:ResultType.deferred,deferredData:rt}:{type:ResultType.data,data:rt}}function createClientSideRequest(d,g,$,b){let j=d.createURL(stripHashFromPath(g)).toString(),_e={signal:$};if(b&&isMutationMethod(b.formMethod)){let{formMethod:et,formEncType:tt,formData:nt}=b;_e.method=et.toUpperCase(),_e.body=tt==="application/x-www-form-urlencoded"?convertFormDataToSearchParams(nt):nt}return new Request(j,_e)}function convertFormDataToSearchParams(d){let g=new URLSearchParams;for(let[$,b]of d.entries())g.append($,b instanceof File?b.name:b);return g}function processRouteLoaderData(d,g,$,b,j){let _e={},et=null,tt,nt=!1,rt={};return $.forEach((it,st)=>{let ut=g[st].route.id;if(invariant(!isRedirectResult(it),"Cannot handle redirect results in processLoaderData"),isErrorResult(it)){let at=findNearestBoundary(d,ut),ht=it.error;b&&(ht=Object.values(b)[0],b=void 0),et=et||{},et[at.route.id]==null&&(et[at.route.id]=ht),_e[ut]=void 0,nt||(nt=!0,tt=isRouteErrorResponse(it.error)?it.error.status:500),it.headers&&(rt[ut]=it.headers)}else isDeferredResult(it)?(j.set(ut,it.deferredData),_e[ut]=it.deferredData.data):_e[ut]=it.data,it.statusCode!=null&&it.statusCode!==200&&!nt&&(tt=it.statusCode),it.headers&&(rt[ut]=it.headers)}),b&&(et=b,_e[Object.keys(b)[0]]=void 0),{loaderData:_e,errors:et,statusCode:tt||200,loaderHeaders:rt}}function processLoaderData(d,g,$,b,j,_e,et,tt){let{loaderData:nt,errors:rt}=processRouteLoaderData(g,$,b,j,tt);for(let it=0;it<_e.length;it++){let{key:st,match:ut}=_e[it];invariant(et!==void 0&&et[it]!==void 0,"Did not find corresponding fetcher result");let at=et[it];if(isErrorResult(at)){let ht=findNearestBoundary(d.matches,ut.route.id);rt&&rt[ht.route.id]||(rt=_extends$2({},rt,{[ht.route.id]:at.error})),d.fetchers.delete(st)}else if(isRedirectResult(at))invariant(!1,"Unhandled fetcher revalidation redirect");else if(isDeferredResult(at))invariant(!1,"Unhandled fetcher deferred data");else{let ht={state:"idle",data:at.data,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0," _hasFetcherDoneAnything ":!0};d.fetchers.set(st,ht)}}return{loaderData:nt,errors:rt}}function mergeLoaderData(d,g,$,b){let j=_extends$2({},g);for(let _e of $){let et=_e.route.id;if(g.hasOwnProperty(et)?g[et]!==void 0&&(j[et]=g[et]):d[et]!==void 0&&(j[et]=d[et]),b&&b.hasOwnProperty(et))break}return j}function findNearestBoundary(d,g){return(g?d.slice(0,d.findIndex(b=>b.route.id===g)+1):[...d]).reverse().find(b=>b.route.hasErrorBoundary===!0)||d[0]}function getShortCircuitMatches(d){let g=d.find($=>$.index||!$.path||$.path==="/")||{id:"__shim-error-route__"};return{matches:[{params:{},pathname:"",pathnameBase:"",route:g}],route:g}}function getInternalRouterError(d,g){let{pathname:$,routeId:b,method:j,type:_e}=g===void 0?{}:g,et="Unknown Server Error",tt="Unknown @remix-run/router error";return d===400?(et="Bad Request",j&&$&&b?tt="You made a "+j+' request to "'+$+'" but '+('did not provide a `loader` for route "'+b+'", ')+"so there is no way to handle the request.":_e==="defer-action"&&(tt="defer() is not supported in actions")):d===403?(et="Forbidden",tt='Route "'+b+'" does not match URL "'+$+'"'):d===404?(et="Not Found",tt='No route matches URL "'+$+'"'):d===405&&(et="Method Not Allowed",j&&$&&b?tt="You made a "+j.toUpperCase()+' request to "'+$+'" but '+('did not provide an `action` for route "'+b+'", ')+"so there is no way to handle the request.":j&&(tt='Invalid request method "'+j.toUpperCase()+'"')),new ErrorResponse(d||500,et,new Error(tt),!0)}function findRedirect(d){for(let g=d.length-1;g>=0;g--){let $=d[g];if(isRedirectResult($))return $}}function stripHashFromPath(d){let g=typeof d=="string"?parsePath(d):d;return createPath(_extends$2({},g,{hash:""}))}function isHashChangeOnly(d,g){return d.pathname===g.pathname&&d.search===g.search&&d.hash!==g.hash}function isDeferredResult(d){return d.type===ResultType.deferred}function isErrorResult(d){return d.type===ResultType.error}function isRedirectResult(d){return(d&&d.type)===ResultType.redirect}function isResponse(d){return d!=null&&typeof d.status=="number"&&typeof d.statusText=="string"&&typeof d.headers=="object"&&typeof d.body<"u"}function isValidMethod(d){return validRequestMethods.has(d)}function isMutationMethod(d){return validMutationMethods.has(d)}async function resolveDeferredResults(d,g,$,b,j,_e){for(let et=0;et<$.length;et++){let tt=$[et],nt=g[et],rt=d.find(st=>st.route.id===nt.route.id),it=rt!=null&&!isNewRouteInstance(rt,nt)&&(_e&&_e[nt.route.id])!==void 0;isDeferredResult(tt)&&(j||it)&&await resolveDeferredData(tt,b,j).then(st=>{st&&($[et]=st||$[et])})}}async function resolveDeferredData(d,g,$){if($===void 0&&($=!1),!await d.deferredData.resolveData(g)){if($)try{return{type:ResultType.data,data:d.deferredData.unwrappedData}}catch(j){return{type:ResultType.error,error:j}}return{type:ResultType.data,data:d.deferredData.data}}}function hasNakedIndexQuery(d){return new URLSearchParams(d).getAll("index").some(g=>g==="")}function createUseMatchesMatch(d,g){let{route:$,pathname:b,params:j}=d;return{id:$.id,pathname:b,params:j,data:g[$.id],handle:$.handle}}function getTargetMatch(d,g){let $=typeof g=="string"?parsePath(g).search:g.search;if(d[d.length-1].route.index&&hasNakedIndexQuery($||""))return d[d.length-1];let b=getPathContributingMatches(d);return b[b.length-1]}/** - * React Router v6.8.0 - * - * Copyright (c) Remix Software Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE.md file in the root directory of this source tree. - * - * @license MIT - */function _extends$1(){return _extends$1=Object.assign?Object.assign.bind():function(d){for(var g=1;g{j.value=b,j.getSnapshot=g,checkIfSnapshotChanged(j)&&_e({inst:j})},[d,b,g]),useEffect(()=>(checkIfSnapshotChanged(j)&&_e({inst:j}),d(()=>{checkIfSnapshotChanged(j)&&_e({inst:j})})),[d]),useDebugValue(b),b}function checkIfSnapshotChanged(d){const g=d.getSnapshot,$=d.value;try{const b=g();return!is($,b)}catch{return!0}}function useSyncExternalStore$1(d,g,$){return g()}const canUseDOM=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",isServerEnvironment=!canUseDOM,shim=isServerEnvironment?useSyncExternalStore$1:useSyncExternalStore$2,useSyncExternalStore="useSyncExternalStore"in React$1?(d=>d.useSyncExternalStore)(React$1):shim,DataRouterContext=reactExports.createContext(null),DataRouterStateContext=reactExports.createContext(null),NavigationContext=reactExports.createContext(null),LocationContext=reactExports.createContext(null),RouteContext=reactExports.createContext({outlet:null,matches:[]}),RouteErrorContext=reactExports.createContext(null);function useHref(d,g){let{relative:$}=g===void 0?{}:g;useInRouterContext()||invariant(!1);let{basename:b,navigator:j}=reactExports.useContext(NavigationContext),{hash:_e,pathname:et,search:tt}=useResolvedPath(d,{relative:$}),nt=et;return b!=="/"&&(nt=et==="/"?b:joinPaths([b,et])),j.createHref({pathname:nt,search:tt,hash:_e})}function useInRouterContext(){return reactExports.useContext(LocationContext)!=null}function useLocation(){return useInRouterContext()||invariant(!1),reactExports.useContext(LocationContext).location}function useNavigate(){useInRouterContext()||invariant(!1);let{basename:d,navigator:g}=reactExports.useContext(NavigationContext),{matches:$}=reactExports.useContext(RouteContext),{pathname:b}=useLocation(),j=JSON.stringify(getPathContributingMatches($).map(tt=>tt.pathnameBase)),_e=reactExports.useRef(!1);return reactExports.useEffect(()=>{_e.current=!0}),reactExports.useCallback(function(tt,nt){if(nt===void 0&&(nt={}),!_e.current)return;if(typeof tt=="number"){g.go(tt);return}let rt=resolveTo(tt,JSON.parse(j),b,nt.relative==="path");d!=="/"&&(rt.pathname=rt.pathname==="/"?d:joinPaths([d,rt.pathname])),(nt.replace?g.replace:g.push)(rt,nt.state,nt)},[d,g,j,b])}const OutletContext=reactExports.createContext(null);function useOutlet(d){let g=reactExports.useContext(RouteContext).outlet;return g&&reactExports.createElement(OutletContext.Provider,{value:d},g)}function useResolvedPath(d,g){let{relative:$}=g===void 0?{}:g,{matches:b}=reactExports.useContext(RouteContext),{pathname:j}=useLocation(),_e=JSON.stringify(getPathContributingMatches(b).map(et=>et.pathnameBase));return reactExports.useMemo(()=>resolveTo(d,JSON.parse(_e),j,$==="path"),[d,_e,j,$])}function useRoutes(d,g){useInRouterContext()||invariant(!1);let{navigator:$}=reactExports.useContext(NavigationContext),b=reactExports.useContext(DataRouterStateContext),{matches:j}=reactExports.useContext(RouteContext),_e=j[j.length-1],et=_e?_e.params:{};_e&&_e.pathname;let tt=_e?_e.pathnameBase:"/";_e&&_e.route;let nt=useLocation(),rt;if(g){var it;let ct=typeof g=="string"?parsePath(g):g;tt==="/"||(it=ct.pathname)!=null&&it.startsWith(tt)||invariant(!1),rt=ct}else rt=nt;let st=rt.pathname||"/",ut=tt==="/"?st:st.slice(tt.length)||"/",at=matchRoutes(d,{pathname:ut}),ht=_renderMatches(at&&at.map(ct=>Object.assign({},ct,{params:Object.assign({},et,ct.params),pathname:joinPaths([tt,$.encodeLocation?$.encodeLocation(ct.pathname).pathname:ct.pathname]),pathnameBase:ct.pathnameBase==="/"?tt:joinPaths([tt,$.encodeLocation?$.encodeLocation(ct.pathnameBase).pathname:ct.pathnameBase])})),j,b||void 0);return g&&ht?reactExports.createElement(LocationContext.Provider,{value:{location:_extends$1({pathname:"/",search:"",hash:"",state:null,key:"default"},rt),navigationType:Action.Pop}},ht):ht}function DefaultErrorElement(){let d=useRouteError(),g=isRouteErrorResponse(d)?d.status+" "+d.statusText:d instanceof Error?d.message:JSON.stringify(d),$=d instanceof Error?d.stack:null,j={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"},_e=null;return reactExports.createElement(reactExports.Fragment,null,reactExports.createElement("h2",null,"Unexpected Application Error!"),reactExports.createElement("h3",{style:{fontStyle:"italic"}},g),$?reactExports.createElement("pre",{style:j},$):null,_e)}class RenderErrorBoundary extends reactExports.Component{constructor(g){super(g),this.state={location:g.location,error:g.error}}static getDerivedStateFromError(g){return{error:g}}static getDerivedStateFromProps(g,$){return $.location!==g.location?{error:g.error,location:g.location}:{error:g.error||$.error,location:$.location}}componentDidCatch(g,$){console.error("React Router caught the following error during render",g,$)}render(){return this.state.error?reactExports.createElement(RouteContext.Provider,{value:this.props.routeContext},reactExports.createElement(RouteErrorContext.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function RenderedRoute(d){let{routeContext:g,match:$,children:b}=d,j=reactExports.useContext(DataRouterContext);return j&&j.static&&j.staticContext&&$.route.errorElement&&(j.staticContext._deepestRenderedBoundaryId=$.route.id),reactExports.createElement(RouteContext.Provider,{value:g},b)}function _renderMatches(d,g,$){if(g===void 0&&(g=[]),d==null)if($!=null&&$.errors)d=$.matches;else return null;let b=d,j=$==null?void 0:$.errors;if(j!=null){let _e=b.findIndex(et=>et.route.id&&(j==null?void 0:j[et.route.id]));_e>=0||invariant(!1),b=b.slice(0,Math.min(b.length,_e+1))}return b.reduceRight((_e,et,tt)=>{let nt=et.route.id?j==null?void 0:j[et.route.id]:null,rt=$?et.route.errorElement||reactExports.createElement(DefaultErrorElement,null):null,it=g.concat(b.slice(0,tt+1)),st=()=>reactExports.createElement(RenderedRoute,{match:et,routeContext:{outlet:_e,matches:it}},nt?rt:et.route.element!==void 0?et.route.element:_e);return $&&(et.route.errorElement||tt===0)?reactExports.createElement(RenderErrorBoundary,{location:$.location,component:rt,error:nt,children:st(),routeContext:{outlet:null,matches:it}}):st()},null)}var DataRouterHook$1;(function(d){d.UseBlocker="useBlocker",d.UseRevalidator="useRevalidator"})(DataRouterHook$1||(DataRouterHook$1={}));var DataRouterStateHook$1;(function(d){d.UseLoaderData="useLoaderData",d.UseActionData="useActionData",d.UseRouteError="useRouteError",d.UseNavigation="useNavigation",d.UseRouteLoaderData="useRouteLoaderData",d.UseMatches="useMatches",d.UseRevalidator="useRevalidator"})(DataRouterStateHook$1||(DataRouterStateHook$1={}));function useDataRouterState(d){let g=reactExports.useContext(DataRouterStateContext);return g||invariant(!1),g}function useRouteContext(d){let g=reactExports.useContext(RouteContext);return g||invariant(!1),g}function useCurrentRouteId(d){let g=useRouteContext(),$=g.matches[g.matches.length-1];return $.route.id||invariant(!1),$.route.id}function useLoaderData(){let d=useDataRouterState(DataRouterStateHook$1.UseLoaderData),g=useCurrentRouteId(DataRouterStateHook$1.UseLoaderData);if(d.errors&&d.errors[g]!=null){console.error("You cannot `useLoaderData` in an errorElement (routeId: "+g+")");return}return d.loaderData[g]}function useRouteError(){var d;let g=reactExports.useContext(RouteErrorContext),$=useDataRouterState(DataRouterStateHook$1.UseRouteError),b=useCurrentRouteId(DataRouterStateHook$1.UseRouteError);return g||((d=$.errors)==null?void 0:d[b])}function RouterProvider(d){let{fallbackElement:g,router:$}=d,b=useSyncExternalStore($.subscribe,()=>$.state,()=>$.state),j=reactExports.useMemo(()=>({createHref:$.createHref,encodeLocation:$.encodeLocation,go:et=>$.navigate(et),push:(et,tt,nt)=>$.navigate(et,{state:tt,preventScrollReset:nt==null?void 0:nt.preventScrollReset}),replace:(et,tt,nt)=>$.navigate(et,{replace:!0,state:tt,preventScrollReset:nt==null?void 0:nt.preventScrollReset})}),[$]),_e=$.basename||"/";return reactExports.createElement(reactExports.Fragment,null,reactExports.createElement(DataRouterContext.Provider,{value:{router:$,navigator:j,static:!1,basename:_e}},reactExports.createElement(DataRouterStateContext.Provider,{value:b},reactExports.createElement(Router,{basename:$.basename,location:$.state.location,navigationType:$.state.historyAction,navigator:j},$.state.initialized?reactExports.createElement(Routes,null):g))),null)}function Outlet(d){return useOutlet(d.context)}function Route(d){invariant(!1)}function Router(d){let{basename:g="/",children:$=null,location:b,navigationType:j=Action.Pop,navigator:_e,static:et=!1}=d;useInRouterContext()&&invariant(!1);let tt=g.replace(/^\/*/,"/"),nt=reactExports.useMemo(()=>({basename:tt,navigator:_e,static:et}),[tt,_e,et]);typeof b=="string"&&(b=parsePath(b));let{pathname:rt="/",search:it="",hash:st="",state:ut=null,key:at="default"}=b,ht=reactExports.useMemo(()=>{let ct=stripBasename(rt,tt);return ct==null?null:{pathname:ct,search:it,hash:st,state:ut,key:at}},[tt,rt,it,st,ut,at]);return ht==null?null:reactExports.createElement(NavigationContext.Provider,{value:nt},reactExports.createElement(LocationContext.Provider,{children:$,value:{location:ht,navigationType:j}}))}function Routes(d){let{children:g,location:$}=d,b=reactExports.useContext(DataRouterContext),j=b&&!g?b.router.routes:createRoutesFromChildren(g);return useRoutes(j,$)}var AwaitRenderStatus;(function(d){d[d.pending=0]="pending",d[d.success=1]="success",d[d.error=2]="error"})(AwaitRenderStatus||(AwaitRenderStatus={}));new Promise(()=>{});function createRoutesFromChildren(d,g){g===void 0&&(g=[]);let $=[];return reactExports.Children.forEach(d,(b,j)=>{if(!reactExports.isValidElement(b))return;if(b.type===reactExports.Fragment){$.push.apply($,createRoutesFromChildren(b.props.children,g));return}b.type!==Route&&invariant(!1),!b.props.index||!b.props.children||invariant(!1);let _e=[...g,j],et={id:b.props.id||_e.join("-"),caseSensitive:b.props.caseSensitive,element:b.props.element,index:b.props.index,path:b.props.path,loader:b.props.loader,action:b.props.action,errorElement:b.props.errorElement,hasErrorBoundary:b.props.errorElement!=null,shouldRevalidate:b.props.shouldRevalidate,handle:b.props.handle};b.props.children&&(et.children=createRoutesFromChildren(b.props.children,_e)),$.push(et)}),$}function enhanceManualRouteObjects(d){return d.map(g=>{let $=_extends$1({},g);return $.hasErrorBoundary==null&&($.hasErrorBoundary=$.errorElement!=null),$.children&&($.children=enhanceManualRouteObjects($.children)),$})}/** - * React Router DOM v6.8.0 - * - * Copyright (c) Remix Software Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE.md file in the root directory of this source tree. - * - * @license MIT - */function _extends(){return _extends=Object.assign?Object.assign.bind():function(d){for(var g=1;g=0)&&($[j]=d[j]);return $}function isModifiedEvent(d){return!!(d.metaKey||d.altKey||d.ctrlKey||d.shiftKey)}function shouldProcessLinkClick(d,g){return d.button===0&&(!g||g==="_self")&&!isModifiedEvent(d)}const _excluded=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset"],_excluded2=["aria-current","caseSensitive","className","end","style","to","children"];function createBrowserRouter(d,g){return createRouter({basename:g==null?void 0:g.basename,history:createBrowserHistory({window:g==null?void 0:g.window}),hydrationData:(g==null?void 0:g.hydrationData)||parseHydrationData(),routes:enhanceManualRouteObjects(d)}).initialize()}function parseHydrationData(){var d;let g=(d=window)==null?void 0:d.__staticRouterHydrationData;return g&&g.errors&&(g=_extends({},g,{errors:deserializeErrors(g.errors)})),g}function deserializeErrors(d){if(!d)return null;let g=Object.entries(d),$={};for(let[b,j]of g)if(j&&j.__type==="RouteErrorResponse")$[b]=new ErrorResponse(j.status,j.statusText,j.data,j.internal===!0);else if(j&&j.__type==="Error"){let _e=new Error(j.message);_e.stack="",$[b]=_e}else $[b]=j;return $}const isBrowser=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Link=reactExports.forwardRef(function(g,$){let{onClick:b,relative:j,reloadDocument:_e,replace:et,state:tt,target:nt,to:rt,preventScrollReset:it}=g,st=_objectWithoutPropertiesLoose(g,_excluded),ut=typeof rt=="string"?rt:createPath(rt),at=/^[a-z+]+:\/\//i.test(ut)||ut.startsWith("//"),ht=ut,ct=!1;if(isBrowser&&at){let pt=new URL(window.location.href),yt=ut.startsWith("//")?new URL(pt.protocol+ut):new URL(ut);yt.origin===pt.origin?ht=yt.pathname+yt.search+yt.hash:ct=!0}let vt=useHref(ht,{relative:j}),ft=useLinkClickHandler(ht,{replace:et,state:tt,target:nt,preventScrollReset:it,relative:j});function gt(pt){b&&b(pt),pt.defaultPrevented||ft(pt)}return reactExports.createElement("a",_extends({},st,{href:at?ut:vt,onClick:ct||_e?b:gt,ref:$,target:nt}))}),NavLink=reactExports.forwardRef(function(g,$){let{"aria-current":b="page",caseSensitive:j=!1,className:_e="",end:et=!1,style:tt,to:nt,children:rt}=g,it=_objectWithoutPropertiesLoose(g,_excluded2),st=useResolvedPath(nt,{relative:it.relative}),ut=useLocation(),at=reactExports.useContext(DataRouterStateContext),{navigator:ht}=reactExports.useContext(NavigationContext),ct=ht.encodeLocation?ht.encodeLocation(st).pathname:st.pathname,vt=ut.pathname,ft=at&&at.navigation&&at.navigation.location?at.navigation.location.pathname:null;j||(vt=vt.toLowerCase(),ft=ft?ft.toLowerCase():null,ct=ct.toLowerCase());let gt=vt===ct||!et&&vt.startsWith(ct)&&vt.charAt(ct.length)==="/",pt=ft!=null&&(ft===ct||!et&&ft.startsWith(ct)&&ft.charAt(ct.length)==="/"),yt=gt?b:void 0,At;typeof _e=="function"?At=_e({isActive:gt,isPending:pt}):At=[_e,gt?"active":null,pt?"pending":null].filter(Boolean).join(" ");let Dt=typeof tt=="function"?tt({isActive:gt,isPending:pt}):tt;return reactExports.createElement(Link,_extends({},it,{"aria-current":yt,className:At,ref:$,style:Dt,to:nt}),typeof rt=="function"?rt({isActive:gt,isPending:pt}):rt)});var DataRouterHook;(function(d){d.UseScrollRestoration="useScrollRestoration",d.UseSubmitImpl="useSubmitImpl",d.UseFetcher="useFetcher"})(DataRouterHook||(DataRouterHook={}));var DataRouterStateHook;(function(d){d.UseFetchers="useFetchers",d.UseScrollRestoration="useScrollRestoration"})(DataRouterStateHook||(DataRouterStateHook={}));function useLinkClickHandler(d,g){let{target:$,replace:b,state:j,preventScrollReset:_e,relative:et}=g===void 0?{}:g,tt=useNavigate(),nt=useLocation(),rt=useResolvedPath(d,{relative:et});return reactExports.useCallback(it=>{if(shouldProcessLinkClick(it,$)){it.preventDefault();let st=b!==void 0?b:createPath(nt)===createPath(rt);tt(d,{replace:st,state:j,preventScrollReset:_e,relative:et})}},[nt,tt,rt,b,j,$,d,_e,et])}var client={},reactDomExports={},reactDom={get exports(){return reactDomExports},set exports(d){reactDomExports=d}},reactDom_production_min={},schedulerExports={},scheduler={get exports(){return schedulerExports},set exports(d){schedulerExports=d}},scheduler_production_min={};/** - * @license React - * scheduler.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */(function(d){function g(Nt,Lt){var jt=Nt.length;Nt.push(Lt);e:for(;0>>1,Qt=Nt[Yt];if(0>>1;Ytj(pn,jt))lnj(yn,pn)?(Nt[Yt]=yn,Nt[ln]=jt,Yt=ln):(Nt[Yt]=pn,Nt[un]=jt,Yt=un);else if(lnj(yn,jt))Nt[Yt]=yn,Nt[ln]=jt,Yt=ln;else break e}}return Lt}function j(Nt,Lt){var jt=Nt.sortIndex-Lt.sortIndex;return jt!==0?jt:Nt.id-Lt.id}if(typeof performance=="object"&&typeof performance.now=="function"){var _e=performance;d.unstable_now=function(){return _e.now()}}else{var et=Date,tt=et.now();d.unstable_now=function(){return et.now()-tt}}var nt=[],rt=[],it=1,st=null,ut=3,at=!1,ht=!1,ct=!1,vt=typeof setTimeout=="function"?setTimeout:null,ft=typeof clearTimeout=="function"?clearTimeout:null,gt=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function pt(Nt){for(var Lt=$(rt);Lt!==null;){if(Lt.callback===null)b(rt);else if(Lt.startTime<=Nt)b(rt),Lt.sortIndex=Lt.expirationTime,g(nt,Lt);else break;Lt=$(rt)}}function yt(Nt){if(ct=!1,pt(Nt),!ht)if($(nt)!==null)ht=!0,Jt(At);else{var Lt=$(rt);Lt!==null&&Xt(yt,Lt.startTime-Nt)}}function At(Nt,Lt){ht=!1,ct&&(ct=!1,ft(Bt),Bt=-1),at=!0;var jt=ut;try{for(pt(Lt),st=$(nt);st!==null&&(!(st.expirationTime>Lt)||Nt&&!_t());){var Yt=st.callback;if(typeof Yt=="function"){st.callback=null,ut=st.priorityLevel;var Qt=Yt(st.expirationTime<=Lt);Lt=d.unstable_now(),typeof Qt=="function"?st.callback=Qt:st===$(nt)&&b(nt),pt(Lt)}else b(nt);st=$(nt)}if(st!==null)var on=!0;else{var un=$(rt);un!==null&&Xt(yt,un.startTime-Lt),on=!1}return on}finally{st=null,ut=jt,at=!1}}var Dt=!1,St=null,Bt=-1,Ot=5,Ct=-1;function _t(){return!(d.unstable_now()-CtNt||125Yt?(Nt.sortIndex=jt,g(rt,Nt),$(nt)===null&&Nt===$(rt)&&(ct?(ft(Bt),Bt=-1):ct=!0,Xt(yt,jt-Yt))):(Nt.sortIndex=Qt,g(nt,Nt),ht||at||(ht=!0,Jt(At))),Nt},d.unstable_shouldYield=_t,d.unstable_wrapCallback=function(Nt){var Lt=ut;return function(){var jt=ut;ut=Lt;try{return Nt.apply(this,arguments)}finally{ut=jt}}}})(scheduler_production_min);(function(d){d.exports=scheduler_production_min})(scheduler);/** - * @license React - * react-dom.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var aa=reactExports,ca=schedulerExports;function p$1(d){for(var g="https://reactjs.org/docs/error-decoder.html?invariant="+d,$=1;$"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),ja=Object.prototype.hasOwnProperty,ka=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,la={},ma={};function oa(d){return ja.call(ma,d)?!0:ja.call(la,d)?!1:ka.test(d)?ma[d]=!0:(la[d]=!0,!1)}function pa(d,g,$,b){if($!==null&&$.type===0)return!1;switch(typeof g){case"function":case"symbol":return!0;case"boolean":return b?!1:$!==null?!$.acceptsBooleans:(d=d.toLowerCase().slice(0,5),d!=="data-"&&d!=="aria-");default:return!1}}function qa(d,g,$,b){if(g===null||typeof g>"u"||pa(d,g,$,b))return!0;if(b)return!1;if($!==null)switch($.type){case 3:return!g;case 4:return g===!1;case 5:return isNaN(g);case 6:return isNaN(g)||1>g}return!1}function v$1(d,g,$,b,j,_e,et){this.acceptsBooleans=g===2||g===3||g===4,this.attributeName=b,this.attributeNamespace=j,this.mustUseProperty=$,this.propertyName=d,this.type=g,this.sanitizeURL=_e,this.removeEmptyString=et}var z={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(d){z[d]=new v$1(d,0,!1,d,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(d){var g=d[0];z[g]=new v$1(g,1,!1,d[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(d){z[d]=new v$1(d,2,!1,d.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(d){z[d]=new v$1(d,2,!1,d,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(d){z[d]=new v$1(d,3,!1,d.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(d){z[d]=new v$1(d,3,!0,d,null,!1,!1)});["capture","download"].forEach(function(d){z[d]=new v$1(d,4,!1,d,null,!1,!1)});["cols","rows","size","span"].forEach(function(d){z[d]=new v$1(d,6,!1,d,null,!1,!1)});["rowSpan","start"].forEach(function(d){z[d]=new v$1(d,5,!1,d.toLowerCase(),null,!1,!1)});var ra=/[\-:]([a-z])/g;function sa(d){return d[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(d){var g=d.replace(ra,sa);z[g]=new v$1(g,1,!1,d,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(d){var g=d.replace(ra,sa);z[g]=new v$1(g,1,!1,d,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(d){var g=d.replace(ra,sa);z[g]=new v$1(g,1,!1,d,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(d){z[d]=new v$1(d,1,!1,d.toLowerCase(),null,!1,!1)});z.xlinkHref=new v$1("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(d){z[d]=new v$1(d,1,!1,d.toLowerCase(),null,!0,!0)});function ta(d,g,$,b){var j=z.hasOwnProperty(g)?z[g]:null;(j!==null?j.type!==0:b||!(2tt||j[et]!==_e[tt]){var nt=` -`+j[et].replace(" at new "," at ");return d.displayName&&nt.includes("")&&(nt=nt.replace("",d.displayName)),nt}while(1<=et&&0<=tt);break}}}finally{Na=!1,Error.prepareStackTrace=$}return(d=d?d.displayName||d.name:"")?Ma(d):""}function Pa(d){switch(d.tag){case 5:return Ma(d.type);case 16:return Ma("Lazy");case 13:return Ma("Suspense");case 19:return Ma("SuspenseList");case 0:case 2:case 15:return d=Oa(d.type,!1),d;case 11:return d=Oa(d.type.render,!1),d;case 1:return d=Oa(d.type,!0),d;default:return""}}function Qa(d){if(d==null)return null;if(typeof d=="function")return d.displayName||d.name||null;if(typeof d=="string")return d;switch(d){case ya:return"Fragment";case wa:return"Portal";case Aa:return"Profiler";case za:return"StrictMode";case Ea:return"Suspense";case Fa:return"SuspenseList"}if(typeof d=="object")switch(d.$$typeof){case Ca:return(d.displayName||"Context")+".Consumer";case Ba:return(d._context.displayName||"Context")+".Provider";case Da:var g=d.render;return d=d.displayName,d||(d=g.displayName||g.name||"",d=d!==""?"ForwardRef("+d+")":"ForwardRef"),d;case Ga:return g=d.displayName||null,g!==null?g:Qa(d.type)||"Memo";case Ha:g=d._payload,d=d._init;try{return Qa(d(g))}catch{}}return null}function Ra(d){var g=d.type;switch(d.tag){case 24:return"Cache";case 9:return(g.displayName||"Context")+".Consumer";case 10:return(g._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return d=g.render,d=d.displayName||d.name||"",g.displayName||(d!==""?"ForwardRef("+d+")":"ForwardRef");case 7:return"Fragment";case 5:return g;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Qa(g);case 8:return g===za?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof g=="function")return g.displayName||g.name||null;if(typeof g=="string")return g}return null}function Sa(d){switch(typeof d){case"boolean":case"number":case"string":case"undefined":return d;case"object":return d;default:return""}}function Ta(d){var g=d.type;return(d=d.nodeName)&&d.toLowerCase()==="input"&&(g==="checkbox"||g==="radio")}function Ua(d){var g=Ta(d)?"checked":"value",$=Object.getOwnPropertyDescriptor(d.constructor.prototype,g),b=""+d[g];if(!d.hasOwnProperty(g)&&typeof $<"u"&&typeof $.get=="function"&&typeof $.set=="function"){var j=$.get,_e=$.set;return Object.defineProperty(d,g,{configurable:!0,get:function(){return j.call(this)},set:function(et){b=""+et,_e.call(this,et)}}),Object.defineProperty(d,g,{enumerable:$.enumerable}),{getValue:function(){return b},setValue:function(et){b=""+et},stopTracking:function(){d._valueTracker=null,delete d[g]}}}}function Va(d){d._valueTracker||(d._valueTracker=Ua(d))}function Wa(d){if(!d)return!1;var g=d._valueTracker;if(!g)return!0;var $=g.getValue(),b="";return d&&(b=Ta(d)?d.checked?"true":"false":d.value),d=b,d!==$?(g.setValue(d),!0):!1}function Xa(d){if(d=d||(typeof document<"u"?document:void 0),typeof d>"u")return null;try{return d.activeElement||d.body}catch{return d.body}}function Ya(d,g){var $=g.checked;return A({},g,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:$??d._wrapperState.initialChecked})}function Za(d,g){var $=g.defaultValue==null?"":g.defaultValue,b=g.checked!=null?g.checked:g.defaultChecked;$=Sa(g.value!=null?g.value:$),d._wrapperState={initialChecked:b,initialValue:$,controlled:g.type==="checkbox"||g.type==="radio"?g.checked!=null:g.value!=null}}function ab(d,g){g=g.checked,g!=null&&ta(d,"checked",g,!1)}function bb(d,g){ab(d,g);var $=Sa(g.value),b=g.type;if($!=null)b==="number"?($===0&&d.value===""||d.value!=$)&&(d.value=""+$):d.value!==""+$&&(d.value=""+$);else if(b==="submit"||b==="reset"){d.removeAttribute("value");return}g.hasOwnProperty("value")?cb(d,g.type,$):g.hasOwnProperty("defaultValue")&&cb(d,g.type,Sa(g.defaultValue)),g.checked==null&&g.defaultChecked!=null&&(d.defaultChecked=!!g.defaultChecked)}function db(d,g,$){if(g.hasOwnProperty("value")||g.hasOwnProperty("defaultValue")){var b=g.type;if(!(b!=="submit"&&b!=="reset"||g.value!==void 0&&g.value!==null))return;g=""+d._wrapperState.initialValue,$||g===d.value||(d.value=g),d.defaultValue=g}$=d.name,$!==""&&(d.name=""),d.defaultChecked=!!d._wrapperState.initialChecked,$!==""&&(d.name=$)}function cb(d,g,$){(g!=="number"||Xa(d.ownerDocument)!==d)&&($==null?d.defaultValue=""+d._wrapperState.initialValue:d.defaultValue!==""+$&&(d.defaultValue=""+$))}var eb=Array.isArray;function fb(d,g,$,b){if(d=d.options,g){g={};for(var j=0;j<$.length;j++)g["$"+$[j]]=!0;for($=0;$"+g.valueOf().toString()+"",g=mb.firstChild;d.firstChild;)d.removeChild(d.firstChild);for(;g.firstChild;)d.appendChild(g.firstChild)}});function ob(d,g){if(g){var $=d.firstChild;if($&&$===d.lastChild&&$.nodeType===3){$.nodeValue=g;return}}d.textContent=g}var pb={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},qb=["Webkit","ms","Moz","O"];Object.keys(pb).forEach(function(d){qb.forEach(function(g){g=g+d.charAt(0).toUpperCase()+d.substring(1),pb[g]=pb[d]})});function rb(d,g,$){return g==null||typeof g=="boolean"||g===""?"":$||typeof g!="number"||g===0||pb.hasOwnProperty(d)&&pb[d]?(""+g).trim():g+"px"}function sb(d,g){d=d.style;for(var $ in g)if(g.hasOwnProperty($)){var b=$.indexOf("--")===0,j=rb($,g[$],b);$==="float"&&($="cssFloat"),b?d.setProperty($,j):d[$]=j}}var tb=A({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function ub(d,g){if(g){if(tb[d]&&(g.children!=null||g.dangerouslySetInnerHTML!=null))throw Error(p$1(137,d));if(g.dangerouslySetInnerHTML!=null){if(g.children!=null)throw Error(p$1(60));if(typeof g.dangerouslySetInnerHTML!="object"||!("__html"in g.dangerouslySetInnerHTML))throw Error(p$1(61))}if(g.style!=null&&typeof g.style!="object")throw Error(p$1(62))}}function vb(d,g){if(d.indexOf("-")===-1)return typeof g.is=="string";switch(d){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var wb=null;function xb(d){return d=d.target||d.srcElement||window,d.correspondingUseElement&&(d=d.correspondingUseElement),d.nodeType===3?d.parentNode:d}var yb=null,zb=null,Ab=null;function Bb(d){if(d=Cb(d)){if(typeof yb!="function")throw Error(p$1(280));var g=d.stateNode;g&&(g=Db(g),yb(d.stateNode,d.type,g))}}function Eb(d){zb?Ab?Ab.push(d):Ab=[d]:zb=d}function Fb(){if(zb){var d=zb,g=Ab;if(Ab=zb=null,Bb(d),g)for(d=0;d>>=0,d===0?32:31-(pc(d)/qc|0)|0}var rc=64,sc=4194304;function tc(d){switch(d&-d){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return d&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return d&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return d}}function uc(d,g){var $=d.pendingLanes;if($===0)return 0;var b=0,j=d.suspendedLanes,_e=d.pingedLanes,et=$&268435455;if(et!==0){var tt=et&~j;tt!==0?b=tc(tt):(_e&=et,_e!==0&&(b=tc(_e)))}else et=$&~j,et!==0?b=tc(et):_e!==0&&(b=tc(_e));if(b===0)return 0;if(g!==0&&g!==b&&!(g&j)&&(j=b&-b,_e=g&-g,j>=_e||j===16&&(_e&4194240)!==0))return g;if(b&4&&(b|=$&16),g=d.entangledLanes,g!==0)for(d=d.entanglements,g&=b;0$;$++)g.push(d);return g}function Ac(d,g,$){d.pendingLanes|=g,g!==536870912&&(d.suspendedLanes=0,d.pingedLanes=0),d=d.eventTimes,g=31-oc(g),d[g]=$}function Bc(d,g){var $=d.pendingLanes&~g;d.pendingLanes=g,d.suspendedLanes=0,d.pingedLanes=0,d.expiredLanes&=g,d.mutableReadLanes&=g,d.entangledLanes&=g,g=d.entanglements;var b=d.eventTimes;for(d=d.expirationTimes;0<$;){var j=31-oc($),_e=1<=be),ee=String.fromCharCode(32),fe=!1;function ge(d,g){switch(d){case"keyup":return $d.indexOf(g.keyCode)!==-1;case"keydown":return g.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function he(d){return d=d.detail,typeof d=="object"&&"data"in d?d.data:null}var ie=!1;function je(d,g){switch(d){case"compositionend":return he(g);case"keypress":return g.which!==32?null:(fe=!0,ee);case"textInput":return d=g.data,d===ee&&fe?null:d;default:return null}}function ke(d,g){if(ie)return d==="compositionend"||!ae&&ge(d,g)?(d=nd(),md=ld=kd=null,ie=!1,d):null;switch(d){case"paste":return null;case"keypress":if(!(g.ctrlKey||g.altKey||g.metaKey)||g.ctrlKey&&g.altKey){if(g.char&&1=g)return{node:$,offset:g-d};d=b}e:{for(;$;){if($.nextSibling){$=$.nextSibling;break e}$=$.parentNode}$=void 0}$=Je($)}}function Le(d,g){return d&&g?d===g?!0:d&&d.nodeType===3?!1:g&&g.nodeType===3?Le(d,g.parentNode):"contains"in d?d.contains(g):d.compareDocumentPosition?!!(d.compareDocumentPosition(g)&16):!1:!1}function Me(){for(var d=window,g=Xa();g instanceof d.HTMLIFrameElement;){try{var $=typeof g.contentWindow.location.href=="string"}catch{$=!1}if($)d=g.contentWindow;else break;g=Xa(d.document)}return g}function Ne(d){var g=d&&d.nodeName&&d.nodeName.toLowerCase();return g&&(g==="input"&&(d.type==="text"||d.type==="search"||d.type==="tel"||d.type==="url"||d.type==="password")||g==="textarea"||d.contentEditable==="true")}function Oe(d){var g=Me(),$=d.focusedElem,b=d.selectionRange;if(g!==$&&$&&$.ownerDocument&&Le($.ownerDocument.documentElement,$)){if(b!==null&&Ne($)){if(g=b.start,d=b.end,d===void 0&&(d=g),"selectionStart"in $)$.selectionStart=g,$.selectionEnd=Math.min(d,$.value.length);else if(d=(g=$.ownerDocument||document)&&g.defaultView||window,d.getSelection){d=d.getSelection();var j=$.textContent.length,_e=Math.min(b.start,j);b=b.end===void 0?_e:Math.min(b.end,j),!d.extend&&_e>b&&(j=b,b=_e,_e=j),j=Ke($,_e);var et=Ke($,b);j&&et&&(d.rangeCount!==1||d.anchorNode!==j.node||d.anchorOffset!==j.offset||d.focusNode!==et.node||d.focusOffset!==et.offset)&&(g=g.createRange(),g.setStart(j.node,j.offset),d.removeAllRanges(),_e>b?(d.addRange(g),d.extend(et.node,et.offset)):(g.setEnd(et.node,et.offset),d.addRange(g)))}}for(g=[],d=$;d=d.parentNode;)d.nodeType===1&&g.push({element:d,left:d.scrollLeft,top:d.scrollTop});for(typeof $.focus=="function"&&$.focus(),$=0;$=document.documentMode,Qe=null,Re=null,Se=null,Te=!1;function Ue(d,g,$){var b=$.window===$?$.document:$.nodeType===9?$:$.ownerDocument;Te||Qe==null||Qe!==Xa(b)||(b=Qe,"selectionStart"in b&&Ne(b)?b={start:b.selectionStart,end:b.selectionEnd}:(b=(b.ownerDocument&&b.ownerDocument.defaultView||window).getSelection(),b={anchorNode:b.anchorNode,anchorOffset:b.anchorOffset,focusNode:b.focusNode,focusOffset:b.focusOffset}),Se&&Ie(Se,b)||(Se=b,b=oe(Re,"onSelect"),0Tf||(d.current=Sf[Tf],Sf[Tf]=null,Tf--)}function G(d,g){Tf++,Sf[Tf]=d.current,d.current=g}var Vf={},H=Uf(Vf),Wf=Uf(!1),Xf=Vf;function Yf(d,g){var $=d.type.contextTypes;if(!$)return Vf;var b=d.stateNode;if(b&&b.__reactInternalMemoizedUnmaskedChildContext===g)return b.__reactInternalMemoizedMaskedChildContext;var j={},_e;for(_e in $)j[_e]=g[_e];return b&&(d=d.stateNode,d.__reactInternalMemoizedUnmaskedChildContext=g,d.__reactInternalMemoizedMaskedChildContext=j),j}function Zf(d){return d=d.childContextTypes,d!=null}function $f(){E(Wf),E(H)}function ag(d,g,$){if(H.current!==Vf)throw Error(p$1(168));G(H,g),G(Wf,$)}function bg(d,g,$){var b=d.stateNode;if(g=g.childContextTypes,typeof b.getChildContext!="function")return $;b=b.getChildContext();for(var j in b)if(!(j in g))throw Error(p$1(108,Ra(d)||"Unknown",j));return A({},$,b)}function cg(d){return d=(d=d.stateNode)&&d.__reactInternalMemoizedMergedChildContext||Vf,Xf=H.current,G(H,d),G(Wf,Wf.current),!0}function dg(d,g,$){var b=d.stateNode;if(!b)throw Error(p$1(169));$?(d=bg(d,g,Xf),b.__reactInternalMemoizedMergedChildContext=d,E(Wf),E(H),G(H,d)):E(Wf),G(Wf,$)}var eg=null,fg=!1,gg=!1;function hg(d){eg===null?eg=[d]:eg.push(d)}function ig(d){fg=!0,hg(d)}function jg(){if(!gg&&eg!==null){gg=!0;var d=0,g=C;try{var $=eg;for(C=1;d<$.length;d++){var b=$[d];do b=b(!0);while(b!==null)}eg=null,fg=!1}catch(j){throw eg!==null&&(eg=eg.slice(d+1)),ac(fc,jg),j}finally{C=g,gg=!1}}return null}var kg=[],lg=0,mg=null,ng=0,og=[],pg=0,qg=null,rg=1,sg="";function tg(d,g){kg[lg++]=ng,kg[lg++]=mg,mg=d,ng=g}function ug(d,g,$){og[pg++]=rg,og[pg++]=sg,og[pg++]=qg,qg=d;var b=rg;d=sg;var j=32-oc(b)-1;b&=~(1<>=et,j-=et,rg=1<<32-oc(g)+j|$<Bt?(Ot=St,St=null):Ot=St.sibling;var Ct=ut(ft,St,pt[Bt],yt);if(Ct===null){St===null&&(St=Ot);break}d&&St&&Ct.alternate===null&&g(ft,St),gt=_e(Ct,gt,Bt),Dt===null?At=Ct:Dt.sibling=Ct,Dt=Ct,St=Ot}if(Bt===pt.length)return $(ft,St),I&&tg(ft,Bt),At;if(St===null){for(;BtBt?(Ot=St,St=null):Ot=St.sibling;var _t=ut(ft,St,Ct.value,yt);if(_t===null){St===null&&(St=Ot);break}d&&St&&_t.alternate===null&&g(ft,St),gt=_e(_t,gt,Bt),Dt===null?At=_t:Dt.sibling=_t,Dt=_t,St=Ot}if(Ct.done)return $(ft,St),I&&tg(ft,Bt),At;if(St===null){for(;!Ct.done;Bt++,Ct=pt.next())Ct=st(ft,Ct.value,yt),Ct!==null&&(gt=_e(Ct,gt,Bt),Dt===null?At=Ct:Dt.sibling=Ct,Dt=Ct);return I&&tg(ft,Bt),At}for(St=b(ft,St);!Ct.done;Bt++,Ct=pt.next())Ct=at(St,ft,Bt,Ct.value,yt),Ct!==null&&(d&&Ct.alternate!==null&&St.delete(Ct.key===null?Bt:Ct.key),gt=_e(Ct,gt,Bt),Dt===null?At=Ct:Dt.sibling=Ct,Dt=Ct);return d&&St.forEach(function(Tt){return g(ft,Tt)}),I&&tg(ft,Bt),At}function vt(ft,gt,pt,yt){if(typeof pt=="object"&&pt!==null&&pt.type===ya&&pt.key===null&&(pt=pt.props.children),typeof pt=="object"&&pt!==null){switch(pt.$$typeof){case va:e:{for(var At=pt.key,Dt=gt;Dt!==null;){if(Dt.key===At){if(At=pt.type,At===ya){if(Dt.tag===7){$(ft,Dt.sibling),gt=j(Dt,pt.props.children),gt.return=ft,ft=gt;break e}}else if(Dt.elementType===At||typeof At=="object"&&At!==null&&At.$$typeof===Ha&&uh(At)===Dt.type){$(ft,Dt.sibling),gt=j(Dt,pt.props),gt.ref=sh(ft,Dt,pt),gt.return=ft,ft=gt;break e}$(ft,Dt);break}else g(ft,Dt);Dt=Dt.sibling}pt.type===ya?(gt=Ah(pt.props.children,ft.mode,yt,pt.key),gt.return=ft,ft=gt):(yt=yh(pt.type,pt.key,pt.props,null,ft.mode,yt),yt.ref=sh(ft,gt,pt),yt.return=ft,ft=yt)}return et(ft);case wa:e:{for(Dt=pt.key;gt!==null;){if(gt.key===Dt)if(gt.tag===4&>.stateNode.containerInfo===pt.containerInfo&>.stateNode.implementation===pt.implementation){$(ft,gt.sibling),gt=j(gt,pt.children||[]),gt.return=ft,ft=gt;break e}else{$(ft,gt);break}else g(ft,gt);gt=gt.sibling}gt=zh(pt,ft.mode,yt),gt.return=ft,ft=gt}return et(ft);case Ha:return Dt=pt._init,vt(ft,gt,Dt(pt._payload),yt)}if(eb(pt))return ht(ft,gt,pt,yt);if(Ka(pt))return ct(ft,gt,pt,yt);th(ft,pt)}return typeof pt=="string"&&pt!==""||typeof pt=="number"?(pt=""+pt,gt!==null&>.tag===6?($(ft,gt.sibling),gt=j(gt,pt),gt.return=ft,ft=gt):($(ft,gt),gt=xh(pt,ft.mode,yt),gt.return=ft,ft=gt),et(ft)):$(ft,gt)}return vt}var Bh=vh(!0),Ch=vh(!1),Dh={},Eh=Uf(Dh),Fh=Uf(Dh),Gh=Uf(Dh);function Hh(d){if(d===Dh)throw Error(p$1(174));return d}function Ih(d,g){switch(G(Gh,g),G(Fh,d),G(Eh,Dh),d=g.nodeType,d){case 9:case 11:g=(g=g.documentElement)?g.namespaceURI:lb(null,"");break;default:d=d===8?g.parentNode:g,g=d.namespaceURI||null,d=d.tagName,g=lb(g,d)}E(Eh),G(Eh,g)}function Jh(){E(Eh),E(Fh),E(Gh)}function Kh(d){Hh(Gh.current);var g=Hh(Eh.current),$=lb(g,d.type);g!==$&&(G(Fh,d),G(Eh,$))}function Lh(d){Fh.current===d&&(E(Eh),E(Fh))}var M=Uf(0);function Mh(d){for(var g=d;g!==null;){if(g.tag===13){var $=g.memoizedState;if($!==null&&($=$.dehydrated,$===null||$.data==="$?"||$.data==="$!"))return g}else if(g.tag===19&&g.memoizedProps.revealOrder!==void 0){if(g.flags&128)return g}else if(g.child!==null){g.child.return=g,g=g.child;continue}if(g===d)break;for(;g.sibling===null;){if(g.return===null||g.return===d)return null;g=g.return}g.sibling.return=g.return,g=g.sibling}return null}var Nh=[];function Oh(){for(var d=0;d$?$:4,d(!0);var b=Qh.transition;Qh.transition={};try{d(!1),g()}finally{C=$,Qh.transition=b}}function Fi(){return di().memoizedState}function Gi(d,g,$){var b=lh(d);if($={lane:b,action:$,hasEagerState:!1,eagerState:null,next:null},Hi(d))Ii(g,$);else if($=Yg(d,g,$,b),$!==null){var j=L();mh($,d,b,j),Ji($,g,b)}}function ri(d,g,$){var b=lh(d),j={lane:b,action:$,hasEagerState:!1,eagerState:null,next:null};if(Hi(d))Ii(g,j);else{var _e=d.alternate;if(d.lanes===0&&(_e===null||_e.lanes===0)&&(_e=g.lastRenderedReducer,_e!==null))try{var et=g.lastRenderedState,tt=_e(et,$);if(j.hasEagerState=!0,j.eagerState=tt,He(tt,et)){var nt=g.interleaved;nt===null?(j.next=j,Xg(g)):(j.next=nt.next,nt.next=j),g.interleaved=j;return}}catch{}finally{}$=Yg(d,g,j,b),$!==null&&(j=L(),mh($,d,b,j),Ji($,g,b))}}function Hi(d){var g=d.alternate;return d===N$1||g!==null&&g===N$1}function Ii(d,g){Th=Sh=!0;var $=d.pending;$===null?g.next=g:(g.next=$.next,$.next=g),d.pending=g}function Ji(d,g,$){if($&4194240){var b=g.lanes;b&=d.pendingLanes,$|=b,g.lanes=$,Cc(d,$)}}var ai={readContext:Vg,useCallback:Q,useContext:Q,useEffect:Q,useImperativeHandle:Q,useInsertionEffect:Q,useLayoutEffect:Q,useMemo:Q,useReducer:Q,useRef:Q,useState:Q,useDebugValue:Q,useDeferredValue:Q,useTransition:Q,useMutableSource:Q,useSyncExternalStore:Q,useId:Q,unstable_isNewReconciler:!1},Yh={readContext:Vg,useCallback:function(d,g){return ci().memoizedState=[d,g===void 0?null:g],d},useContext:Vg,useEffect:vi,useImperativeHandle:function(d,g,$){return $=$!=null?$.concat([d]):null,ti(4194308,4,yi.bind(null,g,d),$)},useLayoutEffect:function(d,g){return ti(4194308,4,d,g)},useInsertionEffect:function(d,g){return ti(4,2,d,g)},useMemo:function(d,g){var $=ci();return g=g===void 0?null:g,d=d(),$.memoizedState=[d,g],d},useReducer:function(d,g,$){var b=ci();return g=$!==void 0?$(g):g,b.memoizedState=b.baseState=g,d={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:d,lastRenderedState:g},b.queue=d,d=d.dispatch=Gi.bind(null,N$1,d),[b.memoizedState,d]},useRef:function(d){var g=ci();return d={current:d},g.memoizedState=d},useState:qi,useDebugValue:Ai,useDeferredValue:function(d){return ci().memoizedState=d},useTransition:function(){var d=qi(!1),g=d[0];return d=Ei.bind(null,d[1]),ci().memoizedState=d,[g,d]},useMutableSource:function(){},useSyncExternalStore:function(d,g,$){var b=N$1,j=ci();if(I){if($===void 0)throw Error(p$1(407));$=$()}else{if($=g(),R===null)throw Error(p$1(349));Rh&30||ni(b,g,$)}j.memoizedState=$;var _e={value:$,getSnapshot:g};return j.queue=_e,vi(ki.bind(null,b,_e,d),[d]),b.flags|=2048,li(9,mi.bind(null,b,_e,$,g),void 0,null),$},useId:function(){var d=ci(),g=R.identifierPrefix;if(I){var $=sg,b=rg;$=(b&~(1<<32-oc(b)-1)).toString(32)+$,g=":"+g+"R"+$,$=Uh++,0<$&&(g+="H"+$.toString(32)),g+=":"}else $=Vh++,g=":"+g+"r"+$.toString(32)+":";return d.memoizedState=g},unstable_isNewReconciler:!1},Zh={readContext:Vg,useCallback:Bi,useContext:Vg,useEffect:ji,useImperativeHandle:zi,useInsertionEffect:wi,useLayoutEffect:xi,useMemo:Ci,useReducer:fi,useRef:si,useState:function(){return fi(ei)},useDebugValue:Ai,useDeferredValue:function(d){var g=di();return Di(g,O$1.memoizedState,d)},useTransition:function(){var d=fi(ei)[0],g=di().memoizedState;return[d,g]},useMutableSource:hi,useSyncExternalStore:ii,useId:Fi,unstable_isNewReconciler:!1},$h={readContext:Vg,useCallback:Bi,useContext:Vg,useEffect:ji,useImperativeHandle:zi,useInsertionEffect:wi,useLayoutEffect:xi,useMemo:Ci,useReducer:gi,useRef:si,useState:function(){return gi(ei)},useDebugValue:Ai,useDeferredValue:function(d){var g=di();return O$1===null?g.memoizedState=d:Di(g,O$1.memoizedState,d)},useTransition:function(){var d=gi(ei)[0],g=di().memoizedState;return[d,g]},useMutableSource:hi,useSyncExternalStore:ii,useId:Fi,unstable_isNewReconciler:!1};function Ki(d,g){try{var $="",b=g;do $+=Pa(b),b=b.return;while(b);var j=$}catch(_e){j=` -Error generating stack: `+_e.message+` -`+_e.stack}return{value:d,source:g,stack:j,digest:null}}function Li(d,g,$){return{value:d,source:null,stack:$??null,digest:g??null}}function Mi(d,g){try{console.error(g.value)}catch($){setTimeout(function(){throw $})}}var Ni=typeof WeakMap=="function"?WeakMap:Map;function Oi(d,g,$){$=ch(-1,$),$.tag=3,$.payload={element:null};var b=g.value;return $.callback=function(){Pi||(Pi=!0,Qi=b),Mi(d,g)},$}function Ri(d,g,$){$=ch(-1,$),$.tag=3;var b=d.type.getDerivedStateFromError;if(typeof b=="function"){var j=g.value;$.payload=function(){return b(j)},$.callback=function(){Mi(d,g)}}var _e=d.stateNode;return _e!==null&&typeof _e.componentDidCatch=="function"&&($.callback=function(){Mi(d,g),typeof b!="function"&&(Si===null?Si=new Set([this]):Si.add(this));var et=g.stack;this.componentDidCatch(g.value,{componentStack:et!==null?et:""})}),$}function Ti(d,g,$){var b=d.pingCache;if(b===null){b=d.pingCache=new Ni;var j=new Set;b.set(g,j)}else j=b.get(g),j===void 0&&(j=new Set,b.set(g,j));j.has($)||(j.add($),d=Ui.bind(null,d,g,$),g.then(d,d))}function Vi(d){do{var g;if((g=d.tag===13)&&(g=d.memoizedState,g=g!==null?g.dehydrated!==null:!0),g)return d;d=d.return}while(d!==null);return null}function Wi(d,g,$,b,j){return d.mode&1?(d.flags|=65536,d.lanes=j,d):(d===g?d.flags|=65536:(d.flags|=128,$.flags|=131072,$.flags&=-52805,$.tag===1&&($.alternate===null?$.tag=17:(g=ch(-1,1),g.tag=2,dh($,g,1))),$.lanes|=1),d)}var Xi=ua.ReactCurrentOwner,Ug=!1;function Yi(d,g,$,b){g.child=d===null?Ch(g,null,$,b):Bh(g,d.child,$,b)}function Zi(d,g,$,b,j){$=$.render;var _e=g.ref;return Tg(g,j),b=Xh(d,g,$,b,_e,j),$=bi(),d!==null&&!Ug?(g.updateQueue=d.updateQueue,g.flags&=-2053,d.lanes&=~j,$i(d,g,j)):(I&&$&&vg(g),g.flags|=1,Yi(d,g,b,j),g.child)}function aj(d,g,$,b,j){if(d===null){var _e=$.type;return typeof _e=="function"&&!bj(_e)&&_e.defaultProps===void 0&&$.compare===null&&$.defaultProps===void 0?(g.tag=15,g.type=_e,cj(d,g,_e,b,j)):(d=yh($.type,null,b,g,g.mode,j),d.ref=g.ref,d.return=g,g.child=d)}if(_e=d.child,!(d.lanes&j)){var et=_e.memoizedProps;if($=$.compare,$=$!==null?$:Ie,$(et,b)&&d.ref===g.ref)return $i(d,g,j)}return g.flags|=1,d=wh(_e,b),d.ref=g.ref,d.return=g,g.child=d}function cj(d,g,$,b,j){if(d!==null){var _e=d.memoizedProps;if(Ie(_e,b)&&d.ref===g.ref)if(Ug=!1,g.pendingProps=b=_e,(d.lanes&j)!==0)d.flags&131072&&(Ug=!0);else return g.lanes=d.lanes,$i(d,g,j)}return dj(d,g,$,b,j)}function ej(d,g,$){var b=g.pendingProps,j=b.children,_e=d!==null?d.memoizedState:null;if(b.mode==="hidden")if(!(g.mode&1))g.memoizedState={baseLanes:0,cachePool:null,transitions:null},G(fj,gj),gj|=$;else{if(!($&1073741824))return d=_e!==null?_e.baseLanes|$:$,g.lanes=g.childLanes=1073741824,g.memoizedState={baseLanes:d,cachePool:null,transitions:null},g.updateQueue=null,G(fj,gj),gj|=d,null;g.memoizedState={baseLanes:0,cachePool:null,transitions:null},b=_e!==null?_e.baseLanes:$,G(fj,gj),gj|=b}else _e!==null?(b=_e.baseLanes|$,g.memoizedState=null):b=$,G(fj,gj),gj|=b;return Yi(d,g,j,$),g.child}function hj(d,g){var $=g.ref;(d===null&&$!==null||d!==null&&d.ref!==$)&&(g.flags|=512,g.flags|=2097152)}function dj(d,g,$,b,j){var _e=Zf($)?Xf:H.current;return _e=Yf(g,_e),Tg(g,j),$=Xh(d,g,$,b,_e,j),b=bi(),d!==null&&!Ug?(g.updateQueue=d.updateQueue,g.flags&=-2053,d.lanes&=~j,$i(d,g,j)):(I&&b&&vg(g),g.flags|=1,Yi(d,g,$,j),g.child)}function ij(d,g,$,b,j){if(Zf($)){var _e=!0;cg(g)}else _e=!1;if(Tg(g,j),g.stateNode===null)jj(d,g),ph(g,$,b),rh(g,$,b,j),b=!0;else if(d===null){var et=g.stateNode,tt=g.memoizedProps;et.props=tt;var nt=et.context,rt=$.contextType;typeof rt=="object"&&rt!==null?rt=Vg(rt):(rt=Zf($)?Xf:H.current,rt=Yf(g,rt));var it=$.getDerivedStateFromProps,st=typeof it=="function"||typeof et.getSnapshotBeforeUpdate=="function";st||typeof et.UNSAFE_componentWillReceiveProps!="function"&&typeof et.componentWillReceiveProps!="function"||(tt!==b||nt!==rt)&&qh(g,et,b,rt),$g=!1;var ut=g.memoizedState;et.state=ut,gh(g,b,et,j),nt=g.memoizedState,tt!==b||ut!==nt||Wf.current||$g?(typeof it=="function"&&(kh(g,$,it,b),nt=g.memoizedState),(tt=$g||oh(g,$,tt,b,ut,nt,rt))?(st||typeof et.UNSAFE_componentWillMount!="function"&&typeof et.componentWillMount!="function"||(typeof et.componentWillMount=="function"&&et.componentWillMount(),typeof et.UNSAFE_componentWillMount=="function"&&et.UNSAFE_componentWillMount()),typeof et.componentDidMount=="function"&&(g.flags|=4194308)):(typeof et.componentDidMount=="function"&&(g.flags|=4194308),g.memoizedProps=b,g.memoizedState=nt),et.props=b,et.state=nt,et.context=rt,b=tt):(typeof et.componentDidMount=="function"&&(g.flags|=4194308),b=!1)}else{et=g.stateNode,bh(d,g),tt=g.memoizedProps,rt=g.type===g.elementType?tt:Lg(g.type,tt),et.props=rt,st=g.pendingProps,ut=et.context,nt=$.contextType,typeof nt=="object"&&nt!==null?nt=Vg(nt):(nt=Zf($)?Xf:H.current,nt=Yf(g,nt));var at=$.getDerivedStateFromProps;(it=typeof at=="function"||typeof et.getSnapshotBeforeUpdate=="function")||typeof et.UNSAFE_componentWillReceiveProps!="function"&&typeof et.componentWillReceiveProps!="function"||(tt!==st||ut!==nt)&&qh(g,et,b,nt),$g=!1,ut=g.memoizedState,et.state=ut,gh(g,b,et,j);var ht=g.memoizedState;tt!==st||ut!==ht||Wf.current||$g?(typeof at=="function"&&(kh(g,$,at,b),ht=g.memoizedState),(rt=$g||oh(g,$,rt,b,ut,ht,nt)||!1)?(it||typeof et.UNSAFE_componentWillUpdate!="function"&&typeof et.componentWillUpdate!="function"||(typeof et.componentWillUpdate=="function"&&et.componentWillUpdate(b,ht,nt),typeof et.UNSAFE_componentWillUpdate=="function"&&et.UNSAFE_componentWillUpdate(b,ht,nt)),typeof et.componentDidUpdate=="function"&&(g.flags|=4),typeof et.getSnapshotBeforeUpdate=="function"&&(g.flags|=1024)):(typeof et.componentDidUpdate!="function"||tt===d.memoizedProps&&ut===d.memoizedState||(g.flags|=4),typeof et.getSnapshotBeforeUpdate!="function"||tt===d.memoizedProps&&ut===d.memoizedState||(g.flags|=1024),g.memoizedProps=b,g.memoizedState=ht),et.props=b,et.state=ht,et.context=nt,b=rt):(typeof et.componentDidUpdate!="function"||tt===d.memoizedProps&&ut===d.memoizedState||(g.flags|=4),typeof et.getSnapshotBeforeUpdate!="function"||tt===d.memoizedProps&&ut===d.memoizedState||(g.flags|=1024),b=!1)}return kj(d,g,$,b,_e,j)}function kj(d,g,$,b,j,_e){hj(d,g);var et=(g.flags&128)!==0;if(!b&&!et)return j&&dg(g,$,!1),$i(d,g,_e);b=g.stateNode,Xi.current=g;var tt=et&&typeof $.getDerivedStateFromError!="function"?null:b.render();return g.flags|=1,d!==null&&et?(g.child=Bh(g,d.child,null,_e),g.child=Bh(g,null,tt,_e)):Yi(d,g,tt,_e),g.memoizedState=b.state,j&&dg(g,$,!0),g.child}function lj(d){var g=d.stateNode;g.pendingContext?ag(d,g.pendingContext,g.pendingContext!==g.context):g.context&&ag(d,g.context,!1),Ih(d,g.containerInfo)}function mj(d,g,$,b,j){return Ig(),Jg(j),g.flags|=256,Yi(d,g,$,b),g.child}var nj={dehydrated:null,treeContext:null,retryLane:0};function oj(d){return{baseLanes:d,cachePool:null,transitions:null}}function pj(d,g,$){var b=g.pendingProps,j=M.current,_e=!1,et=(g.flags&128)!==0,tt;if((tt=et)||(tt=d!==null&&d.memoizedState===null?!1:(j&2)!==0),tt?(_e=!0,g.flags&=-129):(d===null||d.memoizedState!==null)&&(j|=1),G(M,j&1),d===null)return Eg(g),d=g.memoizedState,d!==null&&(d=d.dehydrated,d!==null)?(g.mode&1?d.data==="$!"?g.lanes=8:g.lanes=1073741824:g.lanes=1,null):(et=b.children,d=b.fallback,_e?(b=g.mode,_e=g.child,et={mode:"hidden",children:et},!(b&1)&&_e!==null?(_e.childLanes=0,_e.pendingProps=et):_e=qj(et,b,0,null),d=Ah(d,b,$,null),_e.return=g,d.return=g,_e.sibling=d,g.child=_e,g.child.memoizedState=oj($),g.memoizedState=nj,d):rj(g,et));if(j=d.memoizedState,j!==null&&(tt=j.dehydrated,tt!==null))return sj(d,g,et,b,tt,j,$);if(_e){_e=b.fallback,et=g.mode,j=d.child,tt=j.sibling;var nt={mode:"hidden",children:b.children};return!(et&1)&&g.child!==j?(b=g.child,b.childLanes=0,b.pendingProps=nt,g.deletions=null):(b=wh(j,nt),b.subtreeFlags=j.subtreeFlags&14680064),tt!==null?_e=wh(tt,_e):(_e=Ah(_e,et,$,null),_e.flags|=2),_e.return=g,b.return=g,b.sibling=_e,g.child=b,b=_e,_e=g.child,et=d.child.memoizedState,et=et===null?oj($):{baseLanes:et.baseLanes|$,cachePool:null,transitions:et.transitions},_e.memoizedState=et,_e.childLanes=d.childLanes&~$,g.memoizedState=nj,b}return _e=d.child,d=_e.sibling,b=wh(_e,{mode:"visible",children:b.children}),!(g.mode&1)&&(b.lanes=$),b.return=g,b.sibling=null,d!==null&&($=g.deletions,$===null?(g.deletions=[d],g.flags|=16):$.push(d)),g.child=b,g.memoizedState=null,b}function rj(d,g){return g=qj({mode:"visible",children:g},d.mode,0,null),g.return=d,d.child=g}function tj(d,g,$,b){return b!==null&&Jg(b),Bh(g,d.child,null,$),d=rj(g,g.pendingProps.children),d.flags|=2,g.memoizedState=null,d}function sj(d,g,$,b,j,_e,et){if($)return g.flags&256?(g.flags&=-257,b=Li(Error(p$1(422))),tj(d,g,et,b)):g.memoizedState!==null?(g.child=d.child,g.flags|=128,null):(_e=b.fallback,j=g.mode,b=qj({mode:"visible",children:b.children},j,0,null),_e=Ah(_e,j,et,null),_e.flags|=2,b.return=g,_e.return=g,b.sibling=_e,g.child=b,g.mode&1&&Bh(g,d.child,null,et),g.child.memoizedState=oj(et),g.memoizedState=nj,_e);if(!(g.mode&1))return tj(d,g,et,null);if(j.data==="$!"){if(b=j.nextSibling&&j.nextSibling.dataset,b)var tt=b.dgst;return b=tt,_e=Error(p$1(419)),b=Li(_e,b,void 0),tj(d,g,et,b)}if(tt=(et&d.childLanes)!==0,Ug||tt){if(b=R,b!==null){switch(et&-et){case 4:j=2;break;case 16:j=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:j=32;break;case 536870912:j=268435456;break;default:j=0}j=j&(b.suspendedLanes|et)?0:j,j!==0&&j!==_e.retryLane&&(_e.retryLane=j,Zg(d,j),mh(b,d,j,-1))}return uj(),b=Li(Error(p$1(421))),tj(d,g,et,b)}return j.data==="$?"?(g.flags|=128,g.child=d.child,g=vj.bind(null,d),j._reactRetry=g,null):(d=_e.treeContext,yg=Lf(j.nextSibling),xg=g,I=!0,zg=null,d!==null&&(og[pg++]=rg,og[pg++]=sg,og[pg++]=qg,rg=d.id,sg=d.overflow,qg=g),g=rj(g,b.children),g.flags|=4096,g)}function wj(d,g,$){d.lanes|=g;var b=d.alternate;b!==null&&(b.lanes|=g),Sg(d.return,g,$)}function xj(d,g,$,b,j){var _e=d.memoizedState;_e===null?d.memoizedState={isBackwards:g,rendering:null,renderingStartTime:0,last:b,tail:$,tailMode:j}:(_e.isBackwards=g,_e.rendering=null,_e.renderingStartTime=0,_e.last=b,_e.tail=$,_e.tailMode=j)}function yj(d,g,$){var b=g.pendingProps,j=b.revealOrder,_e=b.tail;if(Yi(d,g,b.children,$),b=M.current,b&2)b=b&1|2,g.flags|=128;else{if(d!==null&&d.flags&128)e:for(d=g.child;d!==null;){if(d.tag===13)d.memoizedState!==null&&wj(d,$,g);else if(d.tag===19)wj(d,$,g);else if(d.child!==null){d.child.return=d,d=d.child;continue}if(d===g)break e;for(;d.sibling===null;){if(d.return===null||d.return===g)break e;d=d.return}d.sibling.return=d.return,d=d.sibling}b&=1}if(G(M,b),!(g.mode&1))g.memoizedState=null;else switch(j){case"forwards":for($=g.child,j=null;$!==null;)d=$.alternate,d!==null&&Mh(d)===null&&(j=$),$=$.sibling;$=j,$===null?(j=g.child,g.child=null):(j=$.sibling,$.sibling=null),xj(g,!1,j,$,_e);break;case"backwards":for($=null,j=g.child,g.child=null;j!==null;){if(d=j.alternate,d!==null&&Mh(d)===null){g.child=j;break}d=j.sibling,j.sibling=$,$=j,j=d}xj(g,!0,$,null,_e);break;case"together":xj(g,!1,null,null,void 0);break;default:g.memoizedState=null}return g.child}function jj(d,g){!(g.mode&1)&&d!==null&&(d.alternate=null,g.alternate=null,g.flags|=2)}function $i(d,g,$){if(d!==null&&(g.dependencies=d.dependencies),hh|=g.lanes,!($&g.childLanes))return null;if(d!==null&&g.child!==d.child)throw Error(p$1(153));if(g.child!==null){for(d=g.child,$=wh(d,d.pendingProps),g.child=$,$.return=g;d.sibling!==null;)d=d.sibling,$=$.sibling=wh(d,d.pendingProps),$.return=g;$.sibling=null}return g.child}function zj(d,g,$){switch(g.tag){case 3:lj(g),Ig();break;case 5:Kh(g);break;case 1:Zf(g.type)&&cg(g);break;case 4:Ih(g,g.stateNode.containerInfo);break;case 10:var b=g.type._context,j=g.memoizedProps.value;G(Mg,b._currentValue),b._currentValue=j;break;case 13:if(b=g.memoizedState,b!==null)return b.dehydrated!==null?(G(M,M.current&1),g.flags|=128,null):$&g.child.childLanes?pj(d,g,$):(G(M,M.current&1),d=$i(d,g,$),d!==null?d.sibling:null);G(M,M.current&1);break;case 19:if(b=($&g.childLanes)!==0,d.flags&128){if(b)return yj(d,g,$);g.flags|=128}if(j=g.memoizedState,j!==null&&(j.rendering=null,j.tail=null,j.lastEffect=null),G(M,M.current),b)break;return null;case 22:case 23:return g.lanes=0,ej(d,g,$)}return $i(d,g,$)}var Aj,Bj,Cj,Dj;Aj=function(d,g){for(var $=g.child;$!==null;){if($.tag===5||$.tag===6)d.appendChild($.stateNode);else if($.tag!==4&&$.child!==null){$.child.return=$,$=$.child;continue}if($===g)break;for(;$.sibling===null;){if($.return===null||$.return===g)return;$=$.return}$.sibling.return=$.return,$=$.sibling}};Bj=function(){};Cj=function(d,g,$,b){var j=d.memoizedProps;if(j!==b){d=g.stateNode,Hh(Eh.current);var _e=null;switch($){case"input":j=Ya(d,j),b=Ya(d,b),_e=[];break;case"select":j=A({},j,{value:void 0}),b=A({},b,{value:void 0}),_e=[];break;case"textarea":j=gb(d,j),b=gb(d,b),_e=[];break;default:typeof j.onClick!="function"&&typeof b.onClick=="function"&&(d.onclick=Bf)}ub($,b);var et;$=null;for(rt in j)if(!b.hasOwnProperty(rt)&&j.hasOwnProperty(rt)&&j[rt]!=null)if(rt==="style"){var tt=j[rt];for(et in tt)tt.hasOwnProperty(et)&&($||($={}),$[et]="")}else rt!=="dangerouslySetInnerHTML"&&rt!=="children"&&rt!=="suppressContentEditableWarning"&&rt!=="suppressHydrationWarning"&&rt!=="autoFocus"&&(ea.hasOwnProperty(rt)?_e||(_e=[]):(_e=_e||[]).push(rt,null));for(rt in b){var nt=b[rt];if(tt=j!=null?j[rt]:void 0,b.hasOwnProperty(rt)&&nt!==tt&&(nt!=null||tt!=null))if(rt==="style")if(tt){for(et in tt)!tt.hasOwnProperty(et)||nt&&nt.hasOwnProperty(et)||($||($={}),$[et]="");for(et in nt)nt.hasOwnProperty(et)&&tt[et]!==nt[et]&&($||($={}),$[et]=nt[et])}else $||(_e||(_e=[]),_e.push(rt,$)),$=nt;else rt==="dangerouslySetInnerHTML"?(nt=nt?nt.__html:void 0,tt=tt?tt.__html:void 0,nt!=null&&tt!==nt&&(_e=_e||[]).push(rt,nt)):rt==="children"?typeof nt!="string"&&typeof nt!="number"||(_e=_e||[]).push(rt,""+nt):rt!=="suppressContentEditableWarning"&&rt!=="suppressHydrationWarning"&&(ea.hasOwnProperty(rt)?(nt!=null&&rt==="onScroll"&&D("scroll",d),_e||tt===nt||(_e=[])):(_e=_e||[]).push(rt,nt))}$&&(_e=_e||[]).push("style",$);var rt=_e;(g.updateQueue=rt)&&(g.flags|=4)}};Dj=function(d,g,$,b){$!==b&&(g.flags|=4)};function Ej(d,g){if(!I)switch(d.tailMode){case"hidden":g=d.tail;for(var $=null;g!==null;)g.alternate!==null&&($=g),g=g.sibling;$===null?d.tail=null:$.sibling=null;break;case"collapsed":$=d.tail;for(var b=null;$!==null;)$.alternate!==null&&(b=$),$=$.sibling;b===null?g||d.tail===null?d.tail=null:d.tail.sibling=null:b.sibling=null}}function S(d){var g=d.alternate!==null&&d.alternate.child===d.child,$=0,b=0;if(g)for(var j=d.child;j!==null;)$|=j.lanes|j.childLanes,b|=j.subtreeFlags&14680064,b|=j.flags&14680064,j.return=d,j=j.sibling;else for(j=d.child;j!==null;)$|=j.lanes|j.childLanes,b|=j.subtreeFlags,b|=j.flags,j.return=d,j=j.sibling;return d.subtreeFlags|=b,d.childLanes=$,g}function Fj(d,g,$){var b=g.pendingProps;switch(wg(g),g.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return S(g),null;case 1:return Zf(g.type)&&$f(),S(g),null;case 3:return b=g.stateNode,Jh(),E(Wf),E(H),Oh(),b.pendingContext&&(b.context=b.pendingContext,b.pendingContext=null),(d===null||d.child===null)&&(Gg(g)?g.flags|=4:d===null||d.memoizedState.isDehydrated&&!(g.flags&256)||(g.flags|=1024,zg!==null&&(Gj(zg),zg=null))),Bj(d,g),S(g),null;case 5:Lh(g);var j=Hh(Gh.current);if($=g.type,d!==null&&g.stateNode!=null)Cj(d,g,$,b,j),d.ref!==g.ref&&(g.flags|=512,g.flags|=2097152);else{if(!b){if(g.stateNode===null)throw Error(p$1(166));return S(g),null}if(d=Hh(Eh.current),Gg(g)){b=g.stateNode,$=g.type;var _e=g.memoizedProps;switch(b[Of]=g,b[Pf]=_e,d=(g.mode&1)!==0,$){case"dialog":D("cancel",b),D("close",b);break;case"iframe":case"object":case"embed":D("load",b);break;case"video":case"audio":for(j=0;j<\/script>",d=d.removeChild(d.firstChild)):typeof b.is=="string"?d=et.createElement($,{is:b.is}):(d=et.createElement($),$==="select"&&(et=d,b.multiple?et.multiple=!0:b.size&&(et.size=b.size))):d=et.createElementNS(d,$),d[Of]=g,d[Pf]=b,Aj(d,g,!1,!1),g.stateNode=d;e:{switch(et=vb($,b),$){case"dialog":D("cancel",d),D("close",d),j=b;break;case"iframe":case"object":case"embed":D("load",d),j=b;break;case"video":case"audio":for(j=0;jHj&&(g.flags|=128,b=!0,Ej(_e,!1),g.lanes=4194304)}else{if(!b)if(d=Mh(et),d!==null){if(g.flags|=128,b=!0,$=d.updateQueue,$!==null&&(g.updateQueue=$,g.flags|=4),Ej(_e,!0),_e.tail===null&&_e.tailMode==="hidden"&&!et.alternate&&!I)return S(g),null}else 2*B()-_e.renderingStartTime>Hj&&$!==1073741824&&(g.flags|=128,b=!0,Ej(_e,!1),g.lanes=4194304);_e.isBackwards?(et.sibling=g.child,g.child=et):($=_e.last,$!==null?$.sibling=et:g.child=et,_e.last=et)}return _e.tail!==null?(g=_e.tail,_e.rendering=g,_e.tail=g.sibling,_e.renderingStartTime=B(),g.sibling=null,$=M.current,G(M,b?$&1|2:$&1),g):(S(g),null);case 22:case 23:return Ij(),b=g.memoizedState!==null,d!==null&&d.memoizedState!==null!==b&&(g.flags|=8192),b&&g.mode&1?gj&1073741824&&(S(g),g.subtreeFlags&6&&(g.flags|=8192)):S(g),null;case 24:return null;case 25:return null}throw Error(p$1(156,g.tag))}function Jj(d,g){switch(wg(g),g.tag){case 1:return Zf(g.type)&&$f(),d=g.flags,d&65536?(g.flags=d&-65537|128,g):null;case 3:return Jh(),E(Wf),E(H),Oh(),d=g.flags,d&65536&&!(d&128)?(g.flags=d&-65537|128,g):null;case 5:return Lh(g),null;case 13:if(E(M),d=g.memoizedState,d!==null&&d.dehydrated!==null){if(g.alternate===null)throw Error(p$1(340));Ig()}return d=g.flags,d&65536?(g.flags=d&-65537|128,g):null;case 19:return E(M),null;case 4:return Jh(),null;case 10:return Rg(g.type._context),null;case 22:case 23:return Ij(),null;case 24:return null;default:return null}}var Kj=!1,U=!1,Lj=typeof WeakSet=="function"?WeakSet:Set,V=null;function Mj(d,g){var $=d.ref;if($!==null)if(typeof $=="function")try{$(null)}catch(b){W(d,g,b)}else $.current=null}function Nj(d,g,$){try{$()}catch(b){W(d,g,b)}}var Oj=!1;function Pj(d,g){if(Cf=dd,d=Me(),Ne(d)){if("selectionStart"in d)var $={start:d.selectionStart,end:d.selectionEnd};else e:{$=($=d.ownerDocument)&&$.defaultView||window;var b=$.getSelection&&$.getSelection();if(b&&b.rangeCount!==0){$=b.anchorNode;var j=b.anchorOffset,_e=b.focusNode;b=b.focusOffset;try{$.nodeType,_e.nodeType}catch{$=null;break e}var et=0,tt=-1,nt=-1,rt=0,it=0,st=d,ut=null;t:for(;;){for(var at;st!==$||j!==0&&st.nodeType!==3||(tt=et+j),st!==_e||b!==0&&st.nodeType!==3||(nt=et+b),st.nodeType===3&&(et+=st.nodeValue.length),(at=st.firstChild)!==null;)ut=st,st=at;for(;;){if(st===d)break t;if(ut===$&&++rt===j&&(tt=et),ut===_e&&++it===b&&(nt=et),(at=st.nextSibling)!==null)break;st=ut,ut=st.parentNode}st=at}$=tt===-1||nt===-1?null:{start:tt,end:nt}}else $=null}$=$||{start:0,end:0}}else $=null;for(Df={focusedElem:d,selectionRange:$},dd=!1,V=g;V!==null;)if(g=V,d=g.child,(g.subtreeFlags&1028)!==0&&d!==null)d.return=g,V=d;else for(;V!==null;){g=V;try{var ht=g.alternate;if(g.flags&1024)switch(g.tag){case 0:case 11:case 15:break;case 1:if(ht!==null){var ct=ht.memoizedProps,vt=ht.memoizedState,ft=g.stateNode,gt=ft.getSnapshotBeforeUpdate(g.elementType===g.type?ct:Lg(g.type,ct),vt);ft.__reactInternalSnapshotBeforeUpdate=gt}break;case 3:var pt=g.stateNode.containerInfo;pt.nodeType===1?pt.textContent="":pt.nodeType===9&&pt.documentElement&&pt.removeChild(pt.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(p$1(163))}}catch(yt){W(g,g.return,yt)}if(d=g.sibling,d!==null){d.return=g.return,V=d;break}V=g.return}return ht=Oj,Oj=!1,ht}function Qj(d,g,$){var b=g.updateQueue;if(b=b!==null?b.lastEffect:null,b!==null){var j=b=b.next;do{if((j.tag&d)===d){var _e=j.destroy;j.destroy=void 0,_e!==void 0&&Nj(g,$,_e)}j=j.next}while(j!==b)}}function Rj(d,g){if(g=g.updateQueue,g=g!==null?g.lastEffect:null,g!==null){var $=g=g.next;do{if(($.tag&d)===d){var b=$.create;$.destroy=b()}$=$.next}while($!==g)}}function Sj(d){var g=d.ref;if(g!==null){var $=d.stateNode;switch(d.tag){case 5:d=$;break;default:d=$}typeof g=="function"?g(d):g.current=d}}function Tj(d){var g=d.alternate;g!==null&&(d.alternate=null,Tj(g)),d.child=null,d.deletions=null,d.sibling=null,d.tag===5&&(g=d.stateNode,g!==null&&(delete g[Of],delete g[Pf],delete g[of],delete g[Qf],delete g[Rf])),d.stateNode=null,d.return=null,d.dependencies=null,d.memoizedProps=null,d.memoizedState=null,d.pendingProps=null,d.stateNode=null,d.updateQueue=null}function Uj(d){return d.tag===5||d.tag===3||d.tag===4}function Vj(d){e:for(;;){for(;d.sibling===null;){if(d.return===null||Uj(d.return))return null;d=d.return}for(d.sibling.return=d.return,d=d.sibling;d.tag!==5&&d.tag!==6&&d.tag!==18;){if(d.flags&2||d.child===null||d.tag===4)continue e;d.child.return=d,d=d.child}if(!(d.flags&2))return d.stateNode}}function Wj(d,g,$){var b=d.tag;if(b===5||b===6)d=d.stateNode,g?$.nodeType===8?$.parentNode.insertBefore(d,g):$.insertBefore(d,g):($.nodeType===8?(g=$.parentNode,g.insertBefore(d,$)):(g=$,g.appendChild(d)),$=$._reactRootContainer,$!=null||g.onclick!==null||(g.onclick=Bf));else if(b!==4&&(d=d.child,d!==null))for(Wj(d,g,$),d=d.sibling;d!==null;)Wj(d,g,$),d=d.sibling}function Xj(d,g,$){var b=d.tag;if(b===5||b===6)d=d.stateNode,g?$.insertBefore(d,g):$.appendChild(d);else if(b!==4&&(d=d.child,d!==null))for(Xj(d,g,$),d=d.sibling;d!==null;)Xj(d,g,$),d=d.sibling}var X=null,Yj=!1;function Zj(d,g,$){for($=$.child;$!==null;)ak(d,g,$),$=$.sibling}function ak(d,g,$){if(lc&&typeof lc.onCommitFiberUnmount=="function")try{lc.onCommitFiberUnmount(kc,$)}catch{}switch($.tag){case 5:U||Mj($,g);case 6:var b=X,j=Yj;X=null,Zj(d,g,$),X=b,Yj=j,X!==null&&(Yj?(d=X,$=$.stateNode,d.nodeType===8?d.parentNode.removeChild($):d.removeChild($)):X.removeChild($.stateNode));break;case 18:X!==null&&(Yj?(d=X,$=$.stateNode,d.nodeType===8?Kf(d.parentNode,$):d.nodeType===1&&Kf(d,$),bd(d)):Kf(X,$.stateNode));break;case 4:b=X,j=Yj,X=$.stateNode.containerInfo,Yj=!0,Zj(d,g,$),X=b,Yj=j;break;case 0:case 11:case 14:case 15:if(!U&&(b=$.updateQueue,b!==null&&(b=b.lastEffect,b!==null))){j=b=b.next;do{var _e=j,et=_e.destroy;_e=_e.tag,et!==void 0&&(_e&2||_e&4)&&Nj($,g,et),j=j.next}while(j!==b)}Zj(d,g,$);break;case 1:if(!U&&(Mj($,g),b=$.stateNode,typeof b.componentWillUnmount=="function"))try{b.props=$.memoizedProps,b.state=$.memoizedState,b.componentWillUnmount()}catch(tt){W($,g,tt)}Zj(d,g,$);break;case 21:Zj(d,g,$);break;case 22:$.mode&1?(U=(b=U)||$.memoizedState!==null,Zj(d,g,$),U=b):Zj(d,g,$);break;default:Zj(d,g,$)}}function bk(d){var g=d.updateQueue;if(g!==null){d.updateQueue=null;var $=d.stateNode;$===null&&($=d.stateNode=new Lj),g.forEach(function(b){var j=ck.bind(null,d,b);$.has(b)||($.add(b),b.then(j,j))})}}function dk(d,g){var $=g.deletions;if($!==null)for(var b=0;b<$.length;b++){var j=$[b];try{var _e=d,et=g,tt=et;e:for(;tt!==null;){switch(tt.tag){case 5:X=tt.stateNode,Yj=!1;break e;case 3:X=tt.stateNode.containerInfo,Yj=!0;break e;case 4:X=tt.stateNode.containerInfo,Yj=!0;break e}tt=tt.return}if(X===null)throw Error(p$1(160));ak(_e,et,j),X=null,Yj=!1;var nt=j.alternate;nt!==null&&(nt.return=null),j.return=null}catch(rt){W(j,g,rt)}}if(g.subtreeFlags&12854)for(g=g.child;g!==null;)ek(g,d),g=g.sibling}function ek(d,g){var $=d.alternate,b=d.flags;switch(d.tag){case 0:case 11:case 14:case 15:if(dk(g,d),fk(d),b&4){try{Qj(3,d,d.return),Rj(3,d)}catch(ct){W(d,d.return,ct)}try{Qj(5,d,d.return)}catch(ct){W(d,d.return,ct)}}break;case 1:dk(g,d),fk(d),b&512&&$!==null&&Mj($,$.return);break;case 5:if(dk(g,d),fk(d),b&512&&$!==null&&Mj($,$.return),d.flags&32){var j=d.stateNode;try{ob(j,"")}catch(ct){W(d,d.return,ct)}}if(b&4&&(j=d.stateNode,j!=null)){var _e=d.memoizedProps,et=$!==null?$.memoizedProps:_e,tt=d.type,nt=d.updateQueue;if(d.updateQueue=null,nt!==null)try{tt==="input"&&_e.type==="radio"&&_e.name!=null&&ab(j,_e),vb(tt,et);var rt=vb(tt,_e);for(et=0;etj&&(j=et),b&=~_e}if(b=j,b=B()-b,b=(120>b?120:480>b?480:1080>b?1080:1920>b?1920:3e3>b?3e3:4320>b?4320:1960*mk(b/1960))-b,10d?16:d,xk===null)var b=!1;else{if(d=xk,xk=null,yk=0,K&6)throw Error(p$1(331));var j=K;for(K|=4,V=d.current;V!==null;){var _e=V,et=_e.child;if(V.flags&16){var tt=_e.deletions;if(tt!==null){for(var nt=0;ntB()-gk?Lk(d,0):sk|=$),Ek(d,g)}function Zk(d,g){g===0&&(d.mode&1?(g=sc,sc<<=1,!(sc&130023424)&&(sc=4194304)):g=1);var $=L();d=Zg(d,g),d!==null&&(Ac(d,g,$),Ek(d,$))}function vj(d){var g=d.memoizedState,$=0;g!==null&&($=g.retryLane),Zk(d,$)}function ck(d,g){var $=0;switch(d.tag){case 13:var b=d.stateNode,j=d.memoizedState;j!==null&&($=j.retryLane);break;case 19:b=d.stateNode;break;default:throw Error(p$1(314))}b!==null&&b.delete(g),Zk(d,$)}var Wk;Wk=function(d,g,$){if(d!==null)if(d.memoizedProps!==g.pendingProps||Wf.current)Ug=!0;else{if(!(d.lanes&$)&&!(g.flags&128))return Ug=!1,zj(d,g,$);Ug=!!(d.flags&131072)}else Ug=!1,I&&g.flags&1048576&&ug(g,ng,g.index);switch(g.lanes=0,g.tag){case 2:var b=g.type;jj(d,g),d=g.pendingProps;var j=Yf(g,H.current);Tg(g,$),j=Xh(null,g,b,d,j,$);var _e=bi();return g.flags|=1,typeof j=="object"&&j!==null&&typeof j.render=="function"&&j.$$typeof===void 0?(g.tag=1,g.memoizedState=null,g.updateQueue=null,Zf(b)?(_e=!0,cg(g)):_e=!1,g.memoizedState=j.state!==null&&j.state!==void 0?j.state:null,ah(g),j.updater=nh,g.stateNode=j,j._reactInternals=g,rh(g,b,d,$),g=kj(null,g,b,!0,_e,$)):(g.tag=0,I&&_e&&vg(g),Yi(null,g,j,$),g=g.child),g;case 16:b=g.elementType;e:{switch(jj(d,g),d=g.pendingProps,j=b._init,b=j(b._payload),g.type=b,j=g.tag=$k(b),d=Lg(b,d),j){case 0:g=dj(null,g,b,d,$);break e;case 1:g=ij(null,g,b,d,$);break e;case 11:g=Zi(null,g,b,d,$);break e;case 14:g=aj(null,g,b,Lg(b.type,d),$);break e}throw Error(p$1(306,b,""))}return g;case 0:return b=g.type,j=g.pendingProps,j=g.elementType===b?j:Lg(b,j),dj(d,g,b,j,$);case 1:return b=g.type,j=g.pendingProps,j=g.elementType===b?j:Lg(b,j),ij(d,g,b,j,$);case 3:e:{if(lj(g),d===null)throw Error(p$1(387));b=g.pendingProps,_e=g.memoizedState,j=_e.element,bh(d,g),gh(g,b,null,$);var et=g.memoizedState;if(b=et.element,_e.isDehydrated)if(_e={element:b,isDehydrated:!1,cache:et.cache,pendingSuspenseBoundaries:et.pendingSuspenseBoundaries,transitions:et.transitions},g.updateQueue.baseState=_e,g.memoizedState=_e,g.flags&256){j=Ki(Error(p$1(423)),g),g=mj(d,g,b,$,j);break e}else if(b!==j){j=Ki(Error(p$1(424)),g),g=mj(d,g,b,$,j);break e}else for(yg=Lf(g.stateNode.containerInfo.firstChild),xg=g,I=!0,zg=null,$=Ch(g,null,b,$),g.child=$;$;)$.flags=$.flags&-3|4096,$=$.sibling;else{if(Ig(),b===j){g=$i(d,g,$);break e}Yi(d,g,b,$)}g=g.child}return g;case 5:return Kh(g),d===null&&Eg(g),b=g.type,j=g.pendingProps,_e=d!==null?d.memoizedProps:null,et=j.children,Ef(b,j)?et=null:_e!==null&&Ef(b,_e)&&(g.flags|=32),hj(d,g),Yi(d,g,et,$),g.child;case 6:return d===null&&Eg(g),null;case 13:return pj(d,g,$);case 4:return Ih(g,g.stateNode.containerInfo),b=g.pendingProps,d===null?g.child=Bh(g,null,b,$):Yi(d,g,b,$),g.child;case 11:return b=g.type,j=g.pendingProps,j=g.elementType===b?j:Lg(b,j),Zi(d,g,b,j,$);case 7:return Yi(d,g,g.pendingProps,$),g.child;case 8:return Yi(d,g,g.pendingProps.children,$),g.child;case 12:return Yi(d,g,g.pendingProps.children,$),g.child;case 10:e:{if(b=g.type._context,j=g.pendingProps,_e=g.memoizedProps,et=j.value,G(Mg,b._currentValue),b._currentValue=et,_e!==null)if(He(_e.value,et)){if(_e.children===j.children&&!Wf.current){g=$i(d,g,$);break e}}else for(_e=g.child,_e!==null&&(_e.return=g);_e!==null;){var tt=_e.dependencies;if(tt!==null){et=_e.child;for(var nt=tt.firstContext;nt!==null;){if(nt.context===b){if(_e.tag===1){nt=ch(-1,$&-$),nt.tag=2;var rt=_e.updateQueue;if(rt!==null){rt=rt.shared;var it=rt.pending;it===null?nt.next=nt:(nt.next=it.next,it.next=nt),rt.pending=nt}}_e.lanes|=$,nt=_e.alternate,nt!==null&&(nt.lanes|=$),Sg(_e.return,$,g),tt.lanes|=$;break}nt=nt.next}}else if(_e.tag===10)et=_e.type===g.type?null:_e.child;else if(_e.tag===18){if(et=_e.return,et===null)throw Error(p$1(341));et.lanes|=$,tt=et.alternate,tt!==null&&(tt.lanes|=$),Sg(et,$,g),et=_e.sibling}else et=_e.child;if(et!==null)et.return=_e;else for(et=_e;et!==null;){if(et===g){et=null;break}if(_e=et.sibling,_e!==null){_e.return=et.return,et=_e;break}et=et.return}_e=et}Yi(d,g,j.children,$),g=g.child}return g;case 9:return j=g.type,b=g.pendingProps.children,Tg(g,$),j=Vg(j),b=b(j),g.flags|=1,Yi(d,g,b,$),g.child;case 14:return b=g.type,j=Lg(b,g.pendingProps),j=Lg(b.type,j),aj(d,g,b,j,$);case 15:return cj(d,g,g.type,g.pendingProps,$);case 17:return b=g.type,j=g.pendingProps,j=g.elementType===b?j:Lg(b,j),jj(d,g),g.tag=1,Zf(b)?(d=!0,cg(g)):d=!1,Tg(g,$),ph(g,b,j),rh(g,b,j,$),kj(null,g,b,!0,d,$);case 19:return yj(d,g,$);case 22:return ej(d,g,$)}throw Error(p$1(156,g.tag))};function Gk(d,g){return ac(d,g)}function al(d,g,$,b){this.tag=d,this.key=$,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=g,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=b,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Bg(d,g,$,b){return new al(d,g,$,b)}function bj(d){return d=d.prototype,!(!d||!d.isReactComponent)}function $k(d){if(typeof d=="function")return bj(d)?1:0;if(d!=null){if(d=d.$$typeof,d===Da)return 11;if(d===Ga)return 14}return 2}function wh(d,g){var $=d.alternate;return $===null?($=Bg(d.tag,g,d.key,d.mode),$.elementType=d.elementType,$.type=d.type,$.stateNode=d.stateNode,$.alternate=d,d.alternate=$):($.pendingProps=g,$.type=d.type,$.flags=0,$.subtreeFlags=0,$.deletions=null),$.flags=d.flags&14680064,$.childLanes=d.childLanes,$.lanes=d.lanes,$.child=d.child,$.memoizedProps=d.memoizedProps,$.memoizedState=d.memoizedState,$.updateQueue=d.updateQueue,g=d.dependencies,$.dependencies=g===null?null:{lanes:g.lanes,firstContext:g.firstContext},$.sibling=d.sibling,$.index=d.index,$.ref=d.ref,$}function yh(d,g,$,b,j,_e){var et=2;if(b=d,typeof d=="function")bj(d)&&(et=1);else if(typeof d=="string")et=5;else e:switch(d){case ya:return Ah($.children,j,_e,g);case za:et=8,j|=8;break;case Aa:return d=Bg(12,$,g,j|2),d.elementType=Aa,d.lanes=_e,d;case Ea:return d=Bg(13,$,g,j),d.elementType=Ea,d.lanes=_e,d;case Fa:return d=Bg(19,$,g,j),d.elementType=Fa,d.lanes=_e,d;case Ia:return qj($,j,_e,g);default:if(typeof d=="object"&&d!==null)switch(d.$$typeof){case Ba:et=10;break e;case Ca:et=9;break e;case Da:et=11;break e;case Ga:et=14;break e;case Ha:et=16,b=null;break e}throw Error(p$1(130,d==null?d:typeof d,""))}return g=Bg(et,$,g,j),g.elementType=d,g.type=b,g.lanes=_e,g}function Ah(d,g,$,b){return d=Bg(7,d,b,g),d.lanes=$,d}function qj(d,g,$,b){return d=Bg(22,d,b,g),d.elementType=Ia,d.lanes=$,d.stateNode={isHidden:!1},d}function xh(d,g,$){return d=Bg(6,d,null,g),d.lanes=$,d}function zh(d,g,$){return g=Bg(4,d.children!==null?d.children:[],d.key,g),g.lanes=$,g.stateNode={containerInfo:d.containerInfo,pendingChildren:null,implementation:d.implementation},g}function bl(d,g,$,b,j){this.tag=g,this.containerInfo=d,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=zc(0),this.expirationTimes=zc(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=zc(0),this.identifierPrefix=b,this.onRecoverableError=j,this.mutableSourceEagerHydrationData=null}function cl(d,g,$,b,j,_e,et,tt,nt){return d=new bl(d,g,$,tt,nt),g===1?(g=1,_e===!0&&(g|=8)):g=0,_e=Bg(3,null,null,g),d.current=_e,_e.stateNode=d,_e.memoizedState={element:b,isDehydrated:$,cache:null,transitions:null,pendingSuspenseBoundaries:null},ah(_e),d}function dl(d,g,$){var b=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(g)}catch($){console.error($)}}g(),d.exports=reactDom_production_min})(reactDom);var m$2=reactDomExports;client.createRoot=m$2.createRoot,client.hydrateRoot=m$2.hydrateRoot;const App$1="",navLinkClass=({isActive:d,isPending:g})=>d?"active":g?"pending":"";function App(){return jsxRuntimeExports.jsxs("div",{className:"App",children:[jsxRuntimeExports.jsxs("div",{className:"flex-row nav",children:[jsxRuntimeExports.jsx("div",{className:"nav-item",children:jsxRuntimeExports.jsx(NavLink,{className:navLinkClass,to:"draw/evaporating-cloud",children:"Evaporating Cloud"})}),"| ",jsxRuntimeExports.jsx("div",{className:"nav-item",children:jsxRuntimeExports.jsx(NavLink,{className:navLinkClass,to:"draw/goal-tree",children:"Goal Tree"})}),"| ",jsxRuntimeExports.jsx("div",{className:"nav-item",children:jsxRuntimeExports.jsx(NavLink,{className:navLinkClass,to:"draw/problem-tree",children:"Problem Tree"})}),"| ",jsxRuntimeExports.jsx("div",{className:"nav-item",children:jsxRuntimeExports.jsx(NavLink,{className:navLinkClass,to:"about",children:"About"})})]}),jsxRuntimeExports.jsx(Outlet,{})]})}const index$1="";function ErrorPage(){const d=useRouteError();return console.error(d),jsxRuntimeExports.jsxs("div",{id:"error-page",children:[jsxRuntimeExports.jsx("h1",{children:"Oops!"}),jsxRuntimeExports.jsx("p",{children:"Sorry, an unexpected error has occurred."}),jsxRuntimeExports.jsx("p",{children:jsxRuntimeExports.jsx("i",{children:d.statusText||d.message})})]})}const Editor=({onChange:d,placeholder:g="",rows:$=20,disabled:b=!1,autoFocus:j=!1,text:_e,setText:et,error:tt})=>{React.useEffect(()=>{d(_e)},[_e]);const nt=rt=>{et(rt.target.value),d(rt.target.value)};return jsxRuntimeExports.jsxs("div",{className:"editor",children:[jsxRuntimeExports.jsx("textarea",{style:{width:"100%",height:"100%",resize:"none"},rows:$,value:_e,onChange:nt,placeholder:g,disabled:b,autoFocus:j}),jsxRuntimeExports.jsx("p",{className:`edit-result ${tt?"error":""}`,children:tt})]})},wrapLines=(d,g)=>{const $=d.split(" "),b=[];let j="";return $.forEach((_e,et)=>{j.length+_e.length>g&&(b.push(j),j=""),j+=_e+" ",et===$.length-1&&b.push(j)}),b};function computeResizeTransform(d,g,$,b){const j=d.getBBox({stroke:!0,fill:!0,markers:!0}),_e=j.width+$,et=j.height+b;console.log("bounding h w: ",et,_e);const tt=g.clientWidth,nt=g.clientHeight;console.log("container h w: ",nt,tt);const rt=Math.min(100/_e,100/et);return console.log("zoomScale: ",rt),`scale(${rt},${rt})`}function saveSvgUrl(d){const g=d.outerHTML,$=`\r -`,b=new Blob([$,g],{type:"image/svg+xml;charset=utf-8"});return URL.createObjectURL(b)}const intermediatePoint=(d,g,$)=>{const b=g.x-d.x,j=g.y-d.y,_e=Math.sqrt(b*b+j*j),et=$/_e;return{x:d.x+b*et,y:d.y+j*et}};function midPoint(d,g){return{x:(d.x+g.x)/2,y:(d.y+g.y)/2}}const Injection=({text:d,edge:g,dx:$,dy:b})=>{if(!d)return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{});const j=wrapLines(d,35),_e=midPoint(g.start,g.end),et=16,tt=_e.x+$,nt=tt-75,rt=_e.y+b,it=b/Math.abs(b),st=rt+j.length*et+7,at=it===1?rt:st,ht=tt;return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("text",{x:nt,y:rt,children:j.map((ct,vt)=>jsxRuntimeExports.jsx("tspan",{x:nt,dy:et,children:ct},vt))}),jsxRuntimeExports.jsx("line",{x1:ht,y1:at,x2:_e.x,y2:_e.y,stroke:"#000",strokeDasharray:"4 5",strokeWidth:"2"})]})},CloudEdge=({edge:d})=>jsxRuntimeExports.jsx("line",{x1:d.adjStart.x,y1:d.adjStart.y,x2:d.end.x,y2:d.end.y,stroke:"#000",strokeWidth:"3",markerStart:"url(#startarrow)"}),CloudNode=({text:d,x:g,y:$,width:b,height:j,annotation:_e})=>{const et=wrapLines(d,20),tt=16,nt=12,rt=et.length*tt,it=$+j/2-rt/2-4,st=g+nt;return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("rect",{x:g,y:$,rx:"10",ry:"10",width:b,height:j}),jsxRuntimeExports.jsx("text",{x:st,y:it,children:et.map((ut,at)=>jsxRuntimeExports.jsx("tspan",{x:st,dy:tt,children:ut},at))}),jsxRuntimeExports.jsx("circle",{cx:g,cy:$,r:"10",style:{fill:"white",stroke:"black",strokeWidth:"2px"}}),jsxRuntimeExports.jsx("text",{x:g-4,y:$+4,children:_e})]})},drawCloud=d=>{const g={A:"",B:"",C:"",D:"","D'":""},$=new Map;d.statements.filter(_t=>_t.type==="node").forEach(_t=>{g[_t.id]=_t.text}),d.statements.forEach(_t=>{if(_t.type==="edge"){const Tt=_t.fromIds[0],kt=_t.toId,Mt=Tt`${_t.x},${_t.y}`).join(" "),Ct=` - svg { - font-family: "trebuchet ms", verdana, arial, sans-serif; - font-size: 13px; - } - svg text { - fill: black; - } - svg text.annotation { - font-weight: bold; - } - svg rect { - fill: white; - stroke: black; - stroke-width: 2; - } - `;return jsxRuntimeExports.jsxs("svg",{id:"cloudSvg",width:"100%",height:"100%",version:"1.1",preserveAspectRatio:"xMinYMin",viewBox:"0 0 100 100",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntimeExports.jsx("style",{children:Ct}),jsxRuntimeExports.jsxs("g",{id:"cloudSvgInner",children:[jsxRuntimeExports.jsxs("defs",{children:[jsxRuntimeExports.jsx("marker",{id:"arrowhead",markerWidth:"10",markerHeight:"7",refX:"0",refY:"1.75",orient:"auto",children:jsxRuntimeExports.jsx("polygon",{points:"0 0, 10 3.5, 0 7",transform:"scale(0.5 0.5)"})}),jsxRuntimeExports.jsx("marker",{id:"startarrow",markerWidth:"10",markerHeight:"7",refX:"5",refY:"1.75",orient:"auto",children:jsxRuntimeExports.jsx("polygon",{points:"10 0, 10 7, 0 3.5",fill:"",transform:"scale(0.5 0.5)"})}),jsxRuntimeExports.jsx("marker",{id:"endarrow",markerWidth:"10",markerHeight:"7",refX:"0",refY:"1.75",orient:"auto",markerUnits:"strokeWidth",children:jsxRuntimeExports.jsx("polygon",{points:"0 0, 10 3.5, 0 7",fill:"",transform:"scale(0.5 0.5)"})})]}),jsxRuntimeExports.jsx(CloudNode,{annotation:"A",text:g.A,x:st.x,y:st.y,width:rt,height:it}),jsxRuntimeExports.jsx(CloudNode,{annotation:"B",text:g.B,x:ut.x,y:ut.y,width:rt,height:it}),jsxRuntimeExports.jsx(CloudNode,{annotation:"C",text:g.C,x:at.x,y:at.y,width:rt,height:it}),jsxRuntimeExports.jsx(CloudNode,{annotation:"D",text:g.D,x:ht.x,y:ht.y,width:rt,height:it}),jsxRuntimeExports.jsx(CloudNode,{annotation:"D'",text:g["D'"],x:ct.x,y:ct.y,width:rt,height:it}),jsxRuntimeExports.jsx(CloudEdge,{edge:vt}),jsxRuntimeExports.jsx(CloudEdge,{edge:ft}),jsxRuntimeExports.jsx(CloudEdge,{edge:gt}),jsxRuntimeExports.jsx(CloudEdge,{edge:pt}),jsxRuntimeExports.jsx(Injection,{text:$["A-B"],edge:vt,dx:-100,dy:-125}),jsxRuntimeExports.jsx(Injection,{text:$["A-C"],edge:ft,dx:-100,dy:125}),jsxRuntimeExports.jsx(Injection,{text:$["B-D"],edge:gt,dx:0,dy:-75}),jsxRuntimeExports.jsx(Injection,{text:$["C-D'"],edge:pt,dx:0,dy:75}),jsxRuntimeExports.jsx(Injection,{text:$["D-D'"],edge:Bt,dx:120,dy:20}),jsxRuntimeExports.jsx("polyline",{points:Ot,markerStart:"url(#startarrow)",markerEnd:"url(#endarrow)",style:{fill:"none",stroke:"black",strokeWidth:3}})]})]})};function createEdge(d,g){const $={start:{x:d.x+d.w,y:d.y+d.h/2},adjStart:{x:0,y:0},end:{x:g.x,y:g.y+g.h/2}};return $.adjStart=intermediatePoint($.start,$.end,16),$}function nodeBottomCenterPont(d){return{x:d.x+d.w/2,y:d.y+d.h}}function nodeTopCenterPont(d){return{x:d.x+d.w/2,y:d.y}}function displacePoint(d,g,$){return{x:d.x+g,y:d.y+$}}function Cloud({ast:d,setSvgElem:g}){return d&&React.useEffect(()=>{const $=document.getElementById("cloudSvgInner"),b=document.getElementById("cloudSvgContainer");$==null||$.setAttribute("transform",computeResizeTransform($,b,10,0)+", translate(-10, 0)"),g(document.getElementById("cloudSvg"))},[d]),jsxRuntimeExports.jsxs("div",{id:"cloudSvgContainer",style:{width:"100%",height:"500"},children:[d&&drawCloud(d),";"]})}var noop$2={value:()=>{}};function dispatch(){for(var d=0,g=arguments.length,$={},b;d=0&&(b=$.slice(j+1),$=$.slice(0,j)),$&&!g.hasOwnProperty($))throw new Error("unknown type: "+$);return{type:$,name:b}})}Dispatch.prototype=dispatch.prototype={constructor:Dispatch,on:function(d,g){var $=this._,b=parseTypenames$1(d+"",$),j,_e=-1,et=b.length;if(arguments.length<2){for(;++_e0)for(var $=new Array(j),b=0,j,_e;b=0&&(g=d.slice(0,$))!=="xmlns"&&(d=d.slice($+1)),namespaces.hasOwnProperty(g)?{space:namespaces[g],local:d}:d}function creatorInherit(d){return function(){var g=this.ownerDocument,$=this.namespaceURI;return $===xhtml&&g.documentElement.namespaceURI===xhtml?g.createElement(d):g.createElementNS($,d)}}function creatorFixed(d){return function(){return this.ownerDocument.createElementNS(d.space,d.local)}}function creator(d){var g=namespace(d);return(g.local?creatorFixed:creatorInherit)(g)}function none(){}function selector(d){return d==null?none:function(){return this.querySelector(d)}}function selection_select(d){typeof d!="function"&&(d=selector(d));for(var g=this._groups,$=g.length,b=new Array($),j=0;j<$;++j)for(var _e=g[j],et=_e.length,tt=b[j]=new Array(et),nt,rt,it=0;it=pt&&(pt=gt+1);!(At=vt[pt])&&++pt=0;)(et=b[j])&&(_e&&et.compareDocumentPosition(_e)^4&&_e.parentNode.insertBefore(et,_e),_e=et);return this}function selection_sort(d){d||(d=ascending);function g(st,ut){return st&&ut?d(st.__data__,ut.__data__):!st-!ut}for(var $=this._groups,b=$.length,j=new Array(b),_e=0;_eg?1:d>=g?0:NaN}function selection_call(){var d=arguments[0];return arguments[0]=this,d.apply(null,arguments),this}function selection_nodes(){return Array.from(this)}function selection_node(){for(var d=this._groups,g=0,$=d.length;g<$;++g)for(var b=d[g],j=0,_e=b.length;j<_e;++j){var et=b[j];if(et)return et}return null}function selection_size(){let d=0;for(const g of this)++d;return d}function selection_empty(){return!this.node()}function selection_each(d){for(var g=this._groups,$=0,b=g.length;$1?this.each((g==null?styleRemove$1:typeof g=="function"?styleFunction$1:styleConstant$1)(d,g,$??"")):styleValue(this.node(),d)}function styleValue(d,g){return d.style.getPropertyValue(g)||defaultView(d).getComputedStyle(d,null).getPropertyValue(g)}function propertyRemove(d){return function(){delete this[d]}}function propertyConstant(d,g){return function(){this[d]=g}}function propertyFunction(d,g){return function(){var $=g.apply(this,arguments);$==null?delete this[d]:this[d]=$}}function selection_property(d,g){return arguments.length>1?this.each((g==null?propertyRemove:typeof g=="function"?propertyFunction:propertyConstant)(d,g)):this.node()[d]}function classArray(d){return d.trim().split(/^|\s+/)}function classList(d){return d.classList||new ClassList(d)}function ClassList(d){this._node=d,this._names=classArray(d.getAttribute("class")||"")}ClassList.prototype={add:function(d){var g=this._names.indexOf(d);g<0&&(this._names.push(d),this._node.setAttribute("class",this._names.join(" ")))},remove:function(d){var g=this._names.indexOf(d);g>=0&&(this._names.splice(g,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(d){return this._names.indexOf(d)>=0}};function classedAdd(d,g){for(var $=classList(d),b=-1,j=g.length;++b=0&&($=g.slice(b+1),g=g.slice(0,b)),{type:g,name:$}})}function onRemove(d){return function(){var g=this.__on;if(g){for(var $=0,b=-1,j=g.length,_e;$>8&15|g>>4&240,g>>4&15|g&240,(g&15)<<4|g&15,1):$===8?rgba(g>>24&255,g>>16&255,g>>8&255,(g&255)/255):$===4?rgba(g>>12&15|g>>8&240,g>>8&15|g>>4&240,g>>4&15|g&240,((g&15)<<4|g&15)/255):null):(g=reRgbInteger.exec(d))?new Rgb(g[1],g[2],g[3],1):(g=reRgbPercent.exec(d))?new Rgb(g[1]*255/100,g[2]*255/100,g[3]*255/100,1):(g=reRgbaInteger.exec(d))?rgba(g[1],g[2],g[3],g[4]):(g=reRgbaPercent.exec(d))?rgba(g[1]*255/100,g[2]*255/100,g[3]*255/100,g[4]):(g=reHslPercent.exec(d))?hsla(g[1],g[2]/100,g[3]/100,1):(g=reHslaPercent.exec(d))?hsla(g[1],g[2]/100,g[3]/100,g[4]):named.hasOwnProperty(d)?rgbn(named[d]):d==="transparent"?new Rgb(NaN,NaN,NaN,0):null}function rgbn(d){return new Rgb(d>>16&255,d>>8&255,d&255,1)}function rgba(d,g,$,b){return b<=0&&(d=g=$=NaN),new Rgb(d,g,$,b)}function rgbConvert(d){return d instanceof Color||(d=color(d)),d?(d=d.rgb(),new Rgb(d.r,d.g,d.b,d.opacity)):new Rgb}function rgb(d,g,$,b){return arguments.length===1?rgbConvert(d):new Rgb(d,g,$,b??1)}function Rgb(d,g,$,b){this.r=+d,this.g=+g,this.b=+$,this.opacity=+b}define(Rgb,rgb,extend(Color,{brighter(d){return d=d==null?brighter:Math.pow(brighter,d),new Rgb(this.r*d,this.g*d,this.b*d,this.opacity)},darker(d){return d=d==null?darker:Math.pow(darker,d),new Rgb(this.r*d,this.g*d,this.b*d,this.opacity)},rgb(){return this},clamp(){return new Rgb(clampi(this.r),clampi(this.g),clampi(this.b),clampa(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:rgb_formatHex,formatHex:rgb_formatHex,formatHex8:rgb_formatHex8,formatRgb:rgb_formatRgb,toString:rgb_formatRgb}));function rgb_formatHex(){return`#${hex$1(this.r)}${hex$1(this.g)}${hex$1(this.b)}`}function rgb_formatHex8(){return`#${hex$1(this.r)}${hex$1(this.g)}${hex$1(this.b)}${hex$1((isNaN(this.opacity)?1:this.opacity)*255)}`}function rgb_formatRgb(){const d=clampa(this.opacity);return`${d===1?"rgb(":"rgba("}${clampi(this.r)}, ${clampi(this.g)}, ${clampi(this.b)}${d===1?")":`, ${d})`}`}function clampa(d){return isNaN(d)?1:Math.max(0,Math.min(1,d))}function clampi(d){return Math.max(0,Math.min(255,Math.round(d)||0))}function hex$1(d){return d=clampi(d),(d<16?"0":"")+d.toString(16)}function hsla(d,g,$,b){return b<=0?d=g=$=NaN:$<=0||$>=1?d=g=NaN:g<=0&&(d=NaN),new Hsl(d,g,$,b)}function hslConvert(d){if(d instanceof Hsl)return new Hsl(d.h,d.s,d.l,d.opacity);if(d instanceof Color||(d=color(d)),!d)return new Hsl;if(d instanceof Hsl)return d;d=d.rgb();var g=d.r/255,$=d.g/255,b=d.b/255,j=Math.min(g,$,b),_e=Math.max(g,$,b),et=NaN,tt=_e-j,nt=(_e+j)/2;return tt?(g===_e?et=($-b)/tt+($0&&nt<1?0:et,new Hsl(et,tt,nt,d.opacity)}function hsl(d,g,$,b){return arguments.length===1?hslConvert(d):new Hsl(d,g,$,b??1)}function Hsl(d,g,$,b){this.h=+d,this.s=+g,this.l=+$,this.opacity=+b}define(Hsl,hsl,extend(Color,{brighter(d){return d=d==null?brighter:Math.pow(brighter,d),new Hsl(this.h,this.s,this.l*d,this.opacity)},darker(d){return d=d==null?darker:Math.pow(darker,d),new Hsl(this.h,this.s,this.l*d,this.opacity)},rgb(){var d=this.h%360+(this.h<0)*360,g=isNaN(d)||isNaN(this.s)?0:this.s,$=this.l,b=$+($<.5?$:1-$)*g,j=2*$-b;return new Rgb(hsl2rgb(d>=240?d-240:d+120,j,b),hsl2rgb(d,j,b),hsl2rgb(d<120?d+240:d-120,j,b),this.opacity)},clamp(){return new Hsl(clamph(this.h),clampt(this.s),clampt(this.l),clampa(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const d=clampa(this.opacity);return`${d===1?"hsl(":"hsla("}${clamph(this.h)}, ${clampt(this.s)*100}%, ${clampt(this.l)*100}%${d===1?")":`, ${d})`}`}}));function clamph(d){return d=(d||0)%360,d<0?d+360:d}function clampt(d){return Math.max(0,Math.min(1,d||0))}function hsl2rgb(d,g,$){return(d<60?g+($-g)*d/60:d<180?$:d<240?g+($-g)*(240-d)/60:g)*255}const constant$2=d=>()=>d;function linear(d,g){return function($){return d+$*g}}function exponential(d,g,$){return d=Math.pow(d,$),g=Math.pow(g,$)-d,$=1/$,function(b){return Math.pow(d+b*g,$)}}function gamma(d){return(d=+d)==1?nogamma:function(g,$){return $-g?exponential(g,$,d):constant$2(isNaN(g)?$:g)}}function nogamma(d,g){var $=g-d;return $?linear(d,$):constant$2(isNaN(d)?g:d)}const interpolateRgb=function d(g){var $=gamma(g);function b(j,_e){var et=$((j=rgb(j)).r,(_e=rgb(_e)).r),tt=$(j.g,_e.g),nt=$(j.b,_e.b),rt=nogamma(j.opacity,_e.opacity);return function(it){return j.r=et(it),j.g=tt(it),j.b=nt(it),j.opacity=rt(it),j+""}}return b.gamma=d,b}(1);function interpolateNumber(d,g){return d=+d,g=+g,function($){return d*(1-$)+g*$}}var reA=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,reB=new RegExp(reA.source,"g");function zero(d){return function(){return d}}function one(d){return function(g){return d(g)+""}}function interpolateString(d,g){var $=reA.lastIndex=reB.lastIndex=0,b,j,_e,et=-1,tt=[],nt=[];for(d=d+"",g=g+"";(b=reA.exec(d))&&(j=reB.exec(g));)(_e=j.index)>$&&(_e=g.slice($,_e),tt[et]?tt[et]+=_e:tt[++et]=_e),(b=b[0])===(j=j[0])?tt[et]?tt[et]+=j:tt[++et]=j:(tt[++et]=null,nt.push({i:et,x:interpolateNumber(b,j)})),$=reB.lastIndex;return $180?it+=360:it-rt>180&&(rt+=360),ut.push({i:st.push(j(st)+"rotate(",null,b)-2,x:interpolateNumber(rt,it)})):it&&st.push(j(st)+"rotate("+it+b)}function tt(rt,it,st,ut){rt!==it?ut.push({i:st.push(j(st)+"skewX(",null,b)-2,x:interpolateNumber(rt,it)}):it&&st.push(j(st)+"skewX("+it+b)}function nt(rt,it,st,ut,at,ht){if(rt!==st||it!==ut){var ct=at.push(j(at)+"scale(",null,",",null,")");ht.push({i:ct-4,x:interpolateNumber(rt,st)},{i:ct-2,x:interpolateNumber(it,ut)})}else(st!==1||ut!==1)&&at.push(j(at)+"scale("+st+","+ut+")")}return function(rt,it){var st=[],ut=[];return rt=d(rt),it=d(it),_e(rt.translateX,rt.translateY,it.translateX,it.translateY,st,ut),et(rt.rotate,it.rotate,st,ut),tt(rt.skewX,it.skewX,st,ut),nt(rt.scaleX,rt.scaleY,it.scaleX,it.scaleY,st,ut),rt=it=null,function(at){for(var ht=-1,ct=ut.length,vt;++ht=0&&d._call.call(void 0,g),d=d._next;--frame}function wake(){clockNow=(clockLast=clock.now())+clockSkew,frame=timeout$1=0;try{timerFlush()}finally{frame=0,nap(),clockNow=0}}function poke(){var d=clock.now(),g=d-clockLast;g>pokeDelay&&(clockSkew-=g,clockLast=d)}function nap(){for(var d,g=taskHead,$,b=1/0;g;)g._call?(b>g._time&&(b=g._time),d=g,g=g._next):($=g._next,g._next=null,g=d?d._next=$:taskHead=$);taskTail=d,sleep(b)}function sleep(d){if(!frame){timeout$1&&(timeout$1=clearTimeout(timeout$1));var g=d-clockNow;g>24?(d<1/0&&(timeout$1=setTimeout(wake,d-clock.now()-clockSkew)),interval&&(interval=clearInterval(interval))):(interval||(clockLast=clock.now(),interval=setInterval(poke,pokeDelay)),frame=1,setFrame(wake))}}function timeout(d,g,$){var b=new Timer;return g=g==null?0:+g,b.restart(j=>{b.stop(),d(j+g)},g,$),b}var emptyOn=dispatch("start","end","cancel","interrupt"),emptyTween=[],CREATED=0,SCHEDULED=1,STARTING=2,STARTED=3,RUNNING=4,ENDING=5,ENDED=6;function schedule(d,g,$,b,j,_e){var et=d.__transition;if(!et)d.__transition={};else if($ in et)return;create(d,$,{name:g,index:b,group:j,on:emptyOn,tween:emptyTween,time:_e.time,delay:_e.delay,duration:_e.duration,ease:_e.ease,timer:null,state:CREATED})}function init(d,g){var $=get$1(d,g);if($.state>CREATED)throw new Error("too late; already scheduled");return $}function set(d,g){var $=get$1(d,g);if($.state>STARTED)throw new Error("too late; already running");return $}function get$1(d,g){var $=d.__transition;if(!$||!($=$[g]))throw new Error("transition not found");return $}function create(d,g,$){var b=d.__transition,j;b[g]=$,$.timer=timer(_e,0,$.time);function _e(rt){$.state=SCHEDULED,$.timer.restart(et,$.delay,$.time),$.delay<=rt&&et(rt-$.delay)}function et(rt){var it,st,ut,at;if($.state!==SCHEDULED)return nt();for(it in b)if(at=b[it],at.name===$.name){if(at.state===STARTED)return timeout(et);at.state===RUNNING?(at.state=ENDED,at.timer.stop(),at.on.call("interrupt",d,d.__data__,at.index,at.group),delete b[it]):+itSTARTING&&b.state=0&&(g=g.slice(0,$)),!g||g==="start"})}function onFunction(d,g,$){var b,j,_e=start(g)?init:set;return function(){var et=_e(this,d),tt=et.on;tt!==b&&(j=(b=tt).copy()).on(g,$),et.on=j}}function transition_on(d,g){var $=this._id;return arguments.length<2?get$1(this.node(),$).on.on(d):this.each(onFunction($,d,g))}function removeFunction(d){return function(){var g=this.parentNode;for(var $ in this.__transition)if(+$!==d)return;g&&g.removeChild(this)}}function transition_remove(){return this.on("end.remove",removeFunction(this._id))}function transition_select(d){var g=this._name,$=this._id;typeof d!="function"&&(d=selector(d));for(var b=this._groups,j=b.length,_e=new Array(j),et=0;et=0))throw new Error(`invalid digits: ${d}`);if(g>15)return append;const $=10**g;return function(b){this._+=b[0];for(let j=1,_e=b.length;j<_e;++j)this._+=Math.round(arguments[j]*$)/$+b[j]}}class Path{constructor(g){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=g==null?append:appendRound(g)}moveTo(g,$){this._append`M${this._x0=this._x1=+g},${this._y0=this._y1=+$}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(g,$){this._append`L${this._x1=+g},${this._y1=+$}`}quadraticCurveTo(g,$,b,j){this._append`Q${+g},${+$},${this._x1=+b},${this._y1=+j}`}bezierCurveTo(g,$,b,j,_e,et){this._append`C${+g},${+$},${+b},${+j},${this._x1=+_e},${this._y1=+et}`}arcTo(g,$,b,j,_e){if(g=+g,$=+$,b=+b,j=+j,_e=+_e,_e<0)throw new Error(`negative radius: ${_e}`);let et=this._x1,tt=this._y1,nt=b-g,rt=j-$,it=et-g,st=tt-$,ut=it*it+st*st;if(this._x1===null)this._append`M${this._x1=g},${this._y1=$}`;else if(ut>epsilon)if(!(Math.abs(st*nt-rt*it)>epsilon)||!_e)this._append`L${this._x1=g},${this._y1=$}`;else{let at=b-et,ht=j-tt,ct=nt*nt+rt*rt,vt=at*at+ht*ht,ft=Math.sqrt(ct),gt=Math.sqrt(ut),pt=_e*Math.tan((pi-Math.acos((ct+ut-vt)/(2*ft*gt)))/2),yt=pt/gt,At=pt/ft;Math.abs(yt-1)>epsilon&&this._append`L${g+yt*it},${$+yt*st}`,this._append`A${_e},${_e},0,0,${+(st*at>it*ht)},${this._x1=g+At*nt},${this._y1=$+At*rt}`}}arc(g,$,b,j,_e,et){if(g=+g,$=+$,b=+b,et=!!et,b<0)throw new Error(`negative radius: ${b}`);let tt=b*Math.cos(j),nt=b*Math.sin(j),rt=g+tt,it=$+nt,st=1^et,ut=et?j-_e:_e-j;this._x1===null?this._append`M${rt},${it}`:(Math.abs(this._x1-rt)>epsilon||Math.abs(this._y1-it)>epsilon)&&this._append`L${rt},${it}`,b&&(ut<0&&(ut=ut%tau+tau),ut>tauEpsilon?this._append`A${b},${b},0,1,${st},${g-tt},${$-nt}A${b},${b},0,1,${st},${this._x1=rt},${this._y1=it}`:ut>epsilon&&this._append`A${b},${b},0,${+(ut>=pi)},${st},${this._x1=g+b*Math.cos(_e)},${this._y1=$+b*Math.sin(_e)}`)}rect(g,$,b,j){this._append`M${this._x0=this._x1=+g},${this._y0=this._y1=+$}h${b=+b}v${+j}h${-b}Z`}toString(){return this._}}function responseText(d){if(!d.ok)throw new Error(d.status+" "+d.statusText);return d.text()}function text(d,g){return fetch(d,g).then(responseText)}function parser$2(d){return(g,$)=>text(g,$).then(b=>new DOMParser().parseFromString(b,d))}var svg=parser$2("image/svg+xml");function constant$1(d){return function(){return d}}function withPath(d){let g=3;return d.digits=function($){if(!arguments.length)return g;if($==null)g=null;else{const b=Math.floor($);if(!(b>=0))throw new RangeError(`invalid digits: ${$}`);g=b}return d},()=>new Path(g)}function array(d){return typeof d=="object"&&"length"in d?d:Array.from(d)}function Linear(d){this._context=d}Linear.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(d,g){switch(d=+d,g=+g,this._point){case 0:this._point=1,this._line?this._context.lineTo(d,g):this._context.moveTo(d,g);break;case 1:this._point=2;default:this._context.lineTo(d,g);break}}};function curveLinear(d){return new Linear(d)}function x(d){return d[0]}function y$1(d){return d[1]}function line(d,g){var $=constant$1(!0),b=null,j=curveLinear,_e=null,et=withPath(tt);d=typeof d=="function"?d:d===void 0?x:constant$1(d),g=typeof g=="function"?g:g===void 0?y$1:constant$1(g);function tt(nt){var rt,it=(nt=array(nt)).length,st,ut=!1,at;for(b==null&&(_e=j(at=et())),rt=0;rt<=it;++rt)!(rt0){if(++g>=HOT_COUNT)return arguments[0]}else g=0;return d.apply(void 0,arguments)}}function constant(d){return function(){return d}}var defineProperty=function(){try{var d=getNative(Object,"defineProperty");return d({},"",{}),d}catch{}}();const defineProperty$1=defineProperty;var baseSetToString=defineProperty$1?function(d,g){return defineProperty$1(d,"toString",{configurable:!0,enumerable:!1,value:constant(g),writable:!0})}:identity$1;const baseSetToString$1=baseSetToString;var setToString=shortOut(baseSetToString$1);const setToString$1=setToString;function arrayEach(d,g){for(var $=-1,b=d==null?0:d.length;++$-1}var MAX_SAFE_INTEGER$1=9007199254740991,reIsUint=/^(?:0|[1-9]\d*)$/;function isIndex(d,g){var $=typeof d;return g=g??MAX_SAFE_INTEGER$1,!!g&&($=="number"||$!="symbol"&&reIsUint.test(d))&&d>-1&&d%1==0&&d-1&&d%1==0&&d<=MAX_SAFE_INTEGER}function isArrayLike(d){return d!=null&&isLength(d.length)&&!isFunction(d)}function isIterateeCall(d,g,$){if(!isObject($))return!1;var b=typeof g;return(b=="number"?isArrayLike($)&&isIndex(g,$.length):b=="string"&&g in $)?eq($[g],d):!1}function createAssigner(d){return baseRest(function(g,$){var b=-1,j=$.length,_e=j>1?$[j-1]:void 0,et=j>2?$[2]:void 0;for(_e=d.length>3&&typeof _e=="function"?(j--,_e):void 0,et&&isIterateeCall($[0],$[1],et)&&(_e=j<3?void 0:_e,j=1),g=Object(g);++b-1}function listCacheSet(d,g){var $=this.__data__,b=assocIndexOf($,d);return b<0?(++this.size,$.push([d,g])):$[b][1]=g,this}function ListCache(d){var g=-1,$=d==null?0:d.length;for(this.clear();++g<$;){var b=d[g];this.set(b[0],b[1])}}ListCache.prototype.clear=listCacheClear;ListCache.prototype.delete=listCacheDelete;ListCache.prototype.get=listCacheGet;ListCache.prototype.has=listCacheHas;ListCache.prototype.set=listCacheSet;var Map$1=getNative(root$2,"Map");const Map$2=Map$1;function mapCacheClear(){this.size=0,this.__data__={hash:new Hash,map:new(Map$2||ListCache),string:new Hash}}function isKeyable(d){var g=typeof d;return g=="string"||g=="number"||g=="symbol"||g=="boolean"?d!=="__proto__":d===null}function getMapData(d,g){var $=d.__data__;return isKeyable(g)?$[typeof g=="string"?"string":"hash"]:$.map}function mapCacheDelete(d){var g=getMapData(this,d).delete(d);return this.size-=g?1:0,g}function mapCacheGet(d){return getMapData(this,d).get(d)}function mapCacheHas(d){return getMapData(this,d).has(d)}function mapCacheSet(d,g){var $=getMapData(this,d),b=$.size;return $.set(d,g),this.size+=$.size==b?0:1,this}function MapCache(d){var g=-1,$=d==null?0:d.length;for(this.clear();++g<$;){var b=d[g];this.set(b[0],b[1])}}MapCache.prototype.clear=mapCacheClear;MapCache.prototype.delete=mapCacheDelete;MapCache.prototype.get=mapCacheGet;MapCache.prototype.has=mapCacheHas;MapCache.prototype.set=mapCacheSet;var FUNC_ERROR_TEXT="Expected a function";function memoize(d,g){if(typeof d!="function"||g!=null&&typeof g!="function")throw new TypeError(FUNC_ERROR_TEXT);var $=function(){var b=arguments,j=g?g.apply(this,b):b[0],_e=$.cache;if(_e.has(j))return _e.get(j);var et=d.apply(this,b);return $.cache=_e.set(j,et)||_e,et};return $.cache=new(memoize.Cache||MapCache),$}memoize.Cache=MapCache;var MAX_MEMOIZE_SIZE=500;function memoizeCapped(d){var g=memoize(d,function(b){return $.size===MAX_MEMOIZE_SIZE&&$.clear(),b}),$=g.cache;return g}var rePropName=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,reEscapeChar=/\\(\\)?/g,stringToPath=memoizeCapped(function(d){var g=[];return d.charCodeAt(0)===46&&g.push(""),d.replace(rePropName,function($,b,j,_e){g.push(j?_e.replace(reEscapeChar,"$1"):b||$)}),g});const stringToPath$1=stringToPath;function toString(d){return d==null?"":baseToString(d)}function castPath(d,g){return isArray$1(d)?d:isKey(d,g)?[d]:stringToPath$1(toString(d))}var INFINITY$1=1/0;function toKey(d){if(typeof d=="string"||isSymbol(d))return d;var g=d+"";return g=="0"&&1/d==-INFINITY$1?"-0":g}function baseGet(d,g){g=castPath(g,d);for(var $=0,b=g.length;d!=null&&$0&&$(tt)?g>1?baseFlatten(tt,g-1,$,b,j):arrayPush(j,tt):b||(j[j.length]=tt)}return j}function flatten(d){var g=d==null?0:d.length;return g?baseFlatten(d,1):[]}function flatRest(d){return setToString$1(overRest(d,void 0,flatten),d+"")}var getPrototype=overArg(Object.getPrototypeOf,Object);const getPrototype$1=getPrototype;var objectTag$3="[object Object]",funcProto=Function.prototype,objectProto$7=Object.prototype,funcToString=funcProto.toString,hasOwnProperty$6=objectProto$7.hasOwnProperty,objectCtorString=funcToString.call(Object);function isPlainObject(d){if(!isObjectLike(d)||baseGetTag(d)!=objectTag$3)return!1;var g=getPrototype$1(d);if(g===null)return!0;var $=hasOwnProperty$6.call(g,"constructor")&&g.constructor;return typeof $=="function"&&$ instanceof $&&funcToString.call($)==objectCtorString}function arrayReduce(d,g,$,b){var j=-1,_e=d==null?0:d.length;for(b&&_e&&($=d[++j]);++j<_e;)$=g($,d[j],j,d);return $}function stackClear(){this.__data__=new ListCache,this.size=0}function stackDelete(d){var g=this.__data__,$=g.delete(d);return this.size=g.size,$}function stackGet(d){return this.__data__.get(d)}function stackHas(d){return this.__data__.has(d)}var LARGE_ARRAY_SIZE$1=200;function stackSet(d,g){var $=this.__data__;if($ instanceof ListCache){var b=$.__data__;if(!Map$2||b.lengthtt))return!1;var rt=_e.get(d),it=_e.get(g);if(rt&&it)return rt==g&&it==d;var st=-1,ut=!0,at=$&COMPARE_UNORDERED_FLAG$3?new SetCache:void 0;for(_e.set(d,g),_e.set(g,d);++st2?g[2]:void 0;for(j&&isIterateeCall(g[0],g[1],j)&&(b=1);++$-1?j[_e?g[et]:et]:void 0}}var nativeMax$1=Math.max;function findIndex(d,g,$){var b=d==null?0:d.length;if(!b)return-1;var j=$==null?0:toInteger($);return j<0&&(j=nativeMax$1(b+j,0)),baseFindIndex(d,baseIteratee(g),j)}var find=createFind(findIndex);const find$1=find;function baseMap(d,g){var $=-1,b=isArrayLike(d)?Array(d.length):[];return baseEach$1(d,function(j,_e,et){b[++$]=g(j,_e,et)}),b}function map(d,g){var $=isArray$1(d)?arrayMap:baseMap;return $(d,baseIteratee(g))}function forIn(d,g){return d==null?d:baseFor$1(d,castFunction(g),keysIn)}function forOwn(d,g){return d&&baseForOwn(d,castFunction(g))}function baseGt(d,g){return d>g}var objectProto$1=Object.prototype,hasOwnProperty$1=objectProto$1.hasOwnProperty;function baseHas(d,g){return d!=null&&hasOwnProperty$1.call(d,g)}function has(d,g){return d!=null&&hasPath(d,g,baseHas)}function baseValues(d,g){return arrayMap(g,function($){return d[$]})}function values(d){return d==null?[]:baseValues(d,keys(d))}var mapTag="[object Map]",setTag="[object Set]",objectProto=Object.prototype,hasOwnProperty=objectProto.hasOwnProperty;function isEmpty(d){if(d==null)return!0;if(isArrayLike(d)&&(isArray$1(d)||typeof d=="string"||typeof d.splice=="function"||isBuffer$1(d)||isTypedArray$1(d)||isArguments$1(d)))return!d.length;var g=getTag$1(d);if(g==mapTag||g==setTag)return!d.size;if(isPrototype(d))return!baseKeys(d).length;for(var $ in d)if(hasOwnProperty.call(d,$))return!1;return!0}function isUndefined(d){return d===void 0}function baseLt(d,g){return dg||_e&&et&&nt&&!tt&&!rt||b&&et&&nt||!$&&nt||!j)return 1;if(!b&&!_e&&!rt&&d=tt)return nt;var rt=$[b];return nt*(rt=="desc"?-1:1)}}return d.index-g.index}function baseOrderBy(d,g,$){g.length?g=arrayMap(g,function(_e){return isArray$1(_e)?function(et){return baseGet(et,_e.length===1?_e[0]:_e)}:_e}):g=[identity$1];var b=-1;g=arrayMap(g,baseUnary(baseIteratee));var j=baseMap(d,function(_e,et,tt){var nt=arrayMap(g,function(rt){return rt(_e)});return{criteria:nt,index:++b,value:_e}});return baseSortBy(j,function(_e,et){return compareMultiple(_e,et,$)})}function basePick(d,g){return basePickBy(d,g,function($,b){return hasIn(d,b)})}var pick=flatRest(function(d,g){return d==null?{}:basePick(d,g)});const pick$1=pick;var nativeCeil=Math.ceil,nativeMax=Math.max;function baseRange(d,g,$,b){for(var j=-1,_e=nativeMax(nativeCeil((g-d)/($||1)),0),et=Array(_e);_e--;)et[b?_e:++j]=d,d+=$;return et}function createRange(d){return function(g,$,b){return b&&typeof b!="number"&&isIterateeCall(g,$,b)&&($=b=void 0),g=toFinite(g),$===void 0?($=g,g=0):$=toFinite($),b=b===void 0?g<$?1:-1:toFinite(b),baseRange(g,$,b,d)}}var range=createRange();const range$1=range;function baseReduce(d,g,$,b,j){return j(d,function(_e,et,tt){$=b?(b=!1,_e):g($,_e,et,tt)}),$}function reduce(d,g,$){var b=isArray$1(d)?arrayReduce:baseReduce,j=arguments.length<3;return b(d,baseIteratee(g),$,j,baseEach$1)}var sortBy=baseRest(function(d,g){if(d==null)return[];var $=g.length;return $>1&&isIterateeCall(d,g[0],g[1])?g=[]:$>2&&isIterateeCall(g[0],g[1],g[2])&&(g=[g[0]]),baseOrderBy(d,baseFlatten(g,1),[])});const sortBy$1=sortBy;var INFINITY=1/0,createSet=Set$2&&1/setToArray(new Set$2([,-0]))[1]==INFINITY?function(d){return new Set$2(d)}:noop$1;const createSet$1=createSet;var LARGE_ARRAY_SIZE=200;function baseUniq(d,g,$){var b=-1,j=arrayIncludes,_e=d.length,et=!0,tt=[],nt=tt;if($)et=!1,j=arrayIncludesWith;else if(_e>=LARGE_ARRAY_SIZE){var rt=g?null:createSet$1(d);if(rt)return setToArray(rt);et=!1,j=cacheHas,nt=new SetCache}else nt=g?[]:tt;e:for(;++b<_e;){var it=d[b],st=g?g(it):it;if(it=$||it!==0?it:0,et&&st===st){for(var ut=nt.length;ut--;)if(nt[ut]===st)continue e;g&&nt.push(st),tt.push(it)}else j(nt,st,$)||(nt!==tt&&nt.push(st),tt.push(it))}return tt}var union=baseRest(function(d){return baseUniq(baseFlatten(d,1,isArrayLikeObject,!0))});const union$1=union;var idCounter=0;function uniqueId(d){var g=++idCounter;return toString(d)+g}function baseZipObject(d,g,$){for(var b=-1,j=d.length,_e=g.length,et={};++b1?j.setNode(_e,$):j.setNode(_e)}),this}setNode(g,$){return has(this._nodes,g)?(arguments.length>1&&(this._nodes[g]=$),this):(this._nodes[g]=arguments.length>1?$:this._defaultNodeLabelFn(g),this._isCompound&&(this._parent[g]=GRAPH_NODE,this._children[g]={},this._children[GRAPH_NODE][g]=!0),this._in[g]={},this._preds[g]={},this._out[g]={},this._sucs[g]={},++this._nodeCount,this)}node(g){return this._nodes[g]}hasNode(g){return has(this._nodes,g)}removeNode(g){var $=this;if(has(this._nodes,g)){var b=function(j){$.removeEdge($._edgeObjs[j])};delete this._nodes[g],this._isCompound&&(this._removeFromParentsChildList(g),delete this._parent[g],forEach(this.children(g),function(j){$.setParent(j)}),delete this._children[g]),forEach(keys(this._in[g]),b),delete this._in[g],delete this._preds[g],forEach(keys(this._out[g]),b),delete this._out[g],delete this._sucs[g],--this._nodeCount}return this}setParent(g,$){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(isUndefined($))$=GRAPH_NODE;else{$+="";for(var b=$;!isUndefined(b);b=this.parent(b))if(b===g)throw new Error("Setting "+$+" as parent of "+g+" would create a cycle");this.setNode($)}return this.setNode(g),this._removeFromParentsChildList(g),this._parent[g]=$,this._children[$][g]=!0,this}_removeFromParentsChildList(g){delete this._children[this._parent[g]][g]}parent(g){if(this._isCompound){var $=this._parent[g];if($!==GRAPH_NODE)return $}}children(g){if(isUndefined(g)&&(g=GRAPH_NODE),this._isCompound){var $=this._children[g];if($)return keys($)}else{if(g===GRAPH_NODE)return this.nodes();if(this.hasNode(g))return[]}}predecessors(g){var $=this._preds[g];if($)return keys($)}successors(g){var $=this._sucs[g];if($)return keys($)}neighbors(g){var $=this.predecessors(g);if($)return union$1($,this.successors(g))}isLeaf(g){var $;return this.isDirected()?$=this.successors(g):$=this.neighbors(g),$.length===0}filterNodes(g){var $=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});$.setGraph(this.graph());var b=this;forEach(this._nodes,function(et,tt){g(tt)&&$.setNode(tt,et)}),forEach(this._edgeObjs,function(et){$.hasNode(et.v)&&$.hasNode(et.w)&&$.setEdge(et,b.edge(et))});var j={};function _e(et){var tt=b.parent(et);return tt===void 0||$.hasNode(tt)?(j[et]=tt,tt):tt in j?j[tt]:_e(tt)}return this._isCompound&&forEach($.nodes(),function(et){$.setParent(et,_e(et))}),$}setDefaultEdgeLabel(g){return isFunction(g)||(g=constant(g)),this._defaultEdgeLabelFn=g,this}edgeCount(){return this._edgeCount}edges(){return values(this._edgeObjs)}setPath(g,$){var b=this,j=arguments;return reduce(g,function(_e,et){return j.length>1?b.setEdge(_e,et,$):b.setEdge(_e,et),et}),this}setEdge(){var g,$,b,j,_e=!1,et=arguments[0];typeof et=="object"&&et!==null&&"v"in et?(g=et.v,$=et.w,b=et.name,arguments.length===2&&(j=arguments[1],_e=!0)):(g=et,$=arguments[1],b=arguments[3],arguments.length>2&&(j=arguments[2],_e=!0)),g=""+g,$=""+$,isUndefined(b)||(b=""+b);var tt=edgeArgsToId(this._isDirected,g,$,b);if(has(this._edgeLabels,tt))return _e&&(this._edgeLabels[tt]=j),this;if(!isUndefined(b)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(g),this.setNode($),this._edgeLabels[tt]=_e?j:this._defaultEdgeLabelFn(g,$,b);var nt=edgeArgsToObj(this._isDirected,g,$,b);return g=nt.v,$=nt.w,Object.freeze(nt),this._edgeObjs[tt]=nt,incrementOrInitEntry(this._preds[$],g),incrementOrInitEntry(this._sucs[g],$),this._in[$][tt]=nt,this._out[g][tt]=nt,this._edgeCount++,this}edge(g,$,b){var j=arguments.length===1?edgeObjToId(this._isDirected,arguments[0]):edgeArgsToId(this._isDirected,g,$,b);return this._edgeLabels[j]}hasEdge(g,$,b){var j=arguments.length===1?edgeObjToId(this._isDirected,arguments[0]):edgeArgsToId(this._isDirected,g,$,b);return has(this._edgeLabels,j)}removeEdge(g,$,b){var j=arguments.length===1?edgeObjToId(this._isDirected,arguments[0]):edgeArgsToId(this._isDirected,g,$,b),_e=this._edgeObjs[j];return _e&&(g=_e.v,$=_e.w,delete this._edgeLabels[j],delete this._edgeObjs[j],decrementOrRemoveEntry(this._preds[$],g),decrementOrRemoveEntry(this._sucs[g],$),delete this._in[$][j],delete this._out[g][j],this._edgeCount--),this}inEdges(g,$){var b=this._in[g];if(b){var j=values(b);return $?filter(j,function(_e){return _e.v===$}):j}}outEdges(g,$){var b=this._out[g];if(b){var j=values(b);return $?filter(j,function(_e){return _e.w===$}):j}}nodeEdges(g,$){var b=this.inEdges(g,$);if(b)return b.concat(this.outEdges(g,$))}}Graph.prototype._nodeCount=0;Graph.prototype._edgeCount=0;function incrementOrInitEntry(d,g){d[g]?d[g]++:d[g]=1}function decrementOrRemoveEntry(d,g){--d[g]||delete d[g]}function edgeArgsToId(d,g,$,b){var j=""+g,_e=""+$;if(!d&&j>_e){var et=j;j=_e,_e=et}return j+EDGE_KEY_DELIM+_e+EDGE_KEY_DELIM+(isUndefined(b)?DEFAULT_EDGE_NAME:b)}function edgeArgsToObj(d,g,$,b){var j=""+g,_e=""+$;if(!d&&j>_e){var et=j;j=_e,_e=et}var tt={v:j,w:_e};return b&&(tt.name=b),tt}function edgeObjToId(d,g){return edgeArgsToId(d,g.v,g.w,g.name)}class List{constructor(){var g={};g._next=g._prev=g,this._sentinel=g}dequeue(){var g=this._sentinel,$=g._prev;if($!==g)return unlink($),$}enqueue(g){var $=this._sentinel;g._prev&&g._next&&unlink(g),g._next=$._next,$._next._prev=g,$._next=g,g._prev=$}toString(){for(var g=[],$=this._sentinel,b=$._prev;b!==$;)g.push(JSON.stringify(b,filterOutLinks)),b=b._prev;return"["+g.join(", ")+"]"}}function unlink(d){d._prev._next=d._next,d._next._prev=d._prev,delete d._next,delete d._prev}function filterOutLinks(d,g){if(d!=="_next"&&d!=="_prev")return g}var DEFAULT_WEIGHT_FN=constant(1);function greedyFAS(d,g){if(d.nodeCount()<=1)return[];var $=buildState(d,g||DEFAULT_WEIGHT_FN),b=doGreedyFAS($.graph,$.buckets,$.zeroIdx);return flatten(map(b,function(j){return d.outEdges(j.v,j.w)}))}function doGreedyFAS(d,g,$){for(var b=[],j=g[g.length-1],_e=g[0],et;d.nodeCount();){for(;et=_e.dequeue();)removeNode(d,g,$,et);for(;et=j.dequeue();)removeNode(d,g,$,et);if(d.nodeCount()){for(var tt=g.length-2;tt>0;--tt)if(et=g[tt].dequeue(),et){b=b.concat(removeNode(d,g,$,et,!0));break}}}return b}function removeNode(d,g,$,b,j){var _e=j?[]:void 0;return forEach(d.inEdges(b.v),function(et){var tt=d.edge(et),nt=d.node(et.v);j&&_e.push({v:et.v,w:et.w}),nt.out-=tt,assignBucket(g,$,nt)}),forEach(d.outEdges(b.v),function(et){var tt=d.edge(et),nt=et.w,rt=d.node(nt);rt.in-=tt,assignBucket(g,$,rt)}),d.removeNode(b.v),_e}function buildState(d,g){var $=new Graph,b=0,j=0;forEach(d.nodes(),function(tt){$.setNode(tt,{v:tt,in:0,out:0})}),forEach(d.edges(),function(tt){var nt=$.edge(tt.v,tt.w)||0,rt=g(tt),it=nt+rt;$.setEdge(tt.v,tt.w,it),j=Math.max(j,$.node(tt.v).out+=rt),b=Math.max(b,$.node(tt.w).in+=rt)});var _e=range$1(j+b+3).map(function(){return new List}),et=b+1;return forEach($.nodes(),function(tt){assignBucket(_e,et,$.node(tt))}),{graph:$,buckets:_e,zeroIdx:et}}function assignBucket(d,g,$){$.out?$.in?d[$.out-$.in+g].enqueue($):d[d.length-1].enqueue($):d[0].enqueue($)}function run$2(d){var g=d.graph().acyclicer==="greedy"?greedyFAS(d,$(d)):dfsFAS(d);forEach(g,function(b){var j=d.edge(b);d.removeEdge(b),j.forwardName=b.name,j.reversed=!0,d.setEdge(b.w,b.v,j,uniqueId("rev"))});function $(b){return function(j){return b.edge(j).weight}}}function dfsFAS(d){var g=[],$={},b={};function j(_e){has(b,_e)||(b[_e]=!0,$[_e]=!0,forEach(d.outEdges(_e),function(et){has($,et.w)?g.push(et):j(et.w)}),delete $[_e])}return forEach(d.nodes(),j),g}function undo$2(d){forEach(d.edges(),function(g){var $=d.edge(g);if($.reversed){d.removeEdge(g);var b=$.forwardName;delete $.reversed,delete $.forwardName,d.setEdge(g.w,g.v,$,b)}})}function addDummyNode(d,g,$,b){var j;do j=uniqueId(b);while(d.hasNode(j));return $.dummy=g,d.setNode(j,$),j}function simplify(d){var g=new Graph().setGraph(d.graph());return forEach(d.nodes(),function($){g.setNode($,d.node($))}),forEach(d.edges(),function($){var b=g.edge($.v,$.w)||{weight:0,minlen:1},j=d.edge($);g.setEdge($.v,$.w,{weight:b.weight+j.weight,minlen:Math.max(b.minlen,j.minlen)})}),g}function asNonCompoundGraph(d){var g=new Graph({multigraph:d.isMultigraph()}).setGraph(d.graph());return forEach(d.nodes(),function($){d.children($).length||g.setNode($,d.node($))}),forEach(d.edges(),function($){g.setEdge($,d.edge($))}),g}function intersectRect$1(d,g){var $=d.x,b=d.y,j=g.x-$,_e=g.y-b,et=d.width/2,tt=d.height/2;if(!j&&!_e)throw new Error("Not possible to find intersection inside of the rectangle");var nt,rt;return Math.abs(_e)*et>Math.abs(j)*tt?(_e<0&&(tt=-tt),nt=tt*j/_e,rt=tt):(j<0&&(et=-et),nt=et,rt=et*_e/j),{x:$+nt,y:b+rt}}function buildLayerMatrix(d){var g=map(range$1(maxRank(d)+1),function(){return[]});return forEach(d.nodes(),function($){var b=d.node($),j=b.rank;isUndefined(j)||(g[j][b.order]=$)}),g}function normalizeRanks(d){var g=min(map(d.nodes(),function($){return d.node($).rank}));forEach(d.nodes(),function($){var b=d.node($);has(b,"rank")&&(b.rank-=g)})}function removeEmptyRanks(d){var g=min(map(d.nodes(),function(_e){return d.node(_e).rank})),$=[];forEach(d.nodes(),function(_e){var et=d.node(_e).rank-g;$[et]||($[et]=[]),$[et].push(_e)});var b=0,j=d.graph().nodeRankFactor;forEach($,function(_e,et){isUndefined(_e)&&et%j!==0?--b:b&&forEach(_e,function(tt){d.node(tt).rank+=b})})}function addBorderNode$1(d,g,$,b){var j={width:0,height:0};return arguments.length>=4&&(j.rank=$,j.order=b),addDummyNode(d,"border",j,g)}function maxRank(d){return max(map(d.nodes(),function(g){var $=d.node(g).rank;if(!isUndefined($))return $}))}function partition(d,g){var $={lhs:[],rhs:[]};return forEach(d,function(b){g(b)?$.lhs.push(b):$.rhs.push(b)}),$}function time(d,g){var $=now$2();try{return g()}finally{console.log(d+" time: "+(now$2()-$)+"ms")}}function notime(d,g){return g()}function addBorderSegments(d){function g($){var b=d.children($),j=d.node($);if(b.length&&forEach(b,g),has(j,"minRank")){j.borderLeft=[],j.borderRight=[];for(var _e=j.minRank,et=j.maxRank+1;_eet.lim&&(tt=et,nt=!0);var rt=filter(g.edges(),function(it){return nt===isDescendant(d,d.node(it.v),tt)&&nt!==isDescendant(d,d.node(it.w),tt)});return minBy(rt,function(it){return slack(g,it)})}function exchangeEdges(d,g,$,b){var j=$.v,_e=$.w;d.removeEdge(j,_e),d.setEdge(b.v,b.w,{}),initLowLimValues(d),initCutValues(d,g),updateRanks(d,g)}function updateRanks(d,g){var $=find$1(d.nodes(),function(j){return!g.node(j).parent}),b=preorder(d,$);b=b.slice(1),forEach(b,function(j){var _e=d.node(j).parent,et=g.edge(j,_e),tt=!1;et||(et=g.edge(_e,j),tt=!0),g.node(j).rank=g.node(_e).rank+(tt?et.minlen:-et.minlen)})}function isTreeEdge(d,g,$){return d.hasEdge(g,$)}function isDescendant(d,g,$){return $.low<=g.lim&&g.lim<=$.lim}function rank(d){switch(d.graph().ranker){case"network-simplex":networkSimplexRanker(d);break;case"tight-tree":tightTreeRanker(d);break;case"longest-path":longestPathRanker(d);break;default:networkSimplexRanker(d)}}var longestPathRanker=longestPath;function tightTreeRanker(d){longestPath(d),feasibleTree(d)}function networkSimplexRanker(d){networkSimplex(d)}function run(d){var g=addDummyNode(d,"root",{},"_root"),$=treeDepths(d),b=max(values($))-1,j=2*b+1;d.graph().nestingRoot=g,forEach(d.edges(),function(et){d.edge(et).minlen*=j});var _e=sumWeights(d)+1;forEach(d.children(),function(et){dfs(d,g,j,_e,b,$,et)}),d.graph().nodeRankFactor=j}function dfs(d,g,$,b,j,_e,et){var tt=d.children(et);if(!tt.length){et!==g&&d.setEdge(g,et,{weight:0,minlen:$});return}var nt=addBorderNode$1(d,"_bt"),rt=addBorderNode$1(d,"_bb"),it=d.node(et);d.setParent(nt,et),it.borderTop=nt,d.setParent(rt,et),it.borderBottom=rt,forEach(tt,function(st){dfs(d,g,$,b,j,_e,st);var ut=d.node(st),at=ut.borderTop?ut.borderTop:st,ht=ut.borderBottom?ut.borderBottom:st,ct=ut.borderTop?b:2*b,vt=at!==ht?1:j-_e[et]+1;d.setEdge(nt,at,{weight:ct,minlen:vt,nestingEdge:!0}),d.setEdge(ht,rt,{weight:ct,minlen:vt,nestingEdge:!0})}),d.parent(et)||d.setEdge(g,nt,{weight:0,minlen:j+_e[et]})}function treeDepths(d){var g={};function $(b,j){var _e=d.children(b);_e&&_e.length&&forEach(_e,function(et){$(et,j+1)}),g[b]=j}return forEach(d.children(),function(b){$(b,1)}),g}function sumWeights(d){return reduce(d.edges(),function(g,$){return g+d.edge($).weight},0)}function cleanup(d){var g=d.graph();d.removeNode(g.nestingRoot),delete g.nestingRoot,forEach(d.edges(),function($){var b=d.edge($);b.nestingEdge&&d.removeEdge($)})}function addSubgraphConstraints(d,g,$){var b={},j;forEach($,function(_e){for(var et=d.parent(_e),tt,nt;et;){if(tt=d.parent(et),tt?(nt=b[tt],b[tt]=et):(nt=j,j=et),nt&&nt!==et){g.setEdge(nt,et);return}et=tt}})}function buildLayerGraph(d,g,$){var b=createRootNode(d),j=new Graph({compound:!0}).setGraph({root:b}).setDefaultNodeLabel(function(_e){return d.node(_e)});return forEach(d.nodes(),function(_e){var et=d.node(_e),tt=d.parent(_e);(et.rank===g||et.minRank<=g&&g<=et.maxRank)&&(j.setNode(_e),j.setParent(_e,tt||b),forEach(d[$](_e),function(nt){var rt=nt.v===_e?nt.w:nt.v,it=j.edge(rt,_e),st=isUndefined(it)?0:it.weight;j.setEdge(rt,_e,{weight:d.edge(nt).weight+st})}),has(et,"minRank")&&j.setNode(_e,{borderLeft:et.borderLeft[g],borderRight:et.borderRight[g]}))}),j}function createRootNode(d){for(var g;d.hasNode(g=uniqueId("_root")););return g}function crossCount(d,g){for(var $=0,b=1;b0;)it%2&&(st+=tt[it+1]),it=it-1>>1,tt[it]+=rt.weight;nt+=rt.weight*st})),nt}function initOrder(d){var g={},$=filter(d.nodes(),function(tt){return!d.children(tt).length}),b=max(map($,function(tt){return d.node(tt).rank})),j=map(range$1(b+1),function(){return[]});function _e(tt){if(!has(g,tt)){g[tt]=!0;var nt=d.node(tt);j[nt.rank].push(tt),forEach(d.successors(tt),_e)}}var et=sortBy$1($,function(tt){return d.node(tt).rank});return forEach(et,_e),j}function barycenter(d,g){return map(g,function($){var b=d.inEdges($);if(b.length){var j=reduce(b,function(_e,et){var tt=d.edge(et),nt=d.node(et.v);return{sum:_e.sum+tt.weight*nt.order,weight:_e.weight+tt.weight}},{sum:0,weight:0});return{v:$,barycenter:j.sum/j.weight,weight:j.weight}}else return{v:$}})}function resolveConflicts(d,g){var $={};forEach(d,function(j,_e){var et=$[j.v]={indegree:0,in:[],out:[],vs:[j.v],i:_e};isUndefined(j.barycenter)||(et.barycenter=j.barycenter,et.weight=j.weight)}),forEach(g.edges(),function(j){var _e=$[j.v],et=$[j.w];!isUndefined(_e)&&!isUndefined(et)&&(et.indegree++,_e.out.push($[j.w]))});var b=filter($,function(j){return!j.indegree});return doResolveConflicts(b)}function doResolveConflicts(d){var g=[];function $(_e){return function(et){et.merged||(isUndefined(et.barycenter)||isUndefined(_e.barycenter)||et.barycenter>=_e.barycenter)&&mergeEntries(_e,et)}}function b(_e){return function(et){et.in.push(_e),--et.indegree===0&&d.push(et)}}for(;d.length;){var j=d.pop();g.push(j),forEach(j.in.reverse(),$(j)),forEach(j.out,b(j))}return map(filter(g,function(_e){return!_e.merged}),function(_e){return pick$1(_e,["vs","i","barycenter","weight"])})}function mergeEntries(d,g){var $=0,b=0;d.weight&&($+=d.barycenter*d.weight,b+=d.weight),g.weight&&($+=g.barycenter*g.weight,b+=g.weight),d.vs=g.vs.concat(d.vs),d.barycenter=$/b,d.weight=b,d.i=Math.min(g.i,d.i),g.merged=!0}function sort(d,g){var $=partition(d,function(it){return has(it,"barycenter")}),b=$.lhs,j=sortBy$1($.rhs,function(it){return-it.i}),_e=[],et=0,tt=0,nt=0;b.sort(compareWithBias(!!g)),nt=consumeUnsortable(_e,j,nt),forEach(b,function(it){nt+=it.vs.length,_e.push(it.vs),et+=it.barycenter*it.weight,tt+=it.weight,nt=consumeUnsortable(_e,j,nt)});var rt={vs:flatten(_e)};return tt&&(rt.barycenter=et/tt,rt.weight=tt),rt}function consumeUnsortable(d,g,$){for(var b;g.length&&(b=last$1(g)).i<=$;)g.pop(),d.push(b.vs),$++;return $}function compareWithBias(d){return function(g,$){return g.barycenter<$.barycenter?-1:g.barycenter>$.barycenter?1:d?$.i-g.i:g.i-$.i}}function sortSubgraph(d,g,$,b){var j=d.children(g),_e=d.node(g),et=_e?_e.borderLeft:void 0,tt=_e?_e.borderRight:void 0,nt={};et&&(j=filter(j,function(ht){return ht!==et&&ht!==tt}));var rt=barycenter(d,j);forEach(rt,function(ht){if(d.children(ht.v).length){var ct=sortSubgraph(d,ht.v,$,b);nt[ht.v]=ct,has(ct,"barycenter")&&mergeBarycenters(ht,ct)}});var it=resolveConflicts(rt,$);expandSubgraphs(it,nt);var st=sort(it,b);if(et&&(st.vs=flatten([et,st.vs,tt]),d.predecessors(et).length)){var ut=d.node(d.predecessors(et)[0]),at=d.node(d.predecessors(tt)[0]);has(st,"barycenter")||(st.barycenter=0,st.weight=0),st.barycenter=(st.barycenter*st.weight+ut.order+at.order)/(st.weight+2),st.weight+=2}return st}function expandSubgraphs(d,g){forEach(d,function($){$.vs=flatten($.vs.map(function(b){return g[b]?g[b].vs:b}))})}function mergeBarycenters(d,g){isUndefined(d.barycenter)?(d.barycenter=g.barycenter,d.weight=g.weight):(d.barycenter=(d.barycenter*d.weight+g.barycenter*g.weight)/(d.weight+g.weight),d.weight+=g.weight)}function order(d){var g=maxRank(d),$=buildLayerGraphs(d,range$1(1,g+1),"inEdges"),b=buildLayerGraphs(d,range$1(g-1,-1,-1),"outEdges"),j=initOrder(d);assignOrder(d,j);for(var _e=Number.POSITIVE_INFINITY,et,tt=0,nt=0;nt<4;++tt,++nt){sweepLayerGraphs(tt%2?$:b,tt%4>=2),j=buildLayerMatrix(d);var rt=crossCount(d,j);rt<_e&&(nt=0,et=cloneDeep(j),_e=rt)}assignOrder(d,et)}function buildLayerGraphs(d,g,$){return map(g,function(b){return buildLayerGraph(d,b,$)})}function sweepLayerGraphs(d,g){var $=new Graph;forEach(d,function(b){var j=b.graph().root,_e=sortSubgraph(b,j,$,g);forEach(_e.vs,function(et,tt){b.node(et).order=tt}),addSubgraphConstraints(b,$,_e.vs)})}function assignOrder(d,g){forEach(g,function($){forEach($,function(b,j){d.node(b).order=j})})}function parentDummyChains(d){var g=postorder(d);forEach(d.graph().dummyChains,function($){for(var b=d.node($),j=b.edgeObj,_e=findPath(d,g,j.v,j.w),et=_e.path,tt=_e.lca,nt=0,rt=et[nt],it=!0;$!==j.w;){if(b=d.node($),it){for(;(rt=et[nt])!==tt&&d.node(rt).maxRanket||tt>g[nt].lim));for(rt=nt,nt=b;(nt=d.parent(nt))!==rt;)_e.push(nt);return{path:j.concat(_e.reverse()),lca:rt}}function postorder(d){var g={},$=0;function b(j){var _e=$;forEach(d.children(j),b),g[j]={low:_e,lim:$++}}return forEach(d.children(),b),g}function findType1Conflicts(d,g){var $={};function b(j,_e){var et=0,tt=0,nt=j.length,rt=last$1(_e);return forEach(_e,function(it,st){var ut=findOtherInnerSegmentNode(d,it),at=ut?d.node(ut).order:nt;(ut||it===rt)&&(forEach(_e.slice(tt,st+1),function(ht){forEach(d.predecessors(ht),function(ct){var vt=d.node(ct),ft=vt.order;(ftrt)&&addConflict($,ut,it)})})}function j(_e,et){var tt=-1,nt,rt=0;return forEach(et,function(it,st){if(d.node(it).dummy==="border"){var ut=d.predecessors(it);ut.length&&(nt=d.node(ut[0]).order,b(et,rt,st,tt,nt),rt=st,tt=nt)}b(et,rt,et.length,nt,_e.length)}),et}return reduce(g,j),$}function findOtherInnerSegmentNode(d,g){if(d.node(g).dummy)return find$1(d.predecessors(g),function($){return d.node($).dummy})}function addConflict(d,g,$){if(g>$){var b=g;g=$,$=b}var j=d[g];j||(d[g]=j={}),j[$]=!0}function hasConflict(d,g,$){if(g>$){var b=g;g=$,$=b}return has(d[g],$)}function verticalAlignment(d,g,$,b){var j={},_e={},et={};return forEach(g,function(tt){forEach(tt,function(nt,rt){j[nt]=nt,_e[nt]=nt,et[nt]=rt})}),forEach(g,function(tt){var nt=-1;forEach(tt,function(rt){var it=b(rt);if(it.length){it=sortBy$1(it,function(ct){return et[ct]});for(var st=(it.length-1)/2,ut=Math.floor(st),at=Math.ceil(st);ut<=at;++ut){var ht=it[ut];_e[rt]===rt&&nt0}function intersectPolygon(d,g,$){var b=d.x,j=d.y,_e=[],et=Number.POSITIVE_INFINITY,tt=Number.POSITIVE_INFINITY;g.forEach(function(ht){et=Math.min(et,ht.x),tt=Math.min(tt,ht.y)});for(var nt=b-d.width/2-et,rt=j-d.height/2-tt,it=0;it1&&_e.sort(function(ht,ct){var vt=ht.x-$.x,ft=ht.y-$.y,gt=Math.sqrt(vt*vt+ft*ft),pt=ct.x-$.x,yt=ct.y-$.y,At=Math.sqrt(pt*pt+yt*yt);return gtMath.abs(j)*tt?(_e<0&&(tt=-tt),nt=_e===0?0:tt*j/_e,rt=tt):(j<0&&(et=-et),nt=et,rt=j===0?0:et*_e/j),{x:$+nt,y:b+rt}}var shapes={rect,ellipse,circle,diamond};function setShapes(d){shapes=d}function rect(d,g,$){var b=d.insert("rect",":first-child").attr("rx",$.rx).attr("ry",$.ry).attr("x",-g.width/2).attr("y",-g.height/2).attr("width",g.width).attr("height",g.height);return $.intersect=function(j){return intersectRect($,j)},b}function ellipse(d,g,$){var b=g.width/2,j=g.height/2,_e=d.insert("ellipse",":first-child").attr("x",-g.width/2).attr("y",-g.height/2).attr("rx",b).attr("ry",j);return $.intersect=function(et){return intersectEllipse($,b,j,et)},_e}function circle(d,g,$){var b=Math.max(g.width,g.height)/2,j=d.insert("circle",":first-child").attr("x",-g.width/2).attr("y",-g.height/2).attr("r",b);return $.intersect=function(_e){return intersectCircle($,b,_e)},j}function diamond(d,g,$){var b=g.width*Math.SQRT2/2,j=g.height*Math.SQRT2/2,_e=[{x:0,y:-j},{x:-b,y:0},{x:0,y:j},{x:b,y:0}],et=d.insert("polygon",":first-child").attr("points",_e.map(function(tt){return tt.x+","+tt.y}).join(" "));return $.intersect=function(tt){return intersectPolygon($,_e,tt)},et}function render(){var d=function(g,$){preProcessGraph($);var b=createOrSelectGroup(g,"output"),j=createOrSelectGroup(b,"clusters"),_e=createOrSelectGroup(b,"edgePaths"),et=createEdgeLabels(createOrSelectGroup(b,"edgeLabels"),$),tt=createNodes(createOrSelectGroup(b,"nodes"),$,shapes);layout($),positionNodes(tt,$),positionEdgeLabels(et,$),createEdgePaths(_e,$,arrows);var nt=createClusters(j,$);positionClusters(nt,$),postProcessGraph($)};return d.createNodes=function(g){return arguments.length?(setCreateNodes(g),d):createNodes},d.createClusters=function(g){return arguments.length?(setCreateClusters(g),d):createClusters},d.createEdgeLabels=function(g){return arguments.length?(setCreateEdgeLabels(g),d):createEdgeLabels},d.createEdgePaths=function(g){return arguments.length?(setCreateEdgePaths(g),d):createEdgePaths},d.shapes=function(g){return arguments.length?(setShapes(g),d):shapes},d.arrows=function(g){return arguments.length?(setArrows(g),d):arrows},d}var NODE_DEFAULT_ATTRS={paddingLeft:10,paddingRight:10,paddingTop:10,paddingBottom:10,rx:0,ry:0,shape:"rect"},EDGE_DEFAULT_ATTRS={arrowhead:"normal",curve:curveLinear};function preProcessGraph(d){d.nodes().forEach(function(g){var $=d.node(g);!has($,"label")&&!d.children(g).length&&($.label=g),has($,"paddingX")&&defaults$1($,{paddingLeft:$.paddingX,paddingRight:$.paddingX}),has($,"paddingY")&&defaults$1($,{paddingTop:$.paddingY,paddingBottom:$.paddingY}),has($,"padding")&&defaults$1($,{paddingLeft:$.padding,paddingRight:$.padding,paddingTop:$.padding,paddingBottom:$.padding}),defaults$1($,NODE_DEFAULT_ATTRS),forEach(["paddingLeft","paddingRight","paddingTop","paddingBottom"],function(b){$[b]=Number($[b])}),has($,"width")&&($._prevWidth=$.width),has($,"height")&&($._prevHeight=$.height)}),d.edges().forEach(function(g){var $=d.edge(g);has($,"label")||($.label=""),defaults$1($,EDGE_DEFAULT_ATTRS)})}function postProcessGraph(d){forEach(d.nodes(),function(g){var $=d.node(g);has($,"_prevWidth")?$.width=$._prevWidth:delete $.width,has($,"_prevHeight")?$.height=$._prevHeight:delete $.height,delete $._prevWidth,delete $._prevHeight})}function createOrSelectGroup(d,g){var $=d.select("g."+g);return $.empty()&&($=d.append("g").attr("class",g)),$}function Tree({semantics:d,setSvgElem:g}){console.log("rendering tree: ",d);const $=new Graph({directed:!0});$.setGraph({}),$.graph().rankdir=(d==null?void 0:d.rankdir)??"TB",$.graph().ranksep=15,$.graph().nodesep=20,$.setDefaultEdgeLabel(function(){return{}});const b=({node:nt,statusPercentage:rt})=>{const it='"trebuchet ms",verdana,arial,sans-serif',st=nt.intermediate?7:13,ut=nt.intermediate?`font: bold ${st}px ${it};`:`font: 300 ${st}px ${it};`,at=nt.intermediate?"ellipse":"rect",ht=at==="rect"?"stroke: black; stroke-width: 1px; rx: 5px; ry: 5px;":"stroke: black; stroke-width: 1px;",ct={label:wrapLines(nt.label,20).join(` -`),shape:at,style:`${ht} fill:#dff8ff;`,labelStyle:ut+"fill: black;"};nt.intermediate&&(ct.width=5,ct.height=5,ct.style=`${ht} fill:white;`),rt!==void 0&&(rt>=70&&(ct.style=`${ht} fill:#95f795;`),rt<70&&rt>30&&(ct.style=`${ht} fill:#fdfdbe;`),rt<=30&&(ct.style=`${ht} fill:#ffb2b2;`)),console.log("creating node ",nt.key),$.setNode(nt.key,ct)};if(React.useEffect(()=>{const rt=select("svg").select("g"),it=render(),st=select("#tree-svg-container");if(!(st!=null&&st.node()))return;it(rt,$),rt.attr("transform",computeResizeTransform(rt.node(),st.node(),13,13)+", translate(13, 13)");const ut=10;rt.selectAll("g.node .annotation-circle").remove(),rt.selectAll("g.node .annotation-label").remove();const at=rt.selectAll("g.node").filter(function(ct){var vt;return(vt=d==null?void 0:d.nodes.get(ct))==null?void 0:vt.annotation});at.append("circle").attr("class","annotation-circle").attr("cx",function(){const ct=this.parentNode;console.log("elem",ct);const vt=ct.getElementsByTagName("rect")[0];return vt?-vt.width.baseVal.value/2:0}).attr("cy",function(){const ct=this.parentNode;console.log("elem",ct);const vt=ct.getElementsByTagName("rect")[0];return vt?-vt.height.baseVal.value/2:0}).attr("r",ut).style("fill","white").style("stroke","black").style("stroke-width","1px");const ht=ct=>ct&&ct.length<2?11:8;at.append("text").attr("class","annotation-label").style("font-size",function(){var ct;return ht((ct=d==null?void 0:d.nodes.get(this.parentNode.__data__))==null?void 0:ct.annotation)+"px"}).attr("x",function(){const ct=this.parentNode;console.log("elem",ct);const vt=ct.getElementsByTagName("rect")[0];return vt?-vt.width.baseVal.value/2:0}).attr("y",function(){const ct=this.parentNode;console.log("elem",ct);const vt=ct.getElementsByTagName("rect")[0];return vt?-vt.height.baseVal.value/2+1.5:0}).attr("r",ut).text(function(){var ct;return(ct=_e.get(this.parentNode.__data__))==null?void 0:ct.annotation}),g(document.getElementById("treeSvg"))},[d]),!d)return jsxRuntimeExports.jsx("div",{children:" No AST "});const j=({from:nt,to:rt})=>{var st,ut;const it=((st=d.nodes.get(nt))==null?void 0:st.intermediate)||((ut=d.nodes.get(rt))==null?void 0:ut.intermediate);$.setEdge(nt,rt,{curve:basis,style:"stroke: gray; fill:none; stroke-width: 1px;",minlen:it?1:2})},{nodes:_e,edges:et}=d;console.log("{nodes, edges}",{nodes:_e,edges:et});for(const[nt,rt]of _e)b({node:rt,statusPercentage:rt.statusPercentage});for(const nt of et)j({from:nt.from,to:nt.to});const tt=` - .annotation-label { - fill: black; - text-anchor: middle; - font-weight: bold; - alignment-baseline: middle; - } - `;return jsxRuntimeExports.jsx("div",{id:"tree-svg-container",style:{width:"100%",height:"500"},children:jsxRuntimeExports.jsxs("svg",{id:"treeSvg",width:"100%",height:"100%",version:"1.1",preserveAspectRatio:"xMinYMin",viewBox:"0 0 100 100",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntimeExports.jsx("style",{children:tt}),jsxRuntimeExports.jsx("g",{})]})})}var rafExports={},raf$1={get exports(){return rafExports},set exports(d){rafExports=d}},performanceNowExports={},performanceNow={get exports(){return performanceNowExports},set exports(d){performanceNowExports=d}};(function(){var d,g,$,b,j,_e;typeof performance<"u"&&performance!==null&&performance.now?performanceNow.exports=function(){return performance.now()}:typeof process<"u"&&process!==null&&process.hrtime?(performanceNow.exports=function(){return(d()-j)/1e6},g=process.hrtime,d=function(){var et;return et=g(),et[0]*1e9+et[1]},b=d(),_e=process.uptime()*1e9,j=b-_e):Date.now?(performanceNow.exports=function(){return Date.now()-$},$=Date.now()):(performanceNow.exports=function(){return new Date().getTime()-$},$=new Date().getTime())}).call(commonjsGlobal);var now=performanceNowExports,root=typeof window>"u"?commonjsGlobal:window,vendors=["moz","webkit"],suffix="AnimationFrame",raf=root["request"+suffix],caf=root["cancel"+suffix]||root["cancelRequest"+suffix];for(var i$1=0;!raf&&i$13&&(this.alpha=tt[3]),this.ok=!0}}this.r=this.r<0||isNaN(this.r)?0:this.r>255?255:this.r,this.g=this.g<0||isNaN(this.g)?0:this.g>255?255:this.g,this.b=this.b<0||isNaN(this.b)?0:this.b>255?255:this.b,this.alpha=this.alpha<0?0:this.alpha>1||isNaN(this.alpha)?1:this.alpha,this.toRGB=function(){return"rgb("+this.r+", "+this.g+", "+this.b+")"},this.toRGBA=function(){return"rgba("+this.r+", "+this.g+", "+this.b+", "+this.alpha+")"},this.toHex=function(){var nt=this.r.toString(16),rt=this.g.toString(16),it=this.b.toString(16);return nt.length==1&&(nt="0"+nt),rt.length==1&&(rt="0"+rt),it.length==1&&(it="0"+it),"#"+nt+rt+it},this.getHelpXML=function(){for(var nt=new Array,rt=0;rt<$.length;rt++)for(var it=$[rt].example,st=0;st "+ct.toRGB()+" -> "+ct.toHex());ht.appendChild(vt),ht.appendChild(ft),at.appendChild(ht)}catch{}return at}};/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. -***************************************************************************** */var t=function(d,g){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function($,b){$.__proto__=b}||function($,b){for(var j in b)Object.prototype.hasOwnProperty.call(b,j)&&($[j]=b[j])})(d,g)};function r(d,g){if(typeof g!="function"&&g!==null)throw new TypeError("Class extends value "+String(g)+" is not a constructor or null");function $(){this.constructor=d}t(d,g),d.prototype=g===null?Object.create(g):($.prototype=g.prototype,new $)}function e(d){var g="";Array.isArray(d)||(d=[d]);for(var $=0;$d.phi1&&(d.phi2-=2*n),d.sweepFlag===1&&d.phi2b)return[];if(b===0)return[[d*$/(d*d+g*g),g*$/(d*d+g*g)]];var j=Math.sqrt(b);return[[(d*$+g*j)/(d*d+g*g),(g*$-d*j)/(d*d+g*g)],[(d*$-g*j)/(d*d+g*g),(g*$+d*j)/(d*d+g*g)]]}var u,h=Math.PI/180;function c$1(d,g,$){return(1-$)*d+$*g}function y(d,g,$,b){return d+Math.cos(b/180*n)*g+Math.sin(b/180*n)*$}function p(d,g,$,b){var j=1e-6,_e=g-d,et=$-g,tt=3*_e+3*(b-$)-6*et,nt=6*(et-_e),rt=3*_e;return Math.abs(tt)St&&(at.sweepFlag=+!at.sweepFlag),at})}function et(){return function(tt){var nt={};for(var rt in tt)nt[rt]=tt[rt];return nt}}d.ROUND=function(tt){function nt(rt){return Math.round(rt*tt)/tt}return tt===void 0&&(tt=1e13),a(tt),function(rt){return rt.x1!==void 0&&(rt.x1=nt(rt.x1)),rt.y1!==void 0&&(rt.y1=nt(rt.y1)),rt.x2!==void 0&&(rt.x2=nt(rt.x2)),rt.y2!==void 0&&(rt.y2=nt(rt.y2)),rt.x!==void 0&&(rt.x=nt(rt.x)),rt.y!==void 0&&(rt.y=nt(rt.y)),rt.rX!==void 0&&(rt.rX=nt(rt.rX)),rt.rY!==void 0&&(rt.rY=nt(rt.rY)),rt}},d.TO_ABS=g,d.TO_REL=function(){return j(function(tt,nt,rt){return tt.relative||(tt.x1!==void 0&&(tt.x1-=nt),tt.y1!==void 0&&(tt.y1-=rt),tt.x2!==void 0&&(tt.x2-=nt),tt.y2!==void 0&&(tt.y2-=rt),tt.x!==void 0&&(tt.x-=nt),tt.y!==void 0&&(tt.y-=rt),tt.relative=!0),tt})},d.NORMALIZE_HVZ=function(tt,nt,rt){return tt===void 0&&(tt=!0),nt===void 0&&(nt=!0),rt===void 0&&(rt=!0),j(function(it,st,ut,at,ht){if(isNaN(at)&&!(it.type&_.MOVE_TO))throw new Error("path must start with moveto");return nt&&it.type&_.HORIZ_LINE_TO&&(it.type=_.LINE_TO,it.y=it.relative?0:ut),rt&&it.type&_.VERT_LINE_TO&&(it.type=_.LINE_TO,it.x=it.relative?0:st),tt&&it.type&_.CLOSE_PATH&&(it.type=_.LINE_TO,it.x=it.relative?at-st:at,it.y=it.relative?ht-ut:ht),it.type&_.ARC&&(it.rX===0||it.rY===0)&&(it.type=_.LINE_TO,delete it.rX,delete it.rY,delete it.xRot,delete it.lArcFlag,delete it.sweepFlag),it})},d.NORMALIZE_ST=$,d.QT_TO_C=b,d.INFO=j,d.SANITIZE=function(tt){tt===void 0&&(tt=0),a(tt);var nt=NaN,rt=NaN,it=NaN,st=NaN;return j(function(ut,at,ht,ct,vt){var ft=Math.abs,gt=!1,pt=0,yt=0;if(ut.type&_.SMOOTH_CURVE_TO&&(pt=isNaN(nt)?0:at-nt,yt=isNaN(rt)?0:ht-rt),ut.type&(_.CURVE_TO|_.SMOOTH_CURVE_TO)?(nt=ut.relative?at+ut.x2:ut.x2,rt=ut.relative?ht+ut.y2:ut.y2):(nt=NaN,rt=NaN),ut.type&_.SMOOTH_QUAD_TO?(it=isNaN(it)?at:2*at-it,st=isNaN(st)?ht:2*ht-st):ut.type&_.QUAD_TO?(it=ut.relative?at+ut.x1:ut.x1,st=ut.relative?ht+ut.y1:ut.y2):(it=NaN,st=NaN),ut.type&_.LINE_COMMANDS||ut.type&_.ARC&&(ut.rX===0||ut.rY===0||!ut.lArcFlag)||ut.type&_.CURVE_TO||ut.type&_.SMOOTH_CURVE_TO||ut.type&_.QUAD_TO||ut.type&_.SMOOTH_QUAD_TO){var At=ut.x===void 0?0:ut.relative?ut.x:ut.x-at,Dt=ut.y===void 0?0:ut.relative?ut.y:ut.y-ht;pt=isNaN(it)?ut.x1===void 0?pt:ut.relative?ut.x:ut.x1-at:it-at,yt=isNaN(st)?ut.y1===void 0?yt:ut.relative?ut.y:ut.y1-ht:st-ht;var St=ut.x2===void 0?0:ut.relative?ut.x:ut.x2-at,Bt=ut.y2===void 0?0:ut.relative?ut.y:ut.y2-ht;ft(At)<=tt&&ft(Dt)<=tt&&ft(pt)<=tt&&ft(yt)<=tt&&ft(St)<=tt&&ft(Bt)<=tt&&(gt=!0)}return ut.type&_.CLOSE_PATH&&ft(at-ct)<=tt&&ft(ht-vt)<=tt&&(gt=!0),gt?[]:ut})},d.MATRIX=_e,d.ROTATE=function(tt,nt,rt){nt===void 0&&(nt=0),rt===void 0&&(rt=0),a(tt,nt,rt);var it=Math.sin(tt),st=Math.cos(tt);return _e(st,it,-it,st,nt-nt*st+rt*it,rt-nt*it-rt*st)},d.TRANSLATE=function(tt,nt){return nt===void 0&&(nt=0),a(tt,nt),_e(1,0,0,1,tt,nt)},d.SCALE=function(tt,nt){return nt===void 0&&(nt=tt),a(tt,nt),_e(tt,0,0,nt,0,0)},d.SKEW_X=function(tt){return a(tt),_e(1,0,Math.atan(tt),1,0,0)},d.SKEW_Y=function(tt){return a(tt),_e(1,Math.atan(tt),0,1,0,0)},d.X_AXIS_SYMMETRY=function(tt){return tt===void 0&&(tt=0),a(tt),_e(-1,0,0,1,tt,0)},d.Y_AXIS_SYMMETRY=function(tt){return tt===void 0&&(tt=0),a(tt),_e(1,0,0,-1,0,tt)},d.A_TO_C=function(){return j(function(tt,nt,rt){return _.ARC===tt.type?function(it,st,ut){var at,ht,ct,vt;it.cX||o(it,st,ut);for(var ft=Math.min(it.phi1,it.phi2),gt=Math.max(it.phi1,it.phi2)-ft,pt=Math.ceil(gt/90),yt=new Array(pt),At=st,Dt=ut,St=0;Stst.maxX&&(st.maxX=jt),jtst.maxY&&(st.maxY=jt),jtLt&&vt(m$1(at,ct.x1,ct.x2,ct.x,Lt));for(var yt=0,At=p(ht,ct.y1,ct.y2,ct.y);ytLt&&ft(m$1(ht,ct.y1,ct.y2,ct.y,Lt))}if(ct.type&_.ARC){vt(ct.x),ft(ct.y),o(ct,at,ht);for(var Dt=ct.xRot/180*Math.PI,St=Math.cos(Dt)*ct.rX,Bt=Math.sin(Dt)*ct.rX,Ot=-Math.sin(Dt)*ct.rY,Ct=Math.cos(Dt)*ct.rY,_t=ct.phi1ct.phi2?[ct.phi2+360,ct.phi1+360]:[ct.phi2,ct.phi1],Tt=_t[0],kt=_t[1],Mt=function(jt){var Yt=jt[0],Qt=jt[1],on=180*Math.atan2(Qt,Yt)/Math.PI;return onTt&&LtTt&&Ltit)throw new SyntaxError('Expected positive number, got "'+it+'" at index "'+et+'"')}else if((this.curArgs.length===3||this.curArgs.length===4)&&this.curNumber!=="0"&&this.curNumber!=="1")throw new SyntaxError('Expected a flag, got "'+this.curNumber+'" at index "'+et+'"')}this.curArgs.push(it),this.curArgs.length===N[this.curCommandType]&&(_.HORIZ_LINE_TO===this.curCommandType?_e({type:_.HORIZ_LINE_TO,relative:this.curCommandRelative,x:it}):_.VERT_LINE_TO===this.curCommandType?_e({type:_.VERT_LINE_TO,relative:this.curCommandRelative,y:it}):this.curCommandType===_.MOVE_TO||this.curCommandType===_.LINE_TO||this.curCommandType===_.SMOOTH_QUAD_TO?(_e({type:this.curCommandType,relative:this.curCommandRelative,x:this.curArgs[0],y:this.curArgs[1]}),_.MOVE_TO===this.curCommandType&&(this.curCommandType=_.LINE_TO)):this.curCommandType===_.CURVE_TO?_e({type:_.CURVE_TO,relative:this.curCommandRelative,x1:this.curArgs[0],y1:this.curArgs[1],x2:this.curArgs[2],y2:this.curArgs[3],x:this.curArgs[4],y:this.curArgs[5]}):this.curCommandType===_.SMOOTH_CURVE_TO?_e({type:_.SMOOTH_CURVE_TO,relative:this.curCommandRelative,x2:this.curArgs[0],y2:this.curArgs[1],x:this.curArgs[2],y:this.curArgs[3]}):this.curCommandType===_.QUAD_TO?_e({type:_.QUAD_TO,relative:this.curCommandRelative,x1:this.curArgs[0],y1:this.curArgs[1],x:this.curArgs[2],y:this.curArgs[3]}):this.curCommandType===_.ARC&&_e({type:_.ARC,relative:this.curCommandRelative,rX:this.curArgs[0],rY:this.curArgs[1],xRot:this.curArgs[2],lArcFlag:this.curArgs[3],sweepFlag:this.curArgs[4],x:this.curArgs[5],y:this.curArgs[6]})),this.curNumber="",this.curNumberHasExpDigits=!1,this.curNumberHasExp=!1,this.curNumberHasDecimal=!1,this.canParseCommandOrComma=!0}if(!T(tt))if(tt===","&&this.canParseCommandOrComma)this.canParseCommandOrComma=!1;else if(tt!=="+"&&tt!=="-"&&tt!==".")if(rt)this.curNumber=tt,this.curNumberHasDecimal=!1;else{if(this.curArgs.length!==0)throw new SyntaxError("Unterminated command at index "+et+".");if(!this.canParseCommandOrComma)throw new SyntaxError('Unexpected character "'+tt+'" at index '+et+". Command cannot follow comma");if(this.canParseCommandOrComma=!1,tt!=="z"&&tt!=="Z")if(tt==="h"||tt==="H")this.curCommandType=_.HORIZ_LINE_TO,this.curCommandRelative=tt==="h";else if(tt==="v"||tt==="V")this.curCommandType=_.VERT_LINE_TO,this.curCommandRelative=tt==="v";else if(tt==="m"||tt==="M")this.curCommandType=_.MOVE_TO,this.curCommandRelative=tt==="m";else if(tt==="l"||tt==="L")this.curCommandType=_.LINE_TO,this.curCommandRelative=tt==="l";else if(tt==="c"||tt==="C")this.curCommandType=_.CURVE_TO,this.curCommandRelative=tt==="c";else if(tt==="s"||tt==="S")this.curCommandType=_.SMOOTH_CURVE_TO,this.curCommandRelative=tt==="s";else if(tt==="q"||tt==="Q")this.curCommandType=_.QUAD_TO,this.curCommandRelative=tt==="q";else if(tt==="t"||tt==="T")this.curCommandType=_.SMOOTH_QUAD_TO,this.curCommandRelative=tt==="t";else{if(tt!=="a"&&tt!=="A")throw new SyntaxError('Unexpected character "'+tt+'" at index '+et+".");this.curCommandType=_.ARC,this.curCommandRelative=tt==="a"}else b.push({type:_.CLOSE_PATH}),this.canParseCommandOrComma=!0,this.curCommandType=-1}else this.curNumber=tt,this.curNumberHasDecimal=tt==="."}else this.curNumber+=tt,this.curNumberHasDecimal=!0;else this.curNumber+=tt;else this.curNumber+=tt,this.curNumberHasExp=!0;else this.curNumber+=tt,this.curNumberHasExpDigits=this.curNumberHasExp}return b},g.prototype.transform=function($){return Object.create(this,{parse:{value:function(b,j){j===void 0&&(j=[]);for(var _e=0,et=Object.getPrototypeOf(this).parse.call(this,b);_e>At;if(et[pt+3]=On,On!==0){var Pn=255/On;et[pt]=(jt*yt>>At)*Pn,et[pt+1]=(Yt*yt>>At)*Pn,et[pt+2]=(Qt*yt>>At)*Pn}else et[pt]=et[pt+1]=et[pt+2]=0;jt-=Jt,Yt-=Xt,Qt-=Nt,on-=Lt,Jt-=vt.r,Xt-=vt.g,Nt-=vt.b,Lt-=vt.a;var Cn=Nn+_e+1;Cn=gt+(Cn>At,cn>0?(cn=255/cn,et[rn]=(It*yt>>At)*cn,et[rn+1]=(Wt*yt>>At)*cn,et[rn+2]=(Gt*yt>>At)*cn):et[rn]=et[rn+1]=et[rn+2]=0,It-=$t,Wt-=bt,Gt-=Rt,Zt-=Ut,$t-=vt.r,bt-=vt.g,Rt-=vt.b,Ut-=vt.a,rn=xn+((rn=bn+it)0&&arguments[0]!==void 0?arguments[0]:{};const g={window:null,ignoreAnimation:!0,ignoreMouse:!0,DOMParser:d,createCanvas($,b){return new OffscreenCanvas($,b)},async createImage($){const j=await(await fetch($)).blob();return await createImageBitmap(j)}};return(typeof globalThis.DOMParser<"u"||typeof d>"u")&&Reflect.deleteProperty(g,"DOMParser"),g}function node(d){let{DOMParser:g,canvas:$,fetch:b}=d;return{window:null,ignoreAnimation:!0,ignoreMouse:!0,DOMParser:g,fetch:b,createCanvas:$.createCanvas,createImage:$.loadImage}}var index=Object.freeze({__proto__:null,offscreen,node});function compressSpaces(d){return d.replace(/(?!\u3000)\s+/gm," ")}function trimLeft(d){return d.replace(/^[\n \t]+/,"")}function trimRight(d){return d.replace(/[\n \t]+$/,"")}function toNumbers(d){const g=d.match(/-?(\d+(?:\.\d*(?:[eE][+-]?\d+)?)?|\.\d+)(?=\D|$)/gm);return g?g.map(parseFloat):[]}function toMatrixValue(d){const g=toNumbers(d);return[g[0]||0,g[1]||0,g[2]||0,g[3]||0,g[4]||0,g[5]||0]}const allUppercase=/^[A-Z-]+$/;function normalizeAttributeName(d){return allUppercase.test(d)?d.toLowerCase():d}function parseExternalUrl(d){const g=/url\(('([^']+)'|"([^"]+)"|([^'")]+))\)/.exec(d);return g&&(g[2]||g[3]||g[4])||""}function normalizeColor(d){if(!d.startsWith("rgb"))return d;let g=3;return d.replace(/\d+(\.\d+)?/g,(b,j)=>g--&&j?String(Math.round(parseFloat(b))):b)}const attributeRegex=/(\[[^\]]+\])/g,idRegex=/(#[^\s+>~.[:]+)/g,classRegex=/(\.[^\s+>~.[:]+)/g,pseudoElementRegex=/(::[^\s+>~.[:]+|:first-line|:first-letter|:before|:after)/gi,pseudoClassWithBracketsRegex=/(:[\w-]+\([^)]*\))/gi,pseudoClassRegex=/(:[^\s+>~.[:]+)/g,elementRegex=/([^\s+>~.[:]+)/g;function findSelectorMatch(d,g){const $=g.exec(d);return $?[d.replace(g," "),$.length]:[d,0]}function getSelectorSpecificity(d){const g=[0,0,0];let $=d.replace(/:not\(([^)]*)\)/g," $1 ").replace(/{[\s\S]*/gm," "),b=0;return[$,b]=findSelectorMatch($,attributeRegex),g[1]+=b,[$,b]=findSelectorMatch($,idRegex),g[0]+=b,[$,b]=findSelectorMatch($,classRegex),g[1]+=b,[$,b]=findSelectorMatch($,pseudoElementRegex),g[2]+=b,[$,b]=findSelectorMatch($,pseudoClassWithBracketsRegex),g[1]+=b,[$,b]=findSelectorMatch($,pseudoClassRegex),g[1]+=b,$=$.replace(/[*\s+>~]/g," ").replace(/[#.]/g," "),[$,b]=findSelectorMatch($,elementRegex),g[2]+=b,g.join("")}const PSEUDO_ZERO=1e-8;function vectorMagnitude(d){return Math.sqrt(Math.pow(d[0],2)+Math.pow(d[1],2))}function vectorsRatio(d,g){return(d[0]*g[0]+d[1]*g[1])/(vectorMagnitude(d)*vectorMagnitude(g))}function vectorsAngle(d,g){return(d[0]*g[1]0&&arguments[0]!==void 0?arguments[0]:" ";const{document:$,name:b}=this;return compressSpaces(this.getString()).trim().split(g).map(j=>new Property($,b,j))}hasValue(g){const $=this.value;return $!==null&&$!==""&&(g||$!==0)&&typeof $<"u"}isString(g){const{value:$}=this,b=typeof $=="string";return!b||!g?b:g.test($)}isUrlDefinition(){return this.isString(/^url\(/)}isPixels(){if(!this.hasValue())return!1;const g=this.getString();switch(!0){case g.endsWith("px"):case/^[0-9]+$/.test(g):return!0;default:return!1}}setValue(g){return this.value=g,this}getValue(g){return typeof g>"u"||this.hasValue()?this.value:g}getNumber(g){if(!this.hasValue())return typeof g>"u"?0:parseFloat(g);const{value:$}=this;let b=parseFloat($);return this.isString(/%$/)&&(b/=100),b}getString(g){return typeof g>"u"||this.hasValue()?typeof this.value>"u"?"":String(this.value):String(g)}getColor(g){let $=this.getString(g);return this.isNormalizedColor||(this.isNormalizedColor=!0,$=normalizeColor($),this.value=$),$}getDpi(){return 96}getRem(){return this.document.rootEmSize}getEm(){return this.document.emSize}getUnits(){return this.getString().replace(/[0-9.-]/g,"")}getPixels(g){let $=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(!this.hasValue())return 0;const[b,j]=typeof g=="boolean"?[void 0,g]:[g],{viewPort:_e}=this.document.screen;switch(!0){case this.isString(/vmin$/):return this.getNumber()/100*Math.min(_e.computeSize("x"),_e.computeSize("y"));case this.isString(/vmax$/):return this.getNumber()/100*Math.max(_e.computeSize("x"),_e.computeSize("y"));case this.isString(/vw$/):return this.getNumber()/100*_e.computeSize("x");case this.isString(/vh$/):return this.getNumber()/100*_e.computeSize("y");case this.isString(/rem$/):return this.getNumber()*this.getRem();case this.isString(/em$/):return this.getNumber()*this.getEm();case this.isString(/ex$/):return this.getNumber()*this.getEm()/2;case this.isString(/px$/):return this.getNumber();case this.isString(/pt$/):return this.getNumber()*this.getDpi()*(1/72);case this.isString(/pc$/):return this.getNumber()*15;case this.isString(/cm$/):return this.getNumber()*this.getDpi()/2.54;case this.isString(/mm$/):return this.getNumber()*this.getDpi()/25.4;case this.isString(/in$/):return this.getNumber()*this.getDpi();case(this.isString(/%$/)&&j):return this.getNumber()*this.getEm();case this.isString(/%$/):return this.getNumber()*_e.computeSize(b);default:{const et=this.getNumber();return $&&et<1?et*_e.computeSize(b):et}}}getMilliseconds(){return this.hasValue()?this.isString(/ms$/)?this.getNumber():this.getNumber()*1e3:0}getRadians(){if(!this.hasValue())return 0;switch(!0){case this.isString(/deg$/):return this.getNumber()*(Math.PI/180);case this.isString(/grad$/):return this.getNumber()*(Math.PI/200);case this.isString(/rad$/):return this.getNumber();default:return this.getNumber()*(Math.PI/180)}}getDefinition(){const g=this.getString(),$=/#([^)'"]+)/.exec(g),b=($==null?void 0:$[1])||g;return this.document.definitions[b]}getFillStyleDefinition(g,$){let b=this.getDefinition();if(!b)return null;if(typeof b.createGradient=="function"&&"getBoundingBox"in g)return b.createGradient(this.document.ctx,g,$);if(typeof b.createPattern=="function"){if(b.getHrefAttribute().hasValue()){const j=b.getAttribute("patternTransform");b=b.getHrefAttribute().getDefinition(),b&&j.hasValue()&&b.getAttribute("patternTransform",!0).setValue(j.value)}if(b)return b.createPattern(this.document.ctx,g,$)}return null}getTextBaseline(){if(!this.hasValue())return null;const g=this.getString();return Property.textBaselineMapping[g]||null}addOpacity(g){let $=this.getColor();const b=$.length;let j=0;for(let _e=0;_e1&&arguments[1]!==void 0?arguments[1]:0;const[b=$,j=$]=toNumbers(g);return new Point(b,j)}static parseScale(g){let $=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1;const[b=$,j=b]=toNumbers(g);return new Point(b,j)}static parsePath(g){const $=toNumbers(g),b=$.length,j=[];for(let _e=0;_e0}runEvents(){if(!this.working)return;const{screen:g,events:$,eventElements:b}=this,{style:j}=g.ctx.canvas;let _e;j&&(j.cursor=""),$.forEach((et,tt)=>{let{run:nt}=et;for(_e=b[tt];_e;)nt(_e),_e=_e.parent}),this.events=[],this.eventElements=[]}checkPath(g,$){if(!this.working||!$)return;const{events:b,eventElements:j}=this;b.forEach((_e,et)=>{let{x:tt,y:nt}=_e;!j[et]&&$.isPointInPath&&$.isPointInPath(tt,nt)&&(j[et]=g)})}checkBoundingBox(g,$){if(!this.working||!$)return;const{events:b,eventElements:j}=this;b.forEach((_e,et)=>{let{x:tt,y:nt}=_e;!j[et]&&$.isPointInBox(tt,nt)&&(j[et]=g)})}mapXY(g,$){const{window:b,ctx:j}=this.screen,_e=new Point(g,$);let et=j.canvas;for(;et;)_e.x-=et.offsetLeft,_e.y-=et.offsetTop,et=et.offsetParent;return b!=null&&b.scrollX&&(_e.x+=b.scrollX),b!=null&&b.scrollY&&(_e.y+=b.scrollY),_e}onClick(g){const{x:$,y:b}=this.mapXY(g.clientX,g.clientY);this.events.push({type:"onclick",x:$,y:b,run(j){j.onClick&&j.onClick()}})}onMouseMove(g){const{x:$,y:b}=this.mapXY(g.clientX,g.clientY);this.events.push({type:"onmousemove",x:$,y:b,run(j){j.onMouseMove&&j.onMouseMove()}})}constructor(g){this.screen=g,this.working=!1,this.events=[],this.eventElements=[],this.onClick=this.onClick.bind(this),this.onMouseMove=this.onMouseMove.bind(this)}}const defaultWindow=typeof window<"u"?window:null,defaultFetch$1=typeof fetch<"u"?fetch.bind(void 0):void 0;class Screen{wait(g){this.waits.push(g)}ready(){return this.readyPromise?this.readyPromise:Promise.resolve()}isReady(){if(this.isReadyLock)return!0;const g=this.waits.every($=>$());return g&&(this.waits=[],this.resolveReady&&this.resolveReady()),this.isReadyLock=g,g}setDefaults(g){g.strokeStyle="rgba(0,0,0,0)",g.lineCap="butt",g.lineJoin="miter",g.miterLimit=4}setViewBox(g){let{document:$,ctx:b,aspectRatio:j,width:_e,desiredWidth:et,height:tt,desiredHeight:nt,minX:rt=0,minY:it=0,refX:st,refY:ut,clip:at=!1,clipX:ht=0,clipY:ct=0}=g;const vt=compressSpaces(j).replace(/^defer\s/,""),[ft,gt]=vt.split(" "),pt=ft||"xMidYMid",yt=gt||"meet",At=_e/et,Dt=tt/nt,St=Math.min(At,Dt),Bt=Math.max(At,Dt);let Ot=et,Ct=nt;yt==="meet"&&(Ot*=St,Ct*=St),yt==="slice"&&(Ot*=Bt,Ct*=Bt);const _t=new Property($,"refX",st),Tt=new Property($,"refY",ut),kt=_t.hasValue()&&Tt.hasValue();if(kt&&b.translate(-St*_t.getPixels("x"),-St*Tt.getPixels("y")),at){const Mt=St*ht,Vt=St*ct;b.beginPath(),b.moveTo(Mt,Vt),b.lineTo(_e,Vt),b.lineTo(_e,tt),b.lineTo(Mt,tt),b.closePath(),b.clip()}if(!kt){const Mt=yt==="meet"&&St===Dt,Vt=yt==="slice"&&Bt===Dt,Jt=yt==="meet"&&St===At,Xt=yt==="slice"&&Bt===At;pt.startsWith("xMid")&&(Mt||Vt)&&b.translate(_e/2-Ot/2,0),pt.endsWith("YMid")&&(Jt||Xt)&&b.translate(0,tt/2-Ct/2),pt.startsWith("xMax")&&(Mt||Vt)&&b.translate(_e-Ot,0),pt.endsWith("YMax")&&(Jt||Xt)&&b.translate(0,tt-Ct)}switch(!0){case pt==="none":b.scale(At,Dt);break;case yt==="meet":b.scale(St,St);break;case yt==="slice":b.scale(Bt,Bt);break}b.translate(-rt,-it)}start(g){let{enableRedraw:$=!1,ignoreMouse:b=!1,ignoreAnimation:j=!1,ignoreDimensions:_e=!1,ignoreClear:et=!1,forceRedraw:tt,scaleWidth:nt,scaleHeight:rt,offsetX:it,offsetY:st}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const{mouse:ut}=this,at=1e3/Screen.FRAMERATE;if(this.isReadyLock=!1,this.frameDuration=at,this.readyPromise=new Promise(gt=>{this.resolveReady=gt}),this.isReady()&&this.render(g,_e,et,nt,rt,it,st),!$)return;let ht=Date.now(),ct=ht,vt=0;const ft=()=>{ht=Date.now(),vt=ht-ct,vt>=at&&(ct=ht-vt%at,this.shouldUpdate(j,tt)&&(this.render(g,_e,et,nt,rt,it,st),ut.runEvents())),this.intervalId=rafExports(ft)};b||ut.start(),this.intervalId=rafExports(ft)}stop(){this.intervalId&&(rafExports.cancel(this.intervalId),this.intervalId=null),this.mouse.stop()}shouldUpdate(g,$){if(!g){const{frameDuration:b}=this;if(this.animations.reduce((_e,et)=>et.update(b)||_e,!1))return!0}return!!(typeof $=="function"&&$()||!this.isReadyLock&&this.isReady()||this.mouse.hasEvents())}render(g,$,b,j,_e,et,tt){const{viewPort:nt,ctx:rt,isFirstRender:it}=this,st=rt.canvas;nt.clear(),st.width&&st.height&&nt.setCurrent(st.width,st.height);const ut=g.getStyle("width"),at=g.getStyle("height");!$&&(it||typeof j!="number"&&typeof _e!="number")&&(ut.hasValue()&&(st.width=ut.getPixels("x"),st.style&&(st.style.width="".concat(st.width,"px"))),at.hasValue()&&(st.height=at.getPixels("y"),st.style&&(st.style.height="".concat(st.height,"px"))));let ht=st.clientWidth||st.width,ct=st.clientHeight||st.height;if($&&ut.hasValue()&&at.hasValue()&&(ht=ut.getPixels("x"),ct=at.getPixels("y")),nt.setCurrent(ht,ct),typeof et=="number"&&g.getAttribute("x",!0).setValue(et),typeof tt=="number"&&g.getAttribute("y",!0).setValue(tt),typeof j=="number"||typeof _e=="number"){const vt=toNumbers(g.getAttribute("viewBox").getString());let ft=0,gt=0;if(typeof j=="number"){const yt=g.getStyle("width");yt.hasValue()?ft=yt.getPixels("x")/j:vt[2]&&!isNaN(vt[2])&&(ft=vt[2]/j)}if(typeof _e=="number"){const yt=g.getStyle("height");yt.hasValue()?gt=yt.getPixels("y")/_e:vt[3]&&!isNaN(vt[3])&&(gt=vt[3]/_e)}ft||(ft=gt),gt||(gt=ft),g.getAttribute("width",!0).setValue(j),g.getAttribute("height",!0).setValue(_e);const pt=g.getStyle("transform",!0,!0);pt.setValue("".concat(pt.getString()," scale(").concat(1/ft,", ").concat(1/gt,")"))}b||rt.clearRect(0,0,ht,ct),g.render(rt),it&&(this.isFirstRender=!1)}constructor(g,{fetch:$=defaultFetch$1,window:b=defaultWindow}={}){if(this.ctx=g,this.viewPort=new ViewPort,this.mouse=new Mouse(this),this.animations=[],this.waits=[],this.frameDuration=0,this.isReadyLock=!1,this.isFirstRender=!0,this.intervalId=null,this.window=b,!$)throw new Error("Can't find 'fetch' in 'globalThis', please provide it via options");this.fetch=$}}Screen.defaultWindow=defaultWindow;Screen.defaultFetch=defaultFetch$1;Screen.FRAMERATE=30;Screen.MAX_VIRTUAL_PIXELS=3e4;const{defaultFetch}=Screen,DefaultDOMParser=typeof DOMParser<"u"?DOMParser:void 0;class Parser{async parse(g){return g.startsWith("<")?this.parseFromString(g):this.load(g)}parseFromString(g){const $=new this.DOMParser;try{return this.checkDocument($.parseFromString(g,"image/svg+xml"))}catch{return this.checkDocument($.parseFromString(g,"text/xml"))}}checkDocument(g){const $=g.getElementsByTagName("parsererror")[0];if($)throw new Error($.textContent||"Unknown parse error");return g}async load(g){const b=await(await this.fetch(g)).text();return this.parseFromString(b)}constructor({fetch:g=defaultFetch,DOMParser:$=DefaultDOMParser}={}){if(!g)throw new Error("Can't find 'fetch' in 'globalThis', please provide it via options");if(!$)throw new Error("Can't find 'DOMParser' in 'globalThis', please provide it via options");this.fetch=g,this.DOMParser=$}}class Translate{apply(g){const{x:$,y:b}=this.point;g.translate($||0,b||0)}unapply(g){const{x:$,y:b}=this.point;g.translate(-1*$||0,-1*b||0)}applyToPoint(g){const{x:$,y:b}=this.point;g.applyTransform([1,0,0,1,$||0,b||0])}constructor(g,$){this.type="translate",this.point=Point.parse($)}}class Rotate{apply(g){const{cx:$,cy:b,originX:j,originY:_e,angle:et}=this,tt=$+j.getPixels("x"),nt=b+_e.getPixels("y");g.translate(tt,nt),g.rotate(et.getRadians()),g.translate(-tt,-nt)}unapply(g){const{cx:$,cy:b,originX:j,originY:_e,angle:et}=this,tt=$+j.getPixels("x"),nt=b+_e.getPixels("y");g.translate(tt,nt),g.rotate(-1*et.getRadians()),g.translate(-tt,-nt)}applyToPoint(g){const{cx:$,cy:b,angle:j}=this,_e=j.getRadians();g.applyTransform([1,0,0,1,$||0,b||0]),g.applyTransform([Math.cos(_e),Math.sin(_e),-Math.sin(_e),Math.cos(_e),0,0]),g.applyTransform([1,0,0,1,-$||0,-b||0])}constructor(g,$,b){this.type="rotate";const j=toNumbers($);this.angle=new Property(g,"angle",j[0]),this.originX=b[0],this.originY=b[1],this.cx=j[1]||0,this.cy=j[2]||0}}class Scale{apply(g){const{scale:{x:$,y:b},originX:j,originY:_e}=this,et=j.getPixels("x"),tt=_e.getPixels("y");g.translate(et,tt),g.scale($,b||$),g.translate(-et,-tt)}unapply(g){const{scale:{x:$,y:b},originX:j,originY:_e}=this,et=j.getPixels("x"),tt=_e.getPixels("y");g.translate(et,tt),g.scale(1/$,1/b||$),g.translate(-et,-tt)}applyToPoint(g){const{x:$,y:b}=this.scale;g.applyTransform([$||0,0,0,b||0,0,0])}constructor(g,$,b){this.type="scale";const j=Point.parseScale($);(j.x===0||j.y===0)&&(j.x=PSEUDO_ZERO,j.y=PSEUDO_ZERO),this.scale=j,this.originX=b[0],this.originY=b[1]}}class Matrix{apply(g){const{originX:$,originY:b,matrix:j}=this,_e=$.getPixels("x"),et=b.getPixels("y");g.translate(_e,et),g.transform(j[0],j[1],j[2],j[3],j[4],j[5]),g.translate(-_e,-et)}unapply(g){const{originX:$,originY:b,matrix:j}=this,_e=j[0],et=j[2],tt=j[4],nt=j[1],rt=j[3],it=j[5],st=0,ut=0,at=1,ht=1/(_e*(rt*at-it*ut)-et*(nt*at-it*st)+tt*(nt*ut-rt*st)),ct=$.getPixels("x"),vt=b.getPixels("y");g.translate(ct,vt),g.transform(ht*(rt*at-it*ut),ht*(it*st-nt*at),ht*(tt*ut-et*at),ht*(_e*at-tt*st),ht*(et*it-tt*rt),ht*(tt*nt-_e*it)),g.translate(-ct,-vt)}applyToPoint(g){g.applyTransform(this.matrix)}constructor(g,$,b){this.type="matrix",this.matrix=toMatrixValue($),this.originX=b[0],this.originY=b[1]}}class Skew extends Matrix{constructor(g,$,b){super(g,$,b),this.type="skew",this.angle=new Property(g,"angle",$)}}class SkewX extends Skew{constructor(g,$,b){super(g,$,b),this.type="skewX",this.matrix=[1,0,Math.tan(this.angle.getRadians()),1,0,0]}}class SkewY extends Skew{constructor(g,$,b){super(g,$,b),this.type="skewY",this.matrix=[1,Math.tan(this.angle.getRadians()),0,1,0,0]}}function parseTransforms(d){return compressSpaces(d).trim().replace(/\)([a-zA-Z])/g,") $1").replace(/\)(\s?,\s?)/g,") ").split(/\s(?=[a-z])/)}function parseTransform(d){const[g="",$=""]=d.split("(");return[g.trim(),$.trim().replace(")","")]}class Transform{static fromElement(g,$){const b=$.getStyle("transform",!1,!0);if(b.hasValue()){const[j,_e=j]=$.getStyle("transform-origin",!1,!0).split();if(j&&_e){const et=[j,_e];return new Transform(g,b.getString(),et)}}return null}apply(g){this.transforms.forEach($=>$.apply(g))}unapply(g){this.transforms.forEach($=>$.unapply(g))}applyToPoint(g){this.transforms.forEach($=>$.applyToPoint(g))}constructor(g,$,b){this.document=g,this.transforms=[],parseTransforms($).forEach(_e=>{if(_e==="none")return;const[et,tt]=parseTransform(_e),nt=Transform.transformTypes[et];nt&&this.transforms.push(new nt(this.document,tt,b))})}}Transform.transformTypes={translate:Translate,rotate:Rotate,scale:Scale,matrix:Matrix,skewX:SkewX,skewY:SkewY};class Element{getAttribute(g){let $=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;const b=this.attributes[g];if(!b&&$){const j=new Property(this.document,g,"");return this.attributes[g]=j,j}return b||Property.empty(this.document)}getHrefAttribute(){let g;for(const $ in this.attributes)if($==="href"||$.endsWith(":href")){g=this.attributes[$];break}return g||Property.empty(this.document)}getStyle(g){let $=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,b=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;const j=this.styles[g];if(j)return j;const _e=this.getAttribute(g);if(_e.hasValue())return this.styles[g]=_e,_e;if(!b){const{parent:et}=this;if(et){const tt=et.getStyle(g);if(tt.hasValue())return tt}}if($){const et=new Property(this.document,g,"");return this.styles[g]=et,et}return Property.empty(this.document)}render(g){if(!(this.getStyle("display").getString()==="none"||this.getStyle("visibility").getString()==="hidden")){if(g.save(),this.getStyle("mask").hasValue()){const $=this.getStyle("mask").getDefinition();$&&(this.applyEffects(g),$.apply(g,this))}else if(this.getStyle("filter").getValue("none")!=="none"){const $=this.getStyle("filter").getDefinition();$&&(this.applyEffects(g),$.apply(g,this))}else this.setContext(g),this.renderChildren(g),this.clearContext(g);g.restore()}}setContext(g){}applyEffects(g){const $=Transform.fromElement(this.document,this);$&&$.apply(g);const b=this.getStyle("clip-path",!1,!0);if(b.hasValue()){const j=b.getDefinition();j&&j.apply(g)}}clearContext(g){}renderChildren(g){this.children.forEach($=>{$.render(g)})}addChild(g){const $=g instanceof Element?g:this.document.createElement(g);$.parent=this,Element.ignoreChildTypes.includes($.type)||this.children.push($)}matchesSelector(g){var $;const{node:b}=this;if(typeof b.matches=="function")return b.matches(g);const j=($=b.getAttribute)===null||$===void 0?void 0:$.call(b,"class");return!j||j===""?!1:j.split(" ").some(_e=>".".concat(_e)===g)}addStylesFromStyleDefinition(){const{styles:g,stylesSpecificity:$}=this.document;let b;for(const j in g)if(!j.startsWith("@")&&this.matchesSelector(j)){const _e=g[j],et=$[j];if(_e)for(const tt in _e){let nt=this.stylesSpecificity[tt];typeof nt>"u"&&(nt="000"),et&&et>=nt&&(b=_e[tt],b&&(this.styles[tt]=b),this.stylesSpecificity[tt]=et)}}}removeStyles(g,$){return $.reduce((j,_e)=>{const et=g.getStyle(_e);if(!et.hasValue())return j;const tt=et.getString();return et.setValue(""),[...j,[_e,tt]]},[])}restoreStyles(g,$){$.forEach(b=>{let[j,_e]=b;g.getStyle(j,!0).setValue(_e)})}isFirstChild(){var g;return((g=this.parent)===null||g===void 0?void 0:g.children.indexOf(this))===0}constructor(g,$,b=!1){if(this.document=g,this.node=$,this.captureTextNodes=b,this.type="",this.attributes={},this.styles={},this.stylesSpecificity={},this.animationFrozen=!1,this.animationFrozenValue="",this.parent=null,this.children=[],!$||$.nodeType!==1)return;Array.from($.attributes).forEach(et=>{const tt=normalizeAttributeName(et.nodeName);this.attributes[tt]=new Property(g,tt,et.value)}),this.addStylesFromStyleDefinition(),this.getAttribute("style").hasValue()&&this.getAttribute("style").getString().split(";").map(tt=>tt.trim()).forEach(tt=>{if(!tt)return;const[nt,rt]=tt.split(":").map(it=>it.trim());nt&&(this.styles[nt]=new Property(g,nt,rt))});const{definitions:j}=g,_e=this.getAttribute("id");_e.hasValue()&&(j[_e.getString()]||(j[_e.getString()]=this)),Array.from($.childNodes).forEach(et=>{if(et.nodeType===1)this.addChild(et);else if(b&&(et.nodeType===3||et.nodeType===4)){const tt=g.createTextNode(et);tt.getText().length>0&&this.addChild(tt)}})}}Element.ignoreChildTypes=["title"];class UnknownElement extends Element{constructor(g,$,b){super(g,$,b)}}function wrapFontFamily(d){const g=d.trim();return/^('|")/.test(g)?g:'"'.concat(g,'"')}function prepareFontFamily(d){return typeof process>"u"?d:d.trim().split(",").map(wrapFontFamily).join(",")}function prepareFontStyle(d){if(!d)return"";const g=d.trim().toLowerCase();switch(g){case"normal":case"italic":case"oblique":case"inherit":case"initial":case"unset":return g;default:return/^oblique\s+(-|)\d+deg$/.test(g)?g:""}}function prepareFontWeight(d){if(!d)return"";const g=d.trim().toLowerCase();switch(g){case"normal":case"bold":case"lighter":case"bolder":case"inherit":case"initial":case"unset":return g;default:return/^[\d.]+$/.test(g)?g:""}}class Font{static parse(){let g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",$=arguments.length>1?arguments[1]:void 0,b="",j="",_e="",et="",tt="";const nt=compressSpaces(g).trim().split(" "),rt={fontSize:!1,fontStyle:!1,fontWeight:!1,fontVariant:!1};return nt.forEach(it=>{switch(!0){case(!rt.fontStyle&&Font.styles.includes(it)):it!=="inherit"&&(b=it),rt.fontStyle=!0;break;case(!rt.fontVariant&&Font.variants.includes(it)):it!=="inherit"&&(j=it),rt.fontStyle=!0,rt.fontVariant=!0;break;case(!rt.fontWeight&&Font.weights.includes(it)):it!=="inherit"&&(_e=it),rt.fontStyle=!0,rt.fontVariant=!0,rt.fontWeight=!0;break;case!rt.fontSize:it!=="inherit"&&(et=it.split("/")[0]||""),rt.fontStyle=!0,rt.fontVariant=!0,rt.fontWeight=!0,rt.fontSize=!0;break;default:it!=="inherit"&&(tt+=it)}}),new Font(b,j,_e,et,tt,$)}toString(){return[prepareFontStyle(this.fontStyle),this.fontVariant,prepareFontWeight(this.fontWeight),this.fontSize,prepareFontFamily(this.fontFamily)].join(" ").trim()}constructor(g,$,b,j,_e,et){const tt=et?typeof et=="string"?Font.parse(et):et:{};this.fontFamily=_e||tt.fontFamily,this.fontSize=j||tt.fontSize,this.fontStyle=g||tt.fontStyle,this.fontWeight=b||tt.fontWeight,this.fontVariant=$||tt.fontVariant}}Font.styles="normal|italic|oblique|inherit";Font.variants="normal|small-caps|inherit";Font.weights="normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900|inherit";class BoundingBox{get x(){return this.x1}get y(){return this.y1}get width(){return this.x2-this.x1}get height(){return this.y2-this.y1}addPoint(g,$){typeof g<"u"&&((isNaN(this.x1)||isNaN(this.x2))&&(this.x1=g,this.x2=g),gthis.x2&&(this.x2=g)),typeof $<"u"&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=$,this.y2=$),$this.y2&&(this.y2=$))}addX(g){this.addPoint(g,0)}addY(g){this.addPoint(0,g)}addBoundingBox(g){if(!g)return;const{x1:$,y1:b,x2:j,y2:_e}=g;this.addPoint($,b),this.addPoint(j,_e)}sumCubic(g,$,b,j,_e){return Math.pow(1-g,3)*$+3*Math.pow(1-g,2)*g*b+3*(1-g)*Math.pow(g,2)*j+Math.pow(g,3)*_e}bezierCurveAdd(g,$,b,j,_e){const et=6*$-12*b+6*j,tt=-3*$+9*b-9*j+3*_e,nt=3*b-3*$;if(tt===0){if(et===0)return;const ut=-nt/et;01&&arguments[1]!==void 0?arguments[1]:!1;if(!$){const b=this.getStyle("fill"),j=this.getStyle("fill-opacity"),_e=this.getStyle("stroke"),et=this.getStyle("stroke-opacity");if(b.isUrlDefinition()){const at=b.getFillStyleDefinition(this,j);at&&(g.fillStyle=at)}else if(b.hasValue()){b.getString()==="currentColor"&&b.setValue(this.getStyle("color").getColor());const at=b.getColor();at!=="inherit"&&(g.fillStyle=at==="none"?"rgba(0,0,0,0)":at)}if(j.hasValue()){const at=new Property(this.document,"fill",g.fillStyle).addOpacity(j).getColor();g.fillStyle=at}if(_e.isUrlDefinition()){const at=_e.getFillStyleDefinition(this,et);at&&(g.strokeStyle=at)}else if(_e.hasValue()){_e.getString()==="currentColor"&&_e.setValue(this.getStyle("color").getColor());const at=_e.getString();at!=="inherit"&&(g.strokeStyle=at==="none"?"rgba(0,0,0,0)":at)}if(et.hasValue()){const at=new Property(this.document,"stroke",g.strokeStyle).addOpacity(et).getString();g.strokeStyle=at}const tt=this.getStyle("stroke-width");if(tt.hasValue()){const at=tt.getPixels();g.lineWidth=at||PSEUDO_ZERO}const nt=this.getStyle("stroke-linecap"),rt=this.getStyle("stroke-linejoin"),it=this.getStyle("stroke-miterlimit"),st=this.getStyle("stroke-dasharray"),ut=this.getStyle("stroke-dashoffset");if(nt.hasValue()&&(g.lineCap=nt.getString()),rt.hasValue()&&(g.lineJoin=rt.getString()),it.hasValue()&&(g.miterLimit=it.getNumber()),st.hasValue()&&st.getString()!=="none"){const at=toNumbers(st.getString());typeof g.setLineDash<"u"?g.setLineDash(at):typeof g.webkitLineDash<"u"?g.webkitLineDash=at:typeof g.mozDash<"u"&&!(at.length===1&&at[0]===0)&&(g.mozDash=at);const ht=ut.getPixels();typeof g.lineDashOffset<"u"?g.lineDashOffset=ht:typeof g.webkitLineDashOffset<"u"?g.webkitLineDashOffset=ht:typeof g.mozDashOffset<"u"&&(g.mozDashOffset=ht)}}if(this.modifiedEmSizeStack=!1,typeof g.font<"u"){const b=this.getStyle("font"),j=this.getStyle("font-style"),_e=this.getStyle("font-variant"),et=this.getStyle("font-weight"),tt=this.getStyle("font-size"),nt=this.getStyle("font-family"),rt=new Font(j.getString(),_e.getString(),et.getString(),tt.hasValue()?"".concat(tt.getPixels(!0),"px"):"",nt.getString(),Font.parse(b.getString(),g.font));j.setValue(rt.fontStyle),_e.setValue(rt.fontVariant),et.setValue(rt.fontWeight),tt.setValue(rt.fontSize),nt.setValue(rt.fontFamily),g.font=rt.toString(),tt.isPixels()&&(this.document.emSize=tt.getPixels(),this.modifiedEmSizeStack=!0)}$||(this.applyEffects(g),g.globalAlpha=this.calculateOpacity())}clearContext(g){super.clearContext(g),this.modifiedEmSizeStack&&this.document.popEmSize()}constructor(...g){super(...g),this.modifiedEmSizeStack=!1}}class TextElement extends RenderedElement{setContext(g){let $=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;super.setContext(g,$);const b=this.getStyle("dominant-baseline").getTextBaseline()||this.getStyle("alignment-baseline").getTextBaseline();b&&(g.textBaseline=b)}initializeCoordinates(){this.x=0,this.y=0,this.leafTexts=[],this.textChunkStart=0,this.minX=Number.POSITIVE_INFINITY,this.maxX=Number.NEGATIVE_INFINITY}getBoundingBox(g){if(this.type!=="text")return this.getTElementBoundingBox(g);this.initializeCoordinates(),this.adjustChildCoordinatesRecursive(g);let $=null;return this.children.forEach((b,j)=>{const _e=this.getChildBoundingBox(g,this,this,j);$?$.addBoundingBox(_e):$=_e}),$}getFontSize(){const{document:g,parent:$}=this,b=Font.parse(g.ctx.font).fontSize;return $.getStyle("font-size").getNumber(b)}getTElementBoundingBox(g){const $=this.getFontSize();return new BoundingBox(this.x,this.y-$,this.x+this.measureText(g),this.y)}getGlyph(g,$,b){const j=$[b];let _e;if(g.isArabic){var et;const tt=$.length,nt=$[b-1],rt=$[b+1];let it="isolated";(b===0||nt===" ")&&b0&&nt!==" "&&b0&&nt!==" "&&(b===tt-1||rt===" ")&&(it="initial"),_e=((et=g.arabicGlyphs[j])===null||et===void 0?void 0:et[it])||g.glyphs[j]}else _e=g.glyphs[j];return _e||(_e=g.missingGlyph),_e}getText(){return""}getTextFromNode(g){const $=g||this.node,b=Array.from($.parentNode.childNodes),j=b.indexOf($),_e=b.length-1;let et=compressSpaces($.textContent||"");return j===0&&(et=trimLeft(et)),j===_e&&(et=trimRight(et)),et}renderChildren(g){if(this.type!=="text"){this.renderTElementChildren(g);return}this.initializeCoordinates(),this.adjustChildCoordinatesRecursive(g),this.children.forEach((b,j)=>{this.renderChild(g,this,this,j)});const{mouse:$}=this.document.screen;$.isWorking()&&$.checkBoundingBox(this,this.getBoundingBox(g))}renderTElementChildren(g){const{document:$,parent:b}=this,j=this.getText(),_e=b.getStyle("font-family").getDefinition();if(_e){const{unitsPerEm:nt}=_e.fontFace,rt=Font.parse($.ctx.font),it=b.getStyle("font-size").getNumber(rt.fontSize),st=b.getStyle("font-style").getString(rt.fontStyle),ut=it/nt,at=_e.isRTL?j.split("").reverse().join(""):j,ht=toNumbers(b.getAttribute("dx").getString()),ct=at.length;for(let vt=0;vt=this.leafTexts.length)return;const g=this.leafTexts[this.textChunkStart],$=g.getStyle("text-anchor").getString("start"),b=!1;let j=0;$==="start"&&!b||$==="end"&&b?j=g.x-this.minX:$==="end"&&!b||$==="start"&&b?j=g.x-this.maxX:j=g.x-(this.minX+this.maxX)/2;for(let _e=this.textChunkStart;_e{this.adjustChildCoordinatesRecursiveCore(g,this,this,b)}),this.applyAnchoring()}adjustChildCoordinatesRecursiveCore(g,$,b,j){const _e=b.children[j];_e.children.length>0?_e.children.forEach((et,tt)=>{$.adjustChildCoordinatesRecursiveCore(g,$,_e,tt)}):this.adjustChildCoordinates(g,$,b,j)}adjustChildCoordinates(g,$,b,j){const _e=b.children[j];if(typeof _e.measureText!="function")return _e;g.save(),_e.setContext(g,!0);const et=_e.getAttribute("x"),tt=_e.getAttribute("y"),nt=_e.getAttribute("dx"),rt=_e.getAttribute("dy"),it=_e.getStyle("font-family").getDefinition(),st=Boolean(it==null?void 0:it.isRTL);j===0&&(et.hasValue()||et.setValue(_e.getInheritedAttribute("x")),tt.hasValue()||tt.setValue(_e.getInheritedAttribute("y")),nt.hasValue()||nt.setValue(_e.getInheritedAttribute("dx")),rt.hasValue()||rt.setValue(_e.getInheritedAttribute("dy")));const ut=_e.measureText(g);return st&&($.x-=ut),et.hasValue()?($.applyAnchoring(),_e.x=et.getPixels("x"),nt.hasValue()&&(_e.x+=nt.getPixels("x"))):(nt.hasValue()&&($.x+=nt.getPixels("x")),_e.x=$.x),$.x=_e.x,st||($.x+=ut),tt.hasValue()?(_e.y=tt.getPixels("y"),rt.hasValue()&&(_e.y+=rt.getPixels("y"))):(rt.hasValue()&&($.y+=rt.getPixels("y")),_e.y=$.y),$.y=_e.y,$.leafTexts.push(_e),$.minX=Math.min($.minX,_e.x,_e.x+ut),$.maxX=Math.max($.maxX,_e.x,_e.x+ut),_e.clearContext(g),g.restore(),_e}getChildBoundingBox(g,$,b,j){const _e=b.children[j];if(typeof _e.getBoundingBox!="function")return null;const et=_e.getBoundingBox(g);return et&&_e.children.forEach((tt,nt)=>{const rt=$.getChildBoundingBox(g,$,_e,nt);et.addBoundingBox(rt)}),et}renderChild(g,$,b,j){const _e=b.children[j];_e.render(g),_e.children.forEach((et,tt)=>{$.renderChild(g,$,_e,tt)})}measureText(g){const{measureCache:$}=this;if(~$)return $;const b=this.getText(),j=this.measureTargetText(g,b);return this.measureCache=j,j}measureTargetText(g,$){if(!$.length)return 0;const{parent:b}=this,j=b.getStyle("font-family").getDefinition();if(j){const et=this.getFontSize(),tt=j.isRTL?$.split("").reverse().join(""):$,nt=toNumbers(b.getAttribute("dx").getString()),rt=tt.length;let it=0;for(let st=0;st0?"":this.getTextFromNode()}}class TextNode extends TSpanElement{constructor(...g){super(...g),this.type="textNode"}}class PathParser extends _{reset(){this.i=-1,this.command=null,this.previousCommand=null,this.start=new Point(0,0),this.control=new Point(0,0),this.current=new Point(0,0),this.points=[],this.angles=[]}isEnd(){const{i:g,commands:$}=this;return g>=$.length-1}next(){const g=this.commands[++this.i];return this.previousCommand=this.command,this.command=g,g}getPoint(){let g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"x",$=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"y";const b=new Point(this.command[g],this.command[$]);return this.makeAbsolute(b)}getAsControlPoint(g,$){const b=this.getPoint(g,$);return this.control=b,b}getAsCurrentPoint(g,$){const b=this.getPoint(g,$);return this.current=b,b}getReflectedControlPoint(){const g=this.previousCommand.type;if(g!==_.CURVE_TO&&g!==_.SMOOTH_CURVE_TO&&g!==_.QUAD_TO&&g!==_.SMOOTH_QUAD_TO)return this.current;const{current:{x:$,y:b},control:{x:j,y:_e}}=this;return new Point(2*$-j,2*b-_e)}makeAbsolute(g){if(this.command.relative){const{x:$,y:b}=this.current;g.x+=$,g.y+=b}return g}addMarker(g,$,b){const{points:j,angles:_e}=this;b&&_e.length>0&&!_e[_e.length-1]&&(_e[_e.length-1]=j[j.length-1].angleTo(b)),this.addMarkerAngle(g,$?$.angleTo(g):null)}addMarkerAngle(g,$){this.points.push(g),this.angles.push($)}getMarkerPoints(){return this.points}getMarkerAngles(){const{angles:g}=this,$=g.length;for(let b=0;b<$;b++)if(!g[b]){for(let j=b+1;j<$;j++)if(g[j]){g[b]=g[j];break}}return g}constructor(g){super(g.replace(/([+\-.])\s+/gm,"$1").replace(/[^MmZzLlHhVvCcSsQqTtAae\d\s.,+-].*/g,"")),this.control=new Point(0,0),this.start=new Point(0,0),this.current=new Point(0,0),this.command=null,this.commands=this.commands,this.i=-1,this.previousCommand=null,this.points=[],this.angles=[]}}class PathElement extends RenderedElement{path(g){const{pathParser:$}=this,b=new BoundingBox;for($.reset(),g&&g.beginPath();!$.isEnd();)switch($.next().type){case PathParser.MOVE_TO:this.pathM(g,b);break;case PathParser.LINE_TO:this.pathL(g,b);break;case PathParser.HORIZ_LINE_TO:this.pathH(g,b);break;case PathParser.VERT_LINE_TO:this.pathV(g,b);break;case PathParser.CURVE_TO:this.pathC(g,b);break;case PathParser.SMOOTH_CURVE_TO:this.pathS(g,b);break;case PathParser.QUAD_TO:this.pathQ(g,b);break;case PathParser.SMOOTH_QUAD_TO:this.pathT(g,b);break;case PathParser.ARC:this.pathA(g,b);break;case PathParser.CLOSE_PATH:this.pathZ(g,b);break}return b}getBoundingBox(g){return this.path()}getMarkers(){const{pathParser:g}=this,$=g.getMarkerPoints(),b=g.getMarkerAngles();return $.map((_e,et)=>[_e,b[et]])}renderChildren(g){this.path(g),this.document.screen.mouse.checkPath(this,g);const $=this.getStyle("fill-rule");g.fillStyle!==""&&($.getString("inherit")!=="inherit"?g.fill($.getString()):g.fill()),g.strokeStyle!==""&&(this.getAttribute("vector-effect").getString()==="non-scaling-stroke"?(g.save(),g.setTransform(1,0,0,1,0,0),g.stroke(),g.restore()):g.stroke());const b=this.getMarkers();if(b){const j=b.length-1,_e=this.getStyle("marker-start"),et=this.getStyle("marker-mid"),tt=this.getStyle("marker-end");if(_e.isUrlDefinition()){const nt=_e.getDefinition(),[rt,it]=b[0];nt.render(g,rt,it)}if(et.isUrlDefinition()){const nt=et.getDefinition();for(let rt=1;rt1&&(j*=Math.sqrt(ut),_e*=Math.sqrt(ut));let at=(tt===nt?-1:1)*Math.sqrt((Math.pow(j,2)*Math.pow(_e,2)-Math.pow(j,2)*Math.pow(st.y,2)-Math.pow(_e,2)*Math.pow(st.x,2))/(Math.pow(j,2)*Math.pow(st.y,2)+Math.pow(_e,2)*Math.pow(st.x,2)));isNaN(at)&&(at=0);const ht=new Point(at*j*st.y/_e,at*-_e*st.x/j),ct=new Point(($.x+it.x)/2+Math.cos(rt)*ht.x-Math.sin(rt)*ht.y,($.y+it.y)/2+Math.sin(rt)*ht.x+Math.cos(rt)*ht.y),vt=vectorsAngle([1,0],[(st.x-ht.x)/j,(st.y-ht.y)/_e]),ft=[(st.x-ht.x)/j,(st.y-ht.y)/_e],gt=[(-st.x-ht.x)/j,(-st.y-ht.y)/_e];let pt=vectorsAngle(ft,gt);return vectorsRatio(ft,gt)<=-1&&(pt=Math.PI),vectorsRatio(ft,gt)>=1&&(pt=0),{currentPoint:it,rX:j,rY:_e,sweepFlag:nt,xAxisRotation:rt,centp:ct,a1:vt,ad:pt}}pathA(g,$){const{pathParser:b}=this,{currentPoint:j,rX:_e,rY:et,sweepFlag:tt,xAxisRotation:nt,centp:rt,a1:it,ad:st}=PathElement.pathA(b),ut=1-tt?1:-1,at=it+ut*(st/2),ht=new Point(rt.x+_e*Math.cos(at),rt.y+et*Math.sin(at));if(b.addMarkerAngle(ht,at-ut*Math.PI/2),b.addMarkerAngle(j,at-ut*Math.PI),$.addPoint(j.x,j.y),g&&!isNaN(it)&&!isNaN(st)){const ct=_e>et?_e:et,vt=_e>et?1:_e/et,ft=_e>et?et/_e:1;g.translate(rt.x,rt.y),g.rotate(nt),g.scale(vt,ft),g.arc(0,0,ct,it,it+st,Boolean(1-tt)),g.scale(1/vt,1/ft),g.rotate(-nt),g.translate(-rt.x,-rt.y)}}static pathZ(g){g.current=g.start}pathZ(g,$){PathElement.pathZ(this.pathParser),g&&$.x1!==$.x2&&$.y1!==$.y2&&g.closePath()}constructor(g,$,b){super(g,$,b),this.type="path",this.pathParser=new PathParser(this.getAttribute("d").getString())}}class SVGElement extends RenderedElement{setContext(g){var $;const{document:b}=this,{screen:j,window:_e}=b,et=g.canvas;if(j.setDefaults(g),"style"in et&&typeof g.font<"u"&&_e&&typeof _e.getComputedStyle<"u"){g.font=_e.getComputedStyle(et).getPropertyValue("font");const gt=new Property(b,"fontSize",Font.parse(g.font).fontSize);gt.hasValue()&&(b.rootEmSize=gt.getPixels("y"),b.emSize=b.rootEmSize)}this.getAttribute("x").hasValue()||this.getAttribute("x",!0).setValue(0),this.getAttribute("y").hasValue()||this.getAttribute("y",!0).setValue(0);let{width:tt,height:nt}=j.viewPort;this.getStyle("width").hasValue()||this.getStyle("width",!0).setValue("100%"),this.getStyle("height").hasValue()||this.getStyle("height",!0).setValue("100%"),this.getStyle("color").hasValue()||this.getStyle("color",!0).setValue("black");const rt=this.getAttribute("refX"),it=this.getAttribute("refY"),st=this.getAttribute("viewBox"),ut=st.hasValue()?toNumbers(st.getString()):null,at=!this.root&&this.getStyle("overflow").getValue("hidden")!=="visible";let ht=0,ct=0,vt=0,ft=0;ut&&(ht=ut[0],ct=ut[1]),this.root||(tt=this.getStyle("width").getPixels("x"),nt=this.getStyle("height").getPixels("y"),this.type==="marker"&&(vt=ht,ft=ct,ht=0,ct=0)),j.viewPort.setCurrent(tt,nt),this.node&&(!this.parent||(($=this.node.parentNode)===null||$===void 0?void 0:$.nodeName)==="foreignObject")&&this.getStyle("transform",!1,!0).hasValue()&&!this.getStyle("transform-origin",!1,!0).hasValue()&&this.getStyle("transform-origin",!0,!0).setValue("50% 50%"),super.setContext(g),g.translate(this.getAttribute("x").getPixels("x"),this.getAttribute("y").getPixels("y")),ut&&(tt=ut[2],nt=ut[3]),b.setViewBox({ctx:g,aspectRatio:this.getAttribute("preserveAspectRatio").getString(),width:j.viewPort.width,desiredWidth:tt,height:j.viewPort.height,desiredHeight:nt,minX:ht,minY:ct,refX:rt.getValue(),refY:it.getValue(),clip:at,clipX:vt,clipY:ft}),ut&&(j.viewPort.removeCurrent(),j.viewPort.setCurrent(tt,nt))}clearContext(g){super.clearContext(g),this.document.screen.viewPort.removeCurrent()}resize(g){let $=arguments.length>1&&arguments[1]!==void 0?arguments[1]:g,b=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;const j=this.getAttribute("width",!0),_e=this.getAttribute("height",!0),et=this.getAttribute("viewBox"),tt=this.getAttribute("style"),nt=j.getNumber(0),rt=_e.getNumber(0);if(b)if(typeof b=="string")this.getAttribute("preserveAspectRatio",!0).setValue(b);else{const it=this.getAttribute("preserveAspectRatio");it.hasValue()&&it.setValue(it.getString().replace(/^\s*(\S.*\S)\s*$/,"$1"))}if(j.setValue(g),_e.setValue($),et.hasValue()||et.setValue("0 0 ".concat(nt||g," ").concat(rt||$)),tt.hasValue()){const it=this.getStyle("width"),st=this.getStyle("height");it.hasValue()&&it.setValue("".concat(g,"px")),st.hasValue()&&st.setValue("".concat($,"px"))}}constructor(...g){super(...g),this.type="svg",this.root=!1}}class RectElement extends PathElement{path(g){const $=this.getAttribute("x").getPixels("x"),b=this.getAttribute("y").getPixels("y"),j=this.getStyle("width",!1,!0).getPixels("x"),_e=this.getStyle("height",!1,!0).getPixels("y"),et=this.getAttribute("rx"),tt=this.getAttribute("ry");let nt=et.getPixels("x"),rt=tt.getPixels("y");if(et.hasValue()&&!tt.hasValue()&&(rt=nt),tt.hasValue()&&!et.hasValue()&&(nt=rt),nt=Math.min(nt,j/2),rt=Math.min(rt,_e/2),g){const it=4*((Math.sqrt(2)-1)/3);g.beginPath(),_e>0&&j>0&&(g.moveTo($+nt,b),g.lineTo($+j-nt,b),g.bezierCurveTo($+j-nt+it*nt,b,$+j,b+rt-it*rt,$+j,b+rt),g.lineTo($+j,b+_e-rt),g.bezierCurveTo($+j,b+_e-rt+it*rt,$+j-nt+it*nt,b+_e,$+j-nt,b+_e),g.lineTo($+nt,b+_e),g.bezierCurveTo($+nt-it*nt,b+_e,$,b+_e-rt+it*rt,$,b+_e-rt),g.lineTo($,b+rt),g.bezierCurveTo($,b+rt-it*rt,$+nt-it*nt,b,$+nt,b),g.closePath())}return new BoundingBox($,b,$+j,b+_e)}getMarkers(){return null}constructor(...g){super(...g),this.type="rect"}}class CircleElement extends PathElement{path(g){const $=this.getAttribute("cx").getPixels("x"),b=this.getAttribute("cy").getPixels("y"),j=this.getAttribute("r").getPixels();return g&&j>0&&(g.beginPath(),g.arc($,b,j,0,Math.PI*2,!1),g.closePath()),new BoundingBox($-j,b-j,$+j,b+j)}getMarkers(){return null}constructor(...g){super(...g),this.type="circle"}}class EllipseElement extends PathElement{path(g){const $=4*((Math.sqrt(2)-1)/3),b=this.getAttribute("rx").getPixels("x"),j=this.getAttribute("ry").getPixels("y"),_e=this.getAttribute("cx").getPixels("x"),et=this.getAttribute("cy").getPixels("y");return g&&b>0&&j>0&&(g.beginPath(),g.moveTo(_e+b,et),g.bezierCurveTo(_e+b,et+$*j,_e+$*b,et+j,_e,et+j),g.bezierCurveTo(_e-$*b,et+j,_e-b,et+$*j,_e-b,et),g.bezierCurveTo(_e-b,et-$*j,_e-$*b,et-j,_e,et-j),g.bezierCurveTo(_e+$*b,et-j,_e+b,et-$*j,_e+b,et),g.closePath()),new BoundingBox(_e-b,et-j,_e+b,et+j)}getMarkers(){return null}constructor(...g){super(...g),this.type="ellipse"}}class LineElement extends PathElement{getPoints(){return[new Point(this.getAttribute("x1").getPixels("x"),this.getAttribute("y1").getPixels("y")),new Point(this.getAttribute("x2").getPixels("x"),this.getAttribute("y2").getPixels("y"))]}path(g){const[{x:$,y:b},{x:j,y:_e}]=this.getPoints();return g&&(g.beginPath(),g.moveTo($,b),g.lineTo(j,_e)),new BoundingBox($,b,j,_e)}getMarkers(){const[g,$]=this.getPoints(),b=g.angleTo($);return[[g,b],[$,b]]}constructor(...g){super(...g),this.type="line"}}class PolylineElement extends PathElement{path(g){const{points:$}=this,[{x:b,y:j}]=$,_e=new BoundingBox(b,j);return g&&(g.beginPath(),g.moveTo(b,j)),$.forEach(et=>{let{x:tt,y:nt}=et;_e.addPoint(tt,nt),g&&g.lineTo(tt,nt)}),_e}getMarkers(){const{points:g}=this,$=g.length-1,b=[];return g.forEach((j,_e)=>{_e!==$&&b.push([j,j.angleTo(g[_e+1])])}),b.length>0&&b.push([g[g.length-1],b[b.length-1][1]]),b}constructor(g,$,b){super(g,$,b),this.type="polyline",this.points=[],this.points=Point.parsePath(this.getAttribute("points").getString())}}class PolygonElement extends PolylineElement{path(g){const $=super.path(g),[{x:b,y:j}]=this.points;return g&&(g.lineTo(b,j),g.closePath()),$}constructor(...g){super(...g),this.type="polygon"}}class PatternElement extends Element{createPattern(g,$,b){const j=this.getStyle("width").getPixels("x",!0),_e=this.getStyle("height").getPixels("y",!0),et=new SVGElement(this.document,null);et.attributes.viewBox=new Property(this.document,"viewBox",this.getAttribute("viewBox").getValue()),et.attributes.width=new Property(this.document,"width","".concat(j,"px")),et.attributes.height=new Property(this.document,"height","".concat(_e,"px")),et.attributes.transform=new Property(this.document,"transform",this.getAttribute("patternTransform").getValue()),et.children=this.children;const tt=this.document.createCanvas(j,_e),nt=tt.getContext("2d"),rt=this.getAttribute("x"),it=this.getAttribute("y");rt.hasValue()&&it.hasValue()&&nt.translate(rt.getPixels("x",!0),it.getPixels("y",!0)),b.hasValue()?this.styles["fill-opacity"]=b:Reflect.deleteProperty(this.styles,"fill-opacity");for(let ut=-1;ut<=1;ut++)for(let at=-1;at<=1;at++)nt.save(),et.attributes.x=new Property(this.document,"x",ut*tt.width),et.attributes.y=new Property(this.document,"y",at*tt.height),et.render(nt),nt.restore();return g.createPattern(tt,"repeat")}constructor(...g){super(...g),this.type="pattern"}}class MarkerElement extends Element{render(g,$,b){if(!$)return;const{x:j,y:_e}=$,et=this.getAttribute("orient").getString("auto"),tt=this.getAttribute("markerUnits").getString("strokeWidth");g.translate(j,_e),et==="auto"&&g.rotate(b),tt==="strokeWidth"&&g.scale(g.lineWidth,g.lineWidth),g.save();const nt=new SVGElement(this.document);nt.type=this.type,nt.attributes.viewBox=new Property(this.document,"viewBox",this.getAttribute("viewBox").getValue()),nt.attributes.refX=new Property(this.document,"refX",this.getAttribute("refX").getValue()),nt.attributes.refY=new Property(this.document,"refY",this.getAttribute("refY").getValue()),nt.attributes.width=new Property(this.document,"width",this.getAttribute("markerWidth").getValue()),nt.attributes.height=new Property(this.document,"height",this.getAttribute("markerHeight").getValue()),nt.attributes.overflow=new Property(this.document,"overflow",this.getAttribute("overflow").getValue()),nt.attributes.fill=new Property(this.document,"fill",this.getAttribute("fill").getColor("black")),nt.attributes.stroke=new Property(this.document,"stroke",this.getAttribute("stroke").getValue("none")),nt.children=this.children,nt.render(g),g.restore(),tt==="strokeWidth"&&g.scale(1/g.lineWidth,1/g.lineWidth),et==="auto"&&g.rotate(-b),g.translate(-j,-_e)}constructor(...g){super(...g),this.type="marker"}}class DefsElement extends Element{render(){}constructor(...g){super(...g),this.type="defs"}}class GElement extends RenderedElement{getBoundingBox(g){const $=new BoundingBox;return this.children.forEach(b=>{$.addBoundingBox(b.getBoundingBox(g))}),$}constructor(...g){super(...g),this.type="g"}}class GradientElement extends Element{getGradientUnits(){return this.getAttribute("gradientUnits").getString("objectBoundingBox")}createGradient(g,$,b){let j=this;this.getHrefAttribute().hasValue()&&(j=this.getHrefAttribute().getDefinition(),this.inheritStopContainer(j));const{stops:_e}=j,et=this.getGradient(g,$);if(!et)return this.addParentOpacity(b,_e[_e.length-1].color);if(_e.forEach(tt=>{et.addColorStop(tt.offset,this.addParentOpacity(b,tt.color))}),this.getAttribute("gradientTransform").hasValue()){const{document:tt}=this,{MAX_VIRTUAL_PIXELS:nt}=Screen,{viewPort:rt}=tt.screen,it=rt.getRoot(),st=new RectElement(tt);st.attributes.x=new Property(tt,"x",-nt/3),st.attributes.y=new Property(tt,"y",-nt/3),st.attributes.width=new Property(tt,"width",nt),st.attributes.height=new Property(tt,"height",nt);const ut=new GElement(tt);ut.attributes.transform=new Property(tt,"transform",this.getAttribute("gradientTransform").getValue()),ut.children=[st];const at=new SVGElement(tt);at.attributes.x=new Property(tt,"x",0),at.attributes.y=new Property(tt,"y",0),at.attributes.width=new Property(tt,"width",it.width),at.attributes.height=new Property(tt,"height",it.height),at.children=[ut];const ht=tt.createCanvas(it.width,it.height),ct=ht.getContext("2d");return ct.fillStyle=et,at.render(ct),ct.createPattern(ht,"no-repeat")}return et}inheritStopContainer(g){this.attributesToInherit.forEach($=>{!this.getAttribute($).hasValue()&&g.getAttribute($).hasValue()&&this.getAttribute($,!0).setValue(g.getAttribute($).getValue())})}addParentOpacity(g,$){return g.hasValue()?new Property(this.document,"color",$).addOpacity(g).getColor():$}constructor(g,$,b){super(g,$,b),this.attributesToInherit=["gradientUnits"],this.stops=[];const{stops:j,children:_e}=this;_e.forEach(et=>{et.type==="stop"&&j.push(et)})}}class LinearGradientElement extends GradientElement{getGradient(g,$){const b=this.getGradientUnits()==="objectBoundingBox",j=b?$.getBoundingBox(g):null;if(b&&!j)return null;!this.getAttribute("x1").hasValue()&&!this.getAttribute("y1").hasValue()&&!this.getAttribute("x2").hasValue()&&!this.getAttribute("y2").hasValue()&&(this.getAttribute("x1",!0).setValue(0),this.getAttribute("y1",!0).setValue(0),this.getAttribute("x2",!0).setValue(1),this.getAttribute("y2",!0).setValue(0));const _e=b?j.x+j.width*this.getAttribute("x1").getNumber():this.getAttribute("x1").getPixels("x"),et=b?j.y+j.height*this.getAttribute("y1").getNumber():this.getAttribute("y1").getPixels("y"),tt=b?j.x+j.width*this.getAttribute("x2").getNumber():this.getAttribute("x2").getPixels("x"),nt=b?j.y+j.height*this.getAttribute("y2").getNumber():this.getAttribute("y2").getPixels("y");return _e===tt&&et===nt?null:g.createLinearGradient(_e,et,tt,nt)}constructor(g,$,b){super(g,$,b),this.type="linearGradient",this.attributesToInherit.push("x1","y1","x2","y2")}}class RadialGradientElement extends GradientElement{getGradient(g,$){const b=this.getGradientUnits()==="objectBoundingBox",j=$.getBoundingBox(g);if(b&&!j)return null;this.getAttribute("cx").hasValue()||this.getAttribute("cx",!0).setValue("50%"),this.getAttribute("cy").hasValue()||this.getAttribute("cy",!0).setValue("50%"),this.getAttribute("r").hasValue()||this.getAttribute("r",!0).setValue("50%");const _e=b?j.x+j.width*this.getAttribute("cx").getNumber():this.getAttribute("cx").getPixels("x"),et=b?j.y+j.height*this.getAttribute("cy").getNumber():this.getAttribute("cy").getPixels("y");let tt=_e,nt=et;this.getAttribute("fx").hasValue()&&(tt=b?j.x+j.width*this.getAttribute("fx").getNumber():this.getAttribute("fx").getPixels("x")),this.getAttribute("fy").hasValue()&&(nt=b?j.y+j.height*this.getAttribute("fy").getNumber():this.getAttribute("fy").getPixels("y"));const rt=b?(j.width+j.height)/2*this.getAttribute("r").getNumber():this.getAttribute("r").getPixels(),it=this.getAttribute("fr").getPixels();return g.createRadialGradient(tt,nt,it,_e,et,rt)}constructor(g,$,b){super(g,$,b),this.type="radialGradient",this.attributesToInherit.push("cx","cy","r","fx","fy","fr")}}class StopElement extends Element{constructor(g,$,b){super(g,$,b),this.type="stop";const j=Math.max(0,Math.min(1,this.getAttribute("offset").getNumber())),_e=this.getStyle("stop-opacity");let et=this.getStyle("stop-color",!0);et.getString()===""&&et.setValue("#000"),_e.hasValue()&&(et=et.addOpacity(_e)),this.offset=j,this.color=et.getColor()}}class AnimateElement extends Element{getProperty(){const g=this.getAttribute("attributeType").getString(),$=this.getAttribute("attributeName").getString();return g==="CSS"?this.parent.getStyle($,!0):this.parent.getAttribute($,!0)}calcValue(){const{initialUnits:g}=this,{progress:$,from:b,to:j}=this.getProgress();let _e=b.getNumber()+(j.getNumber()-b.getNumber())*$;return g==="%"&&(_e*=100),"".concat(_e).concat(g)}update(g){const{parent:$}=this,b=this.getProperty();if(this.initialValue||(this.initialValue=b.getString(),this.initialUnits=b.getUnits()),this.duration>this.maxDuration){const _e=this.getAttribute("fill").getString("remove");if(this.getAttribute("repeatCount").getString()==="indefinite"||this.getAttribute("repeatDur").getString()==="indefinite")this.duration=0;else if(_e==="freeze"&&!this.frozen)this.frozen=!0,$&&b&&($.animationFrozen=!0,$.animationFrozenValue=b.getString());else if(_e==="remove"&&!this.removed)return this.removed=!0,$&&b&&b.setValue($.animationFrozen?$.animationFrozenValue:this.initialValue),!0;return!1}this.duration+=g;let j=!1;if(this.begin{const rt=_e[nt];return tt+(rt-tt)*g}).join(" ")}constructor(...g){super(...g),this.type="animateTransform"}}class FontFaceElement extends Element{constructor(g,$,b){super(g,$,b),this.type="font-face",this.ascent=this.getAttribute("ascent").getNumber(),this.descent=this.getAttribute("descent").getNumber(),this.unitsPerEm=this.getAttribute("units-per-em").getNumber()}}class GlyphElement extends PathElement{constructor(g,$,b){super(g,$,b),this.type="glyph",this.horizAdvX=this.getAttribute("horiz-adv-x").getNumber(),this.unicode=this.getAttribute("unicode").getString(),this.arabicForm=this.getAttribute("arabic-form").getString()}}class MissingGlyphElement extends GlyphElement{constructor(...g){super(...g),this.type="missing-glyph",this.horizAdvX=0}}class FontElement extends Element{render(){}constructor(g,$,b){super(g,$,b),this.type="font",this.isArabic=!1,this.glyphs={},this.arabicGlyphs={},this.isRTL=!1,this.horizAdvX=this.getAttribute("horiz-adv-x").getNumber();const{definitions:j}=g,{children:_e}=this;for(const et of _e)if(et instanceof FontFaceElement){this.fontFace=et;const tt=et.getStyle("font-family");tt.hasValue()&&(j[tt.getString()]=this)}else if(et instanceof MissingGlyphElement)this.missingGlyph=et;else if(et instanceof GlyphElement)if(et.arabicForm){this.isRTL=!0,this.isArabic=!0;const tt=this.arabicGlyphs[et.unicode];typeof tt>"u"?this.arabicGlyphs[et.unicode]={[et.arabicForm]:et}:tt[et.arabicForm]=et}else this.glyphs[et.unicode]=et}}class TRefElement extends TextElement{getText(){const g=this.getHrefAttribute().getDefinition();if(g){const $=g.children[0];if($)return $.getText()}return""}constructor(...g){super(...g),this.type="tref"}}class AElement extends TextElement{getText(){return this.text}renderChildren(g){if(this.hasText){super.renderChildren(g);const{document:$,x:b,y:j}=this,{mouse:_e}=$.screen,et=new Property($,"fontSize",Font.parse($.ctx.font).fontSize);_e.isWorking()&&_e.checkBoundingBox(this,new BoundingBox(b,j-et.getPixels("y"),b+this.measureText(g),j))}else if(this.children.length>0){const $=new GElement(this.document);$.children=this.children,$.parent=this,$.render(g)}}onClick(){const{window:g}=this.document;g&&g.open(this.getHrefAttribute().getString())}onMouseMove(){const g=this.document.ctx;g.canvas.style.cursor="pointer"}constructor(g,$,b){super(g,$,b),this.type="a";const{childNodes:j}=$,_e=j[0],et=j.length>0&&Array.from(j).every(tt=>tt.nodeType===3);this.hasText=et,this.text=et?this.getTextFromNode(_e):""}}class TextPathElement extends TextElement{getText(){return this.text}path(g){const{dataArray:$}=this;g&&g.beginPath(),$.forEach(b=>{let{type:j,points:_e}=b;switch(j){case PathParser.LINE_TO:g&&g.lineTo(_e[0],_e[1]);break;case PathParser.MOVE_TO:g&&g.moveTo(_e[0],_e[1]);break;case PathParser.CURVE_TO:g&&g.bezierCurveTo(_e[0],_e[1],_e[2],_e[3],_e[4],_e[5]);break;case PathParser.QUAD_TO:g&&g.quadraticCurveTo(_e[0],_e[1],_e[2],_e[3]);break;case PathParser.ARC:{const[et,tt,nt,rt,it,st,ut,at]=_e,ht=nt>rt?nt:rt,ct=nt>rt?1:nt/rt,vt=nt>rt?rt/nt:1;g&&(g.translate(et,tt),g.rotate(ut),g.scale(ct,vt),g.arc(0,0,ht,it,it+st,Boolean(1-at)),g.scale(1/ct,1/vt),g.rotate(-ut),g.translate(-et,-tt));break}case PathParser.CLOSE_PATH:g&&g.closePath();break}})}renderChildren(g){this.setTextData(g),g.save();const $=this.parent.getStyle("text-decoration").getString(),b=this.getFontSize(),{glyphInfo:j}=this,_e=g.fillStyle;$==="underline"&&g.beginPath(),j.forEach((et,tt)=>{const{p0:nt,p1:rt,rotation:it,text:st}=et;g.save(),g.translate(nt.x,nt.y),g.rotate(it),g.fillStyle&&g.fillText(st,0,0),g.strokeStyle&&g.strokeText(st,0,0),g.restore(),$==="underline"&&(tt===0&&g.moveTo(nt.x,nt.y+b/8),g.lineTo(rt.x,rt.y+b/5))}),$==="underline"&&(g.lineWidth=b/20,g.strokeStyle=_e,g.stroke(),g.closePath()),g.restore()}getLetterSpacingAt(){let g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return this.letterSpacingCache[g]||0}findSegmentToFitChar(g,$,b,j,_e,et,tt,nt,rt){let it=et,st=this.measureText(g,nt);nt===" "&&$==="justify"&&b-1&&(it+=this.getLetterSpacingAt(rt));const ut=this.textHeight/20,at=this.getEquidistantPointOnPath(it,ut,0),ht=this.getEquidistantPointOnPath(it+st,ut,0),ct={p0:at,p1:ht},vt=at&&ht?Math.atan2(ht.y-at.y,ht.x-at.x):0;if(tt){const ft=Math.cos(Math.PI/2+vt)*tt,gt=Math.cos(-vt)*tt;ct.p0={...at,x:at.x+ft,y:at.y+gt},ct.p1={...ht,x:ht.x+ft,y:ht.y+gt}}return it+=st,{offset:it,segment:ct,rotation:vt}}measureText(g,$){const{measuresCache:b}=this,j=$||this.getText();if(b.has(j))return b.get(j);const _e=this.measureTargetText(g,j);return b.set(j,_e),_e}setTextData(g){if(this.glyphInfo)return;const $=this.getText(),b=$.split(""),j=$.split(" ").length-1,_e=this.parent.getAttribute("dx").split().map(pt=>pt.getPixels("x")),et=this.parent.getAttribute("dy").getPixels("y"),tt=this.parent.getStyle("text-anchor").getString("start"),nt=this.getStyle("letter-spacing"),rt=this.parent.getStyle("letter-spacing");let it=0;!nt.hasValue()||nt.getValue()==="inherit"?it=rt.getPixels():nt.hasValue()&&nt.getValue()!=="initial"&&nt.getValue()!=="unset"&&(it=nt.getPixels());const st=[],ut=$.length;this.letterSpacingCache=st;for(let pt=0;ptAt===0?0:pt+yt||0,0),ht=this.measureText(g),ct=Math.max(ht+at,0);this.textWidth=ht,this.textHeight=this.getFontSize(),this.glyphInfo=[];const vt=this.getPathLength(),ft=this.getStyle("startOffset").getNumber(0)*vt;let gt=0;(tt==="middle"||tt==="center")&&(gt=-ct/2),(tt==="end"||tt==="right")&&(gt=-ct),gt+=ft,b.forEach((pt,yt)=>{const{offset:At,segment:Dt,rotation:St}=this.findSegmentToFitChar(g,tt,ct,vt,j,gt,et,pt,yt);gt=At,!(!Dt.p0||!Dt.p1)&&this.glyphInfo.push({text:b[yt],p0:Dt.p0,p1:Dt.p1,rotation:St})})}parsePathData(g){if(this.pathLength=-1,!g)return[];const $=[],{pathParser:b}=g;for(b.reset();!b.isEnd();){const{current:j}=b,_e=j?j.x:0,et=j?j.y:0,tt=b.next();let nt=tt.type,rt=[];switch(tt.type){case PathParser.MOVE_TO:this.pathM(b,rt);break;case PathParser.LINE_TO:nt=this.pathL(b,rt);break;case PathParser.HORIZ_LINE_TO:nt=this.pathH(b,rt);break;case PathParser.VERT_LINE_TO:nt=this.pathV(b,rt);break;case PathParser.CURVE_TO:this.pathC(b,rt);break;case PathParser.SMOOTH_CURVE_TO:nt=this.pathS(b,rt);break;case PathParser.QUAD_TO:this.pathQ(b,rt);break;case PathParser.SMOOTH_QUAD_TO:nt=this.pathT(b,rt);break;case PathParser.ARC:rt=this.pathA(b);break;case PathParser.CLOSE_PATH:PathElement.pathZ(b);break}tt.type!==PathParser.CLOSE_PATH?$.push({type:nt,points:rt,start:{x:_e,y:et},pathLength:this.calcLength(_e,et,nt,rt)}):$.push({type:PathParser.CLOSE_PATH,points:[],pathLength:0})}return $}pathM(g,$){const{x:b,y:j}=PathElement.pathM(g).point;$.push(b,j)}pathL(g,$){const{x:b,y:j}=PathElement.pathL(g).point;return $.push(b,j),PathParser.LINE_TO}pathH(g,$){const{x:b,y:j}=PathElement.pathH(g).point;return $.push(b,j),PathParser.LINE_TO}pathV(g,$){const{x:b,y:j}=PathElement.pathV(g).point;return $.push(b,j),PathParser.LINE_TO}pathC(g,$){const{point:b,controlPoint:j,currentPoint:_e}=PathElement.pathC(g);$.push(b.x,b.y,j.x,j.y,_e.x,_e.y)}pathS(g,$){const{point:b,controlPoint:j,currentPoint:_e}=PathElement.pathS(g);return $.push(b.x,b.y,j.x,j.y,_e.x,_e.y),PathParser.CURVE_TO}pathQ(g,$){const{controlPoint:b,currentPoint:j}=PathElement.pathQ(g);$.push(b.x,b.y,j.x,j.y)}pathT(g,$){const{controlPoint:b,currentPoint:j}=PathElement.pathT(g);return $.push(b.x,b.y,j.x,j.y),PathParser.QUAD_TO}pathA(g){let{rX:$,rY:b,sweepFlag:j,xAxisRotation:_e,centp:et,a1:tt,ad:nt}=PathElement.pathA(g);return j===0&&nt>0&&(nt-=2*Math.PI),j===1&&nt<0&&(nt+=2*Math.PI),[et.x,et.y,$,b,tt,nt,_e,j]}calcLength(g,$,b,j){let _e=0,et=null,tt=null,nt=0;switch(b){case PathParser.LINE_TO:return this.getLineLength(g,$,j[0],j[1]);case PathParser.CURVE_TO:for(_e=0,et=this.getPointOnCubicBezier(0,g,$,j[0],j[1],j[2],j[3],j[4],j[5]),nt=.01;nt<=1;nt+=.01)tt=this.getPointOnCubicBezier(nt,g,$,j[0],j[1],j[2],j[3],j[4],j[5]),_e+=this.getLineLength(et.x,et.y,tt.x,tt.y),et=tt;return _e;case PathParser.QUAD_TO:for(_e=0,et=this.getPointOnQuadraticBezier(0,g,$,j[0],j[1],j[2],j[3]),nt=.01;nt<=1;nt+=.01)tt=this.getPointOnQuadraticBezier(nt,g,$,j[0],j[1],j[2],j[3]),_e+=this.getLineLength(et.x,et.y,tt.x,tt.y),et=tt;return _e;case PathParser.ARC:{_e=0;const rt=j[4],it=j[5],st=j[4]+it;let ut=Math.PI/180;if(Math.abs(rt-st)st;nt-=ut)tt=this.getPointOnEllipticalArc(j[0],j[1],j[2],j[3],nt,0),_e+=this.getLineLength(et.x,et.y,tt.x,tt.y),et=tt;else for(nt=rt+ut;nt5&&arguments[5]!==void 0?arguments[5]:$,tt=arguments.length>6&&arguments[6]!==void 0?arguments[6]:b;const nt=(_e-b)/(j-$+PSEUDO_ZERO);let rt=Math.sqrt(g*g/(1+nt*nt));j<$&&(rt*=-1);let it=nt*rt,st=null;if(j===$)st={x:et,y:tt+it};else if((tt-b)/(et-$+PSEUDO_ZERO)===nt)st={x:et+rt,y:tt+it};else{let ut=0,at=0;const ht=this.getLineLength($,b,j,_e);if(ht$)return null;const{dataArray:_e}=this;for(const et of _e){if(et&&(et.pathLength<5e-5||b+et.pathLength+5e-5=0&&nt>st)break;j=this.getPointOnEllipticalArc(et.points[0],et.points[1],et.points[2],et.points[3],nt,et.points[6]);break}case PathParser.CURVE_TO:nt=tt/et.pathLength,nt>1&&(nt=1),j=this.getPointOnCubicBezier(nt,et.start.x,et.start.y,et.points[0],et.points[1],et.points[2],et.points[3],et.points[4],et.points[5]);break;case PathParser.QUAD_TO:nt=tt/et.pathLength,nt>1&&(nt=1),j=this.getPointOnQuadraticBezier(nt,et.start.x,et.start.y,et.points[0],et.points[1],et.points[2],et.points[3]);break}if(j)return j;break}return null}getLineLength(g,$,b,j){return Math.sqrt((b-g)*(b-g)+(j-$)*(j-$))}getPathLength(){return this.pathLength===-1&&(this.pathLength=this.dataArray.reduce((g,$)=>$.pathLength>0?g+$.pathLength:g,0)),this.pathLength}getPointOnCubicBezier(g,$,b,j,_e,et,tt,nt,rt){const it=nt*CB1(g)+et*CB2(g)+j*CB3(g)+$*CB4(g),st=rt*CB1(g)+tt*CB2(g)+_e*CB3(g)+b*CB4(g);return{x:it,y:st}}getPointOnQuadraticBezier(g,$,b,j,_e,et,tt){const nt=et*QB1(g)+j*QB2(g)+$*QB3(g),rt=tt*QB1(g)+_e*QB2(g)+b*QB3(g);return{x:nt,y:rt}}getPointOnEllipticalArc(g,$,b,j,_e,et){const tt=Math.cos(et),nt=Math.sin(et),rt={x:b*Math.cos(_e),y:j*Math.sin(_e)};return{x:g+(rt.x*tt-rt.y*nt),y:$+(rt.x*nt+rt.y*tt)}}buildEquidistantCache(g,$){const b=this.getPathLength(),j=$||.25,_e=g||b/100;if(!this.equidistantCache||this.equidistantCache.step!==_e||this.equidistantCache.precision!==j){this.equidistantCache={step:_e,precision:j,points:[]};let et=0;for(let tt=0;tt<=b;tt+=j){const nt=this.getPointOnPath(tt),rt=this.getPointOnPath(tt+j);!nt||!rt||(et+=this.getLineLength(nt.x,nt.y,rt.x,rt.y),et>=_e&&(this.equidistantCache.points.push({x:nt.x,y:nt.y,distance:tt}),et-=_e))}}}getEquidistantPointOnPath(g,$,b){if(this.buildEquidistantCache($,b),g<0||g-this.getPathLength()>5e-5)return null;const j=Math.round(g/this.getPathLength()*(this.equidistantCache.points.length-1));return this.equidistantCache.points[j]||null}constructor(g,$,b){super(g,$,b),this.type="textPath",this.textWidth=0,this.textHeight=0,this.pathLength=-1,this.glyphInfo=null,this.letterSpacingCache=[],this.measuresCache=new Map([["",0]]);const j=this.getHrefAttribute().getDefinition();this.text=this.getTextFromNode(),this.dataArray=this.parsePathData(j)}}const dataUriRegex=/^\s*data:(([^/,;]+\/[^/,;]+)(?:;([^,;=]+=[^,;=]+))?)?(?:;(base64))?,(.*)$/i;class ImageElement extends RenderedElement{async loadImage(g){try{const $=await this.document.createImage(g);this.image=$}catch($){console.error('Error while loading image "'.concat(g,'":'),$)}this.loaded=!0}async loadSvg(g){const $=dataUriRegex.exec(g);if($){const b=$[5];b&&($[4]==="base64"?this.image=atob(b):this.image=decodeURIComponent(b))}else try{const j=await(await this.document.fetch(g)).text();this.image=j}catch(b){console.error('Error while loading image "'.concat(g,'":'),b)}this.loaded=!0}renderChildren(g){const{document:$,image:b,loaded:j}=this,_e=this.getAttribute("x").getPixels("x"),et=this.getAttribute("y").getPixels("y"),tt=this.getStyle("width").getPixels("x"),nt=this.getStyle("height").getPixels("y");if(!(!j||!b||!tt||!nt)){if(g.save(),g.translate(_e,et),typeof b=="string"){const rt=$.canvg.forkString(g,b,{ignoreMouse:!0,ignoreAnimation:!0,ignoreDimensions:!0,ignoreClear:!0,offsetX:0,offsetY:0,scaleWidth:tt,scaleHeight:nt}),{documentElement:it}=rt.document;it&&(it.parent=this),rt.render()}else $.setViewBox({ctx:g,aspectRatio:this.getAttribute("preserveAspectRatio").getString(),width:tt,desiredWidth:b.width,height:nt,desiredHeight:b.height}),this.loaded&&(!("complete"in b)||b.complete)&&g.drawImage(b,0,0);g.restore()}}getBoundingBox(){const g=this.getAttribute("x").getPixels("x"),$=this.getAttribute("y").getPixels("y"),b=this.getStyle("width").getPixels("x"),j=this.getStyle("height").getPixels("y");return new BoundingBox(g,$,g+b,$+j)}constructor(g,$,b){super(g,$,b),this.type="image",this.loaded=!1;const j=this.getHrefAttribute().getString();if(!j)return;const _e=j.endsWith(".svg")||/^\s*data:image\/svg\+xml/i.test(j);g.images.push(this),_e?this.loadSvg(j):this.loadImage(j)}}class SymbolElement extends RenderedElement{render(g){}constructor(...g){super(...g),this.type="symbol"}}class SVGFontLoader{async load(g,$){try{const{document:b}=this,_e=(await b.canvg.parser.load($)).getElementsByTagName("font");Array.from(_e).forEach(et=>{const tt=b.createElement(et);b.definitions[g]=tt})}catch(b){console.error('Error while loading font "'.concat($,'":'),b)}this.loaded=!0}constructor(g){this.document=g,this.loaded=!1,g.fonts.push(this)}}class StyleElement extends Element{constructor(g,$,b){super(g,$,b),this.type="style",compressSpaces(Array.from($.childNodes).map(et=>et.textContent).join("").replace(/(\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+\/)|(^[\s]*\/\/.*)/gm,"").replace(/@import.*;/g,"")).split("}").forEach(et=>{const tt=et.trim();if(!tt)return;const nt=tt.split("{"),rt=nt[0].split(","),it=nt[1].split(";");rt.forEach(st=>{const ut=st.trim();if(!ut)return;const at=g.styles[ut]||{};if(it.forEach(ht=>{const ct=ht.indexOf(":"),vt=ht.substr(0,ct).trim(),ft=ht.substr(ct+1,ht.length-ct).trim();vt&&ft&&(at[vt]=new Property(g,vt,ft))}),g.styles[ut]=at,g.stylesSpecificity[ut]=getSelectorSpecificity(ut),ut==="@font-face"){const ht=at["font-family"].getString().replace(/"|'/g,"");at.src.getString().split(",").forEach(vt=>{if(vt.indexOf('format("svg")')>0){const ft=parseExternalUrl(vt);ft&&new SVGFontLoader(g).load(ht,ft)}})}})})}}StyleElement.parseExternalUrl=parseExternalUrl;class UseElement extends RenderedElement{setContext(g){super.setContext(g);const $=this.getAttribute("x"),b=this.getAttribute("y");$.hasValue()&&g.translate($.getPixels("x"),0),b.hasValue()&&g.translate(0,b.getPixels("y"))}path(g){const{element:$}=this;$&&$.path(g)}renderChildren(g){const{document:$,element:b}=this;if(b){let j=b;if(b.type==="symbol"&&(j=new SVGElement($),j.attributes.viewBox=new Property($,"viewBox",b.getAttribute("viewBox").getString()),j.attributes.preserveAspectRatio=new Property($,"preserveAspectRatio",b.getAttribute("preserveAspectRatio").getString()),j.attributes.overflow=new Property($,"overflow",b.getAttribute("overflow").getString()),j.children=b.children,b.styles.opacity=new Property($,"opacity",this.calculateOpacity())),j.type==="svg"){const et=this.getStyle("width",!1,!0),tt=this.getStyle("height",!1,!0);et.hasValue()&&(j.attributes.width=new Property($,"width",et.getString())),tt.hasValue()&&(j.attributes.height=new Property($,"height",tt.getString()))}const _e=j.parent;j.parent=this,j.render(g),j.parent=_e}}getBoundingBox(g){const{element:$}=this;return $?$.getBoundingBox(g):null}elementTransform(){const{document:g,element:$}=this;return $?Transform.fromElement(g,$):null}get element(){return this.cachedElement||(this.cachedElement=this.getHrefAttribute().getDefinition()),this.cachedElement}constructor(...g){super(...g),this.type="use"}}function imGet(d,g,$,b,j,_e){return d[$*b*4+g*4+_e]}function imSet(d,g,$,b,j,_e,et){d[$*b*4+g*4+_e]=et}function m(d,g,$){return d[g]*$}function c(d,g,$,b){return g+Math.cos(d)*$+Math.sin(d)*b}class FeColorMatrixElement extends Element{apply(g,$,b,j,_e){const{includeOpacity:et,matrix:tt}=this,nt=g.getImageData(0,0,j,_e);for(let rt=0;rt<_e;rt++)for(let it=0;it{at.addBoundingBox(ht.getBoundingBox(g))}),j=Math.floor(at.x1),_e=Math.floor(at.y1),et=Math.floor(at.width),tt=Math.floor(at.height)}const nt=this.removeStyles($,MaskElement.ignoreStyles),rt=b.createCanvas(j+et,_e+tt),it=rt.getContext("2d");b.screen.setDefaults(it),this.renderChildren(it),new FeColorMatrixElement(b,{nodeType:1,childNodes:[],attributes:[{nodeName:"type",value:"luminanceToAlpha"},{nodeName:"includeOpacity",value:"true"}]}).apply(it,0,0,j+et,_e+tt);const st=b.createCanvas(j+et,_e+tt),ut=st.getContext("2d");b.screen.setDefaults(ut),$.render(ut),ut.globalCompositeOperation="destination-in",ut.fillStyle=it.createPattern(rt,"no-repeat"),ut.fillRect(0,0,j+et,_e+tt),g.fillStyle=ut.createPattern(st,"no-repeat"),g.fillRect(0,0,j+et,_e+tt),this.restoreStyles($,nt)}render(g){}constructor(...g){super(...g),this.type="mask"}}MaskElement.ignoreStyles=["mask","transform","clip-path"];const noop=()=>{};class ClipPathElement extends Element{apply(g){const{document:$}=this,b=Reflect.getPrototypeOf(g),{beginPath:j,closePath:_e}=g;b&&(b.beginPath=noop,b.closePath=noop),Reflect.apply(j,g,[]),this.children.forEach(et=>{if(!("path"in et))return;let tt="elementTransform"in et?et.elementTransform():null;tt||(tt=Transform.fromElement($,et)),tt&&tt.apply(g),et.path(g),b&&(b.closePath=_e),tt&&tt.unapply(g)}),Reflect.apply(_e,g,[]),g.clip(),b&&(b.beginPath=j,b.closePath=_e)}render(g){}constructor(...g){super(...g),this.type="clipPath"}}class FilterElement extends Element{apply(g,$){const{document:b,children:j}=this,_e="getBoundingBox"in $?$.getBoundingBox(g):null;if(!_e)return;let et=0,tt=0;j.forEach(ft=>{const gt=ft.extraFilterDistance||0;et=Math.max(et,gt),tt=Math.max(tt,gt)});const nt=Math.floor(_e.width),rt=Math.floor(_e.height),it=nt+2*et,st=rt+2*tt;if(it<1||st<1)return;const ut=Math.floor(_e.x),at=Math.floor(_e.y),ht=this.removeStyles($,FilterElement.ignoreStyles),ct=b.createCanvas(it,st),vt=ct.getContext("2d");b.screen.setDefaults(vt),vt.translate(-ut+et,-at+tt),$.render(vt),j.forEach(ft=>{typeof ft.apply=="function"&&ft.apply(vt,0,0,it,st)}),g.drawImage(ct,0,0,it,st,ut-et,at-tt,it,st),this.restoreStyles($,ht)}render(g){}constructor(...g){super(...g),this.type="filter"}}FilterElement.ignoreStyles=["filter","transform","clip-path"];class FeDropShadowElement extends Element{apply(g,$,b,j,_e){}constructor(g,$,b){super(g,$,b),this.type="feDropShadow",this.addStylesFromStyleDefinition()}}class FeMorphologyElement extends Element{apply(g,$,b,j,_e){}constructor(...g){super(...g),this.type="feMorphology"}}class FeCompositeElement extends Element{apply(g,$,b,j,_e){}constructor(...g){super(...g),this.type="feComposite"}}class FeGaussianBlurElement extends Element{apply(g,$,b,j,_e){const{document:et,blurRadius:tt}=this,nt=et.window?et.window.document.body:null,rt=g.canvas;rt.id=et.getUniqueId(),nt&&(rt.style.display="none",nt.appendChild(rt)),processCanvasRGBA(rt,$,b,j,_e,tt),nt&&nt.removeChild(rt)}constructor(g,$,b){super(g,$,b),this.type="feGaussianBlur",this.blurRadius=Math.floor(this.getAttribute("stdDeviation").getNumber()),this.extraFilterDistance=this.blurRadius}}class TitleElement extends Element{constructor(...g){super(...g),this.type="title"}}class DescElement extends Element{constructor(...g){super(...g),this.type="desc"}}const elements={svg:SVGElement,rect:RectElement,circle:CircleElement,ellipse:EllipseElement,line:LineElement,polyline:PolylineElement,polygon:PolygonElement,path:PathElement,pattern:PatternElement,marker:MarkerElement,defs:DefsElement,linearGradient:LinearGradientElement,radialGradient:RadialGradientElement,stop:StopElement,animate:AnimateElement,animateColor:AnimateColorElement,animateTransform:AnimateTransformElement,font:FontElement,"font-face":FontFaceElement,"missing-glyph":MissingGlyphElement,glyph:GlyphElement,text:TextElement,tspan:TSpanElement,tref:TRefElement,a:AElement,textPath:TextPathElement,image:ImageElement,g:GElement,symbol:SymbolElement,style:StyleElement,use:UseElement,mask:MaskElement,clipPath:ClipPathElement,filter:FilterElement,feDropShadow:FeDropShadowElement,feMorphology:FeMorphologyElement,feComposite:FeCompositeElement,feColorMatrix:FeColorMatrixElement,feGaussianBlur:FeGaussianBlurElement,title:TitleElement,desc:DescElement};function createCanvas(d,g){const $=document.createElement("canvas");return $.width=d,$.height=g,$}async function createImage(d){let g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;const $=document.createElement("img");return g&&($.crossOrigin="Anonymous"),new Promise((b,j)=>{$.onload=()=>{b($)},$.onerror=(_e,et,tt,nt,rt)=>{j(rt)},$.src=d})}const DEFAULT_EM_SIZE=12;class Document{bindCreateImage(g,$){return typeof $=="boolean"?(b,j)=>g(b,typeof j=="boolean"?j:$):g}get window(){return this.screen.window}get fetch(){return this.screen.fetch}get ctx(){return this.screen.ctx}get emSize(){const{emSizeStack:g}=this;return g[g.length-1]||DEFAULT_EM_SIZE}set emSize(g){const{emSizeStack:$}=this;$.push(g)}popEmSize(){const{emSizeStack:g}=this;g.pop()}getUniqueId(){return"canvg".concat(++this.uniqueId)}isImagesLoaded(){return this.images.every(g=>g.loaded)}isFontsLoaded(){return this.fonts.every(g=>g.loaded)}createDocumentElement(g){const $=this.createElement(g.documentElement);return $.root=!0,$.addStylesFromStyleDefinition(),this.documentElement=$,$}createElement(g){const $=g.nodeName.replace(/^[^:]+:/,""),b=Document.elementTypes[$];return b?new b(this,g):new UnknownElement(this,g)}createTextNode(g){return new TextNode(this,g)}setViewBox(g){this.screen.setViewBox({document:this,...g})}constructor(g,{rootEmSize:$=DEFAULT_EM_SIZE,emSize:b=DEFAULT_EM_SIZE,createCanvas:j=Document.createCanvas,createImage:_e=Document.createImage,anonymousCrossOrigin:et}={}){this.canvg=g,this.definitions={},this.styles={},this.stylesSpecificity={},this.images=[],this.fonts=[],this.emSizeStack=[],this.uniqueId=0,this.screen=g.screen,this.rootEmSize=$,this.emSize=b,this.createCanvas=j,this.createImage=this.bindCreateImage(_e,et),this.screen.wait(()=>this.isImagesLoaded()),this.screen.wait(()=>this.isFontsLoaded())}}Document.createCanvas=createCanvas;Document.createImage=createImage;Document.elementTypes=elements;class Canvg{static async from(g,$){let b=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const _e=await new Parser(b).parse($);return new Canvg(g,_e,b)}static fromString(g,$){let b=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const _e=new Parser(b).parseFromString($);return new Canvg(g,_e,b)}fork(g,$){let b=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return Canvg.from(g,$,{...this.options,...b})}forkString(g,$){let b=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return Canvg.fromString(g,$,{...this.options,...b})}ready(){return this.screen.ready()}isReady(){return this.screen.isReady()}async render(){let g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.start({enableRedraw:!0,ignoreAnimation:!0,ignoreMouse:!0,...g}),await this.ready(),this.stop()}start(){let g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const{documentElement:$,screen:b,options:j}=this;b.start($,{enableRedraw:!0,...j,...g})}stop(){this.screen.stop()}resize(g){let $=arguments.length>1&&arguments[1]!==void 0?arguments[1]:g,b=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;this.documentElement.resize(g,$,b)}constructor(g,$,b={}){this.parser=new Parser(b),this.screen=new Screen(g,b),this.options=b;const j=new Document(this,b),_e=j.createDocumentElement($);this.document=j,this.documentElement=_e}}const preset=index.offscreen();async function toPng(d){const{width:g,height:$,svg:b}=d;console.log("svg",b);const j=new OffscreenCanvas(g,$),_e=j.getContext("2d");await(await Canvg.from(_e,b.outerHTML,preset)).render();const tt=await j.convertToBlob();return URL.createObjectURL(tt)}function Diagram({ast:d,semantics:g,diagramType:$}){const[b,j]=React.useState(null),[_e,et]=React.useState(null),[tt,nt]=React.useState(null),rt=async()=>{tt?(j(saveSvgUrl(tt)),et(await toPng({svg:tt,width:tt.clientWidth*2,height:tt.clientHeight*2}))):(j(null),et(null))},it=async st=>{nt(st),j(null),et(null)};return jsxRuntimeExports.jsxs("div",{children:[b&&_e?jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{}):jsxRuntimeExports.jsx("button",{onClick:rt,children:"Export"}),b&&_e&&jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("a",{href:b,download:`${$}.svg`,children:"Download SVG"}),jsxRuntimeExports.jsx("span",{children:" | "}),jsxRuntimeExports.jsx("a",{href:_e,download:`${$}.png`,children:"PNG"})]}),$==="evaporating-cloud"&&jsxRuntimeExports.jsx(Cloud,{ast:d,setSvgElem:it}),$==="goal-tree"&&jsxRuntimeExports.jsx(Tree,{semantics:g,setSvgElem:it}),$==="problem-tree"&&jsxRuntimeExports.jsx(Tree,{semantics:g,setSvgElem:it})]})}const exampleGoalTreeText=`Goal: "Make money now and in the future" - -revUp: "Generate more revenue" { - class: CSF -} -costsDown: "Control costs" { - class: CSF -} - -Goal <- revUp -Goal <- costsDown - -keepCust: "Protect relationship with existing customers" -newCust: "Acquire new customers" - -reduceInfra: "Reduce infrastructure spending" -retain: "Retain employees" -marketSalary: "Keep up with market salaries" - -morale: "Maintain employee morale" -features: "Develop new features" - -newCust <- features - -# This is probably the wrong place for 'retain' -features <- retain - -revUp <- newCust -revUp <- keepCust -costsDown <- reduceInfra -retain <- marketSalary -retain <- morale -`,exampleEvaporatingCloudText=` -A: Maximize business performance - -B: Subordinate all decisions to the financial goal - -C: Ensure people are in a state of optimal performance - -D: Subordinate people's needs to the financial goal - -B <- D: *inject* Psychological flow triggers - -D': Attend to people's needs (& let people work) -`,exampleProblemTreeText=` -bad: "Bad user experience" { - class: UDE -} -cluttered: "Cluttered interface" { - class: UDE -} -bad <- cluttered -ux: "Low investment in UX design" -features: "Many features added" -cluttered <- ux && features -`;let GrammarLocation$4=class{constructor(g,$){this.source=g,this.start=$}toString(){return String(this.source)}offset(g){return{line:g.line+this.start.line-1,column:g.line===1?g.column+this.start.column-1:g.column,offset:g.offset+this.start.offset}}static offsetStart(g){return g.source&&typeof g.source.offset=="function"?g.source.offset(g.start):g.start}static offsetEnd(g){return g.source&&typeof g.source.offset=="function"?g.source.offset(g.end):g.end}};var grammarLocation=GrammarLocation$4;const GrammarLocation$3=grammarLocation,setProtoOf=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,g){d.__proto__=g}||function(d,g){for(const $ in g)Object.prototype.hasOwnProperty.call(g,$)&&(d[$]=g[$])};let GrammarError$3=class extends Error{constructor(g,$,b){super(g),setProtoOf(this,GrammarError$3.prototype),this.name="GrammarError",this.location=$,b===void 0&&(b=[]),this.diagnostics=b,this.stage=null,this.problems=[["error",g,$,b]]}toString(){let g=super.toString();this.location&&(g+=` - at `,this.location.source!==void 0&&this.location.source!==null&&(g+=`${this.location.source}:`),g+=`${this.location.start.line}:${this.location.start.column}`);for(const $ of this.diagnostics)g+=` - from `,$.location.source!==void 0&&$.location.source!==null&&(g+=`${$.location.source}:`),g+=`${$.location.start.line}:${$.location.start.column}: ${$.message}`;return g}format(g){const $=g.map(({source:_e,text:et})=>({source:_e,text:et!=null?String(et).split(/\r\n|\n|\r/g):[]}));function b(_e,et,tt=""){let nt="";const rt=$.find(({source:ut})=>ut===_e.source),it=_e.start,st=GrammarLocation$3.offsetStart(_e);if(rt){const ut=_e.end,at=rt.text[it.line-1],ct=(it.line===ut.line?ut.column:at.length+1)-it.column||1;tt&&(nt+=` -note: ${tt}`),nt+=` - --> ${_e.source}:${st.line}:${st.column} -${"".padEnd(et)} | -${st.line.toString().padStart(et)} | ${at} -${"".padEnd(et)} | ${"".padEnd(it.column-1)}${"".padEnd(ct,"^")}`}else nt+=` - at ${_e.source}:${st.line}:${st.column}`,tt&&(nt+=`: ${tt}`);return nt}function j(_e,et,tt,nt=[]){let rt=-1/0;tt?rt=nt.reduce((st,{location:ut})=>Math.max(st,GrammarLocation$3.offsetStart(ut).line),tt.start.line):rt=Math.max.apply(null,nt.map(st=>st.location.start.line)),rt=rt.toString().length;let it=`${_e}: ${et}`;tt&&(it+=b(tt,rt));for(const st of nt)it+=b(st.location,rt,st.message);return it}return this.problems.filter(_e=>_e[0]!=="info").map(_e=>j(..._e)).join(` - -`)}};var grammarError=GrammarError$3;const visitor$b={build(d){function g(et,...tt){return d[et.type](et,...tt)}function $(){}function b(et,...tt){return g(et.expression,...tt)}function j(et){return function(tt,...nt){tt[et].forEach(rt=>g(rt,...nt))}}const _e={grammar(et,...tt){et.topLevelInitializer&&g(et.topLevelInitializer,...tt),et.initializer&&g(et.initializer,...tt),et.rules.forEach(nt=>g(nt,...tt))},top_level_initializer:$,initializer:$,rule:b,named:b,choice:j("alternatives"),action:b,sequence:j("elements"),labeled:b,text:b,simple_and:b,simple_not:b,optional:b,zero_or_more:b,one_or_more:b,repeated(et,...tt){return et.delimiter&&g(et.delimiter,...tt),g(et.expression,...tt)},group:b,semantic_and:$,semantic_not:$,rule_ref:$,literal:$,class:$,any:$};return Object.keys(_e).forEach(et=>{Object.prototype.hasOwnProperty.call(d,et)||(d[et]=_e[et])}),g}};var visitor_1=visitor$b;const visitor$a=visitor_1,asts$7={findRule(d,g){for(let $=0;$1&&_e.delimiter&&j(_e.delimiter))},semantic_and:b,semantic_not:b,rule_ref(_e){const et=asts$7.findRule(d,_e.name);return et?j(et):void 0},literal(_e){return _e.value!==""},class:$,any:$});return j(g)}};var asts_1=asts$7;const opcodes={PUSH:0,PUSH_EMPTY_STRING:35,PUSH_UNDEFINED:1,PUSH_NULL:2,PUSH_FAILED:3,PUSH_EMPTY_ARRAY:4,PUSH_CURR_POS:5,POP:6,POP_CURR_POS:7,POP_N:8,NIP:9,APPEND:10,WRAP:11,TEXT:12,PLUCK:36,IF:13,IF_ERROR:14,IF_NOT_ERROR:15,IF_LT:30,IF_GE:31,IF_LT_DYNAMIC:32,IF_GE_DYNAMIC:33,WHILE_NOT_ERROR:16,MATCH_ANY:17,MATCH_STRING:18,MATCH_STRING_IC:19,MATCH_CHAR_CLASS:20,MATCH_REGEXP:20,ACCEPT_N:21,ACCEPT_STRING:22,FAIL:23,LOAD_SAVED_POS:24,UPDATE_SAVED_POS:25,CALL:26,RULE:27,SILENT_FAILS_ON:28,SILENT_FAILS_OFF:29,SOURCE_MAP_PUSH:37,SOURCE_MAP_POP:38,SOURCE_MAP_LABEL_PUSH:39,SOURCE_MAP_LABEL_POP:40};var opcodes_1=opcodes;const visitor$9=visitor_1,asts$6=asts_1,GrammarError$2=grammarError,ALWAYS_MATCH$1=1,SOMETIMES_MATCH$1=0,NEVER_MATCH$1=-1;function inferenceMatchResult$1(d){function g(et){return et.match=SOMETIMES_MATCH$1}function $(et){return _e(et.expression),et.match=ALWAYS_MATCH$1}function b(et){return et.match=_e(et.expression)}function j(et,tt){const nt=et.length;let rt=0,it=0;for(let st=0;st0?NEVER_MATCH$1:SOMETIMES_MATCH$1}const _e=visitor$9.build({rule(et){let tt,nt=0;if(typeof et.match>"u"){et.match=SOMETIMES_MATCH$1;do if(tt=et.match,et.match=_e(et.expression),++nt>6)throw new GrammarError$2("Infinity cycle detected when trying to evaluate node match result",et.location);while(tt!==et.match)}return et.match},named:b,choice(et){return et.match=j(et.alternatives,!0)},action:b,sequence(et){return et.match=j(et.elements,!1)},labeled:b,text:b,simple_and:b,simple_not(et){return et.match=-_e(et.expression)},optional:$,zero_or_more:$,one_or_more:b,repeated(et){const tt=_e(et.expression),nt=et.delimiter?_e(et.delimiter):NEVER_MATCH$1,rt=et.min?et.min:et.max;return rt.type!=="constant"||et.max.type!=="constant"?et.match=SOMETIMES_MATCH$1:et.max.value===0||et.max.value!==null&&rt.value>et.max.value?et.match=NEVER_MATCH$1:tt===NEVER_MATCH$1?et.match=rt.value===0?ALWAYS_MATCH$1:NEVER_MATCH$1:tt===ALWAYS_MATCH$1?et.delimiter&&rt.value>=2?et.match=nt:et.match=ALWAYS_MATCH$1:et.delimiter&&rt.value>=2?et.match=nt===NEVER_MATCH$1?NEVER_MATCH$1:SOMETIMES_MATCH$1:et.match=rt.value===0?ALWAYS_MATCH$1:SOMETIMES_MATCH$1},group:b,semantic_and:g,semantic_not:g,rule_ref(et){const tt=asts$6.findRule(d,et.name);return et.match=_e(tt)},literal(et){const tt=et.value.length===0?ALWAYS_MATCH$1:SOMETIMES_MATCH$1;return et.match=tt},class(et){const tt=et.parts.length===0?NEVER_MATCH$1:SOMETIMES_MATCH$1;return et.match=tt},any:g});_e(d)}inferenceMatchResult$1.ALWAYS_MATCH=ALWAYS_MATCH$1;inferenceMatchResult$1.SOMETIMES_MATCH=SOMETIMES_MATCH$1;inferenceMatchResult$1.NEVER_MATCH=NEVER_MATCH$1;var inferenceMatchResult_1=inferenceMatchResult$1;const asts$5=asts_1,op$1=opcodes_1,visitor$8=visitor_1,{ALWAYS_MATCH,SOMETIMES_MATCH,NEVER_MATCH}=inferenceMatchResult_1;function generateBytecode$1(d,g){const $=[],b=[],j=[],_e=[],et=[];function tt(Ct){const _t=$.indexOf(Ct);return _t===-1?$.push(Ct)-1:_t}function nt(Ct){const _t={value:Ct.parts,inverted:Ct.inverted,ignoreCase:Ct.ignoreCase},Tt=JSON.stringify(_t),kt=b.findIndex(Mt=>JSON.stringify(Mt)===Tt);return kt===-1?b.push(_t)-1:kt}function rt(Ct){const _t=JSON.stringify(Ct),Tt=j.findIndex(kt=>JSON.stringify(kt)===_t);return Tt===-1?j.push(Ct)-1:Tt}function it(Ct,_t,Tt){const kt={predicate:Ct,params:_t,body:Tt.code,location:Tt.codeLocation},Mt=JSON.stringify(kt),Vt=_e.findIndex(Jt=>JSON.stringify(Jt)===Mt);return Vt===-1?_e.push(kt)-1:Vt}function st(Ct){return et.push(Ct)-1}function ut(Ct){const _t={};return Object.keys(Ct).forEach(Tt=>{_t[Tt]=Ct[Tt]}),_t}function at(Ct,..._t){return Ct.concat(..._t)}function ht(Ct,_t,Tt,kt){return Ct===ALWAYS_MATCH?Tt:Ct===NEVER_MATCH?kt:_t.concat([Tt.length,kt.length],Tt,kt)}function ct(Ct,_t){return Ct.concat([_t.length],_t)}function vt(Ct,_t,Tt,kt){const Mt=Object.keys(Tt).map(Vt=>kt-Tt[Vt]);return[op$1.CALL,Ct,_t,Mt.length].concat(Mt)}function ft(Ct,_t,Tt){const kt=Ct.match|0;return at([op$1.PUSH_CURR_POS],[op$1.SILENT_FAILS_ON],Ot(Ct,{sp:Tt.sp+1,env:ut(Tt.env),action:null}),[op$1.SILENT_FAILS_OFF],ht(_t?-kt:kt,[_t?op$1.IF_ERROR:op$1.IF_NOT_ERROR],at([op$1.POP],[_t?op$1.POP:op$1.POP_CURR_POS],[op$1.PUSH_UNDEFINED]),at([op$1.POP],[_t?op$1.POP_CURR_POS:op$1.POP],[op$1.PUSH_FAILED])))}function gt(Ct,_t,Tt){const kt=it(!0,Object.keys(Tt.env),Ct);return at([op$1.UPDATE_SAVED_POS],vt(kt,0,Tt.env,Tt.sp),ht(Ct.match|0,[op$1.IF],at([op$1.POP],_t?[op$1.PUSH_FAILED]:[op$1.PUSH_UNDEFINED]),at([op$1.POP],_t?[op$1.PUSH_UNDEFINED]:[op$1.PUSH_FAILED])))}function pt(Ct){return ct([op$1.WHILE_NOT_ERROR],at([op$1.APPEND],Ct))}function yt(Ct,_t,Tt,kt){switch(Ct.type){case"constant":return{pre:[],post:[],sp:Tt};case"variable":return Ct.sp=kt+Tt-_t[Ct.value],{pre:[],post:[],sp:Tt};case"function":{Ct.sp=kt;const Mt=it(!0,Object.keys(_t),{code:Ct.value,codeLocation:Ct.codeLocation});return{pre:vt(Mt,0,_t,Tt),post:[op$1.NIP],sp:Tt+1}}default:throw new Error(`Unknown boundary type "${Ct.type}" for the "repeated" node`)}}function At(Ct,_t){if(_t.value!==null){const Tt=_t.type==="constant"?[op$1.IF_GE,_t.value]:[op$1.IF_GE_DYNAMIC,_t.sp];return ht(SOMETIMES_MATCH,Tt,[op$1.PUSH_FAILED],Ct)}return Ct}function Dt(Ct,_t){const Tt=_t.type==="constant"?[op$1.IF_LT,_t.value]:[op$1.IF_LT_DYNAMIC,_t.sp];return at(Ct,ht(SOMETIMES_MATCH,Tt,[op$1.POP,op$1.POP_CURR_POS,op$1.PUSH_FAILED],[op$1.NIP]))}function St(Ct,_t,Tt,kt,Mt){return Ct?at([op$1.PUSH_CURR_POS],Ot(Ct,{sp:kt.sp+Mt+1,env:ut(kt.env),action:null}),ht(Ct.match|0,[op$1.IF_NOT_ERROR],at([op$1.POP],Tt,ht(-_t,[op$1.IF_ERROR],[op$1.POP,op$1.POP_CURR_POS,op$1.PUSH_FAILED],[op$1.NIP])),[op$1.NIP])):Tt}function Bt(Ct){return g&&g.output==="source-and-map"&&Object.entries(Ct).forEach(([_t,Tt])=>{Ct[_t]=function(kt,...Mt){const Vt=Tt(kt,...Mt);return Vt===void 0||!kt.location?Vt:at([op$1.SOURCE_MAP_PUSH,st(kt.location)],Vt,[op$1.SOURCE_MAP_POP])}}),visitor$8.build(Ct)}const Ot=Bt({grammar(Ct){Ct.rules.forEach(Ot),Ct.literals=$,Ct.classes=b,Ct.expectations=j,Ct.functions=_e,Ct.locations=et},rule(Ct){Ct.bytecode=Ot(Ct.expression,{sp:-1,env:{},pluck:[],action:null})},named(Ct,_t){const Tt=Ct.match|0,kt=Tt===NEVER_MATCH?null:rt({type:"rule",value:Ct.name});return at([op$1.SILENT_FAILS_ON],Ot(Ct.expression,_t),[op$1.SILENT_FAILS_OFF],ht(Tt,[op$1.IF_ERROR],[op$1.FAIL,kt],[]))},choice(Ct,_t){function Tt(kt,Mt){const Vt=kt[0].match|0,Jt=Ot(kt[0],{sp:Mt.sp,env:ut(Mt.env),action:null});return Vt===ALWAYS_MATCH?Jt:at(Jt,kt.length>1?ht(SOMETIMES_MATCH,[op$1.IF_ERROR],at([op$1.POP],Tt(kt.slice(1),Mt)),[]):[])}return Tt(Ct.alternatives,_t)},action(Ct,_t){const Tt=ut(_t.env),kt=Ct.expression.type!=="sequence"||Ct.expression.elements.length===0,Mt=Ot(Ct.expression,{sp:_t.sp+(kt?1:0),env:Tt,action:Ct}),Vt=Ct.expression.match|0,Jt=kt&&Vt!==NEVER_MATCH?it(!1,Object.keys(Tt),Ct):null;return kt?at([op$1.PUSH_CURR_POS],Mt,ht(Vt,[op$1.IF_NOT_ERROR],at([op$1.LOAD_SAVED_POS,1],vt(Jt,1,Tt,_t.sp+2)),[]),[op$1.NIP]):Mt},sequence(Ct,_t){function Tt(kt,Mt){if(kt.length>0){const Vt=Ct.elements.length-kt.length+1;return at(Ot(kt[0],{sp:Mt.sp,env:Mt.env,pluck:Mt.pluck,action:null}),ht(kt[0].match|0,[op$1.IF_NOT_ERROR],Tt(kt.slice(1),{sp:Mt.sp+1,env:Mt.env,pluck:Mt.pluck,action:Mt.action}),at(Vt>1?[op$1.POP_N,Vt]:[op$1.POP],[op$1.POP_CURR_POS],[op$1.PUSH_FAILED])))}else{if(Mt.pluck.length>0)return at([op$1.PLUCK,Ct.elements.length+1,Mt.pluck.length],Mt.pluck.map(Vt=>Mt.sp-Vt));if(Mt.action){const Vt=it(!1,Object.keys(Mt.env),Mt.action);return at([op$1.LOAD_SAVED_POS,Ct.elements.length],vt(Vt,Ct.elements.length+1,Mt.env,Mt.sp))}else return at([op$1.WRAP,Ct.elements.length],[op$1.NIP])}}return at([op$1.PUSH_CURR_POS],Tt(Ct.elements,{sp:_t.sp+1,env:_t.env,pluck:[],action:_t.action}))},labeled(Ct,_t){let Tt=_t.env;const kt=Ct.label,Mt=_t.sp+1;kt&&(Tt=ut(_t.env),_t.env[Ct.label]=Mt),Ct.pick&&_t.pluck.push(Mt);const Vt=Ot(Ct.expression,{sp:_t.sp,env:Tt,action:null});return kt&&Ct.labelLocation&&g&&g.output==="source-and-map"?at([op$1.SOURCE_MAP_LABEL_PUSH,Mt,tt(kt),st(Ct.labelLocation)],Vt,[op$1.SOURCE_MAP_LABEL_POP,Mt]):Vt},text(Ct,_t){return at([op$1.PUSH_CURR_POS],Ot(Ct.expression,{sp:_t.sp+1,env:ut(_t.env),action:null}),ht(Ct.match|0,[op$1.IF_NOT_ERROR],at([op$1.POP],[op$1.TEXT]),[op$1.NIP]))},simple_and(Ct,_t){return ft(Ct.expression,!1,_t)},simple_not(Ct,_t){return ft(Ct.expression,!0,_t)},optional(Ct,_t){return at(Ot(Ct.expression,{sp:_t.sp,env:ut(_t.env),action:null}),ht(-(Ct.expression.match|0),[op$1.IF_ERROR],at([op$1.POP],[op$1.PUSH_NULL]),[]))},zero_or_more(Ct,_t){const Tt=Ot(Ct.expression,{sp:_t.sp+1,env:ut(_t.env),action:null});return at([op$1.PUSH_EMPTY_ARRAY],Tt,pt(Tt),[op$1.POP])},one_or_more(Ct,_t){const Tt=Ot(Ct.expression,{sp:_t.sp+1,env:ut(_t.env),action:null});return at([op$1.PUSH_EMPTY_ARRAY],Tt,ht(Ct.expression.match|0,[op$1.IF_NOT_ERROR],at(pt(Tt),[op$1.POP]),at([op$1.POP],[op$1.POP],[op$1.PUSH_FAILED])))},repeated(Ct,_t){const Tt=Ct.min?Ct.min:Ct.max,kt=Tt.type!=="constant"||Tt.value>0,Mt=Ct.max.type!=="constant"&&Ct.max.value!==null,Vt=kt?2:1,Jt=Ct.min?yt(Ct.min,_t.env,_t.sp,2+(Ct.max.type==="function"?1:0)):{pre:[],post:[],sp:_t.sp},Xt=yt(Ct.max,_t.env,Jt.sp,Vt),Nt=Ot(Ct.expression,{sp:Xt.sp+Vt,env:ut(_t.env),action:null}),Lt=Ct.delimiter!==null?Ot(Ct.expression,{sp:Xt.sp+Vt+1,env:ut(_t.env),action:null}):Nt,jt=St(Ct.delimiter,Ct.expression.match|0,Lt,_t,Vt),Yt=At(jt,Ct.max),Qt=Mt?At(Nt,Ct.max):Nt,on=at(kt?[op$1.PUSH_CURR_POS]:[],[op$1.PUSH_EMPTY_ARRAY],Qt,pt(Yt),[op$1.POP]);return at(Jt.pre,Xt.pre,kt?Dt(on,Tt):on,Xt.post,Jt.post)},group(Ct,_t){return Ot(Ct.expression,{sp:_t.sp,env:ut(_t.env),action:null})},semantic_and(Ct,_t){return gt(Ct,!1,_t)},semantic_not(Ct,_t){return gt(Ct,!0,_t)},rule_ref(Ct){return[op$1.RULE,asts$5.indexOfRule(d,Ct.name)]},literal(Ct){if(Ct.value.length>0){const _t=Ct.match|0,kt=_t===SOMETIMES_MATCH||_t===ALWAYS_MATCH&&!Ct.ignoreCase?tt(Ct.ignoreCase?Ct.value.toLowerCase():Ct.value):null,Mt=_t!==ALWAYS_MATCH?rt({type:"literal",value:Ct.value,ignoreCase:Ct.ignoreCase}):null;return ht(_t,Ct.ignoreCase?[op$1.MATCH_STRING_IC,kt]:[op$1.MATCH_STRING,kt],Ct.ignoreCase?[op$1.ACCEPT_N,Ct.value.length]:[op$1.ACCEPT_STRING,kt],[op$1.FAIL,Mt])}return[op$1.PUSH_EMPTY_STRING]},class(Ct){const _t=Ct.match|0,Tt=_t===SOMETIMES_MATCH?nt(Ct):null,kt=_t!==ALWAYS_MATCH?rt({type:"class",value:Ct.parts,inverted:Ct.inverted,ignoreCase:Ct.ignoreCase}):null;return ht(_t,[op$1.MATCH_CHAR_CLASS,Tt],[op$1.ACCEPT_N,1],[op$1.FAIL,kt])},any(Ct){const _t=Ct.match|0,Tt=_t!==ALWAYS_MATCH?rt({type:"any"}):null;return ht(_t,[op$1.MATCH_ANY],[op$1.ACCEPT_N,1],[op$1.FAIL,Tt])}});Ot(d)}var generateBytecode_1=generateBytecode$1,sourceMap={},sourceMapGenerator={},base64Vlq={},base64$3={};const intToCharMap="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");base64$3.encode=function(d){if(0<=d&&d>>=VLQ_BASE_SHIFT,j>0&&(b|=VLQ_CONTINUATION_BIT),$+=base64$2.encode(b);while(j>0);return $};var util$3={};function getArg(d,g,$){if(g in d)return d[g];if(arguments.length===3)return $;throw new Error('"'+g+'" is a required argument.')}util$3.getArg=getArg;const supportsNullProto=function(){return!("__proto__"in Object.create(null))}();function identity(d){return d}function toSetString(d){return isProtoString(d)?"$"+d:d}util$3.toSetString=supportsNullProto?identity:toSetString;function fromSetString(d){return isProtoString(d)?d.slice(1):d}util$3.fromSetString=supportsNullProto?identity:fromSetString;function isProtoString(d){if(!d)return!1;const g=d.length;if(g<9||d.charCodeAt(g-1)!==95||d.charCodeAt(g-2)!==95||d.charCodeAt(g-3)!==111||d.charCodeAt(g-4)!==116||d.charCodeAt(g-5)!==111||d.charCodeAt(g-6)!==114||d.charCodeAt(g-7)!==112||d.charCodeAt(g-8)!==95||d.charCodeAt(g-9)!==95)return!1;for(let $=g-10;$>=0;$--)if(d.charCodeAt($)!==36)return!1;return!0}function strcmp(d,g){return d===g?0:d===null?1:g===null?-1:d>g?1:-1}function compareByGeneratedPositionsInflated(d,g){let $=d.generatedLine-g.generatedLine;return $!==0||($=d.generatedColumn-g.generatedColumn,$!==0)||($=strcmp(d.source,g.source),$!==0)||($=d.originalLine-g.originalLine,$!==0)||($=d.originalColumn-g.originalColumn,$!==0)?$:strcmp(d.name,g.name)}util$3.compareByGeneratedPositionsInflated=compareByGeneratedPositionsInflated;const PROTOCOL="http:",PROTOCOL_AND_HOST=`${PROTOCOL}//host`;function createSafeHandler(d){return g=>{const $=getURLType(g),b=buildSafeBase(g),j=new URL(g,b);d(j);const _e=j.toString();return $==="absolute"?_e:$==="scheme-relative"?_e.slice(PROTOCOL.length):$==="path-absolute"?_e.slice(PROTOCOL_AND_HOST.length):computeRelativeURL(b,_e)}}function withBase(d,g){return new URL(d,g).toString()}function buildUniqueSegment(d,g){let $=0;do{const b=d+$++;if(g.indexOf(b)===-1)return b}while(!0)}function buildSafeBase(d){const g=d.split("..").length-1,$=buildUniqueSegment("p",d);let b=`${PROTOCOL_AND_HOST}/`;for(let j=0;j0&&!b[b.length-1]&&b.pop();$.length>0&&b.length>0&&$[0]===b[0];)$.shift(),b.shift();return b.map(()=>"..").concat($).join("/")+g.search+g.hash}const ensureDirectory=createSafeHandler(d=>{d.pathname=d.pathname.replace(/\/?$/,"/")}),normalize=createSafeHandler(d=>{});util$3.normalize=normalize;function join(d,g){const $=getURLType(g),b=getURLType(d);if(d=ensureDirectory(d),$==="absolute")return withBase(g,void 0);if(b==="absolute")return withBase(g,d);if($==="scheme-relative")return normalize(g);if(b==="scheme-relative")return withBase(g,withBase(d,PROTOCOL_AND_HOST)).slice(PROTOCOL.length);if($==="path-absolute")return normalize(g);if(b==="path-absolute")return withBase(g,withBase(d,PROTOCOL_AND_HOST)).slice(PROTOCOL_AND_HOST.length);const j=buildSafeBase(g+d),_e=withBase(g,withBase(d,j));return computeRelativeURL(j,_e)}util$3.join=join;function relative(d,g){const $=relativeIfPossible(d,g);return typeof $=="string"?$:normalize(g)}util$3.relative=relative;function relativeIfPossible(d,g){if(getURLType(d)!==getURLType(g))return null;const b=buildSafeBase(d+g),j=new URL(d,b),_e=new URL(g,b);try{new URL("",_e.toString())}catch{return null}return _e.protocol!==j.protocol||_e.user!==j.user||_e.password!==j.password||_e.hostname!==j.hostname||_e.port!==j.port?null:computeRelativeURL(j,_e)}var arraySet={};let ArraySet$1=class{constructor(){this._array=[],this._set=new Map}static fromArray(g,$){const b=new ArraySet$1;for(let j=0,_e=g.length;j<_e;j++)b.add(g[j],$);return b}size(){return this._set.size}add(g,$){const b=this.has(g),j=this._array.length;(!b||$)&&this._array.push(g),b||this._set.set(g,j)}has(g){return this._set.has(g)}indexOf(g){const $=this._set.get(g);if($>=0)return $;throw new Error('"'+g+'" is not in the set.')}at(g){if(g>=0&&g$||b==$&&_e>=j||util$2.compareByGeneratedPositionsInflated(d,g)<=0}let MappingList$1=class{constructor(){this._array=[],this._sorted=!0,this._last={generatedLine:-1,generatedColumn:0}}unsortedForEach(g,$){this._array.forEach(g,$)}add(g){generatedPositionAfter(this._last,g)?(this._last=g,this._array.push(g)):(this._sorted=!1,this._array.push(g))}toArray(){return this._sorted||(this._array.sort(util$2.compareByGeneratedPositionsInflated),this._sorted=!0),this._array}};mappingList.MappingList=MappingList$1;const base64VLQ=base64Vlq,util$1=util$3,ArraySet=arraySet.ArraySet,MappingList=mappingList.MappingList;let SourceMapGenerator$1=class{constructor(g){g||(g={}),this._file=util$1.getArg(g,"file",null),this._sourceRoot=util$1.getArg(g,"sourceRoot",null),this._skipValidation=util$1.getArg(g,"skipValidation",!1),this._sources=new ArraySet,this._names=new ArraySet,this._mappings=new MappingList,this._sourcesContents=null}static fromSourceMap(g){const $=g.sourceRoot,b=new SourceMapGenerator$1({file:g.file,sourceRoot:$});return g.eachMapping(function(j){const _e={generated:{line:j.generatedLine,column:j.generatedColumn}};j.source!=null&&(_e.source=j.source,$!=null&&(_e.source=util$1.relative($,_e.source)),_e.original={line:j.originalLine,column:j.originalColumn},j.name!=null&&(_e.name=j.name)),b.addMapping(_e)}),g.sources.forEach(function(j){let _e=j;$!=null&&(_e=util$1.relative($,j)),b._sources.has(_e)||b._sources.add(_e);const et=g.sourceContentFor(j);et!=null&&b.setSourceContent(j,et)}),b}addMapping(g){const $=util$1.getArg(g,"generated"),b=util$1.getArg(g,"original",null);let j=util$1.getArg(g,"source",null),_e=util$1.getArg(g,"name",null);this._skipValidation||this._validateMapping($,b,j,_e),j!=null&&(j=String(j),this._sources.has(j)||this._sources.add(j)),_e!=null&&(_e=String(_e),this._names.has(_e)||this._names.add(_e)),this._mappings.add({generatedLine:$.line,generatedColumn:$.column,originalLine:b&&b.line,originalColumn:b&&b.column,source:j,name:_e})}setSourceContent(g,$){let b=g;this._sourceRoot!=null&&(b=util$1.relative(this._sourceRoot,b)),$!=null?(this._sourcesContents||(this._sourcesContents=Object.create(null)),this._sourcesContents[util$1.toSetString(b)]=$):this._sourcesContents&&(delete this._sourcesContents[util$1.toSetString(b)],Object.keys(this._sourcesContents).length===0&&(this._sourcesContents=null))}applySourceMap(g,$,b){let j=$;if($==null){if(g.file==null)throw new Error(`SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, or the source map's "file" property. Both were omitted.`);j=g.file}const _e=this._sourceRoot;_e!=null&&(j=util$1.relative(_e,j));const et=this._mappings.toArray().length>0?new ArraySet:this._sources,tt=new ArraySet;this._mappings.unsortedForEach(function(nt){if(nt.source===j&&nt.originalLine!=null){const st=g.originalPositionFor({line:nt.originalLine,column:nt.originalColumn});st.source!=null&&(nt.source=st.source,b!=null&&(nt.source=util$1.join(b,nt.source)),_e!=null&&(nt.source=util$1.relative(_e,nt.source)),nt.originalLine=st.line,nt.originalColumn=st.column,st.name!=null&&(nt.name=st.name))}const rt=nt.source;rt!=null&&!et.has(rt)&&et.add(rt);const it=nt.name;it!=null&&!tt.has(it)&&tt.add(it)},this),this._sources=et,this._names=tt,g.sources.forEach(function(nt){const rt=g.sourceContentFor(nt);rt!=null&&(b!=null&&(nt=util$1.join(b,nt)),_e!=null&&(nt=util$1.relative(_e,nt)),this.setSourceContent(nt,rt))},this)}_validateMapping(g,$,b,j){if($&&typeof $.line!="number"&&typeof $.column!="number")throw new Error("original.line and original.column are not numbers -- you probably meant to omit the original mapping entirely and only map the generated position. If so, pass null for the original mapping instead of an object with empty or null values.");if(!(g&&"line"in g&&"column"in g&&g.line>0&&g.column>=0&&!$&&!b&&!j)){if(!(g&&"line"in g&&"column"in g&&$&&"line"in $&&"column"in $&&g.line>0&&g.column>=0&&$.line>0&&$.column>=0&&b))throw new Error("Invalid mapping: "+JSON.stringify({generated:g,source:b,original:$,name:j}))}}_serializeMappings(){let g=0,$=1,b=0,j=0,_e=0,et=0,tt="",nt,rt,it,st;const ut=this._mappings.toArray();for(let at=0,ht=ut.length;at0){if(!util$1.compareByGeneratedPositionsInflated(rt,ut[at-1]))continue;nt+=","}nt+=base64VLQ.encode(rt.generatedColumn-g),g=rt.generatedColumn,rt.source!=null&&(st=this._sources.indexOf(rt.source),nt+=base64VLQ.encode(st-et),et=st,nt+=base64VLQ.encode(rt.originalLine-1-j),j=rt.originalLine-1,nt+=base64VLQ.encode(rt.originalColumn-b),b=rt.originalColumn,rt.name!=null&&(it=this._names.indexOf(rt.name),nt+=base64VLQ.encode(it-_e),_e=it)),tt+=nt}return tt}_generateSourcesContent(g,$){return g.map(function(b){if(!this._sourcesContents)return null;$!=null&&(b=util$1.relative($,b));const j=util$1.toSetString(b);return Object.prototype.hasOwnProperty.call(this._sourcesContents,j)?this._sourcesContents[j]:null},this)}toJSON(){const g={version:this._version,sources:this._sources.toArray(),names:this._names.toArray(),mappings:this._serializeMappings()};return this._file!=null&&(g.file=this._file),this._sourceRoot!=null&&(g.sourceRoot=this._sourceRoot),this._sourcesContents&&(g.sourcesContent=this._generateSourcesContent(g.sources,g.sourceRoot)),g}toString(){return JSON.stringify(this.toJSON())}};SourceMapGenerator$1.prototype._version=3;sourceMapGenerator.SourceMapGenerator=SourceMapGenerator$1;var sourceNode={};const SourceMapGenerator=sourceMapGenerator.SourceMapGenerator,util=util$3,REGEX_NEWLINE=/(\r?\n)/,NEWLINE_CODE=10,isSourceNode="$$$isSourceNode$$$";let SourceNode$2=class{constructor(g,$,b,j,_e){this.children=[],this.sourceContents={},this.line=g??null,this.column=$??null,this.source=b??null,this.name=_e??null,this[isSourceNode]=!0,j!=null&&this.add(j)}static fromStringWithSourceMap(g,$,b){const j=new SourceNode$2,_e=g.split(REGEX_NEWLINE);let et=0;const tt=function(){const at=ct(),ht=ct()||"";return at+ht;function ct(){return et<_e.length?_e[et++]:void 0}};let nt=1,rt=0,it=null,st;return $.eachMapping(function(at){if(it!==null)if(nt=0;$--)this.prepend(g[$]);else if(g[isSourceNode]||typeof g=="string")this.children.unshift(g);else throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got "+g);return this}walk(g){let $;for(let b=0,j=this.children.length;b0){for($=[],b=0;b' at an index ${g}. -Bytecode: ${this.bytecode}`);return this.varName+g}static sourceNode(g,$,b){const j=GrammarLocation$2.offsetStart(g);return new SourceNode$1(j.line,j.column?j.column-1:null,String(g.source),$,b)}push(g){++this.sp>this.maxSp&&(this.maxSp=this.sp);const $=this.labels[this.sp],b=[this.name(this.sp)," = ",g,";"];if($)if(this.sourceMapStack.length){const j=Stack$1.sourceNode($.location,b.splice(0,2),$.label),{parts:_e,location:et}=this.sourceMapPopInternal(),tt=et.start.offset<$.location.end.offset?{start:$.location.end,end:et.end,source:et.source}:et,nt=Stack$1.sourceNode(tt,b.concat(` -`));return this.sourceMapStack.push([_e,_e.length+1,et]),new SourceNode$1(null,null,$.location.source,[j,nt])}else return Stack$1.sourceNode($.location,b.concat(` -`));return b.join("")}pop(g){return g!==void 0?(this.sp-=g,Array.from({length:g},($,b)=>this.name(this.sp+1+b))):this.name(this.sp--)}top(){return this.name(this.sp)}index(g){if(g<0)throw new RangeError(`Rule '${this.ruleName}': The variable stack overflow: attempt to get a variable at a negative index ${g}. -Bytecode: ${this.bytecode}`);return this.name(this.sp-g)}result(){if(this.maxSp<0)throw new RangeError(`Rule '${this.ruleName}': The variable stack is empty, can't get the result. -Bytecode: ${this.bytecode}`);return this.name(0)}defines(){return this.maxSp<0?"":this.type+" "+Array.from({length:this.maxSp+1},(g,$)=>this.name($)).join(", ")+";"}checkedIf(g,$,b){const j=this.sp;if($(),b){const _e=this.sp;if(this.sp=j,b(),_e!==this.sp)throw new Error("Rule '"+this.ruleName+"', position "+g+": Branches of a condition can't move the stack pointer differently (before: "+j+", after then: "+_e+", after else: "+this.sp+"). Bytecode: "+this.bytecode)}}checkedLoop(g,$){const b=this.sp;if($(),b!==this.sp)throw new Error("Rule '"+this.ruleName+"', position "+g+": Body of a loop can't move the stack pointer (before: "+b+", after: "+this.sp+"). Bytecode: "+this.bytecode)}sourceMapPush(g,$){if(this.sourceMapStack.length){const b=this.sourceMapStack[this.sourceMapStack.length-1];b[2].start.offset===$.start.offset&&b[2].end.offset>$.end.offset&&(b[2]={start:$.end,end:b[2].end,source:b[2].source})}this.sourceMapStack.push([g,g.length,$])}sourceMapPopInternal(){const[g,$,b]=this.sourceMapStack.pop(),j=g.splice($).map(_e=>_e instanceof SourceNode$1?_e:_e+` -`);if(j.length){const _e=GrammarLocation$2.offsetStart(b);g.push(new SourceNode$1(_e.line,_e.column-1,String(b.source),j))}return{parts:g,location:b}}sourceMapPop(g){const{location:$}=this.sourceMapPopInternal();if(this.sourceMapStack.length&&$.end.offset"\\x0"+hex(g)).replace(/[\x10-\x1F\x7F-\xFF]/g,g=>"\\x"+hex(g)).replace(/[\u0100-\u0FFF]/g,g=>"\\u0"+hex(g)).replace(/[\u1000-\uFFFF]/g,g=>"\\u"+hex(g))}utils.stringEscape=stringEscape$1;function regexpClassEscape$1(d){return d.replace(/\\/g,"\\\\").replace(/\//g,"\\/").replace(/]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\x08/g,"\\b").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\v/g,"\\v").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,g=>"\\x0"+hex(g)).replace(/[\x10-\x1F\x7F-\xFF]/g,g=>"\\x"+hex(g)).replace(/[\u0100-\u0FFF]/g,g=>"\\u0"+hex(g)).replace(/[\u1000-\uFFFF]/g,g=>"\\u"+hex(g))}utils.regexpClassEscape=regexpClassEscape$1;function base64$1(d){const g="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",$=d.length%3,b=d.length-$;let j="";for(let _e=0;_e>2],j+=g[(d[_e]&3)<<4|d[_e+1]>>4],j+=g[(d[_e+1]&15)<<2|d[_e+2]>>6],j+=g[d[_e+2]&63];return $===1?(j+=g[d[b]>>2],j+=g[(d[b]&3)<<4],j+="=="):$===2&&(j+=g[d[b]>>2],j+=g[(d[b]&3)<<4|d[b+1]>>4],j+=g[(d[b+1]&15)<<2],j+="="),j}utils.base64=base64$1;const asts$4=asts_1,op=opcodes_1,Stack=stack,VERSION$1=version,{stringEscape,regexpClassEscape}=utils,{SourceNode}=sourceMap,GrammarLocation$1=grammarLocation;function toSourceNode(d,g,$){const b=GrammarLocation$1.offsetStart(g),j=b.line,_e=b.column-1,et=d.split(` -`);return et.length===1?new SourceNode(j,_e,String(g.source),d,$):new SourceNode(null,null,String(g.source),et.map((tt,nt)=>new SourceNode(j+nt,nt===0?_e:0,String(g.source),nt===et.length-1?tt:[tt,` -`],$)))}function wrapInSourceNode(d,g,$,b,j){if($){const _e=GrammarLocation$1.offsetEnd($);return new SourceNode(null,null,String($.source),[d,toSourceNode(g,$,j),new SourceNode(_e.line,_e.column-1,String($.source),b)])}return new SourceNode(null,null,null,[d,g,b])}function generateJS$1(d,g){function $(ct){let vt=!0,ft=0;function gt(pt){return Array.isArray(pt)?pt.map(gt):pt instanceof SourceNode?(ft++,pt.children=gt(pt.children),ft--,pt):(vt?pt=pt.replace(/^(.+)$/gm," $1"):pt=pt.replace(/\n(\s*\S)/g,` - $1`),vt=!ft||pt.endsWith(` -`),pt)}return gt(ct)}function b(ct){return"peg$c"+ct}function j(ct){return"peg$r"+ct}function _e(ct){return"peg$e"+ct}function et(ct){return"peg$f"+ct}function tt(ct){return"peg$parse"+ct}function nt(){function ct(pt){return'"'+stringEscape(pt)+'"'}function vt(pt){return"/^["+(pt.inverted?"^":"")+pt.value.map(yt=>Array.isArray(yt)?regexpClassEscape(yt[0])+"-"+regexpClassEscape(yt[1]):regexpClassEscape(yt)).join("")+"]/"+(pt.ignoreCase?"i":"")}function ft(pt){switch(pt.type){case"rule":return'peg$otherExpectation("'+stringEscape(pt.value)+'")';case"literal":return'peg$literalExpectation("'+stringEscape(pt.value)+'", '+pt.ignoreCase+")";case"class":return"peg$classExpectation(["+pt.value.map(At=>Array.isArray(At)?'["'+stringEscape(At[0])+'", "'+stringEscape(At[1])+'"]':'"'+stringEscape(At)+'"').join(", ")+"], "+pt.inverted+", "+pt.ignoreCase+")";case"any":return"peg$anyExpectation()";default:throw new Error("Unknown expectation type ("+JSON.stringify(pt)+")")}}function gt(pt,yt){return wrapInSourceNode(` - var ${et(yt)} = function(${pt.params.join(", ")}) {`,pt.body,pt.location,"};")}return new SourceNode(null,null,g.grammarSource,[d.literals.map((pt,yt)=>" var "+b(yt)+" = "+ct(pt)+";").concat("",d.classes.map((pt,yt)=>" var "+j(yt)+" = "+vt(pt)+";")).concat("",d.expectations.map((pt,yt)=>" var "+_e(yt)+" = "+ft(pt)+";")).concat("").join(` -`),d.functions.map(gt)])}function rt(ct,vt){const ft=[];return ft.push(""),g.trace&&ft.push("peg$tracer.trace({",' type: "rule.enter",'," rule: "+ct+","," location: peg$computeLocation(startPos, startPos, true)","});",""),g.cache&&(ft.push("var key = peg$currPos * "+d.rules.length+" + "+vt+";","var cached = peg$resultsCache[key];","","if (cached) {"," peg$currPos = cached.nextPos;",""),g.trace&&ft.push("if (cached.result !== peg$FAILED) {"," peg$tracer.trace({",' type: "rule.match",'," rule: "+ct+","," result: cached.result,"," location: peg$computeLocation(startPos, peg$currPos, true)"," });","} else {"," peg$tracer.trace({",' type: "rule.fail",'," rule: "+ct+","," location: peg$computeLocation(startPos, startPos, true)"," });","}",""),ft.push(" return cached.result;","}","")),ft}function it(ct,vt){const ft=[];return g.cache&&ft.push("","peg$resultsCache[key] = { nextPos: peg$currPos, result: "+vt+" };"),g.trace&&ft.push("","if ("+vt+" !== peg$FAILED) {"," peg$tracer.trace({",' type: "rule.match",'," rule: "+ct+","," result: "+vt+","," location: peg$computeLocation(startPos, peg$currPos, true)"," });","} else {"," peg$tracer.trace({",' type: "rule.fail",'," rule: "+ct+","," location: peg$computeLocation(startPos, startPos, true)"," });","}"),ft.push("","return "+vt+";"),ft}function st(ct){const vt=[],ft=new Stack(ct.name,"s","var",ct.bytecode);function gt(yt){let At=0;const Dt=yt.length,St=[];let Bt;function Ot(Tt,kt){const Mt=kt+3,Vt=yt[At+Mt-2],Jt=yt[At+Mt-1];let Xt,Nt;ft.checkedIf(At,()=>{At+=Mt,Xt=gt(yt.slice(At,At+Vt)),At+=Vt},Jt>0?()=>{Nt=gt(yt.slice(At,At+Jt)),At+=Jt}:null),St.push("if ("+Tt+") {"),St.push(...$(Xt)),Jt>0&&(St.push("} else {"),St.push(...$(Nt))),St.push("}")}function Ct(Tt){const Mt=yt[At+2-1];let Vt;ft.checkedLoop(At,()=>{At+=2,Vt=gt(yt.slice(At,At+Mt)),At+=Mt}),St.push("while ("+Tt+") {"),St.push(...$(Vt)),St.push("}")}function _t(Tt){const kt=yt[At+Tt-1];return et(yt[At+1])+"("+yt.slice(At+Tt,At+Tt+kt).map(Mt=>ft.index(Mt)).join(", ")+")"}for(;Atft.index(Vt)).join(", ")} ]`,ft.pop(yt[At+1]),St.push(ft.push(Bt)),At+=Mt;break}case op.IF:Ot(ft.top(),0);break;case op.IF_ERROR:Ot(ft.top()+" === peg$FAILED",0);break;case op.IF_NOT_ERROR:Ot(ft.top()+" !== peg$FAILED",0);break;case op.IF_LT:Ot(ft.top()+".length < "+yt[At+1],1);break;case op.IF_GE:Ot(ft.top()+".length >= "+yt[At+1],1);break;case op.IF_LT_DYNAMIC:Ot(ft.top()+".length < ("+ft.index(yt[At+1])+"|0)",1);break;case op.IF_GE_DYNAMIC:Ot(ft.top()+".length >= ("+ft.index(yt[At+1])+"|0)",1);break;case op.WHILE_NOT_ERROR:Ct(ft.top()+" !== peg$FAILED");break;case op.MATCH_ANY:Ot("input.length > peg$currPos",0);break;case op.MATCH_STRING:Ot(d.literals[yt[At+1]].length>1?"input.substr(peg$currPos, "+d.literals[yt[At+1]].length+") === "+b(yt[At+1]):"input.charCodeAt(peg$currPos) === "+d.literals[yt[At+1]].charCodeAt(0),1);break;case op.MATCH_STRING_IC:Ot("input.substr(peg$currPos, "+d.literals[yt[At+1]].length+").toLowerCase() === "+b(yt[At+1]),1);break;case op.MATCH_CHAR_CLASS:Ot(j(yt[At+1])+".test(input.charAt(peg$currPos))",1);break;case op.ACCEPT_N:St.push(ft.push(yt[At+1]>1?"input.substr(peg$currPos, "+yt[At+1]+")":"input.charAt(peg$currPos)")),St.push(yt[At+1]>1?"peg$currPos += "+yt[At+1]+";":"peg$currPos++;"),At+=2;break;case op.ACCEPT_STRING:St.push(ft.push(b(yt[At+1]))),St.push(d.literals[yt[At+1]].length>1?"peg$currPos += "+d.literals[yt[At+1]].length+";":"peg$currPos++;"),At+=2;break;case op.FAIL:St.push(ft.push("peg$FAILED")),St.push("if (peg$silentFails === 0) { peg$fail("+_e(yt[At+1])+"); }"),At+=2;break;case op.LOAD_SAVED_POS:St.push("peg$savedPos = "+ft.index(yt[At+1])+";"),At+=2;break;case op.UPDATE_SAVED_POS:St.push("peg$savedPos = peg$currPos;"),At++;break;case op.CALL:Bt=_t(4),ft.pop(yt[At+2]),St.push(ft.push(Bt)),At+=4+yt[At+3];break;case op.RULE:St.push(ft.push(tt(d.rules[yt[At+1]].name)+"()")),At+=2;break;case op.SILENT_FAILS_ON:St.push("peg$silentFails++;"),At++;break;case op.SILENT_FAILS_OFF:St.push("peg$silentFails--;"),At++;break;case op.SOURCE_MAP_PUSH:ft.sourceMapPush(St,d.locations[yt[At+1]]),At+=2;break;case op.SOURCE_MAP_POP:{ft.sourceMapPop(),At++;break}case op.SOURCE_MAP_LABEL_PUSH:ft.labels[yt[At+1]]={label:d.literals[yt[At+2]],location:d.locations[yt[At+3]]},At+=4;break;case op.SOURCE_MAP_LABEL_POP:delete ft.labels[yt[At+1]],At+=2;break;default:throw new Error("Invalid opcode: "+yt[At]+".",{rule:ct.name,bytecode:yt})}return St}const pt=gt(ct.bytecode);return vt.push(wrapInSourceNode("function ",tt(ct.name),ct.nameLocation,`() { -`,ct.name)),g.trace&&vt.push(" var startPos = peg$currPos;"),vt.push($(ft.defines())),vt.push(...$(rt('"'+stringEscape(ct.name)+'"',asts$4.indexOfRule(d,ct.name)))),vt.push(...$(pt)),vt.push(...$(it('"'+stringEscape(ct.name)+'"',ft.result()))),vt.push("}"),vt}function ut(ct){return ct.codeLocation?toSourceNode(ct.code,ct.codeLocation,"$"+ct.type):ct.code}function at(){const ct=[];d.topLevelInitializer&&(ct.push(ut(d.topLevelInitializer)),ct.push("")),ct.push("function peg$subclass(child, parent) {"," function C() { this.constructor = child; }"," C.prototype = parent.prototype;"," child.prototype = new C();","}","","function peg$SyntaxError(message, expected, found, location) {"," var self = Error.call(this, message);"," // istanbul ignore next Check is a necessary evil to support older environments"," if (Object.setPrototypeOf) {"," Object.setPrototypeOf(self, peg$SyntaxError.prototype);"," }"," self.expected = expected;"," self.found = found;"," self.location = location;",' self.name = "SyntaxError";'," return self;","}","","peg$subclass(peg$SyntaxError, Error);","","function peg$padEnd(str, targetLength, padString) {",' padString = padString || " ";'," if (str.length > targetLength) { return str; }"," targetLength -= str.length;"," padString += padString.repeat(targetLength);"," return str + padString.slice(0, targetLength);","}","","peg$SyntaxError.prototype.format = function(sources) {",' var str = "Error: " + this.message;'," if (this.location) {"," var src = null;"," var k;"," for (k = 0; k < sources.length; k++) {"," if (sources[k].source === this.location.source) {"," src = sources[k].text.split(/\\r\\n|\\n|\\r/g);"," break;"," }"," }"," var s = this.location.start;",' var offset_s = (this.location.source && (typeof this.location.source.offset === "function"))'," ? this.location.source.offset(s)"," : s;",' var loc = this.location.source + ":" + offset_s.line + ":" + offset_s.column;'," if (src) {"," var e = this.location.end;",` var filler = peg$padEnd("", offset_s.line.toString().length, ' ');`," var line = src[s.line - 1];"," var last = s.line === e.line ? e.column : line.length + 1;"," var hatLen = (last - s.column) || 1;",' str += "\\n --> " + loc + "\\n"',' + filler + " |\\n"',' + offset_s.line + " | " + line + "\\n"',` + filler + " | " + peg$padEnd("", s.column - 1, ' ')`,' + peg$padEnd("", hatLen, "^");'," } else {",' str += "\\n at " + loc;'," }"," }"," return str;","};","","peg$SyntaxError.buildMessage = function(expected, found) {"," var DESCRIBE_EXPECTATION_FNS = {"," literal: function(expectation) {",' return "\\"" + literalEscape(expectation.text) + "\\"";'," },",""," class: function(expectation) {"," var escapedParts = expectation.parts.map(function(part) {"," return Array.isArray(part)",' ? classEscape(part[0]) + "-" + classEscape(part[1])'," : classEscape(part);"," });","",' return "[" + (expectation.inverted ? "^" : "") + escapedParts.join("") + "]";'," },",""," any: function() {",' return "any character";'," },",""," end: function() {",' return "end of input";'," },",""," other: function(expectation) {"," return expectation.description;"," }"," };",""," function hex(ch) {"," return ch.charCodeAt(0).toString(16).toUpperCase();"," }",""," function literalEscape(s) {"," return s",' .replace(/\\\\/g, "\\\\\\\\")',' .replace(/"/g, "\\\\\\"")',' .replace(/\\0/g, "\\\\0")',' .replace(/\\t/g, "\\\\t")',' .replace(/\\n/g, "\\\\n")',' .replace(/\\r/g, "\\\\r")',' .replace(/[\\x00-\\x0F]/g, function(ch) { return "\\\\x0" + hex(ch); })',' .replace(/[\\x10-\\x1F\\x7F-\\x9F]/g, function(ch) { return "\\\\x" + hex(ch); });'," }",""," function classEscape(s) {"," return s",' .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, function(ch) { return "\\\\x0" + hex(ch); })',' .replace(/[\\x10-\\x1F\\x7F-\\x9F]/g, function(ch) { return "\\\\x" + hex(ch); });'," }",""," function describeExpectation(expectation) {"," return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);"," }",""," function describeExpected(expected) {"," var descriptions = expected.map(describeExpectation);"," var i, j;",""," descriptions.sort();",""," if (descriptions.length > 0) {"," for (i = 1, j = 1; i < descriptions.length; i++) {"," if (descriptions[i - 1] !== descriptions[i]) {"," descriptions[j] = descriptions[i];"," j++;"," }"," }"," descriptions.length = j;"," }",""," switch (descriptions.length) {"," case 1:"," return descriptions[0];",""," case 2:",' return descriptions[0] + " or " + descriptions[1];',""," default:",' return descriptions.slice(0, -1).join(", ")',' + ", or "'," + descriptions[descriptions.length - 1];"," }"," }",""," function describeFound(found) {",' return found ? "\\"" + literalEscape(found) + "\\"" : "end of input";'," }","",' return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";',"};",""),g.trace&&ct.push("function peg$DefaultTracer() {"," this.indentLevel = 0;","}","","peg$DefaultTracer.prototype.trace = function(event) {"," var that = this;",""," function log(event) {"," function repeat(string, n) {",' var result = "", i;',""," for (i = 0; i < n; i++) {"," result += string;"," }",""," return result;"," }",""," function pad(string, length) {",' return string + repeat(" ", length - string.length);'," }","",' if (typeof console === "object") {'," console.log(",' event.location.start.line + ":" + event.location.start.column + "-"',' + event.location.end.line + ":" + event.location.end.column + " "',' + pad(event.type, 10) + " "',' + repeat(" ", that.indentLevel) + event.rule'," );"," }"," }",""," switch (event.type) {",' case "rule.enter":'," log(event);"," this.indentLevel++;"," break;","",' case "rule.match":'," this.indentLevel--;"," log(event);"," break;","",' case "rule.fail":'," this.indentLevel--;"," log(event);"," break;",""," default:",' throw new Error("Invalid event type: " + event.type + ".");'," }","};","");const vt="{ "+g.allowedStartRules.map(gt=>gt+": "+tt(gt)).join(", ")+" }",ft=tt(g.allowedStartRules[0]);return ct.push("function peg$parse(input, options) {"," options = options !== undefined ? options : {};",""," var peg$FAILED = {};"," var peg$source = options.grammarSource;",""," var peg$startRuleFunctions = "+vt+";"," var peg$startRuleFunction = "+ft+";","",nt(),""," var peg$currPos = 0;"," var peg$savedPos = 0;"," var peg$posDetailsCache = [{ line: 1, column: 1 }];"," var peg$maxFailPos = 0;"," var peg$maxFailExpected = [];"," var peg$silentFails = 0;",""),g.cache&&ct.push(" var peg$resultsCache = {};",""),g.trace&&ct.push(' var peg$tracer = "tracer" in options ? options.tracer : new peg$DefaultTracer();',""),ct.push(" var peg$result;","",' if ("startRule" in options) {'," if (!(options.startRule in peg$startRuleFunctions)) {",` throw new Error("Can't start parsing from rule \\"" + options.startRule + "\\".");`," }",""," peg$startRuleFunction = peg$startRuleFunctions[options.startRule];"," }",""," function text() {"," return input.substring(peg$savedPos, peg$currPos);"," }",""," function offset() {"," return peg$savedPos;"," }",""," function range() {"," return {"," source: peg$source,"," start: peg$savedPos,"," end: peg$currPos"," };"," }",""," function location() {"," return peg$computeLocation(peg$savedPos, peg$currPos);"," }",""," function expected(description, location) {"," location = location !== undefined"," ? location"," : peg$computeLocation(peg$savedPos, peg$currPos);",""," throw peg$buildStructuredError("," [peg$otherExpectation(description)],"," input.substring(peg$savedPos, peg$currPos),"," location"," );"," }",""," function error(message, location) {"," location = location !== undefined"," ? location"," : peg$computeLocation(peg$savedPos, peg$currPos);",""," throw peg$buildSimpleError(message, location);"," }",""," function peg$literalExpectation(text, ignoreCase) {",' return { type: "literal", text: text, ignoreCase: ignoreCase };'," }",""," function peg$classExpectation(parts, inverted, ignoreCase) {",' return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase };'," }",""," function peg$anyExpectation() {",' return { type: "any" };'," }",""," function peg$endExpectation() {",' return { type: "end" };'," }",""," function peg$otherExpectation(description) {",' return { type: "other", description: description };'," }",""," function peg$computePosDetails(pos) {"," var details = peg$posDetailsCache[pos];"," var p;",""," if (details) {"," return details;"," } else {"," p = pos - 1;"," while (!peg$posDetailsCache[p]) {"," p--;"," }",""," details = peg$posDetailsCache[p];"," details = {"," line: details.line,"," column: details.column"," };",""," while (p < pos) {"," if (input.charCodeAt(p) === 10) {"," details.line++;"," details.column = 1;"," } else {"," details.column++;"," }",""," p++;"," }",""," peg$posDetailsCache[pos] = details;",""," return details;"," }"," }",""," function peg$computeLocation(startPos, endPos, offset) {"," var startPosDetails = peg$computePosDetails(startPos);"," var endPosDetails = peg$computePosDetails(endPos);",""," var res = {"," source: peg$source,"," start: {"," offset: startPos,"," line: startPosDetails.line,"," column: startPosDetails.column"," },"," end: {"," offset: endPos,"," line: endPosDetails.line,"," column: endPosDetails.column"," }"," };",' if (offset && peg$source && (typeof peg$source.offset === "function")) {'," res.start = peg$source.offset(res.start);"," res.end = peg$source.offset(res.end);"," }"," return res;"," }",""," function peg$fail(expected) {"," if (peg$currPos < peg$maxFailPos) { return; }",""," if (peg$currPos > peg$maxFailPos) {"," peg$maxFailPos = peg$currPos;"," peg$maxFailExpected = [];"," }",""," peg$maxFailExpected.push(expected);"," }",""," function peg$buildSimpleError(message, location) {"," return new peg$SyntaxError(message, null, null, location);"," }",""," function peg$buildStructuredError(expected, found, location) {"," return new peg$SyntaxError("," peg$SyntaxError.buildMessage(expected, found),"," expected,"," found,"," location"," );"," }",""),d.rules.forEach(gt=>{ct.push(...$(st(gt))),ct.push("")}),d.initializer&&(ct.push(ut(d.initializer)),ct.push("")),ct.push(" peg$result = peg$startRuleFunction();",""," if (peg$result !== peg$FAILED && peg$currPos === input.length) {"," return peg$result;"," } else {"," if (peg$result !== peg$FAILED && peg$currPos < input.length) {"," peg$fail(peg$endExpectation());"," }",""," throw peg$buildStructuredError("," peg$maxFailExpected,"," peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null,"," peg$maxFailPos < input.length"," ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1)"," : peg$computeLocation(peg$maxFailPos, peg$maxFailPos)"," );"," }","}"),new SourceNode(null,null,g.grammarSource,ct.map(gt=>gt instanceof SourceNode?gt:gt+` -`))}function ht(ct){function vt(){return[`// Generated by Peggy ${VERSION$1}.`,"//","// https://peggyjs.org/"]}function ft(){return g.trace?["{"," SyntaxError: peg$SyntaxError,"," DefaultTracer: peg$DefaultTracer,"," parse: peg$parse","}"].join(` -`):["{"," SyntaxError: peg$SyntaxError,"," parse: peg$parse","}"].join(` -`)}const pt={bare(){return[...vt(),"(function() {",' "use strict";',"",ct,"",$("return "+ft()+";"),"})()"]},commonjs(){const yt=Object.keys(g.dependencies),At=vt();return At.push("",'"use strict";',""),yt.length>0&&(yt.forEach(Dt=>{At.push("var "+Dt+' = require("'+stringEscape(g.dependencies[Dt])+'");')}),At.push("")),At.push(ct,"","module.exports = "+ft()+";"),At},es(){const yt=Object.keys(g.dependencies),At=vt();return At.push(""),yt.length>0&&(yt.forEach(Dt=>{At.push("import "+Dt+' from "'+stringEscape(g.dependencies[Dt])+'";')}),At.push("")),At.push(ct,"","export {"," peg$SyntaxError as SyntaxError,",g.trace?" peg$DefaultTracer as DefaultTracer,":""," peg$parse as parse","};"),At},amd(){const yt=Object.keys(g.dependencies),Dt="["+yt.map(Bt=>g.dependencies[Bt]).map(Bt=>'"'+stringEscape(Bt)+'"').join(", ")+"]",St=yt.join(", ");return[...vt(),"define("+Dt+", function("+St+") {",' "use strict";',"",ct,"",$("return "+ft()+";"),"});"]},globals(){return[...vt(),"(function(root) {",' "use strict";',"",ct,"",$("root."+g.exportVar+" = "+ft()+";"),"})(this);"]},umd(){const yt=Object.keys(g.dependencies),At=yt.map(Ct=>g.dependencies[Ct]),Dt="["+At.map(Ct=>'"'+stringEscape(Ct)+'"').join(", ")+"]",St=At.map(Ct=>'require("'+stringEscape(Ct)+'")').join(", "),Bt=yt.join(", "),Ot=vt();return Ot.push("(function(root, factory) {",' if (typeof define === "function" && define.amd) {'," define("+Dt+", factory);",' } else if (typeof module === "object" && module.exports) {'," module.exports = factory("+St+");"),g.exportVar!==null&&Ot.push(" } else {"," root."+g.exportVar+" = factory();"),Ot.push(" }","})(this, function("+Bt+") {",' "use strict";',"",ct,"",$("return "+ft()+";"),"});"),Ot}}[g.format]();return new SourceNode(null,null,g.grammarSource,pt.map(yt=>yt instanceof SourceNode?yt:yt+` -`))}d.code=ht(at())}var generateJs=generateJS$1;const asts$3=asts_1,visitor$7=visitor_1;function removeProxyRules$1(d,g,$){function b(et){return et.type==="rule"&&et.expression.type==="rule_ref"}function j(et,tt,nt){visitor$7.build({rule_ref(it){it.name===tt&&(it.name=nt,$.info(`Proxy rule "${tt}" replaced by the rule "${nt}"`,it.location,[{message:"This rule will be used",location:asts$3.findRule(et,nt).nameLocation}]))}})(et)}const _e=[];d.rules.forEach((et,tt)=>{b(et)&&(j(d,et.name,et.expression.name),g.allowedStartRules.indexOf(et.name)===-1&&_e.push(tt))}),_e.reverse(),_e.forEach(et=>{d.rules.splice(et,1)})}var removeProxyRules_1=removeProxyRules$1;const visitor$6=visitor_1;function reportDuplicateLabels$1(d,g,$){function b(et){const tt={};return Object.keys(et).forEach(nt=>{tt[nt]=et[nt]}),tt}function j(et,tt){_e(et.expression,b(tt))}const _e=visitor$6.build({rule(et){_e(et.expression,{})},choice(et,tt){et.alternatives.forEach(nt=>{_e(nt,b(tt))})},action:j,labeled(et,tt){const nt=et.label;nt&&Object.prototype.hasOwnProperty.call(tt,nt)&&$.error(`Label "${et.label}" is already defined`,et.labelLocation,[{message:"Original label location",location:tt[nt]}]),_e(et.expression,tt),tt[et.label]=et.labelLocation},text:j,simple_and:j,simple_not:j,optional:j,zero_or_more:j,one_or_more:j,repeated(et,tt){et.delimiter&&_e(et.delimiter,b(tt)),_e(et.expression,b(tt))},group:j});_e(d)}var reportDuplicateLabels_1=reportDuplicateLabels$1;const visitor$5=visitor_1;function reportDuplicateRules$1(d,g,$){const b={};visitor$5.build({rule(_e){if(Object.prototype.hasOwnProperty.call(b,_e.name)){$.error(`Rule "${_e.name}" is already defined`,_e.nameLocation,[{message:"Original rule location",location:b[_e.name]}]);return}b[_e.name]=_e.nameLocation}})(d)}var reportDuplicateRules_1=reportDuplicateRules$1;const asts$2=asts_1,visitor$4=visitor_1;function reportInfiniteRecursion$1(d,g,$){const b=[],j=[],_e=visitor$4.build({rule(et){b.push(et.name),_e(et.expression),b.pop()},sequence(et){et.elements.every(tt=>(_e(tt),!asts$2.alwaysConsumesOnSuccess(d,tt)))},repeated(et){_e(et.expression),et.delimiter&&!asts$2.alwaysConsumesOnSuccess(d,et.expression)&&_e(et.delimiter)},rule_ref(et){j.push(et);const tt=asts$2.findRule(d,et.name);if(b.indexOf(et.name)!==-1){b.push(et.name),$.error("Possible infinite loop when parsing (left recursion: "+b.join(" -> ")+")",tt.nameLocation,j.map((nt,rt,it)=>({message:rt+1!==it.length?`Step ${rt+1}: call of the rule "${nt.name}" without input consumption`:`Step ${rt+1}: call itself without input consumption - left recursion`,location:nt.location})));return}tt&&_e(tt),j.pop()}});_e(d)}var reportInfiniteRecursion_1=reportInfiniteRecursion$1;const asts$1=asts_1,visitor$3=visitor_1;function reportInfiniteRepetition$1(d,g,$){const b=visitor$3.build({zero_or_more(j){asts$1.alwaysConsumesOnSuccess(d,j.expression)||$.error("Possible infinite loop when parsing (repetition used with an expression that may not consume any input)",j.location)},one_or_more(j){asts$1.alwaysConsumesOnSuccess(d,j.expression)||$.error("Possible infinite loop when parsing (repetition used with an expression that may not consume any input)",j.location)},repeated(j){if(j.delimiter&&b(j.delimiter),!(asts$1.alwaysConsumesOnSuccess(d,j.expression)||j.delimiter&&asts$1.alwaysConsumesOnSuccess(d,j.delimiter)))if(j.max.value===null)$.error("Possible infinite loop when parsing (unbounded range repetition used with an expression that may not consume any input)",j.location);else{const _e=j.min?j.min:j.max;$.warning(_e.type==="constant"&&j.max.type==="constant"?`An expression may not consume any input and may always match ${j.max.value} times`:"An expression may not consume any input and may always match with a maximum repetition count",j.location)}}});b(d)}var reportInfiniteRepetition_1=reportInfiniteRepetition$1;const asts=asts_1,visitor$2=visitor_1;function reportUndefinedRules$1(d,g,$){visitor$2.build({rule_ref(j){asts.findRule(d,j.name)||$.error(`Rule "${j.name}" is not defined`,j.location)}})(d)}var reportUndefinedRules_1=reportUndefinedRules$1;const visitor$1=visitor_1;function reportIncorrectPlucking$1(d,g,$){const b=visitor$1.build({action(j){b(j.expression,j)},labeled(j,_e){j.pick&&_e&&$.error('"@" cannot be used with an action block',j.labelLocation,[{message:"Action block location",location:_e.codeLocation}]),b(j.expression)}});b(d)}var reportIncorrectPlucking_1=reportIncorrectPlucking$1;const GrammarError$1=grammarError;class Defaults{constructor(g){g=typeof g<"u"?g:{},typeof g.error=="function"&&(this.error=g.error),typeof g.warning=="function"&&(this.warning=g.warning),typeof g.info=="function"&&(this.info=g.info)}error(){}warning(){}info(){}}let Session$1=class{constructor(g){this._callbacks=new Defaults(g),this._firstError=null,this.errors=0,this.problems=[],this.stage=null}error(...g){++this.errors,this._firstError===null&&(this._firstError=new GrammarError$1(...g),this._firstError.stage=this.stage,this._firstError.problems=this.problems),this.problems.push(["error",...g]),this._callbacks.error(this.stage,...g)}warning(...g){this.problems.push(["warning",...g]),this._callbacks.warning(this.stage,...g)}info(...g){this.problems.push(["info",...g]),this._callbacks.info(this.stage,...g)}checkErrors(){if(this.errors!==0)throw this._firstError}};var session=Session$1;const generateBytecode=generateBytecode_1,generateJS=generateJs,inferenceMatchResult=inferenceMatchResult_1,removeProxyRules=removeProxyRules_1,reportDuplicateLabels=reportDuplicateLabels_1,reportDuplicateRules=reportDuplicateRules_1,reportInfiniteRecursion=reportInfiniteRecursion_1,reportInfiniteRepetition=reportInfiniteRepetition_1,reportUndefinedRules=reportUndefinedRules_1,reportIncorrectPlucking=reportIncorrectPlucking_1,Session=session,visitor=visitor_1,{base64}=utils;function processOptions(d,g){const $={};return Object.keys(d).forEach(b=>{$[b]=d[b]}),Object.keys(g).forEach(b=>{Object.prototype.hasOwnProperty.call($,b)||($[b]=g[b])}),$}function isSourceMapCapable(d){return typeof d=="string"?d.length>0:d&&typeof d.offset=="function"}const compiler$1={visitor,passes:{check:[reportUndefinedRules,reportDuplicateRules,reportDuplicateLabels,reportInfiniteRecursion,reportInfiniteRepetition,reportIncorrectPlucking],transform:[removeProxyRules,inferenceMatchResult],generate:[generateBytecode,generateJS]},compile(ast,passes,options){if(options=options!==void 0?options:{},options=processOptions(options,{allowedStartRules:[ast.rules[0].name],cache:!1,dependencies:{},exportVar:null,format:"bare",output:"parser",trace:!1}),!Array.isArray(options.allowedStartRules))throw new Error("allowedStartRules must be an array");if(options.allowedStartRules.length===0)throw new Error("Must have at least one start rule");const allRules=ast.rules.map(d=>d.name);if(options.allowedStartRules.some(d=>d==="*"))options.allowedStartRules=allRules;else for(const d of options.allowedStartRules)if(allRules.indexOf(d)===-1)throw new Error(`Unknown start rule "${d}"`);if((options.output==="source-and-map"||options.output==="source-with-inline-map")&&!isSourceMapCapable(options.grammarSource))throw new Error("Must provide grammarSource (as a string or GrammarLocation) in order to generate source maps");const session=new Session(options);switch(Object.keys(passes).forEach(d=>{session.stage=d,session.info(`Process stage ${d}`),passes[d].forEach(g=>{session.info(`Process pass ${d}.${g.name}`),g(ast,options,session)}),session.checkErrors()}),options.output){case"parser":return eval(ast.code.toString());case"source":return ast.code.toString();case"source-and-map":return ast.code;case"source-with-inline-map":{if(typeof TextEncoder>"u")throw new Error("TextEncoder is not supported by this platform");const d=ast.code.toStringWithSourceMap(),g=new TextEncoder,$=base64(g.encode(JSON.stringify(d.map.toJSON())));return d.code+`//# sourceMappingURL=data:application/json;charset=utf-8;base64,${$} -`}case"ast":return ast;default:throw new Error("Invalid output format: "+options.output+".")}}};var compiler_1=compiler$1;const OPS_TO_PREFIXED_TYPES={$:"text","&":"simple_and","!":"simple_not"},OPS_TO_SUFFIXED_TYPES={"?":"optional","*":"zero_or_more","+":"one_or_more"},OPS_TO_SEMANTIC_PREDICATE_TYPES={"&":"semantic_and","!":"semantic_not"};function peg$subclass(d,g){function $(){this.constructor=d}$.prototype=g.prototype,d.prototype=new $}function peg$SyntaxError(d,g,$,b){var j=Error.call(this,d);return Object.setPrototypeOf&&Object.setPrototypeOf(j,peg$SyntaxError.prototype),j.expected=g,j.found=$,j.location=b,j.name="SyntaxError",j}peg$subclass(peg$SyntaxError,Error);function peg$padEnd(d,g,$){return $=$||" ",d.length>g?d:(g-=d.length,$+=$.repeat(g),d+$.slice(0,g))}peg$SyntaxError.prototype.format=function(d){var g="Error: "+this.message;if(this.location){var $=null,b;for(b=0;b `+et+` -`+nt+` | -`+_e.line+" | "+rt+` -`+nt+" | "+peg$padEnd("",j.column-1," ")+peg$padEnd("",st,"^")}else g+=` - at `+et}return g};peg$SyntaxError.buildMessage=function(d,g){var $={literal:function(rt){return'"'+j(rt.text)+'"'},class:function(rt){var it=rt.parts.map(function(st){return Array.isArray(st)?_e(st[0])+"-"+_e(st[1]):_e(st)});return"["+(rt.inverted?"^":"")+it.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(rt){return rt.description}};function b(rt){return rt.charCodeAt(0).toString(16).toUpperCase()}function j(rt){return rt.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(it){return"\\x0"+b(it)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(it){return"\\x"+b(it)})}function _e(rt){return rt.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,function(it){return"\\x0"+b(it)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(it){return"\\x"+b(it)})}function et(rt){return $[rt.type](rt)}function tt(rt){var it=rt.map(et),st,ut;if(it.sort(),it.length>0){for(st=1,ut=1;st0?{type:"choice",alternatives:[ot].concat(dt),location:nn()}:ot},Yo=function(ot,dt){return dt!==null?{type:"action",expression:ot,code:dt[0],codeLocation:dt[1],location:nn()}:ot},Xo=function(ot,dt){return dt.length>0||ot.type==="labeled"&&ot.pick?{type:"sequence",elements:[ot].concat(dt),location:nn()}:ot},Qo=function(ot,dt,Et){return Et.type.startsWith("semantic_")&&or('"@" cannot be used on a semantic predicate',ot),{type:"labeled",label:dt!==null?dt[0]:null,labelLocation:dt!==null?dt[1]:ot,pick:!0,expression:Et,location:nn()}},Ko=function(ot,dt){return{type:"labeled",label:ot[0],labelLocation:ot[1],expression:dt,location:nn()}},Zo=function(){return nn()},qo=function(ot){return ys.indexOf(ot[0])>=0&&or(`Label can't be a reserved word "${ot[0]}"`,ot[1]),ot},Jo=function(ot,dt){return{type:OPS_TO_PREFIXED_TYPES[ot],expression:dt,location:nn()}},eu=function(ot,dt){return{type:OPS_TO_SUFFIXED_TYPES[dt],expression:ot,location:nn()}},tu=function(ot,dt,Et){let mt=dt[0],wt=dt[1];return wt.type==="constant"&&wt.value===0&&or("The maximum count of repetitions of the rule must be > 0",wt.location),{type:"repeated",min:mt,max:wt,expression:ot,delimiter:Et,location:nn()}},nu=function(ot,dt){return[ot!==null?ot:{type:"constant",value:0},dt!==null?dt:{type:"constant",value:null}]},ru=function(ot){return[null,ot]},iu=function(ot){return{type:"constant",value:ot,location:nn()}},ou=function(ot){return{type:"variable",value:ot[0],location:nn()}},uu=function(ot){return{type:"function",value:ot[0],codeLocation:ot[1],location:nn()}},su=function(ot){return ot.type==="labeled"||ot.type==="sequence"?{type:"group",expression:ot,location:nn()}:ot},au=function(ot){return{type:"rule_ref",name:ot[0],location:nn()}},lu=function(ot,dt){return{type:OPS_TO_SEMANTIC_PREDICATE_TYPES[ot],code:dt[0],codeLocation:dt[1],location:nn()}},cu=function(ot,dt){return[ot+dt.join(""),nn()]},fu=function(ot,dt){return{type:"literal",value:ot,ignoreCase:dt!==null,location:nn()}},du=function(ot){return ot.join("")},hu=function(ot){return ot.join("")},pu=function(ot,dt,Et){return{type:"class",parts:dt.filter(mt=>mt!==""),inverted:ot!==null,ignoreCase:Et!==null,location:nn()}},gu=function(ot,dt){return ot.charCodeAt(0)>dt.charCodeAt(0)&&or("Invalid character range: "+Du()+"."),[ot,dt]},mu=function(){return""},yu=function(){return"\0"},vu=function(){return"\b"},Eu=function(){return"\f"},Au=function(){return` -`},Cu=function(){return"\r"},xu=function(){return" "},wu=function(){return"\v"},_u=function(ot){return String.fromCharCode(parseInt(ot,16))},Su=function(ot){return String.fromCharCode(parseInt(ot,16))},$u=function(){return{type:"any",location:nn()}},bu=function(ot){return[ot,nn()]},Fu=function(ot){return parseInt(ot,10)},lt=0,Kt=0,rr=[{line:1,column:1}],Rn=0,pr=[],xt=0,ir;if("startRule"in g){if(!(g.startRule in j))throw new Error(`Can't start parsing from rule "`+g.startRule+'".');_e=j[g.startRule]}function Du(){return d.substring(Kt,lt)}function nn(){return ur(Kt,lt)}function or(ot,dt){throw dt=dt!==void 0?dt:ur(Kt,lt),Bu(ot,dt)}function zt(ot,dt){return{type:"literal",text:ot,ignoreCase:dt}}function mn(ot,dt,Et){return{type:"class",parts:ot,inverted:dt,ignoreCase:Et}}function Pu(){return{type:"any"}}function Tu(){return{type:"end"}}function In(ot){return{type:"other",description:ot}}function kr(ot){var dt=rr[ot],Et;if(dt)return dt;for(Et=ot-1;!rr[Et];)Et--;for(dt=rr[Et],dt={line:dt.line,column:dt.column};EtRn&&(Rn=lt,pr=[]),pr.push(ot))}function Bu(ot,dt){return new peg$SyntaxError(ot,null,null,dt)}function ku(ot,dt,Et){return new peg$SyntaxError(peg$SyntaxError.buildMessage(ot,dt),ot,dt,Et)}function Rr(){var ot,dt,Et,mt,wt,Ft;if(ot=lt,en(),dt=lt,Et=Ru(),Et!==$?(mt=en(),dt=Et):(lt=dt,dt=$),dt===$&&(dt=null),Et=lt,mt=Nu(),mt!==$?(wt=en(),Et=mt):(lt=Et,Et=$),Et===$&&(Et=null),mt=[],wt=lt,Ft=Nr(),Ft!==$?(en(),wt=Ft):(lt=wt,wt=$),wt!==$)for(;wt!==$;)mt.push(wt),wt=lt,Ft=Nr(),Ft!==$?(en(),wt=Ft):(lt=wt,wt=$);else mt=$;return mt!==$?(Kt=ot,ot=Uo(dt,Et,mt)):(lt=ot,ot=$),ot}function Ru(){var ot,dt,Et,mt,wt;return ot=lt,d.charCodeAt(lt)===123?(dt=et,lt++):(dt=$,xt===0&&Pt(an)),dt!==$?(Et=Zn(),Et!==$?(d.charCodeAt(lt)===125?(mt=tt,lt++):(mt=$,xt===0&&Pt(gn)),mt!==$?(wt=Sr(),wt!==$?(Kt=ot,ot=Ho(Et)):(lt=ot,ot=$)):(lt=ot,ot=$)):(lt=ot,ot=$)):(lt=ot,ot=$),ot}function Nu(){var ot,dt,Et;return ot=lt,dt=Zn(),dt!==$?(Et=Sr(),Et!==$?(Kt=ot,ot=zo(dt)):(lt=ot,ot=$)):(lt=ot,ot=$),ot}function Nr(){var ot,dt,Et,mt,wt,Ft;return ot=lt,dt=lr(),dt!==$?(en(),Et=lt,mt=Cr(),mt!==$?(en(),Et=mt):(lt=Et,Et=$),Et===$&&(Et=null),d.charCodeAt(lt)===61?(mt=nt,lt++):(mt=$,xt===0&&Pt(_n)),mt!==$?(en(),wt=gr(),wt!==$?(Ft=Sr(),Ft!==$?(Kt=ot,ot=Go(dt,Et,wt)):(lt=ot,ot=$)):(lt=ot,ot=$)):(lt=ot,ot=$)):(lt=ot,ot=$),ot}function gr(){var ot,dt,Et,mt,wt,Ft;if(ot=lt,dt=mr(),dt!==$){for(Et=[],mt=lt,en(),d.charCodeAt(lt)===47?(wt=rt,lt++):(wt=$,xt===0&&Pt(bn)),wt!==$?(en(),Ft=mr(),Ft!==$?mt=Ft:(lt=mt,mt=$)):(lt=mt,mt=$);mt!==$;)Et.push(mt),mt=lt,en(),d.charCodeAt(lt)===47?(wt=rt,lt++):(wt=$,xt===0&&Pt(bn)),wt!==$?(en(),Ft=mr(),Ft!==$?mt=Ft:(lt=mt,mt=$)):(lt=mt,mt=$);Kt=ot,ot=Wo(dt,Et)}else lt=ot,ot=$;return ot}function mr(){var ot,dt,Et,mt;return ot=lt,dt=Ou(),dt!==$?(Et=lt,en(),mt=Zn(),mt!==$?Et=mt:(lt=Et,Et=$),Et===$&&(Et=null),Kt=ot,ot=Yo(dt,Et)):(lt=ot,ot=$),ot}function Ou(){var ot,dt,Et,mt,wt;if(ot=lt,dt=yr(),dt!==$){for(Et=[],mt=lt,en(),wt=yr(),wt!==$?mt=wt:(lt=mt,mt=$);mt!==$;)Et.push(mt),mt=lt,en(),wt=yr(),wt!==$?mt=wt:(lt=mt,mt=$);Kt=ot,ot=Xo(dt,Et)}else lt=ot,ot=$;return ot}function yr(){var ot,dt,Et,mt;return ot=lt,dt=Mu(),dt!==$?(Et=Or(),Et===$&&(Et=null),mt=vr(),mt!==$?(Kt=ot,ot=Qo(dt,Et,mt)):(lt=ot,ot=$)):(lt=ot,ot=$),ot===$&&(ot=lt,dt=Or(),dt!==$?(Et=en(),mt=vr(),mt!==$?(Kt=ot,ot=Ko(dt,mt)):(lt=ot,ot=$)):(lt=ot,ot=$),ot===$&&(ot=vr())),ot}function Mu(){var ot,dt;return ot=lt,d.charCodeAt(lt)===64?(dt=it,lt++):(dt=$,xt===0&&Pt(rn)),dt!==$&&(Kt=ot,dt=Zo()),ot=dt,ot}function Or(){var ot,dt,Et;return ot=lt,dt=lr(),dt!==$?(en(),d.charCodeAt(lt)===58?(Et=st,lt++):(Et=$,xt===0&&Pt(Xn)),Et!==$?(Kt=ot,ot=qo(dt)):(lt=ot,ot=$)):(lt=ot,ot=$),ot}function vr(){var ot,dt,Et;return ot=lt,dt=Lu(),dt!==$?(en(),Et=Mr(),Et!==$?(Kt=ot,ot=Jo(dt,Et)):(lt=ot,ot=$)):(lt=ot,ot=$),ot===$&&(ot=Mr()),ot}function Lu(){var ot;return d.charCodeAt(lt)===36?(ot=ut,lt++):(ot=$,xt===0&&Pt(fn)),ot===$&&(d.charCodeAt(lt)===38?(ot=at,lt++):(ot=$,xt===0&&Pt(An)),ot===$&&(d.charCodeAt(lt)===33?(ot=ht,lt++):(ot=$,xt===0&&Pt(kn)))),ot}function Mr(){var ot,dt,Et;return ot=lt,dt=Ar(),dt!==$?(en(),Et=Iu(),Et!==$?(Kt=ot,ot=eu(dt,Et)):(lt=ot,ot=$)):(lt=ot,ot=$),ot===$&&(ot=ju(),ot===$&&(ot=Ar())),ot}function Iu(){var ot;return d.charCodeAt(lt)===63?(ot=ct,lt++):(ot=$,xt===0&&Pt(zn)),ot===$&&(d.charCodeAt(lt)===42?(ot=vt,lt++):(ot=$,xt===0&&Pt(Qn)),ot===$&&(d.charCodeAt(lt)===43?(ot=ft,lt++):(ot=$,xt===0&&Pt(dr)))),ot}function ju(){var ot,dt,Et,mt,wt,Ft,hn;return ot=lt,dt=Ar(),dt!==$?(en(),d.charCodeAt(lt)===124?(Et=gt,lt++):(Et=$,xt===0&&Pt(qn)),Et!==$?(en(),mt=Vu(),mt!==$?(en(),wt=lt,d.charCodeAt(lt)===44?(Ft=pt,lt++):(Ft=$,xt===0&&Pt(Fn)),Ft!==$?(en(),hn=gr(),hn!==$?(en(),wt=hn):(lt=wt,wt=$)):(lt=wt,wt=$),wt===$&&(wt=null),d.charCodeAt(lt)===124?(Ft=gt,lt++):(Ft=$,xt===0&&Pt(qn)),Ft!==$?(Kt=ot,ot=tu(dt,mt,wt)):(lt=ot,ot=$)):(lt=ot,ot=$)):(lt=ot,ot=$)):(lt=ot,ot=$),ot}function Vu(){var ot,dt,Et,mt;return ot=lt,dt=Er(),dt===$&&(dt=null),en(),d.substr(lt,2)===yt?(Et=yt,lt+=2):(Et=$,xt===0&&Pt(Kn)),Et!==$?(en(),mt=Er(),mt===$&&(mt=null),Kt=ot,ot=nu(dt,mt)):(lt=ot,ot=$),ot===$&&(ot=lt,dt=Er(),dt!==$&&(Kt=ot,dt=ru(dt)),ot=dt),ot}function Er(){var ot,dt;return ot=lt,dt=ns(),dt!==$&&(Kt=ot,dt=iu(dt)),ot=dt,ot===$&&(ot=lt,dt=lr(),dt!==$&&(Kt=ot,dt=ou(dt)),ot=dt,ot===$&&(ot=lt,dt=Zn(),dt!==$&&(Kt=ot,dt=uu(dt)),ot=dt)),ot}function Ar(){var ot,dt,Et,mt;return ot=Xu(),ot===$&&(ot=Qu(),ot===$&&(ot=es(),ot===$&&(ot=Uu(),ot===$&&(ot=Hu(),ot===$&&(ot=lt,d.charCodeAt(lt)===40?(dt=At,lt++):(dt=$,xt===0&&Pt(Jn)),dt!==$?(en(),Et=gr(),Et!==$?(en(),d.charCodeAt(lt)===41?(mt=Dt,lt++):(mt=$,xt===0&&Pt(hr)),mt!==$?(Kt=ot,ot=su(Et)):(lt=ot,ot=$)):(lt=ot,ot=$)):(lt=ot,ot=$)))))),ot}function Uu(){var ot,dt,Et,mt,wt,Ft,hn,Yn;return ot=lt,dt=lr(),dt!==$?(Et=lt,xt++,mt=lt,wt=en(),Ft=lt,hn=Cr(),hn!==$?(Yn=en(),hn=[hn,Yn],Ft=hn):(lt=Ft,Ft=$),Ft===$&&(Ft=null),d.charCodeAt(lt)===61?(hn=nt,lt++):(hn=$,xt===0&&Pt(_n)),hn!==$?(wt=[wt,Ft,hn],mt=wt):(lt=mt,mt=$),xt--,mt===$?Et=void 0:(lt=Et,Et=$),Et!==$?(Kt=ot,ot=au(dt)):(lt=ot,ot=$)):(lt=ot,ot=$),ot}function Hu(){var ot,dt,Et;return ot=lt,dt=zu(),dt!==$?(en(),Et=Zn(),Et!==$?(Kt=ot,ot=lu(dt,Et)):(lt=ot,ot=$)):(lt=ot,ot=$),ot}function zu(){var ot;return d.charCodeAt(lt)===38?(ot=at,lt++):(ot=$,xt===0&&Pt(An)),ot===$&&(d.charCodeAt(lt)===33?(ot=ht,lt++):(ot=$,xt===0&&Pt(kn))),ot}function vn(){var ot;return d.length>lt?(ot=d.charAt(lt),lt++):(ot=$,xt===0&&Pt($r)),ot}function sr(){var ot;return xt++,d.charCodeAt(lt)===9?(ot=St,lt++):(ot=$,xt===0&&Pt(Qr)),ot===$&&(d.charCodeAt(lt)===11?(ot=Bt,lt++):(ot=$,xt===0&&Pt(Kr)),ot===$&&(d.charCodeAt(lt)===12?(ot=Ot,lt++):(ot=$,xt===0&&Pt(Zr)),ot===$&&(d.charCodeAt(lt)===32?(ot=Ct,lt++):(ot=$,xt===0&&Pt(qr)),ot===$&&(d.charCodeAt(lt)===160?(ot=_t,lt++):(ot=$,xt===0&&Pt(Jr)),ot===$&&(d.charCodeAt(lt)===65279?(ot=Tt,lt++):(ot=$,xt===0&&Pt(_i)),ot===$&&(ot=ps())))))),xt--,ot===$&&xt===0&&Pt(Xr),ot}function jn(){var ot;return $n.test(d.charAt(lt))?(ot=d.charAt(lt),lt++):(ot=$,xt===0&&Pt(eo)),ot}function ar(){var ot;return xt++,d.charCodeAt(lt)===10?(ot=kt,lt++):(ot=$,xt===0&&Pt(no)),ot===$&&(d.substr(lt,2)===Mt?(ot=Mt,lt+=2):(ot=$,xt===0&&Pt(ro)),ot===$&&(d.charCodeAt(lt)===13?(ot=Vt,lt++):(ot=$,xt===0&&Pt(io)),ot===$&&(d.charCodeAt(lt)===8232?(ot=Jt,lt++):(ot=$,xt===0&&Pt(oo)),ot===$&&(d.charCodeAt(lt)===8233?(ot=Xt,lt++):(ot=$,xt===0&&Pt(uo)))))),xt--,ot===$&&xt===0&&Pt(to),ot}function Lr(){var ot;return xt++,ot=Gu(),ot===$&&(ot=jr()),xt--,ot===$&&xt===0&&Pt(so),ot}function Gu(){var ot,dt,Et,mt,wt,Ft;if(ot=lt,d.substr(lt,2)===Nt?(dt=Nt,lt+=2):(dt=$,xt===0&&Pt(br)),dt!==$){for(Et=[],mt=lt,wt=lt,xt++,d.substr(lt,2)===Lt?(Ft=Lt,lt+=2):(Ft=$,xt===0&&Pt(Gn)),xt--,Ft===$?wt=void 0:(lt=wt,wt=$),wt!==$?(Ft=vn(),Ft!==$?(wt=[wt,Ft],mt=wt):(lt=mt,mt=$)):(lt=mt,mt=$);mt!==$;)Et.push(mt),mt=lt,wt=lt,xt++,d.substr(lt,2)===Lt?(Ft=Lt,lt+=2):(Ft=$,xt===0&&Pt(Gn)),xt--,Ft===$?wt=void 0:(lt=wt,wt=$),wt!==$?(Ft=vn(),Ft!==$?(wt=[wt,Ft],mt=wt):(lt=mt,mt=$)):(lt=mt,mt=$);d.substr(lt,2)===Lt?(mt=Lt,lt+=2):(mt=$,xt===0&&Pt(Gn)),mt!==$?(dt=[dt,Et,mt],ot=dt):(lt=ot,ot=$)}else lt=ot,ot=$;return ot}function Ir(){var ot,dt,Et,mt,wt,Ft;if(ot=lt,d.substr(lt,2)===Nt?(dt=Nt,lt+=2):(dt=$,xt===0&&Pt(br)),dt!==$){for(Et=[],mt=lt,wt=lt,xt++,d.substr(lt,2)===Lt?(Ft=Lt,lt+=2):(Ft=$,xt===0&&Pt(Gn)),Ft===$&&(Ft=jn()),xt--,Ft===$?wt=void 0:(lt=wt,wt=$),wt!==$?(Ft=vn(),Ft!==$?(wt=[wt,Ft],mt=wt):(lt=mt,mt=$)):(lt=mt,mt=$);mt!==$;)Et.push(mt),mt=lt,wt=lt,xt++,d.substr(lt,2)===Lt?(Ft=Lt,lt+=2):(Ft=$,xt===0&&Pt(Gn)),Ft===$&&(Ft=jn()),xt--,Ft===$?wt=void 0:(lt=wt,wt=$),wt!==$?(Ft=vn(),Ft!==$?(wt=[wt,Ft],mt=wt):(lt=mt,mt=$)):(lt=mt,mt=$);d.substr(lt,2)===Lt?(mt=Lt,lt+=2):(mt=$,xt===0&&Pt(Gn)),mt!==$?(dt=[dt,Et,mt],ot=dt):(lt=ot,ot=$)}else lt=ot,ot=$;return ot}function jr(){var ot,dt,Et,mt,wt,Ft;if(ot=lt,d.substr(lt,2)===jt?(dt=jt,lt+=2):(dt=$,xt===0&&Pt(ao)),dt!==$){for(Et=[],mt=lt,wt=lt,xt++,Ft=jn(),xt--,Ft===$?wt=void 0:(lt=wt,wt=$),wt!==$?(Ft=vn(),Ft!==$?(wt=[wt,Ft],mt=wt):(lt=mt,mt=$)):(lt=mt,mt=$);mt!==$;)Et.push(mt),mt=lt,wt=lt,xt++,Ft=jn(),xt--,Ft===$?wt=void 0:(lt=wt,wt=$),wt!==$?(Ft=vn(),Ft!==$?(wt=[wt,Ft],mt=wt):(lt=mt,mt=$)):(lt=mt,mt=$);dt=[dt,Et],ot=dt}else lt=ot,ot=$;return ot}function lr(){var ot,dt,Et,mt;if(xt++,ot=lt,dt=Vr(),dt!==$){for(Et=[],mt=Ur();mt!==$;)Et.push(mt),mt=Ur();Kt=ot,ot=cu(dt,Et)}else lt=ot,ot=$;return xt--,ot===$&&(dt=$,xt===0&&Pt(lo)),ot}function Vr(){var ot,dt,Et;return ot=Wu(),ot===$&&(d.charCodeAt(lt)===95?(ot=Yt,lt++):(ot=$,xt===0&&Pt(co)),ot===$&&(ot=lt,d.charCodeAt(lt)===92?(dt=Qt,lt++):(dt=$,xt===0&&Pt(Mn)),dt!==$?(Et=Yr(),Et!==$?ot=Et:(lt=ot,ot=$)):(lt=ot,ot=$))),ot}function Ur(){var ot;return ot=Vr(),ot===$&&(d.charCodeAt(lt)===36?(ot=ut,lt++):(ot=$,xt===0&&Pt(fn)),ot===$&&(ot=Yu(),ot===$&&(ot=fs(),ot===$&&(ot=hs(),ot===$&&(d.charCodeAt(lt)===8204?(ot=on,lt++):(ot=$,xt===0&&Pt(fo)),ot===$&&(d.charCodeAt(lt)===8205?(ot=un,lt++):(ot=$,xt===0&&Pt(ho)))))))),ot}function Wu(){var ot;return ot=as(),ot===$&&(ot=rs(),ot===$&&(ot=ss(),ot===$&&(ot=os(),ot===$&&(ot=us(),ot===$&&(ot=ds()))))),ot}function Yu(){var ot;return ot=cs(),ot===$&&(ot=ls()),ot}function Xu(){var ot,dt,Et;return xt++,ot=lt,dt=Cr(),dt!==$?(d.charCodeAt(lt)===105?(Et=pn,lt++):(Et=$,xt===0&&Pt(Fr)),Et===$&&(Et=null),Kt=ot,ot=fu(dt,Et)):(lt=ot,ot=$),xt--,ot===$&&(dt=$,xt===0&&Pt(po)),ot}function Cr(){var ot,dt,Et,mt;if(xt++,ot=lt,d.charCodeAt(lt)===34?(dt=ln,lt++):(dt=$,xt===0&&Pt(er)),dt!==$){for(Et=[],mt=Hr();mt!==$;)Et.push(mt),mt=Hr();d.charCodeAt(lt)===34?(mt=ln,lt++):(mt=$,xt===0&&Pt(er)),mt!==$?(Kt=ot,ot=du(Et)):(lt=ot,ot=$)}else lt=ot,ot=$;if(ot===$)if(ot=lt,d.charCodeAt(lt)===39?(dt=yn,lt++):(dt=$,xt===0&&Pt(tr)),dt!==$){for(Et=[],mt=zr();mt!==$;)Et.push(mt),mt=zr();d.charCodeAt(lt)===39?(mt=yn,lt++):(mt=$,xt===0&&Pt(tr)),mt!==$?(Kt=ot,ot=hu(Et)):(lt=ot,ot=$)}else lt=ot,ot=$;return xt--,ot===$&&(dt=$,xt===0&&Pt(go)),ot}function Hr(){var ot,dt,Et,mt;return ot=lt,dt=lt,Et=lt,xt++,d.charCodeAt(lt)===34?(mt=ln,lt++):(mt=$,xt===0&&Pt(er)),mt===$&&(d.charCodeAt(lt)===92?(mt=Qt,lt++):(mt=$,xt===0&&Pt(Mn)),mt===$&&(mt=jn())),xt--,mt===$?Et=void 0:(lt=Et,Et=$),Et!==$?(mt=vn(),mt!==$?(Et=[Et,mt],dt=Et):(lt=dt,dt=$)):(lt=dt,dt=$),dt!==$?ot=d.substring(ot,lt):ot=dt,ot===$&&(ot=lt,d.charCodeAt(lt)===92?(dt=Qt,lt++):(dt=$,xt===0&&Pt(Mn)),dt!==$?(Et=wr(),Et!==$?ot=Et:(lt=ot,ot=$)):(lt=ot,ot=$),ot===$&&(ot=xr())),ot}function zr(){var ot,dt,Et,mt;return ot=lt,dt=lt,Et=lt,xt++,d.charCodeAt(lt)===39?(mt=yn,lt++):(mt=$,xt===0&&Pt(tr)),mt===$&&(d.charCodeAt(lt)===92?(mt=Qt,lt++):(mt=$,xt===0&&Pt(Mn)),mt===$&&(mt=jn())),xt--,mt===$?Et=void 0:(lt=Et,Et=$),Et!==$?(mt=vn(),mt!==$?(Et=[Et,mt],dt=Et):(lt=dt,dt=$)):(lt=dt,dt=$),dt!==$?ot=d.substring(ot,lt):ot=dt,ot===$&&(ot=lt,d.charCodeAt(lt)===92?(dt=Qt,lt++):(dt=$,xt===0&&Pt(Mn)),dt!==$?(Et=wr(),Et!==$?ot=Et:(lt=ot,ot=$)):(lt=ot,ot=$),ot===$&&(ot=xr())),ot}function Qu(){var ot,dt,Et,mt,wt,Ft;if(xt++,ot=lt,d.charCodeAt(lt)===91?(dt=Dn,lt++):(dt=$,xt===0&&Pt(yo)),dt!==$){for(d.charCodeAt(lt)===94?(Et=Vn,lt++):(Et=$,xt===0&&Pt(vo)),Et===$&&(Et=null),mt=[],wt=Gr(),wt===$&&(wt=cr());wt!==$;)mt.push(wt),wt=Gr(),wt===$&&(wt=cr());d.charCodeAt(lt)===93?(wt=Sn,lt++):(wt=$,xt===0&&Pt(Dr)),wt!==$?(d.charCodeAt(lt)===105?(Ft=pn,lt++):(Ft=$,xt===0&&Pt(Fr)),Ft===$&&(Ft=null),Kt=ot,ot=pu(Et,mt,Ft)):(lt=ot,ot=$)}else lt=ot,ot=$;return xt--,ot===$&&(dt=$,xt===0&&Pt(mo)),ot}function Gr(){var ot,dt,Et,mt;return ot=lt,dt=cr(),dt!==$?(d.charCodeAt(lt)===45?(Et=Nn,lt++):(Et=$,xt===0&&Pt(Eo)),Et!==$?(mt=cr(),mt!==$?(Kt=ot,ot=gu(dt,mt)):(lt=ot,ot=$)):(lt=ot,ot=$)):(lt=ot,ot=$),ot}function cr(){var ot,dt,Et,mt;return ot=lt,dt=lt,Et=lt,xt++,d.charCodeAt(lt)===93?(mt=Sn,lt++):(mt=$,xt===0&&Pt(Dr)),mt===$&&(d.charCodeAt(lt)===92?(mt=Qt,lt++):(mt=$,xt===0&&Pt(Mn)),mt===$&&(mt=jn())),xt--,mt===$?Et=void 0:(lt=Et,Et=$),Et!==$?(mt=vn(),mt!==$?(Et=[Et,mt],dt=Et):(lt=dt,dt=$)):(lt=dt,dt=$),dt!==$?ot=d.substring(ot,lt):ot=dt,ot===$&&(ot=lt,d.charCodeAt(lt)===92?(dt=Qt,lt++):(dt=$,xt===0&&Pt(Mn)),dt!==$?(Et=wr(),Et!==$?ot=Et:(lt=ot,ot=$)):(lt=ot,ot=$),ot===$&&(ot=xr())),ot}function xr(){var ot,dt,Et;return ot=lt,d.charCodeAt(lt)===92?(dt=Qt,lt++):(dt=$,xt===0&&Pt(Mn)),dt!==$?(Et=ar(),Et!==$?(Kt=ot,ot=mu()):(lt=ot,ot=$)):(lt=ot,ot=$),ot}function wr(){var ot,dt,Et,mt;return ot=Ku(),ot===$&&(ot=lt,d.charCodeAt(lt)===48?(dt=On,lt++):(dt=$,xt===0&&Pt(Ao)),dt!==$?(Et=lt,xt++,mt=fr(),xt--,mt===$?Et=void 0:(lt=Et,Et=$),Et!==$?(Kt=ot,ot=yu()):(lt=ot,ot=$)):(lt=ot,ot=$),ot===$&&(ot=Ju(),ot===$&&(ot=Yr()))),ot}function Ku(){var ot;return ot=Wr(),ot===$&&(ot=Zu()),ot}function Wr(){var ot,dt;return d.charCodeAt(lt)===39?(ot=yn,lt++):(ot=$,xt===0&&Pt(tr)),ot===$&&(d.charCodeAt(lt)===34?(ot=ln,lt++):(ot=$,xt===0&&Pt(er)),ot===$&&(d.charCodeAt(lt)===92?(ot=Qt,lt++):(ot=$,xt===0&&Pt(Mn)),ot===$&&(ot=lt,d.charCodeAt(lt)===98?(dt=Pn,lt++):(dt=$,xt===0&&Pt(Co)),dt!==$&&(Kt=ot,dt=vu()),ot=dt,ot===$&&(ot=lt,d.charCodeAt(lt)===102?(dt=Cn,lt++):(dt=$,xt===0&&Pt(xo)),dt!==$&&(Kt=ot,dt=Eu()),ot=dt,ot===$&&(ot=lt,d.charCodeAt(lt)===110?(dt=Ln,lt++):(dt=$,xt===0&&Pt(wo)),dt!==$&&(Kt=ot,dt=Au()),ot=dt,ot===$&&(ot=lt,d.charCodeAt(lt)===114?(dt=Un,lt++):(dt=$,xt===0&&Pt(_o)),dt!==$&&(Kt=ot,dt=Cu()),ot=dt,ot===$&&(ot=lt,d.charCodeAt(lt)===116?(dt=Hn,lt++):(dt=$,xt===0&&Pt(So)),dt!==$&&(Kt=ot,dt=xu()),ot=dt,ot===$&&(ot=lt,d.charCodeAt(lt)===118?(dt=Tn,lt++):(dt=$,xt===0&&Pt($o)),dt!==$&&(Kt=ot,dt=wu()),ot=dt)))))))),ot}function Zu(){var ot,dt,Et,mt;return ot=lt,dt=lt,Et=lt,xt++,mt=qu(),mt===$&&(mt=jn()),xt--,mt===$?Et=void 0:(lt=Et,Et=$),Et!==$?(mt=vn(),mt!==$?(Et=[Et,mt],dt=Et):(lt=dt,dt=$)):(lt=dt,dt=$),dt!==$?ot=d.substring(ot,lt):ot=dt,ot}function qu(){var ot;return ot=Wr(),ot===$&&(ot=fr(),ot===$&&(d.charCodeAt(lt)===120?(ot=Bn,lt++):(ot=$,xt===0&&Pt(Pr)),ot===$&&(d.charCodeAt(lt)===117?(ot=xn,lt++):(ot=$,xt===0&&Pt(Tr))))),ot}function Ju(){var ot,dt,Et,mt,wt,Ft;return ot=lt,d.charCodeAt(lt)===120?(dt=Bn,lt++):(dt=$,xt===0&&Pt(Pr)),dt!==$?(Et=lt,mt=lt,wt=Wn(),wt!==$?(Ft=Wn(),Ft!==$?(wt=[wt,Ft],mt=wt):(lt=mt,mt=$)):(lt=mt,mt=$),mt!==$?Et=d.substring(Et,lt):Et=mt,Et!==$?(Kt=ot,ot=_u(Et)):(lt=ot,ot=$)):(lt=ot,ot=$),ot}function Yr(){var ot,dt,Et,mt,wt,Ft,hn,Yn;return ot=lt,d.charCodeAt(lt)===117?(dt=xn,lt++):(dt=$,xt===0&&Pt(Tr)),dt!==$?(Et=lt,mt=lt,wt=Wn(),wt!==$?(Ft=Wn(),Ft!==$?(hn=Wn(),hn!==$?(Yn=Wn(),Yn!==$?(wt=[wt,Ft,hn,Yn],mt=wt):(lt=mt,mt=$)):(lt=mt,mt=$)):(lt=mt,mt=$)):(lt=mt,mt=$),mt!==$?Et=d.substring(Et,lt):Et=mt,Et!==$?(Kt=ot,ot=Su(Et)):(lt=ot,ot=$)):(lt=ot,ot=$),ot}function fr(){var ot;return cn.test(d.charAt(lt))?(ot=d.charAt(lt),lt++):(ot=$,xt===0&&Pt(bo)),ot}function Wn(){var ot;return $t.test(d.charAt(lt))?(ot=d.charAt(lt),lt++):(ot=$,xt===0&&Pt(Fo)),ot}function es(){var ot,dt;return ot=lt,d.charCodeAt(lt)===46?(dt=En,lt++):(dt=$,xt===0&&Pt(Do)),dt!==$&&(Kt=ot,dt=$u()),ot=dt,ot}function Zn(){var ot,dt,Et,mt;return xt++,ot=lt,d.charCodeAt(lt)===123?(dt=et,lt++):(dt=$,xt===0&&Pt(an)),dt!==$?(Et=ts(),d.charCodeAt(lt)===125?(mt=tt,lt++):(mt=$,xt===0&&Pt(gn)),mt!==$?ot=Et:(lt=ot,ot=$)):(lt=ot,ot=$),xt--,ot===$&&(dt=$,xt===0&&Pt(Po)),ot}function ts(){var ot,dt;return ot=lt,dt=_r(),Kt=ot,dt=bu(dt),ot=dt,ot}function _r(){var ot,dt,Et,mt,wt,Ft;if(ot=lt,dt=[],Et=[],mt=lt,wt=lt,xt++,bt.test(d.charAt(lt))?(Ft=d.charAt(lt),lt++):(Ft=$,xt===0&&Pt(nr)),xt--,Ft===$?wt=void 0:(lt=wt,wt=$),wt!==$?(Ft=vn(),Ft!==$?(wt=[wt,Ft],mt=wt):(lt=mt,mt=$)):(lt=mt,mt=$),mt!==$)for(;mt!==$;)Et.push(mt),mt=lt,wt=lt,xt++,bt.test(d.charAt(lt))?(Ft=d.charAt(lt),lt++):(Ft=$,xt===0&&Pt(nr)),xt--,Ft===$?wt=void 0:(lt=wt,wt=$),wt!==$?(Ft=vn(),Ft!==$?(wt=[wt,Ft],mt=wt):(lt=mt,mt=$)):(lt=mt,mt=$);else Et=$;for(Et===$&&(Et=lt,d.charCodeAt(lt)===123?(mt=et,lt++):(mt=$,xt===0&&Pt(an)),mt!==$?(wt=_r(),d.charCodeAt(lt)===125?(Ft=tt,lt++):(Ft=$,xt===0&&Pt(gn)),Ft!==$?(mt=[mt,wt,Ft],Et=mt):(lt=Et,Et=$)):(lt=Et,Et=$));Et!==$;){if(dt.push(Et),Et=[],mt=lt,wt=lt,xt++,bt.test(d.charAt(lt))?(Ft=d.charAt(lt),lt++):(Ft=$,xt===0&&Pt(nr)),xt--,Ft===$?wt=void 0:(lt=wt,wt=$),wt!==$?(Ft=vn(),Ft!==$?(wt=[wt,Ft],mt=wt):(lt=mt,mt=$)):(lt=mt,mt=$),mt!==$)for(;mt!==$;)Et.push(mt),mt=lt,wt=lt,xt++,bt.test(d.charAt(lt))?(Ft=d.charAt(lt),lt++):(Ft=$,xt===0&&Pt(nr)),xt--,Ft===$?wt=void 0:(lt=wt,wt=$),wt!==$?(Ft=vn(),Ft!==$?(wt=[wt,Ft],mt=wt):(lt=mt,mt=$)):(lt=mt,mt=$);else Et=$;Et===$&&(Et=lt,d.charCodeAt(lt)===123?(mt=et,lt++):(mt=$,xt===0&&Pt(an)),mt!==$?(wt=_r(),d.charCodeAt(lt)===125?(Ft=tt,lt++):(Ft=$,xt===0&&Pt(gn)),Ft!==$?(mt=[mt,wt,Ft],Et=mt):(lt=Et,Et=$)):(lt=Et,Et=$))}return ot=d.substring(ot,lt),ot}function ns(){var ot,dt,Et,mt;if(ot=lt,dt=lt,Et=[],mt=fr(),mt!==$)for(;mt!==$;)Et.push(mt),mt=fr();else Et=$;return Et!==$?dt=d.substring(dt,lt):dt=Et,dt!==$&&(Kt=ot,dt=Fu(dt)),ot=dt,ot}function rs(){var ot;return Rt.test(d.charAt(lt))?(ot=d.charAt(lt),lt++):(ot=$,xt===0&&Pt(To)),ot}function os(){var ot;return Ut.test(d.charAt(lt))?(ot=d.charAt(lt),lt++):(ot=$,xt===0&&Pt(Bo)),ot}function us(){var ot;return It.test(d.charAt(lt))?(ot=d.charAt(lt),lt++):(ot=$,xt===0&&Pt(ko)),ot}function ss(){var ot;return Wt.test(d.charAt(lt))?(ot=d.charAt(lt),lt++):(ot=$,xt===0&&Pt(Ro)),ot}function as(){var ot;return Gt.test(d.charAt(lt))?(ot=d.charAt(lt),lt++):(ot=$,xt===0&&Pt(No)),ot}function ls(){var ot;return Zt.test(d.charAt(lt))?(ot=d.charAt(lt),lt++):(ot=$,xt===0&&Pt(Oo)),ot}function cs(){var ot;return Ht.test(d.charAt(lt))?(ot=d.charAt(lt),lt++):(ot=$,xt===0&&Pt(Mo)),ot}function fs(){var ot;return sn.test(d.charAt(lt))?(ot=d.charAt(lt),lt++):(ot=$,xt===0&&Pt(Lo)),ot}function ds(){var ot;return qt.test(d.charAt(lt))?(ot=d.charAt(lt),lt++):(ot=$,xt===0&&Pt(Io)),ot}function hs(){var ot;return tn.test(d.charAt(lt))?(ot=d.charAt(lt),lt++):(ot=$,xt===0&&Pt(jo)),ot}function ps(){var ot;return dn.test(d.charAt(lt))?(ot=d.charAt(lt),lt++):(ot=$,xt===0&&Pt(Vo)),ot}function en(){var ot,dt;for(ot=[],dt=sr(),dt===$&&(dt=ar(),dt===$&&(dt=Lr()));dt!==$;)ot.push(dt),dt=sr(),dt===$&&(dt=ar(),dt===$&&(dt=Lr()));return ot}function gs(){var ot,dt;for(ot=[],dt=sr(),dt===$&&(dt=Ir());dt!==$;)ot.push(dt),dt=sr(),dt===$&&(dt=Ir());return ot}function Sr(){var ot,dt,Et,mt;if(ot=[],dt=lt,Et=en(),d.charCodeAt(lt)===59?(mt=wn,lt++):(mt=$,xt===0&&Pt(Br)),mt!==$?(Et=[Et,mt],dt=Et):(lt=dt,dt=$),dt!==$)for(;dt!==$;)ot.push(dt),dt=lt,Et=en(),d.charCodeAt(lt)===59?(mt=wn,lt++):(mt=$,xt===0&&Pt(Br)),mt!==$?(Et=[Et,mt],dt=Et):(lt=dt,dt=$);else ot=$;return ot===$&&(ot=lt,dt=gs(),Et=jr(),Et===$&&(Et=null),mt=ar(),mt!==$?(dt=[dt,Et,mt],ot=dt):(lt=ot,ot=$),ot===$&&(ot=lt,dt=en(),Et=ms(),Et!==$?(dt=[dt,Et],ot=dt):(lt=ot,ot=$))),ot}function ms(){var ot,dt;return ot=lt,xt++,d.length>lt?(dt=d.charAt(lt),lt++):(dt=$,xt===0&&Pt($r)),xt--,dt===$?ot=void 0:(lt=ot,ot=$),ot}const ys=g.reservedWords||[];if(ir=_e(),ir!==$&<===d.length)return ir;throw ir!==$&<{et[tt]=_e[tt].slice()}),et}const b="plugins"in g?g.plugins:[],j={parser:peg.parser,passes:$(peg.compiler.passes),reservedWords:peg.RESERVED_WORDS.slice()};return b.forEach(_e=>{_e.use(j,g)}),peg.compiler.compile(j.parser.parse(d,{grammarSource:g.grammarSource,reservedWords:j.reservedWords}),j.passes,g)}};var peg_1=peg;const tocLangGrammarUrl="data:application/octet-stream;base64,Ly8gRGVidWcgd2l0aCBQZWdneUpzIHNhbmRib3gKLy8gaHR0cHM6Ly9wZWdneWpzLm9yZy9vbmxpbmUuaHRtbAoKewogIGZ1bmN0aW9uIG1ha2VJbnRlZ2VyKG8pIHsKICAgIHJldHVybiBwYXJzZUludChvLmpvaW4oIiIpLCAxMCk7CiAgfQp9CgpzdGFydAogID0gc3RhdGVtZW50OnN0YXRlbWVudD8gbW9yZVN0YXRlbWVudHM6KEVPTCBfIEBzdGF0ZW1lbnQpKiBFT0w/IF8KewogIGNvbnN0IHN0YXRlbWVudHMgPSBzdGF0ZW1lbnQgPyBbc3RhdGVtZW50LCAuLi5tb3JlU3RhdGVtZW50c10gOiBtb3JlU3RhdGVtZW50czsKICByZXR1cm4gewogICAgc3RhdGVtZW50czogc3RhdGVtZW50cwogIH07Cn0KCnN0YXRlbWVudCA9IGNvbW1lbnRMaW5lIC8gbm9kZVN0YXRlbWVudCAvIGVkZ2VTdGF0ZW1lbnQKCmNvbW1lbnRMaW5lID0gXyAiIyIgdGV4dDooW15cblxyXSopCnsKICByZXR1cm4gewogICAgdHlwZTogImNvbW1lbnQiLAogICAgdGV4dDogdGV4dC5qb2luKCIiKQogIH07Cn0KCm5vZGVTdGF0ZW1lbnQgPSBfIGlkZW50OmlkZW50IF8gbGFiZWw6Y29sb25MYWJlbCBfIHBhcmFtczpwYXJhbUJsb2NrPyBfCiAgewogICAgcmV0dXJuIHsKICAgICAgdHlwZTogIm5vZGUiLAogICAgICBpZDogaWRlbnQsCiAgICAgIHRleHQ6IGxhYmVsLAogICAgICBwYXJhbXM6IHBhcmFtcyB8fCB7fQogICAgfTsKICB9Cgpjb2xvbkxhYmVsID0gIjoiIF9fIGxhYmVsOmxhYmVsCiAgewogICAgcmV0dXJuIGxhYmVsCiAgfQoKZWRnZVN0YXRlbWVudCA9IGxlZnRFZGdlU3RhdGVtZW50IC8gcmlnaHRFZGdlU3RhdGVtZW50IC8gYmlEaXJFZGdlU3RhdGVtZW50CgpsZWZ0RWRnZVN0YXRlbWVudCA9IF8gIHRvSWQ6aWRlbnQgXyAiPC0iIF8gZnJvbUlkczppZGVudHwuLiwgXyAiJiYiIF98IF8gbGFiZWw6Y29sb25MYWJlbD8KICB7CiAgICByZXR1cm4gewogICAgICB0eXBlOiAiZWRnZSIsCiAgICAgIHRvSWQ6IHRvSWQsCiAgICAgIHRleHQ6IGxhYmVsIHx8IHVuZGVmaW5lZCwKICAgICAgZnJvbUlkczogZnJvbUlkcwogICAgfTsKICB9CgpyaWdodEVkZ2VTdGF0ZW1lbnQgPSBfICBmcm9tSWRzOmlkZW50fC4uLCBfICImJiIgX3wgXyAiLT4iIF8gdG9JZDppZGVudCBfIGxhYmVsOmNvbG9uTGFiZWw/CiAgewogICAgcmV0dXJuIHsKICAgICAgdHlwZTogImVkZ2UiLAogICAgICB0b0lkOiB0b0lkLAogICAgICB0ZXh0OiBsYWJlbCB8fCB1bmRlZmluZWQsCiAgICAgIGZyb21JZHM6IGZyb21JZHMKICAgIH07CiAgfQoKYmlEaXJFZGdlU3RhdGVtZW50ID0gXyAgZnJvbUlkOmlkZW50IF8gIi0tIiBfIHRvSWQ6aWRlbnQgXyBsYWJlbDpjb2xvbkxhYmVsPwogIHsKICAgIHJldHVybiB7CiAgICAgIHR5cGU6ICJlZGdlIiwKICAgICAgdG9JZDogdG9JZCwKICAgICAgdGV4dDogbGFiZWwgfHwgdW5kZWZpbmVkLAogICAgICBmcm9tSWRzOiBbZnJvbUlkXSwKICAgICAgYmlEaXJlY3Rpb25hbDogdHJ1ZQogICAgfTsKICB9CgoKcGFyYW1CbG9jayA9ICJ7IiAgXyBFT0w/IF8gcGFyYW1zOnBhcmFtfC4uLCBfICJFT0wiIF98ICJ9IiAKewoJcmV0dXJuIE9iamVjdC5mcm9tRW50cmllcyhwYXJhbXMpOwp9CgpwYXJhbSA9IGlkZW50OmlkZW50IF8gJzonIF8gZXhwcmVzc2lvbjoobnVtL2xhYmVsKSBfIEVPTD8gXwp7CglyZXR1cm4gW2lkZW50LCBleHByZXNzaW9uXTsKfQoKbnVtID0gIG51bTooWzAtOV0rKQp7IHJldHVybiBtYWtlSW50ZWdlcihudW0pOyB9CgppZGVudCA9IGlkOihbYS16QS1aMC05XyddKykKeyByZXR1cm4gaWQuam9pbigiIik7IH0KCmxhYmVsID0gc3RyOnN0cmluZyAvIHRleHQ6KFtee31cbl0qKQp7IHJldHVybiB0ZXh0LmpvaW4oIiIpLnRyaW0oKTsgfQoKc3RyaW5nID0gIlwiIiB0ZXh0OihbXiJdKikgIlwiIgp7IHJldHVybiB0ZXh0LmpvaW4oIiIpOyB9CgpFT0wKICA9IFsgXHRdKiBbXG5ccl0rCgpfICJvcHRpb25hbCB3aGl0ZXNwYWNlIgogID0gWyBcdF0qCgpfXyAid2hpdGVzcGFjZSIKICA9IFsgXHRdKwo=",loadFile=async d=>await(await fetch(d)).text(),tocLangParserPromise=loadFile(tocLangGrammarUrl).then(d=>peg_1.generate(d)),parsersPromise=Promise.all([tocLangParserPromise]).then(([d])=>({"evaporating-cloud":d,"goal-tree":d,"problem-tree":d})),isGoalNodeStatement=d=>d.type==="node"&&normalizeId(d.id)==="goal",normalizeId=d=>d&&d.toLowerCase()==="goal"?"Goal":d,parseGoalTreeSemantics=d=>{const g=new Map;g.set("Goal",{key:"Goal",label:"",annotation:"G"});const $=[],b=d.statements.find(isGoalNodeStatement);return b&&(g.get("Goal").label=b.text),d.statements.filter(j=>j.type==="node").forEach(j=>{const _e={key:j.id,label:j.text};j.params.class&&(_e.annotation=j.params.class),j.id==="Goal"&&(_e.annotation="G"),(j.params.status||j.params.status===0)&&(_e.statusPercentage=j.params.status),g.set(j.id,_e)}),d.statements.filter(j=>j.type==="edge").forEach(j=>{const _e=j.toId;if(!g.has(_e))throw new Error(`Node ${_e} not found`);if(j.fromIds.length!==1)throw new Error("Edges must have exactly one 'from' node in a Goal Tree");const et=j.fromIds[0];if(!g.has(et))throw new Error(`Requirement ${et} not found`);_e==="Goal"&&(g.get(et).annotation="CSF"),$.push({from:et,to:_e})}),{nodes:g,edges:$,rankdir:"BT"}},parseProblemTreeSemantics=d=>{const g=new Map,$=[],b=j=>{var et,tt,nt;const _e=/^(UDE|FOL|DE)/i;if(typeof((et=j.params)==null?void 0:et.class)=="string"&&((nt=(tt=j.params)==null?void 0:tt.class)!=null&&nt.match(_e)))return j.params.class.match(_e)[0].toUpperCase()};return d.statements.filter(j=>j.type==="node").forEach(j=>{g.set(j.id,{annotation:b(j),key:j.id,label:j.text})}),d.statements.filter(j=>j.type==="edge").forEach(j=>{const _e=j.toId;let et=_e;if(j.fromIds.length>1){const tt=j.fromIds.join("_")+"_cause_"+_e;et=tt,g.set(tt,{key:tt,label:"AND",intermediate:!0}),$.push({from:tt,to:_e})}for(const tt of j.fromIds){if(!g.has(tt))throw new Error(`Cause ${tt} not declared`);if(!g.has(_e))throw new Error(`Effect ${_e} not declared`);$.push({from:tt,to:et})}}),{nodes:g,edges:$,rankdir:"BT"}},normalizeAstIds=d=>{const{statements:g,...$}=d;return{statements:g.map(j=>{const{id:_e,fromIds:et,toId:tt,...nt}=j,rt={...nt};return _e&&(rt.id=normalizeId(_e)),tt&&(rt.toId=normalizeId(tt)),et&&(rt.fromIds=et.map(normalizeId)),rt}),...$}},parseTextToAst=async(d,g)=>{const b=(await parsersPromise)[d].parse(g);return normalizeAstIds(b)};async function loader({params:d}){const g={"evaporating-cloud":exampleEvaporatingCloudText,"goal-tree":exampleGoalTreeText,"problem-tree":exampleProblemTreeText};return{diagramType:d.diagramType,example:g[d.diagramType]}}function Draw(){const{diagramType:d,example:g}=useLoaderData();console.log("diagramType",d);const[$,b]=React.useState(null),[j,_e]=React.useState(null),[et,tt]=React.useState(""),[nt,rt]=React.useState();React.useEffect(()=>{rt(g)},[d]);const it=async st=>{try{const ut=await parseTextToAst(d,st);_e(d==="goal-tree"?parseGoalTreeSemantics(ut):d==="problem-tree"?parseProblemTreeSemantics(ut):null),console.log(ut),b(ut),tt("")}catch(ut){console.error(ut),tt(ut.toString())}};return jsxRuntimeExports.jsxs("div",{className:"flex-row",children:[jsxRuntimeExports.jsx("div",{className:"flex-1",children:jsxRuntimeExports.jsx(Editor,{onChange:it,rows:20,text:nt,setText:rt,error:et})}),jsxRuntimeExports.jsx("div",{className:"flex-1",children:jsxRuntimeExports.jsx(Diagram,{ast:$,semantics:j,diagramType:d})})]})}function About(d){return jsxRuntimeExports.jsxs("div",{id:"about-page",children:[jsxRuntimeExports.jsx("h1",{children:"TOC-Lang"}),jsxRuntimeExports.jsxs("p",{children:["Generate"," ",jsxRuntimeExports.jsx("a",{href:"https://en.wikipedia.org/wiki/Theory_of_constraints",children:"Theory of Constraints"})," ","diagrams from text-based notation. Learn more"," ",jsxRuntimeExports.jsx("a",{href:"https://github.com/raymyers/toc-lang/",children:"on GitHub!"})]})]})}const router=createBrowserRouter([{path:"/",element:jsxRuntimeExports.jsx(App,{}),errorElement:jsxRuntimeExports.jsx(ErrorPage,{}),children:[{index:!0,loader:async()=>redirect("/draw/goal-tree")},{path:"draw/:diagramType",element:jsxRuntimeExports.jsx(Draw,{}),loader},{path:"about",element:jsxRuntimeExports.jsx(About,{})}]}],{basename:"/toc-lang"}),rootResetElt=document.getElementById("root-reset");rootResetElt&&client.createRoot(rootResetElt).render(jsxRuntimeExports.jsx(React.StrictMode,{children:jsxRuntimeExports.jsx(RouterProvider,{router})}))});export default Es(); diff --git a/assets/index-baa6c856.js b/assets/index-baa6c856.js new file mode 100644 index 0000000..819da46 --- /dev/null +++ b/assets/index-baa6c856.js @@ -0,0 +1,212 @@ +var zl=(g,d)=>()=>(d||g((d={exports:{}}).exports,d),d.exports);var Ul=zl((exports,module)=>{function _mergeNamespaces(g,d){for(var b=0;b$[j]})}}}return Object.freeze(Object.defineProperty(g,Symbol.toStringTag,{value:"Module"}))}(function(){const d=document.createElement("link").relList;if(d&&d.supports&&d.supports("modulepreload"))return;for(const j of document.querySelectorAll('link[rel="modulepreload"]'))$(j);new MutationObserver(j=>{for(const _e of j)if(_e.type==="childList")for(const et of _e.addedNodes)et.tagName==="LINK"&&et.rel==="modulepreload"&&$(et)}).observe(document,{childList:!0,subtree:!0});function b(j){const _e={};return j.integrity&&(_e.integrity=j.integrity),j.referrerPolicy&&(_e.referrerPolicy=j.referrerPolicy),j.crossOrigin==="use-credentials"?_e.credentials="include":j.crossOrigin==="anonymous"?_e.credentials="omit":_e.credentials="same-origin",_e}function $(j){if(j.ep)return;j.ep=!0;const _e=b(j);fetch(j.href,_e)}})();var commonjsGlobal=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function getDefaultExportFromCjs(g){return g&&g.__esModule&&Object.prototype.hasOwnProperty.call(g,"default")?g.default:g}var jsxRuntime={exports:{}},reactJsxRuntime_production_min={},react={exports:{}},react_production_min={};/** + * @license React + * react.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var l$2=Symbol.for("react.element"),n$2=Symbol.for("react.portal"),p$3=Symbol.for("react.fragment"),q$1=Symbol.for("react.strict_mode"),r$1=Symbol.for("react.profiler"),t$2=Symbol.for("react.provider"),u$1=Symbol.for("react.context"),v$2=Symbol.for("react.forward_ref"),w=Symbol.for("react.suspense"),x$1=Symbol.for("react.memo"),y$2=Symbol.for("react.lazy"),z$1=Symbol.iterator;function A$1(g){return g===null||typeof g!="object"?null:(g=z$1&&g[z$1]||g["@@iterator"],typeof g=="function"?g:null)}var B$1={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C$2=Object.assign,D$1={};function E$1(g,d,b){this.props=g,this.context=d,this.refs=D$1,this.updater=b||B$1}E$1.prototype.isReactComponent={};E$1.prototype.setState=function(g,d){if(typeof g!="object"&&typeof g!="function"&&g!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,g,d,"setState")};E$1.prototype.forceUpdate=function(g){this.updater.enqueueForceUpdate(this,g,"forceUpdate")};function F(){}F.prototype=E$1.prototype;function G$1(g,d,b){this.props=g,this.context=d,this.refs=D$1,this.updater=b||B$1}var H$1=G$1.prototype=new F;H$1.constructor=G$1;C$2(H$1,E$1.prototype);H$1.isPureReactComponent=!0;var I$1=Array.isArray,J=Object.prototype.hasOwnProperty,K$1={current:null},L$1={key:!0,ref:!0,__self:!0,__source:!0};function M$1(g,d,b){var $,j={},_e=null,et=null;if(d!=null)for($ in d.ref!==void 0&&(et=d.ref),d.key!==void 0&&(_e=""+d.key),d)J.call(d,$)&&!L$1.hasOwnProperty($)&&(j[$]=d[$]);var tt=arguments.length-2;if(tt===1)j.children=b;else if(1"u")throw new Error(d)}function createKey(){return Math.random().toString(36).substr(2,8)}function getHistoryState(g,d){return{usr:g.state,key:g.key,idx:d}}function createLocation(g,d,b,$){return b===void 0&&(b=null),_extends$3({pathname:typeof g=="string"?g:g.pathname,search:"",hash:""},typeof d=="string"?parsePath(d):d,{state:b,key:d&&d.key||$||createKey()})}function createPath(g){let{pathname:d="/",search:b="",hash:$=""}=g;return b&&b!=="?"&&(d+=b.charAt(0)==="?"?b:"?"+b),$&&$!=="#"&&(d+=$.charAt(0)==="#"?$:"#"+$),d}function parsePath(g){let d={};if(g){let b=g.indexOf("#");b>=0&&(d.hash=g.substr(b),g=g.substr(0,b));let $=g.indexOf("?");$>=0&&(d.search=g.substr($),g=g.substr(0,$)),g&&(d.pathname=g)}return d}function getUrlBasedHistory(g,d,b,$){$===void 0&&($={});let{window:j=document.defaultView,v5Compat:_e=!1}=$,et=j.history,tt=Action.Pop,nt=null,rt=it();rt==null&&(rt=0,et.replaceState(_extends$3({},et.state,{idx:rt}),""));function it(){return(et.state||{idx:null}).idx}function st(){tt=Action.Pop;let dt=it(),ht=dt==null?null:dt-rt;rt=dt,nt&&nt({action:tt,location:ct.location,delta:ht})}function ot(dt,ht){tt=Action.Push;let pt=createLocation(ct.location,dt,ht);b&&b(pt,dt),rt=it()+1;let gt=getHistoryState(pt,rt),yt=ct.createHref(pt);try{et.pushState(gt,"",yt)}catch{j.location.assign(yt)}_e&&nt&&nt({action:tt,location:ct.location,delta:1})}function at(dt,ht){tt=Action.Replace;let pt=createLocation(ct.location,dt,ht);b&&b(pt,dt),rt=it();let gt=getHistoryState(pt,rt),yt=ct.createHref(pt);et.replaceState(gt,"",yt),_e&&nt&&nt({action:tt,location:ct.location,delta:0})}function ut(dt){let ht=j.location.origin!=="null"?j.location.origin:j.location.href,pt=typeof dt=="string"?dt:createPath(dt);return invariant(ht,"No window.location.(origin|href) available to create URL for href: "+pt),new URL(pt,ht)}let ct={get action(){return tt},get location(){return g(j,et)},listen(dt){if(nt)throw new Error("A history only accepts one active listener");return j.addEventListener(PopStateEventType,st),nt=dt,()=>{j.removeEventListener(PopStateEventType,st),nt=null}},createHref(dt){return d(j,dt)},createURL:ut,encodeLocation(dt){let ht=ut(dt);return{pathname:ht.pathname,search:ht.search,hash:ht.hash}},push:ot,replace:at,go(dt){return et.go(dt)}};return ct}var ResultType;(function(g){g.data="data",g.deferred="deferred",g.redirect="redirect",g.error="error"})(ResultType||(ResultType={}));function isIndexRoute(g){return g.index===!0}function convertRoutesToDataRoutes(g,d,b){return d===void 0&&(d=[]),b===void 0&&(b=new Set),g.map(($,j)=>{let _e=[...d,j],et=typeof $.id=="string"?$.id:_e.join("-");return invariant($.index!==!0||!$.children,"Cannot specify children on an index route"),invariant(!b.has(et),'Found a route id collision on id "'+et+`". Route id's must be globally unique within Data Router usages`),b.add(et),isIndexRoute($)?_extends$3({},$,{id:et}):_extends$3({},$,{id:et,children:$.children?convertRoutesToDataRoutes($.children,_e,b):void 0})})}function matchRoutes(g,d,b){b===void 0&&(b="/");let $=typeof d=="string"?parsePath(d):d,j=stripBasename($.pathname||"/",b);if(j==null)return null;let _e=flattenRoutes(g);rankRouteBranches(_e);let et=null;for(let tt=0;et==null&&tt<_e.length;++tt)et=matchRouteBranch(_e[tt],safelyDecodeURI(j));return et}function flattenRoutes(g,d,b,$){d===void 0&&(d=[]),b===void 0&&(b=[]),$===void 0&&($="");let j=(_e,et,tt)=>{let nt={relativePath:tt===void 0?_e.path||"":tt,caseSensitive:_e.caseSensitive===!0,childrenIndex:et,route:_e};nt.relativePath.startsWith("/")&&(invariant(nt.relativePath.startsWith($),'Absolute route path "'+nt.relativePath+'" nested under path '+('"'+$+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),nt.relativePath=nt.relativePath.slice($.length));let rt=joinPaths([$,nt.relativePath]),it=b.concat(nt);_e.children&&_e.children.length>0&&(invariant(_e.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+rt+'".')),flattenRoutes(_e.children,d,it,rt)),!(_e.path==null&&!_e.index)&&d.push({path:rt,score:computeScore(rt,_e.index),routesMeta:it})};return g.forEach((_e,et)=>{var tt;if(_e.path===""||!((tt=_e.path)!=null&&tt.includes("?")))j(_e,et);else for(let nt of explodeOptionalSegments(_e.path))j(_e,et,nt)}),d}function explodeOptionalSegments(g){let d=g.split("/");if(d.length===0)return[];let[b,...$]=d,j=b.endsWith("?"),_e=b.replace(/\?$/,"");if($.length===0)return j?[_e,""]:[_e];let et=explodeOptionalSegments($.join("/")),tt=[];return tt.push(...et.map(nt=>nt===""?_e:[_e,nt].join("/"))),j&&tt.push(...et),tt.map(nt=>g.startsWith("/")&&nt===""?"/":nt)}function rankRouteBranches(g){g.sort((d,b)=>d.score!==b.score?b.score-d.score:compareIndexes(d.routesMeta.map($=>$.childrenIndex),b.routesMeta.map($=>$.childrenIndex)))}const paramRe=/^:\w+$/,dynamicSegmentValue=3,indexRouteValue=2,emptySegmentValue=1,staticSegmentValue=10,splatPenalty=-2,isSplat=g=>g==="*";function computeScore(g,d){let b=g.split("/"),$=b.length;return b.some(isSplat)&&($+=splatPenalty),d&&($+=indexRouteValue),b.filter(j=>!isSplat(j)).reduce((j,_e)=>j+(paramRe.test(_e)?dynamicSegmentValue:_e===""?emptySegmentValue:staticSegmentValue),$)}function compareIndexes(g,d){return g.length===d.length&&g.slice(0,-1).every(($,j)=>$===d[j])?g[g.length-1]-d[d.length-1]:0}function matchRouteBranch(g,d){let{routesMeta:b}=g,$={},j="/",_e=[];for(let et=0;et{if(it==="*"){let ot=tt[st]||"";et=_e.slice(0,_e.length-ot.length).replace(/(.)\/+$/,"$1")}return rt[it]=safelyDecodeURIComponent(tt[st]||"",it),rt},{}),pathname:_e,pathnameBase:et,pattern:g}}function compilePath(g,d,b){d===void 0&&(d=!1),b===void 0&&(b=!0),warning(g==="*"||!g.endsWith("*")||g.endsWith("/*"),'Route path "'+g+'" will be treated as if it were '+('"'+g.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+g.replace(/\*$/,"/*")+'".'));let $=[],j="^"+g.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^$?{}|()[\]]/g,"\\$&").replace(/\/:(\w+)/g,(et,tt)=>($.push(tt),"/([^\\/]+)"));return g.endsWith("*")?($.push("*"),j+=g==="*"||g==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):b?j+="\\/*$":g!==""&&g!=="/"&&(j+="(?:(?=\\/|$))"),[new RegExp(j,d?void 0:"i"),$]}function safelyDecodeURI(g){try{return decodeURI(g)}catch(d){return warning(!1,'The URL path "'+g+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+d+").")),g}}function safelyDecodeURIComponent(g,d){try{return decodeURIComponent(g)}catch(b){return warning(!1,'The value for the URL param "'+d+'" will not be decoded because'+(' the string "'+g+'" is a malformed URL segment. This is probably')+(" due to a bad percent encoding ("+b+").")),g}}function stripBasename(g,d){if(d==="/")return g;if(!g.toLowerCase().startsWith(d.toLowerCase()))return null;let b=d.endsWith("/")?d.length-1:d.length,$=g.charAt(b);return $&&$!=="/"?null:g.slice(b)||"/"}function warning(g,d){if(!g){typeof console<"u"&&console.warn(d);try{throw new Error(d)}catch{}}}function resolvePath(g,d){d===void 0&&(d="/");let{pathname:b,search:$="",hash:j=""}=typeof g=="string"?parsePath(g):g;return{pathname:b?b.startsWith("/")?b:resolvePathname(b,d):d,search:normalizeSearch($),hash:normalizeHash(j)}}function resolvePathname(g,d){let b=d.replace(/\/+$/,"").split("/");return g.split("/").forEach(j=>{j===".."?b.length>1&&b.pop():j!=="."&&b.push(j)}),b.length>1?b.join("/"):"/"}function getInvalidPathError(g,d,b,$){return"Cannot include a '"+g+"' character in a manually specified "+("`to."+d+"` field ["+JSON.stringify($)+"]. Please separate it out to the ")+("`to."+b+"` field. Alternatively you may provide the full path as ")+'a string in and the router will parse it for you.'}function getPathContributingMatches(g){return g.filter((d,b)=>b===0||d.route.path&&d.route.path.length>0)}function resolveTo(g,d,b,$){$===void 0&&($=!1);let j;typeof g=="string"?j=parsePath(g):(j=_extends$3({},g),invariant(!j.pathname||!j.pathname.includes("?"),getInvalidPathError("?","pathname","search",j)),invariant(!j.pathname||!j.pathname.includes("#"),getInvalidPathError("#","pathname","hash",j)),invariant(!j.search||!j.search.includes("#"),getInvalidPathError("#","search","hash",j)));let _e=g===""||j.pathname==="",et=_e?"/":j.pathname,tt;if($||et==null)tt=b;else{let st=d.length-1;if(et.startsWith("..")){let ot=et.split("/");for(;ot[0]==="..";)ot.shift(),st-=1;j.pathname=ot.join("/")}tt=st>=0?d[st]:"/"}let nt=resolvePath(j,tt),rt=et&&et!=="/"&&et.endsWith("/"),it=(_e||et===".")&&b.endsWith("/");return!nt.pathname.endsWith("/")&&(rt||it)&&(nt.pathname+="/"),nt}const joinPaths=g=>g.join("/").replace(/\/\/+/g,"/"),normalizePathname=g=>g.replace(/\/+$/,"").replace(/^\/*/,"/"),normalizeSearch=g=>!g||g==="?"?"":g.startsWith("?")?g:"?"+g,normalizeHash=g=>!g||g==="#"?"":g.startsWith("#")?g:"#"+g;class AbortedDeferredError extends Error{}class DeferredData{constructor(d,b){this.pendingKeysSet=new Set,this.subscribers=new Set,this.deferredKeys=[],invariant(d&&typeof d=="object"&&!Array.isArray(d),"defer() only accepts plain objects");let $;this.abortPromise=new Promise((_e,et)=>$=et),this.controller=new AbortController;let j=()=>$(new AbortedDeferredError("Deferred data aborted"));this.unlistenAbortSignal=()=>this.controller.signal.removeEventListener("abort",j),this.controller.signal.addEventListener("abort",j),this.data=Object.entries(d).reduce((_e,et)=>{let[tt,nt]=et;return Object.assign(_e,{[tt]:this.trackPromise(tt,nt)})},{}),this.done&&this.unlistenAbortSignal(),this.init=b}trackPromise(d,b){if(!(b instanceof Promise))return b;this.deferredKeys.push(d),this.pendingKeysSet.add(d);let $=Promise.race([b,this.abortPromise]).then(j=>this.onSettle($,d,null,j),j=>this.onSettle($,d,j));return $.catch(()=>{}),Object.defineProperty($,"_tracked",{get:()=>!0}),$}onSettle(d,b,$,j){return this.controller.signal.aborted&&$ instanceof AbortedDeferredError?(this.unlistenAbortSignal(),Object.defineProperty(d,"_error",{get:()=>$}),Promise.reject($)):(this.pendingKeysSet.delete(b),this.done&&this.unlistenAbortSignal(),$?(Object.defineProperty(d,"_error",{get:()=>$}),this.emit(!1,b),Promise.reject($)):(Object.defineProperty(d,"_data",{get:()=>j}),this.emit(!1,b),j))}emit(d,b){this.subscribers.forEach($=>$(d,b))}subscribe(d){return this.subscribers.add(d),()=>this.subscribers.delete(d)}cancel(){this.controller.abort(),this.pendingKeysSet.forEach((d,b)=>this.pendingKeysSet.delete(b)),this.emit(!0)}async resolveData(d){let b=!1;if(!this.done){let $=()=>this.cancel();d.addEventListener("abort",$),b=await new Promise(j=>{this.subscribe(_e=>{d.removeEventListener("abort",$),(_e||this.done)&&j(_e)})})}return b}get done(){return this.pendingKeysSet.size===0}get unwrappedData(){return invariant(this.data!==null&&this.done,"Can only unwrap data on initialized and settled deferreds"),Object.entries(this.data).reduce((d,b)=>{let[$,j]=b;return Object.assign(d,{[$]:unwrapTrackedPromise(j)})},{})}get pendingKeys(){return Array.from(this.pendingKeysSet)}}function isTrackedPromise(g){return g instanceof Promise&&g._tracked===!0}function unwrapTrackedPromise(g){if(!isTrackedPromise(g))return g;if(g._error)throw g._error;return g._data}const redirect=function(d,b){b===void 0&&(b=302);let $=b;typeof $=="number"?$={status:$}:typeof $.status>"u"&&($.status=302);let j=new Headers($.headers);return j.set("Location",d),new Response(null,_extends$3({},$,{headers:j}))};class ErrorResponse{constructor(d,b,$,j){j===void 0&&(j=!1),this.status=d,this.statusText=b||"",this.internal=j,$ instanceof Error?(this.data=$.toString(),this.error=$):this.data=$}}function isRouteErrorResponse(g){return g!=null&&typeof g.status=="number"&&typeof g.statusText=="string"&&typeof g.internal=="boolean"&&"data"in g}const validMutationMethodsArr=["post","put","patch","delete"],validMutationMethods=new Set(validMutationMethodsArr),validRequestMethodsArr=["get",...validMutationMethodsArr],validRequestMethods=new Set(validRequestMethodsArr),redirectStatusCodes=new Set([301,302,303,307,308]),redirectPreserveMethodStatusCodes=new Set([307,308]),IDLE_NAVIGATION={state:"idle",location:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0},IDLE_FETCHER={state:"idle",data:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0},IDLE_BLOCKER={state:"unblocked",proceed:void 0,reset:void 0,location:void 0},isBrowser$1=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",isServer=!isBrowser$1;function createRouter(g){invariant(g.routes.length>0,"You must provide a non-empty routes array to createRouter");let d=convertRoutesToDataRoutes(g.routes),b=null,$=new Set,j=null,_e=null,et=null,tt=g.hydrationData!=null,nt=matchRoutes(d,g.history.location,g.basename),rt=null;if(nt==null){let $t=getInternalRouterError(404,{pathname:g.history.location.pathname}),{matches:_t,route:Nt}=getShortCircuitMatches(d);nt=_t,rt={[Nt.id]:$t}}let it=!nt.some($t=>$t.route.loader)||g.hydrationData!=null,st,ot={historyAction:g.history.action,location:g.history.location,matches:nt,initialized:it,navigation:IDLE_NAVIGATION,restoreScrollPosition:g.hydrationData!=null?!1:null,preventScrollReset:!1,revalidation:"idle",loaderData:g.hydrationData&&g.hydrationData.loaderData||{},actionData:g.hydrationData&&g.hydrationData.actionData||null,errors:g.hydrationData&&g.hydrationData.errors||rt,fetchers:new Map,blockers:new Map},at=Action.Pop,ut=!1,ct,dt=!1,ht=!1,pt=[],gt=[],yt=new Map,vt=0,St=-1,xt=new Map,Dt=new Set,Pt=new Map,Ct=new Map,wt=null,Tt=new Map,Bt=!1;function Ft(){return b=g.history.listen($t=>{let{action:_t,location:Nt,delta:zt}=$t;if(Bt){Bt=!1;return}warning(wt!=null&&zt===null,"You are trying to use a blocker on a POP navigation to a location that was not created by @remix-run/router. This will fail silently in production. This can happen if you are navigating outside the router via `window.history.pushState`/`window.location.hash` instead of using router navigation APIs. This can also happen if you are using createHashRouter and the user manually changes the URL.");let jt=xn({currentLocation:ot.location,nextLocation:Nt,historyAction:_t});if(jt&&zt!=null){Bt=!0,g.history.go(zt*-1),_n(jt,{state:"blocked",location:Nt,proceed(){_n(jt,{state:"proceeding",proceed:void 0,reset:void 0,location:Nt}),g.history.go(zt)},reset(){Bn(jt),Ht({blockers:new Map(st.state.blockers)})}});return}return Ut(_t,Nt)}),ot.initialized||Ut(Action.Pop,ot.location),st}function Vt(){b&&b(),$.clear(),ct&&ct.abort(),ot.fetchers.forEach(($t,_t)=>On(_t)),ot.blockers.forEach(($t,_t)=>Bn(_t))}function Wt($t){return $.add($t),()=>$.delete($t)}function Ht($t){ot=_extends$3({},ot,$t),$.forEach(_t=>_t(ot))}function Ot($t,_t){var Nt,zt;let jt=ot.actionData!=null&&ot.navigation.formMethod!=null&&isMutationMethod(ot.navigation.formMethod)&&ot.navigation.state==="loading"&&((Nt=$t.state)==null?void 0:Nt._isRedirect)!==!0,qt;_t.actionData?Object.keys(_t.actionData).length>0?qt=_t.actionData:qt=null:jt?qt=ot.actionData:qt=null;let Xt=_t.loaderData?mergeLoaderData(ot.loaderData,_t.loaderData,_t.matches||[],_t.errors):ot.loaderData;for(let[Yt]of Tt)Bn(Yt);let Zt=ut===!0||ot.navigation.formMethod!=null&&isMutationMethod(ot.navigation.formMethod)&&((zt=$t.state)==null?void 0:zt._isRedirect)!==!0;Ht(_extends$3({},_t,{actionData:qt,loaderData:Xt,historyAction:at,location:$t,initialized:!0,navigation:IDLE_NAVIGATION,revalidation:"idle",restoreScrollPosition:hn($t,_t.matches||ot.matches),preventScrollReset:Zt,blockers:new Map(ot.blockers)})),dt||at===Action.Pop||(at===Action.Push?g.history.push($t,$t.state):at===Action.Replace&&g.history.replace($t,$t.state)),at=Action.Pop,ut=!1,dt=!1,ht=!1,pt=[],gt=[]}async function Lt($t,_t){if(typeof $t=="number"){g.history.go($t);return}let{path:Nt,submission:zt,error:jt}=normalizeNavigateOptions($t,_t),qt=ot.location,Xt=createLocation(ot.location,Nt,_t&&_t.state);Xt=_extends$3({},Xt,g.history.encodeLocation(Xt));let Zt=_t&&_t.replace!=null?_t.replace:void 0,Yt=Action.Push;Zt===!0?Yt=Action.Replace:Zt===!1||zt!=null&&isMutationMethod(zt.formMethod)&&zt.formAction===ot.location.pathname+ot.location.search&&(Yt=Action.Replace);let un=_t&&"preventScrollReset"in _t?_t.preventScrollReset===!0:void 0,Jt=xn({currentLocation:qt,nextLocation:Xt,historyAction:Yt});if(Jt){_n(Jt,{state:"blocked",location:Xt,proceed(){_n(Jt,{state:"proceeding",proceed:void 0,reset:void 0,location:Xt}),Lt($t,_t)},reset(){Bn(Jt),Ht({blockers:new Map(ot.blockers)})}});return}return await Ut(Yt,Xt,{submission:zt,pendingError:jt,preventScrollReset:un,replace:_t&&_t.replace})}function It(){if(bn(),Ht({revalidation:"loading"}),ot.navigation.state!=="submitting"){if(ot.navigation.state==="idle"){Ut(ot.historyAction,ot.location,{startUninterruptedRevalidation:!0});return}Ut(at||ot.historyAction,ot.navigation.location,{overrideNavigation:ot.navigation})}}async function Ut($t,_t,Nt){ct&&ct.abort(),ct=null,at=$t,dt=(Nt&&Nt.startUninterruptedRevalidation)===!0,kn(ot.location,ot.matches),ut=(Nt&&Nt.preventScrollReset)===!0;let zt=Nt&&Nt.overrideNavigation,jt=matchRoutes(d,_t,g.basename);if(!jt){let rn=getInternalRouterError(404,{pathname:_t.pathname}),{matches:dn,route:cn}=getShortCircuitMatches(d);En(),Ot(_t,{matches:dn,loaderData:{},errors:{[cn.id]:rn}});return}if(isHashChangeOnly(ot.location,_t)&&!(Nt&&Nt.submission&&isMutationMethod(Nt.submission.formMethod))){Ot(_t,{matches:jt});return}ct=new AbortController;let qt=createClientSideRequest(g.history,_t,ct.signal,Nt&&Nt.submission),Xt,Zt;if(Nt&&Nt.pendingError)Zt={[findNearestBoundary(jt).route.id]:Nt.pendingError};else if(Nt&&Nt.submission&&isMutationMethod(Nt.submission.formMethod)){let rn=await Gt(qt,_t,Nt.submission,jt,{replace:Nt.replace});if(rn.shortCircuited)return;Xt=rn.pendingActionData,Zt=rn.pendingActionError,zt=_extends$3({state:"loading",location:_t},Nt.submission),qt=new Request(qt.url,{signal:qt.signal})}let{shortCircuited:Yt,loaderData:un,errors:Jt}=await tn(qt,_t,jt,zt,Nt&&Nt.submission,Nt&&Nt.replace,Xt,Zt);Yt||(ct=null,Ot(_t,_extends$3({matches:jt},Xt?{actionData:Xt}:{},{loaderData:un,errors:Jt})))}async function Gt($t,_t,Nt,zt,jt){bn();let qt=_extends$3({state:"submitting",location:_t},Nt);Ht({navigation:qt});let Xt,Zt=getTargetMatch(zt,_t);if(!Zt.route.action)Xt={type:ResultType.error,error:getInternalRouterError(405,{method:$t.method,pathname:_t.pathname,routeId:Zt.route.id})};else if(Xt=await callLoaderOrAction("action",$t,Zt,zt,st.basename),$t.signal.aborted)return{shortCircuited:!0};if(isRedirectResult(Xt)){let Yt;return jt&&jt.replace!=null?Yt=jt.replace:Yt=Xt.location===ot.location.pathname+ot.location.search,await Pn(ot,Xt,{submission:Nt,replace:Yt}),{shortCircuited:!0}}if(isErrorResult(Xt)){let Yt=findNearestBoundary(zt,Zt.route.id);return(jt&&jt.replace)!==!0&&(at=Action.Push),{pendingActionData:{},pendingActionError:{[Yt.route.id]:Xt.error}}}if(isDeferredResult(Xt))throw getInternalRouterError(400,{type:"defer-action"});return{pendingActionData:{[Zt.route.id]:Xt.data}}}async function tn($t,_t,Nt,zt,jt,qt,Xt,Zt){let Yt=zt;Yt||(Yt=_extends$3({state:"loading",location:_t,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0},jt));let un=jt||(Yt.formMethod&&Yt.formAction&&Yt.formData&&Yt.formEncType?{formMethod:Yt.formMethod,formAction:Yt.formAction,formData:Yt.formData,formEncType:Yt.formEncType}:void 0),[Jt,rn]=getMatchesToLoad(g.history,ot,Nt,un,_t,ht,pt,gt,Xt,Zt,Pt);if(En(fn=>!(Nt&&Nt.some(Cn=>Cn.route.id===fn))||Jt&&Jt.some(Cn=>Cn.route.id===fn)),Jt.length===0&&rn.length===0)return Ot(_t,_extends$3({matches:Nt,loaderData:{},errors:Zt||null},Xt?{actionData:Xt}:{})),{shortCircuited:!0};if(!dt){rn.forEach(Cn=>{let Mn=ot.fetchers.get(Cn.key),Un={state:"loading",data:Mn&&Mn.data,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0," _hasFetcherDoneAnything ":!0};ot.fetchers.set(Cn.key,Un)});let fn=Xt||ot.actionData;Ht(_extends$3({navigation:Yt},fn?Object.keys(fn).length===0?{actionData:null}:{actionData:fn}:{},rn.length>0?{fetchers:new Map(ot.fetchers)}:{}))}St=++vt,rn.forEach(fn=>yt.set(fn.key,ct));let{results:dn,loaderResults:cn,fetcherResults:gn}=await Hn(ot.matches,Nt,Jt,rn,$t);if($t.signal.aborted)return{shortCircuited:!0};rn.forEach(fn=>yt.delete(fn.key));let Sn=findRedirect(dn);if(Sn)return await Pn(ot,Sn,{replace:qt}),{shortCircuited:!0};let{loaderData:Tn,errors:on}=processLoaderData(ot,Nt,Jt,cn,Zt,rn,gn,Ct);Ct.forEach((fn,Cn)=>{fn.subscribe(Mn=>{(Mn||fn.done)&&Ct.delete(Cn)})}),Nn();let Xn=jn(St);return _extends$3({loaderData:Tn,errors:on},Xn||rn.length>0?{fetchers:new Map(ot.fetchers)}:{})}function nn($t){return ot.fetchers.get($t)||IDLE_FETCHER}function ln($t,_t,Nt,zt){if(isServer)throw new Error("router.fetch() was called during the server render, but it shouldn't be. You are likely calling a useFetcher() method in the body of your component. Try moving it to a useEffect or a callback.");yt.has($t)&&$n($t);let jt=matchRoutes(d,Nt,g.basename);if(!jt){Rn($t,_t,getInternalRouterError(404,{pathname:Nt}));return}let{path:qt,submission:Xt}=normalizeNavigateOptions(Nt,zt,!0),Zt=getTargetMatch(jt,qt);if(ut=(zt&&zt.preventScrollReset)===!0,Xt&&isMutationMethod(Xt.formMethod)){an($t,_t,qt,Zt,jt,Xt);return}Pt.set($t,{routeId:_t,path:qt,match:Zt,matches:jt}),yn($t,_t,qt,Zt,jt,Xt)}async function an($t,_t,Nt,zt,jt,qt){if(bn(),Pt.delete($t),!zt.route.action){let Dn=getInternalRouterError(405,{method:qt.formMethod,pathname:Nt,routeId:_t});Rn($t,_t,Dn);return}let Xt=ot.fetchers.get($t),Zt=_extends$3({state:"submitting"},qt,{data:Xt&&Xt.data," _hasFetcherDoneAnything ":!0});ot.fetchers.set($t,Zt),Ht({fetchers:new Map(ot.fetchers)});let Yt=new AbortController,un=createClientSideRequest(g.history,Nt,Yt.signal,qt);yt.set($t,Yt);let Jt=await callLoaderOrAction("action",un,zt,jt,st.basename);if(un.signal.aborted){yt.get($t)===Yt&&yt.delete($t);return}if(isRedirectResult(Jt)){yt.delete($t),Dt.add($t);let Dn=_extends$3({state:"loading"},qt,{data:void 0," _hasFetcherDoneAnything ":!0});return ot.fetchers.set($t,Dn),Ht({fetchers:new Map(ot.fetchers)}),Pn(ot,Jt,{isFetchActionRedirect:!0})}if(isErrorResult(Jt)){Rn($t,_t,Jt.error);return}if(isDeferredResult(Jt))throw getInternalRouterError(400,{type:"defer-action"});let rn=ot.navigation.location||ot.location,dn=createClientSideRequest(g.history,rn,Yt.signal),cn=ot.navigation.state!=="idle"?matchRoutes(d,ot.navigation.location,g.basename):ot.matches;invariant(cn,"Didn't find any matches after fetcher action");let gn=++vt;xt.set($t,gn);let Sn=_extends$3({state:"loading",data:Jt.data},qt,{" _hasFetcherDoneAnything ":!0});ot.fetchers.set($t,Sn);let[Tn,on]=getMatchesToLoad(g.history,ot,cn,qt,rn,ht,pt,gt,{[zt.route.id]:Jt.data},void 0,Pt);on.filter(Dn=>Dn.key!==$t).forEach(Dn=>{let Qn=Dn.key,er=ot.fetchers.get(Qn),gr={state:"loading",data:er&&er.data,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0," _hasFetcherDoneAnything ":!0};ot.fetchers.set(Qn,gr),yt.set(Qn,Yt)}),Ht({fetchers:new Map(ot.fetchers)});let{results:Xn,loaderResults:fn,fetcherResults:Cn}=await Hn(ot.matches,cn,Tn,on,dn);if(Yt.signal.aborted)return;xt.delete($t),yt.delete($t),on.forEach(Dn=>yt.delete(Dn.key));let Mn=findRedirect(Xn);if(Mn)return Pn(ot,Mn);let{loaderData:Un,errors:qn}=processLoaderData(ot,ot.matches,Tn,fn,void 0,on,Cn,Ct),pr={state:"idle",data:Jt.data,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0," _hasFetcherDoneAnything ":!0};ot.fetchers.set($t,pr);let Jn=jn(gn);ot.navigation.state==="loading"&&gn>St?(invariant(at,"Expected pending action"),ct&&ct.abort(),Ot(ot.navigation.location,{matches:cn,loaderData:Un,errors:qn,fetchers:new Map(ot.fetchers)})):(Ht(_extends$3({errors:qn,loaderData:mergeLoaderData(ot.loaderData,Un,cn,qn)},Jn?{fetchers:new Map(ot.fetchers)}:{})),ht=!1)}async function yn($t,_t,Nt,zt,jt,qt){let Xt=ot.fetchers.get($t),Zt=_extends$3({state:"loading",formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0},qt,{data:Xt&&Xt.data," _hasFetcherDoneAnything ":!0});ot.fetchers.set($t,Zt),Ht({fetchers:new Map(ot.fetchers)});let Yt=new AbortController,un=createClientSideRequest(g.history,Nt,Yt.signal);yt.set($t,Yt);let Jt=await callLoaderOrAction("loader",un,zt,jt,st.basename);if(isDeferredResult(Jt)&&(Jt=await resolveDeferredData(Jt,un.signal,!0)||Jt),yt.get($t)===Yt&&yt.delete($t),un.signal.aborted)return;if(isRedirectResult(Jt)){await Pn(ot,Jt);return}if(isErrorResult(Jt)){let dn=findNearestBoundary(ot.matches,_t);ot.fetchers.delete($t),Ht({fetchers:new Map(ot.fetchers),errors:{[dn.route.id]:Jt.error}});return}invariant(!isDeferredResult(Jt),"Unhandled fetcher deferred data");let rn={state:"idle",data:Jt.data,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0," _hasFetcherDoneAnything ":!0};ot.fetchers.set($t,rn),Ht({fetchers:new Map(ot.fetchers)})}async function Pn($t,_t,Nt){var zt;let{submission:jt,replace:qt,isFetchActionRedirect:Xt}=Nt===void 0?{}:Nt;_t.revalidate&&(ht=!0);let Zt=createLocation($t.location,_t.location,_extends$3({_isRedirect:!0},Xt?{_isFetchActionRedirect:!0}:{}));if(invariant(Zt,"Expected a location on the redirect navigation"),isBrowser$1&&typeof((zt=window)==null?void 0:zt.location)<"u"){let cn=g.history.createURL(_t.location).origin;if(window.location.origin!==cn){qt?window.location.replace(_t.location):window.location.assign(_t.location);return}}ct=null;let Yt=qt===!0?Action.Replace:Action.Push,{formMethod:un,formAction:Jt,formEncType:rn,formData:dn}=$t.navigation;!jt&&un&&Jt&&dn&&rn&&(jt={formMethod:un,formAction:Jt,formEncType:rn,formData:dn}),redirectPreserveMethodStatusCodes.has(_t.status)&&jt&&isMutationMethod(jt.formMethod)?await Ut(Yt,Zt,{submission:_extends$3({},jt,{formAction:_t.location}),preventScrollReset:ut}):await Ut(Yt,Zt,{overrideNavigation:{state:"loading",location:Zt,formMethod:jt?jt.formMethod:void 0,formAction:jt?jt.formAction:void 0,formEncType:jt?jt.formEncType:void 0,formData:jt?jt.formData:void 0},preventScrollReset:ut})}async function Hn($t,_t,Nt,zt,jt){let qt=await Promise.all([...Nt.map(Yt=>callLoaderOrAction("loader",jt,Yt,_t,st.basename)),...zt.map(Yt=>callLoaderOrAction("loader",createClientSideRequest(g.history,Yt.path,jt.signal),Yt.match,Yt.matches,st.basename))]),Xt=qt.slice(0,Nt.length),Zt=qt.slice(Nt.length);return await Promise.all([resolveDeferredResults($t,Nt,Xt,jt.signal,!1,ot.loaderData),resolveDeferredResults($t,zt.map(Yt=>Yt.match),Zt,jt.signal,!0)]),{results:qt,loaderResults:Xt,fetcherResults:Zt}}function bn(){ht=!0,pt.push(...En()),Pt.forEach(($t,_t)=>{yt.has(_t)&&(gt.push(_t),$n(_t))})}function Rn($t,_t,Nt){let zt=findNearestBoundary(ot.matches,_t);On($t),Ht({errors:{[zt.route.id]:Nt},fetchers:new Map(ot.fetchers)})}function On($t){yt.has($t)&&$n($t),Pt.delete($t),xt.delete($t),Dt.delete($t),ot.fetchers.delete($t)}function $n($t){let _t=yt.get($t);invariant(_t,"Expected fetch controller: "+$t),_t.abort(),yt.delete($t)}function An($t){for(let _t of $t){let zt={state:"idle",data:nn(_t).data,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0," _hasFetcherDoneAnything ":!0};ot.fetchers.set(_t,zt)}}function Nn(){let $t=[];for(let _t of Dt){let Nt=ot.fetchers.get(_t);invariant(Nt,"Expected fetcher: "+_t),Nt.state==="loading"&&(Dt.delete(_t),$t.push(_t))}An($t)}function jn($t){let _t=[];for(let[Nt,zt]of xt)if(zt<$t){let jt=ot.fetchers.get(Nt);invariant(jt,"Expected fetcher: "+Nt),jt.state==="loading"&&($n(Nt),xt.delete(Nt),_t.push(Nt))}return An(_t),_t.length>0}function zn($t,_t){let Nt=ot.blockers.get($t)||IDLE_BLOCKER;return Tt.get($t)!==_t&&(Tt.set($t,_t),wt==null?wt=$t:$t!==wt&&warning(!1,"A router only supports one blocker at a time")),Nt}function Bn($t){ot.blockers.delete($t),Tt.delete($t),wt===$t&&(wt=null)}function _n($t,_t){let Nt=ot.blockers.get($t)||IDLE_BLOCKER;invariant(Nt.state==="unblocked"&&_t.state==="blocked"||Nt.state==="blocked"&&_t.state==="blocked"||Nt.state==="blocked"&&_t.state==="proceeding"||Nt.state==="blocked"&&_t.state==="unblocked"||Nt.state==="proceeding"&&_t.state==="unblocked","Invalid blocker state transition: "+Nt.state+" -> "+_t.state),ot.blockers.set($t,_t),Ht({blockers:new Map(ot.blockers)})}function xn($t){let{currentLocation:_t,nextLocation:Nt,historyAction:zt}=$t;if(wt==null)return;let jt=Tt.get(wt);invariant(jt,"Could not find a function for the active blocker");let qt=ot.blockers.get(wt);if(!(qt&&qt.state==="proceeding")&&jt({currentLocation:_t,nextLocation:Nt,historyAction:zt}))return wt}function En($t){let _t=[];return Ct.forEach((Nt,zt)=>{(!$t||$t(zt))&&(Nt.cancel(),_t.push(zt),Ct.delete(zt))}),_t}function wn($t,_t,Nt){if(j=$t,et=_t,_e=Nt||(zt=>zt.key),!tt&&ot.navigation===IDLE_NAVIGATION){tt=!0;let zt=hn(ot.location,ot.matches);zt!=null&&Ht({restoreScrollPosition:zt})}return()=>{j=null,et=null,_e=null}}function kn($t,_t){if(j&&_e&&et){let Nt=_t.map(jt=>createUseMatchesMatch(jt,ot.loaderData)),zt=_e($t,Nt)||$t.key;j[zt]=et()}}function hn($t,_t){if(j&&_e&&et){let Nt=_t.map(qt=>createUseMatchesMatch(qt,ot.loaderData)),zt=_e($t,Nt)||$t.key,jt=j[zt];if(typeof jt=="number")return jt}return null}return st={get basename(){return g.basename},get state(){return ot},get routes(){return d},initialize:Ft,subscribe:Wt,enableScrollRestoration:wn,navigate:Lt,fetch:ln,revalidate:It,createHref:$t=>g.history.createHref($t),encodeLocation:$t=>g.history.encodeLocation($t),getFetcher:nn,deleteFetcher:On,dispose:Vt,getBlocker:zn,deleteBlocker:Bn,_internalFetchControllers:yt,_internalActiveDeferreds:Ct},st}function isSubmissionNavigation(g){return g!=null&&"formData"in g}function normalizeNavigateOptions(g,d,b){b===void 0&&(b=!1);let $=typeof g=="string"?g:createPath(g);if(!d||!isSubmissionNavigation(d))return{path:$};if(d.formMethod&&!isValidMethod(d.formMethod))return{path:$,error:getInternalRouterError(405,{method:d.formMethod})};let j;if(d.formData&&(j={formMethod:d.formMethod||"get",formAction:stripHashFromPath($),formEncType:d&&d.formEncType||"application/x-www-form-urlencoded",formData:d.formData},isMutationMethod(j.formMethod)))return{path:$,submission:j};let _e=parsePath($),et=convertFormDataToSearchParams(d.formData);return b&&_e.search&&hasNakedIndexQuery(_e.search)&&et.append("index",""),_e.search="?"+et,{path:createPath(_e),submission:j}}function getLoaderMatchesUntilBoundary(g,d){let b=g;if(d){let $=g.findIndex(j=>j.route.id===d);$>=0&&(b=g.slice(0,$))}return b}function getMatchesToLoad(g,d,b,$,j,_e,et,tt,nt,rt,it){let st=rt?Object.values(rt)[0]:nt?Object.values(nt)[0]:void 0,ot=g.createURL(d.location),at=g.createURL(j),ut=_e||ot.toString()===at.toString()||ot.search!==at.search,ct=rt?Object.keys(rt)[0]:void 0,ht=getLoaderMatchesUntilBoundary(b,ct).filter((gt,yt)=>{if(gt.route.loader==null)return!1;if(isNewLoader(d.loaderData,d.matches[yt],gt)||et.some(xt=>xt===gt.route.id))return!0;let vt=d.matches[yt],St=gt;return shouldRevalidateLoader(gt,_extends$3({currentUrl:ot,currentParams:vt.params,nextUrl:at,nextParams:St.params},$,{actionResult:st,defaultShouldRevalidate:ut||isNewRouteInstance(vt,St)}))}),pt=[];return it&&it.forEach((gt,yt)=>{if(b.some(vt=>vt.route.id===gt.routeId))tt.includes(yt)?pt.push(_extends$3({key:yt},gt)):shouldRevalidateLoader(gt.match,_extends$3({currentUrl:ot,currentParams:d.matches[d.matches.length-1].params,nextUrl:at,nextParams:b[b.length-1].params},$,{actionResult:st,defaultShouldRevalidate:ut}))&&pt.push(_extends$3({key:yt},gt));else return}),[ht,pt]}function isNewLoader(g,d,b){let $=!d||b.route.id!==d.route.id,j=g[b.route.id]===void 0;return $||j}function isNewRouteInstance(g,d){let b=g.route.path;return g.pathname!==d.pathname||b!=null&&b.endsWith("*")&&g.params["*"]!==d.params["*"]}function shouldRevalidateLoader(g,d){if(g.route.shouldRevalidate){let b=g.route.shouldRevalidate(d);if(typeof b=="boolean")return b}return d.defaultShouldRevalidate}async function callLoaderOrAction(g,d,b,$,j,_e,et,tt){j===void 0&&(j="/"),_e===void 0&&(_e=!1),et===void 0&&(et=!1);let nt,rt,it,st=new Promise((at,ut)=>it=ut),ot=()=>it();d.signal.addEventListener("abort",ot);try{let at=b.route[g];invariant(at,"Could not find the "+g+' to run on the "'+b.route.id+'" route'),rt=await Promise.race([at({request:d,params:b.params,context:tt}),st]),invariant(rt!==void 0,"You defined "+(g==="action"?"an action":"a loader")+" for route "+('"'+b.route.id+"\" but didn't return anything from your `"+g+"` ")+"function. Please return a value or `null`.")}catch(at){nt=ResultType.error,rt=at}finally{d.signal.removeEventListener("abort",ot)}if(isResponse(rt)){let at=rt.status;if(redirectStatusCodes.has(at)){let dt=rt.headers.get("Location");if(invariant(dt,"Redirects returned/thrown from loaders/actions must have a Location header"),/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i.test(dt)){if(!_e){let pt=new URL(d.url),gt=dt.startsWith("//")?new URL(pt.protocol+dt):new URL(dt);gt.origin===pt.origin&&(dt=gt.pathname+gt.search+gt.hash)}}else{let pt=$.slice(0,$.indexOf(b)+1),gt=getPathContributingMatches(pt).map(vt=>vt.pathnameBase),yt=resolveTo(dt,gt,new URL(d.url).pathname);if(invariant(createPath(yt),"Unable to resolve redirect location: "+dt),j){let vt=yt.pathname;yt.pathname=vt==="/"?j:joinPaths([j,vt])}dt=createPath(yt)}if(_e)throw rt.headers.set("Location",dt),rt;return{type:ResultType.redirect,status:at,location:dt,revalidate:rt.headers.get("X-Remix-Revalidate")!==null}}if(et)throw{type:nt||ResultType.data,response:rt};let ut,ct=rt.headers.get("Content-Type");return ct&&/\bapplication\/json\b/.test(ct)?ut=await rt.json():ut=await rt.text(),nt===ResultType.error?{type:nt,error:new ErrorResponse(at,rt.statusText,ut),headers:rt.headers}:{type:ResultType.data,data:ut,statusCode:rt.status,headers:rt.headers}}return nt===ResultType.error?{type:nt,error:rt}:rt instanceof DeferredData?{type:ResultType.deferred,deferredData:rt}:{type:ResultType.data,data:rt}}function createClientSideRequest(g,d,b,$){let j=g.createURL(stripHashFromPath(d)).toString(),_e={signal:b};if($&&isMutationMethod($.formMethod)){let{formMethod:et,formEncType:tt,formData:nt}=$;_e.method=et.toUpperCase(),_e.body=tt==="application/x-www-form-urlencoded"?convertFormDataToSearchParams(nt):nt}return new Request(j,_e)}function convertFormDataToSearchParams(g){let d=new URLSearchParams;for(let[b,$]of g.entries())d.append(b,$ instanceof File?$.name:$);return d}function processRouteLoaderData(g,d,b,$,j){let _e={},et=null,tt,nt=!1,rt={};return b.forEach((it,st)=>{let ot=d[st].route.id;if(invariant(!isRedirectResult(it),"Cannot handle redirect results in processLoaderData"),isErrorResult(it)){let at=findNearestBoundary(g,ot),ut=it.error;$&&(ut=Object.values($)[0],$=void 0),et=et||{},et[at.route.id]==null&&(et[at.route.id]=ut),_e[ot]=void 0,nt||(nt=!0,tt=isRouteErrorResponse(it.error)?it.error.status:500),it.headers&&(rt[ot]=it.headers)}else isDeferredResult(it)?(j.set(ot,it.deferredData),_e[ot]=it.deferredData.data):_e[ot]=it.data,it.statusCode!=null&&it.statusCode!==200&&!nt&&(tt=it.statusCode),it.headers&&(rt[ot]=it.headers)}),$&&(et=$,_e[Object.keys($)[0]]=void 0),{loaderData:_e,errors:et,statusCode:tt||200,loaderHeaders:rt}}function processLoaderData(g,d,b,$,j,_e,et,tt){let{loaderData:nt,errors:rt}=processRouteLoaderData(d,b,$,j,tt);for(let it=0;it<_e.length;it++){let{key:st,match:ot}=_e[it];invariant(et!==void 0&&et[it]!==void 0,"Did not find corresponding fetcher result");let at=et[it];if(isErrorResult(at)){let ut=findNearestBoundary(g.matches,ot.route.id);rt&&rt[ut.route.id]||(rt=_extends$3({},rt,{[ut.route.id]:at.error})),g.fetchers.delete(st)}else if(isRedirectResult(at))invariant(!1,"Unhandled fetcher revalidation redirect");else if(isDeferredResult(at))invariant(!1,"Unhandled fetcher deferred data");else{let ut={state:"idle",data:at.data,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0," _hasFetcherDoneAnything ":!0};g.fetchers.set(st,ut)}}return{loaderData:nt,errors:rt}}function mergeLoaderData(g,d,b,$){let j=_extends$3({},d);for(let _e of b){let et=_e.route.id;if(d.hasOwnProperty(et)?d[et]!==void 0&&(j[et]=d[et]):g[et]!==void 0&&(j[et]=g[et]),$&&$.hasOwnProperty(et))break}return j}function findNearestBoundary(g,d){return(d?g.slice(0,g.findIndex($=>$.route.id===d)+1):[...g]).reverse().find($=>$.route.hasErrorBoundary===!0)||g[0]}function getShortCircuitMatches(g){let d=g.find(b=>b.index||!b.path||b.path==="/")||{id:"__shim-error-route__"};return{matches:[{params:{},pathname:"",pathnameBase:"",route:d}],route:d}}function getInternalRouterError(g,d){let{pathname:b,routeId:$,method:j,type:_e}=d===void 0?{}:d,et="Unknown Server Error",tt="Unknown @remix-run/router error";return g===400?(et="Bad Request",j&&b&&$?tt="You made a "+j+' request to "'+b+'" but '+('did not provide a `loader` for route "'+$+'", ')+"so there is no way to handle the request.":_e==="defer-action"&&(tt="defer() is not supported in actions")):g===403?(et="Forbidden",tt='Route "'+$+'" does not match URL "'+b+'"'):g===404?(et="Not Found",tt='No route matches URL "'+b+'"'):g===405&&(et="Method Not Allowed",j&&b&&$?tt="You made a "+j.toUpperCase()+' request to "'+b+'" but '+('did not provide an `action` for route "'+$+'", ')+"so there is no way to handle the request.":j&&(tt='Invalid request method "'+j.toUpperCase()+'"')),new ErrorResponse(g||500,et,new Error(tt),!0)}function findRedirect(g){for(let d=g.length-1;d>=0;d--){let b=g[d];if(isRedirectResult(b))return b}}function stripHashFromPath(g){let d=typeof g=="string"?parsePath(g):g;return createPath(_extends$3({},d,{hash:""}))}function isHashChangeOnly(g,d){return g.pathname===d.pathname&&g.search===d.search&&g.hash!==d.hash}function isDeferredResult(g){return g.type===ResultType.deferred}function isErrorResult(g){return g.type===ResultType.error}function isRedirectResult(g){return(g&&g.type)===ResultType.redirect}function isResponse(g){return g!=null&&typeof g.status=="number"&&typeof g.statusText=="string"&&typeof g.headers=="object"&&typeof g.body<"u"}function isValidMethod(g){return validRequestMethods.has(g)}function isMutationMethod(g){return validMutationMethods.has(g)}async function resolveDeferredResults(g,d,b,$,j,_e){for(let et=0;etst.route.id===nt.route.id),it=rt!=null&&!isNewRouteInstance(rt,nt)&&(_e&&_e[nt.route.id])!==void 0;isDeferredResult(tt)&&(j||it)&&await resolveDeferredData(tt,$,j).then(st=>{st&&(b[et]=st||b[et])})}}async function resolveDeferredData(g,d,b){if(b===void 0&&(b=!1),!await g.deferredData.resolveData(d)){if(b)try{return{type:ResultType.data,data:g.deferredData.unwrappedData}}catch(j){return{type:ResultType.error,error:j}}return{type:ResultType.data,data:g.deferredData.data}}}function hasNakedIndexQuery(g){return new URLSearchParams(g).getAll("index").some(d=>d==="")}function createUseMatchesMatch(g,d){let{route:b,pathname:$,params:j}=g;return{id:b.id,pathname:$,params:j,data:d[b.id],handle:b.handle}}function getTargetMatch(g,d){let b=typeof d=="string"?parsePath(d).search:d.search;if(g[g.length-1].route.index&&hasNakedIndexQuery(b||""))return g[g.length-1];let $=getPathContributingMatches(g);return $[$.length-1]}/** + * React Router v6.8.0 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */function _extends$2(){return _extends$2=Object.assign?Object.assign.bind():function(g){for(var d=1;d{j.value=$,j.getSnapshot=d,checkIfSnapshotChanged(j)&&_e({inst:j})},[g,$,d]),useEffect(()=>(checkIfSnapshotChanged(j)&&_e({inst:j}),g(()=>{checkIfSnapshotChanged(j)&&_e({inst:j})})),[g]),useDebugValue($),$}function checkIfSnapshotChanged(g){const d=g.getSnapshot,b=g.value;try{const $=d();return!is(b,$)}catch{return!0}}function useSyncExternalStore$1(g,d,b){return d()}const canUseDOM=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",isServerEnvironment=!canUseDOM,shim=isServerEnvironment?useSyncExternalStore$1:useSyncExternalStore$2,useSyncExternalStore="useSyncExternalStore"in React$1?(g=>g.useSyncExternalStore)(React$1):shim,DataRouterContext=reactExports.createContext(null),DataRouterStateContext=reactExports.createContext(null),NavigationContext=reactExports.createContext(null),LocationContext=reactExports.createContext(null),RouteContext=reactExports.createContext({outlet:null,matches:[]}),RouteErrorContext=reactExports.createContext(null);function useHref(g,d){let{relative:b}=d===void 0?{}:d;useInRouterContext()||invariant(!1);let{basename:$,navigator:j}=reactExports.useContext(NavigationContext),{hash:_e,pathname:et,search:tt}=useResolvedPath(g,{relative:b}),nt=et;return $!=="/"&&(nt=et==="/"?$:joinPaths([$,et])),j.createHref({pathname:nt,search:tt,hash:_e})}function useInRouterContext(){return reactExports.useContext(LocationContext)!=null}function useLocation(){return useInRouterContext()||invariant(!1),reactExports.useContext(LocationContext).location}function useNavigate(){useInRouterContext()||invariant(!1);let{basename:g,navigator:d}=reactExports.useContext(NavigationContext),{matches:b}=reactExports.useContext(RouteContext),{pathname:$}=useLocation(),j=JSON.stringify(getPathContributingMatches(b).map(tt=>tt.pathnameBase)),_e=reactExports.useRef(!1);return reactExports.useEffect(()=>{_e.current=!0}),reactExports.useCallback(function(tt,nt){if(nt===void 0&&(nt={}),!_e.current)return;if(typeof tt=="number"){d.go(tt);return}let rt=resolveTo(tt,JSON.parse(j),$,nt.relative==="path");g!=="/"&&(rt.pathname=rt.pathname==="/"?g:joinPaths([g,rt.pathname])),(nt.replace?d.replace:d.push)(rt,nt.state,nt)},[g,d,j,$])}const OutletContext=reactExports.createContext(null);function useOutlet(g){let d=reactExports.useContext(RouteContext).outlet;return d&&reactExports.createElement(OutletContext.Provider,{value:g},d)}function useResolvedPath(g,d){let{relative:b}=d===void 0?{}:d,{matches:$}=reactExports.useContext(RouteContext),{pathname:j}=useLocation(),_e=JSON.stringify(getPathContributingMatches($).map(et=>et.pathnameBase));return reactExports.useMemo(()=>resolveTo(g,JSON.parse(_e),j,b==="path"),[g,_e,j,b])}function useRoutes(g,d){useInRouterContext()||invariant(!1);let{navigator:b}=reactExports.useContext(NavigationContext),$=reactExports.useContext(DataRouterStateContext),{matches:j}=reactExports.useContext(RouteContext),_e=j[j.length-1],et=_e?_e.params:{};_e&&_e.pathname;let tt=_e?_e.pathnameBase:"/";_e&&_e.route;let nt=useLocation(),rt;if(d){var it;let ct=typeof d=="string"?parsePath(d):d;tt==="/"||(it=ct.pathname)!=null&&it.startsWith(tt)||invariant(!1),rt=ct}else rt=nt;let st=rt.pathname||"/",ot=tt==="/"?st:st.slice(tt.length)||"/",at=matchRoutes(g,{pathname:ot}),ut=_renderMatches(at&&at.map(ct=>Object.assign({},ct,{params:Object.assign({},et,ct.params),pathname:joinPaths([tt,b.encodeLocation?b.encodeLocation(ct.pathname).pathname:ct.pathname]),pathnameBase:ct.pathnameBase==="/"?tt:joinPaths([tt,b.encodeLocation?b.encodeLocation(ct.pathnameBase).pathname:ct.pathnameBase])})),j,$||void 0);return d&&ut?reactExports.createElement(LocationContext.Provider,{value:{location:_extends$2({pathname:"/",search:"",hash:"",state:null,key:"default"},rt),navigationType:Action.Pop}},ut):ut}function DefaultErrorElement(){let g=useRouteError(),d=isRouteErrorResponse(g)?g.status+" "+g.statusText:g instanceof Error?g.message:JSON.stringify(g),b=g instanceof Error?g.stack:null,j={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"},_e=null;return reactExports.createElement(reactExports.Fragment,null,reactExports.createElement("h2",null,"Unexpected Application Error!"),reactExports.createElement("h3",{style:{fontStyle:"italic"}},d),b?reactExports.createElement("pre",{style:j},b):null,_e)}class RenderErrorBoundary extends reactExports.Component{constructor(d){super(d),this.state={location:d.location,error:d.error}}static getDerivedStateFromError(d){return{error:d}}static getDerivedStateFromProps(d,b){return b.location!==d.location?{error:d.error,location:d.location}:{error:d.error||b.error,location:b.location}}componentDidCatch(d,b){console.error("React Router caught the following error during render",d,b)}render(){return this.state.error?reactExports.createElement(RouteContext.Provider,{value:this.props.routeContext},reactExports.createElement(RouteErrorContext.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function RenderedRoute(g){let{routeContext:d,match:b,children:$}=g,j=reactExports.useContext(DataRouterContext);return j&&j.static&&j.staticContext&&b.route.errorElement&&(j.staticContext._deepestRenderedBoundaryId=b.route.id),reactExports.createElement(RouteContext.Provider,{value:d},$)}function _renderMatches(g,d,b){if(d===void 0&&(d=[]),g==null)if(b!=null&&b.errors)g=b.matches;else return null;let $=g,j=b==null?void 0:b.errors;if(j!=null){let _e=$.findIndex(et=>et.route.id&&(j==null?void 0:j[et.route.id]));_e>=0||invariant(!1),$=$.slice(0,Math.min($.length,_e+1))}return $.reduceRight((_e,et,tt)=>{let nt=et.route.id?j==null?void 0:j[et.route.id]:null,rt=b?et.route.errorElement||reactExports.createElement(DefaultErrorElement,null):null,it=d.concat($.slice(0,tt+1)),st=()=>reactExports.createElement(RenderedRoute,{match:et,routeContext:{outlet:_e,matches:it}},nt?rt:et.route.element!==void 0?et.route.element:_e);return b&&(et.route.errorElement||tt===0)?reactExports.createElement(RenderErrorBoundary,{location:b.location,component:rt,error:nt,children:st(),routeContext:{outlet:null,matches:it}}):st()},null)}var DataRouterHook$1;(function(g){g.UseBlocker="useBlocker",g.UseRevalidator="useRevalidator"})(DataRouterHook$1||(DataRouterHook$1={}));var DataRouterStateHook$1;(function(g){g.UseLoaderData="useLoaderData",g.UseActionData="useActionData",g.UseRouteError="useRouteError",g.UseNavigation="useNavigation",g.UseRouteLoaderData="useRouteLoaderData",g.UseMatches="useMatches",g.UseRevalidator="useRevalidator"})(DataRouterStateHook$1||(DataRouterStateHook$1={}));function useDataRouterState(g){let d=reactExports.useContext(DataRouterStateContext);return d||invariant(!1),d}function useRouteContext(g){let d=reactExports.useContext(RouteContext);return d||invariant(!1),d}function useCurrentRouteId(g){let d=useRouteContext(),b=d.matches[d.matches.length-1];return b.route.id||invariant(!1),b.route.id}function useLoaderData(){let g=useDataRouterState(DataRouterStateHook$1.UseLoaderData),d=useCurrentRouteId(DataRouterStateHook$1.UseLoaderData);if(g.errors&&g.errors[d]!=null){console.error("You cannot `useLoaderData` in an errorElement (routeId: "+d+")");return}return g.loaderData[d]}function useRouteError(){var g;let d=reactExports.useContext(RouteErrorContext),b=useDataRouterState(DataRouterStateHook$1.UseRouteError),$=useCurrentRouteId(DataRouterStateHook$1.UseRouteError);return d||((g=b.errors)==null?void 0:g[$])}function RouterProvider(g){let{fallbackElement:d,router:b}=g,$=useSyncExternalStore(b.subscribe,()=>b.state,()=>b.state),j=reactExports.useMemo(()=>({createHref:b.createHref,encodeLocation:b.encodeLocation,go:et=>b.navigate(et),push:(et,tt,nt)=>b.navigate(et,{state:tt,preventScrollReset:nt==null?void 0:nt.preventScrollReset}),replace:(et,tt,nt)=>b.navigate(et,{replace:!0,state:tt,preventScrollReset:nt==null?void 0:nt.preventScrollReset})}),[b]),_e=b.basename||"/";return reactExports.createElement(reactExports.Fragment,null,reactExports.createElement(DataRouterContext.Provider,{value:{router:b,navigator:j,static:!1,basename:_e}},reactExports.createElement(DataRouterStateContext.Provider,{value:$},reactExports.createElement(Router,{basename:b.basename,location:b.state.location,navigationType:b.state.historyAction,navigator:j},b.state.initialized?reactExports.createElement(Routes,null):d))),null)}function Outlet(g){return useOutlet(g.context)}function Route(g){invariant(!1)}function Router(g){let{basename:d="/",children:b=null,location:$,navigationType:j=Action.Pop,navigator:_e,static:et=!1}=g;useInRouterContext()&&invariant(!1);let tt=d.replace(/^\/*/,"/"),nt=reactExports.useMemo(()=>({basename:tt,navigator:_e,static:et}),[tt,_e,et]);typeof $=="string"&&($=parsePath($));let{pathname:rt="/",search:it="",hash:st="",state:ot=null,key:at="default"}=$,ut=reactExports.useMemo(()=>{let ct=stripBasename(rt,tt);return ct==null?null:{pathname:ct,search:it,hash:st,state:ot,key:at}},[tt,rt,it,st,ot,at]);return ut==null?null:reactExports.createElement(NavigationContext.Provider,{value:nt},reactExports.createElement(LocationContext.Provider,{children:b,value:{location:ut,navigationType:j}}))}function Routes(g){let{children:d,location:b}=g,$=reactExports.useContext(DataRouterContext),j=$&&!d?$.router.routes:createRoutesFromChildren(d);return useRoutes(j,b)}var AwaitRenderStatus;(function(g){g[g.pending=0]="pending",g[g.success=1]="success",g[g.error=2]="error"})(AwaitRenderStatus||(AwaitRenderStatus={}));new Promise(()=>{});function createRoutesFromChildren(g,d){d===void 0&&(d=[]);let b=[];return reactExports.Children.forEach(g,($,j)=>{if(!reactExports.isValidElement($))return;if($.type===reactExports.Fragment){b.push.apply(b,createRoutesFromChildren($.props.children,d));return}$.type!==Route&&invariant(!1),!$.props.index||!$.props.children||invariant(!1);let _e=[...d,j],et={id:$.props.id||_e.join("-"),caseSensitive:$.props.caseSensitive,element:$.props.element,index:$.props.index,path:$.props.path,loader:$.props.loader,action:$.props.action,errorElement:$.props.errorElement,hasErrorBoundary:$.props.errorElement!=null,shouldRevalidate:$.props.shouldRevalidate,handle:$.props.handle};$.props.children&&(et.children=createRoutesFromChildren($.props.children,_e)),b.push(et)}),b}function enhanceManualRouteObjects(g){return g.map(d=>{let b=_extends$2({},d);return b.hasErrorBoundary==null&&(b.hasErrorBoundary=b.errorElement!=null),b.children&&(b.children=enhanceManualRouteObjects(b.children)),b})}/** + * React Router DOM v6.8.0 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */function _extends$1(){return _extends$1=Object.assign?Object.assign.bind():function(g){for(var d=1;d=0)&&(b[j]=g[j]);return b}function isModifiedEvent(g){return!!(g.metaKey||g.altKey||g.ctrlKey||g.shiftKey)}function shouldProcessLinkClick(g,d){return g.button===0&&(!d||d==="_self")&&!isModifiedEvent(g)}const _excluded$1=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset"],_excluded2=["aria-current","caseSensitive","className","end","style","to","children"];function createBrowserRouter(g,d){return createRouter({basename:d==null?void 0:d.basename,history:createBrowserHistory({window:d==null?void 0:d.window}),hydrationData:(d==null?void 0:d.hydrationData)||parseHydrationData(),routes:enhanceManualRouteObjects(g)}).initialize()}function parseHydrationData(){var g;let d=(g=window)==null?void 0:g.__staticRouterHydrationData;return d&&d.errors&&(d=_extends$1({},d,{errors:deserializeErrors(d.errors)})),d}function deserializeErrors(g){if(!g)return null;let d=Object.entries(g),b={};for(let[$,j]of d)if(j&&j.__type==="RouteErrorResponse")b[$]=new ErrorResponse(j.status,j.statusText,j.data,j.internal===!0);else if(j&&j.__type==="Error"){let _e=new Error(j.message);_e.stack="",b[$]=_e}else b[$]=j;return b}const isBrowser=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Link=reactExports.forwardRef(function(d,b){let{onClick:$,relative:j,reloadDocument:_e,replace:et,state:tt,target:nt,to:rt,preventScrollReset:it}=d,st=_objectWithoutPropertiesLoose$1(d,_excluded$1),ot=typeof rt=="string"?rt:createPath(rt),at=/^[a-z+]+:\/\//i.test(ot)||ot.startsWith("//"),ut=ot,ct=!1;if(isBrowser&&at){let gt=new URL(window.location.href),yt=ot.startsWith("//")?new URL(gt.protocol+ot):new URL(ot);yt.origin===gt.origin?ut=yt.pathname+yt.search+yt.hash:ct=!0}let dt=useHref(ut,{relative:j}),ht=useLinkClickHandler(ut,{replace:et,state:tt,target:nt,preventScrollReset:it,relative:j});function pt(gt){$&&$(gt),gt.defaultPrevented||ht(gt)}return reactExports.createElement("a",_extends$1({},st,{href:at?ot:dt,onClick:ct||_e?$:pt,ref:b,target:nt}))}),NavLink=reactExports.forwardRef(function(d,b){let{"aria-current":$="page",caseSensitive:j=!1,className:_e="",end:et=!1,style:tt,to:nt,children:rt}=d,it=_objectWithoutPropertiesLoose$1(d,_excluded2),st=useResolvedPath(nt,{relative:it.relative}),ot=useLocation(),at=reactExports.useContext(DataRouterStateContext),{navigator:ut}=reactExports.useContext(NavigationContext),ct=ut.encodeLocation?ut.encodeLocation(st).pathname:st.pathname,dt=ot.pathname,ht=at&&at.navigation&&at.navigation.location?at.navigation.location.pathname:null;j||(dt=dt.toLowerCase(),ht=ht?ht.toLowerCase():null,ct=ct.toLowerCase());let pt=dt===ct||!et&&dt.startsWith(ct)&&dt.charAt(ct.length)==="/",gt=ht!=null&&(ht===ct||!et&&ht.startsWith(ct)&&ht.charAt(ct.length)==="/"),yt=pt?$:void 0,vt;typeof _e=="function"?vt=_e({isActive:pt,isPending:gt}):vt=[_e,pt?"active":null,gt?"pending":null].filter(Boolean).join(" ");let St=typeof tt=="function"?tt({isActive:pt,isPending:gt}):tt;return reactExports.createElement(Link,_extends$1({},it,{"aria-current":yt,className:vt,ref:b,style:St,to:nt}),typeof rt=="function"?rt({isActive:pt,isPending:gt}):rt)});var DataRouterHook;(function(g){g.UseScrollRestoration="useScrollRestoration",g.UseSubmitImpl="useSubmitImpl",g.UseFetcher="useFetcher"})(DataRouterHook||(DataRouterHook={}));var DataRouterStateHook;(function(g){g.UseFetchers="useFetchers",g.UseScrollRestoration="useScrollRestoration"})(DataRouterStateHook||(DataRouterStateHook={}));function useLinkClickHandler(g,d){let{target:b,replace:$,state:j,preventScrollReset:_e,relative:et}=d===void 0?{}:d,tt=useNavigate(),nt=useLocation(),rt=useResolvedPath(g,{relative:et});return reactExports.useCallback(it=>{if(shouldProcessLinkClick(it,b)){it.preventDefault();let st=$!==void 0?$:createPath(nt)===createPath(rt);tt(g,{replace:st,state:j,preventScrollReset:_e,relative:et})}},[nt,tt,rt,$,j,b,g,_e,et])}var client={},reactDom={exports:{}},reactDom_production_min={},scheduler={exports:{}},scheduler_production_min={};/** + * @license React + * scheduler.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */(function(g){function d(Ot,Lt){var It=Ot.length;Ot.push(Lt);e:for(;0>>1,Gt=Ot[Ut];if(0>>1;Utj(ln,It))anj(yn,ln)?(Ot[Ut]=yn,Ot[an]=It,Ut=an):(Ot[Ut]=ln,Ot[nn]=It,Ut=nn);else if(anj(yn,It))Ot[Ut]=yn,Ot[an]=It,Ut=an;else break e}}return Lt}function j(Ot,Lt){var It=Ot.sortIndex-Lt.sortIndex;return It!==0?It:Ot.id-Lt.id}if(typeof performance=="object"&&typeof performance.now=="function"){var _e=performance;g.unstable_now=function(){return _e.now()}}else{var et=Date,tt=et.now();g.unstable_now=function(){return et.now()-tt}}var nt=[],rt=[],it=1,st=null,ot=3,at=!1,ut=!1,ct=!1,dt=typeof setTimeout=="function"?setTimeout:null,ht=typeof clearTimeout=="function"?clearTimeout:null,pt=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function gt(Ot){for(var Lt=b(rt);Lt!==null;){if(Lt.callback===null)$(rt);else if(Lt.startTime<=Ot)$(rt),Lt.sortIndex=Lt.expirationTime,d(nt,Lt);else break;Lt=b(rt)}}function yt(Ot){if(ct=!1,gt(Ot),!ut)if(b(nt)!==null)ut=!0,Wt(vt);else{var Lt=b(rt);Lt!==null&&Ht(yt,Lt.startTime-Ot)}}function vt(Ot,Lt){ut=!1,ct&&(ct=!1,ht(Dt),Dt=-1),at=!0;var It=ot;try{for(gt(Lt),st=b(nt);st!==null&&(!(st.expirationTime>Lt)||Ot&&!wt());){var Ut=st.callback;if(typeof Ut=="function"){st.callback=null,ot=st.priorityLevel;var Gt=Ut(st.expirationTime<=Lt);Lt=g.unstable_now(),typeof Gt=="function"?st.callback=Gt:st===b(nt)&&$(nt),gt(Lt)}else $(nt);st=b(nt)}if(st!==null)var tn=!0;else{var nn=b(rt);nn!==null&&Ht(yt,nn.startTime-Lt),tn=!1}return tn}finally{st=null,ot=It,at=!1}}var St=!1,xt=null,Dt=-1,Pt=5,Ct=-1;function wt(){return!(g.unstable_now()-CtOt||125Ut?(Ot.sortIndex=It,d(rt,Ot),b(nt)===null&&Ot===b(rt)&&(ct?(ht(Dt),Dt=-1):ct=!0,Ht(yt,It-Ut))):(Ot.sortIndex=Gt,d(nt,Ot),ut||at||(ut=!0,Wt(vt))),Ot},g.unstable_shouldYield=wt,g.unstable_wrapCallback=function(Ot){var Lt=ot;return function(){var It=ot;ot=Lt;try{return Ot.apply(this,arguments)}finally{ot=It}}}})(scheduler_production_min);scheduler.exports=scheduler_production_min;var schedulerExports=scheduler.exports;/** + * @license React + * react-dom.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var aa=reactExports,ca=schedulerExports;function p$1(g){for(var d="https://reactjs.org/docs/error-decoder.html?invariant="+g,b=1;b"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),ja=Object.prototype.hasOwnProperty,ka=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,la={},ma={};function oa(g){return ja.call(ma,g)?!0:ja.call(la,g)?!1:ka.test(g)?ma[g]=!0:(la[g]=!0,!1)}function pa(g,d,b,$){if(b!==null&&b.type===0)return!1;switch(typeof d){case"function":case"symbol":return!0;case"boolean":return $?!1:b!==null?!b.acceptsBooleans:(g=g.toLowerCase().slice(0,5),g!=="data-"&&g!=="aria-");default:return!1}}function qa(g,d,b,$){if(d===null||typeof d>"u"||pa(g,d,b,$))return!0;if($)return!1;if(b!==null)switch(b.type){case 3:return!d;case 4:return d===!1;case 5:return isNaN(d);case 6:return isNaN(d)||1>d}return!1}function v$1(g,d,b,$,j,_e,et){this.acceptsBooleans=d===2||d===3||d===4,this.attributeName=$,this.attributeNamespace=j,this.mustUseProperty=b,this.propertyName=g,this.type=d,this.sanitizeURL=_e,this.removeEmptyString=et}var z={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(g){z[g]=new v$1(g,0,!1,g,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(g){var d=g[0];z[d]=new v$1(d,1,!1,g[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(g){z[g]=new v$1(g,2,!1,g.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(g){z[g]=new v$1(g,2,!1,g,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(g){z[g]=new v$1(g,3,!1,g.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(g){z[g]=new v$1(g,3,!0,g,null,!1,!1)});["capture","download"].forEach(function(g){z[g]=new v$1(g,4,!1,g,null,!1,!1)});["cols","rows","size","span"].forEach(function(g){z[g]=new v$1(g,6,!1,g,null,!1,!1)});["rowSpan","start"].forEach(function(g){z[g]=new v$1(g,5,!1,g.toLowerCase(),null,!1,!1)});var ra=/[\-:]([a-z])/g;function sa(g){return g[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(g){var d=g.replace(ra,sa);z[d]=new v$1(d,1,!1,g,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(g){var d=g.replace(ra,sa);z[d]=new v$1(d,1,!1,g,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(g){var d=g.replace(ra,sa);z[d]=new v$1(d,1,!1,g,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(g){z[g]=new v$1(g,1,!1,g.toLowerCase(),null,!1,!1)});z.xlinkHref=new v$1("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(g){z[g]=new v$1(g,1,!1,g.toLowerCase(),null,!0,!0)});function ta(g,d,b,$){var j=z.hasOwnProperty(d)?z[d]:null;(j!==null?j.type!==0:$||!(2tt||j[et]!==_e[tt]){var nt=` +`+j[et].replace(" at new "," at ");return g.displayName&&nt.includes("")&&(nt=nt.replace("",g.displayName)),nt}while(1<=et&&0<=tt);break}}}finally{Na=!1,Error.prepareStackTrace=b}return(g=g?g.displayName||g.name:"")?Ma(g):""}function Pa(g){switch(g.tag){case 5:return Ma(g.type);case 16:return Ma("Lazy");case 13:return Ma("Suspense");case 19:return Ma("SuspenseList");case 0:case 2:case 15:return g=Oa(g.type,!1),g;case 11:return g=Oa(g.type.render,!1),g;case 1:return g=Oa(g.type,!0),g;default:return""}}function Qa(g){if(g==null)return null;if(typeof g=="function")return g.displayName||g.name||null;if(typeof g=="string")return g;switch(g){case ya:return"Fragment";case wa:return"Portal";case Aa:return"Profiler";case za:return"StrictMode";case Ea:return"Suspense";case Fa:return"SuspenseList"}if(typeof g=="object")switch(g.$$typeof){case Ca:return(g.displayName||"Context")+".Consumer";case Ba:return(g._context.displayName||"Context")+".Provider";case Da:var d=g.render;return g=g.displayName,g||(g=d.displayName||d.name||"",g=g!==""?"ForwardRef("+g+")":"ForwardRef"),g;case Ga:return d=g.displayName||null,d!==null?d:Qa(g.type)||"Memo";case Ha:d=g._payload,g=g._init;try{return Qa(g(d))}catch{}}return null}function Ra(g){var d=g.type;switch(g.tag){case 24:return"Cache";case 9:return(d.displayName||"Context")+".Consumer";case 10:return(d._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return g=d.render,g=g.displayName||g.name||"",d.displayName||(g!==""?"ForwardRef("+g+")":"ForwardRef");case 7:return"Fragment";case 5:return d;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Qa(d);case 8:return d===za?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof d=="function")return d.displayName||d.name||null;if(typeof d=="string")return d}return null}function Sa(g){switch(typeof g){case"boolean":case"number":case"string":case"undefined":return g;case"object":return g;default:return""}}function Ta(g){var d=g.type;return(g=g.nodeName)&&g.toLowerCase()==="input"&&(d==="checkbox"||d==="radio")}function Ua(g){var d=Ta(g)?"checked":"value",b=Object.getOwnPropertyDescriptor(g.constructor.prototype,d),$=""+g[d];if(!g.hasOwnProperty(d)&&typeof b<"u"&&typeof b.get=="function"&&typeof b.set=="function"){var j=b.get,_e=b.set;return Object.defineProperty(g,d,{configurable:!0,get:function(){return j.call(this)},set:function(et){$=""+et,_e.call(this,et)}}),Object.defineProperty(g,d,{enumerable:b.enumerable}),{getValue:function(){return $},setValue:function(et){$=""+et},stopTracking:function(){g._valueTracker=null,delete g[d]}}}}function Va(g){g._valueTracker||(g._valueTracker=Ua(g))}function Wa(g){if(!g)return!1;var d=g._valueTracker;if(!d)return!0;var b=d.getValue(),$="";return g&&($=Ta(g)?g.checked?"true":"false":g.value),g=$,g!==b?(d.setValue(g),!0):!1}function Xa(g){if(g=g||(typeof document<"u"?document:void 0),typeof g>"u")return null;try{return g.activeElement||g.body}catch{return g.body}}function Ya(g,d){var b=d.checked;return A({},d,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:b??g._wrapperState.initialChecked})}function Za(g,d){var b=d.defaultValue==null?"":d.defaultValue,$=d.checked!=null?d.checked:d.defaultChecked;b=Sa(d.value!=null?d.value:b),g._wrapperState={initialChecked:$,initialValue:b,controlled:d.type==="checkbox"||d.type==="radio"?d.checked!=null:d.value!=null}}function ab(g,d){d=d.checked,d!=null&&ta(g,"checked",d,!1)}function bb(g,d){ab(g,d);var b=Sa(d.value),$=d.type;if(b!=null)$==="number"?(b===0&&g.value===""||g.value!=b)&&(g.value=""+b):g.value!==""+b&&(g.value=""+b);else if($==="submit"||$==="reset"){g.removeAttribute("value");return}d.hasOwnProperty("value")?cb(g,d.type,b):d.hasOwnProperty("defaultValue")&&cb(g,d.type,Sa(d.defaultValue)),d.checked==null&&d.defaultChecked!=null&&(g.defaultChecked=!!d.defaultChecked)}function db(g,d,b){if(d.hasOwnProperty("value")||d.hasOwnProperty("defaultValue")){var $=d.type;if(!($!=="submit"&&$!=="reset"||d.value!==void 0&&d.value!==null))return;d=""+g._wrapperState.initialValue,b||d===g.value||(g.value=d),g.defaultValue=d}b=g.name,b!==""&&(g.name=""),g.defaultChecked=!!g._wrapperState.initialChecked,b!==""&&(g.name=b)}function cb(g,d,b){(d!=="number"||Xa(g.ownerDocument)!==g)&&(b==null?g.defaultValue=""+g._wrapperState.initialValue:g.defaultValue!==""+b&&(g.defaultValue=""+b))}var eb=Array.isArray;function fb(g,d,b,$){if(g=g.options,d){d={};for(var j=0;j"+d.valueOf().toString()+"",d=mb.firstChild;g.firstChild;)g.removeChild(g.firstChild);for(;d.firstChild;)g.appendChild(d.firstChild)}});function ob(g,d){if(d){var b=g.firstChild;if(b&&b===g.lastChild&&b.nodeType===3){b.nodeValue=d;return}}g.textContent=d}var pb={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},qb=["Webkit","ms","Moz","O"];Object.keys(pb).forEach(function(g){qb.forEach(function(d){d=d+g.charAt(0).toUpperCase()+g.substring(1),pb[d]=pb[g]})});function rb(g,d,b){return d==null||typeof d=="boolean"||d===""?"":b||typeof d!="number"||d===0||pb.hasOwnProperty(g)&&pb[g]?(""+d).trim():d+"px"}function sb(g,d){g=g.style;for(var b in d)if(d.hasOwnProperty(b)){var $=b.indexOf("--")===0,j=rb(b,d[b],$);b==="float"&&(b="cssFloat"),$?g.setProperty(b,j):g[b]=j}}var tb=A({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function ub(g,d){if(d){if(tb[g]&&(d.children!=null||d.dangerouslySetInnerHTML!=null))throw Error(p$1(137,g));if(d.dangerouslySetInnerHTML!=null){if(d.children!=null)throw Error(p$1(60));if(typeof d.dangerouslySetInnerHTML!="object"||!("__html"in d.dangerouslySetInnerHTML))throw Error(p$1(61))}if(d.style!=null&&typeof d.style!="object")throw Error(p$1(62))}}function vb(g,d){if(g.indexOf("-")===-1)return typeof d.is=="string";switch(g){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var wb=null;function xb(g){return g=g.target||g.srcElement||window,g.correspondingUseElement&&(g=g.correspondingUseElement),g.nodeType===3?g.parentNode:g}var yb=null,zb=null,Ab=null;function Bb(g){if(g=Cb(g)){if(typeof yb!="function")throw Error(p$1(280));var d=g.stateNode;d&&(d=Db(d),yb(g.stateNode,g.type,d))}}function Eb(g){zb?Ab?Ab.push(g):Ab=[g]:zb=g}function Fb(){if(zb){var g=zb,d=Ab;if(Ab=zb=null,Bb(g),d)for(g=0;g>>=0,g===0?32:31-(pc(g)/qc|0)|0}var rc=64,sc=4194304;function tc(g){switch(g&-g){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return g&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return g&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return g}}function uc(g,d){var b=g.pendingLanes;if(b===0)return 0;var $=0,j=g.suspendedLanes,_e=g.pingedLanes,et=b&268435455;if(et!==0){var tt=et&~j;tt!==0?$=tc(tt):(_e&=et,_e!==0&&($=tc(_e)))}else et=b&~j,et!==0?$=tc(et):_e!==0&&($=tc(_e));if($===0)return 0;if(d!==0&&d!==$&&!(d&j)&&(j=$&-$,_e=d&-d,j>=_e||j===16&&(_e&4194240)!==0))return d;if($&4&&($|=b&16),d=g.entangledLanes,d!==0)for(g=g.entanglements,d&=$;0b;b++)d.push(g);return d}function Ac(g,d,b){g.pendingLanes|=d,d!==536870912&&(g.suspendedLanes=0,g.pingedLanes=0),g=g.eventTimes,d=31-oc(d),g[d]=b}function Bc(g,d){var b=g.pendingLanes&~d;g.pendingLanes=d,g.suspendedLanes=0,g.pingedLanes=0,g.expiredLanes&=d,g.mutableReadLanes&=d,g.entangledLanes&=d,d=g.entanglements;var $=g.eventTimes;for(g=g.expirationTimes;0=be),ee=String.fromCharCode(32),fe=!1;function ge(g,d){switch(g){case"keyup":return $d.indexOf(d.keyCode)!==-1;case"keydown":return d.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function he(g){return g=g.detail,typeof g=="object"&&"data"in g?g.data:null}var ie$2=!1;function je(g,d){switch(g){case"compositionend":return he(d);case"keypress":return d.which!==32?null:(fe=!0,ee);case"textInput":return g=d.data,g===ee&&fe?null:g;default:return null}}function ke(g,d){if(ie$2)return g==="compositionend"||!ae&&ge(g,d)?(g=nd(),md=ld=kd=null,ie$2=!1,g):null;switch(g){case"paste":return null;case"keypress":if(!(d.ctrlKey||d.altKey||d.metaKey)||d.ctrlKey&&d.altKey){if(d.char&&1=d)return{node:b,offset:d-g};g=$}e:{for(;b;){if(b.nextSibling){b=b.nextSibling;break e}b=b.parentNode}b=void 0}b=Je(b)}}function Le(g,d){return g&&d?g===d?!0:g&&g.nodeType===3?!1:d&&d.nodeType===3?Le(g,d.parentNode):"contains"in g?g.contains(d):g.compareDocumentPosition?!!(g.compareDocumentPosition(d)&16):!1:!1}function Me(){for(var g=window,d=Xa();d instanceof g.HTMLIFrameElement;){try{var b=typeof d.contentWindow.location.href=="string"}catch{b=!1}if(b)g=d.contentWindow;else break;d=Xa(g.document)}return d}function Ne(g){var d=g&&g.nodeName&&g.nodeName.toLowerCase();return d&&(d==="input"&&(g.type==="text"||g.type==="search"||g.type==="tel"||g.type==="url"||g.type==="password")||d==="textarea"||g.contentEditable==="true")}function Oe(g){var d=Me(),b=g.focusedElem,$=g.selectionRange;if(d!==b&&b&&b.ownerDocument&&Le(b.ownerDocument.documentElement,b)){if($!==null&&Ne(b)){if(d=$.start,g=$.end,g===void 0&&(g=d),"selectionStart"in b)b.selectionStart=d,b.selectionEnd=Math.min(g,b.value.length);else if(g=(d=b.ownerDocument||document)&&d.defaultView||window,g.getSelection){g=g.getSelection();var j=b.textContent.length,_e=Math.min($.start,j);$=$.end===void 0?_e:Math.min($.end,j),!g.extend&&_e>$&&(j=$,$=_e,_e=j),j=Ke(b,_e);var et=Ke(b,$);j&&et&&(g.rangeCount!==1||g.anchorNode!==j.node||g.anchorOffset!==j.offset||g.focusNode!==et.node||g.focusOffset!==et.offset)&&(d=d.createRange(),d.setStart(j.node,j.offset),g.removeAllRanges(),_e>$?(g.addRange(d),g.extend(et.node,et.offset)):(d.setEnd(et.node,et.offset),g.addRange(d)))}}for(d=[],g=b;g=g.parentNode;)g.nodeType===1&&d.push({element:g,left:g.scrollLeft,top:g.scrollTop});for(typeof b.focus=="function"&&b.focus(),b=0;b=document.documentMode,Qe=null,Re=null,Se=null,Te=!1;function Ue(g,d,b){var $=b.window===b?b.document:b.nodeType===9?b:b.ownerDocument;Te||Qe==null||Qe!==Xa($)||($=Qe,"selectionStart"in $&&Ne($)?$={start:$.selectionStart,end:$.selectionEnd}:($=($.ownerDocument&&$.ownerDocument.defaultView||window).getSelection(),$={anchorNode:$.anchorNode,anchorOffset:$.anchorOffset,focusNode:$.focusNode,focusOffset:$.focusOffset}),Se&&Ie(Se,$)||(Se=$,$=oe(Re,"onSelect"),0<$.length&&(d=new td("onSelect","select",null,d,b),g.push({event:d,listeners:$}),d.target=Qe)))}function Ve(g,d){var b={};return b[g.toLowerCase()]=d.toLowerCase(),b["Webkit"+g]="webkit"+d,b["Moz"+g]="moz"+d,b}var We={animationend:Ve("Animation","AnimationEnd"),animationiteration:Ve("Animation","AnimationIteration"),animationstart:Ve("Animation","AnimationStart"),transitionend:Ve("Transition","TransitionEnd")},Xe={},Ye={};ia&&(Ye=document.createElement("div").style,"AnimationEvent"in window||(delete We.animationend.animation,delete We.animationiteration.animation,delete We.animationstart.animation),"TransitionEvent"in window||delete We.transitionend.transition);function Ze(g){if(Xe[g])return Xe[g];if(!We[g])return g;var d=We[g],b;for(b in d)if(d.hasOwnProperty(b)&&b in Ye)return Xe[g]=d[b];return g}var $e=Ze("animationend"),af=Ze("animationiteration"),bf=Ze("animationstart"),cf=Ze("transitionend"),df=new Map,ef="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function ff(g,d){df.set(g,d),fa(d,[g])}for(var gf=0;gfTf||(g.current=Sf[Tf],Sf[Tf]=null,Tf--)}function G(g,d){Tf++,Sf[Tf]=g.current,g.current=d}var Vf={},H=Uf(Vf),Wf=Uf(!1),Xf=Vf;function Yf(g,d){var b=g.type.contextTypes;if(!b)return Vf;var $=g.stateNode;if($&&$.__reactInternalMemoizedUnmaskedChildContext===d)return $.__reactInternalMemoizedMaskedChildContext;var j={},_e;for(_e in b)j[_e]=d[_e];return $&&(g=g.stateNode,g.__reactInternalMemoizedUnmaskedChildContext=d,g.__reactInternalMemoizedMaskedChildContext=j),j}function Zf(g){return g=g.childContextTypes,g!=null}function $f(){E(Wf),E(H)}function ag(g,d,b){if(H.current!==Vf)throw Error(p$1(168));G(H,d),G(Wf,b)}function bg(g,d,b){var $=g.stateNode;if(d=d.childContextTypes,typeof $.getChildContext!="function")return b;$=$.getChildContext();for(var j in $)if(!(j in d))throw Error(p$1(108,Ra(g)||"Unknown",j));return A({},b,$)}function cg(g){return g=(g=g.stateNode)&&g.__reactInternalMemoizedMergedChildContext||Vf,Xf=H.current,G(H,g),G(Wf,Wf.current),!0}function dg(g,d,b){var $=g.stateNode;if(!$)throw Error(p$1(169));b?(g=bg(g,d,Xf),$.__reactInternalMemoizedMergedChildContext=g,E(Wf),E(H),G(H,g)):E(Wf),G(Wf,b)}var eg=null,fg=!1,gg=!1;function hg(g){eg===null?eg=[g]:eg.push(g)}function ig(g){fg=!0,hg(g)}function jg(){if(!gg&&eg!==null){gg=!0;var g=0,d=C$1;try{var b=eg;for(C$1=1;g>=et,j-=et,rg=1<<32-oc(d)+j|b<Dt?(Pt=xt,xt=null):Pt=xt.sibling;var Ct=ot(ht,xt,gt[Dt],yt);if(Ct===null){xt===null&&(xt=Pt);break}g&&xt&&Ct.alternate===null&&d(ht,xt),pt=_e(Ct,pt,Dt),St===null?vt=Ct:St.sibling=Ct,St=Ct,xt=Pt}if(Dt===gt.length)return b(ht,xt),I&&tg(ht,Dt),vt;if(xt===null){for(;DtDt?(Pt=xt,xt=null):Pt=xt.sibling;var wt=ot(ht,xt,Ct.value,yt);if(wt===null){xt===null&&(xt=Pt);break}g&&xt&&wt.alternate===null&&d(ht,xt),pt=_e(wt,pt,Dt),St===null?vt=wt:St.sibling=wt,St=wt,xt=Pt}if(Ct.done)return b(ht,xt),I&&tg(ht,Dt),vt;if(xt===null){for(;!Ct.done;Dt++,Ct=gt.next())Ct=st(ht,Ct.value,yt),Ct!==null&&(pt=_e(Ct,pt,Dt),St===null?vt=Ct:St.sibling=Ct,St=Ct);return I&&tg(ht,Dt),vt}for(xt=$(ht,xt);!Ct.done;Dt++,Ct=gt.next())Ct=at(xt,ht,Dt,Ct.value,yt),Ct!==null&&(g&&Ct.alternate!==null&&xt.delete(Ct.key===null?Dt:Ct.key),pt=_e(Ct,pt,Dt),St===null?vt=Ct:St.sibling=Ct,St=Ct);return g&&xt.forEach(function(Tt){return d(ht,Tt)}),I&&tg(ht,Dt),vt}function dt(ht,pt,gt,yt){if(typeof gt=="object"&>!==null&>.type===ya&>.key===null&&(gt=gt.props.children),typeof gt=="object"&>!==null){switch(gt.$$typeof){case va:e:{for(var vt=gt.key,St=pt;St!==null;){if(St.key===vt){if(vt=gt.type,vt===ya){if(St.tag===7){b(ht,St.sibling),pt=j(St,gt.props.children),pt.return=ht,ht=pt;break e}}else if(St.elementType===vt||typeof vt=="object"&&vt!==null&&vt.$$typeof===Ha&&uh(vt)===St.type){b(ht,St.sibling),pt=j(St,gt.props),pt.ref=sh(ht,St,gt),pt.return=ht,ht=pt;break e}b(ht,St);break}else d(ht,St);St=St.sibling}gt.type===ya?(pt=Ah(gt.props.children,ht.mode,yt,gt.key),pt.return=ht,ht=pt):(yt=yh(gt.type,gt.key,gt.props,null,ht.mode,yt),yt.ref=sh(ht,pt,gt),yt.return=ht,ht=yt)}return et(ht);case wa:e:{for(St=gt.key;pt!==null;){if(pt.key===St)if(pt.tag===4&&pt.stateNode.containerInfo===gt.containerInfo&&pt.stateNode.implementation===gt.implementation){b(ht,pt.sibling),pt=j(pt,gt.children||[]),pt.return=ht,ht=pt;break e}else{b(ht,pt);break}else d(ht,pt);pt=pt.sibling}pt=zh(gt,ht.mode,yt),pt.return=ht,ht=pt}return et(ht);case Ha:return St=gt._init,dt(ht,pt,St(gt._payload),yt)}if(eb(gt))return ut(ht,pt,gt,yt);if(Ka(gt))return ct(ht,pt,gt,yt);th(ht,gt)}return typeof gt=="string"&>!==""||typeof gt=="number"?(gt=""+gt,pt!==null&&pt.tag===6?(b(ht,pt.sibling),pt=j(pt,gt),pt.return=ht,ht=pt):(b(ht,pt),pt=xh(gt,ht.mode,yt),pt.return=ht,ht=pt),et(ht)):b(ht,pt)}return dt}var Bh=vh(!0),Ch=vh(!1),Dh={},Eh=Uf(Dh),Fh=Uf(Dh),Gh=Uf(Dh);function Hh(g){if(g===Dh)throw Error(p$1(174));return g}function Ih(g,d){switch(G(Gh,d),G(Fh,g),G(Eh,Dh),g=d.nodeType,g){case 9:case 11:d=(d=d.documentElement)?d.namespaceURI:lb(null,"");break;default:g=g===8?d.parentNode:d,d=g.namespaceURI||null,g=g.tagName,d=lb(d,g)}E(Eh),G(Eh,d)}function Jh(){E(Eh),E(Fh),E(Gh)}function Kh(g){Hh(Gh.current);var d=Hh(Eh.current),b=lb(d,g.type);d!==b&&(G(Fh,g),G(Eh,b))}function Lh(g){Fh.current===g&&(E(Eh),E(Fh))}var M=Uf(0);function Mh(g){for(var d=g;d!==null;){if(d.tag===13){var b=d.memoizedState;if(b!==null&&(b=b.dehydrated,b===null||b.data==="$?"||b.data==="$!"))return d}else if(d.tag===19&&d.memoizedProps.revealOrder!==void 0){if(d.flags&128)return d}else if(d.child!==null){d.child.return=d,d=d.child;continue}if(d===g)break;for(;d.sibling===null;){if(d.return===null||d.return===g)return null;d=d.return}d.sibling.return=d.return,d=d.sibling}return null}var Nh=[];function Oh(){for(var g=0;gb?b:4,g(!0);var $=Qh.transition;Qh.transition={};try{g(!1),d()}finally{C$1=b,Qh.transition=$}}function Fi(){return di().memoizedState}function Gi(g,d,b){var $=lh(g);if(b={lane:$,action:b,hasEagerState:!1,eagerState:null,next:null},Hi(g))Ii(d,b);else if(b=Yg(g,d,b,$),b!==null){var j=L();mh(b,g,$,j),Ji(b,d,$)}}function ri(g,d,b){var $=lh(g),j={lane:$,action:b,hasEagerState:!1,eagerState:null,next:null};if(Hi(g))Ii(d,j);else{var _e=g.alternate;if(g.lanes===0&&(_e===null||_e.lanes===0)&&(_e=d.lastRenderedReducer,_e!==null))try{var et=d.lastRenderedState,tt=_e(et,b);if(j.hasEagerState=!0,j.eagerState=tt,He(tt,et)){var nt=d.interleaved;nt===null?(j.next=j,Xg(d)):(j.next=nt.next,nt.next=j),d.interleaved=j;return}}catch{}finally{}b=Yg(g,d,j,$),b!==null&&(j=L(),mh(b,g,$,j),Ji(b,d,$))}}function Hi(g){var d=g.alternate;return g===N$1||d!==null&&d===N$1}function Ii(g,d){Th=Sh=!0;var b=g.pending;b===null?d.next=d:(d.next=b.next,b.next=d),g.pending=d}function Ji(g,d,b){if(b&4194240){var $=d.lanes;$&=g.pendingLanes,b|=$,d.lanes=b,Cc(g,b)}}var ai={readContext:Vg,useCallback:Q,useContext:Q,useEffect:Q,useImperativeHandle:Q,useInsertionEffect:Q,useLayoutEffect:Q,useMemo:Q,useReducer:Q,useRef:Q,useState:Q,useDebugValue:Q,useDeferredValue:Q,useTransition:Q,useMutableSource:Q,useSyncExternalStore:Q,useId:Q,unstable_isNewReconciler:!1},Yh={readContext:Vg,useCallback:function(g,d){return ci().memoizedState=[g,d===void 0?null:d],g},useContext:Vg,useEffect:vi,useImperativeHandle:function(g,d,b){return b=b!=null?b.concat([g]):null,ti(4194308,4,yi.bind(null,d,g),b)},useLayoutEffect:function(g,d){return ti(4194308,4,g,d)},useInsertionEffect:function(g,d){return ti(4,2,g,d)},useMemo:function(g,d){var b=ci();return d=d===void 0?null:d,g=g(),b.memoizedState=[g,d],g},useReducer:function(g,d,b){var $=ci();return d=b!==void 0?b(d):d,$.memoizedState=$.baseState=d,g={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:g,lastRenderedState:d},$.queue=g,g=g.dispatch=Gi.bind(null,N$1,g),[$.memoizedState,g]},useRef:function(g){var d=ci();return g={current:g},d.memoizedState=g},useState:qi,useDebugValue:Ai,useDeferredValue:function(g){return ci().memoizedState=g},useTransition:function(){var g=qi(!1),d=g[0];return g=Ei.bind(null,g[1]),ci().memoizedState=g,[d,g]},useMutableSource:function(){},useSyncExternalStore:function(g,d,b){var $=N$1,j=ci();if(I){if(b===void 0)throw Error(p$1(407));b=b()}else{if(b=d(),R===null)throw Error(p$1(349));Rh&30||ni($,d,b)}j.memoizedState=b;var _e={value:b,getSnapshot:d};return j.queue=_e,vi(ki.bind(null,$,_e,g),[g]),$.flags|=2048,li(9,mi.bind(null,$,_e,b,d),void 0,null),b},useId:function(){var g=ci(),d=R.identifierPrefix;if(I){var b=sg,$=rg;b=($&~(1<<32-oc($)-1)).toString(32)+b,d=":"+d+"R"+b,b=Uh++,0<\/script>",g=g.removeChild(g.firstChild)):typeof $.is=="string"?g=et.createElement(b,{is:$.is}):(g=et.createElement(b),b==="select"&&(et=g,$.multiple?et.multiple=!0:$.size&&(et.size=$.size))):g=et.createElementNS(g,b),g[Of]=d,g[Pf]=$,Aj(g,d,!1,!1),d.stateNode=g;e:{switch(et=vb(b,$),b){case"dialog":D("cancel",g),D("close",g),j=$;break;case"iframe":case"object":case"embed":D("load",g),j=$;break;case"video":case"audio":for(j=0;jHj&&(d.flags|=128,$=!0,Ej(_e,!1),d.lanes=4194304)}else{if(!$)if(g=Mh(et),g!==null){if(d.flags|=128,$=!0,b=g.updateQueue,b!==null&&(d.updateQueue=b,d.flags|=4),Ej(_e,!0),_e.tail===null&&_e.tailMode==="hidden"&&!et.alternate&&!I)return S(d),null}else 2*B()-_e.renderingStartTime>Hj&&b!==1073741824&&(d.flags|=128,$=!0,Ej(_e,!1),d.lanes=4194304);_e.isBackwards?(et.sibling=d.child,d.child=et):(b=_e.last,b!==null?b.sibling=et:d.child=et,_e.last=et)}return _e.tail!==null?(d=_e.tail,_e.rendering=d,_e.tail=d.sibling,_e.renderingStartTime=B(),d.sibling=null,b=M.current,G(M,$?b&1|2:b&1),d):(S(d),null);case 22:case 23:return Ij(),$=d.memoizedState!==null,g!==null&&g.memoizedState!==null!==$&&(d.flags|=8192),$&&d.mode&1?gj&1073741824&&(S(d),d.subtreeFlags&6&&(d.flags|=8192)):S(d),null;case 24:return null;case 25:return null}throw Error(p$1(156,d.tag))}function Jj(g,d){switch(wg(d),d.tag){case 1:return Zf(d.type)&&$f(),g=d.flags,g&65536?(d.flags=g&-65537|128,d):null;case 3:return Jh(),E(Wf),E(H),Oh(),g=d.flags,g&65536&&!(g&128)?(d.flags=g&-65537|128,d):null;case 5:return Lh(d),null;case 13:if(E(M),g=d.memoizedState,g!==null&&g.dehydrated!==null){if(d.alternate===null)throw Error(p$1(340));Ig()}return g=d.flags,g&65536?(d.flags=g&-65537|128,d):null;case 19:return E(M),null;case 4:return Jh(),null;case 10:return Rg(d.type._context),null;case 22:case 23:return Ij(),null;case 24:return null;default:return null}}var Kj=!1,U=!1,Lj=typeof WeakSet=="function"?WeakSet:Set,V=null;function Mj(g,d){var b=g.ref;if(b!==null)if(typeof b=="function")try{b(null)}catch($){W(g,d,$)}else b.current=null}function Nj(g,d,b){try{b()}catch($){W(g,d,$)}}var Oj=!1;function Pj(g,d){if(Cf=dd,g=Me(),Ne(g)){if("selectionStart"in g)var b={start:g.selectionStart,end:g.selectionEnd};else e:{b=(b=g.ownerDocument)&&b.defaultView||window;var $=b.getSelection&&b.getSelection();if($&&$.rangeCount!==0){b=$.anchorNode;var j=$.anchorOffset,_e=$.focusNode;$=$.focusOffset;try{b.nodeType,_e.nodeType}catch{b=null;break e}var et=0,tt=-1,nt=-1,rt=0,it=0,st=g,ot=null;t:for(;;){for(var at;st!==b||j!==0&&st.nodeType!==3||(tt=et+j),st!==_e||$!==0&&st.nodeType!==3||(nt=et+$),st.nodeType===3&&(et+=st.nodeValue.length),(at=st.firstChild)!==null;)ot=st,st=at;for(;;){if(st===g)break t;if(ot===b&&++rt===j&&(tt=et),ot===_e&&++it===$&&(nt=et),(at=st.nextSibling)!==null)break;st=ot,ot=st.parentNode}st=at}b=tt===-1||nt===-1?null:{start:tt,end:nt}}else b=null}b=b||{start:0,end:0}}else b=null;for(Df={focusedElem:g,selectionRange:b},dd=!1,V=d;V!==null;)if(d=V,g=d.child,(d.subtreeFlags&1028)!==0&&g!==null)g.return=d,V=g;else for(;V!==null;){d=V;try{var ut=d.alternate;if(d.flags&1024)switch(d.tag){case 0:case 11:case 15:break;case 1:if(ut!==null){var ct=ut.memoizedProps,dt=ut.memoizedState,ht=d.stateNode,pt=ht.getSnapshotBeforeUpdate(d.elementType===d.type?ct:Lg(d.type,ct),dt);ht.__reactInternalSnapshotBeforeUpdate=pt}break;case 3:var gt=d.stateNode.containerInfo;gt.nodeType===1?gt.textContent="":gt.nodeType===9&>.documentElement&>.removeChild(gt.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(p$1(163))}}catch(yt){W(d,d.return,yt)}if(g=d.sibling,g!==null){g.return=d.return,V=g;break}V=d.return}return ut=Oj,Oj=!1,ut}function Qj(g,d,b){var $=d.updateQueue;if($=$!==null?$.lastEffect:null,$!==null){var j=$=$.next;do{if((j.tag&g)===g){var _e=j.destroy;j.destroy=void 0,_e!==void 0&&Nj(d,b,_e)}j=j.next}while(j!==$)}}function Rj(g,d){if(d=d.updateQueue,d=d!==null?d.lastEffect:null,d!==null){var b=d=d.next;do{if((b.tag&g)===g){var $=b.create;b.destroy=$()}b=b.next}while(b!==d)}}function Sj(g){var d=g.ref;if(d!==null){var b=g.stateNode;switch(g.tag){case 5:g=b;break;default:g=b}typeof d=="function"?d(g):d.current=g}}function Tj(g){var d=g.alternate;d!==null&&(g.alternate=null,Tj(d)),g.child=null,g.deletions=null,g.sibling=null,g.tag===5&&(d=g.stateNode,d!==null&&(delete d[Of],delete d[Pf],delete d[of],delete d[Qf],delete d[Rf])),g.stateNode=null,g.return=null,g.dependencies=null,g.memoizedProps=null,g.memoizedState=null,g.pendingProps=null,g.stateNode=null,g.updateQueue=null}function Uj(g){return g.tag===5||g.tag===3||g.tag===4}function Vj(g){e:for(;;){for(;g.sibling===null;){if(g.return===null||Uj(g.return))return null;g=g.return}for(g.sibling.return=g.return,g=g.sibling;g.tag!==5&&g.tag!==6&&g.tag!==18;){if(g.flags&2||g.child===null||g.tag===4)continue e;g.child.return=g,g=g.child}if(!(g.flags&2))return g.stateNode}}function Wj(g,d,b){var $=g.tag;if($===5||$===6)g=g.stateNode,d?b.nodeType===8?b.parentNode.insertBefore(g,d):b.insertBefore(g,d):(b.nodeType===8?(d=b.parentNode,d.insertBefore(g,b)):(d=b,d.appendChild(g)),b=b._reactRootContainer,b!=null||d.onclick!==null||(d.onclick=Bf));else if($!==4&&(g=g.child,g!==null))for(Wj(g,d,b),g=g.sibling;g!==null;)Wj(g,d,b),g=g.sibling}function Xj(g,d,b){var $=g.tag;if($===5||$===6)g=g.stateNode,d?b.insertBefore(g,d):b.appendChild(g);else if($!==4&&(g=g.child,g!==null))for(Xj(g,d,b),g=g.sibling;g!==null;)Xj(g,d,b),g=g.sibling}var X=null,Yj=!1;function Zj(g,d,b){for(b=b.child;b!==null;)ak(g,d,b),b=b.sibling}function ak(g,d,b){if(lc&&typeof lc.onCommitFiberUnmount=="function")try{lc.onCommitFiberUnmount(kc,b)}catch{}switch(b.tag){case 5:U||Mj(b,d);case 6:var $=X,j=Yj;X=null,Zj(g,d,b),X=$,Yj=j,X!==null&&(Yj?(g=X,b=b.stateNode,g.nodeType===8?g.parentNode.removeChild(b):g.removeChild(b)):X.removeChild(b.stateNode));break;case 18:X!==null&&(Yj?(g=X,b=b.stateNode,g.nodeType===8?Kf(g.parentNode,b):g.nodeType===1&&Kf(g,b),bd(g)):Kf(X,b.stateNode));break;case 4:$=X,j=Yj,X=b.stateNode.containerInfo,Yj=!0,Zj(g,d,b),X=$,Yj=j;break;case 0:case 11:case 14:case 15:if(!U&&($=b.updateQueue,$!==null&&($=$.lastEffect,$!==null))){j=$=$.next;do{var _e=j,et=_e.destroy;_e=_e.tag,et!==void 0&&(_e&2||_e&4)&&Nj(b,d,et),j=j.next}while(j!==$)}Zj(g,d,b);break;case 1:if(!U&&(Mj(b,d),$=b.stateNode,typeof $.componentWillUnmount=="function"))try{$.props=b.memoizedProps,$.state=b.memoizedState,$.componentWillUnmount()}catch(tt){W(b,d,tt)}Zj(g,d,b);break;case 21:Zj(g,d,b);break;case 22:b.mode&1?(U=($=U)||b.memoizedState!==null,Zj(g,d,b),U=$):Zj(g,d,b);break;default:Zj(g,d,b)}}function bk(g){var d=g.updateQueue;if(d!==null){g.updateQueue=null;var b=g.stateNode;b===null&&(b=g.stateNode=new Lj),d.forEach(function($){var j=ck.bind(null,g,$);b.has($)||(b.add($),$.then(j,j))})}}function dk(g,d){var b=d.deletions;if(b!==null)for(var $=0;$j&&(j=et),$&=~_e}if($=j,$=B()-$,$=(120>$?120:480>$?480:1080>$?1080:1920>$?1920:3e3>$?3e3:4320>$?4320:1960*mk($/1960))-$,10<$){g.timeoutHandle=Ff(Qk.bind(null,g,uk,vk),$);break}Qk(g,uk,vk);break;case 5:Qk(g,uk,vk);break;default:throw Error(p$1(329))}}}return Ek(g,B()),g.callbackNode===b?Hk.bind(null,g):null}function Ok(g,d){var b=tk;return g.current.memoizedState.isDehydrated&&(Lk(g,d).flags|=256),g=Jk(g,d),g!==2&&(d=uk,uk=b,d!==null&&Gj(d)),g}function Gj(g){uk===null?uk=g:uk.push.apply(uk,g)}function Pk(g){for(var d=g;;){if(d.flags&16384){var b=d.updateQueue;if(b!==null&&(b=b.stores,b!==null))for(var $=0;$g?16:g,xk===null)var $=!1;else{if(g=xk,xk=null,yk=0,K&6)throw Error(p$1(331));var j=K;for(K|=4,V=g.current;V!==null;){var _e=V,et=_e.child;if(V.flags&16){var tt=_e.deletions;if(tt!==null){for(var nt=0;ntB()-gk?Lk(g,0):sk|=b),Ek(g,d)}function Zk(g,d){d===0&&(g.mode&1?(d=sc,sc<<=1,!(sc&130023424)&&(sc=4194304)):d=1);var b=L();g=Zg(g,d),g!==null&&(Ac(g,d,b),Ek(g,b))}function vj(g){var d=g.memoizedState,b=0;d!==null&&(b=d.retryLane),Zk(g,b)}function ck(g,d){var b=0;switch(g.tag){case 13:var $=g.stateNode,j=g.memoizedState;j!==null&&(b=j.retryLane);break;case 19:$=g.stateNode;break;default:throw Error(p$1(314))}$!==null&&$.delete(d),Zk(g,b)}var Wk;Wk=function(g,d,b){if(g!==null)if(g.memoizedProps!==d.pendingProps||Wf.current)Ug=!0;else{if(!(g.lanes&b)&&!(d.flags&128))return Ug=!1,zj(g,d,b);Ug=!!(g.flags&131072)}else Ug=!1,I&&d.flags&1048576&&ug(d,ng,d.index);switch(d.lanes=0,d.tag){case 2:var $=d.type;jj(g,d),g=d.pendingProps;var j=Yf(d,H.current);Tg(d,b),j=Xh(null,d,$,g,j,b);var _e=bi();return d.flags|=1,typeof j=="object"&&j!==null&&typeof j.render=="function"&&j.$$typeof===void 0?(d.tag=1,d.memoizedState=null,d.updateQueue=null,Zf($)?(_e=!0,cg(d)):_e=!1,d.memoizedState=j.state!==null&&j.state!==void 0?j.state:null,ah(d),j.updater=nh,d.stateNode=j,j._reactInternals=d,rh(d,$,g,b),d=kj(null,d,$,!0,_e,b)):(d.tag=0,I&&_e&&vg(d),Yi(null,d,j,b),d=d.child),d;case 16:$=d.elementType;e:{switch(jj(g,d),g=d.pendingProps,j=$._init,$=j($._payload),d.type=$,j=d.tag=$k($),g=Lg($,g),j){case 0:d=dj(null,d,$,g,b);break e;case 1:d=ij(null,d,$,g,b);break e;case 11:d=Zi(null,d,$,g,b);break e;case 14:d=aj(null,d,$,Lg($.type,g),b);break e}throw Error(p$1(306,$,""))}return d;case 0:return $=d.type,j=d.pendingProps,j=d.elementType===$?j:Lg($,j),dj(g,d,$,j,b);case 1:return $=d.type,j=d.pendingProps,j=d.elementType===$?j:Lg($,j),ij(g,d,$,j,b);case 3:e:{if(lj(d),g===null)throw Error(p$1(387));$=d.pendingProps,_e=d.memoizedState,j=_e.element,bh(g,d),gh(d,$,null,b);var et=d.memoizedState;if($=et.element,_e.isDehydrated)if(_e={element:$,isDehydrated:!1,cache:et.cache,pendingSuspenseBoundaries:et.pendingSuspenseBoundaries,transitions:et.transitions},d.updateQueue.baseState=_e,d.memoizedState=_e,d.flags&256){j=Ki(Error(p$1(423)),d),d=mj(g,d,$,b,j);break e}else if($!==j){j=Ki(Error(p$1(424)),d),d=mj(g,d,$,b,j);break e}else for(yg=Lf(d.stateNode.containerInfo.firstChild),xg=d,I=!0,zg=null,b=Ch(d,null,$,b),d.child=b;b;)b.flags=b.flags&-3|4096,b=b.sibling;else{if(Ig(),$===j){d=$i(g,d,b);break e}Yi(g,d,$,b)}d=d.child}return d;case 5:return Kh(d),g===null&&Eg(d),$=d.type,j=d.pendingProps,_e=g!==null?g.memoizedProps:null,et=j.children,Ef($,j)?et=null:_e!==null&&Ef($,_e)&&(d.flags|=32),hj(g,d),Yi(g,d,et,b),d.child;case 6:return g===null&&Eg(d),null;case 13:return pj(g,d,b);case 4:return Ih(d,d.stateNode.containerInfo),$=d.pendingProps,g===null?d.child=Bh(d,null,$,b):Yi(g,d,$,b),d.child;case 11:return $=d.type,j=d.pendingProps,j=d.elementType===$?j:Lg($,j),Zi(g,d,$,j,b);case 7:return Yi(g,d,d.pendingProps,b),d.child;case 8:return Yi(g,d,d.pendingProps.children,b),d.child;case 12:return Yi(g,d,d.pendingProps.children,b),d.child;case 10:e:{if($=d.type._context,j=d.pendingProps,_e=d.memoizedProps,et=j.value,G(Mg,$._currentValue),$._currentValue=et,_e!==null)if(He(_e.value,et)){if(_e.children===j.children&&!Wf.current){d=$i(g,d,b);break e}}else for(_e=d.child,_e!==null&&(_e.return=d);_e!==null;){var tt=_e.dependencies;if(tt!==null){et=_e.child;for(var nt=tt.firstContext;nt!==null;){if(nt.context===$){if(_e.tag===1){nt=ch(-1,b&-b),nt.tag=2;var rt=_e.updateQueue;if(rt!==null){rt=rt.shared;var it=rt.pending;it===null?nt.next=nt:(nt.next=it.next,it.next=nt),rt.pending=nt}}_e.lanes|=b,nt=_e.alternate,nt!==null&&(nt.lanes|=b),Sg(_e.return,b,d),tt.lanes|=b;break}nt=nt.next}}else if(_e.tag===10)et=_e.type===d.type?null:_e.child;else if(_e.tag===18){if(et=_e.return,et===null)throw Error(p$1(341));et.lanes|=b,tt=et.alternate,tt!==null&&(tt.lanes|=b),Sg(et,b,d),et=_e.sibling}else et=_e.child;if(et!==null)et.return=_e;else for(et=_e;et!==null;){if(et===d){et=null;break}if(_e=et.sibling,_e!==null){_e.return=et.return,et=_e;break}et=et.return}_e=et}Yi(g,d,j.children,b),d=d.child}return d;case 9:return j=d.type,$=d.pendingProps.children,Tg(d,b),j=Vg(j),$=$(j),d.flags|=1,Yi(g,d,$,b),d.child;case 14:return $=d.type,j=Lg($,d.pendingProps),j=Lg($.type,j),aj(g,d,$,j,b);case 15:return cj(g,d,d.type,d.pendingProps,b);case 17:return $=d.type,j=d.pendingProps,j=d.elementType===$?j:Lg($,j),jj(g,d),d.tag=1,Zf($)?(g=!0,cg(d)):g=!1,Tg(d,b),ph(d,$,j),rh(d,$,j,b),kj(null,d,$,!0,g,b);case 19:return yj(g,d,b);case 22:return ej(g,d,b)}throw Error(p$1(156,d.tag))};function Gk(g,d){return ac(g,d)}function al(g,d,b,$){this.tag=g,this.key=b,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=d,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=$,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Bg(g,d,b,$){return new al(g,d,b,$)}function bj(g){return g=g.prototype,!(!g||!g.isReactComponent)}function $k(g){if(typeof g=="function")return bj(g)?1:0;if(g!=null){if(g=g.$$typeof,g===Da)return 11;if(g===Ga)return 14}return 2}function wh(g,d){var b=g.alternate;return b===null?(b=Bg(g.tag,d,g.key,g.mode),b.elementType=g.elementType,b.type=g.type,b.stateNode=g.stateNode,b.alternate=g,g.alternate=b):(b.pendingProps=d,b.type=g.type,b.flags=0,b.subtreeFlags=0,b.deletions=null),b.flags=g.flags&14680064,b.childLanes=g.childLanes,b.lanes=g.lanes,b.child=g.child,b.memoizedProps=g.memoizedProps,b.memoizedState=g.memoizedState,b.updateQueue=g.updateQueue,d=g.dependencies,b.dependencies=d===null?null:{lanes:d.lanes,firstContext:d.firstContext},b.sibling=g.sibling,b.index=g.index,b.ref=g.ref,b}function yh(g,d,b,$,j,_e){var et=2;if($=g,typeof g=="function")bj(g)&&(et=1);else if(typeof g=="string")et=5;else e:switch(g){case ya:return Ah(b.children,j,_e,d);case za:et=8,j|=8;break;case Aa:return g=Bg(12,b,d,j|2),g.elementType=Aa,g.lanes=_e,g;case Ea:return g=Bg(13,b,d,j),g.elementType=Ea,g.lanes=_e,g;case Fa:return g=Bg(19,b,d,j),g.elementType=Fa,g.lanes=_e,g;case Ia:return qj(b,j,_e,d);default:if(typeof g=="object"&&g!==null)switch(g.$$typeof){case Ba:et=10;break e;case Ca:et=9;break e;case Da:et=11;break e;case Ga:et=14;break e;case Ha:et=16,$=null;break e}throw Error(p$1(130,g==null?g:typeof g,""))}return d=Bg(et,b,d,j),d.elementType=g,d.type=$,d.lanes=_e,d}function Ah(g,d,b,$){return g=Bg(7,g,$,d),g.lanes=b,g}function qj(g,d,b,$){return g=Bg(22,g,$,d),g.elementType=Ia,g.lanes=b,g.stateNode={isHidden:!1},g}function xh(g,d,b){return g=Bg(6,g,null,d),g.lanes=b,g}function zh(g,d,b){return d=Bg(4,g.children!==null?g.children:[],g.key,d),d.lanes=b,d.stateNode={containerInfo:g.containerInfo,pendingChildren:null,implementation:g.implementation},d}function bl(g,d,b,$,j){this.tag=d,this.containerInfo=g,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=zc(0),this.expirationTimes=zc(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=zc(0),this.identifierPrefix=$,this.onRecoverableError=j,this.mutableSourceEagerHydrationData=null}function cl(g,d,b,$,j,_e,et,tt,nt){return g=new bl(g,d,b,tt,nt),d===1?(d=1,_e===!0&&(d|=8)):d=0,_e=Bg(3,null,null,d),g.current=_e,_e.stateNode=g,_e.memoizedState={element:$,isDehydrated:b,cache:null,transitions:null,pendingSuspenseBoundaries:null},ah(_e),g}function dl(g,d,b){var $=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(checkDCE)}catch(g){console.error(g)}}checkDCE(),reactDom.exports=reactDom_production_min;var reactDomExports=reactDom.exports,m$2=reactDomExports;client.createRoot=m$2.createRoot,client.hydrateRoot=m$2.hydrateRoot;const App$1="",navLinkClass=({isActive:g,isPending:d})=>g?"active":d?"pending":"";function App(){return jsxRuntimeExports.jsxs("div",{className:"App",children:[jsxRuntimeExports.jsxs("div",{className:"flex-row nav",children:[jsxRuntimeExports.jsx("div",{className:"nav-item",children:jsxRuntimeExports.jsx(NavLink,{className:navLinkClass,to:"draw/evaporating-cloud",children:"Evaporating Cloud"})}),"| ",jsxRuntimeExports.jsx("div",{className:"nav-item",children:jsxRuntimeExports.jsx(NavLink,{className:navLinkClass,to:"draw/goal-tree",children:"Goal Tree"})}),"| ",jsxRuntimeExports.jsx("div",{className:"nav-item",children:jsxRuntimeExports.jsx(NavLink,{className:navLinkClass,to:"draw/problem-tree",children:"Problem Tree"})}),"| ",jsxRuntimeExports.jsx("div",{className:"nav-item",children:jsxRuntimeExports.jsx(NavLink,{className:navLinkClass,to:"about",children:"About"})})]}),jsxRuntimeExports.jsx(Outlet,{})]})}const index$1="";function ErrorPage(){const g=useRouteError();return console.error(g),jsxRuntimeExports.jsxs("div",{id:"error-page",children:[jsxRuntimeExports.jsx("h1",{children:"Oops!"}),jsxRuntimeExports.jsx("p",{children:"Sorry, an unexpected error has occurred."}),jsxRuntimeExports.jsx("p",{children:jsxRuntimeExports.jsx("i",{children:g.statusText||g.message})})]})}function _extends(){return _extends=Object.assign?Object.assign.bind():function(g){for(var d=1;d=0)&&(b[j]=g[j]);return b}class Text{lineAt(d){if(d<0||d>this.length)throw new RangeError(`Invalid position ${d} in document of length ${this.length}`);return this.lineInner(d,!1,1,0)}line(d){if(d<1||d>this.lines)throw new RangeError(`Invalid line number ${d} in ${this.lines}-line document`);return this.lineInner(d,!0,1,0)}replace(d,b,$){[d,b]=clip(this,d,b);let j=[];return this.decompose(0,d,j,2),$.length&&$.decompose(0,$.length,j,3),this.decompose(b,this.length,j,1),TextNode$1.from(j,this.length-(b-d)+$.length)}append(d){return this.replace(this.length,this.length,d)}slice(d,b=this.length){[d,b]=clip(this,d,b);let $=[];return this.decompose(d,b,$,0),TextNode$1.from($,b-d)}eq(d){if(d==this)return!0;if(d.length!=this.length||d.lines!=this.lines)return!1;let b=this.scanIdentical(d,1),$=this.length-this.scanIdentical(d,-1),j=new RawTextCursor(this),_e=new RawTextCursor(d);for(let et=b,tt=b;;){if(j.next(et),_e.next(et),et=0,j.lineBreak!=_e.lineBreak||j.done!=_e.done||j.value!=_e.value)return!1;if(tt+=j.value.length,j.done||tt>=$)return!0}}iter(d=1){return new RawTextCursor(this,d)}iterRange(d,b=this.length){return new PartialTextCursor(this,d,b)}iterLines(d,b){let $;if(d==null)$=this.iter();else{b==null&&(b=this.lines+1);let j=this.line(d).from;$=this.iterRange(j,Math.max(j,b==this.lines+1?this.length:b<=1?0:this.line(b-1).to))}return new LineCursor($)}toString(){return this.sliceString(0)}toJSON(){let d=[];return this.flatten(d),d}constructor(){}static of(d){if(d.length==0)throw new RangeError("A document must have at least one line");return d.length==1&&!d[0]?Text.empty:d.length<=32?new TextLeaf(d):TextNode$1.from(TextLeaf.split(d,[]))}}class TextLeaf extends Text{constructor(d,b=textLength(d)){super(),this.text=d,this.length=b}get lines(){return this.text.length}get children(){return null}lineInner(d,b,$,j){for(let _e=0;;_e++){let et=this.text[_e],tt=j+et.length;if((b?$:tt)>=d)return new Line(j,tt,$,et);j=tt+1,$++}}decompose(d,b,$,j){let _e=d<=0&&b>=this.length?this:new TextLeaf(sliceText(this.text,d,b),Math.min(b,this.length)-Math.max(0,d));if(j&1){let et=$.pop(),tt=appendText(_e.text,et.text.slice(),0,_e.length);if(tt.length<=32)$.push(new TextLeaf(tt,et.length+_e.length));else{let nt=tt.length>>1;$.push(new TextLeaf(tt.slice(0,nt)),new TextLeaf(tt.slice(nt)))}}else $.push(_e)}replace(d,b,$){if(!($ instanceof TextLeaf))return super.replace(d,b,$);[d,b]=clip(this,d,b);let j=appendText(this.text,appendText($.text,sliceText(this.text,0,d)),b),_e=this.length+$.length-(b-d);return j.length<=32?new TextLeaf(j,_e):TextNode$1.from(TextLeaf.split(j,[]),_e)}sliceString(d,b=this.length,$=` +`){[d,b]=clip(this,d,b);let j="";for(let _e=0,et=0;_e<=b&&etd&&et&&(j+=$),d_e&&(j+=tt.slice(Math.max(0,d-_e),b-_e)),_e=nt+1}return j}flatten(d){for(let b of this.text)d.push(b)}scanIdentical(){return 0}static split(d,b){let $=[],j=-1;for(let _e of d)$.push(_e),j+=_e.length+1,$.length==32&&(b.push(new TextLeaf($,j)),$=[],j=-1);return j>-1&&b.push(new TextLeaf($,j)),b}}let TextNode$1=class Kn extends Text{constructor(d,b){super(),this.children=d,this.length=b,this.lines=0;for(let $ of d)this.lines+=$.lines}lineInner(d,b,$,j){for(let _e=0;;_e++){let et=this.children[_e],tt=j+et.length,nt=$+et.lines-1;if((b?nt:tt)>=d)return et.lineInner(d,b,$,j);j=tt+1,$=nt+1}}decompose(d,b,$,j){for(let _e=0,et=0;et<=b&&_e=et){let rt=j&((et<=d?1:0)|(nt>=b?2:0));et>=d&&nt<=b&&!rt?$.push(tt):tt.decompose(d-et,b-et,$,rt)}et=nt+1}}replace(d,b,$){if([d,b]=clip(this,d,b),$.lines=_e&&b<=tt){let nt=et.replace(d-_e,b-_e,$),rt=this.lines-et.lines+nt.lines;if(nt.lines>5-1&&nt.lines>rt>>5+1){let it=this.children.slice();return it[j]=nt,new Kn(it,this.length-(b-d)+$.length)}return super.replace(_e,tt,nt)}_e=tt+1}return super.replace(d,b,$)}sliceString(d,b=this.length,$=` +`){[d,b]=clip(this,d,b);let j="";for(let _e=0,et=0;_ed&&_e&&(j+=$),det&&(j+=tt.sliceString(d-et,b-et,$)),et=nt+1}return j}flatten(d){for(let b of this.children)b.flatten(d)}scanIdentical(d,b){if(!(d instanceof Kn))return 0;let $=0,[j,_e,et,tt]=b>0?[0,0,this.children.length,d.children.length]:[this.children.length-1,d.children.length-1,-1,-1];for(;;j+=b,_e+=b){if(j==et||_e==tt)return $;let nt=this.children[j],rt=d.children[_e];if(nt!=rt)return $+nt.scanIdentical(rt,b);$+=nt.length+1}}static from(d,b=d.reduce(($,j)=>$+j.length+1,-1)){let $=0;for(let at of d)$+=at.lines;if($<32){let at=[];for(let ut of d)ut.flatten(at);return new TextLeaf(at,b)}let j=Math.max(32,$>>5),_e=j<<1,et=j>>1,tt=[],nt=0,rt=-1,it=[];function st(at){let ut;if(at.lines>_e&&at instanceof Kn)for(let ct of at.children)st(ct);else at.lines>et&&(nt>et||!nt)?(ot(),tt.push(at)):at instanceof TextLeaf&&nt&&(ut=it[it.length-1])instanceof TextLeaf&&at.lines+ut.lines<=32?(nt+=at.lines,rt+=at.length+1,it[it.length-1]=new TextLeaf(ut.text.concat(at.text),ut.length+1+at.length)):(nt+at.lines>j&&ot(),nt+=at.lines,rt+=at.length+1,it.push(at))}function ot(){nt!=0&&(tt.push(it.length==1?it[0]:Kn.from(it,rt)),rt=-1,nt=it.length=0)}for(let at of d)st(at);return ot(),tt.length==1?tt[0]:new Kn(tt,b)}};Text.empty=new TextLeaf([""],0);function textLength(g){let d=-1;for(let b of g)d+=b.length+1;return d}function appendText(g,d,b=0,$=1e9){for(let j=0,_e=0,et=!0;_e=b&&(nt>$&&(tt=tt.slice(0,$-j)),j0?1:(d instanceof TextLeaf?d.text.length:d.children.length)<<1]}nextInner(d,b){for(this.done=this.lineBreak=!1;;){let $=this.nodes.length-1,j=this.nodes[$],_e=this.offsets[$],et=_e>>1,tt=j instanceof TextLeaf?j.text.length:j.children.length;if(et==(b>0?tt:0)){if($==0)return this.done=!0,this.value="",this;b>0&&this.offsets[$-1]++,this.nodes.pop(),this.offsets.pop()}else if((_e&1)==(b>0?0:1)){if(this.offsets[$]+=b,d==0)return this.lineBreak=!0,this.value=` +`,this;d--}else if(j instanceof TextLeaf){let nt=j.text[et+(b<0?-1:0)];if(this.offsets[$]+=b,nt.length>Math.max(0,d))return this.value=d==0?nt:b>0?nt.slice(d):nt.slice(0,nt.length-d),this;d-=nt.length}else{let nt=j.children[et+(b<0?-1:0)];d>nt.length?(d-=nt.length,this.offsets[$]+=b):(b<0&&this.offsets[$]--,this.nodes.push(nt),this.offsets.push(b>0?1:(nt instanceof TextLeaf?nt.text.length:nt.children.length)<<1))}}}next(d=0){return d<0&&(this.nextInner(-d,-this.dir),d=this.value.length),this.nextInner(d,this.dir)}}class PartialTextCursor{constructor(d,b,$){this.value="",this.done=!1,this.cursor=new RawTextCursor(d,b>$?-1:1),this.pos=b>$?d.length:0,this.from=Math.min(b,$),this.to=Math.max(b,$)}nextInner(d,b){if(b<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;d+=Math.max(0,b<0?this.pos-this.to:this.from-this.pos);let $=b<0?this.pos-this.from:this.to-this.pos;d>$&&(d=$),$-=d;let{value:j}=this.cursor.next(d);return this.pos+=(j.length+d)*b,this.value=j.length<=$?j:b<0?j.slice(j.length-$):j.slice(0,$),this.done=!this.value,this}next(d=0){return d<0?d=Math.max(d,this.from-this.pos):d>0&&(d=Math.min(d,this.to-this.pos)),this.nextInner(d,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class LineCursor{constructor(d){this.inner=d,this.afterBreak=!0,this.value="",this.done=!1}next(d=0){let{done:b,lineBreak:$,value:j}=this.inner.next(d);return b&&this.afterBreak?(this.value="",this.afterBreak=!1):b?(this.done=!0,this.value=""):$?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=j,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(Text.prototype[Symbol.iterator]=function(){return this.iter()},RawTextCursor.prototype[Symbol.iterator]=PartialTextCursor.prototype[Symbol.iterator]=LineCursor.prototype[Symbol.iterator]=function(){return this});class Line{constructor(d,b,$,j){this.from=d,this.to=b,this.number=$,this.text=j}get length(){return this.to-this.from}}function clip(g,d,b){return d=Math.max(0,Math.min(g.length,d)),[d,Math.max(d,Math.min(g.length,b))]}let extend$1="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(g=>g?parseInt(g,36):1);for(let g=1;gg)return extend$1[d-1]<=g;return!1}function isRegionalIndicator(g){return g>=127462&&g<=127487}const ZWJ=8205;function findClusterBreak(g,d,b=!0,$=!0){return(b?nextClusterBreak:prevClusterBreak)(g,d,$)}function nextClusterBreak(g,d,b){if(d==g.length)return d;d&&surrogateLow(g.charCodeAt(d))&&surrogateHigh(g.charCodeAt(d-1))&&d--;let $=codePointAt(g,d);for(d+=codePointSize($);d=0&&isRegionalIndicator(codePointAt(g,et));)_e++,et-=2;if(_e%2==0)break;d+=2}else break}return d}function prevClusterBreak(g,d,b){for(;d>0;){let $=nextClusterBreak(g,d-2,b);if($=56320&&g<57344}function surrogateHigh(g){return g>=55296&&g<56320}function codePointAt(g,d){let b=g.charCodeAt(d);if(!surrogateHigh(b)||d+1==g.length)return b;let $=g.charCodeAt(d+1);return surrogateLow($)?(b-55296<<10)+($-56320)+65536:b}function fromCodePoint(g){return g<=65535?String.fromCharCode(g):(g-=65536,String.fromCharCode((g>>10)+55296,(g&1023)+56320))}function codePointSize(g){return g<65536?1:2}const DefaultSplit=/\r\n?|\n/;var MapMode=function(g){return g[g.Simple=0]="Simple",g[g.TrackDel=1]="TrackDel",g[g.TrackBefore=2]="TrackBefore",g[g.TrackAfter=3]="TrackAfter",g}(MapMode||(MapMode={}));class ChangeDesc{constructor(d){this.sections=d}get length(){let d=0;for(let b=0;bd)return _e+(d-j);_e+=tt}else{if($!=MapMode.Simple&&rt>=d&&($==MapMode.TrackDel&&jd||$==MapMode.TrackBefore&&jd))return null;if(rt>d||rt==d&&b<0&&!tt)return d==j||b<0?_e:_e+nt;_e+=nt}j=rt}if(d>j)throw new RangeError(`Position ${d} is out of range for changeset of length ${j}`);return _e}touchesRange(d,b=d){for(let $=0,j=0;$=0&&j<=b&&tt>=d)return jb?"cover":!0;j=tt}return!1}toString(){let d="";for(let b=0;b=0?":"+j:"")}return d}toJSON(){return this.sections}static fromJSON(d){if(!Array.isArray(d)||d.length%2||d.some(b=>typeof b!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new ChangeDesc(d)}static create(d){return new ChangeDesc(d)}}class ChangeSet extends ChangeDesc{constructor(d,b){super(d),this.inserted=b}apply(d){if(this.length!=d.length)throw new RangeError("Applying change set to a document with the wrong length");return iterChanges(this,(b,$,j,_e,et)=>d=d.replace(j,j+($-b),et),!1),d}mapDesc(d,b=!1){return mapSet(this,d,b,!0)}invert(d){let b=this.sections.slice(),$=[];for(let j=0,_e=0;j=0){b[j]=tt,b[j+1]=et;let nt=j>>1;for(;$.length0&&addInsert($,b,_e.text),_e.forward(it),tt+=it}let rt=d[et++];for(;tt>1].toJSON()))}return d}static of(d,b,$){let j=[],_e=[],et=0,tt=null;function nt(it=!1){if(!it&&!j.length)return;etot||st<0||ot>b)throw new RangeError(`Invalid change range ${st} to ${ot} (in doc of length ${b})`);let ut=at?typeof at=="string"?Text.of(at.split($||DefaultSplit)):at:Text.empty,ct=ut.length;if(st==ot&&ct==0)return;stet&&addSection(j,st-et,-1),addSection(j,ot-st,ct),addInsert(_e,j,ut),et=ot}}return rt(d),nt(!tt),tt}static empty(d){return new ChangeSet(d?[d,-1]:[],[])}static fromJSON(d){if(!Array.isArray(d))throw new RangeError("Invalid JSON representation of ChangeSet");let b=[],$=[];for(let j=0;jtt&&typeof et!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(_e.length==1)b.push(_e[0],0);else{for(;$.length=0&&b<=0&&b==g[j+1]?g[j]+=d:d==0&&g[j]==0?g[j+1]+=b:$?(g[j]+=d,g[j+1]+=b):g.push(d,b)}function addInsert(g,d,b){if(b.length==0)return;let $=d.length-2>>1;if($>1])),!(b||et==g.sections.length||g.sections[et+1]<0);)tt=g.sections[et++],nt=g.sections[et++];d(j,rt,_e,it,st),j=rt,_e=it}}}function mapSet(g,d,b,$=!1){let j=[],_e=$?[]:null,et=new SectionIter(g),tt=new SectionIter(d);for(let nt=-1;;)if(et.ins==-1&&tt.ins==-1){let rt=Math.min(et.len,tt.len);addSection(j,rt,-1),et.forward(rt),tt.forward(rt)}else if(tt.ins>=0&&(et.ins<0||nt==et.i||et.off==0&&(tt.len=0&&nt=0){let rt=0,it=et.len;for(;it;)if(tt.ins==-1){let st=Math.min(it,tt.len);rt+=st,it-=st,tt.forward(st)}else if(tt.ins==0&&tt.lennt||et.ins>=0&&et.len>nt)&&(tt||$.length>rt),_e.forward2(nt),et.forward(nt)}}}}class SectionIter{constructor(d){this.set=d,this.i=0,this.next()}next(){let{sections:d}=this.set;this.i>1;return b>=d.length?Text.empty:d[b]}textBit(d){let{inserted:b}=this.set,$=this.i-2>>1;return $>=b.length&&!d?Text.empty:b[$].slice(this.off,d==null?void 0:this.off+d)}forward(d){d==this.len?this.next():(this.len-=d,this.off+=d)}forward2(d){this.ins==-1?this.forward(d):d==this.ins?this.next():(this.ins-=d,this.off+=d)}}class SelectionRange{constructor(d,b,$){this.from=d,this.to=b,this.flags=$}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let d=this.flags&7;return d==7?null:d}get goalColumn(){let d=this.flags>>6;return d==16777215?void 0:d}map(d,b=-1){let $,j;return this.empty?$=j=d.mapPos(this.from,b):($=d.mapPos(this.from,1),j=d.mapPos(this.to,-1)),$==this.from&&j==this.to?this:new SelectionRange($,j,this.flags)}extend(d,b=d){if(d<=this.anchor&&b>=this.anchor)return EditorSelection.range(d,b);let $=Math.abs(d-this.anchor)>Math.abs(b-this.anchor)?d:b;return EditorSelection.range(this.anchor,$)}eq(d,b=!1){return this.anchor==d.anchor&&this.head==d.head&&(!b||!this.empty||this.assoc==d.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(d){if(!d||typeof d.anchor!="number"||typeof d.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return EditorSelection.range(d.anchor,d.head)}static create(d,b,$){return new SelectionRange(d,b,$)}}class EditorSelection{constructor(d,b){this.ranges=d,this.mainIndex=b}map(d,b=-1){return d.empty?this:EditorSelection.create(this.ranges.map($=>$.map(d,b)),this.mainIndex)}eq(d,b=!1){if(this.ranges.length!=d.ranges.length||this.mainIndex!=d.mainIndex)return!1;for(let $=0;$d.toJSON()),main:this.mainIndex}}static fromJSON(d){if(!d||!Array.isArray(d.ranges)||typeof d.main!="number"||d.main>=d.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new EditorSelection(d.ranges.map(b=>SelectionRange.fromJSON(b)),d.main)}static single(d,b=d){return new EditorSelection([EditorSelection.range(d,b)],0)}static create(d,b=0){if(d.length==0)throw new RangeError("A selection needs at least one range");for(let $=0,j=0;jd?8:0)|_e)}static normalized(d,b=0){let $=d[b];d.sort((j,_e)=>j.from-_e.from),b=d.indexOf($);for(let j=1;j_e.head?EditorSelection.range(nt,tt):EditorSelection.range(tt,nt))}}return new EditorSelection(d,b)}}function checkSelection(g,d){for(let b of g.ranges)if(b.to>d)throw new RangeError("Selection points outside of document")}let nextID=0;class Facet{constructor(d,b,$,j,_e){this.combine=d,this.compareInput=b,this.compare=$,this.isStatic=j,this.id=nextID++,this.default=d([]),this.extensions=typeof _e=="function"?_e(this):_e}get reader(){return this}static define(d={}){return new Facet(d.combine||(b=>b),d.compareInput||((b,$)=>b===$),d.compare||(d.combine?(b,$)=>b===$:sameArray$1),!!d.static,d.enables)}of(d){return new FacetProvider([],this,0,d)}compute(d,b){if(this.isStatic)throw new Error("Can't compute a static facet");return new FacetProvider(d,this,1,b)}computeN(d,b){if(this.isStatic)throw new Error("Can't compute a static facet");return new FacetProvider(d,this,2,b)}from(d,b){return b||(b=$=>$),this.compute([d],$=>b($.field(d)))}}function sameArray$1(g,d){return g==d||g.length==d.length&&g.every((b,$)=>b===d[$])}class FacetProvider{constructor(d,b,$,j){this.dependencies=d,this.facet=b,this.type=$,this.value=j,this.id=nextID++}dynamicSlot(d){var b;let $=this.value,j=this.facet.compareInput,_e=this.id,et=d[_e]>>1,tt=this.type==2,nt=!1,rt=!1,it=[];for(let st of this.dependencies)st=="doc"?nt=!0:st=="selection"?rt=!0:((b=d[st.id])!==null&&b!==void 0?b:1)&1||it.push(d[st.id]);return{create(st){return st.values[et]=$(st),1},update(st,ot){if(nt&&ot.docChanged||rt&&(ot.docChanged||ot.selection)||ensureAll(st,it)){let at=$(st);if(tt?!compareArray(at,st.values[et],j):!j(at,st.values[et]))return st.values[et]=at,1}return 0},reconfigure:(st,ot)=>{let at,ut=ot.config.address[_e];if(ut!=null){let ct=getAddr(ot,ut);if(this.dependencies.every(dt=>dt instanceof Facet?ot.facet(dt)===st.facet(dt):dt instanceof StateField?ot.field(dt,!1)==st.field(dt,!1):!0)||(tt?compareArray(at=$(st),ct,j):j(at=$(st),ct)))return st.values[et]=ct,0}else at=$(st);return st.values[et]=at,1}}}}function compareArray(g,d,b){if(g.length!=d.length)return!1;for(let $=0;$g[nt.id]),j=b.map(nt=>nt.type),_e=$.filter(nt=>!(nt&1)),et=g[d.id]>>1;function tt(nt){let rt=[];for(let it=0;it<$.length;it++){let st=getAddr(nt,$[it]);if(j[it]==2)for(let ot of st)rt.push(ot);else rt.push(st)}return d.combine(rt)}return{create(nt){for(let rt of $)ensureAddr(nt,rt);return nt.values[et]=tt(nt),1},update(nt,rt){if(!ensureAll(nt,_e))return 0;let it=tt(nt);return d.compare(it,nt.values[et])?0:(nt.values[et]=it,1)},reconfigure(nt,rt){let it=ensureAll(nt,$),st=rt.config.facets[d.id],ot=rt.facet(d);if(st&&!it&&sameArray$1(b,st))return nt.values[et]=ot,0;let at=tt(nt);return d.compare(at,ot)?(nt.values[et]=ot,0):(nt.values[et]=at,1)}}}const initField=Facet.define({static:!0});class StateField{constructor(d,b,$,j,_e){this.id=d,this.createF=b,this.updateF=$,this.compareF=j,this.spec=_e,this.provides=void 0}static define(d){let b=new StateField(nextID++,d.create,d.update,d.compare||(($,j)=>$===j),d);return d.provide&&(b.provides=d.provide(b)),b}create(d){let b=d.facet(initField).find($=>$.field==this);return((b==null?void 0:b.create)||this.createF)(d)}slot(d){let b=d[this.id]>>1;return{create:$=>($.values[b]=this.create($),1),update:($,j)=>{let _e=$.values[b],et=this.updateF(_e,j);return this.compareF(_e,et)?0:($.values[b]=et,1)},reconfigure:($,j)=>j.config.address[this.id]!=null?($.values[b]=j.field(this),0):($.values[b]=this.create($),1)}}init(d){return[this,initField.of({field:this,create:d})]}get extension(){return this}}const Prec_={lowest:4,low:3,default:2,high:1,highest:0};function prec(g){return d=>new PrecExtension(d,g)}const Prec={highest:prec(Prec_.highest),high:prec(Prec_.high),default:prec(Prec_.default),low:prec(Prec_.low),lowest:prec(Prec_.lowest)};class PrecExtension{constructor(d,b){this.inner=d,this.prec=b}}class Compartment{of(d){return new CompartmentInstance(this,d)}reconfigure(d){return Compartment.reconfigure.of({compartment:this,extension:d})}get(d){return d.config.compartments.get(this)}}class CompartmentInstance{constructor(d,b){this.compartment=d,this.inner=b}}class Configuration{constructor(d,b,$,j,_e,et){for(this.base=d,this.compartments=b,this.dynamicSlots=$,this.address=j,this.staticValues=_e,this.facets=et,this.statusTemplate=[];this.statusTemplate.length<$.length;)this.statusTemplate.push(0)}staticFacet(d){let b=this.address[d.id];return b==null?d.default:this.staticValues[b>>1]}static resolve(d,b,$){let j=[],_e=Object.create(null),et=new Map;for(let ot of flatten$1(d,b,et))ot instanceof StateField?j.push(ot):(_e[ot.facet.id]||(_e[ot.facet.id]=[])).push(ot);let tt=Object.create(null),nt=[],rt=[];for(let ot of j)tt[ot.id]=rt.length<<1,rt.push(at=>ot.slot(at));let it=$==null?void 0:$.config.facets;for(let ot in _e){let at=_e[ot],ut=at[0].facet,ct=it&&it[ot]||[];if(at.every(dt=>dt.type==0))if(tt[ut.id]=nt.length<<1|1,sameArray$1(ct,at))nt.push($.facet(ut));else{let dt=ut.combine(at.map(ht=>ht.value));nt.push($&&ut.compare(dt,$.facet(ut))?$.facet(ut):dt)}else{for(let dt of at)dt.type==0?(tt[dt.id]=nt.length<<1|1,nt.push(dt.value)):(tt[dt.id]=rt.length<<1,rt.push(ht=>dt.dynamicSlot(ht)));tt[ut.id]=rt.length<<1,rt.push(dt=>dynamicFacetSlot(dt,ut,at))}}let st=rt.map(ot=>ot(tt));return new Configuration(d,et,st,tt,nt,_e)}}function flatten$1(g,d,b){let $=[[],[],[],[],[]],j=new Map;function _e(et,tt){let nt=j.get(et);if(nt!=null){if(nt<=tt)return;let rt=$[nt].indexOf(et);rt>-1&&$[nt].splice(rt,1),et instanceof CompartmentInstance&&b.delete(et.compartment)}if(j.set(et,tt),Array.isArray(et))for(let rt of et)_e(rt,tt);else if(et instanceof CompartmentInstance){if(b.has(et.compartment))throw new RangeError("Duplicate use of compartment in extensions");let rt=d.get(et.compartment)||et.inner;b.set(et.compartment,rt),_e(rt,tt)}else if(et instanceof PrecExtension)_e(et.inner,et.prec);else if(et instanceof StateField)$[tt].push(et),et.provides&&_e(et.provides,tt);else if(et instanceof FacetProvider)$[tt].push(et),et.facet.extensions&&_e(et.facet.extensions,Prec_.default);else{let rt=et.extension;if(!rt)throw new Error(`Unrecognized extension value in extension set (${et}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);_e(rt,tt)}}return _e(g,Prec_.default),$.reduce((et,tt)=>et.concat(tt))}function ensureAddr(g,d){if(d&1)return 2;let b=d>>1,$=g.status[b];if($==4)throw new Error("Cyclic dependency between fields and/or facets");if($&2)return $;g.status[b]=4;let j=g.computeSlot(g,g.config.dynamicSlots[b]);return g.status[b]=2|j}function getAddr(g,d){return d&1?g.config.staticValues[d>>1]:g.values[d>>1]}const languageData=Facet.define(),allowMultipleSelections=Facet.define({combine:g=>g.some(d=>d),static:!0}),lineSeparator=Facet.define({combine:g=>g.length?g[0]:void 0,static:!0}),changeFilter=Facet.define(),transactionFilter=Facet.define(),transactionExtender=Facet.define(),readOnly=Facet.define({combine:g=>g.length?g[0]:!1});class Annotation{constructor(d,b){this.type=d,this.value=b}static define(){return new AnnotationType}}class AnnotationType{of(d){return new Annotation(this,d)}}class StateEffectType{constructor(d){this.map=d}of(d){return new StateEffect(this,d)}}class StateEffect{constructor(d,b){this.type=d,this.value=b}map(d){let b=this.type.map(this.value,d);return b===void 0?void 0:b==this.value?this:new StateEffect(this.type,b)}is(d){return this.type==d}static define(d={}){return new StateEffectType(d.map||(b=>b))}static mapEffects(d,b){if(!d.length)return d;let $=[];for(let j of d){let _e=j.map(b);_e&&$.push(_e)}return $}}StateEffect.reconfigure=StateEffect.define();StateEffect.appendConfig=StateEffect.define();class Transaction{constructor(d,b,$,j,_e,et){this.startState=d,this.changes=b,this.selection=$,this.effects=j,this.annotations=_e,this.scrollIntoView=et,this._doc=null,this._state=null,$&&checkSelection($,b.newLength),_e.some(tt=>tt.type==Transaction.time)||(this.annotations=_e.concat(Transaction.time.of(Date.now())))}static create(d,b,$,j,_e,et){return new Transaction(d,b,$,j,_e,et)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(d){for(let b of this.annotations)if(b.type==d)return b.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(d){let b=this.annotation(Transaction.userEvent);return!!(b&&(b==d||b.length>d.length&&b.slice(0,d.length)==d&&b[d.length]=="."))}}Transaction.time=Annotation.define();Transaction.userEvent=Annotation.define();Transaction.addToHistory=Annotation.define();Transaction.remote=Annotation.define();function joinRanges(g,d){let b=[];for(let $=0,j=0;;){let _e,et;if($=g[$]))_e=g[$++],et=g[$++];else if(j=0;j--){let _e=$[j](g);_e instanceof Transaction?g=_e:Array.isArray(_e)&&_e.length==1&&_e[0]instanceof Transaction?g=_e[0]:g=resolveTransaction(d,asArray$1(_e),!1)}return g}function extendTransaction(g){let d=g.startState,b=d.facet(transactionExtender),$=g;for(let j=b.length-1;j>=0;j--){let _e=b[j](g);_e&&Object.keys(_e).length&&($=mergeTransaction($,resolveTransactionInner(d,_e,g.changes.newLength),!0))}return $==g?g:Transaction.create(d,g.changes,g.selection,$.effects,$.annotations,$.scrollIntoView)}const none$3=[];function asArray$1(g){return g==null?none$3:Array.isArray(g)?g:[g]}var CharCategory=function(g){return g[g.Word=0]="Word",g[g.Space=1]="Space",g[g.Other=2]="Other",g}(CharCategory||(CharCategory={}));const nonASCIISingleCaseWordChar=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let wordChar;try{wordChar=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function hasWordChar(g){if(wordChar)return wordChar.test(g);for(let d=0;d"€"&&(b.toUpperCase()!=b.toLowerCase()||nonASCIISingleCaseWordChar.test(b)))return!0}return!1}function makeCategorizer(g){return d=>{if(!/\S/.test(d))return CharCategory.Space;if(hasWordChar(d))return CharCategory.Word;for(let b=0;b-1)return CharCategory.Word;return CharCategory.Other}}class EditorState{constructor(d,b,$,j,_e,et){this.config=d,this.doc=b,this.selection=$,this.values=j,this.status=d.statusTemplate.slice(),this.computeSlot=_e,et&&(et._state=this);for(let tt=0;ttj.set(rt,nt)),b=null),j.set(tt.value.compartment,tt.value.extension)):tt.is(StateEffect.reconfigure)?(b=null,$=tt.value):tt.is(StateEffect.appendConfig)&&(b=null,$=asArray$1($).concat(tt.value));let _e;b?_e=d.startState.values.slice():(b=Configuration.resolve($,j,this),_e=new EditorState(b,this.doc,this.selection,b.dynamicSlots.map(()=>null),(nt,rt)=>rt.reconfigure(nt,this),null).values);let et=d.startState.facet(allowMultipleSelections)?d.newSelection:d.newSelection.asSingle();new EditorState(b,d.newDoc,et,_e,(tt,nt)=>nt.update(tt,d),d)}replaceSelection(d){return typeof d=="string"&&(d=this.toText(d)),this.changeByRange(b=>({changes:{from:b.from,to:b.to,insert:d},range:EditorSelection.cursor(b.from+d.length)}))}changeByRange(d){let b=this.selection,$=d(b.ranges[0]),j=this.changes($.changes),_e=[$.range],et=asArray$1($.effects);for(let tt=1;ttet.spec.fromJSON(tt,nt)))}}return EditorState.create({doc:d.doc,selection:EditorSelection.fromJSON(d.selection),extensions:b.extensions?j.concat([b.extensions]):j})}static create(d={}){let b=Configuration.resolve(d.extensions||[],new Map),$=d.doc instanceof Text?d.doc:Text.of((d.doc||"").split(b.staticFacet(EditorState.lineSeparator)||DefaultSplit)),j=d.selection?d.selection instanceof EditorSelection?d.selection:EditorSelection.single(d.selection.anchor,d.selection.head):EditorSelection.single(0);return checkSelection(j,$.length),b.staticFacet(allowMultipleSelections)||(j=j.asSingle()),new EditorState(b,$,j,b.dynamicSlots.map(()=>null),(_e,et)=>et.create(_e),null)}get tabSize(){return this.facet(EditorState.tabSize)}get lineBreak(){return this.facet(EditorState.lineSeparator)||` +`}get readOnly(){return this.facet(readOnly)}phrase(d,...b){for(let $ of this.facet(EditorState.phrases))if(Object.prototype.hasOwnProperty.call($,d)){d=$[d];break}return b.length&&(d=d.replace(/\$(\$|\d*)/g,($,j)=>{if(j=="$")return"$";let _e=+(j||1);return!_e||_e>b.length?$:b[_e-1]})),d}languageDataAt(d,b,$=-1){let j=[];for(let _e of this.facet(languageData))for(let et of _e(this,b,$))Object.prototype.hasOwnProperty.call(et,d)&&j.push(et[d]);return j}charCategorizer(d){return makeCategorizer(this.languageDataAt("wordChars",d).join(""))}wordAt(d){let{text:b,from:$,length:j}=this.doc.lineAt(d),_e=this.charCategorizer(d),et=d-$,tt=d-$;for(;et>0;){let nt=findClusterBreak(b,et,!1);if(_e(b.slice(nt,et))!=CharCategory.Word)break;et=nt}for(;ttg.length?g[0]:4});EditorState.lineSeparator=lineSeparator;EditorState.readOnly=readOnly;EditorState.phrases=Facet.define({compare(g,d){let b=Object.keys(g),$=Object.keys(d);return b.length==$.length&&b.every(j=>g[j]==d[j])}});EditorState.languageData=languageData;EditorState.changeFilter=changeFilter;EditorState.transactionFilter=transactionFilter;EditorState.transactionExtender=transactionExtender;Compartment.reconfigure=StateEffect.define();function combineConfig(g,d,b={}){let $={};for(let j of g)for(let _e of Object.keys(j)){let et=j[_e],tt=$[_e];if(tt===void 0)$[_e]=et;else if(!(tt===et||et===void 0))if(Object.hasOwnProperty.call(b,_e))$[_e]=b[_e](tt,et);else throw new Error("Config merge conflict for field "+_e)}for(let j in d)$[j]===void 0&&($[j]=d[j]);return $}class RangeValue{eq(d){return this==d}range(d,b=d){return Range$1.create(d,b,this)}}RangeValue.prototype.startSide=RangeValue.prototype.endSide=0;RangeValue.prototype.point=!1;RangeValue.prototype.mapMode=MapMode.TrackDel;let Range$1=class Zr{constructor(d,b,$){this.from=d,this.to=b,this.value=$}static create(d,b,$){return new Zr(d,b,$)}};function cmpRange(g,d){return g.from-d.from||g.value.startSide-d.value.startSide}class Chunk{constructor(d,b,$,j){this.from=d,this.to=b,this.value=$,this.maxPoint=j}get length(){return this.to[this.to.length-1]}findIndex(d,b,$,j=0){let _e=$?this.to:this.from;for(let et=j,tt=_e.length;;){if(et==tt)return et;let nt=et+tt>>1,rt=_e[nt]-d||($?this.value[nt].endSide:this.value[nt].startSide)-b;if(nt==et)return rt>=0?et:tt;rt>=0?tt=nt:et=nt+1}}between(d,b,$,j){for(let _e=this.findIndex(b,-1e9,!0),et=this.findIndex($,1e9,!1,_e);_eat||ot==at&&rt.startSide>0&&rt.endSide<=0)continue;(at-ot||rt.endSide-rt.startSide)<0||(et<0&&(et=ot),rt.point&&(tt=Math.max(tt,at-ot)),$.push(rt),j.push(ot-et),_e.push(at-et))}return{mapped:$.length?new Chunk(j,_e,$,tt):null,pos:et}}}class RangeSet{constructor(d,b,$,j){this.chunkPos=d,this.chunk=b,this.nextLayer=$,this.maxPoint=j}static create(d,b,$,j){return new RangeSet(d,b,$,j)}get length(){let d=this.chunk.length-1;return d<0?0:Math.max(this.chunkEnd(d),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let d=this.nextLayer.size;for(let b of this.chunk)d+=b.value.length;return d}chunkEnd(d){return this.chunkPos[d]+this.chunk[d].length}update(d){let{add:b=[],sort:$=!1,filterFrom:j=0,filterTo:_e=this.length}=d,et=d.filter;if(b.length==0&&!et)return this;if($&&(b=b.slice().sort(cmpRange)),this.isEmpty)return b.length?RangeSet.of(b):this;let tt=new LayerCursor(this,null,-1).goto(0),nt=0,rt=[],it=new RangeSetBuilder;for(;tt.value||nt=0){let st=b[nt++];it.addInner(st.from,st.to,st.value)||rt.push(st)}else tt.rangeIndex==1&&tt.chunkIndexthis.chunkEnd(tt.chunkIndex)||_ett.to||_e=_e&&d<=_e+et.length&&et.between(_e,d-_e,b-_e,$)===!1)return}this.nextLayer.between(d,b,$)}}iter(d=0){return HeapCursor.from([this]).goto(d)}get isEmpty(){return this.nextLayer==this}static iter(d,b=0){return HeapCursor.from(d).goto(b)}static compare(d,b,$,j,_e=-1){let et=d.filter(st=>st.maxPoint>0||!st.isEmpty&&st.maxPoint>=_e),tt=b.filter(st=>st.maxPoint>0||!st.isEmpty&&st.maxPoint>=_e),nt=findSharedChunks(et,tt,$),rt=new SpanCursor(et,nt,_e),it=new SpanCursor(tt,nt,_e);$.iterGaps((st,ot,at)=>compare(rt,st,it,ot,at,j)),$.empty&&$.length==0&&compare(rt,0,it,0,0,j)}static eq(d,b,$=0,j){j==null&&(j=1e9-1);let _e=d.filter(it=>!it.isEmpty&&b.indexOf(it)<0),et=b.filter(it=>!it.isEmpty&&d.indexOf(it)<0);if(_e.length!=et.length)return!1;if(!_e.length)return!0;let tt=findSharedChunks(_e,et),nt=new SpanCursor(_e,tt,0).goto($),rt=new SpanCursor(et,tt,0).goto($);for(;;){if(nt.to!=rt.to||!sameValues(nt.active,rt.active)||nt.point&&(!rt.point||!nt.point.eq(rt.point)))return!1;if(nt.to>j)return!0;nt.next(),rt.next()}}static spans(d,b,$,j,_e=-1){let et=new SpanCursor(d,null,_e).goto(b),tt=b,nt=et.openStart;for(;;){let rt=Math.min(et.to,$);if(et.point){let it=et.activeForPoint(et.to),st=et.pointFromtt&&(j.span(tt,rt,et.active,nt),nt=et.openEnd(rt));if(et.to>$)return nt+(et.point&&et.to>$?1:0);tt=et.to,et.next()}}static of(d,b=!1){let $=new RangeSetBuilder;for(let j of d instanceof Range$1?[d]:b?lazySort(d):d)$.add(j.from,j.to,j.value);return $.finish()}static join(d){if(!d.length)return RangeSet.empty;let b=d[d.length-1];for(let $=d.length-2;$>=0;$--)for(let j=d[$];j!=RangeSet.empty;j=j.nextLayer)b=new RangeSet(j.chunkPos,j.chunk,b,Math.max(j.maxPoint,b.maxPoint));return b}}RangeSet.empty=new RangeSet([],[],null,-1);function lazySort(g){if(g.length>1)for(let d=g[0],b=1;b0)return g.slice().sort(cmpRange);d=$}return g}RangeSet.empty.nextLayer=RangeSet.empty;class RangeSetBuilder{finishChunk(d){this.chunks.push(new Chunk(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,d&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(d,b,$){this.addInner(d,b,$)||(this.nextLayer||(this.nextLayer=new RangeSetBuilder)).add(d,b,$)}addInner(d,b,$){let j=d-this.lastTo||$.startSide-this.last.endSide;if(j<=0&&(d-this.lastFrom||$.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return j<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=d),this.from.push(d-this.chunkStart),this.to.push(b-this.chunkStart),this.last=$,this.lastFrom=d,this.lastTo=b,this.value.push($),$.point&&(this.maxPoint=Math.max(this.maxPoint,b-d)),!0)}addChunk(d,b){if((d-this.lastTo||b.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,b.maxPoint),this.chunks.push(b),this.chunkPos.push(d);let $=b.value.length-1;return this.last=b.value[$],this.lastFrom=b.from[$]+d,this.lastTo=b.to[$]+d,!0}finish(){return this.finishInner(RangeSet.empty)}finishInner(d){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return d;let b=RangeSet.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(d):d,this.setMaxPoint);return this.from=null,b}}function findSharedChunks(g,d,b){let $=new Map;for(let _e of g)for(let et=0;et<_e.chunk.length;et++)_e.chunk[et].maxPoint<=0&&$.set(_e.chunk[et],_e.chunkPos[et]);let j=new Set;for(let _e of d)for(let et=0;et<_e.chunk.length;et++){let tt=$.get(_e.chunk[et]);tt!=null&&(b?b.mapPos(tt):tt)==_e.chunkPos[et]&&!(b!=null&&b.touchesRange(tt,tt+_e.chunk[et].length))&&j.add(_e.chunk[et])}return j}class LayerCursor{constructor(d,b,$,j=0){this.layer=d,this.skip=b,this.minPoint=$,this.rank=j}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(d,b=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(d,b,!1),this}gotoInner(d,b,$){for(;this.chunkIndex=this.minPoint)break}}setRangeIndex(d){if(d==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=$&&j.push(new LayerCursor(et,b,$,_e));return j.length==1?j[0]:new HeapCursor(j)}get startSide(){return this.value?this.value.startSide:0}goto(d,b=-1e9){for(let $ of this.heap)$.goto(d,b);for(let $=this.heap.length>>1;$>=0;$--)heapBubble(this.heap,$);return this.next(),this}forward(d,b){for(let $ of this.heap)$.forward(d,b);for(let $=this.heap.length>>1;$>=0;$--)heapBubble(this.heap,$);(this.to-d||this.value.endSide-b)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let d=this.heap[0];this.from=d.from,this.to=d.to,this.value=d.value,this.rank=d.rank,d.value&&d.next(),heapBubble(this.heap,0)}}}function heapBubble(g,d){for(let b=g[d];;){let $=(d<<1)+1;if($>=g.length)break;let j=g[$];if($+1=0&&(j=g[$+1],$++),b.compare(j)<0)break;g[$]=b,g[d]=j,d=$}}class SpanCursor{constructor(d,b,$){this.minPoint=$,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=HeapCursor.from(d,b,$)}goto(d,b=-1e9){return this.cursor.goto(d,b),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=d,this.endSide=b,this.openStart=-1,this.next(),this}forward(d,b){for(;this.minActive>-1&&(this.activeTo[this.minActive]-d||this.active[this.minActive].endSide-b)<0;)this.removeActive(this.minActive);this.cursor.forward(d,b)}removeActive(d){remove$1(this.active,d),remove$1(this.activeTo,d),remove$1(this.activeRank,d),this.minActive=findMinIndex(this.active,this.activeTo)}addActive(d){let b=0,{value:$,to:j,rank:_e}=this.cursor;for(;b0;)b++;insert(this.active,b,$),insert(this.activeTo,b,j),insert(this.activeRank,b,_e),d&&insert(d,b,this.cursor.from),this.minActive=findMinIndex(this.active,this.activeTo)}next(){let d=this.to,b=this.point;this.point=null;let $=this.openStart<0?[]:null;for(;;){let j=this.minActive;if(j>-1&&(this.activeTo[j]-this.cursor.from||this.active[j].endSide-this.cursor.startSide)<0){if(this.activeTo[j]>d){this.to=this.activeTo[j],this.endSide=this.active[j].endSide;break}this.removeActive(j),$&&remove$1($,j)}else if(this.cursor.value)if(this.cursor.from>d){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let _e=this.cursor.value;if(!_e.point)this.addActive($),this.cursor.next();else if(b&&this.cursor.to==this.to&&this.cursor.from=0&&$[j]=0&&!(this.activeRank[$]d||this.activeTo[$]==d&&this.active[$].endSide>=this.point.endSide)&&b.push(this.active[$]);return b.reverse()}openEnd(d){let b=0;for(let $=this.activeTo.length-1;$>=0&&this.activeTo[$]>d;$--)b++;return b}}function compare(g,d,b,$,j,_e){g.goto(d),b.goto($);let et=$+j,tt=$,nt=$-d;for(;;){let rt=g.to+nt-b.to||g.endSide-b.endSide,it=rt<0?g.to+nt:b.to,st=Math.min(it,et);if(g.point||b.point?g.point&&b.point&&(g.point==b.point||g.point.eq(b.point))&&sameValues(g.activeForPoint(g.to),b.activeForPoint(b.to))||_e.comparePoint(tt,st,g.point,b.point):st>tt&&!sameValues(g.active,b.active)&&_e.compareRange(tt,st,g.active,b.active),it>et)break;tt=it,rt<=0&&g.next(),rt>=0&&b.next()}}function sameValues(g,d){if(g.length!=d.length)return!1;for(let b=0;b=d;$--)g[$+1]=g[$];g[d]=b}function findMinIndex(g,d){let b=-1,$=1e9;for(let j=0;j=d)return j;if(j==g.length)break;_e+=g.charCodeAt(j)==9?b-_e%b:1,j=findClusterBreak(g,j)}return $===!0?-1:g.length}const C="ͼ",COUNT=typeof Symbol>"u"?"__"+C:Symbol.for(C),SET=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),top=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class StyleModule{constructor(d,b){this.rules=[];let{finish:$}=b||{};function j(et){return/^@/.test(et)?[et]:et.split(/,\s*/)}function _e(et,tt,nt,rt){let it=[],st=/^@(\w+)\b/.exec(et[0]),ot=st&&st[1]=="keyframes";if(st&&tt==null)return nt.push(et[0]+";");for(let at in tt){let ut=tt[at];if(/&/.test(at))_e(at.split(/,\s*/).map(ct=>et.map(dt=>ct.replace(/&/,dt))).reduce((ct,dt)=>ct.concat(dt)),ut,nt);else if(ut&&typeof ut=="object"){if(!st)throw new RangeError("The value of a property ("+at+") should be a primitive value.");_e(j(at),ut,it,ot)}else ut!=null&&it.push(at.replace(/_.*/,"").replace(/[A-Z]/g,ct=>"-"+ct.toLowerCase())+": "+ut+";")}(it.length||ot)&&nt.push(($&&!st&&!rt?et.map($):et).join(", ")+" {"+it.join(" ")+"}")}for(let et in d)_e(j(et),d[et],this.rules)}getRules(){return this.rules.join(` +`)}static newName(){let d=top[COUNT]||1;return top[COUNT]=d+1,C+d.toString(36)}static mount(d,b,$){let j=d[SET],_e=$&&$.nonce;j?_e&&j.setNonce(_e):j=new StyleSet(d,_e),j.mount(Array.isArray(b)?b:[b])}}let adoptedSet=new Map;class StyleSet{constructor(d,b){let $=d.ownerDocument||d,j=$.defaultView;if(!d.head&&d.adoptedStyleSheets&&j.CSSStyleSheet){let _e=adoptedSet.get($);if(_e)return d.adoptedStyleSheets=[_e.sheet,...d.adoptedStyleSheets],d[SET]=_e;this.sheet=new j.CSSStyleSheet,d.adoptedStyleSheets=[this.sheet,...d.adoptedStyleSheets],adoptedSet.set($,this)}else{this.styleTag=$.createElement("style"),b&&this.styleTag.setAttribute("nonce",b);let _e=d.head||d;_e.insertBefore(this.styleTag,_e.firstChild)}this.modules=[],d[SET]=this}mount(d){let b=this.sheet,$=0,j=0;for(let _e=0;_e-1&&(this.modules.splice(tt,1),j--,tt=-1),tt==-1){if(this.modules.splice(j++,0,et),b)for(let nt=0;nt",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},mac=typeof navigator<"u"&&/Mac/.test(navigator.platform),ie$1=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var i$2=0;i$2<10;i$2++)base[48+i$2]=base[96+i$2]=String(i$2);for(var i$2=1;i$2<=24;i$2++)base[i$2+111]="F"+i$2;for(var i$2=65;i$2<=90;i$2++)base[i$2]=String.fromCharCode(i$2+32),shift[i$2]=String.fromCharCode(i$2);for(var code in base)shift.hasOwnProperty(code)||(shift[code]=base[code]);function keyName(g){var d=mac&&g.metaKey&&g.shiftKey&&!g.ctrlKey&&!g.altKey||ie$1&&g.shiftKey&&g.key&&g.key.length==1||g.key=="Unidentified",b=!d&&g.key||(g.shiftKey?shift:base)[g.keyCode]||g.key||"Unidentified";return b=="Esc"&&(b="Escape"),b=="Del"&&(b="Delete"),b=="Left"&&(b="ArrowLeft"),b=="Up"&&(b="ArrowUp"),b=="Right"&&(b="ArrowRight"),b=="Down"&&(b="ArrowDown"),b}function getSelection(g){let d;return g.nodeType==11?d=g.getSelection?g:g.ownerDocument:d=g,d.getSelection()}function contains(g,d){return d?g==d||g.contains(d.nodeType!=1?d.parentNode:d):!1}function deepActiveElement(g){let d=g.activeElement;for(;d&&d.shadowRoot;)d=d.shadowRoot.activeElement;return d}function hasSelection(g,d){if(!d.anchorNode)return!1;try{return contains(g,d.anchorNode)}catch{return!1}}function clientRectsFor(g){return g.nodeType==3?textRange(g,0,g.nodeValue.length).getClientRects():g.nodeType==1?g.getClientRects():[]}function isEquivalentPosition(g,d,b,$){return b?scanFor(g,d,b,$,-1)||scanFor(g,d,b,$,1):!1}function domIndex(g){for(var d=0;;d++)if(g=g.previousSibling,!g)return d}function scanFor(g,d,b,$,j){for(;;){if(g==b&&d==$)return!0;if(d==(j<0?0:maxOffset(g))){if(g.nodeName=="DIV")return!1;let _e=g.parentNode;if(!_e||_e.nodeType!=1)return!1;d=domIndex(g)+(j<0?0:1),g=_e}else if(g.nodeType==1){if(g=g.childNodes[d+(j<0?-1:0)],g.nodeType==1&&g.contentEditable=="false")return!1;d=j<0?maxOffset(g):0}else return!1}}function maxOffset(g){return g.nodeType==3?g.nodeValue.length:g.childNodes.length}function flattenRect(g,d){let b=d?g.left:g.right;return{left:b,right:b,top:g.top,bottom:g.bottom}}function windowRect(g){return{left:0,right:g.innerWidth,top:0,bottom:g.innerHeight}}function getScale(g,d){let b=d.width/g.offsetWidth,$=d.height/g.offsetHeight;return(b>.995&&b<1.005||!isFinite(b)||Math.abs(d.width-g.offsetWidth)<1)&&(b=1),($>.995&&$<1.005||!isFinite($)||Math.abs(d.height-g.offsetHeight)<1)&&($=1),{scaleX:b,scaleY:$}}function scrollRectIntoView(g,d,b,$,j,_e,et,tt){let nt=g.ownerDocument,rt=nt.defaultView||window;for(let it=g,st=!1;it&&!st;)if(it.nodeType==1){let ot,at=it==nt.body,ut=1,ct=1;if(at)ot=windowRect(rt);else{if(/^(fixed|sticky)$/.test(getComputedStyle(it).position)&&(st=!0),it.scrollHeight<=it.clientHeight&&it.scrollWidth<=it.clientWidth){it=it.assignedSlot||it.parentNode;continue}let pt=it.getBoundingClientRect();({scaleX:ut,scaleY:ct}=getScale(it,pt)),ot={left:pt.left,right:pt.left+it.clientWidth*ut,top:pt.top,bottom:pt.top+it.clientHeight*ct}}let dt=0,ht=0;if(j=="nearest")d.top0&&d.bottom>ot.bottom+ht&&(ht=d.bottom-ot.bottom+ht+et)):d.bottom>ot.bottom&&(ht=d.bottom-ot.bottom+et,b<0&&d.top-ht0&&d.right>ot.right+dt&&(dt=d.right-ot.right+dt+_e)):d.right>ot.right&&(dt=d.right-ot.right+_e,b<0&&d.leftb.clientHeight||b.scrollWidth>b.clientWidth)return b;b=b.assignedSlot||b.parentNode}else if(b.nodeType==11)b=b.host;else break;return null}class DOMSelectionState{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(d){return this.anchorNode==d.anchorNode&&this.anchorOffset==d.anchorOffset&&this.focusNode==d.focusNode&&this.focusOffset==d.focusOffset}setRange(d){let{anchorNode:b,focusNode:$}=d;this.set(b,Math.min(d.anchorOffset,b?maxOffset(b):0),$,Math.min(d.focusOffset,$?maxOffset($):0))}set(d,b,$,j){this.anchorNode=d,this.anchorOffset=b,this.focusNode=$,this.focusOffset=j}}let preventScrollSupported=null;function focusPreventScroll(g){if(g.setActive)return g.setActive();if(preventScrollSupported)return g.focus(preventScrollSupported);let d=[];for(let b=g;b&&(d.push(b,b.scrollTop,b.scrollLeft),b!=b.ownerDocument);b=b.parentNode);if(g.focus(preventScrollSupported==null?{get preventScroll(){return preventScrollSupported={preventScroll:!0},!0}}:void 0),!preventScrollSupported){preventScrollSupported=!1;for(let b=0;bMath.max(1,g.scrollHeight-g.clientHeight-4)}class DOMPos{constructor(d,b,$=!0){this.node=d,this.offset=b,this.precise=$}static before(d,b){return new DOMPos(d.parentNode,domIndex(d),b)}static after(d,b){return new DOMPos(d.parentNode,domIndex(d)+1,b)}}const noChildren=[];class ContentView{constructor(){this.parent=null,this.dom=null,this.flags=2}get overrideDOMText(){return null}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(d){let b=this.posAtStart;for(let $ of this.children){if($==d)return b;b+=$.length+$.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(d){return this.posBefore(d)+d.length}sync(d,b){if(this.flags&2){let $=this.dom,j=null,_e;for(let et of this.children){if(et.flags&7){if(!et.dom&&(_e=j?j.nextSibling:$.firstChild)){let tt=ContentView.get(_e);(!tt||!tt.parent&&tt.canReuseDOM(et))&&et.reuseDOM(_e)}et.sync(d,b),et.flags&=-8}if(_e=j?j.nextSibling:$.firstChild,b&&!b.written&&b.node==$&&_e!=et.dom&&(b.written=!0),et.dom.parentNode==$)for(;_e&&_e!=et.dom;)_e=rm$1(_e);else $.insertBefore(et.dom,_e);j=et.dom}for(_e=j?j.nextSibling:$.firstChild,_e&&b&&b.node==$&&(b.written=!0);_e;)_e=rm$1(_e)}else if(this.flags&1)for(let $ of this.children)$.flags&7&&($.sync(d,b),$.flags&=-8)}reuseDOM(d){}localPosFromDOM(d,b){let $;if(d==this.dom)$=this.dom.childNodes[b];else{let j=maxOffset(d)==0?0:b==0?-1:1;for(;;){let _e=d.parentNode;if(_e==this.dom)break;j==0&&_e.firstChild!=_e.lastChild&&(d==_e.firstChild?j=-1:j=1),d=_e}j<0?$=d:$=d.nextSibling}if($==this.dom.firstChild)return 0;for(;$&&!ContentView.get($);)$=$.nextSibling;if(!$)return this.length;for(let j=0,_e=0;;j++){let et=this.children[j];if(et.dom==$)return _e;_e+=et.length+et.breakAfter}}domBoundsAround(d,b,$=0){let j=-1,_e=-1,et=-1,tt=-1;for(let nt=0,rt=$,it=$;ntb)return st.domBoundsAround(d,b,rt);if(ot>=d&&j==-1&&(j=nt,_e=rt),rt>b&&st.dom.parentNode==this.dom){et=nt,tt=it;break}it=ot,rt=ot+st.breakAfter}return{from:_e,to:tt<0?$+this.length:tt,startDOM:(j?this.children[j-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:et=0?this.children[et].dom:null}}markDirty(d=!1){this.flags|=2,this.markParentsDirty(d)}markParentsDirty(d){for(let b=this.parent;b;b=b.parent){if(d&&(b.flags|=2),b.flags&1)return;b.flags|=1,d=!1}}setParent(d){this.parent!=d&&(this.parent=d,this.flags&7&&this.markParentsDirty(!0))}setDOM(d){this.dom!=d&&(this.dom&&(this.dom.cmView=null),this.dom=d,d.cmView=this)}get rootView(){for(let d=this;;){let b=d.parent;if(!b)return d;d=b}}replaceChildren(d,b,$=noChildren){this.markDirty();for(let j=d;jthis.pos||d==this.pos&&(b>0||this.i==0||this.children[this.i-1].breakAfter))return this.off=d-this.pos,this;let $=this.children[--this.i];this.pos-=$.length+$.breakAfter}}}function replaceRange(g,d,b,$,j,_e,et,tt,nt){let{children:rt}=g,it=rt.length?rt[d]:null,st=_e.length?_e[_e.length-1]:null,ot=st?st.breakAfter:et;if(!(d==$&&it&&!et&&!ot&&_e.length<2&&it.merge(b,j,_e.length?st:null,b==0,tt,nt))){if($0&&(!et&&_e.length&&it.merge(b,it.length,_e[0],!1,tt,0)?it.breakAfter=_e.shift().breakAfter:(b2);var browser={mac:ios||/Mac/.test(nav.platform),windows:/Win/.test(nav.platform),linux:/Linux|X11/.test(nav.platform),ie,ie_version:ie_upto10?doc.documentMode||6:ie_11up?+ie_11up[1]:ie_edge?+ie_edge[1]:0,gecko,gecko_version:gecko?+(/Firefox\/(\d+)/.exec(nav.userAgent)||[0,0])[1]:0,chrome:!!chrome,chrome_version:chrome?+chrome[1]:0,ios,android:/Android\b/.test(nav.userAgent),webkit,safari,webkit_version:webkit?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:doc.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};const MaxJoinLen=256;class TextView extends ContentView{constructor(d){super(),this.text=d}get length(){return this.text.length}createDOM(d){this.setDOM(d||document.createTextNode(this.text))}sync(d,b){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(b&&b.node==this.dom&&(b.written=!0),this.dom.nodeValue=this.text)}reuseDOM(d){d.nodeType==3&&this.createDOM(d)}merge(d,b,$){return this.flags&8||$&&(!($ instanceof TextView)||this.length-(b-d)+$.length>MaxJoinLen||$.flags&8)?!1:(this.text=this.text.slice(0,d)+($?$.text:"")+this.text.slice(b),this.markDirty(),!0)}split(d){let b=new TextView(this.text.slice(d));return this.text=this.text.slice(0,d),this.markDirty(),b.flags|=this.flags&8,b}localPosFromDOM(d,b){return d==this.dom?b:b?this.text.length:0}domAtPos(d){return new DOMPos(this.dom,d)}domBoundsAround(d,b,$){return{from:$,to:$+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(d,b){return textCoords(this.dom,d,b)}}class MarkView extends ContentView{constructor(d,b=[],$=0){super(),this.mark=d,this.children=b,this.length=$;for(let j of b)j.setParent(this)}setAttrs(d){if(clearAttributes(d),this.mark.class&&(d.className=this.mark.class),this.mark.attrs)for(let b in this.mark.attrs)d.setAttribute(b,this.mark.attrs[b]);return d}canReuseDOM(d){return super.canReuseDOM(d)&&!((this.flags|d.flags)&8)}reuseDOM(d){d.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(d),this.flags|=6)}sync(d,b){this.dom?this.flags&4&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(d,b)}merge(d,b,$,j,_e,et){return $&&(!($ instanceof MarkView&&$.mark.eq(this.mark))||d&&_e<=0||bd&&b.push($=d&&(j=_e),$=nt,_e++}let et=this.length-d;return this.length=d,j>-1&&(this.children.length=j,this.markDirty()),new MarkView(this.mark,b,et)}domAtPos(d){return inlineDOMAtPos(this,d)}coordsAt(d,b){return coordsInChildren(this,d,b)}}function textCoords(g,d,b){let $=g.nodeValue.length;d>$&&(d=$);let j=d,_e=d,et=0;d==0&&b<0||d==$&&b>=0?browser.chrome||browser.gecko||(d?(j--,et=1):_e<$&&(_e++,et=-1)):b<0?j--:_e<$&&_e++;let tt=textRange(g,j,_e).getClientRects();if(!tt.length)return null;let nt=tt[(et?et<0:b>=0)?0:tt.length-1];return browser.safari&&!et&&nt.width==0&&(nt=Array.prototype.find.call(tt,rt=>rt.width)||nt),et?flattenRect(nt,et<0):nt||null}class WidgetView extends ContentView{static create(d,b,$){return new WidgetView(d,b,$)}constructor(d,b,$){super(),this.widget=d,this.length=b,this.side=$,this.prevWidget=null}split(d){let b=WidgetView.create(this.widget,this.length-d,this.side);return this.length-=d,b}sync(d){(!this.dom||!this.widget.updateDOM(this.dom,d))&&(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(d)),this.widget.editable||(this.dom.contentEditable="false"))}getSide(){return this.side}merge(d,b,$,j,_e,et){return $&&(!($ instanceof WidgetView)||!this.widget.compare($.widget)||d>0&&_e<=0||b0)?DOMPos.before(this.dom):DOMPos.after(this.dom,d==this.length)}domBoundsAround(){return null}coordsAt(d,b){let $=this.widget.coordsAt(this.dom,d,b);if($)return $;let j=this.dom.getClientRects(),_e=null;if(!j.length)return null;let et=this.side?this.side<0:d>0;for(let tt=et?j.length-1:0;_e=j[tt],!(d>0?tt==0:tt==j.length-1||_e.top<_e.bottom);tt+=et?-1:1);return flattenRect(_e,!et)}get isEditable(){return!1}get isWidget(){return!0}get isHidden(){return this.widget.isHidden}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}}class WidgetBufferView extends ContentView{constructor(d){super(),this.side=d}get length(){return 0}merge(){return!1}become(d){return d instanceof WidgetBufferView&&d.side==this.side}split(){return new WidgetBufferView(this.side)}sync(){if(!this.dom){let d=document.createElement("img");d.className="cm-widgetBuffer",d.setAttribute("aria-hidden","true"),this.setDOM(d)}}getSide(){return this.side}domAtPos(d){return this.side>0?DOMPos.before(this.dom):DOMPos.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(d){return this.dom.getBoundingClientRect()}get overrideDOMText(){return Text.empty}get isHidden(){return!0}}TextView.prototype.children=WidgetView.prototype.children=WidgetBufferView.prototype.children=noChildren;function inlineDOMAtPos(g,d){let b=g.dom,{children:$}=g,j=0;for(let _e=0;j<$.length;j++){let et=$[j],tt=_e+et.length;if(!(tt==_e&&et.getSide()<=0)){if(d>_e&&d0;_e--){let et=$[_e-1];if(et.dom.parentNode==b)return et.domAtPos(et.length)}for(let _e=j;_e<$.length;_e++){let et=$[_e];if(et.dom.parentNode==b)return et.domAtPos(0)}return new DOMPos(b,0)}function joinInlineInto(g,d,b){let $,{children:j}=g;b>0&&d instanceof MarkView&&j.length&&($=j[j.length-1])instanceof MarkView&&$.mark.eq(d.mark)?joinInlineInto($,d.children[0],b-1):(j.push(d),d.setParent(g)),g.length+=d.length}function coordsInChildren(g,d,b){let $=null,j=-1,_e=null,et=-1;function tt(rt,it){for(let st=0,ot=0;st=it&&(at.children.length?tt(at,it-ot):(!_e||_e.isHidden&&b>0)&&(ut>it||ot==ut&&at.getSide()>0)?(_e=at,et=it-ot):(ot-1?1:0)!=j.length-(b&&j.indexOf(b)>-1?1:0))return!1;for(let _e of $)if(_e!=b&&(j.indexOf(_e)==-1||g[_e]!==d[_e]))return!1;return!0}function updateAttrs(g,d,b){let $=!1;if(d)for(let j in d)b&&j in b||($=!0,j=="style"?g.style.cssText="":g.removeAttribute(j));if(b)for(let j in b)d&&d[j]==b[j]||($=!0,j=="style"?g.style.cssText=b[j]:g.setAttribute(j,b[j]));return $}function getAttrs(g){let d=Object.create(null);for(let b=0;b0&&this.children[$-1].length==0;)this.children[--$].destroy();return this.children.length=$,this.markDirty(),this.length=d,b}transferDOM(d){this.dom&&(this.markDirty(),d.setDOM(this.dom),d.prevAttrs=this.prevAttrs===void 0?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(d){attrsEq(this.attrs,d)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=d)}append(d,b){joinInlineInto(this,d,b)}addLineDeco(d){let b=d.spec.attributes,$=d.spec.class;b&&(this.attrs=combineAttrs(b,this.attrs||{})),$&&(this.attrs=combineAttrs({class:$},this.attrs||{}))}domAtPos(d){return inlineDOMAtPos(this,d)}reuseDOM(d){d.nodeName=="DIV"&&(this.setDOM(d),this.flags|=6)}sync(d,b){var $;this.dom?this.flags&4&&(clearAttributes(this.dom),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0):(this.setDOM(document.createElement("div")),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0),this.prevAttrs!==void 0&&(updateAttrs(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(d,b);let j=this.dom.lastChild;for(;j&&ContentView.get(j)instanceof MarkView;)j=j.lastChild;if(!j||!this.length||j.nodeName!="BR"&&(($=ContentView.get(j))===null||$===void 0?void 0:$.isEditable)==!1&&(!browser.ios||!this.children.some(_e=>_e instanceof TextView))){let _e=document.createElement("BR");_e.cmIgnore=!0,this.dom.appendChild(_e)}}measureTextSize(){if(this.children.length==0||this.length>20)return null;let d=0,b;for(let $ of this.children){if(!($ instanceof TextView)||/[^ -~]/.test($.text))return null;let j=clientRectsFor($.dom);if(j.length!=1)return null;d+=j[0].width,b=j[0].height}return d?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:d/this.length,textHeight:b}:null}coordsAt(d,b){let $=coordsInChildren(this,d,b);if(!this.children.length&&$&&this.parent){let{heightOracle:j}=this.parent.view.viewState,_e=$.bottom-$.top;if(Math.abs(_e-j.lineHeight)<2&&j.textHeight<_e){let et=(_e-j.textHeight)/2;return{top:$.top+et,bottom:$.bottom-et,left:$.left,right:$.left}}}return $}become(d){return!1}covers(){return!0}static find(d,b){for(let $=0,j=0;$=b){if(_e instanceof LineView)return _e;if(et>b)break}j=et+_e.breakAfter}return null}}class BlockWidgetView extends ContentView{constructor(d,b,$){super(),this.widget=d,this.length=b,this.deco=$,this.breakAfter=0,this.prevWidget=null}merge(d,b,$,j,_e,et){return $&&(!($ instanceof BlockWidgetView)||!this.widget.compare($.widget)||d>0&&_e<=0||b0}}class WidgetType{eq(d){return!1}updateDOM(d,b){return!1}compare(d){return this==d||this.constructor==d.constructor&&this.eq(d)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(d){return!0}coordsAt(d,b,$){return null}get isHidden(){return!1}get editable(){return!1}destroy(d){}}var BlockType=function(g){return g[g.Text=0]="Text",g[g.WidgetBefore=1]="WidgetBefore",g[g.WidgetAfter=2]="WidgetAfter",g[g.WidgetRange=3]="WidgetRange",g}(BlockType||(BlockType={}));class Decoration extends RangeValue{constructor(d,b,$,j){super(),this.startSide=d,this.endSide=b,this.widget=$,this.spec=j}get heightRelevant(){return!1}static mark(d){return new MarkDecoration(d)}static widget(d){let b=Math.max(-1e4,Math.min(1e4,d.side||0)),$=!!d.block;return b+=$&&!d.inlineOrder?b>0?3e8:-4e8:b>0?1e8:-1e8,new PointDecoration(d,b,b,$,d.widget||null,!1)}static replace(d){let b=!!d.block,$,j;if(d.isBlockGap)$=-5e8,j=4e8;else{let{start:_e,end:et}=getInclusive(d,b);$=(_e?b?-3e8:-1:5e8)-1,j=(et?b?2e8:1:-6e8)+1}return new PointDecoration(d,$,j,b,d.widget||null,!0)}static line(d){return new LineDecoration(d)}static set(d,b=!1){return RangeSet.of(d,b)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}Decoration.none=RangeSet.empty;class MarkDecoration extends Decoration{constructor(d){let{start:b,end:$}=getInclusive(d);super(b?-1:5e8,$?1:-6e8,null,d),this.tagName=d.tagName||"span",this.class=d.class||"",this.attrs=d.attributes||null}eq(d){var b,$;return this==d||d instanceof MarkDecoration&&this.tagName==d.tagName&&(this.class||((b=this.attrs)===null||b===void 0?void 0:b.class))==(d.class||(($=d.attrs)===null||$===void 0?void 0:$.class))&&attrsEq(this.attrs,d.attrs,"class")}range(d,b=d){if(d>=b)throw new RangeError("Mark decorations may not be empty");return super.range(d,b)}}MarkDecoration.prototype.point=!1;class LineDecoration extends Decoration{constructor(d){super(-2e8,-2e8,null,d)}eq(d){return d instanceof LineDecoration&&this.spec.class==d.spec.class&&attrsEq(this.spec.attributes,d.spec.attributes)}range(d,b=d){if(b!=d)throw new RangeError("Line decoration ranges must be zero-length");return super.range(d,b)}}LineDecoration.prototype.mapMode=MapMode.TrackBefore;LineDecoration.prototype.point=!0;class PointDecoration extends Decoration{constructor(d,b,$,j,_e,et){super(b,$,_e,d),this.block=j,this.isReplace=et,this.mapMode=j?b<=0?MapMode.TrackBefore:MapMode.TrackAfter:MapMode.TrackDel}get type(){return this.startSide!=this.endSide?BlockType.WidgetRange:this.startSide<=0?BlockType.WidgetBefore:BlockType.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(d){return d instanceof PointDecoration&&widgetsEq(this.widget,d.widget)&&this.block==d.block&&this.startSide==d.startSide&&this.endSide==d.endSide}range(d,b=d){if(this.isReplace&&(d>b||d==b&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&b!=d)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(d,b)}}PointDecoration.prototype.point=!0;function getInclusive(g,d=!1){let{inclusiveStart:b,inclusiveEnd:$}=g;return b==null&&(b=g.inclusive),$==null&&($=g.inclusive),{start:b??d,end:$??d}}function widgetsEq(g,d){return g==d||!!(g&&d&&g.compare(d))}function addRange(g,d,b,$=0){let j=b.length-1;j>=0&&b[j]+$>=g?b[j]=Math.max(b[j],d):b.push(g,d)}class ContentBuilder{constructor(d,b,$,j){this.doc=d,this.pos=b,this.end=$,this.disallowBlockEffectsFor=j,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.bufferMarks=[],this.atCursorPos=!0,this.openStart=-1,this.openEnd=-1,this.text="",this.textOff=0,this.cursor=d.iter(),this.skip=b}posCovered(){if(this.content.length==0)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;let d=this.content[this.content.length-1];return!(d.breakAfter||d instanceof BlockWidgetView&&d.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new LineView),this.atCursorPos=!0),this.curLine}flushBuffer(d=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(wrapMarks(new WidgetBufferView(-1),d),d.length),this.pendingBuffer=0)}addBlockWidget(d){this.flushBuffer(),this.curLine=null,this.content.push(d)}finish(d){this.pendingBuffer&&d<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,!this.posCovered()&&!(d&&this.content.length&&this.content[this.content.length-1]instanceof BlockWidgetView)&&this.getLine()}buildText(d,b,$){for(;d>0;){if(this.textOff==this.text.length){let{value:_e,lineBreak:et,done:tt}=this.cursor.next(this.skip);if(this.skip=0,tt)throw new Error("Ran out of text content when drawing inline views");if(et){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,d--;continue}else this.text=_e,this.textOff=0}let j=Math.min(this.text.length-this.textOff,d,512);this.flushBuffer(b.slice(b.length-$)),this.getLine().append(wrapMarks(new TextView(this.text.slice(this.textOff,this.textOff+j)),b),$),this.atCursorPos=!0,this.textOff+=j,d-=j,$=0}}span(d,b,$,j){this.buildText(b-d,$,j),this.pos=b,this.openStart<0&&(this.openStart=j)}point(d,b,$,j,_e,et){if(this.disallowBlockEffectsFor[et]&&$ instanceof PointDecoration){if($.block)throw new RangeError("Block decorations may not be specified via plugins");if(b>this.doc.lineAt(this.pos).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}let tt=b-d;if($ instanceof PointDecoration)if($.block)$.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new BlockWidgetView($.widget||new NullWidget("div"),tt,$));else{let nt=WidgetView.create($.widget||new NullWidget("span"),tt,tt?0:$.startSide),rt=this.atCursorPos&&!nt.isEditable&&_e<=j.length&&(d0),it=!nt.isEditable&&(dj.length||$.startSide<=0),st=this.getLine();this.pendingBuffer==2&&!rt&&!nt.isEditable&&(this.pendingBuffer=0),this.flushBuffer(j),rt&&(st.append(wrapMarks(new WidgetBufferView(1),j),_e),_e=j.length+Math.max(0,_e-j.length)),st.append(wrapMarks(nt,j),_e),this.atCursorPos=it,this.pendingBuffer=it?dj.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=j.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco($);tt&&(this.textOff+tt<=this.text.length?this.textOff+=tt:(this.skip+=tt-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=b),this.openStart<0&&(this.openStart=_e)}static build(d,b,$,j,_e){let et=new ContentBuilder(d,b,$,_e);return et.openEnd=RangeSet.spans(j,b,$,et),et.openStart<0&&(et.openStart=et.openEnd),et.finish(et.openEnd),et}}function wrapMarks(g,d){for(let b of d)g=new MarkView(b,[g],g.length);return g}class NullWidget extends WidgetType{constructor(d){super(),this.tag=d}eq(d){return d.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(d){return d.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}var Direction=function(g){return g[g.LTR=0]="LTR",g[g.RTL=1]="RTL",g}(Direction||(Direction={}));const LTR=Direction.LTR,RTL=Direction.RTL;function dec(g){let d=[];for(let b=0;b=b){if(tt.level==$)return et;(_e<0||(j!=0?j<0?tt.fromb:d[_e].level>tt.level))&&(_e=et)}}if(_e<0)throw new RangeError("Index out of range");return _e}}function isolatesEq(g,d){if(g.length!=d.length)return!1;for(let b=0;b=0;ct-=3)if(BracketStack[ct+1]==-at){let dt=BracketStack[ct+2],ht=dt&2?j:dt&4?dt&1?_e:j:0;ht&&(types[st]=types[BracketStack[ct]]=ht),tt=ct;break}}else{if(BracketStack.length==189)break;BracketStack[tt++]=st,BracketStack[tt++]=ot,BracketStack[tt++]=nt}else if((ut=types[st])==2||ut==1){let ct=ut==j;nt=ct?0:1;for(let dt=tt-3;dt>=0;dt-=3){let ht=BracketStack[dt+2];if(ht&2)break;if(ct)BracketStack[dt+2]|=2;else{if(ht&4)break;BracketStack[dt+2]|=4}}}}}function processNeutrals(g,d,b,$){for(let j=0,_e=$;j<=b.length;j++){let et=j?b[j-1].to:g,tt=jnt;)ut==dt&&(ut=b[--ct].from,dt=ct?b[ct-1].to:g),types[--ut]=at;nt=it}else _e=rt,nt++}}}function emitSpans(g,d,b,$,j,_e,et){let tt=$%2?2:1;if($%2==j%2)for(let nt=d,rt=0;ntnt&&et.push(new BidiSpan(nt,ct.from,at));let dt=ct.direction==LTR!=!(at%2);computeSectionOrder(g,dt?$+1:$,j,ct.inner,ct.from,ct.to,et),nt=ct.to}ut=ct.to}else{if(ut==b||(it?types[ut]!=tt:types[ut]==tt))break;ut++}ot?emitSpans(g,nt,ut,$+1,j,ot,et):ntd;){let it=!0,st=!1;if(!rt||nt>_e[rt-1].to){let ct=types[nt-1];ct!=tt&&(it=!1,st=ct==16)}let ot=!it&&tt==1?[]:null,at=it?$:$+1,ut=nt;e:for(;;)if(rt&&ut==_e[rt-1].to){if(st)break e;let ct=_e[--rt];if(!it)for(let dt=ct.from,ht=rt;;){if(dt==d)break e;if(ht&&_e[ht-1].to==dt)dt=_e[--ht].from;else{if(types[dt-1]==tt)break e;break}}if(ot)ot.push(ct);else{ct.totypes.length;)types[types.length]=256;let $=[],j=d==LTR?0:1;return computeSectionOrder(g,j,j,b,0,g.length,$),$}function trivialOrder(g){return[new BidiSpan(0,g,0)]}let movedOver="";function moveVisually(g,d,b,$,j){var _e;let et=$.head-g.from,tt=BidiSpan.find(d,et,(_e=$.bidiLevel)!==null&&_e!==void 0?_e:-1,$.assoc),nt=d[tt],rt=nt.side(j,b);if(et==rt){let ot=tt+=j?1:-1;if(ot<0||ot>=d.length)return null;nt=d[tt=ot],et=nt.side(!j,b),rt=nt.side(j,b)}let it=findClusterBreak(g.text,et,nt.forward(j,b));(itnt.to)&&(it=rt),movedOver=g.text.slice(Math.min(et,it),Math.max(et,it));let st=tt==(j?d.length-1:0)?null:d[tt+(j?1:-1)];return st&&it==rt&&st.level+(j?0:1)g.some(d=>d)}),nativeSelectionHidden=Facet.define({combine:g=>g.some(d=>d)});class ScrollTarget{constructor(d,b="nearest",$="nearest",j=5,_e=5,et=!1){this.range=d,this.y=b,this.x=$,this.yMargin=j,this.xMargin=_e,this.isSnapshot=et}map(d){return d.empty?this:new ScrollTarget(this.range.map(d),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(d){return this.range.to<=d.doc.length?this:new ScrollTarget(EditorSelection.cursor(d.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const scrollIntoView$1=StateEffect.define({map:(g,d)=>g.map(d)});function logException(g,d,b){let $=g.facet(exceptionSink);$.length?$[0](d):window.onerror?window.onerror(String(d),b,void 0,void 0,d):b?console.error(b+":",d):console.error(d)}const editable=Facet.define({combine:g=>g.length?g[0]:!0});let nextPluginID=0;const viewPlugin=Facet.define();class ViewPlugin{constructor(d,b,$,j,_e){this.id=d,this.create=b,this.domEventHandlers=$,this.domEventObservers=j,this.extension=_e(this)}static define(d,b){const{eventHandlers:$,eventObservers:j,provide:_e,decorations:et}=b||{};return new ViewPlugin(nextPluginID++,d,$,j,tt=>{let nt=[viewPlugin.of(tt)];return et&&nt.push(decorations.of(rt=>{let it=rt.plugin(tt);return it?et(it):Decoration.none})),_e&&nt.push(_e(tt)),nt})}static fromClass(d,b){return ViewPlugin.define($=>new d($),b)}}class PluginInstance{constructor(d){this.spec=d,this.mustUpdate=null,this.value=null}update(d){if(this.value){if(this.mustUpdate){let b=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(b)}catch($){if(logException(b.state,$,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.create(d)}catch(b){logException(d.state,b,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(d){var b;if(!((b=this.value)===null||b===void 0)&&b.destroy)try{this.value.destroy()}catch($){logException(d.state,$,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const editorAttributes=Facet.define(),contentAttributes=Facet.define(),decorations=Facet.define(),outerDecorations=Facet.define(),atomicRanges=Facet.define(),bidiIsolatedRanges=Facet.define();function getIsolatedRanges(g,d){let b=g.state.facet(bidiIsolatedRanges);if(!b.length)return b;let $=b.map(_e=>_e instanceof Function?_e(g):_e),j=[];return RangeSet.spans($,d.from,d.to,{point(){},span(_e,et,tt,nt){let rt=_e-d.from,it=et-d.from,st=j;for(let ot=tt.length-1;ot>=0;ot--,nt--){let at=tt[ot].spec.bidiIsolate,ut;if(at==null&&(at=autoDirection(d.text,rt,it)),nt>0&&st.length&&(ut=st[st.length-1]).to==rt&&ut.direction==at)ut.to=it,st=ut.inner;else{let ct={from:rt,to:it,direction:at,inner:[]};st.push(ct),st=ct.inner}}}}),j}const scrollMargins=Facet.define();function getScrollMargins(g){let d=0,b=0,$=0,j=0;for(let _e of g.state.facet(scrollMargins)){let et=_e(g);et&&(et.left!=null&&(d=Math.max(d,et.left)),et.right!=null&&(b=Math.max(b,et.right)),et.top!=null&&($=Math.max($,et.top)),et.bottom!=null&&(j=Math.max(j,et.bottom)))}return{left:d,right:b,top:$,bottom:j}}const styleModule=Facet.define();class ChangedRange{constructor(d,b,$,j){this.fromA=d,this.toA=b,this.fromB=$,this.toB=j}join(d){return new ChangedRange(Math.min(this.fromA,d.fromA),Math.max(this.toA,d.toA),Math.min(this.fromB,d.fromB),Math.max(this.toB,d.toB))}addToSet(d){let b=d.length,$=this;for(;b>0;b--){let j=d[b-1];if(!(j.fromA>$.toA)){if(j.toA<$.fromA)break;$=$.join(j),d.splice(b-1,1)}}return d.splice(b,0,$),d}static extendWithRanges(d,b){if(b.length==0)return d;let $=[];for(let j=0,_e=0,et=0,tt=0;;j++){let nt=j==d.length?null:d[j],rt=et-tt,it=nt?nt.fromB:1e9;for(;_eit)break;_e+=2}if(!nt)return $;new ChangedRange(nt.fromA,nt.toA,nt.fromB,nt.toB).addToSet($),et=nt.toA,tt=nt.toB}}}class ViewUpdate{constructor(d,b,$){this.view=d,this.state=b,this.transactions=$,this.flags=0,this.startState=d.state,this.changes=ChangeSet.empty(this.startState.doc.length);for(let _e of $)this.changes=this.changes.compose(_e.changes);let j=[];this.changes.iterChangedRanges((_e,et,tt,nt)=>j.push(new ChangedRange(_e,et,tt,nt))),this.changedRanges=j}static create(d,b,$){return new ViewUpdate(d,b,$)}get viewportChanged(){return(this.flags&4)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&10)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(d=>d.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}class DocView extends ContentView{get length(){return this.view.state.doc.length}constructor(d){super(),this.view=d,this.decorations=[],this.dynamicDecorationMap=[],this.domChanged=null,this.hasComposition=null,this.markedForComposition=new Set,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.setDOM(d.contentDOM),this.children=[new LineView],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new ChangedRange(0,0,0,d.state.doc.length)],0,null)}update(d){var b;let $=d.changedRanges;this.minWidth>0&&$.length&&($.every(({fromA:rt,toA:it})=>itthis.minWidthTo)?(this.minWidthFrom=d.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=d.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0);let j=-1;this.view.inputState.composing>=0&&(!((b=this.domChanged)===null||b===void 0)&&b.newSel?j=this.domChanged.newSel.head:!touchesComposition(d.changes,this.hasComposition)&&!d.selectionSet&&(j=d.state.selection.main.head));let _e=j>-1?findCompositionRange(this.view,d.changes,j):null;if(this.domChanged=null,this.hasComposition){this.markedForComposition.clear();let{from:rt,to:it}=this.hasComposition;$=new ChangedRange(rt,it,d.changes.mapPos(rt,-1),d.changes.mapPos(it,1)).addToSet($.slice())}this.hasComposition=_e?{from:_e.range.fromB,to:_e.range.toB}:null,(browser.ie||browser.chrome)&&!_e&&d&&d.state.doc.lines!=d.startState.doc.lines&&(this.forceSelection=!0);let et=this.decorations,tt=this.updateDeco(),nt=findChangedDeco(et,tt,d.changes);return $=ChangedRange.extendWithRanges($,nt),!(this.flags&7)&&$.length==0?!1:(this.updateInner($,d.startState.doc.length,_e),d.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(d,b,$){this.view.viewState.mustMeasureContent=!0,this.updateChildren(d,b,$);let{observer:j}=this.view;j.ignore(()=>{this.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let et=browser.chrome||browser.ios?{node:j.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,et),this.flags&=-8,et&&(et.written||j.selectionRange.focusNode!=et.node)&&(this.forceSelection=!0),this.dom.style.height=""}),this.markedForComposition.forEach(et=>et.flags&=-9);let _e=[];if(this.view.viewport.from||this.view.viewport.to=0?j[et]:null;if(!tt)break;let{fromA:nt,toA:rt,fromB:it,toB:st}=tt,ot,at,ut,ct;if($&&$.range.fromBit){let yt=ContentBuilder.build(this.view.state.doc,it,$.range.fromB,this.decorations,this.dynamicDecorationMap),vt=ContentBuilder.build(this.view.state.doc,$.range.toB,st,this.decorations,this.dynamicDecorationMap);at=yt.breakAtStart,ut=yt.openStart,ct=vt.openEnd;let St=this.compositionView($);vt.breakAtStart?St.breakAfter=1:vt.content.length&&St.merge(St.length,St.length,vt.content[0],!1,vt.openStart,0)&&(St.breakAfter=vt.content[0].breakAfter,vt.content.shift()),yt.content.length&&St.merge(0,0,yt.content[yt.content.length-1],!0,0,yt.openEnd)&&yt.content.pop(),ot=yt.content.concat(St).concat(vt.content)}else({content:ot,breakAtStart:at,openStart:ut,openEnd:ct}=ContentBuilder.build(this.view.state.doc,it,st,this.decorations,this.dynamicDecorationMap));let{i:dt,off:ht}=_e.findPos(rt,1),{i:pt,off:gt}=_e.findPos(nt,-1);replaceRange(this,pt,gt,dt,ht,ot,at,ut,ct)}$&&this.fixCompositionDOM($)}compositionView(d){let b=new TextView(d.text.nodeValue);b.flags|=8;for(let{deco:j}of d.marks)b=new MarkView(j,[b],b.length);let $=new LineView;return $.append(b,0),$}fixCompositionDOM(d){let b=(_e,et)=>{et.flags|=8|(et.children.some(nt=>nt.flags&7)?1:0),this.markedForComposition.add(et);let tt=ContentView.get(_e);tt&&tt!=et&&(tt.dom=null),et.setDOM(_e)},$=this.childPos(d.range.fromB,1),j=this.children[$.i];b(d.line,j);for(let _e=d.marks.length-1;_e>=-1;_e--)$=j.childPos($.off,1),j=j.children[$.i],b(_e>=0?d.marks[_e].node:d.text,j)}updateSelection(d=!1,b=!1){(d||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let $=this.view.root.activeElement,j=$==this.dom,_e=!j&&hasSelection(this.dom,this.view.observer.selectionRange)&&!($&&this.dom.contains($));if(!(j||b||_e))return;let et=this.forceSelection;this.forceSelection=!1;let tt=this.view.state.selection.main,nt=this.moveToLine(this.domAtPos(tt.anchor)),rt=tt.empty?nt:this.moveToLine(this.domAtPos(tt.head));if(browser.gecko&&tt.empty&&!this.hasComposition&&betweenUneditable(nt)){let st=document.createTextNode("");this.view.observer.ignore(()=>nt.node.insertBefore(st,nt.node.childNodes[nt.offset]||null)),nt=rt=new DOMPos(st,0),et=!0}let it=this.view.observer.selectionRange;(et||!it.focusNode||(!isEquivalentPosition(nt.node,nt.offset,it.anchorNode,it.anchorOffset)||!isEquivalentPosition(rt.node,rt.offset,it.focusNode,it.focusOffset))&&!this.suppressWidgetCursorChange(it,tt))&&(this.view.observer.ignore(()=>{browser.android&&browser.chrome&&this.dom.contains(it.focusNode)&&inUneditable(it.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let st=getSelection(this.view.root);if(st)if(tt.empty){if(browser.gecko){let ot=nextToUneditable(nt.node,nt.offset);if(ot&&ot!=3){let at=nearbyTextNode(nt.node,nt.offset,ot==1?1:-1);at&&(nt=new DOMPos(at.node,at.offset))}}st.collapse(nt.node,nt.offset),tt.bidiLevel!=null&&st.caretBidiLevel!==void 0&&(st.caretBidiLevel=tt.bidiLevel)}else if(st.extend){st.collapse(nt.node,nt.offset);try{st.extend(rt.node,rt.offset)}catch{}}else{let ot=document.createRange();tt.anchor>tt.head&&([nt,rt]=[rt,nt]),ot.setEnd(rt.node,rt.offset),ot.setStart(nt.node,nt.offset),st.removeAllRanges(),st.addRange(ot)}_e&&this.view.root.activeElement==this.dom&&(this.dom.blur(),$&&$.focus())}),this.view.observer.setSelectionRange(nt,rt)),this.impreciseAnchor=nt.precise?null:new DOMPos(it.anchorNode,it.anchorOffset),this.impreciseHead=rt.precise?null:new DOMPos(it.focusNode,it.focusOffset)}suppressWidgetCursorChange(d,b){return this.hasComposition&&b.empty&&isEquivalentPosition(d.focusNode,d.focusOffset,d.anchorNode,d.anchorOffset)&&this.posFromDOM(d.focusNode,d.focusOffset)==b.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:d}=this,b=d.state.selection.main,$=getSelection(d.root),{anchorNode:j,anchorOffset:_e}=d.observer.selectionRange;if(!$||!b.empty||!b.assoc||!$.modify)return;let et=LineView.find(this,b.head);if(!et)return;let tt=et.posAtStart;if(b.head==tt||b.head==tt+et.length)return;let nt=this.coordsAt(b.head,-1),rt=this.coordsAt(b.head,1);if(!nt||!rt||nt.bottom>rt.top)return;let it=this.domAtPos(b.head+b.assoc);$.collapse(it.node,it.offset),$.modify("move",b.assoc<0?"forward":"backward","lineboundary"),d.observer.readSelectionRange();let st=d.observer.selectionRange;d.docView.posFromDOM(st.anchorNode,st.anchorOffset)!=b.from&&$.collapse(j,_e)}moveToLine(d){let b=this.dom,$;if(d.node!=b)return d;for(let j=d.offset;!$&&j=0;j--){let _e=ContentView.get(b.childNodes[j]);_e instanceof LineView&&($=_e.domAtPos(_e.length))}return $?new DOMPos($.node,$.offset,!0):d}nearest(d){for(let b=d;b;){let $=ContentView.get(b);if($&&$.rootView==this)return $;b=b.parentNode}return null}posFromDOM(d,b){let $=this.nearest(d);if(!$)throw new RangeError("Trying to find position for a DOM position outside of the document");return $.localPosFromDOM(d,b)+$.posAtStart}domAtPos(d){let{i:b,off:$}=this.childCursor().findPos(d,-1);for(;b=0;et--){let tt=this.children[et],nt=_e-tt.breakAfter,rt=nt-tt.length;if(ntd||tt.covers(1))&&(!$||tt instanceof LineView&&!($ instanceof LineView&&b>=0))&&($=tt,j=rt),_e=rt}return $?$.coordsAt(d-j,b):null}coordsForChar(d){let{i:b,off:$}=this.childPos(d,1),j=this.children[b];if(!(j instanceof LineView))return null;for(;j.children.length;){let{i:tt,off:nt}=j.childPos($,1);for(;;tt++){if(tt==j.children.length)return null;if((j=j.children[tt]).length)break}$=nt}if(!(j instanceof TextView))return null;let _e=findClusterBreak(j.text,$);if(_e==$)return null;let et=textRange(j.dom,$,_e).getClientRects();for(let tt=0;ttMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,tt=-1,nt=this.view.textDirection==Direction.LTR;for(let rt=0,it=0;itj)break;if(rt>=$){let at=st.dom.getBoundingClientRect();if(b.push(at.height),et){let ut=st.dom.lastChild,ct=ut?clientRectsFor(ut):[];if(ct.length){let dt=ct[ct.length-1],ht=nt?dt.right-at.left:at.right-dt.left;ht>tt&&(tt=ht,this.minWidth=_e,this.minWidthFrom=rt,this.minWidthTo=ot)}}}rt=ot+st.breakAfter}return b}textDirectionAt(d){let{i:b}=this.childPos(d,1);return getComputedStyle(this.children[b].dom).direction=="rtl"?Direction.RTL:Direction.LTR}measureTextSize(){for(let _e of this.children)if(_e instanceof LineView){let et=_e.measureTextSize();if(et)return et}let d=document.createElement("div"),b,$,j;return d.className="cm-line",d.style.width="99999px",d.style.position="absolute",d.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.dom.appendChild(d);let _e=clientRectsFor(d.firstChild)[0];b=d.getBoundingClientRect().height,$=_e?_e.width/27:7,j=_e?_e.height:b,d.remove()}),{lineHeight:b,charWidth:$,textHeight:j}}childCursor(d=this.length){let b=this.children.length;return b&&(d-=this.children[--b].length),new ChildCursor(this.children,d,b)}computeBlockGapDeco(){let d=[],b=this.view.viewState;for(let $=0,j=0;;j++){let _e=j==b.viewports.length?null:b.viewports[j],et=_e?_e.from-1:this.length;if(et>$){let tt=(b.lineBlockAt(et).bottom-b.lineBlockAt($).top)/this.view.scaleY;d.push(Decoration.replace({widget:new BlockGapWidget(tt),block:!0,inclusive:!0,isBlockGap:!0}).range($,et))}if(!_e)break;$=_e.to+1}return Decoration.set(d)}updateDeco(){let d=this.view.state.facet(decorations).map((j,_e)=>(this.dynamicDecorationMap[_e]=typeof j=="function")?j(this.view):j),b=!1,$=this.view.state.facet(outerDecorations).map((j,_e)=>{let et=typeof j=="function";return et&&(b=!0),et?j(this.view):j});$.length&&(this.dynamicDecorationMap[d.length]=b,d.push(RangeSet.join($)));for(let j=d.length;jb.anchor?-1:1),j;if(!$)return;!b.empty&&(j=this.coordsAt(b.anchor,b.anchor>b.head?-1:1))&&($={left:Math.min($.left,j.left),top:Math.min($.top,j.top),right:Math.max($.right,j.right),bottom:Math.max($.bottom,j.bottom)});let _e=getScrollMargins(this.view),et={left:$.left-_e.left,top:$.top-_e.top,right:$.right+_e.right,bottom:$.bottom+_e.bottom},{offsetWidth:tt,offsetHeight:nt}=this.view.scrollDOM;scrollRectIntoView(this.view.scrollDOM,et,b.head0)$=$.childNodes[j-1],j=maxOffset($);else break}if(b>=0)for(let $=g,j=d;;){if($.nodeType==3)return{node:$,offset:j};if($.nodeType==1&&j<$.childNodes.length&&b>=0)$=$.childNodes[j],j=0;else break}return null}function nextToUneditable(g,d){return g.nodeType!=1?0:(d&&g.childNodes[d-1].contentEditable=="false"?1:0)|(d{$d.from&&(b=!0)}),b}function groupAt(g,d,b=1){let $=g.charCategorizer(d),j=g.doc.lineAt(d),_e=d-j.from;if(j.length==0)return EditorSelection.cursor(d);_e==0?b=1:_e==j.length&&(b=-1);let et=_e,tt=_e;b<0?et=findClusterBreak(j.text,_e,!1):tt=findClusterBreak(j.text,_e);let nt=$(j.text.slice(et,tt));for(;et>0;){let rt=findClusterBreak(j.text,et,!1);if($(j.text.slice(rt,et))!=nt)break;et=rt}for(;ttg?d.left-g:Math.max(0,g-d.right)}function getdy(g,d){return d.top>g?d.top-g:Math.max(0,g-d.bottom)}function yOverlap(g,d){return g.topd.top+1}function upTop(g,d){return dg.bottom?{top:g.top,left:g.left,right:g.right,bottom:d}:g}function domPosAtCoords(g,d,b){let $,j,_e,et,tt=!1,nt,rt,it,st;for(let ut=g.firstChild;ut;ut=ut.nextSibling){let ct=clientRectsFor(ut);for(let dt=0;dtgt||et==gt&&_e>pt){$=ut,j=ht,_e=pt,et=gt;let yt=gt?b0?dt0)}pt==0?b>ht.bottom&&(!it||it.bottomht.top)&&(rt=ut,st=ht):it&&yOverlap(it,ht)?it=upBot(it,ht.bottom):st&&yOverlap(st,ht)&&(st=upTop(st,ht.top))}}if(it&&it.bottom>=b?($=nt,j=it):st&&st.top<=b&&($=rt,j=st),!$)return{node:g,offset:0};let ot=Math.max(j.left,Math.min(j.right,d));if($.nodeType==3)return domPosInText($,ot,b);if(tt&&$.contentEditable!="false")return domPosAtCoords($,ot,b);let at=Array.prototype.indexOf.call(g.childNodes,$)+(d>=(j.left+j.right)/2?1:0);return{node:g,offset:at}}function domPosInText(g,d,b){let $=g.nodeValue.length,j=-1,_e=1e9,et=0;for(let tt=0;tt<$;tt++){let nt=textRange(g,tt,tt+1).getClientRects();for(let rt=0;rtb?it.top-b:b-it.bottom)-1;if(it.left-1<=d&&it.right+1>=d&&st<_e){let ot=d>=(it.left+it.right)/2,at=ot;if((browser.chrome||browser.gecko)&&textRange(g,tt).getBoundingClientRect().left==it.right&&(at=!ot),st<=0)return{node:g,offset:tt+(at?1:0)};j=tt+(at?1:0),_e=st}}}return{node:g,offset:j>-1?j:et>0?g.nodeValue.length:0}}function posAtCoords(g,d,b,$=-1){var j,_e;let et=g.contentDOM.getBoundingClientRect(),tt=et.top+g.viewState.paddingTop,nt,{docHeight:rt}=g.viewState,{x:it,y:st}=d,ot=st-tt;if(ot<0)return 0;if(ot>rt)return g.state.doc.length;for(let yt=g.viewState.heightOracle.textHeight/2,vt=!1;nt=g.elementAtHeight(ot),nt.type!=BlockType.Text;)for(;ot=$>0?nt.bottom+yt:nt.top-yt,!(ot>=0&&ot<=rt);){if(vt)return b?null:0;vt=!0,$=-$}st=tt+ot;let at=nt.from;if(atg.viewport.to)return g.viewport.to==g.state.doc.length?g.state.doc.length:b?null:posAtCoordsImprecise(g,et,nt,it,st);let ut=g.dom.ownerDocument,ct=g.root.elementFromPoint?g.root:ut,dt=ct.elementFromPoint(it,st);dt&&!g.contentDOM.contains(dt)&&(dt=null),dt||(it=Math.max(et.left+1,Math.min(et.right-1,it)),dt=ct.elementFromPoint(it,st),dt&&!g.contentDOM.contains(dt)&&(dt=null));let ht,pt=-1;if(dt&&((j=g.docView.nearest(dt))===null||j===void 0?void 0:j.isEditable)!=!1){if(ut.caretPositionFromPoint){let yt=ut.caretPositionFromPoint(it,st);yt&&({offsetNode:ht,offset:pt}=yt)}else if(ut.caretRangeFromPoint){let yt=ut.caretRangeFromPoint(it,st);yt&&({startContainer:ht,startOffset:pt}=yt,(!g.contentDOM.contains(ht)||browser.safari&&isSuspiciousSafariCaretResult(ht,pt,it)||browser.chrome&&isSuspiciousChromeCaretResult(ht,pt,it))&&(ht=void 0))}}if(!ht||!g.docView.dom.contains(ht)){let yt=LineView.find(g.docView,at);if(!yt)return ot>nt.top+nt.height/2?nt.to:nt.from;({node:ht,offset:pt}=domPosAtCoords(yt.dom,it,st))}let gt=g.docView.nearest(ht);if(!gt)return null;if(gt.isWidget&&((_e=gt.dom)===null||_e===void 0?void 0:_e.nodeType)==1){let yt=gt.dom.getBoundingClientRect();return d.yg.defaultLineHeight*1.5){let tt=g.viewState.heightOracle.textHeight,nt=Math.floor((j-b.top-(g.defaultLineHeight-tt)*.5)/tt);_e+=nt*g.viewState.heightOracle.lineLength}let et=g.state.sliceDoc(b.from,b.to);return b.from+findColumn(et,_e,g.state.tabSize)}function isSuspiciousSafariCaretResult(g,d,b){let $;if(g.nodeType!=3||d!=($=g.nodeValue.length))return!1;for(let j=g.nextSibling;j;j=j.nextSibling)if(j.nodeType!=1||j.nodeName!="BR")return!1;return textRange(g,$-1,$).getBoundingClientRect().left>b}function isSuspiciousChromeCaretResult(g,d,b){if(d!=0)return!1;for(let j=g;;){let _e=j.parentNode;if(!_e||_e.nodeType!=1||_e.firstChild!=j)return!1;if(_e.classList.contains("cm-line"))break;j=_e}let $=g.nodeType==1?g.getBoundingClientRect():textRange(g,0,Math.max(g.nodeValue.length,1)).getBoundingClientRect();return b-$.left>5}function blockAt(g,d){let b=g.lineBlockAt(d);if(Array.isArray(b.type)){for(let $ of b.type)if($.to>d||$.to==d&&($.to==b.to||$.type==BlockType.Text))return $}return b}function moveToLineBoundary(g,d,b,$){let j=blockAt(g,d.head),_e=!$||j.type!=BlockType.Text||!(g.lineWrapping||j.widgetLineBreaks)?null:g.coordsAtPos(d.assoc<0&&d.head>j.from?d.head-1:d.head);if(_e){let et=g.dom.getBoundingClientRect(),tt=g.textDirectionAt(j.from),nt=g.posAtCoords({x:b==(tt==Direction.LTR)?et.right-1:et.left+1,y:(_e.top+_e.bottom)/2});if(nt!=null)return EditorSelection.cursor(nt,b?-1:1)}return EditorSelection.cursor(b?j.to:j.from,b?-1:1)}function moveByChar(g,d,b,$){let j=g.state.doc.lineAt(d.head),_e=g.bidiSpans(j),et=g.textDirectionAt(j.from);for(let tt=d,nt=null;;){let rt=moveVisually(j,_e,et,tt,b),it=movedOver;if(!rt){if(j.number==(b?g.state.doc.lines:1))return tt;it=` +`,j=g.state.doc.line(j.number+(b?1:-1)),_e=g.bidiSpans(j),rt=g.visualLineSide(j,!b)}if(nt){if(!nt(it))return tt}else{if(!$)return rt;nt=$(it)}tt=rt}}function byGroup(g,d,b){let $=g.state.charCategorizer(d),j=$(b);return _e=>{let et=$(_e);return j==CharCategory.Space&&(j=et),j==et}}function moveVertically(g,d,b,$){let j=d.head,_e=b?1:-1;if(j==(b?g.state.doc.length:0))return EditorSelection.cursor(j,d.assoc);let et=d.goalColumn,tt,nt=g.contentDOM.getBoundingClientRect(),rt=g.coordsAtPos(j,d.assoc||-1),it=g.documentTop;if(rt)et==null&&(et=rt.left-nt.left),tt=_e<0?rt.top:rt.bottom;else{let at=g.viewState.lineBlockAt(j);et==null&&(et=Math.min(nt.right-nt.left,g.defaultCharacterWidth*(j-at.from))),tt=(_e<0?at.top:at.bottom)+it}let st=nt.left+et,ot=$??g.viewState.heightOracle.textHeight>>1;for(let at=0;;at+=10){let ut=tt+(ot+at)*_e,ct=posAtCoords(g,{x:st,y:ut},!1,_e);if(utnt.bottom||(_e<0?ctj)){let dt=g.docView.coordsForChar(ct),ht=!dt||ut{if(d>_e&&dj(g)),b.from,d.head>b.from?-1:1);return $==b.from?b:EditorSelection.cursor($,$null),browser.gecko&&firefoxCopyCutHack(d.contentDOM.ownerDocument)}handleEvent(d){!eventBelongsToEditor(this.view,d)||this.ignoreDuringComposition(d)||d.type=="keydown"&&this.keydown(d)||this.runHandlers(d.type,d)}runHandlers(d,b){let $=this.handlers[d];if($){for(let j of $.observers)j(this.view,b);for(let j of $.handlers){if(b.defaultPrevented)break;if(j(this.view,b)){b.preventDefault();break}}}}ensureHandlers(d){let b=computeHandlers(d),$=this.handlers,j=this.view.contentDOM;for(let _e in b)if(_e!="scroll"){let et=!b[_e].handlers.length,tt=$[_e];tt&&et!=!tt.handlers.length&&(j.removeEventListener(_e,this.handleEvent),tt=null),tt||j.addEventListener(_e,this.handleEvent,{passive:et})}for(let _e in $)_e!="scroll"&&!b[_e]&&j.removeEventListener(_e,this.handleEvent);this.handlers=b}keydown(d){if(this.lastKeyCode=d.keyCode,this.lastKeyTime=Date.now(),d.keyCode==9&&Date.now()$.keyCode==d.keyCode))&&!d.ctrlKey||EmacsyPendingKeys.indexOf(d.key)>-1&&d.ctrlKey&&!d.shiftKey)?(this.pendingIOSKey=b||d,setTimeout(()=>this.flushIOSKey(),250),!0):(d.keyCode!=229&&this.view.observer.forceFlush(),!1)}flushIOSKey(){let d=this.pendingIOSKey;return d?(this.pendingIOSKey=void 0,dispatchKey(this.view.contentDOM,d.key,d.keyCode)):!1}ignoreDuringComposition(d){return/^key/.test(d.type)?this.composing>0?!0:browser.safari&&!browser.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1:!1}startMouseSelection(d){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=d}update(d){this.mouseSelection&&this.mouseSelection.update(d),this.draggedContent&&d.docChanged&&(this.draggedContent=this.draggedContent.map(d.changes)),d.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function bindHandler(g,d){return(b,$)=>{try{return d.call(g,$,b)}catch(j){logException(b.state,j)}}}function computeHandlers(g){let d=Object.create(null);function b($){return d[$]||(d[$]={observers:[],handlers:[]})}for(let $ of g){let j=$.spec;if(j&&j.domEventHandlers)for(let _e in j.domEventHandlers){let et=j.domEventHandlers[_e];et&&b(_e).handlers.push(bindHandler($.value,et))}if(j&&j.domEventObservers)for(let _e in j.domEventObservers){let et=j.domEventObservers[_e];et&&b(_e).observers.push(bindHandler($.value,et))}}for(let $ in handlers)b($).handlers.push(handlers[$]);for(let $ in observers)b($).observers.push(observers[$]);return d}const PendingKeys=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],EmacsyPendingKeys="dthko",modifierCodes=[16,17,18,20,91,92,224,225],dragScrollMargin=6;function dragScrollSpeed(g){return Math.max(0,g)*.7+8}function dist(g,d){return Math.max(Math.abs(g.clientX-d.clientX),Math.abs(g.clientY-d.clientY))}class MouseSelection{constructor(d,b,$,j){this.view=d,this.startEvent=b,this.style=$,this.mustSelect=j,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=b,this.scrollParent=scrollableParent(d.contentDOM),this.atoms=d.state.facet(atomicRanges).map(et=>et(d));let _e=d.contentDOM.ownerDocument;_e.addEventListener("mousemove",this.move=this.move.bind(this)),_e.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=b.shiftKey,this.multiple=d.state.facet(EditorState.allowMultipleSelections)&&addsSelectionRange(d,b),this.dragging=isInPrimarySelection(d,b)&&getClickType(b)==1?null:!1}start(d){this.dragging===!1&&this.select(d)}move(d){var b;if(d.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&dist(this.startEvent,d)<10)return;this.select(this.lastEvent=d);let $=0,j=0,_e=((b=this.scrollParent)===null||b===void 0?void 0:b.getBoundingClientRect())||{left:0,top:0,right:this.view.win.innerWidth,bottom:this.view.win.innerHeight},et=getScrollMargins(this.view);d.clientX-et.left<=_e.left+dragScrollMargin?$=-dragScrollSpeed(_e.left-d.clientX):d.clientX+et.right>=_e.right-dragScrollMargin&&($=dragScrollSpeed(d.clientX-_e.right)),d.clientY-et.top<=_e.top+dragScrollMargin?j=-dragScrollSpeed(_e.top-d.clientY):d.clientY+et.bottom>=_e.bottom-dragScrollMargin&&(j=dragScrollSpeed(d.clientY-_e.bottom)),this.setScrollSpeed($,j)}up(d){this.dragging==null&&this.select(this.lastEvent),this.dragging||d.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let d=this.view.contentDOM.ownerDocument;d.removeEventListener("mousemove",this.move),d.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(d,b){this.scrollSpeed={x:d,y:b},d||b?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){this.scrollParent?(this.scrollParent.scrollLeft+=this.scrollSpeed.x,this.scrollParent.scrollTop+=this.scrollSpeed.y):this.view.win.scrollBy(this.scrollSpeed.x,this.scrollSpeed.y),this.dragging===!1&&this.select(this.lastEvent)}skipAtoms(d){let b=null;for(let $=0;$this.select(this.lastEvent),20)}}function addsSelectionRange(g,d){let b=g.state.facet(clickAddsSelectionRange);return b.length?b[0](d):browser.mac?d.metaKey:d.ctrlKey}function dragMovesSelection(g,d){let b=g.state.facet(dragMovesSelection$1);return b.length?b[0](d):browser.mac?!d.altKey:!d.ctrlKey}function isInPrimarySelection(g,d){let{main:b}=g.state.selection;if(b.empty)return!1;let $=getSelection(g.root);if(!$||$.rangeCount==0)return!0;let j=$.getRangeAt(0).getClientRects();for(let _e=0;_e=d.clientX&&et.top<=d.clientY&&et.bottom>=d.clientY)return!0}return!1}function eventBelongsToEditor(g,d){if(!d.bubbles)return!0;if(d.defaultPrevented)return!1;for(let b=d.target,$;b!=g.contentDOM;b=b.parentNode)if(!b||b.nodeType==11||($=ContentView.get(b))&&$.ignoreEvent(d))return!1;return!0}const handlers=Object.create(null),observers=Object.create(null),brokenClipboardAPI=browser.ie&&browser.ie_version<15||browser.ios&&browser.webkit_version<604;function capturePaste(g){let d=g.dom.parentNode;if(!d)return;let b=d.appendChild(document.createElement("textarea"));b.style.cssText="position: fixed; left: -10000px; top: 10px",b.focus(),setTimeout(()=>{g.focus(),b.remove(),doPaste(g,b.value)},50)}function doPaste(g,d){let{state:b}=g,$,j=1,_e=b.toText(d),et=_e.lines==b.selection.ranges.length;if(lastLinewiseCopy!=null&&b.selection.ranges.every(nt=>nt.empty)&&lastLinewiseCopy==_e.toString()){let nt=-1;$=b.changeByRange(rt=>{let it=b.doc.lineAt(rt.from);if(it.from==nt)return{range:rt};nt=it.from;let st=b.toText((et?_e.line(j++).text:d)+b.lineBreak);return{changes:{from:it.from,insert:st},range:EditorSelection.cursor(rt.from+st.length)}})}else et?$=b.changeByRange(nt=>{let rt=_e.line(j++);return{changes:{from:nt.from,to:nt.to,insert:rt.text},range:EditorSelection.cursor(nt.from+rt.length)}}):$=b.replaceSelection(_e);g.dispatch($,{userEvent:"input.paste",scrollIntoView:!0})}observers.scroll=g=>{g.inputState.lastScrollTop=g.scrollDOM.scrollTop,g.inputState.lastScrollLeft=g.scrollDOM.scrollLeft};handlers.keydown=(g,d)=>(g.inputState.setSelectionOrigin("select"),d.keyCode==27&&(g.inputState.lastEscPress=Date.now()),!1);observers.touchstart=(g,d)=>{g.inputState.lastTouchTime=Date.now(),g.inputState.setSelectionOrigin("select.pointer")};observers.touchmove=g=>{g.inputState.setSelectionOrigin("select.pointer")};handlers.mousedown=(g,d)=>{if(g.observer.flush(),g.inputState.lastTouchTime>Date.now()-2e3)return!1;let b=null;for(let $ of g.state.facet(mouseSelectionStyle))if(b=$(g,d),b)break;if(!b&&d.button==0&&(b=basicMouseSelection(g,d)),b){let $=!g.hasFocus;g.inputState.startMouseSelection(new MouseSelection(g,d,b,$)),$&&g.observer.ignore(()=>focusPreventScroll(g.contentDOM));let j=g.inputState.mouseSelection;if(j)return j.start(d),j.dragging===!1}return!1};function rangeForClick(g,d,b,$){if($==1)return EditorSelection.cursor(d,b);if($==2)return groupAt(g.state,d,b);{let j=LineView.find(g.docView,d),_e=g.state.doc.lineAt(j?j.posAtEnd:d),et=j?j.posAtStart:_e.from,tt=j?j.posAtEnd:_e.to;return ttg>=d.top&&g<=d.bottom,inside=(g,d,b)=>insideY(d,b)&&g>=b.left&&g<=b.right;function findPositionSide(g,d,b,$){let j=LineView.find(g.docView,d);if(!j)return 1;let _e=d-j.posAtStart;if(_e==0)return 1;if(_e==j.length)return-1;let et=j.coordsAt(_e,-1);if(et&&inside(b,$,et))return-1;let tt=j.coordsAt(_e,1);return tt&&inside(b,$,tt)?1:et&&insideY($,et)?-1:1}function queryPos(g,d){let b=g.posAtCoords({x:d.clientX,y:d.clientY},!1);return{pos:b,bias:findPositionSide(g,b,d.clientX,d.clientY)}}const BadMouseDetail=browser.ie&&browser.ie_version<=11;let lastMouseDown=null,lastMouseDownCount=0,lastMouseDownTime=0;function getClickType(g){if(!BadMouseDetail)return g.detail;let d=lastMouseDown,b=lastMouseDownTime;return lastMouseDown=g,lastMouseDownTime=Date.now(),lastMouseDownCount=!d||b>Date.now()-400&&Math.abs(d.clientX-g.clientX)<2&&Math.abs(d.clientY-g.clientY)<2?(lastMouseDownCount+1)%3:1}function basicMouseSelection(g,d){let b=queryPos(g,d),$=getClickType(d),j=g.state.selection;return{update(_e){_e.docChanged&&(b.pos=_e.changes.mapPos(b.pos),j=j.map(_e.changes))},get(_e,et,tt){let nt=queryPos(g,_e),rt,it=rangeForClick(g,nt.pos,nt.bias,$);if(b.pos!=nt.pos&&!et){let st=rangeForClick(g,b.pos,b.bias,$),ot=Math.min(st.from,it.from),at=Math.max(st.to,it.to);it=ot1&&(rt=removeRangeAround(j,nt.pos))?rt:tt?j.addRange(it):EditorSelection.create([it])}}}function removeRangeAround(g,d){for(let b=0;b=d)return EditorSelection.create(g.ranges.slice(0,b).concat(g.ranges.slice(b+1)),g.mainIndex==b?0:g.mainIndex-(g.mainIndex>b?1:0))}return null}handlers.dragstart=(g,d)=>{let{selection:{main:b}}=g.state;if(d.target.draggable){let j=g.docView.nearest(d.target);if(j&&j.isWidget){let _e=j.posAtStart,et=_e+j.length;(_e>=b.to||et<=b.from)&&(b=EditorSelection.range(_e,et))}}let{inputState:$}=g;return $.mouseSelection&&($.mouseSelection.dragging=!0),$.draggedContent=b,d.dataTransfer&&(d.dataTransfer.setData("Text",g.state.sliceDoc(b.from,b.to)),d.dataTransfer.effectAllowed="copyMove"),!1};handlers.dragend=g=>(g.inputState.draggedContent=null,!1);function dropText(g,d,b,$){if(!b)return;let j=g.posAtCoords({x:d.clientX,y:d.clientY},!1),{draggedContent:_e}=g.inputState,et=$&&_e&&dragMovesSelection(g,d)?{from:_e.from,to:_e.to}:null,tt={from:j,insert:b},nt=g.state.changes(et?[et,tt]:tt);g.focus(),g.dispatch({changes:nt,selection:{anchor:nt.mapPos(j,-1),head:nt.mapPos(j,1)},userEvent:et?"move.drop":"input.drop"}),g.inputState.draggedContent=null}handlers.drop=(g,d)=>{if(!d.dataTransfer)return!1;if(g.state.readOnly)return!0;let b=d.dataTransfer.files;if(b&&b.length){let $=Array(b.length),j=0,_e=()=>{++j==b.length&&dropText(g,d,$.filter(et=>et!=null).join(g.state.lineBreak),!1)};for(let et=0;et{/[\x00-\x08\x0e-\x1f]{2}/.test(tt.result)||($[et]=tt.result),_e()},tt.readAsText(b[et])}return!0}else{let $=d.dataTransfer.getData("Text");if($)return dropText(g,d,$,!0),!0}return!1};handlers.paste=(g,d)=>{if(g.state.readOnly)return!0;g.observer.flush();let b=brokenClipboardAPI?null:d.clipboardData;return b?(doPaste(g,b.getData("text/plain")||b.getData("text/uri-text")),!0):(capturePaste(g),!1)};function captureCopy(g,d){let b=g.dom.parentNode;if(!b)return;let $=b.appendChild(document.createElement("textarea"));$.style.cssText="position: fixed; left: -10000px; top: 10px",$.value=d,$.focus(),$.selectionEnd=d.length,$.selectionStart=0,setTimeout(()=>{$.remove(),g.focus()},50)}function copiedRange(g){let d=[],b=[],$=!1;for(let j of g.selection.ranges)j.empty||(d.push(g.sliceDoc(j.from,j.to)),b.push(j));if(!d.length){let j=-1;for(let{from:_e}of g.selection.ranges){let et=g.doc.lineAt(_e);et.number>j&&(d.push(et.text),b.push({from:et.from,to:Math.min(g.doc.length,et.to+1)})),j=et.number}$=!0}return{text:d.join(g.lineBreak),ranges:b,linewise:$}}let lastLinewiseCopy=null;handlers.copy=handlers.cut=(g,d)=>{let{text:b,ranges:$,linewise:j}=copiedRange(g.state);if(!b&&!j)return!1;lastLinewiseCopy=j?b:null,d.type=="cut"&&!g.state.readOnly&&g.dispatch({changes:$,scrollIntoView:!0,userEvent:"delete.cut"});let _e=brokenClipboardAPI?null:d.clipboardData;return _e?(_e.clearData(),_e.setData("text/plain",b),!0):(captureCopy(g,b),!1)};const isFocusChange=Annotation.define();function focusChangeTransaction(g,d){let b=[];for(let $ of g.facet(focusChangeEffect)){let j=$(g,d);j&&b.push(j)}return b?g.update({effects:b,annotations:isFocusChange.of(!0)}):null}function updateForFocusChange(g){setTimeout(()=>{let d=g.hasFocus;if(d!=g.inputState.notifiedFocused){let b=focusChangeTransaction(g.state,d);b?g.dispatch(b):g.update([])}},10)}observers.focus=g=>{g.inputState.lastFocusTime=Date.now(),!g.scrollDOM.scrollTop&&(g.inputState.lastScrollTop||g.inputState.lastScrollLeft)&&(g.scrollDOM.scrollTop=g.inputState.lastScrollTop,g.scrollDOM.scrollLeft=g.inputState.lastScrollLeft),updateForFocusChange(g)};observers.blur=g=>{g.observer.clearSelectionRange(),updateForFocusChange(g)};observers.compositionstart=observers.compositionupdate=g=>{g.inputState.compositionFirstChange==null&&(g.inputState.compositionFirstChange=!0),g.inputState.composing<0&&(g.inputState.composing=0)};observers.compositionend=g=>{g.inputState.composing=-1,g.inputState.compositionEndedAt=Date.now(),g.inputState.compositionPendingKey=!0,g.inputState.compositionPendingChange=g.observer.pendingRecords().length>0,g.inputState.compositionFirstChange=null,browser.chrome&&browser.android?g.observer.flushSoon():g.inputState.compositionPendingChange?Promise.resolve().then(()=>g.observer.flush()):setTimeout(()=>{g.inputState.composing<0&&g.docView.hasComposition&&g.update([])},50)};observers.contextmenu=g=>{g.inputState.lastContextMenu=Date.now()};handlers.beforeinput=(g,d)=>{var b;let $;if(browser.chrome&&browser.android&&($=PendingKeys.find(j=>j.inputType==d.inputType))&&(g.observer.delayAndroidKey($.key,$.keyCode),$.key=="Backspace"||$.key=="Delete")){let j=((b=window.visualViewport)===null||b===void 0?void 0:b.height)||0;setTimeout(()=>{var _e;(((_e=window.visualViewport)===null||_e===void 0?void 0:_e.height)||0)>j+10&&g.hasFocus&&(g.contentDOM.blur(),g.focus())},100)}return!1};const appliedFirefoxHack=new Set;function firefoxCopyCutHack(g){appliedFirefoxHack.has(g)||(appliedFirefoxHack.add(g),g.addEventListener("copy",()=>{}),g.addEventListener("cut",()=>{}))}const wrappingWhiteSpace=["pre-wrap","normal","pre-line","break-spaces"];class HeightOracle{constructor(d){this.lineWrapping=d,this.doc=Text.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30,this.heightChanged=!1}heightForGap(d,b){let $=this.doc.lineAt(b).number-this.doc.lineAt(d).number+1;return this.lineWrapping&&($+=Math.max(0,Math.ceil((b-d-$*this.lineLength*.5)/this.lineLength))),this.lineHeight*$}heightForLine(d){return this.lineWrapping?(1+Math.max(0,Math.ceil((d-this.lineLength)/(this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(d){return this.doc=d,this}mustRefreshForWrapping(d){return wrappingWhiteSpace.indexOf(d)>-1!=this.lineWrapping}mustRefreshForHeights(d){let b=!1;for(let $=0;$-1,nt=Math.round(b)!=Math.round(this.lineHeight)||this.lineWrapping!=tt;if(this.lineWrapping=tt,this.lineHeight=b,this.charWidth=$,this.textHeight=j,this.lineLength=_e,nt){this.heightSamples={};for(let rt=0;rt0}set outdated(d){this.flags=(d?2:0)|this.flags&-3}setHeight(d,b){this.height!=b&&(Math.abs(this.height-b)>Epsilon&&(d.heightChanged=!0),this.height=b)}replace(d,b,$){return HeightMap.of($)}decomposeLeft(d,b){b.push(this)}decomposeRight(d,b){b.push(this)}applyChanges(d,b,$,j){let _e=this,et=$.doc;for(let tt=j.length-1;tt>=0;tt--){let{fromA:nt,toA:rt,fromB:it,toB:st}=j[tt],ot=_e.lineAt(nt,QueryType$1.ByPosNoHeight,$.setDoc(b),0,0),at=ot.to>=rt?ot:_e.lineAt(rt,QueryType$1.ByPosNoHeight,$,0,0);for(st+=at.to-rt,rt=at.to;tt>0&&ot.from<=j[tt-1].toA;)nt=j[tt-1].fromA,it=j[tt-1].fromB,tt--,nt_e*2){let tt=d[b-1];tt.break?d.splice(--b,1,tt.left,null,tt.right):d.splice(--b,1,tt.left,tt.right),$+=1+tt.break,j-=tt.size}else if(_e>j*2){let tt=d[$];tt.break?d.splice($,1,tt.left,null,tt.right):d.splice($,1,tt.left,tt.right),$+=2+tt.break,_e-=tt.size}else break;else if(j<_e){let tt=d[b++];tt&&(j+=tt.size)}else{let tt=d[--$];tt&&(_e+=tt.size)}let et=0;return d[b-1]==null?(et=1,b--):d[b]==null&&(et=1,$++),new HeightMapBranch(HeightMap.of(d.slice(0,b)),et,HeightMap.of(d.slice($)))}}HeightMap.prototype.size=1;class HeightMapBlock extends HeightMap{constructor(d,b,$){super(d,b),this.deco=$}blockAt(d,b,$,j){return new BlockInfo(j,this.length,$,this.height,this.deco||0)}lineAt(d,b,$,j,_e){return this.blockAt(0,$,j,_e)}forEachLine(d,b,$,j,_e,et){d<=_e+this.length&&b>=_e&&et(this.blockAt(0,$,j,_e))}updateHeight(d,b=0,$=!1,j){return j&&j.from<=b&&j.more&&this.setHeight(d,j.heights[j.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}}class HeightMapText extends HeightMapBlock{constructor(d,b){super(d,b,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(d,b,$,j){return new BlockInfo(j,this.length,$,this.height,this.breaks)}replace(d,b,$){let j=$[0];return $.length==1&&(j instanceof HeightMapText||j instanceof HeightMapGap&&j.flags&4)&&Math.abs(this.length-j.length)<10?(j instanceof HeightMapGap?j=new HeightMapText(j.length,this.height):j.height=this.height,this.outdated||(j.outdated=!1),j):HeightMap.of($)}updateHeight(d,b=0,$=!1,j){return j&&j.from<=b&&j.more?this.setHeight(d,j.heights[j.index++]):($||this.outdated)&&this.setHeight(d,Math.max(this.widgetHeight,d.heightForLine(this.length-this.collapsed))+this.breaks*d.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class HeightMapGap extends HeightMap{constructor(d){super(d,0)}heightMetrics(d,b){let $=d.doc.lineAt(b).number,j=d.doc.lineAt(b+this.length).number,_e=j-$+1,et,tt=0;if(d.lineWrapping){let nt=Math.min(this.height,d.lineHeight*_e);et=nt/_e,this.length>_e+1&&(tt=(this.height-nt)/(this.length-_e-1))}else et=this.height/_e;return{firstLine:$,lastLine:j,perLine:et,perChar:tt}}blockAt(d,b,$,j){let{firstLine:_e,lastLine:et,perLine:tt,perChar:nt}=this.heightMetrics(b,j);if(b.lineWrapping){let rt=j+Math.round(Math.max(0,Math.min(1,(d-$)/this.height))*this.length),it=b.doc.lineAt(rt),st=tt+it.length*nt,ot=Math.max($,d-st/2);return new BlockInfo(it.from,it.length,ot,st,0)}else{let rt=Math.max(0,Math.min(et-_e,Math.floor((d-$)/tt))),{from:it,length:st}=b.doc.line(_e+rt);return new BlockInfo(it,st,$+tt*rt,tt,0)}}lineAt(d,b,$,j,_e){if(b==QueryType$1.ByHeight)return this.blockAt(d,$,j,_e);if(b==QueryType$1.ByPosNoHeight){let{from:at,to:ut}=$.doc.lineAt(d);return new BlockInfo(at,ut-at,0,0,0)}let{firstLine:et,perLine:tt,perChar:nt}=this.heightMetrics($,_e),rt=$.doc.lineAt(d),it=tt+rt.length*nt,st=rt.number-et,ot=j+tt*st+nt*(rt.from-_e-st);return new BlockInfo(rt.from,rt.length,Math.max(j,Math.min(ot,j+this.height-it)),it,0)}forEachLine(d,b,$,j,_e,et){d=Math.max(d,_e),b=Math.min(b,_e+this.length);let{firstLine:tt,perLine:nt,perChar:rt}=this.heightMetrics($,_e);for(let it=d,st=j;it<=b;){let ot=$.doc.lineAt(it);if(it==d){let ut=ot.number-tt;st+=nt*ut+rt*(d-_e-ut)}let at=nt+rt*ot.length;et(new BlockInfo(ot.from,ot.length,st,at,0)),st+=at,it=ot.to+1}}replace(d,b,$){let j=this.length-b;if(j>0){let _e=$[$.length-1];_e instanceof HeightMapGap?$[$.length-1]=new HeightMapGap(_e.length+j):$.push(null,new HeightMapGap(j-1))}if(d>0){let _e=$[0];_e instanceof HeightMapGap?$[0]=new HeightMapGap(d+_e.length):$.unshift(new HeightMapGap(d-1),null)}return HeightMap.of($)}decomposeLeft(d,b){b.push(new HeightMapGap(d-1),null)}decomposeRight(d,b){b.push(null,new HeightMapGap(this.length-d-1))}updateHeight(d,b=0,$=!1,j){let _e=b+this.length;if(j&&j.from<=b+this.length&&j.more){let et=[],tt=Math.max(b,j.from),nt=-1;for(j.from>b&&et.push(new HeightMapGap(j.from-b-1).updateHeight(d,b));tt<=_e&&j.more;){let it=d.doc.lineAt(tt).length;et.length&&et.push(null);let st=j.heights[j.index++];nt==-1?nt=st:Math.abs(st-nt)>=Epsilon&&(nt=-2);let ot=new HeightMapText(it,st);ot.outdated=!1,et.push(ot),tt+=it+1}tt<=_e&&et.push(null,new HeightMapGap(_e-tt).updateHeight(d,tt));let rt=HeightMap.of(et);return(nt<0||Math.abs(rt.height-this.height)>=Epsilon||Math.abs(nt-this.heightMetrics(d,b).perLine)>=Epsilon)&&(d.heightChanged=!0),rt}else($||this.outdated)&&(this.setHeight(d,d.heightForGap(b,b+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class HeightMapBranch extends HeightMap{constructor(d,b,$){super(d.length+b+$.length,d.height+$.height,b|(d.outdated||$.outdated?2:0)),this.left=d,this.right=$,this.size=d.size+$.size}get break(){return this.flags&1}blockAt(d,b,$,j){let _e=$+this.left.height;return d<_e?this.left.blockAt(d,b,$,j):this.right.blockAt(d,b,_e,j+this.left.length+this.break)}lineAt(d,b,$,j,_e){let et=j+this.left.height,tt=_e+this.left.length+this.break,nt=b==QueryType$1.ByHeight?dtt))return rt;let it=b==QueryType$1.ByPosNoHeight?QueryType$1.ByPosNoHeight:QueryType$1.ByPos;return nt?rt.join(this.right.lineAt(tt,it,$,et,tt)):this.left.lineAt(tt,it,$,j,_e).join(rt)}forEachLine(d,b,$,j,_e,et){let tt=j+this.left.height,nt=_e+this.left.length+this.break;if(this.break)d=nt&&this.right.forEachLine(d,b,$,tt,nt,et);else{let rt=this.lineAt(nt,QueryType$1.ByPos,$,j,_e);d=d&&rt.from<=b&&et(rt),b>rt.to&&this.right.forEachLine(rt.to+1,b,$,tt,nt,et)}}replace(d,b,$){let j=this.left.length+this.break;if(bthis.left.length)return this.balanced(this.left,this.right.replace(d-j,b-j,$));let _e=[];d>0&&this.decomposeLeft(d,_e);let et=_e.length;for(let tt of $)_e.push(tt);if(d>0&&mergeGaps(_e,et-1),b=$&&b.push(null)),d>$&&this.right.decomposeLeft(d-$,b)}decomposeRight(d,b){let $=this.left.length,j=$+this.break;if(d>=j)return this.right.decomposeRight(d-j,b);d<$&&this.left.decomposeRight(d,b),this.break&&d2*b.size||b.size>2*d.size?HeightMap.of(this.break?[d,null,b]:[d,b]):(this.left=d,this.right=b,this.height=d.height+b.height,this.outdated=d.outdated||b.outdated,this.size=d.size+b.size,this.length=d.length+this.break+b.length,this)}updateHeight(d,b=0,$=!1,j){let{left:_e,right:et}=this,tt=b+_e.length+this.break,nt=null;return j&&j.from<=b+_e.length&&j.more?nt=_e=_e.updateHeight(d,b,$,j):_e.updateHeight(d,b,$),j&&j.from<=tt+et.length&&j.more?nt=et=et.updateHeight(d,tt,$,j):et.updateHeight(d,tt,$),nt?this.balanced(_e,et):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function mergeGaps(g,d){let b,$;g[d]==null&&(b=g[d-1])instanceof HeightMapGap&&($=g[d+1])instanceof HeightMapGap&&g.splice(d-1,3,new HeightMapGap(b.length+1+$.length))}const relevantWidgetHeight=5;class NodeBuilder{constructor(d,b){this.pos=d,this.oracle=b,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=d}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(d,b){if(this.lineStart>-1){let $=Math.min(b,this.lineEnd),j=this.nodes[this.nodes.length-1];j instanceof HeightMapText?j.length+=$-this.pos:($>this.pos||!this.isCovered)&&this.nodes.push(new HeightMapText($-this.pos,-1)),this.writtenTo=$,b>$&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=b}point(d,b,$){if(d=relevantWidgetHeight)&&this.addLineDeco(j,_e,et)}else b>d&&this.span(d,b);this.lineEnd>-1&&this.lineEnd-1)return;let{from:d,to:b}=this.oracle.doc.lineAt(this.pos);this.lineStart=d,this.lineEnd=b,this.writtenTod&&this.nodes.push(new HeightMapText(this.pos-d,-1)),this.writtenTo=this.pos}blankContent(d,b){let $=new HeightMapGap(b-d);return this.oracle.doc.lineAt(d).to==b&&($.flags|=4),$}ensureLine(){this.enterLine();let d=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(d instanceof HeightMapText)return d;let b=new HeightMapText(0,-1);return this.nodes.push(b),b}addBlock(d){this.enterLine();let b=d.deco;b&&b.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(d),this.writtenTo=this.pos=this.pos+d.length,b&&b.endSide>0&&(this.covering=d)}addLineDeco(d,b,$){let j=this.ensureLine();j.length+=$,j.collapsed+=$,j.widgetHeight=Math.max(j.widgetHeight,d),j.breaks+=b,this.writtenTo=this.pos=this.pos+$}finish(d){let b=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(b instanceof HeightMapText)&&!this.isCovered?this.nodes.push(new HeightMapText(0,-1)):(this.writtenToit.clientHeight||it.scrollWidth>it.clientWidth)&&st.overflow!="visible"){let ot=it.getBoundingClientRect();_e=Math.max(_e,ot.left),et=Math.min(et,ot.right),tt=Math.max(tt,ot.top),nt=rt==g.parentNode?ot.bottom:Math.min(nt,ot.bottom)}rt=st.position=="absolute"||st.position=="fixed"?it.offsetParent:it.parentNode}else if(rt.nodeType==11)rt=rt.host;else break;return{left:_e-b.left,right:Math.max(_e,et)-b.left,top:tt-(b.top+d),bottom:Math.max(tt,nt)-(b.top+d)}}function fullPixelRange(g,d){let b=g.getBoundingClientRect();return{left:0,right:b.right-b.left,top:d,bottom:b.bottom-(b.top+d)}}class LineGap{constructor(d,b,$){this.from=d,this.to=b,this.size=$}static same(d,b){if(d.length!=b.length)return!1;for(let $=0;$typeof $!="function"&&$.class=="cm-lineWrapping");this.heightOracle=new HeightOracle(b),this.stateDeco=d.facet(decorations).filter($=>typeof $!="function"),this.heightMap=HeightMap.empty().applyChanges(this.stateDeco,Text.empty,this.heightOracle.setDoc(d.doc),[new ChangedRange(0,0,0,d.doc.length)]),this.viewport=this.getViewport(0,null),this.updateViewportLines(),this.updateForViewport(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=Decoration.set(this.lineGaps.map($=>$.draw(this,!1))),this.computeVisibleRanges()}updateForViewport(){let d=[this.viewport],{main:b}=this.state.selection;for(let $=0;$<=1;$++){let j=$?b.head:b.anchor;if(!d.some(({from:_e,to:et})=>j>=_e&&j<=et)){let{from:_e,to:et}=this.lineBlockAt(j);d.push(new Viewport(_e,et))}}this.viewports=d.sort(($,j)=>$.from-j.from),this.scaler=this.heightMap.height<=7e6?IdScaler:new BigScaler(this.heightOracle,this.heightMap,this.viewports)}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,d=>{this.viewportLines.push(this.scaler.scale==1?d:scaleBlock(d,this.scaler))})}update(d,b=null){this.state=d.state;let $=this.stateDeco;this.stateDeco=this.state.facet(decorations).filter(it=>typeof it!="function");let j=d.changedRanges,_e=ChangedRange.extendWithRanges(j,heightRelevantDecoChanges($,this.stateDeco,d?d.changes:ChangeSet.empty(this.state.doc.length))),et=this.heightMap.height,tt=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);this.heightMap=this.heightMap.applyChanges(this.stateDeco,d.startState.doc,this.heightOracle.setDoc(this.state.doc),_e),this.heightMap.height!=et&&(d.flags|=2),tt?(this.scrollAnchorPos=d.changes.mapPos(tt.from,-1),this.scrollAnchorHeight=tt.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=this.heightMap.height);let nt=_e.length?this.mapViewport(this.viewport,d.changes):this.viewport;(b&&(b.range.headnt.to)||!this.viewportIsAppropriate(nt))&&(nt=this.getViewport(0,b));let rt=!d.changes.empty||d.flags&2||nt.from!=this.viewport.from||nt.to!=this.viewport.to;this.viewport=nt,this.updateForViewport(),rt&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,d.changes))),d.flags|=this.computeVisibleRanges(),b&&(this.scrollTarget=b),!this.mustEnforceCursorAssoc&&d.selectionSet&&d.view.lineWrapping&&d.state.selection.main.empty&&d.state.selection.main.assoc&&!d.state.facet(nativeSelectionHidden)&&(this.mustEnforceCursorAssoc=!0)}measure(d){let b=d.contentDOM,$=window.getComputedStyle(b),j=this.heightOracle,_e=$.whiteSpace;this.defaultTextDirection=$.direction=="rtl"?Direction.RTL:Direction.LTR;let et=this.heightOracle.mustRefreshForWrapping(_e),tt=b.getBoundingClientRect(),nt=et||this.mustMeasureContent||this.contentDOMHeight!=tt.height;this.contentDOMHeight=tt.height,this.mustMeasureContent=!1;let rt=0,it=0;if(tt.width&&tt.height){let{scaleX:yt,scaleY:vt}=getScale(b,tt);(this.scaleX!=yt||this.scaleY!=vt)&&(this.scaleX=yt,this.scaleY=vt,rt|=8,et=nt=!0)}let st=(parseInt($.paddingTop)||0)*this.scaleY,ot=(parseInt($.paddingBottom)||0)*this.scaleY;(this.paddingTop!=st||this.paddingBottom!=ot)&&(this.paddingTop=st,this.paddingBottom=ot,rt|=10),this.editorWidth!=d.scrollDOM.clientWidth&&(j.lineWrapping&&(nt=!0),this.editorWidth=d.scrollDOM.clientWidth,rt|=8);let at=d.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=at&&(this.scrollAnchorHeight=-1,this.scrollTop=at),this.scrolledToBottom=isScrolledToBottom(d.scrollDOM);let ut=(this.printing?fullPixelRange:visiblePixelRange)(b,this.paddingTop),ct=ut.top-this.pixelViewport.top,dt=ut.bottom-this.pixelViewport.bottom;this.pixelViewport=ut;let ht=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(ht!=this.inView&&(this.inView=ht,ht&&(nt=!0)),!this.inView&&!this.scrollTarget)return 0;let pt=tt.width;if((this.contentDOMWidth!=pt||this.editorHeight!=d.scrollDOM.clientHeight)&&(this.contentDOMWidth=tt.width,this.editorHeight=d.scrollDOM.clientHeight,rt|=8),nt){let yt=d.docView.measureVisibleLineHeights(this.viewport);if(j.mustRefreshForHeights(yt)&&(et=!0),et||j.lineWrapping&&Math.abs(pt-this.contentDOMWidth)>j.charWidth){let{lineHeight:vt,charWidth:St,textHeight:xt}=d.docView.measureTextSize();et=vt>0&&j.refresh(_e,vt,St,xt,pt/St,yt),et&&(d.docView.minWidth=0,rt|=8)}ct>0&&dt>0?it=Math.max(ct,dt):ct<0&&dt<0&&(it=Math.min(ct,dt)),j.heightChanged=!1;for(let vt of this.viewports){let St=vt.from==this.viewport.from?yt:d.docView.measureVisibleLineHeights(vt);this.heightMap=(et?HeightMap.empty().applyChanges(this.stateDeco,Text.empty,this.heightOracle,[new ChangedRange(0,0,0,d.state.doc.length)]):this.heightMap).updateHeight(j,0,et,new MeasuredHeights(vt.from,St))}j.heightChanged&&(rt|=2)}let gt=!this.viewportIsAppropriate(this.viewport,it)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return gt&&(this.viewport=this.getViewport(it,this.scrollTarget)),this.updateForViewport(),(rt&2||gt)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(et?[]:this.lineGaps,d)),rt|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,d.docView.enforceCursorAssoc()),rt}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(d,b){let $=.5-Math.max(-.5,Math.min(.5,d/1e3/2)),j=this.heightMap,_e=this.heightOracle,{visibleTop:et,visibleBottom:tt}=this,nt=new Viewport(j.lineAt(et-$*1e3,QueryType$1.ByHeight,_e,0,0).from,j.lineAt(tt+(1-$)*1e3,QueryType$1.ByHeight,_e,0,0).to);if(b){let{head:rt}=b.range;if(rtnt.to){let it=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),st=j.lineAt(rt,QueryType$1.ByPos,_e,0,0),ot;b.y=="center"?ot=(st.top+st.bottom)/2-it/2:b.y=="start"||b.y=="nearest"&&rt=tt+Math.max(10,Math.min($,250)))&&j>et-2*1e3&&_e>1,et=j<<1;if(this.defaultTextDirection!=Direction.LTR&&!$)return[];let tt=[],nt=(rt,it,st,ot)=>{if(it-rt<_e)return;let at=this.state.selection.main,ut=[at.from];at.empty||ut.push(at.to);for(let dt of ut)if(dt>rt&&dtdt.from>=st.from&&dt.to<=st.to&&Math.abs(dt.from-rt)<_e&&Math.abs(dt.to-it)<_e&&!ut.some(ht=>dt.fromht));if(!ct){if(itdt.from<=it&&dt.to>=it)){let dt=b.moveToLineBoundary(EditorSelection.cursor(it),!1,!0).head;dt>rt&&(it=dt)}ct=new LineGap(rt,it,this.gapSize(st,rt,it,ot))}tt.push(ct)};for(let rt of this.viewportLines){if(rt.lengthrt.from&&nt(rt.from,ot,rt,it),atb.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(){let d=this.stateDeco;this.lineGaps.length&&(d=d.concat(this.lineGapDeco));let b=[];RangeSet.spans(d,this.viewport.from,this.viewport.to,{span(j,_e){b.push({from:j,to:_e})},point(){}},20);let $=b.length!=this.visibleRanges.length||this.visibleRanges.some((j,_e)=>j.from!=b[_e].from||j.to!=b[_e].to);return this.visibleRanges=b,$?4:0}lineBlockAt(d){return d>=this.viewport.from&&d<=this.viewport.to&&this.viewportLines.find(b=>b.from<=d&&b.to>=d)||scaleBlock(this.heightMap.lineAt(d,QueryType$1.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(d){return scaleBlock(this.heightMap.lineAt(this.scaler.fromDOM(d),QueryType$1.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(d){let b=this.lineBlockAtHeight(d+8);return b.from>=this.viewport.from||this.viewportLines[0].top-d>200?b:this.viewportLines[0]}elementAtHeight(d){return scaleBlock(this.heightMap.blockAt(this.scaler.fromDOM(d),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class Viewport{constructor(d,b){this.from=d,this.to=b}}function lineStructure(g,d,b){let $=[],j=g,_e=0;return RangeSet.spans(b,g,d,{span(){},point(et,tt){et>j&&($.push({from:j,to:et}),_e+=et-j),j=tt}},20),j=1)return d[d.length-1].to;let $=Math.floor(g*b);for(let j=0;;j++){let{from:_e,to:et}=d[j],tt=et-_e;if($<=tt)return _e+$;$-=tt}}function findFraction(g,d){let b=0;for(let{from:$,to:j}of g.ranges){if(d<=j){b+=d-$;break}b+=j-$}return b/g.total}function find$3(g,d){for(let b of g)if(d(b))return b}const IdScaler={toDOM(g){return g},fromDOM(g){return g},scale:1};class BigScaler{constructor(d,b,$){let j=0,_e=0,et=0;this.viewports=$.map(({from:tt,to:nt})=>{let rt=b.lineAt(tt,QueryType$1.ByPos,d,0,0).top,it=b.lineAt(nt,QueryType$1.ByPos,d,0,0).bottom;return j+=it-rt,{from:tt,to:nt,top:rt,bottom:it,domTop:0,domBottom:0}}),this.scale=(7e6-j)/(b.height-j);for(let tt of this.viewports)tt.domTop=et+(tt.top-_e)*this.scale,et=tt.domBottom=tt.domTop+(tt.bottom-tt.top),_e=tt.bottom}toDOM(d){for(let b=0,$=0,j=0;;b++){let _e=bscaleBlock(j,d)):g._content)}const theme=Facet.define({combine:g=>g.join(" ")}),darkTheme=Facet.define({combine:g=>g.indexOf(!0)>-1}),baseThemeID=StyleModule.newName(),baseLightID=StyleModule.newName(),baseDarkID=StyleModule.newName(),lightDarkIDs={"&light":"."+baseLightID,"&dark":"."+baseDarkID};function buildTheme(g,d,b){return new StyleModule(d,{finish($){return/&/.test($)?$.replace(/&\w*/,j=>{if(j=="&")return g;if(!b||!b[j])throw new RangeError(`Unsupported selector: ${j}`);return b[j]}):g+" "+$}})}const baseTheme$1$3=buildTheme("."+baseThemeID,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#444"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",insetInlineStart:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",borderRight:"1px solid #ddd"},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top"},".cm-highlightSpace:before":{content:"attr(data-display)",position:"absolute",pointerEvents:"none",color:"#888"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},lightDarkIDs),LineBreakPlaceholder="￿";class DOMReader{constructor(d,b){this.points=d,this.text="",this.lineSeparator=b.facet(EditorState.lineSeparator)}append(d){this.text+=d}lineBreak(){this.text+=LineBreakPlaceholder}readRange(d,b){if(!d)return this;let $=d.parentNode;for(let j=d;;){this.findPointBefore($,j);let _e=this.text.length;this.readNode(j);let et=j.nextSibling;if(et==b)break;let tt=ContentView.get(j),nt=ContentView.get(et);(tt&&nt?tt.breakAfter:(tt?tt.breakAfter:isBlockElement(j))||isBlockElement(et)&&(j.nodeName!="BR"||j.cmIgnore)&&this.text.length>_e)&&this.lineBreak(),j=et}return this.findPointBefore($,b),this}readTextNode(d){let b=d.nodeValue;for(let $ of this.points)$.node==d&&($.pos=this.text.length+Math.min($.offset,b.length));for(let $=0,j=this.lineSeparator?null:/\r\n?|\n/g;;){let _e=-1,et=1,tt;if(this.lineSeparator?(_e=b.indexOf(this.lineSeparator,$),et=this.lineSeparator.length):(tt=j.exec(b))&&(_e=tt.index,et=tt[0].length),this.append(b.slice($,_e<0?b.length:_e)),_e<0)break;if(this.lineBreak(),et>1)for(let nt of this.points)nt.node==d&&nt.pos>this.text.length&&(nt.pos-=et-1);$=_e+et}}readNode(d){if(d.cmIgnore)return;let b=ContentView.get(d),$=b&&b.overrideDOMText;if($!=null){this.findPointInside(d,$.length);for(let j=$.iter();!j.next().done;)j.lineBreak?this.lineBreak():this.append(j.value)}else d.nodeType==3?this.readTextNode(d):d.nodeName=="BR"?d.nextSibling&&this.lineBreak():d.nodeType==1&&this.readRange(d.firstChild,null)}findPointBefore(d,b){for(let $ of this.points)$.node==d&&d.childNodes[$.offset]==b&&($.pos=this.text.length)}findPointInside(d,b){for(let $ of this.points)(d.nodeType==3?$.node==d:d.contains($.node))&&($.pos=this.text.length+(isAtEnd(d,$.node,$.offset)?b:0))}}function isAtEnd(g,d,b){for(;;){if(!d||b-1)this.newSel=null;else if(b>-1&&(this.bounds=d.docView.domBoundsAround(b,$,0))){let tt=_e||et?[]:selectionPoints(d),nt=new DOMReader(tt,d.state);nt.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=nt.text,this.newSel=selectionFromPoints(tt,this.bounds.from)}else{let tt=d.observer.selectionRange,nt=_e&&_e.node==tt.focusNode&&_e.offset==tt.focusOffset||!contains(d.contentDOM,tt.focusNode)?d.state.selection.main.head:d.docView.posFromDOM(tt.focusNode,tt.focusOffset),rt=et&&et.node==tt.anchorNode&&et.offset==tt.anchorOffset||!contains(d.contentDOM,tt.anchorNode)?d.state.selection.main.anchor:d.docView.posFromDOM(tt.anchorNode,tt.anchorOffset),it=d.viewport;if(browser.ios&&d.state.selection.main.empty&&nt!=rt&&(it.from>0||it.toDate.now()-100?g.inputState.lastKeyCode:-1;if(d.bounds){let{from:et,to:tt}=d.bounds,nt=j.from,rt=null;(_e===8||browser.android&&d.text.length=j.from&&b.to<=j.to&&(b.from!=j.from||b.to!=j.to)&&j.to-j.from-(b.to-b.from)<=4?b={from:j.from,to:j.to,insert:g.state.doc.slice(j.from,b.from).append(b.insert).append(g.state.doc.slice(b.to,j.to))}:(browser.mac||browser.android)&&b&&b.from==b.to&&b.from==j.head-1&&/^\. ?$/.test(b.insert.toString())&&g.contentDOM.getAttribute("autocorrect")=="off"?($&&b.insert.length==2&&($=EditorSelection.single($.main.anchor-1,$.main.head-1)),b={from:j.from,to:j.to,insert:Text.of([" "])}):browser.chrome&&b&&b.from==b.to&&b.from==j.head&&b.insert.toString()==` + `&&g.lineWrapping&&($&&($=EditorSelection.single($.main.anchor-1,$.main.head-1)),b={from:j.from,to:j.to,insert:Text.of([" "])}),b){if(browser.ios&&g.inputState.flushIOSKey()||browser.android&&(b.from==j.from&&b.to==j.to&&b.insert.length==1&&b.insert.lines==2&&dispatchKey(g.contentDOM,"Enter",13)||(b.from==j.from-1&&b.to==j.to&&b.insert.length==0||_e==8&&b.insert.lengthj.head)&&dispatchKey(g.contentDOM,"Backspace",8)||b.from==j.from&&b.to==j.to+1&&b.insert.length==0&&dispatchKey(g.contentDOM,"Delete",46)))return!0;let et=b.insert.toString();g.inputState.composing>=0&&g.inputState.composing++;let tt,nt=()=>tt||(tt=applyDefaultInsert(g,b,$));return g.state.facet(inputHandler$1).some(rt=>rt(g,b.from,b.to,et,nt))||g.dispatch(nt()),!0}else if($&&!$.main.eq(j)){let et=!1,tt="select";return g.inputState.lastSelectionTime>Date.now()-50&&(g.inputState.lastSelectionOrigin=="select"&&(et=!0),tt=g.inputState.lastSelectionOrigin),g.dispatch({selection:$,scrollIntoView:et,userEvent:tt}),!0}else return!1}function applyDefaultInsert(g,d,b){let $,j=g.state,_e=j.selection.main;if(d.from>=_e.from&&d.to<=_e.to&&d.to-d.from>=(_e.to-_e.from)/3&&(!b||b.main.empty&&b.main.from==d.from+d.insert.length)&&g.inputState.composing<0){let tt=_e.fromd.to?j.sliceDoc(d.to,_e.to):"";$=j.replaceSelection(g.state.toText(tt+d.insert.sliceString(0,void 0,g.state.lineBreak)+nt))}else{let tt=j.changes(d),nt=b&&b.main.to<=tt.newLength?b.main:void 0;if(j.selection.ranges.length>1&&g.inputState.composing>=0&&d.to<=_e.to&&d.to>=_e.to-10){let rt=g.state.sliceDoc(d.from,d.to),it,st=b&&findCompositionNode(g,b.main.head);if(st){let ut=d.insert.length-(d.to-d.from);it={from:st.from,to:st.to-ut}}else it=g.state.doc.lineAt(_e.head);let ot=_e.to-d.to,at=_e.to-_e.from;$=j.changeByRange(ut=>{if(ut.from==_e.from&&ut.to==_e.to)return{changes:tt,range:nt||ut.map(tt)};let ct=ut.to-ot,dt=ct-rt.length;if(ut.to-ut.from!=at||g.state.sliceDoc(dt,ct)!=rt||ut.to>=it.from&&ut.from<=it.to)return{range:ut};let ht=j.changes({from:dt,to:ct,insert:d.insert}),pt=ut.to-_e.to;return{changes:ht,range:nt?EditorSelection.range(Math.max(0,nt.anchor+pt),Math.max(0,nt.head+pt)):ut.map(ht)}})}else $={changes:tt,selection:nt&&j.selection.replaceRange(nt)}}let et="input.type";return(g.composing||g.inputState.compositionPendingChange&&g.inputState.compositionEndedAt>Date.now()-50)&&(g.inputState.compositionPendingChange=!1,et+=".compose",g.inputState.compositionFirstChange&&(et+=".start",g.inputState.compositionFirstChange=!1)),j.update($,{userEvent:et,scrollIntoView:!0})}function findDiff(g,d,b,$){let j=Math.min(g.length,d.length),_e=0;for(;_e0&&tt>0&&g.charCodeAt(et-1)==d.charCodeAt(tt-1);)et--,tt--;if($=="end"){let nt=Math.max(0,_e-Math.min(et,tt));b-=et+nt-_e}if(et<_e&&g.length=et?_e-b:0;_e-=nt,tt=_e+(tt-et),et=_e}else if(tt<_e){let nt=b<=_e&&b>=tt?_e-b:0;_e-=nt,et=_e+(et-tt),tt=_e}return{from:_e,toA:et,toB:tt}}function selectionPoints(g){let d=[];if(g.root.activeElement!=g.contentDOM)return d;let{anchorNode:b,anchorOffset:$,focusNode:j,focusOffset:_e}=g.observer.selectionRange;return b&&(d.push(new DOMPoint(b,$)),(j!=b||_e!=$)&&d.push(new DOMPoint(j,_e))),d}function selectionFromPoints(g,d){if(g.length==0)return null;let b=g[0].pos,$=g.length==2?g[1].pos:b;return b>-1&&$>-1?EditorSelection.single(b+d,$+d):null}const observeOptions={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},useCharData=browser.ie&&browser.ie_version<=11;class DOMObserver{constructor(d){this.view=d,this.active=!1,this.selectionRange=new DOMSelectionState,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.parentCheck=-1,this.dom=d.contentDOM,this.observer=new MutationObserver(b=>{for(let $ of b)this.queue.push($);(browser.ie&&browser.ie_version<=11||browser.ios&&d.composing)&&b.some($=>$.type=="childList"&&$.removedNodes.length||$.type=="characterData"&&$.oldValue.length>$.target.nodeValue.length)?this.flushSoon():this.flush()}),useCharData&&(this.onCharData=b=>{this.queue.push({target:b.target,type:"characterData",oldValue:b.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var b;((b=this.view.docView)===null||b===void 0?void 0:b.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),b.length>0&&b[b.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(b=>{b.length>0&&b[b.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(d){this.view.inputState.runHandlers("scroll",d),this.intersecting&&this.view.measure()}onScroll(d){this.intersecting&&this.flush(!1),this.onScrollChanged(d)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(){this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500)}updateGaps(d){if(this.gapIntersection&&(d.length!=this.gaps.length||this.gaps.some((b,$)=>b!=d[$]))){this.gapIntersection.disconnect();for(let b of d)this.gapIntersection.observe(b);this.gaps=d}}onSelectionChange(d){let b=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:$}=this,j=this.selectionRange;if($.state.facet(editable)?$.root.activeElement!=this.dom:!hasSelection($.dom,j))return;let _e=j.anchorNode&&$.docView.nearest(j.anchorNode);if(_e&&_e.ignoreEvent(d)){b||(this.selectionChanged=!1);return}(browser.ie&&browser.ie_version<=11||browser.android&&browser.chrome)&&!$.state.selection.main.empty&&j.focusNode&&isEquivalentPosition(j.focusNode,j.focusOffset,j.anchorNode,j.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:d}=this,b=browser.safari&&d.root.nodeType==11&&deepActiveElement(this.dom.ownerDocument)==this.dom&&safariSelectionRangeHack(this.view)||getSelection(d.root);if(!b||this.selectionRange.eq(b))return!1;let $=hasSelection(this.dom,b);return $&&!this.selectionChanged&&d.inputState.lastFocusTime>Date.now()-200&&d.inputState.lastTouchTime{let _e=this.delayedAndroidKey;_e&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=_e.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&_e.force&&dispatchKey(this.dom,_e.key,_e.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(j)}(!this.delayedAndroidKey||d=="Enter")&&(this.delayedAndroidKey={key:d,keyCode:b,force:this.lastChange{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let d of this.observer.takeRecords())this.queue.push(d);return this.queue}processRecords(){let d=this.pendingRecords();d.length&&(this.queue=[]);let b=-1,$=-1,j=!1;for(let _e of d){let et=this.readMutation(_e);et&&(et.typeOver&&(j=!0),b==-1?{from:b,to:$}=et:(b=Math.min(et.from,b),$=Math.max(et.to,$)))}return{from:b,to:$,typeOver:j}}readChange(){let{from:d,to:b,typeOver:$}=this.processRecords(),j=this.selectionChanged&&hasSelection(this.dom,this.selectionRange);if(d<0&&!j)return null;d>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let _e=new DOMChange(this.view,d,b,$);return this.view.docView.domChanged={newSel:_e.newSel?_e.newSel.main:null},_e}flush(d=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;d&&this.readSelectionRange();let b=this.readChange();if(!b)return this.view.requestMeasure(),!1;let $=this.view.state,j=applyDOMChange(this.view,b);return this.view.state==$&&this.view.update([]),j}readMutation(d){let b=this.view.docView.nearest(d.target);if(!b||b.ignoreMutation(d))return null;if(b.markDirty(d.type=="attributes"),d.type=="attributes"&&(b.flags|=4),d.type=="childList"){let $=findChild(b,d.previousSibling||d.target.previousSibling,-1),j=findChild(b,d.nextSibling||d.target.nextSibling,1);return{from:$?b.posAfter($):b.posAtStart,to:j?b.posBefore(j):b.posAtEnd,typeOver:!1}}else return d.type=="characterData"?{from:b.posAtStart,to:b.posAtEnd,typeOver:d.target.nodeValue==d.oldValue}:null}setWindow(d){d!=this.win&&(this.removeWindowListeners(this.win),this.win=d,this.addWindowListeners(this.win))}addWindowListeners(d){d.addEventListener("resize",this.onResize),d.addEventListener("beforeprint",this.onPrint),d.addEventListener("scroll",this.onScroll),d.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(d){d.removeEventListener("scroll",this.onScroll),d.removeEventListener("resize",this.onResize),d.removeEventListener("beforeprint",this.onPrint),d.document.removeEventListener("selectionchange",this.onSelectionChange)}destroy(){var d,b,$;this.stop(),(d=this.intersection)===null||d===void 0||d.disconnect(),(b=this.gapIntersection)===null||b===void 0||b.disconnect(),($=this.resizeScroll)===null||$===void 0||$.disconnect();for(let j of this.scrollTargets)j.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey)}}function findChild(g,d,b){for(;d;){let $=ContentView.get(d);if($&&$.parent==g)return $;let j=d.parentNode;d=j!=g.dom?j:b>0?d.nextSibling:d.previousSibling}return null}function safariSelectionRangeHack(g){let d=null;function b(nt){nt.preventDefault(),nt.stopImmediatePropagation(),d=nt.getTargetRanges()[0]}if(g.contentDOM.addEventListener("beforeinput",b,!0),g.dom.ownerDocument.execCommand("indent"),g.contentDOM.removeEventListener("beforeinput",b,!0),!d)return null;let $=d.startContainer,j=d.startOffset,_e=d.endContainer,et=d.endOffset,tt=g.docView.domAtPos(g.state.selection.main.anchor);return isEquivalentPosition(tt.node,tt.offset,_e,et)&&([$,j,_e,et]=[_e,et,$,j]),{anchorNode:$,anchorOffset:j,focusNode:_e,focusOffset:et}}class EditorView{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return this.inputState.composing>0}get compositionStarted(){return this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(d={}){this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),d.parent&&d.parent.appendChild(this.dom);let{dispatch:b}=d;this.dispatchTransactions=d.dispatchTransactions||b&&($=>$.forEach(j=>b(j,this)))||($=>this.update($)),this.dispatch=this.dispatch.bind(this),this._root=d.root||getRoot(d.parent)||document,this.viewState=new ViewState(d.state||EditorState.create(d)),d.scrollTo&&d.scrollTo.is(scrollIntoView$1)&&(this.viewState.scrollTarget=d.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(viewPlugin).map($=>new PluginInstance($));for(let $ of this.plugins)$.update(this);this.observer=new DOMObserver(this),this.inputState=new InputState(this),this.inputState.ensureHandlers(this.plugins),this.docView=new DocView(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure()}dispatch(...d){let b=d.length==1&&d[0]instanceof Transaction?d:d.length==1&&Array.isArray(d[0])?d[0]:[this.state.update(...d)];this.dispatchTransactions(b,this)}update(d){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let b=!1,$=!1,j,_e=this.state;for(let ot of d){if(ot.startState!=_e)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");_e=ot.state}if(this.destroyed){this.viewState.state=_e;return}let et=this.hasFocus,tt=0,nt=null;d.some(ot=>ot.annotation(isFocusChange))?(this.inputState.notifiedFocused=et,tt=1):et!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=et,nt=focusChangeTransaction(_e,et),nt||(tt=1));let rt=this.observer.delayedAndroidKey,it=null;if(rt?(this.observer.clearDelayedAndroidKey(),it=this.observer.readChange(),(it&&!this.state.doc.eq(_e.doc)||!this.state.selection.eq(_e.selection))&&(it=null)):this.observer.clear(),_e.facet(EditorState.phrases)!=this.state.facet(EditorState.phrases))return this.setState(_e);j=ViewUpdate.create(this,_e,d),j.flags|=tt;let st=this.viewState.scrollTarget;try{this.updateState=2;for(let ot of d){if(st&&(st=st.map(ot.changes)),ot.scrollIntoView){let{main:at}=ot.state.selection;st=new ScrollTarget(at.empty?at:EditorSelection.cursor(at.head,at.head>at.anchor?-1:1))}for(let at of ot.effects)at.is(scrollIntoView$1)&&(st=at.value.clip(this.state))}this.viewState.update(j,st),this.bidiCache=CachedOrder.update(this.bidiCache,j.changes),j.empty||(this.updatePlugins(j),this.inputState.update(j)),b=this.docView.update(j),this.state.facet(styleModule)!=this.styleModules&&this.mountStyles(),$=this.updateAttrs(),this.showAnnouncements(d),this.docView.updateSelection(b,d.some(ot=>ot.isUserEvent("select.pointer")))}finally{this.updateState=0}if(j.startState.facet(theme)!=j.state.facet(theme)&&(this.viewState.mustMeasureContent=!0),(b||$||st||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),!j.empty)for(let ot of this.state.facet(updateListener))try{ot(j)}catch(at){logException(this.state,at,"update listener")}(nt||it)&&Promise.resolve().then(()=>{nt&&this.state==nt.startState&&this.dispatch(nt),it&&!applyDOMChange(this,it)&&rt.force&&dispatchKey(this.contentDOM,rt.key,rt.keyCode)})}setState(d){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=d;return}this.updateState=2;let b=this.hasFocus;try{for(let $ of this.plugins)$.destroy(this);this.viewState=new ViewState(d),this.plugins=d.facet(viewPlugin).map($=>new PluginInstance($)),this.pluginMap.clear();for(let $ of this.plugins)$.update(this);this.docView.destroy(),this.docView=new DocView(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}b&&this.focus(),this.requestMeasure()}updatePlugins(d){let b=d.startState.facet(viewPlugin),$=d.state.facet(viewPlugin);if(b!=$){let j=[];for(let _e of $){let et=b.indexOf(_e);if(et<0)j.push(new PluginInstance(_e));else{let tt=this.plugins[et];tt.mustUpdate=d,j.push(tt)}}for(let _e of this.plugins)_e.mustUpdate!=d&&_e.destroy(this);this.plugins=j,this.pluginMap.clear()}else for(let j of this.plugins)j.mustUpdate=d;for(let j=0;j-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,d&&this.observer.forceFlush();let b=null,$=this.scrollDOM,j=$.scrollTop*this.scaleY,{scrollAnchorPos:_e,scrollAnchorHeight:et}=this.viewState;Math.abs(j-this.viewState.scrollTop)>1&&(et=-1),this.viewState.scrollAnchorHeight=-1;try{for(let tt=0;;tt++){if(et<0)if(isScrolledToBottom($))_e=-1,et=this.viewState.heightMap.height;else{let at=this.viewState.scrollAnchorAt(j);_e=at.from,et=at.top}this.updateState=1;let nt=this.viewState.measure(this);if(!nt&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(tt>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let rt=[];nt&4||([this.measureRequests,rt]=[rt,this.measureRequests]);let it=rt.map(at=>{try{return at.read(this)}catch(ut){return logException(this.state,ut),BadMeasure}}),st=ViewUpdate.create(this,this.state,[]),ot=!1;st.flags|=nt,b?b.flags|=nt:b=st,this.updateState=2,st.empty||(this.updatePlugins(st),this.inputState.update(st),this.updateAttrs(),ot=this.docView.update(st));for(let at=0;at1||ut<-1){j=j+ut,$.scrollTop=j/this.scaleY,et=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(b&&!b.empty)for(let tt of this.state.facet(updateListener))tt(b)}get themeClasses(){return baseThemeID+" "+(this.state.facet(darkTheme)?baseDarkID:baseLightID)+" "+this.state.facet(theme)}updateAttrs(){let d=attrsFromFacet(this,editorAttributes,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),b={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(editable)?"true":"false",class:"cm-content",style:`${browser.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(b["aria-readonly"]="true"),attrsFromFacet(this,contentAttributes,b);let $=this.observer.ignore(()=>{let j=updateAttrs(this.contentDOM,this.contentAttrs,b),_e=updateAttrs(this.dom,this.editorAttrs,d);return j||_e});return this.editorAttrs=d,this.contentAttrs=b,$}showAnnouncements(d){let b=!0;for(let $ of d)for(let j of $.effects)if(j.is(EditorView.announce)){b&&(this.announceDOM.textContent=""),b=!1;let _e=this.announceDOM.appendChild(document.createElement("div"));_e.textContent=j.value}}mountStyles(){this.styleModules=this.state.facet(styleModule);let d=this.state.facet(EditorView.cspNonce);StyleModule.mount(this.root,this.styleModules.concat(baseTheme$1$3).reverse(),d?{nonce:d}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(d){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),d){if(this.measureRequests.indexOf(d)>-1)return;if(d.key!=null){for(let b=0;b$.spec==d)||null),b&&b.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(d){return this.readMeasured(),this.viewState.elementAtHeight(d)}lineBlockAtHeight(d){return this.readMeasured(),this.viewState.lineBlockAtHeight(d)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(d){return this.viewState.lineBlockAt(d)}get contentHeight(){return this.viewState.contentHeight}moveByChar(d,b,$){return skipAtoms(this,d,moveByChar(this,d,b,$))}moveByGroup(d,b){return skipAtoms(this,d,moveByChar(this,d,b,$=>byGroup(this,d.head,$)))}visualLineSide(d,b){let $=this.bidiSpans(d),j=this.textDirectionAt(d.from),_e=$[b?$.length-1:0];return EditorSelection.cursor(_e.side(b,j)+d.from,_e.forward(!b,j)?1:-1)}moveToLineBoundary(d,b,$=!0){return moveToLineBoundary(this,d,b,$)}moveVertically(d,b,$){return skipAtoms(this,d,moveVertically(this,d,b,$))}domAtPos(d){return this.docView.domAtPos(d)}posAtDOM(d,b=0){return this.docView.posFromDOM(d,b)}posAtCoords(d,b=!0){return this.readMeasured(),posAtCoords(this,d,b)}coordsAtPos(d,b=1){this.readMeasured();let $=this.docView.coordsAt(d,b);if(!$||$.left==$.right)return $;let j=this.state.doc.lineAt(d),_e=this.bidiSpans(j),et=_e[BidiSpan.find(_e,d-j.from,-1,b)];return flattenRect($,et.dir==Direction.LTR==b>0)}coordsForChar(d){return this.readMeasured(),this.docView.coordsForChar(d)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(d){return!this.state.facet(perLineTextDirection)||dthis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(d))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(d){if(d.length>MaxBidiLine)return trivialOrder(d.length);let b=this.textDirectionAt(d.from),$;for(let _e of this.bidiCache)if(_e.from==d.from&&_e.dir==b&&(_e.fresh||isolatesEq(_e.isolates,$=getIsolatedRanges(this,d))))return _e.order;$||($=getIsolatedRanges(this,d));let j=computeOrder(d.text,b,$);return this.bidiCache.push(new CachedOrder(d.from,d.to,b,$,!0,j)),j}get hasFocus(){var d;return(this.dom.ownerDocument.hasFocus()||browser.safari&&((d=this.inputState)===null||d===void 0?void 0:d.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{focusPreventScroll(this.contentDOM),this.docView.updateSelection()})}setRoot(d){this._root!=d&&(this._root=d,this.observer.setWindow((d.nodeType==9?d:d.ownerDocument).defaultView||window),this.mountStyles())}destroy(){for(let d of this.plugins)d.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(d,b={}){return scrollIntoView$1.of(new ScrollTarget(typeof d=="number"?EditorSelection.cursor(d):d,b.y,b.x,b.yMargin,b.xMargin))}scrollSnapshot(){let{scrollTop:d,scrollLeft:b}=this.scrollDOM,$=this.viewState.scrollAnchorAt(d);return scrollIntoView$1.of(new ScrollTarget(EditorSelection.cursor($.from),"start","start",$.top-d,b,!0))}static domEventHandlers(d){return ViewPlugin.define(()=>({}),{eventHandlers:d})}static domEventObservers(d){return ViewPlugin.define(()=>({}),{eventObservers:d})}static theme(d,b){let $=StyleModule.newName(),j=[theme.of($),styleModule.of(buildTheme(`.${$}`,d))];return b&&b.dark&&j.push(darkTheme.of(!0)),j}static baseTheme(d){return Prec.lowest(styleModule.of(buildTheme("."+baseThemeID,d,lightDarkIDs)))}static findFromDOM(d){var b;let $=d.querySelector(".cm-content"),j=$&&ContentView.get($)||ContentView.get(d);return((b=j==null?void 0:j.rootView)===null||b===void 0?void 0:b.view)||null}}EditorView.styleModule=styleModule;EditorView.inputHandler=inputHandler$1;EditorView.focusChangeEffect=focusChangeEffect;EditorView.perLineTextDirection=perLineTextDirection;EditorView.exceptionSink=exceptionSink;EditorView.updateListener=updateListener;EditorView.editable=editable;EditorView.mouseSelectionStyle=mouseSelectionStyle;EditorView.dragMovesSelection=dragMovesSelection$1;EditorView.clickAddsSelectionRange=clickAddsSelectionRange;EditorView.decorations=decorations;EditorView.outerDecorations=outerDecorations;EditorView.atomicRanges=atomicRanges;EditorView.bidiIsolatedRanges=bidiIsolatedRanges;EditorView.scrollMargins=scrollMargins;EditorView.darkTheme=darkTheme;EditorView.cspNonce=Facet.define({combine:g=>g.length?g[0]:""});EditorView.contentAttributes=contentAttributes;EditorView.editorAttributes=editorAttributes;EditorView.lineWrapping=EditorView.contentAttributes.of({class:"cm-lineWrapping"});EditorView.announce=StateEffect.define();const MaxBidiLine=4096,BadMeasure={};class CachedOrder{constructor(d,b,$,j,_e,et){this.from=d,this.to=b,this.dir=$,this.isolates=j,this.fresh=_e,this.order=et}static update(d,b){if(b.empty&&!d.some(_e=>_e.fresh))return d;let $=[],j=d.length?d[d.length-1].dir:Direction.LTR;for(let _e=Math.max(0,d.length-10);_e=0;j--){let _e=$[j],et=typeof _e=="function"?_e(g):_e;et&&combineAttrs(et,b)}return b}const currentPlatform=browser.mac?"mac":browser.windows?"win":browser.linux?"linux":"key";function normalizeKeyName(g,d){const b=g.split(/-(?!$)/);let $=b[b.length-1];$=="Space"&&($=" ");let j,_e,et,tt;for(let nt=0;nt$.concat(j),[]))),b}function runScopeHandlers(g,d,b){return runHandlers(getKeymap(g.state),d,g,b)}let storedPrefix=null;const PrefixTimeout=4e3;function buildKeymap(g,d=currentPlatform){let b=Object.create(null),$=Object.create(null),j=(et,tt)=>{let nt=$[et];if(nt==null)$[et]=tt;else if(nt!=tt)throw new Error("Key binding "+et+" is used both as a regular binding and as a multi-stroke prefix")},_e=(et,tt,nt,rt,it)=>{var st,ot;let at=b[et]||(b[et]=Object.create(null)),ut=tt.split(/ (?!$)/).map(ht=>normalizeKeyName(ht,d));for(let ht=1;ht{let yt=storedPrefix={view:gt,prefix:pt,scope:et};return setTimeout(()=>{storedPrefix==yt&&(storedPrefix=null)},PrefixTimeout),!0}]})}let ct=ut.join(" ");j(ct,!1);let dt=at[ct]||(at[ct]={preventDefault:!1,stopPropagation:!1,run:((ot=(st=at._any)===null||st===void 0?void 0:st.run)===null||ot===void 0?void 0:ot.slice())||[]});nt&&dt.run.push(nt),rt&&(dt.preventDefault=!0),it&&(dt.stopPropagation=!0)};for(let et of g){let tt=et.scope?et.scope.split(" "):["editor"];if(et.any)for(let rt of tt){let it=b[rt]||(b[rt]=Object.create(null));it._any||(it._any={preventDefault:!1,stopPropagation:!1,run:[]});for(let st in it)it[st].run.push(et.any)}let nt=et[d]||et.key;if(nt)for(let rt of tt)_e(rt,nt,et.run,et.preventDefault,et.stopPropagation),et.shift&&_e(rt,"Shift-"+nt,et.shift,et.preventDefault,et.stopPropagation)}return b}function runHandlers(g,d,b,$){let j=keyName(d),_e=codePointAt(j,0),et=codePointSize(_e)==j.length&&j!=" ",tt="",nt=!1,rt=!1,it=!1;storedPrefix&&storedPrefix.view==b&&storedPrefix.scope==$&&(tt=storedPrefix.prefix+" ",modifierCodes.indexOf(d.keyCode)<0&&(rt=!0,storedPrefix=null));let st=new Set,ot=dt=>{if(dt){for(let ht of dt.run)if(!st.has(ht)&&(st.add(ht),ht(b,d)))return dt.stopPropagation&&(it=!0),!0;dt.preventDefault&&(dt.stopPropagation&&(it=!0),rt=!0)}return!1},at=g[$],ut,ct;return at&&(ot(at[tt+modifiers(j,d,!et)])?nt=!0:et&&(d.altKey||d.metaKey||d.ctrlKey)&&!(browser.windows&&d.ctrlKey&&d.altKey)&&(ut=base[d.keyCode])&&ut!=j?(ot(at[tt+modifiers(ut,d,!0)])||d.shiftKey&&(ct=shift[d.keyCode])!=j&&ct!=ut&&ot(at[tt+modifiers(ct,d,!1)]))&&(nt=!0):et&&d.shiftKey&&ot(at[tt+modifiers(j,d,!0)])&&(nt=!0),!nt&&ot(at._any)&&(nt=!0)),rt&&(nt=!0),nt&&it&&d.stopPropagation(),nt}class RectangleMarker{constructor(d,b,$,j,_e){this.className=d,this.left=b,this.top=$,this.width=j,this.height=_e}draw(){let d=document.createElement("div");return d.className=this.className,this.adjust(d),d}update(d,b){return b.className!=this.className?!1:(this.adjust(d),!0)}adjust(d){d.style.left=this.left+"px",d.style.top=this.top+"px",this.width!=null&&(d.style.width=this.width+"px"),d.style.height=this.height+"px"}eq(d){return this.left==d.left&&this.top==d.top&&this.width==d.width&&this.height==d.height&&this.className==d.className}static forRange(d,b,$){if($.empty){let j=d.coordsAtPos($.head,$.assoc||1);if(!j)return[];let _e=getBase(d);return[new RectangleMarker(b,j.left-_e.left,j.top-_e.top,null,j.bottom-j.top)]}else return rectanglesForRange(d,b,$)}}function getBase(g){let d=g.scrollDOM.getBoundingClientRect();return{left:(g.textDirection==Direction.LTR?d.left:d.right-g.scrollDOM.clientWidth*g.scaleX)-g.scrollDOM.scrollLeft*g.scaleX,top:d.top-g.scrollDOM.scrollTop*g.scaleY}}function wrappedLine(g,d,b){let $=EditorSelection.cursor(d);return{from:Math.max(b.from,g.moveToLineBoundary($,!1,!0).from),to:Math.min(b.to,g.moveToLineBoundary($,!0,!0).from),type:BlockType.Text}}function rectanglesForRange(g,d,b){if(b.to<=g.viewport.from||b.from>=g.viewport.to)return[];let $=Math.max(b.from,g.viewport.from),j=Math.min(b.to,g.viewport.to),_e=g.textDirection==Direction.LTR,et=g.contentDOM,tt=et.getBoundingClientRect(),nt=getBase(g),rt=et.querySelector(".cm-line"),it=rt&&window.getComputedStyle(rt),st=tt.left+(it?parseInt(it.paddingLeft)+Math.min(0,parseInt(it.textIndent)):0),ot=tt.right-(it?parseInt(it.paddingRight):0),at=blockAt(g,$),ut=blockAt(g,j),ct=at.type==BlockType.Text?at:null,dt=ut.type==BlockType.Text?ut:null;if(ct&&(g.lineWrapping||at.widgetLineBreaks)&&(ct=wrappedLine(g,$,ct)),dt&&(g.lineWrapping||ut.widgetLineBreaks)&&(dt=wrappedLine(g,j,dt)),ct&&dt&&ct.from==dt.from)return pt(gt(b.from,b.to,ct));{let vt=ct?gt(b.from,null,ct):yt(at,!1),St=dt?gt(null,b.to,dt):yt(ut,!0),xt=[];return(ct||at).to<(dt||ut).from-(ct&&dt?1:0)||at.widgetLineBreaks>1&&vt.bottom+g.defaultLineHeight/2Tt&&Ft.from=Wt)break;It>Vt&&wt(Math.max(Lt,Vt),vt==null&&Lt<=Tt,Math.min(It,Wt),St==null&&It>=Bt,Ot.dir)}if(Vt=Ht.to+1,Vt>=Wt)break}return Ct.length==0&&wt(Tt,vt==null,Bt,St==null,g.textDirection),{top:Dt,bottom:Pt,horizontal:Ct}}function yt(vt,St){let xt=tt.top+(St?vt.top:vt.bottom);return{top:xt,bottom:xt,horizontal:[]}}}function sameMarker(g,d){return g.constructor==d.constructor&&g.eq(d)}class LayerView{constructor(d,b){this.view=d,this.layer=b,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=d.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),b.above&&this.dom.classList.add("cm-layer-above"),b.class&&this.dom.classList.add(b.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(d.state),d.requestMeasure(this.measureReq),b.mount&&b.mount(this.dom,d)}update(d){d.startState.facet(layerOrder)!=d.state.facet(layerOrder)&&this.setOrder(d.state),(this.layer.update(d,this.dom)||d.geometryChanged)&&(this.scale(),d.view.requestMeasure(this.measureReq))}setOrder(d){let b=0,$=d.facet(layerOrder);for(;b<$.length&&$[b]!=this.layer;)b++;this.dom.style.zIndex=String((this.layer.above?150:-1)-b)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:d,scaleY:b}=this.view;(d!=this.scaleX||b!=this.scaleY)&&(this.scaleX=d,this.scaleY=b,this.dom.style.transform=`scale(${1/d}, ${1/b})`)}draw(d){if(d.length!=this.drawn.length||d.some((b,$)=>!sameMarker(b,this.drawn[$]))){let b=this.dom.firstChild,$=0;for(let j of d)j.update&&b&&j.constructor&&this.drawn[$].constructor&&j.update(b,this.drawn[$])?(b=b.nextSibling,$++):this.dom.insertBefore(j.draw(),b);for(;b;){let j=b.nextSibling;b.remove(),b=j}this.drawn=d}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const layerOrder=Facet.define();function layer(g){return[ViewPlugin.define(d=>new LayerView(d,g)),layerOrder.of(g)]}const CanHidePrimary=!browser.ios,selectionConfig=Facet.define({combine(g){return combineConfig(g,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(d,b)=>Math.min(d,b),drawRangeCursor:(d,b)=>d||b})}});function drawSelection(g={}){return[selectionConfig.of(g),cursorLayer,selectionLayer,hideNativeSelection,nativeSelectionHidden.of(!0)]}function configChanged(g){return g.startState.facet(selectionConfig)!=g.state.facet(selectionConfig)}const cursorLayer=layer({above:!0,markers(g){let{state:d}=g,b=d.facet(selectionConfig),$=[];for(let j of d.selection.ranges){let _e=j==d.selection.main;if(j.empty?!_e||CanHidePrimary:b.drawRangeCursor){let et=_e?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",tt=j.empty?j:EditorSelection.cursor(j.head,j.head>j.anchor?-1:1);for(let nt of RectangleMarker.forRange(g,et,tt))$.push(nt)}}return $},update(g,d){g.transactions.some($=>$.selection)&&(d.style.animationName=d.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let b=configChanged(g);return b&&setBlinkRate(g.state,d),g.docChanged||g.selectionSet||b},mount(g,d){setBlinkRate(d.state,g)},class:"cm-cursorLayer"});function setBlinkRate(g,d){d.style.animationDuration=g.facet(selectionConfig).cursorBlinkRate+"ms"}const selectionLayer=layer({above:!1,markers(g){return g.state.selection.ranges.map(d=>d.empty?[]:RectangleMarker.forRange(g,"cm-selectionBackground",d)).reduce((d,b)=>d.concat(b))},update(g,d){return g.docChanged||g.selectionSet||g.viewportChanged||configChanged(g)},class:"cm-selectionLayer"}),themeSpec={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};CanHidePrimary&&(themeSpec[".cm-line"].caretColor="transparent !important",themeSpec[".cm-content"]={caretColor:"transparent !important"});const hideNativeSelection=Prec.highest(EditorView.theme(themeSpec)),setDropCursorPos=StateEffect.define({map(g,d){return g==null?null:d.mapPos(g)}}),dropCursorPos=StateField.define({create(){return null},update(g,d){return g!=null&&(g=d.changes.mapPos(g)),d.effects.reduce((b,$)=>$.is(setDropCursorPos)?$.value:b,g)}}),drawDropCursor=ViewPlugin.fromClass(class{constructor(g){this.view=g,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(g){var d;let b=g.state.field(dropCursorPos);b==null?this.cursor!=null&&((d=this.cursor)===null||d===void 0||d.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(g.startState.field(dropCursorPos)!=b||g.docChanged||g.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:g}=this,d=g.state.field(dropCursorPos),b=d!=null&&g.coordsAtPos(d);if(!b)return null;let $=g.scrollDOM.getBoundingClientRect();return{left:b.left-$.left+g.scrollDOM.scrollLeft*g.scaleX,top:b.top-$.top+g.scrollDOM.scrollTop*g.scaleY,height:b.bottom-b.top}}drawCursor(g){if(this.cursor){let{scaleX:d,scaleY:b}=this.view;g?(this.cursor.style.left=g.left/d+"px",this.cursor.style.top=g.top/b+"px",this.cursor.style.height=g.height/b+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(g){this.view.state.field(dropCursorPos)!=g&&this.view.dispatch({effects:setDropCursorPos.of(g)})}},{eventObservers:{dragover(g){this.setDropPos(this.view.posAtCoords({x:g.clientX,y:g.clientY}))},dragleave(g){(g.target==this.view.contentDOM||!this.view.contentDOM.contains(g.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function dropCursor(){return[dropCursorPos,drawDropCursor]}function iterMatches(g,d,b,$,j){d.lastIndex=0;for(let _e=g.iterRange(b,$),et=b,tt;!_e.next().done;et+=_e.value.length)if(!_e.lineBreak)for(;tt=d.exec(_e.value);)j(et+tt.index,tt)}function matchRanges(g,d){let b=g.visibleRanges;if(b.length==1&&b[0].from==g.viewport.from&&b[0].to==g.viewport.to)return b;let $=[];for(let{from:j,to:_e}of b)j=Math.max(g.state.doc.lineAt(j).from,j-d),_e=Math.min(g.state.doc.lineAt(_e).to,_e+d),$.length&&$[$.length-1].to>=j?$[$.length-1].to=_e:$.push({from:j,to:_e});return $}class MatchDecorator{constructor(d){const{regexp:b,decoration:$,decorate:j,boundary:_e,maxLength:et=1e3}=d;if(!b.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=b,j)this.addMatch=(tt,nt,rt,it)=>j(it,rt,rt+tt[0].length,tt,nt);else if(typeof $=="function")this.addMatch=(tt,nt,rt,it)=>{let st=$(tt,nt,rt);st&&it(rt,rt+tt[0].length,st)};else if($)this.addMatch=(tt,nt,rt,it)=>it(rt,rt+tt[0].length,$);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=_e,this.maxLength=et}createDeco(d){let b=new RangeSetBuilder,$=b.add.bind(b);for(let{from:j,to:_e}of matchRanges(d,this.maxLength))iterMatches(d.state.doc,this.regexp,j,_e,(et,tt)=>this.addMatch(tt,d,et,$));return b.finish()}updateDeco(d,b){let $=1e9,j=-1;return d.docChanged&&d.changes.iterChanges((_e,et,tt,nt)=>{nt>d.view.viewport.from&&tt1e3?this.createDeco(d.view):j>-1?this.updateRange(d.view,b.map(d.changes),$,j):b}updateRange(d,b,$,j){for(let _e of d.visibleRanges){let et=Math.max(_e.from,$),tt=Math.min(_e.to,j);if(tt>et){let nt=d.state.doc.lineAt(et),rt=nt.tont.from;et--)if(this.boundary.test(nt.text[et-1-nt.from])){it=et;break}for(;ttot.push(ht.range(ct,dt));if(nt==rt)for(this.regexp.lastIndex=it-nt.from;(at=this.regexp.exec(nt.text))&&at.indexthis.addMatch(dt,d,ct,ut));b=b.update({filterFrom:it,filterTo:st,filter:(ct,dt)=>ctst,add:ot})}}return b}}const UnicodeRegexpSupport=/x/.unicode!=null?"gu":"g",Specials=new RegExp(`[\0-\b +--Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\uFEFF-]`,UnicodeRegexpSupport),Names={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let _supportsTabSize=null;function supportsTabSize(){var g;if(_supportsTabSize==null&&typeof document<"u"&&document.body){let d=document.body.style;_supportsTabSize=((g=d.tabSize)!==null&&g!==void 0?g:d.MozTabSize)!=null}return _supportsTabSize||!1}const specialCharConfig=Facet.define({combine(g){let d=combineConfig(g,{render:null,specialChars:Specials,addSpecialChars:null});return(d.replaceTabs=!supportsTabSize())&&(d.specialChars=new RegExp(" |"+d.specialChars.source,UnicodeRegexpSupport)),d.addSpecialChars&&(d.specialChars=new RegExp(d.specialChars.source+"|"+d.addSpecialChars.source,UnicodeRegexpSupport)),d}});function highlightSpecialChars(g={}){return[specialCharConfig.of(g),specialCharPlugin()]}let _plugin=null;function specialCharPlugin(){return _plugin||(_plugin=ViewPlugin.fromClass(class{constructor(g){this.view=g,this.decorations=Decoration.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(g.state.facet(specialCharConfig)),this.decorations=this.decorator.createDeco(g)}makeDecorator(g){return new MatchDecorator({regexp:g.specialChars,decoration:(d,b,$)=>{let{doc:j}=b.state,_e=codePointAt(d[0],0);if(_e==9){let et=j.lineAt($),tt=b.state.tabSize,nt=countColumn(et.text,tt,$-et.from);return Decoration.replace({widget:new TabWidget((tt-nt%tt)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[_e]||(this.decorationCache[_e]=Decoration.replace({widget:new SpecialCharWidget(g,_e)}))},boundary:g.replaceTabs?void 0:/[^]/})}update(g){let d=g.state.facet(specialCharConfig);g.startState.facet(specialCharConfig)!=d?(this.decorator=this.makeDecorator(d),this.decorations=this.decorator.createDeco(g.view)):this.decorations=this.decorator.updateDeco(g,this.decorations)}},{decorations:g=>g.decorations}))}const DefaultPlaceholder="•";function placeholder$1(g){return g>=32?DefaultPlaceholder:g==10?"␤":String.fromCharCode(9216+g)}class SpecialCharWidget extends WidgetType{constructor(d,b){super(),this.options=d,this.code=b}eq(d){return d.code==this.code}toDOM(d){let b=placeholder$1(this.code),$=d.state.phrase("Control character")+" "+(Names[this.code]||"0x"+this.code.toString(16)),j=this.options.render&&this.options.render(this.code,$,b);if(j)return j;let _e=document.createElement("span");return _e.textContent=b,_e.title=$,_e.setAttribute("aria-label",$),_e.className="cm-specialChar",_e}ignoreEvent(){return!1}}class TabWidget extends WidgetType{constructor(d){super(),this.width=d}eq(d){return d.width==this.width}toDOM(){let d=document.createElement("span");return d.textContent=" ",d.className="cm-tab",d.style.width=this.width+"px",d}ignoreEvent(){return!1}}function highlightActiveLine(){return activeLineHighlighter}const lineDeco=Decoration.line({class:"cm-activeLine"}),activeLineHighlighter=ViewPlugin.fromClass(class{constructor(g){this.decorations=this.getDeco(g)}update(g){(g.docChanged||g.selectionSet)&&(this.decorations=this.getDeco(g.view))}getDeco(g){let d=-1,b=[];for(let $ of g.state.selection.ranges){let j=g.lineBlockAt($.head);j.from>d&&(b.push(lineDeco.range(j.from)),d=j.from)}return Decoration.set(b)}},{decorations:g=>g.decorations});class Placeholder extends WidgetType{constructor(d){super(),this.content=d}toDOM(){let d=document.createElement("span");return d.className="cm-placeholder",d.style.pointerEvents="none",d.appendChild(typeof this.content=="string"?document.createTextNode(this.content):this.content),typeof this.content=="string"?d.setAttribute("aria-label","placeholder "+this.content):d.setAttribute("aria-hidden","true"),d}coordsAt(d){let b=d.firstChild?clientRectsFor(d.firstChild):[];if(!b.length)return null;let $=window.getComputedStyle(d.parentNode),j=flattenRect(b[0],$.direction!="rtl"),_e=parseInt($.lineHeight);return j.bottom-j.top>_e*1.5?{left:j.left,right:j.right,top:j.top,bottom:j.top+_e}:j}ignoreEvent(){return!1}}function placeholder(g){return ViewPlugin.fromClass(class{constructor(d){this.view=d,this.placeholder=g?Decoration.set([Decoration.widget({widget:new Placeholder(g),side:1}).range(0)]):Decoration.none}get decorations(){return this.view.state.doc.length?Decoration.none:this.placeholder}},{decorations:d=>d.decorations})}const MaxOff=2e3;function rectangleFor(g,d,b){let $=Math.min(d.line,b.line),j=Math.max(d.line,b.line),_e=[];if(d.off>MaxOff||b.off>MaxOff||d.col<0||b.col<0){let et=Math.min(d.off,b.off),tt=Math.max(d.off,b.off);for(let nt=$;nt<=j;nt++){let rt=g.doc.line(nt);rt.length<=tt&&_e.push(EditorSelection.range(rt.from+et,rt.to+tt))}}else{let et=Math.min(d.col,b.col),tt=Math.max(d.col,b.col);for(let nt=$;nt<=j;nt++){let rt=g.doc.line(nt),it=findColumn(rt.text,et,g.tabSize,!0);if(it<0)_e.push(EditorSelection.cursor(rt.to));else{let st=findColumn(rt.text,tt,g.tabSize);_e.push(EditorSelection.range(rt.from+it,rt.from+st))}}}return _e}function absoluteColumn(g,d){let b=g.coordsAtPos(g.viewport.from);return b?Math.round(Math.abs((b.left-d)/g.defaultCharacterWidth)):-1}function getPos(g,d){let b=g.posAtCoords({x:d.clientX,y:d.clientY},!1),$=g.state.doc.lineAt(b),j=b-$.from,_e=j>MaxOff?-1:j==$.length?absoluteColumn(g,d.clientX):countColumn($.text,g.state.tabSize,b-$.from);return{line:$.number,col:_e,off:j}}function rectangleSelectionStyle(g,d){let b=getPos(g,d),$=g.state.selection;return b?{update(j){if(j.docChanged){let _e=j.changes.mapPos(j.startState.doc.line(b.line).from),et=j.state.doc.lineAt(_e);b={line:et.number,col:b.col,off:Math.min(b.off,et.length)},$=$.map(j.changes)}},get(j,_e,et){let tt=getPos(g,j);if(!tt)return $;let nt=rectangleFor(g.state,b,tt);return nt.length?et?EditorSelection.create(nt.concat($.ranges)):EditorSelection.create(nt):$}}:null}function rectangularSelection(g){let d=(g==null?void 0:g.eventFilter)||(b=>b.altKey&&b.button==0);return EditorView.mouseSelectionStyle.of((b,$)=>d($)?rectangleSelectionStyle(b,$):null)}const keys$1={Alt:[18,g=>!!g.altKey],Control:[17,g=>!!g.ctrlKey],Shift:[16,g=>!!g.shiftKey],Meta:[91,g=>!!g.metaKey]},showCrosshair={style:"cursor: crosshair"};function crosshairCursor(g={}){let[d,b]=keys$1[g.key||"Alt"],$=ViewPlugin.fromClass(class{constructor(j){this.view=j,this.isDown=!1}set(j){this.isDown!=j&&(this.isDown=j,this.view.update([]))}},{eventObservers:{keydown(j){this.set(j.keyCode==d||b(j))},keyup(j){(j.keyCode==d||!b(j))&&this.set(!1)},mousemove(j){this.set(b(j))}}});return[$,EditorView.contentAttributes.of(j=>{var _e;return!((_e=j.plugin($))===null||_e===void 0)&&_e.isDown?showCrosshair:null})]}const Outside="-10000px";class TooltipViewManager{constructor(d,b,$){this.facet=b,this.createTooltipView=$,this.input=d.state.facet(b),this.tooltips=this.input.filter(j=>j),this.tooltipViews=this.tooltips.map($)}update(d,b){var $;let j=d.state.facet(this.facet),_e=j.filter(nt=>nt);if(j===this.input){for(let nt of this.tooltipViews)nt.update&&nt.update(d);return!1}let et=[],tt=b?[]:null;for(let nt=0;nt<_e.length;nt++){let rt=_e[nt],it=-1;if(rt){for(let st=0;stb[rt]=nt),b.length=tt.length),this.input=j,this.tooltips=_e,this.tooltipViews=et,!0}}function windowSpace(g){let{win:d}=g;return{top:0,left:0,bottom:d.innerHeight,right:d.innerWidth}}const tooltipConfig=Facet.define({combine:g=>{var d,b,$;return{position:browser.ios?"absolute":((d=g.find(j=>j.position))===null||d===void 0?void 0:d.position)||"fixed",parent:((b=g.find(j=>j.parent))===null||b===void 0?void 0:b.parent)||null,tooltipSpace:(($=g.find(j=>j.tooltipSpace))===null||$===void 0?void 0:$.tooltipSpace)||windowSpace}}}),knownHeight=new WeakMap,tooltipPlugin=ViewPlugin.fromClass(class{constructor(g){this.view=g,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let d=g.state.facet(tooltipConfig);this.position=d.position,this.parent=d.parent,this.classes=g.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.manager=new TooltipViewManager(g,showTooltip,b=>this.createTooltip(b)),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(b=>{Date.now()>this.lastTransaction-50&&b.length>0&&b[b.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),g.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let g of this.manager.tooltipViews)this.intersectionObserver.observe(g.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(g){g.transactions.length&&(this.lastTransaction=Date.now());let d=this.manager.update(g,this.above);d&&this.observeIntersection();let b=d||g.geometryChanged,$=g.state.facet(tooltipConfig);if($.position!=this.position&&!this.madeAbsolute){this.position=$.position;for(let j of this.manager.tooltipViews)j.dom.style.position=this.position;b=!0}if($.parent!=this.parent){this.parent&&this.container.remove(),this.parent=$.parent,this.createContainer();for(let j of this.manager.tooltipViews)this.container.appendChild(j.dom);b=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);b&&this.maybeMeasure()}createTooltip(g){let d=g.create(this.view);if(d.dom.classList.add("cm-tooltip"),g.arrow&&!d.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let b=document.createElement("div");b.className="cm-tooltip-arrow",d.dom.appendChild(b)}return d.dom.style.position=this.position,d.dom.style.top=Outside,d.dom.style.left="0px",this.container.appendChild(d.dom),d.mount&&d.mount(this.view),d}destroy(){var g,d;this.view.win.removeEventListener("resize",this.measureSoon);for(let b of this.manager.tooltipViews)b.dom.remove(),(g=b.destroy)===null||g===void 0||g.call(b);this.parent&&this.container.remove(),(d=this.intersectionObserver)===null||d===void 0||d.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let g=this.view.dom.getBoundingClientRect(),d=1,b=1,$=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:j}=this.manager.tooltipViews[0];if(browser.gecko)$=j.offsetParent!=this.container.ownerDocument.body;else if(j.style.top==Outside&&j.style.left=="0px"){let _e=j.getBoundingClientRect();$=Math.abs(_e.top+1e4)>1||Math.abs(_e.left)>1}}if($||this.position=="absolute")if(this.parent){let j=this.parent.getBoundingClientRect();j.width&&j.height&&(d=j.width/this.parent.offsetWidth,b=j.height/this.parent.offsetHeight)}else({scaleX:d,scaleY:b}=this.view.viewState);return{editor:g,parent:this.parent?this.container.getBoundingClientRect():g,pos:this.manager.tooltips.map((j,_e)=>{let et=this.manager.tooltipViews[_e];return et.getCoords?et.getCoords(j.pos):this.view.coordsAtPos(j.pos)}),size:this.manager.tooltipViews.map(({dom:j})=>j.getBoundingClientRect()),space:this.view.state.facet(tooltipConfig).tooltipSpace(this.view),scaleX:d,scaleY:b,makeAbsolute:$}}writeMeasure(g){var d;if(g.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let tt of this.manager.tooltipViews)tt.dom.style.position="absolute"}let{editor:b,space:$,scaleX:j,scaleY:_e}=g,et=[];for(let tt=0;tt=Math.min(b.bottom,$.bottom)||st.rightMath.min(b.right,$.right)+.1){it.style.top=Outside;continue}let at=nt.arrow?rt.dom.querySelector(".cm-tooltip-arrow"):null,ut=at?7:0,ct=ot.right-ot.left,dt=(d=knownHeight.get(rt))!==null&&d!==void 0?d:ot.bottom-ot.top,ht=rt.offset||noOffset,pt=this.view.textDirection==Direction.LTR,gt=ot.width>$.right-$.left?pt?$.left:$.right-ot.width:pt?Math.min(st.left-(at?14:0)+ht.x,$.right-ct):Math.max($.left,st.left-ct+(at?14:0)-ht.x),yt=this.above[tt];!nt.strictSide&&(yt?st.top-(ot.bottom-ot.top)-ht.y<$.top:st.bottom+(ot.bottom-ot.top)+ht.y>$.bottom)&&yt==$.bottom-st.bottom>st.top-$.top&&(yt=this.above[tt]=!yt);let vt=(yt?st.top-$.top:$.bottom-st.bottom)-ut;if(vtgt&&Dt.topSt&&(St=yt?Dt.top-dt-2-ut:Dt.bottom+ut+2);if(this.position=="absolute"?(it.style.top=(St-g.parent.top)/_e+"px",it.style.left=(gt-g.parent.left)/j+"px"):(it.style.top=St/_e+"px",it.style.left=gt/j+"px"),at){let Dt=st.left+(pt?ht.x:-ht.x)-(gt+14-7);at.style.left=Dt/j+"px"}rt.overlap!==!0&&et.push({left:gt,top:St,right:xt,bottom:St+dt}),it.classList.toggle("cm-tooltip-above",yt),it.classList.toggle("cm-tooltip-below",!yt),rt.positioned&&rt.positioned(g.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let g of this.manager.tooltipViews)g.dom.style.top=Outside}},{eventObservers:{scroll(){this.maybeMeasure()}}}),baseTheme$4=EditorView.baseTheme({".cm-tooltip":{zIndex:100,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:`${7*2}px`,position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),noOffset={x:0,y:0},showTooltip=Facet.define({enables:[tooltipPlugin,baseTheme$4]}),showHoverTooltip=Facet.define();class HoverTooltipHost{static create(d){return new HoverTooltipHost(d)}constructor(d){this.view=d,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new TooltipViewManager(d,showHoverTooltip,b=>this.createHostedView(b))}createHostedView(d){let b=d.create(this.view);return b.dom.classList.add("cm-tooltip-section"),this.dom.appendChild(b.dom),this.mounted&&b.mount&&b.mount(this.view),b}mount(d){for(let b of this.manager.tooltipViews)b.mount&&b.mount(d);this.mounted=!0}positioned(d){for(let b of this.manager.tooltipViews)b.positioned&&b.positioned(d)}update(d){this.manager.update(d)}destroy(){var d;for(let b of this.manager.tooltipViews)(d=b.destroy)===null||d===void 0||d.call(b)}passProp(d){let b;for(let $ of this.manager.tooltipViews){let j=$[d];if(j!==void 0){if(b===void 0)b=j;else if(b!==j)return}}return b}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const showHoverTooltipHost=showTooltip.compute([showHoverTooltip],g=>{let d=g.facet(showHoverTooltip).filter(b=>b);return d.length===0?null:{pos:Math.min(...d.map(b=>b.pos)),end:Math.max(...d.map(b=>{var $;return($=b.end)!==null&&$!==void 0?$:b.pos})),create:HoverTooltipHost.create,above:d[0].above,arrow:d.some(b=>b.arrow)}});class HoverPlugin{constructor(d,b,$,j,_e){this.view=d,this.source=b,this.field=$,this.setHover=j,this.hoverTime=_e,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:d.dom,time:0},this.checkHover=this.checkHover.bind(this),d.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),d.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active)return;let d=Date.now()-this.lastMove.time;dtt.bottom||b.xtt.right+d.defaultCharacterWidth)return;let nt=d.bidiSpans(d.state.doc.lineAt(j)).find(it=>it.from<=j&&it.to>=j),rt=nt&&nt.dir==Direction.RTL?-1:1;_e=b.x{this.pending==tt&&(this.pending=null,nt&&d.dispatch({effects:this.setHover.of(nt)}))},nt=>logException(d.state,nt,"hover tooltip"))}else et&&d.dispatch({effects:this.setHover.of(et)})}get tooltip(){let d=this.view.plugin(tooltipPlugin),b=d?d.manager.tooltips.findIndex($=>$.create==HoverTooltipHost.create):-1;return b>-1?d.manager.tooltipViews[b]:null}mousemove(d){var b;this.lastMove={x:d.clientX,y:d.clientY,target:d.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:$,tooltip:j}=this;if($&&j&&!isInTooltip(j.dom,d)||this.pending){let{pos:_e}=$||this.pending,et=(b=$==null?void 0:$.end)!==null&&b!==void 0?b:_e;(_e==et?this.view.posAtCoords(this.lastMove)!=_e:!isOverRange(this.view,_e,et,d.clientX,d.clientY))&&(this.view.dispatch({effects:this.setHover.of(null)}),this.pending=null)}}mouseleave(d){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:b}=this;if(b){let{tooltip:$}=this;$&&$.dom.contains(d.relatedTarget)?this.watchTooltipLeave($.dom):this.view.dispatch({effects:this.setHover.of(null)})}}watchTooltipLeave(d){let b=$=>{d.removeEventListener("mouseleave",b),this.active&&!this.view.dom.contains($.relatedTarget)&&this.view.dispatch({effects:this.setHover.of(null)})};d.addEventListener("mouseleave",b)}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const tooltipMargin=4;function isInTooltip(g,d){let b=g.getBoundingClientRect();return d.clientX>=b.left-tooltipMargin&&d.clientX<=b.right+tooltipMargin&&d.clientY>=b.top-tooltipMargin&&d.clientY<=b.bottom+tooltipMargin}function isOverRange(g,d,b,$,j,_e){let et=g.scrollDOM.getBoundingClientRect(),tt=g.documentTop+g.documentPadding.top+g.contentHeight;if(et.left>$||et.right<$||et.top>j||Math.min(et.bottom,tt)=d&&nt<=b}function hoverTooltip(g,d={}){let b=StateEffect.define(),$=StateField.define({create(){return null},update(j,_e){if(j&&(d.hideOnChange&&(_e.docChanged||_e.selection)||d.hideOn&&d.hideOn(_e,j)))return null;if(j&&_e.docChanged){let et=_e.changes.mapPos(j.pos,-1,MapMode.TrackDel);if(et==null)return null;let tt=Object.assign(Object.create(null),j);tt.pos=et,j.end!=null&&(tt.end=_e.changes.mapPos(j.end)),j=tt}for(let et of _e.effects)et.is(b)&&(j=et.value),et.is(closeHoverTooltipEffect)&&(j=null);return j},provide:j=>showHoverTooltip.from(j)});return[$,ViewPlugin.define(j=>new HoverPlugin(j,g,$,b,d.hoverTime||300)),showHoverTooltipHost]}function getTooltip(g,d){let b=g.plugin(tooltipPlugin);if(!b)return null;let $=b.manager.tooltips.indexOf(d);return $<0?null:b.manager.tooltipViews[$]}const closeHoverTooltipEffect=StateEffect.define(),panelConfig=Facet.define({combine(g){let d,b;for(let $ of g)d=d||$.topContainer,b=b||$.bottomContainer;return{topContainer:d,bottomContainer:b}}});function getPanel(g,d){let b=g.plugin(panelPlugin),$=b?b.specs.indexOf(d):-1;return $>-1?b.panels[$]:null}const panelPlugin=ViewPlugin.fromClass(class{constructor(g){this.input=g.state.facet(showPanel),this.specs=this.input.filter(b=>b),this.panels=this.specs.map(b=>b(g));let d=g.state.facet(panelConfig);this.top=new PanelGroup(g,!0,d.topContainer),this.bottom=new PanelGroup(g,!1,d.bottomContainer),this.top.sync(this.panels.filter(b=>b.top)),this.bottom.sync(this.panels.filter(b=>!b.top));for(let b of this.panels)b.dom.classList.add("cm-panel"),b.mount&&b.mount()}update(g){let d=g.state.facet(panelConfig);this.top.container!=d.topContainer&&(this.top.sync([]),this.top=new PanelGroup(g.view,!0,d.topContainer)),this.bottom.container!=d.bottomContainer&&(this.bottom.sync([]),this.bottom=new PanelGroup(g.view,!1,d.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let b=g.state.facet(showPanel);if(b!=this.input){let $=b.filter(nt=>nt),j=[],_e=[],et=[],tt=[];for(let nt of $){let rt=this.specs.indexOf(nt),it;rt<0?(it=nt(g.view),tt.push(it)):(it=this.panels[rt],it.update&&it.update(g)),j.push(it),(it.top?_e:et).push(it)}this.specs=$,this.panels=j,this.top.sync(_e),this.bottom.sync(et);for(let nt of tt)nt.dom.classList.add("cm-panel"),nt.mount&&nt.mount()}else for(let $ of this.panels)$.update&&$.update(g)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:g=>EditorView.scrollMargins.of(d=>{let b=d.plugin(g);return b&&{top:b.top.scrollMargin(),bottom:b.bottom.scrollMargin()}})});class PanelGroup{constructor(d,b,$){this.view=d,this.top=b,this.container=$,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(d){for(let b of this.panels)b.destroy&&d.indexOf(b)<0&&b.destroy();this.panels=d,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let b=this.container||this.view.dom;b.insertBefore(this.dom,this.top?b.firstChild:null)}let d=this.dom.firstChild;for(let b of this.panels)if(b.dom.parentNode==this.dom){for(;d!=b.dom;)d=rm(d);d=d.nextSibling}else this.dom.insertBefore(b.dom,d);for(;d;)d=rm(d)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let d of this.classes.split(" "))d&&this.container.classList.remove(d);for(let d of(this.classes=this.view.themeClasses).split(" "))d&&this.container.classList.add(d)}}}function rm(g){let d=g.nextSibling;return g.remove(),d}const showPanel=Facet.define({enables:panelPlugin});class GutterMarker extends RangeValue{compare(d){return this==d||this.constructor==d.constructor&&this.eq(d)}eq(d){return!1}destroy(d){}}GutterMarker.prototype.elementClass="";GutterMarker.prototype.toDOM=void 0;GutterMarker.prototype.mapMode=MapMode.TrackBefore;GutterMarker.prototype.startSide=GutterMarker.prototype.endSide=-1;GutterMarker.prototype.point=!0;const gutterLineClass=Facet.define(),defaults$3={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>RangeSet.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},activeGutters=Facet.define();function gutter(g){return[gutters(),activeGutters.of(Object.assign(Object.assign({},defaults$3),g))]}const unfixGutters=Facet.define({combine:g=>g.some(d=>d)});function gutters(g){let d=[gutterView];return g&&g.fixed===!1&&d.push(unfixGutters.of(!0)),d}const gutterView=ViewPlugin.fromClass(class{constructor(g){this.view=g,this.prevViewport=g.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=g.state.facet(activeGutters).map(d=>new SingleGutterView(g,d));for(let d of this.gutters)this.dom.appendChild(d.dom);this.fixed=!g.state.facet(unfixGutters),this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),g.scrollDOM.insertBefore(this.dom,g.contentDOM)}update(g){if(this.updateGutters(g)){let d=this.prevViewport,b=g.view.viewport,$=Math.min(d.to,b.to)-Math.max(d.from,b.from);this.syncGutters($<(b.to-b.from)*.8)}g.geometryChanged&&(this.dom.style.minHeight=this.view.contentHeight+"px"),this.view.state.facet(unfixGutters)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":""),this.prevViewport=g.view.viewport}syncGutters(g){let d=this.dom.nextSibling;g&&this.dom.remove();let b=RangeSet.iter(this.view.state.facet(gutterLineClass),this.view.viewport.from),$=[],j=this.gutters.map(_e=>new UpdateContext(_e,this.view.viewport,-this.view.documentPadding.top));for(let _e of this.view.viewportLineBlocks)if($.length&&($=[]),Array.isArray(_e.type)){let et=!0;for(let tt of _e.type)if(tt.type==BlockType.Text&&et){advanceCursor(b,$,tt.from);for(let nt of j)nt.line(this.view,tt,$);et=!1}else if(tt.widget)for(let nt of j)nt.widget(this.view,tt)}else if(_e.type==BlockType.Text){advanceCursor(b,$,_e.from);for(let et of j)et.line(this.view,_e,$)}else if(_e.widget)for(let et of j)et.widget(this.view,_e);for(let _e of j)_e.finish();g&&this.view.scrollDOM.insertBefore(this.dom,d)}updateGutters(g){let d=g.startState.facet(activeGutters),b=g.state.facet(activeGutters),$=g.docChanged||g.heightChanged||g.viewportChanged||!RangeSet.eq(g.startState.facet(gutterLineClass),g.state.facet(gutterLineClass),g.view.viewport.from,g.view.viewport.to);if(d==b)for(let j of this.gutters)j.update(g)&&($=!0);else{$=!0;let j=[];for(let _e of b){let et=d.indexOf(_e);et<0?j.push(new SingleGutterView(this.view,_e)):(this.gutters[et].update(g),j.push(this.gutters[et]))}for(let _e of this.gutters)_e.dom.remove(),j.indexOf(_e)<0&&_e.destroy();for(let _e of j)this.dom.appendChild(_e.dom);this.gutters=j}return $}destroy(){for(let g of this.gutters)g.destroy();this.dom.remove()}},{provide:g=>EditorView.scrollMargins.of(d=>{let b=d.plugin(g);return!b||b.gutters.length==0||!b.fixed?null:d.textDirection==Direction.LTR?{left:b.dom.offsetWidth*d.scaleX}:{right:b.dom.offsetWidth*d.scaleX}})});function asArray(g){return Array.isArray(g)?g:[g]}function advanceCursor(g,d,b){for(;g.value&&g.from<=b;)g.from==b&&d.push(g.value),g.next()}class UpdateContext{constructor(d,b,$){this.gutter=d,this.height=$,this.i=0,this.cursor=RangeSet.iter(d.markers,b.from)}addElement(d,b,$){let{gutter:j}=this,_e=(b.top-this.height)/d.scaleY,et=b.height/d.scaleY;if(this.i==j.elements.length){let tt=new GutterElement(d,et,_e,$);j.elements.push(tt),j.dom.appendChild(tt.dom)}else j.elements[this.i].update(d,et,_e,$);this.height=b.bottom,this.i++}line(d,b,$){let j=[];advanceCursor(this.cursor,j,b.from),$.length&&(j=j.concat($));let _e=this.gutter.config.lineMarker(d,b,j);_e&&j.unshift(_e);let et=this.gutter;j.length==0&&!et.config.renderEmptyElements||this.addElement(d,b,j)}widget(d,b){let $=this.gutter.config.widgetMarker(d,b.widget,b);$&&this.addElement(d,b,[$])}finish(){let d=this.gutter;for(;d.elements.length>this.i;){let b=d.elements.pop();d.dom.removeChild(b.dom),b.destroy()}}}class SingleGutterView{constructor(d,b){this.view=d,this.config=b,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let $ in b.domEventHandlers)this.dom.addEventListener($,j=>{let _e=j.target,et;if(_e!=this.dom&&this.dom.contains(_e)){for(;_e.parentNode!=this.dom;)_e=_e.parentNode;let nt=_e.getBoundingClientRect();et=(nt.top+nt.bottom)/2}else et=j.clientY;let tt=d.lineBlockAtHeight(et-d.documentTop);b.domEventHandlers[$](d,tt,j)&&j.preventDefault()});this.markers=asArray(b.markers(d)),b.initialSpacer&&(this.spacer=new GutterElement(d,0,0,[b.initialSpacer(d)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(d){let b=this.markers;if(this.markers=asArray(this.config.markers(d.view)),this.spacer&&this.config.updateSpacer){let j=this.config.updateSpacer(this.spacer.markers[0],d);j!=this.spacer.markers[0]&&this.spacer.update(d.view,0,0,[j])}let $=d.view.viewport;return!RangeSet.eq(this.markers,b,$.from,$.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(d):!1)}destroy(){for(let d of this.elements)d.destroy()}}class GutterElement{constructor(d,b,$,j){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(d,b,$,j)}update(d,b,$,j){this.height!=b&&(this.height=b,this.dom.style.height=b+"px"),this.above!=$&&(this.dom.style.marginTop=(this.above=$)?$+"px":""),sameMarkers(this.markers,j)||this.setMarkers(d,j)}setMarkers(d,b){let $="cm-gutterElement",j=this.dom.firstChild;for(let _e=0,et=0;;){let tt=et,nt=_e_e(tt,nt,rt)||et(tt,nt,rt):et}return $}})}});class NumberMarker extends GutterMarker{constructor(d){super(),this.number=d}eq(d){return this.number==d.number}toDOM(){return document.createTextNode(this.number)}}function formatNumber(g,d){return g.state.facet(lineNumberConfig).formatNumber(d,g.state)}const lineNumberGutter=activeGutters.compute([lineNumberConfig],g=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(d){return d.state.facet(lineNumberMarkers)},lineMarker(d,b,$){return $.some(j=>j.toDOM)?null:new NumberMarker(formatNumber(d,d.state.doc.lineAt(b.from).number))},widgetMarker:()=>null,lineMarkerChange:d=>d.startState.facet(lineNumberConfig)!=d.state.facet(lineNumberConfig),initialSpacer(d){return new NumberMarker(formatNumber(d,maxLineNumber(d.state.doc.lines)))},updateSpacer(d,b){let $=formatNumber(b.view,maxLineNumber(b.view.state.doc.lines));return $==d.number?d:new NumberMarker($)},domEventHandlers:g.facet(lineNumberConfig).domEventHandlers}));function lineNumbers(g={}){return[lineNumberConfig.of(g),gutters(),lineNumberGutter]}function maxLineNumber(g){let d=9;for(;d{let d=[],b=-1;for(let $ of g.selection.ranges){let j=g.doc.lineAt($.head).from;j>b&&(b=j,d.push(activeLineGutterMarker.range(j)))}return RangeSet.of(d)});function highlightActiveLineGutter(){return activeLineGutterHighlighter}const DefaultBufferLength=1024;let nextPropID=0;class Range{constructor(d,b){this.from=d,this.to=b}}class NodeProp{constructor(d={}){this.id=nextPropID++,this.perNode=!!d.perNode,this.deserialize=d.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(d){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof d!="function"&&(d=NodeType.match(d)),b=>{let $=d(b);return $===void 0?null:[this,$]}}}NodeProp.closedBy=new NodeProp({deserialize:g=>g.split(" ")});NodeProp.openedBy=new NodeProp({deserialize:g=>g.split(" ")});NodeProp.group=new NodeProp({deserialize:g=>g.split(" ")});NodeProp.isolate=new NodeProp({deserialize:g=>{if(g&&g!="rtl"&&g!="ltr"&&g!="auto")throw new RangeError("Invalid value for isolate: "+g);return g||"auto"}});NodeProp.contextHash=new NodeProp({perNode:!0});NodeProp.lookAhead=new NodeProp({perNode:!0});NodeProp.mounted=new NodeProp({perNode:!0});class MountedTree{constructor(d,b,$){this.tree=d,this.overlay=b,this.parser=$}static get(d){return d&&d.props&&d.props[NodeProp.mounted.id]}}const noProps=Object.create(null);class NodeType{constructor(d,b,$,j=0){this.name=d,this.props=b,this.id=$,this.flags=j}static define(d){let b=d.props&&d.props.length?Object.create(null):noProps,$=(d.top?1:0)|(d.skipped?2:0)|(d.error?4:0)|(d.name==null?8:0),j=new NodeType(d.name||"",b,d.id,$);if(d.props){for(let _e of d.props)if(Array.isArray(_e)||(_e=_e(j)),_e){if(_e[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");b[_e[0].id]=_e[1]}}return j}prop(d){return this.props[d.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(d){if(typeof d=="string"){if(this.name==d)return!0;let b=this.prop(NodeProp.group);return b?b.indexOf(d)>-1:!1}return this.id==d}static match(d){let b=Object.create(null);for(let $ in d)for(let j of $.split(" "))b[j]=d[$];return $=>{for(let j=$.prop(NodeProp.group),_e=-1;_e<(j?j.length:0);_e++){let et=b[_e<0?$.name:j[_e]];if(et)return et}}}}NodeType.none=new NodeType("",Object.create(null),0,8);const CachedNode=new WeakMap,CachedInnerNode=new WeakMap;var IterMode;(function(g){g[g.ExcludeBuffers=1]="ExcludeBuffers",g[g.IncludeAnonymous=2]="IncludeAnonymous",g[g.IgnoreMounts=4]="IgnoreMounts",g[g.IgnoreOverlays=8]="IgnoreOverlays"})(IterMode||(IterMode={}));let Tree$1=class Dr{constructor(d,b,$,j,_e){if(this.type=d,this.children=b,this.positions=$,this.length=j,this.props=null,_e&&_e.length){this.props=Object.create(null);for(let[et,tt]of _e)this.props[typeof et=="number"?et:et.id]=tt}}toString(){let d=MountedTree.get(this);if(d&&!d.overlay)return d.tree.toString();let b="";for(let $ of this.children){let j=$.toString();j&&(b&&(b+=","),b+=j)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(b.length?"("+b+")":""):b}cursor(d=0){return new TreeCursor(this.topNode,d)}cursorAt(d,b=0,$=0){let j=CachedNode.get(this)||this.topNode,_e=new TreeCursor(j);return _e.moveTo(d,b),CachedNode.set(this,_e._tree),_e}get topNode(){return new TreeNode(this,0,0,null)}resolve(d,b=0){let $=resolveNode(CachedNode.get(this)||this.topNode,d,b,!1);return CachedNode.set(this,$),$}resolveInner(d,b=0){let $=resolveNode(CachedInnerNode.get(this)||this.topNode,d,b,!0);return CachedInnerNode.set(this,$),$}resolveStack(d,b=0){return stackIterator(this,d,b)}iterate(d){let{enter:b,leave:$,from:j=0,to:_e=this.length}=d,et=d.mode||0,tt=(et&IterMode.IncludeAnonymous)>0;for(let nt=this.cursor(et|IterMode.IncludeAnonymous);;){let rt=!1;if(nt.from<=_e&&nt.to>=j&&(!tt&&nt.type.isAnonymous||b(nt)!==!1)){if(nt.firstChild())continue;rt=!0}for(;rt&&$&&(tt||!nt.type.isAnonymous)&&$(nt),!nt.nextSibling();){if(!nt.parent())return;rt=!0}}}prop(d){return d.perNode?this.props?this.props[d.id]:void 0:this.type.prop(d)}get propValues(){let d=[];if(this.props)for(let b in this.props)d.push([+b,this.props[b]]);return d}balance(d={}){return this.children.length<=8?this:balanceRange(NodeType.none,this.children,this.positions,0,this.children.length,0,this.length,(b,$,j)=>new Dr(this.type,b,$,j,this.propValues),d.makeTree||((b,$,j)=>new Dr(NodeType.none,b,$,j)))}static build(d){return buildTree(d)}};Tree$1.empty=new Tree$1(NodeType.none,[],[],0);class FlatBufferCursor{constructor(d,b){this.buffer=d,this.index=b}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new FlatBufferCursor(this.buffer,this.index)}}class TreeBuffer{constructor(d,b,$){this.buffer=d,this.length=b,this.set=$}get type(){return NodeType.none}toString(){let d=[];for(let b=0;b0));nt=et[nt+3]);return tt}slice(d,b,$){let j=this.buffer,_e=new Uint16Array(b-d),et=0;for(let tt=d,nt=0;tt=d&&bd;case 1:return b<=d&&$>d;case 2:return $>d;case 4:return!0}}function resolveNode(g,d,b,$){for(var j;g.from==g.to||(b<1?g.from>=d:g.from>d)||(b>-1?g.to<=d:g.to0?tt.length:-1;d!=rt;d+=b){let it=tt[d],st=nt[d]+et.from;if(checkSide(j,$,st,st+it.length)){if(it instanceof TreeBuffer){if(_e&IterMode.ExcludeBuffers)continue;let ot=it.findChild(0,it.buffer.length,b,$-st,j);if(ot>-1)return new BufferNode(new BufferContext(et,it,d,st),null,ot)}else if(_e&IterMode.IncludeAnonymous||!it.type.isAnonymous||hasChild(it)){let ot;if(!(_e&IterMode.IgnoreMounts)&&(ot=MountedTree.get(it))&&!ot.overlay)return new TreeNode(ot.tree,st,d,et);let at=new TreeNode(it,st,d,et);return _e&IterMode.IncludeAnonymous||!at.type.isAnonymous?at:at.nextChild(b<0?it.children.length-1:0,b,$,j)}}}if(_e&IterMode.IncludeAnonymous||!et.type.isAnonymous||(et.index>=0?d=et.index+b:d=b<0?-1:et._parent._tree.children.length,et=et._parent,!et))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(d){return this.nextChild(0,1,d,2)}childBefore(d){return this.nextChild(this._tree.children.length-1,-1,d,-2)}enter(d,b,$=0){let j;if(!($&IterMode.IgnoreOverlays)&&(j=MountedTree.get(this._tree))&&j.overlay){let _e=d-this.from;for(let{from:et,to:tt}of j.overlay)if((b>0?et<=_e:et<_e)&&(b<0?tt>=_e:tt>_e))return new TreeNode(j.tree,j.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,d,b,$)}nextSignificantParent(){let d=this;for(;d.type.isAnonymous&&d._parent;)d=d._parent;return d}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function getChildren(g,d,b,$){let j=g.cursor(),_e=[];if(!j.firstChild())return _e;if(b!=null){for(;!j.type.is(b);)if(!j.nextSibling())return _e}for(;;){if($!=null&&j.type.is($))return _e;if(j.type.is(d)&&_e.push(j.node),!j.nextSibling())return $==null?_e:[]}}function matchNodeContext(g,d,b=d.length-1){for(let $=g.parent;b>=0;$=$.parent){if(!$)return!1;if(!$.type.isAnonymous){if(d[b]&&d[b]!=$.name)return!1;b--}}return!0}class BufferContext{constructor(d,b,$,j){this.parent=d,this.buffer=b,this.index=$,this.start=j}}class BufferNode extends BaseNode{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(d,b,$){super(),this.context=d,this._parent=b,this.index=$,this.type=d.buffer.set.types[d.buffer.buffer[$]]}child(d,b,$){let{buffer:j}=this.context,_e=j.findChild(this.index+4,j.buffer[this.index+3],d,b-this.context.start,$);return _e<0?null:new BufferNode(this.context,this,_e)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(d){return this.child(1,d,2)}childBefore(d){return this.child(-1,d,-2)}enter(d,b,$=0){if($&IterMode.ExcludeBuffers)return null;let{buffer:j}=this.context,_e=j.findChild(this.index+4,j.buffer[this.index+3],b>0?1:-1,d-this.context.start,b);return _e<0?null:new BufferNode(this.context,this,_e)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(d){return this._parent?null:this.context.parent.nextChild(this.context.index+d,d,0,4)}get nextSibling(){let{buffer:d}=this.context,b=d.buffer[this.index+3];return b<(this._parent?d.buffer[this._parent.index+3]:d.buffer.length)?new BufferNode(this.context,this._parent,b):this.externalSibling(1)}get prevSibling(){let{buffer:d}=this.context,b=this._parent?this._parent.index+4:0;return this.index==b?this.externalSibling(-1):new BufferNode(this.context,this._parent,d.findChild(b,this.index,-1,0,4))}get tree(){return null}toTree(){let d=[],b=[],{buffer:$}=this.context,j=this.index+4,_e=$.buffer[this.index+3];if(_e>j){let et=$.buffer[this.index+1];d.push($.slice(j,_e,et)),b.push(0)}return new Tree$1(this.type,d,b,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function iterStack(g){if(!g.length)return null;let d=0,b=g[0];for(let _e=1;_eb.from||et.to=d){let tt=new TreeNode(et.tree,et.overlay[0].from+_e.from,-1,_e);(j||(j=[$])).push(resolveNode(tt,d,b,!1))}}return j?iterStack(j):$}class TreeCursor{get name(){return this.type.name}constructor(d,b=0){if(this.mode=b,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,d instanceof TreeNode)this.yieldNode(d);else{this._tree=d.context.parent,this.buffer=d.context;for(let $=d._parent;$;$=$._parent)this.stack.unshift($.index);this.bufferNode=d,this.yieldBuf(d.index)}}yieldNode(d){return d?(this._tree=d,this.type=d.type,this.from=d.from,this.to=d.to,!0):!1}yieldBuf(d,b){this.index=d;let{start:$,buffer:j}=this.buffer;return this.type=b||j.set.types[j.buffer[d]],this.from=$+j.buffer[d+1],this.to=$+j.buffer[d+2],!0}yield(d){return d?d instanceof TreeNode?(this.buffer=null,this.yieldNode(d)):(this.buffer=d.context,this.yieldBuf(d.index,d.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(d,b,$){if(!this.buffer)return this.yield(this._tree.nextChild(d<0?this._tree._tree.children.length-1:0,d,b,$,this.mode));let{buffer:j}=this.buffer,_e=j.findChild(this.index+4,j.buffer[this.index+3],d,b-this.buffer.start,$);return _e<0?!1:(this.stack.push(this.index),this.yieldBuf(_e))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(d){return this.enterChild(1,d,2)}childBefore(d){return this.enterChild(-1,d,-2)}enter(d,b,$=this.mode){return this.buffer?$&IterMode.ExcludeBuffers?!1:this.enterChild(1,d,b):this.yield(this._tree.enter(d,b,$))}parent(){if(!this.buffer)return this.yieldNode(this.mode&IterMode.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let d=this.mode&IterMode.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(d)}sibling(d){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+d,d,0,4,this.mode)):!1;let{buffer:b}=this.buffer,$=this.stack.length-1;if(d<0){let j=$<0?0:this.stack[$]+4;if(this.index!=j)return this.yieldBuf(b.findChild(j,this.index,-1,0,4))}else{let j=b.buffer[this.index+3];if(j<($<0?b.buffer.length:b.buffer[this.stack[$]+3]))return this.yieldBuf(j)}return $<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+d,d,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(d){let b,$,{buffer:j}=this;if(j){if(d>0){if(this.index-1)for(let _e=b+d,et=d<0?-1:$._tree.children.length;_e!=et;_e+=d){let tt=$._tree.children[_e];if(this.mode&IterMode.IncludeAnonymous||tt instanceof TreeBuffer||!tt.type.isAnonymous||hasChild(tt))return!1}return!0}move(d,b){if(b&&this.enterChild(d,0,4))return!0;for(;;){if(this.sibling(d))return!0;if(this.atLastNode(d)||!this.parent())return!1}}next(d=!0){return this.move(1,d)}prev(d=!0){return this.move(-1,d)}moveTo(d,b=0){for(;(this.from==this.to||(b<1?this.from>=d:this.from>d)||(b>-1?this.to<=d:this.to=0;){for(let et=d;et;et=et._parent)if(et.index==j){if(j==this.index)return et;b=et,$=_e+1;break e}j=this.stack[--_e]}for(let j=$;j=0;_e--){if(_e<0)return matchNodeContext(this.node,d,j);let et=$[b.buffer[this.stack[_e]]];if(!et.isAnonymous){if(d[j]&&d[j]!=et.name)return!1;j--}}return!0}}function hasChild(g){return g.children.some(d=>d instanceof TreeBuffer||!d.type.isAnonymous||hasChild(d))}function buildTree(g){var d;let{buffer:b,nodeSet:$,maxBufferLength:j=DefaultBufferLength,reused:_e=[],minRepeatType:et=$.types.length}=g,tt=Array.isArray(b)?new FlatBufferCursor(b,b.length):b,nt=$.types,rt=0,it=0;function st(vt,St,xt,Dt,Pt,Ct){let{id:wt,start:Tt,end:Bt,size:Ft}=tt,Vt=it;for(;Ft<0;)if(tt.next(),Ft==-1){let It=_e[wt];xt.push(It),Dt.push(Tt-vt);return}else if(Ft==-3){rt=wt;return}else if(Ft==-4){it=wt;return}else throw new RangeError(`Unrecognized record size: ${Ft}`);let Wt=nt[wt],Ht,Ot,Lt=Tt-vt;if(Bt-Tt<=j&&(Ot=dt(tt.pos-St,Pt))){let It=new Uint16Array(Ot.size-Ot.skip),Ut=tt.pos-Ot.size,Gt=It.length;for(;tt.pos>Ut;)Gt=ht(Ot.start,It,Gt);Ht=new TreeBuffer(It,Bt-Ot.start,$),Lt=Ot.start-vt}else{let It=tt.pos-Ft;tt.next();let Ut=[],Gt=[],tn=wt>=et?wt:-1,nn=0,ln=Bt;for(;tt.pos>It;)tn>=0&&tt.id==tn&&tt.size>=0?(tt.end<=ln-j&&(ut(Ut,Gt,Tt,nn,tt.end,ln,tn,Vt),nn=Ut.length,ln=tt.end),tt.next()):Ct>2500?ot(Tt,It,Ut,Gt):st(Tt,It,Ut,Gt,tn,Ct+1);if(tn>=0&&nn>0&&nn-1&&nn>0){let an=at(Wt);Ht=balanceRange(Wt,Ut,Gt,0,Ut.length,0,Bt-Tt,an,an)}else Ht=ct(Wt,Ut,Gt,Bt-Tt,Vt-Bt)}xt.push(Ht),Dt.push(Lt)}function ot(vt,St,xt,Dt){let Pt=[],Ct=0,wt=-1;for(;tt.pos>St;){let{id:Tt,start:Bt,end:Ft,size:Vt}=tt;if(Vt>4)tt.next();else{if(wt>-1&&Bt=0;Ft-=3)Tt[Vt++]=Pt[Ft],Tt[Vt++]=Pt[Ft+1]-Bt,Tt[Vt++]=Pt[Ft+2]-Bt,Tt[Vt++]=Vt;xt.push(new TreeBuffer(Tt,Pt[2]-Bt,$)),Dt.push(Bt-vt)}}function at(vt){return(St,xt,Dt)=>{let Pt=0,Ct=St.length-1,wt,Tt;if(Ct>=0&&(wt=St[Ct])instanceof Tree$1){if(!Ct&&wt.type==vt&&wt.length==Dt)return wt;(Tt=wt.prop(NodeProp.lookAhead))&&(Pt=xt[Ct]+wt.length+Tt)}return ct(vt,St,xt,Dt,Pt)}}function ut(vt,St,xt,Dt,Pt,Ct,wt,Tt){let Bt=[],Ft=[];for(;vt.length>Dt;)Bt.push(vt.pop()),Ft.push(St.pop()+xt-Pt);vt.push(ct($.types[wt],Bt,Ft,Ct-Pt,Tt-Ct)),St.push(Pt-xt)}function ct(vt,St,xt,Dt,Pt=0,Ct){if(rt){let wt=[NodeProp.contextHash,rt];Ct=Ct?[wt].concat(Ct):[wt]}if(Pt>25){let wt=[NodeProp.lookAhead,Pt];Ct=Ct?[wt].concat(Ct):[wt]}return new Tree$1(vt,St,xt,Dt,Ct)}function dt(vt,St){let xt=tt.fork(),Dt=0,Pt=0,Ct=0,wt=xt.end-j,Tt={size:0,start:0,skip:0};e:for(let Bt=xt.pos-vt;xt.pos>Bt;){let Ft=xt.size;if(xt.id==St&&Ft>=0){Tt.size=Dt,Tt.start=Pt,Tt.skip=Ct,Ct+=4,Dt+=4,xt.next();continue}let Vt=xt.pos-Ft;if(Ft<0||Vt=et?4:0,Ht=xt.start;for(xt.next();xt.pos>Vt;){if(xt.size<0)if(xt.size==-3)Wt+=4;else break e;else xt.id>=et&&(Wt+=4);xt.next()}Pt=Ht,Dt+=Ft,Ct+=Wt}return(St<0||Dt==vt)&&(Tt.size=Dt,Tt.start=Pt,Tt.skip=Ct),Tt.size>4?Tt:void 0}function ht(vt,St,xt){let{id:Dt,start:Pt,end:Ct,size:wt}=tt;if(tt.next(),wt>=0&&Dt4){let Bt=tt.pos-(wt-4);for(;tt.pos>Bt;)xt=ht(vt,St,xt)}St[--xt]=Tt,St[--xt]=Ct-vt,St[--xt]=Pt-vt,St[--xt]=Dt}else wt==-3?rt=Dt:wt==-4&&(it=Dt);return xt}let pt=[],gt=[];for(;tt.pos>0;)st(g.start||0,g.bufferStart||0,pt,gt,-1,0);let yt=(d=g.length)!==null&&d!==void 0?d:pt.length?gt[0]+pt[0].length:0;return new Tree$1(nt[g.topID],pt.reverse(),gt.reverse(),yt)}const nodeSizeCache=new WeakMap;function nodeSize(g,d){if(!g.isAnonymous||d instanceof TreeBuffer||d.type!=g)return 1;let b=nodeSizeCache.get(d);if(b==null){b=1;for(let $ of d.children){if($.type!=g||!($ instanceof Tree$1)){b=1;break}b+=nodeSize(g,$)}nodeSizeCache.set(d,b)}return b}function balanceRange(g,d,b,$,j,_e,et,tt,nt){let rt=0;for(let ut=$;ut=it)break;St+=xt}if(gt==yt+1){if(St>it){let xt=ut[yt];at(xt.children,xt.positions,0,xt.children.length,ct[yt]+pt);continue}st.push(ut[yt])}else{let xt=ct[gt-1]+ut[gt-1].length-vt;st.push(balanceRange(g,ut,ct,yt,gt,vt,xt,null,nt))}ot.push(vt+pt-_e)}}return at(d,b,$,j,0),(tt||nt)(st,ot,et)}class TreeFragment{constructor(d,b,$,j,_e=!1,et=!1){this.from=d,this.to=b,this.tree=$,this.offset=j,this.open=(_e?1:0)|(et?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(d,b=[],$=!1){let j=[new TreeFragment(0,d.length,d,0,!1,$)];for(let _e of b)_e.to>d.length&&j.push(_e);return j}static applyChanges(d,b,$=128){if(!b.length)return d;let j=[],_e=1,et=d.length?d[0]:null;for(let tt=0,nt=0,rt=0;;tt++){let it=tt=$)for(;et&&et.from=ot.from||st<=ot.to||rt){let at=Math.max(ot.from,nt)-rt,ut=Math.min(ot.to,st)-rt;ot=at>=ut?null:new TreeFragment(at,ut,ot.tree,ot.offset+rt,tt>0,!!it)}if(ot&&j.push(ot),et.to>st)break;et=_enew Range(j.from,j.to)):[new Range(0,0)]:[new Range(0,d.length)],this.createParse(d,b||[],$)}parse(d,b,$){let j=this.startParse(d,b,$);for(;;){let _e=j.advance();if(_e)return _e}}};class StringInput{constructor(d){this.string=d}get length(){return this.string.length}chunk(d){return this.string.slice(d)}get lineChunks(){return!1}read(d,b){return this.string.slice(d,b)}}new NodeProp({perNode:!0});let nextTagID=0;class Tag{constructor(d,b,$){this.set=d,this.base=b,this.modified=$,this.id=nextTagID++}static define(d){if(d!=null&&d.base)throw new Error("Can not derive from a modified tag");let b=new Tag([],null,[]);if(b.set.push(b),d)for(let $ of d.set)b.set.push($);return b}static defineModifier(){let d=new Modifier;return b=>b.modified.indexOf(d)>-1?b:Modifier.get(b.base||b,b.modified.concat(d).sort(($,j)=>$.id-j.id))}}let nextModifierID=0;class Modifier{constructor(){this.instances=[],this.id=nextModifierID++}static get(d,b){if(!b.length)return d;let $=b[0].instances.find(tt=>tt.base==d&&sameArray(b,tt.modified));if($)return $;let j=[],_e=new Tag(j,d,b);for(let tt of b)tt.instances.push(_e);let et=powerSet(b);for(let tt of d.set)if(!tt.modified.length)for(let nt of et)j.push(Modifier.get(tt,nt));return _e}}function sameArray(g,d){return g.length==d.length&&g.every((b,$)=>b==d[$])}function powerSet(g){let d=[[]];for(let b=0;b$.length-b.length)}function styleTags(g){let d=Object.create(null);for(let b in g){let $=g[b];Array.isArray($)||($=[$]);for(let j of b.split(" "))if(j){let _e=[],et=2,tt=j;for(let st=0;;){if(tt=="..."&&st>0&&st+3==j.length){et=1;break}let ot=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(tt);if(!ot)throw new RangeError("Invalid path: "+j);if(_e.push(ot[0]=="*"?"":ot[0][0]=='"'?JSON.parse(ot[0]):ot[0]),st+=ot[0].length,st==j.length)break;let at=j[st++];if(st==j.length&&at=="!"){et=0;break}if(at!="/")throw new RangeError("Invalid path: "+j);tt=j.slice(st)}let nt=_e.length-1,rt=_e[nt];if(!rt)throw new RangeError("Invalid path: "+j);let it=new Rule($,et,nt>0?_e.slice(0,nt):null);d[rt]=it.sort(d[rt])}}return ruleNodeProp.add(d)}const ruleNodeProp=new NodeProp;class Rule{constructor(d,b,$,j){this.tags=d,this.mode=b,this.context=$,this.next=j}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(d){return!d||d.depth{let et=j;for(let tt of _e)for(let nt of tt.set){let rt=b[nt.id];if(rt){et=et?et+" "+rt:rt;break}}return et},scope:$}}function highlightTags(g,d){let b=null;for(let $ of g){let j=$.style(d);j&&(b=b?b+" "+j:j)}return b}function highlightTree(g,d,b,$=0,j=g.length){let _e=new HighlightBuilder($,Array.isArray(d)?d:[d],b);_e.highlightRange(g.cursor(),$,j,"",_e.highlighters),_e.flush(j)}class HighlightBuilder{constructor(d,b,$){this.at=d,this.highlighters=b,this.span=$,this.class=""}startSpan(d,b){b!=this.class&&(this.flush(d),d>this.at&&(this.at=d),this.class=b)}flush(d){d>this.at&&this.class&&this.span(this.at,d,this.class)}highlightRange(d,b,$,j,_e){let{type:et,from:tt,to:nt}=d;if(tt>=$||nt<=b)return;et.isTop&&(_e=this.highlighters.filter(at=>!at.scope||at.scope(et)));let rt=j,it=getStyleTags(d)||Rule.empty,st=highlightTags(_e,it.tags);if(st&&(rt&&(rt+=" "),rt+=st,it.mode==1&&(j+=(j?" ":"")+st)),this.startSpan(Math.max(b,tt),rt),it.opaque)return;let ot=d.tree&&d.tree.prop(NodeProp.mounted);if(ot&&ot.overlay){let at=d.node.enter(ot.overlay[0].from+tt,1),ut=this.highlighters.filter(dt=>!dt.scope||dt.scope(ot.tree.type)),ct=d.firstChild();for(let dt=0,ht=tt;;dt++){let pt=dt=gt||!d.nextSibling())););if(!pt||gt>$)break;ht=pt.to+tt,ht>b&&(this.highlightRange(at.cursor(),Math.max(b,pt.from+tt),Math.min($,ht),"",ut),this.startSpan(Math.min($,ht),rt))}ct&&d.parent()}else if(d.firstChild()){ot&&(j="");do if(!(d.to<=b)){if(d.from>=$)break;this.highlightRange(d,b,$,j,_e),this.startSpan(Math.min($,d.to),rt)}while(d.nextSibling());d.parent()}}}function getStyleTags(g){let d=g.type.prop(ruleNodeProp);for(;d&&d.context&&!g.matchContext(d.context);)d=d.next;return d||null}const t$1=Tag.define,comment=t$1(),name=t$1(),typeName=t$1(name),propertyName=t$1(name),literal=t$1(),string=t$1(literal),number=t$1(literal),content=t$1(),heading=t$1(content),keyword=t$1(),operator=t$1(),punctuation=t$1(),bracket=t$1(punctuation),meta=t$1(),tags={comment,lineComment:t$1(comment),blockComment:t$1(comment),docComment:t$1(comment),name,variableName:t$1(name),typeName,tagName:t$1(typeName),propertyName,attributeName:t$1(propertyName),className:t$1(name),labelName:t$1(name),namespace:t$1(name),macroName:t$1(name),literal,string,docString:t$1(string),character:t$1(string),attributeValue:t$1(string),number,integer:t$1(number),float:t$1(number),bool:t$1(literal),regexp:t$1(literal),escape:t$1(literal),color:t$1(literal),url:t$1(literal),keyword,self:t$1(keyword),null:t$1(keyword),atom:t$1(keyword),unit:t$1(keyword),modifier:t$1(keyword),operatorKeyword:t$1(keyword),controlKeyword:t$1(keyword),definitionKeyword:t$1(keyword),moduleKeyword:t$1(keyword),operator,derefOperator:t$1(operator),arithmeticOperator:t$1(operator),logicOperator:t$1(operator),bitwiseOperator:t$1(operator),compareOperator:t$1(operator),updateOperator:t$1(operator),definitionOperator:t$1(operator),typeOperator:t$1(operator),controlOperator:t$1(operator),punctuation,separator:t$1(punctuation),bracket,angleBracket:t$1(bracket),squareBracket:t$1(bracket),paren:t$1(bracket),brace:t$1(bracket),content,heading,heading1:t$1(heading),heading2:t$1(heading),heading3:t$1(heading),heading4:t$1(heading),heading5:t$1(heading),heading6:t$1(heading),contentSeparator:t$1(content),list:t$1(content),quote:t$1(content),emphasis:t$1(content),strong:t$1(content),link:t$1(content),monospace:t$1(content),strikethrough:t$1(content),inserted:t$1(),deleted:t$1(),changed:t$1(),invalid:t$1(),meta,documentMeta:t$1(meta),annotation:t$1(meta),processingInstruction:t$1(meta),definition:Tag.defineModifier(),constant:Tag.defineModifier(),function:Tag.defineModifier(),standard:Tag.defineModifier(),local:Tag.defineModifier(),special:Tag.defineModifier()};tagHighlighter([{tag:tags.link,class:"tok-link"},{tag:tags.heading,class:"tok-heading"},{tag:tags.emphasis,class:"tok-emphasis"},{tag:tags.strong,class:"tok-strong"},{tag:tags.keyword,class:"tok-keyword"},{tag:tags.atom,class:"tok-atom"},{tag:tags.bool,class:"tok-bool"},{tag:tags.url,class:"tok-url"},{tag:tags.labelName,class:"tok-labelName"},{tag:tags.inserted,class:"tok-inserted"},{tag:tags.deleted,class:"tok-deleted"},{tag:tags.literal,class:"tok-literal"},{tag:tags.string,class:"tok-string"},{tag:tags.number,class:"tok-number"},{tag:[tags.regexp,tags.escape,tags.special(tags.string)],class:"tok-string2"},{tag:tags.variableName,class:"tok-variableName"},{tag:tags.local(tags.variableName),class:"tok-variableName tok-local"},{tag:tags.definition(tags.variableName),class:"tok-variableName tok-definition"},{tag:tags.special(tags.variableName),class:"tok-variableName2"},{tag:tags.definition(tags.propertyName),class:"tok-propertyName tok-definition"},{tag:tags.typeName,class:"tok-typeName"},{tag:tags.namespace,class:"tok-namespace"},{tag:tags.className,class:"tok-className"},{tag:tags.macroName,class:"tok-macroName"},{tag:tags.propertyName,class:"tok-propertyName"},{tag:tags.operator,class:"tok-operator"},{tag:tags.comment,class:"tok-comment"},{tag:tags.meta,class:"tok-meta"},{tag:tags.invalid,class:"tok-invalid"},{tag:tags.punctuation,class:"tok-punctuation"}]);var _a;const languageDataProp=new NodeProp,sublanguageProp=new NodeProp;class Language{constructor(d,b,$=[],j=""){this.data=d,this.name=j,EditorState.prototype.hasOwnProperty("tree")||Object.defineProperty(EditorState.prototype,"tree",{get(){return syntaxTree(this)}}),this.parser=b,this.extension=[language.of(this),EditorState.languageData.of((_e,et,tt)=>{let nt=topNodeAt(_e,et,tt),rt=nt.type.prop(languageDataProp);if(!rt)return[];let it=_e.facet(rt),st=nt.type.prop(sublanguageProp);if(st){let ot=nt.resolve(et-nt.from,tt);for(let at of st)if(at.test(ot,_e)){let ut=_e.facet(at.facet);return at.type=="replace"?ut:ut.concat(it)}}return it})].concat($)}isActiveAt(d,b,$=-1){return topNodeAt(d,b,$).type.prop(languageDataProp)==this.data}findRegions(d){let b=d.facet(language);if((b==null?void 0:b.data)==this.data)return[{from:0,to:d.doc.length}];if(!b||!b.allowsNesting)return[];let $=[],j=(_e,et)=>{if(_e.prop(languageDataProp)==this.data){$.push({from:et,to:et+_e.length});return}let tt=_e.prop(NodeProp.mounted);if(tt){if(tt.tree.prop(languageDataProp)==this.data){if(tt.overlay)for(let nt of tt.overlay)$.push({from:nt.from+et,to:nt.to+et});else $.push({from:et,to:et+_e.length});return}else if(tt.overlay){let nt=$.length;if(j(tt.tree,tt.overlay[0].from+et),$.length>nt)return}}for(let nt=0;nt<_e.children.length;nt++){let rt=_e.children[nt];rt instanceof Tree$1&&j(rt,_e.positions[nt]+et)}};return j(syntaxTree(d),0),$}get allowsNesting(){return!0}}Language.setState=StateEffect.define();function topNodeAt(g,d,b){let $=g.facet(language),j=syntaxTree(g).topNode;if(!$||$.allowsNesting)for(let _e=j;_e;_e=_e.enter(d,b,IterMode.ExcludeBuffers))_e.type.isTop&&(j=_e);return j}function syntaxTree(g){let d=g.field(Language.state,!1);return d?d.tree:Tree$1.empty}class DocInput{constructor(d){this.doc=d,this.cursorPos=0,this.string="",this.cursor=d.iter()}get length(){return this.doc.length}syncTo(d){return this.string=this.cursor.next(d-this.cursorPos).value,this.cursorPos=d+this.string.length,this.cursorPos-this.string.length}chunk(d){return this.syncTo(d),this.string}get lineChunks(){return!0}read(d,b){let $=this.cursorPos-this.string.length;return d<$||b>=this.cursorPos?this.doc.sliceString(d,b):this.string.slice(d-$,b-$)}}let currentContext=null;class ParseContext{constructor(d,b,$=[],j,_e,et,tt,nt){this.parser=d,this.state=b,this.fragments=$,this.tree=j,this.treeLen=_e,this.viewport=et,this.skipped=tt,this.scheduleOn=nt,this.parse=null,this.tempSkipped=[]}static create(d,b,$){return new ParseContext(d,b,[],Tree$1.empty,0,$,[],null)}startParse(){return this.parser.startParse(new DocInput(this.state.doc),this.fragments)}work(d,b){return b!=null&&b>=this.state.doc.length&&(b=void 0),this.tree!=Tree$1.empty&&this.isDone(b??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var $;if(typeof d=="number"){let j=Date.now()+d;d=()=>Date.now()>j}for(this.parse||(this.parse=this.startParse()),b!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>b)&&b=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>d)&&this.parse.stopAt(d),this.withContext(()=>{for(;!(b=this.parse.advance()););}),this.treeLen=d,this.tree=b,this.fragments=this.withoutTempSkipped(TreeFragment.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(d){let b=currentContext;currentContext=this;try{return d()}finally{currentContext=b}}withoutTempSkipped(d){for(let b;b=this.tempSkipped.pop();)d=cutFragments(d,b.from,b.to);return d}changes(d,b){let{fragments:$,tree:j,treeLen:_e,viewport:et,skipped:tt}=this;if(this.takeTree(),!d.empty){let nt=[];if(d.iterChangedRanges((rt,it,st,ot)=>nt.push({fromA:rt,toA:it,fromB:st,toB:ot})),$=TreeFragment.applyChanges($,nt),j=Tree$1.empty,_e=0,et={from:d.mapPos(et.from,-1),to:d.mapPos(et.to,1)},this.skipped.length){tt=[];for(let rt of this.skipped){let it=d.mapPos(rt.from,1),st=d.mapPos(rt.to,-1);itd.from&&(this.fragments=cutFragments(this.fragments,j,_e),this.skipped.splice($--,1))}return this.skipped.length>=b?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(d,b){this.skipped.push({from:d,to:b})}static getSkippingParser(d){return new class extends Parser$1{createParse(b,$,j){let _e=j[0].from,et=j[j.length-1].to;return{parsedPos:_e,advance(){let nt=currentContext;if(nt){for(let rt of j)nt.tempSkipped.push(rt);d&&(nt.scheduleOn=nt.scheduleOn?Promise.all([nt.scheduleOn,d]):d)}return this.parsedPos=et,new Tree$1(NodeType.none,[],[],et-_e)},stoppedAt:null,stopAt(){}}}}}isDone(d){d=Math.min(d,this.state.doc.length);let b=this.fragments;return this.treeLen>=d&&b.length&&b[0].from==0&&b[0].to>=d}static get(){return currentContext}}function cutFragments(g,d,b){return TreeFragment.applyChanges(g,[{fromA:d,toA:b,fromB:d,toB:b}])}class LanguageState{constructor(d){this.context=d,this.tree=d.tree}apply(d){if(!d.docChanged&&this.tree==this.context.tree)return this;let b=this.context.changes(d.changes,d.state),$=this.context.treeLen==d.startState.doc.length?void 0:Math.max(d.changes.mapPos(this.context.treeLen),b.viewport.to);return b.work(20,$)||b.takeTree(),new LanguageState(b)}static init(d){let b=Math.min(3e3,d.doc.length),$=ParseContext.create(d.facet(language).parser,d,{from:0,to:b});return $.work(20,b)||$.takeTree(),new LanguageState($)}}Language.state=StateField.define({create:LanguageState.init,update(g,d){for(let b of d.effects)if(b.is(Language.setState))return b.value;return d.startState.facet(language)!=d.state.facet(language)?LanguageState.init(d.state):g.apply(d)}});let requestIdle=g=>{let d=setTimeout(()=>g(),500);return()=>clearTimeout(d)};typeof requestIdleCallback<"u"&&(requestIdle=g=>{let d=-1,b=setTimeout(()=>{d=requestIdleCallback(g,{timeout:500-100})},100);return()=>d<0?clearTimeout(b):cancelIdleCallback(d)});const isInputPending=typeof navigator<"u"&&(!((_a=navigator.scheduling)===null||_a===void 0)&&_a.isInputPending)?()=>navigator.scheduling.isInputPending():null,parseWorker=ViewPlugin.fromClass(class{constructor(d){this.view=d,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(d){let b=this.view.state.field(Language.state).context;(b.updateViewport(d.view.viewport)||this.view.viewport.to>b.treeLen)&&this.scheduleWork(),(d.docChanged||d.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(b)}scheduleWork(){if(this.working)return;let{state:d}=this.view,b=d.field(Language.state);(b.tree!=b.context.tree||!b.context.isDone(d.doc.length))&&(this.working=requestIdle(this.work))}work(d){this.working=null;let b=Date.now();if(this.chunkEndj+1e3,nt=_e.context.work(()=>isInputPending&&isInputPending()||Date.now()>et,j+(tt?0:1e5));this.chunkBudget-=Date.now()-b,(nt||this.chunkBudget<=0)&&(_e.context.takeTree(),this.view.dispatch({effects:Language.setState.of(new LanguageState(_e.context))})),this.chunkBudget>0&&!(nt&&!tt)&&this.scheduleWork(),this.checkAsyncSchedule(_e.context)}checkAsyncSchedule(d){d.scheduleOn&&(this.workScheduled++,d.scheduleOn.then(()=>this.scheduleWork()).catch(b=>logException(this.view.state,b)).then(()=>this.workScheduled--),d.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),language=Facet.define({combine(g){return g.length?g[0]:null},enables:g=>[Language.state,parseWorker,EditorView.contentAttributes.compute([g],d=>{let b=d.facet(g);return b&&b.name?{"data-language":b.name}:{}})]}),indentService=Facet.define(),indentUnit=Facet.define({combine:g=>{if(!g.length)return" ";let d=g[0];if(!d||/\S/.test(d)||Array.from(d).some(b=>b!=d[0]))throw new Error("Invalid indent unit: "+JSON.stringify(g[0]));return d}});function getIndentUnit(g){let d=g.facet(indentUnit);return d.charCodeAt(0)==9?g.tabSize*d.length:d.length}function indentString(g,d){let b="",$=g.tabSize,j=g.facet(indentUnit)[0];if(j==" "){for(;d>=$;)b+=" ",d-=$;j=" "}for(let _e=0;_e=d?syntaxIndentation(g,b,d):null}class IndentContext{constructor(d,b={}){this.state=d,this.options=b,this.unit=getIndentUnit(d)}lineAt(d,b=1){let $=this.state.doc.lineAt(d),{simulateBreak:j,simulateDoubleBreak:_e}=this.options;return j!=null&&j>=$.from&&j<=$.to?_e&&j==d?{text:"",from:d}:(b<0?j-1&&(_e+=et-this.countColumn($,$.search(/\S|$/))),_e}countColumn(d,b=d.length){return countColumn(d,this.state.tabSize,b)}lineIndent(d,b=1){let{text:$,from:j}=this.lineAt(d,b),_e=this.options.overrideIndentation;if(_e){let et=_e(j);if(et>-1)return et}return this.countColumn($,$.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const indentNodeProp=new NodeProp;function syntaxIndentation(g,d,b){let $=d.resolveStack(b),j=$.node.enterUnfinishedNodesBefore(b);if(j!=$.node){let _e=[];for(let et=j;et!=$.node;et=et.parent)_e.push(et);for(let et=_e.length-1;et>=0;et--)$={node:_e[et],next:$}}return indentFor($,g,b)}function indentFor(g,d,b){for(let $=g;$;$=$.next){let j=indentStrategy($.node);if(j)return j(TreeIndentContext.create(d,b,$))}return 0}function ignoreClosed(g){return g.pos==g.options.simulateBreak&&g.options.simulateDoubleBreak}function indentStrategy(g){let d=g.type.prop(indentNodeProp);if(d)return d;let b=g.firstChild,$;if(b&&($=b.type.prop(NodeProp.closedBy))){let j=g.lastChild,_e=j&&$.indexOf(j.name)>-1;return et=>delimitedStrategy(et,!0,1,void 0,_e&&!ignoreClosed(et)?j.from:void 0)}return g.parent==null?topIndent:null}function topIndent(){return 0}class TreeIndentContext extends IndentContext{constructor(d,b,$){super(d.state,d.options),this.base=d,this.pos=b,this.context=$}get node(){return this.context.node}static create(d,b,$){return new TreeIndentContext(d,b,$)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(d){let b=this.state.doc.lineAt(d.from);for(;;){let $=d.resolve(b.from);for(;$.parent&&$.parent.from==$.from;)$=$.parent;if(isParent($,d))break;b=this.state.doc.lineAt($.from)}return this.lineIndent(b.from)}continue(){return indentFor(this.context.next,this.base,this.pos)}}function isParent(g,d){for(let b=d;b;b=b.parent)if(g==b)return!0;return!1}function bracketedAligned(g){let d=g.node,b=d.childAfter(d.from),$=d.lastChild;if(!b)return null;let j=g.options.simulateBreak,_e=g.state.doc.lineAt(b.from),et=j==null||j<=_e.from?_e.to:Math.min(_e.to,j);for(let tt=b.to;;){let nt=d.childAfter(tt);if(!nt||nt==$)return null;if(!nt.type.isSkipped)return nt.from{if(!g.docChanged||!g.isUserEvent("input.type")&&!g.isUserEvent("input.complete"))return g;let d=g.startState.languageDataAt("indentOnInput",g.startState.selection.main.head);if(!d.length)return g;let b=g.newDoc,{head:$}=g.newSelection.main,j=b.lineAt($);if($>j.from+DontIndentBeyond)return g;let _e=b.sliceString(j.from,$);if(!d.some(rt=>rt.test(_e)))return g;let{state:et}=g,tt=-1,nt=[];for(let{head:rt}of et.selection.ranges){let it=et.doc.lineAt(rt);if(it.from==tt)continue;tt=it.from;let st=getIndentation(et,it.from);if(st==null)continue;let ot=/^\s*/.exec(it.text)[0],at=indentString(et,st);ot!=at&&nt.push({from:it.from,to:it.from+ot.length,insert:at})}return nt.length?[g,{changes:nt,sequential:!0}]:g})}const foldService=Facet.define(),foldNodeProp=new NodeProp;function syntaxFolding(g,d,b){let $=syntaxTree(g);if($.lengthb)continue;if(_e&&tt.from=d&&rt.to>b&&(_e=rt)}}return _e}function isUnfinished(g){let d=g.lastChild;return d&&d.to==g.to&&d.type.isError}function foldable(g,d,b){for(let $ of g.facet(foldService)){let j=$(g,d,b);if(j)return j}return syntaxFolding(g,d,b)}function mapRange(g,d){let b=d.mapPos(g.from,1),$=d.mapPos(g.to,-1);return b>=$?void 0:{from:b,to:$}}const foldEffect=StateEffect.define({map:mapRange}),unfoldEffect=StateEffect.define({map:mapRange});function selectedLines(g){let d=[];for(let{head:b}of g.state.selection.ranges)d.some($=>$.from<=b&&$.to>=b)||d.push(g.lineBlockAt(b));return d}const foldState=StateField.define({create(){return Decoration.none},update(g,d){g=g.map(d.changes);for(let b of d.effects)if(b.is(foldEffect)&&!foldExists(g,b.value.from,b.value.to)){let{preparePlaceholder:$}=d.state.facet(foldConfig),j=$?Decoration.replace({widget:new PreparedFoldWidget($(d.state,b.value))}):foldWidget;g=g.update({add:[j.range(b.value.from,b.value.to)]})}else b.is(unfoldEffect)&&(g=g.update({filter:($,j)=>b.value.from!=$||b.value.to!=j,filterFrom:b.value.from,filterTo:b.value.to}));if(d.selection){let b=!1,{head:$}=d.selection.main;g.between($,$,(j,_e)=>{j<$&&_e>$&&(b=!0)}),b&&(g=g.update({filterFrom:$,filterTo:$,filter:(j,_e)=>_e<=$||j>=$}))}return g},provide:g=>EditorView.decorations.from(g),toJSON(g,d){let b=[];return g.between(0,d.doc.length,($,j)=>{b.push($,j)}),b},fromJSON(g){if(!Array.isArray(g)||g.length%2)throw new RangeError("Invalid JSON for fold state");let d=[];for(let b=0;b{(!j||j.from>_e)&&(j={from:_e,to:et})}),j}function foldExists(g,d,b){let $=!1;return g.between(d,d,(j,_e)=>{j==d&&_e==b&&($=!0)}),$}function maybeEnable(g,d){return g.field(foldState,!1)?d:d.concat(StateEffect.appendConfig.of(codeFolding()))}const foldCode=g=>{for(let d of selectedLines(g)){let b=foldable(g.state,d.from,d.to);if(b)return g.dispatch({effects:maybeEnable(g.state,[foldEffect.of(b),announceFold(g,b)])}),!0}return!1},unfoldCode=g=>{if(!g.state.field(foldState,!1))return!1;let d=[];for(let b of selectedLines(g)){let $=findFold(g.state,b.from,b.to);$&&d.push(unfoldEffect.of($),announceFold(g,$,!1))}return d.length&&g.dispatch({effects:d}),d.length>0};function announceFold(g,d,b=!0){let $=g.state.doc.lineAt(d.from).number,j=g.state.doc.lineAt(d.to).number;return EditorView.announce.of(`${g.state.phrase(b?"Folded lines":"Unfolded lines")} ${$} ${g.state.phrase("to")} ${j}.`)}const foldAll=g=>{let{state:d}=g,b=[];for(let $=0;${let d=g.state.field(foldState,!1);if(!d||!d.size)return!1;let b=[];return d.between(0,g.state.doc.length,($,j)=>{b.push(unfoldEffect.of({from:$,to:j}))}),g.dispatch({effects:b}),!0},foldKeymap=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:foldCode},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:unfoldCode},{key:"Ctrl-Alt-[",run:foldAll},{key:"Ctrl-Alt-]",run:unfoldAll}],defaultConfig={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},foldConfig=Facet.define({combine(g){return combineConfig(g,defaultConfig)}});function codeFolding(g){let d=[foldState,baseTheme$1$2];return g&&d.push(foldConfig.of(g)),d}function widgetToDOM(g,d){let{state:b}=g,$=b.facet(foldConfig),j=et=>{let tt=g.lineBlockAt(g.posAtDOM(et.target)),nt=findFold(g.state,tt.from,tt.to);nt&&g.dispatch({effects:unfoldEffect.of(nt)}),et.preventDefault()};if($.placeholderDOM)return $.placeholderDOM(g,j,d);let _e=document.createElement("span");return _e.textContent=$.placeholderText,_e.setAttribute("aria-label",b.phrase("folded code")),_e.title=b.phrase("unfold"),_e.className="cm-foldPlaceholder",_e.onclick=j,_e}const foldWidget=Decoration.replace({widget:new class extends WidgetType{toDOM(g){return widgetToDOM(g,null)}}});class PreparedFoldWidget extends WidgetType{constructor(d){super(),this.value=d}eq(d){return this.value==d.value}toDOM(d){return widgetToDOM(d,this.value)}}const foldGutterDefaults={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class FoldMarker extends GutterMarker{constructor(d,b){super(),this.config=d,this.open=b}eq(d){return this.config==d.config&&this.open==d.open}toDOM(d){if(this.config.markerDOM)return this.config.markerDOM(this.open);let b=document.createElement("span");return b.textContent=this.open?this.config.openText:this.config.closedText,b.title=d.state.phrase(this.open?"Fold line":"Unfold line"),b}}function foldGutter(g={}){let d=Object.assign(Object.assign({},foldGutterDefaults),g),b=new FoldMarker(d,!0),$=new FoldMarker(d,!1),j=ViewPlugin.fromClass(class{constructor(et){this.from=et.viewport.from,this.markers=this.buildMarkers(et)}update(et){(et.docChanged||et.viewportChanged||et.startState.facet(language)!=et.state.facet(language)||et.startState.field(foldState,!1)!=et.state.field(foldState,!1)||syntaxTree(et.startState)!=syntaxTree(et.state)||d.foldingChanged(et))&&(this.markers=this.buildMarkers(et.view))}buildMarkers(et){let tt=new RangeSetBuilder;for(let nt of et.viewportLineBlocks){let rt=findFold(et.state,nt.from,nt.to)?$:foldable(et.state,nt.from,nt.to)?b:null;rt&&tt.add(nt.from,nt.from,rt)}return tt.finish()}}),{domEventHandlers:_e}=d;return[j,gutter({class:"cm-foldGutter",markers(et){var tt;return((tt=et.plugin(j))===null||tt===void 0?void 0:tt.markers)||RangeSet.empty},initialSpacer(){return new FoldMarker(d,!1)},domEventHandlers:Object.assign(Object.assign({},_e),{click:(et,tt,nt)=>{if(_e.click&&_e.click(et,tt,nt))return!0;let rt=findFold(et.state,tt.from,tt.to);if(rt)return et.dispatch({effects:unfoldEffect.of(rt)}),!0;let it=foldable(et.state,tt.from,tt.to);return it?(et.dispatch({effects:foldEffect.of(it)}),!0):!1}})}),codeFolding()]}const baseTheme$1$2=EditorView.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class HighlightStyle{constructor(d,b){this.specs=d;let $;function j(tt){let nt=StyleModule.newName();return($||($=Object.create(null)))["."+nt]=tt,nt}const _e=typeof b.all=="string"?b.all:b.all?j(b.all):void 0,et=b.scope;this.scope=et instanceof Language?tt=>tt.prop(languageDataProp)==et.data:et?tt=>tt==et:void 0,this.style=tagHighlighter(d.map(tt=>({tag:tt.tag,class:tt.class||j(Object.assign({},tt,{tag:null}))})),{all:_e}).style,this.module=$?new StyleModule($):null,this.themeType=b.themeType}static define(d,b){return new HighlightStyle(d,b||{})}}const highlighterFacet=Facet.define(),fallbackHighlighter=Facet.define({combine(g){return g.length?[g[0]]:null}});function getHighlighters(g){let d=g.facet(highlighterFacet);return d.length?d:g.facet(fallbackHighlighter)}function syntaxHighlighting(g,d){let b=[treeHighlighter],$;return g instanceof HighlightStyle&&(g.module&&b.push(EditorView.styleModule.of(g.module)),$=g.themeType),d!=null&&d.fallback?b.push(fallbackHighlighter.of(g)):$?b.push(highlighterFacet.computeN([EditorView.darkTheme],j=>j.facet(EditorView.darkTheme)==($=="dark")?[g]:[])):b.push(highlighterFacet.of(g)),b}class TreeHighlighter{constructor(d){this.markCache=Object.create(null),this.tree=syntaxTree(d.state),this.decorations=this.buildDeco(d,getHighlighters(d.state))}update(d){let b=syntaxTree(d.state),$=getHighlighters(d.state),j=$!=getHighlighters(d.startState);b.length{$.add(et,tt,this.markCache[nt]||(this.markCache[nt]=Decoration.mark({class:nt})))},j,_e);return $.finish()}}const treeHighlighter=Prec.high(ViewPlugin.fromClass(TreeHighlighter,{decorations:g=>g.decorations})),defaultHighlightStyle=HighlightStyle.define([{tag:tags.meta,color:"#404740"},{tag:tags.link,textDecoration:"underline"},{tag:tags.heading,textDecoration:"underline",fontWeight:"bold"},{tag:tags.emphasis,fontStyle:"italic"},{tag:tags.strong,fontWeight:"bold"},{tag:tags.strikethrough,textDecoration:"line-through"},{tag:tags.keyword,color:"#708"},{tag:[tags.atom,tags.bool,tags.url,tags.contentSeparator,tags.labelName],color:"#219"},{tag:[tags.literal,tags.inserted],color:"#164"},{tag:[tags.string,tags.deleted],color:"#a11"},{tag:[tags.regexp,tags.escape,tags.special(tags.string)],color:"#e40"},{tag:tags.definition(tags.variableName),color:"#00f"},{tag:tags.local(tags.variableName),color:"#30a"},{tag:[tags.typeName,tags.namespace],color:"#085"},{tag:tags.className,color:"#167"},{tag:[tags.special(tags.variableName),tags.macroName],color:"#256"},{tag:tags.definition(tags.propertyName),color:"#00c"},{tag:tags.comment,color:"#940"},{tag:tags.invalid,color:"#f00"}]),baseTheme$3=EditorView.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),DefaultScanDist=1e4,DefaultBrackets="()[]{}",bracketMatchingConfig=Facet.define({combine(g){return combineConfig(g,{afterCursor:!0,brackets:DefaultBrackets,maxScanDistance:DefaultScanDist,renderMatch:defaultRenderMatch})}}),matchingMark=Decoration.mark({class:"cm-matchingBracket"}),nonmatchingMark=Decoration.mark({class:"cm-nonmatchingBracket"});function defaultRenderMatch(g){let d=[],b=g.matched?matchingMark:nonmatchingMark;return d.push(b.range(g.start.from,g.start.to)),g.end&&d.push(b.range(g.end.from,g.end.to)),d}const bracketMatchingState=StateField.define({create(){return Decoration.none},update(g,d){if(!d.docChanged&&!d.selection)return g;let b=[],$=d.state.facet(bracketMatchingConfig);for(let j of d.state.selection.ranges){if(!j.empty)continue;let _e=matchBrackets(d.state,j.head,-1,$)||j.head>0&&matchBrackets(d.state,j.head-1,1,$)||$.afterCursor&&(matchBrackets(d.state,j.head,1,$)||j.headEditorView.decorations.from(g)}),bracketMatchingUnique=[bracketMatchingState,baseTheme$3];function bracketMatching(g={}){return[bracketMatchingConfig.of(g),bracketMatchingUnique]}const bracketMatchingHandle=new NodeProp;function matchingNodes(g,d,b){let $=g.prop(d<0?NodeProp.openedBy:NodeProp.closedBy);if($)return $;if(g.name.length==1){let j=b.indexOf(g.name);if(j>-1&&j%2==(d<0?1:0))return[b[j+d]]}return null}function findHandle(g){let d=g.type.prop(bracketMatchingHandle);return d?d(g.node):g}function matchBrackets(g,d,b,$={}){let j=$.maxScanDistance||DefaultScanDist,_e=$.brackets||DefaultBrackets,et=syntaxTree(g),tt=et.resolveInner(d,b);for(let nt=tt;nt;nt=nt.parent){let rt=matchingNodes(nt.type,b,_e);if(rt&&nt.from0?d>=it.from&&dit.from&&d<=it.to))return matchMarkedBrackets(g,d,b,nt,it,rt,_e)}}return matchPlainBrackets(g,d,b,et,tt.type,j,_e)}function matchMarkedBrackets(g,d,b,$,j,_e,et){let tt=$.parent,nt={from:j.from,to:j.to},rt=0,it=tt==null?void 0:tt.cursor();if(it&&(b<0?it.childBefore($.from):it.childAfter($.to)))do if(b<0?it.to<=$.from:it.from>=$.to){if(rt==0&&_e.indexOf(it.type.name)>-1&&it.from0)return null;let rt={from:b<0?d-1:d,to:b>0?d+1:d},it=g.doc.iterRange(d,b>0?g.doc.length:0),st=0;for(let ot=0;!it.next().done&&ot<=_e;){let at=it.value;b<0&&(ot+=at.length);let ut=d+ot*b;for(let ct=b>0?0:at.length-1,dt=b>0?at.length:-1;ct!=dt;ct+=b){let ht=et.indexOf(at[ct]);if(!(ht<0||$.resolveInner(ut+ct,1).type!=j))if(ht%2==0==b>0)st++;else{if(st==1)return{start:rt,end:{from:ut+ct,to:ut+ct+1},matched:ht>>1==nt>>1};st--}}b>0&&(ot+=at.length)}return it.done?{start:rt,matched:!1}:null}const noTokens=Object.create(null),typeArray=[NodeType.none],warned=[],byTag=Object.create(null),defaultTable=Object.create(null);for(let[g,d]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])defaultTable[g]=createTokenType(noTokens,d);function warnForPart(g,d){warned.indexOf(g)>-1||(warned.push(g),console.warn(d))}function createTokenType(g,d){let b=[];for(let tt of d.split(" ")){let nt=[];for(let rt of tt.split(".")){let it=g[rt]||tags[rt];it?typeof it=="function"?nt.length?nt=nt.map(it):warnForPart(rt,`Modifier ${rt} used at start of tag`):nt.length?warnForPart(rt,`Tag ${rt} used as modifier`):nt=Array.isArray(it)?it:[it]:warnForPart(rt,`Unknown highlighting tag ${rt}`)}for(let rt of nt)b.push(rt)}if(!b.length)return 0;let $=d.replace(/ /g,"_"),j=$+" "+b.map(tt=>tt.id),_e=byTag[j];if(_e)return _e.id;let et=byTag[j]=NodeType.define({id:typeArray.length,name:$,props:[styleTags({[$]:b})]});return typeArray.push(et),et.id}Direction.RTL,Direction.LTR;const toggleComment=g=>{let{state:d}=g,b=d.doc.lineAt(d.selection.main.from),$=getConfig(g.state,b.from);return $.line?toggleLineComment(g):$.block?toggleBlockCommentByLine(g):!1};function command(g,d){return({state:b,dispatch:$})=>{if(b.readOnly)return!1;let j=g(d,b);return j?($(b.update(j)),!0):!1}}const toggleLineComment=command(changeLineComment,0),toggleBlockComment=command(changeBlockComment,0),toggleBlockCommentByLine=command((g,d)=>changeBlockComment(g,d,selectedLineRanges(d)),0);function getConfig(g,d){let b=g.languageDataAt("commentTokens",d);return b.length?b[0]:{}}const SearchMargin=50;function findBlockComment(g,{open:d,close:b},$,j){let _e=g.sliceDoc($-SearchMargin,$),et=g.sliceDoc(j,j+SearchMargin),tt=/\s*$/.exec(_e)[0].length,nt=/^\s*/.exec(et)[0].length,rt=_e.length-tt;if(_e.slice(rt-d.length,rt)==d&&et.slice(nt,nt+b.length)==b)return{open:{pos:$-tt,margin:tt&&1},close:{pos:j+nt,margin:nt&&1}};let it,st;j-$<=2*SearchMargin?it=st=g.sliceDoc($,j):(it=g.sliceDoc($,$+SearchMargin),st=g.sliceDoc(j-SearchMargin,j));let ot=/^\s*/.exec(it)[0].length,at=/\s*$/.exec(st)[0].length,ut=st.length-at-b.length;return it.slice(ot,ot+d.length)==d&&st.slice(ut,ut+b.length)==b?{open:{pos:$+ot+d.length,margin:/\s/.test(it.charAt(ot+d.length))?1:0},close:{pos:j-at-b.length,margin:/\s/.test(st.charAt(ut-1))?1:0}}:null}function selectedLineRanges(g){let d=[];for(let b of g.selection.ranges){let $=g.doc.lineAt(b.from),j=b.to<=$.to?$:g.doc.lineAt(b.to),_e=d.length-1;_e>=0&&d[_e].to>$.from?d[_e].to=j.to:d.push({from:$.from+/^\s*/.exec($.text)[0].length,to:j.to})}return d}function changeBlockComment(g,d,b=d.selection.ranges){let $=b.map(_e=>getConfig(d,_e.from).block);if(!$.every(_e=>_e))return null;let j=b.map((_e,et)=>findBlockComment(d,$[et],_e.from,_e.to));if(g!=2&&!j.every(_e=>_e))return{changes:d.changes(b.map((_e,et)=>j[et]?[]:[{from:_e.from,insert:$[et].open+" "},{from:_e.to,insert:" "+$[et].close}]))};if(g!=1&&j.some(_e=>_e)){let _e=[];for(let et=0,tt;etj&&(_e==et||et>st.from)){j=st.from;let ot=/^\s*/.exec(st.text)[0].length,at=ot==st.length,ut=st.text.slice(ot,ot+rt.length)==rt?ot:-1;ot_e.comment<0&&(!_e.empty||_e.single))){let _e=[];for(let{line:tt,token:nt,indent:rt,empty:it,single:st}of $)(st||!it)&&_e.push({from:tt.from+rt,insert:nt+" "});let et=d.changes(_e);return{changes:et,selection:d.selection.map(et,1)}}else if(g!=1&&$.some(_e=>_e.comment>=0)){let _e=[];for(let{line:et,comment:tt,token:nt}of $)if(tt>=0){let rt=et.from+tt,it=rt+nt.length;et.text[it-et.from]==" "&&it++,_e.push({from:rt,to:it})}return{changes:_e}}return null}const fromHistory=Annotation.define(),isolateHistory=Annotation.define(),invertedEffects=Facet.define(),historyConfig=Facet.define({combine(g){return combineConfig(g,{minDepth:100,newGroupDelay:500,joinToEvent:(d,b)=>b},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(d,b)=>($,j)=>d($,j)||b($,j)})}}),historyField_=StateField.define({create(){return HistoryState.empty},update(g,d){let b=d.state.facet(historyConfig),$=d.annotation(fromHistory);if($){let nt=HistEvent.fromTransaction(d,$.selection),rt=$.side,it=rt==0?g.undone:g.done;return nt?it=updateBranch(it,it.length,b.minDepth,nt):it=addSelection(it,d.startState.selection),new HistoryState(rt==0?$.rest:it,rt==0?it:$.rest)}let j=d.annotation(isolateHistory);if((j=="full"||j=="before")&&(g=g.isolate()),d.annotation(Transaction.addToHistory)===!1)return d.changes.empty?g:g.addMapping(d.changes.desc);let _e=HistEvent.fromTransaction(d),et=d.annotation(Transaction.time),tt=d.annotation(Transaction.userEvent);return _e?g=g.addChanges(_e,et,tt,b,d):d.selection&&(g=g.addSelection(d.startState.selection,et,tt,b.newGroupDelay)),(j=="full"||j=="after")&&(g=g.isolate()),g},toJSON(g){return{done:g.done.map(d=>d.toJSON()),undone:g.undone.map(d=>d.toJSON())}},fromJSON(g){return new HistoryState(g.done.map(HistEvent.fromJSON),g.undone.map(HistEvent.fromJSON))}});function history(g={}){return[historyField_,historyConfig.of(g),EditorView.domEventHandlers({beforeinput(d,b){let $=d.inputType=="historyUndo"?undo$3:d.inputType=="historyRedo"?redo:null;return $?(d.preventDefault(),$(b)):!1}})]}function cmd(g,d){return function({state:b,dispatch:$}){if(!d&&b.readOnly)return!1;let j=b.field(historyField_,!1);if(!j)return!1;let _e=j.pop(g,b,d);return _e?($(_e),!0):!1}}const undo$3=cmd(0,!1),redo=cmd(1,!1),undoSelection=cmd(0,!0),redoSelection=cmd(1,!0);class HistEvent{constructor(d,b,$,j,_e){this.changes=d,this.effects=b,this.mapped=$,this.startSelection=j,this.selectionsAfter=_e}setSelAfter(d){return new HistEvent(this.changes,this.effects,this.mapped,this.startSelection,d)}toJSON(){var d,b,$;return{changes:(d=this.changes)===null||d===void 0?void 0:d.toJSON(),mapped:(b=this.mapped)===null||b===void 0?void 0:b.toJSON(),startSelection:($=this.startSelection)===null||$===void 0?void 0:$.toJSON(),selectionsAfter:this.selectionsAfter.map(j=>j.toJSON())}}static fromJSON(d){return new HistEvent(d.changes&&ChangeSet.fromJSON(d.changes),[],d.mapped&&ChangeDesc.fromJSON(d.mapped),d.startSelection&&EditorSelection.fromJSON(d.startSelection),d.selectionsAfter.map(EditorSelection.fromJSON))}static fromTransaction(d,b){let $=none$2;for(let j of d.startState.facet(invertedEffects)){let _e=j(d);_e.length&&($=$.concat(_e))}return!$.length&&d.changes.empty?null:new HistEvent(d.changes.invert(d.startState.doc),$,void 0,b||d.startState.selection,none$2)}static selection(d){return new HistEvent(void 0,none$2,void 0,void 0,d)}}function updateBranch(g,d,b,$){let j=d+1>b+20?d-b-1:0,_e=g.slice(j,d);return _e.push($),_e}function isAdjacent(g,d){let b=[],$=!1;return g.iterChangedRanges((j,_e)=>b.push(j,_e)),d.iterChangedRanges((j,_e,et,tt)=>{for(let nt=0;nt=rt&&et<=it&&($=!0)}}),$}function eqSelectionShape(g,d){return g.ranges.length==d.ranges.length&&g.ranges.filter((b,$)=>b.empty!=d.ranges[$].empty).length===0}function conc(g,d){return g.length?d.length?g.concat(d):g:d}const none$2=[],MaxSelectionsPerEvent=200;function addSelection(g,d){if(g.length){let b=g[g.length-1],$=b.selectionsAfter.slice(Math.max(0,b.selectionsAfter.length-MaxSelectionsPerEvent));return $.length&&$[$.length-1].eq(d)?g:($.push(d),updateBranch(g,g.length-1,1e9,b.setSelAfter($)))}else return[HistEvent.selection([d])]}function popSelection(g){let d=g[g.length-1],b=g.slice();return b[g.length-1]=d.setSelAfter(d.selectionsAfter.slice(0,d.selectionsAfter.length-1)),b}function addMappingToBranch(g,d){if(!g.length)return g;let b=g.length,$=none$2;for(;b;){let j=mapEvent(g[b-1],d,$);if(j.changes&&!j.changes.empty||j.effects.length){let _e=g.slice(0,b);return _e[b-1]=j,_e}else d=j.mapped,b--,$=j.selectionsAfter}return $.length?[HistEvent.selection($)]:none$2}function mapEvent(g,d,b){let $=conc(g.selectionsAfter.length?g.selectionsAfter.map(tt=>tt.map(d)):none$2,b);if(!g.changes)return HistEvent.selection($);let j=g.changes.map(d),_e=d.mapDesc(g.changes,!0),et=g.mapped?g.mapped.composeDesc(_e):_e;return new HistEvent(j,StateEffect.mapEffects(g.effects,d),et,g.startSelection.map(_e),$)}const joinableUserEvent=/^(input\.type|delete)($|\.)/;class HistoryState{constructor(d,b,$=0,j=void 0){this.done=d,this.undone=b,this.prevTime=$,this.prevUserEvent=j}isolate(){return this.prevTime?new HistoryState(this.done,this.undone):this}addChanges(d,b,$,j,_e){let et=this.done,tt=et[et.length-1];return tt&&tt.changes&&!tt.changes.empty&&d.changes&&(!$||joinableUserEvent.test($))&&(!tt.selectionsAfter.length&&b-this.prevTime0&&b-this.prevTimeb.empty?g.moveByChar(b,d):rangeEnd(b,d))}function ltrAtCursor(g){return g.textDirectionAt(g.state.selection.main.head)==Direction.LTR}const cursorCharLeft=g=>cursorByChar(g,!ltrAtCursor(g)),cursorCharRight=g=>cursorByChar(g,ltrAtCursor(g));function cursorByGroup(g,d){return moveSel(g,b=>b.empty?g.moveByGroup(b,d):rangeEnd(b,d))}const cursorGroupLeft=g=>cursorByGroup(g,!ltrAtCursor(g)),cursorGroupRight=g=>cursorByGroup(g,ltrAtCursor(g));function interestingNode(g,d,b){if(d.type.prop(b))return!0;let $=d.to-d.from;return $&&($>2||/[^\s,.;:]/.test(g.sliceDoc(d.from,d.to)))||d.firstChild}function moveBySyntax(g,d,b){let $=syntaxTree(g).resolveInner(d.head),j=b?NodeProp.closedBy:NodeProp.openedBy;for(let nt=d.head;;){let rt=b?$.childAfter(nt):$.childBefore(nt);if(!rt)break;interestingNode(g,rt,j)?$=rt:nt=b?rt.to:rt.from}let _e=$.type.prop(j),et,tt;return _e&&(et=b?matchBrackets(g,$.from,1):matchBrackets(g,$.to,-1))&&et.matched?tt=b?et.end.to:et.end.from:tt=b?$.to:$.from,EditorSelection.cursor(tt,b?-1:1)}const cursorSyntaxLeft=g=>moveSel(g,d=>moveBySyntax(g.state,d,!ltrAtCursor(g))),cursorSyntaxRight=g=>moveSel(g,d=>moveBySyntax(g.state,d,ltrAtCursor(g)));function cursorByLine(g,d){return moveSel(g,b=>{if(!b.empty)return rangeEnd(b,d);let $=g.moveVertically(b,d);return $.head!=b.head?$:g.moveToLineBoundary(b,d)})}const cursorLineUp=g=>cursorByLine(g,!1),cursorLineDown=g=>cursorByLine(g,!0);function pageInfo(g){let d=g.scrollDOM.clientHeightet.empty?g.moveVertically(et,d,b.height):rangeEnd(et,d));if(j.eq($.selection))return!1;let _e;if(b.selfScroll){let et=g.coordsAtPos($.selection.main.head),tt=g.scrollDOM.getBoundingClientRect(),nt=tt.top+b.marginTop,rt=tt.bottom-b.marginBottom;et&&et.top>nt&&et.bottomcursorByPage(g,!1),cursorPageDown=g=>cursorByPage(g,!0);function moveByLineBoundary(g,d,b){let $=g.lineBlockAt(d.head),j=g.moveToLineBoundary(d,b);if(j.head==d.head&&j.head!=(b?$.to:$.from)&&(j=g.moveToLineBoundary(d,b,!1)),!b&&j.head==$.from&&$.length){let _e=/^\s*/.exec(g.state.sliceDoc($.from,Math.min($.from+100,$.to)))[0].length;_e&&d.head!=$.from+_e&&(j=EditorSelection.cursor($.from+_e))}return j}const cursorLineBoundaryForward=g=>moveSel(g,d=>moveByLineBoundary(g,d,!0)),cursorLineBoundaryBackward=g=>moveSel(g,d=>moveByLineBoundary(g,d,!1)),cursorLineBoundaryLeft=g=>moveSel(g,d=>moveByLineBoundary(g,d,!ltrAtCursor(g))),cursorLineBoundaryRight=g=>moveSel(g,d=>moveByLineBoundary(g,d,ltrAtCursor(g))),cursorLineStart=g=>moveSel(g,d=>EditorSelection.cursor(g.lineBlockAt(d.head).from,1)),cursorLineEnd=g=>moveSel(g,d=>EditorSelection.cursor(g.lineBlockAt(d.head).to,-1));function toMatchingBracket(g,d,b){let $=!1,j=updateSel(g.selection,_e=>{let et=matchBrackets(g,_e.head,-1)||matchBrackets(g,_e.head,1)||_e.head>0&&matchBrackets(g,_e.head-1,1)||_e.headtoMatchingBracket(g,d,!1);function extendSel(g,d){let b=updateSel(g.state.selection,$=>{let j=d($);return EditorSelection.range($.anchor,j.head,j.goalColumn,j.bidiLevel||void 0)});return b.eq(g.state.selection)?!1:(g.dispatch(setSel(g.state,b)),!0)}function selectByChar(g,d){return extendSel(g,b=>g.moveByChar(b,d))}const selectCharLeft=g=>selectByChar(g,!ltrAtCursor(g)),selectCharRight=g=>selectByChar(g,ltrAtCursor(g));function selectByGroup(g,d){return extendSel(g,b=>g.moveByGroup(b,d))}const selectGroupLeft=g=>selectByGroup(g,!ltrAtCursor(g)),selectGroupRight=g=>selectByGroup(g,ltrAtCursor(g)),selectSyntaxLeft=g=>extendSel(g,d=>moveBySyntax(g.state,d,!ltrAtCursor(g))),selectSyntaxRight=g=>extendSel(g,d=>moveBySyntax(g.state,d,ltrAtCursor(g)));function selectByLine(g,d){return extendSel(g,b=>g.moveVertically(b,d))}const selectLineUp=g=>selectByLine(g,!1),selectLineDown=g=>selectByLine(g,!0);function selectByPage(g,d){return extendSel(g,b=>g.moveVertically(b,d,pageInfo(g).height))}const selectPageUp=g=>selectByPage(g,!1),selectPageDown=g=>selectByPage(g,!0),selectLineBoundaryForward=g=>extendSel(g,d=>moveByLineBoundary(g,d,!0)),selectLineBoundaryBackward=g=>extendSel(g,d=>moveByLineBoundary(g,d,!1)),selectLineBoundaryLeft=g=>extendSel(g,d=>moveByLineBoundary(g,d,!ltrAtCursor(g))),selectLineBoundaryRight=g=>extendSel(g,d=>moveByLineBoundary(g,d,ltrAtCursor(g))),selectLineStart=g=>extendSel(g,d=>EditorSelection.cursor(g.lineBlockAt(d.head).from)),selectLineEnd=g=>extendSel(g,d=>EditorSelection.cursor(g.lineBlockAt(d.head).to)),cursorDocStart=({state:g,dispatch:d})=>(d(setSel(g,{anchor:0})),!0),cursorDocEnd=({state:g,dispatch:d})=>(d(setSel(g,{anchor:g.doc.length})),!0),selectDocStart=({state:g,dispatch:d})=>(d(setSel(g,{anchor:g.selection.main.anchor,head:0})),!0),selectDocEnd=({state:g,dispatch:d})=>(d(setSel(g,{anchor:g.selection.main.anchor,head:g.doc.length})),!0),selectAll=({state:g,dispatch:d})=>(d(g.update({selection:{anchor:0,head:g.doc.length},userEvent:"select"})),!0),selectLine=({state:g,dispatch:d})=>{let b=selectedLineBlocks(g).map(({from:$,to:j})=>EditorSelection.range($,Math.min(j+1,g.doc.length)));return d(g.update({selection:EditorSelection.create(b),userEvent:"select"})),!0},selectParentSyntax=({state:g,dispatch:d})=>{let b=updateSel(g.selection,$=>{var j;let _e=syntaxTree(g).resolveStack($.from,1);for(let et=_e;et;et=et.next){let{node:tt}=et;if((tt.from<$.from&&tt.to>=$.to||tt.to>$.to&&tt.from<=$.from)&&(!((j=tt.parent)===null||j===void 0)&&j.parent))return EditorSelection.range(tt.to,tt.from)}return $});return d(setSel(g,b)),!0},simplifySelection=({state:g,dispatch:d})=>{let b=g.selection,$=null;return b.ranges.length>1?$=EditorSelection.create([b.main]):b.main.empty||($=EditorSelection.create([EditorSelection.cursor(b.main.head)])),$?(d(setSel(g,$)),!0):!1};function deleteBy(g,d){if(g.state.readOnly)return!1;let b="delete.selection",{state:$}=g,j=$.changeByRange(_e=>{let{from:et,to:tt}=_e;if(et==tt){let nt=d(_e);ntet&&(b="delete.forward",nt=skipAtomic(g,nt,!0)),et=Math.min(et,nt),tt=Math.max(tt,nt)}else et=skipAtomic(g,et,!1),tt=skipAtomic(g,tt,!0);return et==tt?{range:_e}:{changes:{from:et,to:tt},range:EditorSelection.cursor(et,et<_e.head?-1:1)}});return j.changes.empty?!1:(g.dispatch($.update(j,{scrollIntoView:!0,userEvent:b,effects:b=="delete.selection"?EditorView.announce.of($.phrase("Selection deleted")):void 0})),!0)}function skipAtomic(g,d,b){if(g instanceof EditorView)for(let $ of g.state.facet(EditorView.atomicRanges).map(j=>j(g)))$.between(d,d,(j,_e)=>{jd&&(d=b?_e:j)});return d}const deleteByChar=(g,d)=>deleteBy(g,b=>{let $=b.from,{state:j}=g,_e=j.doc.lineAt($),et,tt;if(!d&&$>_e.from&&$<_e.from+200&&!/[^ \t]/.test(et=_e.text.slice(0,$-_e.from))){if(et[et.length-1]==" ")return $-1;let nt=countColumn(et,j.tabSize),rt=nt%getIndentUnit(j)||getIndentUnit(j);for(let it=0;itdeleteByChar(g,!1),deleteCharForward=g=>deleteByChar(g,!0),deleteByGroup=(g,d)=>deleteBy(g,b=>{let $=b.head,{state:j}=g,_e=j.doc.lineAt($),et=j.charCategorizer($);for(let tt=null;;){if($==(d?_e.to:_e.from)){$==b.head&&_e.number!=(d?j.doc.lines:1)&&($+=d?1:-1);break}let nt=findClusterBreak(_e.text,$-_e.from,d)+_e.from,rt=_e.text.slice(Math.min($,nt)-_e.from,Math.max($,nt)-_e.from),it=et(rt);if(tt!=null&&it!=tt)break;(rt!=" "||$!=b.head)&&(tt=it),$=nt}return $}),deleteGroupBackward=g=>deleteByGroup(g,!1),deleteGroupForward=g=>deleteByGroup(g,!0),deleteToLineEnd=g=>deleteBy(g,d=>{let b=g.lineBlockAt(d.head).to;return d.headdeleteBy(g,d=>{let b=g.moveToLineBoundary(d,!1).head;return d.head>b?b:Math.max(0,d.head-1)}),deleteLineBoundaryForward=g=>deleteBy(g,d=>{let b=g.moveToLineBoundary(d,!0).head;return d.head{if(g.readOnly)return!1;let b=g.changeByRange($=>({changes:{from:$.from,to:$.to,insert:Text.of(["",""])},range:EditorSelection.cursor($.from)}));return d(g.update(b,{scrollIntoView:!0,userEvent:"input"})),!0},transposeChars=({state:g,dispatch:d})=>{if(g.readOnly)return!1;let b=g.changeByRange($=>{if(!$.empty||$.from==0||$.from==g.doc.length)return{range:$};let j=$.from,_e=g.doc.lineAt(j),et=j==_e.from?j-1:findClusterBreak(_e.text,j-_e.from,!1)+_e.from,tt=j==_e.to?j+1:findClusterBreak(_e.text,j-_e.from,!0)+_e.from;return{changes:{from:et,to:tt,insert:g.doc.slice(j,tt).append(g.doc.slice(et,j))},range:EditorSelection.cursor(tt)}});return b.changes.empty?!1:(d(g.update(b,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function selectedLineBlocks(g){let d=[],b=-1;for(let $ of g.selection.ranges){let j=g.doc.lineAt($.from),_e=g.doc.lineAt($.to);if(!$.empty&&$.to==_e.from&&(_e=g.doc.lineAt($.to-1)),b>=j.number){let et=d[d.length-1];et.to=_e.to,et.ranges.push($)}else d.push({from:j.from,to:_e.to,ranges:[$]});b=_e.number+1}return d}function moveLine(g,d,b){if(g.readOnly)return!1;let $=[],j=[];for(let _e of selectedLineBlocks(g)){if(b?_e.to==g.doc.length:_e.from==0)continue;let et=g.doc.lineAt(b?_e.to+1:_e.from-1),tt=et.length+1;if(b){$.push({from:_e.to,to:et.to},{from:_e.from,insert:et.text+g.lineBreak});for(let nt of _e.ranges)j.push(EditorSelection.range(Math.min(g.doc.length,nt.anchor+tt),Math.min(g.doc.length,nt.head+tt)))}else{$.push({from:et.from,to:_e.from},{from:_e.to,insert:g.lineBreak+et.text});for(let nt of _e.ranges)j.push(EditorSelection.range(nt.anchor-tt,nt.head-tt))}}return $.length?(d(g.update({changes:$,scrollIntoView:!0,selection:EditorSelection.create(j,g.selection.mainIndex),userEvent:"move.line"})),!0):!1}const moveLineUp=({state:g,dispatch:d})=>moveLine(g,d,!1),moveLineDown=({state:g,dispatch:d})=>moveLine(g,d,!0);function copyLine(g,d,b){if(g.readOnly)return!1;let $=[];for(let j of selectedLineBlocks(g))b?$.push({from:j.from,insert:g.doc.slice(j.from,j.to)+g.lineBreak}):$.push({from:j.to,insert:g.lineBreak+g.doc.slice(j.from,j.to)});return d(g.update({changes:$,scrollIntoView:!0,userEvent:"input.copyline"})),!0}const copyLineUp=({state:g,dispatch:d})=>copyLine(g,d,!1),copyLineDown=({state:g,dispatch:d})=>copyLine(g,d,!0),deleteLine=g=>{if(g.state.readOnly)return!1;let{state:d}=g,b=d.changes(selectedLineBlocks(d).map(({from:j,to:_e})=>(j>0?j--:_eg.moveVertically(j,!0)).map(b);return g.dispatch({changes:b,selection:$,scrollIntoView:!0,userEvent:"delete.line"}),!0};function isBetweenBrackets(g,d){if(/\(\)|\[\]|\{\}/.test(g.sliceDoc(d-1,d+1)))return{from:d,to:d};let b=syntaxTree(g).resolveInner(d),$=b.childBefore(d),j=b.childAfter(d),_e;return $&&j&&$.to<=d&&j.from>=d&&(_e=$.type.prop(NodeProp.closedBy))&&_e.indexOf(j.name)>-1&&g.doc.lineAt($.to).from==g.doc.lineAt(j.from).from&&!/\S/.test(g.sliceDoc($.to,j.from))?{from:$.to,to:j.from}:null}const insertNewlineAndIndent=newlineAndIndent(!1),insertBlankLine=newlineAndIndent(!0);function newlineAndIndent(g){return({state:d,dispatch:b})=>{if(d.readOnly)return!1;let $=d.changeByRange(j=>{let{from:_e,to:et}=j,tt=d.doc.lineAt(_e),nt=!g&&_e==et&&isBetweenBrackets(d,_e);g&&(_e=et=(et<=tt.to?tt:d.doc.lineAt(et)).to);let rt=new IndentContext(d,{simulateBreak:_e,simulateDoubleBreak:!!nt}),it=getIndentation(rt,_e);for(it==null&&(it=countColumn(/^\s*/.exec(d.doc.lineAt(_e).text)[0],d.tabSize));ettt.from&&_e{let j=[];for(let et=$.from;et<=$.to;){let tt=g.doc.lineAt(et);tt.number>b&&($.empty||$.to>tt.from)&&(d(tt,j,$),b=tt.number),et=tt.to+1}let _e=g.changes(j);return{changes:j,range:EditorSelection.range(_e.mapPos($.anchor,1),_e.mapPos($.head,1))}})}const indentSelection=({state:g,dispatch:d})=>{if(g.readOnly)return!1;let b=Object.create(null),$=new IndentContext(g,{overrideIndentation:_e=>{let et=b[_e];return et??-1}}),j=changeBySelectedLine(g,(_e,et,tt)=>{let nt=getIndentation($,_e.from);if(nt==null)return;/\S/.test(_e.text)||(nt=0);let rt=/^\s*/.exec(_e.text)[0],it=indentString(g,nt);(rt!=it||tt.from<_e.from+rt.length)&&(b[_e.from]=nt,et.push({from:_e.from,to:_e.from+rt.length,insert:it}))});return j.changes.empty||d(g.update(j,{userEvent:"indent"})),!0},indentMore=({state:g,dispatch:d})=>g.readOnly?!1:(d(g.update(changeBySelectedLine(g,(b,$)=>{$.push({from:b.from,insert:g.facet(indentUnit)})}),{userEvent:"input.indent"})),!0),indentLess=({state:g,dispatch:d})=>g.readOnly?!1:(d(g.update(changeBySelectedLine(g,(b,$)=>{let j=/^\s*/.exec(b.text)[0];if(!j)return;let _e=countColumn(j,g.tabSize),et=0,tt=indentString(g,Math.max(0,_e-getIndentUnit(g)));for(;et({mac:g.key,run:g.run,shift:g.shift}))),defaultKeymap=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:cursorSyntaxLeft,shift:selectSyntaxLeft},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:cursorSyntaxRight,shift:selectSyntaxRight},{key:"Alt-ArrowUp",run:moveLineUp},{key:"Shift-Alt-ArrowUp",run:copyLineUp},{key:"Alt-ArrowDown",run:moveLineDown},{key:"Shift-Alt-ArrowDown",run:copyLineDown},{key:"Escape",run:simplifySelection},{key:"Mod-Enter",run:insertBlankLine},{key:"Alt-l",mac:"Ctrl-l",run:selectLine},{key:"Mod-i",run:selectParentSyntax,preventDefault:!0},{key:"Mod-[",run:indentLess},{key:"Mod-]",run:indentMore},{key:"Mod-Alt-\\",run:indentSelection},{key:"Shift-Mod-k",run:deleteLine},{key:"Shift-Mod-\\",run:cursorMatchingBracket},{key:"Mod-/",run:toggleComment},{key:"Alt-A",run:toggleBlockComment}].concat(standardKeymap),indentWithTab={key:"Tab",run:indentMore,shift:indentLess};function crelt(){var g=arguments[0];typeof g=="string"&&(g=document.createElement(g));var d=1,b=arguments[1];if(b&&typeof b=="object"&&b.nodeType==null&&!Array.isArray(b)){for(var $ in b)if(Object.prototype.hasOwnProperty.call(b,$)){var j=b[$];typeof j=="string"?g.setAttribute($,j):j!=null&&(g[$]=j)}d++}for(;dg.normalize("NFKD"):g=>g;class SearchCursor{constructor(d,b,$=0,j=d.length,_e,et){this.test=et,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=d.iterRange($,j),this.bufferStart=$,this.normalize=_e?tt=>_e(basicNormalize(tt)):basicNormalize,this.query=this.normalize(b)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return codePointAt(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let d=this.peek();if(d<0)return this.done=!0,this;let b=fromCodePoint(d),$=this.bufferStart+this.bufferPos;this.bufferPos+=codePointSize(d);let j=this.normalize(b);for(let _e=0,et=$;;_e++){let tt=j.charCodeAt(_e),nt=this.match(tt,et);if(_e==j.length-1){if(nt)return this.value=nt,this;break}et==$&&_ethis.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let d=this.matchPos-this.curLineStart;;){this.re.lastIndex=d;let b=this.matchPos<=this.to&&this.re.exec(this.curLine);if(b){let $=this.curLineStart+b.index,j=$+b[0].length;if(this.matchPos=toCharEnd(this.text,j+($==j?1:0)),$==this.curLineStart+this.curLine.length&&this.nextLine(),($this.value.to)&&(!this.test||this.test($,j,b)))return this.value={from:$,to:j,match:b},this;d=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length=$||j.to<=b){let tt=new FlattenedDoc(b,d.sliceString(b,$));return flattened.set(d,tt),tt}if(j.from==b&&j.to==$)return j;let{text:_e,from:et}=j;return et>b&&(_e=d.sliceString(b,et)+_e,et=b),j.to<$&&(_e+=d.sliceString(j.to,$)),flattened.set(d,new FlattenedDoc(et,_e)),new FlattenedDoc(b,_e.slice(b-et,$-et))}}class MultilineRegExpCursor{constructor(d,b,$,j,_e){this.text=d,this.to=_e,this.done=!1,this.value=empty$1,this.matchPos=toCharEnd(d,j),this.re=new RegExp(b,baseFlags+($!=null&&$.ignoreCase?"i":"")),this.test=$==null?void 0:$.test,this.flat=FlattenedDoc.get(d,j,this.chunkEnd(j+5e3))}chunkEnd(d){return d>=this.to?this.to:this.text.lineAt(d).to}next(){for(;;){let d=this.re.lastIndex=this.matchPos-this.flat.from,b=this.re.exec(this.flat.text);if(b&&!b[0]&&b.index==d&&(this.re.lastIndex=d+1,b=this.re.exec(this.flat.text)),b){let $=this.flat.from+b.index,j=$+b[0].length;if((this.flat.to>=this.to||b.index+b[0].length<=this.flat.text.length-10)&&(!this.test||this.test($,j,b)))return this.value={from:$,to:j,match:b},this.matchPos=toCharEnd(this.text,j+($==j?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=FlattenedDoc.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(RegExpCursor.prototype[Symbol.iterator]=MultilineRegExpCursor.prototype[Symbol.iterator]=function(){return this});function validRegExp(g){try{return new RegExp(g,baseFlags),!0}catch{return!1}}function toCharEnd(g,d){if(d>=g.length)return d;let b=g.lineAt(d),$;for(;d=56320&&$<57344;)d++;return d}function createLineDialog(g){let d=String(g.state.doc.lineAt(g.state.selection.main.head).number),b=crelt("input",{class:"cm-textfield",name:"line",value:d}),$=crelt("form",{class:"cm-gotoLine",onkeydown:_e=>{_e.keyCode==27?(_e.preventDefault(),g.dispatch({effects:dialogEffect.of(!1)}),g.focus()):_e.keyCode==13&&(_e.preventDefault(),j())},onsubmit:_e=>{_e.preventDefault(),j()}},crelt("label",g.state.phrase("Go to line"),": ",b)," ",crelt("button",{class:"cm-button",type:"submit"},g.state.phrase("go")));function j(){let _e=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(b.value);if(!_e)return;let{state:et}=g,tt=et.doc.lineAt(et.selection.main.head),[,nt,rt,it,st]=_e,ot=it?+it.slice(1):0,at=rt?+rt:tt.number;if(rt&&st){let dt=at/100;nt&&(dt=dt*(nt=="-"?-1:1)+tt.number/et.doc.lines),at=Math.round(et.doc.lines*dt)}else rt&&nt&&(at=at*(nt=="-"?-1:1)+tt.number);let ut=et.doc.line(Math.max(1,Math.min(et.doc.lines,at))),ct=EditorSelection.cursor(ut.from+Math.max(0,Math.min(ot,ut.length)));g.dispatch({effects:[dialogEffect.of(!1),EditorView.scrollIntoView(ct.from,{y:"center"})],selection:ct}),g.focus()}return{dom:$}}const dialogEffect=StateEffect.define(),dialogField=StateField.define({create(){return!0},update(g,d){for(let b of d.effects)b.is(dialogEffect)&&(g=b.value);return g},provide:g=>showPanel.from(g,d=>d?createLineDialog:null)}),gotoLine=g=>{let d=getPanel(g,createLineDialog);if(!d){let b=[dialogEffect.of(!0)];g.state.field(dialogField,!1)==null&&b.push(StateEffect.appendConfig.of([dialogField,baseTheme$1$1])),g.dispatch({effects:b}),d=getPanel(g,createLineDialog)}return d&&d.dom.querySelector("input").select(),!0},baseTheme$1$1=EditorView.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px","& label":{fontSize:"80%"}}}),defaultHighlightOptions={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},highlightConfig=Facet.define({combine(g){return combineConfig(g,defaultHighlightOptions,{highlightWordAroundCursor:(d,b)=>d||b,minSelectionLength:Math.min,maxMatches:Math.min})}});function highlightSelectionMatches(g){let d=[defaultTheme,matchHighlighter];return g&&d.push(highlightConfig.of(g)),d}const matchDeco=Decoration.mark({class:"cm-selectionMatch"}),mainMatchDeco=Decoration.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function insideWordBoundaries(g,d,b,$){return(b==0||g(d.sliceDoc(b-1,b))!=CharCategory.Word)&&($==d.doc.length||g(d.sliceDoc($,$+1))!=CharCategory.Word)}function insideWord(g,d,b,$){return g(d.sliceDoc(b,b+1))==CharCategory.Word&&g(d.sliceDoc($-1,$))==CharCategory.Word}const matchHighlighter=ViewPlugin.fromClass(class{constructor(g){this.decorations=this.getDeco(g)}update(g){(g.selectionSet||g.docChanged||g.viewportChanged)&&(this.decorations=this.getDeco(g.view))}getDeco(g){let d=g.state.facet(highlightConfig),{state:b}=g,$=b.selection;if($.ranges.length>1)return Decoration.none;let j=$.main,_e,et=null;if(j.empty){if(!d.highlightWordAroundCursor)return Decoration.none;let nt=b.wordAt(j.head);if(!nt)return Decoration.none;et=b.charCategorizer(j.head),_e=b.sliceDoc(nt.from,nt.to)}else{let nt=j.to-j.from;if(nt200)return Decoration.none;if(d.wholeWords){if(_e=b.sliceDoc(j.from,j.to),et=b.charCategorizer(j.head),!(insideWordBoundaries(et,b,j.from,j.to)&&insideWord(et,b,j.from,j.to)))return Decoration.none}else if(_e=b.sliceDoc(j.from,j.to).trim(),!_e)return Decoration.none}let tt=[];for(let nt of g.visibleRanges){let rt=new SearchCursor(b.doc,_e,nt.from,nt.to);for(;!rt.next().done;){let{from:it,to:st}=rt.value;if((!et||insideWordBoundaries(et,b,it,st))&&(j.empty&&it<=j.from&&st>=j.to?tt.push(mainMatchDeco.range(it,st)):(it>=j.to||st<=j.from)&&tt.push(matchDeco.range(it,st)),tt.length>d.maxMatches))return Decoration.none}}return Decoration.set(tt)}},{decorations:g=>g.decorations}),defaultTheme=EditorView.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),selectWord=({state:g,dispatch:d})=>{let{selection:b}=g,$=EditorSelection.create(b.ranges.map(j=>g.wordAt(j.head)||EditorSelection.cursor(j.head)),b.mainIndex);return $.eq(b)?!1:(d(g.update({selection:$})),!0)};function findNextOccurrence(g,d){let{main:b,ranges:$}=g.selection,j=g.wordAt(b.head),_e=j&&j.from==b.from&&j.to==b.to;for(let et=!1,tt=new SearchCursor(g.doc,d,$[$.length-1].to);;)if(tt.next(),tt.done){if(et)return null;tt=new SearchCursor(g.doc,d,0,Math.max(0,$[$.length-1].from-1)),et=!0}else{if(et&&$.some(nt=>nt.from==tt.value.from))continue;if(_e){let nt=g.wordAt(tt.value.from);if(!nt||nt.from!=tt.value.from||nt.to!=tt.value.to)continue}return tt.value}}const selectNextOccurrence=({state:g,dispatch:d})=>{let{ranges:b}=g.selection;if(b.some(_e=>_e.from===_e.to))return selectWord({state:g,dispatch:d});let $=g.sliceDoc(b[0].from,b[0].to);if(g.selection.ranges.some(_e=>g.sliceDoc(_e.from,_e.to)!=$))return!1;let j=findNextOccurrence(g,$);return j?(d(g.update({selection:g.selection.addRange(EditorSelection.range(j.from,j.to),!1),effects:EditorView.scrollIntoView(j.to)})),!0):!1},searchConfigFacet=Facet.define({combine(g){return combineConfig(g,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:d=>new SearchPanel(d),scrollToMatch:d=>EditorView.scrollIntoView(d)})}});class SearchQuery{constructor(d){this.search=d.search,this.caseSensitive=!!d.caseSensitive,this.literal=!!d.literal,this.regexp=!!d.regexp,this.replace=d.replace||"",this.valid=!!this.search&&(!this.regexp||validRegExp(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!d.wholeWord}unquote(d){return this.literal?d:d.replace(/\\([nrt\\])/g,(b,$)=>$=="n"?` +`:$=="r"?"\r":$=="t"?" ":"\\")}eq(d){return this.search==d.search&&this.replace==d.replace&&this.caseSensitive==d.caseSensitive&&this.regexp==d.regexp&&this.wholeWord==d.wholeWord}create(){return this.regexp?new RegExpQuery(this):new StringQuery(this)}getCursor(d,b=0,$){let j=d.doc?d:EditorState.create({doc:d});return $==null&&($=j.doc.length),this.regexp?regexpCursor(this,j,b,$):stringCursor(this,j,b,$)}}class QueryType{constructor(d){this.spec=d}}function stringCursor(g,d,b,$){return new SearchCursor(d.doc,g.unquoted,b,$,g.caseSensitive?void 0:j=>j.toLowerCase(),g.wholeWord?stringWordTest(d.doc,d.charCategorizer(d.selection.main.head)):void 0)}function stringWordTest(g,d){return(b,$,j,_e)=>((_e>b||_e+j.length<$)&&(_e=Math.max(0,b-2),j=g.sliceString(_e,Math.min(g.length,$+2))),(d(charBefore(j,b-_e))!=CharCategory.Word||d(charAfter(j,b-_e))!=CharCategory.Word)&&(d(charAfter(j,$-_e))!=CharCategory.Word||d(charBefore(j,$-_e))!=CharCategory.Word))}class StringQuery extends QueryType{constructor(d){super(d)}nextMatch(d,b,$){let j=stringCursor(this.spec,d,$,d.doc.length).nextOverlapping();return j.done&&(j=stringCursor(this.spec,d,0,b).nextOverlapping()),j.done?null:j.value}prevMatchInRange(d,b,$){for(let j=$;;){let _e=Math.max(b,j-1e4-this.spec.unquoted.length),et=stringCursor(this.spec,d,_e,j),tt=null;for(;!et.nextOverlapping().done;)tt=et.value;if(tt)return tt;if(_e==b)return null;j-=1e4}}prevMatch(d,b,$){return this.prevMatchInRange(d,0,b)||this.prevMatchInRange(d,$,d.doc.length)}getReplacement(d){return this.spec.unquote(this.spec.replace)}matchAll(d,b){let $=stringCursor(this.spec,d,0,d.doc.length),j=[];for(;!$.next().done;){if(j.length>=b)return null;j.push($.value)}return j}highlight(d,b,$,j){let _e=stringCursor(this.spec,d,Math.max(0,b-this.spec.unquoted.length),Math.min($+this.spec.unquoted.length,d.doc.length));for(;!_e.next().done;)j(_e.value.from,_e.value.to)}}function regexpCursor(g,d,b,$){return new RegExpCursor(d.doc,g.search,{ignoreCase:!g.caseSensitive,test:g.wholeWord?regexpWordTest(d.charCategorizer(d.selection.main.head)):void 0},b,$)}function charBefore(g,d){return g.slice(findClusterBreak(g,d,!1),d)}function charAfter(g,d){return g.slice(d,findClusterBreak(g,d))}function regexpWordTest(g){return(d,b,$)=>!$[0].length||(g(charBefore($.input,$.index))!=CharCategory.Word||g(charAfter($.input,$.index))!=CharCategory.Word)&&(g(charAfter($.input,$.index+$[0].length))!=CharCategory.Word||g(charBefore($.input,$.index+$[0].length))!=CharCategory.Word)}class RegExpQuery extends QueryType{nextMatch(d,b,$){let j=regexpCursor(this.spec,d,$,d.doc.length).next();return j.done&&(j=regexpCursor(this.spec,d,0,b).next()),j.done?null:j.value}prevMatchInRange(d,b,$){for(let j=1;;j++){let _e=Math.max(b,$-j*1e4),et=regexpCursor(this.spec,d,_e,$),tt=null;for(;!et.next().done;)tt=et.value;if(tt&&(_e==b||tt.from>_e+10))return tt;if(_e==b)return null}}prevMatch(d,b,$){return this.prevMatchInRange(d,0,b)||this.prevMatchInRange(d,$,d.doc.length)}getReplacement(d){return this.spec.unquote(this.spec.replace).replace(/\$([$&\d+])/g,(b,$)=>$=="$"?"$":$=="&"?d.match[0]:$!="0"&&+$=b)return null;j.push($.value)}return j}highlight(d,b,$,j){let _e=regexpCursor(this.spec,d,Math.max(0,b-250),Math.min($+250,d.doc.length));for(;!_e.next().done;)j(_e.value.from,_e.value.to)}}const setSearchQuery=StateEffect.define(),togglePanel$1=StateEffect.define(),searchState=StateField.define({create(g){return new SearchState(defaultQuery(g).create(),null)},update(g,d){for(let b of d.effects)b.is(setSearchQuery)?g=new SearchState(b.value.create(),g.panel):b.is(togglePanel$1)&&(g=new SearchState(g.query,b.value?createSearchPanel:null));return g},provide:g=>showPanel.from(g,d=>d.panel)});class SearchState{constructor(d,b){this.query=d,this.panel=b}}const matchMark=Decoration.mark({class:"cm-searchMatch"}),selectedMatchMark=Decoration.mark({class:"cm-searchMatch cm-searchMatch-selected"}),searchHighlighter=ViewPlugin.fromClass(class{constructor(g){this.view=g,this.decorations=this.highlight(g.state.field(searchState))}update(g){let d=g.state.field(searchState);(d!=g.startState.field(searchState)||g.docChanged||g.selectionSet||g.viewportChanged)&&(this.decorations=this.highlight(d))}highlight({query:g,panel:d}){if(!d||!g.spec.valid)return Decoration.none;let{view:b}=this,$=new RangeSetBuilder;for(let j=0,_e=b.visibleRanges,et=_e.length;j_e[j+1].from-2*250;)nt=_e[++j].to;g.highlight(b.state,tt,nt,(rt,it)=>{let st=b.state.selection.ranges.some(ot=>ot.from==rt&&ot.to==it);$.add(rt,it,st?selectedMatchMark:matchMark)})}return $.finish()}},{decorations:g=>g.decorations});function searchCommand(g){return d=>{let b=d.state.field(searchState,!1);return b&&b.query.spec.valid?g(d,b):openSearchPanel(d)}}const findNext=searchCommand((g,{query:d})=>{let{to:b}=g.state.selection.main,$=d.nextMatch(g.state,b,b);if(!$)return!1;let j=EditorSelection.single($.from,$.to),_e=g.state.facet(searchConfigFacet);return g.dispatch({selection:j,effects:[announceMatch(g,$),_e.scrollToMatch(j.main,g)],userEvent:"select.search"}),selectSearchInput(g),!0}),findPrevious=searchCommand((g,{query:d})=>{let{state:b}=g,{from:$}=b.selection.main,j=d.prevMatch(b,$,$);if(!j)return!1;let _e=EditorSelection.single(j.from,j.to),et=g.state.facet(searchConfigFacet);return g.dispatch({selection:_e,effects:[announceMatch(g,j),et.scrollToMatch(_e.main,g)],userEvent:"select.search"}),selectSearchInput(g),!0}),selectMatches=searchCommand((g,{query:d})=>{let b=d.matchAll(g.state,1e3);return!b||!b.length?!1:(g.dispatch({selection:EditorSelection.create(b.map($=>EditorSelection.range($.from,$.to))),userEvent:"select.search.matches"}),!0)}),selectSelectionMatches=({state:g,dispatch:d})=>{let b=g.selection;if(b.ranges.length>1||b.main.empty)return!1;let{from:$,to:j}=b.main,_e=[],et=0;for(let tt=new SearchCursor(g.doc,g.sliceDoc($,j));!tt.next().done;){if(_e.length>1e3)return!1;tt.value.from==$&&(et=_e.length),_e.push(EditorSelection.range(tt.value.from,tt.value.to))}return d(g.update({selection:EditorSelection.create(_e,et),userEvent:"select.search.matches"})),!0},replaceNext=searchCommand((g,{query:d})=>{let{state:b}=g,{from:$,to:j}=b.selection.main;if(b.readOnly)return!1;let _e=d.nextMatch(b,$,$);if(!_e)return!1;let et=[],tt,nt,rt=[];if(_e.from==$&&_e.to==j&&(nt=b.toText(d.getReplacement(_e)),et.push({from:_e.from,to:_e.to,insert:nt}),_e=d.nextMatch(b,_e.from,_e.to),rt.push(EditorView.announce.of(b.phrase("replaced match on line $",b.doc.lineAt($).number)+"."))),_e){let it=et.length==0||et[0].from>=_e.to?0:_e.to-_e.from-nt.length;tt=EditorSelection.single(_e.from-it,_e.to-it),rt.push(announceMatch(g,_e)),rt.push(b.facet(searchConfigFacet).scrollToMatch(tt.main,g))}return g.dispatch({changes:et,selection:tt,effects:rt,userEvent:"input.replace"}),!0}),replaceAll=searchCommand((g,{query:d})=>{if(g.state.readOnly)return!1;let b=d.matchAll(g.state,1e9).map(j=>{let{from:_e,to:et}=j;return{from:_e,to:et,insert:d.getReplacement(j)}});if(!b.length)return!1;let $=g.state.phrase("replaced $ matches",b.length)+".";return g.dispatch({changes:b,effects:EditorView.announce.of($),userEvent:"input.replace.all"}),!0});function createSearchPanel(g){return g.state.facet(searchConfigFacet).createPanel(g)}function defaultQuery(g,d){var b,$,j,_e,et;let tt=g.selection.main,nt=tt.empty||tt.to>tt.from+100?"":g.sliceDoc(tt.from,tt.to);if(d&&!nt)return d;let rt=g.facet(searchConfigFacet);return new SearchQuery({search:((b=d==null?void 0:d.literal)!==null&&b!==void 0?b:rt.literal)?nt:nt.replace(/\n/g,"\\n"),caseSensitive:($=d==null?void 0:d.caseSensitive)!==null&&$!==void 0?$:rt.caseSensitive,literal:(j=d==null?void 0:d.literal)!==null&&j!==void 0?j:rt.literal,regexp:(_e=d==null?void 0:d.regexp)!==null&&_e!==void 0?_e:rt.regexp,wholeWord:(et=d==null?void 0:d.wholeWord)!==null&&et!==void 0?et:rt.wholeWord})}function getSearchInput(g){let d=getPanel(g,createSearchPanel);return d&&d.dom.querySelector("[main-field]")}function selectSearchInput(g){let d=getSearchInput(g);d&&d==g.root.activeElement&&d.select()}const openSearchPanel=g=>{let d=g.state.field(searchState,!1);if(d&&d.panel){let b=getSearchInput(g);if(b&&b!=g.root.activeElement){let $=defaultQuery(g.state,d.query.spec);$.valid&&g.dispatch({effects:setSearchQuery.of($)}),b.focus(),b.select()}}else g.dispatch({effects:[togglePanel$1.of(!0),d?setSearchQuery.of(defaultQuery(g.state,d.query.spec)):StateEffect.appendConfig.of(searchExtensions)]});return!0},closeSearchPanel=g=>{let d=g.state.field(searchState,!1);if(!d||!d.panel)return!1;let b=getPanel(g,createSearchPanel);return b&&b.dom.contains(g.root.activeElement)&&g.focus(),g.dispatch({effects:togglePanel$1.of(!1)}),!0},searchKeymap=[{key:"Mod-f",run:openSearchPanel,scope:"editor search-panel"},{key:"F3",run:findNext,shift:findPrevious,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:findNext,shift:findPrevious,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:closeSearchPanel,scope:"editor search-panel"},{key:"Mod-Shift-l",run:selectSelectionMatches},{key:"Mod-Alt-g",run:gotoLine},{key:"Mod-d",run:selectNextOccurrence,preventDefault:!0}];class SearchPanel{constructor(d){this.view=d;let b=this.query=d.state.field(searchState).query.spec;this.commit=this.commit.bind(this),this.searchField=crelt("input",{value:b.search,placeholder:phrase(d,"Find"),"aria-label":phrase(d,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=crelt("input",{value:b.replace,placeholder:phrase(d,"Replace"),"aria-label":phrase(d,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=crelt("input",{type:"checkbox",name:"case",form:"",checked:b.caseSensitive,onchange:this.commit}),this.reField=crelt("input",{type:"checkbox",name:"re",form:"",checked:b.regexp,onchange:this.commit}),this.wordField=crelt("input",{type:"checkbox",name:"word",form:"",checked:b.wholeWord,onchange:this.commit});function $(j,_e,et){return crelt("button",{class:"cm-button",name:j,onclick:_e,type:"button"},et)}this.dom=crelt("div",{onkeydown:j=>this.keydown(j),class:"cm-search"},[this.searchField,$("next",()=>findNext(d),[phrase(d,"next")]),$("prev",()=>findPrevious(d),[phrase(d,"previous")]),$("select",()=>selectMatches(d),[phrase(d,"all")]),crelt("label",null,[this.caseField,phrase(d,"match case")]),crelt("label",null,[this.reField,phrase(d,"regexp")]),crelt("label",null,[this.wordField,phrase(d,"by word")]),...d.state.readOnly?[]:[crelt("br"),this.replaceField,$("replace",()=>replaceNext(d),[phrase(d,"replace")]),$("replaceAll",()=>replaceAll(d),[phrase(d,"replace all")])],crelt("button",{name:"close",onclick:()=>closeSearchPanel(d),"aria-label":phrase(d,"close"),type:"button"},["×"])])}commit(){let d=new SearchQuery({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});d.eq(this.query)||(this.query=d,this.view.dispatch({effects:setSearchQuery.of(d)}))}keydown(d){runScopeHandlers(this.view,d,"search-panel")?d.preventDefault():d.keyCode==13&&d.target==this.searchField?(d.preventDefault(),(d.shiftKey?findPrevious:findNext)(this.view)):d.keyCode==13&&d.target==this.replaceField&&(d.preventDefault(),replaceNext(this.view))}update(d){for(let b of d.transactions)for(let $ of b.effects)$.is(setSearchQuery)&&!$.value.eq(this.query)&&this.setQuery($.value)}setQuery(d){this.query=d,this.searchField.value=d.search,this.replaceField.value=d.replace,this.caseField.checked=d.caseSensitive,this.reField.checked=d.regexp,this.wordField.checked=d.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(searchConfigFacet).top}}function phrase(g,d){return g.state.phrase(d)}const AnnounceMargin=30,Break=/[\s\.,:;?!]/;function announceMatch(g,{from:d,to:b}){let $=g.state.doc.lineAt(d),j=g.state.doc.lineAt(b).to,_e=Math.max($.from,d-AnnounceMargin),et=Math.min(j,b+AnnounceMargin),tt=g.state.sliceDoc(_e,et);if(_e!=$.from){for(let nt=0;nttt.length-AnnounceMargin;nt--)if(!Break.test(tt[nt-1])&&Break.test(tt[nt])){tt=tt.slice(0,nt);break}}return EditorView.announce.of(`${g.state.phrase("current match")}. ${tt} ${g.state.phrase("on line")} ${$.number}.`)}const baseTheme$2=EditorView.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),searchExtensions=[searchState,Prec.low(searchHighlighter),baseTheme$2];class CompletionContext{constructor(d,b,$){this.state=d,this.pos=b,this.explicit=$,this.abortListeners=[]}tokenBefore(d){let b=syntaxTree(this.state).resolveInner(this.pos,-1);for(;b&&d.indexOf(b.name)<0;)b=b.parent;return b?{from:b.from,to:this.pos,text:this.state.sliceDoc(b.from,this.pos),type:b.type}:null}matchBefore(d){let b=this.state.doc.lineAt(this.pos),$=Math.max(b.from,this.pos-250),j=b.text.slice($-b.from,this.pos-b.from),_e=j.search(ensureAnchor(d,!1));return _e<0?null:{from:$+_e,to:this.pos,text:j.slice(_e)}}get aborted(){return this.abortListeners==null}addEventListener(d,b){d=="abort"&&this.abortListeners&&this.abortListeners.push(b)}}function toSet(g){let d=Object.keys(g).join(""),b=/\w/.test(d);return b&&(d=d.replace(/\w/g,"")),`[${b?"\\w":""}${d.replace(/[^\w\s]/g,"\\$&")}]`}function prefixMatch(g){let d=Object.create(null),b=Object.create(null);for(let{label:j}of g){d[j[0]]=!0;for(let _e=1;_etypeof j=="string"?{label:j}:j),[b,$]=d.every(j=>/^\w+$/.test(j.label))?[/\w*$/,/\w+$/]:prefixMatch(d);return j=>{let _e=j.matchBefore($);return _e||j.explicit?{from:_e?_e.from:j.pos,options:d,validFor:b}:null}}class Option{constructor(d,b,$,j){this.completion=d,this.source=b,this.match=$,this.score=j}}function cur(g){return g.selection.main.from}function ensureAnchor(g,d){var b;let{source:$}=g,j=d&&$[0]!="^",_e=$[$.length-1]!="$";return!j&&!_e?g:new RegExp(`${j?"^":""}(?:${$})${_e?"$":""}`,(b=g.flags)!==null&&b!==void 0?b:g.ignoreCase?"i":"")}const pickedCompletion=Annotation.define();function insertCompletionText(g,d,b,$){let{main:j}=g.selection,_e=b-j.from,et=$-j.from;return Object.assign(Object.assign({},g.changeByRange(tt=>tt!=j&&b!=$&&g.sliceDoc(tt.from+_e,tt.from+et)!=g.sliceDoc(b,$)?{range:tt}:{changes:{from:tt.from+_e,to:$==j.from?tt.to:tt.from+et,insert:d},range:EditorSelection.cursor(tt.from+_e+d.length)})),{scrollIntoView:!0,userEvent:"input.complete"})}const SourceCache=new WeakMap;function asSource(g){if(!Array.isArray(g))return g;let d=SourceCache.get(g);return d||SourceCache.set(g,d=completeFromList(g)),d}const startCompletionEffect=StateEffect.define(),closeCompletionEffect=StateEffect.define();class FuzzyMatcher{constructor(d){this.pattern=d,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let b=0;b=48&&vt<=57||vt>=97&&vt<=122?2:vt>=65&&vt<=90?1:0:(St=fromCodePoint(vt))!=St.toLowerCase()?1:St!=St.toUpperCase()?2:0;(!pt||xt==1&&dt||yt==0&&xt!=0)&&(b[st]==vt||$[st]==vt&&(ot=!0)?et[st++]=pt:et.length&&(ht=!1)),yt=xt,pt+=codePointSize(vt)}return st==nt&&et[0]==0&&ht?this.result(-100+(ot?-200:0),et,d):at==nt&&ut==0?this.ret(-200-d.length+(ct==d.length?0:-100),[0,ct]):tt>-1?this.ret(-700-d.length,[tt,tt+this.pattern.length]):at==nt?this.ret(-200+-700-d.length,[ut,ct]):st==nt?this.result(-100+(ot?-200:0)+-700+(ht?0:-1100),et,d):b.length==2?!1:this.result((j[0]?-700:0)+-200+-1100,j,d)}result(d,b,$){let j=[],_e=0;for(let et of b){let tt=et+(this.astral?codePointSize(codePointAt($,et)):1);_e&&j[_e-1]==et?j[_e-1]=tt:(j[_e++]=et,j[_e++]=tt)}return this.ret(d-$.length,j)}}const completionConfig=Facet.define({combine(g){return combineConfig(g,{activateOnTyping:!0,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:defaultPositionInfo,compareCompletions:(d,b)=>d.label.localeCompare(b.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(d,b)=>d&&b,closeOnBlur:(d,b)=>d&&b,icons:(d,b)=>d&&b,tooltipClass:(d,b)=>$=>joinClass(d($),b($)),optionClass:(d,b)=>$=>joinClass(d($),b($)),addToOptions:(d,b)=>d.concat(b)})}});function joinClass(g,d){return g?d?g+" "+d:g:d}function defaultPositionInfo(g,d,b,$,j,_e){let et=g.textDirection==Direction.RTL,tt=et,nt=!1,rt="top",it,st,ot=d.left-j.left,at=j.right-d.right,ut=$.right-$.left,ct=$.bottom-$.top;if(tt&&ot=ct||pt>d.top?it=b.bottom-d.top:(rt="bottom",it=d.bottom-b.top)}let dt=(d.bottom-d.top)/_e.offsetHeight,ht=(d.right-d.left)/_e.offsetWidth;return{style:`${rt}: ${it/dt}px; max-width: ${st/ht}px`,class:"cm-completionInfo-"+(nt?et?"left-narrow":"right-narrow":tt?"left":"right")}}function optionContent(g){let d=g.addToOptions.slice();return g.icons&&d.push({render(b){let $=document.createElement("div");return $.classList.add("cm-completionIcon"),b.type&&$.classList.add(...b.type.split(/\s+/g).map(j=>"cm-completionIcon-"+j)),$.setAttribute("aria-hidden","true"),$},position:20}),d.push({render(b,$,j,_e){let et=document.createElement("span");et.className="cm-completionLabel";let tt=b.displayLabel||b.label,nt=0;for(let rt=0;rt<_e.length;){let it=_e[rt++],st=_e[rt++];it>nt&&et.appendChild(document.createTextNode(tt.slice(nt,it)));let ot=et.appendChild(document.createElement("span"));ot.appendChild(document.createTextNode(tt.slice(it,st))),ot.className="cm-completionMatchedText",nt=st}return ntb.position-$.position).map(b=>b.render)}function rangeAroundSelected(g,d,b){if(g<=b)return{from:0,to:g};if(d<0&&(d=0),d<=g>>1){let j=Math.floor(d/b);return{from:j*b,to:(j+1)*b}}let $=Math.floor((g-d)/b);return{from:g-($+1)*b,to:g-$*b}}class CompletionTooltip{constructor(d,b,$){this.view=d,this.stateField=b,this.applyCompletion=$,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:nt=>this.placeInfo(nt),key:this},this.space=null,this.currentClass="";let j=d.state.field(b),{options:_e,selected:et}=j.open,tt=d.state.facet(completionConfig);this.optionContent=optionContent(tt),this.optionClass=tt.optionClass,this.tooltipClass=tt.tooltipClass,this.range=rangeAroundSelected(_e.length,et,tt.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(d.state),this.dom.addEventListener("mousedown",nt=>{let{options:rt}=d.state.field(b).open;for(let it=nt.target,st;it&&it!=this.dom;it=it.parentNode)if(it.nodeName=="LI"&&(st=/-(\d+)$/.exec(it.id))&&+st[1]{let rt=d.state.field(this.stateField,!1);rt&&rt.tooltip&&d.state.facet(completionConfig).closeOnBlur&&nt.relatedTarget!=d.contentDOM&&d.dispatch({effects:closeCompletionEffect.of(null)})}),this.showOptions(_e,j.id)}mount(){this.updateSel()}showOptions(d,b){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(d,b,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(d){var b;let $=d.state.field(this.stateField),j=d.startState.field(this.stateField);if(this.updateTooltipClass(d.state),$!=j){let{options:_e,selected:et,disabled:tt}=$.open;(!j.open||j.open.options!=_e)&&(this.range=rangeAroundSelected(_e.length,et,d.state.facet(completionConfig).maxRenderedOptions),this.showOptions(_e,$.id)),this.updateSel(),tt!=((b=j.open)===null||b===void 0?void 0:b.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!tt)}}updateTooltipClass(d){let b=this.tooltipClass(d);if(b!=this.currentClass){for(let $ of this.currentClass.split(" "))$&&this.dom.classList.remove($);for(let $ of b.split(" "))$&&this.dom.classList.add($);this.currentClass=b}}positioned(d){this.space=d,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let d=this.view.state.field(this.stateField),b=d.open;if((b.selected>-1&&b.selected=this.range.to)&&(this.range=rangeAroundSelected(b.options.length,b.selected,this.view.state.facet(completionConfig).maxRenderedOptions),this.showOptions(b.options,d.id)),this.updateSelectedOption(b.selected)){this.destroyInfo();let{completion:$}=b.options[b.selected],{info:j}=$;if(!j)return;let _e=typeof j=="string"?document.createTextNode(j):j($);if(!_e)return;"then"in _e?_e.then(et=>{et&&this.view.state.field(this.stateField,!1)==d&&this.addInfoPane(et,$)}).catch(et=>logException(this.view.state,et,"completion info")):this.addInfoPane(_e,$)}}addInfoPane(d,b){this.destroyInfo();let $=this.info=document.createElement("div");if($.className="cm-tooltip cm-completionInfo",d.nodeType!=null)$.appendChild(d),this.infoDestroy=null;else{let{dom:j,destroy:_e}=d;$.appendChild(j),this.infoDestroy=_e||null}this.dom.appendChild($),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(d){let b=null;for(let $=this.list.firstChild,j=this.range.from;$;$=$.nextSibling,j++)$.nodeName!="LI"||!$.id?j--:j==d?$.hasAttribute("aria-selected")||($.setAttribute("aria-selected","true"),b=$):$.hasAttribute("aria-selected")&&$.removeAttribute("aria-selected");return b&&scrollIntoView(this.list,b),b}measureInfo(){let d=this.dom.querySelector("[aria-selected]");if(!d||!this.info)return null;let b=this.dom.getBoundingClientRect(),$=this.info.getBoundingClientRect(),j=d.getBoundingClientRect(),_e=this.space;if(!_e){let et=this.dom.ownerDocument.defaultView||window;_e={left:0,top:0,right:et.innerWidth,bottom:et.innerHeight}}return j.top>Math.min(_e.bottom,b.bottom)-10||j.bottom$.from||$.from==0))if(_e=ot,typeof rt!="string"&&rt.header)j.appendChild(rt.header(rt));else{let at=j.appendChild(document.createElement("completion-section"));at.textContent=ot}}const it=j.appendChild(document.createElement("li"));it.id=b+"-"+et,it.setAttribute("role","option");let st=this.optionClass(tt);st&&(it.className=st);for(let ot of this.optionContent){let at=ot(tt,this.view.state,this.view,nt);at&&it.appendChild(at)}}return $.from&&j.classList.add("cm-completionListIncompleteTop"),$.tonew CompletionTooltip(b,g,d)}function scrollIntoView(g,d){let b=g.getBoundingClientRect(),$=d.getBoundingClientRect(),j=b.height/g.offsetHeight;$.topb.bottom&&(g.scrollTop+=($.bottom-b.bottom)/j)}function score(g){return(g.boost||0)*100+(g.apply?10:0)+(g.info?5:0)+(g.type?1:0)}function sortOptions(g,d){let b=[],$=null,j=nt=>{b.push(nt);let{section:rt}=nt.completion;if(rt){$||($=[]);let it=typeof rt=="string"?rt:rt.name;$.some(st=>st.name==it)||$.push(typeof rt=="string"?{name:it}:rt)}};for(let nt of g)if(nt.hasResult()){let rt=nt.result.getMatch;if(nt.result.filter===!1)for(let it of nt.result.options)j(new Option(it,nt.source,rt?rt(it):[],1e9-b.length));else{let it=new FuzzyMatcher(d.sliceDoc(nt.from,nt.to));for(let st of nt.result.options)if(it.match(st.label)){let ot=st.displayLabel?rt?rt(st,it.matched):[]:it.matched;j(new Option(st,nt.source,ot,it.score+(st.boost||0)))}}}if($){let nt=Object.create(null),rt=0,it=(st,ot)=>{var at,ut;return((at=st.rank)!==null&&at!==void 0?at:1e9)-((ut=ot.rank)!==null&&ut!==void 0?ut:1e9)||(st.nameit.score-rt.score||tt(rt.completion,it.completion))){let rt=nt.completion;!et||et.label!=rt.label||et.detail!=rt.detail||et.type!=null&&rt.type!=null&&et.type!=rt.type||et.apply!=rt.apply||et.boost!=rt.boost?_e.push(nt):score(nt.completion)>score(et)&&(_e[_e.length-1]=nt),et=nt.completion}return _e}class CompletionDialog{constructor(d,b,$,j,_e,et){this.options=d,this.attrs=b,this.tooltip=$,this.timestamp=j,this.selected=_e,this.disabled=et}setSelected(d,b){return d==this.selected||d>=this.options.length?this:new CompletionDialog(this.options,makeAttrs(b,d),this.tooltip,this.timestamp,d,this.disabled)}static build(d,b,$,j,_e){let et=sortOptions(d,b);if(!et.length)return j&&d.some(nt=>nt.state==1)?new CompletionDialog(j.options,j.attrs,j.tooltip,j.timestamp,j.selected,!0):null;let tt=b.facet(completionConfig).selectOnOpen?0:-1;if(j&&j.selected!=tt&&j.selected!=-1){let nt=j.options[j.selected].completion;for(let rt=0;rtrt.hasResult()?Math.min(nt,rt.from):nt,1e8),create:createTooltip,above:_e.aboveCursor},j?j.timestamp:Date.now(),tt,!1)}map(d){return new CompletionDialog(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:d.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}}class CompletionState{constructor(d,b,$){this.active=d,this.id=b,this.open=$}static start(){return new CompletionState(none$1,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(d){let{state:b}=d,$=b.facet(completionConfig),_e=($.override||b.languageDataAt("autocomplete",cur(b)).map(asSource)).map(tt=>(this.active.find(rt=>rt.source==tt)||new ActiveSource(tt,this.active.some(rt=>rt.state!=0)?1:0)).update(d,$));_e.length==this.active.length&&_e.every((tt,nt)=>tt==this.active[nt])&&(_e=this.active);let et=this.open;et&&d.docChanged&&(et=et.map(d.changes)),d.selection||_e.some(tt=>tt.hasResult()&&d.changes.touchesRange(tt.from,tt.to))||!sameResults(_e,this.active)?et=CompletionDialog.build(_e,b,this.id,et,$):et&&et.disabled&&!_e.some(tt=>tt.state==1)&&(et=null),!et&&_e.every(tt=>tt.state!=1)&&_e.some(tt=>tt.hasResult())&&(_e=_e.map(tt=>tt.hasResult()?new ActiveSource(tt.source,0):tt));for(let tt of d.effects)tt.is(setSelectedEffect)&&(et=et&&et.setSelected(tt.value,this.id));return _e==this.active&&et==this.open?this:new CompletionState(_e,this.id,et)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:baseAttrs}}function sameResults(g,d){if(g==d)return!0;for(let b=0,$=0;;){for(;b-1&&(b["aria-activedescendant"]=g+"-"+d),b}const none$1=[];function getUserEvent(g){return g.isUserEvent("input.type")?"input":g.isUserEvent("delete.backward")?"delete":null}class ActiveSource{constructor(d,b,$=-1){this.source=d,this.state=b,this.explicitPos=$}hasResult(){return!1}update(d,b){let $=getUserEvent(d),j=this;$?j=j.handleUserEvent(d,$,b):d.docChanged?j=j.handleChange(d):d.selection&&j.state!=0&&(j=new ActiveSource(j.source,0));for(let _e of d.effects)if(_e.is(startCompletionEffect))j=new ActiveSource(j.source,1,_e.value?cur(d.state):-1);else if(_e.is(closeCompletionEffect))j=new ActiveSource(j.source,0);else if(_e.is(setActiveEffect))for(let et of _e.value)et.source==j.source&&(j=et);return j}handleUserEvent(d,b,$){return b=="delete"||!$.activateOnTyping?this.map(d.changes):new ActiveSource(this.source,1)}handleChange(d){return d.changes.touchesRange(cur(d.startState))?new ActiveSource(this.source,0):this.map(d.changes)}map(d){return d.empty||this.explicitPos<0?this:new ActiveSource(this.source,this.state,d.mapPos(this.explicitPos))}}class ActiveResult extends ActiveSource{constructor(d,b,$,j,_e){super(d,2,b),this.result=$,this.from=j,this.to=_e}hasResult(){return!0}handleUserEvent(d,b,$){var j;let _e=d.changes.mapPos(this.from),et=d.changes.mapPos(this.to,1),tt=cur(d.state);if((this.explicitPos<0?tt<=_e:ttet||b=="delete"&&cur(d.startState)==this.from)return new ActiveSource(this.source,b=="input"&&$.activateOnTyping?1:0);let nt=this.explicitPos<0?-1:d.changes.mapPos(this.explicitPos),rt;return checkValid(this.result.validFor,d.state,_e,et)?new ActiveResult(this.source,nt,this.result,_e,et):this.result.update&&(rt=this.result.update(this.result,_e,et,new CompletionContext(d.state,tt,nt>=0)))?new ActiveResult(this.source,nt,rt,rt.from,(j=rt.to)!==null&&j!==void 0?j:cur(d.state)):new ActiveSource(this.source,1,nt)}handleChange(d){return d.changes.touchesRange(this.from,this.to)?new ActiveSource(this.source,0):this.map(d.changes)}map(d){return d.empty?this:new ActiveResult(this.source,this.explicitPos<0?-1:d.mapPos(this.explicitPos),this.result,d.mapPos(this.from),d.mapPos(this.to,1))}}function checkValid(g,d,b,$){if(!g)return!1;let j=d.sliceDoc(b,$);return typeof g=="function"?g(j,b,$,d):ensureAnchor(g,!0).test(j)}const setActiveEffect=StateEffect.define({map(g,d){return g.map(b=>b.map(d))}}),setSelectedEffect=StateEffect.define(),completionState=StateField.define({create(){return CompletionState.start()},update(g,d){return g.update(d)},provide:g=>[showTooltip.from(g,d=>d.tooltip),EditorView.contentAttributes.from(g,d=>d.attrs)]});function applyCompletion(g,d){const b=d.completion.apply||d.completion.label;let $=g.state.field(completionState).active.find(j=>j.source==d.source);return $ instanceof ActiveResult?(typeof b=="string"?g.dispatch(Object.assign(Object.assign({},insertCompletionText(g.state,b,$.from,$.to)),{annotations:pickedCompletion.of(d.completion)})):b(g,d.completion,$.from,$.to),!0):!1}const createTooltip=completionTooltip(completionState,applyCompletion);function moveCompletionSelection(g,d="option"){return b=>{let $=b.state.field(completionState,!1);if(!$||!$.open||$.open.disabled||Date.now()-$.open.timestamp-1?$.open.selected+j*(g?1:-1):g?0:et-1;return tt<0?tt=d=="page"?0:et-1:tt>=et&&(tt=d=="page"?et-1:0),b.dispatch({effects:setSelectedEffect.of(tt)}),!0}}const acceptCompletion=g=>{let d=g.state.field(completionState,!1);return g.state.readOnly||!d||!d.open||d.open.selected<0||d.open.disabled||Date.now()-d.open.timestampg.state.field(completionState,!1)?(g.dispatch({effects:startCompletionEffect.of(!0)}),!0):!1,closeCompletion=g=>{let d=g.state.field(completionState,!1);return!d||!d.active.some(b=>b.state!=0)?!1:(g.dispatch({effects:closeCompletionEffect.of(null)}),!0)};class RunningQuery{constructor(d,b){this.active=d,this.context=b,this.time=Date.now(),this.updates=[],this.done=void 0}}const MaxUpdateCount=50,MinAbortTime=1e3,completionPlugin=ViewPlugin.fromClass(class{constructor(g){this.view=g,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.composing=0;for(let d of g.state.field(completionState).active)d.state==1&&this.startQuery(d)}update(g){let d=g.state.field(completionState);if(!g.selectionSet&&!g.docChanged&&g.startState.field(completionState)==d)return;let b=g.transactions.some($=>($.selection||$.docChanged)&&!getUserEvent($));for(let $=0;$MaxUpdateCount&&Date.now()-j.time>MinAbortTime){for(let _e of j.context.abortListeners)try{_e()}catch(et){logException(this.view.state,et)}j.context.abortListeners=null,this.running.splice($--,1)}else j.updates.push(...g.transactions)}if(this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),this.debounceUpdate=d.active.some($=>$.state==1&&!this.running.some(j=>j.active.source==$.source))?setTimeout(()=>this.startUpdate(),50):-1,this.composing!=0)for(let $ of g.transactions)getUserEvent($)=="input"?this.composing=2:this.composing==2&&$.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1;let{state:g}=this.view,d=g.field(completionState);for(let b of d.active)b.state==1&&!this.running.some($=>$.active.source==b.source)&&this.startQuery(b)}startQuery(g){let{state:d}=this.view,b=cur(d),$=new CompletionContext(d,b,g.explicitPos==b),j=new RunningQuery(g,$);this.running.push(j),Promise.resolve(g.source($)).then(_e=>{j.context.aborted||(j.done=_e||null,this.scheduleAccept())},_e=>{this.view.dispatch({effects:closeCompletionEffect.of(null)}),logException(this.view.state,_e)})}scheduleAccept(){this.running.every(g=>g.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(completionConfig).updateSyncTime))}accept(){var g;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let d=[],b=this.view.state.facet(completionConfig);for(let $=0;$et.source==j.active.source);if(_e&&_e.state==1)if(j.done==null){let et=new ActiveSource(j.active.source,0);for(let tt of j.updates)et=et.update(tt,b);et.state!=1&&d.push(et)}else this.startQuery(_e)}d.length&&this.view.dispatch({effects:setActiveEffect.of(d)})}},{eventHandlers:{blur(g){let d=this.view.state.field(completionState,!1);if(d&&d.tooltip&&this.view.state.facet(completionConfig).closeOnBlur){let b=d.open&&getTooltip(this.view,d.open.tooltip);(!b||!b.dom.contains(g.relatedTarget))&&this.view.dispatch({effects:closeCompletionEffect.of(null)})}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:startCompletionEffect.of(!1)}),20),this.composing=0}}}),baseTheme$1=EditorView.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}}),defaults$2={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},closeBracketEffect=StateEffect.define({map(g,d){let b=d.mapPos(g,-1,MapMode.TrackAfter);return b??void 0}}),closedBracket=new class extends RangeValue{};closedBracket.startSide=1;closedBracket.endSide=-1;const bracketState=StateField.define({create(){return RangeSet.empty},update(g,d){if(g=g.map(d.changes),d.selection){let b=d.state.doc.lineAt(d.selection.main.head);g=g.update({filter:$=>$>=b.from&&$<=b.to})}for(let b of d.effects)b.is(closeBracketEffect)&&(g=g.update({add:[closedBracket.range(b.value,b.value+1)]}));return g}});function closeBrackets(){return[inputHandler,bracketState]}const definedClosing="()[]{}<>";function closing(g){for(let d=0;d{if((android?g.composing:g.compositionStarted)||g.state.readOnly)return!1;let j=g.state.selection.main;if($.length>2||$.length==2&&codePointSize(codePointAt($,0))==1||d!=j.from||b!=j.to)return!1;let _e=insertBracket(g.state,$);return _e?(g.dispatch(_e),!0):!1}),deleteBracketPair=({state:g,dispatch:d})=>{if(g.readOnly)return!1;let $=config(g,g.selection.main.head).brackets||defaults$2.brackets,j=null,_e=g.changeByRange(et=>{if(et.empty){let tt=prevChar(g.doc,et.head);for(let nt of $)if(nt==tt&&nextChar(g.doc,et.head)==closing(codePointAt(nt,0)))return{changes:{from:et.head-nt.length,to:et.head+nt.length},range:EditorSelection.cursor(et.head-nt.length)}}return{range:j=et}});return j||d(g.update(_e,{scrollIntoView:!0,userEvent:"delete.backward"})),!j},closeBracketsKeymap=[{key:"Backspace",run:deleteBracketPair}];function insertBracket(g,d){let b=config(g,g.selection.main.head),$=b.brackets||defaults$2.brackets;for(let j of $){let _e=closing(codePointAt(j,0));if(d==j)return _e==j?handleSame(g,j,$.indexOf(j+j+j)>-1,b):handleOpen(g,j,_e,b.before||defaults$2.before);if(d==_e&&closedBracketAt(g,g.selection.main.from))return handleClose(g,j,_e)}return null}function closedBracketAt(g,d){let b=!1;return g.field(bracketState).between(0,g.doc.length,$=>{$==d&&(b=!0)}),b}function nextChar(g,d){let b=g.sliceString(d,d+2);return b.slice(0,codePointSize(codePointAt(b,0)))}function prevChar(g,d){let b=g.sliceString(d-2,d);return codePointSize(codePointAt(b,0))==b.length?b:b.slice(1)}function handleOpen(g,d,b,$){let j=null,_e=g.changeByRange(et=>{if(!et.empty)return{changes:[{insert:d,from:et.from},{insert:b,from:et.to}],effects:closeBracketEffect.of(et.to+d.length),range:EditorSelection.range(et.anchor+d.length,et.head+d.length)};let tt=nextChar(g.doc,et.head);return!tt||/\s/.test(tt)||$.indexOf(tt)>-1?{changes:{insert:d+b,from:et.head},effects:closeBracketEffect.of(et.head+d.length),range:EditorSelection.cursor(et.head+d.length)}:{range:j=et}});return j?null:g.update(_e,{scrollIntoView:!0,userEvent:"input.type"})}function handleClose(g,d,b){let $=null,j=g.changeByRange(_e=>_e.empty&&nextChar(g.doc,_e.head)==b?{changes:{from:_e.head,to:_e.head+b.length,insert:b},range:EditorSelection.cursor(_e.head+b.length)}:$={range:_e});return $?null:g.update(j,{scrollIntoView:!0,userEvent:"input.type"})}function handleSame(g,d,b,$){let j=$.stringPrefixes||defaults$2.stringPrefixes,_e=null,et=g.changeByRange(tt=>{if(!tt.empty)return{changes:[{insert:d,from:tt.from},{insert:d,from:tt.to}],effects:closeBracketEffect.of(tt.to+d.length),range:EditorSelection.range(tt.anchor+d.length,tt.head+d.length)};let nt=tt.head,rt=nextChar(g.doc,nt),it;if(rt==d){if(nodeStart(g,nt))return{changes:{insert:d+d,from:nt},effects:closeBracketEffect.of(nt+d.length),range:EditorSelection.cursor(nt+d.length)};if(closedBracketAt(g,nt)){let ot=b&&g.sliceDoc(nt,nt+d.length*3)==d+d+d?d+d+d:d;return{changes:{from:nt,to:nt+ot.length,insert:ot},range:EditorSelection.cursor(nt+ot.length)}}}else{if(b&&g.sliceDoc(nt-2*d.length,nt)==d+d&&(it=canStartStringAt(g,nt-2*d.length,j))>-1&&nodeStart(g,it))return{changes:{insert:d+d+d+d,from:nt},effects:closeBracketEffect.of(nt+d.length),range:EditorSelection.cursor(nt+d.length)};if(g.charCategorizer(nt)(rt)!=CharCategory.Word&&canStartStringAt(g,nt,j)>-1&&!probablyInString(g,nt,d,j))return{changes:{insert:d+d,from:nt},effects:closeBracketEffect.of(nt+d.length),range:EditorSelection.cursor(nt+d.length)}}return{range:_e=tt}});return _e?null:g.update(et,{scrollIntoView:!0,userEvent:"input.type"})}function nodeStart(g,d){let b=syntaxTree(g).resolveInner(d+1);return b.parent&&b.from==d}function probablyInString(g,d,b,$){let j=syntaxTree(g).resolveInner(d,-1),_e=$.reduce((et,tt)=>Math.max(et,tt.length),0);for(let et=0;et<5;et++){let tt=g.sliceDoc(j.from,Math.min(j.to,j.from+b.length+_e)),nt=tt.indexOf(b);if(!nt||nt>-1&&$.indexOf(tt.slice(0,nt))>-1){let it=j.firstChild;for(;it&&it.from==j.from&&it.to-it.from>b.length+nt;){if(g.sliceDoc(it.to-b.length,it.to)==b)return!1;it=it.firstChild}return!0}let rt=j.to==d&&j.parent;if(!rt)break;j=rt}return!1}function canStartStringAt(g,d,b){let $=g.charCategorizer(d);if($(g.sliceDoc(d-1,d))!=CharCategory.Word)return d;for(let j of b){let _e=d-j.length;if(g.sliceDoc(_e,d)==j&&$(g.sliceDoc(_e-1,_e))!=CharCategory.Word)return _e}return-1}function autocompletion(g={}){return[completionState,completionConfig.of(g),completionPlugin,completionKeymapExt,baseTheme$1]}const completionKeymap=[{key:"Ctrl-Space",run:startCompletion},{key:"Escape",run:closeCompletion},{key:"ArrowDown",run:moveCompletionSelection(!0)},{key:"ArrowUp",run:moveCompletionSelection(!1)},{key:"PageDown",run:moveCompletionSelection(!0,"page")},{key:"PageUp",run:moveCompletionSelection(!1,"page")},{key:"Enter",run:acceptCompletion}],completionKeymapExt=Prec.highest(keymap.computeN([completionConfig],g=>g.facet(completionConfig).defaultKeymap?[completionKeymap]:[]));class SelectedDiagnostic{constructor(d,b,$){this.from=d,this.to=b,this.diagnostic=$}}class LintState{constructor(d,b,$){this.diagnostics=d,this.panel=b,this.selected=$}static init(d,b,$){let j=d,_e=$.facet(lintConfig).markerFilter;_e&&(j=_e(j));let et=Decoration.set(j.map(tt=>tt.from==tt.to||tt.from==tt.to-1&&$.doc.lineAt(tt.from).to==tt.from?Decoration.widget({widget:new DiagnosticWidget(tt),diagnostic:tt}).range(tt.from):Decoration.mark({attributes:{class:"cm-lintRange cm-lintRange-"+tt.severity+(tt.markClass?" "+tt.markClass:"")},diagnostic:tt}).range(tt.from,tt.to)),!0);return new LintState(et,b,findDiagnostic(et))}}function findDiagnostic(g,d=null,b=0){let $=null;return g.between(b,1e9,(j,_e,{spec:et})=>{if(!(d&&et.diagnostic!=d))return $=new SelectedDiagnostic(j,_e,et.diagnostic),!1}),$}function hideTooltip(g,d){let b=g.startState.doc.lineAt(d.pos);return!!(g.effects.some($=>$.is(setDiagnosticsEffect))||g.changes.touchesRange(b.from,b.to))}function maybeEnableLint(g,d){return g.field(lintState,!1)?d:d.concat(StateEffect.appendConfig.of(lintExtensions))}const setDiagnosticsEffect=StateEffect.define(),togglePanel=StateEffect.define(),movePanelSelection=StateEffect.define(),lintState=StateField.define({create(){return new LintState(Decoration.none,null,null)},update(g,d){if(d.docChanged){let b=g.diagnostics.map(d.changes),$=null;if(g.selected){let j=d.changes.mapPos(g.selected.from,1);$=findDiagnostic(b,g.selected.diagnostic,j)||findDiagnostic(b,null,j)}g=new LintState(b,g.panel,$)}for(let b of d.effects)b.is(setDiagnosticsEffect)?g=LintState.init(b.value,g.panel,d.state):b.is(togglePanel)?g=new LintState(g.diagnostics,b.value?LintPanel.open:null,g.selected):b.is(movePanelSelection)&&(g=new LintState(g.diagnostics,g.panel,b.value));return g},provide:g=>[showPanel.from(g,d=>d.panel),EditorView.decorations.from(g,d=>d.diagnostics)]}),activeMark=Decoration.mark({class:"cm-lintRange cm-lintRange-active"});function lintTooltip(g,d,b){let{diagnostics:$}=g.state.field(lintState),j=[],_e=2e8,et=0;$.between(d-(b<0?1:0),d+(b>0?1:0),(nt,rt,{spec:it})=>{d>=nt&&d<=rt&&(nt==rt||(d>nt||b>0)&&(drenderDiagnostic(g,b,!1)))}const openLintPanel=g=>{let d=g.state.field(lintState,!1);(!d||!d.panel)&&g.dispatch({effects:maybeEnableLint(g.state,[togglePanel.of(!0)])});let b=getPanel(g,LintPanel.open);return b&&b.dom.querySelector(".cm-panel-lint ul").focus(),!0},closeLintPanel=g=>{let d=g.state.field(lintState,!1);return!d||!d.panel?!1:(g.dispatch({effects:togglePanel.of(!1)}),!0)},nextDiagnostic=g=>{let d=g.state.field(lintState,!1);if(!d)return!1;let b=g.state.selection.main,$=d.diagnostics.iter(b.to+1);return!$.value&&($=d.diagnostics.iter(0),!$.value||$.from==b.from&&$.to==b.to)?!1:(g.dispatch({selection:{anchor:$.from,head:$.to},scrollIntoView:!0}),!0)},lintKeymap=[{key:"Mod-Shift-m",run:openLintPanel,preventDefault:!0},{key:"F8",run:nextDiagnostic}],lintConfig=Facet.define({combine(g){return Object.assign({sources:g.map(d=>d.source)},combineConfig(g.map(d=>d.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null},{needsRefresh:(d,b)=>d?b?$=>d($)||b($):d:b}))}});function assignKeys(g){let d=[];if(g)e:for(let{name:b}of g){for(let $=0;$_e.toLowerCase()==j.toLowerCase())){d.push(j);continue e}}d.push("")}return d}function renderDiagnostic(g,d,b){var $;let j=b?assignKeys(d.actions):[];return crelt("li",{class:"cm-diagnostic cm-diagnostic-"+d.severity},crelt("span",{class:"cm-diagnosticText"},d.renderMessage?d.renderMessage():d.message),($=d.actions)===null||$===void 0?void 0:$.map((_e,et)=>{let tt=!1,nt=ot=>{if(ot.preventDefault(),tt)return;tt=!0;let at=findDiagnostic(g.state.field(lintState).diagnostics,d);at&&_e.apply(g,at.from,at.to)},{name:rt}=_e,it=j[et]?rt.indexOf(j[et]):-1,st=it<0?rt:[rt.slice(0,it),crelt("u",rt.slice(it,it+1)),rt.slice(it+1)];return crelt("button",{type:"button",class:"cm-diagnosticAction",onclick:nt,onmousedown:nt,"aria-label":` Action: ${rt}${it<0?"":` (access key "${j[et]})"`}.`},st)}),d.source&&crelt("div",{class:"cm-diagnosticSource"},d.source))}class DiagnosticWidget extends WidgetType{constructor(d){super(),this.diagnostic=d}eq(d){return d.diagnostic==this.diagnostic}toDOM(){return crelt("span",{class:"cm-lintPoint cm-lintPoint-"+this.diagnostic.severity})}}class PanelItem{constructor(d,b){this.diagnostic=b,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=renderDiagnostic(d,b,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class LintPanel{constructor(d){this.view=d,this.items=[];let b=j=>{if(j.keyCode==27)closeLintPanel(this.view),this.view.focus();else if(j.keyCode==38||j.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(j.keyCode==40||j.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(j.keyCode==36)this.moveSelection(0);else if(j.keyCode==35)this.moveSelection(this.items.length-1);else if(j.keyCode==13)this.view.focus();else if(j.keyCode>=65&&j.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:_e}=this.items[this.selectedIndex],et=assignKeys(_e.actions);for(let tt=0;tt{for(let _e=0;_ecloseLintPanel(this.view)},"×")),this.update()}get selectedIndex(){let d=this.view.state.field(lintState).selected;if(!d)return-1;for(let b=0;b{let rt=-1,it;for(let st=$;st$&&(this.items.splice($,rt-$),j=!0)),b&&it.diagnostic==b.diagnostic?it.dom.hasAttribute("aria-selected")||(it.dom.setAttribute("aria-selected","true"),_e=it):it.dom.hasAttribute("aria-selected")&&it.dom.removeAttribute("aria-selected"),$++});$({sel:_e.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:et,panel:tt})=>{let nt=tt.height/this.list.offsetHeight;et.toptt.bottom&&(this.list.scrollTop+=(et.bottom-tt.bottom)/nt)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),j&&this.sync()}sync(){let d=this.list.firstChild;function b(){let $=d;d=$.nextSibling,$.remove()}for(let $ of this.items)if($.dom.parentNode==this.list){for(;d!=$.dom;)b();d=$.dom.nextSibling}else this.list.insertBefore($.dom,d);for(;d;)b()}moveSelection(d){if(this.selectedIndex<0)return;let b=this.view.state.field(lintState),$=findDiagnostic(b.diagnostics,this.items[d].diagnostic);$&&this.view.dispatch({selection:{anchor:$.from,head:$.to},scrollIntoView:!0,effects:movePanelSelection.of($)})}static open(d){return new LintPanel(d)}}function svg$1(g,d='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,${encodeURIComponent(g)}')`}function underline(g){return svg$1(``,'width="6" height="3"')}const baseTheme=EditorView.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:underline("#d11")},".cm-lintRange-warning":{backgroundImage:underline("orange")},".cm-lintRange-info":{backgroundImage:underline("#999")},".cm-lintRange-hint":{backgroundImage:underline("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}}),lintExtensions=[lintState,EditorView.decorations.compute([lintState],g=>{let{selected:d,panel:b}=g.field(lintState);return!d||!b||d.from==d.to?Decoration.none:Decoration.set([activeMark.range(d.from,d.to)])}),hoverTooltip(lintTooltip,{hideOn:hideTooltip}),baseTheme];var basicSetup=function(d){d===void 0&&(d={});var{crosshairCursor:b=!1}=d,$=[];d.closeBracketsKeymap!==!1&&($=$.concat(closeBracketsKeymap)),d.defaultKeymap!==!1&&($=$.concat(defaultKeymap)),d.searchKeymap!==!1&&($=$.concat(searchKeymap)),d.historyKeymap!==!1&&($=$.concat(historyKeymap)),d.foldKeymap!==!1&&($=$.concat(foldKeymap)),d.completionKeymap!==!1&&($=$.concat(completionKeymap)),d.lintKeymap!==!1&&($=$.concat(lintKeymap));var j=[];return d.lineNumbers!==!1&&j.push(lineNumbers()),d.highlightActiveLineGutter!==!1&&j.push(highlightActiveLineGutter()),d.highlightSpecialChars!==!1&&j.push(highlightSpecialChars()),d.history!==!1&&j.push(history()),d.foldGutter!==!1&&j.push(foldGutter()),d.drawSelection!==!1&&j.push(drawSelection()),d.dropCursor!==!1&&j.push(dropCursor()),d.allowMultipleSelections!==!1&&j.push(EditorState.allowMultipleSelections.of(!0)),d.indentOnInput!==!1&&j.push(indentOnInput()),d.syntaxHighlighting!==!1&&j.push(syntaxHighlighting(defaultHighlightStyle,{fallback:!0})),d.bracketMatching!==!1&&j.push(bracketMatching()),d.closeBrackets!==!1&&j.push(closeBrackets()),d.autocompletion!==!1&&j.push(autocompletion()),d.rectangularSelection!==!1&&j.push(rectangularSelection()),b!==!1&&j.push(crosshairCursor()),d.highlightActiveLine!==!1&&j.push(highlightActiveLine()),d.highlightSelectionMatches!==!1&&j.push(highlightSelectionMatches()),d.tabSize&&typeof d.tabSize=="number"&&j.push(indentUnit.of(" ".repeat(d.tabSize))),j.concat([keymap.of($.flat())]).filter(Boolean)};const chalky="#e5c07b",coral="#e06c75",cyan="#56b6c2",invalid="#ffffff",ivory="#abb2bf",stone="#7d8799",malibu="#61afef",sage="#98c379",whiskey="#d19a66",violet="#c678dd",darkBackground="#21252b",highlightBackground="#2c313a",background="#282c34",tooltipBackground="#353a42",selection$1="#3E4451",cursor="#528bff",oneDarkTheme=EditorView.theme({"&":{color:ivory,backgroundColor:background},".cm-content":{caretColor:cursor},".cm-cursor, .cm-dropCursor":{borderLeftColor:cursor},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:selection$1},".cm-panels":{backgroundColor:darkBackground,color:ivory},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#6699ff0b"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:background,color:stone,border:"none"},".cm-activeLineGutter":{backgroundColor:highlightBackground},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:tooltipBackground},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:tooltipBackground,borderBottomColor:tooltipBackground},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:highlightBackground,color:ivory}}},{dark:!0}),oneDarkHighlightStyle=HighlightStyle.define([{tag:tags.keyword,color:violet},{tag:[tags.name,tags.deleted,tags.character,tags.propertyName,tags.macroName],color:coral},{tag:[tags.function(tags.variableName),tags.labelName],color:malibu},{tag:[tags.color,tags.constant(tags.name),tags.standard(tags.name)],color:whiskey},{tag:[tags.definition(tags.name),tags.separator],color:ivory},{tag:[tags.typeName,tags.className,tags.number,tags.changed,tags.annotation,tags.modifier,tags.self,tags.namespace],color:chalky},{tag:[tags.operator,tags.operatorKeyword,tags.url,tags.escape,tags.regexp,tags.link,tags.special(tags.string)],color:cyan},{tag:[tags.meta,tags.comment],color:stone},{tag:tags.strong,fontWeight:"bold"},{tag:tags.emphasis,fontStyle:"italic"},{tag:tags.strikethrough,textDecoration:"line-through"},{tag:tags.link,color:stone,textDecoration:"underline"},{tag:tags.heading,fontWeight:"bold",color:coral},{tag:[tags.atom,tags.bool,tags.special(tags.variableName)],color:whiskey},{tag:[tags.processingInstruction,tags.string,tags.inserted],color:sage},{tag:tags.invalid,color:invalid}]),oneDark=[oneDarkTheme,syntaxHighlighting(oneDarkHighlightStyle)];var defaultLightThemeOption=EditorView.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),getDefaultExtensions=function(d){d===void 0&&(d={});var{indentWithTab:b=!0,editable:$=!0,readOnly:j=!1,theme:_e="light",placeholder:et="",basicSetup:tt=!0}=d,nt=[];switch(b&&nt.unshift(keymap.of([indentWithTab])),tt&&(typeof tt=="boolean"?nt.unshift(basicSetup()):nt.unshift(basicSetup(tt))),et&&nt.unshift(placeholder(et)),_e){case"light":nt.push(defaultLightThemeOption);break;case"dark":nt.push(oneDark);break;case"none":break;default:nt.push(_e);break}return $===!1&&nt.push(EditorView.editable.of(!1)),j&&nt.push(EditorState.readOnly.of(!0)),[...nt]},getStatistics=g=>({line:g.state.doc.lineAt(g.state.selection.main.from),lineCount:g.state.doc.lines,lineBreak:g.state.lineBreak,length:g.state.doc.length,readOnly:g.state.readOnly,tabSize:g.state.tabSize,selection:g.state.selection,selectionAsSingle:g.state.selection.asSingle().main,ranges:g.state.selection.ranges,selectionCode:g.state.sliceDoc(g.state.selection.main.from,g.state.selection.main.to),selections:g.state.selection.ranges.map(d=>g.state.sliceDoc(d.from,d.to)),selectedText:g.state.selection.ranges.some(d=>!d.empty)}),External=Annotation.define(),emptyExtensions=[];function useCodeMirror(g){var{value:d,selection:b,onChange:$,onStatistics:j,onCreateEditor:_e,onUpdate:et,extensions:tt=emptyExtensions,autoFocus:nt,theme:rt="light",height:it=null,minHeight:st=null,maxHeight:ot=null,width:at=null,minWidth:ut=null,maxWidth:ct=null,placeholder:dt="",editable:ht=!0,readOnly:pt=!1,indentWithTab:gt=!0,basicSetup:yt=!0,root:vt,initialState:St}=g,[xt,Dt]=reactExports.useState(),[Pt,Ct]=reactExports.useState(),[wt,Tt]=reactExports.useState(),Bt=EditorView.theme({"&":{height:it,minHeight:st,maxHeight:ot,width:at,minWidth:ut,maxWidth:ct},"& .cm-scroller":{height:"100% !important"}}),Ft=EditorView.updateListener.of(Ht=>{if(Ht.docChanged&&typeof $=="function"&&!Ht.transactions.some(It=>It.annotation(External))){var Ot=Ht.state.doc,Lt=Ot.toString();$(Lt,Ht)}j&&j(getStatistics(Ht))}),Vt=getDefaultExtensions({theme:rt,editable:ht,readOnly:pt,placeholder:dt,indentWithTab:gt,basicSetup:yt}),Wt=[Ft,Bt,...Vt];return et&&typeof et=="function"&&Wt.push(EditorView.updateListener.of(et)),Wt=Wt.concat(tt),reactExports.useEffect(()=>{if(xt&&!wt){var Ht={doc:d,selection:b,extensions:Wt},Ot=St?EditorState.fromJSON(St.json,Ht,St.fields):EditorState.create(Ht);if(Tt(Ot),!Pt){var Lt=new EditorView({state:Ot,parent:xt,root:vt});Ct(Lt),_e&&_e(Lt,Ot)}}return()=>{Pt&&(Tt(void 0),Ct(void 0))}},[xt,wt]),reactExports.useEffect(()=>Dt(g.container),[g.container]),reactExports.useEffect(()=>()=>{Pt&&(Pt.destroy(),Ct(void 0))},[Pt]),reactExports.useEffect(()=>{nt&&Pt&&Pt.focus()},[nt,Pt]),reactExports.useEffect(()=>{Pt&&Pt.dispatch({effects:StateEffect.reconfigure.of(Wt)})},[rt,tt,it,st,ot,at,ut,ct,dt,ht,pt,gt,yt,$,et]),reactExports.useEffect(()=>{if(d!==void 0){var Ht=Pt?Pt.state.doc.toString():"";Pt&&d!==Ht&&Pt.dispatch({changes:{from:0,to:Ht.length,insert:d||""},annotations:[External.of(!0)]})}},[d,Pt]),{state:wt,setState:Tt,view:Pt,setView:Ct,container:xt,setContainer:Dt}}var _excluded=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],ReactCodeMirror=reactExports.forwardRef((g,d)=>{var{className:b,value:$="",selection:j,extensions:_e=[],onChange:et,onStatistics:tt,onCreateEditor:nt,onUpdate:rt,autoFocus:it,theme:st="light",height:ot,minHeight:at,maxHeight:ut,width:ct,minWidth:dt,maxWidth:ht,basicSetup:pt,placeholder:gt,indentWithTab:yt,editable:vt,readOnly:St,root:xt,initialState:Dt}=g,Pt=_objectWithoutPropertiesLoose(g,_excluded),Ct=reactExports.useRef(null),{state:wt,view:Tt,container:Bt}=useCodeMirror({container:Ct.current,root:xt,value:$,autoFocus:it,theme:st,height:ot,minHeight:at,maxHeight:ut,width:ct,minWidth:dt,maxWidth:ht,basicSetup:pt,placeholder:gt,indentWithTab:yt,editable:vt,readOnly:St,selection:j,onChange:et,onStatistics:tt,onCreateEditor:nt,onUpdate:rt,extensions:_e,initialState:Dt});if(reactExports.useImperativeHandle(d,()=>({editor:Ct.current,state:wt,view:Tt}),[Ct,Bt,wt,Tt]),typeof $!="string")throw new Error("value must be typeof string but got "+typeof $);var Ft=typeof st=="string"?"cm-theme-"+st:"cm-theme";return jsxRuntimeExports.jsx("div",_extends({ref:Ct,className:""+Ft+(b?" "+b:"")},Pt))});ReactCodeMirror.displayName="CodeMirror";const EditorContainer=({onChange:g,placeholder:d="",rows:b=20,disabled:$=!1,autoFocus:j=!1,text:_e,setText:et,error:tt})=>{React.useEffect(()=>{g(_e)},[_e]);function nt(rt,it){console.log("here is the current model value:",rt),et(rt),g(rt)}return jsxRuntimeExports.jsxs("div",{className:"editor",children:[jsxRuntimeExports.jsx(ReactCodeMirror,{value:_e,height:"80vh",extensions:[],onChange:nt}),jsxRuntimeExports.jsx("p",{className:`edit-result ${tt?"error":""}`,children:tt})]})},wrapLines=(g,d)=>{const b=g.split(" "),$=[];let j="";return b.forEach((_e,et)=>{j.length+_e.length>d&&($.push(j),j=""),j+=_e+" ",et===b.length-1&&$.push(j)}),$};function computeResizeTransform(g,d,b,$){const j=g.getBBox({stroke:!0,fill:!0,markers:!0}),_e=j.width+b,et=j.height+$;console.log("bounding h w: ",et,_e);const tt=d.clientWidth,nt=d.clientHeight;console.log("container h w: ",nt,tt);const rt=Math.min(100/_e,100/et);return console.log("zoomScale: ",rt),`scale(${rt},${rt})`}function saveSvgUrl(g){const d=g.outerHTML,b=`\r +`,$=new Blob([b,d],{type:"image/svg+xml;charset=utf-8"});return URL.createObjectURL($)}const intermediatePoint=(g,d,b)=>{const $=d.x-g.x,j=d.y-g.y,_e=Math.sqrt($*$+j*j),et=b/_e;return{x:g.x+$*et,y:g.y+j*et}};function midPoint(g,d){return{x:(g.x+d.x)/2,y:(g.y+d.y)/2}}const Injection=({text:g,edge:d,dx:b,dy:$})=>{if(!g)return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{});const j=wrapLines(g,35),_e=midPoint(d.start,d.end),et=16,tt=_e.x+b,nt=tt-75,rt=_e.y+$,it=$/Math.abs($),st=rt+j.length*et+7,at=it===1?rt:st,ut=tt;return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("text",{x:nt,y:rt,children:j.map((ct,dt)=>jsxRuntimeExports.jsx("tspan",{x:nt,dy:et,children:ct},dt))}),jsxRuntimeExports.jsx("line",{x1:ut,y1:at,x2:_e.x,y2:_e.y,stroke:"#000",strokeDasharray:"4 5",strokeWidth:"2"})]})},CloudEdge=({edge:g})=>jsxRuntimeExports.jsx("line",{x1:g.adjStart.x,y1:g.adjStart.y,x2:g.end.x,y2:g.end.y,stroke:"#000",strokeWidth:"3",markerStart:"url(#startarrow)"}),CloudNode=({text:g,x:d,y:b,width:$,height:j,annotation:_e})=>{const et=wrapLines(g,20),tt=16,nt=12,rt=et.length*tt,it=b+j/2-rt/2-4,st=d+nt;return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("rect",{x:d,y:b,rx:"10",ry:"10",width:$,height:j}),jsxRuntimeExports.jsx("text",{x:st,y:it,children:et.map((ot,at)=>jsxRuntimeExports.jsx("tspan",{x:st,dy:tt,children:ot},at))}),jsxRuntimeExports.jsx("circle",{cx:d,cy:b,r:"10",style:{fill:"white",stroke:"black",strokeWidth:"2px"}}),jsxRuntimeExports.jsx("text",{x:d-4,y:b+4,children:_e})]})},drawCloud=g=>{const d={A:"",B:"",C:"",D:"","D'":""},b=new Map;g.statements.filter(wt=>wt.type==="node").forEach(wt=>{d[wt.id]=wt.text}),g.statements.forEach(wt=>{if(wt.type==="edge"){const Tt=wt.fromIds[0],Bt=wt.toId,Ft=Tt`${wt.x},${wt.y}`).join(" "),Ct=` + svg { + font-family: "trebuchet ms", verdana, arial, sans-serif; + font-size: 13px; + } + svg text { + fill: black; + } + svg text.annotation { + font-weight: bold; + } + svg rect { + fill: white; + stroke: black; + stroke-width: 2; + } + `;return jsxRuntimeExports.jsxs("svg",{id:"cloudSvg",width:"100%",height:"100%",version:"1.1",preserveAspectRatio:"xMinYMin",viewBox:"0 0 100 100",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntimeExports.jsx("style",{children:Ct}),jsxRuntimeExports.jsxs("g",{id:"cloudSvgInner",children:[jsxRuntimeExports.jsxs("defs",{children:[jsxRuntimeExports.jsx("marker",{id:"arrowhead",markerWidth:"10",markerHeight:"7",refX:"0",refY:"1.75",orient:"auto",children:jsxRuntimeExports.jsx("polygon",{points:"0 0, 10 3.5, 0 7",transform:"scale(0.5 0.5)"})}),jsxRuntimeExports.jsx("marker",{id:"startarrow",markerWidth:"10",markerHeight:"7",refX:"5",refY:"1.75",orient:"auto",children:jsxRuntimeExports.jsx("polygon",{points:"10 0, 10 7, 0 3.5",fill:"",transform:"scale(0.5 0.5)"})}),jsxRuntimeExports.jsx("marker",{id:"endarrow",markerWidth:"10",markerHeight:"7",refX:"0",refY:"1.75",orient:"auto",markerUnits:"strokeWidth",children:jsxRuntimeExports.jsx("polygon",{points:"0 0, 10 3.5, 0 7",fill:"",transform:"scale(0.5 0.5)"})})]}),jsxRuntimeExports.jsx(CloudNode,{annotation:"A",text:d.A,x:st.x,y:st.y,width:rt,height:it}),jsxRuntimeExports.jsx(CloudNode,{annotation:"B",text:d.B,x:ot.x,y:ot.y,width:rt,height:it}),jsxRuntimeExports.jsx(CloudNode,{annotation:"C",text:d.C,x:at.x,y:at.y,width:rt,height:it}),jsxRuntimeExports.jsx(CloudNode,{annotation:"D",text:d.D,x:ut.x,y:ut.y,width:rt,height:it}),jsxRuntimeExports.jsx(CloudNode,{annotation:"D'",text:d["D'"],x:ct.x,y:ct.y,width:rt,height:it}),jsxRuntimeExports.jsx(CloudEdge,{edge:dt}),jsxRuntimeExports.jsx(CloudEdge,{edge:ht}),jsxRuntimeExports.jsx(CloudEdge,{edge:pt}),jsxRuntimeExports.jsx(CloudEdge,{edge:gt}),jsxRuntimeExports.jsx(Injection,{text:b["A-B"],edge:dt,dx:-100,dy:-125}),jsxRuntimeExports.jsx(Injection,{text:b["A-C"],edge:ht,dx:-100,dy:125}),jsxRuntimeExports.jsx(Injection,{text:b["B-D"],edge:pt,dx:0,dy:-75}),jsxRuntimeExports.jsx(Injection,{text:b["C-D'"],edge:gt,dx:0,dy:75}),jsxRuntimeExports.jsx(Injection,{text:b["D-D'"],edge:Dt,dx:120,dy:20}),jsxRuntimeExports.jsx("polyline",{points:Pt,markerStart:"url(#startarrow)",markerEnd:"url(#endarrow)",style:{fill:"none",stroke:"black",strokeWidth:3}})]})]})};function createEdge(g,d){const b={start:{x:g.x+g.w,y:g.y+g.h/2},adjStart:{x:0,y:0},end:{x:d.x,y:d.y+d.h/2}};return b.adjStart=intermediatePoint(b.start,b.end,16),b}function nodeBottomCenterPont(g){return{x:g.x+g.w/2,y:g.y+g.h}}function nodeTopCenterPont(g){return{x:g.x+g.w/2,y:g.y}}function displacePoint(g,d,b){return{x:g.x+d,y:g.y+b}}function Cloud({ast:g,setSvgElem:d}){return g&&React.useEffect(()=>{const b=document.getElementById("cloudSvgInner"),$=document.getElementById("cloudSvgContainer");b==null||b.setAttribute("transform",computeResizeTransform(b,$,10,0)+", translate(-10, 0)"),d(document.getElementById("cloudSvg"))},[g]),jsxRuntimeExports.jsxs("div",{id:"cloudSvgContainer",style:{width:"100%",height:"500"},children:[g&&drawCloud(g),";"]})}var noop$2={value:()=>{}};function dispatch(){for(var g=0,d=arguments.length,b={},$;g=0&&($=b.slice(j+1),b=b.slice(0,j)),b&&!d.hasOwnProperty(b))throw new Error("unknown type: "+b);return{type:b,name:$}})}Dispatch.prototype=dispatch.prototype={constructor:Dispatch,on:function(g,d){var b=this._,$=parseTypenames$1(g+"",b),j,_e=-1,et=$.length;if(arguments.length<2){for(;++_e0)for(var b=new Array(j),$=0,j,_e;$=0&&(d=g.slice(0,b))!=="xmlns"&&(g=g.slice(b+1)),namespaces.hasOwnProperty(d)?{space:namespaces[d],local:g}:g}function creatorInherit(g){return function(){var d=this.ownerDocument,b=this.namespaceURI;return b===xhtml&&d.documentElement.namespaceURI===xhtml?d.createElement(g):d.createElementNS(b,g)}}function creatorFixed(g){return function(){return this.ownerDocument.createElementNS(g.space,g.local)}}function creator(g){var d=namespace(g);return(d.local?creatorFixed:creatorInherit)(d)}function none(){}function selector(g){return g==null?none:function(){return this.querySelector(g)}}function selection_select(g){typeof g!="function"&&(g=selector(g));for(var d=this._groups,b=d.length,$=new Array(b),j=0;j=gt&&(gt=pt+1);!(vt=dt[gt])&&++gt=0;)(et=$[j])&&(_e&&et.compareDocumentPosition(_e)^4&&_e.parentNode.insertBefore(et,_e),_e=et);return this}function selection_sort(g){g||(g=ascending);function d(st,ot){return st&&ot?g(st.__data__,ot.__data__):!st-!ot}for(var b=this._groups,$=b.length,j=new Array($),_e=0;_e<$;++_e){for(var et=b[_e],tt=et.length,nt=j[_e]=new Array(tt),rt,it=0;itd?1:g>=d?0:NaN}function selection_call(){var g=arguments[0];return arguments[0]=this,g.apply(null,arguments),this}function selection_nodes(){return Array.from(this)}function selection_node(){for(var g=this._groups,d=0,b=g.length;d1?this.each((d==null?styleRemove$1:typeof d=="function"?styleFunction$1:styleConstant$1)(g,d,b??"")):styleValue(this.node(),g)}function styleValue(g,d){return g.style.getPropertyValue(d)||defaultView(g).getComputedStyle(g,null).getPropertyValue(d)}function propertyRemove(g){return function(){delete this[g]}}function propertyConstant(g,d){return function(){this[g]=d}}function propertyFunction(g,d){return function(){var b=d.apply(this,arguments);b==null?delete this[g]:this[g]=b}}function selection_property(g,d){return arguments.length>1?this.each((d==null?propertyRemove:typeof d=="function"?propertyFunction:propertyConstant)(g,d)):this.node()[g]}function classArray(g){return g.trim().split(/^|\s+/)}function classList(g){return g.classList||new ClassList(g)}function ClassList(g){this._node=g,this._names=classArray(g.getAttribute("class")||"")}ClassList.prototype={add:function(g){var d=this._names.indexOf(g);d<0&&(this._names.push(g),this._node.setAttribute("class",this._names.join(" ")))},remove:function(g){var d=this._names.indexOf(g);d>=0&&(this._names.splice(d,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(g){return this._names.indexOf(g)>=0}};function classedAdd(g,d){for(var b=classList(g),$=-1,j=d.length;++$=0&&(b=d.slice($+1),d=d.slice(0,$)),{type:d,name:b}})}function onRemove(g){return function(){var d=this.__on;if(d){for(var b=0,$=-1,j=d.length,_e;b>8&15|d>>4&240,d>>4&15|d&240,(d&15)<<4|d&15,1):b===8?rgba(d>>24&255,d>>16&255,d>>8&255,(d&255)/255):b===4?rgba(d>>12&15|d>>8&240,d>>8&15|d>>4&240,d>>4&15|d&240,((d&15)<<4|d&15)/255):null):(d=reRgbInteger.exec(g))?new Rgb(d[1],d[2],d[3],1):(d=reRgbPercent.exec(g))?new Rgb(d[1]*255/100,d[2]*255/100,d[3]*255/100,1):(d=reRgbaInteger.exec(g))?rgba(d[1],d[2],d[3],d[4]):(d=reRgbaPercent.exec(g))?rgba(d[1]*255/100,d[2]*255/100,d[3]*255/100,d[4]):(d=reHslPercent.exec(g))?hsla(d[1],d[2]/100,d[3]/100,1):(d=reHslaPercent.exec(g))?hsla(d[1],d[2]/100,d[3]/100,d[4]):named.hasOwnProperty(g)?rgbn(named[g]):g==="transparent"?new Rgb(NaN,NaN,NaN,0):null}function rgbn(g){return new Rgb(g>>16&255,g>>8&255,g&255,1)}function rgba(g,d,b,$){return $<=0&&(g=d=b=NaN),new Rgb(g,d,b,$)}function rgbConvert(g){return g instanceof Color||(g=color(g)),g?(g=g.rgb(),new Rgb(g.r,g.g,g.b,g.opacity)):new Rgb}function rgb(g,d,b,$){return arguments.length===1?rgbConvert(g):new Rgb(g,d,b,$??1)}function Rgb(g,d,b,$){this.r=+g,this.g=+d,this.b=+b,this.opacity=+$}define(Rgb,rgb,extend(Color,{brighter(g){return g=g==null?brighter:Math.pow(brighter,g),new Rgb(this.r*g,this.g*g,this.b*g,this.opacity)},darker(g){return g=g==null?darker:Math.pow(darker,g),new Rgb(this.r*g,this.g*g,this.b*g,this.opacity)},rgb(){return this},clamp(){return new Rgb(clampi(this.r),clampi(this.g),clampi(this.b),clampa(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:rgb_formatHex,formatHex:rgb_formatHex,formatHex8:rgb_formatHex8,formatRgb:rgb_formatRgb,toString:rgb_formatRgb}));function rgb_formatHex(){return`#${hex$1(this.r)}${hex$1(this.g)}${hex$1(this.b)}`}function rgb_formatHex8(){return`#${hex$1(this.r)}${hex$1(this.g)}${hex$1(this.b)}${hex$1((isNaN(this.opacity)?1:this.opacity)*255)}`}function rgb_formatRgb(){const g=clampa(this.opacity);return`${g===1?"rgb(":"rgba("}${clampi(this.r)}, ${clampi(this.g)}, ${clampi(this.b)}${g===1?")":`, ${g})`}`}function clampa(g){return isNaN(g)?1:Math.max(0,Math.min(1,g))}function clampi(g){return Math.max(0,Math.min(255,Math.round(g)||0))}function hex$1(g){return g=clampi(g),(g<16?"0":"")+g.toString(16)}function hsla(g,d,b,$){return $<=0?g=d=b=NaN:b<=0||b>=1?g=d=NaN:d<=0&&(g=NaN),new Hsl(g,d,b,$)}function hslConvert(g){if(g instanceof Hsl)return new Hsl(g.h,g.s,g.l,g.opacity);if(g instanceof Color||(g=color(g)),!g)return new Hsl;if(g instanceof Hsl)return g;g=g.rgb();var d=g.r/255,b=g.g/255,$=g.b/255,j=Math.min(d,b,$),_e=Math.max(d,b,$),et=NaN,tt=_e-j,nt=(_e+j)/2;return tt?(d===_e?et=(b-$)/tt+(b<$)*6:b===_e?et=($-d)/tt+2:et=(d-b)/tt+4,tt/=nt<.5?_e+j:2-_e-j,et*=60):tt=nt>0&&nt<1?0:et,new Hsl(et,tt,nt,g.opacity)}function hsl(g,d,b,$){return arguments.length===1?hslConvert(g):new Hsl(g,d,b,$??1)}function Hsl(g,d,b,$){this.h=+g,this.s=+d,this.l=+b,this.opacity=+$}define(Hsl,hsl,extend(Color,{brighter(g){return g=g==null?brighter:Math.pow(brighter,g),new Hsl(this.h,this.s,this.l*g,this.opacity)},darker(g){return g=g==null?darker:Math.pow(darker,g),new Hsl(this.h,this.s,this.l*g,this.opacity)},rgb(){var g=this.h%360+(this.h<0)*360,d=isNaN(g)||isNaN(this.s)?0:this.s,b=this.l,$=b+(b<.5?b:1-b)*d,j=2*b-$;return new Rgb(hsl2rgb(g>=240?g-240:g+120,j,$),hsl2rgb(g,j,$),hsl2rgb(g<120?g+240:g-120,j,$),this.opacity)},clamp(){return new Hsl(clamph(this.h),clampt(this.s),clampt(this.l),clampa(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const g=clampa(this.opacity);return`${g===1?"hsl(":"hsla("}${clamph(this.h)}, ${clampt(this.s)*100}%, ${clampt(this.l)*100}%${g===1?")":`, ${g})`}`}}));function clamph(g){return g=(g||0)%360,g<0?g+360:g}function clampt(g){return Math.max(0,Math.min(1,g||0))}function hsl2rgb(g,d,b){return(g<60?d+(b-d)*g/60:g<180?b:g<240?d+(b-d)*(240-g)/60:d)*255}const constant$2=g=>()=>g;function linear(g,d){return function(b){return g+b*d}}function exponential(g,d,b){return g=Math.pow(g,b),d=Math.pow(d,b)-g,b=1/b,function($){return Math.pow(g+$*d,b)}}function gamma(g){return(g=+g)==1?nogamma:function(d,b){return b-d?exponential(d,b,g):constant$2(isNaN(d)?b:d)}}function nogamma(g,d){var b=d-g;return b?linear(g,b):constant$2(isNaN(g)?d:g)}const interpolateRgb=function g(d){var b=gamma(d);function $(j,_e){var et=b((j=rgb(j)).r,(_e=rgb(_e)).r),tt=b(j.g,_e.g),nt=b(j.b,_e.b),rt=nogamma(j.opacity,_e.opacity);return function(it){return j.r=et(it),j.g=tt(it),j.b=nt(it),j.opacity=rt(it),j+""}}return $.gamma=g,$}(1);function interpolateNumber(g,d){return g=+g,d=+d,function(b){return g*(1-b)+d*b}}var reA=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,reB=new RegExp(reA.source,"g");function zero(g){return function(){return g}}function one(g){return function(d){return g(d)+""}}function interpolateString(g,d){var b=reA.lastIndex=reB.lastIndex=0,$,j,_e,et=-1,tt=[],nt=[];for(g=g+"",d=d+"";($=reA.exec(g))&&(j=reB.exec(d));)(_e=j.index)>b&&(_e=d.slice(b,_e),tt[et]?tt[et]+=_e:tt[++et]=_e),($=$[0])===(j=j[0])?tt[et]?tt[et]+=j:tt[++et]=j:(tt[++et]=null,nt.push({i:et,x:interpolateNumber($,j)})),b=reB.lastIndex;return b180?it+=360:it-rt>180&&(rt+=360),ot.push({i:st.push(j(st)+"rotate(",null,$)-2,x:interpolateNumber(rt,it)})):it&&st.push(j(st)+"rotate("+it+$)}function tt(rt,it,st,ot){rt!==it?ot.push({i:st.push(j(st)+"skewX(",null,$)-2,x:interpolateNumber(rt,it)}):it&&st.push(j(st)+"skewX("+it+$)}function nt(rt,it,st,ot,at,ut){if(rt!==st||it!==ot){var ct=at.push(j(at)+"scale(",null,",",null,")");ut.push({i:ct-4,x:interpolateNumber(rt,st)},{i:ct-2,x:interpolateNumber(it,ot)})}else(st!==1||ot!==1)&&at.push(j(at)+"scale("+st+","+ot+")")}return function(rt,it){var st=[],ot=[];return rt=g(rt),it=g(it),_e(rt.translateX,rt.translateY,it.translateX,it.translateY,st,ot),et(rt.rotate,it.rotate,st,ot),tt(rt.skewX,it.skewX,st,ot),nt(rt.scaleX,rt.scaleY,it.scaleX,it.scaleY,st,ot),rt=it=null,function(at){for(var ut=-1,ct=ot.length,dt;++ut=0&&g._call.call(void 0,d),g=g._next;--frame}function wake(){clockNow=(clockLast=clock.now())+clockSkew,frame=timeout$1=0;try{timerFlush()}finally{frame=0,nap(),clockNow=0}}function poke(){var g=clock.now(),d=g-clockLast;d>pokeDelay&&(clockSkew-=d,clockLast=g)}function nap(){for(var g,d=taskHead,b,$=1/0;d;)d._call?($>d._time&&($=d._time),g=d,d=d._next):(b=d._next,d._next=null,d=g?g._next=b:taskHead=b);taskTail=g,sleep($)}function sleep(g){if(!frame){timeout$1&&(timeout$1=clearTimeout(timeout$1));var d=g-clockNow;d>24?(g<1/0&&(timeout$1=setTimeout(wake,g-clock.now()-clockSkew)),interval&&(interval=clearInterval(interval))):(interval||(clockLast=clock.now(),interval=setInterval(poke,pokeDelay)),frame=1,setFrame(wake))}}function timeout(g,d,b){var $=new Timer;return d=d==null?0:+d,$.restart(j=>{$.stop(),g(j+d)},d,b),$}var emptyOn=dispatch("start","end","cancel","interrupt"),emptyTween=[],CREATED=0,SCHEDULED=1,STARTING=2,STARTED=3,RUNNING=4,ENDING=5,ENDED=6;function schedule(g,d,b,$,j,_e){var et=g.__transition;if(!et)g.__transition={};else if(b in et)return;create(g,b,{name:d,index:$,group:j,on:emptyOn,tween:emptyTween,time:_e.time,delay:_e.delay,duration:_e.duration,ease:_e.ease,timer:null,state:CREATED})}function init(g,d){var b=get$1(g,d);if(b.state>CREATED)throw new Error("too late; already scheduled");return b}function set(g,d){var b=get$1(g,d);if(b.state>STARTED)throw new Error("too late; already running");return b}function get$1(g,d){var b=g.__transition;if(!b||!(b=b[d]))throw new Error("transition not found");return b}function create(g,d,b){var $=g.__transition,j;$[d]=b,b.timer=timer(_e,0,b.time);function _e(rt){b.state=SCHEDULED,b.timer.restart(et,b.delay,b.time),b.delay<=rt&&et(rt-b.delay)}function et(rt){var it,st,ot,at;if(b.state!==SCHEDULED)return nt();for(it in $)if(at=$[it],at.name===b.name){if(at.state===STARTED)return timeout(et);at.state===RUNNING?(at.state=ENDED,at.timer.stop(),at.on.call("interrupt",g,g.__data__,at.index,at.group),delete $[it]):+itSTARTING&&$.state=0&&(d=d.slice(0,b)),!d||d==="start"})}function onFunction(g,d,b){var $,j,_e=start(d)?init:set;return function(){var et=_e(this,g),tt=et.on;tt!==$&&(j=($=tt).copy()).on(d,b),et.on=j}}function transition_on(g,d){var b=this._id;return arguments.length<2?get$1(this.node(),b).on.on(g):this.each(onFunction(b,g,d))}function removeFunction(g){return function(){var d=this.parentNode;for(var b in this.__transition)if(+b!==g)return;d&&d.removeChild(this)}}function transition_remove(){return this.on("end.remove",removeFunction(this._id))}function transition_select(g){var d=this._name,b=this._id;typeof g!="function"&&(g=selector(g));for(var $=this._groups,j=$.length,_e=new Array(j),et=0;et=0))throw new Error(`invalid digits: ${g}`);if(d>15)return append;const b=10**d;return function($){this._+=$[0];for(let j=1,_e=$.length;j<_e;++j)this._+=Math.round(arguments[j]*b)/b+$[j]}}class Path{constructor(d){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=d==null?append:appendRound(d)}moveTo(d,b){this._append`M${this._x0=this._x1=+d},${this._y0=this._y1=+b}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(d,b){this._append`L${this._x1=+d},${this._y1=+b}`}quadraticCurveTo(d,b,$,j){this._append`Q${+d},${+b},${this._x1=+$},${this._y1=+j}`}bezierCurveTo(d,b,$,j,_e,et){this._append`C${+d},${+b},${+$},${+j},${this._x1=+_e},${this._y1=+et}`}arcTo(d,b,$,j,_e){if(d=+d,b=+b,$=+$,j=+j,_e=+_e,_e<0)throw new Error(`negative radius: ${_e}`);let et=this._x1,tt=this._y1,nt=$-d,rt=j-b,it=et-d,st=tt-b,ot=it*it+st*st;if(this._x1===null)this._append`M${this._x1=d},${this._y1=b}`;else if(ot>epsilon)if(!(Math.abs(st*nt-rt*it)>epsilon)||!_e)this._append`L${this._x1=d},${this._y1=b}`;else{let at=$-et,ut=j-tt,ct=nt*nt+rt*rt,dt=at*at+ut*ut,ht=Math.sqrt(ct),pt=Math.sqrt(ot),gt=_e*Math.tan((pi-Math.acos((ct+ot-dt)/(2*ht*pt)))/2),yt=gt/pt,vt=gt/ht;Math.abs(yt-1)>epsilon&&this._append`L${d+yt*it},${b+yt*st}`,this._append`A${_e},${_e},0,0,${+(st*at>it*ut)},${this._x1=d+vt*nt},${this._y1=b+vt*rt}`}}arc(d,b,$,j,_e,et){if(d=+d,b=+b,$=+$,et=!!et,$<0)throw new Error(`negative radius: ${$}`);let tt=$*Math.cos(j),nt=$*Math.sin(j),rt=d+tt,it=b+nt,st=1^et,ot=et?j-_e:_e-j;this._x1===null?this._append`M${rt},${it}`:(Math.abs(this._x1-rt)>epsilon||Math.abs(this._y1-it)>epsilon)&&this._append`L${rt},${it}`,$&&(ot<0&&(ot=ot%tau+tau),ot>tauEpsilon?this._append`A${$},${$},0,1,${st},${d-tt},${b-nt}A${$},${$},0,1,${st},${this._x1=rt},${this._y1=it}`:ot>epsilon&&this._append`A${$},${$},0,${+(ot>=pi)},${st},${this._x1=d+$*Math.cos(_e)},${this._y1=b+$*Math.sin(_e)}`)}rect(d,b,$,j){this._append`M${this._x0=this._x1=+d},${this._y0=this._y1=+b}h${$=+$}v${+j}h${-$}Z`}toString(){return this._}}function responseText(g){if(!g.ok)throw new Error(g.status+" "+g.statusText);return g.text()}function text(g,d){return fetch(g,d).then(responseText)}function parser$2(g){return(d,b)=>text(d,b).then($=>new DOMParser().parseFromString($,g))}var svg=parser$2("image/svg+xml");function constant$1(g){return function(){return g}}function withPath(g){let d=3;return g.digits=function(b){if(!arguments.length)return d;if(b==null)d=null;else{const $=Math.floor(b);if(!($>=0))throw new RangeError(`invalid digits: ${b}`);d=$}return g},()=>new Path(d)}function array(g){return typeof g=="object"&&"length"in g?g:Array.from(g)}function Linear(g){this._context=g}Linear.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(g,d){switch(g=+g,d=+d,this._point){case 0:this._point=1,this._line?this._context.lineTo(g,d):this._context.moveTo(g,d);break;case 1:this._point=2;default:this._context.lineTo(g,d);break}}};function curveLinear(g){return new Linear(g)}function x(g){return g[0]}function y$1(g){return g[1]}function line(g,d){var b=constant$1(!0),$=null,j=curveLinear,_e=null,et=withPath(tt);g=typeof g=="function"?g:g===void 0?x:constant$1(g),d=typeof d=="function"?d:d===void 0?y$1:constant$1(d);function tt(nt){var rt,it=(nt=array(nt)).length,st,ot=!1,at;for($==null&&(_e=j(at=et())),rt=0;rt<=it;++rt)!(rt0){if(++d>=HOT_COUNT)return arguments[0]}else d=0;return g.apply(void 0,arguments)}}function constant(g){return function(){return g}}var defineProperty=function(){try{var g=getNative(Object,"defineProperty");return g({},"",{}),g}catch{}}();const defineProperty$1=defineProperty;var baseSetToString=defineProperty$1?function(g,d){return defineProperty$1(g,"toString",{configurable:!0,enumerable:!1,value:constant(d),writable:!0})}:identity$1;const baseSetToString$1=baseSetToString;var setToString=shortOut(baseSetToString$1);const setToString$1=setToString;function arrayEach(g,d){for(var b=-1,$=g==null?0:g.length;++b<$&&d(g[b],b,g)!==!1;);return g}function baseFindIndex(g,d,b,$){for(var j=g.length,_e=b+($?1:-1);$?_e--:++_e-1}var MAX_SAFE_INTEGER$1=9007199254740991,reIsUint=/^(?:0|[1-9]\d*)$/;function isIndex(g,d){var b=typeof g;return d=d??MAX_SAFE_INTEGER$1,!!d&&(b=="number"||b!="symbol"&&reIsUint.test(g))&&g>-1&&g%1==0&&g-1&&g%1==0&&g<=MAX_SAFE_INTEGER}function isArrayLike(g){return g!=null&&isLength(g.length)&&!isFunction(g)}function isIterateeCall(g,d,b){if(!isObject(b))return!1;var $=typeof d;return($=="number"?isArrayLike(b)&&isIndex(d,b.length):$=="string"&&d in b)?eq(b[d],g):!1}function createAssigner(g){return baseRest(function(d,b){var $=-1,j=b.length,_e=j>1?b[j-1]:void 0,et=j>2?b[2]:void 0;for(_e=g.length>3&&typeof _e=="function"?(j--,_e):void 0,et&&isIterateeCall(b[0],b[1],et)&&(_e=j<3?void 0:_e,j=1),d=Object(d);++$-1}function listCacheSet(g,d){var b=this.__data__,$=assocIndexOf(b,g);return $<0?(++this.size,b.push([g,d])):b[$][1]=d,this}function ListCache(g){var d=-1,b=g==null?0:g.length;for(this.clear();++d0&&b(tt)?d>1?baseFlatten(tt,d-1,b,$,j):arrayPush(j,tt):$||(j[j.length]=tt)}return j}function flatten(g){var d=g==null?0:g.length;return d?baseFlatten(g,1):[]}function flatRest(g){return setToString$1(overRest(g,void 0,flatten),g+"")}var getPrototype=overArg(Object.getPrototypeOf,Object);const getPrototype$1=getPrototype;var objectTag$3="[object Object]",funcProto=Function.prototype,objectProto$7=Object.prototype,funcToString=funcProto.toString,hasOwnProperty$6=objectProto$7.hasOwnProperty,objectCtorString=funcToString.call(Object);function isPlainObject(g){if(!isObjectLike(g)||baseGetTag(g)!=objectTag$3)return!1;var d=getPrototype$1(g);if(d===null)return!0;var b=hasOwnProperty$6.call(d,"constructor")&&d.constructor;return typeof b=="function"&&b instanceof b&&funcToString.call(b)==objectCtorString}function arrayReduce(g,d,b,$){var j=-1,_e=g==null?0:g.length;for($&&_e&&(b=g[++j]);++j<_e;)b=d(b,g[j],j,g);return b}function stackClear(){this.__data__=new ListCache,this.size=0}function stackDelete(g){var d=this.__data__,b=d.delete(g);return this.size=d.size,b}function stackGet(g){return this.__data__.get(g)}function stackHas(g){return this.__data__.has(g)}var LARGE_ARRAY_SIZE$1=200;function stackSet(g,d){var b=this.__data__;if(b instanceof ListCache){var $=b.__data__;if(!Map$2||$.lengthtt))return!1;var rt=_e.get(g),it=_e.get(d);if(rt&&it)return rt==d&&it==g;var st=-1,ot=!0,at=b&COMPARE_UNORDERED_FLAG$3?new SetCache:void 0;for(_e.set(g,d),_e.set(d,g);++st2?d[2]:void 0;for(j&&isIterateeCall(d[0],d[1],j)&&($=1);++b<$;)for(var _e=d[b],et=keysIn(_e),tt=-1,nt=et.length;++tt-1?j[_e?d[et]:et]:void 0}}var nativeMax$1=Math.max;function findIndex(g,d,b){var $=g==null?0:g.length;if(!$)return-1;var j=b==null?0:toInteger(b);return j<0&&(j=nativeMax$1($+j,0)),baseFindIndex(g,baseIteratee(d),j)}var find=createFind(findIndex);const find$1=find;function baseMap(g,d){var b=-1,$=isArrayLike(g)?Array(g.length):[];return baseEach$1(g,function(j,_e,et){$[++b]=d(j,_e,et)}),$}function map(g,d){var b=isArray$1(g)?arrayMap:baseMap;return b(g,baseIteratee(d))}function forIn(g,d){return g==null?g:baseFor$1(g,castFunction(d),keysIn)}function forOwn(g,d){return g&&baseForOwn(g,castFunction(d))}function baseGt(g,d){return g>d}var objectProto$1=Object.prototype,hasOwnProperty$1=objectProto$1.hasOwnProperty;function baseHas(g,d){return g!=null&&hasOwnProperty$1.call(g,d)}function has(g,d){return g!=null&&hasPath(g,d,baseHas)}function baseValues(g,d){return arrayMap(d,function(b){return g[b]})}function values(g){return g==null?[]:baseValues(g,keys(g))}var mapTag="[object Map]",setTag="[object Set]",objectProto=Object.prototype,hasOwnProperty=objectProto.hasOwnProperty;function isEmpty(g){if(g==null)return!0;if(isArrayLike(g)&&(isArray$1(g)||typeof g=="string"||typeof g.splice=="function"||isBuffer$1(g)||isTypedArray$1(g)||isArguments$1(g)))return!g.length;var d=getTag$1(g);if(d==mapTag||d==setTag)return!g.size;if(isPrototype(g))return!baseKeys(g).length;for(var b in g)if(hasOwnProperty.call(g,b))return!1;return!0}function isUndefined(g){return g===void 0}function baseLt(g,d){return gd||_e&&et&&nt&&!tt&&!rt||$&&et&&nt||!b&&nt||!j)return 1;if(!$&&!_e&&!rt&&g=tt)return nt;var rt=b[$];return nt*(rt=="desc"?-1:1)}}return g.index-d.index}function baseOrderBy(g,d,b){d.length?d=arrayMap(d,function(_e){return isArray$1(_e)?function(et){return baseGet(et,_e.length===1?_e[0]:_e)}:_e}):d=[identity$1];var $=-1;d=arrayMap(d,baseUnary(baseIteratee));var j=baseMap(g,function(_e,et,tt){var nt=arrayMap(d,function(rt){return rt(_e)});return{criteria:nt,index:++$,value:_e}});return baseSortBy(j,function(_e,et){return compareMultiple(_e,et,b)})}function basePick(g,d){return basePickBy(g,d,function(b,$){return hasIn(g,$)})}var pick=flatRest(function(g,d){return g==null?{}:basePick(g,d)});const pick$1=pick;var nativeCeil=Math.ceil,nativeMax=Math.max;function baseRange(g,d,b,$){for(var j=-1,_e=nativeMax(nativeCeil((d-g)/(b||1)),0),et=Array(_e);_e--;)et[$?_e:++j]=g,g+=b;return et}function createRange(g){return function(d,b,$){return $&&typeof $!="number"&&isIterateeCall(d,b,$)&&(b=$=void 0),d=toFinite(d),b===void 0?(b=d,d=0):b=toFinite(b),$=$===void 0?d1&&isIterateeCall(g,d[0],d[1])?d=[]:b>2&&isIterateeCall(d[0],d[1],d[2])&&(d=[d[0]]),baseOrderBy(g,baseFlatten(d,1),[])});const sortBy$1=sortBy;var INFINITY=1/0,createSet=Set$2&&1/setToArray(new Set$2([,-0]))[1]==INFINITY?function(g){return new Set$2(g)}:noop$1;const createSet$1=createSet;var LARGE_ARRAY_SIZE=200;function baseUniq(g,d,b){var $=-1,j=arrayIncludes,_e=g.length,et=!0,tt=[],nt=tt;if(b)et=!1,j=arrayIncludesWith;else if(_e>=LARGE_ARRAY_SIZE){var rt=d?null:createSet$1(g);if(rt)return setToArray(rt);et=!1,j=cacheHas,nt=new SetCache}else nt=d?[]:tt;e:for(;++$<_e;){var it=g[$],st=d?d(it):it;if(it=b||it!==0?it:0,et&&st===st){for(var ot=nt.length;ot--;)if(nt[ot]===st)continue e;d&&nt.push(st),tt.push(it)}else j(nt,st,b)||(nt!==tt&&nt.push(st),tt.push(it))}return tt}var union=baseRest(function(g){return baseUniq(baseFlatten(g,1,isArrayLikeObject,!0))});const union$1=union;var idCounter=0;function uniqueId(g){var d=++idCounter;return toString(g)+d}function baseZipObject(g,d,b){for(var $=-1,j=g.length,_e=d.length,et={};++$1?j.setNode(_e,b):j.setNode(_e)}),this}setNode(d,b){return has(this._nodes,d)?(arguments.length>1&&(this._nodes[d]=b),this):(this._nodes[d]=arguments.length>1?b:this._defaultNodeLabelFn(d),this._isCompound&&(this._parent[d]=GRAPH_NODE,this._children[d]={},this._children[GRAPH_NODE][d]=!0),this._in[d]={},this._preds[d]={},this._out[d]={},this._sucs[d]={},++this._nodeCount,this)}node(d){return this._nodes[d]}hasNode(d){return has(this._nodes,d)}removeNode(d){var b=this;if(has(this._nodes,d)){var $=function(j){b.removeEdge(b._edgeObjs[j])};delete this._nodes[d],this._isCompound&&(this._removeFromParentsChildList(d),delete this._parent[d],forEach(this.children(d),function(j){b.setParent(j)}),delete this._children[d]),forEach(keys(this._in[d]),$),delete this._in[d],delete this._preds[d],forEach(keys(this._out[d]),$),delete this._out[d],delete this._sucs[d],--this._nodeCount}return this}setParent(d,b){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(isUndefined(b))b=GRAPH_NODE;else{b+="";for(var $=b;!isUndefined($);$=this.parent($))if($===d)throw new Error("Setting "+b+" as parent of "+d+" would create a cycle");this.setNode(b)}return this.setNode(d),this._removeFromParentsChildList(d),this._parent[d]=b,this._children[b][d]=!0,this}_removeFromParentsChildList(d){delete this._children[this._parent[d]][d]}parent(d){if(this._isCompound){var b=this._parent[d];if(b!==GRAPH_NODE)return b}}children(d){if(isUndefined(d)&&(d=GRAPH_NODE),this._isCompound){var b=this._children[d];if(b)return keys(b)}else{if(d===GRAPH_NODE)return this.nodes();if(this.hasNode(d))return[]}}predecessors(d){var b=this._preds[d];if(b)return keys(b)}successors(d){var b=this._sucs[d];if(b)return keys(b)}neighbors(d){var b=this.predecessors(d);if(b)return union$1(b,this.successors(d))}isLeaf(d){var b;return this.isDirected()?b=this.successors(d):b=this.neighbors(d),b.length===0}filterNodes(d){var b=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});b.setGraph(this.graph());var $=this;forEach(this._nodes,function(et,tt){d(tt)&&b.setNode(tt,et)}),forEach(this._edgeObjs,function(et){b.hasNode(et.v)&&b.hasNode(et.w)&&b.setEdge(et,$.edge(et))});var j={};function _e(et){var tt=$.parent(et);return tt===void 0||b.hasNode(tt)?(j[et]=tt,tt):tt in j?j[tt]:_e(tt)}return this._isCompound&&forEach(b.nodes(),function(et){b.setParent(et,_e(et))}),b}setDefaultEdgeLabel(d){return isFunction(d)||(d=constant(d)),this._defaultEdgeLabelFn=d,this}edgeCount(){return this._edgeCount}edges(){return values(this._edgeObjs)}setPath(d,b){var $=this,j=arguments;return reduce(d,function(_e,et){return j.length>1?$.setEdge(_e,et,b):$.setEdge(_e,et),et}),this}setEdge(){var d,b,$,j,_e=!1,et=arguments[0];typeof et=="object"&&et!==null&&"v"in et?(d=et.v,b=et.w,$=et.name,arguments.length===2&&(j=arguments[1],_e=!0)):(d=et,b=arguments[1],$=arguments[3],arguments.length>2&&(j=arguments[2],_e=!0)),d=""+d,b=""+b,isUndefined($)||($=""+$);var tt=edgeArgsToId(this._isDirected,d,b,$);if(has(this._edgeLabels,tt))return _e&&(this._edgeLabels[tt]=j),this;if(!isUndefined($)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(d),this.setNode(b),this._edgeLabels[tt]=_e?j:this._defaultEdgeLabelFn(d,b,$);var nt=edgeArgsToObj(this._isDirected,d,b,$);return d=nt.v,b=nt.w,Object.freeze(nt),this._edgeObjs[tt]=nt,incrementOrInitEntry(this._preds[b],d),incrementOrInitEntry(this._sucs[d],b),this._in[b][tt]=nt,this._out[d][tt]=nt,this._edgeCount++,this}edge(d,b,$){var j=arguments.length===1?edgeObjToId(this._isDirected,arguments[0]):edgeArgsToId(this._isDirected,d,b,$);return this._edgeLabels[j]}hasEdge(d,b,$){var j=arguments.length===1?edgeObjToId(this._isDirected,arguments[0]):edgeArgsToId(this._isDirected,d,b,$);return has(this._edgeLabels,j)}removeEdge(d,b,$){var j=arguments.length===1?edgeObjToId(this._isDirected,arguments[0]):edgeArgsToId(this._isDirected,d,b,$),_e=this._edgeObjs[j];return _e&&(d=_e.v,b=_e.w,delete this._edgeLabels[j],delete this._edgeObjs[j],decrementOrRemoveEntry(this._preds[b],d),decrementOrRemoveEntry(this._sucs[d],b),delete this._in[b][j],delete this._out[d][j],this._edgeCount--),this}inEdges(d,b){var $=this._in[d];if($){var j=values($);return b?filter(j,function(_e){return _e.v===b}):j}}outEdges(d,b){var $=this._out[d];if($){var j=values($);return b?filter(j,function(_e){return _e.w===b}):j}}nodeEdges(d,b){var $=this.inEdges(d,b);if($)return $.concat(this.outEdges(d,b))}}Graph.prototype._nodeCount=0;Graph.prototype._edgeCount=0;function incrementOrInitEntry(g,d){g[d]?g[d]++:g[d]=1}function decrementOrRemoveEntry(g,d){--g[d]||delete g[d]}function edgeArgsToId(g,d,b,$){var j=""+d,_e=""+b;if(!g&&j>_e){var et=j;j=_e,_e=et}return j+EDGE_KEY_DELIM+_e+EDGE_KEY_DELIM+(isUndefined($)?DEFAULT_EDGE_NAME:$)}function edgeArgsToObj(g,d,b,$){var j=""+d,_e=""+b;if(!g&&j>_e){var et=j;j=_e,_e=et}var tt={v:j,w:_e};return $&&(tt.name=$),tt}function edgeObjToId(g,d){return edgeArgsToId(g,d.v,d.w,d.name)}class List{constructor(){var d={};d._next=d._prev=d,this._sentinel=d}dequeue(){var d=this._sentinel,b=d._prev;if(b!==d)return unlink(b),b}enqueue(d){var b=this._sentinel;d._prev&&d._next&&unlink(d),d._next=b._next,b._next._prev=d,b._next=d,d._prev=b}toString(){for(var d=[],b=this._sentinel,$=b._prev;$!==b;)d.push(JSON.stringify($,filterOutLinks)),$=$._prev;return"["+d.join(", ")+"]"}}function unlink(g){g._prev._next=g._next,g._next._prev=g._prev,delete g._next,delete g._prev}function filterOutLinks(g,d){if(g!=="_next"&&g!=="_prev")return d}var DEFAULT_WEIGHT_FN=constant(1);function greedyFAS(g,d){if(g.nodeCount()<=1)return[];var b=buildState(g,d||DEFAULT_WEIGHT_FN),$=doGreedyFAS(b.graph,b.buckets,b.zeroIdx);return flatten(map($,function(j){return g.outEdges(j.v,j.w)}))}function doGreedyFAS(g,d,b){for(var $=[],j=d[d.length-1],_e=d[0],et;g.nodeCount();){for(;et=_e.dequeue();)removeNode(g,d,b,et);for(;et=j.dequeue();)removeNode(g,d,b,et);if(g.nodeCount()){for(var tt=d.length-2;tt>0;--tt)if(et=d[tt].dequeue(),et){$=$.concat(removeNode(g,d,b,et,!0));break}}}return $}function removeNode(g,d,b,$,j){var _e=j?[]:void 0;return forEach(g.inEdges($.v),function(et){var tt=g.edge(et),nt=g.node(et.v);j&&_e.push({v:et.v,w:et.w}),nt.out-=tt,assignBucket(d,b,nt)}),forEach(g.outEdges($.v),function(et){var tt=g.edge(et),nt=et.w,rt=g.node(nt);rt.in-=tt,assignBucket(d,b,rt)}),g.removeNode($.v),_e}function buildState(g,d){var b=new Graph,$=0,j=0;forEach(g.nodes(),function(tt){b.setNode(tt,{v:tt,in:0,out:0})}),forEach(g.edges(),function(tt){var nt=b.edge(tt.v,tt.w)||0,rt=d(tt),it=nt+rt;b.setEdge(tt.v,tt.w,it),j=Math.max(j,b.node(tt.v).out+=rt),$=Math.max($,b.node(tt.w).in+=rt)});var _e=range$1(j+$+3).map(function(){return new List}),et=$+1;return forEach(b.nodes(),function(tt){assignBucket(_e,et,b.node(tt))}),{graph:b,buckets:_e,zeroIdx:et}}function assignBucket(g,d,b){b.out?b.in?g[b.out-b.in+d].enqueue(b):g[g.length-1].enqueue(b):g[0].enqueue(b)}function run$2(g){var d=g.graph().acyclicer==="greedy"?greedyFAS(g,b(g)):dfsFAS(g);forEach(d,function($){var j=g.edge($);g.removeEdge($),j.forwardName=$.name,j.reversed=!0,g.setEdge($.w,$.v,j,uniqueId("rev"))});function b($){return function(j){return $.edge(j).weight}}}function dfsFAS(g){var d=[],b={},$={};function j(_e){has($,_e)||($[_e]=!0,b[_e]=!0,forEach(g.outEdges(_e),function(et){has(b,et.w)?d.push(et):j(et.w)}),delete b[_e])}return forEach(g.nodes(),j),d}function undo$2(g){forEach(g.edges(),function(d){var b=g.edge(d);if(b.reversed){g.removeEdge(d);var $=b.forwardName;delete b.reversed,delete b.forwardName,g.setEdge(d.w,d.v,b,$)}})}function addDummyNode(g,d,b,$){var j;do j=uniqueId($);while(g.hasNode(j));return b.dummy=d,g.setNode(j,b),j}function simplify(g){var d=new Graph().setGraph(g.graph());return forEach(g.nodes(),function(b){d.setNode(b,g.node(b))}),forEach(g.edges(),function(b){var $=d.edge(b.v,b.w)||{weight:0,minlen:1},j=g.edge(b);d.setEdge(b.v,b.w,{weight:$.weight+j.weight,minlen:Math.max($.minlen,j.minlen)})}),d}function asNonCompoundGraph(g){var d=new Graph({multigraph:g.isMultigraph()}).setGraph(g.graph());return forEach(g.nodes(),function(b){g.children(b).length||d.setNode(b,g.node(b))}),forEach(g.edges(),function(b){d.setEdge(b,g.edge(b))}),d}function intersectRect$1(g,d){var b=g.x,$=g.y,j=d.x-b,_e=d.y-$,et=g.width/2,tt=g.height/2;if(!j&&!_e)throw new Error("Not possible to find intersection inside of the rectangle");var nt,rt;return Math.abs(_e)*et>Math.abs(j)*tt?(_e<0&&(tt=-tt),nt=tt*j/_e,rt=tt):(j<0&&(et=-et),nt=et,rt=et*_e/j),{x:b+nt,y:$+rt}}function buildLayerMatrix(g){var d=map(range$1(maxRank(g)+1),function(){return[]});return forEach(g.nodes(),function(b){var $=g.node(b),j=$.rank;isUndefined(j)||(d[j][$.order]=b)}),d}function normalizeRanks(g){var d=min(map(g.nodes(),function(b){return g.node(b).rank}));forEach(g.nodes(),function(b){var $=g.node(b);has($,"rank")&&($.rank-=d)})}function removeEmptyRanks(g){var d=min(map(g.nodes(),function(_e){return g.node(_e).rank})),b=[];forEach(g.nodes(),function(_e){var et=g.node(_e).rank-d;b[et]||(b[et]=[]),b[et].push(_e)});var $=0,j=g.graph().nodeRankFactor;forEach(b,function(_e,et){isUndefined(_e)&&et%j!==0?--$:$&&forEach(_e,function(tt){g.node(tt).rank+=$})})}function addBorderNode$1(g,d,b,$){var j={width:0,height:0};return arguments.length>=4&&(j.rank=b,j.order=$),addDummyNode(g,"border",j,d)}function maxRank(g){return max(map(g.nodes(),function(d){var b=g.node(d).rank;if(!isUndefined(b))return b}))}function partition(g,d){var b={lhs:[],rhs:[]};return forEach(g,function($){d($)?b.lhs.push($):b.rhs.push($)}),b}function time(g,d){var b=now$2();try{return d()}finally{console.log(g+" time: "+(now$2()-b)+"ms")}}function notime(g,d){return d()}function addBorderSegments(g){function d(b){var $=g.children(b),j=g.node(b);if($.length&&forEach($,d),has(j,"minRank")){j.borderLeft=[],j.borderRight=[];for(var _e=j.minRank,et=j.maxRank+1;_eet.lim&&(tt=et,nt=!0);var rt=filter(d.edges(),function(it){return nt===isDescendant(g,g.node(it.v),tt)&&nt!==isDescendant(g,g.node(it.w),tt)});return minBy(rt,function(it){return slack(d,it)})}function exchangeEdges(g,d,b,$){var j=b.v,_e=b.w;g.removeEdge(j,_e),g.setEdge($.v,$.w,{}),initLowLimValues(g),initCutValues(g,d),updateRanks(g,d)}function updateRanks(g,d){var b=find$1(g.nodes(),function(j){return!d.node(j).parent}),$=preorder(g,b);$=$.slice(1),forEach($,function(j){var _e=g.node(j).parent,et=d.edge(j,_e),tt=!1;et||(et=d.edge(_e,j),tt=!0),d.node(j).rank=d.node(_e).rank+(tt?et.minlen:-et.minlen)})}function isTreeEdge(g,d,b){return g.hasEdge(d,b)}function isDescendant(g,d,b){return b.low<=d.lim&&d.lim<=b.lim}function rank(g){switch(g.graph().ranker){case"network-simplex":networkSimplexRanker(g);break;case"tight-tree":tightTreeRanker(g);break;case"longest-path":longestPathRanker(g);break;default:networkSimplexRanker(g)}}var longestPathRanker=longestPath;function tightTreeRanker(g){longestPath(g),feasibleTree(g)}function networkSimplexRanker(g){networkSimplex(g)}function run(g){var d=addDummyNode(g,"root",{},"_root"),b=treeDepths(g),$=max(values(b))-1,j=2*$+1;g.graph().nestingRoot=d,forEach(g.edges(),function(et){g.edge(et).minlen*=j});var _e=sumWeights(g)+1;forEach(g.children(),function(et){dfs(g,d,j,_e,$,b,et)}),g.graph().nodeRankFactor=j}function dfs(g,d,b,$,j,_e,et){var tt=g.children(et);if(!tt.length){et!==d&&g.setEdge(d,et,{weight:0,minlen:b});return}var nt=addBorderNode$1(g,"_bt"),rt=addBorderNode$1(g,"_bb"),it=g.node(et);g.setParent(nt,et),it.borderTop=nt,g.setParent(rt,et),it.borderBottom=rt,forEach(tt,function(st){dfs(g,d,b,$,j,_e,st);var ot=g.node(st),at=ot.borderTop?ot.borderTop:st,ut=ot.borderBottom?ot.borderBottom:st,ct=ot.borderTop?$:2*$,dt=at!==ut?1:j-_e[et]+1;g.setEdge(nt,at,{weight:ct,minlen:dt,nestingEdge:!0}),g.setEdge(ut,rt,{weight:ct,minlen:dt,nestingEdge:!0})}),g.parent(et)||g.setEdge(d,nt,{weight:0,minlen:j+_e[et]})}function treeDepths(g){var d={};function b($,j){var _e=g.children($);_e&&_e.length&&forEach(_e,function(et){b(et,j+1)}),d[$]=j}return forEach(g.children(),function($){b($,1)}),d}function sumWeights(g){return reduce(g.edges(),function(d,b){return d+g.edge(b).weight},0)}function cleanup(g){var d=g.graph();g.removeNode(d.nestingRoot),delete d.nestingRoot,forEach(g.edges(),function(b){var $=g.edge(b);$.nestingEdge&&g.removeEdge(b)})}function addSubgraphConstraints(g,d,b){var $={},j;forEach(b,function(_e){for(var et=g.parent(_e),tt,nt;et;){if(tt=g.parent(et),tt?(nt=$[tt],$[tt]=et):(nt=j,j=et),nt&&nt!==et){d.setEdge(nt,et);return}et=tt}})}function buildLayerGraph(g,d,b){var $=createRootNode(g),j=new Graph({compound:!0}).setGraph({root:$}).setDefaultNodeLabel(function(_e){return g.node(_e)});return forEach(g.nodes(),function(_e){var et=g.node(_e),tt=g.parent(_e);(et.rank===d||et.minRank<=d&&d<=et.maxRank)&&(j.setNode(_e),j.setParent(_e,tt||$),forEach(g[b](_e),function(nt){var rt=nt.v===_e?nt.w:nt.v,it=j.edge(rt,_e),st=isUndefined(it)?0:it.weight;j.setEdge(rt,_e,{weight:g.edge(nt).weight+st})}),has(et,"minRank")&&j.setNode(_e,{borderLeft:et.borderLeft[d],borderRight:et.borderRight[d]}))}),j}function createRootNode(g){for(var d;g.hasNode(d=uniqueId("_root")););return d}function crossCount(g,d){for(var b=0,$=1;$0;)it%2&&(st+=tt[it+1]),it=it-1>>1,tt[it]+=rt.weight;nt+=rt.weight*st})),nt}function initOrder(g){var d={},b=filter(g.nodes(),function(tt){return!g.children(tt).length}),$=max(map(b,function(tt){return g.node(tt).rank})),j=map(range$1($+1),function(){return[]});function _e(tt){if(!has(d,tt)){d[tt]=!0;var nt=g.node(tt);j[nt.rank].push(tt),forEach(g.successors(tt),_e)}}var et=sortBy$1(b,function(tt){return g.node(tt).rank});return forEach(et,_e),j}function barycenter(g,d){return map(d,function(b){var $=g.inEdges(b);if($.length){var j=reduce($,function(_e,et){var tt=g.edge(et),nt=g.node(et.v);return{sum:_e.sum+tt.weight*nt.order,weight:_e.weight+tt.weight}},{sum:0,weight:0});return{v:b,barycenter:j.sum/j.weight,weight:j.weight}}else return{v:b}})}function resolveConflicts(g,d){var b={};forEach(g,function(j,_e){var et=b[j.v]={indegree:0,in:[],out:[],vs:[j.v],i:_e};isUndefined(j.barycenter)||(et.barycenter=j.barycenter,et.weight=j.weight)}),forEach(d.edges(),function(j){var _e=b[j.v],et=b[j.w];!isUndefined(_e)&&!isUndefined(et)&&(et.indegree++,_e.out.push(b[j.w]))});var $=filter(b,function(j){return!j.indegree});return doResolveConflicts($)}function doResolveConflicts(g){var d=[];function b(_e){return function(et){et.merged||(isUndefined(et.barycenter)||isUndefined(_e.barycenter)||et.barycenter>=_e.barycenter)&&mergeEntries(_e,et)}}function $(_e){return function(et){et.in.push(_e),--et.indegree===0&&g.push(et)}}for(;g.length;){var j=g.pop();d.push(j),forEach(j.in.reverse(),b(j)),forEach(j.out,$(j))}return map(filter(d,function(_e){return!_e.merged}),function(_e){return pick$1(_e,["vs","i","barycenter","weight"])})}function mergeEntries(g,d){var b=0,$=0;g.weight&&(b+=g.barycenter*g.weight,$+=g.weight),d.weight&&(b+=d.barycenter*d.weight,$+=d.weight),g.vs=d.vs.concat(g.vs),g.barycenter=b/$,g.weight=$,g.i=Math.min(d.i,g.i),d.merged=!0}function sort(g,d){var b=partition(g,function(it){return has(it,"barycenter")}),$=b.lhs,j=sortBy$1(b.rhs,function(it){return-it.i}),_e=[],et=0,tt=0,nt=0;$.sort(compareWithBias(!!d)),nt=consumeUnsortable(_e,j,nt),forEach($,function(it){nt+=it.vs.length,_e.push(it.vs),et+=it.barycenter*it.weight,tt+=it.weight,nt=consumeUnsortable(_e,j,nt)});var rt={vs:flatten(_e)};return tt&&(rt.barycenter=et/tt,rt.weight=tt),rt}function consumeUnsortable(g,d,b){for(var $;d.length&&($=last$1(d)).i<=b;)d.pop(),g.push($.vs),b++;return b}function compareWithBias(g){return function(d,b){return d.barycenterb.barycenter?1:g?b.i-d.i:d.i-b.i}}function sortSubgraph(g,d,b,$){var j=g.children(d),_e=g.node(d),et=_e?_e.borderLeft:void 0,tt=_e?_e.borderRight:void 0,nt={};et&&(j=filter(j,function(ut){return ut!==et&&ut!==tt}));var rt=barycenter(g,j);forEach(rt,function(ut){if(g.children(ut.v).length){var ct=sortSubgraph(g,ut.v,b,$);nt[ut.v]=ct,has(ct,"barycenter")&&mergeBarycenters(ut,ct)}});var it=resolveConflicts(rt,b);expandSubgraphs(it,nt);var st=sort(it,$);if(et&&(st.vs=flatten([et,st.vs,tt]),g.predecessors(et).length)){var ot=g.node(g.predecessors(et)[0]),at=g.node(g.predecessors(tt)[0]);has(st,"barycenter")||(st.barycenter=0,st.weight=0),st.barycenter=(st.barycenter*st.weight+ot.order+at.order)/(st.weight+2),st.weight+=2}return st}function expandSubgraphs(g,d){forEach(g,function(b){b.vs=flatten(b.vs.map(function($){return d[$]?d[$].vs:$}))})}function mergeBarycenters(g,d){isUndefined(g.barycenter)?(g.barycenter=d.barycenter,g.weight=d.weight):(g.barycenter=(g.barycenter*g.weight+d.barycenter*d.weight)/(g.weight+d.weight),g.weight+=d.weight)}function order(g){var d=maxRank(g),b=buildLayerGraphs(g,range$1(1,d+1),"inEdges"),$=buildLayerGraphs(g,range$1(d-1,-1,-1),"outEdges"),j=initOrder(g);assignOrder(g,j);for(var _e=Number.POSITIVE_INFINITY,et,tt=0,nt=0;nt<4;++tt,++nt){sweepLayerGraphs(tt%2?b:$,tt%4>=2),j=buildLayerMatrix(g);var rt=crossCount(g,j);rt<_e&&(nt=0,et=cloneDeep(j),_e=rt)}assignOrder(g,et)}function buildLayerGraphs(g,d,b){return map(d,function($){return buildLayerGraph(g,$,b)})}function sweepLayerGraphs(g,d){var b=new Graph;forEach(g,function($){var j=$.graph().root,_e=sortSubgraph($,j,b,d);forEach(_e.vs,function(et,tt){$.node(et).order=tt}),addSubgraphConstraints($,b,_e.vs)})}function assignOrder(g,d){forEach(d,function(b){forEach(b,function($,j){g.node($).order=j})})}function parentDummyChains(g){var d=postorder(g);forEach(g.graph().dummyChains,function(b){for(var $=g.node(b),j=$.edgeObj,_e=findPath(g,d,j.v,j.w),et=_e.path,tt=_e.lca,nt=0,rt=et[nt],it=!0;b!==j.w;){if($=g.node(b),it){for(;(rt=et[nt])!==tt&&g.node(rt).maxRank<$.rank;)nt++;rt===tt&&(it=!1)}if(!it){for(;ntet||tt>d[nt].lim));for(rt=nt,nt=$;(nt=g.parent(nt))!==rt;)_e.push(nt);return{path:j.concat(_e.reverse()),lca:rt}}function postorder(g){var d={},b=0;function $(j){var _e=b;forEach(g.children(j),$),d[j]={low:_e,lim:b++}}return forEach(g.children(),$),d}function findType1Conflicts(g,d){var b={};function $(j,_e){var et=0,tt=0,nt=j.length,rt=last$1(_e);return forEach(_e,function(it,st){var ot=findOtherInnerSegmentNode(g,it),at=ot?g.node(ot).order:nt;(ot||it===rt)&&(forEach(_e.slice(tt,st+1),function(ut){forEach(g.predecessors(ut),function(ct){var dt=g.node(ct),ht=dt.order;(htrt)&&addConflict(b,ot,it)})})}function j(_e,et){var tt=-1,nt,rt=0;return forEach(et,function(it,st){if(g.node(it).dummy==="border"){var ot=g.predecessors(it);ot.length&&(nt=g.node(ot[0]).order,$(et,rt,st,tt,nt),rt=st,tt=nt)}$(et,rt,et.length,nt,_e.length)}),et}return reduce(d,j),b}function findOtherInnerSegmentNode(g,d){if(g.node(d).dummy)return find$1(g.predecessors(d),function(b){return g.node(b).dummy})}function addConflict(g,d,b){if(d>b){var $=d;d=b,b=$}var j=g[d];j||(g[d]=j={}),j[b]=!0}function hasConflict(g,d,b){if(d>b){var $=d;d=b,b=$}return has(g[d],b)}function verticalAlignment(g,d,b,$){var j={},_e={},et={};return forEach(d,function(tt){forEach(tt,function(nt,rt){j[nt]=nt,_e[nt]=nt,et[nt]=rt})}),forEach(d,function(tt){var nt=-1;forEach(tt,function(rt){var it=$(rt);if(it.length){it=sortBy$1(it,function(ct){return et[ct]});for(var st=(it.length-1)/2,ot=Math.floor(st),at=Math.ceil(st);ot<=at;++ot){var ut=it[ot];_e[rt]===rt&&nt0}function intersectPolygon(g,d,b){var $=g.x,j=g.y,_e=[],et=Number.POSITIVE_INFINITY,tt=Number.POSITIVE_INFINITY;d.forEach(function(ut){et=Math.min(et,ut.x),tt=Math.min(tt,ut.y)});for(var nt=$-g.width/2-et,rt=j-g.height/2-tt,it=0;it1&&_e.sort(function(ut,ct){var dt=ut.x-b.x,ht=ut.y-b.y,pt=Math.sqrt(dt*dt+ht*ht),gt=ct.x-b.x,yt=ct.y-b.y,vt=Math.sqrt(gt*gt+yt*yt);return ptMath.abs(j)*tt?(_e<0&&(tt=-tt),nt=_e===0?0:tt*j/_e,rt=tt):(j<0&&(et=-et),nt=et,rt=j===0?0:et*_e/j),{x:b+nt,y:$+rt}}var shapes={rect,ellipse,circle,diamond};function setShapes(g){shapes=g}function rect(g,d,b){var $=g.insert("rect",":first-child").attr("rx",b.rx).attr("ry",b.ry).attr("x",-d.width/2).attr("y",-d.height/2).attr("width",d.width).attr("height",d.height);return b.intersect=function(j){return intersectRect(b,j)},$}function ellipse(g,d,b){var $=d.width/2,j=d.height/2,_e=g.insert("ellipse",":first-child").attr("x",-d.width/2).attr("y",-d.height/2).attr("rx",$).attr("ry",j);return b.intersect=function(et){return intersectEllipse(b,$,j,et)},_e}function circle(g,d,b){var $=Math.max(d.width,d.height)/2,j=g.insert("circle",":first-child").attr("x",-d.width/2).attr("y",-d.height/2).attr("r",$);return b.intersect=function(_e){return intersectCircle(b,$,_e)},j}function diamond(g,d,b){var $=d.width*Math.SQRT2/2,j=d.height*Math.SQRT2/2,_e=[{x:0,y:-j},{x:-$,y:0},{x:0,y:j},{x:$,y:0}],et=g.insert("polygon",":first-child").attr("points",_e.map(function(tt){return tt.x+","+tt.y}).join(" "));return b.intersect=function(tt){return intersectPolygon(b,_e,tt)},et}function render(){var g=function(d,b){preProcessGraph(b);var $=createOrSelectGroup(d,"output"),j=createOrSelectGroup($,"clusters"),_e=createOrSelectGroup($,"edgePaths"),et=createEdgeLabels(createOrSelectGroup($,"edgeLabels"),b),tt=createNodes(createOrSelectGroup($,"nodes"),b,shapes);layout(b),positionNodes(tt,b),positionEdgeLabels(et,b),createEdgePaths(_e,b,arrows);var nt=createClusters(j,b);positionClusters(nt,b),postProcessGraph(b)};return g.createNodes=function(d){return arguments.length?(setCreateNodes(d),g):createNodes},g.createClusters=function(d){return arguments.length?(setCreateClusters(d),g):createClusters},g.createEdgeLabels=function(d){return arguments.length?(setCreateEdgeLabels(d),g):createEdgeLabels},g.createEdgePaths=function(d){return arguments.length?(setCreateEdgePaths(d),g):createEdgePaths},g.shapes=function(d){return arguments.length?(setShapes(d),g):shapes},g.arrows=function(d){return arguments.length?(setArrows(d),g):arrows},g}var NODE_DEFAULT_ATTRS={paddingLeft:10,paddingRight:10,paddingTop:10,paddingBottom:10,rx:0,ry:0,shape:"rect"},EDGE_DEFAULT_ATTRS={arrowhead:"normal",curve:curveLinear};function preProcessGraph(g){g.nodes().forEach(function(d){var b=g.node(d);!has(b,"label")&&!g.children(d).length&&(b.label=d),has(b,"paddingX")&&defaults$1(b,{paddingLeft:b.paddingX,paddingRight:b.paddingX}),has(b,"paddingY")&&defaults$1(b,{paddingTop:b.paddingY,paddingBottom:b.paddingY}),has(b,"padding")&&defaults$1(b,{paddingLeft:b.padding,paddingRight:b.padding,paddingTop:b.padding,paddingBottom:b.padding}),defaults$1(b,NODE_DEFAULT_ATTRS),forEach(["paddingLeft","paddingRight","paddingTop","paddingBottom"],function($){b[$]=Number(b[$])}),has(b,"width")&&(b._prevWidth=b.width),has(b,"height")&&(b._prevHeight=b.height)}),g.edges().forEach(function(d){var b=g.edge(d);has(b,"label")||(b.label=""),defaults$1(b,EDGE_DEFAULT_ATTRS)})}function postProcessGraph(g){forEach(g.nodes(),function(d){var b=g.node(d);has(b,"_prevWidth")?b.width=b._prevWidth:delete b.width,has(b,"_prevHeight")?b.height=b._prevHeight:delete b.height,delete b._prevWidth,delete b._prevHeight})}function createOrSelectGroup(g,d){var b=g.select("g."+d);return b.empty()&&(b=g.append("g").attr("class",d)),b}function Tree({semantics:g,setSvgElem:d}){console.log("rendering tree: ",g);const b=new Graph({directed:!0});b.setGraph({}),b.graph().rankdir=(g==null?void 0:g.rankdir)??"TB",b.graph().ranksep=15,b.graph().nodesep=20,b.setDefaultEdgeLabel(function(){return{}});const $=({node:nt,statusPercentage:rt})=>{const it='"trebuchet ms",verdana,arial,sans-serif',st=nt.intermediate?7:13,ot=nt.intermediate?`font: bold ${st}px ${it};`:`font: 300 ${st}px ${it};`,at=nt.intermediate?"ellipse":"rect",ut=at==="rect"?"stroke: black; stroke-width: 1px; rx: 5px; ry: 5px;":"stroke: black; stroke-width: 1px;",ct={label:wrapLines(nt.label,20).join(` +`),shape:at,style:`${ut} fill:#dff8ff;`,labelStyle:ot+"fill: black;"};nt.intermediate&&(ct.width=5,ct.height=5,ct.style=`${ut} fill:white;`),rt!==void 0&&(rt>=70&&(ct.style=`${ut} fill:#95f795;`),rt<70&&rt>30&&(ct.style=`${ut} fill:#fdfdbe;`),rt<=30&&(ct.style=`${ut} fill:#ffb2b2;`)),console.log("creating node ",nt.key),b.setNode(nt.key,ct)};if(React.useEffect(()=>{const rt=select("svg").select("g"),it=render(),st=select("#tree-svg-container");if(!(st!=null&&st.node())||!(rt!=null&&rt.node()))return;it(rt,b),rt.attr("transform",computeResizeTransform(rt.node(),st.node(),13,13)+", translate(13, 13)");const ot=10;rt.selectAll("g.node .annotation-circle").remove(),rt.selectAll("g.node .annotation-label").remove();const at=rt.selectAll("g.node").filter(function(ct){var dt;return(dt=g==null?void 0:g.nodes.get(ct))==null?void 0:dt.annotation});at.append("circle").attr("class","annotation-circle").attr("cx",function(){const ct=this.parentNode;console.log("elem",ct);const dt=ct.getElementsByTagName("rect")[0];return dt?-dt.width.baseVal.value/2:0}).attr("cy",function(){const ct=this.parentNode;console.log("elem",ct);const dt=ct.getElementsByTagName("rect")[0];return dt?-dt.height.baseVal.value/2:0}).attr("r",ot).style("fill","white").style("stroke","black").style("stroke-width","1px");const ut=ct=>ct&&ct.length<2?11:8;at.append("text").attr("class","annotation-label").style("font-size",function(){var ct;return ut((ct=g==null?void 0:g.nodes.get(this.parentNode.__data__))==null?void 0:ct.annotation)+"px"}).attr("x",function(){const ct=this.parentNode;console.log("elem",ct);const dt=ct.getElementsByTagName("rect")[0];return dt?-dt.width.baseVal.value/2:0}).attr("y",function(){const ct=this.parentNode;console.log("elem",ct);const dt=ct.getElementsByTagName("rect")[0];return dt?-dt.height.baseVal.value/2+1.5:0}).attr("r",ot).text(function(){var ct;return(ct=_e.get(this.parentNode.__data__))==null?void 0:ct.annotation}),d(document.getElementById("treeSvg"))},[g]),!g)return jsxRuntimeExports.jsx("div",{children:" No AST "});const j=({from:nt,to:rt})=>{var st,ot;const it=((st=g.nodes.get(nt))==null?void 0:st.intermediate)||((ot=g.nodes.get(rt))==null?void 0:ot.intermediate);b.setEdge(nt,rt,{curve:basis,style:"stroke: gray; fill:none; stroke-width: 1px;",minlen:it?1:2})},{nodes:_e,edges:et}=g;console.log("{nodes, edges}",{nodes:_e,edges:et});for(const[nt,rt]of _e)$({node:rt,statusPercentage:rt.statusPercentage});for(const nt of et)j({from:nt.from,to:nt.to});const tt=` + .annotation-label { + fill: black; + text-anchor: middle; + font-weight: bold; + alignment-baseline: middle; + } + `;return jsxRuntimeExports.jsx("div",{id:"tree-svg-container",style:{width:"100%",height:"500"},children:jsxRuntimeExports.jsxs("svg",{id:"treeSvg",width:"100%",height:"100%",version:"1.1",preserveAspectRatio:"xMinYMin",viewBox:"0 0 100 100",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntimeExports.jsx("style",{children:tt}),jsxRuntimeExports.jsx("g",{})]})})}var raf$1={exports:{}},performanceNow={exports:{}};(function(){var g,d,b,$,j,_e;typeof performance<"u"&&performance!==null&&performance.now?performanceNow.exports=function(){return performance.now()}:typeof process<"u"&&process!==null&&process.hrtime?(performanceNow.exports=function(){return(g()-j)/1e6},d=process.hrtime,g=function(){var et;return et=d(),et[0]*1e9+et[1]},$=g(),_e=process.uptime()*1e9,j=$-_e):Date.now?(performanceNow.exports=function(){return Date.now()-b},b=Date.now()):(performanceNow.exports=function(){return new Date().getTime()-b},b=new Date().getTime())}).call(commonjsGlobal);var performanceNowExports=performanceNow.exports,now=performanceNowExports,root=typeof window>"u"?commonjsGlobal:window,vendors=["moz","webkit"],suffix="AnimationFrame",raf=root["request"+suffix],caf=root["cancel"+suffix]||root["cancelRequest"+suffix];for(var i$1=0;!raf&&i$13&&(this.alpha=tt[3]),this.ok=!0}}this.r=this.r<0||isNaN(this.r)?0:this.r>255?255:this.r,this.g=this.g<0||isNaN(this.g)?0:this.g>255?255:this.g,this.b=this.b<0||isNaN(this.b)?0:this.b>255?255:this.b,this.alpha=this.alpha<0?0:this.alpha>1||isNaN(this.alpha)?1:this.alpha,this.toRGB=function(){return"rgb("+this.r+", "+this.g+", "+this.b+")"},this.toRGBA=function(){return"rgba("+this.r+", "+this.g+", "+this.b+", "+this.alpha+")"},this.toHex=function(){var nt=this.r.toString(16),rt=this.g.toString(16),it=this.b.toString(16);return nt.length==1&&(nt="0"+nt),rt.length==1&&(rt="0"+rt),it.length==1&&(it="0"+it),"#"+nt+rt+it},this.getHelpXML=function(){for(var nt=new Array,rt=0;rt "+ct.toRGB()+" -> "+ct.toHex());ut.appendChild(dt),ut.appendChild(ht),at.appendChild(ut)}catch{}return at}};const RGBColor$1=getDefaultExportFromCjs(rgbcolor);/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +***************************************************************************** */var t=function(g,d){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(b,$){b.__proto__=$}||function(b,$){for(var j in $)Object.prototype.hasOwnProperty.call($,j)&&(b[j]=$[j])})(g,d)};function r(g,d){if(typeof d!="function"&&d!==null)throw new TypeError("Class extends value "+String(d)+" is not a constructor or null");function b(){this.constructor=g}t(g,d),g.prototype=d===null?Object.create(d):(b.prototype=d.prototype,new b)}function e(g){var d="";Array.isArray(g)||(g=[g]);for(var b=0;bg.phi1&&(g.phi2-=2*n),g.sweepFlag===1&&g.phi2$)return[];if($===0)return[[g*b/(g*g+d*d),d*b/(g*g+d*d)]];var j=Math.sqrt($);return[[(g*b+d*j)/(g*g+d*d),(d*b-g*j)/(g*g+d*d)],[(g*b-d*j)/(g*g+d*d),(d*b+g*j)/(g*g+d*d)]]}var u,h=Math.PI/180;function c$1(g,d,b){return(1-b)*g+b*d}function y(g,d,b,$){return g+Math.cos($/180*n)*d+Math.sin($/180*n)*b}function p(g,d,b,$){var j=1e-6,_e=d-g,et=b-d,tt=3*_e+3*($-b)-6*et,nt=6*(et-_e),rt=3*_e;return Math.abs(tt)xt&&(at.sweepFlag=+!at.sweepFlag),at})}function et(){return function(tt){var nt={};for(var rt in tt)nt[rt]=tt[rt];return nt}}g.ROUND=function(tt){function nt(rt){return Math.round(rt*tt)/tt}return tt===void 0&&(tt=1e13),a(tt),function(rt){return rt.x1!==void 0&&(rt.x1=nt(rt.x1)),rt.y1!==void 0&&(rt.y1=nt(rt.y1)),rt.x2!==void 0&&(rt.x2=nt(rt.x2)),rt.y2!==void 0&&(rt.y2=nt(rt.y2)),rt.x!==void 0&&(rt.x=nt(rt.x)),rt.y!==void 0&&(rt.y=nt(rt.y)),rt.rX!==void 0&&(rt.rX=nt(rt.rX)),rt.rY!==void 0&&(rt.rY=nt(rt.rY)),rt}},g.TO_ABS=d,g.TO_REL=function(){return j(function(tt,nt,rt){return tt.relative||(tt.x1!==void 0&&(tt.x1-=nt),tt.y1!==void 0&&(tt.y1-=rt),tt.x2!==void 0&&(tt.x2-=nt),tt.y2!==void 0&&(tt.y2-=rt),tt.x!==void 0&&(tt.x-=nt),tt.y!==void 0&&(tt.y-=rt),tt.relative=!0),tt})},g.NORMALIZE_HVZ=function(tt,nt,rt){return tt===void 0&&(tt=!0),nt===void 0&&(nt=!0),rt===void 0&&(rt=!0),j(function(it,st,ot,at,ut){if(isNaN(at)&&!(it.type&_.MOVE_TO))throw new Error("path must start with moveto");return nt&&it.type&_.HORIZ_LINE_TO&&(it.type=_.LINE_TO,it.y=it.relative?0:ot),rt&&it.type&_.VERT_LINE_TO&&(it.type=_.LINE_TO,it.x=it.relative?0:st),tt&&it.type&_.CLOSE_PATH&&(it.type=_.LINE_TO,it.x=it.relative?at-st:at,it.y=it.relative?ut-ot:ut),it.type&_.ARC&&(it.rX===0||it.rY===0)&&(it.type=_.LINE_TO,delete it.rX,delete it.rY,delete it.xRot,delete it.lArcFlag,delete it.sweepFlag),it})},g.NORMALIZE_ST=b,g.QT_TO_C=$,g.INFO=j,g.SANITIZE=function(tt){tt===void 0&&(tt=0),a(tt);var nt=NaN,rt=NaN,it=NaN,st=NaN;return j(function(ot,at,ut,ct,dt){var ht=Math.abs,pt=!1,gt=0,yt=0;if(ot.type&_.SMOOTH_CURVE_TO&&(gt=isNaN(nt)?0:at-nt,yt=isNaN(rt)?0:ut-rt),ot.type&(_.CURVE_TO|_.SMOOTH_CURVE_TO)?(nt=ot.relative?at+ot.x2:ot.x2,rt=ot.relative?ut+ot.y2:ot.y2):(nt=NaN,rt=NaN),ot.type&_.SMOOTH_QUAD_TO?(it=isNaN(it)?at:2*at-it,st=isNaN(st)?ut:2*ut-st):ot.type&_.QUAD_TO?(it=ot.relative?at+ot.x1:ot.x1,st=ot.relative?ut+ot.y1:ot.y2):(it=NaN,st=NaN),ot.type&_.LINE_COMMANDS||ot.type&_.ARC&&(ot.rX===0||ot.rY===0||!ot.lArcFlag)||ot.type&_.CURVE_TO||ot.type&_.SMOOTH_CURVE_TO||ot.type&_.QUAD_TO||ot.type&_.SMOOTH_QUAD_TO){var vt=ot.x===void 0?0:ot.relative?ot.x:ot.x-at,St=ot.y===void 0?0:ot.relative?ot.y:ot.y-ut;gt=isNaN(it)?ot.x1===void 0?gt:ot.relative?ot.x:ot.x1-at:it-at,yt=isNaN(st)?ot.y1===void 0?yt:ot.relative?ot.y:ot.y1-ut:st-ut;var xt=ot.x2===void 0?0:ot.relative?ot.x:ot.x2-at,Dt=ot.y2===void 0?0:ot.relative?ot.y:ot.y2-ut;ht(vt)<=tt&&ht(St)<=tt&&ht(gt)<=tt&&ht(yt)<=tt&&ht(xt)<=tt&&ht(Dt)<=tt&&(pt=!0)}return ot.type&_.CLOSE_PATH&&ht(at-ct)<=tt&&ht(ut-dt)<=tt&&(pt=!0),pt?[]:ot})},g.MATRIX=_e,g.ROTATE=function(tt,nt,rt){nt===void 0&&(nt=0),rt===void 0&&(rt=0),a(tt,nt,rt);var it=Math.sin(tt),st=Math.cos(tt);return _e(st,it,-it,st,nt-nt*st+rt*it,rt-nt*it-rt*st)},g.TRANSLATE=function(tt,nt){return nt===void 0&&(nt=0),a(tt,nt),_e(1,0,0,1,tt,nt)},g.SCALE=function(tt,nt){return nt===void 0&&(nt=tt),a(tt,nt),_e(tt,0,0,nt,0,0)},g.SKEW_X=function(tt){return a(tt),_e(1,0,Math.atan(tt),1,0,0)},g.SKEW_Y=function(tt){return a(tt),_e(1,Math.atan(tt),0,1,0,0)},g.X_AXIS_SYMMETRY=function(tt){return tt===void 0&&(tt=0),a(tt),_e(-1,0,0,1,tt,0)},g.Y_AXIS_SYMMETRY=function(tt){return tt===void 0&&(tt=0),a(tt),_e(1,0,0,-1,0,tt)},g.A_TO_C=function(){return j(function(tt,nt,rt){return _.ARC===tt.type?function(it,st,ot){var at,ut,ct,dt;it.cX||o(it,st,ot);for(var ht=Math.min(it.phi1,it.phi2),pt=Math.max(it.phi1,it.phi2)-ht,gt=Math.ceil(pt/90),yt=new Array(gt),vt=st,St=ot,xt=0;xtst.maxX&&(st.maxX=It),Itst.maxY&&(st.maxY=It),ItLt&&dt(m$1(at,ct.x1,ct.x2,ct.x,Lt));for(var yt=0,vt=p(ut,ct.y1,ct.y2,ct.y);ytLt&&ht(m$1(ut,ct.y1,ct.y2,ct.y,Lt))}if(ct.type&_.ARC){dt(ct.x),ht(ct.y),o(ct,at,ut);for(var St=ct.xRot/180*Math.PI,xt=Math.cos(St)*ct.rX,Dt=Math.sin(St)*ct.rX,Pt=-Math.sin(St)*ct.rY,Ct=Math.cos(St)*ct.rY,wt=ct.phi1ct.phi2?[ct.phi2+360,ct.phi1+360]:[ct.phi2,ct.phi1],Tt=wt[0],Bt=wt[1],Ft=function(It){var Ut=It[0],Gt=It[1],tn=180*Math.atan2(Gt,Ut)/Math.PI;return tnTt&&LtTt&&Ltit)throw new SyntaxError('Expected positive number, got "'+it+'" at index "'+et+'"')}else if((this.curArgs.length===3||this.curArgs.length===4)&&this.curNumber!=="0"&&this.curNumber!=="1")throw new SyntaxError('Expected a flag, got "'+this.curNumber+'" at index "'+et+'"')}this.curArgs.push(it),this.curArgs.length===N[this.curCommandType]&&(_.HORIZ_LINE_TO===this.curCommandType?_e({type:_.HORIZ_LINE_TO,relative:this.curCommandRelative,x:it}):_.VERT_LINE_TO===this.curCommandType?_e({type:_.VERT_LINE_TO,relative:this.curCommandRelative,y:it}):this.curCommandType===_.MOVE_TO||this.curCommandType===_.LINE_TO||this.curCommandType===_.SMOOTH_QUAD_TO?(_e({type:this.curCommandType,relative:this.curCommandRelative,x:this.curArgs[0],y:this.curArgs[1]}),_.MOVE_TO===this.curCommandType&&(this.curCommandType=_.LINE_TO)):this.curCommandType===_.CURVE_TO?_e({type:_.CURVE_TO,relative:this.curCommandRelative,x1:this.curArgs[0],y1:this.curArgs[1],x2:this.curArgs[2],y2:this.curArgs[3],x:this.curArgs[4],y:this.curArgs[5]}):this.curCommandType===_.SMOOTH_CURVE_TO?_e({type:_.SMOOTH_CURVE_TO,relative:this.curCommandRelative,x2:this.curArgs[0],y2:this.curArgs[1],x:this.curArgs[2],y:this.curArgs[3]}):this.curCommandType===_.QUAD_TO?_e({type:_.QUAD_TO,relative:this.curCommandRelative,x1:this.curArgs[0],y1:this.curArgs[1],x:this.curArgs[2],y:this.curArgs[3]}):this.curCommandType===_.ARC&&_e({type:_.ARC,relative:this.curCommandRelative,rX:this.curArgs[0],rY:this.curArgs[1],xRot:this.curArgs[2],lArcFlag:this.curArgs[3],sweepFlag:this.curArgs[4],x:this.curArgs[5],y:this.curArgs[6]})),this.curNumber="",this.curNumberHasExpDigits=!1,this.curNumberHasExp=!1,this.curNumberHasDecimal=!1,this.canParseCommandOrComma=!0}if(!T(tt))if(tt===","&&this.canParseCommandOrComma)this.canParseCommandOrComma=!1;else if(tt!=="+"&&tt!=="-"&&tt!==".")if(rt)this.curNumber=tt,this.curNumberHasDecimal=!1;else{if(this.curArgs.length!==0)throw new SyntaxError("Unterminated command at index "+et+".");if(!this.canParseCommandOrComma)throw new SyntaxError('Unexpected character "'+tt+'" at index '+et+". Command cannot follow comma");if(this.canParseCommandOrComma=!1,tt!=="z"&&tt!=="Z")if(tt==="h"||tt==="H")this.curCommandType=_.HORIZ_LINE_TO,this.curCommandRelative=tt==="h";else if(tt==="v"||tt==="V")this.curCommandType=_.VERT_LINE_TO,this.curCommandRelative=tt==="v";else if(tt==="m"||tt==="M")this.curCommandType=_.MOVE_TO,this.curCommandRelative=tt==="m";else if(tt==="l"||tt==="L")this.curCommandType=_.LINE_TO,this.curCommandRelative=tt==="l";else if(tt==="c"||tt==="C")this.curCommandType=_.CURVE_TO,this.curCommandRelative=tt==="c";else if(tt==="s"||tt==="S")this.curCommandType=_.SMOOTH_CURVE_TO,this.curCommandRelative=tt==="s";else if(tt==="q"||tt==="Q")this.curCommandType=_.QUAD_TO,this.curCommandRelative=tt==="q";else if(tt==="t"||tt==="T")this.curCommandType=_.SMOOTH_QUAD_TO,this.curCommandRelative=tt==="t";else{if(tt!=="a"&&tt!=="A")throw new SyntaxError('Unexpected character "'+tt+'" at index '+et+".");this.curCommandType=_.ARC,this.curCommandRelative=tt==="a"}else $.push({type:_.CLOSE_PATH}),this.canParseCommandOrComma=!0,this.curCommandType=-1}else this.curNumber=tt,this.curNumberHasDecimal=tt==="."}else this.curNumber+=tt,this.curNumberHasDecimal=!0;else this.curNumber+=tt;else this.curNumber+=tt,this.curNumberHasExp=!0;else this.curNumber+=tt,this.curNumberHasExpDigits=this.curNumberHasExp}return $},d.prototype.transform=function(b){return Object.create(this,{parse:{value:function($,j){j===void 0&&(j=[]);for(var _e=0,et=Object.getPrototypeOf(this).parse.call(this,$);_e>vt;if(et[gt+3]=On,On!==0){var $n=255/On;et[gt]=(It*yt>>vt)*$n,et[gt+1]=(Ut*yt>>vt)*$n,et[gt+2]=(Gt*yt>>vt)*$n}else et[gt]=et[gt+1]=et[gt+2]=0;It-=Wt,Ut-=Ht,Gt-=Ot,tn-=Lt,Wt-=dt.r,Ht-=dt.g,Ot-=dt.b,Lt-=dt.a;var An=Rn+_e+1;An=pt+(An>vt,hn>0?(hn=255/hn,et[on]=(jt*yt>>vt)*hn,et[on+1]=(qt*yt>>vt)*hn,et[on+2]=(Xt*yt>>vt)*hn):et[on]=et[on+1]=et[on+2]=0,jt-=$t,qt-=_t,Xt-=Nt,Zt-=zt,$t-=dt.r,_t-=dt.g,Nt-=dt.b,zt-=dt.a,on=xn+((on=Tn+it)0&&arguments[0]!==void 0?arguments[0]:{};const d={window:null,ignoreAnimation:!0,ignoreMouse:!0,DOMParser:g,createCanvas(b,$){return new OffscreenCanvas(b,$)},async createImage(b){const j=await(await fetch(b)).blob();return await createImageBitmap(j)}};return(typeof globalThis.DOMParser<"u"||typeof g>"u")&&Reflect.deleteProperty(d,"DOMParser"),d}function node(g){let{DOMParser:d,canvas:b,fetch:$}=g;return{window:null,ignoreAnimation:!0,ignoreMouse:!0,DOMParser:d,fetch:$,createCanvas:b.createCanvas,createImage:b.loadImage}}var index=Object.freeze({__proto__:null,offscreen,node});function compressSpaces(g){return g.replace(/(?!\u3000)\s+/gm," ")}function trimLeft(g){return g.replace(/^[\n \t]+/,"")}function trimRight(g){return g.replace(/[\n \t]+$/,"")}function toNumbers(g){const d=g.match(/-?(\d+(?:\.\d*(?:[eE][+-]?\d+)?)?|\.\d+)(?=\D|$)/gm);return d?d.map(parseFloat):[]}function toMatrixValue(g){const d=toNumbers(g);return[d[0]||0,d[1]||0,d[2]||0,d[3]||0,d[4]||0,d[5]||0]}const allUppercase=/^[A-Z-]+$/;function normalizeAttributeName(g){return allUppercase.test(g)?g.toLowerCase():g}function parseExternalUrl(g){const d=/url\(('([^']+)'|"([^"]+)"|([^'")]+))\)/.exec(g);return d&&(d[2]||d[3]||d[4])||""}function normalizeColor(g){if(!g.startsWith("rgb"))return g;let d=3;return g.replace(/\d+(\.\d+)?/g,($,j)=>d--&&j?String(Math.round(parseFloat($))):$)}const attributeRegex=/(\[[^\]]+\])/g,idRegex=/(#[^\s+>~.[:]+)/g,classRegex=/(\.[^\s+>~.[:]+)/g,pseudoElementRegex=/(::[^\s+>~.[:]+|:first-line|:first-letter|:before|:after)/gi,pseudoClassWithBracketsRegex=/(:[\w-]+\([^)]*\))/gi,pseudoClassRegex=/(:[^\s+>~.[:]+)/g,elementRegex=/([^\s+>~.[:]+)/g;function findSelectorMatch(g,d){const b=d.exec(g);return b?[g.replace(d," "),b.length]:[g,0]}function getSelectorSpecificity(g){const d=[0,0,0];let b=g.replace(/:not\(([^)]*)\)/g," $1 ").replace(/{[\s\S]*/gm," "),$=0;return[b,$]=findSelectorMatch(b,attributeRegex),d[1]+=$,[b,$]=findSelectorMatch(b,idRegex),d[0]+=$,[b,$]=findSelectorMatch(b,classRegex),d[1]+=$,[b,$]=findSelectorMatch(b,pseudoElementRegex),d[2]+=$,[b,$]=findSelectorMatch(b,pseudoClassWithBracketsRegex),d[1]+=$,[b,$]=findSelectorMatch(b,pseudoClassRegex),d[1]+=$,b=b.replace(/[*\s+>~]/g," ").replace(/[#.]/g," "),[b,$]=findSelectorMatch(b,elementRegex),d[2]+=$,d.join("")}const PSEUDO_ZERO=1e-8;function vectorMagnitude(g){return Math.sqrt(Math.pow(g[0],2)+Math.pow(g[1],2))}function vectorsRatio(g,d){return(g[0]*d[0]+g[1]*d[1])/(vectorMagnitude(g)*vectorMagnitude(d))}function vectorsAngle(g,d){return(g[0]*d[1]0&&arguments[0]!==void 0?arguments[0]:" ";const{document:b,name:$}=this;return compressSpaces(this.getString()).trim().split(d).map(j=>new Property(b,$,j))}hasValue(d){const b=this.value;return b!==null&&b!==""&&(d||b!==0)&&typeof b<"u"}isString(d){const{value:b}=this,$=typeof b=="string";return!$||!d?$:d.test(b)}isUrlDefinition(){return this.isString(/^url\(/)}isPixels(){if(!this.hasValue())return!1;const d=this.getString();switch(!0){case d.endsWith("px"):case/^[0-9]+$/.test(d):return!0;default:return!1}}setValue(d){return this.value=d,this}getValue(d){return typeof d>"u"||this.hasValue()?this.value:d}getNumber(d){if(!this.hasValue())return typeof d>"u"?0:parseFloat(d);const{value:b}=this;let $=parseFloat(b);return this.isString(/%$/)&&($/=100),$}getString(d){return typeof d>"u"||this.hasValue()?typeof this.value>"u"?"":String(this.value):String(d)}getColor(d){let b=this.getString(d);return this.isNormalizedColor||(this.isNormalizedColor=!0,b=normalizeColor(b),this.value=b),b}getDpi(){return 96}getRem(){return this.document.rootEmSize}getEm(){return this.document.emSize}getUnits(){return this.getString().replace(/[0-9.-]/g,"")}getPixels(d){let b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(!this.hasValue())return 0;const[$,j]=typeof d=="boolean"?[void 0,d]:[d],{viewPort:_e}=this.document.screen;switch(!0){case this.isString(/vmin$/):return this.getNumber()/100*Math.min(_e.computeSize("x"),_e.computeSize("y"));case this.isString(/vmax$/):return this.getNumber()/100*Math.max(_e.computeSize("x"),_e.computeSize("y"));case this.isString(/vw$/):return this.getNumber()/100*_e.computeSize("x");case this.isString(/vh$/):return this.getNumber()/100*_e.computeSize("y");case this.isString(/rem$/):return this.getNumber()*this.getRem();case this.isString(/em$/):return this.getNumber()*this.getEm();case this.isString(/ex$/):return this.getNumber()*this.getEm()/2;case this.isString(/px$/):return this.getNumber();case this.isString(/pt$/):return this.getNumber()*this.getDpi()*(1/72);case this.isString(/pc$/):return this.getNumber()*15;case this.isString(/cm$/):return this.getNumber()*this.getDpi()/2.54;case this.isString(/mm$/):return this.getNumber()*this.getDpi()/25.4;case this.isString(/in$/):return this.getNumber()*this.getDpi();case(this.isString(/%$/)&&j):return this.getNumber()*this.getEm();case this.isString(/%$/):return this.getNumber()*_e.computeSize($);default:{const et=this.getNumber();return b&&et<1?et*_e.computeSize($):et}}}getMilliseconds(){return this.hasValue()?this.isString(/ms$/)?this.getNumber():this.getNumber()*1e3:0}getRadians(){if(!this.hasValue())return 0;switch(!0){case this.isString(/deg$/):return this.getNumber()*(Math.PI/180);case this.isString(/grad$/):return this.getNumber()*(Math.PI/200);case this.isString(/rad$/):return this.getNumber();default:return this.getNumber()*(Math.PI/180)}}getDefinition(){const d=this.getString(),b=/#([^)'"]+)/.exec(d),$=(b==null?void 0:b[1])||d;return this.document.definitions[$]}getFillStyleDefinition(d,b){let $=this.getDefinition();if(!$)return null;if(typeof $.createGradient=="function"&&"getBoundingBox"in d)return $.createGradient(this.document.ctx,d,b);if(typeof $.createPattern=="function"){if($.getHrefAttribute().hasValue()){const j=$.getAttribute("patternTransform");$=$.getHrefAttribute().getDefinition(),$&&j.hasValue()&&$.getAttribute("patternTransform",!0).setValue(j.value)}if($)return $.createPattern(this.document.ctx,d,b)}return null}getTextBaseline(){if(!this.hasValue())return null;const d=this.getString();return Property.textBaselineMapping[d]||null}addOpacity(d){let b=this.getColor();const $=b.length;let j=0;for(let _e=0;_e<$&&(b[_e]===","&&j++,j!==3);_e++);if(d.hasValue()&&this.isString()&&j!==3){const _e=new RGBColor$1(b);_e.ok&&(_e.alpha=d.getNumber(),b=_e.toRGBA())}return new Property(this.document,this.name,b)}constructor(d,b,$){this.document=d,this.name=b,this.value=$,this.isNormalizedColor=!1}}Property.textBaselineMapping={baseline:"alphabetic","before-edge":"top","text-before-edge":"top",middle:"middle",central:"middle","after-edge":"bottom","text-after-edge":"bottom",ideographic:"ideographic",alphabetic:"alphabetic",hanging:"hanging",mathematical:"alphabetic"};class ViewPort{clear(){this.viewPorts=[]}setCurrent(d,b){this.viewPorts.push({width:d,height:b})}removeCurrent(){this.viewPorts.pop()}getRoot(){const[d]=this.viewPorts;return d||getDefault()}getCurrent(){const{viewPorts:d}=this,b=d[d.length-1];return b||getDefault()}get width(){return this.getCurrent().width}get height(){return this.getCurrent().height}computeSize(d){return typeof d=="number"?d:d==="x"?this.width:d==="y"?this.height:Math.sqrt(Math.pow(this.width,2)+Math.pow(this.height,2))/Math.sqrt(2)}constructor(){this.viewPorts=[]}}ViewPort.DEFAULT_VIEWPORT_WIDTH=800;ViewPort.DEFAULT_VIEWPORT_HEIGHT=600;function getDefault(){return{width:ViewPort.DEFAULT_VIEWPORT_WIDTH,height:ViewPort.DEFAULT_VIEWPORT_HEIGHT}}class Point{static parse(d){let b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;const[$=b,j=b]=toNumbers(d);return new Point($,j)}static parseScale(d){let b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1;const[$=b,j=$]=toNumbers(d);return new Point($,j)}static parsePath(d){const b=toNumbers(d),$=b.length,j=[];for(let _e=0;_e<$;_e+=2)j.push(new Point(b[_e],b[_e+1]));return j}angleTo(d){return Math.atan2(d.y-this.y,d.x-this.x)}applyTransform(d){const{x:b,y:$}=this,j=b*d[0]+$*d[2]+d[4],_e=b*d[1]+$*d[3]+d[5];this.x=j,this.y=_e}constructor(d,b){this.x=d,this.y=b}}class Mouse{isWorking(){return this.working}start(){if(this.working)return;const{screen:d,onClick:b,onMouseMove:$}=this,j=d.ctx.canvas;j.onclick=b,j.onmousemove=$,this.working=!0}stop(){if(!this.working)return;const d=this.screen.ctx.canvas;this.working=!1,d.onclick=null,d.onmousemove=null}hasEvents(){return this.working&&this.events.length>0}runEvents(){if(!this.working)return;const{screen:d,events:b,eventElements:$}=this,{style:j}=d.ctx.canvas;let _e;j&&(j.cursor=""),b.forEach((et,tt)=>{let{run:nt}=et;for(_e=$[tt];_e;)nt(_e),_e=_e.parent}),this.events=[],this.eventElements=[]}checkPath(d,b){if(!this.working||!b)return;const{events:$,eventElements:j}=this;$.forEach((_e,et)=>{let{x:tt,y:nt}=_e;!j[et]&&b.isPointInPath&&b.isPointInPath(tt,nt)&&(j[et]=d)})}checkBoundingBox(d,b){if(!this.working||!b)return;const{events:$,eventElements:j}=this;$.forEach((_e,et)=>{let{x:tt,y:nt}=_e;!j[et]&&b.isPointInBox(tt,nt)&&(j[et]=d)})}mapXY(d,b){const{window:$,ctx:j}=this.screen,_e=new Point(d,b);let et=j.canvas;for(;et;)_e.x-=et.offsetLeft,_e.y-=et.offsetTop,et=et.offsetParent;return $!=null&&$.scrollX&&(_e.x+=$.scrollX),$!=null&&$.scrollY&&(_e.y+=$.scrollY),_e}onClick(d){const{x:b,y:$}=this.mapXY(d.clientX,d.clientY);this.events.push({type:"onclick",x:b,y:$,run(j){j.onClick&&j.onClick()}})}onMouseMove(d){const{x:b,y:$}=this.mapXY(d.clientX,d.clientY);this.events.push({type:"onmousemove",x:b,y:$,run(j){j.onMouseMove&&j.onMouseMove()}})}constructor(d){this.screen=d,this.working=!1,this.events=[],this.eventElements=[],this.onClick=this.onClick.bind(this),this.onMouseMove=this.onMouseMove.bind(this)}}const defaultWindow=typeof window<"u"?window:null,defaultFetch$1=typeof fetch<"u"?fetch.bind(void 0):void 0;class Screen{wait(d){this.waits.push(d)}ready(){return this.readyPromise?this.readyPromise:Promise.resolve()}isReady(){if(this.isReadyLock)return!0;const d=this.waits.every(b=>b());return d&&(this.waits=[],this.resolveReady&&this.resolveReady()),this.isReadyLock=d,d}setDefaults(d){d.strokeStyle="rgba(0,0,0,0)",d.lineCap="butt",d.lineJoin="miter",d.miterLimit=4}setViewBox(d){let{document:b,ctx:$,aspectRatio:j,width:_e,desiredWidth:et,height:tt,desiredHeight:nt,minX:rt=0,minY:it=0,refX:st,refY:ot,clip:at=!1,clipX:ut=0,clipY:ct=0}=d;const dt=compressSpaces(j).replace(/^defer\s/,""),[ht,pt]=dt.split(" "),gt=ht||"xMidYMid",yt=pt||"meet",vt=_e/et,St=tt/nt,xt=Math.min(vt,St),Dt=Math.max(vt,St);let Pt=et,Ct=nt;yt==="meet"&&(Pt*=xt,Ct*=xt),yt==="slice"&&(Pt*=Dt,Ct*=Dt);const wt=new Property(b,"refX",st),Tt=new Property(b,"refY",ot),Bt=wt.hasValue()&&Tt.hasValue();if(Bt&&$.translate(-xt*wt.getPixels("x"),-xt*Tt.getPixels("y")),at){const Ft=xt*ut,Vt=xt*ct;$.beginPath(),$.moveTo(Ft,Vt),$.lineTo(_e,Vt),$.lineTo(_e,tt),$.lineTo(Ft,tt),$.closePath(),$.clip()}if(!Bt){const Ft=yt==="meet"&&xt===St,Vt=yt==="slice"&&Dt===St,Wt=yt==="meet"&&xt===vt,Ht=yt==="slice"&&Dt===vt;gt.startsWith("xMid")&&(Ft||Vt)&&$.translate(_e/2-Pt/2,0),gt.endsWith("YMid")&&(Wt||Ht)&&$.translate(0,tt/2-Ct/2),gt.startsWith("xMax")&&(Ft||Vt)&&$.translate(_e-Pt,0),gt.endsWith("YMax")&&(Wt||Ht)&&$.translate(0,tt-Ct)}switch(!0){case gt==="none":$.scale(vt,St);break;case yt==="meet":$.scale(xt,xt);break;case yt==="slice":$.scale(Dt,Dt);break}$.translate(-rt,-it)}start(d){let{enableRedraw:b=!1,ignoreMouse:$=!1,ignoreAnimation:j=!1,ignoreDimensions:_e=!1,ignoreClear:et=!1,forceRedraw:tt,scaleWidth:nt,scaleHeight:rt,offsetX:it,offsetY:st}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const{mouse:ot}=this,at=1e3/Screen.FRAMERATE;if(this.isReadyLock=!1,this.frameDuration=at,this.readyPromise=new Promise(pt=>{this.resolveReady=pt}),this.isReady()&&this.render(d,_e,et,nt,rt,it,st),!b)return;let ut=Date.now(),ct=ut,dt=0;const ht=()=>{ut=Date.now(),dt=ut-ct,dt>=at&&(ct=ut-dt%at,this.shouldUpdate(j,tt)&&(this.render(d,_e,et,nt,rt,it,st),ot.runEvents())),this.intervalId=requestAnimationFrame(ht)};$||ot.start(),this.intervalId=requestAnimationFrame(ht)}stop(){this.intervalId&&(requestAnimationFrame.cancel(this.intervalId),this.intervalId=null),this.mouse.stop()}shouldUpdate(d,b){if(!d){const{frameDuration:$}=this;if(this.animations.reduce((_e,et)=>et.update($)||_e,!1))return!0}return!!(typeof b=="function"&&b()||!this.isReadyLock&&this.isReady()||this.mouse.hasEvents())}render(d,b,$,j,_e,et,tt){const{viewPort:nt,ctx:rt,isFirstRender:it}=this,st=rt.canvas;nt.clear(),st.width&&st.height&&nt.setCurrent(st.width,st.height);const ot=d.getStyle("width"),at=d.getStyle("height");!b&&(it||typeof j!="number"&&typeof _e!="number")&&(ot.hasValue()&&(st.width=ot.getPixels("x"),st.style&&(st.style.width="".concat(st.width,"px"))),at.hasValue()&&(st.height=at.getPixels("y"),st.style&&(st.style.height="".concat(st.height,"px"))));let ut=st.clientWidth||st.width,ct=st.clientHeight||st.height;if(b&&ot.hasValue()&&at.hasValue()&&(ut=ot.getPixels("x"),ct=at.getPixels("y")),nt.setCurrent(ut,ct),typeof et=="number"&&d.getAttribute("x",!0).setValue(et),typeof tt=="number"&&d.getAttribute("y",!0).setValue(tt),typeof j=="number"||typeof _e=="number"){const dt=toNumbers(d.getAttribute("viewBox").getString());let ht=0,pt=0;if(typeof j=="number"){const yt=d.getStyle("width");yt.hasValue()?ht=yt.getPixels("x")/j:dt[2]&&!isNaN(dt[2])&&(ht=dt[2]/j)}if(typeof _e=="number"){const yt=d.getStyle("height");yt.hasValue()?pt=yt.getPixels("y")/_e:dt[3]&&!isNaN(dt[3])&&(pt=dt[3]/_e)}ht||(ht=pt),pt||(pt=ht),d.getAttribute("width",!0).setValue(j),d.getAttribute("height",!0).setValue(_e);const gt=d.getStyle("transform",!0,!0);gt.setValue("".concat(gt.getString()," scale(").concat(1/ht,", ").concat(1/pt,")"))}$||rt.clearRect(0,0,ut,ct),d.render(rt),it&&(this.isFirstRender=!1)}constructor(d,{fetch:b=defaultFetch$1,window:$=defaultWindow}={}){if(this.ctx=d,this.viewPort=new ViewPort,this.mouse=new Mouse(this),this.animations=[],this.waits=[],this.frameDuration=0,this.isReadyLock=!1,this.isFirstRender=!0,this.intervalId=null,this.window=$,!b)throw new Error("Can't find 'fetch' in 'globalThis', please provide it via options");this.fetch=b}}Screen.defaultWindow=defaultWindow;Screen.defaultFetch=defaultFetch$1;Screen.FRAMERATE=30;Screen.MAX_VIRTUAL_PIXELS=3e4;const{defaultFetch}=Screen,DefaultDOMParser=typeof DOMParser<"u"?DOMParser:void 0;class Parser{async parse(d){return d.startsWith("<")?this.parseFromString(d):this.load(d)}parseFromString(d){const b=new this.DOMParser;try{return this.checkDocument(b.parseFromString(d,"image/svg+xml"))}catch{return this.checkDocument(b.parseFromString(d,"text/xml"))}}checkDocument(d){const b=d.getElementsByTagName("parsererror")[0];if(b)throw new Error(b.textContent||"Unknown parse error");return d}async load(d){const $=await(await this.fetch(d)).text();return this.parseFromString($)}constructor({fetch:d=defaultFetch,DOMParser:b=DefaultDOMParser}={}){if(!d)throw new Error("Can't find 'fetch' in 'globalThis', please provide it via options");if(!b)throw new Error("Can't find 'DOMParser' in 'globalThis', please provide it via options");this.fetch=d,this.DOMParser=b}}class Translate{apply(d){const{x:b,y:$}=this.point;d.translate(b||0,$||0)}unapply(d){const{x:b,y:$}=this.point;d.translate(-1*b||0,-1*$||0)}applyToPoint(d){const{x:b,y:$}=this.point;d.applyTransform([1,0,0,1,b||0,$||0])}constructor(d,b){this.type="translate",this.point=Point.parse(b)}}class Rotate{apply(d){const{cx:b,cy:$,originX:j,originY:_e,angle:et}=this,tt=b+j.getPixels("x"),nt=$+_e.getPixels("y");d.translate(tt,nt),d.rotate(et.getRadians()),d.translate(-tt,-nt)}unapply(d){const{cx:b,cy:$,originX:j,originY:_e,angle:et}=this,tt=b+j.getPixels("x"),nt=$+_e.getPixels("y");d.translate(tt,nt),d.rotate(-1*et.getRadians()),d.translate(-tt,-nt)}applyToPoint(d){const{cx:b,cy:$,angle:j}=this,_e=j.getRadians();d.applyTransform([1,0,0,1,b||0,$||0]),d.applyTransform([Math.cos(_e),Math.sin(_e),-Math.sin(_e),Math.cos(_e),0,0]),d.applyTransform([1,0,0,1,-b||0,-$||0])}constructor(d,b,$){this.type="rotate";const j=toNumbers(b);this.angle=new Property(d,"angle",j[0]),this.originX=$[0],this.originY=$[1],this.cx=j[1]||0,this.cy=j[2]||0}}class Scale{apply(d){const{scale:{x:b,y:$},originX:j,originY:_e}=this,et=j.getPixels("x"),tt=_e.getPixels("y");d.translate(et,tt),d.scale(b,$||b),d.translate(-et,-tt)}unapply(d){const{scale:{x:b,y:$},originX:j,originY:_e}=this,et=j.getPixels("x"),tt=_e.getPixels("y");d.translate(et,tt),d.scale(1/b,1/$||b),d.translate(-et,-tt)}applyToPoint(d){const{x:b,y:$}=this.scale;d.applyTransform([b||0,0,0,$||0,0,0])}constructor(d,b,$){this.type="scale";const j=Point.parseScale(b);(j.x===0||j.y===0)&&(j.x=PSEUDO_ZERO,j.y=PSEUDO_ZERO),this.scale=j,this.originX=$[0],this.originY=$[1]}}class Matrix{apply(d){const{originX:b,originY:$,matrix:j}=this,_e=b.getPixels("x"),et=$.getPixels("y");d.translate(_e,et),d.transform(j[0],j[1],j[2],j[3],j[4],j[5]),d.translate(-_e,-et)}unapply(d){const{originX:b,originY:$,matrix:j}=this,_e=j[0],et=j[2],tt=j[4],nt=j[1],rt=j[3],it=j[5],st=0,ot=0,at=1,ut=1/(_e*(rt*at-it*ot)-et*(nt*at-it*st)+tt*(nt*ot-rt*st)),ct=b.getPixels("x"),dt=$.getPixels("y");d.translate(ct,dt),d.transform(ut*(rt*at-it*ot),ut*(it*st-nt*at),ut*(tt*ot-et*at),ut*(_e*at-tt*st),ut*(et*it-tt*rt),ut*(tt*nt-_e*it)),d.translate(-ct,-dt)}applyToPoint(d){d.applyTransform(this.matrix)}constructor(d,b,$){this.type="matrix",this.matrix=toMatrixValue(b),this.originX=$[0],this.originY=$[1]}}class Skew extends Matrix{constructor(d,b,$){super(d,b,$),this.type="skew",this.angle=new Property(d,"angle",b)}}class SkewX extends Skew{constructor(d,b,$){super(d,b,$),this.type="skewX",this.matrix=[1,0,Math.tan(this.angle.getRadians()),1,0,0]}}class SkewY extends Skew{constructor(d,b,$){super(d,b,$),this.type="skewY",this.matrix=[1,Math.tan(this.angle.getRadians()),0,1,0,0]}}function parseTransforms(g){return compressSpaces(g).trim().replace(/\)([a-zA-Z])/g,") $1").replace(/\)(\s?,\s?)/g,") ").split(/\s(?=[a-z])/)}function parseTransform(g){const[d="",b=""]=g.split("(");return[d.trim(),b.trim().replace(")","")]}class Transform{static fromElement(d,b){const $=b.getStyle("transform",!1,!0);if($.hasValue()){const[j,_e=j]=b.getStyle("transform-origin",!1,!0).split();if(j&&_e){const et=[j,_e];return new Transform(d,$.getString(),et)}}return null}apply(d){this.transforms.forEach(b=>b.apply(d))}unapply(d){this.transforms.forEach(b=>b.unapply(d))}applyToPoint(d){this.transforms.forEach(b=>b.applyToPoint(d))}constructor(d,b,$){this.document=d,this.transforms=[],parseTransforms(b).forEach(_e=>{if(_e==="none")return;const[et,tt]=parseTransform(_e),nt=Transform.transformTypes[et];nt&&this.transforms.push(new nt(this.document,tt,$))})}}Transform.transformTypes={translate:Translate,rotate:Rotate,scale:Scale,matrix:Matrix,skewX:SkewX,skewY:SkewY};class Element{getAttribute(d){let b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;const $=this.attributes[d];if(!$&&b){const j=new Property(this.document,d,"");return this.attributes[d]=j,j}return $||Property.empty(this.document)}getHrefAttribute(){let d;for(const b in this.attributes)if(b==="href"||b.endsWith(":href")){d=this.attributes[b];break}return d||Property.empty(this.document)}getStyle(d){let b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,$=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;const j=this.styles[d];if(j)return j;const _e=this.getAttribute(d);if(_e.hasValue())return this.styles[d]=_e,_e;if(!$){const{parent:et}=this;if(et){const tt=et.getStyle(d);if(tt.hasValue())return tt}}if(b){const et=new Property(this.document,d,"");return this.styles[d]=et,et}return Property.empty(this.document)}render(d){if(!(this.getStyle("display").getString()==="none"||this.getStyle("visibility").getString()==="hidden")){if(d.save(),this.getStyle("mask").hasValue()){const b=this.getStyle("mask").getDefinition();b&&(this.applyEffects(d),b.apply(d,this))}else if(this.getStyle("filter").getValue("none")!=="none"){const b=this.getStyle("filter").getDefinition();b&&(this.applyEffects(d),b.apply(d,this))}else this.setContext(d),this.renderChildren(d),this.clearContext(d);d.restore()}}setContext(d){}applyEffects(d){const b=Transform.fromElement(this.document,this);b&&b.apply(d);const $=this.getStyle("clip-path",!1,!0);if($.hasValue()){const j=$.getDefinition();j&&j.apply(d)}}clearContext(d){}renderChildren(d){this.children.forEach(b=>{b.render(d)})}addChild(d){const b=d instanceof Element?d:this.document.createElement(d);b.parent=this,Element.ignoreChildTypes.includes(b.type)||this.children.push(b)}matchesSelector(d){var b;const{node:$}=this;if(typeof $.matches=="function")return $.matches(d);const j=(b=$.getAttribute)===null||b===void 0?void 0:b.call($,"class");return!j||j===""?!1:j.split(" ").some(_e=>".".concat(_e)===d)}addStylesFromStyleDefinition(){const{styles:d,stylesSpecificity:b}=this.document;let $;for(const j in d)if(!j.startsWith("@")&&this.matchesSelector(j)){const _e=d[j],et=b[j];if(_e)for(const tt in _e){let nt=this.stylesSpecificity[tt];typeof nt>"u"&&(nt="000"),et&&et>=nt&&($=_e[tt],$&&(this.styles[tt]=$),this.stylesSpecificity[tt]=et)}}}removeStyles(d,b){return b.reduce((j,_e)=>{const et=d.getStyle(_e);if(!et.hasValue())return j;const tt=et.getString();return et.setValue(""),[...j,[_e,tt]]},[])}restoreStyles(d,b){b.forEach($=>{let[j,_e]=$;d.getStyle(j,!0).setValue(_e)})}isFirstChild(){var d;return((d=this.parent)===null||d===void 0?void 0:d.children.indexOf(this))===0}constructor(d,b,$=!1){if(this.document=d,this.node=b,this.captureTextNodes=$,this.type="",this.attributes={},this.styles={},this.stylesSpecificity={},this.animationFrozen=!1,this.animationFrozenValue="",this.parent=null,this.children=[],!b||b.nodeType!==1)return;Array.from(b.attributes).forEach(et=>{const tt=normalizeAttributeName(et.nodeName);this.attributes[tt]=new Property(d,tt,et.value)}),this.addStylesFromStyleDefinition(),this.getAttribute("style").hasValue()&&this.getAttribute("style").getString().split(";").map(tt=>tt.trim()).forEach(tt=>{if(!tt)return;const[nt,rt]=tt.split(":").map(it=>it.trim());nt&&(this.styles[nt]=new Property(d,nt,rt))});const{definitions:j}=d,_e=this.getAttribute("id");_e.hasValue()&&(j[_e.getString()]||(j[_e.getString()]=this)),Array.from(b.childNodes).forEach(et=>{if(et.nodeType===1)this.addChild(et);else if($&&(et.nodeType===3||et.nodeType===4)){const tt=d.createTextNode(et);tt.getText().length>0&&this.addChild(tt)}})}}Element.ignoreChildTypes=["title"];class UnknownElement extends Element{constructor(d,b,$){super(d,b,$)}}function wrapFontFamily(g){const d=g.trim();return/^('|")/.test(d)?d:'"'.concat(d,'"')}function prepareFontFamily(g){return typeof process>"u"?g:g.trim().split(",").map(wrapFontFamily).join(",")}function prepareFontStyle(g){if(!g)return"";const d=g.trim().toLowerCase();switch(d){case"normal":case"italic":case"oblique":case"inherit":case"initial":case"unset":return d;default:return/^oblique\s+(-|)\d+deg$/.test(d)?d:""}}function prepareFontWeight(g){if(!g)return"";const d=g.trim().toLowerCase();switch(d){case"normal":case"bold":case"lighter":case"bolder":case"inherit":case"initial":case"unset":return d;default:return/^[\d.]+$/.test(d)?d:""}}class Font{static parse(){let d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",b=arguments.length>1?arguments[1]:void 0,$="",j="",_e="",et="",tt="";const nt=compressSpaces(d).trim().split(" "),rt={fontSize:!1,fontStyle:!1,fontWeight:!1,fontVariant:!1};return nt.forEach(it=>{switch(!0){case(!rt.fontStyle&&Font.styles.includes(it)):it!=="inherit"&&($=it),rt.fontStyle=!0;break;case(!rt.fontVariant&&Font.variants.includes(it)):it!=="inherit"&&(j=it),rt.fontStyle=!0,rt.fontVariant=!0;break;case(!rt.fontWeight&&Font.weights.includes(it)):it!=="inherit"&&(_e=it),rt.fontStyle=!0,rt.fontVariant=!0,rt.fontWeight=!0;break;case!rt.fontSize:it!=="inherit"&&(et=it.split("/")[0]||""),rt.fontStyle=!0,rt.fontVariant=!0,rt.fontWeight=!0,rt.fontSize=!0;break;default:it!=="inherit"&&(tt+=it)}}),new Font($,j,_e,et,tt,b)}toString(){return[prepareFontStyle(this.fontStyle),this.fontVariant,prepareFontWeight(this.fontWeight),this.fontSize,prepareFontFamily(this.fontFamily)].join(" ").trim()}constructor(d,b,$,j,_e,et){const tt=et?typeof et=="string"?Font.parse(et):et:{};this.fontFamily=_e||tt.fontFamily,this.fontSize=j||tt.fontSize,this.fontStyle=d||tt.fontStyle,this.fontWeight=$||tt.fontWeight,this.fontVariant=b||tt.fontVariant}}Font.styles="normal|italic|oblique|inherit";Font.variants="normal|small-caps|inherit";Font.weights="normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900|inherit";class BoundingBox{get x(){return this.x1}get y(){return this.y1}get width(){return this.x2-this.x1}get height(){return this.y2-this.y1}addPoint(d,b){typeof d<"u"&&((isNaN(this.x1)||isNaN(this.x2))&&(this.x1=d,this.x2=d),dthis.x2&&(this.x2=d)),typeof b<"u"&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=b,this.y2=b),bthis.y2&&(this.y2=b))}addX(d){this.addPoint(d,0)}addY(d){this.addPoint(0,d)}addBoundingBox(d){if(!d)return;const{x1:b,y1:$,x2:j,y2:_e}=d;this.addPoint(b,$),this.addPoint(j,_e)}sumCubic(d,b,$,j,_e){return Math.pow(1-d,3)*b+3*Math.pow(1-d,2)*d*$+3*(1-d)*Math.pow(d,2)*j+Math.pow(d,3)*_e}bezierCurveAdd(d,b,$,j,_e){const et=6*b-12*$+6*j,tt=-3*b+9*$-9*j+3*_e,nt=3*$-3*b;if(tt===0){if(et===0)return;const ot=-nt/et;01&&arguments[1]!==void 0?arguments[1]:!1;if(!b){const $=this.getStyle("fill"),j=this.getStyle("fill-opacity"),_e=this.getStyle("stroke"),et=this.getStyle("stroke-opacity");if($.isUrlDefinition()){const at=$.getFillStyleDefinition(this,j);at&&(d.fillStyle=at)}else if($.hasValue()){$.getString()==="currentColor"&&$.setValue(this.getStyle("color").getColor());const at=$.getColor();at!=="inherit"&&(d.fillStyle=at==="none"?"rgba(0,0,0,0)":at)}if(j.hasValue()){const at=new Property(this.document,"fill",d.fillStyle).addOpacity(j).getColor();d.fillStyle=at}if(_e.isUrlDefinition()){const at=_e.getFillStyleDefinition(this,et);at&&(d.strokeStyle=at)}else if(_e.hasValue()){_e.getString()==="currentColor"&&_e.setValue(this.getStyle("color").getColor());const at=_e.getString();at!=="inherit"&&(d.strokeStyle=at==="none"?"rgba(0,0,0,0)":at)}if(et.hasValue()){const at=new Property(this.document,"stroke",d.strokeStyle).addOpacity(et).getString();d.strokeStyle=at}const tt=this.getStyle("stroke-width");if(tt.hasValue()){const at=tt.getPixels();d.lineWidth=at||PSEUDO_ZERO}const nt=this.getStyle("stroke-linecap"),rt=this.getStyle("stroke-linejoin"),it=this.getStyle("stroke-miterlimit"),st=this.getStyle("stroke-dasharray"),ot=this.getStyle("stroke-dashoffset");if(nt.hasValue()&&(d.lineCap=nt.getString()),rt.hasValue()&&(d.lineJoin=rt.getString()),it.hasValue()&&(d.miterLimit=it.getNumber()),st.hasValue()&&st.getString()!=="none"){const at=toNumbers(st.getString());typeof d.setLineDash<"u"?d.setLineDash(at):typeof d.webkitLineDash<"u"?d.webkitLineDash=at:typeof d.mozDash<"u"&&!(at.length===1&&at[0]===0)&&(d.mozDash=at);const ut=ot.getPixels();typeof d.lineDashOffset<"u"?d.lineDashOffset=ut:typeof d.webkitLineDashOffset<"u"?d.webkitLineDashOffset=ut:typeof d.mozDashOffset<"u"&&(d.mozDashOffset=ut)}}if(this.modifiedEmSizeStack=!1,typeof d.font<"u"){const $=this.getStyle("font"),j=this.getStyle("font-style"),_e=this.getStyle("font-variant"),et=this.getStyle("font-weight"),tt=this.getStyle("font-size"),nt=this.getStyle("font-family"),rt=new Font(j.getString(),_e.getString(),et.getString(),tt.hasValue()?"".concat(tt.getPixels(!0),"px"):"",nt.getString(),Font.parse($.getString(),d.font));j.setValue(rt.fontStyle),_e.setValue(rt.fontVariant),et.setValue(rt.fontWeight),tt.setValue(rt.fontSize),nt.setValue(rt.fontFamily),d.font=rt.toString(),tt.isPixels()&&(this.document.emSize=tt.getPixels(),this.modifiedEmSizeStack=!0)}b||(this.applyEffects(d),d.globalAlpha=this.calculateOpacity())}clearContext(d){super.clearContext(d),this.modifiedEmSizeStack&&this.document.popEmSize()}constructor(...d){super(...d),this.modifiedEmSizeStack=!1}}class TextElement extends RenderedElement{setContext(d){let b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;super.setContext(d,b);const $=this.getStyle("dominant-baseline").getTextBaseline()||this.getStyle("alignment-baseline").getTextBaseline();$&&(d.textBaseline=$)}initializeCoordinates(){this.x=0,this.y=0,this.leafTexts=[],this.textChunkStart=0,this.minX=Number.POSITIVE_INFINITY,this.maxX=Number.NEGATIVE_INFINITY}getBoundingBox(d){if(this.type!=="text")return this.getTElementBoundingBox(d);this.initializeCoordinates(),this.adjustChildCoordinatesRecursive(d);let b=null;return this.children.forEach(($,j)=>{const _e=this.getChildBoundingBox(d,this,this,j);b?b.addBoundingBox(_e):b=_e}),b}getFontSize(){const{document:d,parent:b}=this,$=Font.parse(d.ctx.font).fontSize;return b.getStyle("font-size").getNumber($)}getTElementBoundingBox(d){const b=this.getFontSize();return new BoundingBox(this.x,this.y-b,this.x+this.measureText(d),this.y)}getGlyph(d,b,$){const j=b[$];let _e;if(d.isArabic){var et;const tt=b.length,nt=b[$-1],rt=b[$+1];let it="isolated";($===0||nt===" ")&&$0&&nt!==" "&&$0&&nt!==" "&&($===tt-1||rt===" ")&&(it="initial"),_e=((et=d.arabicGlyphs[j])===null||et===void 0?void 0:et[it])||d.glyphs[j]}else _e=d.glyphs[j];return _e||(_e=d.missingGlyph),_e}getText(){return""}getTextFromNode(d){const b=d||this.node,$=Array.from(b.parentNode.childNodes),j=$.indexOf(b),_e=$.length-1;let et=compressSpaces(b.textContent||"");return j===0&&(et=trimLeft(et)),j===_e&&(et=trimRight(et)),et}renderChildren(d){if(this.type!=="text"){this.renderTElementChildren(d);return}this.initializeCoordinates(),this.adjustChildCoordinatesRecursive(d),this.children.forEach(($,j)=>{this.renderChild(d,this,this,j)});const{mouse:b}=this.document.screen;b.isWorking()&&b.checkBoundingBox(this,this.getBoundingBox(d))}renderTElementChildren(d){const{document:b,parent:$}=this,j=this.getText(),_e=$.getStyle("font-family").getDefinition();if(_e){const{unitsPerEm:nt}=_e.fontFace,rt=Font.parse(b.ctx.font),it=$.getStyle("font-size").getNumber(rt.fontSize),st=$.getStyle("font-style").getString(rt.fontStyle),ot=it/nt,at=_e.isRTL?j.split("").reverse().join(""):j,ut=toNumbers($.getAttribute("dx").getString()),ct=at.length;for(let dt=0;dt=this.leafTexts.length)return;const d=this.leafTexts[this.textChunkStart],b=d.getStyle("text-anchor").getString("start"),$=!1;let j=0;b==="start"&&!$||b==="end"&&$?j=d.x-this.minX:b==="end"&&!$||b==="start"&&$?j=d.x-this.maxX:j=d.x-(this.minX+this.maxX)/2;for(let _e=this.textChunkStart;_e{this.adjustChildCoordinatesRecursiveCore(d,this,this,$)}),this.applyAnchoring()}adjustChildCoordinatesRecursiveCore(d,b,$,j){const _e=$.children[j];_e.children.length>0?_e.children.forEach((et,tt)=>{b.adjustChildCoordinatesRecursiveCore(d,b,_e,tt)}):this.adjustChildCoordinates(d,b,$,j)}adjustChildCoordinates(d,b,$,j){const _e=$.children[j];if(typeof _e.measureText!="function")return _e;d.save(),_e.setContext(d,!0);const et=_e.getAttribute("x"),tt=_e.getAttribute("y"),nt=_e.getAttribute("dx"),rt=_e.getAttribute("dy"),it=_e.getStyle("font-family").getDefinition(),st=!!(it!=null&&it.isRTL);j===0&&(et.hasValue()||et.setValue(_e.getInheritedAttribute("x")),tt.hasValue()||tt.setValue(_e.getInheritedAttribute("y")),nt.hasValue()||nt.setValue(_e.getInheritedAttribute("dx")),rt.hasValue()||rt.setValue(_e.getInheritedAttribute("dy")));const ot=_e.measureText(d);return st&&(b.x-=ot),et.hasValue()?(b.applyAnchoring(),_e.x=et.getPixels("x"),nt.hasValue()&&(_e.x+=nt.getPixels("x"))):(nt.hasValue()&&(b.x+=nt.getPixels("x")),_e.x=b.x),b.x=_e.x,st||(b.x+=ot),tt.hasValue()?(_e.y=tt.getPixels("y"),rt.hasValue()&&(_e.y+=rt.getPixels("y"))):(rt.hasValue()&&(b.y+=rt.getPixels("y")),_e.y=b.y),b.y=_e.y,b.leafTexts.push(_e),b.minX=Math.min(b.minX,_e.x,_e.x+ot),b.maxX=Math.max(b.maxX,_e.x,_e.x+ot),_e.clearContext(d),d.restore(),_e}getChildBoundingBox(d,b,$,j){const _e=$.children[j];if(typeof _e.getBoundingBox!="function")return null;const et=_e.getBoundingBox(d);return et&&_e.children.forEach((tt,nt)=>{const rt=b.getChildBoundingBox(d,b,_e,nt);et.addBoundingBox(rt)}),et}renderChild(d,b,$,j){const _e=$.children[j];_e.render(d),_e.children.forEach((et,tt)=>{b.renderChild(d,b,_e,tt)})}measureText(d){const{measureCache:b}=this;if(~b)return b;const $=this.getText(),j=this.measureTargetText(d,$);return this.measureCache=j,j}measureTargetText(d,b){if(!b.length)return 0;const{parent:$}=this,j=$.getStyle("font-family").getDefinition();if(j){const et=this.getFontSize(),tt=j.isRTL?b.split("").reverse().join(""):b,nt=toNumbers($.getAttribute("dx").getString()),rt=tt.length;let it=0;for(let st=0;st0?"":this.getTextFromNode()}}class TextNode extends TSpanElement{constructor(...d){super(...d),this.type="textNode"}}class PathParser extends _{reset(){this.i=-1,this.command=null,this.previousCommand=null,this.start=new Point(0,0),this.control=new Point(0,0),this.current=new Point(0,0),this.points=[],this.angles=[]}isEnd(){const{i:d,commands:b}=this;return d>=b.length-1}next(){const d=this.commands[++this.i];return this.previousCommand=this.command,this.command=d,d}getPoint(){let d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"x",b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"y";const $=new Point(this.command[d],this.command[b]);return this.makeAbsolute($)}getAsControlPoint(d,b){const $=this.getPoint(d,b);return this.control=$,$}getAsCurrentPoint(d,b){const $=this.getPoint(d,b);return this.current=$,$}getReflectedControlPoint(){const d=this.previousCommand.type;if(d!==_.CURVE_TO&&d!==_.SMOOTH_CURVE_TO&&d!==_.QUAD_TO&&d!==_.SMOOTH_QUAD_TO)return this.current;const{current:{x:b,y:$},control:{x:j,y:_e}}=this;return new Point(2*b-j,2*$-_e)}makeAbsolute(d){if(this.command.relative){const{x:b,y:$}=this.current;d.x+=b,d.y+=$}return d}addMarker(d,b,$){const{points:j,angles:_e}=this;$&&_e.length>0&&!_e[_e.length-1]&&(_e[_e.length-1]=j[j.length-1].angleTo($)),this.addMarkerAngle(d,b?b.angleTo(d):null)}addMarkerAngle(d,b){this.points.push(d),this.angles.push(b)}getMarkerPoints(){return this.points}getMarkerAngles(){const{angles:d}=this,b=d.length;for(let $=0;$[_e,$[et]])}renderChildren(d){this.path(d),this.document.screen.mouse.checkPath(this,d);const b=this.getStyle("fill-rule");d.fillStyle!==""&&(b.getString("inherit")!=="inherit"?d.fill(b.getString()):d.fill()),d.strokeStyle!==""&&(this.getAttribute("vector-effect").getString()==="non-scaling-stroke"?(d.save(),d.setTransform(1,0,0,1,0,0),d.stroke(),d.restore()):d.stroke());const $=this.getMarkers();if($){const j=$.length-1,_e=this.getStyle("marker-start"),et=this.getStyle("marker-mid"),tt=this.getStyle("marker-end");if(_e.isUrlDefinition()){const nt=_e.getDefinition(),[rt,it]=$[0];nt.render(d,rt,it)}if(et.isUrlDefinition()){const nt=et.getDefinition();for(let rt=1;rt1&&(j*=Math.sqrt(ot),_e*=Math.sqrt(ot));let at=(tt===nt?-1:1)*Math.sqrt((Math.pow(j,2)*Math.pow(_e,2)-Math.pow(j,2)*Math.pow(st.y,2)-Math.pow(_e,2)*Math.pow(st.x,2))/(Math.pow(j,2)*Math.pow(st.y,2)+Math.pow(_e,2)*Math.pow(st.x,2)));isNaN(at)&&(at=0);const ut=new Point(at*j*st.y/_e,at*-_e*st.x/j),ct=new Point((b.x+it.x)/2+Math.cos(rt)*ut.x-Math.sin(rt)*ut.y,(b.y+it.y)/2+Math.sin(rt)*ut.x+Math.cos(rt)*ut.y),dt=vectorsAngle([1,0],[(st.x-ut.x)/j,(st.y-ut.y)/_e]),ht=[(st.x-ut.x)/j,(st.y-ut.y)/_e],pt=[(-st.x-ut.x)/j,(-st.y-ut.y)/_e];let gt=vectorsAngle(ht,pt);return vectorsRatio(ht,pt)<=-1&&(gt=Math.PI),vectorsRatio(ht,pt)>=1&&(gt=0),{currentPoint:it,rX:j,rY:_e,sweepFlag:nt,xAxisRotation:rt,centp:ct,a1:dt,ad:gt}}pathA(d,b){const{pathParser:$}=this,{currentPoint:j,rX:_e,rY:et,sweepFlag:tt,xAxisRotation:nt,centp:rt,a1:it,ad:st}=PathElement.pathA($),ot=1-tt?1:-1,at=it+ot*(st/2),ut=new Point(rt.x+_e*Math.cos(at),rt.y+et*Math.sin(at));if($.addMarkerAngle(ut,at-ot*Math.PI/2),$.addMarkerAngle(j,at-ot*Math.PI),b.addPoint(j.x,j.y),d&&!isNaN(it)&&!isNaN(st)){const ct=_e>et?_e:et,dt=_e>et?1:_e/et,ht=_e>et?et/_e:1;d.translate(rt.x,rt.y),d.rotate(nt),d.scale(dt,ht),d.arc(0,0,ct,it,it+st,!!(1-tt)),d.scale(1/dt,1/ht),d.rotate(-nt),d.translate(-rt.x,-rt.y)}}static pathZ(d){d.current=d.start}pathZ(d,b){PathElement.pathZ(this.pathParser),d&&b.x1!==b.x2&&b.y1!==b.y2&&d.closePath()}constructor(d,b,$){super(d,b,$),this.type="path",this.pathParser=new PathParser(this.getAttribute("d").getString())}}class SVGElement extends RenderedElement{setContext(d){var b;const{document:$}=this,{screen:j,window:_e}=$,et=d.canvas;if(j.setDefaults(d),"style"in et&&typeof d.font<"u"&&_e&&typeof _e.getComputedStyle<"u"){d.font=_e.getComputedStyle(et).getPropertyValue("font");const pt=new Property($,"fontSize",Font.parse(d.font).fontSize);pt.hasValue()&&($.rootEmSize=pt.getPixels("y"),$.emSize=$.rootEmSize)}this.getAttribute("x").hasValue()||this.getAttribute("x",!0).setValue(0),this.getAttribute("y").hasValue()||this.getAttribute("y",!0).setValue(0);let{width:tt,height:nt}=j.viewPort;this.getStyle("width").hasValue()||this.getStyle("width",!0).setValue("100%"),this.getStyle("height").hasValue()||this.getStyle("height",!0).setValue("100%"),this.getStyle("color").hasValue()||this.getStyle("color",!0).setValue("black");const rt=this.getAttribute("refX"),it=this.getAttribute("refY"),st=this.getAttribute("viewBox"),ot=st.hasValue()?toNumbers(st.getString()):null,at=!this.root&&this.getStyle("overflow").getValue("hidden")!=="visible";let ut=0,ct=0,dt=0,ht=0;ot&&(ut=ot[0],ct=ot[1]),this.root||(tt=this.getStyle("width").getPixels("x"),nt=this.getStyle("height").getPixels("y"),this.type==="marker"&&(dt=ut,ht=ct,ut=0,ct=0)),j.viewPort.setCurrent(tt,nt),this.node&&(!this.parent||((b=this.node.parentNode)===null||b===void 0?void 0:b.nodeName)==="foreignObject")&&this.getStyle("transform",!1,!0).hasValue()&&!this.getStyle("transform-origin",!1,!0).hasValue()&&this.getStyle("transform-origin",!0,!0).setValue("50% 50%"),super.setContext(d),d.translate(this.getAttribute("x").getPixels("x"),this.getAttribute("y").getPixels("y")),ot&&(tt=ot[2],nt=ot[3]),$.setViewBox({ctx:d,aspectRatio:this.getAttribute("preserveAspectRatio").getString(),width:j.viewPort.width,desiredWidth:tt,height:j.viewPort.height,desiredHeight:nt,minX:ut,minY:ct,refX:rt.getValue(),refY:it.getValue(),clip:at,clipX:dt,clipY:ht}),ot&&(j.viewPort.removeCurrent(),j.viewPort.setCurrent(tt,nt))}clearContext(d){super.clearContext(d),this.document.screen.viewPort.removeCurrent()}resize(d){let b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:d,$=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;const j=this.getAttribute("width",!0),_e=this.getAttribute("height",!0),et=this.getAttribute("viewBox"),tt=this.getAttribute("style"),nt=j.getNumber(0),rt=_e.getNumber(0);if($)if(typeof $=="string")this.getAttribute("preserveAspectRatio",!0).setValue($);else{const it=this.getAttribute("preserveAspectRatio");it.hasValue()&&it.setValue(it.getString().replace(/^\s*(\S.*\S)\s*$/,"$1"))}if(j.setValue(d),_e.setValue(b),et.hasValue()||et.setValue("0 0 ".concat(nt||d," ").concat(rt||b)),tt.hasValue()){const it=this.getStyle("width"),st=this.getStyle("height");it.hasValue()&&it.setValue("".concat(d,"px")),st.hasValue()&&st.setValue("".concat(b,"px"))}}constructor(...d){super(...d),this.type="svg",this.root=!1}}class RectElement extends PathElement{path(d){const b=this.getAttribute("x").getPixels("x"),$=this.getAttribute("y").getPixels("y"),j=this.getStyle("width",!1,!0).getPixels("x"),_e=this.getStyle("height",!1,!0).getPixels("y"),et=this.getAttribute("rx"),tt=this.getAttribute("ry");let nt=et.getPixels("x"),rt=tt.getPixels("y");if(et.hasValue()&&!tt.hasValue()&&(rt=nt),tt.hasValue()&&!et.hasValue()&&(nt=rt),nt=Math.min(nt,j/2),rt=Math.min(rt,_e/2),d){const it=4*((Math.sqrt(2)-1)/3);d.beginPath(),_e>0&&j>0&&(d.moveTo(b+nt,$),d.lineTo(b+j-nt,$),d.bezierCurveTo(b+j-nt+it*nt,$,b+j,$+rt-it*rt,b+j,$+rt),d.lineTo(b+j,$+_e-rt),d.bezierCurveTo(b+j,$+_e-rt+it*rt,b+j-nt+it*nt,$+_e,b+j-nt,$+_e),d.lineTo(b+nt,$+_e),d.bezierCurveTo(b+nt-it*nt,$+_e,b,$+_e-rt+it*rt,b,$+_e-rt),d.lineTo(b,$+rt),d.bezierCurveTo(b,$+rt-it*rt,b+nt-it*nt,$,b+nt,$),d.closePath())}return new BoundingBox(b,$,b+j,$+_e)}getMarkers(){return null}constructor(...d){super(...d),this.type="rect"}}class CircleElement extends PathElement{path(d){const b=this.getAttribute("cx").getPixels("x"),$=this.getAttribute("cy").getPixels("y"),j=this.getAttribute("r").getPixels();return d&&j>0&&(d.beginPath(),d.arc(b,$,j,0,Math.PI*2,!1),d.closePath()),new BoundingBox(b-j,$-j,b+j,$+j)}getMarkers(){return null}constructor(...d){super(...d),this.type="circle"}}class EllipseElement extends PathElement{path(d){const b=4*((Math.sqrt(2)-1)/3),$=this.getAttribute("rx").getPixels("x"),j=this.getAttribute("ry").getPixels("y"),_e=this.getAttribute("cx").getPixels("x"),et=this.getAttribute("cy").getPixels("y");return d&&$>0&&j>0&&(d.beginPath(),d.moveTo(_e+$,et),d.bezierCurveTo(_e+$,et+b*j,_e+b*$,et+j,_e,et+j),d.bezierCurveTo(_e-b*$,et+j,_e-$,et+b*j,_e-$,et),d.bezierCurveTo(_e-$,et-b*j,_e-b*$,et-j,_e,et-j),d.bezierCurveTo(_e+b*$,et-j,_e+$,et-b*j,_e+$,et),d.closePath()),new BoundingBox(_e-$,et-j,_e+$,et+j)}getMarkers(){return null}constructor(...d){super(...d),this.type="ellipse"}}class LineElement extends PathElement{getPoints(){return[new Point(this.getAttribute("x1").getPixels("x"),this.getAttribute("y1").getPixels("y")),new Point(this.getAttribute("x2").getPixels("x"),this.getAttribute("y2").getPixels("y"))]}path(d){const[{x:b,y:$},{x:j,y:_e}]=this.getPoints();return d&&(d.beginPath(),d.moveTo(b,$),d.lineTo(j,_e)),new BoundingBox(b,$,j,_e)}getMarkers(){const[d,b]=this.getPoints(),$=d.angleTo(b);return[[d,$],[b,$]]}constructor(...d){super(...d),this.type="line"}}class PolylineElement extends PathElement{path(d){const{points:b}=this,[{x:$,y:j}]=b,_e=new BoundingBox($,j);return d&&(d.beginPath(),d.moveTo($,j)),b.forEach(et=>{let{x:tt,y:nt}=et;_e.addPoint(tt,nt),d&&d.lineTo(tt,nt)}),_e}getMarkers(){const{points:d}=this,b=d.length-1,$=[];return d.forEach((j,_e)=>{_e!==b&&$.push([j,j.angleTo(d[_e+1])])}),$.length>0&&$.push([d[d.length-1],$[$.length-1][1]]),$}constructor(d,b,$){super(d,b,$),this.type="polyline",this.points=[],this.points=Point.parsePath(this.getAttribute("points").getString())}}class PolygonElement extends PolylineElement{path(d){const b=super.path(d),[{x:$,y:j}]=this.points;return d&&(d.lineTo($,j),d.closePath()),b}constructor(...d){super(...d),this.type="polygon"}}class PatternElement extends Element{createPattern(d,b,$){const j=this.getStyle("width").getPixels("x",!0),_e=this.getStyle("height").getPixels("y",!0),et=new SVGElement(this.document,null);et.attributes.viewBox=new Property(this.document,"viewBox",this.getAttribute("viewBox").getValue()),et.attributes.width=new Property(this.document,"width","".concat(j,"px")),et.attributes.height=new Property(this.document,"height","".concat(_e,"px")),et.attributes.transform=new Property(this.document,"transform",this.getAttribute("patternTransform").getValue()),et.children=this.children;const tt=this.document.createCanvas(j,_e),nt=tt.getContext("2d"),rt=this.getAttribute("x"),it=this.getAttribute("y");rt.hasValue()&&it.hasValue()&&nt.translate(rt.getPixels("x",!0),it.getPixels("y",!0)),$.hasValue()?this.styles["fill-opacity"]=$:Reflect.deleteProperty(this.styles,"fill-opacity");for(let ot=-1;ot<=1;ot++)for(let at=-1;at<=1;at++)nt.save(),et.attributes.x=new Property(this.document,"x",ot*tt.width),et.attributes.y=new Property(this.document,"y",at*tt.height),et.render(nt),nt.restore();return d.createPattern(tt,"repeat")}constructor(...d){super(...d),this.type="pattern"}}class MarkerElement extends Element{render(d,b,$){if(!b)return;const{x:j,y:_e}=b,et=this.getAttribute("orient").getString("auto"),tt=this.getAttribute("markerUnits").getString("strokeWidth");d.translate(j,_e),et==="auto"&&d.rotate($),tt==="strokeWidth"&&d.scale(d.lineWidth,d.lineWidth),d.save();const nt=new SVGElement(this.document);nt.type=this.type,nt.attributes.viewBox=new Property(this.document,"viewBox",this.getAttribute("viewBox").getValue()),nt.attributes.refX=new Property(this.document,"refX",this.getAttribute("refX").getValue()),nt.attributes.refY=new Property(this.document,"refY",this.getAttribute("refY").getValue()),nt.attributes.width=new Property(this.document,"width",this.getAttribute("markerWidth").getValue()),nt.attributes.height=new Property(this.document,"height",this.getAttribute("markerHeight").getValue()),nt.attributes.overflow=new Property(this.document,"overflow",this.getAttribute("overflow").getValue()),nt.attributes.fill=new Property(this.document,"fill",this.getAttribute("fill").getColor("black")),nt.attributes.stroke=new Property(this.document,"stroke",this.getAttribute("stroke").getValue("none")),nt.children=this.children,nt.render(d),d.restore(),tt==="strokeWidth"&&d.scale(1/d.lineWidth,1/d.lineWidth),et==="auto"&&d.rotate(-$),d.translate(-j,-_e)}constructor(...d){super(...d),this.type="marker"}}class DefsElement extends Element{render(){}constructor(...d){super(...d),this.type="defs"}}class GElement extends RenderedElement{getBoundingBox(d){const b=new BoundingBox;return this.children.forEach($=>{b.addBoundingBox($.getBoundingBox(d))}),b}constructor(...d){super(...d),this.type="g"}}class GradientElement extends Element{getGradientUnits(){return this.getAttribute("gradientUnits").getString("objectBoundingBox")}createGradient(d,b,$){let j=this;this.getHrefAttribute().hasValue()&&(j=this.getHrefAttribute().getDefinition(),this.inheritStopContainer(j));const{stops:_e}=j,et=this.getGradient(d,b);if(!et)return this.addParentOpacity($,_e[_e.length-1].color);if(_e.forEach(tt=>{et.addColorStop(tt.offset,this.addParentOpacity($,tt.color))}),this.getAttribute("gradientTransform").hasValue()){const{document:tt}=this,{MAX_VIRTUAL_PIXELS:nt}=Screen,{viewPort:rt}=tt.screen,it=rt.getRoot(),st=new RectElement(tt);st.attributes.x=new Property(tt,"x",-nt/3),st.attributes.y=new Property(tt,"y",-nt/3),st.attributes.width=new Property(tt,"width",nt),st.attributes.height=new Property(tt,"height",nt);const ot=new GElement(tt);ot.attributes.transform=new Property(tt,"transform",this.getAttribute("gradientTransform").getValue()),ot.children=[st];const at=new SVGElement(tt);at.attributes.x=new Property(tt,"x",0),at.attributes.y=new Property(tt,"y",0),at.attributes.width=new Property(tt,"width",it.width),at.attributes.height=new Property(tt,"height",it.height),at.children=[ot];const ut=tt.createCanvas(it.width,it.height),ct=ut.getContext("2d");return ct.fillStyle=et,at.render(ct),ct.createPattern(ut,"no-repeat")}return et}inheritStopContainer(d){this.attributesToInherit.forEach(b=>{!this.getAttribute(b).hasValue()&&d.getAttribute(b).hasValue()&&this.getAttribute(b,!0).setValue(d.getAttribute(b).getValue())})}addParentOpacity(d,b){return d.hasValue()?new Property(this.document,"color",b).addOpacity(d).getColor():b}constructor(d,b,$){super(d,b,$),this.attributesToInherit=["gradientUnits"],this.stops=[];const{stops:j,children:_e}=this;_e.forEach(et=>{et.type==="stop"&&j.push(et)})}}class LinearGradientElement extends GradientElement{getGradient(d,b){const $=this.getGradientUnits()==="objectBoundingBox",j=$?b.getBoundingBox(d):null;if($&&!j)return null;!this.getAttribute("x1").hasValue()&&!this.getAttribute("y1").hasValue()&&!this.getAttribute("x2").hasValue()&&!this.getAttribute("y2").hasValue()&&(this.getAttribute("x1",!0).setValue(0),this.getAttribute("y1",!0).setValue(0),this.getAttribute("x2",!0).setValue(1),this.getAttribute("y2",!0).setValue(0));const _e=$?j.x+j.width*this.getAttribute("x1").getNumber():this.getAttribute("x1").getPixels("x"),et=$?j.y+j.height*this.getAttribute("y1").getNumber():this.getAttribute("y1").getPixels("y"),tt=$?j.x+j.width*this.getAttribute("x2").getNumber():this.getAttribute("x2").getPixels("x"),nt=$?j.y+j.height*this.getAttribute("y2").getNumber():this.getAttribute("y2").getPixels("y");return _e===tt&&et===nt?null:d.createLinearGradient(_e,et,tt,nt)}constructor(d,b,$){super(d,b,$),this.type="linearGradient",this.attributesToInherit.push("x1","y1","x2","y2")}}class RadialGradientElement extends GradientElement{getGradient(d,b){const $=this.getGradientUnits()==="objectBoundingBox",j=b.getBoundingBox(d);if($&&!j)return null;this.getAttribute("cx").hasValue()||this.getAttribute("cx",!0).setValue("50%"),this.getAttribute("cy").hasValue()||this.getAttribute("cy",!0).setValue("50%"),this.getAttribute("r").hasValue()||this.getAttribute("r",!0).setValue("50%");const _e=$?j.x+j.width*this.getAttribute("cx").getNumber():this.getAttribute("cx").getPixels("x"),et=$?j.y+j.height*this.getAttribute("cy").getNumber():this.getAttribute("cy").getPixels("y");let tt=_e,nt=et;this.getAttribute("fx").hasValue()&&(tt=$?j.x+j.width*this.getAttribute("fx").getNumber():this.getAttribute("fx").getPixels("x")),this.getAttribute("fy").hasValue()&&(nt=$?j.y+j.height*this.getAttribute("fy").getNumber():this.getAttribute("fy").getPixels("y"));const rt=$?(j.width+j.height)/2*this.getAttribute("r").getNumber():this.getAttribute("r").getPixels(),it=this.getAttribute("fr").getPixels();return d.createRadialGradient(tt,nt,it,_e,et,rt)}constructor(d,b,$){super(d,b,$),this.type="radialGradient",this.attributesToInherit.push("cx","cy","r","fx","fy","fr")}}class StopElement extends Element{constructor(d,b,$){super(d,b,$),this.type="stop";const j=Math.max(0,Math.min(1,this.getAttribute("offset").getNumber())),_e=this.getStyle("stop-opacity");let et=this.getStyle("stop-color",!0);et.getString()===""&&et.setValue("#000"),_e.hasValue()&&(et=et.addOpacity(_e)),this.offset=j,this.color=et.getColor()}}class AnimateElement extends Element{getProperty(){const d=this.getAttribute("attributeType").getString(),b=this.getAttribute("attributeName").getString();return d==="CSS"?this.parent.getStyle(b,!0):this.parent.getAttribute(b,!0)}calcValue(){const{initialUnits:d}=this,{progress:b,from:$,to:j}=this.getProgress();let _e=$.getNumber()+(j.getNumber()-$.getNumber())*b;return d==="%"&&(_e*=100),"".concat(_e).concat(d)}update(d){const{parent:b}=this,$=this.getProperty();if(this.initialValue||(this.initialValue=$.getString(),this.initialUnits=$.getUnits()),this.duration>this.maxDuration){const _e=this.getAttribute("fill").getString("remove");if(this.getAttribute("repeatCount").getString()==="indefinite"||this.getAttribute("repeatDur").getString()==="indefinite")this.duration=0;else if(_e==="freeze"&&!this.frozen)this.frozen=!0,b&&$&&(b.animationFrozen=!0,b.animationFrozenValue=$.getString());else if(_e==="remove"&&!this.removed)return this.removed=!0,b&&$&&$.setValue(b.animationFrozen?b.animationFrozenValue:this.initialValue),!0;return!1}this.duration+=d;let j=!1;if(this.begin{const rt=_e[nt];return tt+(rt-tt)*d}).join(" ")}constructor(...d){super(...d),this.type="animateTransform"}}class FontFaceElement extends Element{constructor(d,b,$){super(d,b,$),this.type="font-face",this.ascent=this.getAttribute("ascent").getNumber(),this.descent=this.getAttribute("descent").getNumber(),this.unitsPerEm=this.getAttribute("units-per-em").getNumber()}}class GlyphElement extends PathElement{constructor(d,b,$){super(d,b,$),this.type="glyph",this.horizAdvX=this.getAttribute("horiz-adv-x").getNumber(),this.unicode=this.getAttribute("unicode").getString(),this.arabicForm=this.getAttribute("arabic-form").getString()}}class MissingGlyphElement extends GlyphElement{constructor(...d){super(...d),this.type="missing-glyph",this.horizAdvX=0}}class FontElement extends Element{render(){}constructor(d,b,$){super(d,b,$),this.type="font",this.isArabic=!1,this.glyphs={},this.arabicGlyphs={},this.isRTL=!1,this.horizAdvX=this.getAttribute("horiz-adv-x").getNumber();const{definitions:j}=d,{children:_e}=this;for(const et of _e)if(et instanceof FontFaceElement){this.fontFace=et;const tt=et.getStyle("font-family");tt.hasValue()&&(j[tt.getString()]=this)}else if(et instanceof MissingGlyphElement)this.missingGlyph=et;else if(et instanceof GlyphElement)if(et.arabicForm){this.isRTL=!0,this.isArabic=!0;const tt=this.arabicGlyphs[et.unicode];typeof tt>"u"?this.arabicGlyphs[et.unicode]={[et.arabicForm]:et}:tt[et.arabicForm]=et}else this.glyphs[et.unicode]=et}}class TRefElement extends TextElement{getText(){const d=this.getHrefAttribute().getDefinition();if(d){const b=d.children[0];if(b)return b.getText()}return""}constructor(...d){super(...d),this.type="tref"}}class AElement extends TextElement{getText(){return this.text}renderChildren(d){if(this.hasText){super.renderChildren(d);const{document:b,x:$,y:j}=this,{mouse:_e}=b.screen,et=new Property(b,"fontSize",Font.parse(b.ctx.font).fontSize);_e.isWorking()&&_e.checkBoundingBox(this,new BoundingBox($,j-et.getPixels("y"),$+this.measureText(d),j))}else if(this.children.length>0){const b=new GElement(this.document);b.children=this.children,b.parent=this,b.render(d)}}onClick(){const{window:d}=this.document;d&&d.open(this.getHrefAttribute().getString())}onMouseMove(){const d=this.document.ctx;d.canvas.style.cursor="pointer"}constructor(d,b,$){super(d,b,$),this.type="a";const{childNodes:j}=b,_e=j[0],et=j.length>0&&Array.from(j).every(tt=>tt.nodeType===3);this.hasText=et,this.text=et?this.getTextFromNode(_e):""}}class TextPathElement extends TextElement{getText(){return this.text}path(d){const{dataArray:b}=this;d&&d.beginPath(),b.forEach($=>{let{type:j,points:_e}=$;switch(j){case PathParser.LINE_TO:d&&d.lineTo(_e[0],_e[1]);break;case PathParser.MOVE_TO:d&&d.moveTo(_e[0],_e[1]);break;case PathParser.CURVE_TO:d&&d.bezierCurveTo(_e[0],_e[1],_e[2],_e[3],_e[4],_e[5]);break;case PathParser.QUAD_TO:d&&d.quadraticCurveTo(_e[0],_e[1],_e[2],_e[3]);break;case PathParser.ARC:{const[et,tt,nt,rt,it,st,ot,at]=_e,ut=nt>rt?nt:rt,ct=nt>rt?1:nt/rt,dt=nt>rt?rt/nt:1;d&&(d.translate(et,tt),d.rotate(ot),d.scale(ct,dt),d.arc(0,0,ut,it,it+st,!!(1-at)),d.scale(1/ct,1/dt),d.rotate(-ot),d.translate(-et,-tt));break}case PathParser.CLOSE_PATH:d&&d.closePath();break}})}renderChildren(d){this.setTextData(d),d.save();const b=this.parent.getStyle("text-decoration").getString(),$=this.getFontSize(),{glyphInfo:j}=this,_e=d.fillStyle;b==="underline"&&d.beginPath(),j.forEach((et,tt)=>{const{p0:nt,p1:rt,rotation:it,text:st}=et;d.save(),d.translate(nt.x,nt.y),d.rotate(it),d.fillStyle&&d.fillText(st,0,0),d.strokeStyle&&d.strokeText(st,0,0),d.restore(),b==="underline"&&(tt===0&&d.moveTo(nt.x,nt.y+$/8),d.lineTo(rt.x,rt.y+$/5))}),b==="underline"&&(d.lineWidth=$/20,d.strokeStyle=_e,d.stroke(),d.closePath()),d.restore()}getLetterSpacingAt(){let d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return this.letterSpacingCache[d]||0}findSegmentToFitChar(d,b,$,j,_e,et,tt,nt,rt){let it=et,st=this.measureText(d,nt);nt===" "&&b==="justify"&&$-1&&(it+=this.getLetterSpacingAt(rt));const ot=this.textHeight/20,at=this.getEquidistantPointOnPath(it,ot,0),ut=this.getEquidistantPointOnPath(it+st,ot,0),ct={p0:at,p1:ut},dt=at&&ut?Math.atan2(ut.y-at.y,ut.x-at.x):0;if(tt){const ht=Math.cos(Math.PI/2+dt)*tt,pt=Math.cos(-dt)*tt;ct.p0={...at,x:at.x+ht,y:at.y+pt},ct.p1={...ut,x:ut.x+ht,y:ut.y+pt}}return it+=st,{offset:it,segment:ct,rotation:dt}}measureText(d,b){const{measuresCache:$}=this,j=b||this.getText();if($.has(j))return $.get(j);const _e=this.measureTargetText(d,j);return $.set(j,_e),_e}setTextData(d){if(this.glyphInfo)return;const b=this.getText(),$=b.split(""),j=b.split(" ").length-1,_e=this.parent.getAttribute("dx").split().map(gt=>gt.getPixels("x")),et=this.parent.getAttribute("dy").getPixels("y"),tt=this.parent.getStyle("text-anchor").getString("start"),nt=this.getStyle("letter-spacing"),rt=this.parent.getStyle("letter-spacing");let it=0;!nt.hasValue()||nt.getValue()==="inherit"?it=rt.getPixels():nt.hasValue()&&nt.getValue()!=="initial"&&nt.getValue()!=="unset"&&(it=nt.getPixels());const st=[],ot=b.length;this.letterSpacingCache=st;for(let gt=0;gtvt===0?0:gt+yt||0,0),ut=this.measureText(d),ct=Math.max(ut+at,0);this.textWidth=ut,this.textHeight=this.getFontSize(),this.glyphInfo=[];const dt=this.getPathLength(),ht=this.getStyle("startOffset").getNumber(0)*dt;let pt=0;(tt==="middle"||tt==="center")&&(pt=-ct/2),(tt==="end"||tt==="right")&&(pt=-ct),pt+=ht,$.forEach((gt,yt)=>{const{offset:vt,segment:St,rotation:xt}=this.findSegmentToFitChar(d,tt,ct,dt,j,pt,et,gt,yt);pt=vt,!(!St.p0||!St.p1)&&this.glyphInfo.push({text:$[yt],p0:St.p0,p1:St.p1,rotation:xt})})}parsePathData(d){if(this.pathLength=-1,!d)return[];const b=[],{pathParser:$}=d;for($.reset();!$.isEnd();){const{current:j}=$,_e=j?j.x:0,et=j?j.y:0,tt=$.next();let nt=tt.type,rt=[];switch(tt.type){case PathParser.MOVE_TO:this.pathM($,rt);break;case PathParser.LINE_TO:nt=this.pathL($,rt);break;case PathParser.HORIZ_LINE_TO:nt=this.pathH($,rt);break;case PathParser.VERT_LINE_TO:nt=this.pathV($,rt);break;case PathParser.CURVE_TO:this.pathC($,rt);break;case PathParser.SMOOTH_CURVE_TO:nt=this.pathS($,rt);break;case PathParser.QUAD_TO:this.pathQ($,rt);break;case PathParser.SMOOTH_QUAD_TO:nt=this.pathT($,rt);break;case PathParser.ARC:rt=this.pathA($);break;case PathParser.CLOSE_PATH:PathElement.pathZ($);break}tt.type!==PathParser.CLOSE_PATH?b.push({type:nt,points:rt,start:{x:_e,y:et},pathLength:this.calcLength(_e,et,nt,rt)}):b.push({type:PathParser.CLOSE_PATH,points:[],pathLength:0})}return b}pathM(d,b){const{x:$,y:j}=PathElement.pathM(d).point;b.push($,j)}pathL(d,b){const{x:$,y:j}=PathElement.pathL(d).point;return b.push($,j),PathParser.LINE_TO}pathH(d,b){const{x:$,y:j}=PathElement.pathH(d).point;return b.push($,j),PathParser.LINE_TO}pathV(d,b){const{x:$,y:j}=PathElement.pathV(d).point;return b.push($,j),PathParser.LINE_TO}pathC(d,b){const{point:$,controlPoint:j,currentPoint:_e}=PathElement.pathC(d);b.push($.x,$.y,j.x,j.y,_e.x,_e.y)}pathS(d,b){const{point:$,controlPoint:j,currentPoint:_e}=PathElement.pathS(d);return b.push($.x,$.y,j.x,j.y,_e.x,_e.y),PathParser.CURVE_TO}pathQ(d,b){const{controlPoint:$,currentPoint:j}=PathElement.pathQ(d);b.push($.x,$.y,j.x,j.y)}pathT(d,b){const{controlPoint:$,currentPoint:j}=PathElement.pathT(d);return b.push($.x,$.y,j.x,j.y),PathParser.QUAD_TO}pathA(d){let{rX:b,rY:$,sweepFlag:j,xAxisRotation:_e,centp:et,a1:tt,ad:nt}=PathElement.pathA(d);return j===0&&nt>0&&(nt-=2*Math.PI),j===1&&nt<0&&(nt+=2*Math.PI),[et.x,et.y,b,$,tt,nt,_e,j]}calcLength(d,b,$,j){let _e=0,et=null,tt=null,nt=0;switch($){case PathParser.LINE_TO:return this.getLineLength(d,b,j[0],j[1]);case PathParser.CURVE_TO:for(_e=0,et=this.getPointOnCubicBezier(0,d,b,j[0],j[1],j[2],j[3],j[4],j[5]),nt=.01;nt<=1;nt+=.01)tt=this.getPointOnCubicBezier(nt,d,b,j[0],j[1],j[2],j[3],j[4],j[5]),_e+=this.getLineLength(et.x,et.y,tt.x,tt.y),et=tt;return _e;case PathParser.QUAD_TO:for(_e=0,et=this.getPointOnQuadraticBezier(0,d,b,j[0],j[1],j[2],j[3]),nt=.01;nt<=1;nt+=.01)tt=this.getPointOnQuadraticBezier(nt,d,b,j[0],j[1],j[2],j[3]),_e+=this.getLineLength(et.x,et.y,tt.x,tt.y),et=tt;return _e;case PathParser.ARC:{_e=0;const rt=j[4],it=j[5],st=j[4]+it;let ot=Math.PI/180;if(Math.abs(rt-st)st;nt-=ot)tt=this.getPointOnEllipticalArc(j[0],j[1],j[2],j[3],nt,0),_e+=this.getLineLength(et.x,et.y,tt.x,tt.y),et=tt;else for(nt=rt+ot;nt5&&arguments[5]!==void 0?arguments[5]:b,tt=arguments.length>6&&arguments[6]!==void 0?arguments[6]:$;const nt=(_e-$)/(j-b+PSEUDO_ZERO);let rt=Math.sqrt(d*d/(1+nt*nt));jb)return null;const{dataArray:_e}=this;for(const et of _e){if(et&&(et.pathLength<5e-5||$+et.pathLength+5e-5=0&&nt>st)break;j=this.getPointOnEllipticalArc(et.points[0],et.points[1],et.points[2],et.points[3],nt,et.points[6]);break}case PathParser.CURVE_TO:nt=tt/et.pathLength,nt>1&&(nt=1),j=this.getPointOnCubicBezier(nt,et.start.x,et.start.y,et.points[0],et.points[1],et.points[2],et.points[3],et.points[4],et.points[5]);break;case PathParser.QUAD_TO:nt=tt/et.pathLength,nt>1&&(nt=1),j=this.getPointOnQuadraticBezier(nt,et.start.x,et.start.y,et.points[0],et.points[1],et.points[2],et.points[3]);break}if(j)return j;break}return null}getLineLength(d,b,$,j){return Math.sqrt(($-d)*($-d)+(j-b)*(j-b))}getPathLength(){return this.pathLength===-1&&(this.pathLength=this.dataArray.reduce((d,b)=>b.pathLength>0?d+b.pathLength:d,0)),this.pathLength}getPointOnCubicBezier(d,b,$,j,_e,et,tt,nt,rt){const it=nt*CB1(d)+et*CB2(d)+j*CB3(d)+b*CB4(d),st=rt*CB1(d)+tt*CB2(d)+_e*CB3(d)+$*CB4(d);return{x:it,y:st}}getPointOnQuadraticBezier(d,b,$,j,_e,et,tt){const nt=et*QB1(d)+j*QB2(d)+b*QB3(d),rt=tt*QB1(d)+_e*QB2(d)+$*QB3(d);return{x:nt,y:rt}}getPointOnEllipticalArc(d,b,$,j,_e,et){const tt=Math.cos(et),nt=Math.sin(et),rt={x:$*Math.cos(_e),y:j*Math.sin(_e)};return{x:d+(rt.x*tt-rt.y*nt),y:b+(rt.x*nt+rt.y*tt)}}buildEquidistantCache(d,b){const $=this.getPathLength(),j=b||.25,_e=d||$/100;if(!this.equidistantCache||this.equidistantCache.step!==_e||this.equidistantCache.precision!==j){this.equidistantCache={step:_e,precision:j,points:[]};let et=0;for(let tt=0;tt<=$;tt+=j){const nt=this.getPointOnPath(tt),rt=this.getPointOnPath(tt+j);!nt||!rt||(et+=this.getLineLength(nt.x,nt.y,rt.x,rt.y),et>=_e&&(this.equidistantCache.points.push({x:nt.x,y:nt.y,distance:tt}),et-=_e))}}}getEquidistantPointOnPath(d,b,$){if(this.buildEquidistantCache(b,$),d<0||d-this.getPathLength()>5e-5)return null;const j=Math.round(d/this.getPathLength()*(this.equidistantCache.points.length-1));return this.equidistantCache.points[j]||null}constructor(d,b,$){super(d,b,$),this.type="textPath",this.textWidth=0,this.textHeight=0,this.pathLength=-1,this.glyphInfo=null,this.letterSpacingCache=[],this.measuresCache=new Map([["",0]]);const j=this.getHrefAttribute().getDefinition();this.text=this.getTextFromNode(),this.dataArray=this.parsePathData(j)}}const dataUriRegex=/^\s*data:(([^/,;]+\/[^/,;]+)(?:;([^,;=]+=[^,;=]+))?)?(?:;(base64))?,(.*)$/i;class ImageElement extends RenderedElement{async loadImage(d){try{const b=await this.document.createImage(d);this.image=b}catch(b){console.error('Error while loading image "'.concat(d,'":'),b)}this.loaded=!0}async loadSvg(d){const b=dataUriRegex.exec(d);if(b){const $=b[5];$&&(b[4]==="base64"?this.image=atob($):this.image=decodeURIComponent($))}else try{const j=await(await this.document.fetch(d)).text();this.image=j}catch($){console.error('Error while loading image "'.concat(d,'":'),$)}this.loaded=!0}renderChildren(d){const{document:b,image:$,loaded:j}=this,_e=this.getAttribute("x").getPixels("x"),et=this.getAttribute("y").getPixels("y"),tt=this.getStyle("width").getPixels("x"),nt=this.getStyle("height").getPixels("y");if(!(!j||!$||!tt||!nt)){if(d.save(),d.translate(_e,et),typeof $=="string"){const rt=b.canvg.forkString(d,$,{ignoreMouse:!0,ignoreAnimation:!0,ignoreDimensions:!0,ignoreClear:!0,offsetX:0,offsetY:0,scaleWidth:tt,scaleHeight:nt}),{documentElement:it}=rt.document;it&&(it.parent=this),rt.render()}else b.setViewBox({ctx:d,aspectRatio:this.getAttribute("preserveAspectRatio").getString(),width:tt,desiredWidth:$.width,height:nt,desiredHeight:$.height}),this.loaded&&(!("complete"in $)||$.complete)&&d.drawImage($,0,0);d.restore()}}getBoundingBox(){const d=this.getAttribute("x").getPixels("x"),b=this.getAttribute("y").getPixels("y"),$=this.getStyle("width").getPixels("x"),j=this.getStyle("height").getPixels("y");return new BoundingBox(d,b,d+$,b+j)}constructor(d,b,$){super(d,b,$),this.type="image",this.loaded=!1;const j=this.getHrefAttribute().getString();if(!j)return;const _e=j.endsWith(".svg")||/^\s*data:image\/svg\+xml/i.test(j);d.images.push(this),_e?this.loadSvg(j):this.loadImage(j)}}class SymbolElement extends RenderedElement{render(d){}constructor(...d){super(...d),this.type="symbol"}}class SVGFontLoader{async load(d,b){try{const{document:$}=this,_e=(await $.canvg.parser.load(b)).getElementsByTagName("font");Array.from(_e).forEach(et=>{const tt=$.createElement(et);$.definitions[d]=tt})}catch($){console.error('Error while loading font "'.concat(b,'":'),$)}this.loaded=!0}constructor(d){this.document=d,this.loaded=!1,d.fonts.push(this)}}class StyleElement extends Element{constructor(d,b,$){super(d,b,$),this.type="style",compressSpaces(Array.from(b.childNodes).map(et=>et.textContent).join("").replace(/(\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+\/)|(^[\s]*\/\/.*)/gm,"").replace(/@import.*;/g,"")).split("}").forEach(et=>{const tt=et.trim();if(!tt)return;const nt=tt.split("{"),rt=nt[0].split(","),it=nt[1].split(";");rt.forEach(st=>{const ot=st.trim();if(!ot)return;const at=d.styles[ot]||{};if(it.forEach(ut=>{const ct=ut.indexOf(":"),dt=ut.substr(0,ct).trim(),ht=ut.substr(ct+1,ut.length-ct).trim();dt&&ht&&(at[dt]=new Property(d,dt,ht))}),d.styles[ot]=at,d.stylesSpecificity[ot]=getSelectorSpecificity(ot),ot==="@font-face"){const ut=at["font-family"].getString().replace(/"|'/g,"");at.src.getString().split(",").forEach(dt=>{if(dt.indexOf('format("svg")')>0){const ht=parseExternalUrl(dt);ht&&new SVGFontLoader(d).load(ut,ht)}})}})})}}StyleElement.parseExternalUrl=parseExternalUrl;class UseElement extends RenderedElement{setContext(d){super.setContext(d);const b=this.getAttribute("x"),$=this.getAttribute("y");b.hasValue()&&d.translate(b.getPixels("x"),0),$.hasValue()&&d.translate(0,$.getPixels("y"))}path(d){const{element:b}=this;b&&b.path(d)}renderChildren(d){const{document:b,element:$}=this;if($){let j=$;if($.type==="symbol"&&(j=new SVGElement(b),j.attributes.viewBox=new Property(b,"viewBox",$.getAttribute("viewBox").getString()),j.attributes.preserveAspectRatio=new Property(b,"preserveAspectRatio",$.getAttribute("preserveAspectRatio").getString()),j.attributes.overflow=new Property(b,"overflow",$.getAttribute("overflow").getString()),j.children=$.children,$.styles.opacity=new Property(b,"opacity",this.calculateOpacity())),j.type==="svg"){const et=this.getStyle("width",!1,!0),tt=this.getStyle("height",!1,!0);et.hasValue()&&(j.attributes.width=new Property(b,"width",et.getString())),tt.hasValue()&&(j.attributes.height=new Property(b,"height",tt.getString()))}const _e=j.parent;j.parent=this,j.render(d),j.parent=_e}}getBoundingBox(d){const{element:b}=this;return b?b.getBoundingBox(d):null}elementTransform(){const{document:d,element:b}=this;return b?Transform.fromElement(d,b):null}get element(){return this.cachedElement||(this.cachedElement=this.getHrefAttribute().getDefinition()),this.cachedElement}constructor(...d){super(...d),this.type="use"}}function imGet(g,d,b,$,j,_e){return g[b*$*4+d*4+_e]}function imSet(g,d,b,$,j,_e,et){g[b*$*4+d*4+_e]=et}function m(g,d,b){return g[d]*b}function c(g,d,b,$){return d+Math.cos(g)*b+Math.sin(g)*$}class FeColorMatrixElement extends Element{apply(d,b,$,j,_e){const{includeOpacity:et,matrix:tt}=this,nt=d.getImageData(0,0,j,_e);for(let rt=0;rt<_e;rt++)for(let it=0;it{at.addBoundingBox(ut.getBoundingBox(d))}),j=Math.floor(at.x1),_e=Math.floor(at.y1),et=Math.floor(at.width),tt=Math.floor(at.height)}const nt=this.removeStyles(b,MaskElement.ignoreStyles),rt=$.createCanvas(j+et,_e+tt),it=rt.getContext("2d");$.screen.setDefaults(it),this.renderChildren(it),new FeColorMatrixElement($,{nodeType:1,childNodes:[],attributes:[{nodeName:"type",value:"luminanceToAlpha"},{nodeName:"includeOpacity",value:"true"}]}).apply(it,0,0,j+et,_e+tt);const st=$.createCanvas(j+et,_e+tt),ot=st.getContext("2d");$.screen.setDefaults(ot),b.render(ot),ot.globalCompositeOperation="destination-in",ot.fillStyle=it.createPattern(rt,"no-repeat"),ot.fillRect(0,0,j+et,_e+tt),d.fillStyle=ot.createPattern(st,"no-repeat"),d.fillRect(0,0,j+et,_e+tt),this.restoreStyles(b,nt)}render(d){}constructor(...d){super(...d),this.type="mask"}}MaskElement.ignoreStyles=["mask","transform","clip-path"];const noop=()=>{};class ClipPathElement extends Element{apply(d){const{document:b}=this,$=Reflect.getPrototypeOf(d),{beginPath:j,closePath:_e}=d;$&&($.beginPath=noop,$.closePath=noop),Reflect.apply(j,d,[]),this.children.forEach(et=>{if(!("path"in et))return;let tt="elementTransform"in et?et.elementTransform():null;tt||(tt=Transform.fromElement(b,et)),tt&&tt.apply(d),et.path(d),$&&($.closePath=_e),tt&&tt.unapply(d)}),Reflect.apply(_e,d,[]),d.clip(),$&&($.beginPath=j,$.closePath=_e)}render(d){}constructor(...d){super(...d),this.type="clipPath"}}class FilterElement extends Element{apply(d,b){const{document:$,children:j}=this,_e="getBoundingBox"in b?b.getBoundingBox(d):null;if(!_e)return;let et=0,tt=0;j.forEach(ht=>{const pt=ht.extraFilterDistance||0;et=Math.max(et,pt),tt=Math.max(tt,pt)});const nt=Math.floor(_e.width),rt=Math.floor(_e.height),it=nt+2*et,st=rt+2*tt;if(it<1||st<1)return;const ot=Math.floor(_e.x),at=Math.floor(_e.y),ut=this.removeStyles(b,FilterElement.ignoreStyles),ct=$.createCanvas(it,st),dt=ct.getContext("2d");$.screen.setDefaults(dt),dt.translate(-ot+et,-at+tt),b.render(dt),j.forEach(ht=>{typeof ht.apply=="function"&&ht.apply(dt,0,0,it,st)}),d.drawImage(ct,0,0,it,st,ot-et,at-tt,it,st),this.restoreStyles(b,ut)}render(d){}constructor(...d){super(...d),this.type="filter"}}FilterElement.ignoreStyles=["filter","transform","clip-path"];class FeDropShadowElement extends Element{apply(d,b,$,j,_e){}constructor(d,b,$){super(d,b,$),this.type="feDropShadow",this.addStylesFromStyleDefinition()}}class FeMorphologyElement extends Element{apply(d,b,$,j,_e){}constructor(...d){super(...d),this.type="feMorphology"}}class FeCompositeElement extends Element{apply(d,b,$,j,_e){}constructor(...d){super(...d),this.type="feComposite"}}class FeGaussianBlurElement extends Element{apply(d,b,$,j,_e){const{document:et,blurRadius:tt}=this,nt=et.window?et.window.document.body:null,rt=d.canvas;rt.id=et.getUniqueId(),nt&&(rt.style.display="none",nt.appendChild(rt)),processCanvasRGBA(rt,b,$,j,_e,tt),nt&&nt.removeChild(rt)}constructor(d,b,$){super(d,b,$),this.type="feGaussianBlur",this.blurRadius=Math.floor(this.getAttribute("stdDeviation").getNumber()),this.extraFilterDistance=this.blurRadius}}class TitleElement extends Element{constructor(...d){super(...d),this.type="title"}}class DescElement extends Element{constructor(...d){super(...d),this.type="desc"}}const elements={svg:SVGElement,rect:RectElement,circle:CircleElement,ellipse:EllipseElement,line:LineElement,polyline:PolylineElement,polygon:PolygonElement,path:PathElement,pattern:PatternElement,marker:MarkerElement,defs:DefsElement,linearGradient:LinearGradientElement,radialGradient:RadialGradientElement,stop:StopElement,animate:AnimateElement,animateColor:AnimateColorElement,animateTransform:AnimateTransformElement,font:FontElement,"font-face":FontFaceElement,"missing-glyph":MissingGlyphElement,glyph:GlyphElement,text:TextElement,tspan:TSpanElement,tref:TRefElement,a:AElement,textPath:TextPathElement,image:ImageElement,g:GElement,symbol:SymbolElement,style:StyleElement,use:UseElement,mask:MaskElement,clipPath:ClipPathElement,filter:FilterElement,feDropShadow:FeDropShadowElement,feMorphology:FeMorphologyElement,feComposite:FeCompositeElement,feColorMatrix:FeColorMatrixElement,feGaussianBlur:FeGaussianBlurElement,title:TitleElement,desc:DescElement};function createCanvas(g,d){const b=document.createElement("canvas");return b.width=g,b.height=d,b}async function createImage(g){let d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;const b=document.createElement("img");return d&&(b.crossOrigin="Anonymous"),new Promise(($,j)=>{b.onload=()=>{$(b)},b.onerror=(_e,et,tt,nt,rt)=>{j(rt)},b.src=g})}const DEFAULT_EM_SIZE=12;class Document{bindCreateImage(d,b){return typeof b=="boolean"?($,j)=>d($,typeof j=="boolean"?j:b):d}get window(){return this.screen.window}get fetch(){return this.screen.fetch}get ctx(){return this.screen.ctx}get emSize(){const{emSizeStack:d}=this;return d[d.length-1]||DEFAULT_EM_SIZE}set emSize(d){const{emSizeStack:b}=this;b.push(d)}popEmSize(){const{emSizeStack:d}=this;d.pop()}getUniqueId(){return"canvg".concat(++this.uniqueId)}isImagesLoaded(){return this.images.every(d=>d.loaded)}isFontsLoaded(){return this.fonts.every(d=>d.loaded)}createDocumentElement(d){const b=this.createElement(d.documentElement);return b.root=!0,b.addStylesFromStyleDefinition(),this.documentElement=b,b}createElement(d){const b=d.nodeName.replace(/^[^:]+:/,""),$=Document.elementTypes[b];return $?new $(this,d):new UnknownElement(this,d)}createTextNode(d){return new TextNode(this,d)}setViewBox(d){this.screen.setViewBox({document:this,...d})}constructor(d,{rootEmSize:b=DEFAULT_EM_SIZE,emSize:$=DEFAULT_EM_SIZE,createCanvas:j=Document.createCanvas,createImage:_e=Document.createImage,anonymousCrossOrigin:et}={}){this.canvg=d,this.definitions={},this.styles={},this.stylesSpecificity={},this.images=[],this.fonts=[],this.emSizeStack=[],this.uniqueId=0,this.screen=d.screen,this.rootEmSize=b,this.emSize=$,this.createCanvas=j,this.createImage=this.bindCreateImage(_e,et),this.screen.wait(()=>this.isImagesLoaded()),this.screen.wait(()=>this.isFontsLoaded())}}Document.createCanvas=createCanvas;Document.createImage=createImage;Document.elementTypes=elements;class Canvg{static async from(d,b){let $=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const _e=await new Parser($).parse(b);return new Canvg(d,_e,$)}static fromString(d,b){let $=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const _e=new Parser($).parseFromString(b);return new Canvg(d,_e,$)}fork(d,b){let $=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return Canvg.from(d,b,{...this.options,...$})}forkString(d,b){let $=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return Canvg.fromString(d,b,{...this.options,...$})}ready(){return this.screen.ready()}isReady(){return this.screen.isReady()}async render(){let d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.start({enableRedraw:!0,ignoreAnimation:!0,ignoreMouse:!0,...d}),await this.ready(),this.stop()}start(){let d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const{documentElement:b,screen:$,options:j}=this;$.start(b,{enableRedraw:!0,...j,...d})}stop(){this.screen.stop()}resize(d){let b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:d,$=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;this.documentElement.resize(d,b,$)}constructor(d,b,$={}){this.parser=new Parser($),this.screen=new Screen(d,$),this.options=$;const j=new Document(this,$),_e=j.createDocumentElement(b);this.document=j,this.documentElement=_e}}const preset=index.offscreen();async function toPng(g){const{width:d,height:b,svg:$}=g;console.log("svg",$);const j=new OffscreenCanvas(d,b),_e=j.getContext("2d");await(await Canvg.from(_e,$.outerHTML,preset)).render();const tt=await j.convertToBlob();return URL.createObjectURL(tt)}function Diagram({ast:g,semantics:d,diagramType:b}){const[$,j]=React.useState(null),[_e,et]=React.useState(null),[tt,nt]=React.useState(null),rt=async()=>{tt?(j(saveSvgUrl(tt)),et(await toPng({svg:tt,width:tt.clientWidth*2,height:tt.clientHeight*2}))):(j(null),et(null))},it=async st=>{nt(st),j(null),et(null)};return jsxRuntimeExports.jsxs("div",{children:[$&&_e?jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{}):jsxRuntimeExports.jsx("button",{onClick:rt,children:"Export"}),$&&_e&&jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("a",{href:$,download:`${b}.svg`,children:"Download SVG"}),jsxRuntimeExports.jsx("span",{children:" | "}),jsxRuntimeExports.jsx("a",{href:_e,download:`${b}.png`,children:"PNG"})]}),b==="evaporating-cloud"&&jsxRuntimeExports.jsx(Cloud,{ast:g,setSvgElem:it}),b==="goal-tree"&&jsxRuntimeExports.jsx(Tree,{semantics:d,setSvgElem:it}),b==="problem-tree"&&jsxRuntimeExports.jsx(Tree,{semantics:d,setSvgElem:it})]})}const exampleGoalTreeText=`Goal: "Make money now and in the future" + +revUp: "Generate more revenue" { + class: CSF +} +costsDown: "Control costs" { + class: CSF +} + +Goal <- revUp +Goal <- costsDown + +keepCust: "Protect relationship with existing customers" +newCust: "Acquire new customers" + +reduceInfra: "Reduce infrastructure spending" +retain: "Retain employees" +marketSalary: "Keep up with market salaries" + +morale: "Maintain employee morale" +features: "Develop new features" + +newCust <- features + +# This is probably the wrong place for 'retain' +features <- retain + +revUp <- newCust +revUp <- keepCust +costsDown <- reduceInfra +retain <- marketSalary +retain <- morale +`,exampleEvaporatingCloudText=` +A: Maximize business performance + +B: Subordinate all decisions to the financial goal + +C: Ensure people are in a state of optimal performance + +D: Subordinate people's needs to the financial goal + +B <- D: *inject* Psychological flow triggers + +D': Attend to people's needs (& let people work) +`,exampleProblemTreeText=` +bad: "Bad user experience" { + class: UDE +} +cluttered: "Cluttered interface" { + class: UDE +} +bad <- cluttered +ux: "Low investment in UX design" +features: "Many features added" +cluttered <- ux && features +`;let GrammarLocation$4=class{constructor(d,b){this.source=d,this.start=b}toString(){return String(this.source)}offset(d){return{line:d.line+this.start.line-1,column:d.line===1?d.column+this.start.column-1:d.column,offset:d.offset+this.start.offset}}static offsetStart(d){return d.source&&typeof d.source.offset=="function"?d.source.offset(d.start):d.start}static offsetEnd(d){return d.source&&typeof d.source.offset=="function"?d.source.offset(d.end):d.end}};var grammarLocation=GrammarLocation$4;const GrammarLocation$3=grammarLocation,setProtoOf=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(g,d){g.__proto__=d}||function(g,d){for(const b in d)Object.prototype.hasOwnProperty.call(d,b)&&(g[b]=d[b])};let GrammarError$3=class Jr extends Error{constructor(d,b,$){super(d),setProtoOf(this,Jr.prototype),this.name="GrammarError",this.location=b,$===void 0&&($=[]),this.diagnostics=$,this.stage=null,this.problems=[["error",d,b,$]]}toString(){let d=super.toString();this.location&&(d+=` + at `,this.location.source!==void 0&&this.location.source!==null&&(d+=`${this.location.source}:`),d+=`${this.location.start.line}:${this.location.start.column}`);for(const b of this.diagnostics)d+=` + from `,b.location.source!==void 0&&b.location.source!==null&&(d+=`${b.location.source}:`),d+=`${b.location.start.line}:${b.location.start.column}: ${b.message}`;return d}format(d){const b=d.map(({source:_e,text:et})=>({source:_e,text:et!=null?String(et).split(/\r\n|\n|\r/g):[]}));function $(_e,et,tt=""){let nt="";const rt=b.find(({source:ot})=>ot===_e.source),it=_e.start,st=GrammarLocation$3.offsetStart(_e);if(rt){const ot=_e.end,at=rt.text[it.line-1],ct=(it.line===ot.line?ot.column:at.length+1)-it.column||1;tt&&(nt+=` +note: ${tt}`),nt+=` + --> ${_e.source}:${st.line}:${st.column} +${"".padEnd(et)} | +${st.line.toString().padStart(et)} | ${at} +${"".padEnd(et)} | ${"".padEnd(it.column-1)}${"".padEnd(ct,"^")}`}else nt+=` + at ${_e.source}:${st.line}:${st.column}`,tt&&(nt+=`: ${tt}`);return nt}function j(_e,et,tt,nt=[]){let rt=-1/0;tt?rt=nt.reduce((st,{location:ot})=>Math.max(st,GrammarLocation$3.offsetStart(ot).line),tt.start.line):rt=Math.max.apply(null,nt.map(st=>st.location.start.line)),rt=rt.toString().length;let it=`${_e}: ${et}`;tt&&(it+=$(tt,rt));for(const st of nt)it+=$(st.location,rt,st.message);return it}return this.problems.filter(_e=>_e[0]!=="info").map(_e=>j(..._e)).join(` + +`)}};var grammarError=GrammarError$3;const visitor$b={build(g){function d(et,...tt){return g[et.type](et,...tt)}function b(){}function $(et,...tt){return d(et.expression,...tt)}function j(et){return function(tt,...nt){tt[et].forEach(rt=>d(rt,...nt))}}const _e={grammar(et,...tt){et.topLevelInitializer&&d(et.topLevelInitializer,...tt),et.initializer&&d(et.initializer,...tt),et.rules.forEach(nt=>d(nt,...tt))},top_level_initializer:b,initializer:b,rule:$,named:$,choice:j("alternatives"),action:$,sequence:j("elements"),labeled:$,text:$,simple_and:$,simple_not:$,optional:$,zero_or_more:$,one_or_more:$,repeated(et,...tt){return et.delimiter&&d(et.delimiter,...tt),d(et.expression,...tt)},group:$,semantic_and:b,semantic_not:b,rule_ref:b,literal:b,class:b,any:b};return Object.keys(_e).forEach(et=>{Object.prototype.hasOwnProperty.call(g,et)||(g[et]=_e[et])}),d}};var visitor_1=visitor$b;const visitor$a=visitor_1,asts$7={findRule(g,d){for(let b=0;b1&&_e.delimiter&&j(_e.delimiter))},semantic_and:$,semantic_not:$,rule_ref(_e){const et=asts$7.findRule(g,_e.name);return et?j(et):void 0},literal(_e){return _e.value!==""},class:b,any:b});return j(d)}};var asts_1=asts$7;const opcodes={PUSH:0,PUSH_EMPTY_STRING:35,PUSH_UNDEFINED:1,PUSH_NULL:2,PUSH_FAILED:3,PUSH_EMPTY_ARRAY:4,PUSH_CURR_POS:5,POP:6,POP_CURR_POS:7,POP_N:8,NIP:9,APPEND:10,WRAP:11,TEXT:12,PLUCK:36,IF:13,IF_ERROR:14,IF_NOT_ERROR:15,IF_LT:30,IF_GE:31,IF_LT_DYNAMIC:32,IF_GE_DYNAMIC:33,WHILE_NOT_ERROR:16,MATCH_ANY:17,MATCH_STRING:18,MATCH_STRING_IC:19,MATCH_CHAR_CLASS:20,MATCH_REGEXP:20,ACCEPT_N:21,ACCEPT_STRING:22,FAIL:23,LOAD_SAVED_POS:24,UPDATE_SAVED_POS:25,CALL:26,RULE:27,SILENT_FAILS_ON:28,SILENT_FAILS_OFF:29,SOURCE_MAP_PUSH:37,SOURCE_MAP_POP:38,SOURCE_MAP_LABEL_PUSH:39,SOURCE_MAP_LABEL_POP:40};var opcodes_1=opcodes;const visitor$9=visitor_1,asts$6=asts_1,GrammarError$2=grammarError,ALWAYS_MATCH$1=1,SOMETIMES_MATCH$1=0,NEVER_MATCH$1=-1;function inferenceMatchResult$1(g){function d(et){return et.match=SOMETIMES_MATCH$1}function b(et){return _e(et.expression),et.match=ALWAYS_MATCH$1}function $(et){return et.match=_e(et.expression)}function j(et,tt){const nt=et.length;let rt=0,it=0;for(let st=0;st0?NEVER_MATCH$1:SOMETIMES_MATCH$1}const _e=visitor$9.build({rule(et){let tt,nt=0;if(typeof et.match>"u"){et.match=SOMETIMES_MATCH$1;do if(tt=et.match,et.match=_e(et.expression),++nt>6)throw new GrammarError$2("Infinity cycle detected when trying to evaluate node match result",et.location);while(tt!==et.match)}return et.match},named:$,choice(et){return et.match=j(et.alternatives,!0)},action:$,sequence(et){return et.match=j(et.elements,!1)},labeled:$,text:$,simple_and:$,simple_not(et){return et.match=-_e(et.expression)},optional:b,zero_or_more:b,one_or_more:$,repeated(et){const tt=_e(et.expression),nt=et.delimiter?_e(et.delimiter):NEVER_MATCH$1,rt=et.min?et.min:et.max;return rt.type!=="constant"||et.max.type!=="constant"?et.match=SOMETIMES_MATCH$1:et.max.value===0||et.max.value!==null&&rt.value>et.max.value?et.match=NEVER_MATCH$1:tt===NEVER_MATCH$1?et.match=rt.value===0?ALWAYS_MATCH$1:NEVER_MATCH$1:tt===ALWAYS_MATCH$1?et.delimiter&&rt.value>=2?et.match=nt:et.match=ALWAYS_MATCH$1:et.delimiter&&rt.value>=2?et.match=nt===NEVER_MATCH$1?NEVER_MATCH$1:SOMETIMES_MATCH$1:et.match=rt.value===0?ALWAYS_MATCH$1:SOMETIMES_MATCH$1},group:$,semantic_and:d,semantic_not:d,rule_ref(et){const tt=asts$6.findRule(g,et.name);return et.match=_e(tt)},literal(et){const tt=et.value.length===0?ALWAYS_MATCH$1:SOMETIMES_MATCH$1;return et.match=tt},class(et){const tt=et.parts.length===0?NEVER_MATCH$1:SOMETIMES_MATCH$1;return et.match=tt},any:d});_e(g)}inferenceMatchResult$1.ALWAYS_MATCH=ALWAYS_MATCH$1;inferenceMatchResult$1.SOMETIMES_MATCH=SOMETIMES_MATCH$1;inferenceMatchResult$1.NEVER_MATCH=NEVER_MATCH$1;var inferenceMatchResult_1=inferenceMatchResult$1;const asts$5=asts_1,op$1=opcodes_1,visitor$8=visitor_1,{ALWAYS_MATCH,SOMETIMES_MATCH,NEVER_MATCH}=inferenceMatchResult_1;function generateBytecode$1(g,d){const b=[],$=[],j=[],_e=[],et=[];function tt(Ct){const wt=b.indexOf(Ct);return wt===-1?b.push(Ct)-1:wt}function nt(Ct){const wt={value:Ct.parts,inverted:Ct.inverted,ignoreCase:Ct.ignoreCase},Tt=JSON.stringify(wt),Bt=$.findIndex(Ft=>JSON.stringify(Ft)===Tt);return Bt===-1?$.push(wt)-1:Bt}function rt(Ct){const wt=JSON.stringify(Ct),Tt=j.findIndex(Bt=>JSON.stringify(Bt)===wt);return Tt===-1?j.push(Ct)-1:Tt}function it(Ct,wt,Tt){const Bt={predicate:Ct,params:wt,body:Tt.code,location:Tt.codeLocation},Ft=JSON.stringify(Bt),Vt=_e.findIndex(Wt=>JSON.stringify(Wt)===Ft);return Vt===-1?_e.push(Bt)-1:Vt}function st(Ct){return et.push(Ct)-1}function ot(Ct){const wt={};return Object.keys(Ct).forEach(Tt=>{wt[Tt]=Ct[Tt]}),wt}function at(Ct,...wt){return Ct.concat(...wt)}function ut(Ct,wt,Tt,Bt){return Ct===ALWAYS_MATCH?Tt:Ct===NEVER_MATCH?Bt:wt.concat([Tt.length,Bt.length],Tt,Bt)}function ct(Ct,wt){return Ct.concat([wt.length],wt)}function dt(Ct,wt,Tt,Bt){const Ft=Object.keys(Tt).map(Vt=>Bt-Tt[Vt]);return[op$1.CALL,Ct,wt,Ft.length].concat(Ft)}function ht(Ct,wt,Tt){const Bt=Ct.match|0;return at([op$1.PUSH_CURR_POS],[op$1.SILENT_FAILS_ON],Pt(Ct,{sp:Tt.sp+1,env:ot(Tt.env),action:null}),[op$1.SILENT_FAILS_OFF],ut(wt?-Bt:Bt,[wt?op$1.IF_ERROR:op$1.IF_NOT_ERROR],at([op$1.POP],[wt?op$1.POP:op$1.POP_CURR_POS],[op$1.PUSH_UNDEFINED]),at([op$1.POP],[wt?op$1.POP_CURR_POS:op$1.POP],[op$1.PUSH_FAILED])))}function pt(Ct,wt,Tt){const Bt=it(!0,Object.keys(Tt.env),Ct);return at([op$1.UPDATE_SAVED_POS],dt(Bt,0,Tt.env,Tt.sp),ut(Ct.match|0,[op$1.IF],at([op$1.POP],wt?[op$1.PUSH_FAILED]:[op$1.PUSH_UNDEFINED]),at([op$1.POP],wt?[op$1.PUSH_UNDEFINED]:[op$1.PUSH_FAILED])))}function gt(Ct){return ct([op$1.WHILE_NOT_ERROR],at([op$1.APPEND],Ct))}function yt(Ct,wt,Tt,Bt){switch(Ct.type){case"constant":return{pre:[],post:[],sp:Tt};case"variable":return Ct.sp=Bt+Tt-wt[Ct.value],{pre:[],post:[],sp:Tt};case"function":{Ct.sp=Bt;const Ft=it(!0,Object.keys(wt),{code:Ct.value,codeLocation:Ct.codeLocation});return{pre:dt(Ft,0,wt,Tt),post:[op$1.NIP],sp:Tt+1}}default:throw new Error(`Unknown boundary type "${Ct.type}" for the "repeated" node`)}}function vt(Ct,wt){if(wt.value!==null){const Tt=wt.type==="constant"?[op$1.IF_GE,wt.value]:[op$1.IF_GE_DYNAMIC,wt.sp];return ut(SOMETIMES_MATCH,Tt,[op$1.PUSH_FAILED],Ct)}return Ct}function St(Ct,wt){const Tt=wt.type==="constant"?[op$1.IF_LT,wt.value]:[op$1.IF_LT_DYNAMIC,wt.sp];return at(Ct,ut(SOMETIMES_MATCH,Tt,[op$1.POP,op$1.POP_CURR_POS,op$1.PUSH_FAILED],[op$1.NIP]))}function xt(Ct,wt,Tt,Bt,Ft){return Ct?at([op$1.PUSH_CURR_POS],Pt(Ct,{sp:Bt.sp+Ft+1,env:ot(Bt.env),action:null}),ut(Ct.match|0,[op$1.IF_NOT_ERROR],at([op$1.POP],Tt,ut(-wt,[op$1.IF_ERROR],[op$1.POP,op$1.POP_CURR_POS,op$1.PUSH_FAILED],[op$1.NIP])),[op$1.NIP])):Tt}function Dt(Ct){return d&&d.output==="source-and-map"&&Object.entries(Ct).forEach(([wt,Tt])=>{Ct[wt]=function(Bt,...Ft){const Vt=Tt(Bt,...Ft);return Vt===void 0||!Bt.location?Vt:at([op$1.SOURCE_MAP_PUSH,st(Bt.location)],Vt,[op$1.SOURCE_MAP_POP])}}),visitor$8.build(Ct)}const Pt=Dt({grammar(Ct){Ct.rules.forEach(Pt),Ct.literals=b,Ct.classes=$,Ct.expectations=j,Ct.functions=_e,Ct.locations=et},rule(Ct){Ct.bytecode=Pt(Ct.expression,{sp:-1,env:{},pluck:[],action:null})},named(Ct,wt){const Tt=Ct.match|0,Bt=Tt===NEVER_MATCH?null:rt({type:"rule",value:Ct.name});return at([op$1.SILENT_FAILS_ON],Pt(Ct.expression,wt),[op$1.SILENT_FAILS_OFF],ut(Tt,[op$1.IF_ERROR],[op$1.FAIL,Bt],[]))},choice(Ct,wt){function Tt(Bt,Ft){const Vt=Bt[0].match|0,Wt=Pt(Bt[0],{sp:Ft.sp,env:ot(Ft.env),action:null});return Vt===ALWAYS_MATCH?Wt:at(Wt,Bt.length>1?ut(SOMETIMES_MATCH,[op$1.IF_ERROR],at([op$1.POP],Tt(Bt.slice(1),Ft)),[]):[])}return Tt(Ct.alternatives,wt)},action(Ct,wt){const Tt=ot(wt.env),Bt=Ct.expression.type!=="sequence"||Ct.expression.elements.length===0,Ft=Pt(Ct.expression,{sp:wt.sp+(Bt?1:0),env:Tt,action:Ct}),Vt=Ct.expression.match|0,Wt=Bt&&Vt!==NEVER_MATCH?it(!1,Object.keys(Tt),Ct):null;return Bt?at([op$1.PUSH_CURR_POS],Ft,ut(Vt,[op$1.IF_NOT_ERROR],at([op$1.LOAD_SAVED_POS,1],dt(Wt,1,Tt,wt.sp+2)),[]),[op$1.NIP]):Ft},sequence(Ct,wt){function Tt(Bt,Ft){if(Bt.length>0){const Vt=Ct.elements.length-Bt.length+1;return at(Pt(Bt[0],{sp:Ft.sp,env:Ft.env,pluck:Ft.pluck,action:null}),ut(Bt[0].match|0,[op$1.IF_NOT_ERROR],Tt(Bt.slice(1),{sp:Ft.sp+1,env:Ft.env,pluck:Ft.pluck,action:Ft.action}),at(Vt>1?[op$1.POP_N,Vt]:[op$1.POP],[op$1.POP_CURR_POS],[op$1.PUSH_FAILED])))}else{if(Ft.pluck.length>0)return at([op$1.PLUCK,Ct.elements.length+1,Ft.pluck.length],Ft.pluck.map(Vt=>Ft.sp-Vt));if(Ft.action){const Vt=it(!1,Object.keys(Ft.env),Ft.action);return at([op$1.LOAD_SAVED_POS,Ct.elements.length],dt(Vt,Ct.elements.length+1,Ft.env,Ft.sp))}else return at([op$1.WRAP,Ct.elements.length],[op$1.NIP])}}return at([op$1.PUSH_CURR_POS],Tt(Ct.elements,{sp:wt.sp+1,env:wt.env,pluck:[],action:wt.action}))},labeled(Ct,wt){let Tt=wt.env;const Bt=Ct.label,Ft=wt.sp+1;Bt&&(Tt=ot(wt.env),wt.env[Ct.label]=Ft),Ct.pick&&wt.pluck.push(Ft);const Vt=Pt(Ct.expression,{sp:wt.sp,env:Tt,action:null});return Bt&&Ct.labelLocation&&d&&d.output==="source-and-map"?at([op$1.SOURCE_MAP_LABEL_PUSH,Ft,tt(Bt),st(Ct.labelLocation)],Vt,[op$1.SOURCE_MAP_LABEL_POP,Ft]):Vt},text(Ct,wt){return at([op$1.PUSH_CURR_POS],Pt(Ct.expression,{sp:wt.sp+1,env:ot(wt.env),action:null}),ut(Ct.match|0,[op$1.IF_NOT_ERROR],at([op$1.POP],[op$1.TEXT]),[op$1.NIP]))},simple_and(Ct,wt){return ht(Ct.expression,!1,wt)},simple_not(Ct,wt){return ht(Ct.expression,!0,wt)},optional(Ct,wt){return at(Pt(Ct.expression,{sp:wt.sp,env:ot(wt.env),action:null}),ut(-(Ct.expression.match|0),[op$1.IF_ERROR],at([op$1.POP],[op$1.PUSH_NULL]),[]))},zero_or_more(Ct,wt){const Tt=Pt(Ct.expression,{sp:wt.sp+1,env:ot(wt.env),action:null});return at([op$1.PUSH_EMPTY_ARRAY],Tt,gt(Tt),[op$1.POP])},one_or_more(Ct,wt){const Tt=Pt(Ct.expression,{sp:wt.sp+1,env:ot(wt.env),action:null});return at([op$1.PUSH_EMPTY_ARRAY],Tt,ut(Ct.expression.match|0,[op$1.IF_NOT_ERROR],at(gt(Tt),[op$1.POP]),at([op$1.POP],[op$1.POP],[op$1.PUSH_FAILED])))},repeated(Ct,wt){const Tt=Ct.min?Ct.min:Ct.max,Bt=Tt.type!=="constant"||Tt.value>0,Ft=Ct.max.type!=="constant"&&Ct.max.value!==null,Vt=Bt?2:1,Wt=Ct.min?yt(Ct.min,wt.env,wt.sp,2+(Ct.max.type==="function"?1:0)):{pre:[],post:[],sp:wt.sp},Ht=yt(Ct.max,wt.env,Wt.sp,Vt),Ot=Pt(Ct.expression,{sp:Ht.sp+Vt,env:ot(wt.env),action:null}),Lt=Ct.delimiter!==null?Pt(Ct.expression,{sp:Ht.sp+Vt+1,env:ot(wt.env),action:null}):Ot,It=xt(Ct.delimiter,Ct.expression.match|0,Lt,wt,Vt),Ut=vt(It,Ct.max),Gt=Ft?vt(Ot,Ct.max):Ot,tn=at(Bt?[op$1.PUSH_CURR_POS]:[],[op$1.PUSH_EMPTY_ARRAY],Gt,gt(Ut),[op$1.POP]);return at(Wt.pre,Ht.pre,Bt?St(tn,Tt):tn,Ht.post,Wt.post)},group(Ct,wt){return Pt(Ct.expression,{sp:wt.sp,env:ot(wt.env),action:null})},semantic_and(Ct,wt){return pt(Ct,!1,wt)},semantic_not(Ct,wt){return pt(Ct,!0,wt)},rule_ref(Ct){return[op$1.RULE,asts$5.indexOfRule(g,Ct.name)]},literal(Ct){if(Ct.value.length>0){const wt=Ct.match|0,Bt=wt===SOMETIMES_MATCH||wt===ALWAYS_MATCH&&!Ct.ignoreCase?tt(Ct.ignoreCase?Ct.value.toLowerCase():Ct.value):null,Ft=wt!==ALWAYS_MATCH?rt({type:"literal",value:Ct.value,ignoreCase:Ct.ignoreCase}):null;return ut(wt,Ct.ignoreCase?[op$1.MATCH_STRING_IC,Bt]:[op$1.MATCH_STRING,Bt],Ct.ignoreCase?[op$1.ACCEPT_N,Ct.value.length]:[op$1.ACCEPT_STRING,Bt],[op$1.FAIL,Ft])}return[op$1.PUSH_EMPTY_STRING]},class(Ct){const wt=Ct.match|0,Tt=wt===SOMETIMES_MATCH?nt(Ct):null,Bt=wt!==ALWAYS_MATCH?rt({type:"class",value:Ct.parts,inverted:Ct.inverted,ignoreCase:Ct.ignoreCase}):null;return ut(wt,[op$1.MATCH_CHAR_CLASS,Tt],[op$1.ACCEPT_N,1],[op$1.FAIL,Bt])},any(Ct){const wt=Ct.match|0,Tt=wt!==ALWAYS_MATCH?rt({type:"any"}):null;return ut(wt,[op$1.MATCH_ANY],[op$1.ACCEPT_N,1],[op$1.FAIL,Tt])}});Pt(g)}var generateBytecode_1=generateBytecode$1,sourceMap={},sourceMapGenerator={},base64Vlq={},base64$3={};const intToCharMap="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");base64$3.encode=function(g){if(0<=g&&g>>=VLQ_BASE_SHIFT,j>0&&($|=VLQ_CONTINUATION_BIT),b+=base64$2.encode($);while(j>0);return b};var util$3={};function getArg(g,d,b){if(d in g)return g[d];if(arguments.length===3)return b;throw new Error('"'+d+'" is a required argument.')}util$3.getArg=getArg;const supportsNullProto=function(){return!("__proto__"in Object.create(null))}();function identity(g){return g}function toSetString(g){return isProtoString(g)?"$"+g:g}util$3.toSetString=supportsNullProto?identity:toSetString;function fromSetString(g){return isProtoString(g)?g.slice(1):g}util$3.fromSetString=supportsNullProto?identity:fromSetString;function isProtoString(g){if(!g)return!1;const d=g.length;if(d<9||g.charCodeAt(d-1)!==95||g.charCodeAt(d-2)!==95||g.charCodeAt(d-3)!==111||g.charCodeAt(d-4)!==116||g.charCodeAt(d-5)!==111||g.charCodeAt(d-6)!==114||g.charCodeAt(d-7)!==112||g.charCodeAt(d-8)!==95||g.charCodeAt(d-9)!==95)return!1;for(let b=d-10;b>=0;b--)if(g.charCodeAt(b)!==36)return!1;return!0}function strcmp(g,d){return g===d?0:g===null?1:d===null?-1:g>d?1:-1}function compareByGeneratedPositionsInflated(g,d){let b=g.generatedLine-d.generatedLine;return b!==0||(b=g.generatedColumn-d.generatedColumn,b!==0)||(b=strcmp(g.source,d.source),b!==0)||(b=g.originalLine-d.originalLine,b!==0)||(b=g.originalColumn-d.originalColumn,b!==0)?b:strcmp(g.name,d.name)}util$3.compareByGeneratedPositionsInflated=compareByGeneratedPositionsInflated;const PROTOCOL="http:",PROTOCOL_AND_HOST=`${PROTOCOL}//host`;function createSafeHandler(g){return d=>{const b=getURLType(d),$=buildSafeBase(d),j=new URL(d,$);g(j);const _e=j.toString();return b==="absolute"?_e:b==="scheme-relative"?_e.slice(PROTOCOL.length):b==="path-absolute"?_e.slice(PROTOCOL_AND_HOST.length):computeRelativeURL($,_e)}}function withBase(g,d){return new URL(g,d).toString()}function buildUniqueSegment(g,d){let b=0;do{const $=g+b++;if(d.indexOf($)===-1)return $}while(!0)}function buildSafeBase(g){const d=g.split("..").length-1,b=buildUniqueSegment("p",g);let $=`${PROTOCOL_AND_HOST}/`;for(let j=0;j0&&!$[$.length-1]&&$.pop();b.length>0&&$.length>0&&b[0]===$[0];)b.shift(),$.shift();return $.map(()=>"..").concat(b).join("/")+d.search+d.hash}const ensureDirectory=createSafeHandler(g=>{g.pathname=g.pathname.replace(/\/?$/,"/")}),normalize=createSafeHandler(g=>{});util$3.normalize=normalize;function join(g,d){const b=getURLType(d),$=getURLType(g);if(g=ensureDirectory(g),b==="absolute")return withBase(d,void 0);if($==="absolute")return withBase(d,g);if(b==="scheme-relative")return normalize(d);if($==="scheme-relative")return withBase(d,withBase(g,PROTOCOL_AND_HOST)).slice(PROTOCOL.length);if(b==="path-absolute")return normalize(d);if($==="path-absolute")return withBase(d,withBase(g,PROTOCOL_AND_HOST)).slice(PROTOCOL_AND_HOST.length);const j=buildSafeBase(d+g),_e=withBase(d,withBase(g,j));return computeRelativeURL(j,_e)}util$3.join=join;function relative(g,d){const b=relativeIfPossible(g,d);return typeof b=="string"?b:normalize(d)}util$3.relative=relative;function relativeIfPossible(g,d){if(getURLType(g)!==getURLType(d))return null;const $=buildSafeBase(g+d),j=new URL(g,$),_e=new URL(d,$);try{new URL("",_e.toString())}catch{return null}return _e.protocol!==j.protocol||_e.user!==j.user||_e.password!==j.password||_e.hostname!==j.hostname||_e.port!==j.port?null:computeRelativeURL(j,_e)}var arraySet={};let ArraySet$1=class _i{constructor(){this._array=[],this._set=new Map}static fromArray(d,b){const $=new _i;for(let j=0,_e=d.length;j<_e;j++)$.add(d[j],b);return $}size(){return this._set.size}add(d,b){const $=this.has(d),j=this._array.length;(!$||b)&&this._array.push(d),$||this._set.set(d,j)}has(d){return this._set.has(d)}indexOf(d){const b=this._set.get(d);if(b>=0)return b;throw new Error('"'+d+'" is not in the set.')}at(d){if(d>=0&&db||$==b&&_e>=j||util$2.compareByGeneratedPositionsInflated(g,d)<=0}let MappingList$1=class{constructor(){this._array=[],this._sorted=!0,this._last={generatedLine:-1,generatedColumn:0}}unsortedForEach(d,b){this._array.forEach(d,b)}add(d){generatedPositionAfter(this._last,d)?(this._last=d,this._array.push(d)):(this._sorted=!1,this._array.push(d))}toArray(){return this._sorted||(this._array.sort(util$2.compareByGeneratedPositionsInflated),this._sorted=!0),this._array}};mappingList.MappingList=MappingList$1;const base64VLQ=base64Vlq,util$1=util$3,ArraySet=arraySet.ArraySet,MappingList=mappingList.MappingList;let SourceMapGenerator$1=class es{constructor(d){d||(d={}),this._file=util$1.getArg(d,"file",null),this._sourceRoot=util$1.getArg(d,"sourceRoot",null),this._skipValidation=util$1.getArg(d,"skipValidation",!1),this._sources=new ArraySet,this._names=new ArraySet,this._mappings=new MappingList,this._sourcesContents=null}static fromSourceMap(d){const b=d.sourceRoot,$=new es({file:d.file,sourceRoot:b});return d.eachMapping(function(j){const _e={generated:{line:j.generatedLine,column:j.generatedColumn}};j.source!=null&&(_e.source=j.source,b!=null&&(_e.source=util$1.relative(b,_e.source)),_e.original={line:j.originalLine,column:j.originalColumn},j.name!=null&&(_e.name=j.name)),$.addMapping(_e)}),d.sources.forEach(function(j){let _e=j;b!=null&&(_e=util$1.relative(b,j)),$._sources.has(_e)||$._sources.add(_e);const et=d.sourceContentFor(j);et!=null&&$.setSourceContent(j,et)}),$}addMapping(d){const b=util$1.getArg(d,"generated"),$=util$1.getArg(d,"original",null);let j=util$1.getArg(d,"source",null),_e=util$1.getArg(d,"name",null);this._skipValidation||this._validateMapping(b,$,j,_e),j!=null&&(j=String(j),this._sources.has(j)||this._sources.add(j)),_e!=null&&(_e=String(_e),this._names.has(_e)||this._names.add(_e)),this._mappings.add({generatedLine:b.line,generatedColumn:b.column,originalLine:$&&$.line,originalColumn:$&&$.column,source:j,name:_e})}setSourceContent(d,b){let $=d;this._sourceRoot!=null&&($=util$1.relative(this._sourceRoot,$)),b!=null?(this._sourcesContents||(this._sourcesContents=Object.create(null)),this._sourcesContents[util$1.toSetString($)]=b):this._sourcesContents&&(delete this._sourcesContents[util$1.toSetString($)],Object.keys(this._sourcesContents).length===0&&(this._sourcesContents=null))}applySourceMap(d,b,$){let j=b;if(b==null){if(d.file==null)throw new Error(`SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, or the source map's "file" property. Both were omitted.`);j=d.file}const _e=this._sourceRoot;_e!=null&&(j=util$1.relative(_e,j));const et=this._mappings.toArray().length>0?new ArraySet:this._sources,tt=new ArraySet;this._mappings.unsortedForEach(function(nt){if(nt.source===j&&nt.originalLine!=null){const st=d.originalPositionFor({line:nt.originalLine,column:nt.originalColumn});st.source!=null&&(nt.source=st.source,$!=null&&(nt.source=util$1.join($,nt.source)),_e!=null&&(nt.source=util$1.relative(_e,nt.source)),nt.originalLine=st.line,nt.originalColumn=st.column,st.name!=null&&(nt.name=st.name))}const rt=nt.source;rt!=null&&!et.has(rt)&&et.add(rt);const it=nt.name;it!=null&&!tt.has(it)&&tt.add(it)},this),this._sources=et,this._names=tt,d.sources.forEach(function(nt){const rt=d.sourceContentFor(nt);rt!=null&&($!=null&&(nt=util$1.join($,nt)),_e!=null&&(nt=util$1.relative(_e,nt)),this.setSourceContent(nt,rt))},this)}_validateMapping(d,b,$,j){if(b&&typeof b.line!="number"&&typeof b.column!="number")throw new Error("original.line and original.column are not numbers -- you probably meant to omit the original mapping entirely and only map the generated position. If so, pass null for the original mapping instead of an object with empty or null values.");if(!(d&&"line"in d&&"column"in d&&d.line>0&&d.column>=0&&!b&&!$&&!j)){if(!(d&&"line"in d&&"column"in d&&b&&"line"in b&&"column"in b&&d.line>0&&d.column>=0&&b.line>0&&b.column>=0&&$))throw new Error("Invalid mapping: "+JSON.stringify({generated:d,source:$,original:b,name:j}))}}_serializeMappings(){let d=0,b=1,$=0,j=0,_e=0,et=0,tt="",nt,rt,it,st;const ot=this._mappings.toArray();for(let at=0,ut=ot.length;at0){if(!util$1.compareByGeneratedPositionsInflated(rt,ot[at-1]))continue;nt+=","}nt+=base64VLQ.encode(rt.generatedColumn-d),d=rt.generatedColumn,rt.source!=null&&(st=this._sources.indexOf(rt.source),nt+=base64VLQ.encode(st-et),et=st,nt+=base64VLQ.encode(rt.originalLine-1-j),j=rt.originalLine-1,nt+=base64VLQ.encode(rt.originalColumn-$),$=rt.originalColumn,rt.name!=null&&(it=this._names.indexOf(rt.name),nt+=base64VLQ.encode(it-_e),_e=it)),tt+=nt}return tt}_generateSourcesContent(d,b){return d.map(function($){if(!this._sourcesContents)return null;b!=null&&($=util$1.relative(b,$));const j=util$1.toSetString($);return Object.prototype.hasOwnProperty.call(this._sourcesContents,j)?this._sourcesContents[j]:null},this)}toJSON(){const d={version:this._version,sources:this._sources.toArray(),names:this._names.toArray(),mappings:this._serializeMappings()};return this._file!=null&&(d.file=this._file),this._sourceRoot!=null&&(d.sourceRoot=this._sourceRoot),this._sourcesContents&&(d.sourcesContent=this._generateSourcesContent(d.sources,d.sourceRoot)),d}toString(){return JSON.stringify(this.toJSON())}};SourceMapGenerator$1.prototype._version=3;sourceMapGenerator.SourceMapGenerator=SourceMapGenerator$1;var sourceNode={};const SourceMapGenerator=sourceMapGenerator.SourceMapGenerator,util=util$3,REGEX_NEWLINE=/(\r?\n)/,NEWLINE_CODE=10,isSourceNode="$$$isSourceNode$$$";let SourceNode$2=class Pr{constructor(d,b,$,j,_e){this.children=[],this.sourceContents={},this.line=d??null,this.column=b??null,this.source=$??null,this.name=_e??null,this[isSourceNode]=!0,j!=null&&this.add(j)}static fromStringWithSourceMap(d,b,$){const j=new Pr,_e=d.split(REGEX_NEWLINE);let et=0;const tt=function(){const at=ct(),ut=ct()||"";return at+ut;function ct(){return et<_e.length?_e[et++]:void 0}};let nt=1,rt=0,it=null,st;return b.eachMapping(function(at){if(it!==null)if(nt=0;b--)this.prepend(d[b]);else if(d[isSourceNode]||typeof d=="string")this.children.unshift(d);else throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got "+d);return this}walk(d){let b;for(let $=0,j=this.children.length;$0){for(b=[],$=0;$' at an index ${d}. +Bytecode: ${this.bytecode}`);return this.varName+d}static sourceNode(d,b,$){const j=GrammarLocation$2.offsetStart(d);return new SourceNode$1(j.line,j.column?j.column-1:null,String(d.source),b,$)}push(d){++this.sp>this.maxSp&&(this.maxSp=this.sp);const b=this.labels[this.sp],$=[this.name(this.sp)," = ",d,";"];if(b)if(this.sourceMapStack.length){const j=dr.sourceNode(b.location,$.splice(0,2),b.label),{parts:_e,location:et}=this.sourceMapPopInternal(),tt=et.start.offsetthis.name(this.sp+1+$))):this.name(this.sp--)}top(){return this.name(this.sp)}index(d){if(d<0)throw new RangeError(`Rule '${this.ruleName}': The variable stack overflow: attempt to get a variable at a negative index ${d}. +Bytecode: ${this.bytecode}`);return this.name(this.sp-d)}result(){if(this.maxSp<0)throw new RangeError(`Rule '${this.ruleName}': The variable stack is empty, can't get the result. +Bytecode: ${this.bytecode}`);return this.name(0)}defines(){return this.maxSp<0?"":this.type+" "+Array.from({length:this.maxSp+1},(d,b)=>this.name(b)).join(", ")+";"}checkedIf(d,b,$){const j=this.sp;if(b(),$){const _e=this.sp;if(this.sp=j,$(),_e!==this.sp)throw new Error("Rule '"+this.ruleName+"', position "+d+": Branches of a condition can't move the stack pointer differently (before: "+j+", after then: "+_e+", after else: "+this.sp+"). Bytecode: "+this.bytecode)}}checkedLoop(d,b){const $=this.sp;if(b(),$!==this.sp)throw new Error("Rule '"+this.ruleName+"', position "+d+": Body of a loop can't move the stack pointer (before: "+$+", after: "+this.sp+"). Bytecode: "+this.bytecode)}sourceMapPush(d,b){if(this.sourceMapStack.length){const $=this.sourceMapStack[this.sourceMapStack.length-1];$[2].start.offset===b.start.offset&&$[2].end.offset>b.end.offset&&($[2]={start:b.end,end:$[2].end,source:$[2].source})}this.sourceMapStack.push([d,d.length,b])}sourceMapPopInternal(){const[d,b,$]=this.sourceMapStack.pop(),j=d.splice(b).map(_e=>_e instanceof SourceNode$1?_e:_e+` +`);if(j.length){const _e=GrammarLocation$2.offsetStart($);d.push(new SourceNode$1(_e.line,_e.column-1,String($.source),j))}return{parts:d,location:$}}sourceMapPop(d){const{location:b}=this.sourceMapPopInternal();if(this.sourceMapStack.length&&b.end.offset"\\x0"+hex(d)).replace(/[\x10-\x1F\x7F-\xFF]/g,d=>"\\x"+hex(d)).replace(/[\u0100-\u0FFF]/g,d=>"\\u0"+hex(d)).replace(/[\u1000-\uFFFF]/g,d=>"\\u"+hex(d))}utils.stringEscape=stringEscape$1;function regexpClassEscape$1(g){return g.replace(/\\/g,"\\\\").replace(/\//g,"\\/").replace(/]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\x08/g,"\\b").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\v/g,"\\v").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,d=>"\\x0"+hex(d)).replace(/[\x10-\x1F\x7F-\xFF]/g,d=>"\\x"+hex(d)).replace(/[\u0100-\u0FFF]/g,d=>"\\u0"+hex(d)).replace(/[\u1000-\uFFFF]/g,d=>"\\u"+hex(d))}utils.regexpClassEscape=regexpClassEscape$1;function base64$1(g){const d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",b=g.length%3,$=g.length-b;let j="";for(let _e=0;_e<$;_e+=3)j+=d[g[_e]>>2],j+=d[(g[_e]&3)<<4|g[_e+1]>>4],j+=d[(g[_e+1]&15)<<2|g[_e+2]>>6],j+=d[g[_e+2]&63];return b===1?(j+=d[g[$]>>2],j+=d[(g[$]&3)<<4],j+="=="):b===2&&(j+=d[g[$]>>2],j+=d[(g[$]&3)<<4|g[$+1]>>4],j+=d[(g[$+1]&15)<<2],j+="="),j}utils.base64=base64$1;const asts$4=asts_1,op=opcodes_1,Stack=stack,VERSION$1=version,{stringEscape,regexpClassEscape}=utils,{SourceNode}=sourceMap,GrammarLocation$1=grammarLocation;function toSourceNode(g,d,b){const $=GrammarLocation$1.offsetStart(d),j=$.line,_e=$.column-1,et=g.split(` +`);return et.length===1?new SourceNode(j,_e,String(d.source),g,b):new SourceNode(null,null,String(d.source),et.map((tt,nt)=>new SourceNode(j+nt,nt===0?_e:0,String(d.source),nt===et.length-1?tt:[tt,` +`],b)))}function wrapInSourceNode(g,d,b,$,j){if(b){const _e=GrammarLocation$1.offsetEnd(b);return new SourceNode(null,null,String(b.source),[g,toSourceNode(d,b,j),new SourceNode(_e.line,_e.column-1,String(b.source),$)])}return new SourceNode(null,null,null,[g,d,$])}function generateJS$1(g,d){function b(ct){let dt=!0,ht=0;function pt(gt){return Array.isArray(gt)?gt.map(pt):gt instanceof SourceNode?(ht++,gt.children=pt(gt.children),ht--,gt):(dt?gt=gt.replace(/^(.+)$/gm," $1"):gt=gt.replace(/\n(\s*\S)/g,` + $1`),dt=!ht||gt.endsWith(` +`),gt)}return pt(ct)}function $(ct){return"peg$c"+ct}function j(ct){return"peg$r"+ct}function _e(ct){return"peg$e"+ct}function et(ct){return"peg$f"+ct}function tt(ct){return"peg$parse"+ct}function nt(){function ct(gt){return'"'+stringEscape(gt)+'"'}function dt(gt){return"/^["+(gt.inverted?"^":"")+gt.value.map(yt=>Array.isArray(yt)?regexpClassEscape(yt[0])+"-"+regexpClassEscape(yt[1]):regexpClassEscape(yt)).join("")+"]/"+(gt.ignoreCase?"i":"")}function ht(gt){switch(gt.type){case"rule":return'peg$otherExpectation("'+stringEscape(gt.value)+'")';case"literal":return'peg$literalExpectation("'+stringEscape(gt.value)+'", '+gt.ignoreCase+")";case"class":return"peg$classExpectation(["+gt.value.map(vt=>Array.isArray(vt)?'["'+stringEscape(vt[0])+'", "'+stringEscape(vt[1])+'"]':'"'+stringEscape(vt)+'"').join(", ")+"], "+gt.inverted+", "+gt.ignoreCase+")";case"any":return"peg$anyExpectation()";default:throw new Error("Unknown expectation type ("+JSON.stringify(gt)+")")}}function pt(gt,yt){return wrapInSourceNode(` + var ${et(yt)} = function(${gt.params.join(", ")}) {`,gt.body,gt.location,"};")}return new SourceNode(null,null,d.grammarSource,[g.literals.map((gt,yt)=>" var "+$(yt)+" = "+ct(gt)+";").concat("",g.classes.map((gt,yt)=>" var "+j(yt)+" = "+dt(gt)+";")).concat("",g.expectations.map((gt,yt)=>" var "+_e(yt)+" = "+ht(gt)+";")).concat("").join(` +`),g.functions.map(pt)])}function rt(ct,dt){const ht=[];return ht.push(""),d.trace&&ht.push("peg$tracer.trace({",' type: "rule.enter",'," rule: "+ct+","," location: peg$computeLocation(startPos, startPos, true)","});",""),d.cache&&(ht.push("var key = peg$currPos * "+g.rules.length+" + "+dt+";","var cached = peg$resultsCache[key];","","if (cached) {"," peg$currPos = cached.nextPos;",""),d.trace&&ht.push("if (cached.result !== peg$FAILED) {"," peg$tracer.trace({",' type: "rule.match",'," rule: "+ct+","," result: cached.result,"," location: peg$computeLocation(startPos, peg$currPos, true)"," });","} else {"," peg$tracer.trace({",' type: "rule.fail",'," rule: "+ct+","," location: peg$computeLocation(startPos, startPos, true)"," });","}",""),ht.push(" return cached.result;","}","")),ht}function it(ct,dt){const ht=[];return d.cache&&ht.push("","peg$resultsCache[key] = { nextPos: peg$currPos, result: "+dt+" };"),d.trace&&ht.push("","if ("+dt+" !== peg$FAILED) {"," peg$tracer.trace({",' type: "rule.match",'," rule: "+ct+","," result: "+dt+","," location: peg$computeLocation(startPos, peg$currPos, true)"," });","} else {"," peg$tracer.trace({",' type: "rule.fail",'," rule: "+ct+","," location: peg$computeLocation(startPos, startPos, true)"," });","}"),ht.push("","return "+dt+";"),ht}function st(ct){const dt=[],ht=new Stack(ct.name,"s","var",ct.bytecode);function pt(yt){let vt=0;const St=yt.length,xt=[];let Dt;function Pt(Tt,Bt){const Ft=Bt+3,Vt=yt[vt+Ft-2],Wt=yt[vt+Ft-1];let Ht,Ot;ht.checkedIf(vt,()=>{vt+=Ft,Ht=pt(yt.slice(vt,vt+Vt)),vt+=Vt},Wt>0?()=>{Ot=pt(yt.slice(vt,vt+Wt)),vt+=Wt}:null),xt.push("if ("+Tt+") {"),xt.push(...b(Ht)),Wt>0&&(xt.push("} else {"),xt.push(...b(Ot))),xt.push("}")}function Ct(Tt){const Ft=yt[vt+2-1];let Vt;ht.checkedLoop(vt,()=>{vt+=2,Vt=pt(yt.slice(vt,vt+Ft)),vt+=Ft}),xt.push("while ("+Tt+") {"),xt.push(...b(Vt)),xt.push("}")}function wt(Tt){const Bt=yt[vt+Tt-1];return et(yt[vt+1])+"("+yt.slice(vt+Tt,vt+Tt+Bt).map(Ft=>ht.index(Ft)).join(", ")+")"}for(;vtht.index(Vt)).join(", ")} ]`,ht.pop(yt[vt+1]),xt.push(ht.push(Dt)),vt+=Ft;break}case op.IF:Pt(ht.top(),0);break;case op.IF_ERROR:Pt(ht.top()+" === peg$FAILED",0);break;case op.IF_NOT_ERROR:Pt(ht.top()+" !== peg$FAILED",0);break;case op.IF_LT:Pt(ht.top()+".length < "+yt[vt+1],1);break;case op.IF_GE:Pt(ht.top()+".length >= "+yt[vt+1],1);break;case op.IF_LT_DYNAMIC:Pt(ht.top()+".length < ("+ht.index(yt[vt+1])+"|0)",1);break;case op.IF_GE_DYNAMIC:Pt(ht.top()+".length >= ("+ht.index(yt[vt+1])+"|0)",1);break;case op.WHILE_NOT_ERROR:Ct(ht.top()+" !== peg$FAILED");break;case op.MATCH_ANY:Pt("input.length > peg$currPos",0);break;case op.MATCH_STRING:Pt(g.literals[yt[vt+1]].length>1?"input.substr(peg$currPos, "+g.literals[yt[vt+1]].length+") === "+$(yt[vt+1]):"input.charCodeAt(peg$currPos) === "+g.literals[yt[vt+1]].charCodeAt(0),1);break;case op.MATCH_STRING_IC:Pt("input.substr(peg$currPos, "+g.literals[yt[vt+1]].length+").toLowerCase() === "+$(yt[vt+1]),1);break;case op.MATCH_CHAR_CLASS:Pt(j(yt[vt+1])+".test(input.charAt(peg$currPos))",1);break;case op.ACCEPT_N:xt.push(ht.push(yt[vt+1]>1?"input.substr(peg$currPos, "+yt[vt+1]+")":"input.charAt(peg$currPos)")),xt.push(yt[vt+1]>1?"peg$currPos += "+yt[vt+1]+";":"peg$currPos++;"),vt+=2;break;case op.ACCEPT_STRING:xt.push(ht.push($(yt[vt+1]))),xt.push(g.literals[yt[vt+1]].length>1?"peg$currPos += "+g.literals[yt[vt+1]].length+";":"peg$currPos++;"),vt+=2;break;case op.FAIL:xt.push(ht.push("peg$FAILED")),xt.push("if (peg$silentFails === 0) { peg$fail("+_e(yt[vt+1])+"); }"),vt+=2;break;case op.LOAD_SAVED_POS:xt.push("peg$savedPos = "+ht.index(yt[vt+1])+";"),vt+=2;break;case op.UPDATE_SAVED_POS:xt.push("peg$savedPos = peg$currPos;"),vt++;break;case op.CALL:Dt=wt(4),ht.pop(yt[vt+2]),xt.push(ht.push(Dt)),vt+=4+yt[vt+3];break;case op.RULE:xt.push(ht.push(tt(g.rules[yt[vt+1]].name)+"()")),vt+=2;break;case op.SILENT_FAILS_ON:xt.push("peg$silentFails++;"),vt++;break;case op.SILENT_FAILS_OFF:xt.push("peg$silentFails--;"),vt++;break;case op.SOURCE_MAP_PUSH:ht.sourceMapPush(xt,g.locations[yt[vt+1]]),vt+=2;break;case op.SOURCE_MAP_POP:{ht.sourceMapPop(),vt++;break}case op.SOURCE_MAP_LABEL_PUSH:ht.labels[yt[vt+1]]={label:g.literals[yt[vt+2]],location:g.locations[yt[vt+3]]},vt+=4;break;case op.SOURCE_MAP_LABEL_POP:delete ht.labels[yt[vt+1]],vt+=2;break;default:throw new Error("Invalid opcode: "+yt[vt]+".",{rule:ct.name,bytecode:yt})}return xt}const gt=pt(ct.bytecode);return dt.push(wrapInSourceNode("function ",tt(ct.name),ct.nameLocation,`() { +`,ct.name)),d.trace&&dt.push(" var startPos = peg$currPos;"),dt.push(b(ht.defines())),dt.push(...b(rt('"'+stringEscape(ct.name)+'"',asts$4.indexOfRule(g,ct.name)))),dt.push(...b(gt)),dt.push(...b(it('"'+stringEscape(ct.name)+'"',ht.result()))),dt.push("}"),dt}function ot(ct){return ct.codeLocation?toSourceNode(ct.code,ct.codeLocation,"$"+ct.type):ct.code}function at(){const ct=[];g.topLevelInitializer&&(ct.push(ot(g.topLevelInitializer)),ct.push("")),ct.push("function peg$subclass(child, parent) {"," function C() { this.constructor = child; }"," C.prototype = parent.prototype;"," child.prototype = new C();","}","","function peg$SyntaxError(message, expected, found, location) {"," var self = Error.call(this, message);"," // istanbul ignore next Check is a necessary evil to support older environments"," if (Object.setPrototypeOf) {"," Object.setPrototypeOf(self, peg$SyntaxError.prototype);"," }"," self.expected = expected;"," self.found = found;"," self.location = location;",' self.name = "SyntaxError";'," return self;","}","","peg$subclass(peg$SyntaxError, Error);","","function peg$padEnd(str, targetLength, padString) {",' padString = padString || " ";'," if (str.length > targetLength) { return str; }"," targetLength -= str.length;"," padString += padString.repeat(targetLength);"," return str + padString.slice(0, targetLength);","}","","peg$SyntaxError.prototype.format = function(sources) {",' var str = "Error: " + this.message;'," if (this.location) {"," var src = null;"," var k;"," for (k = 0; k < sources.length; k++) {"," if (sources[k].source === this.location.source) {"," src = sources[k].text.split(/\\r\\n|\\n|\\r/g);"," break;"," }"," }"," var s = this.location.start;",' var offset_s = (this.location.source && (typeof this.location.source.offset === "function"))'," ? this.location.source.offset(s)"," : s;",' var loc = this.location.source + ":" + offset_s.line + ":" + offset_s.column;'," if (src) {"," var e = this.location.end;",` var filler = peg$padEnd("", offset_s.line.toString().length, ' ');`," var line = src[s.line - 1];"," var last = s.line === e.line ? e.column : line.length + 1;"," var hatLen = (last - s.column) || 1;",' str += "\\n --> " + loc + "\\n"',' + filler + " |\\n"',' + offset_s.line + " | " + line + "\\n"',` + filler + " | " + peg$padEnd("", s.column - 1, ' ')`,' + peg$padEnd("", hatLen, "^");'," } else {",' str += "\\n at " + loc;'," }"," }"," return str;","};","","peg$SyntaxError.buildMessage = function(expected, found) {"," var DESCRIBE_EXPECTATION_FNS = {"," literal: function(expectation) {",' return "\\"" + literalEscape(expectation.text) + "\\"";'," },",""," class: function(expectation) {"," var escapedParts = expectation.parts.map(function(part) {"," return Array.isArray(part)",' ? classEscape(part[0]) + "-" + classEscape(part[1])'," : classEscape(part);"," });","",' return "[" + (expectation.inverted ? "^" : "") + escapedParts.join("") + "]";'," },",""," any: function() {",' return "any character";'," },",""," end: function() {",' return "end of input";'," },",""," other: function(expectation) {"," return expectation.description;"," }"," };",""," function hex(ch) {"," return ch.charCodeAt(0).toString(16).toUpperCase();"," }",""," function literalEscape(s) {"," return s",' .replace(/\\\\/g, "\\\\\\\\")',' .replace(/"/g, "\\\\\\"")',' .replace(/\\0/g, "\\\\0")',' .replace(/\\t/g, "\\\\t")',' .replace(/\\n/g, "\\\\n")',' .replace(/\\r/g, "\\\\r")',' .replace(/[\\x00-\\x0F]/g, function(ch) { return "\\\\x0" + hex(ch); })',' .replace(/[\\x10-\\x1F\\x7F-\\x9F]/g, function(ch) { return "\\\\x" + hex(ch); });'," }",""," function classEscape(s) {"," return s",' .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, function(ch) { return "\\\\x0" + hex(ch); })',' .replace(/[\\x10-\\x1F\\x7F-\\x9F]/g, function(ch) { return "\\\\x" + hex(ch); });'," }",""," function describeExpectation(expectation) {"," return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);"," }",""," function describeExpected(expected) {"," var descriptions = expected.map(describeExpectation);"," var i, j;",""," descriptions.sort();",""," if (descriptions.length > 0) {"," for (i = 1, j = 1; i < descriptions.length; i++) {"," if (descriptions[i - 1] !== descriptions[i]) {"," descriptions[j] = descriptions[i];"," j++;"," }"," }"," descriptions.length = j;"," }",""," switch (descriptions.length) {"," case 1:"," return descriptions[0];",""," case 2:",' return descriptions[0] + " or " + descriptions[1];',""," default:",' return descriptions.slice(0, -1).join(", ")',' + ", or "'," + descriptions[descriptions.length - 1];"," }"," }",""," function describeFound(found) {",' return found ? "\\"" + literalEscape(found) + "\\"" : "end of input";'," }","",' return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";',"};",""),d.trace&&ct.push("function peg$DefaultTracer() {"," this.indentLevel = 0;","}","","peg$DefaultTracer.prototype.trace = function(event) {"," var that = this;",""," function log(event) {"," function repeat(string, n) {",' var result = "", i;',""," for (i = 0; i < n; i++) {"," result += string;"," }",""," return result;"," }",""," function pad(string, length) {",' return string + repeat(" ", length - string.length);'," }","",' if (typeof console === "object") {'," console.log(",' event.location.start.line + ":" + event.location.start.column + "-"',' + event.location.end.line + ":" + event.location.end.column + " "',' + pad(event.type, 10) + " "',' + repeat(" ", that.indentLevel) + event.rule'," );"," }"," }",""," switch (event.type) {",' case "rule.enter":'," log(event);"," this.indentLevel++;"," break;","",' case "rule.match":'," this.indentLevel--;"," log(event);"," break;","",' case "rule.fail":'," this.indentLevel--;"," log(event);"," break;",""," default:",' throw new Error("Invalid event type: " + event.type + ".");'," }","};","");const dt="{ "+d.allowedStartRules.map(pt=>pt+": "+tt(pt)).join(", ")+" }",ht=tt(d.allowedStartRules[0]);return ct.push("function peg$parse(input, options) {"," options = options !== undefined ? options : {};",""," var peg$FAILED = {};"," var peg$source = options.grammarSource;",""," var peg$startRuleFunctions = "+dt+";"," var peg$startRuleFunction = "+ht+";","",nt(),""," var peg$currPos = 0;"," var peg$savedPos = 0;"," var peg$posDetailsCache = [{ line: 1, column: 1 }];"," var peg$maxFailPos = 0;"," var peg$maxFailExpected = [];"," var peg$silentFails = 0;",""),d.cache&&ct.push(" var peg$resultsCache = {};",""),d.trace&&ct.push(' var peg$tracer = "tracer" in options ? options.tracer : new peg$DefaultTracer();',""),ct.push(" var peg$result;","",' if ("startRule" in options) {'," if (!(options.startRule in peg$startRuleFunctions)) {",` throw new Error("Can't start parsing from rule \\"" + options.startRule + "\\".");`," }",""," peg$startRuleFunction = peg$startRuleFunctions[options.startRule];"," }",""," function text() {"," return input.substring(peg$savedPos, peg$currPos);"," }",""," function offset() {"," return peg$savedPos;"," }",""," function range() {"," return {"," source: peg$source,"," start: peg$savedPos,"," end: peg$currPos"," };"," }",""," function location() {"," return peg$computeLocation(peg$savedPos, peg$currPos);"," }",""," function expected(description, location) {"," location = location !== undefined"," ? location"," : peg$computeLocation(peg$savedPos, peg$currPos);",""," throw peg$buildStructuredError("," [peg$otherExpectation(description)],"," input.substring(peg$savedPos, peg$currPos),"," location"," );"," }",""," function error(message, location) {"," location = location !== undefined"," ? location"," : peg$computeLocation(peg$savedPos, peg$currPos);",""," throw peg$buildSimpleError(message, location);"," }",""," function peg$literalExpectation(text, ignoreCase) {",' return { type: "literal", text: text, ignoreCase: ignoreCase };'," }",""," function peg$classExpectation(parts, inverted, ignoreCase) {",' return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase };'," }",""," function peg$anyExpectation() {",' return { type: "any" };'," }",""," function peg$endExpectation() {",' return { type: "end" };'," }",""," function peg$otherExpectation(description) {",' return { type: "other", description: description };'," }",""," function peg$computePosDetails(pos) {"," var details = peg$posDetailsCache[pos];"," var p;",""," if (details) {"," return details;"," } else {"," p = pos - 1;"," while (!peg$posDetailsCache[p]) {"," p--;"," }",""," details = peg$posDetailsCache[p];"," details = {"," line: details.line,"," column: details.column"," };",""," while (p < pos) {"," if (input.charCodeAt(p) === 10) {"," details.line++;"," details.column = 1;"," } else {"," details.column++;"," }",""," p++;"," }",""," peg$posDetailsCache[pos] = details;",""," return details;"," }"," }",""," function peg$computeLocation(startPos, endPos, offset) {"," var startPosDetails = peg$computePosDetails(startPos);"," var endPosDetails = peg$computePosDetails(endPos);",""," var res = {"," source: peg$source,"," start: {"," offset: startPos,"," line: startPosDetails.line,"," column: startPosDetails.column"," },"," end: {"," offset: endPos,"," line: endPosDetails.line,"," column: endPosDetails.column"," }"," };",' if (offset && peg$source && (typeof peg$source.offset === "function")) {'," res.start = peg$source.offset(res.start);"," res.end = peg$source.offset(res.end);"," }"," return res;"," }",""," function peg$fail(expected) {"," if (peg$currPos < peg$maxFailPos) { return; }",""," if (peg$currPos > peg$maxFailPos) {"," peg$maxFailPos = peg$currPos;"," peg$maxFailExpected = [];"," }",""," peg$maxFailExpected.push(expected);"," }",""," function peg$buildSimpleError(message, location) {"," return new peg$SyntaxError(message, null, null, location);"," }",""," function peg$buildStructuredError(expected, found, location) {"," return new peg$SyntaxError("," peg$SyntaxError.buildMessage(expected, found),"," expected,"," found,"," location"," );"," }",""),g.rules.forEach(pt=>{ct.push(...b(st(pt))),ct.push("")}),g.initializer&&(ct.push(ot(g.initializer)),ct.push("")),ct.push(" peg$result = peg$startRuleFunction();",""," if (peg$result !== peg$FAILED && peg$currPos === input.length) {"," return peg$result;"," } else {"," if (peg$result !== peg$FAILED && peg$currPos < input.length) {"," peg$fail(peg$endExpectation());"," }",""," throw peg$buildStructuredError("," peg$maxFailExpected,"," peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null,"," peg$maxFailPos < input.length"," ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1)"," : peg$computeLocation(peg$maxFailPos, peg$maxFailPos)"," );"," }","}"),new SourceNode(null,null,d.grammarSource,ct.map(pt=>pt instanceof SourceNode?pt:pt+` +`))}function ut(ct){function dt(){return[`// Generated by Peggy ${VERSION$1}.`,"//","// https://peggyjs.org/"]}function ht(){return d.trace?["{"," SyntaxError: peg$SyntaxError,"," DefaultTracer: peg$DefaultTracer,"," parse: peg$parse","}"].join(` +`):["{"," SyntaxError: peg$SyntaxError,"," parse: peg$parse","}"].join(` +`)}const gt={bare(){return[...dt(),"(function() {",' "use strict";',"",ct,"",b("return "+ht()+";"),"})()"]},commonjs(){const yt=Object.keys(d.dependencies),vt=dt();return vt.push("",'"use strict";',""),yt.length>0&&(yt.forEach(St=>{vt.push("var "+St+' = require("'+stringEscape(d.dependencies[St])+'");')}),vt.push("")),vt.push(ct,"","module.exports = "+ht()+";"),vt},es(){const yt=Object.keys(d.dependencies),vt=dt();return vt.push(""),yt.length>0&&(yt.forEach(St=>{vt.push("import "+St+' from "'+stringEscape(d.dependencies[St])+'";')}),vt.push("")),vt.push(ct,"","export {"," peg$SyntaxError as SyntaxError,",d.trace?" peg$DefaultTracer as DefaultTracer,":""," peg$parse as parse","};"),vt},amd(){const yt=Object.keys(d.dependencies),St="["+yt.map(Dt=>d.dependencies[Dt]).map(Dt=>'"'+stringEscape(Dt)+'"').join(", ")+"]",xt=yt.join(", ");return[...dt(),"define("+St+", function("+xt+") {",' "use strict";',"",ct,"",b("return "+ht()+";"),"});"]},globals(){return[...dt(),"(function(root) {",' "use strict";',"",ct,"",b("root."+d.exportVar+" = "+ht()+";"),"})(this);"]},umd(){const yt=Object.keys(d.dependencies),vt=yt.map(Ct=>d.dependencies[Ct]),St="["+vt.map(Ct=>'"'+stringEscape(Ct)+'"').join(", ")+"]",xt=vt.map(Ct=>'require("'+stringEscape(Ct)+'")').join(", "),Dt=yt.join(", "),Pt=dt();return Pt.push("(function(root, factory) {",' if (typeof define === "function" && define.amd) {'," define("+St+", factory);",' } else if (typeof module === "object" && module.exports) {'," module.exports = factory("+xt+");"),d.exportVar!==null&&Pt.push(" } else {"," root."+d.exportVar+" = factory();"),Pt.push(" }","})(this, function("+Dt+") {",' "use strict";',"",ct,"",b("return "+ht()+";"),"});"),Pt}}[d.format]();return new SourceNode(null,null,d.grammarSource,gt.map(yt=>yt instanceof SourceNode?yt:yt+` +`))}g.code=ut(at())}var generateJs=generateJS$1;const asts$3=asts_1,visitor$7=visitor_1;function removeProxyRules$1(g,d,b){function $(et){return et.type==="rule"&&et.expression.type==="rule_ref"}function j(et,tt,nt){visitor$7.build({rule_ref(it){it.name===tt&&(it.name=nt,b.info(`Proxy rule "${tt}" replaced by the rule "${nt}"`,it.location,[{message:"This rule will be used",location:asts$3.findRule(et,nt).nameLocation}]))}})(et)}const _e=[];g.rules.forEach((et,tt)=>{$(et)&&(j(g,et.name,et.expression.name),d.allowedStartRules.indexOf(et.name)===-1&&_e.push(tt))}),_e.reverse(),_e.forEach(et=>{g.rules.splice(et,1)})}var removeProxyRules_1=removeProxyRules$1;const visitor$6=visitor_1;function reportDuplicateLabels$1(g,d,b){function $(et){const tt={};return Object.keys(et).forEach(nt=>{tt[nt]=et[nt]}),tt}function j(et,tt){_e(et.expression,$(tt))}const _e=visitor$6.build({rule(et){_e(et.expression,{})},choice(et,tt){et.alternatives.forEach(nt=>{_e(nt,$(tt))})},action:j,labeled(et,tt){const nt=et.label;nt&&Object.prototype.hasOwnProperty.call(tt,nt)&&b.error(`Label "${et.label}" is already defined`,et.labelLocation,[{message:"Original label location",location:tt[nt]}]),_e(et.expression,tt),tt[et.label]=et.labelLocation},text:j,simple_and:j,simple_not:j,optional:j,zero_or_more:j,one_or_more:j,repeated(et,tt){et.delimiter&&_e(et.delimiter,$(tt)),_e(et.expression,$(tt))},group:j});_e(g)}var reportDuplicateLabels_1=reportDuplicateLabels$1;const visitor$5=visitor_1;function reportDuplicateRules$1(g,d,b){const $={};visitor$5.build({rule(_e){if(Object.prototype.hasOwnProperty.call($,_e.name)){b.error(`Rule "${_e.name}" is already defined`,_e.nameLocation,[{message:"Original rule location",location:$[_e.name]}]);return}$[_e.name]=_e.nameLocation}})(g)}var reportDuplicateRules_1=reportDuplicateRules$1;const asts$2=asts_1,visitor$4=visitor_1;function reportInfiniteRecursion$1(g,d,b){const $=[],j=[],_e=visitor$4.build({rule(et){$.push(et.name),_e(et.expression),$.pop()},sequence(et){et.elements.every(tt=>(_e(tt),!asts$2.alwaysConsumesOnSuccess(g,tt)))},repeated(et){_e(et.expression),et.delimiter&&!asts$2.alwaysConsumesOnSuccess(g,et.expression)&&_e(et.delimiter)},rule_ref(et){j.push(et);const tt=asts$2.findRule(g,et.name);if($.indexOf(et.name)!==-1){$.push(et.name),b.error("Possible infinite loop when parsing (left recursion: "+$.join(" -> ")+")",tt.nameLocation,j.map((nt,rt,it)=>({message:rt+1!==it.length?`Step ${rt+1}: call of the rule "${nt.name}" without input consumption`:`Step ${rt+1}: call itself without input consumption - left recursion`,location:nt.location})));return}tt&&_e(tt),j.pop()}});_e(g)}var reportInfiniteRecursion_1=reportInfiniteRecursion$1;const asts$1=asts_1,visitor$3=visitor_1;function reportInfiniteRepetition$1(g,d,b){const $=visitor$3.build({zero_or_more(j){asts$1.alwaysConsumesOnSuccess(g,j.expression)||b.error("Possible infinite loop when parsing (repetition used with an expression that may not consume any input)",j.location)},one_or_more(j){asts$1.alwaysConsumesOnSuccess(g,j.expression)||b.error("Possible infinite loop when parsing (repetition used with an expression that may not consume any input)",j.location)},repeated(j){if(j.delimiter&&$(j.delimiter),!(asts$1.alwaysConsumesOnSuccess(g,j.expression)||j.delimiter&&asts$1.alwaysConsumesOnSuccess(g,j.delimiter)))if(j.max.value===null)b.error("Possible infinite loop when parsing (unbounded range repetition used with an expression that may not consume any input)",j.location);else{const _e=j.min?j.min:j.max;b.warning(_e.type==="constant"&&j.max.type==="constant"?`An expression may not consume any input and may always match ${j.max.value} times`:"An expression may not consume any input and may always match with a maximum repetition count",j.location)}}});$(g)}var reportInfiniteRepetition_1=reportInfiniteRepetition$1;const asts=asts_1,visitor$2=visitor_1;function reportUndefinedRules$1(g,d,b){visitor$2.build({rule_ref(j){asts.findRule(g,j.name)||b.error(`Rule "${j.name}" is not defined`,j.location)}})(g)}var reportUndefinedRules_1=reportUndefinedRules$1;const visitor$1=visitor_1;function reportIncorrectPlucking$1(g,d,b){const $=visitor$1.build({action(j){$(j.expression,j)},labeled(j,_e){j.pick&&_e&&b.error('"@" cannot be used with an action block',j.labelLocation,[{message:"Action block location",location:_e.codeLocation}]),$(j.expression)}});$(g)}var reportIncorrectPlucking_1=reportIncorrectPlucking$1;const GrammarError$1=grammarError;class Defaults{constructor(d){d=typeof d<"u"?d:{},typeof d.error=="function"&&(this.error=d.error),typeof d.warning=="function"&&(this.warning=d.warning),typeof d.info=="function"&&(this.info=d.info)}error(){}warning(){}info(){}}let Session$1=class{constructor(d){this._callbacks=new Defaults(d),this._firstError=null,this.errors=0,this.problems=[],this.stage=null}error(...d){++this.errors,this._firstError===null&&(this._firstError=new GrammarError$1(...d),this._firstError.stage=this.stage,this._firstError.problems=this.problems),this.problems.push(["error",...d]),this._callbacks.error(this.stage,...d)}warning(...d){this.problems.push(["warning",...d]),this._callbacks.warning(this.stage,...d)}info(...d){this.problems.push(["info",...d]),this._callbacks.info(this.stage,...d)}checkErrors(){if(this.errors!==0)throw this._firstError}};var session=Session$1;const generateBytecode=generateBytecode_1,generateJS=generateJs,inferenceMatchResult=inferenceMatchResult_1,removeProxyRules=removeProxyRules_1,reportDuplicateLabels=reportDuplicateLabels_1,reportDuplicateRules=reportDuplicateRules_1,reportInfiniteRecursion=reportInfiniteRecursion_1,reportInfiniteRepetition=reportInfiniteRepetition_1,reportUndefinedRules=reportUndefinedRules_1,reportIncorrectPlucking=reportIncorrectPlucking_1,Session=session,visitor=visitor_1,{base64}=utils;function processOptions(g,d){const b={};return Object.keys(g).forEach($=>{b[$]=g[$]}),Object.keys(d).forEach($=>{Object.prototype.hasOwnProperty.call(b,$)||(b[$]=d[$])}),b}function isSourceMapCapable(g){return typeof g=="string"?g.length>0:g&&typeof g.offset=="function"}const compiler$1={visitor,passes:{check:[reportUndefinedRules,reportDuplicateRules,reportDuplicateLabels,reportInfiniteRecursion,reportInfiniteRepetition,reportIncorrectPlucking],transform:[removeProxyRules,inferenceMatchResult],generate:[generateBytecode,generateJS]},compile(ast,passes,options){if(options=options!==void 0?options:{},options=processOptions(options,{allowedStartRules:[ast.rules[0].name],cache:!1,dependencies:{},exportVar:null,format:"bare",output:"parser",trace:!1}),!Array.isArray(options.allowedStartRules))throw new Error("allowedStartRules must be an array");if(options.allowedStartRules.length===0)throw new Error("Must have at least one start rule");const allRules=ast.rules.map(g=>g.name);if(options.allowedStartRules.some(g=>g==="*"))options.allowedStartRules=allRules;else for(const g of options.allowedStartRules)if(allRules.indexOf(g)===-1)throw new Error(`Unknown start rule "${g}"`);if((options.output==="source-and-map"||options.output==="source-with-inline-map")&&!isSourceMapCapable(options.grammarSource))throw new Error("Must provide grammarSource (as a string or GrammarLocation) in order to generate source maps");const session=new Session(options);switch(Object.keys(passes).forEach(g=>{session.stage=g,session.info(`Process stage ${g}`),passes[g].forEach(d=>{session.info(`Process pass ${g}.${d.name}`),d(ast,options,session)}),session.checkErrors()}),options.output){case"parser":return eval(ast.code.toString());case"source":return ast.code.toString();case"source-and-map":return ast.code;case"source-with-inline-map":{if(typeof TextEncoder>"u")throw new Error("TextEncoder is not supported by this platform");const g=ast.code.toStringWithSourceMap(),d=new TextEncoder,b=base64(d.encode(JSON.stringify(g.map.toJSON())));return g.code+`//# sourceMappingURL=data:application/json;charset=utf-8;base64,${b} +`}case"ast":return ast;default:throw new Error("Invalid output format: "+options.output+".")}}};var compiler_1=compiler$1;const OPS_TO_PREFIXED_TYPES={$:"text","&":"simple_and","!":"simple_not"},OPS_TO_SUFFIXED_TYPES={"?":"optional","*":"zero_or_more","+":"one_or_more"},OPS_TO_SEMANTIC_PREDICATE_TYPES={"&":"semantic_and","!":"semantic_not"};function peg$subclass(g,d){function b(){this.constructor=g}b.prototype=d.prototype,g.prototype=new b}function peg$SyntaxError(g,d,b,$){var j=Error.call(this,g);return Object.setPrototypeOf&&Object.setPrototypeOf(j,peg$SyntaxError.prototype),j.expected=d,j.found=b,j.location=$,j.name="SyntaxError",j}peg$subclass(peg$SyntaxError,Error);function peg$padEnd(g,d,b){return b=b||" ",g.length>d?g:(d-=g.length,b+=b.repeat(d),g+b.slice(0,d))}peg$SyntaxError.prototype.format=function(g){var d="Error: "+this.message;if(this.location){var b=null,$;for($=0;$ `+et+` +`+nt+` | +`+_e.line+" | "+rt+` +`+nt+" | "+peg$padEnd("",j.column-1," ")+peg$padEnd("",st,"^")}else d+=` + at `+et}return d};peg$SyntaxError.buildMessage=function(g,d){var b={literal:function(rt){return'"'+j(rt.text)+'"'},class:function(rt){var it=rt.parts.map(function(st){return Array.isArray(st)?_e(st[0])+"-"+_e(st[1]):_e(st)});return"["+(rt.inverted?"^":"")+it.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(rt){return rt.description}};function $(rt){return rt.charCodeAt(0).toString(16).toUpperCase()}function j(rt){return rt.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(it){return"\\x0"+$(it)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(it){return"\\x"+$(it)})}function _e(rt){return rt.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,function(it){return"\\x0"+$(it)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(it){return"\\x"+$(it)})}function et(rt){return b[rt.type](rt)}function tt(rt){var it=rt.map(et),st,ot;if(it.sort(),it.length>0){for(st=1,ot=1;st0?{type:"choice",alternatives:[lt].concat(mt),location:sn()}:lt},to=function(lt,mt){return mt!==null?{type:"action",expression:lt,code:mt[0],codeLocation:mt[1],location:sn()}:lt},no=function(lt,mt){return mt.length>0||lt.type==="labeled"&<.pick?{type:"sequence",elements:[lt].concat(mt),location:sn()}:lt},ro=function(lt,mt,At){return At.type.startsWith("semantic_")&&or('"@" cannot be used on a semantic predicate',lt),{type:"labeled",label:mt!==null?mt[0]:null,labelLocation:mt!==null?mt[1]:lt,pick:!0,expression:At,location:sn()}},io=function(lt,mt){return{type:"labeled",label:lt[0],labelLocation:lt[1],expression:mt,location:sn()}},so=function(){return sn()},oo=function(lt){return Hl.indexOf(lt[0])>=0&&or(`Label can't be a reserved word "${lt[0]}"`,lt[1]),lt},ao=function(lt,mt){return{type:OPS_TO_PREFIXED_TYPES[lt],expression:mt,location:sn()}},lo=function(lt,mt){return{type:OPS_TO_SUFFIXED_TYPES[mt],expression:lt,location:sn()}},uo=function(lt,mt,At){let Et=mt[0],kt=mt[1];return kt.type==="constant"&&kt.value===0&&or("The maximum count of repetitions of the rule must be > 0",kt.location),{type:"repeated",min:Et,max:kt,expression:lt,delimiter:At,location:sn()}},co=function(lt,mt){return[lt!==null?lt:{type:"constant",value:0},mt!==null?mt:{type:"constant",value:null}]},ho=function(lt){return[null,lt]},fo=function(lt){return{type:"constant",value:lt,location:sn()}},po=function(lt){return{type:"variable",value:lt[0],location:sn()}},go=function(lt){return{type:"function",value:lt[0],codeLocation:lt[1],location:sn()}},mo=function(lt){return lt.type==="labeled"||lt.type==="sequence"?{type:"group",expression:lt,location:sn()}:lt},yo=function(lt){return{type:"rule_ref",name:lt[0],location:sn()}},vo=function(lt,mt){return{type:OPS_TO_SEMANTIC_PREDICATE_TYPES[lt],code:mt[0],codeLocation:mt[1],location:sn()}},Eo=function(lt,mt){return[lt+mt.join(""),sn()]},Co=function(lt,mt){return{type:"literal",value:lt,ignoreCase:mt!==null,location:sn()}},Ao=function(lt){return lt.join("")},xo=function(lt){return lt.join("")},wo=function(lt,mt,At){return{type:"class",parts:mt.filter(Et=>Et!==""),inverted:lt!==null,ignoreCase:At!==null,location:sn()}},So=function(lt,mt){return lt.charCodeAt(0)>mt.charCodeAt(0)&&or("Invalid character range: "+No()+"."),[lt,mt]},bo=function(){return""},ko=function(){return"\0"},To=function(){return"\b"},Do=function(){return"\f"},Po=function(){return` +`},$o=function(){return"\r"},Bo=function(){return" "},_o=function(){return"\v"},Mo=function(lt){return String.fromCharCode(parseInt(lt,16))},Fo=function(lt){return String.fromCharCode(parseInt(lt,16))},Ro=function(){return{type:"any",location:sn()}},Oo=function(lt){return[lt,sn()]},Lo=function(lt){return parseInt(lt,10)},ft=0,Qt=0,ir=[{line:1,column:1}],Fn=0,mr=[],bt=0,sr;if("startRule"in d){if(!(d.startRule in j))throw new Error(`Can't start parsing from rule "`+d.startRule+'".');_e=j[d.startRule]}function No(){return g.substring(Qt,ft)}function sn(){return ar(Qt,ft)}function or(lt,mt){throw mt=mt!==void 0?mt:ar(Qt,ft),Ho(lt,mt)}function Kt(lt,mt){return{type:"literal",text:lt,ignoreCase:mt}}function mn(lt,mt,At){return{type:"class",parts:lt,inverted:mt,ignoreCase:At}}function Io(){return{type:"any"}}function Vo(){return{type:"end"}}function In(lt){return{type:"other",description:lt}}function Lr(lt){var mt=ir[lt],At;if(mt)return mt;for(At=lt-1;!ir[At];)At--;for(mt=ir[At],mt={line:mt.line,column:mt.column};AtFn&&(Fn=ft,mr=[]),mr.push(lt))}function Ho(lt,mt){return new peg$SyntaxError(lt,null,null,mt)}function jo(lt,mt,At){return new peg$SyntaxError(peg$SyntaxError.buildMessage(lt,mt),lt,mt,At)}function Nr(){var lt,mt,At,Et,kt,Mt;if(lt=ft,en(),mt=ft,At=zo(),At!==b?(Et=en(),mt=At):(ft=mt,mt=b),mt===b&&(mt=null),At=ft,Et=Uo(),Et!==b?(kt=en(),At=Et):(ft=At,At=b),At===b&&(At=null),Et=[],kt=ft,Mt=Ir(),Mt!==b?(en(),kt=Mt):(ft=kt,kt=b),kt!==b)for(;kt!==b;)Et.push(kt),kt=ft,Mt=Ir(),Mt!==b?(en(),kt=Mt):(ft=kt,kt=b);else Et=b;return Et!==b?(Qt=lt,lt=qs(mt,At,Et)):(ft=lt,lt=b),lt}function zo(){var lt,mt,At,Et,kt;return lt=ft,g.charCodeAt(ft)===123?(mt=et,ft++):(mt=b,bt===0&&Rt(cn)),mt!==b?(At=Zn(),At!==b?(g.charCodeAt(ft)===125?(Et=tt,ft++):(Et=b,bt===0&&Rt(gn)),Et!==b?(kt=Tr(),kt!==b?(Qt=lt,lt=Qs(At)):(ft=lt,lt=b)):(ft=lt,lt=b)):(ft=lt,lt=b)):(ft=lt,lt=b),lt}function Uo(){var lt,mt,At;return lt=ft,mt=Zn(),mt!==b?(At=Tr(),At!==b?(Qt=lt,lt=Zs(mt)):(ft=lt,lt=b)):(ft=lt,lt=b),lt}function Ir(){var lt,mt,At,Et,kt,Mt;return lt=ft,mt=cr(),mt!==b?(en(),At=ft,Et=wr(),Et!==b?(en(),At=Et):(ft=At,At=b),At===b&&(At=null),g.charCodeAt(ft)===61?(Et=nt,ft++):(Et=b,bt===0&&Rt(Sn)),Et!==b?(en(),kt=yr(),kt!==b?(Mt=Tr(),Mt!==b?(Qt=lt,lt=Js(mt,At,kt)):(ft=lt,lt=b)):(ft=lt,lt=b)):(ft=lt,lt=b)):(ft=lt,lt=b),lt}function yr(){var lt,mt,At,Et,kt,Mt;if(lt=ft,mt=vr(),mt!==b){for(At=[],Et=ft,en(),g.charCodeAt(ft)===47?(kt=rt,ft++):(kt=b,bt===0&&Rt(Tn)),kt!==b?(en(),Mt=vr(),Mt!==b?Et=Mt:(ft=Et,Et=b)):(ft=Et,Et=b);Et!==b;)At.push(Et),Et=ft,en(),g.charCodeAt(ft)===47?(kt=rt,ft++):(kt=b,bt===0&&Rt(Tn)),kt!==b?(en(),Mt=vr(),Mt!==b?Et=Mt:(ft=Et,Et=b)):(ft=Et,Et=b);Qt=lt,lt=eo(mt,At)}else ft=lt,lt=b;return lt}function vr(){var lt,mt,At,Et;return lt=ft,mt=Wo(),mt!==b?(At=ft,en(),Et=Zn(),Et!==b?At=Et:(ft=At,At=b),At===b&&(At=null),Qt=lt,lt=to(mt,At)):(ft=lt,lt=b),lt}function Wo(){var lt,mt,At,Et,kt;if(lt=ft,mt=Er(),mt!==b){for(At=[],Et=ft,en(),kt=Er(),kt!==b?Et=kt:(ft=Et,Et=b);Et!==b;)At.push(Et),Et=ft,en(),kt=Er(),kt!==b?Et=kt:(ft=Et,Et=b);Qt=lt,lt=no(mt,At)}else ft=lt,lt=b;return lt}function Er(){var lt,mt,At,Et;return lt=ft,mt=Go(),mt!==b?(At=Vr(),At===b&&(At=null),Et=Cr(),Et!==b?(Qt=lt,lt=ro(mt,At,Et)):(ft=lt,lt=b)):(ft=lt,lt=b),lt===b&&(lt=ft,mt=Vr(),mt!==b?(At=en(),Et=Cr(),Et!==b?(Qt=lt,lt=io(mt,Et)):(ft=lt,lt=b)):(ft=lt,lt=b),lt===b&&(lt=Cr())),lt}function Go(){var lt,mt;return lt=ft,g.charCodeAt(ft)===64?(mt=it,ft++):(mt=b,bt===0&&Rt(on)),mt!==b&&(Qt=lt,mt=so()),lt=mt,lt}function Vr(){var lt,mt,At;return lt=ft,mt=cr(),mt!==b?(en(),g.charCodeAt(ft)===58?(At=st,ft++):(At=b,bt===0&&Rt(Xn)),At!==b?(Qt=lt,lt=oo(mt)):(ft=lt,lt=b)):(ft=lt,lt=b),lt}function Cr(){var lt,mt,At;return lt=ft,mt=Yo(),mt!==b?(en(),At=Hr(),At!==b?(Qt=lt,lt=ao(mt,At)):(ft=lt,lt=b)):(ft=lt,lt=b),lt===b&&(lt=Hr()),lt}function Yo(){var lt;return g.charCodeAt(ft)===36?(lt=ot,ft++):(lt=b,bt===0&&Rt(fn)),lt===b&&(g.charCodeAt(ft)===38?(lt=at,ft++):(lt=b,bt===0&&Rt(Cn)),lt===b&&(g.charCodeAt(ft)===33?(lt=ut,ft++):(lt=b,bt===0&&Rt(Mn)))),lt}function Hr(){var lt,mt,At;return lt=ft,mt=xr(),mt!==b?(en(),At=Ko(),At!==b?(Qt=lt,lt=lo(mt,At)):(ft=lt,lt=b)):(ft=lt,lt=b),lt===b&&(lt=Xo(),lt===b&&(lt=xr())),lt}function Ko(){var lt;return g.charCodeAt(ft)===63?(lt=ct,ft++):(lt=b,bt===0&&Rt(Un)),lt===b&&(g.charCodeAt(ft)===42?(lt=dt,ft++):(lt=b,bt===0&&Rt(qn)),lt===b&&(g.charCodeAt(ft)===43?(lt=ht,ft++):(lt=b,bt===0&&Rt(pr)))),lt}function Xo(){var lt,mt,At,Et,kt,Mt,pn;return lt=ft,mt=xr(),mt!==b?(en(),g.charCodeAt(ft)===124?(At=pt,ft++):(At=b,bt===0&&Rt(Jn)),At!==b?(en(),Et=qo(),Et!==b?(en(),kt=ft,g.charCodeAt(ft)===44?(Mt=gt,ft++):(Mt=b,bt===0&&Rt(Dn)),Mt!==b?(en(),pn=yr(),pn!==b?(en(),kt=pn):(ft=kt,kt=b)):(ft=kt,kt=b),kt===b&&(kt=null),g.charCodeAt(ft)===124?(Mt=pt,ft++):(Mt=b,bt===0&&Rt(Jn)),Mt!==b?(Qt=lt,lt=uo(mt,Et,kt)):(ft=lt,lt=b)):(ft=lt,lt=b)):(ft=lt,lt=b)):(ft=lt,lt=b),lt}function qo(){var lt,mt,At,Et;return lt=ft,mt=Ar(),mt===b&&(mt=null),en(),g.substr(ft,2)===yt?(At=yt,ft+=2):(At=b,bt===0&&Rt(Qn)),At!==b?(en(),Et=Ar(),Et===b&&(Et=null),Qt=lt,lt=co(mt,Et)):(ft=lt,lt=b),lt===b&&(lt=ft,mt=Ar(),mt!==b&&(Qt=lt,mt=ho(mt)),lt=mt),lt}function Ar(){var lt,mt;return lt=ft,mt=Tl(),mt!==b&&(Qt=lt,mt=fo(mt)),lt=mt,lt===b&&(lt=ft,mt=cr(),mt!==b&&(Qt=lt,mt=po(mt)),lt=mt,lt===b&&(lt=ft,mt=Zn(),mt!==b&&(Qt=lt,mt=go(mt)),lt=mt)),lt}function xr(){var lt,mt,At,Et;return lt=ba(),lt===b&&(lt=$a(),lt===b&&(lt=xl(),lt===b&&(lt=Qo(),lt===b&&(lt=Zo(),lt===b&&(lt=ft,g.charCodeAt(ft)===40?(mt=vt,ft++):(mt=b,bt===0&&Rt(er)),mt!==b?(en(),At=yr(),At!==b?(en(),g.charCodeAt(ft)===41?(Et=St,ft++):(Et=b,bt===0&&Rt(gr)),Et!==b?(Qt=lt,lt=mo(At)):(ft=lt,lt=b)):(ft=lt,lt=b)):(ft=lt,lt=b)))))),lt}function Qo(){var lt,mt,At,Et,kt,Mt,pn,Yn;return lt=ft,mt=cr(),mt!==b?(At=ft,bt++,Et=ft,kt=en(),Mt=ft,pn=wr(),pn!==b?(Yn=en(),pn=[pn,Yn],Mt=pn):(ft=Mt,Mt=b),Mt===b&&(Mt=null),g.charCodeAt(ft)===61?(pn=nt,ft++):(pn=b,bt===0&&Rt(Sn)),pn!==b?(kt=[kt,Mt,pn],Et=kt):(ft=Et,Et=b),bt--,Et===b?At=void 0:(ft=At,At=b),At!==b?(Qt=lt,lt=yo(mt)):(ft=lt,lt=b)):(ft=lt,lt=b),lt}function Zo(){var lt,mt,At;return lt=ft,mt=Jo(),mt!==b?(en(),At=Zn(),At!==b?(Qt=lt,lt=vo(mt,At)):(ft=lt,lt=b)):(ft=lt,lt=b),lt}function Jo(){var lt;return g.charCodeAt(ft)===38?(lt=at,ft++):(lt=b,bt===0&&Rt(Cn)),lt===b&&(g.charCodeAt(ft)===33?(lt=ut,ft++):(lt=b,bt===0&&Rt(Mn))),lt}function vn(){var lt;return g.length>ft?(lt=g.charAt(ft),ft++):(lt=b,bt===0&&Rt($r)),lt}function lr(){var lt;return bt++,g.charCodeAt(ft)===9?(lt=xt,ft++):(lt=b,bt===0&&Rt(ns)),lt===b&&(g.charCodeAt(ft)===11?(lt=Dt,ft++):(lt=b,bt===0&&Rt(rs)),lt===b&&(g.charCodeAt(ft)===12?(lt=Pt,ft++):(lt=b,bt===0&&Rt(ss)),lt===b&&(g.charCodeAt(ft)===32?(lt=Ct,ft++):(lt=b,bt===0&&Rt(os)),lt===b&&(g.charCodeAt(ft)===160?(lt=wt,ft++):(lt=b,bt===0&&Rt(as)),lt===b&&(g.charCodeAt(ft)===65279?(lt=Tt,ft++):(lt=b,bt===0&&Rt(ls)),lt===b&&(lt=Nl())))))),bt--,lt===b&&bt===0&&Rt(ts),lt}function Vn(){var lt;return kn.test(g.charAt(ft))?(lt=g.charAt(ft),ft++):(lt=b,bt===0&&Rt(us)),lt}function ur(){var lt;return bt++,g.charCodeAt(ft)===10?(lt=Bt,ft++):(lt=b,bt===0&&Rt(hs)),lt===b&&(g.substr(ft,2)===Ft?(lt=Ft,ft+=2):(lt=b,bt===0&&Rt(fs)),lt===b&&(g.charCodeAt(ft)===13?(lt=Vt,ft++):(lt=b,bt===0&&Rt(ds)),lt===b&&(g.charCodeAt(ft)===8232?(lt=Wt,ft++):(lt=b,bt===0&&Rt(ps)),lt===b&&(g.charCodeAt(ft)===8233?(lt=Ht,ft++):(lt=b,bt===0&&Rt(gs)))))),bt--,lt===b&&bt===0&&Rt(cs),lt}function jr(){var lt;return bt++,lt=na(),lt===b&&(lt=Ur()),bt--,lt===b&&bt===0&&Rt(ms),lt}function na(){var lt,mt,At,Et,kt,Mt;if(lt=ft,g.substr(ft,2)===Ot?(mt=Ot,ft+=2):(mt=b,bt===0&&Rt(Br)),mt!==b){for(At=[],Et=ft,kt=ft,bt++,g.substr(ft,2)===Lt?(Mt=Lt,ft+=2):(Mt=b,bt===0&&Rt(Wn)),bt--,Mt===b?kt=void 0:(ft=kt,kt=b),kt!==b?(Mt=vn(),Mt!==b?(kt=[kt,Mt],Et=kt):(ft=Et,Et=b)):(ft=Et,Et=b);Et!==b;)At.push(Et),Et=ft,kt=ft,bt++,g.substr(ft,2)===Lt?(Mt=Lt,ft+=2):(Mt=b,bt===0&&Rt(Wn)),bt--,Mt===b?kt=void 0:(ft=kt,kt=b),kt!==b?(Mt=vn(),Mt!==b?(kt=[kt,Mt],Et=kt):(ft=Et,Et=b)):(ft=Et,Et=b);g.substr(ft,2)===Lt?(Et=Lt,ft+=2):(Et=b,bt===0&&Rt(Wn)),Et!==b?(mt=[mt,At,Et],lt=mt):(ft=lt,lt=b)}else ft=lt,lt=b;return lt}function zr(){var lt,mt,At,Et,kt,Mt;if(lt=ft,g.substr(ft,2)===Ot?(mt=Ot,ft+=2):(mt=b,bt===0&&Rt(Br)),mt!==b){for(At=[],Et=ft,kt=ft,bt++,g.substr(ft,2)===Lt?(Mt=Lt,ft+=2):(Mt=b,bt===0&&Rt(Wn)),Mt===b&&(Mt=Vn()),bt--,Mt===b?kt=void 0:(ft=kt,kt=b),kt!==b?(Mt=vn(),Mt!==b?(kt=[kt,Mt],Et=kt):(ft=Et,Et=b)):(ft=Et,Et=b);Et!==b;)At.push(Et),Et=ft,kt=ft,bt++,g.substr(ft,2)===Lt?(Mt=Lt,ft+=2):(Mt=b,bt===0&&Rt(Wn)),Mt===b&&(Mt=Vn()),bt--,Mt===b?kt=void 0:(ft=kt,kt=b),kt!==b?(Mt=vn(),Mt!==b?(kt=[kt,Mt],Et=kt):(ft=Et,Et=b)):(ft=Et,Et=b);g.substr(ft,2)===Lt?(Et=Lt,ft+=2):(Et=b,bt===0&&Rt(Wn)),Et!==b?(mt=[mt,At,Et],lt=mt):(ft=lt,lt=b)}else ft=lt,lt=b;return lt}function Ur(){var lt,mt,At,Et,kt,Mt;if(lt=ft,g.substr(ft,2)===It?(mt=It,ft+=2):(mt=b,bt===0&&Rt(ys)),mt!==b){for(At=[],Et=ft,kt=ft,bt++,Mt=Vn(),bt--,Mt===b?kt=void 0:(ft=kt,kt=b),kt!==b?(Mt=vn(),Mt!==b?(kt=[kt,Mt],Et=kt):(ft=Et,Et=b)):(ft=Et,Et=b);Et!==b;)At.push(Et),Et=ft,kt=ft,bt++,Mt=Vn(),bt--,Mt===b?kt=void 0:(ft=kt,kt=b),kt!==b?(Mt=vn(),Mt!==b?(kt=[kt,Mt],Et=kt):(ft=Et,Et=b)):(ft=Et,Et=b);mt=[mt,At],lt=mt}else ft=lt,lt=b;return lt}function cr(){var lt,mt,At,Et;if(bt++,lt=ft,mt=Wr(),mt!==b){for(At=[],Et=Gr();Et!==b;)At.push(Et),Et=Gr();Qt=lt,lt=Eo(mt,At)}else ft=lt,lt=b;return bt--,lt===b&&(mt=b,bt===0&&Rt(vs)),lt}function Wr(){var lt,mt,At;return lt=ga(),lt===b&&(g.charCodeAt(ft)===95?(lt=Ut,ft++):(lt=b,bt===0&&Rt(Es)),lt===b&&(lt=ft,g.charCodeAt(ft)===92?(mt=Gt,ft++):(mt=b,bt===0&&Rt(Ln)),mt!==b?(At=Qr(),At!==b?lt=At:(ft=lt,lt=b)):(ft=lt,lt=b))),lt}function Gr(){var lt;return lt=Wr(),lt===b&&(g.charCodeAt(ft)===36?(lt=ot,ft++):(lt=b,bt===0&&Rt(fn)),lt===b&&(lt=xa(),lt===b&&(lt=Rl(),lt===b&&(lt=Ll(),lt===b&&(g.charCodeAt(ft)===8204?(lt=tn,ft++):(lt=b,bt===0&&Rt(Cs)),lt===b&&(g.charCodeAt(ft)===8205?(lt=nn,ft++):(lt=b,bt===0&&Rt(As)))))))),lt}function ga(){var lt;return lt=_l(),lt===b&&(lt=Dl(),lt===b&&(lt=Bl(),lt===b&&(lt=Pl(),lt===b&&(lt=$l(),lt===b&&(lt=Ol()))))),lt}function xa(){var lt;return lt=Fl(),lt===b&&(lt=Ml()),lt}function ba(){var lt,mt,At;return bt++,lt=ft,mt=wr(),mt!==b?(g.charCodeAt(ft)===105?(At=ln,ft++):(At=b,bt===0&&Rt(_r)),At===b&&(At=null),Qt=lt,lt=Co(mt,At)):(ft=lt,lt=b),bt--,lt===b&&(mt=b,bt===0&&Rt(xs)),lt}function wr(){var lt,mt,At,Et;if(bt++,lt=ft,g.charCodeAt(ft)===34?(mt=an,ft++):(mt=b,bt===0&&Rt(tr)),mt!==b){for(At=[],Et=Yr();Et!==b;)At.push(Et),Et=Yr();g.charCodeAt(ft)===34?(Et=an,ft++):(Et=b,bt===0&&Rt(tr)),Et!==b?(Qt=lt,lt=Ao(At)):(ft=lt,lt=b)}else ft=lt,lt=b;if(lt===b)if(lt=ft,g.charCodeAt(ft)===39?(mt=yn,ft++):(mt=b,bt===0&&Rt(nr)),mt!==b){for(At=[],Et=Kr();Et!==b;)At.push(Et),Et=Kr();g.charCodeAt(ft)===39?(Et=yn,ft++):(Et=b,bt===0&&Rt(nr)),Et!==b?(Qt=lt,lt=xo(At)):(ft=lt,lt=b)}else ft=lt,lt=b;return bt--,lt===b&&(mt=b,bt===0&&Rt(ws)),lt}function Yr(){var lt,mt,At,Et;return lt=ft,mt=ft,At=ft,bt++,g.charCodeAt(ft)===34?(Et=an,ft++):(Et=b,bt===0&&Rt(tr)),Et===b&&(g.charCodeAt(ft)===92?(Et=Gt,ft++):(Et=b,bt===0&&Rt(Ln)),Et===b&&(Et=Vn())),bt--,Et===b?At=void 0:(ft=At,At=b),At!==b?(Et=vn(),Et!==b?(At=[At,Et],mt=At):(ft=mt,mt=b)):(ft=mt,mt=b),mt!==b?lt=g.substring(lt,ft):lt=mt,lt===b&&(lt=ft,g.charCodeAt(ft)===92?(mt=Gt,ft++):(mt=b,bt===0&&Rt(Ln)),mt!==b?(At=br(),At!==b?lt=At:(ft=lt,lt=b)):(ft=lt,lt=b),lt===b&&(lt=Sr())),lt}function Kr(){var lt,mt,At,Et;return lt=ft,mt=ft,At=ft,bt++,g.charCodeAt(ft)===39?(Et=yn,ft++):(Et=b,bt===0&&Rt(nr)),Et===b&&(g.charCodeAt(ft)===92?(Et=Gt,ft++):(Et=b,bt===0&&Rt(Ln)),Et===b&&(Et=Vn())),bt--,Et===b?At=void 0:(ft=At,At=b),At!==b?(Et=vn(),Et!==b?(At=[At,Et],mt=At):(ft=mt,mt=b)):(ft=mt,mt=b),mt!==b?lt=g.substring(lt,ft):lt=mt,lt===b&&(lt=ft,g.charCodeAt(ft)===92?(mt=Gt,ft++):(mt=b,bt===0&&Rt(Ln)),mt!==b?(At=br(),At!==b?lt=At:(ft=lt,lt=b)):(ft=lt,lt=b),lt===b&&(lt=Sr())),lt}function $a(){var lt,mt,At,Et,kt,Mt;if(bt++,lt=ft,g.charCodeAt(ft)===91?(mt=Pn,ft++):(mt=b,bt===0&&Rt(bs)),mt!==b){for(g.charCodeAt(ft)===94?(At=Hn,ft++):(At=b,bt===0&&Rt(ks)),At===b&&(At=null),Et=[],kt=Xr(),kt===b&&(kt=hr());kt!==b;)Et.push(kt),kt=Xr(),kt===b&&(kt=hr());g.charCodeAt(ft)===93?(kt=bn,ft++):(kt=b,bt===0&&Rt(Mr)),kt!==b?(g.charCodeAt(ft)===105?(Mt=ln,ft++):(Mt=b,bt===0&&Rt(_r)),Mt===b&&(Mt=null),Qt=lt,lt=wo(At,Et,Mt)):(ft=lt,lt=b)}else ft=lt,lt=b;return bt--,lt===b&&(mt=b,bt===0&&Rt(Ss)),lt}function Xr(){var lt,mt,At,Et;return lt=ft,mt=hr(),mt!==b?(g.charCodeAt(ft)===45?(At=Rn,ft++):(At=b,bt===0&&Rt(Ts)),At!==b?(Et=hr(),Et!==b?(Qt=lt,lt=So(mt,Et)):(ft=lt,lt=b)):(ft=lt,lt=b)):(ft=lt,lt=b),lt}function hr(){var lt,mt,At,Et;return lt=ft,mt=ft,At=ft,bt++,g.charCodeAt(ft)===93?(Et=bn,ft++):(Et=b,bt===0&&Rt(Mr)),Et===b&&(g.charCodeAt(ft)===92?(Et=Gt,ft++):(Et=b,bt===0&&Rt(Ln)),Et===b&&(Et=Vn())),bt--,Et===b?At=void 0:(ft=At,At=b),At!==b?(Et=vn(),Et!==b?(At=[At,Et],mt=At):(ft=mt,mt=b)):(ft=mt,mt=b),mt!==b?lt=g.substring(lt,ft):lt=mt,lt===b&&(lt=ft,g.charCodeAt(ft)===92?(mt=Gt,ft++):(mt=b,bt===0&&Rt(Ln)),mt!==b?(At=br(),At!==b?lt=At:(ft=lt,lt=b)):(ft=lt,lt=b),lt===b&&(lt=Sr())),lt}function Sr(){var lt,mt,At;return lt=ft,g.charCodeAt(ft)===92?(mt=Gt,ft++):(mt=b,bt===0&&Rt(Ln)),mt!==b?(At=ur(),At!==b?(Qt=lt,lt=bo()):(ft=lt,lt=b)):(ft=lt,lt=b),lt}function br(){var lt,mt,At,Et;return lt=yl(),lt===b&&(lt=ft,g.charCodeAt(ft)===48?(mt=On,ft++):(mt=b,bt===0&&Rt(Ds)),mt!==b?(At=ft,bt++,Et=fr(),bt--,Et===b?At=void 0:(ft=At,At=b),At!==b?(Qt=lt,lt=ko()):(ft=lt,lt=b)):(ft=lt,lt=b),lt===b&&(lt=Al(),lt===b&&(lt=Qr()))),lt}function yl(){var lt;return lt=qr(),lt===b&&(lt=El()),lt}function qr(){var lt,mt;return g.charCodeAt(ft)===39?(lt=yn,ft++):(lt=b,bt===0&&Rt(nr)),lt===b&&(g.charCodeAt(ft)===34?(lt=an,ft++):(lt=b,bt===0&&Rt(tr)),lt===b&&(g.charCodeAt(ft)===92?(lt=Gt,ft++):(lt=b,bt===0&&Rt(Ln)),lt===b&&(lt=ft,g.charCodeAt(ft)===98?(mt=$n,ft++):(mt=b,bt===0&&Rt(Ps)),mt!==b&&(Qt=lt,mt=To()),lt=mt,lt===b&&(lt=ft,g.charCodeAt(ft)===102?(mt=An,ft++):(mt=b,bt===0&&Rt($s)),mt!==b&&(Qt=lt,mt=Do()),lt=mt,lt===b&&(lt=ft,g.charCodeAt(ft)===110?(mt=Nn,ft++):(mt=b,bt===0&&Rt(Bs)),mt!==b&&(Qt=lt,mt=Po()),lt=mt,lt===b&&(lt=ft,g.charCodeAt(ft)===114?(mt=jn,ft++):(mt=b,bt===0&&Rt(_s)),mt!==b&&(Qt=lt,mt=$o()),lt=mt,lt===b&&(lt=ft,g.charCodeAt(ft)===116?(mt=zn,ft++):(mt=b,bt===0&&Rt(Ms)),mt!==b&&(Qt=lt,mt=Bo()),lt=mt,lt===b&&(lt=ft,g.charCodeAt(ft)===118?(mt=Bn,ft++):(mt=b,bt===0&&Rt(Fs)),mt!==b&&(Qt=lt,mt=_o()),lt=mt)))))))),lt}function El(){var lt,mt,At,Et;return lt=ft,mt=ft,At=ft,bt++,Et=Cl(),Et===b&&(Et=Vn()),bt--,Et===b?At=void 0:(ft=At,At=b),At!==b?(Et=vn(),Et!==b?(At=[At,Et],mt=At):(ft=mt,mt=b)):(ft=mt,mt=b),mt!==b?lt=g.substring(lt,ft):lt=mt,lt}function Cl(){var lt;return lt=qr(),lt===b&&(lt=fr(),lt===b&&(g.charCodeAt(ft)===120?(lt=_n,ft++):(lt=b,bt===0&&Rt(Fr)),lt===b&&(g.charCodeAt(ft)===117?(lt=xn,ft++):(lt=b,bt===0&&Rt(Rr))))),lt}function Al(){var lt,mt,At,Et,kt,Mt;return lt=ft,g.charCodeAt(ft)===120?(mt=_n,ft++):(mt=b,bt===0&&Rt(Fr)),mt!==b?(At=ft,Et=ft,kt=Gn(),kt!==b?(Mt=Gn(),Mt!==b?(kt=[kt,Mt],Et=kt):(ft=Et,Et=b)):(ft=Et,Et=b),Et!==b?At=g.substring(At,ft):At=Et,At!==b?(Qt=lt,lt=Mo(At)):(ft=lt,lt=b)):(ft=lt,lt=b),lt}function Qr(){var lt,mt,At,Et,kt,Mt,pn,Yn;return lt=ft,g.charCodeAt(ft)===117?(mt=xn,ft++):(mt=b,bt===0&&Rt(Rr)),mt!==b?(At=ft,Et=ft,kt=Gn(),kt!==b?(Mt=Gn(),Mt!==b?(pn=Gn(),pn!==b?(Yn=Gn(),Yn!==b?(kt=[kt,Mt,pn,Yn],Et=kt):(ft=Et,Et=b)):(ft=Et,Et=b)):(ft=Et,Et=b)):(ft=Et,Et=b),Et!==b?At=g.substring(At,ft):At=Et,At!==b?(Qt=lt,lt=Fo(At)):(ft=lt,lt=b)):(ft=lt,lt=b),lt}function fr(){var lt;return hn.test(g.charAt(ft))?(lt=g.charAt(ft),ft++):(lt=b,bt===0&&Rt(Rs)),lt}function Gn(){var lt;return $t.test(g.charAt(ft))?(lt=g.charAt(ft),ft++):(lt=b,bt===0&&Rt(Os)),lt}function xl(){var lt,mt;return lt=ft,g.charCodeAt(ft)===46?(mt=En,ft++):(mt=b,bt===0&&Rt(Ls)),mt!==b&&(Qt=lt,mt=Ro()),lt=mt,lt}function Zn(){var lt,mt,At,Et;return bt++,lt=ft,g.charCodeAt(ft)===123?(mt=et,ft++):(mt=b,bt===0&&Rt(cn)),mt!==b?(At=Sl(),g.charCodeAt(ft)===125?(Et=tt,ft++):(Et=b,bt===0&&Rt(gn)),Et!==b?lt=At:(ft=lt,lt=b)):(ft=lt,lt=b),bt--,lt===b&&(mt=b,bt===0&&Rt(Ns)),lt}function Sl(){var lt,mt;return lt=ft,mt=kr(),Qt=lt,mt=Oo(mt),lt=mt,lt}function kr(){var lt,mt,At,Et,kt,Mt;if(lt=ft,mt=[],At=[],Et=ft,kt=ft,bt++,_t.test(g.charAt(ft))?(Mt=g.charAt(ft),ft++):(Mt=b,bt===0&&Rt(rr)),bt--,Mt===b?kt=void 0:(ft=kt,kt=b),kt!==b?(Mt=vn(),Mt!==b?(kt=[kt,Mt],Et=kt):(ft=Et,Et=b)):(ft=Et,Et=b),Et!==b)for(;Et!==b;)At.push(Et),Et=ft,kt=ft,bt++,_t.test(g.charAt(ft))?(Mt=g.charAt(ft),ft++):(Mt=b,bt===0&&Rt(rr)),bt--,Mt===b?kt=void 0:(ft=kt,kt=b),kt!==b?(Mt=vn(),Mt!==b?(kt=[kt,Mt],Et=kt):(ft=Et,Et=b)):(ft=Et,Et=b);else At=b;for(At===b&&(At=ft,g.charCodeAt(ft)===123?(Et=et,ft++):(Et=b,bt===0&&Rt(cn)),Et!==b?(kt=kr(),g.charCodeAt(ft)===125?(Mt=tt,ft++):(Mt=b,bt===0&&Rt(gn)),Mt!==b?(Et=[Et,kt,Mt],At=Et):(ft=At,At=b)):(ft=At,At=b));At!==b;){if(mt.push(At),At=[],Et=ft,kt=ft,bt++,_t.test(g.charAt(ft))?(Mt=g.charAt(ft),ft++):(Mt=b,bt===0&&Rt(rr)),bt--,Mt===b?kt=void 0:(ft=kt,kt=b),kt!==b?(Mt=vn(),Mt!==b?(kt=[kt,Mt],Et=kt):(ft=Et,Et=b)):(ft=Et,Et=b),Et!==b)for(;Et!==b;)At.push(Et),Et=ft,kt=ft,bt++,_t.test(g.charAt(ft))?(Mt=g.charAt(ft),ft++):(Mt=b,bt===0&&Rt(rr)),bt--,Mt===b?kt=void 0:(ft=kt,kt=b),kt!==b?(Mt=vn(),Mt!==b?(kt=[kt,Mt],Et=kt):(ft=Et,Et=b)):(ft=Et,Et=b);else At=b;At===b&&(At=ft,g.charCodeAt(ft)===123?(Et=et,ft++):(Et=b,bt===0&&Rt(cn)),Et!==b?(kt=kr(),g.charCodeAt(ft)===125?(Mt=tt,ft++):(Mt=b,bt===0&&Rt(gn)),Mt!==b?(Et=[Et,kt,Mt],At=Et):(ft=At,At=b)):(ft=At,At=b))}return lt=g.substring(lt,ft),lt}function Tl(){var lt,mt,At,Et;if(lt=ft,mt=ft,At=[],Et=fr(),Et!==b)for(;Et!==b;)At.push(Et),Et=fr();else At=b;return At!==b?mt=g.substring(mt,ft):mt=At,mt!==b&&(Qt=lt,mt=Lo(mt)),lt=mt,lt}function Dl(){var lt;return Nt.test(g.charAt(ft))?(lt=g.charAt(ft),ft++):(lt=b,bt===0&&Rt(Is)),lt}function Pl(){var lt;return zt.test(g.charAt(ft))?(lt=g.charAt(ft),ft++):(lt=b,bt===0&&Rt(Vs)),lt}function $l(){var lt;return jt.test(g.charAt(ft))?(lt=g.charAt(ft),ft++):(lt=b,bt===0&&Rt(Hs)),lt}function Bl(){var lt;return qt.test(g.charAt(ft))?(lt=g.charAt(ft),ft++):(lt=b,bt===0&&Rt(js)),lt}function _l(){var lt;return Xt.test(g.charAt(ft))?(lt=g.charAt(ft),ft++):(lt=b,bt===0&&Rt(zs)),lt}function Ml(){var lt;return Zt.test(g.charAt(ft))?(lt=g.charAt(ft),ft++):(lt=b,bt===0&&Rt(Us)),lt}function Fl(){var lt;return Yt.test(g.charAt(ft))?(lt=g.charAt(ft),ft++):(lt=b,bt===0&&Rt(Ws)),lt}function Rl(){var lt;return un.test(g.charAt(ft))?(lt=g.charAt(ft),ft++):(lt=b,bt===0&&Rt(Gs)),lt}function Ol(){var lt;return Jt.test(g.charAt(ft))?(lt=g.charAt(ft),ft++):(lt=b,bt===0&&Rt(Ys)),lt}function Ll(){var lt;return rn.test(g.charAt(ft))?(lt=g.charAt(ft),ft++):(lt=b,bt===0&&Rt(Ks)),lt}function Nl(){var lt;return dn.test(g.charAt(ft))?(lt=g.charAt(ft),ft++):(lt=b,bt===0&&Rt(Xs)),lt}function en(){var lt,mt;for(lt=[],mt=lr(),mt===b&&(mt=ur(),mt===b&&(mt=jr()));mt!==b;)lt.push(mt),mt=lr(),mt===b&&(mt=ur(),mt===b&&(mt=jr()));return lt}function Il(){var lt,mt;for(lt=[],mt=lr(),mt===b&&(mt=zr());mt!==b;)lt.push(mt),mt=lr(),mt===b&&(mt=zr());return lt}function Tr(){var lt,mt,At,Et;if(lt=[],mt=ft,At=en(),g.charCodeAt(ft)===59?(Et=wn,ft++):(Et=b,bt===0&&Rt(Or)),Et!==b?(At=[At,Et],mt=At):(ft=mt,mt=b),mt!==b)for(;mt!==b;)lt.push(mt),mt=ft,At=en(),g.charCodeAt(ft)===59?(Et=wn,ft++):(Et=b,bt===0&&Rt(Or)),Et!==b?(At=[At,Et],mt=At):(ft=mt,mt=b);else lt=b;return lt===b&&(lt=ft,mt=Il(),At=Ur(),At===b&&(At=null),Et=ur(),Et!==b?(mt=[mt,At,Et],lt=mt):(ft=lt,lt=b),lt===b&&(lt=ft,mt=en(),At=Vl(),At!==b?(mt=[mt,At],lt=mt):(ft=lt,lt=b))),lt}function Vl(){var lt,mt;return lt=ft,bt++,g.length>ft?(mt=g.charAt(ft),ft++):(mt=b,bt===0&&Rt($r)),bt--,mt===b?lt=void 0:(ft=lt,lt=b),lt}const Hl=d.reservedWords||[];if(sr=_e(),sr!==b&&ft===g.length)return sr;throw sr!==b&&ft{et[tt]=_e[tt].slice()}),et}const $="plugins"in d?d.plugins:[],j={parser:peg.parser,passes:b(peg.compiler.passes),reservedWords:peg.RESERVED_WORDS.slice()};return $.forEach(_e=>{_e.use(j,d)}),peg.compiler.compile(j.parser.parse(g,{grammarSource:d.grammarSource,reservedWords:j.reservedWords}),j.passes,d)}};var peg_1=peg;const peggy=getDefaultExportFromCjs(peg_1),tocLangGrammarUrl="data:application/octet-stream;base64,Ly8gRGVidWcgd2l0aCBQZWdneUpzIHNhbmRib3gKLy8gaHR0cHM6Ly9wZWdneWpzLm9yZy9vbmxpbmUuaHRtbAoKewogIGZ1bmN0aW9uIG1ha2VJbnRlZ2VyKG8pIHsKICAgIHJldHVybiBwYXJzZUludChvLmpvaW4oIiIpLCAxMCk7CiAgfQp9CgpzdGFydAogID0gc3RhdGVtZW50OnN0YXRlbWVudD8gbW9yZVN0YXRlbWVudHM6KEVPTCBfIEBzdGF0ZW1lbnQpKiBFT0w/IF8KewogIGNvbnN0IHN0YXRlbWVudHMgPSBzdGF0ZW1lbnQgPyBbc3RhdGVtZW50LCAuLi5tb3JlU3RhdGVtZW50c10gOiBtb3JlU3RhdGVtZW50czsKICByZXR1cm4gewogICAgc3RhdGVtZW50czogc3RhdGVtZW50cwogIH07Cn0KCnN0YXRlbWVudCA9IGNvbW1lbnRMaW5lIC8gbm9kZVN0YXRlbWVudCAvIGVkZ2VTdGF0ZW1lbnQKCmNvbW1lbnRMaW5lID0gXyAiIyIgdGV4dDooW15cblxyXSopCnsKICByZXR1cm4gewogICAgdHlwZTogImNvbW1lbnQiLAogICAgdGV4dDogdGV4dC5qb2luKCIiKQogIH07Cn0KCm5vZGVTdGF0ZW1lbnQgPSBfIGlkZW50OmlkZW50IF8gbGFiZWw6Y29sb25MYWJlbCBfIHBhcmFtczpwYXJhbUJsb2NrPyBfCiAgewogICAgcmV0dXJuIHsKICAgICAgdHlwZTogIm5vZGUiLAogICAgICBpZDogaWRlbnQsCiAgICAgIHRleHQ6IGxhYmVsLAogICAgICBwYXJhbXM6IHBhcmFtcyB8fCB7fQogICAgfTsKICB9Cgpjb2xvbkxhYmVsID0gIjoiIF9fIGxhYmVsOmxhYmVsCiAgewogICAgcmV0dXJuIGxhYmVsCiAgfQoKZWRnZVN0YXRlbWVudCA9IGxlZnRFZGdlU3RhdGVtZW50IC8gcmlnaHRFZGdlU3RhdGVtZW50IC8gYmlEaXJFZGdlU3RhdGVtZW50CgpsZWZ0RWRnZVN0YXRlbWVudCA9IF8gIHRvSWQ6aWRlbnQgXyAiPC0iIF8gZnJvbUlkczppZGVudHwuLiwgXyAiJiYiIF98IF8gbGFiZWw6Y29sb25MYWJlbD8KICB7CiAgICByZXR1cm4gewogICAgICB0eXBlOiAiZWRnZSIsCiAgICAgIHRvSWQ6IHRvSWQsCiAgICAgIHRleHQ6IGxhYmVsIHx8IHVuZGVmaW5lZCwKICAgICAgZnJvbUlkczogZnJvbUlkcwogICAgfTsKICB9CgpyaWdodEVkZ2VTdGF0ZW1lbnQgPSBfICBmcm9tSWRzOmlkZW50fC4uLCBfICImJiIgX3wgXyAiLT4iIF8gdG9JZDppZGVudCBfIGxhYmVsOmNvbG9uTGFiZWw/CiAgewogICAgcmV0dXJuIHsKICAgICAgdHlwZTogImVkZ2UiLAogICAgICB0b0lkOiB0b0lkLAogICAgICB0ZXh0OiBsYWJlbCB8fCB1bmRlZmluZWQsCiAgICAgIGZyb21JZHM6IGZyb21JZHMKICAgIH07CiAgfQoKYmlEaXJFZGdlU3RhdGVtZW50ID0gXyAgZnJvbUlkOmlkZW50IF8gIi0tIiBfIHRvSWQ6aWRlbnQgXyBsYWJlbDpjb2xvbkxhYmVsPwogIHsKICAgIHJldHVybiB7CiAgICAgIHR5cGU6ICJlZGdlIiwKICAgICAgdG9JZDogdG9JZCwKICAgICAgdGV4dDogbGFiZWwgfHwgdW5kZWZpbmVkLAogICAgICBmcm9tSWRzOiBbZnJvbUlkXSwKICAgICAgYmlEaXJlY3Rpb25hbDogdHJ1ZQogICAgfTsKICB9CgoKcGFyYW1CbG9jayA9ICJ7IiAgXyBFT0w/IF8gcGFyYW1zOnBhcmFtfC4uLCBfICJFT0wiIF98ICJ9IiAKewoJcmV0dXJuIE9iamVjdC5mcm9tRW50cmllcyhwYXJhbXMpOwp9CgpwYXJhbSA9IGlkZW50OmlkZW50IF8gJzonIF8gZXhwcmVzc2lvbjoobnVtL2xhYmVsKSBfIEVPTD8gXwp7CglyZXR1cm4gW2lkZW50LCBleHByZXNzaW9uXTsKfQoKbnVtID0gIG51bTooWzAtOV0rKQp7IHJldHVybiBtYWtlSW50ZWdlcihudW0pOyB9CgppZGVudCA9IGlkOihbYS16QS1aMC05XyddKykKeyByZXR1cm4gaWQuam9pbigiIik7IH0KCmxhYmVsID0gc3RyOnN0cmluZyAvIHRleHQ6KFtee31cbl0qKQp7IHJldHVybiB0ZXh0LmpvaW4oIiIpLnRyaW0oKTsgfQoKc3RyaW5nID0gIlwiIiB0ZXh0OihbXiJdKikgIlwiIgp7IHJldHVybiB0ZXh0LmpvaW4oIiIpOyB9CgpFT0wKICA9IFsgXHRdKiBbXG5ccl0rCgpfICJvcHRpb25hbCB3aGl0ZXNwYWNlIgogID0gWyBcdF0qCgpfXyAid2hpdGVzcGFjZSIKICA9IFsgXHRdKwo=",loadFile=async g=>await(await fetch(g)).text(),tocLangParserPromise=loadFile(tocLangGrammarUrl).then(g=>peggy.generate(g)),parsersPromise=Promise.all([tocLangParserPromise]).then(([g])=>({"evaporating-cloud":g,"goal-tree":g,"problem-tree":g})),isGoalNodeStatement=g=>g.type==="node"&&normalizeId(g.id)==="goal",normalizeId=g=>g&&g.toLowerCase()==="goal"?"Goal":g,parseGoalTreeSemantics=g=>{const d=new Map;d.set("Goal",{key:"Goal",label:"",annotation:"G"});const b=[],$=g.statements.find(isGoalNodeStatement);return $&&(d.get("Goal").label=$.text),g.statements.filter(j=>j.type==="node").forEach(j=>{const _e={key:j.id,label:j.text};j.params.class&&(_e.annotation=j.params.class),j.id==="Goal"&&(_e.annotation="G"),(j.params.status||j.params.status===0)&&(_e.statusPercentage=j.params.status),d.set(j.id,_e)}),g.statements.filter(j=>j.type==="edge").forEach(j=>{const _e=j.toId;if(!d.has(_e))throw new Error(`Node ${_e} not found`);if(j.fromIds.length!==1)throw new Error("Edges must have exactly one 'from' node in a Goal Tree");const et=j.fromIds[0];if(!d.has(et))throw new Error(`Requirement ${et} not found`);_e==="Goal"&&(d.get(et).annotation="CSF"),b.push({from:et,to:_e})}),{nodes:d,edges:b,rankdir:"BT"}},parseProblemTreeSemantics=g=>{const d=new Map,b=[],$=j=>{var et,tt,nt;const _e=/^(UDE|FOL|DE)/i;if(typeof((et=j.params)==null?void 0:et.class)=="string"&&((nt=(tt=j.params)==null?void 0:tt.class)!=null&&nt.match(_e)))return j.params.class.match(_e)[0].toUpperCase()};return g.statements.filter(j=>j.type==="node").forEach(j=>{d.set(j.id,{annotation:$(j),key:j.id,label:j.text})}),g.statements.filter(j=>j.type==="edge").forEach(j=>{const _e=j.toId;let et=_e;if(j.fromIds.length>1){const tt=j.fromIds.join("_")+"_cause_"+_e;et=tt,d.set(tt,{key:tt,label:"AND",intermediate:!0}),b.push({from:tt,to:_e})}for(const tt of j.fromIds){if(!d.has(tt))throw new Error(`Cause ${tt} not declared`);if(!d.has(_e))throw new Error(`Effect ${_e} not declared`);b.push({from:tt,to:et})}}),{nodes:d,edges:b,rankdir:"BT"}},normalizeAstIds=g=>{const{statements:d,...b}=g;return{statements:d.map(j=>{const{id:_e,fromIds:et,toId:tt,...nt}=j,rt={...nt};return _e&&(rt.id=normalizeId(_e)),tt&&(rt.toId=normalizeId(tt)),et&&(rt.fromIds=et.map(normalizeId)),rt}),...b}},parseTextToAst=async(g,d)=>{const b=(await parsersPromise)[g];if(!d)return{statements:[]};const $=b.parse(d);return normalizeAstIds($)};async function loader({params:g}){const d={"evaporating-cloud":exampleEvaporatingCloudText,"goal-tree":exampleGoalTreeText,"problem-tree":exampleProblemTreeText};return{diagramType:g.diagramType,example:d[g.diagramType]}}function Draw(){const{diagramType:g,example:d}=useLoaderData();console.log("diagramType",g);const[b,$]=React.useState(null),[j,_e]=React.useState(null),[et,tt]=React.useState(""),[nt,rt]=React.useState();React.useEffect(()=>{rt(d)},[g]);const it=async st=>{try{const ot=await parseTextToAst(g,st);_e(g==="goal-tree"?parseGoalTreeSemantics(ot):g==="problem-tree"?parseProblemTreeSemantics(ot):null),console.log(ot),$(ot),tt("")}catch(ot){console.error(ot),tt(ot.toString())}};return jsxRuntimeExports.jsxs("div",{className:"flex-row",children:[jsxRuntimeExports.jsx("div",{className:"flex-1",children:jsxRuntimeExports.jsx(EditorContainer,{onChange:it,rows:20,text:nt,setText:rt,error:et})}),jsxRuntimeExports.jsx("div",{className:"flex-1",children:jsxRuntimeExports.jsx(Diagram,{ast:b,semantics:j,diagramType:g})})]})}function About(g){return jsxRuntimeExports.jsxs("div",{id:"about-page",children:[jsxRuntimeExports.jsx("h1",{children:"TOC-Lang"}),jsxRuntimeExports.jsxs("p",{children:["Generate"," ",jsxRuntimeExports.jsx("a",{href:"https://en.wikipedia.org/wiki/Theory_of_constraints",children:"Theory of Constraints"})," ","diagrams from text-based notation. Learn more"," ",jsxRuntimeExports.jsx("a",{href:"https://github.com/raymyers/toc-lang/",children:"on GitHub!"})]})]})}const router=createBrowserRouter([{path:"/",element:jsxRuntimeExports.jsx(App,{}),errorElement:jsxRuntimeExports.jsx(ErrorPage,{}),children:[{index:!0,loader:async()=>redirect("/draw/goal-tree")},{path:"draw/:diagramType",element:jsxRuntimeExports.jsx(Draw,{}),loader},{path:"about",element:jsxRuntimeExports.jsx(About,{})}]}],{basename:"/toc-lang"}),rootResetElt=document.getElementById("root-reset");rootResetElt&&client.createRoot(rootResetElt).render(jsxRuntimeExports.jsx(React.StrictMode,{children:jsxRuntimeExports.jsx(RouterProvider,{router})}))});export default Ul(); diff --git a/index.html b/index.html index 1c034de..71dc6d7 100644 --- a/index.html +++ b/index.html @@ -5,7 +5,7 @@ TOC-Lang (Preview) - +