"use strict";var A=Object.defineProperty;var k=(s,r,t)=>r in s?A(s,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[r]=t;var p=(s,r,t)=>(k(s,typeof r!="symbol"?r+"":r,t),t);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("../../../../parchment@3.0.0/node_modules/parchment/dist/parchment.js"),g=require("../../../../quill-delta@5.1.0/node_modules/quill-delta/dist/Delta.js"),m=require("./break.js"),C=require("./inline.js"),E=require("./text.js"),d=1;class c extends l.BlockBlot{constructor(){super(...arguments);p(this,"cache",{})}delta(){return this.cache.delta==null&&(this.cache.delta=B(this)),this.cache.delta}deleteAt(t,e){super.deleteAt(t,e),this.cache={}}formatAt(t,e,n,i){e<=0||(this.scroll.query(n,l.Scope.BLOCK)?t+e===this.length()&&this.format(n,i):super.formatAt(t,Math.min(e,this.length()-t-1),n,i),this.cache={})}insertAt(t,e,n){if(n!=null){super.insertAt(t,e,n),this.cache={};return}if(e.length===0)return;const i=e.split(`
`),h=i.shift();h.length>0&&(t<this.length()-1||this.children.tail==null?super.insertAt(Math.min(t,this.length()-1),h):this.children.tail.insertAt(this.children.tail.length(),h),this.cache={});let a=this;i.reduce((u,o)=>(a=a.split(u,!0),a.insertAt(0,o),o.length),t+h.length)}insertBefore(t,e){const{head:n}=this.children;super.insertBefore(t,e),n instanceof m.default&&n.remove(),this.cache={}}length(){return this.cache.length==null&&(this.cache.length=super.length()+d),this.cache.length}moveChildren(t,e){super.moveChildren(t,e),this.cache={}}optimize(t){super.optimize(t),this.cache={}}path(t){return super.path(t,!0)}removeChild(t){super.removeChild(t),this.cache={}}split(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(e&&(t===0||t>=this.length()-d)){const i=this.clone();return t===0?(this.parent.insertBefore(i,this),this):(this.parent.insertBefore(i,this.next),i)}const n=super.split(t,e);return this.cache={},n}}c.blotName="block";c.tagName="P";c.defaultChild=m.default;c.allowedChildren=[m.default,C.default,l.EmbedBlot,E.default];class b extends l.EmbedBlot{attach(){super.attach(),this.attributes=new l.AttributorStore(this.domNode)}delta(){return new g.default().insert(this.value(),{...this.formats(),...this.attributes.values()})}format(r,t){const e=this.scroll.query(r,l.Scope.BLOCK_ATTRIBUTE);e!=null&&this.attributes.attribute(e,t)}formatAt(r,t,e,n){this.format(e,n)}insertAt(r,t,e){if(e!=null){super.insertAt(r,t,e);return}const n=t.split(`
`),i=n.pop(),h=n.map(u=>{const o=this.scroll.create(c.blotName);return o.insertAt(0,u),o}),a=this.split(r);h.forEach(u=>{this.parent.insertBefore(u,a)}),i&&this.parent.insertBefore(this.scroll.create("text",i),a)}}b.scope=l.Scope.BLOCK_BLOT;function B(s){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return s.descendants(l.LeafBlot).reduce((t,e)=>e.length()===0?t:t.insert(e.value(),f(e,{},r)),new g.default).insert(`
`,f(s))}function f(s){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;return s==null||("formats"in s&&typeof s.formats=="function"&&(r={...r,...s.formats()},t&&delete r["code-token"]),s.parent==null||s.parent.statics.blotName==="scroll"||s.parent.statics.scope!==s.statics.scope)?r:f(s.parent,r,t)}exports.BlockEmbed=b;exports.blockDelta=B;exports.bubbleFormats=f;exports.default=c;
