티스토리 수익 글 보기

티스토리 수익 글 보기

“use strict”;(self.webpackChunksubstack=self.webpackChunksubstack||[]).push([[“3897”],{43627:function(t,e,r){r.d(e,{JR:()=>b,be:()=>s,gB:()=>c,gl:()=>v,kL:()=>a});var n=r(17402),i=r(15871),o=r(74979);function s(t,e,r){let n=t.slice();return n.splice(r<0?n.length+r:r,0,n.splice(e,1)[0]),n}function l(t){return null!==t&&t>=0}let a=t=>{let{rects:e,activeIndex:r,overIndex:n,index:i}=t,o=s(e,n,r),l=e[i],a=o[i];return a&&l?{x:a.left-l.left,y:a.top-l.top,scaleX:a.width/l.width,scaleY:a.height/l.height}:null},p=”Sortable”,h=n.default.createContext({activeIndex:-1,containerId:p,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:a,disabled:{draggable:!1,droppable:!1}});function c(t){let{children:e,id:r,items:s,strategy:l=a,disabled:c=!1}=t,{active:u,dragOverlay:f,droppableRects:d,over:m,measureDroppableContainers:g}=(0,i.fF)(),y=(0,o.YG)(p,r),v=null!==f.rect,w=(0,n.useMemo)(()=>s.map(t=>”object”==typeof t&&”id”in t?t.id:t),[s]),k=null!=u,b=u?w.indexOf(u.id):-1,S=m?w.indexOf(m.id):-1,x=(0,n.useRef)(w),M=!function(t,e){if(t===e)return!0;if(t.length!==e.length)return!1;for(let r=0;r{M&&k&&g(w)},[M,w,k,g]),(0,n.useEffect)(()=>{x.current=w},[w]);let J=(0,n.useMemo)(()=>({activeIndex:b,containerId:y,disabled:C,disableTransforms:R,items:w,overIndex:S,useDragOverlay:v,sortedRects:w.reduce((t,e,r)=>{let n=d.get(e);return n&&(t[r]=n),t},Array(w.length)),strategy:l}),[b,y,C.draggable,C.droppable,R,w,S,d,v,l]);return n.default.createElement(h.Provider,{value:J},e)}let u=t=>{let{id:e,items:r,activeIndex:n,overIndex:i}=t;return s(r,n,i).indexOf(e)},f=t=>{let{containerId:e,isSorting:r,wasDragging:n,index:i,items:o,newIndex:s,previousItems:l,previousContainerId:a,transition:p}=t;return!!p&&!!n&&(l===o||i!==s)&&(!!r||s!==i&&e===a)},d={duration:200,easing:”ease”},m=”transform”,g=o.Ks.Transition.toString({property:m,duration:0,easing:”linear”}),y={roleDescription:”sortable”};function v(t){var e,r,s,a;let{animateLayoutChanges:p=f,attributes:c,disabled:v,data:w,getNewIndex:k=u,id:b,strategy:S,resizeObserverConfig:x,transition:M=d}=t,{items:R,containerId:C,activeIndex:J,disabled:I,disableTransforms:N,sortedRects:T,overIndex:F,useDragOverlay:E,strategy:O}=(0,n.useContext)(h),A=(e=v,r=I,”boolean”==typeof e?{draggable:e,droppable:!1}:{draggable:null!=(s=null==e?void 0:e.draggable)?s:r.draggable,droppable:null!=(a=null==e?void 0:e.droppable)?a:r.droppable}),z=R.indexOf(b),K=(0,n.useMemo)(()=>({sortable:{containerId:C,index:z,items:R},…w}),[C,w,z,R]),_=(0,n.useMemo)(()=>R.slice(R.indexOf(b)),[R,b]),{rect:j,node:L,isOver:D,setNodeRef:$}=(0,i.zM)({id:b,data:K,disabled:A.droppable,resizeObserverConfig:{updateMeasurementsFor:_,…x}}),{active:B,activatorEvent:W,activeNodeRect:Y,attributes:X,setNodeRef:q,listeners:G,isDragging:U,over:P,setActivatorNodeRef:V,transform:Z}=(0,i.PM)({id:b,data:K,attributes:{…y,…c},disabled:A.draggable}),H=(0,o.jn)($,q),Q=!!B,tt=Q&&!N&&l(J)&&l(F),te=!E&&U,tr=te&&tt?Z:null,tn=tt?null!=tr?tr:(null!=S?S:O)({rects:T,activeNodeRect:Y,activeIndex:J,overIndex:F,index:z}):null,ti=l(J)&&l(F)?k({id:b,items:R,activeIndex:J,overIndex:F}):z,to=null==B?void 0:B.id,ts=(0,n.useRef)({activeId:to,items:R,newIndex:ti,containerId:C}),tl=R!==ts.current.items,ta=p({active:B,containerId:C,isDragging:U,isSorting:Q,id:b,index:z,items:R,newIndex:ts.current.newIndex,previousItems:ts.current.items,previousContainerId:ts.current.containerId,transition:M,wasDragging:null!=ts.current.activeId}),tp=function(t){let{disabled:e,index:r,node:s,rect:l}=t,[a,p]=(0,n.useState)(null),h=(0,n.useRef)(r);return(0,o.Es)(()=>{if(!e&&r!==h.current&&s.current){let t=l.current;if(t){let e=(0,i.Sj)(s.current,{ignoreTransform:!0}),r={x:t.left-e.left,y:t.top-e.top,scaleX:t.width/e.width,scaleY:t.height/e.height};(r.x||r.y)&&p(r)}}r!==h.current&&(h.current=r)},[e,r,s,l]),(0,n.useEffect)(()=>{a&&p(null)},[a]),a}({disabled:!ta,index:z,node:L,rect:j});return(0,n.useEffect)(()=>{Q&&ts.current.newIndex!==ti&&(ts.current.newIndex=ti),C!==ts.current.containerId&&(ts.current.containerId=C),R!==ts.current.items&&(ts.current.items=R)},[Q,ti,C,R]),(0,n.useEffect)(()=>{if(to===ts.current.activeId)return;if(to&&!ts.current.activeId){ts.current.activeId=to;return}let t=setTimeout(()=>{ts.current.activeId=to},50);return()=>clearTimeout(t)},[to]),{active:B,activeIndex:J,attributes:X,data:K,rect:j,index:z,newIndex:ti,items:R,isOver:D,isSorting:Q,isDragging:U,listeners:G,node:L,overIndex:F,over:P,setNodeRef:H,setActivatorNodeRef:V,setDroppableNodeRef:$,setDraggableNodeRef:q,transform:null!=tp?tp:tn,transition:tp||tl&&ts.current.newIndex===z?g:(!te||(0,o.kx)(W))&&M&&(Q||ta)?o.Ks.Transition.toString({…M,property:m}):void 0}}function w(t){if(!t)return!1;let e=t.data.current;return!!e&&”sortable”in e&&”object”==typeof e.sortable&&”containerId”in e.sortable&&”items”in e.sortable&&”index”in e.sortable}let k=[i.vL.Down,i.vL.Right,i.vL.Up,i.vL.Left],b=(t,e)=>{let{context:{active:r,collisionRect:n,droppableRects:s,droppableContainers:l,over:a,scrollableAncestors:p}}=e;if(k.includes(t.code)){if(t.preventDefault(),!r||!n)return;let e=[];l.getEnabled().forEach(r=>{if(!r||null!=r&&r.disabled)return;let o=s.get(r.id);if(o)switch(t.code){case i.vL.Down:n.topo.top&&e.push(r);break;case i.vL.Left:n.left>o.left&&e.push(r);break;case i.vL.Right:n.left1&&(f=u[1].id),null!=f){let t=l.get(r.id),e=l.get(f),a=e?s.get(e.id):null,u=null==e?void 0:e.node.current;if(u&&a&&t&&e){var h,c;let r=(0,i.sl)(u).some((t,e)=>p[e]!==t),s=S(t,e),l=(h=t,c=e,!!w(h)&&!!w(c)&&!!S(h,c)&&h.data.current.sortable.indexm,Es:()=>f,KG:()=>y,Ks:()=>J,Ll:()=>l,Re:()=>M,Sw:()=>o,TW:()=>u,WQ:()=>x,YG:()=>b,YN:()=>g,ZC:()=>w,_q:()=>d,ag:()=>N,e_:()=>C,jn:()=>i,kx:()=>R,l6:()=>s,lk:()=>v,sb:()=>h,wz:()=>p,xZ:()=>c,zk:()=>a});var n=r(17402);function i(){for(var t=arguments.length,e=Array(t),r=0;rt=>{e.forEach(e=>e(t))},e)}let o=”undefined”!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement;function s(t){let e=Object.prototype.toString.call(t);return”[object Window]”===e||”[object global]”===e}function l(t){return”nodeType”in t}function a(t){var e,r;return t?s(t)?t:l(t)&&null!=(e=null==(r=t.ownerDocument)?void 0:r.defaultView)?e:window:window}function p(t){let{Document:e}=a(t);return t instanceof e}function h(t){return!s(t)&&t instanceof a(t).HTMLElement}function c(t){return t instanceof a(t).SVGElement}function u(t){return t?s(t)?t.document:l(t)?p(t)?t:h(t)||c(t)?t.ownerDocument:document:document:document}let f=o?n.useLayoutEffect:n.useEffect;function d(t){let e=(0,n.useRef)(t);return f(()=>{e.current=t}),(0,n.useCallback)(function(){for(var t=arguments.length,r=Array(t),n=0;n{t.current=setInterval(e,r)},[]),(0,n.useCallback)(()=>{null!==t.current&&(clearInterval(t.current),t.current=null)},[])]}function g(t,e){void 0===e&&(e=[t]);let r=(0,n.useRef)(t);return f(()=>{r.current!==t&&(r.current=t)},e),r}function y(t,e){let r=(0,n.useRef)();return(0,n.useMemo)(()=>{let e=t(r.current);return r.current=e,e},[…e])}function v(t){let e=d(t),r=(0,n.useRef)(null),i=(0,n.useCallback)(t=>{t!==r.current&&(null==e||e(t,r.current)),r.current=t},[]);return[r,i]}function w(t){let e=(0,n.useRef)();return(0,n.useEffect)(()=>{e.current=t},[t]),e.current}let k={};function b(t,e){return(0,n.useMemo)(()=>{if(e)return e;let r=null==k[t]?0:k[t]+1;return k[t]=r,t+”-“+r},[t,e])}function S(t){return function(e){for(var r=arguments.length,n=Array(r>1?r-1:0),i=1;i{for(let[n,i]of Object.entries(r)){let r=e[n];null!=r&&(e[n]=r+t*i)}return e},{…e})}}let x=S(1),M=S(-1);function R(t){if(!t)return!1;let{KeyboardEvent:e}=a(t.target);return e&&t instanceof e}function C(t){if(function(t){if(!t)return!1;let{TouchEvent:e}=a(t.target);return e&&t instanceof e}(t)){if(t.touches&&t.touches.length){let{clientX:e,clientY:r}=t.touches[0];return{x:e,y:r}}else if(t.changedTouches&&t.changedTouches.length){let{clientX:e,clientY:r}=t.changedTouches[0];return{x:e,y:r}}}return”clientX”in t&&”clientY”in t?{x:t.clientX,y:t.clientY}:null}let J=Object.freeze({Translate:{toString(t){if(!t)return;let{x:e,y:r}=t;return”translate3d(“+(e?Math.round(e):0)+”px, “+(r?Math.round(r):0)+”px, 0)”}},Scale:{toString(t){if(!t)return;let{scaleX:e,scaleY:r}=t;return”scaleX(“+e+”) scaleY(“+r+”)”}},Transform:{toString(t){if(t)return[J.Translate.toString(t),J.Scale.toString(t)].join(” “)}},Transition:{toString(t){let{property:e,duration:r,easing:n}=t;return e+” “+r+”ms “+n}}}),I=”a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]”;function N(t){return t.matches(I)?t:t.querySelector(I)}},97070:function(t,e,r){r.d(e,{$L:()=>N,Ln:()=>m,N0:()=>J,Um:()=>I,Wg:()=>g,X9:()=>s,dL:()=>D,jP:()=>w,n9:()=>R,oM:()=>k,zy:()=>M});var n=r(579);class i{constructor(t,e,r){this.pos=t,this.delInfo=e,this.recover=r}get deleted(){return(8&this.delInfo)>0}get deletedBefore(){return(5&this.delInfo)>0}get deletedAfter(){return(6&this.delInfo)>0}get deletedAcross(){return(4&this.delInfo)>0}}class o{constructor(t,e=!1){if(this.ranges=t,this.inverted=e,!t.length&&o.empty)return o.empty}recover(t){let e=0,r=65535&t;if(!this.inverted)for(let t=0;tt)break;let p=this.ranges[l+o],h=this.ranges[l+s],c=a+p;if(t<=c){let o=p?t==a?-1:t==c?1:e:e,s=a+n+(o<0?0:h);if(r)return s;let u=t==(e<0?a:c)?null:l/3+(t-a)*65536,f=t==a?2:t==c?1:4;return(e<0?t!=a:t!=c)&&(f|=8),new i(s,f,u)}n+=h-p}return r?t+n:new i(t+n,0,null)}touches(t,e){let r=0,n=65535&e,i=this.inverted?2:1,o=this.inverted?1:2;for(let e=0;et)break;let l=this.ranges[e+i];if(t<=s+l&&e==3*n)return!0;r+=this.ranges[e+o]-l}return!1}forEach(t){let e=this.inverted?2:1,r=this.inverted?1:2;for(let n=0,i=0;n=0;e–){let n=t.getMirror(e);this.appendMap(t._maps[e].invert(),null!=n&&n>e?r-n-1:void 0)}}invert(){let t=new s;return t.appendMappingInverted(this),t}map(t,e=1){if(this.mirror)return this._map(t,e,!0);for(let r=this.from;rr&&et.isAtom&&e.type.allowsMarkType(this.mark.type)?t.mark(this.mark.addToSet(t.marks)):t,i),e.openStart,e.openEnd);return p.fromReplace(t,this.from,this.to,o)}invert(){return new u(this.from,this.to,this.mark)}map(t){let e=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return e.deleted&&r.deleted||e.pos>=r.pos?null:new c(e.pos,r.pos,this.mark)}merge(t){return t instanceof c&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new c(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:”addMark”,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,e){if(“number”!=typeof e.from||”number”!=typeof e.to)throw RangeError(“Invalid input for AddMarkStep.fromJSON”);return new c(e.from,e.to,t.markFromJSON(e.mark))}}a.jsonID(“addMark”,c);class u extends a{constructor(t,e,r){super(),this.from=t,this.to=e,this.mark=r}apply(t){let e=t.slice(this.from,this.to),r=new n.Ji(h(e.content,t=>t.mark(this.mark.removeFromSet(t.marks)),t),e.openStart,e.openEnd);return p.fromReplace(t,this.from,this.to,r)}invert(){return new c(this.from,this.to,this.mark)}map(t){let e=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return e.deleted&&r.deleted||e.pos>=r.pos?null:new u(e.pos,r.pos,this.mark)}merge(t){return t instanceof u&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new u(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:”removeMark”,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,e){if(“number”!=typeof e.from||”number”!=typeof e.to)throw RangeError(“Invalid input for RemoveMarkStep.fromJSON”);return new u(e.from,e.to,t.markFromJSON(e.mark))}}a.jsonID(“removeMark”,u);class f extends a{constructor(t,e){super(),this.pos=t,this.mark=e}apply(t){let e=t.nodeAt(this.pos);if(!e)return p.fail(“No node at mark step’s position”);let r=e.type.create(e.attrs,null,this.mark.addToSet(e.marks));return p.fromReplace(t,this.pos,this.pos+1,new n.Ji(n.FK.from(r),0,+!e.isLeaf))}invert(t){let e=t.nodeAt(this.pos);if(e){let t=this.mark.addToSet(e.marks);if(t.length==e.marks.length){for(let r=0;rr.pos?null:new g(e.pos,r.pos,n,i,this.slice,this.insert,this.structure)}toJSON(){let t={stepType:”replaceAround”,from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,e){if(“number”!=typeof e.from||”number”!=typeof e.to||”number”!=typeof e.gapFrom||”number”!=typeof e.gapTo||”number”!=typeof e.insert)throw RangeError(“Invalid input for ReplaceAroundStep.fromJSON”);return new g(e.from,e.to,e.gapFrom,e.gapTo,n.Ji.fromJSON(t,e.slice),e.insert,!!e.structure)}}function y(t,e,r){let n=t.resolve(e),i=r-e,o=n.depth;for(;i>0&&o>0&&n.indexAfter(o)==n.node(o).childCount;)o–,i–;if(i>0){let t=n.node(o).maybeChild(n.indexAfter(o));for(;i>0;){if(!t||t.isLeaf)return!0;t=t.firstChild,i–}}return!1}function v(t,e,r,i=r.contentMatch,o=!0){let s=t.doc.nodeAt(e),l=[],a=e+1;for(let e=0;e=0;e–)t.step(l[e])}function w(t){let e=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth;;–r){let n=t.$from.node(r),i=t.$from.index(r),o=t.$to.indexAfter(r);if(r{if(i.isText){let s,l=/\r?\n|\r/g;for(;s=l.exec(i.text);){let i=t.mapping.slice(n).map(r+1+o+s.index);t.replaceWith(i,i+1,e.type.schema.linebreakReplacement.create())}}})}function x(t,e,r,n){e.forEach((i,o)=>{if(i.type==i.type.schema.linebreakReplacement){let i=t.mapping.slice(n).map(r+1+o);t.replaceWith(i,i+1,e.type.schema.text(“\n”))}})}function M(t,e,r=1,n){let i=t.resolve(e),o=i.depth-r,s=n&&n[n.length-1]||i.parent;if(o<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!s.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let t=i.depth-1,e=r-2;t>o;t–,e–){let r=i.node(t),o=i.index(t);if(r.type.spec.isolating)return!1;let s=r.content.cutByIndex(o,r.childCount),l=n&&n[e+1];l&&(s=s.replaceChild(0,l.type.create(l.attrs)));let a=n&&n[e]||r;if(!r.canReplace(o+1,r.childCount)||!a.type.validContent(s))return!1}let l=i.indexAfter(o),a=n&&n[0];return i.node(o).canReplaceWith(l,l,a?a.type:i.node(o+1).type)}function R(t,e){let r=t.resolve(e),n=r.index();return C(r.nodeBefore,r.nodeAfter)&&r.parent.canReplace(n,n+1)}function C(t,e){return!!(t&&e&&!t.isLeaf&&function(t,e){e.content.size||t.type.compatibleContent(e.type);let r=t.contentMatchAt(t.childCount),{linebreakReplacement:n}=t.type.schema;for(let i=0;i0?(i=n.node(t+1),s++,o=n.node(t).maybeChild(s)):(i=n.node(t).maybeChild(s-1),o=n.node(t+1)),i&&!i.isTextblock&&C(i,o)&&n.node(t).canReplace(s,s+1))return e;if(0==t)break;e=r<0?n.before(t):n.after(t)}}function I(t,e,r){let n=t.resolve(e);if(!r.content.size)return e;let i=r.content;for(let t=0;t=0;e–){let r=e==n.depth?0:n.pos<=(n.start(e+1)+n.end(e+1))/2?-1:1,o=n.index(e)+ +(r>0),s=n.node(e),l=!1;if(1==t)l=s.canReplace(o,o,i);else{let t=s.contentMatchAt(o).findWrapping(i.firstChild.type);l=t&&s.canReplaceWith(o,o,t[0])}if(l)return 0==r?n.pos:r<0?n.before(e+1):n.after(e+1)}return null}function N(t,e,r=e,i=n.Ji.empty){if(e==r&&!i.size)return null;let o=t.resolve(e),s=t.resolve(r);return T(o,s,i)?new m(e,r,i):new F(o,s,i).fit()}function T(t,e,r){return!r.openStart&&!r.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),r.content)}a.jsonID("replaceAround",g);class F{constructor(t,e,r){this.$from=t,this.$to=e,this.unplaced=r,this.frontier=[],this.placed=n.FK.empty;for(let e=0;e<=t.depth;e++){let r=t.node(e);this.frontier.push({type:r.type,match:r.contentMatchAt(t.indexAfter(e))})}for(let e=t.depth;e>0;e–)this.placed=n.FK.from(t.node(e).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let t=this.findFittable();t?this.placeNodes(t):this.openMore()||this.dropNode()}let t=this.mustMoveInline(),e=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(t<0?this.$to:r.doc.resolve(t));if(!i)return null;let o=this.placed,s=r.depth,l=i.depth;for(;s&&l&&1==o.childCount;)o=o.firstChild.content,s--,l--;let a=new n.Ji(o,s,l);return t>-1?new g(r.pos,t,this.$to.pos,this.$to.end(),a,e):a.size||r.pos!=this.$to.pos?new m(r.pos,i.pos,a):null}findFittable(){let t=this.unplaced.openStart;for(let e=this.unplaced.content,r=0,n=this.unplaced.openEnd;r1&&(n=0),i.type.spec.isolating&&n<=r){t=r;break}e=i.content}for(let e=1;e<=2;e++)for(let r=1==e?t:this.unplaced.openStart;r>=0;r–){let t=null,i=(r?(t=A(this.unplaced.content,r-1).firstChild).content:this.unplaced.content).firstChild;for(let o=this.depth;o>=0;o–){let{type:s,match:l}=this.frontier[o],a,p=null;if(1==e&&(i?l.matchType(i.type)||(p=l.fillBefore(n.FK.from(i),!1)):t&&s.compatibleContent(t.type)))return{sliceDepth:r,frontierDepth:o,parent:t,inject:p};if(2==e&&i&&(a=l.findWrapping(i.type)))return{sliceDepth:r,frontierDepth:o,parent:t,wrap:a};if(t&&l.matchType(t.type))break}}}openMore(){let{content:t,openStart:e,openEnd:r}=this.unplaced,i=A(t,e);return!!i.childCount&&!i.firstChild.isLeaf&&(this.unplaced=new n.Ji(t,e+1,Math.max(r,i.size+e>=t.size-r?e+1:0)),!0)}dropNode(){let{content:t,openStart:e,openEnd:r}=this.unplaced,i=A(t,e);if(i.childCount<=1&&e>0){let o=t.size-e<=e+i.size;this.unplaced=new n.Ji(E(t,e-1,1),e-1,o?e-1:r)}else this.unplaced=new n.Ji(E(t,e,1),e,r)}placeNodes({sliceDepth:t,frontierDepth:e,parent:r,inject:i,wrap:o}){for(;this.depth>e;)this.closeFrontierNode();if(o)for(let t=0;t1||0==a||t.content.size)&&(c=e,h.push(function t(e,r,i){if(r<=0)return e;let o=e.content;return r>1&&(o=o.replaceChild(0,t(o.firstChild,r-1,1==o.childCount?i-1:0))),r>0&&(o=e.type.contentMatch.fillBefore(o).append(o),i<=0&&(o=o.append(e.type.contentMatch.matchFragment(o).fillBefore(n.FK.empty,!0)))),e.copy(o)}(t.mark(u.allowedMarks(t.marks)),1==p?a:0,p==l.childCount?f:-1)))}let d=p==l.childCount;d||(f=-1),this.placed=O(this.placed,e,n.FK.from(h)),this.frontier[e].match=c,d&&f<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let t=0,e=l;t1&&n==this.$to.end(–r);)++n;return n}findCloseLevel(t){t:for(let e=Math.min(this.depth,t.depth);e>=0;e–){let{match:r,type:n}=this.frontier[e],i=e=0;r–){let{match:e,type:n}=this.frontier[r],i=z(t,r,n,e,!0);if(!i||i.childCount)continue t}return{depth:e,fit:o,move:i?t.doc.resolve(t.after(e+1)):t}}}}close(t){let e=this.findCloseLevel(t);if(!e)return null;for(;this.depth>e.depth;)this.closeFrontierNode();e.fit.childCount&&(this.placed=O(this.placed,e.depth,e.fit)),t=e.move;for(let r=e.depth+1;r<=t.depth;r++){let e=t.node(r),n=e.type.contentMatch.fillBefore(e.content,!0,t.index(r));this.openFrontierNode(e.type,e.attrs,n)}return t}openFrontierNode(t,e=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(t),this.placed=O(this.placed,this.depth,n.FK.from(t.create(e,r))),this.frontier.push({type:t,match:t.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(n.FK.empty,!0);t.childCount&&(this.placed=O(this.placed,this.frontier.length,t))}}function E(t,e,r){return 0==e?t.cutByIndex(r,t.childCount):t.replaceChild(0,t.firstChild.copy(E(t.firstChild.content,e-1,r)))}function O(t,e,r){return 0==e?t.append(r):t.replaceChild(t.childCount-1,t.lastChild.copy(O(t.lastChild.content,e-1,r)))}function A(t,e){for(let r=0;r=0;i–){let n=t.start(i);if(ne.pos+(e.depth-i)||t.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(n==e.start(i)||i==t.depth&&i==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==n-1)&&r.push(i)}return r}class _ extends a{constructor(t,e,r){super(),this.pos=t,this.attr=e,this.value=r}apply(t){let e=t.nodeAt(this.pos);if(!e)return p.fail(“No node at attribute step’s position”);let r=Object.create(null);for(let t in e.attrs)r[t]=e.attrs[t];r[this.attr]=this.value;let i=e.type.create(r,null,e.marks);return p.fromReplace(t,this.pos,this.pos+1,new n.Ji(n.FK.from(i),0,+!e.isLeaf))}getMap(){return o.empty}invert(t){return new _(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new _(e.pos,this.attr,this.value)}toJSON(){return{stepType:”attr”,pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,e){if(“number”!=typeof e.pos||”string”!=typeof e.attr)throw RangeError(“Invalid input for AttrStep.fromJSON”);return new _(e.pos,e.attr,e.value)}}a.jsonID(“attr”,_);class j extends a{constructor(t,e){super(),this.attr=t,this.value=e}apply(t){let e=Object.create(null);for(let r in t.attrs)e[r]=t.attrs[r];e[this.attr]=this.value;let r=t.type.create(e,t.content,t.marks);return p.ok(r)}getMap(){return o.empty}invert(t){return new j(this.attr,t.attrs[this.attr])}map(t){return this}toJSON(){return{stepType:”docAttr”,attr:this.attr,value:this.value}}static fromJSON(t,e){if(“string”!=typeof e.attr)throw RangeError(“Invalid input for DocAttrStep.fromJSON”);return new j(e.attr,e.value)}}a.jsonID(“docAttr”,j);let L=class extends Error{};(L=function t(e){let r=Error.call(this,e);return r.__proto__=t.prototype,r}).prototype=Object.create(Error.prototype),L.prototype.constructor=L,L.prototype.name=”TransformError”;class D{constructor(t){this.doc=t,this.steps=[],this.docs=[],this.mapping=new s}get before(){return this.docs.length?this.docs[0]:this.doc}step(t){let e=this.maybeStep(t);if(e.failed)throw new L(e.failed);return this}maybeStep(t){let e=t.apply(this.doc);return e.failed||this.addStep(t,e.doc),e}get docChanged(){return this.steps.length>0}addStep(t,e){this.docs.push(this.doc),this.steps.push(t),this.mapping.appendMap(t.getMap()),this.doc=e}replace(t,e=t,r=n.Ji.empty){let i=N(this.doc,t,e,r);return i&&this.step(i),this}replaceWith(t,e,r){return this.replace(t,e,new n.Ji(n.FK.from(r),0,0))}delete(t,e){return this.replace(t,e,n.Ji.empty)}insert(t,e){return this.replaceWith(t,t,e)}replaceRange(t,e,r){return!function(t,e,r,i){if(!i.size)return t.deleteRange(e,r);let o=t.doc.resolve(e),s=t.doc.resolve(r);if(T(o,s,i))return t.step(new m(e,r,i));let l=K(o,t.doc.resolve(r));0==l[l.length-1]&&l.pop();let a=-(o.depth+1);l.unshift(a);for(let t=o.depth,e=o.pos-1;t>0;t–,e–){let r=o.node(t).type.spec;if(r.defining||r.definingAsContext||r.isolating)break;l.indexOf(t)>-1?a=t:o.before(t)==e&&l.splice(1,0,-t)}let p=l.indexOf(a),h=[],c=i.openStart;for(let t=i.content,e=0;;e++){let r=t.firstChild;if(h.push(r),e==i.openStart)break;t=r.content}for(let t=c-1;t>=0;t–){var u;let e=h[t],r=(u=e.type).spec.defining||u.spec.definingForContent;if(r&&!e.sameMarkup(o.node(Math.abs(a)-1)))c=t;else if(r||!e.type.isTextblock)break}for(let e=i.openStart;e>=0;e–){let a=(e+c+1)%(i.openStart+1),u=h[a];if(u)for(let e=0;eo){let t=s.contentMatchAt(0),r=t.fillBefore(e).append(e);e=r.append(t.matchFragment(r).fillBefore(n.FK.empty,!0))}return e}(i.content,0,i.openStart,a),a,i.openEnd))}}let f=t.steps.length;for(let n=l.length-1;n>=0&&(t.replace(e,r,i),!(t.steps.length>f));n–){let t=l[n];t<0||(e=o.before(t),r=s.after(t))}}(this,t,e,r),this}replaceRangeWith(t,e,r){var i=t,o=e;if(!r.isInline&&i==o&&this.doc.resolve(i).parent.content.size){let t=function(t,e,r){let n=t.resolve(e);if(n.parent.canReplaceWith(n.index(),n.index(),r))return e;if(0==n.parentOffset)for(let t=n.depth-1;t>=0;t–){let e=n.index(t);if(n.node(t).canReplaceWith(e,e,r))return n.before(t+1);if(e>0)return null}if(n.parentOffset==n.parent.content.size)for(let t=n.depth-1;t>=0;t–){let e=n.indexAfter(t);if(n.node(t).canReplaceWith(e,e,r))return n.after(t+1);if(e0&&(s||n.node(r-1).canReplace(n.index(r-1),i.indexAfter(r-1))))return t.delete(n.before(r),i.after(r))}for(let o=1;o<=n.depth&&o<=i.depth;o++)if(e-n.start(o)==n.depth-o&&r>n.end(o)&&i.end(o)-r!=i.depth-o&&n.start(o-1)==i.start(o-1)&&n.node(o-1).canReplace(n.index(o-1),i.index(o-1)))return t.delete(n.before(o),r);t.delete(e,r)}(this,t,e),this}lift(t,e){return!function(t,e,r){let{$from:i,$to:o,depth:s}=e,l=i.before(s+1),a=o.after(s+1),p=l,h=a,c=n.FK.empty,u=0;for(let t=s,e=!1;t>r;t–)e||i.index(t)>0?(e=!0,c=n.FK.from(i.node(t).copy(c)),u++):p–;let f=n.FK.empty,d=0;for(let t=s,e=!1;t>r;t–)e||o.after(t+1)=0;t–){if(i.size){let e=r[t].type.contentMatch.matchFragment(i);if(!e||!e.validEnd)throw RangeError(“Wrapper type given to Transform.wrap does not form valid content of its parent wrapper”)}i=n.FK.from(r[t].type.create(r[t].attrs,i))}let o=e.start,s=e.end;t.step(new g(o,s,o,s,new n.Ji(i,0,0),r.length,!0))}(this,t,e),this}setBlockType(t,e=t,r,i=null){var o=this;if(!r.isTextblock)throw RangeError(“Type given to setBlockType should be a textblock”);let s=o.steps.length;return o.doc.nodesBetween(t,e,(t,e)=>{var l,a,p;let h,c,u=”function”==typeof i?i(t):i;if(t.isTextblock&&!t.hasMarkup(r,u)&&(l=o.doc,a=o.mapping.slice(s).map(e),p=r,c=(h=l.resolve(a)).index(),h.parent.canReplaceWith(c,c+1,p))){let i=null;if(r.schema.linebreakReplacement){let t=”pre”==r.whitespace,e=!!r.contentMatch.matchType(r.schema.linebreakReplacement);t&&!e?i=!1:!t&&e&&(i=!0)}!1===i&&x(o,t,e,s),v(o,o.mapping.slice(s).map(e,1),r,void 0,null===i);let l=o.mapping.slice(s),a=l.map(e,1),p=l.map(e+t.nodeSize,1);return o.step(new g(a,p,a+1,p-1,new n.Ji(n.FK.from(r.create(u,null,t.marks)),0,0),1,!0)),!0===i&&S(o,t,e,s),!1}}),this}setNodeMarkup(t,e,r=null,i){return!function(t,e,r,i,o){let s=t.doc.nodeAt(e);if(!s)throw RangeError(“No node at given position”);r||(r=s.type);let l=r.create(i,null,o||s.marks);if(s.isLeaf)return t.replaceWith(e,e+s.nodeSize,l);if(!r.validContent(s.content))throw RangeError(“Invalid content for node type “+r.name);t.step(new g(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new n.Ji(n.FK.from(l),0,0),1,!0))}(this,t,e,r,i),this}setNodeAttribute(t,e,r){return this.step(new _(t,e,r)),this}setDocAttribute(t,e){return this.step(new j(t,e)),this}addNodeMark(t,e){return this.step(new f(t,e)),this}removeNodeMark(t,e){let r=this.doc.nodeAt(t);if(!r)throw RangeError(“No node at position “+t);if(e instanceof n.CU)e.isInSet(r.marks)&&this.step(new d(t,e));else{let n=r.marks,i,o=[];for(;i=e.isInSet(n);)o.push(new d(t,i)),n=i.removeFromSet(n);for(let t=o.length-1;t>=0;t–)this.step(o[t])}return this}split(t,e=1,r){return!function(t,e,r=1,i){let o=t.doc.resolve(e),s=n.FK.empty,l=n.FK.empty;for(let t=o.depth,e=o.depth-r,a=r-1;t>e;t–,a–){s=n.FK.from(o.node(t).copy(s));let e=i&&i[a];l=n.FK.from(e?e.type.create(e.attrs,l):o.node(t).copy(l))}t.step(new m(e,e,new n.Ji(s.append(l),r,r),!0))}(this,t,e,r),this}addMark(t,e,r){var n;let i,o,s,l;return n=this,s=[],l=[],n.doc.nodesBetween(t,e,(n,a,p)=>{if(!n.isInline)return;let h=n.marks;if(!r.isInSet(h)&&p.type.allowsMarkType(r.type)){let p=Math.max(a,t),f=Math.min(a+n.nodeSize,e),d=r.addToSet(h);for(let t=0;tn.step(t)),l.forEach(t=>n.step(t)),this}removeMark(t,e,r){var i;let o,s;return i=this,o=[],s=0,i.doc.nodesBetween(t,e,(i,l)=>{if(!i.isInline)return;s++;let a=null;if(r instanceof n.sX){let t=i.marks,e;for(;e=r.isInSet(t);)(a||(a=[])).push(e),t=e.removeFromSet(t)}else r?r.isInSet(i.marks)&&(a=[r]):a=i.marks;if(a&&a.length){let r=Math.min(l+i.nodeSize,e);for(let e=0;ei.step(new u(t.from,t.to,t.style))),this}clearIncompatible(t,e,r){return v(this,t,e,r),this}}}}]);