=g){p=I;break}m+=h[I].length+1}let x=((a=h[p].match(/^ */))==null?void 0:a[0])||"",C=Math.min(x.length,t);if(C===0)return!0;let A=d;for(let I=0;I{let{from:a,to:c}=i,f=r.doc.textBetween(a,c,`
+`,`
+`).split(`
+`).map(h=>{var p;let m=((p=h.match(/^ */))==null?void 0:p[0])||"",g=Math.min(m.length,t);return h.slice(g)}).join(`
+`);return l.replaceWith(a,c,r.schema.text(f)),!0})},Enter:({editor:n})=>{if(!this.options.exitOnTripleEnter)return!1;let{state:e}=n,{selection:t}=e,{$from:r,empty:i}=t;if(!i||r.parent.type!==this.type)return!1;let s=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(`
+
+`);return!s||!o?!1:n.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:n})=>{if(!this.options.exitOnArrowDown)return!1;let{state:e}=n,{selection:t,doc:r}=e,{$from:i,empty:s}=t;if(!s||i.parent.type!==this.type||!(i.parentOffset===i.parent.nodeSize-2))return!1;let l=i.after();return l===void 0?!1:r.nodeAt(l)?n.commands.command(({tr:c})=>(c.setSelection(N.near(r.resolve(l))),!0)):n.commands.exitCode()}}},addInputRules(){return[bn({find:Mm,type:this.type,getAttributes:n=>({language:n[1]})}),bn({find:wm,type:this.type,getAttributes:n=>({language:n[1]})})]},addProseMirrorPlugins(){return[new O({key:new R("codeBlockVSCodeHandler"),props:{handlePaste:(n,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;let t=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),i=r?JSON.parse(r):void 0,s=i?.mode;if(!t||!s)return!1;let{tr:o,schema:l}=n.state,a=l.text(t.replace(/\r\n?/g,`
+`));return o.replaceSelectionWith(this.type.create({language:s},a)),o.selection.$from.parent.type!==this.type&&o.setSelection(E.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),n.dispatch(o),!0}}})]}});var Wc=H.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,`
+
+`):""});var Kc=H.create({name:"hardBreak",markdownTokenName:"br",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:n}){return["br",L(this.options.HTMLAttributes,n)]},renderText(){return`
+`},renderMarkdown:()=>`
+`,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:n,chain:e,state:t,editor:r})=>n.first([()=>n.exitCode(),()=>n.command(()=>{let{selection:i,storedMarks:s}=t;if(i.$from.parent.type.spec.isolating)return!1;let{keepMarks:o}=this.options,{splittableMarks:l}=r.extensionManager,a=s||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:d})=>{if(d&&a&&o){let u=a.filter(f=>l.includes(f.type.name));c.ensureMarks(u)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}});var Uc=H.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(n=>({tag:`h${n}`,attrs:{level:n}}))},renderHTML({node:n,HTMLAttributes:e}){return[`h${this.options.levels.includes(n.attrs.level)?n.attrs.level:this.options.levels[0]}`,L(this.options.HTMLAttributes,e),0]},parseMarkdown:(n,e)=>e.createNode("heading",{level:n.depth||1},e.parseInline(n.tokens||[])),renderMarkdown:(n,e)=>{var t;let r=(t=n.attrs)!=null&&t.level?parseInt(n.attrs.level,10):1,i="#".repeat(r);return n.content?`${i} ${e.renderChildren(n.content)}`:""},addCommands(){return{setHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.setNode(this.name,n):!1,toggleHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.toggleNode(this.name,"paragraph",n):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((n,e)=>({...n,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(n=>bn({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}});var Jc=H.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:n}){return["hr",L(this.options.HTMLAttributes,n)]},markdownTokenName:"hr",parseMarkdown:(n,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:n,state:e})=>{if(!Fc(e,e.schema.nodes[this.name]))return!1;let{selection:t}=e,{$to:r}=t,i=n();return xr(t)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:s,tr:o,dispatch:l})=>{if(l){let{$to:a}=o.selection,c=a.end();if(a.nodeAfter)a.nodeAfter.isTextblock?o.setSelection(E.create(o.doc,a.pos+1)):a.nodeAfter.isBlock?o.setSelection(w.create(o.doc,a.pos)):o.setSelection(E.create(o.doc,a.pos));else{let d=s.schema.nodes[this.options.nextNodeType]||a.parent.type.contentMatch.defaultType,u=d?.create();u&&(o.insert(c,u),o.setSelection(E.create(o.doc,c+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Bc({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}});var Cm=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Tm=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,vm=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,Em=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,qc=me.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:n=>n.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:n=>n.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:n}){return["em",L(this.options.HTMLAttributes,n),0]},addCommands(){return{setItalic:()=>({commands:n})=>n.setMark(this.name),toggleItalic:()=>({commands:n})=>n.toggleMark(this.name),unsetItalic:()=>({commands:n})=>n.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(n,e)=>e.applyMark("italic",e.parseInline(n.tokens||[])),markdownOptions:{htmlReopen:{open:"",close:""}},renderMarkdown:(n,e)=>`*${e.renderChildren(n)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Ne({find:Cm,type:this.type}),Ne({find:vm,type:this.type})]},addPasteRules(){return[Se({find:Tm,type:this.type}),Se({find:Em,type:this.type})]}});var Am="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5m\xF6gensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",Nm="\u03B5\u03BB1\u03C52\u0431\u04331\u0435\u043B3\u0434\u0435\u0442\u04384\u0435\u044E2\u043A\u0430\u0442\u043E\u043B\u0438\u043A6\u043E\u043C3\u043C\u043A\u04342\u043E\u043D1\u0441\u043A\u0432\u04306\u043E\u043D\u043B\u0430\u0439\u043D5\u0440\u04333\u0440\u0443\u04412\u04442\u0441\u0430\u0439\u04423\u0440\u04313\u0443\u043A\u04403\u049B\u0430\u04373\u0570\u0561\u05753\u05D9\u05E9\u05E8\u05D0\u05DC5\u05E7\u05D5\u05DD3\u0627\u0628\u0648\u0638\u0628\u064A5\u0631\u0627\u0645\u0643\u06485\u0644\u0627\u0631\u062F\u06464\u0628\u062D\u0631\u064A\u06465\u062C\u0632\u0627\u0626\u06315\u0633\u0639\u0648\u062F\u064A\u06296\u0639\u0644\u064A\u0627\u06465\u0645\u063A\u0631\u06285\u0645\u0627\u0631\u0627\u062A5\u06CC\u0631\u0627\u06465\u0628\u0627\u0631\u062A2\u0632\u0627\u06314\u064A\u062A\u06433\u06BE\u0627\u0631\u062A5\u062A\u0648\u0646\u06334\u0633\u0648\u062F\u0627\u06463\u0631\u064A\u06295\u0634\u0628\u0643\u06294\u0639\u0631\u0627\u06422\u06282\u0645\u0627\u06464\u0641\u0644\u0633\u0637\u064A\u06466\u0642\u0637\u06313\u0643\u0627\u062B\u0648\u0644\u064A\u06436\u0648\u06453\u0645\u0635\u06312\u0644\u064A\u0633\u064A\u06275\u0648\u0631\u064A\u062A\u0627\u0646\u064A\u06277\u0642\u06394\u0647\u0645\u0631\u0627\u06475\u067E\u0627\u06A9\u0633\u062A\u0627\u06467\u0680\u0627\u0631\u062A4\u0915\u0949\u092E3\u0928\u0947\u091F3\u092D\u093E\u0930\u09240\u092E\u094D3\u094B\u09245\u0938\u0902\u0917\u0920\u09285\u09AC\u09BE\u0982\u09B2\u09BE5\u09AD\u09BE\u09B0\u09A42\u09F0\u09A44\u0A2D\u0A3E\u0A30\u0A244\u0AAD\u0ABE\u0AB0\u0AA44\u0B2D\u0B3E\u0B30\u0B244\u0B87\u0BA8\u0BCD\u0BA4\u0BBF\u0BAF\u0BBE6\u0BB2\u0B99\u0BCD\u0B95\u0BC86\u0B9A\u0BBF\u0B99\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0BC2\u0BB0\u0BCD11\u0C2D\u0C3E\u0C30\u0C24\u0C4D5\u0CAD\u0CBE\u0CB0\u0CA44\u0D2D\u0D3E\u0D30\u0D24\u0D025\u0DBD\u0D82\u0D9A\u0DCF4\u0E04\u0E2D\u0E213\u0E44\u0E17\u0E223\u0EA5\u0EB2\u0EA73\u10D2\u10D42\u307F\u3093\u306A3\u30A2\u30DE\u30BE\u30F34\u30AF\u30E9\u30A6\u30C94\u30B0\u30FC\u30B0\u30EB4\u30B3\u30E02\u30B9\u30C8\u30A23\u30BB\u30FC\u30EB3\u30D5\u30A1\u30C3\u30B7\u30E7\u30F36\u30DD\u30A4\u30F3\u30C84\u4E16\u754C2\u4E2D\u4FE11\u56FD1\u570B1\u6587\u7F513\u4E9A\u9A6C\u900A3\u4F01\u4E1A2\u4F5B\u5C712\u4FE1\u606F2\u5065\u5EB72\u516B\u53662\u516C\u53F81\u76CA2\u53F0\u6E7E1\u70632\u5546\u57CE1\u5E971\u68072\u5609\u91CC0\u5927\u9152\u5E975\u5728\u7EBF2\u5927\u62FF2\u5929\u4E3B\u65593\u5A31\u4E502\u5BB6\u96FB2\u5E7F\u4E1C2\u5FAE\u535A2\u6148\u55842\u6211\u7231\u4F603\u624B\u673A2\u62DB\u80582\u653F\u52A11\u5E9C2\u65B0\u52A0\u57612\u95FB2\u65F6\u5C1A2\u66F8\u7C4D2\u673A\u67842\u6DE1\u9A6C\u95213\u6E38\u620F2\u6FB3\u95802\u70B9\u770B2\u79FB\u52A82\u7EC4\u7EC7\u673A\u67844\u7F51\u57401\u5E971\u7AD91\u7EDC2\u8054\u901A2\u8C37\u6B4C2\u8D2D\u72692\u901A\u8CA92\u96C6\u56E22\u96FB\u8A0A\u76C8\u79D14\u98DE\u5229\u6D663\u98DF\u54C12\u9910\u53852\u9999\u683C\u91CC\u62C93\u6E2F2\uB2F7\uB1371\uCEF42\uC0BC\uC1312\uD55C\uAD6D2",qs="numeric",Gs="ascii",Ys="alpha",wn="asciinumeric",Mn="alphanumeric",Xs="domain",td="emoji",Om="scheme",Im="slashscheme",_s="whitespace";function Dm(n,e){return n in e||(e[n]=[]),e[n]}function St(n,e,t){e[qs]&&(e[wn]=!0,e[Mn]=!0),e[Gs]&&(e[wn]=!0,e[Ys]=!0),e[wn]&&(e[Mn]=!0),e[Ys]&&(e[Mn]=!0),e[Mn]&&(e[Xs]=!0),e[td]&&(e[Xs]=!0);for(let r in e){let i=Dm(r,t);i.indexOf(n)<0&&i.push(n)}}function Rm(n,e){let t={};for(let r in e)e[r].indexOf(n)>=0&&(t[r]=!0);return t}function he(n=null){this.j={},this.jr=[],this.jd=null,this.t=n}he.groups={};he.prototype={accepts(){return!!this.t},go(n){let e=this,t=e.j[n];if(t)return t;for(let r=0;rn.ta(e,t,r,i),j=(n,e,t,r,i)=>n.tr(e,t,r,i),Gc=(n,e,t,r,i)=>n.ts(e,t,r,i),b=(n,e,t,r,i)=>n.tt(e,t,r,i),Je="WORD",Qs="UWORD",nd="ASCIINUMERICAL",rd="ALPHANUMERICAL",Nn="LOCALHOST",Zs="TLD",eo="UTLD",Er="SCHEME",Wt="SLASH_SCHEME",no="NUM",to="WS",ro="NL",Cn="OPENBRACE",Tn="CLOSEBRACE",Ar="OPENBRACKET",Nr="CLOSEBRACKET",Or="OPENPAREN",Ir="CLOSEPAREN",Dr="OPENANGLEBRACKET",Rr="CLOSEANGLEBRACKET",Pr="FULLWIDTHLEFTPAREN",Lr="FULLWIDTHRIGHTPAREN",zr="LEFTCORNERBRACKET",Br="RIGHTCORNERBRACKET",Fr="LEFTWHITECORNERBRACKET",$r="RIGHTWHITECORNERBRACKET",Hr="FULLWIDTHLESSTHAN",Vr="FULLWIDTHGREATERTHAN",_r="AMPERSAND",jr="APOSTROPHE",Wr="ASTERISK",rt="AT",Kr="BACKSLASH",Ur="BACKTICK",Jr="CARET",it="COLON",io="COMMA",qr="DOLLAR",Ie="DOT",Gr="EQUALS",so="EXCLAMATION",we="HYPHEN",vn="PERCENT",Yr="PIPE",Xr="PLUS",Qr="POUND",En="QUERY",oo="QUOTE",id="FULLWIDTHMIDDLEDOT",lo="SEMI",De="SLASH",An="TILDE",Zr="UNDERSCORE",sd="EMOJI",ei="SYM",od=Object.freeze({__proto__:null,ALPHANUMERICAL:rd,AMPERSAND:_r,APOSTROPHE:jr,ASCIINUMERICAL:nd,ASTERISK:Wr,AT:rt,BACKSLASH:Kr,BACKTICK:Ur,CARET:Jr,CLOSEANGLEBRACKET:Rr,CLOSEBRACE:Tn,CLOSEBRACKET:Nr,CLOSEPAREN:Ir,COLON:it,COMMA:io,DOLLAR:qr,DOT:Ie,EMOJI:sd,EQUALS:Gr,EXCLAMATION:so,FULLWIDTHGREATERTHAN:Vr,FULLWIDTHLEFTPAREN:Pr,FULLWIDTHLESSTHAN:Hr,FULLWIDTHMIDDLEDOT:id,FULLWIDTHRIGHTPAREN:Lr,HYPHEN:we,LEFTCORNERBRACKET:zr,LEFTWHITECORNERBRACKET:Fr,LOCALHOST:Nn,NL:ro,NUM:no,OPENANGLEBRACKET:Dr,OPENBRACE:Cn,OPENBRACKET:Ar,OPENPAREN:Or,PERCENT:vn,PIPE:Yr,PLUS:Xr,POUND:Qr,QUERY:En,QUOTE:oo,RIGHTCORNERBRACKET:Br,RIGHTWHITECORNERBRACKET:$r,SCHEME:Er,SEMI:lo,SLASH:De,SLASH_SCHEME:Wt,SYM:ei,TILDE:An,TLD:Zs,UNDERSCORE:Zr,UTLD:eo,UWORD:Qs,WORD:Je,WS:to}),Ke=/[a-z]/,Sn=/\p{L}/u,js=/\p{Emoji}/u;var Ue=/\d/,Ws=/\s/;var Yc="\r",Ks=`
+`,Pm="\uFE0F",Lm="\u200D",Us="\uFFFC",Cr=null,Tr=null;function zm(n=[]){let e={};he.groups=e;let t=new he;Cr==null&&(Cr=Xc(Am)),Tr==null&&(Tr=Xc(Nm)),b(t,"'",jr),b(t,"{",Cn),b(t,"}",Tn),b(t,"[",Ar),b(t,"]",Nr),b(t,"(",Or),b(t,")",Ir),b(t,"<",Dr),b(t,">",Rr),b(t,"\uFF08",Pr),b(t,"\uFF09",Lr),b(t,"\u300C",zr),b(t,"\u300D",Br),b(t,"\u300E",Fr),b(t,"\u300F",$r),b(t,"\uFF1C",Hr),b(t,"\uFF1E",Vr),b(t,"&",_r),b(t,"*",Wr),b(t,"@",rt),b(t,"`",Ur),b(t,"^",Jr),b(t,":",it),b(t,",",io),b(t,"$",qr),b(t,".",Ie),b(t,"=",Gr),b(t,"!",so),b(t,"-",we),b(t,"%",vn),b(t,"|",Yr),b(t,"+",Xr),b(t,"#",Qr),b(t,"?",En),b(t,'"',oo),b(t,"/",De),b(t,";",lo),b(t,"~",An),b(t,"_",Zr),b(t,"\\",Kr),b(t,"\u30FB",id);let r=j(t,Ue,no,{[qs]:!0});j(r,Ue,r);let i=j(r,Ke,nd,{[wn]:!0}),s=j(r,Sn,rd,{[Mn]:!0}),o=j(t,Ke,Je,{[Gs]:!0});j(o,Ue,i),j(o,Ke,o),j(i,Ue,i),j(i,Ke,i);let l=j(t,Sn,Qs,{[Ys]:!0});j(l,Ke),j(l,Ue,s),j(l,Sn,l),j(s,Ue,s),j(s,Ke),j(s,Sn,s);let a=b(t,Ks,ro,{[_s]:!0}),c=b(t,Yc,to,{[_s]:!0}),d=j(t,Ws,to,{[_s]:!0});b(t,Us,d),b(c,Ks,a),b(c,Us,d),j(c,Ws,d),b(d,Yc),b(d,Ks),j(d,Ws,d),b(d,Us,d);let u=j(t,js,sd,{[td]:!0});b(u,"#"),j(u,js,u),b(u,Pm,u);let f=b(u,Lm);b(f,"#"),j(f,js,u);let h=[[Ke,o],[Ue,i]],p=[[Ke,null],[Sn,l],[Ue,s]];for(let m=0;mm[0]>g[0]?1:-1);for(let m=0;m=0?x[Xs]=!0:Ke.test(g)?Ue.test(g)?x[wn]=!0:x[Gs]=!0:x[qs]=!0,Gc(t,g,g,x)}return Gc(t,"localhost",Nn,{ascii:!0}),t.jd=new he(ei),{start:t,tokens:Object.assign({groups:e},od)}}function ld(n,e){let t=Bm(e.replace(/[A-Z]/g,l=>l.toLowerCase())),r=t.length,i=[],s=0,o=0;for(;o=0&&(u+=t[o].length,f++),c+=t[o].length,s+=t[o].length,o++;s-=u,o-=f,c-=u,i.push({t:d.t,v:e.slice(s-c,s),s:s-c,e:s})}return i}function Bm(n){let e=[],t=n.length,r=0;for(;r56319||r+1===t||(s=n.charCodeAt(r+1))<56320||s>57343?n[r]:n.slice(r,r+2);e.push(o),r+=o.length}return e}function nt(n,e,t,r,i){let s,o=e.length;for(let l=0;l=0;)s++;if(s>0){e.push(t.join(""));for(let o=parseInt(n.substring(r,r+s),10);o>0;o--)t.pop();r+=s}else t.push(n[r]),r++}return e}var On={defaultProtocol:"http",events:null,format:Qc,formatHref:Qc,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function ao(n,e=null){let t=Object.assign({},On);n&&(t=Object.assign(t,n instanceof ao?n.o:n));let r=t.ignoreTags,i=[];for(let s=0;st?r.substring(0,t)+"\u2026":r},toFormattedHref(n){return n.get("formatHref",this.toHref(n.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(n=On.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(n),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(n){return{type:this.t,value:this.toFormattedString(n),isLink:this.isLink,href:this.toFormattedHref(n),start:this.startIndex(),end:this.endIndex()}},validate(n){return n.get("validate",this.toString(),this)},render(n){let e=this,t=this.toHref(n.get("defaultProtocol")),r=n.get("formatHref",t,this),i=n.get("tagName",t,e),s=this.toFormattedString(n),o={},l=n.get("className",t,e),a=n.get("target",t,e),c=n.get("rel",t,e),d=n.getObj("attributes",t,e),u=n.getObj("events",t,e);return o.href=r,l&&(o.class=l),a&&(o.target=a),c&&(o.rel=c),d&&Object.assign(o,d),{tagName:i,attributes:o,content:s,eventListeners:u}}};function ti(n,e){class t extends ad{constructor(i,s){super(i,s),this.t=n}}for(let r in e)t.prototype[r]=e[r];return t.t=n,t}var Zc=ti("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),ed=ti("text"),Fm=ti("nl"),vr=ti("url",{isLink:!0,toHref(n=On.defaultProtocol){return this.hasProtocol()?this.v:`${n}://${this.v}`},hasProtocol(){let n=this.tk;return n.length>=2&&n[0].t!==Nn&&n[1].t===it}});var Me=n=>new he(n);function $m({groups:n}){let e=n.domain.concat([_r,Wr,rt,Kr,Ur,Jr,qr,Gr,we,no,vn,Yr,Xr,Qr,De,ei,An,Zr]),t=[jr,it,io,Ie,so,vn,En,oo,lo,Dr,Rr,Cn,Tn,Nr,Ar,Or,Ir,Pr,Lr,zr,Br,Fr,$r,Hr,Vr],r=[_r,jr,Wr,Kr,Ur,Jr,qr,Gr,we,Cn,Tn,vn,Yr,Xr,Qr,En,De,ei,An,Zr],i=Me(),s=b(i,An);D(s,r,s),D(s,n.domain,s);let o=Me(),l=Me(),a=Me();D(i,n.domain,o),D(i,n.scheme,l),D(i,n.slashscheme,a),D(o,r,s),D(o,n.domain,o);let c=b(o,rt);b(s,rt,c),b(l,rt,c),b(a,rt,c);let d=b(s,Ie);D(d,r,s),D(d,n.domain,s);let u=Me();D(c,n.domain,u),D(u,n.domain,u);let f=b(u,Ie);D(f,n.domain,u);let h=Me(Zc);D(f,n.tld,h),D(f,n.utld,h),b(c,Nn,h);let p=b(u,we);b(p,we,p),D(p,n.domain,u),D(h,n.domain,u),b(h,Ie,f),b(h,we,p);let m=b(h,it);D(m,n.numeric,Zc);let g=b(o,we),y=b(o,Ie);b(g,we,g),D(g,n.domain,o),D(y,r,s),D(y,n.domain,o);let x=Me(vr);D(y,n.tld,x),D(y,n.utld,x),D(x,n.domain,o),D(x,r,s),b(x,Ie,y),b(x,we,g),b(x,rt,c);let C=b(x,it),A=Me(vr);D(C,n.numeric,A);let M=Me(vr),I=Me();D(M,e,M),D(M,t,I),D(I,e,M),D(I,t,I),b(x,De,M),b(A,De,M);let T=b(l,it),P=b(a,it),z=b(P,De),J=b(z,De);D(l,n.domain,o),b(l,Ie,y),b(l,we,g),D(a,n.domain,o),b(a,Ie,y),b(a,we,g),D(T,n.domain,M),b(T,De,M),b(T,En,M),D(J,n.domain,M),D(J,e,M),b(J,De,M);let qe=[[Cn,Tn],[Ar,Nr],[Or,Ir],[Dr,Rr],[Pr,Lr],[zr,Br],[Fr,$r],[Hr,Vr]];for(let Ce=0;Ce=0&&f++,i++,d++;if(f<0)i-=d,i0&&(s.push(Js(ed,e,o)),o=[]),i-=f,d-=f;let h=u.t,p=t.slice(i-d,i);s.push(Js(h,e,p))}}return o.length>0&&s.push(Js(ed,e,o)),s}function Js(n,e,t){let r=t[0].s,i=t[t.length-1].e,s=e.slice(r,i);return new n(s,t)}var Vm=typeof console<"u"&&console&&console.warn||(()=>{}),_m="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",V={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function cd(){return he.groups={},V.scanner=null,V.parser=null,V.tokenQueue=[],V.pluginQueue=[],V.customSchemes=[],V.initialized=!1,V}function co(n,e=!1){if(V.initialized&&Vm(`linkifyjs: already initialized - will not register custom scheme "${n}" ${_m}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(n))throw new Error(`linkifyjs: incorrect scheme format.
+1. Must only contain digits, lowercase ASCII letters or "-"
+2. Cannot start or end with "-"
+3. "-" cannot repeat`);V.customSchemes.push([n,e])}function jm(){V.scanner=zm(V.customSchemes);for(let n=0;n{let i=e.some(c=>c.docChanged)&&!t.doc.eq(r.doc),s=e.some(c=>c.getMeta("preventAutolink"));if(!i||s)return;let{tr:o}=r,l=Rs(t.doc,[...e]);if(Bs(l).forEach(({newRange:c})=>{let d=uc(r.doc,c,h=>h.isTextblock),u,f;if(d.length>1)u=d[0],f=r.doc.textBetween(u.pos,u.pos+u.node.nodeSize,void 0," ");else if(d.length){let h=r.doc.textBetween(c.from,c.to," "," ");if(!Km.test(h))return;u=d[0],f=r.doc.textBetween(u.pos,c.to,void 0," ")}if(u&&f){let h=f.split(Wm).filter(Boolean);if(h.length<=0)return!1;let p=h[h.length-1],m=u.pos+f.lastIndexOf(p);if(!p)return!1;let g=ni(p).map(y=>y.toObject(n.defaultProtocol));if(!Jm(g))return!1;g.filter(y=>y.isLink).map(y=>({...y,from:m+y.start+1,to:m+y.end+1})).filter(y=>r.schema.marks.code?!r.doc.rangeHasMark(y.from,y.to,r.schema.marks.code):!0).filter(y=>n.validate(y.value)).filter(y=>n.shouldAutoLink(y.value)).forEach(y=>{br(y.from,y.to,r.doc).some(x=>x.mark.type===n.type)||o.addMark(y.from,y.to,n.type.create({href:y.href}))})}}),!!o.steps.length)return o}})}function Gm(n){return new O({key:new R("handleClickLink"),props:{handleClick:(e,t,r)=>{var i,s;if(r.button!==0||!e.editable)return!1;let o=null;if(r.target instanceof HTMLAnchorElement)o=r.target;else{let a=r.target;if(!a)return!1;let c=n.editor.view.dom;o=a.closest("a"),o&&!c.contains(o)&&(o=null)}if(!o)return!1;let l=!1;if(n.enableClickSelection&&(l=n.editor.commands.extendMarkRange(n.type.name)),n.openOnClick){let a=zs(e.state,n.type.name),c=(i=o.href)!=null?i:a.href,d=(s=o.target)!=null?s:a.target;c&&(window.open(c,d),l=!0)}return l}}})}function Ym(n){return new O({key:new R("handlePasteLink"),props:{handlePaste:(e,t,r)=>{let{shouldAutoLink:i}=n,{state:s}=e,{selection:o}=s,{empty:l}=o;if(l)return!1;let a="";r.content.forEach(d=>{a+=d.textContent});let c=ri(a,{defaultProtocol:n.defaultProtocol}).find(d=>d.isLink&&d.value===a);return!a||!c||i!==void 0&&!i(c.value)?!1:n.editor.commands.setMark(n.type,{href:c.href})}}})}function Mt(n,e){let t=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{let i=typeof r=="string"?r:r.scheme;i&&t.push(i)}),!n||n.replace(Um,"").match(new RegExp(`^(?:(?:${t.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var fo=me.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(n=>{if(typeof n=="string"){co(n);return}co(n.scheme,n.optionalSlashes)})},onDestroy(){cd()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(n,e)=>!!Mt(n,e.protocols),validate:n=>!!n,shouldAutoLink:n=>{let e=/^[a-z][a-z0-9+.-]*:\/\//i.test(n),t=/^[a-z][a-z0-9+.-]*:/i.test(n);if(e||t&&!n.includes("@"))return!0;let i=(n.includes("@")?n.split("@").pop():n).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(i)||!/\./.test(i))}}},addAttributes(){return{href:{default:null,parseHTML(n){return n.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class},title:{default:null}}},parseHTML(){return[{tag:"a[href]",getAttrs:n=>{let e=n.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:t=>!!Mt(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:n}){return this.options.isAllowedUri(n.href,{defaultValidate:e=>!!Mt(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",L(this.options.HTMLAttributes,n),0]:["a",L(this.options.HTMLAttributes,{...n,href:""}),0]},markdownTokenName:"link",parseMarkdown:(n,e)=>e.applyMark("link",e.parseInline(n.tokens||[]),{href:n.href,title:n.title||null}),renderMarkdown:(n,e)=>{var t,r,i,s;let o=(r=(t=n.attrs)==null?void 0:t.href)!=null?r:"",l=(s=(i=n.attrs)==null?void 0:i.title)!=null?s:"",a=e.renderChildren(n);return l?`[${a}](${o} "${l}")`:`[${a}](${o})`},addCommands(){return{setLink:n=>({chain:e})=>{let{href:t}=n;return this.options.isAllowedUri(t,{defaultValidate:r=>!!Mt(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,n).setMeta("preventAutolink",!0).run():!1},toggleLink:n=>({chain:e})=>{let{href:t}=n||{};return t&&!this.options.isAllowedUri(t,{defaultValidate:r=>!!Mt(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,n,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:n})=>n().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[Se({find:n=>{let e=[];if(n){let{protocols:t,defaultProtocol:r}=this.options,i=ri(n).filter(s=>s.isLink&&this.options.isAllowedUri(s.value,{defaultValidate:o=>!!Mt(o,t),protocols:t,defaultProtocol:r}));i.length&&i.forEach(s=>{this.options.shouldAutoLink(s.value)&&e.push({text:s.value,data:{href:s.href},index:s.start})})}return e},type:this.type,getAttributes:n=>{var e;return{href:(e=n.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){let n=[],{protocols:e,defaultProtocol:t}=this.options;return this.options.autolink&&n.push(qm({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!Mt(i,e),protocols:e,defaultProtocol:t}),shouldAutoLink:this.options.shouldAutoLink})),n.push(Gm({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&n.push(Ym({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),n}}),dd=fo;var Xm=Object.defineProperty,Qm=(n,e)=>{for(var t in e)Xm(n,t,{get:e[t],enumerable:!0})},Zm="listItem",ud="textStyle",fd=/^\s*([-+*])\s$/,mo=H.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:n}){return["ul",L(this.options.HTMLAttributes,n),0]},markdownTokenName:"list",parseMarkdown:(n,e)=>n.type!=="list"||n.ordered?[]:{type:"bulletList",content:n.items?e.parseChildren(n.items):[]},renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,`
+`):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Zm,this.editor.getAttributes(ud)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let n=Oe({find:fd,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(n=Oe({find:fd,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(ud),editor:this.editor})),[n]}}),go=H.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",L(this.options.HTMLAttributes,n),0]},markdownTokenName:"list_item",parseMarkdown:(n,e)=>{var t;if(n.type!=="list_item")return[];let r=(t=e.parseBlockChildren)!=null?t:e.parseChildren,i=[];if(n.tokens&&n.tokens.length>0)if(n.tokens.some(o=>o.type==="paragraph"))i=r(n.tokens);else{let o=n.tokens[0];if(o&&o.type==="text"&&o.tokens&&o.tokens.length>0){if(i=[{type:"paragraph",content:e.parseInline(o.tokens)}],n.tokens.length>1){let a=n.tokens.slice(1),c=r(a);i.push(...c)}}else i=r(n.tokens)}return i.length===0&&(i=[{type:"paragraph",content:[]}]),{type:"listItem",content:i}},renderMarkdown:(n,e,t)=>xn(n,e,r=>{var i,s;return r.parentType==="bulletList"?"- ":r.parentType==="orderedList"?`${(((s=(i=r.meta)==null?void 0:i.parentAttrs)==null?void 0:s.start)||1)+r.index}. `:"- "},t),addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),eg={};Qm(eg,{findListItemPos:()=>In,getNextListDepth:()=>yo,handleBackspace:()=>ho,handleDelete:()=>po,hasListBefore:()=>gd,hasListItemAfter:()=>tg,hasListItemBefore:()=>yd,listItemHasSubList:()=>kd,nextListIsDeeper:()=>bd,nextListIsHigher:()=>xd});var In=(n,e)=>{let{$from:t}=e.selection,r=_(n,e.schema),i=null,s=t.depth,o=t.pos,l=null;for(;s>0&&l===null;)i=t.node(s),i.type===r?l=s:(s-=1,o-=1);return l===null?null:{$pos:e.doc.resolve(o),depth:l}},yo=(n,e)=>{let t=In(n,e);if(!t)return!1;let[,r]=yc(e,n,t.$pos.pos+4);return r},gd=(n,e,t)=>{let{$anchor:r}=n.selection,i=Math.max(0,r.pos-2),s=n.doc.resolve(i).node();return!(!s||!t.includes(s.type.name))},yd=(n,e)=>{var t;let{$anchor:r}=e.selection,i=e.doc.resolve(r.pos-2);return!(i.index()===0||((t=i.nodeBefore)==null?void 0:t.type.name)!==n)},kd=(n,e,t)=>{if(!t)return!1;let r=_(n,e.schema),i=!1;return t.descendants(s=>{s.type===r&&(i=!0)}),i},ho=(n,e,t)=>{if(n.commands.undoInputRule())return!0;if(n.state.selection.from!==n.state.selection.to)return!1;if(!Ae(n.state,e)&&gd(n.state,e,t)){let{$anchor:l}=n.state.selection,a=n.state.doc.resolve(l.before()-1),c=[];a.node().descendants((f,h)=>{f.type.name===e&&c.push({node:f,pos:h})});let d=c.at(-1);if(!d)return!1;let u=n.state.doc.resolve(a.start()+d.pos+1);return n.chain().cut({from:l.start()-1,to:l.end()+1},u.end()).joinForward().run()}if(!Ae(n.state,e)||!bc(n.state))return!1;let r=In(e,n.state);if(!r)return!1;let s=n.state.doc.resolve(r.$pos.pos-2).node(r.depth),o=kd(e,n.state,s);return yd(e,n.state)&&!o?n.commands.joinItemBackward():n.chain().liftListItem(e).run()},bd=(n,e)=>{let t=yo(n,e),r=In(n,e);return!r||!t?!1:t>r.depth},xd=(n,e)=>{let t=yo(n,e),r=In(n,e);return!r||!t?!1:t{if(!Ae(n.state,e)||!kc(n.state,e))return!1;let{selection:t}=n.state,{$from:r,$to:i}=t;return!t.empty&&r.sameParent(i)?!1:bd(e,n.state)?n.chain().focus(n.state.selection.from+4).lift(e).joinBackward().run():xd(e,n.state)?n.chain().joinForward().joinBackward().run():n.commands.joinItemForward()},tg=(n,e)=>{var t;let{$anchor:r}=e.selection,i=e.doc.resolve(r.pos-r.parentOffset-2);return!(i.index()===i.parent.childCount-1||((t=i.nodeAfter)==null?void 0:t.type.name)!==n)},ko=F.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t})=>{n.state.schema.nodes[t]!==void 0&&po(n,t)&&(e=!0)}),e},"Mod-Delete":({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t})=>{n.state.schema.nodes[t]!==void 0&&po(n,t)&&(e=!0)}),e},Backspace:({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t,wrapperNames:r})=>{n.state.schema.nodes[t]!==void 0&&ho(n,t,r)&&(e=!0)}),e},"Mod-Backspace":({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t,wrapperNames:r})=>{n.state.schema.nodes[t]!==void 0&&ho(n,t,r)&&(e=!0)}),e}}}}),hd=/^(\s*)(\d+)\.\s+(.*)$/,ng=/^\s/;function rg(n){let e=[],t=0,r=0;for(;te;)f.push(n[u]),u+=1;if(f.length>0){let h=Math.min(...f.map(m=>m.indent)),p=Sd(f,h,t);c.push({type:"list",ordered:!0,start:f[0].number,items:p,raw:f.map(m=>m.raw).join(`
+`)})}i.push({type:"list_item",raw:o.raw,tokens:c}),s=u}else s+=1}return i}function ig(n,e){return n.map(t=>{if(t.type!=="list_item")return e.parseChildren([t])[0];let r=[];return t.tokens&&t.tokens.length>0&&t.tokens.forEach(i=>{if(i.type==="paragraph"||i.type==="list"||i.type==="blockquote"||i.type==="code")r.push(...e.parseChildren([i]));else if(i.type==="text"&&i.tokens){let s=e.parseChildren([i]);r.push({type:"paragraph",content:s})}else{let s=e.parseChildren([i]);s.length>0&&r.push(...s)}}),{type:"listItem",content:r}})}var sg="listItem",pd="textStyle",md=/^(\d+)\.\s$/,bo=H.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:n=>n.hasAttribute("start")?parseInt(n.getAttribute("start")||"",10):1},type:{default:null,parseHTML:n=>n.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:n}){let{start:e,...t}=n;return e===1?["ol",L(this.options.HTMLAttributes,t),0]:["ol",L(this.options.HTMLAttributes,n),0]},markdownTokenName:"list",parseMarkdown:(n,e)=>{if(n.type!=="list"||!n.ordered)return[];let t=n.start||1,r=n.items?ig(n.items,e):[];return t!==1?{type:"orderedList",attrs:{start:t},content:r}:{type:"orderedList",content:r}},renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,`
+`):"",markdownTokenizer:{name:"orderedList",level:"block",start:n=>{let e=n.match(/^(\s*)(\d+)\.\s+/),t=e?.index;return t!==void 0?t:-1},tokenize:(n,e,t)=>{var r;let i=n.split(`
+`),[s,o]=rg(i);if(s.length===0)return;let l=Sd(s,0,t);return l.length===0?void 0:{type:"list",ordered:!0,start:((r=s[0])==null?void 0:r.number)||1,items:l,raw:i.slice(0,o).join(`
+`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(sg,this.editor.getAttributes(pd)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let n=Oe({find:md,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(n=Oe({find:md,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(pd)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[n]}}),og=/^\s*(\[([( |x])?\])\s$/,lg=H.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:n=>{let e=n.getAttribute("data-checked");return e===""||e==="true"},renderHTML:n=>({"data-checked":n.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:n,HTMLAttributes:e}){return["li",L(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:n.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(n,e)=>{let t=[];if(n.tokens&&n.tokens.length>0?t.push(e.createNode("paragraph",{},e.parseInline(n.tokens))):n.text?t.push(e.createNode("paragraph",{},[e.createNode("text",{text:n.text})])):t.push(e.createNode("paragraph",{},[])),n.nestedTokens&&n.nestedTokens.length>0){let r=e.parseChildren(n.nestedTokens);t.push(...r)}return e.createNode("taskItem",{checked:n.checked||!1},t)},renderMarkdown:(n,e)=>{var t;let i=`- [${(t=n.attrs)!=null&&t.checked?"x":" "}] `;return xn(n,e,i)},addKeyboardShortcuts(){let n={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...n,Tab:()=>this.editor.commands.sinkListItem(this.name)}:n},addNodeView(){return({node:n,HTMLAttributes:e,getPos:t,editor:r})=>{let i=document.createElement("li"),s=document.createElement("label"),o=document.createElement("span"),l=document.createElement("input"),a=document.createElement("div"),c=u=>{var f,h;l.ariaLabel=((h=(f=this.options.a11y)==null?void 0:f.checkboxLabel)==null?void 0:h.call(f,u,l.checked))||`Task item checkbox for ${u.textContent||"empty task item"}`};c(n),s.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",u=>u.preventDefault()),l.addEventListener("change",u=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}let{checked:f}=u.target;r.isEditable&&typeof t=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:h})=>{let p=t();if(typeof p!="number")return!1;let m=h.doc.nodeAt(p);return h.setNodeMarkup(p,void 0,{...m?.attrs,checked:f}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(n,f)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([u,f])=>{i.setAttribute(u,f)}),i.dataset.checked=n.attrs.checked,l.checked=n.attrs.checked,s.append(l,o),i.append(s,a),Object.entries(e).forEach(([u,f])=>{i.setAttribute(u,f)});let d=new Set(Object.keys(e));return{dom:i,contentDOM:a,update:u=>{if(u.type!==this.type)return!1;i.dataset.checked=u.attrs.checked,l.checked=u.attrs.checked,c(u);let f=r.extensionManager.attributes,h=_t(u,f),p=new Set(Object.keys(h)),m=this.options.HTMLAttributes;return d.forEach(g=>{p.has(g)||(g in m?i.setAttribute(g,m[g]):i.removeAttribute(g))}),Object.entries(h).forEach(([g,y])=>{y==null?g in m?i.setAttribute(g,m[g]):i.removeAttribute(g):i.setAttribute(g,y)}),d=p,!0}}}},addInputRules(){return[Oe({find:og,type:this.type,getAttributes:n=>({checked:n[n.length-1]==="x"})})]}}),ag=H.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:n}){return["ul",L(this.options.HTMLAttributes,n,{"data-type":this.name}),0]},parseMarkdown:(n,e)=>e.createNode("taskList",{},e.parseChildren(n.items||[])),renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,`
+`):"",markdownTokenizer:{name:"taskList",level:"block",start(n){var e;let t=(e=n.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return t!==void 0?t:-1},tokenize(n,e,t){let r=s=>{let o=wr(s,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:l=>({indentLevel:l[1].length,mainContent:l[4],checked:l[3].toLowerCase()==="x"}),createToken:(l,a)=>({type:"taskItem",raw:"",mainContent:l.mainContent,indentLevel:l.indentLevel,checked:l.checked,text:l.mainContent,tokens:t.inlineTokens(l.mainContent),nestedTokens:a}),customNestedParser:r},t);return o?[{type:"taskList",raw:o.raw,items:o.items}]:t.blockTokens(s)},i=wr(n,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:s=>({indentLevel:s[1].length,mainContent:s[4],checked:s[3].toLowerCase()==="x"}),createToken:(s,o)=>({type:"taskItem",raw:"",mainContent:s.mainContent,indentLevel:s.indentLevel,checked:s.checked,text:s.mainContent,tokens:t.inlineTokens(s.mainContent),nestedTokens:o}),customNestedParser:r},t);if(i)return{type:"taskList",raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:n})=>n.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}}),Tk=F.create({name:"listKit",addExtensions(){let n=[];return this.options.bulletList!==!1&&n.push(mo.configure(this.options.bulletList)),this.options.listItem!==!1&&n.push(go.configure(this.options.listItem)),this.options.listKeymap!==!1&&n.push(ko.configure(this.options.listKeymap)),this.options.orderedList!==!1&&n.push(bo.configure(this.options.orderedList)),this.options.taskItem!==!1&&n.push(lg.configure(this.options.taskItem)),this.options.taskList!==!1&&n.push(ag.configure(this.options.taskList)),n}});var ii=" ",xo="\xA0",Md=H.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",L(this.options.HTMLAttributes,n),0]},parseMarkdown:(n,e)=>{let t=n.tokens||[];if(t.length===1&&t[0].type==="image")return e.parseChildren([t[0]]);let r=e.parseInline(t);return t.length===1&&t[0].type==="text"&&(t[0].raw===ii||t[0].text===ii||t[0].raw===xo||t[0].text===xo)&&r.length===1&&r[0].type==="text"&&(r[0].text===ii||r[0].text===xo)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,r)},renderMarkdown:(n,e,t)=>{var r,i;if(!n)return"";let s=Array.isArray(n.content)?n.content:[];if(s.length===0){let o=Array.isArray((r=t?.previousNode)==null?void 0:r.content)?t.previousNode.content:[];return((i=t?.previousNode)==null?void 0:i.type)==="paragraph"&&o.length===0?ii:""}return e.renderChildren(s)},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}});var cg=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,dg=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,wd=me.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["s",L(this.options.HTMLAttributes,n),0]},markdownTokenName:"del",parseMarkdown:(n,e)=>e.applyMark("strike",e.parseInline(n.tokens||[])),renderMarkdown:(n,e)=>`~~${e.renderChildren(n)}~~`,addCommands(){return{setStrike:()=>({commands:n})=>n.setMark(this.name),toggleStrike:()=>({commands:n})=>n.toggleMark(this.name),unsetStrike:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Ne({find:cg,type:this.type})]},addPasteRules(){return[Se({find:dg,type:this.type})]}});var Cd=H.create({name:"text",group:"inline",parseMarkdown:n=>({type:"text",text:n.text||""}),renderMarkdown:n=>n.text||""});var Td=me.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["u",L(this.options.HTMLAttributes,n),0]},parseMarkdown(n,e){return e.applyMark(this.name||"underline",e.parseInline(n.tokens||[]))},renderMarkdown(n,e){return`++${e.renderChildren(n)}++`},markdownTokenizer:{name:"underline",level:"inline",start(n){return n.indexOf("++")},tokenize(n,e,t){let i=/^(\+\+)([\s\S]+?)(\+\+)/.exec(n);if(!i)return;let s=i[2].trim();return{type:"underline",raw:i[0],text:s,tokens:t.inlineTokens(s)}}},addCommands(){return{setUnderline:()=>({commands:n})=>n.setMark(this.name),toggleUnderline:()=>({commands:n})=>n.toggleMark(this.name),unsetUnderline:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function vd(n={}){return new O({view(e){return new So(e,n)}})}var So=class{constructor(e,t){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=t.width)!==null&&r!==void 0?r:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let s=o=>{this[i](o)};return e.dom.addEventListener(i,s),{name:i,handler:s}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,r,i=this.editorView.dom,s=i.getBoundingClientRect(),o=s.width/i.offsetWidth,l=s.height/i.offsetHeight;if(t){let u=e.nodeBefore,f=e.nodeAfter;if(u||f){let h=this.editorView.nodeDOM(this.cursorPos-(u?u.nodeSize:0));if(h){let p=h.getBoundingClientRect(),m=u?p.bottom:p.top;u&&f&&(m=(m+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let g=this.width/2*l;r={left:p.left,right:p.right,top:m-g,bottom:m+g}}}}if(!r){let u=this.editorView.coordsAtPos(this.cursorPos),f=this.width/2*o;r={left:u.left-f,right:u.left+f,top:u.top,bottom:u.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let c,d;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,d=-pageYOffset;else{let u=a.getBoundingClientRect(),f=u.width/a.offsetWidth,h=u.height/a.offsetHeight;c=u.left-a.scrollLeft*f,d=u.top-a.scrollTop*h}this.element.style.left=(r.left-c)/o+"px",this.element.style.top=(r.top-d)/l+"px",this.element.style.width=(r.right-r.left)/o+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),i=r&&r.type.spec.disableDropCursor,s=typeof i=="function"?i(this.editorView,t,e):i;if(t&&!s){let o=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=_n(this.editorView.state.doc,o,this.editorView.dragging.slice);l!=null&&(o=l)}this.setCursor(o),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}};var oe=class n extends N{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return n.valid(r)?new n(r):N.near(r)}content(){return S.empty}eq(e){return e instanceof n&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new n(e.resolve(t.pos))}getBookmark(){return new Mo(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!ug(e)||!fg(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let i=t.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&n.valid(e))return e;let i=e.pos,s=null;for(let o=e.depth;;o--){let l=e.node(o);if(t>0?e.indexAfter(o)0){s=l.child(t>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;i+=t;let a=e.doc.resolve(i);if(n.valid(a))return a}for(;;){let o=t>0?s.firstChild:s.lastChild;if(!o){if(s.isAtom&&!s.isText&&!w.isSelectable(s)){e=e.doc.resolve(i+s.nodeSize*t),r=!1;continue e}break}s=o,i+=t;let l=e.doc.resolve(i);if(n.valid(l))return l}return null}}};oe.prototype.visible=!1;oe.findFrom=oe.findGapCursorFrom;N.jsonID("gapcursor",oe);var Mo=class n{constructor(e){this.pos=e}map(e){return new n(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return oe.valid(t)?new oe(t):N.near(t)}};function Ed(n){return n.isAtom||n.spec.isolating||n.spec.createGapCursor}function ug(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(t-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||Ed(i.type))return!0;if(i.inlineContent)return!1}}return!0}function fg(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(t);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||Ed(i.type))return!0;if(i.inlineContent)return!1}}return!0}function Ad(){return new O({props:{decorations:gg,createSelectionBetween(n,e,t){return e.pos==t.pos&&oe.valid(t)?new oe(t):null},handleClick:pg,handleKeyDown:hg,handleDOMEvents:{beforeinput:mg}}})}var hg=Cs({ArrowLeft:si("horiz",-1),ArrowRight:si("horiz",1),ArrowUp:si("vert",-1),ArrowDown:si("vert",1)});function si(n,e){let t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,s){let o=r.selection,l=e>0?o.$to:o.$from,a=o.empty;if(o instanceof E){if(!s.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=oe.findGapCursorFrom(l,e,a);return c?(i&&i(r.tr.setSelection(new oe(c))),!0):!1}}function pg(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!oe.valid(r))return!1;let i=n.posAtCoords({left:t.clientX,top:t.clientY});return i&&i.inside>-1&&w.isSelectable(n.state.doc.nodeAt(i.inside))?!1:(n.dispatch(n.state.tr.setSelection(new oe(r))),!0)}function mg(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof oe))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let i=k.empty;for(let o=r.length-1;o>=0;o--)i=k.from(r[o].createAndFill(null,i));let s=n.state.tr.replace(t.pos,t.pos,new S(i,0,0));return s.setSelection(E.near(s.doc.resolve(t.pos+1))),n.dispatch(s),!1}function gg(n){if(!(n.selection instanceof oe))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",W.create(n.doc,[se.widget(n.selection.head,e,{key:"gapcursor"})])}var oi=200,te=function(){};te.prototype.append=function(e){return e.length?(e=te.from(e),!this.length&&e||e.length=t?te.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};te.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};te.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)};te.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(s,o){return i.push(e(s,o))},t,r),i};te.from=function(e){return e instanceof te?e:e&&e.length?new Nd(e):te.empty};var Nd=(function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,s){return i==0&&s==this.length?this:new e(this.values.slice(i,s))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,s,o,l){for(var a=s;a=o;a--)if(i(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=oi)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=oi)return new e(i.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e})(te);te.empty=new Nd([]);var yg=(function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return rl&&this.right.forEachInner(r,Math.max(i-l,0),Math.min(this.length,s)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,s,o){var l=this.left.length;if(i>l&&this.right.forEachInvertedInner(r,i-l,Math.max(s,l)-l,o+l)===!1||s=s?this.right.slice(r-s,i-s):this.left.slice(r,s).append(this.right.slice(0,i-s))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(te),wo=te;var kg=500,Ct=class n{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,s;t&&(i=this.remapping(r,this.items.length),s=i.maps.length);let o=e.tr,l,a,c=[],d=[];return this.items.forEach((u,f)=>{if(!u.step){i||(i=this.remapping(r,f+1),s=i.maps.length),s--,d.push(u);return}if(i){d.push(new Re(u.map));let h=u.step.map(i.slice(s)),p;h&&o.maybeStep(h).doc&&(p=o.mapping.maps[o.mapping.maps.length-1],c.push(new Re(p,void 0,void 0,c.length+d.length))),s--,p&&i.appendMap(p,s)}else o.maybeStep(u.step);if(u.selection)return l=i?u.selection.map(i.slice(s)):u.selection,a=new n(this.items.slice(0,r).append(d.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:o,selection:l}}addTransform(e,t,r,i){let s=[],o=this.eventCount,l=this.items,a=!i&&l.length?l.get(l.length-1):null;for(let d=0;dxg&&(l=bg(l,c),o-=c),new n(l.append(s),o)}remapping(e,t){let r=new Zt;return this.items.forEach((i,s)=>{let o=i.mirrorOffset!=null&&s-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,o)},e,t),r}addMaps(e){return this.eventCount==0?this:new n(this.items.append(e.map(t=>new Re(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-t),s=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},i);let a=t;this.items.forEach(f=>{let h=s.getMirror(--a);if(h==null)return;o=Math.min(o,h);let p=s.maps[h];if(f.step){let m=e.steps[h].invert(e.docs[h]),g=f.selection&&f.selection.map(s.slice(a+1,h));g&&l++,r.push(new Re(p,m,g))}else r.push(new Re(p))},i);let c=[];for(let f=t;fkg&&(u=u.compress(this.items.length-r.length)),u}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,i=[],s=0;return this.items.forEach((o,l)=>{if(l>=e)i.push(o),o.selection&&s++;else if(o.step){let a=o.step.map(t.slice(r)),c=a&&a.getMap();if(r--,c&&t.appendMap(c,r),a){let d=o.selection&&o.selection.map(t.slice(r));d&&s++;let u=new Re(c.invert(),a,d),f,h=i.length-1;(f=i.length&&i[h].merge(u))?i[h]=f:i.push(u)}}else o.map&&r--},this.items.length,0),new n(wo.from(i.reverse()),s)}};Ct.empty=new Ct(wo.empty,0);function bg(n,e){let t;return n.forEach((r,i)=>{if(r.selection&&e--==0)return t=i,!1}),n.slice(t)}var Re=class n{constructor(e,t,r,i){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new n(t.getMap().invert(),t,this.selection)}}},Pe=class{constructor(e,t,r,i,s){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=i,this.prevComposition=s}},xg=20;function Sg(n,e,t,r){let i=t.getMeta(wt),s;if(i)return i.historyState;t.getMeta(Cg)&&(n=new Pe(n.done,n.undone,null,0,-1));let o=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(o&&o.getMeta(wt))return o.getMeta(wt).redo?new Pe(n.done.addTransform(t,void 0,r,li(e)),n.undone,Od(t.mapping.maps),n.prevTime,n.prevComposition):new Pe(n.done,n.undone.addTransform(t,void 0,r,li(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!o&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-r.newGroupDelay||!Mg(t,n.prevRanges)),c=o?Co(n.prevRanges,t.mapping):Od(t.mapping.maps);return new Pe(n.done.addTransform(t,a?e.selection.getBookmark():void 0,r,li(e)),Ct.empty,c,t.time,l??n.prevComposition)}else return(s=t.getMeta("rebased"))?new Pe(n.done.rebased(t,s),n.undone.rebased(t,s),Co(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new Pe(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),Co(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function Mg(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,i)=>{for(let s=0;s=e[s]&&(t=!0)}),t}function Od(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,i,s,o)=>e.push(s,o));return e}function Co(n,e){if(!n)return null;let t=[];for(let r=0;r{let i=wt.getState(t);if(!i||(n?i.undone:i.done).eventCount==0)return!1;if(r){let s=wg(i,t,n);s&&r(e?s.scrollIntoView():s)}return!0}}var vo=ai(!1,!0),Eo=ai(!0,!0),Xk=ai(!1,!1),Qk=ai(!0,!1);var ib=F.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:n=>n.length,wordCounter:n=>n.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=n=>{let e=n?.node||this.editor.state.doc;if((n?.mode||this.options.mode)==="textSize"){let r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=n=>{let e=n?.node||this.editor.state.doc,t=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(t)}},addProseMirrorPlugins(){let n=!1;return[new O({key:new R("characterCount"),appendTransaction:(e,t,r)=>{if(n)return;let i=this.options.limit;if(i==null||i===0){n=!0;return}let s=this.storage.characters({node:r.doc});if(s>i){let o=s-i,l=0,a=o;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);let c=r.tr.deleteRange(l,a);return n=!0,c}n=!0},filterTransaction:(e,t)=>{let r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;let i=this.storage.characters({node:t.doc}),s=this.storage.characters({node:e.doc});if(s<=r||i>r&&s>r&&s<=i)return!0;if(i>r&&s>r&&s>i||!e.getMeta("paste"))return!1;let l=e.selection.$head.pos,a=s-r,c=l-a,d=l;return e.deleteRange(c,d),!(this.storage.characters({node:e.doc})>r)}})]}}),Ld=F.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[vd(this.options)]}}),db=F.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new O({key:new R("focus"),props:{decorations:({doc:n,selection:e})=>{let{isEditable:t,isFocused:r}=this.editor,{anchor:i}=e,s=[];if(!t||!r)return W.create(n,[]);let o=0;this.options.mode==="deepest"&&n.descendants((a,c)=>{if(a.isText)return;if(!(i>=c&&i<=c+a.nodeSize-1))return!1;o+=1});let l=0;return n.descendants((a,c)=>{if(a.isText||!(i>=c&&i<=c+a.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&o-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";s.push(se.node(c,c+a.nodeSize,{class:this.options.className}))}),W.create(n,s)}}})]}}),zd=F.create({name:"gapCursor",addProseMirrorPlugins(){return[Ad()]},extendNodeSchema(n){var e;let t={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(e=$(v(n,"allowGapCursor",t)))!=null?e:null}}}),Rd="placeholder";function Tg(n){return n.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}var gb=F.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:Rd,placeholder:"Write something \u2026",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){let n=this.options.dataAttribute?`data-${Tg(this.options.dataAttribute)}`:`data-${Rd}`;return[new O({key:new R("placeholder"),props:{decorations:({doc:e,selection:t})=>{let r=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:i}=t,s=[];if(!r)return null;let o=this.editor.isEmpty;return e.descendants((l,a)=>{let c=i>=a&&i<=a+l.nodeSize,d=!l.isLeaf&&kn(l);if(!l.type.isTextblock)return this.options.includeChildren;if((c||!this.options.showOnlyCurrent)&&d){let u=[this.options.emptyNodeClass];o&&u.push(this.options.emptyEditorClass);let f=se.node(a,a+l.nodeSize,{class:u.join(" "),[n]:typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:l,pos:a,hasAnchor:c}):this.options.placeholder});s.push(f)}return this.options.includeChildren}),W.create(e,s)}}})]}}),xb=F.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){let{editor:n,options:e}=this;return[new O({key:new R("selection"),props:{decorations(t){return t.selection.empty||n.isFocused||!n.isEditable||xr(t.selection)||n.view.dragging?null:W.create(t.doc,[se.inline(t.selection.from,t.selection.to,{class:e.className})])}}})]}}),vg="skipTrailingNode";function Pd({types:n,node:e}){return e&&Array.isArray(n)&&n.includes(e.type)||e?.type===n}var Bd=F.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var n;let e=new R(this.name),t=this.options.node||((n=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:n.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,i])=>i).filter(i=>(this.options.notAfter||[]).concat(t).includes(i.name));return[new O({key:e,appendTransaction:(i,s,o)=>{let{doc:l,tr:a,schema:c}=o,d=e.getState(o),u=l.content.size,f=c.nodes[t];if(!i.some(h=>h.getMeta(vg))&&d)return a.insert(u,f.create())},state:{init:(i,s)=>{let o=s.tr.doc.lastChild;return!Pd({node:o,types:r})},apply:(i,s)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return s;let o=i.doc.lastChild;return!Pd({node:o,types:r})}}})]}}),Fd=F.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>vo(n,e),redo:()=>({state:n,dispatch:e})=>Eo(n,e)}},addProseMirrorPlugins(){return[Dd(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-\u044F":()=>this.editor.commands.undo(),"Shift-Mod-\u044F":()=>this.editor.commands.redo()}}});var Eg=F.create({name:"starterKit",addExtensions(){var n,e,t,r;let i=[];return this.options.bold!==!1&&i.push(Vc.configure(this.options.bold)),this.options.blockquote!==!1&&i.push(Hc.configure(this.options.blockquote)),this.options.bulletList!==!1&&i.push(mo.configure(this.options.bulletList)),this.options.code!==!1&&i.push(_c.configure(this.options.code)),this.options.codeBlock!==!1&&i.push(jc.configure(this.options.codeBlock)),this.options.document!==!1&&i.push(Wc.configure(this.options.document)),this.options.dropcursor!==!1&&i.push(Ld.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&i.push(zd.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&i.push(Kc.configure(this.options.hardBreak)),this.options.heading!==!1&&i.push(Uc.configure(this.options.heading)),this.options.undoRedo!==!1&&i.push(Fd.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&i.push(Jc.configure(this.options.horizontalRule)),this.options.italic!==!1&&i.push(qc.configure(this.options.italic)),this.options.listItem!==!1&&i.push(go.configure(this.options.listItem)),this.options.listKeymap!==!1&&i.push(ko.configure((n=this.options)==null?void 0:n.listKeymap)),this.options.link!==!1&&i.push(fo.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&i.push(bo.configure(this.options.orderedList)),this.options.paragraph!==!1&&i.push(Md.configure(this.options.paragraph)),this.options.strike!==!1&&i.push(wd.configure(this.options.strike)),this.options.text!==!1&&i.push(Cd.configure(this.options.text)),this.options.underline!==!1&&i.push(Td.configure((t=this.options)==null?void 0:t.underline)),this.options.trailingNode!==!1&&i.push(Bd.configure((r=this.options)==null?void 0:r.trailingNode)),i}}),$d=Eg;window.TipTap={Editor:zc,StarterKit:$d,Link:dd};})();
diff --git a/server/src/addie/services/digest-builder.ts b/server/src/addie/services/digest-builder.ts
index 7de93489a1..f9149b734d 100644
--- a/server/src/addie/services/digest-builder.ts
+++ b/server/src/addie/services/digest-builder.ts
@@ -231,21 +231,23 @@ async function buildInsiderSection(): Promise {
const groups = await getDigestEligibleGroups();
const results: DigestInsiderGroup[] = [];
+ const NO_ACTIVITY = /^no recent activity\.?$/i;
+
for (const group of groups) {
try {
const wgContent = await buildWgDigestContent(group.id);
if (!wgContent) continue;
- // Only show groups with meetings, active threads, or a substantive summary
+ // Only show groups with actual recent activity (meetings or threads)
const hasActivity = wgContent.meetingRecaps.length > 0 || wgContent.activeThreads.length > 0;
- const NO_ACTIVITY = /^no recent activity\.?$/i;
+ if (!hasActivity) continue;
+
+ // Use the AI-generated activity summary if available,
+ // fall back to meeting recap or thread text
const hasSubstantiveSummary = wgContent.summary
&& !NO_ACTIVITY.test(wgContent.summary.trim())
&& wgContent.summary.replace(/[*_~`#>\-\s]/g, '').length >= 20;
- if (!hasActivity && !hasSubstantiveSummary) continue;
- // Prefer the AI-generated activity summary (includes Slack context),
- // fall back to meeting recap or thread text
let summary: string;
if (hasSubstantiveSummary) {
summary = truncateAtWord(wgContent.summary!, 200);
diff --git a/server/src/addie/services/digest-editor.ts b/server/src/addie/services/digest-editor.ts
index cc78a550bc..be9e36b3bc 100644
--- a/server/src/addie/services/digest-editor.ts
+++ b/server/src/addie/services/digest-editor.ts
@@ -19,7 +19,7 @@ const VALID_OPS = new Set([
const MAX_EDIT_DEPTH = 2;
const MAX_BATCH_EDITS = 5;
-const MAX_TEXT_LENGTH = 500;
+const MAX_TEXT_LENGTH = 2000;
/**
* Apply an editorial instruction to the digest content.
diff --git a/server/src/addie/templates/weekly-digest.ts b/server/src/addie/templates/weekly-digest.ts
index c841a632a2..de0ab86d83 100644
--- a/server/src/addie/templates/weekly-digest.ts
+++ b/server/src/addie/templates/weekly-digest.ts
@@ -2,11 +2,86 @@ import type { DigestContent, DigestInsiderGroup, PersonaCluster, DigestEmailReci
import type { SlackBlock, SlackBlockMessage } from '../../slack/types.js';
import { trackedUrl } from '../../notifications/email.js';
import { pickNudge } from '../services/digest-nudge.js';
+import DOMPurify from 'isomorphic-dompurify';
const BASE_URL = process.env.BASE_URL || 'https://agenticadvertising.org';
const SLACK_WORKSPACE_URL = process.env.SLACK_WORKSPACE_URL || 'https://agenticads.slack.com';
+function isHtml(text: string): boolean {
+ return /<(?:p|div|br|strong|em|ul|ol|li|a\s)[>\s/]/i.test(text);
+}
+
+/** Add inline styles to TipTap HTML for email client rendering. */
+function htmlToEmailHtml(html: string): string {
+ const clean = DOMPurify.sanitize(html, {
+ ALLOWED_TAGS: ['p', 'br', 'strong', 'b', 'em', 'i', 'a', 'ul', 'ol', 'li'],
+ ALLOWED_ATTR: ['href', 'target', 'rel'],
+ });
+ return clean
+ .replace(//g, '')
+ .replace(//g, '')
+ .replace(/- /g, '
- ')
+ .replace(/
/g, '
');
+}
+
+/** Convert TipTap HTML to Slack mrkdwn using DOM traversal. */
+function htmlToSlackMrkdwn(html: string): string {
+ const dom = DOMPurify.sanitize(html, {
+ ALLOWED_TAGS: ['p', 'br', 'strong', 'b', 'em', 'i', 'a', 'ul', 'ol', 'li'],
+ ALLOWED_ATTR: ['href'],
+ RETURN_DOM: true,
+ }) as unknown as DocumentFragment;
+ return domToSlackMrkdwn(dom).replace(/\n{3,}/g, '\n\n').trim();
+}
+
+// eslint-disable-next-line @typescript-eslint/no-explicit-any -- JSDOM node from DOMPurify RETURN_DOM
+function domToSlackMrkdwn(node: any): string {
+ if (node.nodeType === 3) return node.textContent || '';
+ if (node.nodeType !== 1) return '';
+ const el = node;
+ const tag = el.tagName?.toLowerCase();
+ const inner = Array.from(el.childNodes).map(domToSlackMrkdwn).join('');
+ switch (tag) {
+ case 'br': return '\n';
+ case 'p': return inner + '\n\n';
+ case 'strong': case 'b': return `*${inner}*`;
+ case 'em': case 'i': return `_${inner}_`;
+ case 'a': { const href = el.getAttribute('href'); return href ? `<${href}|${inner}>` : inner; }
+ case 'li': return `• ${inner}\n`;
+ case 'ul': case 'ol': return inner;
+ default: return inner;
+ }
+}
+
+/** Convert TipTap HTML to plain text using DOM traversal. */
+function htmlToPlainText(html: string): string {
+ const dom = DOMPurify.sanitize(html, {
+ ALLOWED_TAGS: ['p', 'br', 'a', 'ul', 'ol', 'li'],
+ ALLOWED_ATTR: ['href'],
+ RETURN_DOM: true,
+ }) as unknown as DocumentFragment;
+ return domToPlainText(dom).replace(/\n{3,}/g, '\n\n').trim();
+}
+
+// eslint-disable-next-line @typescript-eslint/no-explicit-any -- JSDOM node from DOMPurify RETURN_DOM
+function domToPlainText(node: any): string {
+ if (node.nodeType === 3) return node.textContent || '';
+ if (node.nodeType !== 1) return '';
+ const el = node;
+ const tag = el.tagName?.toLowerCase();
+ const inner = Array.from(el.childNodes).map(domToPlainText).join('');
+ switch (tag) {
+ case 'br': return '\n';
+ case 'p': return inner + '\n\n';
+ case 'a': { const href = el.getAttribute('href'); return href && href !== inner ? `${inner} (${href})` : inner; }
+ case 'li': return `- ${inner}\n`;
+ case 'ul': case 'ol': return inner;
+ default: return inner;
+ }
+}
+
/**
* Wrap a URL for email click tracking. Returns raw URL for web/preview renders.
*/
@@ -147,7 +222,11 @@ export function renderDigestEmail(
${content.editorsNote ? `
-
${slackLinksToHtml(content.editorsNote)}
+
${
+ isHtml(content.editorsNote)
+ ? htmlToEmailHtml(content.editorsNote)
+ : slackLinksToHtml(content.editorsNote).replace(/\n/g, '
')
+ }
` : ''}
@@ -400,7 +479,12 @@ function renderDigestText(
lines.push(content.openingTake, '');
if (content.editorsNote) {
- lines.push(slackLinksToPlainText(content.editorsNote), '');
+ lines.push(
+ isHtml(content.editorsNote)
+ ? htmlToPlainText(content.editorsNote)
+ : slackLinksToPlainText(content.editorsNote),
+ '',
+ );
}
if (content.newMembers.length > 0) {
@@ -507,9 +591,12 @@ export function renderDigestSlack(content: DigestContent, editionDate: string):
// Editor's note
if (content.editorsNote) {
+ const mrkdwn = isHtml(content.editorsNote)
+ ? htmlToSlackMrkdwn(content.editorsNote)
+ : escapeSlackMrkdwnPreserveLinks(content.editorsNote);
blocks.push({
type: 'section',
- text: { type: 'mrkdwn', text: escapeSlackMrkdwnPreserveLinks(content.editorsNote).split('\n').map((line) => `> ${line}`).join('\n') },
+ text: { type: 'mrkdwn', text: mrkdwn.split('\n').map((line) => `> ${line}`).join('\n') },
});
}
diff --git a/server/src/newsletters/the-prompt/index.ts b/server/src/newsletters/the-prompt/index.ts
index bfcf9cb771..87ff33f48f 100644
--- a/server/src/newsletters/the-prompt/index.ts
+++ b/server/src/newsletters/the-prompt/index.ts
@@ -6,6 +6,7 @@
*/
import type { NewsletterConfig } from '../config.js';
+import DOMPurify from 'isomorphic-dompurify';
import { registerNewsletter } from '../registry.js';
import { buildDigestContent, hasMinimumContent, generateDigestSubject } from '../../addie/services/digest-builder.js';
import { renderDigestEmail, renderDigestSlack, renderDigestReview } from '../../addie/templates/weekly-digest.js';
@@ -131,12 +132,44 @@ const promptDB: NewsletterEditionDB = {
// ─── Markdown builder ──────────────────────────────────────────────────
+function htmlToMarkdown(html: string): string {
+ const dom = DOMPurify.sanitize(html, {
+ ALLOWED_TAGS: ['p', 'br', 'a', 'strong', 'em', 'li'],
+ ALLOWED_ATTR: ['href'],
+ RETURN_DOM: true,
+ }) as unknown as DocumentFragment;
+ return domToMarkdown(dom).replace(/\n{3,}/g, '\n\n').trim();
+}
+
+// eslint-disable-next-line @typescript-eslint/no-explicit-any -- JSDOM node from DOMPurify RETURN_DOM
+function domToMarkdown(node: any): string {
+ if (node.nodeType === 3) return node.textContent || '';
+ if (node.nodeType !== 1) return '';
+ const el = node;
+ const tag = el.tagName?.toLowerCase();
+ const inner = Array.from(el.childNodes).map(domToMarkdown).join('');
+ switch (tag) {
+ case 'br': return '\n';
+ case 'p': return inner + '\n\n';
+ case 'strong': return `**${inner}**`;
+ case 'em': return `_${inner}_`;
+ case 'a': { const href = el.getAttribute('href'); return href ? `[${inner}](${href})` : inner; }
+ case 'li': return `- ${inner}\n`;
+ default: return inner;
+ }
+}
+
function buildPromptMarkdown(content: unknown): string {
const c = content as DigestContent;
const sections: string[] = [];
sections.push(c.openingTake);
- if (c.editorsNote) sections.push(`> ${c.editorsNote.split('\n').join('\n> ')}`);
+ if (c.editorsNote) {
+ const noteText = /<(?:p|div|br|strong|em|ul|ol|li|a\s)[>\s\/]/i.test(c.editorsNote)
+ ? htmlToMarkdown(c.editorsNote)
+ : c.editorsNote;
+ sections.push(`> ${noteText.split('\n').join('\n> ')}`);
+ }
if (c.newMembers.length > 0) {
sections.push(`Welcome to ${c.newMembers.map((m) => `**${m.name}**`).join(', ')} who joined this week.`);
}
diff --git a/server/src/routes/admin/digest.ts b/server/src/routes/admin/digest.ts
index 06677d6fa5..637db4f731 100644
--- a/server/src/routes/admin/digest.ts
+++ b/server/src/routes/admin/digest.ts
@@ -1,4 +1,5 @@
import { Router, type Request, type Response } from 'express';
+import DOMPurify from 'isomorphic-dompurify';
import { createLogger } from '../../logger.js';
import { requireAuth, requireAdmin } from '../../middleware/auth.js';
import {
@@ -208,9 +209,16 @@ export function setupDigestAdminRoutes(apiRouter: Router): void {
case 'openingTake':
content.openingTake = String(value);
break;
- case 'editorsNote':
- content.editorsNote = value ? String(value) : undefined;
+ case 'editorsNote': {
+ const raw = value ? String(value) : '';
+ content.editorsNote = raw
+ ? DOMPurify.sanitize(raw, {
+ ALLOWED_TAGS: ['p', 'br', 'strong', 'b', 'em', 'i', 'a', 'ul', 'ol', 'li'],
+ ALLOWED_ATTR: ['href', 'target', 'rel'],
+ })
+ : undefined;
break;
+ }
case 'emailSubject':
content.emailSubject = value ? String(value) : undefined;
break;