/*!
Copyright (c) 2026 Lenovo SSG BASD. All rights reserved.
@license Proprietary

This software is the confidential and proprietary property of Lenovo SSG BASD.
You shall not disclose such Confidential Information and shall use it only in
accordance with the terms of the license agreement.

--- Build Info ---
Version: 1.1.1
Build Time: 2026/2/26 17:21:00
Build Commit: 81e556ed827e2f043668506dae6fae8dbb9ef395
*/
import{Node as t,parseIndentedBlocks as e,mergeAttributes as s,wrappingInputRule as n,getRenderedAttributes as r,renderNestedMarkdownContent as i,Extension as o,isNodeActive as a,isAtStartOfNode as d,isAtEndOfNode as p,getNodeType as c,getNodeAtPosition as l}from"../../core/dist/index.js";var h=Object.defineProperty,u="textStyle",m=/^\s*([-+*])\s$/,k=t.create({name:"bulletList",addOptions:()=>({itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}),group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML:()=>[{tag:"ul"}],renderHTML({HTMLAttributes:t}){return["ul",s(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>"list"!==t.type||t.ordered?[]:{type:"bulletList",content:t.items?e.parseChildren(t.items):[]},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,"\n"):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes("listItem",this.editor.getAttributes(u)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=n({find:m,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=n({find:m,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(u),editor:this.editor})),[t]}}),b=t.create({name:"listItem",addOptions:()=>({HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}),content:"paragraph block*",defining:!0,parseHTML:()=>[{tag:"li"}],renderHTML({HTMLAttributes:t}){return["li",s(this.options.HTMLAttributes,t),0]},markdownTokenName:"list_item",parseMarkdown:(t,e)=>{if("list_item"!==t.type)return[];let s=[];if(t.tokens&&t.tokens.length>0){if(t.tokens.some(t=>"paragraph"===t.type))s=e.parseChildren(t.tokens);else{const n=t.tokens[0];if(n&&"text"===n.type&&n.tokens&&n.tokens.length>0){if(s=[{type:"paragraph",content:e.parseInline(n.tokens)}],t.tokens.length>1){const n=t.tokens.slice(1),r=e.parseChildren(n);s.push(...r)}}else s=e.parseChildren(t.tokens)}}return 0===s.length&&(s=[{type:"paragraph",content:[]}]),{type:"listItem",content:s}},renderMarkdown:(t,e,s)=>i(t,e,t=>{var e,s;if("bulletList"===t.parentType)return"- ";if("orderedList"===t.parentType){return`${((null==(s=null==(e=t.meta)?void 0:e.parentAttrs)?void 0:s.start)||1)+t.index}. `}return"- "},s),addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),f={};((t,e)=>{for(var s in e)h(t,s,{get:e[s],enumerable:!0})})(f,{findListItemPos:()=>y,getNextListDepth:()=>L,handleBackspace:()=>v,handleDelete:()=>I,hasListBefore:()=>g,hasListItemAfter:()=>N,hasListItemBefore:()=>T,listItemHasSubList:()=>M,nextListIsDeeper:()=>A,nextListIsHigher:()=>w});var y=(t,e)=>{const{$from:s}=e.selection,n=c(t,e.schema);let r=null,i=s.depth,o=s.pos,a=null;for(;i>0&&null===a;)r=s.node(i),r.type===n?a=i:(i-=1,o-=1);return null===a?null:{$pos:e.doc.resolve(o),depth:a}},L=(t,e)=>{const s=y(t,e);if(!s)return!1;const[,n]=l(e,t,s.$pos.pos+4);return n},g=(t,e,s)=>{const{$anchor:n}=t.selection,r=Math.max(0,n.pos-2),i=t.doc.resolve(r).node();return!(!i||!s.includes(i.type.name))},T=(t,e)=>{var s;const{$anchor:n}=e.selection,r=e.doc.resolve(n.pos-2);return 0!==r.index()&&(null==(s=r.nodeBefore)?void 0:s.type.name)===t},M=(t,e,s)=>{if(!s)return!1;const n=c(t,e.schema);let r=!1;return s.descendants(t=>{t.type===n&&(r=!0)}),r},v=(t,e,s)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!a(t.state,e)&&g(t.state,e,s)){const{$anchor:s}=t.state.selection,n=t.state.doc.resolve(s.before()-1),r=[];n.node().descendants((t,s)=>{t.type.name===e&&r.push({node:t,pos:s})});const i=r.at(-1);if(!i)return!1;const o=t.state.doc.resolve(n.start()+i.pos+1);return t.chain().cut({from:s.start()-1,to:s.end()+1},o.end()).joinForward().run()}if(!a(t.state,e))return!1;if(!d(t.state))return!1;const n=y(e,t.state);if(!n)return!1;const r=t.state.doc.resolve(n.$pos.pos-2).node(n.depth),i=M(e,t.state,r);return T(e,t.state)&&!i?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},A=(t,e)=>{const s=L(t,e),n=y(t,e);return!(!n||!s)&&s>n.depth},w=(t,e)=>{const s=L(t,e),n=y(t,e);return!(!n||!s)&&s<n.depth},I=(t,e)=>{if(!a(t.state,e))return!1;if(!p(t.state,e))return!1;const{selection:s}=t.state,{$from:n,$to:r}=s;return!(!s.empty&&n.sameParent(r))&&(A(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():w(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward())},N=(t,e)=>{var s;const{$anchor:n}=e.selection,r=e.doc.resolve(n.pos-n.parentOffset-2);return r.index()!==r.parent.childCount-1&&(null==(s=r.nodeAfter)?void 0:s.type.name)===t},x=o.create({name:"listKeymap",addOptions:()=>({listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}),addKeyboardShortcuts(){return{Delete:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:s})=>{void 0!==t.state.schema.nodes[s]&&I(t,s)&&(e=!0)}),e},"Mod-Delete":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:s})=>{void 0!==t.state.schema.nodes[s]&&I(t,s)&&(e=!0)}),e},Backspace:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:s,wrapperNames:n})=>{void 0!==t.state.schema.nodes[s]&&v(t,s,n)&&(e=!0)}),e},"Mod-Backspace":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:s,wrapperNames:n})=>{void 0!==t.state.schema.nodes[s]&&v(t,s,n)&&(e=!0)}),e}}}}),C=/^(\s*)(\d+)\.\s+(.*)$/,H=/^\s/;function $(t,e,s){var n;const r=[];let i=0;for(;i<t.length;){const o=t[i];if(o.indent===e){const a=o.content.split("\n"),d=(null==(n=a[0])?void 0:n.trim())||"",p=[];d&&p.push({type:"paragraph",raw:d,tokens:s.inlineTokens(d)});const c=a.slice(1).join("\n").trim();if(c){const t=s.blockTokens(c);p.push(...t)}let l=i+1;const h=[];for(;l<t.length&&t[l].indent>e;)h.push(t[l]),l+=1;if(h.length>0){const t=Math.min(...h.map(t=>t.indent)),e=$(h,t,s);p.push({type:"list",ordered:!0,start:h[0].number,items:e,raw:h.map(t=>t.raw).join("\n")})}r.push({type:"list_item",raw:o.raw,tokens:p}),i=l}else i+=1}return r}var E="textStyle",O=/^(\d+)\.\s$/,j=t.create({name:"orderedList",addOptions:()=>({itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}),group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes:()=>({start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>t.getAttribute("type")}}),parseHTML:()=>[{tag:"ol"}],renderHTML({HTMLAttributes:t}){const{start:e,...n}=t;return 1===e?["ol",s(this.options.HTMLAttributes,n),0]:["ol",s(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>{if("list"!==t.type||!t.ordered)return[];const s=t.start||1,n=t.items?function(t,e){return t.map(t=>{if("list_item"!==t.type)return e.parseChildren([t])[0];const s=[];return t.tokens&&t.tokens.length>0&&t.tokens.forEach(t=>{if("paragraph"===t.type||"list"===t.type||"blockquote"===t.type||"code"===t.type)s.push(...e.parseChildren([t]));else if("text"===t.type&&t.tokens){const n=e.parseChildren([t]);s.push({type:"paragraph",content:n})}else{const n=e.parseChildren([t]);n.length>0&&s.push(...n)}}),{type:"listItem",content:s}})}(t.items,e):[];return 1!==s?{type:"orderedList",attrs:{start:s},content:n}:{type:"orderedList",content:n}},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,"\n"):"",markdownTokenizer:{name:"orderedList",level:"block",start:t=>{const e=t.match(/^(\s*)(\d+)\.\s+/),s=null==e?void 0:e.index;return void 0!==s?s:-1},tokenize:(t,e,s)=>{var n;const r=t.split("\n"),[i,o]=function(t){const e=[];let s=0,n=0;for(;s<t.length;){const r=t[s],i=r.match(C);if(!i)break;const[,o,a,d]=i,p=o.length;let c=d,l=s+1;const h=[r];for(;l<t.length;){const e=t[l];if(e.match(C))break;if(""===e.trim())h.push(e),c+="\n",l+=1;else{if(!e.match(H))break;h.push(e),c+=`\n${e.slice(p+2)}`,l+=1}}e.push({indent:p,number:parseInt(a,10),content:c.trim(),raw:h.join("\n")}),n=l,s=l}return[e,n]}(r);if(0===i.length)return;const a=$(i,0,s);if(0===a.length)return;return{type:"list",ordered:!0,start:(null==(n=i[0])?void 0:n.number)||1,items:a,raw:r.slice(0,o).join("\n")}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes("listItem",this.editor.getAttributes(E)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=n({find:O,type:this.type,getAttributes:t=>({start:+t[1]}),joinPredicate:(t,e)=>e.childCount+e.attrs.start===+t[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=n({find:O,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:t=>({start:+t[1],...this.editor.getAttributes(E)}),joinPredicate:(t,e)=>e.childCount+e.attrs.start===+t[1],editor:this.editor})),[t]}}),S=/^\s*(\[([( |x])?\])\s$/,B=t.create({name:"taskItem",addOptions:()=>({nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}),content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes:()=>({checked:{default:!1,keepOnSplit:!1,parseHTML:t=>{const e=t.getAttribute("data-checked");return""===e||"true"===e},renderHTML:t=>({"data-checked":t.checked})}}),parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:t,HTMLAttributes:e}){return["li",s(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(t,e)=>{const s=[];if(t.tokens&&t.tokens.length>0?s.push(e.createNode("paragraph",{},e.parseInline(t.tokens))):t.text?s.push(e.createNode("paragraph",{},[e.createNode("text",{text:t.text})])):s.push(e.createNode("paragraph",{},[])),t.nestedTokens&&t.nestedTokens.length>0){const n=e.parseChildren(t.nestedTokens);s.push(...n)}return e.createNode("taskItem",{checked:t.checked||!1},s)},renderMarkdown:(t,e)=>{var s;const n=(null==(s=t.attrs)?void 0:s.checked)?"x":" ";return i(t,e,`- [${n}] `)},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:s,editor:n})=>{const i=document.createElement("li"),o=document.createElement("label"),a=document.createElement("span"),d=document.createElement("input"),p=document.createElement("div"),c=t=>{var e,s;d.ariaLabel=(null==(s=null==(e=this.options.a11y)?void 0:e.checkboxLabel)?void 0:s.call(e,t,d.checked))||`Task item checkbox for ${t.textContent||"empty task item"}`};c(t),o.contentEditable="false",d.type="checkbox",d.addEventListener("mousedown",t=>t.preventDefault()),d.addEventListener("change",e=>{if(!n.isEditable&&!this.options.onReadOnlyChecked)return void(d.checked=!d.checked);const{checked:r}=e.target;n.isEditable&&"function"==typeof s&&n.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:t})=>{const e=s();if("number"!=typeof e)return!1;const n=t.doc.nodeAt(e);return t.setNodeMarkup(e,void 0,{...null==n?void 0:n.attrs,checked:r}),!0}).run(),!n.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,r)||(d.checked=!d.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([t,e])=>{i.setAttribute(t,e)}),i.dataset.checked=t.attrs.checked,d.checked=t.attrs.checked,o.append(d,a),i.append(o,p),Object.entries(e).forEach(([t,e])=>{i.setAttribute(t,e)});let l=new Set(Object.keys(e));return{dom:i,contentDOM:p,update:t=>{if(t.type!==this.type)return!1;i.dataset.checked=t.attrs.checked,d.checked=t.attrs.checked,c(t);const e=n.extensionManager.attributes,s=r(t,e),o=new Set(Object.keys(s)),a=this.options.HTMLAttributes;return l.forEach(t=>{o.has(t)||(t in a?i.setAttribute(t,a[t]):i.removeAttribute(t))}),Object.entries(s).forEach(([t,e])=>{null==e?t in a?i.setAttribute(t,a[t]):i.removeAttribute(t):i.setAttribute(t,e)}),l=o,!0}}}},addInputRules(){return[n({find:S,type:this.type,getAttributes:t=>({checked:"x"===t[t.length-1]})})]}}),K=t.create({name:"taskList",addOptions:()=>({itemTypeName:"taskItem",HTMLAttributes:{}}),group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:t}){return["ul",s(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},parseMarkdown:(t,e)=>e.createNode("taskList",{},e.parseChildren(t.items||[])),renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,"\n"):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;const s=null==(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))?void 0:e.index;return void 0!==s?s:-1},tokenize(t,s,n){const r=t=>{const s=e(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:t=>({indentLevel:t[1].length,mainContent:t[4],checked:"x"===t[3].toLowerCase()}),createToken:(t,e)=>({type:"taskItem",raw:"",mainContent:t.mainContent,indentLevel:t.indentLevel,checked:t.checked,text:t.mainContent,tokens:n.inlineTokens(t.mainContent),nestedTokens:e}),customNestedParser:r},n);return s?[{type:"taskList",raw:s.raw,items:s.items}]:n.blockTokens(t)},i=e(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:t=>({indentLevel:t[1].length,mainContent:t[4],checked:"x"===t[3].toLowerCase()}),createToken:(t,e)=>({type:"taskItem",raw:"",mainContent:t.mainContent,indentLevel:t.indentLevel,checked:t.checked,text:t.mainContent,tokens:n.inlineTokens(t.mainContent),nestedTokens:e}),customNestedParser:r},n);if(i)return{type:"taskList",raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});o.create({name:"listKit",addExtensions(){const t=[];return!1!==this.options.bulletList&&t.push(k.configure(this.options.bulletList)),!1!==this.options.listItem&&t.push(b.configure(this.options.listItem)),!1!==this.options.listKeymap&&t.push(x.configure(this.options.listKeymap)),!1!==this.options.orderedList&&t.push(j.configure(this.options.orderedList)),!1!==this.options.taskItem&&t.push(B.configure(this.options.taskItem)),!1!==this.options.taskList&&t.push(K.configure(this.options.taskList)),t}});export{k as BulletList,b as ListItem,x as ListKeymap,j as OrderedList,B as TaskItem,K as TaskList,m as bulletListInputRegex,S as inputRegex,f as listHelpers,O as orderedListInputRegex};