ariadne_view_components 0.0.46-x86_64-linux → 0.0.48-x86_64-linux

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +31 -25
  3. data/app/assets/javascripts/ariadne_view_components.js +2 -2
  4. data/app/assets/javascripts/ariadne_view_components.js.map +1 -1
  5. data/app/assets/javascripts/components/ariadne/accumulator_controller/accumulator_controller.d.ts +22 -0
  6. data/app/assets/javascripts/components/ariadne/dropdown/menu_component.d.ts +1 -0
  7. data/app/assets/javascripts/components/ariadne/options_controller/options_controller.d.ts +21 -0
  8. data/app/assets/javascripts/components/ariadne/toggleable_controller/toggleable_controller.d.ts +34 -0
  9. data/app/assets/stylesheets/ariadne_view_components.css +3 -3
  10. data/app/components/ariadne/accumulator_controller/accumulator_controller.d.ts +22 -0
  11. data/app/components/ariadne/accumulator_controller/accumulator_controller.js +39 -0
  12. data/app/components/ariadne/accumulator_controller/accumulator_controller.ts +48 -0
  13. data/app/components/ariadne/action_card_component.html.erb +11 -0
  14. data/app/components/ariadne/action_card_component.rb +45 -0
  15. data/app/components/ariadne/ariadne.js +6 -0
  16. data/app/components/ariadne/ariadne.ts +6 -0
  17. data/app/components/ariadne/bottom_tab_component.html.erb +4 -0
  18. data/app/components/ariadne/bottom_tab_component.rb +44 -0
  19. data/app/components/ariadne/bottom_tab_nav_component.html.erb +5 -0
  20. data/app/components/ariadne/bottom_tab_nav_component.rb +33 -0
  21. data/app/components/ariadne/breadcrumbs_component.html.erb +13 -0
  22. data/app/components/ariadne/breadcrumbs_component.rb +31 -0
  23. data/app/components/ariadne/checkbox_component.html.erb +5 -0
  24. data/app/components/ariadne/checkbox_component.rb +43 -0
  25. data/app/components/ariadne/close_button_component.html.erb +4 -0
  26. data/app/components/ariadne/close_button_component.rb +32 -0
  27. data/app/components/ariadne/dropdown/menu_component.d.ts +1 -0
  28. data/app/components/ariadne/dropdown/menu_component.js +1 -0
  29. data/app/components/ariadne/list_component/list_component.html.erb +0 -3
  30. data/app/components/ariadne/options_controller/options_controller.d.ts +21 -0
  31. data/app/components/ariadne/options_controller/options_controller.js +50 -0
  32. data/app/components/ariadne/options_controller/options_controller.ts +57 -0
  33. data/app/components/ariadne/popover_component.html.erb +11 -0
  34. data/app/components/ariadne/popover_component.rb +81 -0
  35. data/app/components/ariadne/progress_bar_component.html.erb +5 -0
  36. data/app/components/ariadne/progress_bar_component.rb +63 -0
  37. data/app/components/ariadne/relative_time_component.html.erb +3 -0
  38. data/app/components/ariadne/relative_time_component.rb +61 -0
  39. data/app/components/ariadne/show_more_button_component.html.erb +11 -0
  40. data/app/components/ariadne/show_more_button_component.rb +47 -0
  41. data/app/components/ariadne/spinner_component.html.erb +16 -0
  42. data/app/components/ariadne/spinner_component.rb +45 -0
  43. data/app/components/ariadne/subheader_component.html.erb +11 -0
  44. data/app/components/ariadne/subheader_component.rb +65 -0
  45. data/app/components/ariadne/toggle_component/toggle_component.html.erb +15 -0
  46. data/app/components/ariadne/toggle_component.rb +95 -0
  47. data/app/components/ariadne/toggleable_controller/toggleable_controller.d.ts +34 -0
  48. data/app/components/ariadne/toggleable_controller/toggleable_controller.js +74 -0
  49. data/app/components/ariadne/toggleable_controller/toggleable_controller.ts +87 -0
  50. data/lib/ariadne/view_components/version.rb +1 -1
  51. data/static/arguments.yml +50 -0
  52. data/static/audited_at.json +14 -0
  53. data/static/classes.yml +209 -173
  54. data/static/constants.json +282 -0
  55. data/static/statuses.json +14 -0
  56. data/tailwind.config.js +7 -7
  57. metadata +53 -12
  58. /data/app/assets/javascripts/{ariadne-form.d.ts → components/ariadne/ariadne-form.d.ts} +0 -0
  59. /data/app/assets/javascripts/{ariadne.d.ts → components/ariadne/ariadne.d.ts} +0 -0
  60. /data/app/assets/javascripts/{clipboard_copy_component → components/ariadne/clipboard_copy_component}/clipboard-copy-component.d.ts +0 -0
  61. /data/app/assets/javascripts/{rich_text_area_component → components/ariadne/rich_text_area_component}/rich-text-area-component.d.ts +0 -0
  62. /data/app/assets/javascripts/{slideover_component → components/ariadne/slideover_component}/slideover-component.d.ts +0 -0
  63. /data/app/assets/javascripts/{tab_container_component → components/ariadne/tab_container_component}/tab-container-component.d.ts +0 -0
  64. /data/app/assets/javascripts/{tab_nav_component → components/ariadne/tab_nav_component}/tab-nav-component.d.ts +0 -0
  65. /data/app/assets/javascripts/{time_ago_component → components/ariadne/time_ago_component}/time-ago-component.d.ts +0 -0
  66. /data/app/assets/javascripts/{tooltip_component → components/ariadne/tooltip_component}/tooltip-component.d.ts +0 -0
@@ -1,8 +1,8 @@
1
- class e{constructor(e,t,n){this.eventTarget=e,this.eventName=t,this.eventOptions=n,this.unorderedBindings=new Set}connect(){this.eventTarget.addEventListener(this.eventName,this,this.eventOptions)}disconnect(){this.eventTarget.removeEventListener(this.eventName,this,this.eventOptions)}bindingConnected(e){this.unorderedBindings.add(e)}bindingDisconnected(e){this.unorderedBindings.delete(e)}handleEvent(e){const t=function(e){if("immediatePropagationStopped"in e)return e;{const{stopImmediatePropagation:t}=e;return Object.assign(e,{immediatePropagationStopped:!1,stopImmediatePropagation(){this.immediatePropagationStopped=!0,t.call(this)}})}}(e);for(const e of this.bindings){if(t.immediatePropagationStopped)break;e.handleEvent(t)}}hasBindings(){return this.unorderedBindings.size>0}get bindings(){return Array.from(this.unorderedBindings).sort(((e,t)=>{const n=e.index,r=t.index;return n<r?-1:n>r?1:0}))}}class t{constructor(e){this.application=e,this.eventListenerMaps=new Map,this.started=!1}start(){this.started||(this.started=!0,this.eventListeners.forEach((e=>e.connect())))}stop(){this.started&&(this.started=!1,this.eventListeners.forEach((e=>e.disconnect())))}get eventListeners(){return Array.from(this.eventListenerMaps.values()).reduce(((e,t)=>e.concat(Array.from(t.values()))),[])}bindingConnected(e){this.fetchEventListenerForBinding(e).bindingConnected(e)}bindingDisconnected(e,t=!1){this.fetchEventListenerForBinding(e).bindingDisconnected(e),t&&this.clearEventListenersForBinding(e)}handleError(e,t,n={}){this.application.handleError(e,`Error ${t}`,n)}clearEventListenersForBinding(e){const t=this.fetchEventListenerForBinding(e);t.hasBindings()||(t.disconnect(),this.removeMappedEventListenerFor(e))}removeMappedEventListenerFor(e){const{eventTarget:t,eventName:n,eventOptions:r}=e,i=this.fetchEventListenerMapForEventTarget(t),s=this.cacheKey(n,r);i.delete(s),0==i.size&&this.eventListenerMaps.delete(t)}fetchEventListenerForBinding(e){const{eventTarget:t,eventName:n,eventOptions:r}=e;return this.fetchEventListener(t,n,r)}fetchEventListener(e,t,n){const r=this.fetchEventListenerMapForEventTarget(e),i=this.cacheKey(t,n);let s=r.get(i);return s||(s=this.createEventListener(e,t,n),r.set(i,s)),s}createEventListener(t,n,r){const i=new e(t,n,r);return this.started&&i.connect(),i}fetchEventListenerMapForEventTarget(e){let t=this.eventListenerMaps.get(e);return t||(t=new Map,this.eventListenerMaps.set(e,t)),t}cacheKey(e,t){const n=[e];return Object.keys(t).sort().forEach((e=>{n.push(`${t[e]?"":"!"}${e}`)})),n.join(":")}}const n={stop:({event:e,value:t})=>(t&&e.stopPropagation(),!0),prevent:({event:e,value:t})=>(t&&e.preventDefault(),!0),self:({event:e,value:t,element:n})=>!t||n===e.target},r=/^(?:(.+?)(?:\.(.+?))?(?:@(window|document))?->)?(.+?)(?:#([^:]+?))(?::(.+))?$/;function i(e){return"window"==e?window:"document"==e?document:void 0}function s(e){return e.replace(/(?:[_-])([a-z0-9])/g,((e,t)=>t.toUpperCase()))}function o(e){return s(e.replace(/--/g,"-").replace(/__/g,"_"))}function a(e){return e.charAt(0).toUpperCase()+e.slice(1)}function l(e){return e.replace(/([A-Z])/g,((e,t)=>`-${t.toLowerCase()}`))}const c={a:()=>"click",button:()=>"click",form:()=>"submit",details:()=>"toggle",input:e=>"submit"==e.getAttribute("type")?"click":"input",select:()=>"change",textarea:()=>"input"};function h(e){throw new Error(e)}function d(e){try{return JSON.parse(e)}catch(t){return e}}class u{constructor(e,t){this.context=e,this.action=t}get index(){return this.action.index}get eventTarget(){return this.action.eventTarget}get eventOptions(){return this.action.eventOptions}get identifier(){return this.context.identifier}handleEvent(e){this.willBeInvokedByEvent(e)&&this.applyEventModifiers(e)&&this.invokeWithEvent(e)}get eventName(){return this.action.eventName}get method(){const e=this.controller[this.methodName];if("function"==typeof e)return e;throw new Error(`Action "${this.action}" references undefined method "${this.methodName}"`)}applyEventModifiers(e){const{element:t}=this.action,{actionDescriptorFilters:n}=this.context.application;let r=!0;for(const[i,s]of Object.entries(this.eventOptions))if(i in n){const o=n[i];r=r&&o({name:i,value:s,event:e,element:t})}return r}invokeWithEvent(e){const{target:t,currentTarget:n}=e;try{const{params:r}=this.action,i=Object.assign(e,{params:r});this.method.call(this.controller,i),this.context.logDebugActivity(this.methodName,{event:e,target:t,currentTarget:n,action:this.methodName})}catch(t){const{identifier:n,controller:r,element:i,index:s}=this,o={identifier:n,controller:r,element:i,index:s,event:e};this.context.handleError(t,`invoking action "${this.action}"`,o)}}willBeInvokedByEvent(e){const t=e.target;return!(e instanceof KeyboardEvent&&this.action.isFilterTarget(e))&&(this.element===t||(t instanceof Element&&this.element.contains(t)?this.scope.containsElement(t):this.scope.containsElement(this.action.element)))}get controller(){return this.context.controller}get methodName(){return this.action.methodName}get element(){return this.scope.element}get scope(){return this.context.scope}}class p{constructor(e,t){this.mutationObserverInit={attributes:!0,childList:!0,subtree:!0},this.element=e,this.started=!1,this.delegate=t,this.elements=new Set,this.mutationObserver=new MutationObserver((e=>this.processMutations(e)))}start(){this.started||(this.started=!0,this.mutationObserver.observe(this.element,this.mutationObserverInit),this.refresh())}pause(e){this.started&&(this.mutationObserver.disconnect(),this.started=!1),e(),this.started||(this.mutationObserver.observe(this.element,this.mutationObserverInit),this.started=!0)}stop(){this.started&&(this.mutationObserver.takeRecords(),this.mutationObserver.disconnect(),this.started=!1)}refresh(){if(this.started){const e=new Set(this.matchElementsInTree());for(const t of Array.from(this.elements))e.has(t)||this.removeElement(t);for(const t of Array.from(e))this.addElement(t)}}processMutations(e){if(this.started)for(const t of e)this.processMutation(t)}processMutation(e){"attributes"==e.type?this.processAttributeChange(e.target,e.attributeName):"childList"==e.type&&(this.processRemovedNodes(e.removedNodes),this.processAddedNodes(e.addedNodes))}processAttributeChange(e,t){const n=e;this.elements.has(n)?this.delegate.elementAttributeChanged&&this.matchElement(n)?this.delegate.elementAttributeChanged(n,t):this.removeElement(n):this.matchElement(n)&&this.addElement(n)}processRemovedNodes(e){for(const t of Array.from(e)){const e=this.elementFromNode(t);e&&this.processTree(e,this.removeElement)}}processAddedNodes(e){for(const t of Array.from(e)){const e=this.elementFromNode(t);e&&this.elementIsActive(e)&&this.processTree(e,this.addElement)}}matchElement(e){return this.delegate.matchElement(e)}matchElementsInTree(e=this.element){return this.delegate.matchElementsInTree(e)}processTree(e,t){for(const n of this.matchElementsInTree(e))t.call(this,n)}elementFromNode(e){if(e.nodeType==Node.ELEMENT_NODE)return e}elementIsActive(e){return e.isConnected==this.element.isConnected&&this.element.contains(e)}addElement(e){this.elements.has(e)||this.elementIsActive(e)&&(this.elements.add(e),this.delegate.elementMatched&&this.delegate.elementMatched(e))}removeElement(e){this.elements.has(e)&&(this.elements.delete(e),this.delegate.elementUnmatched&&this.delegate.elementUnmatched(e))}}class f{constructor(e,t,n){this.attributeName=t,this.delegate=n,this.elementObserver=new p(e,this)}get element(){return this.elementObserver.element}get selector(){return`[${this.attributeName}]`}start(){this.elementObserver.start()}pause(e){this.elementObserver.pause(e)}stop(){this.elementObserver.stop()}refresh(){this.elementObserver.refresh()}get started(){return this.elementObserver.started}matchElement(e){return e.hasAttribute(this.attributeName)}matchElementsInTree(e){const t=this.matchElement(e)?[e]:[],n=Array.from(e.querySelectorAll(this.selector));return t.concat(n)}elementMatched(e){this.delegate.elementMatchedAttribute&&this.delegate.elementMatchedAttribute(e,this.attributeName)}elementUnmatched(e){this.delegate.elementUnmatchedAttribute&&this.delegate.elementUnmatchedAttribute(e,this.attributeName)}elementAttributeChanged(e,t){this.delegate.elementAttributeValueChanged&&this.attributeName==t&&this.delegate.elementAttributeValueChanged(e,t)}}function m(e,t){let n=e.get(t);return n||(n=new Set,e.set(t,n)),n}class g{constructor(){this.valuesByKey=new Map}get keys(){return Array.from(this.valuesByKey.keys())}get values(){return Array.from(this.valuesByKey.values()).reduce(((e,t)=>e.concat(Array.from(t))),[])}get size(){return Array.from(this.valuesByKey.values()).reduce(((e,t)=>e+t.size),0)}add(e,t){!function(e,t,n){m(e,t).add(n)}(this.valuesByKey,e,t)}delete(e,t){!function(e,t,n){m(e,t).delete(n),function(e,t){const n=e.get(t);null!=n&&0==n.size&&e.delete(t)}(e,t)}(this.valuesByKey,e,t)}has(e,t){const n=this.valuesByKey.get(e);return null!=n&&n.has(t)}hasKey(e){return this.valuesByKey.has(e)}hasValue(e){return Array.from(this.valuesByKey.values()).some((t=>t.has(e)))}getValuesForKey(e){const t=this.valuesByKey.get(e);return t?Array.from(t):[]}getKeysForValue(e){return Array.from(this.valuesByKey).filter((([t,n])=>n.has(e))).map((([e,t])=>e))}}class y{constructor(e,t,n,r={}){this.selector=t,this.details=r,this.elementObserver=new p(e,this),this.delegate=n,this.matchesByElement=new g}get started(){return this.elementObserver.started}start(){this.elementObserver.start()}pause(e){this.elementObserver.pause(e)}stop(){this.elementObserver.stop()}refresh(){this.elementObserver.refresh()}get element(){return this.elementObserver.element}matchElement(e){const t=e.matches(this.selector);return this.delegate.selectorMatchElement?t&&this.delegate.selectorMatchElement(e,this.details):t}matchElementsInTree(e){const t=this.matchElement(e)?[e]:[],n=Array.from(e.querySelectorAll(this.selector)).filter((e=>this.matchElement(e)));return t.concat(n)}elementMatched(e){this.selectorMatched(e)}elementUnmatched(e){this.selectorUnmatched(e)}elementAttributeChanged(e,t){const n=this.matchElement(e),r=this.matchesByElement.has(this.selector,e);!n&&r&&this.selectorUnmatched(e)}selectorMatched(e){this.delegate.selectorMatched&&(this.delegate.selectorMatched(e,this.selector,this.details),this.matchesByElement.add(this.selector,e))}selectorUnmatched(e){this.delegate.selectorUnmatched(e,this.selector,this.details),this.matchesByElement.delete(this.selector,e)}}class v{constructor(e,t){this.element=e,this.delegate=t,this.started=!1,this.stringMap=new Map,this.mutationObserver=new MutationObserver((e=>this.processMutations(e)))}start(){this.started||(this.started=!0,this.mutationObserver.observe(this.element,{attributes:!0,attributeOldValue:!0}),this.refresh())}stop(){this.started&&(this.mutationObserver.takeRecords(),this.mutationObserver.disconnect(),this.started=!1)}refresh(){if(this.started)for(const e of this.knownAttributeNames)this.refreshAttribute(e,null)}processMutations(e){if(this.started)for(const t of e)this.processMutation(t)}processMutation(e){const t=e.attributeName;t&&this.refreshAttribute(t,e.oldValue)}refreshAttribute(e,t){const n=this.delegate.getStringMapKeyForAttribute(e);if(null!=n){this.stringMap.has(e)||this.stringMapKeyAdded(n,e);const r=this.element.getAttribute(e);if(this.stringMap.get(e)!=r&&this.stringMapValueChanged(r,n,t),null==r){const t=this.stringMap.get(e);this.stringMap.delete(e),t&&this.stringMapKeyRemoved(n,e,t)}else this.stringMap.set(e,r)}}stringMapKeyAdded(e,t){this.delegate.stringMapKeyAdded&&this.delegate.stringMapKeyAdded(e,t)}stringMapValueChanged(e,t,n){this.delegate.stringMapValueChanged&&this.delegate.stringMapValueChanged(e,t,n)}stringMapKeyRemoved(e,t,n){this.delegate.stringMapKeyRemoved&&this.delegate.stringMapKeyRemoved(e,t,n)}get knownAttributeNames(){return Array.from(new Set(this.currentAttributeNames.concat(this.recordedAttributeNames)))}get currentAttributeNames(){return Array.from(this.element.attributes).map((e=>e.name))}get recordedAttributeNames(){return Array.from(this.stringMap.keys())}}class b{constructor(e,t,n){this.attributeObserver=new f(e,t,this),this.delegate=n,this.tokensByElement=new g}get started(){return this.attributeObserver.started}start(){this.attributeObserver.start()}pause(e){this.attributeObserver.pause(e)}stop(){this.attributeObserver.stop()}refresh(){this.attributeObserver.refresh()}get element(){return this.attributeObserver.element}get attributeName(){return this.attributeObserver.attributeName}elementMatchedAttribute(e){this.tokensMatched(this.readTokensForElement(e))}elementAttributeValueChanged(e){const[t,n]=this.refreshTokensForElement(e);this.tokensUnmatched(t),this.tokensMatched(n)}elementUnmatchedAttribute(e){this.tokensUnmatched(this.tokensByElement.getValuesForKey(e))}tokensMatched(e){e.forEach((e=>this.tokenMatched(e)))}tokensUnmatched(e){e.forEach((e=>this.tokenUnmatched(e)))}tokenMatched(e){this.delegate.tokenMatched(e),this.tokensByElement.add(e.element,e)}tokenUnmatched(e){this.delegate.tokenUnmatched(e),this.tokensByElement.delete(e.element,e)}refreshTokensForElement(e){const t=this.tokensByElement.getValuesForKey(e),n=this.readTokensForElement(e),r=function(e,t){const n=Math.max(e.length,t.length);return Array.from({length:n},((n,r)=>[e[r],t[r]]))}(t,n).findIndex((([e,t])=>!function(e,t){return e&&t&&e.index==t.index&&e.content==t.content}(e,t)));return-1==r?[[],[]]:[t.slice(r),n.slice(r)]}readTokensForElement(e){const t=this.attributeName;return function(e,t,n){return e.trim().split(/\s+/).filter((e=>e.length)).map(((e,r)=>({element:t,attributeName:n,content:e,index:r})))}(e.getAttribute(t)||"",e,t)}}class w{constructor(e,t,n){this.tokenListObserver=new b(e,t,this),this.delegate=n,this.parseResultsByToken=new WeakMap,this.valuesByTokenByElement=new WeakMap}get started(){return this.tokenListObserver.started}start(){this.tokenListObserver.start()}stop(){this.tokenListObserver.stop()}refresh(){this.tokenListObserver.refresh()}get element(){return this.tokenListObserver.element}get attributeName(){return this.tokenListObserver.attributeName}tokenMatched(e){const{element:t}=e,{value:n}=this.fetchParseResultForToken(e);n&&(this.fetchValuesByTokenForElement(t).set(e,n),this.delegate.elementMatchedValue(t,n))}tokenUnmatched(e){const{element:t}=e,{value:n}=this.fetchParseResultForToken(e);n&&(this.fetchValuesByTokenForElement(t).delete(e),this.delegate.elementUnmatchedValue(t,n))}fetchParseResultForToken(e){let t=this.parseResultsByToken.get(e);return t||(t=this.parseToken(e),this.parseResultsByToken.set(e,t)),t}fetchValuesByTokenForElement(e){let t=this.valuesByTokenByElement.get(e);return t||(t=new Map,this.valuesByTokenByElement.set(e,t)),t}parseToken(e){try{return{value:this.delegate.parseValueForToken(e)}}catch(e){return{error:e}}}}class x{constructor(e,t){this.context=e,this.delegate=t,this.bindingsByAction=new Map}start(){this.valueListObserver||(this.valueListObserver=new w(this.element,this.actionAttribute,this),this.valueListObserver.start())}stop(){this.valueListObserver&&(this.valueListObserver.stop(),delete this.valueListObserver,this.disconnectAllActions())}get element(){return this.context.element}get identifier(){return this.context.identifier}get actionAttribute(){return this.schema.actionAttribute}get schema(){return this.context.schema}get bindings(){return Array.from(this.bindingsByAction.values())}connectAction(e){const t=new u(this.context,e);this.bindingsByAction.set(e,t),this.delegate.bindingConnected(t)}disconnectAction(e){const t=this.bindingsByAction.get(e);t&&(this.bindingsByAction.delete(e),this.delegate.bindingDisconnected(t))}disconnectAllActions(){this.bindings.forEach((e=>this.delegate.bindingDisconnected(e,!0))),this.bindingsByAction.clear()}parseValueForToken(e){const t=class{constructor(e,t,n,r){this.element=e,this.index=t,this.eventTarget=n.eventTarget||e,this.eventName=n.eventName||function(e){const t=e.tagName.toLowerCase();if(t in c)return c[t](e)}(e)||h("missing event name"),this.eventOptions=n.eventOptions||{},this.identifier=n.identifier||h("missing identifier"),this.methodName=n.methodName||h("missing method name"),this.keyFilter=n.keyFilter||"",this.schema=r}static forToken(e,t){return new this(e.element,e.index,function(e){const t=e.trim().match(r)||[];let n=t[1],s=t[2];return s&&!["keydown","keyup","keypress"].includes(n)&&(n+=`.${s}`,s=""),{eventTarget:i(t[3]),eventName:n,eventOptions:t[6]?(o=t[6],o.split(":").reduce(((e,t)=>Object.assign(e,{[t.replace(/^!/,"")]:!/^!/.test(t)})),{})):{},identifier:t[4],methodName:t[5],keyFilter:s};var o}(e.content),t)}toString(){const e=this.keyFilter?`.${this.keyFilter}`:"",t=this.eventTargetName?`@${this.eventTargetName}`:"";return`${this.eventName}${e}${t}->${this.identifier}#${this.methodName}`}isFilterTarget(e){if(!this.keyFilter)return!1;const t=this.keyFilter.split("+"),n=["meta","ctrl","alt","shift"],[r,i,s,o]=n.map((e=>t.includes(e)));if(e.metaKey!==r||e.ctrlKey!==i||e.altKey!==s||e.shiftKey!==o)return!0;const a=t.filter((e=>!n.includes(e)))[0];return!!a&&(Object.prototype.hasOwnProperty.call(this.keyMappings,a)||h(`contains unknown key filter: ${this.keyFilter}`),this.keyMappings[a].toLowerCase()!==e.key.toLowerCase())}get params(){const e={},t=new RegExp(`^data-${this.identifier}-(.+)-param$`,"i");for(const{name:n,value:r}of Array.from(this.element.attributes)){const i=n.match(t),o=i&&i[1];o&&(e[s(o)]=d(r))}return e}get eventTargetName(){return(e=this.eventTarget)==window?"window":e==document?"document":void 0;var e}get keyMappings(){return this.schema.keyMappings}}.forToken(e,this.schema);if(t.identifier==this.identifier)return t}elementMatchedValue(e,t){this.connectAction(t)}elementUnmatchedValue(e,t){this.disconnectAction(t)}}class k{constructor(e,t){this.context=e,this.receiver=t,this.stringMapObserver=new v(this.element,this),this.valueDescriptorMap=this.controller.valueDescriptorMap}start(){this.stringMapObserver.start(),this.invokeChangedCallbacksForDefaultValues()}stop(){this.stringMapObserver.stop()}get element(){return this.context.element}get controller(){return this.context.controller}getStringMapKeyForAttribute(e){if(e in this.valueDescriptorMap)return this.valueDescriptorMap[e].name}stringMapKeyAdded(e,t){const n=this.valueDescriptorMap[t];this.hasValue(e)||this.invokeChangedCallback(e,n.writer(this.receiver[e]),n.writer(n.defaultValue))}stringMapValueChanged(e,t,n){const r=this.valueDescriptorNameMap[t];null!==e&&(null===n&&(n=r.writer(r.defaultValue)),this.invokeChangedCallback(t,e,n))}stringMapKeyRemoved(e,t,n){const r=this.valueDescriptorNameMap[e];this.hasValue(e)?this.invokeChangedCallback(e,r.writer(this.receiver[e]),n):this.invokeChangedCallback(e,r.writer(r.defaultValue),n)}invokeChangedCallbacksForDefaultValues(){for(const{key:e,name:t,defaultValue:n,writer:r}of this.valueDescriptors)null==n||this.controller.data.has(e)||this.invokeChangedCallback(t,r(n),void 0)}invokeChangedCallback(e,t,n){const r=`${e}Changed`,i=this.receiver[r];if("function"==typeof i){const r=this.valueDescriptorNameMap[e];try{const e=r.reader(t);let s=n;n&&(s=r.reader(n)),i.call(this.receiver,e,s)}catch(e){throw e instanceof TypeError&&(e.message=`Stimulus Value "${this.context.identifier}.${r.name}" - ${e.message}`),e}}}get valueDescriptors(){const{valueDescriptorMap:e}=this;return Object.keys(e).map((t=>e[t]))}get valueDescriptorNameMap(){const e={};return Object.keys(this.valueDescriptorMap).forEach((t=>{const n=this.valueDescriptorMap[t];e[n.name]=n})),e}hasValue(e){const t=`has${a(this.valueDescriptorNameMap[e].name)}`;return this.receiver[t]}}class S{constructor(e,t){this.context=e,this.delegate=t,this.targetsByName=new g}start(){this.tokenListObserver||(this.tokenListObserver=new b(this.element,this.attributeName,this),this.tokenListObserver.start())}stop(){this.tokenListObserver&&(this.disconnectAllTargets(),this.tokenListObserver.stop(),delete this.tokenListObserver)}tokenMatched({element:e,content:t}){this.scope.containsElement(e)&&this.connectTarget(e,t)}tokenUnmatched({element:e,content:t}){this.disconnectTarget(e,t)}connectTarget(e,t){var n;this.targetsByName.has(t,e)||(this.targetsByName.add(t,e),null===(n=this.tokenListObserver)||void 0===n||n.pause((()=>this.delegate.targetConnected(e,t))))}disconnectTarget(e,t){var n;this.targetsByName.has(t,e)&&(this.targetsByName.delete(t,e),null===(n=this.tokenListObserver)||void 0===n||n.pause((()=>this.delegate.targetDisconnected(e,t))))}disconnectAllTargets(){for(const e of this.targetsByName.keys)for(const t of this.targetsByName.getValuesForKey(e))this.disconnectTarget(t,e)}get attributeName(){return`data-${this.context.identifier}-target`}get element(){return this.context.element}get scope(){return this.context.scope}}function M(e,t){const n=A(e);return Array.from(n.reduce(((e,n)=>(function(e,t){const n=e[t];return Array.isArray(n)?n:[]}(n,t).forEach((t=>e.add(t))),e)),new Set))}function O(e,t){return A(e).reduce(((e,n)=>(e.push(...function(e,t){const n=e[t];return n?Object.keys(n).map((e=>[e,n[e]])):[]}(n,t)),e)),[])}function A(e){const t=[];for(;e;)t.push(e),e=Object.getPrototypeOf(e);return t.reverse()}class C{constructor(e,t){this.context=e,this.delegate=t,this.outletsByName=new g,this.outletElementsByName=new g,this.selectorObserverMap=new Map}start(){0===this.selectorObserverMap.size&&(this.outletDefinitions.forEach((e=>{const t=this.selector(e),n={outletName:e};t&&this.selectorObserverMap.set(e,new y(document.body,t,this,n))})),this.selectorObserverMap.forEach((e=>e.start()))),this.dependentContexts.forEach((e=>e.refresh()))}stop(){this.selectorObserverMap.size>0&&(this.disconnectAllOutlets(),this.selectorObserverMap.forEach((e=>e.stop())),this.selectorObserverMap.clear())}refresh(){this.selectorObserverMap.forEach((e=>e.refresh()))}selectorMatched(e,t,{outletName:n}){const r=this.getOutlet(e,n);r&&this.connectOutlet(r,e,n)}selectorUnmatched(e,t,{outletName:n}){const r=this.getOutletFromMap(e,n);r&&this.disconnectOutlet(r,e,n)}selectorMatchElement(e,{outletName:t}){return this.hasOutlet(e,t)&&e.matches(`[${this.context.application.schema.controllerAttribute}~=${t}]`)}connectOutlet(e,t,n){var r;this.outletElementsByName.has(n,t)||(this.outletsByName.add(n,e),this.outletElementsByName.add(n,t),null===(r=this.selectorObserverMap.get(n))||void 0===r||r.pause((()=>this.delegate.outletConnected(e,t,n))))}disconnectOutlet(e,t,n){var r;this.outletElementsByName.has(n,t)&&(this.outletsByName.delete(n,e),this.outletElementsByName.delete(n,t),null===(r=this.selectorObserverMap.get(n))||void 0===r||r.pause((()=>this.delegate.outletDisconnected(e,t,n))))}disconnectAllOutlets(){for(const e of this.outletElementsByName.keys)for(const t of this.outletElementsByName.getValuesForKey(e))for(const n of this.outletsByName.getValuesForKey(e))this.disconnectOutlet(n,t,e)}selector(e){return this.scope.outlets.getSelectorForOutletName(e)}get outletDependencies(){const e=new g;return this.router.modules.forEach((t=>{M(t.definition.controllerConstructor,"outlets").forEach((n=>e.add(n,t.identifier)))})),e}get outletDefinitions(){return this.outletDependencies.getKeysForValue(this.identifier)}get dependentControllerIdentifiers(){return this.outletDependencies.getValuesForKey(this.identifier)}get dependentContexts(){const e=this.dependentControllerIdentifiers;return this.router.contexts.filter((t=>e.includes(t.identifier)))}hasOutlet(e,t){return!!this.getOutlet(e,t)||!!this.getOutletFromMap(e,t)}getOutlet(e,t){return this.application.getControllerForElementAndIdentifier(e,t)}getOutletFromMap(e,t){return this.outletsByName.getValuesForKey(t).find((t=>t.element===e))}get scope(){return this.context.scope}get identifier(){return this.context.identifier}get application(){return this.context.application}get router(){return this.application.router}}class E{constructor(e,t){this.logDebugActivity=(e,t={})=>{const{identifier:n,controller:r,element:i}=this;t=Object.assign({identifier:n,controller:r,element:i},t),this.application.logDebugActivity(this.identifier,e,t)},this.module=e,this.scope=t,this.controller=new e.controllerConstructor(this),this.bindingObserver=new x(this,this.dispatcher),this.valueObserver=new k(this,this.controller),this.targetObserver=new S(this,this),this.outletObserver=new C(this,this);try{this.controller.initialize(),this.logDebugActivity("initialize")}catch(e){this.handleError(e,"initializing controller")}}connect(){this.bindingObserver.start(),this.valueObserver.start(),this.targetObserver.start(),this.outletObserver.start();try{this.controller.connect(),this.logDebugActivity("connect")}catch(e){this.handleError(e,"connecting controller")}}refresh(){this.outletObserver.refresh()}disconnect(){try{this.controller.disconnect(),this.logDebugActivity("disconnect")}catch(e){this.handleError(e,"disconnecting controller")}this.outletObserver.stop(),this.targetObserver.stop(),this.valueObserver.stop(),this.bindingObserver.stop()}get application(){return this.module.application}get identifier(){return this.module.identifier}get schema(){return this.application.schema}get dispatcher(){return this.application.dispatcher}get element(){return this.scope.element}get parentElement(){return this.element.parentElement}handleError(e,t,n={}){const{identifier:r,controller:i,element:s}=this;n=Object.assign({identifier:r,controller:i,element:s},n),this.application.handleError(e,`Error ${t}`,n)}targetConnected(e,t){this.invokeControllerMethod(`${t}TargetConnected`,e)}targetDisconnected(e,t){this.invokeControllerMethod(`${t}TargetDisconnected`,e)}outletConnected(e,t,n){this.invokeControllerMethod(`${o(n)}OutletConnected`,e,t)}outletDisconnected(e,t,n){this.invokeControllerMethod(`${o(n)}OutletDisconnected`,e,t)}invokeControllerMethod(e,...t){const n=this.controller;"function"==typeof n[e]&&n[e](...t)}}function T(e){return function(e,t){const n=D(e),r=function(e,t){return N(t).reduce(((n,r)=>{const i=function(e,t,n){const r=Object.getOwnPropertyDescriptor(e,n);if(!r||!("value"in r)){const e=Object.getOwnPropertyDescriptor(t,n).value;return r&&(e.get=r.get||e.get,e.set=r.set||e.set),e}}(e,t,r);return i&&Object.assign(n,{[r]:i}),n}),{})}(e.prototype,t);return Object.defineProperties(n.prototype,r),n}(e,function(e){return M(e,"blessings").reduce(((t,n)=>{const r=n(e);for(const e in r){const n=t[e]||{};t[e]=Object.assign(n,r[e])}return t}),{})}(e))}const N="function"==typeof Object.getOwnPropertySymbols?e=>[...Object.getOwnPropertyNames(e),...Object.getOwnPropertySymbols(e)]:Object.getOwnPropertyNames,D=(()=>{function e(e){function t(){return Reflect.construct(e,arguments,new.target)}return t.prototype=Object.create(e.prototype,{constructor:{value:t}}),Reflect.setPrototypeOf(t,e),t}try{return function(){const t=e((function(){this.a.call(this)}));t.prototype.a=function(){},new t}(),e}catch(e){return e=>class extends e{}}})();class ${constructor(e,t){this.application=e,this.definition=function(e){return{identifier:e.identifier,controllerConstructor:T(e.controllerConstructor)}}(t),this.contextsByScope=new WeakMap,this.connectedContexts=new Set}get identifier(){return this.definition.identifier}get controllerConstructor(){return this.definition.controllerConstructor}get contexts(){return Array.from(this.connectedContexts)}connectContextForScope(e){const t=this.fetchContextForScope(e);this.connectedContexts.add(t),t.connect()}disconnectContextForScope(e){const t=this.contextsByScope.get(e);t&&(this.connectedContexts.delete(t),t.disconnect())}fetchContextForScope(e){let t=this.contextsByScope.get(e);return t||(t=new E(this,e),this.contextsByScope.set(e,t)),t}}class I{constructor(e){this.scope=e}has(e){return this.data.has(this.getDataKey(e))}get(e){return this.getAll(e)[0]}getAll(e){const t=this.data.get(this.getDataKey(e))||"";return t.match(/[^\s]+/g)||[]}getAttributeName(e){return this.data.getAttributeNameForKey(this.getDataKey(e))}getDataKey(e){return`${e}-class`}get data(){return this.scope.data}}class R{constructor(e){this.scope=e}get element(){return this.scope.element}get identifier(){return this.scope.identifier}get(e){const t=this.getAttributeNameForKey(e);return this.element.getAttribute(t)}set(e,t){const n=this.getAttributeNameForKey(e);return this.element.setAttribute(n,t),this.get(e)}has(e){const t=this.getAttributeNameForKey(e);return this.element.hasAttribute(t)}delete(e){if(this.has(e)){const t=this.getAttributeNameForKey(e);return this.element.removeAttribute(t),!0}return!1}getAttributeNameForKey(e){return`data-${this.identifier}-${l(e)}`}}class B{constructor(e){this.warnedKeysByObject=new WeakMap,this.logger=e}warn(e,t,n){let r=this.warnedKeysByObject.get(e);r||(r=new Set,this.warnedKeysByObject.set(e,r)),r.has(t)||(r.add(t),this.logger.warn(n,e))}}function F(e,t){return`[${e}~="${t}"]`}class P{constructor(e){this.scope=e}get element(){return this.scope.element}get identifier(){return this.scope.identifier}get schema(){return this.scope.schema}has(e){return null!=this.find(e)}find(...e){return e.reduce(((e,t)=>e||this.findTarget(t)||this.findLegacyTarget(t)),void 0)}findAll(...e){return e.reduce(((e,t)=>[...e,...this.findAllTargets(t),...this.findAllLegacyTargets(t)]),[])}findTarget(e){const t=this.getSelectorForTargetName(e);return this.scope.findElement(t)}findAllTargets(e){const t=this.getSelectorForTargetName(e);return this.scope.findAllElements(t)}getSelectorForTargetName(e){return F(this.schema.targetAttributeForScope(this.identifier),e)}findLegacyTarget(e){const t=this.getLegacySelectorForTargetName(e);return this.deprecate(this.scope.findElement(t),e)}findAllLegacyTargets(e){const t=this.getLegacySelectorForTargetName(e);return this.scope.findAllElements(t).map((t=>this.deprecate(t,e)))}getLegacySelectorForTargetName(e){const t=`${this.identifier}.${e}`;return F(this.schema.targetAttribute,t)}deprecate(e,t){if(e){const{identifier:n}=this,r=this.schema.targetAttribute,i=this.schema.targetAttributeForScope(n);this.guide.warn(e,`target:${t}`,`Please replace ${r}="${n}.${t}" with ${i}="${t}". The ${r} attribute is deprecated and will be removed in a future version of Stimulus.`)}return e}get guide(){return this.scope.guide}}class L{constructor(e,t){this.scope=e,this.controllerElement=t}get element(){return this.scope.element}get identifier(){return this.scope.identifier}get schema(){return this.scope.schema}has(e){return null!=this.find(e)}find(...e){return e.reduce(((e,t)=>e||this.findOutlet(t)),void 0)}findAll(...e){return e.reduce(((e,t)=>[...e,...this.findAllOutlets(t)]),[])}getSelectorForOutletName(e){const t=this.schema.outletAttributeForScope(this.identifier,e);return this.controllerElement.getAttribute(t)}findOutlet(e){const t=this.getSelectorForOutletName(e);if(t)return this.findElement(t,e)}findAllOutlets(e){const t=this.getSelectorForOutletName(e);return t?this.findAllElements(t,e):[]}findElement(e,t){return this.scope.queryElements(e).filter((n=>this.matchesElement(n,e,t)))[0]}findAllElements(e,t){return this.scope.queryElements(e).filter((n=>this.matchesElement(n,e,t)))}matchesElement(e,t,n){const r=e.getAttribute(this.scope.schema.controllerAttribute)||"";return e.matches(t)&&r.split(" ").includes(n)}}class V{constructor(e,t,n,r){this.targets=new P(this),this.classes=new I(this),this.data=new R(this),this.containsElement=e=>e.closest(this.controllerSelector)===this.element,this.schema=e,this.element=t,this.identifier=n,this.guide=new B(r),this.outlets=new L(this.documentScope,t)}findElement(e){return this.element.matches(e)?this.element:this.queryElements(e).find(this.containsElement)}findAllElements(e){return[...this.element.matches(e)?[this.element]:[],...this.queryElements(e).filter(this.containsElement)]}queryElements(e){return Array.from(this.element.querySelectorAll(e))}get controllerSelector(){return F(this.schema.controllerAttribute,this.identifier)}get isDocumentScope(){return this.element===document.documentElement}get documentScope(){return this.isDocumentScope?this:new V(this.schema,document.documentElement,this.identifier,this.guide.logger)}}class z{constructor(e,t,n){this.element=e,this.schema=t,this.delegate=n,this.valueListObserver=new w(this.element,this.controllerAttribute,this),this.scopesByIdentifierByElement=new WeakMap,this.scopeReferenceCounts=new WeakMap}start(){this.valueListObserver.start()}stop(){this.valueListObserver.stop()}get controllerAttribute(){return this.schema.controllerAttribute}parseValueForToken(e){const{element:t,content:n}=e,r=this.fetchScopesByIdentifierForElement(t);let i=r.get(n);return i||(i=this.delegate.createScopeForElementAndIdentifier(t,n),r.set(n,i)),i}elementMatchedValue(e,t){const n=(this.scopeReferenceCounts.get(t)||0)+1;this.scopeReferenceCounts.set(t,n),1==n&&this.delegate.scopeConnected(t)}elementUnmatchedValue(e,t){const n=this.scopeReferenceCounts.get(t);n&&(this.scopeReferenceCounts.set(t,n-1),1==n&&this.delegate.scopeDisconnected(t))}fetchScopesByIdentifierForElement(e){let t=this.scopesByIdentifierByElement.get(e);return t||(t=new Map,this.scopesByIdentifierByElement.set(e,t)),t}}class j{constructor(e){this.application=e,this.scopeObserver=new z(this.element,this.schema,this),this.scopesByIdentifier=new g,this.modulesByIdentifier=new Map}get element(){return this.application.element}get schema(){return this.application.schema}get logger(){return this.application.logger}get controllerAttribute(){return this.schema.controllerAttribute}get modules(){return Array.from(this.modulesByIdentifier.values())}get contexts(){return this.modules.reduce(((e,t)=>e.concat(t.contexts)),[])}start(){this.scopeObserver.start()}stop(){this.scopeObserver.stop()}loadDefinition(e){this.unloadIdentifier(e.identifier);const t=new $(this.application,e);this.connectModule(t);const n=e.controllerConstructor.afterLoad;n&&n(e.identifier,this.application)}unloadIdentifier(e){const t=this.modulesByIdentifier.get(e);t&&this.disconnectModule(t)}getContextForElementAndIdentifier(e,t){const n=this.modulesByIdentifier.get(t);if(n)return n.contexts.find((t=>t.element==e))}handleError(e,t,n){this.application.handleError(e,t,n)}createScopeForElementAndIdentifier(e,t){return new V(this.schema,e,t,this.logger)}scopeConnected(e){this.scopesByIdentifier.add(e.identifier,e);const t=this.modulesByIdentifier.get(e.identifier);t&&t.connectContextForScope(e)}scopeDisconnected(e){this.scopesByIdentifier.delete(e.identifier,e);const t=this.modulesByIdentifier.get(e.identifier);t&&t.disconnectContextForScope(e)}connectModule(e){this.modulesByIdentifier.set(e.identifier,e);this.scopesByIdentifier.getValuesForKey(e.identifier).forEach((t=>e.connectContextForScope(t)))}disconnectModule(e){this.modulesByIdentifier.delete(e.identifier);this.scopesByIdentifier.getValuesForKey(e.identifier).forEach((t=>e.disconnectContextForScope(t)))}}const _={controllerAttribute:"data-controller",actionAttribute:"data-action",targetAttribute:"data-target",targetAttributeForScope:e=>`data-${e}-target`,outletAttributeForScope:(e,t)=>`data-${e}-${t}-outlet`,keyMappings:Object.assign(Object.assign({enter:"Enter",tab:"Tab",esc:"Escape",space:" ",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight",home:"Home",end:"End"},K("abcdefghijklmnopqrstuvwxyz".split("").map((e=>[e,e])))),K("0123456789".split("").map((e=>[e,e]))))};function K(e){return e.reduce(((e,[t,n])=>Object.assign(Object.assign({},e),{[t]:n})),{})}function W([e,t],n){return function(e){const t=`${l(e.token)}-value`,n=function(e){const t=function(e){const t=H(e.typeObject.type);if(!t)return;const n=q(e.typeObject.default);if(t!==n){const r=e.controller?`${e.controller}.${e.token}`:e.token;throw new Error(`The specified default value for the Stimulus Value "${r}" must match the defined type "${t}". The provided default value of "${e.typeObject.default}" is of type "${n}".`)}return t}({controller:e.controller,token:e.token,typeObject:e.typeDefinition}),n=q(e.typeDefinition),r=H(e.typeDefinition),i=t||n||r;if(i)return i;const s=e.controller?`${e.controller}.${e.typeDefinition}`:e.token;throw new Error(`Unknown value type "${s}" for "${e.token}" value`)}(e);return{type:n,key:t,name:s(t),get defaultValue(){return function(e){const t=H(e);if(t)return J[t];const n=e.default;return void 0!==n?n:e}(e.typeDefinition)},get hasCustomDefaultValue(){return void 0!==q(e.typeDefinition)},reader:U[n],writer:G[n]||G.default}}({controller:n,token:e,typeDefinition:t})}function H(e){switch(e){case Array:return"array";case Boolean:return"boolean";case Number:return"number";case Object:return"object";case String:return"string"}}function q(e){switch(typeof e){case"boolean":return"boolean";case"number":return"number";case"string":return"string"}return Array.isArray(e)?"array":"[object Object]"===Object.prototype.toString.call(e)?"object":void 0}const J={get array(){return[]},boolean:!1,number:0,get object(){return{}},string:""},U={array(e){const t=JSON.parse(e);if(!Array.isArray(t))throw new TypeError(`expected value of type "array" but instead got value "${e}" of type "${q(t)}"`);return t},boolean:e=>!("0"==e||"false"==String(e).toLowerCase()),number:e=>Number(e),object(e){const t=JSON.parse(e);if(null===t||"object"!=typeof t||Array.isArray(t))throw new TypeError(`expected value of type "object" but instead got value "${e}" of type "${q(t)}"`);return t},string:e=>e},G={default:function(e){return`${e}`},array:Y,object:Y};function Y(e){return JSON.stringify(e)}class X{constructor(e){this.context=e}static get shouldLoad(){return!0}static afterLoad(e,t){}get application(){return this.context.application}get scope(){return this.context.scope}get element(){return this.scope.element}get identifier(){return this.scope.identifier}get targets(){return this.scope.targets}get outlets(){return this.scope.outlets}get classes(){return this.scope.classes}get data(){return this.scope.data}initialize(){}connect(){}disconnect(){}dispatch(e,{target:t=this.element,detail:n={},prefix:r=this.identifier,bubbles:i=!0,cancelable:s=!0}={}){const o=new CustomEvent(r?`${r}:${e}`:e,{detail:n,bubbles:i,cancelable:s});return t.dispatchEvent(o),o}}
1
+ class t{constructor(t,e,n){this.eventTarget=t,this.eventName=e,this.eventOptions=n,this.unorderedBindings=new Set}connect(){this.eventTarget.addEventListener(this.eventName,this,this.eventOptions)}disconnect(){this.eventTarget.removeEventListener(this.eventName,this,this.eventOptions)}bindingConnected(t){this.unorderedBindings.add(t)}bindingDisconnected(t){this.unorderedBindings.delete(t)}handleEvent(t){const e=function(t){if("immediatePropagationStopped"in t)return t;{const{stopImmediatePropagation:e}=t;return Object.assign(t,{immediatePropagationStopped:!1,stopImmediatePropagation(){this.immediatePropagationStopped=!0,e.call(this)}})}}(t);for(const t of this.bindings){if(e.immediatePropagationStopped)break;t.handleEvent(e)}}hasBindings(){return this.unorderedBindings.size>0}get bindings(){return Array.from(this.unorderedBindings).sort(((t,e)=>{const n=t.index,r=e.index;return n<r?-1:n>r?1:0}))}}class e{constructor(t){this.application=t,this.eventListenerMaps=new Map,this.started=!1}start(){this.started||(this.started=!0,this.eventListeners.forEach((t=>t.connect())))}stop(){this.started&&(this.started=!1,this.eventListeners.forEach((t=>t.disconnect())))}get eventListeners(){return Array.from(this.eventListenerMaps.values()).reduce(((t,e)=>t.concat(Array.from(e.values()))),[])}bindingConnected(t){this.fetchEventListenerForBinding(t).bindingConnected(t)}bindingDisconnected(t,e=!1){this.fetchEventListenerForBinding(t).bindingDisconnected(t),e&&this.clearEventListenersForBinding(t)}handleError(t,e,n={}){this.application.handleError(t,`Error ${e}`,n)}clearEventListenersForBinding(t){const e=this.fetchEventListenerForBinding(t);e.hasBindings()||(e.disconnect(),this.removeMappedEventListenerFor(t))}removeMappedEventListenerFor(t){const{eventTarget:e,eventName:n,eventOptions:r}=t,i=this.fetchEventListenerMapForEventTarget(e),s=this.cacheKey(n,r);i.delete(s),0==i.size&&this.eventListenerMaps.delete(e)}fetchEventListenerForBinding(t){const{eventTarget:e,eventName:n,eventOptions:r}=t;return this.fetchEventListener(e,n,r)}fetchEventListener(t,e,n){const r=this.fetchEventListenerMapForEventTarget(t),i=this.cacheKey(e,n);let s=r.get(i);return s||(s=this.createEventListener(t,e,n),r.set(i,s)),s}createEventListener(e,n,r){const i=new t(e,n,r);return this.started&&i.connect(),i}fetchEventListenerMapForEventTarget(t){let e=this.eventListenerMaps.get(t);return e||(e=new Map,this.eventListenerMaps.set(t,e)),e}cacheKey(t,e){const n=[t];return Object.keys(e).sort().forEach((t=>{n.push(`${e[t]?"":"!"}${t}`)})),n.join(":")}}const n={stop:({event:t,value:e})=>(e&&t.stopPropagation(),!0),prevent:({event:t,value:e})=>(e&&t.preventDefault(),!0),self:({event:t,value:e,element:n})=>!e||n===t.target},r=/^(?:(.+?)(?:\.(.+?))?(?:@(window|document))?->)?(.+?)(?:#([^:]+?))(?::(.+))?$/;function i(t){return"window"==t?window:"document"==t?document:void 0}function s(t){return t.replace(/(?:[_-])([a-z0-9])/g,((t,e)=>e.toUpperCase()))}function o(t){return s(t.replace(/--/g,"-").replace(/__/g,"_"))}function a(t){return t.charAt(0).toUpperCase()+t.slice(1)}function l(t){return t.replace(/([A-Z])/g,((t,e)=>`-${e.toLowerCase()}`))}const c={a:()=>"click",button:()=>"click",form:()=>"submit",details:()=>"toggle",input:t=>"submit"==t.getAttribute("type")?"click":"input",select:()=>"change",textarea:()=>"input"};function h(t){throw new Error(t)}function d(t){try{return JSON.parse(t)}catch(e){return t}}class u{constructor(t,e){this.context=t,this.action=e}get index(){return this.action.index}get eventTarget(){return this.action.eventTarget}get eventOptions(){return this.action.eventOptions}get identifier(){return this.context.identifier}handleEvent(t){this.willBeInvokedByEvent(t)&&this.applyEventModifiers(t)&&this.invokeWithEvent(t)}get eventName(){return this.action.eventName}get method(){const t=this.controller[this.methodName];if("function"==typeof t)return t;throw new Error(`Action "${this.action}" references undefined method "${this.methodName}"`)}applyEventModifiers(t){const{element:e}=this.action,{actionDescriptorFilters:n}=this.context.application;let r=!0;for(const[i,s]of Object.entries(this.eventOptions))if(i in n){const o=n[i];r=r&&o({name:i,value:s,event:t,element:e})}return r}invokeWithEvent(t){const{target:e,currentTarget:n}=t;try{const{params:r}=this.action,i=Object.assign(t,{params:r});this.method.call(this.controller,i),this.context.logDebugActivity(this.methodName,{event:t,target:e,currentTarget:n,action:this.methodName})}catch(e){const{identifier:n,controller:r,element:i,index:s}=this,o={identifier:n,controller:r,element:i,index:s,event:t};this.context.handleError(e,`invoking action "${this.action}"`,o)}}willBeInvokedByEvent(t){const e=t.target;return!(t instanceof KeyboardEvent&&this.action.isFilterTarget(t))&&(this.element===e||(e instanceof Element&&this.element.contains(e)?this.scope.containsElement(e):this.scope.containsElement(this.action.element)))}get controller(){return this.context.controller}get methodName(){return this.action.methodName}get element(){return this.scope.element}get scope(){return this.context.scope}}class p{constructor(t,e){this.mutationObserverInit={attributes:!0,childList:!0,subtree:!0},this.element=t,this.started=!1,this.delegate=e,this.elements=new Set,this.mutationObserver=new MutationObserver((t=>this.processMutations(t)))}start(){this.started||(this.started=!0,this.mutationObserver.observe(this.element,this.mutationObserverInit),this.refresh())}pause(t){this.started&&(this.mutationObserver.disconnect(),this.started=!1),t(),this.started||(this.mutationObserver.observe(this.element,this.mutationObserverInit),this.started=!0)}stop(){this.started&&(this.mutationObserver.takeRecords(),this.mutationObserver.disconnect(),this.started=!1)}refresh(){if(this.started){const t=new Set(this.matchElementsInTree());for(const e of Array.from(this.elements))t.has(e)||this.removeElement(e);for(const e of Array.from(t))this.addElement(e)}}processMutations(t){if(this.started)for(const e of t)this.processMutation(e)}processMutation(t){"attributes"==t.type?this.processAttributeChange(t.target,t.attributeName):"childList"==t.type&&(this.processRemovedNodes(t.removedNodes),this.processAddedNodes(t.addedNodes))}processAttributeChange(t,e){const n=t;this.elements.has(n)?this.delegate.elementAttributeChanged&&this.matchElement(n)?this.delegate.elementAttributeChanged(n,e):this.removeElement(n):this.matchElement(n)&&this.addElement(n)}processRemovedNodes(t){for(const e of Array.from(t)){const t=this.elementFromNode(e);t&&this.processTree(t,this.removeElement)}}processAddedNodes(t){for(const e of Array.from(t)){const t=this.elementFromNode(e);t&&this.elementIsActive(t)&&this.processTree(t,this.addElement)}}matchElement(t){return this.delegate.matchElement(t)}matchElementsInTree(t=this.element){return this.delegate.matchElementsInTree(t)}processTree(t,e){for(const n of this.matchElementsInTree(t))e.call(this,n)}elementFromNode(t){if(t.nodeType==Node.ELEMENT_NODE)return t}elementIsActive(t){return t.isConnected==this.element.isConnected&&this.element.contains(t)}addElement(t){this.elements.has(t)||this.elementIsActive(t)&&(this.elements.add(t),this.delegate.elementMatched&&this.delegate.elementMatched(t))}removeElement(t){this.elements.has(t)&&(this.elements.delete(t),this.delegate.elementUnmatched&&this.delegate.elementUnmatched(t))}}class f{constructor(t,e,n){this.attributeName=e,this.delegate=n,this.elementObserver=new p(t,this)}get element(){return this.elementObserver.element}get selector(){return`[${this.attributeName}]`}start(){this.elementObserver.start()}pause(t){this.elementObserver.pause(t)}stop(){this.elementObserver.stop()}refresh(){this.elementObserver.refresh()}get started(){return this.elementObserver.started}matchElement(t){return t.hasAttribute(this.attributeName)}matchElementsInTree(t){const e=this.matchElement(t)?[t]:[],n=Array.from(t.querySelectorAll(this.selector));return e.concat(n)}elementMatched(t){this.delegate.elementMatchedAttribute&&this.delegate.elementMatchedAttribute(t,this.attributeName)}elementUnmatched(t){this.delegate.elementUnmatchedAttribute&&this.delegate.elementUnmatchedAttribute(t,this.attributeName)}elementAttributeChanged(t,e){this.delegate.elementAttributeValueChanged&&this.attributeName==e&&this.delegate.elementAttributeValueChanged(t,e)}}function m(t,e){let n=t.get(e);return n||(n=new Set,t.set(e,n)),n}class g{constructor(){this.valuesByKey=new Map}get keys(){return Array.from(this.valuesByKey.keys())}get values(){return Array.from(this.valuesByKey.values()).reduce(((t,e)=>t.concat(Array.from(e))),[])}get size(){return Array.from(this.valuesByKey.values()).reduce(((t,e)=>t+e.size),0)}add(t,e){!function(t,e,n){m(t,e).add(n)}(this.valuesByKey,t,e)}delete(t,e){!function(t,e,n){m(t,e).delete(n),function(t,e){const n=t.get(e);null!=n&&0==n.size&&t.delete(e)}(t,e)}(this.valuesByKey,t,e)}has(t,e){const n=this.valuesByKey.get(t);return null!=n&&n.has(e)}hasKey(t){return this.valuesByKey.has(t)}hasValue(t){return Array.from(this.valuesByKey.values()).some((e=>e.has(t)))}getValuesForKey(t){const e=this.valuesByKey.get(t);return e?Array.from(e):[]}getKeysForValue(t){return Array.from(this.valuesByKey).filter((([e,n])=>n.has(t))).map((([t,e])=>t))}}class y{constructor(t,e,n,r={}){this.selector=e,this.details=r,this.elementObserver=new p(t,this),this.delegate=n,this.matchesByElement=new g}get started(){return this.elementObserver.started}start(){this.elementObserver.start()}pause(t){this.elementObserver.pause(t)}stop(){this.elementObserver.stop()}refresh(){this.elementObserver.refresh()}get element(){return this.elementObserver.element}matchElement(t){const e=t.matches(this.selector);return this.delegate.selectorMatchElement?e&&this.delegate.selectorMatchElement(t,this.details):e}matchElementsInTree(t){const e=this.matchElement(t)?[t]:[],n=Array.from(t.querySelectorAll(this.selector)).filter((t=>this.matchElement(t)));return e.concat(n)}elementMatched(t){this.selectorMatched(t)}elementUnmatched(t){this.selectorUnmatched(t)}elementAttributeChanged(t,e){const n=this.matchElement(t),r=this.matchesByElement.has(this.selector,t);!n&&r&&this.selectorUnmatched(t)}selectorMatched(t){this.delegate.selectorMatched&&(this.delegate.selectorMatched(t,this.selector,this.details),this.matchesByElement.add(this.selector,t))}selectorUnmatched(t){this.delegate.selectorUnmatched(t,this.selector,this.details),this.matchesByElement.delete(this.selector,t)}}class v{constructor(t,e){this.element=t,this.delegate=e,this.started=!1,this.stringMap=new Map,this.mutationObserver=new MutationObserver((t=>this.processMutations(t)))}start(){this.started||(this.started=!0,this.mutationObserver.observe(this.element,{attributes:!0,attributeOldValue:!0}),this.refresh())}stop(){this.started&&(this.mutationObserver.takeRecords(),this.mutationObserver.disconnect(),this.started=!1)}refresh(){if(this.started)for(const t of this.knownAttributeNames)this.refreshAttribute(t,null)}processMutations(t){if(this.started)for(const e of t)this.processMutation(e)}processMutation(t){const e=t.attributeName;e&&this.refreshAttribute(e,t.oldValue)}refreshAttribute(t,e){const n=this.delegate.getStringMapKeyForAttribute(t);if(null!=n){this.stringMap.has(t)||this.stringMapKeyAdded(n,t);const r=this.element.getAttribute(t);if(this.stringMap.get(t)!=r&&this.stringMapValueChanged(r,n,e),null==r){const e=this.stringMap.get(t);this.stringMap.delete(t),e&&this.stringMapKeyRemoved(n,t,e)}else this.stringMap.set(t,r)}}stringMapKeyAdded(t,e){this.delegate.stringMapKeyAdded&&this.delegate.stringMapKeyAdded(t,e)}stringMapValueChanged(t,e,n){this.delegate.stringMapValueChanged&&this.delegate.stringMapValueChanged(t,e,n)}stringMapKeyRemoved(t,e,n){this.delegate.stringMapKeyRemoved&&this.delegate.stringMapKeyRemoved(t,e,n)}get knownAttributeNames(){return Array.from(new Set(this.currentAttributeNames.concat(this.recordedAttributeNames)))}get currentAttributeNames(){return Array.from(this.element.attributes).map((t=>t.name))}get recordedAttributeNames(){return Array.from(this.stringMap.keys())}}class b{constructor(t,e,n){this.attributeObserver=new f(t,e,this),this.delegate=n,this.tokensByElement=new g}get started(){return this.attributeObserver.started}start(){this.attributeObserver.start()}pause(t){this.attributeObserver.pause(t)}stop(){this.attributeObserver.stop()}refresh(){this.attributeObserver.refresh()}get element(){return this.attributeObserver.element}get attributeName(){return this.attributeObserver.attributeName}elementMatchedAttribute(t){this.tokensMatched(this.readTokensForElement(t))}elementAttributeValueChanged(t){const[e,n]=this.refreshTokensForElement(t);this.tokensUnmatched(e),this.tokensMatched(n)}elementUnmatchedAttribute(t){this.tokensUnmatched(this.tokensByElement.getValuesForKey(t))}tokensMatched(t){t.forEach((t=>this.tokenMatched(t)))}tokensUnmatched(t){t.forEach((t=>this.tokenUnmatched(t)))}tokenMatched(t){this.delegate.tokenMatched(t),this.tokensByElement.add(t.element,t)}tokenUnmatched(t){this.delegate.tokenUnmatched(t),this.tokensByElement.delete(t.element,t)}refreshTokensForElement(t){const e=this.tokensByElement.getValuesForKey(t),n=this.readTokensForElement(t),r=function(t,e){const n=Math.max(t.length,e.length);return Array.from({length:n},((n,r)=>[t[r],e[r]]))}(e,n).findIndex((([t,e])=>!function(t,e){return t&&e&&t.index==e.index&&t.content==e.content}(t,e)));return-1==r?[[],[]]:[e.slice(r),n.slice(r)]}readTokensForElement(t){const e=this.attributeName;return function(t,e,n){return t.trim().split(/\s+/).filter((t=>t.length)).map(((t,r)=>({element:e,attributeName:n,content:t,index:r})))}(t.getAttribute(e)||"",t,e)}}class w{constructor(t,e,n){this.tokenListObserver=new b(t,e,this),this.delegate=n,this.parseResultsByToken=new WeakMap,this.valuesByTokenByElement=new WeakMap}get started(){return this.tokenListObserver.started}start(){this.tokenListObserver.start()}stop(){this.tokenListObserver.stop()}refresh(){this.tokenListObserver.refresh()}get element(){return this.tokenListObserver.element}get attributeName(){return this.tokenListObserver.attributeName}tokenMatched(t){const{element:e}=t,{value:n}=this.fetchParseResultForToken(t);n&&(this.fetchValuesByTokenForElement(e).set(t,n),this.delegate.elementMatchedValue(e,n))}tokenUnmatched(t){const{element:e}=t,{value:n}=this.fetchParseResultForToken(t);n&&(this.fetchValuesByTokenForElement(e).delete(t),this.delegate.elementUnmatchedValue(e,n))}fetchParseResultForToken(t){let e=this.parseResultsByToken.get(t);return e||(e=this.parseToken(t),this.parseResultsByToken.set(t,e)),e}fetchValuesByTokenForElement(t){let e=this.valuesByTokenByElement.get(t);return e||(e=new Map,this.valuesByTokenByElement.set(t,e)),e}parseToken(t){try{return{value:this.delegate.parseValueForToken(t)}}catch(t){return{error:t}}}}class x{constructor(t,e){this.context=t,this.delegate=e,this.bindingsByAction=new Map}start(){this.valueListObserver||(this.valueListObserver=new w(this.element,this.actionAttribute,this),this.valueListObserver.start())}stop(){this.valueListObserver&&(this.valueListObserver.stop(),delete this.valueListObserver,this.disconnectAllActions())}get element(){return this.context.element}get identifier(){return this.context.identifier}get actionAttribute(){return this.schema.actionAttribute}get schema(){return this.context.schema}get bindings(){return Array.from(this.bindingsByAction.values())}connectAction(t){const e=new u(this.context,t);this.bindingsByAction.set(t,e),this.delegate.bindingConnected(e)}disconnectAction(t){const e=this.bindingsByAction.get(t);e&&(this.bindingsByAction.delete(t),this.delegate.bindingDisconnected(e))}disconnectAllActions(){this.bindings.forEach((t=>this.delegate.bindingDisconnected(t,!0))),this.bindingsByAction.clear()}parseValueForToken(t){const e=class{constructor(t,e,n,r){this.element=t,this.index=e,this.eventTarget=n.eventTarget||t,this.eventName=n.eventName||function(t){const e=t.tagName.toLowerCase();if(e in c)return c[e](t)}(t)||h("missing event name"),this.eventOptions=n.eventOptions||{},this.identifier=n.identifier||h("missing identifier"),this.methodName=n.methodName||h("missing method name"),this.keyFilter=n.keyFilter||"",this.schema=r}static forToken(t,e){return new this(t.element,t.index,function(t){const e=t.trim().match(r)||[];let n=e[1],s=e[2];return s&&!["keydown","keyup","keypress"].includes(n)&&(n+=`.${s}`,s=""),{eventTarget:i(e[3]),eventName:n,eventOptions:e[6]?(o=e[6],o.split(":").reduce(((t,e)=>Object.assign(t,{[e.replace(/^!/,"")]:!/^!/.test(e)})),{})):{},identifier:e[4],methodName:e[5],keyFilter:s};var o}(t.content),e)}toString(){const t=this.keyFilter?`.${this.keyFilter}`:"",e=this.eventTargetName?`@${this.eventTargetName}`:"";return`${this.eventName}${t}${e}->${this.identifier}#${this.methodName}`}isFilterTarget(t){if(!this.keyFilter)return!1;const e=this.keyFilter.split("+"),n=["meta","ctrl","alt","shift"],[r,i,s,o]=n.map((t=>e.includes(t)));if(t.metaKey!==r||t.ctrlKey!==i||t.altKey!==s||t.shiftKey!==o)return!0;const a=e.filter((t=>!n.includes(t)))[0];return!!a&&(Object.prototype.hasOwnProperty.call(this.keyMappings,a)||h(`contains unknown key filter: ${this.keyFilter}`),this.keyMappings[a].toLowerCase()!==t.key.toLowerCase())}get params(){const t={},e=new RegExp(`^data-${this.identifier}-(.+)-param$`,"i");for(const{name:n,value:r}of Array.from(this.element.attributes)){const i=n.match(e),o=i&&i[1];o&&(t[s(o)]=d(r))}return t}get eventTargetName(){return(t=this.eventTarget)==window?"window":t==document?"document":void 0;var t}get keyMappings(){return this.schema.keyMappings}}.forToken(t,this.schema);if(e.identifier==this.identifier)return e}elementMatchedValue(t,e){this.connectAction(e)}elementUnmatchedValue(t,e){this.disconnectAction(e)}}class k{constructor(t,e){this.context=t,this.receiver=e,this.stringMapObserver=new v(this.element,this),this.valueDescriptorMap=this.controller.valueDescriptorMap}start(){this.stringMapObserver.start(),this.invokeChangedCallbacksForDefaultValues()}stop(){this.stringMapObserver.stop()}get element(){return this.context.element}get controller(){return this.context.controller}getStringMapKeyForAttribute(t){if(t in this.valueDescriptorMap)return this.valueDescriptorMap[t].name}stringMapKeyAdded(t,e){const n=this.valueDescriptorMap[e];this.hasValue(t)||this.invokeChangedCallback(t,n.writer(this.receiver[t]),n.writer(n.defaultValue))}stringMapValueChanged(t,e,n){const r=this.valueDescriptorNameMap[e];null!==t&&(null===n&&(n=r.writer(r.defaultValue)),this.invokeChangedCallback(e,t,n))}stringMapKeyRemoved(t,e,n){const r=this.valueDescriptorNameMap[t];this.hasValue(t)?this.invokeChangedCallback(t,r.writer(this.receiver[t]),n):this.invokeChangedCallback(t,r.writer(r.defaultValue),n)}invokeChangedCallbacksForDefaultValues(){for(const{key:t,name:e,defaultValue:n,writer:r}of this.valueDescriptors)null==n||this.controller.data.has(t)||this.invokeChangedCallback(e,r(n),void 0)}invokeChangedCallback(t,e,n){const r=`${t}Changed`,i=this.receiver[r];if("function"==typeof i){const r=this.valueDescriptorNameMap[t];try{const t=r.reader(e);let s=n;n&&(s=r.reader(n)),i.call(this.receiver,t,s)}catch(t){throw t instanceof TypeError&&(t.message=`Stimulus Value "${this.context.identifier}.${r.name}" - ${t.message}`),t}}}get valueDescriptors(){const{valueDescriptorMap:t}=this;return Object.keys(t).map((e=>t[e]))}get valueDescriptorNameMap(){const t={};return Object.keys(this.valueDescriptorMap).forEach((e=>{const n=this.valueDescriptorMap[e];t[n.name]=n})),t}hasValue(t){const e=`has${a(this.valueDescriptorNameMap[t].name)}`;return this.receiver[e]}}class S{constructor(t,e){this.context=t,this.delegate=e,this.targetsByName=new g}start(){this.tokenListObserver||(this.tokenListObserver=new b(this.element,this.attributeName,this),this.tokenListObserver.start())}stop(){this.tokenListObserver&&(this.disconnectAllTargets(),this.tokenListObserver.stop(),delete this.tokenListObserver)}tokenMatched({element:t,content:e}){this.scope.containsElement(t)&&this.connectTarget(t,e)}tokenUnmatched({element:t,content:e}){this.disconnectTarget(t,e)}connectTarget(t,e){var n;this.targetsByName.has(e,t)||(this.targetsByName.add(e,t),null===(n=this.tokenListObserver)||void 0===n||n.pause((()=>this.delegate.targetConnected(t,e))))}disconnectTarget(t,e){var n;this.targetsByName.has(e,t)&&(this.targetsByName.delete(e,t),null===(n=this.tokenListObserver)||void 0===n||n.pause((()=>this.delegate.targetDisconnected(t,e))))}disconnectAllTargets(){for(const t of this.targetsByName.keys)for(const e of this.targetsByName.getValuesForKey(t))this.disconnectTarget(e,t)}get attributeName(){return`data-${this.context.identifier}-target`}get element(){return this.context.element}get scope(){return this.context.scope}}function M(t,e){const n=A(t);return Array.from(n.reduce(((t,n)=>(function(t,e){const n=t[e];return Array.isArray(n)?n:[]}(n,e).forEach((e=>t.add(e))),t)),new Set))}function O(t,e){return A(t).reduce(((t,n)=>(t.push(...function(t,e){const n=t[e];return n?Object.keys(n).map((t=>[t,n[t]])):[]}(n,e)),t)),[])}function A(t){const e=[];for(;t;)e.push(t),t=Object.getPrototypeOf(t);return e.reverse()}class E{constructor(t,e){this.context=t,this.delegate=e,this.outletsByName=new g,this.outletElementsByName=new g,this.selectorObserverMap=new Map}start(){0===this.selectorObserverMap.size&&(this.outletDefinitions.forEach((t=>{const e=this.selector(t),n={outletName:t};e&&this.selectorObserverMap.set(t,new y(document.body,e,this,n))})),this.selectorObserverMap.forEach((t=>t.start()))),this.dependentContexts.forEach((t=>t.refresh()))}stop(){this.selectorObserverMap.size>0&&(this.disconnectAllOutlets(),this.selectorObserverMap.forEach((t=>t.stop())),this.selectorObserverMap.clear())}refresh(){this.selectorObserverMap.forEach((t=>t.refresh()))}selectorMatched(t,e,{outletName:n}){const r=this.getOutlet(t,n);r&&this.connectOutlet(r,t,n)}selectorUnmatched(t,e,{outletName:n}){const r=this.getOutletFromMap(t,n);r&&this.disconnectOutlet(r,t,n)}selectorMatchElement(t,{outletName:e}){return this.hasOutlet(t,e)&&t.matches(`[${this.context.application.schema.controllerAttribute}~=${e}]`)}connectOutlet(t,e,n){var r;this.outletElementsByName.has(n,e)||(this.outletsByName.add(n,t),this.outletElementsByName.add(n,e),null===(r=this.selectorObserverMap.get(n))||void 0===r||r.pause((()=>this.delegate.outletConnected(t,e,n))))}disconnectOutlet(t,e,n){var r;this.outletElementsByName.has(n,e)&&(this.outletsByName.delete(n,t),this.outletElementsByName.delete(n,e),null===(r=this.selectorObserverMap.get(n))||void 0===r||r.pause((()=>this.delegate.outletDisconnected(t,e,n))))}disconnectAllOutlets(){for(const t of this.outletElementsByName.keys)for(const e of this.outletElementsByName.getValuesForKey(t))for(const n of this.outletsByName.getValuesForKey(t))this.disconnectOutlet(n,e,t)}selector(t){return this.scope.outlets.getSelectorForOutletName(t)}get outletDependencies(){const t=new g;return this.router.modules.forEach((e=>{M(e.definition.controllerConstructor,"outlets").forEach((n=>t.add(n,e.identifier)))})),t}get outletDefinitions(){return this.outletDependencies.getKeysForValue(this.identifier)}get dependentControllerIdentifiers(){return this.outletDependencies.getValuesForKey(this.identifier)}get dependentContexts(){const t=this.dependentControllerIdentifiers;return this.router.contexts.filter((e=>t.includes(e.identifier)))}hasOutlet(t,e){return!!this.getOutlet(t,e)||!!this.getOutletFromMap(t,e)}getOutlet(t,e){return this.application.getControllerForElementAndIdentifier(t,e)}getOutletFromMap(t,e){return this.outletsByName.getValuesForKey(e).find((e=>e.element===t))}get scope(){return this.context.scope}get identifier(){return this.context.identifier}get application(){return this.context.application}get router(){return this.application.router}}class C{constructor(t,e){this.logDebugActivity=(t,e={})=>{const{identifier:n,controller:r,element:i}=this;e=Object.assign({identifier:n,controller:r,element:i},e),this.application.logDebugActivity(this.identifier,t,e)},this.module=t,this.scope=e,this.controller=new t.controllerConstructor(this),this.bindingObserver=new x(this,this.dispatcher),this.valueObserver=new k(this,this.controller),this.targetObserver=new S(this,this),this.outletObserver=new E(this,this);try{this.controller.initialize(),this.logDebugActivity("initialize")}catch(t){this.handleError(t,"initializing controller")}}connect(){this.bindingObserver.start(),this.valueObserver.start(),this.targetObserver.start(),this.outletObserver.start();try{this.controller.connect(),this.logDebugActivity("connect")}catch(t){this.handleError(t,"connecting controller")}}refresh(){this.outletObserver.refresh()}disconnect(){try{this.controller.disconnect(),this.logDebugActivity("disconnect")}catch(t){this.handleError(t,"disconnecting controller")}this.outletObserver.stop(),this.targetObserver.stop(),this.valueObserver.stop(),this.bindingObserver.stop()}get application(){return this.module.application}get identifier(){return this.module.identifier}get schema(){return this.application.schema}get dispatcher(){return this.application.dispatcher}get element(){return this.scope.element}get parentElement(){return this.element.parentElement}handleError(t,e,n={}){const{identifier:r,controller:i,element:s}=this;n=Object.assign({identifier:r,controller:i,element:s},n),this.application.handleError(t,`Error ${e}`,n)}targetConnected(t,e){this.invokeControllerMethod(`${e}TargetConnected`,t)}targetDisconnected(t,e){this.invokeControllerMethod(`${e}TargetDisconnected`,t)}outletConnected(t,e,n){this.invokeControllerMethod(`${o(n)}OutletConnected`,t,e)}outletDisconnected(t,e,n){this.invokeControllerMethod(`${o(n)}OutletDisconnected`,t,e)}invokeControllerMethod(t,...e){const n=this.controller;"function"==typeof n[t]&&n[t](...e)}}function T(t){return function(t,e){const n=D(t),r=function(t,e){return N(e).reduce(((n,r)=>{const i=function(t,e,n){const r=Object.getOwnPropertyDescriptor(t,n);if(!r||!("value"in r)){const t=Object.getOwnPropertyDescriptor(e,n).value;return r&&(t.get=r.get||t.get,t.set=r.set||t.set),t}}(t,e,r);return i&&Object.assign(n,{[r]:i}),n}),{})}(t.prototype,e);return Object.defineProperties(n.prototype,r),n}(t,function(t){return M(t,"blessings").reduce(((e,n)=>{const r=n(t);for(const t in r){const n=e[t]||{};e[t]=Object.assign(n,r[t])}return e}),{})}(t))}const N="function"==typeof Object.getOwnPropertySymbols?t=>[...Object.getOwnPropertyNames(t),...Object.getOwnPropertySymbols(t)]:Object.getOwnPropertyNames,D=(()=>{function t(t){function e(){return Reflect.construct(t,arguments,new.target)}return e.prototype=Object.create(t.prototype,{constructor:{value:e}}),Reflect.setPrototypeOf(e,t),e}try{return function(){const e=t((function(){this.a.call(this)}));e.prototype.a=function(){},new e}(),t}catch(t){return t=>class extends t{}}})();class ${constructor(t,e){this.application=t,this.definition=function(t){return{identifier:t.identifier,controllerConstructor:T(t.controllerConstructor)}}(e),this.contextsByScope=new WeakMap,this.connectedContexts=new Set}get identifier(){return this.definition.identifier}get controllerConstructor(){return this.definition.controllerConstructor}get contexts(){return Array.from(this.connectedContexts)}connectContextForScope(t){const e=this.fetchContextForScope(t);this.connectedContexts.add(e),e.connect()}disconnectContextForScope(t){const e=this.contextsByScope.get(t);e&&(this.connectedContexts.delete(e),e.disconnect())}fetchContextForScope(t){let e=this.contextsByScope.get(t);return e||(e=new C(this,t),this.contextsByScope.set(t,e)),e}}class I{constructor(t){this.scope=t}has(t){return this.data.has(this.getDataKey(t))}get(t){return this.getAll(t)[0]}getAll(t){const e=this.data.get(this.getDataKey(t))||"";return e.match(/[^\s]+/g)||[]}getAttributeName(t){return this.data.getAttributeNameForKey(this.getDataKey(t))}getDataKey(t){return`${t}-class`}get data(){return this.scope.data}}class R{constructor(t){this.scope=t}get element(){return this.scope.element}get identifier(){return this.scope.identifier}get(t){const e=this.getAttributeNameForKey(t);return this.element.getAttribute(e)}set(t,e){const n=this.getAttributeNameForKey(t);return this.element.setAttribute(n,e),this.get(t)}has(t){const e=this.getAttributeNameForKey(t);return this.element.hasAttribute(e)}delete(t){if(this.has(t)){const e=this.getAttributeNameForKey(t);return this.element.removeAttribute(e),!0}return!1}getAttributeNameForKey(t){return`data-${this.identifier}-${l(t)}`}}class B{constructor(t){this.warnedKeysByObject=new WeakMap,this.logger=t}warn(t,e,n){let r=this.warnedKeysByObject.get(t);r||(r=new Set,this.warnedKeysByObject.set(t,r)),r.has(e)||(r.add(e),this.logger.warn(n,t))}}function F(t,e){return`[${t}~="${e}"]`}class P{constructor(t){this.scope=t}get element(){return this.scope.element}get identifier(){return this.scope.identifier}get schema(){return this.scope.schema}has(t){return null!=this.find(t)}find(...t){return t.reduce(((t,e)=>t||this.findTarget(e)||this.findLegacyTarget(e)),void 0)}findAll(...t){return t.reduce(((t,e)=>[...t,...this.findAllTargets(e),...this.findAllLegacyTargets(e)]),[])}findTarget(t){const e=this.getSelectorForTargetName(t);return this.scope.findElement(e)}findAllTargets(t){const e=this.getSelectorForTargetName(t);return this.scope.findAllElements(e)}getSelectorForTargetName(t){return F(this.schema.targetAttributeForScope(this.identifier),t)}findLegacyTarget(t){const e=this.getLegacySelectorForTargetName(t);return this.deprecate(this.scope.findElement(e),t)}findAllLegacyTargets(t){const e=this.getLegacySelectorForTargetName(t);return this.scope.findAllElements(e).map((e=>this.deprecate(e,t)))}getLegacySelectorForTargetName(t){const e=`${this.identifier}.${t}`;return F(this.schema.targetAttribute,e)}deprecate(t,e){if(t){const{identifier:n}=this,r=this.schema.targetAttribute,i=this.schema.targetAttributeForScope(n);this.guide.warn(t,`target:${e}`,`Please replace ${r}="${n}.${e}" with ${i}="${e}". The ${r} attribute is deprecated and will be removed in a future version of Stimulus.`)}return t}get guide(){return this.scope.guide}}class V{constructor(t,e){this.scope=t,this.controllerElement=e}get element(){return this.scope.element}get identifier(){return this.scope.identifier}get schema(){return this.scope.schema}has(t){return null!=this.find(t)}find(...t){return t.reduce(((t,e)=>t||this.findOutlet(e)),void 0)}findAll(...t){return t.reduce(((t,e)=>[...t,...this.findAllOutlets(e)]),[])}getSelectorForOutletName(t){const e=this.schema.outletAttributeForScope(this.identifier,t);return this.controllerElement.getAttribute(e)}findOutlet(t){const e=this.getSelectorForOutletName(t);if(e)return this.findElement(e,t)}findAllOutlets(t){const e=this.getSelectorForOutletName(t);return e?this.findAllElements(e,t):[]}findElement(t,e){return this.scope.queryElements(t).filter((n=>this.matchesElement(n,t,e)))[0]}findAllElements(t,e){return this.scope.queryElements(t).filter((n=>this.matchesElement(n,t,e)))}matchesElement(t,e,n){const r=t.getAttribute(this.scope.schema.controllerAttribute)||"";return t.matches(e)&&r.split(" ").includes(n)}}class L{constructor(t,e,n,r){this.targets=new P(this),this.classes=new I(this),this.data=new R(this),this.containsElement=t=>t.closest(this.controllerSelector)===this.element,this.schema=t,this.element=e,this.identifier=n,this.guide=new B(r),this.outlets=new V(this.documentScope,e)}findElement(t){return this.element.matches(t)?this.element:this.queryElements(t).find(this.containsElement)}findAllElements(t){return[...this.element.matches(t)?[this.element]:[],...this.queryElements(t).filter(this.containsElement)]}queryElements(t){return Array.from(this.element.querySelectorAll(t))}get controllerSelector(){return F(this.schema.controllerAttribute,this.identifier)}get isDocumentScope(){return this.element===document.documentElement}get documentScope(){return this.isDocumentScope?this:new L(this.schema,document.documentElement,this.identifier,this.guide.logger)}}class z{constructor(t,e,n){this.element=t,this.schema=e,this.delegate=n,this.valueListObserver=new w(this.element,this.controllerAttribute,this),this.scopesByIdentifierByElement=new WeakMap,this.scopeReferenceCounts=new WeakMap}start(){this.valueListObserver.start()}stop(){this.valueListObserver.stop()}get controllerAttribute(){return this.schema.controllerAttribute}parseValueForToken(t){const{element:e,content:n}=t,r=this.fetchScopesByIdentifierForElement(e);let i=r.get(n);return i||(i=this.delegate.createScopeForElementAndIdentifier(e,n),r.set(n,i)),i}elementMatchedValue(t,e){const n=(this.scopeReferenceCounts.get(e)||0)+1;this.scopeReferenceCounts.set(e,n),1==n&&this.delegate.scopeConnected(e)}elementUnmatchedValue(t,e){const n=this.scopeReferenceCounts.get(e);n&&(this.scopeReferenceCounts.set(e,n-1),1==n&&this.delegate.scopeDisconnected(e))}fetchScopesByIdentifierForElement(t){let e=this.scopesByIdentifierByElement.get(t);return e||(e=new Map,this.scopesByIdentifierByElement.set(t,e)),e}}class j{constructor(t){this.application=t,this.scopeObserver=new z(this.element,this.schema,this),this.scopesByIdentifier=new g,this.modulesByIdentifier=new Map}get element(){return this.application.element}get schema(){return this.application.schema}get logger(){return this.application.logger}get controllerAttribute(){return this.schema.controllerAttribute}get modules(){return Array.from(this.modulesByIdentifier.values())}get contexts(){return this.modules.reduce(((t,e)=>t.concat(e.contexts)),[])}start(){this.scopeObserver.start()}stop(){this.scopeObserver.stop()}loadDefinition(t){this.unloadIdentifier(t.identifier);const e=new $(this.application,t);this.connectModule(e);const n=t.controllerConstructor.afterLoad;n&&n(t.identifier,this.application)}unloadIdentifier(t){const e=this.modulesByIdentifier.get(t);e&&this.disconnectModule(e)}getContextForElementAndIdentifier(t,e){const n=this.modulesByIdentifier.get(e);if(n)return n.contexts.find((e=>e.element==t))}handleError(t,e,n){this.application.handleError(t,e,n)}createScopeForElementAndIdentifier(t,e){return new L(this.schema,t,e,this.logger)}scopeConnected(t){this.scopesByIdentifier.add(t.identifier,t);const e=this.modulesByIdentifier.get(t.identifier);e&&e.connectContextForScope(t)}scopeDisconnected(t){this.scopesByIdentifier.delete(t.identifier,t);const e=this.modulesByIdentifier.get(t.identifier);e&&e.disconnectContextForScope(t)}connectModule(t){this.modulesByIdentifier.set(t.identifier,t);this.scopesByIdentifier.getValuesForKey(t.identifier).forEach((e=>t.connectContextForScope(e)))}disconnectModule(t){this.modulesByIdentifier.delete(t.identifier);this.scopesByIdentifier.getValuesForKey(t.identifier).forEach((e=>t.disconnectContextForScope(e)))}}const _={controllerAttribute:"data-controller",actionAttribute:"data-action",targetAttribute:"data-target",targetAttributeForScope:t=>`data-${t}-target`,outletAttributeForScope:(t,e)=>`data-${t}-${e}-outlet`,keyMappings:Object.assign(Object.assign({enter:"Enter",tab:"Tab",esc:"Escape",space:" ",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight",home:"Home",end:"End"},K("abcdefghijklmnopqrstuvwxyz".split("").map((t=>[t,t])))),K("0123456789".split("").map((t=>[t,t]))))};function K(t){return t.reduce(((t,[e,n])=>Object.assign(Object.assign({},t),{[e]:n})),{})}function W([t,e],n){return function(t){const e=`${l(t.token)}-value`,n=function(t){const e=function(t){const e=H(t.typeObject.type);if(!e)return;const n=q(t.typeObject.default);if(e!==n){const r=t.controller?`${t.controller}.${t.token}`:t.token;throw new Error(`The specified default value for the Stimulus Value "${r}" must match the defined type "${e}". The provided default value of "${t.typeObject.default}" is of type "${n}".`)}return e}({controller:t.controller,token:t.token,typeObject:t.typeDefinition}),n=q(t.typeDefinition),r=H(t.typeDefinition),i=e||n||r;if(i)return i;const s=t.controller?`${t.controller}.${t.typeDefinition}`:t.token;throw new Error(`Unknown value type "${s}" for "${t.token}" value`)}(t);return{type:n,key:e,name:s(e),get defaultValue(){return function(t){const e=H(t);if(e)return J[e];const n=t.default;return void 0!==n?n:t}(t.typeDefinition)},get hasCustomDefaultValue(){return void 0!==q(t.typeDefinition)},reader:U[n],writer:G[n]||G.default}}({controller:n,token:t,typeDefinition:e})}function H(t){switch(t){case Array:return"array";case Boolean:return"boolean";case Number:return"number";case Object:return"object";case String:return"string"}}function q(t){switch(typeof t){case"boolean":return"boolean";case"number":return"number";case"string":return"string"}return Array.isArray(t)?"array":"[object Object]"===Object.prototype.toString.call(t)?"object":void 0}const J={get array(){return[]},boolean:!1,number:0,get object(){return{}},string:""},U={array(t){const e=JSON.parse(t);if(!Array.isArray(e))throw new TypeError(`expected value of type "array" but instead got value "${t}" of type "${q(e)}"`);return e},boolean:t=>!("0"==t||"false"==String(t).toLowerCase()),number:t=>Number(t),object(t){const e=JSON.parse(t);if(null===e||"object"!=typeof e||Array.isArray(e))throw new TypeError(`expected value of type "object" but instead got value "${t}" of type "${q(e)}"`);return e},string:t=>t},G={default:function(t){return`${t}`},array:Y,object:Y};function Y(t){return JSON.stringify(t)}class X{constructor(t){this.context=t}static get shouldLoad(){return!0}static afterLoad(t,e){}get application(){return this.context.application}get scope(){return this.context.scope}get element(){return this.scope.element}get identifier(){return this.scope.identifier}get targets(){return this.scope.targets}get outlets(){return this.scope.outlets}get classes(){return this.scope.classes}get data(){return this.scope.data}initialize(){}connect(){}disconnect(){}dispatch(t,{target:e=this.element,detail:n={},prefix:r=this.identifier,bubbles:i=!0,cancelable:s=!0}={}){const o=new CustomEvent(r?`${r}:${t}`:t,{detail:n,bubbles:i,cancelable:s});return e.dispatchEvent(o),o}}
2
2
  /**
3
3
  * @license
4
4
  * Copyright 2017 Google LLC
5
5
  * SPDX-License-Identifier: BSD-3-Clause
6
6
  */
7
- var Z;X.blessings=[function(e){return M(e,"classes").reduce(((e,t)=>{return Object.assign(e,{[`${n=t}Class`]:{get(){const{classes:e}=this;if(e.has(n))return e.get(n);{const t=e.getAttributeName(n);throw new Error(`Missing attribute "${t}"`)}}},[`${n}Classes`]:{get(){return this.classes.getAll(n)}},[`has${a(n)}Class`]:{get(){return this.classes.has(n)}}});var n}),{})},function(e){return M(e,"targets").reduce(((e,t)=>{return Object.assign(e,{[`${n=t}Target`]:{get(){const e=this.targets.find(n);if(e)return e;throw new Error(`Missing target element "${n}" for "${this.identifier}" controller`)}},[`${n}Targets`]:{get(){return this.targets.findAll(n)}},[`has${a(n)}Target`]:{get(){return this.targets.has(n)}}});var n}),{})},function(e){const t=O(e,"values"),n={valueDescriptorMap:{get(){return t.reduce(((e,t)=>{const n=W(t,this.identifier),r=this.data.getAttributeNameForKey(n.key);return Object.assign(e,{[r]:n})}),{})}}};return t.reduce(((e,t)=>Object.assign(e,function(e,t){const n=W(e,t),{key:r,name:i,reader:s,writer:o}=n;return{[i]:{get(){const e=this.data.get(r);return null!==e?s(e):n.defaultValue},set(e){void 0===e?this.data.delete(r):this.data.set(r,o(e))}},[`has${a(i)}`]:{get(){return this.data.has(r)||n.hasCustomDefaultValue}}}}(t))),n)},function(e){return M(e,"outlets").reduce(((e,t)=>Object.assign(e,function(e){const t=o(e);return{[`${t}Outlet`]:{get(){const t=this.outlets.find(e);if(t){const n=this.application.getControllerForElementAndIdentifier(t,e);if(n)return n;throw new Error(`Missing "data-controller=${e}" attribute on outlet element for "${this.identifier}" controller`)}throw new Error(`Missing outlet element "${e}" for "${this.identifier}" controller`)}},[`${t}Outlets`]:{get(){const t=this.outlets.findAll(e);return t.length>0?t.map((t=>{const n=this.application.getControllerForElementAndIdentifier(t,e);if(n)return n;console.warn(`The provided outlet element is missing the outlet controller "${e}" for "${this.identifier}"`,t)})).filter((e=>e)):[]}},[`${t}OutletElement`]:{get(){const t=this.outlets.find(e);if(t)return t;throw new Error(`Missing outlet element "${e}" for "${this.identifier}" controller`)}},[`${t}OutletElements`]:{get(){return this.outlets.findAll(e)}},[`has${a(t)}Outlet`]:{get(){return this.outlets.has(e)}}}}(t))),{})}],X.targets=[],X.outlets=[],X.values={};const Q=window,ee=Q.trustedTypes,te=ee?ee.createPolicy("lit-html",{createHTML:e=>e}):void 0,ne="$lit$",re=`lit$${(Math.random()+"").slice(9)}$`,ie="?"+re,se=`<${ie}>`,oe=document,ae=()=>oe.createComment(""),le=e=>null===e||"object"!=typeof e&&"function"!=typeof e,ce=Array.isArray,he="[ \t\n\f\r]",de=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,ue=/-->/g,pe=/>/g,fe=RegExp(`>|${he}(?:([^\\s"'>=/]+)(${he}*=${he}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),me=/'/g,ge=/"/g,ye=/^(?:script|style|textarea|title)$/i,ve=(e=>(t,...n)=>({_$litType$:e,strings:t,values:n}))(1),be=Symbol.for("lit-noChange"),we=Symbol.for("lit-nothing"),xe=new WeakMap,ke=oe.createTreeWalker(oe,129,null,!1),Se=(e,t)=>{const n=e.length-1,r=[];let i,s=2===t?"<svg>":"",o=de;for(let t=0;t<n;t++){const n=e[t];let a,l,c=-1,h=0;for(;h<n.length&&(o.lastIndex=h,l=o.exec(n),null!==l);)h=o.lastIndex,o===de?"!--"===l[1]?o=ue:void 0!==l[1]?o=pe:void 0!==l[2]?(ye.test(l[2])&&(i=RegExp("</"+l[2],"g")),o=fe):void 0!==l[3]&&(o=fe):o===fe?">"===l[0]?(o=null!=i?i:de,c=-1):void 0===l[1]?c=-2:(c=o.lastIndex-l[2].length,a=l[1],o=void 0===l[3]?fe:'"'===l[3]?ge:me):o===ge||o===me?o=fe:o===ue||o===pe?o=de:(o=fe,i=void 0);const d=o===fe&&e[t+1].startsWith("/>")?" ":"";s+=o===de?n+se:c>=0?(r.push(a),n.slice(0,c)+ne+n.slice(c)+re+d):n+re+(-2===c?(r.push(void 0),t):d)}const a=s+(e[n]||"<?>")+(2===t?"</svg>":"");if(!Array.isArray(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return[void 0!==te?te.createHTML(a):a,r]};class Me{constructor({strings:e,_$litType$:t},n){let r;this.parts=[];let i=0,s=0;const o=e.length-1,a=this.parts,[l,c]=Se(e,t);if(this.el=Me.createElement(l,n),ke.currentNode=this.el.content,2===t){const e=this.el.content,t=e.firstChild;t.remove(),e.append(...t.childNodes)}for(;null!==(r=ke.nextNode())&&a.length<o;){if(1===r.nodeType){if(r.hasAttributes()){const e=[];for(const t of r.getAttributeNames())if(t.endsWith(ne)||t.startsWith(re)){const n=c[s++];if(e.push(t),void 0!==n){const e=r.getAttribute(n.toLowerCase()+ne).split(re),t=/([.?@])?(.*)/.exec(n);a.push({type:1,index:i,name:t[2],strings:e,ctor:"."===t[1]?Te:"?"===t[1]?De:"@"===t[1]?$e:Ee})}else a.push({type:6,index:i})}for(const t of e)r.removeAttribute(t)}if(ye.test(r.tagName)){const e=r.textContent.split(re),t=e.length-1;if(t>0){r.textContent=ee?ee.emptyScript:"";for(let n=0;n<t;n++)r.append(e[n],ae()),ke.nextNode(),a.push({type:2,index:++i});r.append(e[t],ae())}}}else if(8===r.nodeType)if(r.data===ie)a.push({type:2,index:i});else{let e=-1;for(;-1!==(e=r.data.indexOf(re,e+1));)a.push({type:7,index:i}),e+=re.length-1}i++}}static createElement(e,t){const n=oe.createElement("template");return n.innerHTML=e,n}}function Oe(e,t,n=e,r){var i,s,o,a;if(t===be)return t;let l=void 0!==r?null===(i=n._$Co)||void 0===i?void 0:i[r]:n._$Cl;const c=le(t)?void 0:t._$litDirective$;return(null==l?void 0:l.constructor)!==c&&(null===(s=null==l?void 0:l._$AO)||void 0===s||s.call(l,!1),void 0===c?l=void 0:(l=new c(e),l._$AT(e,n,r)),void 0!==r?(null!==(o=(a=n)._$Co)&&void 0!==o?o:a._$Co=[])[r]=l:n._$Cl=l),void 0!==l&&(t=Oe(e,l._$AS(e,t.values),l,r)),t}class Ae{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){var t;const{el:{content:n},parts:r}=this._$AD,i=(null!==(t=null==e?void 0:e.creationScope)&&void 0!==t?t:oe).importNode(n,!0);ke.currentNode=i;let s=ke.nextNode(),o=0,a=0,l=r[0];for(;void 0!==l;){if(o===l.index){let t;2===l.type?t=new Ce(s,s.nextSibling,this,e):1===l.type?t=new l.ctor(s,l.name,l.strings,this,e):6===l.type&&(t=new Ie(s,this,e)),this._$AV.push(t),l=r[++a]}o!==(null==l?void 0:l.index)&&(s=ke.nextNode(),o++)}return i}v(e){let t=0;for(const n of this._$AV)void 0!==n&&(void 0!==n.strings?(n._$AI(e,n,t),t+=n.strings.length-2):n._$AI(e[t])),t++}}class Ce{constructor(e,t,n,r){var i;this.type=2,this._$AH=we,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=n,this.options=r,this._$Cp=null===(i=null==r?void 0:r.isConnected)||void 0===i||i}get _$AU(){var e,t;return null!==(t=null===(e=this._$AM)||void 0===e?void 0:e._$AU)&&void 0!==t?t:this._$Cp}get parentNode(){let e=this._$AA.parentNode;const t=this._$AM;return void 0!==t&&11===(null==e?void 0:e.nodeType)&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=Oe(this,e,t),le(e)?e===we||null==e||""===e?(this._$AH!==we&&this._$AR(),this._$AH=we):e!==this._$AH&&e!==be&&this._(e):void 0!==e._$litType$?this.g(e):void 0!==e.nodeType?this.$(e):(e=>ce(e)||"function"==typeof(null==e?void 0:e[Symbol.iterator]))(e)?this.T(e):this._(e)}k(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}$(e){this._$AH!==e&&(this._$AR(),this._$AH=this.k(e))}_(e){this._$AH!==we&&le(this._$AH)?this._$AA.nextSibling.data=e:this.$(oe.createTextNode(e)),this._$AH=e}g(e){var t;const{values:n,_$litType$:r}=e,i="number"==typeof r?this._$AC(e):(void 0===r.el&&(r.el=Me.createElement(r.h,this.options)),r);if((null===(t=this._$AH)||void 0===t?void 0:t._$AD)===i)this._$AH.v(n);else{const e=new Ae(i,this),t=e.u(this.options);e.v(n),this.$(t),this._$AH=e}}_$AC(e){let t=xe.get(e.strings);return void 0===t&&xe.set(e.strings,t=new Me(e)),t}T(e){ce(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let n,r=0;for(const i of e)r===t.length?t.push(n=new Ce(this.k(ae()),this.k(ae()),this,this.options)):n=t[r],n._$AI(i),r++;r<t.length&&(this._$AR(n&&n._$AB.nextSibling,r),t.length=r)}_$AR(e=this._$AA.nextSibling,t){var n;for(null===(n=this._$AP)||void 0===n||n.call(this,!1,!0,t);e&&e!==this._$AB;){const t=e.nextSibling;e.remove(),e=t}}setConnected(e){var t;void 0===this._$AM&&(this._$Cp=e,null===(t=this._$AP)||void 0===t||t.call(this,e))}}class Ee{constructor(e,t,n,r,i){this.type=1,this._$AH=we,this._$AN=void 0,this.element=e,this.name=t,this._$AM=r,this.options=i,n.length>2||""!==n[0]||""!==n[1]?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=we}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(e,t=this,n,r){const i=this.strings;let s=!1;if(void 0===i)e=Oe(this,e,t,0),s=!le(e)||e!==this._$AH&&e!==be,s&&(this._$AH=e);else{const r=e;let o,a;for(e=i[0],o=0;o<i.length-1;o++)a=Oe(this,r[n+o],t,o),a===be&&(a=this._$AH[o]),s||(s=!le(a)||a!==this._$AH[o]),a===we?e=we:e!==we&&(e+=(null!=a?a:"")+i[o+1]),this._$AH[o]=a}s&&!r&&this.j(e)}j(e){e===we?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=e?e:"")}}class Te extends Ee{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===we?void 0:e}}const Ne=ee?ee.emptyScript:"";class De extends Ee{constructor(){super(...arguments),this.type=4}j(e){e&&e!==we?this.element.setAttribute(this.name,Ne):this.element.removeAttribute(this.name)}}class $e extends Ee{constructor(e,t,n,r,i){super(e,t,n,r,i),this.type=5}_$AI(e,t=this){var n;if((e=null!==(n=Oe(this,e,t,0))&&void 0!==n?n:we)===be)return;const r=this._$AH,i=e===we&&r!==we||e.capture!==r.capture||e.once!==r.once||e.passive!==r.passive,s=e!==we&&(r===we||i);i&&this.element.removeEventListener(this.name,this,r),s&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var t,n;"function"==typeof this._$AH?this._$AH.call(null!==(n=null===(t=this.options)||void 0===t?void 0:t.host)&&void 0!==n?n:this.element,e):this._$AH.handleEvent(e)}}class Ie{constructor(e,t,n){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=n}get _$AU(){return this._$AM._$AU}_$AI(e){Oe(this,e)}}const Re=Q.litHtmlPolyfillSupport;null==Re||Re(Me,Ce),(null!==(Z=Q.litHtmlVersions)&&void 0!==Z?Z:Q.litHtmlVersions=[]).push("2.7.3");class Be extends X{constructor(){super(...arguments),this.onBlur=e=>{this.validateField(e.target)},this.onSubmit=e=>{var t;this.validateForm()||(e.preventDefault(),null===(t=this.firstInvalidField)||void 0===t||t.focus())},this.getRenderString=e=>{const{strings:t,values:n}=e,r=[...n,""].map((e=>"object"==typeof e?this.getRenderString(e):e));return t.reduce(((e,t,n)=>e+t+r[n]),"")}}connect(){this.element.setAttribute("novalidate","true"),this.element.addEventListener("blur",this.onBlur,!0),this.element.addEventListener("submit",this.onSubmit),this.element.addEventListener("ajax:beforeSend",this.onSubmit)}disconnect(){this.element.removeEventListener("blur",this.onBlur),this.element.removeEventListener("submit",this.onSubmit),this.element.removeEventListener("ajax:beforeSend",this.onSubmit)}validateForm(){let e=!0;for(const t of this.formFields)this.shouldValidateField(t)&&!this.validateField(t)&&(e=!1);return e}validateField(e){if(!this.shouldValidateField(e))return!0;const t=e.checkValidity();return e.classList.toggle("invalid",!t),this.refreshErrorForInvalidField(e,t),t}shouldValidateField(e){return!e.disabled&&!e.classList.contains("ProseMirror")&&!["file","reset","submit","button"].includes(e.type)}refreshErrorForInvalidField(e,t){this.removeExistingErrorMessage(e),t||this.showErrorForInvalidField(e)}removeExistingErrorMessage(e){var t;const n=e.closest(".field");if(!n)return;const r=n.querySelector(".error");r&&(null===(t=null==r?void 0:r.parentNode)||void 0===t||t.removeChild(r))}showErrorForInvalidField(e){e.insertAdjacentHTML("afterend",this.buildFieldErrorHtml(e))}buildFieldErrorHtml(e){const t=ve`<p class="error">${e.validationMessage}</p>`;return this.getRenderString(t)}get formFields(){return Array.from(this.formFieldTargets)}get firstInvalidField(){return this.formFields.find((e=>!e.checkValidity()))}}Be.targets=["formField"];function Fe(e){this.content=e}function Pe(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(r),s=t.child(r);if(i!=s){if(!i.sameMarkup(s))return n;if(i.isText&&i.text!=s.text){for(let e=0;i.text[e]==s.text[e];e++)n++;return n}if(i.content.size||s.content.size){let e=Pe(i.content,s.content,n+1);if(null!=e)return e}n+=i.nodeSize}else n+=i.nodeSize}}function Le(e,t,n,r){for(let i=e.childCount,s=t.childCount;;){if(0==i||0==s)return i==s?null:{a:n,b:r};let o=e.child(--i),a=t.child(--s),l=o.nodeSize;if(o!=a){if(!o.sameMarkup(a))return{a:n,b:r};if(o.isText&&o.text!=a.text){let e=0,t=Math.min(o.text.length,a.text.length);for(;e<t&&o.text[o.text.length-e-1]==a.text[a.text.length-e-1];)e++,n--,r--;return{a:n,b:r}}if(o.content.size||a.content.size){let e=Le(o.content,a.content,n-1,r-1);if(e)return e}n-=l,r-=l}else n-=l,r-=l}}Fe.prototype={constructor:Fe,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return-1==t?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,i=r.find(e),s=r.content.slice();return-1==i?s.push(n||e,t):(s[i+1]=t,n&&(s[i]=n)),new Fe(s)},remove:function(e){var t=this.find(e);if(-1==t)return this;var n=this.content.slice();return n.splice(t,2),new Fe(n)},addToStart:function(e,t){return new Fe([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new Fe(n)},addBefore:function(e,t,n){var r=this.remove(t),i=r.content.slice(),s=r.find(e);return i.splice(-1==s?i.length:s,0,t,n),new Fe(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return(e=Fe.from(e)).size?new Fe(e.content.concat(this.subtract(e).content)):this},append:function(e){return(e=Fe.from(e)).size?new Fe(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=Fe.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},get size(){return this.content.length>>1}},Fe.from=function(e){if(e instanceof Fe)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new Fe(t)};class Ve{constructor(e,t){if(this.content=e,this.size=t||0,null==t)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,i){for(let s=0,o=0;o<t;s++){let a=this.content[s],l=o+a.nodeSize;if(l>e&&!1!==n(a,r+o,i||null,s)&&a.content.size){let i=o+1;a.nodesBetween(Math.max(0,e-i),Math.min(a.content.size,t-i),n,r+i)}o=l}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i="",s=!0;return this.nodesBetween(e,t,((o,a)=>{o.isText?(i+=o.text.slice(Math.max(e,a)-a,t-a),s=!n):o.isLeaf?(r?i+="function"==typeof r?r(o):r:o.type.spec.leafText&&(i+=o.type.spec.leafText(o)),s=!n):!s&&o.isBlock&&(i+=n,s=!0)}),0),i}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,n=e.firstChild,r=this.content.slice(),i=0;for(t.isText&&t.sameMarkup(n)&&(r[r.length-1]=t.withText(t.text+n.text),i=1);i<e.content.length;i++)r.push(e.content[i]);return new Ve(r,this.size+e.size)}cut(e,t=this.size){if(0==e&&t==this.size)return this;let n=[],r=0;if(t>e)for(let i=0,s=0;s<t;i++){let o=this.content[i],a=s+o.nodeSize;a>e&&((s<e||a>t)&&(o=o.isText?o.cut(Math.max(0,e-s),Math.min(o.text.length,t-s)):o.cut(Math.max(0,e-s-1),Math.min(o.content.size,t-s-1))),n.push(o),r+=o.nodeSize),s=a}return new Ve(n,r)}cutByIndex(e,t){return e==t?Ve.empty:0==e&&t==this.content.length?this:new Ve(this.content.slice(e,t))}replaceChild(e,t){let n=this.content[e];if(n==t)return this;let r=this.content.slice(),i=this.size+t.nodeSize-n.nodeSize;return r[e]=t,new Ve(r,i)}addToStart(e){return new Ve([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new Ve(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return Pe(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return Le(this,e,t,n)}findIndex(e,t=-1){if(0==e)return je(0,e);if(e==this.size)return je(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let i=r+this.child(n).nodeSize;if(i>=e)return i==e||t>0?je(n+1,i):je(n,r);r=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map((e=>e.toJSON())):null}static fromJSON(e,t){if(!t)return Ve.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new Ve(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return Ve.empty;let t,n=0;for(let r=0;r<e.length;r++){let i=e[r];n+=i.nodeSize,r&&i.isText&&e[r-1].sameMarkup(i)?(t||(t=e.slice(0,r)),t[t.length-1]=i.withText(t[t.length-1].text+i.text)):t&&t.push(i)}return new Ve(t||e,n)}static from(e){if(!e)return Ve.empty;if(e instanceof Ve)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new Ve([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}Ve.empty=new Ve([],0);const ze={index:0,offset:0};function je(e,t){return ze.index=e,ze.offset=t,ze}function _e(e,t){if(e===t)return!0;if(!e||"object"!=typeof e||!t||"object"!=typeof t)return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!_e(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!_e(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}class Ke{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(this.eq(i))return e;if(this.type.excludes(i.type))t||(t=e.slice(0,r));else{if(i.type.excludes(this.type))return e;!n&&i.type.rank>this.type.rank&&(t||(t=e.slice(0,r)),t.push(this),n=!0),t&&t.push(i)}}return t||(t=e.slice()),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&_e(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let n=e.marks[t.type];if(!n)throw new RangeError(`There is no mark type ${t.type} in this schema`);return n.create(t.attrs)}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&0==e.length)return Ke.none;if(e instanceof Ke)return[e];let t=e.slice();return t.sort(((e,t)=>e.type.rank-t.type.rank)),t}}Ke.none=[];class We extends Error{}class He{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let n=Je(this.content,e+this.openStart,t);return n&&new He(n,this.openStart,this.openEnd)}removeBetween(e,t){return new He(qe(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return He.empty;let n=t.openStart||0,r=t.openEnd||0;if("number"!=typeof n||"number"!=typeof r)throw new RangeError("Invalid input for Slice.fromJSON");return new He(Ve.fromJSON(e,t.content),n,r)}static maxOpen(e,t=!0){let n=0,r=0;for(let r=e.firstChild;r&&!r.isLeaf&&(t||!r.type.spec.isolating);r=r.firstChild)n++;for(let n=e.lastChild;n&&!n.isLeaf&&(t||!n.type.spec.isolating);n=n.lastChild)r++;return new He(e,n,r)}}function qe(e,t,n){let{index:r,offset:i}=e.findIndex(t),s=e.maybeChild(r),{index:o,offset:a}=e.findIndex(n);if(i==t||s.isText){if(a!=n&&!e.child(o).isText)throw new RangeError("Removing non-flat range");return e.cut(0,t).append(e.cut(n))}if(r!=o)throw new RangeError("Removing non-flat range");return e.replaceChild(r,s.copy(qe(s.content,t-i-1,n-i-1)))}function Je(e,t,n,r){let{index:i,offset:s}=e.findIndex(t),o=e.maybeChild(i);if(s==t||o.isText)return r&&!r.canReplace(i,i,n)?null:e.cut(0,t).append(n).append(e.cut(t));let a=Je(o.content,t-s-1,n);return a&&e.replaceChild(i,o.copy(a))}function Ue(e,t,n){if(n.openStart>e.depth)throw new We("Inserted content deeper than insertion position");if(e.depth-n.openStart!=t.depth-n.openEnd)throw new We("Inconsistent open depths");return Ge(e,t,n,0)}function Ge(e,t,n,r){let i=e.index(r),s=e.node(r);if(i==t.index(r)&&r<e.depth-n.openStart){let o=Ge(e,t,n,r+1);return s.copy(s.content.replaceChild(i,o))}if(n.content.size){if(n.openStart||n.openEnd||e.depth!=r||t.depth!=r){let{start:i,end:o}=function(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(Ve.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}(n,e);return et(s,tt(e,i,o,t,r))}{let r=e.parent,i=r.content;return et(r,i.cut(0,e.parentOffset).append(n.content).append(i.cut(t.parentOffset)))}}return et(s,nt(e,t,r))}function Ye(e,t){if(!t.type.compatibleContent(e.type))throw new We("Cannot join "+t.type.name+" onto "+e.type.name)}function Xe(e,t,n){let r=e.node(n);return Ye(r,t.node(n)),r}function Ze(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function Qe(e,t,n,r){let i=(t||e).node(n),s=0,o=t?t.index(n):i.childCount;e&&(s=e.index(n),e.depth>n?s++:e.textOffset&&(Ze(e.nodeAfter,r),s++));for(let e=s;e<o;e++)Ze(i.child(e),r);t&&t.depth==n&&t.textOffset&&Ze(t.nodeBefore,r)}function et(e,t){return e.type.checkContent(t),e.copy(t)}function tt(e,t,n,r,i){let s=e.depth>i&&Xe(e,t,i+1),o=r.depth>i&&Xe(n,r,i+1),a=[];return Qe(null,e,i,a),s&&o&&t.index(i)==n.index(i)?(Ye(s,o),Ze(et(s,tt(e,t,n,r,i+1)),a)):(s&&Ze(et(s,nt(e,t,i+1)),a),Qe(t,n,i,a),o&&Ze(et(o,nt(n,r,i+1)),a)),Qe(r,null,i,a),new Ve(a)}function nt(e,t,n){let r=[];if(Qe(null,e,n,r),e.depth>n){Ze(et(Xe(e,t,n+1),nt(e,t,n+1)),r)}return Qe(t,null,n,r),new Ve(r)}He.empty=new He(Ve.empty,0,0);class rt{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return null==e?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[3*this.resolveDepth(e)]}index(e){return this.path[3*this.resolveDepth(e)+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e!=this.depth||this.textOffset?1:0)}start(e){return 0==(e=this.resolveDepth(e))?0:this.path[3*e-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]}after(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]+this.path[3*e].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):0==e?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[3*t],r=0==t?0:this.path[3*t-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(0==e.content.size)return Ke.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let i=n.marks;for(var s=0;s<i.length;s++)!1!==i[s].type.spec.inclusive||r&&i[s].isInSet(r.marks)||(i=i[s--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var i=0;i<n.length;i++)!1!==n[i].type.spec.inclusive||r&&n[i].isInSet(r.marks)||(n=n[i--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new at(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let n=[],r=0,i=t;for(let t=e;;){let{index:e,offset:s}=t.content.findIndex(i),o=i-s;if(n.push(t,e,r+s),!o)break;if(t=t.child(e),t.isText)break;i=o-1,r+=s+1}return new rt(t,n,i)}static resolveCached(e,t){for(let n=0;n<it.length;n++){let r=it[n];if(r.pos==t&&r.doc==e)return r}let n=it[st]=rt.resolve(e,t);return st=(st+1)%ot,n}}let it=[],st=0,ot=12;class at{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const lt=Object.create(null);class ct{constructor(e,t,n,r=Ke.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||Ve.empty}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&_e(this.attrs,t||e.defaultAttrs||lt)&&Ke.sameSet(this.marks,n||Ke.none)}copy(e=null){return e==this.content?this:new ct(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new ct(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return 0==e&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return He.empty;let r=this.resolve(e),i=this.resolve(t),s=n?0:r.sharedDepth(t),o=r.start(s),a=r.node(s).content.cut(r.pos-o,i.pos-o);return new He(a,r.depth-s,i.depth-s)}replace(e,t,n){return Ue(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(0==e)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return rt.resolveCached(this,e)}resolveNoCache(e){return rt.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,(e=>(n.isInSet(e.marks)&&(r=!0),!r))),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),dt(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,n=Ve.empty,r=0,i=n.childCount){let s=this.contentMatchAt(e).matchFragment(n,r,i),o=s&&s.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let e=r;e<i;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(e).matchType(n),s=i&&i.matchFragment(this.content,t);return!!s&&s.validEnd}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content);let e=Ke.none;for(let t=0;t<this.marks.length;t++)e=this.marks[t].addToSet(e);if(!Ke.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map((e=>e.type.name))}`);this.content.forEach((e=>e.check()))}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map((e=>e.toJSON()))),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let n=null;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=t.marks.map(e.markFromJSON)}if("text"==t.type){if("string"!=typeof t.text)throw new RangeError("Invalid text node in JSON");return e.text(t.text,n)}let r=Ve.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,r,n)}}ct.prototype.text=void 0;class ht extends ct{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):dt(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new ht(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new ht(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return 0==e&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function dt(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+"("+t+")";return t}class ut{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let n=new pt(e,t);if(null==n.next)return ut.empty;let r=ft(n);n.next&&n.err("Unexpected trailing text");let i=function(e){let t=Object.create(null);return n(wt(e,0));function n(r){let i=[];r.forEach((t=>{e[t].forEach((({term:t,to:n})=>{if(!t)return;let r;for(let e=0;e<i.length;e++)i[e][0]==t&&(r=i[e][1]);wt(e,n).forEach((e=>{r||i.push([t,r=[]]),-1==r.indexOf(e)&&r.push(e)}))}))}));let s=t[r.join(",")]=new ut(r.indexOf(e.length-1)>-1);for(let e=0;e<i.length;e++){let r=i[e][1].sort(bt);s.next.push({type:i[e][0],next:t[r.join(",")]||n(r)})}return s}}(function(e){let t=[[]];return i(s(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let i={term:r,to:n};return t[e].push(i),i}function i(e,t){e.forEach((e=>e.to=t))}function s(e,t){if("choice"==e.type)return e.exprs.reduce(((e,n)=>e.concat(s(n,t))),[]);if("seq"!=e.type){if("star"==e.type){let o=n();return r(t,o),i(s(e.expr,o),o),[r(o)]}if("plus"==e.type){let o=n();return i(s(e.expr,t),o),i(s(e.expr,o),o),[r(o)]}if("opt"==e.type)return[r(t)].concat(s(e.expr,t));if("range"==e.type){let o=t;for(let t=0;t<e.min;t++){let t=n();i(s(e.expr,o),t),o=t}if(-1==e.max)i(s(e.expr,o),o);else for(let t=e.min;t<e.max;t++){let t=n();r(o,t),i(s(e.expr,o),t),o=t}return[r(o)]}if("name"==e.type)return[r(t,void 0,e.value)];throw new Error("Unknown expr type")}for(let r=0;;r++){let o=s(e.exprs[r],t);if(r==e.exprs.length-1)return o;i(o,t=n())}}}(r));return function(e,t){for(let n=0,r=[e];n<r.length;n++){let e=r[n],i=!e.validEnd,s=[];for(let t=0;t<e.next.length;t++){let{type:n,next:o}=e.next[t];s.push(n.name),!i||n.isText||n.hasRequiredAttrs()||(i=!1),-1==r.indexOf(o)&&r.push(o)}i&&t.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(i,n),i}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let i=t;r&&i<n;i++)r=r.matchType(e.child(i).type);return r}get inlineContent(){return 0!=this.next.length&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!t.isText&&!t.hasRequiredAttrs())return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];return function i(s,o){let a=s.matchFragment(e,n);if(a&&(!t||a.validEnd))return Ve.from(o.map((e=>e.createAndFill())));for(let e=0;e<s.next.length;e++){let{type:t,next:n}=s.next[e];if(!t.isText&&!t.hasRequiredAttrs()&&-1==r.indexOf(n)){r.push(n);let e=i(n,o.concat(t));if(e)return e}}return null}(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),i=r.match;if(i.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<i.next.length;e++){let{type:s,next:o}=i.next[e];s.isLeaf||s.hasRequiredAttrs()||s.name in t||r.type&&!o.validEnd||(n.push({match:s.contentMatch,type:s,via:r}),t[s.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];return function t(n){e.push(n);for(let r=0;r<n.next.length;r++)-1==e.indexOf(n.next[r].next)&&t(n.next[r].next)}(this),e.map(((t,n)=>{let r=n+(t.validEnd?"*":" ")+" ";for(let n=0;n<t.next.length;n++)r+=(n?", ":"")+t.next[n].type.name+"->"+e.indexOf(t.next[n].next);return r})).join("\n")}}ut.empty=new ut(!0);class pt{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),""==this.tokens[this.tokens.length-1]&&this.tokens.pop(),""==this.tokens[0]&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function ft(e){let t=[];do{t.push(mt(e))}while(e.eat("|"));return 1==t.length?t[0]:{type:"choice",exprs:t}}function mt(e){let t=[];do{t.push(gt(e))}while(e.next&&")"!=e.next&&"|"!=e.next);return 1==t.length?t[0]:{type:"seq",exprs:t}}function gt(e){let t=function(e){if(e.eat("(")){let t=ft(e);return e.eat(")")||e.err("Missing closing paren"),t}if(!/\W/.test(e.next)){let t=function(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let i=[];for(let e in n){let r=n[e];r.groups.indexOf(t)>-1&&i.push(r)}0==i.length&&e.err("No node type or group '"+t+"' found");return i}(e,e.next).map((t=>(null==e.inline?e.inline=t.isInline:e.inline!=t.isInline&&e.err("Mixing inline and block content"),{type:"name",value:t})));return e.pos++,1==t.length?t[0]:{type:"choice",exprs:t}}e.err("Unexpected token '"+e.next+"'")}(e);for(;;)if(e.eat("+"))t={type:"plus",expr:t};else if(e.eat("*"))t={type:"star",expr:t};else if(e.eat("?"))t={type:"opt",expr:t};else{if(!e.eat("{"))break;t=vt(e,t)}return t}function yt(e){/\D/.test(e.next)&&e.err("Expected number, got '"+e.next+"'");let t=Number(e.next);return e.pos++,t}function vt(e,t){let n=yt(e),r=n;return e.eat(",")&&(r="}"!=e.next?yt(e):-1),e.eat("}")||e.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:t}}function bt(e,t){return t-e}function wt(e,t){let n=[];return function t(r){let i=e[r];if(1==i.length&&!i[0].term)return t(i[0].to);n.push(r);for(let e=0;e<i.length;e++){let{term:r,to:s}=i[e];r||-1!=n.indexOf(s)||t(s)}}(t),n.sort(bt)}function xt(e){let t=Object.create(null);for(let n in e){let r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function kt(e,t){let n=Object.create(null);for(let r in e){let i=t&&t[r];if(void 0===i){let t=e[r];if(!t.hasDefault)throw new RangeError("No value supplied for attribute "+r);i=t.default}n[r]=i}return n}function St(e){let t=Object.create(null);if(e)for(let n in e)t[n]=new Ot(e[n]);return t}class Mt{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(" "):[],this.attrs=St(n.attrs),this.defaultAttrs=xt(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||"text"==e),this.isText="text"==e}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==ut.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:kt(this.attrs,e)}create(e=null,t,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new ct(this,this.computeAttrs(e),Ve.from(t),Ke.setFrom(n))}createChecked(e=null,t,n){return t=Ve.from(t),this.checkContent(t),new ct(this,this.computeAttrs(e),t,Ke.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),(t=Ve.from(t)).size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let r=this.contentMatch.matchFragment(t),i=r&&r.fillBefore(Ve.empty,!0);return i?new ct(this,e,t.append(i),Ke.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t<e.childCount;t++)if(!this.allowsMarks(e.child(t).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}allowsMarkType(e){return null==this.markSet||this.markSet.indexOf(e)>-1}allowsMarks(e){if(null==this.markSet)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(null==this.markSet)return e;let t;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||(t=e.slice(0,n));return t?t.length?t:Ke.none:e}static compile(e,t){let n=Object.create(null);e.forEach(((e,r)=>n[e]=new Mt(e,t,r)));let r=t.spec.topNode||"doc";if(!n[r])throw new RangeError("Schema is missing its top node type ('"+r+"')");if(!n.text)throw new RangeError("Every schema needs a 'text' type");for(let e in n.text.attrs)throw new RangeError("The text node type should not have attributes");return n}}class Ot{constructor(e){this.hasDefault=Object.prototype.hasOwnProperty.call(e,"default"),this.default=e.default}get isRequired(){return!this.hasDefault}}class At{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=St(r.attrs),this.excluded=null;let i=xt(this.attrs);this.instance=i?new Ke(this,i):null}create(e=null){return!e&&this.instance?this.instance:new Ke(this,kt(this.attrs,e))}static compile(e,t){let n=Object.create(null),r=0;return e.forEach(((e,i)=>n[e]=new At(e,r++,t,i))),n}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}excludes(e){return this.excluded.indexOf(e)>-1}}class Ct{constructor(e){this.cached=Object.create(null);let t=this.spec={};for(let n in e)t[n]=e[n];t.nodes=Fe.from(e.nodes),t.marks=Fe.from(e.marks||{}),this.nodes=Mt.compile(this.spec.nodes,this),this.marks=At.compile(this.spec.marks,this);let n=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw new RangeError(e+" can not be both a node and a mark");let t=this.nodes[e],r=t.spec.content||"",i=t.spec.marks;t.contentMatch=n[r]||(n[r]=ut.parse(r,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.markSet="_"==i?null:i?Et(this,i.split(" ")):""!=i&&t.inlineContent?null:[]}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=null==n?[t]:""==n?[]:Et(this,n.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,n,r){if("string"==typeof e)e=this.nodeType(e);else{if(!(e instanceof Mt))throw new RangeError("Invalid node type: "+e);if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}return e.createChecked(t,n,r)}text(e,t){let n=this.nodes.text;return new ht(n,n.defaultAttrs,e,Ke.setFrom(t))}mark(e,t){return"string"==typeof e&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return ct.fromJSON(this,e)}markFromJSON(e){return Ke.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function Et(e,t){let n=[];for(let r=0;r<t.length;r++){let i=t[r],s=e.marks[i],o=s;if(s)n.push(s);else for(let t in e.marks){let r=e.marks[t];("_"==i||r.spec.group&&r.spec.group.split(" ").indexOf(i)>-1)&&n.push(o=r)}if(!o)throw new SyntaxError("Unknown mark type: '"+t[r]+"'")}return n}class Tt{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[],t.forEach((e=>{e.tag?this.tags.push(e):e.style&&this.styles.push(e)})),this.normalizeLists=!this.tags.some((t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)}))}parse(e,t={}){let n=new Bt(this,t,!1);return n.addAll(e,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new Bt(this,t,!0);return n.addAll(e,t.from,t.to),He.maxOpen(n.finish())}matchTag(e,t,n){for(let r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){let n=this.tags[r];if(Ft(e,n.tag)&&(void 0===n.namespace||e.namespaceURI==n.namespace)&&(!n.context||t.matchesContext(n.context))){if(n.getAttrs){let t=n.getAttrs(e);if(!1===t)continue;n.attrs=t||void 0}return n}}}matchStyle(e,t,n,r){for(let i=r?this.styles.indexOf(r)+1:0;i<this.styles.length;i++){let r=this.styles[i],s=r.style;if(!(0!=s.indexOf(e)||r.context&&!n.matchesContext(r.context)||s.length>e.length&&(61!=s.charCodeAt(e.length)||s.slice(e.length+1)!=t))){if(r.getAttrs){let e=r.getAttrs(t);if(!1===e)continue;r.attrs=e||void 0}return r}}}static schemaRules(e){let t=[];function n(e){let n=null==e.priority?50:e.priority,r=0;for(;r<t.length;r++){let e=t[r];if((null==e.priority?50:e.priority)<n)break}t.splice(r,0,e)}for(let t in e.marks){let r=e.marks[t].spec.parseDOM;r&&r.forEach((e=>{n(e=Pt(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)}))}for(let t in e.nodes){let r=e.nodes[t].spec.parseDOM;r&&r.forEach((e=>{n(e=Pt(e)),e.node||e.ignore||e.mark||(e.node=t)}))}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Tt(e,Tt.schemaRules(e)))}}const Nt={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},Dt={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},$t={ol:!0,ul:!0};function It(e,t,n){return null!=t?(t?1:0)|("full"===t?2:0):e&&"pre"==e.whitespace?3:-5&n}class Rt{constructor(e,t,n,r,i,s,o){this.type=e,this.attrs=t,this.marks=n,this.pendingMarks=r,this.solid=i,this.options=o,this.content=[],this.activeMarks=Ke.none,this.stashMarks=[],this.match=s||(4&o?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(Ve.from(e));if(!t){let t,n=this.type.contentMatch;return(t=n.findWrapping(e.type))?(this.match=n,t):null}this.match=this.type.contentMatch.matchFragment(t)}return this.match.findWrapping(e.type)}finish(e){if(!(1&this.options)){let e,t=this.content[this.content.length-1];if(t&&t.isText&&(e=/[ \t\r\n\u000c]+$/.exec(t.text))){let n=t;t.text.length==e[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-e[0].length))}}let t=Ve.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(Ve.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}popFromStashMark(e){for(let t=this.stashMarks.length-1;t>=0;t--)if(e.eq(this.stashMarks[t]))return this.stashMarks.splice(t,1)[0]}applyPending(e){for(let t=0,n=this.pendingMarks;t<n.length;t++){let r=n[t];(this.type?this.type.allowsMarkType(r.type):Lt(r.type,e))&&!r.isInSet(this.activeMarks)&&(this.activeMarks=r.addToSet(this.activeMarks),this.pendingMarks=r.removeFromSet(this.pendingMarks))}}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Nt.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Bt{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0;let r,i=t.topNode,s=It(null,t.preserveWhitespace,0)|(n?4:0);r=i?new Rt(i.type,i.attrs,Ke.none,Ke.none,!0,t.topMatch||i.type.contentMatch,s):new Rt(n?null:e.schema.topNodeType,null,Ke.none,Ke.none,!0,null,s),this.nodes=[r],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e){if(3==e.nodeType)this.addTextNode(e);else if(1==e.nodeType){let t=e.getAttribute("style");if(t){let n=this.readStyles(function(e){let t,n=/\s*([\w-]+)\s*:\s*([^;]+)/g,r=[];for(;t=n.exec(e);)r.push(t[1],t[2].trim());return r}(t));if(!n)return;let[r,i]=n,s=this.top;for(let e=0;e<i.length;e++)this.removePendingMark(i[e],s);for(let e=0;e<r.length;e++)this.addPendingMark(r[e]);this.addElement(e);for(let e=0;e<r.length;e++)this.removePendingMark(r[e],s);for(let e=0;e<i.length;e++)this.addPendingMark(i[e])}else this.addElement(e)}}addTextNode(e){let t=e.nodeValue,n=this.top;if(2&n.options||n.inlineContext(e)||/[^ \t\r\n\u000c]/.test(t)){if(1&n.options)t=2&n.options?t.replace(/\r\n?/g,"\n"):t.replace(/\r?\n|\r/g," ");else if(t=t.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(t)&&this.open==this.nodes.length-1){let r=n.content[n.content.length-1],i=e.previousSibling;(!r||i&&"BR"==i.nodeName||r.isText&&/[ \t\r\n\u000c]$/.test(r.text))&&(t=t.slice(1))}t&&this.insertNode(this.parser.schema.text(t)),this.findInText(e)}else this.findInside(e)}addElement(e,t){let n,r=e.nodeName.toLowerCase();$t.hasOwnProperty(r)&&this.parser.normalizeLists&&function(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=1==t.nodeType?t.nodeName.toLowerCase():null;e&&$t.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):"li"==e?n=t:e&&(n=null)}}(e);let i=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(n=this.parser.matchTag(e,this,t));if(i?i.ignore:Dt.hasOwnProperty(r))this.findInside(e),this.ignoreFallback(e);else if(!i||i.skip||i.closeParent){i&&i.closeParent?this.open=Math.max(0,this.open-1):i&&i.skip.nodeType&&(e=i.skip);let t,n=this.top,s=this.needsBlock;if(Nt.hasOwnProperty(r))n.content.length&&n.content[0].isInline&&this.open&&(this.open--,n=this.top),t=!0,n.type||(this.needsBlock=!0);else if(!e.firstChild)return void this.leafFallback(e);this.addAll(e),t&&this.sync(n),this.needsBlock=s}else this.addElementByRule(e,i,!1===i.consuming?n:void 0)}leafFallback(e){"BR"==e.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode("\n"))}ignoreFallback(e){"BR"!=e.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"))}readStyles(e){let t=Ke.none,n=Ke.none;e:for(let r=0;r<e.length;r+=2)for(let i;;){let s=this.parser.matchStyle(e[r],e[r+1],this,i);if(!s)continue e;if(s.ignore)return null;if(s.clearMark?this.top.pendingMarks.forEach((e=>{s.clearMark(e)&&(n=e.addToSet(n))})):t=this.parser.schema.marks[s.mark].create(s.attrs).addToSet(t),!1!==s.consuming)break;i=s}return[t,n]}addElementByRule(e,t,n){let r,i,s;if(t.node)i=this.parser.schema.nodes[t.node],i.isLeaf?this.insertNode(i.create(t.attrs))||this.leafFallback(e):r=this.enter(i,t.attrs||null,t.preserveWhitespace);else{s=this.parser.schema.marks[t.mark].create(t.attrs),this.addPendingMark(s)}let o=this.top;if(i&&i.isLeaf)this.findInside(e);else if(n)this.addElement(e,n);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach((e=>this.insertNode(e)));else{let n=e;"string"==typeof t.contentElement?n=e.querySelector(t.contentElement):"function"==typeof t.contentElement?n=t.contentElement(e):t.contentElement&&(n=t.contentElement),this.findAround(e,n,!0),this.addAll(n)}r&&this.sync(o)&&this.open--,s&&this.removePendingMark(s,o)}addAll(e,t,n){let r=t||0;for(let i=t?e.childNodes[t]:e.firstChild,s=null==n?null:e.childNodes[n];i!=s;i=i.nextSibling,++r)this.findAtPoint(e,r),this.addDOM(i);this.findAtPoint(e,r)}findPlace(e){let t,n;for(let r=this.open;r>=0;r--){let i=this.nodes[r],s=i.findWrapping(e);if(s&&(!t||t.length>s.length)&&(t=s,n=i,!s.length))break;if(i.solid)break}if(!t)return!1;this.sync(n);for(let e=0;e<t.length;e++)this.enterInner(t[e],null,!1);return!0}insertNode(e){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&this.enterInner(e)}if(this.findPlace(e)){this.closeExtra();let t=this.top;t.applyPending(e.type),t.match&&(t.match=t.match.matchType(e.type));let n=t.activeMarks;for(let r=0;r<e.marks.length;r++)t.type&&!t.type.allowsMarkType(e.marks[r].type)||(n=e.marks[r].addToSet(n));return t.content.push(e.mark(n)),!0}return!1}enter(e,t,n){let r=this.findPlace(e.create(t));return r&&this.enterInner(e,t,!0,n),r}enterInner(e,t=null,n=!1,r){this.closeExtra();let i=this.top;i.applyPending(e),i.match=i.match&&i.match.matchType(e);let s=It(e,r,i.options);4&i.options&&0==i.content.length&&(s|=4),this.nodes.push(new Rt(e,t,i.activeMarks,i.pendingMarks,n,null,s)),this.open++}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(this.isOpen||this.options.topOpen)}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)null==this.find[t].pos&&1==e.nodeType&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let r=0;r<this.find.length;r++)if(null==this.find[r].pos&&1==e.nodeType&&e.contains(this.find[r].node)){t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),n=this.options.context,r=!(this.isOpen||n&&n.parent.type!=this.nodes[0].type),i=-(n?n.depth+1:0)+(r?0:1),s=(e,o)=>{for(;e>=0;e--){let a=t[e];if(""==a){if(e==t.length-1||0==e)continue;for(;o>=i;o--)if(s(e-1,o))return!0;return!1}{let e=o>0||0==o&&r?this.nodes[o].type:n&&o>=i?n.node(o-i).type:null;if(!e||e.name!=a&&-1==e.groups.indexOf(a))return!1;o--}}return!0};return s(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}addPendingMark(e){let t=function(e,t){for(let n=0;n<t.length;n++)if(e.eq(t[n]))return t[n]}(e,this.top.pendingMarks);t&&this.top.stashMarks.push(t),this.top.pendingMarks=e.addToSet(this.top.pendingMarks)}removePendingMark(e,t){for(let n=this.open;n>=0;n--){let r=this.nodes[n];if(r.pendingMarks.lastIndexOf(e)>-1)r.pendingMarks=e.removeFromSet(r.pendingMarks);else{r.activeMarks=e.removeFromSet(r.activeMarks);let t=r.popFromStashMark(e);t&&r.type&&r.type.allowsMarkType(t.type)&&(r.activeMarks=t.addToSet(r.activeMarks))}if(r==t)break}}}function Ft(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function Pt(e){let t={};for(let n in e)t[n]=e[n];return t}function Lt(e,t){let n=t.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(e))continue;let s=[],o=e=>{s.push(e);for(let n=0;n<e.edgeCount;n++){let{type:r,next:i}=e.edge(n);if(r==t)return!0;if(s.indexOf(i)<0&&o(i))return!0}};if(o(i.contentMatch))return!0}}class Vt{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||(n=jt(t).createDocumentFragment());let r=n,i=[];return e.forEach((e=>{if(i.length||e.marks.length){let n=0,s=0;for(;n<i.length&&s<e.marks.length;){let t=e.marks[s];if(this.marks[t.type.name]){if(!t.eq(i[n][0])||!1===t.type.spec.spanning)break;n++,s++}else s++}for(;n<i.length;)r=i.pop()[1];for(;s<e.marks.length;){let n=e.marks[s++],o=this.serializeMark(n,e.isInline,t);o&&(i.push([n,r]),r.appendChild(o.dom),r=o.contentDOM||o.dom)}}r.appendChild(this.serializeNodeInner(e,t))})),n}serializeNodeInner(e,t){let{dom:n,contentDOM:r}=Vt.renderSpec(jt(t),this.nodes[e.type.name](e));if(r){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,r)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let i=this.serializeMark(e.marks[r],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(n),n=i.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&Vt.renderSpec(jt(n),r(e,t))}static renderSpec(e,t,n=null){if("string"==typeof t)return{dom:e.createTextNode(t)};if(null!=t.nodeType)return{dom:t};if(t.dom&&null!=t.dom.nodeType)return t;let r,i=t[0],s=i.indexOf(" ");s>0&&(n=i.slice(0,s),i=i.slice(s+1));let o=n?e.createElementNS(n,i):e.createElement(i),a=t[1],l=1;if(a&&"object"==typeof a&&null==a.nodeType&&!Array.isArray(a)){l=2;for(let e in a)if(null!=a[e]){let t=e.indexOf(" ");t>0?o.setAttributeNS(e.slice(0,t),e.slice(t+1),a[e]):o.setAttribute(e,a[e])}}for(let i=l;i<t.length;i++){let s=t[i];if(0===s){if(i<t.length-1||i>l)throw new RangeError("Content hole must be the only child of its parent node");return{dom:o,contentDOM:o}}{let{dom:t,contentDOM:i}=Vt.renderSpec(e,s,n);if(o.appendChild(t),i){if(r)throw new RangeError("Multiple content holes");r=i}}}return{dom:o,contentDOM:r}}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Vt(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=zt(e.nodes);return t.text||(t.text=e=>e.text),t}static marksFromSchema(e){return zt(e.marks)}}function zt(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function jt(e){return e.document||window.document}const _t=Math.pow(2,16);function Kt(e,t){return e+t*_t}function Wt(e){return 65535&e}class Ht{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}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 qt{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&qt.empty)return qt.empty}recover(e){let t=0,n=Wt(e);if(!this.inverted)for(let e=0;e<n;e++)t+=this.ranges[3*e+2]-this.ranges[3*e+1];return this.ranges[3*n]+t+function(e){return(e-(65535&e))/_t}(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let r=0,i=this.inverted?2:1,s=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let a=this.ranges[o]-(this.inverted?r:0);if(a>e)break;let l=this.ranges[o+i],c=this.ranges[o+s],h=a+l;if(e<=h){let i=a+r+((l?e==a?-1:e==h?1:t:t)<0?0:c);if(n)return i;let s=e==(t<0?a:h)?null:Kt(o/3,e-a),d=e==a?2:e==h?1:4;return(t<0?e!=a:e!=h)&&(d|=8),new Ht(i,d,s)}r+=c-l}return n?e+r:new Ht(e+r,0,null)}touches(e,t){let n=0,r=Wt(t),i=this.inverted?2:1,s=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let o=this.ranges[t]-(this.inverted?n:0);if(o>e)break;let a=this.ranges[t+i];if(e<=o+a&&t==3*r)return!0;n+=this.ranges[t+s]-a}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,i=0;r<this.ranges.length;r+=3){let s=this.ranges[r],o=s-(this.inverted?i:0),a=s+(this.inverted?0:i),l=this.ranges[r+t],c=this.ranges[r+n];e(o,o+l,a,a+c),i+=c-l}}invert(){return new qt(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return 0==e?qt.empty:new qt(e<0?[0,-e,0]:[0,0,e])}}qt.empty=new qt([]);class Jt{constructor(e=[],t,n=0,r=e.length){this.maps=e,this.mirror=t,this.from=n,this.to=r}slice(e=0,t=this.maps.length){return new Jt(this.maps,this.mirror,e,t)}copy(){return new Jt(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)}appendMap(e,t){this.to=this.maps.push(e),null!=t&&this.setMirror(this.maps.length-1,t)}appendMapping(e){for(let t=0,n=this.maps.length;t<e.maps.length;t++){let r=e.getMirror(t);this.appendMap(e.maps[t],null!=r&&r<t?n+r:void 0)}}getMirror(e){if(this.mirror)for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this.maps.length+e.maps.length;t>=0;t--){let r=e.getMirror(t);this.appendMap(e.maps[t].invert(),null!=r&&r>t?n-r-1:void 0)}}invert(){let e=new Jt;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this.maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let r=0;for(let n=this.from;n<this.to;n++){let i=this.maps[n].mapResult(e,t);if(null!=i.recover){let t=this.getMirror(n);if(null!=t&&t>n&&t<this.to){n=t,e=this.maps[t].recover(i.recover);continue}}r|=i.delInfo,e=i.pos}return n?e:new Ht(e,r,null)}}const Ut=Object.create(null);class Gt{getMap(){return qt.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=Ut[t.stepType];if(!n)throw new RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in Ut)throw new RangeError("Duplicate use of step JSON ID "+e);return Ut[e]=t,t.prototype.jsonID=e,t}}class Yt{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new Yt(e,null)}static fail(e){return new Yt(null,e)}static fromReplace(e,t,n,r){try{return Yt.ok(e.replace(t,n,r))}catch(e){if(e instanceof We)return Yt.fail(e.message);throw e}}}function Xt(e,t,n){let r=[];for(let i=0;i<e.childCount;i++){let s=e.child(i);s.content.size&&(s=s.copy(Xt(s.content,t,s))),s.isInline&&(s=t(s,n,i)),r.push(s)}return Ve.fromArray(r)}class Zt extends Gt{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),r=n.node(n.sharedDepth(this.to)),i=new He(Xt(t.content,((e,t)=>e.isAtom&&t.type.allowsMarkType(this.mark.type)?e.mark(this.mark.addToSet(e.marks)):e),r),t.openStart,t.openEnd);return Yt.fromReplace(e,this.from,this.to,i)}invert(){return new Qt(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new Zt(t.pos,n.pos,this.mark)}merge(e){return e instanceof Zt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Zt(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Zt(t.from,t.to,e.markFromJSON(t.mark))}}Gt.jsonID("addMark",Zt);class Qt extends Gt{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new He(Xt(t.content,(e=>e.mark(this.mark.removeFromSet(e.marks))),e),t.openStart,t.openEnd);return Yt.fromReplace(e,this.from,this.to,n)}invert(){return new Zt(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new Qt(t.pos,n.pos,this.mark)}merge(e){return e instanceof Qt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Qt(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Qt(t.from,t.to,e.markFromJSON(t.mark))}}Gt.jsonID("removeMark",Qt);class en extends Gt{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Yt.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return Yt.fromReplace(e,this.pos,this.pos+1,new He(Ve.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let e=this.mark.addToSet(t.marks);if(e.length==t.marks.length){for(let n=0;n<t.marks.length;n++)if(!t.marks[n].isInSet(e))return new en(this.pos,t.marks[n]);return new en(this.pos,this.mark)}}return new tn(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new en(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new en(t.pos,e.markFromJSON(t.mark))}}Gt.jsonID("addNodeMark",en);class tn extends Gt{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Yt.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return Yt.fromReplace(e,this.pos,this.pos+1,new He(Ve.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return t&&this.mark.isInSet(t.marks)?new en(this.pos,this.mark):this}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new tn(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new tn(t.pos,e.markFromJSON(t.mark))}}Gt.jsonID("removeNodeMark",tn);class nn extends Gt{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&sn(e,this.from,this.to)?Yt.fail("Structure replace would overwrite content"):Yt.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new qt([this.from,this.to-this.from,this.slice.size])}invert(e){return new nn(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deletedAcross&&n.deletedAcross?null:new nn(t.pos,Math.max(t.pos,n.pos),this.slice)}merge(e){if(!(e instanceof nn)||e.structure||this.structure)return null;if(this.from+this.slice.size!=e.from||this.slice.openEnd||e.slice.openStart){if(e.to!=this.from||this.slice.openStart||e.slice.openEnd)return null;{let t=this.slice.size+e.slice.size==0?He.empty:new He(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new nn(e.from,this.to,t,this.structure)}}{let t=this.slice.size+e.slice.size==0?He.empty:new He(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new nn(this.from,this.to+(e.to-e.from),t,this.structure)}}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new nn(t.from,t.to,He.fromJSON(e,t.slice),!!t.structure)}}Gt.jsonID("replace",nn);class rn extends Gt{constructor(e,t,n,r,i,s,o=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=r,this.slice=i,this.insert=s,this.structure=o}apply(e){if(this.structure&&(sn(e,this.from,this.gapFrom)||sn(e,this.gapTo,this.to)))return Yt.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return Yt.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,t.content);return n?Yt.fromReplace(e,this.from,this.to,n):Yt.fail("Content does not fit in gap")}getMap(){return new qt([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new rn(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1),r=e.map(this.gapFrom,-1),i=e.map(this.gapTo,1);return t.deletedAcross&&n.deletedAcross||r<t.pos||i>n.pos?null:new rn(t.pos,n.pos,r,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to||"number"!=typeof t.gapFrom||"number"!=typeof t.gapTo||"number"!=typeof t.insert)throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new rn(t.from,t.to,t.gapFrom,t.gapTo,He.fromJSON(e,t.slice),t.insert,!!t.structure)}}function sn(e,t,n){let r=e.resolve(t),i=n-t,s=r.depth;for(;i>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,i--;if(i>0){let e=r.node(s).maybeChild(r.indexAfter(s));for(;i>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,i--}}return!1}function on(e,t,n){return(0==t||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function an(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth;;--n){let r=e.$from.node(n),i=e.$from.index(n),s=e.$to.indexAfter(n);if(n<e.depth&&r.canReplace(i,s,t))return n;if(0==n||r.type.spec.isolating||!on(r,i,s))break}return null}function ln(e,t,n=null,r=e){let i=function(e,t){let{parent:n,startIndex:r,endIndex:i}=e,s=n.contentMatchAt(r).findWrapping(t);if(!s)return null;let o=s.length?s[0]:t;return n.canReplaceWith(r,i,o)?s:null}(e,t),s=i&&function(e,t){let{parent:n,startIndex:r,endIndex:i}=e,s=n.child(r),o=t.contentMatch.findWrapping(s.type);if(!o)return null;let a=(o.length?o[o.length-1]:t).contentMatch;for(let e=r;a&&e<i;e++)a=a.matchType(n.child(e).type);return a&&a.validEnd?o:null}(r,t);return s?i.map(cn).concat({type:t,attrs:n}).concat(s.map(cn)):null}function cn(e){return{type:e,attrs:null}}function hn(e,t,n=1,r){let i=e.resolve(t),s=i.depth-n,o=r&&r[r.length-1]||i.parent;if(s<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let e=i.depth-1,t=n-2;e>s;e--,t--){let n=i.node(e),s=i.index(e);if(n.type.spec.isolating)return!1;let o=n.content.cutByIndex(s,n.childCount),a=r&&r[t]||n;if(a!=n&&(o=o.replaceChild(0,a.type.create(a.attrs))),!n.canReplace(s+1,n.childCount)||!a.type.validContent(o))return!1}let a=i.indexAfter(s),l=r&&r[0];return i.node(s).canReplaceWith(a,a,l?l.type:i.node(s+1).type)}function dn(e,t){let n=e.resolve(t),r=n.index();return un(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function un(e,t){return!(!e||!t||e.isLeaf||!e.canAppend(t))}function pn(e,t,n=-1){let r=e.resolve(t);for(let e=r.depth;;e--){let i,s,o=r.index(e);if(e==r.depth?(i=r.nodeBefore,s=r.nodeAfter):n>0?(i=r.node(e+1),o++,s=r.node(e).maybeChild(o)):(i=r.node(e).maybeChild(o-1),s=r.node(e+1)),i&&!i.isTextblock&&un(i,s)&&r.node(e).canReplace(o,o+1))return t;if(0==e)break;t=n<0?r.before(e):r.after(e)}}function fn(e,t,n){let r=e.resolve(t);if(!n.content.size)return t;let i=n.content;for(let e=0;e<n.openStart;e++)i=i.firstChild.content;for(let e=1;e<=(0==n.openStart&&n.size?2:1);e++)for(let t=r.depth;t>=0;t--){let n=t==r.depth?0:r.pos<=(r.start(t+1)+r.end(t+1))/2?-1:1,s=r.index(t)+(n>0?1:0),o=r.node(t),a=!1;if(1==e)a=o.canReplace(s,s,i);else{let e=o.contentMatchAt(s).findWrapping(i.firstChild.type);a=e&&o.canReplaceWith(s,s,e[0])}if(a)return 0==n?r.pos:n<0?r.before(t+1):r.after(t+1)}return null}function mn(e,t,n=t,r=He.empty){if(t==n&&!r.size)return null;let i=e.resolve(t),s=e.resolve(n);return gn(i,s,r)?new nn(t,n,r):new yn(i,s,r).fit()}function gn(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}Gt.jsonID("replaceAround",rn);class yn{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=Ve.empty;for(let t=0;t<=e.depth;t++){let n=e.node(t);this.frontier.push({type:n.type,match:n.contentMatchAt(e.indexAfter(t))})}for(let t=e.depth;t>0;t--)this.placed=Ve.from(e.node(t).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,r=this.close(e<0?this.$to:n.doc.resolve(e));if(!r)return null;let i=this.placed,s=n.depth,o=r.depth;for(;s&&o&&1==i.childCount;)i=i.firstChild.content,s--,o--;let a=new He(i,s,o);return e>-1?new rn(n.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||n.pos!=this.$to.pos?new nn(n.pos,r.pos,a):null}findFittable(){for(let e=1;e<=2;e++)for(let t=this.unplaced.openStart;t>=0;t--){let n,r=null;t?(r=wn(this.unplaced.content,t-1).firstChild,n=r.content):n=this.unplaced.content;let i=n.firstChild;for(let n=this.depth;n>=0;n--){let s,{type:o,match:a}=this.frontier[n],l=null;if(1==e&&(i?a.matchType(i.type)||(l=a.fillBefore(Ve.from(i),!1)):r&&o.compatibleContent(r.type)))return{sliceDepth:t,frontierDepth:n,parent:r,inject:l};if(2==e&&i&&(s=a.findWrapping(i.type)))return{sliceDepth:t,frontierDepth:n,parent:r,wrap:s};if(r&&a.matchType(r.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=wn(e,t);return!(!r.childCount||r.firstChild.isLeaf)&&(this.unplaced=new He(e,t+1,Math.max(n,r.size+t>=e.size-n?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=wn(e,t);if(r.childCount<=1&&t>0){let i=e.size-t<=t+r.size;this.unplaced=new He(vn(e,t-1,1),t-1,i?t-1:n)}else this.unplaced=new He(vn(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:r,wrap:i}){for(;this.depth>t;)this.closeFrontierNode();if(i)for(let e=0;e<i.length;e++)this.openFrontierNode(i[e]);let s=this.unplaced,o=n?n.content:s.content,a=s.openStart-e,l=0,c=[],{match:h,type:d}=this.frontier[t];if(r){for(let e=0;e<r.childCount;e++)c.push(r.child(e));h=h.matchFragment(r)}let u=o.size+e-(s.content.size-s.openEnd);for(;l<o.childCount;){let e=o.child(l),t=h.matchType(e.type);if(!t)break;l++,(l>1||0==a||e.content.size)&&(h=t,c.push(xn(e.mark(d.allowedMarks(e.marks)),1==l?a:0,l==o.childCount?u:-1)))}let p=l==o.childCount;p||(u=-1),this.placed=bn(this.placed,t,Ve.from(c)),this.frontier[t].match=h,p&&u<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let e=0,t=o;e<u;e++){let e=t.lastChild;this.frontier.push({type:e.type,match:e.contentMatchAt(e.childCount)}),t=e.content}this.unplaced=p?0==e?He.empty:new He(vn(s.content,e-1,1),e-1,u<0?s.openEnd:e-1):new He(vn(s.content,e,l),s.openStart,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e,t=this.frontier[this.depth];if(!t.type.isTextblock||!kn(this.$to,this.$to.depth,t.type,t.match,!1)||this.$to.depth==this.depth&&(e=this.findCloseLevel(this.$to))&&e.depth==this.depth)return-1;let{depth:n}=this.$to,r=this.$to.after(n);for(;n>1&&r==this.$to.end(--n);)++r;return r}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:r}=this.frontier[t],i=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),s=kn(e,t,r,n,i);if(s){for(let n=t-1;n>=0;n--){let{match:t,type:r}=this.frontier[n],i=kn(e,n,r,t,!0);if(!i||i.childCount)continue e}return{depth:t,fit:s,move:i?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=bn(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let t=e.node(n),r=t.type.contentMatch.fillBefore(t.content,!0,e.index(n));this.openFrontierNode(t.type,t.attrs,r)}return e}openFrontierNode(e,t=null,n){let r=this.frontier[this.depth];r.match=r.match.matchType(e),this.placed=bn(this.placed,this.depth,Ve.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(Ve.empty,!0);e.childCount&&(this.placed=bn(this.placed,this.frontier.length,e))}}function vn(e,t,n){return 0==t?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(vn(e.firstChild.content,t-1,n)))}function bn(e,t,n){return 0==t?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(bn(e.lastChild.content,t-1,n)))}function wn(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}function xn(e,t,n){if(t<=0)return e;let r=e.content;return t>1&&(r=r.replaceChild(0,xn(r.firstChild,t-1,1==r.childCount?n-1:0))),t>0&&(r=e.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(e.type.contentMatch.matchFragment(r).fillBefore(Ve.empty,!0)))),e.copy(r)}function kn(e,t,n,r,i){let s=e.node(t),o=i?e.indexAfter(t):e.index(t);if(o==s.childCount&&!n.compatibleContent(s.type))return null;let a=r.fillBefore(s.content,!0,o);return a&&!function(e,t,n){for(let r=n;r<t.childCount;r++)if(!e.allowsMarks(t.child(r).marks))return!0;return!1}(n,s.content,o)?a:null}function Sn(e){return e.spec.defining||e.spec.definingForContent}function Mn(e,t,n,r,i){if(t<n){let i=e.firstChild;e=e.replaceChild(0,i.copy(Mn(i.content,t+1,n,r,i)))}if(t>r){let t=i.contentMatchAt(0),n=t.fillBefore(e).append(e);e=n.append(t.matchFragment(n).fillBefore(Ve.empty,!0))}return e}function On(e,t){let n=[];for(let r=Math.min(e.depth,t.depth);r>=0;r--){let i=e.start(r);if(i<e.pos-(e.depth-r)||t.end(r)>t.pos+(t.depth-r)||e.node(r).type.spec.isolating||t.node(r).type.spec.isolating)break;(i==t.start(r)||r==e.depth&&r==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&r&&t.start(r-1)==i-1)&&n.push(r)}return n}class An extends Gt{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return Yt.fail("No node at attribute step's position");let n=Object.create(null);for(let e in t.attrs)n[e]=t.attrs[e];n[this.attr]=this.value;let r=t.type.create(n,null,t.marks);return Yt.fromReplace(e,this.pos,this.pos+1,new He(Ve.from(r),0,t.isLeaf?0:1))}getMap(){return qt.empty}invert(e){return new An(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new An(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if("number"!=typeof t.pos||"string"!=typeof t.attr)throw new RangeError("Invalid input for AttrStep.fromJSON");return new An(t.pos,t.attr,t.value)}}Gt.jsonID("attr",An);let Cn=class extends Error{};Cn=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n},(Cn.prototype=Object.create(Error.prototype)).constructor=Cn,Cn.prototype.name="TransformError";const En=Object.create(null);class Tn{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new Nn(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=He.empty){let n=t.content.lastChild,r=null;for(let e=0;e<t.openEnd;e++)r=n,n=n.lastChild;let i=e.steps.length,s=this.ranges;for(let o=0;o<s.length;o++){let{$from:a,$to:l}=s[o],c=e.mapping.slice(i);e.replaceRange(c.map(a.pos),c.map(l.pos),o?He.empty:t),0==o&&zn(e,i,(n?n.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,r=this.ranges;for(let i=0;i<r.length;i++){let{$from:s,$to:o}=r[i],a=e.mapping.slice(n),l=a.map(s.pos),c=a.map(o.pos);i?e.deleteRange(l,c):(e.replaceRangeWith(l,c,t),zn(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let r=e.parent.inlineContent?new In(e):Vn(e.node(0),e.parent,e.pos,e.index(),t,n);if(r)return r;for(let r=e.depth-1;r>=0;r--){let i=t<0?Vn(e.node(0),e.node(r),e.before(r+1),e.index(r),t,n):Vn(e.node(0),e.node(r),e.after(r+1),e.index(r)+1,t,n);if(i)return i}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new Pn(e.node(0))}static atStart(e){return Vn(e,e,0,0,1)||new Pn(e)}static atEnd(e){return Vn(e,e,e.content.size,e.childCount,-1)||new Pn(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=En[t.type];if(!n)throw new RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in En)throw new RangeError("Duplicate use of selection JSON ID "+e);return En[e]=t,t.prototype.jsonID=e,t}getBookmark(){return In.between(this.$anchor,this.$head).getBookmark()}}Tn.prototype.visible=!0;class Nn{constructor(e,t){this.$from=e,this.$to=t}}let Dn=!1;function $n(e){Dn||e.parent.inlineContent||(Dn=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}class In extends Tn{constructor(e,t=e){$n(e),$n(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let n=e.resolve(t.map(this.head));if(!n.parent.inlineContent)return Tn.near(n);let r=e.resolve(t.map(this.anchor));return new In(r.parent.inlineContent?r:n,n)}replace(e,t=He.empty){if(super.replace(e,t),t==He.empty){let t=this.$from.marksAcross(this.$to);t&&e.ensureMarks(t)}}eq(e){return e instanceof In&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Rn(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if("number"!=typeof t.anchor||"number"!=typeof t.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new In(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,n=t){let r=e.resolve(t);return new this(r,n==t?r:e.resolve(n))}static between(e,t,n){let r=e.pos-t.pos;if(n&&!r||(n=r>=0?1:-1),!t.parent.inlineContent){let e=Tn.findFrom(t,n,!0)||Tn.findFrom(t,-n,!0);if(!e)return Tn.near(t,n);t=e.$head}return e.parent.inlineContent||(0==r||(e=(Tn.findFrom(e,-n,!0)||Tn.findFrom(e,n,!0)).$anchor).pos<t.pos!=r<0)&&(e=t),new In(e,t)}}Tn.jsonID("text",In);class Rn{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Rn(e.map(this.anchor),e.map(this.head))}resolve(e){return In.between(e.resolve(this.anchor),e.resolve(this.head))}}class Bn extends Tn{constructor(e){let t=e.nodeAfter,n=e.node(0).resolve(e.pos+t.nodeSize);super(e,n),this.node=t}map(e,t){let{deleted:n,pos:r}=t.mapResult(this.anchor),i=e.resolve(r);return n?Tn.near(i):new Bn(i)}content(){return new He(Ve.from(this.node),0,0)}eq(e){return e instanceof Bn&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Fn(this.anchor)}static fromJSON(e,t){if("number"!=typeof t.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Bn(e.resolve(t.anchor))}static create(e,t){return new Bn(e.resolve(t))}static isSelectable(e){return!e.isText&&!1!==e.type.spec.selectable}}Bn.prototype.visible=!1,Tn.jsonID("node",Bn);class Fn{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:n}=e.mapResult(this.anchor);return t?new Rn(n,n):new Fn(n)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&Bn.isSelectable(n)?new Bn(t):Tn.near(t)}}class Pn extends Tn{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=He.empty){if(t==He.empty){e.delete(0,e.doc.content.size);let t=Tn.atStart(e.doc);t.eq(e.selection)||e.setSelection(t)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new Pn(e)}map(e){return new Pn(e)}eq(e){return e instanceof Pn}getBookmark(){return Ln}}Tn.jsonID("all",Pn);const Ln={map(){return this},resolve:e=>new Pn(e)};function Vn(e,t,n,r,i,s=!1){if(t.inlineContent)return In.create(e,n);for(let o=r-(i>0?0:1);i>0?o<t.childCount:o>=0;o+=i){let r=t.child(o);if(r.isAtom){if(!s&&Bn.isSelectable(r))return Bn.create(e,n-(i<0?r.nodeSize:0))}else{let t=Vn(e,r,n+i,i<0?r.childCount:0,i,s);if(t)return t}n+=r.nodeSize*i}return null}function zn(e,t,n){let r=e.steps.length-1;if(r<t)return;let i,s=e.steps[r];(s instanceof nn||s instanceof rn)&&(e.mapping.maps[r].forEach(((e,t,n,r)=>{null==i&&(i=r)})),e.setSelection(Tn.near(e.doc.resolve(i),n)))}class jn extends class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Jt}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Cn(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,n=He.empty){let r=mn(this.doc,e,t,n);return r&&this.step(r),this}replaceWith(e,t,n){return this.replace(e,t,new He(Ve.from(n),0,0))}delete(e,t){return this.replace(e,t,He.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return function(e,t,n,r){if(!r.size)return e.deleteRange(t,n);let i=e.doc.resolve(t),s=e.doc.resolve(n);if(gn(i,s,r))return e.step(new nn(t,n,r));let o=On(i,e.doc.resolve(n));0==o[o.length-1]&&o.pop();let a=-(i.depth+1);o.unshift(a);for(let e=i.depth,t=i.pos-1;e>0;e--,t--){let n=i.node(e).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;o.indexOf(e)>-1?a=e:i.before(e)==t&&o.splice(1,0,-e)}let l=o.indexOf(a),c=[],h=r.openStart;for(let e=r.content,t=0;;t++){let n=e.firstChild;if(c.push(n),t==r.openStart)break;e=n.content}for(let e=h-1;e>=0;e--){let t=c[e].type,n=Sn(t);if(n&&i.node(l).type!=t)h=e;else if(n||!t.isTextblock)break}for(let t=r.openStart;t>=0;t--){let a=(t+h+1)%(r.openStart+1),d=c[a];if(d)for(let t=0;t<o.length;t++){let c=o[(t+l)%o.length],h=!0;c<0&&(h=!1,c=-c);let u=i.node(c-1),p=i.index(c-1);if(u.canReplaceWith(p,p,d.type,d.marks))return e.replace(i.before(c),h?s.after(c):n,new He(Mn(r.content,0,r.openStart,a),a,r.openEnd))}}let d=e.steps.length;for(let a=o.length-1;a>=0&&(e.replace(t,n,r),!(e.steps.length>d));a--){let e=o[a];e<0||(t=i.before(e),n=s.after(e))}}(this,e,t,n),this}replaceRangeWith(e,t,n){return function(e,t,n,r){if(!r.isInline&&t==n&&e.doc.resolve(t).parent.content.size){let i=function(e,t,n){let r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;if(0==r.parentOffset)for(let e=r.depth-1;e>=0;e--){let t=r.index(e);if(r.node(e).canReplaceWith(t,t,n))return r.before(e+1);if(t>0)return null}if(r.parentOffset==r.parent.content.size)for(let e=r.depth-1;e>=0;e--){let t=r.indexAfter(e);if(r.node(e).canReplaceWith(t,t,n))return r.after(e+1);if(t<r.node(e).childCount)return null}return null}(e.doc,t,r.type);null!=i&&(t=n=i)}e.replaceRange(t,n,new He(Ve.from(r),0,0))}(this,e,t,n),this}deleteRange(e,t){return function(e,t,n){let r=e.doc.resolve(t),i=e.doc.resolve(n),s=On(r,i);for(let t=0;t<s.length;t++){let n=s[t],o=t==s.length-1;if(o&&0==n||r.node(n).type.contentMatch.validEnd)return e.delete(r.start(n),i.end(n));if(n>0&&(o||r.node(n-1).canReplace(r.index(n-1),i.indexAfter(n-1))))return e.delete(r.before(n),i.after(n))}for(let s=1;s<=r.depth&&s<=i.depth;s++)if(t-r.start(s)==r.depth-s&&n>r.end(s)&&i.end(s)-n!=i.depth-s)return e.delete(r.before(s),n);e.delete(t,n)}(this,e,t),this}lift(e,t){return function(e,t,n){let{$from:r,$to:i,depth:s}=t,o=r.before(s+1),a=i.after(s+1),l=o,c=a,h=Ve.empty,d=0;for(let e=s,t=!1;e>n;e--)t||r.index(e)>0?(t=!0,h=Ve.from(r.node(e).copy(h)),d++):l--;let u=Ve.empty,p=0;for(let e=s,t=!1;e>n;e--)t||i.after(e+1)<i.end(e)?(t=!0,u=Ve.from(i.node(e).copy(u)),p++):c++;e.step(new rn(l,c,o,a,new He(h.append(u),d,p),h.size-d,!0))}(this,e,t),this}join(e,t=1){return function(e,t,n){let r=new nn(t-n,t+n,He.empty,!0);e.step(r)}(this,e,t),this}wrap(e,t){return function(e,t,n){let r=Ve.empty;for(let e=n.length-1;e>=0;e--){if(r.size){let t=n[e].type.contentMatch.matchFragment(r);if(!t||!t.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=Ve.from(n[e].type.create(n[e].attrs,r))}let i=t.start,s=t.end;e.step(new rn(i,s,i,s,new He(r,0,0),n.length,!0))}(this,e,t),this}setBlockType(e,t=e,n,r=null){return function(e,t,n,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=e.steps.length;e.doc.nodesBetween(t,n,((t,n)=>{if(t.isTextblock&&!t.hasMarkup(r,i)&&function(e,t,n){let r=e.resolve(t),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}(e.doc,e.mapping.slice(s).map(n),r)){e.clearIncompatible(e.mapping.slice(s).map(n,1),r);let o=e.mapping.slice(s),a=o.map(n,1),l=o.map(n+t.nodeSize,1);return e.step(new rn(a,l,a+1,l-1,new He(Ve.from(r.create(i,null,t.marks)),0,0),1,!0)),!1}}))}(this,e,t,n,r),this}setNodeMarkup(e,t,n=null,r=[]){return function(e,t,n,r,i){let s=e.doc.nodeAt(t);if(!s)throw new RangeError("No node at given position");n||(n=s.type);let o=n.create(r,null,i||s.marks);if(s.isLeaf)return e.replaceWith(t,t+s.nodeSize,o);if(!n.validContent(s.content))throw new RangeError("Invalid content for node type "+n.name);e.step(new rn(t,t+s.nodeSize,t+1,t+s.nodeSize-1,new He(Ve.from(o),0,0),1,!0))}(this,e,t,n,r),this}setNodeAttribute(e,t,n){return this.step(new An(e,t,n)),this}addNodeMark(e,t){return this.step(new en(e,t)),this}removeNodeMark(e,t){if(!(t instanceof Ke)){let n=this.doc.nodeAt(e);if(!n)throw new RangeError("No node at position "+e);if(!(t=t.isInSet(n.marks)))return this}return this.step(new tn(e,t)),this}split(e,t=1,n){return function(e,t,n=1,r){let i=e.doc.resolve(t),s=Ve.empty,o=Ve.empty;for(let e=i.depth,t=i.depth-n,a=n-1;e>t;e--,a--){s=Ve.from(i.node(e).copy(s));let t=r&&r[a];o=Ve.from(t?t.type.create(t.attrs,o):i.node(e).copy(o))}e.step(new nn(t,t,new He(s.append(o),n,n),!0))}(this,e,t,n),this}addMark(e,t,n){return function(e,t,n,r){let i,s,o=[],a=[];e.doc.nodesBetween(t,n,((e,l,c)=>{if(!e.isInline)return;let h=e.marks;if(!r.isInSet(h)&&c.type.allowsMarkType(r.type)){let c=Math.max(l,t),d=Math.min(l+e.nodeSize,n),u=r.addToSet(h);for(let e=0;e<h.length;e++)h[e].isInSet(u)||(i&&i.to==c&&i.mark.eq(h[e])?i.to=d:o.push(i=new Qt(c,d,h[e])));s&&s.to==c?s.to=d:a.push(s=new Zt(c,d,r))}})),o.forEach((t=>e.step(t))),a.forEach((t=>e.step(t)))}(this,e,t,n),this}removeMark(e,t,n){return function(e,t,n,r){let i=[],s=0;e.doc.nodesBetween(t,n,((e,o)=>{if(!e.isInline)return;s++;let a=null;if(r instanceof At){let t,n=e.marks;for(;t=r.isInSet(n);)(a||(a=[])).push(t),n=t.removeFromSet(n)}else r?r.isInSet(e.marks)&&(a=[r]):a=e.marks;if(a&&a.length){let r=Math.min(o+e.nodeSize,n);for(let e=0;e<a.length;e++){let n,l=a[e];for(let e=0;e<i.length;e++){let t=i[e];t.step==s-1&&l.eq(i[e].style)&&(n=t)}n?(n.to=r,n.step=s):i.push({style:l,from:Math.max(o,t),to:r,step:s})}}})),i.forEach((t=>e.step(new Qt(t.from,t.to,t.style))))}(this,e,t,n),this}clearIncompatible(e,t,n){return function(e,t,n,r=n.contentMatch){let i=e.doc.nodeAt(t),s=[],o=t+1;for(let t=0;t<i.childCount;t++){let a=i.child(t),l=o+a.nodeSize,c=r.matchType(a.type);if(c){r=c;for(let t=0;t<a.marks.length;t++)n.allowsMarkType(a.marks[t].type)||e.step(new Qt(o,l,a.marks[t]))}else s.push(new nn(o,l,He.empty));o=l}if(!r.validEnd){let t=r.fillBefore(Ve.empty,!0);e.replace(o,o,new He(t,0,0))}for(let t=s.length-1;t>=0;t--)e.step(s[t])}(this,e,t,n),this}}{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=-3&(1|this.updated),this.storedMarks=null,this}get selectionSet(){return(1&this.updated)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=2,this}ensureMarks(e){return Ke.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(2&this.updated)>0}addStep(e,t){super.addStep(e,t),this.updated=-3&this.updated,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||Ke.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let r=this.doc.type.schema;if(null==t)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();{if(null==n&&(n=t),n=null==n?t:n,!e)return this.deleteRange(t,n);let i=this.storedMarks;if(!i){let e=this.doc.resolve(t);i=n==t?e.marks():e.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,r.text(e,i)),this.selection.empty||this.setSelection(Tn.near(this.selection.$to)),this}}setMeta(e,t){return this.meta["string"==typeof e?e:e.key]=t,this}getMeta(e){return this.meta["string"==typeof e?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=4,this}get scrolledIntoView(){return(4&this.updated)>0}}function _n(e,t){return t&&e?e.bind(t):e}class Kn{constructor(e,t,n){this.name=e,this.init=_n(t.init,n),this.apply=_n(t.apply,n)}}const Wn=[new Kn("doc",{init:e=>e.doc||e.schema.topNodeType.createAndFill(),apply:e=>e.doc}),new Kn("selection",{init:(e,t)=>e.selection||Tn.atStart(t.doc),apply:e=>e.selection}),new Kn("storedMarks",{init:e=>e.storedMarks||null,apply:(e,t,n,r)=>r.selection.$cursor?e.storedMarks:null}),new Kn("scrollToSelection",{init:()=>0,apply:(e,t)=>e.scrolledIntoView?t+1:t})];class Hn{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Wn.slice(),t&&t.forEach((e=>{if(this.pluginsByKey[e.key])throw new RangeError("Adding different instances of a keyed plugin ("+e.key+")");this.plugins.push(e),this.pluginsByKey[e.key]=e,e.spec.state&&this.fields.push(new Kn(e.key,e.spec.state,e))}))}}class qn{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let n=0;n<this.config.plugins.length;n++)if(n!=t){let t=this.config.plugins[n];if(t.spec.filterTransaction&&!t.spec.filterTransaction.call(t,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],n=this.applyInner(e),r=null;for(;;){let i=!1;for(let s=0;s<this.config.plugins.length;s++){let o=this.config.plugins[s];if(o.spec.appendTransaction){let a=r?r[s].n:0,l=r?r[s].state:this,c=a<t.length&&o.spec.appendTransaction.call(o,a?t.slice(a):t,l,n);if(c&&n.filterTransaction(c,s)){if(c.setMeta("appendedTransaction",e),!r){r=[];for(let e=0;e<this.config.plugins.length;e++)r.push(e<s?{state:n,n:t.length}:{state:this,n:0})}t.push(c),n=n.applyInner(c),i=!0}r&&(r[s]={state:n,n:t.length})}}if(!i)return{state:n,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new qn(this.config),n=this.config.fields;for(let r=0;r<n.length;r++){let i=n[r];t[i.name]=i.apply(e,this[i.name],this,t)}return t}get tr(){return new jn(this)}static create(e){let t=new Hn(e.doc?e.doc.type.schema:e.schema,e.plugins),n=new qn(t);for(let r=0;r<t.fields.length;r++)n[t.fields[r].name]=t.fields[r].init(e,n);return n}reconfigure(e){let t=new Hn(this.schema,e.plugins),n=t.fields,r=new qn(t);for(let t=0;t<n.length;t++){let i=n[t].name;r[i]=this.hasOwnProperty(i)?this[i]:n[t].init(e,r)}return r}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map((e=>e.toJSON()))),e&&"object"==typeof e)for(let n in e){if("doc"==n||"selection"==n)throw new RangeError("The JSON fields `doc` and `selection` are reserved");let r=e[n],i=r.spec.state;i&&i.toJSON&&(t[n]=i.toJSON.call(r,this[r.key]))}return t}static fromJSON(e,t,n){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let r=new Hn(e.schema,e.plugins),i=new qn(r);return r.fields.forEach((r=>{if("doc"==r.name)i.doc=ct.fromJSON(e.schema,t.doc);else if("selection"==r.name)i.selection=Tn.fromJSON(i.doc,t.selection);else if("storedMarks"==r.name)t.storedMarks&&(i.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(n)for(let s in n){let o=n[s],a=o.spec.state;if(o.key==r.name&&a&&a.fromJSON&&Object.prototype.hasOwnProperty.call(t,s))return void(i[r.name]=a.fromJSON.call(o,e,t[s],i))}i[r.name]=r.init(e,i)}})),i}}function Jn(e,t,n){for(let r in e){let i=e[r];i instanceof Function?i=i.bind(t):"handleDOMEvents"==r&&(i=Jn(i,t,{})),n[r]=i}return n}class Un{constructor(e){this.spec=e,this.props={},e.props&&Jn(e.props,this,this.props),this.key=e.key?e.key.key:Yn("plugin")}getState(e){return e[this.key]}}const Gn=Object.create(null);function Yn(e){return e in Gn?e+"$"+ ++Gn[e]:(Gn[e]=0,e+"$")}class Xn{constructor(e="key"){this.key=Yn(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Zn=function(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t},Qn=function(e){let t=e.assignedSlot||e.parentNode;return t&&11==t.nodeType?t.host:t};let er=null;const tr=function(e,t,n){let r=er||(er=document.createRange());return r.setEnd(e,null==n?e.nodeValue.length:n),r.setStart(e,t||0),r},nr=function(e,t,n,r){return n&&(ir(e,t,n,r,-1)||ir(e,t,n,r,1))},rr=/^(img|br|input|textarea|hr)$/i;function ir(e,t,n,r,i){for(;;){if(e==n&&t==r)return!0;if(t==(i<0?0:sr(e))){let n=e.parentNode;if(!n||1!=n.nodeType||or(e)||rr.test(e.nodeName)||"false"==e.contentEditable)return!1;t=Zn(e)+(i<0?0:1),e=n}else{if(1!=e.nodeType)return!1;if("false"==(e=e.childNodes[t+(i<0?-1:0)]).contentEditable)return!1;t=i<0?sr(e):0}}}function sr(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function or(e){let t;for(let n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}const ar=function(e){return e.focusNode&&nr(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function lr(e,t){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}const cr="undefined"!=typeof navigator?navigator:null,hr="undefined"!=typeof document?document:null,dr=cr&&cr.userAgent||"",ur=/Edge\/(\d+)/.exec(dr),pr=/MSIE \d/.exec(dr),fr=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(dr),mr=!!(pr||fr||ur),gr=pr?document.documentMode:fr?+fr[1]:ur?+ur[1]:0,yr=!mr&&/gecko\/(\d+)/i.test(dr);yr&&(/Firefox\/(\d+)/.exec(dr)||[0,0])[1];const vr=!mr&&/Chrome\/(\d+)/.exec(dr),br=!!vr,wr=vr?+vr[1]:0,xr=!mr&&!!cr&&/Apple Computer/.test(cr.vendor),kr=xr&&(/Mobile\/\w+/.test(dr)||!!cr&&cr.maxTouchPoints>2),Sr=kr||!!cr&&/Mac/.test(cr.platform),Mr=/Android \d/.test(dr),Or=!!hr&&"webkitFontSmoothing"in hr.documentElement.style,Ar=Or?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Cr(e){return{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function Er(e,t){return"number"==typeof e?e:e[t]}function Tr(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,r=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*r}}function Nr(e,t,n){let r=e.someProp("scrollThreshold")||0,i=e.someProp("scrollMargin")||5,s=e.dom.ownerDocument;for(let o=n||e.dom;o;o=Qn(o)){if(1!=o.nodeType)continue;let e=o,n=e==s.body,a=n?Cr(s):Tr(e),l=0,c=0;if(t.top<a.top+Er(r,"top")?c=-(a.top-t.top+Er(i,"top")):t.bottom>a.bottom-Er(r,"bottom")&&(c=t.bottom-a.bottom+Er(i,"bottom")),t.left<a.left+Er(r,"left")?l=-(a.left-t.left+Er(i,"left")):t.right>a.right-Er(r,"right")&&(l=t.right-a.right+Er(i,"right")),l||c)if(n)s.defaultView.scrollBy(l,c);else{let n=e.scrollLeft,r=e.scrollTop;c&&(e.scrollTop+=c),l&&(e.scrollLeft+=l);let i=e.scrollLeft-n,s=e.scrollTop-r;t={left:t.left-i,top:t.top-s,right:t.right-i,bottom:t.bottom-s}}if(n)break}}function Dr(e){let t=[],n=e.ownerDocument;for(let r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=Qn(r));return t}function $r(e,t){for(let n=0;n<e.length;n++){let{dom:r,top:i,left:s}=e[n];r.scrollTop!=i+t&&(r.scrollTop=i+t),r.scrollLeft!=s&&(r.scrollLeft=s)}}let Ir=null;function Rr(e,t){let n,r,i=2e8,s=0,o=t.top,a=t.top;for(let l=e.firstChild,c=0;l;l=l.nextSibling,c++){let e;if(1==l.nodeType)e=l.getClientRects();else{if(3!=l.nodeType)continue;e=tr(l).getClientRects()}for(let h=0;h<e.length;h++){let d=e[h];if(d.top<=o&&d.bottom>=a){o=Math.max(d.bottom,o),a=Math.min(d.top,a);let e=d.left>t.left?d.left-t.left:d.right<t.left?t.left-d.right:0;if(e<i){n=l,i=e,r=e&&3==n.nodeType?{left:d.right<t.left?d.right:d.left,top:t.top}:t,1==l.nodeType&&e&&(s=c+(t.left>=(d.left+d.right)/2?1:0));continue}}!n&&(t.left>=d.right&&t.top>=d.top||t.left>=d.left&&t.top>=d.bottom)&&(s=c+1)}}return n&&3==n.nodeType?function(e,t){let n=e.nodeValue.length,r=document.createRange();for(let i=0;i<n;i++){r.setEnd(e,i+1),r.setStart(e,i);let n=Lr(r,1);if(n.top!=n.bottom&&Br(t,n))return{node:e,offset:i+(t.left>=(n.left+n.right)/2?1:0)}}return{node:e,offset:0}}(n,r):!n||i&&1==n.nodeType?{node:e,offset:s}:Rr(n,r)}function Br(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function Fr(e,t,n){let r=e.childNodes.length;if(r&&n.top<n.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(t.top-n.top)/(n.bottom-n.top))-2)),s=i;;){let n=e.childNodes[s];if(1==n.nodeType){let e=n.getClientRects();for(let r=0;r<e.length;r++){let i=e[r];if(Br(t,i))return Fr(n,t,i)}}if((s=(s+1)%r)==i)break}return e}function Pr(e,t){let n,r=e.dom.ownerDocument,i=0;if(r.caretPositionFromPoint)try{let e=r.caretPositionFromPoint(t.left,t.top);e&&({offsetNode:n,offset:i}=e)}catch(e){}if(!n&&r.caretRangeFromPoint){let e=r.caretRangeFromPoint(t.left,t.top);e&&({startContainer:n,startOffset:i}=e)}let s,o=(e.root.elementFromPoint?e.root:r).elementFromPoint(t.left,t.top);if(!o||!e.dom.contains(1!=o.nodeType?o.parentNode:o)){let n=e.dom.getBoundingClientRect();if(!Br(t,n))return null;if(o=Fr(e.dom,t,n),!o)return null}if(xr)for(let e=o;n&&e;e=Qn(e))e.draggable&&(n=void 0);if(o=function(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}(o,t),n){if(yr&&1==n.nodeType&&(i=Math.min(i,n.childNodes.length),i<n.childNodes.length)){let e,r=n.childNodes[i];"IMG"==r.nodeName&&(e=r.getBoundingClientRect()).right<=t.left&&e.bottom>t.top&&i++}n==e.dom&&i==n.childNodes.length-1&&1==n.lastChild.nodeType&&t.top>n.lastChild.getBoundingClientRect().bottom?s=e.state.doc.content.size:0!=i&&1==n.nodeType&&"BR"==n.childNodes[i-1].nodeName||(s=function(e,t,n,r){let i=-1;for(let n=t;n!=e.dom;){let t=e.docView.nearestDesc(n,!0);if(!t)return null;if(t.node.isBlock&&t.parent){let e=t.dom.getBoundingClientRect();if(e.left>r.left||e.top>r.top)i=t.posBefore;else{if(!(e.right<r.left||e.bottom<r.top))break;i=t.posAfter}}n=t.dom.parentNode}return i>-1?i:e.docView.posFromDOM(t,n,1)}(e,n,i,t))}null==s&&(s=function(e,t,n){let{node:r,offset:i}=Rr(t,n),s=-1;if(1==r.nodeType&&!r.firstChild){let e=r.getBoundingClientRect();s=e.left!=e.right&&n.left>(e.left+e.right)/2?1:-1}return e.docView.posFromDOM(r,i,s)}(e,o,t));let a=e.docView.nearestDesc(o,!0);return{pos:s,inside:a?a.posAtStart-a.border:-1}}function Lr(e,t){let n=e.getClientRects();return n.length?n[t<0?0:n.length-1]:e.getBoundingClientRect()}const Vr=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function zr(e,t,n){let{node:r,offset:i,atom:s}=e.docView.domFromPos(t,n<0?-1:1),o=Or||yr;if(3==r.nodeType){if(!o||!Vr.test(r.nodeValue)&&(n<0?i:i!=r.nodeValue.length)){let e=i,t=i,s=n<0?1:-1;return n<0&&!i?(t++,s=-1):n>=0&&i==r.nodeValue.length?(e--,s=1):n<0?e--:t++,jr(Lr(tr(r,e,t),1),s<0)}{let e=Lr(tr(r,i,i),n);if(yr&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let t=Lr(tr(r,i-1,i-1),-1);if(t.top==e.top){let n=Lr(tr(r,i,i+1),-1);if(n.top!=e.top)return jr(n,n.left<t.left)}}return e}}if(!e.state.doc.resolve(t-(s||0)).parent.inlineContent){if(null==s&&i&&(n<0||i==sr(r))){let e=r.childNodes[i-1];if(1==e.nodeType)return _r(e.getBoundingClientRect(),!1)}if(null==s&&i<sr(r)){let e=r.childNodes[i];if(1==e.nodeType)return _r(e.getBoundingClientRect(),!0)}return _r(r.getBoundingClientRect(),n>=0)}if(null==s&&i&&(n<0||i==sr(r))){let e=r.childNodes[i-1],t=3==e.nodeType?tr(e,sr(e)-(o?0:1)):1!=e.nodeType||"BR"==e.nodeName&&e.nextSibling?null:e;if(t)return jr(Lr(t,1),!1)}if(null==s&&i<sr(r)){let e=r.childNodes[i];for(;e.pmViewDesc&&e.pmViewDesc.ignoreForCoords;)e=e.nextSibling;let t=e?3==e.nodeType?tr(e,0,o?0:1):1==e.nodeType?e:null:null;if(t)return jr(Lr(t,-1),!0)}return jr(Lr(3==r.nodeType?tr(r):r,-n),n>=0)}function jr(e,t){if(0==e.width)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function _r(e,t){if(0==e.height)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function Kr(e,t,n){let r=e.state,i=e.root.activeElement;r!=t&&e.updateState(t),i!=e.dom&&e.focus();try{return n()}finally{r!=t&&e.updateState(r),i!=e.dom&&i&&i.focus()}}const Wr=/[\u0590-\u08ac]/;let Hr=null,qr=null,Jr=!1;function Ur(e,t,n){return Hr==t&&qr==n?Jr:(Hr=t,qr=n,Jr="up"==n||"down"==n?function(e,t,n){let r=t.selection,i="up"==n?r.$from:r.$to;return Kr(e,t,(()=>{let{node:t}=e.docView.domFromPos(i.pos,"up"==n?-1:1);for(;;){let n=e.docView.nearestDesc(t,!0);if(!n)break;if(n.node.isBlock){t=n.dom;break}t=n.dom.parentNode}let r=zr(e,i.pos,1);for(let e=t.firstChild;e;e=e.nextSibling){let t;if(1==e.nodeType)t=e.getClientRects();else{if(3!=e.nodeType)continue;t=tr(e,0,e.nodeValue.length).getClientRects()}for(let e=0;e<t.length;e++){let i=t[e];if(i.bottom>i.top+1&&("up"==n?r.top-i.top>2*(i.bottom-r.top):i.bottom-r.bottom>2*(r.bottom-i.top)))return!1}}return!0}))}(e,t,n):function(e,t,n){let{$head:r}=t.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,s=!i,o=i==r.parent.content.size,a=e.domSelection();return Wr.test(r.parent.textContent)&&a.modify?Kr(e,t,(()=>{let{focusNode:t,focusOffset:i,anchorNode:s,anchorOffset:o}=e.domSelectionRange(),l=a.caretBidiLevel;a.modify("move",n,"character");let c=r.depth?e.docView.domAfterPos(r.before()):e.dom,{focusNode:h,focusOffset:d}=e.domSelectionRange(),u=h&&!c.contains(1==h.nodeType?h:h.parentNode)||t==h&&i==d;try{a.collapse(s,o),t&&(t!=s||i!=o)&&a.extend&&a.extend(t,i)}catch(e){}return null!=l&&(a.caretBidiLevel=l),u})):"left"==n||"backward"==n?s:o}(e,t,n))}class Gr{constructor(e,t,n,r){this.parent=e,this.children=t,this.dom=n,this.contentDOM=r,this.dirty=0,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,n=this.posAtStart;;t++){let r=this.children[t];if(r==e)return n;n+=r.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,n){if(this.contentDOM&&this.contentDOM.contains(1==e.nodeType?e:e.parentNode)){if(n<0){let n,r;if(e==this.contentDOM)n=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.previousSibling}for(;n&&(!(r=n.pmViewDesc)||r.parent!=this);)n=n.previousSibling;return n?this.posBeforeChild(r)+r.size:this.posAtStart}{let n,r;if(e==this.contentDOM)n=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.nextSibling}for(;n&&(!(r=n.pmViewDesc)||r.parent!=this);)n=n.nextSibling;return n?this.posBeforeChild(r):this.posAtEnd}}let r;if(e==this.dom&&this.contentDOM)r=t>Zn(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))r=2&e.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==t)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!1;break}if(t.previousSibling)break}if(null==r&&t==e.childNodes.length)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!0;break}if(t.nextSibling)break}}return(null==r?n>0:r)?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,r=e;r;r=r.parentNode){let i,s=this.getDesc(r);if(s&&(!t||s.node)){if(!n||!(i=s.nodeDOM)||(1==i.nodeType?i.contains(1==e.nodeType?e:e.parentNode):i==e))return s;n=!1}}}getDesc(e){let t=e.pmViewDesc;for(let e=t;e;e=e.parent)if(e==this)return t}posFromDOM(e,t,n){for(let r=e;r;r=r.parentNode){let i=this.getDesc(r);if(i)return i.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let r=this.children[t],i=n+r.size;if(n==e&&i!=n){for(;!r.border&&r.children.length;)r=r.children[0];return r}if(e<i)return r.descAt(e-n-r.border);n=i}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n,r=0,i=0;for(let t=0;r<this.children.length;r++){let n=this.children[r],s=t+n.size;if(s>e||n instanceof ni){i=e-t;break}t=s}if(i)return this.children[r].domFromPos(i-this.children[r].border,t);for(;r&&!(n=this.children[r-1]).size&&n instanceof Yr&&n.side>=0;r--);if(t<=0){let e,n=!0;for(;e=r?this.children[r-1]:null,e&&e.dom.parentNode!=this.contentDOM;r--,n=!1);return e&&t&&n&&!e.border&&!e.domAtom?e.domFromPos(e.size,t):{node:this.contentDOM,offset:e?Zn(e.dom)+1:0}}{let e,n=!0;for(;e=r<this.children.length?this.children[r]:null,e&&e.dom.parentNode!=this.contentDOM;r++,n=!1);return e&&n&&!e.border&&!e.domAtom?e.domFromPos(0,t):{node:this.contentDOM,offset:e?Zn(e.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,n=0){if(0==this.children.length)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let r=-1,i=-1;for(let s=n,o=0;;o++){let n=this.children[o],a=s+n.size;if(-1==r&&e<=a){let i=s+n.border;if(e>=i&&t<=a-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(e,t,i);e=s;for(let t=o;t>0;t--){let n=this.children[t-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){r=Zn(n.dom)+1;break}e-=n.size}-1==r&&(r=0)}if(r>-1&&(a>t||o==this.children.length-1)){t=a;for(let e=o+1;e<this.children.length;e++){let n=this.children[e];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(-1)){i=Zn(n.dom);break}t+=n.size}-1==i&&(i=this.contentDOM.childNodes.length);break}s=a}return{node:this.contentDOM,from:e,to:t,fromOffset:r,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return 0==t.size||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:n}=this.domFromPos(e,0);if(1!=t.nodeType||n==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[n]}setSelection(e,t,n,r=!1){let i=Math.min(e,t),s=Math.max(e,t);for(let o=0,a=0;o<this.children.length;o++){let l=this.children[o],c=a+l.size;if(i>a&&s<c)return l.setSelection(e-a-l.border,t-a-l.border,n,r);a=c}let o=this.domFromPos(e,e?-1:1),a=t==e?o:this.domFromPos(t,t?-1:1),l=n.getSelection(),c=!1;if((yr||xr)&&e==t){let{node:e,offset:t}=o;if(3==e.nodeType){if(c=!(!t||"\n"!=e.nodeValue[t-1]),c&&t==e.nodeValue.length)for(let t,n=e;n;n=n.parentNode){if(t=n.nextSibling){"BR"==t.nodeName&&(o=a={node:t.parentNode,offset:Zn(t)+1});break}let e=n.pmViewDesc;if(e&&e.node&&e.node.isBlock)break}}else{let n=e.childNodes[t-1];c=n&&("BR"==n.nodeName||"false"==n.contentEditable)}}if(yr&&l.focusNode&&l.focusNode!=a.node&&1==l.focusNode.nodeType){let e=l.focusNode.childNodes[l.focusOffset];e&&"false"==e.contentEditable&&(r=!0)}if(!(r||c&&xr)&&nr(o.node,o.offset,l.anchorNode,l.anchorOffset)&&nr(a.node,a.offset,l.focusNode,l.focusOffset))return;let h=!1;if((l.extend||e==t)&&!c){l.collapse(o.node,o.offset);try{e!=t&&l.extend(a.node,a.offset),h=!0}catch(e){}}if(!h){if(e>t){let e=o;o=a,a=e}let n=document.createRange();n.setEnd(a.node,a.offset),n.setStart(o.node,o.offset),l.removeAllRanges(),l.addRange(n)}}ignoreMutation(e){return!this.contentDOM&&"selection"!=e.type}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,r=0;r<this.children.length;r++){let i=this.children[r],s=n+i.size;if(n==s?e<=s&&t>=n:e<s&&t>n){let r=n+i.border,o=s-i.border;if(e>=r&&t<=o)return this.dirty=e==n||t==s?2:1,void(e!=r||t!=o||!i.contentLost&&i.dom.parentNode==this.contentDOM?i.markDirty(e-r,t-r):i.dirty=3);i.dirty=i.dom!=i.contentDOM||i.dom.parentNode!=this.contentDOM||i.children.length?3:2}n=s}this.dirty=2}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=1==e?2:1;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}}class Yr extends Gr{constructor(e,t,n,r){let i,s=t.type.toDOM;if("function"==typeof s&&(s=s(n,(()=>i?i.parent?i.parent.posBeforeChild(i):void 0:r))),!t.type.spec.raw){if(1!=s.nodeType){let e=document.createElement("span");e.appendChild(s),s=e}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=t,this.widget=t,i=this}matchesWidget(e){return 0==this.dirty&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return!!t&&t(e)}ignoreMutation(e){return"selection"!=e.type||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}}class Xr extends Gr{constructor(e,t,n,r){super(e,[],t,null),this.textDOM=n,this.text=r}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return"characterData"===e.type&&e.target.nodeValue==e.oldValue}}class Zr extends Gr{constructor(e,t,n,r){super(e,[],n,r),this.mark=t}static create(e,t,n,r){let i=r.nodeViews[t.type.name],s=i&&i(t,r,n);return s&&s.dom||(s=Vt.renderSpec(document,t.type.spec.toDOM(t,n))),new Zr(e,t,s.dom,s.contentDOM||s.dom)}parseRule(){return 3&this.dirty||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM||void 0}}matchesMark(e){return 3!=this.dirty&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),0!=this.dirty){let e=this.parent;for(;!e.node;)e=e.parent;e.dirty<this.dirty&&(e.dirty=this.dirty),this.dirty=0}}slice(e,t,n){let r=Zr.create(this.parent,this.mark,!0,n),i=this.children,s=this.size;t<s&&(i=mi(i,t,s,n)),e>0&&(i=mi(i,0,e,n));for(let e=0;e<i.length;e++)i[e].parent=r;return r.children=i,r}}class Qr extends Gr{constructor(e,t,n,r,i,s,o,a,l){super(e,[],i,s),this.node=t,this.outerDeco=n,this.innerDeco=r,this.nodeDOM=o,s&&this.updateChildren(a,l)}static create(e,t,n,r,i,s){let o,a=i.nodeViews[t.type.name],l=a&&a(t,i,(()=>o?o.parent?o.parent.posBeforeChild(o):void 0:s),n,r),c=l&&l.dom,h=l&&l.contentDOM;if(t.isText)if(c){if(3!=c.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else c=document.createTextNode(t.text);else c||({dom:c,contentDOM:h}=Vt.renderSpec(document,t.type.spec.toDOM(t)));h||t.isText||"BR"==c.nodeName||(c.hasAttribute("contenteditable")||(c.contentEditable="false"),t.type.spec.draggable&&(c.draggable=!0));let d=c;return c=hi(c,n,t),l?o=new ri(e,t,n,r,c,h||null,d,l,i,s+1):t.isText?new ti(e,t,n,r,c,d,i):new Qr(e,t,n,r,c,h||null,d,i,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if("pre"==this.node.type.whitespace&&(e.preserveWhitespace="full"),this.contentDOM)if(this.contentLost){for(let t=this.children.length-1;t>=0;t--){let n=this.children[t];if(this.dom.contains(n.dom.parentNode)){e.contentElement=n.dom.parentNode;break}}e.contentElement||(e.getContent=()=>Ve.empty)}else e.contentElement=this.contentDOM;else e.getContent=()=>this.node.content;return e}matchesNode(e,t,n){return 0==this.dirty&&e.eq(this.node)&&di(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let n=this.node.inlineContent,r=t,i=e.composing?this.localCompositionInfo(e,t):null,s=i&&i.pos>-1?i:null,o=i&&i.pos<0,a=new pi(this,s&&s.node,e);!function(e,t,n,r){let i=t.locals(e),s=0;if(0==i.length){for(let n=0;n<e.childCount;n++){let o=e.child(n);r(o,i,t.forChild(s,o),n),s+=o.nodeSize}return}let o=0,a=[],l=null;for(let c=0;;){if(o<i.length&&i[o].to==s){let e,t=i[o++];for(;o<i.length&&i[o].to==s;)(e||(e=[t])).push(i[o++]);if(e){e.sort(fi);for(let t=0;t<e.length;t++)n(e[t],c,!!l)}else n(t,c,!!l)}let h,d;if(l)d=-1,h=l,l=null;else{if(!(c<e.childCount))break;d=c,h=e.child(c++)}for(let e=0;e<a.length;e++)a[e].to<=s&&a.splice(e--,1);for(;o<i.length&&i[o].from<=s&&i[o].to>s;)a.push(i[o++]);let u=s+h.nodeSize;if(h.isText){let e=u;o<i.length&&i[o].from<e&&(e=i[o].from);for(let t=0;t<a.length;t++)a[t].to<e&&(e=a[t].to);e<u&&(l=h.cut(e-s),h=h.cut(0,e-s),u=e,d=-1)}let p=h.isInline&&!h.isLeaf?a.filter((e=>!e.inline)):a.slice();r(h,p,t.forChild(s,h),d),s=u}}(this.node,this.innerDeco,((t,i,s)=>{t.spec.marks?a.syncToMarks(t.spec.marks,n,e):t.type.side>=0&&!s&&a.syncToMarks(i==this.node.childCount?Ke.none:this.node.child(i).marks,n,e),a.placeWidget(t,e,r)}),((t,s,l,c)=>{let h;a.syncToMarks(t.marks,n,e),a.findNodeMatch(t,s,l,c)||o&&e.state.selection.from>r&&e.state.selection.to<r+t.nodeSize&&(h=a.findIndexWithChild(i.node))>-1&&a.updateNodeAt(t,s,l,h,e)||a.updateNextNode(t,s,l,e,c)||a.addNode(t,s,l,e,r),r+=t.nodeSize})),a.syncToMarks([],n,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||2==this.dirty)&&(s&&this.protectLocalComposition(e,s),ii(this.contentDOM,this.children,e),kr&&function(e){if("UL"==e.nodeName||"OL"==e.nodeName){let t=e.style.cssText;e.style.cssText=t+"; list-style: square !important",window.getComputedStyle(e).listStyle,e.style.cssText=t}}(this.dom))}localCompositionInfo(e,t){let{from:n,to:r}=e.state.selection;if(!(e.state.selection instanceof In)||n<t||r>t+this.node.content.size)return null;let i=e.domSelectionRange(),s=function(e,t){for(;;){if(3==e.nodeType)return e;if(1==e.nodeType&&t>0){if(e.childNodes.length>t&&3==e.childNodes[t].nodeType)return e.childNodes[t];t=sr(e=e.childNodes[t-1])}else{if(!(1==e.nodeType&&t<e.childNodes.length))return null;e=e.childNodes[t],t=0}}}(i.focusNode,i.focusOffset);if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let e=s.nodeValue,i=function(e,t,n,r){for(let i=0,s=0;i<e.childCount&&s<=r;){let o=e.child(i++),a=s;if(s+=o.nodeSize,!o.isText)continue;let l=o.text;for(;i<e.childCount;){let t=e.child(i++);if(s+=t.nodeSize,!t.isText)break;l+=t.text}if(s>=n){let e=a<r?l.lastIndexOf(t,r-a-1):-1;if(e>=0&&e+t.length+a>=n)return a+e;if(n==r&&l.length>=r+t.length-a&&l.slice(r-a,r-a+t.length)==t)return r}}return-1}(this.node.content,e,n-t,r-t);return i<0?null:{node:s,pos:i,text:e}}return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:n,text:r}){if(this.getDesc(t))return;let i=t;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let s=new Xr(this,i,t,r);e.input.compositionNodes.push(s),this.children=mi(this.children,n,n+r.length,e,s)}update(e,t,n,r){return!(3==this.dirty||!e.sameMarkup(this.node))&&(this.updateInner(e,t,n,r),!0)}updateInner(e,t,n,r){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=0}updateOuterDeco(e){if(di(e,this.outerDeco))return;let t=1!=this.nodeDOM.nodeType,n=this.dom;this.dom=li(this.dom,this.nodeDOM,ai(this.outerDeco,this.node,t),ai(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){1==this.nodeDOM.nodeType&&this.nodeDOM.classList.add("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||(this.dom.draggable=!0)}deselectNode(){1==this.nodeDOM.nodeType&&this.nodeDOM.classList.remove("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||this.dom.removeAttribute("draggable")}get domAtom(){return this.node.isAtom}}function ei(e,t,n,r,i){return hi(r,t,e),new Qr(void 0,e,t,n,r,r,r,i,0)}class ti extends Qr{constructor(e,t,n,r,i,s,o){super(e,t,n,r,i,null,s,o,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,r){return!(3==this.dirty||0!=this.dirty&&!this.inParent()||!e.sameMarkup(this.node))&&(this.updateOuterDeco(t),0==this.dirty&&e.text==this.node.text||e.text==this.nodeDOM.nodeValue||(this.nodeDOM.nodeValue=e.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=e,this.dirty=0,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return"characterData"!=e.type&&"selection"!=e.type}slice(e,t,n){let r=this.node.cut(e,t),i=document.createTextNode(r.text);return new ti(this.parent,r,this.outerDeco,this.innerDeco,i,i,n)}markDirty(e,t){super.markDirty(e,t),this.dom==this.nodeDOM||0!=e&&t!=this.nodeDOM.nodeValue.length||(this.dirty=3)}get domAtom(){return!1}}class ni extends Gr{parseRule(){return{ignore:!0}}matchesHack(e){return 0==this.dirty&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return"IMG"==this.dom.nodeName}}class ri extends Qr{constructor(e,t,n,r,i,s,o,a,l,c){super(e,t,n,r,i,s,o,l,c),this.spec=a}update(e,t,n,r){if(3==this.dirty)return!1;if(this.spec.update){let i=this.spec.update(e,t,n);return i&&this.updateInner(e,t,n,r),i}return!(!this.contentDOM&&!e.isLeaf)&&super.update(e,t,n,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,r){this.spec.setSelection?this.spec.setSelection(e,t,n):super.setSelection(e,t,n,r)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return!!this.spec.stopEvent&&this.spec.stopEvent(e)}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function ii(e,t,n){let r=e.firstChild,i=!1;for(let s=0;s<t.length;s++){let o=t[s],a=o.dom;if(a.parentNode==e){for(;a!=r;)r=ui(r),i=!0;r=r.nextSibling}else i=!0,e.insertBefore(a,r);if(o instanceof Zr){let t=r?r.previousSibling:e.lastChild;ii(o.contentDOM,o.children,n),r=t?t.nextSibling:e.firstChild}}for(;r;)r=ui(r),i=!0;i&&n.trackWrites==e&&(n.trackWrites=null)}const si=function(e){e&&(this.nodeName=e)};si.prototype=Object.create(null);const oi=[new si];function ai(e,t,n){if(0==e.length)return oi;let r=n?oi[0]:new si,i=[r];for(let s=0;s<e.length;s++){let o=e[s].type.attrs;if(o){o.nodeName&&i.push(r=new si(o.nodeName));for(let e in o){let s=o[e];null!=s&&(n&&1==i.length&&i.push(r=new si(t.isInline?"span":"div")),"class"==e?r.class=(r.class?r.class+" ":"")+s:"style"==e?r.style=(r.style?r.style+";":"")+s:"nodeName"!=e&&(r[e]=s))}}}return i}function li(e,t,n,r){if(n==oi&&r==oi)return t;let i=t;for(let t=0;t<r.length;t++){let s=r[t],o=n[t];if(t){let t;o&&o.nodeName==s.nodeName&&i!=e&&(t=i.parentNode)&&t.nodeName.toLowerCase()==s.nodeName||(t=document.createElement(s.nodeName),t.pmIsDeco=!0,t.appendChild(i),o=oi[0]),i=t}ci(i,o||oi[0],s)}return i}function ci(e,t,n){for(let r in t)"class"==r||"style"==r||"nodeName"==r||r in n||e.removeAttribute(r);for(let r in n)"class"!=r&&"style"!=r&&"nodeName"!=r&&n[r]!=t[r]&&e.setAttribute(r,n[r]);if(t.class!=n.class){let r=t.class?t.class.split(" ").filter(Boolean):[],i=n.class?n.class.split(" ").filter(Boolean):[];for(let t=0;t<r.length;t++)-1==i.indexOf(r[t])&&e.classList.remove(r[t]);for(let t=0;t<i.length;t++)-1==r.indexOf(i[t])&&e.classList.add(i[t]);0==e.classList.length&&e.removeAttribute("class")}if(t.style!=n.style){if(t.style){let n,r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;for(;n=r.exec(t.style);)e.style.removeProperty(n[1])}n.style&&(e.style.cssText+=n.style)}}function hi(e,t,n){return li(e,e,oi,ai(t,n,1!=e.nodeType))}function di(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].type.eq(t[n].type))return!1;return!0}function ui(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}class pi{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=function(e,t){let n=t,r=n.children.length,i=e.childCount,s=new Map,o=[];e:for(;i>0;){let a;for(;;)if(r){let e=n.children[r-1];if(!(e instanceof Zr)){a=e,r--;break}n=e,r=e.children.length}else{if(n==t)break e;r=n.parent.children.indexOf(n),n=n.parent}let l=a.node;if(l){if(l!=e.child(i-1))break;--i,s.set(a,i),o.push(a)}}return{index:i,matched:s,matches:o.reverse()}}(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,n){let r=0,i=this.stack.length>>1,s=Math.min(i,e.length);for(;r<s&&(r==i-1?this.top:this.stack[r+1<<1]).matchesMark(e[r])&&!1!==e[r].type.spec.spanning;)r++;for(;r<i;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),i--;for(;i<e.length;){this.stack.push(this.top,this.index+1);let r=-1;for(let t=this.index;t<Math.min(this.index+3,this.top.children.length);t++)if(this.top.children[t].matchesMark(e[i])){r=t;break}if(r>-1)r>this.index&&(this.changed=!0,this.destroyBetween(this.index,r)),this.top=this.top.children[this.index];else{let r=Zr.create(this.top,e[i],t,n);this.top.children.splice(this.index,0,r),this.top=r,this.changed=!0}this.index=0,i++}}findNodeMatch(e,t,n,r){let i,s=-1;if(r>=this.preMatch.index&&(i=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&i.matchesNode(e,t,n))s=this.top.children.indexOf(i,this.index);else for(let r=this.index,i=Math.min(this.top.children.length,r+5);r<i;r++){let i=this.top.children[r];if(i.matchesNode(e,t,n)&&!this.preMatch.matched.has(i)){s=r;break}}return!(s<0)&&(this.destroyBetween(this.index,s),this.index++,!0)}updateNodeAt(e,t,n,r,i){let s=this.top.children[r];return 3==s.dirty&&s.dom==s.contentDOM&&(s.dirty=2),!!s.update(e,t,n,i)&&(this.destroyBetween(this.index,r),this.index++,!0)}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let t=e.pmViewDesc;if(t)for(let e=this.index;e<this.top.children.length;e++)if(this.top.children[e]==t)return e;return-1}e=t}}updateNextNode(e,t,n,r,i){for(let s=this.index;s<this.top.children.length;s++){let o=this.top.children[s];if(o instanceof Qr){let a=this.preMatch.matched.get(o);if(null!=a&&a!=i)return!1;let l=o.dom;if(!(this.lock&&(l==this.lock||1==l.nodeType&&l.contains(this.lock.parentNode))&&!(e.isText&&o.node&&o.node.isText&&o.nodeDOM.nodeValue==e.text&&3!=o.dirty&&di(t,o.outerDeco)))&&o.update(e,t,n,r))return this.destroyBetween(this.index,s),o.dom!=l&&(this.changed=!0),this.index++,!0;break}}return!1}addNode(e,t,n,r,i){this.top.children.splice(this.index++,0,Qr.create(this.top,e,t,n,r,i)),this.changed=!0}placeWidget(e,t,n){let r=this.index<this.top.children.length?this.top.children[this.index]:null;if(!r||!r.matchesWidget(e)||e!=r.widget&&r.widget.type.toDOM.parentNode){let r=new Yr(this.top,e,t,n);this.top.children.splice(this.index++,0,r),this.changed=!0}else this.index++}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof Zr;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof ti)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((xr||br)&&e&&"false"==e.dom.contentEditable&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let n=document.createElement(e);"IMG"==e&&(n.className="ProseMirror-separator",n.alt=""),"BR"==e&&(n.className="ProseMirror-trailingBreak");let r=new ni(this.top,[],n,null);t!=this.top?t.children.push(r):t.children.splice(this.index++,0,r),this.changed=!0}}}function fi(e,t){return e.type.side-t.type.side}function mi(e,t,n,r,i){let s=[];for(let o=0,a=0;o<e.length;o++){let l=e[o],c=a,h=a+=l.size;c>=n||h<=t?s.push(l):(c<t&&s.push(l.slice(0,t-c,r)),i&&(s.push(i),i=void 0),h>n&&s.push(l.slice(n-c,l.size,r)))}return s}function gi(e,t=null){let n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;let i=e.docView.nearestDesc(n.focusNode),s=i&&0==i.size,o=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let a,l,c=r.resolve(o);if(ar(n)){for(a=c;i&&!i.node;)i=i.parent;let e=i.node;if(i&&e.isAtom&&Bn.isSelectable(e)&&i.parent&&(!e.isInline||!function(e,t,n){for(let r=0==t,i=t==sr(e);r||i;){if(e==n)return!0;let t=Zn(e);if(!(e=e.parentNode))return!1;r=r&&0==t,i=i&&t==sr(e)}}(n.focusNode,n.focusOffset,i.dom))){let e=i.posBefore;l=new Bn(o==e?c:r.resolve(e))}}else{let t=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(t<0)return null;a=r.resolve(t)}if(!l){l=Oi(e,a,c,"pointer"==t||e.state.selection.head<c.pos&&!s?1:-1)}return l}function yi(e){return e.editable?e.hasFocus():Ci(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function vi(e,t=!1){let n=e.state.selection;if(Si(e,n),yi(e)){if(!t&&e.input.mouseDown&&e.input.mouseDown.allowDefault&&br){let t=e.domSelectionRange(),n=e.domObserver.currentSelection;if(t.anchorNode&&n.anchorNode&&nr(t.anchorNode,t.anchorOffset,n.anchorNode,n.anchorOffset))return e.input.mouseDown.delayedSelectionSync=!0,void e.domObserver.setCurSelection()}if(e.domObserver.disconnectSelection(),e.cursorWrapper)!function(e){let t=e.domSelection(),n=document.createRange(),r=e.cursorWrapper.dom,i="IMG"==r.nodeName;i?n.setEnd(r.parentNode,Zn(r)+1):n.setEnd(r,0);n.collapse(!1),t.removeAllRanges(),t.addRange(n),!i&&!e.state.selection.visible&&mr&&gr<=11&&(r.disabled=!0,r.disabled=!1)}(e);else{let r,i,{anchor:s,head:o}=n;!bi||n instanceof In||(n.$from.parent.inlineContent||(r=wi(e,n.from)),n.empty||n.$from.parent.inlineContent||(i=wi(e,n.to))),e.docView.setSelection(s,o,e.root,t),bi&&(r&&ki(r),i&&ki(i)),n.visible?e.dom.classList.remove("ProseMirror-hideselection"):(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&function(e){let t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.input.hideSelectionGuard);let n=e.domSelectionRange(),r=n.anchorNode,i=n.anchorOffset;t.addEventListener("selectionchange",e.input.hideSelectionGuard=()=>{n.anchorNode==r&&n.anchorOffset==i||(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout((()=>{yi(e)&&!e.state.selection.visible||e.dom.classList.remove("ProseMirror-hideselection")}),20))})}(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}const bi=xr||br&&wr<63;function wi(e,t){let{node:n,offset:r}=e.docView.domFromPos(t,0),i=r<n.childNodes.length?n.childNodes[r]:null,s=r?n.childNodes[r-1]:null;if(xr&&i&&"false"==i.contentEditable)return xi(i);if(!(i&&"false"!=i.contentEditable||s&&"false"!=s.contentEditable)){if(i)return xi(i);if(s)return xi(s)}}function xi(e){return e.contentEditable="true",xr&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function ki(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function Si(e,t){if(t instanceof Bn){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(Mi(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else Mi(e)}function Mi(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function Oi(e,t,n,r){return e.someProp("createSelectionBetween",(r=>r(e,t,n)))||In.between(t,n,r)}function Ai(e){return!(e.editable&&!e.hasFocus())&&Ci(e)}function Ci(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(3==t.anchorNode.nodeType?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(3==t.focusNode.nodeType?t.focusNode.parentNode:t.focusNode))}catch(e){return!1}}function Ei(e,t){let{$anchor:n,$head:r}=e.selection,i=t>0?n.max(r):n.min(r),s=i.parent.inlineContent?i.depth?e.doc.resolve(t>0?i.after():i.before()):null:i;return s&&Tn.findFrom(s,t)}function Ti(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function Ni(e,t,n){let r=e.state.selection;if(!(r instanceof In)){if(r instanceof Bn&&r.node.isInline)return Ti(e,new In(t>0?r.$to:r.$from));{let n=Ei(e.state,t);return!!n&&Ti(e,n)}}if(!r.empty||n.indexOf("s")>-1)return!1;if(e.endOfTextblock(t>0?"right":"left")){let n=Ei(e.state,t);return!!(n&&n instanceof Bn)&&Ti(e,n)}if(!(Sr&&n.indexOf("m")>-1)){let n,i=r.$head,s=i.textOffset?null:t<0?i.nodeBefore:i.nodeAfter;if(!s||s.isText)return!1;let o=t<0?i.pos-s.nodeSize:i.pos;return!!(s.isAtom||(n=e.docView.descAt(o))&&!n.contentDOM)&&(Bn.isSelectable(s)?Ti(e,new Bn(t<0?e.state.doc.resolve(i.pos-s.nodeSize):i)):!!Or&&Ti(e,new In(e.state.doc.resolve(t<0?o:o+s.nodeSize))))}}function Di(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function $i(e){let t=e.pmViewDesc;return t&&0==t.size&&(e.nextSibling||"BR"!=e.nodeName)}function Ii(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i,s,o=!1;for(yr&&1==n.nodeType&&r<Di(n)&&$i(n.childNodes[r])&&(o=!0);;)if(r>0){if(1!=n.nodeType)break;{let e=n.childNodes[r-1];if($i(e))i=n,s=--r;else{if(3!=e.nodeType)break;n=e,r=n.nodeValue.length}}}else{if(Bi(n))break;{let t=n.previousSibling;for(;t&&$i(t);)i=n.parentNode,s=Zn(t),t=t.previousSibling;if(t)n=t,r=Di(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}}o?Fi(e,n,r):i&&Fi(e,i,s)}function Ri(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i,s,o=Di(n);for(;;)if(r<o){if(1!=n.nodeType)break;if(!$i(n.childNodes[r]))break;i=n,s=++r}else{if(Bi(n))break;{let t=n.nextSibling;for(;t&&$i(t);)i=t.parentNode,s=Zn(t)+1,t=t.nextSibling;if(t)n=t,r=0,o=Di(n);else{if(n=n.parentNode,n==e.dom)break;r=o=0}}}i&&Fi(e,i,s)}function Bi(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function Fi(e,t,n){let r=e.domSelection();if(ar(r)){let e=document.createRange();e.setEnd(t,n),e.setStart(t,n),r.removeAllRanges(),r.addRange(e)}else r.extend&&r.extend(t,n);e.domObserver.setCurSelection();let{state:i}=e;setTimeout((()=>{e.state==i&&vi(e)}),50)}function Pi(e,t,n){let r=e.state.selection;if(r instanceof In&&!r.empty||n.indexOf("s")>-1)return!1;if(Sr&&n.indexOf("m")>-1)return!1;let{$from:i,$to:s}=r;if(!i.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){let n=Ei(e.state,t);if(n&&n instanceof Bn)return Ti(e,n)}if(!i.parent.inlineContent){let n=t<0?i:s,o=r instanceof Pn?Tn.near(n,t):Tn.findFrom(n,t);return!!o&&Ti(e,o)}return!1}function Li(e,t){if(!(e.state.selection instanceof In))return!0;let{$head:n,$anchor:r,empty:i}=e.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;let s=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(s&&!s.isText){let r=e.state.tr;return t<0?r.delete(n.pos-s.nodeSize,n.pos):r.delete(n.pos,n.pos+s.nodeSize),e.dispatch(r),!0}return!1}function Vi(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function zi(e,t){let n=t.keyCode,r=function(e){let t="";return e.ctrlKey&&(t+="c"),e.metaKey&&(t+="m"),e.altKey&&(t+="a"),e.shiftKey&&(t+="s"),t}(t);return 8==n||Sr&&72==n&&"c"==r?Li(e,-1)||Ii(e):46==n||Sr&&68==n&&"c"==r?Li(e,1)||Ri(e):13==n||27==n||(37==n||Sr&&66==n&&"c"==r?Ni(e,-1,r)||Ii(e):39==n||Sr&&70==n&&"c"==r?Ni(e,1,r)||Ri(e):38==n||Sr&&80==n&&"c"==r?Pi(e,-1,r)||Ii(e):40==n||Sr&&78==n&&"c"==r?function(e){if(!xr||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&1==t.nodeType&&0==n&&t.firstChild&&"false"==t.firstChild.contentEditable){let n=t.firstChild;Vi(e,n,"true"),setTimeout((()=>Vi(e,n,"false")),20)}return!1}(e)||Pi(e,1,r)||Ri(e):r==(Sr?"m":"c")&&(66==n||73==n||89==n||90==n))}function ji(e,t){e.someProp("transformCopied",(e=>{t=e(t)}));let n=[],{content:r,openStart:i,openEnd:s}=t;for(;i>1&&s>1&&1==r.childCount&&1==r.firstChild.childCount;){i--,s--;let e=r.firstChild;n.push(e.type.name,e.attrs!=e.type.defaultAttrs?e.attrs:null),r=e.content}let o=e.someProp("clipboardSerializer")||Vt.fromSchema(e.state.schema),a=Xi(),l=a.createElement("div");l.appendChild(o.serializeFragment(r,{document:a}));let c,h=l.firstChild,d=0;for(;h&&1==h.nodeType&&(c=Gi[h.nodeName.toLowerCase()]);){for(let e=c.length-1;e>=0;e--){let t=a.createElement(c[e]);for(;l.firstChild;)t.appendChild(l.firstChild);l.appendChild(t),d++}h=l.firstChild}h&&1==h.nodeType&&h.setAttribute("data-pm-slice",`${i} ${s}${d?` -${d}`:""} ${JSON.stringify(n)}`);let u=e.someProp("clipboardTextSerializer",(e=>e(t)))||t.content.textBetween(0,t.content.size,"\n\n");return{dom:l,text:u}}function _i(e,t,n,r,i){let s,o,a=i.parent.type.spec.code;if(!n&&!t)return null;let l=t&&(r||a||!n);if(l){if(e.someProp("transformPastedText",(e=>{t=e(t,a||r)})),a)return t?new He(Ve.from(e.state.schema.text(t.replace(/\r\n?/g,"\n"))),0,0):He.empty;let n=e.someProp("clipboardTextParser",(e=>e(t,i,r)));if(n)o=n;else{let n=i.marks(),{schema:r}=e.state,o=Vt.fromSchema(r);s=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach((e=>{let t=s.appendChild(document.createElement("p"));e&&t.appendChild(o.serializeNode(r.text(e,n)))}))}}else e.someProp("transformPastedHTML",(e=>{n=e(n)})),s=function(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n,r=Xi().createElement("div"),i=/<([a-z][^>\s]+)/i.exec(e);(n=i&&Gi[i[1].toLowerCase()])&&(e=n.map((e=>"<"+e+">")).join("")+e+n.map((e=>"</"+e+">")).reverse().join(""));if(r.innerHTML=e,n)for(let e=0;e<n.length;e++)r=r.querySelector(n[e])||r;return r}(n),Or&&function(e){let t=e.querySelectorAll(br?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<t.length;n++){let r=t[n];1==r.childNodes.length&&" "==r.textContent&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),r)}}(s);let c=s&&s.querySelector("[data-pm-slice]"),h=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(h&&h[3])for(let e=+h[3];e>0&&s.firstChild;e--)s=s.firstChild;if(!o){let t=e.someProp("clipboardParser")||e.someProp("domParser")||Tt.fromSchema(e.state.schema);o=t.parseSlice(s,{preserveWhitespace:!(!l&&!h),context:i,ruleFromNode:e=>"BR"!=e.nodeName||e.nextSibling||!e.parentNode||Ki.test(e.parentNode.nodeName)?null:{ignore:!0}})}if(h)o=function(e,t){if(!e.size)return e;let n,r=e.content.firstChild.type.schema;try{n=JSON.parse(t)}catch(t){return e}let{content:i,openStart:s,openEnd:o}=e;for(let e=n.length-2;e>=0;e-=2){let t=r.nodes[n[e]];if(!t||t.hasRequiredAttrs())break;i=Ve.from(t.create(n[e+1],i)),s++,o++}return new He(i,s,o)}(Ui(o,+h[1],+h[2]),h[4]);else if(o=He.maxOpen(function(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let r,i=t.node(n).contentMatchAt(t.index(n)),s=[];if(e.forEach((e=>{if(!s)return;let t,n=i.findWrapping(e.type);if(!n)return s=null;if(t=s.length&&r.length&&Hi(n,r,e,s[s.length-1],0))s[s.length-1]=t;else{s.length&&(s[s.length-1]=qi(s[s.length-1],r.length));let t=Wi(e,n);s.push(t),i=i.matchType(t.type),r=n}})),s)return Ve.from(s)}return e}(o.content,i),!0),o.openStart||o.openEnd){let e=0,t=0;for(let t=o.content.firstChild;e<o.openStart&&!t.type.spec.isolating;e++,t=t.firstChild);for(let e=o.content.lastChild;t<o.openEnd&&!e.type.spec.isolating;t++,e=e.lastChild);o=Ui(o,e,t)}return e.someProp("transformPasted",(e=>{o=e(o)})),o}const Ki=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function Wi(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,Ve.from(e));return e}function Hi(e,t,n,r,i){if(i<e.length&&i<t.length&&e[i]==t[i]){let s=Hi(e,t,n,r.lastChild,i+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(i==e.length-1?n.type:e[i+1]))return r.copy(r.content.append(Ve.from(Wi(n,e,i+1))))}}function qi(e,t){if(0==t)return e;let n=e.content.replaceChild(e.childCount-1,qi(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(Ve.empty,!0);return e.copy(n.append(r))}function Ji(e,t,n,r,i,s){let o=t<0?e.firstChild:e.lastChild,a=o.content;return i<r-1&&(a=Ji(a,t,n,r,i+1,s)),i>=n&&(a=t<0?o.contentMatchAt(0).fillBefore(a,e.childCount>1||s<=i).append(a):a.append(o.contentMatchAt(o.childCount).fillBefore(Ve.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,o.copy(a))}function Ui(e,t,n){return t<e.openStart&&(e=new He(Ji(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new He(Ji(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}const Gi={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let Yi=null;function Xi(){return Yi||(Yi=document.implementation.createHTMLDocument("title"))}const Zi={},Qi={},es={touchstart:!0,touchmove:!0};class ts{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastAndroidDelete=0,this.composing=!1,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function ns(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function rs(e){e.someProp("handleDOMEvents",(t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>is(e,t))}))}function is(e,t){return e.someProp("handleDOMEvents",(n=>{let r=n[t.type];return!!r&&(r(e,t)||t.defaultPrevented)}))}function ss(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||11==n.nodeType||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}function as(e){return{left:e.clientX,top:e.clientY}}function ls(e,t,n,r,i){if(-1==r)return!1;let s=e.state.doc.resolve(r);for(let r=s.depth+1;r>0;r--)if(e.someProp(t,(t=>r>s.depth?t(e,n,s.nodeAfter,s.before(r),i,!0):t(e,n,s.node(r),s.before(r),i,!1))))return!0;return!1}function cs(e,t,n){e.focused||e.focus();let r=e.state.tr.setSelection(t);"pointer"==n&&r.setMeta("pointer",!0),e.dispatch(r)}function hs(e,t,n,r,i){return ls(e,"handleClickOn",t,n,r)||e.someProp("handleClick",(n=>n(e,t,r)))||(i?function(e,t){if(-1==t)return!1;let n,r,i=e.state.selection;i instanceof Bn&&(n=i.node);let s=e.state.doc.resolve(t);for(let e=s.depth+1;e>0;e--){let t=e>s.depth?s.nodeAfter:s.node(e);if(Bn.isSelectable(t)){r=n&&i.$from.depth>0&&e>=i.$from.depth&&s.before(i.$from.depth+1)==i.$from.pos?s.before(i.$from.depth):s.before(e);break}}return null!=r&&(cs(e,Bn.create(e.state.doc,r),"pointer"),!0)}(e,n):function(e,t){if(-1==t)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return!!(r&&r.isAtom&&Bn.isSelectable(r))&&(cs(e,new Bn(n),"pointer"),!0)}(e,n))}function ds(e,t,n,r){return ls(e,"handleDoubleClickOn",t,n,r)||e.someProp("handleDoubleClick",(n=>n(e,t,r)))}function us(e,t,n,r){return ls(e,"handleTripleClickOn",t,n,r)||e.someProp("handleTripleClick",(n=>n(e,t,r)))||function(e,t,n){if(0!=n.button)return!1;let r=e.state.doc;if(-1==t)return!!r.inlineContent&&(cs(e,In.create(r,0,r.content.size),"pointer"),!0);let i=r.resolve(t);for(let t=i.depth+1;t>0;t--){let n=t>i.depth?i.nodeAfter:i.node(t),s=i.before(t);if(n.inlineContent)cs(e,In.create(r,s+1,s+1+n.content.size),"pointer");else{if(!Bn.isSelectable(n))continue;cs(e,Bn.create(r,s),"pointer")}return!0}}(e,n,r)}function ps(e){return ws(e)}Qi.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=16==n.keyCode||n.shiftKey,!gs(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!Mr||!br||13!=n.keyCode))if(229!=n.keyCode&&e.domObserver.forceFlush(),!kr||13!=n.keyCode||n.ctrlKey||n.altKey||n.metaKey)e.someProp("handleKeyDown",(t=>t(e,n)))||zi(e,n)?n.preventDefault():ns(e,"key");else{let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout((()=>{e.input.lastIOSEnter==t&&(e.someProp("handleKeyDown",(t=>t(e,lr(13,"Enter")))),e.input.lastIOSEnter=0)}),200)}},Qi.keyup=(e,t)=>{16==t.keyCode&&(e.input.shiftKey=!1)},Qi.keypress=(e,t)=>{let n=t;if(gs(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||Sr&&n.metaKey)return;if(e.someProp("handleKeyPress",(t=>t(e,n))))return void n.preventDefault();let r=e.state.selection;if(!(r instanceof In&&r.$from.sameParent(r.$to))){let t=String.fromCharCode(n.charCode);e.someProp("handleTextInput",(n=>n(e,r.$from.pos,r.$to.pos,t)))||e.dispatch(e.state.tr.insertText(t).scrollIntoView()),n.preventDefault()}};const fs=Sr?"metaKey":"ctrlKey";Zi.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=ps(e),i=Date.now(),s="singleClick";i-e.input.lastClick.time<500&&function(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}(n,e.input.lastClick)&&!n[fs]&&("singleClick"==e.input.lastClick.type?s="doubleClick":"doubleClick"==e.input.lastClick.type&&(s="tripleClick")),e.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:s};let o=e.posAtCoords(as(n));o&&("singleClick"==s?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new ms(e,o,n,!!r)):("doubleClick"==s?ds:us)(e,o.pos,o.inside,n)?n.preventDefault():ns(e,"pointer"))};class ms{constructor(e,t,n,r){let i,s;if(this.view=e,this.pos=t,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!n[fs],this.allowDefault=n.shiftKey,t.inside>-1)i=e.state.doc.nodeAt(t.inside),s=t.inside;else{let n=e.state.doc.resolve(t.pos);i=n.parent,s=n.depth?n.before():0}const o=r?null:n.target,a=o?e.docView.nearestDesc(o,!0):null;this.target=a?a.dom:null;let{selection:l}=e.state;(0==n.button&&i.type.spec.draggable&&!1!==i.type.spec.selectable||l instanceof Bn&&l.from<=s&&l.to>s)&&(this.mightDrag={node:i,pos:s,addAttr:!(!this.target||this.target.draggable),setUneditable:!(!this.target||!yr||this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout((()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")}),20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),ns(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout((()=>vi(this.view))),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(as(e))),this.updateAllowDefault(e),this.allowDefault||!t?ns(this.view,"pointer"):hs(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():0==e.button&&(this.flushed||xr&&this.mightDrag&&!this.mightDrag.node.isAtom||br&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(cs(this.view,Tn.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):ns(this.view,"pointer")}move(e){this.updateAllowDefault(e),ns(this.view,"pointer"),0==e.buttons&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}function gs(e,t){return!!e.composing||!!(xr&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500)&&(e.input.compositionEndedAt=-2e8,!0)}Zi.touchstart=e=>{e.input.lastTouch=Date.now(),ps(e),ns(e,"pointer")},Zi.touchmove=e=>{e.input.lastTouch=Date.now(),ns(e,"pointer")},Zi.contextmenu=e=>ps(e);const ys=Mr?5e3:-1;function vs(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout((()=>ws(e)),t))}function bs(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=function(){let e=document.createEvent("Event");return e.initEvent("event",!0,!0),e.timeStamp}());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function ws(e,t=!1){if(!(Mr&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),bs(e),t||e.docView&&e.docView.dirty){let t=gi(e);return t&&!t.eq(e.state.selection)?e.dispatch(e.state.tr.setSelection(t)):e.updateState(e.state),!0}return!1}}Qi.compositionstart=Qi.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$from;if(t.selection.empty&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some((e=>!1===e.type.spec.inclusive))))e.markCursor=e.state.storedMarks||n.marks(),ws(e,!0),e.markCursor=null;else if(ws(e),yr&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelectionRange();for(let n=t.focusNode,r=t.focusOffset;n&&1==n.nodeType&&0!=r;){let t=r<0?n.lastChild:n.childNodes[r-1];if(!t)break;if(3==t.nodeType){e.domSelection().collapse(t,t.nodeValue.length);break}n=t,r=-1}}e.input.composing=!0}vs(e,ys)},Qi.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,vs(e,20))};const xs=mr&&gr<15||kr&&Ar<604;function ks(e,t,n,r){let i=_i(e,t,n,e.input.shiftKey,e.state.selection.$from);if(e.someProp("handlePaste",(t=>t(e,r,i||He.empty))))return!0;if(!i)return!1;let s=function(e){return 0==e.openStart&&0==e.openEnd&&1==e.content.childCount?e.content.firstChild:null}(i),o=s?e.state.tr.replaceSelectionWith(s,e.input.shiftKey):e.state.tr.replaceSelection(i);return e.dispatch(o.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}Zi.copy=Qi.cut=(e,t)=>{let n=t,r=e.state.selection,i="cut"==n.type;if(r.empty)return;let s=xs?null:n.clipboardData,o=r.content(),{dom:a,text:l}=ji(e,o);s?(n.preventDefault(),s.clearData(),s.setData("text/html",a.innerHTML),s.setData("text/plain",l)):function(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(t),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout((()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()}),50)}(e,a),i&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))},Qi.paste=(e,t)=>{let n=t;if(e.composing&&!Mr)return;let r=xs?null:n.clipboardData;r&&ks(e,r.getData("text/plain"),r.getData("text/html"),n)?n.preventDefault():function(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus(),setTimeout((()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?ks(e,r.value,null,t):ks(e,r.textContent,r.innerHTML,t)}),50)}(e,n)};class Ss{constructor(e,t){this.slice=e,this.move=t}}const Ms=Sr?"altKey":"ctrlKey";Zi.dragstart=(e,t)=>{let n=t,r=e.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=e.state.selection,s=i.empty?null:e.posAtCoords(as(n));if(s&&s.pos>=i.from&&s.pos<=(i instanceof Bn?i.to-1:i.to));else if(r&&r.mightDrag)e.dispatch(e.state.tr.setSelection(Bn.create(e.state.doc,r.mightDrag.pos)));else if(n.target&&1==n.target.nodeType){let t=e.docView.nearestDesc(n.target,!0);t&&t.node.type.spec.draggable&&t!=e.docView&&e.dispatch(e.state.tr.setSelection(Bn.create(e.state.doc,t.posBefore)))}let o=e.state.selection.content(),{dom:a,text:l}=ji(e,o);n.dataTransfer.clearData(),n.dataTransfer.setData(xs?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",xs||n.dataTransfer.setData("text/plain",l),e.dragging=new Ss(o,!n[Ms])},Zi.dragend=e=>{let t=e.dragging;window.setTimeout((()=>{e.dragging==t&&(e.dragging=null)}),50)},Qi.dragover=Qi.dragenter=(e,t)=>t.preventDefault(),Qi.drop=(e,t)=>{let n=t,r=e.dragging;if(e.dragging=null,!n.dataTransfer)return;let i=e.posAtCoords(as(n));if(!i)return;let s=e.state.doc.resolve(i.pos),o=r&&r.slice;o?e.someProp("transformPasted",(e=>{o=e(o)})):o=_i(e,n.dataTransfer.getData(xs?"Text":"text/plain"),xs?null:n.dataTransfer.getData("text/html"),!1,s);let a=!(!r||n[Ms]);if(e.someProp("handleDrop",(t=>t(e,n,o||He.empty,a))))return void n.preventDefault();if(!o)return;n.preventDefault();let l=o?fn(e.state.doc,s.pos,o):s.pos;null==l&&(l=s.pos);let c=e.state.tr;a&&c.deleteSelection();let h=c.mapping.map(l),d=0==o.openStart&&0==o.openEnd&&1==o.content.childCount,u=c.doc;if(d?c.replaceRangeWith(h,h,o.content.firstChild):c.replaceRange(h,h,o),c.doc.eq(u))return;let p=c.doc.resolve(h);if(d&&Bn.isSelectable(o.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(o.content.firstChild))c.setSelection(new Bn(p));else{let t=c.mapping.map(l);c.mapping.maps[c.mapping.maps.length-1].forEach(((e,n,r,i)=>t=i)),c.setSelection(Oi(e,p,c.doc.resolve(t)))}e.focus(),e.dispatch(c.setMeta("uiEvent","drop"))},Zi.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0,setTimeout((()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&vi(e)}),20))},Zi.blur=(e,t)=>{let n=t;e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),e.focused=!1)},Zi.beforeinput=(e,t)=>{if(br&&Mr&&"deleteContentBackward"==t.inputType){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout((()=>{if(e.input.domChangeCount!=t)return;if(e.dom.blur(),e.focus(),e.someProp("handleKeyDown",(t=>t(e,lr(8,"Backspace")))))return;let{$cursor:n}=e.state.selection;n&&n.pos>0&&e.dispatch(e.state.tr.delete(n.pos-1,n.pos).scrollIntoView())}),50)}};for(let e in Qi)Zi[e]=Qi[e];function Os(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}class As{constructor(e,t){this.toDOM=e,this.spec=t||Ds,this.side=this.spec.side||0}map(e,t,n,r){let{pos:i,deleted:s}=e.mapResult(t.from+r,this.side<0?-1:1);return s?null:new Ts(i-n,i-n,this)}valid(){return!0}eq(e){return this==e||e instanceof As&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Os(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Cs{constructor(e,t){this.attrs=e,this.spec=t||Ds}map(e,t,n,r){let i=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-n,s=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-n;return i>=s?null:new Ts(i,s,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof Cs&&Os(this.attrs,e.attrs)&&Os(this.spec,e.spec)}static is(e){return e.type instanceof Cs}destroy(){}}class Es{constructor(e,t){this.attrs=e,this.spec=t||Ds}map(e,t,n,r){let i=e.mapResult(t.from+r,1);if(i.deleted)return null;let s=e.mapResult(t.to+r,-1);return s.deleted||s.pos<=i.pos?null:new Ts(i.pos-n,s.pos-n,this)}valid(e,t){let n,{index:r,offset:i}=e.content.findIndex(t.from);return i==t.from&&!(n=e.child(r)).isText&&i+n.nodeSize==t.to}eq(e){return this==e||e instanceof Es&&Os(this.attrs,e.attrs)&&Os(this.spec,e.spec)}destroy(){}}class Ts{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(e,t){return new Ts(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,n){return this.type.map(e,this,t,n)}static widget(e,t,n){return new Ts(e,e,new As(t,n))}static inline(e,t,n,r){return new Ts(e,t,new Cs(n,r))}static node(e,t,n,r){return new Ts(e,t,new Es(n,r))}get spec(){return this.type.spec}get inline(){return this.type instanceof Cs}}const Ns=[],Ds={};class $s{constructor(e,t){this.local=e.length?e:Ns,this.children=t.length?t:Ns}static create(e,t){return t.length?Ls(t,e,0,Ds):Is}find(e,t,n){let r=[];return this.findInner(null==e?0:e,null==t?1e9:t,r,0,n),r}findInner(e,t,n,r,i){for(let s=0;s<this.local.length;s++){let o=this.local[s];o.from<=t&&o.to>=e&&(!i||i(o.spec))&&n.push(o.copy(o.from+r,o.to+r))}for(let s=0;s<this.children.length;s+=3)if(this.children[s]<t&&this.children[s+1]>e){let o=this.children[s]+1;this.children[s+2].findInner(e-o,t-o,n,r+o,i)}}map(e,t,n){return this==Is||0==e.maps.length?this:this.mapInner(e,t,0,0,n||Ds)}mapInner(e,t,n,r,i){let s;for(let o=0;o<this.local.length;o++){let a=this.local[o].map(e,n,r);a&&a.type.valid(t,a)?(s||(s=[])).push(a):i.onRemove&&i.onRemove(this.local[o].spec)}return this.children.length?function(e,t,n,r,i,s,o){let a=e.slice();for(let e=0,t=s;e<n.maps.length;e++){let r=0;n.maps[e].forEach(((e,n,s,o)=>{let l=o-s-(n-e);for(let o=0;o<a.length;o+=3){let c=a[o+1];if(c<0||e>c+t-r)continue;let h=a[o]+t-r;n>=h?a[o+1]=e<=h?-2:-1:s>=i&&l&&(a[o]+=l,a[o+1]+=l)}r+=l})),t=n.maps[e].map(t,-1)}let l=!1;for(let t=0;t<a.length;t+=3)if(a[t+1]<0){if(-2==a[t+1]){l=!0,a[t+1]=-1;continue}let c=n.map(e[t]+s),h=c-i;if(h<0||h>=r.content.size){l=!0;continue}let d=n.map(e[t+1]+s,-1)-i,{index:u,offset:p}=r.content.findIndex(h),f=r.maybeChild(u);if(f&&p==h&&p+f.nodeSize==d){let r=a[t+2].mapInner(n,f,c+1,e[t]+s+1,o);r!=Is?(a[t]=h,a[t+1]=d,a[t+2]=r):(a[t+1]=-2,l=!0)}else l=!0}if(l){let l=function(e,t,n,r,i,s,o){function a(e,t){for(let s=0;s<e.local.length;s++){let a=e.local[s].map(r,i,t);a?n.push(a):o.onRemove&&o.onRemove(e.local[s].spec)}for(let n=0;n<e.children.length;n+=3)a(e.children[n+2],e.children[n]+t+1)}for(let n=0;n<e.length;n+=3)-1==e[n+1]&&a(e[n+2],t[n]+s+1);return n}(a,e,t,n,i,s,o),c=Ls(l,r,0,o);t=c.local;for(let e=0;e<a.length;e+=3)a[e+1]<0&&(a.splice(e,3),e-=3);for(let e=0,t=0;e<c.children.length;e+=3){let n=c.children[e];for(;t<a.length&&a[t]<n;)t+=3;a.splice(t,0,c.children[e],c.children[e+1],c.children[e+2])}}return new $s(t.sort(Vs),a)}(this.children,s||[],e,t,n,r,i):s?new $s(s.sort(Vs),Ns):Is}add(e,t){return t.length?this==Is?$s.create(e,t):this.addInner(e,t,0):this}addInner(e,t,n){let r,i=0;e.forEach(((e,s)=>{let o,a=s+n;if(o=Fs(t,e,a)){for(r||(r=this.children.slice());i<r.length&&r[i]<s;)i+=3;r[i]==s?r[i+2]=r[i+2].addInner(e,o,a+1):r.splice(i,0,s,s+e.nodeSize,Ls(o,e,a+1,Ds)),i+=3}}));let s=Bs(i?Ps(t):t,-n);for(let t=0;t<s.length;t++)s[t].type.valid(e,s[t])||s.splice(t--,1);return new $s(s.length?this.local.concat(s).sort(Vs):this.local,r||this.children)}remove(e){return 0==e.length||this==Is?this:this.removeInner(e,0)}removeInner(e,t){let n=this.children,r=this.local;for(let r=0;r<n.length;r+=3){let i,s=n[r]+t,o=n[r+1]+t;for(let t,n=0;n<e.length;n++)(t=e[n])&&t.from>s&&t.to<o&&(e[n]=null,(i||(i=[])).push(t));if(!i)continue;n==this.children&&(n=this.children.slice());let a=n[r+2].removeInner(i,s+1);a!=Is?n[r+2]=a:(n.splice(r,3),r-=3)}if(r.length)for(let n,i=0;i<e.length;i++)if(n=e[i])for(let e=0;e<r.length;e++)r[e].eq(n,t)&&(r==this.local&&(r=this.local.slice()),r.splice(e--,1));return n==this.children&&r==this.local?this:r.length||n.length?new $s(r,n):Is}forChild(e,t){if(this==Is)return this;if(t.isLeaf)return $s.empty;let n,r;for(let t=0;t<this.children.length;t+=3)if(this.children[t]>=e){this.children[t]==e&&(n=this.children[t+2]);break}let i=e+1,s=i+t.content.size;for(let e=0;e<this.local.length;e++){let t=this.local[e];if(t.from<s&&t.to>i&&t.type instanceof Cs){let e=Math.max(i,t.from)-i,n=Math.min(s,t.to)-i;e<n&&(r||(r=[])).push(t.copy(e,n))}}if(r){let e=new $s(r.sort(Vs),Ns);return n?new Rs([e,n]):e}return n||Is}eq(e){if(this==e)return!0;if(!(e instanceof $s)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return zs(this.localsInner(e))}localsInner(e){if(this==Is)return Ns;if(e.inlineContent||!this.local.some(Cs.is))return this.local;let t=[];for(let e=0;e<this.local.length;e++)this.local[e].type instanceof Cs||t.push(this.local[e]);return t}}$s.empty=new $s([],[]),$s.removeOverlap=zs;const Is=$s.empty;class Rs{constructor(e){this.members=e}map(e,t){const n=this.members.map((n=>n.map(e,t,Ds)));return Rs.from(n)}forChild(e,t){if(t.isLeaf)return $s.empty;let n=[];for(let r=0;r<this.members.length;r++){let i=this.members[r].forChild(e,t);i!=Is&&(i instanceof Rs?n=n.concat(i.members):n.push(i))}return Rs.from(n)}eq(e){if(!(e instanceof Rs)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,n=!0;for(let r=0;r<this.members.length;r++){let i=this.members[r].localsInner(e);if(i.length)if(t){n&&(t=t.slice(),n=!1);for(let e=0;e<i.length;e++)t.push(i[e])}else t=i}return t?zs(n?t:t.sort(Vs)):Ns}static from(e){switch(e.length){case 0:return Is;case 1:return e[0];default:return new Rs(e)}}}function Bs(e,t){if(!t||!e.length)return e;let n=[];for(let r=0;r<e.length;r++){let i=e[r];n.push(new Ts(i.from+t,i.to+t,i.type))}return n}function Fs(e,t,n){if(t.isLeaf)return null;let r=n+t.nodeSize,i=null;for(let t,s=0;s<e.length;s++)(t=e[s])&&t.from>n&&t.to<r&&((i||(i=[])).push(t),e[s]=null);return i}function Ps(e){let t=[];for(let n=0;n<e.length;n++)null!=e[n]&&t.push(e[n]);return t}function Ls(e,t,n,r){let i=[],s=!1;t.forEach(((t,o)=>{let a=Fs(e,t,o+n);if(a){s=!0;let e=Ls(a,t,n+o+1,r);e!=Is&&i.push(o,o+t.nodeSize,e)}}));let o=Bs(s?Ps(e):e,-n).sort(Vs);for(let e=0;e<o.length;e++)o[e].type.valid(t,o[e])||(r.onRemove&&r.onRemove(o[e].spec),o.splice(e--,1));return o.length||i.length?new $s(o,i):Is}function Vs(e,t){return e.from-t.from||e.to-t.to}function zs(e){let t=e;for(let n=0;n<t.length-1;n++){let r=t[n];if(r.from!=r.to)for(let i=n+1;i<t.length;i++){let s=t[i];if(s.from!=r.from){s.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,s.from),js(t,i,r.copy(s.from,r.to)));break}s.to!=r.to&&(t==e&&(t=e.slice()),t[i]=s.copy(s.from,r.to),js(t,i+1,s.copy(r.to,s.to)))}}return t}function js(e,t,n){for(;t<e.length&&Vs(n,e[t])>0;)t++;e.splice(t,0,n)}function _s(e){let t=[];return e.someProp("decorations",(n=>{let r=n(e.state);r&&r!=Is&&t.push(r)})),e.cursorWrapper&&t.push($s.create(e.state.doc,[e.cursorWrapper.deco])),Rs.from(t)}const Ks={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Ws=mr&&gr<=11;class Hs{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class qs{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Hs,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.observer=window.MutationObserver&&new window.MutationObserver((e=>{for(let t=0;t<e.length;t++)this.queue.push(e[t]);mr&&gr<=11&&e.some((e=>"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length))?this.flushSoon():this.flush()})),Ws&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout((()=>{this.flushingSoon=-1,this.flush()}),20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,Ks)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout((()=>this.flush()),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout((()=>this.suppressingSelectionUpdates=!1),50)}onSelectionChange(){if(Ai(this.view)){if(this.suppressingSelectionUpdates)return vi(this.view);if(mr&&gr<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&nr(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t,n=new Set;for(let t=e.focusNode;t;t=Qn(t))n.add(t);for(let r=e.anchorNode;r;r=Qn(r))if(n.has(r)){t=r;break}let r=t&&this.view.docView.nearestDesc(t);return r&&r.ignoreMutation({type:"selection",target:3==t.nodeType?t.parentNode:t})?(this.setCurSelection(),!0):void 0}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.observer?this.observer.takeRecords():[];this.queue.length&&(t=this.queue.concat(t),this.queue.length=0);let n=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&Ai(e)&&!this.ignoreSelectionChange(n),i=-1,s=-1,o=!1,a=[];if(e.editable)for(let e=0;e<t.length;e++){let n=this.registerMutation(t[e],a);n&&(i=i<0?n.from:Math.min(n.from,i),s=s<0?n.to:Math.max(n.to,s),n.typeOver&&(o=!0))}if(yr&&a.length>1){let e=a.filter((e=>"BR"==e.nodeName));if(2==e.length){let t=e[0],n=e[1];t.parentNode&&t.parentNode.parentNode==n.parentNode?n.remove():t.remove()}}let l=null;i<0&&r&&e.input.lastFocus>Date.now()-200&&e.input.lastTouch<Date.now()-300&&ar(n)&&(l=gi(e))&&l.eq(Tn.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,vi(e),this.currentSelection.set(n),e.scrollToSelection()):(i>-1||r)&&(i>-1&&(e.docView.markDirty(i,s),function(e){if(Js.has(e))return;if(Js.set(e,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(e.dom).whiteSpace)){if(e.requiresGeckoHackNode=yr,Us)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),Us=!0}}(e)),this.handleDOMChange(i,s,o,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||vi(e),this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if("attributes"==e.type&&(n==this.view.docView||"contenteditable"==e.attributeName||"style"==e.attributeName&&!e.oldValue&&!e.target.getAttribute("style")))return null;if(!n||n.ignoreMutation(e))return null;if("childList"==e.type){for(let n=0;n<e.addedNodes.length;n++)t.push(e.addedNodes[n]);if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let r=e.previousSibling,i=e.nextSibling;if(mr&&gr<=11&&e.addedNodes.length)for(let t=0;t<e.addedNodes.length;t++){let{previousSibling:n,nextSibling:s}=e.addedNodes[t];(!n||Array.prototype.indexOf.call(e.addedNodes,n)<0)&&(r=n),(!s||Array.prototype.indexOf.call(e.addedNodes,s)<0)&&(i=s)}let s=r&&r.parentNode==e.target?Zn(r)+1:0,o=n.localPosFromDOM(e.target,s,-1),a=i&&i.parentNode==e.target?Zn(i):e.target.childNodes.length;return{from:o,to:n.localPosFromDOM(e.target,a,1)}}return"attributes"==e.type?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}}}let Js=new WeakMap,Us=!1;function Gs(e){let t=e.pmViewDesc;if(t)return t.parseRule();if("BR"==e.nodeName&&e.parentNode){if(xr&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let e=document.createElement("div");return e.appendChild(document.createElement("li")),{skip:e}}if(e.parentNode.lastChild==e||xr&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if("IMG"==e.nodeName&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null}function Ys(e,t,n,r,i){if(t<0){let t=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,n=gi(e,t);if(n&&!e.state.selection.eq(n)){let r=e.state.tr.setSelection(n);"pointer"==t?r.setMeta("pointer",!0):"key"==t&&r.scrollIntoView(),e.dispatch(r)}return}let s=e.state.doc.resolve(t),o=s.sharedDepth(n);t=s.before(o+1),n=e.state.doc.resolve(n).after(o+1);let a,l,c=e.state.selection,h=function(e,t,n){let r,{node:i,fromOffset:s,toOffset:o,from:a,to:l}=e.docView.parseRange(t,n),c=e.domSelectionRange(),h=c.anchorNode;if(h&&e.dom.contains(1==h.nodeType?h:h.parentNode)&&(r=[{node:h,offset:c.anchorOffset}],ar(c)||r.push({node:c.focusNode,offset:c.focusOffset})),br&&8===e.input.lastKeyCode)for(let e=o;e>s;e--){let t=i.childNodes[e-1],n=t.pmViewDesc;if("BR"==t.nodeName&&!n){o=e;break}if(!n||n.size)break}let d=e.state.doc,u=e.someProp("domParser")||Tt.fromSchema(e.state.schema),p=d.resolve(a),f=null,m=u.parse(i,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:s,to:o,preserveWhitespace:"pre"!=p.parent.type.whitespace||"full",findPositions:r,ruleFromNode:Gs,context:p});if(r&&null!=r[0].pos){let e=r[0].pos,t=r[1]&&r[1].pos;null==t&&(t=e),f={anchor:e+a,head:t+a}}return{doc:m,sel:f,from:a,to:l}}(e,t,n),d=e.state.doc,u=d.slice(h.from,h.to);8===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime?(a=e.state.selection.to,l="end"):(a=e.state.selection.from,l="start"),e.input.lastKeyCode=null;let p=function(e,t,n,r,i){let s=e.findDiffStart(t,n);if(null==s)return null;let{a:o,b:a}=e.findDiffEnd(t,n+e.size,n+t.size);if("end"==i){r-=o+Math.max(0,s-Math.min(o,a))-s}if(o<s&&e.size<t.size){s-=r<=s&&r>=o?s-r:0,a=s+(a-o),o=s}else if(a<s){s-=r<=s&&r>=a?s-r:0,o=s+(o-a),a=s}return{start:s,endA:o,endB:a}}(u.content,h.doc.content,h.from,a,l);if((kr&&e.input.lastIOSEnter>Date.now()-225||Mr)&&i.some((e=>"DIV"==e.nodeName||"P"==e.nodeName))&&(!p||p.endA>=p.endB)&&e.someProp("handleKeyDown",(t=>t(e,lr(13,"Enter")))))return void(e.input.lastIOSEnter=0);if(!p){if(!(r&&c instanceof In&&!c.empty&&c.$head.sameParent(c.$anchor))||e.composing||h.sel&&h.sel.anchor!=h.sel.head){if(h.sel){let t=Xs(e,e.state.doc,h.sel);t&&!t.eq(e.state.selection)&&e.dispatch(e.state.tr.setSelection(t))}return}p={start:c.from,endA:c.to,endB:c.to}}if(br&&e.cursorWrapper&&h.sel&&h.sel.anchor==e.cursorWrapper.deco.from&&h.sel.head==h.sel.anchor){let e=p.endB-p.start;h.sel={anchor:h.sel.anchor+e,head:h.sel.anchor+e}}e.input.domChangeCount++,e.state.selection.from<e.state.selection.to&&p.start==p.endB&&e.state.selection instanceof In&&(p.start>e.state.selection.from&&p.start<=e.state.selection.from+2&&e.state.selection.from>=h.from?p.start=e.state.selection.from:p.endA<e.state.selection.to&&p.endA>=e.state.selection.to-2&&e.state.selection.to<=h.to&&(p.endB+=e.state.selection.to-p.endA,p.endA=e.state.selection.to)),mr&&gr<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>h.from&&"  "==h.doc.textBetween(p.start-h.from-1,p.start-h.from+1)&&(p.start--,p.endA--,p.endB--);let f,m=h.doc.resolveNoCache(p.start-h.from),g=h.doc.resolveNoCache(p.endB-h.from),y=d.resolve(p.start),v=m.sameParent(g)&&m.parent.inlineContent&&y.end()>=p.endA;if((kr&&e.input.lastIOSEnter>Date.now()-225&&(!v||i.some((e=>"DIV"==e.nodeName||"P"==e.nodeName)))||!v&&m.pos<h.doc.content.size&&(f=Tn.findFrom(h.doc.resolve(m.pos+1),1,!0))&&f.head==g.pos)&&e.someProp("handleKeyDown",(t=>t(e,lr(13,"Enter")))))return void(e.input.lastIOSEnter=0);if(e.state.selection.anchor>p.start&&function(e,t,n,r,i){if(!r.parent.isTextblock||n-t<=i.pos-r.pos||Zs(r,!0,!1)<i.pos)return!1;let s=e.resolve(t);if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let o=e.resolve(Zs(s,!0,!0));return!(!o.parent.isTextblock||o.pos>n||Zs(o,!0,!1)<n)&&r.parent.content.cut(r.parentOffset).eq(o.parent.content)}(d,p.start,p.endA,m,g)&&e.someProp("handleKeyDown",(t=>t(e,lr(8,"Backspace")))))return void(Mr&&br&&e.domObserver.suppressSelectionUpdates());br&&Mr&&p.endB==p.start&&(e.input.lastAndroidDelete=Date.now()),Mr&&!v&&m.start()!=g.start()&&0==g.parentOffset&&m.depth==g.depth&&h.sel&&h.sel.anchor==h.sel.head&&h.sel.head==p.endA&&(p.endB-=2,g=h.doc.resolveNoCache(p.endB-h.from),setTimeout((()=>{e.someProp("handleKeyDown",(function(t){return t(e,lr(13,"Enter"))}))}),20));let b,w,x,k=p.start,S=p.endA;if(v)if(m.pos==g.pos)mr&&gr<=11&&0==m.parentOffset&&(e.domObserver.suppressSelectionUpdates(),setTimeout((()=>vi(e)),20)),b=e.state.tr.delete(k,S),w=d.resolve(p.start).marksAcross(d.resolve(p.endA));else if(p.endA==p.endB&&(x=function(e,t){let n,r,i,s=e.firstChild.marks,o=t.firstChild.marks,a=s,l=o;for(let e=0;e<o.length;e++)a=o[e].removeFromSet(a);for(let e=0;e<s.length;e++)l=s[e].removeFromSet(l);if(1==a.length&&0==l.length)r=a[0],n="add",i=e=>e.mark(r.addToSet(e.marks));else{if(0!=a.length||1!=l.length)return null;r=l[0],n="remove",i=e=>e.mark(r.removeFromSet(e.marks))}let c=[];for(let e=0;e<t.childCount;e++)c.push(i(t.child(e)));if(Ve.from(c).eq(e))return{mark:r,type:n}}(m.parent.content.cut(m.parentOffset,g.parentOffset),y.parent.content.cut(y.parentOffset,p.endA-y.start()))))b=e.state.tr,"add"==x.type?b.addMark(k,S,x.mark):b.removeMark(k,S,x.mark);else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let t=m.parent.textBetween(m.parentOffset,g.parentOffset);if(e.someProp("handleTextInput",(n=>n(e,k,S,t))))return;b=e.state.tr.insertText(t,k,S)}if(b||(b=e.state.tr.replace(k,S,h.doc.slice(p.start-h.from,p.endB-h.from))),h.sel){let t=Xs(e,b.doc,h.sel);t&&!(br&&Mr&&e.composing&&t.empty&&(p.start!=p.endB||e.input.lastAndroidDelete<Date.now()-100)&&(t.head==k||t.head==b.mapping.map(S)-1)||mr&&t.empty&&t.head==k)&&b.setSelection(t)}w&&b.ensureMarks(w),e.dispatch(b.scrollIntoView())}function Xs(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:Oi(e,t.resolve(n.anchor),t.resolve(n.head))}function Zs(e,t,n){let r=e.depth,i=t?e.end():e.pos;for(;r>0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,i++,t=!1;if(n){let t=e.node(r).maybeChild(e.indexAfter(r));for(;t&&!t.isLeaf;)t=t.firstChild,i++}return i}class Qs{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new ts,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(io),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):"function"==typeof e?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=no(this),to(this),this.nodeViews=ro(this),this.docView=ei(this.state.doc,eo(this),_s(this),this.dom,this),this.domObserver=new qs(this,((e,t,n,r)=>Ys(this,e,t,n,r))),this.domObserver.start(),function(e){for(let t in Zi){let n=Zi[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{!ss(e,t)||is(e,t)||!e.editable&&t.type in Qi||n(e,t)},es[t]?{passive:!0}:void 0)}xr&&e.dom.addEventListener("input",(()=>null)),rs(e)}(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&rs(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(io),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let e in this._props)t[e]=this._props[e];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){let n=this.state,r=!1,i=!1;e.storedMarks&&this.composing&&(bs(this),i=!0),this.state=e;let s=n.plugins!=e.plugins||this._props.plugins!=t.plugins;if(s||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=ro(this);(function(e,t){let n=0,r=0;for(let r in e){if(e[r]!=t[r])return!0;n++}for(let e in t)r++;return n!=r})(e,this.nodeViews)&&(this.nodeViews=e,r=!0)}(s||t.handleDOMEvents!=this._props.handleDOMEvents)&&rs(this),this.editable=no(this),to(this);let o=_s(this),a=eo(this),l=n.plugins==e.plugins||n.doc.eq(e.doc)?e.scrollToSelection>n.scrollToSelection?"to selection":"preserve":"reset",c=r||!this.docView.matchesNode(e.doc,a,o);!c&&e.selection.eq(n.selection)||(i=!0);let h="preserve"==l&&i&&null==this.dom.style.overflowAnchor&&function(e){let t,n,r=e.dom.getBoundingClientRect(),i=Math.max(0,r.top);for(let s=(r.left+r.right)/2,o=i+1;o<Math.min(innerHeight,r.bottom);o+=5){let r=e.root.elementFromPoint(s,o);if(!r||r==e.dom||!e.dom.contains(r))continue;let a=r.getBoundingClientRect();if(a.top>=i-20){t=r,n=a.top;break}}return{refDOM:t,refTop:n,stack:Dr(e.dom)}}(this);if(i){this.domObserver.stop();let t=c&&(mr||br)&&!this.composing&&!n.selection.empty&&!e.selection.empty&&function(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}(n.selection,e.selection);if(c){let n=br?this.trackWrites=this.domSelectionRange().focusNode:null;!r&&this.docView.update(e.doc,a,o,this)||(this.docView.updateOuterDeco([]),this.docView.destroy(),this.docView=ei(e.doc,a,o,this.dom,this)),n&&!this.trackWrites&&(t=!0)}t||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&function(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return nr(t.node,t.offset,n.anchorNode,n.anchorOffset)}(this))?vi(this,t):(Si(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(n),"reset"==l?this.dom.scrollTop=0:"to selection"==l?this.scrollToSelection():h&&function({refDOM:e,refTop:t,stack:n}){let r=e?e.getBoundingClientRect().top:0;$r(n,0==r?0:r-t)}(h)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(this.someProp("handleScrollToSelection",(e=>e(this))));else if(this.state.selection instanceof Bn){let t=this.docView.domAfterPos(this.state.selection.from);1==t.nodeType&&Nr(this,t.getBoundingClientRect(),e)}else Nr(this,this.coordsAtPos(this.state.selection.head,1),e)}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(e&&e.plugins==this.state.plugins&&this.directPlugins==this.prevDirectPlugins)for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}else{this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let e=0;e<this.directPlugins.length;e++){let t=this.directPlugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}for(let e=0;e<this.state.plugins.length;e++){let t=this.state.plugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}}}someProp(e,t){let n,r=this._props&&this._props[e];if(null!=r&&(n=t?t(r):r))return n;for(let r=0;r<this.directPlugins.length;r++){let i=this.directPlugins[r].props[e];if(null!=i&&(n=t?t(i):i))return n}let i=this.state.plugins;if(i)for(let r=0;r<i.length;r++){let s=i[r].props[e];if(null!=s&&(n=t?t(s):s))return n}}hasFocus(){if(mr){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if("false"==e.contentEditable)return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&function(e){if(e.setActive)return e.setActive();if(Ir)return e.focus(Ir);let t=Dr(e);e.focus(null==Ir?{get preventScroll(){return Ir={preventScroll:!0},!0}}:void 0),Ir||(Ir=!1,$r(t,0))}(this.dom),vi(this),this.domObserver.start()}get root(){let e=this._root;if(null==e)for(let e=this.dom.parentNode;e;e=e.parentNode)if(9==e.nodeType||11==e.nodeType&&e.host)return e.getSelection||(Object.getPrototypeOf(e).getSelection=()=>e.ownerDocument.getSelection()),this._root=e;return e||document}posAtCoords(e){return Pr(this,e)}coordsAtPos(e,t=1){return zr(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let r=this.docView.posFromDOM(e,t,n);if(null==r)throw new RangeError("DOM position not inside the editor");return r}endOfTextblock(e,t){return Ur(this,t||this.state,e)}destroy(){this.docView&&(!function(e){e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],_s(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null)}get isDestroyed(){return null==this.docView}dispatchEvent(e){return function(e,t){is(e,t)||!Zi[t.type]||!e.editable&&t.type in Qi||Zi[t.type](e,t)}(this,e)}dispatch(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))}domSelectionRange(){return xr&&11===this.root.nodeType&&function(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}(this.dom.ownerDocument)==this.dom?function(e){let t;function n(e){e.preventDefault(),e.stopImmediatePropagation(),t=e.getTargetRanges()[0]}e.dom.addEventListener("beforeinput",n,!0),document.execCommand("indent"),e.dom.removeEventListener("beforeinput",n,!0);let r=t.startContainer,i=t.startOffset,s=t.endContainer,o=t.endOffset,a=e.domAtPos(e.state.selection.anchor);return nr(a.node,a.offset,s,o)&&([r,i,s,o]=[s,o,r,i]),{anchorNode:r,anchorOffset:i,focusNode:s,focusOffset:o}}(this):this.domSelection()}domSelection(){return this.root.getSelection()}}function eo(e){let t=Object.create(null);return t.class="ProseMirror",t.contenteditable=String(e.editable),t.translate="no",e.someProp("attributes",(n=>{if("function"==typeof n&&(n=n(e.state)),n)for(let e in n)"class"==e&&(t.class+=" "+n[e]),"style"==e?t.style=(t.style?t.style+";":"")+n[e]:t[e]||"contenteditable"==e||"nodeName"==e||(t[e]=String(n[e]))})),[Ts.node(0,e.state.doc.content.size,t)]}function to(e){if(e.markCursor){let t=document.createElement("img");t.className="ProseMirror-separator",t.setAttribute("mark-placeholder","true"),t.setAttribute("alt",""),e.cursorWrapper={dom:t,deco:Ts.widget(e.state.selection.head,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function no(e){return!e.someProp("editable",(t=>!1===t(e.state)))}function ro(e){let t=Object.create(null);function n(e){for(let n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp("nodeViews",n),e.someProp("markViews",n),t}function io(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var so={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},oo={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},ao="undefined"!=typeof navigator&&/Chrome\/(\d+)/.exec(navigator.userAgent);"undefined"!=typeof navigator&&/Gecko\/\d+/.test(navigator.userAgent);for(var lo="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),co="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),ho=lo||ao&&+ao[1]<57,uo=0;uo<10;uo++)so[48+uo]=so[96+uo]=String(uo);for(uo=1;uo<=24;uo++)so[uo+111]="F"+uo;for(uo=65;uo<=90;uo++)so[uo]=String.fromCharCode(uo+32),oo[uo]=String.fromCharCode(uo);for(var po in so)oo.hasOwnProperty(po)||(oo[po]=so[po]);const fo="undefined"!=typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform);function mo(e){let t,n,r,i,s=e.split(/-(?!$)/),o=s[s.length-1];"Space"==o&&(o=" ");for(let e=0;e<s.length-1;e++){let o=s[e];if(/^(cmd|meta|m)$/i.test(o))i=!0;else if(/^a(lt)?$/i.test(o))t=!0;else if(/^(c|ctrl|control)$/i.test(o))n=!0;else if(/^s(hift)?$/i.test(o))r=!0;else{if(!/^mod$/i.test(o))throw new Error("Unrecognized modifier name: "+o);fo?i=!0:n=!0}}return t&&(o="Alt-"+o),n&&(o="Ctrl-"+o),i&&(o="Meta-"+o),r&&(o="Shift-"+o),o}function go(e,t,n){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),!1!==n&&t.shiftKey&&(e="Shift-"+e),e}function yo(e){let t=function(e){let t=Object.create(null);for(let n in e)t[mo(n)]=e[n];return t}(e);return function(e,n){let r,i=function(e){var t=!(ho&&(e.ctrlKey||e.altKey||e.metaKey)||co&&e.shiftKey&&e.key&&1==e.key.length||"Unidentified"==e.key)&&e.key||(e.shiftKey?oo:so)[e.keyCode]||e.key||"Unidentified";return"Esc"==t&&(t="Escape"),"Del"==t&&(t="Delete"),"Left"==t&&(t="ArrowLeft"),"Up"==t&&(t="ArrowUp"),"Right"==t&&(t="ArrowRight"),"Down"==t&&(t="ArrowDown"),t}(n),s=1==i.length&&" "!=i,o=t[go(i,n,!s)];if(o&&o(e.state,e.dispatch,e))return!0;if(s&&(n.shiftKey||n.altKey||n.metaKey||i.charCodeAt(0)>127)&&(r=so[n.keyCode])&&r!=i){let i=t[go(r,n,!0)];if(i&&i(e.state,e.dispatch,e))return!0}else if(s&&n.shiftKey){let r=t[go(i,n,!0)];if(r&&r(e.state,e.dispatch,e))return!0}return!1}}function vo(e,t,n=!1){for(let r=e;r;r="start"==t?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&1!=r.childCount)return!1}return!1}function bo(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function wo(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){let n=e.node(t);if(e.index(t)+1<n.childCount)return e.doc.resolve(e.after(t+1));if(n.type.spec.isolating)break}return null}function xo(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function ko(e,t,n){let r,i,s=t.nodeBefore,o=t.nodeAfter;if(s.type.spec.isolating||o.type.spec.isolating)return!1;if(function(e,t,n){let r=t.nodeBefore,i=t.nodeAfter,s=t.index();return!(!(r&&i&&r.type.compatibleContent(i.type))||(!r.content.size&&t.parent.canReplace(s-1,s)?(n&&n(e.tr.delete(t.pos-r.nodeSize,t.pos).scrollIntoView()),0):!t.parent.canReplace(s,s+1)||!i.isTextblock&&!dn(e.doc,t.pos)||(n&&n(e.tr.clearIncompatible(t.pos,r.type,r.contentMatchAt(r.childCount)).join(t.pos).scrollIntoView()),0)))}(e,t,n))return!0;let a=t.parent.canReplace(t.index(),t.index()+1);if(a&&(r=(i=s.contentMatchAt(s.childCount)).findWrapping(o.type))&&i.matchType(r[0]||o.type).validEnd){if(n){let i=t.pos+o.nodeSize,a=Ve.empty;for(let e=r.length-1;e>=0;e--)a=Ve.from(r[e].create(null,a));a=Ve.from(s.copy(a));let l=e.tr.step(new rn(t.pos-1,i,t.pos,i,new He(a,1,0),r.length,!0)),c=i+2*r.length;dn(l.doc,c)&&l.join(c),n(l.scrollIntoView())}return!0}let l=Tn.findFrom(t,1),c=l&&l.$from.blockRange(l.$to),h=c&&an(c);if(null!=h&&h>=t.depth)return n&&n(e.tr.lift(c,h).scrollIntoView()),!0;if(a&&vo(o,"start",!0)&&vo(s,"end")){let r=s,i=[];for(;i.push(r),!r.isTextblock;)r=r.lastChild;let a=o,l=1;for(;!a.isTextblock;a=a.firstChild)l++;if(r.canReplace(r.childCount,r.childCount,a.content)){if(n){let r=Ve.empty;for(let e=i.length-1;e>=0;e--)r=Ve.from(i[e].copy(r));n(e.tr.step(new rn(t.pos-i.length,t.pos+o.nodeSize,t.pos+l,t.pos+o.nodeSize-l,new He(r,i.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function So(e){return function(t,n){let r=t.selection,i=e<0?r.$from:r.$to,s=i.depth;for(;i.node(s).isInline;){if(!s)return!1;s--}return!!i.node(s).isTextblock&&(n&&n(t.tr.setSelection(In.create(t.doc,e<0?i.start(s):i.end(s)))),!0)}}const Mo=So(-1),Oo=So(1);function Ao(e,t=null){return function(n,r){let i=!1;for(let r=0;r<n.selection.ranges.length&&!i;r++){let{$from:{pos:s},$to:{pos:o}}=n.selection.ranges[r];n.doc.nodesBetween(s,o,((r,s)=>{if(i)return!1;if(r.isTextblock&&!r.hasMarkup(e,t))if(r.type==e)i=!0;else{let t=n.doc.resolve(s),r=t.index();i=t.parent.canReplaceWith(r,r+1,e)}}))}if(!i)return!1;if(r){let i=n.tr;for(let r=0;r<n.selection.ranges.length;r++){let{$from:{pos:s},$to:{pos:o}}=n.selection.ranges[r];i.setBlockType(s,o,e,t)}r(i.scrollIntoView())}return!0}}function Co(e,t=null){return function(n,r){let{$from:i,$to:s}=n.selection,o=i.blockRange(s),a=!1,l=o;if(!o)return!1;if(o.depth>=2&&i.node(o.depth-1).type.compatibleContent(e)&&0==o.startIndex){if(0==i.index(o.depth-1))return!1;let e=n.doc.resolve(o.start-2);l=new at(e,e,o.depth),o.endIndex<o.parent.childCount&&(o=new at(i,n.doc.resolve(s.end(o.depth)),o.depth)),a=!0}let c=ln(l,e,t,o);return!!c&&(r&&r(function(e,t,n,r,i){let s=Ve.empty;for(let e=n.length-1;e>=0;e--)s=Ve.from(n[e].type.create(n[e].attrs,s));e.step(new rn(t.start-(r?2:0),t.end,t.start,t.end,new He(s,0,0),n.length,!0));let o=0;for(let e=0;e<n.length;e++)n[e].type==i&&(o=e+1);let a=n.length-o,l=t.start+n.length-(r?2:0),c=t.parent;for(let n=t.startIndex,r=t.endIndex,i=!0;n<r;n++,i=!1)!i&&hn(e.doc,l,a)&&(e.split(l,a),l+=2*a),l+=c.child(n).nodeSize;return e}(n.tr,o,c,a,e).scrollIntoView()),!0)}}function Eo(e){return function(t,n){let{$from:r,$to:i}=t.selection,s=r.blockRange(i,(t=>t.childCount>0&&t.firstChild.type==e));return!!s&&(!n||(r.node(s.depth-1).type==e?function(e,t,n,r){let i=e.tr,s=r.end,o=r.$to.end(r.depth);s<o&&(i.step(new rn(s-1,o,s,o,new He(Ve.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new at(i.doc.resolve(r.$from.pos),i.doc.resolve(o),r.depth));const a=an(r);if(null==a)return!1;i.lift(r,a);let l=i.mapping.map(s,-1)-1;dn(i.doc,l)&&i.join(l);return t(i.scrollIntoView()),!0}(t,n,e,s):function(e,t,n){let r=e.tr,i=n.parent;for(let e=n.end,t=n.endIndex-1,s=n.startIndex;t>s;t--)e-=i.child(t).nodeSize,r.delete(e-1,e+1);let s=r.doc.resolve(n.start),o=s.nodeAfter;if(r.mapping.map(n.end)!=n.start+s.nodeAfter.nodeSize)return!1;let a=0==n.startIndex,l=n.endIndex==i.childCount,c=s.node(-1),h=s.index(-1);if(!c.canReplace(h+(a?0:1),h+1,o.content.append(l?Ve.empty:Ve.from(i))))return!1;let d=s.pos,u=d+o.nodeSize;return r.step(new rn(d-(a?1:0),u+(l?1:0),d+1,u-1,new He((a?Ve.empty:Ve.from(i.copy(Ve.empty))).append(l?Ve.empty:Ve.from(i.copy(Ve.empty))),a?0:1,l?0:1),a?0:1)),t(r.scrollIntoView()),!0}(t,n,s)))}}function To(e){const{state:t,transaction:n}=e;let{selection:r}=n,{doc:i}=n,{storedMarks:s}=n;return{...t,apply:t.apply.bind(t),applyTransaction:t.applyTransaction.bind(t),filterTransaction:t.filterTransaction,plugins:t.plugins,schema:t.schema,reconfigure:t.reconfigure.bind(t),toJSON:t.toJSON.bind(t),get storedMarks(){return s},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,s=n.storedMarks,n}}}"undefined"!=typeof navigator?/Mac|iP(hone|[oa]d)/.test(navigator.platform):"undefined"!=typeof os&&os.platform&&os.platform();class No{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:e,editor:t,state:n}=this,{view:r}=t,{tr:i}=n,s=this.buildProps(i);return Object.fromEntries(Object.entries(e).map((([e,t])=>[e,(...e)=>{const n=t(...e)(s);return i.getMeta("preventDispatch")||this.hasCustomState||r.dispatch(i),n}])))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){const{rawCommands:n,editor:r,state:i}=this,{view:s}=r,o=[],a=!!e,l=e||i.tr,c={...Object.fromEntries(Object.entries(n).map((([e,n])=>[e,(...e)=>{const r=this.buildProps(l,t),i=n(...e)(r);return o.push(i),c}]))),run:()=>(a||!t||l.getMeta("preventDispatch")||this.hasCustomState||s.dispatch(l),o.every((e=>!0===e)))};return c}createCan(e){const{rawCommands:t,state:n}=this,r=e||n.tr,i=this.buildProps(r,false),s=Object.fromEntries(Object.entries(t).map((([e,t])=>[e,(...e)=>t(...e)({...i,dispatch:void 0})])));return{...s,chain:()=>this.createChain(r,false)}}buildProps(e,t=!0){const{rawCommands:n,editor:r,state:i}=this,{view:s}=r;i.storedMarks&&e.setStoredMarks(i.storedMarks);const o={tr:e,editor:r,view:s,state:To({state:i,transaction:e}),dispatch:t?()=>{}:void 0,chain:()=>this.createChain(e),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(n).map((([e,t])=>[e,(...e)=>t(...e)(o)])))}};return o}}function Do(e,t,n){if(void 0===e.config[t]&&e.parent)return Do(e.parent,t,n);if("function"==typeof e.config[t]){return e.config[t].bind({...n,parent:e.parent?Do(e.parent,t,n):null})}return e.config[t]}function $o(e){return{baseExtensions:e.filter((e=>"extension"===e.type)),nodeExtensions:e.filter((e=>"node"===e.type)),markExtensions:e.filter((e=>"mark"===e.type))}}function Io(e){const t=[],{nodeExtensions:n,markExtensions:r}=$o(e),i=[...n,...r],s={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return e.forEach((e=>{const n=Do(e,"addGlobalAttributes",{name:e.name,options:e.options,storage:e.storage});if(!n)return;n().forEach((e=>{e.types.forEach((n=>{Object.entries(e.attributes).forEach((([e,r])=>{t.push({type:n,name:e,attribute:{...s,...r}})}))}))}))})),i.forEach((e=>{const n={name:e.name,options:e.options,storage:e.storage},r=Do(e,"addAttributes",n);if(!r)return;const i=r();Object.entries(i).forEach((([n,r])=>{const i={...s,...r};"function"==typeof(null==i?void 0:i.default)&&(i.default=i.default()),(null==i?void 0:i.isRequired)&&void 0===(null==i?void 0:i.default)&&delete i.default,t.push({type:e.name,name:n,attribute:i})}))})),t}function Ro(e,t){if("string"==typeof e){if(!t.nodes[e])throw Error(`There is no node type named '${e}'. Maybe you forgot to add the extension?`);return t.nodes[e]}return e}function Bo(...e){return e.filter((e=>!!e)).reduce(((e,t)=>{const n={...e};return Object.entries(t).forEach((([e,t])=>{n[e]?n[e]="class"===e?[n[e],t].join(" "):"style"===e?[n[e],t].join("; "):t:n[e]=t})),n}),{})}function Fo(e,t){return t.filter((e=>e.attribute.rendered)).map((t=>t.attribute.renderHTML?t.attribute.renderHTML(e.attrs)||{}:{[t.name]:e.attrs[t.name]})).reduce(((e,t)=>Bo(e,t)),{})}function Po(e){return"function"==typeof e}function Lo(e,t,...n){return Po(e)?t?e.bind(t)(...n):e(...n):e}function Vo(e,t){return e.style?e:{...e,getAttrs:n=>{const r=e.getAttrs?e.getAttrs(n):e.attrs;if(!1===r)return!1;const i=t.reduce(((e,t)=>{const r=t.attribute.parseHTML?t.attribute.parseHTML(n):function(e){return"string"!=typeof e?e:e.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(e):"true"===e||"false"!==e&&e}(n.getAttribute(t.name));return null==r?e:{...e,[t.name]:r}}),{});return{...r,...i}}}}function zo(e){return Object.fromEntries(Object.entries(e).filter((([e,t])=>("attrs"!==e||!function(e={}){return 0===Object.keys(e).length&&e.constructor===Object}(t))&&null!=t)))}function jo(e,t){return t.nodes[e]||t.marks[e]||null}function _o(e,t){return Array.isArray(t)?t.some((t=>("string"==typeof t?t:t.name)===e.name)):t}function Ko(e){return"[object RegExp]"===Object.prototype.toString.call(e)}function Wo(e){var t;const{editor:n,from:r,to:i,text:s,rules:o,plugin:a}=e,{view:l}=n;if(l.composing)return!1;const c=l.state.doc.resolve(r);if(c.parent.type.spec.code||(null===(t=c.nodeBefore||c.nodeAfter)||void 0===t?void 0:t.marks.find((e=>e.type.spec.code))))return!1;let h=!1;const d=((e,t=500)=>{let n="";const r=e.parentOffset;return e.parent.nodesBetween(Math.max(0,r-t),r,((e,t,i,s)=>{var o,a;const l=(null===(a=(o=e.type.spec).toText)||void 0===a?void 0:a.call(o,{node:e,pos:t,parent:i,index:s}))||e.textContent||"%leaf%";n+=l.slice(0,Math.max(0,r-t))})),n})(c)+s;return o.forEach((e=>{if(h)return;const t=((e,t)=>{if(Ko(t))return t.exec(e);const n=t(e);if(!n)return null;const r=[n.text];return r.index=n.index,r.input=e,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r})(d,e.find);if(!t)return;const o=l.state.tr,c=To({state:l.state,transaction:o}),u={from:r-(t[0].length-s.length),to:i},{commands:p,chain:f,can:m}=new No({editor:n,state:c});null!==e.handler({state:c,range:u,match:t,commands:p,chain:f,can:m})&&o.steps.length&&(o.setMeta(a,{transform:o,from:r,to:i,text:s}),l.dispatch(o),h=!0)})),h}function Ho(e){const{editor:t,rules:n}=e,r=new Un({state:{init:()=>null,apply(e,t){const n=e.getMeta(r);return n||(e.selectionSet||e.docChanged?null:t)}},props:{handleTextInput:(e,i,s,o)=>Wo({editor:t,from:i,to:s,text:o,rules:n,plugin:r}),handleDOMEvents:{compositionend:e=>(setTimeout((()=>{const{$cursor:i}=e.state.selection;i&&Wo({editor:t,from:i.pos,to:i.pos,text:"",rules:n,plugin:r})})),!1)},handleKeyDown(e,i){if("Enter"!==i.key)return!1;const{$cursor:s}=e.state.selection;return!!s&&Wo({editor:t,from:s.pos,to:s.pos,text:"\n",rules:n,plugin:r})}},isInputRules:!0});return r}function qo(e){const{editor:t,state:n,from:r,to:i,rule:s}=e,{commands:o,chain:a,can:l}=new No({editor:t,state:n}),c=[];n.doc.nodesBetween(r,i,((e,t)=>{if(!e.isTextblock||e.type.spec.code)return;const h=Math.max(r,t),d=Math.min(i,t+e.content.size);((e,t)=>{if(Ko(t))return[...e.matchAll(t)];const n=t(e);return n?n.map((t=>{const n=[t.text];return n.index=t.index,n.input=e,n.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),n.push(t.replaceWith)),n})):[]})(e.textBetween(h-t,d-t,void 0,""),s.find).forEach((e=>{if(void 0===e.index)return;const t=h+e.index+1,r=t+e[0].length,i={from:n.tr.mapping.map(t),to:n.tr.mapping.map(r)},d=s.handler({state:n,range:i,match:e,commands:o,chain:a,can:l});c.push(d)}))}));return c.every((e=>null!==e))}function Jo(e){const{editor:t,rules:n}=e;let r=null,i=!1,s=!1;return n.map((e=>new Un({view(e){const t=t=>{var n;r=(null===(n=e.dom.parentElement)||void 0===n?void 0:n.contains(t.target))?e.dom.parentElement:null};return window.addEventListener("dragstart",t),{destroy(){window.removeEventListener("dragstart",t)}}},props:{handleDOMEvents:{drop:e=>(s=r===e.dom.parentElement,!1),paste:(e,t)=>{var n;const r=null===(n=t.clipboardData)||void 0===n?void 0:n.getData("text/html");return i=!!(null==r?void 0:r.includes("data-pm-slice")),!1}}},appendTransaction:(n,r,o)=>{const a=n[0],l="paste"===a.getMeta("uiEvent")&&!i,c="drop"===a.getMeta("uiEvent")&&!s;if(!l&&!c)return;const h=r.doc.content.findDiffStart(o.doc.content),d=r.doc.content.findDiffEnd(o.doc.content);if("number"!=typeof h||!d||h===d.b)return;const u=o.tr,p=To({state:o,transaction:u});return qo({editor:t,state:p,from:Math.max(h-1,0),to:d.b-1,rule:e})&&u.steps.length?u:void 0}})))}class Uo{constructor(e,t){this.splittableMarks=[],this.editor=t,this.extensions=Uo.resolve(e),this.schema=function(e,t){var n;const r=Io(e),{nodeExtensions:i,markExtensions:s}=$o(e),o=null===(n=i.find((e=>Do(e,"topNode"))))||void 0===n?void 0:n.name,a=Object.fromEntries(i.map((n=>{const i=r.filter((e=>e.type===n.name)),s={name:n.name,options:n.options,storage:n.storage,editor:t},o=e.reduce(((e,t)=>{const r=Do(t,"extendNodeSchema",s);return{...e,...r?r(n):{}}}),{}),a=zo({...o,content:Lo(Do(n,"content",s)),marks:Lo(Do(n,"marks",s)),group:Lo(Do(n,"group",s)),inline:Lo(Do(n,"inline",s)),atom:Lo(Do(n,"atom",s)),selectable:Lo(Do(n,"selectable",s)),draggable:Lo(Do(n,"draggable",s)),code:Lo(Do(n,"code",s)),defining:Lo(Do(n,"defining",s)),isolating:Lo(Do(n,"isolating",s)),attrs:Object.fromEntries(i.map((e=>{var t;return[e.name,{default:null===(t=null==e?void 0:e.attribute)||void 0===t?void 0:t.default}]})))}),l=Lo(Do(n,"parseHTML",s));l&&(a.parseDOM=l.map((e=>Vo(e,i))));const c=Do(n,"renderHTML",s);c&&(a.toDOM=e=>c({node:e,HTMLAttributes:Fo(e,i)}));const h=Do(n,"renderText",s);return h&&(a.toText=h),[n.name,a]}))),l=Object.fromEntries(s.map((n=>{const i=r.filter((e=>e.type===n.name)),s={name:n.name,options:n.options,storage:n.storage,editor:t},o=e.reduce(((e,t)=>{const r=Do(t,"extendMarkSchema",s);return{...e,...r?r(n):{}}}),{}),a=zo({...o,inclusive:Lo(Do(n,"inclusive",s)),excludes:Lo(Do(n,"excludes",s)),group:Lo(Do(n,"group",s)),spanning:Lo(Do(n,"spanning",s)),code:Lo(Do(n,"code",s)),attrs:Object.fromEntries(i.map((e=>{var t;return[e.name,{default:null===(t=null==e?void 0:e.attribute)||void 0===t?void 0:t.default}]})))}),l=Lo(Do(n,"parseHTML",s));l&&(a.parseDOM=l.map((e=>Vo(e,i))));const c=Do(n,"renderHTML",s);return c&&(a.toDOM=e=>c({mark:e,HTMLAttributes:Fo(e,i)})),[n.name,a]})));return new Ct({topNode:o,nodes:a,marks:l})}(this.extensions,t),this.extensions.forEach((e=>{var t;this.editor.extensionStorage[e.name]=e.storage;const n={name:e.name,options:e.options,storage:e.storage,editor:this.editor,type:jo(e.name,this.schema)};if("mark"===e.type){(null===(t=Lo(Do(e,"keepOnSplit",n)))||void 0===t||t)&&this.splittableMarks.push(e.name)}const r=Do(e,"onBeforeCreate",n);r&&this.editor.on("beforeCreate",r);const i=Do(e,"onCreate",n);i&&this.editor.on("create",i);const s=Do(e,"onUpdate",n);s&&this.editor.on("update",s);const o=Do(e,"onSelectionUpdate",n);o&&this.editor.on("selectionUpdate",o);const a=Do(e,"onTransaction",n);a&&this.editor.on("transaction",a);const l=Do(e,"onFocus",n);l&&this.editor.on("focus",l);const c=Do(e,"onBlur",n);c&&this.editor.on("blur",c);const h=Do(e,"onDestroy",n);h&&this.editor.on("destroy",h)}))}static resolve(e){const t=Uo.sort(Uo.flatten(e)),n=function(e){const t=e.filter(((t,n)=>e.indexOf(t)!==n));return[...new Set(t)]}(t.map((e=>e.name)));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map((e=>`'${e}'`)).join(", ")}]. This can lead to issues.`),t}static flatten(e){return e.map((e=>{const t=Do(e,"addExtensions",{name:e.name,options:e.options,storage:e.storage});return t?[e,...this.flatten(t())]:e})).flat(10)}static sort(e){return e.sort(((e,t)=>{const n=Do(e,"priority")||100,r=Do(t,"priority")||100;return n>r?-1:n<r?1:0}))}get commands(){return this.extensions.reduce(((e,t)=>{const n=Do(t,"addCommands",{name:t.name,options:t.options,storage:t.storage,editor:this.editor,type:jo(t.name,this.schema)});return n?{...e,...n()}:e}),{})}get plugins(){const{editor:e}=this,t=Uo.sort([...this.extensions].reverse()),n=[],r=[],i=t.map((t=>{const i={name:t.name,options:t.options,storage:t.storage,editor:e,type:jo(t.name,this.schema)},s=[],o=Do(t,"addKeyboardShortcuts",i);let a={};if("mark"===t.type&&t.config.exitable&&(a.ArrowRight=()=>Ra.handleExit({editor:e,mark:t})),o){const t=Object.fromEntries(Object.entries(o()).map((([t,n])=>[t,()=>n({editor:e})])));a={...a,...t}}const l=new Un({props:{handleKeyDown:yo(a)}});s.push(l);const c=Do(t,"addInputRules",i);_o(t,e.options.enableInputRules)&&c&&n.push(...c());const h=Do(t,"addPasteRules",i);_o(t,e.options.enablePasteRules)&&h&&r.push(...h());const d=Do(t,"addProseMirrorPlugins",i);if(d){const e=d();s.push(...e)}return s})).flat();return[Ho({editor:e,rules:n}),...Jo({editor:e,rules:r}),...i]}get attributes(){return Io(this.extensions)}get nodeViews(){const{editor:e}=this,{nodeExtensions:t}=$o(this.extensions);return Object.fromEntries(t.filter((e=>!!Do(e,"addNodeView"))).map((t=>{const n=this.attributes.filter((e=>e.type===t.name)),r={name:t.name,options:t.options,storage:t.storage,editor:e,type:Ro(t.name,this.schema)},i=Do(t,"addNodeView",r);if(!i)return[];return[t.name,(r,s,o,a)=>{const l=Fo(r,n);return i()({editor:e,node:r,getPos:o,decorations:a,HTMLAttributes:l,extension:t})}]})))}}function Go(e){return"Object"===function(e){return Object.prototype.toString.call(e).slice(8,-1)}(e)&&(e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype)}function Yo(e,t){const n={...e};return Go(e)&&Go(t)&&Object.keys(t).forEach((r=>{Go(t[r])?r in e?n[r]=Yo(e[r],t[r]):Object.assign(n,{[r]:t[r]}):Object.assign(n,{[r]:t[r]})})),n}class Xo{constructor(e={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=Lo(Do(this,"addOptions",{name:this.name}))),this.storage=Lo(Do(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new Xo(e)}configure(e={}){const t=this.extend();return t.options=Yo(this.options,e),t.storage=Lo(Do(t,"addStorage",{name:t.name,options:t.options})),t}extend(e={}){const t=new Xo(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=Lo(Do(t,"addOptions",{name:t.name})),t.storage=Lo(Do(t,"addStorage",{name:t.name,options:t.options})),t}}function Zo(e,t,n){const{from:r,to:i}=t,{blockSeparator:s="\n\n",textSerializers:o={}}=n||{};let a="",l=!0;return e.nodesBetween(r,i,((e,n,c,h)=>{var d;const u=null==o?void 0:o[e.type.name];u?(e.isBlock&&!l&&(a+=s,l=!0),c&&(a+=u({node:e,pos:n,parent:c,index:h,range:t}))):e.isText?(a+=null===(d=null==e?void 0:e.text)||void 0===d?void 0:d.slice(Math.max(r,n)-n,i-n),l=!1):e.isBlock&&!l&&(a+=s,l=!0)})),a}function Qo(e){return Object.fromEntries(Object.entries(e.nodes).filter((([,e])=>e.spec.toText)).map((([e,t])=>[e,t.spec.toText])))}const ea=Xo.create({name:"clipboardTextSerializer",addProseMirrorPlugins(){return[new Un({key:new Xn("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:e}=this,{state:t,schema:n}=e,{doc:r,selection:i}=t,{ranges:s}=i,o=Math.min(...s.map((e=>e.$from.pos))),a=Math.max(...s.map((e=>e.$to.pos)));return Zo(r,{from:o,to:a},{textSerializers:Qo(n)})}}})]}});function ta(e,t,n={strict:!0}){const r=Object.keys(t);return!r.length||r.every((r=>n.strict?t[r]===e[r]:Ko(t[r])?t[r].test(e[r]):t[r]===e[r]))}function na(e,t,n={}){return e.find((e=>e.type===t&&ta(e.attrs,n)))}function ra(e,t,n={}){return!!na(e,t,n)}function ia(e,t,n={}){if(!e||!t)return;let r=e.parent.childAfter(e.parentOffset);if(e.parentOffset===r.offset&&0!==r.offset&&(r=e.parent.childBefore(e.parentOffset)),!r.node)return;const i=na([...r.node.marks],t,n);if(!i)return;let s=r.index,o=e.start()+r.offset,a=s+1,l=o+r.node.nodeSize;for(na([...r.node.marks],t,n);s>0&&i.isInSet(e.parent.child(s-1).marks);)s-=1,o-=e.parent.child(s).nodeSize;for(;a<e.parent.childCount&&ra([...e.parent.child(a).marks],t,n);)l+=e.parent.child(a).nodeSize,a+=1;return{from:o,to:l}}function sa(e,t){if("string"==typeof e){if(!t.marks[e])throw Error(`There is no mark type named '${e}'. Maybe you forgot to add the extension?`);return t.marks[e]}return e}function oa(e){return e instanceof In}function aa(e=0,t=0,n=0){return Math.min(Math.max(e,t),n)}function la(e,t=null){if(!t)return null;const n=Tn.atStart(e),r=Tn.atEnd(e);if("start"===t||!0===t)return n;if("end"===t)return r;const i=n.from,s=r.to;return"all"===t?In.create(e,aa(0,i,s),aa(e.content.size,i,s)):In.create(e,aa(t,i,s),aa(t,i,s))}function ca(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function ha(e){const t=`<body>${e}</body>`;return(new window.DOMParser).parseFromString(t,"text/html").body}function da(e,t,n){if(n={slice:!0,parseOptions:{},...n},"object"==typeof e&&null!==e)try{return Array.isArray(e)&&e.length>0?Ve.fromArray(e.map((e=>t.nodeFromJSON(e)))):t.nodeFromJSON(e)}catch(r){return console.warn("[tiptap warn]: Invalid content.","Passed value:",e,"Error:",r),da("",t,n)}if("string"==typeof e){const r=Tt.fromSchema(t);return n.slice?r.parseSlice(ha(e),n.parseOptions).content:r.parse(ha(e),n.parseOptions)}return da("",t,n)}function ua(){return"undefined"!=typeof navigator&&/Mac/.test(navigator.platform)}function pa(e,t,n={}){const{from:r,to:i,empty:s}=e.selection,o=t?Ro(t,e.schema):null,a=[];e.doc.nodesBetween(r,i,((e,t)=>{if(e.isText)return;const n=Math.max(r,t),s=Math.min(i,t+e.nodeSize);a.push({node:e,from:n,to:s})}));const l=i-r,c=a.filter((e=>!o||o.name===e.node.type.name)).filter((e=>ta(e.node.attrs,n,{strict:!1})));if(s)return!!c.length;return c.reduce(((e,t)=>e+t.to-t.from),0)>=l}function fa(e,t){return t.nodes[e]?"node":t.marks[e]?"mark":null}function ma(e,t){const n="string"==typeof t?[t]:t;return Object.keys(e).reduce(((t,r)=>(n.includes(r)||(t[r]=e[r]),t)),{})}function ga(e,t,n={}){return da(e,t,{slice:!1,parseOptions:n})}function ya(e){return t=>function(e,t){for(let n=e.depth;n>0;n-=1){const r=e.node(n);if(t(r))return{pos:n>0?e.before(n):0,start:e.start(n),depth:n,node:r}}}(t.$from,e)}function va(e,t){const n=sa(t,e.schema),{from:r,to:i,empty:s}=e.selection,o=[];s?(e.storedMarks&&o.push(...e.storedMarks),o.push(...e.selection.$head.marks())):e.doc.nodesBetween(r,i,(e=>{o.push(...e.marks)}));const a=o.find((e=>e.type.name===n.name));return a?{...a.attrs}:{}}function ba(e,t){const n=fa("string"==typeof t?t:t.name,e.schema);return"node"===n?function(e,t){const n=Ro(t,e.schema),{from:r,to:i}=e.selection,s=[];e.doc.nodesBetween(r,i,(e=>{s.push(e)}));const o=s.reverse().find((e=>e.type.name===n.name));return o?{...o.attrs}:{}}(e,t):"mark"===n?va(e,t):{}}function wa(e,t,n){return Object.fromEntries(Object.entries(n).filter((([n])=>{const r=e.find((e=>e.type===t&&e.name===n));return!!r&&r.attribute.keepOnSplit})))}function xa(e,t,n={}){const{empty:r,ranges:i}=e.selection,s=t?sa(t,e.schema):null;if(r)return!!(e.storedMarks||e.selection.$from.marks()).filter((e=>!s||s.name===e.type.name)).find((e=>ta(e.attrs,n,{strict:!1})));let o=0;const a=[];if(i.forEach((({$from:t,$to:n})=>{const r=t.pos,i=n.pos;e.doc.nodesBetween(r,i,((e,t)=>{if(!e.isText&&!e.marks.length)return;const n=Math.max(r,t),s=Math.min(i,t+e.nodeSize);o+=s-n,a.push(...e.marks.map((e=>({mark:e,from:n,to:s}))))}))})),0===o)return!1;const l=a.filter((e=>!s||s.name===e.mark.type.name)).filter((e=>ta(e.mark.attrs,n,{strict:!1}))).reduce(((e,t)=>e+t.to-t.from),0),c=a.filter((e=>!s||e.mark.type!==s&&e.mark.type.excludes(s))).reduce(((e,t)=>e+t.to-t.from),0);return(l>0?l+c:l)>=o}function ka(e,t){const{nodeExtensions:n}=$o(t),r=n.find((t=>t.name===e));if(!r)return!1;const i=Lo(Do(r,"group",{name:r.name,options:r.options,storage:r.storage}));return"string"==typeof i&&i.split(" ").includes("list")}function Sa(e,t){const n=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();if(n){const r=n.filter((e=>null==t?void 0:t.includes(e.type.name)));e.tr.ensureMarks(r)}}const Ma=(e,t)=>{const n=ya((e=>e.type===t))(e.selection);if(!n)return!0;const r=e.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(void 0===r)return!0;const i=e.doc.nodeAt(r);return n.node.type!==(null==i?void 0:i.type)||!dn(e.doc,n.pos)||(e.join(n.pos),!0)},Oa=(e,t)=>{const n=ya((e=>e.type===t))(e.selection);if(!n)return!0;const r=e.doc.resolve(n.start).after(n.depth);if(void 0===r)return!0;const i=e.doc.nodeAt(r);return n.node.type!==(null==i?void 0:i.type)||!dn(e.doc,r)||(e.join(r),!0)};var Aa=Object.freeze({__proto__:null,blur:()=>({editor:e,view:t})=>(requestAnimationFrame((()=>{var n;e.isDestroyed||(t.dom.blur(),null===(n=null===window||void 0===window?void 0:window.getSelection())||void 0===n||n.removeAllRanges())})),!0),clearContent:(e=!1)=>({commands:t})=>t.setContent("",e),clearNodes:()=>({state:e,tr:t,dispatch:n})=>{const{selection:r}=t,{ranges:i}=r;return!n||(i.forEach((({$from:n,$to:r})=>{e.doc.nodesBetween(n.pos,r.pos,((e,n)=>{if(e.type.isText)return;const{doc:r,mapping:i}=t,s=r.resolve(i.map(n)),o=r.resolve(i.map(n+e.nodeSize)),a=s.blockRange(o);if(!a)return;const l=an(a);if(e.type.isTextblock){const{defaultType:e}=s.parent.contentMatchAt(s.index());t.setNodeMarkup(a.start,e)}(l||0===l)&&t.lift(a,l)}))})),!0)},command:e=>t=>e(t),createParagraphNear:()=>({state:e,dispatch:t})=>((e,t)=>{let n=e.selection,{$from:r,$to:i}=n;if(n instanceof Pn||r.parent.inlineContent||i.parent.inlineContent)return!1;let s=xo(i.parent.contentMatchAt(i.indexAfter()));if(!s||!s.isTextblock)return!1;if(t){let n=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,o=e.tr.insert(n,s.createAndFill());o.setSelection(In.create(o.doc,n+1)),t(o.scrollIntoView())}return!0})(e,t),deleteCurrentNode:()=>({tr:e,dispatch:t})=>{const{selection:n}=e,r=n.$anchor.node();if(r.content.size>0)return!1;const i=e.selection.$anchor;for(let n=i.depth;n>0;n-=1){if(i.node(n).type===r.type){if(t){const t=i.before(n),r=i.after(n);e.delete(t,r).scrollIntoView()}return!0}}return!1},deleteNode:e=>({tr:t,state:n,dispatch:r})=>{const i=Ro(e,n.schema),s=t.selection.$anchor;for(let e=s.depth;e>0;e-=1){if(s.node(e).type===i){if(r){const n=s.before(e),r=s.after(e);t.delete(n,r).scrollIntoView()}return!0}}return!1},deleteRange:e=>({tr:t,dispatch:n})=>{const{from:r,to:i}=e;return n&&t.delete(r,i),!0},deleteSelection:()=>({state:e,dispatch:t})=>((e,t)=>!e.selection.empty&&(t&&t(e.tr.deleteSelection().scrollIntoView()),!0))(e,t),enter:()=>({commands:e})=>e.keyboardShortcut("Enter"),exitCode:()=>({state:e,dispatch:t})=>((e,t)=>{let{$head:n,$anchor:r}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),s=n.indexAfter(-1),o=xo(i.contentMatchAt(s));if(!o||!i.canReplaceWith(s,s,o))return!1;if(t){let r=n.after(),i=e.tr.replaceWith(r,r,o.createAndFill());i.setSelection(Tn.near(i.doc.resolve(r),1)),t(i.scrollIntoView())}return!0})(e,t),extendMarkRange:(e,t={})=>({tr:n,state:r,dispatch:i})=>{const s=sa(e,r.schema),{doc:o,selection:a}=n,{$from:l,from:c,to:h}=a;if(i){const e=ia(l,s,t);if(e&&e.from<=c&&e.to>=h){const t=In.create(o,e.from,e.to);n.setSelection(t)}}return!0},first:e=>t=>{const n="function"==typeof e?e(t):e;for(let e=0;e<n.length;e+=1)if(n[e](t))return!0;return!1},focus:(e=null,t={})=>({editor:n,view:r,tr:i,dispatch:s})=>{t={scrollIntoView:!0,...t};const o=()=>{ca()&&r.dom.focus(),requestAnimationFrame((()=>{n.isDestroyed||(r.focus(),(null==t?void 0:t.scrollIntoView)&&n.commands.scrollIntoView())}))};if(r.hasFocus()&&null===e||!1===e)return!0;if(s&&null===e&&!oa(n.state.selection))return o(),!0;const a=la(i.doc,e)||n.state.selection,l=n.state.selection.eq(a);return s&&(l||i.setSelection(a),l&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},forEach:(e,t)=>n=>e.every(((e,r)=>t(e,{...n,index:r}))),insertContent:(e,t)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},e,t),insertContentAt:(e,t,n)=>({tr:r,dispatch:i,editor:s})=>{if(i){n={parseOptions:{},updateSelection:!0,...n};const i=da(t,s.schema,{parseOptions:{preserveWhitespace:"full",...n.parseOptions}});if("<>"===i.toString())return!0;let{from:o,to:a}="number"==typeof e?{from:e,to:e}:e,l=!0,c=!0;if((i.toString().startsWith("<")?i:[i]).forEach((e=>{e.check(),l=!!l&&(e.isText&&0===e.marks.length),c=!!c&&e.isBlock})),o===a&&c){const{parent:e}=r.doc.resolve(o);e.isTextblock&&!e.type.spec.code&&!e.childCount&&(o-=1,a+=1)}l?Array.isArray(t)?r.insertText(t.map((e=>e.text||"")).join(""),o,a):"object"==typeof t&&t&&t.text?r.insertText(t.text,o,a):r.insertText(t,o,a):r.replaceWith(o,a,i),n.updateSelection&&function(e,t,n){const r=e.steps.length-1;if(r<t)return;const i=e.steps[r];if(!(i instanceof nn||i instanceof rn))return;const s=e.mapping.maps[r];let o=0;s.forEach(((e,t,n,r)=>{0===o&&(o=r)})),e.setSelection(Tn.near(e.doc.resolve(o),n))}(r,r.steps.length-1,-1)}return!0},joinUp:()=>({state:e,dispatch:t})=>((e,t)=>{let n,r=e.selection,i=r instanceof Bn;if(i){if(r.node.isTextblock||!dn(e.doc,r.from))return!1;n=r.from}else if(n=pn(e.doc,r.from,-1),null==n)return!1;if(t){let r=e.tr.join(n);i&&r.setSelection(Bn.create(r.doc,n-e.doc.resolve(n).nodeBefore.nodeSize)),t(r.scrollIntoView())}return!0})(e,t),joinDown:()=>({state:e,dispatch:t})=>((e,t)=>{let n,r=e.selection;if(r instanceof Bn){if(r.node.isTextblock||!dn(e.doc,r.to))return!1;n=r.to}else if(n=pn(e.doc,r.to,1),null==n)return!1;return t&&t(e.tr.join(n).scrollIntoView()),!0})(e,t),joinBackward:()=>({state:e,dispatch:t})=>((e,t,n)=>{let r=function(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("backward",e):n.parentOffset>0)?null:n}(e,n);if(!r)return!1;let i=bo(r);if(!i){let n=r.blockRange(),i=n&&an(n);return null!=i&&(t&&t(e.tr.lift(n,i).scrollIntoView()),!0)}let s=i.nodeBefore;if(!s.type.spec.isolating&&ko(e,i,t))return!0;if(0==r.parent.content.size&&(vo(s,"end")||Bn.isSelectable(s))){let n=mn(e.doc,r.before(),r.after(),He.empty);if(n&&n.slice.size<n.to-n.from){if(t){let r=e.tr.step(n);r.setSelection(vo(s,"end")?Tn.findFrom(r.doc.resolve(r.mapping.map(i.pos,-1)),-1):Bn.create(r.doc,i.pos-s.nodeSize)),t(r.scrollIntoView())}return!0}}return!(!s.isAtom||i.depth!=r.depth-1||(t&&t(e.tr.delete(i.pos-s.nodeSize,i.pos).scrollIntoView()),0))})(e,t),joinForward:()=>({state:e,dispatch:t})=>((e,t,n)=>{let r=function(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("forward",e):n.parentOffset<n.parent.content.size)?null:n}(e,n);if(!r)return!1;let i=wo(r);if(!i)return!1;let s=i.nodeAfter;if(ko(e,i,t))return!0;if(0==r.parent.content.size&&(vo(s,"start")||Bn.isSelectable(s))){let n=mn(e.doc,r.before(),r.after(),He.empty);if(n&&n.slice.size<n.to-n.from){if(t){let r=e.tr.step(n);r.setSelection(vo(s,"start")?Tn.findFrom(r.doc.resolve(r.mapping.map(i.pos)),1):Bn.create(r.doc,r.mapping.map(i.pos))),t(r.scrollIntoView())}return!0}}return!(!s.isAtom||i.depth!=r.depth-1||(t&&t(e.tr.delete(i.pos,i.pos+s.nodeSize).scrollIntoView()),0))})(e,t),keyboardShortcut:e=>({editor:t,view:n,tr:r,dispatch:i})=>{const s=function(e){const t=e.split(/-(?!$)/);let n,r,i,s,o=t[t.length-1];"Space"===o&&(o=" ");for(let e=0;e<t.length-1;e+=1){const o=t[e];if(/^(cmd|meta|m)$/i.test(o))s=!0;else if(/^a(lt)?$/i.test(o))n=!0;else if(/^(c|ctrl|control)$/i.test(o))r=!0;else if(/^s(hift)?$/i.test(o))i=!0;else{if(!/^mod$/i.test(o))throw new Error(`Unrecognized modifier name: ${o}`);ca()||ua()?s=!0:r=!0}}return n&&(o=`Alt-${o}`),r&&(o=`Ctrl-${o}`),s&&(o=`Meta-${o}`),i&&(o=`Shift-${o}`),o}(e).split(/-(?!$)/),o=s.find((e=>!["Alt","Ctrl","Meta","Shift"].includes(e))),a=new KeyboardEvent("keydown",{key:"Space"===o?" ":o,altKey:s.includes("Alt"),ctrlKey:s.includes("Ctrl"),metaKey:s.includes("Meta"),shiftKey:s.includes("Shift"),bubbles:!0,cancelable:!0}),l=t.captureTransaction((()=>{n.someProp("handleKeyDown",(e=>e(n,a)))}));return null==l||l.steps.forEach((e=>{const t=e.map(r.mapping);t&&i&&r.maybeStep(t)})),!0},lift:(e,t={})=>({state:n,dispatch:r})=>!!pa(n,Ro(e,n.schema),t)&&((e,t)=>{let{$from:n,$to:r}=e.selection,i=n.blockRange(r),s=i&&an(i);return null!=s&&(t&&t(e.tr.lift(i,s).scrollIntoView()),!0)})(n,r),liftEmptyBlock:()=>({state:e,dispatch:t})=>((e,t)=>{let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let r=n.before();if(hn(e.doc,r))return t&&t(e.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),i=r&&an(r);return null!=i&&(t&&t(e.tr.lift(r,i).scrollIntoView()),!0)})(e,t),liftListItem:e=>({state:t,dispatch:n})=>Eo(Ro(e,t.schema))(t,n),newlineInCode:()=>({state:e,dispatch:t})=>((e,t)=>{let{$head:n,$anchor:r}=e.selection;return!(!n.parent.type.spec.code||!n.sameParent(r)||(t&&t(e.tr.insertText("\n").scrollIntoView()),0))})(e,t),resetAttributes:(e,t)=>({tr:n,state:r,dispatch:i})=>{let s=null,o=null;const a=fa("string"==typeof e?e:e.name,r.schema);return!!a&&("node"===a&&(s=Ro(e,r.schema)),"mark"===a&&(o=sa(e,r.schema)),i&&n.selection.ranges.forEach((e=>{r.doc.nodesBetween(e.$from.pos,e.$to.pos,((e,r)=>{s&&s===e.type&&n.setNodeMarkup(r,void 0,ma(e.attrs,t)),o&&e.marks.length&&e.marks.forEach((i=>{o===i.type&&n.addMark(r,r+e.nodeSize,o.create(ma(i.attrs,t)))}))}))})),!0)},scrollIntoView:()=>({tr:e,dispatch:t})=>(t&&e.scrollIntoView(),!0),selectAll:()=>({tr:e,commands:t})=>t.setTextSelection({from:0,to:e.doc.content.size}),selectNodeBackward:()=>({state:e,dispatch:t})=>((e,t,n)=>{let{$head:r,empty:i}=e.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",e):r.parentOffset>0)return!1;s=bo(r)}let o=s&&s.nodeBefore;return!(!o||!Bn.isSelectable(o)||(t&&t(e.tr.setSelection(Bn.create(e.doc,s.pos-o.nodeSize)).scrollIntoView()),0))})(e,t),selectNodeForward:()=>({state:e,dispatch:t})=>((e,t,n)=>{let{$head:r,empty:i}=e.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",e):r.parentOffset<r.parent.content.size)return!1;s=wo(r)}let o=s&&s.nodeAfter;return!(!o||!Bn.isSelectable(o)||(t&&t(e.tr.setSelection(Bn.create(e.doc,s.pos)).scrollIntoView()),0))})(e,t),selectParentNode:()=>({state:e,dispatch:t})=>((e,t)=>{let n,{$from:r,to:i}=e.selection,s=r.sharedDepth(i);return 0!=s&&(n=r.before(s),t&&t(e.tr.setSelection(Bn.create(e.doc,n))),!0)})(e,t),selectTextblockEnd:()=>({state:e,dispatch:t})=>Oo(e,t),selectTextblockStart:()=>({state:e,dispatch:t})=>Mo(e,t),setContent:(e,t=!1,n={})=>({tr:r,editor:i,dispatch:s})=>{const{doc:o}=r,a=ga(e,i.schema,n);return s&&r.replaceWith(0,o.content.size,a).setMeta("preventUpdate",!t),!0},setMark:(e,t={})=>({tr:n,state:r,dispatch:i})=>{const{selection:s}=n,{empty:o,ranges:a}=s,l=sa(e,r.schema);if(i)if(o){const e=va(r,l);n.addStoredMark(l.create({...e,...t}))}else a.forEach((e=>{const i=e.$from.pos,s=e.$to.pos;r.doc.nodesBetween(i,s,((e,r)=>{const o=Math.max(r,i),a=Math.min(r+e.nodeSize,s);e.marks.find((e=>e.type===l))?e.marks.forEach((e=>{l===e.type&&n.addMark(o,a,l.create({...e.attrs,...t}))})):n.addMark(o,a,l.create(t))}))}));return function(e,t,n){var r;const{selection:i}=t;let s=null;if(oa(i)&&(s=i.$cursor),s){const t=null!==(r=e.storedMarks)&&void 0!==r?r:s.marks();return!!n.isInSet(t)||!t.some((e=>e.type.excludes(n)))}const{ranges:o}=i;return o.some((({$from:t,$to:r})=>{let i=0===t.depth&&e.doc.inlineContent&&e.doc.type.allowsMarkType(n);return e.doc.nodesBetween(t.pos,r.pos,((e,t,r)=>{if(i)return!1;if(e.isInline){const t=!r||r.type.allowsMarkType(n),s=!!n.isInSet(e.marks)||!e.marks.some((e=>e.type.excludes(n)));i=t&&s}return!i})),i}))}(r,n,l)},setMeta:(e,t)=>({tr:n})=>(n.setMeta(e,t),!0),setNode:(e,t={})=>({state:n,dispatch:r,chain:i})=>{const s=Ro(e,n.schema);return s.isTextblock?i().command((({commands:e})=>!!Ao(s,t)(n)||e.clearNodes())).command((({state:e})=>Ao(s,t)(e,r))).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},setNodeSelection:e=>({tr:t,dispatch:n})=>{if(n){const{doc:n}=t,r=aa(e,0,n.content.size),i=Bn.create(n,r);t.setSelection(i)}return!0},setTextSelection:e=>({tr:t,dispatch:n})=>{if(n){const{doc:n}=t,{from:r,to:i}="number"==typeof e?{from:e,to:e}:e,s=In.atStart(n).from,o=In.atEnd(n).to,a=aa(r,s,o),l=aa(i,s,o),c=In.create(n,a,l);t.setSelection(c)}return!0},sinkListItem:e=>({state:t,dispatch:n})=>{const r=Ro(e,t.schema);return(i=r,function(e,t){let{$from:n,$to:r}=e.selection,s=n.blockRange(r,(e=>e.childCount>0&&e.firstChild.type==i));if(!s)return!1;let o=s.startIndex;if(0==o)return!1;let a=s.parent,l=a.child(o-1);if(l.type!=i)return!1;if(t){let n=l.lastChild&&l.lastChild.type==a.type,r=Ve.from(n?i.create():null),o=new He(Ve.from(i.create(null,Ve.from(a.type.create(null,r)))),n?3:1,0),c=s.start,h=s.end;t(e.tr.step(new rn(c-(n?3:1),h,c,h,o,1,!0)).scrollIntoView())}return!0})(t,n);var i},splitBlock:({keepMarks:e=!0}={})=>({tr:t,state:n,dispatch:r,editor:i})=>{const{selection:s,doc:o}=t,{$from:a,$to:l}=s,c=wa(i.extensionManager.attributes,a.node().type.name,a.node().attrs);if(s instanceof Bn&&s.node.isBlock)return!(!a.parentOffset||!hn(o,a.pos))&&(r&&(e&&Sa(n,i.extensionManager.splittableMarks),t.split(a.pos).scrollIntoView()),!0);if(!a.parent.isBlock)return!1;if(r){const r=l.parentOffset===l.parent.content.size;s instanceof In&&t.deleteSelection();const o=0===a.depth?void 0:function(e){for(let t=0;t<e.edgeCount;t+=1){const{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}(a.node(-1).contentMatchAt(a.indexAfter(-1)));let h=r&&o?[{type:o,attrs:c}]:void 0,d=hn(t.doc,t.mapping.map(a.pos),1,h);if(h||d||!hn(t.doc,t.mapping.map(a.pos),1,o?[{type:o}]:void 0)||(d=!0,h=o?[{type:o,attrs:c}]:void 0),d&&(t.split(t.mapping.map(a.pos),1,h),o&&!r&&!a.parentOffset&&a.parent.type!==o)){const e=t.mapping.map(a.before()),n=t.doc.resolve(e);a.node(-1).canReplaceWith(n.index(),n.index()+1,o)&&t.setNodeMarkup(t.mapping.map(a.before()),o)}e&&Sa(n,i.extensionManager.splittableMarks),t.scrollIntoView()}return!0},splitListItem:e=>({tr:t,state:n,dispatch:r,editor:i})=>{var s;const o=Ro(e,n.schema),{$from:a,$to:l}=n.selection,c=n.selection.node;if(c&&c.isBlock||a.depth<2||!a.sameParent(l))return!1;const h=a.node(-1);if(h.type!==o)return!1;const d=i.extensionManager.attributes;if(0===a.parent.content.size&&a.node(-1).childCount===a.indexAfter(-1)){if(2===a.depth||a.node(-3).type!==o||a.index(-2)!==a.node(-2).childCount-1)return!1;if(r){let e=Ve.empty;const n=a.index(-1)?1:a.index(-2)?2:3;for(let t=a.depth-n;t>=a.depth-3;t-=1)e=Ve.from(a.node(t).copy(e));const r=a.indexAfter(-1)<a.node(-2).childCount?1:a.indexAfter(-2)<a.node(-3).childCount?2:3,i=wa(d,a.node().type.name,a.node().attrs),l=(null===(s=o.contentMatch.defaultType)||void 0===s?void 0:s.createAndFill(i))||void 0;e=e.append(Ve.from(o.createAndFill(null,l)||void 0));const c=a.before(a.depth-(n-1));t.replace(c,a.after(-r),new He(e,4-n,0));let h=-1;t.doc.nodesBetween(c,t.doc.content.size,((e,t)=>{if(h>-1)return!1;e.isTextblock&&0===e.content.size&&(h=t+1)})),h>-1&&t.setSelection(In.near(t.doc.resolve(h))),t.scrollIntoView()}return!0}const u=l.pos===a.end()?h.contentMatchAt(0).defaultType:null,p=wa(d,h.type.name,h.attrs),f=wa(d,a.node().type.name,a.node().attrs);t.delete(a.pos,l.pos);const m=u?[{type:o,attrs:p},{type:u,attrs:f}]:[{type:o,attrs:p}];if(!hn(t.doc,a.pos,2))return!1;if(r){const{selection:e,storedMarks:s}=n,{splittableMarks:o}=i.extensionManager,l=s||e.$to.parentOffset&&e.$from.marks();if(t.split(a.pos,2,m).scrollIntoView(),!l||!r)return!0;const c=l.filter((e=>o.includes(e.type.name)));t.ensureMarks(c)}return!0},toggleList:(e,t,n,r={})=>({editor:i,tr:s,state:o,dispatch:a,chain:l,commands:c,can:h})=>{const{extensions:d,splittableMarks:u}=i.extensionManager,p=Ro(e,o.schema),f=Ro(t,o.schema),{selection:m,storedMarks:g}=o,{$from:y,$to:v}=m,b=y.blockRange(v),w=g||m.$to.parentOffset&&m.$from.marks();if(!b)return!1;const x=ya((e=>ka(e.type.name,d)))(m);if(b.depth>=1&&x&&b.depth-x.depth<=1){if(x.node.type===p)return c.liftListItem(f);if(ka(x.node.type.name,d)&&p.validContent(x.node.content)&&a)return l().command((()=>(s.setNodeMarkup(x.pos,p),!0))).command((()=>Ma(s,p))).command((()=>Oa(s,p))).run()}return n&&w&&a?l().command((()=>{const e=h().wrapInList(p,r),t=w.filter((e=>u.includes(e.type.name)));return s.ensureMarks(t),!!e||c.clearNodes()})).wrapInList(p,r).command((()=>Ma(s,p))).command((()=>Oa(s,p))).run():l().command((()=>!!h().wrapInList(p,r)||c.clearNodes())).wrapInList(p,r).command((()=>Ma(s,p))).command((()=>Oa(s,p))).run()},toggleMark:(e,t={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:s=!1}=n,o=sa(e,r.schema);return xa(r,o,t)?i.unsetMark(o,{extendEmptyMarkRange:s}):i.setMark(o,t)},toggleNode:(e,t,n={})=>({state:r,commands:i})=>{const s=Ro(e,r.schema),o=Ro(t,r.schema);return pa(r,s,n)?i.setNode(o):i.setNode(s,n)},toggleWrap:(e,t={})=>({state:n,commands:r})=>{const i=Ro(e,n.schema);return pa(n,i,t)?r.lift(i):r.wrapIn(i,t)},undoInputRule:()=>({state:e,dispatch:t})=>{const n=e.plugins;for(let r=0;r<n.length;r+=1){const i=n[r];let s;if(i.spec.isInputRules&&(s=i.getState(e))){if(t){const t=e.tr,n=s.transform;for(let e=n.steps.length-1;e>=0;e-=1)t.step(n.steps[e].invert(n.docs[e]));if(s.text){const n=t.doc.resolve(s.from).marks();t.replaceWith(s.from,s.to,e.schema.text(s.text,n))}else t.delete(s.from,s.to)}return!0}}return!1},unsetAllMarks:()=>({tr:e,dispatch:t})=>{const{selection:n}=e,{empty:r,ranges:i}=n;return r||t&&i.forEach((t=>{e.removeMark(t.$from.pos,t.$to.pos)})),!0},unsetMark:(e,t={})=>({tr:n,state:r,dispatch:i})=>{var s;const{extendEmptyMarkRange:o=!1}=t,{selection:a}=n,l=sa(e,r.schema),{$from:c,empty:h,ranges:d}=a;if(!i)return!0;if(h&&o){let{from:e,to:t}=a;const r=null===(s=c.marks().find((e=>e.type===l)))||void 0===s?void 0:s.attrs,i=ia(c,l,r);i&&(e=i.from,t=i.to),n.removeMark(e,t,l)}else d.forEach((e=>{n.removeMark(e.$from.pos,e.$to.pos,l)}));return n.removeStoredMark(l),!0},updateAttributes:(e,t={})=>({tr:n,state:r,dispatch:i})=>{let s=null,o=null;const a=fa("string"==typeof e?e:e.name,r.schema);return!!a&&("node"===a&&(s=Ro(e,r.schema)),"mark"===a&&(o=sa(e,r.schema)),i&&n.selection.ranges.forEach((e=>{const i=e.$from.pos,a=e.$to.pos;r.doc.nodesBetween(i,a,((e,r)=>{s&&s===e.type&&n.setNodeMarkup(r,void 0,{...e.attrs,...t}),o&&e.marks.length&&e.marks.forEach((s=>{if(o===s.type){const l=Math.max(r,i),c=Math.min(r+e.nodeSize,a);n.addMark(l,c,o.create({...s.attrs,...t}))}}))}))})),!0)},wrapIn:(e,t={})=>({state:n,dispatch:r})=>function(e,t=null){return function(n,r){let{$from:i,$to:s}=n.selection,o=i.blockRange(s),a=o&&ln(o,e,t);return!!a&&(r&&r(n.tr.wrap(o,a).scrollIntoView()),!0)}}(Ro(e,n.schema),t)(n,r),wrapInList:(e,t={})=>({state:n,dispatch:r})=>Co(Ro(e,n.schema),t)(n,r)});const Ca=Xo.create({name:"commands",addCommands:()=>({...Aa})}),Ea=Xo.create({name:"editable",addProseMirrorPlugins(){return[new Un({key:new Xn("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Ta=Xo.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:e}=this;return[new Un({key:new Xn("focusEvents"),props:{handleDOMEvents:{focus:(t,n)=>{e.isFocused=!0;const r=e.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return t.dispatch(r),!1},blur:(t,n)=>{e.isFocused=!1;const r=e.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return t.dispatch(r),!1}}}})]}}),Na=Xo.create({name:"keymap",addKeyboardShortcuts(){const e=()=>this.editor.commands.first((({commands:e})=>[()=>e.undoInputRule(),()=>e.command((({tr:t})=>{const{selection:n,doc:r}=t,{empty:i,$anchor:s}=n,{pos:o,parent:a}=s,l=Tn.atStart(r).from===o;return!(!(i&&l&&a.type.isTextblock)||a.textContent.length)&&e.clearNodes()})),()=>e.deleteSelection(),()=>e.joinBackward(),()=>e.selectNodeBackward()])),t=()=>this.editor.commands.first((({commands:e})=>[()=>e.deleteSelection(),()=>e.deleteCurrentNode(),()=>e.joinForward(),()=>e.selectNodeForward()])),n={Enter:()=>this.editor.commands.first((({commands:e})=>[()=>e.newlineInCode(),()=>e.createParagraphNear(),()=>e.liftEmptyBlock(),()=>e.splitBlock()])),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:e,"Mod-Backspace":e,"Shift-Backspace":e,Delete:t,"Mod-Delete":t,"Mod-a":()=>this.editor.commands.selectAll()},r={...n},i={...n,"Ctrl-h":e,"Alt-Backspace":e,"Ctrl-d":t,"Ctrl-Alt-Backspace":t,"Alt-Delete":t,"Alt-d":t,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return ca()||ua()?i:r},addProseMirrorPlugins(){return[new Un({key:new Xn("clearDocument"),appendTransaction:(e,t,n)=>{if(!(e.some((e=>e.docChanged))&&!t.doc.eq(n.doc)))return;const{empty:r,from:i,to:s}=t.selection,o=Tn.atStart(t.doc).from,a=Tn.atEnd(t.doc).to;if(r||!(i===o&&s===a))return;if(!(0===n.doc.textBetween(0,n.doc.content.size," "," ").length))return;const l=n.tr,c=To({state:n,transaction:l}),{commands:h}=new No({editor:this.editor,state:c});return h.clearNodes(),l.steps.length?l:void 0}})]}}),Da=Xo.create({name:"tabindex",addProseMirrorPlugins(){return[new Un({key:new Xn("tabindex"),props:{attributes:this.editor.isEditable?{tabindex:"0"}:{}}})]}});var $a=Object.freeze({__proto__:null,ClipboardTextSerializer:ea,Commands:Ca,Editable:Ea,FocusEvents:Ta,Keymap:Na,Tabindex:Da});class Ia extends class{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){const n=this.callbacks[e];return n&&n.forEach((e=>e.apply(this,t))),this}off(e,t){const n=this.callbacks[e];return n&&(t?this.callbacks[e]=n.filter((e=>e!==t)):delete this.callbacks[e]),this}removeAllListeners(){this.callbacks={}}}{constructor(e={}){super(),this.isFocused=!1,this.extensionStorage={},this.options={element:document.createElement("div"),content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,onBeforeCreate:()=>null,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.createView(),this.injectCSS(),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),window.setTimeout((()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}))}),0)}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&document&&(this.css=function(e,t){const n=document.querySelector("style[data-tiptap-style]");if(null!==n)return n;const r=document.createElement("style");return t&&r.setAttribute("nonce",t),r.setAttribute("data-tiptap-style",""),r.innerHTML=e,document.getElementsByTagName("head")[0].appendChild(r),r}('.ProseMirror {\n position: relative;\n}\n\n.ProseMirror {\n word-wrap: break-word;\n white-space: pre-wrap;\n white-space: break-spaces;\n -webkit-font-variant-ligatures: none;\n font-variant-ligatures: none;\n font-feature-settings: "liga" 0; /* the above doesn\'t seem to work in Edge */\n}\n\n.ProseMirror [contenteditable="false"] {\n white-space: normal;\n}\n\n.ProseMirror [contenteditable="false"] [contenteditable="true"] {\n white-space: pre-wrap;\n}\n\n.ProseMirror pre {\n white-space: pre-wrap;\n}\n\nimg.ProseMirror-separator {\n display: inline !important;\n border: none !important;\n margin: 0 !important;\n width: 1px !important;\n height: 1px !important;\n}\n\n.ProseMirror-gapcursor {\n display: none;\n pointer-events: none;\n position: absolute;\n margin: 0;\n}\n\n.ProseMirror-gapcursor:after {\n content: "";\n display: block;\n position: absolute;\n top: -2px;\n width: 20px;\n border-top: 1px solid black;\n animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;\n}\n\n@keyframes ProseMirror-cursor-blink {\n to {\n visibility: hidden;\n }\n}\n\n.ProseMirror-hideselection *::selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection *::-moz-selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection * {\n caret-color: transparent;\n}\n\n.ProseMirror-focused .ProseMirror-gapcursor {\n display: block;\n}\n\n.tippy-box[data-animation=fade][data-state=hidden] {\n opacity: 0\n}',this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},this.view&&this.state&&!this.isDestroyed&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(e,t=!0){this.setOptions({editable:e}),t&&this.emit("update",{editor:this,transaction:this.state.tr})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get state(){return this.view.state}registerPlugin(e,t){const n=Po(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],r=this.state.reconfigure({plugins:n});this.view.updateState(r)}unregisterPlugin(e){if(this.isDestroyed)return;const t="string"==typeof e?`${e}$`:e.key,n=this.state.reconfigure({plugins:this.state.plugins.filter((e=>!e.key.startsWith(t)))});this.view.updateState(n)}createExtensionManager(){const e=[...this.options.enableCoreExtensions?Object.values($a):[],...this.options.extensions].filter((e=>["extension","node","mark"].includes(null==e?void 0:e.type)));this.extensionManager=new Uo(e,this)}createCommandManager(){this.commandManager=new No({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){const e=ga(this.options.content,this.schema,this.options.parseOptions),t=la(e,this.options.autofocus);this.view=new Qs(this.options.element,{...this.options.editorProps,dispatchTransaction:this.dispatchTransaction.bind(this),state:qn.create({doc:e,selection:t||void 0})});const n=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(n),this.createNodeViews();this.view.dom.editor=this}createNodeViews(){this.view.setProps({nodeViews:this.extensionManager.nodeViews})}captureTransaction(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;const t=this.capturedTransaction;return this.capturedTransaction=null,t}dispatchTransaction(e){if(this.view.isDestroyed)return;if(this.isCapturingTransaction)return this.capturedTransaction?void e.steps.forEach((e=>{var t;return null===(t=this.capturedTransaction)||void 0===t?void 0:t.step(e)})):void(this.capturedTransaction=e);const t=this.state.apply(e),n=!this.state.selection.eq(t.selection);this.view.updateState(t),this.emit("transaction",{editor:this,transaction:e}),n&&this.emit("selectionUpdate",{editor:this,transaction:e});const r=e.getMeta("focus"),i=e.getMeta("blur");r&&this.emit("focus",{editor:this,event:r.event,transaction:e}),i&&this.emit("blur",{editor:this,event:i.event,transaction:e}),e.docChanged&&!e.getMeta("preventUpdate")&&this.emit("update",{editor:this,transaction:e})}getAttributes(e){return ba(this.state,e)}isActive(e,t){const n="string"==typeof e?e:null,r="string"==typeof e?t:e;return function(e,t,n={}){if(!t)return pa(e,null,n)||xa(e,null,n);const r=fa(t,e.schema);return"node"===r?pa(e,t,n):"mark"===r&&xa(e,t,n)}(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return function(e,t){const n=Vt.fromSchema(t).serializeFragment(e),r=document.implementation.createHTMLDocument().createElement("div");return r.appendChild(n),r.innerHTML}(this.state.doc.content,this.schema)}getText(e){const{blockSeparator:t="\n\n",textSerializers:n={}}=e||{};return function(e,t){return Zo(e,{from:0,to:e.content.size},t)}(this.state.doc,{blockSeparator:t,textSerializers:{...Qo(this.schema),...n}})}get isEmpty(){return function(e){var t;const n=null===(t=e.type.createAndFill())||void 0===t?void 0:t.toJSON(),r=e.toJSON();return JSON.stringify(n)===JSON.stringify(r)}(this.state.doc)}getCharacterCount(){return console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.'),this.state.doc.content.size-2}destroy(){this.emit("destroy"),this.view&&this.view.destroy(),this.removeAllListeners()}get isDestroyed(){var e;return!(null===(e=this.view)||void 0===e?void 0:e.docView)}}class Ra{constructor(e={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=Lo(Do(this,"addOptions",{name:this.name}))),this.storage=Lo(Do(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new Ra(e)}configure(e={}){const t=this.extend();return t.options=Yo(this.options,e),t.storage=Lo(Do(t,"addStorage",{name:t.name,options:t.options})),t}extend(e={}){const t=new Ra(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=Lo(Do(t,"addOptions",{name:t.name})),t.storage=Lo(Do(t,"addStorage",{name:t.name,options:t.options})),t}static handleExit({editor:e,mark:t}){const{tr:n}=e.state,r=e.state.selection.$from;if(r.pos===r.end()){const i=r.marks(),s=!!i.find((e=>(null==e?void 0:e.type.name)===t.name));if(!s)return!1;const o=i.find((e=>(null==e?void 0:e.type.name)===t.name));return o&&n.removeStoredMark(o),n.insertText(" ",r.pos),e.view.dispatch(n),!0}return!1}}class Ba{constructor(e={}){this.type="node",this.name="node",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=Lo(Do(this,"addOptions",{name:this.name}))),this.storage=Lo(Do(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new Ba(e)}configure(e={}){const t=this.extend();return t.options=Yo(this.options,e),t.storage=Lo(Do(t,"addStorage",{name:t.name,options:t.options})),t}extend(e={}){const t=new Ba(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=Lo(Do(t,"addOptions",{name:t.name})),t.storage=Lo(Do(t,"addStorage",{name:t.name,options:t.options})),t}}const Fa=Ba.create({name:"doc",topNode:!0,content:"block+"}),Pa=Ba.create({name:"paragraph",priority:1e3,addOptions:()=>({HTMLAttributes:{}}),group:"block",content:"inline*",parseHTML:()=>[{tag:"p"}],renderHTML({HTMLAttributes:e}){return["p",Bo(this.options.HTMLAttributes,e),0]},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),La=Ba.create({name:"text",group:"inline"});function Va(e={}){return new Un({view:t=>new za(t,e)})}class za{constructor(e,t){this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=t.width||1,this.color=t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map((t=>{let n=e=>{this[t](e)};return e.dom.addEventListener(t,n),{name:t,handler:n}}))}destroy(){this.handlers.forEach((({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t)))}update(e,t){null!=this.cursorPos&&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,null==e?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e,t=this.editorView.state.doc.resolve(this.cursorPos);if(!t.parent.inlineContent){let n=t.nodeBefore,r=t.nodeAfter;if(n||r){let t=this.editorView.nodeDOM(this.cursorPos-(n?n.nodeSize:0));if(t){let i=t.getBoundingClientRect(),s=n?i.bottom:i.top;n&&r&&(s=(s+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2),e={left:i.left,right:i.right,top:s-this.width/2,bottom:s+this.width/2}}}}if(!e){let t=this.editorView.coordsAtPos(this.cursorPos);e={left:t.left-this.width/2,right:t.left+this.width/2,top:t.top,bottom:t.bottom}}let n,r,i=this.editorView.dom.offsetParent;if(this.element||(this.element=i.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none; background-color: "+this.color),!i||i==document.body&&"static"==getComputedStyle(i).position)n=-pageXOffset,r=-pageYOffset;else{let e=i.getBoundingClientRect();n=e.left-i.scrollLeft,r=e.top-i.scrollTop}this.element.style.left=e.left-n+"px",this.element.style.top=e.top-r+"px",this.element.style.width=e.right-e.left+"px",this.element.style.height=e.bottom-e.top+"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}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=n&&n.type.spec.disableDropCursor,i="function"==typeof r?r(this.editorView,t,e):r;if(t&&!i){let e=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice&&(e=fn(this.editorView.state.doc,e,this.editorView.dragging.slice),null==e))return this.setCursor(null);this.setCursor(e),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){e.target!=this.editorView.dom&&this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}const ja=Xo.create({name:"dropCursor",addOptions:()=>({color:"currentColor",width:1,class:void 0}),addProseMirrorPlugins(){return[Va(this.options)]}});class _a extends Tn{constructor(e){super(e,e)}map(e,t){let n=e.resolve(t.map(this.head));return _a.valid(n)?new _a(n):Tn.near(n)}content(){return He.empty}eq(e){return e instanceof _a&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for GapCursor.fromJSON");return new _a(e.resolve(t.pos))}getBookmark(){return new Ka(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!function(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(0!=n)for(let e=r.child(n-1);;e=e.lastChild){if(0==e.childCount&&!e.inlineContent||e.isAtom||e.type.spec.isolating)return!0;if(e.inlineContent)return!1}else if(r.type.spec.isolating)return!0}return!0}(e)||!function(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n!=r.childCount)for(let e=r.child(n);;e=e.firstChild){if(0==e.childCount&&!e.inlineContent||e.isAtom||e.type.spec.isolating)return!0;if(e.inlineContent)return!1}else if(r.type.spec.isolating)return!0}return!0}(e))return!1;let n=t.type.spec.allowGapCursor;if(null!=n)return n;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(e,t,n=!1){e:for(;;){if(!n&&_a.valid(e))return e;let r=e.pos,i=null;for(let n=e.depth;;n--){let s=e.node(n);if(t>0?e.indexAfter(n)<s.childCount:e.index(n)>0){i=s.child(t>0?e.indexAfter(n):e.index(n)-1);break}if(0==n)return null;r+=t;let o=e.doc.resolve(r);if(_a.valid(o))return o}for(;;){let s=t>0?i.firstChild:i.lastChild;if(!s){if(i.isAtom&&!i.isText&&!Bn.isSelectable(i)){e=e.doc.resolve(r+i.nodeSize*t),n=!1;continue e}break}i=s,r+=t;let o=e.doc.resolve(r);if(_a.valid(o))return o}return null}}}_a.prototype.visible=!1,_a.findFrom=_a.findGapCursorFrom,Tn.jsonID("gapcursor",_a);class Ka{constructor(e){this.pos=e}map(e){return new Ka(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return _a.valid(t)?new _a(t):Tn.near(t)}}const Wa=yo({ArrowLeft:Ha("horiz",-1),ArrowRight:Ha("horiz",1),ArrowUp:Ha("vert",-1),ArrowDown:Ha("vert",1)});function Ha(e,t){const n="vert"==e?t>0?"down":"up":t>0?"right":"left";return function(e,r,i){let s=e.selection,o=t>0?s.$to:s.$from,a=s.empty;if(s instanceof In){if(!i.endOfTextblock(n)||0==o.depth)return!1;a=!1,o=e.doc.resolve(t>0?o.after():o.before())}let l=_a.findGapCursorFrom(o,t,a);return!!l&&(r&&r(e.tr.setSelection(new _a(l))),!0)}}function qa(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!_a.valid(r))return!1;let i=e.posAtCoords({left:n.clientX,top:n.clientY});return!(i&&i.inside>-1&&Bn.isSelectable(e.state.doc.nodeAt(i.inside)))&&(e.dispatch(e.state.tr.setSelection(new _a(r))),!0)}function Ja(e,t){if("insertCompositionText"!=t.inputType||!(e.state.selection instanceof _a))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let i=Ve.empty;for(let e=r.length-1;e>=0;e--)i=Ve.from(r[e].createAndFill(null,i));let s=e.state.tr.replace(n.pos,n.pos,new He(i,0,0));return s.setSelection(In.near(s.doc.resolve(n.pos+1))),e.dispatch(s),!1}function Ua(e){if(!(e.selection instanceof _a))return null;let t=document.createElement("div");return t.className="ProseMirror-gapcursor",$s.create(e.doc,[Ts.widget(e.selection.head,t,{key:"gapcursor"})])}const Ga=Xo.create({name:"gapCursor",addProseMirrorPlugins:()=>[new Un({props:{decorations:Ua,createSelectionBetween:(e,t,n)=>t.pos==n.pos&&_a.valid(n)?new _a(n):null,handleClick:qa,handleKeyDown:Wa,handleDOMEvents:{beforeinput:Ja}}})],extendNodeSchema(e){var t;return{allowGapCursor:null!==(t=Lo(Do(e,"allowGapCursor",{name:e.name,options:e.options,storage:e.storage})))&&void 0!==t?t:null}}});var Ya=function(){};Ya.prototype.append=function(e){return e.length?(e=Ya.from(e),!this.length&&e||e.length<200&&this.leafAppend(e)||this.length<200&&e.leafPrepend(this)||this.appendInner(e)):this},Ya.prototype.prepend=function(e){return e.length?Ya.from(e).append(this):this},Ya.prototype.appendInner=function(e){return new Za(this,e)},Ya.prototype.slice=function(e,t){return void 0===e&&(e=0),void 0===t&&(t=this.length),e>=t?Ya.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},Ya.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},Ya.prototype.forEach=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},Ya.prototype.map=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length);var r=[];return this.forEach((function(t,n){return r.push(e(t,n))}),t,n),r},Ya.from=function(e){return e instanceof Ya?e:e&&e.length?new Xa(e):Ya.empty};var Xa=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return 0==e&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var i=t;i<n;i++)if(!1===e(this.values[i],r+i))return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){for(var i=t-1;i>=n;i--)if(!1===e(this.values[i],r+i))return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=200)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=200)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(Ya);Ya.empty=new Xa([]);var Za=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,r){var i=this.left.length;return!(t<i&&!1===this.left.forEachInner(e,t,Math.min(n,i),r))&&(!(n>i&&!1===this.right.forEachInner(e,Math.max(t-i,0),Math.min(this.length,n)-i,r+i))&&void 0)},t.prototype.forEachInvertedInner=function(e,t,n,r){var i=this.left.length;return!(t>i&&!1===this.right.forEachInvertedInner(e,t-i,Math.max(n,i)-i,r+i))&&(!(n<i&&!1===this.left.forEachInvertedInner(e,Math.min(t,i),n,r))&&void 0)},t.prototype.sliceInner=function(e,t){if(0==e&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(Ya),Qa=Ya;class el{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(0==this.eventCount)return null;let n,r,i=this.items.length;for(;;i--){if(this.items.get(i-1).selection){--i;break}}t&&(n=this.remapping(i,this.items.length),r=n.maps.length);let s,o,a=e.tr,l=[],c=[];return this.items.forEach(((e,t)=>{if(!e.step)return n||(n=this.remapping(i,t+1),r=n.maps.length),r--,void c.push(e);if(n){c.push(new tl(e.map));let t,i=e.step.map(n.slice(r));i&&a.maybeStep(i).doc&&(t=a.mapping.maps[a.mapping.maps.length-1],l.push(new tl(t,void 0,void 0,l.length+c.length))),r--,t&&n.appendMap(t,r)}else a.maybeStep(e.step);return e.selection?(s=n?e.selection.map(n.slice(r)):e.selection,o=new el(this.items.slice(0,i).append(c.reverse().concat(l)),this.eventCount-1),!1):void 0}),this.items.length,0),{remaining:o,transform:a,selection:s}}addTransform(e,t,n,r){let i=[],s=this.eventCount,o=this.items,a=!r&&o.length?o.get(o.length-1):null;for(let n=0;n<e.steps.length;n++){let l,c=e.steps[n].invert(e.docs[n]),h=new tl(e.mapping.maps[n],c,t);(l=a&&a.merge(h))&&(h=l,n?i.pop():o=o.slice(0,o.length-1)),i.push(h),t&&(s++,t=void 0),r||(a=h)}let l=s-n.depth;return l>rl&&(o=function(e,t){let n;return e.forEach(((e,r)=>{if(e.selection&&0==t--)return n=r,!1})),e.slice(n)}(o,l),s-=l),new el(o.append(i),s)}remapping(e,t){let n=new Jt;return this.items.forEach(((t,r)=>{let i=null!=t.mirrorOffset&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,i)}),e,t),n}addMaps(e){return 0==this.eventCount?this:new el(this.items.append(e.map((e=>new tl(e)))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let n=[],r=Math.max(0,this.items.length-t),i=e.mapping,s=e.steps.length,o=this.eventCount;this.items.forEach((e=>{e.selection&&o--}),r);let a=t;this.items.forEach((t=>{let r=i.getMirror(--a);if(null==r)return;s=Math.min(s,r);let l=i.maps[r];if(t.step){let s=e.steps[r].invert(e.docs[r]),c=t.selection&&t.selection.map(i.slice(a+1,r));c&&o++,n.push(new tl(l,s,c))}else n.push(new tl(l))}),r);let l=[];for(let e=t;e<s;e++)l.push(new tl(i.maps[e]));let c=this.items.slice(0,r).append(l).append(n),h=new el(c,o);return h.emptyItemCount()>500&&(h=h.compress(this.items.length-n.length)),h}emptyItemCount(){let e=0;return this.items.forEach((t=>{t.step||e++})),e}compress(e=this.items.length){let t=this.remapping(0,e),n=t.maps.length,r=[],i=0;return this.items.forEach(((s,o)=>{if(o>=e)r.push(s),s.selection&&i++;else if(s.step){let e=s.step.map(t.slice(n)),o=e&&e.getMap();if(n--,o&&t.appendMap(o,n),e){let a=s.selection&&s.selection.map(t.slice(n));a&&i++;let l,c=new tl(o.invert(),e,a),h=r.length-1;(l=r.length&&r[h].merge(c))?r[h]=l:r.push(c)}}else s.map&&n--}),this.items.length,0),new el(Qa.from(r.reverse()),i)}}el.empty=new el(Qa.empty,0);class tl{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new tl(t.getMap().invert(),t,this.selection)}}}class nl{constructor(e,t,n,r){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r}}const rl=20;function il(e){let t=[];return e.forEach(((e,n,r,i)=>t.push(r,i))),t}function sl(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let i=t.map(e[r],1),s=t.map(e[r+1],-1);i<=s&&n.push(i,s)}return n}function ol(e,t,n,r){let i=cl(t),s=hl.get(t).spec.config,o=(r?e.undone:e.done).popEvent(t,i);if(!o)return;let a=o.selection.resolve(o.transform.doc),l=(r?e.done:e.undone).addTransform(o.transform,t.selection.getBookmark(),s,i),c=new nl(r?l:o.remaining,r?o.remaining:l,null,0);n(o.transform.setSelection(a).setMeta(hl,{redo:r,historyState:c}).scrollIntoView())}let al=!1,ll=null;function cl(e){let t=e.plugins;if(ll!=t){al=!1,ll=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){al=!0;break}}return al}const hl=new Xn("history"),dl=new Xn("closeHistory");function ul(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new Un({key:hl,state:{init:()=>new nl(el.empty,el.empty,null,0),apply:(t,n,r)=>function(e,t,n,r){let i,s=n.getMeta(hl);if(s)return s.historyState;n.getMeta(dl)&&(e=new nl(e.done,e.undone,null,0));let o=n.getMeta("appendedTransaction");if(0==n.steps.length)return e;if(o&&o.getMeta(hl))return o.getMeta(hl).redo?new nl(e.done.addTransform(n,void 0,r,cl(t)),e.undone,il(n.mapping.maps[n.steps.length-1]),e.prevTime):new nl(e.done,e.undone.addTransform(n,void 0,r,cl(t)),null,e.prevTime);if(!1===n.getMeta("addToHistory")||o&&!1===o.getMeta("addToHistory"))return(i=n.getMeta("rebased"))?new nl(e.done.rebased(n,i),e.undone.rebased(n,i),sl(e.prevRanges,n.mapping),e.prevTime):new nl(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),sl(e.prevRanges,n.mapping),e.prevTime);{let i=0==e.prevTime||!o&&(e.prevTime<(n.time||0)-r.newGroupDelay||!function(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach(((e,r)=>{for(let i=0;i<t.length;i+=2)e<=t[i+1]&&r>=t[i]&&(n=!0)})),n}(n,e.prevRanges)),s=o?sl(e.prevRanges,n.mapping):il(n.mapping.maps[n.steps.length-1]);return new nl(e.done.addTransform(n,i?t.selection.getBookmark():void 0,r,cl(t)),el.empty,s,n.time)}}(n,r,t,e)},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r="historyUndo"==n?pl:"historyRedo"==n?fl:null;return!!r&&(t.preventDefault(),r(e.state,e.dispatch))}}}})}const pl=(e,t)=>{let n=hl.getState(e);return!(!n||0==n.done.eventCount)&&(t&&ol(n,e,t,!1),!0)},fl=(e,t)=>{let n=hl.getState(e);return!(!n||0==n.undone.eventCount)&&(t&&ol(n,e,t,!0),!0)},ml=Xo.create({name:"history",addOptions:()=>({depth:100,newGroupDelay:500}),addCommands:()=>({undo:()=>({state:e,dispatch:t})=>pl(e,t),redo:()=>({state:e,dispatch:t})=>fl(e,t)}),addProseMirrorPlugins(){return[ul(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Mod-y":()=>this.editor.commands.redo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}});class gl extends X{connect(){for(const e of this.editorTargets){const t=new Ia({extensions:[ja,Ga,ml,Fa,Pa,La],content:"",injectCSS:!1,element:e,editorProps:{attributes:{class:"ariadne-h-28 ariadne-max-h-48 ariadne-p-2 ariadne-rounded-lg ariadne-overflow-y-auto focus:ariadne-outline-none"}},parseOptions:{preserveWhitespace:!0}}),n=e.previousElementSibling;if(n){const r=e.closest("form");null==r||r.addEventListener("submit",(()=>{n.setAttribute("value",t.getText()||""),t.commands.clearContent()}))}}}}gl.targets=["editor"];class yl extends X{toggle(){this.expandableTarget.classList.toggle("ariadne-hidden");for(const e of this.slidePanelTargets)e.classList.toggle("ariadne-hidden")}}yl.targets=["expandable","expandWrapper","slidePanel","buttonWrapper"];class vl extends X{constructor(){super(...arguments),this.SELECTED_CLASSES=["ariadne-border-slate-500","ariadne-text-slate-600"],this.UNSELECTED_CLASSES=["ariadne-text-gray-500","hover:ariadne-text-gray-700","hover:ariadne-border-gray-300"]}connect(){for(const e of this.tabTargets)e.hasAttribute("aria-current")&&(e.classList.add(...this.SELECTED_CLASSES),e.classList.remove(...this.UNSELECTED_CLASSES))}toggle(e){for(const t of this.tabTargets)t===e.target?(t.setAttribute("aria-current","page"),t.classList.add(...this.SELECTED_CLASSES),t.classList.remove(...this.UNSELECTED_CLASSES)):t.hasAttribute("aria-current")&&(t.removeAttribute("aria-current"),t.classList.add(...this.UNSELECTED_CLASSES),t.classList.remove(...this.SELECTED_CLASSES))}}vl.targets=["tab"];var bl="top",wl="bottom",xl="right",kl="left",Sl=[bl,wl,xl,kl],Ml=Sl.reduce((function(e,t){return e.concat([t+"-start",t+"-end"])}),[]),Ol=[].concat(Sl,["auto"]).reduce((function(e,t){return e.concat([t,t+"-start",t+"-end"])}),[]),Al=["beforeRead","read","afterRead","beforeMain","main","afterMain","beforeWrite","write","afterWrite"];function Cl(e){return e?(e.nodeName||"").toLowerCase():null}function El(e){if(null==e)return window;if("[object Window]"!==e.toString()){var t=e.ownerDocument;return t&&t.defaultView||window}return e}function Tl(e){return e instanceof El(e).Element||e instanceof Element}function Nl(e){return e instanceof El(e).HTMLElement||e instanceof HTMLElement}function Dl(e){return"undefined"!=typeof ShadowRoot&&(e instanceof El(e).ShadowRoot||e instanceof ShadowRoot)}var $l={name:"applyStyles",enabled:!0,phase:"write",fn:function(e){var t=e.state;Object.keys(t.elements).forEach((function(e){var n=t.styles[e]||{},r=t.attributes[e]||{},i=t.elements[e];Nl(i)&&Cl(i)&&(Object.assign(i.style,n),Object.keys(r).forEach((function(e){var t=r[e];!1===t?i.removeAttribute(e):i.setAttribute(e,!0===t?"":t)})))}))},effect:function(e){var t=e.state,n={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(t.elements.popper.style,n.popper),t.styles=n,t.elements.arrow&&Object.assign(t.elements.arrow.style,n.arrow),function(){Object.keys(t.elements).forEach((function(e){var r=t.elements[e],i=t.attributes[e]||{},s=Object.keys(t.styles.hasOwnProperty(e)?t.styles[e]:n[e]).reduce((function(e,t){return e[t]="",e}),{});Nl(r)&&Cl(r)&&(Object.assign(r.style,s),Object.keys(i).forEach((function(e){r.removeAttribute(e)})))}))}},requires:["computeStyles"]};function Il(e){return e.split("-")[0]}var Rl=Math.max,Bl=Math.min,Fl=Math.round;function Pl(){var e=navigator.userAgentData;return null!=e&&e.brands&&Array.isArray(e.brands)?e.brands.map((function(e){return e.brand+"/"+e.version})).join(" "):navigator.userAgent}function Ll(){return!/^((?!chrome|android).)*safari/i.test(Pl())}function Vl(e,t,n){void 0===t&&(t=!1),void 0===n&&(n=!1);var r=e.getBoundingClientRect(),i=1,s=1;t&&Nl(e)&&(i=e.offsetWidth>0&&Fl(r.width)/e.offsetWidth||1,s=e.offsetHeight>0&&Fl(r.height)/e.offsetHeight||1);var o=(Tl(e)?El(e):window).visualViewport,a=!Ll()&&n,l=(r.left+(a&&o?o.offsetLeft:0))/i,c=(r.top+(a&&o?o.offsetTop:0))/s,h=r.width/i,d=r.height/s;return{width:h,height:d,top:c,right:l+h,bottom:c+d,left:l,x:l,y:c}}function zl(e){var t=Vl(e),n=e.offsetWidth,r=e.offsetHeight;return Math.abs(t.width-n)<=1&&(n=t.width),Math.abs(t.height-r)<=1&&(r=t.height),{x:e.offsetLeft,y:e.offsetTop,width:n,height:r}}function jl(e,t){var n=t.getRootNode&&t.getRootNode();if(e.contains(t))return!0;if(n&&Dl(n)){var r=t;do{if(r&&e.isSameNode(r))return!0;r=r.parentNode||r.host}while(r)}return!1}function _l(e){return El(e).getComputedStyle(e)}function Kl(e){return["table","td","th"].indexOf(Cl(e))>=0}function Wl(e){return((Tl(e)?e.ownerDocument:e.document)||window.document).documentElement}function Hl(e){return"html"===Cl(e)?e:e.assignedSlot||e.parentNode||(Dl(e)?e.host:null)||Wl(e)}function ql(e){return Nl(e)&&"fixed"!==_l(e).position?e.offsetParent:null}function Jl(e){for(var t=El(e),n=ql(e);n&&Kl(n)&&"static"===_l(n).position;)n=ql(n);return n&&("html"===Cl(n)||"body"===Cl(n)&&"static"===_l(n).position)?t:n||function(e){var t=/firefox/i.test(Pl());if(/Trident/i.test(Pl())&&Nl(e)&&"fixed"===_l(e).position)return null;var n=Hl(e);for(Dl(n)&&(n=n.host);Nl(n)&&["html","body"].indexOf(Cl(n))<0;){var r=_l(n);if("none"!==r.transform||"none"!==r.perspective||"paint"===r.contain||-1!==["transform","perspective"].indexOf(r.willChange)||t&&"filter"===r.willChange||t&&r.filter&&"none"!==r.filter)return n;n=n.parentNode}return null}(e)||t}function Ul(e){return["top","bottom"].indexOf(e)>=0?"x":"y"}function Gl(e,t,n){return Rl(e,Bl(t,n))}function Yl(e){return Object.assign({},{top:0,right:0,bottom:0,left:0},e)}function Xl(e,t){return t.reduce((function(t,n){return t[n]=e,t}),{})}var Zl={name:"arrow",enabled:!0,phase:"main",fn:function(e){var t,n=e.state,r=e.name,i=e.options,s=n.elements.arrow,o=n.modifiersData.popperOffsets,a=Il(n.placement),l=Ul(a),c=[kl,xl].indexOf(a)>=0?"height":"width";if(s&&o){var h=function(e,t){return Yl("number"!=typeof(e="function"==typeof e?e(Object.assign({},t.rects,{placement:t.placement})):e)?e:Xl(e,Sl))}(i.padding,n),d=zl(s),u="y"===l?bl:kl,p="y"===l?wl:xl,f=n.rects.reference[c]+n.rects.reference[l]-o[l]-n.rects.popper[c],m=o[l]-n.rects.reference[l],g=Jl(s),y=g?"y"===l?g.clientHeight||0:g.clientWidth||0:0,v=f/2-m/2,b=h[u],w=y-d[c]-h[p],x=y/2-d[c]/2+v,k=Gl(b,x,w),S=l;n.modifiersData[r]=((t={})[S]=k,t.centerOffset=k-x,t)}},effect:function(e){var t=e.state,n=e.options.element,r=void 0===n?"[data-popper-arrow]":n;null!=r&&("string"!=typeof r||(r=t.elements.popper.querySelector(r)))&&jl(t.elements.popper,r)&&(t.elements.arrow=r)},requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function Ql(e){return e.split("-")[1]}var ec={top:"auto",right:"auto",bottom:"auto",left:"auto"};function tc(e){var t,n=e.popper,r=e.popperRect,i=e.placement,s=e.variation,o=e.offsets,a=e.position,l=e.gpuAcceleration,c=e.adaptive,h=e.roundOffsets,d=e.isFixed,u=o.x,p=void 0===u?0:u,f=o.y,m=void 0===f?0:f,g="function"==typeof h?h({x:p,y:m}):{x:p,y:m};p=g.x,m=g.y;var y=o.hasOwnProperty("x"),v=o.hasOwnProperty("y"),b=kl,w=bl,x=window;if(c){var k=Jl(n),S="clientHeight",M="clientWidth";if(k===El(n)&&"static"!==_l(k=Wl(n)).position&&"absolute"===a&&(S="scrollHeight",M="scrollWidth"),i===bl||(i===kl||i===xl)&&"end"===s)w=wl,m-=(d&&k===x&&x.visualViewport?x.visualViewport.height:k[S])-r.height,m*=l?1:-1;if(i===kl||(i===bl||i===wl)&&"end"===s)b=xl,p-=(d&&k===x&&x.visualViewport?x.visualViewport.width:k[M])-r.width,p*=l?1:-1}var O,A=Object.assign({position:a},c&&ec),C=!0===h?function(e,t){var n=e.x,r=e.y,i=t.devicePixelRatio||1;return{x:Fl(n*i)/i||0,y:Fl(r*i)/i||0}}({x:p,y:m},El(n)):{x:p,y:m};return p=C.x,m=C.y,l?Object.assign({},A,((O={})[w]=v?"0":"",O[b]=y?"0":"",O.transform=(x.devicePixelRatio||1)<=1?"translate("+p+"px, "+m+"px)":"translate3d("+p+"px, "+m+"px, 0)",O)):Object.assign({},A,((t={})[w]=v?m+"px":"",t[b]=y?p+"px":"",t.transform="",t))}var nc={passive:!0};var rc={left:"right",right:"left",bottom:"top",top:"bottom"};function ic(e){return e.replace(/left|right|bottom|top/g,(function(e){return rc[e]}))}var sc={start:"end",end:"start"};function oc(e){return e.replace(/start|end/g,(function(e){return sc[e]}))}function ac(e){var t=El(e);return{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function lc(e){return Vl(Wl(e)).left+ac(e).scrollLeft}function cc(e){var t=_l(e),n=t.overflow,r=t.overflowX,i=t.overflowY;return/auto|scroll|overlay|hidden/.test(n+i+r)}function hc(e){return["html","body","#document"].indexOf(Cl(e))>=0?e.ownerDocument.body:Nl(e)&&cc(e)?e:hc(Hl(e))}function dc(e,t){var n;void 0===t&&(t=[]);var r=hc(e),i=r===(null==(n=e.ownerDocument)?void 0:n.body),s=El(r),o=i?[s].concat(s.visualViewport||[],cc(r)?r:[]):r,a=t.concat(o);return i?a:a.concat(dc(Hl(o)))}function uc(e){return Object.assign({},e,{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height})}function pc(e,t,n){return"viewport"===t?uc(function(e,t){var n=El(e),r=Wl(e),i=n.visualViewport,s=r.clientWidth,o=r.clientHeight,a=0,l=0;if(i){s=i.width,o=i.height;var c=Ll();(c||!c&&"fixed"===t)&&(a=i.offsetLeft,l=i.offsetTop)}return{width:s,height:o,x:a+lc(e),y:l}}(e,n)):Tl(t)?function(e,t){var n=Vl(e,!1,"fixed"===t);return n.top=n.top+e.clientTop,n.left=n.left+e.clientLeft,n.bottom=n.top+e.clientHeight,n.right=n.left+e.clientWidth,n.width=e.clientWidth,n.height=e.clientHeight,n.x=n.left,n.y=n.top,n}(t,n):uc(function(e){var t,n=Wl(e),r=ac(e),i=null==(t=e.ownerDocument)?void 0:t.body,s=Rl(n.scrollWidth,n.clientWidth,i?i.scrollWidth:0,i?i.clientWidth:0),o=Rl(n.scrollHeight,n.clientHeight,i?i.scrollHeight:0,i?i.clientHeight:0),a=-r.scrollLeft+lc(e),l=-r.scrollTop;return"rtl"===_l(i||n).direction&&(a+=Rl(n.clientWidth,i?i.clientWidth:0)-s),{width:s,height:o,x:a,y:l}}(Wl(e)))}function fc(e,t,n,r){var i="clippingParents"===t?function(e){var t=dc(Hl(e)),n=["absolute","fixed"].indexOf(_l(e).position)>=0&&Nl(e)?Jl(e):e;return Tl(n)?t.filter((function(e){return Tl(e)&&jl(e,n)&&"body"!==Cl(e)})):[]}(e):[].concat(t),s=[].concat(i,[n]),o=s[0],a=s.reduce((function(t,n){var i=pc(e,n,r);return t.top=Rl(i.top,t.top),t.right=Bl(i.right,t.right),t.bottom=Bl(i.bottom,t.bottom),t.left=Rl(i.left,t.left),t}),pc(e,o,r));return a.width=a.right-a.left,a.height=a.bottom-a.top,a.x=a.left,a.y=a.top,a}function mc(e){var t,n=e.reference,r=e.element,i=e.placement,s=i?Il(i):null,o=i?Ql(i):null,a=n.x+n.width/2-r.width/2,l=n.y+n.height/2-r.height/2;switch(s){case bl:t={x:a,y:n.y-r.height};break;case wl:t={x:a,y:n.y+n.height};break;case xl:t={x:n.x+n.width,y:l};break;case kl:t={x:n.x-r.width,y:l};break;default:t={x:n.x,y:n.y}}var c=s?Ul(s):null;if(null!=c){var h="y"===c?"height":"width";switch(o){case"start":t[c]=t[c]-(n[h]/2-r[h]/2);break;case"end":t[c]=t[c]+(n[h]/2-r[h]/2)}}return t}function gc(e,t){void 0===t&&(t={});var n=t,r=n.placement,i=void 0===r?e.placement:r,s=n.strategy,o=void 0===s?e.strategy:s,a=n.boundary,l=void 0===a?"clippingParents":a,c=n.rootBoundary,h=void 0===c?"viewport":c,d=n.elementContext,u=void 0===d?"popper":d,p=n.altBoundary,f=void 0!==p&&p,m=n.padding,g=void 0===m?0:m,y=Yl("number"!=typeof g?g:Xl(g,Sl)),v="popper"===u?"reference":"popper",b=e.rects.popper,w=e.elements[f?v:u],x=fc(Tl(w)?w:w.contextElement||Wl(e.elements.popper),l,h,o),k=Vl(e.elements.reference),S=mc({reference:k,element:b,strategy:"absolute",placement:i}),M=uc(Object.assign({},b,S)),O="popper"===u?M:k,A={top:x.top-O.top+y.top,bottom:O.bottom-x.bottom+y.bottom,left:x.left-O.left+y.left,right:O.right-x.right+y.right},C=e.modifiersData.offset;if("popper"===u&&C){var E=C[i];Object.keys(A).forEach((function(e){var t=[xl,wl].indexOf(e)>=0?1:-1,n=[bl,wl].indexOf(e)>=0?"y":"x";A[e]+=E[n]*t}))}return A}function yc(e,t){void 0===t&&(t={});var n=t,r=n.placement,i=n.boundary,s=n.rootBoundary,o=n.padding,a=n.flipVariations,l=n.allowedAutoPlacements,c=void 0===l?Ol:l,h=Ql(r),d=h?a?Ml:Ml.filter((function(e){return Ql(e)===h})):Sl,u=d.filter((function(e){return c.indexOf(e)>=0}));0===u.length&&(u=d);var p=u.reduce((function(t,n){return t[n]=gc(e,{placement:n,boundary:i,rootBoundary:s,padding:o})[Il(n)],t}),{});return Object.keys(p).sort((function(e,t){return p[e]-p[t]}))}var vc={name:"flip",enabled:!0,phase:"main",fn:function(e){var t=e.state,n=e.options,r=e.name;if(!t.modifiersData[r]._skip){for(var i=n.mainAxis,s=void 0===i||i,o=n.altAxis,a=void 0===o||o,l=n.fallbackPlacements,c=n.padding,h=n.boundary,d=n.rootBoundary,u=n.altBoundary,p=n.flipVariations,f=void 0===p||p,m=n.allowedAutoPlacements,g=t.options.placement,y=Il(g),v=l||(y===g||!f?[ic(g)]:function(e){if("auto"===Il(e))return[];var t=ic(e);return[oc(e),t,oc(t)]}(g)),b=[g].concat(v).reduce((function(e,n){return e.concat("auto"===Il(n)?yc(t,{placement:n,boundary:h,rootBoundary:d,padding:c,flipVariations:f,allowedAutoPlacements:m}):n)}),[]),w=t.rects.reference,x=t.rects.popper,k=new Map,S=!0,M=b[0],O=0;O<b.length;O++){var A=b[O],C=Il(A),E="start"===Ql(A),T=[bl,wl].indexOf(C)>=0,N=T?"width":"height",D=gc(t,{placement:A,boundary:h,rootBoundary:d,altBoundary:u,padding:c}),$=T?E?xl:kl:E?wl:bl;w[N]>x[N]&&($=ic($));var I=ic($),R=[];if(s&&R.push(D[C]<=0),a&&R.push(D[$]<=0,D[I]<=0),R.every((function(e){return e}))){M=A,S=!1;break}k.set(A,R)}if(S)for(var B=function(e){var t=b.find((function(t){var n=k.get(t);if(n)return n.slice(0,e).every((function(e){return e}))}));if(t)return M=t,"break"},F=f?3:1;F>0;F--){if("break"===B(F))break}t.placement!==M&&(t.modifiersData[r]._skip=!0,t.placement=M,t.reset=!0)}},requiresIfExists:["offset"],data:{_skip:!1}};function bc(e,t,n){return void 0===n&&(n={x:0,y:0}),{top:e.top-t.height-n.y,right:e.right-t.width+n.x,bottom:e.bottom-t.height+n.y,left:e.left-t.width-n.x}}function wc(e){return[bl,xl,wl,kl].some((function(t){return e[t]>=0}))}var xc={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:function(e){var t=e.state,n=e.options,r=e.name,i=n.offset,s=void 0===i?[0,0]:i,o=Ol.reduce((function(e,n){return e[n]=function(e,t,n){var r=Il(e),i=[kl,bl].indexOf(r)>=0?-1:1,s="function"==typeof n?n(Object.assign({},t,{placement:e})):n,o=s[0],a=s[1];return o=o||0,a=(a||0)*i,[kl,xl].indexOf(r)>=0?{x:a,y:o}:{x:o,y:a}}(n,t.rects,s),e}),{}),a=o[t.placement],l=a.x,c=a.y;null!=t.modifiersData.popperOffsets&&(t.modifiersData.popperOffsets.x+=l,t.modifiersData.popperOffsets.y+=c),t.modifiersData[r]=o}};var kc={name:"preventOverflow",enabled:!0,phase:"main",fn:function(e){var t=e.state,n=e.options,r=e.name,i=n.mainAxis,s=void 0===i||i,o=n.altAxis,a=void 0!==o&&o,l=n.boundary,c=n.rootBoundary,h=n.altBoundary,d=n.padding,u=n.tether,p=void 0===u||u,f=n.tetherOffset,m=void 0===f?0:f,g=gc(t,{boundary:l,rootBoundary:c,padding:d,altBoundary:h}),y=Il(t.placement),v=Ql(t.placement),b=!v,w=Ul(y),x="x"===w?"y":"x",k=t.modifiersData.popperOffsets,S=t.rects.reference,M=t.rects.popper,O="function"==typeof m?m(Object.assign({},t.rects,{placement:t.placement})):m,A="number"==typeof O?{mainAxis:O,altAxis:O}:Object.assign({mainAxis:0,altAxis:0},O),C=t.modifiersData.offset?t.modifiersData.offset[t.placement]:null,E={x:0,y:0};if(k){if(s){var T,N="y"===w?bl:kl,D="y"===w?wl:xl,$="y"===w?"height":"width",I=k[w],R=I+g[N],B=I-g[D],F=p?-M[$]/2:0,P="start"===v?S[$]:M[$],L="start"===v?-M[$]:-S[$],V=t.elements.arrow,z=p&&V?zl(V):{width:0,height:0},j=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:{top:0,right:0,bottom:0,left:0},_=j[N],K=j[D],W=Gl(0,S[$],z[$]),H=b?S[$]/2-F-W-_-A.mainAxis:P-W-_-A.mainAxis,q=b?-S[$]/2+F+W+K+A.mainAxis:L+W+K+A.mainAxis,J=t.elements.arrow&&Jl(t.elements.arrow),U=J?"y"===w?J.clientTop||0:J.clientLeft||0:0,G=null!=(T=null==C?void 0:C[w])?T:0,Y=I+q-G,X=Gl(p?Bl(R,I+H-G-U):R,I,p?Rl(B,Y):B);k[w]=X,E[w]=X-I}if(a){var Z,Q="x"===w?bl:kl,ee="x"===w?wl:xl,te=k[x],ne="y"===x?"height":"width",re=te+g[Q],ie=te-g[ee],se=-1!==[bl,kl].indexOf(y),oe=null!=(Z=null==C?void 0:C[x])?Z:0,ae=se?re:te-S[ne]-M[ne]-oe+A.altAxis,le=se?te+S[ne]+M[ne]-oe-A.altAxis:ie,ce=p&&se?function(e,t,n){var r=Gl(e,t,n);return r>n?n:r}(ae,te,le):Gl(p?ae:re,te,p?le:ie);k[x]=ce,E[x]=ce-te}t.modifiersData[r]=E}},requiresIfExists:["offset"]};function Sc(e,t,n){void 0===n&&(n=!1);var r,i,s=Nl(t),o=Nl(t)&&function(e){var t=e.getBoundingClientRect(),n=Fl(t.width)/e.offsetWidth||1,r=Fl(t.height)/e.offsetHeight||1;return 1!==n||1!==r}(t),a=Wl(t),l=Vl(e,o,n),c={scrollLeft:0,scrollTop:0},h={x:0,y:0};return(s||!s&&!n)&&(("body"!==Cl(t)||cc(a))&&(c=(r=t)!==El(r)&&Nl(r)?{scrollLeft:(i=r).scrollLeft,scrollTop:i.scrollTop}:ac(r)),Nl(t)?((h=Vl(t,!0)).x+=t.clientLeft,h.y+=t.clientTop):a&&(h.x=lc(a))),{x:l.left+c.scrollLeft-h.x,y:l.top+c.scrollTop-h.y,width:l.width,height:l.height}}function Mc(e){var t=new Map,n=new Set,r=[];function i(e){n.add(e.name),[].concat(e.requires||[],e.requiresIfExists||[]).forEach((function(e){if(!n.has(e)){var r=t.get(e);r&&i(r)}})),r.push(e)}return e.forEach((function(e){t.set(e.name,e)})),e.forEach((function(e){n.has(e.name)||i(e)})),r}var Oc={placement:"bottom",modifiers:[],strategy:"absolute"};function Ac(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return!t.some((function(e){return!(e&&"function"==typeof e.getBoundingClientRect)}))}function Cc(e){void 0===e&&(e={});var t=e,n=t.defaultModifiers,r=void 0===n?[]:n,i=t.defaultOptions,s=void 0===i?Oc:i;return function(e,t,n){void 0===n&&(n=s);var i,o,a={placement:"bottom",orderedModifiers:[],options:Object.assign({},Oc,s),modifiersData:{},elements:{reference:e,popper:t},attributes:{},styles:{}},l=[],c=!1,h={state:a,setOptions:function(n){var i="function"==typeof n?n(a.options):n;d(),a.options=Object.assign({},s,a.options,i),a.scrollParents={reference:Tl(e)?dc(e):e.contextElement?dc(e.contextElement):[],popper:dc(t)};var o=function(e){var t=Mc(e);return Al.reduce((function(e,n){return e.concat(t.filter((function(e){return e.phase===n})))}),[])}(function(e){var t=e.reduce((function(e,t){var n=e[t.name];return e[t.name]=n?Object.assign({},n,t,{options:Object.assign({},n.options,t.options),data:Object.assign({},n.data,t.data)}):t,e}),{});return Object.keys(t).map((function(e){return t[e]}))}([].concat(r,a.options.modifiers)));return a.orderedModifiers=o.filter((function(e){return e.enabled})),a.orderedModifiers.forEach((function(e){var t=e.name,n=e.options,r=void 0===n?{}:n,i=e.effect;if("function"==typeof i){var s=i({state:a,name:t,instance:h,options:r}),o=function(){};l.push(s||o)}})),h.update()},forceUpdate:function(){if(!c){var e=a.elements,t=e.reference,n=e.popper;if(Ac(t,n)){a.rects={reference:Sc(t,Jl(n),"fixed"===a.options.strategy),popper:zl(n)},a.reset=!1,a.placement=a.options.placement,a.orderedModifiers.forEach((function(e){return a.modifiersData[e.name]=Object.assign({},e.data)}));for(var r=0;r<a.orderedModifiers.length;r++)if(!0!==a.reset){var i=a.orderedModifiers[r],s=i.fn,o=i.options,l=void 0===o?{}:o,d=i.name;"function"==typeof s&&(a=s({state:a,options:l,name:d,instance:h})||a)}else a.reset=!1,r=-1}}},update:(i=function(){return new Promise((function(e){h.forceUpdate(),e(a)}))},function(){return o||(o=new Promise((function(e){Promise.resolve().then((function(){o=void 0,e(i())}))}))),o}),destroy:function(){d(),c=!0}};if(!Ac(e,t))return h;function d(){l.forEach((function(e){return e()})),l=[]}return h.setOptions(n).then((function(e){!c&&n.onFirstUpdate&&n.onFirstUpdate(e)})),h}}var Ec=Cc({defaultModifiers:[{name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:function(e){var t=e.state,n=e.instance,r=e.options,i=r.scroll,s=void 0===i||i,o=r.resize,a=void 0===o||o,l=El(t.elements.popper),c=[].concat(t.scrollParents.reference,t.scrollParents.popper);return s&&c.forEach((function(e){e.addEventListener("scroll",n.update,nc)})),a&&l.addEventListener("resize",n.update,nc),function(){s&&c.forEach((function(e){e.removeEventListener("scroll",n.update,nc)})),a&&l.removeEventListener("resize",n.update,nc)}},data:{}},{name:"popperOffsets",enabled:!0,phase:"read",fn:function(e){var t=e.state,n=e.name;t.modifiersData[n]=mc({reference:t.rects.reference,element:t.rects.popper,strategy:"absolute",placement:t.placement})},data:{}},{name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:function(e){var t=e.state,n=e.options,r=n.gpuAcceleration,i=void 0===r||r,s=n.adaptive,o=void 0===s||s,a=n.roundOffsets,l=void 0===a||a,c={placement:Il(t.placement),variation:Ql(t.placement),popper:t.elements.popper,popperRect:t.rects.popper,gpuAcceleration:i,isFixed:"fixed"===t.options.strategy};null!=t.modifiersData.popperOffsets&&(t.styles.popper=Object.assign({},t.styles.popper,tc(Object.assign({},c,{offsets:t.modifiersData.popperOffsets,position:t.options.strategy,adaptive:o,roundOffsets:l})))),null!=t.modifiersData.arrow&&(t.styles.arrow=Object.assign({},t.styles.arrow,tc(Object.assign({},c,{offsets:t.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:l})))),t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-placement":t.placement})},data:{}},$l,xc,vc,kc,Zl,{name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:function(e){var t=e.state,n=e.name,r=t.rects.reference,i=t.rects.popper,s=t.modifiersData.preventOverflow,o=gc(t,{elementContext:"reference"}),a=gc(t,{altBoundary:!0}),l=bc(o,r),c=bc(a,i,s),h=wc(l),d=wc(c);t.modifiersData[n]={referenceClippingOffsets:l,popperEscapeOffsets:c,isReferenceHidden:h,hasPopperEscaped:d},t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-reference-hidden":h,"data-popper-escaped":d})}}]});class Tc extends X{connect(){this.popperInstance=Ec(this.triggerTarget,this.tooltipTarget,{placement:this.placementValue,modifiers:[{name:"offset",options:{offset:this.offsetValue}}]})}disconnect(){this.popperInstance&&this.popperInstance.destroy()}show(){this.tooltipTarget.setAttribute("data-tooltip-show",""),this.tooltipTarget.classList.remove("ariadne-invisible"),this.popperInstance.update(),this.dispatch("shown",{detail:{trigger:this.triggerTarget,tooltip:this.tooltipTarget}})}hide(){this.tooltipTarget.removeAttribute("data-tooltip-show"),this.tooltipTarget.classList.add("ariadne-invisible"),this.dispatch("ariadne-hidden",{detail:{trigger:this.triggerTarget,tooltip:this.tooltipTarget}})}}function Nc(e){return Array.from(e.querySelectorAll('[role="tablist"] [role="tab"]')).filter((t=>t instanceof HTMLElement&&t.closest(e.tagName)===e))}Tc.targets=["trigger","tooltip"],Tc.values={placement:{type:String,default:"top"},offset:{type:Array,default:[0,8]}};class Dc extends HTMLElement{constructor(){super(),this.addEventListener("keydown",(e=>{const t=e.target;if(!(t instanceof HTMLElement))return;if(t.closest(this.tagName)!==this)return;if("tab"!==t.getAttribute("role")&&!t.closest('[role="tablist"]'))return;const n=Nc(this),r=n.indexOf(n.find((e=>e.matches('[aria-selected="true"]')))),[i,s]="vertical"===t.closest('[role="tablist"]')?.getAttribute("aria-orientation")?[["ArrowDown","ArrowRight"],["ArrowUp","ArrowLeft"]]:[["ArrowRight"],["ArrowLeft"]];if(i.some((t=>e.code===t))){let e=r+1;e>=n.length&&(e=0),this.selectTab(e)}else if(s.some((t=>e.code===t))){let e=r-1;e<0&&(e=n.length-1),this.selectTab(e)}else"Home"===e.code?(this.selectTab(0),e.preventDefault()):"End"===e.code&&(this.selectTab(n.length-1),e.preventDefault())})),this.addEventListener("click",(e=>{const t=Nc(this);if(!(e.target instanceof Element))return;if(e.target.closest(this.tagName)!==this)return;const n=e.target.closest('[role="tab"]');if(!(n instanceof HTMLElement&&n.closest('[role="tablist"]')))return;const r=t.indexOf(n);this.selectTab(r)}))}connectedCallback(){for(const e of Nc(this))e.hasAttribute("aria-selected")||e.setAttribute("aria-selected","false"),e.hasAttribute("tabindex")||("true"===e.getAttribute("aria-selected")?e.setAttribute("tabindex","0"):e.setAttribute("tabindex","-1"))}selectTab(e){const t=Nc(this),n=Array.from(this.querySelectorAll('[role="tabpanel"]')).filter((e=>e.closest(this.tagName)===this));if(e>t.length-1)throw new RangeError(`Index "${e}" out of bounds`);const r=t[e],i=n[e];if(!!this.dispatchEvent(new CustomEvent("tab-container-change",{bubbles:!0,cancelable:!0,detail:{relatedTarget:i}}))){for(const e of t)e.setAttribute("aria-selected","false"),e.setAttribute("tabindex","-1");for(const e of n)e.hidden=!0,e.hasAttribute("tabindex")||e.hasAttribute("data-tab-container-no-tabstop")||e.setAttribute("tabindex","0");r.setAttribute("aria-selected","true"),r.setAttribute("tabindex","0"),r.focus(),i.hidden=!1,this.dispatchEvent(new CustomEvent("tab-container-changed",{bubbles:!0,detail:{relatedTarget:i}}))}}}window.customElements.get("tab-container")||(window.TabContainerElement=Dc,window.customElements.define("tab-container",Dc));const $c=["ariadne-border-slate-500","ariadne-text-slate-600"],Ic=["ariadne-text-gray-500","hover:ariadne-text-gray-700","hover:ariadne-border-gray-300"];for(const e of document.getElementsByTagName("tab-container"))e.addEventListener("tab-container-change",(function(e){var t;const n=e.detail.relatedTarget,r=n.closest("tab-container").firstElementChild,i=r.querySelector('[aria-selected="true"]'),s=null===(t=n.getAttribute("id"))||void 0===t?void 0:t.split("-").slice(1).join("-"),o=r.querySelector(`#${s}`);i.classList.remove(...$c),i.classList.add(...Ic),o.classList.add(...$c),o.classList.remove(...Ic)}));const Rc=["second","minute","hour","day","month","year"];const Bc=/^[-+]?P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)W)?(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?)?$/;class Fc{constructor(e=0,t=0,n=0,r=0,i=0,s=0,o=0){this.years=e,this.months=t,this.weeks=n,this.days=r,this.hours=i,this.minutes=s,this.seconds=o}abs(){return new Fc(Math.abs(this.years),Math.abs(this.months),Math.abs(this.weeks),Math.abs(this.days),Math.abs(this.hours),Math.abs(this.minutes),Math.abs(this.seconds))}static from(e){var t;if("string"==typeof e){const n=String(e).trim(),r=n.startsWith("-")?-1:1,i=null===(t=n.match(Bc))||void 0===t?void 0:t.slice(1).map((e=>(Number(e)||0)*r));return i?new Fc(...i):new Fc}if("object"==typeof e){const{years:t,months:n,weeks:r,days:i,hours:s,minutes:o,seconds:a}=e;return new Fc(t,n,r,i,s,o,a)}throw new RangeError("invalid duration")}}function Pc(e,t,n){const r=function(e,t){const n=new Date(e);return n.setFullYear(n.getFullYear()+t.years),n.setMonth(n.getMonth()+t.months),n.setDate(n.getDate()+7*t.weeks+t.days),n.setHours(n.getHours()+t.hours),n.setMinutes(n.getMinutes()+t.minutes),n.setSeconds(n.getSeconds()+t.seconds),n}(e,Fc.from(n).abs());return!r||Math.abs(Number(r)-Number(e))>Math.abs(Number(e)-Number(t))}var Lc,Vc,zc,jc,_c,Kc,Wc,Hc=function(e,t,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(e):r?r.value:t.get(e)},qc=function(e,t,n,r,i){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?i.call(e,n):i?i.value=n:t.set(e,n),n};const Jc=("undefined"!=typeof globalThis?globalThis:window).HTMLElement||null;class Uc extends Event{constructor(e,t,n,r){super("relative-time-updated",{bubbles:!0,composed:!0}),this.oldText=e,this.newText=t,this.oldTitle=n,this.newTitle=r}}function Gc(e){if(!e.date)return 1/0;if("elapsed"===e.format){const t=e.precision;if("second"===t)return 1e3;if("minute"===t)return 6e4}const t=Math.abs(Date.now()-e.date.getTime());return t<6e4?1e3:t<36e5?6e4:36e5}const Yc=new class{constructor(){this.elements=new Set,this.time=1/0,this.timer=-1}observe(e){if(this.elements.has(e))return;this.elements.add(e);const t=e.date;if(t&&t.getTime()){const t=Gc(e),n=Date.now()+t;n<this.time&&(clearTimeout(this.timer),this.timer=setTimeout((()=>this.update()),t),this.time=n)}}unobserve(e){this.elements.has(e)&&this.elements.delete(e)}update(){if(clearTimeout(this.timer),!this.elements.size)return;let e=1/0;for(const t of this.elements)e=Math.min(e,Gc(t)),t.update();this.time=Math.min(36e5,e),this.timer=setTimeout((()=>this.update()),this.time),this.time+=Date.now()}};class Xc extends Jc{constructor(){super(...arguments),Lc.add(this),Vc.set(this,!1),zc.set(this,!1),_c.set(this,this.shadowRoot?this.shadowRoot:this.attachShadow?this.attachShadow({mode:"open"}):this)}static get observedAttributes(){return["second","minute","hour","weekday","day","month","year","time-zone-name","prefix","threshold","tense","precision","format","datetime","lang","title"]}get second(){const e=this.getAttribute("second");if("numeric"===e||"2-digit"===e)return e}set second(e){this.setAttribute("second",e||"")}get minute(){const e=this.getAttribute("minute");if("numeric"===e||"2-digit"===e)return e}set minute(e){this.setAttribute("minute",e||"")}get hour(){const e=this.getAttribute("hour");if("numeric"===e||"2-digit"===e)return e}set hour(e){this.setAttribute("hour",e||"")}get weekday(){const e=this.getAttribute("weekday");if("long"===e||"short"===e||"narrow"===e)return e}set weekday(e){this.setAttribute("weekday",e||"")}get day(){var e;const t=null!==(e=this.getAttribute("day"))&&void 0!==e?e:"numeric";if("numeric"===t||"2-digit"===t)return t}set day(e){this.setAttribute("day",e||"")}get month(){var e;const t=null!==(e=this.getAttribute("month"))&&void 0!==e?e:"short";if("numeric"===t||"2-digit"===t||"short"===t||"long"===t||"narrow"===t)return t}set month(e){this.setAttribute("month",e||"")}get year(){var e;const t=this.getAttribute("year");return"numeric"===t||"2-digit"===t?t:this.hasAttribute("year")||(new Date).getUTCFullYear()===(null===(e=this.date)||void 0===e?void 0:e.getUTCFullYear())?void 0:"numeric"}set year(e){this.setAttribute("day",e||"")}get timeZoneName(){const e=this.getAttribute("time-zone-name");if("long"===e||"short"===e||"shortOffset"===e||"longOffset"===e||"shortGeneric"===e||"longGeneric"===e)return e}set timeZoneName(e){this.setAttribute("time-zone-name",e||"")}get prefix(){var e;return null!==(e=this.getAttribute("prefix"))&&void 0!==e?e:"on"}set prefix(e){this.setAttribute("prefix",e)}get threshold(){const e=this.getAttribute("threshold");return e&&(t=e,Bc.test(t))?e:"P30D";var t}set threshold(e){this.setAttribute("threshold",e)}get tense(){const e=this.getAttribute("tense");return"past"===e?"past":"future"===e?"future":"auto"}set tense(e){this.setAttribute("tense",e)}get precision(){const e=this.getAttribute("precision");return Rc.includes(e)?e:"second"}set precision(e){this.setAttribute("precision",e)}get format(){const e=this.getAttribute("format");return"micro"===e?"micro":"elapsed"===e?"elapsed":"auto"}set format(e){this.setAttribute("format",e)}get datetime(){return this.getAttribute("datetime")||""}set datetime(e){this.setAttribute("datetime",e)}get date(){const e=Date.parse(this.datetime);return Number.isNaN(e)?null:new Date(e)}set date(e){this.datetime=(null==e?void 0:e.toISOString())||""}connectedCallback(){this.update()}disconnectedCallback(){Yc.unobserve(this)}attributeChangedCallback(e,t,n){t!==n&&("title"===e&&qc(this,Vc,null!==n&&Hc(this,Lc,"m",Kc).call(this)!==n,"f"),Hc(this,zc,"f")||"title"===e&&Hc(this,Vc,"f")||qc(this,zc,(async()=>{await Promise.resolve(),this.update()})(),"f"))}update(){const e=Hc(this,_c,"f").textContent||"",t=this.getAttribute("title")||"";let n=t,r=e;const i=new Date;Hc(this,Vc,"f")||(n=Hc(this,Lc,"m",Kc).call(this)||"",n&&this.setAttribute("title",n)),r=Hc(this,Lc,"m",Wc).call(this,i)||"",r?Hc(this,_c,"f").textContent=r:this.shadowRoot===Hc(this,_c,"f")&&this.textContent&&(Hc(this,_c,"f").textContent=this.textContent),r===e&&n===t||this.dispatchEvent(new Uc(e,r,t,n));const s=this.date,o=this.format,a=("auto"===o||"micro"===o)&&s&&Pc(i,s,this.threshold);"elapsed"===o||a?Yc.observe(this):Yc.unobserve(this),qc(this,zc,!1,"f")}}Vc=new WeakMap,zc=new WeakMap,_c=new WeakMap,Lc=new WeakSet,jc=function(){var e,t;return null!==(t=null===(e=this.closest("[lang]"))||void 0===e?void 0:e.getAttribute("lang"))&&void 0!==t?t:"default"},Kc=function(){const e=this.date;if(e&&"undefined"!=typeof Intl&&Intl.DateTimeFormat)return new Intl.DateTimeFormat(Hc(this,Lc,"a",jc),{day:"numeric",month:"short",year:"numeric",hour:"numeric",minute:"2-digit",timeZoneName:"short"}).format(e)},Wc=function(e=new Date){const t=this.date;if(!t)return;const n=this.format;if("elapsed"===n){const e=Rc.indexOf(this.precision)||0,n=function(e){const t=Math.abs(e.getTime()-(new Date).getTime()),n=Math.floor(t/1e3),r=Math.floor(n/60),i=Math.floor(r/60),s=Math.floor(i/24),o=Math.floor(s/30),a=Math.floor(o/12),l=[];return a&&l.push([a,"year"]),o-12*a&&l.push([o-12*a,"month"]),s-30*o&&l.push([s-30*o,"day"]),i-24*s&&l.push([i-24*s,"hour"]),r-60*i&&l.push([r-60*i,"minute"]),n-60*r&&l.push([n-60*r,"second"]),l}(t).filter((t=>Rc.indexOf(t[1])>=e));return n.map((([e,t])=>`${e}${t[0]}`)).join(" ")||`0${this.precision[0]}`}const r=this.tense,i="micro"===n,s=e.getTime()<t.getTime(),o=Pc(e,t,this.threshold),a=Hc(this,Lc,"a",jc);if("undefined"!=typeof Intl&&Intl.RelativeTimeFormat){const e=new Intl.RelativeTimeFormat(a,{numeric:"auto"});if("past"===r||"auto"===r&&!s&&o){const[n,r]=i?function(e){const t=(new Date).getTime()-e.getTime(),n=Math.round(t/1e3),r=Math.round(n/60),i=Math.round(r/60),s=Math.round(i/24),o=Math.round(s/30),a=Math.round(o/12);return r<1?[1,"minute"]:r<60?[r,"minute"]:i<24?[i,"hour"]:s<365?[s,"day"]:[a,"year"]}(t):function(e){const t=(new Date).getTime()-e.getTime(),n=Math.round(t/1e3),r=Math.round(n/60),i=Math.round(r/60),s=Math.round(i/24),o=Math.round(s/30),a=Math.round(o/12);return t<0||n<10?[0,"second"]:n<45?[-n,"second"]:n<90||r<45?[-r,"minute"]:r<90||i<24?[-i,"hour"]:i<36||s<30?[-s,"day"]:o<18?[-o,"month"]:[-a,"year"]}(t);return i?`${n}${r[0]}`:e.format(n,r)}if("future"===r||"auto"===r&&s&&o){const[n,r]=i?function(e){const t=e.getTime()-(new Date).getTime(),n=Math.round(t/1e3),r=Math.round(n/60),i=Math.round(r/60),s=Math.round(i/24),o=Math.round(s/30),a=Math.round(o/12);return s>=365?[a,"year"]:i>=24?[s,"day"]:r>=60?[i,"hour"]:r>1?[r,"minute"]:[1,"minute"]}(t):function(e){const t=e.getTime()-(new Date).getTime(),n=Math.round(t/1e3),r=Math.round(n/60),i=Math.round(r/60),s=Math.round(i/24),o=Math.round(s/30),a=Math.round(o/12);return o>=18||o>=12?[a,"year"]:s>=45||s>=30?[o,"month"]:i>=36||i>=24?[s,"day"]:r>=90||r>=45?[i,"hour"]:n>=90||n>=45?[r,"minute"]:n>=10?[n,"second"]:[0,"second"]}(t);return i?`${n}${r[0]}`:e.format(n,r)}}if("undefined"==typeof Intl||!Intl.DateTimeFormat)return;const l=new Intl.DateTimeFormat(a,{second:this.second,minute:this.minute,hour:this.hour,weekday:this.weekday,day:this.day,month:this.month,year:this.year,timeZoneName:this.timeZoneName});return`${this.prefix} ${l.format(t)}`.trim()};const Zc="undefined"!=typeof globalThis?globalThis:window;try{customElements.define("relative-time",Xc),Zc.RelativeTimeElement=Xc}catch(te){if(!(Zc.DOMException&&te instanceof DOMException&&"NotSupportedError"===te.name||te instanceof ReferenceError))throw te}const Qc=class{constructor(e=document.documentElement,r=_){this.logger=console,this.debug=!1,this.logDebugActivity=(e,t,n={})=>{this.debug&&this.logFormattedMessage(e,t,n)},this.element=e,this.schema=r,this.dispatcher=new t(this),this.router=new j(this),this.actionDescriptorFilters=Object.assign({},n)}static start(e,t){const n=new this(e,t);return n.start(),n}async start(){await new Promise((e=>{"loading"==document.readyState?document.addEventListener("DOMContentLoaded",(()=>e())):e()})),this.logDebugActivity("application","starting"),this.dispatcher.start(),this.router.start(),this.logDebugActivity("application","start")}stop(){this.logDebugActivity("application","stopping"),this.dispatcher.stop(),this.router.stop(),this.logDebugActivity("application","stop")}register(e,t){this.load({identifier:e,controllerConstructor:t})}registerActionOption(e,t){this.actionDescriptorFilters[e]=t}load(e,...t){(Array.isArray(e)?e:[e,...t]).forEach((e=>{e.controllerConstructor.shouldLoad&&this.router.loadDefinition(e)}))}unload(e,...t){(Array.isArray(e)?e:[e,...t]).forEach((e=>this.router.unloadIdentifier(e)))}get controllers(){return this.router.contexts.map((e=>e.controller))}getControllerForElementAndIdentifier(e,t){const n=this.router.getContextForElementAndIdentifier(e,t);return n?n.controller:null}handleError(e,t,n){var r;this.logger.error("%s\n\n%o\n\n%o",t,e,n),null===(r=window.onerror)||void 0===r||r.call(window,t,"",0,0,e)}logFormattedMessage(e,t,n={}){n=Object.assign({application:this},n),this.logger.groupCollapsed(`${e} #${t}`),this.logger.log("details:",Object.assign({},n)),this.logger.groupEnd()}}.start();Qc.register("clipboard-copy-component",class extends X{copy(){const e=this.element.attributes.getNamedItem("value"),t=this.element.attributes.getNamedItem("for");if(e)navigator.clipboard.writeText(e.value);else if(t){const e=document.getElementById(t.value);navigator.clipboard.writeText((null==e?void 0:e.textContent)||"")}else navigator.clipboard.writeText(this.element.textContent||"")}}),Qc.register("ariadne-form",Be),Qc.register("rich-text-area-component",gl),Qc.register("slideover-component",yl),Qc.register("tab-nav-component",vl),Qc.register("tooltip-component",Tc);
7
+ var Z;X.blessings=[function(t){return M(t,"classes").reduce(((t,e)=>{return Object.assign(t,{[`${n=e}Class`]:{get(){const{classes:t}=this;if(t.has(n))return t.get(n);{const e=t.getAttributeName(n);throw new Error(`Missing attribute "${e}"`)}}},[`${n}Classes`]:{get(){return this.classes.getAll(n)}},[`has${a(n)}Class`]:{get(){return this.classes.has(n)}}});var n}),{})},function(t){return M(t,"targets").reduce(((t,e)=>{return Object.assign(t,{[`${n=e}Target`]:{get(){const t=this.targets.find(n);if(t)return t;throw new Error(`Missing target element "${n}" for "${this.identifier}" controller`)}},[`${n}Targets`]:{get(){return this.targets.findAll(n)}},[`has${a(n)}Target`]:{get(){return this.targets.has(n)}}});var n}),{})},function(t){const e=O(t,"values"),n={valueDescriptorMap:{get(){return e.reduce(((t,e)=>{const n=W(e,this.identifier),r=this.data.getAttributeNameForKey(n.key);return Object.assign(t,{[r]:n})}),{})}}};return e.reduce(((t,e)=>Object.assign(t,function(t,e){const n=W(t,e),{key:r,name:i,reader:s,writer:o}=n;return{[i]:{get(){const t=this.data.get(r);return null!==t?s(t):n.defaultValue},set(t){void 0===t?this.data.delete(r):this.data.set(r,o(t))}},[`has${a(i)}`]:{get(){return this.data.has(r)||n.hasCustomDefaultValue}}}}(e))),n)},function(t){return M(t,"outlets").reduce(((t,e)=>Object.assign(t,function(t){const e=o(t);return{[`${e}Outlet`]:{get(){const e=this.outlets.find(t);if(e){const n=this.application.getControllerForElementAndIdentifier(e,t);if(n)return n;throw new Error(`Missing "data-controller=${t}" attribute on outlet element for "${this.identifier}" controller`)}throw new Error(`Missing outlet element "${t}" for "${this.identifier}" controller`)}},[`${e}Outlets`]:{get(){const e=this.outlets.findAll(t);return e.length>0?e.map((e=>{const n=this.application.getControllerForElementAndIdentifier(e,t);if(n)return n;console.warn(`The provided outlet element is missing the outlet controller "${t}" for "${this.identifier}"`,e)})).filter((t=>t)):[]}},[`${e}OutletElement`]:{get(){const e=this.outlets.find(t);if(e)return e;throw new Error(`Missing outlet element "${t}" for "${this.identifier}" controller`)}},[`${e}OutletElements`]:{get(){return this.outlets.findAll(t)}},[`has${a(e)}Outlet`]:{get(){return this.outlets.has(t)}}}}(e))),{})}],X.targets=[],X.outlets=[],X.values={};const Q=window,tt=Q.trustedTypes,et=tt?tt.createPolicy("lit-html",{createHTML:t=>t}):void 0,nt="$lit$",rt=`lit$${(Math.random()+"").slice(9)}$`,it="?"+rt,st=`<${it}>`,ot=document,at=()=>ot.createComment(""),lt=t=>null===t||"object"!=typeof t&&"function"!=typeof t,ct=Array.isArray,ht="[ \t\n\f\r]",dt=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,ut=/-->/g,pt=/>/g,ft=RegExp(`>|${ht}(?:([^\\s"'>=/]+)(${ht}*=${ht}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),mt=/'/g,gt=/"/g,yt=/^(?:script|style|textarea|title)$/i,vt=(t=>(e,...n)=>({_$litType$:t,strings:e,values:n}))(1),bt=Symbol.for("lit-noChange"),wt=Symbol.for("lit-nothing"),xt=new WeakMap,kt=ot.createTreeWalker(ot,129,null,!1),St=(t,e)=>{const n=t.length-1,r=[];let i,s=2===e?"<svg>":"",o=dt;for(let e=0;e<n;e++){const n=t[e];let a,l,c=-1,h=0;for(;h<n.length&&(o.lastIndex=h,l=o.exec(n),null!==l);)h=o.lastIndex,o===dt?"!--"===l[1]?o=ut:void 0!==l[1]?o=pt:void 0!==l[2]?(yt.test(l[2])&&(i=RegExp("</"+l[2],"g")),o=ft):void 0!==l[3]&&(o=ft):o===ft?">"===l[0]?(o=null!=i?i:dt,c=-1):void 0===l[1]?c=-2:(c=o.lastIndex-l[2].length,a=l[1],o=void 0===l[3]?ft:'"'===l[3]?gt:mt):o===gt||o===mt?o=ft:o===ut||o===pt?o=dt:(o=ft,i=void 0);const d=o===ft&&t[e+1].startsWith("/>")?" ":"";s+=o===dt?n+st:c>=0?(r.push(a),n.slice(0,c)+nt+n.slice(c)+rt+d):n+rt+(-2===c?(r.push(void 0),e):d)}const a=s+(t[n]||"<?>")+(2===e?"</svg>":"");if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return[void 0!==et?et.createHTML(a):a,r]};class Mt{constructor({strings:t,_$litType$:e},n){let r;this.parts=[];let i=0,s=0;const o=t.length-1,a=this.parts,[l,c]=St(t,e);if(this.el=Mt.createElement(l,n),kt.currentNode=this.el.content,2===e){const t=this.el.content,e=t.firstChild;e.remove(),t.append(...e.childNodes)}for(;null!==(r=kt.nextNode())&&a.length<o;){if(1===r.nodeType){if(r.hasAttributes()){const t=[];for(const e of r.getAttributeNames())if(e.endsWith(nt)||e.startsWith(rt)){const n=c[s++];if(t.push(e),void 0!==n){const t=r.getAttribute(n.toLowerCase()+nt).split(rt),e=/([.?@])?(.*)/.exec(n);a.push({type:1,index:i,name:e[2],strings:t,ctor:"."===e[1]?Tt:"?"===e[1]?Dt:"@"===e[1]?$t:Ct})}else a.push({type:6,index:i})}for(const e of t)r.removeAttribute(e)}if(yt.test(r.tagName)){const t=r.textContent.split(rt),e=t.length-1;if(e>0){r.textContent=tt?tt.emptyScript:"";for(let n=0;n<e;n++)r.append(t[n],at()),kt.nextNode(),a.push({type:2,index:++i});r.append(t[e],at())}}}else if(8===r.nodeType)if(r.data===it)a.push({type:2,index:i});else{let t=-1;for(;-1!==(t=r.data.indexOf(rt,t+1));)a.push({type:7,index:i}),t+=rt.length-1}i++}}static createElement(t,e){const n=ot.createElement("template");return n.innerHTML=t,n}}function Ot(t,e,n=t,r){var i,s,o,a;if(e===bt)return e;let l=void 0!==r?null===(i=n._$Co)||void 0===i?void 0:i[r]:n._$Cl;const c=lt(e)?void 0:e._$litDirective$;return(null==l?void 0:l.constructor)!==c&&(null===(s=null==l?void 0:l._$AO)||void 0===s||s.call(l,!1),void 0===c?l=void 0:(l=new c(t),l._$AT(t,n,r)),void 0!==r?(null!==(o=(a=n)._$Co)&&void 0!==o?o:a._$Co=[])[r]=l:n._$Cl=l),void 0!==l&&(e=Ot(t,l._$AS(t,e.values),l,r)),e}class At{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){var e;const{el:{content:n},parts:r}=this._$AD,i=(null!==(e=null==t?void 0:t.creationScope)&&void 0!==e?e:ot).importNode(n,!0);kt.currentNode=i;let s=kt.nextNode(),o=0,a=0,l=r[0];for(;void 0!==l;){if(o===l.index){let e;2===l.type?e=new Et(s,s.nextSibling,this,t):1===l.type?e=new l.ctor(s,l.name,l.strings,this,t):6===l.type&&(e=new It(s,this,t)),this._$AV.push(e),l=r[++a]}o!==(null==l?void 0:l.index)&&(s=kt.nextNode(),o++)}return kt.currentNode=ot,i}v(t){let e=0;for(const n of this._$AV)void 0!==n&&(void 0!==n.strings?(n._$AI(t,n,e),e+=n.strings.length-2):n._$AI(t[e])),e++}}class Et{constructor(t,e,n,r){var i;this.type=2,this._$AH=wt,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=n,this.options=r,this._$Cp=null===(i=null==r?void 0:r.isConnected)||void 0===i||i}get _$AU(){var t,e;return null!==(e=null===(t=this._$AM)||void 0===t?void 0:t._$AU)&&void 0!==e?e:this._$Cp}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return void 0!==e&&11===(null==t?void 0:t.nodeType)&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=Ot(this,t,e),lt(t)?t===wt||null==t||""===t?(this._$AH!==wt&&this._$AR(),this._$AH=wt):t!==this._$AH&&t!==bt&&this._(t):void 0!==t._$litType$?this.g(t):void 0!==t.nodeType?this.$(t):(t=>ct(t)||"function"==typeof(null==t?void 0:t[Symbol.iterator]))(t)?this.T(t):this._(t)}k(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}$(t){this._$AH!==t&&(this._$AR(),this._$AH=this.k(t))}_(t){this._$AH!==wt&&lt(this._$AH)?this._$AA.nextSibling.data=t:this.$(ot.createTextNode(t)),this._$AH=t}g(t){var e;const{values:n,_$litType$:r}=t,i="number"==typeof r?this._$AC(t):(void 0===r.el&&(r.el=Mt.createElement(r.h,this.options)),r);if((null===(e=this._$AH)||void 0===e?void 0:e._$AD)===i)this._$AH.v(n);else{const t=new At(i,this),e=t.u(this.options);t.v(n),this.$(e),this._$AH=t}}_$AC(t){let e=xt.get(t.strings);return void 0===e&&xt.set(t.strings,e=new Mt(t)),e}T(t){ct(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let n,r=0;for(const i of t)r===e.length?e.push(n=new Et(this.k(at()),this.k(at()),this,this.options)):n=e[r],n._$AI(i),r++;r<e.length&&(this._$AR(n&&n._$AB.nextSibling,r),e.length=r)}_$AR(t=this._$AA.nextSibling,e){var n;for(null===(n=this._$AP)||void 0===n||n.call(this,!1,!0,e);t&&t!==this._$AB;){const e=t.nextSibling;t.remove(),t=e}}setConnected(t){var e;void 0===this._$AM&&(this._$Cp=t,null===(e=this._$AP)||void 0===e||e.call(this,t))}}class Ct{constructor(t,e,n,r,i){this.type=1,this._$AH=wt,this._$AN=void 0,this.element=t,this.name=e,this._$AM=r,this.options=i,n.length>2||""!==n[0]||""!==n[1]?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=wt}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,e=this,n,r){const i=this.strings;let s=!1;if(void 0===i)t=Ot(this,t,e,0),s=!lt(t)||t!==this._$AH&&t!==bt,s&&(this._$AH=t);else{const r=t;let o,a;for(t=i[0],o=0;o<i.length-1;o++)a=Ot(this,r[n+o],e,o),a===bt&&(a=this._$AH[o]),s||(s=!lt(a)||a!==this._$AH[o]),a===wt?t=wt:t!==wt&&(t+=(null!=a?a:"")+i[o+1]),this._$AH[o]=a}s&&!r&&this.j(t)}j(t){t===wt?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=t?t:"")}}class Tt extends Ct{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===wt?void 0:t}}const Nt=tt?tt.emptyScript:"";class Dt extends Ct{constructor(){super(...arguments),this.type=4}j(t){t&&t!==wt?this.element.setAttribute(this.name,Nt):this.element.removeAttribute(this.name)}}class $t extends Ct{constructor(t,e,n,r,i){super(t,e,n,r,i),this.type=5}_$AI(t,e=this){var n;if((t=null!==(n=Ot(this,t,e,0))&&void 0!==n?n:wt)===bt)return;const r=this._$AH,i=t===wt&&r!==wt||t.capture!==r.capture||t.once!==r.once||t.passive!==r.passive,s=t!==wt&&(r===wt||i);i&&this.element.removeEventListener(this.name,this,r),s&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e,n;"function"==typeof this._$AH?this._$AH.call(null!==(n=null===(e=this.options)||void 0===e?void 0:e.host)&&void 0!==n?n:this.element,t):this._$AH.handleEvent(t)}}class It{constructor(t,e,n){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=n}get _$AU(){return this._$AM._$AU}_$AI(t){Ot(this,t)}}const Rt=Q.litHtmlPolyfillSupport;null==Rt||Rt(Mt,Et),(null!==(Z=Q.litHtmlVersions)&&void 0!==Z?Z:Q.litHtmlVersions=[]).push("2.7.4");class Bt extends X{constructor(){super(...arguments),this.onBlur=t=>{this.validateField(t.target)},this.onSubmit=t=>{var e;this.validateForm()||(t.preventDefault(),null===(e=this.firstInvalidField)||void 0===e||e.focus())},this.getRenderString=t=>{const{strings:e,values:n}=t,r=[...n,""].map((t=>"object"==typeof t?this.getRenderString(t):t));return e.reduce(((t,e,n)=>t+e+r[n]),"")}}connect(){this.element.setAttribute("novalidate","true"),this.element.addEventListener("blur",this.onBlur,!0),this.element.addEventListener("submit",this.onSubmit),this.element.addEventListener("ajax:beforeSend",this.onSubmit)}disconnect(){this.element.removeEventListener("blur",this.onBlur),this.element.removeEventListener("submit",this.onSubmit),this.element.removeEventListener("ajax:beforeSend",this.onSubmit)}validateForm(){let t=!0;for(const e of this.formFields)this.shouldValidateField(e)&&!this.validateField(e)&&(t=!1);return t}validateField(t){if(!this.shouldValidateField(t))return!0;const e=t.checkValidity();return t.classList.toggle("invalid",!e),this.refreshErrorForInvalidField(t,e),e}shouldValidateField(t){return!t.disabled&&!t.classList.contains("ProseMirror")&&!["file","reset","submit","button"].includes(t.type)}refreshErrorForInvalidField(t,e){this.removeExistingErrorMessage(t),e||this.showErrorForInvalidField(t)}removeExistingErrorMessage(t){var e;const n=t.closest(".field");if(!n)return;const r=n.querySelector(".error");r&&(null===(e=null==r?void 0:r.parentNode)||void 0===e||e.removeChild(r))}showErrorForInvalidField(t){t.insertAdjacentHTML("afterend",this.buildFieldErrorHtml(t))}buildFieldErrorHtml(t){const e=vt`<p class="error">${t.validationMessage}</p>`;return this.getRenderString(e)}get formFields(){return Array.from(this.formFieldTargets)}get firstInvalidField(){return this.formFields.find((t=>!t.checkValidity()))}}function Ft(t,e,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(t):r?r.value:e.get(t)}var Pt,Vt,Lt;Bt.targets=["formField"];class zt extends X{constructor(){super(...arguments),Pt.add(this)}connect(){this.select(new Event("Init"),this.activeIndexValue)}select(t,e){for(let n in this.optionTargets){const r=this.optionTargets[n],i=void 0===e?r===t.currentTarget:Number(n)===Number(e);i&&(this.activeIndexValue=Number(n)),Ft(this,Pt,"m",Vt).call(this,r,i)}}}Pt=new WeakSet,Vt=function(t,e){this.hasSyncedAttrsValue&&Ft(this,Pt,"m",Lt).call(this,t,this.syncedAttrsValue,e),this.hasAntiAttrsValue&&Ft(this,Pt,"m",Lt).call(this,t,this.antiAttrsValue,!e)},Lt=function(t,e,n){const r=String(n);for(let n in e){const i=e[n];t.setAttribute(i,r)}},zt.targets=["option"],zt.values={activeIndex:{type:Number,default:0},syncedAttrs:Array,antiAttrs:Array};class jt extends X{connect(){this.accumulate()}accumulate(){let t=0;for(let e in this.sumTargets){const n=this.sumTargets[e],r=Number(n.getAttribute(this.sumAttrValue));isNaN(r)||(t+=r)}this.setAttributesTo(t)}setAttributesTo(t){for(let e in this.syncAttrsValue){const n=this.syncAttrsValue[e];this.accumulator.setAttribute(n,t.toString())}}get accumulator(){var t;return null!==(t=this.accumulatorTarget)&&void 0!==t?t:this.element}}jt.targets=["sum","accumulator"],jt.values={syncAttrs:{type:Array,default:["aria-valuenow"]},sumAttr:{type:"string",default:"data-value"}};const _t={events:["click","touchend"],onlyVisible:!0,dispatchEvent:!0,eventPrefix:!0},Kt=(t,e={})=>{const n=t,{onlyVisible:r,dispatchEvent:i,events:s,eventPrefix:o}=Object.assign({},_t,e),a=t=>{const s=(null==e?void 0:e.element)||n.element;if(!(s.contains(t.target)||!function(t){const e=t.getBoundingClientRect(),n=window.innerHeight||document.documentElement.clientHeight,r=window.innerWidth||document.documentElement.clientWidth,i=e.top<=n&&e.top+e.height>0,s=e.left<=r&&e.left+e.width>0;return i&&s}(s)&&r)&&(n.clickOutside&&n.clickOutside(t),i)){const e=((t,e,n)=>{let r=t;return!0===n?r=`${e.identifier}:${t}`:"string"==typeof n&&(r=`${n}:${t}`),r})("click:outside",n,o),r=((t,e,n)=>{const{bubbles:r,cancelable:i,composed:s}=e||{bubbles:!0,cancelable:!0,composed:!0};return e&&Object.assign(n,{originalEvent:e}),new CustomEvent(t,{bubbles:r,cancelable:i,composed:s,detail:n})})(e,t,{controller:n});s.dispatchEvent(r)}},l=()=>{null==s||s.forEach((t=>{window.addEventListener(t,a,!0)}))},c=()=>{null==s||s.forEach((t=>{window.removeEventListener(t,a,!0)}))},h=n.disconnect.bind(n);return Object.assign(n,{disconnect(){c(),h()}}),l(),[l,c]};(class extends X{}).debounces=[];var Wt,Ht,qt,Jt;(class extends X{}).throttles=[];class Ut extends X{constructor(){super(...arguments),Wt.add(this)}connect(){Ft(this,Wt,"m",Ht).call(this),Ft(this,Wt,"m",Jt).call(this,new Event("Init")),Kt(this,{dispatchEvent:this.closeOnOutsideClickValue})}toggle(t,e){this.stateValue=null!=e?e:!this.stateValue,Ft(this,Wt,"m",Ht).call(this),Ft(this,Wt,"m",Jt).call(this,t)}clickOutside(t){this.closeOnOutsideClickValue&&this.toggle(t,!1)}}Wt=new WeakSet,Ht=function(){this.hasSyncedAttrsValue&&Ft(this,Wt,"m",qt).call(this,this.syncedAttrsValue),this.hasAntiAttrsValue&&Ft(this,Wt,"m",qt).call(this,this.antiAttrsValue,!1)},qt=function(t,e=!0){const n=String(e?this.stateValue:!this.stateValue);for(let e in t){const r=t[e];"false"===n&&Ut.removeOnFalseAttrs[r]?this.element.removeAttribute(r):this.element.setAttribute(r,n)}},Jt=function(t){if(this.hasToggleableOutlet)for(let e in this.toggleableOutlets){this.toggleableOutlets[e].toggle(t,this.stateValue)}},Ut.outlets=["toggleable"],Ut.values={state:{type:Boolean,default:!1},syncedAttrs:Array,antiAttrs:Array,closeOnOutsideClick:{type:Boolean,default:!1}},Ut.removeOnFalseAttrs={checked:!0};function Gt(t){this.content=t}function Yt(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let i=t.child(r),s=e.child(r);if(i!=s){if(!i.sameMarkup(s))return n;if(i.isText&&i.text!=s.text){for(let t=0;i.text[t]==s.text[t];t++)n++;return n}if(i.content.size||s.content.size){let t=Yt(i.content,s.content,n+1);if(null!=t)return t}n+=i.nodeSize}else n+=i.nodeSize}}function Xt(t,e,n,r){for(let i=t.childCount,s=e.childCount;;){if(0==i||0==s)return i==s?null:{a:n,b:r};let o=t.child(--i),a=e.child(--s),l=o.nodeSize;if(o!=a){if(!o.sameMarkup(a))return{a:n,b:r};if(o.isText&&o.text!=a.text){let t=0,e=Math.min(o.text.length,a.text.length);for(;t<e&&o.text[o.text.length-t-1]==a.text[a.text.length-t-1];)t++,n--,r--;return{a:n,b:r}}if(o.content.size||a.content.size){let t=Xt(o.content,a.content,n-1,r-1);if(t)return t}n-=l,r-=l}else n-=l,r-=l}}Gt.prototype={constructor:Gt,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return-1==e?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,i=r.find(t),s=r.content.slice();return-1==i?s.push(n||t,e):(s[i+1]=e,n&&(s[i]=n)),new Gt(s)},remove:function(t){var e=this.find(t);if(-1==e)return this;var n=this.content.slice();return n.splice(e,2),new Gt(n)},addToStart:function(t,e){return new Gt([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new Gt(n)},addBefore:function(t,e,n){var r=this.remove(e),i=r.content.slice(),s=r.find(t);return i.splice(-1==s?i.length:s,0,e,n),new Gt(i)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return(t=Gt.from(t)).size?new Gt(t.content.concat(this.subtract(t).content)):this},append:function(t){return(t=Gt.from(t)).size?new Gt(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=Gt.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},get size(){return this.content.length>>1}},Gt.from=function(t){if(t instanceof Gt)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new Gt(e)};class Zt{constructor(t,e){if(this.content=t,this.size=e||0,null==e)for(let e=0;e<t.length;e++)this.size+=t[e].nodeSize}nodesBetween(t,e,n,r=0,i){for(let s=0,o=0;o<e;s++){let a=this.content[s],l=o+a.nodeSize;if(l>t&&!1!==n(a,r+o,i||null,s)&&a.content.size){let i=o+1;a.nodesBetween(Math.max(0,t-i),Math.min(a.content.size,e-i),n,r+i)}o=l}}descendants(t){this.nodesBetween(0,this.size,t)}textBetween(t,e,n,r){let i="",s=!0;return this.nodesBetween(t,e,((o,a)=>{o.isText?(i+=o.text.slice(Math.max(t,a)-a,e-a),s=!n):o.isLeaf?(r?i+="function"==typeof r?r(o):r:o.type.spec.leafText&&(i+=o.type.spec.leafText(o)),s=!n):!s&&o.isBlock&&(i+=n,s=!0)}),0),i}append(t){if(!t.size)return this;if(!this.size)return t;let e=this.lastChild,n=t.firstChild,r=this.content.slice(),i=0;for(e.isText&&e.sameMarkup(n)&&(r[r.length-1]=e.withText(e.text+n.text),i=1);i<t.content.length;i++)r.push(t.content[i]);return new Zt(r,this.size+t.size)}cut(t,e=this.size){if(0==t&&e==this.size)return this;let n=[],r=0;if(e>t)for(let i=0,s=0;s<e;i++){let o=this.content[i],a=s+o.nodeSize;a>t&&((s<t||a>e)&&(o=o.isText?o.cut(Math.max(0,t-s),Math.min(o.text.length,e-s)):o.cut(Math.max(0,t-s-1),Math.min(o.content.size,e-s-1))),n.push(o),r+=o.nodeSize),s=a}return new Zt(n,r)}cutByIndex(t,e){return t==e?Zt.empty:0==t&&e==this.content.length?this:new Zt(this.content.slice(t,e))}replaceChild(t,e){let n=this.content[t];if(n==e)return this;let r=this.content.slice(),i=this.size+e.nodeSize-n.nodeSize;return r[t]=e,new Zt(r,i)}addToStart(t){return new Zt([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new Zt(this.content.concat(t),this.size+t.nodeSize)}eq(t){if(this.content.length!=t.content.length)return!1;for(let e=0;e<this.content.length;e++)if(!this.content[e].eq(t.content[e]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(t){let e=this.content[t];if(!e)throw new RangeError("Index "+t+" out of range for "+this);return e}maybeChild(t){return this.content[t]||null}forEach(t){for(let e=0,n=0;e<this.content.length;e++){let r=this.content[e];t(r,n,e),n+=r.nodeSize}}findDiffStart(t,e=0){return Yt(this,t,e)}findDiffEnd(t,e=this.size,n=t.size){return Xt(this,t,e,n)}findIndex(t,e=-1){if(0==t)return te(0,t);if(t==this.size)return te(this.content.length,t);if(t>this.size||t<0)throw new RangeError(`Position ${t} outside of fragment (${this})`);for(let n=0,r=0;;n++){let i=r+this.child(n).nodeSize;if(i>=t)return i==t||e>0?te(n+1,i):te(n,r);r=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map((t=>t.toJSON())):null}static fromJSON(t,e){if(!e)return Zt.empty;if(!Array.isArray(e))throw new RangeError("Invalid input for Fragment.fromJSON");return new Zt(e.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return Zt.empty;let e,n=0;for(let r=0;r<t.length;r++){let i=t[r];n+=i.nodeSize,r&&i.isText&&t[r-1].sameMarkup(i)?(e||(e=t.slice(0,r)),e[e.length-1]=i.withText(e[e.length-1].text+i.text)):e&&e.push(i)}return new Zt(e||t,n)}static from(t){if(!t)return Zt.empty;if(t instanceof Zt)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new Zt([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}Zt.empty=new Zt([],0);const Qt={index:0,offset:0};function te(t,e){return Qt.index=t,Qt.offset=e,Qt}function ee(t,e){if(t===e)return!0;if(!t||"object"!=typeof t||!e||"object"!=typeof e)return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!ee(t[n],e[n]))return!1}else{for(let n in t)if(!(n in e)||!ee(t[n],e[n]))return!1;for(let n in e)if(!(n in t))return!1}return!0}class ne{constructor(t,e){this.type=t,this.attrs=e}addToSet(t){let e,n=!1;for(let r=0;r<t.length;r++){let i=t[r];if(this.eq(i))return t;if(this.type.excludes(i.type))e||(e=t.slice(0,r));else{if(i.type.excludes(this.type))return t;!n&&i.type.rank>this.type.rank&&(e||(e=t.slice(0,r)),e.push(this),n=!0),e&&e.push(i)}}return e||(e=t.slice()),n||e.push(this),e}removeFromSet(t){for(let e=0;e<t.length;e++)if(this.eq(t[e]))return t.slice(0,e).concat(t.slice(e+1));return t}isInSet(t){for(let e=0;e<t.length;e++)if(this.eq(t[e]))return!0;return!1}eq(t){return this==t||this.type==t.type&&ee(this.attrs,t.attrs)}toJSON(){let t={type:this.type.name};for(let e in this.attrs){t.attrs=this.attrs;break}return t}static fromJSON(t,e){if(!e)throw new RangeError("Invalid input for Mark.fromJSON");let n=t.marks[e.type];if(!n)throw new RangeError(`There is no mark type ${e.type} in this schema`);return n.create(e.attrs)}static sameSet(t,e){if(t==e)return!0;if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].eq(e[n]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&0==t.length)return ne.none;if(t instanceof ne)return[t];let e=t.slice();return e.sort(((t,e)=>t.type.rank-e.type.rank)),e}}ne.none=[];class re extends Error{}class ie{constructor(t,e,n){this.content=t,this.openStart=e,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,e){let n=oe(this.content,t+this.openStart,e);return n&&new ie(n,this.openStart,this.openEnd)}removeBetween(t,e){return new ie(se(this.content,t+this.openStart,e+this.openStart),this.openStart,this.openEnd)}eq(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let t={content:this.content.toJSON()};return this.openStart>0&&(t.openStart=this.openStart),this.openEnd>0&&(t.openEnd=this.openEnd),t}static fromJSON(t,e){if(!e)return ie.empty;let n=e.openStart||0,r=e.openEnd||0;if("number"!=typeof n||"number"!=typeof r)throw new RangeError("Invalid input for Slice.fromJSON");return new ie(Zt.fromJSON(t,e.content),n,r)}static maxOpen(t,e=!0){let n=0,r=0;for(let r=t.firstChild;r&&!r.isLeaf&&(e||!r.type.spec.isolating);r=r.firstChild)n++;for(let n=t.lastChild;n&&!n.isLeaf&&(e||!n.type.spec.isolating);n=n.lastChild)r++;return new ie(t,n,r)}}function se(t,e,n){let{index:r,offset:i}=t.findIndex(e),s=t.maybeChild(r),{index:o,offset:a}=t.findIndex(n);if(i==e||s.isText){if(a!=n&&!t.child(o).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(r,s.copy(se(s.content,e-i-1,n-i-1)))}function oe(t,e,n,r){let{index:i,offset:s}=t.findIndex(e),o=t.maybeChild(i);if(s==e||o.isText)return r&&!r.canReplace(i,i,n)?null:t.cut(0,e).append(n).append(t.cut(e));let a=oe(o.content,e-s-1,n);return a&&t.replaceChild(i,o.copy(a))}function ae(t,e,n){if(n.openStart>t.depth)throw new re("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new re("Inconsistent open depths");return le(t,e,n,0)}function le(t,e,n,r){let i=t.index(r),s=t.node(r);if(i==e.index(r)&&r<t.depth-n.openStart){let o=le(t,e,n,r+1);return s.copy(s.content.replaceChild(i,o))}if(n.content.size){if(n.openStart||n.openEnd||t.depth!=r||e.depth!=r){let{start:i,end:o}=function(t,e){let n=e.depth-t.openStart,r=e.node(n).copy(t.content);for(let t=n-1;t>=0;t--)r=e.node(t).copy(Zt.from(r));return{start:r.resolveNoCache(t.openStart+n),end:r.resolveNoCache(r.content.size-t.openEnd-n)}}(n,t);return pe(s,fe(t,i,o,e,r))}{let r=t.parent,i=r.content;return pe(r,i.cut(0,t.parentOffset).append(n.content).append(i.cut(e.parentOffset)))}}return pe(s,me(t,e,r))}function ce(t,e){if(!e.type.compatibleContent(t.type))throw new re("Cannot join "+e.type.name+" onto "+t.type.name)}function he(t,e,n){let r=t.node(n);return ce(r,e.node(n)),r}function de(t,e){let n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function ue(t,e,n,r){let i=(e||t).node(n),s=0,o=e?e.index(n):i.childCount;t&&(s=t.index(n),t.depth>n?s++:t.textOffset&&(de(t.nodeAfter,r),s++));for(let t=s;t<o;t++)de(i.child(t),r);e&&e.depth==n&&e.textOffset&&de(e.nodeBefore,r)}function pe(t,e){return t.type.checkContent(e),t.copy(e)}function fe(t,e,n,r,i){let s=t.depth>i&&he(t,e,i+1),o=r.depth>i&&he(n,r,i+1),a=[];return ue(null,t,i,a),s&&o&&e.index(i)==n.index(i)?(ce(s,o),de(pe(s,fe(t,e,n,r,i+1)),a)):(s&&de(pe(s,me(t,e,i+1)),a),ue(e,n,i,a),o&&de(pe(o,me(n,r,i+1)),a)),ue(r,null,i,a),new Zt(a)}function me(t,e,n){let r=[];if(ue(null,t,n,r),t.depth>n){de(pe(he(t,e,n+1),me(t,e,n+1)),r)}return ue(e,null,n,r),new Zt(r)}ie.empty=new ie(Zt.empty,0,0);class ge{constructor(t,e,n){this.pos=t,this.path=e,this.parentOffset=n,this.depth=e.length/3-1}resolveDepth(t){return null==t?this.depth:t<0?this.depth+t:t}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(t){return this.path[3*this.resolveDepth(t)]}index(t){return this.path[3*this.resolveDepth(t)+1]}indexAfter(t){return t=this.resolveDepth(t),this.index(t)+(t!=this.depth||this.textOffset?1:0)}start(t){return 0==(t=this.resolveDepth(t))?0:this.path[3*t-1]+1}end(t){return t=this.resolveDepth(t),this.start(t)+this.node(t).content.size}before(t){if(!(t=this.resolveDepth(t)))throw new RangeError("There is no position before the top-level node");return t==this.depth+1?this.pos:this.path[3*t-1]}after(t){if(!(t=this.resolveDepth(t)))throw new RangeError("There is no position after the top-level node");return t==this.depth+1?this.pos:this.path[3*t-1]+this.path[3*t].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let t=this.parent,e=this.index(this.depth);if(e==t.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=t.child(e);return n?t.child(e).cut(n):r}get nodeBefore(){let t=this.index(this.depth),e=this.pos-this.path[this.path.length-1];return e?this.parent.child(t).cut(0,e):0==t?null:this.parent.child(t-1)}posAtIndex(t,e){e=this.resolveDepth(e);let n=this.path[3*e],r=0==e?0:this.path[3*e-1]+1;for(let e=0;e<t;e++)r+=n.child(e).nodeSize;return r}marks(){let t=this.parent,e=this.index();if(0==t.content.size)return ne.none;if(this.textOffset)return t.child(e).marks;let n=t.maybeChild(e-1),r=t.maybeChild(e);if(!n){let t=n;n=r,r=t}let i=n.marks;for(var s=0;s<i.length;s++)!1!==i[s].type.spec.inclusive||r&&i[s].isInSet(r.marks)||(i=i[s--].removeFromSet(i));return i}marksAcross(t){let e=this.parent.maybeChild(this.index());if(!e||!e.isInline)return null;let n=e.marks,r=t.parent.maybeChild(t.index());for(var i=0;i<n.length;i++)!1!==n[i].type.spec.inclusive||r&&n[i].isInSet(r.marks)||(n=n[i--].removeFromSet(n));return n}sharedDepth(t){for(let e=this.depth;e>0;e--)if(this.start(e)<=t&&this.end(e)>=t)return e;return 0}blockRange(t=this,e){if(t.pos<this.pos)return t.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==t.pos?1:0);n>=0;n--)if(t.pos<=this.end(n)&&(!e||e(this.node(n))))return new we(this,t,n);return null}sameParent(t){return this.pos-this.parentOffset==t.pos-t.parentOffset}max(t){return t.pos>this.pos?t:this}min(t){return t.pos<this.pos?t:this}toString(){let t="";for(let e=1;e<=this.depth;e++)t+=(t?"/":"")+this.node(e).type.name+"_"+this.index(e-1);return t+":"+this.parentOffset}static resolve(t,e){if(!(e>=0&&e<=t.content.size))throw new RangeError("Position "+e+" out of range");let n=[],r=0,i=e;for(let e=t;;){let{index:t,offset:s}=e.content.findIndex(i),o=i-s;if(n.push(e,t,r+s),!o)break;if(e=e.child(t),e.isText)break;i=o-1,r+=s+1}return new ge(e,n,i)}static resolveCached(t,e){for(let n=0;n<ye.length;n++){let r=ye[n];if(r.pos==e&&r.doc==t)return r}let n=ye[ve]=ge.resolve(t,e);return ve=(ve+1)%be,n}}let ye=[],ve=0,be=12;class we{constructor(t,e,n){this.$from=t,this.$to=e,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const xe=Object.create(null);class ke{constructor(t,e,n,r=ne.none){this.type=t,this.attrs=e,this.marks=r,this.content=n||Zt.empty}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(t){return this.content.child(t)}maybeChild(t){return this.content.maybeChild(t)}forEach(t){this.content.forEach(t)}nodesBetween(t,e,n,r=0){this.content.nodesBetween(t,e,n,r,this)}descendants(t){this.nodesBetween(0,this.content.size,t)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(t,e,n,r){return this.content.textBetween(t,e,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(t){return this==t||this.sameMarkup(t)&&this.content.eq(t.content)}sameMarkup(t){return this.hasMarkup(t.type,t.attrs,t.marks)}hasMarkup(t,e,n){return this.type==t&&ee(this.attrs,e||t.defaultAttrs||xe)&&ne.sameSet(this.marks,n||ne.none)}copy(t=null){return t==this.content?this:new ke(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new ke(this.type,this.attrs,this.content,t)}cut(t,e=this.content.size){return 0==t&&e==this.content.size?this:this.copy(this.content.cut(t,e))}slice(t,e=this.content.size,n=!1){if(t==e)return ie.empty;let r=this.resolve(t),i=this.resolve(e),s=n?0:r.sharedDepth(e),o=r.start(s),a=r.node(s).content.cut(r.pos-o,i.pos-o);return new ie(a,r.depth-s,i.depth-s)}replace(t,e,n){return ae(this.resolve(t),this.resolve(e),n)}nodeAt(t){for(let e=this;;){let{index:n,offset:r}=e.content.findIndex(t);if(e=e.maybeChild(n),!e)return null;if(r==t||e.isText)return e;t-=r+1}}childAfter(t){let{index:e,offset:n}=this.content.findIndex(t);return{node:this.content.maybeChild(e),index:e,offset:n}}childBefore(t){if(0==t)return{node:null,index:0,offset:0};let{index:e,offset:n}=this.content.findIndex(t);if(n<t)return{node:this.content.child(e),index:e,offset:n};let r=this.content.child(e-1);return{node:r,index:e-1,offset:n-r.nodeSize}}resolve(t){return ge.resolveCached(this,t)}resolveNoCache(t){return ge.resolve(this,t)}rangeHasMark(t,e,n){let r=!1;return e>t&&this.nodesBetween(t,e,(t=>(n.isInSet(t.marks)&&(r=!0),!r))),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let t=this.type.name;return this.content.size&&(t+="("+this.content.toStringInner()+")"),Me(this.marks,t)}contentMatchAt(t){let e=this.type.contentMatch.matchFragment(this.content,0,t);if(!e)throw new Error("Called contentMatchAt on a node with invalid content");return e}canReplace(t,e,n=Zt.empty,r=0,i=n.childCount){let s=this.contentMatchAt(t).matchFragment(n,r,i),o=s&&s.matchFragment(this.content,e);if(!o||!o.validEnd)return!1;for(let t=r;t<i;t++)if(!this.type.allowsMarks(n.child(t).marks))return!1;return!0}canReplaceWith(t,e,n,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(t).matchType(n),s=i&&i.matchFragment(this.content,e);return!!s&&s.validEnd}canAppend(t){return t.content.size?this.canReplace(this.childCount,this.childCount,t.content):this.type.compatibleContent(t.type)}check(){this.type.checkContent(this.content);let t=ne.none;for(let e=0;e<this.marks.length;e++)t=this.marks[e].addToSet(t);if(!ne.sameSet(t,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map((t=>t.type.name))}`);this.content.forEach((t=>t.check()))}toJSON(){let t={type:this.type.name};for(let e in this.attrs){t.attrs=this.attrs;break}return this.content.size&&(t.content=this.content.toJSON()),this.marks.length&&(t.marks=this.marks.map((t=>t.toJSON()))),t}static fromJSON(t,e){if(!e)throw new RangeError("Invalid input for Node.fromJSON");let n=null;if(e.marks){if(!Array.isArray(e.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=e.marks.map(t.markFromJSON)}if("text"==e.type){if("string"!=typeof e.text)throw new RangeError("Invalid text node in JSON");return t.text(e.text,n)}let r=Zt.fromJSON(t,e.content);return t.nodeType(e.type).create(e.attrs,r,n)}}ke.prototype.text=void 0;class Se extends ke{constructor(t,e,n,r){if(super(t,e,null,r),!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Me(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(t,e){return this.text.slice(t,e)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new Se(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new Se(this.type,this.attrs,t,this.marks)}cut(t=0,e=this.text.length){return 0==t&&e==this.text.length?this:this.withText(this.text.slice(t,e))}eq(t){return this.sameMarkup(t)&&this.text==t.text}toJSON(){let t=super.toJSON();return t.text=this.text,t}}function Me(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class Oe{constructor(t){this.validEnd=t,this.next=[],this.wrapCache=[]}static parse(t,e){let n=new Ae(t,e);if(null==n.next)return Oe.empty;let r=Ee(n);n.next&&n.err("Unexpected trailing text");let i=function(t){let e=Object.create(null);return n(Ie(t,0));function n(r){let i=[];r.forEach((e=>{t[e].forEach((({term:e,to:n})=>{if(!e)return;let r;for(let t=0;t<i.length;t++)i[t][0]==e&&(r=i[t][1]);Ie(t,n).forEach((t=>{r||i.push([e,r=[]]),-1==r.indexOf(t)&&r.push(t)}))}))}));let s=e[r.join(",")]=new Oe(r.indexOf(t.length-1)>-1);for(let t=0;t<i.length;t++){let r=i[t][1].sort($e);s.next.push({type:i[t][0],next:e[r.join(",")]||n(r)})}return s}}(function(t){let e=[[]];return i(s(t,0),n()),e;function n(){return e.push([])-1}function r(t,n,r){let i={term:r,to:n};return e[t].push(i),i}function i(t,e){t.forEach((t=>t.to=e))}function s(t,e){if("choice"==t.type)return t.exprs.reduce(((t,n)=>t.concat(s(n,e))),[]);if("seq"!=t.type){if("star"==t.type){let o=n();return r(e,o),i(s(t.expr,o),o),[r(o)]}if("plus"==t.type){let o=n();return i(s(t.expr,e),o),i(s(t.expr,o),o),[r(o)]}if("opt"==t.type)return[r(e)].concat(s(t.expr,e));if("range"==t.type){let o=e;for(let e=0;e<t.min;e++){let e=n();i(s(t.expr,o),e),o=e}if(-1==t.max)i(s(t.expr,o),o);else for(let e=t.min;e<t.max;e++){let e=n();r(o,e),i(s(t.expr,o),e),o=e}return[r(o)]}if("name"==t.type)return[r(e,void 0,t.value)];throw new Error("Unknown expr type")}for(let r=0;;r++){let o=s(t.exprs[r],e);if(r==t.exprs.length-1)return o;i(o,e=n())}}}(r));return function(t,e){for(let n=0,r=[t];n<r.length;n++){let t=r[n],i=!t.validEnd,s=[];for(let e=0;e<t.next.length;e++){let{type:n,next:o}=t.next[e];s.push(n.name),!i||n.isText||n.hasRequiredAttrs()||(i=!1),-1==r.indexOf(o)&&r.push(o)}i&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(i,n),i}matchType(t){for(let e=0;e<this.next.length;e++)if(this.next[e].type==t)return this.next[e].next;return null}matchFragment(t,e=0,n=t.childCount){let r=this;for(let i=e;r&&i<n;i++)r=r.matchType(t.child(i).type);return r}get inlineContent(){return 0!=this.next.length&&this.next[0].type.isInline}get defaultType(){for(let t=0;t<this.next.length;t++){let{type:e}=this.next[t];if(!e.isText&&!e.hasRequiredAttrs())return e}return null}compatible(t){for(let e=0;e<this.next.length;e++)for(let n=0;n<t.next.length;n++)if(this.next[e].type==t.next[n].type)return!0;return!1}fillBefore(t,e=!1,n=0){let r=[this];return function i(s,o){let a=s.matchFragment(t,n);if(a&&(!e||a.validEnd))return Zt.from(o.map((t=>t.createAndFill())));for(let t=0;t<s.next.length;t++){let{type:e,next:n}=s.next[t];if(!e.isText&&!e.hasRequiredAttrs()&&-1==r.indexOf(n)){r.push(n);let t=i(n,o.concat(e));if(t)return t}}return null}(this,[])}findWrapping(t){for(let e=0;e<this.wrapCache.length;e+=2)if(this.wrapCache[e]==t)return this.wrapCache[e+1];let e=this.computeWrapping(t);return this.wrapCache.push(t,e),e}computeWrapping(t){let e=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),i=r.match;if(i.matchType(t)){let t=[];for(let e=r;e.type;e=e.via)t.push(e.type);return t.reverse()}for(let t=0;t<i.next.length;t++){let{type:s,next:o}=i.next[t];s.isLeaf||s.hasRequiredAttrs()||s.name in e||r.type&&!o.validEnd||(n.push({match:s.contentMatch,type:s,via:r}),e[s.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(t){if(t>=this.next.length)throw new RangeError(`There's no ${t}th edge in this content match`);return this.next[t]}toString(){let t=[];return function e(n){t.push(n);for(let r=0;r<n.next.length;r++)-1==t.indexOf(n.next[r].next)&&e(n.next[r].next)}(this),t.map(((e,n)=>{let r=n+(e.validEnd?"*":" ")+" ";for(let n=0;n<e.next.length;n++)r+=(n?", ":"")+e.next[n].type.name+"->"+t.indexOf(e.next[n].next);return r})).join("\n")}}Oe.empty=new Oe(!0);class Ae{constructor(t,e){this.string=t,this.nodeTypes=e,this.inline=null,this.pos=0,this.tokens=t.split(/\s*(?=\b|\W|$)/),""==this.tokens[this.tokens.length-1]&&this.tokens.pop(),""==this.tokens[0]&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(t){return this.next==t&&(this.pos++||!0)}err(t){throw new SyntaxError(t+" (in content expression '"+this.string+"')")}}function Ee(t){let e=[];do{e.push(Ce(t))}while(t.eat("|"));return 1==e.length?e[0]:{type:"choice",exprs:e}}function Ce(t){let e=[];do{e.push(Te(t))}while(t.next&&")"!=t.next&&"|"!=t.next);return 1==e.length?e[0]:{type:"seq",exprs:e}}function Te(t){let e=function(t){if(t.eat("(")){let e=Ee(t);return t.eat(")")||t.err("Missing closing paren"),e}if(!/\W/.test(t.next)){let e=function(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let i=[];for(let t in n){let r=n[t];r.groups.indexOf(e)>-1&&i.push(r)}0==i.length&&t.err("No node type or group '"+e+"' found");return i}(t,t.next).map((e=>(null==t.inline?t.inline=e.isInline:t.inline!=e.isInline&&t.err("Mixing inline and block content"),{type:"name",value:e})));return t.pos++,1==e.length?e[0]:{type:"choice",exprs:e}}t.err("Unexpected token '"+t.next+"'")}(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else{if(!t.eat("{"))break;e=De(t,e)}return e}function Ne(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function De(t,e){let n=Ne(t),r=n;return t.eat(",")&&(r="}"!=t.next?Ne(t):-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function $e(t,e){return e-t}function Ie(t,e){let n=[];return function e(r){let i=t[r];if(1==i.length&&!i[0].term)return e(i[0].to);n.push(r);for(let t=0;t<i.length;t++){let{term:r,to:s}=i[t];r||-1!=n.indexOf(s)||e(s)}}(e),n.sort($e)}function Re(t){let e=Object.create(null);for(let n in t){let r=t[n];if(!r.hasDefault)return null;e[n]=r.default}return e}function Be(t,e){let n=Object.create(null);for(let r in t){let i=e&&e[r];if(void 0===i){let e=t[r];if(!e.hasDefault)throw new RangeError("No value supplied for attribute "+r);i=e.default}n[r]=i}return n}function Fe(t){let e=Object.create(null);if(t)for(let n in t)e[n]=new Ve(t[n]);return e}class Pe{constructor(t,e,n){this.name=t,this.schema=e,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(" "):[],this.attrs=Fe(n.attrs),this.defaultAttrs=Re(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||"text"==t),this.isText="text"==t}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Oe.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let t in this.attrs)if(this.attrs[t].isRequired)return!0;return!1}compatibleContent(t){return this==t||this.contentMatch.compatible(t.contentMatch)}computeAttrs(t){return!t&&this.defaultAttrs?this.defaultAttrs:Be(this.attrs,t)}create(t=null,e,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new ke(this,this.computeAttrs(t),Zt.from(e),ne.setFrom(n))}createChecked(t=null,e,n){return e=Zt.from(e),this.checkContent(e),new ke(this,this.computeAttrs(t),e,ne.setFrom(n))}createAndFill(t=null,e,n){if(t=this.computeAttrs(t),(e=Zt.from(e)).size){let t=this.contentMatch.fillBefore(e);if(!t)return null;e=t.append(e)}let r=this.contentMatch.matchFragment(e),i=r&&r.fillBefore(Zt.empty,!0);return i?new ke(this,t,e.append(i),ne.setFrom(n)):null}validContent(t){let e=this.contentMatch.matchFragment(t);if(!e||!e.validEnd)return!1;for(let e=0;e<t.childCount;e++)if(!this.allowsMarks(t.child(e).marks))return!1;return!0}checkContent(t){if(!this.validContent(t))throw new RangeError(`Invalid content for node ${this.name}: ${t.toString().slice(0,50)}`)}allowsMarkType(t){return null==this.markSet||this.markSet.indexOf(t)>-1}allowsMarks(t){if(null==this.markSet)return!0;for(let e=0;e<t.length;e++)if(!this.allowsMarkType(t[e].type))return!1;return!0}allowedMarks(t){if(null==this.markSet)return t;let e;for(let n=0;n<t.length;n++)this.allowsMarkType(t[n].type)?e&&e.push(t[n]):e||(e=t.slice(0,n));return e?e.length?e:ne.none:t}static compile(t,e){let n=Object.create(null);t.forEach(((t,r)=>n[t]=new Pe(t,e,r)));let r=e.spec.topNode||"doc";if(!n[r])throw new RangeError("Schema is missing its top node type ('"+r+"')");if(!n.text)throw new RangeError("Every schema needs a 'text' type");for(let t in n.text.attrs)throw new RangeError("The text node type should not have attributes");return n}}class Ve{constructor(t){this.hasDefault=Object.prototype.hasOwnProperty.call(t,"default"),this.default=t.default}get isRequired(){return!this.hasDefault}}class Le{constructor(t,e,n,r){this.name=t,this.rank=e,this.schema=n,this.spec=r,this.attrs=Fe(r.attrs),this.excluded=null;let i=Re(this.attrs);this.instance=i?new ne(this,i):null}create(t=null){return!t&&this.instance?this.instance:new ne(this,Be(this.attrs,t))}static compile(t,e){let n=Object.create(null),r=0;return t.forEach(((t,i)=>n[t]=new Le(t,r++,e,i))),n}removeFromSet(t){for(var e=0;e<t.length;e++)t[e].type==this&&(t=t.slice(0,e).concat(t.slice(e+1)),e--);return t}isInSet(t){for(let e=0;e<t.length;e++)if(t[e].type==this)return t[e]}excludes(t){return this.excluded.indexOf(t)>-1}}class ze{constructor(t){this.cached=Object.create(null);let e=this.spec={};for(let n in t)e[n]=t[n];e.nodes=Gt.from(t.nodes),e.marks=Gt.from(t.marks||{}),this.nodes=Pe.compile(this.spec.nodes,this),this.marks=Le.compile(this.spec.marks,this);let n=Object.create(null);for(let t in this.nodes){if(t in this.marks)throw new RangeError(t+" can not be both a node and a mark");let e=this.nodes[t],r=e.spec.content||"",i=e.spec.marks;e.contentMatch=n[r]||(n[r]=Oe.parse(r,this.nodes)),e.inlineContent=e.contentMatch.inlineContent,e.markSet="_"==i?null:i?je(this,i.split(" ")):""!=i&&e.inlineContent?null:[]}for(let t in this.marks){let e=this.marks[t],n=e.spec.excludes;e.excluded=null==n?[e]:""==n?[]:je(this,n.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(t,e=null,n,r){if("string"==typeof t)t=this.nodeType(t);else{if(!(t instanceof Pe))throw new RangeError("Invalid node type: "+t);if(t.schema!=this)throw new RangeError("Node type from different schema used ("+t.name+")")}return t.createChecked(e,n,r)}text(t,e){let n=this.nodes.text;return new Se(n,n.defaultAttrs,t,ne.setFrom(e))}mark(t,e){return"string"==typeof t&&(t=this.marks[t]),t.create(e)}nodeFromJSON(t){return ke.fromJSON(this,t)}markFromJSON(t){return ne.fromJSON(this,t)}nodeType(t){let e=this.nodes[t];if(!e)throw new RangeError("Unknown node type: "+t);return e}}function je(t,e){let n=[];for(let r=0;r<e.length;r++){let i=e[r],s=t.marks[i],o=s;if(s)n.push(s);else for(let e in t.marks){let r=t.marks[e];("_"==i||r.spec.group&&r.spec.group.split(" ").indexOf(i)>-1)&&n.push(o=r)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}class _e{constructor(t,e){this.schema=t,this.rules=e,this.tags=[],this.styles=[],e.forEach((t=>{t.tag?this.tags.push(t):t.style&&this.styles.push(t)})),this.normalizeLists=!this.tags.some((e=>{if(!/^(ul|ol)\b/.test(e.tag)||!e.node)return!1;let n=t.nodes[e.node];return n.contentMatch.matchType(n)}))}parse(t,e={}){let n=new Ue(this,e,!1);return n.addAll(t,e.from,e.to),n.finish()}parseSlice(t,e={}){let n=new Ue(this,e,!0);return n.addAll(t,e.from,e.to),ie.maxOpen(n.finish())}matchTag(t,e,n){for(let r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){let n=this.tags[r];if(Ge(t,n.tag)&&(void 0===n.namespace||t.namespaceURI==n.namespace)&&(!n.context||e.matchesContext(n.context))){if(n.getAttrs){let e=n.getAttrs(t);if(!1===e)continue;n.attrs=e||void 0}return n}}}matchStyle(t,e,n,r){for(let i=r?this.styles.indexOf(r)+1:0;i<this.styles.length;i++){let r=this.styles[i],s=r.style;if(!(0!=s.indexOf(t)||r.context&&!n.matchesContext(r.context)||s.length>t.length&&(61!=s.charCodeAt(t.length)||s.slice(t.length+1)!=e))){if(r.getAttrs){let t=r.getAttrs(e);if(!1===t)continue;r.attrs=t||void 0}return r}}}static schemaRules(t){let e=[];function n(t){let n=null==t.priority?50:t.priority,r=0;for(;r<e.length;r++){let t=e[r];if((null==t.priority?50:t.priority)<n)break}e.splice(r,0,t)}for(let e in t.marks){let r=t.marks[e].spec.parseDOM;r&&r.forEach((t=>{n(t=Ye(t)),t.mark||t.ignore||t.clearMark||(t.mark=e)}))}for(let e in t.nodes){let r=t.nodes[e].spec.parseDOM;r&&r.forEach((t=>{n(t=Ye(t)),t.node||t.ignore||t.mark||(t.node=e)}))}return e}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new _e(t,_e.schemaRules(t)))}}const Ke={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},We={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},He={ol:!0,ul:!0};function qe(t,e,n){return null!=e?(e?1:0)|("full"===e?2:0):t&&"pre"==t.whitespace?3:-5&n}class Je{constructor(t,e,n,r,i,s,o){this.type=t,this.attrs=e,this.marks=n,this.pendingMarks=r,this.solid=i,this.options=o,this.content=[],this.activeMarks=ne.none,this.stashMarks=[],this.match=s||(4&o?null:t.contentMatch)}findWrapping(t){if(!this.match){if(!this.type)return[];let e=this.type.contentMatch.fillBefore(Zt.from(t));if(!e){let e,n=this.type.contentMatch;return(e=n.findWrapping(t.type))?(this.match=n,e):null}this.match=this.type.contentMatch.matchFragment(e)}return this.match.findWrapping(t.type)}finish(t){if(!(1&this.options)){let t,e=this.content[this.content.length-1];if(e&&e.isText&&(t=/[ \t\r\n\u000c]+$/.exec(e.text))){let n=e;e.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-t[0].length))}}let e=Zt.from(this.content);return!t&&this.match&&(e=e.append(this.match.fillBefore(Zt.empty,!0))),this.type?this.type.create(this.attrs,e,this.marks):e}popFromStashMark(t){for(let e=this.stashMarks.length-1;e>=0;e--)if(t.eq(this.stashMarks[e]))return this.stashMarks.splice(e,1)[0]}applyPending(t){for(let e=0,n=this.pendingMarks;e<n.length;e++){let r=n[e];(this.type?this.type.allowsMarkType(r.type):Xe(r.type,t))&&!r.isInSet(this.activeMarks)&&(this.activeMarks=r.addToSet(this.activeMarks),this.pendingMarks=r.removeFromSet(this.pendingMarks))}}inlineContext(t){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:t.parentNode&&!Ke.hasOwnProperty(t.parentNode.nodeName.toLowerCase())}}class Ue{constructor(t,e,n){this.parser=t,this.options=e,this.isOpen=n,this.open=0;let r,i=e.topNode,s=qe(null,e.preserveWhitespace,0)|(n?4:0);r=i?new Je(i.type,i.attrs,ne.none,ne.none,!0,e.topMatch||i.type.contentMatch,s):new Je(n?null:t.schema.topNodeType,null,ne.none,ne.none,!0,null,s),this.nodes=[r],this.find=e.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(t){if(3==t.nodeType)this.addTextNode(t);else if(1==t.nodeType){let e=t.getAttribute("style");if(e){let n=this.readStyles(function(t){let e,n=/\s*([\w-]+)\s*:\s*([^;]+)/g,r=[];for(;e=n.exec(t);)r.push(e[1],e[2].trim());return r}(e));if(!n)return;let[r,i]=n,s=this.top;for(let t=0;t<i.length;t++)this.removePendingMark(i[t],s);for(let t=0;t<r.length;t++)this.addPendingMark(r[t]);this.addElement(t);for(let t=0;t<r.length;t++)this.removePendingMark(r[t],s);for(let t=0;t<i.length;t++)this.addPendingMark(i[t])}else this.addElement(t)}}addTextNode(t){let e=t.nodeValue,n=this.top;if(2&n.options||n.inlineContext(t)||/[^ \t\r\n\u000c]/.test(e)){if(1&n.options)e=2&n.options?e.replace(/\r\n?/g,"\n"):e.replace(/\r?\n|\r/g," ");else if(e=e.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(e)&&this.open==this.nodes.length-1){let r=n.content[n.content.length-1],i=t.previousSibling;(!r||i&&"BR"==i.nodeName||r.isText&&/[ \t\r\n\u000c]$/.test(r.text))&&(e=e.slice(1))}e&&this.insertNode(this.parser.schema.text(e)),this.findInText(t)}else this.findInside(t)}addElement(t,e){let n,r=t.nodeName.toLowerCase();He.hasOwnProperty(r)&&this.parser.normalizeLists&&function(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let t=1==e.nodeType?e.nodeName.toLowerCase():null;t&&He.hasOwnProperty(t)&&n?(n.appendChild(e),e=n):"li"==t?n=e:t&&(n=null)}}(t);let i=this.options.ruleFromNode&&this.options.ruleFromNode(t)||(n=this.parser.matchTag(t,this,e));if(i?i.ignore:We.hasOwnProperty(r))this.findInside(t),this.ignoreFallback(t);else if(!i||i.skip||i.closeParent){i&&i.closeParent?this.open=Math.max(0,this.open-1):i&&i.skip.nodeType&&(t=i.skip);let e,n=this.top,s=this.needsBlock;if(Ke.hasOwnProperty(r))n.content.length&&n.content[0].isInline&&this.open&&(this.open--,n=this.top),e=!0,n.type||(this.needsBlock=!0);else if(!t.firstChild)return void this.leafFallback(t);this.addAll(t),e&&this.sync(n),this.needsBlock=s}else this.addElementByRule(t,i,!1===i.consuming?n:void 0)}leafFallback(t){"BR"==t.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(t.ownerDocument.createTextNode("\n"))}ignoreFallback(t){"BR"!=t.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"))}readStyles(t){let e=ne.none,n=ne.none;t:for(let r=0;r<t.length;r+=2)for(let i;;){let s=this.parser.matchStyle(t[r],t[r+1],this,i);if(!s)continue t;if(s.ignore)return null;if(s.clearMark?this.top.pendingMarks.forEach((t=>{s.clearMark(t)&&(n=t.addToSet(n))})):e=this.parser.schema.marks[s.mark].create(s.attrs).addToSet(e),!1!==s.consuming)break;i=s}return[e,n]}addElementByRule(t,e,n){let r,i,s;if(e.node)i=this.parser.schema.nodes[e.node],i.isLeaf?this.insertNode(i.create(e.attrs))||this.leafFallback(t):r=this.enter(i,e.attrs||null,e.preserveWhitespace);else{s=this.parser.schema.marks[e.mark].create(e.attrs),this.addPendingMark(s)}let o=this.top;if(i&&i.isLeaf)this.findInside(t);else if(n)this.addElement(t,n);else if(e.getContent)this.findInside(t),e.getContent(t,this.parser.schema).forEach((t=>this.insertNode(t)));else{let n=t;"string"==typeof e.contentElement?n=t.querySelector(e.contentElement):"function"==typeof e.contentElement?n=e.contentElement(t):e.contentElement&&(n=e.contentElement),this.findAround(t,n,!0),this.addAll(n)}r&&this.sync(o)&&this.open--,s&&this.removePendingMark(s,o)}addAll(t,e,n){let r=e||0;for(let i=e?t.childNodes[e]:t.firstChild,s=null==n?null:t.childNodes[n];i!=s;i=i.nextSibling,++r)this.findAtPoint(t,r),this.addDOM(i);this.findAtPoint(t,r)}findPlace(t){let e,n;for(let r=this.open;r>=0;r--){let i=this.nodes[r],s=i.findWrapping(t);if(s&&(!e||e.length>s.length)&&(e=s,n=i,!s.length))break;if(i.solid)break}if(!e)return!1;this.sync(n);for(let t=0;t<e.length;t++)this.enterInner(e[t],null,!1);return!0}insertNode(t){if(t.isInline&&this.needsBlock&&!this.top.type){let t=this.textblockFromContext();t&&this.enterInner(t)}if(this.findPlace(t)){this.closeExtra();let e=this.top;e.applyPending(t.type),e.match&&(e.match=e.match.matchType(t.type));let n=e.activeMarks;for(let r=0;r<t.marks.length;r++)e.type&&!e.type.allowsMarkType(t.marks[r].type)||(n=t.marks[r].addToSet(n));return e.content.push(t.mark(n)),!0}return!1}enter(t,e,n){let r=this.findPlace(t.create(e));return r&&this.enterInner(t,e,!0,n),r}enterInner(t,e=null,n=!1,r){this.closeExtra();let i=this.top;i.applyPending(t),i.match=i.match&&i.match.matchType(t);let s=qe(t,r,i.options);4&i.options&&0==i.content.length&&(s|=4),this.nodes.push(new Je(t,e,i.activeMarks,i.pendingMarks,n,null,s)),this.open++}closeExtra(t=!1){let e=this.nodes.length-1;if(e>this.open){for(;e>this.open;e--)this.nodes[e-1].content.push(this.nodes[e].finish(t));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(this.isOpen||this.options.topOpen)}sync(t){for(let e=this.open;e>=0;e--)if(this.nodes[e]==t)return this.open=e,!0;return!1}get currentPos(){this.closeExtra();let t=0;for(let e=this.open;e>=0;e--){let n=this.nodes[e].content;for(let e=n.length-1;e>=0;e--)t+=n[e].nodeSize;e&&t++}return t}findAtPoint(t,e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==t&&this.find[n].offset==e&&(this.find[n].pos=this.currentPos)}findInside(t){if(this.find)for(let e=0;e<this.find.length;e++)null==this.find[e].pos&&1==t.nodeType&&t.contains(this.find[e].node)&&(this.find[e].pos=this.currentPos)}findAround(t,e,n){if(t!=e&&this.find)for(let r=0;r<this.find.length;r++)if(null==this.find[r].pos&&1==t.nodeType&&t.contains(this.find[r].node)){e.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}}findInText(t){if(this.find)for(let e=0;e<this.find.length;e++)this.find[e].node==t&&(this.find[e].pos=this.currentPos-(t.nodeValue.length-this.find[e].offset))}matchesContext(t){if(t.indexOf("|")>-1)return t.split(/\s*\|\s*/).some(this.matchesContext,this);let e=t.split("/"),n=this.options.context,r=!(this.isOpen||n&&n.parent.type!=this.nodes[0].type),i=-(n?n.depth+1:0)+(r?0:1),s=(t,o)=>{for(;t>=0;t--){let a=e[t];if(""==a){if(t==e.length-1||0==t)continue;for(;o>=i;o--)if(s(t-1,o))return!0;return!1}{let t=o>0||0==o&&r?this.nodes[o].type:n&&o>=i?n.node(o-i).type:null;if(!t||t.name!=a&&-1==t.groups.indexOf(a))return!1;o--}}return!0};return s(e.length-1,this.open)}textblockFromContext(){let t=this.options.context;if(t)for(let e=t.depth;e>=0;e--){let n=t.node(e).contentMatchAt(t.indexAfter(e)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let t in this.parser.schema.nodes){let e=this.parser.schema.nodes[t];if(e.isTextblock&&e.defaultAttrs)return e}}addPendingMark(t){let e=function(t,e){for(let n=0;n<e.length;n++)if(t.eq(e[n]))return e[n]}(t,this.top.pendingMarks);e&&this.top.stashMarks.push(e),this.top.pendingMarks=t.addToSet(this.top.pendingMarks)}removePendingMark(t,e){for(let n=this.open;n>=0;n--){let r=this.nodes[n];if(r.pendingMarks.lastIndexOf(t)>-1)r.pendingMarks=t.removeFromSet(r.pendingMarks);else{r.activeMarks=t.removeFromSet(r.activeMarks);let e=r.popFromStashMark(t);e&&r.type&&r.type.allowsMarkType(e.type)&&(r.activeMarks=e.addToSet(r.activeMarks))}if(r==e)break}}}function Ge(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function Ye(t){let e={};for(let n in t)e[n]=t[n];return e}function Xe(t,e){let n=e.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(t))continue;let s=[],o=t=>{s.push(t);for(let n=0;n<t.edgeCount;n++){let{type:r,next:i}=t.edge(n);if(r==e)return!0;if(s.indexOf(i)<0&&o(i))return!0}};if(o(i.contentMatch))return!0}}class Ze{constructor(t,e){this.nodes=t,this.marks=e}serializeFragment(t,e={},n){n||(n=tn(e).createDocumentFragment());let r=n,i=[];return t.forEach((t=>{if(i.length||t.marks.length){let n=0,s=0;for(;n<i.length&&s<t.marks.length;){let e=t.marks[s];if(this.marks[e.type.name]){if(!e.eq(i[n][0])||!1===e.type.spec.spanning)break;n++,s++}else s++}for(;n<i.length;)r=i.pop()[1];for(;s<t.marks.length;){let n=t.marks[s++],o=this.serializeMark(n,t.isInline,e);o&&(i.push([n,r]),r.appendChild(o.dom),r=o.contentDOM||o.dom)}}r.appendChild(this.serializeNodeInner(t,e))})),n}serializeNodeInner(t,e){let{dom:n,contentDOM:r}=Ze.renderSpec(tn(e),this.nodes[t.type.name](t));if(r){if(t.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(t.content,e,r)}return n}serializeNode(t,e={}){let n=this.serializeNodeInner(t,e);for(let r=t.marks.length-1;r>=0;r--){let i=this.serializeMark(t.marks[r],t.isInline,e);i&&((i.contentDOM||i.dom).appendChild(n),n=i.dom)}return n}serializeMark(t,e,n={}){let r=this.marks[t.type.name];return r&&Ze.renderSpec(tn(n),r(t,e))}static renderSpec(t,e,n=null){if("string"==typeof e)return{dom:t.createTextNode(e)};if(null!=e.nodeType)return{dom:e};if(e.dom&&null!=e.dom.nodeType)return e;let r,i=e[0],s=i.indexOf(" ");s>0&&(n=i.slice(0,s),i=i.slice(s+1));let o=n?t.createElementNS(n,i):t.createElement(i),a=e[1],l=1;if(a&&"object"==typeof a&&null==a.nodeType&&!Array.isArray(a)){l=2;for(let t in a)if(null!=a[t]){let e=t.indexOf(" ");e>0?o.setAttributeNS(t.slice(0,e),t.slice(e+1),a[t]):o.setAttribute(t,a[t])}}for(let i=l;i<e.length;i++){let s=e[i];if(0===s){if(i<e.length-1||i>l)throw new RangeError("Content hole must be the only child of its parent node");return{dom:o,contentDOM:o}}{let{dom:e,contentDOM:i}=Ze.renderSpec(t,s,n);if(o.appendChild(e),i){if(r)throw new RangeError("Multiple content holes");r=i}}}return{dom:o,contentDOM:r}}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new Ze(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(t){let e=Qe(t.nodes);return e.text||(e.text=t=>t.text),e}static marksFromSchema(t){return Qe(t.marks)}}function Qe(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function tn(t){return t.document||window.document}const en=Math.pow(2,16);function nn(t,e){return t+e*en}function rn(t){return 65535&t}class sn{constructor(t,e,n){this.pos=t,this.delInfo=e,this.recover=n}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 on{constructor(t,e=!1){if(this.ranges=t,this.inverted=e,!t.length&&on.empty)return on.empty}recover(t){let e=0,n=rn(t);if(!this.inverted)for(let t=0;t<n;t++)e+=this.ranges[3*t+2]-this.ranges[3*t+1];return this.ranges[3*n]+e+function(t){return(t-(65535&t))/en}(t)}mapResult(t,e=1){return this._map(t,e,!1)}map(t,e=1){return this._map(t,e,!0)}_map(t,e,n){let r=0,i=this.inverted?2:1,s=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let a=this.ranges[o]-(this.inverted?r:0);if(a>t)break;let l=this.ranges[o+i],c=this.ranges[o+s],h=a+l;if(t<=h){let i=a+r+((l?t==a?-1:t==h?1:e:e)<0?0:c);if(n)return i;let s=t==(e<0?a:h)?null:nn(o/3,t-a),d=t==a?2:t==h?1:4;return(e<0?t!=a:t!=h)&&(d|=8),new sn(i,d,s)}r+=c-l}return n?t+r:new sn(t+r,0,null)}touches(t,e){let n=0,r=rn(e),i=this.inverted?2:1,s=this.inverted?1:2;for(let e=0;e<this.ranges.length;e+=3){let o=this.ranges[e]-(this.inverted?n:0);if(o>t)break;let a=this.ranges[e+i];if(t<=o+a&&e==3*r)return!0;n+=this.ranges[e+s]-a}return!1}forEach(t){let e=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,i=0;r<this.ranges.length;r+=3){let s=this.ranges[r],o=s-(this.inverted?i:0),a=s+(this.inverted?0:i),l=this.ranges[r+e],c=this.ranges[r+n];t(o,o+l,a,a+c),i+=c-l}}invert(){return new on(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(t){return 0==t?on.empty:new on(t<0?[0,-t,0]:[0,0,t])}}on.empty=new on([]);class an{constructor(t=[],e,n=0,r=t.length){this.maps=t,this.mirror=e,this.from=n,this.to=r}slice(t=0,e=this.maps.length){return new an(this.maps,this.mirror,t,e)}copy(){return new an(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)}appendMap(t,e){this.to=this.maps.push(t),null!=e&&this.setMirror(this.maps.length-1,e)}appendMapping(t){for(let e=0,n=this.maps.length;e<t.maps.length;e++){let r=t.getMirror(e);this.appendMap(t.maps[e],null!=r&&r<e?n+r:void 0)}}getMirror(t){if(this.mirror)for(let e=0;e<this.mirror.length;e++)if(this.mirror[e]==t)return this.mirror[e+(e%2?-1:1)]}setMirror(t,e){this.mirror||(this.mirror=[]),this.mirror.push(t,e)}appendMappingInverted(t){for(let e=t.maps.length-1,n=this.maps.length+t.maps.length;e>=0;e--){let r=t.getMirror(e);this.appendMap(t.maps[e].invert(),null!=r&&r>e?n-r-1:void 0)}}invert(){let t=new an;return t.appendMappingInverted(this),t}map(t,e=1){if(this.mirror)return this._map(t,e,!0);for(let n=this.from;n<this.to;n++)t=this.maps[n].map(t,e);return t}mapResult(t,e=1){return this._map(t,e,!1)}_map(t,e,n){let r=0;for(let n=this.from;n<this.to;n++){let i=this.maps[n].mapResult(t,e);if(null!=i.recover){let e=this.getMirror(n);if(null!=e&&e>n&&e<this.to){n=e,t=this.maps[e].recover(i.recover);continue}}r|=i.delInfo,t=i.pos}return n?t:new sn(t,r,null)}}const ln=Object.create(null);class cn{getMap(){return on.empty}merge(t){return null}static fromJSON(t,e){if(!e||!e.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=ln[e.stepType];if(!n)throw new RangeError(`No step type ${e.stepType} defined`);return n.fromJSON(t,e)}static jsonID(t,e){if(t in ln)throw new RangeError("Duplicate use of step JSON ID "+t);return ln[t]=e,e.prototype.jsonID=t,e}}class hn{constructor(t,e){this.doc=t,this.failed=e}static ok(t){return new hn(t,null)}static fail(t){return new hn(null,t)}static fromReplace(t,e,n,r){try{return hn.ok(t.replace(e,n,r))}catch(t){if(t instanceof re)return hn.fail(t.message);throw t}}}function dn(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let s=t.child(i);s.content.size&&(s=s.copy(dn(s.content,e,s))),s.isInline&&(s=e(s,n,i)),r.push(s)}return Zt.fromArray(r)}class un extends cn{constructor(t,e,n){super(),this.from=t,this.to=e,this.mark=n}apply(t){let e=t.slice(this.from,this.to),n=t.resolve(this.from),r=n.node(n.sharedDepth(this.to)),i=new ie(dn(e.content,((t,e)=>t.isAtom&&e.type.allowsMarkType(this.mark.type)?t.mark(this.mark.addToSet(t.marks)):t),r),e.openStart,e.openEnd);return hn.fromReplace(t,this.from,this.to,i)}invert(){return new pn(this.from,this.to,this.mark)}map(t){let e=t.mapResult(this.from,1),n=t.mapResult(this.to,-1);return e.deleted&&n.deleted||e.pos>=n.pos?null:new un(e.pos,n.pos,this.mark)}merge(t){return t instanceof un&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new un(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 new RangeError("Invalid input for AddMarkStep.fromJSON");return new un(e.from,e.to,t.markFromJSON(e.mark))}}cn.jsonID("addMark",un);class pn extends cn{constructor(t,e,n){super(),this.from=t,this.to=e,this.mark=n}apply(t){let e=t.slice(this.from,this.to),n=new ie(dn(e.content,(t=>t.mark(this.mark.removeFromSet(t.marks))),t),e.openStart,e.openEnd);return hn.fromReplace(t,this.from,this.to,n)}invert(){return new un(this.from,this.to,this.mark)}map(t){let e=t.mapResult(this.from,1),n=t.mapResult(this.to,-1);return e.deleted&&n.deleted||e.pos>=n.pos?null:new pn(e.pos,n.pos,this.mark)}merge(t){return t instanceof pn&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new pn(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 new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new pn(e.from,e.to,t.markFromJSON(e.mark))}}cn.jsonID("removeMark",pn);class fn extends cn{constructor(t,e){super(),this.pos=t,this.mark=e}apply(t){let e=t.nodeAt(this.pos);if(!e)return hn.fail("No node at mark step's position");let n=e.type.create(e.attrs,null,this.mark.addToSet(e.marks));return hn.fromReplace(t,this.pos,this.pos+1,new ie(Zt.from(n),0,e.isLeaf?0:1))}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 n=0;n<e.marks.length;n++)if(!e.marks[n].isInSet(t))return new fn(this.pos,e.marks[n]);return new fn(this.pos,this.mark)}}return new mn(this.pos,this.mark)}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new fn(e.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,e){if("number"!=typeof e.pos)throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new fn(e.pos,t.markFromJSON(e.mark))}}cn.jsonID("addNodeMark",fn);class mn extends cn{constructor(t,e){super(),this.pos=t,this.mark=e}apply(t){let e=t.nodeAt(this.pos);if(!e)return hn.fail("No node at mark step's position");let n=e.type.create(e.attrs,null,this.mark.removeFromSet(e.marks));return hn.fromReplace(t,this.pos,this.pos+1,new ie(Zt.from(n),0,e.isLeaf?0:1))}invert(t){let e=t.nodeAt(this.pos);return e&&this.mark.isInSet(e.marks)?new fn(this.pos,this.mark):this}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new mn(e.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,e){if("number"!=typeof e.pos)throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new mn(e.pos,t.markFromJSON(e.mark))}}cn.jsonID("removeNodeMark",mn);class gn extends cn{constructor(t,e,n,r=!1){super(),this.from=t,this.to=e,this.slice=n,this.structure=r}apply(t){return this.structure&&vn(t,this.from,this.to)?hn.fail("Structure replace would overwrite content"):hn.fromReplace(t,this.from,this.to,this.slice)}getMap(){return new on([this.from,this.to-this.from,this.slice.size])}invert(t){return new gn(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let e=t.mapResult(this.from,1),n=t.mapResult(this.to,-1);return e.deletedAcross&&n.deletedAcross?null:new gn(e.pos,Math.max(e.pos,n.pos),this.slice)}merge(t){if(!(t instanceof gn)||t.structure||this.structure)return null;if(this.from+this.slice.size!=t.from||this.slice.openEnd||t.slice.openStart){if(t.to!=this.from||this.slice.openStart||t.slice.openEnd)return null;{let e=this.slice.size+t.slice.size==0?ie.empty:new ie(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new gn(t.from,this.to,e,this.structure)}}{let e=this.slice.size+t.slice.size==0?ie.empty:new ie(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new gn(this.from,this.to+(t.to-t.from),e,this.structure)}}toJSON(){let t={stepType:"replace",from:this.from,to:this.to};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)throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new gn(e.from,e.to,ie.fromJSON(t,e.slice),!!e.structure)}}cn.jsonID("replace",gn);class yn extends cn{constructor(t,e,n,r,i,s,o=!1){super(),this.from=t,this.to=e,this.gapFrom=n,this.gapTo=r,this.slice=i,this.insert=s,this.structure=o}apply(t){if(this.structure&&(vn(t,this.from,this.gapFrom)||vn(t,this.gapTo,this.to)))return hn.fail("Structure gap-replace would overwrite content");let e=t.slice(this.gapFrom,this.gapTo);if(e.openStart||e.openEnd)return hn.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,e.content);return n?hn.fromReplace(t,this.from,this.to,n):hn.fail("Content does not fit in gap")}getMap(){return new on([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let e=this.gapTo-this.gapFrom;return new yn(this.from,this.from+this.slice.size+e,this.from+this.insert,this.from+this.insert+e,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let e=t.mapResult(this.from,1),n=t.mapResult(this.to,-1),r=t.map(this.gapFrom,-1),i=t.map(this.gapTo,1);return e.deletedAcross&&n.deletedAcross||r<e.pos||i>n.pos?null:new yn(e.pos,n.pos,r,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 new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new yn(e.from,e.to,e.gapFrom,e.gapTo,ie.fromJSON(t,e.slice),e.insert,!!e.structure)}}function vn(t,e,n){let r=t.resolve(e),i=n-e,s=r.depth;for(;i>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,i--;if(i>0){let t=r.node(s).maybeChild(r.indexAfter(s));for(;i>0;){if(!t||t.isLeaf)return!0;t=t.firstChild,i--}}return!1}function bn(t,e,n){return(0==e||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function wn(t){let e=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let n=t.depth;;--n){let r=t.$from.node(n),i=t.$from.index(n),s=t.$to.indexAfter(n);if(n<t.depth&&r.canReplace(i,s,e))return n;if(0==n||r.type.spec.isolating||!bn(r,i,s))break}return null}function xn(t,e,n=null,r=t){let i=function(t,e){let{parent:n,startIndex:r,endIndex:i}=t,s=n.contentMatchAt(r).findWrapping(e);if(!s)return null;let o=s.length?s[0]:e;return n.canReplaceWith(r,i,o)?s:null}(t,e),s=i&&function(t,e){let{parent:n,startIndex:r,endIndex:i}=t,s=n.child(r),o=e.contentMatch.findWrapping(s.type);if(!o)return null;let a=(o.length?o[o.length-1]:e).contentMatch;for(let t=r;a&&t<i;t++)a=a.matchType(n.child(t).type);return a&&a.validEnd?o:null}(r,e);return s?i.map(kn).concat({type:e,attrs:n}).concat(s.map(kn)):null}function kn(t){return{type:t,attrs:null}}function Sn(t,e,n=1,r){let i=t.resolve(e),s=i.depth-n,o=r&&r[r.length-1]||i.parent;if(s<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let t=i.depth-1,e=n-2;t>s;t--,e--){let n=i.node(t),s=i.index(t);if(n.type.spec.isolating)return!1;let o=n.content.cutByIndex(s,n.childCount),a=r&&r[e]||n;if(a!=n&&(o=o.replaceChild(0,a.type.create(a.attrs))),!n.canReplace(s+1,n.childCount)||!a.type.validContent(o))return!1}let a=i.indexAfter(s),l=r&&r[0];return i.node(s).canReplaceWith(a,a,l?l.type:i.node(s+1).type)}function Mn(t,e){let n=t.resolve(e),r=n.index();return On(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function On(t,e){return!(!t||!e||t.isLeaf||!t.canAppend(e))}function An(t,e,n=-1){let r=t.resolve(e);for(let t=r.depth;;t--){let i,s,o=r.index(t);if(t==r.depth?(i=r.nodeBefore,s=r.nodeAfter):n>0?(i=r.node(t+1),o++,s=r.node(t).maybeChild(o)):(i=r.node(t).maybeChild(o-1),s=r.node(t+1)),i&&!i.isTextblock&&On(i,s)&&r.node(t).canReplace(o,o+1))return e;if(0==t)break;e=n<0?r.before(t):r.after(t)}}function En(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let i=n.content;for(let t=0;t<n.openStart;t++)i=i.firstChild.content;for(let t=1;t<=(0==n.openStart&&n.size?2:1);t++)for(let e=r.depth;e>=0;e--){let n=e==r.depth?0:r.pos<=(r.start(e+1)+r.end(e+1))/2?-1:1,s=r.index(e)+(n>0?1:0),o=r.node(e),a=!1;if(1==t)a=o.canReplace(s,s,i);else{let t=o.contentMatchAt(s).findWrapping(i.firstChild.type);a=t&&o.canReplaceWith(s,s,t[0])}if(a)return 0==n?r.pos:n<0?r.before(e+1):r.after(e+1)}return null}function Cn(t,e,n=e,r=ie.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),s=t.resolve(n);return Tn(i,s,r)?new gn(e,n,r):new Nn(i,s,r).fit()}function Tn(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}cn.jsonID("replaceAround",yn);class Nn{constructor(t,e,n){this.$from=t,this.$to=e,this.unplaced=n,this.frontier=[],this.placed=Zt.empty;for(let e=0;e<=t.depth;e++){let n=t.node(e);this.frontier.push({type:n.type,match:n.contentMatchAt(t.indexAfter(e))})}for(let e=t.depth;e>0;e--)this.placed=Zt.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,n=this.$from,r=this.close(t<0?this.$to:n.doc.resolve(t));if(!r)return null;let i=this.placed,s=n.depth,o=r.depth;for(;s&&o&&1==i.childCount;)i=i.firstChild.content,s--,o--;let a=new ie(i,s,o);return t>-1?new yn(n.pos,t,this.$to.pos,this.$to.end(),a,e):a.size||n.pos!=this.$to.pos?new gn(n.pos,r.pos,a):null}findFittable(){for(let t=1;t<=2;t++)for(let e=this.unplaced.openStart;e>=0;e--){let n,r=null;e?(r=In(this.unplaced.content,e-1).firstChild,n=r.content):n=this.unplaced.content;let i=n.firstChild;for(let n=this.depth;n>=0;n--){let s,{type:o,match:a}=this.frontier[n],l=null;if(1==t&&(i?a.matchType(i.type)||(l=a.fillBefore(Zt.from(i),!1)):r&&o.compatibleContent(r.type)))return{sliceDepth:e,frontierDepth:n,parent:r,inject:l};if(2==t&&i&&(s=a.findWrapping(i.type)))return{sliceDepth:e,frontierDepth:n,parent:r,wrap:s};if(r&&a.matchType(r.type))break}}}openMore(){let{content:t,openStart:e,openEnd:n}=this.unplaced,r=In(t,e);return!(!r.childCount||r.firstChild.isLeaf)&&(this.unplaced=new ie(t,e+1,Math.max(n,r.size+e>=t.size-n?e+1:0)),!0)}dropNode(){let{content:t,openStart:e,openEnd:n}=this.unplaced,r=In(t,e);if(r.childCount<=1&&e>0){let i=t.size-e<=e+r.size;this.unplaced=new ie(Dn(t,e-1,1),e-1,i?e-1:n)}else this.unplaced=new ie(Dn(t,e,1),e,n)}placeNodes({sliceDepth:t,frontierDepth:e,parent:n,inject:r,wrap:i}){for(;this.depth>e;)this.closeFrontierNode();if(i)for(let t=0;t<i.length;t++)this.openFrontierNode(i[t]);let s=this.unplaced,o=n?n.content:s.content,a=s.openStart-t,l=0,c=[],{match:h,type:d}=this.frontier[e];if(r){for(let t=0;t<r.childCount;t++)c.push(r.child(t));h=h.matchFragment(r)}let u=o.size+t-(s.content.size-s.openEnd);for(;l<o.childCount;){let t=o.child(l),e=h.matchType(t.type);if(!e)break;l++,(l>1||0==a||t.content.size)&&(h=e,c.push(Rn(t.mark(d.allowedMarks(t.marks)),1==l?a:0,l==o.childCount?u:-1)))}let p=l==o.childCount;p||(u=-1),this.placed=$n(this.placed,e,Zt.from(c)),this.frontier[e].match=h,p&&u<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let t=0,e=o;t<u;t++){let t=e.lastChild;this.frontier.push({type:t.type,match:t.contentMatchAt(t.childCount)}),e=t.content}this.unplaced=p?0==t?ie.empty:new ie(Dn(s.content,t-1,1),t-1,u<0?s.openEnd:t-1):new ie(Dn(s.content,t,l),s.openStart,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let t,e=this.frontier[this.depth];if(!e.type.isTextblock||!Bn(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:n}=this.$to,r=this.$to.after(n);for(;n>1&&r==this.$to.end(--n);)++r;return r}findCloseLevel(t){t:for(let e=Math.min(this.depth,t.depth);e>=0;e--){let{match:n,type:r}=this.frontier[e],i=e<t.depth&&t.end(e+1)==t.pos+(t.depth-(e+1)),s=Bn(t,e,r,n,i);if(s){for(let n=e-1;n>=0;n--){let{match:e,type:r}=this.frontier[n],i=Bn(t,n,r,e,!0);if(!i||i.childCount)continue t}return{depth:e,fit:s,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=$n(this.placed,e.depth,e.fit)),t=e.move;for(let n=e.depth+1;n<=t.depth;n++){let e=t.node(n),r=e.type.contentMatch.fillBefore(e.content,!0,t.index(n));this.openFrontierNode(e.type,e.attrs,r)}return t}openFrontierNode(t,e=null,n){let r=this.frontier[this.depth];r.match=r.match.matchType(t),this.placed=$n(this.placed,this.depth,Zt.from(t.create(e,n))),this.frontier.push({type:t,match:t.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(Zt.empty,!0);t.childCount&&(this.placed=$n(this.placed,this.frontier.length,t))}}function Dn(t,e,n){return 0==e?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Dn(t.firstChild.content,e-1,n)))}function $n(t,e,n){return 0==e?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy($n(t.lastChild.content,e-1,n)))}function In(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function Rn(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,Rn(r.firstChild,e-1,1==r.childCount?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(Zt.empty,!0)))),t.copy(r)}function Bn(t,e,n,r,i){let s=t.node(e),o=i?t.indexAfter(e):t.index(e);if(o==s.childCount&&!n.compatibleContent(s.type))return null;let a=r.fillBefore(s.content,!0,o);return a&&!function(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}(n,s.content,o)?a:null}function Fn(t){return t.spec.defining||t.spec.definingForContent}function Pn(t,e,n,r,i){if(e<n){let i=t.firstChild;t=t.replaceChild(0,i.copy(Pn(i.content,e+1,n,r,i)))}if(e>r){let e=i.contentMatchAt(0),n=e.fillBefore(t).append(t);t=n.append(e.matchFragment(n).fillBefore(Zt.empty,!0))}return t}function Vn(t,e){let n=[];for(let r=Math.min(t.depth,e.depth);r>=0;r--){let i=t.start(r);if(i<t.pos-(t.depth-r)||e.end(r)>e.pos+(e.depth-r)||t.node(r).type.spec.isolating||e.node(r).type.spec.isolating)break;(i==e.start(r)||r==t.depth&&r==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&r&&e.start(r-1)==i-1)&&n.push(r)}return n}class Ln extends cn{constructor(t,e,n){super(),this.pos=t,this.attr=e,this.value=n}apply(t){let e=t.nodeAt(this.pos);if(!e)return hn.fail("No node at attribute step's position");let n=Object.create(null);for(let t in e.attrs)n[t]=e.attrs[t];n[this.attr]=this.value;let r=e.type.create(n,null,e.marks);return hn.fromReplace(t,this.pos,this.pos+1,new ie(Zt.from(r),0,e.isLeaf?0:1))}getMap(){return on.empty}invert(t){return new Ln(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 Ln(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 new RangeError("Invalid input for AttrStep.fromJSON");return new Ln(e.pos,e.attr,e.value)}}cn.jsonID("attr",Ln);let zn=class extends Error{};zn=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n},(zn.prototype=Object.create(Error.prototype)).constructor=zn,zn.prototype.name="TransformError";const jn=Object.create(null);class _n{constructor(t,e,n){this.$anchor=t,this.$head=e,this.ranges=n||[new Kn(t.min(e),t.max(e))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let t=this.ranges;for(let e=0;e<t.length;e++)if(t[e].$from.pos!=t[e].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(t,e=ie.empty){let n=e.content.lastChild,r=null;for(let t=0;t<e.openEnd;t++)r=n,n=n.lastChild;let i=t.steps.length,s=this.ranges;for(let o=0;o<s.length;o++){let{$from:a,$to:l}=s[o],c=t.mapping.slice(i);t.replaceRange(c.map(a.pos),c.map(l.pos),o?ie.empty:e),0==o&&Qn(t,i,(n?n.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(t,e){let n=t.steps.length,r=this.ranges;for(let i=0;i<r.length;i++){let{$from:s,$to:o}=r[i],a=t.mapping.slice(n),l=a.map(s.pos),c=a.map(o.pos);i?t.deleteRange(l,c):(t.replaceRangeWith(l,c,e),Qn(t,n,e.isInline?-1:1))}}static findFrom(t,e,n=!1){let r=t.parent.inlineContent?new qn(t):Zn(t.node(0),t.parent,t.pos,t.index(),e,n);if(r)return r;for(let r=t.depth-1;r>=0;r--){let i=e<0?Zn(t.node(0),t.node(r),t.before(r+1),t.index(r),e,n):Zn(t.node(0),t.node(r),t.after(r+1),t.index(r)+1,e,n);if(i)return i}return null}static near(t,e=1){return this.findFrom(t,e)||this.findFrom(t,-e)||new Yn(t.node(0))}static atStart(t){return Zn(t,t,0,0,1)||new Yn(t)}static atEnd(t){return Zn(t,t,t.content.size,t.childCount,-1)||new Yn(t)}static fromJSON(t,e){if(!e||!e.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=jn[e.type];if(!n)throw new RangeError(`No selection type ${e.type} defined`);return n.fromJSON(t,e)}static jsonID(t,e){if(t in jn)throw new RangeError("Duplicate use of selection JSON ID "+t);return jn[t]=e,e.prototype.jsonID=t,e}getBookmark(){return qn.between(this.$anchor,this.$head).getBookmark()}}_n.prototype.visible=!0;class Kn{constructor(t,e){this.$from=t,this.$to=e}}let Wn=!1;function Hn(t){Wn||t.parent.inlineContent||(Wn=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class qn extends _n{constructor(t,e=t){Hn(t),Hn(e),super(t,e)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,e){let n=t.resolve(e.map(this.head));if(!n.parent.inlineContent)return _n.near(n);let r=t.resolve(e.map(this.anchor));return new qn(r.parent.inlineContent?r:n,n)}replace(t,e=ie.empty){if(super.replace(t,e),e==ie.empty){let e=this.$from.marksAcross(this.$to);e&&t.ensureMarks(e)}}eq(t){return t instanceof qn&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new Jn(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(t,e){if("number"!=typeof e.anchor||"number"!=typeof e.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new qn(t.resolve(e.anchor),t.resolve(e.head))}static create(t,e,n=e){let r=t.resolve(e);return new this(r,n==e?r:t.resolve(n))}static between(t,e,n){let r=t.pos-e.pos;if(n&&!r||(n=r>=0?1:-1),!e.parent.inlineContent){let t=_n.findFrom(e,n,!0)||_n.findFrom(e,-n,!0);if(!t)return _n.near(e,n);e=t.$head}return t.parent.inlineContent||(0==r||(t=(_n.findFrom(t,-n,!0)||_n.findFrom(t,n,!0)).$anchor).pos<e.pos!=r<0)&&(t=e),new qn(t,e)}}_n.jsonID("text",qn);class Jn{constructor(t,e){this.anchor=t,this.head=e}map(t){return new Jn(t.map(this.anchor),t.map(this.head))}resolve(t){return qn.between(t.resolve(this.anchor),t.resolve(this.head))}}class Un extends _n{constructor(t){let e=t.nodeAfter,n=t.node(0).resolve(t.pos+e.nodeSize);super(t,n),this.node=e}map(t,e){let{deleted:n,pos:r}=e.mapResult(this.anchor),i=t.resolve(r);return n?_n.near(i):new Un(i)}content(){return new ie(Zt.from(this.node),0,0)}eq(t){return t instanceof Un&&t.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Gn(this.anchor)}static fromJSON(t,e){if("number"!=typeof e.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Un(t.resolve(e.anchor))}static create(t,e){return new Un(t.resolve(e))}static isSelectable(t){return!t.isText&&!1!==t.type.spec.selectable}}Un.prototype.visible=!1,_n.jsonID("node",Un);class Gn{constructor(t){this.anchor=t}map(t){let{deleted:e,pos:n}=t.mapResult(this.anchor);return e?new Jn(n,n):new Gn(n)}resolve(t){let e=t.resolve(this.anchor),n=e.nodeAfter;return n&&Un.isSelectable(n)?new Un(e):_n.near(e)}}class Yn extends _n{constructor(t){super(t.resolve(0),t.resolve(t.content.size))}replace(t,e=ie.empty){if(e==ie.empty){t.delete(0,t.doc.content.size);let e=_n.atStart(t.doc);e.eq(t.selection)||t.setSelection(e)}else super.replace(t,e)}toJSON(){return{type:"all"}}static fromJSON(t){return new Yn(t)}map(t){return new Yn(t)}eq(t){return t instanceof Yn}getBookmark(){return Xn}}_n.jsonID("all",Yn);const Xn={map(){return this},resolve:t=>new Yn(t)};function Zn(t,e,n,r,i,s=!1){if(e.inlineContent)return qn.create(t,n);for(let o=r-(i>0?0:1);i>0?o<e.childCount:o>=0;o+=i){let r=e.child(o);if(r.isAtom){if(!s&&Un.isSelectable(r))return Un.create(t,n-(i<0?r.nodeSize:0))}else{let e=Zn(t,r,n+i,i<0?r.childCount:0,i,s);if(e)return e}n+=r.nodeSize*i}return null}function Qn(t,e,n){let r=t.steps.length-1;if(r<e)return;let i,s=t.steps[r];(s instanceof gn||s instanceof yn)&&(t.mapping.maps[r].forEach(((t,e,n,r)=>{null==i&&(i=r)})),t.setSelection(_n.near(t.doc.resolve(i),n)))}class tr extends class{constructor(t){this.doc=t,this.steps=[],this.docs=[],this.mapping=new an}get before(){return this.docs.length?this.docs[0]:this.doc}step(t){let e=this.maybeStep(t);if(e.failed)throw new zn(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,n=ie.empty){let r=Cn(this.doc,t,e,n);return r&&this.step(r),this}replaceWith(t,e,n){return this.replace(t,e,new ie(Zt.from(n),0,0))}delete(t,e){return this.replace(t,e,ie.empty)}insert(t,e){return this.replaceWith(t,t,e)}replaceRange(t,e,n){return function(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let i=t.doc.resolve(e),s=t.doc.resolve(n);if(Tn(i,s,r))return t.step(new gn(e,n,r));let o=Vn(i,t.doc.resolve(n));0==o[o.length-1]&&o.pop();let a=-(i.depth+1);o.unshift(a);for(let t=i.depth,e=i.pos-1;t>0;t--,e--){let n=i.node(t).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;o.indexOf(t)>-1?a=t:i.before(t)==e&&o.splice(1,0,-t)}let l=o.indexOf(a),c=[],h=r.openStart;for(let t=r.content,e=0;;e++){let n=t.firstChild;if(c.push(n),e==r.openStart)break;t=n.content}for(let t=h-1;t>=0;t--){let e=c[t].type,n=Fn(e);if(n&&i.node(l).type!=e)h=t;else if(n||!e.isTextblock)break}for(let e=r.openStart;e>=0;e--){let a=(e+h+1)%(r.openStart+1),d=c[a];if(d)for(let e=0;e<o.length;e++){let c=o[(e+l)%o.length],h=!0;c<0&&(h=!1,c=-c);let u=i.node(c-1),p=i.index(c-1);if(u.canReplaceWith(p,p,d.type,d.marks))return t.replace(i.before(c),h?s.after(c):n,new ie(Pn(r.content,0,r.openStart,a),a,r.openEnd))}}let d=t.steps.length;for(let a=o.length-1;a>=0&&(t.replace(e,n,r),!(t.steps.length>d));a--){let t=o[a];t<0||(e=i.before(t),n=s.after(t))}}(this,t,e,n),this}replaceRangeWith(t,e,n){return function(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=function(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(0==r.parentOffset)for(let t=r.depth-1;t>=0;t--){let e=r.index(t);if(r.node(t).canReplaceWith(e,e,n))return r.before(t+1);if(e>0)return null}if(r.parentOffset==r.parent.content.size)for(let t=r.depth-1;t>=0;t--){let e=r.indexAfter(t);if(r.node(t).canReplaceWith(e,e,n))return r.after(t+1);if(e<r.node(t).childCount)return null}return null}(t.doc,e,r.type);null!=i&&(e=n=i)}t.replaceRange(e,n,new ie(Zt.from(r),0,0))}(this,t,e,n),this}deleteRange(t,e){return function(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n),s=Vn(r,i);for(let e=0;e<s.length;e++){let n=s[e],o=e==s.length-1;if(o&&0==n||r.node(n).type.contentMatch.validEnd)return t.delete(r.start(n),i.end(n));if(n>0&&(o||r.node(n-1).canReplace(r.index(n-1),i.indexAfter(n-1))))return t.delete(r.before(n),i.after(n))}for(let s=1;s<=r.depth&&s<=i.depth;s++)if(e-r.start(s)==r.depth-s&&n>r.end(s)&&i.end(s)-n!=i.depth-s)return t.delete(r.before(s),n);t.delete(e,n)}(this,t,e),this}lift(t,e){return function(t,e,n){let{$from:r,$to:i,depth:s}=e,o=r.before(s+1),a=i.after(s+1),l=o,c=a,h=Zt.empty,d=0;for(let t=s,e=!1;t>n;t--)e||r.index(t)>0?(e=!0,h=Zt.from(r.node(t).copy(h)),d++):l--;let u=Zt.empty,p=0;for(let t=s,e=!1;t>n;t--)e||i.after(t+1)<i.end(t)?(e=!0,u=Zt.from(i.node(t).copy(u)),p++):c++;t.step(new yn(l,c,o,a,new ie(h.append(u),d,p),h.size-d,!0))}(this,t,e),this}join(t,e=1){return function(t,e,n){let r=new gn(e-n,e+n,ie.empty,!0);t.step(r)}(this,t,e),this}wrap(t,e){return function(t,e,n){let r=Zt.empty;for(let t=n.length-1;t>=0;t--){if(r.size){let e=n[t].type.contentMatch.matchFragment(r);if(!e||!e.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=Zt.from(n[t].type.create(n[t].attrs,r))}let i=e.start,s=e.end;t.step(new yn(i,s,i,s,new ie(r,0,0),n.length,!0))}(this,t,e),this}setBlockType(t,e=t,n,r=null){return function(t,e,n,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=t.steps.length;t.doc.nodesBetween(e,n,((e,n)=>{if(e.isTextblock&&!e.hasMarkup(r,i)&&function(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}(t.doc,t.mapping.slice(s).map(n),r)){t.clearIncompatible(t.mapping.slice(s).map(n,1),r);let o=t.mapping.slice(s),a=o.map(n,1),l=o.map(n+e.nodeSize,1);return t.step(new yn(a,l,a+1,l-1,new ie(Zt.from(r.create(i,null,e.marks)),0,0),1,!0)),!1}}))}(this,t,e,n,r),this}setNodeMarkup(t,e,n=null,r=[]){return function(t,e,n,r,i){let s=t.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");n||(n=s.type);let o=n.create(r,null,i||s.marks);if(s.isLeaf)return t.replaceWith(e,e+s.nodeSize,o);if(!n.validContent(s.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new yn(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new ie(Zt.from(o),0,0),1,!0))}(this,t,e,n,r),this}setNodeAttribute(t,e,n){return this.step(new Ln(t,e,n)),this}addNodeMark(t,e){return this.step(new fn(t,e)),this}removeNodeMark(t,e){if(!(e instanceof ne)){let n=this.doc.nodeAt(t);if(!n)throw new RangeError("No node at position "+t);if(!(e=e.isInSet(n.marks)))return this}return this.step(new mn(t,e)),this}split(t,e=1,n){return function(t,e,n=1,r){let i=t.doc.resolve(e),s=Zt.empty,o=Zt.empty;for(let t=i.depth,e=i.depth-n,a=n-1;t>e;t--,a--){s=Zt.from(i.node(t).copy(s));let e=r&&r[a];o=Zt.from(e?e.type.create(e.attrs,o):i.node(t).copy(o))}t.step(new gn(e,e,new ie(s.append(o),n,n),!0))}(this,t,e,n),this}addMark(t,e,n){return function(t,e,n,r){let i,s,o=[],a=[];t.doc.nodesBetween(e,n,((t,l,c)=>{if(!t.isInline)return;let h=t.marks;if(!r.isInSet(h)&&c.type.allowsMarkType(r.type)){let c=Math.max(l,e),d=Math.min(l+t.nodeSize,n),u=r.addToSet(h);for(let t=0;t<h.length;t++)h[t].isInSet(u)||(i&&i.to==c&&i.mark.eq(h[t])?i.to=d:o.push(i=new pn(c,d,h[t])));s&&s.to==c?s.to=d:a.push(s=new un(c,d,r))}})),o.forEach((e=>t.step(e))),a.forEach((e=>t.step(e)))}(this,t,e,n),this}removeMark(t,e,n){return function(t,e,n,r){let i=[],s=0;t.doc.nodesBetween(e,n,((t,o)=>{if(!t.isInline)return;s++;let a=null;if(r instanceof Le){let e,n=t.marks;for(;e=r.isInSet(n);)(a||(a=[])).push(e),n=e.removeFromSet(n)}else r?r.isInSet(t.marks)&&(a=[r]):a=t.marks;if(a&&a.length){let r=Math.min(o+t.nodeSize,n);for(let t=0;t<a.length;t++){let n,l=a[t];for(let t=0;t<i.length;t++){let e=i[t];e.step==s-1&&l.eq(i[t].style)&&(n=e)}n?(n.to=r,n.step=s):i.push({style:l,from:Math.max(o,e),to:r,step:s})}}})),i.forEach((e=>t.step(new pn(e.from,e.to,e.style))))}(this,t,e,n),this}clearIncompatible(t,e,n){return function(t,e,n,r=n.contentMatch){let i=t.doc.nodeAt(e),s=[],o=e+1;for(let e=0;e<i.childCount;e++){let a=i.child(e),l=o+a.nodeSize,c=r.matchType(a.type);if(c){r=c;for(let e=0;e<a.marks.length;e++)n.allowsMarkType(a.marks[e].type)||t.step(new pn(o,l,a.marks[e]))}else s.push(new gn(o,l,ie.empty));o=l}if(!r.validEnd){let e=r.fillBefore(Zt.empty,!0);t.replace(o,o,new ie(e,0,0))}for(let e=s.length-1;e>=0;e--)t.step(s[e])}(this,t,e,n),this}}{constructor(t){super(t.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=t.selection,this.storedMarks=t.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(t){if(t.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=t,this.curSelectionFor=this.steps.length,this.updated=-3&(1|this.updated),this.storedMarks=null,this}get selectionSet(){return(1&this.updated)>0}setStoredMarks(t){return this.storedMarks=t,this.updated|=2,this}ensureMarks(t){return ne.sameSet(this.storedMarks||this.selection.$from.marks(),t)||this.setStoredMarks(t),this}addStoredMark(t){return this.ensureMarks(t.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(t){return this.ensureMarks(t.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(2&this.updated)>0}addStep(t,e){super.addStep(t,e),this.updated=-3&this.updated,this.storedMarks=null}setTime(t){return this.time=t,this}replaceSelection(t){return this.selection.replace(this,t),this}replaceSelectionWith(t,e=!0){let n=this.selection;return e&&(t=t.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||ne.none))),n.replaceWith(this,t),this}deleteSelection(){return this.selection.replace(this),this}insertText(t,e,n){let r=this.doc.type.schema;if(null==e)return t?this.replaceSelectionWith(r.text(t),!0):this.deleteSelection();{if(null==n&&(n=e),n=null==n?e:n,!t)return this.deleteRange(e,n);let i=this.storedMarks;if(!i){let t=this.doc.resolve(e);i=n==e?t.marks():t.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(e,n,r.text(t,i)),this.selection.empty||this.setSelection(_n.near(this.selection.$to)),this}}setMeta(t,e){return this.meta["string"==typeof t?t:t.key]=e,this}getMeta(t){return this.meta["string"==typeof t?t:t.key]}get isGeneric(){for(let t in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=4,this}get scrolledIntoView(){return(4&this.updated)>0}}function er(t,e){return e&&t?t.bind(e):t}class nr{constructor(t,e,n){this.name=t,this.init=er(e.init,n),this.apply=er(e.apply,n)}}const rr=[new nr("doc",{init:t=>t.doc||t.schema.topNodeType.createAndFill(),apply:t=>t.doc}),new nr("selection",{init:(t,e)=>t.selection||_n.atStart(e.doc),apply:t=>t.selection}),new nr("storedMarks",{init:t=>t.storedMarks||null,apply:(t,e,n,r)=>r.selection.$cursor?t.storedMarks:null}),new nr("scrollToSelection",{init:()=>0,apply:(t,e)=>t.scrolledIntoView?e+1:e})];class ir{constructor(t,e){this.schema=t,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=rr.slice(),e&&e.forEach((t=>{if(this.pluginsByKey[t.key])throw new RangeError("Adding different instances of a keyed plugin ("+t.key+")");this.plugins.push(t),this.pluginsByKey[t.key]=t,t.spec.state&&this.fields.push(new nr(t.key,t.spec.state,t))}))}}class sr{constructor(t){this.config=t}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(t){return this.applyTransaction(t).state}filterTransaction(t,e=-1){for(let n=0;n<this.config.plugins.length;n++)if(n!=e){let e=this.config.plugins[n];if(e.spec.filterTransaction&&!e.spec.filterTransaction.call(e,t,this))return!1}return!0}applyTransaction(t){if(!this.filterTransaction(t))return{state:this,transactions:[]};let e=[t],n=this.applyInner(t),r=null;for(;;){let i=!1;for(let s=0;s<this.config.plugins.length;s++){let o=this.config.plugins[s];if(o.spec.appendTransaction){let a=r?r[s].n:0,l=r?r[s].state:this,c=a<e.length&&o.spec.appendTransaction.call(o,a?e.slice(a):e,l,n);if(c&&n.filterTransaction(c,s)){if(c.setMeta("appendedTransaction",t),!r){r=[];for(let t=0;t<this.config.plugins.length;t++)r.push(t<s?{state:n,n:e.length}:{state:this,n:0})}e.push(c),n=n.applyInner(c),i=!0}r&&(r[s]={state:n,n:e.length})}}if(!i)return{state:n,transactions:e}}}applyInner(t){if(!t.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let e=new sr(this.config),n=this.config.fields;for(let r=0;r<n.length;r++){let i=n[r];e[i.name]=i.apply(t,this[i.name],this,e)}return e}get tr(){return new tr(this)}static create(t){let e=new ir(t.doc?t.doc.type.schema:t.schema,t.plugins),n=new sr(e);for(let r=0;r<e.fields.length;r++)n[e.fields[r].name]=e.fields[r].init(t,n);return n}reconfigure(t){let e=new ir(this.schema,t.plugins),n=e.fields,r=new sr(e);for(let e=0;e<n.length;e++){let i=n[e].name;r[i]=this.hasOwnProperty(i)?this[i]:n[e].init(t,r)}return r}toJSON(t){let e={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(e.storedMarks=this.storedMarks.map((t=>t.toJSON()))),t&&"object"==typeof t)for(let n in t){if("doc"==n||"selection"==n)throw new RangeError("The JSON fields `doc` and `selection` are reserved");let r=t[n],i=r.spec.state;i&&i.toJSON&&(e[n]=i.toJSON.call(r,this[r.key]))}return e}static fromJSON(t,e,n){if(!e)throw new RangeError("Invalid input for EditorState.fromJSON");if(!t.schema)throw new RangeError("Required config field 'schema' missing");let r=new ir(t.schema,t.plugins),i=new sr(r);return r.fields.forEach((r=>{if("doc"==r.name)i.doc=ke.fromJSON(t.schema,e.doc);else if("selection"==r.name)i.selection=_n.fromJSON(i.doc,e.selection);else if("storedMarks"==r.name)e.storedMarks&&(i.storedMarks=e.storedMarks.map(t.schema.markFromJSON));else{if(n)for(let s in n){let o=n[s],a=o.spec.state;if(o.key==r.name&&a&&a.fromJSON&&Object.prototype.hasOwnProperty.call(e,s))return void(i[r.name]=a.fromJSON.call(o,t,e[s],i))}i[r.name]=r.init(t,i)}})),i}}function or(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):"handleDOMEvents"==r&&(i=or(i,e,{})),n[r]=i}return n}class ar{constructor(t){this.spec=t,this.props={},t.props&&or(t.props,this,this.props),this.key=t.key?t.key.key:cr("plugin")}getState(t){return t[this.key]}}const lr=Object.create(null);function cr(t){return t in lr?t+"$"+ ++lr[t]:(lr[t]=0,t+"$")}class hr{constructor(t="key"){this.key=cr(t)}get(t){return t.config.pluginsByKey[this.key]}getState(t){return t[this.key]}}const dr=function(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e},ur=function(t){let e=t.assignedSlot||t.parentNode;return e&&11==e.nodeType?e.host:e};let pr=null;const fr=function(t,e,n){let r=pr||(pr=document.createRange());return r.setEnd(t,null==n?t.nodeValue.length:n),r.setStart(t,e||0),r},mr=function(t,e,n,r){return n&&(yr(t,e,n,r,-1)||yr(t,e,n,r,1))},gr=/^(img|br|input|textarea|hr)$/i;function yr(t,e,n,r,i){for(;;){if(t==n&&e==r)return!0;if(e==(i<0?0:vr(t))){let n=t.parentNode;if(!n||1!=n.nodeType||br(t)||gr.test(t.nodeName)||"false"==t.contentEditable)return!1;e=dr(t)+(i<0?0:1),t=n}else{if(1!=t.nodeType)return!1;if("false"==(t=t.childNodes[e+(i<0?-1:0)]).contentEditable)return!1;e=i<0?vr(t):0}}}function vr(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function br(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const wr=function(t){return t.focusNode&&mr(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function xr(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}const kr="undefined"!=typeof navigator?navigator:null,Sr="undefined"!=typeof document?document:null,Mr=kr&&kr.userAgent||"",Or=/Edge\/(\d+)/.exec(Mr),Ar=/MSIE \d/.exec(Mr),Er=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Mr),Cr=!!(Ar||Er||Or),Tr=Ar?document.documentMode:Er?+Er[1]:Or?+Or[1]:0,Nr=!Cr&&/gecko\/(\d+)/i.test(Mr);Nr&&(/Firefox\/(\d+)/.exec(Mr)||[0,0])[1];const Dr=!Cr&&/Chrome\/(\d+)/.exec(Mr),$r=!!Dr,Ir=Dr?+Dr[1]:0,Rr=!Cr&&!!kr&&/Apple Computer/.test(kr.vendor),Br=Rr&&(/Mobile\/\w+/.test(Mr)||!!kr&&kr.maxTouchPoints>2),Fr=Br||!!kr&&/Mac/.test(kr.platform),Pr=/Android \d/.test(Mr),Vr=!!Sr&&"webkitFontSmoothing"in Sr.documentElement.style,Lr=Vr?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function zr(t){return{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function jr(t,e){return"number"==typeof t?t:t[e]}function _r(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function Kr(t,e,n){let r=t.someProp("scrollThreshold")||0,i=t.someProp("scrollMargin")||5,s=t.dom.ownerDocument;for(let o=n||t.dom;o;o=ur(o)){if(1!=o.nodeType)continue;let t=o,n=t==s.body,a=n?zr(s):_r(t),l=0,c=0;if(e.top<a.top+jr(r,"top")?c=-(a.top-e.top+jr(i,"top")):e.bottom>a.bottom-jr(r,"bottom")&&(c=e.bottom-a.bottom+jr(i,"bottom")),e.left<a.left+jr(r,"left")?l=-(a.left-e.left+jr(i,"left")):e.right>a.right-jr(r,"right")&&(l=e.right-a.right+jr(i,"right")),l||c)if(n)s.defaultView.scrollBy(l,c);else{let n=t.scrollLeft,r=t.scrollTop;c&&(t.scrollTop+=c),l&&(t.scrollLeft+=l);let i=t.scrollLeft-n,s=t.scrollTop-r;e={left:e.left-i,top:e.top-s,right:e.right-i,bottom:e.bottom-s}}if(n)break}}function Wr(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=ur(r));return e}function Hr(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:i,left:s}=t[n];r.scrollTop!=i+e&&(r.scrollTop=i+e),r.scrollLeft!=s&&(r.scrollLeft=s)}}let qr=null;function Jr(t,e){let n,r,i=2e8,s=0,o=e.top,a=e.top;for(let l=t.firstChild,c=0;l;l=l.nextSibling,c++){let t;if(1==l.nodeType)t=l.getClientRects();else{if(3!=l.nodeType)continue;t=fr(l).getClientRects()}for(let h=0;h<t.length;h++){let d=t[h];if(d.top<=o&&d.bottom>=a){o=Math.max(d.bottom,o),a=Math.min(d.top,a);let t=d.left>e.left?d.left-e.left:d.right<e.left?e.left-d.right:0;if(t<i){n=l,i=t,r=t&&3==n.nodeType?{left:d.right<e.left?d.right:d.left,top:e.top}:e,1==l.nodeType&&t&&(s=c+(e.left>=(d.left+d.right)/2?1:0));continue}}!n&&(e.left>=d.right&&e.top>=d.top||e.left>=d.left&&e.top>=d.bottom)&&(s=c+1)}}return n&&3==n.nodeType?function(t,e){let n=t.nodeValue.length,r=document.createRange();for(let i=0;i<n;i++){r.setEnd(t,i+1),r.setStart(t,i);let n=Xr(r,1);if(n.top!=n.bottom&&Ur(e,n))return{node:t,offset:i+(e.left>=(n.left+n.right)/2?1:0)}}return{node:t,offset:0}}(n,r):!n||i&&1==n.nodeType?{node:t,offset:s}:Jr(n,r)}function Ur(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function Gr(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),s=i;;){let n=t.childNodes[s];if(1==n.nodeType){let t=n.getClientRects();for(let r=0;r<t.length;r++){let i=t[r];if(Ur(e,i))return Gr(n,e,i)}}if((s=(s+1)%r)==i)break}return t}function Yr(t,e){let n,r=t.dom.ownerDocument,i=0;if(r.caretPositionFromPoint)try{let t=r.caretPositionFromPoint(e.left,e.top);t&&({offsetNode:n,offset:i}=t)}catch(t){}if(!n&&r.caretRangeFromPoint){let t=r.caretRangeFromPoint(e.left,e.top);t&&({startContainer:n,startOffset:i}=t)}let s,o=(t.root.elementFromPoint?t.root:r).elementFromPoint(e.left,e.top);if(!o||!t.dom.contains(1!=o.nodeType?o.parentNode:o)){let n=t.dom.getBoundingClientRect();if(!Ur(e,n))return null;if(o=Gr(t.dom,e,n),!o)return null}if(Rr)for(let t=o;n&&t;t=ur(t))t.draggable&&(n=void 0);if(o=function(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}(o,e),n){if(Nr&&1==n.nodeType&&(i=Math.min(i,n.childNodes.length),i<n.childNodes.length)){let t,r=n.childNodes[i];"IMG"==r.nodeName&&(t=r.getBoundingClientRect()).right<=e.left&&t.bottom>e.top&&i++}n==t.dom&&i==n.childNodes.length-1&&1==n.lastChild.nodeType&&e.top>n.lastChild.getBoundingClientRect().bottom?s=t.state.doc.content.size:0!=i&&1==n.nodeType&&"BR"==n.childNodes[i-1].nodeName||(s=function(t,e,n,r){let i=-1;for(let n=e;n!=t.dom;){let e=t.docView.nearestDesc(n,!0);if(!e)return null;if(e.node.isBlock&&e.parent){let t=e.dom.getBoundingClientRect();if(t.left>r.left||t.top>r.top)i=e.posBefore;else{if(!(t.right<r.left||t.bottom<r.top))break;i=e.posAfter}}n=e.dom.parentNode}return i>-1?i:t.docView.posFromDOM(e,n,1)}(t,n,i,e))}null==s&&(s=function(t,e,n){let{node:r,offset:i}=Jr(e,n),s=-1;if(1==r.nodeType&&!r.firstChild){let t=r.getBoundingClientRect();s=t.left!=t.right&&n.left>(t.left+t.right)/2?1:-1}return t.docView.posFromDOM(r,i,s)}(t,o,e));let a=t.docView.nearestDesc(o,!0);return{pos:s,inside:a?a.posAtStart-a.border:-1}}function Xr(t,e){let n=t.getClientRects();return n.length?n[e<0?0:n.length-1]:t.getBoundingClientRect()}const Zr=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Qr(t,e,n){let{node:r,offset:i,atom:s}=t.docView.domFromPos(e,n<0?-1:1),o=Vr||Nr;if(3==r.nodeType){if(!o||!Zr.test(r.nodeValue)&&(n<0?i:i!=r.nodeValue.length)){let t=i,e=i,s=n<0?1:-1;return n<0&&!i?(e++,s=-1):n>=0&&i==r.nodeValue.length?(t--,s=1):n<0?t--:e++,ti(Xr(fr(r,t,e),1),s<0)}{let t=Xr(fr(r,i,i),n);if(Nr&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let e=Xr(fr(r,i-1,i-1),-1);if(e.top==t.top){let n=Xr(fr(r,i,i+1),-1);if(n.top!=t.top)return ti(n,n.left<e.left)}}return t}}if(!t.state.doc.resolve(e-(s||0)).parent.inlineContent){if(null==s&&i&&(n<0||i==vr(r))){let t=r.childNodes[i-1];if(1==t.nodeType)return ei(t.getBoundingClientRect(),!1)}if(null==s&&i<vr(r)){let t=r.childNodes[i];if(1==t.nodeType)return ei(t.getBoundingClientRect(),!0)}return ei(r.getBoundingClientRect(),n>=0)}if(null==s&&i&&(n<0||i==vr(r))){let t=r.childNodes[i-1],e=3==t.nodeType?fr(t,vr(t)-(o?0:1)):1!=t.nodeType||"BR"==t.nodeName&&t.nextSibling?null:t;if(e)return ti(Xr(e,1),!1)}if(null==s&&i<vr(r)){let t=r.childNodes[i];for(;t.pmViewDesc&&t.pmViewDesc.ignoreForCoords;)t=t.nextSibling;let e=t?3==t.nodeType?fr(t,0,o?0:1):1==t.nodeType?t:null:null;if(e)return ti(Xr(e,-1),!0)}return ti(Xr(3==r.nodeType?fr(r):r,-n),n>=0)}function ti(t,e){if(0==t.width)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function ei(t,e){if(0==t.height)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function ni(t,e,n){let r=t.state,i=t.root.activeElement;r!=e&&t.updateState(e),i!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),i!=t.dom&&i&&i.focus()}}const ri=/[\u0590-\u08ac]/;let ii=null,si=null,oi=!1;function ai(t,e,n){return ii==e&&si==n?oi:(ii=e,si=n,oi="up"==n||"down"==n?function(t,e,n){let r=e.selection,i="up"==n?r.$from:r.$to;return ni(t,e,(()=>{let{node:e}=t.docView.domFromPos(i.pos,"up"==n?-1:1);for(;;){let n=t.docView.nearestDesc(e,!0);if(!n)break;if(n.node.isBlock){e=n.dom;break}e=n.dom.parentNode}let r=Qr(t,i.pos,1);for(let t=e.firstChild;t;t=t.nextSibling){let e;if(1==t.nodeType)e=t.getClientRects();else{if(3!=t.nodeType)continue;e=fr(t,0,t.nodeValue.length).getClientRects()}for(let t=0;t<e.length;t++){let i=e[t];if(i.bottom>i.top+1&&("up"==n?r.top-i.top>2*(i.bottom-r.top):i.bottom-r.bottom>2*(r.bottom-i.top)))return!1}}return!0}))}(t,e,n):function(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,s=!i,o=i==r.parent.content.size,a=t.domSelection();return ri.test(r.parent.textContent)&&a.modify?ni(t,e,(()=>{let{focusNode:e,focusOffset:i,anchorNode:s,anchorOffset:o}=t.domSelectionRange(),l=a.caretBidiLevel;a.modify("move",n,"character");let c=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:h,focusOffset:d}=t.domSelectionRange(),u=h&&!c.contains(1==h.nodeType?h:h.parentNode)||e==h&&i==d;try{a.collapse(s,o),e&&(e!=s||i!=o)&&a.extend&&a.extend(e,i)}catch(t){}return null!=l&&(a.caretBidiLevel=l),u})):"left"==n||"backward"==n?s:o}(t,e,n))}class li{constructor(t,e,n,r){this.parent=t,this.children=e,this.dom=n,this.contentDOM=r,this.dirty=0,n.pmViewDesc=this}matchesWidget(t){return!1}matchesMark(t){return!1}matchesNode(t,e,n){return!1}matchesHack(t){return!1}parseRule(){return null}stopEvent(t){return!1}get size(){let t=0;for(let e=0;e<this.children.length;e++)t+=this.children[e].size;return t}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let t=0;t<this.children.length;t++)this.children[t].destroy()}posBeforeChild(t){for(let e=0,n=this.posAtStart;;e++){let r=this.children[e];if(r==t)return n;n+=r.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(t,e,n){if(this.contentDOM&&this.contentDOM.contains(1==t.nodeType?t:t.parentNode)){if(n<0){let n,r;if(t==this.contentDOM)n=t.childNodes[e-1];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;n=t.previousSibling}for(;n&&(!(r=n.pmViewDesc)||r.parent!=this);)n=n.previousSibling;return n?this.posBeforeChild(r)+r.size:this.posAtStart}{let n,r;if(t==this.contentDOM)n=t.childNodes[e];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;n=t.nextSibling}for(;n&&(!(r=n.pmViewDesc)||r.parent!=this);)n=n.nextSibling;return n?this.posBeforeChild(r):this.posAtEnd}}let r;if(t==this.dom&&this.contentDOM)r=e>dr(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))r=2&t.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==e)for(let e=t;;e=e.parentNode){if(e==this.dom){r=!1;break}if(e.previousSibling)break}if(null==r&&e==t.childNodes.length)for(let e=t;;e=e.parentNode){if(e==this.dom){r=!0;break}if(e.nextSibling)break}}return(null==r?n>0:r)?this.posAtEnd:this.posAtStart}nearestDesc(t,e=!1){for(let n=!0,r=t;r;r=r.parentNode){let i,s=this.getDesc(r);if(s&&(!e||s.node)){if(!n||!(i=s.nodeDOM)||(1==i.nodeType?i.contains(1==t.nodeType?t:t.parentNode):i==t))return s;n=!1}}}getDesc(t){let e=t.pmViewDesc;for(let t=e;t;t=t.parent)if(t==this)return e}posFromDOM(t,e,n){for(let r=t;r;r=r.parentNode){let i=this.getDesc(r);if(i)return i.localPosFromDOM(t,e,n)}return-1}descAt(t){for(let e=0,n=0;e<this.children.length;e++){let r=this.children[e],i=n+r.size;if(n==t&&i!=n){for(;!r.border&&r.children.length;)r=r.children[0];return r}if(t<i)return r.descAt(t-n-r.border);n=i}}domFromPos(t,e){if(!this.contentDOM)return{node:this.dom,offset:0,atom:t+1};let n,r=0,i=0;for(let e=0;r<this.children.length;r++){let n=this.children[r],s=e+n.size;if(s>t||n instanceof mi){i=t-e;break}e=s}if(i)return this.children[r].domFromPos(i-this.children[r].border,e);for(;r&&!(n=this.children[r-1]).size&&n instanceof ci&&n.side>=0;r--);if(e<=0){let t,n=!0;for(;t=r?this.children[r-1]:null,t&&t.dom.parentNode!=this.contentDOM;r--,n=!1);return t&&e&&n&&!t.border&&!t.domAtom?t.domFromPos(t.size,e):{node:this.contentDOM,offset:t?dr(t.dom)+1:0}}{let t,n=!0;for(;t=r<this.children.length?this.children[r]:null,t&&t.dom.parentNode!=this.contentDOM;r++,n=!1);return t&&n&&!t.border&&!t.domAtom?t.domFromPos(0,e):{node:this.contentDOM,offset:t?dr(t.dom):this.contentDOM.childNodes.length}}}parseRange(t,e,n=0){if(0==this.children.length)return{node:this.contentDOM,from:t,to:e,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let r=-1,i=-1;for(let s=n,o=0;;o++){let n=this.children[o],a=s+n.size;if(-1==r&&t<=a){let i=s+n.border;if(t>=i&&e<=a-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(t,e,i);t=s;for(let e=o;e>0;e--){let n=this.children[e-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){r=dr(n.dom)+1;break}t-=n.size}-1==r&&(r=0)}if(r>-1&&(a>e||o==this.children.length-1)){e=a;for(let t=o+1;t<this.children.length;t++){let n=this.children[t];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(-1)){i=dr(n.dom);break}e+=n.size}-1==i&&(i=this.contentDOM.childNodes.length);break}s=a}return{node:this.contentDOM,from:t,to:e,fromOffset:r,toOffset:i}}emptyChildAt(t){if(this.border||!this.contentDOM||!this.children.length)return!1;let e=this.children[t<0?0:this.children.length-1];return 0==e.size||e.emptyChildAt(t)}domAfterPos(t){let{node:e,offset:n}=this.domFromPos(t,0);if(1!=e.nodeType||n==e.childNodes.length)throw new RangeError("No node after pos "+t);return e.childNodes[n]}setSelection(t,e,n,r=!1){let i=Math.min(t,e),s=Math.max(t,e);for(let o=0,a=0;o<this.children.length;o++){let l=this.children[o],c=a+l.size;if(i>a&&s<c)return l.setSelection(t-a-l.border,e-a-l.border,n,r);a=c}let o=this.domFromPos(t,t?-1:1),a=e==t?o:this.domFromPos(e,e?-1:1),l=n.getSelection(),c=!1;if((Nr||Rr)&&t==e){let{node:t,offset:e}=o;if(3==t.nodeType){if(c=!(!e||"\n"!=t.nodeValue[e-1]),c&&e==t.nodeValue.length)for(let e,n=t;n;n=n.parentNode){if(e=n.nextSibling){"BR"==e.nodeName&&(o=a={node:e.parentNode,offset:dr(e)+1});break}let t=n.pmViewDesc;if(t&&t.node&&t.node.isBlock)break}}else{let n=t.childNodes[e-1];c=n&&("BR"==n.nodeName||"false"==n.contentEditable)}}if(Nr&&l.focusNode&&l.focusNode!=a.node&&1==l.focusNode.nodeType){let t=l.focusNode.childNodes[l.focusOffset];t&&"false"==t.contentEditable&&(r=!0)}if(!(r||c&&Rr)&&mr(o.node,o.offset,l.anchorNode,l.anchorOffset)&&mr(a.node,a.offset,l.focusNode,l.focusOffset))return;let h=!1;if((l.extend||t==e)&&!c){l.collapse(o.node,o.offset);try{t!=e&&l.extend(a.node,a.offset),h=!0}catch(t){}}if(!h){if(t>e){let t=o;o=a,a=t}let n=document.createRange();n.setEnd(a.node,a.offset),n.setStart(o.node,o.offset),l.removeAllRanges(),l.addRange(n)}}ignoreMutation(t){return!this.contentDOM&&"selection"!=t.type}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(t,e){for(let n=0,r=0;r<this.children.length;r++){let i=this.children[r],s=n+i.size;if(n==s?t<=s&&e>=n:t<s&&e>n){let r=n+i.border,o=s-i.border;if(t>=r&&e<=o)return this.dirty=t==n||e==s?2:1,void(t!=r||e!=o||!i.contentLost&&i.dom.parentNode==this.contentDOM?i.markDirty(t-r,e-r):i.dirty=3);i.dirty=i.dom!=i.contentDOM||i.dom.parentNode!=this.contentDOM||i.children.length?3:2}n=s}this.dirty=2}markParentsDirty(){let t=1;for(let e=this.parent;e;e=e.parent,t++){let n=1==t?2:1;e.dirty<n&&(e.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}}class ci extends li{constructor(t,e,n,r){let i,s=e.type.toDOM;if("function"==typeof s&&(s=s(n,(()=>i?i.parent?i.parent.posBeforeChild(i):void 0:r))),!e.type.spec.raw){if(1!=s.nodeType){let t=document.createElement("span");t.appendChild(s),s=t}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(t,[],s,null),this.widget=e,this.widget=e,i=this}matchesWidget(t){return 0==this.dirty&&t.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(t){let e=this.widget.spec.stopEvent;return!!e&&e(t)}ignoreMutation(t){return"selection"!=t.type||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}}class hi extends li{constructor(t,e,n,r){super(t,[],e,null),this.textDOM=n,this.text=r}get size(){return this.text.length}localPosFromDOM(t,e){return t!=this.textDOM?this.posAtStart+(e?this.size:0):this.posAtStart+e}domFromPos(t){return{node:this.textDOM,offset:t}}ignoreMutation(t){return"characterData"===t.type&&t.target.nodeValue==t.oldValue}}class di extends li{constructor(t,e,n,r){super(t,[],n,r),this.mark=e}static create(t,e,n,r){let i=r.nodeViews[e.type.name],s=i&&i(e,r,n);return s&&s.dom||(s=Ze.renderSpec(document,e.type.spec.toDOM(e,n))),new di(t,e,s.dom,s.contentDOM||s.dom)}parseRule(){return 3&this.dirty||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM||void 0}}matchesMark(t){return 3!=this.dirty&&this.mark.eq(t)}markDirty(t,e){if(super.markDirty(t,e),0!=this.dirty){let t=this.parent;for(;!t.node;)t=t.parent;t.dirty<this.dirty&&(t.dirty=this.dirty),this.dirty=0}}slice(t,e,n){let r=di.create(this.parent,this.mark,!0,n),i=this.children,s=this.size;e<s&&(i=Ci(i,e,s,n)),t>0&&(i=Ci(i,0,t,n));for(let t=0;t<i.length;t++)i[t].parent=r;return r.children=i,r}}class ui extends li{constructor(t,e,n,r,i,s,o,a,l){super(t,[],i,s),this.node=e,this.outerDeco=n,this.innerDeco=r,this.nodeDOM=o,s&&this.updateChildren(a,l)}static create(t,e,n,r,i,s){let o,a=i.nodeViews[e.type.name],l=a&&a(e,i,(()=>o?o.parent?o.parent.posBeforeChild(o):void 0:s),n,r),c=l&&l.dom,h=l&&l.contentDOM;if(e.isText)if(c){if(3!=c.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else c=document.createTextNode(e.text);else c||({dom:c,contentDOM:h}=Ze.renderSpec(document,e.type.spec.toDOM(e)));h||e.isText||"BR"==c.nodeName||(c.hasAttribute("contenteditable")||(c.contentEditable="false"),e.type.spec.draggable&&(c.draggable=!0));let d=c;return c=Si(c,n,e),l?o=new gi(t,e,n,r,c,h||null,d,l,i,s+1):e.isText?new fi(t,e,n,r,c,d,i):new ui(t,e,n,r,c,h||null,d,i,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if("pre"==this.node.type.whitespace&&(t.preserveWhitespace="full"),this.contentDOM)if(this.contentLost){for(let e=this.children.length-1;e>=0;e--){let n=this.children[e];if(this.dom.contains(n.dom.parentNode)){t.contentElement=n.dom.parentNode;break}}t.contentElement||(t.getContent=()=>Zt.empty)}else t.contentElement=this.contentDOM;else t.getContent=()=>this.node.content;return t}matchesNode(t,e,n){return 0==this.dirty&&t.eq(this.node)&&Mi(e,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(t,e){let n=this.node.inlineContent,r=e,i=t.composing?this.localCompositionInfo(t,e):null,s=i&&i.pos>-1?i:null,o=i&&i.pos<0,a=new Ai(this,s&&s.node,t);!function(t,e,n,r){let i=e.locals(t),s=0;if(0==i.length){for(let n=0;n<t.childCount;n++){let o=t.child(n);r(o,i,e.forChild(s,o),n),s+=o.nodeSize}return}let o=0,a=[],l=null;for(let c=0;;){if(o<i.length&&i[o].to==s){let t,e=i[o++];for(;o<i.length&&i[o].to==s;)(t||(t=[e])).push(i[o++]);if(t){t.sort(Ei);for(let e=0;e<t.length;e++)n(t[e],c,!!l)}else n(e,c,!!l)}let h,d;if(l)d=-1,h=l,l=null;else{if(!(c<t.childCount))break;d=c,h=t.child(c++)}for(let t=0;t<a.length;t++)a[t].to<=s&&a.splice(t--,1);for(;o<i.length&&i[o].from<=s&&i[o].to>s;)a.push(i[o++]);let u=s+h.nodeSize;if(h.isText){let t=u;o<i.length&&i[o].from<t&&(t=i[o].from);for(let e=0;e<a.length;e++)a[e].to<t&&(t=a[e].to);t<u&&(l=h.cut(t-s),h=h.cut(0,t-s),u=t,d=-1)}let p=h.isInline&&!h.isLeaf?a.filter((t=>!t.inline)):a.slice();r(h,p,e.forChild(s,h),d),s=u}}(this.node,this.innerDeco,((e,i,s)=>{e.spec.marks?a.syncToMarks(e.spec.marks,n,t):e.type.side>=0&&!s&&a.syncToMarks(i==this.node.childCount?ne.none:this.node.child(i).marks,n,t),a.placeWidget(e,t,r)}),((e,s,l,c)=>{let h;a.syncToMarks(e.marks,n,t),a.findNodeMatch(e,s,l,c)||o&&t.state.selection.from>r&&t.state.selection.to<r+e.nodeSize&&(h=a.findIndexWithChild(i.node))>-1&&a.updateNodeAt(e,s,l,h,t)||a.updateNextNode(e,s,l,t,c)||a.addNode(e,s,l,t,r),r+=e.nodeSize})),a.syncToMarks([],n,t),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||2==this.dirty)&&(s&&this.protectLocalComposition(t,s),yi(this.contentDOM,this.children,t),Br&&function(t){if("UL"==t.nodeName||"OL"==t.nodeName){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}(this.dom))}localCompositionInfo(t,e){let{from:n,to:r}=t.state.selection;if(!(t.state.selection instanceof qn)||n<e||r>e+this.node.content.size)return null;let i=t.domSelectionRange(),s=function(t,e){for(;;){if(3==t.nodeType)return t;if(1==t.nodeType&&e>0){if(t.childNodes.length>e&&3==t.childNodes[e].nodeType)return t.childNodes[e];e=vr(t=t.childNodes[e-1])}else{if(!(1==t.nodeType&&e<t.childNodes.length))return null;t=t.childNodes[e],e=0}}}(i.focusNode,i.focusOffset);if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let t=s.nodeValue,i=function(t,e,n,r){for(let i=0,s=0;i<t.childCount&&s<=r;){let o=t.child(i++),a=s;if(s+=o.nodeSize,!o.isText)continue;let l=o.text;for(;i<t.childCount;){let e=t.child(i++);if(s+=e.nodeSize,!e.isText)break;l+=e.text}if(s>=n){let t=a<r?l.lastIndexOf(e,r-a-1):-1;if(t>=0&&t+e.length+a>=n)return a+t;if(n==r&&l.length>=r+e.length-a&&l.slice(r-a,r-a+e.length)==e)return r}}return-1}(this.node.content,t,n-e,r-e);return i<0?null:{node:s,pos:i,text:t}}return{node:s,pos:-1,text:""}}protectLocalComposition(t,{node:e,pos:n,text:r}){if(this.getDesc(e))return;let i=e;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let s=new hi(this,i,e,r);t.input.compositionNodes.push(s),this.children=Ci(this.children,n,n+r.length,t,s)}update(t,e,n,r){return!(3==this.dirty||!t.sameMarkup(this.node))&&(this.updateInner(t,e,n,r),!0)}updateInner(t,e,n,r){this.updateOuterDeco(e),this.node=t,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=0}updateOuterDeco(t){if(Mi(t,this.outerDeco))return;let e=1!=this.nodeDOM.nodeType,n=this.dom;this.dom=xi(this.dom,this.nodeDOM,wi(this.outerDeco,this.node,e),wi(t,this.node,e)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=t}selectNode(){1==this.nodeDOM.nodeType&&this.nodeDOM.classList.add("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||(this.dom.draggable=!0)}deselectNode(){1==this.nodeDOM.nodeType&&this.nodeDOM.classList.remove("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||this.dom.removeAttribute("draggable")}get domAtom(){return this.node.isAtom}}function pi(t,e,n,r,i){return Si(r,e,t),new ui(void 0,t,e,n,r,r,r,i,0)}class fi extends ui{constructor(t,e,n,r,i,s,o){super(t,e,n,r,i,null,s,o,0)}parseRule(){let t=this.nodeDOM.parentNode;for(;t&&t!=this.dom&&!t.pmIsDeco;)t=t.parentNode;return{skip:t||!0}}update(t,e,n,r){return!(3==this.dirty||0!=this.dirty&&!this.inParent()||!t.sameMarkup(this.node))&&(this.updateOuterDeco(e),0==this.dirty&&t.text==this.node.text||t.text==this.nodeDOM.nodeValue||(this.nodeDOM.nodeValue=t.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=t,this.dirty=0,!0)}inParent(){let t=this.parent.contentDOM;for(let e=this.nodeDOM;e;e=e.parentNode)if(e==t)return!0;return!1}domFromPos(t){return{node:this.nodeDOM,offset:t}}localPosFromDOM(t,e,n){return t==this.nodeDOM?this.posAtStart+Math.min(e,this.node.text.length):super.localPosFromDOM(t,e,n)}ignoreMutation(t){return"characterData"!=t.type&&"selection"!=t.type}slice(t,e,n){let r=this.node.cut(t,e),i=document.createTextNode(r.text);return new fi(this.parent,r,this.outerDeco,this.innerDeco,i,i,n)}markDirty(t,e){super.markDirty(t,e),this.dom==this.nodeDOM||0!=t&&e!=this.nodeDOM.nodeValue.length||(this.dirty=3)}get domAtom(){return!1}}class mi extends li{parseRule(){return{ignore:!0}}matchesHack(t){return 0==this.dirty&&this.dom.nodeName==t}get domAtom(){return!0}get ignoreForCoords(){return"IMG"==this.dom.nodeName}}class gi extends ui{constructor(t,e,n,r,i,s,o,a,l,c){super(t,e,n,r,i,s,o,l,c),this.spec=a}update(t,e,n,r){if(3==this.dirty)return!1;if(this.spec.update){let i=this.spec.update(t,e,n);return i&&this.updateInner(t,e,n,r),i}return!(!this.contentDOM&&!t.isLeaf)&&super.update(t,e,n,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(t,e,n,r){this.spec.setSelection?this.spec.setSelection(t,e,n):super.setSelection(t,e,n,r)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(t){return!!this.spec.stopEvent&&this.spec.stopEvent(t)}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}}function yi(t,e,n){let r=t.firstChild,i=!1;for(let s=0;s<e.length;s++){let o=e[s],a=o.dom;if(a.parentNode==t){for(;a!=r;)r=Oi(r),i=!0;r=r.nextSibling}else i=!0,t.insertBefore(a,r);if(o instanceof di){let e=r?r.previousSibling:t.lastChild;yi(o.contentDOM,o.children,n),r=e?e.nextSibling:t.firstChild}}for(;r;)r=Oi(r),i=!0;i&&n.trackWrites==t&&(n.trackWrites=null)}const vi=function(t){t&&(this.nodeName=t)};vi.prototype=Object.create(null);const bi=[new vi];function wi(t,e,n){if(0==t.length)return bi;let r=n?bi[0]:new vi,i=[r];for(let s=0;s<t.length;s++){let o=t[s].type.attrs;if(o){o.nodeName&&i.push(r=new vi(o.nodeName));for(let t in o){let s=o[t];null!=s&&(n&&1==i.length&&i.push(r=new vi(e.isInline?"span":"div")),"class"==t?r.class=(r.class?r.class+" ":"")+s:"style"==t?r.style=(r.style?r.style+";":"")+s:"nodeName"!=t&&(r[t]=s))}}}return i}function xi(t,e,n,r){if(n==bi&&r==bi)return e;let i=e;for(let e=0;e<r.length;e++){let s=r[e],o=n[e];if(e){let e;o&&o.nodeName==s.nodeName&&i!=t&&(e=i.parentNode)&&e.nodeName.toLowerCase()==s.nodeName||(e=document.createElement(s.nodeName),e.pmIsDeco=!0,e.appendChild(i),o=bi[0]),i=e}ki(i,o||bi[0],s)}return i}function ki(t,e,n){for(let r in e)"class"==r||"style"==r||"nodeName"==r||r in n||t.removeAttribute(r);for(let r in n)"class"!=r&&"style"!=r&&"nodeName"!=r&&n[r]!=e[r]&&t.setAttribute(r,n[r]);if(e.class!=n.class){let r=e.class?e.class.split(" ").filter(Boolean):[],i=n.class?n.class.split(" ").filter(Boolean):[];for(let e=0;e<r.length;e++)-1==i.indexOf(r[e])&&t.classList.remove(r[e]);for(let e=0;e<i.length;e++)-1==r.indexOf(i[e])&&t.classList.add(i[e]);0==t.classList.length&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let n,r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;for(;n=r.exec(e.style);)t.style.removeProperty(n[1])}n.style&&(t.style.cssText+=n.style)}}function Si(t,e,n){return xi(t,t,bi,wi(e,n,1!=t.nodeType))}function Mi(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].type.eq(e[n].type))return!1;return!0}function Oi(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class Ai{constructor(t,e,n){this.lock=e,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=t,this.preMatch=function(t,e){let n=e,r=n.children.length,i=t.childCount,s=new Map,o=[];t:for(;i>0;){let a;for(;;)if(r){let t=n.children[r-1];if(!(t instanceof di)){a=t,r--;break}n=t,r=t.children.length}else{if(n==e)break t;r=n.parent.children.indexOf(n),n=n.parent}let l=a.node;if(l){if(l!=t.child(i-1))break;--i,s.set(a,i),o.push(a)}}return{index:i,matched:s,matches:o.reverse()}}(t.node.content,t)}destroyBetween(t,e){if(t!=e){for(let n=t;n<e;n++)this.top.children[n].destroy();this.top.children.splice(t,e-t),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(t,e,n){let r=0,i=this.stack.length>>1,s=Math.min(i,t.length);for(;r<s&&(r==i-1?this.top:this.stack[r+1<<1]).matchesMark(t[r])&&!1!==t[r].type.spec.spanning;)r++;for(;r<i;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),i--;for(;i<t.length;){this.stack.push(this.top,this.index+1);let r=-1;for(let e=this.index;e<Math.min(this.index+3,this.top.children.length);e++)if(this.top.children[e].matchesMark(t[i])){r=e;break}if(r>-1)r>this.index&&(this.changed=!0,this.destroyBetween(this.index,r)),this.top=this.top.children[this.index];else{let r=di.create(this.top,t[i],e,n);this.top.children.splice(this.index,0,r),this.top=r,this.changed=!0}this.index=0,i++}}findNodeMatch(t,e,n,r){let i,s=-1;if(r>=this.preMatch.index&&(i=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&i.matchesNode(t,e,n))s=this.top.children.indexOf(i,this.index);else for(let r=this.index,i=Math.min(this.top.children.length,r+5);r<i;r++){let i=this.top.children[r];if(i.matchesNode(t,e,n)&&!this.preMatch.matched.has(i)){s=r;break}}return!(s<0)&&(this.destroyBetween(this.index,s),this.index++,!0)}updateNodeAt(t,e,n,r,i){let s=this.top.children[r];return 3==s.dirty&&s.dom==s.contentDOM&&(s.dirty=2),!!s.update(t,e,n,i)&&(this.destroyBetween(this.index,r),this.index++,!0)}findIndexWithChild(t){for(;;){let e=t.parentNode;if(!e)return-1;if(e==this.top.contentDOM){let e=t.pmViewDesc;if(e)for(let t=this.index;t<this.top.children.length;t++)if(this.top.children[t]==e)return t;return-1}t=e}}updateNextNode(t,e,n,r,i){for(let s=this.index;s<this.top.children.length;s++){let o=this.top.children[s];if(o instanceof ui){let a=this.preMatch.matched.get(o);if(null!=a&&a!=i)return!1;let l=o.dom;if(!(this.lock&&(l==this.lock||1==l.nodeType&&l.contains(this.lock.parentNode))&&!(t.isText&&o.node&&o.node.isText&&o.nodeDOM.nodeValue==t.text&&3!=o.dirty&&Mi(e,o.outerDeco)))&&o.update(t,e,n,r))return this.destroyBetween(this.index,s),o.dom!=l&&(this.changed=!0),this.index++,!0;break}}return!1}addNode(t,e,n,r,i){this.top.children.splice(this.index++,0,ui.create(this.top,t,e,n,r,i)),this.changed=!0}placeWidget(t,e,n){let r=this.index<this.top.children.length?this.top.children[this.index]:null;if(!r||!r.matchesWidget(t)||t!=r.widget&&r.widget.type.toDOM.parentNode){let r=new ci(this.top,t,e,n);this.top.children.splice(this.index++,0,r),this.changed=!0}else this.index++}addTextblockHacks(){let t=this.top.children[this.index-1],e=this.top;for(;t instanceof di;)e=t,t=e.children[e.children.length-1];(!t||!(t instanceof fi)||/\n$/.test(t.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(t.node.text))&&((Rr||$r)&&t&&"false"==t.dom.contentEditable&&this.addHackNode("IMG",e),this.addHackNode("BR",this.top))}addHackNode(t,e){if(e==this.top&&this.index<e.children.length&&e.children[this.index].matchesHack(t))this.index++;else{let n=document.createElement(t);"IMG"==t&&(n.className="ProseMirror-separator",n.alt=""),"BR"==t&&(n.className="ProseMirror-trailingBreak");let r=new mi(this.top,[],n,null);e!=this.top?e.children.push(r):e.children.splice(this.index++,0,r),this.changed=!0}}}function Ei(t,e){return t.type.side-e.type.side}function Ci(t,e,n,r,i){let s=[];for(let o=0,a=0;o<t.length;o++){let l=t[o],c=a,h=a+=l.size;c>=n||h<=e?s.push(l):(c<e&&s.push(l.slice(0,e-c,r)),i&&(s.push(i),i=void 0),h>n&&s.push(l.slice(n-c,l.size,r)))}return s}function Ti(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let i=t.docView.nearestDesc(n.focusNode),s=i&&0==i.size,o=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let a,l,c=r.resolve(o);if(wr(n)){for(a=c;i&&!i.node;)i=i.parent;let t=i.node;if(i&&t.isAtom&&Un.isSelectable(t)&&i.parent&&(!t.isInline||!function(t,e,n){for(let r=0==e,i=e==vr(t);r||i;){if(t==n)return!0;let e=dr(t);if(!(t=t.parentNode))return!1;r=r&&0==e,i=i&&e==vr(t)}}(n.focusNode,n.focusOffset,i.dom))){let t=i.posBefore;l=new Un(o==t?c:r.resolve(t))}}else{let e=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(e<0)return null;a=r.resolve(e)}if(!l){l=Vi(t,a,c,"pointer"==e||t.state.selection.head<c.pos&&!s?1:-1)}return l}function Ni(t){return t.editable?t.hasFocus():zi(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function Di(t,e=!1){let n=t.state.selection;if(Fi(t,n),Ni(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&$r){let e=t.domSelectionRange(),n=t.domObserver.currentSelection;if(e.anchorNode&&n.anchorNode&&mr(e.anchorNode,e.anchorOffset,n.anchorNode,n.anchorOffset))return t.input.mouseDown.delayedSelectionSync=!0,void t.domObserver.setCurSelection()}if(t.domObserver.disconnectSelection(),t.cursorWrapper)!function(t){let e=t.domSelection(),n=document.createRange(),r=t.cursorWrapper.dom,i="IMG"==r.nodeName;i?n.setEnd(r.parentNode,dr(r)+1):n.setEnd(r,0);n.collapse(!1),e.removeAllRanges(),e.addRange(n),!i&&!t.state.selection.visible&&Cr&&Tr<=11&&(r.disabled=!0,r.disabled=!1)}(t);else{let r,i,{anchor:s,head:o}=n;!$i||n instanceof qn||(n.$from.parent.inlineContent||(r=Ii(t,n.from)),n.empty||n.$from.parent.inlineContent||(i=Ii(t,n.to))),t.docView.setSelection(s,o,t.root,e),$i&&(r&&Bi(r),i&&Bi(i)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&function(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),r=n.anchorNode,i=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{n.anchorNode==r&&n.anchorOffset==i||(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout((()=>{Ni(t)&&!t.state.selection.visible||t.dom.classList.remove("ProseMirror-hideselection")}),20))})}(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const $i=Rr||$r&&Ir<63;function Ii(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),i=r<n.childNodes.length?n.childNodes[r]:null,s=r?n.childNodes[r-1]:null;if(Rr&&i&&"false"==i.contentEditable)return Ri(i);if(!(i&&"false"!=i.contentEditable||s&&"false"!=s.contentEditable)){if(i)return Ri(i);if(s)return Ri(s)}}function Ri(t){return t.contentEditable="true",Rr&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function Bi(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function Fi(t,e){if(e instanceof Un){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(Pi(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else Pi(t)}function Pi(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Vi(t,e,n,r){return t.someProp("createSelectionBetween",(r=>r(t,e,n)))||qn.between(e,n,r)}function Li(t){return!(t.editable&&!t.hasFocus())&&zi(t)}function zi(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(3==e.anchorNode.nodeType?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(3==e.focusNode.nodeType?e.focusNode.parentNode:e.focusNode))}catch(t){return!1}}function ji(t,e){let{$anchor:n,$head:r}=t.selection,i=e>0?n.max(r):n.min(r),s=i.parent.inlineContent?i.depth?t.doc.resolve(e>0?i.after():i.before()):null:i;return s&&_n.findFrom(s,e)}function _i(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function Ki(t,e,n){let r=t.state.selection;if(!(r instanceof qn)){if(r instanceof Un&&r.node.isInline)return _i(t,new qn(e>0?r.$to:r.$from));{let n=ji(t.state,e);return!!n&&_i(t,n)}}if(!r.empty||n.indexOf("s")>-1)return!1;if(t.endOfTextblock(e>0?"right":"left")){let n=ji(t.state,e);return!!(n&&n instanceof Un)&&_i(t,n)}if(!(Fr&&n.indexOf("m")>-1)){let n,i=r.$head,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!s||s.isText)return!1;let o=e<0?i.pos-s.nodeSize:i.pos;return!!(s.isAtom||(n=t.docView.descAt(o))&&!n.contentDOM)&&(Un.isSelectable(s)?_i(t,new Un(e<0?t.state.doc.resolve(i.pos-s.nodeSize):i)):!!Vr&&_i(t,new qn(t.state.doc.resolve(e<0?o:o+s.nodeSize))))}}function Wi(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function Hi(t){let e=t.pmViewDesc;return e&&0==e.size&&(t.nextSibling||"BR"!=t.nodeName)}function qi(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,s,o=!1;for(Nr&&1==n.nodeType&&r<Wi(n)&&Hi(n.childNodes[r])&&(o=!0);;)if(r>0){if(1!=n.nodeType)break;{let t=n.childNodes[r-1];if(Hi(t))i=n,s=--r;else{if(3!=t.nodeType)break;n=t,r=n.nodeValue.length}}}else{if(Ui(n))break;{let e=n.previousSibling;for(;e&&Hi(e);)i=n.parentNode,s=dr(e),e=e.previousSibling;if(e)n=e,r=Wi(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?Gi(t,n,r):i&&Gi(t,i,s)}function Ji(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,s,o=Wi(n);for(;;)if(r<o){if(1!=n.nodeType)break;if(!Hi(n.childNodes[r]))break;i=n,s=++r}else{if(Ui(n))break;{let e=n.nextSibling;for(;e&&Hi(e);)i=e.parentNode,s=dr(e)+1,e=e.nextSibling;if(e)n=e,r=0,o=Wi(n);else{if(n=n.parentNode,n==t.dom)break;r=o=0}}}i&&Gi(t,i,s)}function Ui(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function Gi(t,e,n){let r=t.domSelection();if(wr(r)){let t=document.createRange();t.setEnd(e,n),t.setStart(e,n),r.removeAllRanges(),r.addRange(t)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:i}=t;setTimeout((()=>{t.state==i&&Di(t)}),50)}function Yi(t,e,n){let r=t.state.selection;if(r instanceof qn&&!r.empty||n.indexOf("s")>-1)return!1;if(Fr&&n.indexOf("m")>-1)return!1;let{$from:i,$to:s}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let n=ji(t.state,e);if(n&&n instanceof Un)return _i(t,n)}if(!i.parent.inlineContent){let n=e<0?i:s,o=r instanceof Yn?_n.near(n,e):_n.findFrom(n,e);return!!o&&_i(t,o)}return!1}function Xi(t,e){if(!(t.state.selection instanceof qn))return!0;let{$head:n,$anchor:r,empty:i}=t.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(s&&!s.isText){let r=t.state.tr;return e<0?r.delete(n.pos-s.nodeSize,n.pos):r.delete(n.pos,n.pos+s.nodeSize),t.dispatch(r),!0}return!1}function Zi(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function Qi(t,e){let n=e.keyCode,r=function(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}(e);return 8==n||Fr&&72==n&&"c"==r?Xi(t,-1)||qi(t):46==n||Fr&&68==n&&"c"==r?Xi(t,1)||Ji(t):13==n||27==n||(37==n||Fr&&66==n&&"c"==r?Ki(t,-1,r)||qi(t):39==n||Fr&&70==n&&"c"==r?Ki(t,1,r)||Ji(t):38==n||Fr&&80==n&&"c"==r?Yi(t,-1,r)||qi(t):40==n||Fr&&78==n&&"c"==r?function(t){if(!Rr||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&1==e.nodeType&&0==n&&e.firstChild&&"false"==e.firstChild.contentEditable){let n=e.firstChild;Zi(t,n,"true"),setTimeout((()=>Zi(t,n,"false")),20)}return!1}(t)||Yi(t,1,r)||Ji(t):r==(Fr?"m":"c")&&(66==n||73==n||89==n||90==n))}function ts(t,e){t.someProp("transformCopied",(t=>{e=t(e)}));let n=[],{content:r,openStart:i,openEnd:s}=e;for(;i>1&&s>1&&1==r.childCount&&1==r.firstChild.childCount;){i--,s--;let t=r.firstChild;n.push(t.type.name,t.attrs!=t.type.defaultAttrs?t.attrs:null),r=t.content}let o=t.someProp("clipboardSerializer")||Ze.fromSchema(t.state.schema),a=ds(),l=a.createElement("div");l.appendChild(o.serializeFragment(r,{document:a}));let c,h=l.firstChild,d=0;for(;h&&1==h.nodeType&&(c=cs[h.nodeName.toLowerCase()]);){for(let t=c.length-1;t>=0;t--){let e=a.createElement(c[t]);for(;l.firstChild;)e.appendChild(l.firstChild);l.appendChild(e),d++}h=l.firstChild}h&&1==h.nodeType&&h.setAttribute("data-pm-slice",`${i} ${s}${d?` -${d}`:""} ${JSON.stringify(n)}`);let u=t.someProp("clipboardTextSerializer",(t=>t(e)))||e.content.textBetween(0,e.content.size,"\n\n");return{dom:l,text:u}}function es(t,e,n,r,i){let s,o,a=i.parent.type.spec.code;if(!n&&!e)return null;let l=e&&(r||a||!n);if(l){if(t.someProp("transformPastedText",(t=>{e=t(e,a||r)})),a)return e?new ie(Zt.from(t.state.schema.text(e.replace(/\r\n?/g,"\n"))),0,0):ie.empty;let n=t.someProp("clipboardTextParser",(t=>t(e,i,r)));if(n)o=n;else{let n=i.marks(),{schema:r}=t.state,o=Ze.fromSchema(r);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach((t=>{let e=s.appendChild(document.createElement("p"));t&&e.appendChild(o.serializeNode(r.text(t,n)))}))}}else t.someProp("transformPastedHTML",(t=>{n=t(n)})),s=function(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n,r=ds().createElement("div"),i=/<([a-z][^>\s]+)/i.exec(t);(n=i&&cs[i[1].toLowerCase()])&&(t=n.map((t=>"<"+t+">")).join("")+t+n.map((t=>"</"+t+">")).reverse().join(""));if(r.innerHTML=t,n)for(let t=0;t<n.length;t++)r=r.querySelector(n[t])||r;return r}(n),Vr&&function(t){let e=t.querySelectorAll($r?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<e.length;n++){let r=e[n];1==r.childNodes.length&&" "==r.textContent&&r.parentNode&&r.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),r)}}(s);let c=s&&s.querySelector("[data-pm-slice]"),h=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(h&&h[3])for(let t=+h[3];t>0&&s.firstChild;t--)s=s.firstChild;if(!o){let e=t.someProp("clipboardParser")||t.someProp("domParser")||_e.fromSchema(t.state.schema);o=e.parseSlice(s,{preserveWhitespace:!(!l&&!h),context:i,ruleFromNode:t=>"BR"!=t.nodeName||t.nextSibling||!t.parentNode||ns.test(t.parentNode.nodeName)?null:{ignore:!0}})}if(h)o=function(t,e){if(!t.size)return t;let n,r=t.content.firstChild.type.schema;try{n=JSON.parse(e)}catch(e){return t}let{content:i,openStart:s,openEnd:o}=t;for(let t=n.length-2;t>=0;t-=2){let e=r.nodes[n[t]];if(!e||e.hasRequiredAttrs())break;i=Zt.from(e.create(n[t+1],i)),s++,o++}return new ie(i,s,o)}(ls(o,+h[1],+h[2]),h[4]);else if(o=ie.maxOpen(function(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let r,i=e.node(n).contentMatchAt(e.index(n)),s=[];if(t.forEach((t=>{if(!s)return;let e,n=i.findWrapping(t.type);if(!n)return s=null;if(e=s.length&&r.length&&is(n,r,t,s[s.length-1],0))s[s.length-1]=e;else{s.length&&(s[s.length-1]=ss(s[s.length-1],r.length));let e=rs(t,n);s.push(e),i=i.matchType(e.type),r=n}})),s)return Zt.from(s)}return t}(o.content,i),!0),o.openStart||o.openEnd){let t=0,e=0;for(let e=o.content.firstChild;t<o.openStart&&!e.type.spec.isolating;t++,e=e.firstChild);for(let t=o.content.lastChild;e<o.openEnd&&!t.type.spec.isolating;e++,t=t.lastChild);o=ls(o,t,e)}return t.someProp("transformPasted",(t=>{o=t(o)})),o}const ns=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function rs(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,Zt.from(t));return t}function is(t,e,n,r,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let s=is(t,e,n,r.lastChild,i+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(i==t.length-1?n.type:t[i+1]))return r.copy(r.content.append(Zt.from(rs(n,t,i+1))))}}function ss(t,e){if(0==e)return t;let n=t.content.replaceChild(t.childCount-1,ss(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(Zt.empty,!0);return t.copy(n.append(r))}function as(t,e,n,r,i,s){let o=e<0?t.firstChild:t.lastChild,a=o.content;return i<r-1&&(a=as(a,e,n,r,i+1,s)),i>=n&&(a=e<0?o.contentMatchAt(0).fillBefore(a,t.childCount>1||s<=i).append(a):a.append(o.contentMatchAt(o.childCount).fillBefore(Zt.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(a))}function ls(t,e,n){return e<t.openStart&&(t=new ie(as(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new ie(as(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const cs={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let hs=null;function ds(){return hs||(hs=document.implementation.createHTMLDocument("title"))}const us={},ps={},fs={touchstart:!0,touchmove:!0};class ms{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastAndroidDelete=0,this.composing=!1,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function gs(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function ys(t){t.someProp("handleDOMEvents",(e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=e=>vs(t,e))}))}function vs(t,e){return t.someProp("handleDOMEvents",(n=>{let r=n[e.type];return!!r&&(r(t,e)||e.defaultPrevented)}))}function bs(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||11==n.nodeType||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function ws(t){return{left:t.clientX,top:t.clientY}}function xs(t,e,n,r,i){if(-1==r)return!1;let s=t.state.doc.resolve(r);for(let r=s.depth+1;r>0;r--)if(t.someProp(e,(e=>r>s.depth?e(t,n,s.nodeAfter,s.before(r),i,!0):e(t,n,s.node(r),s.before(r),i,!1))))return!0;return!1}function ks(t,e,n){t.focused||t.focus();let r=t.state.tr.setSelection(e);"pointer"==n&&r.setMeta("pointer",!0),t.dispatch(r)}function Ss(t,e,n,r,i){return xs(t,"handleClickOn",e,n,r)||t.someProp("handleClick",(n=>n(t,e,r)))||(i?function(t,e){if(-1==e)return!1;let n,r,i=t.state.selection;i instanceof Un&&(n=i.node);let s=t.state.doc.resolve(e);for(let t=s.depth+1;t>0;t--){let e=t>s.depth?s.nodeAfter:s.node(t);if(Un.isSelectable(e)){r=n&&i.$from.depth>0&&t>=i.$from.depth&&s.before(i.$from.depth+1)==i.$from.pos?s.before(i.$from.depth):s.before(t);break}}return null!=r&&(ks(t,Un.create(t.state.doc,r),"pointer"),!0)}(t,n):function(t,e){if(-1==e)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return!!(r&&r.isAtom&&Un.isSelectable(r))&&(ks(t,new Un(n),"pointer"),!0)}(t,n))}function Ms(t,e,n,r){return xs(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",(n=>n(t,e,r)))}function Os(t,e,n,r){return xs(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",(n=>n(t,e,r)))||function(t,e,n){if(0!=n.button)return!1;let r=t.state.doc;if(-1==e)return!!r.inlineContent&&(ks(t,qn.create(r,0,r.content.size),"pointer"),!0);let i=r.resolve(e);for(let e=i.depth+1;e>0;e--){let n=e>i.depth?i.nodeAfter:i.node(e),s=i.before(e);if(n.inlineContent)ks(t,qn.create(r,s+1,s+1+n.content.size),"pointer");else{if(!Un.isSelectable(n))continue;ks(t,Un.create(r,s),"pointer")}return!0}}(t,n,r)}function As(t){return Is(t)}ps.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=16==n.keyCode||n.shiftKey,!Ts(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!Pr||!$r||13!=n.keyCode))if(229!=n.keyCode&&t.domObserver.forceFlush(),!Br||13!=n.keyCode||n.ctrlKey||n.altKey||n.metaKey)t.someProp("handleKeyDown",(e=>e(t,n)))||Qi(t,n)?n.preventDefault():gs(t,"key");else{let e=Date.now();t.input.lastIOSEnter=e,t.input.lastIOSEnterFallbackTimeout=setTimeout((()=>{t.input.lastIOSEnter==e&&(t.someProp("handleKeyDown",(e=>e(t,xr(13,"Enter")))),t.input.lastIOSEnter=0)}),200)}},ps.keyup=(t,e)=>{16==e.keyCode&&(t.input.shiftKey=!1)},ps.keypress=(t,e)=>{let n=e;if(Ts(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Fr&&n.metaKey)return;if(t.someProp("handleKeyPress",(e=>e(t,n))))return void n.preventDefault();let r=t.state.selection;if(!(r instanceof qn&&r.$from.sameParent(r.$to))){let e=String.fromCharCode(n.charCode);t.someProp("handleTextInput",(n=>n(t,r.$from.pos,r.$to.pos,e)))||t.dispatch(t.state.tr.insertText(e).scrollIntoView()),n.preventDefault()}};const Es=Fr?"metaKey":"ctrlKey";us.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=As(t),i=Date.now(),s="singleClick";i-t.input.lastClick.time<500&&function(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}(n,t.input.lastClick)&&!n[Es]&&("singleClick"==t.input.lastClick.type?s="doubleClick":"doubleClick"==t.input.lastClick.type&&(s="tripleClick")),t.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:s};let o=t.posAtCoords(ws(n));o&&("singleClick"==s?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new Cs(t,o,n,!!r)):("doubleClick"==s?Ms:Os)(t,o.pos,o.inside,n)?n.preventDefault():gs(t,"pointer"))};class Cs{constructor(t,e,n,r){let i,s;if(this.view=t,this.pos=e,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=t.state.doc,this.selectNode=!!n[Es],this.allowDefault=n.shiftKey,e.inside>-1)i=t.state.doc.nodeAt(e.inside),s=e.inside;else{let n=t.state.doc.resolve(e.pos);i=n.parent,s=n.depth?n.before():0}const o=r?null:n.target,a=o?t.docView.nearestDesc(o,!0):null;this.target=a?a.dom:null;let{selection:l}=t.state;(0==n.button&&i.type.spec.draggable&&!1!==i.type.spec.selectable||l instanceof Un&&l.from<=s&&l.to>s)&&(this.mightDrag={node:i,pos:s,addAttr:!(!this.target||this.target.draggable),setUneditable:!(!this.target||!Nr||this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout((()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")}),20),this.view.domObserver.start()),t.root.addEventListener("mouseup",this.up=this.up.bind(this)),t.root.addEventListener("mousemove",this.move=this.move.bind(this)),gs(t,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout((()=>Di(this.view))),this.view.input.mouseDown=null}up(t){if(this.done(),!this.view.dom.contains(t.target))return;let e=this.pos;this.view.state.doc!=this.startDoc&&(e=this.view.posAtCoords(ws(t))),this.updateAllowDefault(t),this.allowDefault||!e?gs(this.view,"pointer"):Ss(this.view,e.pos,e.inside,t,this.selectNode)?t.preventDefault():0==t.button&&(this.flushed||Rr&&this.mightDrag&&!this.mightDrag.node.isAtom||$r&&!this.view.state.selection.visible&&Math.min(Math.abs(e.pos-this.view.state.selection.from),Math.abs(e.pos-this.view.state.selection.to))<=2)?(ks(this.view,_n.near(this.view.state.doc.resolve(e.pos)),"pointer"),t.preventDefault()):gs(this.view,"pointer")}move(t){this.updateAllowDefault(t),gs(this.view,"pointer"),0==t.buttons&&this.done()}updateAllowDefault(t){!this.allowDefault&&(Math.abs(this.event.x-t.clientX)>4||Math.abs(this.event.y-t.clientY)>4)&&(this.allowDefault=!0)}}function Ts(t,e){return!!t.composing||!!(Rr&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500)&&(t.input.compositionEndedAt=-2e8,!0)}us.touchstart=t=>{t.input.lastTouch=Date.now(),As(t),gs(t,"pointer")},us.touchmove=t=>{t.input.lastTouch=Date.now(),gs(t,"pointer")},us.contextmenu=t=>As(t);const Ns=Pr?5e3:-1;function Ds(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout((()=>Is(t)),e))}function $s(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=function(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function Is(t,e=!1){if(!(Pr&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),$s(t),e||t.docView&&t.docView.dirty){let e=Ti(t);return e&&!e.eq(t.state.selection)?t.dispatch(t.state.tr.setSelection(e)):t.updateState(t.state),!0}return!1}}ps.compositionstart=ps.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$from;if(e.selection.empty&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some((t=>!1===t.type.spec.inclusive))))t.markCursor=t.state.storedMarks||n.marks(),Is(t,!0),t.markCursor=null;else if(Is(t),Nr&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let e=t.domSelectionRange();for(let n=e.focusNode,r=e.focusOffset;n&&1==n.nodeType&&0!=r;){let e=r<0?n.lastChild:n.childNodes[r-1];if(!e)break;if(3==e.nodeType){t.domSelection().collapse(e,e.nodeValue.length);break}n=e,r=-1}}t.input.composing=!0}Ds(t,Ns)},ps.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,Ds(t,20))};const Rs=Cr&&Tr<15||Br&&Lr<604;function Bs(t,e,n,r){let i=es(t,e,n,t.input.shiftKey,t.state.selection.$from);if(t.someProp("handlePaste",(e=>e(t,r,i||ie.empty))))return!0;if(!i)return!1;let s=function(t){return 0==t.openStart&&0==t.openEnd&&1==t.content.childCount?t.content.firstChild:null}(i),o=s?t.state.tr.replaceSelectionWith(s,t.input.shiftKey):t.state.tr.replaceSelection(i);return t.dispatch(o.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}us.copy=ps.cut=(t,e)=>{let n=e,r=t.state.selection,i="cut"==n.type;if(r.empty)return;let s=Rs?null:n.clipboardData,o=r.content(),{dom:a,text:l}=ts(t,o);s?(n.preventDefault(),s.clearData(),s.setData("text/html",a.innerHTML),s.setData("text/plain",l)):function(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout((()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()}),50)}(t,a),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))},ps.paste=(t,e)=>{let n=e;if(t.composing&&!Pr)return;let r=Rs?null:n.clipboardData;r&&Bs(t,r.getData("text/plain"),r.getData("text/html"),n)?n.preventDefault():function(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus(),setTimeout((()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?Bs(t,r.value,null,e):Bs(t,r.textContent,r.innerHTML,e)}),50)}(t,n)};class Fs{constructor(t,e){this.slice=t,this.move=e}}const Ps=Fr?"altKey":"ctrlKey";us.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=t.state.selection,s=i.empty?null:t.posAtCoords(ws(n));if(s&&s.pos>=i.from&&s.pos<=(i instanceof Un?i.to-1:i.to));else if(r&&r.mightDrag)t.dispatch(t.state.tr.setSelection(Un.create(t.state.doc,r.mightDrag.pos)));else if(n.target&&1==n.target.nodeType){let e=t.docView.nearestDesc(n.target,!0);e&&e.node.type.spec.draggable&&e!=t.docView&&t.dispatch(t.state.tr.setSelection(Un.create(t.state.doc,e.posBefore)))}let o=t.state.selection.content(),{dom:a,text:l}=ts(t,o);n.dataTransfer.clearData(),n.dataTransfer.setData(Rs?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",Rs||n.dataTransfer.setData("text/plain",l),t.dragging=new Fs(o,!n[Ps])},us.dragend=t=>{let e=t.dragging;window.setTimeout((()=>{t.dragging==e&&(t.dragging=null)}),50)},ps.dragover=ps.dragenter=(t,e)=>e.preventDefault(),ps.drop=(t,e)=>{let n=e,r=t.dragging;if(t.dragging=null,!n.dataTransfer)return;let i=t.posAtCoords(ws(n));if(!i)return;let s=t.state.doc.resolve(i.pos),o=r&&r.slice;o?t.someProp("transformPasted",(t=>{o=t(o)})):o=es(t,n.dataTransfer.getData(Rs?"Text":"text/plain"),Rs?null:n.dataTransfer.getData("text/html"),!1,s);let a=!(!r||n[Ps]);if(t.someProp("handleDrop",(e=>e(t,n,o||ie.empty,a))))return void n.preventDefault();if(!o)return;n.preventDefault();let l=o?En(t.state.doc,s.pos,o):s.pos;null==l&&(l=s.pos);let c=t.state.tr;a&&c.deleteSelection();let h=c.mapping.map(l),d=0==o.openStart&&0==o.openEnd&&1==o.content.childCount,u=c.doc;if(d?c.replaceRangeWith(h,h,o.content.firstChild):c.replaceRange(h,h,o),c.doc.eq(u))return;let p=c.doc.resolve(h);if(d&&Un.isSelectable(o.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(o.content.firstChild))c.setSelection(new Un(p));else{let e=c.mapping.map(l);c.mapping.maps[c.mapping.maps.length-1].forEach(((t,n,r,i)=>e=i)),c.setSelection(Vi(t,p,c.doc.resolve(e)))}t.focus(),t.dispatch(c.setMeta("uiEvent","drop"))},us.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout((()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&Di(t)}),20))},us.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)},us.beforeinput=(t,e)=>{if($r&&Pr&&"deleteContentBackward"==e.inputType){t.domObserver.flushSoon();let{domChangeCount:e}=t.input;setTimeout((()=>{if(t.input.domChangeCount!=e)return;if(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",(e=>e(t,xr(8,"Backspace")))))return;let{$cursor:n}=t.state.selection;n&&n.pos>0&&t.dispatch(t.state.tr.delete(n.pos-1,n.pos).scrollIntoView())}),50)}};for(let t in ps)us[t]=ps[t];function Vs(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}class Ls{constructor(t,e){this.toDOM=t,this.spec=e||Ws,this.side=this.spec.side||0}map(t,e,n,r){let{pos:i,deleted:s}=t.mapResult(e.from+r,this.side<0?-1:1);return s?null:new _s(i-n,i-n,this)}valid(){return!0}eq(t){return this==t||t instanceof Ls&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&Vs(this.spec,t.spec))}destroy(t){this.spec.destroy&&this.spec.destroy(t)}}class zs{constructor(t,e){this.attrs=t,this.spec=e||Ws}map(t,e,n,r){let i=t.map(e.from+r,this.spec.inclusiveStart?-1:1)-n,s=t.map(e.to+r,this.spec.inclusiveEnd?1:-1)-n;return i>=s?null:new _s(i,s,this)}valid(t,e){return e.from<e.to}eq(t){return this==t||t instanceof zs&&Vs(this.attrs,t.attrs)&&Vs(this.spec,t.spec)}static is(t){return t.type instanceof zs}destroy(){}}class js{constructor(t,e){this.attrs=t,this.spec=e||Ws}map(t,e,n,r){let i=t.mapResult(e.from+r,1);if(i.deleted)return null;let s=t.mapResult(e.to+r,-1);return s.deleted||s.pos<=i.pos?null:new _s(i.pos-n,s.pos-n,this)}valid(t,e){let n,{index:r,offset:i}=t.content.findIndex(e.from);return i==e.from&&!(n=t.child(r)).isText&&i+n.nodeSize==e.to}eq(t){return this==t||t instanceof js&&Vs(this.attrs,t.attrs)&&Vs(this.spec,t.spec)}destroy(){}}class _s{constructor(t,e,n){this.from=t,this.to=e,this.type=n}copy(t,e){return new _s(t,e,this.type)}eq(t,e=0){return this.type.eq(t.type)&&this.from+e==t.from&&this.to+e==t.to}map(t,e,n){return this.type.map(t,this,e,n)}static widget(t,e,n){return new _s(t,t,new Ls(e,n))}static inline(t,e,n,r){return new _s(t,e,new zs(n,r))}static node(t,e,n,r){return new _s(t,e,new js(n,r))}get spec(){return this.type.spec}get inline(){return this.type instanceof zs}}const Ks=[],Ws={};class Hs{constructor(t,e){this.local=t.length?t:Ks,this.children=e.length?e:Ks}static create(t,e){return e.length?Xs(e,t,0,Ws):qs}find(t,e,n){let r=[];return this.findInner(null==t?0:t,null==e?1e9:e,r,0,n),r}findInner(t,e,n,r,i){for(let s=0;s<this.local.length;s++){let o=this.local[s];o.from<=e&&o.to>=t&&(!i||i(o.spec))&&n.push(o.copy(o.from+r,o.to+r))}for(let s=0;s<this.children.length;s+=3)if(this.children[s]<e&&this.children[s+1]>t){let o=this.children[s]+1;this.children[s+2].findInner(t-o,e-o,n,r+o,i)}}map(t,e,n){return this==qs||0==t.maps.length?this:this.mapInner(t,e,0,0,n||Ws)}mapInner(t,e,n,r,i){let s;for(let o=0;o<this.local.length;o++){let a=this.local[o].map(t,n,r);a&&a.type.valid(e,a)?(s||(s=[])).push(a):i.onRemove&&i.onRemove(this.local[o].spec)}return this.children.length?function(t,e,n,r,i,s,o){let a=t.slice();for(let t=0,e=s;t<n.maps.length;t++){let r=0;n.maps[t].forEach(((t,n,s,o)=>{let l=o-s-(n-t);for(let o=0;o<a.length;o+=3){let c=a[o+1];if(c<0||t>c+e-r)continue;let h=a[o]+e-r;n>=h?a[o+1]=t<=h?-2:-1:s>=i&&l&&(a[o]+=l,a[o+1]+=l)}r+=l})),e=n.maps[t].map(e,-1)}let l=!1;for(let e=0;e<a.length;e+=3)if(a[e+1]<0){if(-2==a[e+1]){l=!0,a[e+1]=-1;continue}let c=n.map(t[e]+s),h=c-i;if(h<0||h>=r.content.size){l=!0;continue}let d=n.map(t[e+1]+s,-1)-i,{index:u,offset:p}=r.content.findIndex(h),f=r.maybeChild(u);if(f&&p==h&&p+f.nodeSize==d){let r=a[e+2].mapInner(n,f,c+1,t[e]+s+1,o);r!=qs?(a[e]=h,a[e+1]=d,a[e+2]=r):(a[e+1]=-2,l=!0)}else l=!0}if(l){let l=function(t,e,n,r,i,s,o){function a(t,e){for(let s=0;s<t.local.length;s++){let a=t.local[s].map(r,i,e);a?n.push(a):o.onRemove&&o.onRemove(t.local[s].spec)}for(let n=0;n<t.children.length;n+=3)a(t.children[n+2],t.children[n]+e+1)}for(let n=0;n<t.length;n+=3)-1==t[n+1]&&a(t[n+2],e[n]+s+1);return n}(a,t,e,n,i,s,o),c=Xs(l,r,0,o);e=c.local;for(let t=0;t<a.length;t+=3)a[t+1]<0&&(a.splice(t,3),t-=3);for(let t=0,e=0;t<c.children.length;t+=3){let n=c.children[t];for(;e<a.length&&a[e]<n;)e+=3;a.splice(e,0,c.children[t],c.children[t+1],c.children[t+2])}}return new Hs(e.sort(Zs),a)}(this.children,s||[],t,e,n,r,i):s?new Hs(s.sort(Zs),Ks):qs}add(t,e){return e.length?this==qs?Hs.create(t,e):this.addInner(t,e,0):this}addInner(t,e,n){let r,i=0;t.forEach(((t,s)=>{let o,a=s+n;if(o=Gs(e,t,a)){for(r||(r=this.children.slice());i<r.length&&r[i]<s;)i+=3;r[i]==s?r[i+2]=r[i+2].addInner(t,o,a+1):r.splice(i,0,s,s+t.nodeSize,Xs(o,t,a+1,Ws)),i+=3}}));let s=Us(i?Ys(e):e,-n);for(let e=0;e<s.length;e++)s[e].type.valid(t,s[e])||s.splice(e--,1);return new Hs(s.length?this.local.concat(s).sort(Zs):this.local,r||this.children)}remove(t){return 0==t.length||this==qs?this:this.removeInner(t,0)}removeInner(t,e){let n=this.children,r=this.local;for(let r=0;r<n.length;r+=3){let i,s=n[r]+e,o=n[r+1]+e;for(let e,n=0;n<t.length;n++)(e=t[n])&&e.from>s&&e.to<o&&(t[n]=null,(i||(i=[])).push(e));if(!i)continue;n==this.children&&(n=this.children.slice());let a=n[r+2].removeInner(i,s+1);a!=qs?n[r+2]=a:(n.splice(r,3),r-=3)}if(r.length)for(let n,i=0;i<t.length;i++)if(n=t[i])for(let t=0;t<r.length;t++)r[t].eq(n,e)&&(r==this.local&&(r=this.local.slice()),r.splice(t--,1));return n==this.children&&r==this.local?this:r.length||n.length?new Hs(r,n):qs}forChild(t,e){if(this==qs)return this;if(e.isLeaf)return Hs.empty;let n,r;for(let e=0;e<this.children.length;e+=3)if(this.children[e]>=t){this.children[e]==t&&(n=this.children[e+2]);break}let i=t+1,s=i+e.content.size;for(let t=0;t<this.local.length;t++){let e=this.local[t];if(e.from<s&&e.to>i&&e.type instanceof zs){let t=Math.max(i,e.from)-i,n=Math.min(s,e.to)-i;t<n&&(r||(r=[])).push(e.copy(t,n))}}if(r){let t=new Hs(r.sort(Zs),Ks);return n?new Js([t,n]):t}return n||qs}eq(t){if(this==t)return!0;if(!(t instanceof Hs)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(let e=0;e<this.local.length;e++)if(!this.local[e].eq(t.local[e]))return!1;for(let e=0;e<this.children.length;e+=3)if(this.children[e]!=t.children[e]||this.children[e+1]!=t.children[e+1]||!this.children[e+2].eq(t.children[e+2]))return!1;return!0}locals(t){return Qs(this.localsInner(t))}localsInner(t){if(this==qs)return Ks;if(t.inlineContent||!this.local.some(zs.is))return this.local;let e=[];for(let t=0;t<this.local.length;t++)this.local[t].type instanceof zs||e.push(this.local[t]);return e}}Hs.empty=new Hs([],[]),Hs.removeOverlap=Qs;const qs=Hs.empty;class Js{constructor(t){this.members=t}map(t,e){const n=this.members.map((n=>n.map(t,e,Ws)));return Js.from(n)}forChild(t,e){if(e.isLeaf)return Hs.empty;let n=[];for(let r=0;r<this.members.length;r++){let i=this.members[r].forChild(t,e);i!=qs&&(i instanceof Js?n=n.concat(i.members):n.push(i))}return Js.from(n)}eq(t){if(!(t instanceof Js)||t.members.length!=this.members.length)return!1;for(let e=0;e<this.members.length;e++)if(!this.members[e].eq(t.members[e]))return!1;return!0}locals(t){let e,n=!0;for(let r=0;r<this.members.length;r++){let i=this.members[r].localsInner(t);if(i.length)if(e){n&&(e=e.slice(),n=!1);for(let t=0;t<i.length;t++)e.push(i[t])}else e=i}return e?Qs(n?e:e.sort(Zs)):Ks}static from(t){switch(t.length){case 0:return qs;case 1:return t[0];default:return new Js(t)}}}function Us(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let i=t[r];n.push(new _s(i.from+e,i.to+e,i.type))}return n}function Gs(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,i=null;for(let e,s=0;s<t.length;s++)(e=t[s])&&e.from>n&&e.to<r&&((i||(i=[])).push(e),t[s]=null);return i}function Ys(t){let e=[];for(let n=0;n<t.length;n++)null!=t[n]&&e.push(t[n]);return e}function Xs(t,e,n,r){let i=[],s=!1;e.forEach(((e,o)=>{let a=Gs(t,e,o+n);if(a){s=!0;let t=Xs(a,e,n+o+1,r);t!=qs&&i.push(o,o+e.nodeSize,t)}}));let o=Us(s?Ys(t):t,-n).sort(Zs);for(let t=0;t<o.length;t++)o[t].type.valid(e,o[t])||(r.onRemove&&r.onRemove(o[t].spec),o.splice(t--,1));return o.length||i.length?new Hs(o,i):qs}function Zs(t,e){return t.from-e.from||t.to-e.to}function Qs(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let i=n+1;i<e.length;i++){let s=e[i];if(s.from!=r.from){s.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,s.from),to(e,i,r.copy(s.from,r.to)));break}s.to!=r.to&&(e==t&&(e=t.slice()),e[i]=s.copy(s.from,r.to),to(e,i+1,s.copy(r.to,s.to)))}}return e}function to(t,e,n){for(;e<t.length&&Zs(n,t[e])>0;)e++;t.splice(e,0,n)}function eo(t){let e=[];return t.someProp("decorations",(n=>{let r=n(t.state);r&&r!=qs&&e.push(r)})),t.cursorWrapper&&e.push(Hs.create(t.state.doc,[t.cursorWrapper.deco])),Js.from(e)}const no={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},ro=Cr&&Tr<=11;class io{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(t){this.anchorNode=t.anchorNode,this.anchorOffset=t.anchorOffset,this.focusNode=t.focusNode,this.focusOffset=t.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(t){return t.anchorNode==this.anchorNode&&t.anchorOffset==this.anchorOffset&&t.focusNode==this.focusNode&&t.focusOffset==this.focusOffset}}class so{constructor(t,e){this.view=t,this.handleDOMChange=e,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new io,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.observer=window.MutationObserver&&new window.MutationObserver((t=>{for(let e=0;e<t.length;e++)this.queue.push(t[e]);Cr&&Tr<=11&&t.some((t=>"childList"==t.type&&t.removedNodes.length||"characterData"==t.type&&t.oldValue.length>t.target.nodeValue.length))?this.flushSoon():this.flush()})),ro&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout((()=>{this.flushingSoon=-1,this.flush()}),20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,no)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let t=this.observer.takeRecords();if(t.length){for(let e=0;e<t.length;e++)this.queue.push(t[e]);window.setTimeout((()=>this.flush()),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout((()=>this.suppressingSelectionUpdates=!1),50)}onSelectionChange(){if(Li(this.view)){if(this.suppressingSelectionUpdates)return Di(this.view);if(Cr&&Tr<=11&&!this.view.state.selection.empty){let t=this.view.domSelectionRange();if(t.focusNode&&mr(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(t){if(!t.focusNode)return!0;let e,n=new Set;for(let e=t.focusNode;e;e=ur(e))n.add(e);for(let r=t.anchorNode;r;r=ur(r))if(n.has(r)){e=r;break}let r=e&&this.view.docView.nearestDesc(e);return r&&r.ignoreMutation({type:"selection",target:3==e.nodeType?e.parentNode:e})?(this.setCurSelection(),!0):void 0}flush(){let{view:t}=this;if(!t.docView||this.flushingSoon>-1)return;let e=this.observer?this.observer.takeRecords():[];this.queue.length&&(e=this.queue.concat(e),this.queue.length=0);let n=t.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&Li(t)&&!this.ignoreSelectionChange(n),i=-1,s=-1,o=!1,a=[];if(t.editable)for(let t=0;t<e.length;t++){let n=this.registerMutation(e[t],a);n&&(i=i<0?n.from:Math.min(n.from,i),s=s<0?n.to:Math.max(n.to,s),n.typeOver&&(o=!0))}if(Nr&&a.length>1){let t=a.filter((t=>"BR"==t.nodeName));if(2==t.length){let e=t[0],n=t[1];e.parentNode&&e.parentNode.parentNode==n.parentNode?n.remove():e.remove()}}let l=null;i<0&&r&&t.input.lastFocus>Date.now()-200&&t.input.lastTouch<Date.now()-300&&wr(n)&&(l=Ti(t))&&l.eq(_n.near(t.state.doc.resolve(0),1))?(t.input.lastFocus=0,Di(t),this.currentSelection.set(n),t.scrollToSelection()):(i>-1||r)&&(i>-1&&(t.docView.markDirty(i,s),function(t){if(oo.has(t))return;if(oo.set(t,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)){if(t.requiresGeckoHackNode=Nr,ao)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),ao=!0}}(t)),this.handleDOMChange(i,s,o,a),t.docView&&t.docView.dirty?t.updateState(t.state):this.currentSelection.eq(n)||Di(t),this.currentSelection.set(n))}registerMutation(t,e){if(e.indexOf(t.target)>-1)return null;let n=this.view.docView.nearestDesc(t.target);if("attributes"==t.type&&(n==this.view.docView||"contenteditable"==t.attributeName||"style"==t.attributeName&&!t.oldValue&&!t.target.getAttribute("style")))return null;if(!n||n.ignoreMutation(t))return null;if("childList"==t.type){for(let n=0;n<t.addedNodes.length;n++)e.push(t.addedNodes[n]);if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(t.target))return{from:n.posBefore,to:n.posAfter};let r=t.previousSibling,i=t.nextSibling;if(Cr&&Tr<=11&&t.addedNodes.length)for(let e=0;e<t.addedNodes.length;e++){let{previousSibling:n,nextSibling:s}=t.addedNodes[e];(!n||Array.prototype.indexOf.call(t.addedNodes,n)<0)&&(r=n),(!s||Array.prototype.indexOf.call(t.addedNodes,s)<0)&&(i=s)}let s=r&&r.parentNode==t.target?dr(r)+1:0,o=n.localPosFromDOM(t.target,s,-1),a=i&&i.parentNode==t.target?dr(i):t.target.childNodes.length;return{from:o,to:n.localPosFromDOM(t.target,a,1)}}return"attributes"==t.type?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:{from:n.posAtStart,to:n.posAtEnd,typeOver:t.target.nodeValue==t.oldValue}}}let oo=new WeakMap,ao=!1;function lo(t){let e=t.pmViewDesc;if(e)return e.parseRule();if("BR"==t.nodeName&&t.parentNode){if(Rr&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}if(t.parentNode.lastChild==t||Rr&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if("IMG"==t.nodeName&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}function co(t,e,n,r,i){if(e<0){let e=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,n=Ti(t,e);if(n&&!t.state.selection.eq(n)){let r=t.state.tr.setSelection(n);"pointer"==e?r.setMeta("pointer",!0):"key"==e&&r.scrollIntoView(),t.dispatch(r)}return}let s=t.state.doc.resolve(e),o=s.sharedDepth(n);e=s.before(o+1),n=t.state.doc.resolve(n).after(o+1);let a,l,c=t.state.selection,h=function(t,e,n){let r,{node:i,fromOffset:s,toOffset:o,from:a,to:l}=t.docView.parseRange(e,n),c=t.domSelectionRange(),h=c.anchorNode;if(h&&t.dom.contains(1==h.nodeType?h:h.parentNode)&&(r=[{node:h,offset:c.anchorOffset}],wr(c)||r.push({node:c.focusNode,offset:c.focusOffset})),$r&&8===t.input.lastKeyCode)for(let t=o;t>s;t--){let e=i.childNodes[t-1],n=e.pmViewDesc;if("BR"==e.nodeName&&!n){o=t;break}if(!n||n.size)break}let d=t.state.doc,u=t.someProp("domParser")||_e.fromSchema(t.state.schema),p=d.resolve(a),f=null,m=u.parse(i,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:s,to:o,preserveWhitespace:"pre"!=p.parent.type.whitespace||"full",findPositions:r,ruleFromNode:lo,context:p});if(r&&null!=r[0].pos){let t=r[0].pos,e=r[1]&&r[1].pos;null==e&&(e=t),f={anchor:t+a,head:e+a}}return{doc:m,sel:f,from:a,to:l}}(t,e,n),d=t.state.doc,u=d.slice(h.from,h.to);8===t.input.lastKeyCode&&Date.now()-100<t.input.lastKeyCodeTime?(a=t.state.selection.to,l="end"):(a=t.state.selection.from,l="start"),t.input.lastKeyCode=null;let p=function(t,e,n,r,i){let s=t.findDiffStart(e,n);if(null==s)return null;let{a:o,b:a}=t.findDiffEnd(e,n+t.size,n+e.size);if("end"==i){r-=o+Math.max(0,s-Math.min(o,a))-s}if(o<s&&t.size<e.size){s-=r<=s&&r>=o?s-r:0,a=s+(a-o),o=s}else if(a<s){s-=r<=s&&r>=a?s-r:0,o=s+(o-a),a=s}return{start:s,endA:o,endB:a}}(u.content,h.doc.content,h.from,a,l);if((Br&&t.input.lastIOSEnter>Date.now()-225||Pr)&&i.some((t=>"DIV"==t.nodeName||"P"==t.nodeName))&&(!p||p.endA>=p.endB)&&t.someProp("handleKeyDown",(e=>e(t,xr(13,"Enter")))))return void(t.input.lastIOSEnter=0);if(!p){if(!(r&&c instanceof qn&&!c.empty&&c.$head.sameParent(c.$anchor))||t.composing||h.sel&&h.sel.anchor!=h.sel.head){if(h.sel){let e=ho(t,t.state.doc,h.sel);e&&!e.eq(t.state.selection)&&t.dispatch(t.state.tr.setSelection(e))}return}p={start:c.from,endA:c.to,endB:c.to}}if($r&&t.cursorWrapper&&h.sel&&h.sel.anchor==t.cursorWrapper.deco.from&&h.sel.head==h.sel.anchor){let t=p.endB-p.start;h.sel={anchor:h.sel.anchor+t,head:h.sel.anchor+t}}t.input.domChangeCount++,t.state.selection.from<t.state.selection.to&&p.start==p.endB&&t.state.selection instanceof qn&&(p.start>t.state.selection.from&&p.start<=t.state.selection.from+2&&t.state.selection.from>=h.from?p.start=t.state.selection.from:p.endA<t.state.selection.to&&p.endA>=t.state.selection.to-2&&t.state.selection.to<=h.to&&(p.endB+=t.state.selection.to-p.endA,p.endA=t.state.selection.to)),Cr&&Tr<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>h.from&&"  "==h.doc.textBetween(p.start-h.from-1,p.start-h.from+1)&&(p.start--,p.endA--,p.endB--);let f,m=h.doc.resolveNoCache(p.start-h.from),g=h.doc.resolveNoCache(p.endB-h.from),y=d.resolve(p.start),v=m.sameParent(g)&&m.parent.inlineContent&&y.end()>=p.endA;if((Br&&t.input.lastIOSEnter>Date.now()-225&&(!v||i.some((t=>"DIV"==t.nodeName||"P"==t.nodeName)))||!v&&m.pos<h.doc.content.size&&(f=_n.findFrom(h.doc.resolve(m.pos+1),1,!0))&&f.head==g.pos)&&t.someProp("handleKeyDown",(e=>e(t,xr(13,"Enter")))))return void(t.input.lastIOSEnter=0);if(t.state.selection.anchor>p.start&&function(t,e,n,r,i){if(!r.parent.isTextblock||n-e<=i.pos-r.pos||uo(r,!0,!1)<i.pos)return!1;let s=t.resolve(e);if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let o=t.resolve(uo(s,!0,!0));return!(!o.parent.isTextblock||o.pos>n||uo(o,!0,!1)<n)&&r.parent.content.cut(r.parentOffset).eq(o.parent.content)}(d,p.start,p.endA,m,g)&&t.someProp("handleKeyDown",(e=>e(t,xr(8,"Backspace")))))return void(Pr&&$r&&t.domObserver.suppressSelectionUpdates());$r&&Pr&&p.endB==p.start&&(t.input.lastAndroidDelete=Date.now()),Pr&&!v&&m.start()!=g.start()&&0==g.parentOffset&&m.depth==g.depth&&h.sel&&h.sel.anchor==h.sel.head&&h.sel.head==p.endA&&(p.endB-=2,g=h.doc.resolveNoCache(p.endB-h.from),setTimeout((()=>{t.someProp("handleKeyDown",(function(e){return e(t,xr(13,"Enter"))}))}),20));let b,w,x,k=p.start,S=p.endA;if(v)if(m.pos==g.pos)Cr&&Tr<=11&&0==m.parentOffset&&(t.domObserver.suppressSelectionUpdates(),setTimeout((()=>Di(t)),20)),b=t.state.tr.delete(k,S),w=d.resolve(p.start).marksAcross(d.resolve(p.endA));else if(p.endA==p.endB&&(x=function(t,e){let n,r,i,s=t.firstChild.marks,o=e.firstChild.marks,a=s,l=o;for(let t=0;t<o.length;t++)a=o[t].removeFromSet(a);for(let t=0;t<s.length;t++)l=s[t].removeFromSet(l);if(1==a.length&&0==l.length)r=a[0],n="add",i=t=>t.mark(r.addToSet(t.marks));else{if(0!=a.length||1!=l.length)return null;r=l[0],n="remove",i=t=>t.mark(r.removeFromSet(t.marks))}let c=[];for(let t=0;t<e.childCount;t++)c.push(i(e.child(t)));if(Zt.from(c).eq(t))return{mark:r,type:n}}(m.parent.content.cut(m.parentOffset,g.parentOffset),y.parent.content.cut(y.parentOffset,p.endA-y.start()))))b=t.state.tr,"add"==x.type?b.addMark(k,S,x.mark):b.removeMark(k,S,x.mark);else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let e=m.parent.textBetween(m.parentOffset,g.parentOffset);if(t.someProp("handleTextInput",(n=>n(t,k,S,e))))return;b=t.state.tr.insertText(e,k,S)}if(b||(b=t.state.tr.replace(k,S,h.doc.slice(p.start-h.from,p.endB-h.from))),h.sel){let e=ho(t,b.doc,h.sel);e&&!($r&&Pr&&t.composing&&e.empty&&(p.start!=p.endB||t.input.lastAndroidDelete<Date.now()-100)&&(e.head==k||e.head==b.mapping.map(S)-1)||Cr&&e.empty&&e.head==k)&&b.setSelection(e)}w&&b.ensureMarks(w),t.dispatch(b.scrollIntoView())}function ho(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:Vi(t,e.resolve(n.anchor),e.resolve(n.head))}function uo(t,e,n){let r=t.depth,i=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,i++,e=!1;if(n){let e=t.node(r).maybeChild(t.indexAfter(r));for(;e&&!e.isLeaf;)e=e.firstChild,i++}return i}class po{constructor(t,e){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new ms,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=e,this.state=e.state,this.directPlugins=e.plugins||[],this.directPlugins.forEach(vo),this.dispatch=this.dispatch.bind(this),this.dom=t&&t.mount||document.createElement("div"),t&&(t.appendChild?t.appendChild(this.dom):"function"==typeof t?t(this.dom):t.mount&&(this.mounted=!0)),this.editable=go(this),mo(this),this.nodeViews=yo(this),this.docView=pi(this.state.doc,fo(this),eo(this),this.dom,this),this.domObserver=new so(this,((t,e,n,r)=>co(this,t,e,n,r))),this.domObserver.start(),function(t){for(let e in us){let n=us[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=e=>{!bs(t,e)||vs(t,e)||!t.editable&&e.type in ps||n(t,e)},fs[e]?{passive:!0}:void 0)}Rr&&t.dom.addEventListener("input",(()=>null)),ys(t)}(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let t=this._props;this._props={};for(let e in t)this._props[e]=t[e];this._props.state=this.state}return this._props}update(t){t.handleDOMEvents!=this._props.handleDOMEvents&&ys(this);let e=this._props;this._props=t,t.plugins&&(t.plugins.forEach(vo),this.directPlugins=t.plugins),this.updateStateInner(t.state,e)}setProps(t){let e={};for(let t in this._props)e[t]=this._props[t];e.state=this.state;for(let n in t)e[n]=t[n];this.update(e)}updateState(t){this.updateStateInner(t,this._props)}updateStateInner(t,e){let n=this.state,r=!1,i=!1;t.storedMarks&&this.composing&&($s(this),i=!0),this.state=t;let s=n.plugins!=t.plugins||this._props.plugins!=e.plugins;if(s||this._props.plugins!=e.plugins||this._props.nodeViews!=e.nodeViews){let t=yo(this);(function(t,e){let n=0,r=0;for(let r in t){if(t[r]!=e[r])return!0;n++}for(let t in e)r++;return n!=r})(t,this.nodeViews)&&(this.nodeViews=t,r=!0)}(s||e.handleDOMEvents!=this._props.handleDOMEvents)&&ys(this),this.editable=go(this),mo(this);let o=eo(this),a=fo(this),l=n.plugins==t.plugins||n.doc.eq(t.doc)?t.scrollToSelection>n.scrollToSelection?"to selection":"preserve":"reset",c=r||!this.docView.matchesNode(t.doc,a,o);!c&&t.selection.eq(n.selection)||(i=!0);let h="preserve"==l&&i&&null==this.dom.style.overflowAnchor&&function(t){let e,n,r=t.dom.getBoundingClientRect(),i=Math.max(0,r.top);for(let s=(r.left+r.right)/2,o=i+1;o<Math.min(innerHeight,r.bottom);o+=5){let r=t.root.elementFromPoint(s,o);if(!r||r==t.dom||!t.dom.contains(r))continue;let a=r.getBoundingClientRect();if(a.top>=i-20){e=r,n=a.top;break}}return{refDOM:e,refTop:n,stack:Wr(t.dom)}}(this);if(i){this.domObserver.stop();let e=c&&(Cr||$r)&&!this.composing&&!n.selection.empty&&!t.selection.empty&&function(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}(n.selection,t.selection);if(c){let n=$r?this.trackWrites=this.domSelectionRange().focusNode:null;!r&&this.docView.update(t.doc,a,o,this)||(this.docView.updateOuterDeco([]),this.docView.destroy(),this.docView=pi(t.doc,a,o,this.dom,this)),n&&!this.trackWrites&&(e=!0)}e||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&function(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return mr(e.node,e.offset,n.anchorNode,n.anchorOffset)}(this))?Di(this,e):(Fi(this,t.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(n),"reset"==l?this.dom.scrollTop=0:"to selection"==l?this.scrollToSelection():h&&function({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;Hr(n,0==r?0:r-e)}(h)}scrollToSelection(){let t=this.domSelectionRange().focusNode;if(this.someProp("handleScrollToSelection",(t=>t(this))));else if(this.state.selection instanceof Un){let e=this.docView.domAfterPos(this.state.selection.from);1==e.nodeType&&Kr(this,e.getBoundingClientRect(),t)}else Kr(this,this.coordsAtPos(this.state.selection.head,1),t)}destroyPluginViews(){let t;for(;t=this.pluginViews.pop();)t.destroy&&t.destroy()}updatePluginViews(t){if(t&&t.plugins==this.state.plugins&&this.directPlugins==this.prevDirectPlugins)for(let e=0;e<this.pluginViews.length;e++){let n=this.pluginViews[e];n.update&&n.update(this,t)}else{this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let e=this.directPlugins[t];e.spec.view&&this.pluginViews.push(e.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let e=this.state.plugins[t];e.spec.view&&this.pluginViews.push(e.spec.view(this))}}}someProp(t,e){let n,r=this._props&&this._props[t];if(null!=r&&(n=e?e(r):r))return n;for(let r=0;r<this.directPlugins.length;r++){let i=this.directPlugins[r].props[t];if(null!=i&&(n=e?e(i):i))return n}let i=this.state.plugins;if(i)for(let r=0;r<i.length;r++){let s=i[r].props[t];if(null!=s&&(n=e?e(s):s))return n}}hasFocus(){if(Cr){let t=this.root.activeElement;if(t==this.dom)return!0;if(!t||!this.dom.contains(t))return!1;for(;t&&this.dom!=t&&this.dom.contains(t);){if("false"==t.contentEditable)return!1;t=t.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&function(t){if(t.setActive)return t.setActive();if(qr)return t.focus(qr);let e=Wr(t);t.focus(null==qr?{get preventScroll(){return qr={preventScroll:!0},!0}}:void 0),qr||(qr=!1,Hr(e,0))}(this.dom),Di(this),this.domObserver.start()}get root(){let t=this._root;if(null==t)for(let t=this.dom.parentNode;t;t=t.parentNode)if(9==t.nodeType||11==t.nodeType&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t;return t||document}posAtCoords(t){return Yr(this,t)}coordsAtPos(t,e=1){return Qr(this,t,e)}domAtPos(t,e=0){return this.docView.domFromPos(t,e)}nodeDOM(t){let e=this.docView.descAt(t);return e?e.nodeDOM:null}posAtDOM(t,e,n=-1){let r=this.docView.posFromDOM(t,e,n);if(null==r)throw new RangeError("DOM position not inside the editor");return r}endOfTextblock(t,e){return ai(this,e||this.state,t)}destroy(){this.docView&&(!function(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],eo(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null)}get isDestroyed(){return null==this.docView}dispatchEvent(t){return function(t,e){vs(t,e)||!us[e.type]||!t.editable&&e.type in ps||us[e.type](t,e)}(this,t)}dispatch(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))}domSelectionRange(){return Rr&&11===this.root.nodeType&&function(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}(this.dom.ownerDocument)==this.dom?function(t){let e;function n(t){t.preventDefault(),t.stopImmediatePropagation(),e=t.getTargetRanges()[0]}t.dom.addEventListener("beforeinput",n,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",n,!0);let r=e.startContainer,i=e.startOffset,s=e.endContainer,o=e.endOffset,a=t.domAtPos(t.state.selection.anchor);return mr(a.node,a.offset,s,o)&&([r,i,s,o]=[s,o,r,i]),{anchorNode:r,anchorOffset:i,focusNode:s,focusOffset:o}}(this):this.domSelection()}domSelection(){return this.root.getSelection()}}function fo(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),e.translate="no",t.someProp("attributes",(n=>{if("function"==typeof n&&(n=n(t.state)),n)for(let t in n)"class"==t&&(e.class+=" "+n[t]),"style"==t?e.style=(e.style?e.style+";":"")+n[t]:e[t]||"contenteditable"==t||"nodeName"==t||(e[t]=String(n[t]))})),[_s.node(0,t.state.doc.content.size,e)]}function mo(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:_s.widget(t.state.selection.head,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function go(t){return!t.someProp("editable",(e=>!1===e(t.state)))}function yo(t){let e=Object.create(null);function n(t){for(let n in t)Object.prototype.hasOwnProperty.call(e,n)||(e[n]=t[n])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function vo(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var bo={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},wo={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},xo="undefined"!=typeof navigator&&/Chrome\/(\d+)/.exec(navigator.userAgent);"undefined"!=typeof navigator&&/Gecko\/\d+/.test(navigator.userAgent);for(var ko="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),So="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Mo=ko||xo&&+xo[1]<57,Oo=0;Oo<10;Oo++)bo[48+Oo]=bo[96+Oo]=String(Oo);for(Oo=1;Oo<=24;Oo++)bo[Oo+111]="F"+Oo;for(Oo=65;Oo<=90;Oo++)bo[Oo]=String.fromCharCode(Oo+32),wo[Oo]=String.fromCharCode(Oo);for(var Ao in bo)wo.hasOwnProperty(Ao)||(wo[Ao]=bo[Ao]);const Eo="undefined"!=typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform);function Co(t){let e,n,r,i,s=t.split(/-(?!$)/),o=s[s.length-1];"Space"==o&&(o=" ");for(let t=0;t<s.length-1;t++){let o=s[t];if(/^(cmd|meta|m)$/i.test(o))i=!0;else if(/^a(lt)?$/i.test(o))e=!0;else if(/^(c|ctrl|control)$/i.test(o))n=!0;else if(/^s(hift)?$/i.test(o))r=!0;else{if(!/^mod$/i.test(o))throw new Error("Unrecognized modifier name: "+o);Eo?i=!0:n=!0}}return e&&(o="Alt-"+o),n&&(o="Ctrl-"+o),i&&(o="Meta-"+o),r&&(o="Shift-"+o),o}function To(t,e,n){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),!1!==n&&e.shiftKey&&(t="Shift-"+t),t}function No(t){let e=function(t){let e=Object.create(null);for(let n in t)e[Co(n)]=t[n];return e}(t);return function(t,n){let r,i=function(t){var e=!(Mo&&(t.ctrlKey||t.altKey||t.metaKey)||So&&t.shiftKey&&t.key&&1==t.key.length||"Unidentified"==t.key)&&t.key||(t.shiftKey?wo:bo)[t.keyCode]||t.key||"Unidentified";return"Esc"==e&&(e="Escape"),"Del"==e&&(e="Delete"),"Left"==e&&(e="ArrowLeft"),"Up"==e&&(e="ArrowUp"),"Right"==e&&(e="ArrowRight"),"Down"==e&&(e="ArrowDown"),e}(n),s=1==i.length&&" "!=i,o=e[To(i,n,!s)];if(o&&o(t.state,t.dispatch,t))return!0;if(s&&(n.shiftKey||n.altKey||n.metaKey||i.charCodeAt(0)>127)&&(r=bo[n.keyCode])&&r!=i){let i=e[To(r,n,!0)];if(i&&i(t.state,t.dispatch,t))return!0}else if(s&&n.shiftKey){let r=e[To(i,n,!0)];if(r&&r(t.state,t.dispatch,t))return!0}return!1}}function Do(t,e,n=!1){for(let r=t;r;r="start"==e?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&1!=r.childCount)return!1}return!1}function $o(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function Io(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){let n=t.node(e);if(t.index(e)+1<n.childCount)return t.doc.resolve(t.after(e+1));if(n.type.spec.isolating)break}return null}function Ro(t){for(let e=0;e<t.edgeCount;e++){let{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function Bo(t,e,n){let r,i,s=e.nodeBefore,o=e.nodeAfter;if(s.type.spec.isolating||o.type.spec.isolating)return!1;if(function(t,e,n){let r=e.nodeBefore,i=e.nodeAfter,s=e.index();return!(!(r&&i&&r.type.compatibleContent(i.type))||(!r.content.size&&e.parent.canReplace(s-1,s)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),0):!e.parent.canReplace(s,s+1)||!i.isTextblock&&!Mn(t.doc,e.pos)||(n&&n(t.tr.clearIncompatible(e.pos,r.type,r.contentMatchAt(r.childCount)).join(e.pos).scrollIntoView()),0)))}(t,e,n))return!0;let a=e.parent.canReplace(e.index(),e.index()+1);if(a&&(r=(i=s.contentMatchAt(s.childCount)).findWrapping(o.type))&&i.matchType(r[0]||o.type).validEnd){if(n){let i=e.pos+o.nodeSize,a=Zt.empty;for(let t=r.length-1;t>=0;t--)a=Zt.from(r[t].create(null,a));a=Zt.from(s.copy(a));let l=t.tr.step(new yn(e.pos-1,i,e.pos,i,new ie(a,1,0),r.length,!0)),c=i+2*r.length;Mn(l.doc,c)&&l.join(c),n(l.scrollIntoView())}return!0}let l=_n.findFrom(e,1),c=l&&l.$from.blockRange(l.$to),h=c&&wn(c);if(null!=h&&h>=e.depth)return n&&n(t.tr.lift(c,h).scrollIntoView()),!0;if(a&&Do(o,"start",!0)&&Do(s,"end")){let r=s,i=[];for(;i.push(r),!r.isTextblock;)r=r.lastChild;let a=o,l=1;for(;!a.isTextblock;a=a.firstChild)l++;if(r.canReplace(r.childCount,r.childCount,a.content)){if(n){let r=Zt.empty;for(let t=i.length-1;t>=0;t--)r=Zt.from(i[t].copy(r));n(t.tr.step(new yn(e.pos-i.length,e.pos+o.nodeSize,e.pos+l,e.pos+o.nodeSize-l,new ie(r,i.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function Fo(t){return function(e,n){let r=e.selection,i=t<0?r.$from:r.$to,s=i.depth;for(;i.node(s).isInline;){if(!s)return!1;s--}return!!i.node(s).isTextblock&&(n&&n(e.tr.setSelection(qn.create(e.doc,t<0?i.start(s):i.end(s)))),!0)}}const Po=Fo(-1),Vo=Fo(1);function Lo(t,e=null){return function(n,r){let i=!1;for(let r=0;r<n.selection.ranges.length&&!i;r++){let{$from:{pos:s},$to:{pos:o}}=n.selection.ranges[r];n.doc.nodesBetween(s,o,((r,s)=>{if(i)return!1;if(r.isTextblock&&!r.hasMarkup(t,e))if(r.type==t)i=!0;else{let e=n.doc.resolve(s),r=e.index();i=e.parent.canReplaceWith(r,r+1,t)}}))}if(!i)return!1;if(r){let i=n.tr;for(let r=0;r<n.selection.ranges.length;r++){let{$from:{pos:s},$to:{pos:o}}=n.selection.ranges[r];i.setBlockType(s,o,t,e)}r(i.scrollIntoView())}return!0}}function zo(t,e=null){return function(n,r){let{$from:i,$to:s}=n.selection,o=i.blockRange(s),a=!1,l=o;if(!o)return!1;if(o.depth>=2&&i.node(o.depth-1).type.compatibleContent(t)&&0==o.startIndex){if(0==i.index(o.depth-1))return!1;let t=n.doc.resolve(o.start-2);l=new we(t,t,o.depth),o.endIndex<o.parent.childCount&&(o=new we(i,n.doc.resolve(s.end(o.depth)),o.depth)),a=!0}let c=xn(l,t,e,o);return!!c&&(r&&r(function(t,e,n,r,i){let s=Zt.empty;for(let t=n.length-1;t>=0;t--)s=Zt.from(n[t].type.create(n[t].attrs,s));t.step(new yn(e.start-(r?2:0),e.end,e.start,e.end,new ie(s,0,0),n.length,!0));let o=0;for(let t=0;t<n.length;t++)n[t].type==i&&(o=t+1);let a=n.length-o,l=e.start+n.length-(r?2:0),c=e.parent;for(let n=e.startIndex,r=e.endIndex,i=!0;n<r;n++,i=!1)!i&&Sn(t.doc,l,a)&&(t.split(l,a),l+=2*a),l+=c.child(n).nodeSize;return t}(n.tr,o,c,a,t).scrollIntoView()),!0)}}function jo(t){return function(e,n){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,(e=>e.childCount>0&&e.firstChild.type==t));return!!s&&(!n||(r.node(s.depth-1).type==t?function(t,e,n,r){let i=t.tr,s=r.end,o=r.$to.end(r.depth);s<o&&(i.step(new yn(s-1,o,s,o,new ie(Zt.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new we(i.doc.resolve(r.$from.pos),i.doc.resolve(o),r.depth));const a=wn(r);if(null==a)return!1;i.lift(r,a);let l=i.mapping.map(s,-1)-1;Mn(i.doc,l)&&i.join(l);return e(i.scrollIntoView()),!0}(e,n,t,s):function(t,e,n){let r=t.tr,i=n.parent;for(let t=n.end,e=n.endIndex-1,s=n.startIndex;e>s;e--)t-=i.child(e).nodeSize,r.delete(t-1,t+1);let s=r.doc.resolve(n.start),o=s.nodeAfter;if(r.mapping.map(n.end)!=n.start+s.nodeAfter.nodeSize)return!1;let a=0==n.startIndex,l=n.endIndex==i.childCount,c=s.node(-1),h=s.index(-1);if(!c.canReplace(h+(a?0:1),h+1,o.content.append(l?Zt.empty:Zt.from(i))))return!1;let d=s.pos,u=d+o.nodeSize;return r.step(new yn(d-(a?1:0),u+(l?1:0),d+1,u-1,new ie((a?Zt.empty:Zt.from(i.copy(Zt.empty))).append(l?Zt.empty:Zt.from(i.copy(Zt.empty))),a?0:1,l?0:1),a?0:1)),e(r.scrollIntoView()),!0}(e,n,s)))}}function _o(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:i}=n,{storedMarks:s}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),filterTransaction:e.filterTransaction,plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return s},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,s=n.storedMarks,n}}}"undefined"!=typeof navigator?/Mac|iP(hone|[oa]d)/.test(navigator.platform):"undefined"!=typeof os&&os.platform&&os.platform();class Ko{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:e,state:n}=this,{view:r}=e,{tr:i}=n,s=this.buildProps(i);return Object.fromEntries(Object.entries(t).map((([t,e])=>[t,(...t)=>{const n=e(...t)(s);return i.getMeta("preventDispatch")||this.hasCustomState||r.dispatch(i),n}])))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:s}=r,o=[],a=!!t,l=t||i.tr,c={...Object.fromEntries(Object.entries(n).map((([t,n])=>[t,(...t)=>{const r=this.buildProps(l,e),i=n(...t)(r);return o.push(i),c}]))),run:()=>(a||!e||l.getMeta("preventDispatch")||this.hasCustomState||s.dispatch(l),o.every((t=>!0===t)))};return c}createCan(t){const{rawCommands:e,state:n}=this,r=t||n.tr,i=this.buildProps(r,false),s=Object.fromEntries(Object.entries(e).map((([t,e])=>[t,(...t)=>e(...t)({...i,dispatch:void 0})])));return{...s,chain:()=>this.createChain(r,false)}}buildProps(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:s}=r;i.storedMarks&&t.setStoredMarks(i.storedMarks);const o={tr:t,editor:r,view:s,state:_o({state:i,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map((([t,e])=>[t,(...t)=>e(...t)(o)])))}};return o}}function Wo(t,e,n){if(void 0===t.config[e]&&t.parent)return Wo(t.parent,e,n);if("function"==typeof t.config[e]){return t.config[e].bind({...n,parent:t.parent?Wo(t.parent,e,n):null})}return t.config[e]}function Ho(t){return{baseExtensions:t.filter((t=>"extension"===t.type)),nodeExtensions:t.filter((t=>"node"===t.type)),markExtensions:t.filter((t=>"mark"===t.type))}}function qo(t){const e=[],{nodeExtensions:n,markExtensions:r}=Ho(t),i=[...n,...r],s={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return t.forEach((t=>{const n=Wo(t,"addGlobalAttributes",{name:t.name,options:t.options,storage:t.storage});if(!n)return;n().forEach((t=>{t.types.forEach((n=>{Object.entries(t.attributes).forEach((([t,r])=>{e.push({type:n,name:t,attribute:{...s,...r}})}))}))}))})),i.forEach((t=>{const n={name:t.name,options:t.options,storage:t.storage},r=Wo(t,"addAttributes",n);if(!r)return;const i=r();Object.entries(i).forEach((([n,r])=>{const i={...s,...r};"function"==typeof(null==i?void 0:i.default)&&(i.default=i.default()),(null==i?void 0:i.isRequired)&&void 0===(null==i?void 0:i.default)&&delete i.default,e.push({type:t.name,name:n,attribute:i})}))})),e}function Jo(t,e){if("string"==typeof t){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}function Uo(...t){return t.filter((t=>!!t)).reduce(((t,e)=>{const n={...t};return Object.entries(e).forEach((([t,e])=>{n[t]?n[t]="class"===t?[n[t],e].join(" "):"style"===t?[n[t],e].join("; "):e:n[t]=e})),n}),{})}function Go(t,e){return e.filter((t=>t.attribute.rendered)).map((e=>e.attribute.renderHTML?e.attribute.renderHTML(t.attrs)||{}:{[e.name]:t.attrs[e.name]})).reduce(((t,e)=>Uo(t,e)),{})}function Yo(t){return"function"==typeof t}function Xo(t,e,...n){return Yo(t)?e?t.bind(e)(...n):t(...n):t}function Zo(t,e){return t.style?t:{...t,getAttrs:n=>{const r=t.getAttrs?t.getAttrs(n):t.attrs;if(!1===r)return!1;const i=e.reduce(((t,e)=>{const r=e.attribute.parseHTML?e.attribute.parseHTML(n):function(t){return"string"!=typeof t?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):"true"===t||"false"!==t&&t}(n.getAttribute(e.name));return null==r?t:{...t,[e.name]:r}}),{});return{...r,...i}}}}function Qo(t){return Object.fromEntries(Object.entries(t).filter((([t,e])=>("attrs"!==t||!function(t={}){return 0===Object.keys(t).length&&t.constructor===Object}(e))&&null!=e)))}function ta(t,e){return e.nodes[t]||e.marks[t]||null}function ea(t,e){return Array.isArray(e)?e.some((e=>("string"==typeof e?e:e.name)===t.name)):e}function na(t){return"[object RegExp]"===Object.prototype.toString.call(t)}function ra(t){var e;const{editor:n,from:r,to:i,text:s,rules:o,plugin:a}=t,{view:l}=n;if(l.composing)return!1;const c=l.state.doc.resolve(r);if(c.parent.type.spec.code||(null===(e=c.nodeBefore||c.nodeAfter)||void 0===e?void 0:e.marks.find((t=>t.type.spec.code))))return!1;let h=!1;const d=((t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,((t,e,i,s)=>{var o,a;const l=(null===(a=(o=t.type.spec).toText)||void 0===a?void 0:a.call(o,{node:t,pos:e,parent:i,index:s}))||t.textContent||"%leaf%";n+=l.slice(0,Math.max(0,r-e))})),n})(c)+s;return o.forEach((t=>{if(h)return;const e=((t,e)=>{if(na(e))return e.exec(t);const n=e(t);if(!n)return null;const r=[n.text];return r.index=n.index,r.input=t,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r})(d,t.find);if(!e)return;const o=l.state.tr,c=_o({state:l.state,transaction:o}),u={from:r-(e[0].length-s.length),to:i},{commands:p,chain:f,can:m}=new Ko({editor:n,state:c});null!==t.handler({state:c,range:u,match:e,commands:p,chain:f,can:m})&&o.steps.length&&(o.setMeta(a,{transform:o,from:r,to:i,text:s}),l.dispatch(o),h=!0)})),h}function ia(t){const{editor:e,rules:n}=t,r=new ar({state:{init:()=>null,apply(t,e){const n=t.getMeta(r);return n||(t.selectionSet||t.docChanged?null:e)}},props:{handleTextInput:(t,i,s,o)=>ra({editor:e,from:i,to:s,text:o,rules:n,plugin:r}),handleDOMEvents:{compositionend:t=>(setTimeout((()=>{const{$cursor:i}=t.state.selection;i&&ra({editor:e,from:i.pos,to:i.pos,text:"",rules:n,plugin:r})})),!1)},handleKeyDown(t,i){if("Enter"!==i.key)return!1;const{$cursor:s}=t.state.selection;return!!s&&ra({editor:e,from:s.pos,to:s.pos,text:"\n",rules:n,plugin:r})}},isInputRules:!0});return r}function sa(t){const{editor:e,state:n,from:r,to:i,rule:s}=t,{commands:o,chain:a,can:l}=new Ko({editor:e,state:n}),c=[];n.doc.nodesBetween(r,i,((t,e)=>{if(!t.isTextblock||t.type.spec.code)return;const h=Math.max(r,e),d=Math.min(i,e+t.content.size);((t,e)=>{if(na(e))return[...t.matchAll(e)];const n=e(t);return n?n.map((e=>{const n=[e.text];return n.index=e.index,n.input=t,n.data=e.data,e.replaceWith&&(e.text.includes(e.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),n.push(e.replaceWith)),n})):[]})(t.textBetween(h-e,d-e,void 0,""),s.find).forEach((t=>{if(void 0===t.index)return;const e=h+t.index+1,r=e+t[0].length,i={from:n.tr.mapping.map(e),to:n.tr.mapping.map(r)},d=s.handler({state:n,range:i,match:t,commands:o,chain:a,can:l});c.push(d)}))}));return c.every((t=>null!==t))}function oa(t){const{editor:e,rules:n}=t;let r=null,i=!1,s=!1;return n.map((t=>new ar({view(t){const e=e=>{var n;r=(null===(n=t.dom.parentElement)||void 0===n?void 0:n.contains(e.target))?t.dom.parentElement:null};return window.addEventListener("dragstart",e),{destroy(){window.removeEventListener("dragstart",e)}}},props:{handleDOMEvents:{drop:t=>(s=r===t.dom.parentElement,!1),paste:(t,e)=>{var n;const r=null===(n=e.clipboardData)||void 0===n?void 0:n.getData("text/html");return i=!!(null==r?void 0:r.includes("data-pm-slice")),!1}}},appendTransaction:(n,r,o)=>{const a=n[0],l="paste"===a.getMeta("uiEvent")&&!i,c="drop"===a.getMeta("uiEvent")&&!s;if(!l&&!c)return;const h=r.doc.content.findDiffStart(o.doc.content),d=r.doc.content.findDiffEnd(o.doc.content);if("number"!=typeof h||!d||h===d.b)return;const u=o.tr,p=_o({state:o,transaction:u});return sa({editor:e,state:p,from:Math.max(h-1,0),to:d.b-1,rule:t})&&u.steps.length?u:void 0}})))}class aa{constructor(t,e){this.splittableMarks=[],this.editor=e,this.extensions=aa.resolve(t),this.schema=function(t,e){var n;const r=qo(t),{nodeExtensions:i,markExtensions:s}=Ho(t),o=null===(n=i.find((t=>Wo(t,"topNode"))))||void 0===n?void 0:n.name,a=Object.fromEntries(i.map((n=>{const i=r.filter((t=>t.type===n.name)),s={name:n.name,options:n.options,storage:n.storage,editor:e},o=t.reduce(((t,e)=>{const r=Wo(e,"extendNodeSchema",s);return{...t,...r?r(n):{}}}),{}),a=Qo({...o,content:Xo(Wo(n,"content",s)),marks:Xo(Wo(n,"marks",s)),group:Xo(Wo(n,"group",s)),inline:Xo(Wo(n,"inline",s)),atom:Xo(Wo(n,"atom",s)),selectable:Xo(Wo(n,"selectable",s)),draggable:Xo(Wo(n,"draggable",s)),code:Xo(Wo(n,"code",s)),defining:Xo(Wo(n,"defining",s)),isolating:Xo(Wo(n,"isolating",s)),attrs:Object.fromEntries(i.map((t=>{var e;return[t.name,{default:null===(e=null==t?void 0:t.attribute)||void 0===e?void 0:e.default}]})))}),l=Xo(Wo(n,"parseHTML",s));l&&(a.parseDOM=l.map((t=>Zo(t,i))));const c=Wo(n,"renderHTML",s);c&&(a.toDOM=t=>c({node:t,HTMLAttributes:Go(t,i)}));const h=Wo(n,"renderText",s);return h&&(a.toText=h),[n.name,a]}))),l=Object.fromEntries(s.map((n=>{const i=r.filter((t=>t.type===n.name)),s={name:n.name,options:n.options,storage:n.storage,editor:e},o=t.reduce(((t,e)=>{const r=Wo(e,"extendMarkSchema",s);return{...t,...r?r(n):{}}}),{}),a=Qo({...o,inclusive:Xo(Wo(n,"inclusive",s)),excludes:Xo(Wo(n,"excludes",s)),group:Xo(Wo(n,"group",s)),spanning:Xo(Wo(n,"spanning",s)),code:Xo(Wo(n,"code",s)),attrs:Object.fromEntries(i.map((t=>{var e;return[t.name,{default:null===(e=null==t?void 0:t.attribute)||void 0===e?void 0:e.default}]})))}),l=Xo(Wo(n,"parseHTML",s));l&&(a.parseDOM=l.map((t=>Zo(t,i))));const c=Wo(n,"renderHTML",s);return c&&(a.toDOM=t=>c({mark:t,HTMLAttributes:Go(t,i)})),[n.name,a]})));return new ze({topNode:o,nodes:a,marks:l})}(this.extensions,e),this.extensions.forEach((t=>{var e;this.editor.extensionStorage[t.name]=t.storage;const n={name:t.name,options:t.options,storage:t.storage,editor:this.editor,type:ta(t.name,this.schema)};if("mark"===t.type){(null===(e=Xo(Wo(t,"keepOnSplit",n)))||void 0===e||e)&&this.splittableMarks.push(t.name)}const r=Wo(t,"onBeforeCreate",n);r&&this.editor.on("beforeCreate",r);const i=Wo(t,"onCreate",n);i&&this.editor.on("create",i);const s=Wo(t,"onUpdate",n);s&&this.editor.on("update",s);const o=Wo(t,"onSelectionUpdate",n);o&&this.editor.on("selectionUpdate",o);const a=Wo(t,"onTransaction",n);a&&this.editor.on("transaction",a);const l=Wo(t,"onFocus",n);l&&this.editor.on("focus",l);const c=Wo(t,"onBlur",n);c&&this.editor.on("blur",c);const h=Wo(t,"onDestroy",n);h&&this.editor.on("destroy",h)}))}static resolve(t){const e=aa.sort(aa.flatten(t)),n=function(t){const e=t.filter(((e,n)=>t.indexOf(e)!==n));return[...new Set(e)]}(e.map((t=>t.name)));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map((t=>`'${t}'`)).join(", ")}]. This can lead to issues.`),e}static flatten(t){return t.map((t=>{const e=Wo(t,"addExtensions",{name:t.name,options:t.options,storage:t.storage});return e?[t,...this.flatten(e())]:t})).flat(10)}static sort(t){return t.sort(((t,e)=>{const n=Wo(t,"priority")||100,r=Wo(e,"priority")||100;return n>r?-1:n<r?1:0}))}get commands(){return this.extensions.reduce(((t,e)=>{const n=Wo(e,"addCommands",{name:e.name,options:e.options,storage:e.storage,editor:this.editor,type:ta(e.name,this.schema)});return n?{...t,...n()}:t}),{})}get plugins(){const{editor:t}=this,e=aa.sort([...this.extensions].reverse()),n=[],r=[],i=e.map((e=>{const i={name:e.name,options:e.options,storage:e.storage,editor:t,type:ta(e.name,this.schema)},s=[],o=Wo(e,"addKeyboardShortcuts",i);let a={};if("mark"===e.type&&e.config.exitable&&(a.ArrowRight=()=>Ja.handleExit({editor:t,mark:e})),o){const e=Object.fromEntries(Object.entries(o()).map((([e,n])=>[e,()=>n({editor:t})])));a={...a,...e}}const l=new ar({props:{handleKeyDown:No(a)}});s.push(l);const c=Wo(e,"addInputRules",i);ea(e,t.options.enableInputRules)&&c&&n.push(...c());const h=Wo(e,"addPasteRules",i);ea(e,t.options.enablePasteRules)&&h&&r.push(...h());const d=Wo(e,"addProseMirrorPlugins",i);if(d){const t=d();s.push(...t)}return s})).flat();return[ia({editor:t,rules:n}),...oa({editor:t,rules:r}),...i]}get attributes(){return qo(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=Ho(this.extensions);return Object.fromEntries(e.filter((t=>!!Wo(t,"addNodeView"))).map((e=>{const n=this.attributes.filter((t=>t.type===e.name)),r={name:e.name,options:e.options,storage:e.storage,editor:t,type:Jo(e.name,this.schema)},i=Wo(e,"addNodeView",r);if(!i)return[];return[e.name,(r,s,o,a)=>{const l=Go(r,n);return i()({editor:t,node:r,getPos:o,decorations:a,HTMLAttributes:l,extension:e})}]})))}}function la(t){return"Object"===function(t){return Object.prototype.toString.call(t).slice(8,-1)}(t)&&(t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype)}function ca(t,e){const n={...t};return la(t)&&la(e)&&Object.keys(e).forEach((r=>{la(e[r])?r in t?n[r]=ca(t[r],e[r]):Object.assign(n,{[r]:e[r]}):Object.assign(n,{[r]:e[r]})})),n}class ha{constructor(t={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...t},this.name=this.config.name,t.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=Xo(Wo(this,"addOptions",{name:this.name}))),this.storage=Xo(Wo(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t={}){return new ha(t)}configure(t={}){const e=this.extend();return e.options=ca(this.options,t),e.storage=Xo(Wo(e,"addStorage",{name:e.name,options:e.options})),e}extend(t={}){const e=new ha(t);return e.parent=this,this.child=e,e.name=t.name?t.name:e.parent.name,t.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${e.name}".`),e.options=Xo(Wo(e,"addOptions",{name:e.name})),e.storage=Xo(Wo(e,"addStorage",{name:e.name,options:e.options})),e}}function da(t,e,n){const{from:r,to:i}=e,{blockSeparator:s="\n\n",textSerializers:o={}}=n||{};let a="",l=!0;return t.nodesBetween(r,i,((t,n,c,h)=>{var d;const u=null==o?void 0:o[t.type.name];u?(t.isBlock&&!l&&(a+=s,l=!0),c&&(a+=u({node:t,pos:n,parent:c,index:h,range:e}))):t.isText?(a+=null===(d=null==t?void 0:t.text)||void 0===d?void 0:d.slice(Math.max(r,n)-n,i-n),l=!1):t.isBlock&&!l&&(a+=s,l=!0)})),a}function ua(t){return Object.fromEntries(Object.entries(t.nodes).filter((([,t])=>t.spec.toText)).map((([t,e])=>[t,e.spec.toText])))}const pa=ha.create({name:"clipboardTextSerializer",addProseMirrorPlugins(){return[new ar({key:new hr("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:i}=e,{ranges:s}=i,o=Math.min(...s.map((t=>t.$from.pos))),a=Math.max(...s.map((t=>t.$to.pos)));return da(r,{from:o,to:a},{textSerializers:ua(n)})}}})]}});function fa(t,e,n={strict:!0}){const r=Object.keys(e);return!r.length||r.every((r=>n.strict?e[r]===t[r]:na(e[r])?e[r].test(t[r]):e[r]===t[r]))}function ma(t,e,n={}){return t.find((t=>t.type===e&&fa(t.attrs,n)))}function ga(t,e,n={}){return!!ma(t,e,n)}function ya(t,e,n={}){if(!t||!e)return;let r=t.parent.childAfter(t.parentOffset);if(t.parentOffset===r.offset&&0!==r.offset&&(r=t.parent.childBefore(t.parentOffset)),!r.node)return;const i=ma([...r.node.marks],e,n);if(!i)return;let s=r.index,o=t.start()+r.offset,a=s+1,l=o+r.node.nodeSize;for(ma([...r.node.marks],e,n);s>0&&i.isInSet(t.parent.child(s-1).marks);)s-=1,o-=t.parent.child(s).nodeSize;for(;a<t.parent.childCount&&ga([...t.parent.child(a).marks],e,n);)l+=t.parent.child(a).nodeSize,a+=1;return{from:o,to:l}}function va(t,e){if("string"==typeof t){if(!e.marks[t])throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`);return e.marks[t]}return t}function ba(t){return t instanceof qn}function wa(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function xa(t,e=null){if(!e)return null;const n=_n.atStart(t),r=_n.atEnd(t);if("start"===e||!0===e)return n;if("end"===e)return r;const i=n.from,s=r.to;return"all"===e?qn.create(t,wa(0,i,s),wa(t.content.size,i,s)):qn.create(t,wa(e,i,s),wa(e,i,s))}function ka(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function Sa(t){const e=`<body>${t}</body>`;return(new window.DOMParser).parseFromString(e,"text/html").body}function Ma(t,e,n){if(n={slice:!0,parseOptions:{},...n},"object"==typeof t&&null!==t)try{return Array.isArray(t)&&t.length>0?Zt.fromArray(t.map((t=>e.nodeFromJSON(t)))):e.nodeFromJSON(t)}catch(r){return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",r),Ma("",e,n)}if("string"==typeof t){const r=_e.fromSchema(e);return n.slice?r.parseSlice(Sa(t),n.parseOptions).content:r.parse(Sa(t),n.parseOptions)}return Ma("",e,n)}function Oa(){return"undefined"!=typeof navigator&&/Mac/.test(navigator.platform)}function Aa(t,e,n={}){const{from:r,to:i,empty:s}=t.selection,o=e?Jo(e,t.schema):null,a=[];t.doc.nodesBetween(r,i,((t,e)=>{if(t.isText)return;const n=Math.max(r,e),s=Math.min(i,e+t.nodeSize);a.push({node:t,from:n,to:s})}));const l=i-r,c=a.filter((t=>!o||o.name===t.node.type.name)).filter((t=>fa(t.node.attrs,n,{strict:!1})));if(s)return!!c.length;return c.reduce(((t,e)=>t+e.to-e.from),0)>=l}function Ea(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function Ca(t,e){const n="string"==typeof e?[e]:e;return Object.keys(t).reduce(((e,r)=>(n.includes(r)||(e[r]=t[r]),e)),{})}function Ta(t,e,n={}){return Ma(t,e,{slice:!1,parseOptions:n})}function Na(t){return e=>function(t,e){for(let n=t.depth;n>0;n-=1){const r=t.node(n);if(e(r))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:r}}}(e.$from,t)}function Da(t,e){const n=va(e,t.schema),{from:r,to:i,empty:s}=t.selection,o=[];s?(t.storedMarks&&o.push(...t.storedMarks),o.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,i,(t=>{o.push(...t.marks)}));const a=o.find((t=>t.type.name===n.name));return a?{...a.attrs}:{}}function $a(t,e){const n=Ea("string"==typeof e?e:e.name,t.schema);return"node"===n?function(t,e){const n=Jo(e,t.schema),{from:r,to:i}=t.selection,s=[];t.doc.nodesBetween(r,i,(t=>{s.push(t)}));const o=s.reverse().find((t=>t.type.name===n.name));return o?{...o.attrs}:{}}(t,e):"mark"===n?Da(t,e):{}}function Ia(t,e,n){return Object.fromEntries(Object.entries(n).filter((([n])=>{const r=t.find((t=>t.type===e&&t.name===n));return!!r&&r.attribute.keepOnSplit})))}function Ra(t,e,n={}){const{empty:r,ranges:i}=t.selection,s=e?va(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter((t=>!s||s.name===t.type.name)).find((t=>fa(t.attrs,n,{strict:!1})));let o=0;const a=[];if(i.forEach((({$from:e,$to:n})=>{const r=e.pos,i=n.pos;t.doc.nodesBetween(r,i,((t,e)=>{if(!t.isText&&!t.marks.length)return;const n=Math.max(r,e),s=Math.min(i,e+t.nodeSize);o+=s-n,a.push(...t.marks.map((t=>({mark:t,from:n,to:s}))))}))})),0===o)return!1;const l=a.filter((t=>!s||s.name===t.mark.type.name)).filter((t=>fa(t.mark.attrs,n,{strict:!1}))).reduce(((t,e)=>t+e.to-e.from),0),c=a.filter((t=>!s||t.mark.type!==s&&t.mark.type.excludes(s))).reduce(((t,e)=>t+e.to-e.from),0);return(l>0?l+c:l)>=o}function Ba(t,e){const{nodeExtensions:n}=Ho(e),r=n.find((e=>e.name===t));if(!r)return!1;const i=Xo(Wo(r,"group",{name:r.name,options:r.options,storage:r.storage}));return"string"==typeof i&&i.split(" ").includes("list")}function Fa(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const r=n.filter((t=>null==e?void 0:e.includes(t.type.name)));t.tr.ensureMarks(r)}}const Pa=(t,e)=>{const n=Na((t=>t.type===e))(t.selection);if(!n)return!0;const r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(void 0===r)return!0;const i=t.doc.nodeAt(r);return n.node.type!==(null==i?void 0:i.type)||!Mn(t.doc,n.pos)||(t.join(n.pos),!0)},Va=(t,e)=>{const n=Na((t=>t.type===e))(t.selection);if(!n)return!0;const r=t.doc.resolve(n.start).after(n.depth);if(void 0===r)return!0;const i=t.doc.nodeAt(r);return n.node.type!==(null==i?void 0:i.type)||!Mn(t.doc,r)||(t.join(r),!0)};var La=Object.freeze({__proto__:null,blur:()=>({editor:t,view:e})=>(requestAnimationFrame((()=>{var n;t.isDestroyed||(e.dom.blur(),null===(n=null===window||void 0===window?void 0:window.getSelection())||void 0===n||n.removeAllRanges())})),!0),clearContent:(t=!1)=>({commands:e})=>e.setContent("",t),clearNodes:()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:i}=r;return!n||(i.forEach((({$from:n,$to:r})=>{t.doc.nodesBetween(n.pos,r.pos,((t,n)=>{if(t.type.isText)return;const{doc:r,mapping:i}=e,s=r.resolve(i.map(n)),o=r.resolve(i.map(n+t.nodeSize)),a=s.blockRange(o);if(!a)return;const l=wn(a);if(t.type.isTextblock){const{defaultType:t}=s.parent.contentMatchAt(s.index());e.setNodeMarkup(a.start,t)}(l||0===l)&&e.lift(a,l)}))})),!0)},command:t=>e=>t(e),createParagraphNear:()=>({state:t,dispatch:e})=>((t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof Yn||r.parent.inlineContent||i.parent.inlineContent)return!1;let s=Ro(i.parent.contentMatchAt(i.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let n=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,o=t.tr.insert(n,s.createAndFill());o.setSelection(qn.create(o.doc,n+1)),e(o.scrollIntoView())}return!0})(t,e),deleteCurrentNode:()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const i=t.selection.$anchor;for(let n=i.depth;n>0;n-=1){if(i.node(n).type===r.type){if(e){const e=i.before(n),r=i.after(n);t.delete(e,r).scrollIntoView()}return!0}}return!1},deleteNode:t=>({tr:e,state:n,dispatch:r})=>{const i=Jo(t,n.schema),s=e.selection.$anchor;for(let t=s.depth;t>0;t-=1){if(s.node(t).type===i){if(r){const n=s.before(t),r=s.after(t);e.delete(n,r).scrollIntoView()}return!0}}return!1},deleteRange:t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;return n&&e.delete(r,i),!0},deleteSelection:()=>({state:t,dispatch:e})=>((t,e)=>!t.selection.empty&&(e&&e(t.tr.deleteSelection().scrollIntoView()),!0))(t,e),enter:()=>({commands:t})=>t.keyboardShortcut("Enter"),exitCode:()=>({state:t,dispatch:e})=>((t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),s=n.indexAfter(-1),o=Ro(i.contentMatchAt(s));if(!o||!i.canReplaceWith(s,s,o))return!1;if(e){let r=n.after(),i=t.tr.replaceWith(r,r,o.createAndFill());i.setSelection(_n.near(i.doc.resolve(r),1)),e(i.scrollIntoView())}return!0})(t,e),extendMarkRange:(t,e={})=>({tr:n,state:r,dispatch:i})=>{const s=va(t,r.schema),{doc:o,selection:a}=n,{$from:l,from:c,to:h}=a;if(i){const t=ya(l,s,e);if(t&&t.from<=c&&t.to>=h){const e=qn.create(o,t.from,t.to);n.setSelection(e)}}return!0},first:t=>e=>{const n="function"==typeof t?t(e):t;for(let t=0;t<n.length;t+=1)if(n[t](e))return!0;return!1},focus:(t=null,e={})=>({editor:n,view:r,tr:i,dispatch:s})=>{e={scrollIntoView:!0,...e};const o=()=>{ka()&&r.dom.focus(),requestAnimationFrame((()=>{n.isDestroyed||(r.focus(),(null==e?void 0:e.scrollIntoView)&&n.commands.scrollIntoView())}))};if(r.hasFocus()&&null===t||!1===t)return!0;if(s&&null===t&&!ba(n.state.selection))return o(),!0;const a=xa(i.doc,t)||n.state.selection,l=n.state.selection.eq(a);return s&&(l||i.setSelection(a),l&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},forEach:(t,e)=>n=>t.every(((t,r)=>e(t,{...n,index:r}))),insertContent:(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),insertContentAt:(t,e,n)=>({tr:r,dispatch:i,editor:s})=>{if(i){n={parseOptions:{},updateSelection:!0,...n};const i=Ma(e,s.schema,{parseOptions:{preserveWhitespace:"full",...n.parseOptions}});if("<>"===i.toString())return!0;let{from:o,to:a}="number"==typeof t?{from:t,to:t}:t,l=!0,c=!0;if((i.toString().startsWith("<")?i:[i]).forEach((t=>{t.check(),l=!!l&&(t.isText&&0===t.marks.length),c=!!c&&t.isBlock})),o===a&&c){const{parent:t}=r.doc.resolve(o);t.isTextblock&&!t.type.spec.code&&!t.childCount&&(o-=1,a+=1)}l?Array.isArray(e)?r.insertText(e.map((t=>t.text||"")).join(""),o,a):"object"==typeof e&&e&&e.text?r.insertText(e.text,o,a):r.insertText(e,o,a):r.replaceWith(o,a,i),n.updateSelection&&function(t,e,n){const r=t.steps.length-1;if(r<e)return;const i=t.steps[r];if(!(i instanceof gn||i instanceof yn))return;const s=t.mapping.maps[r];let o=0;s.forEach(((t,e,n,r)=>{0===o&&(o=r)})),t.setSelection(_n.near(t.doc.resolve(o),n))}(r,r.steps.length-1,-1)}return!0},joinUp:()=>({state:t,dispatch:e})=>((t,e)=>{let n,r=t.selection,i=r instanceof Un;if(i){if(r.node.isTextblock||!Mn(t.doc,r.from))return!1;n=r.from}else if(n=An(t.doc,r.from,-1),null==n)return!1;if(e){let r=t.tr.join(n);i&&r.setSelection(Un.create(r.doc,n-t.doc.resolve(n).nodeBefore.nodeSize)),e(r.scrollIntoView())}return!0})(t,e),joinDown:()=>({state:t,dispatch:e})=>((t,e)=>{let n,r=t.selection;if(r instanceof Un){if(r.node.isTextblock||!Mn(t.doc,r.to))return!1;n=r.to}else if(n=An(t.doc,r.to,1),null==n)return!1;return e&&e(t.tr.join(n).scrollIntoView()),!0})(t,e),joinBackward:()=>({state:t,dispatch:e})=>((t,e,n)=>{let r=function(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}(t,n);if(!r)return!1;let i=$o(r);if(!i){let n=r.blockRange(),i=n&&wn(n);return null!=i&&(e&&e(t.tr.lift(n,i).scrollIntoView()),!0)}let s=i.nodeBefore;if(!s.type.spec.isolating&&Bo(t,i,e))return!0;if(0==r.parent.content.size&&(Do(s,"end")||Un.isSelectable(s))){let n=Cn(t.doc,r.before(),r.after(),ie.empty);if(n&&n.slice.size<n.to-n.from){if(e){let r=t.tr.step(n);r.setSelection(Do(s,"end")?_n.findFrom(r.doc.resolve(r.mapping.map(i.pos,-1)),-1):Un.create(r.doc,i.pos-s.nodeSize)),e(r.scrollIntoView())}return!0}}return!(!s.isAtom||i.depth!=r.depth-1||(e&&e(t.tr.delete(i.pos-s.nodeSize,i.pos).scrollIntoView()),0))})(t,e),joinForward:()=>({state:t,dispatch:e})=>((t,e,n)=>{let r=function(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}(t,n);if(!r)return!1;let i=Io(r);if(!i)return!1;let s=i.nodeAfter;if(Bo(t,i,e))return!0;if(0==r.parent.content.size&&(Do(s,"start")||Un.isSelectable(s))){let n=Cn(t.doc,r.before(),r.after(),ie.empty);if(n&&n.slice.size<n.to-n.from){if(e){let r=t.tr.step(n);r.setSelection(Do(s,"start")?_n.findFrom(r.doc.resolve(r.mapping.map(i.pos)),1):Un.create(r.doc,r.mapping.map(i.pos))),e(r.scrollIntoView())}return!0}}return!(!s.isAtom||i.depth!=r.depth-1||(e&&e(t.tr.delete(i.pos,i.pos+s.nodeSize).scrollIntoView()),0))})(t,e),keyboardShortcut:t=>({editor:e,view:n,tr:r,dispatch:i})=>{const s=function(t){const e=t.split(/-(?!$)/);let n,r,i,s,o=e[e.length-1];"Space"===o&&(o=" ");for(let t=0;t<e.length-1;t+=1){const o=e[t];if(/^(cmd|meta|m)$/i.test(o))s=!0;else if(/^a(lt)?$/i.test(o))n=!0;else if(/^(c|ctrl|control)$/i.test(o))r=!0;else if(/^s(hift)?$/i.test(o))i=!0;else{if(!/^mod$/i.test(o))throw new Error(`Unrecognized modifier name: ${o}`);ka()||Oa()?s=!0:r=!0}}return n&&(o=`Alt-${o}`),r&&(o=`Ctrl-${o}`),s&&(o=`Meta-${o}`),i&&(o=`Shift-${o}`),o}(t).split(/-(?!$)/),o=s.find((t=>!["Alt","Ctrl","Meta","Shift"].includes(t))),a=new KeyboardEvent("keydown",{key:"Space"===o?" ":o,altKey:s.includes("Alt"),ctrlKey:s.includes("Ctrl"),metaKey:s.includes("Meta"),shiftKey:s.includes("Shift"),bubbles:!0,cancelable:!0}),l=e.captureTransaction((()=>{n.someProp("handleKeyDown",(t=>t(n,a)))}));return null==l||l.steps.forEach((t=>{const e=t.map(r.mapping);e&&i&&r.maybeStep(e)})),!0},lift:(t,e={})=>({state:n,dispatch:r})=>!!Aa(n,Jo(t,n.schema),e)&&((t,e)=>{let{$from:n,$to:r}=t.selection,i=n.blockRange(r),s=i&&wn(i);return null!=s&&(e&&e(t.tr.lift(i,s).scrollIntoView()),!0)})(n,r),liftEmptyBlock:()=>({state:t,dispatch:e})=>((t,e)=>{let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let r=n.before();if(Sn(t.doc,r))return e&&e(t.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),i=r&&wn(r);return null!=i&&(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)})(t,e),liftListItem:t=>({state:e,dispatch:n})=>jo(Jo(t,e.schema))(e,n),newlineInCode:()=>({state:t,dispatch:e})=>((t,e)=>{let{$head:n,$anchor:r}=t.selection;return!(!n.parent.type.spec.code||!n.sameParent(r)||(e&&e(t.tr.insertText("\n").scrollIntoView()),0))})(t,e),resetAttributes:(t,e)=>({tr:n,state:r,dispatch:i})=>{let s=null,o=null;const a=Ea("string"==typeof t?t:t.name,r.schema);return!!a&&("node"===a&&(s=Jo(t,r.schema)),"mark"===a&&(o=va(t,r.schema)),i&&n.selection.ranges.forEach((t=>{r.doc.nodesBetween(t.$from.pos,t.$to.pos,((t,r)=>{s&&s===t.type&&n.setNodeMarkup(r,void 0,Ca(t.attrs,e)),o&&t.marks.length&&t.marks.forEach((i=>{o===i.type&&n.addMark(r,r+t.nodeSize,o.create(Ca(i.attrs,e)))}))}))})),!0)},scrollIntoView:()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),selectAll:()=>({tr:t,commands:e})=>e.setTextSelection({from:0,to:t.doc.content.size}),selectNodeBackward:()=>({state:t,dispatch:e})=>((t,e,n)=>{let{$head:r,empty:i}=t.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;s=$o(r)}let o=s&&s.nodeBefore;return!(!o||!Un.isSelectable(o)||(e&&e(t.tr.setSelection(Un.create(t.doc,s.pos-o.nodeSize)).scrollIntoView()),0))})(t,e),selectNodeForward:()=>({state:t,dispatch:e})=>((t,e,n)=>{let{$head:r,empty:i}=t.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;s=Io(r)}let o=s&&s.nodeAfter;return!(!o||!Un.isSelectable(o)||(e&&e(t.tr.setSelection(Un.create(t.doc,s.pos)).scrollIntoView()),0))})(t,e),selectParentNode:()=>({state:t,dispatch:e})=>((t,e)=>{let n,{$from:r,to:i}=t.selection,s=r.sharedDepth(i);return 0!=s&&(n=r.before(s),e&&e(t.tr.setSelection(Un.create(t.doc,n))),!0)})(t,e),selectTextblockEnd:()=>({state:t,dispatch:e})=>Vo(t,e),selectTextblockStart:()=>({state:t,dispatch:e})=>Po(t,e),setContent:(t,e=!1,n={})=>({tr:r,editor:i,dispatch:s})=>{const{doc:o}=r,a=Ta(t,i.schema,n);return s&&r.replaceWith(0,o.content.size,a).setMeta("preventUpdate",!e),!0},setMark:(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:s}=n,{empty:o,ranges:a}=s,l=va(t,r.schema);if(i)if(o){const t=Da(r,l);n.addStoredMark(l.create({...t,...e}))}else a.forEach((t=>{const i=t.$from.pos,s=t.$to.pos;r.doc.nodesBetween(i,s,((t,r)=>{const o=Math.max(r,i),a=Math.min(r+t.nodeSize,s);t.marks.find((t=>t.type===l))?t.marks.forEach((t=>{l===t.type&&n.addMark(o,a,l.create({...t.attrs,...e}))})):n.addMark(o,a,l.create(e))}))}));return function(t,e,n){var r;const{selection:i}=e;let s=null;if(ba(i)&&(s=i.$cursor),s){const e=null!==(r=t.storedMarks)&&void 0!==r?r:s.marks();return!!n.isInSet(e)||!e.some((t=>t.type.excludes(n)))}const{ranges:o}=i;return o.some((({$from:e,$to:r})=>{let i=0===e.depth&&t.doc.inlineContent&&t.doc.type.allowsMarkType(n);return t.doc.nodesBetween(e.pos,r.pos,((t,e,r)=>{if(i)return!1;if(t.isInline){const e=!r||r.type.allowsMarkType(n),s=!!n.isInSet(t.marks)||!t.marks.some((t=>t.type.excludes(n)));i=e&&s}return!i})),i}))}(r,n,l)},setMeta:(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),setNode:(t,e={})=>({state:n,dispatch:r,chain:i})=>{const s=Jo(t,n.schema);return s.isTextblock?i().command((({commands:t})=>!!Lo(s,e)(n)||t.clearNodes())).command((({state:t})=>Lo(s,e)(t,r))).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},setNodeSelection:t=>({tr:e,dispatch:n})=>{if(n){const{doc:n}=e,r=wa(t,0,n.content.size),i=Un.create(n,r);e.setSelection(i)}return!0},setTextSelection:t=>({tr:e,dispatch:n})=>{if(n){const{doc:n}=e,{from:r,to:i}="number"==typeof t?{from:t,to:t}:t,s=qn.atStart(n).from,o=qn.atEnd(n).to,a=wa(r,s,o),l=wa(i,s,o),c=qn.create(n,a,l);e.setSelection(c)}return!0},sinkListItem:t=>({state:e,dispatch:n})=>{const r=Jo(t,e.schema);return(i=r,function(t,e){let{$from:n,$to:r}=t.selection,s=n.blockRange(r,(t=>t.childCount>0&&t.firstChild.type==i));if(!s)return!1;let o=s.startIndex;if(0==o)return!1;let a=s.parent,l=a.child(o-1);if(l.type!=i)return!1;if(e){let n=l.lastChild&&l.lastChild.type==a.type,r=Zt.from(n?i.create():null),o=new ie(Zt.from(i.create(null,Zt.from(a.type.create(null,r)))),n?3:1,0),c=s.start,h=s.end;e(t.tr.step(new yn(c-(n?3:1),h,c,h,o,1,!0)).scrollIntoView())}return!0})(e,n);var i},splitBlock:({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:i})=>{const{selection:s,doc:o}=e,{$from:a,$to:l}=s,c=Ia(i.extensionManager.attributes,a.node().type.name,a.node().attrs);if(s instanceof Un&&s.node.isBlock)return!(!a.parentOffset||!Sn(o,a.pos))&&(r&&(t&&Fa(n,i.extensionManager.splittableMarks),e.split(a.pos).scrollIntoView()),!0);if(!a.parent.isBlock)return!1;if(r){const r=l.parentOffset===l.parent.content.size;s instanceof qn&&e.deleteSelection();const o=0===a.depth?void 0:function(t){for(let e=0;e<t.edgeCount;e+=1){const{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}(a.node(-1).contentMatchAt(a.indexAfter(-1)));let h=r&&o?[{type:o,attrs:c}]:void 0,d=Sn(e.doc,e.mapping.map(a.pos),1,h);if(h||d||!Sn(e.doc,e.mapping.map(a.pos),1,o?[{type:o}]:void 0)||(d=!0,h=o?[{type:o,attrs:c}]:void 0),d&&(e.split(e.mapping.map(a.pos),1,h),o&&!r&&!a.parentOffset&&a.parent.type!==o)){const t=e.mapping.map(a.before()),n=e.doc.resolve(t);a.node(-1).canReplaceWith(n.index(),n.index()+1,o)&&e.setNodeMarkup(e.mapping.map(a.before()),o)}t&&Fa(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return!0},splitListItem:t=>({tr:e,state:n,dispatch:r,editor:i})=>{var s;const o=Jo(t,n.schema),{$from:a,$to:l}=n.selection,c=n.selection.node;if(c&&c.isBlock||a.depth<2||!a.sameParent(l))return!1;const h=a.node(-1);if(h.type!==o)return!1;const d=i.extensionManager.attributes;if(0===a.parent.content.size&&a.node(-1).childCount===a.indexAfter(-1)){if(2===a.depth||a.node(-3).type!==o||a.index(-2)!==a.node(-2).childCount-1)return!1;if(r){let t=Zt.empty;const n=a.index(-1)?1:a.index(-2)?2:3;for(let e=a.depth-n;e>=a.depth-3;e-=1)t=Zt.from(a.node(e).copy(t));const r=a.indexAfter(-1)<a.node(-2).childCount?1:a.indexAfter(-2)<a.node(-3).childCount?2:3,i=Ia(d,a.node().type.name,a.node().attrs),l=(null===(s=o.contentMatch.defaultType)||void 0===s?void 0:s.createAndFill(i))||void 0;t=t.append(Zt.from(o.createAndFill(null,l)||void 0));const c=a.before(a.depth-(n-1));e.replace(c,a.after(-r),new ie(t,4-n,0));let h=-1;e.doc.nodesBetween(c,e.doc.content.size,((t,e)=>{if(h>-1)return!1;t.isTextblock&&0===t.content.size&&(h=e+1)})),h>-1&&e.setSelection(qn.near(e.doc.resolve(h))),e.scrollIntoView()}return!0}const u=l.pos===a.end()?h.contentMatchAt(0).defaultType:null,p=Ia(d,h.type.name,h.attrs),f=Ia(d,a.node().type.name,a.node().attrs);e.delete(a.pos,l.pos);const m=u?[{type:o,attrs:p},{type:u,attrs:f}]:[{type:o,attrs:p}];if(!Sn(e.doc,a.pos,2))return!1;if(r){const{selection:t,storedMarks:s}=n,{splittableMarks:o}=i.extensionManager,l=s||t.$to.parentOffset&&t.$from.marks();if(e.split(a.pos,2,m).scrollIntoView(),!l||!r)return!0;const c=l.filter((t=>o.includes(t.type.name)));e.ensureMarks(c)}return!0},toggleList:(t,e,n,r={})=>({editor:i,tr:s,state:o,dispatch:a,chain:l,commands:c,can:h})=>{const{extensions:d,splittableMarks:u}=i.extensionManager,p=Jo(t,o.schema),f=Jo(e,o.schema),{selection:m,storedMarks:g}=o,{$from:y,$to:v}=m,b=y.blockRange(v),w=g||m.$to.parentOffset&&m.$from.marks();if(!b)return!1;const x=Na((t=>Ba(t.type.name,d)))(m);if(b.depth>=1&&x&&b.depth-x.depth<=1){if(x.node.type===p)return c.liftListItem(f);if(Ba(x.node.type.name,d)&&p.validContent(x.node.content)&&a)return l().command((()=>(s.setNodeMarkup(x.pos,p),!0))).command((()=>Pa(s,p))).command((()=>Va(s,p))).run()}return n&&w&&a?l().command((()=>{const t=h().wrapInList(p,r),e=w.filter((t=>u.includes(t.type.name)));return s.ensureMarks(e),!!t||c.clearNodes()})).wrapInList(p,r).command((()=>Pa(s,p))).command((()=>Va(s,p))).run():l().command((()=>!!h().wrapInList(p,r)||c.clearNodes())).wrapInList(p,r).command((()=>Pa(s,p))).command((()=>Va(s,p))).run()},toggleMark:(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:s=!1}=n,o=va(t,r.schema);return Ra(r,o,e)?i.unsetMark(o,{extendEmptyMarkRange:s}):i.setMark(o,e)},toggleNode:(t,e,n={})=>({state:r,commands:i})=>{const s=Jo(t,r.schema),o=Jo(e,r.schema);return Aa(r,s,n)?i.setNode(o):i.setNode(s,n)},toggleWrap:(t,e={})=>({state:n,commands:r})=>{const i=Jo(t,n.schema);return Aa(n,i,e)?r.lift(i):r.wrapIn(i,e)},undoInputRule:()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r<n.length;r+=1){const i=n[r];let s;if(i.spec.isInputRules&&(s=i.getState(t))){if(e){const e=t.tr,n=s.transform;for(let t=n.steps.length-1;t>=0;t-=1)e.step(n.steps[t].invert(n.docs[t]));if(s.text){const n=e.doc.resolve(s.from).marks();e.replaceWith(s.from,s.to,t.schema.text(s.text,n))}else e.delete(s.from,s.to)}return!0}}return!1},unsetAllMarks:()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:r,ranges:i}=n;return r||e&&i.forEach((e=>{t.removeMark(e.$from.pos,e.$to.pos)})),!0},unsetMark:(t,e={})=>({tr:n,state:r,dispatch:i})=>{var s;const{extendEmptyMarkRange:o=!1}=e,{selection:a}=n,l=va(t,r.schema),{$from:c,empty:h,ranges:d}=a;if(!i)return!0;if(h&&o){let{from:t,to:e}=a;const r=null===(s=c.marks().find((t=>t.type===l)))||void 0===s?void 0:s.attrs,i=ya(c,l,r);i&&(t=i.from,e=i.to),n.removeMark(t,e,l)}else d.forEach((t=>{n.removeMark(t.$from.pos,t.$to.pos,l)}));return n.removeStoredMark(l),!0},updateAttributes:(t,e={})=>({tr:n,state:r,dispatch:i})=>{let s=null,o=null;const a=Ea("string"==typeof t?t:t.name,r.schema);return!!a&&("node"===a&&(s=Jo(t,r.schema)),"mark"===a&&(o=va(t,r.schema)),i&&n.selection.ranges.forEach((t=>{const i=t.$from.pos,a=t.$to.pos;r.doc.nodesBetween(i,a,((t,r)=>{s&&s===t.type&&n.setNodeMarkup(r,void 0,{...t.attrs,...e}),o&&t.marks.length&&t.marks.forEach((s=>{if(o===s.type){const l=Math.max(r,i),c=Math.min(r+t.nodeSize,a);n.addMark(l,c,o.create({...s.attrs,...e}))}}))}))})),!0)},wrapIn:(t,e={})=>({state:n,dispatch:r})=>function(t,e=null){return function(n,r){let{$from:i,$to:s}=n.selection,o=i.blockRange(s),a=o&&xn(o,t,e);return!!a&&(r&&r(n.tr.wrap(o,a).scrollIntoView()),!0)}}(Jo(t,n.schema),e)(n,r),wrapInList:(t,e={})=>({state:n,dispatch:r})=>zo(Jo(t,n.schema),e)(n,r)});const za=ha.create({name:"commands",addCommands:()=>({...La})}),ja=ha.create({name:"editable",addProseMirrorPlugins(){return[new ar({key:new hr("editable"),props:{editable:()=>this.editor.options.editable}})]}}),_a=ha.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new ar({key:new hr("focusEvents"),props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;const r=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,n)=>{t.isFocused=!1;const r=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),Ka=ha.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first((({commands:t})=>[()=>t.undoInputRule(),()=>t.command((({tr:e})=>{const{selection:n,doc:r}=e,{empty:i,$anchor:s}=n,{pos:o,parent:a}=s,l=_n.atStart(r).from===o;return!(!(i&&l&&a.type.isTextblock)||a.textContent.length)&&t.clearNodes()})),()=>t.deleteSelection(),()=>t.joinBackward(),()=>t.selectNodeBackward()])),e=()=>this.editor.commands.first((({commands:t})=>[()=>t.deleteSelection(),()=>t.deleteCurrentNode(),()=>t.joinForward(),()=>t.selectNodeForward()])),n={Enter:()=>this.editor.commands.first((({commands:t})=>[()=>t.newlineInCode(),()=>t.createParagraphNear(),()=>t.liftEmptyBlock(),()=>t.splitBlock()])),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},r={...n},i={...n,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return ka()||Oa()?i:r},addProseMirrorPlugins(){return[new ar({key:new hr("clearDocument"),appendTransaction:(t,e,n)=>{if(!(t.some((t=>t.docChanged))&&!e.doc.eq(n.doc)))return;const{empty:r,from:i,to:s}=e.selection,o=_n.atStart(e.doc).from,a=_n.atEnd(e.doc).to;if(r||!(i===o&&s===a))return;if(!(0===n.doc.textBetween(0,n.doc.content.size," "," ").length))return;const l=n.tr,c=_o({state:n,transaction:l}),{commands:h}=new Ko({editor:this.editor,state:c});return h.clearNodes(),l.steps.length?l:void 0}})]}}),Wa=ha.create({name:"tabindex",addProseMirrorPlugins(){return[new ar({key:new hr("tabindex"),props:{attributes:this.editor.isEditable?{tabindex:"0"}:{}}})]}});var Ha=Object.freeze({__proto__:null,ClipboardTextSerializer:pa,Commands:za,Editable:ja,FocusEvents:_a,Keymap:Ka,Tabindex:Wa});class qa extends class{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){const n=this.callbacks[t];return n&&n.forEach((t=>t.apply(this,e))),this}off(t,e){const n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter((t=>t!==e)):delete this.callbacks[t]),this}removeAllListeners(){this.callbacks={}}}{constructor(t={}){super(),this.isFocused=!1,this.extensionStorage={},this.options={element:document.createElement("div"),content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,onBeforeCreate:()=>null,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(t),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.createView(),this.injectCSS(),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),window.setTimeout((()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}))}),0)}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&document&&(this.css=function(t,e){const n=document.querySelector("style[data-tiptap-style]");if(null!==n)return n;const r=document.createElement("style");return e&&r.setAttribute("nonce",e),r.setAttribute("data-tiptap-style",""),r.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(r),r}('.ProseMirror {\n position: relative;\n}\n\n.ProseMirror {\n word-wrap: break-word;\n white-space: pre-wrap;\n white-space: break-spaces;\n -webkit-font-variant-ligatures: none;\n font-variant-ligatures: none;\n font-feature-settings: "liga" 0; /* the above doesn\'t seem to work in Edge */\n}\n\n.ProseMirror [contenteditable="false"] {\n white-space: normal;\n}\n\n.ProseMirror [contenteditable="false"] [contenteditable="true"] {\n white-space: pre-wrap;\n}\n\n.ProseMirror pre {\n white-space: pre-wrap;\n}\n\nimg.ProseMirror-separator {\n display: inline !important;\n border: none !important;\n margin: 0 !important;\n width: 1px !important;\n height: 1px !important;\n}\n\n.ProseMirror-gapcursor {\n display: none;\n pointer-events: none;\n position: absolute;\n margin: 0;\n}\n\n.ProseMirror-gapcursor:after {\n content: "";\n display: block;\n position: absolute;\n top: -2px;\n width: 20px;\n border-top: 1px solid black;\n animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;\n}\n\n@keyframes ProseMirror-cursor-blink {\n to {\n visibility: hidden;\n }\n}\n\n.ProseMirror-hideselection *::selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection *::-moz-selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection * {\n caret-color: transparent;\n}\n\n.ProseMirror-focused .ProseMirror-gapcursor {\n display: block;\n}\n\n.tippy-box[data-animation=fade][data-state=hidden] {\n opacity: 0\n}',this.options.injectNonce))}setOptions(t={}){this.options={...this.options,...t},this.view&&this.state&&!this.isDestroyed&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(t,e=!0){this.setOptions({editable:t}),e&&this.emit("update",{editor:this,transaction:this.state.tr})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get state(){return this.view.state}registerPlugin(t,e){const n=Yo(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t],r=this.state.reconfigure({plugins:n});this.view.updateState(r)}unregisterPlugin(t){if(this.isDestroyed)return;const e="string"==typeof t?`${t}$`:t.key,n=this.state.reconfigure({plugins:this.state.plugins.filter((t=>!t.key.startsWith(e)))});this.view.updateState(n)}createExtensionManager(){const t=[...this.options.enableCoreExtensions?Object.values(Ha):[],...this.options.extensions].filter((t=>["extension","node","mark"].includes(null==t?void 0:t.type)));this.extensionManager=new aa(t,this)}createCommandManager(){this.commandManager=new Ko({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){const t=Ta(this.options.content,this.schema,this.options.parseOptions),e=xa(t,this.options.autofocus);this.view=new po(this.options.element,{...this.options.editorProps,dispatchTransaction:this.dispatchTransaction.bind(this),state:sr.create({doc:t,selection:e||void 0})});const n=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(n),this.createNodeViews();this.view.dom.editor=this}createNodeViews(){this.view.setProps({nodeViews:this.extensionManager.nodeViews})}captureTransaction(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction)return this.capturedTransaction?void t.steps.forEach((t=>{var e;return null===(e=this.capturedTransaction)||void 0===e?void 0:e.step(t)})):void(this.capturedTransaction=t);const e=this.state.apply(t),n=!this.state.selection.eq(e.selection);this.view.updateState(e),this.emit("transaction",{editor:this,transaction:t}),n&&this.emit("selectionUpdate",{editor:this,transaction:t});const r=t.getMeta("focus"),i=t.getMeta("blur");r&&this.emit("focus",{editor:this,event:r.event,transaction:t}),i&&this.emit("blur",{editor:this,event:i.event,transaction:t}),t.docChanged&&!t.getMeta("preventUpdate")&&this.emit("update",{editor:this,transaction:t})}getAttributes(t){return $a(this.state,t)}isActive(t,e){const n="string"==typeof t?t:null,r="string"==typeof t?e:t;return function(t,e,n={}){if(!e)return Aa(t,null,n)||Ra(t,null,n);const r=Ea(e,t.schema);return"node"===r?Aa(t,e,n):"mark"===r&&Ra(t,e,n)}(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return function(t,e){const n=Ze.fromSchema(e).serializeFragment(t),r=document.implementation.createHTMLDocument().createElement("div");return r.appendChild(n),r.innerHTML}(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e="\n\n",textSerializers:n={}}=t||{};return function(t,e){return da(t,{from:0,to:t.content.size},e)}(this.state.doc,{blockSeparator:e,textSerializers:{...ua(this.schema),...n}})}get isEmpty(){return function(t){var e;const n=null===(e=t.type.createAndFill())||void 0===e?void 0:e.toJSON(),r=t.toJSON();return JSON.stringify(n)===JSON.stringify(r)}(this.state.doc)}getCharacterCount(){return console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.'),this.state.doc.content.size-2}destroy(){this.emit("destroy"),this.view&&this.view.destroy(),this.removeAllListeners()}get isDestroyed(){var t;return!(null===(t=this.view)||void 0===t?void 0:t.docView)}}class Ja{constructor(t={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...t},this.name=this.config.name,t.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=Xo(Wo(this,"addOptions",{name:this.name}))),this.storage=Xo(Wo(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t={}){return new Ja(t)}configure(t={}){const e=this.extend();return e.options=ca(this.options,t),e.storage=Xo(Wo(e,"addStorage",{name:e.name,options:e.options})),e}extend(t={}){const e=new Ja(t);return e.parent=this,this.child=e,e.name=t.name?t.name:e.parent.name,t.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${e.name}".`),e.options=Xo(Wo(e,"addOptions",{name:e.name})),e.storage=Xo(Wo(e,"addStorage",{name:e.name,options:e.options})),e}static handleExit({editor:t,mark:e}){const{tr:n}=t.state,r=t.state.selection.$from;if(r.pos===r.end()){const i=r.marks(),s=!!i.find((t=>(null==t?void 0:t.type.name)===e.name));if(!s)return!1;const o=i.find((t=>(null==t?void 0:t.type.name)===e.name));return o&&n.removeStoredMark(o),n.insertText(" ",r.pos),t.view.dispatch(n),!0}return!1}}class Ua{constructor(t={}){this.type="node",this.name="node",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...t},this.name=this.config.name,t.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=Xo(Wo(this,"addOptions",{name:this.name}))),this.storage=Xo(Wo(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t={}){return new Ua(t)}configure(t={}){const e=this.extend();return e.options=ca(this.options,t),e.storage=Xo(Wo(e,"addStorage",{name:e.name,options:e.options})),e}extend(t={}){const e=new Ua(t);return e.parent=this,this.child=e,e.name=t.name?t.name:e.parent.name,t.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${e.name}".`),e.options=Xo(Wo(e,"addOptions",{name:e.name})),e.storage=Xo(Wo(e,"addStorage",{name:e.name,options:e.options})),e}}const Ga=Ua.create({name:"doc",topNode:!0,content:"block+"}),Ya=Ua.create({name:"paragraph",priority:1e3,addOptions:()=>({HTMLAttributes:{}}),group:"block",content:"inline*",parseHTML:()=>[{tag:"p"}],renderHTML({HTMLAttributes:t}){return["p",Uo(this.options.HTMLAttributes,t),0]},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Xa=Ua.create({name:"text",group:"inline"});function Za(t={}){return new ar({view:e=>new Qa(e,t)})}class Qa{constructor(t,e){this.editorView=t,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=e.width||1,this.color=e.color||"black",this.class=e.class,this.handlers=["dragover","dragend","drop","dragleave"].map((e=>{let n=t=>{this[e](t)};return t.dom.addEventListener(e,n),{name:e,handler:n}}))}destroy(){this.handlers.forEach((({name:t,handler:e})=>this.editorView.dom.removeEventListener(t,e)))}update(t,e){null!=this.cursorPos&&e.doc!=t.state.doc&&(this.cursorPos>t.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(t){t!=this.cursorPos&&(this.cursorPos=t,null==t?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let t,e=this.editorView.state.doc.resolve(this.cursorPos);if(!e.parent.inlineContent){let n=e.nodeBefore,r=e.nodeAfter;if(n||r){let e=this.editorView.nodeDOM(this.cursorPos-(n?n.nodeSize:0));if(e){let i=e.getBoundingClientRect(),s=n?i.bottom:i.top;n&&r&&(s=(s+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2),t={left:i.left,right:i.right,top:s-this.width/2,bottom:s+this.width/2}}}}if(!t){let e=this.editorView.coordsAtPos(this.cursorPos);t={left:e.left-this.width/2,right:e.left+this.width/2,top:e.top,bottom:e.bottom}}let n,r,i=this.editorView.dom.offsetParent;if(this.element||(this.element=i.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none; background-color: "+this.color),!i||i==document.body&&"static"==getComputedStyle(i).position)n=-pageXOffset,r=-pageYOffset;else{let t=i.getBoundingClientRect();n=t.left-i.scrollLeft,r=t.top-i.scrollTop}this.element.style.left=t.left-n+"px",this.element.style.top=t.top-r+"px",this.element.style.width=t.right-t.left+"px",this.element.style.height=t.bottom-t.top+"px"}scheduleRemoval(t){clearTimeout(this.timeout),this.timeout=setTimeout((()=>this.setCursor(null)),t)}dragover(t){if(!this.editorView.editable)return;let e=this.editorView.posAtCoords({left:t.clientX,top:t.clientY}),n=e&&e.inside>=0&&this.editorView.state.doc.nodeAt(e.inside),r=n&&n.type.spec.disableDropCursor,i="function"==typeof r?r(this.editorView,e,t):r;if(e&&!i){let t=e.pos;if(this.editorView.dragging&&this.editorView.dragging.slice&&(t=En(this.editorView.state.doc,t,this.editorView.dragging.slice),null==t))return this.setCursor(null);this.setCursor(t),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(t){t.target!=this.editorView.dom&&this.editorView.dom.contains(t.relatedTarget)||this.setCursor(null)}}const tl=ha.create({name:"dropCursor",addOptions:()=>({color:"currentColor",width:1,class:void 0}),addProseMirrorPlugins(){return[Za(this.options)]}});class el extends _n{constructor(t){super(t,t)}map(t,e){let n=t.resolve(e.map(this.head));return el.valid(n)?new el(n):_n.near(n)}content(){return ie.empty}eq(t){return t instanceof el&&t.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(t,e){if("number"!=typeof e.pos)throw new RangeError("Invalid input for GapCursor.fromJSON");return new el(t.resolve(e.pos))}getBookmark(){return new nl(this.anchor)}static valid(t){let e=t.parent;if(e.isTextblock||!function(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(0!=n)for(let t=r.child(n-1);;t=t.lastChild){if(0==t.childCount&&!t.inlineContent||t.isAtom||t.type.spec.isolating)return!0;if(t.inlineContent)return!1}else if(r.type.spec.isolating)return!0}return!0}(t)||!function(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n!=r.childCount)for(let t=r.child(n);;t=t.firstChild){if(0==t.childCount&&!t.inlineContent||t.isAtom||t.type.spec.isolating)return!0;if(t.inlineContent)return!1}else if(r.type.spec.isolating)return!0}return!0}(t))return!1;let n=e.type.spec.allowGapCursor;if(null!=n)return n;let r=e.contentMatchAt(t.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(t,e,n=!1){t:for(;;){if(!n&&el.valid(t))return t;let r=t.pos,i=null;for(let n=t.depth;;n--){let s=t.node(n);if(e>0?t.indexAfter(n)<s.childCount:t.index(n)>0){i=s.child(e>0?t.indexAfter(n):t.index(n)-1);break}if(0==n)return null;r+=e;let o=t.doc.resolve(r);if(el.valid(o))return o}for(;;){let s=e>0?i.firstChild:i.lastChild;if(!s){if(i.isAtom&&!i.isText&&!Un.isSelectable(i)){t=t.doc.resolve(r+i.nodeSize*e),n=!1;continue t}break}i=s,r+=e;let o=t.doc.resolve(r);if(el.valid(o))return o}return null}}}el.prototype.visible=!1,el.findFrom=el.findGapCursorFrom,_n.jsonID("gapcursor",el);class nl{constructor(t){this.pos=t}map(t){return new nl(t.map(this.pos))}resolve(t){let e=t.resolve(this.pos);return el.valid(e)?new el(e):_n.near(e)}}const rl=No({ArrowLeft:il("horiz",-1),ArrowRight:il("horiz",1),ArrowUp:il("vert",-1),ArrowDown:il("vert",1)});function il(t,e){const n="vert"==t?e>0?"down":"up":e>0?"right":"left";return function(t,r,i){let s=t.selection,o=e>0?s.$to:s.$from,a=s.empty;if(s instanceof qn){if(!i.endOfTextblock(n)||0==o.depth)return!1;a=!1,o=t.doc.resolve(e>0?o.after():o.before())}let l=el.findGapCursorFrom(o,e,a);return!!l&&(r&&r(t.tr.setSelection(new el(l))),!0)}}function sl(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!el.valid(r))return!1;let i=t.posAtCoords({left:n.clientX,top:n.clientY});return!(i&&i.inside>-1&&Un.isSelectable(t.state.doc.nodeAt(i.inside)))&&(t.dispatch(t.state.tr.setSelection(new el(r))),!0)}function ol(t,e){if("insertCompositionText"!=e.inputType||!(t.state.selection instanceof el))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let i=Zt.empty;for(let t=r.length-1;t>=0;t--)i=Zt.from(r[t].createAndFill(null,i));let s=t.state.tr.replace(n.pos,n.pos,new ie(i,0,0));return s.setSelection(qn.near(s.doc.resolve(n.pos+1))),t.dispatch(s),!1}function al(t){if(!(t.selection instanceof el))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",Hs.create(t.doc,[_s.widget(t.selection.head,e,{key:"gapcursor"})])}const ll=ha.create({name:"gapCursor",addProseMirrorPlugins:()=>[new ar({props:{decorations:al,createSelectionBetween:(t,e,n)=>e.pos==n.pos&&el.valid(n)?new el(n):null,handleClick:sl,handleKeyDown:rl,handleDOMEvents:{beforeinput:ol}}})],extendNodeSchema(t){var e;return{allowGapCursor:null!==(e=Xo(Wo(t,"allowGapCursor",{name:t.name,options:t.options,storage:t.storage})))&&void 0!==e?e:null}}});var cl=function(){};cl.prototype.append=function(t){return t.length?(t=cl.from(t),!this.length&&t||t.length<200&&this.leafAppend(t)||this.length<200&&t.leafPrepend(this)||this.appendInner(t)):this},cl.prototype.prepend=function(t){return t.length?cl.from(t).append(this):this},cl.prototype.appendInner=function(t){return new dl(this,t)},cl.prototype.slice=function(t,e){return void 0===t&&(t=0),void 0===e&&(e=this.length),t>=e?cl.empty:this.sliceInner(Math.max(0,t),Math.min(this.length,e))},cl.prototype.get=function(t){if(!(t<0||t>=this.length))return this.getInner(t)},cl.prototype.forEach=function(t,e,n){void 0===e&&(e=0),void 0===n&&(n=this.length),e<=n?this.forEachInner(t,e,n,0):this.forEachInvertedInner(t,e,n,0)},cl.prototype.map=function(t,e,n){void 0===e&&(e=0),void 0===n&&(n=this.length);var r=[];return this.forEach((function(e,n){return r.push(t(e,n))}),e,n),r},cl.from=function(t){return t instanceof cl?t:t&&t.length?new hl(t):cl.empty};var hl=function(t){function e(e){t.call(this),this.values=e}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(t,n){return 0==t&&n==this.length?this:new e(this.values.slice(t,n))},e.prototype.getInner=function(t){return this.values[t]},e.prototype.forEachInner=function(t,e,n,r){for(var i=e;i<n;i++)if(!1===t(this.values[i],r+i))return!1},e.prototype.forEachInvertedInner=function(t,e,n,r){for(var i=e-1;i>=n;i--)if(!1===t(this.values[i],r+i))return!1},e.prototype.leafAppend=function(t){if(this.length+t.length<=200)return new e(this.values.concat(t.flatten()))},e.prototype.leafPrepend=function(t){if(this.length+t.length<=200)return new e(t.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e}(cl);cl.empty=new hl([]);var dl=function(t){function e(e,n){t.call(this),this.left=e,this.right=n,this.length=e.length+n.length,this.depth=Math.max(e.depth,n.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(t){return t<this.left.length?this.left.get(t):this.right.get(t-this.left.length)},e.prototype.forEachInner=function(t,e,n,r){var i=this.left.length;return!(e<i&&!1===this.left.forEachInner(t,e,Math.min(n,i),r))&&(!(n>i&&!1===this.right.forEachInner(t,Math.max(e-i,0),Math.min(this.length,n)-i,r+i))&&void 0)},e.prototype.forEachInvertedInner=function(t,e,n,r){var i=this.left.length;return!(e>i&&!1===this.right.forEachInvertedInner(t,e-i,Math.max(n,i)-i,r+i))&&(!(n<i&&!1===this.left.forEachInvertedInner(t,Math.min(e,i),n,r))&&void 0)},e.prototype.sliceInner=function(t,e){if(0==t&&e==this.length)return this;var n=this.left.length;return e<=n?this.left.slice(t,e):t>=n?this.right.slice(t-n,e-n):this.left.slice(t,n).append(this.right.slice(0,e-n))},e.prototype.leafAppend=function(t){var n=this.right.leafAppend(t);if(n)return new e(this.left,n)},e.prototype.leafPrepend=function(t){var n=this.left.leafPrepend(t);if(n)return new e(n,this.right)},e.prototype.appendInner=function(t){return this.left.depth>=Math.max(this.right.depth,t.depth)+1?new e(this.left,new e(this.right,t)):new e(this,t)},e}(cl),ul=cl;class pl{constructor(t,e){this.items=t,this.eventCount=e}popEvent(t,e){if(0==this.eventCount)return null;let n,r,i=this.items.length;for(;;i--){if(this.items.get(i-1).selection){--i;break}}e&&(n=this.remapping(i,this.items.length),r=n.maps.length);let s,o,a=t.tr,l=[],c=[];return this.items.forEach(((t,e)=>{if(!t.step)return n||(n=this.remapping(i,e+1),r=n.maps.length),r--,void c.push(t);if(n){c.push(new fl(t.map));let e,i=t.step.map(n.slice(r));i&&a.maybeStep(i).doc&&(e=a.mapping.maps[a.mapping.maps.length-1],l.push(new fl(e,void 0,void 0,l.length+c.length))),r--,e&&n.appendMap(e,r)}else a.maybeStep(t.step);return t.selection?(s=n?t.selection.map(n.slice(r)):t.selection,o=new pl(this.items.slice(0,i).append(c.reverse().concat(l)),this.eventCount-1),!1):void 0}),this.items.length,0),{remaining:o,transform:a,selection:s}}addTransform(t,e,n,r){let i=[],s=this.eventCount,o=this.items,a=!r&&o.length?o.get(o.length-1):null;for(let n=0;n<t.steps.length;n++){let l,c=t.steps[n].invert(t.docs[n]),h=new fl(t.mapping.maps[n],c,e);(l=a&&a.merge(h))&&(h=l,n?i.pop():o=o.slice(0,o.length-1)),i.push(h),e&&(s++,e=void 0),r||(a=h)}let l=s-n.depth;return l>gl&&(o=function(t,e){let n;return t.forEach(((t,r)=>{if(t.selection&&0==e--)return n=r,!1})),t.slice(n)}(o,l),s-=l),new pl(o.append(i),s)}remapping(t,e){let n=new an;return this.items.forEach(((e,r)=>{let i=null!=e.mirrorOffset&&r-e.mirrorOffset>=t?n.maps.length-e.mirrorOffset:void 0;n.appendMap(e.map,i)}),t,e),n}addMaps(t){return 0==this.eventCount?this:new pl(this.items.append(t.map((t=>new fl(t)))),this.eventCount)}rebased(t,e){if(!this.eventCount)return this;let n=[],r=Math.max(0,this.items.length-e),i=t.mapping,s=t.steps.length,o=this.eventCount;this.items.forEach((t=>{t.selection&&o--}),r);let a=e;this.items.forEach((e=>{let r=i.getMirror(--a);if(null==r)return;s=Math.min(s,r);let l=i.maps[r];if(e.step){let s=t.steps[r].invert(t.docs[r]),c=e.selection&&e.selection.map(i.slice(a+1,r));c&&o++,n.push(new fl(l,s,c))}else n.push(new fl(l))}),r);let l=[];for(let t=e;t<s;t++)l.push(new fl(i.maps[t]));let c=this.items.slice(0,r).append(l).append(n),h=new pl(c,o);return h.emptyItemCount()>500&&(h=h.compress(this.items.length-n.length)),h}emptyItemCount(){let t=0;return this.items.forEach((e=>{e.step||t++})),t}compress(t=this.items.length){let e=this.remapping(0,t),n=e.maps.length,r=[],i=0;return this.items.forEach(((s,o)=>{if(o>=t)r.push(s),s.selection&&i++;else if(s.step){let t=s.step.map(e.slice(n)),o=t&&t.getMap();if(n--,o&&e.appendMap(o,n),t){let a=s.selection&&s.selection.map(e.slice(n));a&&i++;let l,c=new fl(o.invert(),t,a),h=r.length-1;(l=r.length&&r[h].merge(c))?r[h]=l:r.push(c)}}else s.map&&n--}),this.items.length,0),new pl(ul.from(r.reverse()),i)}}pl.empty=new pl(ul.empty,0);class fl{constructor(t,e,n,r){this.map=t,this.step=e,this.selection=n,this.mirrorOffset=r}merge(t){if(this.step&&t.step&&!t.selection){let e=t.step.merge(this.step);if(e)return new fl(e.getMap().invert(),e,this.selection)}}}class ml{constructor(t,e,n,r){this.done=t,this.undone=e,this.prevRanges=n,this.prevTime=r}}const gl=20;function yl(t){let e=[];return t.forEach(((t,n,r,i)=>e.push(r,i))),e}function vl(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let i=e.map(t[r],1),s=e.map(t[r+1],-1);i<=s&&n.push(i,s)}return n}function bl(t,e,n,r){let i=kl(e),s=Sl.get(e).spec.config,o=(r?t.undone:t.done).popEvent(e,i);if(!o)return;let a=o.selection.resolve(o.transform.doc),l=(r?t.done:t.undone).addTransform(o.transform,e.selection.getBookmark(),s,i),c=new ml(r?l:o.remaining,r?o.remaining:l,null,0);n(o.transform.setSelection(a).setMeta(Sl,{redo:r,historyState:c}).scrollIntoView())}let wl=!1,xl=null;function kl(t){let e=t.plugins;if(xl!=e){wl=!1,xl=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){wl=!0;break}}return wl}const Sl=new hr("history"),Ml=new hr("closeHistory");function Ol(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new ar({key:Sl,state:{init:()=>new ml(pl.empty,pl.empty,null,0),apply:(e,n,r)=>function(t,e,n,r){let i,s=n.getMeta(Sl);if(s)return s.historyState;n.getMeta(Ml)&&(t=new ml(t.done,t.undone,null,0));let o=n.getMeta("appendedTransaction");if(0==n.steps.length)return t;if(o&&o.getMeta(Sl))return o.getMeta(Sl).redo?new ml(t.done.addTransform(n,void 0,r,kl(e)),t.undone,yl(n.mapping.maps[n.steps.length-1]),t.prevTime):new ml(t.done,t.undone.addTransform(n,void 0,r,kl(e)),null,t.prevTime);if(!1===n.getMeta("addToHistory")||o&&!1===o.getMeta("addToHistory"))return(i=n.getMeta("rebased"))?new ml(t.done.rebased(n,i),t.undone.rebased(n,i),vl(t.prevRanges,n.mapping),t.prevTime):new ml(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),vl(t.prevRanges,n.mapping),t.prevTime);{let i=0==t.prevTime||!o&&(t.prevTime<(n.time||0)-r.newGroupDelay||!function(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach(((t,r)=>{for(let i=0;i<e.length;i+=2)t<=e[i+1]&&r>=e[i]&&(n=!0)})),n}(n,t.prevRanges)),s=o?vl(t.prevRanges,n.mapping):yl(n.mapping.maps[n.steps.length-1]);return new ml(t.done.addTransform(n,i?e.selection.getBookmark():void 0,r,kl(e)),pl.empty,s,n.time)}}(n,r,e,t)},config:t,props:{handleDOMEvents:{beforeinput(t,e){let n=e.inputType,r="historyUndo"==n?Al:"historyRedo"==n?El:null;return!!r&&(e.preventDefault(),r(t.state,t.dispatch))}}}})}const Al=(t,e)=>{let n=Sl.getState(t);return!(!n||0==n.done.eventCount)&&(e&&bl(n,t,e,!1),!0)},El=(t,e)=>{let n=Sl.getState(t);return!(!n||0==n.undone.eventCount)&&(e&&bl(n,t,e,!0),!0)},Cl=ha.create({name:"history",addOptions:()=>({depth:100,newGroupDelay:500}),addCommands:()=>({undo:()=>({state:t,dispatch:e})=>Al(t,e),redo:()=>({state:t,dispatch:e})=>El(t,e)}),addProseMirrorPlugins(){return[Ol(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Mod-y":()=>this.editor.commands.redo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}});class Tl extends X{connect(){for(const t of this.editorTargets){const e=new qa({extensions:[tl,ll,Cl,Ga,Ya,Xa],content:"",injectCSS:!1,element:t,editorProps:{attributes:{class:"ariadne-h-28 ariadne-max-h-48 ariadne-p-2 ariadne-rounded-lg ariadne-overflow-y-auto focus:ariadne-outline-none"}},parseOptions:{preserveWhitespace:!0}}),n=t.previousElementSibling;if(n){const r=t.closest("form");null==r||r.addEventListener("submit",(()=>{n.setAttribute("value",e.getText()||""),e.commands.clearContent()}))}}}}Tl.targets=["editor"];class Nl extends X{toggle(){this.expandableTarget.classList.toggle("ariadne-hidden");for(const t of this.slidePanelTargets)t.classList.toggle("ariadne-hidden")}}Nl.targets=["expandable","expandWrapper","slidePanel","buttonWrapper"];class Dl extends X{constructor(){super(...arguments),this.SELECTED_CLASSES=["ariadne-border-slate-500","ariadne-text-slate-600"],this.UNSELECTED_CLASSES=["ariadne-text-gray-500","hover:ariadne-text-gray-700","hover:ariadne-border-gray-300"]}connect(){for(const t of this.tabTargets)t.hasAttribute("aria-current")&&(t.classList.add(...this.SELECTED_CLASSES),t.classList.remove(...this.UNSELECTED_CLASSES))}toggle(t){for(const e of this.tabTargets)e===t.target?(e.setAttribute("aria-current","page"),e.classList.add(...this.SELECTED_CLASSES),e.classList.remove(...this.UNSELECTED_CLASSES)):e.hasAttribute("aria-current")&&(e.removeAttribute("aria-current"),e.classList.add(...this.UNSELECTED_CLASSES),e.classList.remove(...this.SELECTED_CLASSES))}}Dl.targets=["tab"];var $l="top",Il="bottom",Rl="right",Bl="left",Fl=[$l,Il,Rl,Bl],Pl=Fl.reduce((function(t,e){return t.concat([e+"-start",e+"-end"])}),[]),Vl=[].concat(Fl,["auto"]).reduce((function(t,e){return t.concat([e,e+"-start",e+"-end"])}),[]),Ll=["beforeRead","read","afterRead","beforeMain","main","afterMain","beforeWrite","write","afterWrite"];function zl(t){return t?(t.nodeName||"").toLowerCase():null}function jl(t){if(null==t)return window;if("[object Window]"!==t.toString()){var e=t.ownerDocument;return e&&e.defaultView||window}return t}function _l(t){return t instanceof jl(t).Element||t instanceof Element}function Kl(t){return t instanceof jl(t).HTMLElement||t instanceof HTMLElement}function Wl(t){return"undefined"!=typeof ShadowRoot&&(t instanceof jl(t).ShadowRoot||t instanceof ShadowRoot)}var Hl={name:"applyStyles",enabled:!0,phase:"write",fn:function(t){var e=t.state;Object.keys(e.elements).forEach((function(t){var n=e.styles[t]||{},r=e.attributes[t]||{},i=e.elements[t];Kl(i)&&zl(i)&&(Object.assign(i.style,n),Object.keys(r).forEach((function(t){var e=r[t];!1===e?i.removeAttribute(t):i.setAttribute(t,!0===e?"":e)})))}))},effect:function(t){var e=t.state,n={popper:{position:e.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(e.elements.popper.style,n.popper),e.styles=n,e.elements.arrow&&Object.assign(e.elements.arrow.style,n.arrow),function(){Object.keys(e.elements).forEach((function(t){var r=e.elements[t],i=e.attributes[t]||{},s=Object.keys(e.styles.hasOwnProperty(t)?e.styles[t]:n[t]).reduce((function(t,e){return t[e]="",t}),{});Kl(r)&&zl(r)&&(Object.assign(r.style,s),Object.keys(i).forEach((function(t){r.removeAttribute(t)})))}))}},requires:["computeStyles"]};function ql(t){return t.split("-")[0]}var Jl=Math.max,Ul=Math.min,Gl=Math.round;function Yl(){var t=navigator.userAgentData;return null!=t&&t.brands&&Array.isArray(t.brands)?t.brands.map((function(t){return t.brand+"/"+t.version})).join(" "):navigator.userAgent}function Xl(){return!/^((?!chrome|android).)*safari/i.test(Yl())}function Zl(t,e,n){void 0===e&&(e=!1),void 0===n&&(n=!1);var r=t.getBoundingClientRect(),i=1,s=1;e&&Kl(t)&&(i=t.offsetWidth>0&&Gl(r.width)/t.offsetWidth||1,s=t.offsetHeight>0&&Gl(r.height)/t.offsetHeight||1);var o=(_l(t)?jl(t):window).visualViewport,a=!Xl()&&n,l=(r.left+(a&&o?o.offsetLeft:0))/i,c=(r.top+(a&&o?o.offsetTop:0))/s,h=r.width/i,d=r.height/s;return{width:h,height:d,top:c,right:l+h,bottom:c+d,left:l,x:l,y:c}}function Ql(t){var e=Zl(t),n=t.offsetWidth,r=t.offsetHeight;return Math.abs(e.width-n)<=1&&(n=e.width),Math.abs(e.height-r)<=1&&(r=e.height),{x:t.offsetLeft,y:t.offsetTop,width:n,height:r}}function tc(t,e){var n=e.getRootNode&&e.getRootNode();if(t.contains(e))return!0;if(n&&Wl(n)){var r=e;do{if(r&&t.isSameNode(r))return!0;r=r.parentNode||r.host}while(r)}return!1}function ec(t){return jl(t).getComputedStyle(t)}function nc(t){return["table","td","th"].indexOf(zl(t))>=0}function rc(t){return((_l(t)?t.ownerDocument:t.document)||window.document).documentElement}function ic(t){return"html"===zl(t)?t:t.assignedSlot||t.parentNode||(Wl(t)?t.host:null)||rc(t)}function sc(t){return Kl(t)&&"fixed"!==ec(t).position?t.offsetParent:null}function oc(t){for(var e=jl(t),n=sc(t);n&&nc(n)&&"static"===ec(n).position;)n=sc(n);return n&&("html"===zl(n)||"body"===zl(n)&&"static"===ec(n).position)?e:n||function(t){var e=/firefox/i.test(Yl());if(/Trident/i.test(Yl())&&Kl(t)&&"fixed"===ec(t).position)return null;var n=ic(t);for(Wl(n)&&(n=n.host);Kl(n)&&["html","body"].indexOf(zl(n))<0;){var r=ec(n);if("none"!==r.transform||"none"!==r.perspective||"paint"===r.contain||-1!==["transform","perspective"].indexOf(r.willChange)||e&&"filter"===r.willChange||e&&r.filter&&"none"!==r.filter)return n;n=n.parentNode}return null}(t)||e}function ac(t){return["top","bottom"].indexOf(t)>=0?"x":"y"}function lc(t,e,n){return Jl(t,Ul(e,n))}function cc(t){return Object.assign({},{top:0,right:0,bottom:0,left:0},t)}function hc(t,e){return e.reduce((function(e,n){return e[n]=t,e}),{})}var dc={name:"arrow",enabled:!0,phase:"main",fn:function(t){var e,n=t.state,r=t.name,i=t.options,s=n.elements.arrow,o=n.modifiersData.popperOffsets,a=ql(n.placement),l=ac(a),c=[Bl,Rl].indexOf(a)>=0?"height":"width";if(s&&o){var h=function(t,e){return cc("number"!=typeof(t="function"==typeof t?t(Object.assign({},e.rects,{placement:e.placement})):t)?t:hc(t,Fl))}(i.padding,n),d=Ql(s),u="y"===l?$l:Bl,p="y"===l?Il:Rl,f=n.rects.reference[c]+n.rects.reference[l]-o[l]-n.rects.popper[c],m=o[l]-n.rects.reference[l],g=oc(s),y=g?"y"===l?g.clientHeight||0:g.clientWidth||0:0,v=f/2-m/2,b=h[u],w=y-d[c]-h[p],x=y/2-d[c]/2+v,k=lc(b,x,w),S=l;n.modifiersData[r]=((e={})[S]=k,e.centerOffset=k-x,e)}},effect:function(t){var e=t.state,n=t.options.element,r=void 0===n?"[data-popper-arrow]":n;null!=r&&("string"!=typeof r||(r=e.elements.popper.querySelector(r)))&&tc(e.elements.popper,r)&&(e.elements.arrow=r)},requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function uc(t){return t.split("-")[1]}var pc={top:"auto",right:"auto",bottom:"auto",left:"auto"};function fc(t){var e,n=t.popper,r=t.popperRect,i=t.placement,s=t.variation,o=t.offsets,a=t.position,l=t.gpuAcceleration,c=t.adaptive,h=t.roundOffsets,d=t.isFixed,u=o.x,p=void 0===u?0:u,f=o.y,m=void 0===f?0:f,g="function"==typeof h?h({x:p,y:m}):{x:p,y:m};p=g.x,m=g.y;var y=o.hasOwnProperty("x"),v=o.hasOwnProperty("y"),b=Bl,w=$l,x=window;if(c){var k=oc(n),S="clientHeight",M="clientWidth";if(k===jl(n)&&"static"!==ec(k=rc(n)).position&&"absolute"===a&&(S="scrollHeight",M="scrollWidth"),i===$l||(i===Bl||i===Rl)&&"end"===s)w=Il,m-=(d&&k===x&&x.visualViewport?x.visualViewport.height:k[S])-r.height,m*=l?1:-1;if(i===Bl||(i===$l||i===Il)&&"end"===s)b=Rl,p-=(d&&k===x&&x.visualViewport?x.visualViewport.width:k[M])-r.width,p*=l?1:-1}var O,A=Object.assign({position:a},c&&pc),E=!0===h?function(t,e){var n=t.x,r=t.y,i=e.devicePixelRatio||1;return{x:Gl(n*i)/i||0,y:Gl(r*i)/i||0}}({x:p,y:m},jl(n)):{x:p,y:m};return p=E.x,m=E.y,l?Object.assign({},A,((O={})[w]=v?"0":"",O[b]=y?"0":"",O.transform=(x.devicePixelRatio||1)<=1?"translate("+p+"px, "+m+"px)":"translate3d("+p+"px, "+m+"px, 0)",O)):Object.assign({},A,((e={})[w]=v?m+"px":"",e[b]=y?p+"px":"",e.transform="",e))}var mc={passive:!0};var gc={left:"right",right:"left",bottom:"top",top:"bottom"};function yc(t){return t.replace(/left|right|bottom|top/g,(function(t){return gc[t]}))}var vc={start:"end",end:"start"};function bc(t){return t.replace(/start|end/g,(function(t){return vc[t]}))}function wc(t){var e=jl(t);return{scrollLeft:e.pageXOffset,scrollTop:e.pageYOffset}}function xc(t){return Zl(rc(t)).left+wc(t).scrollLeft}function kc(t){var e=ec(t),n=e.overflow,r=e.overflowX,i=e.overflowY;return/auto|scroll|overlay|hidden/.test(n+i+r)}function Sc(t){return["html","body","#document"].indexOf(zl(t))>=0?t.ownerDocument.body:Kl(t)&&kc(t)?t:Sc(ic(t))}function Mc(t,e){var n;void 0===e&&(e=[]);var r=Sc(t),i=r===(null==(n=t.ownerDocument)?void 0:n.body),s=jl(r),o=i?[s].concat(s.visualViewport||[],kc(r)?r:[]):r,a=e.concat(o);return i?a:a.concat(Mc(ic(o)))}function Oc(t){return Object.assign({},t,{left:t.x,top:t.y,right:t.x+t.width,bottom:t.y+t.height})}function Ac(t,e,n){return"viewport"===e?Oc(function(t,e){var n=jl(t),r=rc(t),i=n.visualViewport,s=r.clientWidth,o=r.clientHeight,a=0,l=0;if(i){s=i.width,o=i.height;var c=Xl();(c||!c&&"fixed"===e)&&(a=i.offsetLeft,l=i.offsetTop)}return{width:s,height:o,x:a+xc(t),y:l}}(t,n)):_l(e)?function(t,e){var n=Zl(t,!1,"fixed"===e);return n.top=n.top+t.clientTop,n.left=n.left+t.clientLeft,n.bottom=n.top+t.clientHeight,n.right=n.left+t.clientWidth,n.width=t.clientWidth,n.height=t.clientHeight,n.x=n.left,n.y=n.top,n}(e,n):Oc(function(t){var e,n=rc(t),r=wc(t),i=null==(e=t.ownerDocument)?void 0:e.body,s=Jl(n.scrollWidth,n.clientWidth,i?i.scrollWidth:0,i?i.clientWidth:0),o=Jl(n.scrollHeight,n.clientHeight,i?i.scrollHeight:0,i?i.clientHeight:0),a=-r.scrollLeft+xc(t),l=-r.scrollTop;return"rtl"===ec(i||n).direction&&(a+=Jl(n.clientWidth,i?i.clientWidth:0)-s),{width:s,height:o,x:a,y:l}}(rc(t)))}function Ec(t,e,n,r){var i="clippingParents"===e?function(t){var e=Mc(ic(t)),n=["absolute","fixed"].indexOf(ec(t).position)>=0&&Kl(t)?oc(t):t;return _l(n)?e.filter((function(t){return _l(t)&&tc(t,n)&&"body"!==zl(t)})):[]}(t):[].concat(e),s=[].concat(i,[n]),o=s[0],a=s.reduce((function(e,n){var i=Ac(t,n,r);return e.top=Jl(i.top,e.top),e.right=Ul(i.right,e.right),e.bottom=Ul(i.bottom,e.bottom),e.left=Jl(i.left,e.left),e}),Ac(t,o,r));return a.width=a.right-a.left,a.height=a.bottom-a.top,a.x=a.left,a.y=a.top,a}function Cc(t){var e,n=t.reference,r=t.element,i=t.placement,s=i?ql(i):null,o=i?uc(i):null,a=n.x+n.width/2-r.width/2,l=n.y+n.height/2-r.height/2;switch(s){case $l:e={x:a,y:n.y-r.height};break;case Il:e={x:a,y:n.y+n.height};break;case Rl:e={x:n.x+n.width,y:l};break;case Bl:e={x:n.x-r.width,y:l};break;default:e={x:n.x,y:n.y}}var c=s?ac(s):null;if(null!=c){var h="y"===c?"height":"width";switch(o){case"start":e[c]=e[c]-(n[h]/2-r[h]/2);break;case"end":e[c]=e[c]+(n[h]/2-r[h]/2)}}return e}function Tc(t,e){void 0===e&&(e={});var n=e,r=n.placement,i=void 0===r?t.placement:r,s=n.strategy,o=void 0===s?t.strategy:s,a=n.boundary,l=void 0===a?"clippingParents":a,c=n.rootBoundary,h=void 0===c?"viewport":c,d=n.elementContext,u=void 0===d?"popper":d,p=n.altBoundary,f=void 0!==p&&p,m=n.padding,g=void 0===m?0:m,y=cc("number"!=typeof g?g:hc(g,Fl)),v="popper"===u?"reference":"popper",b=t.rects.popper,w=t.elements[f?v:u],x=Ec(_l(w)?w:w.contextElement||rc(t.elements.popper),l,h,o),k=Zl(t.elements.reference),S=Cc({reference:k,element:b,strategy:"absolute",placement:i}),M=Oc(Object.assign({},b,S)),O="popper"===u?M:k,A={top:x.top-O.top+y.top,bottom:O.bottom-x.bottom+y.bottom,left:x.left-O.left+y.left,right:O.right-x.right+y.right},E=t.modifiersData.offset;if("popper"===u&&E){var C=E[i];Object.keys(A).forEach((function(t){var e=[Rl,Il].indexOf(t)>=0?1:-1,n=[$l,Il].indexOf(t)>=0?"y":"x";A[t]+=C[n]*e}))}return A}function Nc(t,e){void 0===e&&(e={});var n=e,r=n.placement,i=n.boundary,s=n.rootBoundary,o=n.padding,a=n.flipVariations,l=n.allowedAutoPlacements,c=void 0===l?Vl:l,h=uc(r),d=h?a?Pl:Pl.filter((function(t){return uc(t)===h})):Fl,u=d.filter((function(t){return c.indexOf(t)>=0}));0===u.length&&(u=d);var p=u.reduce((function(e,n){return e[n]=Tc(t,{placement:n,boundary:i,rootBoundary:s,padding:o})[ql(n)],e}),{});return Object.keys(p).sort((function(t,e){return p[t]-p[e]}))}var Dc={name:"flip",enabled:!0,phase:"main",fn:function(t){var e=t.state,n=t.options,r=t.name;if(!e.modifiersData[r]._skip){for(var i=n.mainAxis,s=void 0===i||i,o=n.altAxis,a=void 0===o||o,l=n.fallbackPlacements,c=n.padding,h=n.boundary,d=n.rootBoundary,u=n.altBoundary,p=n.flipVariations,f=void 0===p||p,m=n.allowedAutoPlacements,g=e.options.placement,y=ql(g),v=l||(y===g||!f?[yc(g)]:function(t){if("auto"===ql(t))return[];var e=yc(t);return[bc(t),e,bc(e)]}(g)),b=[g].concat(v).reduce((function(t,n){return t.concat("auto"===ql(n)?Nc(e,{placement:n,boundary:h,rootBoundary:d,padding:c,flipVariations:f,allowedAutoPlacements:m}):n)}),[]),w=e.rects.reference,x=e.rects.popper,k=new Map,S=!0,M=b[0],O=0;O<b.length;O++){var A=b[O],E=ql(A),C="start"===uc(A),T=[$l,Il].indexOf(E)>=0,N=T?"width":"height",D=Tc(e,{placement:A,boundary:h,rootBoundary:d,altBoundary:u,padding:c}),$=T?C?Rl:Bl:C?Il:$l;w[N]>x[N]&&($=yc($));var I=yc($),R=[];if(s&&R.push(D[E]<=0),a&&R.push(D[$]<=0,D[I]<=0),R.every((function(t){return t}))){M=A,S=!1;break}k.set(A,R)}if(S)for(var B=function(t){var e=b.find((function(e){var n=k.get(e);if(n)return n.slice(0,t).every((function(t){return t}))}));if(e)return M=e,"break"},F=f?3:1;F>0;F--){if("break"===B(F))break}e.placement!==M&&(e.modifiersData[r]._skip=!0,e.placement=M,e.reset=!0)}},requiresIfExists:["offset"],data:{_skip:!1}};function $c(t,e,n){return void 0===n&&(n={x:0,y:0}),{top:t.top-e.height-n.y,right:t.right-e.width+n.x,bottom:t.bottom-e.height+n.y,left:t.left-e.width-n.x}}function Ic(t){return[$l,Rl,Il,Bl].some((function(e){return t[e]>=0}))}var Rc={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:function(t){var e=t.state,n=t.options,r=t.name,i=n.offset,s=void 0===i?[0,0]:i,o=Vl.reduce((function(t,n){return t[n]=function(t,e,n){var r=ql(t),i=[Bl,$l].indexOf(r)>=0?-1:1,s="function"==typeof n?n(Object.assign({},e,{placement:t})):n,o=s[0],a=s[1];return o=o||0,a=(a||0)*i,[Bl,Rl].indexOf(r)>=0?{x:a,y:o}:{x:o,y:a}}(n,e.rects,s),t}),{}),a=o[e.placement],l=a.x,c=a.y;null!=e.modifiersData.popperOffsets&&(e.modifiersData.popperOffsets.x+=l,e.modifiersData.popperOffsets.y+=c),e.modifiersData[r]=o}};var Bc={name:"preventOverflow",enabled:!0,phase:"main",fn:function(t){var e=t.state,n=t.options,r=t.name,i=n.mainAxis,s=void 0===i||i,o=n.altAxis,a=void 0!==o&&o,l=n.boundary,c=n.rootBoundary,h=n.altBoundary,d=n.padding,u=n.tether,p=void 0===u||u,f=n.tetherOffset,m=void 0===f?0:f,g=Tc(e,{boundary:l,rootBoundary:c,padding:d,altBoundary:h}),y=ql(e.placement),v=uc(e.placement),b=!v,w=ac(y),x="x"===w?"y":"x",k=e.modifiersData.popperOffsets,S=e.rects.reference,M=e.rects.popper,O="function"==typeof m?m(Object.assign({},e.rects,{placement:e.placement})):m,A="number"==typeof O?{mainAxis:O,altAxis:O}:Object.assign({mainAxis:0,altAxis:0},O),E=e.modifiersData.offset?e.modifiersData.offset[e.placement]:null,C={x:0,y:0};if(k){if(s){var T,N="y"===w?$l:Bl,D="y"===w?Il:Rl,$="y"===w?"height":"width",I=k[w],R=I+g[N],B=I-g[D],F=p?-M[$]/2:0,P="start"===v?S[$]:M[$],V="start"===v?-M[$]:-S[$],L=e.elements.arrow,z=p&&L?Ql(L):{width:0,height:0},j=e.modifiersData["arrow#persistent"]?e.modifiersData["arrow#persistent"].padding:{top:0,right:0,bottom:0,left:0},_=j[N],K=j[D],W=lc(0,S[$],z[$]),H=b?S[$]/2-F-W-_-A.mainAxis:P-W-_-A.mainAxis,q=b?-S[$]/2+F+W+K+A.mainAxis:V+W+K+A.mainAxis,J=e.elements.arrow&&oc(e.elements.arrow),U=J?"y"===w?J.clientTop||0:J.clientLeft||0:0,G=null!=(T=null==E?void 0:E[w])?T:0,Y=I+q-G,X=lc(p?Ul(R,I+H-G-U):R,I,p?Jl(B,Y):B);k[w]=X,C[w]=X-I}if(a){var Z,Q="x"===w?$l:Bl,tt="x"===w?Il:Rl,et=k[x],nt="y"===x?"height":"width",rt=et+g[Q],it=et-g[tt],st=-1!==[$l,Bl].indexOf(y),ot=null!=(Z=null==E?void 0:E[x])?Z:0,at=st?rt:et-S[nt]-M[nt]-ot+A.altAxis,lt=st?et+S[nt]+M[nt]-ot-A.altAxis:it,ct=p&&st?function(t,e,n){var r=lc(t,e,n);return r>n?n:r}(at,et,lt):lc(p?at:rt,et,p?lt:it);k[x]=ct,C[x]=ct-et}e.modifiersData[r]=C}},requiresIfExists:["offset"]};function Fc(t,e,n){void 0===n&&(n=!1);var r,i,s=Kl(e),o=Kl(e)&&function(t){var e=t.getBoundingClientRect(),n=Gl(e.width)/t.offsetWidth||1,r=Gl(e.height)/t.offsetHeight||1;return 1!==n||1!==r}(e),a=rc(e),l=Zl(t,o,n),c={scrollLeft:0,scrollTop:0},h={x:0,y:0};return(s||!s&&!n)&&(("body"!==zl(e)||kc(a))&&(c=(r=e)!==jl(r)&&Kl(r)?{scrollLeft:(i=r).scrollLeft,scrollTop:i.scrollTop}:wc(r)),Kl(e)?((h=Zl(e,!0)).x+=e.clientLeft,h.y+=e.clientTop):a&&(h.x=xc(a))),{x:l.left+c.scrollLeft-h.x,y:l.top+c.scrollTop-h.y,width:l.width,height:l.height}}function Pc(t){var e=new Map,n=new Set,r=[];function i(t){n.add(t.name),[].concat(t.requires||[],t.requiresIfExists||[]).forEach((function(t){if(!n.has(t)){var r=e.get(t);r&&i(r)}})),r.push(t)}return t.forEach((function(t){e.set(t.name,t)})),t.forEach((function(t){n.has(t.name)||i(t)})),r}var Vc={placement:"bottom",modifiers:[],strategy:"absolute"};function Lc(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return!e.some((function(t){return!(t&&"function"==typeof t.getBoundingClientRect)}))}function zc(t){void 0===t&&(t={});var e=t,n=e.defaultModifiers,r=void 0===n?[]:n,i=e.defaultOptions,s=void 0===i?Vc:i;return function(t,e,n){void 0===n&&(n=s);var i,o,a={placement:"bottom",orderedModifiers:[],options:Object.assign({},Vc,s),modifiersData:{},elements:{reference:t,popper:e},attributes:{},styles:{}},l=[],c=!1,h={state:a,setOptions:function(n){var i="function"==typeof n?n(a.options):n;d(),a.options=Object.assign({},s,a.options,i),a.scrollParents={reference:_l(t)?Mc(t):t.contextElement?Mc(t.contextElement):[],popper:Mc(e)};var o=function(t){var e=Pc(t);return Ll.reduce((function(t,n){return t.concat(e.filter((function(t){return t.phase===n})))}),[])}(function(t){var e=t.reduce((function(t,e){var n=t[e.name];return t[e.name]=n?Object.assign({},n,e,{options:Object.assign({},n.options,e.options),data:Object.assign({},n.data,e.data)}):e,t}),{});return Object.keys(e).map((function(t){return e[t]}))}([].concat(r,a.options.modifiers)));return a.orderedModifiers=o.filter((function(t){return t.enabled})),a.orderedModifiers.forEach((function(t){var e=t.name,n=t.options,r=void 0===n?{}:n,i=t.effect;if("function"==typeof i){var s=i({state:a,name:e,instance:h,options:r}),o=function(){};l.push(s||o)}})),h.update()},forceUpdate:function(){if(!c){var t=a.elements,e=t.reference,n=t.popper;if(Lc(e,n)){a.rects={reference:Fc(e,oc(n),"fixed"===a.options.strategy),popper:Ql(n)},a.reset=!1,a.placement=a.options.placement,a.orderedModifiers.forEach((function(t){return a.modifiersData[t.name]=Object.assign({},t.data)}));for(var r=0;r<a.orderedModifiers.length;r++)if(!0!==a.reset){var i=a.orderedModifiers[r],s=i.fn,o=i.options,l=void 0===o?{}:o,d=i.name;"function"==typeof s&&(a=s({state:a,options:l,name:d,instance:h})||a)}else a.reset=!1,r=-1}}},update:(i=function(){return new Promise((function(t){h.forceUpdate(),t(a)}))},function(){return o||(o=new Promise((function(t){Promise.resolve().then((function(){o=void 0,t(i())}))}))),o}),destroy:function(){d(),c=!0}};if(!Lc(t,e))return h;function d(){l.forEach((function(t){return t()})),l=[]}return h.setOptions(n).then((function(t){!c&&n.onFirstUpdate&&n.onFirstUpdate(t)})),h}}var jc=zc({defaultModifiers:[{name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:function(t){var e=t.state,n=t.instance,r=t.options,i=r.scroll,s=void 0===i||i,o=r.resize,a=void 0===o||o,l=jl(e.elements.popper),c=[].concat(e.scrollParents.reference,e.scrollParents.popper);return s&&c.forEach((function(t){t.addEventListener("scroll",n.update,mc)})),a&&l.addEventListener("resize",n.update,mc),function(){s&&c.forEach((function(t){t.removeEventListener("scroll",n.update,mc)})),a&&l.removeEventListener("resize",n.update,mc)}},data:{}},{name:"popperOffsets",enabled:!0,phase:"read",fn:function(t){var e=t.state,n=t.name;e.modifiersData[n]=Cc({reference:e.rects.reference,element:e.rects.popper,strategy:"absolute",placement:e.placement})},data:{}},{name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:function(t){var e=t.state,n=t.options,r=n.gpuAcceleration,i=void 0===r||r,s=n.adaptive,o=void 0===s||s,a=n.roundOffsets,l=void 0===a||a,c={placement:ql(e.placement),variation:uc(e.placement),popper:e.elements.popper,popperRect:e.rects.popper,gpuAcceleration:i,isFixed:"fixed"===e.options.strategy};null!=e.modifiersData.popperOffsets&&(e.styles.popper=Object.assign({},e.styles.popper,fc(Object.assign({},c,{offsets:e.modifiersData.popperOffsets,position:e.options.strategy,adaptive:o,roundOffsets:l})))),null!=e.modifiersData.arrow&&(e.styles.arrow=Object.assign({},e.styles.arrow,fc(Object.assign({},c,{offsets:e.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:l})))),e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-placement":e.placement})},data:{}},Hl,Rc,Dc,Bc,dc,{name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:function(t){var e=t.state,n=t.name,r=e.rects.reference,i=e.rects.popper,s=e.modifiersData.preventOverflow,o=Tc(e,{elementContext:"reference"}),a=Tc(e,{altBoundary:!0}),l=$c(o,r),c=$c(a,i,s),h=Ic(l),d=Ic(c);e.modifiersData[n]={referenceClippingOffsets:l,popperEscapeOffsets:c,isReferenceHidden:h,hasPopperEscaped:d},e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-reference-hidden":h,"data-popper-escaped":d})}}]});class _c extends X{connect(){this.popperInstance=jc(this.triggerTarget,this.tooltipTarget,{placement:this.placementValue,modifiers:[{name:"offset",options:{offset:this.offsetValue}}]})}disconnect(){this.popperInstance&&this.popperInstance.destroy()}show(){this.tooltipTarget.setAttribute("data-tooltip-show",""),this.tooltipTarget.classList.remove("ariadne-invisible"),this.popperInstance.update(),this.dispatch("shown",{detail:{trigger:this.triggerTarget,tooltip:this.tooltipTarget}})}hide(){this.tooltipTarget.removeAttribute("data-tooltip-show"),this.tooltipTarget.classList.add("ariadne-invisible"),this.dispatch("ariadne-hidden",{detail:{trigger:this.triggerTarget,tooltip:this.tooltipTarget}})}}function Kc(t){return Array.from(t.querySelectorAll('[role="tablist"] [role="tab"]')).filter((e=>e instanceof HTMLElement&&e.closest(t.tagName)===t))}_c.targets=["trigger","tooltip"],_c.values={placement:{type:String,default:"top"},offset:{type:Array,default:[0,8]}};class Wc extends HTMLElement{constructor(){super(),this.addEventListener("keydown",(t=>{const e=t.target;if(!(e instanceof HTMLElement))return;if(e.closest(this.tagName)!==this)return;if("tab"!==e.getAttribute("role")&&!e.closest('[role="tablist"]'))return;const n=Kc(this),r=n.indexOf(n.find((t=>t.matches('[aria-selected="true"]')))),[i,s]="vertical"===e.closest('[role="tablist"]')?.getAttribute("aria-orientation")?[["ArrowDown","ArrowRight"],["ArrowUp","ArrowLeft"]]:[["ArrowRight"],["ArrowLeft"]];if(i.some((e=>t.code===e))){let t=r+1;t>=n.length&&(t=0),this.selectTab(t)}else if(s.some((e=>t.code===e))){let t=r-1;t<0&&(t=n.length-1),this.selectTab(t)}else"Home"===t.code?(this.selectTab(0),t.preventDefault()):"End"===t.code&&(this.selectTab(n.length-1),t.preventDefault())})),this.addEventListener("click",(t=>{const e=Kc(this);if(!(t.target instanceof Element))return;if(t.target.closest(this.tagName)!==this)return;const n=t.target.closest('[role="tab"]');if(!(n instanceof HTMLElement&&n.closest('[role="tablist"]')))return;const r=e.indexOf(n);this.selectTab(r)}))}connectedCallback(){for(const t of Kc(this))t.hasAttribute("aria-selected")||t.setAttribute("aria-selected","false"),t.hasAttribute("tabindex")||("true"===t.getAttribute("aria-selected")?t.setAttribute("tabindex","0"):t.setAttribute("tabindex","-1"))}selectTab(t){const e=Kc(this),n=Array.from(this.querySelectorAll('[role="tabpanel"]')).filter((t=>t.closest(this.tagName)===this));if(t>e.length-1)throw new RangeError(`Index "${t}" out of bounds`);const r=e[t],i=n[t];if(!!this.dispatchEvent(new CustomEvent("tab-container-change",{bubbles:!0,cancelable:!0,detail:{relatedTarget:i}}))){for(const t of e)t.setAttribute("aria-selected","false"),t.setAttribute("tabindex","-1");for(const t of n)t.hidden=!0,t.hasAttribute("tabindex")||t.hasAttribute("data-tab-container-no-tabstop")||t.setAttribute("tabindex","0");r.setAttribute("aria-selected","true"),r.setAttribute("tabindex","0"),r.focus(),i.hidden=!1,this.dispatchEvent(new CustomEvent("tab-container-changed",{bubbles:!0,detail:{relatedTarget:i}}))}}}window.customElements.get("tab-container")||(window.TabContainerElement=Wc,window.customElements.define("tab-container",Wc));const Hc=["ariadne-border-slate-500","ariadne-text-slate-600"],qc=["ariadne-text-gray-500","hover:ariadne-text-gray-700","hover:ariadne-border-gray-300"];for(const t of document.getElementsByTagName("tab-container"))t.addEventListener("tab-container-change",(function(t){var e;const n=t.detail.relatedTarget,r=n.closest("tab-container").firstElementChild,i=r.querySelector('[aria-selected="true"]'),s=null===(e=n.getAttribute("id"))||void 0===e?void 0:e.split("-").slice(1).join("-"),o=r.querySelector(`#${s}`);i.classList.remove(...Hc),i.classList.add(...qc),o.classList.add(...Hc),o.classList.remove(...qc)}));const Jc=["second","minute","hour","day","month","year"];const Uc=/^[-+]?P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)W)?(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?)?$/;class Gc{constructor(t=0,e=0,n=0,r=0,i=0,s=0,o=0){this.years=t,this.months=e,this.weeks=n,this.days=r,this.hours=i,this.minutes=s,this.seconds=o}abs(){return new Gc(Math.abs(this.years),Math.abs(this.months),Math.abs(this.weeks),Math.abs(this.days),Math.abs(this.hours),Math.abs(this.minutes),Math.abs(this.seconds))}static from(t){var e;if("string"==typeof t){const n=String(t).trim(),r=n.startsWith("-")?-1:1,i=null===(e=n.match(Uc))||void 0===e?void 0:e.slice(1).map((t=>(Number(t)||0)*r));return i?new Gc(...i):new Gc}if("object"==typeof t){const{years:e,months:n,weeks:r,days:i,hours:s,minutes:o,seconds:a}=t;return new Gc(e,n,r,i,s,o,a)}throw new RangeError("invalid duration")}}function Yc(t,e,n){const r=function(t,e){const n=new Date(t);return n.setFullYear(n.getFullYear()+e.years),n.setMonth(n.getMonth()+e.months),n.setDate(n.getDate()+7*e.weeks+e.days),n.setHours(n.getHours()+e.hours),n.setMinutes(n.getMinutes()+e.minutes),n.setSeconds(n.getSeconds()+e.seconds),n}(t,Gc.from(n).abs());return!r||Math.abs(Number(r)-Number(t))>Math.abs(Number(t)-Number(e))}var Xc,Zc,Qc,th,eh,nh,rh,ih=function(t,e,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(t):r?r.value:e.get(t)},sh=function(t,e,n,r,i){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?i.call(t,n):i?i.value=n:e.set(t,n),n};const oh=("undefined"!=typeof globalThis?globalThis:window).HTMLElement||null;class ah extends Event{constructor(t,e,n,r){super("relative-time-updated",{bubbles:!0,composed:!0}),this.oldText=t,this.newText=e,this.oldTitle=n,this.newTitle=r}}function lh(t){if(!t.date)return 1/0;if("elapsed"===t.format){const e=t.precision;if("second"===e)return 1e3;if("minute"===e)return 6e4}const e=Math.abs(Date.now()-t.date.getTime());return e<6e4?1e3:e<36e5?6e4:36e5}const ch=new class{constructor(){this.elements=new Set,this.time=1/0,this.timer=-1}observe(t){if(this.elements.has(t))return;this.elements.add(t);const e=t.date;if(e&&e.getTime()){const e=lh(t),n=Date.now()+e;n<this.time&&(clearTimeout(this.timer),this.timer=setTimeout((()=>this.update()),e),this.time=n)}}unobserve(t){this.elements.has(t)&&this.elements.delete(t)}update(){if(clearTimeout(this.timer),!this.elements.size)return;let t=1/0;for(const e of this.elements)t=Math.min(t,lh(e)),e.update();this.time=Math.min(36e5,t),this.timer=setTimeout((()=>this.update()),this.time),this.time+=Date.now()}};class hh extends oh{constructor(){super(...arguments),Xc.add(this),Zc.set(this,!1),Qc.set(this,!1),eh.set(this,this.shadowRoot?this.shadowRoot:this.attachShadow?this.attachShadow({mode:"open"}):this)}static get observedAttributes(){return["second","minute","hour","weekday","day","month","year","time-zone-name","prefix","threshold","tense","precision","format","datetime","lang","title"]}get second(){const t=this.getAttribute("second");if("numeric"===t||"2-digit"===t)return t}set second(t){this.setAttribute("second",t||"")}get minute(){const t=this.getAttribute("minute");if("numeric"===t||"2-digit"===t)return t}set minute(t){this.setAttribute("minute",t||"")}get hour(){const t=this.getAttribute("hour");if("numeric"===t||"2-digit"===t)return t}set hour(t){this.setAttribute("hour",t||"")}get weekday(){const t=this.getAttribute("weekday");if("long"===t||"short"===t||"narrow"===t)return t}set weekday(t){this.setAttribute("weekday",t||"")}get day(){var t;const e=null!==(t=this.getAttribute("day"))&&void 0!==t?t:"numeric";if("numeric"===e||"2-digit"===e)return e}set day(t){this.setAttribute("day",t||"")}get month(){var t;const e=null!==(t=this.getAttribute("month"))&&void 0!==t?t:"short";if("numeric"===e||"2-digit"===e||"short"===e||"long"===e||"narrow"===e)return e}set month(t){this.setAttribute("month",t||"")}get year(){var t;const e=this.getAttribute("year");return"numeric"===e||"2-digit"===e?e:this.hasAttribute("year")||(new Date).getUTCFullYear()===(null===(t=this.date)||void 0===t?void 0:t.getUTCFullYear())?void 0:"numeric"}set year(t){this.setAttribute("day",t||"")}get timeZoneName(){const t=this.getAttribute("time-zone-name");if("long"===t||"short"===t||"shortOffset"===t||"longOffset"===t||"shortGeneric"===t||"longGeneric"===t)return t}set timeZoneName(t){this.setAttribute("time-zone-name",t||"")}get prefix(){var t;return null!==(t=this.getAttribute("prefix"))&&void 0!==t?t:"on"}set prefix(t){this.setAttribute("prefix",t)}get threshold(){const t=this.getAttribute("threshold");return t&&(e=t,Uc.test(e))?t:"P30D";var e}set threshold(t){this.setAttribute("threshold",t)}get tense(){const t=this.getAttribute("tense");return"past"===t?"past":"future"===t?"future":"auto"}set tense(t){this.setAttribute("tense",t)}get precision(){const t=this.getAttribute("precision");return Jc.includes(t)?t:"second"}set precision(t){this.setAttribute("precision",t)}get format(){const t=this.getAttribute("format");return"micro"===t?"micro":"elapsed"===t?"elapsed":"auto"}set format(t){this.setAttribute("format",t)}get datetime(){return this.getAttribute("datetime")||""}set datetime(t){this.setAttribute("datetime",t)}get date(){const t=Date.parse(this.datetime);return Number.isNaN(t)?null:new Date(t)}set date(t){this.datetime=(null==t?void 0:t.toISOString())||""}connectedCallback(){this.update()}disconnectedCallback(){ch.unobserve(this)}attributeChangedCallback(t,e,n){e!==n&&("title"===t&&sh(this,Zc,null!==n&&ih(this,Xc,"m",nh).call(this)!==n,"f"),ih(this,Qc,"f")||"title"===t&&ih(this,Zc,"f")||sh(this,Qc,(async()=>{await Promise.resolve(),this.update()})(),"f"))}update(){const t=ih(this,eh,"f").textContent||"",e=this.getAttribute("title")||"";let n=e,r=t;const i=new Date;ih(this,Zc,"f")||(n=ih(this,Xc,"m",nh).call(this)||"",n&&this.setAttribute("title",n)),r=ih(this,Xc,"m",rh).call(this,i)||"",r?ih(this,eh,"f").textContent=r:this.shadowRoot===ih(this,eh,"f")&&this.textContent&&(ih(this,eh,"f").textContent=this.textContent),r===t&&n===e||this.dispatchEvent(new ah(t,r,e,n));const s=this.date,o=this.format,a=("auto"===o||"micro"===o)&&s&&Yc(i,s,this.threshold);"elapsed"===o||a?ch.observe(this):ch.unobserve(this),sh(this,Qc,!1,"f")}}Zc=new WeakMap,Qc=new WeakMap,eh=new WeakMap,Xc=new WeakSet,th=function(){var t,e;return null!==(e=null===(t=this.closest("[lang]"))||void 0===t?void 0:t.getAttribute("lang"))&&void 0!==e?e:"default"},nh=function(){const t=this.date;if(t&&"undefined"!=typeof Intl&&Intl.DateTimeFormat)return new Intl.DateTimeFormat(ih(this,Xc,"a",th),{day:"numeric",month:"short",year:"numeric",hour:"numeric",minute:"2-digit",timeZoneName:"short"}).format(t)},rh=function(t=new Date){const e=this.date;if(!e)return;const n=this.format;if("elapsed"===n){const t=Jc.indexOf(this.precision)||0,n=function(t){const e=Math.abs(t.getTime()-(new Date).getTime()),n=Math.floor(e/1e3),r=Math.floor(n/60),i=Math.floor(r/60),s=Math.floor(i/24),o=Math.floor(s/30),a=Math.floor(o/12),l=[];return a&&l.push([a,"year"]),o-12*a&&l.push([o-12*a,"month"]),s-30*o&&l.push([s-30*o,"day"]),i-24*s&&l.push([i-24*s,"hour"]),r-60*i&&l.push([r-60*i,"minute"]),n-60*r&&l.push([n-60*r,"second"]),l}(e).filter((e=>Jc.indexOf(e[1])>=t));return n.map((([t,e])=>`${t}${e[0]}`)).join(" ")||`0${this.precision[0]}`}const r=this.tense,i="micro"===n,s=t.getTime()<e.getTime(),o=Yc(t,e,this.threshold),a=ih(this,Xc,"a",th);if("undefined"!=typeof Intl&&Intl.RelativeTimeFormat){const t=new Intl.RelativeTimeFormat(a,{numeric:"auto"});if("past"===r||"auto"===r&&!s&&o){const[n,r]=i?function(t){const e=(new Date).getTime()-t.getTime(),n=Math.round(e/1e3),r=Math.round(n/60),i=Math.round(r/60),s=Math.round(i/24),o=Math.round(s/30),a=Math.round(o/12);return r<1?[1,"minute"]:r<60?[r,"minute"]:i<24?[i,"hour"]:s<365?[s,"day"]:[a,"year"]}(e):function(t){const e=(new Date).getTime()-t.getTime(),n=Math.round(e/1e3),r=Math.round(n/60),i=Math.round(r/60),s=Math.round(i/24),o=Math.round(s/30),a=Math.round(o/12);return e<0||n<10?[0,"second"]:n<45?[-n,"second"]:n<90||r<45?[-r,"minute"]:r<90||i<24?[-i,"hour"]:i<36||s<30?[-s,"day"]:o<18?[-o,"month"]:[-a,"year"]}(e);return i?`${n}${r[0]}`:t.format(n,r)}if("future"===r||"auto"===r&&s&&o){const[n,r]=i?function(t){const e=t.getTime()-(new Date).getTime(),n=Math.round(e/1e3),r=Math.round(n/60),i=Math.round(r/60),s=Math.round(i/24),o=Math.round(s/30),a=Math.round(o/12);return s>=365?[a,"year"]:i>=24?[s,"day"]:r>=60?[i,"hour"]:r>1?[r,"minute"]:[1,"minute"]}(e):function(t){const e=t.getTime()-(new Date).getTime(),n=Math.round(e/1e3),r=Math.round(n/60),i=Math.round(r/60),s=Math.round(i/24),o=Math.round(s/30),a=Math.round(o/12);return o>=18||o>=12?[a,"year"]:s>=45||s>=30?[o,"month"]:i>=36||i>=24?[s,"day"]:r>=90||r>=45?[i,"hour"]:n>=90||n>=45?[r,"minute"]:n>=10?[n,"second"]:[0,"second"]}(e);return i?`${n}${r[0]}`:t.format(n,r)}}if("undefined"==typeof Intl||!Intl.DateTimeFormat)return;const l=new Intl.DateTimeFormat(a,{second:this.second,minute:this.minute,hour:this.hour,weekday:this.weekday,day:this.day,month:this.month,year:this.year,timeZoneName:this.timeZoneName});return`${this.prefix} ${l.format(e)}`.trim()};const dh="undefined"!=typeof globalThis?globalThis:window;try{customElements.define("relative-time",hh),dh.RelativeTimeElement=hh}catch(et){if(!(dh.DOMException&&et instanceof DOMException&&"NotSupportedError"===et.name||et instanceof ReferenceError))throw et}const uh=class{constructor(t=document.documentElement,r=_){this.logger=console,this.debug=!1,this.logDebugActivity=(t,e,n={})=>{this.debug&&this.logFormattedMessage(t,e,n)},this.element=t,this.schema=r,this.dispatcher=new e(this),this.router=new j(this),this.actionDescriptorFilters=Object.assign({},n)}static start(t,e){const n=new this(t,e);return n.start(),n}async start(){await new Promise((t=>{"loading"==document.readyState?document.addEventListener("DOMContentLoaded",(()=>t())):t()})),this.logDebugActivity("application","starting"),this.dispatcher.start(),this.router.start(),this.logDebugActivity("application","start")}stop(){this.logDebugActivity("application","stopping"),this.dispatcher.stop(),this.router.stop(),this.logDebugActivity("application","stop")}register(t,e){this.load({identifier:t,controllerConstructor:e})}registerActionOption(t,e){this.actionDescriptorFilters[t]=e}load(t,...e){(Array.isArray(t)?t:[t,...e]).forEach((t=>{t.controllerConstructor.shouldLoad&&this.router.loadDefinition(t)}))}unload(t,...e){(Array.isArray(t)?t:[t,...e]).forEach((t=>this.router.unloadIdentifier(t)))}get controllers(){return this.router.contexts.map((t=>t.controller))}getControllerForElementAndIdentifier(t,e){const n=this.router.getContextForElementAndIdentifier(t,e);return n?n.controller:null}handleError(t,e,n){var r;this.logger.error("%s\n\n%o\n\n%o",e,t,n),null===(r=window.onerror)||void 0===r||r.call(window,e,"",0,0,t)}logFormattedMessage(t,e,n={}){n=Object.assign({application:this},n),this.logger.groupCollapsed(`${t} #${e}`),this.logger.log("details:",Object.assign({},n)),this.logger.groupEnd()}}.start();uh.register("clipboard-copy-component",class extends X{copy(){const t=this.element.attributes.getNamedItem("value"),e=this.element.attributes.getNamedItem("for");if(t)navigator.clipboard.writeText(t.value);else if(e){const t=document.getElementById(e.value);navigator.clipboard.writeText((null==t?void 0:t.textContent)||"")}else navigator.clipboard.writeText(this.element.textContent||"")}}),uh.register("ariadne-form",Bt),uh.register("rich-text-area-component",Tl),uh.register("slideover-component",Nl),uh.register("tab-nav-component",Dl),uh.register("tooltip-component",_c),uh.register("toggleable",Ut),uh.register("accumulator",jt),uh.register("options",zt);
8
8
  //# sourceMappingURL=ariadne_view_components.js.map