jsx-slack
Version:
Build JSON object for Slack Block Kit surfaces from JSX
7 lines • 158 kB
JavaScript
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const{defineProperty:Ge,create:Nt,keys:$t,freeze:Ut}=Object,G="$$jsxslack",Me=`${G}Component`,q=(e,u=null,...r)=>{let n=Nt(null);if(typeof e=="function"){let t={...u||{}},{length:o}=r;o===1?[t.children]=r:o>1&&(t.children=r),n=e(t)}if(n&&typeof n=="object"){for(let t of $t(n))n[t]===void 0&&delete n[t];if(!n[G]){let t=r;if(!r.length){let{children:o}=u||{};o!==void 0&&(t=[].concat(o))}Ge(n,G,{value:{type:e,props:u,children:t}})}}return n},h=(e,u,r={})=>Ge(u,Me,{value:Ut(Ge({...r},"name",{value:e,enumerable:!0}))}),Rt=h("Fragment",({children:e})=>[].concat(e)),Ou=e=>typeof e=="function"&&!!Object.prototype.hasOwnProperty.call(e,Me),Vu=e=>typeof e=="object"&&!!e&&!!Object.prototype.hasOwnProperty.call(e,G),Y=(e,u)=>Vu(e)&&Ou(e[G].type)?typeof u=="string"?e[G].type[Me].name===u:u?e[G].type===u:!0:!1,j=e=>Array.isArray(e)?[...e]:{...e};function m(e){return e}(e=>{e.isValidElement=Vu,e.createElement=q,e.h=q,e.Fragment=Rt;const u=t=>t.reduce((o,a)=>(Array.isArray(a)&&!Y(a)?o.push(...u(a)):a==null||a===!0||a===!1?o.push(null):o.push(a),o),[]),r=t=>u([t]);e.Children=Object.freeze({count:t=>t==null?0:r(t).length,forEach:(t,o)=>{e.Children.map(t,o)},map:(t,o)=>t==null?t:r(t).reduce((a,i,l)=>{const c=o.call(i,i,l);return c!=null&&a.push(c),a},[]),only:t=>{if((0,e.isValidElement)(t))return t;throw new Error("JSXSlack.Children.only expected to receive a single JSXSlack element child.")},toArray:t=>r(t).reduce((o,a)=>a==null?o:Y(a,"Fragment")?o.concat(e.Children.toArray([...a])):[...o,a],[])});let n=!1;e.exactMode=t=>(t!==void 0&&(n=t),n)})(m||(m={})),Object.freeze(m);const Z=(e,u)=>Object.defineProperty(u,"$$jsxslack",{value:e.$$jsxslack}),O=(e,u,r=!0)=>{const n=q(u,e.$$jsxslack.props,...e.$$jsxslack.children);return r&&typeof n=="object"&&n?Z(e,j(n)):n},S=e=>{if(m.isValidElement(e)){if(typeof e.$$jsxslack.type=="string")return`<${e.$$jsxslack.type}>`;if(Ou(e.$$jsxslack.type))return`<${e.$$jsxslack.type.$$jsxslackComponent.name}>`}},It=e=>{var u;const r=m.isValidElement(e)?(u=e.$$jsxslack.props)==null?void 0:u.__source:e;if(typeof r=="object"&&r&&Object.prototype.hasOwnProperty.call(r,"columnNumber")&&Object.prototype.hasOwnProperty.call(r,"fileName")&&Object.prototype.hasOwnProperty.call(r,"lineNumber"))return r};class C extends Error{constructor(u,r){super(u),this.name=new.target.name,this.originalStack=this.stack,Object.setPrototypeOf(this,new.target.prototype),this.resetStack(r)}resetStack(u){const r=It(u);if(!r)return;const n=S(u)||"JSX element";this.stack=`${this.name}: ${this.message}
at ${n} (${r.fileName}:${r.lineNumber}:${r.columnNumber})`}}const jt={m:1e3,cm:900,d:500,cd:400,c:100,xc:90,l:50,xl:40,x:10,ix:9,v:5,iv:4,i:1},Pu=e=>{if(e==="@channel"||e==="@everyone"||e==="@here")return e;const u=e.match(/^(#C|@[SUW])[A-Z0-9]{8,}$/);if(u)return u[1]==="#C"||u[1]==="@S"?u[1]:"@UW"},T=e=>{if(e===void 0)return;const u=Number.parseInt(e.toString(),10);if(!Number.isNaN(u))return u},te=e=>{if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="bigint")return e.toString()},ze=e=>{const u=T(e);if(u===void 0)return e.toString();if(u<=0)return u.toString();const r=Math.floor((u-1)/26);return(r>0?ze(r):"")+String.fromCharCode((u-1)%26+97)},Hu=e=>{let u=T(e);if(u===void 0)return e.toString();if(u<=0||u>=4e3)return u.toString();let r="";for(const[n,t]of Object.entries(jt)){const o=Math.floor(u/t);r+=o>0?n.repeat(o):"",u%=t}return r},Gu=(e,u=!1)=>m.Children.toArray(e).map(r=>m.isValidElement(r)?u&&r.$$jsxslack.type==="br"?`
`:Gu(r.$$jsxslack.children):r).join(""),y=(e,{emoji:u=!0,layoutTags:r=!1}={})=>({type:"plain_text",text:typeof e=="string"?e:Gu(e,r),emoji:u}),Ot=e=>{const u={};let{include:r}=e;return r&&(Array.isArray(r)||(r=r.split(" ")),r=[...new Set(r)].filter(n=>["im","mpim","private","public"].includes(n)),r.length>0&&(u.include=r)),e.excludeBotUsers!==void 0&&(u.exclude_bot_users=!!e.excludeBotUsers),e.excludeExternalSharedChannels!==void 0&&(u.exclude_external_shared_channels=!!e.excludeExternalSharedChannels),Object.keys(u).length>0?u:void 0},Mu=e=>{const u={};let{dispatchAction:r}=e;if(typeof r!="boolean"&&r){Array.isArray(r)||(r=r.split(" "));const n=[...new Set(r.filter(t=>["onEnterPressed","onCharacterEntered"].includes(t)).map(t=>t==="onEnterPressed"?"on_enter_pressed":"on_character_entered"))];n.length>0&&(u.trigger_actions_on=n)}return Object.keys(u).length>0?u:void 0},Vt=h("EmailTextInput",e=>({type:"email_text_input",action_id:e.actionId,placeholder:e.placeholder?y(e.placeholder,{emoji:!1}):void 0,initial_value:e.initialValue,dispatch_action_config:e.dispatchActionConfig,focus_on_load:e.focusOnLoad})),Pt=h("NumberTextInput",e=>{var u;return{type:"number_input",action_id:e.actionId,placeholder:e.placeholder?y(e.placeholder,{emoji:!1}):void 0,is_decimal_allowed:(u=e.isDecimalAllowed)!=null?u:!1,min_value:e.minValue,max_value:e.maxValue,initial_value:e.initialValue,dispatch_action_config:e.dispatchActionConfig,focus_on_load:e.focusOnLoad}}),zu=h("PlainTextInput",e=>({type:"plain_text_input",action_id:e.actionId,placeholder:e.placeholder?y(e.placeholder,{emoji:!1}):void 0,initial_value:e.initialValue,multiline:e.multiline,max_length:e.maxLength,min_length:e.minLength,dispatch_action_config:e.dispatchActionConfig,focus_on_load:e.focusOnLoad})),Ht=h("UrlTextInput",e=>({type:"url_text_input",action_id:e.actionId,placeholder:e.placeholder?y(e.placeholder,{emoji:!1}):void 0,initial_value:e.initialValue,dispatch_action_config:e.dispatchActionConfig,focus_on_load:e.focusOnLoad})),w=e=>{if(e.autoFocus!==void 0)return!!e.autoFocus;if(e.autofocus!==void 0)return!!e.autofocus},Be=["channels_select","checkboxes","conversations_select","datepicker","datetimepicker","email_text_input","external_select","multi_channels_select","multi_conversations_select","multi_external_select","multi_static_select","multi_users_select","number_input","plain_text_input","radio_buttons","static_select","timepicker","url_text_input","users_select"],Gt=({element:e,from:u})=>{if(typeof e!="object")throw new C(`${u} has invalid value as an element of input layout block.`);if(!Be.includes(e.type)){const r=S(e);throw new C(`${u} has detected an invalid type as the element of input layout block: "${e.type}"${r?` (Provided by ${r})`:""}`,e)}return j(e)},L=(e,u,r)=>{const n=j(q(Gt,{element:e,from:r?`<${r.$$jsxslackComponent.name}>`:"Input layout block"}));if(u.label){const t=u.hint||u.title;return{type:"input",block_id:u.blockId||u.id,label:y(u.label),hint:t?y(t):void 0,optional:!u.required,dispatch_action:u.dispatchAction!==void 0?!!u.dispatchAction:void 0,element:n}}return e},V=h("Input",e=>e.type==="hidden"||e.type==="submit"?{}:L(e.children||j((()=>{const u={actionId:e.actionId||e.name,placeholder:e.placeholder,dispatchActionConfig:Mu(e),focusOnLoad:w(e)};return e.type==="url"?q(Ht,{...u,initialValue:te(e.value)||void 0}):e.type==="email"?q(Vt,{...u,initialValue:te(e.value)||void 0}):e.type==="number"?q(Pt,{...u,initialValue:te(e.value)||void 0,isDecimalAllowed:e.decimal===void 0?void 0:!!e.decimal,maxValue:te(e.max),minValue:te(e.min)}):q(zu,{...u,initialValue:e.value,maxLength:T(e.maxLength),minLength:T(e.minLength)})})()),{...e,dispatchAction:e.dispatchAction===void 0?void 0:!!e.dispatchAction},V)),Je=Symbol("jsx-slack-option-selected"),W=h("Option",({children:e,description:u,selected:r,value:n})=>{const t=y(e),o={text:t,value:n||t.text,description:u!==void 0?y(u):void 0};return r!==void 0&&Object.defineProperty(o,Je,{value:r}),o}),ne=h("Option",({children:e,label:u})=>{const r=m.Children.toArray(e).reduce((n,t)=>{if(!m.isValidElement(t))return n;let o=t;if(o.$$jsxslack.type==="option"&&(o=O(o,W,!1)),o.$$jsxslack.type!==W){const a=S(t);throw new C(`<Optgroup> must contain only <Option>${a?` but it is included ${a}`:""}.`,t)}return[...n,o]},[]);return{label:y(u),options:r}}),Ju=Symbol("jsx-slack-select-fragment-selected-options"),Ye=h("SelectFragment",({children:e,from:u})=>{let r=0,n;const t=`<${(u==null?void 0:u.$$jsxslackComponent.name)||"SelectFragment"}>`,o=[],a=m.Children.toArray(e).reduce((i,l)=>{if(!m.isValidElement(l))return i;let c=l;l.$$jsxslack.type==="option"&&(c=O(l,W,!1)),l.$$jsxslack.type==="optgroup"&&(c=O(l,ne,!1));const{type:s}=c.$$jsxslack;if(s===W)r+=1,c[Je]&&o.push(c);else if(s===ne)r+=c.options.length,o.push(...c.options.filter(p=>p[Je]));else{const p=S(l);throw new C(`${t} must contain either of <Option> or <Optgroup>${p?` but it is included ${p}`:""}.`,l)}if(n&&n!==s)throw new C(`<Option> and <Optgroup> cannot be mixed in the immediate children of ${t}.`,l);return n=s,[...i,c]},[]);return r>0?Object.defineProperty(n===ne?{option_groups:a}:{options:a},Ju,{value:o}):{options:[]}}),Yu=Ye,R=h("Select",e=>{const u=Y(e.children,Ye)?e.children:q(Ye,{from:R,children:e.children});if(u.options&&u.options.length===0)throw new C("<Select> must contain least of one <Option> or <Optgroup>.",e.__source);const r=e.value===void 0?u[Ju]||[]:(o=>{const a=u.options||[].concat(...u.option_groups.map(l=>l.options)),i=[].concat(o);return a.filter(l=>i.includes(l.value))})(e.value),n=e.actionId||e.name,t=e.placeholder!==void 0?y(e.placeholder):void 0;return L(e.multiple?{type:"multi_static_select",action_id:n,placeholder:t,...u,initial_options:r.length>0?r:void 0,max_selected_items:T(e.maxSelectedItems),confirm:e.confirm,focus_on_load:w(e)}:{type:"static_select",action_id:n,placeholder:t,...u,initial_option:r.length>0?r[r.length-1]:void 0,confirm:e.confirm,focus_on_load:w(e)},e,R)}),K=h("Textarea",e=>L(j(q(zu,{actionId:e.actionId||e.name,initialValue:e.value,maxLength:T(e.maxLength),minLength:T(e.minLength),placeholder:e.placeholder,multiline:!0,dispatchActionConfig:Mu(e),focusOnLoad:w(e)})),{...e,dispatchAction:e.dispatchAction===void 0?void 0:!!e.dispatchAction},K)),we=h("Button",e=>{var u;let r;return e.confirm&&(r=e.confirm,r.style===void 0&&e.style!==void 0&&(r={...r,style:e.style},m.isValidElement(e.confirm)&&Z(e.confirm,r))),{type:"button",action_id:e.actionId||e.name,accessibility_label:(u=e.accessibilityLabel)!=null?u:e["aria-label"],text:y(e.children),value:e.value,url:e.url,style:e.style,confirm:r}}),Zu=e=>u=>{const r=S(u),n=Y(u);throw new C(`<${e}> cannot include the ${r?n&&r!=="<Input>"?`input component. Please remove "label" prop from <${r.slice(1,-1)} label="...">.`:`element for "input" type: ${r}`:'element for "input" type.'}`,u)},oe=e=>{const u=S(e);throw new C(`<Actions> cannot include the element for selection from multiple options${u?`: <${u.slice(1,-1)} multiple>`:"."}`,e)},ae=["button","channels_select","checkboxes","conversations_select","datepicker","datetimepicker","external_select","overflow","radio_buttons","static_select","timepicker","users_select","workflow_button"],Mt={...ae.reduce((e,u)=>({...e,[u]:()=>{}}),{}),channels_select:e=>{if(e.response_url_enabled)throw new C("<ChannelsSelect responseUrlEnabled> is available only in the usage of input components.",e)},conversations_select:e=>{if(e.response_url_enabled)throw new C("<ConversationsSelect responseUrlEnabled> is available only in the usage of input components.",e)},multi_channels_select:oe,multi_conversations_select:oe,multi_external_select:oe,multi_static_select:oe,multi_users_select:oe,input:Zu("Actions")},Wu=h("Actions",({blockId:e,children:u,id:r,...n})=>{const t=m.Children.toArray(u).reduce((o,a)=>{let i=a;if(m.isValidElement(a)&&(a.$$jsxslack.type==="button"&&(i=O(a,we)),a.$$jsxslack.type==="select"&&(i=O(a,R))),typeof i=="object"){const l=Mt[i.type];if(!l){const c=S(a);throw new C(`<Actions> has detected an incompatible element in its children${c?`: ${c}`:"."}`,a)}return l(i),[...o,i]}return o},[]);if(t.length>25)throw new C(`<Actions> can contain up to 25 elements, but there are ${t.length} elements.`,n.__source);return{type:"actions",block_id:e||r,elements:t}}),ie=h("Divider",({blockId:e,id:u})=>({type:"divider",block_id:e||u})),le=h("Header",({blockId:e,children:u,id:r})=>({type:"header",block_id:e||r,text:y(u,{layoutTags:!0})})),ce=h("Image",({blockId:e,id:u,alt:r,src:n,title:t})=>({type:"image",block_id:e||u,alt_text:r,image_url:n,title:t?y(t):void 0})),zt=["January","February","March","April","May","June","July","August","September","October","November","December"],Jt=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Ze=["th","st","nd","rd"],Yt=e=>{const u=e%100;return`${e}${Ze[(u-20)%10]||Ze[u]||Ze[0]}`};function Zt(e,u){const r=(o=!1)=>{let a=zt[e.getUTCMonth()];o&&(a=a.slice(0,3));let i=e.getUTCDate();return o||(i=Yt(i)),`${a} ${i}, ${e.getUTCFullYear()}`},n=(o=!1)=>{const a=`${e.getUTCHours()}`.padStart(2,"0"),i=`${e.getUTCMinutes()}`.padStart(2,"0"),l=e.getUTCHours()>=12?"PM":"AM";if(!o)return`${a}:${i} ${l}`;const c=`${e.getUTCSeconds()}`.padStart(2,"0");return`${a}:${i}:${c} ${l}`},t=o=>{const a=new Date,i=a.getUTCFullYear(),l=a.getUTCMonth(),c=a.getUTCDate(),s=Date.UTC(i,l,c-1,0,0,0),p=Date.UTC(i,l,c,0,0,0),f=Date.UTC(i,l,c+1,0,0,0),g=Date.UTC(i,l,c+2,0,0,0)-1,D=e.getTime();let v="";return s<=D&&D<p&&(v="yesterday"),p<=D&&D<f&&(v="today"),f<=D&&D<=g&&(v="tomorrow"),v&&o&&(v=`${v.slice(0,1).toUpperCase()}${v.slice(1)}`),v};return u.replace(/{date_num}/g,()=>{const o=`${e.getUTCFullYear()}`.padStart(4,"0"),a=`${e.getUTCMonth()+1}`.padStart(2,"0"),i=`${e.getUTCDate()}`.padStart(2,"0");return`${o}-${a}-${i}`}).replace(/{date_pretty}/g,(o,a)=>t(a===0)||"{date}").replace(/{date_short_pretty}/g,(o,a)=>t(a===0)||"{date_short}").replace(/{date_long_pretty}/g,(o,a)=>t(a===0)||"{date_long}").replace(/{date}/g,()=>r()).replace(/{date_short}/g,()=>r(!0)).replace(/{date_long}/g,()=>`${Jt[e.getUTCDay()]}, ${r()}`).replace(/{time}/g,()=>n()).replace(/{time_secs}/g,()=>n(!0))}const Wt=/(<[^>]*>|:[-a-z0-9ÀÁÂÃÄÇÈÉÊËÍÎÏÑÓÔÕÖŒœÙÚÛÜŸßàáâãäçèéêëíîïñóôõöùúûüÿ__++'\u1100-\u11ff\u2e80-\u2fd5\u3005\u3041-\u3096\u30a0-\u30ff\u3130-\u318f\u3400-\u4db5\u4e00-\u9fcb\ua960-\ua97f\uac00-\ud7ff\uff10-\uff19\uff41-\uff5a\uff61-\uff9f]+:)/,P=e=>u=>`<span data-escape="${e.repeat(u.length)}">${u}</span>`,X={blockquote:e=>e.replace(/^((?:<(?:[^>]|>(?=<))*>)?)(>)/gm,(u,r,n)=>`${r}\xAD${n}`).replace(/^((?:<(?:[^>]|>(?=<))*>)?)(>)/gm,(u,r,n)=>`${r}${P("\xAD\uFF1E")(n)}`),bold:e=>e.replace(/\*+/g,P("\u2217")).replace(/*+/g,P("\uFE61")),italic:e=>e.replace(/_+/g,P("\u02CD")).replace(/_+/g,P("\u2E0F")),code:e=>e.replace(/`+/g,P("\u02CB")).replace(/`+/g,P("\u02CB")),strikethrough:e=>e.replace(/~+/g,P("\u223C"))},Kt=e=>Object.values(X).reduce((u,r)=>r(u),e),Ku=(e,u=Kt)=>e.split(Wt).reduce((r,n,t)=>[...r,t%2?n:u(n)],[]).join(""),Fe=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),Xu=e=>Fe(e).replace(/\|+/g,encodeURI),Qu=(e,u,r)=>e.split(u).reduce((n,t,o)=>n.concat(o%2?t:r(t)),[]).join(""),er=e=>Qu(e,/(<[\s\S]*?>)/,u=>Qu(u,/(&\w+;)/,r=>[...r].map(n=>`&#${n.codePointAt(0)};`))),ke=e=>typeof e=="string"?e.replace(/&(amp|gt|lt|quot|#\d+);/g,(u,r)=>r.startsWith("#")?String.fromCodePoint(Number.parseInt(r.slice(1),10)):{amp:"&",gt:">",lt:"<",quot:'"'}[r]):e,se=(e,u=!0)=>{let r="";for(const n of Object.keys(e))if(e[n]!=null&&["number","bigint","boolean","string","symbol"].includes(typeof e[n])){let t=e[n].toString();u&&(t=Fe(t)),r+=` ${n}="${t.replace(/"/g,""")}"`}return r},Xt=(e,u,r,n)=>{var t;const o=()=>r.join(""),a=(...l)=>n.length>0&&l.some(c=>c===n[n.length-1]),i=(...l)=>l.some(c=>n.includes(c));if(e==="br")return"<br />";if(a("pre","code")&&!["a","time"].includes(e))return o();switch(e){case"b":case"strong":return i("b","strong","time")?o():`<b>${X.bold(o())}</b>`;case"i":case"em":return i("i","em","time")?o():`<i>${Ku(o(),X.italic)}</i>`;case"s":case"strike":case"del":return i("s","strike","del","time")?o():`<s>${X.strikethrough(o())}</s>`;case"code":return i("time")?o():`<code>${X.code(o())}</code>`;case"p":return i("p")?o():`<p>${o()}</p>`;case"blockquote":return i("blockquote","ul","ol","time")?o():`<blockquote>${X.blockquote(o())}</blockquote>`;case"pre":return i("ul","ol","time")?o():`<pre>${er(o().replace(/`{3}/g,"``\u02CB"))}</pre>`;case"a":{if(i("a","time"))return o();let l=o();return!l&&u.href&&Pu(u.href)&&(l="specialLink"),`<a${se(u)}>${l}</a>`}case"time":{const l=(t=u.dateTime)!=null?t:u.datetime,c=Number.parseInt(l,10),s=new Date(Number.isNaN(c)?l:c*1e3),p=Math.floor(s.getTime()/1e3),f=o().replace(/\|/g,"\u01C0"),g=se({datetime:p}),D=u.fallback?se({"data-fallback":u.fallback.replace(/\|/g,"\u01C0")}):se({"data-fallback":Zt(s,f)},!1);return`<time${g}${D}>${er(f)}</time>`}case"small":case"span":case"ul":return`<${e}>${o()}</${e}>`;case"ol":case"li":return`<${e}${se(u)}>${o()}</${e}>`;default:throw new C(`Unknown HTML-like element: ${e}`,u.__source)}},qe=h("Escape",m.Fragment.bind(null)),We=(e,u,r=!1)=>{var n;return((n=m.Children.map(e,t=>t))==null?void 0:n.reduce((t,o)=>{if(m.isValidElement(o)){const{type:a,props:i,children:l}=o.$$jsxslack;if(typeof a=="string"){const p=We(l,[...u,a]);return[...t,Xt(a,i||{},p,u)]}const c=!r&&a===qe,s=We(l,u,c);return t.concat(c?Ku(s.join("")):s)}return[...t,Fe(o.toString())]},[]))||[]},Ke=function(e){if(e==null)return rn;if(typeof e=="function")return Se(e);if(typeof e=="object")return Array.isArray(e)?Qt(e):en(e);if(typeof e=="string")return un(e);throw new Error("Expected function, string, or object as test")};function Qt(e){const u=[];let r=-1;for(;++r<e.length;)u[r]=Ke(e[r]);return Se(n);function n(...t){let o=-1;for(;++o<u.length;)if(u[o].apply(this,t))return!0;return!1}}function en(e){const u=e;return Se(r);function r(n){const t=n;let o;for(o in e)if(t[o]!==u[o])return!1;return!0}}function un(e){return Se(u);function u(r){return r&&r.type===e}}function Se(e){return u;function u(r,n,t){return!!(tn(r)&&e.call(this,r,typeof n=="number"?n:void 0,t||void 0))}}function rn(){return!0}function tn(e){return e!==null&&typeof e=="object"&&"type"in e}function C2(e){return e}const ur=[],nn=!0,rr=!1,on="skip";function an(e,u,r,n){let t;typeof u=="function"&&typeof r!="function"?(n=r,r=u):t=u;const o=Ke(t),a=n?-1:1;i(e,void 0,[])();function i(l,c,s){const p=l&&typeof l=="object"?l:{};if(typeof p.type=="string"){const g=typeof p.tagName=="string"?p.tagName:typeof p.name=="string"?p.name:void 0;Object.defineProperty(f,"name",{value:"node ("+(l.type+(g?"<"+g+">":""))+")"})}return f;function f(){let g=ur,D,v,N;if((!u||o(l,c,s[s.length-1]||void 0))&&(g=ln(r(l,s)),g[0]===rr))return g;if("children"in l&&l.children){const F=l;if(F.children&&g[0]!==on)for(v=(n?F.children.length:-1)+a,N=s.concat(F);v>-1&&v<F.children.length;){const M=F.children[v];if(D=i(M,v,N)(),D[0]===rr)return D;v=typeof D[1]=="number"?D[1]:v+a}}return g}}}function ln(e){return Array.isArray(e)?e:typeof e=="number"?[nn,e]:e==null?ur:[e]}function Xe(e,u,r,n){let t,o,a;typeof u=="function"&&typeof r!="function"?(o=void 0,a=u,t=r):(o=u,a=r,t=n),an(e,o,i,t);function i(l,c){const s=c[c.length-1],p=s?s.children.indexOf(l):void 0;return a(l,p,s)}}var tr=-1,_e=0,Te=1,Le=2,Qe=3,eu=4,uu=5,ru=6,nr=7,or=8,ar=typeof self=="object"?self:globalThis,cn=(e,u)=>{const r=(t,o)=>(e.set(o,t),t),n=t=>{if(e.has(t))return e.get(t);const[o,a]=u[t];switch(o){case _e:case tr:return r(a,t);case Te:{const i=r([],t);for(const l of a)i.push(n(l));return i}case Le:{const i=r({},t);for(const[l,c]of a)i[n(l)]=n(c);return i}case Qe:return r(new Date(a),t);case eu:{const{source:i,flags:l}=a;return r(new RegExp(i,l),t)}case uu:{const i=r(new Map,t);for(const[l,c]of a)i.set(n(l),n(c));return i}case ru:{const i=r(new Set,t);for(const l of a)i.add(n(l));return i}case nr:{const{name:i,message:l}=a;return r(new ar[i](l),t)}case or:return r(BigInt(a),t);case"BigInt":return r(Object(BigInt(a)),t)}return r(new ar[o](a),t)};return n},ir=e=>cn(new Map,e)(0),Q="",{toString:sn}={},{keys:pn}=Object,pe=e=>{const u=typeof e;if(u!=="object"||!e)return[_e,u];const r=sn.call(e).slice(8,-1);switch(r){case"Array":return[Te,Q];case"Object":return[Le,Q];case"Date":return[Qe,Q];case"RegExp":return[eu,Q];case"Map":return[uu,Q];case"Set":return[ru,Q]}return r.includes("Array")?[Te,r]:r.includes("Error")?[nr,r]:[Le,r]},Ne=([e,u])=>e===_e&&(u==="function"||u==="symbol"),dn=(e,u,r,n)=>{const t=(a,i)=>{const l=n.push(a)-1;return r.set(i,l),l},o=a=>{if(r.has(a))return r.get(a);let[i,l]=pe(a);switch(i){case _e:{let s=a;switch(l){case"bigint":i=or,s=a.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+l);s=null;break;case"undefined":return t([tr],a)}return t([i,s],a)}case Te:{if(l)return t([l,[...a]],a);const s=[],p=t([i,s],a);for(const f of a)s.push(o(f));return p}case Le:{if(l)switch(l){case"BigInt":return t([l,a.toString()],a);case"Boolean":case"Number":case"String":return t([l,a.valueOf()],a)}if(u&&"toJSON"in a)return o(a.toJSON());const s=[],p=t([i,s],a);for(const f of pn(a))(e||!Ne(pe(a[f])))&&s.push([o(f),o(a[f])]);return p}case Qe:return t([i,a.toISOString()],a);case eu:{const{source:s,flags:p}=a;return t([i,{source:s,flags:p}],a)}case uu:{const s=[],p=t([i,s],a);for(const[f,g]of a)(e||!(Ne(pe(f))||Ne(pe(g))))&&s.push([o(f),o(g)]);return p}case ru:{const s=[],p=t([i,s],a);for(const f of a)(e||!Ne(pe(f)))&&s.push(o(f));return p}}const{message:c}=a;return t([i,{name:l,message:c}],a)};return o},lr=(e,{json:u,lossy:r}={})=>{const n=[];return dn(!(u||r),!!u,new Map,n)(e),n},cr=typeof structuredClone=="function"?(e,u)=>u&&("json"in u||"lossy"in u)?ir(lr(e,u)):structuredClone(e):(e,u)=>ir(lr(e,u)),tu=function(e,u,r,n,t){const o=$(u);return sr(e)?o.call(t,e,r,n):!1},$=function(e){if(e==null)return mn;if(typeof e=="string")return hn(e);if(typeof e=="object")return fn(e);if(typeof e=="function")return nu(e);throw new Error("Expected function, string, or array as `test`")};function fn(e){const u=[];let r=-1;for(;++r<e.length;)u[r]=$(e[r]);return nu(n);function n(...t){let o=-1;for(;++o<u.length;)if(u[o].apply(this,t))return!0;return!1}}function hn(e){return nu(u);function u(r){return r.tagName===e}}function nu(e){return u;function u(r,n,t){return!!(sr(r)&&e.call(this,r,typeof n=="number"?n:void 0,t||void 0))}}function mn(e){return!!(e&&typeof e=="object"&&"type"in e&&e.type==="element"&&"tagName"in e&&typeof e.tagName=="string")}function sr(e){return e!==null&&typeof e=="object"&&"type"in e&&"tagName"in e}var pr=$(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"}),gn=/[ \t\n\f\r]/g;function dr(e){return typeof e=="object"?e.type==="text"?fr(e.value):!1:fr(e)}function fr(e){return e.replace(gn,"")===""}var de=function(e){if(e==null)return yn;if(typeof e=="function")return $e(e);if(typeof e=="object")return Array.isArray(e)?An(e):bn(e);if(typeof e=="string")return Dn(e);throw new Error("Expected function, string, or object as test")};function An(e){const u=[];let r=-1;for(;++r<e.length;)u[r]=de(e[r]);return $e(n);function n(...t){let o=-1;for(;++o<u.length;)if(u[o].apply(this,t))return!0;return!1}}function bn(e){const u=e;return $e(r);function r(n){const t=n;let o;for(o in e)if(t[o]!==u[o])return!1;return!0}}function Dn(e){return $e(u);function u(r){return r&&r.type===e}}function $e(e){return u;function u(r,n,t){return!!(vn(r)&&e.call(this,r,typeof n=="number"?n:void 0,t||void 0))}}function yn(){return!0}function vn(e){return e!==null&&typeof e=="object"&&"type"in e}var Cn=["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"],En=["button","input","select","textarea"],xn=["area","base","basefont","dialog","datalist","head","link","meta","noembed","noframes","param","rp","script","source","style","template","track","title"],Bn={},ou=de(["doctype","comment"]);function wn(e){const u=Ln((e||Bn).newlines?_n:Tn);return function(r){hr(r,{collapse:u,whitespace:"normal"})}}function hr(e,u){if("children"in e){const r={...u};return(e.type==="root"||Ar(e))&&(r.before=!0,r.after=!0),r.whitespace=Nn(e,u),kn(e,r)}if(e.type==="text"){if(u.whitespace==="normal")return Fn(e,u);u.whitespace==="nowrap"&&(e.value=u.collapse(e.value))}return{ignore:ou(e),stripAtStart:!1,remove:!1}}function Fn(e,u){const r=u.collapse(e.value),n={ignore:!1,stripAtStart:!1,remove:!1};let t=0,o=r.length;return u.before&&br(r.charAt(0))&&t++,t!==o&&br(r.charAt(o-1))&&(u.after?o--:n.stripAtStart=!0),t===o?n.remove=!0:e.value=r.slice(t,o),n}function kn(e,u){let r=u.before;const n=u.after,t=e.children;let o=t.length,a=-1;for(;++a<o;){const i=hr(t[a],{...u,after:mr(t,a,n),before:r});i.remove?(t.splice(a,1),a--,o--):i.ignore||(r=i.stripAtStart),gr(t[a])&&(r=!1)}return{ignore:!1,stripAtStart:!!(r||n),remove:!1}}function mr(e,u,r){for(;++u<e.length;){const n=e[u];let t=qn(n);if(t===void 0&&"children"in n&&!Sn(n)&&(t=mr(n.children,-1)),typeof t=="boolean")return t}return r}function qn(e){if(e.type==="element"){if(gr(e))return!1;if(Ar(e))return!0}else if(e.type==="text"){if(!dr(e))return!1}else if(!ou(e))return!1}function gr(e){return pr(e)||tu(e,En)}function Ar(e){return tu(e,Cn)}function Sn(e){return!!(e.type==="element"&&e.properties.hidden)||ou(e)||tu(e,xn)}function br(e){return e===" "||e===`
`}function _n(e){const u=/\r?\n|\r/.exec(e);return u?u[0]:" "}function Tn(){return" "}function Ln(e){return u;function u(r){return String(r).replace(/[\t\n\v\f\r ]+/g,e)}}function Nn(e,u){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":u.whitespace;case"textarea":return"pre-wrap"}return u.whitespace}var Dr=[],$n=!0,au=!1,yr="skip";function Un(e,u,r,n){let t;typeof u=="function"&&typeof r!="function"?(n=r,r=u):t=u;const o=de(t),a=n?-1:1;i(e,void 0,[])();function i(l,c,s){const p=l&&typeof l=="object"?l:{};if(typeof p.type=="string"){const g=typeof p.tagName=="string"?p.tagName:typeof p.name=="string"?p.name:void 0;Object.defineProperty(f,"name",{value:"node ("+(l.type+(g?"<"+g+">":""))+")"})}return f;function f(){let g=Dr,D,v,N;if((!u||o(l,c,s[s.length-1]||void 0))&&(g=Rn(r(l,s)),g[0]===au))return g;if("children"in l&&l.children){const F=l;if(F.children&&g[0]!==yr)for(v=(n?F.children.length:-1)+a,N=s.concat(F);v>-1&&v<F.children.length;){const M=F.children[v];if(D=i(M,v,N)(),D[0]===au)return D;v=typeof D[1]=="number"?D[1]:v+a}}return g}}}function Rn(e){return Array.isArray(e)?e:typeof e=="number"?[$n,e]:e==null?Dr:[e]}function Ue(e,u,r,n){let t,o,a;typeof u=="function"&&typeof r!="function"?(o=void 0,a=u,t=r):(o=u,a=r,t=n),Un(e,o,i,t);function i(l,c){const s=c[c.length-1],p=s?s.children.indexOf(l):void 0;return a(l,p,s)}}var In=vr("end"),jn=vr("start");function vr(e){return u;function u(r){const n=r&&r.position&&r.position[e]||{};if(typeof n.line=="number"&&n.line>0&&typeof n.column=="number"&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset=="number"&&n.offset>-1?n.offset:void 0}}}function On(e){const u=jn(e),r=In(e);if(u&&r)return{start:u,end:r}}function Vn(e,u){const r=u.properties||{},n=e.all(u),t={type:"link",url:e.resolve(String(r.href||"")||null),title:r.title?String(r.title):null,children:n};return e.patch(u,t),t}function Pn(e,u){e.baseFound||(e.frozenBaseUrl=String(u.properties&&u.properties.href||"")||void 0,e.baseFound=!0)}function Hn(e,u){const r={type:"blockquote",children:e.toFlow(e.all(u))};return e.patch(u,r),r}function Gn(e,u){const r={type:"break"};return e.patch(u,r),r}var Cr=function(e,u,r){const n=de(r);if(!e||!e.type||!e.children)throw new Error("Expected parent node");if(typeof u=="number"){if(u<0||u===Number.POSITIVE_INFINITY)throw new Error("Expected positive finite number as index")}else if(u=e.children.indexOf(u),u<0)throw new Error("Expected child node or index");for(;++u<e.children.length;)if(n(e.children[u],u,e))return e.children[u]},Er=/\n/g,xr=/[\t ]+/g,iu=$("br"),Br=$(Kn),Mn=$("p"),wr=$("tr"),zn=$(["datalist","head","noembed","noframes","noscript","rp","script","style","template","title",Wn,Xn]),Fr=$(["address","article","aside","blockquote","body","caption","center","dd","dialog","dir","dl","dt","div","figure","figcaption","footer","form,","h1","h2","h3","h4","h5","h6","header","hgroup","hr","html","legend","listing","main","menu","nav","ol","p","plaintext","pre","section","ul","xmp"]);function fe(e,u={}){const r="children"in e?e.children:[],n=Fr(e),t=Sr(e,{whitespace:u.whitespace||"normal",breakBefore:!1,breakAfter:!1}),o=[];(e.type==="text"||e.type==="comment")&&o.push(...qr(e,{whitespace:t,breakBefore:!0,breakAfter:!0}));let a=-1;for(;++a<r.length;)o.push(...kr(r[a],e,{whitespace:t,breakBefore:a?void 0:n,breakAfter:a<r.length-1?iu(r[a+1]):n}));const i=[];let l;for(a=-1;++a<o.length;){const c=o[a];typeof c=="number"?l!==void 0&&c>l&&(l=c):c&&(l!==void 0&&l>-1&&i.push(`
`.repeat(l)||" "),l=-1,i.push(c))}return i.join("")}function kr(e,u,r){return e.type==="element"?Jn(e,u,r):e.type==="text"?r.whitespace==="normal"?qr(e,r):Yn(e):[]}function Jn(e,u,r){const n=Sr(e,r),t=e.children||[];let o=-1,a=[];if(zn(e))return a;let i,l;for(iu(e)||wr(e)&&Cr(u,e,wr)?l=`
`:Mn(e)?(i=2,l=2):Fr(e)&&(i=1,l=1);++o<t.length;)a=a.concat(kr(t[o],e,{whitespace:n,breakBefore:o?void 0:i,breakAfter:o<t.length-1?iu(t[o+1]):l}));return Br(e)&&Cr(u,e,Br)&&a.push(" "),i&&a.unshift(i),l&&a.push(l),a}function qr(e,u){const r=String(e.value),n=[],t=[];let o=0;for(;o<=r.length;){Er.lastIndex=o;const l=Er.exec(r),c=l&&"index"in l?l.index:r.length;n.push(Zn(r.slice(o,c).replace(/[\u061C\u200E\u200F\u202A-\u202E\u2066-\u2069]/g,""),o===0?u.breakBefore:!0,c===r.length?u.breakAfter:!0)),o=c+1}let a=-1,i;for(;++a<n.length;)n[a].charCodeAt(n[a].length-1)===8203||a<n.length-1&&n[a+1].charCodeAt(0)===8203?(t.push(n[a]),i=void 0):n[a]?(typeof i=="number"&&t.push(i),t.push(n[a]),i=0):(a===0||a===n.length-1)&&t.push(0);return t}function Yn(e){return[String(e.value)]}function Zn(e,u,r){const n=[];let t=0,o;for(;t<e.length;){xr.lastIndex=t;const a=xr.exec(e);o=a?a.index:e.length,!t&&!o&&a&&!u&&n.push(""),t!==o&&n.push(e.slice(t,o)),t=a?o+a[0].length:o}return t!==o&&!r&&n.push(""),n.join(" ")}function Sr(e,u){if(e.type==="element"){const r=e.properties||{};switch(e.tagName){case"listing":case"plaintext":case"xmp":return"pre";case"nobr":return"nowrap";case"pre":return r.wrap?"pre-wrap":"pre";case"td":case"th":return r.noWrap?"nowrap":u.whitespace;case"textarea":return"pre-wrap"}}return u.whitespace}function Wn(e){return!!(e.properties||{}).hidden}function Kn(e){return e.tagName==="td"||e.tagName==="th"}function Xn(e){return e.tagName==="dialog"&&!(e.properties||{}).open}function Qn(e){const u=String(e);let r=u.length;for(;r>0;){const n=u.codePointAt(r-1);if(n!==void 0&&(n===10||n===13))r--;else break}return u.slice(0,r)}var lu="language-";function Re(e,u){const r=u.children;let n=-1,t,o;if(u.tagName==="pre")for(;++n<r.length;){const i=r[n];if(i.type==="element"&&i.tagName==="code"&&i.properties&&i.properties.className&&Array.isArray(i.properties.className)){t=i.properties.className;break}}if(t){for(n=-1;++n<t.length;)if(String(t[n]).slice(0,lu.length)===lu){o=String(t[n]).slice(lu.length);break}}const a={type:"code",lang:o||null,meta:null,value:Qn(fe(u))};return e.patch(u,a),a}function eo(e,u){const r={type:"html",value:"<!--"+u.value+"-->"};return e.patch(u,r),r}function cu(e,u){const r={type:"delete",children:e.all(u)};return e.patch(u,r),r}function su(e){let u=-1;if(e.length>1){for(;++u<e.length;)if(e[u].spread)return!0}return!1}function uo(e,u){const r=[],n=[];let t=-1;for(;++t<u.children.length;){const i=u.children[t];i.type==="element"&&i.tagName==="div"?r.push(...i.children):r.push(i)}let o={definitions:[],titles:[]};for(t=-1;++t<r.length;){const i=r[t];if(i.type==="element"&&i.tagName==="dt"){const l=r[t-1];l&&l.type==="element"&&l.tagName==="dd"&&(n.push(o),o={definitions:[],titles:[]}),o.titles.push(i)}else o.definitions.push(i)}n.push(o),t=-1;const a=[];for(;++t<n.length;){const i=[..._r(e,n[t].titles),..._r(e,n[t].definitions)];i.length>0&&a.push({type:"listItem",spread:i.length>1,checked:null,children:i})}if(a.length>0){const i={type:"list",ordered:!1,start:null,spread:su(a),children:a};return e.patch(u,i),i}}function _r(e,u){const r=e.all({type:"root",children:u}),n=e.toSpecificContent(r,ro);return n.length===0?[]:n.length===1?n[0].children:[{type:"list",ordered:!1,start:null,spread:su(n),children:n}]}function ro(){return{type:"listItem",spread:!1,checked:null,children:[]}}function Ie(e,u){const r={type:"emphasis",children:e.all(u)};return e.patch(u,r),r}function ee(e,u){const r=Number(u.tagName.charAt(1))||1,n=e.all(u),t={type:"heading",depth:r,children:n};return e.patch(u,t),t}function to(e,u){const r={type:"thematicBreak"};return e.patch(u,r),r}function no(e,u){const r=u.properties||{},n=String(r.src||""),t=String(r.title||"");if(n&&t){const o={type:"link",title:null,url:e.resolve(n),children:[{type:"text",value:t}]};return e.patch(u,o),o}}function Tr(e,u){const r=u.properties||{},n={type:"image",url:e.resolve(String(r.src||"")||null),title:r.title?String(r.title):null,alt:r.alt?String(r.alt):""};return e.patch(u,n),n}function he(e,u){const r={type:"inlineCode",value:fe(u)};return e.patch(u,r),r}function Lr(e,u){const r=[],n=[],t=u||e.properties||{},o=Nr(e),a=Math.min(Number.parseInt(String(t.size),10),0)||(t.multiple?4:1);let i=-1;for(;++i<o.length;){const s=o[i];s&&s.properties&&s.properties.selected&&r.push(s)}const l=r.length>0?r:o,c=l.length>a?a:l.length;for(i=-1;++i<c;){const s=l[i],p=s.properties||{},f=fe(s),g=f||String(p.label||""),D=String(p.value||"")||f;n.push([D,g===D?void 0:g])}return n}function Nr(e){const u=[];let r=-1;for(;++r<e.children.length;){const n=e.children[r];"children"in n&&Array.isArray(n.children)&&u.push(...Nr(n)),n.type==="element"&&n.tagName==="option"&&(!n.properties||!n.properties.disabled)&&u.push(n)}return u}var oo="[x]",ao="[ ]";function io(e,u){const r=u.properties||{},n=String(r.value||r.placeholder||"");if(r.disabled||r.type==="hidden"||r.type==="file")return;if(r.type==="checkbox"||r.type==="radio"){const l={type:"text",value:r.checked?e.options.checked||oo:e.options.unchecked||ao};return e.patch(u,l),l}if(r.type==="image"){const l=r.alt||n;if(l){const c={type:"image",url:e.resolve(String(r.src||"")||null),title:String(r.title||"")||null,alt:String(l)};return e.patch(u,c),c}return}let t=[];if(n)t=[[n,void 0]];else if(r.type!=="button"&&r.type!=="file"&&r.type!=="password"&&r.type!=="reset"&&r.type!=="submit"&&r.list){const l=String(r.list),c=e.elementById.get(l);c&&c.tagName==="datalist"&&(t=Lr(c,r))}if(t.length===0)return;if(r.type==="password"&&(t[0]=["\u2022".repeat(t[0][0].length),void 0]),r.type==="email"||r.type==="url"){const l=[];let c=-1;for(;++c<t.length;){const s=e.resolve(t[c][0]),p={type:"link",title:null,url:r.type==="email"?"mailto:"+s:s,children:[{type:"text",value:t[c][1]||s}]};l.push(p),c!==t.length-1&&l.push({type:"text",value:", "})}return l}const o=[];let a=-1;for(;++a<t.length;)o.push(t[a][1]?t[a][1]+" ("+t[a][0]+")":t[a][0]);const i={type:"text",value:o.join(", ")};return e.patch(u,i),i}var lo={}.hasOwnProperty;function co(e,u){const r=e.type==="element"&&lo.call(e.properties,u)&&e.properties[u];return r!=null&&r!==!1}var so=new Set(["pingback","prefetch","stylesheet"]);function po(e){if(e.type!=="element"||e.tagName!=="link")return!1;if(e.properties.itemProp)return!0;const u=e.properties.rel;let r=-1;if(!Array.isArray(u)||u.length===0)return!1;for(;++r<u.length;)if(!so.has(String(u[r])))return!1;return!0}var fo=$(["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"]),ho=$("meta");function $r(e){return!!(e.type==="text"||fo(e)||pr(e)||po(e)||ho(e)&&co(e,"itemProp"))}function pu(e,u){const{rest:r,checkbox:n}=Rr(u),t=n?!!n.properties.checked:null,o=Ur(r),a=e.toFlow(e.all(r)),i={type:"listItem",spread:o,checked:t,children:a};return e.patch(u,i),i}function Ur(e){let u=-1,r=!1;for(;++u<e.children.length;){const n=e.children[u];if(n.type==="element"){if($r(n))continue;if(n.tagName==="p"||r||Ur(n))return!0;r=!0}}return!1}function Rr(e){const u=e.children[0];if(u&&u.type==="element"&&u.tagName==="input"&&u.properties&&(u.properties.type==="checkbox"||u.properties.type==="radio")){const r={...e,children:e.children.slice(1)};return{checkbox:u,rest:r}}if(u&&u.type==="element"&&u.tagName==="p"){const{checkbox:r,rest:n}=Rr(u);if(r){const t={...e,children:[n,...e.children.slice(1)]};return{checkbox:r,rest:t}}}return{checkbox:void 0,rest:e}}function du(e,u){const r=u.tagName==="ol",n=e.toSpecificContent(e.all(u),mo);let t=null;r&&(t=u.properties&&u.properties.start?Number.parseInt(String(u.properties.start),10):1);const o={type:"list",ordered:r,start:t,spread:su(n),children:n};return e.patch(u,o),o}function mo(){return{type:"listItem",spread:!1,checked:null,children:[]}}var go={};function Ao(e,u){const r=go,n=typeof r.includeImageAlt=="boolean"?r.includeImageAlt:!0,t=typeof r.includeHtml=="boolean"?r.includeHtml:!0;return Ir(e,n,t)}function Ir(e,u,r){if(bo(e)){if("value"in e)return e.type==="html"&&!r?"":e.value;if(u&&"alt"in e&&e.alt)return e.alt;if("children"in e)return jr(e.children,u,r)}return Array.isArray(e)?jr(e,u,r):""}function jr(e,u,r){const n=[];let t=-1;for(;++t<e.length;)n[t]=Ir(e[t],u,r);return n.join("")}function bo(e){return!!(e&&typeof e=="object")}var Do=de(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function je(e){let u=-1;for(;++u<e.length;){const r=e[u];if(!Pr(r)||"children"in r&&je(r.children))return!0}return!1}function Or(e){return Vr(e,u,function(r){return r});function u(r){return r.every(function(n){return n.type==="text"?dr(n.value):!1})?[]:[{type:"paragraph",children:r}]}}function yo(e){return Vr(e.children,u,r);function u(n){const t=fu(e);return t.children=n,[t]}function r(n){if("children"in n&&"children"in e){const t=fu(e),o=fu(n);return t.children=n.children,o.children.push(t),o}return{...n}}}function Vr(e,u,r){const n=vo(e),t=[];let o=[],a=-1;for(;++a<n.length;){const i=n[a];Pr(i)?o.push(i):(o.length>0&&(t.push(...u(o)),o=[]),t.push(r(i)))}return o.length>0&&(t.push(...u(o)),o=[]),t}function vo(e){const u=[];let r=-1;for(;++r<e.length;){const n=e[r];(n.type==="delete"||n.type==="link")&&je(n.children)?u.push(...yo(n)):u.push(n)}return u}function Pr(e){const u=e.data&&e.data.hName;return u?$r({type:"element",tagName:u,properties:{},children:[]}):Do(e)}function fu(e){return cr({...e,children:[]})}function Hr(e,u){const r=u.properties||{},n=u.tagName==="video"?String(r.poster||""):"";let t=String(r.src||""),o=-1,a=!1,i=e.all(u);if(Ue({type:"root",children:i},function(s){if(s.type==="link")return a=!0,au}),a||je(i))return i;for(;!t&&++o<u.children.length;){const s=u.children[o];s.type==="element"&&s.tagName==="source"&&s.properties&&(t=String(s.properties.src||""))}if(n){const s={type:"image",title:null,url:e.resolve(n),alt:Ao(i)};e.patch(u,s),i=[s]}const l=i,c={type:"link",title:r.title?String(r.title):null,url:e.resolve(t),children:l};return e.patch(u,c),c}function Gr(e,u){const r=e.all(u);if(r.length>0){const n={type:"paragraph",children:r};return e.patch(u,n),n}}var Co=['"'];function Eo(e,u){const r=e.options.quotes||Co;e.qNesting++;const n=e.all(u);e.qNesting--;const t=r[e.qNesting%r.length],o=n[0],a=n[n.length-1],i=t.charAt(0),l=t.length>1?t.charAt(1):t;return o&&o.type==="text"?o.value=i+o.value:n.unshift({type:"text",value:i}),a&&a.type==="text"?a.value+=l:n.push({type:"text",value:l}),n}function xo(e,u){let r=e.all(u);(e.options.document||je(r))&&(r=Or(r));const n={type:"root",children:r};return e.patch(u,n),n}function Bo(e,u){const r=Lr(u);let n=-1;const t=[];for(;++n<r.length;){const o=r[n];t.push(o[1]?o[1]+" ("+o[0]+")":o[0])}if(t.length>0){const o={type:"text",value:t.join(", ")};return e.patch(u,o),o}}function Mr(e,u){const r={type:"strong",children:e.all(u)};return e.patch(u,r),r}function zr(e,u){const r={type:"tableCell",children:e.all(u)};if(e.patch(u,r),u.properties){const n=u.properties.rowSpan,t=u.properties.colSpan;if(n||t){const o=r.data||(r.data={});n&&(o.hastUtilToMdastTemporaryRowSpan=n),t&&(o.hastUtilToMdastTemporaryColSpan=t)}}return r}function wo(e,u){const r={type:"tableRow",children:e.toSpecificContent(e.all(u),Fo)};return e.patch(u,r),r}function Fo(){return{type:"tableCell",children:[]}}function ko(e,u){if(e.inTable){const c={type:"text",value:fe(u)};return e.patch(u,c),c}e.inTable=!0;const{align:r,headless:n}=qo(u),t=e.toSpecificContent(e.all(u),Jr);n&&t.unshift(Jr());let o=-1;for(;++o<t.length;){const c=t[o],s=e.toSpecificContent(c.children,So);c.children=s}let a=1;for(o=-1;++o<t.length;){const c=t[o].children;let s=-1;for(;++s<c.length;){const p=c[s];if(p.data){const f=p.data,g=Number.parseInt(String(f.hastUtilToMdastTemporaryColSpan),10)||1,D=Number.parseInt(String(f.hastUtilToMdastTemporaryRowSpan),10)||1;if(g>1||D>1){let v=o-1;for(;++v<o+D;){let N=s-1;for(;++N<s+g&&t[v];){const F=[];(v!==o||N!==s)&&F.push({type:"tableCell",children:[]}),t[v].children.splice(N,0,...F)}}}"hastUtilToMdastTemporaryColSpan"in p.data&&delete p.data.hastUtilToMdastTemporaryColSpan,"hastUtilToMdastTemporaryRowSpan"in p.data&&delete p.data.hastUtilToMdastTemporaryRowSpan,Object.keys(p.data).length===0&&delete p.data}}c.length>a&&(a=c.length)}for(o=-1;++o<t.length;){const c=t[o].children;let s=c.length-1;for(;++s<a;)c.push({type:"tableCell",children:[]})}let i=r.length-1;for(;++i<a;)r.push(null);e.inTable=!1;const l={type:"table",align:r,children:t};return e.patch(u,l),l}function qo(e){const u={align:[null],headless:!0};let r=0,n=0;return Ue(e,function(t){if(t.type==="element"){if(t.tagName==="table"&&e!==t)return yr;if((t.tagName==="th"||t.tagName==="td")&&t.properties){if(!u.align[n]){const o=String(t.properties.align||"")||null;(o==="center"||o==="left"||o==="right"||o===null)&&(u.align[n]=o)}u.headless&&r<2&&t.tagName==="th"&&(u.headless=!1),n++}else t.tagName==="thead"?u.headless=!1:t.tagName==="tr"&&(r++,n=0)}}),u}function So(){return{type:"tableCell",children:[]}}function Jr(){return{type:"tableRow",children:[]}}function _o(e,u){const r={type:"text",value:u.value};return e.patch(u,r),r}function To(e,u){const r={type:"text",value:fe(u)};return e.patch(u,r),r}function Lo(e,u){const r={type:"text",value:"\u200B"};return e.patch(u,r),r}var Yr={comment:eo,doctype:b,root:xo,text:_o},hu={applet:b,area:b,basefont:b,bgsound:b,caption:b,col:b,colgroup:b,command:b,content:b,datalist:b,dialog:b,element:b,embed:b,frame:b,frameset:b,isindex:b,keygen:b,link:b,math:b,menu:b,menuitem:b,meta:b,nextid:b,noembed:b,noframes:b,optgroup:b,option:b,param:b,script:b,shadow:b,source:b,spacer:b,style:b,svg:b,template:b,title:b,track:b,abbr:A,acronym:A,bdi:A,bdo:A,big:A,blink:A,button:A,canvas:A,cite:A,data:A,details:A,dfn:A,font:A,ins:A,label:A,map:A,marquee:A,meter:A,nobr:A,noscript:A,object:A,output:A,progress:A,rb:A,rbc:A,rp:A,rt:A,rtc:A,ruby:A,slot:A,small:A,span:A,sup:A,sub:A,tbody:A,tfoot:A,thead:A,time:A,address:B,article:B,aside:B,body:B,center:B,div:B,fieldset:B,figcaption:B,figure:B,form:B,footer:B,header:B,hgroup:B,html:B,legend:B,main:B,multicol:B,nav:B,picture:B,section:B,a:Vn,audio:Hr,b:Mr,base:Pn,blockquote:Hn,br:Gn,code:he,dir:du,dl:uo,dt:pu,dd:pu,del:cu,em:Ie,h1:ee,h2:ee,h3:ee,h4:ee,h5:ee,h6:ee,hr:to,i:Ie,iframe:no,img:Tr,image:Tr,input:io,kbd:he,li:pu,listing:Re,mark:Ie,ol:du,p:Gr,plaintext:Re,pre:Re,q:Eo,s:cu,samp:he,select:Bo,strike:cu,strong:Mr,summary:Gr,table:ko,td:zr,textarea:To,th:zr,tr:wo,tt:he,u:Ie,ul:du,var:he,video:Hr,wbr:Lo,xmp:Re};function A(e,u){return e.all(u)}function B(e,u){return e.toFlow(e.all(u))}function b(){}var Zr={}.hasOwnProperty;function No(e){return{all:$o,baseFound:!1,elementById:new Map,frozenBaseUrl:void 0,handlers:{...hu,...e.handlers},inTable:!1,nodeHandlers:{...Yr,...e.nodeHandlers},one:Uo,options:e,patch:Ro,qNesting:0,resolve:Io,toFlow:jo,toSpecificContent:Oo}}function $o(e){const u=e.children||[],r=[];let n=-1;for(;++n<u.length;){const a=u[n],i=this.one(a,e);Array.isArray(i)?r.push(...i):i&&r.push(i)}let t=0,o=r.length;for(;t<o&&r[t].type==="break";)t++;for(;o>t&&r[o-1].type==="break";)o--;return t===0&&o===r.length?r:r.slice(t,o)}function Uo(e,u){if(e.type==="element"){if(e.properties&&e.properties.dataMdast==="ignore")return;if(Zr.call(this.handlers,e.tagName))return this.handlers[e.tagName](this,e,u)||void 0}else if(Zr.call(this.nodeHandlers,e.type))return this.nodeHandlers[e.type](this,e,u)||void 0;if("value"in e&&typeof e.value=="string"){const r={type:"text",value:e.value};return this.patch(e,r),r}if("children"in e)return this.all(e)}function Ro(e,u){e.position&&(u.position=On(e))}function Io(e){const u=this.frozenBaseUrl;return e==null?"":u?String(new URL(e,u)):e}function jo(e){return Or(e)}function Oo(e,u){const r=u(),n=[];let t=[],o=-1;for(;++o<e.length;){const i=e[o];if(a(i))t.length>0&&(i.children.unshift(...t),t=[]),n.push(i);else{const l=i;t.push(l)}}if(t.length>0){let i=n[n.length-1];i||(i=u(),n.push(i)),i.children.push(...t),t=[]}return n;function a(i){return i.type===r.type}}var Vo={};function Po(e,u){const r=cr(e),n=u||Vo,t=wn({newlines:n.newlines===!0}),o=No(n);let a;t(r),Ue(r,function(l){if(l&&l.type==="element"&&l.properties){const c=String(l.properties.id||"")||void 0;c&&!o.elementById.has(c)&&o.elementById.set(c,l)}});const i=o.one(r,void 0);return i?Array.isArray(i)?a={type:"root",children:i}:a=i:a={type:"root",children:[]},Ue(a,function(l,c,s){if(l.type==="text"&&c!==void 0&&s){const p=s.children[c-1];if(p&&p.type===l.type)return p.value+=l.value,s.children.splice(c,1),p.position&&l.position&&(p.position.end=l.position.end),c-1;if(l.value=l.value.replace(/[\t ]*(\r?\n|\r)[\t ]*/,"$1"),s&&(s.type==="heading"||s.type==="paragraph"||s.type==="root")&&(c||(l.value=l.value.replace(/^[\t ]+/,"")),c===s.children.length-1&&(l.value=l.value.replace(/[\t ]+$/,""))),!l.value)return s.children.splice(c,1),c}}),a}var Ho=hu.li,Wr=hu.textarea,Go=Yr.root;function Kr(e){for(var u,r,n=arguments,t=1,o="",a="",i=[0],l=function(p){t===1&&(p||(o=o.replace(/^\s*\n\s*|\s*\n\s*$/g,"")))?i.push(p?n[p]:o):t===3&&(p||o)?(i[1]=p?n[p]:o,t=2):t===2&&o==="..."&&p?i[2]=Object.assign(i[2]||{},n[p]):t===2&&o&&!p?(i[2]=i[2]||{})[o]=!0:t>=5&&(t===5?((i[2]=i[2]||{})[r]=p?o?o+n[p]:n[p]:o,t=6):(p||o)&&(i[2][r]+=p?o+n[p]:o)),o=""},c=0;c<e.length;c++){c&&(t===1&&l(),l(c));for(var s=0;s<e[c].length;s++)u=e[c][s],t===1?u==="<"?(l(),i=[i,"",null],t=3):o+=u:t===4?o==="--"&&u===">"?(t=1,o=""):o=u+o[0]:a?u===a?a="":o+=u:u==='"'||u==="'"?a=u:u===">"?(l(),t=1):t&&(u==="="?(t=5,r=o,o=""):u==="/"&&(t<5||e[c][s+1]===">")?(l(),t===3&&(i=i[0]),t=i,(i=i[0]).push(this.apply(null,t.slice(1))),t=0):u===" "||u===" "||u===`
`||u==="\r"?(l(),t=2):o+=u),t===3&&o==="!--"&&(t=4,i=i[0])}return l(),i.length>2?i.slice(1):i[1]}const Mo=e=>e.replace(/&/g,"&").replace(/(?![\t\n\r ])\s/g,u=>`&#${u.codePointAt(0)};`),zo=Kr.bind((e,u,...r)=>{const n={tagName:e,type:"element",properties:{},children:[]};for(const t of u?Object.keys(u):[])n.properties[t]=ke(u[t]);for(const t of r){const o=ke(t);n.children.push(typeof o=="string"?{value:Mo(o),type:"text"}:o)}return n});function Jo(e){const{children:u}=zo([`<body>${e}</body>`]);return{type:"root",children:u}}const Yo=Ke(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]),Xr=new WeakMap;function Zo(e){return Qr(e,void 0)}function Qr(e,u){const r=Xr.get(e);if(r)return r;const n={};let t;for(t in e)t!=="children"&&(n[t]=e[t]);return Object.defineProperty(n,"node",{writable:!0,configurable:!0,value:e}),Object.defineProperty(n,"parent",{configurable:!0,get:o,set:a}),"children"in e&&Object.defineProperty(n,"children",{enumerable:!0,configurable:!0,get:i}),Xr.set(e,n),n;function o(){return u}function a(l){u=l}function i(){return e.children.map(function(c){return Qr(c,n)})}}const Wo={0:58,1:58,2:58,3:58,4:58,5:58,6:58,7:58,8:58,9:58,a:49.69999694824219,b:56,c:47.75,d:56,e:52.79998779296875,f:35.04998779296875,g:52,h:55.79998779296875,i:24,j:24,k:50.79998779296875,l:23.599990844726562,m:82.25,n:55.79998779296875,o:56.69999694824219,p:56.04998779296875,q:56,r:36.399993896484375,s:43.29998779296875,t:35.84999084472656,u:55.75,v:51.59999084472656,w:78.55000305175781,x:49.79998779296875,y:51.54998779296875,z:45.19999694824219,A:67.69999694824219,B:64.64999389648438,C:66.80000305175781,D:76.05000305175781,E:57.75,F:56.54998779296875,G:73.05000305175781,H:76.34999084472656,I:28,J:42.25,K:66.25,L:51.34999084472656,M:92.84999084472656,N:76.34999084472656,O:80.05000305175781,P:60.04998779296875,Q:80.05000305175781,R:62.649993896484375,S:54.25,T:59.04998779296875,U:73.55000305175781,V:67.69999694824219,W:103.55000305175781,X:64.89999389648438,Y:62.399993896484375,Z:60.19999694824219,"-":37.149993896484375,".":23.599990844726562,"\u2022":58,"\u25E6":40.44999694824219,"\u25AA":40.44999694824219},mu={"\u2002":50,"\u2003":75,"\u2004":33.29998779296875,"\u2005":25,"\u2006":16.649993896484375,"\u2007":58,"\u2008":21.25,"\u2009":12.5,"\u200A":6.25},Ko=Object.keys(mu).reduce((e,u)=>({...e,[mu[u]]:u}),{}),Xo=Object.values(mu).sort((e,u)=>u-e),et=new Map,ut=new Map;function rt(e){let u=et.get(e);if(u===void 0){u="";let r=e;Xo.forEach(n=>{const t=Math.floor(r/n);t>0&&(u+=Ko[n].repeat(t)),r-=n*t}),et.set(e,u)}return u}function tt(e){let u=ut.get(e);return u