@intelliweave/embedded 1.6.47 → 1.6.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/component/component.js +15 -15
- package/dist/intelliweave-wordpress.zip +0 -0
- package/dist/node/node.js +1 -1
- package/dist/react/react.js +15 -15
- package/dist/script-tag/script-tag.js +13 -13
- package/dist/webpack/index.js +13 -13
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as pr,c as Oi,d as _i}from"./chunk-FSRPMVAS.js";var gs=pr((v1,ms)=>{"use strict";var _n=Object.prototype.hasOwnProperty,fs=Object.prototype.toString,ls=Object.defineProperty,us=Object.getOwnPropertyDescriptor,cs=function(n){return typeof Array.isArray=="function"?Array.isArray(n):fs.call(n)==="[object Array]"},ps=function(n){if(!n||fs.call(n)!=="[object Object]")return!1;var t=_n.call(n,"constructor"),r=n.constructor&&n.constructor.prototype&&_n.call(n.constructor.prototype,"isPrototypeOf");if(n.constructor&&!t&&!r)return!1;var i;for(i in n);return typeof i>"u"||_n.call(n,i)},hs=function(n,t){ls&&t.name==="__proto__"?ls(n,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):n[t.name]=t.newValue},ds=function(n,t){if(t==="__proto__")if(_n.call(n,t)){if(us)return us(n,t).value}else return;return n[t]};ms.exports=function e(){var n,t,r,i,o,a,s=arguments[0],l=1,u=arguments.length,c=!1;for(typeof s=="boolean"&&(c=s,s=arguments[1]||{},l=2),(s==null||typeof s!="object"&&typeof s!="function")&&(s={});l<u;++l)if(n=arguments[l],n!=null)for(t in n)r=ds(s,t),i=ds(n,t),s!==i&&(c&&i&&(ps(i)||(o=cs(i)))?(o?(o=!1,a=r&&cs(r)?r:[]):a=r&&ps(r)?r:{},hs(s,{name:t,newValue:e(c,a,i)})):typeof i<"u"&&hs(s,{name:t,newValue:i}));return s}});var Ws=pr(O=>{"use strict";var Kt=Symbol.for("react.element"),Op=Symbol.for("react.portal"),_p=Symbol.for("react.fragment"),Hp=Symbol.for("react.strict_mode"),Up=Symbol.for("react.profiler"),Kp=Symbol.for("react.provider"),Yp=Symbol.for("react.context"),jp=Symbol.for("react.forward_ref"),Jp=Symbol.for("react.suspense"),Qp=Symbol.for("react.memo"),qp=Symbol.for("react.lazy"),As=Symbol.iterator;function $p(e){return e===null||typeof e!="object"?null:(e=As&&e[As]||e["@@iterator"],typeof e=="function"?e:null)}var
|
|
1
|
+
import{b as pr,c as Oi,d as _i}from"./chunk-FSRPMVAS.js";var gs=pr((v1,ms)=>{"use strict";var _n=Object.prototype.hasOwnProperty,fs=Object.prototype.toString,ls=Object.defineProperty,us=Object.getOwnPropertyDescriptor,cs=function(n){return typeof Array.isArray=="function"?Array.isArray(n):fs.call(n)==="[object Array]"},ps=function(n){if(!n||fs.call(n)!=="[object Object]")return!1;var t=_n.call(n,"constructor"),r=n.constructor&&n.constructor.prototype&&_n.call(n.constructor.prototype,"isPrototypeOf");if(n.constructor&&!t&&!r)return!1;var i;for(i in n);return typeof i>"u"||_n.call(n,i)},hs=function(n,t){ls&&t.name==="__proto__"?ls(n,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):n[t.name]=t.newValue},ds=function(n,t){if(t==="__proto__")if(_n.call(n,t)){if(us)return us(n,t).value}else return;return n[t]};ms.exports=function e(){var n,t,r,i,o,a,s=arguments[0],l=1,u=arguments.length,c=!1;for(typeof s=="boolean"&&(c=s,s=arguments[1]||{},l=2),(s==null||typeof s!="object"&&typeof s!="function")&&(s={});l<u;++l)if(n=arguments[l],n!=null)for(t in n)r=ds(s,t),i=ds(n,t),s!==i&&(c&&i&&(ps(i)||(o=cs(i)))?(o?(o=!1,a=r&&cs(r)?r:[]):a=r&&ps(r)?r:{},hs(s,{name:t,newValue:e(c,a,i)})):typeof i<"u"&&hs(s,{name:t,newValue:i}));return s}});var Ws=pr(O=>{"use strict";var Kt=Symbol.for("react.element"),Op=Symbol.for("react.portal"),_p=Symbol.for("react.fragment"),Hp=Symbol.for("react.strict_mode"),Up=Symbol.for("react.profiler"),Kp=Symbol.for("react.provider"),Yp=Symbol.for("react.context"),jp=Symbol.for("react.forward_ref"),Jp=Symbol.for("react.suspense"),Qp=Symbol.for("react.memo"),qp=Symbol.for("react.lazy"),As=Symbol.iterator;function $p(e){return e===null||typeof e!="object"?null:(e=As&&e[As]||e["@@iterator"],typeof e=="function"?e:null)}var Fs={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Rs=Object.assign,zs={};function xt(e,n,t){this.props=e,this.context=n,this.refs=zs,this.updater=t||Fs}xt.prototype.isReactComponent={};xt.prototype.setState=function(e,n){if(typeof e!="object"&&typeof e!="function"&&e!=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,e,n,"setState")};xt.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function Zs(){}Zs.prototype=xt.prototype;function zi(e,n,t){this.props=e,this.context=n,this.refs=zs,this.updater=t||Fs}var Zi=zi.prototype=new Zs;Zi.constructor=zi;Rs(Zi,xt.prototype);Zi.isPureReactComponent=!0;var Ls=Array.isArray,Ps=Object.prototype.hasOwnProperty,Pi={current:null},Vs={key:!0,ref:!0,__self:!0,__source:!0};function Ns(e,n,t){var r,i={},o=null,a=null;if(n!=null)for(r in n.ref!==void 0&&(a=n.ref),n.key!==void 0&&(o=""+n.key),n)Ps.call(n,r)&&!Vs.hasOwnProperty(r)&&(i[r]=n[r]);var s=arguments.length-2;if(s===1)i.children=t;else if(1<s){for(var l=Array(s),u=0;u<s;u++)l[u]=arguments[u+2];i.children=l}if(e&&e.defaultProps)for(r in s=e.defaultProps,s)i[r]===void 0&&(i[r]=s[r]);return{$$typeof:Kt,type:e,key:o,ref:a,props:i,_owner:Pi.current}}function eh(e,n){return{$$typeof:Kt,type:e.type,key:n,ref:e.ref,props:e.props,_owner:e._owner}}function Vi(e){return typeof e=="object"&&e!==null&&e.$$typeof===Kt}function th(e){var n={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(t){return n[t]})}var Ms=/\/+/g;function Ri(e,n){return typeof e=="object"&&e!==null&&e.key!=null?th(""+e.key):n.toString(36)}function sr(e,n,t,r,i){var o=typeof e;(o==="undefined"||o==="boolean")&&(e=null);var a=!1;if(e===null)a=!0;else switch(o){case"string":case"number":a=!0;break;case"object":switch(e.$$typeof){case Kt:case Op:a=!0}}if(a)return a=e,i=i(a),e=r===""?"."+Ri(a,0):r,Ls(i)?(t="",e!=null&&(t=e.replace(Ms,"$&/")+"/"),sr(i,n,t,"",function(u){return u})):i!=null&&(Vi(i)&&(i=eh(i,t+(!i.key||a&&a.key===i.key?"":(""+i.key).replace(Ms,"$&/")+"/")+e)),n.push(i)),1;if(a=0,r=r===""?".":r+":",Ls(e))for(var s=0;s<e.length;s++){o=e[s];var l=r+Ri(o,s);a+=sr(o,n,t,l,i)}else if(l=$p(e),typeof l=="function")for(e=l.call(e),s=0;!(o=e.next()).done;)o=o.value,l=r+Ri(o,s++),a+=sr(o,n,t,l,i);else if(o==="object")throw n=String(e),Error("Objects are not valid as a React child (found: "+(n==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":n)+"). If you meant to render a collection of children, use an array instead.");return a}function ar(e,n,t){if(e==null)return e;var r=[],i=0;return sr(e,r,"","",function(o){return n.call(t,o,i++)}),r}function nh(e){if(e._status===-1){var n=e._result;n=n(),n.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t)},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t)}),e._status===-1&&(e._status=0,e._result=n)}if(e._status===1)return e._result.default;throw e._result}var de={current:null},lr={transition:null},rh={ReactCurrentDispatcher:de,ReactCurrentBatchConfig:lr,ReactCurrentOwner:Pi};function Bs(){throw Error("act(...) is not supported in production builds of React.")}O.Children={map:ar,forEach:function(e,n,t){ar(e,function(){n.apply(this,arguments)},t)},count:function(e){var n=0;return ar(e,function(){n++}),n},toArray:function(e){return ar(e,function(n){return n})||[]},only:function(e){if(!Vi(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};O.Component=xt;O.Fragment=_p;O.Profiler=Up;O.PureComponent=zi;O.StrictMode=Hp;O.Suspense=Jp;O.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=rh;O.act=Bs;O.cloneElement=function(e,n,t){if(e==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var r=Rs({},e.props),i=e.key,o=e.ref,a=e._owner;if(n!=null){if(n.ref!==void 0&&(o=n.ref,a=Pi.current),n.key!==void 0&&(i=""+n.key),e.type&&e.type.defaultProps)var s=e.type.defaultProps;for(l in n)Ps.call(n,l)&&!Vs.hasOwnProperty(l)&&(r[l]=n[l]===void 0&&s!==void 0?s[l]:n[l])}var l=arguments.length-2;if(l===1)r.children=t;else if(1<l){s=Array(l);for(var u=0;u<l;u++)s[u]=arguments[u+2];r.children=s}return{$$typeof:Kt,type:e.type,key:i,ref:o,props:r,_owner:a}};O.createContext=function(e){return e={$$typeof:Yp,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:Kp,_context:e},e.Consumer=e};O.createElement=Ns;O.createFactory=function(e){var n=Ns.bind(null,e);return n.type=e,n};O.createRef=function(){return{current:null}};O.forwardRef=function(e){return{$$typeof:jp,render:e}};O.isValidElement=Vi;O.lazy=function(e){return{$$typeof:qp,_payload:{_status:-1,_result:e},_init:nh}};O.memo=function(e,n){return{$$typeof:Qp,type:e,compare:n===void 0?null:n}};O.startTransition=function(e){var n=lr.transition;lr.transition={};try{e()}finally{lr.transition=n}};O.unstable_act=Bs;O.useCallback=function(e,n){return de.current.useCallback(e,n)};O.useContext=function(e){return de.current.useContext(e)};O.useDebugValue=function(){};O.useDeferredValue=function(e){return de.current.useDeferredValue(e)};O.useEffect=function(e,n){return de.current.useEffect(e,n)};O.useId=function(){return de.current.useId()};O.useImperativeHandle=function(e,n,t){return de.current.useImperativeHandle(e,n,t)};O.useInsertionEffect=function(e,n){return de.current.useInsertionEffect(e,n)};O.useLayoutEffect=function(e,n){return de.current.useLayoutEffect(e,n)};O.useMemo=function(e,n){return de.current.useMemo(e,n)};O.useReducer=function(e,n,t){return de.current.useReducer(e,n,t)};O.useRef=function(e){return de.current.useRef(e)};O.useState=function(e){return de.current.useState(e)};O.useSyncExternalStore=function(e,n,t){return de.current.useSyncExternalStore(e,n,t)};O.useTransition=function(){return de.current.useTransition()};O.version="18.3.1"});var Xs=pr((Jw,Gs)=>{"use strict";Gs.exports=Ws()});var se=[];for(jt=0;jt<256;++jt)se.push((jt+256).toString(16).slice(1));var jt;function Hi(e,n=0){return(se[e[n+0]]+se[e[n+1]]+se[e[n+2]]+se[e[n+3]]+"-"+se[e[n+4]]+se[e[n+5]]+"-"+se[e[n+6]]+se[e[n+7]]+"-"+se[e[n+8]]+se[e[n+9]]+"-"+se[e[n+10]]+se[e[n+11]]+se[e[n+12]]+se[e[n+13]]+se[e[n+14]]+se[e[n+15]]).toLowerCase()}var Jt,Ys=new Uint8Array(16);function hr(){if(!Jt&&(Jt=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Jt))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Jt(Ys)}var js=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),dr={randomUUID:js};function Js(e,n,t){if(dr.randomUUID&&!n&&!e)return dr.randomUUID();e=e||{};var r=e.random||(e.rng||hr)();if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,n){t=t||0;for(var i=0;i<16;++i)n[t+i]=r[i];return n}return Hi(r)}var Ue=Js;function Ui(e){let n=(e||"").split(`
|
|
2
2
|
`);for(;n.length>0&&n[0].trim()=="";)n.shift();for(;n.length>0&&n[n.length-1].trim()=="";)n.pop();let t=1/0;for(let r of n){let i=r.match(/^\s*/)?.[0].length||0;t=Math.min(t,i)}return t>0&&t<1/0&&(n=n.map(r=>r.substring(t))),n.join(`
|
|
3
3
|
`)}var Qs={};function Be(){return typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:Qs}function Q(){return Be().intelliweave=Be().intelliweave||Be().webWeaver||{},Be().intelliweave}async function*Ki(e){let n="",t=function*(){for(;;){let o=n.indexOf(`
|
|
4
4
|
|
|
@@ -6,7 +6,7 @@ import{b as pr,c as Oi,d as _i}from"./chunk-FSRPMVAS.js";var gs=pr((v1,ms)=>{"us
|
|
|
6
6
|
`);for(let u of l){o=u.indexOf(": ");let c=u.slice(0,o),h=u.slice(o+2);o==-1&&(c=u,h=""),c&&(s[c]!==void 0?s[c]+=`
|
|
7
7
|
`+h:s[c]=h)}yield s}},r=new TextDecoder,i=e.getReader();for(;;){let{done:o,value:a}=await i.read();if(o)break;n+=r.decode(a,{stream:!0}),yield*t()}n+=r.decode()+`
|
|
8
8
|
|
|
9
|
-
`,yield*t()}function Yi(){if(Q().userID)return Q().userID;if(typeof localStorage<"u"){let e=localStorage.getItem("intelliweave.uid")||"";return e||(e=Ue(),localStorage.setItem("intelliweave.uid",e),e)}else return Ue()}var Qt=class Qt{constructor(n){this.module="IntelliWeave";this.module=n}get debugEnabled(){return Qt.debug?!0:typeof window<"u"&&Q().debug}log(...n){this.debugEnabled&&console.log(`[IntelliWeave > ${this.module}]`,...n)}debug(...n){this.debugEnabled&&console.debug(`[IntelliWeave > ${this.module}]`,...n)}info(...n){this.debugEnabled&&console.info(`[IntelliWeave > ${this.module}]`,...n)}warn(...n){console.warn(`[IntelliWeave > ${this.module}]`,...n)}error(...n){console.error(`[IntelliWeave > ${this.module}]`,...n)}timer(n,...t){let r=Date.now();return this.debug(`[${n} 0ms] Started`,...t),(...i)=>this.debug(`[${n} ${Math.floor(Date.now()-r)}ms]`,...i)}};Qt.debug=!1;var U=Qt;var Ze=new U("ChatGPT"),qt=class{constructor(n){this.id="";this.metadata={};this.config={apiKey:"",endpoint:"",model:"gpt-4-turbo",systemMessage:"",userID:"",stream:!0,maxTokens:4096};this.messages=[];this.tools=[];this.maxToolCallsPerMessage=10;this._hasRemovedToolCallHistorySinceLastMessage=0;this.stats={tokensUsed:0};this.config={...this.config,...n}}async sendMessage(n){this.messages.push({role:"user",content:n}),await this.processMessages(),this._hasRemovedToolCallHistorySinceLastMessage=0;let t=this.messages[this.messages.length-1];return t?.role=="assistant"&&t.content||""}async processMessages(){await this.config.onBeforeMessageProcessing?.(),Ze.debug("Process message state:",{context:this.config.systemMessage,tools:this.tools.slice(),messages:this.messages.slice(),removedToolCallHistory:this._hasRemovedToolCallHistorySinceLastMessage});let n=this.messages[this.messages.length-1];if(n?.role=="user"||n?.role=="tool")await this.trimMessages(),await this.sendToAPI(),await this.processMessages();else if(n?.role=="assistant"&&n?.tool_calls?.length){for(let t of n.tool_calls)await this.processToolCall(t);await this.processMessages()}}async trimMessages(){for(;;){let n=await this.sendToAPI(!0);if(JSON.stringify(n).length/3.8<this.config.maxTokens)break;if(this.messages.length<2){Ze.warn("[ChatGPT] Unable to trim messages, no messages left! Please check the size of the system message and the LLM's context window size.");break}for(this.messages=this.messages.slice(Math.floor(this.messages.length/2));this.messages.length&&this.messages[0].role=="tool";)this.messages.shift()}}async sendToAPI(n){let t=0;for(let l=this.messages.length-1;l>=0;l--)if(this.messages[l].role=="assistant"&&this.messages[l].tool_calls){if(t+=1,t>=this.maxToolCallsPerMessage)throw new Error(`Exceeded the maximum tool calls per message limit of ${this.maxToolCallsPerMessage}.`)}else if(this.messages[l].role=="user")break;Ze.debug("Before LLM state:",{context:this.config.systemMessage,tools:this.tools.slice(),messages:this.messages.slice(),removedToolCallHistory:this._hasRemovedToolCallHistorySinceLastMessage});let r={model:this.config.model,temperature:.2,user:this.config.userID,tools:[],stream:!!this.config.stream,max_tokens:1024,messages:[{role:"system",content:this.config.systemMessage},...this.messages]};for(let l of this.tools){l.description&&l.description.length>1024&&Ze.warn(`Tool description for "${l.name}" is too long, it will be truncated.`);let u={type:"function",function:{name:l.name,description:(l.description||"").substring(0,1024),parameters:{type:"object",properties:{}}}};if(Array.isArray(l.params))for(let c of l.params)u.function.parameters.properties[c.name]={type:c.type,description:c.description};else if(l.params){let c=l.params;for(let h in c)u.function.parameters.properties[h]={type:"string",description:c[h]}}r.tools.push(u)}r.user||delete r.user,r.tools.length||delete r.tools;let i={};if(i["Content-Type"]="application/json",this.config.apiKey&&(i.Authorization=`Bearer ${this.config.apiKey}`),n)return r;let o=await fetch(this.config.endpoint||"https://api.openai.com/v1/chat/completions",{method:"POST",headers:i,body:JSON.stringify(r)});if(!o.ok){let l=`${o.status} ${o.statusText}`;try{let c=await o.json();l=c.errorText||c.error?.message||c.error||l}catch{}let u=new Error(l);throw u.code=o.status,u}let a=null,s=null;if(this.config.stream)for await(let l of Ki(o.body)){if(l.data=="[DONE]")break;if(!l.data)continue;let u=JSON.parse(l.data);if(s){for(let c in u.choices[0].delta)if(typeof u.choices[0].delta[c]=="string"){if(c=="role"&&s[c]==u.choices[0].delta[c])continue;s[c]=(s[c]||"")+u.choices[0].delta[c]}for(let c of u.choices[0].delta.tool_calls||[]){if(s.tool_calls||(s.tool_calls=[]),!s.tool_calls[c.index]){s.tool_calls[c.index]=c;continue}let h=s.tool_calls[c.index];h.function=h.function||{},h.function.name=(h.function.name||"")+(c.function?.name||""),h.function.arguments=(h.function.arguments||"")+(c.function?.arguments||"")}}else s={chunkID:u.id,...u.choices[0].delta};s?.content&&!s.content.startsWith("{")&&this.config.onAIMessage?.(s.content,!0)}else a=await o.json(),this.stats.tokensUsed+=a.usage?.total_tokens||0,Ze.debug(`Used ${a.usage?.total_tokens||0} tokens, total used: ${this.stats.tokensUsed}`),s=a.choices?.[0]?.message;if(s||(Ze.warn("No response block in API response."),s={role:"assistant",content:""}),s.role=="user")throw new Error("API returned a user message, which is not allowed.");this.processIncomingMessage(s),this.messages.push(s),s.content&&this.config.onAIMessage?.(s.content,!1)}processIncomingMessage(n){}registerTool(n){this.tools.push(n)}async processToolCall(n){try{let t=this.tools.find(o=>o.name==n.function.name);if(!t)throw new Error(`Tool "${n.function.name}" not found.`);let r=JSON.parse(n.function.arguments);this.config.onAIToolStart?.(n.function.name,r);let i=await t.callback(r);if(typeof i!="string"&&(i=JSON.stringify(i)||""),(i===""||i==="undefined")&&(i="success"),this._hasRemovedToolCallHistorySinceLastMessage<3&&t.removeFromMessageHistory){Ze.debug(`Removing tool call history for "${t.name}"`),this._hasRemovedToolCallHistorySinceLastMessage++,this.messages=this.messages.filter(o=>o.role!="assistant"||!o.tool_calls?.find(a=>a.id==n.id));return}else t.removeFromMessageHistory&&Ze.info(`The AI attempted to reuse a tool call that we removed from history. Skipping... "${t.name}"`);this.messages.push({role:"tool",content:i,tool_call_id:n.id})}catch(t){Ze.warn(`Unable to process tool call for "${n?.function?.name}"`,t),this.messages.push({role:"tool",content:`Error: ${t.message}`,tool_call_id:n.id})}}resetConversation(){this.messages=[]}};var J=function(){return J=Object.assign||function(n){for(var t,r=1,i=arguments.length;r<i;r++){t=arguments[r];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(n[o]=t[o])}return n},J.apply(this,arguments)};function qs(e,n,t,r){function i(o){return o instanceof t?o:new t(function(a){a(o)})}return new(t||(t=Promise))(function(o,a){function s(c){try{u(r.next(c))}catch(h){a(h)}}function l(c){try{u(r.throw(c))}catch(h){a(h)}}function u(c){c.done?o(c.value):i(c.value).then(s,l)}u((r=r.apply(e,n||[])).next())})}function $s(e,n){var t={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,a;return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(u){return function(c){return l([u,c])}}function l(u){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(t=0)),t;)try{if(r=1,i&&(o=u[0]&2?i.return:u[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,u[1])).done)return o;switch(i=0,o&&(u=[u[0]&2,o.value]),u[0]){case 0:case 1:o=u;break;case 4:return t.label++,{value:u[1],done:!1};case 5:t.label++,i=u[1],u=[0];continue;case 7:u=t.ops.pop(),t.trys.pop();continue;default:if(o=t.trys,!(o=o.length>0&&o[o.length-1])&&(u[0]===6||u[0]===2)){t=0;continue}if(u[0]===3&&(!o||u[1]>o[0]&&u[1]<o[3])){t.label=u[1];break}if(u[0]===6&&t.label<o[1]){t.label=o[1],o=u;break}if(o&&t.label<o[2]){t.label=o[2],t.ops.push(u);break}o[2]&&t.ops.pop(),t.trys.pop();continue}u=n.call(e,t)}catch(c){u=[6,c],i=0}finally{r=o=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}function X(e){var n=typeof Symbol=="function"&&Symbol.iterator,t=n&&e[n],r=0;if(t)return t.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")}function $(e,n){var t=typeof Symbol=="function"&&e[Symbol.iterator];if(!t)return e;var r=t.call(e),i,o=[],a;try{for(;(n===void 0||n-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(s){a={error:s}}finally{try{i&&!i.done&&(t=r.return)&&t.call(r)}finally{if(a)throw a.error}}return o}var el="ENTRIES",$i="KEYS",eo="VALUES",le="",fr=function(){function e(n,t){var r=n._tree,i=Array.from(r.keys());this.set=n,this._type=t,this._path=i.length>0?[{node:r,keys:i}]:[]}return e.prototype.next=function(){var n=this.dive();return this.backtrack(),n},e.prototype.dive=function(){if(this._path.length===0)return{done:!0,value:void 0};var n=ot(this._path),t=n.node,r=n.keys;if(ot(r)===le)return{done:!1,value:this.result()};var i=t.get(ot(r));return this._path.push({node:i,keys:Array.from(i.keys())}),this.dive()},e.prototype.backtrack=function(){if(this._path.length!==0){var n=ot(this._path).keys;n.pop(),!(n.length>0)&&(this._path.pop(),this.backtrack())}},e.prototype.key=function(){return this.set._prefix+this._path.map(function(n){var t=n.keys;return ot(t)}).filter(function(n){return n!==le}).join("")},e.prototype.value=function(){return ot(this._path).node.get(le)},e.prototype.result=function(){switch(this._type){case eo:return this.value();case $i:return this.key();default:return[this.key(),this.value()]}},e.prototype[Symbol.iterator]=function(){return this},e}(),ot=function(e){return e[e.length-1]},tl=function(e,n,t){var r=new Map;if(n===void 0)return r;for(var i=n.length+1,o=i+t,a=new Uint8Array(o*i).fill(t+1),s=0;s<i;++s)a[s]=s;for(var l=1;l<o;++l)a[l*i]=l;return to(e,n,t,r,a,1,i,""),r},to=function(e,n,t,r,i,o,a,s){var l,u,c=o*a;try{e:for(var h=X(e.keys()),d=h.next();!d.done;d=h.next()){var p=d.value;if(p===le){var g=i[c-1];g<=t&&r.set(s,[e.get(p),g])}else{for(var w=o,k=0;k<p.length;++k,++w){for(var y=p[k],I=a*w,v=I-a,z=i[I],Z=Math.max(0,w-t-1),x=Math.min(a-1,w+t),L=Z;L<x;++L){var R=y!==n[L],M=i[v+L]+ +R,P=i[v+L+1]+1,D=i[I+L]+1,F=i[I+L+1]=Math.min(M,P,D);F<z&&(z=F)}if(z>t)continue e}to(e.get(p),n,t,r,i,w,a,s+p)}}}catch(E){l={error:E}}finally{try{d&&!d.done&&(u=h.return)&&u.call(h)}finally{if(l)throw l.error}}},mr=function(){function e(n,t){n===void 0&&(n=new Map),t===void 0&&(t=""),this._size=void 0,this._tree=n,this._prefix=t}return e.prototype.atPrefix=function(n){var t,r;if(!n.startsWith(this._prefix))throw new Error("Mismatched prefix");var i=$(en(this._tree,n.slice(this._prefix.length)),2),o=i[0],a=i[1];if(o===void 0){var s=$(Sr(a),2),l=s[0],u=s[1];try{for(var c=X(l.keys()),h=c.next();!h.done;h=c.next()){var d=h.value;if(d!==le&&d.startsWith(u)){var p=new Map;return p.set(d.slice(u.length),l.get(d)),new e(p,n)}}}catch(g){t={error:g}}finally{try{h&&!h.done&&(r=c.return)&&r.call(c)}finally{if(t)throw t.error}}}return new e(o,n)},e.prototype.clear=function(){this._size=void 0,this._tree.clear()},e.prototype.delete=function(n){return this._size=void 0,nl(this._tree,n)},e.prototype.entries=function(){return new fr(this,el)},e.prototype.forEach=function(n){var t,r;try{for(var i=X(this),o=i.next();!o.done;o=i.next()){var a=$(o.value,2),s=a[0],l=a[1];n(s,l,this)}}catch(u){t={error:u}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}},e.prototype.fuzzyGet=function(n,t){return tl(this._tree,n,t)},e.prototype.get=function(n){var t=wr(this._tree,n);return t!==void 0?t.get(le):void 0},e.prototype.has=function(n){var t=wr(this._tree,n);return t!==void 0&&t.has(le)},e.prototype.keys=function(){return new fr(this,$i)},e.prototype.set=function(n,t){if(typeof n!="string")throw new Error("key must be a string");this._size=void 0;var r=gr(this._tree,n);return r.set(le,t),this},Object.defineProperty(e.prototype,"size",{get:function(){if(this._size)return this._size;this._size=0;for(var n=this.entries();!n.next().done;)this._size+=1;return this._size},enumerable:!1,configurable:!0}),e.prototype.update=function(n,t){if(typeof n!="string")throw new Error("key must be a string");this._size=void 0;var r=gr(this._tree,n);return r.set(le,t(r.get(le))),this},e.prototype.fetch=function(n,t){if(typeof n!="string")throw new Error("key must be a string");this._size=void 0;var r=gr(this._tree,n),i=r.get(le);return i===void 0&&r.set(le,i=t()),i},e.prototype.values=function(){return new fr(this,eo)},e.prototype[Symbol.iterator]=function(){return this.entries()},e.from=function(n){var t,r,i=new e;try{for(var o=X(n),a=o.next();!a.done;a=o.next()){var s=$(a.value,2),l=s[0],u=s[1];i.set(l,u)}}catch(c){t={error:c}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(t)throw t.error}}return i},e.fromObject=function(n){return e.from(Object.entries(n))},e}(),en=function(e,n,t){var r,i;if(t===void 0&&(t=[]),n.length===0||e==null)return[e,t];try{for(var o=X(e.keys()),a=o.next();!a.done;a=o.next()){var s=a.value;if(s!==le&&n.startsWith(s))return t.push([e,s]),en(e.get(s),n.slice(s.length),t)}}catch(l){r={error:l}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(r)throw r.error}}return t.push([e,n]),en(void 0,"",t)},wr=function(e,n){var t,r;if(n.length===0||e==null)return e;try{for(var i=X(e.keys()),o=i.next();!o.done;o=i.next()){var a=o.value;if(a!==le&&n.startsWith(a))return wr(e.get(a),n.slice(a.length))}}catch(s){t={error:s}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}},gr=function(e,n){var t,r,i=n.length;e:for(var o=0;e&&o<i;){try{for(var a=(t=void 0,X(e.keys())),s=a.next();!s.done;s=a.next()){var l=s.value;if(l!==le&&n[o]===l[0]){for(var u=Math.min(i-o,l.length),c=1;c<u&&n[o+c]===l[c];)++c;var h=e.get(l);if(c===l.length)e=h;else{var d=new Map;d.set(l.slice(c),h),e.set(n.slice(o,o+c),d),e.delete(l),e=d}o+=c;continue e}}}catch(g){t={error:g}}finally{try{s&&!s.done&&(r=a.return)&&r.call(a)}finally{if(t)throw t.error}}var p=new Map;return e.set(n.slice(o),p),p}return e},nl=function(e,n){var t=$(en(e,n),2),r=t[0],i=t[1];if(r!==void 0){if(r.delete(le),r.size===0)no(i);else if(r.size===1){var o=$(r.entries().next().value,2),a=o[0],s=o[1];ro(i,a,s)}}},no=function(e){if(e.length!==0){var n=$(Sr(e),2),t=n[0],r=n[1];if(t.delete(r),t.size===0)no(e.slice(0,-1));else if(t.size===1){var i=$(t.entries().next().value,2),o=i[0],a=i[1];o!==le&&ro(e.slice(0,-1),o,a)}}},ro=function(e,n,t){if(e.length!==0){var r=$(Sr(e),2),i=r[0],o=r[1];i.set(o+n,t),i.delete(o)}},Sr=function(e){return e[e.length-1]},kt,Cr="or",io="and",rl="and_not",oo=function(){function e(n){if(n?.fields==null)throw new Error('MiniSearch: option "fields" must be provided');var t=n.autoVacuum==null||n.autoVacuum===!0?br:n.autoVacuum;this._options=J(J(J({},xr),n),{autoVacuum:t,searchOptions:J(J({},ji),n.searchOptions||{}),autoSuggestOptions:J(J({},ll),n.autoSuggestOptions||{})}),this._index=new mr,this._documentCount=0,this._documentIds=new Map,this._idToShortId=new Map,this._fieldIds={},this._fieldLength=new Map,this._avgFieldLength=[],this._nextId=0,this._storedFields=new Map,this._dirtCount=0,this._currentVacuum=null,this._enqueuedVacuum=null,this._enqueuedVacuumConditions=kr,this.addFields(this._options.fields)}return e.prototype.add=function(n){var t,r,i,o,a,s,l=this._options,u=l.extractField,c=l.tokenize,h=l.processTerm,d=l.fields,p=l.idField,g=u(n,p);if(g==null)throw new Error('MiniSearch: document does not have ID field "'.concat(p,'"'));if(this._idToShortId.has(g))throw new Error("MiniSearch: duplicate ID ".concat(g));var w=this.addDocumentId(g);this.saveStoredFields(w,n);try{for(var k=X(d),y=k.next();!y.done;y=k.next()){var I=y.value,v=u(n,I);if(v!=null){var z=c(v.toString(),I),Z=this._fieldIds[I],x=new Set(z).size;this.addFieldLength(w,Z,this._documentCount-1,x);try{for(var L=(i=void 0,X(z)),R=L.next();!R.done;R=L.next()){var M=R.value,P=h(M,I);if(Array.isArray(P))try{for(var D=(a=void 0,X(P)),F=D.next();!F.done;F=D.next()){var E=F.value;this.addTerm(Z,w,E)}}catch(A){a={error:A}}finally{try{F&&!F.done&&(s=D.return)&&s.call(D)}finally{if(a)throw a.error}}else P&&this.addTerm(Z,w,P)}}catch(A){i={error:A}}finally{try{R&&!R.done&&(o=L.return)&&o.call(L)}finally{if(i)throw i.error}}}}}catch(A){t={error:A}}finally{try{y&&!y.done&&(r=k.return)&&r.call(k)}finally{if(t)throw t.error}}},e.prototype.addAll=function(n){var t,r;try{for(var i=X(n),o=i.next();!o.done;o=i.next()){var a=o.value;this.add(a)}}catch(s){t={error:s}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}},e.prototype.addAllAsync=function(n,t){var r=this;t===void 0&&(t={});var i=t.chunkSize,o=i===void 0?10:i,a={chunk:[],promise:Promise.resolve()},s=n.reduce(function(c,h,d){var p=c.chunk,g=c.promise;return p.push(h),(d+1)%o===0?{chunk:[],promise:g.then(function(){return new Promise(function(w){return setTimeout(w,0)})}).then(function(){return r.addAll(p)})}:{chunk:p,promise:g}},a),l=s.chunk,u=s.promise;return u.then(function(){return r.addAll(l)})},e.prototype.remove=function(n){var t,r,i,o,a,s,l=this._options,u=l.tokenize,c=l.processTerm,h=l.extractField,d=l.fields,p=l.idField,g=h(n,p);if(g==null)throw new Error('MiniSearch: document does not have ID field "'.concat(p,'"'));var w=this._idToShortId.get(g);if(w==null)throw new Error("MiniSearch: cannot remove document with ID ".concat(g,": it is not in the index"));try{for(var k=X(d),y=k.next();!y.done;y=k.next()){var I=y.value,v=h(n,I);if(v!=null){var z=u(v.toString(),I),Z=this._fieldIds[I],x=new Set(z).size;this.removeFieldLength(w,Z,this._documentCount,x);try{for(var L=(i=void 0,X(z)),R=L.next();!R.done;R=L.next()){var M=R.value,P=c(M,I);if(Array.isArray(P))try{for(var D=(a=void 0,X(P)),F=D.next();!F.done;F=D.next()){var E=F.value;this.removeTerm(Z,w,E)}}catch(A){a={error:A}}finally{try{F&&!F.done&&(s=D.return)&&s.call(D)}finally{if(a)throw a.error}}else P&&this.removeTerm(Z,w,P)}}catch(A){i={error:A}}finally{try{R&&!R.done&&(o=L.return)&&o.call(L)}finally{if(i)throw i.error}}}}}catch(A){t={error:A}}finally{try{y&&!y.done&&(r=k.return)&&r.call(k)}finally{if(t)throw t.error}}this._storedFields.delete(w),this._documentIds.delete(w),this._idToShortId.delete(g),this._fieldLength.delete(w),this._documentCount-=1},e.prototype.removeAll=function(n){var t,r;if(n)try{for(var i=X(n),o=i.next();!o.done;o=i.next()){var a=o.value;this.remove(a)}}catch(s){t={error:s}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}else{if(arguments.length>0)throw new Error("Expected documents to be present. Omit the argument to remove all documents.");this._index=new mr,this._documentCount=0,this._documentIds=new Map,this._idToShortId=new Map,this._fieldLength=new Map,this._avgFieldLength=[],this._storedFields=new Map,this._nextId=0}},e.prototype.discard=function(n){var t=this,r=this._idToShortId.get(n);if(r==null)throw new Error("MiniSearch: cannot discard document with ID ".concat(n,": it is not in the index"));this._idToShortId.delete(n),this._documentIds.delete(r),this._storedFields.delete(r),(this._fieldLength.get(r)||[]).forEach(function(i,o){t.removeFieldLength(r,o,t._documentCount,i)}),this._fieldLength.delete(r),this._documentCount-=1,this._dirtCount+=1,this.maybeAutoVacuum()},e.prototype.maybeAutoVacuum=function(){if(this._options.autoVacuum!==!1){var n=this._options.autoVacuum,t=n.minDirtFactor,r=n.minDirtCount,i=n.batchSize,o=n.batchWait;this.conditionalVacuum({batchSize:i,batchWait:o},{minDirtCount:r,minDirtFactor:t})}},e.prototype.discardAll=function(n){var t,r,i=this._options.autoVacuum;try{this._options.autoVacuum=!1;try{for(var o=X(n),a=o.next();!a.done;a=o.next()){var s=a.value;this.discard(s)}}catch(l){t={error:l}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(t)throw t.error}}}finally{this._options.autoVacuum=i}this.maybeAutoVacuum()},e.prototype.replace=function(n){var t=this._options,r=t.idField,i=t.extractField,o=i(n,r);this.discard(o),this.add(n)},e.prototype.vacuum=function(n){return n===void 0&&(n={}),this.conditionalVacuum(n)},e.prototype.conditionalVacuum=function(n,t){var r=this;return this._currentVacuum?(this._enqueuedVacuumConditions=this._enqueuedVacuumConditions&&t,this._enqueuedVacuum!=null?this._enqueuedVacuum:(this._enqueuedVacuum=this._currentVacuum.then(function(){var i=r._enqueuedVacuumConditions;return r._enqueuedVacuumConditions=kr,r.performVacuuming(n,i)}),this._enqueuedVacuum)):this.vacuumConditionsMet(t)===!1?Promise.resolve():(this._currentVacuum=this.performVacuuming(n),this._currentVacuum)},e.prototype.performVacuuming=function(n,t){return qs(this,void 0,void 0,function(){var r,i,o,a,s,l,u,c,h,d,p,g,w,k,y,I,v,z,Z,x,L,R,M,P,D;return $s(this,function(F){switch(F.label){case 0:if(r=this._dirtCount,!this.vacuumConditionsMet(t))return[3,10];i=n.batchSize||vr.batchSize,o=n.batchWait||vr.batchWait,a=1,F.label=1;case 1:F.trys.push([1,7,8,9]),s=X(this._index),l=s.next(),F.label=2;case 2:if(l.done)return[3,6];u=$(l.value,2),c=u[0],h=u[1];try{for(d=(R=void 0,X(h)),p=d.next();!p.done;p=d.next()){g=$(p.value,2),w=g[0],k=g[1];try{for(y=(P=void 0,X(k)),I=y.next();!I.done;I=y.next())v=$(I.value,1),z=v[0],!this._documentIds.has(z)&&(k.size<=1?h.delete(w):k.delete(z))}catch(E){P={error:E}}finally{try{I&&!I.done&&(D=y.return)&&D.call(y)}finally{if(P)throw P.error}}}}catch(E){R={error:E}}finally{try{p&&!p.done&&(M=d.return)&&M.call(d)}finally{if(R)throw R.error}}return this._index.get(c).size===0&&this._index.delete(c),a%i!==0?[3,4]:[4,new Promise(function(E){return setTimeout(E,o)})];case 3:F.sent(),F.label=4;case 4:a+=1,F.label=5;case 5:return l=s.next(),[3,2];case 6:return[3,9];case 7:return Z=F.sent(),x={error:Z},[3,9];case 8:try{l&&!l.done&&(L=s.return)&&L.call(s)}finally{if(x)throw x.error}return[7];case 9:this._dirtCount-=r,F.label=10;case 10:return[4,null];case 11:return F.sent(),this._currentVacuum=this._enqueuedVacuum,this._enqueuedVacuum=null,[2]}})})},e.prototype.vacuumConditionsMet=function(n){if(n==null)return!0;var t=n.minDirtCount,r=n.minDirtFactor;return t=t||br.minDirtCount,r=r||br.minDirtFactor,this.dirtCount>=t&&this.dirtFactor>=r},Object.defineProperty(e.prototype,"isVacuuming",{get:function(){return this._currentVacuum!=null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dirtCount",{get:function(){return this._dirtCount},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dirtFactor",{get:function(){return this._dirtCount/(1+this._documentCount+this._dirtCount)},enumerable:!1,configurable:!0}),e.prototype.has=function(n){return this._idToShortId.has(n)},e.prototype.getStoredFields=function(n){var t=this._idToShortId.get(n);if(t!=null)return this._storedFields.get(t)},e.prototype.search=function(n,t){var r,i;t===void 0&&(t={});var o=this.executeQuery(n,t),a=[];try{for(var s=X(o),l=s.next();!l.done;l=s.next()){var u=$(l.value,2),c=u[0],h=u[1],d=h.score,p=h.terms,g=h.match,w=p.length||1,k={id:this._documentIds.get(c),score:d*w,terms:Object.keys(g),queryTerms:p,match:g};Object.assign(k,this._storedFields.get(c)),(t.filter==null||t.filter(k))&&a.push(k)}}catch(y){r={error:y}}finally{try{l&&!l.done&&(i=s.return)&&i.call(s)}finally{if(r)throw r.error}}return n===e.wildcard&&t.boostDocument==null&&this._options.searchOptions.boostDocument==null||a.sort(Qi),a},e.prototype.autoSuggest=function(n,t){var r,i,o,a;t===void 0&&(t={}),t=J(J({},this._options.autoSuggestOptions),t);var s=new Map;try{for(var l=X(this.search(n,t)),u=l.next();!u.done;u=l.next()){var c=u.value,h=c.score,d=c.terms,p=d.join(" "),g=s.get(p);g!=null?(g.score+=h,g.count+=1):s.set(p,{score:h,terms:d,count:1})}}catch(Z){r={error:Z}}finally{try{u&&!u.done&&(i=l.return)&&i.call(l)}finally{if(r)throw r.error}}var w=[];try{for(var k=X(s),y=k.next();!y.done;y=k.next()){var I=$(y.value,2),g=I[0],v=I[1],h=v.score,d=v.terms,z=v.count;w.push({suggestion:g,terms:d,score:h/z})}}catch(Z){o={error:Z}}finally{try{y&&!y.done&&(a=k.return)&&a.call(k)}finally{if(o)throw o.error}}return w.sort(Qi),w},Object.defineProperty(e.prototype,"documentCount",{get:function(){return this._documentCount},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"termCount",{get:function(){return this._index.size},enumerable:!1,configurable:!0}),e.loadJSON=function(n,t){if(t==null)throw new Error("MiniSearch: loadJSON should be given the same options used when serializing the index");return this.loadJS(JSON.parse(n),t)},e.getDefault=function(n){if(xr.hasOwnProperty(n))return yr(xr,n);throw new Error('MiniSearch: unknown option "'.concat(n,'"'))},e.loadJS=function(n,t){var r,i,o,a,s,l,u=n.index,c=n.documentCount,h=n.nextId,d=n.documentIds,p=n.fieldIds,g=n.fieldLength,w=n.averageFieldLength,k=n.storedFields,y=n.dirtCount,I=n.serializationVersion;if(I!==1&&I!==2)throw new Error("MiniSearch: cannot deserialize an index created with an incompatible version");var v=new e(t);v._documentCount=c,v._nextId=h,v._documentIds=$t(d),v._idToShortId=new Map,v._fieldIds=p,v._fieldLength=$t(g),v._avgFieldLength=w,v._storedFields=$t(k),v._dirtCount=y||0,v._index=new mr;try{for(var z=X(v._documentIds),Z=z.next();!Z.done;Z=z.next()){var x=$(Z.value,2),L=x[0],R=x[1];v._idToShortId.set(R,L)}}catch(ne){r={error:ne}}finally{try{Z&&!Z.done&&(i=z.return)&&i.call(z)}finally{if(r)throw r.error}}try{for(var M=X(u),P=M.next();!P.done;P=M.next()){var D=$(P.value,2),F=D[0],E=D[1],A=new Map;try{for(var N=(s=void 0,X(Object.keys(E))),H=N.next();!H.done;H=N.next()){var Y=H.value,re=E[Y];I===1&&(re=re.ds),A.set(parseInt(Y,10),$t(re))}}catch(ne){s={error:ne}}finally{try{H&&!H.done&&(l=N.return)&&l.call(N)}finally{if(s)throw s.error}}v._index.set(F,A)}}catch(ne){o={error:ne}}finally{try{P&&!P.done&&(a=M.return)&&a.call(M)}finally{if(o)throw o.error}}return v},e.prototype.executeQuery=function(n,t){var r=this;if(t===void 0&&(t={}),n===e.wildcard)return this.executeWildcardQuery(t);if(typeof n!="string"){var i=J(J(J({},t),n),{queries:void 0}),o=n.queries.map(function(k){return r.executeQuery(k,i)});return this.combineResults(o,i.combineWith)}var a=this._options,s=a.tokenize,l=a.processTerm,u=a.searchOptions,c=J(J({tokenize:s,processTerm:l},u),t),h=c.tokenize,d=c.processTerm,p=h(n).flatMap(function(k){return d(k)}).filter(function(k){return!!k}),g=p.map(sl(c)),w=g.map(function(k){return r.executeQuerySpec(k,c)});return this.combineResults(w,c.combineWith)},e.prototype.executeQuerySpec=function(n,t){var r,i,o,a,s=J(J({},this._options.searchOptions),t),l=(s.fields||this._options.fields).reduce(function(Y,re){var ne;return J(J({},Y),(ne={},ne[re]=yr(s.boost,re)||1,ne))},{}),u=s.boostDocument,c=s.weights,h=s.maxFuzzy,d=s.bm25,p=J(J({},ji.weights),c),g=p.fuzzy,w=p.prefix,k=this._index.get(n.term),y=this.termResults(n.term,n.term,1,k,l,u,d),I,v;if(n.prefix&&(I=this._index.atPrefix(n.term)),n.fuzzy){var z=n.fuzzy===!0?.2:n.fuzzy,Z=z<1?Math.min(h,Math.round(n.term.length*z)):z;Z&&(v=this._index.fuzzyGet(n.term,Z))}if(I)try{for(var x=X(I),L=x.next();!L.done;L=x.next()){var R=$(L.value,2),M=R[0],P=R[1],D=M.length-n.term.length;if(D){v?.delete(M);var F=w*M.length/(M.length+.3*D);this.termResults(n.term,M,F,P,l,u,d,y)}}}catch(Y){r={error:Y}}finally{try{L&&!L.done&&(i=x.return)&&i.call(x)}finally{if(r)throw r.error}}if(v)try{for(var E=X(v.keys()),A=E.next();!A.done;A=E.next()){var M=A.value,N=$(v.get(M),2),H=N[0],D=N[1];if(D){var F=g*M.length/(M.length+D);this.termResults(n.term,M,F,H,l,u,d,y)}}}catch(Y){o={error:Y}}finally{try{A&&!A.done&&(a=E.return)&&a.call(E)}finally{if(o)throw o.error}}return y},e.prototype.executeWildcardQuery=function(n){var t,r,i=new Map,o=J(J({},this._options.searchOptions),n);try{for(var a=X(this._documentIds),s=a.next();!s.done;s=a.next()){var l=$(s.value,2),u=l[0],c=l[1],h=o.boostDocument?o.boostDocument(c,"",this._storedFields.get(u)):1;i.set(u,{score:h,terms:[],match:{}})}}catch(d){t={error:d}}finally{try{s&&!s.done&&(r=a.return)&&r.call(a)}finally{if(t)throw t.error}}return i},e.prototype.combineResults=function(n,t){if(t===void 0&&(t=Cr),n.length===0)return new Map;var r=t.toLowerCase();return n.reduce(il[r])||new Map},e.prototype.toJSON=function(){var n,t,r,i,o=[];try{for(var a=X(this._index),s=a.next();!s.done;s=a.next()){var l=$(s.value,2),u=l[0],c=l[1],h={};try{for(var d=(r=void 0,X(c)),p=d.next();!p.done;p=d.next()){var g=$(p.value,2),w=g[0],k=g[1];h[w]=Object.fromEntries(k)}}catch(y){r={error:y}}finally{try{p&&!p.done&&(i=d.return)&&i.call(d)}finally{if(r)throw r.error}}o.push([u,h])}}catch(y){n={error:y}}finally{try{s&&!s.done&&(t=a.return)&&t.call(a)}finally{if(n)throw n.error}}return{documentCount:this._documentCount,nextId:this._nextId,documentIds:Object.fromEntries(this._documentIds),fieldIds:this._fieldIds,fieldLength:Object.fromEntries(this._fieldLength),averageFieldLength:this._avgFieldLength,storedFields:Object.fromEntries(this._storedFields),dirtCount:this._dirtCount,index:o,serializationVersion:2}},e.prototype.termResults=function(n,t,r,i,o,a,s,l){var u,c,h,d,p;if(l===void 0&&(l=new Map),i==null)return l;try{for(var g=X(Object.keys(o)),w=g.next();!w.done;w=g.next()){var k=w.value,y=o[k],I=this._fieldIds[k],v=i.get(I);if(v!=null){var z=v.size,Z=this._avgFieldLength[I];try{for(var x=(h=void 0,X(v.keys())),L=x.next();!L.done;L=x.next()){var R=L.value;if(!this._documentIds.has(R)){this.removeTerm(I,R,t),z-=1;continue}var M=a?a(this._documentIds.get(R),t,this._storedFields.get(R)):1;if(M){var P=v.get(R),D=this._fieldLength.get(R)[I],F=al(P,z,this._documentCount,D,Z,s),E=r*y*M*F,A=l.get(R);if(A){A.score+=E,ul(A.terms,n);var N=yr(A.match,t);N?N.push(k):A.match[t]=[k]}else l.set(R,{score:E,terms:[n],match:(p={},p[t]=[k],p)})}}}catch(H){h={error:H}}finally{try{L&&!L.done&&(d=x.return)&&d.call(x)}finally{if(h)throw h.error}}}}}catch(H){u={error:H}}finally{try{w&&!w.done&&(c=g.return)&&c.call(g)}finally{if(u)throw u.error}}return l},e.prototype.addTerm=function(n,t,r){var i=this._index.fetch(r,qi),o=i.get(n);if(o==null)o=new Map,o.set(t,1),i.set(n,o);else{var a=o.get(t);o.set(t,(a||0)+1)}},e.prototype.removeTerm=function(n,t,r){if(!this._index.has(r)){this.warnDocumentChanged(t,n,r);return}var i=this._index.fetch(r,qi),o=i.get(n);o==null||o.get(t)==null?this.warnDocumentChanged(t,n,r):o.get(t)<=1?o.size<=1?i.delete(n):o.delete(t):o.set(t,o.get(t)-1),this._index.get(r).size===0&&this._index.delete(r)},e.prototype.warnDocumentChanged=function(n,t,r){var i,o;try{for(var a=X(Object.keys(this._fieldIds)),s=a.next();!s.done;s=a.next()){var l=s.value;if(this._fieldIds[l]===t){this._options.logger("warn","MiniSearch: document with ID ".concat(this._documentIds.get(n),' has changed before removal: term "').concat(r,'" was not present in field "').concat(l,'". Removing a document after it has changed can corrupt the index!'),"version_conflict");return}}}catch(u){i={error:u}}finally{try{s&&!s.done&&(o=a.return)&&o.call(a)}finally{if(i)throw i.error}}},e.prototype.addDocumentId=function(n){var t=this._nextId;return this._idToShortId.set(n,t),this._documentIds.set(t,n),this._documentCount+=1,this._nextId+=1,t},e.prototype.addFields=function(n){for(var t=0;t<n.length;t++)this._fieldIds[n[t]]=t},e.prototype.addFieldLength=function(n,t,r,i){var o=this._fieldLength.get(n);o==null&&this._fieldLength.set(n,o=[]),o[t]=i;var a=this._avgFieldLength[t]||0,s=a*r+i;this._avgFieldLength[t]=s/(r+1)},e.prototype.removeFieldLength=function(n,t,r,i){if(r===1){this._avgFieldLength[t]=0;return}var o=this._avgFieldLength[t]*r-i;this._avgFieldLength[t]=o/(r-1)},e.prototype.saveStoredFields=function(n,t){var r,i,o=this._options,a=o.storeFields,s=o.extractField;if(!(a==null||a.length===0)){var l=this._storedFields.get(n);l==null&&this._storedFields.set(n,l={});try{for(var u=X(a),c=u.next();!c.done;c=u.next()){var h=c.value,d=s(t,h);d!==void 0&&(l[h]=d)}}catch(p){r={error:p}}finally{try{c&&!c.done&&(i=u.return)&&i.call(u)}finally{if(r)throw r.error}}}},e.wildcard=Symbol("*"),e}(),yr=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)?e[n]:void 0},il=(kt={},kt[Cr]=function(e,n){var t,r;try{for(var i=X(n.keys()),o=i.next();!o.done;o=i.next()){var a=o.value,s=e.get(a);if(s==null)e.set(a,n.get(a));else{var l=n.get(a),u=l.score,c=l.terms,h=l.match;s.score=s.score+u,s.match=Object.assign(s.match,h),Ji(s.terms,c)}}}catch(d){t={error:d}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}return e},kt[io]=function(e,n){var t,r,i=new Map;try{for(var o=X(n.keys()),a=o.next();!a.done;a=o.next()){var s=a.value,l=e.get(s);if(l!=null){var u=n.get(s),c=u.score,h=u.terms,d=u.match;Ji(l.terms,h),i.set(s,{score:l.score+c,terms:l.terms,match:Object.assign(l.match,d)})}}}catch(p){t={error:p}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(t)throw t.error}}return i},kt[rl]=function(e,n){var t,r;try{for(var i=X(n.keys()),o=i.next();!o.done;o=i.next()){var a=o.value;e.delete(a)}}catch(s){t={error:s}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}return e},kt),ol={k:1.2,b:.7,d:.5},al=function(e,n,t,r,i,o){var a=o.k,s=o.b,l=o.d,u=Math.log(1+(t-n+.5)/(n+.5));return u*(l+e*(a+1)/(e+a*(1-s+s*r/i)))},sl=function(e){return function(n,t,r){var i=typeof e.fuzzy=="function"?e.fuzzy(n,t,r):e.fuzzy||!1,o=typeof e.prefix=="function"?e.prefix(n,t,r):e.prefix===!0;return{term:n,fuzzy:i,prefix:o}}},xr={idField:"id",extractField:function(e,n){return e[n]},tokenize:function(e){return e.split(cl)},processTerm:function(e){return e.toLowerCase()},fields:void 0,searchOptions:void 0,storeFields:[],logger:function(e,n){typeof console?.[e]=="function"&&console[e](n)},autoVacuum:!0},ji={combineWith:Cr,prefix:!1,fuzzy:!1,maxFuzzy:6,boost:{},weights:{fuzzy:.45,prefix:.375},bm25:ol},ll={combineWith:io,prefix:function(e,n,t){return n===t.length-1}},vr={batchSize:1e3,batchWait:10},kr={minDirtFactor:.1,minDirtCount:20},br=J(J({},vr),kr),ul=function(e,n){e.includes(n)||e.push(n)},Ji=function(e,n){var t,r;try{for(var i=X(n),o=i.next();!o.done;o=i.next()){var a=o.value;e.includes(a)||e.push(a)}}catch(s){t={error:s}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}},Qi=function(e,n){var t=e.score,r=n.score;return r-t},qi=function(){return new Map},$t=function(e){var n,t,r=new Map;try{for(var i=X(Object.keys(e)),o=i.next();!o.done;o=i.next()){var a=o.value;r.set(parseInt(a,10),e[a])}}catch(s){n={error:s}}finally{try{o&&!o.done&&(t=i.return)&&t.call(i)}finally{if(n)throw n.error}}return r},cl=/[\n\r -#%-*,-/:;?@[-\]_{}\u00A0\u00A1\u00A7\u00AB\u00B6\u00B7\u00BB\u00BF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u1680\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2000-\u200A\u2010-\u2029\u202F-\u2043\u2045-\u2051\u2053-\u205F\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u3000-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]+/u;var ao=[{id:"search",type:"action",name:"Search the knowledge base.",content:"Search the knowledge base for information, actions, tools, tours, UI elements, etc. Use this on EVERY request if you don't have information. If the user asks for personal information, use this. If the user asks you to do something, use this to find the tool you need.",isContext:!0,removeFromMessageHistory:!0,parameters:[{name:"query",type:"string",description:"The search query"}],action:async(e,n)=>{let t=await n.knowledgeBase.search(e.query);n.updateKnowledgeBase(t),n.submitAnalyticsEvent({type:"kb-search",query:e.query,results:t});let r=t.filter(o=>o.type!="action").map(o=>"id="+o.id).join(", ")||"(none)",i=t.filter(o=>o.type=="action").map(o=>"name="+o.id.replaceAll(/[^a-zA-Z0-9_]/g,"_")).join(", ")||"(none)";return`Search complete, context has been updated. New info entries found: ${r}. New tools available: ${i}.`}},{id:"ui.openURL",type:"action",name:"Open a URL in a new tab.",isContext:!0,get disabled(){return typeof window>"u"},content:"Opens the specified URL in a new tab.",parameters:[{name:"url",type:"string",description:"The URL to open"}],action:(e,n)=>{if(!window.open(e.url,"_blank"))throw new Error("Window blocked by popup blocker.");return n.submitAnalyticsEvent({type:"open-url",url:e.url}),"URL opened"}}];var at=new U("KnowledgeBase"),so=1,tn=class e{constructor(n){this._sources=[{id:"core.internal",query:async()=>ao}];this._windowSources=[];this.lastResults=[];this.manualEntries=[];this.ai=n}registerSource(n,t){let r=n;return typeof n=="function"&&(t=n,r=`source.${so++}`),this._sources.push({id:r,query:t}),r}removeSource(n){this._sources=this.sources.filter(t=>t.id!==n&&t.query!==n)}addEntry(n){this.manualEntries.push(n)}removeEntry(n){this.manualEntries=this.manualEntries.filter(t=>t.id!==n)}get sources(){let n=this._sources;return typeof window<"u"&&Q().knowledgeBaseSources&&(n=n.concat(Q().knowledgeBaseSources.map(t=>({id:t.name,query:t})))),n=n.concat(this._windowSources),n=n.filter(t=>!t.disabled),n}async search(n){at.debug(`Searching knowledge base for: ${n}`);let t=new Event("webweaver_kb_search",{bubbles:!0,cancelable:!0});t.query=n,t.entries=[],t.sources=[],typeof document<"u"&&document.dispatchEvent(t),this._windowSources=t.sources;let i=(await Promise.all(this.sources.map(async l=>{try{return await l.query(n)}catch(u){return at.warn(`Knowledge source '${l.id}' failed:`,u),[]}}))).flat();i=i.concat(t.entries),i=i.concat(this.manualEntries),Q().knowledgeBase&&(i=i.concat(Q().knowledgeBase)),i=i.filter(l=>l&&!l.disabled);for(let l=0;l<i.length;l++){let u=i[l];if(u.id=u.id||`temp.${l}`,!u.action&&u.type=="tour"&&(u.action=c=>{throw new Error("This tour does not have an action. You must perform the tour content manually.")}),!u.action&&u.type=="info"&&(u.action=c=>{throw new Error("This item does not have an action. Use the content to provide information to the user instead.")}),u.parameters&&!Array.isArray(u.parameters)){let c=u.parameters,h=[];for(let d in c)h.push({name:d,type:"string",description:u.parameters[d]});u.parameters=h}u.content=Ui(typeof u.content=="function"?u.content():u.content)}let o=new oo({fields:["id","type","name","content","tags"],storeFields:[],searchOptions:{boost:{name:3,tags:2},fuzzy:.2}});o.addAll(i);let s=o.search(n).map(l=>i.find(u=>u.id==l.id));for(let l of i)l.isContext&&(s.find(u=>u.id===l.id)||s.push(l));return this.lastResults=s,at.debug("Found results:",s),s}getCachedEntry(n){return this.lastResults.find(t=>t.id==n)}registerSourceFromURL(n,t){t||(t=`external.${so++}`),at.debug(`Registering remote knowledge base source: ${n}`);let r=[],i=async(a,s)=>{at.debug(`Calling remote knowledge base action: ${a.id}`);let l={type:"action",userID:this.ai.userID,extra:this.ai.extra,actionID:a.id,parameters:s},u=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)});if(!u.ok)throw new Error(`HTTP Error ${u.status} ${u.statusText}`);let c=await u.json();return o(c.updateItems||[]),c.response},o=a=>{for(let s of a){if(!s.id){at.warn("KB item skipped since it has no ID.",s);continue}let l=r.find(u=>u.id==s.id);if(l){l.name=s.name||l.name||"",l.content=s.content||l.content||"",l.disabled=s.disabled??l.disabled,l.isContext=s.isContext??l.isContext,l.parameters=s.parameters||l.parameters||[],l.tags=s.tags||l.tags,l.type=s.type||l.type;continue}r.push({...s,action:u=>i(s,u)})}};this.registerSource(t,async a=>{let s={type:"search",userID:this.ai?.userID||"",extra:this.ai?.extra||{},query:a},l=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!l.ok)throw new Error(`HTTP Error ${l.status} ${l.statusText}`);let u=await l.json();return o(u.items),r})}clone(){let n=new e(this.ai);return n._sources=this._sources,n._windowSources=this._windowSources,n.manualEntries=this.manualEntries,n}};var lo={name:"@intelliweave/embedded",version:"1.6.47",description:"Integrate IntelliWeave into your app or website.",main:"./dist/webpack/index.js",types:"./dist/webpack/index.d.ts",type:"module",exports:{".":"./dist/webpack/index.js","./component":"./dist/component/component.js","./node":"./dist/node/node.js","./react":"./dist/react/react.js","./webpack":"./dist/webpack/index.js"},scripts:{build:"npm run build:lib && npm run build:docs","build:lib":"tsx build.ts","build:dev":"cross-env DEVELOPMENT=1 npm run build","build:docs":"typedoc src/index.mts --out dist/docs/",deploy:'npm run build && gsutil cp ./dist/web-weaver.min.js gs://metapress-cdn/web-weaver.min.js && gcloud compute url-maps invalidate-cdn-cache mp-cdn-loadbalancer --project="mp-backend-api" --path "/web-weaver.min.js" --async',"start:server":"cd server && npm run start","deploy:server":"cd server && npm run deploy","llm:build":"cd llm-server && docker build -t web-weaver-llm .","llm:start":"npm run llm:build && docker run -it --rm -p 8000:80 --gpus=all web-weaver-llm","llm:deploy.docker":"npm run llm:build && gcloud auth configure-docker us-central1-docker.pkg.dev && docker tag web-weaver-llm us-central1-docker.pkg.dev/ydangle-web-companion/docker-artifacts/web-weaver-llm && docker push us-central1-docker.pkg.dev/ydangle-web-companion/docker-artifacts/web-weaver-llm","llm:deploy":'npm run llm:deploy.docker && gcloud run deploy web-weaver-llm --project=ydangle-web-companion --image=us-central1-docker.pkg.dev/ydangle-web-companion/docker-artifacts/web-weaver-llm --allow-unauthenticated --region=us-central1 --description="Web Weaver LLM" --concurrency=2 --min-instances=0 --timeout=5m --memory=16Gi --cpu=8',prepack:"npm run build",test:"npm run build && tsx --test"},keywords:["web","weaver","ai","assistant","chat"],author:"jjv360",license:"UNLICENSED",devDependencies:{"@types/audioworklet":"^0.0.64","@types/lodash":"^4.17.13","@types/react":"^18.3.12","@types/uuid":"^10.0.0",bestzip:"^2.2.1","cross-env":"^7.0.3","find-cache-dir":"^5.0.0",lodash:"^4.17.21","onnxruntime-web":"^1.20.0",react:"^18.3.1","replace-in-file":"^8.2.0",tsup:"^8.3.5",tsx:"^4.19.2",typedoc:"^0.27.6"},peerDependencies:{"onnxruntime-web":"^1.20.0",react:"^18 || ^19"},dependencies:{minisearch:"^6.3.0","rehype-document":"^7.0.3","rehype-external-links":"^3.0.0","rehype-format":"^5.0.0","rehype-stringify":"^10.0.0","remark-parse":"^11.0.0","remark-rehype":"^11.1.0",unified:"^11.0.4",uuid:"^10.0.0"}};var nn=class{constructor(n){this.ai=n}async boolean(n,t){let r=this.ai.clone();r.resetConversation(),r.getContextPrefix=async()=>'You will receive a question and some data. Answer the question by replying only with the word "true" or "false".';let i=await r.sendMessage(n+`
|
|
9
|
+
`,yield*t()}function Yi(){if(Q().userID)return Q().userID;if(typeof localStorage<"u"){let e=localStorage.getItem("intelliweave.uid")||"";return e||(e=Ue(),localStorage.setItem("intelliweave.uid",e),e)}else return Ue()}var Qt=class Qt{constructor(n){this.module="IntelliWeave";this.module=n}get debugEnabled(){return Qt.debug?!0:typeof window<"u"&&Q().debug}log(...n){this.debugEnabled&&console.log(`[IntelliWeave > ${this.module}]`,...n)}debug(...n){this.debugEnabled&&console.debug(`[IntelliWeave > ${this.module}]`,...n)}info(...n){this.debugEnabled&&console.info(`[IntelliWeave > ${this.module}]`,...n)}warn(...n){console.warn(`[IntelliWeave > ${this.module}]`,...n)}error(...n){console.error(`[IntelliWeave > ${this.module}]`,...n)}timer(n,...t){let r=Date.now();return this.debug(`[${n} 0ms] Started`,...t),(...i)=>this.debug(`[${n} ${Math.floor(Date.now()-r)}ms]`,...i)}};Qt.debug=!1;var U=Qt;var Ze=new U("ChatGPT"),qt=class{constructor(n){this.id="";this.metadata={};this.config={apiKey:"",endpoint:"",model:"gpt-4-turbo",systemMessage:"",userID:"",stream:!0,maxTokens:4096};this.messages=[];this.tools=[];this.maxToolCallsPerMessage=10;this._hasRemovedToolCallHistorySinceLastMessage=0;this.stats={tokensUsed:0};this.config={...this.config,...n}}async sendMessage(n){this.messages.push({role:"user",content:n}),await this.processMessages(),this._hasRemovedToolCallHistorySinceLastMessage=0;let t=this.messages[this.messages.length-1];return t?.role=="assistant"&&t.content||""}async processMessages(){await this.config.onBeforeMessageProcessing?.(),Ze.debug("Process message state:",{context:this.config.systemMessage,tools:this.tools.slice(),messages:this.messages.slice(),removedToolCallHistory:this._hasRemovedToolCallHistorySinceLastMessage});let n=this.messages[this.messages.length-1];if(n?.role=="user"||n?.role=="tool")await this.trimMessages(),await this.sendToAPI(),await this.processMessages();else if(n?.role=="assistant"&&n?.tool_calls?.length){for(let t of n.tool_calls)await this.processToolCall(t);await this.processMessages()}}async trimMessages(){for(;;){let n=await this.sendToAPI(!0);if(JSON.stringify(n).length/3.8<this.config.maxTokens)break;if(this.messages.length<2){Ze.warn("[ChatGPT] Unable to trim messages, no messages left! Please check the size of the system message and the LLM's context window size.");break}for(this.messages=this.messages.slice(Math.floor(this.messages.length/2));this.messages.length&&this.messages[0].role=="tool";)this.messages.shift()}}async sendToAPI(n){let t=0;for(let l=this.messages.length-1;l>=0;l--)if(this.messages[l].role=="assistant"&&this.messages[l].tool_calls){if(t+=1,t>=this.maxToolCallsPerMessage)throw new Error(`Exceeded the maximum tool calls per message limit of ${this.maxToolCallsPerMessage}.`)}else if(this.messages[l].role=="user")break;Ze.debug("Before LLM state:",{context:this.config.systemMessage,tools:this.tools.slice(),messages:this.messages.slice(),removedToolCallHistory:this._hasRemovedToolCallHistorySinceLastMessage});let r={model:this.config.model,temperature:.2,user:this.config.userID,tools:[],stream:!!this.config.stream,max_tokens:1024,messages:[{role:"system",content:this.config.systemMessage},...this.messages]};for(let l of this.tools){l.description&&l.description.length>1024&&Ze.warn(`Tool description for "${l.name}" is too long, it will be truncated.`);let u={type:"function",function:{name:l.name,description:(l.description||"").substring(0,1024),parameters:{type:"object",properties:{}}}};if(Array.isArray(l.params))for(let c of l.params)u.function.parameters.properties[c.name]={type:c.type,description:c.description};else if(l.params){let c=l.params;for(let h in c)u.function.parameters.properties[h]={type:"string",description:c[h]}}r.tools.push(u)}r.user||delete r.user,r.tools.length||delete r.tools;let i={};if(i["Content-Type"]="application/json",this.config.apiKey&&(i.Authorization=`Bearer ${this.config.apiKey}`),n)return r;let o=await fetch(this.config.endpoint||"https://api.openai.com/v1/chat/completions",{method:"POST",headers:i,body:JSON.stringify(r)});if(!o.ok){let l=`${o.status} ${o.statusText}`;try{let c=await o.json();l=c.errorText||c.error?.message||c.error||l}catch{}let u=new Error(l);throw u.code=o.status,u}let a=null,s=null;if(this.config.stream)for await(let l of Ki(o.body)){if(l.data=="[DONE]")break;if(!l.data)continue;let u=JSON.parse(l.data);if(s){for(let c in u.choices[0].delta)if(typeof u.choices[0].delta[c]=="string"){if(c=="role"&&s[c]==u.choices[0].delta[c])continue;s[c]=(s[c]||"")+u.choices[0].delta[c]}for(let c of u.choices[0].delta.tool_calls||[]){if(s.tool_calls||(s.tool_calls=[]),!s.tool_calls[c.index]){s.tool_calls[c.index]=c;continue}let h=s.tool_calls[c.index];h.function=h.function||{},h.function.name=(h.function.name||"")+(c.function?.name||""),h.function.arguments=(h.function.arguments||"")+(c.function?.arguments||"")}}else s={chunkID:u.id,...u.choices[0].delta};s?.content&&!s.content.startsWith("{")&&this.config.onAIMessage?.(s.content,!0)}else a=await o.json(),this.stats.tokensUsed+=a.usage?.total_tokens||0,Ze.debug(`Used ${a.usage?.total_tokens||0} tokens, total used: ${this.stats.tokensUsed}`),s=a.choices?.[0]?.message;if(s||(Ze.warn("No response block in API response."),s={role:"assistant",content:""}),s.role=="user")throw new Error("API returned a user message, which is not allowed.");this.processIncomingMessage(s),this.messages.push(s),s.content&&this.config.onAIMessage?.(s.content,!1)}processIncomingMessage(n){}registerTool(n){this.tools.push(n)}async processToolCall(n){try{let t=this.tools.find(o=>o.name==n.function.name);if(!t)throw new Error(`Tool "${n.function.name}" not found.`);let r=JSON.parse(n.function.arguments);this.config.onAIToolStart?.(n.function.name,r);let i=await t.callback(r);if(typeof i!="string"&&(i=JSON.stringify(i)||""),(i===""||i==="undefined")&&(i="success"),this._hasRemovedToolCallHistorySinceLastMessage<3&&t.removeFromMessageHistory){Ze.debug(`Removing tool call history for "${t.name}"`),this._hasRemovedToolCallHistorySinceLastMessage++,this.messages=this.messages.filter(o=>o.role!="assistant"||!o.tool_calls?.find(a=>a.id==n.id));return}else t.removeFromMessageHistory&&Ze.info(`The AI attempted to reuse a tool call that we removed from history. Skipping... "${t.name}"`);this.messages.push({role:"tool",content:i,tool_call_id:n.id})}catch(t){Ze.warn(`Unable to process tool call for "${n?.function?.name}"`,t),this.messages.push({role:"tool",content:`Error: ${t.message}`,tool_call_id:n.id})}}resetConversation(){this.messages=[]}};var J=function(){return J=Object.assign||function(n){for(var t,r=1,i=arguments.length;r<i;r++){t=arguments[r];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(n[o]=t[o])}return n},J.apply(this,arguments)};function qs(e,n,t,r){function i(o){return o instanceof t?o:new t(function(a){a(o)})}return new(t||(t=Promise))(function(o,a){function s(c){try{u(r.next(c))}catch(h){a(h)}}function l(c){try{u(r.throw(c))}catch(h){a(h)}}function u(c){c.done?o(c.value):i(c.value).then(s,l)}u((r=r.apply(e,n||[])).next())})}function $s(e,n){var t={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,a;return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(u){return function(c){return l([u,c])}}function l(u){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(t=0)),t;)try{if(r=1,i&&(o=u[0]&2?i.return:u[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,u[1])).done)return o;switch(i=0,o&&(u=[u[0]&2,o.value]),u[0]){case 0:case 1:o=u;break;case 4:return t.label++,{value:u[1],done:!1};case 5:t.label++,i=u[1],u=[0];continue;case 7:u=t.ops.pop(),t.trys.pop();continue;default:if(o=t.trys,!(o=o.length>0&&o[o.length-1])&&(u[0]===6||u[0]===2)){t=0;continue}if(u[0]===3&&(!o||u[1]>o[0]&&u[1]<o[3])){t.label=u[1];break}if(u[0]===6&&t.label<o[1]){t.label=o[1],o=u;break}if(o&&t.label<o[2]){t.label=o[2],t.ops.push(u);break}o[2]&&t.ops.pop(),t.trys.pop();continue}u=n.call(e,t)}catch(c){u=[6,c],i=0}finally{r=o=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}function X(e){var n=typeof Symbol=="function"&&Symbol.iterator,t=n&&e[n],r=0;if(t)return t.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")}function $(e,n){var t=typeof Symbol=="function"&&e[Symbol.iterator];if(!t)return e;var r=t.call(e),i,o=[],a;try{for(;(n===void 0||n-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(s){a={error:s}}finally{try{i&&!i.done&&(t=r.return)&&t.call(r)}finally{if(a)throw a.error}}return o}var el="ENTRIES",$i="KEYS",eo="VALUES",le="",fr=function(){function e(n,t){var r=n._tree,i=Array.from(r.keys());this.set=n,this._type=t,this._path=i.length>0?[{node:r,keys:i}]:[]}return e.prototype.next=function(){var n=this.dive();return this.backtrack(),n},e.prototype.dive=function(){if(this._path.length===0)return{done:!0,value:void 0};var n=ot(this._path),t=n.node,r=n.keys;if(ot(r)===le)return{done:!1,value:this.result()};var i=t.get(ot(r));return this._path.push({node:i,keys:Array.from(i.keys())}),this.dive()},e.prototype.backtrack=function(){if(this._path.length!==0){var n=ot(this._path).keys;n.pop(),!(n.length>0)&&(this._path.pop(),this.backtrack())}},e.prototype.key=function(){return this.set._prefix+this._path.map(function(n){var t=n.keys;return ot(t)}).filter(function(n){return n!==le}).join("")},e.prototype.value=function(){return ot(this._path).node.get(le)},e.prototype.result=function(){switch(this._type){case eo:return this.value();case $i:return this.key();default:return[this.key(),this.value()]}},e.prototype[Symbol.iterator]=function(){return this},e}(),ot=function(e){return e[e.length-1]},tl=function(e,n,t){var r=new Map;if(n===void 0)return r;for(var i=n.length+1,o=i+t,a=new Uint8Array(o*i).fill(t+1),s=0;s<i;++s)a[s]=s;for(var l=1;l<o;++l)a[l*i]=l;return to(e,n,t,r,a,1,i,""),r},to=function(e,n,t,r,i,o,a,s){var l,u,c=o*a;try{e:for(var h=X(e.keys()),d=h.next();!d.done;d=h.next()){var p=d.value;if(p===le){var g=i[c-1];g<=t&&r.set(s,[e.get(p),g])}else{for(var w=o,k=0;k<p.length;++k,++w){for(var y=p[k],I=a*w,v=I-a,z=i[I],Z=Math.max(0,w-t-1),x=Math.min(a-1,w+t),L=Z;L<x;++L){var R=y!==n[L],F=i[v+L]+ +R,P=i[v+L+1]+1,D=i[I+L]+1,M=i[I+L+1]=Math.min(F,P,D);M<z&&(z=M)}if(z>t)continue e}to(e.get(p),n,t,r,i,w,a,s+p)}}}catch(E){l={error:E}}finally{try{d&&!d.done&&(u=h.return)&&u.call(h)}finally{if(l)throw l.error}}},mr=function(){function e(n,t){n===void 0&&(n=new Map),t===void 0&&(t=""),this._size=void 0,this._tree=n,this._prefix=t}return e.prototype.atPrefix=function(n){var t,r;if(!n.startsWith(this._prefix))throw new Error("Mismatched prefix");var i=$(en(this._tree,n.slice(this._prefix.length)),2),o=i[0],a=i[1];if(o===void 0){var s=$(Sr(a),2),l=s[0],u=s[1];try{for(var c=X(l.keys()),h=c.next();!h.done;h=c.next()){var d=h.value;if(d!==le&&d.startsWith(u)){var p=new Map;return p.set(d.slice(u.length),l.get(d)),new e(p,n)}}}catch(g){t={error:g}}finally{try{h&&!h.done&&(r=c.return)&&r.call(c)}finally{if(t)throw t.error}}}return new e(o,n)},e.prototype.clear=function(){this._size=void 0,this._tree.clear()},e.prototype.delete=function(n){return this._size=void 0,nl(this._tree,n)},e.prototype.entries=function(){return new fr(this,el)},e.prototype.forEach=function(n){var t,r;try{for(var i=X(this),o=i.next();!o.done;o=i.next()){var a=$(o.value,2),s=a[0],l=a[1];n(s,l,this)}}catch(u){t={error:u}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}},e.prototype.fuzzyGet=function(n,t){return tl(this._tree,n,t)},e.prototype.get=function(n){var t=wr(this._tree,n);return t!==void 0?t.get(le):void 0},e.prototype.has=function(n){var t=wr(this._tree,n);return t!==void 0&&t.has(le)},e.prototype.keys=function(){return new fr(this,$i)},e.prototype.set=function(n,t){if(typeof n!="string")throw new Error("key must be a string");this._size=void 0;var r=gr(this._tree,n);return r.set(le,t),this},Object.defineProperty(e.prototype,"size",{get:function(){if(this._size)return this._size;this._size=0;for(var n=this.entries();!n.next().done;)this._size+=1;return this._size},enumerable:!1,configurable:!0}),e.prototype.update=function(n,t){if(typeof n!="string")throw new Error("key must be a string");this._size=void 0;var r=gr(this._tree,n);return r.set(le,t(r.get(le))),this},e.prototype.fetch=function(n,t){if(typeof n!="string")throw new Error("key must be a string");this._size=void 0;var r=gr(this._tree,n),i=r.get(le);return i===void 0&&r.set(le,i=t()),i},e.prototype.values=function(){return new fr(this,eo)},e.prototype[Symbol.iterator]=function(){return this.entries()},e.from=function(n){var t,r,i=new e;try{for(var o=X(n),a=o.next();!a.done;a=o.next()){var s=$(a.value,2),l=s[0],u=s[1];i.set(l,u)}}catch(c){t={error:c}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(t)throw t.error}}return i},e.fromObject=function(n){return e.from(Object.entries(n))},e}(),en=function(e,n,t){var r,i;if(t===void 0&&(t=[]),n.length===0||e==null)return[e,t];try{for(var o=X(e.keys()),a=o.next();!a.done;a=o.next()){var s=a.value;if(s!==le&&n.startsWith(s))return t.push([e,s]),en(e.get(s),n.slice(s.length),t)}}catch(l){r={error:l}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(r)throw r.error}}return t.push([e,n]),en(void 0,"",t)},wr=function(e,n){var t,r;if(n.length===0||e==null)return e;try{for(var i=X(e.keys()),o=i.next();!o.done;o=i.next()){var a=o.value;if(a!==le&&n.startsWith(a))return wr(e.get(a),n.slice(a.length))}}catch(s){t={error:s}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}},gr=function(e,n){var t,r,i=n.length;e:for(var o=0;e&&o<i;){try{for(var a=(t=void 0,X(e.keys())),s=a.next();!s.done;s=a.next()){var l=s.value;if(l!==le&&n[o]===l[0]){for(var u=Math.min(i-o,l.length),c=1;c<u&&n[o+c]===l[c];)++c;var h=e.get(l);if(c===l.length)e=h;else{var d=new Map;d.set(l.slice(c),h),e.set(n.slice(o,o+c),d),e.delete(l),e=d}o+=c;continue e}}}catch(g){t={error:g}}finally{try{s&&!s.done&&(r=a.return)&&r.call(a)}finally{if(t)throw t.error}}var p=new Map;return e.set(n.slice(o),p),p}return e},nl=function(e,n){var t=$(en(e,n),2),r=t[0],i=t[1];if(r!==void 0){if(r.delete(le),r.size===0)no(i);else if(r.size===1){var o=$(r.entries().next().value,2),a=o[0],s=o[1];ro(i,a,s)}}},no=function(e){if(e.length!==0){var n=$(Sr(e),2),t=n[0],r=n[1];if(t.delete(r),t.size===0)no(e.slice(0,-1));else if(t.size===1){var i=$(t.entries().next().value,2),o=i[0],a=i[1];o!==le&&ro(e.slice(0,-1),o,a)}}},ro=function(e,n,t){if(e.length!==0){var r=$(Sr(e),2),i=r[0],o=r[1];i.set(o+n,t),i.delete(o)}},Sr=function(e){return e[e.length-1]},kt,Cr="or",io="and",rl="and_not",oo=function(){function e(n){if(n?.fields==null)throw new Error('MiniSearch: option "fields" must be provided');var t=n.autoVacuum==null||n.autoVacuum===!0?br:n.autoVacuum;this._options=J(J(J({},xr),n),{autoVacuum:t,searchOptions:J(J({},ji),n.searchOptions||{}),autoSuggestOptions:J(J({},ll),n.autoSuggestOptions||{})}),this._index=new mr,this._documentCount=0,this._documentIds=new Map,this._idToShortId=new Map,this._fieldIds={},this._fieldLength=new Map,this._avgFieldLength=[],this._nextId=0,this._storedFields=new Map,this._dirtCount=0,this._currentVacuum=null,this._enqueuedVacuum=null,this._enqueuedVacuumConditions=kr,this.addFields(this._options.fields)}return e.prototype.add=function(n){var t,r,i,o,a,s,l=this._options,u=l.extractField,c=l.tokenize,h=l.processTerm,d=l.fields,p=l.idField,g=u(n,p);if(g==null)throw new Error('MiniSearch: document does not have ID field "'.concat(p,'"'));if(this._idToShortId.has(g))throw new Error("MiniSearch: duplicate ID ".concat(g));var w=this.addDocumentId(g);this.saveStoredFields(w,n);try{for(var k=X(d),y=k.next();!y.done;y=k.next()){var I=y.value,v=u(n,I);if(v!=null){var z=c(v.toString(),I),Z=this._fieldIds[I],x=new Set(z).size;this.addFieldLength(w,Z,this._documentCount-1,x);try{for(var L=(i=void 0,X(z)),R=L.next();!R.done;R=L.next()){var F=R.value,P=h(F,I);if(Array.isArray(P))try{for(var D=(a=void 0,X(P)),M=D.next();!M.done;M=D.next()){var E=M.value;this.addTerm(Z,w,E)}}catch(A){a={error:A}}finally{try{M&&!M.done&&(s=D.return)&&s.call(D)}finally{if(a)throw a.error}}else P&&this.addTerm(Z,w,P)}}catch(A){i={error:A}}finally{try{R&&!R.done&&(o=L.return)&&o.call(L)}finally{if(i)throw i.error}}}}}catch(A){t={error:A}}finally{try{y&&!y.done&&(r=k.return)&&r.call(k)}finally{if(t)throw t.error}}},e.prototype.addAll=function(n){var t,r;try{for(var i=X(n),o=i.next();!o.done;o=i.next()){var a=o.value;this.add(a)}}catch(s){t={error:s}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}},e.prototype.addAllAsync=function(n,t){var r=this;t===void 0&&(t={});var i=t.chunkSize,o=i===void 0?10:i,a={chunk:[],promise:Promise.resolve()},s=n.reduce(function(c,h,d){var p=c.chunk,g=c.promise;return p.push(h),(d+1)%o===0?{chunk:[],promise:g.then(function(){return new Promise(function(w){return setTimeout(w,0)})}).then(function(){return r.addAll(p)})}:{chunk:p,promise:g}},a),l=s.chunk,u=s.promise;return u.then(function(){return r.addAll(l)})},e.prototype.remove=function(n){var t,r,i,o,a,s,l=this._options,u=l.tokenize,c=l.processTerm,h=l.extractField,d=l.fields,p=l.idField,g=h(n,p);if(g==null)throw new Error('MiniSearch: document does not have ID field "'.concat(p,'"'));var w=this._idToShortId.get(g);if(w==null)throw new Error("MiniSearch: cannot remove document with ID ".concat(g,": it is not in the index"));try{for(var k=X(d),y=k.next();!y.done;y=k.next()){var I=y.value,v=h(n,I);if(v!=null){var z=u(v.toString(),I),Z=this._fieldIds[I],x=new Set(z).size;this.removeFieldLength(w,Z,this._documentCount,x);try{for(var L=(i=void 0,X(z)),R=L.next();!R.done;R=L.next()){var F=R.value,P=c(F,I);if(Array.isArray(P))try{for(var D=(a=void 0,X(P)),M=D.next();!M.done;M=D.next()){var E=M.value;this.removeTerm(Z,w,E)}}catch(A){a={error:A}}finally{try{M&&!M.done&&(s=D.return)&&s.call(D)}finally{if(a)throw a.error}}else P&&this.removeTerm(Z,w,P)}}catch(A){i={error:A}}finally{try{R&&!R.done&&(o=L.return)&&o.call(L)}finally{if(i)throw i.error}}}}}catch(A){t={error:A}}finally{try{y&&!y.done&&(r=k.return)&&r.call(k)}finally{if(t)throw t.error}}this._storedFields.delete(w),this._documentIds.delete(w),this._idToShortId.delete(g),this._fieldLength.delete(w),this._documentCount-=1},e.prototype.removeAll=function(n){var t,r;if(n)try{for(var i=X(n),o=i.next();!o.done;o=i.next()){var a=o.value;this.remove(a)}}catch(s){t={error:s}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}else{if(arguments.length>0)throw new Error("Expected documents to be present. Omit the argument to remove all documents.");this._index=new mr,this._documentCount=0,this._documentIds=new Map,this._idToShortId=new Map,this._fieldLength=new Map,this._avgFieldLength=[],this._storedFields=new Map,this._nextId=0}},e.prototype.discard=function(n){var t=this,r=this._idToShortId.get(n);if(r==null)throw new Error("MiniSearch: cannot discard document with ID ".concat(n,": it is not in the index"));this._idToShortId.delete(n),this._documentIds.delete(r),this._storedFields.delete(r),(this._fieldLength.get(r)||[]).forEach(function(i,o){t.removeFieldLength(r,o,t._documentCount,i)}),this._fieldLength.delete(r),this._documentCount-=1,this._dirtCount+=1,this.maybeAutoVacuum()},e.prototype.maybeAutoVacuum=function(){if(this._options.autoVacuum!==!1){var n=this._options.autoVacuum,t=n.minDirtFactor,r=n.minDirtCount,i=n.batchSize,o=n.batchWait;this.conditionalVacuum({batchSize:i,batchWait:o},{minDirtCount:r,minDirtFactor:t})}},e.prototype.discardAll=function(n){var t,r,i=this._options.autoVacuum;try{this._options.autoVacuum=!1;try{for(var o=X(n),a=o.next();!a.done;a=o.next()){var s=a.value;this.discard(s)}}catch(l){t={error:l}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(t)throw t.error}}}finally{this._options.autoVacuum=i}this.maybeAutoVacuum()},e.prototype.replace=function(n){var t=this._options,r=t.idField,i=t.extractField,o=i(n,r);this.discard(o),this.add(n)},e.prototype.vacuum=function(n){return n===void 0&&(n={}),this.conditionalVacuum(n)},e.prototype.conditionalVacuum=function(n,t){var r=this;return this._currentVacuum?(this._enqueuedVacuumConditions=this._enqueuedVacuumConditions&&t,this._enqueuedVacuum!=null?this._enqueuedVacuum:(this._enqueuedVacuum=this._currentVacuum.then(function(){var i=r._enqueuedVacuumConditions;return r._enqueuedVacuumConditions=kr,r.performVacuuming(n,i)}),this._enqueuedVacuum)):this.vacuumConditionsMet(t)===!1?Promise.resolve():(this._currentVacuum=this.performVacuuming(n),this._currentVacuum)},e.prototype.performVacuuming=function(n,t){return qs(this,void 0,void 0,function(){var r,i,o,a,s,l,u,c,h,d,p,g,w,k,y,I,v,z,Z,x,L,R,F,P,D;return $s(this,function(M){switch(M.label){case 0:if(r=this._dirtCount,!this.vacuumConditionsMet(t))return[3,10];i=n.batchSize||vr.batchSize,o=n.batchWait||vr.batchWait,a=1,M.label=1;case 1:M.trys.push([1,7,8,9]),s=X(this._index),l=s.next(),M.label=2;case 2:if(l.done)return[3,6];u=$(l.value,2),c=u[0],h=u[1];try{for(d=(R=void 0,X(h)),p=d.next();!p.done;p=d.next()){g=$(p.value,2),w=g[0],k=g[1];try{for(y=(P=void 0,X(k)),I=y.next();!I.done;I=y.next())v=$(I.value,1),z=v[0],!this._documentIds.has(z)&&(k.size<=1?h.delete(w):k.delete(z))}catch(E){P={error:E}}finally{try{I&&!I.done&&(D=y.return)&&D.call(y)}finally{if(P)throw P.error}}}}catch(E){R={error:E}}finally{try{p&&!p.done&&(F=d.return)&&F.call(d)}finally{if(R)throw R.error}}return this._index.get(c).size===0&&this._index.delete(c),a%i!==0?[3,4]:[4,new Promise(function(E){return setTimeout(E,o)})];case 3:M.sent(),M.label=4;case 4:a+=1,M.label=5;case 5:return l=s.next(),[3,2];case 6:return[3,9];case 7:return Z=M.sent(),x={error:Z},[3,9];case 8:try{l&&!l.done&&(L=s.return)&&L.call(s)}finally{if(x)throw x.error}return[7];case 9:this._dirtCount-=r,M.label=10;case 10:return[4,null];case 11:return M.sent(),this._currentVacuum=this._enqueuedVacuum,this._enqueuedVacuum=null,[2]}})})},e.prototype.vacuumConditionsMet=function(n){if(n==null)return!0;var t=n.minDirtCount,r=n.minDirtFactor;return t=t||br.minDirtCount,r=r||br.minDirtFactor,this.dirtCount>=t&&this.dirtFactor>=r},Object.defineProperty(e.prototype,"isVacuuming",{get:function(){return this._currentVacuum!=null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dirtCount",{get:function(){return this._dirtCount},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dirtFactor",{get:function(){return this._dirtCount/(1+this._documentCount+this._dirtCount)},enumerable:!1,configurable:!0}),e.prototype.has=function(n){return this._idToShortId.has(n)},e.prototype.getStoredFields=function(n){var t=this._idToShortId.get(n);if(t!=null)return this._storedFields.get(t)},e.prototype.search=function(n,t){var r,i;t===void 0&&(t={});var o=this.executeQuery(n,t),a=[];try{for(var s=X(o),l=s.next();!l.done;l=s.next()){var u=$(l.value,2),c=u[0],h=u[1],d=h.score,p=h.terms,g=h.match,w=p.length||1,k={id:this._documentIds.get(c),score:d*w,terms:Object.keys(g),queryTerms:p,match:g};Object.assign(k,this._storedFields.get(c)),(t.filter==null||t.filter(k))&&a.push(k)}}catch(y){r={error:y}}finally{try{l&&!l.done&&(i=s.return)&&i.call(s)}finally{if(r)throw r.error}}return n===e.wildcard&&t.boostDocument==null&&this._options.searchOptions.boostDocument==null||a.sort(Qi),a},e.prototype.autoSuggest=function(n,t){var r,i,o,a;t===void 0&&(t={}),t=J(J({},this._options.autoSuggestOptions),t);var s=new Map;try{for(var l=X(this.search(n,t)),u=l.next();!u.done;u=l.next()){var c=u.value,h=c.score,d=c.terms,p=d.join(" "),g=s.get(p);g!=null?(g.score+=h,g.count+=1):s.set(p,{score:h,terms:d,count:1})}}catch(Z){r={error:Z}}finally{try{u&&!u.done&&(i=l.return)&&i.call(l)}finally{if(r)throw r.error}}var w=[];try{for(var k=X(s),y=k.next();!y.done;y=k.next()){var I=$(y.value,2),g=I[0],v=I[1],h=v.score,d=v.terms,z=v.count;w.push({suggestion:g,terms:d,score:h/z})}}catch(Z){o={error:Z}}finally{try{y&&!y.done&&(a=k.return)&&a.call(k)}finally{if(o)throw o.error}}return w.sort(Qi),w},Object.defineProperty(e.prototype,"documentCount",{get:function(){return this._documentCount},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"termCount",{get:function(){return this._index.size},enumerable:!1,configurable:!0}),e.loadJSON=function(n,t){if(t==null)throw new Error("MiniSearch: loadJSON should be given the same options used when serializing the index");return this.loadJS(JSON.parse(n),t)},e.getDefault=function(n){if(xr.hasOwnProperty(n))return yr(xr,n);throw new Error('MiniSearch: unknown option "'.concat(n,'"'))},e.loadJS=function(n,t){var r,i,o,a,s,l,u=n.index,c=n.documentCount,h=n.nextId,d=n.documentIds,p=n.fieldIds,g=n.fieldLength,w=n.averageFieldLength,k=n.storedFields,y=n.dirtCount,I=n.serializationVersion;if(I!==1&&I!==2)throw new Error("MiniSearch: cannot deserialize an index created with an incompatible version");var v=new e(t);v._documentCount=c,v._nextId=h,v._documentIds=$t(d),v._idToShortId=new Map,v._fieldIds=p,v._fieldLength=$t(g),v._avgFieldLength=w,v._storedFields=$t(k),v._dirtCount=y||0,v._index=new mr;try{for(var z=X(v._documentIds),Z=z.next();!Z.done;Z=z.next()){var x=$(Z.value,2),L=x[0],R=x[1];v._idToShortId.set(R,L)}}catch(ne){r={error:ne}}finally{try{Z&&!Z.done&&(i=z.return)&&i.call(z)}finally{if(r)throw r.error}}try{for(var F=X(u),P=F.next();!P.done;P=F.next()){var D=$(P.value,2),M=D[0],E=D[1],A=new Map;try{for(var V=(s=void 0,X(Object.keys(E))),H=V.next();!H.done;H=V.next()){var Y=H.value,re=E[Y];I===1&&(re=re.ds),A.set(parseInt(Y,10),$t(re))}}catch(ne){s={error:ne}}finally{try{H&&!H.done&&(l=V.return)&&l.call(V)}finally{if(s)throw s.error}}v._index.set(M,A)}}catch(ne){o={error:ne}}finally{try{P&&!P.done&&(a=F.return)&&a.call(F)}finally{if(o)throw o.error}}return v},e.prototype.executeQuery=function(n,t){var r=this;if(t===void 0&&(t={}),n===e.wildcard)return this.executeWildcardQuery(t);if(typeof n!="string"){var i=J(J(J({},t),n),{queries:void 0}),o=n.queries.map(function(k){return r.executeQuery(k,i)});return this.combineResults(o,i.combineWith)}var a=this._options,s=a.tokenize,l=a.processTerm,u=a.searchOptions,c=J(J({tokenize:s,processTerm:l},u),t),h=c.tokenize,d=c.processTerm,p=h(n).flatMap(function(k){return d(k)}).filter(function(k){return!!k}),g=p.map(sl(c)),w=g.map(function(k){return r.executeQuerySpec(k,c)});return this.combineResults(w,c.combineWith)},e.prototype.executeQuerySpec=function(n,t){var r,i,o,a,s=J(J({},this._options.searchOptions),t),l=(s.fields||this._options.fields).reduce(function(Y,re){var ne;return J(J({},Y),(ne={},ne[re]=yr(s.boost,re)||1,ne))},{}),u=s.boostDocument,c=s.weights,h=s.maxFuzzy,d=s.bm25,p=J(J({},ji.weights),c),g=p.fuzzy,w=p.prefix,k=this._index.get(n.term),y=this.termResults(n.term,n.term,1,k,l,u,d),I,v;if(n.prefix&&(I=this._index.atPrefix(n.term)),n.fuzzy){var z=n.fuzzy===!0?.2:n.fuzzy,Z=z<1?Math.min(h,Math.round(n.term.length*z)):z;Z&&(v=this._index.fuzzyGet(n.term,Z))}if(I)try{for(var x=X(I),L=x.next();!L.done;L=x.next()){var R=$(L.value,2),F=R[0],P=R[1],D=F.length-n.term.length;if(D){v?.delete(F);var M=w*F.length/(F.length+.3*D);this.termResults(n.term,F,M,P,l,u,d,y)}}}catch(Y){r={error:Y}}finally{try{L&&!L.done&&(i=x.return)&&i.call(x)}finally{if(r)throw r.error}}if(v)try{for(var E=X(v.keys()),A=E.next();!A.done;A=E.next()){var F=A.value,V=$(v.get(F),2),H=V[0],D=V[1];if(D){var M=g*F.length/(F.length+D);this.termResults(n.term,F,M,H,l,u,d,y)}}}catch(Y){o={error:Y}}finally{try{A&&!A.done&&(a=E.return)&&a.call(E)}finally{if(o)throw o.error}}return y},e.prototype.executeWildcardQuery=function(n){var t,r,i=new Map,o=J(J({},this._options.searchOptions),n);try{for(var a=X(this._documentIds),s=a.next();!s.done;s=a.next()){var l=$(s.value,2),u=l[0],c=l[1],h=o.boostDocument?o.boostDocument(c,"",this._storedFields.get(u)):1;i.set(u,{score:h,terms:[],match:{}})}}catch(d){t={error:d}}finally{try{s&&!s.done&&(r=a.return)&&r.call(a)}finally{if(t)throw t.error}}return i},e.prototype.combineResults=function(n,t){if(t===void 0&&(t=Cr),n.length===0)return new Map;var r=t.toLowerCase();return n.reduce(il[r])||new Map},e.prototype.toJSON=function(){var n,t,r,i,o=[];try{for(var a=X(this._index),s=a.next();!s.done;s=a.next()){var l=$(s.value,2),u=l[0],c=l[1],h={};try{for(var d=(r=void 0,X(c)),p=d.next();!p.done;p=d.next()){var g=$(p.value,2),w=g[0],k=g[1];h[w]=Object.fromEntries(k)}}catch(y){r={error:y}}finally{try{p&&!p.done&&(i=d.return)&&i.call(d)}finally{if(r)throw r.error}}o.push([u,h])}}catch(y){n={error:y}}finally{try{s&&!s.done&&(t=a.return)&&t.call(a)}finally{if(n)throw n.error}}return{documentCount:this._documentCount,nextId:this._nextId,documentIds:Object.fromEntries(this._documentIds),fieldIds:this._fieldIds,fieldLength:Object.fromEntries(this._fieldLength),averageFieldLength:this._avgFieldLength,storedFields:Object.fromEntries(this._storedFields),dirtCount:this._dirtCount,index:o,serializationVersion:2}},e.prototype.termResults=function(n,t,r,i,o,a,s,l){var u,c,h,d,p;if(l===void 0&&(l=new Map),i==null)return l;try{for(var g=X(Object.keys(o)),w=g.next();!w.done;w=g.next()){var k=w.value,y=o[k],I=this._fieldIds[k],v=i.get(I);if(v!=null){var z=v.size,Z=this._avgFieldLength[I];try{for(var x=(h=void 0,X(v.keys())),L=x.next();!L.done;L=x.next()){var R=L.value;if(!this._documentIds.has(R)){this.removeTerm(I,R,t),z-=1;continue}var F=a?a(this._documentIds.get(R),t,this._storedFields.get(R)):1;if(F){var P=v.get(R),D=this._fieldLength.get(R)[I],M=al(P,z,this._documentCount,D,Z,s),E=r*y*F*M,A=l.get(R);if(A){A.score+=E,ul(A.terms,n);var V=yr(A.match,t);V?V.push(k):A.match[t]=[k]}else l.set(R,{score:E,terms:[n],match:(p={},p[t]=[k],p)})}}}catch(H){h={error:H}}finally{try{L&&!L.done&&(d=x.return)&&d.call(x)}finally{if(h)throw h.error}}}}}catch(H){u={error:H}}finally{try{w&&!w.done&&(c=g.return)&&c.call(g)}finally{if(u)throw u.error}}return l},e.prototype.addTerm=function(n,t,r){var i=this._index.fetch(r,qi),o=i.get(n);if(o==null)o=new Map,o.set(t,1),i.set(n,o);else{var a=o.get(t);o.set(t,(a||0)+1)}},e.prototype.removeTerm=function(n,t,r){if(!this._index.has(r)){this.warnDocumentChanged(t,n,r);return}var i=this._index.fetch(r,qi),o=i.get(n);o==null||o.get(t)==null?this.warnDocumentChanged(t,n,r):o.get(t)<=1?o.size<=1?i.delete(n):o.delete(t):o.set(t,o.get(t)-1),this._index.get(r).size===0&&this._index.delete(r)},e.prototype.warnDocumentChanged=function(n,t,r){var i,o;try{for(var a=X(Object.keys(this._fieldIds)),s=a.next();!s.done;s=a.next()){var l=s.value;if(this._fieldIds[l]===t){this._options.logger("warn","MiniSearch: document with ID ".concat(this._documentIds.get(n),' has changed before removal: term "').concat(r,'" was not present in field "').concat(l,'". Removing a document after it has changed can corrupt the index!'),"version_conflict");return}}}catch(u){i={error:u}}finally{try{s&&!s.done&&(o=a.return)&&o.call(a)}finally{if(i)throw i.error}}},e.prototype.addDocumentId=function(n){var t=this._nextId;return this._idToShortId.set(n,t),this._documentIds.set(t,n),this._documentCount+=1,this._nextId+=1,t},e.prototype.addFields=function(n){for(var t=0;t<n.length;t++)this._fieldIds[n[t]]=t},e.prototype.addFieldLength=function(n,t,r,i){var o=this._fieldLength.get(n);o==null&&this._fieldLength.set(n,o=[]),o[t]=i;var a=this._avgFieldLength[t]||0,s=a*r+i;this._avgFieldLength[t]=s/(r+1)},e.prototype.removeFieldLength=function(n,t,r,i){if(r===1){this._avgFieldLength[t]=0;return}var o=this._avgFieldLength[t]*r-i;this._avgFieldLength[t]=o/(r-1)},e.prototype.saveStoredFields=function(n,t){var r,i,o=this._options,a=o.storeFields,s=o.extractField;if(!(a==null||a.length===0)){var l=this._storedFields.get(n);l==null&&this._storedFields.set(n,l={});try{for(var u=X(a),c=u.next();!c.done;c=u.next()){var h=c.value,d=s(t,h);d!==void 0&&(l[h]=d)}}catch(p){r={error:p}}finally{try{c&&!c.done&&(i=u.return)&&i.call(u)}finally{if(r)throw r.error}}}},e.wildcard=Symbol("*"),e}(),yr=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)?e[n]:void 0},il=(kt={},kt[Cr]=function(e,n){var t,r;try{for(var i=X(n.keys()),o=i.next();!o.done;o=i.next()){var a=o.value,s=e.get(a);if(s==null)e.set(a,n.get(a));else{var l=n.get(a),u=l.score,c=l.terms,h=l.match;s.score=s.score+u,s.match=Object.assign(s.match,h),Ji(s.terms,c)}}}catch(d){t={error:d}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}return e},kt[io]=function(e,n){var t,r,i=new Map;try{for(var o=X(n.keys()),a=o.next();!a.done;a=o.next()){var s=a.value,l=e.get(s);if(l!=null){var u=n.get(s),c=u.score,h=u.terms,d=u.match;Ji(l.terms,h),i.set(s,{score:l.score+c,terms:l.terms,match:Object.assign(l.match,d)})}}}catch(p){t={error:p}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(t)throw t.error}}return i},kt[rl]=function(e,n){var t,r;try{for(var i=X(n.keys()),o=i.next();!o.done;o=i.next()){var a=o.value;e.delete(a)}}catch(s){t={error:s}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}return e},kt),ol={k:1.2,b:.7,d:.5},al=function(e,n,t,r,i,o){var a=o.k,s=o.b,l=o.d,u=Math.log(1+(t-n+.5)/(n+.5));return u*(l+e*(a+1)/(e+a*(1-s+s*r/i)))},sl=function(e){return function(n,t,r){var i=typeof e.fuzzy=="function"?e.fuzzy(n,t,r):e.fuzzy||!1,o=typeof e.prefix=="function"?e.prefix(n,t,r):e.prefix===!0;return{term:n,fuzzy:i,prefix:o}}},xr={idField:"id",extractField:function(e,n){return e[n]},tokenize:function(e){return e.split(cl)},processTerm:function(e){return e.toLowerCase()},fields:void 0,searchOptions:void 0,storeFields:[],logger:function(e,n){typeof console?.[e]=="function"&&console[e](n)},autoVacuum:!0},ji={combineWith:Cr,prefix:!1,fuzzy:!1,maxFuzzy:6,boost:{},weights:{fuzzy:.45,prefix:.375},bm25:ol},ll={combineWith:io,prefix:function(e,n,t){return n===t.length-1}},vr={batchSize:1e3,batchWait:10},kr={minDirtFactor:.1,minDirtCount:20},br=J(J({},vr),kr),ul=function(e,n){e.includes(n)||e.push(n)},Ji=function(e,n){var t,r;try{for(var i=X(n),o=i.next();!o.done;o=i.next()){var a=o.value;e.includes(a)||e.push(a)}}catch(s){t={error:s}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}},Qi=function(e,n){var t=e.score,r=n.score;return r-t},qi=function(){return new Map},$t=function(e){var n,t,r=new Map;try{for(var i=X(Object.keys(e)),o=i.next();!o.done;o=i.next()){var a=o.value;r.set(parseInt(a,10),e[a])}}catch(s){n={error:s}}finally{try{o&&!o.done&&(t=i.return)&&t.call(i)}finally{if(n)throw n.error}}return r},cl=/[\n\r -#%-*,-/:;?@[-\]_{}\u00A0\u00A1\u00A7\u00AB\u00B6\u00B7\u00BB\u00BF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u1680\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2000-\u200A\u2010-\u2029\u202F-\u2043\u2045-\u2051\u2053-\u205F\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u3000-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]+/u;var ao=[{id:"search",type:"action",name:"Search the knowledge base.",content:"Search the knowledge base for information, actions, tools, tours, UI elements, etc. Use this on EVERY request if you don't have information. If the user asks for personal information, use this. If the user asks you to do something, use this to find the tool you need.",isContext:!0,removeFromMessageHistory:!0,parameters:[{name:"query",type:"string",description:"The search query"}],action:async(e,n)=>{let t=await n.knowledgeBase.search(e.query);n.updateKnowledgeBase(t),n.submitAnalyticsEvent({type:"kb-search",query:e.query,results:t});let r=t.filter(o=>o.type!="action").map(o=>"id="+o.id).join(", ")||"(none)",i=t.filter(o=>o.type=="action").map(o=>"name="+o.id.replaceAll(/[^a-zA-Z0-9_]/g,"_")).join(", ")||"(none)";return`Search complete, context has been updated. New info entries found: ${r}. New tools available: ${i}.`}},{id:"ui.openURL",type:"action",name:"Open a URL in a new tab.",isContext:!0,get disabled(){return typeof window>"u"},content:"Opens the specified URL in a new tab.",parameters:[{name:"url",type:"string",description:"The URL to open"}],action:(e,n)=>{if(!window.open(e.url,"_blank"))throw new Error("Window blocked by popup blocker.");return n.submitAnalyticsEvent({type:"open-url",url:e.url}),"URL opened"}}];var at=new U("KnowledgeBase"),so=1,tn=class e{constructor(n){this._sources=[{id:"core.internal",query:async()=>ao}];this._windowSources=[];this.lastResults=[];this.manualEntries=[];this.ai=n}registerSource(n,t){let r=n;return typeof n=="function"&&(t=n,r=`source.${so++}`),this._sources.push({id:r,query:t}),r}removeSource(n){this._sources=this.sources.filter(t=>t.id!==n&&t.query!==n)}addEntry(n){this.manualEntries.push(n)}removeEntry(n){this.manualEntries=this.manualEntries.filter(t=>t.id!==n)}get sources(){let n=this._sources;return typeof window<"u"&&Q().knowledgeBaseSources&&(n=n.concat(Q().knowledgeBaseSources.map(t=>({id:t.name,query:t})))),n=n.concat(this._windowSources),n=n.filter(t=>!t.disabled),n}async search(n){at.debug(`Searching knowledge base for: ${n}`);let t=new Event("webweaver_kb_search",{bubbles:!0,cancelable:!0});t.query=n,t.entries=[],t.sources=[],typeof document<"u"&&document.dispatchEvent(t),this._windowSources=t.sources;let i=(await Promise.all(this.sources.map(async l=>{try{return await l.query(n)}catch(u){return at.warn(`Knowledge source '${l.id}' failed:`,u),[]}}))).flat();i=i.concat(t.entries),i=i.concat(this.manualEntries),Q().knowledgeBase&&(i=i.concat(Q().knowledgeBase)),i=i.filter(l=>l&&!l.disabled);for(let l=0;l<i.length;l++){let u=i[l];if(u.id=u.id||`temp.${l}`,!u.action&&u.type=="tour"&&(u.action=c=>{throw new Error("This tour does not have an action. You must perform the tour content manually.")}),!u.action&&u.type=="info"&&(u.action=c=>{throw new Error("This item does not have an action. Use the content to provide information to the user instead.")}),u.parameters&&!Array.isArray(u.parameters)){let c=u.parameters,h=[];for(let d in c)h.push({name:d,type:"string",description:u.parameters[d]});u.parameters=h}u.content=Ui(typeof u.content=="function"?u.content():u.content)}let o=new oo({fields:["id","type","name","content","tags"],storeFields:[],searchOptions:{boost:{name:3,tags:2},fuzzy:.2}});o.addAll(i);let s=o.search(n).map(l=>i.find(u=>u.id==l.id));for(let l of i)l.isContext&&(s.find(u=>u.id===l.id)||s.push(l));return this.lastResults=s,at.debug("Found results:",s),s}getCachedEntry(n){return this.lastResults.find(t=>t.id==n)}registerSourceFromURL(n,t){t||(t=`external.${so++}`),at.debug(`Registering remote knowledge base source: ${n}`);let r=[],i=async(a,s)=>{at.debug(`Calling remote knowledge base action: ${a.id}`);let l={type:"action",userID:this.ai.userID,extra:this.ai.extra,actionID:a.id,parameters:s},u=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)});if(!u.ok)throw new Error(`HTTP Error ${u.status} ${u.statusText}`);let c=await u.json();return o(c.updateItems||[]),c.response},o=a=>{for(let s of a){if(!s.id){at.warn("KB item skipped since it has no ID.",s);continue}let l=r.find(u=>u.id==s.id);if(l){l.name=s.name||l.name||"",l.content=s.content||l.content||"",l.disabled=s.disabled??l.disabled,l.isContext=s.isContext??l.isContext,l.parameters=s.parameters||l.parameters||[],l.tags=s.tags||l.tags,l.type=s.type||l.type;continue}r.push({...s,action:u=>i(s,u)})}};this.registerSource(t,async a=>{let s={type:"search",userID:this.ai?.userID||"",extra:this.ai?.extra||{},query:a},l=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!l.ok)throw new Error(`HTTP Error ${l.status} ${l.statusText}`);let u=await l.json();return o(u.items),r})}clone(){let n=new e(this.ai);return n._sources=this._sources,n._windowSources=this._windowSources,n.manualEntries=this.manualEntries,n}};var lo={name:"@intelliweave/embedded",version:"1.6.48",description:"Integrate IntelliWeave into your app or website.",main:"./dist/webpack/index.js",types:"./dist/webpack/index.d.ts",type:"module",exports:{".":"./dist/webpack/index.js","./component":"./dist/component/component.js","./node":"./dist/node/node.js","./react":"./dist/react/react.js","./webpack":"./dist/webpack/index.js"},scripts:{build:"npm run build:lib && npm run build:docs","build:lib":"tsx build.ts","build:dev":"cross-env DEVELOPMENT=1 npm run build","build:docs":"typedoc src/index.mts --out dist/docs/",deploy:'npm run build && gsutil cp ./dist/web-weaver.min.js gs://metapress-cdn/web-weaver.min.js && gcloud compute url-maps invalidate-cdn-cache mp-cdn-loadbalancer --project="mp-backend-api" --path "/web-weaver.min.js" --async',"start:server":"cd server && npm run start","deploy:server":"cd server && npm run deploy","llm:build":"cd llm-server && docker build -t web-weaver-llm .","llm:start":"npm run llm:build && docker run -it --rm -p 8000:80 --gpus=all web-weaver-llm","llm:deploy.docker":"npm run llm:build && gcloud auth configure-docker us-central1-docker.pkg.dev && docker tag web-weaver-llm us-central1-docker.pkg.dev/ydangle-web-companion/docker-artifacts/web-weaver-llm && docker push us-central1-docker.pkg.dev/ydangle-web-companion/docker-artifacts/web-weaver-llm","llm:deploy":'npm run llm:deploy.docker && gcloud run deploy web-weaver-llm --project=ydangle-web-companion --image=us-central1-docker.pkg.dev/ydangle-web-companion/docker-artifacts/web-weaver-llm --allow-unauthenticated --region=us-central1 --description="Web Weaver LLM" --concurrency=2 --min-instances=0 --timeout=5m --memory=16Gi --cpu=8',prepack:"npm run build",test:"npm run build && tsx --test"},keywords:["web","weaver","ai","assistant","chat"],author:"jjv360",license:"UNLICENSED",devDependencies:{"@types/audioworklet":"^0.0.64","@types/lodash":"^4.17.13","@types/react":"^18.3.12","@types/uuid":"^10.0.0",bestzip:"^2.2.1","cross-env":"^7.0.3","find-cache-dir":"^5.0.0",lodash:"^4.17.21","onnxruntime-web":"^1.20.0",react:"^18.3.1","replace-in-file":"^8.2.0",tsup:"^8.3.5",tsx:"^4.19.2",typedoc:"^0.27.6"},peerDependencies:{"onnxruntime-web":"^1.20.0",react:"^18 || ^19"},dependencies:{minisearch:"^6.3.0","rehype-document":"^7.0.3","rehype-external-links":"^3.0.0","rehype-format":"^5.0.0","rehype-stringify":"^10.0.0","remark-parse":"^11.0.0","remark-rehype":"^11.1.0",unified:"^11.0.4",uuid:"^10.0.0"}};var nn=class{constructor(n){this.ai=n}async boolean(n,t){let r=this.ai.clone();r.resetConversation(),r.getContextPrefix=async()=>'You will receive a question and some data. Answer the question by replying only with the word "true" or "false".';let i=await r.sendMessage(n+`
|
|
10
10
|
|
|
11
11
|
`+JSON.stringify(t))||"";if(i.toLowerCase().includes("true"))return!0;if(i.toLowerCase().includes("false"))return!1;throw new Error("The AI did not give a boolean answer: "+i)}async choose(n,t,r){r=r.map(a=>a.trim());let i=this.ai.clone();i.resetConversation(),i.getContextPrefix=async()=>"You will receive a question and some data and options. Answer the question by replying with the option you want to choose. Only say the option you want, no additional text.";let o=await i.sendMessage("question:"+n+`
|
|
12
12
|
|
|
@@ -162,12 +162,12 @@ You have access to a database of knowledge base items. These include "info" type
|
|
|
162
162
|
<!-- Logo -->
|
|
163
163
|
<img id='root' src='${this.attr.logo||Er}' />
|
|
164
164
|
|
|
165
|
-
`;this._lastLogoSrc=""}onCreate(){this.layoutUpdateTimer=setInterval(()=>this.onUpdate(),100)}onDestroy(){clearInterval(this.layoutUpdateTimer)}onUpdate(){let t=this.child("root");if(!t)return;let r=this.attr.logo||Er;this._lastLogoSrc!=r&&(this._lastLogoSrc=r,t.src=r);let i=this.attr.focusID?document.getElementById(this.attr.focusID):null;if(i){let o=i.getBoundingClientRect();if(!o)return;t.style.position="fixed",t.style.width="128px",t.style.height="128px",t.style.left=Math.round(o.x+o.width/2-128/2)+"px",t.style.top=Math.round(o.y+o.height/2-128/2)+"px"}else{let o=this.getBoundingClientRect();if(!o)return;t.style.width=o.width+"px",t.style.height=o.height+"px",t.style.left=o.x+"px",t.style.top=o.y+"px"}}refreshLayout(){setTimeout(()=>this.onUpdate(),100)}};St.observedAttributes=["logo","focusID"];var ho=typeof self=="object"?self:globalThis,gl=(e,n)=>{let t=(i,o)=>(e.set(o,i),i),r=i=>{if(e.has(i))return e.get(i);let[o,a]=n[i];switch(o){case 0:case-1:return t(a,i);case 1:{let s=t([],i);for(let l of a)s.push(r(l));return s}case 2:{let s=t({},i);for(let[l,u]of a)s[r(l)]=r(u);return s}case 3:return t(new Date(a),i);case 4:{let{source:s,flags:l}=a;return t(new RegExp(s,l),i)}case 5:{let s=t(new Map,i);for(let[l,u]of a)s.set(r(l),r(u));return s}case 6:{let s=t(new Set,i);for(let l of a)s.add(r(l));return s}case 7:{let{name:s,message:l}=a;return t(new ho[s](l),i)}case 8:return t(BigInt(a),i);case"BigInt":return t(Object(BigInt(a)),i)}return t(new ho[o](a),i)};return r},Lr=e=>gl(new Map,e)(0);var lt="",{toString:yl}={},{keys:xl}=Object,Tt=e=>{let n=typeof e;if(n!=="object"||!e)return[0,n];let t=yl.call(e).slice(8,-1);switch(t){case"Array":return[1,lt];case"Object":return[2,lt];case"Date":return[3,lt];case"RegExp":return[4,lt];case"Map":return[5,lt];case"Set":return[6,lt]}return t.includes("Array")?[1,t]:t.includes("Error")?[7,t]:[2,t]},pn=([e,n])=>e===0&&(n==="function"||n==="symbol"),bl=(e,n,t,r)=>{let i=(a,s)=>{let l=r.push(a)-1;return t.set(s,l),l},o=a=>{if(t.has(a))return t.get(a);let[s,l]=Tt(a);switch(s){case 0:{let c=a;switch(l){case"bigint":s=8,c=a.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+l);c=null;break;case"undefined":return i([-1],a)}return i([s,c],a)}case 1:{if(l)return i([l,[...a]],a);let c=[],h=i([s,c],a);for(let d of a)c.push(o(d));return h}case 2:{if(l)switch(l){case"BigInt":return i([l,a.toString()],a);case"Boolean":case"Number":case"String":return i([l,a.valueOf()],a)}if(n&&"toJSON"in a)return o(a.toJSON());let c=[],h=i([s,c],a);for(let d of xl(a))(e||!pn(Tt(a[d])))&&c.push([o(d),o(a[d])]);return h}case 3:return i([s,a.toISOString()],a);case 4:{let{source:c,flags:h}=a;return i([s,{source:c,flags:h}],a)}case 5:{let c=[],h=i([s,c],a);for(let[d,p]of a)(e||!(pn(Tt(d))||pn(Tt(p))))&&c.push([o(d),o(p)]);return h}case 6:{let c=[],h=i([s,c],a);for(let d of a)(e||!pn(Tt(d)))&&c.push(o(d));return h}}let{message:u}=a;return i([s,{name:l,message:u}],a)};return o},Fr=(e,{json:n,lossy:t}={})=>{let r=[];return bl(!(n||t),!!n,new Map,r)(e),r};var Te=typeof structuredClone=="function"?(e,n)=>n&&("json"in n||"lossy"in n)?Lr(Fr(e,n)):structuredClone(e):(e,n)=>Lr(Fr(e,n));var Ae=function(e,n,t,r,i){let o=Le(n);if(t!=null&&(typeof t!="number"||t<0||t===Number.POSITIVE_INFINITY))throw new Error("Expected positive finite `index`");if(r!=null&&(!r.type||!r.children))throw new Error("Expected valid `parent`");if(t==null!=(r==null))throw new Error("Expected both `index` and `parent`");return fo(e)?o.call(i,e,t,r):!1},Le=function(e){if(e==null)return kl;if(typeof e=="string")return vl(e);if(typeof e=="object")return wl(e);if(typeof e=="function")return Mr(e);throw new Error("Expected function, string, or array as `test`")};function wl(e){let n=[],t=-1;for(;++t<e.length;)n[t]=Le(e[t]);return Mr(r);function r(...i){let o=-1;for(;++o<n.length;)if(n[o].apply(this,i))return!0;return!1}}function vl(e){return Mr(n);function n(t){return t.tagName===e}}function Mr(e){return n;function n(t,r,i){return!!(fo(t)&&e.call(this,t,typeof r=="number"?r:void 0,i||void 0))}}function kl(e){return!!(e&&typeof e=="object"&&"type"in e&&e.type==="element"&&"tagName"in e&&typeof e.tagName=="string")}function fo(e){return e!==null&&typeof e=="object"&&"type"in e&&"tagName"in e}var Sl=/^[a-zA-Z][a-zA-Z\d+\-.]*?:/,Cl=/^[a-zA-Z]:\\/;function Rr(e){if(typeof e!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof e}\``);return Cl.test(e)?!1:Sl.test(e)}function mo(e){let n=String(e||"").trim();return n?n.split(/[ \t\n\r\f]+/g):[]}function go(e){return e.join(" ").trim()}var ut=function(e){if(e==null)return Al;if(typeof e=="function")return hn(e);if(typeof e=="object")return Array.isArray(e)?El(e):Il(e);if(typeof e=="string")return Tl(e);throw new Error("Expected function, string, or object as test")};function El(e){let n=[],t=-1;for(;++t<e.length;)n[t]=ut(e[t]);return hn(r);function r(...i){let o=-1;for(;++o<n.length;)if(n[o].apply(this,i))return!0;return!1}}function Il(e){let n=e;return hn(t);function t(r){let i=r,o;for(o in e)if(i[o]!==n[o])return!1;return!0}}function Tl(e){return hn(n);function n(t){return t&&t.type===e}}function hn(e){return n;function n(t,r,i){return!!(Ll(t)&&e.call(this,t,typeof r=="number"?r:void 0,i||void 0))}}function Al(){return!0}function Ll(e){return e!==null&&typeof e=="object"&&"type"in e}var yo=[],zr=!0,dn=!1,At="skip";function Lt(e,n,t,r){let i;typeof n=="function"&&typeof t!="function"?(r=t,t=n):i=n;let o=ut(i),a=r?-1:1;s(e,void 0,[])();function s(l,u,c){let h=l&&typeof l=="object"?l:{};if(typeof h.type=="string"){let p=typeof h.tagName=="string"?h.tagName:typeof h.name=="string"?h.name:void 0;Object.defineProperty(d,"name",{value:"node ("+(l.type+(p?"<"+p+">":""))+")"})}return d;function d(){let p=yo,g,w,k;if((!n||o(l,u,c[c.length-1]||void 0))&&(p=Fl(t(l,c)),p[0]===dn))return p;if("children"in l&&l.children){let y=l;if(y.children&&p[0]!==At)for(w=(r?y.children.length:-1)+a,k=c.concat(y);w>-1&&w<y.children.length;){let I=y.children[w];if(g=s(I,w,k)(),g[0]===dn)return g;w=typeof g[1]=="number"?g[1]:w+a}}return p}}}function Fl(e){return Array.isArray(e)?e:typeof e=="number"?[zr,e]:e==null?yo:[e]}function Ft(e,n,t,r){let i,o,a;typeof n=="function"&&typeof t!="function"?(o=void 0,a=n,i=t):(o=n,a=t,i=r),Lt(e,o,s,i);function s(l,u){let c=u[u.length-1],h=c?c.children.indexOf(l):void 0;return a(l,h,c)}}var Ml=["http","https"],Rl=["nofollow"],zl={};function fn(e){let n=e||zl,t=n.protocols||Ml,r=Le(n.test);return function(i){Ft(i,"element",function(o,a,s){if(o.tagName==="a"&&typeof o.properties.href=="string"&&r(o,a,s)){let l=o.properties.href;if(Rr(l)?t.includes(l.slice(0,l.indexOf(":"))):l.startsWith("//")){let u=Mt(n.content,o),c=u&&!Array.isArray(u)?[u]:u,h=Mt(n.rel,o)||Rl,d=typeof h=="string"?mo(h):h,p=Mt(n.target,o),g=Mt(n.properties,o);if(g&&Object.assign(o.properties,Te(g)),d.length>0&&(o.properties.rel=[...d]),p&&(o.properties.target=p),c){let w=Mt(n.contentProperties,o)||{};o.children.push({type:"element",tagName:"span",properties:Te(w),children:Te(c)})}}}})}}function Mt(e,n){return typeof e=="function"?e(n):e}var Ye=Le(function(e){return e.tagName==="audio"||e.tagName==="canvas"||e.tagName==="embed"||e.tagName==="iframe"||e.tagName==="img"||e.tagName==="math"||e.tagName==="object"||e.tagName==="picture"||e.tagName==="svg"||e.tagName==="video"});var Zl={}.hasOwnProperty;function Zr(e,n){let t=e.type==="element"&&Zl.call(e.properties,n)&&e.properties[n];return t!=null&&t!==!1}var Pl=new Set(["pingback","prefetch","stylesheet"]);function Pr(e){if(e.type!=="element"||e.tagName!=="link")return!1;if(e.properties.itemProp)return!0;let n=e.properties.rel,t=-1;if(!Array.isArray(n)||n.length===0)return!1;for(;++t<n.length;)if(!Pl.has(String(n[t])))return!1;return!0}var Nl=Le(["a","abbr","area","b","bdi","bdo","br","button","cite","code","data","datalist","del","dfn","em","i","input","ins","kbd","keygen","label","map","mark","meter","noscript","output","progress","q","ruby","s","samp","script","select","small","span","strong","sub","sup","template","textarea","time","u","var","wbr"]),Vl=Le("meta");function Nr(e){return!!(e.type==="text"||Nl(e)||Ye(e)||Pr(e)||Vl(e)&&Zr(e,"itemProp"))}var Bl=/[ \t\n\f\r]/g;function xe(e){return typeof e=="object"?e.type==="text"?xo(e.value):!1:xo(e)}function xo(e){return e.replace(Bl,"")===""}var Vr=["pre","script","style","textarea"];var bo=["address","article","aside","blockquote","body","br","caption","center","col","colgroup","dd","dialog","dir","div","dl","dt","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","legend","li","li","listing","main","menu","nav","ol","optgroup","option","p","plaintext","pre","section","summary","table","tbody","td","td","tfoot","th","th","thead","tr","ul","wbr","xmp"];var wo=["button","input","select","textarea"];var vo=["area","base","basefont","dialog","datalist","head","link","meta","noembed","noframes","param","rp","script","source","style","template","track","title"];var Wl={},Br=ut(["doctype","comment"]);function mn(e){let t=Ul((e||Wl).newlines?_l:Hl);return function(r){So(r,{collapse:t,whitespace:"normal"})}}function So(e,n){if("children"in e){let t={...n};return(e.type==="root"||Io(e))&&(t.before=!0,t.after=!0),t.whitespace=Kl(e,n),Xl(e,t)}if(e.type==="text"){if(n.whitespace==="normal")return Gl(e,n);n.whitespace==="nowrap"&&(e.value=n.collapse(e.value))}return{ignore:Br(e),stripAtStart:!1,remove:!1}}function Gl(e,n){let t=n.collapse(e.value),r={ignore:!1,stripAtStart:!1,remove:!1},i=0,o=t.length;return n.before&&ko(t.charAt(0))&&i++,i!==o&&ko(t.charAt(o-1))&&(n.after?o--:r.stripAtStart=!0),i===o?r.remove=!0:e.value=t.slice(i,o),r}function Xl(e,n){let t=n.before,r=n.after,i=e.children,o=i.length,a=-1;for(;++a<o;){let s=So(i[a],{...n,after:Co(i,a,r),before:t});s.remove?(i.splice(a,1),a--,o--):s.ignore||(t=s.stripAtStart),Eo(i[a])&&(t=!1)}return{ignore:!1,stripAtStart:!!(t||r),remove:!1}}function Co(e,n,t){for(;++n<e.length;){let r=e[n],i=Dl(r);if(i===void 0&&"children"in r&&!Ol(r)&&(i=Co(r.children,-1)),typeof i=="boolean")return i}return t}function Dl(e){if(e.type==="element"){if(Eo(e))return!1;if(Io(e))return!0}else if(e.type==="text"){if(!xe(e))return!1}else if(!Br(e))return!1}function Eo(e){return Ye(e)||Ae(e,wo)}function Io(e){return Ae(e,bo)}function Ol(e){return!!(e.type==="element"&&e.properties.hidden)||Br(e)||Ae(e,vo)}function ko(e){return e===" "||e===`
|
|
166
|
-
`}function _l(e){let n=/\r?\n|\r/.exec(e);return n?n[0]:" "}function Hl(){return" "}function Ul(e){return n;function n(t){return String(t).replace(/[\t\n\v\f\r ]+/g,e)}}function Kl(e,n){if("tagName"in e&&e.properties)switch(e.tagName){case"listing":case"plaintext":case"script":case"style":case"xmp":return"pre";case"nobr":return"nowrap";case"pre":return e.properties.wrap?"pre-wrap":"pre";case"td":case"th":return e.properties.noWrap?"nowrap":n.whitespace;case"textarea":return"pre-wrap";default:}return n.whitespace}var Yl={},jl=mn({newlines:!0});function gn(e){let n=e||Yl,t=n.indent||2,r=n.indentInitial;return typeof t=="number"&&(t=" ".repeat(t)),r==null&&(r=!0),function(a){let s;jl(a),Lt(a,function(l,u){let c=-1;if(!("children"in l))return;if(Ae(l,"head")&&(s=!0),s&&Ae(l,"body")&&(s=void 0),Ae(l,
|
|
165
|
+
`;this._lastLogoSrc=""}onCreate(){this.layoutUpdateTimer=setInterval(()=>this.onUpdate(),250)}onDestroy(){clearInterval(this.layoutUpdateTimer)}onUpdate(){let t=this.child("root");if(!t)return;let r=this.attr.logo||Er;this._lastLogoSrc!=r&&(this._lastLogoSrc=r,t.src=r);let i=window.visualViewport?.offsetTop||0,o=window.visualViewport?.offsetLeft||0,a=this.attr.focusID?document.getElementById(this.attr.focusID):null;if(a){let s=a.getBoundingClientRect();if(!s)return;t.style.position="fixed",t.style.width="128px",t.style.height="128px",t.style.left=Math.round(s.x+s.width/2-128/2+o)+"px",t.style.top=Math.round(s.y+s.height/2-128/2+i)+"px"}else{let s=this.getBoundingClientRect();if(!s)return;t.style.width=s.width+"px",t.style.height=s.height+"px",t.style.left=Math.round(s.x+o)+"px",t.style.top=Math.round(s.y+i)+"px"}}refreshLayout(){setTimeout(()=>this.onUpdate(),100)}};St.observedAttributes=["logo","focusID"];var ho=typeof self=="object"?self:globalThis,gl=(e,n)=>{let t=(i,o)=>(e.set(o,i),i),r=i=>{if(e.has(i))return e.get(i);let[o,a]=n[i];switch(o){case 0:case-1:return t(a,i);case 1:{let s=t([],i);for(let l of a)s.push(r(l));return s}case 2:{let s=t({},i);for(let[l,u]of a)s[r(l)]=r(u);return s}case 3:return t(new Date(a),i);case 4:{let{source:s,flags:l}=a;return t(new RegExp(s,l),i)}case 5:{let s=t(new Map,i);for(let[l,u]of a)s.set(r(l),r(u));return s}case 6:{let s=t(new Set,i);for(let l of a)s.add(r(l));return s}case 7:{let{name:s,message:l}=a;return t(new ho[s](l),i)}case 8:return t(BigInt(a),i);case"BigInt":return t(Object(BigInt(a)),i)}return t(new ho[o](a),i)};return r},Lr=e=>gl(new Map,e)(0);var lt="",{toString:yl}={},{keys:xl}=Object,Tt=e=>{let n=typeof e;if(n!=="object"||!e)return[0,n];let t=yl.call(e).slice(8,-1);switch(t){case"Array":return[1,lt];case"Object":return[2,lt];case"Date":return[3,lt];case"RegExp":return[4,lt];case"Map":return[5,lt];case"Set":return[6,lt]}return t.includes("Array")?[1,t]:t.includes("Error")?[7,t]:[2,t]},pn=([e,n])=>e===0&&(n==="function"||n==="symbol"),bl=(e,n,t,r)=>{let i=(a,s)=>{let l=r.push(a)-1;return t.set(s,l),l},o=a=>{if(t.has(a))return t.get(a);let[s,l]=Tt(a);switch(s){case 0:{let c=a;switch(l){case"bigint":s=8,c=a.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+l);c=null;break;case"undefined":return i([-1],a)}return i([s,c],a)}case 1:{if(l)return i([l,[...a]],a);let c=[],h=i([s,c],a);for(let d of a)c.push(o(d));return h}case 2:{if(l)switch(l){case"BigInt":return i([l,a.toString()],a);case"Boolean":case"Number":case"String":return i([l,a.valueOf()],a)}if(n&&"toJSON"in a)return o(a.toJSON());let c=[],h=i([s,c],a);for(let d of xl(a))(e||!pn(Tt(a[d])))&&c.push([o(d),o(a[d])]);return h}case 3:return i([s,a.toISOString()],a);case 4:{let{source:c,flags:h}=a;return i([s,{source:c,flags:h}],a)}case 5:{let c=[],h=i([s,c],a);for(let[d,p]of a)(e||!(pn(Tt(d))||pn(Tt(p))))&&c.push([o(d),o(p)]);return h}case 6:{let c=[],h=i([s,c],a);for(let d of a)(e||!pn(Tt(d)))&&c.push(o(d));return h}}let{message:u}=a;return i([s,{name:l,message:u}],a)};return o},Mr=(e,{json:n,lossy:t}={})=>{let r=[];return bl(!(n||t),!!n,new Map,r)(e),r};var Te=typeof structuredClone=="function"?(e,n)=>n&&("json"in n||"lossy"in n)?Lr(Mr(e,n)):structuredClone(e):(e,n)=>Lr(Mr(e,n));var Ae=function(e,n,t,r,i){let o=Le(n);if(t!=null&&(typeof t!="number"||t<0||t===Number.POSITIVE_INFINITY))throw new Error("Expected positive finite `index`");if(r!=null&&(!r.type||!r.children))throw new Error("Expected valid `parent`");if(t==null!=(r==null))throw new Error("Expected both `index` and `parent`");return fo(e)?o.call(i,e,t,r):!1},Le=function(e){if(e==null)return kl;if(typeof e=="string")return vl(e);if(typeof e=="object")return wl(e);if(typeof e=="function")return Fr(e);throw new Error("Expected function, string, or array as `test`")};function wl(e){let n=[],t=-1;for(;++t<e.length;)n[t]=Le(e[t]);return Fr(r);function r(...i){let o=-1;for(;++o<n.length;)if(n[o].apply(this,i))return!0;return!1}}function vl(e){return Fr(n);function n(t){return t.tagName===e}}function Fr(e){return n;function n(t,r,i){return!!(fo(t)&&e.call(this,t,typeof r=="number"?r:void 0,i||void 0))}}function kl(e){return!!(e&&typeof e=="object"&&"type"in e&&e.type==="element"&&"tagName"in e&&typeof e.tagName=="string")}function fo(e){return e!==null&&typeof e=="object"&&"type"in e&&"tagName"in e}var Sl=/^[a-zA-Z][a-zA-Z\d+\-.]*?:/,Cl=/^[a-zA-Z]:\\/;function Rr(e){if(typeof e!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof e}\``);return Cl.test(e)?!1:Sl.test(e)}function mo(e){let n=String(e||"").trim();return n?n.split(/[ \t\n\r\f]+/g):[]}function go(e){return e.join(" ").trim()}var ut=function(e){if(e==null)return Al;if(typeof e=="function")return hn(e);if(typeof e=="object")return Array.isArray(e)?El(e):Il(e);if(typeof e=="string")return Tl(e);throw new Error("Expected function, string, or object as test")};function El(e){let n=[],t=-1;for(;++t<e.length;)n[t]=ut(e[t]);return hn(r);function r(...i){let o=-1;for(;++o<n.length;)if(n[o].apply(this,i))return!0;return!1}}function Il(e){let n=e;return hn(t);function t(r){let i=r,o;for(o in e)if(i[o]!==n[o])return!1;return!0}}function Tl(e){return hn(n);function n(t){return t&&t.type===e}}function hn(e){return n;function n(t,r,i){return!!(Ll(t)&&e.call(this,t,typeof r=="number"?r:void 0,i||void 0))}}function Al(){return!0}function Ll(e){return e!==null&&typeof e=="object"&&"type"in e}var yo=[],zr=!0,dn=!1,At="skip";function Lt(e,n,t,r){let i;typeof n=="function"&&typeof t!="function"?(r=t,t=n):i=n;let o=ut(i),a=r?-1:1;s(e,void 0,[])();function s(l,u,c){let h=l&&typeof l=="object"?l:{};if(typeof h.type=="string"){let p=typeof h.tagName=="string"?h.tagName:typeof h.name=="string"?h.name:void 0;Object.defineProperty(d,"name",{value:"node ("+(l.type+(p?"<"+p+">":""))+")"})}return d;function d(){let p=yo,g,w,k;if((!n||o(l,u,c[c.length-1]||void 0))&&(p=Ml(t(l,c)),p[0]===dn))return p;if("children"in l&&l.children){let y=l;if(y.children&&p[0]!==At)for(w=(r?y.children.length:-1)+a,k=c.concat(y);w>-1&&w<y.children.length;){let I=y.children[w];if(g=s(I,w,k)(),g[0]===dn)return g;w=typeof g[1]=="number"?g[1]:w+a}}return p}}}function Ml(e){return Array.isArray(e)?e:typeof e=="number"?[zr,e]:e==null?yo:[e]}function Mt(e,n,t,r){let i,o,a;typeof n=="function"&&typeof t!="function"?(o=void 0,a=n,i=t):(o=n,a=t,i=r),Lt(e,o,s,i);function s(l,u){let c=u[u.length-1],h=c?c.children.indexOf(l):void 0;return a(l,h,c)}}var Fl=["http","https"],Rl=["nofollow"],zl={};function fn(e){let n=e||zl,t=n.protocols||Fl,r=Le(n.test);return function(i){Mt(i,"element",function(o,a,s){if(o.tagName==="a"&&typeof o.properties.href=="string"&&r(o,a,s)){let l=o.properties.href;if(Rr(l)?t.includes(l.slice(0,l.indexOf(":"))):l.startsWith("//")){let u=Ft(n.content,o),c=u&&!Array.isArray(u)?[u]:u,h=Ft(n.rel,o)||Rl,d=typeof h=="string"?mo(h):h,p=Ft(n.target,o),g=Ft(n.properties,o);if(g&&Object.assign(o.properties,Te(g)),d.length>0&&(o.properties.rel=[...d]),p&&(o.properties.target=p),c){let w=Ft(n.contentProperties,o)||{};o.children.push({type:"element",tagName:"span",properties:Te(w),children:Te(c)})}}}})}}function Ft(e,n){return typeof e=="function"?e(n):e}var Ye=Le(function(e){return e.tagName==="audio"||e.tagName==="canvas"||e.tagName==="embed"||e.tagName==="iframe"||e.tagName==="img"||e.tagName==="math"||e.tagName==="object"||e.tagName==="picture"||e.tagName==="svg"||e.tagName==="video"});var Zl={}.hasOwnProperty;function Zr(e,n){let t=e.type==="element"&&Zl.call(e.properties,n)&&e.properties[n];return t!=null&&t!==!1}var Pl=new Set(["pingback","prefetch","stylesheet"]);function Pr(e){if(e.type!=="element"||e.tagName!=="link")return!1;if(e.properties.itemProp)return!0;let n=e.properties.rel,t=-1;if(!Array.isArray(n)||n.length===0)return!1;for(;++t<n.length;)if(!Pl.has(String(n[t])))return!1;return!0}var Vl=Le(["a","abbr","area","b","bdi","bdo","br","button","cite","code","data","datalist","del","dfn","em","i","input","ins","kbd","keygen","label","map","mark","meter","noscript","output","progress","q","ruby","s","samp","script","select","small","span","strong","sub","sup","template","textarea","time","u","var","wbr"]),Nl=Le("meta");function Vr(e){return!!(e.type==="text"||Vl(e)||Ye(e)||Pr(e)||Nl(e)&&Zr(e,"itemProp"))}var Bl=/[ \t\n\f\r]/g;function xe(e){return typeof e=="object"?e.type==="text"?xo(e.value):!1:xo(e)}function xo(e){return e.replace(Bl,"")===""}var Nr=["pre","script","style","textarea"];var bo=["address","article","aside","blockquote","body","br","caption","center","col","colgroup","dd","dialog","dir","div","dl","dt","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","legend","li","li","listing","main","menu","nav","ol","optgroup","option","p","plaintext","pre","section","summary","table","tbody","td","td","tfoot","th","th","thead","tr","ul","wbr","xmp"];var wo=["button","input","select","textarea"];var vo=["area","base","basefont","dialog","datalist","head","link","meta","noembed","noframes","param","rp","script","source","style","template","track","title"];var Wl={},Br=ut(["doctype","comment"]);function mn(e){let t=Ul((e||Wl).newlines?_l:Hl);return function(r){So(r,{collapse:t,whitespace:"normal"})}}function So(e,n){if("children"in e){let t={...n};return(e.type==="root"||Io(e))&&(t.before=!0,t.after=!0),t.whitespace=Kl(e,n),Xl(e,t)}if(e.type==="text"){if(n.whitespace==="normal")return Gl(e,n);n.whitespace==="nowrap"&&(e.value=n.collapse(e.value))}return{ignore:Br(e),stripAtStart:!1,remove:!1}}function Gl(e,n){let t=n.collapse(e.value),r={ignore:!1,stripAtStart:!1,remove:!1},i=0,o=t.length;return n.before&&ko(t.charAt(0))&&i++,i!==o&&ko(t.charAt(o-1))&&(n.after?o--:r.stripAtStart=!0),i===o?r.remove=!0:e.value=t.slice(i,o),r}function Xl(e,n){let t=n.before,r=n.after,i=e.children,o=i.length,a=-1;for(;++a<o;){let s=So(i[a],{...n,after:Co(i,a,r),before:t});s.remove?(i.splice(a,1),a--,o--):s.ignore||(t=s.stripAtStart),Eo(i[a])&&(t=!1)}return{ignore:!1,stripAtStart:!!(t||r),remove:!1}}function Co(e,n,t){for(;++n<e.length;){let r=e[n],i=Dl(r);if(i===void 0&&"children"in r&&!Ol(r)&&(i=Co(r.children,-1)),typeof i=="boolean")return i}return t}function Dl(e){if(e.type==="element"){if(Eo(e))return!1;if(Io(e))return!0}else if(e.type==="text"){if(!xe(e))return!1}else if(!Br(e))return!1}function Eo(e){return Ye(e)||Ae(e,wo)}function Io(e){return Ae(e,bo)}function Ol(e){return!!(e.type==="element"&&e.properties.hidden)||Br(e)||Ae(e,vo)}function ko(e){return e===" "||e===`
|
|
166
|
+
`}function _l(e){let n=/\r?\n|\r/.exec(e);return n?n[0]:" "}function Hl(){return" "}function Ul(e){return n;function n(t){return String(t).replace(/[\t\n\v\f\r ]+/g,e)}}function Kl(e,n){if("tagName"in e&&e.properties)switch(e.tagName){case"listing":case"plaintext":case"script":case"style":case"xmp":return"pre";case"nobr":return"nowrap";case"pre":return e.properties.wrap?"pre-wrap":"pre";case"td":case"th":return e.properties.noWrap?"nowrap":n.whitespace;case"textarea":return"pre-wrap";default:}return n.whitespace}var Yl={},jl=mn({newlines:!0});function gn(e){let n=e||Yl,t=n.indent||2,r=n.indentInitial;return typeof t=="number"&&(t=" ".repeat(t)),r==null&&(r=!0),function(a){let s;jl(a),Lt(a,function(l,u){let c=-1;if(!("children"in l))return;if(Ae(l,"head")&&(s=!0),s&&Ae(l,"body")&&(s=void 0),Ae(l,Nr))return At;let h=l.children,d=u.length;if(h.length===0||!Wr(l,s))return;r||d--;let p;for(;++c<h.length;){let k=h[c];(k.type==="text"||k.type==="comment")&&(k.value.includes(`
|
|
167
167
|
`)&&(p=!0),k.value=k.value.replace(/ *\n/g,"$&"+String(t).repeat(d)))}let g=[],w;for(c=-1;++c<h.length;){let k=h[c];(Wr(k,s)||p&&!c)&&(i(g,d,k),p=!0),w=k,g.push(k)}w&&(p||Wr(w,s))&&(xe(w)&&(g.pop(),w=g[g.length-1]),i(g,d-1)),l.children=g})};function i(a,s,l){let u=a[a.length-1],c=u&&xe(u)?a[a.length-2]:u,h=(o(c)&&o(l)?`
|
|
168
168
|
|
|
169
169
|
`:`
|
|
170
|
-
`)+String(t).repeat(Math.max(s,0));u&&u.type==="text"?u.value=xe(u)?h:u.value+h:a.push({type:"text",value:h})}function o(a){return!!(a&&a.type==="element"&&n.blanks&&n.blanks.length>0&&n.blanks.includes(a.tagName))}}function Wr(e,n){return e.type==="root"||(e.type==="element"?n||Ae(e,"script")||Ye(e)||!Nr(e):!1)}var To=["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","keygen","link","meta","param","source","track","wbr"];var Pe=class{constructor(n,t,r){this.property=n,this.normal=t,r&&(this.space=r)}};Pe.prototype.property={};Pe.prototype.normal={};Pe.prototype.space=null;function Gr(e,n){let t={},r={},i=-1;for(;++i<e.length;)Object.assign(t,e[i].property),Object.assign(r,e[i].normal);return new Pe(t,r,n)}function Rt(e){return e.toLowerCase()}var ue=class{constructor(n,t){this.property=n,this.attribute=t}};ue.prototype.space=null;ue.prototype.boolean=!1;ue.prototype.booleanish=!1;ue.prototype.overloadedBoolean=!1;ue.prototype.number=!1;ue.prototype.commaSeparated=!1;ue.prototype.spaceSeparated=!1;ue.prototype.commaOrSpaceSeparated=!1;ue.prototype.mustUseProperty=!1;ue.prototype.defined=!1;var zt={};Oi(zt,{boolean:()=>V,booleanish:()=>q,commaOrSpaceSeparated:()=>fe,commaSeparated:()=>We,number:()=>S,overloadedBoolean:()=>Xr,spaceSeparated:()=>K});var Jl=0,V=je(),q=je(),Xr=je(),S=je(),K=je(),We=je(),fe=je();function je(){return 2**++Jl}var Dr=Object.keys(zt),Je=class extends ue{constructor(n,t,r,i){let o=-1;if(super(n,t),Ao(this,"space",i),typeof r=="number")for(;++o<Dr.length;){let a=Dr[o];Ao(this,Dr[o],(r&zt[a])===zt[a])}}};Je.prototype.defined=!0;function Ao(e,n,t){t&&(e[n]=t)}var Ql={}.hasOwnProperty;function ve(e){let n={},t={},r;for(r in e.properties)if(Ql.call(e.properties,r)){let i=e.properties[r],o=new Je(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(o.mustUseProperty=!0),n[r]=o,t[Rt(r)]=r,t[Rt(o.attribute)]=r}return new Pe(n,t,e.space)}var Or=ve({space:"xlink",transform(e,n){return"xlink:"+n.slice(5).toLowerCase()},properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null}});var _r=ve({space:"xml",transform(e,n){return"xml:"+n.slice(3).toLowerCase()},properties:{xmlLang:null,xmlBase:null,xmlSpace:null}});function yn(e,n){return n in e?e[n]:n}function xn(e,n){return yn(e,n.toLowerCase())}var Hr=ve({space:"xmlns",attributes:{xmlnsxlink:"xmlns:xlink"},transform:xn,properties:{xmlns:null,xmlnsXLink:null}});var Ur=ve({transform(e,n){return n==="role"?n:"aria-"+n.slice(4).toLowerCase()},properties:{ariaActiveDescendant:null,ariaAtomic:q,ariaAutoComplete:null,ariaBusy:q,ariaChecked:q,ariaColCount:S,ariaColIndex:S,ariaColSpan:S,ariaControls:K,ariaCurrent:null,ariaDescribedBy:K,ariaDetails:null,ariaDisabled:q,ariaDropEffect:K,ariaErrorMessage:null,ariaExpanded:q,ariaFlowTo:K,ariaGrabbed:q,ariaHasPopup:null,ariaHidden:q,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:K,ariaLevel:S,ariaLive:null,ariaModal:q,ariaMultiLine:q,ariaMultiSelectable:q,ariaOrientation:null,ariaOwns:K,ariaPlaceholder:null,ariaPosInSet:S,ariaPressed:q,ariaReadOnly:q,ariaRelevant:null,ariaRequired:q,ariaRoleDescription:K,ariaRowCount:S,ariaRowIndex:S,ariaRowSpan:S,ariaSelected:q,ariaSetSize:S,ariaSort:null,ariaValueMax:S,ariaValueMin:S,ariaValueNow:S,ariaValueText:null,role:null}});var Lo=ve({space:"html",attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},transform:xn,mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:We,acceptCharset:K,accessKey:K,action:null,allow:null,allowFullScreen:V,allowPaymentRequest:V,allowUserMedia:V,alt:null,as:null,async:V,autoCapitalize:null,autoComplete:K,autoFocus:V,autoPlay:V,blocking:K,capture:null,charSet:null,checked:V,cite:null,className:K,cols:S,colSpan:null,content:null,contentEditable:q,controls:V,controlsList:K,coords:S|We,crossOrigin:null,data:null,dateTime:null,decoding:null,default:V,defer:V,dir:null,dirName:null,disabled:V,download:Xr,draggable:q,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:V,formTarget:null,headers:K,height:S,hidden:V,high:S,href:null,hrefLang:null,htmlFor:K,httpEquiv:K,id:null,imageSizes:null,imageSrcSet:null,inert:V,inputMode:null,integrity:null,is:null,isMap:V,itemId:null,itemProp:K,itemRef:K,itemScope:V,itemType:K,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:V,low:S,manifest:null,max:null,maxLength:S,media:null,method:null,min:null,minLength:S,multiple:V,muted:V,name:null,nonce:null,noModule:V,noValidate:V,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:V,optimum:S,pattern:null,ping:K,placeholder:null,playsInline:V,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:V,referrerPolicy:null,rel:K,required:V,reversed:V,rows:S,rowSpan:S,sandbox:K,scope:null,scoped:V,seamless:V,selected:V,shadowRootClonable:V,shadowRootDelegatesFocus:V,shadowRootMode:null,shape:null,size:S,sizes:null,slot:null,span:S,spellCheck:q,src:null,srcDoc:null,srcLang:null,srcSet:null,start:S,step:null,style:null,tabIndex:S,target:null,title:null,translate:null,type:null,typeMustMatch:V,useMap:null,value:q,width:S,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:K,axis:null,background:null,bgColor:null,border:S,borderColor:null,bottomMargin:S,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:V,declare:V,event:null,face:null,frame:null,frameBorder:null,hSpace:S,leftMargin:S,link:null,longDesc:null,lowSrc:null,marginHeight:S,marginWidth:S,noResize:V,noHref:V,noShade:V,noWrap:V,object:null,profile:null,prompt:null,rev:null,rightMargin:S,rules:null,scheme:null,scrolling:q,standby:null,summary:null,text:null,topMargin:S,valueType:null,version:null,vAlign:null,vLink:null,vSpace:S,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:V,disableRemotePlayback:V,prefix:null,property:null,results:S,security:null,unselectable:null}});var Fo=ve({space:"svg",attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},transform:yn,properties:{about:fe,accentHeight:S,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:S,amplitude:S,arabicForm:null,ascent:S,attributeName:null,attributeType:null,azimuth:S,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:S,by:null,calcMode:null,capHeight:S,className:K,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:S,diffuseConstant:S,direction:null,display:null,dur:null,divisor:S,dominantBaseline:null,download:V,dx:null,dy:null,edgeMode:null,editable:null,elevation:S,enableBackground:null,end:null,event:null,exponent:S,externalResourcesRequired:null,fill:null,fillOpacity:S,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:We,g2:We,glyphName:We,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:S,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:S,horizOriginX:S,horizOriginY:S,id:null,ideographic:S,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:S,k:S,k1:S,k2:S,k3:S,k4:S,kernelMatrix:fe,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:S,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:S,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:S,overlineThickness:S,paintOrder:null,panose1:null,path:null,pathLength:S,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:K,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:S,pointsAtY:S,pointsAtZ:S,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:fe,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:fe,rev:fe,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:fe,requiredFeatures:fe,requiredFonts:fe,requiredFormats:fe,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:S,specularExponent:S,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:S,strikethroughThickness:S,string:null,stroke:null,strokeDashArray:fe,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:S,strokeOpacity:S,strokeWidth:null,style:null,surfaceScale:S,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:fe,tabIndex:S,tableValues:null,target:null,targetX:S,targetY:S,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:fe,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:S,underlineThickness:S,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:S,values:null,vAlphabetic:S,vMathematical:S,vectorEffect:null,vHanging:S,vIdeographic:S,version:null,vertAdvY:S,vertOriginX:S,vertOriginY:S,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:S,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null}});var ql=/^data[-\w.:]+$/i,Mo=/-[a-z]/g,$l=/[A-Z]/g;function Kr(e,n){let t=Rt(n),r=n,i=ue;if(t in e.normal)return e.property[e.normal[t]];if(t.length>4&&t.slice(0,4)==="data"&&ql.test(n)){if(n.charAt(4)==="-"){let o=n.slice(5).replace(Mo,tu);r="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{let o=n.slice(4);if(!Mo.test(o)){let a=o.replace($l,eu);a.charAt(0)!=="-"&&(a="-"+a),n="data"+a}}i=Je}return new i(r,n)}function eu(e){return"-"+e.toLowerCase()}function tu(e){return e.charAt(1).toUpperCase()}var Ro=Gr([_r,Or,Hr,Ur,Lo],"html"),bn=Gr([_r,Or,Hr,Ur,Fo],"svg");var zo={}.hasOwnProperty;function Zo(e,n){let t=n||{};function r(i,...o){let a=r.invalid,s=r.handlers;if(i&&zo.call(i,e)){let l=String(i[e]);a=zo.call(s,l)?s[l]:r.unknown}if(a)return a.call(this,i,...o)}return r.handlers=t.handlers||{},r.invalid=t.invalid,r.unknown=t.unknown,r}var nu=/["&'<>`]/g,ru=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,iu=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,ou=/[|\\{}()[\]^$+*?.]/g,Po=new WeakMap;function No(e,n){if(e=e.replace(n.subset?au(n.subset):nu,r),n.subset||n.escapeOnly)return e;return e.replace(ru,t).replace(iu,r);function t(i,o,a){return n.format((i.charCodeAt(0)-55296)*1024+i.charCodeAt(1)-56320+65536,a.charCodeAt(o+2),n)}function r(i,o,a){return n.format(i.charCodeAt(0),a.charCodeAt(o+1),n)}}function au(e){let n=Po.get(e);return n||(n=su(e),Po.set(e,n)),n}function su(e){let n=[],t=-1;for(;++t<e.length;)n.push(e[t].replace(ou,"\\$&"));return new RegExp("(?:"+n.join("|")+")","g")}var lu=/[\dA-Fa-f]/;function Vo(e,n,t){let r="&#x"+e.toString(16).toUpperCase();return t&&n&&!lu.test(String.fromCharCode(n))?r:r+";"}var uu=/\d/;function Bo(e,n,t){let r="&#"+String(e);return t&&n&&!uu.test(String.fromCharCode(n))?r:r+";"}var Wo=["AElig","AMP","Aacute","Acirc","Agrave","Aring","Atilde","Auml","COPY","Ccedil","ETH","Eacute","Ecirc","Egrave","Euml","GT","Iacute","Icirc","Igrave","Iuml","LT","Ntilde","Oacute","Ocirc","Ograve","Oslash","Otilde","Ouml","QUOT","REG","THORN","Uacute","Ucirc","Ugrave","Uuml","Yacute","aacute","acirc","acute","aelig","agrave","amp","aring","atilde","auml","brvbar","ccedil","cedil","cent","copy","curren","deg","divide","eacute","ecirc","egrave","eth","euml","frac12","frac14","frac34","gt","iacute","icirc","iexcl","igrave","iquest","iuml","laquo","lt","macr","micro","middot","nbsp","not","ntilde","oacute","ocirc","ograve","ordf","ordm","oslash","otilde","ouml","para","plusmn","pound","quot","raquo","reg","sect","shy","sup1","sup2","sup3","szlig","thorn","times","uacute","ucirc","ugrave","uml","uuml","yacute","yen","yuml"];var wn={nbsp:"\xA0",iexcl:"\xA1",cent:"\xA2",pound:"\xA3",curren:"\xA4",yen:"\xA5",brvbar:"\xA6",sect:"\xA7",uml:"\xA8",copy:"\xA9",ordf:"\xAA",laquo:"\xAB",not:"\xAC",shy:"\xAD",reg:"\xAE",macr:"\xAF",deg:"\xB0",plusmn:"\xB1",sup2:"\xB2",sup3:"\xB3",acute:"\xB4",micro:"\xB5",para:"\xB6",middot:"\xB7",cedil:"\xB8",sup1:"\xB9",ordm:"\xBA",raquo:"\xBB",frac14:"\xBC",frac12:"\xBD",frac34:"\xBE",iquest:"\xBF",Agrave:"\xC0",Aacute:"\xC1",Acirc:"\xC2",Atilde:"\xC3",Auml:"\xC4",Aring:"\xC5",AElig:"\xC6",Ccedil:"\xC7",Egrave:"\xC8",Eacute:"\xC9",Ecirc:"\xCA",Euml:"\xCB",Igrave:"\xCC",Iacute:"\xCD",Icirc:"\xCE",Iuml:"\xCF",ETH:"\xD0",Ntilde:"\xD1",Ograve:"\xD2",Oacute:"\xD3",Ocirc:"\xD4",Otilde:"\xD5",Ouml:"\xD6",times:"\xD7",Oslash:"\xD8",Ugrave:"\xD9",Uacute:"\xDA",Ucirc:"\xDB",Uuml:"\xDC",Yacute:"\xDD",THORN:"\xDE",szlig:"\xDF",agrave:"\xE0",aacute:"\xE1",acirc:"\xE2",atilde:"\xE3",auml:"\xE4",aring:"\xE5",aelig:"\xE6",ccedil:"\xE7",egrave:"\xE8",eacute:"\xE9",ecirc:"\xEA",euml:"\xEB",igrave:"\xEC",iacute:"\xED",icirc:"\xEE",iuml:"\xEF",eth:"\xF0",ntilde:"\xF1",ograve:"\xF2",oacute:"\xF3",ocirc:"\xF4",otilde:"\xF5",ouml:"\xF6",divide:"\xF7",oslash:"\xF8",ugrave:"\xF9",uacute:"\xFA",ucirc:"\xFB",uuml:"\xFC",yacute:"\xFD",thorn:"\xFE",yuml:"\xFF",fnof:"\u0192",Alpha:"\u0391",Beta:"\u0392",Gamma:"\u0393",Delta:"\u0394",Epsilon:"\u0395",Zeta:"\u0396",Eta:"\u0397",Theta:"\u0398",Iota:"\u0399",Kappa:"\u039A",Lambda:"\u039B",Mu:"\u039C",Nu:"\u039D",Xi:"\u039E",Omicron:"\u039F",Pi:"\u03A0",Rho:"\u03A1",Sigma:"\u03A3",Tau:"\u03A4",Upsilon:"\u03A5",Phi:"\u03A6",Chi:"\u03A7",Psi:"\u03A8",Omega:"\u03A9",alpha:"\u03B1",beta:"\u03B2",gamma:"\u03B3",delta:"\u03B4",epsilon:"\u03B5",zeta:"\u03B6",eta:"\u03B7",theta:"\u03B8",iota:"\u03B9",kappa:"\u03BA",lambda:"\u03BB",mu:"\u03BC",nu:"\u03BD",xi:"\u03BE",omicron:"\u03BF",pi:"\u03C0",rho:"\u03C1",sigmaf:"\u03C2",sigma:"\u03C3",tau:"\u03C4",upsilon:"\u03C5",phi:"\u03C6",chi:"\u03C7",psi:"\u03C8",omega:"\u03C9",thetasym:"\u03D1",upsih:"\u03D2",piv:"\u03D6",bull:"\u2022",hellip:"\u2026",prime:"\u2032",Prime:"\u2033",oline:"\u203E",frasl:"\u2044",weierp:"\u2118",image:"\u2111",real:"\u211C",trade:"\u2122",alefsym:"\u2135",larr:"\u2190",uarr:"\u2191",rarr:"\u2192",darr:"\u2193",harr:"\u2194",crarr:"\u21B5",lArr:"\u21D0",uArr:"\u21D1",rArr:"\u21D2",dArr:"\u21D3",hArr:"\u21D4",forall:"\u2200",part:"\u2202",exist:"\u2203",empty:"\u2205",nabla:"\u2207",isin:"\u2208",notin:"\u2209",ni:"\u220B",prod:"\u220F",sum:"\u2211",minus:"\u2212",lowast:"\u2217",radic:"\u221A",prop:"\u221D",infin:"\u221E",ang:"\u2220",and:"\u2227",or:"\u2228",cap:"\u2229",cup:"\u222A",int:"\u222B",there4:"\u2234",sim:"\u223C",cong:"\u2245",asymp:"\u2248",ne:"\u2260",equiv:"\u2261",le:"\u2264",ge:"\u2265",sub:"\u2282",sup:"\u2283",nsub:"\u2284",sube:"\u2286",supe:"\u2287",oplus:"\u2295",otimes:"\u2297",perp:"\u22A5",sdot:"\u22C5",lceil:"\u2308",rceil:"\u2309",lfloor:"\u230A",rfloor:"\u230B",lang:"\u2329",rang:"\u232A",loz:"\u25CA",spades:"\u2660",clubs:"\u2663",hearts:"\u2665",diams:"\u2666",quot:'"',amp:"&",lt:"<",gt:">",OElig:"\u0152",oelig:"\u0153",Scaron:"\u0160",scaron:"\u0161",Yuml:"\u0178",circ:"\u02C6",tilde:"\u02DC",ensp:"\u2002",emsp:"\u2003",thinsp:"\u2009",zwnj:"\u200C",zwj:"\u200D",lrm:"\u200E",rlm:"\u200F",ndash:"\u2013",mdash:"\u2014",lsquo:"\u2018",rsquo:"\u2019",sbquo:"\u201A",ldquo:"\u201C",rdquo:"\u201D",bdquo:"\u201E",dagger:"\u2020",Dagger:"\u2021",permil:"\u2030",lsaquo:"\u2039",rsaquo:"\u203A",euro:"\u20AC"};var Go=["cent","copy","divide","gt","lt","not","para","times"];var Xo={}.hasOwnProperty,Yr={},vn;for(vn in wn)Xo.call(wn,vn)&&(Yr[wn[vn]]=vn);var cu=/[^\dA-Za-z]/;function Do(e,n,t,r){let i=String.fromCharCode(e);if(Xo.call(Yr,i)){let o=Yr[i],a="&"+o;return t&&Wo.includes(o)&&!Go.includes(o)&&(!r||n&&n!==61&&cu.test(String.fromCharCode(n)))?a:a+";"}return""}function Oo(e,n,t){let r=Vo(e,n,t.omitOptionalSemicolons),i;if((t.useNamedReferences||t.useShortestReferences)&&(i=Do(e,n,t.omitOptionalSemicolons,t.attribute)),(t.useShortestReferences||!i)&&t.useShortestReferences){let o=Bo(e,n,t.omitOptionalSemicolons);o.length<r.length&&(r=o)}return i&&(!t.useShortestReferences||i.length<r.length)?i:r}function Ne(e,n){return No(e,Object.assign({format:Oo},n))}var pu=/^>|^->|<!--|-->|--!>|<!-$/g,hu=[">"],du=["<",">"];function _o(e,n,t,r){return r.settings.bogusComments?"<?"+Ne(e.value,Object.assign({},r.settings.characterReferences,{subset:hu}))+">":"<!--"+e.value.replace(pu,i)+"-->";function i(o){return Ne(o,Object.assign({},r.settings.characterReferences,{subset:du}))}}function Ho(e,n,t,r){return"<!"+(r.settings.upperDoctype?"DOCTYPE":"doctype")+(r.settings.tightDoctype?"":" ")+"html>"}function jr(e,n){let t=String(e);if(typeof n!="string")throw new TypeError("Expected character");let r=0,i=t.indexOf(n);for(;i!==-1;)r++,i=t.indexOf(n,i+n.length);return r}function Uo(e,n){let t=n||{};return(e[e.length-1]===""?[...e,""]:e).join((t.padRight?" ":"")+","+(t.padLeft===!1?"":" ")).trim()}var ee=Ko(1),Jr=Ko(-1),fu=[];function Ko(e){return n;function n(t,r,i){let o=t?t.children:fu,a=(r||0)+e,s=o[a];if(!i)for(;s&&xe(s);)a+=e,s=o[a];return s}}var mu={}.hasOwnProperty;function kn(e){return n;function n(t,r,i){return mu.call(e,t.tagName)&&e[t.tagName](t,r,i)}}var Zt=kn({body:yu,caption:Qr,colgroup:Qr,dd:vu,dt:wu,head:Qr,html:gu,li:bu,optgroup:ku,option:Su,p:xu,rp:Yo,rt:Yo,tbody:Eu,td:jo,tfoot:Iu,th:jo,thead:Cu,tr:Tu});function Qr(e,n,t){let r=ee(t,n,!0);return!r||r.type!=="comment"&&!(r.type==="text"&&xe(r.value.charAt(0)))}function gu(e,n,t){let r=ee(t,n);return!r||r.type!=="comment"}function yu(e,n,t){let r=ee(t,n);return!r||r.type!=="comment"}function xu(e,n,t){let r=ee(t,n);return r?r.type==="element"&&(r.tagName==="address"||r.tagName==="article"||r.tagName==="aside"||r.tagName==="blockquote"||r.tagName==="details"||r.tagName==="div"||r.tagName==="dl"||r.tagName==="fieldset"||r.tagName==="figcaption"||r.tagName==="figure"||r.tagName==="footer"||r.tagName==="form"||r.tagName==="h1"||r.tagName==="h2"||r.tagName==="h3"||r.tagName==="h4"||r.tagName==="h5"||r.tagName==="h6"||r.tagName==="header"||r.tagName==="hgroup"||r.tagName==="hr"||r.tagName==="main"||r.tagName==="menu"||r.tagName==="nav"||r.tagName==="ol"||r.tagName==="p"||r.tagName==="pre"||r.tagName==="section"||r.tagName==="table"||r.tagName==="ul"):!t||!(t.type==="element"&&(t.tagName==="a"||t.tagName==="audio"||t.tagName==="del"||t.tagName==="ins"||t.tagName==="map"||t.tagName==="noscript"||t.tagName==="video"))}function bu(e,n,t){let r=ee(t,n);return!r||r.type==="element"&&r.tagName==="li"}function wu(e,n,t){let r=ee(t,n);return!!(r&&r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd"))}function vu(e,n,t){let r=ee(t,n);return!r||r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd")}function Yo(e,n,t){let r=ee(t,n);return!r||r.type==="element"&&(r.tagName==="rp"||r.tagName==="rt")}function ku(e,n,t){let r=ee(t,n);return!r||r.type==="element"&&r.tagName==="optgroup"}function Su(e,n,t){let r=ee(t,n);return!r||r.type==="element"&&(r.tagName==="option"||r.tagName==="optgroup")}function Cu(e,n,t){let r=ee(t,n);return!!(r&&r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot"))}function Eu(e,n,t){let r=ee(t,n);return!r||r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot")}function Iu(e,n,t){return!ee(t,n)}function Tu(e,n,t){let r=ee(t,n);return!r||r.type==="element"&&r.tagName==="tr"}function jo(e,n,t){let r=ee(t,n);return!r||r.type==="element"&&(r.tagName==="td"||r.tagName==="th")}var Jo=kn({body:Fu,colgroup:Mu,head:Lu,html:Au,tbody:Ru});function Au(e){let n=ee(e,-1);return!n||n.type!=="comment"}function Lu(e){let n=e.children,t=[],r=-1;for(;++r<n.length;){let i=n[r];if(i.type==="element"&&(i.tagName==="title"||i.tagName==="base")){if(t.includes(i.tagName))return!1;t.push(i.tagName)}}return n.length>0}function Fu(e){let n=ee(e,-1,!0);return!n||n.type!=="comment"&&!(n.type==="text"&&xe(n.value.charAt(0)))&&!(n.type==="element"&&(n.tagName==="meta"||n.tagName==="link"||n.tagName==="script"||n.tagName==="style"||n.tagName==="template"))}function Mu(e,n,t){let r=Jr(t,n),i=ee(e,-1,!0);return t&&r&&r.type==="element"&&r.tagName==="colgroup"&&Zt(r,t.children.indexOf(r),t)?!1:!!(i&&i.type==="element"&&i.tagName==="col")}function Ru(e,n,t){let r=Jr(t,n),i=ee(e,-1);return t&&r&&r.type==="element"&&(r.tagName==="thead"||r.tagName==="tbody")&&Zt(r,t.children.indexOf(r),t)?!1:!!(i&&i.type==="element"&&i.tagName==="tr")}var Sn={name:[[`
|
|
170
|
+
`)+String(t).repeat(Math.max(s,0));u&&u.type==="text"?u.value=xe(u)?h:u.value+h:a.push({type:"text",value:h})}function o(a){return!!(a&&a.type==="element"&&n.blanks&&n.blanks.length>0&&n.blanks.includes(a.tagName))}}function Wr(e,n){return e.type==="root"||(e.type==="element"?n||Ae(e,"script")||Ye(e)||!Vr(e):!1)}var To=["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","keygen","link","meta","param","source","track","wbr"];var Pe=class{constructor(n,t,r){this.property=n,this.normal=t,r&&(this.space=r)}};Pe.prototype.property={};Pe.prototype.normal={};Pe.prototype.space=null;function Gr(e,n){let t={},r={},i=-1;for(;++i<e.length;)Object.assign(t,e[i].property),Object.assign(r,e[i].normal);return new Pe(t,r,n)}function Rt(e){return e.toLowerCase()}var ue=class{constructor(n,t){this.property=n,this.attribute=t}};ue.prototype.space=null;ue.prototype.boolean=!1;ue.prototype.booleanish=!1;ue.prototype.overloadedBoolean=!1;ue.prototype.number=!1;ue.prototype.commaSeparated=!1;ue.prototype.spaceSeparated=!1;ue.prototype.commaOrSpaceSeparated=!1;ue.prototype.mustUseProperty=!1;ue.prototype.defined=!1;var zt={};Oi(zt,{boolean:()=>N,booleanish:()=>q,commaOrSpaceSeparated:()=>fe,commaSeparated:()=>We,number:()=>S,overloadedBoolean:()=>Xr,spaceSeparated:()=>K});var Jl=0,N=je(),q=je(),Xr=je(),S=je(),K=je(),We=je(),fe=je();function je(){return 2**++Jl}var Dr=Object.keys(zt),Je=class extends ue{constructor(n,t,r,i){let o=-1;if(super(n,t),Ao(this,"space",i),typeof r=="number")for(;++o<Dr.length;){let a=Dr[o];Ao(this,Dr[o],(r&zt[a])===zt[a])}}};Je.prototype.defined=!0;function Ao(e,n,t){t&&(e[n]=t)}var Ql={}.hasOwnProperty;function ve(e){let n={},t={},r;for(r in e.properties)if(Ql.call(e.properties,r)){let i=e.properties[r],o=new Je(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(o.mustUseProperty=!0),n[r]=o,t[Rt(r)]=r,t[Rt(o.attribute)]=r}return new Pe(n,t,e.space)}var Or=ve({space:"xlink",transform(e,n){return"xlink:"+n.slice(5).toLowerCase()},properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null}});var _r=ve({space:"xml",transform(e,n){return"xml:"+n.slice(3).toLowerCase()},properties:{xmlLang:null,xmlBase:null,xmlSpace:null}});function yn(e,n){return n in e?e[n]:n}function xn(e,n){return yn(e,n.toLowerCase())}var Hr=ve({space:"xmlns",attributes:{xmlnsxlink:"xmlns:xlink"},transform:xn,properties:{xmlns:null,xmlnsXLink:null}});var Ur=ve({transform(e,n){return n==="role"?n:"aria-"+n.slice(4).toLowerCase()},properties:{ariaActiveDescendant:null,ariaAtomic:q,ariaAutoComplete:null,ariaBusy:q,ariaChecked:q,ariaColCount:S,ariaColIndex:S,ariaColSpan:S,ariaControls:K,ariaCurrent:null,ariaDescribedBy:K,ariaDetails:null,ariaDisabled:q,ariaDropEffect:K,ariaErrorMessage:null,ariaExpanded:q,ariaFlowTo:K,ariaGrabbed:q,ariaHasPopup:null,ariaHidden:q,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:K,ariaLevel:S,ariaLive:null,ariaModal:q,ariaMultiLine:q,ariaMultiSelectable:q,ariaOrientation:null,ariaOwns:K,ariaPlaceholder:null,ariaPosInSet:S,ariaPressed:q,ariaReadOnly:q,ariaRelevant:null,ariaRequired:q,ariaRoleDescription:K,ariaRowCount:S,ariaRowIndex:S,ariaRowSpan:S,ariaSelected:q,ariaSetSize:S,ariaSort:null,ariaValueMax:S,ariaValueMin:S,ariaValueNow:S,ariaValueText:null,role:null}});var Lo=ve({space:"html",attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},transform:xn,mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:We,acceptCharset:K,accessKey:K,action:null,allow:null,allowFullScreen:N,allowPaymentRequest:N,allowUserMedia:N,alt:null,as:null,async:N,autoCapitalize:null,autoComplete:K,autoFocus:N,autoPlay:N,blocking:K,capture:null,charSet:null,checked:N,cite:null,className:K,cols:S,colSpan:null,content:null,contentEditable:q,controls:N,controlsList:K,coords:S|We,crossOrigin:null,data:null,dateTime:null,decoding:null,default:N,defer:N,dir:null,dirName:null,disabled:N,download:Xr,draggable:q,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:N,formTarget:null,headers:K,height:S,hidden:N,high:S,href:null,hrefLang:null,htmlFor:K,httpEquiv:K,id:null,imageSizes:null,imageSrcSet:null,inert:N,inputMode:null,integrity:null,is:null,isMap:N,itemId:null,itemProp:K,itemRef:K,itemScope:N,itemType:K,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:N,low:S,manifest:null,max:null,maxLength:S,media:null,method:null,min:null,minLength:S,multiple:N,muted:N,name:null,nonce:null,noModule:N,noValidate:N,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:N,optimum:S,pattern:null,ping:K,placeholder:null,playsInline:N,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:N,referrerPolicy:null,rel:K,required:N,reversed:N,rows:S,rowSpan:S,sandbox:K,scope:null,scoped:N,seamless:N,selected:N,shadowRootClonable:N,shadowRootDelegatesFocus:N,shadowRootMode:null,shape:null,size:S,sizes:null,slot:null,span:S,spellCheck:q,src:null,srcDoc:null,srcLang:null,srcSet:null,start:S,step:null,style:null,tabIndex:S,target:null,title:null,translate:null,type:null,typeMustMatch:N,useMap:null,value:q,width:S,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:K,axis:null,background:null,bgColor:null,border:S,borderColor:null,bottomMargin:S,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:N,declare:N,event:null,face:null,frame:null,frameBorder:null,hSpace:S,leftMargin:S,link:null,longDesc:null,lowSrc:null,marginHeight:S,marginWidth:S,noResize:N,noHref:N,noShade:N,noWrap:N,object:null,profile:null,prompt:null,rev:null,rightMargin:S,rules:null,scheme:null,scrolling:q,standby:null,summary:null,text:null,topMargin:S,valueType:null,version:null,vAlign:null,vLink:null,vSpace:S,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:N,disableRemotePlayback:N,prefix:null,property:null,results:S,security:null,unselectable:null}});var Mo=ve({space:"svg",attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},transform:yn,properties:{about:fe,accentHeight:S,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:S,amplitude:S,arabicForm:null,ascent:S,attributeName:null,attributeType:null,azimuth:S,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:S,by:null,calcMode:null,capHeight:S,className:K,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:S,diffuseConstant:S,direction:null,display:null,dur:null,divisor:S,dominantBaseline:null,download:N,dx:null,dy:null,edgeMode:null,editable:null,elevation:S,enableBackground:null,end:null,event:null,exponent:S,externalResourcesRequired:null,fill:null,fillOpacity:S,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:We,g2:We,glyphName:We,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:S,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:S,horizOriginX:S,horizOriginY:S,id:null,ideographic:S,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:S,k:S,k1:S,k2:S,k3:S,k4:S,kernelMatrix:fe,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:S,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:S,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:S,overlineThickness:S,paintOrder:null,panose1:null,path:null,pathLength:S,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:K,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:S,pointsAtY:S,pointsAtZ:S,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:fe,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:fe,rev:fe,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:fe,requiredFeatures:fe,requiredFonts:fe,requiredFormats:fe,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:S,specularExponent:S,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:S,strikethroughThickness:S,string:null,stroke:null,strokeDashArray:fe,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:S,strokeOpacity:S,strokeWidth:null,style:null,surfaceScale:S,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:fe,tabIndex:S,tableValues:null,target:null,targetX:S,targetY:S,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:fe,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:S,underlineThickness:S,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:S,values:null,vAlphabetic:S,vMathematical:S,vectorEffect:null,vHanging:S,vIdeographic:S,version:null,vertAdvY:S,vertOriginX:S,vertOriginY:S,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:S,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null}});var ql=/^data[-\w.:]+$/i,Fo=/-[a-z]/g,$l=/[A-Z]/g;function Kr(e,n){let t=Rt(n),r=n,i=ue;if(t in e.normal)return e.property[e.normal[t]];if(t.length>4&&t.slice(0,4)==="data"&&ql.test(n)){if(n.charAt(4)==="-"){let o=n.slice(5).replace(Fo,tu);r="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{let o=n.slice(4);if(!Fo.test(o)){let a=o.replace($l,eu);a.charAt(0)!=="-"&&(a="-"+a),n="data"+a}}i=Je}return new i(r,n)}function eu(e){return"-"+e.toLowerCase()}function tu(e){return e.charAt(1).toUpperCase()}var Ro=Gr([_r,Or,Hr,Ur,Lo],"html"),bn=Gr([_r,Or,Hr,Ur,Mo],"svg");var zo={}.hasOwnProperty;function Zo(e,n){let t=n||{};function r(i,...o){let a=r.invalid,s=r.handlers;if(i&&zo.call(i,e)){let l=String(i[e]);a=zo.call(s,l)?s[l]:r.unknown}if(a)return a.call(this,i,...o)}return r.handlers=t.handlers||{},r.invalid=t.invalid,r.unknown=t.unknown,r}var nu=/["&'<>`]/g,ru=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,iu=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,ou=/[|\\{}()[\]^$+*?.]/g,Po=new WeakMap;function Vo(e,n){if(e=e.replace(n.subset?au(n.subset):nu,r),n.subset||n.escapeOnly)return e;return e.replace(ru,t).replace(iu,r);function t(i,o,a){return n.format((i.charCodeAt(0)-55296)*1024+i.charCodeAt(1)-56320+65536,a.charCodeAt(o+2),n)}function r(i,o,a){return n.format(i.charCodeAt(0),a.charCodeAt(o+1),n)}}function au(e){let n=Po.get(e);return n||(n=su(e),Po.set(e,n)),n}function su(e){let n=[],t=-1;for(;++t<e.length;)n.push(e[t].replace(ou,"\\$&"));return new RegExp("(?:"+n.join("|")+")","g")}var lu=/[\dA-Fa-f]/;function No(e,n,t){let r="&#x"+e.toString(16).toUpperCase();return t&&n&&!lu.test(String.fromCharCode(n))?r:r+";"}var uu=/\d/;function Bo(e,n,t){let r="&#"+String(e);return t&&n&&!uu.test(String.fromCharCode(n))?r:r+";"}var Wo=["AElig","AMP","Aacute","Acirc","Agrave","Aring","Atilde","Auml","COPY","Ccedil","ETH","Eacute","Ecirc","Egrave","Euml","GT","Iacute","Icirc","Igrave","Iuml","LT","Ntilde","Oacute","Ocirc","Ograve","Oslash","Otilde","Ouml","QUOT","REG","THORN","Uacute","Ucirc","Ugrave","Uuml","Yacute","aacute","acirc","acute","aelig","agrave","amp","aring","atilde","auml","brvbar","ccedil","cedil","cent","copy","curren","deg","divide","eacute","ecirc","egrave","eth","euml","frac12","frac14","frac34","gt","iacute","icirc","iexcl","igrave","iquest","iuml","laquo","lt","macr","micro","middot","nbsp","not","ntilde","oacute","ocirc","ograve","ordf","ordm","oslash","otilde","ouml","para","plusmn","pound","quot","raquo","reg","sect","shy","sup1","sup2","sup3","szlig","thorn","times","uacute","ucirc","ugrave","uml","uuml","yacute","yen","yuml"];var wn={nbsp:"\xA0",iexcl:"\xA1",cent:"\xA2",pound:"\xA3",curren:"\xA4",yen:"\xA5",brvbar:"\xA6",sect:"\xA7",uml:"\xA8",copy:"\xA9",ordf:"\xAA",laquo:"\xAB",not:"\xAC",shy:"\xAD",reg:"\xAE",macr:"\xAF",deg:"\xB0",plusmn:"\xB1",sup2:"\xB2",sup3:"\xB3",acute:"\xB4",micro:"\xB5",para:"\xB6",middot:"\xB7",cedil:"\xB8",sup1:"\xB9",ordm:"\xBA",raquo:"\xBB",frac14:"\xBC",frac12:"\xBD",frac34:"\xBE",iquest:"\xBF",Agrave:"\xC0",Aacute:"\xC1",Acirc:"\xC2",Atilde:"\xC3",Auml:"\xC4",Aring:"\xC5",AElig:"\xC6",Ccedil:"\xC7",Egrave:"\xC8",Eacute:"\xC9",Ecirc:"\xCA",Euml:"\xCB",Igrave:"\xCC",Iacute:"\xCD",Icirc:"\xCE",Iuml:"\xCF",ETH:"\xD0",Ntilde:"\xD1",Ograve:"\xD2",Oacute:"\xD3",Ocirc:"\xD4",Otilde:"\xD5",Ouml:"\xD6",times:"\xD7",Oslash:"\xD8",Ugrave:"\xD9",Uacute:"\xDA",Ucirc:"\xDB",Uuml:"\xDC",Yacute:"\xDD",THORN:"\xDE",szlig:"\xDF",agrave:"\xE0",aacute:"\xE1",acirc:"\xE2",atilde:"\xE3",auml:"\xE4",aring:"\xE5",aelig:"\xE6",ccedil:"\xE7",egrave:"\xE8",eacute:"\xE9",ecirc:"\xEA",euml:"\xEB",igrave:"\xEC",iacute:"\xED",icirc:"\xEE",iuml:"\xEF",eth:"\xF0",ntilde:"\xF1",ograve:"\xF2",oacute:"\xF3",ocirc:"\xF4",otilde:"\xF5",ouml:"\xF6",divide:"\xF7",oslash:"\xF8",ugrave:"\xF9",uacute:"\xFA",ucirc:"\xFB",uuml:"\xFC",yacute:"\xFD",thorn:"\xFE",yuml:"\xFF",fnof:"\u0192",Alpha:"\u0391",Beta:"\u0392",Gamma:"\u0393",Delta:"\u0394",Epsilon:"\u0395",Zeta:"\u0396",Eta:"\u0397",Theta:"\u0398",Iota:"\u0399",Kappa:"\u039A",Lambda:"\u039B",Mu:"\u039C",Nu:"\u039D",Xi:"\u039E",Omicron:"\u039F",Pi:"\u03A0",Rho:"\u03A1",Sigma:"\u03A3",Tau:"\u03A4",Upsilon:"\u03A5",Phi:"\u03A6",Chi:"\u03A7",Psi:"\u03A8",Omega:"\u03A9",alpha:"\u03B1",beta:"\u03B2",gamma:"\u03B3",delta:"\u03B4",epsilon:"\u03B5",zeta:"\u03B6",eta:"\u03B7",theta:"\u03B8",iota:"\u03B9",kappa:"\u03BA",lambda:"\u03BB",mu:"\u03BC",nu:"\u03BD",xi:"\u03BE",omicron:"\u03BF",pi:"\u03C0",rho:"\u03C1",sigmaf:"\u03C2",sigma:"\u03C3",tau:"\u03C4",upsilon:"\u03C5",phi:"\u03C6",chi:"\u03C7",psi:"\u03C8",omega:"\u03C9",thetasym:"\u03D1",upsih:"\u03D2",piv:"\u03D6",bull:"\u2022",hellip:"\u2026",prime:"\u2032",Prime:"\u2033",oline:"\u203E",frasl:"\u2044",weierp:"\u2118",image:"\u2111",real:"\u211C",trade:"\u2122",alefsym:"\u2135",larr:"\u2190",uarr:"\u2191",rarr:"\u2192",darr:"\u2193",harr:"\u2194",crarr:"\u21B5",lArr:"\u21D0",uArr:"\u21D1",rArr:"\u21D2",dArr:"\u21D3",hArr:"\u21D4",forall:"\u2200",part:"\u2202",exist:"\u2203",empty:"\u2205",nabla:"\u2207",isin:"\u2208",notin:"\u2209",ni:"\u220B",prod:"\u220F",sum:"\u2211",minus:"\u2212",lowast:"\u2217",radic:"\u221A",prop:"\u221D",infin:"\u221E",ang:"\u2220",and:"\u2227",or:"\u2228",cap:"\u2229",cup:"\u222A",int:"\u222B",there4:"\u2234",sim:"\u223C",cong:"\u2245",asymp:"\u2248",ne:"\u2260",equiv:"\u2261",le:"\u2264",ge:"\u2265",sub:"\u2282",sup:"\u2283",nsub:"\u2284",sube:"\u2286",supe:"\u2287",oplus:"\u2295",otimes:"\u2297",perp:"\u22A5",sdot:"\u22C5",lceil:"\u2308",rceil:"\u2309",lfloor:"\u230A",rfloor:"\u230B",lang:"\u2329",rang:"\u232A",loz:"\u25CA",spades:"\u2660",clubs:"\u2663",hearts:"\u2665",diams:"\u2666",quot:'"',amp:"&",lt:"<",gt:">",OElig:"\u0152",oelig:"\u0153",Scaron:"\u0160",scaron:"\u0161",Yuml:"\u0178",circ:"\u02C6",tilde:"\u02DC",ensp:"\u2002",emsp:"\u2003",thinsp:"\u2009",zwnj:"\u200C",zwj:"\u200D",lrm:"\u200E",rlm:"\u200F",ndash:"\u2013",mdash:"\u2014",lsquo:"\u2018",rsquo:"\u2019",sbquo:"\u201A",ldquo:"\u201C",rdquo:"\u201D",bdquo:"\u201E",dagger:"\u2020",Dagger:"\u2021",permil:"\u2030",lsaquo:"\u2039",rsaquo:"\u203A",euro:"\u20AC"};var Go=["cent","copy","divide","gt","lt","not","para","times"];var Xo={}.hasOwnProperty,Yr={},vn;for(vn in wn)Xo.call(wn,vn)&&(Yr[wn[vn]]=vn);var cu=/[^\dA-Za-z]/;function Do(e,n,t,r){let i=String.fromCharCode(e);if(Xo.call(Yr,i)){let o=Yr[i],a="&"+o;return t&&Wo.includes(o)&&!Go.includes(o)&&(!r||n&&n!==61&&cu.test(String.fromCharCode(n)))?a:a+";"}return""}function Oo(e,n,t){let r=No(e,n,t.omitOptionalSemicolons),i;if((t.useNamedReferences||t.useShortestReferences)&&(i=Do(e,n,t.omitOptionalSemicolons,t.attribute)),(t.useShortestReferences||!i)&&t.useShortestReferences){let o=Bo(e,n,t.omitOptionalSemicolons);o.length<r.length&&(r=o)}return i&&(!t.useShortestReferences||i.length<r.length)?i:r}function Ve(e,n){return Vo(e,Object.assign({format:Oo},n))}var pu=/^>|^->|<!--|-->|--!>|<!-$/g,hu=[">"],du=["<",">"];function _o(e,n,t,r){return r.settings.bogusComments?"<?"+Ve(e.value,Object.assign({},r.settings.characterReferences,{subset:hu}))+">":"<!--"+e.value.replace(pu,i)+"-->";function i(o){return Ve(o,Object.assign({},r.settings.characterReferences,{subset:du}))}}function Ho(e,n,t,r){return"<!"+(r.settings.upperDoctype?"DOCTYPE":"doctype")+(r.settings.tightDoctype?"":" ")+"html>"}function jr(e,n){let t=String(e);if(typeof n!="string")throw new TypeError("Expected character");let r=0,i=t.indexOf(n);for(;i!==-1;)r++,i=t.indexOf(n,i+n.length);return r}function Uo(e,n){let t=n||{};return(e[e.length-1]===""?[...e,""]:e).join((t.padRight?" ":"")+","+(t.padLeft===!1?"":" ")).trim()}var ee=Ko(1),Jr=Ko(-1),fu=[];function Ko(e){return n;function n(t,r,i){let o=t?t.children:fu,a=(r||0)+e,s=o[a];if(!i)for(;s&&xe(s);)a+=e,s=o[a];return s}}var mu={}.hasOwnProperty;function kn(e){return n;function n(t,r,i){return mu.call(e,t.tagName)&&e[t.tagName](t,r,i)}}var Zt=kn({body:yu,caption:Qr,colgroup:Qr,dd:vu,dt:wu,head:Qr,html:gu,li:bu,optgroup:ku,option:Su,p:xu,rp:Yo,rt:Yo,tbody:Eu,td:jo,tfoot:Iu,th:jo,thead:Cu,tr:Tu});function Qr(e,n,t){let r=ee(t,n,!0);return!r||r.type!=="comment"&&!(r.type==="text"&&xe(r.value.charAt(0)))}function gu(e,n,t){let r=ee(t,n);return!r||r.type!=="comment"}function yu(e,n,t){let r=ee(t,n);return!r||r.type!=="comment"}function xu(e,n,t){let r=ee(t,n);return r?r.type==="element"&&(r.tagName==="address"||r.tagName==="article"||r.tagName==="aside"||r.tagName==="blockquote"||r.tagName==="details"||r.tagName==="div"||r.tagName==="dl"||r.tagName==="fieldset"||r.tagName==="figcaption"||r.tagName==="figure"||r.tagName==="footer"||r.tagName==="form"||r.tagName==="h1"||r.tagName==="h2"||r.tagName==="h3"||r.tagName==="h4"||r.tagName==="h5"||r.tagName==="h6"||r.tagName==="header"||r.tagName==="hgroup"||r.tagName==="hr"||r.tagName==="main"||r.tagName==="menu"||r.tagName==="nav"||r.tagName==="ol"||r.tagName==="p"||r.tagName==="pre"||r.tagName==="section"||r.tagName==="table"||r.tagName==="ul"):!t||!(t.type==="element"&&(t.tagName==="a"||t.tagName==="audio"||t.tagName==="del"||t.tagName==="ins"||t.tagName==="map"||t.tagName==="noscript"||t.tagName==="video"))}function bu(e,n,t){let r=ee(t,n);return!r||r.type==="element"&&r.tagName==="li"}function wu(e,n,t){let r=ee(t,n);return!!(r&&r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd"))}function vu(e,n,t){let r=ee(t,n);return!r||r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd")}function Yo(e,n,t){let r=ee(t,n);return!r||r.type==="element"&&(r.tagName==="rp"||r.tagName==="rt")}function ku(e,n,t){let r=ee(t,n);return!r||r.type==="element"&&r.tagName==="optgroup"}function Su(e,n,t){let r=ee(t,n);return!r||r.type==="element"&&(r.tagName==="option"||r.tagName==="optgroup")}function Cu(e,n,t){let r=ee(t,n);return!!(r&&r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot"))}function Eu(e,n,t){let r=ee(t,n);return!r||r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot")}function Iu(e,n,t){return!ee(t,n)}function Tu(e,n,t){let r=ee(t,n);return!r||r.type==="element"&&r.tagName==="tr"}function jo(e,n,t){let r=ee(t,n);return!r||r.type==="element"&&(r.tagName==="td"||r.tagName==="th")}var Jo=kn({body:Mu,colgroup:Fu,head:Lu,html:Au,tbody:Ru});function Au(e){let n=ee(e,-1);return!n||n.type!=="comment"}function Lu(e){let n=e.children,t=[],r=-1;for(;++r<n.length;){let i=n[r];if(i.type==="element"&&(i.tagName==="title"||i.tagName==="base")){if(t.includes(i.tagName))return!1;t.push(i.tagName)}}return n.length>0}function Mu(e){let n=ee(e,-1,!0);return!n||n.type!=="comment"&&!(n.type==="text"&&xe(n.value.charAt(0)))&&!(n.type==="element"&&(n.tagName==="meta"||n.tagName==="link"||n.tagName==="script"||n.tagName==="style"||n.tagName==="template"))}function Fu(e,n,t){let r=Jr(t,n),i=ee(e,-1,!0);return t&&r&&r.type==="element"&&r.tagName==="colgroup"&&Zt(r,t.children.indexOf(r),t)?!1:!!(i&&i.type==="element"&&i.tagName==="col")}function Ru(e,n,t){let r=Jr(t,n),i=ee(e,-1);return t&&r&&r.type==="element"&&(r.tagName==="thead"||r.tagName==="tbody")&&Zt(r,t.children.indexOf(r),t)?!1:!!(i&&i.type==="element"&&i.tagName==="tr")}var Sn={name:[[`
|
|
171
171
|
\f\r &/=>`.split(""),`
|
|
172
172
|
\f\r "&'/=>\``.split("")],[`\0
|
|
173
173
|
\f\r "&'/<=>`.split(""),`\0
|
|
@@ -175,19 +175,19 @@ You have access to a database of knowledge base items. These include "info" type
|
|
|
175
175
|
\f\r &>`.split(""),`\0
|
|
176
176
|
\f\r "&'<=>\``.split("")],[`\0
|
|
177
177
|
\f\r "&'<=>\``.split(""),`\0
|
|
178
|
-
\f\r "&'<=>\``.split("")]],single:[["&'".split(""),"\"&'`".split("")],["\0&'".split(""),"\0\"&'`".split("")]],double:[['"&'.split(""),"\"&'`".split("")],['\0"&'.split(""),"\0\"&'`".split("")]]};function Qo(e,n,t,r){let i=r.schema,o=i.space==="svg"?!1:r.settings.omitOptionalTags,a=i.space==="svg"?r.settings.closeEmptyElements:r.settings.voids.includes(e.tagName.toLowerCase()),s=[],l;i.space==="html"&&e.tagName==="svg"&&(r.schema=bn);let u=zu(r,e.properties),c=r.all(i.space==="html"&&e.tagName==="template"?e.content:e);return r.schema=i,c&&(a=!1),(u||!o||!Jo(e,n,t))&&(s.push("<",e.tagName,u?" "+u:""),a&&(i.space==="svg"||r.settings.closeSelfClosing)&&(l=u.charAt(u.length-1),(!r.settings.tightSelfClosing||l==="/"||l&&l!=='"'&&l!=="'")&&s.push(" "),s.push("/")),s.push(">")),s.push(c),!a&&(!o||!Zt(e,n,t))&&s.push("</"+e.tagName+">"),s.join("")}function zu(e,n){let t=[],r=-1,i;if(n){for(i in n)if(n[i]!==null&&n[i]!==void 0){let o=Zu(e,i,n[i]);o&&t.push(o)}}for(;++r<t.length;){let o=e.settings.tightAttributes?t[r].charAt(t[r].length-1):void 0;r!==t.length-1&&o!=='"'&&o!=="'"&&(t[r]+=" ")}return t.join("")}function Zu(e,n,t){let r=Kr(e.schema,n),i=e.settings.allowParseErrors&&e.schema.space==="html"?0:1,o=e.settings.allowDangerousCharacters?0:1,a=e.quote,s;if(r.overloadedBoolean&&(t===r.attribute||t==="")?t=!0:(r.boolean||r.overloadedBoolean&&typeof t!="string")&&(t=!!t),t==null||t===!1||typeof t=="number"&&Number.isNaN(t))return"";let l=Ne(r.attribute,Object.assign({},e.settings.characterReferences,{subset:Sn.name[i][o]}));return t===!0||(t=Array.isArray(t)?(r.commaSeparated?Uo:go)(t,{padLeft:!e.settings.tightCommaSeparatedLists}):String(t),e.settings.collapseEmptyAttributes&&!t)?l:(e.settings.preferUnquoted&&(s=Ne(t,Object.assign({},e.settings.characterReferences,{attribute:!0,subset:Sn.unquoted[i][o]}))),s!==t&&(e.settings.quoteSmart&&jr(t,a)>jr(t,e.alternative)&&(a=e.alternative),s=a+Ne(t,Object.assign({},e.settings.characterReferences,{subset:(a==="'"?Sn.single:Sn.double)[i][o],attribute:!0}))+a),l+(s&&"="+s))}var Pu=["<","&"];function Cn(e,n,t,r){return t&&t.type==="element"&&(t.tagName==="script"||t.tagName==="style")?e.value:Ne(e.value,Object.assign({},r.settings.characterReferences,{subset:Pu}))}function qo(e,n,t,r){return r.settings.allowDangerousHtml?e.value:Cn(e,n,t,r)}function $o(e,n,t,r){return r.all(e)}var ea=Zo("type",{invalid:Nu,unknown:Vu,handlers:{comment:_o,doctype:Ho,element:Qo,raw:qo,root:$o,text:Cn}});function Nu(e){throw new Error("Expected node, not `"+e+"`")}function Vu(e){let n=e;throw new Error("Cannot compile unknown node `"+n.type+"`")}var Bu={},Wu={},Gu=[];function qr(e,n){let t=n||Bu,r=t.quote||'"',i=r==='"'?"'":'"';if(r!=='"'&&r!=="'")throw new Error("Invalid quote `"+r+"`, expected `'` or `\"`");return{one:Xu,all:Du,settings:{omitOptionalTags:t.omitOptionalTags||!1,allowParseErrors:t.allowParseErrors||!1,allowDangerousCharacters:t.allowDangerousCharacters||!1,quoteSmart:t.quoteSmart||!1,preferUnquoted:t.preferUnquoted||!1,tightAttributes:t.tightAttributes||!1,upperDoctype:t.upperDoctype||!1,tightDoctype:t.tightDoctype||!1,bogusComments:t.bogusComments||!1,tightCommaSeparatedLists:t.tightCommaSeparatedLists||!1,tightSelfClosing:t.tightSelfClosing||!1,collapseEmptyAttributes:t.collapseEmptyAttributes||!1,allowDangerousHtml:t.allowDangerousHtml||!1,voids:t.voids||To,characterReferences:t.characterReferences||Wu,closeSelfClosing:t.closeSelfClosing||!1,closeEmptyElements:t.closeEmptyElements||!1},schema:t.space==="svg"?bn:Ro,quote:r,alternative:i}.one(Array.isArray(e)?{type:"root",children:e}:e,void 0,void 0)}function Xu(e,n,t){return ea(e,n,t,this)}function Du(e){let n=[],t=e&&e.children||Gu,r=-1;for(;++r<t.length;)n[r]=this.one(t[r],r,e);return n.join("")}function En(e){let n=this,t={...n.data("settings"),...e};n.compiler=r;function r(i){return qr(i,t)}}var Ou={};function $r(e,n){let t=n||Ou,r=typeof t.includeImageAlt=="boolean"?t.includeImageAlt:!0,i=typeof t.includeHtml=="boolean"?t.includeHtml:!0;return na(e,r,i)}function na(e,n,t){if(_u(e)){if("value"in e)return e.type==="html"&&!t?"":e.value;if(n&&"alt"in e&&e.alt)return e.alt;if("children"in e)return ta(e.children,n,t)}return Array.isArray(e)?ta(e,n,t):""}function ta(e,n,t){let r=[],i=-1;for(;++i<e.length;)r[i]=na(e[i],n,t);return r.join("")}function _u(e){return!!(e&&typeof e=="object")}var ra=document.createElement("i");function ct(e){let n="&"+e+";";ra.innerHTML=n;let t=ra.textContent;return t.charCodeAt(t.length-1)===59&&e!=="semi"||t===n?!1:t}function ce(e,n,t,r){let i=e.length,o=0,a;if(n<0?n=-n>i?0:i+n:n=n>i?i:n,t=t>0?t:0,r.length<1e4)a=Array.from(r),a.unshift(n,t),e.splice(...a);else for(t&&e.splice(n,t);o<r.length;)a=r.slice(o,o+1e4),a.unshift(n,0),e.splice(...a),o+=1e4,n+=1e4}function he(e,n){return e.length>0?(ce(e,e.length,0,n),e):n}var ia={}.hasOwnProperty;function oa(e){let n={},t=-1;for(;++t<e.length;)Hu(n,e[t]);return n}function Hu(e,n){let t;for(t in n){let i=(ia.call(e,t)?e[t]:void 0)||(e[t]={}),o=n[t],a;if(o)for(a in o){ia.call(i,a)||(i[a]=[]);let s=o[a];Uu(i[a],Array.isArray(s)?s:s?[s]:[])}}}function Uu(e,n){let t=-1,r=[];for(;++t<n.length;)(n[t].add==="after"?e:r).push(n[t]);ce(e,0,0,r)}function In(e,n){let t=Number.parseInt(e,n);return t<9||t===11||t>13&&t<32||t>126&&t<160||t>55295&&t<57344||t>64975&&t<65008||(t&65535)===65535||(t&65535)===65534||t>1114111?"\uFFFD":String.fromCodePoint(t)}function Ve(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}var be=Ge(/[A-Za-z]/),ie=Ge(/[\dA-Za-z]/),aa=Ge(/[#-'*+\--9=?A-Z^-~]/);function Pt(e){return e!==null&&(e<32||e===127)}var Nt=Ge(/\d/),sa=Ge(/[\dA-Fa-f]/),la=Ge(/[!-/:-@[-`{-~]/);function T(e){return e!==null&&e<-2}function te(e){return e!==null&&(e<0||e===32)}function B(e){return e===-2||e===-1||e===32}var ua=Ge(/\p{P}|\p{S}/u),ca=Ge(/\s/);function Ge(e){return n;function n(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function ke(e){let n=[],t=-1,r=0,i=0;for(;++t<e.length;){let o=e.charCodeAt(t),a="";if(o===37&&ie(e.charCodeAt(t+1))&&ie(e.charCodeAt(t+2)))i=2;else if(o<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(o))||(a=String.fromCharCode(o));else if(o>55295&&o<57344){let s=e.charCodeAt(t+1);o<56320&&s>56319&&s<57344?(a=String.fromCharCode(o,s),i=1):a="\uFFFD"}else a=String.fromCharCode(o);a&&(n.push(e.slice(r,t),encodeURIComponent(a)),r=t+i+1,a=""),i&&(t+=i,i=0)}return n.join("")+e.slice(r)}function G(e,n,t,r){let i=r?r-1:Number.POSITIVE_INFINITY,o=0;return a;function a(l){return B(l)?(e.enter(t),s(l)):n(l)}function s(l){return B(l)&&o++<i?(e.consume(l),s):(e.exit(t),n(l))}}var pa={tokenize:Ku};function Ku(e){let n=e.attempt(this.parser.constructs.contentInitial,r,i),t;return n;function r(s){if(s===null){e.consume(s);return}return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),G(e,n,"linePrefix")}function i(s){return e.enter("paragraph"),o(s)}function o(s){let l=e.enter("chunkText",{contentType:"text",previous:t});return t&&(t.next=l),t=l,a(s)}function a(s){if(s===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(s);return}return T(s)?(e.consume(s),e.exit("chunkText"),o):(e.consume(s),a)}}var da={tokenize:Yu},ha={tokenize:ju};function Yu(e){let n=this,t=[],r=0,i,o,a;return s;function s(v){if(r<t.length){let z=t[r];return n.containerState=z[1],e.attempt(z[0].continuation,l,u)(v)}return u(v)}function l(v){if(r++,n.containerState._closeFlow){n.containerState._closeFlow=void 0,i&&I();let z=n.events.length,Z=z,x;for(;Z--;)if(n.events[Z][0]==="exit"&&n.events[Z][1].type==="chunkFlow"){x=n.events[Z][1].end;break}y(r);let L=z;for(;L<n.events.length;)n.events[L][1].end=Object.assign({},x),L++;return ce(n.events,Z+1,0,n.events.slice(z)),n.events.length=L,u(v)}return s(v)}function u(v){if(r===t.length){if(!i)return d(v);if(i.currentConstruct&&i.currentConstruct.concrete)return g(v);n.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return n.containerState={},e.check(ha,c,h)(v)}function c(v){return i&&I(),y(r),d(v)}function h(v){return n.parser.lazy[n.now().line]=r!==t.length,a=n.now().offset,g(v)}function d(v){return n.containerState={},e.attempt(ha,p,g)(v)}function p(v){return r++,t.push([n.currentConstruct,n.containerState]),d(v)}function g(v){if(v===null){i&&I(),y(0),e.consume(v);return}return i=i||n.parser.flow(n.now()),e.enter("chunkFlow",{contentType:"flow",previous:o,_tokenizer:i}),w(v)}function w(v){if(v===null){k(e.exit("chunkFlow"),!0),y(0),e.consume(v);return}return T(v)?(e.consume(v),k(e.exit("chunkFlow")),r=0,n.interrupt=void 0,s):(e.consume(v),w)}function k(v,z){let Z=n.sliceStream(v);if(z&&Z.push(null),v.previous=o,o&&(o.next=v),o=v,i.defineSkip(v.start),i.write(Z),n.parser.lazy[v.start.line]){let x=i.events.length;for(;x--;)if(i.events[x][1].start.offset<a&&(!i.events[x][1].end||i.events[x][1].end.offset>a))return;let L=n.events.length,R=L,M,P;for(;R--;)if(n.events[R][0]==="exit"&&n.events[R][1].type==="chunkFlow"){if(M){P=n.events[R][1].end;break}M=!0}for(y(r),x=L;x<n.events.length;)n.events[x][1].end=Object.assign({},P),x++;ce(n.events,R+1,0,n.events.slice(L)),n.events.length=x}}function y(v){let z=t.length;for(;z-- >v;){let Z=t[z];n.containerState=Z[1],Z[0].exit.call(n,e)}t.length=v}function I(){i.write([null]),o=void 0,i=void 0,n.containerState._closeFlow=void 0}}function ju(e,n,t){return G(e,e.attempt(this.parser.constructs.document,n,t),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function ei(e){if(e===null||te(e)||ca(e))return 1;if(ua(e))return 2}function pt(e,n,t){let r=[],i=-1;for(;++i<e.length;){let o=e[i].resolveAll;o&&!r.includes(o)&&(n=o(n,t),r.push(o))}return n}var Vt={name:"attention",tokenize:Qu,resolveAll:Ju};function Ju(e,n){let t=-1,r,i,o,a,s,l,u,c;for(;++t<e.length;)if(e[t][0]==="enter"&&e[t][1].type==="attentionSequence"&&e[t][1]._close){for(r=t;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&n.sliceSerialize(e[r][1]).charCodeAt(0)===n.sliceSerialize(e[t][1]).charCodeAt(0)){if((e[r][1]._close||e[t][1]._open)&&(e[t][1].end.offset-e[t][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[t][1].end.offset-e[t][1].start.offset)%3))continue;l=e[r][1].end.offset-e[r][1].start.offset>1&&e[t][1].end.offset-e[t][1].start.offset>1?2:1;let h=Object.assign({},e[r][1].end),d=Object.assign({},e[t][1].start);fa(h,-l),fa(d,l),a={type:l>1?"strongSequence":"emphasisSequence",start:h,end:Object.assign({},e[r][1].end)},s={type:l>1?"strongSequence":"emphasisSequence",start:Object.assign({},e[t][1].start),end:d},o={type:l>1?"strongText":"emphasisText",start:Object.assign({},e[r][1].end),end:Object.assign({},e[t][1].start)},i={type:l>1?"strong":"emphasis",start:Object.assign({},a.start),end:Object.assign({},s.end)},e[r][1].end=Object.assign({},a.start),e[t][1].start=Object.assign({},s.end),u=[],e[r][1].end.offset-e[r][1].start.offset&&(u=he(u,[["enter",e[r][1],n],["exit",e[r][1],n]])),u=he(u,[["enter",i,n],["enter",a,n],["exit",a,n],["enter",o,n]]),u=he(u,pt(n.parser.constructs.insideSpan.null,e.slice(r+1,t),n)),u=he(u,[["exit",o,n],["enter",s,n],["exit",s,n],["exit",i,n]]),e[t][1].end.offset-e[t][1].start.offset?(c=2,u=he(u,[["enter",e[t][1],n],["exit",e[t][1],n]])):c=0,ce(e,r-1,t-r+3,u),t=r+u.length-c-2;break}}for(t=-1;++t<e.length;)e[t][1].type==="attentionSequence"&&(e[t][1].type="data");return e}function Qu(e,n){let t=this.parser.constructs.attentionMarkers.null,r=this.previous,i=ei(r),o;return a;function a(l){return o=l,e.enter("attentionSequence"),s(l)}function s(l){if(l===o)return e.consume(l),s;let u=e.exit("attentionSequence"),c=ei(l),h=!c||c===2&&i||t.includes(l),d=!i||i===2&&c||t.includes(r);return u._open=!!(o===42?h:h&&(i||!d)),u._close=!!(o===42?d:d&&(c||!h)),n(l)}}function fa(e,n){e.column+=n,e.offset+=n,e._bufferIndex+=n}var ti={name:"autolink",tokenize:qu};function qu(e,n,t){let r=0;return i;function i(p){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),o}function o(p){return be(p)?(e.consume(p),a):p===64?t(p):u(p)}function a(p){return p===43||p===45||p===46||ie(p)?(r=1,s(p)):u(p)}function s(p){return p===58?(e.consume(p),r=0,l):(p===43||p===45||p===46||ie(p))&&r++<32?(e.consume(p),s):(r=0,u(p))}function l(p){return p===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),n):p===null||p===32||p===60||Pt(p)?t(p):(e.consume(p),l)}function u(p){return p===64?(e.consume(p),c):aa(p)?(e.consume(p),u):t(p)}function c(p){return ie(p)?h(p):t(p)}function h(p){return p===46?(e.consume(p),r=0,c):p===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),n):d(p)}function d(p){if((p===45||ie(p))&&r++<63){let g=p===45?d:h;return e.consume(p),g}return t(p)}}var Xe={tokenize:$u,partial:!0};function $u(e,n,t){return r;function r(o){return B(o)?G(e,i,"linePrefix")(o):i(o)}function i(o){return o===null||T(o)?n(o):t(o)}}var Tn={name:"blockQuote",tokenize:ec,continuation:{tokenize:tc},exit:nc};function ec(e,n,t){let r=this;return i;function i(a){if(a===62){let s=r.containerState;return s.open||(e.enter("blockQuote",{_container:!0}),s.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(a),e.exit("blockQuoteMarker"),o}return t(a)}function o(a){return B(a)?(e.enter("blockQuotePrefixWhitespace"),e.consume(a),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),n):(e.exit("blockQuotePrefix"),n(a))}}function tc(e,n,t){let r=this;return i;function i(a){return B(a)?G(e,o,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a):o(a)}function o(a){return e.attempt(Tn,n,t)(a)}}function nc(e){e.exit("blockQuote")}var An={name:"characterEscape",tokenize:rc};function rc(e,n,t){return r;function r(o){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(o),e.exit("escapeMarker"),i}function i(o){return la(o)?(e.enter("characterEscapeValue"),e.consume(o),e.exit("characterEscapeValue"),e.exit("characterEscape"),n):t(o)}}var Ln={name:"characterReference",tokenize:ic};function ic(e,n,t){let r=this,i=0,o,a;return s;function s(h){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(h),e.exit("characterReferenceMarker"),l}function l(h){return h===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(h),e.exit("characterReferenceMarkerNumeric"),u):(e.enter("characterReferenceValue"),o=31,a=ie,c(h))}function u(h){return h===88||h===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(h),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),o=6,a=sa,c):(e.enter("characterReferenceValue"),o=7,a=Nt,c(h))}function c(h){if(h===59&&i){let d=e.exit("characterReferenceValue");return a===ie&&!ct(r.sliceSerialize(d))?t(h):(e.enter("characterReferenceMarker"),e.consume(h),e.exit("characterReferenceMarker"),e.exit("characterReference"),n)}return a(h)&&i++<o?(e.consume(h),c):t(h)}}var ma={tokenize:ac,partial:!0},Fn={name:"codeFenced",tokenize:oc,concrete:!0};function oc(e,n,t){let r=this,i={tokenize:Z,partial:!0},o=0,a=0,s;return l;function l(x){return u(x)}function u(x){let L=r.events[r.events.length-1];return o=L&&L[1].type==="linePrefix"?L[2].sliceSerialize(L[1],!0).length:0,s=x,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),c(x)}function c(x){return x===s?(a++,e.consume(x),c):a<3?t(x):(e.exit("codeFencedFenceSequence"),B(x)?G(e,h,"whitespace")(x):h(x))}function h(x){return x===null||T(x)?(e.exit("codeFencedFence"),r.interrupt?n(x):e.check(ma,w,z)(x)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),d(x))}function d(x){return x===null||T(x)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),h(x)):B(x)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),G(e,p,"whitespace")(x)):x===96&&x===s?t(x):(e.consume(x),d)}function p(x){return x===null||T(x)?h(x):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),g(x))}function g(x){return x===null||T(x)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),h(x)):x===96&&x===s?t(x):(e.consume(x),g)}function w(x){return e.attempt(i,z,k)(x)}function k(x){return e.enter("lineEnding"),e.consume(x),e.exit("lineEnding"),y}function y(x){return o>0&&B(x)?G(e,I,"linePrefix",o+1)(x):I(x)}function I(x){return x===null||T(x)?e.check(ma,w,z)(x):(e.enter("codeFlowValue"),v(x))}function v(x){return x===null||T(x)?(e.exit("codeFlowValue"),I(x)):(e.consume(x),v)}function z(x){return e.exit("codeFenced"),n(x)}function Z(x,L,R){let M=0;return P;function P(N){return x.enter("lineEnding"),x.consume(N),x.exit("lineEnding"),D}function D(N){return x.enter("codeFencedFence"),B(N)?G(x,F,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(N):F(N)}function F(N){return N===s?(x.enter("codeFencedFenceSequence"),E(N)):R(N)}function E(N){return N===s?(M++,x.consume(N),E):M>=a?(x.exit("codeFencedFenceSequence"),B(N)?G(x,A,"whitespace")(N):A(N)):R(N)}function A(N){return N===null||T(N)?(x.exit("codeFencedFence"),L(N)):R(N)}}}function ac(e,n,t){let r=this;return i;function i(a){return a===null?t(a):(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),o)}function o(a){return r.parser.lazy[r.now().line]?t(a):n(a)}}var Bt={name:"codeIndented",tokenize:lc},sc={tokenize:uc,partial:!0};function lc(e,n,t){let r=this;return i;function i(u){return e.enter("codeIndented"),G(e,o,"linePrefix",5)(u)}function o(u){let c=r.events[r.events.length-1];return c&&c[1].type==="linePrefix"&&c[2].sliceSerialize(c[1],!0).length>=4?a(u):t(u)}function a(u){return u===null?l(u):T(u)?e.attempt(sc,a,l)(u):(e.enter("codeFlowValue"),s(u))}function s(u){return u===null||T(u)?(e.exit("codeFlowValue"),a(u)):(e.consume(u),s)}function l(u){return e.exit("codeIndented"),n(u)}}function uc(e,n,t){let r=this;return i;function i(a){return r.parser.lazy[r.now().line]?t(a):T(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),i):G(e,o,"linePrefix",5)(a)}function o(a){let s=r.events[r.events.length-1];return s&&s[1].type==="linePrefix"&&s[2].sliceSerialize(s[1],!0).length>=4?n(a):T(a)?i(a):t(a)}}var ni={name:"codeText",tokenize:hc,resolve:cc,previous:pc};function cc(e){let n=e.length-4,t=3,r,i;if((e[t][1].type==="lineEnding"||e[t][1].type==="space")&&(e[n][1].type==="lineEnding"||e[n][1].type==="space")){for(r=t;++r<n;)if(e[r][1].type==="codeTextData"){e[t][1].type="codeTextPadding",e[n][1].type="codeTextPadding",t+=2,n-=2;break}}for(r=t-1,n++;++r<=n;)i===void 0?r!==n&&e[r][1].type!=="lineEnding"&&(i=r):(r===n||e[r][1].type==="lineEnding")&&(e[i][1].type="codeTextData",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),n-=r-i-2,r=i+2),i=void 0);return e}function pc(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function hc(e,n,t){let r=this,i=0,o,a;return s;function s(d){return e.enter("codeText"),e.enter("codeTextSequence"),l(d)}function l(d){return d===96?(e.consume(d),i++,l):(e.exit("codeTextSequence"),u(d))}function u(d){return d===null?t(d):d===32?(e.enter("space"),e.consume(d),e.exit("space"),u):d===96?(a=e.enter("codeTextSequence"),o=0,h(d)):T(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),u):(e.enter("codeTextData"),c(d))}function c(d){return d===null||d===32||d===96||T(d)?(e.exit("codeTextData"),u(d)):(e.consume(d),c)}function h(d){return d===96?(e.consume(d),o++,h):o===i?(e.exit("codeTextSequence"),e.exit("codeText"),n(d)):(a.type="codeTextData",c(d))}}var Mn=class{constructor(n){this.left=n?[...n]:[],this.right=[]}get(n){if(n<0||n>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+n+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return n<this.left.length?this.left[n]:this.right[this.right.length-n+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(n,t){let r=t??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(n,r):n>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-n+this.left.length).reverse():this.left.slice(n).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(n,t,r){let i=t||0;this.setCursor(Math.trunc(n));let o=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&Wt(this.left,r),o.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(n){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(n)}pushMany(n){this.setCursor(Number.POSITIVE_INFINITY),Wt(this.left,n)}unshift(n){this.setCursor(0),this.right.push(n)}unshiftMany(n){this.setCursor(0),Wt(this.right,n.reverse())}setCursor(n){if(!(n===this.left.length||n>this.left.length&&this.right.length===0||n<0&&this.left.length===0))if(n<this.left.length){let t=this.left.splice(n,Number.POSITIVE_INFINITY);Wt(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-n,Number.POSITIVE_INFINITY);Wt(this.left,t.reverse())}}};function Wt(e,n){let t=0;if(n.length<1e4)e.push(...n);else for(;t<n.length;)e.push(...n.slice(t,t+1e4)),t+=1e4}function Rn(e){let n={},t=-1,r,i,o,a,s,l,u,c=new Mn(e);for(;++t<c.length;){for(;t in n;)t=n[t];if(r=c.get(t),t&&r[1].type==="chunkFlow"&&c.get(t-1)[1].type==="listItemPrefix"&&(l=r[1]._tokenizer.events,o=0,o<l.length&&l[o][1].type==="lineEndingBlank"&&(o+=2),o<l.length&&l[o][1].type==="content"))for(;++o<l.length&&l[o][1].type!=="content";)l[o][1].type==="chunkText"&&(l[o][1]._isInFirstContentOfListItem=!0,o++);if(r[0]==="enter")r[1].contentType&&(Object.assign(n,dc(c,t)),t=n[t],u=!0);else if(r[1]._container){for(o=t,i=void 0;o--&&(a=c.get(o),a[1].type==="lineEnding"||a[1].type==="lineEndingBlank");)a[0]==="enter"&&(i&&(c.get(i)[1].type="lineEndingBlank"),a[1].type="lineEnding",i=o);i&&(r[1].end=Object.assign({},c.get(i)[1].start),s=c.slice(i,t),s.unshift(r),c.splice(i,t-i+1,s))}}return ce(e,0,Number.POSITIVE_INFINITY,c.slice(0)),!u}function dc(e,n){let t=e.get(n)[1],r=e.get(n)[2],i=n-1,o=[],a=t._tokenizer||r.parser[t.contentType](t.start),s=a.events,l=[],u={},c,h,d=-1,p=t,g=0,w=0,k=[w];for(;p;){for(;e.get(++i)[1]!==p;);o.push(i),p._tokenizer||(c=r.sliceStream(p),p.next||c.push(null),h&&a.defineSkip(p.start),p._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=!0),a.write(c),p._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=void 0)),h=p,p=p.next}for(p=t;++d<s.length;)s[d][0]==="exit"&&s[d-1][0]==="enter"&&s[d][1].type===s[d-1][1].type&&s[d][1].start.line!==s[d][1].end.line&&(w=d+1,k.push(w),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(a.events=[],p?(p._tokenizer=void 0,p.previous=void 0):k.pop(),d=k.length;d--;){let y=s.slice(k[d],k[d+1]),I=o.pop();l.push([I,I+y.length-1]),e.splice(I,2,y)}for(l.reverse(),d=-1;++d<l.length;)u[g+l[d][0]]=g+l[d][1],g+=l[d][1]-l[d][0]-1;return u}var ri={tokenize:gc,resolve:mc},fc={tokenize:yc,partial:!0};function mc(e){return Rn(e),e}function gc(e,n){let t;return r;function r(s){return e.enter("content"),t=e.enter("chunkContent",{contentType:"content"}),i(s)}function i(s){return s===null?o(s):T(s)?e.check(fc,a,o)(s):(e.consume(s),i)}function o(s){return e.exit("chunkContent"),e.exit("content"),n(s)}function a(s){return e.consume(s),e.exit("chunkContent"),t.next=e.enter("chunkContent",{contentType:"content",previous:t}),t=t.next,i}}function yc(e,n,t){let r=this;return i;function i(a){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),G(e,o,"linePrefix")}function o(a){if(a===null||T(a))return t(a);let s=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&s&&s[1].type==="linePrefix"&&s[2].sliceSerialize(s[1],!0).length>=4?n(a):e.interrupt(r.parser.constructs.flow,t,n)(a)}}function zn(e,n,t,r,i,o,a,s,l){let u=l||Number.POSITIVE_INFINITY,c=0;return h;function h(y){return y===60?(e.enter(r),e.enter(i),e.enter(o),e.consume(y),e.exit(o),d):y===null||y===32||y===41||Pt(y)?t(y):(e.enter(r),e.enter(a),e.enter(s),e.enter("chunkString",{contentType:"string"}),w(y))}function d(y){return y===62?(e.enter(o),e.consume(y),e.exit(o),e.exit(i),e.exit(r),n):(e.enter(s),e.enter("chunkString",{contentType:"string"}),p(y))}function p(y){return y===62?(e.exit("chunkString"),e.exit(s),d(y)):y===null||y===60||T(y)?t(y):(e.consume(y),y===92?g:p)}function g(y){return y===60||y===62||y===92?(e.consume(y),p):p(y)}function w(y){return!c&&(y===null||y===41||te(y))?(e.exit("chunkString"),e.exit(s),e.exit(a),e.exit(r),n(y)):c<u&&y===40?(e.consume(y),c++,w):y===41?(e.consume(y),c--,w):y===null||y===32||y===40||Pt(y)?t(y):(e.consume(y),y===92?k:w)}function k(y){return y===40||y===41||y===92?(e.consume(y),w):w(y)}}function Zn(e,n,t,r,i,o){let a=this,s=0,l;return u;function u(p){return e.enter(r),e.enter(i),e.consume(p),e.exit(i),e.enter(o),c}function c(p){return s>999||p===null||p===91||p===93&&!l||p===94&&!s&&"_hiddenFootnoteSupport"in a.parser.constructs?t(p):p===93?(e.exit(o),e.enter(i),e.consume(p),e.exit(i),e.exit(r),n):T(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),c):(e.enter("chunkString",{contentType:"string"}),h(p))}function h(p){return p===null||p===91||p===93||T(p)||s++>999?(e.exit("chunkString"),c(p)):(e.consume(p),l||(l=!B(p)),p===92?d:h)}function d(p){return p===91||p===92||p===93?(e.consume(p),s++,h):h(p)}}function Pn(e,n,t,r,i,o){let a;return s;function s(d){return d===34||d===39||d===40?(e.enter(r),e.enter(i),e.consume(d),e.exit(i),a=d===40?41:d,l):t(d)}function l(d){return d===a?(e.enter(i),e.consume(d),e.exit(i),e.exit(r),n):(e.enter(o),u(d))}function u(d){return d===a?(e.exit(o),l(a)):d===null?t(d):T(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),G(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),c(d))}function c(d){return d===a||d===null||T(d)?(e.exit("chunkString"),u(d)):(e.consume(d),d===92?h:c)}function h(d){return d===a||d===92?(e.consume(d),c):c(d)}}function Qe(e,n){let t;return r;function r(i){return T(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),t=!0,r):B(i)?G(e,r,t?"linePrefix":"lineSuffix")(i):n(i)}}var ii={name:"definition",tokenize:bc},xc={tokenize:wc,partial:!0};function bc(e,n,t){let r=this,i;return o;function o(p){return e.enter("definition"),a(p)}function a(p){return Zn.call(r,e,s,t,"definitionLabel","definitionLabelMarker","definitionLabelString")(p)}function s(p){return i=Ve(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),p===58?(e.enter("definitionMarker"),e.consume(p),e.exit("definitionMarker"),l):t(p)}function l(p){return te(p)?Qe(e,u)(p):u(p)}function u(p){return zn(e,c,t,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(p)}function c(p){return e.attempt(xc,h,h)(p)}function h(p){return B(p)?G(e,d,"whitespace")(p):d(p)}function d(p){return p===null||T(p)?(e.exit("definition"),r.parser.defined.push(i),n(p)):t(p)}}function wc(e,n,t){return r;function r(s){return te(s)?Qe(e,i)(s):t(s)}function i(s){return Pn(e,o,t,"definitionTitle","definitionTitleMarker","definitionTitleString")(s)}function o(s){return B(s)?G(e,a,"whitespace")(s):a(s)}function a(s){return s===null||T(s)?n(s):t(s)}}var oi={name:"hardBreakEscape",tokenize:vc};function vc(e,n,t){return r;function r(o){return e.enter("hardBreakEscape"),e.consume(o),i}function i(o){return T(o)?(e.exit("hardBreakEscape"),n(o)):t(o)}}var ai={name:"headingAtx",tokenize:Sc,resolve:kc};function kc(e,n){let t=e.length-2,r=3,i,o;return e[r][1].type==="whitespace"&&(r+=2),t-2>r&&e[t][1].type==="whitespace"&&(t-=2),e[t][1].type==="atxHeadingSequence"&&(r===t-1||t-4>r&&e[t-2][1].type==="whitespace")&&(t-=r+1===t?2:4),t>r&&(i={type:"atxHeadingText",start:e[r][1].start,end:e[t][1].end},o={type:"chunkText",start:e[r][1].start,end:e[t][1].end,contentType:"text"},ce(e,r,t-r+1,[["enter",i,n],["enter",o,n],["exit",o,n],["exit",i,n]])),e}function Sc(e,n,t){let r=0;return i;function i(c){return e.enter("atxHeading"),o(c)}function o(c){return e.enter("atxHeadingSequence"),a(c)}function a(c){return c===35&&r++<6?(e.consume(c),a):c===null||te(c)?(e.exit("atxHeadingSequence"),s(c)):t(c)}function s(c){return c===35?(e.enter("atxHeadingSequence"),l(c)):c===null||T(c)?(e.exit("atxHeading"),n(c)):B(c)?G(e,s,"whitespace")(c):(e.enter("atxHeadingText"),u(c))}function l(c){return c===35?(e.consume(c),l):(e.exit("atxHeadingSequence"),s(c))}function u(c){return c===null||c===35||te(c)?(e.exit("atxHeadingText"),s(c)):(e.consume(c),u)}}var ga=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],si=["pre","script","style","textarea"];var li={name:"htmlFlow",tokenize:Tc,resolveTo:Ic,concrete:!0},Cc={tokenize:Lc,partial:!0},Ec={tokenize:Ac,partial:!0};function Ic(e){let n=e.length;for(;n--&&!(e[n][0]==="enter"&&e[n][1].type==="htmlFlow"););return n>1&&e[n-2][1].type==="linePrefix"&&(e[n][1].start=e[n-2][1].start,e[n+1][1].start=e[n-2][1].start,e.splice(n-2,2)),e}function Tc(e,n,t){let r=this,i,o,a,s,l;return u;function u(m){return c(m)}function c(m){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(m),h}function h(m){return m===33?(e.consume(m),d):m===47?(e.consume(m),o=!0,w):m===63?(e.consume(m),i=3,r.interrupt?n:f):be(m)?(e.consume(m),a=String.fromCharCode(m),k):t(m)}function d(m){return m===45?(e.consume(m),i=2,p):m===91?(e.consume(m),i=5,s=0,g):be(m)?(e.consume(m),i=4,r.interrupt?n:f):t(m)}function p(m){return m===45?(e.consume(m),r.interrupt?n:f):t(m)}function g(m){let me="CDATA[";return m===me.charCodeAt(s++)?(e.consume(m),s===me.length?r.interrupt?n:F:g):t(m)}function w(m){return be(m)?(e.consume(m),a=String.fromCharCode(m),k):t(m)}function k(m){if(m===null||m===47||m===62||te(m)){let me=m===47,_e=a.toLowerCase();return!me&&!o&&si.includes(_e)?(i=1,r.interrupt?n(m):F(m)):ga.includes(a.toLowerCase())?(i=6,me?(e.consume(m),y):r.interrupt?n(m):F(m)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?t(m):o?I(m):v(m))}return m===45||ie(m)?(e.consume(m),a+=String.fromCharCode(m),k):t(m)}function y(m){return m===62?(e.consume(m),r.interrupt?n:F):t(m)}function I(m){return B(m)?(e.consume(m),I):P(m)}function v(m){return m===47?(e.consume(m),P):m===58||m===95||be(m)?(e.consume(m),z):B(m)?(e.consume(m),v):P(m)}function z(m){return m===45||m===46||m===58||m===95||ie(m)?(e.consume(m),z):Z(m)}function Z(m){return m===61?(e.consume(m),x):B(m)?(e.consume(m),Z):v(m)}function x(m){return m===null||m===60||m===61||m===62||m===96?t(m):m===34||m===39?(e.consume(m),l=m,L):B(m)?(e.consume(m),x):R(m)}function L(m){return m===l?(e.consume(m),l=null,M):m===null||T(m)?t(m):(e.consume(m),L)}function R(m){return m===null||m===34||m===39||m===47||m===60||m===61||m===62||m===96||te(m)?Z(m):(e.consume(m),R)}function M(m){return m===47||m===62||B(m)?v(m):t(m)}function P(m){return m===62?(e.consume(m),D):t(m)}function D(m){return m===null||T(m)?F(m):B(m)?(e.consume(m),D):t(m)}function F(m){return m===45&&i===2?(e.consume(m),H):m===60&&i===1?(e.consume(m),Y):m===62&&i===4?(e.consume(m),we):m===63&&i===3?(e.consume(m),f):m===93&&i===5?(e.consume(m),ne):T(m)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(Cc,Me,E)(m)):m===null||T(m)?(e.exit("htmlFlowData"),E(m)):(e.consume(m),F)}function E(m){return e.check(Ec,A,Me)(m)}function A(m){return e.enter("lineEnding"),e.consume(m),e.exit("lineEnding"),N}function N(m){return m===null||T(m)?E(m):(e.enter("htmlFlowData"),F(m))}function H(m){return m===45?(e.consume(m),f):F(m)}function Y(m){return m===47?(e.consume(m),a="",re):F(m)}function re(m){if(m===62){let me=a.toLowerCase();return si.includes(me)?(e.consume(m),we):F(m)}return be(m)&&a.length<8?(e.consume(m),a+=String.fromCharCode(m),re):F(m)}function ne(m){return m===93?(e.consume(m),f):F(m)}function f(m){return m===62?(e.consume(m),we):m===45&&i===2?(e.consume(m),f):F(m)}function we(m){return m===null||T(m)?(e.exit("htmlFlowData"),Me(m)):(e.consume(m),we)}function Me(m){return e.exit("htmlFlow"),n(m)}}function Ac(e,n,t){let r=this;return i;function i(a){return T(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),o):t(a)}function o(a){return r.parser.lazy[r.now().line]?t(a):n(a)}}function Lc(e,n,t){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(Xe,n,t)}}var ui={name:"htmlText",tokenize:Fc};function Fc(e,n,t){let r=this,i,o,a;return s;function s(f){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(f),l}function l(f){return f===33?(e.consume(f),u):f===47?(e.consume(f),Z):f===63?(e.consume(f),v):be(f)?(e.consume(f),R):t(f)}function u(f){return f===45?(e.consume(f),c):f===91?(e.consume(f),o=0,g):be(f)?(e.consume(f),I):t(f)}function c(f){return f===45?(e.consume(f),p):t(f)}function h(f){return f===null?t(f):f===45?(e.consume(f),d):T(f)?(a=h,Y(f)):(e.consume(f),h)}function d(f){return f===45?(e.consume(f),p):h(f)}function p(f){return f===62?H(f):f===45?d(f):h(f)}function g(f){let we="CDATA[";return f===we.charCodeAt(o++)?(e.consume(f),o===we.length?w:g):t(f)}function w(f){return f===null?t(f):f===93?(e.consume(f),k):T(f)?(a=w,Y(f)):(e.consume(f),w)}function k(f){return f===93?(e.consume(f),y):w(f)}function y(f){return f===62?H(f):f===93?(e.consume(f),y):w(f)}function I(f){return f===null||f===62?H(f):T(f)?(a=I,Y(f)):(e.consume(f),I)}function v(f){return f===null?t(f):f===63?(e.consume(f),z):T(f)?(a=v,Y(f)):(e.consume(f),v)}function z(f){return f===62?H(f):v(f)}function Z(f){return be(f)?(e.consume(f),x):t(f)}function x(f){return f===45||ie(f)?(e.consume(f),x):L(f)}function L(f){return T(f)?(a=L,Y(f)):B(f)?(e.consume(f),L):H(f)}function R(f){return f===45||ie(f)?(e.consume(f),R):f===47||f===62||te(f)?M(f):t(f)}function M(f){return f===47?(e.consume(f),H):f===58||f===95||be(f)?(e.consume(f),P):T(f)?(a=M,Y(f)):B(f)?(e.consume(f),M):H(f)}function P(f){return f===45||f===46||f===58||f===95||ie(f)?(e.consume(f),P):D(f)}function D(f){return f===61?(e.consume(f),F):T(f)?(a=D,Y(f)):B(f)?(e.consume(f),D):M(f)}function F(f){return f===null||f===60||f===61||f===62||f===96?t(f):f===34||f===39?(e.consume(f),i=f,E):T(f)?(a=F,Y(f)):B(f)?(e.consume(f),F):(e.consume(f),A)}function E(f){return f===i?(e.consume(f),i=void 0,N):f===null?t(f):T(f)?(a=E,Y(f)):(e.consume(f),E)}function A(f){return f===null||f===34||f===39||f===60||f===61||f===96?t(f):f===47||f===62||te(f)?M(f):(e.consume(f),A)}function N(f){return f===47||f===62||te(f)?M(f):t(f)}function H(f){return f===62?(e.consume(f),e.exit("htmlTextData"),e.exit("htmlText"),n):t(f)}function Y(f){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),re}function re(f){return B(f)?G(e,ne,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(f):ne(f)}function ne(f){return e.enter("htmlTextData"),a(f)}}var qe={name:"labelEnd",tokenize:Nc,resolveTo:Pc,resolveAll:Zc},Mc={tokenize:Vc},Rc={tokenize:Bc},zc={tokenize:Wc};function Zc(e){let n=-1;for(;++n<e.length;){let t=e[n][1];(t.type==="labelImage"||t.type==="labelLink"||t.type==="labelEnd")&&(e.splice(n+1,t.type==="labelImage"?4:2),t.type="data",n++)}return e}function Pc(e,n){let t=e.length,r=0,i,o,a,s;for(;t--;)if(i=e[t][1],o){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;e[t][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(a){if(e[t][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(o=t,i.type!=="labelLink")){r=2;break}}else i.type==="labelEnd"&&(a=t);let l={type:e[o][1].type==="labelLink"?"link":"image",start:Object.assign({},e[o][1].start),end:Object.assign({},e[e.length-1][1].end)},u={type:"label",start:Object.assign({},e[o][1].start),end:Object.assign({},e[a][1].end)},c={type:"labelText",start:Object.assign({},e[o+r+2][1].end),end:Object.assign({},e[a-2][1].start)};return s=[["enter",l,n],["enter",u,n]],s=he(s,e.slice(o+1,o+r+3)),s=he(s,[["enter",c,n]]),s=he(s,pt(n.parser.constructs.insideSpan.null,e.slice(o+r+4,a-3),n)),s=he(s,[["exit",c,n],e[a-2],e[a-1],["exit",u,n]]),s=he(s,e.slice(a+1)),s=he(s,[["exit",l,n]]),ce(e,o,e.length,s),e}function Nc(e,n,t){let r=this,i=r.events.length,o,a;for(;i--;)if((r.events[i][1].type==="labelImage"||r.events[i][1].type==="labelLink")&&!r.events[i][1]._balanced){o=r.events[i][1];break}return s;function s(d){return o?o._inactive?h(d):(a=r.parser.defined.includes(Ve(r.sliceSerialize({start:o.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(d),e.exit("labelMarker"),e.exit("labelEnd"),l):t(d)}function l(d){return d===40?e.attempt(Mc,c,a?c:h)(d):d===91?e.attempt(Rc,c,a?u:h)(d):a?c(d):h(d)}function u(d){return e.attempt(zc,c,h)(d)}function c(d){return n(d)}function h(d){return o._balanced=!0,t(d)}}function Vc(e,n,t){return r;function r(h){return e.enter("resource"),e.enter("resourceMarker"),e.consume(h),e.exit("resourceMarker"),i}function i(h){return te(h)?Qe(e,o)(h):o(h)}function o(h){return h===41?c(h):zn(e,a,s,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(h)}function a(h){return te(h)?Qe(e,l)(h):c(h)}function s(h){return t(h)}function l(h){return h===34||h===39||h===40?Pn(e,u,t,"resourceTitle","resourceTitleMarker","resourceTitleString")(h):c(h)}function u(h){return te(h)?Qe(e,c)(h):c(h)}function c(h){return h===41?(e.enter("resourceMarker"),e.consume(h),e.exit("resourceMarker"),e.exit("resource"),n):t(h)}}function Bc(e,n,t){let r=this;return i;function i(s){return Zn.call(r,e,o,a,"reference","referenceMarker","referenceString")(s)}function o(s){return r.parser.defined.includes(Ve(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?n(s):t(s)}function a(s){return t(s)}}function Wc(e,n,t){return r;function r(o){return e.enter("reference"),e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),i}function i(o){return o===93?(e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),e.exit("reference"),n):t(o)}}var ci={name:"labelStartImage",tokenize:Gc,resolveAll:qe.resolveAll};function Gc(e,n,t){let r=this;return i;function i(s){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(s),e.exit("labelImageMarker"),o}function o(s){return s===91?(e.enter("labelMarker"),e.consume(s),e.exit("labelMarker"),e.exit("labelImage"),a):t(s)}function a(s){return s===94&&"_hiddenFootnoteSupport"in r.parser.constructs?t(s):n(s)}}var pi={name:"labelStartLink",tokenize:Xc,resolveAll:qe.resolveAll};function Xc(e,n,t){let r=this;return i;function i(a){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelLink"),o}function o(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?t(a):n(a)}}var Gt={name:"lineEnding",tokenize:Dc};function Dc(e,n){return t;function t(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),G(e,n,"linePrefix")}}var $e={name:"thematicBreak",tokenize:Oc};function Oc(e,n,t){let r=0,i;return o;function o(u){return e.enter("thematicBreak"),a(u)}function a(u){return i=u,s(u)}function s(u){return u===i?(e.enter("thematicBreakSequence"),l(u)):r>=3&&(u===null||T(u))?(e.exit("thematicBreak"),n(u)):t(u)}function l(u){return u===i?(e.consume(u),r++,l):(e.exit("thematicBreakSequence"),B(u)?G(e,s,"whitespace")(u):s(u))}}var pe={name:"list",tokenize:Uc,continuation:{tokenize:Kc},exit:jc},_c={tokenize:Jc,partial:!0},Hc={tokenize:Yc,partial:!0};function Uc(e,n,t){let r=this,i=r.events[r.events.length-1],o=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,a=0;return s;function s(p){let g=r.containerState.type||(p===42||p===43||p===45?"listUnordered":"listOrdered");if(g==="listUnordered"?!r.containerState.marker||p===r.containerState.marker:Nt(p)){if(r.containerState.type||(r.containerState.type=g,e.enter(g,{_container:!0})),g==="listUnordered")return e.enter("listItemPrefix"),p===42||p===45?e.check($e,t,u)(p):u(p);if(!r.interrupt||p===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),l(p)}return t(p)}function l(p){return Nt(p)&&++a<10?(e.consume(p),l):(!r.interrupt||a<2)&&(r.containerState.marker?p===r.containerState.marker:p===41||p===46)?(e.exit("listItemValue"),u(p)):t(p)}function u(p){return e.enter("listItemMarker"),e.consume(p),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||p,e.check(Xe,r.interrupt?t:c,e.attempt(_c,d,h))}function c(p){return r.containerState.initialBlankLine=!0,o++,d(p)}function h(p){return B(p)?(e.enter("listItemPrefixWhitespace"),e.consume(p),e.exit("listItemPrefixWhitespace"),d):t(p)}function d(p){return r.containerState.size=o+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,n(p)}}function Kc(e,n,t){let r=this;return r.containerState._closeFlow=void 0,e.check(Xe,i,o);function i(s){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,G(e,n,"listItemIndent",r.containerState.size+1)(s)}function o(s){return r.containerState.furtherBlankLines||!B(s)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,a(s)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(Hc,n,a)(s))}function a(s){return r.containerState._closeFlow=!0,r.interrupt=void 0,G(e,e.attempt(pe,n,t),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(s)}}function Yc(e,n,t){let r=this;return G(e,i,"listItemIndent",r.containerState.size+1);function i(o){let a=r.events[r.events.length-1];return a&&a[1].type==="listItemIndent"&&a[2].sliceSerialize(a[1],!0).length===r.containerState.size?n(o):t(o)}}function jc(e){e.exit(this.containerState.type)}function Jc(e,n,t){let r=this;return G(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(o){let a=r.events[r.events.length-1];return!B(o)&&a&&a[1].type==="listItemPrefixWhitespace"?n(o):t(o)}}var Nn={name:"setextUnderline",tokenize:qc,resolveTo:Qc};function Qc(e,n){let t=e.length,r,i,o;for(;t--;)if(e[t][0]==="enter"){if(e[t][1].type==="content"){r=t;break}e[t][1].type==="paragraph"&&(i=t)}else e[t][1].type==="content"&&e.splice(t,1),!o&&e[t][1].type==="definition"&&(o=t);let a={type:"setextHeading",start:Object.assign({},e[i][1].start),end:Object.assign({},e[e.length-1][1].end)};return e[i][1].type="setextHeadingText",o?(e.splice(i,0,["enter",a,n]),e.splice(o+1,0,["exit",e[r][1],n]),e[r][1].end=Object.assign({},e[o][1].end)):e[r][1]=a,e.push(["exit",a,n]),e}function qc(e,n,t){let r=this,i;return o;function o(u){let c=r.events.length,h;for(;c--;)if(r.events[c][1].type!=="lineEnding"&&r.events[c][1].type!=="linePrefix"&&r.events[c][1].type!=="content"){h=r.events[c][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||h)?(e.enter("setextHeadingLine"),i=u,a(u)):t(u)}function a(u){return e.enter("setextHeadingLineSequence"),s(u)}function s(u){return u===i?(e.consume(u),s):(e.exit("setextHeadingLineSequence"),B(u)?G(e,l,"lineSuffix")(u):l(u))}function l(u){return u===null||T(u)?(e.exit("setextHeadingLine"),n(u)):t(u)}}var ya={tokenize:$c};function $c(e){let n=this,t=e.attempt(Xe,r,e.attempt(this.parser.constructs.flowInitial,i,G(e,e.attempt(this.parser.constructs.flow,i,e.attempt(ri,i)),"linePrefix")));return t;function r(o){if(o===null){e.consume(o);return}return e.enter("lineEndingBlank"),e.consume(o),e.exit("lineEndingBlank"),n.currentConstruct=void 0,t}function i(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),n.currentConstruct=void 0,t}}var xa={resolveAll:ka()},ba=va("string"),wa=va("text");function va(e){return{tokenize:n,resolveAll:ka(e==="text"?ep:void 0)};function n(t){let r=this,i=this.parser.constructs[e],o=t.attempt(i,a,s);return a;function a(c){return u(c)?o(c):s(c)}function s(c){if(c===null){t.consume(c);return}return t.enter("data"),t.consume(c),l}function l(c){return u(c)?(t.exit("data"),o(c)):(t.consume(c),l)}function u(c){if(c===null)return!0;let h=i[c],d=-1;if(h)for(;++d<h.length;){let p=h[d];if(!p.previous||p.previous.call(r,r.previous))return!0}return!1}}}function ka(e){return n;function n(t,r){let i=-1,o;for(;++i<=t.length;)o===void 0?t[i]&&t[i][1].type==="data"&&(o=i,i++):(!t[i]||t[i][1].type!=="data")&&(i!==o+2&&(t[o][1].end=t[i-1][1].end,t.splice(o+2,i-o-2),i=o+2),o=void 0);return e?e(t,r):t}}function ep(e,n){let t=0;for(;++t<=e.length;)if((t===e.length||e[t][1].type==="lineEnding")&&e[t-1][1].type==="data"){let r=e[t-1][1],i=n.sliceStream(r),o=i.length,a=-1,s=0,l;for(;o--;){let u=i[o];if(typeof u=="string"){for(a=u.length;u.charCodeAt(a-1)===32;)s++,a--;if(a)break;a=-1}else if(u===-2)l=!0,s++;else if(u!==-1){o++;break}}if(s){let u={type:t===e.length||l||s<2?"lineSuffix":"hardBreakTrailing",start:{line:r.end.line,column:r.end.column-s,offset:r.end.offset-s,_index:r.start._index+o,_bufferIndex:o?a:r.start._bufferIndex+a},end:Object.assign({},r.end)};r.end=Object.assign({},u.start),r.start.offset===r.end.offset?Object.assign(r,u):(e.splice(t,0,["enter",u,n],["exit",u,n]),t+=2)}t++}return e}function Sa(e,n,t){let r=Object.assign(t?Object.assign({},t):{line:1,column:1,offset:0},{_index:0,_bufferIndex:-1}),i={},o=[],a=[],s=[],l=!0,u={consume:z,enter:Z,exit:x,attempt:M(L),check:M(R),interrupt:M(R,{interrupt:!0})},c={previous:null,code:null,containerState:{},events:[],parser:e,sliceStream:w,sliceSerialize:g,now:k,defineSkip:y,write:p},h=n.tokenize.call(c,u),d;return n.resolveAll&&o.push(n),c;function p(E){return a=he(a,E),I(),a[a.length-1]!==null?[]:(P(n,0),c.events=pt(o,c.events,c),c.events)}function g(E,A){return np(w(E),A)}function w(E){return tp(a,E)}function k(){let{line:E,column:A,offset:N,_index:H,_bufferIndex:Y}=r;return{line:E,column:A,offset:N,_index:H,_bufferIndex:Y}}function y(E){i[E.line]=E.column,F()}function I(){let E;for(;r._index<a.length;){let A=a[r._index];if(typeof A=="string")for(E=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===E&&r._bufferIndex<A.length;)v(A.charCodeAt(r._bufferIndex));else v(A)}}function v(E){l=void 0,d=E,h=h(E)}function z(E){T(E)?(r.line++,r.column=1,r.offset+=E===-3?2:1,F()):E!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===a[r._index].length&&(r._bufferIndex=-1,r._index++)),c.previous=E,l=!0}function Z(E,A){let N=A||{};return N.type=E,N.start=k(),c.events.push(["enter",N,c]),s.push(N),N}function x(E){let A=s.pop();return A.end=k(),c.events.push(["exit",A,c]),A}function L(E,A){P(E,A.from)}function R(E,A){A.restore()}function M(E,A){return N;function N(H,Y,re){let ne,f,we,Me;return Array.isArray(H)?me(H):"tokenize"in H?me([H]):m(H);function m(ae){return bt;function bt(Ie){let nt=Ie!==null&&ae[Ie],rt=Ie!==null&&ae.null,cr=[...Array.isArray(nt)?nt:nt?[nt]:[],...Array.isArray(rt)?rt:rt?[rt]:[]];return me(cr)(Ie)}}function me(ae){return ne=ae,f=0,ae.length===0?re:_e(ae[f])}function _e(ae){return bt;function bt(Ie){return Me=D(),we=ae,ae.partial||(c.currentConstruct=ae),ae.name&&c.parser.constructs.disable.null.includes(ae.name)?Yt(Ie):ae.tokenize.call(A?Object.assign(Object.create(c),A):c,u,ur,Yt)(Ie)}}function ur(ae){return l=!0,E(we,Me),Y}function Yt(ae){return l=!0,Me.restore(),++f<ne.length?_e(ne[f]):re}}}function P(E,A){E.resolveAll&&!o.includes(E)&&o.push(E),E.resolve&&ce(c.events,A,c.events.length-A,E.resolve(c.events.slice(A),c)),E.resolveTo&&(c.events=E.resolveTo(c.events,c))}function D(){let E=k(),A=c.previous,N=c.currentConstruct,H=c.events.length,Y=Array.from(s);return{restore:re,from:H};function re(){r=E,c.previous=A,c.currentConstruct=N,c.events.length=H,s=Y,F()}}function F(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function tp(e,n){let t=n.start._index,r=n.start._bufferIndex,i=n.end._index,o=n.end._bufferIndex,a;if(t===i)a=[e[t].slice(r,o)];else{if(a=e.slice(t,i),r>-1){let s=a[0];typeof s=="string"?a[0]=s.slice(r):a.shift()}o>0&&a.push(e[i].slice(0,o))}return a}function np(e,n){let t=-1,r=[],i;for(;++t<e.length;){let o=e[t],a;if(typeof o=="string")a=o;else switch(o){case-5:{a="\r";break}case-4:{a=`
|
|
178
|
+
\f\r "&'<=>\``.split("")]],single:[["&'".split(""),"\"&'`".split("")],["\0&'".split(""),"\0\"&'`".split("")]],double:[['"&'.split(""),"\"&'`".split("")],['\0"&'.split(""),"\0\"&'`".split("")]]};function Qo(e,n,t,r){let i=r.schema,o=i.space==="svg"?!1:r.settings.omitOptionalTags,a=i.space==="svg"?r.settings.closeEmptyElements:r.settings.voids.includes(e.tagName.toLowerCase()),s=[],l;i.space==="html"&&e.tagName==="svg"&&(r.schema=bn);let u=zu(r,e.properties),c=r.all(i.space==="html"&&e.tagName==="template"?e.content:e);return r.schema=i,c&&(a=!1),(u||!o||!Jo(e,n,t))&&(s.push("<",e.tagName,u?" "+u:""),a&&(i.space==="svg"||r.settings.closeSelfClosing)&&(l=u.charAt(u.length-1),(!r.settings.tightSelfClosing||l==="/"||l&&l!=='"'&&l!=="'")&&s.push(" "),s.push("/")),s.push(">")),s.push(c),!a&&(!o||!Zt(e,n,t))&&s.push("</"+e.tagName+">"),s.join("")}function zu(e,n){let t=[],r=-1,i;if(n){for(i in n)if(n[i]!==null&&n[i]!==void 0){let o=Zu(e,i,n[i]);o&&t.push(o)}}for(;++r<t.length;){let o=e.settings.tightAttributes?t[r].charAt(t[r].length-1):void 0;r!==t.length-1&&o!=='"'&&o!=="'"&&(t[r]+=" ")}return t.join("")}function Zu(e,n,t){let r=Kr(e.schema,n),i=e.settings.allowParseErrors&&e.schema.space==="html"?0:1,o=e.settings.allowDangerousCharacters?0:1,a=e.quote,s;if(r.overloadedBoolean&&(t===r.attribute||t==="")?t=!0:(r.boolean||r.overloadedBoolean&&typeof t!="string")&&(t=!!t),t==null||t===!1||typeof t=="number"&&Number.isNaN(t))return"";let l=Ve(r.attribute,Object.assign({},e.settings.characterReferences,{subset:Sn.name[i][o]}));return t===!0||(t=Array.isArray(t)?(r.commaSeparated?Uo:go)(t,{padLeft:!e.settings.tightCommaSeparatedLists}):String(t),e.settings.collapseEmptyAttributes&&!t)?l:(e.settings.preferUnquoted&&(s=Ve(t,Object.assign({},e.settings.characterReferences,{attribute:!0,subset:Sn.unquoted[i][o]}))),s!==t&&(e.settings.quoteSmart&&jr(t,a)>jr(t,e.alternative)&&(a=e.alternative),s=a+Ve(t,Object.assign({},e.settings.characterReferences,{subset:(a==="'"?Sn.single:Sn.double)[i][o],attribute:!0}))+a),l+(s&&"="+s))}var Pu=["<","&"];function Cn(e,n,t,r){return t&&t.type==="element"&&(t.tagName==="script"||t.tagName==="style")?e.value:Ve(e.value,Object.assign({},r.settings.characterReferences,{subset:Pu}))}function qo(e,n,t,r){return r.settings.allowDangerousHtml?e.value:Cn(e,n,t,r)}function $o(e,n,t,r){return r.all(e)}var ea=Zo("type",{invalid:Vu,unknown:Nu,handlers:{comment:_o,doctype:Ho,element:Qo,raw:qo,root:$o,text:Cn}});function Vu(e){throw new Error("Expected node, not `"+e+"`")}function Nu(e){let n=e;throw new Error("Cannot compile unknown node `"+n.type+"`")}var Bu={},Wu={},Gu=[];function qr(e,n){let t=n||Bu,r=t.quote||'"',i=r==='"'?"'":'"';if(r!=='"'&&r!=="'")throw new Error("Invalid quote `"+r+"`, expected `'` or `\"`");return{one:Xu,all:Du,settings:{omitOptionalTags:t.omitOptionalTags||!1,allowParseErrors:t.allowParseErrors||!1,allowDangerousCharacters:t.allowDangerousCharacters||!1,quoteSmart:t.quoteSmart||!1,preferUnquoted:t.preferUnquoted||!1,tightAttributes:t.tightAttributes||!1,upperDoctype:t.upperDoctype||!1,tightDoctype:t.tightDoctype||!1,bogusComments:t.bogusComments||!1,tightCommaSeparatedLists:t.tightCommaSeparatedLists||!1,tightSelfClosing:t.tightSelfClosing||!1,collapseEmptyAttributes:t.collapseEmptyAttributes||!1,allowDangerousHtml:t.allowDangerousHtml||!1,voids:t.voids||To,characterReferences:t.characterReferences||Wu,closeSelfClosing:t.closeSelfClosing||!1,closeEmptyElements:t.closeEmptyElements||!1},schema:t.space==="svg"?bn:Ro,quote:r,alternative:i}.one(Array.isArray(e)?{type:"root",children:e}:e,void 0,void 0)}function Xu(e,n,t){return ea(e,n,t,this)}function Du(e){let n=[],t=e&&e.children||Gu,r=-1;for(;++r<t.length;)n[r]=this.one(t[r],r,e);return n.join("")}function En(e){let n=this,t={...n.data("settings"),...e};n.compiler=r;function r(i){return qr(i,t)}}var Ou={};function $r(e,n){let t=n||Ou,r=typeof t.includeImageAlt=="boolean"?t.includeImageAlt:!0,i=typeof t.includeHtml=="boolean"?t.includeHtml:!0;return na(e,r,i)}function na(e,n,t){if(_u(e)){if("value"in e)return e.type==="html"&&!t?"":e.value;if(n&&"alt"in e&&e.alt)return e.alt;if("children"in e)return ta(e.children,n,t)}return Array.isArray(e)?ta(e,n,t):""}function ta(e,n,t){let r=[],i=-1;for(;++i<e.length;)r[i]=na(e[i],n,t);return r.join("")}function _u(e){return!!(e&&typeof e=="object")}var ra=document.createElement("i");function ct(e){let n="&"+e+";";ra.innerHTML=n;let t=ra.textContent;return t.charCodeAt(t.length-1)===59&&e!=="semi"||t===n?!1:t}function ce(e,n,t,r){let i=e.length,o=0,a;if(n<0?n=-n>i?0:i+n:n=n>i?i:n,t=t>0?t:0,r.length<1e4)a=Array.from(r),a.unshift(n,t),e.splice(...a);else for(t&&e.splice(n,t);o<r.length;)a=r.slice(o,o+1e4),a.unshift(n,0),e.splice(...a),o+=1e4,n+=1e4}function he(e,n){return e.length>0?(ce(e,e.length,0,n),e):n}var ia={}.hasOwnProperty;function oa(e){let n={},t=-1;for(;++t<e.length;)Hu(n,e[t]);return n}function Hu(e,n){let t;for(t in n){let i=(ia.call(e,t)?e[t]:void 0)||(e[t]={}),o=n[t],a;if(o)for(a in o){ia.call(i,a)||(i[a]=[]);let s=o[a];Uu(i[a],Array.isArray(s)?s:s?[s]:[])}}}function Uu(e,n){let t=-1,r=[];for(;++t<n.length;)(n[t].add==="after"?e:r).push(n[t]);ce(e,0,0,r)}function In(e,n){let t=Number.parseInt(e,n);return t<9||t===11||t>13&&t<32||t>126&&t<160||t>55295&&t<57344||t>64975&&t<65008||(t&65535)===65535||(t&65535)===65534||t>1114111?"\uFFFD":String.fromCodePoint(t)}function Ne(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}var be=Ge(/[A-Za-z]/),ie=Ge(/[\dA-Za-z]/),aa=Ge(/[#-'*+\--9=?A-Z^-~]/);function Pt(e){return e!==null&&(e<32||e===127)}var Vt=Ge(/\d/),sa=Ge(/[\dA-Fa-f]/),la=Ge(/[!-/:-@[-`{-~]/);function T(e){return e!==null&&e<-2}function te(e){return e!==null&&(e<0||e===32)}function B(e){return e===-2||e===-1||e===32}var ua=Ge(/\p{P}|\p{S}/u),ca=Ge(/\s/);function Ge(e){return n;function n(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function ke(e){let n=[],t=-1,r=0,i=0;for(;++t<e.length;){let o=e.charCodeAt(t),a="";if(o===37&&ie(e.charCodeAt(t+1))&&ie(e.charCodeAt(t+2)))i=2;else if(o<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(o))||(a=String.fromCharCode(o));else if(o>55295&&o<57344){let s=e.charCodeAt(t+1);o<56320&&s>56319&&s<57344?(a=String.fromCharCode(o,s),i=1):a="\uFFFD"}else a=String.fromCharCode(o);a&&(n.push(e.slice(r,t),encodeURIComponent(a)),r=t+i+1,a=""),i&&(t+=i,i=0)}return n.join("")+e.slice(r)}function G(e,n,t,r){let i=r?r-1:Number.POSITIVE_INFINITY,o=0;return a;function a(l){return B(l)?(e.enter(t),s(l)):n(l)}function s(l){return B(l)&&o++<i?(e.consume(l),s):(e.exit(t),n(l))}}var pa={tokenize:Ku};function Ku(e){let n=e.attempt(this.parser.constructs.contentInitial,r,i),t;return n;function r(s){if(s===null){e.consume(s);return}return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),G(e,n,"linePrefix")}function i(s){return e.enter("paragraph"),o(s)}function o(s){let l=e.enter("chunkText",{contentType:"text",previous:t});return t&&(t.next=l),t=l,a(s)}function a(s){if(s===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(s);return}return T(s)?(e.consume(s),e.exit("chunkText"),o):(e.consume(s),a)}}var da={tokenize:Yu},ha={tokenize:ju};function Yu(e){let n=this,t=[],r=0,i,o,a;return s;function s(v){if(r<t.length){let z=t[r];return n.containerState=z[1],e.attempt(z[0].continuation,l,u)(v)}return u(v)}function l(v){if(r++,n.containerState._closeFlow){n.containerState._closeFlow=void 0,i&&I();let z=n.events.length,Z=z,x;for(;Z--;)if(n.events[Z][0]==="exit"&&n.events[Z][1].type==="chunkFlow"){x=n.events[Z][1].end;break}y(r);let L=z;for(;L<n.events.length;)n.events[L][1].end=Object.assign({},x),L++;return ce(n.events,Z+1,0,n.events.slice(z)),n.events.length=L,u(v)}return s(v)}function u(v){if(r===t.length){if(!i)return d(v);if(i.currentConstruct&&i.currentConstruct.concrete)return g(v);n.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return n.containerState={},e.check(ha,c,h)(v)}function c(v){return i&&I(),y(r),d(v)}function h(v){return n.parser.lazy[n.now().line]=r!==t.length,a=n.now().offset,g(v)}function d(v){return n.containerState={},e.attempt(ha,p,g)(v)}function p(v){return r++,t.push([n.currentConstruct,n.containerState]),d(v)}function g(v){if(v===null){i&&I(),y(0),e.consume(v);return}return i=i||n.parser.flow(n.now()),e.enter("chunkFlow",{contentType:"flow",previous:o,_tokenizer:i}),w(v)}function w(v){if(v===null){k(e.exit("chunkFlow"),!0),y(0),e.consume(v);return}return T(v)?(e.consume(v),k(e.exit("chunkFlow")),r=0,n.interrupt=void 0,s):(e.consume(v),w)}function k(v,z){let Z=n.sliceStream(v);if(z&&Z.push(null),v.previous=o,o&&(o.next=v),o=v,i.defineSkip(v.start),i.write(Z),n.parser.lazy[v.start.line]){let x=i.events.length;for(;x--;)if(i.events[x][1].start.offset<a&&(!i.events[x][1].end||i.events[x][1].end.offset>a))return;let L=n.events.length,R=L,F,P;for(;R--;)if(n.events[R][0]==="exit"&&n.events[R][1].type==="chunkFlow"){if(F){P=n.events[R][1].end;break}F=!0}for(y(r),x=L;x<n.events.length;)n.events[x][1].end=Object.assign({},P),x++;ce(n.events,R+1,0,n.events.slice(L)),n.events.length=x}}function y(v){let z=t.length;for(;z-- >v;){let Z=t[z];n.containerState=Z[1],Z[0].exit.call(n,e)}t.length=v}function I(){i.write([null]),o=void 0,i=void 0,n.containerState._closeFlow=void 0}}function ju(e,n,t){return G(e,e.attempt(this.parser.constructs.document,n,t),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function ei(e){if(e===null||te(e)||ca(e))return 1;if(ua(e))return 2}function pt(e,n,t){let r=[],i=-1;for(;++i<e.length;){let o=e[i].resolveAll;o&&!r.includes(o)&&(n=o(n,t),r.push(o))}return n}var Nt={name:"attention",tokenize:Qu,resolveAll:Ju};function Ju(e,n){let t=-1,r,i,o,a,s,l,u,c;for(;++t<e.length;)if(e[t][0]==="enter"&&e[t][1].type==="attentionSequence"&&e[t][1]._close){for(r=t;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&n.sliceSerialize(e[r][1]).charCodeAt(0)===n.sliceSerialize(e[t][1]).charCodeAt(0)){if((e[r][1]._close||e[t][1]._open)&&(e[t][1].end.offset-e[t][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[t][1].end.offset-e[t][1].start.offset)%3))continue;l=e[r][1].end.offset-e[r][1].start.offset>1&&e[t][1].end.offset-e[t][1].start.offset>1?2:1;let h=Object.assign({},e[r][1].end),d=Object.assign({},e[t][1].start);fa(h,-l),fa(d,l),a={type:l>1?"strongSequence":"emphasisSequence",start:h,end:Object.assign({},e[r][1].end)},s={type:l>1?"strongSequence":"emphasisSequence",start:Object.assign({},e[t][1].start),end:d},o={type:l>1?"strongText":"emphasisText",start:Object.assign({},e[r][1].end),end:Object.assign({},e[t][1].start)},i={type:l>1?"strong":"emphasis",start:Object.assign({},a.start),end:Object.assign({},s.end)},e[r][1].end=Object.assign({},a.start),e[t][1].start=Object.assign({},s.end),u=[],e[r][1].end.offset-e[r][1].start.offset&&(u=he(u,[["enter",e[r][1],n],["exit",e[r][1],n]])),u=he(u,[["enter",i,n],["enter",a,n],["exit",a,n],["enter",o,n]]),u=he(u,pt(n.parser.constructs.insideSpan.null,e.slice(r+1,t),n)),u=he(u,[["exit",o,n],["enter",s,n],["exit",s,n],["exit",i,n]]),e[t][1].end.offset-e[t][1].start.offset?(c=2,u=he(u,[["enter",e[t][1],n],["exit",e[t][1],n]])):c=0,ce(e,r-1,t-r+3,u),t=r+u.length-c-2;break}}for(t=-1;++t<e.length;)e[t][1].type==="attentionSequence"&&(e[t][1].type="data");return e}function Qu(e,n){let t=this.parser.constructs.attentionMarkers.null,r=this.previous,i=ei(r),o;return a;function a(l){return o=l,e.enter("attentionSequence"),s(l)}function s(l){if(l===o)return e.consume(l),s;let u=e.exit("attentionSequence"),c=ei(l),h=!c||c===2&&i||t.includes(l),d=!i||i===2&&c||t.includes(r);return u._open=!!(o===42?h:h&&(i||!d)),u._close=!!(o===42?d:d&&(c||!h)),n(l)}}function fa(e,n){e.column+=n,e.offset+=n,e._bufferIndex+=n}var ti={name:"autolink",tokenize:qu};function qu(e,n,t){let r=0;return i;function i(p){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),o}function o(p){return be(p)?(e.consume(p),a):p===64?t(p):u(p)}function a(p){return p===43||p===45||p===46||ie(p)?(r=1,s(p)):u(p)}function s(p){return p===58?(e.consume(p),r=0,l):(p===43||p===45||p===46||ie(p))&&r++<32?(e.consume(p),s):(r=0,u(p))}function l(p){return p===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),n):p===null||p===32||p===60||Pt(p)?t(p):(e.consume(p),l)}function u(p){return p===64?(e.consume(p),c):aa(p)?(e.consume(p),u):t(p)}function c(p){return ie(p)?h(p):t(p)}function h(p){return p===46?(e.consume(p),r=0,c):p===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),n):d(p)}function d(p){if((p===45||ie(p))&&r++<63){let g=p===45?d:h;return e.consume(p),g}return t(p)}}var Xe={tokenize:$u,partial:!0};function $u(e,n,t){return r;function r(o){return B(o)?G(e,i,"linePrefix")(o):i(o)}function i(o){return o===null||T(o)?n(o):t(o)}}var Tn={name:"blockQuote",tokenize:ec,continuation:{tokenize:tc},exit:nc};function ec(e,n,t){let r=this;return i;function i(a){if(a===62){let s=r.containerState;return s.open||(e.enter("blockQuote",{_container:!0}),s.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(a),e.exit("blockQuoteMarker"),o}return t(a)}function o(a){return B(a)?(e.enter("blockQuotePrefixWhitespace"),e.consume(a),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),n):(e.exit("blockQuotePrefix"),n(a))}}function tc(e,n,t){let r=this;return i;function i(a){return B(a)?G(e,o,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a):o(a)}function o(a){return e.attempt(Tn,n,t)(a)}}function nc(e){e.exit("blockQuote")}var An={name:"characterEscape",tokenize:rc};function rc(e,n,t){return r;function r(o){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(o),e.exit("escapeMarker"),i}function i(o){return la(o)?(e.enter("characterEscapeValue"),e.consume(o),e.exit("characterEscapeValue"),e.exit("characterEscape"),n):t(o)}}var Ln={name:"characterReference",tokenize:ic};function ic(e,n,t){let r=this,i=0,o,a;return s;function s(h){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(h),e.exit("characterReferenceMarker"),l}function l(h){return h===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(h),e.exit("characterReferenceMarkerNumeric"),u):(e.enter("characterReferenceValue"),o=31,a=ie,c(h))}function u(h){return h===88||h===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(h),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),o=6,a=sa,c):(e.enter("characterReferenceValue"),o=7,a=Vt,c(h))}function c(h){if(h===59&&i){let d=e.exit("characterReferenceValue");return a===ie&&!ct(r.sliceSerialize(d))?t(h):(e.enter("characterReferenceMarker"),e.consume(h),e.exit("characterReferenceMarker"),e.exit("characterReference"),n)}return a(h)&&i++<o?(e.consume(h),c):t(h)}}var ma={tokenize:ac,partial:!0},Mn={name:"codeFenced",tokenize:oc,concrete:!0};function oc(e,n,t){let r=this,i={tokenize:Z,partial:!0},o=0,a=0,s;return l;function l(x){return u(x)}function u(x){let L=r.events[r.events.length-1];return o=L&&L[1].type==="linePrefix"?L[2].sliceSerialize(L[1],!0).length:0,s=x,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),c(x)}function c(x){return x===s?(a++,e.consume(x),c):a<3?t(x):(e.exit("codeFencedFenceSequence"),B(x)?G(e,h,"whitespace")(x):h(x))}function h(x){return x===null||T(x)?(e.exit("codeFencedFence"),r.interrupt?n(x):e.check(ma,w,z)(x)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),d(x))}function d(x){return x===null||T(x)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),h(x)):B(x)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),G(e,p,"whitespace")(x)):x===96&&x===s?t(x):(e.consume(x),d)}function p(x){return x===null||T(x)?h(x):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),g(x))}function g(x){return x===null||T(x)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),h(x)):x===96&&x===s?t(x):(e.consume(x),g)}function w(x){return e.attempt(i,z,k)(x)}function k(x){return e.enter("lineEnding"),e.consume(x),e.exit("lineEnding"),y}function y(x){return o>0&&B(x)?G(e,I,"linePrefix",o+1)(x):I(x)}function I(x){return x===null||T(x)?e.check(ma,w,z)(x):(e.enter("codeFlowValue"),v(x))}function v(x){return x===null||T(x)?(e.exit("codeFlowValue"),I(x)):(e.consume(x),v)}function z(x){return e.exit("codeFenced"),n(x)}function Z(x,L,R){let F=0;return P;function P(V){return x.enter("lineEnding"),x.consume(V),x.exit("lineEnding"),D}function D(V){return x.enter("codeFencedFence"),B(V)?G(x,M,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(V):M(V)}function M(V){return V===s?(x.enter("codeFencedFenceSequence"),E(V)):R(V)}function E(V){return V===s?(F++,x.consume(V),E):F>=a?(x.exit("codeFencedFenceSequence"),B(V)?G(x,A,"whitespace")(V):A(V)):R(V)}function A(V){return V===null||T(V)?(x.exit("codeFencedFence"),L(V)):R(V)}}}function ac(e,n,t){let r=this;return i;function i(a){return a===null?t(a):(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),o)}function o(a){return r.parser.lazy[r.now().line]?t(a):n(a)}}var Bt={name:"codeIndented",tokenize:lc},sc={tokenize:uc,partial:!0};function lc(e,n,t){let r=this;return i;function i(u){return e.enter("codeIndented"),G(e,o,"linePrefix",5)(u)}function o(u){let c=r.events[r.events.length-1];return c&&c[1].type==="linePrefix"&&c[2].sliceSerialize(c[1],!0).length>=4?a(u):t(u)}function a(u){return u===null?l(u):T(u)?e.attempt(sc,a,l)(u):(e.enter("codeFlowValue"),s(u))}function s(u){return u===null||T(u)?(e.exit("codeFlowValue"),a(u)):(e.consume(u),s)}function l(u){return e.exit("codeIndented"),n(u)}}function uc(e,n,t){let r=this;return i;function i(a){return r.parser.lazy[r.now().line]?t(a):T(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),i):G(e,o,"linePrefix",5)(a)}function o(a){let s=r.events[r.events.length-1];return s&&s[1].type==="linePrefix"&&s[2].sliceSerialize(s[1],!0).length>=4?n(a):T(a)?i(a):t(a)}}var ni={name:"codeText",tokenize:hc,resolve:cc,previous:pc};function cc(e){let n=e.length-4,t=3,r,i;if((e[t][1].type==="lineEnding"||e[t][1].type==="space")&&(e[n][1].type==="lineEnding"||e[n][1].type==="space")){for(r=t;++r<n;)if(e[r][1].type==="codeTextData"){e[t][1].type="codeTextPadding",e[n][1].type="codeTextPadding",t+=2,n-=2;break}}for(r=t-1,n++;++r<=n;)i===void 0?r!==n&&e[r][1].type!=="lineEnding"&&(i=r):(r===n||e[r][1].type==="lineEnding")&&(e[i][1].type="codeTextData",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),n-=r-i-2,r=i+2),i=void 0);return e}function pc(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function hc(e,n,t){let r=this,i=0,o,a;return s;function s(d){return e.enter("codeText"),e.enter("codeTextSequence"),l(d)}function l(d){return d===96?(e.consume(d),i++,l):(e.exit("codeTextSequence"),u(d))}function u(d){return d===null?t(d):d===32?(e.enter("space"),e.consume(d),e.exit("space"),u):d===96?(a=e.enter("codeTextSequence"),o=0,h(d)):T(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),u):(e.enter("codeTextData"),c(d))}function c(d){return d===null||d===32||d===96||T(d)?(e.exit("codeTextData"),u(d)):(e.consume(d),c)}function h(d){return d===96?(e.consume(d),o++,h):o===i?(e.exit("codeTextSequence"),e.exit("codeText"),n(d)):(a.type="codeTextData",c(d))}}var Fn=class{constructor(n){this.left=n?[...n]:[],this.right=[]}get(n){if(n<0||n>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+n+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return n<this.left.length?this.left[n]:this.right[this.right.length-n+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(n,t){let r=t??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(n,r):n>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-n+this.left.length).reverse():this.left.slice(n).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(n,t,r){let i=t||0;this.setCursor(Math.trunc(n));let o=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&Wt(this.left,r),o.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(n){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(n)}pushMany(n){this.setCursor(Number.POSITIVE_INFINITY),Wt(this.left,n)}unshift(n){this.setCursor(0),this.right.push(n)}unshiftMany(n){this.setCursor(0),Wt(this.right,n.reverse())}setCursor(n){if(!(n===this.left.length||n>this.left.length&&this.right.length===0||n<0&&this.left.length===0))if(n<this.left.length){let t=this.left.splice(n,Number.POSITIVE_INFINITY);Wt(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-n,Number.POSITIVE_INFINITY);Wt(this.left,t.reverse())}}};function Wt(e,n){let t=0;if(n.length<1e4)e.push(...n);else for(;t<n.length;)e.push(...n.slice(t,t+1e4)),t+=1e4}function Rn(e){let n={},t=-1,r,i,o,a,s,l,u,c=new Fn(e);for(;++t<c.length;){for(;t in n;)t=n[t];if(r=c.get(t),t&&r[1].type==="chunkFlow"&&c.get(t-1)[1].type==="listItemPrefix"&&(l=r[1]._tokenizer.events,o=0,o<l.length&&l[o][1].type==="lineEndingBlank"&&(o+=2),o<l.length&&l[o][1].type==="content"))for(;++o<l.length&&l[o][1].type!=="content";)l[o][1].type==="chunkText"&&(l[o][1]._isInFirstContentOfListItem=!0,o++);if(r[0]==="enter")r[1].contentType&&(Object.assign(n,dc(c,t)),t=n[t],u=!0);else if(r[1]._container){for(o=t,i=void 0;o--&&(a=c.get(o),a[1].type==="lineEnding"||a[1].type==="lineEndingBlank");)a[0]==="enter"&&(i&&(c.get(i)[1].type="lineEndingBlank"),a[1].type="lineEnding",i=o);i&&(r[1].end=Object.assign({},c.get(i)[1].start),s=c.slice(i,t),s.unshift(r),c.splice(i,t-i+1,s))}}return ce(e,0,Number.POSITIVE_INFINITY,c.slice(0)),!u}function dc(e,n){let t=e.get(n)[1],r=e.get(n)[2],i=n-1,o=[],a=t._tokenizer||r.parser[t.contentType](t.start),s=a.events,l=[],u={},c,h,d=-1,p=t,g=0,w=0,k=[w];for(;p;){for(;e.get(++i)[1]!==p;);o.push(i),p._tokenizer||(c=r.sliceStream(p),p.next||c.push(null),h&&a.defineSkip(p.start),p._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=!0),a.write(c),p._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=void 0)),h=p,p=p.next}for(p=t;++d<s.length;)s[d][0]==="exit"&&s[d-1][0]==="enter"&&s[d][1].type===s[d-1][1].type&&s[d][1].start.line!==s[d][1].end.line&&(w=d+1,k.push(w),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(a.events=[],p?(p._tokenizer=void 0,p.previous=void 0):k.pop(),d=k.length;d--;){let y=s.slice(k[d],k[d+1]),I=o.pop();l.push([I,I+y.length-1]),e.splice(I,2,y)}for(l.reverse(),d=-1;++d<l.length;)u[g+l[d][0]]=g+l[d][1],g+=l[d][1]-l[d][0]-1;return u}var ri={tokenize:gc,resolve:mc},fc={tokenize:yc,partial:!0};function mc(e){return Rn(e),e}function gc(e,n){let t;return r;function r(s){return e.enter("content"),t=e.enter("chunkContent",{contentType:"content"}),i(s)}function i(s){return s===null?o(s):T(s)?e.check(fc,a,o)(s):(e.consume(s),i)}function o(s){return e.exit("chunkContent"),e.exit("content"),n(s)}function a(s){return e.consume(s),e.exit("chunkContent"),t.next=e.enter("chunkContent",{contentType:"content",previous:t}),t=t.next,i}}function yc(e,n,t){let r=this;return i;function i(a){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),G(e,o,"linePrefix")}function o(a){if(a===null||T(a))return t(a);let s=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&s&&s[1].type==="linePrefix"&&s[2].sliceSerialize(s[1],!0).length>=4?n(a):e.interrupt(r.parser.constructs.flow,t,n)(a)}}function zn(e,n,t,r,i,o,a,s,l){let u=l||Number.POSITIVE_INFINITY,c=0;return h;function h(y){return y===60?(e.enter(r),e.enter(i),e.enter(o),e.consume(y),e.exit(o),d):y===null||y===32||y===41||Pt(y)?t(y):(e.enter(r),e.enter(a),e.enter(s),e.enter("chunkString",{contentType:"string"}),w(y))}function d(y){return y===62?(e.enter(o),e.consume(y),e.exit(o),e.exit(i),e.exit(r),n):(e.enter(s),e.enter("chunkString",{contentType:"string"}),p(y))}function p(y){return y===62?(e.exit("chunkString"),e.exit(s),d(y)):y===null||y===60||T(y)?t(y):(e.consume(y),y===92?g:p)}function g(y){return y===60||y===62||y===92?(e.consume(y),p):p(y)}function w(y){return!c&&(y===null||y===41||te(y))?(e.exit("chunkString"),e.exit(s),e.exit(a),e.exit(r),n(y)):c<u&&y===40?(e.consume(y),c++,w):y===41?(e.consume(y),c--,w):y===null||y===32||y===40||Pt(y)?t(y):(e.consume(y),y===92?k:w)}function k(y){return y===40||y===41||y===92?(e.consume(y),w):w(y)}}function Zn(e,n,t,r,i,o){let a=this,s=0,l;return u;function u(p){return e.enter(r),e.enter(i),e.consume(p),e.exit(i),e.enter(o),c}function c(p){return s>999||p===null||p===91||p===93&&!l||p===94&&!s&&"_hiddenFootnoteSupport"in a.parser.constructs?t(p):p===93?(e.exit(o),e.enter(i),e.consume(p),e.exit(i),e.exit(r),n):T(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),c):(e.enter("chunkString",{contentType:"string"}),h(p))}function h(p){return p===null||p===91||p===93||T(p)||s++>999?(e.exit("chunkString"),c(p)):(e.consume(p),l||(l=!B(p)),p===92?d:h)}function d(p){return p===91||p===92||p===93?(e.consume(p),s++,h):h(p)}}function Pn(e,n,t,r,i,o){let a;return s;function s(d){return d===34||d===39||d===40?(e.enter(r),e.enter(i),e.consume(d),e.exit(i),a=d===40?41:d,l):t(d)}function l(d){return d===a?(e.enter(i),e.consume(d),e.exit(i),e.exit(r),n):(e.enter(o),u(d))}function u(d){return d===a?(e.exit(o),l(a)):d===null?t(d):T(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),G(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),c(d))}function c(d){return d===a||d===null||T(d)?(e.exit("chunkString"),u(d)):(e.consume(d),d===92?h:c)}function h(d){return d===a||d===92?(e.consume(d),c):c(d)}}function Qe(e,n){let t;return r;function r(i){return T(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),t=!0,r):B(i)?G(e,r,t?"linePrefix":"lineSuffix")(i):n(i)}}var ii={name:"definition",tokenize:bc},xc={tokenize:wc,partial:!0};function bc(e,n,t){let r=this,i;return o;function o(p){return e.enter("definition"),a(p)}function a(p){return Zn.call(r,e,s,t,"definitionLabel","definitionLabelMarker","definitionLabelString")(p)}function s(p){return i=Ne(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),p===58?(e.enter("definitionMarker"),e.consume(p),e.exit("definitionMarker"),l):t(p)}function l(p){return te(p)?Qe(e,u)(p):u(p)}function u(p){return zn(e,c,t,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(p)}function c(p){return e.attempt(xc,h,h)(p)}function h(p){return B(p)?G(e,d,"whitespace")(p):d(p)}function d(p){return p===null||T(p)?(e.exit("definition"),r.parser.defined.push(i),n(p)):t(p)}}function wc(e,n,t){return r;function r(s){return te(s)?Qe(e,i)(s):t(s)}function i(s){return Pn(e,o,t,"definitionTitle","definitionTitleMarker","definitionTitleString")(s)}function o(s){return B(s)?G(e,a,"whitespace")(s):a(s)}function a(s){return s===null||T(s)?n(s):t(s)}}var oi={name:"hardBreakEscape",tokenize:vc};function vc(e,n,t){return r;function r(o){return e.enter("hardBreakEscape"),e.consume(o),i}function i(o){return T(o)?(e.exit("hardBreakEscape"),n(o)):t(o)}}var ai={name:"headingAtx",tokenize:Sc,resolve:kc};function kc(e,n){let t=e.length-2,r=3,i,o;return e[r][1].type==="whitespace"&&(r+=2),t-2>r&&e[t][1].type==="whitespace"&&(t-=2),e[t][1].type==="atxHeadingSequence"&&(r===t-1||t-4>r&&e[t-2][1].type==="whitespace")&&(t-=r+1===t?2:4),t>r&&(i={type:"atxHeadingText",start:e[r][1].start,end:e[t][1].end},o={type:"chunkText",start:e[r][1].start,end:e[t][1].end,contentType:"text"},ce(e,r,t-r+1,[["enter",i,n],["enter",o,n],["exit",o,n],["exit",i,n]])),e}function Sc(e,n,t){let r=0;return i;function i(c){return e.enter("atxHeading"),o(c)}function o(c){return e.enter("atxHeadingSequence"),a(c)}function a(c){return c===35&&r++<6?(e.consume(c),a):c===null||te(c)?(e.exit("atxHeadingSequence"),s(c)):t(c)}function s(c){return c===35?(e.enter("atxHeadingSequence"),l(c)):c===null||T(c)?(e.exit("atxHeading"),n(c)):B(c)?G(e,s,"whitespace")(c):(e.enter("atxHeadingText"),u(c))}function l(c){return c===35?(e.consume(c),l):(e.exit("atxHeadingSequence"),s(c))}function u(c){return c===null||c===35||te(c)?(e.exit("atxHeadingText"),s(c)):(e.consume(c),u)}}var ga=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],si=["pre","script","style","textarea"];var li={name:"htmlFlow",tokenize:Tc,resolveTo:Ic,concrete:!0},Cc={tokenize:Lc,partial:!0},Ec={tokenize:Ac,partial:!0};function Ic(e){let n=e.length;for(;n--&&!(e[n][0]==="enter"&&e[n][1].type==="htmlFlow"););return n>1&&e[n-2][1].type==="linePrefix"&&(e[n][1].start=e[n-2][1].start,e[n+1][1].start=e[n-2][1].start,e.splice(n-2,2)),e}function Tc(e,n,t){let r=this,i,o,a,s,l;return u;function u(m){return c(m)}function c(m){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(m),h}function h(m){return m===33?(e.consume(m),d):m===47?(e.consume(m),o=!0,w):m===63?(e.consume(m),i=3,r.interrupt?n:f):be(m)?(e.consume(m),a=String.fromCharCode(m),k):t(m)}function d(m){return m===45?(e.consume(m),i=2,p):m===91?(e.consume(m),i=5,s=0,g):be(m)?(e.consume(m),i=4,r.interrupt?n:f):t(m)}function p(m){return m===45?(e.consume(m),r.interrupt?n:f):t(m)}function g(m){let me="CDATA[";return m===me.charCodeAt(s++)?(e.consume(m),s===me.length?r.interrupt?n:M:g):t(m)}function w(m){return be(m)?(e.consume(m),a=String.fromCharCode(m),k):t(m)}function k(m){if(m===null||m===47||m===62||te(m)){let me=m===47,_e=a.toLowerCase();return!me&&!o&&si.includes(_e)?(i=1,r.interrupt?n(m):M(m)):ga.includes(a.toLowerCase())?(i=6,me?(e.consume(m),y):r.interrupt?n(m):M(m)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?t(m):o?I(m):v(m))}return m===45||ie(m)?(e.consume(m),a+=String.fromCharCode(m),k):t(m)}function y(m){return m===62?(e.consume(m),r.interrupt?n:M):t(m)}function I(m){return B(m)?(e.consume(m),I):P(m)}function v(m){return m===47?(e.consume(m),P):m===58||m===95||be(m)?(e.consume(m),z):B(m)?(e.consume(m),v):P(m)}function z(m){return m===45||m===46||m===58||m===95||ie(m)?(e.consume(m),z):Z(m)}function Z(m){return m===61?(e.consume(m),x):B(m)?(e.consume(m),Z):v(m)}function x(m){return m===null||m===60||m===61||m===62||m===96?t(m):m===34||m===39?(e.consume(m),l=m,L):B(m)?(e.consume(m),x):R(m)}function L(m){return m===l?(e.consume(m),l=null,F):m===null||T(m)?t(m):(e.consume(m),L)}function R(m){return m===null||m===34||m===39||m===47||m===60||m===61||m===62||m===96||te(m)?Z(m):(e.consume(m),R)}function F(m){return m===47||m===62||B(m)?v(m):t(m)}function P(m){return m===62?(e.consume(m),D):t(m)}function D(m){return m===null||T(m)?M(m):B(m)?(e.consume(m),D):t(m)}function M(m){return m===45&&i===2?(e.consume(m),H):m===60&&i===1?(e.consume(m),Y):m===62&&i===4?(e.consume(m),we):m===63&&i===3?(e.consume(m),f):m===93&&i===5?(e.consume(m),ne):T(m)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(Cc,Fe,E)(m)):m===null||T(m)?(e.exit("htmlFlowData"),E(m)):(e.consume(m),M)}function E(m){return e.check(Ec,A,Fe)(m)}function A(m){return e.enter("lineEnding"),e.consume(m),e.exit("lineEnding"),V}function V(m){return m===null||T(m)?E(m):(e.enter("htmlFlowData"),M(m))}function H(m){return m===45?(e.consume(m),f):M(m)}function Y(m){return m===47?(e.consume(m),a="",re):M(m)}function re(m){if(m===62){let me=a.toLowerCase();return si.includes(me)?(e.consume(m),we):M(m)}return be(m)&&a.length<8?(e.consume(m),a+=String.fromCharCode(m),re):M(m)}function ne(m){return m===93?(e.consume(m),f):M(m)}function f(m){return m===62?(e.consume(m),we):m===45&&i===2?(e.consume(m),f):M(m)}function we(m){return m===null||T(m)?(e.exit("htmlFlowData"),Fe(m)):(e.consume(m),we)}function Fe(m){return e.exit("htmlFlow"),n(m)}}function Ac(e,n,t){let r=this;return i;function i(a){return T(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),o):t(a)}function o(a){return r.parser.lazy[r.now().line]?t(a):n(a)}}function Lc(e,n,t){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(Xe,n,t)}}var ui={name:"htmlText",tokenize:Mc};function Mc(e,n,t){let r=this,i,o,a;return s;function s(f){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(f),l}function l(f){return f===33?(e.consume(f),u):f===47?(e.consume(f),Z):f===63?(e.consume(f),v):be(f)?(e.consume(f),R):t(f)}function u(f){return f===45?(e.consume(f),c):f===91?(e.consume(f),o=0,g):be(f)?(e.consume(f),I):t(f)}function c(f){return f===45?(e.consume(f),p):t(f)}function h(f){return f===null?t(f):f===45?(e.consume(f),d):T(f)?(a=h,Y(f)):(e.consume(f),h)}function d(f){return f===45?(e.consume(f),p):h(f)}function p(f){return f===62?H(f):f===45?d(f):h(f)}function g(f){let we="CDATA[";return f===we.charCodeAt(o++)?(e.consume(f),o===we.length?w:g):t(f)}function w(f){return f===null?t(f):f===93?(e.consume(f),k):T(f)?(a=w,Y(f)):(e.consume(f),w)}function k(f){return f===93?(e.consume(f),y):w(f)}function y(f){return f===62?H(f):f===93?(e.consume(f),y):w(f)}function I(f){return f===null||f===62?H(f):T(f)?(a=I,Y(f)):(e.consume(f),I)}function v(f){return f===null?t(f):f===63?(e.consume(f),z):T(f)?(a=v,Y(f)):(e.consume(f),v)}function z(f){return f===62?H(f):v(f)}function Z(f){return be(f)?(e.consume(f),x):t(f)}function x(f){return f===45||ie(f)?(e.consume(f),x):L(f)}function L(f){return T(f)?(a=L,Y(f)):B(f)?(e.consume(f),L):H(f)}function R(f){return f===45||ie(f)?(e.consume(f),R):f===47||f===62||te(f)?F(f):t(f)}function F(f){return f===47?(e.consume(f),H):f===58||f===95||be(f)?(e.consume(f),P):T(f)?(a=F,Y(f)):B(f)?(e.consume(f),F):H(f)}function P(f){return f===45||f===46||f===58||f===95||ie(f)?(e.consume(f),P):D(f)}function D(f){return f===61?(e.consume(f),M):T(f)?(a=D,Y(f)):B(f)?(e.consume(f),D):F(f)}function M(f){return f===null||f===60||f===61||f===62||f===96?t(f):f===34||f===39?(e.consume(f),i=f,E):T(f)?(a=M,Y(f)):B(f)?(e.consume(f),M):(e.consume(f),A)}function E(f){return f===i?(e.consume(f),i=void 0,V):f===null?t(f):T(f)?(a=E,Y(f)):(e.consume(f),E)}function A(f){return f===null||f===34||f===39||f===60||f===61||f===96?t(f):f===47||f===62||te(f)?F(f):(e.consume(f),A)}function V(f){return f===47||f===62||te(f)?F(f):t(f)}function H(f){return f===62?(e.consume(f),e.exit("htmlTextData"),e.exit("htmlText"),n):t(f)}function Y(f){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),re}function re(f){return B(f)?G(e,ne,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(f):ne(f)}function ne(f){return e.enter("htmlTextData"),a(f)}}var qe={name:"labelEnd",tokenize:Vc,resolveTo:Pc,resolveAll:Zc},Fc={tokenize:Nc},Rc={tokenize:Bc},zc={tokenize:Wc};function Zc(e){let n=-1;for(;++n<e.length;){let t=e[n][1];(t.type==="labelImage"||t.type==="labelLink"||t.type==="labelEnd")&&(e.splice(n+1,t.type==="labelImage"?4:2),t.type="data",n++)}return e}function Pc(e,n){let t=e.length,r=0,i,o,a,s;for(;t--;)if(i=e[t][1],o){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;e[t][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(a){if(e[t][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(o=t,i.type!=="labelLink")){r=2;break}}else i.type==="labelEnd"&&(a=t);let l={type:e[o][1].type==="labelLink"?"link":"image",start:Object.assign({},e[o][1].start),end:Object.assign({},e[e.length-1][1].end)},u={type:"label",start:Object.assign({},e[o][1].start),end:Object.assign({},e[a][1].end)},c={type:"labelText",start:Object.assign({},e[o+r+2][1].end),end:Object.assign({},e[a-2][1].start)};return s=[["enter",l,n],["enter",u,n]],s=he(s,e.slice(o+1,o+r+3)),s=he(s,[["enter",c,n]]),s=he(s,pt(n.parser.constructs.insideSpan.null,e.slice(o+r+4,a-3),n)),s=he(s,[["exit",c,n],e[a-2],e[a-1],["exit",u,n]]),s=he(s,e.slice(a+1)),s=he(s,[["exit",l,n]]),ce(e,o,e.length,s),e}function Vc(e,n,t){let r=this,i=r.events.length,o,a;for(;i--;)if((r.events[i][1].type==="labelImage"||r.events[i][1].type==="labelLink")&&!r.events[i][1]._balanced){o=r.events[i][1];break}return s;function s(d){return o?o._inactive?h(d):(a=r.parser.defined.includes(Ne(r.sliceSerialize({start:o.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(d),e.exit("labelMarker"),e.exit("labelEnd"),l):t(d)}function l(d){return d===40?e.attempt(Fc,c,a?c:h)(d):d===91?e.attempt(Rc,c,a?u:h)(d):a?c(d):h(d)}function u(d){return e.attempt(zc,c,h)(d)}function c(d){return n(d)}function h(d){return o._balanced=!0,t(d)}}function Nc(e,n,t){return r;function r(h){return e.enter("resource"),e.enter("resourceMarker"),e.consume(h),e.exit("resourceMarker"),i}function i(h){return te(h)?Qe(e,o)(h):o(h)}function o(h){return h===41?c(h):zn(e,a,s,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(h)}function a(h){return te(h)?Qe(e,l)(h):c(h)}function s(h){return t(h)}function l(h){return h===34||h===39||h===40?Pn(e,u,t,"resourceTitle","resourceTitleMarker","resourceTitleString")(h):c(h)}function u(h){return te(h)?Qe(e,c)(h):c(h)}function c(h){return h===41?(e.enter("resourceMarker"),e.consume(h),e.exit("resourceMarker"),e.exit("resource"),n):t(h)}}function Bc(e,n,t){let r=this;return i;function i(s){return Zn.call(r,e,o,a,"reference","referenceMarker","referenceString")(s)}function o(s){return r.parser.defined.includes(Ne(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?n(s):t(s)}function a(s){return t(s)}}function Wc(e,n,t){return r;function r(o){return e.enter("reference"),e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),i}function i(o){return o===93?(e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),e.exit("reference"),n):t(o)}}var ci={name:"labelStartImage",tokenize:Gc,resolveAll:qe.resolveAll};function Gc(e,n,t){let r=this;return i;function i(s){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(s),e.exit("labelImageMarker"),o}function o(s){return s===91?(e.enter("labelMarker"),e.consume(s),e.exit("labelMarker"),e.exit("labelImage"),a):t(s)}function a(s){return s===94&&"_hiddenFootnoteSupport"in r.parser.constructs?t(s):n(s)}}var pi={name:"labelStartLink",tokenize:Xc,resolveAll:qe.resolveAll};function Xc(e,n,t){let r=this;return i;function i(a){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelLink"),o}function o(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?t(a):n(a)}}var Gt={name:"lineEnding",tokenize:Dc};function Dc(e,n){return t;function t(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),G(e,n,"linePrefix")}}var $e={name:"thematicBreak",tokenize:Oc};function Oc(e,n,t){let r=0,i;return o;function o(u){return e.enter("thematicBreak"),a(u)}function a(u){return i=u,s(u)}function s(u){return u===i?(e.enter("thematicBreakSequence"),l(u)):r>=3&&(u===null||T(u))?(e.exit("thematicBreak"),n(u)):t(u)}function l(u){return u===i?(e.consume(u),r++,l):(e.exit("thematicBreakSequence"),B(u)?G(e,s,"whitespace")(u):s(u))}}var pe={name:"list",tokenize:Uc,continuation:{tokenize:Kc},exit:jc},_c={tokenize:Jc,partial:!0},Hc={tokenize:Yc,partial:!0};function Uc(e,n,t){let r=this,i=r.events[r.events.length-1],o=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,a=0;return s;function s(p){let g=r.containerState.type||(p===42||p===43||p===45?"listUnordered":"listOrdered");if(g==="listUnordered"?!r.containerState.marker||p===r.containerState.marker:Vt(p)){if(r.containerState.type||(r.containerState.type=g,e.enter(g,{_container:!0})),g==="listUnordered")return e.enter("listItemPrefix"),p===42||p===45?e.check($e,t,u)(p):u(p);if(!r.interrupt||p===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),l(p)}return t(p)}function l(p){return Vt(p)&&++a<10?(e.consume(p),l):(!r.interrupt||a<2)&&(r.containerState.marker?p===r.containerState.marker:p===41||p===46)?(e.exit("listItemValue"),u(p)):t(p)}function u(p){return e.enter("listItemMarker"),e.consume(p),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||p,e.check(Xe,r.interrupt?t:c,e.attempt(_c,d,h))}function c(p){return r.containerState.initialBlankLine=!0,o++,d(p)}function h(p){return B(p)?(e.enter("listItemPrefixWhitespace"),e.consume(p),e.exit("listItemPrefixWhitespace"),d):t(p)}function d(p){return r.containerState.size=o+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,n(p)}}function Kc(e,n,t){let r=this;return r.containerState._closeFlow=void 0,e.check(Xe,i,o);function i(s){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,G(e,n,"listItemIndent",r.containerState.size+1)(s)}function o(s){return r.containerState.furtherBlankLines||!B(s)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,a(s)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(Hc,n,a)(s))}function a(s){return r.containerState._closeFlow=!0,r.interrupt=void 0,G(e,e.attempt(pe,n,t),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(s)}}function Yc(e,n,t){let r=this;return G(e,i,"listItemIndent",r.containerState.size+1);function i(o){let a=r.events[r.events.length-1];return a&&a[1].type==="listItemIndent"&&a[2].sliceSerialize(a[1],!0).length===r.containerState.size?n(o):t(o)}}function jc(e){e.exit(this.containerState.type)}function Jc(e,n,t){let r=this;return G(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(o){let a=r.events[r.events.length-1];return!B(o)&&a&&a[1].type==="listItemPrefixWhitespace"?n(o):t(o)}}var Vn={name:"setextUnderline",tokenize:qc,resolveTo:Qc};function Qc(e,n){let t=e.length,r,i,o;for(;t--;)if(e[t][0]==="enter"){if(e[t][1].type==="content"){r=t;break}e[t][1].type==="paragraph"&&(i=t)}else e[t][1].type==="content"&&e.splice(t,1),!o&&e[t][1].type==="definition"&&(o=t);let a={type:"setextHeading",start:Object.assign({},e[i][1].start),end:Object.assign({},e[e.length-1][1].end)};return e[i][1].type="setextHeadingText",o?(e.splice(i,0,["enter",a,n]),e.splice(o+1,0,["exit",e[r][1],n]),e[r][1].end=Object.assign({},e[o][1].end)):e[r][1]=a,e.push(["exit",a,n]),e}function qc(e,n,t){let r=this,i;return o;function o(u){let c=r.events.length,h;for(;c--;)if(r.events[c][1].type!=="lineEnding"&&r.events[c][1].type!=="linePrefix"&&r.events[c][1].type!=="content"){h=r.events[c][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||h)?(e.enter("setextHeadingLine"),i=u,a(u)):t(u)}function a(u){return e.enter("setextHeadingLineSequence"),s(u)}function s(u){return u===i?(e.consume(u),s):(e.exit("setextHeadingLineSequence"),B(u)?G(e,l,"lineSuffix")(u):l(u))}function l(u){return u===null||T(u)?(e.exit("setextHeadingLine"),n(u)):t(u)}}var ya={tokenize:$c};function $c(e){let n=this,t=e.attempt(Xe,r,e.attempt(this.parser.constructs.flowInitial,i,G(e,e.attempt(this.parser.constructs.flow,i,e.attempt(ri,i)),"linePrefix")));return t;function r(o){if(o===null){e.consume(o);return}return e.enter("lineEndingBlank"),e.consume(o),e.exit("lineEndingBlank"),n.currentConstruct=void 0,t}function i(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),n.currentConstruct=void 0,t}}var xa={resolveAll:ka()},ba=va("string"),wa=va("text");function va(e){return{tokenize:n,resolveAll:ka(e==="text"?ep:void 0)};function n(t){let r=this,i=this.parser.constructs[e],o=t.attempt(i,a,s);return a;function a(c){return u(c)?o(c):s(c)}function s(c){if(c===null){t.consume(c);return}return t.enter("data"),t.consume(c),l}function l(c){return u(c)?(t.exit("data"),o(c)):(t.consume(c),l)}function u(c){if(c===null)return!0;let h=i[c],d=-1;if(h)for(;++d<h.length;){let p=h[d];if(!p.previous||p.previous.call(r,r.previous))return!0}return!1}}}function ka(e){return n;function n(t,r){let i=-1,o;for(;++i<=t.length;)o===void 0?t[i]&&t[i][1].type==="data"&&(o=i,i++):(!t[i]||t[i][1].type!=="data")&&(i!==o+2&&(t[o][1].end=t[i-1][1].end,t.splice(o+2,i-o-2),i=o+2),o=void 0);return e?e(t,r):t}}function ep(e,n){let t=0;for(;++t<=e.length;)if((t===e.length||e[t][1].type==="lineEnding")&&e[t-1][1].type==="data"){let r=e[t-1][1],i=n.sliceStream(r),o=i.length,a=-1,s=0,l;for(;o--;){let u=i[o];if(typeof u=="string"){for(a=u.length;u.charCodeAt(a-1)===32;)s++,a--;if(a)break;a=-1}else if(u===-2)l=!0,s++;else if(u!==-1){o++;break}}if(s){let u={type:t===e.length||l||s<2?"lineSuffix":"hardBreakTrailing",start:{line:r.end.line,column:r.end.column-s,offset:r.end.offset-s,_index:r.start._index+o,_bufferIndex:o?a:r.start._bufferIndex+a},end:Object.assign({},r.end)};r.end=Object.assign({},u.start),r.start.offset===r.end.offset?Object.assign(r,u):(e.splice(t,0,["enter",u,n],["exit",u,n]),t+=2)}t++}return e}function Sa(e,n,t){let r=Object.assign(t?Object.assign({},t):{line:1,column:1,offset:0},{_index:0,_bufferIndex:-1}),i={},o=[],a=[],s=[],l=!0,u={consume:z,enter:Z,exit:x,attempt:F(L),check:F(R),interrupt:F(R,{interrupt:!0})},c={previous:null,code:null,containerState:{},events:[],parser:e,sliceStream:w,sliceSerialize:g,now:k,defineSkip:y,write:p},h=n.tokenize.call(c,u),d;return n.resolveAll&&o.push(n),c;function p(E){return a=he(a,E),I(),a[a.length-1]!==null?[]:(P(n,0),c.events=pt(o,c.events,c),c.events)}function g(E,A){return np(w(E),A)}function w(E){return tp(a,E)}function k(){let{line:E,column:A,offset:V,_index:H,_bufferIndex:Y}=r;return{line:E,column:A,offset:V,_index:H,_bufferIndex:Y}}function y(E){i[E.line]=E.column,M()}function I(){let E;for(;r._index<a.length;){let A=a[r._index];if(typeof A=="string")for(E=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===E&&r._bufferIndex<A.length;)v(A.charCodeAt(r._bufferIndex));else v(A)}}function v(E){l=void 0,d=E,h=h(E)}function z(E){T(E)?(r.line++,r.column=1,r.offset+=E===-3?2:1,M()):E!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===a[r._index].length&&(r._bufferIndex=-1,r._index++)),c.previous=E,l=!0}function Z(E,A){let V=A||{};return V.type=E,V.start=k(),c.events.push(["enter",V,c]),s.push(V),V}function x(E){let A=s.pop();return A.end=k(),c.events.push(["exit",A,c]),A}function L(E,A){P(E,A.from)}function R(E,A){A.restore()}function F(E,A){return V;function V(H,Y,re){let ne,f,we,Fe;return Array.isArray(H)?me(H):"tokenize"in H?me([H]):m(H);function m(ae){return bt;function bt(Ie){let nt=Ie!==null&&ae[Ie],rt=Ie!==null&&ae.null,cr=[...Array.isArray(nt)?nt:nt?[nt]:[],...Array.isArray(rt)?rt:rt?[rt]:[]];return me(cr)(Ie)}}function me(ae){return ne=ae,f=0,ae.length===0?re:_e(ae[f])}function _e(ae){return bt;function bt(Ie){return Fe=D(),we=ae,ae.partial||(c.currentConstruct=ae),ae.name&&c.parser.constructs.disable.null.includes(ae.name)?Yt(Ie):ae.tokenize.call(A?Object.assign(Object.create(c),A):c,u,ur,Yt)(Ie)}}function ur(ae){return l=!0,E(we,Fe),Y}function Yt(ae){return l=!0,Fe.restore(),++f<ne.length?_e(ne[f]):re}}}function P(E,A){E.resolveAll&&!o.includes(E)&&o.push(E),E.resolve&&ce(c.events,A,c.events.length-A,E.resolve(c.events.slice(A),c)),E.resolveTo&&(c.events=E.resolveTo(c.events,c))}function D(){let E=k(),A=c.previous,V=c.currentConstruct,H=c.events.length,Y=Array.from(s);return{restore:re,from:H};function re(){r=E,c.previous=A,c.currentConstruct=V,c.events.length=H,s=Y,M()}}function M(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function tp(e,n){let t=n.start._index,r=n.start._bufferIndex,i=n.end._index,o=n.end._bufferIndex,a;if(t===i)a=[e[t].slice(r,o)];else{if(a=e.slice(t,i),r>-1){let s=a[0];typeof s=="string"?a[0]=s.slice(r):a.shift()}o>0&&a.push(e[i].slice(0,o))}return a}function np(e,n){let t=-1,r=[],i;for(;++t<e.length;){let o=e[t],a;if(typeof o=="string")a=o;else switch(o){case-5:{a="\r";break}case-4:{a=`
|
|
179
179
|
`;break}case-3:{a=`\r
|
|
180
|
-
`;break}case-2:{a=n?" ":" ";break}case-1:{if(!n&&i)continue;a=" ";break}default:a=String.fromCharCode(o)}i=o===-2,r.push(a)}return r.join("")}var hi={};Oi(hi,{attentionMarkers:()=>cp,contentInitial:()=>ip,disable:()=>pp,document:()=>rp,flow:()=>ap,flowInitial:()=>op,insideSpan:()=>up,string:()=>sp,text:()=>lp});var rp={42:pe,43:pe,45:pe,48:pe,49:pe,50:pe,51:pe,52:pe,53:pe,54:pe,55:pe,56:pe,57:pe,62:Tn},ip={91:ii},op={[-2]:Bt,[-1]:Bt,32:Bt},ap={35:ai,42:$e,45:[Nn,$e],60:li,61:Nn,95:$e,96:Fn,126:Fn},sp={38:Ln,92:An},lp={[-5]:Gt,[-4]:Gt,[-3]:Gt,33:ci,38:Ln,42:Vt,60:[ti,ui],91:pi,92:[oi,An],93:qe,95:Vt,96:ni},up={null:[Vt,xa]},cp={null:[42,95]},pp={null:[]};function di(e){let t=oa([hi,...(e||{}).extensions||[]]),r={defined:[],lazy:{},constructs:t,content:i(pa),document:i(da),flow:i(ya),string:i(ba),text:i(wa)};return r;function i(o){return a;function a(s){return Sa(r,o,s)}}}function fi(e){for(;!Rn(e););return e}var Ca=/[\0\t\n\r]/g;function mi(){let e=1,n="",t=!0,r;return i;function i(o,a,s){let l=[],u,c,h,d,p;for(o=n+(typeof o=="string"?o.toString():new TextDecoder(a||void 0).decode(o)),h=0,n="",t&&(o.charCodeAt(0)===65279&&h++,t=void 0);h<o.length;){if(Ca.lastIndex=h,u=Ca.exec(o),d=u&&u.index!==void 0?u.index:o.length,p=o.charCodeAt(d),!u){n=o.slice(h);break}if(p===10&&h===d&&r)l.push(-3),r=void 0;else switch(r&&(l.push(-5),r=void 0),h<d&&(l.push(o.slice(h,d)),e+=d-h),p){case 0:{l.push(65533),e++;break}case 9:{for(c=Math.ceil(e/4)*4,l.push(-2);e++<c;)l.push(-1);break}case 10:{l.push(-4),e=1;break}default:r=!0,e=1}h=d+1}return s&&(r&&l.push(-5),n&&l.push(n),l.push(null)),l}}var hp=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Ea(e){return e.replace(hp,dp)}function dp(e,n,t){if(n)return n;if(t.charCodeAt(0)===35){let i=t.charCodeAt(1),o=i===120||i===88;return In(t.slice(o?2:1),o?16:10)}return ct(t)||e}function De(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?Ia(e.position):"start"in e||"end"in e?Ia(e):"line"in e||"column"in e?gi(e):""}function gi(e){return Ta(e&&e.line)+":"+Ta(e&&e.column)}function Ia(e){return gi(e&&e.start)+"-"+gi(e&&e.end)}function Ta(e){return e&&typeof e=="number"?e:1}var La={}.hasOwnProperty;function yi(e,n,t){return typeof n!="string"&&(t=n,n=void 0),fp(t)(fi(di(t).document().write(mi()(e,n,!0))))}function fp(e){let n={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:o(Xi),autolinkProtocol:M,autolinkEmail:M,atxHeading:o(Bi),blockQuote:o(bt),characterEscape:M,characterReference:M,codeFenced:o(Ie),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:o(Ie,a),codeText:o(nt,a),codeTextData:M,data:M,codeFlowValue:M,definition:o(rt),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:o(cr),hardBreakEscape:o(Wi),hardBreakTrailing:o(Wi),htmlFlow:o(Gi,a),htmlFlowData:M,htmlText:o(Gi,a),htmlTextData:M,image:o(Ds),label:a,link:o(Xi),listItem:o(Os),listItemValue:d,listOrdered:o(Di,h),listUnordered:o(Di),paragraph:o(_s),reference:m,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:o(Bi),strong:o(Hs),thematicBreak:o(Ks)},exit:{atxHeading:l(),atxHeadingSequence:Z,autolink:l(),autolinkEmail:ae,autolinkProtocol:Yt,blockQuote:l(),characterEscapeValue:P,characterReferenceMarkerHexadecimal:_e,characterReferenceMarkerNumeric:_e,characterReferenceValue:ur,codeFenced:l(k),codeFencedFence:w,codeFencedFenceInfo:p,codeFencedFenceMeta:g,codeFlowValue:P,codeIndented:l(y),codeText:l(N),codeTextData:P,data:P,definition:l(),definitionDestinationString:z,definitionLabelString:I,definitionTitleString:v,emphasis:l(),hardBreakEscape:l(F),hardBreakTrailing:l(F),htmlFlow:l(E),htmlFlowData:P,htmlText:l(A),htmlTextData:P,image:l(Y),label:ne,labelText:re,lineEnding:D,link:l(H),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:me,resourceDestinationString:f,resourceTitleString:we,resource:Me,setextHeading:l(R),setextHeadingLineSequence:L,setextHeadingText:x,strong:l(),thematicBreak:l()}};Fa(n,(e||{}).mdastExtensions||[]);let t={};return r;function r(b){let C={type:"root",children:[]},W={stack:[C],tokenStack:[],config:n,enter:s,exit:u,buffer:a,resume:c,data:t},_=[],j=-1;for(;++j<b.length;)if(b[j][1].type==="listOrdered"||b[j][1].type==="listUnordered")if(b[j][0]==="enter")_.push(j);else{let Se=_.pop();j=i(b,Se,j)}for(j=-1;++j<b.length;){let Se=n[b[j][0]];La.call(Se,b[j][1].type)&&Se[b[j][1].type].call(Object.assign({sliceSerialize:b[j][2].sliceSerialize},W),b[j][1])}if(W.tokenStack.length>0){let Se=W.tokenStack[W.tokenStack.length-1];(Se[1]||Aa).call(W,void 0,Se[0])}for(C.position={start:Oe(b.length>0?b[0][1].start:{line:1,column:1,offset:0}),end:Oe(b.length>0?b[b.length-2][1].end:{line:1,column:1,offset:0})},j=-1;++j<n.transforms.length;)C=n.transforms[j](C)||C;return C}function i(b,C,W){let _=C-1,j=-1,Se=!1,He,Re,wt,vt;for(;++_<=W;){let ge=b[_];switch(ge[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{ge[0]==="enter"?j++:j--,vt=void 0;break}case"lineEndingBlank":{ge[0]==="enter"&&(He&&!vt&&!j&&!wt&&(wt=_),vt=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:vt=void 0}if(!j&&ge[0]==="enter"&&ge[1].type==="listItemPrefix"||j===-1&&ge[0]==="exit"&&(ge[1].type==="listUnordered"||ge[1].type==="listOrdered")){if(He){let it=_;for(Re=void 0;it--;){let ze=b[it];if(ze[1].type==="lineEnding"||ze[1].type==="lineEndingBlank"){if(ze[0]==="exit")continue;Re&&(b[Re][1].type="lineEndingBlank",Se=!0),ze[1].type="lineEnding",Re=it}else if(!(ze[1].type==="linePrefix"||ze[1].type==="blockQuotePrefix"||ze[1].type==="blockQuotePrefixWhitespace"||ze[1].type==="blockQuoteMarker"||ze[1].type==="listItemIndent"))break}wt&&(!Re||wt<Re)&&(He._spread=!0),He.end=Object.assign({},Re?b[Re][1].start:ge[1].end),b.splice(Re||_,0,["exit",He,ge[2]]),_++,W++}if(ge[1].type==="listItemPrefix"){let it={type:"listItem",_spread:!1,start:Object.assign({},ge[1].start),end:void 0};He=it,b.splice(_,0,["enter",it,ge[2]]),_++,W++,wt=void 0,vt=!0}}}return b[C][1]._spread=Se,W}function o(b,C){return W;function W(_){s.call(this,b(_),_),C&&C.call(this,_)}}function a(){this.stack.push({type:"fragment",children:[]})}function s(b,C,W){this.stack[this.stack.length-1].children.push(b),this.stack.push(b),this.tokenStack.push([C,W]),b.position={start:Oe(C.start),end:void 0}}function l(b){return C;function C(W){b&&b.call(this,W),u.call(this,W)}}function u(b,C){let W=this.stack.pop(),_=this.tokenStack.pop();if(_)_[0].type!==b.type&&(C?C.call(this,b,_[0]):(_[1]||Aa).call(this,b,_[0]));else throw new Error("Cannot close `"+b.type+"` ("+De({start:b.start,end:b.end})+"): it\u2019s not open");W.position.end=Oe(b.end)}function c(){return $r(this.stack.pop())}function h(){this.data.expectingFirstListItemValue=!0}function d(b){if(this.data.expectingFirstListItemValue){let C=this.stack[this.stack.length-2];C.start=Number.parseInt(this.sliceSerialize(b),10),this.data.expectingFirstListItemValue=void 0}}function p(){let b=this.resume(),C=this.stack[this.stack.length-1];C.lang=b}function g(){let b=this.resume(),C=this.stack[this.stack.length-1];C.meta=b}function w(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function k(){let b=this.resume(),C=this.stack[this.stack.length-1];C.value=b.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function y(){let b=this.resume(),C=this.stack[this.stack.length-1];C.value=b.replace(/(\r?\n|\r)$/g,"")}function I(b){let C=this.resume(),W=this.stack[this.stack.length-1];W.label=C,W.identifier=Ve(this.sliceSerialize(b)).toLowerCase()}function v(){let b=this.resume(),C=this.stack[this.stack.length-1];C.title=b}function z(){let b=this.resume(),C=this.stack[this.stack.length-1];C.url=b}function Z(b){let C=this.stack[this.stack.length-1];if(!C.depth){let W=this.sliceSerialize(b).length;C.depth=W}}function x(){this.data.setextHeadingSlurpLineEnding=!0}function L(b){let C=this.stack[this.stack.length-1];C.depth=this.sliceSerialize(b).codePointAt(0)===61?1:2}function R(){this.data.setextHeadingSlurpLineEnding=void 0}function M(b){let W=this.stack[this.stack.length-1].children,_=W[W.length-1];(!_||_.type!=="text")&&(_=Us(),_.position={start:Oe(b.start),end:void 0},W.push(_)),this.stack.push(_)}function P(b){let C=this.stack.pop();C.value+=this.sliceSerialize(b),C.position.end=Oe(b.end)}function D(b){let C=this.stack[this.stack.length-1];if(this.data.atHardBreak){let W=C.children[C.children.length-1];W.position.end=Oe(b.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&n.canContainEols.includes(C.type)&&(M.call(this,b),P.call(this,b))}function F(){this.data.atHardBreak=!0}function E(){let b=this.resume(),C=this.stack[this.stack.length-1];C.value=b}function A(){let b=this.resume(),C=this.stack[this.stack.length-1];C.value=b}function N(){let b=this.resume(),C=this.stack[this.stack.length-1];C.value=b}function H(){let b=this.stack[this.stack.length-1];if(this.data.inReference){let C=this.data.referenceType||"shortcut";b.type+="Reference",b.referenceType=C,delete b.url,delete b.title}else delete b.identifier,delete b.label;this.data.referenceType=void 0}function Y(){let b=this.stack[this.stack.length-1];if(this.data.inReference){let C=this.data.referenceType||"shortcut";b.type+="Reference",b.referenceType=C,delete b.url,delete b.title}else delete b.identifier,delete b.label;this.data.referenceType=void 0}function re(b){let C=this.sliceSerialize(b),W=this.stack[this.stack.length-2];W.label=Ea(C),W.identifier=Ve(C).toLowerCase()}function ne(){let b=this.stack[this.stack.length-1],C=this.resume(),W=this.stack[this.stack.length-1];if(this.data.inReference=!0,W.type==="link"){let _=b.children;W.children=_}else W.alt=C}function f(){let b=this.resume(),C=this.stack[this.stack.length-1];C.url=b}function we(){let b=this.resume(),C=this.stack[this.stack.length-1];C.title=b}function Me(){this.data.inReference=void 0}function m(){this.data.referenceType="collapsed"}function me(b){let C=this.resume(),W=this.stack[this.stack.length-1];W.label=C,W.identifier=Ve(this.sliceSerialize(b)).toLowerCase(),this.data.referenceType="full"}function _e(b){this.data.characterReferenceType=b.type}function ur(b){let C=this.sliceSerialize(b),W=this.data.characterReferenceType,_;W?(_=In(C,W==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):_=ct(C);let j=this.stack.pop();j.value+=_,j.position.end=Oe(b.end)}function Yt(b){P.call(this,b);let C=this.stack[this.stack.length-1];C.url=this.sliceSerialize(b)}function ae(b){P.call(this,b);let C=this.stack[this.stack.length-1];C.url="mailto:"+this.sliceSerialize(b)}function bt(){return{type:"blockquote",children:[]}}function Ie(){return{type:"code",lang:null,meta:null,value:""}}function nt(){return{type:"inlineCode",value:""}}function rt(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function cr(){return{type:"emphasis",children:[]}}function Bi(){return{type:"heading",depth:0,children:[]}}function Wi(){return{type:"break"}}function Gi(){return{type:"html",value:""}}function Ds(){return{type:"image",title:null,url:"",alt:null}}function Xi(){return{type:"link",title:null,url:"",children:[]}}function Di(b){return{type:"list",ordered:b.type==="listOrdered",start:null,spread:b._spread,children:[]}}function Os(b){return{type:"listItem",spread:b._spread,checked:null,children:[]}}function _s(){return{type:"paragraph",children:[]}}function Hs(){return{type:"strong",children:[]}}function Us(){return{type:"text",value:""}}function Ks(){return{type:"thematicBreak"}}}function Oe(e){return{line:e.line,column:e.column,offset:e.offset}}function Fa(e,n){let t=-1;for(;++t<n.length;){let r=n[t];Array.isArray(r)?Fa(e,r):mp(e,r)}}function mp(e,n){let t;for(t in n)if(La.call(n,t))switch(t){case"canContainEols":{let r=n[t];r&&e[t].push(...r);break}case"transforms":{let r=n[t];r&&e[t].push(...r);break}case"enter":case"exit":{let r=n[t];r&&Object.assign(e[t],r);break}}}function Aa(e,n){throw e?new Error("Cannot close `"+e.type+"` ("+De({start:e.start,end:e.end})+"): a different token (`"+n.type+"`, "+De({start:n.start,end:n.end})+") is open"):new Error("Cannot close document, a token (`"+n.type+"`, "+De({start:n.start,end:n.end})+") is still open")}function Vn(e){let n=this;n.parser=t;function t(r){return yi(r,{...n.data("settings"),...e,extensions:n.data("micromarkExtensions")||[],mdastExtensions:n.data("fromMarkdownExtensions")||[]})}}function Ma(e,n){let t={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(n),!0)};return e.patch(n,t),e.applyData(n,t)}function Ra(e,n){let t={type:"element",tagName:"br",properties:{},children:[]};return e.patch(n,t),[e.applyData(n,t),{type:"text",value:`
|
|
180
|
+
`;break}case-2:{a=n?" ":" ";break}case-1:{if(!n&&i)continue;a=" ";break}default:a=String.fromCharCode(o)}i=o===-2,r.push(a)}return r.join("")}var hi={};Oi(hi,{attentionMarkers:()=>cp,contentInitial:()=>ip,disable:()=>pp,document:()=>rp,flow:()=>ap,flowInitial:()=>op,insideSpan:()=>up,string:()=>sp,text:()=>lp});var rp={42:pe,43:pe,45:pe,48:pe,49:pe,50:pe,51:pe,52:pe,53:pe,54:pe,55:pe,56:pe,57:pe,62:Tn},ip={91:ii},op={[-2]:Bt,[-1]:Bt,32:Bt},ap={35:ai,42:$e,45:[Vn,$e],60:li,61:Vn,95:$e,96:Mn,126:Mn},sp={38:Ln,92:An},lp={[-5]:Gt,[-4]:Gt,[-3]:Gt,33:ci,38:Ln,42:Nt,60:[ti,ui],91:pi,92:[oi,An],93:qe,95:Nt,96:ni},up={null:[Nt,xa]},cp={null:[42,95]},pp={null:[]};function di(e){let t=oa([hi,...(e||{}).extensions||[]]),r={defined:[],lazy:{},constructs:t,content:i(pa),document:i(da),flow:i(ya),string:i(ba),text:i(wa)};return r;function i(o){return a;function a(s){return Sa(r,o,s)}}}function fi(e){for(;!Rn(e););return e}var Ca=/[\0\t\n\r]/g;function mi(){let e=1,n="",t=!0,r;return i;function i(o,a,s){let l=[],u,c,h,d,p;for(o=n+(typeof o=="string"?o.toString():new TextDecoder(a||void 0).decode(o)),h=0,n="",t&&(o.charCodeAt(0)===65279&&h++,t=void 0);h<o.length;){if(Ca.lastIndex=h,u=Ca.exec(o),d=u&&u.index!==void 0?u.index:o.length,p=o.charCodeAt(d),!u){n=o.slice(h);break}if(p===10&&h===d&&r)l.push(-3),r=void 0;else switch(r&&(l.push(-5),r=void 0),h<d&&(l.push(o.slice(h,d)),e+=d-h),p){case 0:{l.push(65533),e++;break}case 9:{for(c=Math.ceil(e/4)*4,l.push(-2);e++<c;)l.push(-1);break}case 10:{l.push(-4),e=1;break}default:r=!0,e=1}h=d+1}return s&&(r&&l.push(-5),n&&l.push(n),l.push(null)),l}}var hp=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Ea(e){return e.replace(hp,dp)}function dp(e,n,t){if(n)return n;if(t.charCodeAt(0)===35){let i=t.charCodeAt(1),o=i===120||i===88;return In(t.slice(o?2:1),o?16:10)}return ct(t)||e}function De(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?Ia(e.position):"start"in e||"end"in e?Ia(e):"line"in e||"column"in e?gi(e):""}function gi(e){return Ta(e&&e.line)+":"+Ta(e&&e.column)}function Ia(e){return gi(e&&e.start)+"-"+gi(e&&e.end)}function Ta(e){return e&&typeof e=="number"?e:1}var La={}.hasOwnProperty;function yi(e,n,t){return typeof n!="string"&&(t=n,n=void 0),fp(t)(fi(di(t).document().write(mi()(e,n,!0))))}function fp(e){let n={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:o(Xi),autolinkProtocol:F,autolinkEmail:F,atxHeading:o(Bi),blockQuote:o(bt),characterEscape:F,characterReference:F,codeFenced:o(Ie),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:o(Ie,a),codeText:o(nt,a),codeTextData:F,data:F,codeFlowValue:F,definition:o(rt),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:o(cr),hardBreakEscape:o(Wi),hardBreakTrailing:o(Wi),htmlFlow:o(Gi,a),htmlFlowData:F,htmlText:o(Gi,a),htmlTextData:F,image:o(Ds),label:a,link:o(Xi),listItem:o(Os),listItemValue:d,listOrdered:o(Di,h),listUnordered:o(Di),paragraph:o(_s),reference:m,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:o(Bi),strong:o(Hs),thematicBreak:o(Ks)},exit:{atxHeading:l(),atxHeadingSequence:Z,autolink:l(),autolinkEmail:ae,autolinkProtocol:Yt,blockQuote:l(),characterEscapeValue:P,characterReferenceMarkerHexadecimal:_e,characterReferenceMarkerNumeric:_e,characterReferenceValue:ur,codeFenced:l(k),codeFencedFence:w,codeFencedFenceInfo:p,codeFencedFenceMeta:g,codeFlowValue:P,codeIndented:l(y),codeText:l(V),codeTextData:P,data:P,definition:l(),definitionDestinationString:z,definitionLabelString:I,definitionTitleString:v,emphasis:l(),hardBreakEscape:l(M),hardBreakTrailing:l(M),htmlFlow:l(E),htmlFlowData:P,htmlText:l(A),htmlTextData:P,image:l(Y),label:ne,labelText:re,lineEnding:D,link:l(H),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:me,resourceDestinationString:f,resourceTitleString:we,resource:Fe,setextHeading:l(R),setextHeadingLineSequence:L,setextHeadingText:x,strong:l(),thematicBreak:l()}};Ma(n,(e||{}).mdastExtensions||[]);let t={};return r;function r(b){let C={type:"root",children:[]},W={stack:[C],tokenStack:[],config:n,enter:s,exit:u,buffer:a,resume:c,data:t},_=[],j=-1;for(;++j<b.length;)if(b[j][1].type==="listOrdered"||b[j][1].type==="listUnordered")if(b[j][0]==="enter")_.push(j);else{let Se=_.pop();j=i(b,Se,j)}for(j=-1;++j<b.length;){let Se=n[b[j][0]];La.call(Se,b[j][1].type)&&Se[b[j][1].type].call(Object.assign({sliceSerialize:b[j][2].sliceSerialize},W),b[j][1])}if(W.tokenStack.length>0){let Se=W.tokenStack[W.tokenStack.length-1];(Se[1]||Aa).call(W,void 0,Se[0])}for(C.position={start:Oe(b.length>0?b[0][1].start:{line:1,column:1,offset:0}),end:Oe(b.length>0?b[b.length-2][1].end:{line:1,column:1,offset:0})},j=-1;++j<n.transforms.length;)C=n.transforms[j](C)||C;return C}function i(b,C,W){let _=C-1,j=-1,Se=!1,He,Re,wt,vt;for(;++_<=W;){let ge=b[_];switch(ge[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{ge[0]==="enter"?j++:j--,vt=void 0;break}case"lineEndingBlank":{ge[0]==="enter"&&(He&&!vt&&!j&&!wt&&(wt=_),vt=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:vt=void 0}if(!j&&ge[0]==="enter"&&ge[1].type==="listItemPrefix"||j===-1&&ge[0]==="exit"&&(ge[1].type==="listUnordered"||ge[1].type==="listOrdered")){if(He){let it=_;for(Re=void 0;it--;){let ze=b[it];if(ze[1].type==="lineEnding"||ze[1].type==="lineEndingBlank"){if(ze[0]==="exit")continue;Re&&(b[Re][1].type="lineEndingBlank",Se=!0),ze[1].type="lineEnding",Re=it}else if(!(ze[1].type==="linePrefix"||ze[1].type==="blockQuotePrefix"||ze[1].type==="blockQuotePrefixWhitespace"||ze[1].type==="blockQuoteMarker"||ze[1].type==="listItemIndent"))break}wt&&(!Re||wt<Re)&&(He._spread=!0),He.end=Object.assign({},Re?b[Re][1].start:ge[1].end),b.splice(Re||_,0,["exit",He,ge[2]]),_++,W++}if(ge[1].type==="listItemPrefix"){let it={type:"listItem",_spread:!1,start:Object.assign({},ge[1].start),end:void 0};He=it,b.splice(_,0,["enter",it,ge[2]]),_++,W++,wt=void 0,vt=!0}}}return b[C][1]._spread=Se,W}function o(b,C){return W;function W(_){s.call(this,b(_),_),C&&C.call(this,_)}}function a(){this.stack.push({type:"fragment",children:[]})}function s(b,C,W){this.stack[this.stack.length-1].children.push(b),this.stack.push(b),this.tokenStack.push([C,W]),b.position={start:Oe(C.start),end:void 0}}function l(b){return C;function C(W){b&&b.call(this,W),u.call(this,W)}}function u(b,C){let W=this.stack.pop(),_=this.tokenStack.pop();if(_)_[0].type!==b.type&&(C?C.call(this,b,_[0]):(_[1]||Aa).call(this,b,_[0]));else throw new Error("Cannot close `"+b.type+"` ("+De({start:b.start,end:b.end})+"): it\u2019s not open");W.position.end=Oe(b.end)}function c(){return $r(this.stack.pop())}function h(){this.data.expectingFirstListItemValue=!0}function d(b){if(this.data.expectingFirstListItemValue){let C=this.stack[this.stack.length-2];C.start=Number.parseInt(this.sliceSerialize(b),10),this.data.expectingFirstListItemValue=void 0}}function p(){let b=this.resume(),C=this.stack[this.stack.length-1];C.lang=b}function g(){let b=this.resume(),C=this.stack[this.stack.length-1];C.meta=b}function w(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function k(){let b=this.resume(),C=this.stack[this.stack.length-1];C.value=b.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function y(){let b=this.resume(),C=this.stack[this.stack.length-1];C.value=b.replace(/(\r?\n|\r)$/g,"")}function I(b){let C=this.resume(),W=this.stack[this.stack.length-1];W.label=C,W.identifier=Ne(this.sliceSerialize(b)).toLowerCase()}function v(){let b=this.resume(),C=this.stack[this.stack.length-1];C.title=b}function z(){let b=this.resume(),C=this.stack[this.stack.length-1];C.url=b}function Z(b){let C=this.stack[this.stack.length-1];if(!C.depth){let W=this.sliceSerialize(b).length;C.depth=W}}function x(){this.data.setextHeadingSlurpLineEnding=!0}function L(b){let C=this.stack[this.stack.length-1];C.depth=this.sliceSerialize(b).codePointAt(0)===61?1:2}function R(){this.data.setextHeadingSlurpLineEnding=void 0}function F(b){let W=this.stack[this.stack.length-1].children,_=W[W.length-1];(!_||_.type!=="text")&&(_=Us(),_.position={start:Oe(b.start),end:void 0},W.push(_)),this.stack.push(_)}function P(b){let C=this.stack.pop();C.value+=this.sliceSerialize(b),C.position.end=Oe(b.end)}function D(b){let C=this.stack[this.stack.length-1];if(this.data.atHardBreak){let W=C.children[C.children.length-1];W.position.end=Oe(b.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&n.canContainEols.includes(C.type)&&(F.call(this,b),P.call(this,b))}function M(){this.data.atHardBreak=!0}function E(){let b=this.resume(),C=this.stack[this.stack.length-1];C.value=b}function A(){let b=this.resume(),C=this.stack[this.stack.length-1];C.value=b}function V(){let b=this.resume(),C=this.stack[this.stack.length-1];C.value=b}function H(){let b=this.stack[this.stack.length-1];if(this.data.inReference){let C=this.data.referenceType||"shortcut";b.type+="Reference",b.referenceType=C,delete b.url,delete b.title}else delete b.identifier,delete b.label;this.data.referenceType=void 0}function Y(){let b=this.stack[this.stack.length-1];if(this.data.inReference){let C=this.data.referenceType||"shortcut";b.type+="Reference",b.referenceType=C,delete b.url,delete b.title}else delete b.identifier,delete b.label;this.data.referenceType=void 0}function re(b){let C=this.sliceSerialize(b),W=this.stack[this.stack.length-2];W.label=Ea(C),W.identifier=Ne(C).toLowerCase()}function ne(){let b=this.stack[this.stack.length-1],C=this.resume(),W=this.stack[this.stack.length-1];if(this.data.inReference=!0,W.type==="link"){let _=b.children;W.children=_}else W.alt=C}function f(){let b=this.resume(),C=this.stack[this.stack.length-1];C.url=b}function we(){let b=this.resume(),C=this.stack[this.stack.length-1];C.title=b}function Fe(){this.data.inReference=void 0}function m(){this.data.referenceType="collapsed"}function me(b){let C=this.resume(),W=this.stack[this.stack.length-1];W.label=C,W.identifier=Ne(this.sliceSerialize(b)).toLowerCase(),this.data.referenceType="full"}function _e(b){this.data.characterReferenceType=b.type}function ur(b){let C=this.sliceSerialize(b),W=this.data.characterReferenceType,_;W?(_=In(C,W==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):_=ct(C);let j=this.stack.pop();j.value+=_,j.position.end=Oe(b.end)}function Yt(b){P.call(this,b);let C=this.stack[this.stack.length-1];C.url=this.sliceSerialize(b)}function ae(b){P.call(this,b);let C=this.stack[this.stack.length-1];C.url="mailto:"+this.sliceSerialize(b)}function bt(){return{type:"blockquote",children:[]}}function Ie(){return{type:"code",lang:null,meta:null,value:""}}function nt(){return{type:"inlineCode",value:""}}function rt(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function cr(){return{type:"emphasis",children:[]}}function Bi(){return{type:"heading",depth:0,children:[]}}function Wi(){return{type:"break"}}function Gi(){return{type:"html",value:""}}function Ds(){return{type:"image",title:null,url:"",alt:null}}function Xi(){return{type:"link",title:null,url:"",children:[]}}function Di(b){return{type:"list",ordered:b.type==="listOrdered",start:null,spread:b._spread,children:[]}}function Os(b){return{type:"listItem",spread:b._spread,checked:null,children:[]}}function _s(){return{type:"paragraph",children:[]}}function Hs(){return{type:"strong",children:[]}}function Us(){return{type:"text",value:""}}function Ks(){return{type:"thematicBreak"}}}function Oe(e){return{line:e.line,column:e.column,offset:e.offset}}function Ma(e,n){let t=-1;for(;++t<n.length;){let r=n[t];Array.isArray(r)?Ma(e,r):mp(e,r)}}function mp(e,n){let t;for(t in n)if(La.call(n,t))switch(t){case"canContainEols":{let r=n[t];r&&e[t].push(...r);break}case"transforms":{let r=n[t];r&&e[t].push(...r);break}case"enter":case"exit":{let r=n[t];r&&Object.assign(e[t],r);break}}}function Aa(e,n){throw e?new Error("Cannot close `"+e.type+"` ("+De({start:e.start,end:e.end})+"): a different token (`"+n.type+"`, "+De({start:n.start,end:n.end})+") is open"):new Error("Cannot close document, a token (`"+n.type+"`, "+De({start:n.start,end:n.end})+") is still open")}function Nn(e){let n=this;n.parser=t;function t(r){return yi(r,{...n.data("settings"),...e,extensions:n.data("micromarkExtensions")||[],mdastExtensions:n.data("fromMarkdownExtensions")||[]})}}function Fa(e,n){let t={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(n),!0)};return e.patch(n,t),e.applyData(n,t)}function Ra(e,n){let t={type:"element",tagName:"br",properties:{},children:[]};return e.patch(n,t),[e.applyData(n,t),{type:"text",value:`
|
|
181
181
|
`}]}function za(e,n){let t=n.value?n.value+`
|
|
182
|
-
`:"",r={};n.lang&&(r.className=["language-"+n.lang]);let i={type:"element",tagName:"code",properties:r,children:[{type:"text",value:t}]};return n.meta&&(i.data={meta:n.meta}),e.patch(n,i),i=e.applyData(n,i),i={type:"element",tagName:"pre",properties:{},children:[i]},e.patch(n,i),i}function Za(e,n){let t={type:"element",tagName:"del",properties:{},children:e.all(n)};return e.patch(n,t),e.applyData(n,t)}function Pa(e,n){let t={type:"element",tagName:"em",properties:{},children:e.all(n)};return e.patch(n,t),e.applyData(n,t)}function
|
|
182
|
+
`:"",r={};n.lang&&(r.className=["language-"+n.lang]);let i={type:"element",tagName:"code",properties:r,children:[{type:"text",value:t}]};return n.meta&&(i.data={meta:n.meta}),e.patch(n,i),i=e.applyData(n,i),i={type:"element",tagName:"pre",properties:{},children:[i]},e.patch(n,i),i}function Za(e,n){let t={type:"element",tagName:"del",properties:{},children:e.all(n)};return e.patch(n,t),e.applyData(n,t)}function Pa(e,n){let t={type:"element",tagName:"em",properties:{},children:e.all(n)};return e.patch(n,t),e.applyData(n,t)}function Va(e,n){let t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(n.identifier).toUpperCase(),i=ke(r.toLowerCase()),o=e.footnoteOrder.indexOf(r),a,s=e.footnoteCounts.get(r);s===void 0?(s=0,e.footnoteOrder.push(r),a=e.footnoteOrder.length):a=o+1,s+=1,e.footnoteCounts.set(r,s);let l={type:"element",tagName:"a",properties:{href:"#"+t+"fn-"+i,id:t+"fnref-"+i+(s>1?"-"+s:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(a)}]};e.patch(n,l);let u={type:"element",tagName:"sup",properties:{},children:[l]};return e.patch(n,u),e.applyData(n,u)}function Na(e,n){let t={type:"element",tagName:"h"+n.depth,properties:{},children:e.all(n)};return e.patch(n,t),e.applyData(n,t)}function Ba(e,n){if(e.options.allowDangerousHtml){let t={type:"raw",value:n.value};return e.patch(n,t),e.applyData(n,t)}}function Bn(e,n){let t=n.referenceType,r="]";if(t==="collapsed"?r+="[]":t==="full"&&(r+="["+(n.label||n.identifier)+"]"),n.type==="imageReference")return[{type:"text",value:"!["+n.alt+r}];let i=e.all(n),o=i[0];o&&o.type==="text"?o.value="["+o.value:i.unshift({type:"text",value:"["});let a=i[i.length-1];return a&&a.type==="text"?a.value+=r:i.push({type:"text",value:r}),i}function Wa(e,n){let t=String(n.identifier).toUpperCase(),r=e.definitionById.get(t);if(!r)return Bn(e,n);let i={src:ke(r.url||""),alt:n.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);let o={type:"element",tagName:"img",properties:i,children:[]};return e.patch(n,o),e.applyData(n,o)}function Ga(e,n){let t={src:ke(n.url)};n.alt!==null&&n.alt!==void 0&&(t.alt=n.alt),n.title!==null&&n.title!==void 0&&(t.title=n.title);let r={type:"element",tagName:"img",properties:t,children:[]};return e.patch(n,r),e.applyData(n,r)}function Xa(e,n){let t={type:"text",value:n.value.replace(/\r?\n|\r/g," ")};e.patch(n,t);let r={type:"element",tagName:"code",properties:{},children:[t]};return e.patch(n,r),e.applyData(n,r)}function Da(e,n){let t=String(n.identifier).toUpperCase(),r=e.definitionById.get(t);if(!r)return Bn(e,n);let i={href:ke(r.url||"")};r.title!==null&&r.title!==void 0&&(i.title=r.title);let o={type:"element",tagName:"a",properties:i,children:e.all(n)};return e.patch(n,o),e.applyData(n,o)}function Oa(e,n){let t={href:ke(n.url)};n.title!==null&&n.title!==void 0&&(t.title=n.title);let r={type:"element",tagName:"a",properties:t,children:e.all(n)};return e.patch(n,r),e.applyData(n,r)}function _a(e,n,t){let r=e.all(n),i=t?gp(t):Ha(n),o={},a=[];if(typeof n.checked=="boolean"){let c=r[0],h;c&&c.type==="element"&&c.tagName==="p"?h=c:(h={type:"element",tagName:"p",properties:{},children:[]},r.unshift(h)),h.children.length>0&&h.children.unshift({type:"text",value:" "}),h.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:n.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let s=-1;for(;++s<r.length;){let c=r[s];(i||s!==0||c.type!=="element"||c.tagName!=="p")&&a.push({type:"text",value:`
|
|
183
183
|
`}),c.type==="element"&&c.tagName==="p"&&!i?a.push(...c.children):a.push(c)}let l=r[r.length-1];l&&(i||l.type!=="element"||l.tagName!=="p")&&a.push({type:"text",value:`
|
|
184
|
-
`});let u={type:"element",tagName:"li",properties:o,children:a};return e.patch(n,u),e.applyData(n,u)}function gp(e){let n=!1;if(e.type==="list"){n=e.spread||!1;let t=e.children,r=-1;for(;!n&&++r<t.length;)n=Ha(t[r])}return n}function Ha(e){let n=e.spread;return n??e.children.length>1}function Ua(e,n){let t={},r=e.all(n),i=-1;for(typeof n.start=="number"&&n.start!==1&&(t.start=n.start);++i<r.length;){let a=r[i];if(a.type==="element"&&a.tagName==="li"&&a.properties&&Array.isArray(a.properties.className)&&a.properties.className.includes("task-list-item")){t.className=["contains-task-list"];break}}let o={type:"element",tagName:n.ordered?"ol":"ul",properties:t,children:e.wrap(r,!0)};return e.patch(n,o),e.applyData(n,o)}function Ka(e,n){let t={type:"element",tagName:"p",properties:{},children:e.all(n)};return e.patch(n,t),e.applyData(n,t)}function Ya(e,n){let t={type:"root",children:e.wrap(e.all(n))};return e.patch(n,t),e.applyData(n,t)}function ja(e,n){let t={type:"element",tagName:"strong",properties:{},children:e.all(n)};return e.patch(n,t),e.applyData(n,t)}var Wn=Ja("end"),Gn=Ja("start");function Ja(e){return n;function n(t){let r=t&&t.position&&t.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function xi(e){let n=Gn(e),t=Wn(e);if(n&&t)return{start:n,end:t}}function Qa(e,n){let t=e.all(n),r=t.shift(),i=[];if(r){let a={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(n.children[0],a),i.push(a)}if(t.length>0){let a={type:"element",tagName:"tbody",properties:{},children:e.wrap(t,!0)},s=Gn(n.children[1]),l=Wn(n.children[n.children.length-1]);s&&l&&(a.position={start:s,end:l}),i.push(a)}let o={type:"element",tagName:"table",properties:{},children:e.wrap(i,!0)};return e.patch(n,o),e.applyData(n,o)}function qa(e,n,t){let r=t?t.children:void 0,o=(r?r.indexOf(n):1)===0?"th":"td",a=t&&t.type==="table"?t.align:void 0,s=a?a.length:n.children.length,l=-1,u=[];for(;++l<s;){let h=n.children[l],d={},p=a?a[l]:void 0;p&&(d.align=p);let g={type:"element",tagName:o,properties:d,children:[]};h&&(g.children=e.all(h),e.patch(h,g),g=e.applyData(h,g)),u.push(g)}let c={type:"element",tagName:"tr",properties:{},children:e.wrap(u,!0)};return e.patch(n,c),e.applyData(n,c)}function $a(e,n){let t={type:"element",tagName:"td",properties:{},children:e.all(n)};return e.patch(n,t),e.applyData(n,t)}function ts(e){let n=String(e),t=/\r?\n|\r/g,r=t.exec(n),i=0,o=[];for(;r;)o.push(es(n.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=t.exec(n);return o.push(es(n.slice(i),i>0,!1)),o.join("")}function es(e,n,t){let r=0,i=e.length;if(n){let o=e.codePointAt(r);for(;o===9||o===32;)r++,o=e.codePointAt(r)}if(t){let o=e.codePointAt(i-1);for(;o===9||o===32;)i--,o=e.codePointAt(i-1)}return i>r?e.slice(r,i):""}function ns(e,n){let t={type:"text",value:ts(String(n.value))};return e.patch(n,t),e.applyData(n,t)}function rs(e,n){let t={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(n,t),e.applyData(n,t)}var is={blockquote:
|
|
184
|
+
`});let u={type:"element",tagName:"li",properties:o,children:a};return e.patch(n,u),e.applyData(n,u)}function gp(e){let n=!1;if(e.type==="list"){n=e.spread||!1;let t=e.children,r=-1;for(;!n&&++r<t.length;)n=Ha(t[r])}return n}function Ha(e){let n=e.spread;return n??e.children.length>1}function Ua(e,n){let t={},r=e.all(n),i=-1;for(typeof n.start=="number"&&n.start!==1&&(t.start=n.start);++i<r.length;){let a=r[i];if(a.type==="element"&&a.tagName==="li"&&a.properties&&Array.isArray(a.properties.className)&&a.properties.className.includes("task-list-item")){t.className=["contains-task-list"];break}}let o={type:"element",tagName:n.ordered?"ol":"ul",properties:t,children:e.wrap(r,!0)};return e.patch(n,o),e.applyData(n,o)}function Ka(e,n){let t={type:"element",tagName:"p",properties:{},children:e.all(n)};return e.patch(n,t),e.applyData(n,t)}function Ya(e,n){let t={type:"root",children:e.wrap(e.all(n))};return e.patch(n,t),e.applyData(n,t)}function ja(e,n){let t={type:"element",tagName:"strong",properties:{},children:e.all(n)};return e.patch(n,t),e.applyData(n,t)}var Wn=Ja("end"),Gn=Ja("start");function Ja(e){return n;function n(t){let r=t&&t.position&&t.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function xi(e){let n=Gn(e),t=Wn(e);if(n&&t)return{start:n,end:t}}function Qa(e,n){let t=e.all(n),r=t.shift(),i=[];if(r){let a={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(n.children[0],a),i.push(a)}if(t.length>0){let a={type:"element",tagName:"tbody",properties:{},children:e.wrap(t,!0)},s=Gn(n.children[1]),l=Wn(n.children[n.children.length-1]);s&&l&&(a.position={start:s,end:l}),i.push(a)}let o={type:"element",tagName:"table",properties:{},children:e.wrap(i,!0)};return e.patch(n,o),e.applyData(n,o)}function qa(e,n,t){let r=t?t.children:void 0,o=(r?r.indexOf(n):1)===0?"th":"td",a=t&&t.type==="table"?t.align:void 0,s=a?a.length:n.children.length,l=-1,u=[];for(;++l<s;){let h=n.children[l],d={},p=a?a[l]:void 0;p&&(d.align=p);let g={type:"element",tagName:o,properties:d,children:[]};h&&(g.children=e.all(h),e.patch(h,g),g=e.applyData(h,g)),u.push(g)}let c={type:"element",tagName:"tr",properties:{},children:e.wrap(u,!0)};return e.patch(n,c),e.applyData(n,c)}function $a(e,n){let t={type:"element",tagName:"td",properties:{},children:e.all(n)};return e.patch(n,t),e.applyData(n,t)}function ts(e){let n=String(e),t=/\r?\n|\r/g,r=t.exec(n),i=0,o=[];for(;r;)o.push(es(n.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=t.exec(n);return o.push(es(n.slice(i),i>0,!1)),o.join("")}function es(e,n,t){let r=0,i=e.length;if(n){let o=e.codePointAt(r);for(;o===9||o===32;)r++,o=e.codePointAt(r)}if(t){let o=e.codePointAt(i-1);for(;o===9||o===32;)i--,o=e.codePointAt(i-1)}return i>r?e.slice(r,i):""}function ns(e,n){let t={type:"text",value:ts(String(n.value))};return e.patch(n,t),e.applyData(n,t)}function rs(e,n){let t={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(n,t),e.applyData(n,t)}var is={blockquote:Fa,break:Ra,code:za,delete:Za,emphasis:Pa,footnoteReference:Va,heading:Na,html:Ba,imageReference:Wa,image:Ga,inlineCode:Xa,linkReference:Da,link:Oa,listItem:_a,list:Ua,paragraph:Ka,root:Ya,strong:ja,table:Qa,tableCell:$a,tableRow:qa,text:ns,thematicBreak:rs,toml:Xn,yaml:Xn,definition:Xn,footnoteDefinition:Xn};function Xn(){}function yp(e,n){let t=[{type:"text",value:"\u21A9"}];return n>1&&t.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(n)}]}),t}function xp(e,n){return"Back to reference "+(e+1)+(n>1?"-"+n:"")}function os(e){let n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",t=e.options.footnoteBackContent||yp,r=e.options.footnoteBackLabel||xp,i=e.options.footnoteLabel||"Footnotes",o=e.options.footnoteLabelTagName||"h2",a=e.options.footnoteLabelProperties||{className:["sr-only"]},s=[],l=-1;for(;++l<e.footnoteOrder.length;){let u=e.footnoteById.get(e.footnoteOrder[l]);if(!u)continue;let c=e.all(u),h=String(u.identifier).toUpperCase(),d=ke(h.toLowerCase()),p=0,g=[],w=e.footnoteCounts.get(h);for(;w!==void 0&&++p<=w;){g.length>0&&g.push({type:"text",value:" "});let I=typeof t=="string"?t:t(l,p);typeof I=="string"&&(I={type:"text",value:I}),g.push({type:"element",tagName:"a",properties:{href:"#"+n+"fnref-"+d+(p>1?"-"+p:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(l,p),className:["data-footnote-backref"]},children:Array.isArray(I)?I:[I]})}let k=c[c.length-1];if(k&&k.type==="element"&&k.tagName==="p"){let I=k.children[k.children.length-1];I&&I.type==="text"?I.value+=" ":k.children.push({type:"text",value:" "}),k.children.push(...g)}else c.push(...g);let y={type:"element",tagName:"li",properties:{id:n+"fn-"+d},children:e.wrap(c,!0)};e.patch(u,y),s.push(y)}if(s.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{...Te(a),id:"footnote-label"},children:[{type:"text",value:i}]},{type:"text",value:`
|
|
185
185
|
`},{type:"element",tagName:"ol",properties:{},children:e.wrap(s,!0)},{type:"text",value:`
|
|
186
|
-
`}]}}var bi={}.hasOwnProperty,bp={};function ss(e,n){let t=n||bp,r=new Map,i=new Map,o=new Map,a={...is,...t.handlers},s={all:u,applyData:vp,definitionById:r,footnoteById:i,footnoteCounts:o,footnoteOrder:[],handlers:a,one:l,options:t,patch:wp,wrap:Sp};return
|
|
186
|
+
`}]}}var bi={}.hasOwnProperty,bp={};function ss(e,n){let t=n||bp,r=new Map,i=new Map,o=new Map,a={...is,...t.handlers},s={all:u,applyData:vp,definitionById:r,footnoteById:i,footnoteCounts:o,footnoteOrder:[],handlers:a,one:l,options:t,patch:wp,wrap:Sp};return Mt(e,function(c){if(c.type==="definition"||c.type==="footnoteDefinition"){let h=c.type==="definition"?r:i,d=String(c.identifier).toUpperCase();h.has(d)||h.set(d,c)}}),s;function l(c,h){let d=c.type,p=s.handlers[d];if(bi.call(s.handlers,d)&&p)return p(s,c,h);if(s.options.passThrough&&s.options.passThrough.includes(d)){if("children"in c){let{children:w,...k}=c,y=Te(k);return y.children=s.all(c),y}return Te(c)}return(s.options.unknownHandler||kp)(s,c,h)}function u(c){let h=[];if("children"in c){let d=c.children,p=-1;for(;++p<d.length;){let g=s.one(d[p],c);if(g){if(p&&d[p-1].type==="break"&&(!Array.isArray(g)&&g.type==="text"&&(g.value=as(g.value)),!Array.isArray(g)&&g.type==="element")){let w=g.children[0];w&&w.type==="text"&&(w.value=as(w.value))}Array.isArray(g)?h.push(...g):h.push(g)}}}return h}}function wp(e,n){e.position&&(n.position=xi(e))}function vp(e,n){let t=n;if(e&&e.data){let r=e.data.hName,i=e.data.hChildren,o=e.data.hProperties;if(typeof r=="string")if(t.type==="element")t.tagName=r;else{let a="children"in t?t.children:[t];t={type:"element",tagName:r,properties:{},children:a}}t.type==="element"&&o&&Object.assign(t.properties,Te(o)),"children"in t&&t.children&&i!==null&&i!==void 0&&(t.children=i)}return t}function kp(e,n){let t=n.data||{},r="value"in n&&!(bi.call(t,"hProperties")||bi.call(t,"hChildren"))?{type:"text",value:n.value}:{type:"element",tagName:"div",properties:{},children:e.all(n)};return e.patch(n,r),e.applyData(n,r)}function Sp(e,n){let t=[],r=-1;for(n&&t.push({type:"text",value:`
|
|
187
187
|
`});++r<e.length;)r&&t.push({type:"text",value:`
|
|
188
188
|
`}),t.push(e[r]);return n&&e.length>0&&t.push({type:"text",value:`
|
|
189
189
|
`}),t}function as(e){let n=0,t=e.charCodeAt(n);for(;t===9||t===32;)n++,t=e.charCodeAt(n);return e.slice(n)}function Dn(e,n){let t=ss(e,n),r=t.one(e,void 0),i=os(t),o=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return i&&("children"in o,o.children.push({type:"text",value:`
|
|
190
|
-
`},i)),o}function On(e,n){return e&&"run"in e?async function(t,r){let i=Dn(t,{file:r,...n});await e.run(i,r)}:function(t,r){return Dn(t,{file:r,...n||e})}}function wi(e){if(e)throw e}var Un=_i(gs(),1);function Xt(e){if(typeof e!="object"||e===null)return!1;let n=Object.getPrototypeOf(e);return(n===null||n===Object.prototype||Object.getPrototypeOf(n)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function vi(){let e=[],n={run:t,use:r};return n;function t(...i){let o=-1,a=i.pop();if(typeof a!="function")throw new TypeError("Expected function as last argument, not "+a);s(null,...i);function s(l,...u){let c=e[++o],h=-1;if(l){a(l);return}for(;++h<i.length;)(u[h]===null||u[h]===void 0)&&(u[h]=i[h]);i=u,c?ys(c,s)(...u):a(null,...u)}}function r(i){if(typeof i!="function")throw new TypeError("Expected `middelware` to be a function, not "+i);return e.push(i),n}}function ys(e,n){let t;return r;function r(...a){let s=e.length>a.length,l;s&&a.push(i);try{l=e.apply(this,a)}catch(u){let c=u;if(s&&t)throw c;return i(c)}s||(l&&l.then&&typeof l.then=="function"?l.then(o,i):l instanceof Error?i(l):o(l))}function i(a,...s){t||(t=!0,n(a,...s))}function o(a){i(null,a)}}var oe=class extends Error{constructor(n,t,r){super(),typeof t=="string"&&(r=t,t=void 0);let i="",o={},a=!1;if(t&&("line"in t&&"column"in t?o={place:t}:"start"in t&&"end"in t?o={place:t}:"type"in t?o={ancestors:[t],place:t.position}:o={...t}),typeof n=="string"?i=n:!o.cause&&n&&(a=!0,i=n.message,o.cause=n),!o.ruleId&&!o.source&&typeof r=="string"){let l=r.indexOf(":");l===-1?o.ruleId=r:(o.source=r.slice(0,l),o.ruleId=r.slice(l+1))}if(!o.place&&o.ancestors&&o.ancestors){let l=o.ancestors[o.ancestors.length-1];l&&(o.place=l.position)}let s=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=s?s.column:void 0,this.fatal=void 0,this.file,this.message=i,this.line=s?s.line:void 0,this.name=De(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=a&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual,this.expected,this.note,this.url}};oe.prototype.file="";oe.prototype.name="";oe.prototype.reason="";oe.prototype.message="";oe.prototype.stack="";oe.prototype.column=void 0;oe.prototype.line=void 0;oe.prototype.ancestors=void 0;oe.prototype.cause=void 0;oe.prototype.fatal=void 0;oe.prototype.place=void 0;oe.prototype.ruleId=void 0;oe.prototype.source=void 0;var Ce={basename:Cp,dirname:Ep,extname:Ip,join:Tp,sep:"/"};function Cp(e,n){if(n!==void 0&&typeof n!="string")throw new TypeError('"ext" argument must be a string');Dt(e);let t=0,r=-1,i=e.length,o;if(n===void 0||n.length===0||n.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(o){t=i+1;break}}else r<0&&(o=!0,r=i+1);return r<0?"":e.slice(t,r)}if(n===e)return"";let a=-1,s=n.length-1;for(;i--;)if(e.codePointAt(i)===47){if(o){t=i+1;break}}else a<0&&(o=!0,a=i+1),s>-1&&(e.codePointAt(i)===n.codePointAt(s--)?s<0&&(r=i):(s=-1,r=a));return t===r?r=a:r<0&&(r=e.length),e.slice(t,r)}function Ep(e){if(Dt(e),e.length===0)return".";let n=-1,t=e.length,r;for(;--t;)if(e.codePointAt(t)===47){if(r){n=t;break}}else r||(r=!0);return n<0?e.codePointAt(0)===47?"/":".":n===1&&e.codePointAt(0)===47?"//":e.slice(0,n)}function Ip(e){Dt(e);let n=e.length,t=-1,r=0,i=-1,o=0,a;for(;n--;){let s=e.codePointAt(n);if(s===47){if(a){r=n+1;break}continue}t<0&&(a=!0,t=n+1),s===46?i<0?i=n:o!==1&&(o=1):i>-1&&(o=-1)}return i<0||t<0||o===0||o===1&&i===t-1&&i===r+1?"":e.slice(i,t)}function Tp(...e){let n=-1,t;for(;++n<e.length;)Dt(e[n]),e[n]&&(t=t===void 0?e[n]:t+"/"+e[n]);return t===void 0?".":Ap(t)}function Ap(e){Dt(e);let n=e.codePointAt(0)===47,t=Lp(e,!n);return t.length===0&&!n&&(t="."),t.length>0&&e.codePointAt(e.length-1)===47&&(t+="/"),n?"/"+t:t}function Lp(e,n){let t="",r=0,i=-1,o=0,a=-1,s,l;for(;++a<=e.length;){if(a<e.length)s=e.codePointAt(a);else{if(s===47)break;s=47}if(s===47){if(!(i===a-1||o===1))if(i!==a-1&&o===2){if(t.length<2||r!==2||t.codePointAt(t.length-1)!==46||t.codePointAt(t.length-2)!==46){if(t.length>2){if(l=t.lastIndexOf("/"),l!==t.length-1){l<0?(t="",r=0):(t=t.slice(0,l),r=t.length-1-t.lastIndexOf("/")),i=a,o=0;continue}}else if(t.length>0){t="",r=0,i=a,o=0;continue}}n&&(t=t.length>0?t+"/..":"..",r=2)}else t.length>0?t+="/"+e.slice(i+1,a):t=e.slice(i+1,a),r=a-i-1;i=a,o=0}else s===46&&o>-1?o++:o=-1}return t}function Dt(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}var xs={cwd:Fp};function Fp(){return"/"}function ht(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function bs(e){if(typeof e=="string")e=new URL(e);else if(!ht(e)){let n=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw n.code="ERR_INVALID_ARG_TYPE",n}if(e.protocol!=="file:"){let n=new TypeError("The URL must be of scheme file");throw n.code="ERR_INVALID_URL_SCHEME",n}return Mp(e)}function Mp(e){if(e.hostname!==""){let r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}let n=e.pathname,t=-1;for(;++t<n.length;)if(n.codePointAt(t)===37&&n.codePointAt(t+1)===50){let r=n.codePointAt(t+2);if(r===70||r===102){let i=new TypeError("File URL path must not include encoded / characters");throw i.code="ERR_INVALID_FILE_URL_PATH",i}}return decodeURIComponent(n)}var ki=["history","path","basename","stem","extname","dirname"],Ot=class{constructor(n){let t;n?ht(n)?t={path:n}:typeof n=="string"||Rp(n)?t={value:n}:t=n:t={},this.cwd=xs.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<ki.length;){let o=ki[r];o in t&&t[o]!==void 0&&t[o]!==null&&(this[o]=o==="history"?[...t[o]]:t[o])}let i;for(i in t)ki.includes(i)||(this[i]=t[i])}get basename(){return typeof this.path=="string"?Ce.basename(this.path):void 0}set basename(n){Ci(n,"basename"),Si(n,"basename"),this.path=Ce.join(this.dirname||"",n)}get dirname(){return typeof this.path=="string"?Ce.dirname(this.path):void 0}set dirname(n){ws(this.basename,"dirname"),this.path=Ce.join(n||"",this.basename)}get extname(){return typeof this.path=="string"?Ce.extname(this.path):void 0}set extname(n){if(Si(n,"extname"),ws(this.dirname,"extname"),n){if(n.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(n.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=Ce.join(this.dirname,this.stem+(n||""))}get path(){return this.history[this.history.length-1]}set path(n){ht(n)&&(n=bs(n)),Ci(n,"path"),this.path!==n&&this.history.push(n)}get stem(){return typeof this.path=="string"?Ce.basename(this.path,this.extname):void 0}set stem(n){Ci(n,"stem"),Si(n,"stem"),this.path=Ce.join(this.dirname||"",n+(this.extname||""))}fail(n,t,r){let i=this.message(n,t,r);throw i.fatal=!0,i}info(n,t,r){let i=this.message(n,t,r);return i.fatal=void 0,i}message(n,t,r){let i=new oe(n,t,r);return this.path&&(i.name=this.path+":"+i.name,i.file=this.path),i.fatal=!1,this.messages.push(i),i}toString(n){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(n||void 0).decode(this.value)}};function Si(e,n){if(e&&e.includes(Ce.sep))throw new Error("`"+n+"` cannot be a path: did not expect `"+Ce.sep+"`")}function Ci(e,n){if(!e)throw new Error("`"+n+"` cannot be empty")}function ws(e,n){if(!e)throw new Error("Setting `"+n+"` requires `path` to be set too")}function Rp(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}var vs=function(e){let r=this.constructor.prototype,i=r[e],o=function(){return i.apply(o,arguments)};Object.setPrototypeOf(o,r);let a=Object.getOwnPropertyNames(i);for(let s of a){let l=Object.getOwnPropertyDescriptor(i,s);l&&Object.defineProperty(o,s,l)}return o};var zp={}.hasOwnProperty,Ai=class e extends vs{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=vi()}copy(){let n=new e,t=-1;for(;++t<this.attachers.length;){let r=this.attachers[t];n.use(...r)}return n.data((0,Un.default)(!0,{},this.namespace)),n}data(n,t){return typeof n=="string"?arguments.length===2?(Ti("data",this.frozen),this.namespace[n]=t,this):zp.call(this.namespace,n)&&this.namespace[n]||void 0:n?(Ti("data",this.frozen),this.namespace=n,this):this.namespace}freeze(){if(this.frozen)return this;let n=this;for(;++this.freezeIndex<this.attachers.length;){let[t,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;r[0]===!0&&(r[0]=void 0);let i=t.call(n,...r);typeof i=="function"&&this.transformers.use(i)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(n){this.freeze();let t=Hn(n),r=this.parser||this.Parser;return Ei("parse",r),r(String(t),t)}process(n,t){let r=this;return this.freeze(),Ei("process",this.parser||this.Parser),Ii("process",this.compiler||this.Compiler),t?i(void 0,t):new Promise(i);function i(o,a){let s=Hn(n),l=r.parse(s);r.run(l,s,function(c,h,d){if(c||!h||!d)return u(c);let p=h,g=r.stringify(p,d);Pp(g)?d.value=g:d.result=g,u(c,d)});function u(c,h){c||!h?a(c):o?o(h):t(void 0,h)}}}processSync(n){let t=!1,r;return this.freeze(),Ei("processSync",this.parser||this.Parser),Ii("processSync",this.compiler||this.Compiler),this.process(n,i),Ss("processSync","process",t),r;function i(o,a){t=!0,wi(o),r=a}}run(n,t,r){ks(n),this.freeze();let i=this.transformers;return!r&&typeof t=="function"&&(r=t,t=void 0),r?o(void 0,r):new Promise(o);function o(a,s){let l=Hn(t);i.run(n,l,u);function u(c,h,d){let p=h||n;c?s(c):a?a(p):r(void 0,p,d)}}}runSync(n,t){let r=!1,i;return this.run(n,t,o),Ss("runSync","run",r),i;function o(a,s){wi(a),i=s,r=!0}}stringify(n,t){this.freeze();let r=Hn(t),i=this.compiler||this.Compiler;return Ii("stringify",i),ks(n),i(n,r)}use(n,...t){let r=this.attachers,i=this.namespace;if(Ti("use",this.frozen),n!=null)if(typeof n=="function")l(n,t);else if(typeof n=="object")Array.isArray(n)?s(n):a(n);else throw new TypeError("Expected usable value, not `"+n+"`");return this;function o(u){if(typeof u=="function")l(u,[]);else if(typeof u=="object")if(Array.isArray(u)){let[c,...h]=u;l(c,h)}else a(u);else throw new TypeError("Expected usable value, not `"+u+"`")}function a(u){if(!("plugins"in u)&&!("settings"in u))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");s(u.plugins),u.settings&&(i.settings=(0,Un.default)(!0,i.settings,u.settings))}function s(u){let c=-1;if(u!=null)if(Array.isArray(u))for(;++c<u.length;){let h=u[c];o(h)}else throw new TypeError("Expected a list of plugins, not `"+u+"`")}function l(u,c){let h=-1,d=-1;for(;++h<r.length;)if(r[h][0]===u){d=h;break}if(d===-1)r.push([u,...c]);else if(c.length>0){let[p,...g]=c,w=r[d][1];Xt(w)&&Xt(p)&&(p=(0,Un.default)(!0,w,p)),r[d]=[u,p,...g]}}}},Li=new Ai().freeze();function Ei(e,n){if(typeof n!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Ii(e,n){if(typeof n!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Ti(e,n){if(n)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function ks(e){if(!Xt(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function Ss(e,n,t){if(!t)throw new Error("`"+e+"` finished async. Use `"+n+"` instead")}function Hn(e){return Zp(e)?e:new Ot(e)}function Zp(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function Pp(e){return typeof e=="string"||Np(e)}function Np(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}var _t=class extends ye{constructor(){super(...arguments);this.html=()=>`
|
|
190
|
+
`},i)),o}function On(e,n){return e&&"run"in e?async function(t,r){let i=Dn(t,{file:r,...n});await e.run(i,r)}:function(t,r){return Dn(t,{file:r,...n||e})}}function wi(e){if(e)throw e}var Un=_i(gs(),1);function Xt(e){if(typeof e!="object"||e===null)return!1;let n=Object.getPrototypeOf(e);return(n===null||n===Object.prototype||Object.getPrototypeOf(n)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function vi(){let e=[],n={run:t,use:r};return n;function t(...i){let o=-1,a=i.pop();if(typeof a!="function")throw new TypeError("Expected function as last argument, not "+a);s(null,...i);function s(l,...u){let c=e[++o],h=-1;if(l){a(l);return}for(;++h<i.length;)(u[h]===null||u[h]===void 0)&&(u[h]=i[h]);i=u,c?ys(c,s)(...u):a(null,...u)}}function r(i){if(typeof i!="function")throw new TypeError("Expected `middelware` to be a function, not "+i);return e.push(i),n}}function ys(e,n){let t;return r;function r(...a){let s=e.length>a.length,l;s&&a.push(i);try{l=e.apply(this,a)}catch(u){let c=u;if(s&&t)throw c;return i(c)}s||(l&&l.then&&typeof l.then=="function"?l.then(o,i):l instanceof Error?i(l):o(l))}function i(a,...s){t||(t=!0,n(a,...s))}function o(a){i(null,a)}}var oe=class extends Error{constructor(n,t,r){super(),typeof t=="string"&&(r=t,t=void 0);let i="",o={},a=!1;if(t&&("line"in t&&"column"in t?o={place:t}:"start"in t&&"end"in t?o={place:t}:"type"in t?o={ancestors:[t],place:t.position}:o={...t}),typeof n=="string"?i=n:!o.cause&&n&&(a=!0,i=n.message,o.cause=n),!o.ruleId&&!o.source&&typeof r=="string"){let l=r.indexOf(":");l===-1?o.ruleId=r:(o.source=r.slice(0,l),o.ruleId=r.slice(l+1))}if(!o.place&&o.ancestors&&o.ancestors){let l=o.ancestors[o.ancestors.length-1];l&&(o.place=l.position)}let s=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=s?s.column:void 0,this.fatal=void 0,this.file,this.message=i,this.line=s?s.line:void 0,this.name=De(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=a&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual,this.expected,this.note,this.url}};oe.prototype.file="";oe.prototype.name="";oe.prototype.reason="";oe.prototype.message="";oe.prototype.stack="";oe.prototype.column=void 0;oe.prototype.line=void 0;oe.prototype.ancestors=void 0;oe.prototype.cause=void 0;oe.prototype.fatal=void 0;oe.prototype.place=void 0;oe.prototype.ruleId=void 0;oe.prototype.source=void 0;var Ce={basename:Cp,dirname:Ep,extname:Ip,join:Tp,sep:"/"};function Cp(e,n){if(n!==void 0&&typeof n!="string")throw new TypeError('"ext" argument must be a string');Dt(e);let t=0,r=-1,i=e.length,o;if(n===void 0||n.length===0||n.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(o){t=i+1;break}}else r<0&&(o=!0,r=i+1);return r<0?"":e.slice(t,r)}if(n===e)return"";let a=-1,s=n.length-1;for(;i--;)if(e.codePointAt(i)===47){if(o){t=i+1;break}}else a<0&&(o=!0,a=i+1),s>-1&&(e.codePointAt(i)===n.codePointAt(s--)?s<0&&(r=i):(s=-1,r=a));return t===r?r=a:r<0&&(r=e.length),e.slice(t,r)}function Ep(e){if(Dt(e),e.length===0)return".";let n=-1,t=e.length,r;for(;--t;)if(e.codePointAt(t)===47){if(r){n=t;break}}else r||(r=!0);return n<0?e.codePointAt(0)===47?"/":".":n===1&&e.codePointAt(0)===47?"//":e.slice(0,n)}function Ip(e){Dt(e);let n=e.length,t=-1,r=0,i=-1,o=0,a;for(;n--;){let s=e.codePointAt(n);if(s===47){if(a){r=n+1;break}continue}t<0&&(a=!0,t=n+1),s===46?i<0?i=n:o!==1&&(o=1):i>-1&&(o=-1)}return i<0||t<0||o===0||o===1&&i===t-1&&i===r+1?"":e.slice(i,t)}function Tp(...e){let n=-1,t;for(;++n<e.length;)Dt(e[n]),e[n]&&(t=t===void 0?e[n]:t+"/"+e[n]);return t===void 0?".":Ap(t)}function Ap(e){Dt(e);let n=e.codePointAt(0)===47,t=Lp(e,!n);return t.length===0&&!n&&(t="."),t.length>0&&e.codePointAt(e.length-1)===47&&(t+="/"),n?"/"+t:t}function Lp(e,n){let t="",r=0,i=-1,o=0,a=-1,s,l;for(;++a<=e.length;){if(a<e.length)s=e.codePointAt(a);else{if(s===47)break;s=47}if(s===47){if(!(i===a-1||o===1))if(i!==a-1&&o===2){if(t.length<2||r!==2||t.codePointAt(t.length-1)!==46||t.codePointAt(t.length-2)!==46){if(t.length>2){if(l=t.lastIndexOf("/"),l!==t.length-1){l<0?(t="",r=0):(t=t.slice(0,l),r=t.length-1-t.lastIndexOf("/")),i=a,o=0;continue}}else if(t.length>0){t="",r=0,i=a,o=0;continue}}n&&(t=t.length>0?t+"/..":"..",r=2)}else t.length>0?t+="/"+e.slice(i+1,a):t=e.slice(i+1,a),r=a-i-1;i=a,o=0}else s===46&&o>-1?o++:o=-1}return t}function Dt(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}var xs={cwd:Mp};function Mp(){return"/"}function ht(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function bs(e){if(typeof e=="string")e=new URL(e);else if(!ht(e)){let n=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw n.code="ERR_INVALID_ARG_TYPE",n}if(e.protocol!=="file:"){let n=new TypeError("The URL must be of scheme file");throw n.code="ERR_INVALID_URL_SCHEME",n}return Fp(e)}function Fp(e){if(e.hostname!==""){let r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}let n=e.pathname,t=-1;for(;++t<n.length;)if(n.codePointAt(t)===37&&n.codePointAt(t+1)===50){let r=n.codePointAt(t+2);if(r===70||r===102){let i=new TypeError("File URL path must not include encoded / characters");throw i.code="ERR_INVALID_FILE_URL_PATH",i}}return decodeURIComponent(n)}var ki=["history","path","basename","stem","extname","dirname"],Ot=class{constructor(n){let t;n?ht(n)?t={path:n}:typeof n=="string"||Rp(n)?t={value:n}:t=n:t={},this.cwd=xs.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<ki.length;){let o=ki[r];o in t&&t[o]!==void 0&&t[o]!==null&&(this[o]=o==="history"?[...t[o]]:t[o])}let i;for(i in t)ki.includes(i)||(this[i]=t[i])}get basename(){return typeof this.path=="string"?Ce.basename(this.path):void 0}set basename(n){Ci(n,"basename"),Si(n,"basename"),this.path=Ce.join(this.dirname||"",n)}get dirname(){return typeof this.path=="string"?Ce.dirname(this.path):void 0}set dirname(n){ws(this.basename,"dirname"),this.path=Ce.join(n||"",this.basename)}get extname(){return typeof this.path=="string"?Ce.extname(this.path):void 0}set extname(n){if(Si(n,"extname"),ws(this.dirname,"extname"),n){if(n.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(n.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=Ce.join(this.dirname,this.stem+(n||""))}get path(){return this.history[this.history.length-1]}set path(n){ht(n)&&(n=bs(n)),Ci(n,"path"),this.path!==n&&this.history.push(n)}get stem(){return typeof this.path=="string"?Ce.basename(this.path,this.extname):void 0}set stem(n){Ci(n,"stem"),Si(n,"stem"),this.path=Ce.join(this.dirname||"",n+(this.extname||""))}fail(n,t,r){let i=this.message(n,t,r);throw i.fatal=!0,i}info(n,t,r){let i=this.message(n,t,r);return i.fatal=void 0,i}message(n,t,r){let i=new oe(n,t,r);return this.path&&(i.name=this.path+":"+i.name,i.file=this.path),i.fatal=!1,this.messages.push(i),i}toString(n){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(n||void 0).decode(this.value)}};function Si(e,n){if(e&&e.includes(Ce.sep))throw new Error("`"+n+"` cannot be a path: did not expect `"+Ce.sep+"`")}function Ci(e,n){if(!e)throw new Error("`"+n+"` cannot be empty")}function ws(e,n){if(!e)throw new Error("Setting `"+n+"` requires `path` to be set too")}function Rp(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}var vs=function(e){let r=this.constructor.prototype,i=r[e],o=function(){return i.apply(o,arguments)};Object.setPrototypeOf(o,r);let a=Object.getOwnPropertyNames(i);for(let s of a){let l=Object.getOwnPropertyDescriptor(i,s);l&&Object.defineProperty(o,s,l)}return o};var zp={}.hasOwnProperty,Ai=class e extends vs{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=vi()}copy(){let n=new e,t=-1;for(;++t<this.attachers.length;){let r=this.attachers[t];n.use(...r)}return n.data((0,Un.default)(!0,{},this.namespace)),n}data(n,t){return typeof n=="string"?arguments.length===2?(Ti("data",this.frozen),this.namespace[n]=t,this):zp.call(this.namespace,n)&&this.namespace[n]||void 0:n?(Ti("data",this.frozen),this.namespace=n,this):this.namespace}freeze(){if(this.frozen)return this;let n=this;for(;++this.freezeIndex<this.attachers.length;){let[t,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;r[0]===!0&&(r[0]=void 0);let i=t.call(n,...r);typeof i=="function"&&this.transformers.use(i)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(n){this.freeze();let t=Hn(n),r=this.parser||this.Parser;return Ei("parse",r),r(String(t),t)}process(n,t){let r=this;return this.freeze(),Ei("process",this.parser||this.Parser),Ii("process",this.compiler||this.Compiler),t?i(void 0,t):new Promise(i);function i(o,a){let s=Hn(n),l=r.parse(s);r.run(l,s,function(c,h,d){if(c||!h||!d)return u(c);let p=h,g=r.stringify(p,d);Pp(g)?d.value=g:d.result=g,u(c,d)});function u(c,h){c||!h?a(c):o?o(h):t(void 0,h)}}}processSync(n){let t=!1,r;return this.freeze(),Ei("processSync",this.parser||this.Parser),Ii("processSync",this.compiler||this.Compiler),this.process(n,i),Ss("processSync","process",t),r;function i(o,a){t=!0,wi(o),r=a}}run(n,t,r){ks(n),this.freeze();let i=this.transformers;return!r&&typeof t=="function"&&(r=t,t=void 0),r?o(void 0,r):new Promise(o);function o(a,s){let l=Hn(t);i.run(n,l,u);function u(c,h,d){let p=h||n;c?s(c):a?a(p):r(void 0,p,d)}}}runSync(n,t){let r=!1,i;return this.run(n,t,o),Ss("runSync","run",r),i;function o(a,s){wi(a),i=s,r=!0}}stringify(n,t){this.freeze();let r=Hn(t),i=this.compiler||this.Compiler;return Ii("stringify",i),ks(n),i(n,r)}use(n,...t){let r=this.attachers,i=this.namespace;if(Ti("use",this.frozen),n!=null)if(typeof n=="function")l(n,t);else if(typeof n=="object")Array.isArray(n)?s(n):a(n);else throw new TypeError("Expected usable value, not `"+n+"`");return this;function o(u){if(typeof u=="function")l(u,[]);else if(typeof u=="object")if(Array.isArray(u)){let[c,...h]=u;l(c,h)}else a(u);else throw new TypeError("Expected usable value, not `"+u+"`")}function a(u){if(!("plugins"in u)&&!("settings"in u))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");s(u.plugins),u.settings&&(i.settings=(0,Un.default)(!0,i.settings,u.settings))}function s(u){let c=-1;if(u!=null)if(Array.isArray(u))for(;++c<u.length;){let h=u[c];o(h)}else throw new TypeError("Expected a list of plugins, not `"+u+"`")}function l(u,c){let h=-1,d=-1;for(;++h<r.length;)if(r[h][0]===u){d=h;break}if(d===-1)r.push([u,...c]);else if(c.length>0){let[p,...g]=c,w=r[d][1];Xt(w)&&Xt(p)&&(p=(0,Un.default)(!0,w,p)),r[d]=[u,p,...g]}}}},Li=new Ai().freeze();function Ei(e,n){if(typeof n!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Ii(e,n){if(typeof n!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Ti(e,n){if(n)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function ks(e){if(!Xt(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function Ss(e,n,t){if(!t)throw new Error("`"+e+"` finished async. Use `"+n+"` instead")}function Hn(e){return Zp(e)?e:new Ot(e)}function Zp(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function Pp(e){return typeof e=="string"||Vp(e)}function Vp(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}var _t=class extends ye{constructor(){super(...arguments);this.html=()=>`
|
|
191
191
|
|
|
192
192
|
<!-- Styling -->
|
|
193
193
|
<style>
|
|
@@ -274,7 +274,7 @@ You have access to a database of knowledge base items. These include "info" type
|
|
|
274
274
|
<div class='llm-selector-item-icon' style="background-image: url('${r.icon}'); "></div>
|
|
275
275
|
<div class='llm-selector-item-name'>${r.name}</div>
|
|
276
276
|
<div class='llm-selector-item-provider'>${r.provider}</div>
|
|
277
|
-
`,i.addEventListener("click",o=>{this.dispatchEvent(new CustomEvent("select",{detail:r.id}))}),t.appendChild(i)}}};_t.observedAttributes=["open"];var dt=new U("ONNXModel"),Ee=class e{constructor(n){this.stateTensors={};this.constantTensors={};this._runActive=!1;this.ignoreIfBusy=!1;this.session=n,dt.debug(`Model input parameters: ${n.inputNames.join(", ")}`),dt.debug(`Model output parameters: ${n.outputNames.join(", ")}`)}static isSupported(){return!!e.lib}static async load(n){if(!e.lib)throw new Error("ONNX runtime not loaded, please set the runtime loader. Example: ONNXModel.lib = () => import('onnxruntime-web')");this.onnx||(dt.debug("Loading ONNX runtime"),this.onnx=await e.lib()),dt.debug(`Loading model: ${n}`);let t=await this.onnx.InferenceSession.create(n);return new e(t)}makeTensor(n,t,r=0){let i=1;for(let a of t)i*=a;let o;if(n=="float32")o=new e.onnx.Tensor(new Float32Array(i),t);else if(n=="int8")o=new e.onnx.Tensor(new Int8Array(i),t);else if(n=="int16")o=new e.onnx.Tensor(new Int16Array(i),t);else if(n=="int32")o=new e.onnx.Tensor(new Int32Array(i),t);else if(n=="int64")o=new e.onnx.Tensor(new BigInt64Array(i),t);else if(n=="uint8")o=new e.onnx.Tensor(new Uint8Array(i),t);else if(n=="uint16")o=new e.onnx.Tensor(new Uint16Array(i),t);else if(n=="uint32")o=new e.onnx.Tensor(new Uint32Array(i),t);else if(n=="uint64")o=new e.onnx.Tensor(new BigUint64Array(i),t);else throw new Error(`Invalid type: ${n}`);return r!==0&&(n=="int64"||n=="uint64")?o.data.fill(BigInt(r)):r!==0&&o.data.fill(r),o}registerConstant(n,t){if(!this.session.inputNames.includes(n))throw new Error(`Model does not have an input named: ${n}`);return this.constantTensors[n]=t,t}makeConstant(n,t,r,i=0){return this.registerConstant(n,this.makeTensor(t,r,i))}registerState(n,t,r){if(t||(t=n),!this.session.inputNames.includes(n))throw new Error(`Model does not have an input named: ${n}`);if(!this.session.outputNames.includes(t))throw new Error(`Model does not have an output named: ${t}`);return this.stateTensors[n]={outputName:t,tensor:r},r}makeState(n,t,r,i,o=0){return this.registerState(n,t,this.makeTensor(r,i,o))}async run(n={}){if(this._runActive&&this.ignoreIfBusy)return dt.debug("Ignoring run request because a previous run is still active");if(this._runActive)throw new Error("A previous run is still active");this._runActive=!0;for(let t in this.stateTensors)n[t]=this.stateTensors[t].tensor;for(let t in this.constantTensors)n[t]=this.constantTensors[t];try{let t=await this.session.run(n);for(let r in this.stateTensors){let i=t[this.stateTensors[r].outputName];this.stateTensors[r].tensor=i}return t}finally{this._runActive=!1}}resetState(){dt.debug("Resetting state tensors");for(let n in this.stateTensors)this.stateTensors[n].tensor.data.fill(0)}};var Cs="data:application/javascript;base64,dmFyIGM9Y2xhc3N7Y29uc3RydWN0b3IoaSx0KXt0aGlzLm91dHB1dEJ1ZmZlclNpemU9MDt0aGlzLnBhcnRpYWxCdWZmZXJzPVtdO3RoaXMucGFydGlhbEJ1ZmZlck9mZnNldD0wO2lmKCFpKXRocm93IG5ldyBFcnJvcihgSW52YWxpZCBhcnJheSBjbGFzczogJHtpfWApO2lmKCF0fHx0PD0wKXRocm93IG5ldyBFcnJvcihgSW52YWxpZCBvdXRwdXQgYnVmZmVyIHNpemU6ICR7dH1gKTt0aGlzLkFycmF5Q2xhc3M9aSx0aGlzLm91dHB1dEJ1ZmZlclNpemU9dH1nZXQgcXVldWVkU2l6ZSgpe3JldHVybiB0aGlzLnBhcnRpYWxCdWZmZXJzLnJlZHVjZSgoaSx0KT0+aSt0Lmxlbmd0aCwwKX1mZWVkKGkpe3RoaXMucGFydGlhbEJ1ZmZlcnMucHVzaChpKX1nZXQgY2FuRHJhaW4oKXtyZXR1cm4gdGhpcy5wYXJ0aWFsQnVmZmVycy5yZWR1Y2UoKHQscik9PnQrci5sZW5ndGgsMCktdGhpcy5wYXJ0aWFsQnVmZmVyT2Zmc2V0Pj10aGlzLm91dHB1dEJ1ZmZlclNpemV9ZHJhaW4oKXtpZighdGhpcy5jYW5EcmFpbilyZXR1cm4gbnVsbDtsZXQgaT10aGlzLkFycmF5Q2xhc3MsdD1uZXcgaSh0aGlzLm91dHB1dEJ1ZmZlclNpemUpLHI9MDtmb3IoO3IhPXQubGVuZ3RoOyl7aWYocj50Lmxlbmd0aCl0aHJvdyBuZXcgRXJyb3IoYEJ1ZmZlciBvdmVyZmxvdzogJHtyfSA+ICR7dC5sZW5ndGh9YCk7bGV0IGE9dC5sZW5ndGgtcixzPXRoaXMucGFydGlhbEJ1ZmZlcnNbMF0sZj1zLmxlbmd0aC10aGlzLnBhcnR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.sampleRate=0;this.format="int16";this.isCancelled=!1;if(!r||r<=0)throw new Error(`Invalid sample rate: ${r}`);if(!i||i!="int16"&&i!="float32")throw new Error(`Invalid format: ${i}`);this.sampleRate=r,this.format=i,this.port.onmessage=o=>this.onWorkletMessage(o),this.port.postMessage({action:"start",inputSampleRate:r,outputSampleRate:t.sampleRate,format:i})}feed(t){this.port.postMessage({action:"data",buffer:t.buffer},[t.buffer])}async play(t){if(this.isCancelled)throw new Error("PCMPlayerNode has already been cancelled.");if(this._playPromise)throw new Error("Already playing a stream");this._playPromise=new Promise(r=>this._playPromiseResolve=r),this.dispatchEvent(new CustomEvent("start",{detail:{player:this,stream:t}}));try{let r=t.getReader();for(;!this.isCancelled;){let{done:i,value:o}=await r.read();if(i||!o)break;this.feed(o)}}catch(r){Wp.warn("Stream error:",r),this.dispatchEvent(new CustomEvent("error",{detail:{player:this,stream:t,error:r}}))}this.port.postMessage({action:"end"}),await this._playPromise}onWorkletMessage(t){t.data.action=="end"&&(this._playPromiseResolve?.(),this.dispatchEvent(new CustomEvent("end",{detail:{player:this}})))}stop(){this.isCancelled=!0,this.port.postMessage({action:"cancel"}),this._playPromiseResolve?.()}};var Yn=new U("SpeechOutput"),Is=.5,Gp=.8,jn=class extends EventTarget{constructor(n){super(),this.ai=n,this.ai.addEventListener("output",t=>this.onTextOutputFromAI(t)),this.ai.audio?.speechRecognition.addEventListener("speechstart",t=>this.interrupt()),this.ai.knowledgeBase.registerSource(()=>[{id:"system.voice",type:"info",name:"Voice active",isContext:!0,disabled:!1,content:"Text-to-speech is active. The user can hear your voice."}])}onTextOutputFromAI(n){n.detail.isChunk||this.ai?.audio?.speechRecognition.isRunning&&this.speak(n.detail.message)}async speak(n){if(!this.ai?.config?.voice?.providerID)return Yn.warn("No voice provider configured");let t=`speech-${Xp++}`;await this.ai.audio.beginAccess(t);try{await this._speakWithLock(n)}finally{this.ai.audio.endAccess(t)}}async _speakWithLock(n){this.interrupt(),this.ai.audio.speechRecognition.voiceDetection&&(this.ai.audio.speechRecognition.voiceDetection.sensitivity=Gp);let t=this.ai?._voiceTracker||Yn.timer(`${this.ai.config.voice.providerID} voice`);t(`Speak: ${n}`),this.currentPlayerVolume?.disconnect(),this.currentPlayerVolume=this.ai.audio.context.createGain(),this.currentPlayerVolume.connect(this.ai.audio.context.destination);let r=this.currentPlayerVolume,i=new Kn(this.ai.audio.context,24e3,"int16");this.currentPlayer=i,i.connect(r),i.addEventListener("end",a=>{let s=a;t(`PCM stream ${s.detail.interrupted?"interrupted":"ended"}`),this.currentPlayer==i&&!s.detail.interrupted&&(this.currentPlayer=void 0,this.onSpeechEnd())});let o;if(this.ai.config.voice.providerID=="openai")o=await fetch("https://api.openai.com/v1/audio/speech",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.ai.config.voice.apiKey}`},body:JSON.stringify({model:"tts-1",input:n,voice:this.ai.config.voice.voiceID,response_format:"pcm"})});else if(this.ai.config.voice.providerID=="elevenlabs")o=await fetch(`https://api.elevenlabs.io/v1/text-to-speech/${this.ai.config.voice.voiceID}?output_format=pcm_24000`,{method:"POST",headers:{"xi-api-key":`${this.ai.config.voice.apiKey}`,"Content-Type":"application/json"},body:JSON.stringify({text:n})});else{Yn.warn(`Unknown voice provider: ${this.ai.config.voice.providerID}`);return}if(t(`Received response ${o.status} ${o.statusText}`),!o.ok){Yn.warn(`Failed to generate voice sample: ${o.status} ${o.statusText}`);return}this.dispatchEvent(new CustomEvent("speechstart",{detail:{ai:this.ai,message:n}})),t("Playing PCM stream"),await i.play(o.body),t("Audio has ended")}get isSpeaking(){return!!this.currentPlayer}async interrupt(){if(!this.currentPlayerVolume)return;let n=this.currentPlayerVolume,t=this.currentPlayer;this.currentPlayerVolume=void 0,this.currentPlayer=void 0,this.ai?.audio?.speechRecognition.voiceDetection&&(this.ai.audio.speechRecognition.voiceDetection.sensitivity=Is);let r=400;n.gain.linearRampToValueAtTime(0,r/1e3),await new Promise(i=>setTimeout(i,r+250)),n.disconnect(),t?.stop(),t?.disconnect()}onSpeechEnd(){this.dispatchEvent(new CustomEvent("speechend",{detail:{ai:this.ai}})),this.ai?.audio?.speechRecognition.voiceDetection&&(this.ai.audio.speechRecognition.voiceDetection.sensitivity=Is)}},Xp=1;function Jn(e,n){let t=n.reduce((l,u)=>l+u.byteLength,0),r=new DataView(new ArrayBuffer(44));r.setUint8(0,82),r.setUint8(1,73),r.setUint8(2,70),r.setUint8(3,70),r.setUint32(4,44+t,!0),r.setUint8(8,87),r.setUint8(9,65),r.setUint8(10,86),r.setUint8(11,69);let i=1,o=32,a=i*o/8,s=e*a;return r.setUint8(12,102),r.setUint8(13,109),r.setUint8(14,116),r.setUint8(15,32),r.setUint32(16,16,!0),r.setUint16(20,3,!0),r.setUint16(22,i,!0),r.setUint32(24,e,!0),r.setUint32(28,s,!0),r.setUint16(32,a,!0),r.setUint16(34,o,!0),r.setUint8(36,100),r.setUint8(37,97),r.setUint8(38,116),r.setUint8(39,97),r.setUint32(40,t,!0),new File([r,...n],"audio.wav",{type:"audio/wav"})}var Qn=class extends AudioWorkletNode{constructor(t,r,i,o){super(t,"pcm-receiver-node",{numberOfInputs:1});this.format="int16";this.format=i;let a=["int16","int64","float32"];if(!r||r<=0)throw new Error(`Invalid sample rate: ${r}`);if(!a.includes(i))throw new Error(`Invalid format ${i}, must be one of: ${a.join(", ")}`);if(!o||o<=0)throw new Error(`Invalid buffer size: ${o}`);this.port.onmessage=s=>this.onWorkletMessage(s),this.port.postMessage({action:"start",inputSampleRate:t.sampleRate,outputSampleRate:r,format:i,bufferSize:o})}onWorkletMessage(t){if(t.data.action=="data"){let r=null;if(this.format=="int16"&&(r=new Int16Array(t.data.buffer)),this.format=="int64"&&(r=new BigInt64Array(t.data.buffer)),this.format=="float32"&&(r=new Float32Array(t.data.buffer)),!r)throw new Error(`Invalid format: ${this.format}`);this.onData(r),this.dispatchEvent(new CustomEvent("data",{detail:{data:r}}))}}onData(t){}};var Fi=16e3,qn=256,ft=8,Ht=new U("VoiceDetectionNode"),Ut=class Ut extends Qn{constructor(t){super(t,Fi,"float32",qn*ft);this.isVoiceActive=!1;this.lastVoiceActiveDate=0;this.voiceEndTimeout=50;this.sensitivity=.5;this.sentivityEnd=.2;this.nextVadReset=0;this.currentProbability=0;this._lastVoiceActive=!1;if(!Ut.vadModelURL)throw new Error("VAD model url not set, please load it and set it to VoiceDetectionNode.vadModelURL");this.loadModel()}get isVoicePossiblyEnding(){return this.isVoiceActive&&this.currentProbability<this.sensitivity}get sampleRate(){return Fi}get numberOfSamples(){return qn}get numberOfSampleChunks(){return ft}get outputBufferSize(){return qn*ft}get isModelLoaded(){return!!this.vad}async loadModel(){Ht.debug("Loading VAD model"),this.vad=await Ee.load(Ut.vadModelURL),this.vad.ignoreIfBusy=!0,Ht.debug("Model loaded"),this.vad.makeConstant("sr","int64",[1],Fi),this.vad.makeState("h","hn","float32",[2,ft,64]),this.vad.makeState("c","cn","float32",[2,ft,64])}async onData(t){if(this.vad)try{let r=await this.vad.run({input:new Ee.onnx.Tensor(t,[ft,qn])});if(!r)return;this.currentProbability=0;for(let a=0;a<r.output.data.length;a++)r.output.data[a]>this.currentProbability&&(this.currentProbability=r.output.data[a]);let i=this.isVoiceActive?this.sentivityEnd:this.sensitivity,o=this.currentProbability>i;if(!o&&this._lastVoiceActive&&(this.nextVadReset=Date.now(),this.vad.resetState()),this._lastVoiceActive=o,o&&!this.isVoiceActive?(this.lastVoiceActiveDate=Date.now(),this.isVoiceActive=!0,this.dispatchEvent(new CustomEvent("speechstart")),this.onSpeechStart(),Ht.debug("Started speaking")):o?this.lastVoiceActiveDate=Date.now():!o&&this.isVoiceActive&&Date.now()<this.lastVoiceActiveDate+this.voiceEndTimeout||!o&&this.isVoiceActive&&(this.isVoiceActive=!1,this.dispatchEvent(new CustomEvent("speechend")),this.onSpeechEnd(),Ht.debug("Stopped speaking after timeout")),!o){let a=Date.now();a>this.nextVadReset&&(this.nextVadReset=a+5e3,this.vad.resetState())}}catch(r){Ht.error("VAD failed:",r)}}onSpeechStart(){}onSpeechEnd(){}};Ut.vadModelURL="";var mt=Ut;var Ts=new U("VoiceChunkOutputNode"),gt=class extends mt{constructor(){super(...arguments);this.buffers=[];this.recordedBuffers=[];this._voiceRecording=!1;this.backBufferDurationSeconds=3}get bufferDuration(){return this.buffers.reduce((t,r)=>t+r.length,0)/8e3}async onData(t){if(await super.onData(t),this.isVoiceActive&&!this._voiceRecording){Ts.debug(`Voice detected, sending ${this.buffers.length} existing chunks`),this._voiceRecording=!0;for(let r of this.buffers)this.recordedBuffers.push(r),this.dispatchEvent(new CustomEvent("voicedata",{detail:{data:r,isFinal:!1}})),this.onVoiceChunk(r);this.recordedBuffers.push(t),this.dispatchEvent(new CustomEvent("voicedata",{detail:{data:t,isFinal:!1}})),this.onVoiceChunk(t),this.buffers=[]}else if(this.isVoiceActive)this.recordedBuffers.push(t),this.dispatchEvent(new CustomEvent("voicedata",{detail:{data:t,isFinal:!1}})),this.onVoiceChunk(t);else if(!this.isVoiceActive&&this._voiceRecording){this.recordedBuffers.push(t),this.dispatchEvent(new CustomEvent("voicedata",{detail:{data:t,isFinal:!0}})),this.onVoiceChunk(t),this._voiceRecording=!1;let r=this.recordedBuffers.reduce((i,o)=>i+o.length,0);Ts.debug(`Voice complete, recorded ${(r/8e3).toFixed(2)} seconds of audio, ${r*4/1024} KB of data`),this.dispatchEvent(new CustomEvent("voicedataend",{detail:{data:this.recordedBuffers}})),this.onVoiceEnd(this.recordedBuffers),this.recordedBuffers=[]}else for(this.buffers.push(t);this.bufferDuration>this.backBufferDurationSeconds;)this.buffers.shift()}onVoiceChunk(t){}onVoiceEnd(t){}};var $n=new U("OpenAITranscriptionNode"),er=class extends gt{constructor(t,r){super(t);this.apiKey="";this.pendingBuffers=[];this.isTranscribing=!1;this.apiKey=r}async onVoiceEnd(t){let r=$n.timer("OpenAI Transcribe");this.isTranscribing=!0,this.pendingBuffers.push(...t);let i=Jn(this.sampleRate,this.pendingBuffers);this.lastRequestAbortController?.abort(),this.lastRequestAbortController=new AbortController;let o="";try{let a=new FormData;a.append("file",i),a.append("model","whisper-1"),a.append("response_format","text");let s=await fetch("https://api.openai.com/v1/audio/transcriptions",{method:"POST",headers:{Authorization:`Bearer ${this.apiKey}`},body:a,signal:this.lastRequestAbortController.signal});if(!s.ok)throw new Error(`Failed to generate voice sample: ${s.status} ${s.statusText}`);r("Response received"),o=await s.text(),r("Content received: "+o),this.lastRequestAbortController=void 0}catch(a){$n.error(`Failed to transcribe speech: ${a.message}`);return}finally{this.isTranscribing=!1}if(this.pendingBuffers=[],!o)return $n.debug("Transcription complete, but no text was found");$n.debug(`Transcription: ${o}`),this.onVoiceTranscription(o),this.dispatchEvent(new CustomEvent("transcription",{detail:{text:o}}))}onVoiceTranscription(t){}};var tr=class extends WebSocket{constructor(t){super(t);this.pendingData=[];this.addEventListener("open",()=>this._onOpen())}send(t){this.readyState==WebSocket.OPEN?super.send(t):this.pendingData.push(t)}_onOpen(){for(let t of this.pendingData)super.send(t);this.pendingData=[]}};var Fe=new U("IntelliWeaveTranscriptionNode"),Dp="wss://speech.intelliweave.ai/api/v1/transcribe",rr=class rr extends gt{constructor(t,r){super(t);this.apiAddress=Dp;this.apiKey="";this.isTranscribing=!1;this.apiKey=r}async onVoiceChunk(t){this.isTranscribing=!0,this.ws?this.ws.send(t):(Fe.debug("Opening WebSocket connection"),this.ws=new tr(this.apiAddress),this.ws.send(JSON.stringify({type:"hello",sampleRate:16e3,channels:1,format:"float32",apiKey:this.apiKey})),this.ws.send(t.buffer),this.ws.onopen=()=>{Fe.debug("WebSocket connection opened")},this.ws.addEventListener("message",i=>{let o=JSON.parse(i.data);if(o.error)return Fe.warn("Error: "+o.error);if(o.type!="transcription")return Fe.warn("Invalid response type",o);if(o.streaming&&!o.final)return Fe.debug("Partial transcription: "+o.partialText);if(this.isTranscribing=!1,!o.text.trim())return Fe.warn(`Empty transcription (${o.processingTime}ms)`);Fe.debug(`Transcription: ${o.text} (${o.processingTime}ms)`),this.onVoiceTranscription(o.text),this.dispatchEvent(new CustomEvent("transcription",{detail:{text:o.text}}))}),this.ws.addEventListener("close",()=>this.onSocketClose()),this.ws.addEventListener("error",i=>Fe.warn("WebSocket error")));let r=1e3*60*1;this.shutdownTimer&&clearTimeout(this.shutdownTimer),this.shutdownTimer=setTimeout(()=>{Fe.debug("Shutting down WebSocket connection"),this.ws?.close(),this.ws=void 0},r)}async onVoiceEnd(t){if(this.ws?.send(JSON.stringify({type:"end"})),rr.debugExportWav){let r=Jn(this.sampleRate,t),i=document.createElement("a");i.href=URL.createObjectURL(r),i.download="recording.wav",i.click()}}onVoiceTranscription(t){}onSocketClose(){Fe.debug("WebSocket connection closed"),this.ws=void 0,this.isTranscribing=!1}};rr.debugExportWav=!1;var nr=rr;var Mi=new U("SpeechRecognition"),ir=class extends EventTarget{constructor(t){super();this.isRunning=!1;this._skipEvents=!1;this.maxVolumeHeard=0;this.ai=t,this.ai.knowledgeBase.registerSource(()=>[{id:"system.microphone.enable",type:"action",name:"Enable or disable microphone",isContext:!0,content:`Starts or stops listening to input from the user through the microphone. ${this.isRunning?"Microphone access is currently enabled and you can hear the user.":"Microphone access is currently disabled."}.`,parameters:[{name:"enable",type:"boolean",description:"If true, enables the microphone. If false, disables it."}],action:async r=>{r.enable?await this.start():this.stop()}}])}get isSupported(){if(!Ee.lib||!this.ai?.vadModel||!Be().AudioWorkletNode)return!1;if(this.ai?.config?.transcription?.providerID!="intelliweave"){if(!(this.ai?.config?.transcription?.providerID=="openai"&&this.ai.config?.transcription?.apiKey))return!1}return!0}async start(){if(!this.isSupported)throw new Error("Speech recognition not supported in this persona and browser.");if(!this.isRunning){this.isRunning=!0;try{await this.ai.audio.beginAccess("speech-recognition"),this.micStream=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0}});let t=this.ai.audio.context.createMediaStreamSource(this.micStream);this.analyserNode=this.ai.audio.context.createAnalyser(),this.analyserNode.fftSize=32,t.connect(this.analyserNode),this.analyserBuffer=new Float32Array(this.analyserNode.fftSize),mt.vadModelURL=URL.createObjectURL(this.ai.vadModel),this.ai?.config?.transcription?.providerID=="openai"?(this.voiceDetection=new er(this.ai.audio.context,this.ai.config.transcription.apiKey),t.connect(this.voiceDetection)):(this.voiceDetection=new nr(this.ai.audio.context,this.ai.apiKey),this.voiceDetection.apiAddress=this.ai?.config?.transcription?.url||this.voiceDetection.apiAddress,t.connect(this.voiceDetection)),this.voiceDetection.addEventListener("speechstart",r=>{this.ai._voiceTracker=Mi.timer("voice interaction","Speech started"),this.dispatchEvent(new CustomEvent(r.type,{detail:r.detail}))}),this.voiceDetection.addEventListener("speechend",r=>{this.ai._voiceTracker?.("Speech ended"),this.dispatchEvent(new CustomEvent(r.type,{detail:r.detail}))}),this.voiceDetection.addEventListener("transcription",r=>{this.ai._voiceTracker?.(`Transcription: ${r.detail.text}`),this.onTranscription(r)}),this._skipEvents||this.dispatchEvent(new CustomEvent("start",{detail:{speechRecognition:this}}))}catch(t){Mi.error("Failed to start speech recognition:",t),this.stop()}}}stop(){this.isRunning&&(this.isRunning=!1,this.ai.audio.endAccess("speech-recognition"),this.voiceDetection?.disconnect(),this.voiceDetection=void 0,this.micStream?.getTracks().forEach(t=>t.stop()),this.micStream=void 0,this.analyserNode=void 0,this.analyserBuffer=void 0,this._skipEvents||this.dispatchEvent(new CustomEvent("end",{detail:{speechRecognition:this}})))}get volumeLevel(){if(!this.analyserNode||!this.analyserBuffer)return 0;this.analyserNode.getFloatTimeDomainData(this.analyserBuffer);let t=0;for(let i of this.analyserBuffer)t+=i*i;let r=Math.sqrt(t/this.analyserBuffer.length);return r>this.maxVolumeHeard&&(this.maxVolumeHeard=r),this.maxVolumeHeard*=.999,this.maxVolumeHeard<.01&&(this.maxVolumeHeard=.01),Math.min(1,Math.max(0,r/this.maxVolumeHeard))}get wordsCurrentlyBeingSpoken(){return!!this.voiceDetection?.isVoiceActive}get isTranscribing(){return!!this.voiceDetection?.isTranscribing}onTranscription(t){let r=t.detail.text;Mi.debug("Heard:",r),this.dispatchEvent(new CustomEvent("speech",{detail:{transcript:r,isFinal:!0}}))}async reset(){if(this.isRunning){this._skipEvents=!0;try{this.stop(),await this.start(),this._skipEvents=!1}catch(t){throw this._skipEvents=!1,t}}}};var or=new U("AudioSystem"),yt=class{constructor(n){this.locks=[];if(!n)throw new Error("AI reference is required. Please pass in the IntelliWeave instance to the constructor.");this.ai=n,this.ai.audio=this,this.speechRecognition=new ir(this.ai),this.speechOutput=new jn(this.ai)}static get isSupported(){return!(!Ee.lib||!Be().AudioWorkletNode)}async beginAccess(n){or.debug(`Began access for: ${n}`),this.locks.includes(n)||this.locks.push(n),!this.context&&(or.debug("Creating AudioContext"),this.context=new AudioContext({latencyHint:"interactive"}),this.context.resume(),await Promise.all([this.context.audioWorklet.addModule(Cs),this.context.audioWorklet.addModule(Es)]))}endAccess(n){or.debug(`Ended access for: ${n}`),this.locks=this.locks.filter(t=>t!=n),!this.locks.length&&(or.debug("Closing AudioContext"),this.context?.close(),this.context=void 0)}};var Kw=new U("Stream");var et=_i(Xs(),1);var nv=new U("React");var rv=(0,et.createContext)(void 0);var Vi=new U("Embed"),tt=class extends ye{constructor(){super();this.config={};this.suggestions=[];this.html=()=>`
|
|
277
|
+
`,i.addEventListener("click",o=>{this.dispatchEvent(new CustomEvent("select",{detail:r.id}))}),t.appendChild(i)}}};_t.observedAttributes=["open"];var dt=new U("ONNXModel"),Ee=class e{constructor(n){this.stateTensors={};this.constantTensors={};this._runActive=!1;this.ignoreIfBusy=!1;this.session=n,dt.debug(`Model input parameters: ${n.inputNames.join(", ")}`),dt.debug(`Model output parameters: ${n.outputNames.join(", ")}`)}static isSupported(){return!!e.lib}static async load(n){if(!e.lib)throw new Error("ONNX runtime not loaded, please set the runtime loader. Example: ONNXModel.lib = () => import('onnxruntime-web')");this.onnx||(dt.debug("Loading ONNX runtime"),this.onnx=await e.lib()),dt.debug(`Loading model: ${n}`);let t=await this.onnx.InferenceSession.create(n);return new e(t)}makeTensor(n,t,r=0){let i=1;for(let a of t)i*=a;let o;if(n=="float32")o=new e.onnx.Tensor(new Float32Array(i),t);else if(n=="int8")o=new e.onnx.Tensor(new Int8Array(i),t);else if(n=="int16")o=new e.onnx.Tensor(new Int16Array(i),t);else if(n=="int32")o=new e.onnx.Tensor(new Int32Array(i),t);else if(n=="int64")o=new e.onnx.Tensor(new BigInt64Array(i),t);else if(n=="uint8")o=new e.onnx.Tensor(new Uint8Array(i),t);else if(n=="uint16")o=new e.onnx.Tensor(new Uint16Array(i),t);else if(n=="uint32")o=new e.onnx.Tensor(new Uint32Array(i),t);else if(n=="uint64")o=new e.onnx.Tensor(new BigUint64Array(i),t);else throw new Error(`Invalid type: ${n}`);return r!==0&&(n=="int64"||n=="uint64")?o.data.fill(BigInt(r)):r!==0&&o.data.fill(r),o}registerConstant(n,t){if(!this.session.inputNames.includes(n))throw new Error(`Model does not have an input named: ${n}`);return this.constantTensors[n]=t,t}makeConstant(n,t,r,i=0){return this.registerConstant(n,this.makeTensor(t,r,i))}registerState(n,t,r){if(t||(t=n),!this.session.inputNames.includes(n))throw new Error(`Model does not have an input named: ${n}`);if(!this.session.outputNames.includes(t))throw new Error(`Model does not have an output named: ${t}`);return this.stateTensors[n]={outputName:t,tensor:r},r}makeState(n,t,r,i,o=0){return this.registerState(n,t,this.makeTensor(r,i,o))}async run(n={}){if(this._runActive&&this.ignoreIfBusy)return dt.debug("Ignoring run request because a previous run is still active");if(this._runActive)throw new Error("A previous run is still active");this._runActive=!0;for(let t in this.stateTensors)n[t]=this.stateTensors[t].tensor;for(let t in this.constantTensors)n[t]=this.constantTensors[t];try{let t=await this.session.run(n);for(let r in this.stateTensors){let i=t[this.stateTensors[r].outputName];this.stateTensors[r].tensor=i}return t}finally{this._runActive=!1}}resetState(){dt.debug("Resetting state tensors");for(let n in this.stateTensors)this.stateTensors[n].tensor.data.fill(0)}};var Cs="data:application/javascript;base64,dmFyIGM9Y2xhc3N7Y29uc3R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HQsaSxmKXtmb3IobGV0IGE9MDthPGkubGVuZ3RoO2ErKyl7bGV0IHM9TWF0aC5taW4oaVthXS5sZW5ndGgsdFswXS5sZW5ndGgpO2ZvcihsZXQgcj0wO3I8cztyKyspaVthXVtyXS5zZXQodFswXVtyXSl9aWYoIXRoaXMucmVzYW1wbGVyKXJldHVybiEwO2xldCBoPW5ldyBGbG9hdDMyQXJyYXkoaVswXVswXS5sZW5ndGgpO2ZvcihoLnNldChpWzBdWzBdKSx0aGlzLmlucHV0QnVmZmVyLmZlZWQoaCk7dGhpcy5pbnB1dEJ1ZmZlci5jYW5EcmFpbjspe2xldCBhPXRoaXMuaW5wdXRCdWZmZXIuZHJhaW4oKSxzPXRoaXMucmVzYW1wbGVyLnJlc2FtcGxlKGEpO3RoaXMuZm9ybWF0PT0iaW50MTYiP3RoaXMub3V0cHV0QnVmZmVyLmZlZWQoZChzKSk6dGhpcy5mb3JtYXQ9PSJpbnQ2NCI/dGhpcy5vdXRwdXRCdWZmZXIuZmVlZCh3KHMpKTp0aGlzLmZvcm1hdD09ImZsb2F0MzIiJiZ0aGlzLm91dHB1dEJ1ZmZlci5mZWVkKHMpfWZvcig7dGhpcy5vdXRwdXRCdWZmZXIuY2FuRHJhaW47KXtsZXQgYT10aGlzLm91dHB1dEJ1ZmZlci5kcmFpbigpO2lmKCFhKWJyZWFrO3RoaXMucG9ydC5wb3N0TWVzc2FnZSh7YWN0aW9uOiJkYXRhIixidWZmZXI6YS5idWZmZXJ9LFthLmJ1ZmZlcl0pfXJldHVybiEwfX07cmVnaXN0ZXJQcm9jZXNzb3IoInBjbS1yZWNlaXZlci1ub2RlIix5KTsK";var Wp=new U("PCMPlayerNode"),Kn=class extends AudioWorkletNode{constructor(t,r,i){super(t,"pcm-player-node",{numberOfInputs:0});this.sampleRate=0;this.format="int16";this.isCancelled=!1;if(!r||r<=0)throw new Error(`Invalid sample rate: ${r}`);if(!i||i!="int16"&&i!="float32")throw new Error(`Invalid format: ${i}`);this.sampleRate=r,this.format=i,this.port.onmessage=o=>this.onWorkletMessage(o),this.port.postMessage({action:"start",inputSampleRate:r,outputSampleRate:t.sampleRate,format:i})}feed(t){this.port.postMessage({action:"data",buffer:t.buffer},[t.buffer])}async play(t){if(this.isCancelled)throw new Error("PCMPlayerNode has already been cancelled.");if(this._playPromise)throw new Error("Already playing a stream");this._playPromise=new Promise(r=>this._playPromiseResolve=r),this.dispatchEvent(new CustomEvent("start",{detail:{player:this,stream:t}}));try{let r=t.getReader();for(;!this.isCancelled;){let{done:i,value:o}=await r.read();if(i||!o)break;this.feed(o)}}catch(r){Wp.warn("Stream error:",r),this.dispatchEvent(new CustomEvent("error",{detail:{player:this,stream:t,error:r}}))}this.port.postMessage({action:"end"}),await this._playPromise}onWorkletMessage(t){t.data.action=="end"&&(this._playPromiseResolve?.(),this.dispatchEvent(new CustomEvent("end",{detail:{player:this}})))}stop(){this.isCancelled=!0,this.port.postMessage({action:"cancel"}),this._playPromiseResolve?.()}};var Yn=new U("SpeechOutput"),Is=.5,Gp=.8,jn=class extends EventTarget{constructor(n){super(),this.ai=n,this.ai.addEventListener("output",t=>this.onTextOutputFromAI(t)),this.ai.audio?.speechRecognition.addEventListener("speechstart",t=>this.interrupt()),this.ai.knowledgeBase.registerSource(()=>[{id:"system.voice",type:"info",name:"Voice active",isContext:!0,disabled:!1,content:"Text-to-speech is active. The user can hear your voice."}])}onTextOutputFromAI(n){n.detail.isChunk||this.ai?.audio?.speechRecognition.isRunning&&this.speak(n.detail.message)}async speak(n){if(!this.ai?.config?.voice?.providerID)return Yn.warn("No voice provider configured");let t=`speech-${Xp++}`;await this.ai.audio.beginAccess(t);try{await this._speakWithLock(n)}finally{this.ai.audio.endAccess(t)}}async _speakWithLock(n){this.interrupt(),this.ai.audio.speechRecognition.voiceDetection&&(this.ai.audio.speechRecognition.voiceDetection.sensitivity=Gp);let t=this.ai?._voiceTracker||Yn.timer(`${this.ai.config.voice.providerID} voice`);t(`Speak: ${n}`),this.currentPlayerVolume?.disconnect(),this.currentPlayerVolume=this.ai.audio.context.createGain(),this.currentPlayerVolume.connect(this.ai.audio.context.destination);let r=this.currentPlayerVolume,i=new Kn(this.ai.audio.context,24e3,"int16");this.currentPlayer=i,i.connect(r),i.addEventListener("end",a=>{let s=a;t(`PCM stream ${s.detail.interrupted?"interrupted":"ended"}`),this.currentPlayer==i&&!s.detail.interrupted&&(this.currentPlayer=void 0,this.onSpeechEnd())});let o;if(this.ai.config.voice.providerID=="openai")o=await fetch("https://api.openai.com/v1/audio/speech",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.ai.config.voice.apiKey}`},body:JSON.stringify({model:"tts-1",input:n,voice:this.ai.config.voice.voiceID,response_format:"pcm"})});else if(this.ai.config.voice.providerID=="elevenlabs")o=await fetch(`https://api.elevenlabs.io/v1/text-to-speech/${this.ai.config.voice.voiceID}?output_format=pcm_24000`,{method:"POST",headers:{"xi-api-key":`${this.ai.config.voice.apiKey}`,"Content-Type":"application/json"},body:JSON.stringify({text:n})});else{Yn.warn(`Unknown voice provider: ${this.ai.config.voice.providerID}`);return}if(t(`Received response ${o.status} ${o.statusText}`),!o.ok){Yn.warn(`Failed to generate voice sample: ${o.status} ${o.statusText}`);return}this.dispatchEvent(new CustomEvent("speechstart",{detail:{ai:this.ai,message:n}})),t("Playing PCM stream"),await i.play(o.body),t("Audio has ended")}get isSpeaking(){return!!this.currentPlayer}async interrupt(){if(!this.currentPlayerVolume)return;let n=this.currentPlayerVolume,t=this.currentPlayer;this.currentPlayerVolume=void 0,this.currentPlayer=void 0,this.ai?.audio?.speechRecognition.voiceDetection&&(this.ai.audio.speechRecognition.voiceDetection.sensitivity=Is);let r=400;n.gain.linearRampToValueAtTime(0,r/1e3),await new Promise(i=>setTimeout(i,r+250)),n.disconnect(),t?.stop(),t?.disconnect()}onSpeechEnd(){this.dispatchEvent(new CustomEvent("speechend",{detail:{ai:this.ai}})),this.ai?.audio?.speechRecognition.voiceDetection&&(this.ai.audio.speechRecognition.voiceDetection.sensitivity=Is)}},Xp=1;function Jn(e,n){let t=n.reduce((l,u)=>l+u.byteLength,0),r=new DataView(new ArrayBuffer(44));r.setUint8(0,82),r.setUint8(1,73),r.setUint8(2,70),r.setUint8(3,70),r.setUint32(4,44+t,!0),r.setUint8(8,87),r.setUint8(9,65),r.setUint8(10,86),r.setUint8(11,69);let i=1,o=32,a=i*o/8,s=e*a;return r.setUint8(12,102),r.setUint8(13,109),r.setUint8(14,116),r.setUint8(15,32),r.setUint32(16,16,!0),r.setUint16(20,3,!0),r.setUint16(22,i,!0),r.setUint32(24,e,!0),r.setUint32(28,s,!0),r.setUint16(32,a,!0),r.setUint16(34,o,!0),r.setUint8(36,100),r.setUint8(37,97),r.setUint8(38,116),r.setUint8(39,97),r.setUint32(40,t,!0),new File([r,...n],"audio.wav",{type:"audio/wav"})}var Qn=class extends AudioWorkletNode{constructor(t,r,i,o){super(t,"pcm-receiver-node",{numberOfInputs:1});this.format="int16";this.format=i;let a=["int16","int64","float32"];if(!r||r<=0)throw new Error(`Invalid sample rate: ${r}`);if(!a.includes(i))throw new Error(`Invalid format ${i}, must be one of: ${a.join(", ")}`);if(!o||o<=0)throw new Error(`Invalid buffer size: ${o}`);this.port.onmessage=s=>this.onWorkletMessage(s),this.port.postMessage({action:"start",inputSampleRate:t.sampleRate,outputSampleRate:r,format:i,bufferSize:o})}onWorkletMessage(t){if(t.data.action=="data"){let r=null;if(this.format=="int16"&&(r=new Int16Array(t.data.buffer)),this.format=="int64"&&(r=new BigInt64Array(t.data.buffer)),this.format=="float32"&&(r=new Float32Array(t.data.buffer)),!r)throw new Error(`Invalid format: ${this.format}`);this.onData(r),this.dispatchEvent(new CustomEvent("data",{detail:{data:r}}))}}onData(t){}};var Mi=16e3,qn=256,ft=8,Ht=new U("VoiceDetectionNode"),Ut=class Ut extends Qn{constructor(t){super(t,Mi,"float32",qn*ft);this.isVoiceActive=!1;this.lastVoiceActiveDate=0;this.voiceEndTimeout=50;this.sensitivity=.5;this.sentivityEnd=.2;this.nextVadReset=0;this.currentProbability=0;this._lastVoiceActive=!1;if(!Ut.vadModelURL)throw new Error("VAD model url not set, please load it and set it to VoiceDetectionNode.vadModelURL");this.loadModel()}get isVoicePossiblyEnding(){return this.isVoiceActive&&this.currentProbability<this.sensitivity}get sampleRate(){return Mi}get numberOfSamples(){return qn}get numberOfSampleChunks(){return ft}get outputBufferSize(){return qn*ft}get isModelLoaded(){return!!this.vad}async loadModel(){Ht.debug("Loading VAD model"),this.vad=await Ee.load(Ut.vadModelURL),this.vad.ignoreIfBusy=!0,Ht.debug("Model loaded"),this.vad.makeConstant("sr","int64",[1],Mi),this.vad.makeState("h","hn","float32",[2,ft,64]),this.vad.makeState("c","cn","float32",[2,ft,64])}async onData(t){if(this.vad)try{let r=await this.vad.run({input:new Ee.onnx.Tensor(t,[ft,qn])});if(!r)return;this.currentProbability=0;for(let a=0;a<r.output.data.length;a++)r.output.data[a]>this.currentProbability&&(this.currentProbability=r.output.data[a]);let i=this.isVoiceActive?this.sentivityEnd:this.sensitivity,o=this.currentProbability>i;if(!o&&this._lastVoiceActive&&(this.nextVadReset=Date.now(),this.vad.resetState()),this._lastVoiceActive=o,o&&!this.isVoiceActive?(this.lastVoiceActiveDate=Date.now(),this.isVoiceActive=!0,this.dispatchEvent(new CustomEvent("speechstart")),this.onSpeechStart(),Ht.debug("Started speaking")):o?this.lastVoiceActiveDate=Date.now():!o&&this.isVoiceActive&&Date.now()<this.lastVoiceActiveDate+this.voiceEndTimeout||!o&&this.isVoiceActive&&(this.isVoiceActive=!1,this.dispatchEvent(new CustomEvent("speechend")),this.onSpeechEnd(),Ht.debug("Stopped speaking after timeout")),!o){let a=Date.now();a>this.nextVadReset&&(this.nextVadReset=a+5e3,this.vad.resetState())}}catch(r){Ht.error("VAD failed:",r)}}onSpeechStart(){}onSpeechEnd(){}};Ut.vadModelURL="";var mt=Ut;var Ts=new U("VoiceChunkOutputNode"),gt=class extends mt{constructor(){super(...arguments);this.buffers=[];this.recordedBuffers=[];this._voiceRecording=!1;this.backBufferDurationSeconds=3}get bufferDuration(){return this.buffers.reduce((t,r)=>t+r.length,0)/8e3}async onData(t){if(await super.onData(t),this.isVoiceActive&&!this._voiceRecording){Ts.debug(`Voice detected, sending ${this.buffers.length} existing chunks`),this._voiceRecording=!0;for(let r of this.buffers)this.recordedBuffers.push(r),this.dispatchEvent(new CustomEvent("voicedata",{detail:{data:r,isFinal:!1}})),this.onVoiceChunk(r);this.recordedBuffers.push(t),this.dispatchEvent(new CustomEvent("voicedata",{detail:{data:t,isFinal:!1}})),this.onVoiceChunk(t),this.buffers=[]}else if(this.isVoiceActive)this.recordedBuffers.push(t),this.dispatchEvent(new CustomEvent("voicedata",{detail:{data:t,isFinal:!1}})),this.onVoiceChunk(t);else if(!this.isVoiceActive&&this._voiceRecording){this.recordedBuffers.push(t),this.dispatchEvent(new CustomEvent("voicedata",{detail:{data:t,isFinal:!0}})),this.onVoiceChunk(t),this._voiceRecording=!1;let r=this.recordedBuffers.reduce((i,o)=>i+o.length,0);Ts.debug(`Voice complete, recorded ${(r/8e3).toFixed(2)} seconds of audio, ${r*4/1024} KB of data`),this.dispatchEvent(new CustomEvent("voicedataend",{detail:{data:this.recordedBuffers}})),this.onVoiceEnd(this.recordedBuffers),this.recordedBuffers=[]}else for(this.buffers.push(t);this.bufferDuration>this.backBufferDurationSeconds;)this.buffers.shift()}onVoiceChunk(t){}onVoiceEnd(t){}};var $n=new U("OpenAITranscriptionNode"),er=class extends gt{constructor(t,r){super(t);this.apiKey="";this.pendingBuffers=[];this.isTranscribing=!1;this.apiKey=r}async onVoiceEnd(t){let r=$n.timer("OpenAI Transcribe");this.isTranscribing=!0,this.pendingBuffers.push(...t);let i=Jn(this.sampleRate,this.pendingBuffers);this.lastRequestAbortController?.abort(),this.lastRequestAbortController=new AbortController;let o="";try{let a=new FormData;a.append("file",i),a.append("model","whisper-1"),a.append("response_format","text");let s=await fetch("https://api.openai.com/v1/audio/transcriptions",{method:"POST",headers:{Authorization:`Bearer ${this.apiKey}`},body:a,signal:this.lastRequestAbortController.signal});if(!s.ok)throw new Error(`Failed to generate voice sample: ${s.status} ${s.statusText}`);r("Response received"),o=await s.text(),r("Content received: "+o),this.lastRequestAbortController=void 0}catch(a){$n.error(`Failed to transcribe speech: ${a.message}`);return}finally{this.isTranscribing=!1}if(this.pendingBuffers=[],!o)return $n.debug("Transcription complete, but no text was found");$n.debug(`Transcription: ${o}`),this.onVoiceTranscription(o),this.dispatchEvent(new CustomEvent("transcription",{detail:{text:o}}))}onVoiceTranscription(t){}};var tr=class extends WebSocket{constructor(t){super(t);this.pendingData=[];this.addEventListener("open",()=>this._onOpen())}send(t){this.readyState==WebSocket.OPEN?super.send(t):this.pendingData.push(t)}_onOpen(){for(let t of this.pendingData)super.send(t);this.pendingData=[]}};var Me=new U("IntelliWeaveTranscriptionNode"),Dp="wss://speech.intelliweave.ai/api/v1/transcribe",rr=class rr extends gt{constructor(t,r){super(t);this.apiAddress=Dp;this.apiKey="";this.isTranscribing=!1;this.apiKey=r}async onVoiceChunk(t){this.isTranscribing=!0,this.ws?this.ws.send(t):(Me.debug("Opening WebSocket connection"),this.ws=new tr(this.apiAddress),this.ws.send(JSON.stringify({type:"hello",sampleRate:16e3,channels:1,format:"float32",apiKey:this.apiKey})),this.ws.send(t.buffer),this.ws.onopen=()=>{Me.debug("WebSocket connection opened")},this.ws.addEventListener("message",i=>{let o=JSON.parse(i.data);if(o.error)return Me.warn("Error: "+o.error);if(o.type!="transcription")return Me.warn("Invalid response type",o);if(o.streaming&&!o.final)return Me.debug("Partial transcription: "+o.partialText);if(this.isTranscribing=!1,!o.text.trim())return Me.warn(`Empty transcription (${o.processingTime}ms)`);Me.debug(`Transcription: ${o.text} (${o.processingTime}ms)`),this.onVoiceTranscription(o.text),this.dispatchEvent(new CustomEvent("transcription",{detail:{text:o.text}}))}),this.ws.addEventListener("close",()=>this.onSocketClose()),this.ws.addEventListener("error",i=>Me.warn("WebSocket error")));let r=1e3*60*1;this.shutdownTimer&&clearTimeout(this.shutdownTimer),this.shutdownTimer=setTimeout(()=>{Me.debug("Shutting down WebSocket connection"),this.ws?.close(),this.ws=void 0},r)}async onVoiceEnd(t){if(this.ws?.send(JSON.stringify({type:"end"})),rr.debugExportWav){let r=Jn(this.sampleRate,t),i=document.createElement("a");i.href=URL.createObjectURL(r),i.download="recording.wav",i.click()}}onVoiceTranscription(t){}onSocketClose(){Me.debug("WebSocket connection closed"),this.ws=void 0,this.isTranscribing=!1}};rr.debugExportWav=!1;var nr=rr;var Fi=new U("SpeechRecognition"),ir=class extends EventTarget{constructor(t){super();this.isRunning=!1;this._skipEvents=!1;this.maxVolumeHeard=0;this.ai=t,this.ai.knowledgeBase.registerSource(()=>[{id:"system.microphone.enable",type:"action",name:"Enable or disable microphone",isContext:!0,content:`Starts or stops listening to input from the user through the microphone. ${this.isRunning?"Microphone access is currently enabled and you can hear the user.":"Microphone access is currently disabled."}.`,parameters:[{name:"enable",type:"boolean",description:"If true, enables the microphone. If false, disables it."}],action:async r=>{r.enable?await this.start():this.stop()}}])}get isSupported(){if(!Ee.lib||!this.ai?.vadModel||!Be().AudioWorkletNode)return!1;if(this.ai?.config?.transcription?.providerID!="intelliweave"){if(!(this.ai?.config?.transcription?.providerID=="openai"&&this.ai.config?.transcription?.apiKey))return!1}return!0}async start(){if(!this.isSupported)throw new Error("Speech recognition not supported in this persona and browser.");if(!this.isRunning){this.isRunning=!0;try{await this.ai.audio.beginAccess("speech-recognition"),this.micStream=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0}});let t=this.ai.audio.context.createMediaStreamSource(this.micStream);this.analyserNode=this.ai.audio.context.createAnalyser(),this.analyserNode.fftSize=32,t.connect(this.analyserNode),this.analyserBuffer=new Float32Array(this.analyserNode.fftSize),mt.vadModelURL=URL.createObjectURL(this.ai.vadModel),this.ai?.config?.transcription?.providerID=="openai"?(this.voiceDetection=new er(this.ai.audio.context,this.ai.config.transcription.apiKey),t.connect(this.voiceDetection)):(this.voiceDetection=new nr(this.ai.audio.context,this.ai.apiKey),this.voiceDetection.apiAddress=this.ai?.config?.transcription?.url||this.voiceDetection.apiAddress,t.connect(this.voiceDetection)),this.voiceDetection.addEventListener("speechstart",r=>{this.ai._voiceTracker=Fi.timer("voice interaction","Speech started"),this.dispatchEvent(new CustomEvent(r.type,{detail:r.detail}))}),this.voiceDetection.addEventListener("speechend",r=>{this.ai._voiceTracker?.("Speech ended"),this.dispatchEvent(new CustomEvent(r.type,{detail:r.detail}))}),this.voiceDetection.addEventListener("transcription",r=>{this.ai._voiceTracker?.(`Transcription: ${r.detail.text}`),this.onTranscription(r)}),this._skipEvents||this.dispatchEvent(new CustomEvent("start",{detail:{speechRecognition:this}}))}catch(t){Fi.error("Failed to start speech recognition:",t),this.stop()}}}stop(){this.isRunning&&(this.isRunning=!1,this.ai.audio.endAccess("speech-recognition"),this.voiceDetection?.disconnect(),this.voiceDetection=void 0,this.micStream?.getTracks().forEach(t=>t.stop()),this.micStream=void 0,this.analyserNode=void 0,this.analyserBuffer=void 0,this._skipEvents||this.dispatchEvent(new CustomEvent("end",{detail:{speechRecognition:this}})))}get volumeLevel(){if(!this.analyserNode||!this.analyserBuffer)return 0;this.analyserNode.getFloatTimeDomainData(this.analyserBuffer);let t=0;for(let i of this.analyserBuffer)t+=i*i;let r=Math.sqrt(t/this.analyserBuffer.length);return r>this.maxVolumeHeard&&(this.maxVolumeHeard=r),this.maxVolumeHeard*=.999,this.maxVolumeHeard<.01&&(this.maxVolumeHeard=.01),Math.min(1,Math.max(0,r/this.maxVolumeHeard))}get wordsCurrentlyBeingSpoken(){return!!this.voiceDetection?.isVoiceActive}get isTranscribing(){return!!this.voiceDetection?.isTranscribing}onTranscription(t){let r=t.detail.text;Fi.debug("Heard:",r),this.dispatchEvent(new CustomEvent("speech",{detail:{transcript:r,isFinal:!0}}))}async reset(){if(this.isRunning){this._skipEvents=!0;try{this.stop(),await this.start(),this._skipEvents=!1}catch(t){throw this._skipEvents=!1,t}}}};var or=new U("AudioSystem"),yt=class{constructor(n){this.locks=[];if(!n)throw new Error("AI reference is required. Please pass in the IntelliWeave instance to the constructor.");this.ai=n,this.ai.audio=this,this.speechRecognition=new ir(this.ai),this.speechOutput=new jn(this.ai)}static get isSupported(){return!(!Ee.lib||!Be().AudioWorkletNode)}async beginAccess(n){or.debug(`Began access for: ${n}`),this.locks.includes(n)||this.locks.push(n),!this.context&&(or.debug("Creating AudioContext"),this.context=new AudioContext({latencyHint:"interactive"}),this.context.resume(),await Promise.all([this.context.audioWorklet.addModule(Cs),this.context.audioWorklet.addModule(Es)]))}endAccess(n){or.debug(`Ended access for: ${n}`),this.locks=this.locks.filter(t=>t!=n),!this.locks.length&&(or.debug("Closing AudioContext"),this.context?.close(),this.context=void 0)}};var Kw=new U("Stream");var et=_i(Xs(),1);var nv=new U("React");var rv=(0,et.createContext)(void 0);var Ni=new U("Embed"),tt=class extends ye{constructor(){super();this.config={};this.suggestions=[];this.html=()=>`
|
|
278
278
|
|
|
279
279
|
<!-- Styling -->
|
|
280
280
|
<style>
|
|
@@ -399,7 +399,7 @@ You have access to a database of knowledge base items. These include "info" type
|
|
|
399
399
|
|
|
400
400
|
</div>
|
|
401
401
|
|
|
402
|
-
`;this._isProcessing=!1;this.ai=new st,yt.isSupported&&(this.ai.audio=new yt(this.ai))}onCreate(){Q().embed&&
|
|
402
|
+
`;this._isProcessing=!1;this.ai=new st,yt.isSupported&&(this.ai.audio=new yt(this.ai))}onCreate(){Q().embed&&Ni.warn("Only one <web-weaver-embed> element should be on the page."),Q().embed=this,this.child("root").addEventListener("click",i=>this.onContainerClick(i)),this.child("web-weaver-logo").addEventListener("click",i=>this.onLogoClick(i)),this.child("interaction-bar").addEventListener("input-message",i=>this.processInput(i.detail)),this.child("interaction-bar").addEventListener("llm-button-click",i=>this.state.llmPanelOpen=!this.state.llmPanelOpen),this.child("llm-selector-panel").addEventListener("select",i=>this.onLLMModelSelect(i)),this.child("interaction-bar").connectAI(this.ai),this.ai.onAIMessage=this.onAIMessage.bind(this),this.ai.onAIToolStart=this.onAIToolStart.bind(this),this.ai.knowledgeBase.addEntry({id:"ui.focusElement",type:"action",name:"Focus on an element",content:"Focuses and draws the user's attention to an HTML element on the page.",isContext:!0,parameters:[{name:"elementID",type:"string",description:"The HTML ID of the element to focus."}],action:i=>{let o=i.elementID||"";if(o.startsWith("#")&&(o=o.substring(1)),!o)throw new Error("No element ID specified.");let a=document.getElementById(o);if(!a)throw new Error(`Could not find the element with ID "${o}".`);a.scrollIntoView({behavior:"smooth",block:"center",inline:"center"}),this.attr.focusID=o,this.ai.submitAnalyticsEvent({type:"focus-element",elementID:o})}}),this.ai.knowledgeBase.addEntry({id:"ui.suggestResponse",type:"action",name:"Suggest a response",content:"Add a button with a suggested response for the user's next message. Supports multiple calls at once.",isContext:!0,parameters:[{name:"text",type:"string",description:"The suggested response for the user's next message."}],action:i=>(this.suggestions.push(i.text),this.ai.submitAnalyticsEvent({type:"suggest-response",text:i.text}),"Suggestion button added")});let r=this.attr.apiKey||Q().apiKey;if(!r)return Ni.warn("No API key specified, some features may be unavailable.");this.state.loading=!0,this.ai.load(r).then(i=>{this.config=i,Q().introductionMessage=this.config.introductionMessage,Q().analytics=this.config.analytics!==void 0?!!this.config.analytics:Q().analytics,this.state.loading=!1,this.resetConversation()})}onUpdate(){this.child("web-weaver-embed-inner").style.display=this.attr.open?"":"none",this.child("interaction-bar").style.display=this.attr.open?"":"none",this.child("root").className=this.attr.open?"open":"",this.child("llm-selector-panel").attr.open=this.state.llmPanelOpen,this.child("root").style.right=this.attr.offsetX?this.attr.offsetX+"px":"20px",this.child("root").style.bottom=this.attr.offsetY?this.attr.offsetY+"px":"20px",this.child("interaction-bar").attr.loading=this.state.loading,this.child("interaction-bar").attr.llmName=this.ai.currentModel?.metadata?.name||this.ai.currentModel?.id||"None",this.child("interaction-bar").attr.llmButtonVisible=this.ai.models.length>1;let t=this.child("web-weaver-logo");t.attr.focusID=this.attr.focusID,t.refreshLayout(),this.child("llm-selector-panel").state.items=this.ai.models.sort((r,i)=>(i.priority||0)-(r.priority||0)),this.child("llm-selector-panel").state.selectedID=this.ai.currentModel?.id}onDestroy(){Q().embed==this&&(Q().embed=null)}onContainerClick(t){this.attr.open||(t.preventDefault(),this.attr.open=!0)}onLogoClick(t){t.preventDefault(),t.stopPropagation(),this.attr.focusID?this.attr.focusID="":this.attr.open=!this.attr.open}open(){this.attr.open=!0}close(){this.attr.open=!1}resetConversation(){let t=this.child("web-weaver-embed-inner");for(this.state.llmPanelOpen=!1;t.children.length>0;)t.children[0].remove();this.ai.resetConversation(),this.suggestions=[];let r=document.createElement("div");r.className="introduction-message",r.innerHTML=Q().introductionMessage||`Welcome to <b>${document.title||"Web Weaver"}</b>. How can I help you?`,t.appendChild(r),this.ai.insertAssistantMessage(r.innerText);for(let i of Q().introductionSuggestions||[]){let o=document.createElement("div");o.className="suggestion-button",o.innerText=i,o.addEventListener("click",a=>this.onSuggestionClick(a,i)),t.appendChild(o)}}async processInput(t){if(this._isProcessing)return;this._isProcessing=!0,this.state.loading=!0,this.state.llmPanelOpen=!1;let r=this.child("web-weaver-embed-inner");this.suggestions=[];try{for(let o of Array.from(r.querySelectorAll(".suggestion-button")))o.remove();this.attr.focusID="";let i=document.createElement("div");i.className="input",i.innerText=t,r.appendChild(i),r.lastElementChild?.scrollIntoView({behavior:"instant",block:"end"}),await this.ai.sendMessage(t);for(let o of this.suggestions){let a=document.createElement("div");a.className="suggestion-button",a.innerText=o,a.addEventListener("click",s=>this.onSuggestionClick(s,o)),r.appendChild(a)}r.lastElementChild?.scrollIntoView({behavior:"instant",block:"end"})}catch(i){Ni.error("Failed to process input:",i);let o=document.createElement("div");o.className="output",o.innerText="Sorry, there was a problem getting a response. "+i.message,r.appendChild(o);let a=document.createElement("div");a.className="suggestion-button",a.innerText="Reset conversation",a.addEventListener("click",s=>this.resetConversation()),r.appendChild(a)}this.state.loading=!1,this._isProcessing=!1}async onAIMessage(t){let r=await Li().use(Nn).use(On).use(fn,{target:"_blank",rel:["noopener","noreferrer"]}).use(gn).use(En).processSync(t),i=this.child("web-weaver-embed-inner"),o=i.lastElementChild;if(o&&o.classList.contains("output"))o.innerHTML=r.toString("utf-8");else{let a=document.createElement("div");a.className="output",a.innerHTML=r.toString("utf-8"),i.appendChild(a)}for(let a of Array.from(i.querySelectorAll(".tool")))a.remove();i.lastElementChild?.scrollIntoView({behavior:"instant",block:"end"})}onAIToolStart(t,r){let i=`Running: ${t}`;t=="search"&&(i=`Searching: ${r?.query}`),t=="ui.focusElement"&&(i=`Focusing: #${r?.elementID}`),t=="ui.suggestResponse"&&(i=`Suggested response: ${r?.text}`);let o=this.child("web-weaver-embed-inner"),a=document.createElement("div");a.className="tool",a.innerText=i,o.appendChild(a),o.lastElementChild?.scrollIntoView({behavior:"instant",block:"end"})}onSuggestionClick(t,r){this.processInput(r)}onLLMModelSelect(t){t.preventDefault(),this.ai.setModel(t.detail),this.state.llmPanelOpen=!1}};tt.tagName="intelliweave-embed",tt.observedAttributes=["logo","focusID","open"];Ee.lib=()=>import("./ort.bundle.min-5QOPZPPI.js");document.body.appendChild(tt.create());
|
|
403
403
|
/*! Bundled license information:
|
|
404
404
|
|
|
405
405
|
react/cjs/react.production.min.js:
|