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:Lt,keys:$t,freeze:Ut}=Object,J="$$jsxslack",ju=J+"Component",q=(e,u=null,...r)=>{let t=Lt(null);if(typeof e=="function"){let n={...u||{}},{length:o}=r;o===1?[n.children]=r:o>1&&(n.children=r),t=e(n)}if(t&&typeof t=="object"){for(let n of $t(t))t[n]===void 0&&delete t[n];if(!t[J]){let n=r;if(!r.length){let{children:o}=u||{};o!==void 0&&(n=[].concat(o))}Ge(t,J,{value:{type:e,props:u,children:n}})}}return t},h=(e,u,r={})=>Ge(u,ju,{value:Ut(Ge({...r},"name",{value:e,enumerable:!0}))}),It=h("Fragment",({children:e})=>[].concat(e)),Ou=e=>typeof e=="function"&&!!Object.prototype.hasOwnProperty.call(e,ju),Vu=e=>typeof e=="object"&&!!e&&!!Object.prototype.hasOwnProperty.call(e,J),Y=(e,u)=>Vu(e)&&Ou(e[J].type)&&(!u||e[J].type===u),j=e=>Array.isArray(e)?[...e]:{...e};function m(e){return e}(e=>{e.isValidElement=Vu,e.createElement=q,e.h=q,e.Fragment=It;const u=n=>n.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=n=>u([n]);e.Children=Object.freeze({count:n=>n==null?0:r(n).length,forEach:(n,o)=>{e.Children.map(n,o)},map:(n,o)=>n==null?n:r(n).reduce((a,i,l)=>{const c=o.call(i,i,l);return c!=null&&a.push(c),a},[]),only:n=>{if((0,e.isValidElement)(n))return n;throw new Error("JSXSlack.Children.only expected to receive a single JSXSlack element child.")},toArray:n=>r(n).reduce((o,a)=>a==null?o:Y(a,e.Fragment)?o.concat(e.Children.toArray([...a])):[...o,a],[])});let t=!1;e.exactMode=n=>(n!==void 0&&(t=n),t)})(m||(m={})),Object.freeze(m);const Z=(e,u)=>Object.defineProperty(u,"$$jsxslack",{value:e.$$jsxslack}),O=(e,u,r=!0)=>{const t=q(u,e.$$jsxslack.props,...e.$$jsxslack.children);return r&&typeof t=="object"&&t?Z(e,j(t)):t},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}>`}},Rt=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=Rt(u);if(!r)return;const t=S(u)||"JSX element";this.stack=`${this.name}: ${this.message}
at ${t} (${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()},Me=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?Me(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[t,n]of Object.entries(jt)){const o=Math.floor(u/n);r+=o>0?t.repeat(o):"",u%=n}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(t=>["im","mpim","private","public"].includes(t)),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 t=[...new Set(r.filter(n=>["onEnterPressed","onCharacterEntered"].includes(n)).map(n=>n==="onEnterPressed"?"on_enter_pressed":"on_character_entered"))];t.length>0&&(u.trigger_actions_on=t)}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)},N=(e,u,r)=>{const t=j(q(Gt,{element:e,from:r?`<${r.$$jsxslackComponent.name}>`:"Input layout block"}));if(u.label){const n=u.hint||u.title;return{type:"input",block_id:u.blockId||u.id,label:y(u.label),hint:n?y(n):void 0,optional:!u.required,dispatch_action:u.dispatchAction!==void 0?!!u.dispatchAction:void 0,element:t}}return e},V=h("Input",e=>e.type==="hidden"||e.type==="submit"?{}:N(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)),ze=Symbol("jsx-slack-option-selected"),W=h("Option",({children:e,description:u,selected:r,value:t})=>{const n=y(e),o={text:n,value:t||n.text,description:u!==void 0?y(u):void 0};return r!==void 0&&Object.defineProperty(o,ze,{value:r}),o}),ne=h("Option",({children:e,label:u})=>{const r=m.Children.toArray(e).reduce((t,n)=>{if(!m.isValidElement(n))return t;let o=n;if(o.$$jsxslack.type==="option"&&(o=O(o,W,!1)),o.$$jsxslack.type!==W){const a=S(n);throw new C(`<Optgroup> must contain only <Option>${a?` but it is included ${a}`:""}.`,n)}return[...t,o]},[]);return{label:y(u),options:r}}),Ju=Symbol("jsx-slack-select-fragment-selected-options"),Je=h("SelectFragment",({children:e,from:u})=>{let r=0,t;const n=`<${(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[ze]&&o.push(c);else if(s===ne)r+=c.options.length,o.push(...c.options.filter(p=>p[ze]));else{const p=S(l);throw new C(`${n} must contain either of <Option> or <Optgroup>${p?` but it is included ${p}`:""}.`,l)}if(t&&t!==s)throw new C(`<Option> and <Optgroup> cannot be mixed in the immediate children of ${n}.`,l);return t=s,[...i,c]},[]);return r>0?Object.defineProperty(t===ne?{option_groups:a}:{options:a},Ju,{value:o}):{options:[]}}),Yu=Je,I=h("Select",e=>{const u=(()=>Y(e.children,Je)?e.children:q(Je,{from:I,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),t=e.actionId||e.name,n=e.placeholder!==void 0?y(e.placeholder):void 0;return N(e.multiple?{type:"multi_static_select",action_id:t,placeholder:n,...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:t,placeholder:n,...u,initial_option:r.length>0?r[r.length-1]:void 0,confirm:e.confirm,focus_on_load:w(e)},e,I)}),K=h("Textarea",e=>N(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),t=Y(u);throw new C(`<${e}> cannot include the ${(()=>r?t&&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,...t})=>{const n=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,I))),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(n.length>25)throw new C(`<Actions> can contain up to 25 elements, but there are ${n.length} elements.`,t.__source);return{type:"actions",block_id:e||r,elements:n}}),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:t,title:n})=>({type:"image",block_id:e||u,alt_text:r,image_url:t,title:n?y(n):void 0})),zt=["January","February","March","April","May","June","July","August","September","October","November","December"],Jt=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Ye=["th","st","nd","rd"],Yt=e=>{const u=e%100;return`${e}${Ye[(u-20)%10]||Ye[u]||Ye[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()}`},t=(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}`},n=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)=>n(a===0)||"{date}").replace(/{date_short_pretty}/g,(o,a)=>n(a===0)||"{date_short}").replace(/{date_long_pretty}/g,(o,a)=>n(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,()=>t()).replace(/{time_secs}/g,()=>t(!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,t)=>`${r}\xAD${t}`).replace(/^((?:<(?:[^>]|>(?=<))*>)?)(>)/gm,(u,r,t)=>`${r}${P("\xAD\uFF1E")(t)}`),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,t,n)=>[...r,n%2?t:u(t)],[]).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((t,n,o)=>t.concat(o%2?n:r(n)),[]).join(""),er=e=>Qu(e,/(<[\s\S]*?>)/,u=>Qu(u,/(&\w+;)/,r=>[...r].map(t=>`&#${t.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 t of Object.keys(e))if(e[t]!=null&&["number","bigint","boolean","string","symbol"].includes(typeof e[t])){let n=e[t].toString();u&&(n=Fe(n)),r+=` ${t}="${n.replace(/"/g,""")}"`}return r},Xt=(e,u,r,t)=>{var n;const o=()=>r.join(""),a=(...l)=>t.length>0&&l.some(c=>c===t[t.length-1]),i=(...l)=>l.some(c=>t.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=(n=u.dateTime)!=null?n: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)),Ze=(e,u,r=!1)=>{var t;return((t=m.Children.map(e,n=>n))==null?void 0:t.reduce((n,o)=>{if(m.isValidElement(o)){const{type:a,props:i,children:l}=o.$$jsxslack;if(typeof a=="string"){const p=Ze(l,[...u,a]);return[...n,Xt(a,i||{},p,u)]}const c=!r&&a===qe,s=Ze(l,u,c);return n.concat(c?Ku(s.join("")):s)}return[...n,Fe(o.toString())]},[]))||[]},We=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]=We(e[r]);return Se(t);function t(...n){let o=-1;for(;++o<u.length;)if(u[o].apply(this,n))return!0;return!1}}function en(e){const u=e;return Se(r);function r(t){const n=t;let o;for(o in e)if(n[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,t,n){return!!(tn(r)&&e.call(this,r,typeof t=="number"?t:void 0,n||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,t){let n;typeof u=="function"&&typeof r!="function"?(t=r,r=u):n=u;const o=We(n),a=t?-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,L;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=(t?F.children.length:-1)+a,L=s.concat(F);v>-1&&v<F.children.length;){const G=F.children[v];if(D=i(G,v,L)(),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 Ke(e,u,r,t){let n,o,a;typeof u=="function"&&typeof r!="function"?(o=void 0,a=u,n=r):(o=u,a=r,n=t),an(e,o,i,n);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,Ne=2,Xe=3,Qe=4,eu=5,uu=6,nr=7,or=8,ar=typeof self=="object"?self:globalThis,cn=(e,u)=>{const r=(n,o)=>(e.set(o,n),n),t=n=>{if(e.has(n))return e.get(n);const[o,a]=u[n];switch(o){case _e:case tr:return r(a,n);case Te:{const i=r([],n);for(const l of a)i.push(t(l));return i}case Ne:{const i=r({},n);for(const[l,c]of a)i[t(l)]=t(c);return i}case Xe:return r(new Date(a),n);case Qe:{const{source:i,flags:l}=a;return r(new RegExp(i,l),n)}case eu:{const i=r(new Map,n);for(const[l,c]of a)i.set(t(l),t(c));return i}case uu:{const i=r(new Set,n);for(const l of a)i.add(t(l));return i}case nr:{const{name:i,message:l}=a;return r(new ar[i](l),n)}case or:return r(BigInt(a),n);case"BigInt":return r(Object(BigInt(a)),n)}return r(new ar[o](a),n)};return t},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[Ne,Q];case"Date":return[Xe,Q];case"RegExp":return[Qe,Q];case"Map":return[eu,Q];case"Set":return[uu,Q]}return r.includes("Array")?[Te,r]:r.includes("Error")?[nr,r]:[Ne,r]},Le=([e,u])=>e===_e&&(u==="function"||u==="symbol"),dn=(e,u,r,t)=>{const n=(a,i)=>{const l=t.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 n([tr],a)}return n([i,s],a)}case Te:{if(l)return n([l,[...a]],a);const s=[],p=n([i,s],a);for(const f of a)s.push(o(f));return p}case Ne:{if(l)switch(l){case"BigInt":return n([l,a.toString()],a);case"Boolean":case"Number":case"String":return n([l,a.valueOf()],a)}if(u&&"toJSON"in a)return o(a.toJSON());const s=[],p=n([i,s],a);for(const f of pn(a))(e||!Le(pe(a[f])))&&s.push([o(f),o(a[f])]);return p}case Xe:return n([i,a.toISOString()],a);case Qe:{const{source:s,flags:p}=a;return n([i,{source:s,flags:p}],a)}case eu:{const s=[],p=n([i,s],a);for(const[f,g]of a)(e||!(Le(pe(f))||Le(pe(g))))&&s.push([o(f),o(g)]);return p}case uu:{const s=[],p=n([i,s],a);for(const f of a)(e||!Le(pe(f)))&&s.push(o(f));return p}}const{message:c}=a;return n([i,{name:l,message:c}],a)};return o},lr=(e,{json:u,lossy:r}={})=>{const t=[];return dn(!(u||r),!!u,new Map,t)(e),t},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)),ru=function(e,u,r,t,n){const o=$(u);if(r!=null&&(typeof r!="number"||r<0||r===Number.POSITIVE_INFINITY))throw new Error("Expected positive finite `index`");if(t!=null&&(!t.type||!t.children))throw new Error("Expected valid `parent`");if(r==null!=(t==null))throw new Error("Expected both `index` and `parent`");return sr(e)?o.call(n,e,r,t):!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 tu(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 tu(t);function t(...n){let o=-1;for(;++o<u.length;)if(u[o].apply(this,n))return!0;return!1}}function hn(e){return tu(u);function u(r){return r.tagName===e}}function tu(e){return u;function u(r,t,n){return!!(sr(r)&&e.call(this,r,typeof t=="number"?t:void 0,n||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(t);function t(...n){let o=-1;for(;++o<u.length;)if(u[o].apply(this,n))return!0;return!1}}function bn(e){const u=e;return $e(r);function r(t){const n=t;let o;for(o in e)if(n[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,t,n){return!!(vn(r)&&e.call(this,r,typeof t=="number"?t:void 0,n||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={},nu=de(["doctype","comment"]);function wn(e){const u=Nn((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=Ln(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:nu(e),stripAtStart:!1,remove:!1}}function Fn(e,u){const r=u.collapse(e.value),t={ignore:!1,stripAtStart:!1,remove:!1};let n=0,o=r.length;return u.before&&br(r.charAt(0))&&n++,n!==o&&br(r.charAt(o-1))&&(u.after?o--:t.stripAtStart=!0),n===o?t.remove=!0:e.value=r.slice(n,o),t}function kn(e,u){let r=u.before;const t=u.after,n=e.children;let o=n.length,a=-1;for(;++a<o;){const i=hr(n[a],{...u,after:mr(n,a,t),before:r});i.remove?(n.splice(a,1),a--,o--):i.ignore||(r=i.stripAtStart),gr(n[a])&&(r=!1)}return{ignore:!1,stripAtStart:!!(r||t),remove:!1}}function mr(e,u,r){for(;++u<e.length;){const t=e[u];let n=qn(t);if(n===void 0&&"children"in t&&!Sn(t)&&(n=mr(t.children,-1)),typeof n=="boolean")return n}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(!nu(e))return!1}function gr(e){return pr(e)||ru(e,En)}function Ar(e){return ru(e,Cn)}function Sn(e){return!!(e.type==="element"&&e.properties.hidden)||nu(e)||ru(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 Nn(e){return u;function u(r){return String(r).replace(/[\t\n\v\f\r ]+/g,e)}}function Ln(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,ou=!1,yr="skip";function Un(e,u,r,t){let n;typeof u=="function"&&typeof r!="function"?(t=r,r=u):n=u;const o=de(n),a=t?-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,L;if((!u||o(l,c,s[s.length-1]||void 0))&&(g=In(r(l,s)),g[0]===ou))return g;if("children"in l&&l.children){const F=l;if(F.children&&g[0]!==yr)for(v=(t?F.children.length:-1)+a,L=s.concat(F);v>-1&&v<F.children.length;){const G=F.children[v];if(D=i(G,v,L)(),D[0]===ou)return D;v=typeof D[1]=="number"?D[1]:v+a}}return g}}}function In(e){return Array.isArray(e)?e:typeof e=="number"?[$n,e]:e==null?Dr:[e]}function Ue(e,u,r,t){let n,o,a;typeof u=="function"&&typeof r!="function"?(o=void 0,a=u,n=r):(o=u,a=r,n=t),Un(e,o,i,n);function i(l,c){const s=c[c.length-1],p=s?s.children.indexOf(l):void 0;return a(l,p,s)}}var Rn=vr("end"),jn=vr("start");function vr(e){return u;function u(r){const t=r&&r.position&&r.position[e]||{};if(typeof t.line=="number"&&t.line>0&&typeof t.column=="number"&&t.column>0)return{line:t.line,column:t.column,offset:typeof t.offset=="number"&&t.offset>-1?t.offset:void 0}}}function On(e){const u=jn(e),r=Rn(e);if(u&&r)return{start:u,end:r}}function Vn(e,u){const r=u.properties||{},t=e.all(u),n={type:"link",url:e.resolve(String(r.href||"")||null),title:r.title?String(r.title):null,children:t};return e.patch(u,n),n}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 t=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(t(e.children[u],u,e))return e.children[u]},Er=/\n/g,xr=/[\t ]+/g,au=$("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:[],t=Fr(e),n=Sr(e,{whitespace:u.whitespace||"normal",breakBefore:!1,breakAfter:!1}),o=[];(e.type==="text"||e.type==="comment")&&o.push(...qr(e,{whitespace:n,breakBefore:!0,breakAfter:!0}));let a=-1;for(;++a<r.length;)o.push(...kr(r[a],e,{whitespace:n,breakBefore:a?void 0:t,breakAfter:a<r.length-1?au(r[a+1]):t}));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 t=Sr(e,r),n=e.children||[];let o=-1,a=[];if(zn(e))return a;let i,l;for(au(e)||wr(e)&&Cr(u,e,wr)?l=`
`:Mn(e)?(i=2,l=2):Fr(e)&&(i=1,l=1);++o<n.length;)a=a.concat(kr(n[o],e,{whitespace:t,breakBefore:o?void 0:i,breakAfter:o<n.length-1?au(n[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),t=[],n=[];let o=0;for(;o<=r.length;){Er.lastIndex=o;const l=Er.exec(r),c=l&&"index"in l?l.index:r.length;t.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<t.length;)t[a].charCodeAt(t[a].length-1)===8203||a<t.length-1&&t[a+1].charCodeAt(0)===8203?(n.push(t[a]),i=void 0):t[a]?(typeof i=="number"&&n.push(i),n.push(t[a]),i=0):(a===0||a===t.length-1)&&n.push(0);return n}function Yn(e){return[String(e.value)]}function Zn(e,u,r){const t=[];let n=0,o;for(;n<e.length;){xr.lastIndex=n;const a=xr.exec(e);o=a?a.index:e.length,!n&&!o&&a&&!u&&t.push(""),n!==o&&t.push(e.slice(n,o)),n=a?o+a[0].length:o}return n!==o&&!r&&t.push(""),t.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 t=u.codePointAt(r-1);if(t!==void 0&&(t===10||t===13))r--;else break}return u.slice(0,r)}var iu="language-";function Ie(e,u){const r=u.children;let t=-1,n,o;if(u.tagName==="pre")for(;++t<r.length;){const i=r[t];if(i.type==="element"&&i.tagName==="code"&&i.properties&&i.properties.className&&Array.isArray(i.properties.className)){n=i.properties.className;break}}if(n){for(t=-1;++t<n.length;)if(String(n[t]).slice(0,iu.length)===iu){o=String(n[t]).slice(iu.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 lu(e,u){const r={type:"delete",children:e.all(u)};return e.patch(u,r),r}function cu(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=[],t=[];let n=-1;for(;++n<u.children.length;){const i=u.children[n];i.type==="element"&&i.tagName==="div"?r.push(...i.children):r.push(i)}let o={definitions:[],titles:[]};for(n=-1;++n<r.length;){const i=r[n];if(i.type==="element"&&i.tagName==="dt"){const l=r[n-1];l&&l.type==="element"&&l.tagName==="dd"&&(t.push(o),o={definitions:[],titles:[]}),o.titles.push(i)}else o.definitions.push(i)}t.push(o),n=-1;const a=[];for(;++n<t.length;){const i=[..._r(e,t[n].titles),..._r(e,t[n].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:cu(a),children:a};return e.patch(u,i),i}}function _r(e,u){const r=e.all({type:"root",children:u}),t=e.toSpecificContent(r,ro);return t.length===0?[]:t.length===1?t[0].children:[{type:"list",ordered:!1,start:null,spread:cu(t),children:t}]}function ro(){return{type:"listItem",spread:!1,checked:null,children:[]}}function Re(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,t=e.all(u),n={type:"heading",depth:r,children:t};return e.patch(u,n),n}function to(e,u){const r={type:"thematicBreak"};return e.patch(u,r),r}function no(e,u){const r=u.properties||{},t=String(r.src||""),n=String(r.title||"");if(t&&n){const o={type:"link",title:null,url:e.resolve(t),children:[{type:"text",value:n}]};return e.patch(u,o),o}}function Tr(e,u){const r=u.properties||{},t={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,t),t}function he(e,u){const r={type:"inlineCode",value:fe(u)};return e.patch(u,r),r}function Nr(e,u){const r=[],t=[],n=u||e.properties||{},o=Lr(e),a=Math.min(Number.parseInt(String(n.size),10),0)||(n.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;t.push([D,g===D?void 0:g])}return t}function Lr(e){const u=[];let r=-1;for(;++r<e.children.length;){const t=e.children[r];"children"in t&&Array.isArray(t.children)&&u.push(...Lr(t)),t.type==="element"&&t.tagName==="option"&&(!t.properties||!t.properties.disabled)&&u.push(t)}return u}var oo="[x]",ao="[ ]";function io(e,u){const r=u.properties||{},t=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||t;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 n=[];if(t)n=[[t,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"&&(n=Nr(c,r))}if(n.length===0)return;if(r.type==="password"&&(n[0]=["\u2022".repeat(n[0][0].length),void 0]),r.type==="email"||r.type==="url"){const l=[];let c=-1;for(;++c<n.length;){const s=e.resolve(n[c][0]),p={type:"link",title:null,url:r.type==="email"?"mailto:"+s:s,children:[{type:"text",value:n[c][1]||s}]};l.push(p),c!==n.length-1&&l.push({type:"text",value:", "})}return l}const o=[];let a=-1;for(;++a<n.length;)o.push(n[a][1]?n[a][1]+" ("+n[a][0]+")":n[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 su(e,u){const{rest:r,checkbox:t}=Ir(u),n=t?!!t.properties.checked:null,o=Ur(r),a=e.toFlow(e.all(r)),i={type:"listItem",spread:o,checked:n,children:a};return e.patch(u,i),i}function Ur(e){let u=-1,r=!1;for(;++u<e.children.length;){const t=e.children[u];if(t.type==="element"){if($r(t))continue;if(t.tagName==="p"||r||Ur(t))return!0;r=!0}}return!1}function Ir(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:t}=Ir(u);if(r){const n={...e,children:[t,...e.children.slice(1)]};return{checkbox:r,rest:n}}}return{checkbox:void 0,rest:e}}function pu(e,u){const r=u.tagName==="ol",t=e.toSpecificContent(e.all(u),mo);let n=null;r&&(n=u.properties&&u.properties.start?Number.parseInt(String(u.properties.start),10):1);const o={type:"list",ordered:r,start:n,spread:cu(t),children:t};return e.patch(u,o),o}function mo(){return{type:"listItem",spread:!1,checked:null,children:[]}}var go={};function Ao(e,u){const r=u||go,t=typeof r.includeImageAlt=="boolean"?r.includeImageAlt:!0,n=typeof r.includeHtml=="boolean"?r.includeHtml:!0;return Rr(e,t,n)}function Rr(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 t=[];let n=-1;for(;++n<e.length;)t[n]=Rr(e[n],u,r);return t.join("")}function bo(e){return!!(e&&typeof e=="object")}var Do=de(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","link","linkReference","strong","text"]);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(t){return t.type==="text"?dr(t.value):!1})?[]:[{type:"paragraph",children:r}]}}function yo(e){return Vr(e.children,u,r);function u(t){const n=du(e);return n.children=t,[n]}function r(t){if("children"in t&&"children"in e){const n=du(e),o=du(t);return n.children=t.children,o.children.push(n),o}return{...t}}}function Vr(e,u,r){const t=vo(e),n=[];let o=[],a=-1;for(;++a<t.length;){const i=t[a];Pr(i)?o.push(i):(o.length>0&&(n.push(...u(o)),o=[]),n.push(r(i)))}return o.length>0&&(n.push(...u(o)),o=[]),n}function vo(e){const u=[];let r=-1;for(;++r<e.length;){const t=e[r];(t.type==="delete"||t.type==="link")&&je(t.children)?u.push(...yo(t)):u.push(t)}return u}function Pr(e){const u=e.data&&e.data.hName;return u?$r({type:"element",tagName:u,properties:{},children:[]}):Do(e)}function du(e){return cr({...e,children:[]})}function Hr(e,u){const r=u.properties||{},t=u.tagName==="video"?String(r.poster||""):"";let n=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,ou}),a||je(i))return i;for(;!n&&++o<u.children.length;){const s=u.children[o];s.type==="element"&&s.tagName==="source"&&s.properties&&(n=String(s.properties.src||""))}if(t){const s={type:"image",title:null,url:e.resolve(t),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(n),children:l};return e.patch(u,c),c}function Gr(e,u){const r=e.all(u);if(r.length>0){const t={type:"paragraph",children:r};return e.patch(u,t),t}}var Co=['"'];function Eo(e,u){const r=e.options.quotes||Co;e.qNesting++;const t=e.all(u);e.qNesting--;const n=r[e.qNesting%r.length],o=t[0],a=t[t.length-1],i=n.charAt(0),l=n.length>1?n.charAt(1):n;return o&&o.type==="text"?o.value=i+o.value:t.unshift({type:"text",value:i}),a&&a.type==="text"?a.value+=l:t.push({type:"text",value:l}),t}function xo(e,u){let r=e.all(u);(e.options.document||je(r))&&(r=Or(r));const t={type:"root",children:r};return e.patch(u,t),t}function Bo(e,u){const r=Nr(u);let t=-1;const n=[];for(;++t<r.length;){const o=r[t];n.push(o[1]?o[1]+" ("+o[0]+")":o[0])}if(n.length>0){const o={type:"text",value:n.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 t=u.properties.rowSpan,n=u.properties.colSpan;if(t||n){const o=r.data||(r.data={});t&&(o.hastUtilToMdastTemporaryRowSpan=t),n&&(o.hastUtilToMdastTemporaryColSpan=n)}}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:t}=qo(u),n=e.toSpecificContent(e.all(u),Jr);t&&n.unshift(Jr());let o=-1;for(;++o<n.length;){const c=n[o],s=e.toSpecificContent(c.children,So);c.children=s}let a=1;for(o=-1;++o<n.length;){const c=n[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 L=s-1;for(;++L<s+g&&n[v];){const F=[];(v!==o||L!==s)&&F.push({type:"tableCell",children:[]}),n[v].children.splice(L,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<n.length;){const c=n[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:n};return e.patch(u,l),l}function qo(e){const u={align:[null],headless:!0};let r=0,t=0;return Ue(e,function(n){if(n.type==="element"){if(n.tagName==="table"&&e!==n)return yr;if((n.tagName==="th"||n.tagName==="td")&&n.properties){if(!u.align[t]){const o=String(n.properties.align||"")||null;(o==="center"||o==="left"||o==="right"||o===null)&&(u.align[t]=o)}u.headless&&r<2&&n.tagName==="th"&&(u.headless=!1),t++}else n.tagName==="thead"?u.headless=!1:n.tagName==="tr"&&(r++,t=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 No(e,u){const r={type:"text",value:"\u200B"};return e.patch(u,r),r}var Yr={comment:eo,doctype:b,root:xo,text:_o},fu={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:pu,dl:uo,dt:su,dd:su,del:lu,em:Re,h1:ee,h2:ee,h3:ee,h4:ee,h5:ee,h6:ee,hr:to,i:Re,iframe:no,img:Tr,image:Tr,input:io,kbd:he,li:su,listing:Ie,mark:Re,ol:pu,p:Gr,plaintext:Ie,pre:Ie,q:Eo,s:lu,samp:he,select:Bo,strike:lu,strong:Mr,summary:Gr,table:ko,td:zr,textarea:To,th:zr,tr:wo,tt:he,u:Re,ul:pu,var:he,video:Hr,wbr:No,xmp:Ie};function A(e,u){return e.all(u)}function B(e,u){return e.toFlow(e.all(u))}function b(){}var Zr={}.hasOwnProperty;function Lo(e){return{all:$o,baseFound:!1,elementById:new Map,frozenBaseUrl:void 0,handlers:{...fu,...e.handlers},inTable:!1,nodeHandlers:{...Yr,...e.nodeHandlers},one:Uo,options:e,patch:Io,qNesting:0,resolve:Ro,toFlow:jo,toSpecificContent:Oo}}function $o(e){const u=e.children||[],r=[];let t=-1;for(;++t<u.length;){const a=u[t],i=this.one(a,e);Array.isArray(i)?r.push(...i):i&&r.push(i)}let n=0,o=r.length;for(;n<o&&r[n].type==="break";)n++;for(;o>n&&r[o-1].type==="break";)o--;return n===0&&o===r.length?r:r.slice(n,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 Io(e,u){e.position&&(u.position=On(e))}function Ro(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(),t=[];let n=[],o=-1;for(;++o<e.length;){const i=e[o];if(a(i))n.length>0&&(i.children.unshift(...n),n=[]),t.push(i);else{const l=i;n.push(l)}}if(n.length>0){let i=t[t.length-1];i||(i=u(),t.push(i)),i.children.push(...n),n=[]}return t;function a(i){return i.type===r.type}}var Vo={};function Po(e,u){const r=cr(e),t=u||Vo,n=wn({newlines:t.newlines===!0}),o=Lo(t);let a;n(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=fu.li,Wr=fu.textarea,Go=Yr.root;function Kr(e){for(var u,r,t=arguments,n=1,o="",a="",i=[0],l=function(p){n===1&&(p||(o=o.replace(/^\s*\n\s*|\s*\n\s*$/g,"")))?i.push(p?t[p]:o):n===3&&(p||o)?(i[1]=p?t[p]:o,n=2):n===2&&o==="..."&&p?i[2]=Object.assign(i[2]||{},t[p]):n===2&&o&&!p?(i[2]=i[2]||{})[o]=!0:n>=5&&(n===5?((i[2]=i[2]||{})[r]=p?o?o+t[p]:t[p]:o,n=6):(p||o)&&(i[2][r]+=p?o+t[p]:o)),o=""},c=0;c<e.length;c++){c&&(n===1&&l(),l(c));for(var s=0;s<e[c].length;s++)u=e[c][s],n===1?u==="<"?(l(),i=[i,"",null],n=3):o+=u:n===4?o==="--"&&u===">"?(n=1,o=""):o=u+o[0]:a?u===a?a="":o+=u:u==='"'||u==="'"?a=u:u===">"?(l(),n=1):n&&(u==="="?(n=5,r=o,o=""):u==="/"&&(n<5||e[c][s+1]===">")?(l(),n===3&&(i=i[0]),n=i,(i=i[0]).push(this.apply(null,n.slice(1))),n=0):u===" "||u===" "||u===`
`||u==="\r"?(l(),n=2):o+=u),n===3&&o==="!--"&&(n=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 t={tagName:e,type:"element",properties:{},children:[]};for(const n of u?Object.keys(u):[])t.properties[n]=ke(u[n]);for(const n of r){const o=ke(n);t.children.push(typeof o=="string"?{value:Mo(o),type:"text"}:o)}return t});function Jo(e){const{children:u}=zo([`<body>${e}</body>`]);return{type:"root",children:u}}const Yo=We(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","link","linkReference","strong","text"]),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 t={};let n;for(n in e)n!=="children"&&(t[n]=e[n]);return Object.defineProperty(t,"node",{writable:!0,configurable:!0,value:e}),Object.defineProperty(t,"parent",{configurable:!0,get:o,set:a}),"children"in e&&Object.defineProperty(t,"children",{enumerable:!0,configurable:!0,get:i}),Xr.set(e,t),t;function o(){return u}function a(l){u=l}function i(){return e.children.map(function(c){return Qr(c,t)})}}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},hu={"\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(hu).reduce((e,u)=>({...e,[hu[u]]:u}),{}),Xo=Object.values(hu).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(t=>{const n=M