import{r as e}from"./rolldown-runtime.WmLfqUcM.js";var t=e({plugin_exports:()=>n});(function(){var e=hugerte.util.Tools.resolve(`hugerte.PluginManager`);let t=(e,t,n)=>{let r=t===`UL`?`InsertUnorderedList`:`InsertOrderedList`;e.execCommand(r,!1,n===!1?null:{"list-style-type":n})},n=e=>{e.addCommand(`ApplyUnorderedListStyle`,(n,r)=>{t(e,`UL`,r[`list-style-type`])}),e.addCommand(`ApplyOrderedListStyle`,(n,r)=>{t(e,`OL`,r[`list-style-type`])})},r=e=>t=>t.options.get(e),i=e=>{let t=e.options.register;t(`advlist_number_styles`,{processor:`string[]`,default:`default,lower-alpha,lower-greek,lower-roman,upper-alpha,upper-roman`.split(`,`)}),t(`advlist_bullet_styles`,{processor:`string[]`,default:`default,circle,square`.split(`,`)})},a=r(`advlist_number_styles`),o=r(`advlist_bullet_styles`),s=e=>e==null,c=e=>!s(e);var l=hugerte.util.Tools.resolve(`hugerte.util.Tools`);class u{constructor(e,t){this.tag=e,this.value=t}static some(e){return new u(!0,e)}static none(){return u.singletonNone}fold(e,t){return this.tag?t(this.value):e()}isSome(){return this.tag}isNone(){return!this.tag}map(e){return this.tag?u.some(e(this.value)):u.none()}bind(e){return this.tag?e(this.value):u.none()}exists(e){return this.tag&&e(this.value)}forall(e){return!this.tag||e(this.value)}filter(e){return!this.tag||e(this.value)?this:u.none()}getOr(e){return this.tag?this.value:e}or(e){return this.tag?this:e}getOrThunk(e){return this.tag?this.value:e()}orThunk(e){return this.tag?this:e()}getOrDie(e){if(this.tag)return this.value;throw Error(e??`Called getOrDie on None`)}static from(e){return c(e)?u.some(e):u.none()}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(e){this.tag&&e(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:`none()`}}u.singletonNone=new u(!1);let d=(e,t,n)=>{for(let r=0,i=e.length;r<i;r++){let i=e[r];if(t(i,r))return u.some(i);if(n(i,r))break}return u.none()},f=e=>/\btox\-/.test(e.className),p=(e,t)=>e.dom.isChildOf(t,e.getBody()),m=e=>t=>c(t)&&e.test(t.nodeName),h=m(/^(OL|UL|DL)$/),g=m(/^(TH|TD)$/),_=(e,t,n)=>d(t,e=>h(e)&&!f(e),g).exists(t=>t.nodeName===n&&p(e,t)),v=e=>{let t=e.dom.getParent(e.selection.getNode(),`ol,ul`),n=e.dom.getStyle(t,`listStyleType`);return u.from(n)},y=(e,t)=>t!==null&&!e.dom.isEditable(t),b=(e,t)=>y(e,e.dom.getParent(t,`ol,ul,dl`))&&e.selection.isEditable(),x=(e,t)=>{let n=e.selection.getNode();return t({parents:e.dom.getParents(n),element:n}),e.on(`NodeChange`,t),()=>e.off(`NodeChange`,t)},S=e=>e.replace(/\-/g,` `).replace(/\b\w/g,e=>e.toUpperCase()),C=e=>s(e)||e===`default`?``:e,w=(e,t)=>n=>{let r=(e,r)=>{let i=e.selection.getStart(!0);n.setActive(_(e,r,t)),n.setEnabled(!b(e,i)&&e.selection.isEditable())};return x(e,t=>r(e,t.parents))},T=(e,n,r,i,a,o)=>{e.ui.registry.addSplitButton(n,{tooltip:r,icon:a===`OL`?`ordered-list`:`unordered-list`,presets:`listpreview`,columns:3,fetch:e=>{e(l.map(o,e=>{let t=a===`OL`?`num`:`bull`,n=e===`disc`||e===`decimal`?`default`:e,r=C(e),i=S(e);return{type:`choiceitem`,value:r,icon:`list-`+t+`-`+n,text:i}}))},onAction:()=>e.execCommand(i),onItemAction:(n,r)=>{t(e,a,r)},select:t=>v(e).map(e=>t===e).getOr(!1),onSetup:w(e,a)})},E=(e,n,r,i,a,o)=>{e.ui.registry.addToggleButton(n,{active:!1,tooltip:r,icon:a===`OL`?`ordered-list`:`unordered-list`,onSetup:w(e,a),onAction:()=>e.queryCommandState(i)||o===``?e.execCommand(i):t(e,a,o)})},D=(e,t,n,r,i,a)=>{a.length>1?T(e,t,n,r,i,a):E(e,t,n,r,i,C(a[0]))},O=e=>{D(e,`numlist`,`Numbered list`,`InsertOrderedList`,`OL`,a(e)),D(e,`bullist`,`Bullet list`,`InsertUnorderedList`,`UL`,o(e))};e.add(`advlist`,e=>{e.hasPlugin(`lists`)?(i(e),O(e),n(e)):console.error(`Please use the Lists plugin together with the Advanced List plugin.`)})})();var n={};export{t};