!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).wtfPerson=e()}(this,(function(){"use strict";const t={redirects:!0,infoboxes:!0,templates:!0,sections:!0};const e={headers:!0,images:!0,tables:!0,lists:!0,paragraphs:!0};const n={sentences:!0};const i=function(t,e,n){if(!e||!t)return t;"number"==typeof t&&(t=String(t)),e=e.replace(/[\-[\]/{}()*+?.\\^$|]/g,"\\$&");let i=new RegExp("\\b"+e+"\\b");return t=!0===i.test(t)?t.replace(i,n):t.replace(e,n)},a={links:!0,formatting:!0};var s=(t,e)=>{t=t||"";let n=(e=e||15)-(t=String(t)).length;n=Math.ceil(n/2);for(let i=0;i<n;i+=1)(t=" "+t).length<e&&(t+=" ");return t};const r={image:!0,caption:!0,alt:!0,signature:!0,"signature alt":!0},o={images:!0},c=s;const l=s,h=t=>"| "+(t=t.map((t=>l(t,14)))).join(" | ")+" |";const p=function(e){let n=this,i="";return!0===(e=Object.assign({},t,e)).redirects&&!0===this.isRedirect()?function(t){let e=t.redirectTo(),n=e.page;return n="./"+n.replace(/ /g,"_"),e.anchor&&(n+="#"+e.anchor),"↳ [".concat(e.text,"](").concat(n,")")}(this):(!0===e.infoboxes&&!0===e.templates&&(i+=this.infoboxes().map((t=>t.markdown(e))).join("\n\n")),!0!==e.sections&&!0!==e.paragraphs&&!0!==e.sentences||(i+=n.sections().map((t=>t.markdown(e))).join("\n\n")),!0===e.references&&(i+="## References",i+=this.citations().map((t=>t.json(e))).join("\n")),i)},d=function(t){let n="";if(!0===(t=Object.assign({},e,t)).headers&&this.title()){let t="##";for(let e=0;e<this.depth();e+=1)t+="#";n+=t+" "+this.title()+"\n"}if(!0===t.images){let t=this.images();t.length>0&&(n+=t.map((t=>t.markdown())).join("\n"),n+="\n")}if(!0===t.tables){let e=this.tables();e.length>0&&(n+="\n",n+=e.map((e=>e.markdown(t))).join("\n"),n+="\n")}if(!0===t.lists){let e=this.lists();e.length>0&&(n+=e.map((e=>e.markdown(t))).join("\n"),n+="\n")}return!0!==t.paragraphs&&!0!==t.sentences||(n+=this.paragraphs().map((e=>e.sentences().map((e=>e.markdown(t))).join(" "))).join("\n\n")),n},f=function(t){let e="";return!0===(t=Object.assign({},n,t)).sentences&&(e+=this.sentences().reduce(((e,n)=>e+=n.markdown(t)+"\n"),{})),e},m=function(t){t=Object.assign({},a,t);let e=this.text();return!0===t.links&&this.links().forEach((t=>{let n=t.markdown(),a=t.text()||t.page();e=i(e,a,n)})),!0===t.formatting&&(this.bolds().forEach((t=>{e=i(e,t,"**"+t+"**")})),this.italics().forEach((t=>{e=i(e,t,"*"+t+"*")}))),e},u=function(){let t=this.href();return t=t.replace(/ /g,"_"),"["+(this.text()||this.page())+"]("+t+")"},g=function(){let t=this.data.file.replace(/^(file|image):/i,"");return t=t.replace(/\.(jpg|jpeg|png|gif|svg)/i,""),"!["+t+"]("+this.thumbnail()+")"},k=function(t){t=Object.assign({},o,t);let e="|"+c("",35)+"|"+c("",30)+"|\n";return e+="|"+c("---",35)+"|"+c("---",30)+"|\n",Object.keys(this.data).forEach((n=>{if(!0===r[n])return;let i="**"+n+"**",a=this.data[n].markdown(t);a=a.split(/\n/g).join(", "),e+="|"+c(i,35)+"|"+c(a,30)+" |\n"})),e},w=function(t){return this.lines().map((e=>" * "+e.markdown(t))).join("\n")},b=function(){if(this.data&&this.data.url&&this.data.title)return"⌃ [".concat(this.data.title,"](").concat(this.data.url,")");if(this.data.encyclopedia)return"⌃ ".concat(this.data.encyclopedia);if(this.data.title){let t=this.data.title;return this.data.author&&(t+=this.data.author),this.data.first&&this.data.last&&(t+=this.data.first+" "+this.data.last),"⌃ ".concat(t)}return this.inline?"⌃ ".concat(this.inline.markdown()):""},j=function(t){let e="";if(!this||0===this.length)return e;let n=this.data,i=Object.keys(n[0]),a=i.map((t=>!0===/^col[0-9]/.test(t)?"":t));return e+=h(a)+"\n",e+=h(a.map((()=>"---")))+"\n",e+=n.map((e=>{let n=i.map((n=>e[n]&&e[n].markdown(t)||""));return h(n)})).join("\n"),e+"\n"};return function(t){t.Doc.prototype.markdown=p,t.Section.prototype.markdown=d,t.Paragraph.prototype.markdown=f,t.Sentence.prototype.markdown=m,t.Link.prototype.markdown=u,t.Image.prototype.markdown=g,t.Infobox.prototype.markdown=k,t.Table.prototype.markdown=j,t.List.prototype.markdown=w,t.Reference.prototype.markdown=b}}));
