satis 2.0.7 → 2.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/gem-push.yml +11 -0
- data/.gitignore +15 -0
- data/.nvmrc +1 -0
- data/.rubocop.yml +18 -0
- data/Gemfile +27 -0
- data/Procfile +2 -0
- data/TODO.md +26 -0
- data/app/assets/images/satis/.keep +0 -0
- data/bin/importmap +4 -0
- data/bin/rails +14 -0
- data/lib/satis/version.rb +1 -1
- data/package.json +9 -0
- data/satis.gemspec +39 -0
- data/vendor/javascript/@codemirror--autocomplete.js +2 -0
- data/vendor/javascript/@codemirror--commands.js +2 -0
- data/vendor/javascript/@codemirror--lang-css.js +2 -0
- data/vendor/javascript/@codemirror--lang-html.js +2 -0
- data/vendor/javascript/@codemirror--lang-javascript.js +2 -0
- data/vendor/javascript/@codemirror--lang-json.js +2 -0
- data/vendor/javascript/@codemirror--lang-liquid.js +2 -0
- data/vendor/javascript/@codemirror--lang-markdown.js +2 -0
- data/vendor/javascript/@codemirror--lang-yaml.js +2 -0
- data/vendor/javascript/@codemirror--language.js +2 -0
- data/vendor/javascript/@codemirror--lint.js +2 -0
- data/vendor/javascript/@codemirror--search.js +2 -0
- data/vendor/javascript/@codemirror--state.js +2 -0
- data/vendor/javascript/@codemirror--view.js +2 -0
- data/vendor/javascript/@lezer--common.js +2 -0
- data/vendor/javascript/@lezer--css.js +2 -0
- data/vendor/javascript/@lezer--highlight.js +2 -0
- data/vendor/javascript/@lezer--html.js +2 -0
- data/vendor/javascript/@lezer--javascript.js +2 -0
- data/vendor/javascript/@lezer--json.js +2 -0
- data/vendor/javascript/@lezer--lr.js +2 -0
- data/vendor/javascript/@lezer--markdown.js +2 -0
- data/vendor/javascript/@lezer--yaml.js +2 -0
- data/vendor/javascript/@rails--actiontext.js +2 -0
- data/vendor/javascript/codemirror.js +2 -0
- data/vendor/javascript/crelt.js +2 -0
- data/vendor/javascript/data.min.js +7 -0
- data/vendor/javascript/intl-tel-input-utils.js +520 -0
- data/vendor/javascript/intl-tel-input.js +1782 -0
- data/vendor/javascript/leaflet.js +6 -0
- data/vendor/javascript/popper.js.js +1805 -0
- data/vendor/javascript/sortablejs.js +134 -0
- data/vendor/javascript/style-mod.js +2 -0
- data/vendor/javascript/tippy.js.js +2 -0
- data/vendor/javascript/trix.js +2 -0
- data/vendor/javascript/w3c-keyname.js +2 -0
- data/yarn.lock +821 -0
- metadata +51 -2
@@ -0,0 +1,2 @@
|
|
1
|
+
var t="2.0.10";const o="[data-trix-attachment]",s={preview:{presentation:"gallery",caption:{name:!0,size:!0}},file:{caption:{size:!0}}},a={default:{tagName:"div",parse:!1},quote:{tagName:"blockquote",nestable:!0},heading1:{tagName:"h1",terminal:!0,breakOnReturn:!0,group:!1},code:{tagName:"pre",terminal:!0,text:{plaintext:!0}},bulletList:{tagName:"ul",parse:!1},bullet:{tagName:"li",listAttribute:"bulletList",group:!1,nestable:!0,test(t){return r(t.parentNode)===a[this.listAttribute].tagName}},numberList:{tagName:"ol",parse:!1},number:{tagName:"li",listAttribute:"numberList",group:!1,nestable:!0,test(t){return r(t.parentNode)===a[this.listAttribute].tagName}},attachmentGallery:{tagName:"div",exclusive:!0,terminal:!0,parse:!1,group:!1}},r=t=>{var o;return null==t||null===(o=t.tagName)||void 0===o?void 0:o.toLowerCase()},l=navigator.userAgent.match(/android\s([0-9]+.*Chrome)/i),c=l&&parseInt(l[1]);var u={composesExistingText:/Android.*Chrome/.test(navigator.userAgent),recentAndroid:c&&c>12,samsungAndroid:c&&navigator.userAgent.match(/Android.*SM-/),forcesObjectResizing:/Trident.*rv:11/.test(navigator.userAgent),supportsInputEvents:"undefined"!=typeof InputEvent&&["data","getTargetRanges","inputType"].every((t=>t in InputEvent.prototype))},d={attachFiles:"Attach Files",bold:"Bold",bullets:"Bullets",byte:"Byte",bytes:"Bytes",captionPlaceholder:"Add a caption…",code:"Code",heading1:"Heading",indent:"Increase Level",italic:"Italic",link:"Link",numbers:"Numbers",outdent:"Decrease Level",quote:"Quote",redo:"Redo",remove:"Remove",strike:"Strikethrough",undo:"Undo",unlink:"Unlink",url:"URL",urlPlaceholder:"Enter a URL…",GB:"GB",KB:"KB",MB:"MB",PB:"PB",TB:"TB"};const m=[d.bytes,d.KB,d.MB,d.GB,d.TB,d.PB];var p={prefix:"IEC",precision:2,formatter(t){switch(t){case 0:return"0 ".concat(d.bytes);case 1:return"1 ".concat(d.byte);default:let o;"SI"===this.prefix?o=1e3:"IEC"===this.prefix&&(o=1024);const s=Math.floor(Math.log(t)/Math.log(o)),a=(t/Math.pow(o,s)).toFixed(this.precision).replace(/0*$/,"").replace(/\.$/,"");return"".concat(a," ").concat(m[s])}}};const L="\ufeff",M=" ",g=function(t){for(const o in t){const s=t[o];this[o]=s}return this},j=document.documentElement,W=j.matches,f=function(t){let{onElement:o,matchingSelector:s,withCallback:a,inPhase:l,preventDefault:c,times:u}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const d=o||j,m=s,p="capturing"===l,h=function(t){null!=u&&0==--u&&h.destroy();const o=A(t.target,{matchingSelector:m});null!=o&&(null==a||a.call(o,t,o),c&&t.preventDefault())};return h.destroy=()=>d.removeEventListener(t,h,p),d.addEventListener(t,h,p),h},b=function(t){let{onElement:o,bubbles:s,cancelable:a,attributes:l}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const c=null!=o?o:j;s=!1!==s,a=!1!==a;const u=document.createEvent("Events");return u.initEvent(t,s,a),null!=l&&g.call(u,l),c.dispatchEvent(u)},v=function(t,o){if(1===(null==t?void 0:t.nodeType))return W.call(t,o)},A=function(t){let{matchingSelector:o,untilNode:s}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};for(;t&&t.nodeType!==Node.ELEMENT_NODE;)t=t.parentNode;if(null!=t){if(null==o)return t;if(t.closest&&null==s)return t.closest(o);for(;t&&t!==s;){if(v(t,o))return t;t=t.parentNode}}},x=t=>document.activeElement!==t&&y(t,document.activeElement),y=function(t,o){if(t&&o)for(;o;){if(o===t)return!0;o=o.parentNode}},C=function(t){var o;if(null===(o=t)||void 0===o||!o.parentNode)return;let s=0;for(t=t.previousSibling;t;)s++,t=t.previousSibling;return s},R=t=>{var o;return null==t||null===(o=t.parentNode)||void 0===o?void 0:o.removeChild(t)},S=function(t){let{onlyNodesOfType:o,usingFilter:s,expandEntityReferences:a}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const l=(()=>{switch(o){case"element":return NodeFilter.SHOW_ELEMENT;case"text":return NodeFilter.SHOW_TEXT;case"comment":return NodeFilter.SHOW_COMMENT;default:return NodeFilter.SHOW_ALL}})();return document.createTreeWalker(t,l,null!=s?s:null,!0===a)},E=t=>{var o;return null==t||null===(o=t.tagName)||void 0===o?void 0:o.toLowerCase()},k=function(t){let o,s,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};"object"==typeof t?(a=t,t=a.tagName):a={attributes:a};const l=document.createElement(t);if(null!=a.editable&&(null==a.attributes&&(a.attributes={}),a.attributes.contenteditable=a.editable),a.attributes)for(o in a.attributes)s=a.attributes[o],l.setAttribute(o,s);if(a.style)for(o in a.style)s=a.style[o],l.style[o]=s;if(a.data)for(o in a.data)s=a.data[o],l.dataset[o]=s;return a.className&&a.className.split(" ").forEach((t=>{l.classList.add(t)})),a.textContent&&(l.textContent=a.textContent),a.childNodes&&[].concat(a.childNodes).forEach((t=>{l.appendChild(t)})),l};let q;const D=function(){if(null!=q)return q;q=[];for(const t in a){const o=a[t];o.tagName&&q.push(o.tagName)}return q},w=t=>B(null==t?void 0:t.firstChild),T=function(t){let{strict:o}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{strict:!0};return o?B(t):B(t)||!B(t.firstChild)&&function(t){return D().includes(E(t))&&!D().includes(E(t.firstChild))}(t)},B=t=>F(t)&&"block"===(null==t?void 0:t.data),F=t=>(null==t?void 0:t.nodeType)===Node.COMMENT_NODE,I=function(t){let{name:o}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(t)return O(t)?t.data===L?!o||t.parentNode.dataset.trixCursorTarget===o:void 0:I(t.firstChild)},P=t=>v(t,o),N=t=>O(t)&&""===(null==t?void 0:t.data),O=t=>(null==t?void 0:t.nodeType)===Node.TEXT_NODE,U={level2Enabled:!0,getLevel(){return this.level2Enabled&&u.supportsInputEvents?2:0},pickFiles(t){const o=k("input",{type:"file",multiple:!0,hidden:!0,id:this.fileInputId});o.addEventListener("change",(()=>{t(o.files),R(o)})),R(document.getElementById(this.fileInputId)),document.body.appendChild(o),o.click()}};var V={removeBlankTableCells:!1,tableCellSeparator:" | ",tableRowSeparator:"\n"},H={bold:{tagName:"strong",inheritable:!0,parser(t){const o=window.getComputedStyle(t);return"bold"===o.fontWeight||o.fontWeight>=600}},italic:{tagName:"em",inheritable:!0,parser:t=>"italic"===window.getComputedStyle(t).fontStyle},href:{groupTagName:"a",parser(t){const s="a:not(".concat(o,")"),a=t.closest(s);if(a)return a.getAttribute("href")}},strike:{tagName:"del",inheritable:!0},frozen:{style:{backgroundColor:"highlight"}}},J={getDefaultHTML:()=>'<div class="trix-button-row">\n <span class="trix-button-group trix-button-group--text-tools" data-trix-button-group="text-tools">\n <button type="button" class="trix-button trix-button--icon trix-button--icon-bold" data-trix-attribute="bold" data-trix-key="b" title="'.concat(d.bold,'" tabindex="-1">').concat(d.bold,'</button>\n <button type="button" class="trix-button trix-button--icon trix-button--icon-italic" data-trix-attribute="italic" data-trix-key="i" title="').concat(d.italic,'" tabindex="-1">').concat(d.italic,'</button>\n <button type="button" class="trix-button trix-button--icon trix-button--icon-strike" data-trix-attribute="strike" title="').concat(d.strike,'" tabindex="-1">').concat(d.strike,'</button>\n <button type="button" class="trix-button trix-button--icon trix-button--icon-link" data-trix-attribute="href" data-trix-action="link" data-trix-key="k" title="').concat(d.link,'" tabindex="-1">').concat(d.link,'</button>\n </span>\n\n <span class="trix-button-group trix-button-group--block-tools" data-trix-button-group="block-tools">\n <button type="button" class="trix-button trix-button--icon trix-button--icon-heading-1" data-trix-attribute="heading1" title="').concat(d.heading1,'" tabindex="-1">').concat(d.heading1,'</button>\n <button type="button" class="trix-button trix-button--icon trix-button--icon-quote" data-trix-attribute="quote" title="').concat(d.quote,'" tabindex="-1">').concat(d.quote,'</button>\n <button type="button" class="trix-button trix-button--icon trix-button--icon-code" data-trix-attribute="code" title="').concat(d.code,'" tabindex="-1">').concat(d.code,'</button>\n <button type="button" class="trix-button trix-button--icon trix-button--icon-bullet-list" data-trix-attribute="bullet" title="').concat(d.bullets,'" tabindex="-1">').concat(d.bullets,'</button>\n <button type="button" class="trix-button trix-button--icon trix-button--icon-number-list" data-trix-attribute="number" title="').concat(d.numbers,'" tabindex="-1">').concat(d.numbers,'</button>\n <button type="button" class="trix-button trix-button--icon trix-button--icon-decrease-nesting-level" data-trix-action="decreaseNestingLevel" title="').concat(d.outdent,'" tabindex="-1">').concat(d.outdent,'</button>\n <button type="button" class="trix-button trix-button--icon trix-button--icon-increase-nesting-level" data-trix-action="increaseNestingLevel" title="').concat(d.indent,'" tabindex="-1">').concat(d.indent,'</button>\n </span>\n\n <span class="trix-button-group trix-button-group--file-tools" data-trix-button-group="file-tools">\n <button type="button" class="trix-button trix-button--icon trix-button--icon-attach" data-trix-action="attachFiles" title="').concat(d.attachFiles,'" tabindex="-1">').concat(d.attachFiles,'</button>\n </span>\n\n <span class="trix-button-group-spacer"></span>\n\n <span class="trix-button-group trix-button-group--history-tools" data-trix-button-group="history-tools">\n <button type="button" class="trix-button trix-button--icon trix-button--icon-undo" data-trix-action="undo" data-trix-key="z" title="').concat(d.undo,'" tabindex="-1">').concat(d.undo,'</button>\n <button type="button" class="trix-button trix-button--icon trix-button--icon-redo" data-trix-action="redo" data-trix-key="shift+z" title="').concat(d.redo,'" tabindex="-1">').concat(d.redo,'</button>\n </span>\n </div>\n\n <div class="trix-dialogs" data-trix-dialogs>\n <div class="trix-dialog trix-dialog--link" data-trix-dialog="href" data-trix-dialog-attribute="href">\n <div class="trix-dialog__link-fields">\n <input type="url" name="href" class="trix-input trix-input--dialog" placeholder="').concat(d.urlPlaceholder,'" aria-label="').concat(d.url,'" required data-trix-input>\n <div class="trix-button-group">\n <input type="button" class="trix-button trix-button--dialog" value="').concat(d.link,'" data-trix-method="setAttribute">\n <input type="button" class="trix-button trix-button--dialog" value="').concat(d.unlink,'" data-trix-method="removeAttribute">\n </div>\n </div>\n </div>\n </div>')};const K={interval:5e3};var G=Object.freeze({__proto__:null,attachments:s,blockAttributes:a,browser:u,css:{attachment:"attachment",attachmentCaption:"attachment__caption",attachmentCaptionEditor:"attachment__caption-editor",attachmentMetadata:"attachment__metadata",attachmentMetadataContainer:"attachment__metadata-container",attachmentName:"attachment__name",attachmentProgress:"attachment__progress",attachmentSize:"attachment__size",attachmentToolbar:"attachment__toolbar",attachmentGallery:"attachment-gallery"},fileSize:p,input:U,keyNames:{8:"backspace",9:"tab",13:"return",27:"escape",37:"left",39:"right",46:"delete",68:"d",72:"h",79:"o"},lang:d,parser:V,textAttributes:H,toolbar:J,undo:K});class z{static proxyMethod(t){const{name:o,toMethod:s,toProperty:a,optional:l}=_(t);this.prototype[o]=function(){let t,c;var u,d;s?c=l?null===(u=this[s])||void 0===u?void 0:u.call(this):this[s]():a&&(c=this[a]);return l?(t=null===(d=c)||void 0===d?void 0:d[o],t?$.call(t,c,arguments):void 0):(t=c[o],$.call(t,c,arguments))}}}const _=function(t){const o=t.match(Q);if(!o)throw new Error("can't parse @proxyMethod expression: ".concat(t));const s={name:o[4]};return null!=o[2]?s.toMethod=o[1]:s.toProperty=o[1],null!=o[3]&&(s.optional=!0),s},{apply:$}=Function.prototype,Q=new RegExp("^(.+?)(\\(\\))?(\\?)?\\.(.+?)$");var Y,Z,tt;class X extends z{static box(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return t instanceof this?t:this.fromUCS2String(null==t?void 0:t.toString())}static fromUCS2String(t){return new this(t,at(t))}static fromCodepoints(t){return new this(lt(t),t)}constructor(t,o){super(...arguments),this.ucs2String=t,this.codepoints=o,this.length=this.codepoints.length,this.ucs2Length=this.ucs2String.length}offsetToUCS2Offset(t){return lt(this.codepoints.slice(0,Math.max(0,t))).length}offsetFromUCS2Offset(t){return at(this.ucs2String.slice(0,Math.max(0,t))).length}slice(){return this.constructor.fromCodepoints(this.codepoints.slice(...arguments))}charAt(t){return this.slice(t,t+1)}isEqualTo(t){return this.constructor.box(t).ucs2String===this.ucs2String}toJSON(){return this.ucs2String}getCacheKey(){return this.ucs2String}toString(){return this.ucs2String}}const et=1===(null===(Y=Array.from)||void 0===Y?void 0:Y.call(Array,"👼").length),it=null!=(null===(Z=" ".codePointAt)||void 0===Z?void 0:Z.call(" ",0)),st=" 👼"===(null===(tt=String.fromCodePoint)||void 0===tt?void 0:tt.call(String,32,128124));let at,lt;at=et&&it?t=>Array.from(t).map((t=>t.codePointAt(0))):function(t){const o=[];let s=0;const{length:a}=t;for(;s<a;){let l=t.charCodeAt(s++);if(55296<=l&&l<=56319&&s<a){const o=t.charCodeAt(s++);56320==(64512&o)?l=((1023&l)<<10)+(1023&o)+65536:s--}o.push(l)}return o},lt=st?t=>String.fromCodePoint(...Array.from(t||[])):function(t){return(()=>{const o=[];return Array.from(t).forEach((t=>{let s="";t>65535&&(t-=65536,s+=String.fromCharCode(t>>>10&1023|55296),t=56320|1023&t),o.push(s+String.fromCharCode(t))})),o})().join("")};let ct=0;class nt extends z{static fromJSONString(t){return this.fromJSON(JSON.parse(t))}constructor(){super(...arguments),this.id=++ct}hasSameConstructorAs(t){return this.constructor===(null==t?void 0:t.constructor)}isEqualTo(t){return this===t}inspect(){const t=[],o=this.contentsForInspection()||{};for(const s in o){const a=o[s];t.push("".concat(s,"=").concat(a))}return"#<".concat(this.constructor.name,":").concat(this.id).concat(t.length?" ".concat(t.join(", ")):"",">")}contentsForInspection(){}toJSONString(){return JSON.stringify(this)}toUTF16String(){return X.box(this)}getCacheKey(){return this.id.toString()}}const rt=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(t.length!==o.length)return!1;for(let s=0;s<t.length;s++)if(t[s]!==o[s])return!1;return!0},ot=function(t){const o=t.slice(0);for(var s=arguments.length,a=new Array(s>1?s-1:0),l=1;l<s;l++)a[l-1]=arguments[l];return o.splice(...a),o},ht=/[\u05BE\u05C0\u05C3\u05D0-\u05EA\u05F0-\u05F4\u061B\u061F\u0621-\u063A\u0640-\u064A\u066D\u0671-\u06B7\u06BA-\u06BE\u06C0-\u06CE\u06D0-\u06D5\u06E5\u06E6\u200F\u202B\u202E\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE72\uFE74\uFE76-\uFEFC]/,ut=function(){const t=k("input",{dir:"auto",name:"x",dirName:"x.dir"}),o=k("textarea",{dir:"auto",name:"y",dirName:"y.dir"}),s=k("form");s.appendChild(t),s.appendChild(o);const a=function(){try{return new FormData(s).has(o.dirName)}catch(t){return!1}}(),l=function(){try{return t.matches(":dir(ltr),:dir(rtl)")}catch(t){return!1}}();return a?function(t){return o.value=t,new FormData(s).get(o.dirName)}:l?function(o){return t.value=o,t.matches(":dir(rtl)")?"rtl":"ltr"}:function(t){const o=t.trim().charAt(0);return ht.test(o)?"rtl":"ltr"}}();let yt=null,Rt=null,It=null,Ut=null;const dt=()=>(yt||(yt=ft().concat(mt())),yt),gt=t=>a[t],mt=()=>(Rt||(Rt=Object.keys(a)),Rt),pt=t=>H[t],ft=()=>(It||(It=Object.keys(H)),It),bt=function(t,o){vt(t).textContent=o.replace(/%t/g,t)},vt=function(t){const o=document.createElement("style");o.setAttribute("type","text/css"),o.setAttribute("data-tag-name",t.toLowerCase());const s=At();return s&&o.setAttribute("nonce",s),document.head.insertBefore(o,document.head.firstChild),o},At=function(){const t=xt("trix-csp-nonce")||xt("csp-nonce");if(t)return t.getAttribute("content")},xt=t=>document.head.querySelector("meta[name=".concat(t,"]")),ne={"application/x-trix-feature-detection":"test"},Ct=function(t){const o=t.getData("text/plain"),s=t.getData("text/html");if(!o||!s)return null==o?void 0:o.length;{const{body:t}=(new DOMParser).parseFromString(s,"text/html");if(t.textContent===o)return!t.querySelector("*")}},ue=/Mac|^iP/.test(navigator.platform)?t=>t.metaKey:t=>t.ctrlKey,St=t=>setTimeout(t,1),Et=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const o={};for(const s in t){const a=t[s];o[s]=a}return o},kt=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(Object.keys(t).length!==Object.keys(o).length)return!1;for(const s in t)if(t[s]!==o[s])return!1;return!0},Lt=function(t){if(null!=t)return Array.isArray(t)||(t=[t,t]),[Tt(t[0]),Tt(null!=t[1]?t[1]:t[0])]},Dt=function(t){if(null==t)return;const[o,s]=Lt(t);return Bt(o,s)},wt=function(t,o){if(null==t||null==o)return;const[s,a]=Lt(t),[l,c]=Lt(o);return Bt(s,l)&&Bt(a,c)},Tt=function(t){return"number"==typeof t?t:Et(t)},Bt=function(t,o){return"number"==typeof t?t===o:kt(t,o)};class Ft extends z{constructor(){super(...arguments),this.update=this.update.bind(this),this.selectionManagers=[]}start(){this.started||(this.started=!0,document.addEventListener("selectionchange",this.update,!0))}stop(){if(this.started)return this.started=!1,document.removeEventListener("selectionchange",this.update,!0)}registerSelectionManager(t){if(!this.selectionManagers.includes(t))return this.selectionManagers.push(t),this.start()}unregisterSelectionManager(t){if(this.selectionManagers=this.selectionManagers.filter((o=>o!==t)),0===this.selectionManagers.length)return this.stop()}notifySelectionManagersOfSelectionChange(){return this.selectionManagers.map((t=>t.selectionDidChange()))}update(){this.notifySelectionManagersOfSelectionChange()}reset(){this.update()}}const Pe=new Ft,Pt=function(){const t=window.getSelection();if(t.rangeCount>0)return t},Nt=function(){var t;const o=null===(t=Pt())||void 0===t?void 0:t.getRangeAt(0);if(o&&!Mt(o))return o},Ot=function(t){const o=window.getSelection();return o.removeAllRanges(),o.addRange(t),Pe.update()},Mt=t=>jt(t.startContainer)||jt(t.endContainer),jt=t=>!Object.getPrototypeOf(t),Wt=t=>t.replace(new RegExp("".concat(L),"g"),"").replace(new RegExp("".concat(M),"g")," "),ze=new RegExp("[^\\S".concat(M,"]")),qt=t=>t.replace(new RegExp("".concat(ze.source),"g")," ").replace(/\ {2,}/g," "),Vt=function(t,o){if(t.isEqualTo(o))return["",""];const s=zt(t,o),{length:a}=s.utf16String;let l;if(a){const{offset:c}=s,u=t.codepoints.slice(0,c).concat(t.codepoints.slice(c+a));l=zt(o,X.fromCodepoints(u))}else l=zt(o,t);return[s.utf16String.toString(),l.utf16String.toString()]},zt=function(t,o){let s=0,a=t.length,l=o.length;for(;s<a&&t.charAt(s).isEqualTo(o.charAt(s));)s++;for(;a>s+1&&t.charAt(a-1).isEqualTo(o.charAt(l-1));)a--,l--;return{utf16String:t.slice(s,a),offset:s}};class _t extends nt{static fromCommonAttributesOfObjects(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];if(!t.length)return new this;let o=Gt(t[0]),s=o.getKeys();return t.slice(1).forEach((t=>{s=o.getKeysCommonToHash(Gt(t)),o=o.slice(s)})),o}static box(t){return Gt(t)}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(...arguments),this.values=Kt(t)}add(t,o){return this.merge(Ht(t,o))}remove(t){return new _t(Kt(this.values,t))}get(t){return this.values[t]}has(t){return t in this.values}merge(t){return new _t(Jt(this.values,$t(t)))}slice(t){const o={};return Array.from(t).forEach((t=>{this.has(t)&&(o[t]=this.values[t])})),new _t(o)}getKeys(){return Object.keys(this.values)}getKeysCommonToHash(t){return t=Gt(t),this.getKeys().filter((o=>this.values[o]===t.values[o]))}isEqualTo(t){return rt(this.toArray(),Gt(t).toArray())}isEmpty(){return 0===this.getKeys().length}toArray(){if(!this.array){const t=[];for(const o in this.values){const s=this.values[o];t.push(t.push(o,s))}this.array=t.slice(0)}return this.array}toObject(){return Kt(this.values)}toJSON(){return this.toObject()}contentsForInspection(){return{values:JSON.stringify(this.values)}}}const Ht=function(t,o){const s={};return s[t]=o,s},Jt=function(t,o){const s=Kt(t);for(const t in o){const a=o[t];s[t]=a}return s},Kt=function(t,o){const s={};return Object.keys(t).sort().forEach((a=>{a!==o&&(s[a]=t[a])})),s},Gt=function(t){return t instanceof _t?t:new _t(t)},$t=function(t){return t instanceof _t?t.values:t};class Xt{static groupObjects(){let t,o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],{depth:s,asTree:a}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};a&&null==s&&(s=0);const l=[];return Array.from(o).forEach((o=>{var c;if(t){var u,d,m;if(null!==(u=o.canBeGrouped)&&void 0!==u&&u.call(o,s)&&null!==(d=(m=t[t.length-1]).canBeGroupedWith)&&void 0!==d&&d.call(m,o,s))return void t.push(o);l.push(new this(t,{depth:s,asTree:a})),t=null}null!==(c=o.canBeGrouped)&&void 0!==c&&c.call(o,s)?t=[o]:l.push(o)})),t&&l.push(new this(t,{depth:s,asTree:a})),l}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],{depth:o,asTree:s}=arguments.length>1?arguments[1]:void 0;this.objects=t,s&&(this.depth=o,this.objects=this.constructor.groupObjects(this.objects,{asTree:s,depth:this.depth+1}))}getObjects(){return this.objects}getDepth(){return this.depth}getCacheKey(){const t=["objectGroup"];return Array.from(this.getObjects()).forEach((o=>{t.push(o.getCacheKey())})),t.join("/")}}class Yt extends z{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];super(...arguments),this.objects={},Array.from(t).forEach((t=>{const o=JSON.stringify(t);null==this.objects[o]&&(this.objects[o]=t)}))}find(t){const o=JSON.stringify(t);return this.objects[o]}}class Qt{constructor(t){this.reset(t)}add(t){const o=Zt(t);this.elements[o]=t}remove(t){const o=Zt(t),s=this.elements[o];if(s)return delete this.elements[o],s}reset(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return this.elements={},Array.from(t).forEach((t=>{this.add(t)})),t}}const Zt=t=>t.dataset.trixStoreKey;class te extends z{isPerforming(){return!0===this.performing}hasPerformed(){return!0===this.performed}hasSucceeded(){return this.performed&&this.succeeded}hasFailed(){return this.performed&&!this.succeeded}getPromise(){return this.promise||(this.promise=new Promise(((t,o)=>(this.performing=!0,this.perform(((s,a)=>{this.succeeded=s,this.performing=!1,this.performed=!0,this.succeeded?t(a):o(a)})))))),this.promise}perform(t){return t(!1)}release(){var t,o;null===(t=this.promise)||void 0===t||null===(o=t.cancel)||void 0===o||o.call(t),this.promise=null,this.performing=null,this.performed=null,this.succeeded=null}}te.proxyMethod("getPromise().then"),te.proxyMethod("getPromise().catch");class ee extends z{constructor(t){let o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(...arguments),this.object=t,this.options=o,this.childViews=[],this.rootView=this}getNodes(){return this.nodes||(this.nodes=this.createNodes()),this.nodes.map((t=>t.cloneNode(!0)))}invalidate(){var t;return this.nodes=null,this.childViews=[],null===(t=this.parentView)||void 0===t?void 0:t.invalidate()}invalidateViewForObject(t){var o;return null===(o=this.findViewForObject(t))||void 0===o?void 0:o.invalidate()}findOrCreateCachedChildView(t,o,s){let a=this.getCachedViewForObject(o);return a?this.recordChildView(a):(a=this.createChildView(...arguments),this.cacheViewForObject(a,o)),a}createChildView(t,o){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};o instanceof Xt&&(s.viewClass=t,t=ie);const a=new t(o,s);return this.recordChildView(a)}recordChildView(t){return t.parentView=this,t.rootView=this.rootView,this.childViews.push(t),t}getAllChildViews(){let t=[];return this.childViews.forEach((o=>{t.push(o),t=t.concat(o.getAllChildViews())})),t}findElement(){return this.findElementForObject(this.object)}findElementForObject(t){const o=null==t?void 0:t.id;if(o)return this.rootView.element.querySelector("[data-trix-id='".concat(o,"']"))}findViewForObject(t){for(const o of this.getAllChildViews())if(o.object===t)return o}getViewCache(){return this.rootView!==this?this.rootView.getViewCache():this.isViewCachingEnabled()?(this.viewCache||(this.viewCache={}),this.viewCache):void 0}isViewCachingEnabled(){return!1!==this.shouldCacheViews}enableViewCaching(){this.shouldCacheViews=!0}disableViewCaching(){this.shouldCacheViews=!1}getCachedViewForObject(t){var o;return null===(o=this.getViewCache())||void 0===o?void 0:o[t.getCacheKey()]}cacheViewForObject(t,o){const s=this.getViewCache();s&&(s[o.getCacheKey()]=t)}garbageCollectCachedViews(){const t=this.getViewCache();if(t){const o=this.getAllChildViews().concat(this).map((t=>t.object.getCacheKey()));for(const s in t)o.includes(s)||delete t[s]}}}class ie extends ee{constructor(){super(...arguments),this.objectGroup=this.object,this.viewClass=this.options.viewClass,delete this.options.viewClass}getChildViews(){return this.childViews.length||Array.from(this.objectGroup.getObjects()).forEach((t=>{this.findOrCreateCachedChildView(this.viewClass,t,this.options)})),this.childViews}createNodes(){const t=this.createContainerElement();return this.getChildViews().forEach((o=>{Array.from(o.getNodes()).forEach((o=>{t.appendChild(o)}))})),[t]}createContainerElement(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.objectGroup.getDepth();return this.getChildViews()[0].createContainerElement(t)}}const{css:_e}=G;class re extends ee{constructor(){super(...arguments),this.attachment=this.object,this.attachment.uploadProgressDelegate=this,this.attachmentPiece=this.options.piece}createContentNodes(){return[]}createNodes(){let t;const o=t=k({tagName:"figure",className:this.getClassName(),data:this.getData(),editable:!1}),s=this.getHref();return s&&(t=k({tagName:"a",editable:!1,attributes:{href:s,tabindex:-1}}),o.appendChild(t)),this.attachment.hasContent()?t.innerHTML=this.attachment.getContent():this.createContentNodes().forEach((o=>{t.appendChild(o)})),t.appendChild(this.createCaptionElement()),this.attachment.isPending()&&(this.progressElement=k({tagName:"progress",attributes:{class:_e.attachmentProgress,value:this.attachment.getUploadProgress(),max:100},data:{trixMutable:!0,trixStoreKey:["progressElement",this.attachment.id].join("/")}}),o.appendChild(this.progressElement)),[oe("left"),o,oe("right")]}createCaptionElement(){const t=k({tagName:"figcaption",className:_e.attachmentCaption}),o=this.attachmentPiece.getCaption();if(o)t.classList.add("".concat(_e.attachmentCaption,"--edited")),t.textContent=o;else{let o,s;const a=this.getCaptionConfig();if(a.name&&(o=this.attachment.getFilename()),a.size&&(s=this.attachment.getFormattedFilesize()),o){const s=k({tagName:"span",className:_e.attachmentName,textContent:o});t.appendChild(s)}if(s){o&&t.appendChild(document.createTextNode(" "));const a=k({tagName:"span",className:_e.attachmentSize,textContent:s});t.appendChild(a)}}return t}getClassName(){const t=[_e.attachment,"".concat(_e.attachment,"--").concat(this.attachment.getType())],o=this.attachment.getExtension();return o&&t.push("".concat(_e.attachment,"--").concat(o)),t.join(" ")}getData(){const t={trixAttachment:JSON.stringify(this.attachment),trixContentType:this.attachment.getContentType(),trixId:this.attachment.id},{attributes:o}=this.attachmentPiece;return o.isEmpty()||(t.trixAttributes=JSON.stringify(o)),this.attachment.isPending()&&(t.trixSerialize=!1),t}getHref(){if(!se(this.attachment.getContent(),"a"))return this.attachment.getHref()}getCaptionConfig(){var t;const o=this.attachment.getType(),a=Et(null===(t=s[o])||void 0===t?void 0:t.caption);return"file"===o&&(a.name=!0),a}findProgressElement(){var t;return null===(t=this.findElement())||void 0===t?void 0:t.querySelector("progress")}attachmentDidChangeUploadProgress(){const t=this.attachment.getUploadProgress(),o=this.findProgressElement();o&&(o.value=t)}}const oe=t=>k({tagName:"span",textContent:L,data:{trixCursorTarget:t,trixSerialize:!1}}),se=function(t,o){const s=k("div");return s.innerHTML=t||"",s.querySelector(o)};class ae extends re{constructor(){super(...arguments),this.attachment.previewDelegate=this}createContentNodes(){return this.image=k({tagName:"img",attributes:{src:""},data:{trixMutable:!0}}),this.refresh(this.image),[this.image]}createCaptionElement(){const t=super.createCaptionElement(...arguments);return t.textContent||t.setAttribute("data-trix-placeholder",d.captionPlaceholder),t}refresh(t){var o;t||(t=null===(o=this.findElement())||void 0===o?void 0:o.querySelector("img"));if(t)return this.updateAttributesForImage(t)}updateAttributesForImage(t){const o=this.attachment.getURL(),s=this.attachment.getPreviewURL();if(t.src=s||o,s===o)t.removeAttribute("data-trix-serialized-attributes");else{const s=JSON.stringify({src:o});t.setAttribute("data-trix-serialized-attributes",s)}const a=this.attachment.getWidth(),l=this.attachment.getHeight();null!=a&&(t.width=a),null!=l&&(t.height=l);const c=["imageElement",this.attachment.id,t.src,t.width,t.height].join("/");t.dataset.trixStoreKey=c}attachmentDidChangeAttributes(){return this.refresh(this.image),this.refresh()}}class le extends ee{constructor(){super(...arguments),this.piece=this.object,this.attributes=this.piece.getAttributes(),this.textConfig=this.options.textConfig,this.context=this.options.context,this.piece.attachment?this.attachment=this.piece.attachment:this.string=this.piece.toString()}createNodes(){let t=this.attachment?this.createAttachmentNodes():this.createStringNodes();const o=this.createElement();if(o){const s=function(t){for(;null!==(o=t)&&void 0!==o&&o.firstElementChild;){var o;t=t.firstElementChild}return t}(o);Array.from(t).forEach((t=>{s.appendChild(t)})),t=[o]}return t}createAttachmentNodes(){const t=this.attachment.isPreviewable()?ae:re;return this.createChildView(t,this.piece.attachment,{piece:this.piece}).getNodes()}createStringNodes(){var t;if(null!==(t=this.textConfig)&&void 0!==t&&t.plaintext)return[document.createTextNode(this.string)];{const t=[],o=this.string.split("\n");for(let s=0;s<o.length;s++){const a=o[s];if(s>0){const o=k("br");t.push(o)}if(a.length){const o=document.createTextNode(this.preserveSpaces(a));t.push(o)}}return t}}createElement(){let t,o,s;const a={};for(o in this.attributes){s=this.attributes[o];const c=pt(o);if(c){if(c.tagName){var l;const o=k(c.tagName);l?(l.appendChild(o),l=o):t=l=o}if(c.styleProperty&&(a[c.styleProperty]=s),c.style)for(o in c.style)s=c.style[o],a[o]=s}}if(Object.keys(a).length)for(o in t||(t=k("span")),a)s=a[o],t.style[o]=s;return t}createContainerElement(){for(const t in this.attributes){const o=this.attributes[t],s=pt(t);if(s&&s.groupTagName){const a={};return a[t]=o,k(s.groupTagName,a)}}}preserveSpaces(t){return this.context.isLast&&(t=t.replace(/\ $/,M)),t=t.replace(/(\S)\ {3}(\S)/g,"$1 ".concat(M," $2")).replace(/\ {2}/g,"".concat(M," ")).replace(/\ {2}/g," ".concat(M)),(this.context.isFirst||this.context.followsWhitespace)&&(t=t.replace(/^\ /,M)),t}}class ce extends ee{constructor(){super(...arguments),this.text=this.object,this.textConfig=this.options.textConfig}createNodes(){const t=[],o=Xt.groupObjects(this.getPieces()),s=o.length-1;for(let l=0;l<o.length;l++){const c=o[l],u={};0===l&&(u.isFirst=!0),l===s&&(u.isLast=!0),he(a)&&(u.followsWhitespace=!0);const d=this.findOrCreateCachedChildView(le,c,{textConfig:this.textConfig,context:u});t.push(...Array.from(d.getNodes()||[]));var a=c}return t}getPieces(){return Array.from(this.text.getPieces()).filter((t=>!t.hasAttribute("blockBreak")))}}const he=t=>/\s$/.test(null==t?void 0:t.toString()),{css:He}=G;class de extends ee{constructor(){super(...arguments),this.block=this.object,this.attributes=this.block.getAttributes()}createNodes(){const t=[document.createComment("block")];if(this.block.isEmpty())t.push(k("br"));else{var o;const s=null===(o=gt(this.block.getLastAttribute()))||void 0===o?void 0:o.text,a=this.findOrCreateCachedChildView(ce,this.block.text,{textConfig:s});t.push(...Array.from(a.getNodes()||[])),this.shouldAddExtraNewlineElement()&&t.push(k("br"))}if(this.attributes.length)return t;{let o;const{tagName:s}=a.default;this.block.isRTL()&&(o={dir:"rtl"});const l=k({tagName:s,attributes:o});return t.forEach((t=>l.appendChild(t))),[l]}}createContainerElement(t){let o,s;const a=this.attributes[t],{tagName:l}=gt(a);if(0===t&&this.block.isRTL()&&(o={dir:"rtl"}),"attachmentGallery"===a){const t=this.block.getBlockBreakPosition();s="".concat(He.attachmentGallery," ").concat(He.attachmentGallery,"--").concat(t)}return k({tagName:l,className:s,attributes:o})}shouldAddExtraNewlineElement(){return/\n\n$/.test(this.block.toString())}}class ge extends ee{static render(t){const o=k("div"),s=new this(t,{element:o});return s.render(),s.sync(),o}constructor(){super(...arguments),this.element=this.options.element,this.elementStore=new Qt,this.setDocument(this.object)}setDocument(t){t.isEqualTo(this.document)||(this.document=this.object=t)}render(){if(this.childViews=[],this.shadowElement=k("div"),!this.document.isEmpty()){const t=Xt.groupObjects(this.document.getBlocks(),{asTree:!0});Array.from(t).forEach((t=>{const o=this.findOrCreateCachedChildView(de,t);Array.from(o.getNodes()).map((t=>this.shadowElement.appendChild(t)))}))}}isSynced(){return pe(this.shadowElement,this.element)}sync(){const t=this.createDocumentFragmentForSync();for(;this.element.lastChild;)this.element.removeChild(this.element.lastChild);return this.element.appendChild(t),this.didSync()}didSync(){return this.elementStore.reset(me(this.element)),St((()=>this.garbageCollectCachedViews()))}createDocumentFragmentForSync(){const t=document.createDocumentFragment();return Array.from(this.shadowElement.childNodes).forEach((o=>{t.appendChild(o.cloneNode(!0))})),Array.from(me(t)).forEach((t=>{const o=this.elementStore.remove(t);o&&t.parentNode.replaceChild(o,t)})),t}}const me=t=>t.querySelectorAll("[data-trix-store-key]"),pe=(t,o)=>fe(t.innerHTML)===fe(o.innerHTML),fe=t=>t.replace(/ /g," ");function be(t){var o,s;function n(o,s){try{var a=t[o](s),l=a.value,c=l instanceof ve;Promise.resolve(c?l.v:l).then((function(s){if(c){var u="return"===o?"return":"next";if(!l.k||s.done)return n(u,s);s=t[u](s).value}r(a.done?"return":"normal",s)}),(function(t){n("throw",t)}))}catch(t){r("throw",t)}}function r(t,a){switch(t){case"return":o.resolve({value:a,done:!0});break;case"throw":o.reject(a);break;default:o.resolve({value:a,done:!1})}(o=o.next)?n(o.key,o.arg):s=null}this._invoke=function(t,a){return new Promise((function(l,c){var u={key:t,arg:a,resolve:l,reject:c,next:null};s?s=s.next=u:(o=s=u,n(t,a))}))},"function"!=typeof t.return&&(this.return=void 0)}function ve(t,o){this.v=t,this.k=o}function Ae(t,o,s){return(o=xe(o))in t?Object.defineProperty(t,o,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[o]=s,t}function xe(t){var o=function(t,o){if("object"!=typeof t||null===t)return t;var s=t[Symbol.toPrimitive];if(void 0!==s){var a=s.call(t,o||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===o?String:Number)(t)}(t,"string");return"symbol"==typeof o?o:String(o)}be.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},be.prototype.next=function(t){return this._invoke("next",t)},be.prototype.throw=function(t){return this._invoke("throw",t)},be.prototype.return=function(t){return this._invoke("return",t)};class ye extends nt{static registerType(t,o){o.type=t,this.types[t]=o}static fromJSON(t){const o=this.types[t.type];if(o)return o.fromJSON(t)}constructor(t){let o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(...arguments),this.attributes=_t.box(o)}copyWithAttributes(t){return new this.constructor(this.getValue(),t)}copyWithAdditionalAttributes(t){return this.copyWithAttributes(this.attributes.merge(t))}copyWithoutAttribute(t){return this.copyWithAttributes(this.attributes.remove(t))}copy(){return this.copyWithAttributes(this.attributes)}getAttribute(t){return this.attributes.get(t)}getAttributesHash(){return this.attributes}getAttributes(){return this.attributes.toObject()}hasAttribute(t){return this.attributes.has(t)}hasSameStringValueAsPiece(t){return t&&this.toString()===t.toString()}hasSameAttributesAsPiece(t){return t&&(this.attributes===t.attributes||this.attributes.isEqualTo(t.attributes))}isBlockBreak(){return!1}isEqualTo(t){return super.isEqualTo(...arguments)||this.hasSameConstructorAs(t)&&this.hasSameStringValueAsPiece(t)&&this.hasSameAttributesAsPiece(t)}isEmpty(){return 0===this.length}isSerializable(){return!0}toJSON(){return{type:this.constructor.type,attributes:this.getAttributes()}}contentsForInspection(){return{type:this.constructor.type,attributes:this.attributes.inspect()}}canBeGrouped(){return this.hasAttribute("href")}canBeGroupedWith(t){return this.getAttribute("href")===t.getAttribute("href")}getLength(){return this.length}canBeConsolidatedWith(t){return!1}}Ae(ye,"types",{});class Ce extends te{constructor(t){super(...arguments),this.url=t}perform(t){const o=new Image;o.onload=()=>(o.width=this.width=o.naturalWidth,o.height=this.height=o.naturalHeight,t(!0,o)),o.onerror=()=>t(!1),o.src=this.url}}class Re extends nt{static attachmentForFile(t){const o=new this(this.attributesForFile(t));return o.setFile(t),o}static attributesForFile(t){return new _t({filename:t.name,filesize:t.size,contentType:t.type})}static fromJSON(t){return new this(t)}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(t),this.releaseFile=this.releaseFile.bind(this),this.attributes=_t.box(t),this.didChangeAttributes()}getAttribute(t){return this.attributes.get(t)}hasAttribute(t){return this.attributes.has(t)}getAttributes(){return this.attributes.toObject()}setAttributes(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const o=this.attributes.merge(t);var s,a,l,c;if(!this.attributes.isEqualTo(o))return this.attributes=o,this.didChangeAttributes(),null===(s=this.previewDelegate)||void 0===s||null===(a=s.attachmentDidChangeAttributes)||void 0===a||a.call(s,this),null===(l=this.delegate)||void 0===l||null===(c=l.attachmentDidChangeAttributes)||void 0===c?void 0:c.call(l,this)}didChangeAttributes(){if(this.isPreviewable())return this.preloadURL()}isPending(){return null!=this.file&&!(this.getURL()||this.getHref())}isPreviewable(){return this.attributes.has("previewable")?this.attributes.get("previewable"):Re.previewablePattern.test(this.getContentType())}getType(){return this.hasContent()?"content":this.isPreviewable()?"preview":"file"}getURL(){return this.attributes.get("url")}getHref(){return this.attributes.get("href")}getFilename(){return this.attributes.get("filename")||""}getFilesize(){return this.attributes.get("filesize")}getFormattedFilesize(){const t=this.attributes.get("filesize");return"number"==typeof t?p.formatter(t):""}getExtension(){var t;return null===(t=this.getFilename().match(/\.(\w+)$/))||void 0===t?void 0:t[1].toLowerCase()}getContentType(){return this.attributes.get("contentType")}hasContent(){return this.attributes.has("content")}getContent(){return this.attributes.get("content")}getWidth(){return this.attributes.get("width")}getHeight(){return this.attributes.get("height")}getFile(){return this.file}setFile(t){if(this.file=t,this.isPreviewable())return this.preloadFile()}releaseFile(){this.releasePreloadedFile(),this.file=null}getUploadProgress(){return null!=this.uploadProgress?this.uploadProgress:0}setUploadProgress(t){var o,s;if(this.uploadProgress!==t)return this.uploadProgress=t,null===(o=this.uploadProgressDelegate)||void 0===o||null===(s=o.attachmentDidChangeUploadProgress)||void 0===s?void 0:s.call(o,this)}toJSON(){return this.getAttributes()}getCacheKey(){return[super.getCacheKey(...arguments),this.attributes.getCacheKey(),this.getPreviewURL()].join("/")}getPreviewURL(){return this.previewURL||this.preloadingURL}setPreviewURL(t){var o,s,a,l;if(t!==this.getPreviewURL())return this.previewURL=t,null===(o=this.previewDelegate)||void 0===o||null===(s=o.attachmentDidChangeAttributes)||void 0===s||s.call(o,this),null===(a=this.delegate)||void 0===a||null===(l=a.attachmentDidChangePreviewURL)||void 0===l?void 0:l.call(a,this)}preloadURL(){return this.preload(this.getURL(),this.releaseFile)}preloadFile(){if(this.file)return this.fileObjectURL=URL.createObjectURL(this.file),this.preload(this.fileObjectURL)}releasePreloadedFile(){this.fileObjectURL&&(URL.revokeObjectURL(this.fileObjectURL),this.fileObjectURL=null)}preload(t,o){if(t&&t!==this.getPreviewURL()){this.preloadingURL=t;return new Ce(t).then((s=>{let{width:a,height:l}=s;return this.getWidth()&&this.getHeight()||this.setAttributes({width:a,height:l}),this.preloadingURL=null,this.setPreviewURL(t),null==o?void 0:o()})).catch((()=>(this.preloadingURL=null,null==o?void 0:o())))}}}Ae(Re,"previewablePattern",/^image(\/(gif|png|webp|jpe?g)|$)/);class Se extends ye{static fromJSON(t){return new this(Re.fromJSON(t.attachment),t.attributes)}constructor(t){super(...arguments),this.attachment=t,this.length=1,this.ensureAttachmentExclusivelyHasAttribute("href"),this.attachment.hasContent()||this.removeProhibitedAttributes()}ensureAttachmentExclusivelyHasAttribute(t){this.hasAttribute(t)&&(this.attachment.hasAttribute(t)||this.attachment.setAttributes(this.attributes.slice([t])),this.attributes=this.attributes.remove(t))}removeProhibitedAttributes(){const t=this.attributes.slice(Se.permittedAttributes);t.isEqualTo(this.attributes)||(this.attributes=t)}getValue(){return this.attachment}isSerializable(){return!this.attachment.isPending()}getCaption(){return this.attributes.get("caption")||""}isEqualTo(t){var o;return super.isEqualTo(t)&&this.attachment.id===(null==t||null===(o=t.attachment)||void 0===o?void 0:o.id)}toString(){return""}toJSON(){const t=super.toJSON(...arguments);return t.attachment=this.attachment,t}getCacheKey(){return[super.getCacheKey(...arguments),this.attachment.getCacheKey()].join("/")}toConsole(){return JSON.stringify(this.toString())}}Ae(Se,"permittedAttributes",["caption","presentation"]),ye.registerType("attachment",Se);class Ee extends ye{static fromJSON(t){return new this(t.string,t.attributes)}constructor(t){super(...arguments),this.string=(t=>t.replace(/\r\n?/g,"\n"))(t),this.length=this.string.length}getValue(){return this.string}toString(){return this.string.toString()}isBlockBreak(){return"\n"===this.toString()&&!0===this.getAttribute("blockBreak")}toJSON(){const t=super.toJSON(...arguments);return t.string=this.string,t}canBeConsolidatedWith(t){return t&&this.hasSameConstructorAs(t)&&this.hasSameAttributesAsPiece(t)}consolidateWith(t){return new this.constructor(this.toString()+t.toString(),this.attributes)}splitAtOffset(t){let o,s;return 0===t?(o=null,s=this):t===this.length?(o=this,s=null):(o=new this.constructor(this.string.slice(0,t),this.attributes),s=new this.constructor(this.string.slice(t),this.attributes)),[o,s]}toConsole(){let{string:t}=this;return t.length>15&&(t=t.slice(0,14)+"…"),JSON.stringify(t.toString())}}ye.registerType("string",Ee);class ke extends nt{static box(t){return t instanceof this?t:new this(t)}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];super(...arguments),this.objects=t.slice(0),this.length=this.objects.length}indexOf(t){return this.objects.indexOf(t)}splice(){for(var t=arguments.length,o=new Array(t),s=0;s<t;s++)o[s]=arguments[s];return new this.constructor(ot(this.objects,...o))}eachObject(t){return this.objects.map(((o,s)=>t(o,s)))}insertObjectAtIndex(t,o){return this.splice(o,0,t)}insertSplittableListAtIndex(t,o){return this.splice(o,0,...t.objects)}insertSplittableListAtPosition(t,o){const[s,a]=this.splitObjectAtPosition(o);return new this.constructor(s).insertSplittableListAtIndex(t,a)}editObjectAtIndex(t,o){return this.replaceObjectAtIndex(o(this.objects[t]),t)}replaceObjectAtIndex(t,o){return this.splice(o,1,t)}removeObjectAtIndex(t){return this.splice(t,1)}getObjectAtIndex(t){return this.objects[t]}getSplittableListInRange(t){const[o,s,a]=this.splitObjectsAtRange(t);return new this.constructor(o.slice(s,a+1))}selectSplittableList(t){const o=this.objects.filter((o=>t(o)));return new this.constructor(o)}removeObjectsInRange(t){const[o,s,a]=this.splitObjectsAtRange(t);return new this.constructor(o).splice(s,a-s+1)}transformObjectsInRange(t,o){const[s,a,l]=this.splitObjectsAtRange(t),c=s.map(((t,s)=>a<=s&&s<=l?o(t):t));return new this.constructor(c)}splitObjectsAtRange(t){let o,[s,a,l]=this.splitObjectAtPosition(De(t));return[s,o]=new this.constructor(s).splitObjectAtPosition(we(t)+l),[s,a,o-1]}getObjectAtPosition(t){const{index:o}=this.findIndexAndOffsetAtPosition(t);return this.objects[o]}splitObjectAtPosition(t){let o,s;const{index:a,offset:l}=this.findIndexAndOffsetAtPosition(t),c=this.objects.slice(0);if(null!=a)if(0===l)o=a,s=0;else{const t=this.getObjectAtIndex(a),[u,d]=t.splitAtOffset(l);c.splice(a,1,u,d),o=a+1,s=u.getLength()-l}else o=c.length,s=0;return[c,o,s]}consolidate(){const t=[];let o=this.objects[0];return this.objects.slice(1).forEach((s=>{var a,l;null!==(a=(l=o).canBeConsolidatedWith)&&void 0!==a&&a.call(l,s)?o=o.consolidateWith(s):(t.push(o),o=s)})),o&&t.push(o),new this.constructor(t)}consolidateFromIndexToIndex(t,o){const s=this.objects.slice(0).slice(t,o+1),a=new this.constructor(s).consolidate().toArray();return this.splice(t,s.length,...a)}findIndexAndOffsetAtPosition(t){let o,s=0;for(o=0;o<this.objects.length;o++){const a=s+this.objects[o].getLength();if(s<=t&&t<a)return{index:o,offset:t-s};s=a}return{index:null,offset:null}}findPositionAtIndexAndOffset(t,o){let s=0;for(let a=0;a<this.objects.length;a++){const l=this.objects[a];if(a<t)s+=l.getLength();else if(a===t){s+=o;break}}return s}getEndPosition(){return null==this.endPosition&&(this.endPosition=0,this.objects.forEach((t=>this.endPosition+=t.getLength()))),this.endPosition}toString(){return this.objects.join("")}toArray(){return this.objects.slice(0)}toJSON(){return this.toArray()}isEqualTo(t){return super.isEqualTo(...arguments)||Le(this.objects,null==t?void 0:t.objects)}contentsForInspection(){return{objects:"[".concat(this.objects.map((t=>t.inspect())).join(", "),"]")}}}const Le=function(t){let o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(t.length!==o.length)return!1;let s=!0;for(let a=0;a<t.length;a++){const l=t[a];s&&!l.isEqualTo(o[a])&&(s=!1)}return s},De=t=>t[0],we=t=>t[1];class Te extends nt{static textForAttachmentWithAttributes(t,o){return new this([new Se(t,o)])}static textForStringWithAttributes(t,o){return new this([new Ee(t,o)])}static fromJSON(t){return new this(Array.from(t).map((t=>ye.fromJSON(t))))}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];super(...arguments);const o=t.filter((t=>!t.isEmpty()));this.pieceList=new ke(o)}copy(){return this.copyWithPieceList(this.pieceList)}copyWithPieceList(t){return new this.constructor(t.consolidate().toArray())}copyUsingObjectMap(t){const o=this.getPieces().map((o=>t.find(o)||o));return new this.constructor(o)}appendText(t){return this.insertTextAtPosition(t,this.getLength())}insertTextAtPosition(t,o){return this.copyWithPieceList(this.pieceList.insertSplittableListAtPosition(t.pieceList,o))}removeTextAtRange(t){return this.copyWithPieceList(this.pieceList.removeObjectsInRange(t))}replaceTextAtRange(t,o){return this.removeTextAtRange(o).insertTextAtPosition(t,o[0])}moveTextFromRangeToPosition(t,o){if(t[0]<=o&&o<=t[1])return;const s=this.getTextAtRange(t),a=s.getLength();return t[0]<o&&(o-=a),this.removeTextAtRange(t).insertTextAtPosition(s,o)}addAttributeAtRange(t,o,s){const a={};return a[t]=o,this.addAttributesAtRange(a,s)}addAttributesAtRange(t,o){return this.copyWithPieceList(this.pieceList.transformObjectsInRange(o,(o=>o.copyWithAdditionalAttributes(t))))}removeAttributeAtRange(t,o){return this.copyWithPieceList(this.pieceList.transformObjectsInRange(o,(o=>o.copyWithoutAttribute(t))))}setAttributesAtRange(t,o){return this.copyWithPieceList(this.pieceList.transformObjectsInRange(o,(o=>o.copyWithAttributes(t))))}getAttributesAtPosition(t){var o;return(null===(o=this.pieceList.getObjectAtPosition(t))||void 0===o?void 0:o.getAttributes())||{}}getCommonAttributes(){const t=Array.from(this.pieceList.toArray()).map((t=>t.getAttributes()));return _t.fromCommonAttributesOfObjects(t).toObject()}getCommonAttributesAtRange(t){return this.getTextAtRange(t).getCommonAttributes()||{}}getExpandedRangeForAttributeAtOffset(t,o){let s,a=s=o;const l=this.getLength();for(;a>0&&this.getCommonAttributesAtRange([a-1,s])[t];)a--;for(;s<l&&this.getCommonAttributesAtRange([o,s+1])[t];)s++;return[a,s]}getTextAtRange(t){return this.copyWithPieceList(this.pieceList.getSplittableListInRange(t))}getStringAtRange(t){return this.pieceList.getSplittableListInRange(t).toString()}getStringAtPosition(t){return this.getStringAtRange([t,t+1])}startsWithString(t){return this.getStringAtRange([0,t.length])===t}endsWithString(t){const o=this.getLength();return this.getStringAtRange([o-t.length,o])===t}getAttachmentPieces(){return this.pieceList.toArray().filter((t=>!!t.attachment))}getAttachments(){return this.getAttachmentPieces().map((t=>t.attachment))}getAttachmentAndPositionById(t){let o=0;for(const a of this.pieceList.toArray()){var s;if((null===(s=a.attachment)||void 0===s?void 0:s.id)===t)return{attachment:a.attachment,position:o};o+=a.length}return{attachment:null,position:null}}getAttachmentById(t){const{attachment:o}=this.getAttachmentAndPositionById(t);return o}getRangeOfAttachment(t){const o=this.getAttachmentAndPositionById(t.id),s=o.position;if(t=o.attachment)return[s,s+1]}updateAttributesForAttachment(t,o){const s=this.getRangeOfAttachment(o);return s?this.addAttributesAtRange(t,s):this}getLength(){return this.pieceList.getEndPosition()}isEmpty(){return 0===this.getLength()}isEqualTo(t){var o;return super.isEqualTo(t)||(null==t||null===(o=t.pieceList)||void 0===o?void 0:o.isEqualTo(this.pieceList))}isBlockBreak(){return 1===this.getLength()&&this.pieceList.getObjectAtIndex(0).isBlockBreak()}eachPiece(t){return this.pieceList.eachObject(t)}getPieces(){return this.pieceList.toArray()}getPieceAtPosition(t){return this.pieceList.getObjectAtPosition(t)}contentsForInspection(){return{pieceList:this.pieceList.inspect()}}toSerializableText(){const t=this.pieceList.selectSplittableList((t=>t.isSerializable()));return this.copyWithPieceList(t)}toString(){return this.pieceList.toString()}toJSON(){return this.pieceList.toJSON()}toConsole(){return JSON.stringify(this.pieceList.toArray().map((t=>JSON.parse(t.toConsole()))))}getDirection(){return ut(this.toString())}isRTL(){return"rtl"===this.getDirection()}}class Be extends nt{static fromJSON(t){return new this(Te.fromJSON(t.text),t.attributes)}constructor(t,o){super(...arguments),this.text=Fe(t||new Te),this.attributes=o||[]}isEmpty(){return this.text.isBlockBreak()}isEqualTo(t){return!!super.isEqualTo(t)||this.text.isEqualTo(null==t?void 0:t.text)&&rt(this.attributes,null==t?void 0:t.attributes)}copyWithText(t){return new Be(t,this.attributes)}copyWithoutText(){return this.copyWithText(null)}copyWithAttributes(t){return new Be(this.text,t)}copyWithoutAttributes(){return this.copyWithAttributes(null)}copyUsingObjectMap(t){const o=t.find(this.text);return o?this.copyWithText(o):this.copyWithText(this.text.copyUsingObjectMap(t))}addAttribute(t){const o=this.attributes.concat(je(t));return this.copyWithAttributes(o)}removeAttribute(t){const{listAttribute:o}=gt(t),s=Ue(Ue(this.attributes,t),o);return this.copyWithAttributes(s)}removeLastAttribute(){return this.removeAttribute(this.getLastAttribute())}getLastAttribute(){return We(this.attributes)}getAttributes(){return this.attributes.slice(0)}getAttributeLevel(){return this.attributes.length}getAttributeAtLevel(t){return this.attributes[t-1]}hasAttribute(t){return this.attributes.includes(t)}hasAttributes(){return this.getAttributeLevel()>0}getLastNestableAttribute(){return We(this.getNestableAttributes())}getNestableAttributes(){return this.attributes.filter((t=>gt(t).nestable))}getNestingLevel(){return this.getNestableAttributes().length}decreaseNestingLevel(){const t=this.getLastNestableAttribute();return t?this.removeAttribute(t):this}increaseNestingLevel(){const t=this.getLastNestableAttribute();if(t){const o=this.attributes.lastIndexOf(t),s=ot(this.attributes,o+1,0,...je(t));return this.copyWithAttributes(s)}return this}getListItemAttributes(){return this.attributes.filter((t=>gt(t).listAttribute))}isListItem(){var t;return null===(t=gt(this.getLastAttribute()))||void 0===t?void 0:t.listAttribute}isTerminalBlock(){var t;return null===(t=gt(this.getLastAttribute()))||void 0===t?void 0:t.terminal}breaksOnReturn(){var t;return null===(t=gt(this.getLastAttribute()))||void 0===t?void 0:t.breakOnReturn}findLineBreakInDirectionFromPosition(t,o){const s=this.toString();let a;switch(t){case"forward":a=s.indexOf("\n",o);break;case"backward":a=s.slice(0,o).lastIndexOf("\n")}if(-1!==a)return a}contentsForInspection(){return{text:this.text.inspect(),attributes:this.attributes}}toString(){return this.text.toString()}toJSON(){return{text:this.text,attributes:this.attributes}}getDirection(){return this.text.getDirection()}isRTL(){return this.text.isRTL()}getLength(){return this.text.getLength()}canBeConsolidatedWith(t){return!this.hasAttributes()&&!t.hasAttributes()&&this.getDirection()===t.getDirection()}consolidateWith(t){const o=Te.textForStringWithAttributes("\n"),s=this.getTextWithoutBlockBreak().appendText(o);return this.copyWithText(s.appendText(t.text))}splitAtOffset(t){let o,s;return 0===t?(o=null,s=this):t===this.getLength()?(o=this,s=null):(o=this.copyWithText(this.text.getTextAtRange([0,t])),s=this.copyWithText(this.text.getTextAtRange([t,this.getLength()]))),[o,s]}getBlockBreakPosition(){return this.text.getLength()-1}getTextWithoutBlockBreak(){return Oe(this.text)?this.text.getTextAtRange([0,this.getBlockBreakPosition()]):this.text.copy()}canBeGrouped(t){return this.attributes[t]}canBeGroupedWith(t,o){const s=t.getAttributes(),l=s[o],c=this.attributes[o];return c===l&&!(!1===gt(c).group&&!(()=>{if(!Ut){Ut=[];for(const t in a){const{listAttribute:o}=a[t];null!=o&&Ut.push(o)}}return Ut})().includes(s[o+1]))&&(this.getDirection()===t.getDirection()||t.isEmpty())}}const Fe=function(t){return t=Ie(t),Ne(t)},Ie=function(t){let o=!1;const s=t.getPieces();let a=s.slice(0,s.length-1);const l=s[s.length-1];return l?(a=a.map((t=>t.isBlockBreak()?(o=!0,Me(t)):t)),o?new Te([...a,l]):t):t},ri=Te.textForStringWithAttributes("\n",{blockBreak:!0}),Ne=function(t){return Oe(t)?t:t.appendText(ri)},Oe=function(t){const o=t.getLength();return 0!==o&&t.getTextAtRange([o-1,o]).isBlockBreak()},Me=t=>t.copyWithoutAttribute("blockBreak"),je=function(t){const{listAttribute:o}=gt(t);return o?[o,t]:[t]},We=t=>t.slice(-1)[0],Ue=function(t,o){const s=t.lastIndexOf(o);return-1===s?t:ot(t,s,1)};class qe extends nt{static fromJSON(t){return new this(Array.from(t).map((t=>Be.fromJSON(t))))}static fromString(t,o){const s=Te.textForStringWithAttributes(t,o);return new this([new Be(s)])}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];super(...arguments),0===t.length&&(t=[new Be]),this.blockList=ke.box(t)}isEmpty(){const t=this.getBlockAtIndex(0);return 1===this.blockList.length&&t.isEmpty()&&!t.hasAttributes()}copy(){const t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).consolidateBlocks?this.blockList.consolidate().toArray():this.blockList.toArray();return new this.constructor(t)}copyUsingObjectsFromDocument(t){const o=new Yt(t.getObjects());return this.copyUsingObjectMap(o)}copyUsingObjectMap(t){const o=this.getBlocks().map((o=>t.find(o)||o.copyUsingObjectMap(t)));return new this.constructor(o)}copyWithBaseBlockAttributes(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];const o=this.getBlocks().map((o=>{const s=t.concat(o.getAttributes());return o.copyWithAttributes(s)}));return new this.constructor(o)}replaceBlock(t,o){const s=this.blockList.indexOf(t);return-1===s?this:new this.constructor(this.blockList.replaceObjectAtIndex(o,s))}insertDocumentAtRange(t,o){const{blockList:s}=t;o=Lt(o);let[a]=o;const{index:l,offset:c}=this.locationFromPosition(a);let u=this;const d=this.getBlockAtPosition(a);return Dt(o)&&d.isEmpty()&&!d.hasAttributes()?u=new this.constructor(u.blockList.removeObjectAtIndex(l)):d.getBlockBreakPosition()===c&&a++,u=u.removeTextAtRange(o),new this.constructor(u.blockList.insertSplittableListAtPosition(s,a))}mergeDocumentAtRange(t,o){let s,a;o=Lt(o);const[l]=o,c=this.locationFromPosition(l),u=this.getBlockAtIndex(c.index).getAttributes(),d=t.getBaseBlockAttributes(),m=u.slice(-d.length);if(rt(d,m)){const o=u.slice(0,-d.length);s=t.copyWithBaseBlockAttributes(o)}else s=t.copy({consolidateBlocks:!0}).copyWithBaseBlockAttributes(u);const p=s.getBlockCount(),L=s.getBlockAtIndex(0);if(rt(u,L.getAttributes())){const t=L.getTextWithoutBlockBreak();if(a=this.insertTextAtRange(t,o),p>1){s=new this.constructor(s.getBlocks().slice(1));const o=l+t.getLength();a=a.insertDocumentAtRange(s,o)}}else a=this.insertDocumentAtRange(s,o);return a}insertTextAtRange(t,o){o=Lt(o);const[s]=o,{index:a,offset:l}=this.locationFromPosition(s),c=this.removeTextAtRange(o);return new this.constructor(c.blockList.editObjectAtIndex(a,(o=>o.copyWithText(o.text.insertTextAtPosition(t,l)))))}removeTextAtRange(t){let o;t=Lt(t);const[s,a]=t;if(Dt(t))return this;const[l,c]=Array.from(this.locationRangeFromRange(t)),u=l.index,d=l.offset,m=this.getBlockAtIndex(u),p=c.index,L=c.offset,M=this.getBlockAtIndex(p);if(a-s==1&&m.getBlockBreakPosition()===d&&M.getBlockBreakPosition()!==L&&"\n"===M.text.getStringAtPosition(L))o=this.blockList.editObjectAtIndex(p,(t=>t.copyWithText(t.text.removeTextAtRange([L,L+1]))));else{let t;const s=m.text.getTextAtRange([0,d]),a=M.text.getTextAtRange([L,M.getLength()]),l=s.appendText(a);t=u!==p&&0===d&&m.getAttributeLevel()>=M.getAttributeLevel()?M.copyWithText(l):m.copyWithText(l);const c=p+1-u;o=this.blockList.splice(u,c,t)}return new this.constructor(o)}moveTextFromRangeToPosition(t,o){let s;t=Lt(t);const[a,l]=t;if(a<=o&&o<=l)return this;let c=this.getDocumentAtRange(t),u=this.removeTextAtRange(t);const d=a<o;d&&(o-=c.getLength());const[m,...p]=c.getBlocks();return 0===p.length?(s=m.getTextWithoutBlockBreak(),d&&(o+=1)):s=m.text,u=u.insertTextAtRange(s,o),0===p.length?u:(c=new this.constructor(p),o+=s.getLength(),u.insertDocumentAtRange(c,o))}addAttributeAtRange(t,o,s){let{blockList:a}=this;return this.eachBlockAtRange(s,((s,l,c)=>a=a.editObjectAtIndex(c,(function(){return gt(t)?s.addAttribute(t,o):l[0]===l[1]?s:s.copyWithText(s.text.addAttributeAtRange(t,o,l))})))),new this.constructor(a)}addAttribute(t,o){let{blockList:s}=this;return this.eachBlock(((a,l)=>s=s.editObjectAtIndex(l,(()=>a.addAttribute(t,o))))),new this.constructor(s)}removeAttributeAtRange(t,o){let{blockList:s}=this;return this.eachBlockAtRange(o,(function(o,a,l){gt(t)?s=s.editObjectAtIndex(l,(()=>o.removeAttribute(t))):a[0]!==a[1]&&(s=s.editObjectAtIndex(l,(()=>o.copyWithText(o.text.removeAttributeAtRange(t,a)))))})),new this.constructor(s)}updateAttributesForAttachment(t,o){const s=this.getRangeOfAttachment(o),[a]=Array.from(s),{index:l}=this.locationFromPosition(a),c=this.getTextAtIndex(l);return new this.constructor(this.blockList.editObjectAtIndex(l,(s=>s.copyWithText(c.updateAttributesForAttachment(t,o)))))}removeAttributeForAttachment(t,o){const s=this.getRangeOfAttachment(o);return this.removeAttributeAtRange(t,s)}insertBlockBreakAtRange(t){let o;t=Lt(t);const[s]=t,{offset:a}=this.locationFromPosition(s),l=this.removeTextAtRange(t);return 0===a&&(o=[new Be]),new this.constructor(l.blockList.insertSplittableListAtPosition(new ke(o),s))}applyBlockAttributeAtRange(t,o,s){const a=this.expandRangeToLineBreaksAndSplitBlocks(s);let l=a.document;s=a.range;const c=gt(t);if(c.listAttribute){l=l.removeLastListAttributeAtRange(s,{exceptAttributeName:t});const o=l.convertLineBreaksToBlockBreaksInRange(s);l=o.document,s=o.range}else l=c.exclusive?l.removeBlockAttributesAtRange(s):c.terminal?l.removeLastTerminalAttributeAtRange(s):l.consolidateBlocksAtRange(s);return l.addAttributeAtRange(t,o,s)}removeLastListAttributeAtRange(t){let o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{blockList:s}=this;return this.eachBlockAtRange(t,(function(t,a,l){const c=t.getLastAttribute();c&>(c).listAttribute&&c!==o.exceptAttributeName&&(s=s.editObjectAtIndex(l,(()=>t.removeAttribute(c))))})),new this.constructor(s)}removeLastTerminalAttributeAtRange(t){let{blockList:o}=this;return this.eachBlockAtRange(t,(function(t,s,a){const l=t.getLastAttribute();l&>(l).terminal&&(o=o.editObjectAtIndex(a,(()=>t.removeAttribute(l))))})),new this.constructor(o)}removeBlockAttributesAtRange(t){let{blockList:o}=this;return this.eachBlockAtRange(t,(function(t,s,a){t.hasAttributes()&&(o=o.editObjectAtIndex(a,(()=>t.copyWithoutAttributes())))})),new this.constructor(o)}expandRangeToLineBreaksAndSplitBlocks(t){let o;t=Lt(t);let[s,a]=t;const l=this.locationFromPosition(s),c=this.locationFromPosition(a);let u=this;const d=u.getBlockAtIndex(l.index);if(l.offset=d.findLineBreakInDirectionFromPosition("backward",l.offset),null!=l.offset&&(o=u.positionFromLocation(l),u=u.insertBlockBreakAtRange([o,o+1]),c.index+=1,c.offset-=u.getBlockAtIndex(l.index).getLength(),l.index+=1),l.offset=0,0===c.offset&&c.index>l.index)c.index-=1,c.offset=u.getBlockAtIndex(c.index).getBlockBreakPosition();else{const t=u.getBlockAtIndex(c.index);"\n"===t.text.getStringAtRange([c.offset-1,c.offset])?c.offset-=1:c.offset=t.findLineBreakInDirectionFromPosition("forward",c.offset),c.offset!==t.getBlockBreakPosition()&&(o=u.positionFromLocation(c),u=u.insertBlockBreakAtRange([o,o+1]))}return s=u.positionFromLocation(l),a=u.positionFromLocation(c),{document:u,range:t=Lt([s,a])}}convertLineBreaksToBlockBreaksInRange(t){t=Lt(t);let[o]=t;const s=this.getStringAtRange(t).slice(0,-1);let a=this;return s.replace(/.*?\n/g,(function(t){o+=t.length,a=a.insertBlockBreakAtRange([o-1,o])})),{document:a,range:t}}consolidateBlocksAtRange(t){t=Lt(t);const[o,s]=t,a=this.locationFromPosition(o).index,l=this.locationFromPosition(s).index;return new this.constructor(this.blockList.consolidateFromIndexToIndex(a,l))}getDocumentAtRange(t){t=Lt(t);const o=this.blockList.getSplittableListInRange(t).toArray();return new this.constructor(o)}getStringAtRange(t){let o;const s=t=Lt(t);return s[s.length-1]!==this.getLength()&&(o=-1),this.getDocumentAtRange(t).toString().slice(0,o)}getBlockAtIndex(t){return this.blockList.getObjectAtIndex(t)}getBlockAtPosition(t){const{index:o}=this.locationFromPosition(t);return this.getBlockAtIndex(o)}getTextAtIndex(t){var o;return null===(o=this.getBlockAtIndex(t))||void 0===o?void 0:o.text}getTextAtPosition(t){const{index:o}=this.locationFromPosition(t);return this.getTextAtIndex(o)}getPieceAtPosition(t){const{index:o,offset:s}=this.locationFromPosition(t);return this.getTextAtIndex(o).getPieceAtPosition(s)}getCharacterAtPosition(t){const{index:o,offset:s}=this.locationFromPosition(t);return this.getTextAtIndex(o).getStringAtRange([s,s+1])}getLength(){return this.blockList.getEndPosition()}getBlocks(){return this.blockList.toArray()}getBlockCount(){return this.blockList.length}getEditCount(){return this.editCount}eachBlock(t){return this.blockList.eachObject(t)}eachBlockAtRange(t,o){let s,a;t=Lt(t);const[l,c]=t,u=this.locationFromPosition(l),d=this.locationFromPosition(c);if(u.index===d.index)return s=this.getBlockAtIndex(u.index),a=[u.offset,d.offset],o(s,a,u.index);for(let t=u.index;t<=d.index;t++)if(s=this.getBlockAtIndex(t),s){switch(t){case u.index:a=[u.offset,s.text.getLength()];break;case d.index:a=[0,d.offset];break;default:a=[0,s.text.getLength()]}o(s,a,t)}}getCommonAttributesAtRange(t){t=Lt(t);const[o]=t;if(Dt(t))return this.getCommonAttributesAtPosition(o);{const o=[],s=[];return this.eachBlockAtRange(t,(function(t,a){if(a[0]!==a[1])return o.push(t.text.getCommonAttributesAtRange(a)),s.push(Ve(t))})),_t.fromCommonAttributesOfObjects(o).merge(_t.fromCommonAttributesOfObjects(s)).toObject()}}getCommonAttributesAtPosition(t){let o,s;const{index:a,offset:l}=this.locationFromPosition(t),c=this.getBlockAtIndex(a);if(!c)return{};const u=Ve(c),d=c.text.getAttributesAtPosition(l),m=c.text.getAttributesAtPosition(l-1),p=Object.keys(H).filter((t=>H[t].inheritable));for(o in m)s=m[o],(s===d[o]||p.includes(o))&&(u[o]=s);return u}getRangeOfCommonAttributeAtPosition(t,o){const{index:s,offset:a}=this.locationFromPosition(o),l=this.getTextAtIndex(s),[c,u]=Array.from(l.getExpandedRangeForAttributeAtOffset(t,a)),d=this.positionFromLocation({index:s,offset:c}),m=this.positionFromLocation({index:s,offset:u});return Lt([d,m])}getBaseBlockAttributes(){let t=this.getBlockAtIndex(0).getAttributes();for(let o=1;o<this.getBlockCount();o++){const s=this.getBlockAtIndex(o).getAttributes(),a=Math.min(t.length,s.length);t=(()=>{const o=[];for(let l=0;l<a&&s[l]===t[l];l++)o.push(s[l]);return o})()}return t}getAttachmentById(t){for(const o of this.getAttachments())if(o.id===t)return o}getAttachmentPieces(){let t=[];return this.blockList.eachObject((o=>{let{text:s}=o;return t=t.concat(s.getAttachmentPieces())})),t}getAttachments(){return this.getAttachmentPieces().map((t=>t.attachment))}getRangeOfAttachment(t){let o=0;const s=this.blockList.toArray();for(let a=0;a<s.length;a++){const{text:l}=s[a],c=l.getRangeOfAttachment(t);if(c)return Lt([o+c[0],o+c[1]]);o+=l.getLength()}}getLocationRangeOfAttachment(t){const o=this.getRangeOfAttachment(t);return this.locationRangeFromRange(o)}getAttachmentPieceForAttachment(t){for(const o of this.getAttachmentPieces())if(o.attachment===t)return o}findRangesForBlockAttribute(t){let o=0;const s=[];return this.getBlocks().forEach((a=>{const l=a.getLength();a.hasAttribute(t)&&s.push([o,o+l]),o+=l})),s}findRangesForTextAttribute(t){let{withValue:o}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=0,a=[];const l=[];return this.getPieces().forEach((c=>{const u=c.getLength();(function(s){return o?s.getAttribute(t)===o:s.hasAttribute(t)})(c)&&(a[1]===s?a[1]=s+u:l.push(a=[s,s+u])),s+=u})),l}locationFromPosition(t){const o=this.blockList.findIndexAndOffsetAtPosition(Math.max(0,t));if(null!=o.index)return o;{const t=this.getBlocks();return{index:t.length-1,offset:t[t.length-1].getLength()}}}positionFromLocation(t){return this.blockList.findPositionAtIndexAndOffset(t.index,t.offset)}locationRangeFromPosition(t){return Lt(this.locationFromPosition(t))}locationRangeFromRange(t){if(!(t=Lt(t)))return;const[o,s]=Array.from(t),a=this.locationFromPosition(o),l=this.locationFromPosition(s);return Lt([a,l])}rangeFromLocationRange(t){let o;t=Lt(t);const s=this.positionFromLocation(t[0]);return Dt(t)||(o=this.positionFromLocation(t[1])),Lt([s,o])}isEqualTo(t){return this.blockList.isEqualTo(null==t?void 0:t.blockList)}getTexts(){return this.getBlocks().map((t=>t.text))}getPieces(){const t=[];return Array.from(this.getTexts()).forEach((o=>{t.push(...Array.from(o.getPieces()||[]))})),t}getObjects(){return this.getBlocks().concat(this.getTexts()).concat(this.getPieces())}toSerializableDocument(){const t=[];return this.blockList.eachObject((o=>t.push(o.copyWithText(o.text.toSerializableText())))),new this.constructor(t)}toString(){return this.blockList.toString()}toJSON(){return this.blockList.toJSON()}toConsole(){return JSON.stringify(this.blockList.toArray().map((t=>JSON.parse(t.text.toConsole()))))}}const Ve=function(t){const o={},s=t.getLastAttribute();return s&&(o[s]=!0),o},oi="style href src width height class".split(" "),si="javascript:".split(" "),ai="script iframe form".split(" ");class Je extends z{static sanitize(t,o){const s=new this(t,o);return s.sanitize(),s}constructor(t){let{allowedAttributes:o,forbiddenProtocols:s,forbiddenElements:a}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(...arguments),this.allowedAttributes=o||oi,this.forbiddenProtocols=s||si,this.forbiddenElements=a||ai,this.body=Ke(t)}sanitize(){return this.sanitizeElements(),this.normalizeListElementNesting()}getHTML(){return this.body.innerHTML}getBody(){return this.body}sanitizeElements(){const t=S(this.body),o=[];for(;t.nextNode();){const s=t.currentNode;switch(s.nodeType){case Node.ELEMENT_NODE:this.elementIsRemovable(s)?o.push(s):this.sanitizeElement(s);break;case Node.COMMENT_NODE:o.push(s)}}return o.forEach((t=>R(t))),this.body}sanitizeElement(t){return t.hasAttribute("href")&&this.forbiddenProtocols.includes(t.protocol)&&t.removeAttribute("href"),Array.from(t.attributes).forEach((o=>{let{name:s}=o;this.allowedAttributes.includes(s)||0===s.indexOf("data-trix")||t.removeAttribute(s)})),t}normalizeListElementNesting(){return Array.from(this.body.querySelectorAll("ul,ol")).forEach((t=>{const o=t.previousElementSibling;o&&"li"===E(o)&&o.appendChild(t)})),this.body}elementIsRemovable(t){if((null==t?void 0:t.nodeType)===Node.ELEMENT_NODE)return this.elementIsForbidden(t)||this.elementIsntSerializable(t)}elementIsForbidden(t){return this.forbiddenElements.includes(E(t))}elementIsntSerializable(t){return"false"===t.getAttribute("data-trix-serialize")&&!P(t)}}const Ke=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";t=t.replace(/<\/html[^>]*>[^]*$/i,"</html>");const o=document.implementation.createHTMLDocument("");return o.documentElement.innerHTML=t,Array.from(o.head.querySelectorAll("style")).forEach((t=>{o.body.appendChild(t)})),o.body},Ge=function(t){let o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return{string:t=Wt(t),attributes:o,type:"string"}},$e=(t,o)=>{try{return JSON.parse(t.getAttribute("data-trix-".concat(o)))}catch(t){return{}}};class Xe extends z{static parse(t,o){const s=new this(t,o);return s.parse(),s}constructor(t){let{referenceElement:o}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(...arguments),this.html=t,this.referenceElement=o,this.blocks=[],this.blockElements=[],this.processedElements=[]}getDocument(){return qe.fromJSON(this.blocks)}parse(){try{this.createHiddenContainer();const t=Je.sanitize(this.html).getHTML();this.containerElement.innerHTML=t;const o=S(this.containerElement,{usingFilter:ti});for(;o.nextNode();)this.processNode(o.currentNode);return this.translateBlockElementMarginsToNewlines()}finally{this.removeHiddenContainer()}}createHiddenContainer(){return this.referenceElement?(this.containerElement=this.referenceElement.cloneNode(!1),this.containerElement.removeAttribute("id"),this.containerElement.setAttribute("data-trix-internal",""),this.containerElement.style.display="none",this.referenceElement.parentNode.insertBefore(this.containerElement,this.referenceElement.nextSibling)):(this.containerElement=k({tagName:"div",style:{display:"none"}}),document.body.appendChild(this.containerElement))}removeHiddenContainer(){return R(this.containerElement)}processNode(t){switch(t.nodeType){case Node.TEXT_NODE:if(!this.isInsignificantTextNode(t))return this.appendBlockForTextNode(t),this.processTextNode(t);break;case Node.ELEMENT_NODE:return this.appendBlockForElement(t),this.processElement(t)}}appendBlockForTextNode(t){const o=t.parentNode;if(o===this.currentBlockElement&&this.isBlockElement(t.previousSibling))return this.appendStringWithAttributes("\n");if(o===this.containerElement||this.isBlockElement(o)){var s;const t=this.getBlockAttributes(o);rt(t,null===(s=this.currentBlock)||void 0===s?void 0:s.attributes)||(this.currentBlock=this.appendBlockForAttributesWithElement(t,o),this.currentBlockElement=o)}}appendBlockForElement(t){const o=this.isBlockElement(t),s=y(this.currentBlockElement,t);if(o&&!this.isBlockElement(t.firstChild)){if(!this.isInsignificantTextNode(t.firstChild)||!this.isBlockElement(t.firstElementChild)){const o=this.getBlockAttributes(t);if(t.firstChild){if(s&&rt(o,this.currentBlock.attributes))return this.appendStringWithAttributes("\n");this.currentBlock=this.appendBlockForAttributesWithElement(o,t),this.currentBlockElement=t}}}else if(this.currentBlockElement&&!s&&!o){const o=this.findParentBlockElement(t);if(o)return this.appendBlockForElement(o);this.currentBlock=this.appendEmptyBlock(),this.currentBlockElement=null}}findParentBlockElement(t){let{parentElement:o}=t;for(;o&&o!==this.containerElement;){if(this.isBlockElement(o)&&this.blockElements.includes(o))return o;o=o.parentElement}return null}processTextNode(t){let o=t.data;var s;Ye(t.parentNode)||(o=qt(o),ni(null===(s=t.previousSibling)||void 0===s?void 0:s.textContent)&&(o=ei(o)));return this.appendStringWithAttributes(o,this.getTextAttributes(t.parentNode))}processElement(t){let o;if(P(t)){if(o=$e(t,"attachment"),Object.keys(o).length){const s=this.getTextAttributes(t);this.appendAttachmentWithAttributes(o,s),t.innerHTML=""}return this.processedElements.push(t)}switch(E(t)){case"br":return this.isExtraBR(t)||this.isBlockElement(t.nextSibling)||this.appendStringWithAttributes("\n",this.getTextAttributes(t)),this.processedElements.push(t);case"img":o={url:t.getAttribute("src"),contentType:"image"};const s=(t=>{const o=t.getAttribute("width"),s=t.getAttribute("height"),a={};return o&&(a.width=parseInt(o,10)),s&&(a.height=parseInt(s,10)),a})(t);for(const t in s){const a=s[t];o[t]=a}return this.appendAttachmentWithAttributes(o,this.getTextAttributes(t)),this.processedElements.push(t);case"tr":if(this.needsTableSeparator(t))return this.appendStringWithAttributes(V.tableRowSeparator);break;case"td":if(this.needsTableSeparator(t))return this.appendStringWithAttributes(V.tableCellSeparator)}}appendBlockForAttributesWithElement(t,o){this.blockElements.push(o);const s=function(){return{text:[],attributes:arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}}}(t);return this.blocks.push(s),s}appendEmptyBlock(){return this.appendBlockForAttributesWithElement([],null)}appendStringWithAttributes(t,o){return this.appendPiece(Ge(t,o))}appendAttachmentWithAttributes(t,o){return this.appendPiece(function(t){return{attachment:t,attributes:arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},type:"attachment"}}(t,o))}appendPiece(t){return 0===this.blocks.length&&this.appendEmptyBlock(),this.blocks[this.blocks.length-1].text.push(t)}appendStringToTextAtIndex(t,o){const{text:s}=this.blocks[o],a=s[s.length-1];if("string"!==(null==a?void 0:a.type))return s.push(Ge(t));a.string+=t}prependStringToTextAtIndex(t,o){const{text:s}=this.blocks[o],a=s[0];if("string"!==(null==a?void 0:a.type))return s.unshift(Ge(t));a.string=t+a.string}getTextAttributes(t){let o;const s={};for(const a in H){const l=H[a];if(l.tagName&&A(t,{matchingSelector:l.tagName,untilNode:this.containerElement}))s[a]=!0;else if(l.parser){if(o=l.parser(t),o){let c=!1;for(const s of this.findBlockElementAncestors(t))if(l.parser(s)===o){c=!0;break}c||(s[a]=o)}}else l.styleProperty&&(o=t.style[l.styleProperty],o&&(s[a]=o))}if(P(t)){const a=$e(t,"attributes");for(const t in a)o=a[t],s[t]=o}return s}getBlockAttributes(t){const o=[];for(;t&&t!==this.containerElement;){for(const l in a){const c=a[l];var s;!1!==c.parse&&E(t)===c.tagName&&(null!==(s=c.test)&&void 0!==s&&s.call(c,t)||!c.test)&&(o.push(l),c.listAttribute&&o.push(c.listAttribute))}t=t.parentNode}return o.reverse()}findBlockElementAncestors(t){const o=[];for(;t&&t!==this.containerElement;){const s=E(t);D().includes(s)&&o.push(t),t=t.parentNode}return o}isBlockElement(t){if((null==t?void 0:t.nodeType)===Node.ELEMENT_NODE&&!P(t)&&!A(t,{matchingSelector:"td",untilNode:this.containerElement}))return D().includes(E(t))||"block"===window.getComputedStyle(t).display}isInsignificantTextNode(t){if((null==t?void 0:t.nodeType)!==Node.TEXT_NODE)return;if(!ii(t.data))return;const{parentNode:o,previousSibling:s,nextSibling:a}=t;return Qe(o.previousSibling)&&!this.isBlockElement(o.previousSibling)||Ye(o)?void 0:!s||this.isBlockElement(s)||!a||this.isBlockElement(a)}isExtraBR(t){return"br"===E(t)&&this.isBlockElement(t.parentNode)&&t.parentNode.lastChild===t}needsTableSeparator(t){if(V.removeBlankTableCells){var o;const s=null===(o=t.previousSibling)||void 0===o?void 0:o.textContent;return s&&/\S/.test(s)}return t.previousSibling}translateBlockElementMarginsToNewlines(){const t=this.getMarginOfDefaultBlockElement();for(let o=0;o<this.blocks.length;o++){const s=this.getMarginOfBlockElementAtIndex(o);s&&(s.top>2*t.top&&this.prependStringToTextAtIndex("\n",o),s.bottom>2*t.bottom&&this.appendStringToTextAtIndex("\n",o))}}getMarginOfBlockElementAtIndex(t){const o=this.blockElements[t];if(o&&o.textContent&&!D().includes(E(o))&&!this.processedElements.includes(o))return Ze(o)}getMarginOfDefaultBlockElement(){const t=k(a.default.tagName);return this.containerElement.appendChild(t),Ze(t)}}const Ye=function(t){const{whiteSpace:o}=window.getComputedStyle(t);return["pre","pre-wrap","pre-line"].includes(o)},Qe=t=>t&&!ni(t.textContent),Ze=function(t){const o=window.getComputedStyle(t);if("block"===o.display)return{top:parseInt(o.marginTop),bottom:parseInt(o.marginBottom)}},ti=function(t){return"style"===E(t)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT},ei=t=>t.replace(new RegExp("^".concat(ze.source,"+")),""),ii=t=>new RegExp("^".concat(ze.source,"*$")).test(t),ni=t=>/\s$/.test(t),li=["contenteditable","data-trix-id","data-trix-store-key","data-trix-mutable","data-trix-placeholder","tabindex"],ci="data-trix-serialized-attributes",fi="[".concat(ci,"]"),Ai=new RegExp("\x3c!--block--\x3e","g"),Di={"application/json":function(t){let o;if(t instanceof qe)o=t;else{if(!(t instanceof HTMLElement))throw new Error("unserializable object");o=Xe.parse(t.innerHTML).getDocument()}return o.toSerializableDocument().toJSONString()},"text/html":function(t){let o;if(t instanceof qe)o=ge.render(t);else{if(!(t instanceof HTMLElement))throw new Error("unserializable object");o=t.cloneNode(!0)}return Array.from(o.querySelectorAll("[data-trix-serialize=false]")).forEach((t=>{R(t)})),li.forEach((t=>{Array.from(o.querySelectorAll("[".concat(t,"]"))).forEach((o=>{o.removeAttribute(t)}))})),Array.from(o.querySelectorAll(fi)).forEach((t=>{try{const o=JSON.parse(t.getAttribute(ci));t.removeAttribute(ci);for(const s in o){const a=o[s];t.setAttribute(s,a)}}catch(t){}})),o.innerHTML.replace(Ai,"")}};var wi=Object.freeze({__proto__:null});class hi extends z{constructor(t,o){super(...arguments),this.attachmentManager=t,this.attachment=o,this.id=this.attachment.id,this.file=this.attachment.file}remove(){return this.attachmentManager.requestRemovalOfAttachment(this.attachment)}}hi.proxyMethod("attachment.getAttribute"),hi.proxyMethod("attachment.hasAttribute"),hi.proxyMethod("attachment.setAttribute"),hi.proxyMethod("attachment.getAttributes"),hi.proxyMethod("attachment.setAttributes"),hi.proxyMethod("attachment.isPending"),hi.proxyMethod("attachment.isPreviewable"),hi.proxyMethod("attachment.getURL"),hi.proxyMethod("attachment.getHref"),hi.proxyMethod("attachment.getFilename"),hi.proxyMethod("attachment.getFilesize"),hi.proxyMethod("attachment.getFormattedFilesize"),hi.proxyMethod("attachment.getExtension"),hi.proxyMethod("attachment.getContentType"),hi.proxyMethod("attachment.getFile"),hi.proxyMethod("attachment.setFile"),hi.proxyMethod("attachment.releaseFile"),hi.proxyMethod("attachment.getUploadProgress"),hi.proxyMethod("attachment.setUploadProgress");class ui extends z{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];super(...arguments),this.managedAttachments={},Array.from(t).forEach((t=>{this.manageAttachment(t)}))}getAttachments(){const t=[];for(const o in this.managedAttachments){const s=this.managedAttachments[o];t.push(s)}return t}manageAttachment(t){return this.managedAttachments[t.id]||(this.managedAttachments[t.id]=new hi(this,t)),this.managedAttachments[t.id]}attachmentIsManaged(t){return t.id in this.managedAttachments}requestRemovalOfAttachment(t){var o,s;if(this.attachmentIsManaged(t))return null===(o=this.delegate)||void 0===o||null===(s=o.attachmentManagerDidRequestRemovalOfAttachment)||void 0===s?void 0:s.call(o,t)}unmanageAttachment(t){const o=this.managedAttachments[t.id];return delete this.managedAttachments[t.id],o}}class di{constructor(t){this.composition=t,this.document=this.composition.document;const o=this.composition.getSelectedRange();this.startPosition=o[0],this.endPosition=o[1],this.startLocation=this.document.locationFromPosition(this.startPosition),this.endLocation=this.document.locationFromPosition(this.endPosition),this.block=this.document.getBlockAtIndex(this.endLocation.index),this.breaksOnReturn=this.block.breaksOnReturn(),this.previousCharacter=this.block.text.getStringAtPosition(this.endLocation.offset-1),this.nextCharacter=this.block.text.getStringAtPosition(this.endLocation.offset)}shouldInsertBlockBreak(){return this.block.hasAttributes()&&this.block.isListItem()&&!this.block.isEmpty()?0!==this.startLocation.offset:this.breaksOnReturn&&"\n"!==this.nextCharacter}shouldBreakFormattedBlock(){return this.block.hasAttributes()&&!this.block.isListItem()&&(this.breaksOnReturn&&"\n"===this.nextCharacter||"\n"===this.previousCharacter)}shouldDecreaseListLevel(){return this.block.hasAttributes()&&this.block.isListItem()&&this.block.isEmpty()}shouldPrependListItem(){return this.block.isListItem()&&0===this.startLocation.offset&&!this.block.isEmpty()}shouldRemoveLastBlockAttribute(){return this.block.hasAttributes()&&!this.block.isListItem()&&this.block.isEmpty()}}class gi extends z{constructor(){super(...arguments),this.document=new qe,this.attachments=[],this.currentAttributes={},this.revision=0}setDocument(t){var o,s;if(!t.isEqualTo(this.document))return this.document=t,this.refreshAttachments(),this.revision++,null===(o=this.delegate)||void 0===o||null===(s=o.compositionDidChangeDocument)||void 0===s?void 0:s.call(o,t)}getSnapshot(){return{document:this.document,selectedRange:this.getSelectedRange()}}loadSnapshot(t){var o,s,a,l;let{document:c,selectedRange:u}=t;return null===(o=this.delegate)||void 0===o||null===(s=o.compositionWillLoadSnapshot)||void 0===s||s.call(o),this.setDocument(null!=c?c:new qe),this.setSelection(null!=u?u:[0,0]),null===(a=this.delegate)||void 0===a||null===(l=a.compositionDidLoadSnapshot)||void 0===l?void 0:l.call(a)}insertText(t){let{updatePosition:o}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{updatePosition:!0};const s=this.getSelectedRange();this.setDocument(this.document.insertTextAtRange(t,s));const a=s[0],l=a+t.getLength();return o&&this.setSelection(l),this.notifyDelegateOfInsertionAtRange([a,l])}insertBlock(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Be;const o=new qe([t]);return this.insertDocument(o)}insertDocument(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new qe;const o=this.getSelectedRange();this.setDocument(this.document.insertDocumentAtRange(t,o));const s=o[0],a=s+t.getLength();return this.setSelection(a),this.notifyDelegateOfInsertionAtRange([s,a])}insertString(t,o){const s=this.getCurrentTextAttributes(),a=Te.textForStringWithAttributes(t,s);return this.insertText(a,o)}insertBlockBreak(){const t=this.getSelectedRange();this.setDocument(this.document.insertBlockBreakAtRange(t));const o=t[0],s=o+1;return this.setSelection(s),this.notifyDelegateOfInsertionAtRange([o,s])}insertLineBreak(){const t=new di(this);if(t.shouldDecreaseListLevel())return this.decreaseListLevel(),this.setSelection(t.startPosition);if(t.shouldPrependListItem()){const o=new qe([t.block.copyWithoutText()]);return this.insertDocument(o)}return t.shouldInsertBlockBreak()?this.insertBlockBreak():t.shouldRemoveLastBlockAttribute()?this.removeLastBlockAttribute():t.shouldBreakFormattedBlock()?this.breakFormattedBlock(t):this.insertString("\n")}insertHTML(t){const o=Xe.parse(t).getDocument(),s=this.getSelectedRange();this.setDocument(this.document.mergeDocumentAtRange(o,s));const a=s[0],l=a+o.getLength()-1;return this.setSelection(l),this.notifyDelegateOfInsertionAtRange([a,l])}replaceHTML(t){const o=Xe.parse(t).getDocument().copyUsingObjectsFromDocument(this.document),s=this.getLocationRange({strict:!1}),a=this.document.rangeFromLocationRange(s);return this.setDocument(o),this.setSelection(a)}insertFile(t){return this.insertFiles([t])}insertFiles(t){const o=[];return Array.from(t).forEach((t=>{var s;if(null!==(s=this.delegate)&&void 0!==s&&s.compositionShouldAcceptFile(t)){const s=Re.attachmentForFile(t);o.push(s)}})),this.insertAttachments(o)}insertAttachment(t){return this.insertAttachments([t])}insertAttachments(t){let o=new Te;return Array.from(t).forEach((t=>{var a;const l=t.getType(),c=null===(a=s[l])||void 0===a?void 0:a.presentation,u=this.getCurrentTextAttributes();c&&(u.presentation=c);const d=Te.textForAttachmentWithAttributes(t,u);o=o.appendText(d)})),this.insertText(o)}shouldManageDeletingInDirection(t){const o=this.getLocationRange();if(Dt(o)){if("backward"===t&&0===o[0].offset)return!0;if(this.shouldManageMovingCursorInDirection(t))return!0}else if(o[0].index!==o[1].index)return!0;return!1}deleteInDirection(t){let o,s,a,{length:l}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const c=this.getLocationRange();let u=this.getSelectedRange();const d=Dt(u);if(d?s="backward"===t&&0===c[0].offset:a=c[0].index!==c[1].index,s&&this.canDecreaseBlockAttributeLevel()){const t=this.getBlock();if(t.isListItem()?this.decreaseListLevel():this.decreaseBlockAttributeLevel(),this.setSelection(u[0]),t.isEmpty())return!1}return d&&(u=this.getExpandedRangeInDirection(t,{length:l}),"backward"===t&&(o=this.getAttachmentAtRange(u))),o?(this.editAttachment(o),!1):(this.setDocument(this.document.removeTextAtRange(u)),this.setSelection(u[0]),!s&&!a&&void 0)}moveTextFromRange(t){const[o]=Array.from(this.getSelectedRange());return this.setDocument(this.document.moveTextFromRangeToPosition(t,o)),this.setSelection(o)}removeAttachment(t){const o=this.document.getRangeOfAttachment(t);if(o)return this.stopEditingAttachment(),this.setDocument(this.document.removeTextAtRange(o)),this.setSelection(o[0])}removeLastBlockAttribute(){const[t,o]=Array.from(this.getSelectedRange()),s=this.document.getBlockAtPosition(o);return this.removeCurrentAttribute(s.getLastAttribute()),this.setSelection(t)}insertPlaceholder(){return this.placeholderPosition=this.getPosition(),this.insertString(" ")}selectPlaceholder(){if(null!=this.placeholderPosition)return this.setSelectedRange([this.placeholderPosition,this.placeholderPosition+1]),this.getSelectedRange()}forgetPlaceholder(){this.placeholderPosition=null}hasCurrentAttribute(t){const o=this.currentAttributes[t];return null!=o&&!1!==o}toggleCurrentAttribute(t){const o=!this.currentAttributes[t];return o?this.setCurrentAttribute(t,o):this.removeCurrentAttribute(t)}canSetCurrentAttribute(t){return gt(t)?this.canSetCurrentBlockAttribute(t):this.canSetCurrentTextAttribute(t)}canSetCurrentTextAttribute(t){const o=this.getSelectedDocument();if(o){for(const t of Array.from(o.getAttachments()))if(!t.hasContent())return!1;return!0}}canSetCurrentBlockAttribute(t){const o=this.getBlock();if(o)return!o.isTerminalBlock()}setCurrentAttribute(t,o){return gt(t)?this.setBlockAttribute(t,o):(this.setTextAttribute(t,o),this.currentAttributes[t]=o,this.notifyDelegateOfCurrentAttributesChange())}setTextAttribute(t,o){const s=this.getSelectedRange();if(!s)return;const[a,l]=Array.from(s);if(a!==l)return this.setDocument(this.document.addAttributeAtRange(t,o,s));if("href"===t){const t=Te.textForStringWithAttributes(o,{href:o});return this.insertText(t)}}setBlockAttribute(t,o){const s=this.getSelectedRange();if(this.canSetCurrentAttribute(t))return this.setDocument(this.document.applyBlockAttributeAtRange(t,o,s)),this.setSelection(s)}removeCurrentAttribute(t){return gt(t)?(this.removeBlockAttribute(t),this.updateCurrentAttributes()):(this.removeTextAttribute(t),delete this.currentAttributes[t],this.notifyDelegateOfCurrentAttributesChange())}removeTextAttribute(t){const o=this.getSelectedRange();if(o)return this.setDocument(this.document.removeAttributeAtRange(t,o))}removeBlockAttribute(t){const o=this.getSelectedRange();if(o)return this.setDocument(this.document.removeAttributeAtRange(t,o))}canDecreaseNestingLevel(){var t;return(null===(t=this.getBlock())||void 0===t?void 0:t.getNestingLevel())>0}canIncreaseNestingLevel(){var t;const o=this.getBlock();if(o){if(null===(t=gt(o.getLastNestableAttribute()))||void 0===t||!t.listAttribute)return o.getNestingLevel()>0;{const t=this.getPreviousBlock();if(t)return function(){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return rt((arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).slice(0,t.length),t)}(t.getListItemAttributes(),o.getListItemAttributes())}}}decreaseNestingLevel(){const t=this.getBlock();if(t)return this.setDocument(this.document.replaceBlock(t,t.decreaseNestingLevel()))}increaseNestingLevel(){const t=this.getBlock();if(t)return this.setDocument(this.document.replaceBlock(t,t.increaseNestingLevel()))}canDecreaseBlockAttributeLevel(){var t;return(null===(t=this.getBlock())||void 0===t?void 0:t.getAttributeLevel())>0}decreaseBlockAttributeLevel(){var t;const o=null===(t=this.getBlock())||void 0===t?void 0:t.getLastAttribute();if(o)return this.removeCurrentAttribute(o)}decreaseListLevel(){let[t]=Array.from(this.getSelectedRange());const{index:o}=this.document.locationFromPosition(t);let s=o;const a=this.getBlock().getAttributeLevel();let l=this.document.getBlockAtIndex(s+1);for(;l&&l.isListItem()&&!(l.getAttributeLevel()<=a);)s++,l=this.document.getBlockAtIndex(s+1);t=this.document.positionFromLocation({index:o,offset:0});const c=this.document.positionFromLocation({index:s,offset:0});return this.setDocument(this.document.removeLastListAttributeAtRange([t,c]))}updateCurrentAttributes(){const t=this.getSelectedRange({ignoreLock:!0});if(t){const o=this.document.getCommonAttributesAtRange(t);if(Array.from(dt()).forEach((t=>{o[t]||this.canSetCurrentAttribute(t)||(o[t]=!1)})),!kt(o,this.currentAttributes))return this.currentAttributes=o,this.notifyDelegateOfCurrentAttributesChange()}}getCurrentAttributes(){return g.call({},this.currentAttributes)}getCurrentTextAttributes(){const t={};for(const o in this.currentAttributes){const s=this.currentAttributes[o];!1!==s&&pt(o)&&(t[o]=s)}return t}freezeSelection(){return this.setCurrentAttribute("frozen",!0)}thawSelection(){return this.removeCurrentAttribute("frozen")}hasFrozenSelection(){return this.hasCurrentAttribute("frozen")}setSelection(t){var o;const s=this.document.locationRangeFromRange(t);return null===(o=this.delegate)||void 0===o?void 0:o.compositionDidRequestChangingSelectionToLocationRange(s)}getSelectedRange(){const t=this.getLocationRange();if(t)return this.document.rangeFromLocationRange(t)}setSelectedRange(t){const o=this.document.locationRangeFromRange(t);return this.getSelectionManager().setLocationRange(o)}getPosition(){const t=this.getLocationRange();if(t)return this.document.positionFromLocation(t[0])}getLocationRange(t){return this.targetLocationRange?this.targetLocationRange:this.getSelectionManager().getLocationRange(t)||Lt({index:0,offset:0})}withTargetLocationRange(t,o){let s;this.targetLocationRange=t;try{s=o()}finally{this.targetLocationRange=null}return s}withTargetRange(t,o){const s=this.document.locationRangeFromRange(t);return this.withTargetLocationRange(s,o)}withTargetDOMRange(t,o){const s=this.createLocationRangeFromDOMRange(t,{strict:!1});return this.withTargetLocationRange(s,o)}getExpandedRangeInDirection(t){let{length:o}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},[s,a]=Array.from(this.getSelectedRange());return"backward"===t?o?s-=o:s=this.translateUTF16PositionFromOffset(s,-1):o?a+=o:a=this.translateUTF16PositionFromOffset(a,1),Lt([s,a])}shouldManageMovingCursorInDirection(t){if(this.editingAttachment)return!0;const o=this.getExpandedRangeInDirection(t);return null!=this.getAttachmentAtRange(o)}moveCursorInDirection(t){let o,s;if(this.editingAttachment)s=this.document.getRangeOfAttachment(this.editingAttachment);else{const a=this.getSelectedRange();s=this.getExpandedRangeInDirection(t),o=!wt(a,s)}if("backward"===t?this.setSelectedRange(s[0]):this.setSelectedRange(s[1]),o){const t=this.getAttachmentAtRange(s);if(t)return this.editAttachment(t)}}expandSelectionInDirection(t){let{length:o}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const s=this.getExpandedRangeInDirection(t,{length:o});return this.setSelectedRange(s)}expandSelectionForEditing(){if(this.hasCurrentAttribute("href"))return this.expandSelectionAroundCommonAttribute("href")}expandSelectionAroundCommonAttribute(t){const o=this.getPosition(),s=this.document.getRangeOfCommonAttributeAtPosition(t,o);return this.setSelectedRange(s)}selectionContainsAttachments(){var t;return(null===(t=this.getSelectedAttachments())||void 0===t?void 0:t.length)>0}selectionIsInCursorTarget(){return this.editingAttachment||this.positionIsCursorTarget(this.getPosition())}positionIsCursorTarget(t){const o=this.document.locationFromPosition(t);if(o)return this.locationIsCursorTarget(o)}positionIsBlockBreak(t){var o;return null===(o=this.document.getPieceAtPosition(t))||void 0===o?void 0:o.isBlockBreak()}getSelectedDocument(){const t=this.getSelectedRange();if(t)return this.document.getDocumentAtRange(t)}getSelectedAttachments(){var t;return null===(t=this.getSelectedDocument())||void 0===t?void 0:t.getAttachments()}getAttachments(){return this.attachments.slice(0)}refreshAttachments(){const t=this.document.getAttachments(),{added:o,removed:s}=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];const s=[],a=[],l=new Set;t.forEach((t=>{l.add(t)}));const c=new Set;return o.forEach((t=>{c.add(t),l.has(t)||s.push(t)})),t.forEach((t=>{c.has(t)||a.push(t)})),{added:s,removed:a}}(this.attachments,t);return this.attachments=t,Array.from(s).forEach((t=>{var o,s;t.delegate=null,null===(o=this.delegate)||void 0===o||null===(s=o.compositionDidRemoveAttachment)||void 0===s||s.call(o,t)})),(()=>{const t=[];return Array.from(o).forEach((o=>{var s,a;o.delegate=this,t.push(null===(s=this.delegate)||void 0===s||null===(a=s.compositionDidAddAttachment)||void 0===a?void 0:a.call(s,o))})),t})()}attachmentDidChangeAttributes(t){var o,s;return this.revision++,null===(o=this.delegate)||void 0===o||null===(s=o.compositionDidEditAttachment)||void 0===s?void 0:s.call(o,t)}attachmentDidChangePreviewURL(t){var o,s;return this.revision++,null===(o=this.delegate)||void 0===o||null===(s=o.compositionDidChangeAttachmentPreviewURL)||void 0===s?void 0:s.call(o,t)}editAttachment(t,o){var s,a;if(t!==this.editingAttachment)return this.stopEditingAttachment(),this.editingAttachment=t,null===(s=this.delegate)||void 0===s||null===(a=s.compositionDidStartEditingAttachment)||void 0===a?void 0:a.call(s,this.editingAttachment,o)}stopEditingAttachment(){var t,o;this.editingAttachment&&(null===(t=this.delegate)||void 0===t||null===(o=t.compositionDidStopEditingAttachment)||void 0===o||o.call(t,this.editingAttachment),this.editingAttachment=null)}updateAttributesForAttachment(t,o){return this.setDocument(this.document.updateAttributesForAttachment(t,o))}removeAttributeForAttachment(t,o){return this.setDocument(this.document.removeAttributeForAttachment(t,o))}breakFormattedBlock(t){let{document:o}=t;const{block:s}=t;let a=t.startPosition,l=[a-1,a];s.getBlockBreakPosition()===t.startLocation.offset?(s.breaksOnReturn()&&"\n"===t.nextCharacter?a+=1:o=o.removeTextAtRange(l),l=[a,a]):"\n"===t.nextCharacter?"\n"===t.previousCharacter?l=[a-1,a+1]:(l=[a,a+1],a+=1):t.startLocation.offset-1!=0&&(a+=1);const c=new qe([s.removeLastAttribute().copyWithoutText()]);return this.setDocument(o.insertDocumentAtRange(c,l)),this.setSelection(a)}getPreviousBlock(){const t=this.getLocationRange();if(t){const{index:o}=t[0];if(o>0)return this.document.getBlockAtIndex(o-1)}}getBlock(){const t=this.getLocationRange();if(t)return this.document.getBlockAtIndex(t[0].index)}getAttachmentAtRange(t){const o=this.document.getDocumentAtRange(t);if(o.toString()==="".concat("","\n"))return o.getAttachments()[0]}notifyDelegateOfCurrentAttributesChange(){var t,o;return null===(t=this.delegate)||void 0===t||null===(o=t.compositionDidChangeCurrentAttributes)||void 0===o?void 0:o.call(t,this.currentAttributes)}notifyDelegateOfInsertionAtRange(t){var o,s;return null===(o=this.delegate)||void 0===o||null===(s=o.compositionDidPerformInsertionAtRange)||void 0===s?void 0:s.call(o,t)}translateUTF16PositionFromOffset(t,o){const s=this.document.toUTF16String(),a=s.offsetFromUCS2Offset(t);return s.offsetToUCS2Offset(a+o)}}gi.proxyMethod("getSelectionManager().getPointRange"),gi.proxyMethod("getSelectionManager().setLocationRangeFromPointRange"),gi.proxyMethod("getSelectionManager().createLocationRangeFromDOMRange"),gi.proxyMethod("getSelectionManager().locationIsCursorTarget"),gi.proxyMethod("getSelectionManager().selectionIsExpanded"),gi.proxyMethod("delegate?.getSelectionManager");class mi extends z{constructor(t){super(...arguments),this.composition=t,this.undoEntries=[],this.redoEntries=[]}recordUndoEntry(t){let{context:o,consolidatable:s}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const a=this.undoEntries.slice(-1)[0];if(!s||!pi(a,t,o)){const s=this.createEntry({description:t,context:o});this.undoEntries.push(s),this.redoEntries=[]}}undo(){const t=this.undoEntries.pop();if(t){const o=this.createEntry(t);return this.redoEntries.push(o),this.composition.loadSnapshot(t.snapshot)}}redo(){const t=this.redoEntries.pop();if(t){const o=this.createEntry(t);return this.undoEntries.push(o),this.composition.loadSnapshot(t.snapshot)}}canUndo(){return this.undoEntries.length>0}canRedo(){return this.redoEntries.length>0}createEntry(){let{description:t,context:o}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{description:null==t?void 0:t.toString(),context:JSON.stringify(o),snapshot:this.composition.getSnapshot()}}}const pi=(t,o,s)=>(null==t?void 0:t.description)===(null==o?void 0:o.toString())&&(null==t?void 0:t.context)===JSON.stringify(s),Ti="attachmentGallery";class bi{constructor(t){this.document=t.document,this.selectedRange=t.selectedRange}perform(){return this.removeBlockAttribute(),this.applyBlockAttribute()}getSnapshot(){return{document:this.document,selectedRange:this.selectedRange}}removeBlockAttribute(){return this.findRangesOfBlocks().map((t=>this.document=this.document.removeAttributeAtRange(Ti,t)))}applyBlockAttribute(){let t=0;this.findRangesOfPieces().forEach((o=>{o[1]-o[0]>1&&(o[0]+=t,o[1]+=t,"\n"!==this.document.getCharacterAtPosition(o[1])&&(this.document=this.document.insertBlockBreakAtRange(o[1]),o[1]<this.selectedRange[1]&&this.moveSelectedRangeForward(),o[1]++,t++),0!==o[0]&&"\n"!==this.document.getCharacterAtPosition(o[0]-1)&&(this.document=this.document.insertBlockBreakAtRange(o[0]),o[0]<this.selectedRange[0]&&this.moveSelectedRangeForward(),o[0]++,t++),this.document=this.document.applyBlockAttributeAtRange(Ti,!0,o))}))}findRangesOfBlocks(){return this.document.findRangesForBlockAttribute(Ti)}findRangesOfPieces(){return this.document.findRangesForTextAttribute("presentation",{withValue:"gallery"})}moveSelectedRangeForward(){this.selectedRange[0]+=1,this.selectedRange[1]+=1}}const vi=function(t){const o=new bi(t);return o.perform(),o.getSnapshot()},Bi=[vi];class xi{constructor(t,o,s){this.insertFiles=this.insertFiles.bind(this),this.composition=t,this.selectionManager=o,this.element=s,this.undoManager=new mi(this.composition),this.filters=Bi.slice(0)}loadDocument(t){return this.loadSnapshot({document:t,selectedRange:[0,0]})}loadHTML(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";const o=Xe.parse(t,{referenceElement:this.element}).getDocument();return this.loadDocument(o)}loadJSON(t){let{document:o,selectedRange:s}=t;return o=qe.fromJSON(o),this.loadSnapshot({document:o,selectedRange:s})}loadSnapshot(t){return this.undoManager=new mi(this.composition),this.composition.loadSnapshot(t)}getDocument(){return this.composition.document}getSelectedDocument(){return this.composition.getSelectedDocument()}getSnapshot(){return this.composition.getSnapshot()}toJSON(){return this.getSnapshot()}deleteInDirection(t){return this.composition.deleteInDirection(t)}insertAttachment(t){return this.composition.insertAttachment(t)}insertAttachments(t){return this.composition.insertAttachments(t)}insertDocument(t){return this.composition.insertDocument(t)}insertFile(t){return this.composition.insertFile(t)}insertFiles(t){return this.composition.insertFiles(t)}insertHTML(t){return this.composition.insertHTML(t)}insertString(t){return this.composition.insertString(t)}insertText(t){return this.composition.insertText(t)}insertLineBreak(){return this.composition.insertLineBreak()}getSelectedRange(){return this.composition.getSelectedRange()}getPosition(){return this.composition.getPosition()}getClientRectAtPosition(t){const o=this.getDocument().locationRangeFromRange([t,t+1]);return this.selectionManager.getClientRectAtLocationRange(o)}expandSelectionInDirection(t){return this.composition.expandSelectionInDirection(t)}moveCursorInDirection(t){return this.composition.moveCursorInDirection(t)}setSelectedRange(t){return this.composition.setSelectedRange(t)}activateAttribute(t){let o=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return this.composition.setCurrentAttribute(t,o)}attributeIsActive(t){return this.composition.hasCurrentAttribute(t)}canActivateAttribute(t){return this.composition.canSetCurrentAttribute(t)}deactivateAttribute(t){return this.composition.removeCurrentAttribute(t)}canDecreaseNestingLevel(){return this.composition.canDecreaseNestingLevel()}canIncreaseNestingLevel(){return this.composition.canIncreaseNestingLevel()}decreaseNestingLevel(){if(this.canDecreaseNestingLevel())return this.composition.decreaseNestingLevel()}increaseNestingLevel(){if(this.canIncreaseNestingLevel())return this.composition.increaseNestingLevel()}canRedo(){return this.undoManager.canRedo()}canUndo(){return this.undoManager.canUndo()}recordUndoEntry(t){let{context:o,consolidatable:s}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.undoManager.recordUndoEntry(t,{context:o,consolidatable:s})}redo(){if(this.canRedo())return this.undoManager.redo()}undo(){if(this.canUndo())return this.undoManager.undo()}}class yi{constructor(t){this.element=t}findLocationFromContainerAndOffset(t,o){let{strict:s}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{strict:!0},a=0,l=!1;const c={index:0,offset:0},u=this.findAttachmentElementParentForNode(t);u&&(t=u.parentNode,o=C(u));const d=S(this.element,{usingFilter:Ei});for(;d.nextNode();){const u=d.currentNode;if(u===t&&O(t)){I(u)||(c.offset+=o);break}if(u.parentNode===t){if(a++===o)break}else if(!y(t,u)&&a>0)break;T(u,{strict:s})?(l&&c.index++,c.offset=0,l=!0):c.offset+=Ci(u)}return c}findContainerAndOffsetFromLocation(t){let o,s;if(0===t.index&&0===t.offset){for(o=this.element,s=0;o.firstChild;)if(o=o.firstChild,w(o)){s=1;break}return[o,s]}let[a,l]=this.findNodeAndOffsetFromLocation(t);if(a){if(O(a))0===Ci(a)?(o=a.parentNode.parentNode,s=C(a.parentNode),I(a,{name:"right"})&&s++):(o=a,s=t.offset-l);else{if(o=a.parentNode,!T(a.previousSibling)&&!w(o))for(;a===o.lastChild&&(a=o,o=o.parentNode,!w(o)););s=C(a),0!==t.offset&&s++}return[o,s]}}findNodeAndOffsetFromLocation(t){let o,s,a=0;for(const l of this.getSignificantNodesForIndex(t.index)){const c=Ci(l);if(t.offset<=a+c)if(O(l)){if(o=l,s=a,t.offset===s&&I(o))break}else o||(o=l,s=a);if(a+=c,a>t.offset)break}return[o,s]}findAttachmentElementParentForNode(t){for(;t&&t!==this.element;){if(P(t))return t;t=t.parentNode}}getSignificantNodesForIndex(t){const o=[],s=S(this.element,{usingFilter:Ri});let a=!1;for(;s.nextNode();){const c=s.currentNode;var l;if(B(c)){if(null!=l?l++:l=0,l===t)a=!0;else if(a)break}else a&&o.push(c)}return o}}const Ci=function(t){return t.nodeType===Node.TEXT_NODE?I(t)?0:t.textContent.length:"br"===E(t)||P(t)?1:0},Ri=function(t){return Si(t)===NodeFilter.FILTER_ACCEPT?Ei(t):NodeFilter.FILTER_REJECT},Si=function(t){return N(t)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT},Ei=function(t){return P(t.parentNode)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT};class ki{createDOMRangeFromPoint(t){let o,{x:s,y:a}=t;if(document.caretPositionFromPoint){const{offsetNode:t,offset:l}=document.caretPositionFromPoint(s,a);return o=document.createRange(),o.setStart(t,l),o}if(document.caretRangeFromPoint)return document.caretRangeFromPoint(s,a);if(document.body.createTextRange){const l=Nt();try{const t=document.body.createTextRange();t.moveToPoint(s,a),t.select()}catch(t){}return o=Nt(),Ot(l),o}}getClientRectsForDOMRange(t){const o=Array.from(t.getClientRects());return[o[0],o[o.length-1]]}}class Li extends z{constructor(t){super(...arguments),this.didMouseDown=this.didMouseDown.bind(this),this.selectionDidChange=this.selectionDidChange.bind(this),this.element=t,this.locationMapper=new yi(this.element),this.pointMapper=new ki,this.lockCount=0,f("mousedown",{onElement:this.element,withCallback:this.didMouseDown})}getLocationRange(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return!1===t.strict?this.createLocationRangeFromDOMRange(Nt()):t.ignoreLock?this.currentLocationRange:this.lockedLocationRange?this.lockedLocationRange:this.currentLocationRange}setLocationRange(t){if(this.lockedLocationRange)return;t=Lt(t);const o=this.createDOMRangeFromLocationRange(t);o&&(Ot(o),this.updateCurrentLocationRange(t))}setLocationRangeFromPointRange(t){t=Lt(t);const o=this.getLocationAtPoint(t[0]),s=this.getLocationAtPoint(t[1]);this.setLocationRange([o,s])}getClientRectAtLocationRange(t){const o=this.createDOMRangeFromLocationRange(t);if(o)return this.getClientRectsForDOMRange(o)[1]}locationIsCursorTarget(t){const o=Array.from(this.findNodeAndOffsetFromLocation(t))[0];return I(o)}lock(){0==this.lockCount++&&(this.updateCurrentLocationRange(),this.lockedLocationRange=this.getLocationRange())}unlock(){if(0==--this.lockCount){const{lockedLocationRange:t}=this;if(this.lockedLocationRange=null,null!=t)return this.setLocationRange(t)}}clearSelection(){var t;return null===(t=Pt())||void 0===t?void 0:t.removeAllRanges()}selectionIsCollapsed(){var t;return!0===(null===(t=Nt())||void 0===t?void 0:t.collapsed)}selectionIsExpanded(){return!this.selectionIsCollapsed()}createLocationRangeFromDOMRange(t,o){if(null==t||!this.domRangeWithinElement(t))return;const s=this.findLocationFromContainerAndOffset(t.startContainer,t.startOffset,o);if(!s)return;const a=t.collapsed?void 0:this.findLocationFromContainerAndOffset(t.endContainer,t.endOffset,o);return Lt([s,a])}didMouseDown(){return this.pauseTemporarily()}pauseTemporarily(){let t;this.paused=!0;const e=()=>{if(this.paused=!1,clearTimeout(o),Array.from(t).forEach((t=>{t.destroy()})),y(document,this.element))return this.selectionDidChange()},o=setTimeout(e,200);t=["mousemove","keydown"].map((t=>f(t,{onElement:document,withCallback:e})))}selectionDidChange(){if(!this.paused&&!x(this.element))return this.updateCurrentLocationRange()}updateCurrentLocationRange(t){var o,s;if((null!=t?t:t=this.createLocationRangeFromDOMRange(Nt()))&&!wt(t,this.currentLocationRange))return this.currentLocationRange=t,null===(o=this.delegate)||void 0===o||null===(s=o.locationRangeDidChange)||void 0===s?void 0:s.call(o,this.currentLocationRange.slice(0))}createDOMRangeFromLocationRange(t){const o=this.findContainerAndOffsetFromLocation(t[0]),s=Dt(t)?o:this.findContainerAndOffsetFromLocation(t[1])||o;if(null!=o&&null!=s){const t=document.createRange();return t.setStart(...Array.from(o||[])),t.setEnd(...Array.from(s||[])),t}}getLocationAtPoint(t){const o=this.createDOMRangeFromPoint(t);var s;if(o)return null===(s=this.createLocationRangeFromDOMRange(o))||void 0===s?void 0:s[0]}domRangeWithinElement(t){return t.collapsed?y(this.element,t.startContainer):y(this.element,t.startContainer)&&y(this.element,t.endContainer)}}Li.proxyMethod("locationMapper.findLocationFromContainerAndOffset"),Li.proxyMethod("locationMapper.findContainerAndOffsetFromLocation"),Li.proxyMethod("locationMapper.findNodeAndOffsetFromLocation"),Li.proxyMethod("pointMapper.createDOMRangeFromPoint"),Li.proxyMethod("pointMapper.getClientRectsForDOMRange");var Fi=Object.freeze({__proto__:null,Attachment:Re,AttachmentManager:ui,AttachmentPiece:Se,Block:Be,Composition:gi,Document:qe,Editor:xi,HTMLParser:Xe,HTMLSanitizer:Je,LineBreakInsertion:di,LocationMapper:yi,ManagedAttachment:hi,Piece:ye,PointMapper:ki,SelectionManager:Li,SplittableList:ke,StringPiece:Ee,Text:Te,UndoManager:mi}),Mi=Object.freeze({__proto__:null,ObjectView:ee,AttachmentView:re,BlockView:de,DocumentView:ge,PieceView:le,PreviewableAttachmentView:ae,TextView:ce});const{lang:ji,css:Wi,keyNames:Hi}=G,Ii=function(t){return function(){const o=t.apply(this,arguments);o.do(),this.undos||(this.undos=[]),this.undos.push(o.undo)}};class Pi extends z{constructor(t,o,s){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};super(...arguments),Ae(this,"makeElementMutable",Ii((()=>({do:()=>{this.element.dataset.trixMutable=!0},undo:()=>delete this.element.dataset.trixMutable})))),Ae(this,"addToolbar",Ii((()=>{const t=k({tagName:"div",className:Wi.attachmentToolbar,data:{trixMutable:!0},childNodes:k({tagName:"div",className:"trix-button-row",childNodes:k({tagName:"span",className:"trix-button-group trix-button-group--actions",childNodes:k({tagName:"button",className:"trix-button trix-button--remove",textContent:ji.remove,attributes:{title:ji.remove},data:{trixAction:"remove"}})})})});return this.attachment.isPreviewable()&&t.appendChild(k({tagName:"div",className:Wi.attachmentMetadataContainer,childNodes:k({tagName:"span",className:Wi.attachmentMetadata,childNodes:[k({tagName:"span",className:Wi.attachmentName,textContent:this.attachment.getFilename(),attributes:{title:this.attachment.getFilename()}}),k({tagName:"span",className:Wi.attachmentSize,textContent:this.attachment.getFormattedFilesize()})]})})),f("click",{onElement:t,withCallback:this.didClickToolbar}),f("click",{onElement:t,matchingSelector:"[data-trix-action]",withCallback:this.didClickActionButton}),b("trix-attachment-before-toolbar",{onElement:this.element,attributes:{toolbar:t,attachment:this.attachment}}),{do:()=>this.element.appendChild(t),undo:()=>R(t)}}))),Ae(this,"installCaptionEditor",Ii((()=>{const t=k({tagName:"textarea",className:Wi.attachmentCaptionEditor,attributes:{placeholder:ji.captionPlaceholder},data:{trixMutable:!0}});t.value=this.attachmentPiece.getCaption();const o=t.cloneNode();o.classList.add("trix-autoresize-clone"),o.tabIndex=-1;const i=function(){o.value=t.value,t.style.height=o.scrollHeight+"px"};f("input",{onElement:t,withCallback:i}),f("input",{onElement:t,withCallback:this.didInputCaption}),f("keydown",{onElement:t,withCallback:this.didKeyDownCaption}),f("change",{onElement:t,withCallback:this.didChangeCaption}),f("blur",{onElement:t,withCallback:this.didBlurCaption});const s=this.element.querySelector("figcaption"),a=s.cloneNode();return{do:()=>{if(s.style.display="none",a.appendChild(t),a.appendChild(o),a.classList.add("".concat(Wi.attachmentCaption,"--editing")),s.parentElement.insertBefore(a,s),i(),this.options.editCaption)return St((()=>t.focus()))},undo(){R(a),s.style.display=null}}}))),this.didClickToolbar=this.didClickToolbar.bind(this),this.didClickActionButton=this.didClickActionButton.bind(this),this.didKeyDownCaption=this.didKeyDownCaption.bind(this),this.didInputCaption=this.didInputCaption.bind(this),this.didChangeCaption=this.didChangeCaption.bind(this),this.didBlurCaption=this.didBlurCaption.bind(this),this.attachmentPiece=t,this.element=o,this.container=s,this.options=a,this.attachment=this.attachmentPiece.attachment,"a"===E(this.element)&&(this.element=this.element.firstChild),this.install()}install(){this.makeElementMutable(),this.addToolbar(),this.attachment.isPreviewable()&&this.installCaptionEditor()}uninstall(){var t;let o=this.undos.pop();for(this.savePendingCaption();o;)o(),o=this.undos.pop();null===(t=this.delegate)||void 0===t||t.didUninstallAttachmentEditor(this)}savePendingCaption(){if(null!=this.pendingCaption){const l=this.pendingCaption;var t,o,s,a;this.pendingCaption=null,l?null===(t=this.delegate)||void 0===t||null===(o=t.attachmentEditorDidRequestUpdatingAttributesForAttachment)||void 0===o||o.call(t,{caption:l},this.attachment):null===(s=this.delegate)||void 0===s||null===(a=s.attachmentEditorDidRequestRemovingAttributeForAttachment)||void 0===a||a.call(s,"caption",this.attachment)}}didClickToolbar(t){return t.preventDefault(),t.stopPropagation()}didClickActionButton(t){var o;if("remove"===t.target.getAttribute("data-trix-action"))return null===(o=this.delegate)||void 0===o?void 0:o.attachmentEditorDidRequestRemovalOfAttachment(this.attachment)}didKeyDownCaption(t){var o,s;if("return"===Hi[t.keyCode])return t.preventDefault(),this.savePendingCaption(),null===(o=this.delegate)||void 0===o||null===(s=o.attachmentEditorDidRequestDeselectingAttachment)||void 0===s?void 0:s.call(o,this.attachment)}didInputCaption(t){this.pendingCaption=t.target.value.replace(/\s/g," ").trim()}didChangeCaption(t){return this.savePendingCaption()}didBlurCaption(t){return this.savePendingCaption()}}class Ni extends z{constructor(t,s){super(...arguments),this.didFocus=this.didFocus.bind(this),this.didBlur=this.didBlur.bind(this),this.didClickAttachment=this.didClickAttachment.bind(this),this.element=t,this.composition=s,this.documentView=new ge(this.composition.document,{element:this.element}),f("focus",{onElement:this.element,withCallback:this.didFocus}),f("blur",{onElement:this.element,withCallback:this.didBlur}),f("click",{onElement:this.element,matchingSelector:"a[contenteditable=false]",preventDefault:!0}),f("mousedown",{onElement:this.element,matchingSelector:o,withCallback:this.didClickAttachment}),f("click",{onElement:this.element,matchingSelector:"a".concat(o),preventDefault:!0})}didFocus(t){var o;const i=()=>{var t,o;if(!this.focused)return this.focused=!0,null===(t=this.delegate)||void 0===t||null===(o=t.compositionControllerDidFocus)||void 0===o?void 0:o.call(t)};return(null===(o=this.blurPromise)||void 0===o?void 0:o.then(i))||i()}didBlur(t){this.blurPromise=new Promise((t=>St((()=>{var o,s;x(this.element)||(this.focused=null,null===(o=this.delegate)||void 0===o||null===(s=o.compositionControllerDidBlur)||void 0===s||s.call(o));return this.blurPromise=null,t()}))))}didClickAttachment(t,o){var s,a;const l=this.findAttachmentForElement(o),c=!!A(t.target,{matchingSelector:"figcaption"});return null===(s=this.delegate)||void 0===s||null===(a=s.compositionControllerDidSelectAttachment)||void 0===a?void 0:a.call(s,l,{editCaption:c})}getSerializableElement(){return this.isEditingAttachment()?this.documentView.shadowElement:this.element}render(){var t,o,s,a,l,c;(this.revision!==this.composition.revision&&(this.documentView.setDocument(this.composition.document),this.documentView.render(),this.revision=this.composition.revision),this.canSyncDocumentView()&&!this.documentView.isSynced())&&(null===(s=this.delegate)||void 0===s||null===(a=s.compositionControllerWillSyncDocumentView)||void 0===a||a.call(s),this.documentView.sync(),null===(l=this.delegate)||void 0===l||null===(c=l.compositionControllerDidSyncDocumentView)||void 0===c||c.call(l));return null===(t=this.delegate)||void 0===t||null===(o=t.compositionControllerDidRender)||void 0===o?void 0:o.call(t)}rerenderViewForObject(t){return this.invalidateViewForObject(t),this.render()}invalidateViewForObject(t){return this.documentView.invalidateViewForObject(t)}isViewCachingEnabled(){return this.documentView.isViewCachingEnabled()}enableViewCaching(){return this.documentView.enableViewCaching()}disableViewCaching(){return this.documentView.disableViewCaching()}refreshViewCache(){return this.documentView.garbageCollectCachedViews()}isEditingAttachment(){return!!this.attachmentEditor}installAttachmentEditorForAttachment(t,o){var s;if((null===(s=this.attachmentEditor)||void 0===s?void 0:s.attachment)===t)return;const a=this.documentView.findElementForObject(t);if(!a)return;this.uninstallAttachmentEditor();const l=this.composition.document.getAttachmentPieceForAttachment(t);this.attachmentEditor=new Pi(l,a,this.element,o),this.attachmentEditor.delegate=this}uninstallAttachmentEditor(){var t;return null===(t=this.attachmentEditor)||void 0===t?void 0:t.uninstall()}didUninstallAttachmentEditor(){return this.attachmentEditor=null,this.render()}attachmentEditorDidRequestUpdatingAttributesForAttachment(t,o){var s,a;return null===(s=this.delegate)||void 0===s||null===(a=s.compositionControllerWillUpdateAttachment)||void 0===a||a.call(s,o),this.composition.updateAttributesForAttachment(t,o)}attachmentEditorDidRequestRemovingAttributeForAttachment(t,o){var s,a;return null===(s=this.delegate)||void 0===s||null===(a=s.compositionControllerWillUpdateAttachment)||void 0===a||a.call(s,o),this.composition.removeAttributeForAttachment(t,o)}attachmentEditorDidRequestRemovalOfAttachment(t){var o,s;return null===(o=this.delegate)||void 0===o||null===(s=o.compositionControllerDidRequestRemovalOfAttachment)||void 0===s?void 0:s.call(o,t)}attachmentEditorDidRequestDeselectingAttachment(t){var o,s;return null===(o=this.delegate)||void 0===o||null===(s=o.compositionControllerDidRequestDeselectingAttachment)||void 0===s?void 0:s.call(o,t)}canSyncDocumentView(){return!this.isEditingAttachment()}findAttachmentForElement(t){return this.composition.document.getAttachmentById(parseInt(t.dataset.trixId,10))}}class Oi extends z{}const Xi="data-trix-mutable",Gi="[".concat(Xi,"]"),$i={attributes:!0,childList:!0,characterData:!0,characterDataOldValue:!0,subtree:!0};class Ui extends z{constructor(t){super(t),this.didMutate=this.didMutate.bind(this),this.element=t,this.observer=new window.MutationObserver(this.didMutate),this.start()}start(){return this.reset(),this.observer.observe(this.element,$i)}stop(){return this.observer.disconnect()}didMutate(t){var o,s;if(this.mutations.push(...Array.from(this.findSignificantMutations(t)||[])),this.mutations.length)return null===(o=this.delegate)||void 0===o||null===(s=o.elementDidMutate)||void 0===s||s.call(o,this.getMutationSummary()),this.reset()}reset(){this.mutations=[]}findSignificantMutations(t){return t.filter((t=>this.mutationIsSignificant(t)))}mutationIsSignificant(t){if(this.nodeIsMutable(t.target))return!1;for(const o of Array.from(this.nodesModifiedByMutation(t)))if(this.nodeIsSignificant(o))return!0;return!1}nodeIsSignificant(t){return t!==this.element&&!this.nodeIsMutable(t)&&!N(t)}nodeIsMutable(t){return A(t,{matchingSelector:Gi})}nodesModifiedByMutation(t){const o=[];switch(t.type){case"attributes":t.attributeName!==Xi&&o.push(t.target);break;case"characterData":o.push(t.target.parentNode),o.push(t.target);break;case"childList":o.push(...Array.from(t.addedNodes||[])),o.push(...Array.from(t.removedNodes||[]))}return o}getMutationSummary(){return this.getTextMutationSummary()}getTextMutationSummary(){const{additions:t,deletions:o}=this.getTextChangesFromCharacterData(),s=this.getTextChangesFromChildList();Array.from(s.additions).forEach((o=>{Array.from(t).includes(o)||t.push(o)})),o.push(...Array.from(s.deletions||[]));const a={},l=t.join("");l&&(a.textAdded=l);const c=o.join("");return c&&(a.textDeleted=c),a}getMutationsByType(t){return Array.from(this.mutations).filter((o=>o.type===t))}getTextChangesFromChildList(){let t,o;const s=[],a=[];Array.from(this.getMutationsByType("childList")).forEach((t=>{s.push(...Array.from(t.addedNodes||[])),a.push(...Array.from(t.removedNodes||[]))}));0===s.length&&1===a.length&&B(a[0])?(t=[],o=["\n"]):(t=qi(s),o=qi(a));return{additions:t.filter(((t,s)=>t!==o[s])).map(Wt),deletions:o.filter(((o,s)=>o!==t[s])).map(Wt)}}getTextChangesFromCharacterData(){let t,o;const s=this.getMutationsByType("characterData");if(s.length){const a=s[0],l=s[s.length-1],c=function(t,o){let s,a;return t=X.box(t),(o=X.box(o)).length<t.length?[a,s]=Vt(t,o):[s,a]=Vt(o,t),{added:s,removed:a}}(Wt(a.oldValue),Wt(l.target.data));t=c.added,o=c.removed}return{additions:t?[t]:[],deletions:o?[o]:[]}}}const qi=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];const o=[];for(const s of Array.from(t))switch(s.nodeType){case Node.TEXT_NODE:o.push(s.data);break;case Node.ELEMENT_NODE:"br"===E(s)?o.push("\n"):o.push(...Array.from(qi(s.childNodes)||[]))}return o};class Vi extends te{constructor(t){super(...arguments),this.file=t}perform(t){const o=new FileReader;return o.onerror=()=>t(!1),o.onload=()=>{o.onerror=null;try{o.abort()}catch(t){}return t(!0,this.file)},o.readAsArrayBuffer(this.file)}}class zi{constructor(t){this.element=t}shouldIgnore(t){return!!u.samsungAndroid&&(this.previousEvent=this.event,this.event=t,this.checkSamsungKeyboardBuggyModeStart(),this.checkSamsungKeyboardBuggyModeEnd(),this.buggyMode)}checkSamsungKeyboardBuggyModeStart(){this.insertingLongTextAfterUnidentifiedChar()&&_i(this.element.innerText,this.event.data)&&(this.buggyMode=!0,this.event.preventDefault())}checkSamsungKeyboardBuggyModeEnd(){this.buggyMode&&"insertText"!==this.event.inputType&&(this.buggyMode=!1)}insertingLongTextAfterUnidentifiedChar(){var t;return this.isBeforeInputInsertText()&&this.previousEventWasUnidentifiedKeydown()&&(null===(t=this.event.data)||void 0===t?void 0:t.length)>50}isBeforeInputInsertText(){return"beforeinput"===this.event.type&&"insertText"===this.event.inputType}previousEventWasUnidentifiedKeydown(){var t,o;return"keydown"===(null===(t=this.previousEvent)||void 0===t?void 0:t.type)&&"Unidentified"===(null===(o=this.previousEvent)||void 0===o?void 0:o.key)}}const _i=(t,o)=>Ji(t)===Ji(o),Yi=new RegExp("(".concat("","|").concat(L,"|").concat(M,"|\\s)+"),"g"),Ji=t=>t.replace(Yi," ").trim();class Ki extends z{constructor(t){super(...arguments),this.element=t,this.mutationObserver=new Ui(this.element),this.mutationObserver.delegate=this,this.flakyKeyboardDetector=new zi(this.element);for(const t in this.constructor.events)f(t,{onElement:this.element,withCallback:this.handlerFor(t)})}elementDidMutate(t){}editorWillSyncDocumentView(){return this.mutationObserver.stop()}editorDidSyncDocumentView(){return this.mutationObserver.start()}requestRender(){var t,o;return null===(t=this.delegate)||void 0===t||null===(o=t.inputControllerDidRequestRender)||void 0===o?void 0:o.call(t)}requestReparse(){var t,o;return null===(t=this.delegate)||void 0===t||null===(o=t.inputControllerDidRequestReparse)||void 0===o||o.call(t),this.requestRender()}attachFiles(t){const o=Array.from(t).map((t=>new Vi(t)));return Promise.all(o).then((t=>{this.handleInput((function(){var o,s;return null===(o=this.delegate)||void 0===o||o.inputControllerWillAttachFiles(),null===(s=this.responder)||void 0===s||s.insertFiles(t),this.requestRender()}))}))}handlerFor(t){return o=>{o.defaultPrevented||this.handleInput((()=>{if(!x(this.element)){if(this.flakyKeyboardDetector.shouldIgnore(o))return;this.eventName=t,this.constructor.events[t].call(this,o)}}))}}handleInput(t){try{var o;null===(o=this.delegate)||void 0===o||o.inputControllerWillHandleInput(),t.call(this)}finally{var s;null===(s=this.delegate)||void 0===s||s.inputControllerDidHandleInput()}}createLinkHTML(t,o){const s=document.createElement("a");return s.href=t,s.textContent=o||t,s.outerHTML}}var tn;Ae(Ki,"events",{});const{browser:dn,keyNames:gn}=G;let mn=0;class Qi extends Ki{constructor(){super(...arguments),this.resetInputSummary()}setInputSummary(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.inputSummary.eventName=this.eventName;for(const o in t){const s=t[o];this.inputSummary[o]=s}return this.inputSummary}resetInputSummary(){this.inputSummary={}}reset(){return this.resetInputSummary(),Pe.reset()}elementDidMutate(t){var o,s;return this.isComposing()?null===(o=this.delegate)||void 0===o||null===(s=o.inputControllerDidAllowUnhandledInput)||void 0===s?void 0:s.call(o):this.handleInput((function(){return this.mutationIsSignificant(t)&&(this.mutationIsExpected(t)?this.requestRender():this.requestReparse()),this.reset()}))}mutationIsExpected(t){let{textAdded:o,textDeleted:s}=t;if(this.inputSummary.preferDocument)return!0;const a=null!=o?o===this.inputSummary.textAdded:!this.inputSummary.textAdded,l=null!=s?this.inputSummary.didDelete:!this.inputSummary.didDelete,c=["\n"," \n"].includes(o)&&!a,u="\n"===s&&!l;if(c&&!u||u&&!c){const t=this.getSelectedRange();if(t){var d;const s=c?o.replace(/\n$/,"").length||-1:(null==o?void 0:o.length)||1;if(null!==(d=this.responder)&&void 0!==d&&d.positionIsBlockBreak(t[1]+s))return!0}}return a&&l}mutationIsSignificant(t){var o;const s=Object.keys(t).length>0,a=""===(null===(o=this.compositionInput)||void 0===o?void 0:o.getEndData());return s||!a}getCompositionInput(){if(this.isComposing())return this.compositionInput;this.compositionInput=new rn(this)}isComposing(){return this.compositionInput&&!this.compositionInput.isEnded()}deleteInDirection(t,o){var s;return!1!==(null===(s=this.responder)||void 0===s?void 0:s.deleteInDirection(t))?this.setInputSummary({didDelete:!0}):o?(o.preventDefault(),this.requestRender()):void 0}serializeSelectionToDataTransfer(t){var o;if(!function(t){if(null==t||!t.setData)return!1;for(const o in ne){const s=ne[o];try{if(t.setData(o,s),!t.getData(o)===s)return!1}catch(t){return!1}}return!0}(t))return;const s=null===(o=this.responder)||void 0===o?void 0:o.getSelectedDocument().toSerializableDocument();return t.setData("application/x-trix-document",JSON.stringify(s)),t.setData("text/html",ge.render(s).innerHTML),t.setData("text/plain",s.toString().replace(/\n$/,"")),!0}canAcceptDataTransfer(t){const o={};return Array.from((null==t?void 0:t.types)||[]).forEach((t=>{o[t]=!0})),o.Files||o["application/x-trix-document"]||o["text/html"]||o["text/plain"]}getPastedHTMLUsingHiddenElement(t){const o=this.getSelectedRange(),s={position:"absolute",left:"".concat(window.pageXOffset,"px"),top:"".concat(window.pageYOffset,"px"),opacity:0},a=k({style:s,tagName:"div",editable:!0});return document.body.appendChild(a),a.focus(),requestAnimationFrame((()=>{const s=a.innerHTML;return R(a),this.setSelectedRange(o),t(s)}))}}Ae(Qi,"events",{keydown(t){this.isComposing()||this.resetInputSummary(),this.inputSummary.didInput=!0;const o=gn[t.keyCode];if(o){var s;let a=this.keys;["ctrl","alt","shift","meta"].forEach((o=>{var s;t["".concat(o,"Key")]&&("ctrl"===o&&(o="control"),a=null===(s=a)||void 0===s?void 0:s[o])})),null!=(null===(s=a)||void 0===s?void 0:s[o])&&(this.setInputSummary({keyName:o}),Pe.reset(),a[o].call(this,t))}if(ue(t)){const o=String.fromCharCode(t.keyCode).toLowerCase();if(o){var a;const s=["alt","shift"].map((o=>{if(t["".concat(o,"Key")])return o})).filter((t=>t));s.push(o),null!==(a=this.delegate)&&void 0!==a&&a.inputControllerDidReceiveKeyboardCommand(s)&&t.preventDefault()}}},keypress(t){if(null!=this.inputSummary.eventName)return;if(t.metaKey)return;if(t.ctrlKey&&!t.altKey)return;const o=en(t);var s,a;return o?(null===(s=this.delegate)||void 0===s||s.inputControllerWillPerformTyping(),null===(a=this.responder)||void 0===a||a.insertString(o),this.setInputSummary({textAdded:o,didDelete:this.selectionIsExpanded()})):void 0},textInput(t){const{data:o}=t,{textAdded:s}=this.inputSummary;if(s&&s!==o&&s.toUpperCase()===o){var a;const t=this.getSelectedRange();return this.setSelectedRange([t[0],t[1]+s.length]),null===(a=this.responder)||void 0===a||a.insertString(o),this.setInputSummary({textAdded:o}),this.setSelectedRange(t)}},dragenter(t){t.preventDefault()},dragstart(t){var o,s;return this.serializeSelectionToDataTransfer(t.dataTransfer),this.draggedRange=this.getSelectedRange(),null===(o=this.delegate)||void 0===o||null===(s=o.inputControllerDidStartDrag)||void 0===s?void 0:s.call(o)},dragover(t){if(this.draggedRange||this.canAcceptDataTransfer(t.dataTransfer)){t.preventDefault();const a={x:t.clientX,y:t.clientY};var o,s;if(!kt(a,this.draggingPoint))return this.draggingPoint=a,null===(o=this.delegate)||void 0===o||null===(s=o.inputControllerDidReceiveDragOverPoint)||void 0===s?void 0:s.call(o,this.draggingPoint)}},dragend(t){var o,s;null===(o=this.delegate)||void 0===o||null===(s=o.inputControllerDidCancelDrag)||void 0===s||s.call(o),this.draggedRange=null,this.draggingPoint=null},drop(t){var o,s;t.preventDefault();const a=null===(o=t.dataTransfer)||void 0===o?void 0:o.files,l=t.dataTransfer.getData("application/x-trix-document"),c={x:t.clientX,y:t.clientY};if(null===(s=this.responder)||void 0===s||s.setLocationRangeFromPointRange(c),null!=a&&a.length)this.attachFiles(a);else if(this.draggedRange){var u,d;null===(u=this.delegate)||void 0===u||u.inputControllerWillMoveText(),null===(d=this.responder)||void 0===d||d.moveTextFromRange(this.draggedRange),this.draggedRange=null,this.requestRender()}else if(l){var m;const t=qe.fromJSONString(l);null===(m=this.responder)||void 0===m||m.insertDocument(t),this.requestRender()}this.draggedRange=null,this.draggingPoint=null},cut(t){var o,s;if(null!==(o=this.responder)&&void 0!==o&&o.selectionIsExpanded()&&(this.serializeSelectionToDataTransfer(t.clipboardData)&&t.preventDefault(),null===(s=this.delegate)||void 0===s||s.inputControllerWillCutText(),this.deleteInDirection("backward"),t.defaultPrevented))return this.requestRender()},copy(t){var o;null!==(o=this.responder)&&void 0!==o&&o.selectionIsExpanded()&&this.serializeSelectionToDataTransfer(t.clipboardData)&&t.preventDefault()},paste(t){const o=t.clipboardData||t.testClipboardData,s={clipboard:o};if(!o||nn(t))return void this.getPastedHTMLUsingHiddenElement((t=>{var o,a,l;return s.type="text/html",s.html=t,null===(o=this.delegate)||void 0===o||o.inputControllerWillPaste(s),null===(a=this.responder)||void 0===a||a.insertHTML(s.html),this.requestRender(),null===(l=this.delegate)||void 0===l?void 0:l.inputControllerDidPaste(s)}));const a=o.getData("URL"),l=o.getData("text/html"),c=o.getData("public.url-name");if(a){var u,d,m;let t;s.type="text/html",t=c?qt(c).trim():a,s.html=this.createLinkHTML(a,t),null===(u=this.delegate)||void 0===u||u.inputControllerWillPaste(s),this.setInputSummary({textAdded:t,didDelete:this.selectionIsExpanded()}),null===(d=this.responder)||void 0===d||d.insertHTML(s.html),this.requestRender(),null===(m=this.delegate)||void 0===m||m.inputControllerDidPaste(s)}else if(Ct(o)){var p,L,M;s.type="text/plain",s.string=o.getData("text/plain"),null===(p=this.delegate)||void 0===p||p.inputControllerWillPaste(s),this.setInputSummary({textAdded:s.string,didDelete:this.selectionIsExpanded()}),null===(L=this.responder)||void 0===L||L.insertString(s.string),this.requestRender(),null===(M=this.delegate)||void 0===M||M.inputControllerDidPaste(s)}else if(l){var j,W,q;s.type="text/html",s.html=l,null===(j=this.delegate)||void 0===j||j.inputControllerWillPaste(s),null===(W=this.responder)||void 0===W||W.insertHTML(s.html),this.requestRender(),null===(q=this.delegate)||void 0===q||q.inputControllerDidPaste(s)}else if(Array.from(o.types).includes("Files")){var U,V;const t=null===(U=o.items)||void 0===U||null===(U=U[0])||void 0===U||null===(V=U.getAsFile)||void 0===V?void 0:V.call(U);if(t){var H,J,K;const o=Zi(t);!t.name&&o&&(t.name="pasted-file-".concat(++mn,".").concat(o)),s.type="File",s.file=t,null===(H=this.delegate)||void 0===H||H.inputControllerWillAttachFiles(),null===(J=this.responder)||void 0===J||J.insertFile(s.file),this.requestRender(),null===(K=this.delegate)||void 0===K||K.inputControllerDidPaste(s)}}t.preventDefault()},compositionstart(t){return this.getCompositionInput().start(t.data)},compositionupdate(t){return this.getCompositionInput().update(t.data)},compositionend(t){return this.getCompositionInput().end(t.data)},beforeinput(t){this.inputSummary.didInput=!0},input(t){return this.inputSummary.didInput=!0,t.stopPropagation()}}),Ae(Qi,"keys",{backspace(t){var o;return null===(o=this.delegate)||void 0===o||o.inputControllerWillPerformTyping(),this.deleteInDirection("backward",t)},delete(t){var o;return null===(o=this.delegate)||void 0===o||o.inputControllerWillPerformTyping(),this.deleteInDirection("forward",t)},return(t){var o,s;return this.setInputSummary({preferDocument:!0}),null===(o=this.delegate)||void 0===o||o.inputControllerWillPerformTyping(),null===(s=this.responder)||void 0===s?void 0:s.insertLineBreak()},tab(t){var o,s;null!==(o=this.responder)&&void 0!==o&&o.canIncreaseNestingLevel()&&(null===(s=this.responder)||void 0===s||s.increaseNestingLevel(),this.requestRender(),t.preventDefault())},left(t){var o;if(this.selectionIsInCursorTarget())return t.preventDefault(),null===(o=this.responder)||void 0===o?void 0:o.moveCursorInDirection("backward")},right(t){var o;if(this.selectionIsInCursorTarget())return t.preventDefault(),null===(o=this.responder)||void 0===o?void 0:o.moveCursorInDirection("forward")},control:{d(t){var o;return null===(o=this.delegate)||void 0===o||o.inputControllerWillPerformTyping(),this.deleteInDirection("forward",t)},h(t){var o;return null===(o=this.delegate)||void 0===o||o.inputControllerWillPerformTyping(),this.deleteInDirection("backward",t)},o(t){var o,s;return t.preventDefault(),null===(o=this.delegate)||void 0===o||o.inputControllerWillPerformTyping(),null===(s=this.responder)||void 0===s||s.insertString("\n",{updatePosition:!1}),this.requestRender()}},shift:{return(t){var o,s;null===(o=this.delegate)||void 0===o||o.inputControllerWillPerformTyping(),null===(s=this.responder)||void 0===s||s.insertString("\n"),this.requestRender(),t.preventDefault()},tab(t){var o,s;null!==(o=this.responder)&&void 0!==o&&o.canDecreaseNestingLevel()&&(null===(s=this.responder)||void 0===s||s.decreaseNestingLevel(),this.requestRender(),t.preventDefault())},left(t){if(this.selectionIsInCursorTarget())return t.preventDefault(),this.expandSelectionInDirection("backward")},right(t){if(this.selectionIsInCursorTarget())return t.preventDefault(),this.expandSelectionInDirection("forward")}},alt:{backspace(t){var o;return this.setInputSummary({preferDocument:!1}),null===(o=this.delegate)||void 0===o?void 0:o.inputControllerWillPerformTyping()}},meta:{backspace(t){var o;return this.setInputSummary({preferDocument:!1}),null===(o=this.delegate)||void 0===o?void 0:o.inputControllerWillPerformTyping()}}}),Qi.proxyMethod("responder?.getSelectedRange"),Qi.proxyMethod("responder?.setSelectedRange"),Qi.proxyMethod("responder?.expandSelectionInDirection"),Qi.proxyMethod("responder?.selectionIsInCursorTarget"),Qi.proxyMethod("responder?.selectionIsExpanded");const Zi=t=>{var o;return null===(o=t.type)||void 0===o||null===(o=o.match(/\/(\w+)$/))||void 0===o?void 0:o[1]},pn=!(null===(tn=" ".codePointAt)||void 0===tn||!tn.call(" ",0)),en=function(t){if(t.key&&pn&&t.key.codePointAt(0)===t.keyCode)return t.key;{let o;if(null===t.which?o=t.keyCode:0!==t.which&&0!==t.charCode&&(o=t.charCode),null!=o&&"escape"!==gn[o])return X.fromCodepoints([o]).toString()}},nn=function(t){const o=t.clipboardData;if(o){if(o.types.includes("text/html")){for(const t of o.types){const s=/^CorePasteboardFlavorType/.test(t),a=/^dyn\./.test(t)&&o.getData(t);if(s||a)return!0}return!1}{const t=o.types.includes("com.apple.webarchive"),s=o.types.includes("com.apple.flat-rtfd");return t||s}}};class rn extends z{constructor(t){super(...arguments),this.inputController=t,this.responder=this.inputController.responder,this.delegate=this.inputController.delegate,this.inputSummary=this.inputController.inputSummary,this.data={}}start(t){if(this.data.start=t,this.isSignificant()){var o,s;"keypress"===this.inputSummary.eventName&&this.inputSummary.textAdded&&(null===(s=this.responder)||void 0===s||s.deleteInDirection("left"));this.selectionIsExpanded()||(this.insertPlaceholder(),this.requestRender()),this.range=null===(o=this.responder)||void 0===o?void 0:o.getSelectedRange()}}update(t){if(this.data.update=t,this.isSignificant()){const t=this.selectPlaceholder();t&&(this.forgetPlaceholder(),this.range=t)}}end(t){return this.data.end=t,this.isSignificant()?(this.forgetPlaceholder(),this.canApplyToDocument()?(this.setInputSummary({preferDocument:!0,didInput:!1}),null===(o=this.delegate)||void 0===o||o.inputControllerWillPerformTyping(),null===(s=this.responder)||void 0===s||s.setSelectedRange(this.range),null===(a=this.responder)||void 0===a||a.insertString(this.data.end),null===(l=this.responder)||void 0===l?void 0:l.setSelectedRange(this.range[0]+this.data.end.length)):null!=this.data.start||null!=this.data.update?(this.requestReparse(),this.inputController.reset()):void 0):this.inputController.reset();var o,s,a,l}getEndData(){return this.data.end}isEnded(){return null!=this.getEndData()}isSignificant(){return!dn.composesExistingText||this.inputSummary.didInput}canApplyToDocument(){var t,o;return 0===(null===(t=this.data.start)||void 0===t?void 0:t.length)&&(null===(o=this.data.end)||void 0===o?void 0:o.length)>0&&this.range}}rn.proxyMethod("inputController.setInputSummary"),rn.proxyMethod("inputController.requestRender"),rn.proxyMethod("inputController.requestReparse"),rn.proxyMethod("responder?.selectionIsExpanded"),rn.proxyMethod("responder?.insertPlaceholder"),rn.proxyMethod("responder?.selectPlaceholder"),rn.proxyMethod("responder?.forgetPlaceholder");class on extends Ki{constructor(){super(...arguments),this.render=this.render.bind(this)}elementDidMutate(){return this.scheduledRender?this.composing?null===(t=this.delegate)||void 0===t||null===(o=t.inputControllerDidAllowUnhandledInput)||void 0===o?void 0:o.call(t):void 0:this.reparse();var t,o}scheduleRender(){return this.scheduledRender?this.scheduledRender:this.scheduledRender=requestAnimationFrame(this.render)}render(){var t,o;(cancelAnimationFrame(this.scheduledRender),this.scheduledRender=null,this.composing)||null===(o=this.delegate)||void 0===o||o.render();null===(t=this.afterRender)||void 0===t||t.call(this),this.afterRender=null}reparse(){var t;return null===(t=this.delegate)||void 0===t?void 0:t.reparse()}insertString(){var t;let o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",s=arguments.length>1?arguments[1]:void 0;return null===(t=this.delegate)||void 0===t||t.inputControllerWillPerformTyping(),this.withTargetDOMRange((function(){var t;return null===(t=this.responder)||void 0===t?void 0:t.insertString(o,s)}))}toggleAttributeIfSupported(t){var o;if(dt().includes(t))return null===(o=this.delegate)||void 0===o||o.inputControllerWillPerformFormatting(t),this.withTargetDOMRange((function(){var o;return null===(o=this.responder)||void 0===o?void 0:o.toggleCurrentAttribute(t)}))}activateAttributeIfSupported(t,o){var s;if(dt().includes(t))return null===(s=this.delegate)||void 0===s||s.inputControllerWillPerformFormatting(t),this.withTargetDOMRange((function(){var s;return null===(s=this.responder)||void 0===s?void 0:s.setCurrentAttribute(t,o)}))}deleteInDirection(t){let{recordUndoEntry:o}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{recordUndoEntry:!0};var s;o&&(null===(s=this.delegate)||void 0===s||s.inputControllerWillPerformTyping());const n=()=>{var o;return null===(o=this.responder)||void 0===o?void 0:o.deleteInDirection(t)},a=this.getTargetDOMRange({minLength:2});return a?this.withTargetDOMRange(a,n):n()}withTargetDOMRange(t,o){var s;return"function"==typeof t&&(o=t,t=this.getTargetDOMRange()),t?null===(s=this.responder)||void 0===s?void 0:s.withTargetDOMRange(t,o.bind(this)):(Pe.reset(),o.call(this))}getTargetDOMRange(){var t,o;let{minLength:s}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{minLength:0};const a=null===(t=(o=this.event).getTargetRanges)||void 0===t?void 0:t.call(o);if(a&&a.length){const t=sn(a[0]);if(0===s||t.toString().length>=s)return t}}withEvent(t,o){let s;this.event=t;try{s=o.call(this)}finally{this.event=null}return s}}Ae(on,"events",{keydown(t){if(ue(t)){var o;const s=hn(t);null!==(o=this.delegate)&&void 0!==o&&o.inputControllerDidReceiveKeyboardCommand(s)&&t.preventDefault()}else{let o=t.key;t.altKey&&(o+="+Alt"),t.shiftKey&&(o+="+Shift");const s=this.constructor.keys[o];if(s)return this.withEvent(t,s)}},paste(t){var o;let s;const a=null===(o=t.clipboardData)||void 0===o?void 0:o.getData("URL");return ln(t)?(t.preventDefault(),this.attachFiles(t.clipboardData.files)):cn(t)?(t.preventDefault(),s={type:"text/plain",string:t.clipboardData.getData("text/plain")},null===(l=this.delegate)||void 0===l||l.inputControllerWillPaste(s),null===(c=this.responder)||void 0===c||c.insertString(s.string),this.render(),null===(u=this.delegate)||void 0===u?void 0:u.inputControllerDidPaste(s)):a?(t.preventDefault(),s={type:"text/html",html:this.createLinkHTML(a)},null===(d=this.delegate)||void 0===d||d.inputControllerWillPaste(s),null===(m=this.responder)||void 0===m||m.insertHTML(s.html),this.render(),null===(p=this.delegate)||void 0===p?void 0:p.inputControllerDidPaste(s)):void 0;var l,c,u,d,m,p},beforeinput(t){const o=this.constructor.inputTypes[t.inputType];o&&(this.withEvent(t,o),this.scheduleRender())},input(t){Pe.reset()},dragstart(t){var o,s;null!==(o=this.responder)&&void 0!==o&&o.selectionContainsAttachments()&&(t.dataTransfer.setData("application/x-trix-dragging",!0),this.dragging={range:null===(s=this.responder)||void 0===s?void 0:s.getSelectedRange(),point:un(t)})},dragenter(t){an(t)&&t.preventDefault()},dragover(t){if(this.dragging){t.preventDefault();const s=un(t);var o;if(!kt(s,this.dragging.point))return this.dragging.point=s,null===(o=this.responder)||void 0===o?void 0:o.setLocationRangeFromPointRange(s)}else an(t)&&t.preventDefault()},drop(t){var o,s;if(this.dragging)return t.preventDefault(),null===(o=this.delegate)||void 0===o||o.inputControllerWillMoveText(),null===(s=this.responder)||void 0===s||s.moveTextFromRange(this.dragging.range),this.dragging=null,this.scheduleRender();if(an(t)){var a;t.preventDefault();const o=un(t);return null===(a=this.responder)||void 0===a||a.setLocationRangeFromPointRange(o),this.attachFiles(t.dataTransfer.files)}},dragend(){var t;this.dragging&&(null===(t=this.responder)||void 0===t||t.setSelectedRange(this.dragging.range),this.dragging=null)},compositionend(t){this.composing&&(this.composing=!1,u.recentAndroid||this.scheduleRender())}}),Ae(on,"keys",{ArrowLeft(){var t,o;if(null!==(t=this.responder)&&void 0!==t&&t.shouldManageMovingCursorInDirection("backward"))return this.event.preventDefault(),null===(o=this.responder)||void 0===o?void 0:o.moveCursorInDirection("backward")},ArrowRight(){var t,o;if(null!==(t=this.responder)&&void 0!==t&&t.shouldManageMovingCursorInDirection("forward"))return this.event.preventDefault(),null===(o=this.responder)||void 0===o?void 0:o.moveCursorInDirection("forward")},Backspace(){var t,o,s;if(null!==(t=this.responder)&&void 0!==t&&t.shouldManageDeletingInDirection("backward"))return this.event.preventDefault(),null===(o=this.delegate)||void 0===o||o.inputControllerWillPerformTyping(),null===(s=this.responder)||void 0===s||s.deleteInDirection("backward"),this.render()},Tab(){var t,o;if(null!==(t=this.responder)&&void 0!==t&&t.canIncreaseNestingLevel())return this.event.preventDefault(),null===(o=this.responder)||void 0===o||o.increaseNestingLevel(),this.render()},"Tab+Shift"(){var t,o;if(null!==(t=this.responder)&&void 0!==t&&t.canDecreaseNestingLevel())return this.event.preventDefault(),null===(o=this.responder)||void 0===o||o.decreaseNestingLevel(),this.render()}}),Ae(on,"inputTypes",{deleteByComposition(){return this.deleteInDirection("backward",{recordUndoEntry:!1})},deleteByCut(){return this.deleteInDirection("backward")},deleteByDrag(){return this.event.preventDefault(),this.withTargetDOMRange((function(){var t;this.deleteByDragRange=null===(t=this.responder)||void 0===t?void 0:t.getSelectedRange()}))},deleteCompositionText(){return this.deleteInDirection("backward",{recordUndoEntry:!1})},deleteContent(){return this.deleteInDirection("backward")},deleteContentBackward(){return this.deleteInDirection("backward")},deleteContentForward(){return this.deleteInDirection("forward")},deleteEntireSoftLine(){return this.deleteInDirection("forward")},deleteHardLineBackward(){return this.deleteInDirection("backward")},deleteHardLineForward(){return this.deleteInDirection("forward")},deleteSoftLineBackward(){return this.deleteInDirection("backward")},deleteSoftLineForward(){return this.deleteInDirection("forward")},deleteWordBackward(){return this.deleteInDirection("backward")},deleteWordForward(){return this.deleteInDirection("forward")},formatBackColor(){return this.activateAttributeIfSupported("backgroundColor",this.event.data)},formatBold(){return this.toggleAttributeIfSupported("bold")},formatFontColor(){return this.activateAttributeIfSupported("color",this.event.data)},formatFontName(){return this.activateAttributeIfSupported("font",this.event.data)},formatIndent(){var t;if(null!==(t=this.responder)&&void 0!==t&&t.canIncreaseNestingLevel())return this.withTargetDOMRange((function(){var t;return null===(t=this.responder)||void 0===t?void 0:t.increaseNestingLevel()}))},formatItalic(){return this.toggleAttributeIfSupported("italic")},formatJustifyCenter(){return this.toggleAttributeIfSupported("justifyCenter")},formatJustifyFull(){return this.toggleAttributeIfSupported("justifyFull")},formatJustifyLeft(){return this.toggleAttributeIfSupported("justifyLeft")},formatJustifyRight(){return this.toggleAttributeIfSupported("justifyRight")},formatOutdent(){var t;if(null!==(t=this.responder)&&void 0!==t&&t.canDecreaseNestingLevel())return this.withTargetDOMRange((function(){var t;return null===(t=this.responder)||void 0===t?void 0:t.decreaseNestingLevel()}))},formatRemove(){this.withTargetDOMRange((function(){for(const s in null===(t=this.responder)||void 0===t?void 0:t.getCurrentAttributes()){var t,o;null===(o=this.responder)||void 0===o||o.removeCurrentAttribute(s)}}))},formatSetBlockTextDirection(){return this.activateAttributeIfSupported("blockDir",this.event.data)},formatSetInlineTextDirection(){return this.activateAttributeIfSupported("textDir",this.event.data)},formatStrikeThrough(){return this.toggleAttributeIfSupported("strike")},formatSubscript(){return this.toggleAttributeIfSupported("sub")},formatSuperscript(){return this.toggleAttributeIfSupported("sup")},formatUnderline(){return this.toggleAttributeIfSupported("underline")},historyRedo(){var t;return null===(t=this.delegate)||void 0===t?void 0:t.inputControllerWillPerformRedo()},historyUndo(){var t;return null===(t=this.delegate)||void 0===t?void 0:t.inputControllerWillPerformUndo()},insertCompositionText(){return this.composing=!0,this.insertString(this.event.data)},insertFromComposition(){return this.composing=!1,this.insertString(this.event.data)},insertFromDrop(){const t=this.deleteByDragRange;var o;if(t)return this.deleteByDragRange=null,null===(o=this.delegate)||void 0===o||o.inputControllerWillMoveText(),this.withTargetDOMRange((function(){var o;return null===(o=this.responder)||void 0===o?void 0:o.moveTextFromRange(t)}))},insertFromPaste(){var t;const{dataTransfer:o}=this.event,s={dataTransfer:o},a=o.getData("URL"),l=o.getData("text/html");if(a){var c;let t;this.event.preventDefault(),s.type="text/html";const l=o.getData("public.url-name");t=l?qt(l).trim():a,s.html=this.createLinkHTML(a,t),null===(c=this.delegate)||void 0===c||c.inputControllerWillPaste(s),this.withTargetDOMRange((function(){var t;return null===(t=this.responder)||void 0===t?void 0:t.insertHTML(s.html)})),this.afterRender=()=>{var t;return null===(t=this.delegate)||void 0===t?void 0:t.inputControllerDidPaste(s)}}else if(Ct(o)){var u;s.type="text/plain",s.string=o.getData("text/plain"),null===(u=this.delegate)||void 0===u||u.inputControllerWillPaste(s),this.withTargetDOMRange((function(){var t;return null===(t=this.responder)||void 0===t?void 0:t.insertString(s.string)})),this.afterRender=()=>{var t;return null===(t=this.delegate)||void 0===t?void 0:t.inputControllerDidPaste(s)}}else if(l){var d;this.event.preventDefault(),s.type="text/html",s.html=l,null===(d=this.delegate)||void 0===d||d.inputControllerWillPaste(s),this.withTargetDOMRange((function(){var t;return null===(t=this.responder)||void 0===t?void 0:t.insertHTML(s.html)})),this.afterRender=()=>{var t;return null===(t=this.delegate)||void 0===t?void 0:t.inputControllerDidPaste(s)}}else if(null!==(t=o.files)&&void 0!==t&&t.length){var m;s.type="File",s.file=o.files[0],null===(m=this.delegate)||void 0===m||m.inputControllerWillPaste(s),this.withTargetDOMRange((function(){var t;return null===(t=this.responder)||void 0===t?void 0:t.insertFile(s.file)})),this.afterRender=()=>{var t;return null===(t=this.delegate)||void 0===t?void 0:t.inputControllerDidPaste(s)}}},insertFromYank(){return this.insertString(this.event.data)},insertLineBreak(){return this.insertString("\n")},insertLink(){return this.activateAttributeIfSupported("href",this.event.data)},insertOrderedList(){return this.toggleAttributeIfSupported("number")},insertParagraph(){var t;return null===(t=this.delegate)||void 0===t||t.inputControllerWillPerformTyping(),this.withTargetDOMRange((function(){var t;return null===(t=this.responder)||void 0===t?void 0:t.insertLineBreak()}))},insertReplacementText(){const t=this.event.dataTransfer.getData("text/plain"),o=this.event.getTargetRanges()[0];this.withTargetDOMRange(o,(()=>{this.insertString(t,{updatePosition:!1})}))},insertText(){var t;return this.insertString(this.event.data||(null===(t=this.event.dataTransfer)||void 0===t?void 0:t.getData("text/plain")))},insertTranspose(){return this.insertString(this.event.data)},insertUnorderedList(){return this.toggleAttributeIfSupported("bullet")}});const sn=function(t){const o=document.createRange();return o.setStart(t.startContainer,t.startOffset),o.setEnd(t.endContainer,t.endOffset),o},an=t=>{var o;return Array.from((null===(o=t.dataTransfer)||void 0===o?void 0:o.types)||[]).includes("Files")},ln=function(t){const o=t.clipboardData;if(o)return o.types.includes("Files")&&1===o.types.length&&o.files.length>=1},cn=function(t){const o=t.clipboardData;if(o)return o.types.includes("text/plain")&&1===o.types.length},hn=function(t){const o=[];return t.altKey&&o.push("alt"),t.shiftKey&&o.push("shift"),o.push(t.key),o},un=t=>({x:t.clientX,y:t.clientY}),fn="[data-trix-attribute]",bn="[data-trix-action]",vn="".concat(fn,", ").concat(bn),kn="[data-trix-dialog]",Sn="".concat(kn,"[data-trix-active]"),En="".concat(kn," [data-trix-method]"),Dn="".concat(kn," [data-trix-input]"),An=(t,o)=>(o||(o=yn(t)),t.querySelector("[data-trix-input][name='".concat(o,"']"))),xn=t=>t.getAttribute("data-trix-action"),yn=t=>t.getAttribute("data-trix-attribute")||t.getAttribute("data-trix-dialog-attribute");class Cn extends z{constructor(t){super(t),this.didClickActionButton=this.didClickActionButton.bind(this),this.didClickAttributeButton=this.didClickAttributeButton.bind(this),this.didClickDialogButton=this.didClickDialogButton.bind(this),this.didKeyDownDialogInput=this.didKeyDownDialogInput.bind(this),this.element=t,this.attributes={},this.actions={},this.resetDialogInputs(),f("mousedown",{onElement:this.element,matchingSelector:bn,withCallback:this.didClickActionButton}),f("mousedown",{onElement:this.element,matchingSelector:fn,withCallback:this.didClickAttributeButton}),f("click",{onElement:this.element,matchingSelector:vn,preventDefault:!0}),f("click",{onElement:this.element,matchingSelector:En,withCallback:this.didClickDialogButton}),f("keydown",{onElement:this.element,matchingSelector:Dn,withCallback:this.didKeyDownDialogInput})}didClickActionButton(t,o){var s;null===(s=this.delegate)||void 0===s||s.toolbarDidClickButton(),t.preventDefault();const a=xn(o);return this.getDialog(a)?this.toggleDialog(a):null===(l=this.delegate)||void 0===l?void 0:l.toolbarDidInvokeAction(a,o);var l}didClickAttributeButton(t,o){var s;null===(s=this.delegate)||void 0===s||s.toolbarDidClickButton(),t.preventDefault();const a=yn(o);var l;this.getDialog(a)?this.toggleDialog(a):null===(l=this.delegate)||void 0===l||l.toolbarDidToggleAttribute(a);return this.refreshAttributeButtons()}didClickDialogButton(t,o){const s=A(o,{matchingSelector:kn});return this[o.getAttribute("data-trix-method")].call(this,s)}didKeyDownDialogInput(t,o){if(13===t.keyCode){t.preventDefault();const s=o.getAttribute("name"),a=this.getDialog(s);this.setAttribute(a)}if(27===t.keyCode)return t.preventDefault(),this.hideDialog()}updateActions(t){return this.actions=t,this.refreshActionButtons()}refreshActionButtons(){return this.eachActionButton(((t,o)=>{t.disabled=!1===this.actions[o]}))}eachActionButton(t){return Array.from(this.element.querySelectorAll(bn)).map((o=>t(o,xn(o))))}updateAttributes(t){return this.attributes=t,this.refreshAttributeButtons()}refreshAttributeButtons(){return this.eachAttributeButton(((t,o)=>(t.disabled=!1===this.attributes[o],this.attributes[o]||this.dialogIsVisible(o)?(t.setAttribute("data-trix-active",""),t.classList.add("trix-active")):(t.removeAttribute("data-trix-active"),t.classList.remove("trix-active")))))}eachAttributeButton(t){return Array.from(this.element.querySelectorAll(fn)).map((o=>t(o,yn(o))))}applyKeyboardCommand(t){const o=JSON.stringify(t.sort());for(const t of Array.from(this.element.querySelectorAll("[data-trix-key]"))){const s=t.getAttribute("data-trix-key").split("+");if(JSON.stringify(s.sort())===o)return b("mousedown",{onElement:t}),!0}return!1}dialogIsVisible(t){const o=this.getDialog(t);if(o)return o.hasAttribute("data-trix-active")}toggleDialog(t){return this.dialogIsVisible(t)?this.hideDialog():this.showDialog(t)}showDialog(t){var o,s;this.hideDialog(),null===(o=this.delegate)||void 0===o||o.toolbarWillShowDialog();const a=this.getDialog(t);a.setAttribute("data-trix-active",""),a.classList.add("trix-active"),Array.from(a.querySelectorAll("input[disabled]")).forEach((t=>{t.removeAttribute("disabled")}));const l=yn(a);if(l){const o=An(a,t);o&&(o.value=this.attributes[l]||"",o.select())}return null===(s=this.delegate)||void 0===s?void 0:s.toolbarDidShowDialog(t)}setAttribute(t){const o=yn(t),s=An(t,o);return s.willValidate&&!s.checkValidity()?(s.setAttribute("data-trix-validate",""),s.classList.add("trix-validate"),s.focus()):(null===(a=this.delegate)||void 0===a||a.toolbarDidUpdateAttribute(o,s.value),this.hideDialog());var a}removeAttribute(t){var o;const s=yn(t);return null===(o=this.delegate)||void 0===o||o.toolbarDidRemoveAttribute(s),this.hideDialog()}hideDialog(){const t=this.element.querySelector(Sn);var o;if(t)return t.removeAttribute("data-trix-active"),t.classList.remove("trix-active"),this.resetDialogInputs(),null===(o=this.delegate)||void 0===o?void 0:o.toolbarDidHideDialog((t=>t.getAttribute("data-trix-dialog"))(t))}resetDialogInputs(){Array.from(this.element.querySelectorAll(Dn)).forEach((t=>{t.setAttribute("disabled","disabled"),t.removeAttribute("data-trix-validate"),t.classList.remove("trix-validate")}))}getDialog(t){return this.element.querySelector("[data-trix-dialog=".concat(t,"]"))}}class Rn extends Oi{constructor(t){let{editorElement:o,document:s,html:a}=t;super(...arguments),this.editorElement=o,this.selectionManager=new Li(this.editorElement),this.selectionManager.delegate=this,this.composition=new gi,this.composition.delegate=this,this.attachmentManager=new ui(this.composition.getAttachments()),this.attachmentManager.delegate=this,this.inputController=2===U.getLevel()?new on(this.editorElement):new Qi(this.editorElement),this.inputController.delegate=this,this.inputController.responder=this.composition,this.compositionController=new Ni(this.editorElement,this.composition),this.compositionController.delegate=this,this.toolbarController=new Cn(this.editorElement.toolbarElement),this.toolbarController.delegate=this,this.editor=new xi(this.composition,this.selectionManager,this.editorElement),s?this.editor.loadDocument(s):this.editor.loadHTML(a)}registerSelectionManager(){return Pe.registerSelectionManager(this.selectionManager)}unregisterSelectionManager(){return Pe.unregisterSelectionManager(this.selectionManager)}render(){return this.compositionController.render()}reparse(){return this.composition.replaceHTML(this.editorElement.innerHTML)}compositionDidChangeDocument(t){if(this.notifyEditorElement("document-change"),!this.handlingInput)return this.render()}compositionDidChangeCurrentAttributes(t){return this.currentAttributes=t,this.toolbarController.updateAttributes(this.currentAttributes),this.updateCurrentActions(),this.notifyEditorElement("attributes-change",{attributes:this.currentAttributes})}compositionDidPerformInsertionAtRange(t){this.pasting&&(this.pastedRange=t)}compositionShouldAcceptFile(t){return this.notifyEditorElement("file-accept",{file:t})}compositionDidAddAttachment(t){const o=this.attachmentManager.manageAttachment(t);return this.notifyEditorElement("attachment-add",{attachment:o})}compositionDidEditAttachment(t){this.compositionController.rerenderViewForObject(t);const o=this.attachmentManager.manageAttachment(t);return this.notifyEditorElement("attachment-edit",{attachment:o}),this.notifyEditorElement("change")}compositionDidChangeAttachmentPreviewURL(t){return this.compositionController.invalidateViewForObject(t),this.notifyEditorElement("change")}compositionDidRemoveAttachment(t){const o=this.attachmentManager.unmanageAttachment(t);return this.notifyEditorElement("attachment-remove",{attachment:o})}compositionDidStartEditingAttachment(t,o){return this.attachmentLocationRange=this.composition.document.getLocationRangeOfAttachment(t),this.compositionController.installAttachmentEditorForAttachment(t,o),this.selectionManager.setLocationRange(this.attachmentLocationRange)}compositionDidStopEditingAttachment(t){this.compositionController.uninstallAttachmentEditor(),this.attachmentLocationRange=null}compositionDidRequestChangingSelectionToLocationRange(t){if(!this.loadingSnapshot||this.isFocused())return this.requestedLocationRange=t,this.compositionRevisionWhenLocationRangeRequested=this.composition.revision,this.handlingInput?void 0:this.render()}compositionWillLoadSnapshot(){this.loadingSnapshot=!0}compositionDidLoadSnapshot(){this.compositionController.refreshViewCache(),this.render(),this.loadingSnapshot=!1}getSelectionManager(){return this.selectionManager}attachmentManagerDidRequestRemovalOfAttachment(t){return this.removeAttachment(t)}compositionControllerWillSyncDocumentView(){return this.inputController.editorWillSyncDocumentView(),this.selectionManager.lock(),this.selectionManager.clearSelection()}compositionControllerDidSyncDocumentView(){return this.inputController.editorDidSyncDocumentView(),this.selectionManager.unlock(),this.updateCurrentActions(),this.notifyEditorElement("sync")}compositionControllerDidRender(){this.requestedLocationRange&&(this.compositionRevisionWhenLocationRangeRequested===this.composition.revision&&this.selectionManager.setLocationRange(this.requestedLocationRange),this.requestedLocationRange=null,this.compositionRevisionWhenLocationRangeRequested=null),this.renderedCompositionRevision!==this.composition.revision&&(this.runEditorFilters(),this.composition.updateCurrentAttributes(),this.notifyEditorElement("render")),this.renderedCompositionRevision=this.composition.revision}compositionControllerDidFocus(){return this.isFocusedInvisibly()&&this.setLocationRange({index:0,offset:0}),this.toolbarController.hideDialog(),this.notifyEditorElement("focus")}compositionControllerDidBlur(){return this.notifyEditorElement("blur")}compositionControllerDidSelectAttachment(t,o){return this.toolbarController.hideDialog(),this.composition.editAttachment(t,o)}compositionControllerDidRequestDeselectingAttachment(t){const o=this.attachmentLocationRange||this.composition.document.getLocationRangeOfAttachment(t);return this.selectionManager.setLocationRange(o[1])}compositionControllerWillUpdateAttachment(t){return this.editor.recordUndoEntry("Edit Attachment",{context:t.id,consolidatable:!0})}compositionControllerDidRequestRemovalOfAttachment(t){return this.removeAttachment(t)}inputControllerWillHandleInput(){this.handlingInput=!0,this.requestedRender=!1}inputControllerDidRequestRender(){this.requestedRender=!0}inputControllerDidHandleInput(){if(this.handlingInput=!1,this.requestedRender)return this.requestedRender=!1,this.render()}inputControllerDidAllowUnhandledInput(){return this.notifyEditorElement("change")}inputControllerDidRequestReparse(){return this.reparse()}inputControllerWillPerformTyping(){return this.recordTypingUndoEntry()}inputControllerWillPerformFormatting(t){return this.recordFormattingUndoEntry(t)}inputControllerWillCutText(){return this.editor.recordUndoEntry("Cut")}inputControllerWillPaste(t){return this.editor.recordUndoEntry("Paste"),this.pasting=!0,this.notifyEditorElement("before-paste",{paste:t})}inputControllerDidPaste(t){return t.range=this.pastedRange,this.pastedRange=null,this.pasting=null,this.notifyEditorElement("paste",{paste:t})}inputControllerWillMoveText(){return this.editor.recordUndoEntry("Move")}inputControllerWillAttachFiles(){return this.editor.recordUndoEntry("Drop Files")}inputControllerWillPerformUndo(){return this.editor.undo()}inputControllerWillPerformRedo(){return this.editor.redo()}inputControllerDidReceiveKeyboardCommand(t){return this.toolbarController.applyKeyboardCommand(t)}inputControllerDidStartDrag(){this.locationRangeBeforeDrag=this.selectionManager.getLocationRange()}inputControllerDidReceiveDragOverPoint(t){return this.selectionManager.setLocationRangeFromPointRange(t)}inputControllerDidCancelDrag(){this.selectionManager.setLocationRange(this.locationRangeBeforeDrag),this.locationRangeBeforeDrag=null}locationRangeDidChange(t){return this.composition.updateCurrentAttributes(),this.updateCurrentActions(),this.attachmentLocationRange&&!wt(this.attachmentLocationRange,t)&&this.composition.stopEditingAttachment(),this.notifyEditorElement("selection-change")}toolbarDidClickButton(){if(!this.getLocationRange())return this.setLocationRange({index:0,offset:0})}toolbarDidInvokeAction(t,o){return this.invokeAction(t,o)}toolbarDidToggleAttribute(t){if(this.recordFormattingUndoEntry(t),this.composition.toggleCurrentAttribute(t),this.render(),!this.selectionFrozen)return this.editorElement.focus()}toolbarDidUpdateAttribute(t,o){if(this.recordFormattingUndoEntry(t),this.composition.setCurrentAttribute(t,o),this.render(),!this.selectionFrozen)return this.editorElement.focus()}toolbarDidRemoveAttribute(t){if(this.recordFormattingUndoEntry(t),this.composition.removeCurrentAttribute(t),this.render(),!this.selectionFrozen)return this.editorElement.focus()}toolbarWillShowDialog(t){return this.composition.expandSelectionForEditing(),this.freezeSelection()}toolbarDidShowDialog(t){return this.notifyEditorElement("toolbar-dialog-show",{dialogName:t})}toolbarDidHideDialog(t){return this.thawSelection(),this.editorElement.focus(),this.notifyEditorElement("toolbar-dialog-hide",{dialogName:t})}freezeSelection(){if(!this.selectionFrozen)return this.selectionManager.lock(),this.composition.freezeSelection(),this.selectionFrozen=!0,this.render()}thawSelection(){if(this.selectionFrozen)return this.composition.thawSelection(),this.selectionManager.unlock(),this.selectionFrozen=!1,this.render()}canInvokeAction(t){return!!this.actionIsExternal(t)||!(null===(o=this.actions[t])||void 0===o||null===(o=o.test)||void 0===o||!o.call(this));var o}invokeAction(t,o){return this.actionIsExternal(t)?this.notifyEditorElement("action-invoke",{actionName:t,invokingElement:o}):null===(s=this.actions[t])||void 0===s||null===(s=s.perform)||void 0===s?void 0:s.call(this);var s}actionIsExternal(t){return/^x-./.test(t)}getCurrentActions(){const t={};for(const o in this.actions)t[o]=this.canInvokeAction(o);return t}updateCurrentActions(){const t=this.getCurrentActions();if(!kt(t,this.currentActions))return this.currentActions=t,this.toolbarController.updateActions(this.currentActions),this.notifyEditorElement("actions-change",{actions:this.currentActions})}runEditorFilters(){let t=this.composition.getSnapshot();if(Array.from(this.editor.filters).forEach((o=>{const{document:s,selectedRange:a}=t;t=o.call(this.editor,t)||{},t.document||(t.document=s),t.selectedRange||(t.selectedRange=a)})),o=t,s=this.composition.getSnapshot(),!wt(o.selectedRange,s.selectedRange)||!o.document.isEqualTo(s.document))return this.composition.loadSnapshot(t);var o,s}updateInputElement(){const t=function(t,o){const s=Di[o];if(s)return s(t);throw new Error("unknown content type: ".concat(o))}(this.compositionController.getSerializableElement(),"text/html");return this.editorElement.setInputElementValue(t)}notifyEditorElement(t,o){switch(t){case"document-change":this.documentChangedSinceLastRender=!0;break;case"render":this.documentChangedSinceLastRender&&(this.documentChangedSinceLastRender=!1,this.notifyEditorElement("change"));break;case"change":case"attachment-add":case"attachment-edit":case"attachment-remove":this.updateInputElement()}return this.editorElement.notify(t,o)}removeAttachment(t){return this.editor.recordUndoEntry("Delete Attachment"),this.composition.removeAttachment(t),this.render()}recordFormattingUndoEntry(t){const o=gt(t),s=this.selectionManager.getLocationRange();if(o||!Dt(s))return this.editor.recordUndoEntry("Formatting",{context:this.getUndoContext(),consolidatable:!0})}recordTypingUndoEntry(){return this.editor.recordUndoEntry("Typing",{context:this.getUndoContext(this.currentAttributes),consolidatable:!0})}getUndoContext(){for(var t=arguments.length,o=new Array(t),s=0;s<t;s++)o[s]=arguments[s];return[this.getLocationContext(),this.getTimeContext(),...Array.from(o)]}getLocationContext(){const t=this.selectionManager.getLocationRange();return Dt(t)?t[0].index:t}getTimeContext(){return K.interval>0?Math.floor((new Date).getTime()/K.interval):0}isFocused(){var t;return this.editorElement===(null===(t=this.editorElement.ownerDocument)||void 0===t?void 0:t.activeElement)}isFocusedInvisibly(){return this.isFocused()&&!this.getLocationRange()}get actions(){return this.constructor.actions}}Ae(Rn,"actions",{undo:{test(){return this.editor.canUndo()},perform(){return this.editor.undo()}},redo:{test(){return this.editor.canRedo()},perform(){return this.editor.redo()}},link:{test(){return this.editor.canActivateAttribute("href")}},increaseNestingLevel:{test(){return this.editor.canIncreaseNestingLevel()},perform(){return this.editor.increaseNestingLevel()&&this.render()}},decreaseNestingLevel:{test(){return this.editor.canDecreaseNestingLevel()},perform(){return this.editor.decreaseNestingLevel()&&this.render()}},attachFiles:{test:()=>!0,perform(){return U.pickFiles(this.editor.insertFiles)}}}),Rn.proxyMethod("getSelectionManager().setLocationRange"),Rn.proxyMethod("getSelectionManager().getLocationRange");var In=Object.freeze({__proto__:null,AttachmentEditorController:Pi,CompositionController:Ni,Controller:Oi,EditorController:Rn,InputController:Ki,Level0InputController:Qi,Level2InputController:on,ToolbarController:Cn}),Nn=Object.freeze({__proto__:null,MutationObserver:Ui,SelectionChangeObserver:Ft}),On=Object.freeze({__proto__:null,FileVerificationOperation:Vi,ImagePreloadOperation:Ce});bt("trix-toolbar","%t {\n display: block;\n}\n\n%t {\n white-space: nowrap;\n}\n\n%t [data-trix-dialog] {\n display: none;\n}\n\n%t [data-trix-dialog][data-trix-active] {\n display: block;\n}\n\n%t [data-trix-dialog] [data-trix-validate]:invalid {\n background-color: #ffdddd;\n}");class Ln extends HTMLElement{connectedCallback(){""===this.innerHTML&&(this.innerHTML=J.getDefaultHTML())}}let Mn=0;const wn=function(t){if(!t.hasAttribute("contenteditable"))return t.setAttribute("contenteditable",""),function(t){let o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return o.times=1,f(t,o)}("focus",{onElement:t,withCallback:()=>Tn(t)})},Tn=function(t){return Bn(t),Fn(t)},Bn=function(t){var o,s;if(null!==(o=(s=document).queryCommandSupported)&&void 0!==o&&o.call(s,"enableObjectResizing"))return document.execCommand("enableObjectResizing",!1,!1),f("mscontrolselect",{onElement:t,preventDefault:!0})},Fn=function(t){var o,s;if(null!==(o=(s=document).queryCommandSupported)&&void 0!==o&&o.call(s,"DefaultParagraphSeparator")){const{tagName:t}=a.default;if(["div","p"].includes(t))return document.execCommand("DefaultParagraphSeparator",!1,t)}},jn=u.forcesObjectResizing?{display:"inline",width:"auto"}:{display:"inline-block",width:"1px"};bt("trix-editor","%t {\n display: block;\n}\n\n%t:empty:not(:focus)::before {\n content: attr(placeholder);\n color: graytext;\n cursor: text;\n pointer-events: none;\n white-space: pre-line;\n}\n\n%t a[contenteditable=false] {\n cursor: text;\n}\n\n%t img {\n max-width: 100%;\n height: auto;\n}\n\n%t ".concat(o," figcaption textarea {\n resize: none;\n}\n\n%t ").concat(o," figcaption textarea.trix-autoresize-clone {\n position: absolute;\n left: -9999px;\n max-height: 0px;\n}\n\n%t ").concat(o," figcaption[data-trix-placeholder]:empty::before {\n content: attr(data-trix-placeholder);\n color: graytext;\n}\n\n%t [data-trix-cursor-target] {\n display: ").concat(jn.display," !important;\n width: ").concat(jn.width," !important;\n padding: 0 !important;\n margin: 0 !important;\n border: none !important;\n}\n\n%t [data-trix-cursor-target=left] {\n vertical-align: top !important;\n margin-left: -1px !important;\n}\n\n%t [data-trix-cursor-target=right] {\n vertical-align: bottom !important;\n margin-right: -1px !important;\n}"));class Pn extends HTMLElement{get trixId(){return this.hasAttribute("trix-id")?this.getAttribute("trix-id"):(this.setAttribute("trix-id",++Mn),this.trixId)}get labels(){const t=[];this.id&&this.ownerDocument&&t.push(...Array.from(this.ownerDocument.querySelectorAll("label[for='".concat(this.id,"']"))||[]));const o=A(this,{matchingSelector:"label"});return o&&[this,null].includes(o.control)&&t.push(o),t}get toolbarElement(){var t;if(this.hasAttribute("toolbar"))return null===(t=this.ownerDocument)||void 0===t?void 0:t.getElementById(this.getAttribute("toolbar"));if(this.parentNode){const t="trix-toolbar-".concat(this.trixId);this.setAttribute("toolbar",t);const o=k("trix-toolbar",{id:t});return this.parentNode.insertBefore(o,this),o}}get form(){var t;return null===(t=this.inputElement)||void 0===t?void 0:t.form}get inputElement(){var t;if(this.hasAttribute("input"))return null===(t=this.ownerDocument)||void 0===t?void 0:t.getElementById(this.getAttribute("input"));if(this.parentNode){const t="trix-input-".concat(this.trixId);this.setAttribute("input",t);const o=k("input",{type:"hidden",id:t});return this.parentNode.insertBefore(o,this.nextElementSibling),o}}get editor(){var t;return null===(t=this.editorController)||void 0===t?void 0:t.editor}get name(){var t;return null===(t=this.inputElement)||void 0===t?void 0:t.name}get value(){var t;return null===(t=this.inputElement)||void 0===t?void 0:t.value}set value(t){var o;this.defaultValue=t,null===(o=this.editor)||void 0===o||o.loadHTML(this.defaultValue)}notify(t,o){if(this.editorController)return b("trix-".concat(t),{onElement:this,attributes:o})}setInputElementValue(t){this.inputElement&&(this.inputElement.value=t)}connectedCallback(){this.hasAttribute("data-trix-internal")||(wn(this),function(t){t.hasAttribute("role")||t.setAttribute("role","textbox")}(this),function(t){if(t.hasAttribute("aria-label")||t.hasAttribute("aria-labelledby"))return;const e=function(){const o=Array.from(t.labels).map((o=>{if(!o.contains(t))return o.textContent})).filter((t=>t)),s=o.join(" ");return s?t.setAttribute("aria-label",s):t.removeAttribute("aria-label")};e(),f("focus",{onElement:t,withCallback:e})}(this),this.editorController||(b("trix-before-initialize",{onElement:this}),this.editorController=new Rn({editorElement:this,html:this.defaultValue=this.value}),requestAnimationFrame((()=>b("trix-initialize",{onElement:this})))),this.editorController.registerSelectionManager(),this.registerResetListener(),this.registerClickListener(),function(t){!document.querySelector(":focus")&&t.hasAttribute("autofocus")&&document.querySelector("[autofocus]")===t&&t.focus()}(this))}disconnectedCallback(){var t;return null===(t=this.editorController)||void 0===t||t.unregisterSelectionManager(),this.unregisterResetListener(),this.unregisterClickListener()}registerResetListener(){return this.resetListener=this.resetBubbled.bind(this),window.addEventListener("reset",this.resetListener,!1)}unregisterResetListener(){return window.removeEventListener("reset",this.resetListener,!1)}registerClickListener(){return this.clickListener=this.clickBubbled.bind(this),window.addEventListener("click",this.clickListener,!1)}unregisterClickListener(){return window.removeEventListener("click",this.clickListener,!1)}resetBubbled(t){if(!t.defaultPrevented&&t.target===this.form)return this.reset()}clickBubbled(t){if(t.defaultPrevented)return;if(this.contains(t.target))return;const o=A(t.target,{matchingSelector:"label"});return o&&Array.from(this.labels).includes(o)?this.focus():void 0}reset(){this.value=this.defaultValue}}const Wn={VERSION:t,config:G,core:wi,models:Fi,views:Mi,controllers:In,observers:Nn,operations:On,elements:Object.freeze({__proto__:null,TrixEditorElement:Pn,TrixToolbarElement:Ln}),filters:Object.freeze({__proto__:null,Filter:bi,attachmentGalleryFilter:vi})};Object.assign(Wn,Fi),window.Trix=Wn,setTimeout((function(){customElements.get("trix-toolbar")||customElements.define("trix-toolbar",Ln),customElements.get("trix-editor")||customElements.define("trix-editor",Pn)}),0);export{Wn as default};
|
2
|
+
|
@@ -0,0 +1,2 @@
|
|
1
|
+
var e={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:"'"};var r={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'};var t="undefined"!=typeof navigator&&/Mac/.test(navigator.platform);var o="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var n=0;n<10;n++)e[48+n]=e[96+n]=String(n);for(n=1;n<=24;n++)e[n+111]="F"+n;for(n=65;n<=90;n++){e[n]=String.fromCharCode(n+32);r[n]=String.fromCharCode(n)}for(var a in e)r.hasOwnProperty(a)||(r[a]=e[a]);function keyName(n){var a=t&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||o&&n.shiftKey&&n.key&&1==n.key.length||"Unidentified"==n.key;var i=!a&&n.key||(n.shiftKey?r:e)[n.keyCode]||n.key||"Unidentified";"Esc"==i&&(i="Escape");"Del"==i&&(i="Delete");"Left"==i&&(i="ArrowLeft");"Up"==i&&(i="ArrowUp");"Right"==i&&(i="ArrowRight");"Down"==i&&(i="ArrowDown");return i}export{e as base,keyName,r as shift};
|
2
|
+
|