smart-webcomponents-react 23.1.1 → 23.1.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (217) hide show
  1. package/editor/editor.d.ts +15 -0
  2. package/editor/editor.esm.js +34 -1
  3. package/editor/editor.umd.js +34 -1
  4. package/index.d.ts +15 -0
  5. package/package.json +1 -1
  6. package/source/modules/smart.3dchart.js +2 -2
  7. package/source/modules/smart.accordion.js +2 -2
  8. package/source/modules/smart.array.js +2 -2
  9. package/source/modules/smart.barcode.js +2 -2
  10. package/source/modules/smart.breadcrumb.js +2 -2
  11. package/source/modules/smart.button.js +2 -2
  12. package/source/modules/smart.buttongroup.js +2 -2
  13. package/source/modules/smart.calendar.js +2 -2
  14. package/source/modules/smart.card.js +2 -2
  15. package/source/modules/smart.cardview.js +2 -2
  16. package/source/modules/smart.carousel.js +2 -2
  17. package/source/modules/smart.chart.js +2 -2
  18. package/source/modules/smart.checkbox.js +2 -2
  19. package/source/modules/smart.checkinput.js +2 -2
  20. package/source/modules/smart.chip.js +2 -2
  21. package/source/modules/smart.colorinput.js +2 -2
  22. package/source/modules/smart.colorpanel.js +2 -2
  23. package/source/modules/smart.colorpicker.js +2 -2
  24. package/source/modules/smart.combobox.js +2 -2
  25. package/source/modules/smart.common.js +2 -2
  26. package/source/modules/smart.countryinput.js +2 -2
  27. package/source/modules/smart.dateinput.js +2 -2
  28. package/source/modules/smart.daterangeinput.js +2 -2
  29. package/source/modules/smart.datetimepicker.js +2 -2
  30. package/source/modules/smart.dockinglayout.js +2 -2
  31. package/source/modules/smart.dropdownbutton.js +2 -2
  32. package/source/modules/smart.dropdownlist.js +2 -2
  33. package/source/modules/smart.editor.js +3 -3
  34. package/source/modules/smart.element.js +2 -2
  35. package/source/modules/smart.fileupload.js +2 -2
  36. package/source/modules/smart.form.js +2 -2
  37. package/source/modules/smart.formulaparser.js +2 -2
  38. package/source/modules/smart.ganttchart.js +2 -2
  39. package/source/modules/smart.gauge.js +2 -2
  40. package/source/modules/smart.grid.js +4 -4
  41. package/source/modules/smart.gridpanel.js +2 -2
  42. package/source/modules/smart.gridview.js +4 -4
  43. package/source/modules/smart.input.js +2 -2
  44. package/source/modules/smart.kanban.js +2 -2
  45. package/source/modules/smart.layout.js +2 -2
  46. package/source/modules/smart.led.js +2 -2
  47. package/source/modules/smart.listbox.js +2 -2
  48. package/source/modules/smart.listmenu.js +2 -2
  49. package/source/modules/smart.map.js +2 -2
  50. package/source/modules/smart.maskedtextbox.js +2 -2
  51. package/source/modules/smart.menu.js +2 -2
  52. package/source/modules/smart.multicomboinput.js +2 -2
  53. package/source/modules/smart.multiinput.js +2 -2
  54. package/source/modules/smart.multilinetextbox.js +2 -2
  55. package/source/modules/smart.multisplitbutton.js +2 -2
  56. package/source/modules/smart.numberinput.js +2 -2
  57. package/source/modules/smart.numerictextbox.js +2 -2
  58. package/source/modules/smart.pager.js +2 -2
  59. package/source/modules/smart.passwordinput.js +2 -2
  60. package/source/modules/smart.passwordtextbox.js +2 -2
  61. package/source/modules/smart.path.js +2 -2
  62. package/source/modules/smart.phoneinput.js +2 -2
  63. package/source/modules/smart.pivottable.js +2 -2
  64. package/source/modules/smart.progressbar.js +2 -2
  65. package/source/modules/smart.qrcode.js +2 -2
  66. package/source/modules/smart.querybuilder.js +2 -2
  67. package/source/modules/smart.radiobutton.js +2 -2
  68. package/source/modules/smart.rating.js +2 -2
  69. package/source/modules/smart.ribbon.js +2 -2
  70. package/source/modules/smart.router.js +2 -2
  71. package/source/modules/smart.scheduler.js +2 -2
  72. package/source/modules/smart.scrollbar.js +2 -2
  73. package/source/modules/smart.slider.js +2 -2
  74. package/source/modules/smart.sortable.js +2 -2
  75. package/source/modules/smart.splitter.js +2 -2
  76. package/source/modules/smart.switchbutton.js +2 -2
  77. package/source/modules/smart.table.js +2 -2
  78. package/source/modules/smart.tabs.js +2 -2
  79. package/source/modules/smart.tank.js +2 -2
  80. package/source/modules/smart.textarea.js +2 -2
  81. package/source/modules/smart.textbox.js +2 -2
  82. package/source/modules/smart.timeinput.js +2 -2
  83. package/source/modules/smart.timeline.js +2 -2
  84. package/source/modules/smart.timepicker.js +2 -2
  85. package/source/modules/smart.toast.js +2 -2
  86. package/source/modules/smart.tooltip.js +2 -2
  87. package/source/modules/smart.tree.js +2 -2
  88. package/source/modules/smart.validator.js +2 -2
  89. package/source/modules/smart.window.js +2 -2
  90. package/source/smart.3dchart.js +1 -1
  91. package/source/smart.accordion.js +1 -1
  92. package/source/smart.ajax.js +1 -1
  93. package/source/smart.array.js +1 -1
  94. package/source/smart.barcode.js +1 -1
  95. package/source/smart.bootstrap.js +1 -1
  96. package/source/smart.breadcrumb.js +1 -1
  97. package/source/smart.button.js +1 -1
  98. package/source/smart.buttongroup.js +1 -1
  99. package/source/smart.calendar.js +1 -1
  100. package/source/smart.card.js +1 -1
  101. package/source/smart.cardview.js +1 -1
  102. package/source/smart.carousel.js +1 -1
  103. package/source/smart.chart.annotations.js +1 -1
  104. package/source/smart.chart.api.js +1 -1
  105. package/source/smart.chart.core.js +1 -1
  106. package/source/smart.chart.js +1 -1
  107. package/source/smart.chart.rangeselector.js +1 -1
  108. package/source/smart.chart.waterfall.js +1 -1
  109. package/source/smart.checkbox.js +1 -1
  110. package/source/smart.checkinput.js +1 -1
  111. package/source/smart.chip.js +1 -1
  112. package/source/smart.colorinput.js +1 -1
  113. package/source/smart.colorpanel.js +1 -1
  114. package/source/smart.colorpicker.js +1 -1
  115. package/source/smart.combobox.js +1 -1
  116. package/source/smart.complex.js +1 -1
  117. package/source/smart.core.js +1 -1
  118. package/source/smart.countryinput.js +1 -1
  119. package/source/smart.data.js +1 -1
  120. package/source/smart.date.js +1 -1
  121. package/source/smart.dateformatpanel.js +1 -1
  122. package/source/smart.dateinput.js +1 -1
  123. package/source/smart.daterangeinput.js +1 -1
  124. package/source/smart.datetimepicker.js +1 -1
  125. package/source/smart.dockinglayout.js +1 -1
  126. package/source/smart.draw.js +1 -1
  127. package/source/smart.dropdownbutton.js +1 -1
  128. package/source/smart.dropdownlist.js +1 -1
  129. package/source/smart.editor.js +2 -2
  130. package/source/smart.element.js +1 -1
  131. package/source/smart.elements.js +4 -4
  132. package/source/smart.export.js +1 -1
  133. package/source/smart.fileupload.js +1 -1
  134. package/source/smart.filter.js +1 -1
  135. package/source/smart.filterbuilder.js +1 -1
  136. package/source/smart.filterpanel.js +1 -1
  137. package/source/smart.form.js +1 -1
  138. package/source/smart.format.js +1 -1
  139. package/source/smart.formulaparser.js +1 -1
  140. package/source/smart.ganttchart.js +1 -1
  141. package/source/smart.gauge.js +1 -1
  142. package/source/smart.grid.cell.js +1 -1
  143. package/source/smart.grid.chart.js +1 -1
  144. package/source/smart.grid.column.js +2 -2
  145. package/source/smart.grid.core.js +2 -2
  146. package/source/smart.grid.dialog.js +1 -1
  147. package/source/smart.grid.edit.js +1 -1
  148. package/source/smart.grid.export.js +1 -1
  149. package/source/smart.grid.filter.js +1 -1
  150. package/source/smart.grid.group.js +1 -1
  151. package/source/smart.grid.js +1 -1
  152. package/source/smart.grid.menu.js +1 -1
  153. package/source/smart.grid.pager.js +1 -1
  154. package/source/smart.grid.reorder.js +1 -1
  155. package/source/smart.grid.resize.js +1 -1
  156. package/source/smart.grid.row.js +1 -1
  157. package/source/smart.grid.select.js +1 -1
  158. package/source/smart.grid.sort.js +1 -1
  159. package/source/smart.grid.toolbar.js +1 -1
  160. package/source/smart.grid.tree.js +1 -1
  161. package/source/smart.grid.view.js +1 -1
  162. package/source/smart.gridpanel.js +1 -1
  163. package/source/smart.input.js +1 -1
  164. package/source/smart.kanban.js +1 -1
  165. package/source/smart.layout.js +1 -1
  166. package/source/smart.led.js +1 -1
  167. package/source/smart.listbox.js +1 -1
  168. package/source/smart.listmenu.js +1 -1
  169. package/source/smart.map.js +1 -1
  170. package/source/smart.maskedtextbox.js +1 -1
  171. package/source/smart.math.js +1 -1
  172. package/source/smart.menu.js +1 -1
  173. package/source/smart.multicomboinput.js +1 -1
  174. package/source/smart.multiinput.js +1 -1
  175. package/source/smart.multilinetextbox.js +1 -1
  176. package/source/smart.multisplitbutton.js +1 -1
  177. package/source/smart.numberformatpanel.js +1 -1
  178. package/source/smart.numberinput.js +1 -1
  179. package/source/smart.numeric.js +1 -1
  180. package/source/smart.numerictextbox.js +1 -1
  181. package/source/smart.pager.js +1 -1
  182. package/source/smart.passwordinput.js +1 -1
  183. package/source/smart.passwordtextbox.js +1 -1
  184. package/source/smart.path.js +1 -1
  185. package/source/smart.phoneinput.js +1 -1
  186. package/source/smart.pivottable.js +1 -1
  187. package/source/smart.powerbutton.js +1 -1
  188. package/source/smart.progressbar.js +1 -1
  189. package/source/smart.qrcode.js +1 -1
  190. package/source/smart.radiobutton.js +1 -1
  191. package/source/smart.rating.js +1 -1
  192. package/source/smart.ribbon.js +1 -1
  193. package/source/smart.router.js +1 -1
  194. package/source/smart.scheduler.js +1 -1
  195. package/source/smart.scrollbar.js +1 -1
  196. package/source/smart.slider.js +1 -1
  197. package/source/smart.sortable.js +1 -1
  198. package/source/smart.sparkline.js +1 -1
  199. package/source/smart.splitter.js +1 -1
  200. package/source/smart.switchbutton.js +1 -1
  201. package/source/smart.table.js +1 -1
  202. package/source/smart.tabs.js +1 -1
  203. package/source/smart.tank.js +1 -1
  204. package/source/smart.textarea.js +1 -1
  205. package/source/smart.textbox.js +1 -1
  206. package/source/smart.tickintervalhandler.js +1 -1
  207. package/source/smart.timeinput.js +1 -1
  208. package/source/smart.timeline.js +1 -1
  209. package/source/smart.timepicker.js +1 -1
  210. package/source/smart.toast.js +1 -1
  211. package/source/smart.tooltip.js +1 -1
  212. package/source/smart.tree.js +1 -1
  213. package/source/smart.validationpanel.js +1 -1
  214. package/source/smart.validator.js +1 -1
  215. package/source/smart.window.js +1 -1
  216. package/source/typescript/smart.editor.d.ts +15 -0
  217. package/source/typescript/smart.elements.d.ts +15 -0
@@ -1,5 +1,5 @@
1
1
 
2
- /* Smart UI v23.1.1 (2025-05-29)
2
+ /* Smart UI v23.1.19 (2025-06-17)
3
3
  Copyright (c) 2011-2024 jQWidgets.
4
4
  License: https://htmlelements.com/license/ */ //
5
5
 
@@ -824,7 +824,7 @@ Smart("smart-color-input",class extends Smart.Input{static get properties(){retu
824
824
  /***/ 7855:
825
825
  /***/ (() => {
826
826
 
827
- Smart("smart-editor",class extends Smart.ContentElement{static get properties(){return{ai:{type:"any",reflectToAttribute:!1,value:{model:{value:"gpt-3.5-turbo",type:"string"},limit:{value:10,type:"number"},maxTokens:{value:250,type:"number"},temperature:{value:.7,type:"number"},url:{value:"",type:"string"},key:{value:"",type:"string"}}},autoLoad:{value:!1,type:"boolean"},autoSave:{value:!1,type:"boolean"},enablePages:{value:!1,type:"boolean"},pageIndex:{value:0,type:"number"},pages:{value:[],type:"array"},autoSaveInterval:{value:1e3,type:"number"},autoExpand:{value:!1,type:"boolean"},charCountFormatFunction:{value:null,type:"function?"},contentFiltering:{value:{attributes:{value:[],type:"array"},attributeFilterMode:{allowedValues:["blackList","whiteList"],value:"blackList",type:"string"},tags:{value:[],type:"array"},tagFilterMode:{allowedValues:["blackList","whiteList"],value:"blackList",type:"string"},styleAttributes:{value:[],type:"array"},styleAttributeFilterMode:{allowedValues:["blackList","whiteList"],value:"blackList",type:"string"}},type:"object"},contextMenu:{allowedValues:["default","browser","none"],value:"default",type:"string"},contextMenuDataSource:{value:null,type:"any",reflectToAttribute:!1},dataExport:{value:{style:{value:null,type:"object"},fileName:{value:"smartEditor",type:"string?"},pageOrientation:{value:"portrait",type:"string"}},type:"object"},disableEditing:{value:!1,type:"boolean"},disableSearchBar:{value:!1,type:"boolean"},editMode:{allowedValues:["html","blockHtml","markdown"],value:"html",defaultReflectToAttribute:!0,type:"string"},sortable:{value:!1,type:"boolean"},addBlock:{defaultReflectToAttribute:!0,value:!1,type:"boolean"},enableHtmlEncode:{value:!1,type:"boolean"},enableTabKey:{value:!1,type:"boolean"},findAndReplaceTimeout:{value:50,type:"number"},hideToolbar:{value:!1,type:"boolean"},hideInlineToolbar:{value:!1,type:"boolean"},imageFormat:{allowedValues:["blob","base64"],value:"base64",type:"string"},imageName:{value:"userfile[]",type:"string"},innerHTML:{type:"string",validator:"_sanitize",reflectToAttribute:!1},inlineToolbarOffset:{value:[0,-5],type:"array"},iframeSettings:{value:{attributes:{value:null,type:"object?"},enabled:{value:!1,type:"boolean"},copyStyles:{value:!0,type:"boolean"},resources:{value:null,type:"object?"}},type:"object"},maxCharCount:{value:null,type:"number?"},messages:{extend:!0,value:{en:{invalidValue:"{{elementType}}: Invalid {{property}} value. {{property}} should be of type {{typeOne}} or {{typeTwo}}.",incorrectArgument:"{{elementType}}: Incorrect argument {{argumentName}} in method {{methodName}}.",permissionsRequired:"{{elementType}}: Permissions are required for the following action {{actionName}}.",timeout:"{{elementType}}: The import request has timed out.",importError:"{{elementType}}: The import request errored with the following status: {{status}}.",exportError:"{{elementType}}: The Export request errored with the following status: {{status}}.",ok:"Ok",cancel:"Cancel",alignLeft:"Align Left",alignCenter:"Align Center",alignRight:"Align Right",alignJustify:"Align Justify",segoeUi:"Segoe UI",arial:"Arial",georgia:"Georgia",impact:"Impact",tahoma:"Tahoma",timesNewRoman:"Times New Roman",verdana:"Verdana",p:"Paragraph",pre:"Code",code:"Code",blockquote:"Quotation",h1:"Heading 1",h2:"Heading 2",h3:"Heading 3",h4:"Heading 4",h5:"Heading 5",h6:"Heading 6",bold:"Bold",italic:"Italic",underline:"Underline",strikethrough:"Strikethrough",orderedlist:"Ordered List",unorderedlist:"Unordered List",checklist:"Check List",subscript:"Subscript",superscript:"Superscript",alignment:"Alignments",fontname:"Font Name",fontsize:"Font Size",formats:"Formats",backgroundcolor:"Background Color",fontcolor:"Font Color",redo:"Redo",undo:"Undo",indent:"Indent",outdent:"Outdent",createlink:"Hyperlink",insertlink:"Insert a hyperlink",hyperlink:"Hyperlink",editlink:"Hyperlink",removelink:"Remove link",openlink:"Open link",image:"Image",video:"Video",table:"Table",lowercase:"Lower Case",uppercase:"Upper Case",print:" Print",cut:" Cut",copy:" Copy",paste:" Paste",clearformat:"Clear Format",fullscreen:"Full Screen",restore:"Restore Screen",sourcecode:"Source Code",preview:"Preview",splitmode:"Split Editor",address:"Web Address",text:"Display Text",addressPlaceholder:"https://example.com",textPlaceholder:"Enter Text",targetPlaceholder:"Select Target",titlePlaceholder:"Enter a Title",urlPlaceholder:"http://example.com/image.png",fileUrlPlaceholder:"http://example.com/file.pdf",srcPlaceholder:"https://www.youtube.com/embed/video_link",thumbnail:"Or provide a URL as a video thumbnail",thumbnailPlaceholder:"https://www.link-to-thumbnail.jpg",videoUrl:"Video URL",videoUrlPlaceholder:"https://www.youtube.com/video_link",captionPlaceholder:"Caption",altPlaceholder:"Alternative Text",widthPlaceholder:"auto",heightPlaceholder:"auto",target:"Open Link in",linkBlankDescr:"New Window",linkSelfDescr:"Same Window",linkParentDescr:"Parent Frame",linkTopDescr:"Full Body of the Window",linkCustomDescr:"Custom Frame Name",title:"Title",fileUrl:"Or provide the URL to a file",url:"Or provide the URL to an image",src:"Or provide the URL to an embed video",width:"Width",height:"Height",alt:"Alternative Text",caption:"Caption",display:"Display",displayPlaceholder:"Display",displayBlock:"Block",displayInline:"Inline",draggable:"Enable Dragging",resizable:"Enable Resizing",browse:"Browse",connectionError:"{{elementType}}: File Upload requires connection to the server.",wrongItemIndex:"{{elementType}}: There is no file with such an index in the list of uploaded files.",tooLongFileName:"{{elementType}}: File name is too long.",totalFiles:"Total files: ",cancelFile:"Cancel File",dashedborders:"Dashed Borders",altrows:"Alternate Rows",insertRowBefore:"Insert Row Before",insertRowAfter:"Insert Row After",deleteRow:"Delete Row",insertColumnLeft:"Insert Column Left",insertColumnRight:"Insert Column Right",deleteColumn:"Delete Column",alignTop:"Align Top",alignMiddle:"Align Middle",alignBottom:"Align Bottom",delete:"Delete",tablerows:"Table Rows",tablecolumns:"Table Columns",tablevalign:"Table Cell Vertical Align",tablestyle:"Table Style",tableheader:"Table Header",buttonLabel:"Custom Table",pasteLabel:"Choose the paste format action:",cols:"Columns",rows:"Rows",alphabet:"abcdefghijklmnopqrstuvwxyz",header:"Header",column:"Column",plainText:"Plain Text",keepFormat:"Keep Format",cleanFormat:"Clean Format",roleDescription:"Text Editor",iframeTitle:"Editor Content is Encloused in it's own DOM inside an iFrame",toolbarButtonAriaLabel:"Toolbar Toggle Button",primaryToolbarAriaLabel:"Primary Toolbar",secondaryToolbarAriaLabel:"Secondary Toolbar",inputAriaLabel:"Enter Text",homeTab:"Home",viewTab:"View",insertTab:"Insert",layoutTab:"Layout",undoGroup:"Undo",clipboardGroup:"Clipboard",fontGroup:"Font",paragraphGroup:"Paragraph",editingGroup:"Editing",tableGroup:"Tables",imageGroup:"Images",videoGroup:"Videos",linkGroup:"Links",viewsGroup:"Views",deleteGroup:"Delete",findandreplace:"Find and Replace",requiredMessage:"The content of the Editor cannot be empty",tableProperties:"Table Properties",imageProperties:"Image Properties",videoProperties:"Video Properties",linkProperties:"Link Properties",selectAll:"Select All",deleteTable:"Delete Table",deleteImage:"Delete Image",deleteVideo:"Delete Video",createLink:"Create Link",deleteLink:"Delete Link",copyImage:"Copy",cutImage:"Cut",copyVideo:"Copy",cutVideo:"Cut",find:"Find",findPlaceholder:"",replace:"Replace",replaceWith:"Replace With",replaceAll:"Replace All",replacePlaceholder:"",results:"Results",resultsPlaceholder:"No match",matchCase:"Match Case",searchPlaceholder:"Search...",newLinePlaceholder:"Write, press ' / ' for commands…",addButton:"Click to add below \nAlt+Click to add above",askQuestion:"Ask AI",file:"File",date:"Date",emoji:"Emoji",user:"User",bulletedList:"Bulleted list",numberedList:"Numbered list",toDoList:"To-do list",toggleList:"Toggle list",callout:"Callout",quote:"Quote",divider:"Divider",askQuestionToAI:"Ask a question to AI",insertAnImage:"Insert an image",insertAVideo:"Insert a video",insertAFile:"Insert a file",insertADate:"Insert a date",insertAnEmoji:"Insert an emoji",insertAUser:"Insert a user",justStartWritingWithPlainText:"Just start writing with plain text",bigSectionHeading:"Main Title",mediumSectionHeading:"Section Heading",smallSectionHeading:"Subsection Heading",verySmallSectionHeading:"Smaller Subsection",extraSmallSectionHeading:"Minor Heading",leastImportantHeading:"Least Important Heading",startABulletedList:"Start a bulleted list",startANumberedList:"Start a numbered list",startAToDoList:"Start a to-do list",togglesCanHideShowContent:"Toggles can hide/show content",makeWritingStandOut:"Make writing stand out",captureAQuote:"Capture a quote",insertATable:"Insert a table",breakUpYourWriting:"Break up your writing",noResults:"No Results",typeToFilter:"Type to filter...",editSelection:"Edit Selection",rewrite:"Rewrite",rewriteDescription:"Rewrite the selected text",continueWriting:"Continue writing",continueWritingDescription:"Extend the content further",fixSpellingGrammar:"Fix spelling & grammar",fixSpellingGrammarDescription:"Correct spelling and grammatical errors",summarize:"Summarize",summarizeDescription:"Generate a concise summary of the text",makeShorter:"Make shorter",makeShorterDescription:"Reduce the length of the text while maintaining meaning",makeLonger:"Make longer",makeLongerDescription:"Expand the text with more details",explain:"Explain",explainDescription:"Provide a clearer or more detailed explanation",changeTone:"Change Tone",concise:"Concise",conciseDescription:"Make the text more brief and to the point",professional:"Professional",professionalDescription:"Adjust the text to sound more formal and business-like",casual:"Casual",casualDescription:"Make the text sound more relaxed and friendly",funny:"Funny",funnyDescription:"Add humor or a lighthearted tone to the text",translate:"Translate",translateEnglish:"Translate to English",translateEnglishDescription:"Translate the text into English",translateSpanish:"Translate to Spanish",translateSpanishDescription:"Translate the text into Spanish",translatePortuguese:"Translate to Portuguese",translatePortugueseDescription:"Translate the text into Portuguese",translateItalian:"Translate to Italian",translateItalianDescription:"Translate the text into Italian",translateDutch:"Translate to Dutch",translateDutchDescription:"Translate the text into Dutch",translateChinese:"Translate to Chinese",translateChineseDescription:"Translate the text into Chinese",translateKorean:"Translate to Korean",translateKoreanDescription:"Translate the text into Korean",translateJapanese:"Translate to Japanese",translateJapaneseDescription:"Translate the text into Japanese",translateRussian:"Translate to Russian",translateRussianDescription:"Translate the text into Russian",processing:"Processing...",typePrompt:"Type your prompt here",keep:"Keep",insertBelow:"Insert below",page:"Link to a page",insertPage:"Organize ideas, tasks, and notes",task:"Task",insertTask:"Insert a task",twoColumns:"2 columns",threeColumns:"3 columns",fourColumns:"4 columns",twoColumnsDescription:"Create 2 of blocks",threeColumnsDescription:"Create 3 of blocks",fourColumnsDescription:"Create 4 of blocks",taskPlaceholder:"Enter Task Name"}}},name:{value:null,type:"string?"},pasteFormat:{allowedValues:["prompt","plainText","keepFormat","cleanFormat"],value:"keepFormat",type:"string"},postData:{value:null,type:"object"},placeholder:{value:"",type:"string"},removeStylesOnClearFormat:{value:!1,type:"boolean"},required:{value:!1,type:"boolean"},sanitized:{value:!1,type:"boolean"},showCharCount:{value:!1,type:"boolean"},compactImageDialog:{value:!1,type:"boolean"},splitModeRefreshTimeout:{value:100,type:"number"},toolbarItems:{value:["bold","italic","underline","|","formats","alignment","orderedList","unorderedList","|","hyperlink","image","video","|","sourceCode","undo","redo"],reflectToAttribute:!1,type:"array"},toolbarMode:{allowedValues:["menu","singleLineRibbon"],value:"menu",type:"string"},toolbarOnFocus:{value:!1,type:"boolean"},toolbarRibbonConfig:{value:[{name:"homeTab",groups:[{name:"undoGroup",items:["undo","redo"]},{name:"clipboardGroup",items:["cut","copy","paste"]},{name:"fontGroup",items:["fontName","fontSize","backgroundColor","fontColor","clearFormat","formats","bold","italic","underline","strikethrough","superscript","subscript"]},{name:"paragraphGroup",items:["orderedList","unorderedList","indent","outdent","alignment"]},{name:"editingGroup",items:["findAndReplace"]}]},{name:"insertTab",groups:[{name:"tableGroup",items:["table"]},{name:"imageGroup",items:["image"]},{name:"videoGroup",items:["video"]},{name:"linkGroup",items:["createLink","removeLink"]}]},{name:"viewTab",groups:[{name:"viewsGroup",items:["fullScreen","sourceCode","splitMode"]}]},{name:"layoutTab",hidden:!0,groups:[{name:"deleteGroup",items:["delete"]},{name:"tableGroup",items:["table","tableHeader","tableRows","tableColumns","tableVAlign","tableStyle",""]},{name:"imageGroup",items:["image","caption"]},{name:"videoGroup",items:["video","caption"]}]}],type:"array"},toolbarViewMode:{allowedValues:["toggle","multiRow","scroll"],value:"toggle",type:"string"},toolbarSticky:{value:!1,type:"boolean"},spellCheck:{value:!0,type:"boolean"},value:{value:"",type:"string",validator:"_sanitize",reflectToAttribute:!1},validateFile:{value:null,type:"function?",reflectToAttribute:!1},uploadUrl:{value:"",type:"string",reflectToAttribute:!1},removeUrl:{value:"",type:"string",reflectToAttribute:!1},onImageRemove:{value:null,type:"function?"},autoUpload:{value:!0,type:"boolean"},users:{value:[],type:"array",reflectToAttribute:!1},windowCustomizationFunction:{value:null,reflectToAttribute:!1,type:"function?"}}}static get listeners(){return{"document.down":"_documentDownHandler","document.move":"_documentMoveHandler","document.up":"_documentUpHandler","document.dragstart":"_dragStartHandler","document.selectstart":"_selectStartHandler","document.selectionchange":"_selectionChangeHandler","container.dragend":"_dragEndHandler","container.drop":"_dropHandler","container.change":"_changeHandler","container.beforeinput":"_beforeInputHandler","container.input":"_afterInputHandler","contentContainer.contextmenu":"_contextMenuHandler","contentContainer.keydown":"_editableElementKeyDownHandler","contentContainer.keyup":"_updateOnInputChange","contentContainer.paste":"_updateOnInputChange","input.focus":"_editableElementFocusHandler","input.blur":"_editableElementBlurHandler","input.change":"_inputChangeEvent","editableElement.focus":"_editableElementFocusHandler","editableElement.blur":"_editableElementBlurHandler","editableElement.wheel":"_editableElementWheelHandler","editableElement.move":"_editableElementMoveHandler","editableElement.mouseEnter":"_editableElementMouseEnterHandler",touchmove:"_touchmoveHandler",resize:"_resizeHandler",mouseleave:"_mouseLeaveHandler"}}static get requires(){return{"Smart.Button":"smart.button.js","Smart.Window":"smart.window.js","Smart.Tooltip":"smart.tooltip.js"}}static get styleUrls(){return["smart.editor.css"]}template(){return'<div id="container" role="presentation">\n <div id="toolbar" class="smart-editor-toolbar" role="presentation">\n <div id="toolbarItemsPrimary" class="smart-editor-toolbar-items-primary" role="toolbar"></div>\n <div id="toolbarToggleButton" class="smart-editor-toolbar-toggle-button" role="button"></div>\n <div id="toolbarItemsSecondary" class="smart-editor-toolbar-items-secondary" role="toolbar"></div>\n </div>\n <div id="contentContainer" class="smart-editor-content-container" role="presentation">\n <div class="smart-editor-editable" contenteditable="true" id="editableElement" aria-placeholder="[[placeholder]]"\n inner-h-t-m-l="[[innerHTML]]" role="textbox" aria-multiline="true"><content></content></div>\n <textarea name="[[name]]" id="input" class="smart-hidden" placeholder="[[placeholder]]" aria-placeholder="[[placeholder]]"\n spellcheck="[[spellCheck]]" autocapitalize="none" autocomplete="off"></textarea>\n <div class="smart-hidden smart-editor-tabs" id="tabs">\n </div>\n </div>\n </div>'}_editableElementMouseEnterHandler(){this._setSortable()}propertyChangedHandler(e,t,a){const o=this;switch(e){case"contentFiltering":case"contentFiltering_attributes":case"contentFiltering_attributeFilterMode":case"contentFiltering_tags":case"contentFiltering_tagFilterMode":case"contentFiltering_styleAttributes":case"contentFiltering_styleAttributeFilterMode":o._handleContentFiltering();break;case"disabled":case"disableEditing":o.$.input.readonly=a,o.$.editableElement.setAttribute("contenteditable",!a),"disabled"===e&&o._setFocusable();break;case"disableSearchBar":o._closeSearchToolbar();break;case"enableHtmlEncode":{const e=o.$.input;e.classList.contains("smart-hidden")||(e.value=o._getInputValue());break}case"hideToolbar":a&&o._updateToolbarItems(void 0,o.$.toolbar);break;case"sortable":o._setSortable();break;case"users":o._refreshTasks();break;case"innerHTML":case"value":if(""===a)a="&nbsp;";else{const e=e=>{let t=e.replace(/\\"/g,'"');return t=t.replace(/\\+/g,""),t=t.replace(/&nbsp;/g," "),t=t.replace(/"\s*=/g,'="'),t};let t=(e=>{const t=document.createElement("textarea");return t.innerHTML=e,t.value})(a);t=e(t),a=t}if("blockHtml"===o.editMode){const e=o._createEditorBlock(!1,!1,a);o.innerHTML=o.value=a=e.outerHTML}o._handleInputContent(e,a),"blockHtml"===o.editMode?setTimeout((()=>{o._initEditorBlocks(),o._refreshEditorBlockPlaceholder(),o._editorBlocks=o.$.editableElement.querySelectorAll(".smart-editor-block"),o._setSortable(),o._renderPages(),o._refreshTasks()}),100):o._renderPages(),o.$.fireEvent("change",{oldValue:o._value||t,value:o._value=o._getCurrentValue()});break;case"editMode":o._handleEditMode(a);break;case"hideInlineToolbar":{const e=o.$.inlineToolbar;e&&e.visible&&e.classList.contains("smart-editor-inline-toolbar")&&e.close();break}case"toolbarViewMode":o._toggleToolbar("toggle"===a);break;case"pages":case"enablePages":o._renderPages();break;case"toolbarOnFocus":case"toolbarMode":case"toolbarRibbonConfig":o._handleToolbarMode();break;case"locale":delete o._toolbarItemsObj,delete o._inlineToolbarItemsObj,o._refreshToolbarItems(o._getToolbarItems()),o._closeToolbar(),o._closeWindow();break;case"iframeSettings":o._handleInputElement();break;case"maxCharCount":o._handleMaxCharCount(),o._setCharCount();break;case"name":a&&"markdown"!==o.editMode&&(o.$.input.value=o._getInputValue(o.$.editableElement.innerHTML.trim()));break;case"placeholder":o._handlePlaceholder();break;case"pasteFormat":o._closeWindow();break;case"readonly":o.$.input.readonly=a,o.$.editableElement.setAttribute("contenteditable","markdown"!==o.editMode&&!a),o._closePopups(),o._setResizeFrame(),o._closeWindow();break;case"showCharCount":o._setCharCount();break;case"rightToLeft":case"animation":case"theme":o._updateIframeBody();break;case"toolbarItems":o._handleToolbarItems();break;default:super.propertyChangedHandler(e,t,a)}}_mouseLeaveHandler(){const e=this;e.$.headerInsertLine&&(e.$.headerInsertLine.classList.remove("show"),e.$.headerSortable.classList.remove("show"))}addToolbarItem(e){const t=this;t.toolbarItems||(t.toolbarItems=[]),t.toolbarItems.push(e),t._handleToolbarItems()}insertToolbarItem(e,t){const a=this;a.toolbarItems||(a.toolbarItems=[]),a.toolbarItems.splice(t,0,e),a._handleToolbarItems()}removeToolbarItem(e){const t=this;t.toolbarItems||(t.toolbarItems=[]),t.toolbarItems.splice(e,1),t._handleToolbarItems()}_handleToolbarItems(){const e=this,t=e.$.toolbarItemsPrimary,a=e.$.toolbarItemsSecondary;if(t&&a&&(t.innerHTML=a.innerHTML="",delete e._toolbarItemsObj,delete e._inlineToolbarItemsObj,e._refreshToolbarItems(e._getToolbarItems()),"toggle"===e.toolbarViewMode)){const o=e.$.toolbarToggleButton;t.scrollHeight!==t.offsetHeight||a.children.length?o.classList.remove("smart-visibility-hidden"):o.classList.add("smart-visibility-hidden")}}_refreshSortableMenuItems(e){const t=e.querySelectorAll(".smart-editor-context-menu-item");t.forEach((e=>e.classList.remove("smart-hidden")));const a=document.createElement("div");a.classList.add("smart-editor-context-menu-item"),a.setAttribute("role","option"),a.innerHTML=this.localize("noResults"),a.classList.add("smart-hidden"),a.style.whiteSpace="nowrap",a.style.paddingLeft=a.style.paddingBottom=a.style.paddingTop="5px",a.style.paddingRight="7px",a.classList.add("empty-item");let o=!1;return t.forEach((e=>{e.classList.contains("empty-item")&&(o=!0)})),o||e.appendChild(a),[t,a]}_getSortableMenuItems(){const e=this,t=[{label:e.localize("askQuestion"),value:"ai",description:e.localize("askQuestionToAI")}],a=[{label:e.localize("image"),value:"image",description:e.localize("insertAnImage")},{label:e.localize("video"),value:"video",description:e.localize("insertAVideo")},{label:e.localize("file"),value:"file",description:e.localize("insertAFile")},{label:e.localize("date"),value:"date",description:e.localize("insertADate")},{label:e.localize("emoji"),value:"emoji",description:e.localize("insertAnEmoji")}];e.users&&e.users.length>0&&a.push({label:e.localize("user"),value:"user",description:e.localize("insertAUser")});const o=[{label:e.localize("text"),name:"text",value:"text",description:e.localize("justStartWritingWithPlainText")},{label:e.localize("h1"),name:"formats",value:"h1",description:e.localize("bigSectionHeading")},{label:e.localize("h2"),name:"formats",value:"h2",description:e.localize("mediumSectionHeading")},{label:e.localize("h3"),name:"formats",value:"h3",description:e.localize("smallSectionHeading")},{label:e.localize("h4"),name:"formats",value:"h4",description:e.localize("verySmallSectionHeading")},{label:e.localize("h5"),name:"formats",value:"h5",description:e.localize("extraSmallSectionHeading")},{label:e.localize("h6"),name:"formats",value:"h6",description:e.localize("leastImportantHeading")},{label:e.localize("bulletedList"),value:"unorderedlist",description:e.localize("startABulletedList")},{label:e.localize("numberedList"),value:"orderedlist",description:e.localize("startANumberedList")},{label:e.localize("toDoList"),value:"checklist",description:e.localize("startAToDoList")},{label:e.localize("toggleList"),value:"togglelist",description:e.localize("togglesCanHideShowContent")},{label:e.localize("callout"),value:"callout",description:e.localize("makeWritingStandOut")},{label:e.localize("quote"),name:"formats",value:"blockquote",description:e.localize("captureAQuote")},{label:e.localize("createLink"),name:"hyperlink",value:"hyperlink",description:e.localize("insertlink")},{label:e.localize("table"),value:"table",description:e.localize("insertATable")},{label:e.localize("divider"),value:"divider",description:e.localize("breakUpYourWriting")},{label:e.localize("task"),value:"task",description:e.localize("insertTask")}];if(e.enablePages){const t=[{label:e.localize("page"),value:"page",description:e.localize("insertPage")}];o.push(...t)}const i=[{label:e.localize("twoColumns"),value:"twoColumns",description:e.localize("twoColumnsDescription")}];return o.push(...i),e.ai.key&&o.push(...t),o.push(...a),o}_getAIMenuItems(){const e=this;return[{label:e.localize("editSelection","Edit Selection"),value:"category"},{label:e.localize("rewrite","Rewrite"),value:"rewrite",description:e.localize("rewriteDescription","Rewrite the selected text")},{label:e.localize("continueWriting","Continue writing"),value:"continue_writing",description:e.localize("continueWritingDescription","Extend the content further")},{label:e.localize("fixSpellingGrammar","Fix spelling & grammar"),value:"fix_spelling_grammar",description:e.localize("fixSpellingGrammarDescription","Correct spelling and grammatical errors")},{label:e.localize("summarize","Summarize"),value:"summarize",description:e.localize("summarizeDescription","Generate a concise summary of the text")},{label:e.localize("makeShorter","Make shorter"),value:"make_shorter",description:e.localize("makeShorterDescription","Reduce the length of the text while maintaining meaning")},{label:e.localize("makeLonger","Make longer"),value:"make_longer",description:e.localize("makeLongerDescription","Expand the text with more details")},{label:e.localize("explain","Explain"),value:"explain",description:e.localize("explainDescription","Provide a clearer or more detailed explanation")},{label:e.localize("changeTone","Change Tone"),value:"category"},{label:e.localize("concise","Concise"),value:"concise",description:e.localize("conciseDescription","Make the text more brief and to the point")},{label:e.localize("professional","Professional"),value:"professional",description:e.localize("professionalDescription","Adjust the text to sound more formal and business-like")},{label:e.localize("casual","Casual"),value:"casual",description:e.localize("casualDescription","Make the text sound more relaxed and friendly")},{label:e.localize("funny","Funny"),value:"funny",description:e.localize("funnyDescription","Add humor or a lighthearted tone to the text")},{label:e.localize("translate","Translate"),value:"category"},{label:e.localize("translateEnglish","Translate to English"),value:"translate_english",description:e.localize("translateEnglishDescription","Translate the text into English")},{label:e.localize("translateSpanish","Translate to Spanish"),value:"translate_spanish",description:e.localize("translateSpanishDescription","Translate the text into Spanish")},{label:e.localize("translatePortuguese","Translate to Portuguese"),value:"translate_portuguese",description:e.localize("translatePortugueseDescription","Translate the text into Portuguese")},{label:e.localize("translateItalian","Translate to Italian"),value:"translate_italian",description:e.localize("translateItalianDescription","Translate the text into Italian")},{label:e.localize("translateDutch","Translate to Dutch"),value:"translate_dutch",description:e.localize("translateDutchDescription","Translate the text into Dutch")},{label:e.localize("translateChinese","Translate to Chinese"),value:"translate_chinese",description:e.localize("translateChineseDescription","Translate the text into Chinese")},{label:e.localize("translateKorean","Translate to Korean"),value:"translate_korean",description:e.localize("translateKoreanDescription","Translate the text into Korean")},{label:e.localize("translateJapanese","Translate to Japanese"),value:"translate_japanese",description:e.localize("translateJapaneseDescription","Translate the text into Japanese")},{label:e.localize("translateRussian","Translate to Russian"),value:"translate_russian",description:e.localize("translateRussianDescription","Translate the text into Russian")}]}_createCallout(e,t){const a=this;a._callout&&a._callout.remove();const o=document.createElement("div");a._callout=o,o.classList.add("dropdown","smart-editor-callout"),o.innerHTML="\n <div class='categories' id='categories'></div>\n <div class='tabs' id='tabs'></div>\n ";const i=o,n=i.firstElementChild,r=i.lastElementChild;document.body.appendChild(o);const l={General:[{emoji:"💡",title:"Idea"},{emoji:"📌",title:"Pinned Note"},{emoji:"🔥",title:"On Fire"},{emoji:"⚡",title:"Lightning Fast"},{emoji:"💬",title:"Chat"},{emoji:"📅",title:"Calendar"},{emoji:"🔒",title:"Locked & Secure"},{emoji:"⭐",title:"Starred"},{emoji:"🎉",title:"Celebration"},{emoji:"📝",title:"Notes"},{emoji:"📂",title:"Folder"},{emoji:"🔔",title:"Notification"},{emoji:"🌟",title:"Shining Star"},{emoji:"🚀",title:"Rocket Boost"},{emoji:"📈",title:"Growth"},{emoji:"🎯",title:"Target Achieved"},{emoji:"💪",title:"Strength"},{emoji:"⏳",title:"Time Running"},{emoji:"🧠",title:"Brainstorm"},{emoji:"📚",title:"Learning"},{emoji:"🖋️",title:"Writing"},{emoji:"📋",title:"Clipboard"},{emoji:"🗓️",title:"Schedule"},{emoji:"🏆",title:"Trophy"},{emoji:"🎁",title:"Gift"},{emoji:"🎨",title:"Creativity"},{emoji:"⚖️",title:"Balance"},{emoji:"⏲️",title:"Timer"},{emoji:"🌍",title:"Global"},{emoji:"🔍",title:"Search"},{emoji:"🛠️",title:"Tools & Fixes"},{emoji:"📜",title:"Document"},{emoji:"🎵",title:"Music"},{emoji:"📎",title:"Attachment"},{emoji:"🖥️",title:"Computer Work"},{emoji:"📱",title:"Mobile"},{emoji:"💭",title:"Thinking"},{emoji:"✉️",title:"Email"},{emoji:"🔄",title:"Sync & Refresh"},{emoji:"🕒",title:"Time Management"},{emoji:"💰",title:"Finance"},{emoji:"📊",title:"Analytics"},{emoji:"🛒",title:"Shopping"},{emoji:"🔑",title:"Key Info"},{emoji:"⚙️",title:"Settings"},{emoji:"🎬",title:"Video Content"},{emoji:"🗃️",title:"Storage"},{emoji:"🏅",title:"Achievement"},{emoji:"📘",title:"Book"},{emoji:"📤",title:"Sent"},{emoji:"📥",title:"Received"},{emoji:"📍",title:"Location"},{emoji:"✏️",title:"Edit"},{emoji:"🖼️",title:"Image"},{emoji:"📻",title:"Podcast & Radio"},{emoji:"🛎️",title:"Reminder"},{emoji:"🔦",title:"Highlight"},{emoji:"🌈",title:"Inspiration"},{emoji:"🎙️",title:"Recording"},{emoji:"🖌️",title:"Design"}],Productivity:[{emoji:"🧠",title:"Brainstorming"},{emoji:"⏳",title:"Time Management"},{emoji:"🔑",title:"Key"},{emoji:"🗂️",title:"Organizer"},{emoji:"📈",title:"Analytics"},{emoji:"💼",title:"Business"},{emoji:"📋",title:"Checklist"},{emoji:"🖥️",title:"Computer"},{emoji:"📅",title:"Schedule"},{emoji:"📚",title:"Learning"},{emoji:"🚀",title:"Success"},{emoji:"💻",title:"Laptop"},{emoji:"📱",title:"Mobile"},{emoji:"⏰",title:"Alarm Clock"},{emoji:"📂",title:"Documents"},{emoji:"📝",title:"Writing"},{emoji:"✏️",title:"Edit"},{emoji:"🔔",title:"Reminder"},{emoji:"⚡",title:"Quick Action"},{emoji:"💪",title:"Effort"},{emoji:"🛠️",title:"Tools"},{emoji:"📊",title:"Statistics"},{emoji:"💡",title:"Creativity"},{emoji:"🎯",title:"Focus"},{emoji:"📎",title:"Attachment"},{emoji:"📤",title:"Outbox"},{emoji:"📥",title:"Inbox"},{emoji:"🔍",title:"Search"},{emoji:"🗝️",title:"Solution"},{emoji:"🏗️",title:"Building"},{emoji:"🏃‍♂️",title:"Hustle"},{emoji:"🏅",title:"Achievement"},{emoji:"🌍",title:"Global Work"},{emoji:"💰",title:"Finance"},{emoji:"📢",title:"Announcement"},{emoji:"🔄",title:"Refresh"},{emoji:"✅",title:"Completed Task"},{emoji:"📶",title:"Progress"},{emoji:"🖇️",title:"Connection"},{emoji:"📜",title:"Documentation"},{emoji:"🏆",title:"Success"},{emoji:"🚦",title:"Prioritization"},{emoji:"🎛️",title:"Control Panel"},{emoji:"💳",title:"Payment"},{emoji:"🛎️",title:"Service"},{emoji:"🌐",title:"Online Work"},{emoji:"📍",title:"Location"},{emoji:"🛒",title:"Shopping List"},{emoji:"📜",title:"Agreement"},{emoji:"⚙️",title:"Settings"},{emoji:"📑",title:"Bookmarks"},{emoji:"🛤️",title:"Roadmap"}],Motivation:[{emoji:"🎯",title:"Goal Setting"},{emoji:"💪",title:"Strength"},{emoji:"🚀",title:"Ambition"},{emoji:"🌟",title:"Shining Bright"},{emoji:"🏆",title:"Victory"},{emoji:"🔥",title:"Passion"},{emoji:"⚡",title:"Energy"},{emoji:"🏅",title:"Achievement"},{emoji:"🌱",title:"Growth"},{emoji:"💯",title:"Excellence"},{emoji:"🎉",title:"Celebration"},{emoji:"🎁",title:"Reward"},{emoji:"✨",title:"Inspiration"},{emoji:"💥",title:"Breakthrough"},{emoji:"💫",title:"Momentum"},{emoji:"🌠",title:"Dream Big"},{emoji:"🥇",title:"First Place"},{emoji:"🚀",title:"Sky's the Limit"},{emoji:"💨",title:"Speed"},{emoji:"💡",title:"Bright Ideas"},{emoji:"🏋️‍♂️",title:"Hard Work"},{emoji:"📈",title:"Progress"},{emoji:"🔝",title:"Top Performance"},{emoji:"👊",title:"Determination"},{emoji:"🕶️",title:"Confidence"},{emoji:"🤩",title:"Excitement"},{emoji:"🚧",title:"Overcoming Challenges"},{emoji:"💎",title:"Value"},{emoji:"🏁",title:"Finish Line"},{emoji:"🌞",title:"Positivity"},{emoji:"🔥",title:"Stay Motivated"},{emoji:"🎵",title:"Power Playlist"},{emoji:"🛤️",title:"Journey to Success"},{emoji:"🤝",title:"Support System"},{emoji:"📅",title:"Daily Wins"},{emoji:"🎙️",title:"Speak Up"},{emoji:"🧗‍♂️",title:"Keep Climbing"},{emoji:"🏃‍♂️",title:"Keep Moving"},{emoji:"📢",title:"Encouragement"},{emoji:"💰",title:"Financial Goals"},{emoji:"🎓",title:"Learning & Growth"},{emoji:"🛠️",title:"Building Success"},{emoji:"⚖️",title:"Balance & Focus"},{emoji:"🥂",title:"Milestone Celebration"},{emoji:"🗺️",title:"Vision & Strategy"},{emoji:"🛑",title:"No Excuses"},{emoji:"🚦",title:"Go Mode"},{emoji:"🚀",title:"Unstoppable"}],"Smile Faces":[{emoji:"😀",title:"Big Smile"},{emoji:"😃",title:"Happy Face"},{emoji:"😄",title:"Grinning"},{emoji:"😁",title:"Cheerful"},{emoji:"😆",title:"Laughing Hard"},{emoji:"😅",title:"Relieved Laugh"},{emoji:"😂",title:"Tears of Joy"},{emoji:"🤣",title:"ROFL"},{emoji:"😜",title:"Playful Wink"},{emoji:"😎",title:"Cool & Confident"},{emoji:"😍",title:"Heart Eyes"},{emoji:"😊",title:"Warm Smile"},{emoji:"😉",title:"Wink"},{emoji:"🥰",title:"Feeling Loved"},{emoji:"😚",title:"Kissy Face"},{emoji:"😙",title:"Smooch"},{emoji:"😋",title:"Yummy!"},{emoji:"😛",title:"Tongue Out"},{emoji:"😏",title:"Smirking"},{emoji:"😌",title:"Content & Relaxed"},{emoji:"😗",title:"Kissing Face"},{emoji:"🥳",title:"Party Mode"},{emoji:"🤩",title:"Star-Struck"},{emoji:"🤗",title:"Hugging You"},{emoji:"😇",title:"Angel Mode"},{emoji:"😻",title:"Loving Cat"},{emoji:"😺",title:"Happy Cat"},{emoji:"😽",title:"Cat Kiss"},{emoji:"🤭",title:"Oops, My Bad"},{emoji:"🫠",title:"Melting with Happiness"},{emoji:"🥹",title:"Touched & Emotional"},{emoji:"🫡",title:"Respect"},{emoji:"🤤",title:"Drooling"},{emoji:"😬",title:"Awkward Smile"},{emoji:"🤪",title:"Crazy Fun"},{emoji:"😵‍💫",title:"Dizzy & Confused"},{emoji:"😯",title:"Surprised & Speechless"},{emoji:"🤠",title:"Yeehaw Mood"},{emoji:"😆",title:"Giggle"},{emoji:"🫢",title:"Oops!"},{emoji:"🙃",title:"Upside Down Fun"},{emoji:"😜",title:"Goofy"},{emoji:"😹",title:"Cat LOL"},{emoji:"😈",title:"Mischievous Grin"},{emoji:"👻",title:"Silly Ghost"},{emoji:"🥴",title:"Woozy"},{emoji:"🫨",title:"Shaking with Excitement"},{emoji:"💃",title:"Dancing Queen"}],People:[{emoji:"👨‍💻",title:"Man Technologist"},{emoji:"👩‍💻",title:"Woman Technologist"},{emoji:"👨‍🎓",title:"Man Student"},{emoji:"👩‍🎓",title:"Woman Student"},{emoji:"👨‍🏫",title:"Man Teacher"},{emoji:"👩‍🏫",title:"Woman Teacher"},{emoji:"👨‍⚖️",title:"Man Judge"},{emoji:"👩‍⚖️",title:"Woman Judge"},{emoji:"👨‍🔬",title:"Man Scientist"},{emoji:"👩‍🔬",title:"Woman Scientist"},{emoji:"👨‍🎨",title:"Man Artist"},{emoji:"👩‍🎨",title:"Woman Artist"},{emoji:"👨‍🍳",title:"Man Chef"},{emoji:"👩‍🍳",title:"Woman Chef"},{emoji:"👨‍🚀",title:"Man Astronaut"},{emoji:"👩‍🚀",title:"Woman Astronaut"},{emoji:"🧑‍⚖️",title:"Person Judge"},{emoji:"🧑‍🔬",title:"Person Scientist"},{emoji:"🧑‍🎨",title:"Person Artist"},{emoji:"🧑‍🍳",title:"Person Chef"},{emoji:"🧑‍🚀",title:"Person Astronaut"},{emoji:"🧑‍⚖️",title:"Person Lawyer"},{emoji:"👶",title:"Baby"},{emoji:"👧",title:"Girl"},{emoji:"👦",title:"Boy"},{emoji:"👨",title:"Man"},{emoji:"👩",title:"Woman"},{emoji:"🧑",title:"Person"},{emoji:"🧓",title:"Older Person"},{emoji:"👵",title:"Grandmother"},{emoji:"👴",title:"Grandfather"},{emoji:"👮",title:"Police Officer"},{emoji:"👷",title:"Construction Worker"},{emoji:"💂",title:"Guard"},{emoji:"👩‍⚖️",title:"Female Judge"},{emoji:"👩‍🍳",title:"Female Chef"},{emoji:"👨‍⚖️",title:"Male Judge"},{emoji:"👨‍🍳",title:"Male Chef"},{emoji:"💃",title:"Dancer"},{emoji:"🕺",title:"Man Dancing"},{emoji:"🤦",title:"Facepalm"},{emoji:"🤷",title:"Shrug"},{emoji:"🙋",title:"Person Raising Hand"},{emoji:"🙋‍♂️",title:"Man Raising Hand"},{emoji:"🙋‍♀️",title:"Woman Raising Hand"},{emoji:"🙆",title:"Person Gesturing OK"},{emoji:"🙆‍♂️",title:"Man Gesturing OK"},{emoji:"🙆‍♀️",title:"Woman Gesturing OK"},{emoji:"💅",title:"Nail Polish"},{emoji:"🧑‍🦱",title:"Person with Curly Hair"},{emoji:"🧑‍🦳",title:"Person with White Hair"},{emoji:"🧑‍🦲",title:"Bald Person"}],"Food & Drink":[{emoji:"🍎",title:"Red Apple"},{emoji:"🍏",title:"Green Apple"},{emoji:"🍐",title:"Pear"},{emoji:"🍊",title:"Orange"},{emoji:"🍋",title:"Lemon"},{emoji:"🍌",title:"Banana"},{emoji:"🍉",title:"Watermelon"},{emoji:"🍇",title:"Grapes"},{emoji:"🍓",title:"Strawberry"},{emoji:"🫐",title:"Blueberry"},{emoji:"🍒",title:"Cherries"},{emoji:"🍑",title:"Peach"},{emoji:"🥭",title:"Mango"},{emoji:"🍍",title:"Pineapple"},{emoji:"🥥",title:"Coconut"},{emoji:"🥝",title:"Kiwi"},{emoji:"🍅",title:"Tomato"},{emoji:"🌶️",title:"Hot Pepper"},{emoji:"🥒",title:"Cucumber"},{emoji:"🥕",title:"Carrot"},{emoji:"🌽",title:"Corn"},{emoji:"🥔",title:"Potato"},{emoji:"🧅",title:"Onion"},{emoji:"🧄",title:"Garlic"},{emoji:"🥑",title:"Avocado"},{emoji:"🥦",title:"Broccoli"},{emoji:"🥬",title:"Lettuce"},{emoji:"🫛",title:"Peas"},{emoji:"🥜",title:"Peanuts"},{emoji:"🌰",title:"Chestnut"},{emoji:"🍞",title:"Bread"},{emoji:"🥖",title:"Baguette"},{emoji:"🥐",title:"Croissant"},{emoji:"🥯",title:"Bagel"},{emoji:"🧇",title:"Waffle"},{emoji:"🥞",title:"Pancakes"},{emoji:"🧀",title:"Cheese"},{emoji:"🍗",title:"Chicken Leg"},{emoji:"🥩",title:"Steak"},{emoji:"🍖",title:"Meat on Bone"},{emoji:"🌭",title:"Hot Dog"},{emoji:"🍔",title:"Burger"},{emoji:"🍕",title:"Pizza"},{emoji:"🥪",title:"Sandwich"},{emoji:"🌮",title:"Taco"},{emoji:"🌯",title:"Burrito"},{emoji:"🥗",title:"Salad"},{emoji:"🍣",title:"Sushi"},{emoji:"🍛",title:"Curry"},{emoji:"🍜",title:"Noodles"},{emoji:"🍲",title:"Soup"},{emoji:"🥘",title:"Paella"},{emoji:"🫕",title:"Fondue"},{emoji:"🍚",title:"Cooked Rice"},{emoji:"🍤",title:"Fried Shrimp"},{emoji:"🥮",title:"Moon Cake"},{emoji:"🍩",title:"Doughnut"},{emoji:"🍪",title:"Cookie"},{emoji:"🍰",title:"Cake"},{emoji:"🎂",title:"Birthday Cake"},{emoji:"🧁",title:"Cupcake"},{emoji:"🍫",title:"Chocolate"},{emoji:"🍬",title:"Candy"},{emoji:"🍭",title:"Lollipop"},{emoji:"🍮",title:"Custard"},{emoji:"🍯",title:"Honey"},{emoji:"🥛",title:"Milk"},{emoji:"🍼",title:"Baby Bottle"},{emoji:"☕",title:"Coffee"},{emoji:"🍵",title:"Tea"},{emoji:"🧃",title:"Juice"},{emoji:"🥤",title:"Soft Drink"},{emoji:"🍹",title:"Cocktail"},{emoji:"🍷",title:"Wine"},{emoji:"🍺",title:"Beer"},{emoji:"🍻",title:"Cheers"},{emoji:"🥂",title:"Champagne"},{emoji:"🥃",title:"Whiskey"}],Symbols:[{emoji:"✅",title:"Check Mark"},{emoji:"❌",title:"Cross Mark"},{emoji:"⚠️",title:"Warning"},{emoji:"ℹ️",title:"Information"},{emoji:"❓",title:"Question"},{emoji:"❗",title:"Exclamation"},{emoji:"🔄",title:"Refresh"},{emoji:"🔃",title:"Reload"},{emoji:"➕",title:"Plus"},{emoji:"➖",title:"Minus"},{emoji:"➗",title:"Division"},{emoji:"✖️",title:"Multiplication"},{emoji:"💲",title:"Dollar Sign"},{emoji:"💱",title:"Currency Exchange"},{emoji:"⚡",title:"Lightning"},{emoji:"🔒",title:"Lock"},{emoji:"🔓",title:"Unlock"},{emoji:"🔑",title:"Key"},{emoji:"🆕",title:"New"},{emoji:"🆙",title:"Up"},{emoji:"🆒",title:"Cool"},{emoji:"🆓",title:"Free"},{emoji:"🆖",title:"No Good"},{emoji:"🈺",title:"Open Business"},{emoji:"🈚",title:"Not Available"},{emoji:"⭕",title:"Circle"},{emoji:"💠",title:"Diamond"},{emoji:"🔷",title:"Blue Diamond"},{emoji:"🔶",title:"Orange Diamond"},{emoji:"🔴",title:"Red Circle"},{emoji:"🟢",title:"Green Circle"},{emoji:"🔵",title:"Blue Circle"},{emoji:"🟡",title:"Yellow Circle"},{emoji:"⚪",title:"White Circle"},{emoji:"⚫",title:"Black Circle"},{emoji:"⬆️",title:"Up Arrow"},{emoji:"⬇️",title:"Down Arrow"},{emoji:"⬅️",title:"Left Arrow"},{emoji:"➡️",title:"Right Arrow"},{emoji:"↔️",title:"Left-Right Arrow"},{emoji:"↕️",title:"Up-Down Arrow"},{emoji:"🔄",title:"Rotate"},{emoji:"♻️",title:"Recycle"},{emoji:"🏳️",title:"White Flag"},{emoji:"🏴",title:"Black Flag"},{emoji:"🏁",title:"Finish Line"},{emoji:"⚜️",title:"Fleur-de-lis"},{emoji:"♾️",title:"Infinity"}],Flags:[{emoji:"🇺🇸",title:"United States"},{emoji:"🇨🇦",title:"Canada"},{emoji:"🇬🇧",title:"United Kingdom"},{emoji:"🇦🇺",title:"Australia"},{emoji:"🇩🇪",title:"Germany"},{emoji:"🇫🇷",title:"France"},{emoji:"🇮🇹",title:"Italy"},{emoji:"🇪🇸",title:"Spain"},{emoji:"🇳🇱",title:"Netherlands"},{emoji:"🇧🇪",title:"Belgium"},{emoji:"🇨🇭",title:"Switzerland"},{emoji:"🇦🇹",title:"Austria"},{emoji:"🇸🇪",title:"Sweden"},{emoji:"🇳🇴",title:"Norway"},{emoji:"🇩🇰",title:"Denmark"},{emoji:"🇫🇮",title:"Finland"},{emoji:"🇮🇪",title:"Ireland"},{emoji:"🇵🇱",title:"Poland"},{emoji:"🇨🇿",title:"Czech Republic"},{emoji:"🇸🇰",title:"Slovakia"},{emoji:"🇭🇺",title:"Hungary"},{emoji:"🇷🇴",title:"Romania"},{emoji:"🇧🇬",title:"Bulgaria"},{emoji:"🇬🇷",title:"Greece"},{emoji:"🇵🇹",title:"Portugal"},{emoji:"🇷🇺",title:"Russia"},{emoji:"🇹🇷",title:"Turkey"},{emoji:"🇨🇳",title:"China"},{emoji:"🇯🇵",title:"Japan"},{emoji:"🇰🇷",title:"South Korea"},{emoji:"🇮🇳",title:"India"},{emoji:"🇧🇷",title:"Brazil"},{emoji:"🇲🇽",title:"Mexico"},{emoji:"🇦🇷",title:"Argentina"},{emoji:"🇨🇴",title:"Colombia"},{emoji:"🇨🇱",title:"Chile"},{emoji:"🇿🇦",title:"South Africa"},{emoji:"🇪🇬",title:"Egypt"},{emoji:"🇦🇪",title:"United Arab Emirates"},{emoji:"🇮🇱",title:"Israel"},{emoji:"🇸🇦",title:"Saudi Arabia"},{emoji:"🇮🇩",title:"Indonesia"},{emoji:"🇲🇾",title:"Malaysia"},{emoji:"🇵🇭",title:"Philippines"},{emoji:"🇹🇭",title:"Thailand"},{emoji:"🇻🇳",title:"Vietnam"},{emoji:"🇸🇬",title:"Singapore"},{emoji:"🇰🇪",title:"Kenya"},{emoji:"🇳🇬",title:"Nigeria"},{emoji:"🇵🇰",title:"Pakistan"},{emoji:"🇳🇿",title:"New Zealand"},{emoji:"🇺🇦",title:"Ukraine"}],Gestures:[{emoji:"👍",title:"Thumbs Up"},{emoji:"👎",title:"Thumbs Down"},{emoji:"👌",title:"OK Hand"},{emoji:"🤞",title:"Fingers Crossed"},{emoji:"✌️",title:"Victory Hand"},{emoji:"🤟",title:"Love-You Gesture"},{emoji:"🤙",title:"Call Me Hand"},{emoji:"👋",title:"Waving Hand"},{emoji:"🖐",title:"Raised Hand"},{emoji:"✋",title:"Stop Hand"},{emoji:"🤚",title:"Raised Backhand"},{emoji:"🤲",title:"Palms Up Together"},{emoji:"👐",title:"Open Hands"},{emoji:"🙌",title:"Raising Hands"},{emoji:"🙋",title:"Person Raising Hand"},{emoji:"🙋‍♂️",title:"Man Raising Hand"},{emoji:"🙋‍♀️",title:"Woman Raising Hand"},{emoji:"👈",title:"Backhand Index Pointing Left"},{emoji:"👉",title:"Backhand Index Pointing Right"},{emoji:"👆",title:"Backhand Index Pointing Up"},{emoji:"👇",title:"Backhand Index Pointing Down"},{emoji:"🤚",title:"Raised Backhand"},{emoji:"🖖",title:"Vulcan Salute"},{emoji:"🤜",title:"Right-Facing Fist"},{emoji:"🤛",title:"Left-Facing Fist"},{emoji:"🖐",title:"Five Fingers Raised"},{emoji:"🖖",title:"Vulcan Salute"},{emoji:"✋🏼",title:"Stop Hand Light Skin Tone"},{emoji:"✋🏽",title:"Stop Hand Medium Skin Tone"},{emoji:"✋🏾",title:"Stop Hand Medium-Dark Skin Tone"},{emoji:"✋🏿",title:"Stop Hand Dark Skin Tone"},{emoji:"👌🏼",title:"OK Hand Light Skin Tone"},{emoji:"👌🏽",title:"OK Hand Medium Skin Tone"},{emoji:"👌🏾",title:"OK Hand Medium-Dark Skin Tone"},{emoji:"👌🏿",title:"OK Hand Dark Skin Tone"},{emoji:"🤟🏼",title:"Love-You Gesture Light Skin Tone"},{emoji:"🤟🏽",title:"Love-You Gesture Medium Skin Tone"},{emoji:"🤟🏾",title:"Love-You Gesture Medium-Dark Skin Tone"},{emoji:"🤟🏿",title:"Love-You Gesture Dark Skin Tone"},{emoji:"✋🏻",title:"Stop Hand Light Skin Tone"},{emoji:"👋🏻",title:"Waving Hand Light Skin Tone"},{emoji:"👋🏼",title:"Waving Hand Medium-Light Skin Tone"},{emoji:"👋🏽",title:"Waving Hand Medium Skin Tone"},{emoji:"👋🏾",title:"Waving Hand Medium-Dark Skin Tone"},{emoji:"👋🏿",title:"Waving Hand Dark Skin Tone"},{emoji:"🖐🏻",title:"Raised Hand Light Skin Tone"},{emoji:"🖐🏼",title:"Raised Hand Medium-Light Skin Tone"},{emoji:"🖐🏽",title:"Raised Hand Medium Skin Tone"},{emoji:"🤲🏾",title:"Palms Up Together Medium-Dark Skin Tone"},{emoji:"🤲🏿",title:"Palms Up Together Dark Skin Tone"}]};let s="General";const d={General:"💡",Productivity:"✅",Motivation:"🎯","Smile Faces":"😀",People:"👨‍💻","Food & Drink":"🍎",Symbols:"✨",Flags:"🏳️",Gestures:"👍"};function c(e){s=e;const a=r.querySelector(".active");a&&a.classList.remove("active"),r.querySelector(`[title='${e}']`).classList.add("active"),function(e){n.innerHTML="",l[e].forEach((e=>{const a=document.createElement("div");a.classList.add("option"),a.innerHTML=`<span title="${e.title}" class='emoji'>${e.emoji}</span>`,a.addEventListener("click",(function(){o.setAttribute("value",e.emoji),i.style.display="none",t(e.emoji,e.title)})),n.appendChild(a)}))}(e)}const m=a.offset(e);i.style.left=m.left+"px",i.style.top=m.top-a.$.editableElement.scrollTop+e.offsetHeight+5+"px",i.style.display="block",setTimeout((()=>{a._adjustPopupBounds(i)}),100),r.innerHTML="",Object.keys(l).forEach((e=>{const t=document.createElement("div");t.classList.add("tab"),t.innerHTML=`${d[e]}`,t.setAttribute("title",e),t.addEventListener("click",(()=>c(e))),r.appendChild(t)})),c(s)}_createDatePopup(e,t){const a=this;a._datePopup&&a._datePopup.remove();const o=document.createElement("div");a._datePopup=o,o.classList.add("dropdown","smart-editor-date-popup"),o.innerHTML="\n ";const i=o;document.body.appendChild(o);const n=a.offset(e);i.style.left=n.left+"px",i.style.top=n.top-a.$.editableElement.scrollTop+e.offsetHeight+5+"px",i.style.display="block",setTimeout((()=>{a._adjustPopupBounds(i)}),100);const r=document.createElement("smart-calendar");r.onchange=e=>{t(e.detail.value)},i.appendChild(r)}_refreshPageLabels(){let e=[...this.querySelectorAll(".smart-editor-tab")];[...this.querySelectorAll(".smart-editor-page-label")].forEach((t=>{const a=t.getAttribute("data-id");if(a){const o=parseInt(a);e[o]&&(t.textContent=e[o].textContent.trim())}}))}_setEditorValue(e,t){const a=this;if(e){if(t.innerHTML=e,a.enablePages){const t=a.pages[a.pageIndex];t&&(t.innerHTML=e)}t.whenRendered((()=>{t._initEditorBlocks(),t._refreshEditorBlockPlaceholder(),t._editorBlocks=t.$.editableElement.querySelectorAll(".smart-editor-block"),t._setSortable(),t._currentBlock=t.querySelector(".smart-editor-block"),a._refreshTasks();const e=document.createRange(),o=window.getSelection();t.$.editableElement.lastChild&&(e.setStartAfter(t.$.editableElement.lastChild),e.collapse(!0),o.removeAllRanges(),o.addRange(e)),a._refreshPageLabels()}))}else t.whenRendered((()=>{t.value||t._createEditorBlock(!1,!1,"&nbsp;")}))}_createAIPopup(e,t,a){const o=this;o._aiPopup&&o._aiPopup.remove();const i=document.createElement("div");o._aiPopup=i,i.classList.add("dropdown","smart-editor-ai-popup"),i.innerHTML="\n ";const n=i;document.body.appendChild(i);const r=o.offset(e);n.style.left=r.left+"px",n.style.top=r.top-o.$.editableElement.scrollTop+e.offsetHeight+5+"px",n.style.display="block";let l=[{label:"Outline",value:"Generate an outline about"},{label:"Email",value:"Write an email about"},{label:"Meeting Agenda",value:"Create a meeting agenda for"},{label:"Blog Post",value:"Write a blog post about"},{label:"Social Media Post",value:"Write a social media post about"},{label:"Press Release",value:"Write a press release about"},{label:"Job Description",value:"Write a job description for"},{label:"Website Copy",value:"Write website copy for"}];t&&(l=[]);let s="";for(let e=0;e<l.length;e++)s+=`<button class="smart-editor-predefined-btn" data-click="${l[e].value}">${l[e].label}</button>`;n.innerHTML=` <div class="smart-editor-container">\n <span class="button-close"></span>\n <div class="smart-editor-input-container">\n <input type="text" id="userPrompt" class="smart-editor-input" placeholder="${o.localize("typePrompt")}" />\n <button class="smart-editor-submit-btn" onclick="getAIResponse()">Ask AI <span class="smart-editor-icon-arrow-up">↑</span></button>\n </div>\n\n <div id="aiResult" class="smart-editor-result-box">\n \x3c!-- AI response will appear here --\x3e\n </div>\n <div id="timeoutMessage" class="smart-editor-timeout-message"></div>\n\n <div class="smart-editor-header"><span class="smart-editor-ai-icon"></span>Draft</div>\n\n \x3c!-- Predefined list buttons --\x3e\n <div class="smart-editor-predefined-container">\n ${s}\n </div>\n\n \x3c!-- Modal Popup for AI response --\x3e\n <button id="keepButton" class="smart-editor-keep-btn" onclick="keepResponse()">${o.localize("keep")}</button>\n <button id="replaceButton" class="smart-editor-replace-btn secondary" onclick="keepResponse()">${o.localize("replace")}</button>\n </div>`;const d=n.querySelector("#userPrompt"),c=n.querySelector("#aiResult"),m=n.querySelector("#timeoutMessage"),u=n.querySelector(".smart-editor-submit-btn"),p=document.querySelector("#keepButton"),b=document.querySelector("#replaceButton"),h=n.querySelector(".smart-editor-header"),g=n.querySelector(".button-close"),f=(()=>{let e=window.getSelection();return e.rangeCount?e.getRangeAt(0).toString():""})();if(t){h.classList.add("smart-hidden"),d.parentElement.classList.add("smart-hidden"),d.value='"'+f+'"',p.textContent=o.localize("insertBelow");const e=[{label:o.localize("editSelection","Edit Selection"),value:"category"},{label:o.localize("rewrite","Rewrite"),value:"rewrite",description:o.localize("rewriteDescription","Rewrite the selected text")},{label:o.localize("continueWriting","Continue writing"),value:"continue_writing",description:o.localize("continueWritingDescription","Extend the content further")},{label:o.localize("fixSpellingGrammar","Fix spelling & grammar"),value:"fix_spelling_grammar",description:o.localize("fixSpellingGrammarDescription","Correct spelling and grammatical errors")},{label:o.localize("summarize","Summarize"),value:"summarize",description:o.localize("summarizeDescription","Generate a concise summary of the text")},{label:o.localize("makeShorter","Make shorter"),value:"make_shorter",description:o.localize("makeShorterDescription","Reduce the length of the text while maintaining meaning")},{label:o.localize("makeLonger","Make longer"),value:"make_longer",description:o.localize("makeLongerDescription","Expand the text with more details")},{label:o.localize("explain","Explain"),value:"explain",description:o.localize("explainDescription","Provide a clearer or more detailed explanation")},{label:o.localize("changeTone","Change Tone"),value:"category"},{label:o.localize("concise","Concise"),value:"concise",description:o.localize("conciseDescription","Make the text more brief and to the point")},{label:o.localize("professional","Professional"),value:"professional",description:o.localize("professionalDescription","Adjust the text to sound more formal and business-like")},{label:o.localize("casual","Casual"),value:"casual",description:o.localize("casualDescription","Make the text sound more relaxed and friendly")},{label:o.localize("funny","Funny"),value:"funny",description:o.localize("funnyDescription","Add humor or a lighthearted tone to the text")},{label:o.localize("translate","Translate"),value:"category"},{label:o.localize("translateEnglish","Translate to English"),value:"translate_english",description:o.localize("translateEnglishDescription","Translate the text into English")},{label:o.localize("translateSpanish","Translate to Spanish"),value:"translate_spanish",description:o.localize("translateSpanishDescription","Translate the text into Spanish")},{label:o.localize("translatePortuguese","Translate to Portuguese"),value:"translate_portuguese",description:o.localize("translatePortugueseDescription","Translate the text into Portuguese")},{label:o.localize("translateItalian","Translate to Italian"),value:"translate_italian",description:o.localize("translateItalianDescription","Translate the text into Italian")},{label:o.localize("translateDutch","Translate to Dutch"),value:"translate_dutch",description:o.localize("translateDutchDescription","Translate the text into Dutch")},{label:o.localize("translateChinese","Translate to Chinese"),value:"translate_chinese",description:o.localize("translateChineseDescription","Translate the text into Chinese")},{label:o.localize("translateKorean","Translate to Korean"),value:"translate_korean",description:o.localize("translateKoreanDescription","Translate the text into Korean")},{label:o.localize("translateJapanese","Translate to Japanese"),value:"translate_japanese",description:o.localize("translateJapaneseDescription","Translate the text into Japanese")},{label:o.localize("translateRussian","Translate to Russian"),value:"translate_russian",description:o.localize("translateRussianDescription","Translate the text into Russian")}].find((e=>e.value===t));e&&(d.value+=" - "+e.description)}else d.parentElement.style.marginTop="15px";p.classList.add("smart-hidden"),b.classList.add("smart-hidden"),p.id="",b.id="",u.id="",m.id="",c.id="",d.id="",d.onkeydown=e=>{"Enter"===e.key&&(u.disabled||u.click())},t||setTimeout((()=>{d.focus()}),50),n.querySelectorAll(".smart-editor-predefined-btn").forEach((e=>{e.onclick=()=>{var t;t=e.getAttribute("data-click"),d.value=t,m.innerHTML="",d.focus()}})),b.onclick=()=>{o._aiPopup.remove(),delete o._aiPopup,a(c.innerHTML,!0)},g.onclick=()=>{o._aiPopup.remove(),delete o._aiPopup},p.onclick=()=>{o._aiPopup.remove(),delete o._aiPopup,a(c.innerHTML)},u.onclick=()=>{if(""===d.value.trim())return;c.innerHTML="",m.innerHTML="",u.disabled=!0,c.innerHTML='<div class="smart-editor-loading"><div class="smart-editor-spinner"></div>'+o.localize("processing")+"</div>";const e=setTimeout((()=>{c.innerHTML="",m.innerHTML="Sorry, the request timed out. Please try again.",u.disabled=!1}),1e4);(()=>{const a=o.ai.url,i=o.ai.key;let n=""+d.value;n?async function(e){if(e+=t?", respond in formatted HTML.":". Return the result as formatted HTML.",o._limit||(o._limit=0),o._limit++,o._limit>o.ai.limit)return"Sorry, the limit for AI prompts has been reached.";const n=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({model:o.ai.model,messages:[{role:"user",content:e}],max_tokens:o.ai.maxTokens,temperature:o.ai.temperature})});if(!n.ok)throw new Error(`Error: ${n.statusText}`);return(await n.json()).choices[0].message.content.trim()}(n).then((a=>{clearTimeout(e),a=a.replace(/^"|"$/g,""),c.innerHTML=a,m.innerHTML="",u.disabled=!1,p.classList.remove("smart-hidden"),t&&b.classList.remove("smart-hidden")})).catch((t=>{clearTimeout(e),console.error("Error:",t),c.innerHTML="",m.innerHTML="Sorry, the request timed out. Please try again.",p.classList.add("smart-hidden"),b.classList.add("smart-hidden"),u.disabled=!1})):(c.innerHTML="",m.innerHTML="",u.disabled=!1,p.classList.add("smart-hidden"),b.classList.add("smart-hidden"))})()},setTimeout((()=>{o._adjustPopupBounds(n)}),100),t&&u.click()}_refreshTasks(){const e=this,t=e.$.editableElement.querySelectorAll(".smart-editor-task-box");t.forEach((t=>{e._renderTask(t)})),0===t.length&&e.$.editableElement.querySelectorAll("[data-task]").forEach((t=>{if(!t.classList.contains("smart-editor-task-box")){const a=e.users&&e.users.length?'<span class="user-icon">🧑‍💼</span><span class="user-label">&nbsp;</span>':'<span hidden class="user-icon">🧑‍💼</span><span hidden class="user-label">&nbsp;</span>',o=`\n <span title="Idea" class="task-icon">◻️</span><input placeholder="${e.localize("taskPlaceholder")}" value="${t.textContent.trim()}" class="label"></input><span hidden class="text">${t.textContent.trim()}</span><span class="due-date-icon">📅</span><span class="date-label">&nbsp;</span><span class="priority-icon">⚪</span>\n ${a}<span class="delete-icon"></span><span class="plus-icon"></span>`;t.innerHTML=o,t.classList.add("smart-editor-block"),t.setAttribute("data-block",""),t.classList.add("smart-editor-task-box")}e._renderTask(t)}))}_createTask(){const e=this;e._disableNewBlock||e.$.contentContainer.dispatchEvent(new KeyboardEvent("keydown",{key:"Enter"}));const t=e.users&&e.users.length?'<span class="user-icon">🧑‍💼</span><span class="user-label">&nbsp;</span>':'<span hidden class="user-icon">🧑‍💼</span><span hidden class="user-label">&nbsp;</span>',a=`<div data-task class="smart-editor-task-box task" contenteditable="false">\n<span title="Idea" class="task-icon">◻️</span><input placeholder="${e.localize("taskPlaceholder")}" class="label"></input><span hidden class="text"></span><span class="due-date-icon">📅</span><span class="date-label">&nbsp;</span><span class="priority-icon">⚪</span>\n${t}<span class="delete-icon"></span><span class="plus-icon"></span></div><div empty class="smart-editor-block">&nbsp;</div>`,o=e._currentBlock;if(o)return o.innerHTML=a,o.removeAttribute("empty"),o.removeAttribute("data-placeholder"),e._renderTask(o),delete e._filterSortableMenuInput,delete e._currentBlock,e._closeContextMenu(),o}_renderTask(e){const t=this,a=e.querySelector("input"),o=e.querySelector(".text");o.onpointerdown=()=>{a.hidden=!1,a.value=o.textContent,o.hidden=!0,setTimeout((()=>{a.focus()}),25)};const i=()=>{!function(a){const i=document.createElement("style");i.textContent='\n .smart-text-editor-tooltip {\n position: absolute;\n background-color: rgba(50, 50, 50, 0.9);\n color: #fff;\n font-size: 12px;\n text-align: left;\n padding: 4px 8px;\n border-radius: 4px;\n opacity: 0;\n transition: opacity 0.1s ease-in-out;\n white-space: nowrap;\n pointer-events: none;\n box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);\n max-width: 300px;\n z-index:999999;\n overflow: hidden;\n }\n .smart-text-editor-tooltip::after {\n content: "";\n position: absolute;\n bottom: -6px;\n left: 50%;\n transform: translateX(-50%);\n border-width: 6px;\n border-style: solid;\n border-color: rgba(50, 50, 50, 0.9) transparent transparent transparent;\n }\n ',document.head.appendChild(i);let n=null;t._taskTooltip?n=t._taskTooltip:(n=document.createElement("div"),t._taskTooltip=n,n.className="smart-text-editor-tooltip",document.body.appendChild(n)),a.onmouseenter=function(a){const i=e.querySelector(".due-date-icon"),r=e.querySelector(".task-icon"),l=e.querySelector(".user-icon"),s=e.querySelector(".priority-icon");let d="";const c=e=>{if(e&&e.hasAttribute("data-title")){const a=e.getAttribute("data-title");if(a===t.localize("taskPlaceholder"))return;d+="<div>"+a+"</div>"}};if(c(o),c(r),c(s),c(i),c(l),d){n.innerHTML=d,n.style.left=`${a.pageX+8}px`;const o=t.$.editableElement.scrollTop;n.style.top=t.offset(e).top-o+e.offsetHeight+8+"px",n.style.opacity=1}},a.onmouseleave=function(){n.style.opacity=0}}(e)},n=e=>{const a=e.target.parentElement.querySelector("input");if(a.hidden=!1,a.focus(),a.value=o.textContent,a.parentElement.nextElementSibling){const e=a.parentElement.nextElementSibling;e&&e.classList.contains("smart-editor-block")&&e.remove(),a.value||(a.value=t.localize("taskPlaceholder"))}t._currentBlock=t._createEditorBlock(e.altKey,!1),t._disableNewBlock=!0;const i=t._createTask();delete t._disableNewBlock;const n=a.closest(".smart-editor-block");if(n&&n.nextElementSibling&&n.nextElementSibling.querySelector(".smart-editor-task-box")){const e=i.querySelector(".smart-editor-block");e&&i.nextElementSibling&&e.remove()}t._editorBlocks=t.$.editableElement.querySelectorAll(".smart-editor-block"),a.hidden=!0,o.hidden=!1,e.stopPropagation(),e.preventDefault()};a.onblur=a.onchange=()=>{a.value&&(a.hidden=!0,o.hidden=!1),i()},a.onkeydown=e=>{"Enter"===e.key&&n(e),e.stopPropagation(),o.textContent=a.value,o.setAttribute("data-title","📄"+o.textContent)},a.oninput=e=>{e.stopPropagation(),o.textContent=a.value,o.setAttribute("data-title","📄"+o.textContent)},a.onkeyup=e=>{o.setAttribute("data-title","📄"+o.textContent),e.stopPropagation()};const r=(t,a,o,i,n)=>{const r=a.find((e=>""+e.value==""+i));if(t.textContent=r.icon,o?t.setAttribute("data-title",r.label):t.setAttribute("data-title",r.icon+" "+r.label),n){const t=e.querySelector("[data-task]");t&&(t.setAttribute(n,r.value),t.setAttribute(n+"-label",r.label))}},l=(e,a,o,n)=>{const l=e.target,s=t._openContextMenu(e,a,!0,o,l);s.callback=e=>(r(l,a,o,e,n),delete s.callback,!0),i(),e.stopPropagation(),e.preventDefault()};e.querySelector(".plus-icon").onpointerdown=e=>{n(e)},e.querySelector(".due-date-icon").onpointerdown=a=>{const o=a.target;t._createDatePopup(o,(a=>{const n=new Smart.Utilities.DateTime(a[0]);o.textContent="⏰",o.setAttribute("data-title","⏰ "+n.toString("MMMM dd, yyyy")),e.setAttribute("data-due",n.toString("yyyy-MM-dd")),t._setSelectionRange(o,1,1),t._datePopup.remove(),i()})),a.stopPropagation(),a.preventDefault()},e.querySelector(".task-icon").onpointerdown=e=>{l(e,[{label:"◻️ None",value:"none",icon:"◻️"},{label:"📝 To Do",value:"toDo",icon:"📝"},{label:"🔄 In Progress",value:"inProgress",icon:"🔄"},{label:"✅ Done",value:"done",icon:"✅"}],"smart-editor-task-menu","data-status")};const s=()=>[{label:"None",value:"none",image:"🧑",icon:"🧑"},...t.users].map((e=>({label:e.label||e.name,id:e.value||e.id,value:e.value||e.id,image:e.image,icon:"🧑‍💻"})));if(e.querySelector(".user-icon").onpointerdown=e=>{l(e,s(),"","data-user")},e.querySelector(".priority-icon").onpointerdown=e=>{l(e,[{label:"⚪ No Priority",value:"noPriority",icon:"⚪"},{label:"🟢 Low Priority",value:"lowPriority",icon:"🟢"},{label:"🟡 Medium Priority",value:"mediumPriority",icon:"🟡"},{label:"🔴 High Priority",value:"highPriority",icon:"🔴"}],"smart-editor-task-menu","data-priority")},e.querySelector(".delete-icon").onpointerdown=e=>{const t=e.target.closest(".smart-editor-task-box");t&&t.remove()},t.users&&t.users.length?e.querySelector(".user-icon").hidden=!1:e.querySelector(".user-icon").hidden=!0,e.hasAttribute("data-status")){const t=e.getAttribute("data-status");[{label:"◻️ None",value:"none",icon:"◻️"},{label:"📝 To Do",value:"toDo",icon:"📝"},{label:"🔄 In Progress",value:"inProgress",icon:"🔄"},{label:"✅ Done",value:"done",icon:"✅"}].forEach((a=>{(a.value===t||a.label.indexOf(t)>=0)&&r(e.querySelector(".task-icon"),[{label:"◻️ None",value:"none",icon:"◻️"},{label:"📝 To Do",value:"toDo",icon:"📝"},{label:"🔄 In Progress",value:"inProgress",icon:"🔄"},{label:"✅ Done",value:"done",icon:"✅"}],"smart-editor-task-menu",a.value,"data-status")}))}if(e.hasAttribute("data-priority")){const t=e.getAttribute("data-priority");[{label:"⚪ No Priority",value:"noPriority",icon:"⚪"},{label:"🟢 Low Priority",value:"lowPriority",icon:"🟢"},{label:"🟡 Medium Priority",value:"mediumPriority",icon:"🟡"},{label:"🔴 High Priority",value:"highPriority",icon:"🔴"}].forEach((a=>{(a.value===t||a.label.indexOf(t)>=0)&&r(e.querySelector(".priority-icon"),[{label:"⚪ No Priority",value:"noPriority",icon:"⚪"},{label:"🟢 Low Priority",value:"lowPriority",icon:"🟢"},{label:"🟡 Medium Priority",value:"mediumPriority",icon:"🟡"},{label:"🔴 High Priority",value:"highPriority",icon:"🔴"}],"smart-editor-task-menu",a.value,"data-priority")}))}if(e.hasAttribute("data-user")){const t=e.getAttribute("data-user");s().forEach((a=>{(a.value===t||a.label.indexOf(t)>=0)&&r(e.querySelector(".user-icon"),s(),"smart-editor-task-menu",a.value,"data-priority")}))}if(e.hasAttribute("data-due-date")){const t=e.getAttribute("data-due-date"),a=new Smart.Utilities.DateTime(t),o=e.querySelector(".due-date-icon");o.textContent="⏰",o.setAttribute("data-title","⏰ "+a.toString("MMMM dd, yyyy")),e.setAttribute("data-due",a.toString("yyyy-MM-dd")),i()}i(),e.querySelector("input").focus()}_renderSortableMenu(e,t,a){const o=this,i=o._currentBlock;o._renderSortableMenuTimer&&clearTimeout(o._renderSortableMenuTimer),o._renderSortableMenuTimer=setTimeout((()=>{let n=document.createElement("input");n.isInline=a,n.style.borderWidth="0px",n.style.outline="none",n.style.width="auto",n.style.backgroundColor="var(--smart-surface)",n.style.color="var(--smart-background-color)",n.style.fontSize="inherit",n.style.fontFamily="inherit";const r=e=>{const t=document.createElement("span");t.textContent=e.value||e.placeholder||" ",t.style.minWidth="30px",t.classList.add("smart-element"),t.style.position="absolute",e._measureStyle||(e._measureStyle=getComputedStyle(e)),t.style.fontSize=e._measureStyle.fontSize,t.style.fontFamily=e._measureStyle.fontFamily,t.style.fontWeight=e._measureStyle.fontWeight,document.body.appendChild(t),e.style.width=t.offsetWidth+10+"px",t.remove()};if(t&&o._filterSortableMenuInput)n=o._filterSortableMenuInput;else{n.style.display="none",n.autoAdjustWidth=!0,n.placeholder=o.localize("typeToFilter"),n.style.setProperty("--smart-background","var(--smart-surface)"),n.style.setProperty("--smart-editor-label-padding","0px");const e=o.offset(i);if(a){n.value="/"+o.localize("typeToFilter");let e=window.getSelection();if(!e.rangeCount)return;let t=e.getRangeAt(0);t.deleteContents(),t.insertNode(n),t.setStartAfter(n),t.setEndAfter(n),e.removeAllRanges(),e.addRange(t)}else n.style.height="20px",n.style.position="absolute",n.style.top=e.top+"px",n.style.left=e.left+"px",document.body.appendChild(n);n.style.borderLeftWidth=n.style.borderRightWidth=n.style.borderTopWidth=n.style.borderBottomWidth="0px",o._filterSortableMenuInput=n,o._filterSortableMenuInput.block=i,setTimeout((()=>{n.focus(),a&&(n.selectionStart=n.selectionEnd=1)}),100)}n.style.maxHeight="30px",i?(n.style.height=n.style.lineHeight=i.offsetHeight+"px",n.style.display="",i.removeAttribute("empty"),i.removeAttribute("data-placeholder")):n.style.display="";const l=o._getSortableMenuItems(),s=o._openContextMenu(e,l,!0,"smart-editor-add-menu",n),[d,c]=o._refreshSortableMenuItems(s);r(n),n.oninput=()=>{r(n)},n.onkeyup=e=>{const t=e.key;if("ArrowUp"===e.key||"ArrowDown"===e.key||"Enter"===e.key||"Escape"===e.key)return;if("Enter"!==t&&"Escape"!==t||(e.stopPropagation(),e.preventDefault()),n.value==="/"+o.localize("typeToFilter"))return;const a=n.value.startsWith("/")?n.value.substring(1).toLowerCase():n.value.toLowerCase();let i=!1;c.classList.add("smart-hidden"),d.forEach((function(e){e.getAttribute("label").toLowerCase().includes(a)||""===a?(e.classList.remove("smart-hidden"),i=!0):e.classList.add("smart-hidden"),e.removeAttribute("selected"),s.style.height="auto"})),d[s.active].classList.contains("smart-hidden")&&(d[s.active].removeAttribute("selected"),s.active=0,d[s.active].setAttribute("selected",""));const r=Array.from(s.querySelectorAll(".smart-editor-context-menu-item:not(.smart-hidden)"));0!==r.length&&r[s.active]&&r[s.active].setAttribute("selected","");const l=o.offset(n);l.top-o.$.editableElement.scrollTop+n.offsetHeight+5+s.offsetHeight>window.innerHeight?s.style.top=l.top-o.$.editableElement.scrollTop-n.offsetHeight+5-s.offsetHeight+"px":s.style.top=l.top-o.$.editableElement.scrollTop+n.offsetHeight+5+"px",i||(c.classList.remove("smart-hidden"),void 0!==n.noResultChars?n.noResultChars++:n.noResultChars=0,n.noResultChars>=3&&(n.dispatchEvent(new KeyboardEvent("keydown",{key:"Enter"})),delete n.noResultChars))},n.setValue=(t,r)=>{if(r)switch(delete o._filterSortableMenuInput,r.name||(r.name=r.value),r.name){case"text":break;case"user":return o._currentBlock?o._closeContextMenu():o.$.contentContainer.dispatchEvent(new KeyboardEvent("keydown",{key:"Enter"})),o.$.contentContainer.dispatchEvent(new KeyboardEvent("keydown",{key:"@"})),void n.remove();case"formats":{!o._currentBlock||o._currentBlock&&""!==o._currentBlock.textContent.trim()?o.$.contentContainer.dispatchEvent(new KeyboardEvent("keydown",{key:"Enter"})):o._closeContextMenu();const e=o._createInsertionMarker();let t=o._getSelectionRange();const a=o._currentBlock;""===o._currentBlock.textContent.trim()&&(o._currentBlock.innerHTML=""),a.appendChild(e),a.removeAttribute("empty"),a.removeAttribute("data-placeholder"),o.selectRange(t);const i=o.$.editableElement.getRootNode().querySelector("#INSERTION_MARKER");if(!i)return;i.innerHTML="&nbsp;",i.removeAttribute("id"),o._setSelectionRange(i),t=o._getSelectionRange(),t.collapse();const l=document.createElement(r.value);return l.innerHTML="",l.setAttribute("data-placeholder",r.label),l.setAttribute("empty",""),l.classList.add("smart-editor-format-block"),l.setAttribute("contenteditable",""),i.parentElement.insertBefore(l,i),i.remove(),void n.remove()}case"divider":{o.$.contentContainer.dispatchEvent(new KeyboardEvent("keydown",{key:"Enter"}));const e=o._currentBlock;e.removeAttribute("empty"),e.removeAttribute("data-placeholder");const t=document.createElement("div");return t.classList.add("smart-editor-divider-block"),t.setAttribute("contenteditable",""),t.style.borderTopColor="var(--smart-border)",t.style.borderTopStyle="solid",t.style.borderTopWidth="1px",t.style.marginTop=t.style.marginBottom="10px",e.appendChild(t),o._setSelectionRange(t),o._getSelectionRange().collapse(),o.$.contentContainer.dispatchEvent(new KeyboardEvent("keydown",{key:"Enter"})),void n.remove()}case"twoColumns":case"threeColumns":case"fourColumns":{o.$.contentContainer.dispatchEvent(new KeyboardEvent("keydown",{key:"Enter"}));const e=o._currentBlock;e.removeAttribute("empty"),e.removeAttribute("data-placeholder"),e.classList.add("smart-editor-two-columns"),e.setAttribute("data-block-2","");const t=o._createEditorBlock(!1,!1),a=o._createEditorBlock(!1,!1);if(t.setAttribute("data-placeholder","Column 1"),a.setAttribute("data-placeholder","Column 2"),t.setAttribute("empty",""),a.setAttribute("empty",""),t.classList.add("smart-editor-n-columns-block"),a.classList.add("smart-editor-n-columns-block"),t.setAttribute("data-block-n",""),a.setAttribute("data-block-n",""),e.appendChild(t),e.appendChild(a),"threeColumns"===r.name){e.classList.add("smart-editor-three-columns");const t=o._createEditorBlock(!1,!1);t.setAttribute("data-placeholder","Column 3"),t.setAttribute("empty",""),t.classList.add("smart-editor-n-columns-block"),e.appendChild(t)}if("fourColumns"===r.name){e.classList.add("smart-editor-four-columns");const t=o._createEditorBlock(!1,!1);t.setAttribute("data-placeholder","Column 4"),t.setAttribute("empty",""),t.classList.add("smart-editor-n-columns-block"),e.appendChild(t)}const i=document.createElement("span");return i.innerHTML="&nbsp;",e.appendChild(i),o._setSelectionRange(t,0,0),void n.remove()}case"table":{!o._currentBlock||o._currentBlock&&""!==o._currentBlock.textContent.trim()?o.$.contentContainer.dispatchEvent(new KeyboardEvent("keydown",{key:"Enter"})):o._closeContextMenu();const e=o._createInsertionMarker();let t=o._getSelectionRange();const a=o._currentBlock;a.appendChild(e),a.removeAttribute("empty"),a.removeAttribute("data-placeholder"),o.selectRange(t);const i=o.$.editableElement.getRootNode().querySelector("#INSERTION_MARKER");i.innerHTML="&nbsp;",i.removeAttribute("id"),o._setSelectionRange(i),t=o._getSelectionRange(),t.collapse();const l=document.createElement(r.value);return l.innerHTML="<tr><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr>",l.setAttribute("data-placeholder",r.label),l.setAttribute("empty",""),l.classList.add("smart-editor-table-block"),l.setAttribute("contenteditable",""),i.parentElement.insertBefore(l,i),i.remove(),void n.remove()}case"togglelist":{const e=`<div class="editable-list expanded" contenteditable="true">\n<span class="toggle-icon"></span><label>${o.localize("toggleList")}</label>\n<div class="nested">\n <ul>\n <li>Child 1</li>\n <li>Child 2</li>\n </ul>\n</div>\n</div>`;o.$.contentContainer.dispatchEvent(new KeyboardEvent("keydown",{key:"Enter"}));const t=document.createRange(),a=window.getSelection(),i=o._currentBlock;i.innerHTML=e,i.removeAttribute("empty"),i.removeAttribute("data-placeholder"),t.setStart(i.querySelector(".toggle-icon").nextSibling,0),t.collapse(!0),a.removeAllRanges(),a.addRange(t),n.remove(),delete o._filterSortableMenuInput,delete o._currentBlock,o._closeContextMenu();const l=o.$.toolbar.querySelector('.smart-editor-toolbar-item[item-name="'+r.name+'"]');return void(l&&(o._handleToolbarItemDown(l),o._handleToolbarUp(l)))}case"checklist":case"unorderedlist":case"orderedlist":{o.preventInsertBlock=!0,o.$.contentContainer.dispatchEvent(new KeyboardEvent("keydown",{key:"Enter"}));const e=document.createRange(),t=window.getSelection(),a=o._currentBlock;a.innerHTML="&nbsp;",e.setStart(a,0),e.collapse(!0),t.removeAllRanges(),t.addRange(e),n.remove(),delete o._filterSortableMenuInput,delete o._currentBlock,o._closeContextMenu();const i=o.$.toolbar.querySelector('.smart-editor-toolbar-item[item-name="'+r.name+'"]');return i&&(o._handleToolbarItemDown(i),o._handleToolbarUp(i)),void delete o.preventInsertBlock}case"callout":{const e='<div class="smart-editor-callout-box callout" contenteditable="true">\n<span title="Idea" class="callout-icon">💡</span><span>&nbsp;</span>\n</div>';o.$.contentContainer.dispatchEvent(new KeyboardEvent("keydown",{key:"Enter"}));const t=document.createRange(),a=window.getSelection(),i=o._currentBlock;return i.innerHTML=e,n.remove(),i.removeAttribute("empty"),i.removeAttribute("data-placeholder"),t.setStart(i.querySelector(".callout-icon").nextSibling,0),t.collapse(!0),a.removeAllRanges(),a.addRange(t),delete o._filterSortableMenuInput,delete o._currentBlock,void o._closeContextMenu()}case"task":return n.remove(),void o._createTask();case"emoji":{const e=o._createInsertionMarker();let a=o._getSelectionRange();n.nextSibling?n.parentElement.insertBefore(e,n.nextSibling):n.parentElement.appendChild(e),o.selectRange(a);const i=o.$.editableElement.getRootNode().querySelector("#INSERTION_MARKER");i.innerHTML=t,i.removeAttribute("id"),o._setSelectionRange(i),a=o._getSelectionRange(),a.collapse();const r=document.createElement("span");return r.classList.add("callout"),r.innerHTML='<span title="Warm Smile" class="callout-icon">😊</span>&nbsp;',i.parentElement.insertBefore(r,i),i.remove(),o._createCallout(r.firstElementChild,((e,t)=>{r.firstElementChild.textContent=e,r.firstElementChild.title=t,o._setSelectionRange(r,1,1)})),delete o._filterSortableMenuInput,delete o._currentBlock,n.remove(),void o._closeContextMenu()}case"ai":{const e=o._createInsertionMarker();let a=o._getSelectionRange();n.nextSibling?n.parentElement.insertBefore(e,n.nextSibling):n.parentElement.appendChild(e),o.selectRange(a);const i=o.$.editableElement.getRootNode().querySelector("#INSERTION_MARKER");i.innerHTML=t,i.removeAttribute("id"),o._setSelectionRange(i),a=o._getSelectionRange(),a.collapse();const r=document.createElement("span");return r.classList.add("callout"),r.innerHTML='<span class="ai-label">&nbsp;</span>',i.parentElement.insertBefore(r,i),i.remove(),o._createAIPopup(r.firstElementChild,!1,(e=>{r.classList.add("smart-editor-block");let t=document.createElement("div");t.innerHTML=e;let a=[],i=!1,n="";t.querySelectorAll("[disabled]").forEach((e=>{e.removeAttribute("disabled")})),t.childNodes.forEach((e=>{if(3===e.nodeType){let t=e.textContent.trim();t&&a.push(`<div data-block-id="${Smart.Utilities.Core.createGUID()}" class="smart-editor-block">${t}</div>`)}else"UL"===e.tagName||"OL"===e.tagName?a.push(`<div data-block-id="${Smart.Utilities.Core.createGUID()}" class="smart-editor-block">${e.outerHTML}</div>`):"LI"===e.tagName?(i||(n='<div data-block-id="${Smart.Utilities.Core.createGUID()}" class="smart-editor-block"><ul>',i=!0),n+=`<li>${e.innerHTML}</li>`):e.tagName.match(/^H[1-6]$/)?a.push(`<div data-block-id="${Smart.Utilities.Core.createGUID()}" class="smart-editor-block">${e.outerHTML}</div>`):"P"===e.tagName?(e.textContent.split("\n").forEach((e=>{a.push(`<div data-block-id="${Smart.Utilities.Core.createGUID()}" class="smart-editor-block">${e}</div>`)})),e.remove()):("BLOCKQUOTE"===e.tagName||e.tagName,a.push(`<div data-block-id="${Smart.Utilities.Core.createGUID()}" class="smart-editor-block">${e.outerHTML}</div>`))})),i&&(n+=i?"</ul></div>":"</ol></div>",a.push(n));const l=window.getSelection();l&&l.anchorNode&&l.anchorNode.classList&&l.anchorNode.classList.contains("smart-editor-block")&&""===l.anchorNode.textContent&&l.anchorNode.remove(),o._createEditorBlock(!1,!1,a.join("")),o._editorBlocks=o.$.editableElement.querySelectorAll(".smart-editor-block"),o._setSelectionRange(r,1,1),o._aiPopup&&o._aiPopup.remove()})),delete o._filterSortableMenuInput,delete o._currentBlock,n.remove(),void o._closeContextMenu()}case"page":{const t=o._createInsertionMarker();return n.nextSibling?n.parentElement.insertBefore(t,n.nextSibling):n.parentElement.appendChild(t),setTimeout((()=>{const t=o._getCaretCoordinates(o.$.editableElement);e.pageX=t.x+15,e.pageY=t.y;let a=[...o.querySelectorAll(".smart-editor-tab")];o.owner&&(a=[...o.owner.querySelectorAll(".smart-editor-tab")]),a=a.map(((e,t)=>({label:e.textContent.trim(),value:"pageLink",id:t}))),o._openContextMenu(e,a,!0)}),50),delete o._filterSortableMenuInput,delete o._currentBlock,n.remove(),void o._closeContextMenu()}case"date":{const e=o._createInsertionMarker();let a=o._getSelectionRange();n.nextSibling?n.parentElement.insertBefore(e,n.nextSibling):n.parentElement.appendChild(e),o.selectRange(a);const i=o.$.editableElement.getRootNode().querySelector("#INSERTION_MARKER");i.innerHTML=t,i.removeAttribute("id"),o._setSelectionRange(i),a=o._getSelectionRange(),a.collapse();const r=document.createElement("span");return r.classList.add("callout"),r.innerHTML='<span class="date-icon">📅</span><span class="date-label">&nbsp;</span>',i.parentElement.insertBefore(r,i),i.remove(),o._createDatePopup(r.firstElementChild,(e=>{const t=new Smart.Utilities.DateTime(e[0]);r.lastElementChild.textContent=t.toString("MMMM dd, yyyy"),o._setSelectionRange(r,1,1),o._datePopup.remove()})),delete o._filterSortableMenuInput,delete o._currentBlock,n.remove(),void o._closeContextMenu()}case"image":case"file":case"video":{const e=document.createElement("div");return e.classList.add("smart-editor-toolbar-item"),e.setAttribute("item-name",r.name),e.setAttribute("item-type","button"),e.setAttribute("title",r.label),o._handleToolbarItemDown(e),o._handleToolbarUp(e),void n.remove()}case"hyperlink":{n.remove();const e=o.$.toolbar.querySelector('.smart-editor-toolbar-item[item-name="'+r.name+'"]');return void(e&&(o._handleToolbarItemDown(e),o._handleToolbarUp(e)))}default:{n.remove();const e=o.$.toolbar.querySelector('.smart-editor-toolbar-item[item-name="'+r.name+'"]');e&&(o._handleToolbarItemDown(e),o._handleToolbarUp(e));break}}if(a){const e=o._createInsertionMarker();let a=o._getSelectionRange();n.nextSibling?n.parentElement.insertBefore(e,n.nextSibling):n.parentElement.appendChild(e),o.selectRange(a);const i=o.$.editableElement.getRootNode().querySelector("#INSERTION_MARKER");i.innerHTML=t,i.removeAttribute("id"),o._setSelectionRange(i),a=o._getSelectionRange(),a.collapse();const r=document.createTextNode(t);i.parentElement.insertBefore(r,i),i.remove()}else i.innerHTML=t;i&&(i.removeAttribute("empty"),i.removeAttribute("data-placeholder"));const l=document.createRange(),s=window.getSelection();n.remove(),delete o._filterSortableMenuInput,delete o._currentBlock,a||(l.setStart(i.childNodes[0],t.length),l.collapse(!0),s.removeAllRanges(),s.addRange(l)),o._closeContextMenu()},n.onkeydown=e=>{let t=e.key;if(a&&n.value==="/"+o.localize("typeToFilter")&&(n.value="/"),"Backspace"===t&&(""!==n.value&&"/"!==n.value||(n.value="",t="Enter")),"Enter"===t||"Escape"===t){const t=s.querySelectorAll(".smart-editor-context-menu-item");let a="";for(let e=0;e<t.length;e++)if(t[e].hasAttribute("selected")&&!t[e].classList.contains("smart-hidden")){const o=t[e],i=o.getAttribute("value"),r=o.getAttribute("name"),l=o.getAttribute("label");"/"===n.value&&(n.value=""),a={name:r,label:l,value:i};break}let o=n.value;n.setValue(o,a),e.preventDefault(),e.stopPropagation()}"ArrowDown"===t&&(s.handleKeyDown(e),e.preventDefault(),e.stopPropagation()),"ArrowUp"===t&&(s.handleKeyDown(e),e.preventDefault(),e.stopPropagation()),e.stopPropagation()}}),0)}_getCurrentWord(e=0){const t=window.getSelection();if(!t||0===t.rangeCount)return"";let a=t.focusNode,o=t.focusOffset;if(a.nodeType!==Node.TEXT_NODE){if(!(a.childNodes.length>0))return"";if(a=a.childNodes[o]||a,a.nodeType!==Node.TEXT_NODE)return""}const i=a.textContent.slice(0,o+e).match(/(\w+)$/);return i?i[1]:""}_getCurrentTwoWords(){const e=window.getSelection();if(!e.rangeCount)return;const t=e.getRangeAt(0),a=t.startContainer,o=t.startOffset;return a.nodeType===Node.TEXT_NODE?a.textContent.slice(0,o).trim().split(/\s+/).slice(-2).join(" "):null}_setDictionary(){this._dictionary=window.Smart.WordsDictionary,this._collocations=["good morning","dear customer","good evening","good night","thank you","you are welcome","excuse me","I am sorry","take care","see you","good luck","best regards","best wishes","make sure","find out","let me","give me","take a","come back","go ahead","hold on","sit down","stand up","wake up","look at","listen to","pay attention","run away","turn off","turn on","high quality","low cost","big deal","fast food","strong coffee","hard work","easy way","long time","short term","real life","good idea","bad news","hot water","cold drink","heavy rain","annual report","business plan","market value","profit margin","stock market","cash flow","interest rate","sales team","customer service","supply chain","brand awareness","artificial intelligence","machine learning","data science","social media","search engine","user interface","web development","cyber security","cloud computing","software update","next week","last year","this time","right now","every day","few minutes","long time","next day","earlier today","yesterday evening","make money","take care","give advice","set goals","lose weight","save time","spend time","tell stories","break rules","follow orders","raise questions","face challenges","gain experience","keep in mind","get better","stay safe","find solutions","have fun","public transport","human rights","social responsibility","foreign policy","higher education","climate change","book an appointment","political issues","economic growth","health care","electric vehicle","medical treatment","project deadline","project management","task management","team collaboration","meeting agenda","time tracking","resource allocation","project scope","stakeholder engagement","action plan","progress report","deliverable timeline","workflow optimization","risk assessment","status update","goal setting","milestone tracking","budget planning","strategic planning","quality assurance","work breakdown","task delegation","process improvement","feedback loop","decision making","daily standup","sprint planning","agile methodology","Kanban board","task prioritization","performance evaluation","team alignment","work efficiency","meeting notes","timeline adjustment","task dependencies","scope creep","cross functional","on time delivery","client feedback","communication strategy","schedule adherence","action items","risk mitigation","workload balance","effort estimation","knowledge sharing","stakeholder communication","version control","resource planning","status report","collaboration tools","mark a date","Thank you very much","I appreciate your time","Let me know","Feel free to contact me","Looking forward to your response","Kind regards","Have a great day","Hope this helps","Please find attached","As soon as possible","At your earliest convenience","I would like to","We are pleased to","We are writing to","It would be great if","Just a quick reminder","Thanks for reaching out","Let’s touch base","We need to discuss","Keep me posted","I’ll get back to you","Circle back later","Put it on the agenda","Take it offline","Reach out to the team","On the same page","Move forward with this","Set up a call","Schedule a meeting","Run the numbers","Draft a proposal","Close the loop","Follow up on this","Touch base with you","Loop me in","Send over the details","set a reminder","schedule an appointment","check the calendar","save the date","plan an event","add to the calendar","book a slot","pick a date","set a deadline","choose a time","reserve a date","time slot availability","confirm the booking","sync calendars","change the date","share the calendar","view calendar","update the calendar","open the calendar","employee engagement","workplace culture","performance review","talent acquisition","employee retention","human capital","compensation package","benefit plan","training program","staff development","employee satisfaction","job satisfaction","leadership development","diversity inclusion","recruitment strategy","onboarding process","job description","career progression","team building","workplace diversity","employee recognition","conflict resolution","internal communication","staff turnover","organizational culture","hr policies","hr strategy","staff motivation","employee performance","talent management","workplace wellness","salary negotiation","employment law","team dynamics","job interview","workforce planning","brand strategy","market research","content marketing","social media","customer acquisition","customer retention","advertising campaign","digital marketing","email marketing","target audience","customer journey","sales funnel","marketing automation","lead generation","search engine optimization","pay per click","search engine marketing","influencer marketing","affiliate marketing","market segmentation","buyer persona","conversion rate","value proposition","content strategy","data analytics","brand awareness","product launch","marketing budget","public relations","creative strategy","customer feedback","product positioning","brand identity","website optimization","social engagement","event marketing","video marketing","marketing campaign","advertising strategy","ecommerce marketing","customer insights","digital advertising","content creation","media planning","marketing research","brand loyalty","viral marketing","online presence","marketing performance","customer experience","make a decision","take a break","do homework","catch a cold","have a look","give a speech","pay attention","keep a secret","break the law","set the table","do business","save time","spend money","lose weight","gain weight","make progress","run a business","meet a deadline","break a promise","keep a promise","make an effort","take a risk","make money","earn a living","reach a conclusion","raise awareness","offer assistance","take advantage","give up","take a shower","have a party","make friends","give an explanation","pay a visit","take notes","give an example","do research","make a mistake","take a chance","save energy","lose control","raise a question","catch a glimpse","make an appointment","have an effect","pay the price","take action","give advice","take responsibility","make a complaint","take care","pay a compliment","have a conversation","break the news","come to an agreement","make a call","take a decision","pay a bill","catch the bus","make a reservation","take a seat","give a hand","save money","lose interest","come to a conclusion","take a nap","have a meal","make a suggestion","pay attention to","take part","give permission","save face","lose patience","make an impression","come to a decision","take a photo","have a good time","make a difference","pay off","take place","give a gift","save the day","lose sight","make a noise","come prepared","take a walk","have a shower","make an offer","pay respects","give a try","save resources","lose track","make a plan","come to terms","take a look","have a headache","make a profit","pay attention to detail","take time off","give thanks","catch a break","make a wish","have a blast","do the dishes","make a bed","keep in touch","do exercise","have lunch","make a mess","give a kiss","take a breath","do the laundry","have dinner","make a choice","take a moment","give a hug","do the cleaning","have fun","give a chance","do the shopping","have breakfast","take a deep breath","give a call","do a favor","make a fortune","give a smile","do your best","make a scene","take a bow","do well","take charge","give notice","have an idea","make an entrance","give a warning","do damage","have a seat","take a trip","give a performance","make an announcement","give instructions","have a baby","take a deep dive","give a presentation","do the math","have a dream","take a sip","give a lecture","do the cooking","have a cry","make a promise","take a look around","give a shout","do a workout","have a chat","make a record","take a shortcut","do your hair","have a cup of tea","take a test","take the stage","do a favor for","have a word","make an impact","do a project","have a meeting","take a stand","give a discount","have a rest","make a move","give a reason","do a job","have a go","take a fall","make a fuss","take part in","do your makeup","make an impact on","take a selfie","do the ironing","have a heart-to-heart","make a phone call","take a chance on","have a quiet moment","make a commitment","take advantage of","give an opinion","have a laugh","make a joke","take advice","give credit","do your duty","have a goal","make a commitment to","take notes on","give a compliment","do the washing","have a snack","take an exam","give consent","have a try","take a minute","give feedback","do the gardening","have a heart","make a living","give a cry","have a look at","take a glance","give a thumbs up","do the paperwork","have a ride","make a remark","give a high five","take a class","do a study","have a holiday","take a detour","do your nails","have a bite","take an interest","give a ring","do the exercise","have a taste","have a word with","make arrangements","take a survey","give a round of applause","do a crossword","make a list","take a pill","make a donation","have a breakthrough","make amends","take a toll","do justice","have a sense","make a habit","give an answer","do the driving","have a question","make a statement","take measures","do your job","have an impact","give a message","do your best work","have a clear idea","make a big difference","take a risk with","give a warm welcome","have a tough time","make a toast","take a closer look","give an honest opinion","do a recap","have a conversation about","make a promise to","give a strong performance","do the heavy lifting","have a moment","make progress on","take pride in","do the right thing","have a clear mind","make an offer on","take it easy","give in","do a double take","take your time","give your best","make a mountain out of a molehill","take a step forward","give it a try","do the honors","make a decision on","give a standing ovation","do the talking","take a break from","give up hope","do your part","make a fool of oneself","have a quick look","make a decision about","take a long walk","give a clear answer","do your utmost","have a vivid imagination","make a significant impact","take a calculated risk","offer a warm welcome","lend a hand","experience difficulties","make a toast to","take a last look","give a quick glance","do a final review","have a spontaneous idea","make a remarkable discovery","take a sudden break","give a grateful nod","do a comprehensive analysis","make small talk","take a moment of silence","give a thoughtful gift","do a brief summary","have a brief conversation","make a clear decision","take a short break","do a creative project","have a creative mind","make a creative effort","take a creative approach","give a creative solution","do thorough research","have a thorough understanding","make a proper introduction","take a proper look","give a proper response","do a proper job","have a proper meal","make a careful observation","take a careful look","give careful consideration","do a careful analysis","have a careful discussion","make a wise decision","take a wise approach","give wise advice","make a wise move","have a pleasant day","make a friendly gesture","exchange friendly greetings","give a friendly smile","do a quick fix","have a quick meal","make a quick repair","take a quick shower","give a quick answer","do a rapid assessment","have a rapid response","make a rapid decision","take a swift action","give a swift reply","make a swift change","have a swift recovery","make a long-term commitment","take a long-term view","take a long drive","give a sudden shout","make a sudden change","have a sudden idea","take a sudden break","give a sudden smile","do a fun activity","take a quiet walk","give a quiet nod","give the silent treatment","have a silent moment","give a soft smile","have a soft spot","make a deep impression","give a deep sigh","do a deep clean","have a deep sleep","make a deep connection","take a deep dive into","give a deep insight","have a detailed discussion","make a detailed analysis","give full support","take full responsibility","offer a sincere apology","make a heartfelt apology","do a quick assessment","have a genuine smile","make a fresh start","take a bold step","give a warm embrace","do a regular checkup","have a successful career","make a wise investment","take a risk in","give a lasting impression","do a complete overhaul","have an open mind","make a smart choice","take an active role","give a solid performance","do a meticulous job","have a supportive network","make a bold move","take proactive measures","give a generous donation","do a careful study","have a meaningful conversation","make an informed decision","take a refreshing break","give a clear explanation","do a systematic review","have a productive day","make a strong argument","take decisive action","give constructive criticism","do extensive research","have a balanced view","make a thoughtful gesture","take effective measures","give sincere thanks","do a proper evaluation","have a clear objective","make a strategic decision","take a moment to reflect","give genuine feedback","do an honest review","have a heartfelt conversation","make a lasting impact","take the lead","give clear instructions","do an in-depth analysis","have a final word","make a notable achievement","take a firm stand","give immediate attention","do a practical demonstration","have a valuable insight","make a compelling argument","take serious action","give positive reinforcement","do an effective job","have a diverse perspective","make a creative decision","take constructive steps","give measurable results","do a quick turnaround","have a rapid recovery","make a notable contribution","take full advantage","give heartfelt support","do exceptional work","have an impressive record","make a positive impact","take a moment of reflection","give a powerful speech","do a significant task","have a successful event","make a grand entrance","take a memorable photo","give a remarkable performance","do a final check","have an engaging conversation","make a decisive move","take a confident step","give a sincere compliment","do an accurate measurement","have a thorough preparation","make a flawless presentation","take complete control","give a detailed report","do a precise calculation","have an enjoyable evening","make a smooth transition","take steady progress","give a clear perspective","do a thorough check","have a disciplined routine","make a powerful impression","take immediate action","give an insightful comment","do a creative design","have a proactive approach","make a flexible schedule","take careful steps","give a considerate response","do an innovative project","have a dynamic personality","make a logical argument","take a well-deserved break","give an enthusiastic cheer","do a friendly favor","have a cooperative spirit","make a fruitful collaboration","earn mutual respect","give respectful attention","do a rigorous test","have a profound impact","make a significant difference","take thoughtful action","give inspiring advice","do remarkable work","have a lasting legacy","make an extraordinary effort","take bold initiatives","give wholehearted support","do a groundbreaking study","have an innovative idea","make a historic achievement","take strategic risks","give transformative feedback","do pioneering work"]}_refreshToolbarPosition(){const e=this;if(e.toolbarOnFocus){e.setAttribute("popup",""),e.$.toolbar.setAttribute("popup","");const t=e.offset(e);e.$.toolbar.id=e.id+"_toolbar",document.querySelector("#"+e.$.toolbar.id)&&document.querySelector("#"+e.$.toolbar.id).remove(),document.body.appendChild(e.$.toolbar),e.$.toolbar.style.position="absolute",e.$.toolbar.style.top=t.top+1+e.offsetHeight+"px",e.$.toolbar.style.left=t.left+"px",e.$.toolbar.style.width=e.offsetWidth-5+"px",e.offsetWidth>=1e3&&(e.$.toolbar.style.width="auto"),e.$.toolbar.onchange=t=>{e._changeHandler(t)}}}_renderPages(){const e=this;if(e.enablePages){e.$.tabs.classList.remove("smart-hidden"),e.$.tabs.innerHTML='<div class="smart-editor-tabs-divider"></div>',e.pages[0]&&(e.$.editableElement.innerHTML=e.pages[0].innerHTML);const t=t=>{const a=e.$.tabs.querySelectorAll(".smart-editor-tab")[t],i=e.pages[t];a&&i&&(a.remove(),e.pages.splice(t,1)),o(t)},a=e=>Array.from(e.parentNode.querySelectorAll(".smart-editor-tab")).indexOf(e),o=t=>{const a=e.$.tabs.querySelectorAll(".smart-editor-tab")[t];if(a&&a.classList.contains("active"))return;const o=e.pages[e.pageIndex];o&&(o.innerHTML=e.getHTML()),e.pageIndex=t;let i=-1;e.toolbarOnFocus&&(e.$.tabs.querySelectorAll(".smart-editor-tab").forEach(((e,t)=>{e===a&&(i=t)})),0!==i?e.$.toolbar.classList.add("smart-hidden"):e.$.toolbar.classList.remove("smart-hidden")),e._closeInlinePopups(),e.$.tabs.querySelectorAll(".smart-editor-tab").forEach((e=>e.classList.remove("active"))),a.classList.add("active");const n=e.pages[t];if(n){const t=n.innerHTML;e.$.editableElement.innerHTML=t;const a=document.createRange(),o=window.getSelection();e.$.editableElement.lastChild&&(a.setStartAfter(e.$.editableElement.lastChild),a.collapse(!0),o.removeAllRanges(),o.addRange(a)),"blockHtml"===e.editMode&&(e._initEditorBlocks(),e._refreshEditorBlockPlaceholder(),e._editorBlocks=e.$.editableElement.querySelectorAll(".smart-editor-block"),1===e._editorBlocks.length&&(e._currentBlock=e.$.editableElement.querySelector(".smart-editor-block")))}},i=t=>{const o=e.$.tabs.querySelectorAll(".smart-editor-tab")[t],i=document.createElement("input");i.type="text",i.value=o.innerText,i.style.width=`${o.offsetWidth}px`;const n=document.createElement("span");function r(){n.innerText=i.value||"New Tab",i.style.width=`${n.offsetWidth+10}px`}n.style.position="absolute",n.style.visibility="hidden",n.style.whiteSpace="nowrap",n.style.top="-1000px",n.style.font=window.getComputedStyle(o).font,document.body.appendChild(n),i.oninput=r,i.onchange=function(){o.innerHTML=i.value||"New Tab";const t=a(o),r=e.pages[t];r&&(r.label=o.innerText),i.remove(),n.remove(),e._refreshPageLabels()},o.innerHTML="",o.appendChild(i),i.focus(),r()};if(e.$.tabs.selectTab=o,e.$.tabs.deleteTab=t,e.$.tabs.getTabIndex=a,e.$.tabs.editTab=i,0===e.pages.length){const t={label:"Page 1",innerHTML:e.getHTML()};e.pages.push(t)}let n=e.pages.map((e=>e.label));0===n.length&&n.push("Page 1"),n.forEach(((t,n)=>{const r=document.createElement("div");r.classList.add("smart-editor-tab"),r.innerText=t,0===n&&r.classList.add("active"),r.ondblclick=function(){const e=a(r);i(e)},r.onclick=function(e){const t=a(r);o(t),e.preventDefault()},e.$.tabs.appendChild(r)}));const r=document.createElement("button");e.$.plusBtn=r,e.$.plusBtn.innerHTML="+",e.$.plusBtn.classList.add("smart-editor-tab-plus"),e.$.tabs.appendChild(e.$.plusBtn),e.$.tabs.addTab=t=>{let n=e.$.tabs.querySelectorAll(".smart-editor-tab").length+1;const r=document.createElement("div");r.classList.add("smart-editor-tab"),r.innerText=t||"Page "+n,r.ondblclick=function(){const e=a(r);i(e)},r.onclick=function(e){const t=a(r);o(t),e.preventDefault()},e.$.tabs.insertBefore(r,e.$.tabs.lastElementChild);const l=e._createEditorBlock(!1,!1,"");let s="";s="blockHtml"===e.editMode?l.outerHTML:"&nbsp;";const d={label:r.innerText,innerHTML:s};e.pages.push(d),o(n-1)},e.$.plusBtn.onclick=()=>{e.$.tabs.addTab()}}else e.$.tabs.classList.add("smart-hidden")}render(){const e=this,t=()=>0===e.offsetWidth||0===e.offsetHeight,a=()=>{if(e._isMobile=Smart.Utilities.Core.isMobile,e._isFireFox=Smart.Utilities.Core.Browser.Firefox,e._isSafari=Smart.Utilities.Core.Browser.Safari,e._isMacOS=(window.navigator.platform||"").indexOf("Mac")>-1,e._handleMaxCharCount(),e._handleInputContent(),e._setToolbarVisibility(),e._handleToolbarMode(),e._handleInputElement(),e._handleEditMode(),e._predefPropertyGetter(),e._setCharCount(),e._setFocusable(),e._setAriaSettings(),e.spellCheck?e.$.editableElement.setAttribute("spellcheck",""):(e.$.editableElement.removeAttribute("spellcheck"),e.$.editableElement.spellcheck=!1),e.autoExpand&&e.expandToolbar(),e.isInitialized=!0,e.checkLicense(),e._setSortable(),e.$.input&&(e.$.input.value=e._getInputValue(e.$.editableElement.innerHTML.trim())),"blockHtml"===e.editMode){let t=e.innerHTML;if(""===t&&(t="&nbsp;"),0===e.querySelectorAll("[data-block]").length){if("blockHtml"===e.editMode){const a=e._createEditorBlock(!1,!1,t);a.setAttribute("empty",""),e.innerHTML=e.value=t=a.outerHTML}e._handleInputContent("innerHTML",t),"blockHtml"===e.editMode?(e._initEditorBlocks(),e._refreshEditorBlockPlaceholder(),e._editorBlocks=e.$.editableElement.querySelectorAll(".smart-editor-block"),1===e._editorBlocks.length&&(e._currentBlock=e.$.editableElement.querySelector(".smart-editor-block")),e._setSortable(),e._renderPages()):e._renderPages(),e._renderPages(),e._refreshTasks()}}};if(t())return requestAnimationFrame((()=>{e.isInitialized||t()?e._createInterval=setInterval((()=>{e.isInitialized||t()||(a(),e._setDictionary(),clearInterval(e._createInterval))}),100):(a(),e._setDictionary())})),void super.render();a(),e._setDictionary(),super.render()}_setSortable(){const e=this;if(e.sortable&&"blockHtml"===e.editMode){e.$.headerInsertLine&&(e.$.headerInsertLine.remove(),e.$.headerSortable.remove(),e.$.editableElement.querySelectorAll(".smart-editor-insert-line").forEach((e=>e.remove())),e.$.editableElement.querySelectorAll(".smart-editor-sortable").forEach((e=>e.remove()))),e.$.headerInsertLine=document.createElement("div"),e.$.headerSortable=document.createElement("div"),e.$.headerInsertLine.classList.add("smart-editor-insert-line"),e.$.headerSortable.classList.add("smart-editor-sortable"),e.addBlock&&e.$.editableElement.appendChild(e.$.headerInsertLine),e.$.editableElement.appendChild(e.$.headerSortable),e.setAttribute("sortable",""),e.addBlock&&(e.$.headerInsertLine.title=e.localize("addButton"),e.$.headerInsertLine.onpointerdown=t=>{e.$.headerInsertLine.item&&e._setSelectionRange(e.$.headerInsertLine.item.item,0,0);let a=e._getSelectionRange().endContainer;for(;a&&(!a.classList||!a.classList.contains("smart-editor-block"));)a=a.parentElement;e._currentBlock=a;const o=e._currentBlock&&e._currentBlock.hasAttribute("empty");a=o?e._currentBlock:e._createEditorBlock(t.altKey,!1),e._currentBlock=a,e._renderSortableMenu(t,o,!0),t.preventDefault(),t.stopPropagation()});const t=function(){const e=document.createElement("div");return e.classList.add("smart-editor-drag-line","smart-hidden"),e};e._blockDragDetails={},e.$.headerSortable.onpointerdown=function(a){e._blockDragDetails&&e._blockDragDetails.line&&e._blockDragDetails.line.remove();const o=t();e.$.editableElement.appendChild(o),e._blockDragDetails={line:o,x:a.pageX,y:a.pageY},e._blockDragDetails.items=[],e.$.editableElement.querySelectorAll(".smart-editor-block").forEach((t=>{const a=t.offsetHeight,o=e.offset(t).top;e._blockDragDetails.items.push({item:t,top:o,bottom:o+a})}))},e.$.headerSortable.onpointermove=function(t){if(e._blockDragDetails&&e._blockDragDetails.line){if(e._blockDragDetails.dragging)return;if(Math.abs(t.pageX-e._blockDragDetails.x)>=1||Math.abs(t.pageY-e._blockDragDetails.y>=1)){const a=e._blockDragDetails.items,o=e.offset(e.$.editableElement),i=e.$.editableElement.scrollTop;a.forEach(((n,r)=>{n.top-i+2<t.pageY&&t.pageY<n.bottom-i-2?(e._blockDragDetails.line.style.top=n.top-o.top-i+"px",e._blockDragDetails.dragItem=n,e._blockDragDetails.dragging=!0,t.preventDefault(),t.stopPropagation()):r===a.length-1&&t.pageY>n.bottom-i&&(e._blockDragDetails.line.style.top=n.bottom-o.top-i+"px",e._blockDragDetails.dragItem=n,e._blockDragDetails.dragging=!0,t.preventDefault(),t.stopPropagation())})),e._blockDragDetails.line.classList.remove("smart-hidden")}}}}}detached(){const e=this;super.detached(),delete e._dragDetails,delete e._resizeFrameObj,delete e._toolbarItemClick,e._endInlineToolbarClick(),e._closeWindow(),e._closeToolbarItemDropDown(e.$.inputPopup),e._closeToolbarItemDropDown(e.$.colorInputPopup),e._closeContextMenu(),e._closeToolbar(),e._taskTooltip&&e._taskTooltip.remove(),e.toolbarOnFocus&&document.querySelector("#"+e.$.toolbar.id)&&document.querySelector("#"+e.$.toolbar.id).remove(),e._handleTableSelection()}select(){this.focus()}focus(){const e=this,t="markdown"===e.editMode?e.$.input:e.$.editableElement;if(!t)return;t.focus();const a=document.createRange(),o=window.getSelection();a.selectNodeContents(e.$.editableElement),e._currentBlock&&"blockHtml"===e.editMode&&e._currentBlock.parentElement===e.$.editableElement&&a.selectNodeContents(e._currentBlock),a.collapse(!1),o.removeAllRanges(),o.addRange(a),e._refreshToolbarPosition()}blur(){const e=this,t="markdown"===e.editMode?e.$.input:e.$.editableElement;t&&t.blur()}clearState(){const e=this;e.id?window.localStorage.removeItem("smartEditor"+e.id):e.warn(e.localize("noId"))}collapseToolbar(){this._toggleToolbar(!0)}disableToolbarItem(e){this._setToolbarItemAttr(e,"disabled",!0)}enableToolbarItem(e){this._setToolbarItemAttr(e,"disabled",!1)}expandToolbar(){this._toggleToolbar()}executeCommand(e,t){const a=this,o=a._getCurrentValue();a.$.editableElement.focus();const i=a.$.editableElement.getRootNode().execCommand(e,!1,t),n=a._getCurrentValue();return a.$.fireEvent("change",{value:n,oldValue:o}),i}exportData(e,t){this._handleDataExport(e,t)}importData(e,t){"string"==typeof e&&(e={url:e}),t||(t={}),this._ajax(e,t)}fullScreenMode(e){const t=this;t.$.fireEvent("actionStart",{name:"fullScreenMode"}).defaultPrevented||(t._handleFullScreenMode(t._toggleItem("fullscreen",e)),t.$.fireEvent("actionEnd",{name:"fullScreenMode"}))}getCharCount(){const e=this;if("html"===e.editMode||"blockHtml"===e.editMode){const t=e.$.editableElement,a=t.textContent.length,o=t.innerText.length;return o&&a?o:0}return e.$.input.value.length}getSelection(){const e=this.$.iframe;let t,a;return e?(t=e.contentDocument,a=e.contentWindow):(t=document,a=window),new function(e){var t={initialize:function(e){this.document=e},getSelection:function(){return this.document.getSelection?this.document.getSelection():this.document.selection},getRange:function(){var e=this.getSelection();if(!e)return null;try{return e.rangeCount>0?e.getRangeAt(0):this.document.createRange?this.document.createRange():this.document.selection.createRange()}catch(e){return this.document.body.createTextRange()}},selectRange:function(e){if(e.select)e.select();else{var t=this.getSelection();t.addRange&&(t.removeAllRanges(),t.addRange(e))}},selectNode:function(e,t){var a=this.getRange(),o=this.getSelection();if(a.moveToElementText)a.moveToElementText(e),a.select();else if(o.addRange)try{t?a.selectNodeContents(e):a.selectNode(e),o.removeAllRanges(),o.addRange(a)}catch(e){}else o.setBaseAndExtent(e,0,e,1);return e},isCollapsed:function(){var e=this.getRange();return!e.item&&(0==e.boundingWidth||this.getSelection().isCollapsed)},collapse:function(e){var t=this.getRange(),a=this.getSelection();t.select?(t.collapse(e),t.select()):e?a.collapseToStart():a.collapseToEnd()},getContent:function(){var t=this.getRange(),a=e.createElement("div");return this.isCollapsed()?"":t.cloneContents?(a.appendChild(t.cloneContents()),a.innerHTML):null!=t.item||null!=t.htmlText?t.item?t.item(0).outerHTML:t.htmlText:t.toString()},getText:function(){var e=this.getRange(),t=this.getSelection();return this.isCollapsed()?"":e.text||(t.toString?t.toString():"")},getNode:function(){var t=this.getRange();if(!$.smart.browser.msie||$.smart.browser.version>=9){var a=null;if(t)for(a=t.commonAncestorContainer,t.collapsed||t.startContainer==t.endContainer&&t.startOffset-t.endOffset<2&&t.startContainer.hasChildNodes()&&(a=t.startContainer.childNodes[t.startOffset]);"element"!=typeof a;)a=a.parentNode;return e.id(a)}return e.id(t.item?t.item(0):t.parentElement())},insertContent:function(e){var t=this.getRange();if(t.pasteHTML)t.pasteHTML(e),t.collapse(!1),t.select();else if(t.insertNode)if(t.deleteContents(),t.createContextualFragment)t.insertNode(t.createContextualFragment(e));else{var a=this.document,o=a.createDocumentFragment(),i=a.createElement("div");o.appendChild(i),i.outerHTML=e,t.insertNode(o)}}};return t.initialize(e),t}(t)}getSelectionRange(){return this._selectionRange}clearContent(){const e=this;e._setResizeFrame(),e.$.editableElement.innerHTML=e.$.input.value=""}setHTML(e){this._setEditorValue(e,this)}getHTML(){const e=this;if("markdown"===e.editMode){const t=e.$.input;return window.marked?window.marked(t.value):t.value}{const t=document.createElement("div");return t.innerHTML=e.$.editableElement.innerHTML,e._autoSuggest&&e._autoSuggest.parentNode&&e._autoSuggest.remove(),"blockHtml"===e.editMode&&(t.querySelectorAll(".smart-editor-insert-line").forEach((e=>e.remove())),t.querySelectorAll(".smart-editor-sortable").forEach((e=>e.remove())),t.querySelectorAll(".smart-editor-block").forEach((e=>{e.removeAttribute("data-block-id"),e.removeAttribute("class"),e.removeAttribute("contenteditable")})),t.querySelectorAll(".smart-editor-page").forEach((e=>{e.removeAttribute("data-block-id"),e.removeAttribute("class"),e.removeAttribute("contenteditable")}))),t.innerHTML}}getText(){const e=this;return"markdown"===e.editMode?e.$.input.value:e.$.editableElement.textContent}loadState(e){const t=this;t.id?(e||(e=window.localStorage.getItem("smartEditor"+t.id)),"string"==typeof e&&(t.set("value",e),t.$.editableElement.innerHTML=t.$.input.value=e)):t.warn(t.localize("noId"))}showMessage(e,t){const a=this;if(!e||!a.isRendered)return;if(!Smart.Toast)return void a.error(a.localize("missingReference",{elementType:a.nodeName.toLowerCase(),methodName:"showMessage",files:"smart.toast.js"}));a._setToast();const o=a.$.toast;if(o){let i;if("object"==typeof t)for(let e in t)"iconType"===e?i=t[e]:o[e]=t[e];if(!a.$.container.contains(o)){const e=a.$toast;a._toastVisibilityHandler||(a._toastVisibilityHandler=e=>{const t=e.type;"close"===e.type&&e.detail.instance===a._requiredMessage&&delete a._requiredMessage,e.stopPropagation(),a.$.fireEvent("message"+t.slice(0,1).toUpperCase()+t.slice(1),e.detail)},e.listen("open",a._toastVisibilityHandler),e.listen("close",a._toastVisibilityHandler)),a.$.container.appendChild(o)}return o.open(e+"",i)}}_isAllContentSelected(){const e=this.$.editableElement,t=window.getSelection();if(!t.rangeCount)return!1;const a=t.toString().replace(/\s+/g," ").trim(),o=e.innerText.replace(/\s+/g," ").trim();return a===o&&o.length>0}hideMessage(e){const t=this.$.toast;t&&(void 0===e?t.closeAll():t.closeItem(e))}hideLastMessage(){const e=this.$.toast;e&&e.closeLast()}selectAll(){this._selectAll()}selectRange(e,t){const a=this,o=a.$.editableElement.getRootNode();if(!o)return;e=parseInt(e),t=parseInt(t),e=Math.min(e,t),t=Math.max(e,t);const i=a.$.input,n=a.$.editableElement,r="markdown"===a.editMode||a.$.editableElement.classList.contains("smart-hidden")?i:n,l=a.$.iframe,[s,d]=l?[l.contentWindow,l.contentDocument]:[window,document],c=s.getSelection();let m=o.activeElement;if((!m||m!==i&&m!==n||m.classList.contains("smart-hidden"))&&(r.focus(),m=r),c.removeAllRanges(),delete a._selectionRange,!isNaN(e)&&!isNaN(t)&&e!==t){if(m===i)i.setSelectionRange(e,t),a._selectionRange={selectionStart:e,selectionEnd:t};else{const o=a._getNodes(n,e,t).nodes;for(let e=0,t=o.length;e<t;e+=1){const{node:t,index:i,startIndex:n}=o[e],r=d.createRange();t.nodeType===Node.TEXT_NODE?(r.setStart(t,Math.max(0,n)),r.setEnd(t,Math.min(i,t.nodeValue.length))):r.selectNodeContents(t),c.addRange(r),a._selectionRange=r}}a._updateToolbarItems()}}saveState(){const e=this;e.id?window.localStorage.setItem("smartEditor"+e.id,e.$.editableElement.innerHTML):e.warn(e.localize("noId"))}splitMode(e){const t=this;t.$.fireEvent("actionStart",{name:"splitMode"}).defaultPrevented||(t._handleSplitMode(t._toggleItem("splitmode",e)),t.$.fireEvent("actionEnd",{name:"splitMode"}))}previewMode(e){const t=this;t.$.contentContainer.hasAttribute("split-mode")||t.$.fireEvent("actionStart",{name:"sourcecode"}).defaultPrevented||(t._handleSourceCodeMode(t._toggleItem("sourcecode",e)),t.$.fireEvent("actionEnd",{name:"sourcecode"}))}print(){this._handlePrint()}updateToolbarItem(e,t){const a=this,o=a.toolbarItems;let i;if("string"==typeof e?i=o.find((t=>t.name===e)):"number"==typeof e&&(i=o[e]),i){a._closePopups(),a._closeWindow(),delete a._toolbarItemsObj[i.name],delete a._inlineToolbarItemsObj[i.name];for(let e in t)i[e]=t[e];return a._refreshToolbarItems(a._getToolbarItems()),!0}}_toggleItem(e,t){const a=this._toolbarItemsObj;if(!a)return;const o=a[e],i=this.$.toolbar.querySelector(`.smart-editor-toolbar-item[item-name="${e}"]`);return o&&i?((t=o.value=void 0===t?!o.value:!!t)?(i.setAttribute("checked",""),i.setAttribute("aria-pressed",!0)):(i.removeAttribute("checked"),i.setAttribute("aria-pressed",!1)),i):void 0}_ajax(e,t={}){const a=this;let o="GET",i=e.url,n=null,r=!0;if(e.type&&(o=e.type),e.data)if("GET"===o){i+="?";for(let t in e.data)Object.prototype.hasOwnProperty.call(e.data,t)&&(i+=encodeURI(t+"="+e.data[t]+"&"));"&"===i.charAt(i.length-1)&&(i=i.slice(0,i.length-1))}else"POST"===o&&(n=JSON.stringify(e.data));t&&!1===t.async&&(r=!1),void 0!==window.fetch&&r?a._ajaxFetch(e,t,o,i,n):a._ajaxXMLHttpRequest(e,t,o,i,n,r)}_ajaxFetch(e,t,a,o,i){const n=this,r={method:a};let l,s,d;t&&t.contentType&&(r.headers=new Headers({"Content-Type":t.contentType})),null!==i&&(r.body=i),e.timeout&&(s=setTimeout((function(){d=!0}),e.timeout)),t.beforeSend&&!1===t.beforeSend(r,t)||fetch(o,r).then((function(e){if(d)throw l=408,n.error(n.localize("timeout",{elementType:n.nodeName.toLowerCase()}));if(s&&clearTimeout(s),l=e.status,!e.ok)throw n.error(n.localize("importError",{elementType:n.nodeName.toLowerCase(),status:e.statusText}));return e.text()})).then((e=>n._ajaxComplete(t,e,l))).catch((function(e){t&&t.loadError&&t.loadError(l,e)}))}_ajaxXMLHttpRequest(e,t,a,o,i,n){const r=new XMLHttpRequest,l=this;r.open(a,o,n),r.ontimeout=function(){t&&t.loadError&&t.loadError(408,"timeout")},r.onload=function(){if(4===r.readyState){const a=r.status;let o=r.response;a>=200&&a<=299?("json"===e.dataType&&(o=JSON.parse(o)),l._ajaxComplete(t,o,a)):t&&t.loadError&&t.loadError(a,o)}},r.onerror=function(){t&&t.loadError&&t.loadError(r.status,r.response)},t&&t.contentType&&r.setRequestHeader("Content-Type",t.contentType),n&&e.timeout&&(r.timeout=e.timeout),t.beforeSend&&!1===t.beforeSend(r,t)||r.send(i)}_ajaxComplete(e,t){if(e){if(e.beforeLoadComplete){const a=e.beforeLoadComplete(t);a&&(t=a)}this._handleInputContent("value",t)}}_afterInputHandler(e){const t=this,a=t._beforeInputObj,o=t.$.editableElement,i=!o.innerHTML;let n,r;if(a&&a.type&&(n=a.type,r=a.rangeDetails),delete t._beforeInputObj,t._bigramStore=function(e,t=2){const a=new Set(["the","is","and","a","to","of","in","on","for","with","at","by","an","this","that","it","as"]);let o=e.toLowerCase().replace(/[^\w\s]/g,"").split(/\s+/);o=o.filter((e=>!a.has(e)));let i={};for(let e=0;e<o.length-1;e++){let t=o[e]+" "+o[e+1];i[t]=(i[t]||0)+1}return Object.entries(i).filter((([e,a])=>a>=t)).sort(((e,t)=>t[1]-e[1])).map((e=>e[0]))}(t.$.editableElement.textContent),i&&(t._setResizeFrame(),t._closeToolbar()),"insertParagraph"===n||i){let e=t._getSelectionRange().startContainer;if(e.nodeType===Node.TEXT_NODE&&(e=e.parentElement),e&&e.classList&&(e.closest(".smart-editor-image-caption")||e.closest(".smart-editor-editable table")))return;const a=t.$.iframe,[n,r]=a?[a.contentWindow,a.contentDocument]:[window,document];("div"===n.getSelection().anchorNode.nodeName.toLowerCase()||e===o&&i)&&r.execCommand("insertHTML",!1,"<p><br></p>")}else if(n&&r&&n.indexOf("delete")>-1){const e=t._resizeFrameObj;e&&e.target&&!o.contains(e.target)&&t._setResizeFrame()}o.textContent.length&&o.innerText.length?o.removeAttribute("show-placeholder"):o.setAttribute("show-placeholder",""),t.name&&e.target===t.$.editableElement&&"markdown"!==t.editMode&&(t.$.input.value=t._getInputValue(t.$.editableElement.innerHTML.trim())),t._setCharCount()}_createInsertionMarker(){const e=this.$.editableElement.getRootNode().querySelector("#INSERTION_MARKER");e&&e.remove();const t=document.createElement("span");return t.id="INSERTION_MARKER",t.innerHTML="&nbsp;",t}_beforeInputHandler(e){const t=this,a=t.$.iframe,o=t.$.contentContainer,i=t.$.editableElement,n=(a?a.contentWindow:window).getSelection(),r=n.rangeCount>0?n.getRangeAt(0):null;if(!r)return;const l=e.inputType,s=r.startContainer;let d;if(l&&(d=l.indexOf("delete")>-1,t._beforeInputObj={type:l,rangeDetails:{startOffset:r.startOffset,endOffset:r.endOffset,startContainer:r.startContainer,endContainer:r.endContainer}}),d&&i.contains(s))if(s===r.endContainer&&r.startOffset===r.endOffset){const e=t._resizeFrameObj;let a=s;if(e&&e.target&&e.target.contains(s))return;if(a.nodeType!==Node.TEXT_NODE&&a.innerHTML.length){if(a===i)return}else{let e=a.parentElement,t=a.previousElementSibling;for(;!t&&e;)t=e.previousElementSibling,e=e.parentElement;i!==t&&i.contains(t)&&!t.innerHTML.length&&t.nodeName}}else r.deleteContents(),e.preventDefault();if(!o.classList.contains("char-count-maxed")||d){if("insertParagraph"===l){const a=t._getSelectionRange().startContainer;if(a.nodeType===Node.TEXT_NODE&&a.parentElement===i){if(-1!==t.$.editableElement.innerHTML.indexOf("<")){const a=document.createElement("p");a.innerHTML="&#8203;";const o=t._createInsertionMarker();let n=t._getSelectionRange(),r=n.endContainer;r.parentElement.insertBefore(a,n.endContainer.nextSibling),r.parentElement.insertBefore(o,a.nextSibling),t.selectRange(n);const l=i.getRootNode().querySelector("#INSERTION_MARKER");return t._setSelectionRange(l.previousElementSibling),n=t._getSelectionRange(),n.collapse(),l.remove(),e.preventDefault&&e.preventDefault(),!1}i.getRootNode().execCommand("formatBlock",!1,"p")}}}else e.preventDefault()}_changeHandler(e){const t=this,a=e.target,o=e.detail,i=a.closest(".smart-editor-toolbar-item");if(e.stopPropagation(),t._toolbarItemsObj||t._inlineToolbarItemsObj)return i&&a===t.$.inputPopup||a===t.$.colorInputPopup?(t._ignoreSelectionChange=!0,t._updateToolbarItem(i,o),void delete t._ignoreSelectionChange):void 0}_contextMenuHandler(e){const t=this,a=t.contextMenu;if("browser"!==a)if(e.preventDefault(),"none"!==a){if(e.target&&3!==e.target.nodeType&&e.target.classList.contains("smart-editor-tab")){const a=t.$.tabs.getTabIndex(e.target);if(a>0){const o=[{value:"deleteTab",id:a,label:t.localize("delete")}];return void t._openContextMenu(e,o,!0)}}t._openContextMenu(e)}else t._closeContextMenu();else t._closeContextMenu()}_closeContextMenu(){const e=this.$.inlineToolbar,t=this.$.fireEvent("dropDownToolbarClosing",{target:e}).defaultPrevented;e&&e.visible&&e.classList.contains("smart-editor-context-menu")&&!t&&e.close()}_openContextMenu(e,t,a,o,i){let n=this,r=e.target,l=n.$.inlineToolbar;if(i&&(r=i),l||(l=n._createToolbar()),l.classList.remove("smart-editor-add-menu"),l.classList.remove("smart-editor-task-menu"),l.classList.remove("smart-editor-ai-menu"),n.$.fireEvent("contextMenuOpening",{target:l}).defaultPrevented)return;l.removeAttribute("bottom"),o?(l._cssClass=o,l.classList.add(o)):l._cssClass&&(l.classList.remove(l._cssClass),delete l._cssClass),"smart-editor-ai-menu"===o&&n.toolbarOnFocus&&l.setAttribute("bottom",""),n._setupToolbar(r,"context"),l.parentElement||n.getShadowRootOrBody().appendChild(l),l.clear(),n._setContextMenuContent(r,t),l.querySelectorAll(".smart-editor-context-menu-item").forEach((e=>{e.classList.remove("smart-hidden")}));const s=n.getBoundingClientRect();if(l.style.left=Math.min(e.pageX+1,s.right+window.pageXOffset-l.offsetWidth)+"px",l.style.top=Math.min(e.pageY+1,s.bottom+window.pageYOffset-l.offsetHeight)+"px",i){const e=n.offset(i);l.style.left=e.left+"px",l.style.top=e.top-n.$.editableElement.scrollTop+i.offsetHeight+5+"px"}if(l.open(),l.style.height="",t)if(l.hasAttribute("bottom")){if(i){const e=n.offset(i);l.style.left=e.left+"px",l.style.top=e.top-n.$.editableElement.scrollTop-5-l.offsetHeight+"px"}}else setTimeout((()=>{n._adjustPopupBounds(l)}),100);return a&&n._focusContextMenu(l),l}_focusContextMenu(e){const t=this;e.tabIndex=0;let a=e.querySelector(".smart-editor-context-menu-item");const o=e.querySelectorAll(".smart-editor-context-menu-item");o.forEach(((e,t)=>{e.tabIndex=t,e.removeAttribute("selected")})),e.options=o,setTimeout((()=>{a.focus()}),50),"category"===a.getAttribute("value")&&(a=a.nextElementSibling),a.setAttribute("selected",""),e.active=0,e.handleKeyDown=a=>{switch(o.forEach((e=>{e.removeAttribute("selected")})),a.key){case"ArrowDown":{const t=Array.from(e.querySelectorAll('.smart-editor-context-menu-item:not(.smart-hidden):not([value="category"])'));e.active=Math.min(e.active+1,t.length-1),t.forEach(((t,o)=>{t.removeAttribute("selected"),o===e.active&&(t.setAttribute("selected",""),t.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})),a.stopPropagation(),a.preventDefault()}));break}case"ArrowUp":{const t=Array.from(e.querySelectorAll('.smart-editor-context-menu-item:not(.smart-hidden):not([value="category"])'));e.active=Math.max(e.active-1,0),t.forEach(((t,a)=>{t.removeAttribute("selected"),a===e.active&&(t.setAttribute("selected",""),t.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"}))})),a.stopPropagation(),a.preventDefault();break}case"Enter":case"Tab":o[e.active].click(),a.stopPropagation(),a.preventDefault();break;case"Escape":t._closeContextMenu()}},e.onkeydown=t=>{e.handleKeyDown(t)}}_setContextMenuContent(e,t){const a=this;if(!e)return;let o=a._contextList,i=a._getContextMenuTargetType(e),n=a._getContextMenuDataSource(e,i);t&&(n=t),o||(a._contextList=o=document.createElement("div"),o.classList.add("smart-editor-context-menu-item-container"));const r=document.createDocumentFragment(),l=n.length;let s=o.children;for(;s.length>l;)s[0].remove();s=Array.from(s);for(let t=0;t<l;t++){const o=n[t];let l,d,c=s[t];if("object"==typeof o?(l=o.label,d=o.value):l=d=o+"",c||(c=document.createElement("div"),c.classList.add("smart-editor-context-menu-item"),c.setAttribute("role","option")),c.removeAttribute("disabled"),"deleteLink"!==o||"image"!==i||e.closest(".smart-editor-editable a")){if("cut"===o||"copy"===o){const e=a._getSelectionRange();(void 0!==e.selectionStart?e.selectionStart:e.startOffset)===(void 0!==e.selectionEnd?e.selectionEnd:e.endOffset)&&c.setAttribute("disabled","")}}else c.setAttribute("disabled","");c.parentElement||r.appendChild(c);let m="";if(o.image){const e=o.image;m+=`<div class="user-icon smart-icon" style="${e?`background-size: 24px 24px; margin-left: -30px; margin-right: 10px; border-radius: 50%; width: 24px; height: 24px; background-image: url('${e}');`:""}"></div>`}void 0!==o.id&&c.setAttribute("id",o.id),void 0!==o.label&&c.setAttribute("label",o.label),void 0!==o.name&&c.setAttribute("name",o.name),c.innerHTML=m+a.localize(l)||l,c.removeAttribute("description"),o.description&&(c.innerHTML+=`<span class="smart-editor-context-menu-item-description">${o.description}</span>`,c.setAttribute("description",o.description)),c.setAttribute("value",d)}o.appendChild(r),a.$.inlineToolbar.appendChild(o)}_getContextMenuTargetType(e){let t;return t=e.closest(".smart-editor-editable table")?"table":e.closest(".smart-editor-editable img")?"image":e.closest(".smart-editor-video-container")?"video":e.closest(".smart-editor-file-container")?"file":e.closest(".smart-editor-editable a")?"link":"text",t}_getContextMenuDataSource(e,t){if(!t)return[];const a=this.contextMenuDataSource;let o;switch(t){case"table":o=["tableProperties","insertRowAfter","insertRowBefore","insertColumnLeft","insertColumnRight","deleteRow","deleteColumn","deleteTable","selectAll"];break;case"image":o=["imageProperties","copyImage","cutImage","createLink","deleteLink","deleteImage","caption"];break;case"video":o=["videoProperties","copyVideo","cutVideo","deleteVideo","caption"];break;case"file":o=["fileProperties","deleteFile"];break;case"link":o=["linkProperties","deleteLink","selectAll"];break;default:o=["copy","cut","paste","selectAll"]}return a&&(o="function"==typeof a?a(e,t,o):Array.isArray(a)?a:[]),o}_updateToolbarItem(e,t){const a=this,o=a.editMode,i=e.getAttribute("item-name"),n=a.$.toolbarItemsPrimary,r=a.$.toolbarItemsSecondary,l=a.$.inlineToolbar,s="markdown"===o?a.$.input:a.$.editableElement,d=(e,o,i)=>{o&&(o.label=t["alignment"===o.name?"value":"label"],o.value=t.value,e&&a._setItemValue(e,o),i&&a._updateToolbarTarget(o))};if(l&&l.contains(e)?(d(e,a._inlineToolbarItemsObj[i],!0),a._toolbarItemsObj&&a._toolbarItemsObj[i]&&d(a.$.toolbar.querySelector(`.smart-editor-toolbar-item[item-name=${i}]`),a._toolbarItemsObj[i])):(n.contains(e)||r.contains(e))&&a._toolbarItemsObj&&(d(e,a._toolbarItemsObj[i],!0),l&&l.visible&&a._inlineToolbarItemsObj&&d(l.querySelector(`.smart-editor-toolbar-item[item-name=${i}]`),a._inlineToolbarItemsObj[i])),s.getRootNode().activeElement!==s){const e=a._selectionRange,t=s.scrollTop;e&&("markdown"===o?a._setSelectionRange(s,e.selectionStart,e.selectionEnd):a._setSelectionRange(e.startContainer,e.startOffset,e.endOffset)),s.focus({preventScroll:!0}),a._isSafari&&t&&(s.scrollTop=t)}}_updateToolbarTarget(e){const t=this,a=t._resizeFrameObj;if(!e)return;const o=t.$.inlineToolbar;let i;a&&a.target?i=a.target:o&&o.visible&&(i=o.selector,i=i.closest?i.closest(".smart-editor-editable img")||i.closest(".smart-editor-editable table"):void 0);const n=i?i.nodeName.toLowerCase():"";if(i&&"img"===n)return"alignment"===e.name&&(i.closest(".smart-editor-image-container")||i).setAttribute("alignment",e.value),t._setResizeFrame(i),void(o&&o.visible&&o.reposition());if(i&&"table"===n)return void t._handleTableToolbarAction(e,i);const r=t._getSelectionRange();if(r&&(r.startContainer||void 0!==r.selectionStart)){const a=e.name;if(t.$.fireEvent("actionStart",{name:a}).defaultPrevented)return;switch(a){case"backgroundcolor":t._handleBackgroundColor(e);break;case"fontcolor":t._handleFontColor(e);break;case"alignment":t._handleTextAlignment(e);break;case"fontsize":t._handleFontSize(e);break;case"fontname":t._handleFontName(e);break;case"formats":t._handleFormats(e);break;case"paste":t._handlePaste(e);break;default:{const t=r.startContainer.closest?r.startContainer:r.startContainer.parentElement;return void(t&&t.closest&&t.setAttribute(e.name,e.value))}}a&&(t.$.fireEvent("actionEnd",{name:a}),(()=>{const e=t._changingValue,a=t.$.input,o=t.$.editableElement.getRootNode().activeElement===a?a.value:t.$.editableElement.innerHTML;void 0!==e&&o!==e&&t.$.fireEvent("changing",{value:o,oldValue:t._changingValue})})())}}_setSelectionRange(e,t,a){const o=this,i=o.$.iframe,n=o.editMode;let r;if(o.disabled)return;if("markdown"===n||o.$.editableElement.classList.contains("smart-hidden")){r=o.$.input,o._selectionRange={selectionStart:void 0!==t?t:r.selectionStart,selectionEnd:void 0!==a?a:r.selectionEnd};const e=o._selectionRange;return void(o._selectionChangeFired||r.setSelectionRange(e.selectionStart,e.selectionEnd))}const l=(i?i.contentWindow:window).getSelection();let s;if(r=o.$.editableElement,e){if(s=document.createRange(),"number"==typeof t&&"number"==typeof a)try{s.setStart(e,parseInt(t)),s.setEnd(e,parseInt(a))}catch(t){s.selectNodeContents(e)}else"img"===e.nodeName.toLowerCase()||e.classList.contains("smart-editor-video-container")?(s.setStartBefore(e),s.setEndAfter(e),s.selectNode(e)):s.selectNodeContents(e);l.removeAllRanges(),l.addRange(s)}else l.rangeCount&&(s=l.getRangeAt(0));try{s&&s.startContainer&&r.contains(s.startContainer)&&(o._selectionRange=s)}catch(e){}o._selectionRange||(s=document.createRange(),s.selectNodeContents(r),s.collapse(!0),o._selectionRange=s)}_getSelectionRange(){const e=this,t=e.editMode;let a=e._selectionRange;return a&&("markdown"===t&&void 0===a.selectionStart||"html"===t&&void 0===a.startContainer||"blockHtml"===t&&void 0===a.startContainer)&&(delete e._selectionRange,a=void 0),a||e._setSelectionRange(),e._selectionRange}_setCharCount(){const e=this,t=e.$.contentContainer;if(!e.showCharCount)return void t.removeAttribute("char-count");const a=e.maxCharCount;let o,i;if("html"===e.editMode||"blockHtml"===e.editMode){const t=e.$.editableElement,a=t.textContent.length,o=t.innerText.length;i=o&&a?o:0}else i=e.$.input.value.length;if(o=e.charCountFormatFunction?e.charCountFormatFunction(i,a)+"":a?`${i} / ${a}`:i+"",t.setAttribute("char-count",o),null===a)return void t.classList.remove("char-count-low","char-count-medium");const n=parseFloat((i/a).toFixed(2));t.classList[n>=.7&&n<=.9?"add":"remove"]("char-count-warning"),t.classList[n>=.9?"add":"remove"]("char-count-error"),t.classList[i>=a?"add":"remove"]("char-count-maxed")}_documentDownHandler(e){const t=this,a=t.$.iframe,o=t.$.inlineToolbar,i=t.$.window,n=e.originalEvent||e,r=t.shadowRoot||t.isInShadowDOM?n.composedPath()[0]:n.target;if(t.contains(document.activeElement)){const e=t.getSelectionRange();t._editorSelectionRange=e}if(o&&o.contains(r)){const e=r.closest(".smart-editor-toolbar-item");return t._handleToolbarItemDown(e,r),void n.preventDefault()}if(t.toolbarOnFocus){const e=r.closest(".smart-editor-toolbar-item");if(e&&t.$.toolbar.contains(e))return t._handleToolbarItemDown(e,r),void n.preventDefault()}if(t.$.container.contains(r)||a&&a.contentDocument.body.contains(r))return void t._handleDownInside(n,r);const l=r.closest(".smart-input-drop-down-menu");let s;if(l&&(s=l.ownerElement),i&&i.opened&&!i.contains(s||r)&&i.close(),t._handleTableSelection(),s&&(t.$.toolbarItemsPrimary.contains(s)||t.$.toolbarItemsSecondary.contains(s)||o&&o.contains(s)))return t._toolbarItemClick={},void n.preventDefault();t._setResizeFrame(),t._closePopups()}_handleDownInside(e,t){const a=this,o=e.originalEvent||e,i=t.closest(".smart-editor-toolbar-item"),n=a.$.inlineToolbar,r=t.classList.contains("smart-editor-video-container")?t:null,l=a.$.window;let s=a._editorVideoItemClick;if(s&&(r&&s.dragElement&&s.dragElement.remove(),delete a._editorVideoItemClick,s=void 0),t===a.$.toolbarToggleButton)a._toolbarItemClick={},e.preventDefault();else{if(i)return a._handleToolbarItemDown(i,t),void e.preventDefault();if(t.closest(".smart-editor-toolbar-tab"))e.preventDefault();else if(r)s||(s=a._editorVideoItemClick={target:t,originalSelectionRange:a._selectionRange}),e.preventDefault(),!1!==r.getAttribute("draggable")&&r.querySelector("video")?(s.dragElement=a._createWhiteSpaceChar(t,r),a._setSelectionRange(t)):s.dragElement&&(s.dragElement.remove(),delete s.dragElement);else if(t.closest(".smart-editor-search-bar"))a._searchBarDown={target:t},t.closest(".smart-search-input")||e.preventDefault();else{const e={x:o.pageX+window.pageXOffset,y:o.pageY+window.pageYOffset};l&&l.opened&&l.close();const i=a._getInlineToolbarTarget(t,e);if(i){const t=a.$.contentContainer;t.contains(t.getRootNode().activeElement)||a._focusEditableElement(),a._handleInlineToolbarItemDown(i,e)}else!n||n.contains(t)&&n.classList.contains("smart-editor-drop-down-toolbar")||(a._closeToolbar(),a._handleTableSelection())}}a._closeToolbarItemDropDown(a.$.inputPopup),a._closeToolbarItemDropDown(a.$.colorInputPopup)}_handleToolbarItemDown(e,t){const a=this,o=a.$.inlineToolbar,i=a.$.window;if(!e)return;const n=e.getAttribute?e.getAttribute("item-type"):e.type,r=e.getAttribute?e.getAttribute("item-name"):e.name;switch(!i||!i.opened||i._target&&i._target.item.name===r||i.close(),a._toolbarItemClick={toolbarItem:e},a._resizeFrameObj&&a._resizeFrameObj.target?a._toolbarItemClick.target=a._resizeFrameObj.target:a._setResizeFrame(),a._setSelectionRange(),n){case"button":["hyperlink","createlink","image","file","video"].includes(r)?a._toolbarItemClick.callback=a._toggleWindow:"table"===r&&(a._toolbarItemClick.callback=o&&o.contains(e)?a._toggleWindow:a._toggleDropDownToolbar);break;case"toggle":e.toggleAttribute("checked"),e.hasAttribute("checked")?e.setAttribute("aria-pressed",!0):e.setAttribute("aria-pressed",!1),a._closeToolbarItemDropDown(a.$.inputPopup),a._closeToolbarItemDropDown(a.$.colorInputPopup);break;case"drop-down":a._toolbarItemClick.callback=a._toggleItemDropDown;break;case"color-input":t.closest(".smart-editor-item-drop-down-button")&&(a._toolbarItemClick.callback=a._toggleItemDropDown)}}_handleInlineToolbarItemDown(e,t){const a=this,o=e.closest(".smart-editor-editable table"),i=a.$.editableElement;if(a._inlineToolbarClickObj&&a._inlineToolbarClickObj.target&&(a._inlineToolbarClickObj.target.removeAttribute("drag-id"),a._inlineToolbarClickObj.dragElement&&a._inlineToolbarClickObj.dragElement.removeAttribute("drag-id")),a._inlineToolbarClickObj={},e)if("img"===e.nodeName.toLowerCase())e.setAttribute("drag-id",Math.random().toString(36).substr(2,5));else if(e.classList.contains("smart-editor-video-container")){const t=e.querySelector("video, iframe");t&&(t.setAttribute("drag-id",Math.random().toString(36).substr(2,5)),a._inlineToolbarClickObj.dragElement=t)}if(o&&i.hasAttribute("table-cell-resize")){const n=i.getAttribute("table-cell-resize");a._inlineToolbarClickObj.resizeDetails={x:t.x,y:t.y,position:n,target:"vertical"===n?e.closest("tr"):e,table:o},e=void 0}a._handleTableSelection(e),a._inlineToolbarClickObj.target=e,a._inlineToolbarClickObj.dragTarget=e}_getInlineToolbarTarget(e,t){const a=this;let o,i=e.closest(".smart-editor-editable img")||e.closest(".smart-editor-editable a")||e.closest(".smart-editor-video-container");return i||(o=e.closest(".smart-editor-editable table"),o&&(i=e.closest(".smart-editor-editable td")||e.closest(".smart-editor-editable th"))),e.closest(".smart-editor-resize-frame")&&a._resizeFrameObj?(a._resizeFrameObj.resizeDetails={x:t.x,y:t.y,position:e.getAttribute("position")},i=a._resizeFrameObj.target):i&&(i&&"img"===i.nodeName.toLowerCase()||o||i.classList.contains("smart-editor-video-container"))||a._setResizeFrame(),i}_documentMoveHandler(e){const t=this,a=t._resizeFrameObj,o=t._inlineToolbarClickObj,i=e.originalEvent||e;if(a&&a.resizeDetails)t._handleFrameResize(i);else if(o&&o.resizeDetails)t._handleTableCellResize(i);else if(i&&i.target)if(t._blockDragDetails&&t._blockDragDetails.dragging){if(t._blockDragDetails.line){const e=t._blockDragDetails.items,a=t.offset(t.$.editableElement);delete t._blockDragDetails.dropItem;const o=t.$.editableElement.scrollTop;e.forEach(((n,r)=>{n.top-o<=i.pageY&&i.pageY<=n.bottom-o?(t._blockDragDetails.line.style.top=n.top-a.top-o+"px",t._blockDragDetails.dropItem=n,t._blockDragDetails.dropAbove=!0):r===e.length-1&&i.pageY>n.bottom-o&&(t._blockDragDetails.line.style.top=n.bottom-a.top-o+"px",t._blockDragDetails.dropItem=n,t._blockDragDetails.dropAbove=!1)})),t._blockDragDetails.dropItem||(i.pageY<e[0].top?(t._blockDragDetails.dropItem=e[0],t._blockDragDetails.dropAbove=!0):i.pageY>e[e.length-1].bottom&&(t._blockDragDetails.dropItem=e[e.length-1],t._blockDragDetails.dropAbove=!1))}}else{t.$.headerInsertLine&&(t.$.headerInsertLine.classList.remove("show"),t.$.headerSortable.classList.remove("show"));let e=[];(t._editorBlocks||t.$.editableElement.querySelectorAll(".smart-editor-block")).forEach((a=>{const o=a.offsetHeight,i=t.offset(a).top;e.push({item:a,top:i,height:o,bottom:i+o})})),e.forEach((e=>{const a=t.$.editableElement.scrollTop;if(e.top-a<=i.pageY&&i.pageY<=e.bottom-a){const o=t.offset(t.$.editableElement),i=e.top+e.height/2-9-a,n=e.top-a;if(!t.$.headerInsertLine)return;if(e.height<=40?(t.$.headerInsertLine.style.top=i-o.top+"px",t.$.headerSortable.style.top=i-5-o.top+"px"):(t.$.headerInsertLine.style.top=n-o.top+"px",t.$.headerSortable.style.top=n-5-o.top+"px"),t.$.headerInsertLine.item=e,t._isSelecting)return;t.$.headerInsertLine.classList.add("show"),t.$.headerSortable.classList.add("show")}}))}}_touchmoveHandler(e){const t=this,a=t._resizeFrameObj;t._isMobile&&a&&a.target&&(a.resizeDetails?(e.preventDefault(),e.stopPropagation()):(t._closeToolbar(),t._setResizeFrame()))}_dragStartHandler(e){const t=this,a=t._resizeFrameObj,o=t._inlineToolbarClickObj;if(a&&a.resizeDetails||o&&o.resizeDetails)return e.preventDefault(),void delete t._dragDetails;if(!t.$.contentContainer.contains(e.target))return;if(!o||!o.target)return void e.preventDefault();const i=t._inlineToolbarClickObj.target;if(i&&(["img","table"].indexOf(i.nodeName.toLowerCase())>-1||i.classList.contains("smart-editor-video-container"))){if("false"===i.getAttribute("draggable"))return void e.preventDefault();const a=e.target,o=a.parentElement,n=a.closest(".smart-editor-image-container");t._closeToolbar(),t._setResizeFrame(),t._dragDetails={target:a,scrollTop:t.$.editableElement.scrollTop,container:n,anchor:o&&"a"===o.nodeName.toLowerCase()?o:void 0,caption:n?n.querySelector(".smart-editor-image-caption"):void 0}}}_dropHandler(){const e=this;e._isFireFox&&e._dragEndHandler()}_dragEndHandler(){const e=this,t=e.$.inlineToolbar,a=e._dragDetails;if(a){const o=a.target,i=a.container,n=e.$.editableElement,r=n.querySelector(`[drag-id="${o.getAttribute("drag-id")}"]`);if(r){const o=a.anchor;if(r.removeAttribute("drag-id"),i&&!i.contains(r)&&r.parentElement){const e=a.caption;let t=r.parentElement;if(t.classList.contains("smart-editor-video-container")){const e=t;t=t.parentElement,e.remove(),t.appendChild(r)}i.remove(),i.innerHTML="",t.insertBefore(i,r),i.appendChild(r),e&&i.appendChild(e)}o&&r.parentElement!==o&&(o.innerHTML="",r.parentElement.insertBefore(o,r),o.appendChild(r)),void 0!==a.scrollTop&&(n.scrollTop=a.scrollTop),requestAnimationFrame((()=>e._setResizeFrame(r)));const l=e._resizeFrameObj;if(e._editorVideoItemClick){const t=n.querySelectorAll('.smart-editor-video-white-space, div[pseudo="-webkit-media-controls"]');for(let e=0,a=t.length;e<a;e+=1)t[e].remove();delete e._editorVideoItemClick}(!t||t&&!t.visible)&&l&&l.target&&e._openInlineToolbar(l.target)}return void delete e._dragDetails}e._setSelectionRange();const o=e._getSelectionRange();o&&o.startOffset!==o.endOffset&&(e._handleInlineToolbar(o.startContainer),e._focusEditableElement())}_documentUpHandler(e){const t=this,a=t._resizeFrameObj,o=t.$.inlineToolbar,i=e.originalEvent||e,n=t.shadowRoot||t.isInShadowDOM?i.composedPath()[0]:i.target;if(n&&n.classList.contains("toggle-icon")){if(i.defaultPrevented)return;return n.parentElement.classList.toggle("expanded"),i.stopPropagation(),void i.preventDefault()}if(n&&n.classList.contains("smart-editor-page-label")){const e=n.getAttribute("data-id");if(i.defaultPrevented)return;if(e){const a=t.$.tabs.querySelectorAll(".smart-editor-tab");a[parseInt(e)]&&a[parseInt(e)].click()}return i.stopPropagation(),void i.preventDefault()}if(n&&n.classList.contains("callout-icon")){if(i.defaultPrevented)return;return i.stopPropagation(),i.preventDefault(),n.parentElement.classList.toggle("expanded"),void t._createCallout(n,((e,a)=>{n.textContent=e,n.title=a,t._setSelectionRange(n,1,1)}))}if(n&&n.classList.contains("date-icon")){if(i.defaultPrevented)return;return i.stopPropagation(),i.preventDefault(),n.parentElement.classList.toggle("expanded"),void t._createDatePopup(n,(e=>{const a=new Smart.Utilities.DateTime(e[0]);n.parentElement.lastElementChild.textContent=a.toString("MMMM dd, yyyy"),t._setSelectionRange(n,1,1),t._datePopup.remove()}))}if(t._blockDragDetails&&t._blockDragDetails.line)try{if(t._blockDragDetails.dragItem&&t._blockDragDetails.dropItem){const e=t._blockDragDetails.dragItem.item,a=t._blockDragDetails.dropItem.item;t._blockDragDetails.dropAbove?a.parentElement.insertBefore(e,a):a.nextElementSibling?a.parentElement.insertBefore(e,a.nextElementSibling):a.parentElement.appendChild(e)}delete t._blockDragDetails.dragging,t._blockDragDetails.line.remove(),t._blockDragDetails.line=null,delete t._blockDragDetails}catch(e){delete t._blockDragDetails.dragging,t._blockDragDetails.line.remove(),t._blockDragDetails.line=null,delete t._blockDragDetails}if(a&&(a.resizeDetails&&a.target&&(a.target.removeAttribute("dragged"),t.$.fireEvent("resizeEnd",{target:a.target})),delete a.resizeDetails),t._dragDetails)return t._endInlineToolbarClick(),void delete t._toolbarItemClick;const r=t.$.iframe;if(t.$.container.contains(n)||o&&o.contains(n)||r&&r.contentDocument.body.contains(n)){const e=n.closest(".smart-editor-toolbar-item");e?t._handleToolbarUp(e):t._handleContentUp(i,n)}else if(t.toolbarOnFocus){const e=n.closest(".smart-editor-toolbar-item");e?t.$.toolbar.contains(e)&&t._handleToolbarUp(e):t._handleContentUp(i,n)}t._endInlineToolbarClick(),delete t._searchBarDown,delete t._dragDetails,delete t._toolbarItemClick}_handleToolbarUp(e){const t=this,a=t._toolbarItemClick,o=e.getAttribute("item-type");if(a&&a.toolbarItem===e){const e=a.toolbarItem;"custom"!==o&&(t._handleToolbarItemClick(event,e),t._focusEditableElement())}}_handleContentUp(e,t){const a=this,o=a._inlineToolbarClickObj,i=a.$.toolbarToggleButton,n=a._editorVideoItemClick,r=void 0!==e.button&&2===e.button,l=a._isMacOS&&e.metaKey||e.ctrlKey;if(a._isControlPressed=l,r||t!==i&&!i.contains(t))if(t.classList.contains("smart-editor-toolbar-tab"))a.$.toolbar.hasAttribute("expanded")?t.hasAttribute("checked")||a._selectToolbarTab(t):(a._selectToolbarTab(t),a._toggleSecondaryToolbar(t.hasAttribute("checked")));else if(n&&t.classList.contains("smart-editor-video-container")&&t===n.target)a._setResizeFrame(t),a._focusEditableElement();else if(o){const e=o.target;e&&(e===t||e.contains(t))&&(r?a._setResizeFrame(e):a._handleInlineToolbar(e),a._focusEditableElement())}else if(t&&"LI"===t.nodeName&&t.closest("UL[checklist]")){const e=a._getSelectionRange();e&&0===e.startOffset&&0===e.endOffset&&(t.hasAttribute("checked")?t.removeAttribute("checked"):t.setAttribute("checked",""))}else if(!r&&(a.$.editableElement.contains(t)||"markdown"===a.editMode&&t===a.$.input)){const e=a.$.iframe,t=e?e.contentWindow:window;requestAnimationFrame((()=>{e&&a._setSelectionRange();const o=a._getSelectionRange();if(o instanceof t.Range){let e=o.startContainer;o.startOffset!==o.endOffset&&(a._handleInlineToolbar(e),a._focusEditableElement())}}))}else!r&&t.closest(".smart-editor-search-bar")&&a._handleSearchButtonClick(t.closest(".smart-search-button"));else a._toggleToolbar(a.$.toolbar.hasAttribute("expanded"))}_toggleSecondaryToolbar(e){const t=this,a=t.$.toolbar,o=t.$.toolbarItemsPrimary,i=t.$.toolbarItemsSecondary,n=()=>{a.hasAttribute("expanded")?(i.classList.remove("smart-drop-down"),a.contains(i)||a.appendChild(i),i.style.top=""):(i.classList.add("smart-drop-down"),a.contains(i)&&a.parentElement.insertBefore(i,a.nextElementSibling),i.style.top=o.offsetTop+o.offsetHeight+"px")};if(!e&&(i.classList.add("smart-visibility-hidden"),t.hasAnimation))return i.addEventListener("transitionend",n,{once:!0}),void i.addEventListener("transitioncancel",n,{once:!0});n(),e&&(t._setToolbarGroupHeight(),i.classList.remove("smart-visibility-hidden"))}_setToolbarGroupHeight(){const e=this.$.toolbarItemsSecondary,t=e.children;if(e.style.height="","menu"===this.toolbarMode)return;let a;for(let e=0,o=t.length;e<o;e+=1){const o=t[e].offsetHeight;(void 0===a||a<o)&&(a=o)}void 0!==a&&(e.style.height=a+"px")}_endInlineToolbarClick(){const e=this,t=e._inlineToolbarClickObj;if(t){const a=t.resizeDetails;if(!e._dragDetails&&t.target&&(t.target.removeAttribute("drag-id"),t.dragElement&&t.dragElement.removeAttribute("drag-id")),a&&a.target){if("horizontal"===a.position){const e=a.cells,t=a.table.offsetWidth;e&&e.forEach((e=>{e.style.width&&(e.style.width=100*parseFloat((e.offsetWidth/t).toFixed(2))+"%")}))}e.$.editableElement.removeAttribute("table-cell-resize"),a.target.removeAttribute("resizing"),a.isInlineToolbarOpened&&e._handleInlineToolbar(a.target)}delete e._inlineToolbarClickObj}}_updateToolbarItems(e,t){const a=this;if(a._dragDetails||a.readonly||a.disabled)return;if("markdown"===a.editMode)return void a._updateToolbarItemsMarkdown(e);const o=a._getSelectionRange(),i=a.$.inlineToolbar;let n,r;if(!o)return;if(t||(t=a.$.toolbar),i&&t!==i&&!a.hideInlineToolbar&&i.visible&&(a._updateToolbarItems(e,i),n=!0),t!==a.$.toolbar||a.hideToolbar?n||a.hideInlineToolbar||(r=a._inlineToolbarItemsObj):r=a._toolbarItemsObj,!r)return;const l=a.$.editableElement;let s,d=o.startOffset>o.endOffset?o.endContainer:o.startContainer;if(d&&(d.closest||(d=d.parentElement),d&&d.closest)){e||(e=["alignment","bold","italic","strikethrough","underline","fontsize","fontname","formats","fontcolor","backgroundcolor","orderedlist","unorderedlist","checklist","subscript","superscript"]);for(let o=0,i=e.length;o<i;o+=1){const i=e[o],n=r[i];if(n){let e;if("alignment"===i)e=d.style.textAlign;else if("bold"===i)e=!!a._getNodeFromList(d,["b","strong","h1","h2","h3","h4","h5","h6"]);else if("italic"===i)e=!!a._getNodeFromList(d,["i"]);else if("underline"===i)e=!!a._getNodeFromList(d,["u"]);else if("strikethrough"===i)e=!!a._getNodeFromList(d,["strike"]);else if("fontsize"===i){const t=d.closest(".smart-editor-editable font");t&&(e=t.style.fontSize),e||(s||(s=window.getComputedStyle(d)),e=s.fontSize),e=parseInt(e),isNaN(e)&&(e="")}else if("fontname"===i){const t=d.closest(".smart-editor-editable font");t&&t.hasAttribute("face")?e=t.getAttribute("face"):(s||(s=window.getComputedStyle(d)),e=s.fontFamily.split(",")[0])}else if("formats"===i&&d!==l){const t=n.dataSource;if(e="",t){const o=t.map((e=>e.value));e=a._getNodeFromList(d,o)||""}}else if("fontcolor"===i){const t=d.closest(".smart-editor-editable font");t?e=t.color:(s||(s=window.getComputedStyle(d)),e=s.color)}else if("backgroundcolor"===i)e=a._getNodeBackgroundColor(d),e||(s||(s=window.getComputedStyle(d)),e=s.backgroundColor);else if("orderedlist"===i||"unorderedlist"===i){e=!!d.closest(`.smart-editor-editable ${"orderedlist"===i?"ol":"ul"} li`);const t=d.closest(`.smart-editor-editable ${"orderedlist"===i?"ol":"ul"} li`);t&&t.parentElement&&t.parentElement.hasAttribute("checklist")&&(e=!1)}else if("checklist"===i){e=!!d.closest(`.smart-editor-editable ${"orderedlist"===i?"ol":"ul"} li`);const t=d.closest(`.smart-editor-editable ${"orderedlist"===i?"ol":"ul"} li`);t&&t.hasAttribute("checklist")&&(e=!0),t&&t.parentElement&&!t.parentElement.hasAttribute("checklist")&&(e=!1)}else"subscript"===i?e=!!d.closest(".smart-editor-editable sub"):"superscript"===i&&(e=!!d.closest(".smart-editor-editable sup"));if(!e&&n.dataSource){let t=n.dataSource[0];"fontcolor"===n.name&&(t=n.dataSource[n.dataSource.length-1]),"backgroundcolor"===n.name&&(t=""),t&&(e=t.value||t)}null!==e&&(n.value=e,a._setItemValue(t.querySelector(`.smart-editor-toolbar-item[item-name=${i}]`),n))}}}}_updateToolbarItemsMarkdown(e){const t=this,a=t._getSelectionRange();if(!a||void 0===a.selectionStart)return;const o=a.selectionStart;e||(e=["bold","italic","strikethrough","underline","formats","orderedlist","unorderedlist","subscript","superscript"]);for(let a=0,i=e.length;a<i;a+=1){const i=e[a],n=t._toolbarItemsObj[i];if(n){let e;if("bold"===i)e=!!t._getMarkdownItem(o,"**"),e||(e=!!t._getMarkdownItem(o,"__"));else if("italic"===i)e=!!t._getMarkdownItem(o,"*"),e||(e=!!t._getMarkdownItem(o,"_"));else if("strikethrough"===i)e=!!t._getMarkdownItem(o,"~~");else if("underline"===i)e=!!t._getMarkdownItem(o,"<ins>","</ins>");else if("formats"===i){const a=n.dataSource;if(e="",a){const i=a.map((e=>e.value));e:for(let a=0,n=i.length;a<n;a+=1)if(e=t._getMarkdownFormat(o,i[a]),e&&void 0!==e.formatName){e=e.formatName;break e}}}else"orderedlist"===i||"unorderedlist"===i?e=!!t._getMarkdownFormat(o,i):"subscript"===i?e=!!t._getMarkdownItem(o,"<sub>","</sub>"):"superscript"===i&&(e=!!t._getMarkdownItem(o,"<sup>","</sup>"));if(!e&&n.dataSource){let t=n.dataSource[0];"fontcolor"===n.name&&(t=n.dataSource[n.dataSource.length-1]),"backgroundcolor"===n.name&&(t=""),t&&(e=t.value||t)}null!==e&&(n.value=e,t._setItemValue(t.$.toolbar.querySelector(`.smart-editor-toolbar-item[item-name=${i}]`),n))}}}_getMarkdownItem(e,t,a=t){const o=this.$.input.value,i=o.lastIndexOf(t,Math.max(0,e-1)),n=o.indexOf(a,i>-1?i+t.length:e);if(!(i<0||i>e||n<0||n<e||o.slice(i,e).indexOf("\n")>-1||o.slice(e,n).indexOf("\n")>-1))return" "!==o[i+1]&&o[i-1]!==t&&o[i+1]!==t&&" "!==o[n-1]&&o[n-1]!==t&&o[n+1]!==t?{startIndex:i,endIndex:n+a.length}:void 0}_getMarkdownFormat(e,t){const a=this.$.input.value,o=a.lastIndexOf("\n",Math.max(0,e-1))+1,i=a.slice(o,e);let n;switch(t){case"h1":n="# ";break;case"h2":n="## ";break;case"h3":n="### ";break;case"h4":n="#### ";break;case"h5":n="##### ";break;case"h6":n="###### ";break;case"code":case"pre":n="```";break;case"blockquote":n="> ";break;case"orderedlist":{const e=/^\s*([0-9]+\.{1}\s+)/gs.exec(i);return e?{formatName:t,occuranceIndex:o+e.input.indexOf(e[1])}:void 0}case"unorderedlist":{const e=/^\s*([-+*]{1}\s+)/gs.exec(i);return e?{formatName:t,occuranceIndex:o+e.input.indexOf(e[1])}:void 0}default:n=t+""}const r=i.indexOf(n);if(r>=0&&r<=3&&i.slice(r,n.length)===n)return{formatName:t,occuranceIndex:o+r,markdown:n}}_getNodeFromList(e,t){const a=this.$.editableElement;if(e&&t)for(;e&&e!==a;){const a=e.nodeName.toLocaleLowerCase();if(t.indexOf(a)>-1)return a;e=e.parentElement}}_getNodeBackgroundColor(e){const t=this.$.editableElement;for(;e&&e!==t;){const t=e.style.backgroundColor;if(t)return t;e=e.parentElement}}_editableElementBlurHandler(e){const t=this,a=t.$.editableElement,o=t.$.contentContainer;if(!t._toolbarItemClick&&!o.contains(o.getRootNode().activeElement)){const i=t._value,n=()=>{o.removeAttribute("required"),t._requiredMessage&&(t.hideMessage(t._requiredMessage),delete t._requiredMessage)},r=t._getCurrentValue();if(t.required){const e=t.$.editableElement;"markdown"===t.editMode&&!t.$.input.value||"markdown"!==t.editMode&&!e.textContent&&!e.querySelectorAll("img, table").length?(o.hasAttribute("required")||o.setAttribute("required",""),t._requiredMessage||(t._requiredMessage=t.showMessage(t.localize("requiredMessage"),{autoClose:!1,iconType:"error"}))):n()}else n();if(i!==r){if(t.enablePages){const e=t.pages[t.pageIndex];e&&(e.innerHTML=r)}t.$.fireEvent("change",{oldValue:i,value:r}),t.name&&e.target===a&&"markdown"!==t.editMode&&(t.$.input.value=t._getInputValue(a.innerHTML.trim()))}t.removeAttribute("focus"),t.removeAttribute("aria-activedescendant")}t._autoSuggest&&t._autoSuggest.remove()}_editableElementFocusHandler(e){const t=this,a=t.editMode,o="markdown"===a?t.$.input:t.$.editableElement;let i=t._autoSaveObj;t.setAttribute("focus",""),e.target.id&&t.setAttribute("aria-activedescendant",e.target.id),t._value=t._getCurrentValue(),t.autoSave?(i||(i=t._autoSaveObj={}),clearInterval(i.interval),i.interval=setInterval((()=>{o.getRootNode().activeElement!==o&&clearInterval(i.interval),window.localStorage.setItem("smartEditor"+t.id,"markdown"===a?o.value:o.innerHTML)}),t.autoSaveInterval)):i&&(clearInterval(i.interval),delete t._autoSaveObj)}_inputChangeEvent(e){e.stopPropagation()}_updateOnInputChange(e){const t=this,a=t.$.editableElement,o=e.target,i=t.$.input,n=o.classList.contains("smart-search-input"),r=()=>{const e=l===i?i.value:t.$.editableElement.innerHTML;void 0!==s&&e!==s&&t.$.fireEvent("changing",{value:e,oldValue:t._changingValue})};if(t._editorBlocks=t.$.editableElement.querySelectorAll(".smart-editor-block"),"paste"===e.type&&a.contains(o)){const a=e.clipboardData;if(a&&a.types.length){const o=a.types.indexOf("text/html")>-1?"text/html":"text/plain",[i,n]=["\x3c!--StartFragment--\x3e","\x3c!--EndFragment--\x3e"];let r=a.getData(o);e.preventDefault();let l=(e.clipboardData||e.originalEvent.clipboardData).items,s=null;for(let e=0;e<l.length;e++)0===l[e].type.indexOf("image")&&(s=l[e].getAsFile());if(null!==s){const e=r;let o=!1;if((e.includes('xmlns:o="urn:schemas-microsoft-com:office:office"')||e.includes('xmlns:x="urn:schemas-microsoft-com:office:excel"')||e.includes('xmlns="urn:schemas-microsoft-com:office:word"')||e.includes('xmlns:w="urn:schemas-microsoft-com:office:word"')||e.includes('xmlns:v="urn:schemas-microsoft-com:vml"')||e.includes('ProgId="Excel.Sheet"')||e.includes("application/vnd.oasis.opendocument.spreadsheet")||e.includes("LibreOffice Calc"))&&(o=!0),!o){let e=new FileReader;return e.onload=function(e){t.$.editableElement.getRootNode().execCommand("insertHTML",!1,`<img src="${e.target.result}"/>`)},void e.readAsDataURL(s)}{const e=a.getData("text/html"),t=a.getData("text/plain");if(e&&e.includes("<table")){const t=document.createElement("div");t.innerHTML=e;const a=t.querySelector("table"),o=document.createElement("table");if(a){const e=[];for(let t of a.rows){const a=document.createElement("tr");o.appendChild(a);const i=[];for(let e of t.cells)a.appendChild(e.cloneNode(!0)),i.push(e.textContent.trim());e.push(i)}r=o.outerHTML}}else{const e=t.split("\n").map((e=>e.split("\t")));r=JSON.stringify(e,null,2)}}}r.indexOf(i)>-1&&r.indexOf(n)>-1&&(r=r.slice(r.indexOf(i),r.indexOf(n))),t._handlePasteAction(r,{advanced:!0,value:t.pasteFormat},o)}}const l=a.getRootNode().activeElement,s=t._changingValue;if(!t.$.contentContainer.hasAttribute("split-mode")){if(clearTimeout(t._refreshTimeout),delete t._refreshTimeout,n){const a=t.findAndReplaceTimeout,o=e.key;if(clearTimeout(t._findAndReplaceTimeout),!o||"enter"===o.toLowerCase())return;return void(a?t._findAndReplaceTimeout=setTimeout((()=>t._applySearching(e.target.value)),a):t._applySearching(e.target.value))}const a=t._resizeFrameObj?t._resizeFrameObj.target:void 0;return a&&!a.parentElement&&(t._setResizeFrame(),t._closeToolbar()),void r()}r(),clearTimeout(t._refreshTimeout);let d=t.$.input.value;t._refreshTimeout=setTimeout((()=>{clearTimeout(t._refreshTimeout),"markdown"===t.editMode?t.$.editableElement.innerHTML=window.marked?window.marked(d):d:l===i?t.$.editableElement.innerHTML=t._getInputValue(d,!0):t.$.input.value=t._getInputValue(t.$.editableElement.innerHTML.trim())}),t.splitModeRefreshTimeout)}_editableElementWheelHandler(){const e=this.$.inlineToolbar;this._setResizeFrame(),e&&e.visible&&e.close()}_getCaretCoordinates(e){const t=e.getBoundingClientRect(),a=window.getSelection().getRangeAt(0).getClientRects()[0];let o={};const i=this.offset(e);return a&&t&&(o.x=i.left+a.left-t.left,o.y=i.top+a.top-t.top),o}_insertWordAfterCurrentWord(e,t=!0){const a=this,o=window.getSelection();if(!o||0===o.rangeCount)return;let i=o.getRangeAt(0),n=o.focusNode,r=o.focusOffset;if(n.nodeType!==Node.TEXT_NODE){if(!(n.childNodes.length>0))return;if(n=n.childNodes[r]||n,n.nodeType!==Node.TEXT_NODE)return}const l=n.textContent,s=l.substring(0,r);let d=s.match(/(\w+)$/),c=0;if(t&&!d&&(d=s.trimEnd().match(/(\w+)$/),c=1),!d){if(t)return;const a=document.createTextNode(e+" ");return i.insertNode(a),i.setStartAfter(a),i.collapse(!0),o.removeAllRanges(),void o.addRange(i)}const m=d.index+d[0].length+c,u=l.substring(0,m);let p=l.substring(m);const b=document.createTextNode(u);if(t&&p.trim().startsWith(e.trim()))return;let h=document.createTextNode(""+e);const g=document.createTextNode(""+p);if(t){const e=document.createElement("span");e&&(e.classList.add("smart-auto-suggest"),e.style.color="var(--smart-disabled)"),e.appendChild(h);const t=n.parentNode;t.insertBefore(b,n),t.insertBefore(e,n),t.insertBefore(g,n),t.removeChild(n),a._autoSuggest=e}else{const e=n.parentNode;e.insertBefore(b,n),e.insertBefore(h,n),e.removeChild(n)}let f=t?0:1+e.length;const v=document.createRange();v.setStart(h,f),v.collapse(!0),o.removeAllRanges(),o.addRange(v)}_closeInlinePopups(){const e=this;e._callout&&(e._callout.remove(),delete e._callout),e._datePopup&&(e._datePopup.remove(),delete e._datePopup),e._pagePopup&&(e._pagePopup.remove(),delete e._pagePopup),e._aiPopup&&(e._aiPopup.remove(),delete e._aiPopup)}_editableElementKeyDownHandler(e){const t=this,a=t.$.editableElement,o=t.$.input,i=e.target.getRootNode().activeElement,n=e.key.toLowerCase(),r=t._isMacOS&&e.metaKey||e.ctrlKey;if(t._isControlPressed=r,!t.disabled&&!t.readonly){if(t._closeInlinePopups(),"blockHtml"===t.editMode&&t._setSortable(),"markdown"!==t.editMode)if(t._autoSuggestTimer&&clearTimeout(t._autoSuggestTimer),t._autoSuggest&&"Tab"===e.key&&e.preventDefault(),/^[a-zA-Z]$/.test(n)||" "===n||"backspace"===n||"delete"===n||"tab"===n){let a=200;if(("backspace"===n||"delete"===n)&&t._isAllContentSelected())if("blockHtml"===t.editMode){const a=t._createEditorBlock(!1,!1,"");t.innerHTML=t.value=a.outerHTML,e.preventDefault(),e.stopPropagation()}else t.$.editableElement.innerHTML="";if("blockHtml"===t.editMode){const e=t._currentBlock;e&&(e.removeAttribute("empty"),e.removeAttribute("data-placeholder"))}t._incrementalSearch||(t._incrementalSearch=""),t._incrementalSearch=t._incrementalSearch.trimStart(),"tab"===n?(a=0,t._incrementalSearch="",t._autoSuggest&&t._autoSuggest.textContent.length>=3&&t._autoSuggest.parentNode&&(e.preventDefault(),e.stopPropagation())):t._autoSuggest&&t._autoSuggest.remove(),/^[a-zA-Z]$/.test(n)||" "===n?t._incrementalSearch+=n:"backspace"===n&&(t._incrementalSearch=t._incrementalSearch.substring(0,t._incrementalSearch.length-1)),t._incrementalSearchTimer&&clearTimeout(t._incrementalSearchTimer),t._incrementalSearchTimer=setTimeout((()=>{t._incrementalSearch=""}),2e3);let o=!0;(e.ctrlKey||e.altKey)&&(o=!1),o&&(t._autoSuggestTimer=setTimeout((()=>{const a=t._getCurrentWord();if("Tab"===e.key){if(t._autoSuggest){const e=t._autoSuggest.textContent;t._autoSuggest.previousSibling&&(t._autoSuggest.previousSibling.textContent+=e),t._autoSuggest&&t._autoSuggest.remove()}return}let o;t._autoSuggest&&t._autoSuggest.remove();let i=t._collocations;if(t._bigramStore&&(i=i.concat(t._bigramStore)),i&&t._incrementalSearch.length>=2){t._incrementalSearch=t._incrementalSearch.toLowerCase();for(let e in i){const a=i[e].toLowerCase();if(a.startsWith(t._incrementalSearch)){o=a.substring(t._incrementalSearch.length);break}}let e="",a=(()=>{const e=window.getSelection();if(!e.rangeCount)return"";const t=e.getRangeAt(0).cloneRange();if(!t.collapsed)return"";t.setStart(t.startContainer,0);const a=t.toString().trim().split(/\s+/);return a.length>=2?a[a.length-2]:""})();if(a&&a.length>t._incrementalSearch.length){a=a.toLowerCase();for(let o in i){const n=i[o].toLowerCase();if(n.startsWith(a+" "+t._incrementalSearch)){e=n.substring(a.length+1+t._incrementalSearch.length);break}}e&&(o=e)}}if(o)setTimeout((()=>{t._insertWordAfterCurrentWord(o,!0)}),100);else if(a.length>=3&&" "!==n&&"backspace"!==n&&"delete"!==n){let e="";t._autoSuggest&&t._autoSuggest.remove();for(let o of t._dictionary)if(o.toLowerCase().startsWith(a.toLowerCase())&&o.length>a.length){e=o.substring(a.length),t._insertWordAfterCurrentWord(e);break}}else t._autoSuggest&&(t._autoSuggest.remove(),delete t._autoSuggest)}),a))}else t._incrementalSearch="",t._autoSuggest&&("Tab"===e.key?e.preventDefault():t._autoSuggest.remove());switch(n){case"/":if(!t._filterSortableMenuInput&&"blockHtml"===t.editMode){const o=t._getCaretCoordinates(a);e.pageX=o.x,e.pageY=o.y;let i=t._getSelectionRange().endContainer;for(;i&&(!i.classList||!i.classList.contains("smart-editor-block"));)i=i.parentElement;const n=i&&i.hasAttribute("empty");return t._currentBlock=i,t._renderSortableMenu(e,n,!0),e.preventDefault(),void e.stopPropagation()}break;case"@":if(t.users)return void setTimeout((()=>{const o=t._getCaretCoordinates(a);e.pageX=o.x+15,e.pageY=o.y;const i=[...t.users].map((e=>({label:e.label||e.name,id:e.value||e.id,value:"userProperties",image:e.image,color:e.color})));i.length&&t._openContextMenu(e,i,!0)}),50);break;case"a":if(!r){t._changingValue=i===a?a.innerHTML:o.value;break}if(i.classList.contains("smart-editor-image-caption"))return e.preventDefault(),t._setSelectionRange(i),void t._handleInlineToolbar(t._getSelectionRange().startContainer);if(t._tableCell)return e.preventDefault(),t._setSelectionRange(t._tableCell),void t._handleInlineToolbar(t._getSelectionRange().startContainer);break;case"backspace":case"delete":{const n=t._resizeFrameObj?t._resizeFrameObj.target:void 0;n&&("img"===n.nodeName.toLowerCase()||n.classList.contains("smart-editor-video-container"))&&(e.preventDefault(),t._deleteResizeFrameTarget(n)),t._changingValue=i===a?a.innerHTML:o.value;break}case"enter":if(!t.disableSearchBar){const a=t._searchToolbar;a&&!a.classList.contains("smart-visibility-hidden")&&(e.preventDefault(),t._highlightSearchResult(!e.shiftKey));const o=t._getSelectionRange();if(o&&o.startContainer){let e=o.startContainer;if("#text"===e.nodeName&&(e=e.parentElement),"LI"===e.nodeName||"LI"===e.parentElement.nodeName){const t=e.closest("ul");if(t&&t.hasAttribute("checklist")){const t=e.hasAttribute("checked");e.removeAttribute("checked"),setTimeout((()=>{t&&e.setAttribute("checked","")}))}}}if("blockHtml"===t.editMode){const a=t._createEditorBlock(e.altKey,!0);a&&"boolean"==typeof a?e.preventDefault():a&&(e.preventDefault(),e.stopPropagation(),a.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"}),t._currentBlock=a,t.scrollTop=0)}}break;case"escape":i===a?t._closeToolbar():i.classList.contains("smart-search-input")&&t._closeSearchToolbar();break;case"tab":t.enableTabKey&&(e.preventDefault(),t._handleTabInsert());break;case"alt":return;default:t._handleToolbarShortcuts(e,i)}t._closeToolbar()}}_initEditorBlocks(){const e=this.querySelectorAll("[data-block]");for(let t=0;t<e.length;t++){const a=e[t];a.setAttribute("data-block-id",Smart.Utilities.Core.createGUID()),a.classList.add("smart-editor-block"),a.hasAttribute("data-block-2")&&a.classList.add("smart-editor-two-columns"),a.hasAttribute("data-block-n")&&a.classList.add("smart-editor-n-columns-block")}}_refreshEditorBlockPlaceholder(){const e=this,t=t=>{const a=[...e.querySelectorAll(".smart-editor-block"),...e.querySelectorAll(".smart-editor-format-block")];for(let o=0;o<a.length;o++){const i=a[o];i.removeAttribute("empty"),i.removeAttribute("data-placeholder"),(""===i.textContent.trim()&&document.activeElement===i||t&&i===t.target&&""===i.textContent.trim())&&(i.setAttribute("empty",""),i.setAttribute("data-placeholder",e.localize("newLinePlaceholder")))}};t(),e.$.editableElement.onpointerdown=e.$.editableElement.oninput=e=>{t(e)},e.$.editableElement.onpaste=e=>{setTimeout((()=>{t(e)}),100)}}_refreshEditorBlockCursor(e){const t=this;(e=>{const a=document.createRange(),o=window.getSelection();a.setStart(e,0),a.collapse(!0),o.removeAllRanges(),o.addRange(a),""===e.textContent.trim()&&(e.setAttribute("data-placeholder",t.localize("newLinePlaceholder")),e.setAttribute("empty","")),""!==e.textContent.trim()&&(e.removeAttribute("empty"),e.removeAttribute("data-placeholder"))})(e)}_createEditorBlock(e,t,a){const o=this,i=o.$.editableElement;let n=window.getSelection(),r=n.anchorNode;for(;r&&r!==o.$.editableElement;)r=r.parentNode;if(!r){const e=o._createInsertionMarker();i.appendChild(e),o._setSelectionRange(e,0,0),n=window.getSelection(),e.id="",e.remove()}o._refreshEditorBlockPlaceholder();let l=n.anchorNode;for(;l&&l!==i;){if(("LI"===l.nodeName||"TD"===l.nodeName)&&""!==l.textContent.trim()&&!o._isControlPressed)return;l=l.parentNode}for(l=n.anchorNode;l&&l!==i&&(!l.classList||!l.classList.contains("smart-editor-block"));)l=l.parentNode;l&&l!==i&&l.classList&&!l.classList.contains("smart-editor-block")&&!event.ctrlKey&&(l=l.closest(".smart-editor-block"));const s=document.createElement("div");s.innerHTML="",s.setAttribute("data-block-id",Smart.Utilities.Core.createGUID()),s.setAttribute("data-block",""),s.classList.add("smart-editor-block");const d=n.rangeCount>0?n.getRangeAt(0):null;let c=d?d.startContainer:null;if(t&&d){const e=d.cloneRange();e.setEndAfter(c);const t=e.extractContents();s.appendChild(t)}""===s.textContent.trim()&&(s.innerHTML="");let m=n.anchorNode;if(m&&3===m.nodeType&&(m=m.parentElement),m){const e=m.closest(".editable-list");if(e&&!o._isControlPressed)if("LABEL"===m.nodeName){if(""!==s.textContent.trim()){const t=e.querySelector(".nested"),a=document.createElement("div");return a.innerHTML=s.innerHTML,t.insertBefore(a,t.firstElementChild),o._setSelectionRange(a,0,0),!0}}else if(m.closest(".nested")&&"LI"!==m.nodeName){const e=document.createElement("div");return e.innerHTML=s.innerHTML,""===s.textContent.trim()&&(e.innerHTML="&nbsp;"),m.nextElementSibling?m.parentElement.insertBefore(e,m.nextElementSibling):m.parentElement.appendChild(e),o._setSelectionRange(e,0,0),!0}}if(l&&l!==i&&l.parentNode===i)e?i.insertBefore(s,l):i.insertBefore(s,l.nextSibling),o._refreshEditorBlockCursor(s);else if(l&&n.anchorNode&&n.anchorNode.parentElement!==i){let t=n.anchorNode.parentElement;if(t&&!o.$.editableElement.contains(t)&&(t=o.$.editableElement),"H1"===t.nodeName||"H2"===t.nodeName||"H3"===t.nodeName||"H4"===t.nodeName||"H5"===t.nodeName||"H6"===t.nodeName||"UL"===t.nodeName||"OL"===t.nodeName||"BLOCKQUOTE"===t.nodeName||"PRE"===t.nodeName||"LABEL"===t.nodeName||"P"===t.nodeName){const a=t.closest(".smart-editor-block");let n=t,r=null;for(;n;){if(n.classList.contains("smart-editor-n-columns-block")){r=n;break}n=n.parentElement}r?r.appendChild(s):e&&a?a.parentElement.insertBefore(s,a):a&&a.nextSibling?a.parentElement.insertBefore(s,a.nextSibling):t.nextSibling?t.parentElement.insertBefore(s,t.nextSibling):i.appendChild(s),o._refreshEditorBlockCursor(s),""!==s.textContent.trim()&&(s.removeAttribute("empty"),s.removeAttribute("data-placeholder"))}else{let a=t,r=null;for(;a;){if(a.classList.contains("smart-editor-n-columns-block")){r=a;break}a=a.parentElement}if(t&&t.nodeType!==Node.TEXT_NODE&&t.classList.contains("smart-editor-n-columns-block"))t.appendChild(s);else if(t&&t.parentElement&&t.parentElement.classList.contains("smart-editor-n-columns-block"))t.parentElement.appendChild(s);else if(r)r.appendChild(s);else{let t=n.anchorNode;if(t.nodeType===Node.TEXT_NODE)for(;t&&t.nodeType!==Node.TEXT_NODE;)t=t.parentNode;if(t&&t.nodeType!==Node.TEXT_NODE){const a=t&&t.classList.contains("smart-editor-block")?t:t.closest(".smart-editor-block");a?e&&t?a.parentElement.insertBefore(s,a):t&&t.nextSibling?a.parentElement.insertBefore(s,a.nextSibling):a.appendChild(s):i.appendChild(s)}else t&&t.nodeType===Node.TEXT_NODE&&t.parentElement&&t.parentElement.closest(".smart-editor-block")&&t.parentElement.parentElement?t.parentElement.parentElement.insertBefore(s,t.parentElement.nextSibling):i.appendChild(s)}o._refreshEditorBlockCursor(s)}}else l&&"DIV"===l.nodeName&&l.classList.contains("smart-editor-block")?e&&l?i.insertBefore(s,l):l&&l.nextSibling&&i.insertBefore(s,l.nextSibling):(s.innerHTML="",i.appendChild(s),o._refreshEditorBlockCursor(s));return a&&(s.innerHTML=a,s.removeAttribute("empty"),s.removeAttribute("data-placeholder")),s}_handleToolbarShortcuts(e,t){const a=this,o=a.$.editableElement,i=a.$.input,n=e.key,r=a._isMacOS&&e.metaKey||e.ctrlKey;if(!r)return void(a._changingValue=t===o?o.innerHTML:i.value);a._changingValue=t===o?o.innerHTML:i.value;const l=a._resizeFrameObj;let s;switch(l&&l.target&&(s=l.target),n.toLocaleLowerCase()){case"b":e.preventDefault(),a._handleTextDecorations("bold");break;case"c":r&&s&&a._handleImageCopy(s);break;case"x":r&&s&&a._handleImageCut(s);break;case"k":e.preventDefault(),a._openWindow({name:"hyperlink"});break;case"i":e.shiftKey?(e.preventDefault(),a._openWindow({name:"image"},s)):(e.preventDefault(),a._handleTextDecorations("italic"));break;case"e":e.shiftKey?(e.preventDefault(),a._openWindow({name:"table"},s)):(e.preventDefault(),a._updateToolbarTarget({name:"alignment",value:"center"}));break;case"u":e.shiftKey?(e.preventDefault(),a._handleTextCase("uppercase")):(e.preventDefault(),a._handleTextDecorations("underline"));break;case"s":e.shiftKey&&(e.preventDefault(),a._handleTextDecorations("strikethrough"));break;case"l":e.shiftKey?(e.preventDefault(),a._handleTextCase("lowercase")):(e.preventDefault(),a._updateToolbarTarget({name:"alignment",value:"left"}));break;case"+":e.shiftKey&&(e.preventDefault(),a._handleSubSuperScript("superscript"));break;case"=":e.shiftKey?(e.preventDefault(),a._handleSubSuperScript("superscript")):(e.preventDefault(),a._handleSubSuperScript("subscript"));break;case"]":e.preventDefault(),a._handleIndentation("indent");break;case"[":e.preventDefault(),a._handleIndentation("outdent");break;case"h":if(e.shiftKey){const t=a._toolbarItemsObj.sourcecode;t&&(t.value=void 0===t.value||!t.value),e.preventDefault(),a._handleSourceCodeMode()}break;case"f":if(e.shiftKey){const t=a._toolbarItemsObj.fullscreen;t&&(t.value=void 0===t.value||!t.value),e.preventDefault(),a._handleFullScreenMode()}else(!r||a.disableSearchBar||"html"!==a.editMode||o.classList.contains("smart-hidden"))&&(!r||a.disableSearchBar||"blockHtml"!==a.editMode||o.classList.contains("smart-hidden"))||(e.preventDefault(),a._openSearchBar());break;case"j":e.preventDefault(),a._updateToolbarTarget({name:"alignment",value:"justify"});break;case"r":e.shiftKey?(e.preventDefault(),a._handleClearFormat()):(e.preventDefault(),a._updateToolbarTarget({name:"alignment",value:"right"}));break;case"o":e.shiftKey?(e.preventDefault(),a._handleList("orderedlist")):e.altKey&&(e.preventDefault(),a._handleList("unorderedlist"))}(()=>{const e=a._changingValue,t=a.$.input,o=a.$.editableElement.getRootNode().activeElement===t?t.value:a.$.editableElement.innerHTML;void 0!==e&&o!==e&&a.$.fireEvent("changing",{value:o,oldValue:a._changingValue})})()}_editableElementMoveHandler(e){const t=this,a=t.$.editableElement,o=e.originalEvent||e,i=o.clientX,n=o.clientY,r=t.shadowRoot||t.isInShadowDOM?o.composedPath()[0]:o.target;if(e.stopPropagation(),!r||!r.closest||t._isMobile||"false"===a.getAttribute("contenteditable"))return void a.removeAttribute("table-cell-resize");const l=t._inlineToolbarClickObj;if(l&&l.resizeDetails||t._dragDetails)return;const s=r.tagName.toLowerCase();if(!r.closest(".smart-editor-editable table")||"td"!==s&&"th"!==s)return void a.removeAttribute("table-cell-resize");const d=r.getBoundingClientRect();n<d.bottom+5&&n>d.bottom-5?a.setAttribute("table-cell-resize","vertical"):i<d.right+5&&i>d.right-5&&r.nextElementSibling?a.setAttribute("table-cell-resize","horizontal"):a.removeAttribute("table-cell-resize")}_focusEditableElement(){const e=this,t=e.$.iframe,a=e.editMode;let o=e.$.editableElement;if(("markdown"===a||o.classList.contains("smart-hidden"))&&(o=e.$.input),t&&t.focus({preventScroll:!0}),o.getRootNode().activeElement!==o){const i=e._getSelectionRange(),n=o.scrollTop,r=t?t.contentWindow:window;if(o.focus({preventScroll:!0}),e._isSafari&&n&&(o.scrollTop=n),"markdown"===a||o.classList.contains("smart-hidden"))return void(void 0!==i.selectionStart&&e._setSelectionRange(i.selectionStart,i.selectionEnd));if(i instanceof r.Range){const e=(t?t.contentWindow:window).getSelection();e.removeAllRanges(),e.addRange(i)}}}_getTextFromCarret(){const e=this._getSelectionRange(),t=e.startContainer,a=t.textContent;let o,i;if(!e.toString()&&a.length>0&&a.indexOf(" ")>-1){const t=a.slice(0,e.startOffset).lastIndexOf(" ")+1;let n=a.slice(e.endOffset).indexOf(" ");n<0&&(n=a.length-1),o=t>-1?t:e.startOffset,i=Math.max(e.endOffset,e.endOffset+n)}else o=0,i=t.length;return{selectionStartIndex:o,selectionEndIndex:i}}_handleSearchButtonClick(e){const t=this;if(!e)return;const a=e.classList;a.contains("smart-search-button")&&(a.contains("prev")?t._highlightSearchResult():a.contains("next")?t._highlightSearchResult(!0):a.contains("close")&&t._closeSearchToolbar())}_highlightSearchResult(e){const t=this,a=t.$.contentContainer,o=t.$.editableElement.querySelectorAll(".find-and-replace-match"),i=a.querySelector(".smart-search-input-container"),n=o.length;for(let a=0,r=n;a<r;a+=1){const r=o[a];if(r.classList.contains("selected")){const l=e?Math.min(n-1,a+1):Math.max(0,a-1),s=o[l];return s&&(s.classList.add("selected"),i.setAttribute("selected",l+1),t._scrollToMarker(s)),void(s!==r&&r.classList.remove("selected"))}}}_handleToolbarItemClick(e,t){const a=this;if(!t)return;const o=a.$.inlineToolbar,i=a._toolbarItemClick,n=t.getAttribute("item-type"),r=t.getAttribute("item-name");let l,s;a._changingValue||(a._changingValue=a.$.editableElement.innerHTML),e&&(l=e.originalEvent||e,s=a.shadowRoot||a.isInShadowDOM?l.composedPath()[0]:l.target);const d=()=>{const e=a._changingValue,t=a.$.input,o=a.$.editableElement.getRootNode().activeElement===t?t.value:a.$.editableElement.innerHTML;void 0!==e&&o!==e&&a.$.fireEvent("changing",{value:o,oldValue:a._changingValue})};if("custom"!==n&&l&&(a.hasRippleAnimation&&"delimiter"!==n&&Smart.Utilities.Animation.Ripple.animate(s,l.pageX,l.pageY),i&&i.callback))return i.callback.call(a,t,i.target),a.$.fireEvent("toobarItemClick",{value:r,originalEvent:l}),void d();a.$.fireEvent("actionStart",{name:r}).defaultPrevented||(a._handleToolbarItemAction(t),a._closeToolbarItemDropDown(a.$.inputPopup),a._closeToolbarItemDropDown(a.$.colorInputPopup),o&&o.close(),l&&(a.$.fireEvent("toobarItemClick",{value:r,originalEvent:l}),d()),r&&a.$.fireEvent("actionEnd",{name:r}))}_handleToolbarItemAction(e){const t=this,a=t._toolbarItemClick;if(!e)return;const o=e.getAttribute?e.getAttribute("item-type"):e.type,i=e.getAttribute?e.getAttribute("item-name"):e.name;if("custom"!==o){switch(t._changingValue||(t._changingValue=t.$.editableElement.innerHTML),i){case"ai":{const a=t._getAIMenuItems();let o=t.$.inlineToolbar;if(o&&o.classList.contains("smart-editor-ai-menu")&&o.hasAttribute("visible"))return void t._closeContextMenu();setTimeout((()=>{let o=e;if(!e.offsetHeight||!(e=>{if(!e)return!1;for(;e;){const t=window.getComputedStyle(e);if("none"===t.display||"hidden"===t.visibility||0===parseFloat(t.opacity))return!1;e=e.parentElement}return!0})(e)){const e=window.getSelection();if(e){let t=e.focusNode;t&&("#text"===t.nodeName&&(t=t.parentElement),o=t)}}t._openContextMenu({target:o},a,!0,"smart-editor-ai-menu",o)}),50);break}case"bold":case"italic":case"underline":case"strikethrough":t._handleTextDecorations(i);break;case"clearformat":t._handleClearFormat();break;case"redo":case"undo":t._handleUndoRedo(i);break;case"lowercase":case"uppercase":t._handleTextCase(i);break;case"backgroundcolor":t._handleBackgroundColor(e.getAttribute("item-value"));break;case"fontcolor":t._handleFontColor(e.getAttribute("item-value"));break;case"findandreplace":case"editlink":t._openWindow(e);break;case"openlink":{const a=t.$.inlineToolbar;if(a&&a.contains(e)){const e=a.selector;let t;e.nodeName!==Node.TEXT_NODE&&(t=e.closest(".smart-editor-editable a")),t&&window.open(t.href,t.target)}break}case"caption":{if(!a)break;const e=a.target;if(e&&"img"===e.nodeName.toLowerCase()){const a=e.closest(".smart-editor-image-container");let o;a&&a.querySelector(".smart-editor-image-caption")||(o=t.localize("captionPlaceholder")),t._handleImgCaption(e,{caption:o,focusCaption:!0})}else if(e.classList.contains("smart-editor-video-container")){const a=e.querySelectorAll(".smart-editor-video-container > video, .smart-editor-video-container > iframe");let o;e.querySelector(".smart-editor-image-caption")||(o=t.localize("captionPlaceholder")),t._handleVideoCaption(a[0]||a[1],{caption:o,focusCaption:!0})}break}case"cut":case"copy":case"paste":t._handleClipboardAction(i);break;case"delete":t._resizeFrameObj&&t._resizeFrameObj.target?t._deleteResizeFrameTarget(a.target):t._handleTextDelete();break;case"removelink":a&&t._handleLinkRemove(a.target);break;case"tableheader":case"tablerows":case"tablecolumns":case"tablevalign":case"tablestyle":t._handleTableToolbarAction(e);break;case"sourcecode":t._handleSourceCodeMode(e);break;case"splitmode":t._handleSplitMode(e);break;case"fullscreen":t._handleFullScreenMode(e);break;case"orderedlist":case"unorderedlist":t._handleList(i);break;case"checklist":t._handleCheckList("unorderedlist");break;case"indent":case"outdent":t._handleIndentation(i);break;case"subscript":case"superscript":t._handleSubSuperScript(i);break;case"print":t._handlePrint();break;default:t._inlineToolbarItemsObj?t._updateEditorViaWindow(t._inlineToolbarItemsObj[i]):t._toolbarItemsObj&&t._updateEditorViaWindow(t._toolbarItemsObj[i])}(()=>{const e=t._changingValue,a=t.$.input,o=t.$.editableElement.getRootNode().activeElement===a?a.value:t.$.editableElement.innerHTML;void 0!==e&&o!==e&&t.$.fireEvent("changing",{value:o,oldValue:t._changingValue})})()}}_handleCommonToolbarAction(e,t){const a=this;if(a._changingValue=a.$.editableElement.innerHTML,"html"===a.editMode||"blockHtml"===a.editMode){const o=a._getSelectionRange(),i=a.$.iframe,[n,r]=i?[i.contentDocument,i.contentWindow]:[document,window];let l,s=o.startContainer;if(!s)return;const d=e=>"string"==typeof e?("removeFormat"===e&&a.removeStylesOnClearFormat&&a._removeNodeStyles(o.commonAncestorContainer),n.execCommand(e)):"object"==typeof e?n.execCommand(e.name,!1,e.value):void 0;if(o.startOffset===o.endOffset&&s.nodeType===Node.TEXT_NODE){const{selectionStartIndex:e,selectionEndIndex:t}=a._getTextFromCarret();l=o.startOffset-e,a._setSelectionRange(s,e,t)}d(e)&&void 0!==l&&a._setSelectionRange(r.getSelection().focusNode,l,l),t&&a._updateToolbarItems(t)}(()=>{const e=a._changingValue,t=a.$.input,o=a.$.editableElement.getRootNode().activeElement===t?t.value:a.$.editableElement.innerHTML;void 0!==e&&o!==e&&a.$.fireEvent("changing",{value:o,oldValue:a._changingValue})})()}_handleClearFormat(){this._handleCommonToolbarAction("removeFormat")}_handleFontName(e){this._handleCommonToolbarAction(e)}_handleFontSize(e){const t=this;if("markdown"===t.editMode)return;const a=t._getSelectionRange();let o,i=a.startContainer;if(i){if(a.startOffset===a.endOffset){if(i.nodeType!==Node.TEXT_NODE){const o=document.createElement("font");return a.insertNode(o),t._setSelectionRange(o),void(o.style.fontSize=e.value+"px")}{const{selectionStartIndex:e,selectionEndIndex:n}=t._getTextFromCarret();o=a.startOffset-e,t._setSelectionRange(i,e,n)}}if((t.$.editableElement.getRootNode()||document).execCommand("fontSize",!1,3)){const i=t.$.iframe,n=i?i.contentWindow:window;if(a.commonAncestorContainer.closest){const t=a.commonAncestorContainer.querySelectorAll("font[size]");for(let a=0,o=t.length;a<o;a+=1){const o=t[a];o.removeAttribute("size"),o.style.fontSize=e.value+"px"}}else{const t=n.getSelection().focusNode;if(!t)return;const a=t.closest?t.closest(".smart-editor-editable font"):t.parentElement;"font"===a.nodeName.toLowerCase()&&(a.removeAttribute("size"),a.style.fontSize=e.value+"px")}void 0!==o&&t._setSelectionRange(n.getSelection().focusNode,o,o)}}}_handleFormats(e){const t=this;if("markdown"===t.editMode){let a;switch(e.value){case"h1":a="#";break;case"h2":a="##";break;case"h3":a="###";break;case"h4":a="####";break;case"h5":a="#####";break;case"h6":a="######";break;case"code":case"pre":a="```\n\n```";break;case"blockquote":a=">";break;case"p":a="";break;default:a=e.value}const o=e.dataSource,i=t.$.input.selectionStart;if(o){const e=o.map((e=>e.value));for(let a=0,o=e.length;a<o;a+=1){const o=t._getMarkdownFormat(i,e[a]);if(o&&void 0!==o.formatName){t._removeMarkDown(o.markdown,o.occuranceIndex,!0);break}}}return void(0===a.indexOf("#")||0===a.indexOf(">")?(a+=" ",t._insertMarkDown(a,t.$.input.selectionStart+a.length,!0)):t._insertMarkDown(a,t.$.input.selectionStart+a.length/2))}let a=t._getSelectionRange().startContainer;if(a){if("blockHtml"===t.editMode){const o=a.textContent;a.textContent="";const i=getSelection().anchorNode.parentElement.closest(".smart-editor-block");t._currentBlock=i||t._createEditorBlock(!1,!1);const n=t._createInsertionMarker();let r=t._getSelectionRange();const l=t._currentBlock;if(!l)return void t.$.editableElement.getRootNode().execCommand("formatBlock",!1,e.value);l.appendChild(n),l.removeAttribute("empty"),l.removeAttribute("data-placeholder"),t.selectRange(r);const s=t.$.editableElement.getRootNode().querySelector("#INSERTION_MARKER");s.innerHTML="&nbsp;",s.removeAttribute("id"),t._setSelectionRange(s),r=t._getSelectionRange(),r.collapse();const d=document.createElement(e.value);return d.innerHTML=o,o||(d.setAttribute("data-placeholder",e.label),d.setAttribute("empty","")),d.classList.add("smart-editor-format-block"),d.setAttribute("contenteditable",""),s.parentElement.insertBefore(d,s),void s.remove()}t.$.editableElement.getRootNode().execCommand("formatBlock",!1,e.value)}}_handleSubSuperScript(e){const t=this;"markdown"!==t.editMode?t._handleCommonToolbarAction(e,["subscript","superscript"]):t._handleMarkdownItem(e)}_handleMarkdownItem(e){const t=this,a=t.$.input,o=t._getSelectionRange(),i=o.selectionStart,n=o.selectionEnd;let r,l,s,d=a.value;switch(e){case"bold":l="**",s="**";break;case"italic":l="*",s="*";break;case"underline":l="<ins>",s="</ins>";break;case"strikethrough":l="~~",s="~~";break;case"subscript":l="<sub>",s="</sub>";break;case"superscript":l="<sup>",s="</sup>"}if(void 0!==i&&i!==n){const e=l.length,o=s.length;if(r=d.slice(i,n),d.slice(i-e,i)===l&&d.slice(n,n+o)===s)return a.value=d.slice(0,i-e)+r+d.slice(n+o),t._refreshMarkdownPreview(),void t._setSelectionRange(a,i-e,n-e)}l&&s&&t._insertMarkDown(l+s,a.selectionStart+l.length)}_handleTextDecorations(e){const t=this;if("markdown"===t.editMode)return void t._handleMarkdownItem(e);const a=t._getSelectionRange();let o,i=a.startContainer;if(!i)return;if(a.startOffset===a.endOffset&&i.nodeType===Node.TEXT_NODE){const{selectionStartIndex:e,selectionEndIndex:i}=t._getTextFromCarret();o=a.startOffset-e}if((t.$.editableElement.getRootNode()||document).execCommand(e))if(void 0!==o){const e=t.$.iframe;(e?e.contentWindow:window).getSelection().focusNode}else t._setSelectionRange();const n=t.$.toolbar,r=n.querySelector('.smart-editor-toolbar-item[item-name="'+e+'"]');if(r&&"bold"===e||"italic"===e||"underline"===e||"strikethrough"===e){let a=null;n!==t.$.toolbar||t.hideToolbar?t.hideInlineToolbar||(a=t._inlineToolbarItemsObj):a=t._toolbarItemsObj,a&&(a[e],r.hasAttribute("checked")?(r.removeAttribute("checked"),r.setAttribute("aria-pressed",!1)):(r.setAttribute("checked",""),r.setAttribute("aria-pressed",!0)))}else t._updateToolbarItems([e])}_handlePasteAction(e,t,a){if(!e)return;const o=this;if(t&&!t.name&&"prompt"===o.pasteFormat){const i={name:"paste",text:e,textType:a};return t&&(i.value=t.value,i.advanced=t.advanced),void o._openWindow(i)}o._handleTextPaste(e,t,a)}_handleTextPaste(e,t,a){const o=this,i=o.$.input;if(o.$.contentContainer.classList.contains("char-count-maxed"))return;if("markdown"===o.editMode)return o._insertMarkDown(e),void o._setCharCount();e=e.replace(/<!--StartFragment-->|<!--EndFragment-->/gi,"");let n,r,l=o.pasteFormat;if(t&&t.advanced&&(l=t.value),!a||"plainText"===l){const t=document.createElement("div");t.innerHTML=e,e=t.innerText}const s=e.toLocaleLowerCase();if(n=document.createElement("span"),n.innerHTML=e,"blockHtml"===o.editMode){o.$.editableElement.getRootNode().execCommand("delete"),n=document.createElement("div"),n.classList.add("smart-editor-block");let t=document.createElement("div");t.innerHTML=e;let a=[],i=!1,r=!1,l="";if(t.querySelectorAll("[disabled]").forEach((e=>{e.removeAttribute("disabled")})),t.childNodes.forEach((e=>{if(3===e.nodeType){let t=e.textContent.trim();t&&a.push(`<div data-block-id="${Smart.Utilities.Core.createGUID()}" class="smart-editor-block">${t}</div>`)}else"UL"===e.tagName||"OL"===e.tagName?a.push(`<div data-block-id="${Smart.Utilities.Core.createGUID()}" class="smart-editor-block">${e.outerHTML}</div>`):"LI"===e.tagName?(i||r||(l='<div data-block-id="${Smart.Utilities.Core.createGUID()}" class="smart-editor-block"><ul>',i=!0),l+=`<li>${e.innerHTML}</li>`):e.tagName.match(/^H[1-6]$/)?a.push(`<div data-block-id="${Smart.Utilities.Core.createGUID()}" class="smart-editor-block">${e.outerHTML}</div>`):"P"===e.tagName?(e.textContent.split("\n").forEach((e=>{a.push(`<div data-block-id="${Smart.Utilities.Core.createGUID()}" class="smart-editor-block">${e}</div>`)})),e.remove()):("BLOCKQUOTE"===e.tagName||e.tagName,a.push(`<div data-block-id="${Smart.Utilities.Core.createGUID()}" class="smart-editor-block">${e.outerHTML}</div>`))})),(i||r)&&(l+=i?"</ul></div>":"</ol></div>",a.push(l)),a.length>1){const e=window.getSelection();return e&&e.anchorNode&&e.anchorNode.classList&&e.anchorNode.classList.contains("smart-editor-block")&&""===e.anchorNode.textContent&&e.anchorNode.remove(),o._createEditorBlock(!1,!1,a.join("")),void(o._editorBlocks=o.$.editableElement.querySelectorAll(".smart-editor-block"))}n=document.createElement("span"),n.innerHTML=e}if(s.indexOf("<video")>-1||s.indexOf("<iframe")>-1||s.indexOf("smart-editor-image-caption")>-1){const e=n.querySelectorAll("video, iframe"),t=n.querySelector(".smart-editor-image-caption"),a=e.length>0;let o=document.createDocumentFragment();for(let t=0,a=e.length;t<a;t+=1)o.appendChild(e[t]);if(t&&(t.removeAttribute("style"),o.appendChild(t)),a||t){const e=document.createElement("span");n.classList.add("smart-editor-image-container"),a&&n.classList.add("smart-editor-video-container"),n.setAttribute("contenteditable",!1),o.childElementCount&&(n.innerHTML="",n.appendChild(o)),e.appendChild(n),n=e}}if("cleanFormat"===l&&o._removeNodeStyles(n),(!a||"text/plain"===a)&&(n=document.createTextNode(n.innerHTML),r=Node.TEXT_NODE,/^(https?:\/\/)?([\w.-]+\.[a-z]{2,})(\/[^\s]*)?$/i.test(e.trim()))){n=document.createElement("a"),n.innerHTML=e,n.href=e,n.target="_blank";const t=o._getSelectionRange();return t.deleteContents(),t.insertNode(n),o._handleNodeContentFiltering(n),void t.collapse()}if(i.getRootNode().activeElement===i){const e=i.value;return i.value=e.slice(0,i.selectionStart)+(r===Node.TEXT_NODE?n.textContent:n.innerHTML)+e.slice(i.selectionEnd),void o._setCharCount()}const d=o._getSelectionRange(),c=o.$.iframe,[m,u]=c?[c.contentWindow,c.contentDocument]:[window,document];if(!(d instanceof m.Range))return u.execCommand("paste"),void o._handleContentFiltering();if(d.deleteContents(),n.childNodes.length)for(;n.lastChild;)d.insertNode(n.lastChild);else d.insertNode(n);o._handleNodeContentFiltering(n),d.collapse()}_removeNodeStyles(e){if(e&&e.nodeType!==Node.TEXT_NODE){const t=e.querySelectorAll("style, [style]");for(let e=0,a=t.length;e<a;e+=1){const a=t[e];"style"===a.nodeName.toLowerCase()?a.remove():t[e].removeAttribute("style")}e.removeAttribute("style")}}_handlePaste(e){const t=this,a=navigator.clipboard,o=a.read?"read":"readText",i=()=>{a[o]&&a[o]().then((a=>{if(Array.isArray(a)&&a.length){const o=a[0],i=o.types.indexOf("text/html")>-1?"text/html":"text/plain";o.getType(i).then((a=>{a.text().then((a=>t._handlePasteAction(a,e,i)))}))}else"string"==typeof a&&t._handlePasteAction(a,e)}))};if(navigator.permissions&&navigator.permissions.query&&!t._isFireFox)try{navigator.permissions.query({name:"clipboard-read"}).then((e=>{("granted"===e.state||"prompt"===e.state&&a[o])&&i()}))}catch(e){t.error(t.localize("permissionsRequired",{elementType:t.nodeName.toLowerCase(),actionName:"paste"}))}else if(a[o])return void i();t.$.editableElement.getRootNode().execCommand("paste")}_handlePasteViaWindow(e){const t=this,a=t._getItemOptionsViaWindow(e);if(!e||"paste"!==e.name)return;let o=t.pasteFormat;for(let e in a)if(a[e]){o=e;break}e.value=o,t._handleTextPaste(e.text,e,e.textType)}_handleClipboardAction(e){const t=this,a=t.editMode,o=t.$.input;if("paste"===e)return void t._handlePaste();const i=t._getSelectionRange();if(("copy"===e||"cut"===e)&&(document.execCommand("copy"),"cut"===e))if("markdown"===a){const e=o.value,a=o.selectionStart;o.value=e.slice(0,a)+e.slice(o.selectionEnd),t._setSelectionRange(o,a,a),t._refreshMarkdownPreview()}else i.deleteContents()}_handleLinkRemove(e){const t=this;let a;if(e&&"img"===e.nodeName.toLowerCase())a=e.closest(".smart-editor-editable a"),a&&(a.parentElement.insertBefore(e,a),a.remove());else{const e=t.$.iframe;let a,o;e?(a=e.contentDocument,o=e.contentWindow):(a=document,o=window);const i=o.getSelection(),n=t._getSelectionRange();i.removeAllRanges(),i.addRange(n);const r=i.anchorNode?i.anchorNode.parentElement:void 0;if(!r||"a"!==r.nodeName.toLowerCase())return;n.selectNode(i.anchorNode),a.execCommand("unlink",!1,!1)}}_handleBackgroundColor(e){const t=this;if("markdown"===t.editMode)return;const a=t.$.iframe,o="string"==typeof e?e:e.value,[i,n]=a?[a.contentDocument,a.contentWindow]:[document,window],r=t.$.inlineToolbar,l=t._getSelectionRange(),s=r&&r.visible?r.selector:l.commonAncestorContainer;let d;if(s&&["th","td"].indexOf(s.nodeName.toLowerCase())>-1){if(l.startOffset===l.endOffset)return void(s.style.backgroundColor=o);d=s.style.backgroundColor}const c=l.startOffset,m=l.endOffset,u=l.startContainer;let p;if(u&&u.nodeType===Node.TEXT_NODE&&l.startOffset===l.endOffset){const{selectionStartIndex:e,selectionEndIndex:a}=t._getTextFromCarret();p=l.startOffset-e,t._setSelectionRange(u,e,a)}else u.closest&&c!==m&&t._setSelectionRange(u,c,m);const b=i.execCommand("hiliteColor",!1,o&&"transparent"!==o?o:"transparent");s&&d?s.style.backgroundColor=d:b&&void 0!==p&&t._setSelectionRange(n.getSelection().focusNode,p,p)}_handleFontColor(e){const t=this;if("markdown"===t.editMode)return;const a=t._getSelectionRange(),o="string"==typeof e?e:e.value,i=a.startContainer,n=t.$.iframe,r=o?"foreColor":"removeFormat",[l,s]=n?[n.contentDocument,n.contentWindow]:[document,window];let d;if(i&&i.nodeType===Node.TEXT_NODE&&a.startOffset===a.endOffset){const e=i.parentElement;if("font"===e.nodeName.toLocaleLowerCase())return void(e.color=o);const{selectionStartIndex:n,selectionEndIndex:r}=t._getTextFromCarret();d=a.startOffset-n,t._setSelectionRange(i,n,r)}l.execCommand(r,!1,o)&&void 0!==d&&t._setSelectionRange(s.getSelection().focusNode,d,d)}_handlePrint(){const e=this,t=e.dataExport.fileName;e.dataExport.fileName=null;const a=window.open("","","width=800,height=500"),o=a.document.open(),i='<!DOCTYPE html><html><head><meta charset="utf-8" /><title>'+t+"</title></head><body>"+e._handleDataExport("html")+"</body></html>";try{o.write(i),o.close(),setTimeout((function(){a.print(),a.close()}),100)}catch(e){}e.dataExport.fileName=t}_handleDataExport(e,t){const a=this;if(!Smart.Utilities.DataExporter)return void a.error(a.localize("missingReference",{elementType:a.nodeName.toLowerCase(),methodName:"exportData",files:"smart.export.js"}));try{new JSZip}catch(e){return void a.error(a.localize("missingReference",{elementType:a.nodeName.toLowerCase(),methodName:"exportData",files:"jszip.min.js"}))}if("pdf"===e&&!window.pdfMake)return void a.error(a.localize("missingReference",{elementType:a.nodeName.toLowerCase(),methodName:"exportData",files:"pdfMake.min.js"}));if("pdf"===e)return void a._exportToPDF(a.dataExport.fileName,e);let o;if("markdown"===a.editMode){const t=a.$.input;o="md"!==e&&window.marked?window.marked(t.value):t.value}else o=a.$.editableElement["pdf"===e?"textContent":"innerHTML"];const i=new Smart.Utilities.DataExporter({exportHeader:!1,pageOrientation:a.dataExport.pageOrientation,style:a.dataExport.style}),n=[{value:o}];return a._setExportStyles(i,e),i.exportData(n,e,a.dataExport.fileName,t)}_exportToPDF(e,t){const a=this,o=a.$.editableElement,i=window.getComputedStyle(a),n=a.dataExport.style,r={pageOrientation:a.pageOrientation||"portrait",info:{title:"smartEditor",creator:"Smart",producer:"Smart"}};if(n&&(r.styles=n),r.defaultStyle={fontSize:parseFloat(i.fontSize)},"markdown"===a.editMode){const e=a.$.input,i=document.createElement("div");let n;"md"!==t?o.classList.contains("smart-hidden")?(i.innerHTML=window.marked?window.marked(e.value):e.value,n=a._processHTMLAsPDFObject(i,[])):n=a._processHTMLAsPDFObject(o,[]):(i.innerHTML=e.value,n=a._processHTMLAsPDFObject(i,[])),r.content=n}else r.content=a._processHTMLAsPDFObject(a.$.editableElement,[]);try{pdfMake.createPdf(r).download(e)}catch(e){console.error(a.localize("exportError",{elementType:a.nodeName.toLowerCase(),status:e.toString()}))}}_processHTMLAsPDFObject(e,t,a){const o=this,i={},n=["left","center","right"],r=e.childNodes,l=["td","th"].indexOf(e.nodeName.toLowerCase())>-1;for(let a=0,s=r.length;a<s;a+=1){const s=r[a],d=s.nodeName.toLowerCase(),c=s.nodeType===Node.TEXT_NODE;let m;if("table"===d){const e=s.querySelectorAll("thead tr"),t=s.querySelectorAll("thead tr:last-of-type td, thead tr:last-of-type th"),a=s.querySelectorAll("tbody tr:last-of-type td, tbody tr:last-of-type th"),i=t.length?t:a,n=s.querySelectorAll("body tr");let r=e.length;if(!r)for(let e=0,t=n.length;e<t&&Array.from(n[e].children).every((e=>"th"===e.nodeName.toLowerCase()));e+=1)r++;m={table:{headerRows:r,widths:(()=>{const e=Math.round(100/i.length)+"%";let t=[];for(let a=0,o=i.length;a<o;a+=1)t.push(e);return t})(),body:(()=>{let e=[];for(let t=0,a=n.length;t<a;t+=1){const a=n[t],r=a.children;let l=[];for(let e=0,t=a.childElementCount;e<t;e+=1){const t=o._processHTMLAsPDFObject(r[e],[],!0);if(a.childElementCount<i.length){let e;for(e=Array.isArray(t)&&1===t.length?t[0]:{text:t},e.colSpan=Math.round(i.length/a.childElementCount),l.push(e);l.length<i.length;)l.push({text:""})}else l.push(1===t.length?t[0]:t)}e.push(l)}return e})()}}}else if("ul"===d)m={ul:o._processHTMLAsPDFObject(s,[])};else if("ol"===d)m={ol:o._processHTMLAsPDFObject(s,[])};else if("img"===d){const e=document.createElement("canvas"),t=e.getContext("2d");let a;e.width=s.naturalWidth||s.width,e.height=s.naturalHeight||s.height,t.drawImage(s,0,0);try{a=e.toDataURL("image/png")}catch(e){console.error(o.localize("exportError",{elementType:o.nodeName.toLowerCase(),status:e.toString()}));continue}if(a.indexOf("image/png")<0){console.error(o.localize("exportError",{elementType:o.nodeName.toLowerCase(),status:"Invalid image"}));continue}m={image:a,width:s.width,height:s.height}}else"a"===d?(m={},s.childElementCount?s.querySelector("img")&&(m=o._processHTMLAsPDFObject(s,[],!0)[0]||{}):m.text=s.textContent,m.link=s.href):s.childElementCount?t=t.concat(o._processHTMLAsPDFObject(s,[],!0)):m={text:s.textContent.trim()?s.textContent:"\n"};if(m){const a=window.getComputedStyle(c?e:s);if(!c||l){const e=a.backgroundColor,t=parseFloat(a.fontSize);isNaN(t)||(m.fontSize=t),m.alignment=i.alignment=n.indexOf(a.textAlign)>-1?a.textAlign:n[0],"rgba(0, 0, 0, 0)"!==e&&"transparent"!==e&&(m.fillColor=i.fillColor=o._RGBAtoHex(e)),parseInt(a.fontWeight)>500&&(m.bold=!0),"italic"===a.fontStyle&&(m.italics=!0)}m.inlineElement=c||a.display.indexOf("inline")>-1,m.color=i.color=o._RGBAtoHex(a.color),t.push(m)}}return 1===t.length?t:a||l?(i[t.every((e=>e.inlineElement&&!e.image))?"text":"stack"]=t,[i]):t}_RGBAtoHex(e){const t=/rgb[a]?\(\s*(\d+),\s*(\d+),\s*(\d+),?\s*(\d*.\d+|\d+)?\)/gi.exec(e.replace(/\s/g,""));if(null===t)return e;const a=parseFloat(t[1]).toString(16).toUpperCase(),o=parseFloat(t[2]).toString(16).toUpperCase(),i=parseFloat(t[3]).toString(16).toUpperCase();return"#"+"0".repeat(2-a.length)+a+"0".repeat(2-o.length)+o+"0".repeat(2-i.length)+i}_setExportStyles(e,t){const a=this;if(e.style)return;const o=window.getComputedStyle(a),i=o.getPropertyValue("--smart-border-width")||"1px",n=o.getPropertyValue("--smart-border")||"black",r=o.getPropertyValue("--smart-editor-table-column-width")||"initial",l=o.getPropertyValue("--smart-editor-table-cell-min-height")||"20px",s=o.getPropertyValue("--smart-editor-table-cell-min-width")||l,d=o.getPropertyValue("--smart-surface")||"#333",c=o.getPropertyValue("--smart-alternation-index0-background")||d;e.style={border:"initial",width:"100%",height:a.$.editableElement.scrollHeight+"px",removeDefault:!0,custom:`\n ${"html"===t&&a.rightToLeft?"body { direction: rtl; }":""}\n\n .column table {\n width: 100%;\n border-collapse: collapse;\n empty-cells: show;\n border-spacing: 0;\n table-layout: fixed;\n }\n \n .column td, .column th {\n border: ${i} solid ${n};\n width: ${r};\n min-height: ${l};\n min-width: ${s};\n padding: 2px 5px;\n vertical-align: middle;\n }\n \n .column table img {\n max-width: 100%;\n }\n \n .column table table {\n width: 100%;\n }\n \n .column table th {\n background: ${d};\n }\n\n .column th:empty::before,\n .column td:empty::before {\n content: 'A';\n visibility: hidden;\n }\n \n .column table[dashed-borders] th, .column table[dashed-borders] td {\n border-style: dashed;\n }\n \n .column table[alternation] tr:nth-child(2n) {\n background-color: ${c};\n }\n \n .column .smart-editor-image-container {\n display: inline-block;\n }\n \n .column .smart-editor-image-container[display="block"] {\n display: block;\n }\n \n .column .smart-editor-image-container[display="block"][alignment="left"] img {\n margin-left: 0;\n }\n \n .column .smart-editor-image-container[display="block"][alignment="left"] .smart-editor-image-caption {\n text-align: left;\n }\n \n .column .smart-editor-image-container[display="block"][alignment="right"] img {\n margin-right: 0;\n }\n \n .column .smart-editor-image-container[display="block"][alignment="right"] .smart-editor-image-caption {\n text-align: right;\n }\n \n .column .smart-editor-image-container:not([display="block"])[alignment="left"] {\n float: left;\n }\n \n .column .smart-editor-image-container:not([display="block"])[alignment="right"] {\n float: right;\n }\n \n .column .smart-editor-image-container .smart-editor-image-caption {\n display: block;\n text-align: center;\n outline: none;\n }`}}_handleSourceCodeMode(e){const t=this,a=t.editMode,o=t._toolbarItemsObj.sourcecode;let i;if(t.$.contentContainer.hasAttribute("split-mode"))return;e?i=e.hasAttribute("checked"):(i=o?o.value:!t.classList.contains("preview-mode"),e=t.$.toolbar.querySelector('.smart-editor-toolbar-item[item-name="sourcecode"]')),t._closePopups(),t._closeWindow(),t._closeSearchToolbar(),t._setResizeFrame(),t._handleTableSelection();const n=t.$.editableElement,r=t.$.input;"markdown"===a?i&&n.classList.contains("smart-hidden")?(n.innerHTML=window.marked?window.marked(r.value):r.value,n.classList.remove("smart-hidden"),r.classList.add("smart-hidden"),n.focus({preventScroll:!0})):!i&&r.classList.contains("smart-hidden")&&(n.classList.add("smart-hidden"),r.classList.remove("smart-hidden"),r.focus({preventScroll:!0})):i&&r.classList.contains("smart-hidden")?(r.value=t._getInputValue(n.innerHTML),n.classList.add("smart-hidden"),r.classList.remove("smart-hidden"),r.focus({preventScroll:!0})):!i&&n.classList.contains("smart-hidden")&&(n.innerHTML=t._getInputValue(r.value,!0),"blockHtml"===t.editMode&&t._createEditorBlock(!1,!1,"&nbsp;"),r.classList.add("smart-hidden"),n.classList.remove("smart-hidden"),n.focus({preventScroll:!0}),t._handleContentFiltering()),i?t.classList.add("preview-mode"):t.classList.remove("preview-mode"),o&&(o.value=i),e&&o&&(i?(e.setAttribute("checked",""),e.setAttribute("aria-pressed",!0)):(e.removeAttribute("checked"),e.setAttribute("aria-pressed",!1)),t._setTextSelection(),t._setToolbarItemAttr("sourcecode","disabled",o.disabled))}_offsetTop(e){return e?e.offsetTop+this._offsetTop(e.offsetParent):0}_offsetLeft(e){return e?e.offsetLeft+this._offsetLeft(e.offsetParent):0}offset(e){return{left:this._offsetLeft(e),top:this._offsetTop(e)}}_setTextSelection(){const e=this,t=e.$.input,a=e.$.editableElement,o=e._selectionRange;if(!o)return;const i=o.commonAncestorContainer;if(i){if(t.classList.contains("smart-hidden"))return;const n=e._getParentCharDetails(o.startContainer,i),r=e._getParentCharDetails(o.endContainer,i),l=e._getSiblingsCharOffset(n.parentElement,r.parentElement),{charOffset:s}=e._getParentCharDetails(i,a),d=o.startOffset+n.charOffset+s,c=o.endOffset+r.charOffset+l+s;e._setSelectionRange(t,d,c)}else if(!a.classList.contains("smart-hidden")){const i=o.selectionStart,n=o.selectionEnd,r=t.value;if(void 0===i||void 0===n||i===n&&(r.length===i||0===i))return;if(0===i&&n===a.innerHTML.length)return void e._setSelectionRange(a);const l=e._getNodeByChartOffset(a.firstChild,i,n);if(!l)return;const{node:s,charOffset:d}=l;e._setSelectionRange(s,i-d,n-d)}}_getNodeByChartOffset(e,t,a){const o=this;let i=0;for(;e;){const n=e.outerHTML||e.textContent,r=n.length;if(i<=t&&i+r>=a){e.tagName&&(i+=e.outerHTML.slice(0,n.indexOf(e.innerHTML)).length);const r=o._getNodeByChartOffset(e.firstChild,t-i,a-i);return r?{node:r.node,charOffset:r.charOffset+i}:{node:e,charOffset:i}}e=e.nextSibling,i+=r}}_getParentCharDetails(e,t){let a=0;if(e===t)return{charOffset:a,parentElement:e.parentElement};let o=e,i=e.innerHTML||e.textContent,n=e.parentElement;for(;n&&n!==t&&t.contains(n);){const e=n.outerHTML;a+=e.indexOf(i),i=e,o=n,n=n.parentElement}return a+=(t.innerHTML||t.textContent).indexOf(i),{charOffset:a,parentElement:o}}_getPreSiblingOffset(e,t){let a=0,o=e.textContent,i=e.previousSibling;for(;i&&t.contains(i);){const e=i.outerHTML||i.textContent;o=e+o,a+=e.length,i=i.previousSibling}return a}_getSiblingsCharOffset(e,t){let a=0,o=e.nextSibling;if(e===t)return a;for(;o&&o!==t;)a+=(o.outerHTML||o.textContent).length,o=o.nextSibling;return a}_handleFullScreenMode(e){const t=this,a=t._toolbarItemsObj.fullscreen;let o;e?o=e.hasAttribute("checked"):(o=a?a.value:!t.classList.contains("full-screen-mode"),e=t.$.toolbar.querySelector('.smart-editor-toolbar-item[item-name="fullscreen"]')),t._closePopups(),t._setResizeFrame(),t._handleTableSelection(),o?(t.classList.add("full-screen-mode"),t._lastToolbarExpandedState=t.$.toolbar.hasAttribute("expanded")):(t.classList.remove("full-screen-mode"),t._lastToolbarExpandedState&&t._toggleToolbar()),a&&(a.value=o),e&&a&&(o?(e.setAttribute("cheched",""),e.setAttribute("aria-pressed",!0)):(e.removeAttribute("checked"),e.setAttribute("aria-pressed",!1)),a.disabled?(e.setAttribute("disabled",""),e.setAttribute("aria-disabled",!0)):(e.removeAttribute("disabled"),e.removeAttribute("aria-disabled")))}_handleSplitMode(e){const t=this,a=t.$.editableElement,o=t.$.input,i=t.$.contentContainer,n=t._toolbarItemsObj,r=n.splitmode,l=n.sourcecode,s=e?e.hasAttribute("checked"):!i.hasAttribute("split-mode"),d=t.editMode;t._closePopups(),s?("markdown"===d?a.innerHTML=window.marked?window.marked(o.value):o.value:o.value=a.innerHTML.trim(),i.setAttribute("split-mode",""),o.classList.remove("smart-hidden"),a.classList.remove("smart-hidden"),l&&t._setToolbarItemAttr("sourcecode","disabled",!0)):(i.removeAttribute("split-mode",""),"markdown"===d?a.classList.add("smart-hidden"):o.classList.add("smart-hidden"),l&&t._setToolbarItemAttr("sourcecode","disabled",!1)),r&&(r.value=s),e||(e=t.$.toolbar.querySelector('.smart-editor-toolbar-item[item-name="splitmode"]')),e&&(s?(e.setAttribute("checked",""),e.setAttribute("aria-pressed",!0)):(e.removeAttribute("checked"),e.setAttribute("aria-pressed",!1))),t._resizeFrameObj&&t._setResizeFrame(t._resizeFrameObj.target),t.classList.contains("preview-mode")&&t._handleSourceCodeMode()}_handleUndoRedo(e){this.$.editableElement.getRootNode().execCommand(e)}_handleTextCase(e){const t=this;if("markdown"===t.editMode)return;const a=t._getSelectionRange(),o=a.startContainer;if(!o)return;const i=o.textContent;let n,r,l,s,d=a.startOffset;o.nodeType===Node.TEXT_NODE&&a.startOffset===a.endOffset?(({selectionStartIndex:l,selectionEndIndex:s}=t._getTextFromCarret()),r=i.slice(l,s)):([l,s]=[d,a.endOffset],r=i.slice(d,a.endOffset),n=a.endOffset),r="lowercase"===e?r.toLowerCase():r.toUpperCase(),o.textContent=i.slice(0,l)+r+i.slice(s),t._setSelectionRange(o,d,n||d)}_insertBlock(){const e=this;if("blockHtml"===e.editMode){if(e.preventInsertBlock)return;e.$.contentContainer.dispatchEvent(new KeyboardEvent("keydown",{key:"Enter"}));const t=e._currentBlock;if(!t)return;t.innerHTML="&nbsp;",t.removeAttribute("empty"),t.removeAttribute("data-placeholder"),e._setSelectionRange(t,0,0)}}_handleList(e){const t=this;if(!e)return;if("markdown"===t.editMode){const a="orderedlist"===e?"1. ":"- ",o=t.$.input.selectionStart,i=t._getMarkdownFormat(o,"orderedlist"),n=t._getMarkdownFormat(o,"unorderedlist");if(i&&(t._removeMarkDown(a,i.occuranceIndex,"orderedlist"!==e),"orderedlist"===e))return;if(n&&(t._removeMarkDown(a,n.occuranceIndex,"unorderedlist"!==e),"unorderedlist"===e))return;return void t._insertMarkDown(a,t.$.input.selectionStart+a.length,!0)}"blockHtml"===t.editMode&&t._insertBlock();let a,o,i=t._getSelectionRange();if(i.startContainer===i.endContainer&&(a=i.startOffset,o=i.endOffset),t.$.editableElement.getRootNode().execCommand("insert"+e,!1)){const e=t.$.iframe;i=(e?e.contentWindow:window).getSelection(),void 0!==o&&void 0!==o&&t._setSelectionRange(i.focusNode,a,o),t._updateToolbarItems(["orderedlist","unorderedlist"])}}_handleCheckList(e){const t=this;if(!e)return;if("markdown"===t.editMode){const a="orderedlist"===e?"1. ":"- ",o=t.$.input.selectionStart,i=t._getMarkdownFormat(o,"orderedlist"),n=t._getMarkdownFormat(o,"unorderedlist");if(i&&(t._removeMarkDown(a,i.occuranceIndex,"orderedlist"!==e),"orderedlist"===e))return;if(n&&(t._removeMarkDown(a,n.occuranceIndex,"unorderedlist"!==e),"unorderedlist"===e))return;return void t._insertMarkDown(a,t.$.input.selectionStart+a.length,!0)}if("blockHtml"===t.editMode){t.$.contentContainer.dispatchEvent(new KeyboardEvent("keydown",{key:"Enter"}));const e=t._currentBlock;e.innerHTML="&nbsp;",e.removeAttribute("empty"),e.removeAttribute("data-placeholder"),t._setSelectionRange(e,0,0)}let a,o,i=t._getSelectionRange();if(i.startContainer===i.endContainer&&(a=i.startOffset,o=i.endOffset),t.$.editableElement.getRootNode().execCommand("insert"+e,!1)){const e=t.$.iframe;if(i=(e?e.contentWindow:window).getSelection(),void 0!==o&&void 0!==o){const e=i.focusNode.parentElement.closest("ul");e&&e.setAttribute("checklist",""),t._setSelectionRange(i.focusNode,a,o)}t._updateToolbarItems(["checklist"])}}replaceSelection(e){this.$.editableElement.getRootNode().execCommand("delete"),this.$.editableElement.getRootNode().execCommand("insertHTML",0,e)}_handleIndentation(e){"markdown"!==this.editMode&&this.$.editableElement.getRootNode().execCommand(e,!1)}_handleTextDelete(){this.$.editableElement.getRootNode().execCommand("delete")}_handleTabInsert(){this.$.editableElement.getRootNode().execCommand("insertHTML",!1,"&#009")}_handleTableToolbarAction(e,t){const a=this,o=a._toolbarItemClick;if(!t&&o&&(t=o.target),!t||"table"!==t.nodeName.toLowerCase()||!e)return;const i=e.getAttribute?e.getAttribute("item-name"):e.name,n=a.$.inlineToolbar;let r=e;if(r.closest){const e=a.$.inlineToolbar;r=(e&&e.contains(r)?a._inlineToolbarItemsObj:a._toolbarItemsObj)[i]}if(!o&&a.$.fireEvent("actionStart",{name:i}).defaultPrevented)return;switch(i){case"backgroundcolor":a._handleBackgroundColor(r);break;case"fontcolor":a._handleFontColor(r);break;case"fontsize":a._handleFontSize(r);break;case"tableheader":a._handleTableHeader(t);break;case"tablerows":a._handleTableRows(t,r);break;case"tablecolumns":a._handleTableColumns(t,r);break;case"tablevalign":a._handleTableVAlignment(t,r);break;case"alignment":a._handleTextAlignment(r);break;case"tablestyle":a._handleTableStyle(t,r);break;case"formats":a._handleFormats(r);break;default:a._handleToolbarItemAction(e)}!o&&i&&a.$.fireEvent("actionEnd",{name:i}),n&&n.visible&&(a.$.editableElement.contains(n.selector)?n.reposition():a._closeToolbar());const l=a._getSelectionRange().startContainer;let s;if(l.nodeType===Node.TEXT_NODE){const e=l.parentElement;s=e.closest("th")||e.closest("td")}else s=["th","td"].indexOf(l.nodeName.toLowerCase())>-1;a._setResizeFrame(s&&t.contains(l)?t:void 0)}_handleTableHeader(e,t){let a,o,i=e.querySelector("th"),n=e.querySelector("tbody tr"),r=e.querySelector("thead");if(n&&(o=Array.from(n.children)),t||!r&&!i){if(void 0===t||!0===t){let t=e.querySelectorAll("tbody tr:first-of-type td").length;r||(r=document.createElement("thead")),a=r.querySelector("tr"),a||(a=document.createElement("tr"));const i=Array.from(a.children);for(;i.length>t;)i.pop().remove();for(let e=i.length;e<t;e+=1){const t=document.createElement("th");o[e]&&(t.style.width=o[e].style.width,o[e].style.width=""),a.appendChild(t)}r.appendChild(a),e.insertBefore(r,e.querySelector("tbody")||e.querySelector("tr"))}}else r&&r.remove(),i&&(a=i.closest("tr"),a&&a.remove(),Array.from(a.children).forEach(((e,t)=>o[t].style.width=e.style.width)))}_handleTableRows(e,t){if(!e)return;const a=this,o=a.$.inlineToolbar.selector,i=o.nodeName.toLocaleLowerCase();let n;if(!(o&&["th","td"].indexOf(i)>-1))return;if(n=o.closest("tr"),!n)return;const r=t.value,l=n.closest("thead");switch(r){case"insertRowAfter":case"insertRowBefore":{const t=document.createElement("tr"),a=n.parentElement;if(!a)break;const o=e.querySelector("tr").childElementCount,l="th"===i?"th":"td";for(let e=0;e<o;e+=1)t.appendChild(document.createElement(l));a.insertBefore(t,r.indexOf("Before")>-1?n:n.nextElementSibling);break}case"deleteRow":a._closeToolbar(),n.remove(),l&&!l.children.length&&l.remove()}const s=e.querySelectorAll("tr").length;s?(e.setAttribute("aria-rowcount",s),a._resizeFrameObj&&a._setResizeFrame(a._resizeFrameObj.target)):e.remove()}_handleTableColumns(e,t){if(!e)return;const a=this,o=a.$.inlineToolbar.selector;if(!(o&&["th","td"].indexOf(o.nodeName.toLowerCase())>-1))return;const i=t.value,n=Array.from(e.querySelectorAll("tr"));if(!n.length)return a._closeToolbar(),void e.remove();const r=Array.from(o.parentElement.children).indexOf(o);switch(i){case"insertColumnLeft":case"insertColumnRight":{const e=i.indexOf("Left")>-1;for(let t=0,a=n.length;t<a;t+=1){const a=n[t],o=a.children[r];if(o){const t="th"===o.tagName.toLowerCase()?"th":"td";a.insertBefore(document.createElement(t),e?o:o.nextElementSibling)}}break}case"deleteColumn":a._closeToolbar();for(let e=0,t=n.length;e<t;e+=1){const t=n[e].children[r];t&&t.remove()}}const l=n[0].children.length;l?(e.setAttribute("aria-colcount",l),a._resizeFrameObj&&a._setResizeFrame(a._resizeFrameObj.target)):e.remove()}_handleTextAlignment(e){if("markdown"===this.editMode)return;const t="justify"===e.value?"full":e.value;this.$.editableElement.getRootNode().execCommand("justify"+t.charAt(0).toUpperCase()+t.slice(1),!1,null)}_handleTableVAlignment(e,t){const a=this.$.inlineToolbar;if(!a)return;const o=a.selector;o&&["th","td"].indexOf(o.nodeName.toLowerCase())>-1&&(o.style.verticalAlign=t.value)}_handleTableStyle(e,t){const a=this.$.inlineToolbar.selector;if(a&&["th","td"].indexOf(a.nodeName.toLowerCase())>-1)switch(t.value){case"altrows":e.toggleAttribute("alternation");break;case"dashedborders":e.toggleAttribute("dashed-borders")}}_handleInlineToolbar(e){const t=this,a=e.nodeName.toLowerCase();"a"===a?((t._isControlPressed||e.classList.contains("smart-editor-file"))&&window.open(e.href,e.target),t._openInlineToolbar(e),t._refreshToolbarTabs()):"img"===a||["td","th"].indexOf(a)>-1?(t._setResizeFrame(e),t._openInlineToolbar(e),t._refreshToolbarTabs()):e.nodeType===Node.TEXT_NODE&&e.textContent.trim().length&&t._openInlineToolbar(e)}_handleTableCellResize(e){const t=this,a=t._inlineToolbarClickObj,o=a?a.resizeDetails:void 0;if(!o)return;const i=o.target,n=o.position,r=t.$.inlineToolbar;switch(o.started||t.$.fireEvent("resizeStart",{target:i}),i.setAttribute("resizing",""),o.started=!0,r&&r.visible&&(o.isInlineToolbarOpened=!0,t._closeToolbar()),n){case"horizontal":{const a=e.pageX+window.pageXOffset;if(t._setTableResizeDetails(o),!o.shrinkingCell)break;t._handleHorizontalTableCellResize(o,a);break}case"vertical":{const a=o.table;a.style.height&&(a.querySelectorAll("tr").forEach((e=>e.style.height=e.offsetHeight+"px")),a.style.height=""),t._resizeFrameObj&&t._resizeFrameObj.target&&t._setResizeFrame();const n=e.pageY+window.pageYOffset,r=o.y-n;let l=i.offsetHeight;l-=r,i.style.height=Math.max(1,l)+"px",l===i.offsetHeight&&(o.y=n+Math.abs(Math.min(0,l)));break}}}_setTableResizeDetails(e){const t=e.table,a=e.target;let o,i=e.expandingCell,n=e.shrinkingCell,r=e.isLastCell,l=e.areAllCellsResized;if(!i){const n=t.querySelector("tr"),r=Array.from(a.parentElement.children).indexOf(a);o=e.cells=Array.from(n.children),i=e.expandingCell=o[r]}e.shrinkingCell||(n=e.shrinkingCell=i.nextElementSibling,l=e.areAllCellsResized=!o.some((e=>e!==i&&e!==n&&!e.style.width)),r=e.isLastCell=l&&null===n.nextElementSibling,l&&!e.lastCell&&(e.lastCell=o[o.length-1]),r&&(n.style.width=""))}_handleHorizontalTableCellResize(e,t){const a=30,o=e.isLastCell;let i=e.expandingCell,n=e.shrinkingCell,r=i.offsetWidth,l=n.offsetWidth,s=e.x-t;const d=e.x-r+a,c=e.x+n.offsetWidth-a;if(o){const o=r+l-a;i.style.width=Math.min(Math.max(a,r-s),o)+"px",i.offsetWidth!==r&&(e.x=Math.min(c,Math.max(d,t)))}else{let o;s>0&&([i,n]=[n,i],[r,l]=[l,r],s*=-1),n.style.width=Math.max(a,l+s)+"px",o=n.offsetWidth-l,i.style.width=Math.max(a,i.offsetWidth-o)+"px",0!==o&&(e.x=Math.min(c,Math.max(d,t))),e.lastCell&&(e.lastCell.style.width="")}}_handleFrameResize(e){const t=this,a=t._resizeFrameObj;if(!a)return;t._closeToolbar();const o=a.resizableElement||a.target,i=a.resizeDetails,n=i.position,r=e.pageX+window.pageXOffset,l=e.pageY+window.pageYOffset,s=i.x-r,d=i.y-l;let c,m;c=o.offsetWidth,m=o.offsetHeight,i.started||(a.target.setAttribute("dragged",""),t.$.fireEvent("resizeStart",{target:o})),i.started=!0;const u=c,p=m,b=t.rightToLeft?-1:1;switch(n){case"top-left":o.style.width=Math.max(0,u+b*s)+"px",o.style.height=Math.max(0,p+d)+"px",c=o.offsetWidth,m=o.offsetHeight,u!==c&&(i.x-=b*(c-u)),p!==m&&(i.y-=m-p);break;case"bottom-left":o.style.width=Math.max(0,u+b*s)+"px",o.style.height=Math.max(0,p-d)+"px",c=o.offsetWidth,m=o.offsetHeight,u!==c&&(i.x-=b*(c-u)),p!==m&&(i.y+=m-p);break;case"bottom-right":o.style.width=Math.max(0,u-b*s)+"px",o.style.height=Math.max(0,p-d)+"px",c=o.offsetWidth,m=o.offsetHeight,u!==c&&(i.x+=b*(c-u)),p!==m&&(i.y+=m-p);break;case"top-right":o.style.width=Math.max(0,u+b*-s)+"px",o.style.height=Math.max(0,p+d)+"px",c=o.offsetWidth,m=o.offsetHeight,p!==m&&(i.y-=m-p),u!==c&&(i.x+=b*(c-u));break;case"top-center":o.style.height=Math.max(0,p+d)+"px",m=o.offsetHeight,p!==m&&(i.y-=m-p);break;case"bottom-center":o.style.height=Math.max(0,p-d)+"px",m=o.offsetHeight,p!==m&&(i.y+=m-p);break;case"left-center":o.style.width=Math.max(0,u+b*s)+"px",c=o.offsetWidth,u!==c&&(i.x-=b*(c-u));break;case"right-center":o.style.width=Math.max(0,u-b*s)+"px",c=o.offsetWidth,u!==c&&(i.x+=b*(c-u))}t._positionResizeHandles()}_deleteResizeFrameTarget(e){const t=this,a=t._getSelectionRange();if(e)if("img"===e.nodeName.toLowerCase()){const a=e.closest(".smart-editor-editable .smart-editor-image-container"),l=(a||e).parentElement,s=l&&"a"===l.nodeName.toLowerCase()?l:void 0;if(t._setResizeFrame(),(s||a||e).remove(),URL.revokeObjectURL(e.src),t.removeUrl){let a=new FormData,l=new XMLHttpRequest;const s=(e,t)=>{let a=e.split(","),o=a[0].match(/:(.*?);/)[1],i=atob(a[1]),n=i.length,r=new Uint8Array(n);for(;n--;)r[n]=i.charCodeAt(n);return new File([r],t,{type:o})};o=e.src,i=e.name,n=e=>{a.append(t.imageName,e),l.open("POST",t.removeUrl),l.send(a)},(r=new Image).crossOrigin="Anonymous",r.onload=function(){var e=document.createElement("canvas"),t=e.getContext("2d");e.height=this.naturalHeight,e.width=this.naturalWidth,t.drawImage(this,0,0);var a=e.toDataURL("image/jpeg");n(s(a,i))},r.src=o}t.onImageRemove&&t.onImageRemove(e.src)}else if(e.classList.contains("smart-editor-video-container")){const a=e.querySelector(".smart-editor-video-container video, .smart-editor-video-container > iframe");t._setResizeFrame(),e.remove(),a&&URL.revokeObjectURL(a.src)}else if("table"===e.nodeName.toLowerCase()){const a=e.closest(".smart-editor-editable table");a&&(t._setResizeFrame(),a.remove())}var o,i,n,r;t._setCharCount(),t._setSelectionRange(a.startContainer,a.startOffset,a.endOffset),t._focusEditableElement()}_setResizeFrame(e,t){const a=this,o=a.$.editableElement;let i,n=e?e.nodeName.toLowerCase():"",r=a._resizeFrameObj;if("td"!==n&&"th"!==n||(e=e.closest(".smart-editor-editable table")),n=e?e.nodeName.toLowerCase():"",e&&e.parentElement&&("img"===n||"table"===n||e.classList.contains("smart-editor-video-container"))&&"false"!==o.getAttribute("contenteditable"))if(r?i=r.element:(r=a._resizeFrameObj={},i=r.element=document.createElement("span"),i.classList.add("smart-editor-resize-frame"),i.innerHTML='<span position="top-left"></span><span position="top-right"></span>\n <span position="bottom-left"></span><span position="bottom-right"></span>\n <span position="top-center"></span><span position="bottom-center"></span>\n <span position="left-center"></span><span position="right-center"></span>'),r.target&&r.target.removeAttribute("show-resize-frame"),r.target=e,e.classList.contains("smart-editor-video-container")?r.resizableElement=e.querySelector("video, iframe"):delete r.resizableElement,a._refreshToolbarTabs(),"false"!==e.getAttribute("resizable")){if(e.setAttribute("show-resize-frame",""),a._positionResizeHandles(),i.parentElement||a.$.contentContainer.appendChild(i),!t&&"img"===n){const e=a.$.iframe;(e?e.contentWindow:window).getSelection().collapse(null),a._updateToolbarItems()}}else e.removeAttribute("show-resize-frame");else{if(r){if(r.element.remove(),r.target){const e=o.querySelectorAll("[show-resize-frame]");for(let t=0,a=e.length;t<a;t+=1)e[t].removeAttribute("show-resize-frame")}delete r.target}a._refreshToolbarTabs()}}_setToast(){const e=this;let t=e.$.toast;return t||(e.$.toast=t=document.createElement("smart-toast"),t.appendTo=e.$.container,t.showCloseButton=!0,t.itemClass="smart-editor-message",e.$toast=Smart.Utilities.Extend(t)),t.rightToLeft=e.rightToLeft,t.theme=e.theme,t.animation=e.animation,t}_positionResizeHandles(){const e=this,t=e._resizeFrameObj;if(!e._resizeFrameObj)return;const a=t.element,o=e.rightToLeft,i=o?"right":"left",n=(t.resizableElement||t.target).getBoundingClientRect(),r=a.children,l=r[0],s=r[1],d=r[2],c=r[3],m=r[4],u=r[5],p=r[6],b=r[7],h=e.$.editableElement,g=e.$.contentContainer.getBoundingClientRect(),f=n.top-g.top+h.offsetTop,v=n.width,_=n.height;let k;if(o)k=g.right-n.right+(h.offsetLeft+h.offsetWidth-g.width),l.style.left=d.style.left=p.style.left="";else{let t=0;e.sortable&&(t=0),k=n.left-g.left+h.offsetLeft-t,l.style.right=d.style.right=p.style.right=""}l.style.top=s.style.top=m.style.top=f+"px",l.style[i]=d.style[i]=p.style[i]=k+"px",d.style.top=c.style.top=u.style.top=f+_+"px",s.style[i]=c.style[i]=b.style[i]=v+k+"px",m.style[i]=u.style[i]=k+v/2+"px",p.style.top=b.style.top=f+_/2+"px"}_openInlineToolbar(e){const t=this,a=t.$.editableElement;let o=t.$.inlineToolbar;if(t._closeToolbarItemDropDown(t.$.inputPopup),t._closeToolbarItemDropDown(t.$.colorInputPopup),"false"===a.getAttribute("contenteditable")||t.hideInlineToolbar)return void(o&&o.visible&&o.close());if(o||(o=t._createToolbar()),o.classList.remove("smart-editor-add-menu"),o.classList.remove("smart-editor-ai-menu"),t.$.fireEvent("inlineToolbarOpening",{target:o}).defaultPrevented)return;t._setupToolbar(e,"inline"),o.parentElement||t.getShadowRootOrBody().appendChild(o);const i=t._getInlineToolbarContent(e);o.clear(),i instanceof DocumentFragment&&(o.appendChild(i),o.open(),t._setAriaOwns(o)),t._updateToolbarItems(void 0,o)}_closeToolbar(){const e=this,t=e.$.inlineToolbar;if(t){const a=t.classList,o=a.contains("smart-editor-context-menu")?"contextMenu":a.contains("smart-editor-inline-toolbar")?"inlineToolbar":"dropDownToolbar";if(e._filterSortableMenuInput&&e._filterSortableMenuInput.block&&e._filterSortableMenuInput.dispatchEvent(new KeyboardEvent("keydown",{key:"Escape"})),e.$.fireEvent(o+"Closing",{target:t}).defaultPrevented)return;t.close()}}_closePopups(){const e=this;e._closeToolbar(),e._closeToolbarItemDropDown(e.$.inputPopup),e._closeToolbarItemDropDown(e.$.colorInputPopup)}_createToolbar(){const e=this;let t=e.$.inlineToolbar;return t||(t=document.createElement("smart-tooltip"),t.offset=[0,0],e.$.inlineToolbar=t,e.$inlineToolbar=Smart.Utilities.Extend(t),t)}_setupToolbar(e,t){const a=this,o=a.$.iframe,i=a.$.inlineToolbar,n=a.$inlineToolbar;if(!i.visible){const e=e=>a._tooltipVisibilityHandler.call(a,e),t=e=>a._tooltipVisibilityHandler.call(a,e),o=e=>a._tooltipChangeHandler.call(a,e),i=e=>a._tooltipClickHandler.call(a,e),r=e=>a._tooltipTransitionEndHandler.call(a,e);n.unlisten("open"),n.unlisten("close"),n.unlisten("change"),n.unlisten("click"),n.unlisten("transitionend"),n.listen("open",e),n.listen("close",t),n.listen("change",o),n.listen("click",i),n.listen("transitionend",r)}if(i.locale=a.locale,i.rightToLeft=a.rightToLeft,i.theme=a.theme,i.animation=a.animation,i.openMode="manual",i.style.height="","inline"===t)i.position="auto",i.iframeRect=o?o.getBoundingClientRect():null,i.arrow=!0,i.align="center",i.offset=a.inlineToolbarOffset,i.classList.add("smart-editor-toolbar","smart-editor-inline-toolbar"),i.classList.remove("smart-editor-drop-down-toolbar","smart-editor-context-menu"),i.setAttribute("role","tooltip"),i.setAttribute("aria-label","Inline Toolbar");else{if("context"!==t)return i.position="auto",i.iframeRect=null,i.arrow=!1,i.align=a.rightToLeft?"right":"left",i.offset=[0,-5],i.selector=e,i.classList.add("smart-editor-toolbar","smart-editor-drop-down-toolbar"),i.classList.remove("smart-editor-inline-toolbar","smart-editor-context-menu"),i.setAttribute("role","tooltip"),void i.setAttribute("aria-label","Drop Down Toolbar");i.position="absolute",i.arrow=!1,i.classList.add("smart-editor-context-menu"),i.classList.remove("smart-editor-toolbar","smart-editor-drop-down-toolbar","smart-editor-inline-toolbar"),i.setAttribute("role","listbox"),i.setAttribute("aria-label","Context Menu")}if(i.selector&&!i.selector.closest&&delete i.selector.getBoundingClientRect,e.closest)i.selector=e;else{const t=e.parentElement,o=a._getSelectionRange();t.getBoundingClientRect=()=>o.getBoundingClientRect(),i.selector=t}}_getInlineToolbarContent(e){const t=this,a=t.$.inlineToolbar;if(a.innerHTML&&a.selector.nodeName===e.nodeName)return;let o;const i=t._toolbarItemsObj,n=e.nodeName.toLowerCase(),r=(e=[])=>{let t;for(let a=0,o=e.length;a<o;a+=1){const o=i[e[a]];if(o){t=o;break}}return t};let l;switch(n){case"a":l=r(["hyperlink","createlink"]);break;case"#text":l=r(["cut","copy","paste"]);break;case"img":l=r(["image"]);break;case"td":case"th":l=r(["table"]);break;default:return}return o=l&&Array.isArray(l.inlineToolbarItems)?l.inlineToolbarItems:t._getDefaultInlineToolbarItems(e,n),o.length?t._getToolbarItems(a,o):void 0}_getDefaultInlineToolbarItems(e,t){let a;const o=this;switch(t){case"a":a=[{name:"openlink",title:o.localize("openlink")+" - "+e.href},"editLink","removeLink"];break;case"#text":{let e=[];this.ai.key&&(e=["ai"]),a=[...e,"cut","copy","paste","|","bold","italic","strikethrough","underline","fontsize","fontname","fontcolor","backgroundcolor"];break}case"img":a=["image","alignment","createlink","delete","caption"],e.closest(".smart-editor-editable a")&&a.splice(a.indexOf("createlink")+1,0,"openlink","removelink");break;case"td":case"th":a=["table","tableheader","tablerows","tablecolumns","backgroundcolor","fontcolor","delete","alignment","tablevalign","tablestyle"];break;default:return[]}return a}_getNodes(e,t=0,a,o=0){const i=this,n=e.childNodes;let r=[];for(let e=0,l=n.length;e<l;e+=1){const l=n[e];if(l.childElementCount){const e=i._getNodes(l,t,a,o);if(o=e.index,e.nodes.length&&(r=r.concat(e.nodes)),o>=a)break}else if(l.nodeType===Node.TEXT_NODE){const e=l.nodeValue;if(!e.trim())continue;const i=e.length;if(o+i>t&&r.push({node:l,index:a-o,startIndex:Math.max(0,t-o)}),(o+=i)>a)break}else if((o+=(l.textContent||l.innerText||l.innerHTML).length)>t&&r.push({node:l,index:o}),o>a)break}return{nodes:r,index:o}}_tooltipChangeHandler(e){const t=this,a=e.target,o=t.$.inlineToolbar;o&&o.classList.contains("smart-editor-drop-down-toolbar")&&o.visible&&o.contains(a)?a.classList.contains("smart-table-picker")&&(t._handleTableInsert({cells:e.detail.value}),o.close()):t._changeHandler(e)}_tooltipClickHandler(e){const t=this,a=e.target,o=t.$.inlineToolbar;if(o&&o.classList.contains("smart-editor-drop-down-toolbar")&&o.contains(e.target)&&a.closest(".smart-table-picker-button")){const e=t._getSelectionRange();let a;return e.startContainer&&["th","td"].indexOf(e.startContainer.nodeName.toLowerCase())>-1&&(a=e.startContainer.closest(".smart-editor-editable table")),void t._openWindow(o.selector,a)}if(o&&o.classList.contains("smart-editor-context-menu")){const o=a.closest(".smart-editor-context-menu-item");if(o)return void t._handleContextMenuItemClick(e,o)}}_tooltipVisibilityHandler(e){const t=this,a=t.$.inlineToolbar,o=e.type;if(e.target!==a)return;const i=t.$.inlineToolbar,n=t.$inlineToolbar;let r;r=a.classList.contains("smart-editor-toolbar")?(a.classList.contains("smart-editor-drop-down-toolbar")?"inline":"dropDown")+"Toolbar":"contextMenu",e.stopPropagation(),"close"===e.type?(i.selector&&!i.selector.closest&&delete i.selector.getBoundingClientRect,i.hasAnimation||(n.unlisten(e.type),n.unlisten("change"),n.unlisten("click"),i.remove(),t._focusEditableElement()),t._setAriaOwns(a)):"open"===e.type&&t._setAriaOwns(a),t.$.fireEvent(r+o.slice(0,1).toUpperCase()+o.slice(1),Object.assign({target:e.target},e.detail))}_tooltipTransitionEndHandler(e){const t=this;if(!(e.target instanceof Smart.Tooltip))return;const a=t.$.inlineToolbar,o=t.$inlineToolbar;a.visible||(o.unlisten("transitionend"),a.style.top=a.style.left=0,a.remove(),t._setAriaOwns(a))}_toggleItemDropDown(e){const t=this,a=e.getAttribute("item-type");let o;if("drop-down"===a?(t.$.inputPopup||(t.$.inputPopup=document.createElement("smart-input")),o=t.$.inputPopup):"color-input"===a&&(t.$.colorInputPopup||(t.$.colorInputPopup=document.createElement("smart-color-input")),o=t.$.colorInputPopup),o.noRipple=!0,t.$.inputPopup&&o===t.$.colorInputPopup&&t.$.inputPopup.parentElement?t._closeToolbarItemDropDown(t.$.inputPopup):t.$.colorInputPopup&&o===t.$.inputPopup&&t.$.colorInputPopup.parentElement&&t._closeToolbarItemDropDown(t.$.colorInputPopup),o)if(o.locale=t.locale,o.rightToLeft=t.rightToLeft,o.theme=t.theme,o.animation=t.animation,e.contains(o)&&o.opened)t._closeToolbarItemDropDown(o);else{const a=t.$.inlineToolbar;a&&!a.contains(e)&&t._closeToolbar(),o.remove(),t._openToolbarItemDropDown(e,o)}}_toggleDropDownToolbar(e){const t=this;if(!e)return;if("table"!==e.getAttribute("item-name"))return;const a=t.$.inlineToolbar;if(a&&a.visible&&a.classList.contains("smart-editor-drop-down-toolbar")){if(a.contains(e)){const a=t._getSelectionRange();let o;return a.startContainer&&["th","td"].indexOf(a.startContainer.nodeName.toLowerCase())>-1&&(o=a.startContainer.closest(".smart-editor-editable table")),void t._openWindow(e,o)}a.classList.contains("smart-editor-drop-down-toolbar")&&a.close()}else t._closeToolbarItemDropDown(t.$.inputPopup),t._closeToolbarItemDropDown(t.$.colorInputPopup),t._openDropDownToolbar(e)}_openDropDownToolbar(e){const t=this;let a=t.$.inlineToolbar;a||(a=t._createToolbar()),t.$.fireEvent("dropDownToolbarOpening",{target:a}).defaultPrevented||(t._setupToolbar(e,"dropDown"),a.parentElement||t.getShadowRootOrBody().appendChild(a),t._setDropDownToolbarContent(e),a.open(),t._setAriaControls(e,a))}_setDropDownToolbarContent(e){const t=this,a=t.$.inlineToolbar,o=e.getAttribute("item-name");let i=t._dropDownToolbarObj;i||(i=t._dropDownToolbarObj={});let n=i[o];n||(n=document.createElement("smart-table-picker"),i[o]=n),n.rightToLeft=t.rightToLeft,n.locale=t.locale,n.messages=t.messages,n.value=[],a.contains(n)||(a.clear(),a.appendChild(n))}_openSearchBar(){const e=this,t=e.$.editableElement,a=e.$.contentContainer;let o=e._searchToolbar;if(e.disableSearchBar||t.classList.contains("smart-hidden"))return void(o&&o.remove());o||(o=e._searchToolbar=document.createElement("div"),o.classList.add("smart-editor-search-bar"),o.innerHTML='<span class="smart-search-input-container">\n <input class="smart-search-input"></input>\n </span>\n <smart-button class="smart-search-button prev"></smart-button>\n <smart-button class="smart-search-button next"></smart-button>\n <smart-button class="smart-search-button close"></smart-button>'),o.ontransitionend=null;const i=e.animation,n=e.theme,r=e.rightToLeft,l=o.children;let s;for(let t=0,a=l.length;t<a;t+=1){const a=l[t];if(a.classList.contains("smart-search-input-container")){const t=a.firstElementChild;t.placeholder=e.localize("searchPlaceholder"),s=t}a.animation=i,a.theme=n,a.rightToLeft=r}if(a.contains(o)||a.appendChild(o),o.classList.remove("smart-visibility-hidden"),s){const t=e.$.iframe,a=(t?t.contentWindow:window).getSelection().toString();s.value=a,s.focus({preventScroll:!0}),a&&e._applySearching(a)}delete e._lastSearchQuery}_closeSearchToolbar(){const e=this,t=e._searchToolbar;if(t&&!t.classList.contains("smart-visibility-hidden")){t.classList.add("smart-visibility-hidden"),t.ontransitionend=()=>{t.remove(),t.ontransitionend=null};const a=Array.from(e.$.editableElement.querySelectorAll(".find-and-replace-match"));for(let e=0,t=a.length;e<t;e+=1){const t=a[e];t.outerHTML=t.textContent}e._focusEditableElement()}}_toggleWindow(e,t){const a=this;if(!e)return;const o=e.getAttribute("item-name"),i=a.$.window;if(!i)return void a._openWindow(e,t);const n=i._target?i._target.item:void 0;!n||n.name!==o||n.name===o&&!i.opened?a._openWindow(e,t):i.close()}_openWindow(e,t){const a=this;if(!e||!a._toolbarItemsObj||a._window&&a._window.opened)return;let o;t&&t.classList.contains("smart-editor-video-container")&&(t=t.querySelector(".smart-editor-video-container > video, .smart-editor-video-container > iframe"));const i=a.$.editableElement;if(e.closest){if(!e.classList.contains("smart-editor-toolbar-item"))return;o=(e.closest(".smart-editor-inline-toolbar")?a._inlineToolbarItemsObj:a._toolbarItemsObj)[e.getAttribute("item-name")]}else"object"==typeof e&&"string"==typeof e.name&&(o=e);if(!o||"findandreplace"===o.name&&i.classList.contains("smart-hidden"))return;const n=a._createWindow(o);a.$.fireEvent("dialogOpening",{target:n,item:o}).defaultPrevented||(a._closeToolbarItemDropDown(a.$.inputPopup),a._closeToolbarItemDropDown(a.$.colorInputPopup),n._target={item:o,itemTarget:t,originalTarget:e},a._closeToolbar(),n.parentElement||a.getShadowRootOrBody().appendChild(n),n.isCompleted?a._setupWindow():n.whenReady((()=>a._setupWindow())))}_closeWindow(){const e=this,t=e.$.window;t&&t.opened&&(e.$.fireEvent("dialogClosing",{target:t,item:t._target.item}).defaultPrevented||t.close())}_setupWindow(){const e=this,t=e.$.window,a=t._target,o=a.item;function i(){e._positionWindow(),t.opened?(t.bringToFront(),t._handleActiveState(),t._onOpenCallback&&t._onOpenCallback()):t.open()}if(t.locale=e.locale,t.rightToLeft=e.rightToLeft,t.theme=e.theme,t.animation=e.animation,e.windowCustomizationFunction?e.windowCustomizationFunction(t,o):(e._setPopupWindowTemplate("header",o),e._setPopupWindowTemplate("footer",o),e._setPopupWindowTemplate("content",o)),!t.opened){const a=e.$window,o=t=>e._windowOpenHandler.call(e,t),i=t=>e._windowCloseHandler.call(e,t),n=t=>e._windowClickHandler.call(e,t),r=t=>e._windowChangeHandler.call(e,t),l=t=>e._windowKeyDownHandler.call(e,t),s=t=>e._windowKeyUpHandler.call(e,t),d=t=>e._windowTransitionendHandler.call(e,t),c=t=>e._fileUploadCompletedHandler.call(e,t),m=t=>e._fileUploadErrorHandler.call(e,t);a.unlisten("transitionend"),a.unlisten("open"),a.unlisten("close"),a.unlisten("click"),a.unlisten("change"),a.unlisten("keydown"),a.unlisten("keyup"),a.unlisten("uploadCompleted"),a.unlisten("uploadError"),t._onOpenCallback=()=>{((t.shadowRoot||t).querySelector(".smart-editor-window-editor:not(.smart-hidden) .smart-input.smart-element")||t).focus({preventScroll:!0})},t.hasAnimation&&a.listen("transitionend",d),a.listen("open",o),a.listen("close",i),a.listen("click",n),a.listen("change",r),a.listen("keydown",l),a.listen("keyup",s),a.listen("uploadCompleted",c),a.listen("uploadError",m)}t.shadowRoot?e._onShadowDomLoaded(t,"smart.window.css",i):i(),e._setAriaOwns(t),e._setAriaControls(a.originalTarget,t)}_setPopupWindowTemplate(e,t){const a=this,o=a.$.window;if(!o)return;if("content"===e)return void a._setWindowContent(t);o[e+"Template"]||(o[e+"Template"]=a._createWindowTemplate(e));const i=o._target.item;if("header"===e)o.label=a.localize(i.name)||"";else if("footer"===e){const e=(o.shadowRoot||o).querySelectorAll(".smart-editor-window-button"),i="findandreplace"===t.name;for(let t=0;t<e.length;t++){const o=e[t];o.innerHTML='<span class="smart-icon"></span>',o.theme=a.theme,o.rightToLeft=a.rightToLeft,o.animation=a.animation,o.classList.contains("ok")?i?(o.classList.add("replace"),o.innerHTML+=a.localize("replace"),o.setAttribute("aria-label","replace")):(o.classList.remove("replace"),o.innerHTML+=a.localize("ok"),o.setAttribute("aria-label","ok")):o.classList.contains("cancel")?(o.innerHTML+=a.localize("cancel"),o.setAttribute("aria-label","cancel")):i?(o.classList.contains("replace-all")&&(o.innerHTML+=a.localize("replaceAll"),o.setAttribute("aria-label","replaceAll")),o.classList.remove("smart-hidden")):o.classList.add("smart-hidden");const n=o.querySelector(".smart-ripple");n&&n.parentElement.removeChild(n)}}}_adjustPopupBounds(e){const t=window.innerHeight+window.pageYOffset,a=this.offset(e);a.bottom=a.top+e.offsetHeight;let o=a.top;e.style.height="";let i=e.offsetHeight;a.bottom>t&&(a.top-i>=0?o=a.top-i-30:(i=Math.min(i,t-a.top-10),i<100&&(i=100))),o<0&&(o=10),e.style.top=`${o}px`,e.style.height=`${i}px`}_setWindowContent(e){const t=this,a=t.$.window,o=a._target.originalTarget,i=[].slice.call(a.getElementsByClassName("smart-editor-window-editor"));if((!a.innerHTML||i.length)&&o){switch(e.name){case"createlink":case"editlink":case"hyperlink":case"image":case"video":case"file":case"table":case"paste":case"findandreplace":t._createWindowEditors(e)}o.id&&a.setAttribute("aria-controls",o.id)}}_createWindowEditors(e){const t=this,a=t.$.window,o=e.name;let i,n=t._windowEditors,r=a.querySelector(".smart-editor-window-content-wrapper");r||(r=document.createElement("div"),r.classList.add("smart-editor-window-content-wrapper"),a.appendChild(r)),t._windowEditors||(n=t._windowEditors={}),n&&(i=n[o]),i||(i=document.createElement("div"),i.classList.add(`smart-editor-window-${o}`),i.innerHTML=t._getWindowEditorTemplate(o),n[o]=i),r.contains(i)||(r.innerHTML="",r.appendChild(i));const l=i.querySelectorAll(".smart-editor-window-editor[type]");for(let e=0;e<l.length;e++)t._setPopupWindowEditor(l[e])}_getWindowEditorTemplate(e){const t=this;switch(e){case"createlink":case"editlink":case"hyperlink":return'\n <div class="smart-editor-window-editor" type="address">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="text">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="title">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="target">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>';case"image":return t.compactImageDialog?'\n <div class="smart-editor-window-editor" type="file">\n <smart-file-upload item-editor></smart-file-upload>\n </div>\n <div class="smart-editor-window-editor" type="url">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="width">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="height">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>':'\n <div class="smart-editor-window-editor" type="file">\n <smart-file-upload item-editor></smart-file-upload>\n </div>\n <div class="smart-editor-window-editor" type="url">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="width">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="height">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="alt">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="title">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="caption">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="display">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="alignment">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="draggable">\n <smart-check-box item-editor></smart-check-box>\n </div>\n <div class="smart-editor-window-editor" type="resizable">\n <smart-check-box item-editor></smart-check-box>\n </div>';case"file":return'\n <div class="smart-editor-window-editor" type="file">\n <smart-file-upload item-editor></smart-file-upload>\n </div>\n <div class="smart-editor-window-editor" type="fileUrl">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n ';case"table":return'\n <div class="smart-editor-window-editor" type="cols">\n <label></label>\n <smart-number-input item-editor></smart-number-input>\n </div>\n <div class="smart-editor-window-editor" type="rows">\n <label></label>\n <smart-number-input item-editor></smart-number-input>\n </div>\n <div class="smart-editor-window-editor" type="width">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="height">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="tableheader">\n <smart-check-box item-editor></smart-check-box>\n </div>\n <div class="smart-editor-window-editor" type="altrows">\n <smart-check-box item-editor></smart-check-box>\n </div>\n <div class="smart-editor-window-editor" type="dashedborders">\n <smart-check-box item-editor></smart-check-box>\n </div>\n <div class="smart-editor-window-editor" type="resizable">\n <smart-check-box item-editor></smart-check-box>\n </div>';case"paste":return'\n <div class="smart-editor-window-editor" type="keepFormat">\n <label></label>\n <smart-radio-button checked group-name="editorPasteViaWindow" item-editor></smart-radio-button>\n </div>\n <div class="smart-editor-window-editor" type="cleanFormat">\n <smart-radio-button group-name="editorPasteViaWindow" item-editor></smart-radio-button>\n </div>\n <div class="smart-editor-window-editor" type="plainText">\n <smart-radio-button group-name="editorPasteViaWindow" item-editor></smart-radio-button>\n </div>';case"findandreplace":return'\n <div class="smart-editor-window-editor" type="find">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="replaceWith">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="results">\n <label></label>\n <smart-list-box virtualized item-editor></smart-list-box>\n </div>\n <div class="smart-editor-window-editor" type="matchCase">\n <smart-check-box item-editor></smart-check-box>\n </div>';case"video":return'\n <div class="smart-editor-window-editor" type="file">\n <smart-file-upload item-editor></smart-file-upload>\n </div>\n <div class="smart-editor-window-editor" type="src">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="width">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="height">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="thumbnail">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="videoUrl">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="alt">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="title">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="caption">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="display">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="alignment">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="draggable">\n <smart-check-box item-editor></smart-check-box>\n </div>\n <div class="smart-editor-window-editor" type="resizable">\n <smart-check-box item-editor></smart-check-box>\n </div>';default:return""}}_setPopupWindowEditor(e){const t=this,a=e.getAttribute("type"),o=e.querySelector("label"),i=t.$.window._target,n=i.item,r="markdown"===t.editMode,l=n.editor;let s,d=e.querySelector("[item-editor]");if(o&&("paste"===n.name?(o.id=t.id+"pasteLabel",o.innerHTML=t.localize("pasteLabel")||""):(o.id=t.id+a+"Label",o.innerHTML=t.localize(a)||"")),!d)return;const c=t._toolbarItemClick;let m;switch(m=c?c.target:i.itemTarget,n.name){case"hyperlink":case"createlink":case"editlink":{const o=t._getSelectionRange();let i=o.startContainer;i&&"a"!==i.nodeName.toLowerCase()&&(i=i.parentElement),i&&"a"===i.nodeName.toLowerCase()?"address"===a?s=i.getAttribute("href"):"text"===a?s=i.textContent:"title"===a?s=i.title:"target"===a&&(s=i.target):s="text"===a?r?t.$.input.value.slice(o.selectionStart,o.selectionEnd):o.toString():l&&void 0!==l[a]?l[a]+"":"","target"===a&&r||m&&"img"===m.nodeName.toLowerCase()&&["title","text"].indexOf(a)>-1?e.classList.add("smart-hidden"):e.classList.remove("smart-hidden");break}case"video":case"file":case"image":{const o=t._toolbarItemClick,d=o?o.target:i.itemTarget;if(d&&["img","video","iframe"].indexOf(d.nodeName.toLowerCase())>-1){const e=d.closest(".smart-editor-image-container");switch(a){case"file":d.file instanceof File&&(s=d.file);break;case"url":case"src":s=d.file instanceof File?"":d.getAttribute("src")||"";break;case"alt":s=d.alt;break;case"title":s=d.title;break;case"width":if(s=d.style.width||(e?e.style.width:""),!s){const e=d.getAttribute("width");e&&(s=e)}break;case"height":if(s=d.style.height||(e?e.style.height:""),!s){const e=d.getAttribute("height");e&&(s=e)}break;case"caption":if(e){const t=e.querySelector(".smart-editor-image-caption");t&&(s=t.textContent)}void 0===s&&(s="");break;case"alignment":s=(e||d).getAttribute("alignment")||"";break;case"display":s=(e||d).getAttribute("display")||"";break;case"draggable":case"resizable":{const t=("video"===n.name?e:d).getAttribute(a);s=null==t||"true"===t;break}}}else s=l?("draggable"===a||"resizable"===a)&&void 0===l[a]||(void 0!==l[a]?l[a]+"":""):"width"===a?480:"height"===a?270:"draggable"===a||"resizable"===a||"";r&&["file","url","videoUrl","alt","title","thumbnail"].indexOf(a)<0||!r&&"video"===n.name&&["alt","thumbnail","videoUrl"].indexOf(a)>-1?e.classList.add("smart-hidden"):e.classList.remove("smart-hidden");break}case"table":{const t=i.itemTarget&&"table"===i.itemTarget.nodeName.toLowerCase()?i.itemTarget:void 0;switch(a){case"width":case"height":s=t?t.style[a]:l&&void 0!==l[a]?l[a]:"";break;case"cols":s=t?t.querySelector("tbody > tr").children.length+"":l&&void 0!==l[a]?l[a]:"1";break;case"rows":s=t?t.querySelectorAll("tbody > tr").length+"":l&&void 0!==l[a]?l[a]:"1";break;case"tableheader":s=!!r||(t?null!==t.querySelector("thead"):!(!l||void 0===l[a])&&l[a]);break;case"altrows":s=t?t.hasAttribute("alternation"):!(!l||void 0===l[a])&&l[a];break;case"dashedborders":s=t?t.hasAttribute("dashed-borders"):!(!l||void 0===l[a])&&l[a];break;case"resizable":s=t?!("false"===t.getAttribute("resizable")):!l||void 0===l[a]||l[a]}r&&["cols","rows","tableheader"].indexOf(a)<0?e.classList.add("smart-hidden"):e.classList.remove("smart-hidden");break}case"paste":s=a===t.pasteFormat;break;case"findandreplace":s=l&&void 0!==l[a]?l[a]:""}t._setupEditorElement(d,a,s),t._setEditorCommonProperties(d)}_setupEditorElement(e,t,a){const o=this,i=o.$.window._target.item,n=i.editor,r="markdown"===o.editMode;if((e instanceof Smart.CheckBox||e instanceof Smart.RadioButton)&&(e.innerHTML=o.localize(t)||"",e.checked=!!a),e instanceof Smart.NumberInput)e.min=1,e.value=parseInt(a);else{if(e instanceof Smart.FileUpload)return"file"===t&&e.isCompleted&&(e.cancelAll(),a&&e.addFile(a)),e.uploadUrl="",e.removeUrl="",e.autoUpload=!1,o.postData?e.postData=o.postData:o.getAttribute("post-data")&&(e.postData=JSON.parse(o.getAttribute("post-data"))),o.uploadUrl&&(e.uploadUrl=o.uploadUrl,o._fileUpload=e,o._fileUpload.name=o.imageName,e.autoUpload=o.autoUpload),o.removeUrl&&(e.removeUrl=o.removeUrl),o.validateFile&&(e.validateFile=o.validateFile),n&&(n.uploadUrl&&(e.uploadUrl=n.uploadUrl,e.autoUpload=!0),n.removeUrl&&(e.removeUrl=n.removeUrl)),e.dropZone=e.parentElement,e.accept=i.allowedTypes||(r||"video"!==i.name?"image/*":"video/mp4,video/x-m4v,video/*"),"file"===i.name&&(e.accept=i.allowedTypes||"*"),void(e.hideFooter=!0);if(e instanceof Smart.ListBox)e.selectionMode="one",e.itemHeight=35;else{if("string"==typeof e.placeholder&&(e.placeholder=o.localize(t+"Placeholder")||""),e.dropDownClassList&&(e.dropDownClassList=["smart-editor-input"]),void 0!==e.dataSource){if("target"===t||"alignment"===t||"display"===t){e.dataSource.length||(e.dataSource=o._getDefaultDataSource(t)),"alignment"!==t||a||(a="center");const i=a?e.dataSource.find((e=>"object"==typeof e&&e.value===a)):void 0;i&&"object"==typeof i&&(a=i.label||a),e.readonly=!i&&!a||i&&""!==i.value}else e.dataSource=[];"string"==typeof e.dropDownButtonPosition&&(e.dropDownButtonPosition=e.dataSource.length?o.rightToLeft?"left":"right":"none")}e.value=void 0===a?"":a+""}}}_setEditorCommonProperties(e){const t=this;if(e){const a=e.messages,o=t.messages,i=t.locale;for(let e in a.en){const t=o[i][e];void 0!==t&&(a[i]||(a[i]={}),a[i][e]=t)}e.locale=t.locale,e.rightToLeft=t.rightToLeft,e.animation=t.animation,e.theme=t.theme}}_createWindow(){const e=this,t=e.$.window;if(t)return t;const a=document.createElement("smart-window");return a.classList.add("smart-editor-window"),a.id=e.id+"Window",a.setAttribute("smart-id","window"),e.$.window=a,e.$window=Smart.Utilities.Extend(a),a.rightToLeft=e.rightToLeft,a.theme=e.theme,a.animation=e.animation,a.disableSnap=!0,a.headerButtons=["close"],a.style.zIndex=999999,a}_createWindowTemplate(e){const t=this,a=t.animation,o=t.theme,i=t.rightToLeft;let n;return"footer"===e&&(n=document.createElement("template"),n.innerHTML=`<smart-button class="smart-editor-window-button primary replace replace-all smart-hidden"\n animation="${a}" theme="${o}" ${i?"right-to-left":""}>\n </smart-button>\n <smart-button class="smart-editor-window-button ok primary"\n animation="${a}" theme="${o}" ${i?"right-to-left":""}>\n </smart-button>\n <smart-button class="smart-editor-window-button cancel"\n animation="${a}" theme="${o}" ${i?"right-to-left":""}>\n </smart-button>`),n}_positionWindow(){const e=this,t=e.getShadowRootOrBody(),a=e.$.window;if(!a||!t.contains(a))return;const o=e.getBoundingClientRect();a.opened||(a.style.left=a.style.top=""),a.style.left=Math.max(o.left+window.pageXOffset,o.left+window.pageXOffset+o.width/2-a.offsetWidth/2)+"px",a.style.top=Math.max(o.top+window.pageYOffset,o.top+window.pageYOffset+o.height/2-a.offsetHeight/2)+"px"}_windowChangeHandler(e){const t=this,a=e.detail,o=t.$.window._target.item;let i=(e.originalEvent||e).target;const n=i.closest(".smart-editor-window-editor");if(!i.hasAttribute("item-editor")||!o||!n)return;const r=n.getAttribute("type");if(o.name.indexOf("link")>0&&"target"===r&&i instanceof Smart.Input)i.readonly=!!a.value.length;else if(t._windowEditors&&o.name.indexOf("findandreplace")>-1)if("results"===r&&i instanceof Smart.ListBox)t._handleMarkerSelection(e.target);else if("matchCase"===r&&i instanceof Smart.CheckBox){const e=n.parentElement.querySelector('.smart-editor-window-editor[type="find"] [item-editor]');e&&t._findMatches(e.value)}}_windowClickHandler(e){const t=this;let a=(e.originalEvent||e).target;a.shadowRoot&&(a=(e.originalEvent||e).composedPath()[0]);const o=t.$.window,i=o._target,n=a.closest(".smart-editor-window-button");if(o&&n&&i){if("findandreplace"===i.item.name){const e=n.classList,a=n.classList.contains("replace-all");if(a||e.contains("ok"))return void t._replaceMatches(o._target.item,a)}else if(n.classList.contains("ok")&&!1===t._updateEditorViaWindow(i.item))return;o.close(),delete o._target}}_windowCloseHandler(e){const t=this,a=e.target;if(!a.classList.contains("smart-editor-window"))return;const o=t.$window;if(o){t.$.fireEvent("dialogClose",{target:e.target,item:e.target._target.item}),o.unlisten("close"),o.unlisten("click"),o.unlisten("change"),o.unlisten("keydown"),o.unlisten("uploadCompleted"),o.unlisten("uploadError"),t.hasAttribute("aria-owns")&&t.removeAttribute("aria-owns"),t.hasAnimation||(a.remove(),t._setAriaOwns(a));const i=a._target,n=i.itemTarget;if("findandreplace"===i.item.name&&t._findMatches(""),t._focusEditableElement(),"blockHtml"===t.editMode&&(t._editorBlocks=t.$.editableElement.querySelectorAll(".smart-editor-block")),n&&["img","th","td","table"].indexOf(n.nodeName.toLowerCase())>-1)return void t._setResizeFrame(n)}}_windowKeyDownHandler(e){const t=this,a=t.$.window;if("Enter"!==e.key||!a._target)return;const o=a._target.item,i=a.getRootNode().activeElement;if(o&&i.closest(".smart-editor-window-editor")){if(!1===t._updateEditorViaWindow(o))return;e.stopPropagation(),e.preventDefault(),a.close(),delete a._target}}_windowKeyUpHandler(e){const t=this,a=e.target;if(a.closest('.smart-editor-window-editor[type="find"]')){const e=a.closest("[item-editor]");if(e){const a=t.findAndReplaceTimeout;if(clearTimeout(t._findAndReplaceTimeout),"html"!==t.editMode)return;a?t._findAndReplaceTimeout=setTimeout((()=>t._findMatches(e.value)),a):t._findMatches(e.value)}}}_windowOpenHandler(e){const t=this,a=e.target;if(!a.classList.contains("smart-editor-window"))return;const o=t.$window;if(o){const i=a._target.item;if(t._setAriaOwns(a),t.$.fireEvent("dialogOpen",{target:e.target,item:i}),o.unlisten("open"),"findandreplace"===i.name){const e=a.querySelector('.smart-editor-window-editor[type="find"] [item-editor]');t._findMatches(e?e.value:"")}}}_windowTransitionendHandler(e){const t=this,a=e.target;a.classList.contains("smart-editor-window")&&(a.opened||"visibility"!==e.propertyName||(t.$window.unlisten("transitionend"),t.$.window.remove(),t._setAriaOwns(a)))}_updateEditorViaWindow(e){const t=this;if(!e||!t._windowEditors)return;const a=t.$.iframe,o=t.$.editableElement;let i,n;t.$.contentContainer.contains(o.getRootNode().activeElement)||t._focusEditableElement(),a?(i=a.contentWindow,n=i.getSelection()):(i=window,n=window.getSelection());const r=t._windowEditors[e.name],l=t._getSelectionRange();let s;if(r&&!t.$.fireEvent("actionStart",{name:e.name}).defaultPrevented){switch(l instanceof i.Range&&(n.removeAllRanges(),n.addRange(l)),e.name){case"editlink":case"createlink":case"hyperlink":s=t._handleLinksInsert(e);break;case"image":s=t._handleImageInsert(e);break;case"table":t._handleTableInsert(t._getItemOptionsViaWindow(e));break;case"paste":t._handlePasteViaWindow(e);break;case"video":s=t._handleVideoInsert(e);break;case"file":s=t._handleFileInsert(e)}return t.$.fireEvent("actionEnd",{name:e.name}),s?(s(),!1):void 0}}_focusFirstInputCallback(e,t){const a=this._windowEditors[e];if(a)return()=>{const e=a.querySelector(`.smart-editor-window-editor[type="${t}"] .smart-input[item-editor]`);e&&e.focus({preventScroll:!0})}}_fileUploadCompletedHandler(e){const t=this.$.window;let a;t&&t.opened&&t._target&&(a=t._target.item),e.stopPropagation(),this.$.fireEvent("imageUploadSuccess",Object.assign({target:e.target,toolbarItem:a},e.detail));const o=e.detail.fileURL,i=e.detail.serverResponse,n=t.querySelector('[type="url"] [item-editor]');o?(n.value=o,n._details=e.detail):i&&(Array.isArray(i)?e.detail.serverResponse[0].file_url?n.value=e.detail.serverResponse[0].file_url:e.detail.serverResponse[0].fileURL&&(n.value=e.detail.serverResponse[0].fileURL):e.detail.serverResponse.file_url?n.value=e.detail.serverResponse.file_url:e.detail.serverResponse.fileURL&&(n.value=e.detail.serverResponse.fileURL))}_fileUploadErrorHandler(e){const t=this.$.window;let a;t&&t.opened&&t._target&&(a=t._target.item),e.stopPropagation(),this.$.fireEvent("imageUploadFailed",Object.assign({target:e.target,toolbarItem:a},e.detail))}_replaceMatches(e,t){const a=this,o=a.$.editableElement;if(!e||!a._windowEditors||"html"!==a.editMode||o.classList.contains("smart-hidden"))return;const i=a._getItemOptionsViaWindow(e),n=a._windowEditors[e.name],r=n.querySelector('.smart-editor-window-editor[type="results"] smart-list-box[item-editor]'),l=n.querySelector('.smart-editor-window-editor[type="results"] label'),s=r.selectedIndexes;if(!i||!s||!s.length)return;const d=i.replaceWith,c=Array.from(o.querySelectorAll(".find-and-replace-match"));for(let e=0,a=c.length;e<a;e+=1){const a=c[e];(t||s.indexOf(e)>-1)&&(a.outerHTML=d)}t?r.dataSource=[]:s.forEach((e=>r.removeAt(e))),a._setFindAndReplaceLabel(l,r)}_findMatches(e){const t=this,a=t.$.editableElement,o=t._windowEditors,i=o?o.findandreplace:void 0,n=i.querySelector('.smart-editor-window-editor[type="results"] smart-list-box[item-editor]'),r=i.querySelector('.smart-editor-window-editor[type="results"] label'),l=i.querySelector('.smart-editor-window-editor[type="matchCase"] smart-check-box[item-editor]'),s=t.$.window.querySelectorAll(".smart-editor-window-button.replace");n&&"smart-list-box"===n.nodeName.toLowerCase()&&(n.dataSource=[]),t._findAndReplaceTimeout&&(clearTimeout(t._findAndReplaceTimeout),delete t._findAndReplaceTimeout);const d=Array.from(a.querySelectorAll(".find-and-replace-match"));for(let e=0,t=d.length;e<t;e+=1){const t=d[e];t.outerHTML=t.textContent}if("html"===t.editMode)if(e){n.dataSource=t._getFindMarkers(a,new RegExp(e,"gm"+(l.checked?"":"i")),[]),n.select("0"),t._setFindAndReplaceLabel(r,n);for(let e=0,t=s.length;e<t;e+=1)s[e].disabled=!1}else{t._setFindAndReplaceLabel(r);for(let e=0,t=s.length;e<t;e+=1)s[e].disabled=!0}}_clearSearchToolbar(){const e=this,t=e._searchToolbar;t&&!t.classList.contains("smart-visibility-hidden")&&(t.value="",delete e._lastSearchQuery)}_applySearching(e){const t=this,a=t.$.editableElement;if(t._lastSearchQuery===e||a.classList.contains("smart-hidden"))return;const o=t.$.contentContainer.querySelector(".smart-search-input-container");let i;t._findAndReplaceTimeout&&(clearTimeout(t._findAndReplaceTimeout),delete t._findAndReplaceTimeout);const n=Array.from(a.querySelectorAll(".find-and-replace-match"));for(let e=0,t=n.length;e<t;e+=1){const t=n[e];t.outerHTML=t.textContent}if("html"===t.editMode){if(e){i=t._getFindMarkers(a,new RegExp(e,"gmi"),[]).length;const o=a.querySelector(".find-and-replace-match");o&&(o.classList.add("selected"),t._scrollToMarker(o))}o&&(o.setAttribute("matches",i||0),o.setAttribute("selected",i?1:0)),t._lastSearchQuery=e}}_scrollToMarker(e){const t=this,a=t._searchToolbar,o=a&&!t._searchToolbar.classList.contains("smart-visibility-hidden")?a.offsetHeight:0,i=t.$.editableElement,n=i.getBoundingClientRect(),r=e.getBoundingClientRect(),l=i.scrollLeft,s=i.scrollTop,d=n.height,c=n.width,m=r.height,u=r.width,p=r.top-n.top+s,b=r.left-n.left+l;s+o>p||l>b?i.scrollTo(b-c,p-o-10):(s+d<p+m||l+c<b+u)&&i.scrollTo(b+u-c,p+m-d)}_setFindAndReplaceLabel(e,t){if(!e)return;const a=t?t.items.length:0;if(!t||!a)return e.removeAttribute("matches"),void e.removeAttribute("selected");if(e){const o=t.selectedIndexes[0];e.setAttribute("matches",a),e.setAttribute("selected",o?o+1:1)}}_getFindMarkers(e,t,a){const o=this,i=Array.from(e.childNodes);for(let e=0,n=i.length;e<n;e+=1){const n=i[e];if(n.childElementCount)o._getFindMarkers(n,t,a);else if(n.textContent){const e=document.createDocumentFragment(),o=n.textContent;let i,r=0;if(o.matchAll)i=Array.from(o.matchAll(t));else{let e;for(i=[];e=t.exec(o);)i.push(e)}if(i.forEach((t=>{const o=t.input,i=t.index,n=t[0],l=o.substring(r,i),s=a.length,d=document.createElement("span");l.length&&e.appendChild(document.createTextNode(l)),d.classList.add("find-and-replace-match"),d.setAttribute("match-id",s),d.textContent=n,e.appendChild(d);const c=o.substring(Math.max(0,i-10),i),m=o.substr(i+n.length,10);a.push({label:`${i>0?"...":""}${c}<b>${n}</b>${m}${i<o.length-1?"...":""}`,value:s}),r=i+n.length})),!e.childElementCount)continue;const l=n.textContent.substr(r);l&&e.appendChild(document.createTextNode(l)),n.nodeType===Node.TEXT_NODE?(n.parentElement.insertBefore(e,n),n.remove()):(n.innerHTML="",n.appendChild(e))}}return a}_handleMarkerSelection(e){const t=this,a=e.selectedValues[0],o=t.$.editableElement.querySelectorAll(`.find-and-replace-match.selected, .find-and-replace-match[match-id="${a}"]`);let i;for(let e=0,t=o.length;e<t;e+=1){const t=o[e];t.getAttribute("match-id")===a?(t.classList.add("selected"),i=t):t.classList.remove("selected")}i&&t._scrollToMarker(i);const n=t._windowEditors,r=n?n.findandreplace:void 0,l=r?r.querySelector('.smart-editor-window-editor[type="results"] label'):void 0;if(l){const t=e.selectedIndexes;l.setAttribute("selected",t.length?t[0]+1:0)}}_handleImageInsert(e){const t=this,a=t._getItemOptionsViaWindow(e),o=t.$.window;if(!o)return;"blockHtml"===t.editMode&&t._insertBlock();let i,n,r,l,s,d=o._target.itemTarget;if(a.file.length?(l=a.file[0],i=URL.createObjectURL(l)):a.url&&(i=a.url+""),!i&&a)return t._focusFirstInputCallback(e.name,"url");if("markdown"===t.editMode)return n=a.title?` "${a.title}"`:"",void t._insertMarkDown(`![${a.alt}](${i}${n})`);const c=t.$.iframe,m=t.$.editableElement,u=c?c.contentDocument:document;if(!d||"img"!==d.nodeName.toLowerCase()){const e=t.id+"newImage"+Math.random().toString(36).substr(2,5);s=u.execCommand("insertHTML",!1,`<img id="${e}"></img>`),d=m.querySelector("#"+e)}if(d&&"img"===d.nodeName.toLowerCase()){const e=a.display&&"inline"===a.display.toLowerCase()?"inline":"block",o=a.width+"",n=a.height+"";if(t._handleImgCaption(d,a),s&&(d.id=""),URL.revokeObjectURL(d.src),d.src=i,l&&(d.file=l,"base64"===t.imageFormat)){const e=new FileReader;e.readAsDataURL(l),e.onload=()=>d.src=e.result}if(t.uploadUrl&&t._fileUpload&&(d.name=i.replace(t.uploadUrl+"/",""),!t.autoUpload)){const e=e=>{t.$.fireEvent("imageUploadSuccess",e.detail);const a=e.detail.fileURL,o=e.detail.serverResponse;a?d.src=a:o&&(Array.isArray(o)?e.detail.serverResponse[0].file_url?d.src=e.detail.serverResponse[0].file_url:e.detail.serverResponse[0].fileURL&&(d.src=e.detail.serverResponse[0].fileURL):e.detail.serverResponse.file_url?d.src=e.detail.serverResponse.file_url:e.detail.serverResponse.fileURL&&(d.src=e.detail.serverResponse.fileURL))};t._fileUpload.onuploadcompleted=e,t._fileUpload.onuploaderror=e=>{console.error(e.detail)},t._fileUpload.uploadAll()}if(d.removeAttribute("width"),d.removeAttribute("height"),d.style.width=o&&"auto"!==o?parseFloat(o)+(o.indexOf("%")>-1?"%":"px"):"",d.style.height=n&&"auto"!==n?parseFloat(n)+(n.indexOf("%")>-1?"%":"px"):"",a.alt&&(d.alt=a.alt),a.title&&(d.title=a.title),a.alignment){const e=a.alignment.toLowerCase();r=e.indexOf("left")>-1?"left":e.indexOf("right")>-1?"right":"center"}d.setAttribute("resizable",a.resizable),d.setAttribute("draggable",a.draggable);const c=d.closest(".smart-editor-image-container");c?(c.setAttribute("alignment",r),c.setAttribute("display",e),d.removeAttribute("alignment"),d.removeAttribute("display")):(d.setAttribute("alignment",r),d.setAttribute("display",e))}}_handleFileInsert(e){const t=this,a=t._getItemOptionsViaWindow(e),o=t.$.window;if(!o)return;"blockHtml"===t.editMode&&t._insertBlock();let i,n,r,l,s=o._target.itemTarget;if(a.file.length?(r=a.file[0],i=URL.createObjectURL(r)):a.url&&(i=a.url+""),!i&&a)return t._focusFirstInputCallback(e.name,"url");if("markdown"===t.editMode)return n=a.title?` "${a.title}"`:"",void t._insertMarkDown(`![''](${i}${n})`);const d=t.$.iframe,c=t.$.editableElement,m=d?d.contentDocument:document;if(!s||"a"!==s.nodeName.toLowerCase()){const e=t.id+"newImage"+Math.random().toString(36).substr(2,5);t.$.contentContainer.dispatchEvent(new KeyboardEvent("keydown",{key:"Enter"})),l=m.execCommand("insertHTML",!1,`<a type=${r.type} href="${i}" id="${e}"><span></span>${r.name}</a>`),s=c.querySelector("#"+e)}if(s&&"a"===s.nodeName.toLowerCase()){if(l&&(s.id=""),URL.revokeObjectURL(s.src),s.src=i,r&&(s.file=r,"base64"===t.imageFormat)){const e=new FileReader;e.readAsDataURL(r),e.onload=()=>s.src=e.result}if(t.uploadUrl&&t._fileUpload&&(s.name=i.replace(t.uploadUrl+"/",""),!t.autoUpload)){const e=e=>{t.$.fireEvent("imageUploadSuccess",e.detail);const a=e.detail.fileURL,o=e.detail.serverResponse;a?s.src=a:o&&(Array.isArray(o)?e.detail.serverResponse[0].file_url?s.src=e.detail.serverResponse[0].file_url:e.detail.serverResponse[0].fileURL&&(s.src=e.detail.serverResponse[0].fileURL):e.detail.serverResponse.file_url?s.src=e.detail.serverResponse.file_url:e.detail.serverResponse.fileURL&&(s.src=e.detail.serverResponse.fileURL))};t._fileUpload.onuploadcompleted=e,t._fileUpload.onuploaderror=e=>{console.error(e.detail)},t._fileUpload.uploadAll()}s.classList.add("smart-editor-file"),s.href=s.src,r.name.indexOf(".pdf")>=0?s.classList.add("smart-icon-pdf"):r.name.indexOf(".png")>=0||r.name.indexOf(".jpg")>=0||r.name.indexOf(".jpeg")>=0||r.name.indexOf(".gif")>=0?s.classList.add("smart-icon-image"):r.name.indexOf(".tsv")>=0||r.name.indexOf(".txt")>=0||r.name.indexOf(".csv")>=0?s.classList.add("smart-icon-text"):r.name.indexOf(".xls")>=0||r.name.indexOf(".xlsx")>=0?s.classList.add("smart-icon-excel"):r.name.indexOf(".ppt")>=0?s.classList.add("smart-icon-powerpoint"):r.name.indexOf(".zip")>=0||r.name.indexOf(".rar")>=0||r.name.indexOf(".7z")>=0?s.classList.add("smart-icon-archive"):r.name.indexOf(".doc")>=0||r.name.indexOf(".docx")>=0?s.classList.add("smart-icon-word"):r.name.indexOf(".mp3")>=0?s.classList.add("smart-icon-music"):r.name.indexOf(".mp4")>=0||r.name.indexOf(".avi")>=0||r.name.indexOf(".mov")>=0||r.name.indexOf(".mp4")>=0||r.name.indexOf(".mpeg")>=0||r.name.indexOf(".webm")>=0?s.classList.add("smart-icon-video"):s.classList.add("smart-icon-file"),a.title&&(s.title=a.title)}}_handleVideoInsert(e){const t=this,a=t._getItemOptionsViaWindow(e),o=t.$.window;if(!o)return;"blockHtml"===t.editMode&&t._insertBlock();let i,n,r,l,s=o._target.itemTarget;if(a.file.length?(r=a.file[0],i=URL.createObjectURL(r),s&&"video"!==s.nodeName.toLowerCase()&&(s.remove(),s=void 0)):(a.src||a.videoUrl)&&(i=(a.src||a.videoUrl)+"",s&&"iframe"!==s.nodeName.toLowerCase()&&(s.remove(),s=void 0)),s&&s.file&&(r=s.file),!i&&!r&&a)return t._focusFirstInputCallback(e.name,"src");if("markdown"===t.editMode)return n=a.title?` "${a.title}"`:"",void t._insertMarkDown(`[![${a.alt}](${i||a.thumbnail||""})](${a.videoUrl} ${n})`);const d=t.$.iframe,c=t.$.editableElement,m=d?d.contentDocument:document;if(!r||s&&"video"===s.nodeName.toLowerCase()){if(!(r||s&&"iframe"===s.nodeName.toLowerCase())){const e=t.id+"newVideo"+Math.random().toString(36).substr(2,5);l=m.execCommand("insertHTML",!1,`<iframe id="${e}" frameborder="0" allowfullscreen></iframe>`),s=c.querySelector("#"+e)}}else{const e=t.id+"newVideo"+Math.random().toString(36).substr(2,5);l=m.execCommand("insertHTML",!1,`<video id="${e}"></video>`),s=c.querySelector("#"+e)}if(s){if(l&&s.removeAttribute("id"),URL.revokeObjectURL(s.src),s.controls=!0,s.frameborder=0,s.allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",t._handleVideoCaption(s,a),void 0!==a.width){const e=a.width+"";s.style.width=e?e+(e.indexOf("%")<0?"px":""):""}if(void 0!==a.height){const e=a.height+"";s.style.height=e?e+(e.indexOf("%")<0?"px":""):""}if(r){if(s.file===r)return;if(s.file=r,"base64"===t.imageFormat){const e=new FileReader;e.readAsDataURL(r),e.onload=()=>s.src=e.result}}else s.src!==i&&(s.src=i)}}_insertMarkDown(e,t,a){const o=this;if("markdown"!==o.editMode)return;const i=o.$.input,n=o._getSelectionRange(),r=n.selectionStart,l=n.selectionEnd;let s,d=i.value;if(void 0!==r&&r!==l&&(s=d.slice(r,l)),a){let t=d.lastIndexOf("\n",r-1)+1;for(;" "===d[t+1];)t++;i.value=d.slice(0,t)+e+d.slice(t)}else i.value=d.slice(0,i.selectionStart)+e+d.slice(i.selectionEnd);void 0!==r&&(void 0===t&&(t=r+e.length),s?a?o._setSelectionRange(i,r+e.length,l+e.length):(d=i.value,i.value=d.slice(0,t)+s+d.slice(t),o._setSelectionRange(i,t,t+s.length)):o._setSelectionRange(i,t,t)),o._refreshMarkdownPreview()}_removeMarkDown(e,t,a){const o=this,i=o.$.input,n=i.value,r=o._getSelectionRange(),l=r.selectionStart,s=r.selectionEnd,d=e.length;i.value=n.slice(0,t)+n.slice(t+d),o._setSelectionRange(i,l-d,s-d),a||o._refreshMarkdownPreview()}_handleLinksInsert(e){const t=this,a=t.$.window,o=t.editMode,i=t._getItemOptionsViaWindow(e);if(!i.address)return t._focusFirstInputCallback(e.name,"address");if("markdown"===o){let e;return e=i.title?`[${i.text}](${i.address}, "${i.title}")`:`[${i.text}](${i.address})`,void t._insertMarkDown(e)}const n=t.$.iframe,[r,l]=n?[n.contentDocument,n.contentWindow]:[document,window],s=l.getSelection();let d,c,m=s.anchorNode?s.anchorNode.parentElement:void 0,u=a&&a._target?a._target.itemTarget:void 0;u&&"img"===u.nodeName.toLowerCase()?(d=a._target.itemTarget,m=d.parentElement,m&&"a"===m.nodeName.toLowerCase()||(m=document.createElement("a"),d.parentElement.insertBefore(m,d),m.appendChild(d))):m=s.anchorNode?s.anchorNode.parentElement:void 0,i.address&&"a"!==m.nodeName.toLowerCase()&&(c=r.execCommand("createLink",!1,i.address),m=s.anchorNode.parentElement),"a"===m.nodeName.toLowerCase()&&(i.address?c||m.setAttribute("href",i.address):m.setAttribute("href",""),i.text?m.textContent=i.text:m.innerHTML||(m.textContent=i.address||""),m.title=i.title||"",m.target=i.target||"",d||s.selectAllChildren(m))}_refreshMarkdownPreview(){const e=this,t=e.$.input;if(e.$.contentContainer.hasAttribute("split-mode")){let a=t.value;e.$.editableElement.innerHTML=window.marked?window.marked(a):a}}_handleImgCaption(e,t){const a=this;if(!t)return;let o,i=e.closest(".smart-editor-image-container");const n=e.nodeName.toLowerCase(),r="video"===n||"iframe"===n&&e.src.indexOf("/embed")>-1;if(t.caption||r){if(i||(i=document.createElement("span"),i.classList.add("smart-editor-image-container"),i.setAttribute("draggable",!1),i.setAttribute("contenteditable",!1),e.hasAttribute("alignment")&&i.setAttribute("alignment",e.getAttribute("alignment")),e.hasAttribute("display")&&i.setAttribute("display",e.getAttribute("display")),e.parentElement.insertBefore(i,e),i.appendChild(e)),i.classList[r?"add":"remove"]("smart-editor-video-container"),o=i.querySelector(".smart-editor-image-caption"),o||(o=document.createElement("span"),o.setAttribute("contenteditable",!0),o.classList.add("smart-editor-image-caption"),i.appendChild(o)),o.textContent=t.caption,t.focusCaption)return delete a._toolbarItemClick,a._setSelectionRange(o),a._setResizeFrame(),void a.$.editableElement.scrollTo(o.offsetLeft,o.offsetTop)}else!t.caption&&i&&(i.hasAttribute("alignment")&&e.setAttribute("alignment",i.getAttribute("alignment")),i.hasAttribute("display")&&e.setAttribute("display",i.getAttribute("display")),i.parentElement.insertBefore(e,i),i.remove());a._resizeFrameObj&&a._resizeFrameObj.target&&a._setResizeFrame(a._resizeFrameObj.target,!0)}_handleVideoCaption(e,t){const a=this,o=e?e.nodeName.toLowerCase():void 0;if(!t||"video"!==o&&"iframe"!==o)return;let i=e.closest(".smart-editor-video-container");if(i||(i=document.createElement("span"),i.classList.add("smart-editor-image-container","smart-editor-video-container"),i.setAttribute("contenteditable",!1),e.parentElement.insertBefore(i,e),i.appendChild(e)),i.setAttribute("resizable",t.resizable),!1===t.draggable?i.setAttribute("draggable",!1):i.removeAttribute("draggable"),t.title&&(e.title=t.title),t.alignment){let e=t.alignment.toLowerCase();e=e.indexOf("left")>-1?"left":e.indexOf("right")>-1?"right":"center",i.setAttribute("alignment",e)}if(t.display){const e="inline"===t.display.toLowerCase()?"inline":"block";i.setAttribute("display",e)}if(t.caption){let e=i.querySelector(".smart-editor-image-caption");if(e||(e=document.createElement("span"),e.setAttribute("contenteditable",!0),e.classList.add("smart-editor-image-caption"),i.appendChild(e)),e.textContent=t.caption,t.focusCaption)return delete a._toolbarItemClick,a._setSelectionRange(e),a._setResizeFrame(),void a.$.editableElement.scrollTo(e.offsetLeft,e.offsetTop)}else if(!t.caption){let e=i.querySelector(".smart-editor-image-caption");e&&e.remove()}a._resizeFrameObj&&a._resizeFrameObj.target&&a._setResizeFrame(a._resizeFrameObj.target,!0)}_handleTableInsert(e){const t=this,a=t.editMode;if(!e)return;if("markdown"===a)return void t._insertTableMarkdown(e);"blockHtml"===t.editMode&&t._insertBlock();const o=t._getSelectionRange();let i,n,r,l;if(e.cells){const t=e.cells;[r,l]=[t[1],t[0]]}else{let t=o.startContainer;[r,l]=[parseInt(e.cols),parseInt(e.rows)],t.nodeType===Node.TEXT_NODE&&(t=t.parentElement),i=t&&t.closest&&t.closest(".smart-editor-editable table")}if(!i){const e=t.$.editableElement,a=t.$.iframe,r=(a?a.contentWindow:window).getSelection();r.removeAllRanges(),r.addRange(o);const l=t.id+"newTable"+Math.random().toString(36).substr(2,5);"blockHtml"===t.editMode&&t._currentBlock?(t._currentBlock.innerHTML+=`<table id="${l}"><tbody></tbody></table>`,n=!0):n=(a?a.contentDocument:document).execCommand("insertHTML",!1,`<table id="${l}"><tbody></tbody></table>`),i=e.querySelector("#"+l)}if(i&&"table"===i.nodeName.toLowerCase()){let a,o=i.querySelector("tbody");for(o?a=Array.from(o.children):(i.innerHTML="<tbody></tbody>",o=i.firstElementChild,a=[]);a.length>l;)a.pop().remove();for(let e=a.length,t=l;e<t;e+=1)a.push(document.createElement("tr"));for(let e=0,t=a.length;e<t;e+=1){const t=a[e],i=Array.from(t.children);for(;i.length>r;)i.pop().remove();for(let e=0,a=r;e<a;e+=1){let a=i[e];a||(a=t.appendChild(document.createElement("td")))}t.parentElement||o.appendChild(t)}void 0===e.tableheader?e.tableheader=!!i.querySelector("th"):void 0===e.altrows?e.altrows=i.hasAttribute("alternation"):void 0===e.dashedborders?e.dashedborders=i.hasAttribute("dashed-borders"):void 0===e.resizable&&(e.resizable="false"!==i.getAttribute("resizable")),t._handleTableHeader(i,e.tableheader),e.altrows?i.setAttribute("alternation",""):i.removeAttribute("alternation"),e.dashedborders?i.setAttribute("dashed-borders",""):i.removeAttribute("dashed-borders");const s=e.width,d=e.height;i.style.width=s?s+(s.indexOf("%")<0?"px":""):"",i.style.height=d?d+(d.indexOf("%")<0?"px":""):"",n&&i.removeAttribute("id"),i.setAttribute("aria-rowcount",l),i.setAttribute("aria-colcount",r),i.setAttribute("resizable",e.resizable)}t._setResizeFrame(i)}_insertTableMarkdown(e){const t=this,a=e.cells,[o,i]=a?[a[1],a[0]]:[parseInt(e.cols),parseInt(e.rows)],n=t.localize("alphabet"),r=t.localize("header"),l=t.localize("column");let s="";if(!1!==e.tableheader){let e="",t=Math.max(3,r.length)+3;for(;t>0;)e+="-",t--;for(let e=1;e<=o;e+=1)s+=`| ${r} ${e} `;s+="|\n";for(let t=0;t<o;t++)s+=`|${e} `;s+="|\n"}for(let e=0;e<i;e++){const t=n[Math.max(0,e-1)%n.length].toUpperCase();for(let e=1;e<=o;e+=1)s+=`| ${l} ${t} ${e} `;s+="|\n"}t._insertMarkDown(s)}_handleTableSelection(e){const t=this,a=t.$.editableElement;if(t._tableCell&&t._tableCell.removeAttribute("selected"),"false"!==a.getAttribute("contenteditable"))return e&&["th","td"].indexOf(e.nodeName.toLowerCase())>-1?(t._tableCell=e,void e.setAttribute("selected","")):void delete t._tableCell}_getItemOptionsViaWindow(e){const t=this._windowEditors[e.name];if(!t)return;const a=t.children;let o={};for(let e=0,t=a.length;e<t;e+=1){const t=a[e].getAttribute("type"),i=a[e].querySelector("[item-editor]");let n;if(t){if(i instanceof Smart.Input)if(void 0===i.$.input.dataValue&&i.dataSource&&i.dataSource.length){const e=i.dataSource[0];n="string"==typeof e?e:e.value||e.label}else n=i.$.input.dataValue||i.value;else i instanceof Smart.CheckBox||i instanceof Smart.RadioButton?n=i.checked:i instanceof Smart.FileUpload?n=i.value:i instanceof Smart.ListBox&&(n=i.selectedIndexes);o[t]=n}}return o}_closeToolbarItemDropDown(e){const t=this,a=()=>{e.opened||e.remove()};e&&(e.opened?(e.hasAnimation&&(e.removeEventListener("transitionend",a),e.addEventListener("transitionend",a,{once:!0})),e.close(),t._setAriaOwns(e)):a())}_openToolbarItemDropDown(e,t){const a=this,o=e.getBoundingClientRect();a._setupDropDown(e,t),t.style.width=o.width+"px",t.style.height=o.height+"px",e.contains(t)||e.appendChild(t),t.open(),a._setAriaOwns(t),a._setAriaControls(e,t)}_setupDropDown(e,t){const a=this,o=a.$.inlineToolbar,i=o&&o.contains(e)?a._inlineToolbarItemsObj:a._toolbarItemsObj,n=i?i[e.getAttribute("item-name")]:void 0;let r;if(n&&(r=n.dataSource),r||(r=[]),t instanceof Smart.ColorInput?(t.dropDownClassList=["smart-editor-color-input"],t.additionalColors=["#FF9EB7","#FFCFC9","#FFD66D","#FFEBB6","#93DF89","#D1F7C4","#9DC7FF","#D0F0FD","#CDAFFF","#ECE1FD","#FA9DE2","#FFDAF6","#CBCBCB","#EDEDED","#FFFFFF",""]):(t.dropDownClassList=["smart-editor-input"],t.dropDownHeight=310),t.classList.add("smart-editor-item-drop-down"),t.readonly=!0,t.dataSource=r,t.dropDownOpenMode="manual",t.dropDownButtonPosition=a.rightToLeft?"left":"right",void 0!==n.value){const e=n.name;t.value=e.indexOf("table")>-1||e.indexOf("paste")>-1?"":n.value+""}else t.value="";t.dropDownOpenPosition="auto"}_toggleToolbar(e){const t=this,a=t.$.toolbar,o=t.$.contentContainer,i=t.toolbarViewMode,n="toggle"===i,r=t.$.toolbarToggleButton,l=t.$.toolbarItemsPrimary,s=t.hasAnimation;a.style.transition=s&&n?"none":"",a.style.height="";const d=a.offsetHeight,c=o.offsetHeight;if(e&&"toggle"===i){if(r.removeAttribute("checked"),r.setAttribute("aria-pressed",!1),!a.hasAttribute("expanded"))return void(a.style.transition="");a.removeAttribute("expanded")}else{if(r.setAttribute("checked",""),r.setAttribute("aria-pressed",!0),a.hasAttribute("expanded"))return a.style.transition="",void(t.$.toolbarItemsSecondary.innerHTML&&t._refreshToolbarItems());"scroll"!==i?a.setAttribute("expanded",""):a.removeAttribute("expanded")}if(t._refreshToolbarItems(),"menu"!==t.toolbarMode)return void(a.hasAttribute("expanded")?(l.querySelector(".smart-editor-toolbar-tab[checked]")||t._selectToolbarTab(l.firstElementChild),t._toggleSecondaryToolbar(!0)):(t._selectToolbarTab(null),t._toggleSecondaryToolbar()));if(!n)return;const m=a.offsetHeight,u=t.$.inlineToolbar;u&&u.visible&&u.reposition(),t._resizeFrameObj&&t._setResizeFrame(t._resizeFrameObj.target),a.style.height=d+"px",o.style.height=c+"px",s?requestAnimationFrame((()=>{a.style.transition="",a.style.height=m+"px",o.style.height=c+d-m+"px",requestAnimationFrame((()=>a.style.height=o.style.height=""))})):(a.style.transition="",a.style.height=m+"px",o.style.height=c+d-m+"px",requestAnimationFrame((()=>a.style.height=o.style.height="")))}_predefPropertyGetter(e="value"){const t=this;Object.defineProperty(t,e,{get:function(){return t.context===t?t.properties[e].value:t._getCurrentValue()},set(a){t._properties[e].value=t._getCurrentValue(),t.updateProperty(t,t._properties[e],a)}})}_getCurrentValue(){const e=this;if("markdown"===e.editMode)return e.$.input.value;let t=e.$.editableElement.innerHTML;return e.enableHtmlEncode&&(t=t.replaceAll("<","&lt;").replaceAll(">","&gt;")),t=t.replaceAll("var(--smart-background-color)","inherit"),t=t.replaceAll("var(--smart-font-weight)","inherit"),t}_getInputValue(e,t){const a=this.$.input;return void 0===e&&(e=a.value),e=(e=(e=!t&&this.enableHtmlEncode?e.replaceAll("<","&lt;").replaceAll(">","&gt;"):e.replaceAll("&lt;","<").replaceAll("&gt;",">")).replaceAll("var(--smart-background-color)","inherit")).replaceAll("var(--smart-font-weight)","inherit")}_handleEditMode(e){const t=this,a=t.$.input,o=t.$.editableElement,i=t.editMode,n=t._toolbarItemsObj.sourcecode,r=!!n&&n.value;t._closePopups(),"html"===e?r?a.value=o.innerHTML:o.innerHTML=a.value:"markdown"===e&&(r?o.innerHTML=window.marked?window.marked(a.value):a.value:a.value=o.textContent,t._closeSearchToolbar()),t.$.contentContainer.hasAttribute("split-mode")||("markdown"===i?r?(a.classList.add("smart-hidden"),o.classList.remove("smart-hidden")):(a.classList.remove("smart-hidden"),o.classList.add("smart-hidden")):r?(a.classList.remove("smart-hidden"),o.classList.add("smart-hidden")):(a.classList.add("smart-hidden"),o.classList.remove("smart-hidden"))),t.readonly||t.disableEditing||t.$.editableElement.setAttribute("contenteditable","markdown"!==i)}_handleInputContent(e,t){const a=this,o=a.$.editableElement,i=a.$.input,n=a.editMode;if(!a.isRendered&&a.autoLoad){const e=window.localStorage.getItem("smartEditor"+a.id);e&&a.set("value",e)}const r=a.value;void 0===t&&r&&(t=r),void 0!==t?"html"===n||"blockHtml"===n?a.$.editableElement.innerHTML=t:a.$.input.value=t:t||"markdown"!==n||(a.$.input.value=a.$.editableElement.textContent),a.$.contentContainer.hasAttribute("split-mode")?"markdown"===n?o.innerHTML=window.marked?window.marked(i.value):i.value:i.value=o.innerHTML.trim():a.classList.contains("preview-mode")&&("markdown"===n?o.innerHTML=window.marked?window.marked(i.value):i.value:i.value=o.innerHTML),o.textContent.length&&o.innerText.length?(o.removeAttribute("show-placeholder"),a._handleContentFiltering()):o.setAttribute("show-placeholder",""),a._clearSearchToolbar()}_sanitize(e,t){return this.sanitized?t.replaceAll(/(<[\/]?script[>]?)|([on].*=['"`]?.*['"`]?)|(SRC=['"`]?javascript:['"`]?)/gim,""):t}_handleNodeContentFiltering(e){const t=this,a=t.contentFiltering;if("html"!==t.editMode&&"blockHtml"!==t.editMode)return;const o=a.tags.map((e=>e.trim())),i=a.attributes.map((e=>e.trim())),n=a.styleAttributes.map((e=>e.trim()));if(!o.length&&!i.length&&!n.length)return;const r=a.tagFilterMode,l=a.attributeFilterMode,s=a.styleAttributeFilterMode;let d=e.innerHTML;if(o.length){const e=new RegExp(/<\s*\/?\s*([a-z0-9]+).*?>/,"gmi");let t,a=[];for(;null!==(t=e.exec(d));){const e=t[1],i=o.indexOf(e)>-1;(i&&"blackList"===r||!i&&"whiteList"===r)&&a.push(t[0])}a.forEach((e=>d=d.replace(e,"")))}e.innerHTML=d;const c=t.$.editableElement.querySelectorAll("*");for(let e=0,t=c.length;e<t;e+=1){const t=c[e];if(i.length){const e=Array.from(t.attributes);for(let a=0,o=e.length;a<o;a+=1){const o=e[a].name,n=i.indexOf(o)>-1;(n&&"blackList"===l||!n&&"whiteList"===l)&&t.removeAttribute(o)}}if(n.length){const e=t.getAttribute("style");if(!e)continue;const a=e.split(";");let o=[];for(let e=0,t=a.length;e<t;e+=1){const t=a[e],i=t.indexOf(":"),r=n.indexOf(t.slice(0,i>0?i:void 0))>-1;(r&&"whiteList"===s||!r&&"blackList"===s)&&o.push(t)}a.length&&(o.length?t.setAttribute("style",o.join(";")):t.removeAttribute("style"))}}t._setCharCount()}_handleContentFiltering(){const e=this,t=e.contentFiltering;if("html"!==e.editMode&&"blockHtml"!==e.editMode)return;const a=t.tags.map((e=>e.trim())),o=t.attributes.map((e=>e.trim())),i=t.styleAttributes.map((e=>e.trim()));if(!a.length&&!o.length&&!i.length)return;const n=t.tagFilterMode,r=t.attributeFilterMode,l=t.styleAttributeFilterMode;let s=e.$.editableElement.innerHTML;if(a.length){const e=new RegExp(/<\s*\/?\s*([a-z0-9]+).*?>/,"gmi");let t,o=[];for(;null!==(t=e.exec(s));){const e=t[1],i=a.indexOf(e)>-1;(i&&"blackList"===n||!i&&"whiteList"===n)&&o.push(t[0])}o.forEach((e=>s=s.replace(e,"")))}e.$.editableElement.innerHTML=s;const d=e.$.editableElement.querySelectorAll("*");for(let e=0,t=d.length;e<t;e+=1){const t=d[e];if(o.length){const e=Array.from(t.attributes);for(let a=0,i=e.length;a<i;a+=1){const i=e[a].name,n=o.indexOf(i)>-1;(n&&"blackList"===r||!n&&"whiteList"===r)&&t.removeAttribute(i)}}if(i.length){const e=t.getAttribute("style");if(!e)continue;const a=e.split(";");let o=[];for(let e=0,t=a.length;e<t;e+=1){const t=a[e],n=t.indexOf(":"),r=i.indexOf(t.slice(0,n>0?n:void 0))>-1;(r&&"whiteList"===l||!r&&"blackList"===l)&&o.push(t)}a.length&&(o.length?t.setAttribute("style",o.join(";")):t.removeAttribute("style"))}}e._setCharCount()}_handleContextMenuItemClick(e,t){if(!t||!t.classList.contains("smart-editor-context-menu-item"))return;const a=this,o=a.$.inlineToolbar,i=t.getAttribute("value");if(!o)return;if(o.callback&&o.callback(i))return a.$.fireEvent("contextMenuItemClick",{originalEvent:e,value:i}),void a._closeContextMenu();const n=o.selector;switch(i){case"category":case"rewrite":case"continue_writing":case"fix_spelling_grammar":case"summarize":case"make_shorter":case"make_longer":case"explain":case"concise":case"professional":case"casual":case"funny":case"translate_english":case"translate_spanish":case"translate_portuguese":case"translate_italian":case"translate_dutch":case"translate_chinese":case"translate_korean":case"translate_japanese":case"translate_russian":{const e=window.getSelection();if(!e||0===e.rangeCount)return"";let t=e.focusNode;t&&("#text"===t.nodeName&&(t=t.parentElement),a._createAIPopup(t,i,((e,t)=>{if(t)a.replaceSelection(e);else{let t=window.getSelection();if(!t.rangeCount)return;let o=t.getRangeAt(0);o.collapse(!1),t.removeAllRanges(),t.addRange(o);const i=a._isControlPressed;a._isControlPressed=!0;const n=a._createEditorBlock(!1,!1);n.removeAttribute("empty"),n.removeAttribute("data-placeholder"),n.innerHTML=e,a._isControlPressed=i}a._aiPopup&&(a._aiPopup.remove(),delete a._aiPopup)})));break}case"imageProperties":a._openWindow({name:"image"},n.closest(".smart-editor-editable img"));break;case"fileProperties":a._openWindow({name:"file"},n.closest(".smart-editor-editable .file"));break;case"linkProperties":a._openWindow({name:"hyperlink"});break;case"tableProperties":a._openWindow({name:"table"},n.closest(".smart-editor-editable table"));break;case"videoProperties":{const e=n.closest(".smart-editor-video-container");if(e){const t=e.querySelectorAll(".smart-editor-video-container > video, .smart-editor-video-container > iframe");a._openWindow({name:"video"},t[0]||t[1])}break}case"insertRowAfter":case"insertRowBefore":case"deleteRow":a._handleTableRows(n.closest(".smart-editor-editable table"),{value:i});break;case"insertColumnLeft":case"insertColumnRight":case"deleteColumn":a._handleTableColumns(n.closest(".smart-editor-editable table"),{value:i});break;case"deleteImage":case"deleteTable":{const e=a._resizeFrameObj?a._resizeFrameObj.target:void 0;e&&a._deleteResizeFrameTarget(e);break}case"deleteVideo":{const e=n.closest(".smart-editor-video-container");if(e){const t=a._resizeFrameObj?a._resizeFrameObj.target:void 0;if(t===e){a._deleteResizeFrameTarget(t);break}e.remove()}break}case"userProperties":a.$.editableElement.getRootNode().execCommand("insertHTML",0,t.getAttribute("label"));break;case"createLink":a._openWindow({name:"hyperlink"},n.closest(".smart-editor-editable img"));break;case"deleteLink":a._handleLinkRemove(n);break;case"copyImage":a._handleImageCopy(n.closest(".smart-editor-editable img"));break;case"cutImage":a._handleImageCut(n.closest(".smart-editor-editable img"));break;case"copyVideo":a._handleImageCopy(n.closest(".smart-editor-video-container"));break;case"cutVideo":a._handleImageCut(n.closest(".smart-editor-video-container"));break;case"deleteTab":{const e=t.getAttribute("id");e&&a.$.tabs.deleteTab(e);break}case"copy":case"cut":case"paste":a._handleClipboardAction(i);break;case"caption":{const e=n.closest(".smart-editor-editable img");let t;if(e&&"img"===e.nodeName.toLowerCase()){const o=e.closest(".smart-editor-image-container");o&&o.querySelector(".smart-editor-image-caption")||(t=a.localize("captionPlaceholder")),a._handleImgCaption(e,{caption:t,focusCaption:!0})}else if(n.classList.contains("smart-editor-video-container")){const e=n.querySelectorAll(".smart-editor-video-container > video, .smart-editor-video-container > iframe");n.querySelector(".smart-editor-image-caption")||(t=a.localize("captionPlaceholder")),a._handleVideoCaption(e[0]||e[1],{caption:t,focusCaption:!0})}break}case"selectAll":a._selectAll();break;case"text":case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":case"user":case"emoji":case"twoColumns":case"callout":case"table":case"date":case"divider":case"page":case"task":case"image":case"video":case"file":case"blockquote":case"unorderedlist":case"ai":case"orderedlist":case"hyperlink":case"checklist":case"togglelist":{let e="",o=a._filterSortableMenuInput;if(o){let i=o.value;const n=t,r=n.getAttribute("name");let l=n.getAttribute("value"),s=n.getAttribute("label");"/"===i&&(i=""),i==="/"+a.localize("typeToFilter")&&(i=""),e={name:r,value:l,label:s},o.setValue(i,e)}break}case"pageLink":{const e=t;let o=e.getAttribute("id"),i=e.getAttribute("label");const n=a.$.editableElement.getRootNode().querySelector("#INSERTION_MARKER");n.removeAttribute("id"),n.id="",a._setSelectionRange(n),a._getSelectionRange().collapse();const r=document.createElement("span");r.classList.add("smart-editor-page-label"),r.innerHTML=i,r.setAttribute("data-id",o),n.parentElement.insertBefore(r,n);const l=document.createRange(),s=window.getSelection();l.setStartAfter(n),l.collapse(!0),s.removeAllRanges(),s.addRange(l);break}}a.$.fireEvent("contextMenuItemClick",{originalEvent:e,value:i}),a._closeContextMenu()}_handleImageCopy(e){const t=this;if(!e||"img"!==e.nodeName.toLowerCase()&&!e.classList.contains("smart-editor-video-container"))return;const a=t._createWhiteSpaceChar(e,e.classList.contains("smart-editor-video-container")?e:void 0);t._setSelectionRange(e),t.$.editableElement.getRootNode().execCommand("copy"),a&&a.remove()}_handleImageCut(e){const t=this;if(!e||"img"!==e.nodeName.toLowerCase()&&!e.classList.contains("smart-editor-video-container"))return;const a=t._createWhiteSpaceChar(e,e.classList.contains("smart-editor-video-container")?e:void 0);t._setSelectionRange(e),t.$.editableElement.getRootNode().execCommand("cut"),t._setResizeFrame(),a&&a.remove()}_createWhiteSpaceChar(e,t){if(!t)return;const a=document.createElement("span");return a.innerHTML="&nbsp;",a.classList.add("smart-editor-video-white-space"),e.appendChild(a),a}_handleInputElement(){const e=this,t=e.iframeSettings,a=e.$.contentContainer,o=e.$.container,i=e.$.editableElement,n=e.$.input,r=e.readonly,l=e.disableEditing;if(i.contentEditable=!r&&!l,n.readonly=r||l,e._handlePlaceholder(),e._closePopups(),t.enabled?e._handleIframeSettings():o.contains(a)||(o.appendChild(a),i.setAttribute("contenteditable",!0),e.$.iframe&&(e.$.iframe.remove(),e._removeIframeEventListeners(),delete e.$.iframe)),"markdown"===e.editMode){const t=e.$.editableElement;e.$.input.classList.remove("smart-hidden"),t.classList.add("smart-hidden")}}_handleToolbarMode(){const e=this,t=e.$.toolbar,a=e.$.toolbarItemsSecondary,o=e.toolbarMode;e.$.toolbarItemsPrimary.innerHTML=a.innerHTML="","menu"===o?(a.classList.remove("smart-drop-down"),a.style.top=a.style.height="",t.contains(a)||t.appendChild(a),e._refreshToolbarItems(e._getToolbarItems())):(e._setToolbarTabs(),e._setToolbarItemGroups(),e._toolbarItemsObj||(e._toolbarItemsObj={}),e._refreshToolbarItems()),e.toolbarOnFocus&&e._refreshToolbarPosition(),e._setToolbarGroupHeight()}_setToolbarTabs(){const e=this,t=e.toolbarRibbonConfig,a=e.$.toolbarToggleButton,o=e.$.toolbarItemsPrimary,i=o.querySelectorAll(".smart-editor-toolbar-tab"),n=document.createDocumentFragment();let r;for(let a=0,o=t.length;a<o;a+=1){const o=t[a];let l=i[a];l||(l=document.createElement("div")),l.classList.add("smart-editor-toolbar-tab"),l.setAttribute("tab-name",o.name),l.textContent=e.localize(o.name),!r&&l.hasAttribute("checked")&&(r=l),r!==l&&l.removeAttribute("checked"),l.classList[o.hidden?"add":"remove"]("smart-hidden"),n.appendChild(l)}a.hasAttribute("checked")&&!r&&n.children[0].setAttribute("checked",""),o.appendChild(n)}_setToolbarItemGroups(){const e=this,t=e.toolbarRibbonConfig,a=Array.from(e.$.toolbarItemsPrimary.querySelectorAll(".smart-editor-toolbar-tab")).find((e=>e.hasAttribute("checked")));if(!t||!a)return;const o=a.getAttribute("tab-name"),i=t.find((e=>e.name===o)),n=i?i.groups:null,r=e.$.toolbarItemsSecondary,l="singleLineRibbon"===e.toolbarMode;if(r.innerHTML="",!Array.isArray(n))return;const s=r.querySelectorAll(".smart-editor-toolbar-tab-group"),d=document.createDocumentFragment();for(let t=0,a=n.length;t<a;t+=1){const a=n[t],o=a.name;let i=s[t];if(i||(i=document.createElement("div")),l)i.innerHTML="",i.appendChild(e._getToolbarItems(e.$.toolbar,a.items));else{i.innerHTML='<div class="smart-editor-tab-group-container"></div><div class="smart-editor-tab-group-label"></div>';const t=i.firstElementChild;i.lastElementChild.innerHTML=e.localize(o),t.appendChild(e._getToolbarItems(e.$.toolbar,a.items))}i.classList.add("smart-editor-toolbar-tab-group"),i.setAttribute("group-name",o),d.appendChild(i)}r.appendChild(d),r.classList.remove("smart-visibility-hidden"),e._refreshToolbarTabs()}_refreshToolbarTabs(){const e=this,t=e._resizeFrameObj,a=Array.from(e.$.toolbarItemsPrimary.children).find((e=>"layouttab"===(e.getAttribute("tab-name")||"").toLowerCase()));if(!a)return;if(!t||!t.target||"singleLineRibbon"!==e.toolbarMode)return a.classList.add("smart-hidden"),void(a.hasAttribute("checked")&&e._selectToolbarTab(e.$.toolbarItemsPrimary.firstElementChild));const o=e.$.toolbarItemsSecondary.children,i=t.target,n=i.nodeName.toLowerCase();let r,l,s;for(let e=0,t=o.length;e<t;e+=1){const t=o[e],a=t.getAttribute("group-name");"tableGroup"===a?(l=t,l.classList.add("smart-hidden")):"imageGroup"===a?(r=t,r.classList.add("smart-hidden")):"videoGroup"===a&&(s=t,s.classList.add("smart-hidden"))}"table"===n?(a.classList.remove("smart-hidden"),l&&l.classList.remove("smart-hidden")):"img"===n?(a.classList.remove("smart-hidden"),r&&r.classList.remove("smart-hidden")):i.classList.contains("smart-editor-video-container")?(a.classList.remove("smart-hidden"),s&&s.classList.remove("smart-hidden")):a.classList.add("smart-hidden")}_handlePlaceholder(){const e=this.$.editableElement,t=this.placeholder;t?e.setAttribute("placeholder",t):e.removeAttribute("placeholder")}_handleIframeSettings(){const e=this;e.iframeSettings.enabled&&(()=>{let t=e.$.iframe;t||(t=e.$.iframe=document.createElement("iframe")),t.onload=()=>{e._handleIframeBody(),e._handleIframeAttributes(),e._handleIframeResources()},t.parentElement||e.$.container.appendChild(t),!t.contentWindow.marked&&window.marked&&(t.contentWindow.marked=window.marked)})()}_removeIframeEventListeners(){const e=this,t=e.$.iframe.contentDocument,a=e.$iframe;a&&(a.unlisten("down"),a.unlisten("move"),a.unlisten("up")),t.removeEventListener("dragstart",e._iframeDragStartHandler),t.removeEventListener("dragend",e._iframeDragEndHandler),t.removeEventListener("selectionchange",e._iframeSelectionChangeHandler)}_handleIframeBody(){const e=this,t=e.$.iframe.contentDocument,a=t.body;if(!a)return;let o=e.$iframe;a.classList.add("smart-editor","smart-element","smart-editor-iframe-body"),a.appendChild(e.$.contentContainer),e._updateIframeBody(),o||(o=e.$iframe=Smart.Utilities.Extend(a)),e._iframeDownHandler=t=>e._documentDownHandler.call(e,t),e._iframeMoveHandler=t=>e._documentMoveHandler.call(e,t),e._iframeUpHandler=t=>e._documentUpHandler.call(e,t),e._iframeDragStartHandler=t=>e._dragStartHandler.call(e,t),e._iframeDragEndHandler=t=>e._dragEndHandler.call(e,t),e._iframeSelectionChangeHandler=t=>e._selectionChangeHandler.call(e,t),e._removeIframeEventListeners(),o.listen("down",e._iframeDownHandler),o.listen("move",e._iframeMoveHandler),o.listen("up",e._iframeUpHandler),t.addEventListener("dragstart",e._iframeDragStartHandler),t.addEventListener("dragend",e._iframeDragEndHandler),t.addEventListener("selectionchange",e._iframeSelectionChangeHandler)}_updateIframeBody(){const e=this,t=e.$.iframe;if(!t)return;const a=t.contentDocument.body;a&&(e.rightToLeft?a.setAttribute("right-to-left",""):a.removeAttribute("right-to-left"),e.theme?a.setAttribute("theme",e.theme):a.removeAttribute("theme"),a.setAttribute("animation",e.animation))}_handleIframeAttributes(){const e=this,t=e.$.iframe,a=e.iframeSettings.attributes;if(!t)return;if(t.hasAttribute("title")||t.setAttribute("title",e.localize("iframeTitle")),!a||"object"!=typeof a)return;const o=e.$.editableElement;for(let e in a){const i=a[e];"readonly"===e?o.setAttribute("contenteditable",!i):t[e]=i}}_handleIframeResources(){const e=this,t=e.iframeSettings.resources,a=e.$.iframe;if(!a||"object"!=typeof t)return;const o=document.styleSheets,i=a.contentDocument,n=i.head,r=i.body;if(e.iframeSettings.copyStyles)for(let e in o){const t=o[e],i=t.ownerNode;"text/css"===t.type&&i&&["link","style"].indexOf(i.nodeName.toLocaleLowerCase())>-1&&a.contentDocument.head.appendChild(t.ownerNode.cloneNode())}for(let e in t){const a=e,o=t[e];let i;if((a+"").indexOf("style")>-1||"link"===a?(i=document.createElement("link"),i.rel="stylesheet",i.type="text/css","string"==typeof o&&(i.href=o)):"script"===a&&(i=document.createElement("script"),i.type="text/javascript","string"==typeof o&&(i.src=o)),"object"==typeof o&&"[object Object]"===o.toString())for(let e in o)i[e]=o[e];"module"===i.type?r.appendChild(i):n.appendChild(i)}}_handleMaxCharCount(){const e=this,t=e.$.input;null!==e.maxCharCount?t.maxLength=e.maxCharCount:t.removeAttribute("maxlength")}_getToolbarItems(e,t){const a=this;e||(e=a.$.toolbar),t||(t=a.toolbarItems);const o=e===a.$.toolbar?"toolbar":"inlineToolbar",i=e.querySelectorAll(".smart-editor-toolbar-item"),n=document.createDocumentFragment();for(let e=0,r=t.length;e<r;e+=1){const r=a._getToolbarItemDetails(o,t[e]),l=r.name,s=r.type;let d=i[e];if(d?"custom"===d.getAttribute("item-type")&&(d.innerHTML=""):(d=document.createElement("div"),d.classList.add("smart-editor-toolbar-item")),"color-input"===s)d.innerHTML||(d.innerHTML=`<div class="smart-editor-item-action-button" item-name="${l}"></div>\n <div class="smart-editor-item-drop-down-button"></div>`);else if("custom"===s){const e=r.template;d.innerHTML="",e&&e.closest&&!d.contains(e)?d.appendChild(e):"string"!=typeof e||d.innerHTML?"function"==typeof e&&e(d,r):d.innerHTML=e||""}else"toggle"===s&&(r.value?(d.setAttribute("checked",""),d.setAttribute("aria-pressed",!0)):(d.removeAttribute("checked"),d.setAttribute("aria-pressed",!1)),d.innerHTML&&(d.innerHTML=""));r.disabled||"paste"===l&&a._isFireFox?(d.setAttribute("disabled",""),d.setAttribute("aria-disabled",!0)):(d.removeAttribute("disabled"),d.removeAttribute("aria-disabled")),d.setAttribute("role","delimiter"===s?"separator":"button"),"color-input"===s||"drop-down"===s?d.setAttribute("aria-haspopup",!0):d.removeAttribute("aria-haspopup"),a._setItemValue(d,r),r.title?d.setAttribute("title",r.title):d.removeAttribute("title"),d.setAttribute("item-name",l),d.setAttribute("item-type",s),d.style.width=r.width||"",n.appendChild(d)}return n}_setItemValue(e,t){const a=this;let o=t.value;e&&t&&("button"===t.type?o?(e.setAttribute("checked",""),e.setAttribute("aria-pressed",!0)):(e.removeAttribute("checked"),e.setAttribute("aria-pressed",!1)):(o||"color-input"!==t.type?["fontname","formats"].indexOf(t.name)>-1&&(o=a.localize(t.value)||t.label||t.value):o="transparent",o?(e.setAttribute("item-value",o),e.style.setProperty("--item-value",o)):(e.removeAttribute("item-value"),e.style.removeProperty("--item-value"))))}_refreshToolbarItems(e){const t=this,a=t.$.toolbar,o=t.$.toolbarToggleButton,i=t.$.toolbarItemsPrimary,n=t.$.toolbarItemsSecondary;if("menu"===t.toolbarMode){if(i.scrollTop=i.scrollLeft=0,e)i.appendChild(e);else{const e=Array.from(n.children),t=document.createDocumentFragment(),a=e.length;for(let o=0;o<a;o+=1)t.appendChild(e[o]);a>0&&i.appendChild(t)}if("toggle"===t.toolbarViewMode){const e=i.offsetHeight;if(a.hasAttribute("expanded")){let t=[];e:for(;i.scrollHeight>e;){const e=i.lastElementChild;if(!e)break e;t.push(e),e.remove()}t.reverse();for(let e=0,a=t.length;e<a;e+=1)n.appendChild(t[e])}else i.scrollHeight===e&&o.classList.add("smart-visibility-hidden")}}else o.classList.remove("smart-visibility-hidden")}_resizeHandler(e){const t=this,a=t.$.inlineToolbar;if(e.target===t){if("toggle"===t.toolbarViewMode){const e=t.$.toolbarItemsPrimary,a=t.$.toolbarItemsSecondary;t.$.toolbar.hasAttribute("expanded")&&t._refreshToolbarItems();const o=t.$.toolbarToggleButton;e.scrollHeight!==e.offsetHeight||a.children.length?o.classList.remove("smart-visibility-hidden"):o.classList.add("smart-visibility-hidden")}if("menu"===t.toolbarMode||t.$.toolbarItemsSecondary.classList.contains("smart-visibility-hidden")||t._setToolbarGroupHeight(),a&&a.visible){const e=a.selector;e.classList.contains("smart-editor-toolbar-item")&&e.offsetTop>=t.$.toolbar.offsetHeight?a.close():a.reposition()}t._positionWindow(),t._refreshToolbarPosition(),t._resizeFrameObj&&t._setResizeFrame(t._resizeFrameObj.target)}}recycle(){this._positionWindow(),this._refreshToolbarPosition()}_setToolbarItemAttr(e,t,a){const o=this,i=o.$.toolbar,n=o.$.inlineToolbar,r=[o._toolbarItemsObj,o._inlineToolbarItemsObj];for(let o=0,l=r.length;o<l;o+=1){const l=r[o],s=l?l[e]:void 0;if(s){const o=l==l?i:n;if(s[t]=a,!o||!o.parentElement)continue;const r=o.querySelector(`.smart-editor-toolbar-item[item-name="${e}"]`);if(!r)continue;null==a||!1===a?(r.removeAttribute(t),"disabled"===t&&r.removeAttribute("aria-disabled")):(r.setAttribute(t,a),"disabled"===t&&r.setAttribute("aria-disabled",!0))}}}_setToolbarVisibility(){const e=this,t=e.$.toolbar,a=e.$.toolbarToggleButton;"toggle"!==e.toolbarViewMode||a.hasAttribute("checked")?t.setAttribute("expanded",""):t.removeAttribute("expanded")}_getToolbarItemDetails(e,t){const a=this;let o,i=a[`_${e}ItemsObj`];if(o="string"==typeof t?t:"object"==typeof t&&t.name?t.name+"":"",o=o.trim().toLowerCase(),i){if(void 0!==i[o])return i[o]}else i=a[`_${e}ItemsObj`]={};const n=i[o]={};return n.title=t.title||a.localize(o),n.name=o,n.toolbarName=e,n.advanced=!!t.advanced,n.inlineToolbarItems=t.inlineToolbarItems,a._setItemType(t,n,o),a._setItemData(t,n,o),a._setItemTemplate(t,n,o),a._setItemSpecifics(t,n,o),n}_setItemType(e,t,a){let o;if(t){switch(a){case"sourcecode":case"splitmode":case"fullscreen":o="toggle";break;case"alignment":case"fontname":case"fontsize":case"formats":case"tablerows":case"tablecolumns":case"tablevalign":case"tablestyle":o="drop-down";break;case"backgroundcolor":case"fontcolor":o="color-input";break;case"bold":case"italic":case"underline":case"strikethrough":case"delete":case"redo":case"undo":case"indent":case"outdent":case"openlink":case"editlink":case"createlink":case"removelink":case"hyperlink":case"cut":case"copy":case"image":case"video":case"file":case"lowercase":case"uppercase":case"print":case"caption":case"clearformat":case"table":case"tableheader":case"orderedlist":case"unorderedlist":case"checklist":case"subscript":case"superscript":case"findandreplace":case"ai":o="button";break;case"paste":o=t.advanced?"drop-down":"button";break;default:o="string"==typeof e?"delimiter":"custom"}t.type=o}}_setItemData(e,t,a){const o=this;let i,n;if(!t||!e)return;const r=t.type;let l=e.width;if("drop-down"===r||"color-input"===r){if("object"==typeof e&&(i=e.dataSource,void 0!==e.value&&(n=e.value+"")),i&&Array.isArray(i)||(i=o._getDefaultDataSource(a,t)),void 0===n&&("fontsize"===t.name&&(n=parseInt(window.getComputedStyle(o.$.editableElement).fontSize)),isNaN(n)&&i.length)){let e=i[0];"fontcolor"===t.name&&(e=i[i.length-1]),"backgroundcolor"===t.name&&(e="transparent"),n=e["alignment"===a?"value":"label"]||e}a.indexOf("table")>-1&&(n="")}void 0!==l&&("number"==typeof l?l+="px":(l+="",l.includes("%")||(l=parseFloat(e.width),l=isNaN(l)?"":l+"px"))),t.dataSource=i,"color-input"===r&&(t.additionalColors=["#FF9EB7","#FFCFC9","#FFD66D","#FFEBB6","#93DF89","#D1F7C4","#9DC7FF","#D0F0FD","#CDAFFF","#ECE1FD","#FA9DE2","#FFDAF6","#CBCBCB","#EDEDED","#FFFFFF",""]),t.value=n,t.disabled=!!e.disabled,t.width=l}_setItemSpecifics(e,t,a){if(!t||"object"!=typeof e)return;let o=e.editor,i=t.editor;if(i||(i=t.editor={}),!o)return;let n=[],r=[];switch(a){case"createlink":case"removelink":case"hyperlink":n=["address","text","target"];break;case"image":n=["allowedTypes","uploadUrl","removeUrl","path","display"],r=["draggable","resizable"];break;case"file":n=["allowedTypes","uploadUrl","removeUrl","path","display"];break;case"table":n=["cols","rows","tableheader"],r=["altrows","dashedborders","resizable"]}for(let e in o){let t=o[e];void 0!==t&&(n.indexOf(e)>-1?"display"===e?t="block"===t?"block":"inline":t+="":r.indexOf(e)>-1?t=!!t:"width"!==e&&"height"!==e||"string"==typeof t||(t+="px"),i[e]=t)}}_getDefaultDataSource(e,t){const a=this;let o=[];switch(e){case"alignment":o=[{label:a.localize("alignLeft"),value:"left",icon:"editor-icon"},{label:a.localize("alignCenter"),value:"center",icon:"editor-icon"},{label:a.localize("alignRight"),value:"right",icon:"editor-icon"}],t&&"toolbar"===t.toolbarName&&o.push({label:a.localize("alignJustify"),value:"justify",icon:"editor-icon"});break;case"display":o=[{label:a.localize("displayInline"),value:"inline"},{label:a.localize("displayBlock"),value:"block"}];break;case"fontname":["arial","Courier New","georgia","impact","Roboto","segoeUi","tahoma","timesNewRoman","verdana"].forEach((e=>{o.push({label:a.localize(e),value:e})}));break;case"fontsize":["8","10","12","14","18","24","36"].forEach((e=>{o.push({label:e,value:e})}));break;case"formats":["p","pre","blockquote","h1","h2","h3","h4","h5","h6"].forEach((e=>{o.push({label:a.localize(e),value:e})}));break;case"backgroundcolor":case"fontcolor":o=["#D50000","#E67C73","#F4511E","#F6BF26","#0B8043","#33B679","#3F51B5","#039BE5","#7986CB","#8C47FF","#8E24AA","#FF36C2","#616161","#454545","#949494","#000000"];break;case"paste":o=[{label:a.localize("plainText"),value:"plainText"},{label:a.localize("keepFormat"),value:"keepFormat"},{label:a.localize("cleanFormat"),value:"cleanFormat"}];break;case"target":o=[{label:a.localize("linkBlankDescr"),value:"_blank"},{label:a.localize("linkSelfDescr"),value:"_self"},{label:a.localize("linkParentDescr"),value:"_parent"},{label:a.localize("linkTopDescr"),value:"_top"},{label:a.localize("linkCustomDescr"),value:""}];break;case"tablerows":o=[{label:a.localize("insertRowBefore"),value:"insertRowBefore",icon:"editor-icon"},{label:a.localize("insertRowAfter"),value:"insertRowAfter",icon:"editor-icon"},{label:a.localize("deleteRow"),value:"deleteRow",icon:"editor-icon"}];break;case"tablecolumns":o=[{label:a.localize("insertColumnLeft"),value:"insertColumnLeft",icon:"editor-icon"},{label:a.localize("insertColumnRight"),value:"insertColumnRight",icon:"editor-icon"},{label:a.localize("deleteColumn"),value:"deleteColumn",icon:"editor-icon"}];break;case"tablevalign":o=[{label:a.localize("alignTop"),value:"top"},{label:a.localize("alignMiddle"),value:"middle"},{label:a.localize("alignBottom"),value:"bottom"}];break;case"tablestyle":o=[{label:a.localize("dashedborders"),value:"dashedborders"},{label:a.localize("altrows"),value:"altrows"}]}return o}_setItemTemplate(e,t){let a=e.template;t&&(a?(a&&a.closest?a="content"in a?document.importNode(a.content,!0):a:"function"==typeof a?a=a.bind(this):"string"==typeof a&&(a=document.getElementById(a)||a),t.template=a):delete t.template)}_setAriaSettings(){const e=this,t=e.$.input,a=e.$.editableElement;e.setAttribute("role","application"),e.setAttribute("aria-roledescription",e.localize("roleDescription")),e.$.toolbarToggleButton.setAttribute("aria-label",e.localize("toolbarButtonAriaLabel")),e.$.toolbarItemsPrimary.setAttribute("aria-label",e.localize("primaryToolbarAriaLabel")),e.$.toolbarItemsSecondary.setAttribute("aria-label",e.localize("secondaryToolbarAriaLabel")),t.setAttribute("aria-label",e.localize("inputAreaLabel")),t.id=e.id+"TextArea",a.id=e.id+"EditableElement",a.setAttribute("aria-label",e.localize("inputAriaLabel"))}_setAriaControls(e,t){const a=this;e&&e.nodeName&&(t.id||(t.id=a.id+"Popup"+Math.floor(65536*(1+Math.random())).toString(16).substring(1)),e.setAttribute("aria-controls",t.id))}_setAriaOwns(e){const t=this;if(!e)return;const a=e.id;let o=(t.getAttribute("aria-owns")||"").split(" ").filter((e=>e.length));const i=o.indexOf(a);if(i>-1){if(e.parentElement&&(e.opened||e.visible))return;o.splice(i,1)}else o.push(a);o.length?t.setAttribute("aria-owns",o.join(" ")):t.removeAttribute("aria-owns")}_setFocusable(){const e=this,t=e.$.editableElement;if(e.disabled||e.unfocusable)return void(t&&t.removeAttribute("tabindex"));const a=e.tabIndex>0?e.tabIndex:0;t&&(t.tabIndex=a)}_selectAll(){const e=this,t=e.$.input,a=e.$.editableElement;t.classList.contains("smart-hidden")||t.select(),a.classList.contains("smart-hidden")||e._setSelectionRange(a)}_selectStartHandler(e){const t=this,a=t._resizeFrameObj,o=t._inlineToolbarClickObj;(t._blockDragDetails&&t._blockDragDetails.line||a&&a.resizeDetails||o&&o.resizeDetails)&&e.preventDefault()}_selectionChangeHandler(e){const t=this;if(t.disabled||!e.target.getSelection)return;const a=e.target.getSelection().focusNode;if(t.$.contentContainer.contains(a)){if(t._ignoreSelectionChange||a.classList&&a.classList.contains("smart-search-input"))return;t._selectionChangeFired=!0,t._setSelectionRange(),t._updateToolbarItems(),t._isSelecting=!0,clearTimeout(t._selectingTimer),t._selectingTimer=setTimeout((()=>{delete t._isSelecting}),500),delete t._selectionChangeFired}}_selectToolbarTab(e){const t=this,a=t.$.toolbar,o=t.$.toolbarItemsPrimary,i=e&&!e.hasAttribute("checked"),n=o.querySelectorAll(".smart-editor-toolbar-tab");for(let t=0,a=n.length;t<a;t+=1){const a=n[t];e===a&&i?a.setAttribute("checked",""):a.removeAttribute("checked")}let r=t._tabSelectionBar;r||(t._tabSelectionBar=r=document.createElement("div"),r.classList.add("smart-editor-toolbar-tab-selection-bar")),r.classList.add("smart-visibility-hidden"),e&&e.hasAttribute("checked")?(a.setAttribute("toolbar-tab-selected",""),r.style.left=e.offsetLeft+"px",r.style.width=e.offsetWidth+"px",o.contains(r)||o.appendChild(r),t._setToolbarItemGroups(),requestAnimationFrame((()=>r.classList.remove("smart-visibility-hidden")))):a.removeAttribute("toolbar-tab-selected")}}),Smart("smart-table-picker",class extends Smart.BaseElement{static get properties(){return{columns:{value:10,type:"number"},messages:{extend:!0,value:{en:{buttonLabel:"Insert Table"}}},rows:{value:3,type:"number"},value:{value:[],type:"array"}}}static get listeners(){return{"tableGrid.mouseover":"_cellOver","tableGrid.mouseleave":"_cellLeave","tableGrid.click":"_cellOver"}}template(){return'<div id="container" role="presentation">\n <div id="tableGrid" class="smart-table-picker-grid" role="presentation"></div>\n <div class="smart-table-picker-separator" role="separator"></div>\n <smart-button id="tableButton" class="smart-table-picker-button" right-to-left="[[rightToLeft]]"></smart-button>\n </div>'}propertyChangedHandler(e,t,a){const o=this;switch(e){case"value":o._selectCell(a,t,!0);break;case"rows":case"columns":o._createTableGrid();break;case"messages":o._setTableButton();break;default:super.propertyChangedHandler(e,t,a)}}render(){const e=this;e._isMobile=Smart.Utilities.Core.isMobile,e._createTableGrid(),e._setTableButton(),e._setAria(),super.render()}_setAria(){this.setAttribute("role","grid")}_createTableGrid(){const e=this,t=e.$.tableGrid,a=e.columns,o=e.rows,i=t.children,n=document.createDocumentFragment();let r=i.length;for(;r>o;){const e=i[0];if(!e)break;e.remove(),r--}for(let e=r,t=o;e<t;e+=1){const e=document.createElement("div");e.setAttribute("role","row"),n.appendChild(e)}n.children.length&&t.appendChild(n);for(let e=0,t=o;e<t;e+=1){const t=i[e],o=t.children;let n=o.length;for(;n>a&&o[0];)o[0].remove(),n--;for(let e=n,o=a;e<o;e+=1){const e=document.createElement("span");e.setAttribute("role","gridcell"),e.classList.add("smart-table-picker-cell"),t.appendChild(e)}}e._selectCell(e.value)}_cellOver(e){const t=this,a=e.target;let o=[];if(!t.$.tableGrid.contains(a))return void t._selectCell(t.value);const i=a.closest(".smart-table-picker-cell");if(i){const a=i.parentElement,n=Array.from(a.children);o[0]=Math.max(0,Array.from(t.$.tableGrid.children).indexOf(a)+1),o[1]=Math.max(0,n.indexOf(i)+1),t._selectCell(o,t.value,"click"===e.type)}}_cellLeave(){this._selectCell(this.value)}_selectCell(e,t,a){const o=this,i=o.$.tableGrid,n=Array.from(i.children),r=n.length;let l=0,s=0;e&&(l=e[0]||0,s=e[1]||0);for(let e=0,t=r;e<t;e+=1){const t=n[e].children;if(l<e+1)for(let e=0,a=t.length;e<a;e+=1)t[e].removeAttribute("selected");else for(let e=0,a=t.length;e<a;e+=1)s>=e+1?t[e].setAttribute("selected",""):t[e].removeAttribute("selected")}i.setAttribute("value",l+"x"+s),a&&(void 0===t&&(t=o.value),o.set("value",[l,s]),t[0]===l&&t[1]===s||o.$.fireEvent("change",{value:e,oldValue:t}))}_setTableButton(){this.$.tableButton.innerHTML=this.localize("buttonLabel")}});
827
+ Smart("smart-editor",class extends Smart.ContentElement{static get properties(){return{ai:{type:"any",reflectToAttribute:!1,value:{model:{value:"gpt-3.5-turbo",type:"string"},limit:{value:10,type:"number"},maxTokens:{value:250,type:"number"},temperature:{value:.7,type:"number"},url:{value:"",type:"string"},key:{value:"",type:"string"}}},autoLoad:{value:!1,type:"boolean"},autoSave:{value:!1,type:"boolean"},autoFormatting:{value:!0,type:"boolean"},enablePages:{value:!1,type:"boolean"},pageIndex:{value:0,type:"number"},pages:{value:[],type:"array"},autoSaveInterval:{value:1e3,type:"number"},autoExpand:{value:!1,type:"boolean"},charCountFormatFunction:{value:null,type:"function?"},contentFiltering:{value:{attributes:{value:[],type:"array"},attributeFilterMode:{allowedValues:["blackList","whiteList"],value:"blackList",type:"string"},tags:{value:[],type:"array"},tagFilterMode:{allowedValues:["blackList","whiteList"],value:"blackList",type:"string"},styleAttributes:{value:[],type:"array"},styleAttributeFilterMode:{allowedValues:["blackList","whiteList"],value:"blackList",type:"string"}},type:"object"},content_css:{value:"",type:"string"},contextMenu:{allowedValues:["default","browser","none"],value:"default",type:"string"},contextMenuDataSource:{value:null,type:"any",reflectToAttribute:!1},dataExport:{value:{style:{value:null,type:"object"},fileName:{value:"smartEditor",type:"string?"},pageOrientation:{value:"portrait",type:"string"}},type:"object"},disableEditing:{value:!1,type:"boolean"},disableSearchBar:{value:!1,type:"boolean"},editMode:{allowedValues:["html","blockHtml","markdown"],value:"html",defaultReflectToAttribute:!0,type:"string"},sortable:{value:!1,type:"boolean"},addBlock:{defaultReflectToAttribute:!0,value:!1,type:"boolean"},enableHtmlEncode:{value:!1,type:"boolean"},enableTabKey:{value:!1,type:"boolean"},findAndReplaceTimeout:{value:50,type:"number"},hideToolbar:{value:!1,type:"boolean"},hideInlineToolbar:{value:!1,type:"boolean"},imageFormat:{allowedValues:["blob","base64"],value:"base64",type:"string"},imageName:{value:"userfile[]",type:"string"},innerHTML:{type:"string",validator:"_sanitize",reflectToAttribute:!1},inlineToolbarOffset:{value:[0,-5],type:"array"},iframeSettings:{value:{attributes:{value:null,type:"object?"},enabled:{value:!1,type:"boolean"},copyStyles:{value:!0,type:"boolean"},resources:{value:null,type:"object?"}},type:"object"},maxCharCount:{value:null,type:"number?"},messages:{extend:!0,value:{en:{invalidValue:"{{elementType}}: Invalid {{property}} value. {{property}} should be of type {{typeOne}} or {{typeTwo}}.",incorrectArgument:"{{elementType}}: Incorrect argument {{argumentName}} in method {{methodName}}.",permissionsRequired:"{{elementType}}: Permissions are required for the following action {{actionName}}.",timeout:"{{elementType}}: The import request has timed out.",importError:"{{elementType}}: The import request errored with the following status: {{status}}.",exportError:"{{elementType}}: The Export request errored with the following status: {{status}}.",ok:"Ok",cancel:"Cancel",alignLeft:"Align Left",alignCenter:"Align Center",alignRight:"Align Right",alignJustify:"Align Justify",segoeUi:"Segoe UI",arial:"Arial",georgia:"Georgia",impact:"Impact",tahoma:"Tahoma",timesNewRoman:"Times New Roman",verdana:"Verdana",p:"Paragraph",pre:"Code",code:"Code",blockquote:"Quotation",h1:"Heading 1",h2:"Heading 2",h3:"Heading 3",h4:"Heading 4",h5:"Heading 5",h6:"Heading 6",bold:"Bold",italic:"Italic",underline:"Underline",strikethrough:"Strikethrough",orderedlist:"Ordered List",unorderedlist:"Unordered List",checklist:"Check List",subscript:"Subscript",superscript:"Superscript",alignment:"Alignments",fontname:"Font Name",fontsize:"Font Size",formats:"Formats",backgroundcolor:"Background Color",fontcolor:"Font Color",redo:"Redo",undo:"Undo",indent:"Indent",outdent:"Outdent",createlink:"Hyperlink",insertlink:"Insert a hyperlink",hyperlink:"Hyperlink",editlink:"Hyperlink",removelink:"Remove link",openlink:"Open link",image:"Image",video:"Video",table:"Table",lowercase:"Lower Case",uppercase:"Upper Case",print:" Print",cut:" Cut",copy:" Copy",paste:" Paste",clearformat:"Clear Format",fullscreen:"Full Screen",restore:"Restore Screen",sourcecode:"Source Code",preview:"Preview",splitmode:"Split Editor",address:"Web Address",text:"Display Text",addressPlaceholder:"https://example.com",textPlaceholder:"Enter Text",targetPlaceholder:"Select Target",titlePlaceholder:"Enter a Title",urlPlaceholder:"http://example.com/image.png",fileUrlPlaceholder:"http://example.com/file.pdf",srcPlaceholder:"https://www.youtube.com/embed/video_link",thumbnail:"Or provide a URL as a video thumbnail",thumbnailPlaceholder:"https://www.link-to-thumbnail.jpg",videoUrl:"Video URL",videoUrlPlaceholder:"https://www.youtube.com/video_link",captionPlaceholder:"Caption",altPlaceholder:"Alternative Text",widthPlaceholder:"auto",heightPlaceholder:"auto",target:"Open Link in",linkBlankDescr:"New Window",linkSelfDescr:"Same Window",linkParentDescr:"Parent Frame",linkTopDescr:"Full Body of the Window",linkCustomDescr:"Custom Frame Name",title:"Title",fileUrl:"Or provide the URL to a file",url:"Or provide the URL to an image",src:"Or provide the URL to an embed video",width:"Width",height:"Height",alt:"Alternative Text",caption:"Caption",display:"Display",displayPlaceholder:"Display",displayBlock:"Block",displayInline:"Inline",draggable:"Enable Dragging",resizable:"Enable Resizing",browse:"Browse",connectionError:"{{elementType}}: File Upload requires connection to the server.",wrongItemIndex:"{{elementType}}: There is no file with such an index in the list of uploaded files.",tooLongFileName:"{{elementType}}: File name is too long.",totalFiles:"Total files: ",cancelFile:"Cancel File",dashedborders:"Dashed Borders",altrows:"Alternate Rows",insertRowBefore:"Insert Row Before",insertRowAfter:"Insert Row After",deleteRow:"Delete Row",insertColumnLeft:"Insert Column Left",insertColumnRight:"Insert Column Right",deleteColumn:"Delete Column",alignTop:"Align Top",alignMiddle:"Align Middle",alignBottom:"Align Bottom",delete:"Delete",tablerows:"Table Rows",tablecolumns:"Table Columns",tablevalign:"Table Cell Vertical Align",tablestyle:"Table Style",tableheader:"Table Header",buttonLabel:"Custom Table",pasteLabel:"Choose the paste format action:",cols:"Columns",rows:"Rows",alphabet:"abcdefghijklmnopqrstuvwxyz",header:"Header",column:"Column",plainText:"Plain Text",keepFormat:"Keep Format",cleanFormat:"Clean Format",roleDescription:"Text Editor",iframeTitle:"Editor Content is Encloused in it's own DOM inside an iFrame",toolbarButtonAriaLabel:"Toolbar Toggle Button",primaryToolbarAriaLabel:"Primary Toolbar",secondaryToolbarAriaLabel:"Secondary Toolbar",inputAriaLabel:"Enter Text",homeTab:"Home",viewTab:"View",insertTab:"Insert",layoutTab:"Layout",undoGroup:"Undo",clipboardGroup:"Clipboard",fontGroup:"Font",paragraphGroup:"Paragraph",editingGroup:"Editing",tableGroup:"Tables",imageGroup:"Images",videoGroup:"Videos",linkGroup:"Links",viewsGroup:"Views",deleteGroup:"Delete",findandreplace:"Find and Replace",requiredMessage:"The content of the Editor cannot be empty",tableProperties:"Table Properties",imageProperties:"Image Properties",videoProperties:"Video Properties",linkProperties:"Link Properties",selectAll:"Select All",deleteTable:"Delete Table",deleteImage:"Delete Image",deleteVideo:"Delete Video",createLink:"Create Link",deleteLink:"Delete Link",copyImage:"Copy",cutImage:"Cut",copyVideo:"Copy",cutVideo:"Cut",find:"Find",findPlaceholder:"",replace:"Replace",replaceWith:"Replace With",replaceAll:"Replace All",replacePlaceholder:"",results:"Results",resultsPlaceholder:"No match",matchCase:"Match Case",searchPlaceholder:"Search...",newLinePlaceholder:"Write, press ' / ' for commands…",addButton:"Click to add below \nAlt+Click to add above",askQuestion:"Ask AI",file:"File",date:"Date",emoji:"Emoji",user:"User",bulletedList:"Bulleted list",numberedList:"Numbered list",toDoList:"To-do list",toggleList:"Toggle list",callout:"Callout",quote:"Quote",divider:"Divider",askQuestionToAI:"Ask a question to AI",insertAnImage:"Insert an image",insertAVideo:"Insert a video",insertAFile:"Insert a file",insertADate:"Insert a date",insertAnEmoji:"Insert an emoji",insertAUser:"Insert a user",justStartWritingWithPlainText:"Just start writing with plain text",bigSectionHeading:"Main Title",mediumSectionHeading:"Section Heading",smallSectionHeading:"Subsection Heading",verySmallSectionHeading:"Smaller Subsection",extraSmallSectionHeading:"Minor Heading",leastImportantHeading:"Least Important Heading",startABulletedList:"Start a bulleted list",startANumberedList:"Start a numbered list",startAToDoList:"Start a to-do list",togglesCanHideShowContent:"Toggles can hide/show content",makeWritingStandOut:"Make writing stand out",captureAQuote:"Capture a quote",insertATable:"Insert a table",breakUpYourWriting:"Break up your writing",noResults:"No Results",typeToFilter:"Type to filter...",editSelection:"Edit Selection",rewrite:"Rewrite",rewriteDescription:"Rewrite the selected text",continueWriting:"Continue writing",continueWritingDescription:"Extend the content further",fixSpellingGrammar:"Fix spelling & grammar",fixSpellingGrammarDescription:"Correct spelling and grammatical errors",summarize:"Summarize",summarizeDescription:"Generate a concise summary of the text",makeShorter:"Make shorter",makeShorterDescription:"Reduce the length of the text while maintaining meaning",makeLonger:"Make longer",makeLongerDescription:"Expand the text with more details",explain:"Explain",explainDescription:"Provide a clearer or more detailed explanation",changeTone:"Change Tone",concise:"Concise",conciseDescription:"Make the text more brief and to the point",professional:"Professional",professionalDescription:"Adjust the text to sound more formal and business-like",casual:"Casual",casualDescription:"Make the text sound more relaxed and friendly",funny:"Funny",funnyDescription:"Add humor or a lighthearted tone to the text",translate:"Translate",translateEnglish:"Translate to English",translateEnglishDescription:"Translate the text into English",translateSpanish:"Translate to Spanish",translateSpanishDescription:"Translate the text into Spanish",translatePortuguese:"Translate to Portuguese",translatePortugueseDescription:"Translate the text into Portuguese",translateItalian:"Translate to Italian",translateItalianDescription:"Translate the text into Italian",translateDutch:"Translate to Dutch",translateDutchDescription:"Translate the text into Dutch",translateChinese:"Translate to Chinese",translateChineseDescription:"Translate the text into Chinese",translateKorean:"Translate to Korean",translateKoreanDescription:"Translate the text into Korean",translateJapanese:"Translate to Japanese",translateJapaneseDescription:"Translate the text into Japanese",translateRussian:"Translate to Russian",translateRussianDescription:"Translate the text into Russian",processing:"Processing...",typePrompt:"Type your prompt here",keep:"Keep",insertBelow:"Insert below",page:"Link to a page",insertPage:"Organize ideas, tasks, and notes",task:"Task",insertTask:"Insert a task",twoColumns:"2 columns",threeColumns:"3 columns",fourColumns:"4 columns",twoColumnsDescription:"Create 2 of blocks",threeColumnsDescription:"Create 3 of blocks",fourColumnsDescription:"Create 4 of blocks",taskPlaceholder:"Enter Task Name"}}},name:{value:null,type:"string?"},pasteFormat:{allowedValues:["prompt","plainText","keepFormat","cleanFormat"],value:"keepFormat",type:"string"},postData:{value:null,type:"object"},placeholder:{value:"",type:"string"},removeStylesOnClearFormat:{value:!1,type:"boolean"},required:{value:!1,type:"boolean"},sanitized:{value:!1,type:"boolean"},showCharCount:{value:!1,type:"boolean"},compactImageDialog:{value:!1,type:"boolean"},imagePasteWidth:{value:0,type:"number"},imagePasteHeight:{value:0,type:"number"},splitModeRefreshTimeout:{value:100,type:"number"},toolbarItems:{value:["bold","italic","underline","|","formats","alignment","orderedList","unorderedList","|","hyperlink","image","video","|","sourceCode","undo","redo"],reflectToAttribute:!1,type:"array"},toolbarMode:{allowedValues:["menu","singleLineRibbon"],value:"menu",type:"string"},toolbarOnFocus:{value:!1,type:"boolean"},toolbarRibbonConfig:{value:[{name:"homeTab",groups:[{name:"undoGroup",items:["undo","redo"]},{name:"clipboardGroup",items:["cut","copy","paste"]},{name:"fontGroup",items:["fontName","fontSize","backgroundColor","fontColor","clearFormat","formats","bold","italic","underline","strikethrough","superscript","subscript"]},{name:"paragraphGroup",items:["orderedList","unorderedList","indent","outdent","alignment"]},{name:"editingGroup",items:["findAndReplace"]}]},{name:"insertTab",groups:[{name:"tableGroup",items:["table"]},{name:"imageGroup",items:["image"]},{name:"videoGroup",items:["video"]},{name:"linkGroup",items:["createLink","removeLink"]}]},{name:"viewTab",groups:[{name:"viewsGroup",items:["fullScreen","sourceCode","splitMode"]}]},{name:"layoutTab",hidden:!0,groups:[{name:"deleteGroup",items:["delete"]},{name:"tableGroup",items:["table","tableHeader","tableRows","tableColumns","tableVAlign","tableStyle",""]},{name:"imageGroup",items:["image","caption"]},{name:"videoGroup",items:["video","caption"]}]}],type:"array"},toolbarViewMode:{allowedValues:["toggle","multiRow","scroll"],value:"toggle",type:"string"},toolbarSticky:{value:!1,type:"boolean"},spellCheck:{value:!0,type:"boolean"},value:{value:"",type:"string",validator:"_sanitize",reflectToAttribute:!1},validateFile:{value:null,type:"function?",reflectToAttribute:!1},uploadUrl:{value:"",type:"string",reflectToAttribute:!1},removeUrl:{value:"",type:"string",reflectToAttribute:!1},onImageRemove:{value:null,type:"function?"},autoUpload:{value:!0,type:"boolean"},users:{value:[],type:"array",reflectToAttribute:!1},windowCustomizationFunction:{value:null,reflectToAttribute:!1,type:"function?"}}}static get listeners(){return{"document.down":"_documentDownHandler","document.move":"_documentMoveHandler","document.up":"_documentUpHandler","document.dragstart":"_dragStartHandler","document.selectstart":"_selectStartHandler","document.selectionchange":"_selectionChangeHandler","container.dragend":"_dragEndHandler","container.drop":"_dropHandler","container.change":"_changeHandler","container.beforeinput":"_beforeInputHandler","container.input":"_afterInputHandler","contentContainer.contextmenu":"_contextMenuHandler","contentContainer.keydown":"_editableElementKeyDownHandler","contentContainer.keyup":"_updateOnInputChange","contentContainer.paste":"_updateOnInputChange","input.focus":"_editableElementFocusHandler","input.blur":"_editableElementBlurHandler","input.change":"_inputChangeEvent","editableElement.focus":"_editableElementFocusHandler","editableElement.blur":"_editableElementBlurHandler","editableElement.wheel":"_editableElementWheelHandler","editableElement.move":"_editableElementMoveHandler","editableElement.mouseEnter":"_editableElementMouseEnterHandler",touchmove:"_touchmoveHandler",resize:"_resizeHandler",mouseleave:"_mouseLeaveHandler"}}static get requires(){return{"Smart.Button":"smart.button.js","Smart.Window":"smart.window.js","Smart.Tooltip":"smart.tooltip.js"}}static get styleUrls(){return["smart.editor.css"]}template(){return'<div id="container" role="presentation">\n <div id="toolbar" class="smart-editor-toolbar" role="presentation">\n <div id="toolbarItemsPrimary" class="smart-editor-toolbar-items-primary" role="toolbar"></div>\n <div id="toolbarToggleButton" class="smart-editor-toolbar-toggle-button" role="button"></div>\n <div id="toolbarItemsSecondary" class="smart-editor-toolbar-items-secondary" role="toolbar"></div>\n </div>\n <div id="contentContainer" class="smart-editor-content-container" role="presentation">\n <div class="smart-editor-editable" contenteditable="true" id="editableElement" aria-placeholder="[[placeholder]]"\n inner-h-t-m-l="[[innerHTML]]" role="textbox" aria-multiline="true"><content></content></div>\n <textarea name="[[name]]" id="input" class="smart-hidden" placeholder="[[placeholder]]" aria-placeholder="[[placeholder]]"\n spellcheck="[[spellCheck]]" autocapitalize="none" autocomplete="off"></textarea>\n <div class="smart-hidden smart-editor-tabs" id="tabs">\n </div>\n </div>\n </div>'}_editableElementMouseEnterHandler(){this._setSortable()}propertyChangedHandler(e,t,a){const o=this;switch(e){case"contentFiltering":case"contentFiltering_attributes":case"contentFiltering_attributeFilterMode":case"contentFiltering_tags":case"contentFiltering_tagFilterMode":case"contentFiltering_styleAttributes":case"contentFiltering_styleAttributeFilterMode":o._handleContentFiltering();break;case"disabled":case"disableEditing":o.$.input.readonly=a,o.$.editableElement.setAttribute("contenteditable",!a),"disabled"===e&&o._setFocusable();break;case"disableSearchBar":o._closeSearchToolbar();break;case"enableHtmlEncode":{const e=o.$.input;e.classList.contains("smart-hidden")||(e.value=o._getInputValue());break}case"hideToolbar":a&&o._updateToolbarItems(void 0,o.$.toolbar);break;case"sortable":o._setSortable();break;case"users":o._refreshTasks();break;case"innerHTML":case"value":if(""===a)a="&nbsp;";else{const e=e=>{let t=e.replace(/\\"/g,'"');return t=t.replace(/\\+/g,""),t=t.replace(/&nbsp;/g," "),t=t.replace(/"\s*=/g,'="'),t};let t=(e=>{const t=document.createElement("textarea");return t.innerHTML=e,t.value})(a);t=e(t),a=t}if("blockHtml"===o.editMode){const e=o._createEditorBlock(!1,!1,a);o.innerHTML=o.value=a=e.outerHTML}o._handleInputContent(e,a),"blockHtml"===o.editMode?setTimeout((()=>{o._initEditorBlocks(),o._refreshEditorBlockPlaceholder(),o._editorBlocks=o.$.editableElement.querySelectorAll(".smart-editor-block"),o._setSortable(),o._renderPages(),o._refreshTasks()}),100):o._renderPages(),o.$.fireEvent("change",{oldValue:o._value||t,value:o._value=o._getCurrentValue()});break;case"editMode":o._handleEditMode(a);break;case"hideInlineToolbar":{const e=o.$.inlineToolbar;e&&e.visible&&e.classList.contains("smart-editor-inline-toolbar")&&e.close();break}case"toolbarViewMode":o._toggleToolbar("toggle"===a);break;case"pages":case"enablePages":o._renderPages();break;case"toolbarOnFocus":case"toolbarMode":case"toolbarRibbonConfig":o._handleToolbarMode();break;case"locale":delete o._toolbarItemsObj,delete o._inlineToolbarItemsObj,o._refreshToolbarItems(o._getToolbarItems()),o._closeToolbar(),o._closeWindow();break;case"iframeSettings":o._handleInputElement();break;case"maxCharCount":o._handleMaxCharCount(),o._setCharCount();break;case"name":a&&"markdown"!==o.editMode&&(o.$.input.value=o._getInputValue(o.$.editableElement.innerHTML.trim()));break;case"placeholder":o._handlePlaceholder();break;case"pasteFormat":o._closeWindow();break;case"readonly":o.$.input.readonly=a,o.$.editableElement.setAttribute("contenteditable","markdown"!==o.editMode&&!a),o._closePopups(),o._setResizeFrame(),o._closeWindow();break;case"showCharCount":o._setCharCount();break;case"rightToLeft":case"animation":case"theme":o._updateIframeBody();break;case"toolbarItems":o._handleToolbarItems();break;default:super.propertyChangedHandler(e,t,a)}}_mouseLeaveHandler(){const e=this;e.$.headerInsertLine&&(e.$.headerInsertLine.classList.remove("show"),e.$.headerSortable.classList.remove("show"))}addToolbarItem(e){const t=this;t.toolbarItems||(t.toolbarItems=[]),t.toolbarItems.push(e),t._handleToolbarItems()}insertToolbarItem(e,t){const a=this;a.toolbarItems||(a.toolbarItems=[]),a.toolbarItems.splice(t,0,e),a._handleToolbarItems()}removeToolbarItem(e){const t=this;t.toolbarItems||(t.toolbarItems=[]),t.toolbarItems.splice(e,1),t._handleToolbarItems()}_handleToolbarItems(){const e=this,t=e.$.toolbarItemsPrimary,a=e.$.toolbarItemsSecondary;if(t&&a&&(t.innerHTML=a.innerHTML="",delete e._toolbarItemsObj,delete e._inlineToolbarItemsObj,e._refreshToolbarItems(e._getToolbarItems()),"toggle"===e.toolbarViewMode)){const o=e.$.toolbarToggleButton;t.scrollHeight!==t.offsetHeight||a.children.length?o.classList.remove("smart-visibility-hidden"):o.classList.add("smart-visibility-hidden")}}_refreshSortableMenuItems(e){const t=e.querySelectorAll(".smart-editor-context-menu-item");t.forEach((e=>e.classList.remove("smart-hidden")));const a=document.createElement("div");a.classList.add("smart-editor-context-menu-item"),a.setAttribute("role","option"),a.innerHTML=this.localize("noResults"),a.classList.add("smart-hidden"),a.style.whiteSpace="nowrap",a.style.paddingLeft=a.style.paddingBottom=a.style.paddingTop="5px",a.style.paddingRight="7px",a.classList.add("empty-item");let o=!1;return t.forEach((e=>{e.classList.contains("empty-item")&&(o=!0)})),o||e.appendChild(a),[t,a]}_getSortableMenuItems(){const e=this,t=[{label:e.localize("askQuestion"),value:"ai",description:e.localize("askQuestionToAI")}],a=[{label:e.localize("image"),value:"image",description:e.localize("insertAnImage")},{label:e.localize("video"),value:"video",description:e.localize("insertAVideo")},{label:e.localize("file"),value:"file",description:e.localize("insertAFile")},{label:e.localize("date"),value:"date",description:e.localize("insertADate")},{label:e.localize("emoji"),value:"emoji",description:e.localize("insertAnEmoji")}];e.users&&e.users.length>0&&a.push({label:e.localize("user"),value:"user",description:e.localize("insertAUser")});const o=[{label:e.localize("text"),name:"text",value:"text",description:e.localize("justStartWritingWithPlainText")},{label:e.localize("h1"),name:"formats",value:"h1",description:e.localize("bigSectionHeading")},{label:e.localize("h2"),name:"formats",value:"h2",description:e.localize("mediumSectionHeading")},{label:e.localize("h3"),name:"formats",value:"h3",description:e.localize("smallSectionHeading")},{label:e.localize("h4"),name:"formats",value:"h4",description:e.localize("verySmallSectionHeading")},{label:e.localize("h5"),name:"formats",value:"h5",description:e.localize("extraSmallSectionHeading")},{label:e.localize("h6"),name:"formats",value:"h6",description:e.localize("leastImportantHeading")},{label:e.localize("bulletedList"),value:"unorderedlist",description:e.localize("startABulletedList")},{label:e.localize("numberedList"),value:"orderedlist",description:e.localize("startANumberedList")},{label:e.localize("toDoList"),value:"checklist",description:e.localize("startAToDoList")},{label:e.localize("toggleList"),value:"togglelist",description:e.localize("togglesCanHideShowContent")},{label:e.localize("callout"),value:"callout",description:e.localize("makeWritingStandOut")},{label:e.localize("quote"),name:"formats",value:"blockquote",description:e.localize("captureAQuote")},{label:e.localize("createLink"),name:"hyperlink",value:"hyperlink",description:e.localize("insertlink")},{label:e.localize("table"),value:"table",description:e.localize("insertATable")},{label:e.localize("divider"),value:"divider",description:e.localize("breakUpYourWriting")},{label:e.localize("task"),value:"task",description:e.localize("insertTask")}];if(e.enablePages){const t=[{label:e.localize("page"),value:"page",description:e.localize("insertPage")}];o.push(...t)}const i=[{label:e.localize("twoColumns"),value:"twoColumns",description:e.localize("twoColumnsDescription")}];return o.push(...i),e.ai.key&&o.push(...t),o.push(...a),o}_getAIMenuItems(){const e=this;return[{label:e.localize("editSelection","Edit Selection"),value:"category"},{label:e.localize("rewrite","Rewrite"),value:"rewrite",description:e.localize("rewriteDescription","Rewrite the selected text")},{label:e.localize("continueWriting","Continue writing"),value:"continue_writing",description:e.localize("continueWritingDescription","Extend the content further")},{label:e.localize("fixSpellingGrammar","Fix spelling & grammar"),value:"fix_spelling_grammar",description:e.localize("fixSpellingGrammarDescription","Correct spelling and grammatical errors")},{label:e.localize("summarize","Summarize"),value:"summarize",description:e.localize("summarizeDescription","Generate a concise summary of the text")},{label:e.localize("makeShorter","Make shorter"),value:"make_shorter",description:e.localize("makeShorterDescription","Reduce the length of the text while maintaining meaning")},{label:e.localize("makeLonger","Make longer"),value:"make_longer",description:e.localize("makeLongerDescription","Expand the text with more details")},{label:e.localize("explain","Explain"),value:"explain",description:e.localize("explainDescription","Provide a clearer or more detailed explanation")},{label:e.localize("changeTone","Change Tone"),value:"category"},{label:e.localize("concise","Concise"),value:"concise",description:e.localize("conciseDescription","Make the text more brief and to the point")},{label:e.localize("professional","Professional"),value:"professional",description:e.localize("professionalDescription","Adjust the text to sound more formal and business-like")},{label:e.localize("casual","Casual"),value:"casual",description:e.localize("casualDescription","Make the text sound more relaxed and friendly")},{label:e.localize("funny","Funny"),value:"funny",description:e.localize("funnyDescription","Add humor or a lighthearted tone to the text")},{label:e.localize("translate","Translate"),value:"category"},{label:e.localize("translateEnglish","Translate to English"),value:"translate_english",description:e.localize("translateEnglishDescription","Translate the text into English")},{label:e.localize("translateSpanish","Translate to Spanish"),value:"translate_spanish",description:e.localize("translateSpanishDescription","Translate the text into Spanish")},{label:e.localize("translatePortuguese","Translate to Portuguese"),value:"translate_portuguese",description:e.localize("translatePortugueseDescription","Translate the text into Portuguese")},{label:e.localize("translateItalian","Translate to Italian"),value:"translate_italian",description:e.localize("translateItalianDescription","Translate the text into Italian")},{label:e.localize("translateDutch","Translate to Dutch"),value:"translate_dutch",description:e.localize("translateDutchDescription","Translate the text into Dutch")},{label:e.localize("translateChinese","Translate to Chinese"),value:"translate_chinese",description:e.localize("translateChineseDescription","Translate the text into Chinese")},{label:e.localize("translateKorean","Translate to Korean"),value:"translate_korean",description:e.localize("translateKoreanDescription","Translate the text into Korean")},{label:e.localize("translateJapanese","Translate to Japanese"),value:"translate_japanese",description:e.localize("translateJapaneseDescription","Translate the text into Japanese")},{label:e.localize("translateRussian","Translate to Russian"),value:"translate_russian",description:e.localize("translateRussianDescription","Translate the text into Russian")}]}_createCallout(e,t){const a=this;a._callout&&a._callout.remove();const o=document.createElement("div");a._callout=o,o.classList.add("dropdown","smart-editor-callout"),o.innerHTML="\n <div class='categories' id='categories'></div>\n <div class='tabs' id='tabs'></div>\n ";const i=o,n=i.firstElementChild,r=i.lastElementChild;document.body.appendChild(o);const l={General:[{emoji:"💡",title:"Idea"},{emoji:"📌",title:"Pinned Note"},{emoji:"🔥",title:"On Fire"},{emoji:"⚡",title:"Lightning Fast"},{emoji:"💬",title:"Chat"},{emoji:"📅",title:"Calendar"},{emoji:"🔒",title:"Locked & Secure"},{emoji:"⭐",title:"Starred"},{emoji:"🎉",title:"Celebration"},{emoji:"📝",title:"Notes"},{emoji:"📂",title:"Folder"},{emoji:"🔔",title:"Notification"},{emoji:"🌟",title:"Shining Star"},{emoji:"🚀",title:"Rocket Boost"},{emoji:"📈",title:"Growth"},{emoji:"🎯",title:"Target Achieved"},{emoji:"💪",title:"Strength"},{emoji:"⏳",title:"Time Running"},{emoji:"🧠",title:"Brainstorm"},{emoji:"📚",title:"Learning"},{emoji:"🖋️",title:"Writing"},{emoji:"📋",title:"Clipboard"},{emoji:"🗓️",title:"Schedule"},{emoji:"🏆",title:"Trophy"},{emoji:"🎁",title:"Gift"},{emoji:"🎨",title:"Creativity"},{emoji:"⚖️",title:"Balance"},{emoji:"⏲️",title:"Timer"},{emoji:"🌍",title:"Global"},{emoji:"🔍",title:"Search"},{emoji:"🛠️",title:"Tools & Fixes"},{emoji:"📜",title:"Document"},{emoji:"🎵",title:"Music"},{emoji:"📎",title:"Attachment"},{emoji:"🖥️",title:"Computer Work"},{emoji:"📱",title:"Mobile"},{emoji:"💭",title:"Thinking"},{emoji:"✉️",title:"Email"},{emoji:"🔄",title:"Sync & Refresh"},{emoji:"🕒",title:"Time Management"},{emoji:"💰",title:"Finance"},{emoji:"📊",title:"Analytics"},{emoji:"🛒",title:"Shopping"},{emoji:"🔑",title:"Key Info"},{emoji:"⚙️",title:"Settings"},{emoji:"🎬",title:"Video Content"},{emoji:"🗃️",title:"Storage"},{emoji:"🏅",title:"Achievement"},{emoji:"📘",title:"Book"},{emoji:"📤",title:"Sent"},{emoji:"📥",title:"Received"},{emoji:"📍",title:"Location"},{emoji:"✏️",title:"Edit"},{emoji:"🖼️",title:"Image"},{emoji:"📻",title:"Podcast & Radio"},{emoji:"🛎️",title:"Reminder"},{emoji:"🔦",title:"Highlight"},{emoji:"🌈",title:"Inspiration"},{emoji:"🎙️",title:"Recording"},{emoji:"🖌️",title:"Design"}],Productivity:[{emoji:"🧠",title:"Brainstorming"},{emoji:"⏳",title:"Time Management"},{emoji:"🔑",title:"Key"},{emoji:"🗂️",title:"Organizer"},{emoji:"📈",title:"Analytics"},{emoji:"💼",title:"Business"},{emoji:"📋",title:"Checklist"},{emoji:"🖥️",title:"Computer"},{emoji:"📅",title:"Schedule"},{emoji:"📚",title:"Learning"},{emoji:"🚀",title:"Success"},{emoji:"💻",title:"Laptop"},{emoji:"📱",title:"Mobile"},{emoji:"⏰",title:"Alarm Clock"},{emoji:"📂",title:"Documents"},{emoji:"📝",title:"Writing"},{emoji:"✏️",title:"Edit"},{emoji:"🔔",title:"Reminder"},{emoji:"⚡",title:"Quick Action"},{emoji:"💪",title:"Effort"},{emoji:"🛠️",title:"Tools"},{emoji:"📊",title:"Statistics"},{emoji:"💡",title:"Creativity"},{emoji:"🎯",title:"Focus"},{emoji:"📎",title:"Attachment"},{emoji:"📤",title:"Outbox"},{emoji:"📥",title:"Inbox"},{emoji:"🔍",title:"Search"},{emoji:"🗝️",title:"Solution"},{emoji:"🏗️",title:"Building"},{emoji:"🏃‍♂️",title:"Hustle"},{emoji:"🏅",title:"Achievement"},{emoji:"🌍",title:"Global Work"},{emoji:"💰",title:"Finance"},{emoji:"📢",title:"Announcement"},{emoji:"🔄",title:"Refresh"},{emoji:"✅",title:"Completed Task"},{emoji:"📶",title:"Progress"},{emoji:"🖇️",title:"Connection"},{emoji:"📜",title:"Documentation"},{emoji:"🏆",title:"Success"},{emoji:"🚦",title:"Prioritization"},{emoji:"🎛️",title:"Control Panel"},{emoji:"💳",title:"Payment"},{emoji:"🛎️",title:"Service"},{emoji:"🌐",title:"Online Work"},{emoji:"📍",title:"Location"},{emoji:"🛒",title:"Shopping List"},{emoji:"📜",title:"Agreement"},{emoji:"⚙️",title:"Settings"},{emoji:"📑",title:"Bookmarks"},{emoji:"🛤️",title:"Roadmap"}],Motivation:[{emoji:"🎯",title:"Goal Setting"},{emoji:"💪",title:"Strength"},{emoji:"🚀",title:"Ambition"},{emoji:"🌟",title:"Shining Bright"},{emoji:"🏆",title:"Victory"},{emoji:"🔥",title:"Passion"},{emoji:"⚡",title:"Energy"},{emoji:"🏅",title:"Achievement"},{emoji:"🌱",title:"Growth"},{emoji:"💯",title:"Excellence"},{emoji:"🎉",title:"Celebration"},{emoji:"🎁",title:"Reward"},{emoji:"✨",title:"Inspiration"},{emoji:"💥",title:"Breakthrough"},{emoji:"💫",title:"Momentum"},{emoji:"🌠",title:"Dream Big"},{emoji:"🥇",title:"First Place"},{emoji:"🚀",title:"Sky's the Limit"},{emoji:"💨",title:"Speed"},{emoji:"💡",title:"Bright Ideas"},{emoji:"🏋️‍♂️",title:"Hard Work"},{emoji:"📈",title:"Progress"},{emoji:"🔝",title:"Top Performance"},{emoji:"👊",title:"Determination"},{emoji:"🕶️",title:"Confidence"},{emoji:"🤩",title:"Excitement"},{emoji:"🚧",title:"Overcoming Challenges"},{emoji:"💎",title:"Value"},{emoji:"🏁",title:"Finish Line"},{emoji:"🌞",title:"Positivity"},{emoji:"🔥",title:"Stay Motivated"},{emoji:"🎵",title:"Power Playlist"},{emoji:"🛤️",title:"Journey to Success"},{emoji:"🤝",title:"Support System"},{emoji:"📅",title:"Daily Wins"},{emoji:"🎙️",title:"Speak Up"},{emoji:"🧗‍♂️",title:"Keep Climbing"},{emoji:"🏃‍♂️",title:"Keep Moving"},{emoji:"📢",title:"Encouragement"},{emoji:"💰",title:"Financial Goals"},{emoji:"🎓",title:"Learning & Growth"},{emoji:"🛠️",title:"Building Success"},{emoji:"⚖️",title:"Balance & Focus"},{emoji:"🥂",title:"Milestone Celebration"},{emoji:"🗺️",title:"Vision & Strategy"},{emoji:"🛑",title:"No Excuses"},{emoji:"🚦",title:"Go Mode"},{emoji:"🚀",title:"Unstoppable"}],"Smile Faces":[{emoji:"😀",title:"Big Smile"},{emoji:"😃",title:"Happy Face"},{emoji:"😄",title:"Grinning"},{emoji:"😁",title:"Cheerful"},{emoji:"😆",title:"Laughing Hard"},{emoji:"😅",title:"Relieved Laugh"},{emoji:"😂",title:"Tears of Joy"},{emoji:"🤣",title:"ROFL"},{emoji:"😜",title:"Playful Wink"},{emoji:"😎",title:"Cool & Confident"},{emoji:"😍",title:"Heart Eyes"},{emoji:"😊",title:"Warm Smile"},{emoji:"😉",title:"Wink"},{emoji:"🥰",title:"Feeling Loved"},{emoji:"😚",title:"Kissy Face"},{emoji:"😙",title:"Smooch"},{emoji:"😋",title:"Yummy!"},{emoji:"😛",title:"Tongue Out"},{emoji:"😏",title:"Smirking"},{emoji:"😌",title:"Content & Relaxed"},{emoji:"😗",title:"Kissing Face"},{emoji:"🥳",title:"Party Mode"},{emoji:"🤩",title:"Star-Struck"},{emoji:"🤗",title:"Hugging You"},{emoji:"😇",title:"Angel Mode"},{emoji:"😻",title:"Loving Cat"},{emoji:"😺",title:"Happy Cat"},{emoji:"😽",title:"Cat Kiss"},{emoji:"🤭",title:"Oops, My Bad"},{emoji:"🫠",title:"Melting with Happiness"},{emoji:"🥹",title:"Touched & Emotional"},{emoji:"🫡",title:"Respect"},{emoji:"🤤",title:"Drooling"},{emoji:"😬",title:"Awkward Smile"},{emoji:"🤪",title:"Crazy Fun"},{emoji:"😵‍💫",title:"Dizzy & Confused"},{emoji:"😯",title:"Surprised & Speechless"},{emoji:"🤠",title:"Yeehaw Mood"},{emoji:"😆",title:"Giggle"},{emoji:"🫢",title:"Oops!"},{emoji:"🙃",title:"Upside Down Fun"},{emoji:"😜",title:"Goofy"},{emoji:"😹",title:"Cat LOL"},{emoji:"😈",title:"Mischievous Grin"},{emoji:"👻",title:"Silly Ghost"},{emoji:"🥴",title:"Woozy"},{emoji:"🫨",title:"Shaking with Excitement"},{emoji:"💃",title:"Dancing Queen"}],People:[{emoji:"👨‍💻",title:"Man Technologist"},{emoji:"👩‍💻",title:"Woman Technologist"},{emoji:"👨‍🎓",title:"Man Student"},{emoji:"👩‍🎓",title:"Woman Student"},{emoji:"👨‍🏫",title:"Man Teacher"},{emoji:"👩‍🏫",title:"Woman Teacher"},{emoji:"👨‍⚖️",title:"Man Judge"},{emoji:"👩‍⚖️",title:"Woman Judge"},{emoji:"👨‍🔬",title:"Man Scientist"},{emoji:"👩‍🔬",title:"Woman Scientist"},{emoji:"👨‍🎨",title:"Man Artist"},{emoji:"👩‍🎨",title:"Woman Artist"},{emoji:"👨‍🍳",title:"Man Chef"},{emoji:"👩‍🍳",title:"Woman Chef"},{emoji:"👨‍🚀",title:"Man Astronaut"},{emoji:"👩‍🚀",title:"Woman Astronaut"},{emoji:"🧑‍⚖️",title:"Person Judge"},{emoji:"🧑‍🔬",title:"Person Scientist"},{emoji:"🧑‍🎨",title:"Person Artist"},{emoji:"🧑‍🍳",title:"Person Chef"},{emoji:"🧑‍🚀",title:"Person Astronaut"},{emoji:"🧑‍⚖️",title:"Person Lawyer"},{emoji:"👶",title:"Baby"},{emoji:"👧",title:"Girl"},{emoji:"👦",title:"Boy"},{emoji:"👨",title:"Man"},{emoji:"👩",title:"Woman"},{emoji:"🧑",title:"Person"},{emoji:"🧓",title:"Older Person"},{emoji:"👵",title:"Grandmother"},{emoji:"👴",title:"Grandfather"},{emoji:"👮",title:"Police Officer"},{emoji:"👷",title:"Construction Worker"},{emoji:"💂",title:"Guard"},{emoji:"👩‍⚖️",title:"Female Judge"},{emoji:"👩‍🍳",title:"Female Chef"},{emoji:"👨‍⚖️",title:"Male Judge"},{emoji:"👨‍🍳",title:"Male Chef"},{emoji:"💃",title:"Dancer"},{emoji:"🕺",title:"Man Dancing"},{emoji:"🤦",title:"Facepalm"},{emoji:"🤷",title:"Shrug"},{emoji:"🙋",title:"Person Raising Hand"},{emoji:"🙋‍♂️",title:"Man Raising Hand"},{emoji:"🙋‍♀️",title:"Woman Raising Hand"},{emoji:"🙆",title:"Person Gesturing OK"},{emoji:"🙆‍♂️",title:"Man Gesturing OK"},{emoji:"🙆‍♀️",title:"Woman Gesturing OK"},{emoji:"💅",title:"Nail Polish"},{emoji:"🧑‍🦱",title:"Person with Curly Hair"},{emoji:"🧑‍🦳",title:"Person with White Hair"},{emoji:"🧑‍🦲",title:"Bald Person"}],"Food & Drink":[{emoji:"🍎",title:"Red Apple"},{emoji:"🍏",title:"Green Apple"},{emoji:"🍐",title:"Pear"},{emoji:"🍊",title:"Orange"},{emoji:"🍋",title:"Lemon"},{emoji:"🍌",title:"Banana"},{emoji:"🍉",title:"Watermelon"},{emoji:"🍇",title:"Grapes"},{emoji:"🍓",title:"Strawberry"},{emoji:"🫐",title:"Blueberry"},{emoji:"🍒",title:"Cherries"},{emoji:"🍑",title:"Peach"},{emoji:"🥭",title:"Mango"},{emoji:"🍍",title:"Pineapple"},{emoji:"🥥",title:"Coconut"},{emoji:"🥝",title:"Kiwi"},{emoji:"🍅",title:"Tomato"},{emoji:"🌶️",title:"Hot Pepper"},{emoji:"🥒",title:"Cucumber"},{emoji:"🥕",title:"Carrot"},{emoji:"🌽",title:"Corn"},{emoji:"🥔",title:"Potato"},{emoji:"🧅",title:"Onion"},{emoji:"🧄",title:"Garlic"},{emoji:"🥑",title:"Avocado"},{emoji:"🥦",title:"Broccoli"},{emoji:"🥬",title:"Lettuce"},{emoji:"🫛",title:"Peas"},{emoji:"🥜",title:"Peanuts"},{emoji:"🌰",title:"Chestnut"},{emoji:"🍞",title:"Bread"},{emoji:"🥖",title:"Baguette"},{emoji:"🥐",title:"Croissant"},{emoji:"🥯",title:"Bagel"},{emoji:"🧇",title:"Waffle"},{emoji:"🥞",title:"Pancakes"},{emoji:"🧀",title:"Cheese"},{emoji:"🍗",title:"Chicken Leg"},{emoji:"🥩",title:"Steak"},{emoji:"🍖",title:"Meat on Bone"},{emoji:"🌭",title:"Hot Dog"},{emoji:"🍔",title:"Burger"},{emoji:"🍕",title:"Pizza"},{emoji:"🥪",title:"Sandwich"},{emoji:"🌮",title:"Taco"},{emoji:"🌯",title:"Burrito"},{emoji:"🥗",title:"Salad"},{emoji:"🍣",title:"Sushi"},{emoji:"🍛",title:"Curry"},{emoji:"🍜",title:"Noodles"},{emoji:"🍲",title:"Soup"},{emoji:"🥘",title:"Paella"},{emoji:"🫕",title:"Fondue"},{emoji:"🍚",title:"Cooked Rice"},{emoji:"🍤",title:"Fried Shrimp"},{emoji:"🥮",title:"Moon Cake"},{emoji:"🍩",title:"Doughnut"},{emoji:"🍪",title:"Cookie"},{emoji:"🍰",title:"Cake"},{emoji:"🎂",title:"Birthday Cake"},{emoji:"🧁",title:"Cupcake"},{emoji:"🍫",title:"Chocolate"},{emoji:"🍬",title:"Candy"},{emoji:"🍭",title:"Lollipop"},{emoji:"🍮",title:"Custard"},{emoji:"🍯",title:"Honey"},{emoji:"🥛",title:"Milk"},{emoji:"🍼",title:"Baby Bottle"},{emoji:"☕",title:"Coffee"},{emoji:"🍵",title:"Tea"},{emoji:"🧃",title:"Juice"},{emoji:"🥤",title:"Soft Drink"},{emoji:"🍹",title:"Cocktail"},{emoji:"🍷",title:"Wine"},{emoji:"🍺",title:"Beer"},{emoji:"🍻",title:"Cheers"},{emoji:"🥂",title:"Champagne"},{emoji:"🥃",title:"Whiskey"}],Symbols:[{emoji:"✅",title:"Check Mark"},{emoji:"❌",title:"Cross Mark"},{emoji:"⚠️",title:"Warning"},{emoji:"ℹ️",title:"Information"},{emoji:"❓",title:"Question"},{emoji:"❗",title:"Exclamation"},{emoji:"🔄",title:"Refresh"},{emoji:"🔃",title:"Reload"},{emoji:"➕",title:"Plus"},{emoji:"➖",title:"Minus"},{emoji:"➗",title:"Division"},{emoji:"✖️",title:"Multiplication"},{emoji:"💲",title:"Dollar Sign"},{emoji:"💱",title:"Currency Exchange"},{emoji:"⚡",title:"Lightning"},{emoji:"🔒",title:"Lock"},{emoji:"🔓",title:"Unlock"},{emoji:"🔑",title:"Key"},{emoji:"🆕",title:"New"},{emoji:"🆙",title:"Up"},{emoji:"🆒",title:"Cool"},{emoji:"🆓",title:"Free"},{emoji:"🆖",title:"No Good"},{emoji:"🈺",title:"Open Business"},{emoji:"🈚",title:"Not Available"},{emoji:"⭕",title:"Circle"},{emoji:"💠",title:"Diamond"},{emoji:"🔷",title:"Blue Diamond"},{emoji:"🔶",title:"Orange Diamond"},{emoji:"🔴",title:"Red Circle"},{emoji:"🟢",title:"Green Circle"},{emoji:"🔵",title:"Blue Circle"},{emoji:"🟡",title:"Yellow Circle"},{emoji:"⚪",title:"White Circle"},{emoji:"⚫",title:"Black Circle"},{emoji:"⬆️",title:"Up Arrow"},{emoji:"⬇️",title:"Down Arrow"},{emoji:"⬅️",title:"Left Arrow"},{emoji:"➡️",title:"Right Arrow"},{emoji:"↔️",title:"Left-Right Arrow"},{emoji:"↕️",title:"Up-Down Arrow"},{emoji:"🔄",title:"Rotate"},{emoji:"♻️",title:"Recycle"},{emoji:"🏳️",title:"White Flag"},{emoji:"🏴",title:"Black Flag"},{emoji:"🏁",title:"Finish Line"},{emoji:"⚜️",title:"Fleur-de-lis"},{emoji:"♾️",title:"Infinity"}],Flags:[{emoji:"🇺🇸",title:"United States"},{emoji:"🇨🇦",title:"Canada"},{emoji:"🇬🇧",title:"United Kingdom"},{emoji:"🇦🇺",title:"Australia"},{emoji:"🇩🇪",title:"Germany"},{emoji:"🇫🇷",title:"France"},{emoji:"🇮🇹",title:"Italy"},{emoji:"🇪🇸",title:"Spain"},{emoji:"🇳🇱",title:"Netherlands"},{emoji:"🇧🇪",title:"Belgium"},{emoji:"🇨🇭",title:"Switzerland"},{emoji:"🇦🇹",title:"Austria"},{emoji:"🇸🇪",title:"Sweden"},{emoji:"🇳🇴",title:"Norway"},{emoji:"🇩🇰",title:"Denmark"},{emoji:"🇫🇮",title:"Finland"},{emoji:"🇮🇪",title:"Ireland"},{emoji:"🇵🇱",title:"Poland"},{emoji:"🇨🇿",title:"Czech Republic"},{emoji:"🇸🇰",title:"Slovakia"},{emoji:"🇭🇺",title:"Hungary"},{emoji:"🇷🇴",title:"Romania"},{emoji:"🇧🇬",title:"Bulgaria"},{emoji:"🇬🇷",title:"Greece"},{emoji:"🇵🇹",title:"Portugal"},{emoji:"🇷🇺",title:"Russia"},{emoji:"🇹🇷",title:"Turkey"},{emoji:"🇨🇳",title:"China"},{emoji:"🇯🇵",title:"Japan"},{emoji:"🇰🇷",title:"South Korea"},{emoji:"🇮🇳",title:"India"},{emoji:"🇧🇷",title:"Brazil"},{emoji:"🇲🇽",title:"Mexico"},{emoji:"🇦🇷",title:"Argentina"},{emoji:"🇨🇴",title:"Colombia"},{emoji:"🇨🇱",title:"Chile"},{emoji:"🇿🇦",title:"South Africa"},{emoji:"🇪🇬",title:"Egypt"},{emoji:"🇦🇪",title:"United Arab Emirates"},{emoji:"🇮🇱",title:"Israel"},{emoji:"🇸🇦",title:"Saudi Arabia"},{emoji:"🇮🇩",title:"Indonesia"},{emoji:"🇲🇾",title:"Malaysia"},{emoji:"🇵🇭",title:"Philippines"},{emoji:"🇹🇭",title:"Thailand"},{emoji:"🇻🇳",title:"Vietnam"},{emoji:"🇸🇬",title:"Singapore"},{emoji:"🇰🇪",title:"Kenya"},{emoji:"🇳🇬",title:"Nigeria"},{emoji:"🇵🇰",title:"Pakistan"},{emoji:"🇳🇿",title:"New Zealand"},{emoji:"🇺🇦",title:"Ukraine"}],Gestures:[{emoji:"👍",title:"Thumbs Up"},{emoji:"👎",title:"Thumbs Down"},{emoji:"👌",title:"OK Hand"},{emoji:"🤞",title:"Fingers Crossed"},{emoji:"✌️",title:"Victory Hand"},{emoji:"🤟",title:"Love-You Gesture"},{emoji:"🤙",title:"Call Me Hand"},{emoji:"👋",title:"Waving Hand"},{emoji:"🖐",title:"Raised Hand"},{emoji:"✋",title:"Stop Hand"},{emoji:"🤚",title:"Raised Backhand"},{emoji:"🤲",title:"Palms Up Together"},{emoji:"👐",title:"Open Hands"},{emoji:"🙌",title:"Raising Hands"},{emoji:"🙋",title:"Person Raising Hand"},{emoji:"🙋‍♂️",title:"Man Raising Hand"},{emoji:"🙋‍♀️",title:"Woman Raising Hand"},{emoji:"👈",title:"Backhand Index Pointing Left"},{emoji:"👉",title:"Backhand Index Pointing Right"},{emoji:"👆",title:"Backhand Index Pointing Up"},{emoji:"👇",title:"Backhand Index Pointing Down"},{emoji:"🤚",title:"Raised Backhand"},{emoji:"🖖",title:"Vulcan Salute"},{emoji:"🤜",title:"Right-Facing Fist"},{emoji:"🤛",title:"Left-Facing Fist"},{emoji:"🖐",title:"Five Fingers Raised"},{emoji:"🖖",title:"Vulcan Salute"},{emoji:"✋🏼",title:"Stop Hand Light Skin Tone"},{emoji:"✋🏽",title:"Stop Hand Medium Skin Tone"},{emoji:"✋🏾",title:"Stop Hand Medium-Dark Skin Tone"},{emoji:"✋🏿",title:"Stop Hand Dark Skin Tone"},{emoji:"👌🏼",title:"OK Hand Light Skin Tone"},{emoji:"👌🏽",title:"OK Hand Medium Skin Tone"},{emoji:"👌🏾",title:"OK Hand Medium-Dark Skin Tone"},{emoji:"👌🏿",title:"OK Hand Dark Skin Tone"},{emoji:"🤟🏼",title:"Love-You Gesture Light Skin Tone"},{emoji:"🤟🏽",title:"Love-You Gesture Medium Skin Tone"},{emoji:"🤟🏾",title:"Love-You Gesture Medium-Dark Skin Tone"},{emoji:"🤟🏿",title:"Love-You Gesture Dark Skin Tone"},{emoji:"✋🏻",title:"Stop Hand Light Skin Tone"},{emoji:"👋🏻",title:"Waving Hand Light Skin Tone"},{emoji:"👋🏼",title:"Waving Hand Medium-Light Skin Tone"},{emoji:"👋🏽",title:"Waving Hand Medium Skin Tone"},{emoji:"👋🏾",title:"Waving Hand Medium-Dark Skin Tone"},{emoji:"👋🏿",title:"Waving Hand Dark Skin Tone"},{emoji:"🖐🏻",title:"Raised Hand Light Skin Tone"},{emoji:"🖐🏼",title:"Raised Hand Medium-Light Skin Tone"},{emoji:"🖐🏽",title:"Raised Hand Medium Skin Tone"},{emoji:"🤲🏾",title:"Palms Up Together Medium-Dark Skin Tone"},{emoji:"🤲🏿",title:"Palms Up Together Dark Skin Tone"}]};let s="General";const d={General:"💡",Productivity:"✅",Motivation:"🎯","Smile Faces":"😀",People:"👨‍💻","Food & Drink":"🍎",Symbols:"✨",Flags:"🏳️",Gestures:"👍"};function c(e){s=e;const a=r.querySelector(".active");a&&a.classList.remove("active"),r.querySelector(`[title='${e}']`).classList.add("active"),function(e){n.innerHTML="",l[e].forEach((e=>{const a=document.createElement("div");a.classList.add("option"),a.innerHTML=`<span title="${e.title}" class='emoji'>${e.emoji}</span>`,a.addEventListener("click",(function(){o.setAttribute("value",e.emoji),i.style.display="none",t(e.emoji,e.title)})),n.appendChild(a)}))}(e)}const m=a.offset(e);i.style.left=m.left+"px",i.style.top=m.top-a.$.editableElement.scrollTop+e.offsetHeight+5+"px",i.style.display="block",setTimeout((()=>{a._adjustPopupBounds(i)}),100),r.innerHTML="",Object.keys(l).forEach((e=>{const t=document.createElement("div");t.classList.add("tab"),t.innerHTML=`${d[e]}`,t.setAttribute("title",e),t.addEventListener("click",(()=>c(e))),r.appendChild(t)})),c(s)}_createDatePopup(e,t){const a=this;a._datePopup&&a._datePopup.remove();const o=document.createElement("div");a._datePopup=o,o.classList.add("dropdown","smart-editor-date-popup"),o.innerHTML="\n ";const i=o;document.body.appendChild(o);const n=a.offset(e);i.style.left=n.left+"px",i.style.top=n.top-a.$.editableElement.scrollTop+e.offsetHeight+5+"px",i.style.display="block",setTimeout((()=>{a._adjustPopupBounds(i)}),100);const r=document.createElement("smart-calendar");r.onchange=e=>{t(e.detail.value)},i.appendChild(r)}_refreshPageLabels(){let e=[...this.querySelectorAll(".smart-editor-tab")];[...this.querySelectorAll(".smart-editor-page-label")].forEach((t=>{const a=t.getAttribute("data-id");if(a){const o=parseInt(a);e[o]&&(t.textContent=e[o].textContent.trim())}}))}_setEditorValue(e,t){const a=this;if(e){if(t.innerHTML=e,a.enablePages){const t=a.pages[a.pageIndex];t&&(t.innerHTML=e)}t.whenRendered((()=>{t._initEditorBlocks(),t._refreshEditorBlockPlaceholder(),t._editorBlocks=t.$.editableElement.querySelectorAll(".smart-editor-block"),t._setSortable(),t._currentBlock=t.querySelector(".smart-editor-block"),a._refreshTasks();const e=document.createRange(),o=window.getSelection();t.$.editableElement.lastChild&&(e.setStartAfter(t.$.editableElement.lastChild),e.collapse(!0),o.removeAllRanges(),o.addRange(e)),a._refreshPageLabels()}))}else t.whenRendered((()=>{t.value||t._createEditorBlock(!1,!1,"&nbsp;")}))}_createAIPopup(e,t,a){const o=this;o._aiPopup&&o._aiPopup.remove();const i=document.createElement("div");o._aiPopup=i,i.classList.add("dropdown","smart-editor-ai-popup"),i.innerHTML="\n ";const n=i;document.body.appendChild(i);const r=o.offset(e);n.style.left=r.left+"px",n.style.top=r.top-o.$.editableElement.scrollTop+e.offsetHeight+5+"px",n.style.display="block";let l=[{label:"Outline",value:"Generate an outline about"},{label:"Email",value:"Write an email about"},{label:"Meeting Agenda",value:"Create a meeting agenda for"},{label:"Blog Post",value:"Write a blog post about"},{label:"Social Media Post",value:"Write a social media post about"},{label:"Press Release",value:"Write a press release about"},{label:"Job Description",value:"Write a job description for"},{label:"Website Copy",value:"Write website copy for"}];t&&(l=[]);let s="";for(let e=0;e<l.length;e++)s+=`<button class="smart-editor-predefined-btn" data-click="${l[e].value}">${l[e].label}</button>`;n.innerHTML=` <div class="smart-editor-container">\n <span class="button-close"></span>\n <div class="smart-editor-input-container">\n <input type="text" id="userPrompt" class="smart-editor-input" placeholder="${o.localize("typePrompt")}" />\n <button class="smart-editor-submit-btn" onclick="getAIResponse()">Ask AI <span class="smart-editor-icon-arrow-up">↑</span></button>\n </div>\n\n <div id="aiResult" class="smart-editor-result-box">\n \x3c!-- AI response will appear here --\x3e\n </div>\n <div id="timeoutMessage" class="smart-editor-timeout-message"></div>\n\n <div class="smart-editor-header"><span class="smart-editor-ai-icon"></span>Draft</div>\n\n \x3c!-- Predefined list buttons --\x3e\n <div class="smart-editor-predefined-container">\n ${s}\n </div>\n\n \x3c!-- Modal Popup for AI response --\x3e\n <button id="keepButton" class="smart-editor-keep-btn" onclick="keepResponse()">${o.localize("keep")}</button>\n <button id="replaceButton" class="smart-editor-replace-btn secondary" onclick="keepResponse()">${o.localize("replace")}</button>\n </div>`;const d=n.querySelector("#userPrompt"),c=n.querySelector("#aiResult"),m=n.querySelector("#timeoutMessage"),u=n.querySelector(".smart-editor-submit-btn"),p=document.querySelector("#keepButton"),b=document.querySelector("#replaceButton"),h=n.querySelector(".smart-editor-header"),g=n.querySelector(".button-close"),f=(()=>{let e=window.getSelection();return e.rangeCount?e.getRangeAt(0).toString():""})();if(t){h.classList.add("smart-hidden"),d.parentElement.classList.add("smart-hidden"),d.value='"'+f+'"',p.textContent=o.localize("insertBelow");const e=[{label:o.localize("editSelection","Edit Selection"),value:"category"},{label:o.localize("rewrite","Rewrite"),value:"rewrite",description:o.localize("rewriteDescription","Rewrite the selected text")},{label:o.localize("continueWriting","Continue writing"),value:"continue_writing",description:o.localize("continueWritingDescription","Extend the content further")},{label:o.localize("fixSpellingGrammar","Fix spelling & grammar"),value:"fix_spelling_grammar",description:o.localize("fixSpellingGrammarDescription","Correct spelling and grammatical errors")},{label:o.localize("summarize","Summarize"),value:"summarize",description:o.localize("summarizeDescription","Generate a concise summary of the text")},{label:o.localize("makeShorter","Make shorter"),value:"make_shorter",description:o.localize("makeShorterDescription","Reduce the length of the text while maintaining meaning")},{label:o.localize("makeLonger","Make longer"),value:"make_longer",description:o.localize("makeLongerDescription","Expand the text with more details")},{label:o.localize("explain","Explain"),value:"explain",description:o.localize("explainDescription","Provide a clearer or more detailed explanation")},{label:o.localize("changeTone","Change Tone"),value:"category"},{label:o.localize("concise","Concise"),value:"concise",description:o.localize("conciseDescription","Make the text more brief and to the point")},{label:o.localize("professional","Professional"),value:"professional",description:o.localize("professionalDescription","Adjust the text to sound more formal and business-like")},{label:o.localize("casual","Casual"),value:"casual",description:o.localize("casualDescription","Make the text sound more relaxed and friendly")},{label:o.localize("funny","Funny"),value:"funny",description:o.localize("funnyDescription","Add humor or a lighthearted tone to the text")},{label:o.localize("translate","Translate"),value:"category"},{label:o.localize("translateEnglish","Translate to English"),value:"translate_english",description:o.localize("translateEnglishDescription","Translate the text into English")},{label:o.localize("translateSpanish","Translate to Spanish"),value:"translate_spanish",description:o.localize("translateSpanishDescription","Translate the text into Spanish")},{label:o.localize("translatePortuguese","Translate to Portuguese"),value:"translate_portuguese",description:o.localize("translatePortugueseDescription","Translate the text into Portuguese")},{label:o.localize("translateItalian","Translate to Italian"),value:"translate_italian",description:o.localize("translateItalianDescription","Translate the text into Italian")},{label:o.localize("translateDutch","Translate to Dutch"),value:"translate_dutch",description:o.localize("translateDutchDescription","Translate the text into Dutch")},{label:o.localize("translateChinese","Translate to Chinese"),value:"translate_chinese",description:o.localize("translateChineseDescription","Translate the text into Chinese")},{label:o.localize("translateKorean","Translate to Korean"),value:"translate_korean",description:o.localize("translateKoreanDescription","Translate the text into Korean")},{label:o.localize("translateJapanese","Translate to Japanese"),value:"translate_japanese",description:o.localize("translateJapaneseDescription","Translate the text into Japanese")},{label:o.localize("translateRussian","Translate to Russian"),value:"translate_russian",description:o.localize("translateRussianDescription","Translate the text into Russian")}].find((e=>e.value===t));e&&(d.value+=" - "+e.description)}else d.parentElement.style.marginTop="15px";p.classList.add("smart-hidden"),b.classList.add("smart-hidden"),p.id="",b.id="",u.id="",m.id="",c.id="",d.id="",d.onkeydown=e=>{"Enter"===e.key&&(u.disabled||u.click())},t||setTimeout((()=>{d.focus()}),50),n.querySelectorAll(".smart-editor-predefined-btn").forEach((e=>{e.onclick=()=>{var t;t=e.getAttribute("data-click"),d.value=t,m.innerHTML="",d.focus()}})),b.onclick=()=>{o._aiPopup.remove(),delete o._aiPopup,a(c.innerHTML,!0)},g.onclick=()=>{o._aiPopup.remove(),delete o._aiPopup},p.onclick=()=>{o._aiPopup.remove(),delete o._aiPopup,a(c.innerHTML)},u.onclick=()=>{if(""===d.value.trim())return;c.innerHTML="",m.innerHTML="",u.disabled=!0,c.innerHTML='<div class="smart-editor-loading"><div class="smart-editor-spinner"></div>'+o.localize("processing")+"</div>";const e=setTimeout((()=>{c.innerHTML="",m.innerHTML="Sorry, the request timed out. Please try again.",u.disabled=!1}),1e4);(()=>{const a=o.ai.url,i=o.ai.key;let n=""+d.value;n?async function(e){if(e+=t?", respond in formatted HTML.":". Return the result as formatted HTML.",o._limit||(o._limit=0),o._limit++,o._limit>o.ai.limit)return"Sorry, the limit for AI prompts has been reached.";const n=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({model:o.ai.model,messages:[{role:"user",content:e}],max_tokens:o.ai.maxTokens,temperature:o.ai.temperature})});if(!n.ok)throw new Error(`Error: ${n.statusText}`);return(await n.json()).choices[0].message.content.trim()}(n).then((a=>{clearTimeout(e),a=a.replace(/^"|"$/g,""),c.innerHTML=a,m.innerHTML="",u.disabled=!1,p.classList.remove("smart-hidden"),t&&b.classList.remove("smart-hidden")})).catch((t=>{clearTimeout(e),console.error("Error:",t),c.innerHTML="",m.innerHTML="Sorry, the request timed out. Please try again.",p.classList.add("smart-hidden"),b.classList.add("smart-hidden"),u.disabled=!1})):(c.innerHTML="",m.innerHTML="",u.disabled=!1,p.classList.add("smart-hidden"),b.classList.add("smart-hidden"))})()},setTimeout((()=>{o._adjustPopupBounds(n)}),100),t&&u.click()}_refreshTasks(){const e=this,t=e.$.editableElement.querySelectorAll(".smart-editor-task-box");t.forEach((t=>{e._renderTask(t)})),0===t.length&&e.$.editableElement.querySelectorAll("[data-task]").forEach((t=>{if(!t.classList.contains("smart-editor-task-box")){const a=e.users&&e.users.length?'<span class="user-icon">🧑‍💼</span><span class="user-label">&nbsp;</span>':'<span hidden class="user-icon">🧑‍💼</span><span hidden class="user-label">&nbsp;</span>',o=`\n <span title="Idea" class="task-icon">◻️</span><input placeholder="${e.localize("taskPlaceholder")}" value="${t.textContent.trim()}" class="label"></input><span hidden class="text">${t.textContent.trim()}</span><span class="due-date-icon">📅</span><span class="date-label">&nbsp;</span><span class="priority-icon">⚪</span>\n ${a}<span class="delete-icon"></span><span class="plus-icon"></span>`;t.innerHTML=o,t.classList.add("smart-editor-block"),t.setAttribute("data-block",""),t.classList.add("smart-editor-task-box")}e._renderTask(t)}))}_createTask(){const e=this;e._disableNewBlock||e.$.contentContainer.dispatchEvent(new KeyboardEvent("keydown",{key:"Enter"}));const t=e.users&&e.users.length?'<span class="user-icon">🧑‍💼</span><span class="user-label">&nbsp;</span>':'<span hidden class="user-icon">🧑‍💼</span><span hidden class="user-label">&nbsp;</span>',a=`<div data-task class="smart-editor-task-box task" contenteditable="false">\n<span title="Idea" class="task-icon">◻️</span><input placeholder="${e.localize("taskPlaceholder")}" class="label"></input><span hidden class="text"></span><span class="due-date-icon">📅</span><span class="date-label">&nbsp;</span><span class="priority-icon">⚪</span>\n${t}<span class="delete-icon"></span><span class="plus-icon"></span></div><div empty class="smart-editor-block">&nbsp;</div>`,o=e._currentBlock;if(o)return o.innerHTML=a,o.removeAttribute("empty"),o.removeAttribute("data-placeholder"),e._renderTask(o),delete e._filterSortableMenuInput,delete e._currentBlock,e._closeContextMenu(),o}_renderTask(e){const t=this,a=e.querySelector("input"),o=e.querySelector(".text");o.onpointerdown=()=>{a.hidden=!1,a.value=o.textContent,o.hidden=!0,setTimeout((()=>{a.focus()}),25)};const i=()=>{!function(a){const i=document.createElement("style");i.textContent='\n .smart-text-editor-tooltip {\n position: absolute;\n background-color: rgba(50, 50, 50, 0.9);\n color: #fff;\n font-size: 12px;\n text-align: left;\n padding: 4px 8px;\n border-radius: 4px;\n opacity: 0;\n transition: opacity 0.1s ease-in-out;\n white-space: nowrap;\n pointer-events: none;\n box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);\n max-width: 300px;\n z-index:999999;\n overflow: hidden;\n }\n .smart-text-editor-tooltip::after {\n content: "";\n position: absolute;\n bottom: -6px;\n left: 50%;\n transform: translateX(-50%);\n border-width: 6px;\n border-style: solid;\n border-color: rgba(50, 50, 50, 0.9) transparent transparent transparent;\n }\n ',document.head.appendChild(i);let n=null;t._taskTooltip?n=t._taskTooltip:(n=document.createElement("div"),t._taskTooltip=n,n.className="smart-text-editor-tooltip",document.body.appendChild(n)),a.onmouseenter=function(a){const i=e.querySelector(".due-date-icon"),r=e.querySelector(".task-icon"),l=e.querySelector(".user-icon"),s=e.querySelector(".priority-icon");let d="";const c=e=>{if(e&&e.hasAttribute("data-title")){const a=e.getAttribute("data-title");if(a===t.localize("taskPlaceholder"))return;d+="<div>"+a+"</div>"}};if(c(o),c(r),c(s),c(i),c(l),d){n.innerHTML=d,n.style.left=`${a.pageX+8}px`;const o=t.$.editableElement.scrollTop;n.style.top=t.offset(e).top-o+e.offsetHeight+8+"px",n.style.opacity=1}},a.onmouseleave=function(){n.style.opacity=0}}(e)},n=e=>{const a=e.target.parentElement.querySelector("input");if(a.hidden=!1,a.focus(),a.value=o.textContent,a.parentElement.nextElementSibling){const e=a.parentElement.nextElementSibling;e&&e.classList.contains("smart-editor-block")&&e.remove(),a.value||(a.value=t.localize("taskPlaceholder"))}t._currentBlock=t._createEditorBlock(e.altKey,!1),t._disableNewBlock=!0;const i=t._createTask();delete t._disableNewBlock;const n=a.closest(".smart-editor-block");if(n&&n.nextElementSibling&&n.nextElementSibling.querySelector(".smart-editor-task-box")){const e=i.querySelector(".smart-editor-block");e&&i.nextElementSibling&&e.remove()}t._editorBlocks=t.$.editableElement.querySelectorAll(".smart-editor-block"),a.hidden=!0,o.hidden=!1,e.stopPropagation(),e.preventDefault()};a.onblur=a.onchange=()=>{a.value&&(a.hidden=!0,o.hidden=!1),i()},a.onkeydown=e=>{"Enter"===e.key&&n(e),e.stopPropagation(),o.textContent=a.value,o.setAttribute("data-title","📄"+o.textContent)},a.oninput=e=>{e.stopPropagation(),o.textContent=a.value,o.setAttribute("data-title","📄"+o.textContent)},a.onkeyup=e=>{o.setAttribute("data-title","📄"+o.textContent),e.stopPropagation()};const r=(t,a,o,i,n)=>{const r=a.find((e=>""+e.value==""+i));if(t.textContent=r.icon,o?t.setAttribute("data-title",r.label):t.setAttribute("data-title",r.icon+" "+r.label),n){const t=e.querySelector("[data-task]");t&&(t.setAttribute(n,r.value),t.setAttribute(n+"-label",r.label))}},l=(e,a,o,n)=>{const l=e.target,s=t._openContextMenu(e,a,!0,o,l);s.callback=e=>(r(l,a,o,e,n),delete s.callback,!0),i(),e.stopPropagation(),e.preventDefault()};e.querySelector(".plus-icon").onpointerdown=e=>{n(e)},e.querySelector(".due-date-icon").onpointerdown=a=>{const o=a.target;t._createDatePopup(o,(a=>{const n=new Smart.Utilities.DateTime(a[0]);o.textContent="⏰",o.setAttribute("data-title","⏰ "+n.toString("MMMM dd, yyyy")),e.setAttribute("data-due",n.toString("yyyy-MM-dd")),t._setSelectionRange(o,1,1),t._datePopup.remove(),i()})),a.stopPropagation(),a.preventDefault()},e.querySelector(".task-icon").onpointerdown=e=>{l(e,[{label:"◻️ None",value:"none",icon:"◻️"},{label:"📝 To Do",value:"toDo",icon:"📝"},{label:"🔄 In Progress",value:"inProgress",icon:"🔄"},{label:"✅ Done",value:"done",icon:"✅"}],"smart-editor-task-menu","data-status")};const s=()=>[{label:"None",value:"none",image:"🧑",icon:"🧑"},...t.users].map((e=>({label:e.label||e.name,id:e.value||e.id,value:e.value||e.id,image:e.image,icon:"🧑‍💻"})));if(e.querySelector(".user-icon").onpointerdown=e=>{l(e,s(),"","data-user")},e.querySelector(".priority-icon").onpointerdown=e=>{l(e,[{label:"⚪ No Priority",value:"noPriority",icon:"⚪"},{label:"🟢 Low Priority",value:"lowPriority",icon:"🟢"},{label:"🟡 Medium Priority",value:"mediumPriority",icon:"🟡"},{label:"🔴 High Priority",value:"highPriority",icon:"🔴"}],"smart-editor-task-menu","data-priority")},e.querySelector(".delete-icon").onpointerdown=e=>{const t=e.target.closest(".smart-editor-task-box");t&&t.remove()},t.users&&t.users.length?e.querySelector(".user-icon").hidden=!1:e.querySelector(".user-icon").hidden=!0,e.hasAttribute("data-status")){const t=e.getAttribute("data-status");[{label:"◻️ None",value:"none",icon:"◻️"},{label:"📝 To Do",value:"toDo",icon:"📝"},{label:"🔄 In Progress",value:"inProgress",icon:"🔄"},{label:"✅ Done",value:"done",icon:"✅"}].forEach((a=>{(a.value===t||a.label.indexOf(t)>=0)&&r(e.querySelector(".task-icon"),[{label:"◻️ None",value:"none",icon:"◻️"},{label:"📝 To Do",value:"toDo",icon:"📝"},{label:"🔄 In Progress",value:"inProgress",icon:"🔄"},{label:"✅ Done",value:"done",icon:"✅"}],"smart-editor-task-menu",a.value,"data-status")}))}if(e.hasAttribute("data-priority")){const t=e.getAttribute("data-priority");[{label:"⚪ No Priority",value:"noPriority",icon:"⚪"},{label:"🟢 Low Priority",value:"lowPriority",icon:"🟢"},{label:"🟡 Medium Priority",value:"mediumPriority",icon:"🟡"},{label:"🔴 High Priority",value:"highPriority",icon:"🔴"}].forEach((a=>{(a.value===t||a.label.indexOf(t)>=0)&&r(e.querySelector(".priority-icon"),[{label:"⚪ No Priority",value:"noPriority",icon:"⚪"},{label:"🟢 Low Priority",value:"lowPriority",icon:"🟢"},{label:"🟡 Medium Priority",value:"mediumPriority",icon:"🟡"},{label:"🔴 High Priority",value:"highPriority",icon:"🔴"}],"smart-editor-task-menu",a.value,"data-priority")}))}if(e.hasAttribute("data-user")){const t=e.getAttribute("data-user");s().forEach((a=>{(a.value===t||a.label.indexOf(t)>=0)&&r(e.querySelector(".user-icon"),s(),"smart-editor-task-menu",a.value,"data-priority")}))}if(e.hasAttribute("data-due-date")){const t=e.getAttribute("data-due-date"),a=new Smart.Utilities.DateTime(t),o=e.querySelector(".due-date-icon");o.textContent="⏰",o.setAttribute("data-title","⏰ "+a.toString("MMMM dd, yyyy")),e.setAttribute("data-due",a.toString("yyyy-MM-dd")),i()}i(),e.querySelector("input").focus()}_renderSortableMenu(e,t,a){const o=this,i=o._currentBlock;o._renderSortableMenuTimer&&clearTimeout(o._renderSortableMenuTimer),o._renderSortableMenuTimer=setTimeout((()=>{let n=document.createElement("input");n.isInline=a,n.style.borderWidth="0px",n.style.outline="none",n.style.width="auto",n.style.backgroundColor="var(--smart-surface)",n.style.color="var(--smart-background-color)",n.style.fontSize="inherit",n.style.fontFamily="inherit";const r=e=>{const t=document.createElement("span");t.textContent=e.value||e.placeholder||" ",t.style.minWidth="30px",t.classList.add("smart-element"),t.style.position="absolute",e._measureStyle||(e._measureStyle=getComputedStyle(e)),t.style.fontSize=e._measureStyle.fontSize,t.style.fontFamily=e._measureStyle.fontFamily,t.style.fontWeight=e._measureStyle.fontWeight,document.body.appendChild(t),e.style.width=t.offsetWidth+10+"px",t.remove()};if(t&&o._filterSortableMenuInput)n=o._filterSortableMenuInput;else{n.style.display="none",n.autoAdjustWidth=!0,n.placeholder=o.localize("typeToFilter"),n.style.setProperty("--smart-background","var(--smart-surface)"),n.style.setProperty("--smart-editor-label-padding","0px");const e=o.offset(i);if(a){n.value="/"+o.localize("typeToFilter");let e=window.getSelection();if(!e.rangeCount)return;let t=e.getRangeAt(0);t.deleteContents(),t.insertNode(n),t.setStartAfter(n),t.setEndAfter(n),e.removeAllRanges(),e.addRange(t)}else n.style.height="20px",n.style.position="absolute",n.style.top=e.top+"px",n.style.left=e.left+"px",document.body.appendChild(n);n.style.borderLeftWidth=n.style.borderRightWidth=n.style.borderTopWidth=n.style.borderBottomWidth="0px",o._filterSortableMenuInput=n,o._filterSortableMenuInput.block=i,setTimeout((()=>{n.focus(),a&&(n.selectionStart=n.selectionEnd=1)}),100)}n.style.maxHeight="30px",i?(n.style.height=n.style.lineHeight=i.offsetHeight+"px",n.style.display="",i.removeAttribute("empty"),i.removeAttribute("data-placeholder")):n.style.display="";const l=o._getSortableMenuItems(),s=o._openContextMenu(e,l,!0,"smart-editor-add-menu",n),[d,c]=o._refreshSortableMenuItems(s);r(n),n.oninput=()=>{r(n)},n.onkeyup=e=>{const t=e.key;if("ArrowUp"===e.key||"ArrowDown"===e.key||"Enter"===e.key||"Escape"===e.key)return;if("Enter"!==t&&"Escape"!==t||(e.stopPropagation(),e.preventDefault()),n.value==="/"+o.localize("typeToFilter"))return;const a=n.value.startsWith("/")?n.value.substring(1).toLowerCase():n.value.toLowerCase();let i=!1;c.classList.add("smart-hidden"),d.forEach((function(e){e.getAttribute("label").toLowerCase().includes(a)||""===a?(e.classList.remove("smart-hidden"),i=!0):e.classList.add("smart-hidden"),e.removeAttribute("selected"),s.style.height="auto"})),d[s.active].classList.contains("smart-hidden")&&(d[s.active].removeAttribute("selected"),s.active=0,d[s.active].setAttribute("selected",""));const r=Array.from(s.querySelectorAll(".smart-editor-context-menu-item:not(.smart-hidden)"));0!==r.length&&r[s.active]&&r[s.active].setAttribute("selected","");const l=o.offset(n);l.top-o.$.editableElement.scrollTop+n.offsetHeight+5+s.offsetHeight>window.innerHeight?s.style.top=l.top-o.$.editableElement.scrollTop-n.offsetHeight+5-s.offsetHeight+"px":s.style.top=l.top-o.$.editableElement.scrollTop+n.offsetHeight+5+"px",i||(c.classList.remove("smart-hidden"),void 0!==n.noResultChars?n.noResultChars++:n.noResultChars=0,n.noResultChars>=3&&(n.dispatchEvent(new KeyboardEvent("keydown",{key:"Enter"})),delete n.noResultChars))},n.setValue=(t,r)=>{if(r)switch(delete o._filterSortableMenuInput,r.name||(r.name=r.value),r.name){case"text":break;case"user":return o._currentBlock?o._closeContextMenu():o.$.contentContainer.dispatchEvent(new KeyboardEvent("keydown",{key:"Enter"})),o.$.contentContainer.dispatchEvent(new KeyboardEvent("keydown",{key:"@"})),void n.remove();case"formats":{!o._currentBlock||o._currentBlock&&""!==o._currentBlock.textContent.trim()?o.$.contentContainer.dispatchEvent(new KeyboardEvent("keydown",{key:"Enter"})):o._closeContextMenu();const e=o._createInsertionMarker();let t=o._getSelectionRange();const a=o._currentBlock;""===o._currentBlock.textContent.trim()&&(o._currentBlock.innerHTML=""),a.appendChild(e),a.removeAttribute("empty"),a.removeAttribute("data-placeholder"),o.selectRange(t);const i=o.$.editableElement.getRootNode().querySelector("#INSERTION_MARKER");if(!i)return;i.innerHTML="&nbsp;",i.removeAttribute("id"),o._setSelectionRange(i),t=o._getSelectionRange(),t.collapse();const l=document.createElement(r.value);return l.innerHTML="",l.setAttribute("data-placeholder",r.label),l.setAttribute("empty",""),l.classList.add("smart-editor-format-block"),l.setAttribute("contenteditable",""),i.parentElement.insertBefore(l,i),i.remove(),void n.remove()}case"divider":{o.$.contentContainer.dispatchEvent(new KeyboardEvent("keydown",{key:"Enter"}));const e=o._currentBlock;e.removeAttribute("empty"),e.removeAttribute("data-placeholder");const t=document.createElement("div");return t.classList.add("smart-editor-divider-block"),t.setAttribute("contenteditable",""),t.style.borderTopColor="var(--smart-border)",t.style.borderTopStyle="solid",t.style.borderTopWidth="1px",t.style.marginTop=t.style.marginBottom="10px",e.appendChild(t),o._setSelectionRange(t),o._getSelectionRange().collapse(),o.$.contentContainer.dispatchEvent(new KeyboardEvent("keydown",{key:"Enter"})),void n.remove()}case"twoColumns":case"threeColumns":case"fourColumns":{o.$.contentContainer.dispatchEvent(new KeyboardEvent("keydown",{key:"Enter"}));const e=o._currentBlock;e.removeAttribute("empty"),e.removeAttribute("data-placeholder"),e.classList.add("smart-editor-two-columns"),e.setAttribute("data-block-2","");const t=o._createEditorBlock(!1,!1),a=o._createEditorBlock(!1,!1);if(t.setAttribute("data-placeholder","Column 1"),a.setAttribute("data-placeholder","Column 2"),t.setAttribute("empty",""),a.setAttribute("empty",""),t.classList.add("smart-editor-n-columns-block"),a.classList.add("smart-editor-n-columns-block"),t.setAttribute("data-block-n",""),a.setAttribute("data-block-n",""),e.appendChild(t),e.appendChild(a),"threeColumns"===r.name){e.classList.add("smart-editor-three-columns");const t=o._createEditorBlock(!1,!1);t.setAttribute("data-placeholder","Column 3"),t.setAttribute("empty",""),t.classList.add("smart-editor-n-columns-block"),e.appendChild(t)}if("fourColumns"===r.name){e.classList.add("smart-editor-four-columns");const t=o._createEditorBlock(!1,!1);t.setAttribute("data-placeholder","Column 4"),t.setAttribute("empty",""),t.classList.add("smart-editor-n-columns-block"),e.appendChild(t)}const i=document.createElement("span");return i.innerHTML="&nbsp;",e.appendChild(i),o._setSelectionRange(t,0,0),void n.remove()}case"table":{!o._currentBlock||o._currentBlock&&""!==o._currentBlock.textContent.trim()?o.$.contentContainer.dispatchEvent(new KeyboardEvent("keydown",{key:"Enter"})):o._closeContextMenu();const e=o._createInsertionMarker();let t=o._getSelectionRange();const a=o._currentBlock;a.appendChild(e),a.removeAttribute("empty"),a.removeAttribute("data-placeholder"),o.selectRange(t);const i=o.$.editableElement.getRootNode().querySelector("#INSERTION_MARKER");i.innerHTML="&nbsp;",i.removeAttribute("id"),o._setSelectionRange(i),t=o._getSelectionRange(),t.collapse();const l=document.createElement(r.value);return l.innerHTML="<tr><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr>",l.setAttribute("data-placeholder",r.label),l.setAttribute("empty",""),l.classList.add("smart-editor-table-block"),l.setAttribute("contenteditable",""),i.parentElement.insertBefore(l,i),i.remove(),void n.remove()}case"togglelist":{const e=`<div class="editable-list expanded" contenteditable="true">\n<span class="toggle-icon"></span><label>${o.localize("toggleList")}</label>\n<div class="nested">\n <ul>\n <li>Child 1</li>\n <li>Child 2</li>\n </ul>\n</div>\n</div>`;o.$.contentContainer.dispatchEvent(new KeyboardEvent("keydown",{key:"Enter"}));const t=document.createRange(),a=window.getSelection(),i=o._currentBlock;i.innerHTML=e,i.removeAttribute("empty"),i.removeAttribute("data-placeholder"),t.setStart(i.querySelector(".toggle-icon").nextSibling,0),t.collapse(!0),a.removeAllRanges(),a.addRange(t),n.remove(),delete o._filterSortableMenuInput,delete o._currentBlock,o._closeContextMenu();let l=o.$.toolbar.querySelector('.smart-editor-toolbar-item[item-name="'+r.name+'"]');return l||(l={type:r.name,name:r.name}),void(l&&(o._handleToolbarItemDown(l),o._handleToolbarUp(l)))}case"checklist":case"unorderedlist":case"orderedlist":{o.preventInsertBlock=!0,o.$.contentContainer.dispatchEvent(new KeyboardEvent("keydown",{key:"Enter"}));const e=document.createRange(),t=window.getSelection(),a=o._currentBlock;a.innerHTML="&nbsp;",e.setStart(a,0),e.collapse(!0),t.removeAllRanges(),t.addRange(e),n.remove(),delete o._filterSortableMenuInput,delete o._currentBlock,o._closeContextMenu();let i=o.$.toolbar.querySelector('.smart-editor-toolbar-item[item-name="'+r.name+'"]');return i||(i={type:r.name,name:r.name}),i&&(o._handleToolbarItemDown(i),o._handleToolbarUp(i)),void delete o.preventInsertBlock}case"callout":{const e='<div class="smart-editor-callout-box callout" contenteditable="true">\n<span title="Idea" class="callout-icon">💡</span><span>&nbsp;</span>\n</div>';o.$.contentContainer.dispatchEvent(new KeyboardEvent("keydown",{key:"Enter"}));const t=document.createRange(),a=window.getSelection(),i=o._currentBlock;return i.innerHTML=e,n.remove(),i.removeAttribute("empty"),i.removeAttribute("data-placeholder"),t.setStart(i.querySelector(".callout-icon").nextSibling,0),t.collapse(!0),a.removeAllRanges(),a.addRange(t),delete o._filterSortableMenuInput,delete o._currentBlock,void o._closeContextMenu()}case"task":return n.remove(),void o._createTask();case"emoji":{const e=o._createInsertionMarker();let a=o._getSelectionRange();n.nextSibling?n.parentElement.insertBefore(e,n.nextSibling):n.parentElement.appendChild(e),o.selectRange(a);const i=o.$.editableElement.getRootNode().querySelector("#INSERTION_MARKER");i.innerHTML=t,i.removeAttribute("id"),o._setSelectionRange(i),a=o._getSelectionRange(),a.collapse();const r=document.createElement("span");return r.classList.add("callout"),r.innerHTML='<span title="Warm Smile" class="callout-icon">😊</span>&nbsp;',i.parentElement.insertBefore(r,i),i.remove(),o._createCallout(r.firstElementChild,((e,t)=>{r.firstElementChild.textContent=e,r.firstElementChild.title=t,o._setSelectionRange(r,1,1)})),delete o._filterSortableMenuInput,delete o._currentBlock,n.remove(),void o._closeContextMenu()}case"ai":{const e=o._createInsertionMarker();let a=o._getSelectionRange();n.nextSibling?n.parentElement.insertBefore(e,n.nextSibling):n.parentElement.appendChild(e),o.selectRange(a);const i=o.$.editableElement.getRootNode().querySelector("#INSERTION_MARKER");i.innerHTML=t,i.removeAttribute("id"),o._setSelectionRange(i),a=o._getSelectionRange(),a.collapse();const r=document.createElement("span");return r.classList.add("callout"),r.innerHTML='<span class="ai-label">&nbsp;</span>',i.parentElement.insertBefore(r,i),i.remove(),o._createAIPopup(r.firstElementChild,!1,(e=>{r.classList.add("smart-editor-block");let t=document.createElement("div");t.innerHTML=e;let a=[],i=!1,n="";t.querySelectorAll("[disabled]").forEach((e=>{e.removeAttribute("disabled")})),t.childNodes.forEach((e=>{if(3===e.nodeType){let t=e.textContent.trim();t&&a.push(`<div data-block-id="${Smart.Utilities.Core.createGUID()}" class="smart-editor-block">${t}</div>`)}else"UL"===e.tagName||"OL"===e.tagName?a.push(`<div data-block-id="${Smart.Utilities.Core.createGUID()}" class="smart-editor-block">${e.outerHTML}</div>`):"LI"===e.tagName?(i||(n='<div data-block-id="${Smart.Utilities.Core.createGUID()}" class="smart-editor-block"><ul>',i=!0),n+=`<li>${e.innerHTML}</li>`):e.tagName.match(/^H[1-6]$/)?a.push(`<div data-block-id="${Smart.Utilities.Core.createGUID()}" class="smart-editor-block">${e.outerHTML}</div>`):"P"===e.tagName?(e.textContent.split("\n").forEach((e=>{a.push(`<div data-block-id="${Smart.Utilities.Core.createGUID()}" class="smart-editor-block">${e}</div>`)})),e.remove()):("BLOCKQUOTE"===e.tagName||e.tagName,a.push(`<div data-block-id="${Smart.Utilities.Core.createGUID()}" class="smart-editor-block">${e.outerHTML}</div>`))})),i&&(n+=i?"</ul></div>":"</ol></div>",a.push(n));const l=window.getSelection();l&&l.anchorNode&&l.anchorNode.classList&&l.anchorNode.classList.contains("smart-editor-block")&&""===l.anchorNode.textContent&&l.anchorNode.remove(),o._createEditorBlock(!1,!1,a.join("")),o._editorBlocks=o.$.editableElement.querySelectorAll(".smart-editor-block"),o._setSelectionRange(r,1,1),o._aiPopup&&o._aiPopup.remove()})),delete o._filterSortableMenuInput,delete o._currentBlock,n.remove(),void o._closeContextMenu()}case"page":{const t=o._createInsertionMarker();return n.nextSibling?n.parentElement.insertBefore(t,n.nextSibling):n.parentElement.appendChild(t),setTimeout((()=>{const t=o._getCaretCoordinates(o.$.editableElement);e.pageX=t.x+15,e.pageY=t.y;let a=[...o.querySelectorAll(".smart-editor-tab")];o.owner&&(a=[...o.owner.querySelectorAll(".smart-editor-tab")]),a=a.map(((e,t)=>({label:e.textContent.trim(),value:"pageLink",id:t}))),o._openContextMenu(e,a,!0)}),50),delete o._filterSortableMenuInput,delete o._currentBlock,n.remove(),void o._closeContextMenu()}case"date":{const e=o._createInsertionMarker();let a=o._getSelectionRange();n.nextSibling?n.parentElement.insertBefore(e,n.nextSibling):n.parentElement.appendChild(e),o.selectRange(a);const i=o.$.editableElement.getRootNode().querySelector("#INSERTION_MARKER");i.innerHTML=t,i.removeAttribute("id"),o._setSelectionRange(i),a=o._getSelectionRange(),a.collapse();const r=document.createElement("span");return r.classList.add("callout"),r.innerHTML='<span class="date-icon">📅</span><span class="date-label">&nbsp;</span>',i.parentElement.insertBefore(r,i),i.remove(),o._createDatePopup(r.firstElementChild,(e=>{const t=new Smart.Utilities.DateTime(e[0]);r.lastElementChild.textContent=t.toString("MMMM dd, yyyy"),o._setSelectionRange(r,1,1),o._datePopup.remove()})),delete o._filterSortableMenuInput,delete o._currentBlock,n.remove(),void o._closeContextMenu()}case"image":case"file":case"video":{const e=document.createElement("div");return e.classList.add("smart-editor-toolbar-item"),e.setAttribute("item-name",r.name),e.setAttribute("item-type","button"),e.setAttribute("title",r.label),o._handleToolbarItemDown(e),o._handleToolbarUp(e),void n.remove()}case"hyperlink":{n.remove();const e=o.$.toolbar.querySelector('.smart-editor-toolbar-item[item-name="'+r.name+'"]');return void(e&&(o._handleToolbarItemDown(e),o._handleToolbarUp(e)))}default:{n.remove();const e=o.$.toolbar.querySelector('.smart-editor-toolbar-item[item-name="'+r.name+'"]');e&&(o._handleToolbarItemDown(e),o._handleToolbarUp(e));break}}if(a){const e=o._createInsertionMarker();let a=o._getSelectionRange();n.nextSibling?n.parentElement.insertBefore(e,n.nextSibling):n.parentElement.appendChild(e),o.selectRange(a);const i=o.$.editableElement.getRootNode().querySelector("#INSERTION_MARKER");i.innerHTML=t,i.removeAttribute("id"),o._setSelectionRange(i),a=o._getSelectionRange(),a.collapse();const r=document.createTextNode(t);i.parentElement.insertBefore(r,i),i.remove()}else i.innerHTML=t;i&&(i.removeAttribute("empty"),i.removeAttribute("data-placeholder"));const l=document.createRange(),s=window.getSelection();n.remove(),delete o._filterSortableMenuInput,delete o._currentBlock,a||(l.setStart(i.childNodes[0],t.length),l.collapse(!0),s.removeAllRanges(),s.addRange(l)),o._closeContextMenu()},n.onkeydown=e=>{let t=e.key;if(a&&n.value==="/"+o.localize("typeToFilter")&&(n.value="/"),"Backspace"===t&&(""!==n.value&&"/"!==n.value||(n.value="",t="Enter")),"Enter"===t||"Escape"===t){const t=s.querySelectorAll(".smart-editor-context-menu-item");let a="";for(let e=0;e<t.length;e++)if(t[e].hasAttribute("selected")&&!t[e].classList.contains("smart-hidden")){const o=t[e],i=o.getAttribute("value"),r=o.getAttribute("name"),l=o.getAttribute("label");"/"===n.value&&(n.value=""),a={name:r,label:l,value:i};break}let o=n.value;n.setValue(o,a),e.preventDefault(),e.stopPropagation()}"ArrowDown"===t&&(s.handleKeyDown(e),e.preventDefault(),e.stopPropagation()),"ArrowUp"===t&&(s.handleKeyDown(e),e.preventDefault(),e.stopPropagation()),e.stopPropagation()}}),0)}_getCurrentWord(e=0){const t=window.getSelection();if(!t||0===t.rangeCount)return"";let a=t.focusNode,o=t.focusOffset;if(a.nodeType!==Node.TEXT_NODE){if(!(a.childNodes.length>0))return"";if(a=a.childNodes[o]||a,a.nodeType!==Node.TEXT_NODE)return""}const i=a.textContent.slice(0,o+e).match(/(\w+)$/);return i?i[1]:""}_getCurrentTwoWords(){const e=window.getSelection();if(!e.rangeCount)return;const t=e.getRangeAt(0),a=t.startContainer,o=t.startOffset;return a.nodeType===Node.TEXT_NODE?a.textContent.slice(0,o).trim().split(/\s+/).slice(-2).join(" "):null}_setDictionary(){this._dictionary=window.Smart.WordsDictionary,this._collocations=["good morning","dear customer","good evening","good night","thank you","you are welcome","excuse me","I am sorry","take care","see you","good luck","best regards","best wishes","make sure","find out","let me","give me","take a","come back","go ahead","hold on","sit down","stand up","wake up","look at","listen to","pay attention","run away","turn off","turn on","high quality","low cost","big deal","fast food","strong coffee","hard work","easy way","long time","short term","real life","good idea","bad news","hot water","cold drink","heavy rain","annual report","business plan","market value","profit margin","stock market","cash flow","interest rate","sales team","customer service","supply chain","brand awareness","artificial intelligence","machine learning","data science","social media","search engine","user interface","web development","cyber security","cloud computing","software update","next week","last year","this time","right now","every day","few minutes","long time","next day","earlier today","yesterday evening","make money","take care","give advice","set goals","lose weight","save time","spend time","tell stories","break rules","follow orders","raise questions","face challenges","gain experience","keep in mind","get better","stay safe","find solutions","have fun","public transport","human rights","social responsibility","foreign policy","higher education","climate change","book an appointment","political issues","economic growth","health care","electric vehicle","medical treatment","project deadline","project management","task management","team collaboration","meeting agenda","time tracking","resource allocation","project scope","stakeholder engagement","action plan","progress report","deliverable timeline","workflow optimization","risk assessment","status update","goal setting","milestone tracking","budget planning","strategic planning","quality assurance","work breakdown","task delegation","process improvement","feedback loop","decision making","daily standup","sprint planning","agile methodology","Kanban board","task prioritization","performance evaluation","team alignment","work efficiency","meeting notes","timeline adjustment","task dependencies","scope creep","cross functional","on time delivery","client feedback","communication strategy","schedule adherence","action items","risk mitigation","workload balance","effort estimation","knowledge sharing","stakeholder communication","version control","resource planning","status report","collaboration tools","mark a date","Thank you very much","I appreciate your time","Let me know","Feel free to contact me","Looking forward to your response","Kind regards","Have a great day","Hope this helps","Please find attached","As soon as possible","At your earliest convenience","I would like to","We are pleased to","We are writing to","It would be great if","Just a quick reminder","Thanks for reaching out","Let’s touch base","We need to discuss","Keep me posted","I’ll get back to you","Circle back later","Put it on the agenda","Take it offline","Reach out to the team","On the same page","Move forward with this","Set up a call","Schedule a meeting","Run the numbers","Draft a proposal","Close the loop","Follow up on this","Touch base with you","Loop me in","Send over the details","set a reminder","schedule an appointment","check the calendar","save the date","plan an event","add to the calendar","book a slot","pick a date","set a deadline","choose a time","reserve a date","time slot availability","confirm the booking","sync calendars","change the date","share the calendar","view calendar","update the calendar","open the calendar","employee engagement","workplace culture","performance review","talent acquisition","employee retention","human capital","compensation package","benefit plan","training program","staff development","employee satisfaction","job satisfaction","leadership development","diversity inclusion","recruitment strategy","onboarding process","job description","career progression","team building","workplace diversity","employee recognition","conflict resolution","internal communication","staff turnover","organizational culture","hr policies","hr strategy","staff motivation","employee performance","talent management","workplace wellness","salary negotiation","employment law","team dynamics","job interview","workforce planning","brand strategy","market research","content marketing","social media","customer acquisition","customer retention","advertising campaign","digital marketing","email marketing","target audience","customer journey","sales funnel","marketing automation","lead generation","search engine optimization","pay per click","search engine marketing","influencer marketing","affiliate marketing","market segmentation","buyer persona","conversion rate","value proposition","content strategy","data analytics","brand awareness","product launch","marketing budget","public relations","creative strategy","customer feedback","product positioning","brand identity","website optimization","social engagement","event marketing","video marketing","marketing campaign","advertising strategy","ecommerce marketing","customer insights","digital advertising","content creation","media planning","marketing research","brand loyalty","viral marketing","online presence","marketing performance","customer experience","make a decision","take a break","do homework","catch a cold","have a look","give a speech","pay attention","keep a secret","break the law","set the table","do business","save time","spend money","lose weight","gain weight","make progress","run a business","meet a deadline","break a promise","keep a promise","make an effort","take a risk","make money","earn a living","reach a conclusion","raise awareness","offer assistance","take advantage","give up","take a shower","have a party","make friends","give an explanation","pay a visit","take notes","give an example","do research","make a mistake","take a chance","save energy","lose control","raise a question","catch a glimpse","make an appointment","have an effect","pay the price","take action","give advice","take responsibility","make a complaint","take care","pay a compliment","have a conversation","break the news","come to an agreement","make a call","take a decision","pay a bill","catch the bus","make a reservation","take a seat","give a hand","save money","lose interest","come to a conclusion","take a nap","have a meal","make a suggestion","pay attention to","take part","give permission","save face","lose patience","make an impression","come to a decision","take a photo","have a good time","make a difference","pay off","take place","give a gift","save the day","lose sight","make a noise","come prepared","take a walk","have a shower","make an offer","pay respects","give a try","save resources","lose track","make a plan","come to terms","take a look","have a headache","make a profit","pay attention to detail","take time off","give thanks","catch a break","make a wish","have a blast","do the dishes","make a bed","keep in touch","do exercise","have lunch","make a mess","give a kiss","take a breath","do the laundry","have dinner","make a choice","take a moment","give a hug","do the cleaning","have fun","give a chance","do the shopping","have breakfast","take a deep breath","give a call","do a favor","make a fortune","give a smile","do your best","make a scene","take a bow","do well","take charge","give notice","have an idea","make an entrance","give a warning","do damage","have a seat","take a trip","give a performance","make an announcement","give instructions","have a baby","take a deep dive","give a presentation","do the math","have a dream","take a sip","give a lecture","do the cooking","have a cry","make a promise","take a look around","give a shout","do a workout","have a chat","make a record","take a shortcut","do your hair","have a cup of tea","take a test","take the stage","do a favor for","have a word","make an impact","do a project","have a meeting","take a stand","give a discount","have a rest","make a move","give a reason","do a job","have a go","take a fall","make a fuss","take part in","do your makeup","make an impact on","take a selfie","do the ironing","have a heart-to-heart","make a phone call","take a chance on","have a quiet moment","make a commitment","take advantage of","give an opinion","have a laugh","make a joke","take advice","give credit","do your duty","have a goal","make a commitment to","take notes on","give a compliment","do the washing","have a snack","take an exam","give consent","have a try","take a minute","give feedback","do the gardening","have a heart","make a living","give a cry","have a look at","take a glance","give a thumbs up","do the paperwork","have a ride","make a remark","give a high five","take a class","do a study","have a holiday","take a detour","do your nails","have a bite","take an interest","give a ring","do the exercise","have a taste","have a word with","make arrangements","take a survey","give a round of applause","do a crossword","make a list","take a pill","make a donation","have a breakthrough","make amends","take a toll","do justice","have a sense","make a habit","give an answer","do the driving","have a question","make a statement","take measures","do your job","have an impact","give a message","do your best work","have a clear idea","make a big difference","take a risk with","give a warm welcome","have a tough time","make a toast","take a closer look","give an honest opinion","do a recap","have a conversation about","make a promise to","give a strong performance","do the heavy lifting","have a moment","make progress on","take pride in","do the right thing","have a clear mind","make an offer on","take it easy","give in","do a double take","take your time","give your best","make a mountain out of a molehill","take a step forward","give it a try","do the honors","make a decision on","give a standing ovation","do the talking","take a break from","give up hope","do your part","make a fool of oneself","have a quick look","make a decision about","take a long walk","give a clear answer","do your utmost","have a vivid imagination","make a significant impact","take a calculated risk","offer a warm welcome","lend a hand","experience difficulties","make a toast to","take a last look","give a quick glance","do a final review","have a spontaneous idea","make a remarkable discovery","take a sudden break","give a grateful nod","do a comprehensive analysis","make small talk","take a moment of silence","give a thoughtful gift","do a brief summary","have a brief conversation","make a clear decision","take a short break","do a creative project","have a creative mind","make a creative effort","take a creative approach","give a creative solution","do thorough research","have a thorough understanding","make a proper introduction","take a proper look","give a proper response","do a proper job","have a proper meal","make a careful observation","take a careful look","give careful consideration","do a careful analysis","have a careful discussion","make a wise decision","take a wise approach","give wise advice","make a wise move","have a pleasant day","make a friendly gesture","exchange friendly greetings","give a friendly smile","do a quick fix","have a quick meal","make a quick repair","take a quick shower","give a quick answer","do a rapid assessment","have a rapid response","make a rapid decision","take a swift action","give a swift reply","make a swift change","have a swift recovery","make a long-term commitment","take a long-term view","take a long drive","give a sudden shout","make a sudden change","have a sudden idea","take a sudden break","give a sudden smile","do a fun activity","take a quiet walk","give a quiet nod","give the silent treatment","have a silent moment","give a soft smile","have a soft spot","make a deep impression","give a deep sigh","do a deep clean","have a deep sleep","make a deep connection","take a deep dive into","give a deep insight","have a detailed discussion","make a detailed analysis","give full support","take full responsibility","offer a sincere apology","make a heartfelt apology","do a quick assessment","have a genuine smile","make a fresh start","take a bold step","give a warm embrace","do a regular checkup","have a successful career","make a wise investment","take a risk in","give a lasting impression","do a complete overhaul","have an open mind","make a smart choice","take an active role","give a solid performance","do a meticulous job","have a supportive network","make a bold move","take proactive measures","give a generous donation","do a careful study","have a meaningful conversation","make an informed decision","take a refreshing break","give a clear explanation","do a systematic review","have a productive day","make a strong argument","take decisive action","give constructive criticism","do extensive research","have a balanced view","make a thoughtful gesture","take effective measures","give sincere thanks","do a proper evaluation","have a clear objective","make a strategic decision","take a moment to reflect","give genuine feedback","do an honest review","have a heartfelt conversation","make a lasting impact","take the lead","give clear instructions","do an in-depth analysis","have a final word","make a notable achievement","take a firm stand","give immediate attention","do a practical demonstration","have a valuable insight","make a compelling argument","take serious action","give positive reinforcement","do an effective job","have a diverse perspective","make a creative decision","take constructive steps","give measurable results","do a quick turnaround","have a rapid recovery","make a notable contribution","take full advantage","give heartfelt support","do exceptional work","have an impressive record","make a positive impact","take a moment of reflection","give a powerful speech","do a significant task","have a successful event","make a grand entrance","take a memorable photo","give a remarkable performance","do a final check","have an engaging conversation","make a decisive move","take a confident step","give a sincere compliment","do an accurate measurement","have a thorough preparation","make a flawless presentation","take complete control","give a detailed report","do a precise calculation","have an enjoyable evening","make a smooth transition","take steady progress","give a clear perspective","do a thorough check","have a disciplined routine","make a powerful impression","take immediate action","give an insightful comment","do a creative design","have a proactive approach","make a flexible schedule","take careful steps","give a considerate response","do an innovative project","have a dynamic personality","make a logical argument","take a well-deserved break","give an enthusiastic cheer","do a friendly favor","have a cooperative spirit","make a fruitful collaboration","earn mutual respect","give respectful attention","do a rigorous test","have a profound impact","make a significant difference","take thoughtful action","give inspiring advice","do remarkable work","have a lasting legacy","make an extraordinary effort","take bold initiatives","give wholehearted support","do a groundbreaking study","have an innovative idea","make a historic achievement","take strategic risks","give transformative feedback","do pioneering work"]}_refreshToolbarPosition(){const e=this;if(e.toolbarOnFocus){e.setAttribute("popup",""),e.$.toolbar.setAttribute("popup","");const t=e.offset(e);e.$.toolbar.id=e.id+"_toolbar",document.querySelector("#"+e.$.toolbar.id)&&document.querySelector("#"+e.$.toolbar.id).remove(),document.body.appendChild(e.$.toolbar),e.$.toolbar.style.position="absolute",e.$.toolbar.style.top=t.top+1+e.offsetHeight+"px",e.$.toolbar.style.left=t.left+"px",e.$.toolbar.style.width=e.offsetWidth-5+"px",e.offsetWidth>=1e3&&(e.$.toolbar.style.width="auto"),e.$.toolbar.onchange=t=>{e._changeHandler(t)}}}_renderPages(){const e=this;if(e.enablePages){e.$.tabs.classList.remove("smart-hidden"),e.$.tabs.innerHTML='<div class="smart-editor-tabs-divider"></div>',e.pages[0]&&(e.$.editableElement.innerHTML=e.pages[0].innerHTML);const t=t=>{const a=e.$.tabs.querySelectorAll(".smart-editor-tab")[t],i=e.pages[t];a&&i&&(a.remove(),e.pages.splice(t,1)),o(t)},a=e=>Array.from(e.parentNode.querySelectorAll(".smart-editor-tab")).indexOf(e),o=t=>{const a=e.$.tabs.querySelectorAll(".smart-editor-tab")[t];if(a&&a.classList.contains("active"))return;const o=e.pages[e.pageIndex];o&&(o.innerHTML=e.getHTML()),e.pageIndex=t;let i=-1;e.toolbarOnFocus&&(e.$.tabs.querySelectorAll(".smart-editor-tab").forEach(((e,t)=>{e===a&&(i=t)})),0!==i?e.$.toolbar.classList.add("smart-hidden"):e.$.toolbar.classList.remove("smart-hidden")),e._closeInlinePopups(),e.$.tabs.querySelectorAll(".smart-editor-tab").forEach((e=>e.classList.remove("active"))),a.classList.add("active");const n=e.pages[t];if(n){const t=n.innerHTML;e.$.editableElement.innerHTML=t;const a=document.createRange(),o=window.getSelection();e.$.editableElement.lastChild&&(a.setStartAfter(e.$.editableElement.lastChild),a.collapse(!0),o.removeAllRanges(),o.addRange(a)),"blockHtml"===e.editMode&&(e._initEditorBlocks(),e._refreshEditorBlockPlaceholder(),e._editorBlocks=e.$.editableElement.querySelectorAll(".smart-editor-block"),1===e._editorBlocks.length&&(e._currentBlock=e.$.editableElement.querySelector(".smart-editor-block")))}},i=t=>{const o=e.$.tabs.querySelectorAll(".smart-editor-tab")[t],i=document.createElement("input");i.type="text",i.value=o.innerText,i.style.width=`${o.offsetWidth}px`;const n=document.createElement("span");function r(){n.innerText=i.value||"New Tab",i.style.width=`${n.offsetWidth+10}px`}n.style.position="absolute",n.style.visibility="hidden",n.style.whiteSpace="nowrap",n.style.top="-1000px",n.style.font=window.getComputedStyle(o).font,document.body.appendChild(n),i.oninput=r,i.onchange=function(){o.innerHTML=i.value||"New Tab";const t=a(o),r=e.pages[t];r&&(r.label=o.innerText),i.remove(),n.remove(),e._refreshPageLabels()},o.innerHTML="",o.appendChild(i),i.focus(),r()};if(e.$.tabs.selectTab=o,e.$.tabs.deleteTab=t,e.$.tabs.getTabIndex=a,e.$.tabs.editTab=i,0===e.pages.length){const t={label:"Page 1",innerHTML:e.getHTML()};e.pages.push(t)}let n=e.pages.map((e=>e.label));0===n.length&&n.push("Page 1"),n.forEach(((t,n)=>{const r=document.createElement("div");r.classList.add("smart-editor-tab"),r.innerText=t,0===n&&r.classList.add("active"),r.ondblclick=function(){const e=a(r);i(e)},r.onclick=function(e){const t=a(r);o(t),e.preventDefault()},e.$.tabs.appendChild(r)}));const r=document.createElement("button");e.$.plusBtn=r,e.$.plusBtn.innerHTML="+",e.$.plusBtn.classList.add("smart-editor-tab-plus"),e.$.tabs.appendChild(e.$.plusBtn),e.$.tabs.addTab=t=>{let n=e.$.tabs.querySelectorAll(".smart-editor-tab").length+1;const r=document.createElement("div");r.classList.add("smart-editor-tab"),r.innerText=t||"Page "+n,r.ondblclick=function(){const e=a(r);i(e)},r.onclick=function(e){const t=a(r);o(t),e.preventDefault()},e.$.tabs.insertBefore(r,e.$.tabs.lastElementChild);const l=e._createEditorBlock(!1,!1,"");let s="";s="blockHtml"===e.editMode?l.outerHTML:"&nbsp;";const d={label:r.innerText,innerHTML:s};e.pages.push(d),o(n-1)},e.$.plusBtn.onclick=()=>{e.$.tabs.addTab()}}else e.$.tabs.classList.add("smart-hidden")}_getContentStyle(){const e=this;return e.content_css?"<style>"+e.content_css.replaceAll("div {",".smart-editor-content div {")+"</style>":""}render(){const e=this,t=()=>0===e.offsetWidth||0===e.offsetHeight;e.content_css&&(e.innerHTML=e._getContentStyle()+e.innerHTML);const a=()=>{if(e._isMobile=Smart.Utilities.Core.isMobile,e._isFireFox=Smart.Utilities.Core.Browser.Firefox,e._isSafari=Smart.Utilities.Core.Browser.Safari,e._isMacOS=(window.navigator.platform||"").indexOf("Mac")>-1,e._handleMaxCharCount(),e._handleInputContent(),e._setToolbarVisibility(),e._handleToolbarMode(),e._handleInputElement(),e._handleEditMode(),e._predefPropertyGetter(),e._setCharCount(),e._setFocusable(),e._setAriaSettings(),e.spellCheck?e.$.editableElement.setAttribute("spellcheck",""):(e.$.editableElement.removeAttribute("spellcheck"),e.$.editableElement.spellcheck=!1),e.autoExpand&&e.expandToolbar(),e.isInitialized=!0,e.checkLicense(),e._setSortable(),e.$.input&&(e.$.input.value=e._getInputValue(e.$.editableElement.innerHTML.trim())),"blockHtml"===e.editMode){let t=e.innerHTML;if(""===t&&(t="&nbsp;"),0===e.querySelectorAll("[data-block]").length){if("blockHtml"===e.editMode){const a=e._createEditorBlock(!1,!1,t);a.setAttribute("empty",""),e.innerHTML=e.value=t=a.outerHTML}e._handleInputContent("innerHTML",t),"blockHtml"===e.editMode?(e._initEditorBlocks(),e._refreshEditorBlockPlaceholder(),e._editorBlocks=e.$.editableElement.querySelectorAll(".smart-editor-block"),1===e._editorBlocks.length&&(e._currentBlock=e.$.editableElement.querySelector(".smart-editor-block")),e._setSortable(),e._renderPages()):e._renderPages(),e._renderPages(),e._refreshTasks()}}};if(t())return requestAnimationFrame((()=>{e.isInitialized||t()?e._createInterval=setInterval((()=>{e.isInitialized||t()||(a(),e._setDictionary(),clearInterval(e._createInterval))}),100):(a(),e._setDictionary())})),void super.render();a(),e._setDictionary(),super.render()}_setSortable(){const e=this;if(e.sortable&&"blockHtml"===e.editMode){e.$.headerInsertLine&&(e.$.headerInsertLine.remove(),e.$.headerSortable.remove(),e.$.editableElement.querySelectorAll(".smart-editor-insert-line").forEach((e=>e.remove())),e.$.editableElement.querySelectorAll(".smart-editor-sortable").forEach((e=>e.remove()))),e.$.headerInsertLine=document.createElement("div"),e.$.headerSortable=document.createElement("div"),e.$.headerInsertLine.classList.add("smart-editor-insert-line"),e.$.headerSortable.classList.add("smart-editor-sortable"),e.addBlock&&e.$.editableElement.appendChild(e.$.headerInsertLine),e.$.editableElement.appendChild(e.$.headerSortable),e.setAttribute("sortable",""),e.addBlock&&(e.$.headerInsertLine.title=e.localize("addButton"),e.$.headerInsertLine.onpointerdown=t=>{e.$.headerInsertLine.item&&e._setSelectionRange(e.$.headerInsertLine.item.item,0,0);let a=e._getSelectionRange().endContainer;for(;a&&(!a.classList||!a.classList.contains("smart-editor-block"));)a=a.parentElement;e._currentBlock=a;const o=e._currentBlock&&e._currentBlock.hasAttribute("empty");a=o?e._currentBlock:e._createEditorBlock(t.altKey,!1),e._currentBlock=a,e._renderSortableMenu(t,o,!0),t.preventDefault(),t.stopPropagation()});const t=function(){const e=document.createElement("div");return e.classList.add("smart-editor-drag-line","smart-hidden"),e};e._blockDragDetails={},e.$.headerSortable.onpointerdown=function(a){e._blockDragDetails&&e._blockDragDetails.line&&e._blockDragDetails.line.remove();const o=t();e.$.editableElement.appendChild(o),e._blockDragDetails={line:o,x:a.pageX,y:a.pageY},e._blockDragDetails.items=[],e.$.editableElement.querySelectorAll(".smart-editor-block").forEach((t=>{const a=t.offsetHeight,o=e.offset(t).top;e._blockDragDetails.items.push({item:t,top:o,bottom:o+a})}))},e.$.headerSortable.onpointermove=function(t){if(e._blockDragDetails&&e._blockDragDetails.line){if(e._blockDragDetails.dragging)return;if(Math.abs(t.pageX-e._blockDragDetails.x)>=1||Math.abs(t.pageY-e._blockDragDetails.y>=1)){const a=e._blockDragDetails.items,o=e.offset(e.$.editableElement),i=e.$.editableElement.scrollTop;a.forEach(((n,r)=>{n.top-i+2<t.pageY&&t.pageY<n.bottom-i-2?(e._blockDragDetails.line.style.top=n.top-o.top-i+"px",e._blockDragDetails.dragItem=n,e._blockDragDetails.dragging=!0,t.preventDefault(),t.stopPropagation()):r===a.length-1&&t.pageY>n.bottom-i&&(e._blockDragDetails.line.style.top=n.bottom-o.top-i+"px",e._blockDragDetails.dragItem=n,e._blockDragDetails.dragging=!0,t.preventDefault(),t.stopPropagation())})),e._blockDragDetails.line.classList.remove("smart-hidden")}}}}}detached(){const e=this;super.detached(),delete e._dragDetails,delete e._resizeFrameObj,delete e._toolbarItemClick,e._endInlineToolbarClick(),e._closeWindow(),e._closeToolbarItemDropDown(e.$.inputPopup),e._closeToolbarItemDropDown(e.$.colorInputPopup),e._closeContextMenu(),e._closeToolbar(),e._taskTooltip&&e._taskTooltip.remove(),e.toolbarOnFocus&&document.querySelector("#"+e.$.toolbar.id)&&document.querySelector("#"+e.$.toolbar.id).remove(),e._handleTableSelection()}select(){this.focus()}focus(){const e=this,t="markdown"===e.editMode?e.$.input:e.$.editableElement;if(!t)return;t.focus();const a=document.createRange(),o=window.getSelection();a.selectNodeContents(e.$.editableElement),e._currentBlock&&"blockHtml"===e.editMode&&e._currentBlock.parentElement===e.$.editableElement&&a.selectNodeContents(e._currentBlock),a.collapse(!1),o.removeAllRanges(),o.addRange(a),e._refreshToolbarPosition()}blur(){const e=this,t="markdown"===e.editMode?e.$.input:e.$.editableElement;t&&t.blur()}clearState(){const e=this;e.id?window.localStorage.removeItem("smartEditor"+e.id):e.warn(e.localize("noId"))}collapseToolbar(){this._toggleToolbar(!0)}disableToolbarItem(e){this._setToolbarItemAttr(e,"disabled",!0)}enableToolbarItem(e){this._setToolbarItemAttr(e,"disabled",!1)}expandToolbar(){this._toggleToolbar()}executeCommand(e,t){const a=this,o=a._getCurrentValue();a.$.editableElement.focus();const i=a.$.editableElement.getRootNode().execCommand(e,!1,t),n=a._getCurrentValue();return a.$.fireEvent("change",{value:n,oldValue:o}),i}exportData(e,t){this._handleDataExport(e,t)}importData(e,t){"string"==typeof e&&(e={url:e}),t||(t={}),this._ajax(e,t)}fullScreenMode(e){const t=this;t.$.fireEvent("actionStart",{name:"fullScreenMode"}).defaultPrevented||(t._handleFullScreenMode(t._toggleItem("fullscreen",e)),t.$.fireEvent("actionEnd",{name:"fullScreenMode"}))}getCharCount(){const e=this;if("html"===e.editMode||"blockHtml"===e.editMode){const t=e.$.editableElement,a=t.textContent.length,o=t.innerText.length;return o&&a?o:0}return e.$.input.value.length}getSelection(){const e=this.$.iframe;let t,a;return e?(t=e.contentDocument,a=e.contentWindow):(t=document,a=window),new function(e){var t={initialize:function(e){this.document=e},getSelection:function(){return this.document.getSelection?this.document.getSelection():this.document.selection},getRange:function(){var e=this.getSelection();if(!e)return null;try{return e.rangeCount>0?e.getRangeAt(0):this.document.createRange?this.document.createRange():this.document.selection.createRange()}catch(e){return this.document.body.createTextRange()}},selectRange:function(e){if(e.select)e.select();else{var t=this.getSelection();t.addRange&&(t.removeAllRanges(),t.addRange(e))}},selectNode:function(e,t){var a=this.getRange(),o=this.getSelection();if(a.moveToElementText)a.moveToElementText(e),a.select();else if(o.addRange)try{t?a.selectNodeContents(e):a.selectNode(e),o.removeAllRanges(),o.addRange(a)}catch(e){}else o.setBaseAndExtent(e,0,e,1);return e},isCollapsed:function(){var e=this.getRange();return!e.item&&(0==e.boundingWidth||this.getSelection().isCollapsed)},collapse:function(e){var t=this.getRange(),a=this.getSelection();t.select?(t.collapse(e),t.select()):e?a.collapseToStart():a.collapseToEnd()},getContent:function(){var t=this.getRange(),a=e.createElement("div");return this.isCollapsed()?"":t.cloneContents?(a.appendChild(t.cloneContents()),a.innerHTML):null!=t.item||null!=t.htmlText?t.item?t.item(0).outerHTML:t.htmlText:t.toString()},getText:function(){var e=this.getRange(),t=this.getSelection();return this.isCollapsed()?"":e.text||(t.toString?t.toString():"")},getNode:function(){var t=this.getRange();if(!$.smart.browser.msie||$.smart.browser.version>=9){var a=null;if(t)for(a=t.commonAncestorContainer,t.collapsed||t.startContainer==t.endContainer&&t.startOffset-t.endOffset<2&&t.startContainer.hasChildNodes()&&(a=t.startContainer.childNodes[t.startOffset]);"element"!=typeof a;)a=a.parentNode;return e.id(a)}return e.id(t.item?t.item(0):t.parentElement())},insertContent:function(e){var t=this.getRange();if(t.pasteHTML)t.pasteHTML(e),t.collapse(!1),t.select();else if(t.insertNode)if(t.deleteContents(),t.createContextualFragment)t.insertNode(t.createContextualFragment(e));else{var a=this.document,o=a.createDocumentFragment(),i=a.createElement("div");o.appendChild(i),i.outerHTML=e,t.insertNode(o)}}};return t.initialize(e),t}(t)}getSelectionRange(){return this._selectionRange}clearContent(){const e=this;e._setResizeFrame(),e.$.editableElement.innerHTML=e.$.input.value=""}setHTML(e){this._setEditorValue(e,this)}getHTML(){const e=this;if("markdown"===e.editMode){const t=e.$.input;return window.marked?window.marked(t.value):t.value}{const t=document.createElement("div");return t.innerHTML=e.$.editableElement.innerHTML,e._autoSuggest&&e._autoSuggest.parentNode&&e._autoSuggest.remove(),"blockHtml"===e.editMode&&(t.querySelectorAll(".smart-editor-insert-line").forEach((e=>e.remove())),t.querySelectorAll(".smart-editor-sortable").forEach((e=>e.remove())),t.querySelectorAll(".smart-editor-block").forEach((e=>{e.removeAttribute("data-block-id"),e.removeAttribute("class"),e.removeAttribute("contenteditable")})),t.querySelectorAll(".smart-editor-page").forEach((e=>{e.removeAttribute("data-block-id"),e.removeAttribute("class"),e.removeAttribute("contenteditable")}))),t.innerHTML}}getText(){const e=this;return"markdown"===e.editMode?e.$.input.value:e.$.editableElement.textContent}loadState(e){const t=this;t.id?(e||(e=window.localStorage.getItem("smartEditor"+t.id)),"string"==typeof e&&(t.set("value",e),t.$.editableElement.innerHTML=t.$.input.value=e)):t.warn(t.localize("noId"))}showMessage(e,t){const a=this;if(!e||!a.isRendered)return;if(!Smart.Toast)return void a.error(a.localize("missingReference",{elementType:a.nodeName.toLowerCase(),methodName:"showMessage",files:"smart.toast.js"}));a._setToast();const o=a.$.toast;if(o){let i;if("object"==typeof t)for(let e in t)"iconType"===e?i=t[e]:o[e]=t[e];if(!a.$.container.contains(o)){const e=a.$toast;a._toastVisibilityHandler||(a._toastVisibilityHandler=e=>{const t=e.type;"close"===e.type&&e.detail.instance===a._requiredMessage&&delete a._requiredMessage,e.stopPropagation(),a.$.fireEvent("message"+t.slice(0,1).toUpperCase()+t.slice(1),e.detail)},e.listen("open",a._toastVisibilityHandler),e.listen("close",a._toastVisibilityHandler)),a.$.container.appendChild(o)}return o.open(e+"",i)}}_isAllContentSelected(){const e=this.$.editableElement,t=window.getSelection();if(!t.rangeCount)return!1;const a=t.toString().replace(/\s+/g," ").trim(),o=e.innerText.replace(/\s+/g," ").trim();return a===o&&o.length>0}hideMessage(e){const t=this.$.toast;t&&(void 0===e?t.closeAll():t.closeItem(e))}hideLastMessage(){const e=this.$.toast;e&&e.closeLast()}selectAll(){this._selectAll()}selectRange(e,t){const a=this,o=a.$.editableElement.getRootNode();if(!o)return;e=parseInt(e),t=parseInt(t),e=Math.min(e,t),t=Math.max(e,t);const i=a.$.input,n=a.$.editableElement,r="markdown"===a.editMode||a.$.editableElement.classList.contains("smart-hidden")?i:n,l=a.$.iframe,[s,d]=l?[l.contentWindow,l.contentDocument]:[window,document],c=s.getSelection();let m=o.activeElement;if((!m||m!==i&&m!==n||m.classList.contains("smart-hidden"))&&(r.focus(),m=r),c.removeAllRanges(),delete a._selectionRange,!isNaN(e)&&!isNaN(t)&&e!==t){if(m===i)i.setSelectionRange(e,t),a._selectionRange={selectionStart:e,selectionEnd:t};else{const o=a._getNodes(n,e,t).nodes;for(let e=0,t=o.length;e<t;e+=1){const{node:t,index:i,startIndex:n}=o[e],r=d.createRange();t.nodeType===Node.TEXT_NODE?(r.setStart(t,Math.max(0,n)),r.setEnd(t,Math.min(i,t.nodeValue.length))):r.selectNodeContents(t),c.addRange(r),a._selectionRange=r}}a._updateToolbarItems()}}saveState(){const e=this;e.id?window.localStorage.setItem("smartEditor"+e.id,e.$.editableElement.innerHTML):e.warn(e.localize("noId"))}splitMode(e){const t=this;t.$.fireEvent("actionStart",{name:"splitMode"}).defaultPrevented||(t._handleSplitMode(t._toggleItem("splitmode",e)),t.$.fireEvent("actionEnd",{name:"splitMode"}))}previewMode(e){const t=this;t.$.contentContainer.hasAttribute("split-mode")||t.$.fireEvent("actionStart",{name:"sourcecode"}).defaultPrevented||(t._handleSourceCodeMode(t._toggleItem("sourcecode",e)),t.$.fireEvent("actionEnd",{name:"sourcecode"}))}print(){this._handlePrint()}updateToolbarItem(e,t){const a=this,o=a.toolbarItems;let i;if("string"==typeof e?i=o.find((t=>t.name===e)):"number"==typeof e&&(i=o[e]),i){a._closePopups(),a._closeWindow(),delete a._toolbarItemsObj[i.name],delete a._inlineToolbarItemsObj[i.name];for(let e in t)i[e]=t[e];return a._refreshToolbarItems(a._getToolbarItems()),!0}}_toggleItem(e,t){const a=this._toolbarItemsObj;if(!a)return;const o=a[e],i=this.$.toolbar.querySelector(`.smart-editor-toolbar-item[item-name="${e}"]`);return o&&i?((t=o.value=void 0===t?!o.value:!!t)?(i.setAttribute("checked",""),i.setAttribute("aria-pressed",!0)):(i.removeAttribute("checked"),i.setAttribute("aria-pressed",!1)),i):void 0}_ajax(e,t={}){const a=this;let o="GET",i=e.url,n=null,r=!0;if(e.type&&(o=e.type),e.data)if("GET"===o){i+="?";for(let t in e.data)Object.prototype.hasOwnProperty.call(e.data,t)&&(i+=encodeURI(t+"="+e.data[t]+"&"));"&"===i.charAt(i.length-1)&&(i=i.slice(0,i.length-1))}else"POST"===o&&(n=JSON.stringify(e.data));t&&!1===t.async&&(r=!1),void 0!==window.fetch&&r?a._ajaxFetch(e,t,o,i,n):a._ajaxXMLHttpRequest(e,t,o,i,n,r)}_ajaxFetch(e,t,a,o,i){const n=this,r={method:a};let l,s,d;t&&t.contentType&&(r.headers=new Headers({"Content-Type":t.contentType})),null!==i&&(r.body=i),e.timeout&&(s=setTimeout((function(){d=!0}),e.timeout)),t.beforeSend&&!1===t.beforeSend(r,t)||fetch(o,r).then((function(e){if(d)throw l=408,n.error(n.localize("timeout",{elementType:n.nodeName.toLowerCase()}));if(s&&clearTimeout(s),l=e.status,!e.ok)throw n.error(n.localize("importError",{elementType:n.nodeName.toLowerCase(),status:e.statusText}));return e.text()})).then((e=>n._ajaxComplete(t,e,l))).catch((function(e){t&&t.loadError&&t.loadError(l,e)}))}_ajaxXMLHttpRequest(e,t,a,o,i,n){const r=new XMLHttpRequest,l=this;r.open(a,o,n),r.ontimeout=function(){t&&t.loadError&&t.loadError(408,"timeout")},r.onload=function(){if(4===r.readyState){const a=r.status;let o=r.response;a>=200&&a<=299?("json"===e.dataType&&(o=JSON.parse(o)),l._ajaxComplete(t,o,a)):t&&t.loadError&&t.loadError(a,o)}},r.onerror=function(){t&&t.loadError&&t.loadError(r.status,r.response)},t&&t.contentType&&r.setRequestHeader("Content-Type",t.contentType),n&&e.timeout&&(r.timeout=e.timeout),t.beforeSend&&!1===t.beforeSend(r,t)||r.send(i)}_ajaxComplete(e,t){if(e){if(e.beforeLoadComplete){const a=e.beforeLoadComplete(t);a&&(t=a)}this._handleInputContent("value",t)}}_afterInputHandler(e){const t=this,a=t._beforeInputObj,o=t.$.editableElement,i=!o.innerHTML;let n,r;if(a&&a.type&&(n=a.type,r=a.rangeDetails),delete t._beforeInputObj,t._bigramStore=function(e,t=2){const a=new Set(["the","is","and","a","to","of","in","on","for","with","at","by","an","this","that","it","as"]);let o=e.toLowerCase().replace(/[^\w\s]/g,"").split(/\s+/);o=o.filter((e=>!a.has(e)));let i={};for(let e=0;e<o.length-1;e++){let t=o[e]+" "+o[e+1];i[t]=(i[t]||0)+1}return Object.entries(i).filter((([e,a])=>a>=t)).sort(((e,t)=>t[1]-e[1])).map((e=>e[0]))}(t.$.editableElement.textContent),i&&(t._setResizeFrame(),t._closeToolbar()),"insertParagraph"===n||i){let e=t._getSelectionRange().startContainer;if(e.nodeType===Node.TEXT_NODE&&(e=e.parentElement),e&&e.classList&&(e.closest(".smart-editor-image-caption")||e.closest(".smart-editor-editable table")))return;const a=t.$.iframe,[n,r]=a?[a.contentWindow,a.contentDocument]:[window,document];("div"===n.getSelection().anchorNode.nodeName.toLowerCase()||e===o&&i)&&r.execCommand("insertHTML",!1,"<p><br></p>")}else if(n&&r&&n.indexOf("delete")>-1){const e=t._resizeFrameObj;e&&e.target&&!o.contains(e.target)&&t._setResizeFrame()}o.textContent.length&&o.innerText.length?o.removeAttribute("show-placeholder"):o.setAttribute("show-placeholder",""),t.name&&e.target===t.$.editableElement&&"markdown"!==t.editMode&&(t.$.input.value=t._getInputValue(t.$.editableElement.innerHTML.trim())),t._setCharCount()}_createInsertionMarker(){const e=this.$.editableElement.getRootNode().querySelector("#INSERTION_MARKER");e&&e.remove();const t=document.createElement("span");return t.id="INSERTION_MARKER",t.innerHTML="&nbsp;",t}_beforeInputHandler(e){const t=this,a=t.$.iframe,o=t.$.contentContainer,i=t.$.editableElement,n=(a?a.contentWindow:window).getSelection(),r=n.rangeCount>0?n.getRangeAt(0):null;if(!r)return;const l=e.inputType,s=r.startContainer;let d;if(l&&(d=l.indexOf("delete")>-1,t._beforeInputObj={type:l,rangeDetails:{startOffset:r.startOffset,endOffset:r.endOffset,startContainer:r.startContainer,endContainer:r.endContainer}}),d&&i.contains(s))if(s===r.endContainer&&r.startOffset===r.endOffset){const e=t._resizeFrameObj;let a=s;if(e&&e.target&&e.target.contains(s))return;if(a.nodeType!==Node.TEXT_NODE&&a.innerHTML.length){if(a===i)return}else{let e=a.parentElement,t=a.previousElementSibling;for(;!t&&e;)t=e.previousElementSibling,e=e.parentElement;i!==t&&i.contains(t)&&!t.innerHTML.length&&t.nodeName}}else r.deleteContents(),e.preventDefault();if(!o.classList.contains("char-count-maxed")||d){if("insertParagraph"===l){const a=t._getSelectionRange().startContainer;if(a.nodeType===Node.TEXT_NODE&&a.parentElement===i){if(-1!==t.$.editableElement.innerHTML.indexOf("<")){const a=document.createElement("p");a.innerHTML="&#8203;";const o=t._createInsertionMarker();let n=t._getSelectionRange(),r=n.endContainer;r.parentElement.insertBefore(a,n.endContainer.nextSibling),r.parentElement.insertBefore(o,a.nextSibling),t.selectRange(n);const l=i.getRootNode().querySelector("#INSERTION_MARKER");return t._setSelectionRange(l.previousElementSibling),n=t._getSelectionRange(),n.collapse(),l.remove(),e.preventDefault&&e.preventDefault(),!1}i.getRootNode().execCommand("formatBlock",!1,"p")}}}else e.preventDefault()}_changeHandler(e){const t=this,a=e.target,o=e.detail,i=a.closest(".smart-editor-toolbar-item");if(e.stopPropagation(),t._toolbarItemsObj||t._inlineToolbarItemsObj)return i&&a===t.$.inputPopup||a===t.$.colorInputPopup?(t._ignoreSelectionChange=!0,t._updateToolbarItem(i,o),void delete t._ignoreSelectionChange):void 0}_contextMenuHandler(e){const t=this,a=t.contextMenu;if("browser"!==a)if(e.preventDefault(),"none"!==a){if(e.target&&3!==e.target.nodeType&&e.target.classList.contains("smart-editor-tab")){const a=t.$.tabs.getTabIndex(e.target);if(a>0){const o=[{value:"deleteTab",id:a,label:t.localize("delete")}];return void t._openContextMenu(e,o,!0)}}t._openContextMenu(e)}else t._closeContextMenu();else t._closeContextMenu()}_closeContextMenu(){const e=this.$.inlineToolbar,t=this.$.fireEvent("dropDownToolbarClosing",{target:e}).defaultPrevented;e&&e.visible&&e.classList.contains("smart-editor-context-menu")&&!t&&e.close()}_openContextMenu(e,t,a,o,i){let n=this,r=e.target,l=n.$.inlineToolbar;if(i&&(r=i),l||(l=n._createToolbar()),l.classList.remove("smart-editor-add-menu"),l.classList.remove("smart-editor-task-menu"),l.classList.remove("smart-editor-ai-menu"),n.$.fireEvent("contextMenuOpening",{target:l}).defaultPrevented)return;l.removeAttribute("bottom"),o?(l._cssClass=o,l.classList.add(o)):l._cssClass&&(l.classList.remove(l._cssClass),delete l._cssClass),"smart-editor-ai-menu"===o&&n.toolbarOnFocus&&l.setAttribute("bottom",""),n._setupToolbar(r,"context"),l.parentElement||n.getShadowRootOrBody().appendChild(l),l.clear(),n._setContextMenuContent(r,t),l.querySelectorAll(".smart-editor-context-menu-item").forEach((e=>{e.classList.remove("smart-hidden")}));const s=n.getBoundingClientRect();if(l.style.left=Math.min(e.pageX+1,s.right+window.pageXOffset-l.offsetWidth)+"px",l.style.top=Math.min(e.pageY+1,s.bottom+window.pageYOffset-l.offsetHeight)+"px",i){const e=n.offset(i);l.style.left=e.left+"px",l.style.top=e.top-n.$.editableElement.scrollTop+i.offsetHeight+5+"px"}if(l.open(),l.style.height="",t)if(l.hasAttribute("bottom")){if(i){const e=n.offset(i);l.style.left=e.left+"px",l.style.top=e.top-n.$.editableElement.scrollTop-5-l.offsetHeight+"px"}}else setTimeout((()=>{n._adjustPopupBounds(l)}),100);return a&&n._focusContextMenu(l),l}_focusContextMenu(e){const t=this;e.tabIndex=0;let a=e.querySelector(".smart-editor-context-menu-item");const o=e.querySelectorAll(".smart-editor-context-menu-item");o.forEach(((e,t)=>{e.tabIndex=t,e.removeAttribute("selected")})),e.options=o,setTimeout((()=>{a.focus()}),50),"category"===a.getAttribute("value")&&(a=a.nextElementSibling),a.setAttribute("selected",""),e.active=0,e.handleKeyDown=a=>{switch(o.forEach((e=>{e.removeAttribute("selected")})),a.key){case"ArrowDown":{const t=Array.from(e.querySelectorAll('.smart-editor-context-menu-item:not(.smart-hidden):not([value="category"])'));e.active=Math.min(e.active+1,t.length-1),t.forEach(((t,o)=>{t.removeAttribute("selected"),o===e.active&&(t.setAttribute("selected",""),t.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})),a.stopPropagation(),a.preventDefault()}));break}case"ArrowUp":{const t=Array.from(e.querySelectorAll('.smart-editor-context-menu-item:not(.smart-hidden):not([value="category"])'));e.active=Math.max(e.active-1,0),t.forEach(((t,a)=>{t.removeAttribute("selected"),a===e.active&&(t.setAttribute("selected",""),t.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"}))})),a.stopPropagation(),a.preventDefault();break}case"Enter":case"Tab":o[e.active].click(),a.stopPropagation(),a.preventDefault();break;case"Escape":t._closeContextMenu()}},e.onkeydown=t=>{e.handleKeyDown(t)}}_setContextMenuContent(e,t){const a=this;if(!e)return;let o=a._contextList,i=a._getContextMenuTargetType(e),n=a._getContextMenuDataSource(e,i);t&&(n=t),o||(a._contextList=o=document.createElement("div"),o.classList.add("smart-editor-context-menu-item-container"));const r=document.createDocumentFragment(),l=n.length;let s=o.children;for(;s.length>l;)s[0].remove();s=Array.from(s);for(let t=0;t<l;t++){const o=n[t];let l,d,c=s[t];if("object"==typeof o?(l=o.label,d=o.value):l=d=o+"",c||(c=document.createElement("div"),c.classList.add("smart-editor-context-menu-item"),c.setAttribute("role","option")),c.removeAttribute("disabled"),"deleteLink"!==o||"image"!==i||e.closest(".smart-editor-editable a")){if("cut"===o||"copy"===o){const e=a._getSelectionRange();(void 0!==e.selectionStart?e.selectionStart:e.startOffset)===(void 0!==e.selectionEnd?e.selectionEnd:e.endOffset)&&c.setAttribute("disabled","")}}else c.setAttribute("disabled","");c.parentElement||r.appendChild(c);let m="";if(o.image){const e=o.image;m+=`<div class="user-icon smart-icon" style="${e?`background-size: 24px 24px; margin-left: -30px; margin-right: 10px; border-radius: 50%; width: 24px; height: 24px; background-image: url('${e}');`:""}"></div>`}void 0!==o.id&&c.setAttribute("id",o.id),void 0!==o.label&&c.setAttribute("label",o.label),void 0!==o.name&&c.setAttribute("name",o.name),c.innerHTML=m+a.localize(l)||l,c.removeAttribute("description"),o.description&&(c.innerHTML+=`<span class="smart-editor-context-menu-item-description">${o.description}</span>`,c.setAttribute("description",o.description)),c.setAttribute("value",d)}o.appendChild(r),a.$.inlineToolbar.appendChild(o)}_getContextMenuTargetType(e){let t;return t=e.closest(".smart-editor-editable table")?"table":e.closest(".smart-editor-editable img")?"image":e.closest(".smart-editor-video-container")?"video":e.closest(".smart-editor-file-container")?"file":e.closest(".smart-editor-editable a")?"link":"text",t}_getContextMenuDataSource(e,t){if(!t)return[];const a=this.contextMenuDataSource;let o;switch(t){case"table":o=["tableProperties","insertRowAfter","insertRowBefore","insertColumnLeft","insertColumnRight","deleteRow","deleteColumn","deleteTable","selectAll"];break;case"image":o=["imageProperties","copyImage","cutImage","createLink","deleteLink","deleteImage","caption"];break;case"video":o=["videoProperties","copyVideo","cutVideo","deleteVideo","caption"];break;case"file":o=["fileProperties","deleteFile"];break;case"link":o=["linkProperties","deleteLink","selectAll"];break;default:o=["copy","cut","paste","selectAll"]}return a&&(o="function"==typeof a?a(e,t,o):Array.isArray(a)?a:[]),o}_updateToolbarItem(e,t){const a=this,o=a.editMode,i=e.getAttribute("item-name"),n=a.$.toolbarItemsPrimary,r=a.$.toolbarItemsSecondary,l=a.$.inlineToolbar,s="markdown"===o?a.$.input:a.$.editableElement,d=(e,o,i)=>{o&&(o.label=t["alignment"===o.name?"value":"label"],o.value=t.value,e&&a._setItemValue(e,o),i&&a._updateToolbarTarget(o))};if(l&&l.contains(e)?(d(e,a._inlineToolbarItemsObj[i],!0),a._toolbarItemsObj&&a._toolbarItemsObj[i]&&d(a.$.toolbar.querySelector(`.smart-editor-toolbar-item[item-name=${i}]`),a._toolbarItemsObj[i])):(n.contains(e)||r.contains(e))&&a._toolbarItemsObj&&(d(e,a._toolbarItemsObj[i],!0),l&&l.visible&&a._inlineToolbarItemsObj&&d(l.querySelector(`.smart-editor-toolbar-item[item-name=${i}]`),a._inlineToolbarItemsObj[i])),s.getRootNode().activeElement!==s){const e=a._selectionRange,t=s.scrollTop;e&&("markdown"===o?a._setSelectionRange(s,e.selectionStart,e.selectionEnd):a._setSelectionRange(e.startContainer,e.startOffset,e.endOffset)),s.focus({preventScroll:!0}),a._isSafari&&t&&(s.scrollTop=t)}}_updateToolbarTarget(e){const t=this,a=t._resizeFrameObj;if(!e)return;const o=t.$.inlineToolbar;let i;a&&a.target?i=a.target:o&&o.visible&&(i=o.selector,i=i.closest?i.closest(".smart-editor-editable img")||i.closest(".smart-editor-editable table"):void 0);const n=i?i.nodeName.toLowerCase():"";if(i&&"img"===n)return"alignment"===e.name&&(i.closest(".smart-editor-image-container")||i).setAttribute("alignment",e.value),t._setResizeFrame(i),void(o&&o.visible&&o.reposition());if(i&&"table"===n)return void t._handleTableToolbarAction(e,i);const r=t._getSelectionRange();if(r&&(r.startContainer||void 0!==r.selectionStart)){const a=e.name;if(t.$.fireEvent("actionStart",{name:a}).defaultPrevented)return;switch(a){case"backgroundcolor":t._handleBackgroundColor(e);break;case"fontcolor":t._handleFontColor(e);break;case"alignment":t._handleTextAlignment(e);break;case"fontsize":t._handleFontSize(e);break;case"fontname":t._handleFontName(e);break;case"formats":t._handleFormats(e);break;case"paste":t._handlePaste(e);break;default:{const t=r.startContainer.closest?r.startContainer:r.startContainer.parentElement;return void(t&&t.closest&&t.setAttribute(e.name,e.value))}}a&&(t.$.fireEvent("actionEnd",{name:a}),(()=>{const e=t._changingValue,a=t.$.input,o=t.$.editableElement.getRootNode().activeElement===a?a.value:t.$.editableElement.innerHTML;void 0!==e&&o!==e&&t.$.fireEvent("changing",{value:o,oldValue:t._changingValue})})())}}_setSelectionRange(e,t,a){const o=this,i=o.$.iframe,n=o.editMode;let r;if(o.disabled)return;if("markdown"===n||o.$.editableElement.classList.contains("smart-hidden")){r=o.$.input,o._selectionRange={selectionStart:void 0!==t?t:r.selectionStart,selectionEnd:void 0!==a?a:r.selectionEnd};const e=o._selectionRange;return void(o._selectionChangeFired||r.setSelectionRange(e.selectionStart,e.selectionEnd))}const l=(i?i.contentWindow:window).getSelection();let s;if(r=o.$.editableElement,e){if(s=document.createRange(),"number"==typeof t&&"number"==typeof a)try{s.setStart(e,parseInt(t)),s.setEnd(e,parseInt(a))}catch(t){s.selectNodeContents(e)}else"img"===e.nodeName.toLowerCase()||e.classList.contains("smart-editor-video-container")?(s.setStartBefore(e),s.setEndAfter(e),s.selectNode(e)):s.selectNodeContents(e);l.removeAllRanges(),l.addRange(s)}else l.rangeCount&&(s=l.getRangeAt(0));try{s&&s.startContainer&&r.contains(s.startContainer)&&(o._selectionRange=s)}catch(e){}o._selectionRange||(s=document.createRange(),s.selectNodeContents(r),s.collapse(!0),o._selectionRange=s)}_getSelectionRange(){const e=this,t=e.editMode;let a=e._selectionRange;return a&&("markdown"===t&&void 0===a.selectionStart||"html"===t&&void 0===a.startContainer||"blockHtml"===t&&void 0===a.startContainer)&&(delete e._selectionRange,a=void 0),a||e._setSelectionRange(),e._selectionRange}_setCharCount(){const e=this,t=e.$.contentContainer;if(!e.showCharCount)return void t.removeAttribute("char-count");const a=e.maxCharCount;let o,i;if("html"===e.editMode||"blockHtml"===e.editMode){const t=e.$.editableElement,a=t.textContent.length,o=t.innerText.length;i=o&&a?o:0}else i=e.$.input.value.length;if(o=e.charCountFormatFunction?e.charCountFormatFunction(i,a)+"":a?`${i} / ${a}`:i+"",t.setAttribute("char-count",o),null===a)return void t.classList.remove("char-count-low","char-count-medium");const n=parseFloat((i/a).toFixed(2));t.classList[n>=.7&&n<=.9?"add":"remove"]("char-count-warning"),t.classList[n>=.9?"add":"remove"]("char-count-error"),t.classList[i>=a?"add":"remove"]("char-count-maxed")}_documentDownHandler(e){const t=this,a=t.$.iframe,o=t.$.inlineToolbar,i=t.$.window,n=e.originalEvent||e,r=t.shadowRoot||t.isInShadowDOM?n.composedPath()[0]:n.target;if(t.contains(document.activeElement)){const e=t.getSelectionRange();t._editorSelectionRange=e}if(o&&o.contains(r)){const e=r.closest(".smart-editor-toolbar-item");return t._handleToolbarItemDown(e,r),void n.preventDefault()}if(t.toolbarOnFocus){const e=r.closest(".smart-editor-toolbar-item");if(e&&t.$.toolbar.contains(e))return t._handleToolbarItemDown(e,r),void n.preventDefault()}if(t.$.container.contains(r)||a&&a.contentDocument.body.contains(r))return void t._handleDownInside(n,r);const l=r.closest(".smart-input-drop-down-menu");let s;if(l&&(s=l.ownerElement),i&&i.opened&&!i.contains(s||r)&&i.close(),t._handleTableSelection(),s&&(t.$.toolbarItemsPrimary.contains(s)||t.$.toolbarItemsSecondary.contains(s)||o&&o.contains(s)))return t._toolbarItemClick={},void n.preventDefault();t._setResizeFrame(),t._closePopups()}_handleDownInside(e,t){const a=this,o=e.originalEvent||e,i=t.closest(".smart-editor-toolbar-item"),n=a.$.inlineToolbar,r=t.classList.contains("smart-editor-video-container")?t:null,l=a.$.window;let s=a._editorVideoItemClick;if(s&&(r&&s.dragElement&&s.dragElement.remove(),delete a._editorVideoItemClick,s=void 0),t===a.$.toolbarToggleButton)a._toolbarItemClick={},e.preventDefault();else{if(i)return a._handleToolbarItemDown(i,t),void e.preventDefault();if(t.closest(".smart-editor-toolbar-tab"))e.preventDefault();else if(r)s||(s=a._editorVideoItemClick={target:t,originalSelectionRange:a._selectionRange}),e.preventDefault(),!1!==r.getAttribute("draggable")&&r.querySelector("video")?(s.dragElement=a._createWhiteSpaceChar(t,r),a._setSelectionRange(t)):s.dragElement&&(s.dragElement.remove(),delete s.dragElement);else if(t.closest(".smart-editor-search-bar"))a._searchBarDown={target:t},t.closest(".smart-search-input")||e.preventDefault();else{const e={x:o.pageX+window.pageXOffset,y:o.pageY+window.pageYOffset};l&&l.opened&&l.close();const i=a._getInlineToolbarTarget(t,e);if(i){const t=a.$.contentContainer;t.contains(t.getRootNode().activeElement)||a._focusEditableElement(),a._handleInlineToolbarItemDown(i,e)}else!n||n.contains(t)&&n.classList.contains("smart-editor-drop-down-toolbar")||(a._closeToolbar(),a._handleTableSelection())}}a._closeToolbarItemDropDown(a.$.inputPopup),a._closeToolbarItemDropDown(a.$.colorInputPopup)}_handleToolbarItemDown(e,t){const a=this,o=a.$.inlineToolbar,i=a.$.window;if(!e)return;const n=e.getAttribute?e.getAttribute("item-type"):e.type,r=e.getAttribute?e.getAttribute("item-name"):e.name;switch(!i||!i.opened||i._target&&i._target.item.name===r||i.close(),a._toolbarItemClick={toolbarItem:e},a._resizeFrameObj&&a._resizeFrameObj.target?a._toolbarItemClick.target=a._resizeFrameObj.target:a._setResizeFrame(),a._setSelectionRange(),n){case"button":["hyperlink","createlink","image","file","video"].includes(r)?a._toolbarItemClick.callback=a._toggleWindow:"table"===r&&(a._toolbarItemClick.callback=o&&o.contains(e)?a._toggleWindow:a._toggleDropDownToolbar);break;case"toggle":e.toggleAttribute("checked"),e.hasAttribute("checked")?e.setAttribute("aria-pressed",!0):e.setAttribute("aria-pressed",!1),a._closeToolbarItemDropDown(a.$.inputPopup),a._closeToolbarItemDropDown(a.$.colorInputPopup);break;case"drop-down":a._toolbarItemClick.callback=a._toggleItemDropDown;break;case"color-input":t.closest(".smart-editor-item-drop-down-button")&&(a._toolbarItemClick.callback=a._toggleItemDropDown)}}_handleInlineToolbarItemDown(e,t){const a=this,o=e.closest(".smart-editor-editable table"),i=a.$.editableElement;if(a._inlineToolbarClickObj&&a._inlineToolbarClickObj.target&&(a._inlineToolbarClickObj.target.removeAttribute("drag-id"),a._inlineToolbarClickObj.dragElement&&a._inlineToolbarClickObj.dragElement.removeAttribute("drag-id")),a._inlineToolbarClickObj={},e)if("img"===e.nodeName.toLowerCase())e.setAttribute("drag-id",Math.random().toString(36).substr(2,5));else if(e.classList.contains("smart-editor-video-container")){const t=e.querySelector("video, iframe");t&&(t.setAttribute("drag-id",Math.random().toString(36).substr(2,5)),a._inlineToolbarClickObj.dragElement=t)}if(o&&i.hasAttribute("table-cell-resize")){const n=i.getAttribute("table-cell-resize");a._inlineToolbarClickObj.resizeDetails={x:t.x,y:t.y,position:n,target:"vertical"===n?e.closest("tr"):e,table:o},e=void 0}a._handleTableSelection(e),a._inlineToolbarClickObj.target=e,a._inlineToolbarClickObj.dragTarget=e}_getInlineToolbarTarget(e,t){const a=this;let o,i=e.closest(".smart-editor-editable img")||e.closest(".smart-editor-editable a")||e.closest(".smart-editor-video-container");return i||(o=e.closest(".smart-editor-editable table"),o&&(i=e.closest(".smart-editor-editable td")||e.closest(".smart-editor-editable th"))),e.closest(".smart-editor-resize-frame")&&a._resizeFrameObj?(a._resizeFrameObj.resizeDetails={x:t.x,y:t.y,position:e.getAttribute("position")},i=a._resizeFrameObj.target):i&&(i&&"img"===i.nodeName.toLowerCase()||o||i.classList.contains("smart-editor-video-container"))||a._setResizeFrame(),i}_documentMoveHandler(e){const t=this,a=t._resizeFrameObj,o=t._inlineToolbarClickObj,i=e.originalEvent||e;if(a&&a.resizeDetails)t._handleFrameResize(i);else if(o&&o.resizeDetails)t._handleTableCellResize(i);else if(i&&i.target)if(t._blockDragDetails&&t._blockDragDetails.dragging){if(t._blockDragDetails.line){const e=t._blockDragDetails.items,a=t.offset(t.$.editableElement);delete t._blockDragDetails.dropItem;const o=t.$.editableElement.scrollTop;e.forEach(((n,r)=>{n.top-o<=i.pageY&&i.pageY<=n.bottom-o?(t._blockDragDetails.line.style.top=n.top-a.top-o+"px",t._blockDragDetails.dropItem=n,t._blockDragDetails.dropAbove=!0):r===e.length-1&&i.pageY>n.bottom-o&&(t._blockDragDetails.line.style.top=n.bottom-a.top-o+"px",t._blockDragDetails.dropItem=n,t._blockDragDetails.dropAbove=!1)})),t._blockDragDetails.dropItem||(i.pageY<e[0].top?(t._blockDragDetails.dropItem=e[0],t._blockDragDetails.dropAbove=!0):i.pageY>e[e.length-1].bottom&&(t._blockDragDetails.dropItem=e[e.length-1],t._blockDragDetails.dropAbove=!1))}}else{t.$.headerInsertLine&&(t.$.headerInsertLine.classList.remove("show"),t.$.headerSortable.classList.remove("show"));let e=[];(t._editorBlocks||t.$.editableElement.querySelectorAll(".smart-editor-block")).forEach((a=>{const o=a.offsetHeight,i=t.offset(a).top;e.push({item:a,top:i,height:o,bottom:i+o})})),e.forEach((e=>{const a=t.$.editableElement.scrollTop;if(e.top-a<=i.pageY&&i.pageY<=e.bottom-a){const o=t.offset(t.$.editableElement),i=e.top+e.height/2-9-a,n=e.top-a;if(!t.$.headerInsertLine)return;if(e.height<=40?(t.$.headerInsertLine.style.top=i-o.top+"px",t.$.headerSortable.style.top=i-5-o.top+"px"):(t.$.headerInsertLine.style.top=n-o.top+"px",t.$.headerSortable.style.top=n-5-o.top+"px"),t.$.headerInsertLine.item=e,t._isSelecting)return;t.$.headerInsertLine.classList.add("show"),t.$.headerSortable.classList.add("show")}}))}}_touchmoveHandler(e){const t=this,a=t._resizeFrameObj;t._isMobile&&a&&a.target&&(a.resizeDetails?(e.preventDefault(),e.stopPropagation()):(t._closeToolbar(),t._setResizeFrame()))}_dragStartHandler(e){const t=this,a=t._resizeFrameObj,o=t._inlineToolbarClickObj;if(a&&a.resizeDetails||o&&o.resizeDetails)return e.preventDefault(),void delete t._dragDetails;if(!t.$.contentContainer.contains(e.target))return;if(!o||!o.target)return void e.preventDefault();const i=t._inlineToolbarClickObj.target;if(i&&(["img","table"].indexOf(i.nodeName.toLowerCase())>-1||i.classList.contains("smart-editor-video-container"))){if("false"===i.getAttribute("draggable"))return void e.preventDefault();const a=e.target,o=a.parentElement,n=a.closest(".smart-editor-image-container");t._closeToolbar(),t._setResizeFrame(),t._dragDetails={target:a,scrollTop:t.$.editableElement.scrollTop,container:n,anchor:o&&"a"===o.nodeName.toLowerCase()?o:void 0,caption:n?n.querySelector(".smart-editor-image-caption"):void 0}}}_dropHandler(){const e=this;e._isFireFox&&e._dragEndHandler()}_dragEndHandler(){const e=this,t=e.$.inlineToolbar,a=e._dragDetails;if(a){const o=a.target,i=a.container,n=e.$.editableElement,r=n.querySelector(`[drag-id="${o.getAttribute("drag-id")}"]`);if(r){const o=a.anchor;if(r.removeAttribute("drag-id"),i&&!i.contains(r)&&r.parentElement){const e=a.caption;let t=r.parentElement;if(t.classList.contains("smart-editor-video-container")){const e=t;t=t.parentElement,e.remove(),t.appendChild(r)}i.remove(),i.innerHTML="",t.insertBefore(i,r),i.appendChild(r),e&&i.appendChild(e)}o&&r.parentElement!==o&&(o.innerHTML="",r.parentElement.insertBefore(o,r),o.appendChild(r)),void 0!==a.scrollTop&&(n.scrollTop=a.scrollTop),requestAnimationFrame((()=>e._setResizeFrame(r)));const l=e._resizeFrameObj;if(e._editorVideoItemClick){const t=n.querySelectorAll('.smart-editor-video-white-space, div[pseudo="-webkit-media-controls"]');for(let e=0,a=t.length;e<a;e+=1)t[e].remove();delete e._editorVideoItemClick}(!t||t&&!t.visible)&&l&&l.target&&e._openInlineToolbar(l.target)}return void delete e._dragDetails}e._setSelectionRange();const o=e._getSelectionRange();o&&o.startOffset!==o.endOffset&&(e._handleInlineToolbar(o.startContainer),e._focusEditableElement())}_documentUpHandler(e){const t=this,a=t._resizeFrameObj,o=t.$.inlineToolbar,i=e.originalEvent||e,n=t.shadowRoot||t.isInShadowDOM?i.composedPath()[0]:i.target;if(n&&n.classList.contains("toggle-icon")){if(i.defaultPrevented)return;return n.parentElement.classList.toggle("expanded"),i.stopPropagation(),void i.preventDefault()}if(n&&n.classList.contains("smart-editor-page-label")){const e=n.getAttribute("data-id");if(i.defaultPrevented)return;if(e){const a=t.$.tabs.querySelectorAll(".smart-editor-tab");a[parseInt(e)]&&a[parseInt(e)].click()}return i.stopPropagation(),void i.preventDefault()}if(n&&n.classList.contains("callout-icon")){if(i.defaultPrevented)return;return i.stopPropagation(),i.preventDefault(),n.parentElement.classList.toggle("expanded"),void t._createCallout(n,((e,a)=>{n.textContent=e,n.title=a,t._setSelectionRange(n,1,1)}))}if(n&&n.classList.contains("date-icon")){if(i.defaultPrevented)return;return i.stopPropagation(),i.preventDefault(),n.parentElement.classList.toggle("expanded"),void t._createDatePopup(n,(e=>{const a=new Smart.Utilities.DateTime(e[0]);n.parentElement.lastElementChild.textContent=a.toString("MMMM dd, yyyy"),t._setSelectionRange(n,1,1),t._datePopup.remove()}))}if(t._blockDragDetails&&t._blockDragDetails.line)try{if(t._blockDragDetails.dragItem&&t._blockDragDetails.dropItem){const e=t._blockDragDetails.dragItem.item,a=t._blockDragDetails.dropItem.item;t._blockDragDetails.dropAbove?a.parentElement.insertBefore(e,a):a.nextElementSibling?a.parentElement.insertBefore(e,a.nextElementSibling):a.parentElement.appendChild(e)}delete t._blockDragDetails.dragging,t._blockDragDetails.line.remove(),t._blockDragDetails.line=null,delete t._blockDragDetails}catch(e){delete t._blockDragDetails.dragging,t._blockDragDetails.line.remove(),t._blockDragDetails.line=null,delete t._blockDragDetails}if(a&&(a.resizeDetails&&a.target&&(a.target.removeAttribute("dragged"),t.$.fireEvent("resizeEnd",{target:a.target})),delete a.resizeDetails),t._dragDetails)return t._endInlineToolbarClick(),void delete t._toolbarItemClick;const r=t.$.iframe;if(t.$.container.contains(n)||o&&o.contains(n)||r&&r.contentDocument.body.contains(n)){const e=n.closest(".smart-editor-toolbar-item");e?t._handleToolbarUp(e):t._handleContentUp(i,n)}else if(t.toolbarOnFocus){const e=n.closest(".smart-editor-toolbar-item");e?t.$.toolbar.contains(e)&&t._handleToolbarUp(e):t._handleContentUp(i,n)}t._endInlineToolbarClick(),delete t._searchBarDown,delete t._dragDetails,delete t._toolbarItemClick}_handleToolbarUp(e){const t=this,a=t._toolbarItemClick,o=e.getAttribute?e.getAttribute("item-type"):e.type;if(a&&a.toolbarItem===e){const e=a.toolbarItem;"custom"!==o&&(t._handleToolbarItemClick(event,e),t._focusEditableElement())}}_handleContentUp(e,t){const a=this,o=a._inlineToolbarClickObj,i=a.$.toolbarToggleButton,n=a._editorVideoItemClick,r=void 0!==e.button&&2===e.button,l=a._isMacOS&&e.metaKey||e.ctrlKey;if(a._isControlPressed=l,r||t!==i&&!i.contains(t))if(t.classList.contains("smart-editor-toolbar-tab"))a.$.toolbar.hasAttribute("expanded")?t.hasAttribute("checked")||a._selectToolbarTab(t):(a._selectToolbarTab(t),a._toggleSecondaryToolbar(t.hasAttribute("checked")));else if(n&&t.classList.contains("smart-editor-video-container")&&t===n.target)a._setResizeFrame(t),a._focusEditableElement();else if(o){const e=o.target;e&&(e===t||e.contains(t))&&(r?a._setResizeFrame(e):a._handleInlineToolbar(e),a._focusEditableElement())}else if(t&&"LI"===t.nodeName&&t.closest("UL[checklist]")){const e=a._getSelectionRange();e&&0===e.startOffset&&0===e.endOffset&&(t.hasAttribute("checked")?t.removeAttribute("checked"):t.setAttribute("checked",""))}else if(!r&&(a.$.editableElement.contains(t)||"markdown"===a.editMode&&t===a.$.input)){const e=a.$.iframe,t=e?e.contentWindow:window;requestAnimationFrame((()=>{e&&a._setSelectionRange();const o=a._getSelectionRange();if(o instanceof t.Range){let e=o.startContainer;o.startOffset!==o.endOffset&&(a._handleInlineToolbar(e),a._focusEditableElement())}}))}else!r&&t.closest(".smart-editor-search-bar")&&a._handleSearchButtonClick(t.closest(".smart-search-button"));else a._toggleToolbar(a.$.toolbar.hasAttribute("expanded"))}_toggleSecondaryToolbar(e){const t=this,a=t.$.toolbar,o=t.$.toolbarItemsPrimary,i=t.$.toolbarItemsSecondary,n=()=>{a.hasAttribute("expanded")?(i.classList.remove("smart-drop-down"),a.contains(i)||a.appendChild(i),i.style.top=""):(i.classList.add("smart-drop-down"),a.contains(i)&&a.parentElement.insertBefore(i,a.nextElementSibling),i.style.top=o.offsetTop+o.offsetHeight+"px")};if(!e&&(i.classList.add("smart-visibility-hidden"),t.hasAnimation))return i.addEventListener("transitionend",n,{once:!0}),void i.addEventListener("transitioncancel",n,{once:!0});n(),e&&(t._setToolbarGroupHeight(),i.classList.remove("smart-visibility-hidden"))}_setToolbarGroupHeight(){const e=this.$.toolbarItemsSecondary,t=e.children;if(e.style.height="","menu"===this.toolbarMode)return;let a;for(let e=0,o=t.length;e<o;e+=1){const o=t[e].offsetHeight;(void 0===a||a<o)&&(a=o)}void 0!==a&&(e.style.height=a+"px")}_endInlineToolbarClick(){const e=this,t=e._inlineToolbarClickObj;if(t){const a=t.resizeDetails;if(!e._dragDetails&&t.target&&(t.target.removeAttribute("drag-id"),t.dragElement&&t.dragElement.removeAttribute("drag-id")),a&&a.target){if("horizontal"===a.position){const e=a.cells,t=a.table.offsetWidth;e&&e.forEach((e=>{e.style.width&&(e.style.width=100*parseFloat((e.offsetWidth/t).toFixed(2))+"%")}))}e.$.editableElement.removeAttribute("table-cell-resize"),a.target.removeAttribute("resizing"),a.isInlineToolbarOpened&&e._handleInlineToolbar(a.target)}delete e._inlineToolbarClickObj}}_updateToolbarItems(e,t){const a=this;if(a._dragDetails||a.readonly||a.disabled)return;if("markdown"===a.editMode)return void a._updateToolbarItemsMarkdown(e);const o=a._getSelectionRange(),i=a.$.inlineToolbar;let n,r;if(!o)return;if(t||(t=a.$.toolbar),i&&t!==i&&!a.hideInlineToolbar&&i.visible&&(a._updateToolbarItems(e,i),n=!0),t!==a.$.toolbar||a.hideToolbar?n||a.hideInlineToolbar||(r=a._inlineToolbarItemsObj):r=a._toolbarItemsObj,!r)return;const l=a.$.editableElement;let s,d=o.startOffset>o.endOffset?o.endContainer:o.startContainer;if(d&&(d.closest||(d=d.parentElement),d&&d.closest)){e||(e=["alignment","bold","italic","strikethrough","underline","fontsize","fontname","formats","fontcolor","backgroundcolor","orderedlist","unorderedlist","checklist","subscript","superscript"]);for(let o=0,i=e.length;o<i;o+=1){const i=e[o],n=r[i];if(n){let e;if("alignment"===i)e=d.style.textAlign;else if("bold"===i)e=!!a._getNodeFromList(d,["b","strong","h1","h2","h3","h4","h5","h6"]);else if("italic"===i)e=!!a._getNodeFromList(d,["i"]);else if("underline"===i)e=!!a._getNodeFromList(d,["u"]);else if("strikethrough"===i)e=!!a._getNodeFromList(d,["strike"]);else if("fontsize"===i){const t=d.closest(".smart-editor-editable font");t&&(e=t.style.fontSize),e||(s||(s=window.getComputedStyle(d)),e=s.fontSize),e=parseInt(e),isNaN(e)&&(e="")}else if("fontname"===i){const t=d.closest(".smart-editor-editable font");t&&t.hasAttribute("face")?e=t.getAttribute("face"):(s||(s=window.getComputedStyle(d)),e=s.fontFamily.split(",")[0])}else if("formats"===i&&d!==l){const t=n.dataSource;if(e="",t){const o=t.map((e=>e.value));e=a._getNodeFromList(d,o)||""}}else if("fontcolor"===i){const t=d.closest(".smart-editor-editable font");t?e=t.color:(s||(s=window.getComputedStyle(d)),e=s.color)}else if("backgroundcolor"===i)e=a._getNodeBackgroundColor(d),e||(s||(s=window.getComputedStyle(d)),e=s.backgroundColor);else if("orderedlist"===i||"unorderedlist"===i){e=!!d.closest(`.smart-editor-editable ${"orderedlist"===i?"ol":"ul"} li`);const t=d.closest(`.smart-editor-editable ${"orderedlist"===i?"ol":"ul"} li`);t&&t.parentElement&&t.parentElement.hasAttribute("checklist")&&(e=!1)}else if("checklist"===i){e=!!d.closest(`.smart-editor-editable ${"orderedlist"===i?"ol":"ul"} li`);const t=d.closest(`.smart-editor-editable ${"orderedlist"===i?"ol":"ul"} li`);t&&t.hasAttribute("checklist")&&(e=!0),t&&t.parentElement&&!t.parentElement.hasAttribute("checklist")&&(e=!1)}else"subscript"===i?e=!!d.closest(".smart-editor-editable sub"):"superscript"===i&&(e=!!d.closest(".smart-editor-editable sup"));if(!e&&n.dataSource){let t=n.dataSource[0];"fontcolor"===n.name&&(t=n.dataSource[n.dataSource.length-1]),"backgroundcolor"===n.name&&(t=""),t&&(e=t.value||t)}null!==e&&(n.value=e,a._setItemValue(t.querySelector(`.smart-editor-toolbar-item[item-name=${i}]`),n))}}}}_updateToolbarItemsMarkdown(e){const t=this,a=t._getSelectionRange();if(!a||void 0===a.selectionStart)return;const o=a.selectionStart;e||(e=["bold","italic","strikethrough","underline","formats","orderedlist","unorderedlist","subscript","superscript"]);for(let a=0,i=e.length;a<i;a+=1){const i=e[a],n=t._toolbarItemsObj[i];if(n){let e;if("bold"===i)e=!!t._getMarkdownItem(o,"**"),e||(e=!!t._getMarkdownItem(o,"__"));else if("italic"===i)e=!!t._getMarkdownItem(o,"*"),e||(e=!!t._getMarkdownItem(o,"_"));else if("strikethrough"===i)e=!!t._getMarkdownItem(o,"~~");else if("underline"===i)e=!!t._getMarkdownItem(o,"<ins>","</ins>");else if("formats"===i){const a=n.dataSource;if(e="",a){const i=a.map((e=>e.value));e:for(let a=0,n=i.length;a<n;a+=1)if(e=t._getMarkdownFormat(o,i[a]),e&&void 0!==e.formatName){e=e.formatName;break e}}}else"orderedlist"===i||"unorderedlist"===i?e=!!t._getMarkdownFormat(o,i):"subscript"===i?e=!!t._getMarkdownItem(o,"<sub>","</sub>"):"superscript"===i&&(e=!!t._getMarkdownItem(o,"<sup>","</sup>"));if(!e&&n.dataSource){let t=n.dataSource[0];"fontcolor"===n.name&&(t=n.dataSource[n.dataSource.length-1]),"backgroundcolor"===n.name&&(t=""),t&&(e=t.value||t)}null!==e&&(n.value=e,t._setItemValue(t.$.toolbar.querySelector(`.smart-editor-toolbar-item[item-name=${i}]`),n))}}}_getMarkdownItem(e,t,a=t){const o=this.$.input.value,i=o.lastIndexOf(t,Math.max(0,e-1)),n=o.indexOf(a,i>-1?i+t.length:e);if(!(i<0||i>e||n<0||n<e||o.slice(i,e).indexOf("\n")>-1||o.slice(e,n).indexOf("\n")>-1))return" "!==o[i+1]&&o[i-1]!==t&&o[i+1]!==t&&" "!==o[n-1]&&o[n-1]!==t&&o[n+1]!==t?{startIndex:i,endIndex:n+a.length}:void 0}_getMarkdownFormat(e,t){const a=this.$.input.value,o=a.lastIndexOf("\n",Math.max(0,e-1))+1,i=a.slice(o,e);let n;switch(t){case"h1":n="# ";break;case"h2":n="## ";break;case"h3":n="### ";break;case"h4":n="#### ";break;case"h5":n="##### ";break;case"h6":n="###### ";break;case"code":case"pre":n="```";break;case"blockquote":n="> ";break;case"orderedlist":{const e=/^\s*([0-9]+\.{1}\s+)/gs.exec(i);return e?{formatName:t,occuranceIndex:o+e.input.indexOf(e[1])}:void 0}case"unorderedlist":{const e=/^\s*([-+*]{1}\s+)/gs.exec(i);return e?{formatName:t,occuranceIndex:o+e.input.indexOf(e[1])}:void 0}default:n=t+""}const r=i.indexOf(n);if(r>=0&&r<=3&&i.slice(r,n.length)===n)return{formatName:t,occuranceIndex:o+r,markdown:n}}_getNodeFromList(e,t){const a=this.$.editableElement;if(e&&t)for(;e&&e!==a;){const a=e.nodeName.toLocaleLowerCase();if(t.indexOf(a)>-1)return a;e=e.parentElement}}_getNodeBackgroundColor(e){const t=this.$.editableElement;for(;e&&e!==t;){const t=e.style.backgroundColor;if(t)return t;e=e.parentElement}}_editableElementBlurHandler(e){const t=this,a=t.$.editableElement,o=t.$.contentContainer;if(!t._toolbarItemClick&&!o.contains(o.getRootNode().activeElement)){const i=t._value,n=()=>{o.removeAttribute("required"),t._requiredMessage&&(t.hideMessage(t._requiredMessage),delete t._requiredMessage)},r=t._getCurrentValue();if(t.required){const e=t.$.editableElement;"markdown"===t.editMode&&!t.$.input.value||"markdown"!==t.editMode&&!e.textContent&&!e.querySelectorAll("img, table").length?(o.hasAttribute("required")||o.setAttribute("required",""),t._requiredMessage||(t._requiredMessage=t.showMessage(t.localize("requiredMessage"),{autoClose:!1,iconType:"error"}))):n()}else n();if(i!==r){if(t.enablePages){const e=t.pages[t.pageIndex];e&&(e.innerHTML=r)}t.$.fireEvent("change",{oldValue:i,value:r}),t.name&&e.target===a&&"markdown"!==t.editMode&&(t.$.input.value=t._getInputValue(a.innerHTML.trim()))}t.removeAttribute("focus"),t.removeAttribute("aria-activedescendant")}t._autoSuggest&&t._autoSuggest.remove()}_editableElementFocusHandler(e){const t=this,a=t.editMode,o="markdown"===a?t.$.input:t.$.editableElement;let i=t._autoSaveObj;t.setAttribute("focus",""),e.target.id&&t.setAttribute("aria-activedescendant",e.target.id),t._value=t._getCurrentValue(),t.autoSave?(i||(i=t._autoSaveObj={}),clearInterval(i.interval),i.interval=setInterval((()=>{o.getRootNode().activeElement!==o&&clearInterval(i.interval),window.localStorage.setItem("smartEditor"+t.id,"markdown"===a?o.value:o.innerHTML)}),t.autoSaveInterval)):i&&(clearInterval(i.interval),delete t._autoSaveObj)}_inputChangeEvent(e){e.stopPropagation()}_updateOnInputChange(e){const t=this,a=t.$.editableElement,o=e.target,i=t.$.input,n=o.classList.contains("smart-search-input"),r=()=>{const e=l===i?i.value:t.$.editableElement.innerHTML;void 0!==s&&e!==s&&t.$.fireEvent("changing",{value:e,oldValue:t._changingValue})};if(t._editorBlocks=t.$.editableElement.querySelectorAll(".smart-editor-block"),"paste"===e.type&&a.contains(o)){const a=e.clipboardData;if(a&&a.types.length){const o=a.types.indexOf("text/html")>-1?"text/html":"text/plain",[i,n]=["\x3c!--StartFragment--\x3e","\x3c!--EndFragment--\x3e"];let r=a.getData(o);e.preventDefault();let l=(e.clipboardData||e.originalEvent.clipboardData).items,s=null;for(let e=0;e<l.length;e++)0===l[e].type.indexOf("image")&&(s=l[e].getAsFile());if(null!==s){const e=r;let o=!1;if((e.includes('xmlns:o="urn:schemas-microsoft-com:office:office"')||e.includes('xmlns:x="urn:schemas-microsoft-com:office:excel"')||e.includes('xmlns="urn:schemas-microsoft-com:office:word"')||e.includes('xmlns:w="urn:schemas-microsoft-com:office:word"')||e.includes('xmlns:v="urn:schemas-microsoft-com:vml"')||e.includes('ProgId="Excel.Sheet"')||e.includes("application/vnd.oasis.opendocument.spreadsheet")||e.includes("LibreOffice Calc"))&&(o=!0),!o){let e=new FileReader;return e.onload=function(e){let a,o="";t.imagePasteWidth&&(a=`width="${t.imagePasteWidth}"`),t.imagePasteHeight&&(o=`height="${t.imagePasteHeight}"`),t.$.editableElement.getRootNode().execCommand("insertHTML",!1,`<img ${a} ${o} src="${e.target.result}"/>`)},void e.readAsDataURL(s)}{const e=a.getData("text/html"),t=a.getData("text/plain");if(e&&e.includes("<table")){const t=document.createElement("div");t.innerHTML=e;const a=t.querySelector("table"),o=document.createElement("table");if(a){const e=[];for(let t of a.rows){const a=document.createElement("tr");o.appendChild(a);const i=[];for(let e of t.cells)a.appendChild(e.cloneNode(!0)),i.push(e.textContent.trim());e.push(i)}r=o.outerHTML}}else{const e=t.split("\n").map((e=>e.split("\t")));r=JSON.stringify(e,null,2)}}}r.indexOf(i)>-1&&r.indexOf(n)>-1&&(r=r.slice(r.indexOf(i),r.indexOf(n))),t._handlePasteAction(r,{advanced:!0,value:t.pasteFormat},o)}}const l=a.getRootNode().activeElement,s=t._changingValue;if(!t.$.contentContainer.hasAttribute("split-mode")){if(clearTimeout(t._refreshTimeout),delete t._refreshTimeout,n){const a=t.findAndReplaceTimeout,o=e.key;if(clearTimeout(t._findAndReplaceTimeout),!o||"enter"===o.toLowerCase())return;return void(a?t._findAndReplaceTimeout=setTimeout((()=>t._applySearching(e.target.value)),a):t._applySearching(e.target.value))}const a=t._resizeFrameObj?t._resizeFrameObj.target:void 0;if(a&&!a.parentElement&&(t._setResizeFrame(),t._closeToolbar()),t.autoFormatting){const e=e=>{const t=e.split("\n"),a=[];let o=!1,i=!1,n=!1,r=!1;for(let e of t){const t=e.trim();if(""===t||/^[-*] $/.test(t))continue;if(e=e.replace(/\u00A0/g," "),"```"===t){o=!o,r=!0,a.push(o?"<pre><code>":"</code></pre>");continue}if(o){a.push(e);continue}if(/^#{1,6} /.test(e)){const t=e.match(/^#{1,6}/)[0].length;let o=e.replace(/^#{1,6} /,"");""===o.trim()&&(o="&nbsp;"),a.push(`<h${t}>${o}</h${t}>`),r=!0;continue}if(/^> /.test(e)){a.push(`<blockquote>${e.slice(2)}</blockquote>`),r=!0;continue}if(/^(- ?){3,}$/.test(e)||/^(\* ?){3,}$/.test(e)){a.push("<hr>"),r=!0;continue}if(/^\[ \] /.test(e)){n||(a.push("<ul checklist>"),n=!0),a.push(`<li>${e.slice(4)}</li>`),r=!0;continue}if(/^\[x\] /.test(e)){n||(a.push("<ul checklist>"),n=!0),a.push(`<li checked>${e.slice(4)}</li>`),r=!0;continue}if(/^[-*] /.test(e)){i||(a.push("<ul>"),i=!0);let t=e.slice(2);""===t.trim()&&(t="&nbsp;"),a.push(`<li>${t}</li>`),r=!0;continue}if(/^1[.)] /.test(e)){i||(a.push("<ol>"),i=!0),a.push(`<li>${e.slice(3)}</li>`),r=!0;continue}let l=e.replace(/\*\*(.*?)\*\*/g,"<strong>$1</strong>").replace(/__(.*?)__/g,"<strong>$1</strong>").replace(/(?<!\*)\*(?!\*)(.*?)\*(?!\*)/g,"<em>$1</em>").replace(/(?<!_)_(?!_)(.*?)_(?!_)/g,"<em>$1</em>").replace(/`([^`]+?)`/g,"<code>$1</code>").replace(/~~(.*?)~~/g,"<del>$1</del>");l!==e&&(r=!0),a.push(`<p>${l}</p>`)}return i&&a.push(n?"</ul>":"</ol>"),n&&!i&&a.push("</ul>"),r?a.join("\n"):null},a=window.getSelection().focusNode,o=e(a.textContent);if(o){const e=3===a.nodeType?a.parentElement:a,i=document.createElement("div");i.innerHTML=o,i.setAttribute("data-block-id",Smart.Utilities.Core.createGUID()),i.setAttribute("data-block",""),i.classList.add("smart-editor-block"),e.replaceWith(i),t._setSelectionRange(i);let n=window.getSelection();const r=n.rangeCount>0?n.getRangeAt(0):null;r&&(r.collapse(!0),r.setStartAfter(i))}}return void r()}r(),clearTimeout(t._refreshTimeout);let d=t.$.input.value;t._refreshTimeout=setTimeout((()=>{clearTimeout(t._refreshTimeout),"markdown"===t.editMode?t.$.editableElement.innerHTML=window.marked?window.marked(d):d:l===i?t.$.editableElement.innerHTML=t._getInputValue(d,!0):t.$.input.value=t._getInputValue(t.$.editableElement.innerHTML.trim())}),t.splitModeRefreshTimeout)}_editableElementWheelHandler(){const e=this.$.inlineToolbar;this._setResizeFrame(),e&&e.visible&&e.close()}_getCaretCoordinates(e){const t=e.getBoundingClientRect(),a=window.getSelection().getRangeAt(0).getClientRects()[0];let o={};const i=this.offset(e);return a&&t&&(o.x=i.left+a.left-t.left,o.y=i.top+a.top-t.top),o}_insertWordAfterCurrentWord(e,t=!0){const a=this,o=window.getSelection();if(!o||0===o.rangeCount)return;let i=o.getRangeAt(0),n=o.focusNode,r=o.focusOffset;if(n.nodeType!==Node.TEXT_NODE){if(!(n.childNodes.length>0))return;if(n=n.childNodes[r]||n,n.nodeType!==Node.TEXT_NODE)return}const l=n.textContent,s=l.substring(0,r);let d=s.match(/(\w+)$/),c=0;if(t&&!d&&(d=s.trimEnd().match(/(\w+)$/),c=1),!d){if(t)return;const a=document.createTextNode(e+" ");return i.insertNode(a),i.setStartAfter(a),i.collapse(!0),o.removeAllRanges(),void o.addRange(i)}const m=d.index+d[0].length+c,u=l.substring(0,m);let p=l.substring(m);const b=document.createTextNode(u);if(t&&p.trim().startsWith(e.trim()))return;let h=document.createTextNode(""+e);const g=document.createTextNode(""+p);if(t){const e=document.createElement("span");e&&(e.classList.add("smart-auto-suggest"),e.style.color="var(--smart-disabled)"),e.appendChild(h);const t=n.parentNode;t.insertBefore(b,n),t.insertBefore(e,n),t.insertBefore(g,n),t.removeChild(n),a._autoSuggest=e}else{const e=n.parentNode;e.insertBefore(b,n),e.insertBefore(h,n),e.removeChild(n)}let f=t?0:1+e.length;const v=document.createRange();v.setStart(h,f),v.collapse(!0),o.removeAllRanges(),o.addRange(v)}_closeInlinePopups(){const e=this;e._callout&&(e._callout.remove(),delete e._callout),e._datePopup&&(e._datePopup.remove(),delete e._datePopup),e._pagePopup&&(e._pagePopup.remove(),delete e._pagePopup),e._aiPopup&&(e._aiPopup.remove(),delete e._aiPopup)}_editableElementKeyDownHandler(e){const t=this,a=t.$.editableElement,o=t.$.input,i=e.target.getRootNode().activeElement,n=e.key.toLowerCase(),r=t._isMacOS&&e.metaKey||e.ctrlKey;if(t._isControlPressed=r,!t.disabled&&!t.readonly){if(t._closeInlinePopups(),"blockHtml"===t.editMode&&t._setSortable(),"markdown"!==t.editMode)if(t._autoSuggestTimer&&clearTimeout(t._autoSuggestTimer),t._autoSuggest&&"Tab"===e.key&&e.preventDefault(),/^[a-zA-Z]$/.test(n)||" "===n||"backspace"===n||"delete"===n||"tab"===n){let a=200;if(("backspace"===n||"delete"===n)&&t._isAllContentSelected())if("blockHtml"===t.editMode){const a=t._createEditorBlock(!1,!1,"");a&&(t.innerHTML=t.value=a.outerHTML,e.preventDefault(),e.stopPropagation())}else t.$.editableElement.innerHTML="";if("blockHtml"===t.editMode){const e=t._currentBlock;e&&(e.removeAttribute("empty"),e.removeAttribute("data-placeholder"))}t._incrementalSearch||(t._incrementalSearch=""),t._incrementalSearch=t._incrementalSearch.trimStart(),"tab"===n?(a=0,t._incrementalSearch="",t._autoSuggest&&t._autoSuggest.textContent.length>=3&&t._autoSuggest.parentNode&&(e.preventDefault(),e.stopPropagation())):t._autoSuggest&&t._autoSuggest.remove(),/^[a-zA-Z]$/.test(n)||" "===n?t._incrementalSearch+=n:"backspace"===n&&(t._incrementalSearch=t._incrementalSearch.substring(0,t._incrementalSearch.length-1)),t._incrementalSearchTimer&&clearTimeout(t._incrementalSearchTimer),t._incrementalSearchTimer=setTimeout((()=>{t._incrementalSearch=""}),2e3);let o=!0;(e.ctrlKey||e.altKey)&&(o=!1),o&&(t._autoSuggestTimer=setTimeout((()=>{const a=t._getCurrentWord();if("Tab"===e.key){if(t._autoSuggest){const e=t._autoSuggest.textContent;t._autoSuggest.previousSibling&&(t._autoSuggest.previousSibling.textContent+=e),t._autoSuggest&&t._autoSuggest.remove()}return}let o;t._autoSuggest&&t._autoSuggest.remove();let i=t._collocations;if(t._bigramStore&&(i=i.concat(t._bigramStore)),i&&t._incrementalSearch.length>=2){t._incrementalSearch=t._incrementalSearch.toLowerCase();for(let e in i){const a=i[e].toLowerCase();if(a.startsWith(t._incrementalSearch)){o=a.substring(t._incrementalSearch.length);break}}let e="",a=(()=>{const e=window.getSelection();if(!e.rangeCount)return"";const t=e.getRangeAt(0).cloneRange();if(!t.collapsed)return"";t.setStart(t.startContainer,0);const a=t.toString().trim().split(/\s+/);return a.length>=2?a[a.length-2]:""})();if(a&&a.length>t._incrementalSearch.length){a=a.toLowerCase();for(let o in i){const n=i[o].toLowerCase();if(n.startsWith(a+" "+t._incrementalSearch)){e=n.substring(a.length+1+t._incrementalSearch.length);break}}e&&(o=e)}}if(o)setTimeout((()=>{t._insertWordAfterCurrentWord(o,!0)}),100);else if(a.length>=3&&" "!==n&&"backspace"!==n&&"delete"!==n){let e="";t._autoSuggest&&t._autoSuggest.remove();for(let o of t._dictionary)if(o.toLowerCase().startsWith(a.toLowerCase())&&o.length>a.length){e=o.substring(a.length),t._insertWordAfterCurrentWord(e);break}}else t._autoSuggest&&(t._autoSuggest.remove(),delete t._autoSuggest)}),a))}else t._incrementalSearch="",t._autoSuggest&&("Tab"===e.key?e.preventDefault():t._autoSuggest.remove());switch(n){case"/":if(!t._filterSortableMenuInput&&"blockHtml"===t.editMode){const o=t._getCaretCoordinates(a);e.pageX=o.x,e.pageY=o.y;let i=t._getSelectionRange().endContainer;for(;i&&(!i.classList||!i.classList.contains("smart-editor-block"));)i=i.parentElement;const n=i&&i.hasAttribute("empty");return t._currentBlock=i,t._renderSortableMenu(e,n,!0),e.preventDefault(),void e.stopPropagation()}break;case"@":if(t.users)return void setTimeout((()=>{const o=t._getCaretCoordinates(a);e.pageX=o.x+15,e.pageY=o.y;const i=[...t.users].map((e=>({label:e.label||e.name,id:e.value||e.id,value:"userProperties",image:e.image,color:e.color})));i.length&&t._openContextMenu(e,i,!0)}),50);break;case"a":if(!r){t._changingValue=i===a?a.innerHTML:o.value;break}if(i.classList.contains("smart-editor-image-caption"))return e.preventDefault(),t._setSelectionRange(i),void t._handleInlineToolbar(t._getSelectionRange().startContainer);if(t._tableCell)return e.preventDefault(),t._setSelectionRange(t._tableCell),void t._handleInlineToolbar(t._getSelectionRange().startContainer);break;case"backspace":case"delete":{const n=t._resizeFrameObj?t._resizeFrameObj.target:void 0;n&&("img"===n.nodeName.toLowerCase()||n.classList.contains("smart-editor-video-container"))&&(e.preventDefault(),t._deleteResizeFrameTarget(n)),t._changingValue=i===a?a.innerHTML:o.value;break}case"enter":if(!t.disableSearchBar){const a=t._searchToolbar;a&&!a.classList.contains("smart-visibility-hidden")&&(e.preventDefault(),t._highlightSearchResult(!e.shiftKey));const o=t._getSelectionRange();if(o&&o.startContainer){let e=o.startContainer;if("#text"===e.nodeName&&(e=e.parentElement),"LI"===e.nodeName||"LI"===e.parentElement.nodeName){const a=e.closest("ul");if(""===e.textContent.trim()&&(t._isControlPressed=!0,t._createEditorBlock(!1,!1),t._isControlPressed=!1,e.remove()),a&&a.hasAttribute("checklist")){const t=e.hasAttribute("checked");e.removeAttribute("checked"),setTimeout((()=>{t&&e.setAttribute("checked","")}))}}}if("blockHtml"===t.editMode){const a=t._createEditorBlock(e.altKey,!0);a&&"boolean"==typeof a?e.preventDefault():a&&(e.preventDefault(),e.stopPropagation(),a.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"}),t._currentBlock=a,t.scrollTop=0)}}break;case"escape":i===a?t._closeToolbar():i.classList.contains("smart-search-input")&&t._closeSearchToolbar();break;case"tab":if(t.enableTabKey)e.preventDefault(),t._handleTabInsert();else{const a=t._getSelectionRange();if(a&&a.startContainer){let t=a.startContainer;if("#text"===t.nodeName&&(t=t.parentElement),"LI"===t.nodeName||"LI"===t.parentElement.nodeName){window.getSelection();const a=t;if(a)if(e.shiftKey){const t=a.parentNode,o=t.parentNode.closest?t.parentNode.closest("li"):null;if(o){o.parentNode.insertBefore(a,o.nextSibling);const t=document.createRange();t.selectNodeContents(a),t.collapse(!0);const i=window.getSelection();i.removeAllRanges(),i.addRange(t),e.preventDefault()}}else{const t=a.closest("ul, ol");if(!t)return;const o=a.previousElementSibling;if(o){let e=o.querySelector("ul, ol");const i=t.tagName.toLowerCase();e||(e=document.createElement(i),o.appendChild(e)),e.appendChild(a);const n=e.firstChild,r=document.createRange();r.selectNodeContents(n),r.collapse(!0);const l=window.getSelection();l.removeAllRanges(),l.addRange(r)}e.preventDefault()}}}}break;case"alt":return;default:t._handleToolbarShortcuts(e,i)}t._closeToolbar()}}_initEditorBlocks(){const e=this.querySelectorAll("[data-block]");for(let t=0;t<e.length;t++){const a=e[t];a.setAttribute("data-block-id",Smart.Utilities.Core.createGUID()),a.classList.add("smart-editor-block"),a.hasAttribute("data-block-2")&&a.classList.add("smart-editor-two-columns"),a.hasAttribute("data-block-n")&&a.classList.add("smart-editor-n-columns-block")}}_refreshEditorBlockPlaceholder(){const e=this,t=t=>{const a=[...e.querySelectorAll(".smart-editor-block"),...e.querySelectorAll(".smart-editor-format-block")];for(let o=0;o<a.length;o++){const i=a[o];i.removeAttribute("empty"),i.removeAttribute("data-placeholder"),(""===i.textContent.trim()&&document.activeElement===i||t&&i===t.target&&""===i.textContent.trim())&&(i.setAttribute("empty",""),i.setAttribute("data-placeholder",e.localize("newLinePlaceholder")))}};t(),e.$.editableElement.onpointerdown=e.$.editableElement.oninput=e=>{t(e)},e.$.editableElement.onpaste=e=>{setTimeout((()=>{t(e)}),100)}}_refreshEditorBlockCursor(e){const t=this;(e=>{const a=document.createRange(),o=window.getSelection();a.setStart(e,0),a.collapse(!0),o.removeAllRanges(),o.addRange(a),""===e.textContent.trim()&&(e.setAttribute("data-placeholder",t.localize("newLinePlaceholder")),e.setAttribute("empty","")),""!==e.textContent.trim()&&(e.removeAttribute("empty"),e.removeAttribute("data-placeholder"))})(e)}_createEditorBlock(e,t,a){const o=this,i=o.$.editableElement;let n=window.getSelection(),r=n.anchorNode;for(;r&&r!==o.$.editableElement;)r=r.parentNode;if(!r){const e=o._createInsertionMarker();i.appendChild(e),o._setSelectionRange(e,0,0),n=window.getSelection(),e.id="",e.remove()}o._refreshEditorBlockPlaceholder();let l=n.anchorNode;for(;l&&l!==i;){if(("LI"===l.nodeName||"TD"===l.nodeName)&&""!==l.textContent.trim()&&!o._isControlPressed)return;l=l.parentNode}for(l=n.anchorNode;l&&l!==i&&(!l.classList||!l.classList.contains("smart-editor-block"));)l=l.parentNode;l&&l!==i&&l.classList&&!l.classList.contains("smart-editor-block")&&!event.ctrlKey&&(l=l.closest(".smart-editor-block"));const s=document.createElement("div");s.innerHTML="",s.setAttribute("data-block-id",Smart.Utilities.Core.createGUID()),s.setAttribute("data-block",""),s.classList.add("smart-editor-block");const d=n.rangeCount>0?n.getRangeAt(0):null;let c=d?d.startContainer:null;if(t&&d){const e=d.cloneRange();e.setEndAfter(c);const t=e.extractContents();s.appendChild(t)}""===s.textContent.trim()&&(s.innerHTML="");let m=n.anchorNode;if(m&&3===m.nodeType&&(m=m.parentElement),m){const e=m.closest(".editable-list");if(e&&!o._isControlPressed)if("LABEL"===m.nodeName){if(""!==s.textContent.trim()){const t=e.querySelector(".nested"),a=document.createElement("div");return a.innerHTML=s.innerHTML,t.insertBefore(a,t.firstElementChild),o._setSelectionRange(a,0,0),!0}}else if(m.closest(".nested")&&"LI"!==m.nodeName){const e=document.createElement("div");return e.innerHTML=s.innerHTML,""===s.textContent.trim()&&(e.innerHTML="&nbsp;"),m.nextElementSibling?m.parentElement.insertBefore(e,m.nextElementSibling):m.parentElement.appendChild(e),o._setSelectionRange(e,0,0),!0}}if(l&&l!==i&&l.parentNode===i)e?i.insertBefore(s,l):i.insertBefore(s,l.nextSibling),o._refreshEditorBlockCursor(s);else if(l&&n.anchorNode&&n.anchorNode.parentElement!==i){let t=n.anchorNode.parentElement;if(t&&!o.$.editableElement.contains(t)&&(t=o.$.editableElement),"H1"===t.nodeName||"H2"===t.nodeName||"H3"===t.nodeName||"H4"===t.nodeName||"H5"===t.nodeName||"H6"===t.nodeName||"UL"===t.nodeName||"OL"===t.nodeName||"BLOCKQUOTE"===t.nodeName||"PRE"===t.nodeName||"LABEL"===t.nodeName||"P"===t.nodeName){const a=t.closest(".smart-editor-block");let n=t,r=null;for(;n;){if(n.classList.contains("smart-editor-n-columns-block")){r=n;break}n=n.parentElement}r?r.appendChild(s):e&&a?a.parentElement.insertBefore(s,a):a&&a.nextSibling?a.parentElement.insertBefore(s,a.nextSibling):t.nextSibling?t.parentElement.insertBefore(s,t.nextSibling):i.appendChild(s),o._refreshEditorBlockCursor(s),""!==s.textContent.trim()&&(s.removeAttribute("empty"),s.removeAttribute("data-placeholder"))}else{let a=t,r=null;for(;a;){if(a.classList.contains("smart-editor-n-columns-block")){r=a;break}a=a.parentElement}if(t&&t.nodeType!==Node.TEXT_NODE&&t.classList.contains("smart-editor-n-columns-block"))t.appendChild(s);else if(t&&t.parentElement&&t.parentElement.classList.contains("smart-editor-n-columns-block"))t.parentElement.appendChild(s);else if(r)r.appendChild(s);else{let t=n.anchorNode;if(t.nodeType===Node.TEXT_NODE)for(;t&&t.nodeType!==Node.TEXT_NODE;)t=t.parentNode;if(t&&t.nodeType!==Node.TEXT_NODE){const a=t&&t.classList.contains("smart-editor-block")?t:t.closest(".smart-editor-block");a?e&&t?a.parentElement.insertBefore(s,a):t&&t.nextSibling?a.parentElement.insertBefore(s,a.nextSibling):a&&t.parentElement&&t.parentElement.closest(".smart-editor-block")?t.parentElement.appendChild(s):a.appendChild(s):i.appendChild(s)}else t&&t.nodeType===Node.TEXT_NODE&&t.parentElement&&t.parentElement.closest(".smart-editor-block")&&t.parentElement.parentElement?t.parentElement.parentElement.insertBefore(s,t.parentElement.nextSibling):i.appendChild(s)}o._refreshEditorBlockCursor(s)}}else l&&"DIV"===l.nodeName&&l.classList.contains("smart-editor-block")?e&&l?i.insertBefore(s,l):l&&l.nextSibling&&i.insertBefore(s,l.nextSibling):(s.innerHTML="",i.appendChild(s),o._refreshEditorBlockCursor(s));return a&&(s.innerHTML=a,s.removeAttribute("empty"),s.removeAttribute("data-placeholder")),s}_handleToolbarShortcuts(e,t){const a=this,o=a.$.editableElement,i=a.$.input,n=e.key,r=a._isMacOS&&e.metaKey||e.ctrlKey;if(!r)return void(a._changingValue=t===o?o.innerHTML:i.value);a._changingValue=t===o?o.innerHTML:i.value;const l=a._resizeFrameObj;let s;switch(l&&l.target&&(s=l.target),n.toLocaleLowerCase()){case"b":e.preventDefault(),a._handleTextDecorations("bold");break;case"c":r&&s&&a._handleImageCopy(s);break;case"x":r&&s&&a._handleImageCut(s);break;case"k":e.preventDefault(),a._openWindow({name:"hyperlink"});break;case"i":e.shiftKey?(e.preventDefault(),a._openWindow({name:"image"},s)):(e.preventDefault(),a._handleTextDecorations("italic"));break;case"e":e.shiftKey?(e.preventDefault(),a._openWindow({name:"table"},s)):(e.preventDefault(),a._updateToolbarTarget({name:"alignment",value:"center"}));break;case"u":e.shiftKey?(e.preventDefault(),a._handleTextCase("uppercase")):(e.preventDefault(),a._handleTextDecorations("underline"));break;case"s":e.shiftKey&&(e.preventDefault(),a._handleTextDecorations("strikethrough"));break;case"l":e.shiftKey?(e.preventDefault(),a._handleTextCase("lowercase")):(e.preventDefault(),a._updateToolbarTarget({name:"alignment",value:"left"}));break;case"+":e.shiftKey&&(e.preventDefault(),a._handleSubSuperScript("superscript"));break;case"=":e.shiftKey?(e.preventDefault(),a._handleSubSuperScript("superscript")):(e.preventDefault(),a._handleSubSuperScript("subscript"));break;case"]":e.preventDefault(),a._handleIndentation("indent");break;case"[":e.preventDefault(),a._handleIndentation("outdent");break;case"h":if(e.shiftKey){const t=a._toolbarItemsObj.sourcecode;t&&(t.value=void 0===t.value||!t.value),e.preventDefault(),a._handleSourceCodeMode()}break;case"f":if(e.shiftKey){const t=a._toolbarItemsObj.fullscreen;t&&(t.value=void 0===t.value||!t.value),e.preventDefault(),a._handleFullScreenMode()}else(!r||a.disableSearchBar||"html"!==a.editMode||o.classList.contains("smart-hidden"))&&(!r||a.disableSearchBar||"blockHtml"!==a.editMode||o.classList.contains("smart-hidden"))||(e.preventDefault(),a._openSearchBar());break;case"j":e.preventDefault(),a._updateToolbarTarget({name:"alignment",value:"justify"});break;case"r":e.shiftKey?(e.preventDefault(),a._handleClearFormat()):(e.preventDefault(),a._updateToolbarTarget({name:"alignment",value:"right"}));break;case"o":e.shiftKey?(e.preventDefault(),a._handleList("orderedlist")):e.altKey&&(e.preventDefault(),a._handleList("unorderedlist"))}(()=>{const e=a._changingValue,t=a.$.input,o=a.$.editableElement.getRootNode().activeElement===t?t.value:a.$.editableElement.innerHTML;void 0!==e&&o!==e&&a.$.fireEvent("changing",{value:o,oldValue:a._changingValue})})()}_editableElementMoveHandler(e){const t=this,a=t.$.editableElement,o=e.originalEvent||e,i=o.clientX,n=o.clientY,r=t.shadowRoot||t.isInShadowDOM?o.composedPath()[0]:o.target;if(e.stopPropagation(),!r||!r.closest||t._isMobile||"false"===a.getAttribute("contenteditable"))return void a.removeAttribute("table-cell-resize");const l=t._inlineToolbarClickObj;if(l&&l.resizeDetails||t._dragDetails)return;const s=r.tagName.toLowerCase();if(!r.closest(".smart-editor-editable table")||"td"!==s&&"th"!==s)return void a.removeAttribute("table-cell-resize");const d=r.getBoundingClientRect();n<d.bottom+5&&n>d.bottom-5?a.setAttribute("table-cell-resize","vertical"):i<d.right+5&&i>d.right-5&&r.nextElementSibling?a.setAttribute("table-cell-resize","horizontal"):a.removeAttribute("table-cell-resize")}_focusEditableElement(){const e=this,t=e.$.iframe,a=e.editMode;let o=e.$.editableElement;if(("markdown"===a||o.classList.contains("smart-hidden"))&&(o=e.$.input),t&&t.focus({preventScroll:!0}),o.getRootNode().activeElement!==o){const i=e._getSelectionRange(),n=o.scrollTop,r=t?t.contentWindow:window;if(o.focus({preventScroll:!0}),e._isSafari&&n&&(o.scrollTop=n),"markdown"===a||o.classList.contains("smart-hidden"))return void(void 0!==i.selectionStart&&e._setSelectionRange(i.selectionStart,i.selectionEnd));if(i instanceof r.Range){const e=(t?t.contentWindow:window).getSelection();e.removeAllRanges(),e.addRange(i)}}}_getTextFromCarret(){const e=this._getSelectionRange(),t=e.startContainer,a=t.textContent;let o,i;if(!e.toString()&&a.length>0&&a.indexOf(" ")>-1){const t=a.slice(0,e.startOffset).lastIndexOf(" ")+1;let n=a.slice(e.endOffset).indexOf(" ");n<0&&(n=a.length-1),o=t>-1?t:e.startOffset,i=Math.max(e.endOffset,e.endOffset+n)}else o=0,i=t.length;return{selectionStartIndex:o,selectionEndIndex:i}}_handleSearchButtonClick(e){const t=this;if(!e)return;const a=e.classList;a.contains("smart-search-button")&&(a.contains("prev")?t._highlightSearchResult():a.contains("next")?t._highlightSearchResult(!0):a.contains("close")&&t._closeSearchToolbar())}_highlightSearchResult(e){const t=this,a=t.$.contentContainer,o=t.$.editableElement.querySelectorAll(".find-and-replace-match"),i=a.querySelector(".smart-search-input-container"),n=o.length;for(let a=0,r=n;a<r;a+=1){const r=o[a];if(r.classList.contains("selected")){const l=e?Math.min(n-1,a+1):Math.max(0,a-1),s=o[l];return s&&(s.classList.add("selected"),i.setAttribute("selected",l+1),t._scrollToMarker(s)),void(s!==r&&r.classList.remove("selected"))}}}_handleToolbarItemClick(e,t){const a=this;if(!t)return;const o=a.$.inlineToolbar,i=a._toolbarItemClick,n=t.getAttribute?t.getAttribute("item-type"):t.type,r=t.getAttribute?t.getAttribute("item-name"):t.name;let l,s;a._changingValue||(a._changingValue=a.$.editableElement.innerHTML),e&&(l=e.originalEvent||e,s=a.shadowRoot||a.isInShadowDOM?l.composedPath()[0]:l.target);const d=()=>{const e=a._changingValue,t=a.$.input,o=a.$.editableElement.getRootNode().activeElement===t?t.value:a.$.editableElement.innerHTML;void 0!==e&&o!==e&&a.$.fireEvent("changing",{value:o,oldValue:a._changingValue})};if("custom"!==n&&l&&(a.hasRippleAnimation&&"delimiter"!==n&&Smart.Utilities.Animation.Ripple.animate(s,l.pageX,l.pageY),i&&i.callback))return i.callback.call(a,t,i.target),a.$.fireEvent("toobarItemClick",{value:r,originalEvent:l}),void d();a.$.fireEvent("actionStart",{name:r}).defaultPrevented||(a._handleToolbarItemAction(t),a._closeToolbarItemDropDown(a.$.inputPopup),a._closeToolbarItemDropDown(a.$.colorInputPopup),o&&o.close(),l&&(a.$.fireEvent("toobarItemClick",{value:r,originalEvent:l}),d()),r&&a.$.fireEvent("actionEnd",{name:r}))}_handleToolbarItemAction(e){const t=this,a=t._toolbarItemClick;if(!e)return;const o=e.getAttribute?e.getAttribute("item-type"):e.type,i=e.getAttribute?e.getAttribute("item-name"):e.name;if("custom"!==o){switch(t._changingValue||(t._changingValue=t.$.editableElement.innerHTML),i){case"ai":{const a=t._getAIMenuItems();let o=t.$.inlineToolbar;if(o&&o.classList.contains("smart-editor-ai-menu")&&o.hasAttribute("visible"))return void t._closeContextMenu();setTimeout((()=>{let o=e;if(!e.offsetHeight||!(e=>{if(!e)return!1;for(;e;){const t=window.getComputedStyle(e);if("none"===t.display||"hidden"===t.visibility||0===parseFloat(t.opacity))return!1;e=e.parentElement}return!0})(e)){const e=window.getSelection();if(e){let t=e.focusNode;t&&("#text"===t.nodeName&&(t=t.parentElement),o=t)}}t._openContextMenu({target:o},a,!0,"smart-editor-ai-menu",o)}),50);break}case"bold":case"italic":case"underline":case"strikethrough":t._handleTextDecorations(i);break;case"clearformat":t._handleClearFormat();break;case"redo":case"undo":t._handleUndoRedo(i);break;case"lowercase":case"uppercase":t._handleTextCase(i);break;case"backgroundcolor":t._handleBackgroundColor(e.getAttribute("item-value"));break;case"fontcolor":t._handleFontColor(e.getAttribute("item-value"));break;case"findandreplace":case"editlink":t._openWindow(e);break;case"openlink":{const a=t.$.inlineToolbar;if(a&&a.contains(e)){const e=a.selector;let t;e.nodeName!==Node.TEXT_NODE&&(t=e.closest(".smart-editor-editable a")),t&&window.open(t.href,t.target)}break}case"caption":{if(!a)break;const e=a.target;if(e&&"img"===e.nodeName.toLowerCase()){const a=e.closest(".smart-editor-image-container");let o;a&&a.querySelector(".smart-editor-image-caption")||(o=t.localize("captionPlaceholder")),t._handleImgCaption(e,{caption:o,focusCaption:!0})}else if(e.classList.contains("smart-editor-video-container")){const a=e.querySelectorAll(".smart-editor-video-container > video, .smart-editor-video-container > iframe");let o;e.querySelector(".smart-editor-image-caption")||(o=t.localize("captionPlaceholder")),t._handleVideoCaption(a[0]||a[1],{caption:o,focusCaption:!0})}break}case"cut":case"copy":case"paste":t._handleClipboardAction(i);break;case"delete":t._resizeFrameObj&&t._resizeFrameObj.target?t._deleteResizeFrameTarget(a.target):t._handleTextDelete();break;case"removelink":a&&t._handleLinkRemove(a.target);break;case"tableheader":case"tablerows":case"tablecolumns":case"tablevalign":case"tablestyle":t._handleTableToolbarAction(e);break;case"sourcecode":t._handleSourceCodeMode(e);break;case"splitmode":t._handleSplitMode(e);break;case"fullscreen":t._handleFullScreenMode(e);break;case"orderedlist":case"unorderedlist":t._handleList(i);break;case"checklist":t._handleCheckList("unorderedlist");break;case"indent":case"outdent":t._handleIndentation(i);break;case"subscript":case"superscript":t._handleSubSuperScript(i);break;case"print":t._handlePrint();break;default:t._inlineToolbarItemsObj?t._updateEditorViaWindow(t._inlineToolbarItemsObj[i]):t._toolbarItemsObj&&t._updateEditorViaWindow(t._toolbarItemsObj[i])}(()=>{const e=t._changingValue,a=t.$.input,o=t.$.editableElement.getRootNode().activeElement===a?a.value:t.$.editableElement.innerHTML;void 0!==e&&o!==e&&t.$.fireEvent("changing",{value:o,oldValue:t._changingValue})})()}}_handleCommonToolbarAction(e,t){const a=this;if(a._changingValue=a.$.editableElement.innerHTML,"html"===a.editMode||"blockHtml"===a.editMode){const o=a._getSelectionRange(),i=a.$.iframe,[n,r]=i?[i.contentDocument,i.contentWindow]:[document,window];let l,s=o.startContainer;if(!s)return;const d=e=>"string"==typeof e?("removeFormat"===e&&a.removeStylesOnClearFormat&&a._removeNodeStyles(o.commonAncestorContainer),n.execCommand(e)):"object"==typeof e?n.execCommand(e.name,!1,e.value):void 0;if(o.startOffset===o.endOffset&&s.nodeType===Node.TEXT_NODE){const{selectionStartIndex:e,selectionEndIndex:t}=a._getTextFromCarret();l=o.startOffset-e,a._setSelectionRange(s,e,t)}d(e)&&void 0!==l&&a._setSelectionRange(r.getSelection().focusNode,l,l),t&&a._updateToolbarItems(t)}(()=>{const e=a._changingValue,t=a.$.input,o=a.$.editableElement.getRootNode().activeElement===t?t.value:a.$.editableElement.innerHTML;void 0!==e&&o!==e&&a.$.fireEvent("changing",{value:o,oldValue:a._changingValue})})()}_handleClearFormat(){this._handleCommonToolbarAction("removeFormat")}_handleFontName(e){this._handleCommonToolbarAction(e)}_handleFontSize(e){const t=this;if("markdown"===t.editMode)return;const a=t._getSelectionRange();let o,i=a.startContainer;if(i){if(a.startOffset===a.endOffset){if(i.nodeType!==Node.TEXT_NODE){const o=document.createElement("font");return a.insertNode(o),t._setSelectionRange(o),void(o.style.fontSize=e.value+"px")}{const{selectionStartIndex:e,selectionEndIndex:n}=t._getTextFromCarret();o=a.startOffset-e,t._setSelectionRange(i,e,n)}}if((t.$.editableElement.getRootNode()||document).execCommand("fontSize",!1,3)){const i=t.$.iframe,n=i?i.contentWindow:window;if(a.commonAncestorContainer.closest){const t=a.commonAncestorContainer.querySelectorAll("font[size]");for(let a=0,o=t.length;a<o;a+=1){const o=t[a];o.removeAttribute("size"),o.style.fontSize=e.value+"px"}}else{const t=n.getSelection().focusNode;if(!t)return;const a=t.closest?t.closest(".smart-editor-editable font"):t.parentElement;"font"===a.nodeName.toLowerCase()&&(a.removeAttribute("size"),a.style.fontSize=e.value+"px")}void 0!==o&&t._setSelectionRange(n.getSelection().focusNode,o,o)}}}_handleFormats(e){const t=this;if("markdown"===t.editMode){let a;switch(e.value){case"h1":a="#";break;case"h2":a="##";break;case"h3":a="###";break;case"h4":a="####";break;case"h5":a="#####";break;case"h6":a="######";break;case"code":case"pre":a="```\n\n```";break;case"blockquote":a=">";break;case"p":a="";break;default:a=e.value}const o=e.dataSource,i=t.$.input.selectionStart;if(o){const e=o.map((e=>e.value));for(let a=0,o=e.length;a<o;a+=1){const o=t._getMarkdownFormat(i,e[a]);if(o&&void 0!==o.formatName){t._removeMarkDown(o.markdown,o.occuranceIndex,!0);break}}}return void(0===a.indexOf("#")||0===a.indexOf(">")?(a+=" ",t._insertMarkDown(a,t.$.input.selectionStart+a.length,!0)):t._insertMarkDown(a,t.$.input.selectionStart+a.length/2))}let a=t._getSelectionRange().startContainer;if(a){if("blockHtml"===t.editMode){const o=a.textContent;a.textContent="";const i=getSelection().anchorNode.parentElement.closest(".smart-editor-block");t._currentBlock=i||t._createEditorBlock(!1,!1);const n=t._createInsertionMarker();let r=t._getSelectionRange();const l=t._currentBlock;if(!l)return void t.$.editableElement.getRootNode().execCommand("formatBlock",!1,e.value);l.appendChild(n),l.removeAttribute("empty"),l.removeAttribute("data-placeholder"),t.selectRange(r);const s=t.$.editableElement.getRootNode().querySelector("#INSERTION_MARKER");s.innerHTML="&nbsp;",s.removeAttribute("id"),t._setSelectionRange(s),r=t._getSelectionRange(),r.collapse();const d=document.createElement(e.value);return d.innerHTML=o,o||(d.setAttribute("data-placeholder",e.label),d.setAttribute("empty","")),d.classList.add("smart-editor-format-block"),d.setAttribute("contenteditable",""),s.parentElement.insertBefore(d,s),void s.remove()}t.$.editableElement.getRootNode().execCommand("formatBlock",!1,e.value)}}_handleSubSuperScript(e){const t=this;"markdown"!==t.editMode?t._handleCommonToolbarAction(e,["subscript","superscript"]):t._handleMarkdownItem(e)}_handleMarkdownItem(e){const t=this,a=t.$.input,o=t._getSelectionRange(),i=o.selectionStart,n=o.selectionEnd;let r,l,s,d=a.value;switch(e){case"bold":l="**",s="**";break;case"italic":l="*",s="*";break;case"underline":l="<ins>",s="</ins>";break;case"strikethrough":l="~~",s="~~";break;case"subscript":l="<sub>",s="</sub>";break;case"superscript":l="<sup>",s="</sup>"}if(void 0!==i&&i!==n){const e=l.length,o=s.length;if(r=d.slice(i,n),d.slice(i-e,i)===l&&d.slice(n,n+o)===s)return a.value=d.slice(0,i-e)+r+d.slice(n+o),t._refreshMarkdownPreview(),void t._setSelectionRange(a,i-e,n-e)}l&&s&&t._insertMarkDown(l+s,a.selectionStart+l.length)}_handleTextDecorations(e){const t=this;if("markdown"===t.editMode)return void t._handleMarkdownItem(e);const a=t._getSelectionRange();let o,i=a.startContainer;if(!i)return;if(a.startOffset===a.endOffset&&i.nodeType===Node.TEXT_NODE){const{selectionStartIndex:e,selectionEndIndex:i}=t._getTextFromCarret();o=a.startOffset-e}if((t.$.editableElement.getRootNode()||document).execCommand(e))if(void 0!==o){const e=t.$.iframe;(e?e.contentWindow:window).getSelection().focusNode}else t._setSelectionRange();const n=t.$.toolbar,r=n.querySelector('.smart-editor-toolbar-item[item-name="'+e+'"]');if(r&&"bold"===e||"italic"===e||"underline"===e||"strikethrough"===e){let a=null;n!==t.$.toolbar||t.hideToolbar?t.hideInlineToolbar||(a=t._inlineToolbarItemsObj):a=t._toolbarItemsObj,a&&(a[e],r.hasAttribute("checked")?(r.removeAttribute("checked"),r.setAttribute("aria-pressed",!1)):(r.setAttribute("checked",""),r.setAttribute("aria-pressed",!0)))}else t._updateToolbarItems([e])}_handlePasteAction(e,t,a){if(!e)return;const o=this;if(t&&!t.name&&"prompt"===o.pasteFormat){const i={name:"paste",text:e,textType:a};return t&&(i.value=t.value,i.advanced=t.advanced),void o._openWindow(i)}o._handleTextPaste(e,t,a)}_handleTextPaste(e,t,a){const o=this,i=o.$.input;if(o.$.contentContainer.classList.contains("char-count-maxed"))return;if("markdown"===o.editMode)return o._insertMarkDown(e),void o._setCharCount();e=e.replace(/<!--StartFragment-->|<!--EndFragment-->/gi,"");let n,r,l=o.pasteFormat;if(t&&t.advanced&&(l=t.value),!a||"plainText"===l){const t=document.createElement("div");t.innerHTML=e,e=t.innerText}const s=e.toLocaleLowerCase();if(n=document.createElement("span"),n.innerHTML=e,"blockHtml"===o.editMode){o.$.editableElement.getRootNode().execCommand("delete"),n=document.createElement("div"),n.classList.add("smart-editor-block");let t=document.createElement("div");t.innerHTML=e;let a=[],i=!1,r=!1,l="";if(t.querySelectorAll("[disabled]").forEach((e=>{e.removeAttribute("disabled")})),t.childNodes.forEach((e=>{if(3===e.nodeType){let t=e.textContent.trim();t&&a.push(`<div data-block-id="${Smart.Utilities.Core.createGUID()}" class="smart-editor-block">${t}</div>`)}else"UL"===e.tagName||"OL"===e.tagName?a.push(`<div data-block-id="${Smart.Utilities.Core.createGUID()}" class="smart-editor-block">${e.outerHTML}</div>`):"LI"===e.tagName?(i||r||(l='<div data-block-id="${Smart.Utilities.Core.createGUID()}" class="smart-editor-block"><ul>',i=!0),l+=`<li>${e.innerHTML}</li>`):e.tagName.match(/^H[1-6]$/)?a.push(`<div data-block-id="${Smart.Utilities.Core.createGUID()}" class="smart-editor-block">${e.outerHTML}</div>`):"P"===e.tagName?(e.textContent.split("\n").forEach((e=>{a.push(`<div data-block-id="${Smart.Utilities.Core.createGUID()}" class="smart-editor-block">${e}</div>`)})),e.remove()):("BLOCKQUOTE"===e.tagName||e.tagName,a.push(`<div data-block-id="${Smart.Utilities.Core.createGUID()}" class="smart-editor-block">${e.outerHTML}</div>`))})),(i||r)&&(l+=i?"</ul></div>":"</ol></div>",a.push(l)),a.length>1){const e=window.getSelection();return e&&e.anchorNode&&e.anchorNode.classList&&e.anchorNode.classList.contains("smart-editor-block")&&""===e.anchorNode.textContent&&e.anchorNode.remove(),o._createEditorBlock(!1,!1,a.join("")),void(o._editorBlocks=o.$.editableElement.querySelectorAll(".smart-editor-block"))}n=document.createElement("span"),n.innerHTML=e}if(s.indexOf("<video")>-1||s.indexOf("<iframe")>-1||s.indexOf("smart-editor-image-caption")>-1){const e=n.querySelectorAll("video, iframe"),t=n.querySelector(".smart-editor-image-caption"),a=e.length>0;let o=document.createDocumentFragment();for(let t=0,a=e.length;t<a;t+=1)o.appendChild(e[t]);if(t&&(t.removeAttribute("style"),o.appendChild(t)),a||t){const e=document.createElement("span");n.classList.add("smart-editor-image-container"),a&&n.classList.add("smart-editor-video-container"),n.setAttribute("contenteditable",!1),o.childElementCount&&(n.innerHTML="",n.appendChild(o)),e.appendChild(n),n=e}}if("cleanFormat"===l&&o._removeNodeStyles(n),(!a||"text/plain"===a)&&(n=document.createTextNode(n.innerHTML),r=Node.TEXT_NODE,/^(https?:\/\/)?([\w.-]+\.[a-z]{2,})(\/[^\s]*)?$/i.test(e.trim()))){n=document.createElement("a"),n.innerHTML=e,n.href=e,n.target="_blank";const t=o._getSelectionRange();return t.deleteContents(),t.insertNode(n),o._handleNodeContentFiltering(n),void t.collapse()}if(i.getRootNode().activeElement===i){const e=i.value;return i.value=e.slice(0,i.selectionStart)+(r===Node.TEXT_NODE?n.textContent:n.innerHTML)+e.slice(i.selectionEnd),void o._setCharCount()}const d=o._getSelectionRange(),c=o.$.iframe,[m,u]=c?[c.contentWindow,c.contentDocument]:[window,document];if(!(d instanceof m.Range))return u.execCommand("paste"),void o._handleContentFiltering();if(d.deleteContents(),n.childNodes.length)for(;n.lastChild;)d.insertNode(n.lastChild);else d.insertNode(n);o._handleNodeContentFiltering(n),d.collapse()}_removeNodeStyles(e){if(e&&e.nodeType!==Node.TEXT_NODE){const t=e.querySelectorAll("style, [style]");for(let e=0,a=t.length;e<a;e+=1){const a=t[e];"style"===a.nodeName.toLowerCase()?a.remove():t[e].removeAttribute("style")}e.removeAttribute("style")}}_handlePaste(e){const t=this,a=navigator.clipboard,o=a.read?"read":"readText",i=()=>{a[o]&&a[o]().then((a=>{if(Array.isArray(a)&&a.length){const o=a[0],i=o.types.indexOf("text/html")>-1?"text/html":"text/plain";o.getType(i).then((a=>{a.text().then((a=>t._handlePasteAction(a,e,i)))}))}else"string"==typeof a&&t._handlePasteAction(a,e)}))};if(navigator.permissions&&navigator.permissions.query&&!t._isFireFox)try{navigator.permissions.query({name:"clipboard-read"}).then((e=>{("granted"===e.state||"prompt"===e.state&&a[o])&&i()}))}catch(e){t.error(t.localize("permissionsRequired",{elementType:t.nodeName.toLowerCase(),actionName:"paste"}))}else if(a[o])return void i();t.$.editableElement.getRootNode().execCommand("paste")}_handlePasteViaWindow(e){const t=this,a=t._getItemOptionsViaWindow(e);if(!e||"paste"!==e.name)return;let o=t.pasteFormat;for(let e in a)if(a[e]){o=e;break}e.value=o,t._handleTextPaste(e.text,e,e.textType)}_handleClipboardAction(e){const t=this,a=t.editMode,o=t.$.input;if("paste"===e)return void t._handlePaste();const i=t._getSelectionRange();if(("copy"===e||"cut"===e)&&(document.execCommand("copy"),"cut"===e))if("markdown"===a){const e=o.value,a=o.selectionStart;o.value=e.slice(0,a)+e.slice(o.selectionEnd),t._setSelectionRange(o,a,a),t._refreshMarkdownPreview()}else i.deleteContents()}_handleLinkRemove(e){const t=this;let a;if(e&&"img"===e.nodeName.toLowerCase())a=e.closest(".smart-editor-editable a"),a&&(a.parentElement.insertBefore(e,a),a.remove());else{const e=t.$.iframe;let a,o;e?(a=e.contentDocument,o=e.contentWindow):(a=document,o=window);const i=o.getSelection(),n=t._getSelectionRange();i.removeAllRanges(),i.addRange(n);const r=i.anchorNode?i.anchorNode.parentElement:void 0;if(!r||"a"!==r.nodeName.toLowerCase())return;n.selectNode(i.anchorNode),a.execCommand("unlink",!1,!1)}}_handleBackgroundColor(e){const t=this;if("markdown"===t.editMode)return;const a=t.$.iframe,o="string"==typeof e?e:e.value,[i,n]=a?[a.contentDocument,a.contentWindow]:[document,window],r=t.$.inlineToolbar,l=t._getSelectionRange(),s=r&&r.visible?r.selector:l.commonAncestorContainer;let d;if(s&&["th","td"].indexOf(s.nodeName.toLowerCase())>-1){if(l.startOffset===l.endOffset)return void(s.style.backgroundColor=o);d=s.style.backgroundColor}const c=l.startOffset,m=l.endOffset,u=l.startContainer;let p;if(u&&u.nodeType===Node.TEXT_NODE&&l.startOffset===l.endOffset){const{selectionStartIndex:e,selectionEndIndex:a}=t._getTextFromCarret();p=l.startOffset-e,t._setSelectionRange(u,e,a)}else u.closest&&c!==m&&t._setSelectionRange(u,c,m);const b=i.execCommand("hiliteColor",!1,o&&"transparent"!==o?o:"transparent");s&&d?s.style.backgroundColor=d:b&&void 0!==p&&t._setSelectionRange(n.getSelection().focusNode,p,p)}_handleFontColor(e){const t=this;if("markdown"===t.editMode)return;const a=t._getSelectionRange(),o="string"==typeof e?e:e.value,i=a.startContainer,n=t.$.iframe,r=o?"foreColor":"removeFormat",[l,s]=n?[n.contentDocument,n.contentWindow]:[document,window];let d;if(i&&i.nodeType===Node.TEXT_NODE&&a.startOffset===a.endOffset){const e=i.parentElement;if("font"===e.nodeName.toLocaleLowerCase())return void(e.color=o);const{selectionStartIndex:n,selectionEndIndex:r}=t._getTextFromCarret();d=a.startOffset-n,t._setSelectionRange(i,n,r)}l.execCommand(r,!1,o)&&void 0!==d&&t._setSelectionRange(s.getSelection().focusNode,d,d)}_handlePrint(){const e=this,t=e.dataExport.fileName;e.dataExport.fileName=null;const a=window.open("","","width=800,height=500"),o=a.document.open(),i='<!DOCTYPE html><html><head><meta charset="utf-8" /><title>'+t+"</title></head><body>"+e._handleDataExport("html")+"</body></html>";try{o.write(i),o.close(),setTimeout((function(){a.print(),a.close()}),100)}catch(e){}e.dataExport.fileName=t}_handleDataExport(e,t){const a=this;if(!Smart.Utilities.DataExporter)return void a.error(a.localize("missingReference",{elementType:a.nodeName.toLowerCase(),methodName:"exportData",files:"smart.export.js"}));try{new JSZip}catch(e){return void a.error(a.localize("missingReference",{elementType:a.nodeName.toLowerCase(),methodName:"exportData",files:"jszip.min.js"}))}if("pdf"===e&&!window.pdfMake)return void a.error(a.localize("missingReference",{elementType:a.nodeName.toLowerCase(),methodName:"exportData",files:"pdfMake.min.js"}));if("pdf"===e)return void a._exportToPDF(a.dataExport.fileName,e);let o;if("markdown"===a.editMode){const t=a.$.input;o="md"!==e&&window.marked?window.marked(t.value):t.value}else o=a.$.editableElement["pdf"===e?"textContent":"innerHTML"];const i=new Smart.Utilities.DataExporter({exportHeader:!1,pageOrientation:a.dataExport.pageOrientation,style:a.dataExport.style}),n=[{value:o}];return a._setExportStyles(i,e),i.exportData(n,e,a.dataExport.fileName,t)}_exportToPDF(e,t){const a=this,o=a.$.editableElement,i=window.getComputedStyle(a),n=a.dataExport.style,r={pageOrientation:a.pageOrientation||"portrait",info:{title:"smartEditor",creator:"Smart",producer:"Smart"}};if(n&&(r.styles=n),r.defaultStyle={fontSize:parseFloat(i.fontSize)},"markdown"===a.editMode){const e=a.$.input,i=document.createElement("div");let n;"md"!==t?o.classList.contains("smart-hidden")?(i.innerHTML=window.marked?window.marked(e.value):e.value,n=a._processHTMLAsPDFObject(i,[])):n=a._processHTMLAsPDFObject(o,[]):(i.innerHTML=e.value,n=a._processHTMLAsPDFObject(i,[])),r.content=n}else r.content=a._processHTMLAsPDFObject(a.$.editableElement,[]);try{pdfMake.createPdf(r).download(e)}catch(e){console.error(a.localize("exportError",{elementType:a.nodeName.toLowerCase(),status:e.toString()}))}}_processHTMLAsPDFObject(e,t,a){const o=this,i={},n=["left","center","right"],r=e.childNodes,l=["td","th"].indexOf(e.nodeName.toLowerCase())>-1;for(let a=0,s=r.length;a<s;a+=1){const s=r[a],d=s.nodeName.toLowerCase(),c=s.nodeType===Node.TEXT_NODE;let m;if("table"===d){const e=s.querySelectorAll("thead tr"),t=s.querySelectorAll("thead tr:last-of-type td, thead tr:last-of-type th"),a=s.querySelectorAll("tbody tr:last-of-type td, tbody tr:last-of-type th"),i=t.length?t:a,n=s.querySelectorAll("body tr");let r=e.length;if(!r)for(let e=0,t=n.length;e<t&&Array.from(n[e].children).every((e=>"th"===e.nodeName.toLowerCase()));e+=1)r++;m={table:{headerRows:r,widths:(()=>{const e=Math.round(100/i.length)+"%";let t=[];for(let a=0,o=i.length;a<o;a+=1)t.push(e);return t})(),body:(()=>{let e=[];for(let t=0,a=n.length;t<a;t+=1){const a=n[t],r=a.children;let l=[];for(let e=0,t=a.childElementCount;e<t;e+=1){const t=o._processHTMLAsPDFObject(r[e],[],!0);if(a.childElementCount<i.length){let e;for(e=Array.isArray(t)&&1===t.length?t[0]:{text:t},e.colSpan=Math.round(i.length/a.childElementCount),l.push(e);l.length<i.length;)l.push({text:""})}else l.push(1===t.length?t[0]:t)}e.push(l)}return e})()}}}else if("ul"===d)m={ul:o._processHTMLAsPDFObject(s,[])};else if("ol"===d)m={ol:o._processHTMLAsPDFObject(s,[])};else if("img"===d){const e=document.createElement("canvas"),t=e.getContext("2d");let a;e.width=s.naturalWidth||s.width,e.height=s.naturalHeight||s.height,t.drawImage(s,0,0);try{a=e.toDataURL("image/png")}catch(e){console.error(o.localize("exportError",{elementType:o.nodeName.toLowerCase(),status:e.toString()}));continue}if(a.indexOf("image/png")<0){console.error(o.localize("exportError",{elementType:o.nodeName.toLowerCase(),status:"Invalid image"}));continue}m={image:a,width:s.width,height:s.height}}else"a"===d?(m={},s.childElementCount?s.querySelector("img")&&(m=o._processHTMLAsPDFObject(s,[],!0)[0]||{}):m.text=s.textContent,m.link=s.href):s.childElementCount?t=t.concat(o._processHTMLAsPDFObject(s,[],!0)):m={text:s.textContent.trim()?s.textContent:"\n"};if(m){const a=window.getComputedStyle(c?e:s);if(!c||l){const e=a.backgroundColor,t=parseFloat(a.fontSize);isNaN(t)||(m.fontSize=t),m.alignment=i.alignment=n.indexOf(a.textAlign)>-1?a.textAlign:n[0],"rgba(0, 0, 0, 0)"!==e&&"transparent"!==e&&(m.fillColor=i.fillColor=o._RGBAtoHex(e)),parseInt(a.fontWeight)>500&&(m.bold=!0),"italic"===a.fontStyle&&(m.italics=!0)}m.inlineElement=c||a.display.indexOf("inline")>-1,m.color=i.color=o._RGBAtoHex(a.color),t.push(m)}}return 1===t.length?t:a||l?(i[t.every((e=>e.inlineElement&&!e.image))?"text":"stack"]=t,[i]):t}_RGBAtoHex(e){const t=/rgb[a]?\(\s*(\d+),\s*(\d+),\s*(\d+),?\s*(\d*.\d+|\d+)?\)/gi.exec(e.replace(/\s/g,""));if(null===t)return e;const a=parseFloat(t[1]).toString(16).toUpperCase(),o=parseFloat(t[2]).toString(16).toUpperCase(),i=parseFloat(t[3]).toString(16).toUpperCase();return"#"+"0".repeat(2-a.length)+a+"0".repeat(2-o.length)+o+"0".repeat(2-i.length)+i}_setExportStyles(e,t){const a=this;if(e.style)return;const o=window.getComputedStyle(a),i=o.getPropertyValue("--smart-border-width")||"1px",n=o.getPropertyValue("--smart-border")||"black",r=o.getPropertyValue("--smart-editor-table-column-width")||"initial",l=o.getPropertyValue("--smart-editor-table-cell-min-height")||"20px",s=o.getPropertyValue("--smart-editor-table-cell-min-width")||l,d=o.getPropertyValue("--smart-surface")||"#333",c=o.getPropertyValue("--smart-alternation-index0-background")||d;e.style={border:"initial",width:"100%",height:a.$.editableElement.scrollHeight+"px",removeDefault:!0,custom:`\n ${"html"===t&&a.rightToLeft?"body { direction: rtl; }":""}\n\n .column table {\n width: 100%;\n border-collapse: collapse;\n empty-cells: show;\n border-spacing: 0;\n table-layout: fixed;\n }\n \n .column td, .column th {\n border: ${i} solid ${n};\n width: ${r};\n min-height: ${l};\n min-width: ${s};\n padding: 2px 5px;\n vertical-align: middle;\n }\n \n .column table img {\n max-width: 100%;\n }\n \n .column table table {\n width: 100%;\n }\n \n .column table th {\n background: ${d};\n }\n\n .column th:empty::before,\n .column td:empty::before {\n content: 'A';\n visibility: hidden;\n }\n \n .column table[dashed-borders] th, .column table[dashed-borders] td {\n border-style: dashed;\n }\n \n .column table[alternation] tr:nth-child(2n) {\n background-color: ${c};\n }\n \n .column .smart-editor-image-container {\n display: inline-block;\n }\n \n .column .smart-editor-image-container[display="block"] {\n display: block;\n }\n \n .column .smart-editor-image-container[display="block"][alignment="left"] img {\n margin-left: 0;\n }\n \n .column .smart-editor-image-container[display="block"][alignment="left"] .smart-editor-image-caption {\n text-align: left;\n }\n \n .column .smart-editor-image-container[display="block"][alignment="right"] img {\n margin-right: 0;\n }\n \n .column .smart-editor-image-container[display="block"][alignment="right"] .smart-editor-image-caption {\n text-align: right;\n }\n \n .column .smart-editor-image-container:not([display="block"])[alignment="left"] {\n float: left;\n }\n \n .column .smart-editor-image-container:not([display="block"])[alignment="right"] {\n float: right;\n }\n \n .column .smart-editor-image-container .smart-editor-image-caption {\n display: block;\n text-align: center;\n outline: none;\n }`}}_handleSourceCodeMode(e){const t=this,a=t.editMode,o=t._toolbarItemsObj.sourcecode;let i;if(t.$.contentContainer.hasAttribute("split-mode"))return;e?i=e.hasAttribute("checked"):(i=o?o.value:!t.classList.contains("preview-mode"),e=t.$.toolbar.querySelector('.smart-editor-toolbar-item[item-name="sourcecode"]')),t._closePopups(),t._closeWindow(),t._closeSearchToolbar(),t._setResizeFrame(),t._handleTableSelection();const n=t.$.editableElement,r=t.$.input;"markdown"===a?i&&n.classList.contains("smart-hidden")?(n.innerHTML=window.marked?window.marked(r.value):r.value,n.classList.remove("smart-hidden"),r.classList.add("smart-hidden"),n.focus({preventScroll:!0})):!i&&r.classList.contains("smart-hidden")&&(n.classList.add("smart-hidden"),r.classList.remove("smart-hidden"),r.focus({preventScroll:!0})):i&&r.classList.contains("smart-hidden")?(r.value=t._getInputValue(n.innerHTML),n.classList.add("smart-hidden"),r.classList.remove("smart-hidden"),r.focus({preventScroll:!0})):!i&&n.classList.contains("smart-hidden")&&(n.innerHTML=t._getInputValue(r.value,!0),"blockHtml"===t.editMode&&t._createEditorBlock(!1,!1,"&nbsp;"),r.classList.add("smart-hidden"),n.classList.remove("smart-hidden"),n.focus({preventScroll:!0}),t._handleContentFiltering()),i?t.classList.add("preview-mode"):t.classList.remove("preview-mode"),o&&(o.value=i),e&&o&&(i?(e.setAttribute("checked",""),e.setAttribute("aria-pressed",!0)):(e.removeAttribute("checked"),e.setAttribute("aria-pressed",!1)),t._setTextSelection(),t._setToolbarItemAttr("sourcecode","disabled",o.disabled))}_offsetTop(e){return e?e.offsetTop+this._offsetTop(e.offsetParent):0}_offsetLeft(e){return e?e.offsetLeft+this._offsetLeft(e.offsetParent):0}offset(e){return{left:this._offsetLeft(e),top:this._offsetTop(e)}}_setTextSelection(){const e=this,t=e.$.input,a=e.$.editableElement,o=e._selectionRange;if(!o)return;const i=o.commonAncestorContainer;if(i){if(t.classList.contains("smart-hidden"))return;const n=e._getParentCharDetails(o.startContainer,i),r=e._getParentCharDetails(o.endContainer,i),l=e._getSiblingsCharOffset(n.parentElement,r.parentElement),{charOffset:s}=e._getParentCharDetails(i,a),d=o.startOffset+n.charOffset+s,c=o.endOffset+r.charOffset+l+s;e._setSelectionRange(t,d,c)}else if(!a.classList.contains("smart-hidden")){const i=o.selectionStart,n=o.selectionEnd,r=t.value;if(void 0===i||void 0===n||i===n&&(r.length===i||0===i))return;if(0===i&&n===a.innerHTML.length)return void e._setSelectionRange(a);const l=e._getNodeByChartOffset(a.firstChild,i,n);if(!l)return;const{node:s,charOffset:d}=l;e._setSelectionRange(s,i-d,n-d)}}_getNodeByChartOffset(e,t,a){const o=this;let i=0;for(;e;){const n=e.outerHTML||e.textContent,r=n.length;if(i<=t&&i+r>=a){e.tagName&&(i+=e.outerHTML.slice(0,n.indexOf(e.innerHTML)).length);const r=o._getNodeByChartOffset(e.firstChild,t-i,a-i);return r?{node:r.node,charOffset:r.charOffset+i}:{node:e,charOffset:i}}e=e.nextSibling,i+=r}}_getParentCharDetails(e,t){let a=0;if(e===t)return{charOffset:a,parentElement:e.parentElement};let o=e,i=e.innerHTML||e.textContent,n=e.parentElement;for(;n&&n!==t&&t.contains(n);){const e=n.outerHTML;a+=e.indexOf(i),i=e,o=n,n=n.parentElement}return a+=(t.innerHTML||t.textContent).indexOf(i),{charOffset:a,parentElement:o}}_getPreSiblingOffset(e,t){let a=0,o=e.textContent,i=e.previousSibling;for(;i&&t.contains(i);){const e=i.outerHTML||i.textContent;o=e+o,a+=e.length,i=i.previousSibling}return a}_getSiblingsCharOffset(e,t){let a=0,o=e.nextSibling;if(e===t)return a;for(;o&&o!==t;)a+=(o.outerHTML||o.textContent).length,o=o.nextSibling;return a}_handleFullScreenMode(e){const t=this,a=t._toolbarItemsObj.fullscreen;let o;e?o=e.hasAttribute("checked"):(o=a?a.value:!t.classList.contains("full-screen-mode"),e=t.$.toolbar.querySelector('.smart-editor-toolbar-item[item-name="fullscreen"]')),t._closePopups(),t._setResizeFrame(),t._handleTableSelection(),o?(t.classList.add("full-screen-mode"),t._lastToolbarExpandedState=t.$.toolbar.hasAttribute("expanded")):(t.classList.remove("full-screen-mode"),t._lastToolbarExpandedState&&t._toggleToolbar()),a&&(a.value=o),e&&a&&(o?(e.setAttribute("cheched",""),e.setAttribute("aria-pressed",!0)):(e.removeAttribute("checked"),e.setAttribute("aria-pressed",!1)),a.disabled?(e.setAttribute("disabled",""),e.setAttribute("aria-disabled",!0)):(e.removeAttribute("disabled"),e.removeAttribute("aria-disabled")))}_handleSplitMode(e){const t=this,a=t.$.editableElement,o=t.$.input,i=t.$.contentContainer,n=t._toolbarItemsObj,r=n.splitmode,l=n.sourcecode,s=e?e.hasAttribute("checked"):!i.hasAttribute("split-mode"),d=t.editMode;t._closePopups(),s?("markdown"===d?a.innerHTML=window.marked?window.marked(o.value):o.value:o.value=a.innerHTML.trim(),i.setAttribute("split-mode",""),o.classList.remove("smart-hidden"),a.classList.remove("smart-hidden"),l&&t._setToolbarItemAttr("sourcecode","disabled",!0)):(i.removeAttribute("split-mode",""),"markdown"===d?a.classList.add("smart-hidden"):o.classList.add("smart-hidden"),l&&t._setToolbarItemAttr("sourcecode","disabled",!1)),r&&(r.value=s),e||(e=t.$.toolbar.querySelector('.smart-editor-toolbar-item[item-name="splitmode"]')),e&&(s?(e.setAttribute("checked",""),e.setAttribute("aria-pressed",!0)):(e.removeAttribute("checked"),e.setAttribute("aria-pressed",!1))),t._resizeFrameObj&&t._setResizeFrame(t._resizeFrameObj.target),t.classList.contains("preview-mode")&&t._handleSourceCodeMode()}_handleUndoRedo(e){this.$.editableElement.getRootNode().execCommand(e)}_handleTextCase(e){const t=this;if("markdown"===t.editMode)return;const a=t._getSelectionRange(),o=a.startContainer;if(!o)return;const i=o.textContent;let n,r,l,s,d=a.startOffset;o.nodeType===Node.TEXT_NODE&&a.startOffset===a.endOffset?(({selectionStartIndex:l,selectionEndIndex:s}=t._getTextFromCarret()),r=i.slice(l,s)):([l,s]=[d,a.endOffset],r=i.slice(d,a.endOffset),n=a.endOffset),r="lowercase"===e?r.toLowerCase():r.toUpperCase(),o.textContent=i.slice(0,l)+r+i.slice(s),t._setSelectionRange(o,d,n||d)}_insertBlock(){const e=this;if("blockHtml"===e.editMode){if(e.preventInsertBlock)return;e.$.contentContainer.dispatchEvent(new KeyboardEvent("keydown",{key:"Enter"}));const t=e._currentBlock;if(!t)return;t.innerHTML="&nbsp;",t.removeAttribute("empty"),t.removeAttribute("data-placeholder"),e._setSelectionRange(t,0,0)}}_handleList(e){const t=this;if(!e)return;if("markdown"===t.editMode){const a="orderedlist"===e?"1. ":"- ",o=t.$.input.selectionStart,i=t._getMarkdownFormat(o,"orderedlist"),n=t._getMarkdownFormat(o,"unorderedlist");if(i&&(t._removeMarkDown(a,i.occuranceIndex,"orderedlist"!==e),"orderedlist"===e))return;if(n&&(t._removeMarkDown(a,n.occuranceIndex,"unorderedlist"!==e),"unorderedlist"===e))return;return void t._insertMarkDown(a,t.$.input.selectionStart+a.length,!0)}"blockHtml"===t.editMode&&t._insertBlock();let a,o,i=t._getSelectionRange();if(i.startContainer===i.endContainer&&(a=i.startOffset,o=i.endOffset),t.$.editableElement.getRootNode().execCommand("insert"+e,!1)){const e=t.$.iframe;i=(e?e.contentWindow:window).getSelection(),void 0!==o&&void 0!==o&&t._setSelectionRange(i.focusNode,a,o),t._updateToolbarItems(["orderedlist","unorderedlist"])}}_handleCheckList(e){const t=this;if(!e)return;if("markdown"===t.editMode){const a="orderedlist"===e?"1. ":"- ",o=t.$.input.selectionStart,i=t._getMarkdownFormat(o,"orderedlist"),n=t._getMarkdownFormat(o,"unorderedlist");if(i&&(t._removeMarkDown(a,i.occuranceIndex,"orderedlist"!==e),"orderedlist"===e))return;if(n&&(t._removeMarkDown(a,n.occuranceIndex,"unorderedlist"!==e),"unorderedlist"===e))return;return void t._insertMarkDown(a,t.$.input.selectionStart+a.length,!0)}if("blockHtml"===t.editMode){t.$.contentContainer.dispatchEvent(new KeyboardEvent("keydown",{key:"Enter"}));const e=t._currentBlock;e.innerHTML="&nbsp;",e.removeAttribute("empty"),e.removeAttribute("data-placeholder"),t._setSelectionRange(e,0,0)}let a,o,i=t._getSelectionRange();if(i.startContainer===i.endContainer&&(a=i.startOffset,o=i.endOffset),t.$.editableElement.getRootNode().execCommand("insert"+e,!1)){const e=t.$.iframe;if(i=(e?e.contentWindow:window).getSelection(),void 0!==o&&void 0!==o){const e=i.focusNode.parentElement.closest("ul");e&&e.setAttribute("checklist",""),t._setSelectionRange(i.focusNode,a,o)}t._updateToolbarItems(["checklist"])}}replaceSelection(e){this.$.editableElement.getRootNode().execCommand("delete"),this.$.editableElement.getRootNode().execCommand("insertHTML",0,e)}_handleIndentation(e){"markdown"!==this.editMode&&this.$.editableElement.getRootNode().execCommand(e,!1)}_handleTextDelete(){this.$.editableElement.getRootNode().execCommand("delete")}_handleTabInsert(){this.$.editableElement.getRootNode().execCommand("insertHTML",!1,"&#009")}_handleTableToolbarAction(e,t){const a=this,o=a._toolbarItemClick;if(!t&&o&&(t=o.target),!t||"table"!==t.nodeName.toLowerCase()||!e)return;const i=e.getAttribute?e.getAttribute("item-name"):e.name,n=a.$.inlineToolbar;let r=e;if(r.closest){const e=a.$.inlineToolbar;r=(e&&e.contains(r)?a._inlineToolbarItemsObj:a._toolbarItemsObj)[i]}if(!o&&a.$.fireEvent("actionStart",{name:i}).defaultPrevented)return;switch(i){case"backgroundcolor":a._handleBackgroundColor(r);break;case"fontcolor":a._handleFontColor(r);break;case"fontsize":a._handleFontSize(r);break;case"tableheader":a._handleTableHeader(t);break;case"tablerows":a._handleTableRows(t,r);break;case"tablecolumns":a._handleTableColumns(t,r);break;case"tablevalign":a._handleTableVAlignment(t,r);break;case"alignment":a._handleTextAlignment(r);break;case"tablestyle":a._handleTableStyle(t,r);break;case"formats":a._handleFormats(r);break;default:a._handleToolbarItemAction(e)}!o&&i&&a.$.fireEvent("actionEnd",{name:i}),n&&n.visible&&(a.$.editableElement.contains(n.selector)?n.reposition():a._closeToolbar());const l=a._getSelectionRange().startContainer;let s;if(l.nodeType===Node.TEXT_NODE){const e=l.parentElement;s=e.closest("th")||e.closest("td")}else s=["th","td"].indexOf(l.nodeName.toLowerCase())>-1;a._setResizeFrame(s&&t.contains(l)?t:void 0)}_handleTableHeader(e,t){let a,o,i=e.querySelector("th"),n=e.querySelector("tbody tr"),r=e.querySelector("thead");if(n&&(o=Array.from(n.children)),t||!r&&!i){if(void 0===t||!0===t){let t=e.querySelectorAll("tbody tr:first-of-type td").length;r||(r=document.createElement("thead")),a=r.querySelector("tr"),a||(a=document.createElement("tr"));const i=Array.from(a.children);for(;i.length>t;)i.pop().remove();for(let e=i.length;e<t;e+=1){const t=document.createElement("th");o[e]&&(t.style.width=o[e].style.width,o[e].style.width=""),a.appendChild(t)}r.appendChild(a),e.insertBefore(r,e.querySelector("tbody")||e.querySelector("tr"))}}else r&&r.remove(),i&&(a=i.closest("tr"),a&&a.remove(),Array.from(a.children).forEach(((e,t)=>o[t].style.width=e.style.width)))}_handleTableRows(e,t){if(!e)return;const a=this,o=a.$.inlineToolbar.selector,i=o.nodeName.toLocaleLowerCase();let n;if(!(o&&["th","td"].indexOf(i)>-1))return;if(n=o.closest("tr"),!n)return;const r=t.value,l=n.closest("thead");switch(r){case"insertRowAfter":case"insertRowBefore":{const t=document.createElement("tr"),a=n.parentElement;if(!a)break;const o=e.querySelector("tr").childElementCount,l="th"===i?"th":"td";for(let e=0;e<o;e+=1)t.appendChild(document.createElement(l));a.insertBefore(t,r.indexOf("Before")>-1?n:n.nextElementSibling);break}case"deleteRow":a._closeToolbar(),n.remove(),l&&!l.children.length&&l.remove()}const s=e.querySelectorAll("tr").length;s?(e.setAttribute("aria-rowcount",s),a._resizeFrameObj&&a._setResizeFrame(a._resizeFrameObj.target)):e.remove()}_handleTableColumns(e,t){if(!e)return;const a=this,o=a.$.inlineToolbar.selector;if(!(o&&["th","td"].indexOf(o.nodeName.toLowerCase())>-1))return;const i=t.value,n=Array.from(e.querySelectorAll("tr"));if(!n.length)return a._closeToolbar(),void e.remove();const r=Array.from(o.parentElement.children).indexOf(o);switch(i){case"insertColumnLeft":case"insertColumnRight":{const e=i.indexOf("Left")>-1;for(let t=0,a=n.length;t<a;t+=1){const a=n[t],o=a.children[r];if(o){const t="th"===o.tagName.toLowerCase()?"th":"td";a.insertBefore(document.createElement(t),e?o:o.nextElementSibling)}}break}case"deleteColumn":a._closeToolbar();for(let e=0,t=n.length;e<t;e+=1){const t=n[e].children[r];t&&t.remove()}}const l=n[0].children.length;l?(e.setAttribute("aria-colcount",l),a._resizeFrameObj&&a._setResizeFrame(a._resizeFrameObj.target)):e.remove()}_handleTextAlignment(e){if("markdown"===this.editMode)return;const t="justify"===e.value?"full":e.value;this.$.editableElement.getRootNode().execCommand("justify"+t.charAt(0).toUpperCase()+t.slice(1),!1,null)}_handleTableVAlignment(e,t){const a=this.$.inlineToolbar;if(!a)return;const o=a.selector;o&&["th","td"].indexOf(o.nodeName.toLowerCase())>-1&&(o.style.verticalAlign=t.value)}_handleTableStyle(e,t){const a=this.$.inlineToolbar.selector;if(a&&["th","td"].indexOf(a.nodeName.toLowerCase())>-1)switch(t.value){case"altrows":e.toggleAttribute("alternation");break;case"dashedborders":e.toggleAttribute("dashed-borders")}}_handleInlineToolbar(e){const t=this,a=e.nodeName.toLowerCase();"a"===a?((t._isControlPressed||e.classList.contains("smart-editor-file"))&&window.open(e.href,e.target),t._openInlineToolbar(e),t._refreshToolbarTabs()):"img"===a||["td","th"].indexOf(a)>-1?(t._setResizeFrame(e),t._openInlineToolbar(e),t._refreshToolbarTabs()):e.nodeType===Node.TEXT_NODE&&e.textContent.trim().length&&t._openInlineToolbar(e)}_handleTableCellResize(e){const t=this,a=t._inlineToolbarClickObj,o=a?a.resizeDetails:void 0;if(!o)return;const i=o.target,n=o.position,r=t.$.inlineToolbar;switch(o.started||t.$.fireEvent("resizeStart",{target:i}),i.setAttribute("resizing",""),o.started=!0,r&&r.visible&&(o.isInlineToolbarOpened=!0,t._closeToolbar()),n){case"horizontal":{const a=e.pageX+window.pageXOffset;if(t._setTableResizeDetails(o),!o.shrinkingCell)break;t._handleHorizontalTableCellResize(o,a);break}case"vertical":{const a=o.table;a.style.height&&(a.querySelectorAll("tr").forEach((e=>e.style.height=e.offsetHeight+"px")),a.style.height=""),t._resizeFrameObj&&t._resizeFrameObj.target&&t._setResizeFrame();const n=e.pageY+window.pageYOffset,r=o.y-n;let l=i.offsetHeight;l-=r,i.style.height=Math.max(1,l)+"px",l===i.offsetHeight&&(o.y=n+Math.abs(Math.min(0,l)));break}}}_setTableResizeDetails(e){const t=e.table,a=e.target;let o,i=e.expandingCell,n=e.shrinkingCell,r=e.isLastCell,l=e.areAllCellsResized;if(!i){const n=t.querySelector("tr"),r=Array.from(a.parentElement.children).indexOf(a);o=e.cells=Array.from(n.children),i=e.expandingCell=o[r]}e.shrinkingCell||(n=e.shrinkingCell=i.nextElementSibling,l=e.areAllCellsResized=!o.some((e=>e!==i&&e!==n&&!e.style.width)),r=e.isLastCell=l&&null===n.nextElementSibling,l&&!e.lastCell&&(e.lastCell=o[o.length-1]),r&&(n.style.width=""))}_handleHorizontalTableCellResize(e,t){const a=30,o=e.isLastCell;let i=e.expandingCell,n=e.shrinkingCell,r=i.offsetWidth,l=n.offsetWidth,s=e.x-t;const d=e.x-r+a,c=e.x+n.offsetWidth-a;if(o){const o=r+l-a;i.style.width=Math.min(Math.max(a,r-s),o)+"px",i.offsetWidth!==r&&(e.x=Math.min(c,Math.max(d,t)))}else{let o;s>0&&([i,n]=[n,i],[r,l]=[l,r],s*=-1),n.style.width=Math.max(a,l+s)+"px",o=n.offsetWidth-l,i.style.width=Math.max(a,i.offsetWidth-o)+"px",0!==o&&(e.x=Math.min(c,Math.max(d,t))),e.lastCell&&(e.lastCell.style.width="")}}_handleFrameResize(e){const t=this,a=t._resizeFrameObj;if(!a)return;t._closeToolbar();const o=a.resizableElement||a.target,i=a.resizeDetails,n=i.position,r=e.pageX+window.pageXOffset,l=e.pageY+window.pageYOffset,s=i.x-r,d=i.y-l;let c,m;c=o.offsetWidth,m=o.offsetHeight,i.started||(a.target.setAttribute("dragged",""),t.$.fireEvent("resizeStart",{target:o})),i.started=!0;const u=c,p=m,b=t.rightToLeft?-1:1;switch(n){case"top-left":o.style.width=Math.max(0,u+b*s)+"px",o.style.height=Math.max(0,p+d)+"px",c=o.offsetWidth,m=o.offsetHeight,u!==c&&(i.x-=b*(c-u)),p!==m&&(i.y-=m-p);break;case"bottom-left":o.style.width=Math.max(0,u+b*s)+"px",o.style.height=Math.max(0,p-d)+"px",c=o.offsetWidth,m=o.offsetHeight,u!==c&&(i.x-=b*(c-u)),p!==m&&(i.y+=m-p);break;case"bottom-right":o.style.width=Math.max(0,u-b*s)+"px",o.style.height=Math.max(0,p-d)+"px",c=o.offsetWidth,m=o.offsetHeight,u!==c&&(i.x+=b*(c-u)),p!==m&&(i.y+=m-p);break;case"top-right":o.style.width=Math.max(0,u+b*-s)+"px",o.style.height=Math.max(0,p+d)+"px",c=o.offsetWidth,m=o.offsetHeight,p!==m&&(i.y-=m-p),u!==c&&(i.x+=b*(c-u));break;case"top-center":o.style.height=Math.max(0,p+d)+"px",m=o.offsetHeight,p!==m&&(i.y-=m-p);break;case"bottom-center":o.style.height=Math.max(0,p-d)+"px",m=o.offsetHeight,p!==m&&(i.y+=m-p);break;case"left-center":o.style.width=Math.max(0,u+b*s)+"px",c=o.offsetWidth,u!==c&&(i.x-=b*(c-u));break;case"right-center":o.style.width=Math.max(0,u-b*s)+"px",c=o.offsetWidth,u!==c&&(i.x+=b*(c-u))}t._positionResizeHandles()}_deleteResizeFrameTarget(e){const t=this,a=t._getSelectionRange();if(e)if("img"===e.nodeName.toLowerCase()){const a=e.closest(".smart-editor-editable .smart-editor-image-container"),l=(a||e).parentElement,s=l&&"a"===l.nodeName.toLowerCase()?l:void 0;if(t._setResizeFrame(),(s||a||e).remove(),URL.revokeObjectURL(e.src),t.removeUrl){let a=new FormData,l=new XMLHttpRequest;const s=(e,t)=>{let a=e.split(","),o=a[0].match(/:(.*?);/)[1],i=atob(a[1]),n=i.length,r=new Uint8Array(n);for(;n--;)r[n]=i.charCodeAt(n);return new File([r],t,{type:o})};o=e.src,i=e.name,n=e=>{a.append(t.imageName,e),l.open("POST",t.removeUrl),l.send(a)},(r=new Image).crossOrigin="Anonymous",r.onload=function(){var e=document.createElement("canvas"),t=e.getContext("2d");e.height=this.naturalHeight,e.width=this.naturalWidth,t.drawImage(this,0,0);var a=e.toDataURL("image/jpeg");n(s(a,i))},r.src=o}t.onImageRemove&&t.onImageRemove(e.src)}else if(e.classList.contains("smart-editor-video-container")){const a=e.querySelector(".smart-editor-video-container video, .smart-editor-video-container > iframe");t._setResizeFrame(),e.remove(),a&&URL.revokeObjectURL(a.src)}else if("table"===e.nodeName.toLowerCase()){const a=e.closest(".smart-editor-editable table");a&&(t._setResizeFrame(),a.remove())}var o,i,n,r;t._setCharCount(),t._setSelectionRange(a.startContainer,a.startOffset,a.endOffset),t._focusEditableElement()}_setResizeFrame(e,t){const a=this,o=a.$.editableElement;let i,n=e?e.nodeName.toLowerCase():"",r=a._resizeFrameObj;if("td"!==n&&"th"!==n||(e=e.closest(".smart-editor-editable table")),n=e?e.nodeName.toLowerCase():"",e&&e.parentElement&&("img"===n||"table"===n||e.classList.contains("smart-editor-video-container"))&&"false"!==o.getAttribute("contenteditable"))if(r?i=r.element:(r=a._resizeFrameObj={},i=r.element=document.createElement("span"),i.classList.add("smart-editor-resize-frame"),i.innerHTML='<span position="top-left"></span><span position="top-right"></span>\n <span position="bottom-left"></span><span position="bottom-right"></span>\n <span position="top-center"></span><span position="bottom-center"></span>\n <span position="left-center"></span><span position="right-center"></span>'),r.target&&r.target.removeAttribute("show-resize-frame"),r.target=e,e.classList.contains("smart-editor-video-container")?r.resizableElement=e.querySelector("video, iframe"):delete r.resizableElement,a._refreshToolbarTabs(),"false"!==e.getAttribute("resizable")){if(e.setAttribute("show-resize-frame",""),a._positionResizeHandles(),i.parentElement||a.$.contentContainer.appendChild(i),!t&&"img"===n){const e=a.$.iframe;(e?e.contentWindow:window).getSelection().collapse(null),a._updateToolbarItems()}}else e.removeAttribute("show-resize-frame");else{if(r){if(r.element.remove(),r.target){const e=o.querySelectorAll("[show-resize-frame]");for(let t=0,a=e.length;t<a;t+=1)e[t].removeAttribute("show-resize-frame")}delete r.target}a._refreshToolbarTabs()}}_setToast(){const e=this;let t=e.$.toast;return t||(e.$.toast=t=document.createElement("smart-toast"),t.appendTo=e.$.container,t.showCloseButton=!0,t.itemClass="smart-editor-message",e.$toast=Smart.Utilities.Extend(t)),t.rightToLeft=e.rightToLeft,t.theme=e.theme,t.animation=e.animation,t}_positionResizeHandles(){const e=this,t=e._resizeFrameObj;if(!e._resizeFrameObj)return;const a=t.element,o=e.rightToLeft,i=o?"right":"left",n=(t.resizableElement||t.target).getBoundingClientRect(),r=a.children,l=r[0],s=r[1],d=r[2],c=r[3],m=r[4],u=r[5],p=r[6],b=r[7],h=e.$.editableElement,g=e.$.contentContainer.getBoundingClientRect(),f=n.top-g.top+h.offsetTop,v=n.width,_=n.height;let k;if(o)k=g.right-n.right+(h.offsetLeft+h.offsetWidth-g.width),l.style.left=d.style.left=p.style.left="";else{let t=0;e.sortable&&(t=0),k=n.left-g.left+h.offsetLeft-t,l.style.right=d.style.right=p.style.right=""}l.style.top=s.style.top=m.style.top=f+"px",l.style[i]=d.style[i]=p.style[i]=k+"px",d.style.top=c.style.top=u.style.top=f+_+"px",s.style[i]=c.style[i]=b.style[i]=v+k+"px",m.style[i]=u.style[i]=k+v/2+"px",p.style.top=b.style.top=f+_/2+"px"}_openInlineToolbar(e){const t=this,a=t.$.editableElement;let o=t.$.inlineToolbar;if(t._closeToolbarItemDropDown(t.$.inputPopup),t._closeToolbarItemDropDown(t.$.colorInputPopup),"false"===a.getAttribute("contenteditable")||t.hideInlineToolbar)return void(o&&o.visible&&o.close());if(o||(o=t._createToolbar()),o.classList.remove("smart-editor-add-menu"),o.classList.remove("smart-editor-ai-menu"),t.$.fireEvent("inlineToolbarOpening",{target:o}).defaultPrevented)return;t._setupToolbar(e,"inline"),o.parentElement||t.getShadowRootOrBody().appendChild(o);const i=t._getInlineToolbarContent(e);o.clear(),i instanceof DocumentFragment&&(o.appendChild(i),o.open(),t._setAriaOwns(o)),t._updateToolbarItems(void 0,o)}_closeToolbar(){const e=this,t=e.$.inlineToolbar;if(t){const a=t.classList,o=a.contains("smart-editor-context-menu")?"contextMenu":a.contains("smart-editor-inline-toolbar")?"inlineToolbar":"dropDownToolbar";if(e._filterSortableMenuInput&&e._filterSortableMenuInput.block&&e._filterSortableMenuInput.dispatchEvent(new KeyboardEvent("keydown",{key:"Escape"})),e.$.fireEvent(o+"Closing",{target:t}).defaultPrevented)return;t.close()}}_closePopups(){const e=this;e._closeToolbar(),e._closeToolbarItemDropDown(e.$.inputPopup),e._closeToolbarItemDropDown(e.$.colorInputPopup)}_createToolbar(){const e=this;let t=e.$.inlineToolbar;return t||(t=document.createElement("smart-tooltip"),t.offset=[0,0],e.$.inlineToolbar=t,e.$inlineToolbar=Smart.Utilities.Extend(t),t)}_setupToolbar(e,t){const a=this,o=a.$.iframe,i=a.$.inlineToolbar,n=a.$inlineToolbar;if(!i.visible){const e=e=>a._tooltipVisibilityHandler.call(a,e),t=e=>a._tooltipVisibilityHandler.call(a,e),o=e=>a._tooltipChangeHandler.call(a,e),i=e=>a._tooltipClickHandler.call(a,e),r=e=>a._tooltipTransitionEndHandler.call(a,e);n.unlisten("open"),n.unlisten("close"),n.unlisten("change"),n.unlisten("click"),n.unlisten("transitionend"),n.listen("open",e),n.listen("close",t),n.listen("change",o),n.listen("click",i),n.listen("transitionend",r)}if(i.locale=a.locale,i.rightToLeft=a.rightToLeft,i.theme=a.theme,i.animation=a.animation,i.openMode="manual",i.style.height="","inline"===t)i.position="auto",i.iframeRect=o?o.getBoundingClientRect():null,i.arrow=!0,i.align="center",i.offset=a.inlineToolbarOffset,i.classList.add("smart-editor-toolbar","smart-editor-inline-toolbar"),i.classList.remove("smart-editor-drop-down-toolbar","smart-editor-context-menu"),i.setAttribute("role","tooltip"),i.setAttribute("aria-label","Inline Toolbar");else{if("context"!==t)return i.position="auto",i.iframeRect=null,i.arrow=!1,i.align=a.rightToLeft?"right":"left",i.offset=[0,-5],i.selector=e,i.classList.add("smart-editor-toolbar","smart-editor-drop-down-toolbar"),i.classList.remove("smart-editor-inline-toolbar","smart-editor-context-menu"),i.setAttribute("role","tooltip"),void i.setAttribute("aria-label","Drop Down Toolbar");i.position="absolute",i.arrow=!1,i.classList.add("smart-editor-context-menu"),i.classList.remove("smart-editor-toolbar","smart-editor-drop-down-toolbar","smart-editor-inline-toolbar"),i.setAttribute("role","listbox"),i.setAttribute("aria-label","Context Menu")}if(i.selector&&!i.selector.closest&&delete i.selector.getBoundingClientRect,e.closest)i.selector=e;else{const t=e.parentElement,o=a._getSelectionRange();t.getBoundingClientRect=()=>o.getBoundingClientRect(),i.selector=t}}_getInlineToolbarContent(e){const t=this,a=t.$.inlineToolbar;if(a.innerHTML&&a.selector.nodeName===e.nodeName)return;let o;const i=t._toolbarItemsObj,n=e.nodeName.toLowerCase(),r=(e=[])=>{let t;for(let a=0,o=e.length;a<o;a+=1){const o=i[e[a]];if(o){t=o;break}}return t};let l;switch(n){case"a":l=r(["hyperlink","createlink"]);break;case"#text":l=r(["cut","copy","paste"]);break;case"img":l=r(["image"]);break;case"td":case"th":l=r(["table"]);break;default:return}return o=l&&Array.isArray(l.inlineToolbarItems)?l.inlineToolbarItems:t._getDefaultInlineToolbarItems(e,n),o.length?t._getToolbarItems(a,o):void 0}_getDefaultInlineToolbarItems(e,t){let a;const o=this;switch(t){case"a":a=[{name:"openlink",title:o.localize("openlink")+" - "+e.href},"editLink","removeLink"];break;case"#text":{let e=[];this.ai.key&&(e=["ai"]),a=[...e,"cut","copy","paste","|","bold","italic","strikethrough","underline","fontsize","fontname","fontcolor","backgroundcolor"];break}case"img":a=["image","alignment","createlink","delete","caption"],e.closest(".smart-editor-editable a")&&a.splice(a.indexOf("createlink")+1,0,"openlink","removelink");break;case"td":case"th":a=["table","tableheader","tablerows","tablecolumns","backgroundcolor","fontcolor","delete","alignment","tablevalign","tablestyle"];break;default:return[]}return a}_getNodes(e,t=0,a,o=0){const i=this,n=e.childNodes;let r=[];for(let e=0,l=n.length;e<l;e+=1){const l=n[e];if(l.childElementCount){const e=i._getNodes(l,t,a,o);if(o=e.index,e.nodes.length&&(r=r.concat(e.nodes)),o>=a)break}else if(l.nodeType===Node.TEXT_NODE){const e=l.nodeValue;if(!e.trim())continue;const i=e.length;if(o+i>t&&r.push({node:l,index:a-o,startIndex:Math.max(0,t-o)}),(o+=i)>a)break}else if((o+=(l.textContent||l.innerText||l.innerHTML).length)>t&&r.push({node:l,index:o}),o>a)break}return{nodes:r,index:o}}_tooltipChangeHandler(e){const t=this,a=e.target,o=t.$.inlineToolbar;o&&o.classList.contains("smart-editor-drop-down-toolbar")&&o.visible&&o.contains(a)?a.classList.contains("smart-table-picker")&&(t._handleTableInsert({cells:e.detail.value}),o.close()):t._changeHandler(e)}_tooltipClickHandler(e){const t=this,a=e.target,o=t.$.inlineToolbar;if(o&&o.classList.contains("smart-editor-drop-down-toolbar")&&o.contains(e.target)&&a.closest(".smart-table-picker-button")){const e=t._getSelectionRange();let a;return e.startContainer&&["th","td"].indexOf(e.startContainer.nodeName.toLowerCase())>-1&&(a=e.startContainer.closest(".smart-editor-editable table")),void t._openWindow(o.selector,a)}if(o&&o.classList.contains("smart-editor-context-menu")){const o=a.closest(".smart-editor-context-menu-item");if(o)return void t._handleContextMenuItemClick(e,o)}}_tooltipVisibilityHandler(e){const t=this,a=t.$.inlineToolbar,o=e.type;if(e.target!==a)return;const i=t.$.inlineToolbar,n=t.$inlineToolbar;let r;r=a.classList.contains("smart-editor-toolbar")?(a.classList.contains("smart-editor-drop-down-toolbar")?"inline":"dropDown")+"Toolbar":"contextMenu",e.stopPropagation(),"close"===e.type?(i.selector&&!i.selector.closest&&delete i.selector.getBoundingClientRect,i.hasAnimation||(n.unlisten(e.type),n.unlisten("change"),n.unlisten("click"),i.remove(),t._focusEditableElement()),t._setAriaOwns(a)):"open"===e.type&&t._setAriaOwns(a),t.$.fireEvent(r+o.slice(0,1).toUpperCase()+o.slice(1),Object.assign({target:e.target},e.detail))}_tooltipTransitionEndHandler(e){const t=this;if(!(e.target instanceof Smart.Tooltip))return;const a=t.$.inlineToolbar,o=t.$inlineToolbar;a.visible||(o.unlisten("transitionend"),a.style.top=a.style.left=0,a.remove(),t._setAriaOwns(a))}_toggleItemDropDown(e){const t=this,a=e.getAttribute("item-type");let o;if("drop-down"===a?(t.$.inputPopup||(t.$.inputPopup=document.createElement("smart-input")),o=t.$.inputPopup):"color-input"===a&&(t.$.colorInputPopup||(t.$.colorInputPopup=document.createElement("smart-color-input")),o=t.$.colorInputPopup),o.noRipple=!0,t.$.inputPopup&&o===t.$.colorInputPopup&&t.$.inputPopup.parentElement?t._closeToolbarItemDropDown(t.$.inputPopup):t.$.colorInputPopup&&o===t.$.inputPopup&&t.$.colorInputPopup.parentElement&&t._closeToolbarItemDropDown(t.$.colorInputPopup),o)if(o.locale=t.locale,o.rightToLeft=t.rightToLeft,o.theme=t.theme,o.animation=t.animation,e.contains(o)&&o.opened)t._closeToolbarItemDropDown(o);else{const a=t.$.inlineToolbar;a&&!a.contains(e)&&t._closeToolbar(),o.remove(),t._openToolbarItemDropDown(e,o)}}_toggleDropDownToolbar(e){const t=this;if(!e)return;if("table"!==e.getAttribute("item-name"))return;const a=t.$.inlineToolbar;if(a&&a.visible&&a.classList.contains("smart-editor-drop-down-toolbar")){if(a.contains(e)){const a=t._getSelectionRange();let o;return a.startContainer&&["th","td"].indexOf(a.startContainer.nodeName.toLowerCase())>-1&&(o=a.startContainer.closest(".smart-editor-editable table")),void t._openWindow(e,o)}a.classList.contains("smart-editor-drop-down-toolbar")&&a.close()}else t._closeToolbarItemDropDown(t.$.inputPopup),t._closeToolbarItemDropDown(t.$.colorInputPopup),t._openDropDownToolbar(e)}_openDropDownToolbar(e){const t=this;let a=t.$.inlineToolbar;a||(a=t._createToolbar()),t.$.fireEvent("dropDownToolbarOpening",{target:a}).defaultPrevented||(t._setupToolbar(e,"dropDown"),a.parentElement||t.getShadowRootOrBody().appendChild(a),t._setDropDownToolbarContent(e),a.open(),t._setAriaControls(e,a))}_setDropDownToolbarContent(e){const t=this,a=t.$.inlineToolbar,o=e.getAttribute("item-name");let i=t._dropDownToolbarObj;i||(i=t._dropDownToolbarObj={});let n=i[o];n||(n=document.createElement("smart-table-picker"),i[o]=n),n.rightToLeft=t.rightToLeft,n.locale=t.locale,n.messages=t.messages,n.value=[],a.contains(n)||(a.clear(),a.appendChild(n))}_openSearchBar(){const e=this,t=e.$.editableElement,a=e.$.contentContainer;let o=e._searchToolbar;if(e.disableSearchBar||t.classList.contains("smart-hidden"))return void(o&&o.remove());o||(o=e._searchToolbar=document.createElement("div"),o.classList.add("smart-editor-search-bar"),o.innerHTML='<span class="smart-search-input-container">\n <input class="smart-search-input"></input>\n </span>\n <smart-button class="smart-search-button prev"></smart-button>\n <smart-button class="smart-search-button next"></smart-button>\n <smart-button class="smart-search-button close"></smart-button>'),o.ontransitionend=null;const i=e.animation,n=e.theme,r=e.rightToLeft,l=o.children;let s;for(let t=0,a=l.length;t<a;t+=1){const a=l[t];if(a.classList.contains("smart-search-input-container")){const t=a.firstElementChild;t.placeholder=e.localize("searchPlaceholder"),s=t}a.animation=i,a.theme=n,a.rightToLeft=r}if(a.contains(o)||a.appendChild(o),o.classList.remove("smart-visibility-hidden"),s){const t=e.$.iframe,a=(t?t.contentWindow:window).getSelection().toString();s.value=a,s.focus({preventScroll:!0}),a&&e._applySearching(a)}delete e._lastSearchQuery}_closeSearchToolbar(){const e=this,t=e._searchToolbar;if(t&&!t.classList.contains("smart-visibility-hidden")){t.classList.add("smart-visibility-hidden"),t.ontransitionend=()=>{t.remove(),t.ontransitionend=null};const a=Array.from(e.$.editableElement.querySelectorAll(".find-and-replace-match"));for(let e=0,t=a.length;e<t;e+=1){const t=a[e];t.outerHTML=t.textContent}e._focusEditableElement()}}_toggleWindow(e,t){const a=this;if(!e)return;const o=e.getAttribute("item-name"),i=a.$.window;if(!i)return void a._openWindow(e,t);const n=i._target?i._target.item:void 0;!n||n.name!==o||n.name===o&&!i.opened?a._openWindow(e,t):i.close()}_openWindow(e,t){const a=this;if(!e||!a._toolbarItemsObj||a._window&&a._window.opened)return;let o;t&&t.classList.contains("smart-editor-video-container")&&(t=t.querySelector(".smart-editor-video-container > video, .smart-editor-video-container > iframe"));const i=a.$.editableElement;if(e.closest){if(!e.classList.contains("smart-editor-toolbar-item"))return;o=(e.closest(".smart-editor-inline-toolbar")?a._inlineToolbarItemsObj:a._toolbarItemsObj)[e.getAttribute("item-name")]}else"object"==typeof e&&"string"==typeof e.name&&(o=e);if(!o||"findandreplace"===o.name&&i.classList.contains("smart-hidden"))return;const n=a._createWindow(o);a.$.fireEvent("dialogOpening",{target:n,item:o}).defaultPrevented||(a._closeToolbarItemDropDown(a.$.inputPopup),a._closeToolbarItemDropDown(a.$.colorInputPopup),n._target={item:o,itemTarget:t,originalTarget:e},a._closeToolbar(),n.parentElement||a.getShadowRootOrBody().appendChild(n),n.isCompleted?a._setupWindow():n.whenReady((()=>a._setupWindow())))}_closeWindow(){const e=this,t=e.$.window;t&&t.opened&&(e.$.fireEvent("dialogClosing",{target:t,item:t._target.item}).defaultPrevented||t.close())}_setupWindow(){const e=this,t=e.$.window,a=t._target,o=a.item;function i(){e._positionWindow(),t.opened?(t.bringToFront(),t._handleActiveState(),t._onOpenCallback&&t._onOpenCallback()):t.open()}if(t.locale=e.locale,t.rightToLeft=e.rightToLeft,t.theme=e.theme,t.animation=e.animation,e.windowCustomizationFunction?e.windowCustomizationFunction(t,o):(e._setPopupWindowTemplate("header",o),e._setPopupWindowTemplate("footer",o),e._setPopupWindowTemplate("content",o)),!t.opened){const a=e.$window,o=t=>e._windowOpenHandler.call(e,t),i=t=>e._windowCloseHandler.call(e,t),n=t=>e._windowClickHandler.call(e,t),r=t=>e._windowChangeHandler.call(e,t),l=t=>e._windowKeyDownHandler.call(e,t),s=t=>e._windowKeyUpHandler.call(e,t),d=t=>e._windowTransitionendHandler.call(e,t),c=t=>e._fileUploadCompletedHandler.call(e,t),m=t=>e._fileUploadErrorHandler.call(e,t);a.unlisten("transitionend"),a.unlisten("open"),a.unlisten("close"),a.unlisten("click"),a.unlisten("change"),a.unlisten("keydown"),a.unlisten("keyup"),a.unlisten("uploadCompleted"),a.unlisten("uploadError"),t._onOpenCallback=()=>{((t.shadowRoot||t).querySelector(".smart-editor-window-editor:not(.smart-hidden) .smart-input.smart-element")||t).focus({preventScroll:!0})},t.hasAnimation&&a.listen("transitionend",d),a.listen("open",o),a.listen("close",i),a.listen("click",n),a.listen("change",r),a.listen("keydown",l),a.listen("keyup",s),a.listen("uploadCompleted",c),a.listen("uploadError",m)}t.shadowRoot?e._onShadowDomLoaded(t,"smart.window.css",i):i(),e._setAriaOwns(t),e._setAriaControls(a.originalTarget,t)}_setPopupWindowTemplate(e,t){const a=this,o=a.$.window;if(!o)return;if("content"===e)return void a._setWindowContent(t);o[e+"Template"]||(o[e+"Template"]=a._createWindowTemplate(e));const i=o._target.item;if("header"===e)o.label=a.localize(i.name)||"";else if("footer"===e){const e=(o.shadowRoot||o).querySelectorAll(".smart-editor-window-button"),i="findandreplace"===t.name;for(let t=0;t<e.length;t++){const o=e[t];o.innerHTML='<span class="smart-icon"></span>',o.theme=a.theme,o.rightToLeft=a.rightToLeft,o.animation=a.animation,o.classList.contains("ok")?i?(o.classList.add("replace"),o.innerHTML+=a.localize("replace"),o.setAttribute("aria-label","replace")):(o.classList.remove("replace"),o.innerHTML+=a.localize("ok"),o.setAttribute("aria-label","ok")):o.classList.contains("cancel")?(o.innerHTML+=a.localize("cancel"),o.setAttribute("aria-label","cancel")):i?(o.classList.contains("replace-all")&&(o.innerHTML+=a.localize("replaceAll"),o.setAttribute("aria-label","replaceAll")),o.classList.remove("smart-hidden")):o.classList.add("smart-hidden");const n=o.querySelector(".smart-ripple");n&&n.parentElement.removeChild(n)}}}_adjustPopupBounds(e){const t=window.innerHeight+window.pageYOffset,a=this.offset(e);a.bottom=a.top+e.offsetHeight;let o=a.top;e.style.height="";let i=e.offsetHeight;e.classList.contains("smart-editor-ai-popup")&&(e.querySelector(".smart-editor-predefined-container").classList.remove("smart-hidden"),e.querySelector(".smart-editor-header").classList.remove("smart-hidden")),a.bottom>t&&(a.top-i>=0?o=a.top-i-30:(i=Math.min(i,t-a.top-10),e.classList.contains("smart-editor-ai-popup")&&(e.querySelector(".smart-editor-predefined-container").classList.add("smart-hidden"),e.querySelector(".smart-editor-header").classList.add("smart-hidden")),i<100&&(i=100))),o<0&&(o=10),e.style.top=`${o}px`,e.style.height=`${i}px`}_setWindowContent(e){const t=this,a=t.$.window,o=a._target.originalTarget,i=[].slice.call(a.getElementsByClassName("smart-editor-window-editor"));if((!a.innerHTML||i.length)&&o){switch(e.name){case"createlink":case"editlink":case"hyperlink":case"image":case"video":case"file":case"table":case"paste":case"findandreplace":t._createWindowEditors(e)}o.id&&a.setAttribute("aria-controls",o.id)}}_createWindowEditors(e){const t=this,a=t.$.window,o=e.name;let i,n=t._windowEditors,r=a.querySelector(".smart-editor-window-content-wrapper");r||(r=document.createElement("div"),r.classList.add("smart-editor-window-content-wrapper"),a.appendChild(r)),t._windowEditors||(n=t._windowEditors={}),n&&(i=n[o]),i||(i=document.createElement("div"),i.classList.add(`smart-editor-window-${o}`),i.innerHTML=t._getWindowEditorTemplate(o),n[o]=i),r.contains(i)||(r.innerHTML="",r.appendChild(i));const l=i.querySelectorAll(".smart-editor-window-editor[type]");for(let e=0;e<l.length;e++)t._setPopupWindowEditor(l[e])}_getWindowEditorTemplate(e){const t=this;switch(e){case"createlink":case"editlink":case"hyperlink":return'\n <div class="smart-editor-window-editor" type="address">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="text">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="title">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="target">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>';case"image":return t.compactImageDialog?'\n <div class="smart-editor-window-editor" type="file">\n <smart-file-upload item-editor></smart-file-upload>\n </div>\n <div class="smart-editor-window-editor" type="url">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="width">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="height">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>':'\n <div class="smart-editor-window-editor" type="file">\n <smart-file-upload item-editor></smart-file-upload>\n </div>\n <div class="smart-editor-window-editor" type="url">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="width">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="height">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="alt">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="title">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="caption">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="display">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="alignment">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="draggable">\n <smart-check-box item-editor></smart-check-box>\n </div>\n <div class="smart-editor-window-editor" type="resizable">\n <smart-check-box item-editor></smart-check-box>\n </div>';case"file":return'\n <div class="smart-editor-window-editor" type="file">\n <smart-file-upload item-editor></smart-file-upload>\n </div>\n <div class="smart-editor-window-editor" type="fileUrl">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n ';case"table":return'\n <div class="smart-editor-window-editor" type="cols">\n <label></label>\n <smart-number-input item-editor></smart-number-input>\n </div>\n <div class="smart-editor-window-editor" type="rows">\n <label></label>\n <smart-number-input item-editor></smart-number-input>\n </div>\n <div class="smart-editor-window-editor" type="width">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="height">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="tableheader">\n <smart-check-box item-editor></smart-check-box>\n </div>\n <div class="smart-editor-window-editor" type="altrows">\n <smart-check-box item-editor></smart-check-box>\n </div>\n <div class="smart-editor-window-editor" type="dashedborders">\n <smart-check-box item-editor></smart-check-box>\n </div>\n <div class="smart-editor-window-editor" type="resizable">\n <smart-check-box item-editor></smart-check-box>\n </div>';case"paste":return'\n <div class="smart-editor-window-editor" type="keepFormat">\n <label></label>\n <smart-radio-button checked group-name="editorPasteViaWindow" item-editor></smart-radio-button>\n </div>\n <div class="smart-editor-window-editor" type="cleanFormat">\n <smart-radio-button group-name="editorPasteViaWindow" item-editor></smart-radio-button>\n </div>\n <div class="smart-editor-window-editor" type="plainText">\n <smart-radio-button group-name="editorPasteViaWindow" item-editor></smart-radio-button>\n </div>';case"findandreplace":return'\n <div class="smart-editor-window-editor" type="find">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="replaceWith">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="results">\n <label></label>\n <smart-list-box virtualized item-editor></smart-list-box>\n </div>\n <div class="smart-editor-window-editor" type="matchCase">\n <smart-check-box item-editor></smart-check-box>\n </div>';case"video":return'\n <div class="smart-editor-window-editor" type="file">\n <smart-file-upload item-editor></smart-file-upload>\n </div>\n <div class="smart-editor-window-editor" type="src">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="width">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="height">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="thumbnail">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="videoUrl">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="alt">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="title">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="caption">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="display">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="alignment">\n <label></label>\n <smart-input item-editor></smart-input>\n </div>\n <div class="smart-editor-window-editor" type="draggable">\n <smart-check-box item-editor></smart-check-box>\n </div>\n <div class="smart-editor-window-editor" type="resizable">\n <smart-check-box item-editor></smart-check-box>\n </div>';default:return""}}_setPopupWindowEditor(e){const t=this,a=e.getAttribute("type"),o=e.querySelector("label"),i=t.$.window._target,n=i.item,r="markdown"===t.editMode,l=n.editor;let s,d=e.querySelector("[item-editor]");if(o&&("paste"===n.name?(o.id=t.id+"pasteLabel",o.innerHTML=t.localize("pasteLabel")||""):(o.id=t.id+a+"Label",o.innerHTML=t.localize(a)||"")),!d)return;const c=t._toolbarItemClick;let m;switch(m=c?c.target:i.itemTarget,n.name){case"hyperlink":case"createlink":case"editlink":{const o=t._getSelectionRange();let i=o.startContainer;i&&"a"!==i.nodeName.toLowerCase()&&(i=i.parentElement),i&&"a"===i.nodeName.toLowerCase()?"address"===a?s=i.getAttribute("href"):"text"===a?s=i.textContent:"title"===a?s=i.title:"target"===a&&(s=i.target):s="text"===a?r?t.$.input.value.slice(o.selectionStart,o.selectionEnd):o.toString():l&&void 0!==l[a]?l[a]+"":"","target"===a&&r||m&&"img"===m.nodeName.toLowerCase()&&["title","text"].indexOf(a)>-1?e.classList.add("smart-hidden"):e.classList.remove("smart-hidden");break}case"video":case"file":case"image":{const o=t._toolbarItemClick,d=o?o.target:i.itemTarget;if(d&&["img","video","iframe"].indexOf(d.nodeName.toLowerCase())>-1){const e=d.closest(".smart-editor-image-container");switch(a){case"file":d.file instanceof File&&(s=d.file);break;case"url":case"src":s=d.file instanceof File?"":d.getAttribute("src")||"";break;case"alt":s=d.alt;break;case"title":s=d.title;break;case"width":if(s=d.style.width||(e?e.style.width:""),!s){const e=d.getAttribute("width");e&&(s=e)}break;case"height":if(s=d.style.height||(e?e.style.height:""),!s){const e=d.getAttribute("height");e&&(s=e)}break;case"caption":if(e){const t=e.querySelector(".smart-editor-image-caption");t&&(s=t.textContent)}void 0===s&&(s="");break;case"alignment":s=(e||d).getAttribute("alignment")||"";break;case"display":s=(e||d).getAttribute("display")||"";break;case"draggable":case"resizable":{const t=("video"===n.name?e:d).getAttribute(a);s=null==t||"true"===t;break}}}else s=l?("draggable"===a||"resizable"===a)&&void 0===l[a]||(void 0!==l[a]?l[a]+"":""):"width"===a?480:"height"===a?270:"draggable"===a||"resizable"===a||"";r&&["file","url","videoUrl","alt","title","thumbnail"].indexOf(a)<0||!r&&"video"===n.name&&["alt","thumbnail","videoUrl"].indexOf(a)>-1?e.classList.add("smart-hidden"):e.classList.remove("smart-hidden");break}case"table":{const t=i.itemTarget&&"table"===i.itemTarget.nodeName.toLowerCase()?i.itemTarget:void 0;switch(a){case"width":case"height":s=t?t.style[a]:l&&void 0!==l[a]?l[a]:"";break;case"cols":s=t?t.querySelector("tbody > tr").children.length+"":l&&void 0!==l[a]?l[a]:"1";break;case"rows":s=t?t.querySelectorAll("tbody > tr").length+"":l&&void 0!==l[a]?l[a]:"1";break;case"tableheader":s=!!r||(t?null!==t.querySelector("thead"):!(!l||void 0===l[a])&&l[a]);break;case"altrows":s=t?t.hasAttribute("alternation"):!(!l||void 0===l[a])&&l[a];break;case"dashedborders":s=t?t.hasAttribute("dashed-borders"):!(!l||void 0===l[a])&&l[a];break;case"resizable":s=t?!("false"===t.getAttribute("resizable")):!l||void 0===l[a]||l[a]}r&&["cols","rows","tableheader"].indexOf(a)<0?e.classList.add("smart-hidden"):e.classList.remove("smart-hidden");break}case"paste":s=a===t.pasteFormat;break;case"findandreplace":s=l&&void 0!==l[a]?l[a]:""}t._setupEditorElement(d,a,s),t._setEditorCommonProperties(d)}_setupEditorElement(e,t,a){const o=this,i=o.$.window._target.item,n=i.editor,r="markdown"===o.editMode;if((e instanceof Smart.CheckBox||e instanceof Smart.RadioButton)&&(e.innerHTML=o.localize(t)||"",e.checked=!!a),e instanceof Smart.NumberInput)e.min=1,e.value=parseInt(a);else{if(e instanceof Smart.FileUpload)return"file"===t&&e.isCompleted&&(e.cancelAll(),a&&e.addFile(a)),e.uploadUrl="",e.removeUrl="",e.autoUpload=!1,o.postData?e.postData=o.postData:o.getAttribute("post-data")&&(e.postData=JSON.parse(o.getAttribute("post-data"))),o.uploadUrl&&(e.uploadUrl=o.uploadUrl,o._fileUpload=e,o._fileUpload.name=o.imageName,e.autoUpload=o.autoUpload),o.removeUrl&&(e.removeUrl=o.removeUrl),o.validateFile&&(e.validateFile=o.validateFile),n&&(n.uploadUrl&&(e.uploadUrl=n.uploadUrl,e.autoUpload=!0),n.removeUrl&&(e.removeUrl=n.removeUrl)),e.dropZone=e.parentElement,e.accept=i.allowedTypes||(r||"video"!==i.name?"image/*":"video/mp4,video/x-m4v,video/*"),"file"===i.name&&(e.accept=i.allowedTypes||"*"),void(e.hideFooter=!0);if(e instanceof Smart.ListBox)e.selectionMode="one",e.itemHeight=35;else{if("string"==typeof e.placeholder&&(e.placeholder=o.localize(t+"Placeholder")||""),e.dropDownClassList&&(e.dropDownClassList=["smart-editor-input"]),void 0!==e.dataSource){if("target"===t||"alignment"===t||"display"===t){e.dataSource.length||(e.dataSource=o._getDefaultDataSource(t)),"alignment"!==t||a||(a="center");const i=a?e.dataSource.find((e=>"object"==typeof e&&e.value===a)):void 0;i&&"object"==typeof i&&(a=i.label||a),e.readonly=!i&&!a||i&&""!==i.value}else e.dataSource=[];"string"==typeof e.dropDownButtonPosition&&(e.dropDownButtonPosition=e.dataSource.length?o.rightToLeft?"left":"right":"none")}e.value=void 0===a?"":a+""}}}_setEditorCommonProperties(e){const t=this;if(e){const a=e.messages,o=t.messages,i=t.locale;for(let e in a.en){const t=o[i][e];void 0!==t&&(a[i]||(a[i]={}),a[i][e]=t)}e.locale=t.locale,e.rightToLeft=t.rightToLeft,e.animation=t.animation,e.theme=t.theme}}_createWindow(){const e=this,t=e.$.window;if(t)return t;const a=document.createElement("smart-window");return a.classList.add("smart-editor-window"),a.id=e.id+"Window",a.setAttribute("smart-id","window"),e.$.window=a,e.$window=Smart.Utilities.Extend(a),a.rightToLeft=e.rightToLeft,a.theme=e.theme,a.animation=e.animation,a.disableSnap=!0,a.headerButtons=["close"],a.style.zIndex=999999,a}_createWindowTemplate(e){const t=this,a=t.animation,o=t.theme,i=t.rightToLeft;let n;return"footer"===e&&(n=document.createElement("template"),n.innerHTML=`<smart-button class="smart-editor-window-button primary replace replace-all smart-hidden"\n animation="${a}" theme="${o}" ${i?"right-to-left":""}>\n </smart-button>\n <smart-button class="smart-editor-window-button ok primary"\n animation="${a}" theme="${o}" ${i?"right-to-left":""}>\n </smart-button>\n <smart-button class="smart-editor-window-button cancel"\n animation="${a}" theme="${o}" ${i?"right-to-left":""}>\n </smart-button>`),n}_positionWindow(){const e=this,t=e.getShadowRootOrBody(),a=e.$.window;if(!a||!t.contains(a))return;const o=e.getBoundingClientRect();a.opened||(a.style.left=a.style.top=""),a.style.left=Math.max(o.left+window.pageXOffset,o.left+window.pageXOffset+o.width/2-a.offsetWidth/2)+"px",a.style.top=Math.max(o.top+window.pageYOffset,o.top+window.pageYOffset+o.height/2-a.offsetHeight/2)+"px"}_windowChangeHandler(e){const t=this,a=e.detail,o=t.$.window._target.item;let i=(e.originalEvent||e).target;const n=i.closest(".smart-editor-window-editor");if(!i.hasAttribute("item-editor")||!o||!n)return;const r=n.getAttribute("type");if(o.name.indexOf("link")>0&&"target"===r&&i instanceof Smart.Input)i.readonly=!!a.value.length;else if(t._windowEditors&&o.name.indexOf("findandreplace")>-1)if("results"===r&&i instanceof Smart.ListBox)t._handleMarkerSelection(e.target);else if("matchCase"===r&&i instanceof Smart.CheckBox){const e=n.parentElement.querySelector('.smart-editor-window-editor[type="find"] [item-editor]');e&&t._findMatches(e.value)}}_windowClickHandler(e){const t=this;let a=(e.originalEvent||e).target;a.shadowRoot&&(a=(e.originalEvent||e).composedPath()[0]);const o=t.$.window,i=o._target,n=a.closest(".smart-editor-window-button");if(o&&n&&i){if("findandreplace"===i.item.name){const e=n.classList,a=n.classList.contains("replace-all");if(a||e.contains("ok"))return void t._replaceMatches(o._target.item,a)}else if(n.classList.contains("ok")&&!1===t._updateEditorViaWindow(i.item))return;o.close(),delete o._target}}_windowCloseHandler(e){const t=this,a=e.target;if(!a.classList.contains("smart-editor-window"))return;const o=t.$window;if(o){t.$.fireEvent("dialogClose",{target:e.target,item:e.target._target.item}),o.unlisten("close"),o.unlisten("click"),o.unlisten("change"),o.unlisten("keydown"),o.unlisten("uploadCompleted"),o.unlisten("uploadError"),t.hasAttribute("aria-owns")&&t.removeAttribute("aria-owns"),t.hasAnimation||(a.remove(),t._setAriaOwns(a));const i=a._target,n=i.itemTarget;if("findandreplace"===i.item.name&&t._findMatches(""),t._focusEditableElement(),"blockHtml"===t.editMode&&(t._editorBlocks=t.$.editableElement.querySelectorAll(".smart-editor-block")),n&&["img","th","td","table"].indexOf(n.nodeName.toLowerCase())>-1)return void t._setResizeFrame(n)}}_windowKeyDownHandler(e){const t=this,a=t.$.window;if("Enter"!==e.key||!a._target)return;const o=a._target.item,i=a.getRootNode().activeElement;if(o&&i.closest(".smart-editor-window-editor")){if(!1===t._updateEditorViaWindow(o))return;e.stopPropagation(),e.preventDefault(),a.close(),delete a._target}}_windowKeyUpHandler(e){const t=this,a=e.target;if(a.closest('.smart-editor-window-editor[type="find"]')){const e=a.closest("[item-editor]");if(e){const a=t.findAndReplaceTimeout;if(clearTimeout(t._findAndReplaceTimeout),"html"!==t.editMode)return;a?t._findAndReplaceTimeout=setTimeout((()=>t._findMatches(e.value)),a):t._findMatches(e.value)}}}_windowOpenHandler(e){const t=this,a=e.target;if(!a.classList.contains("smart-editor-window"))return;const o=t.$window;if(o){const i=a._target.item;if(t._setAriaOwns(a),t.$.fireEvent("dialogOpen",{target:e.target,item:i}),o.unlisten("open"),"findandreplace"===i.name){const e=a.querySelector('.smart-editor-window-editor[type="find"] [item-editor]');t._findMatches(e?e.value:"")}}}_windowTransitionendHandler(e){const t=this,a=e.target;a.classList.contains("smart-editor-window")&&(a.opened||"visibility"!==e.propertyName||(t.$window.unlisten("transitionend"),t.$.window.remove(),t._setAriaOwns(a)))}_updateEditorViaWindow(e){const t=this;if(!e||!t._windowEditors)return;const a=t.$.iframe,o=t.$.editableElement;let i,n;t.$.contentContainer.contains(o.getRootNode().activeElement)||t._focusEditableElement(),a?(i=a.contentWindow,n=i.getSelection()):(i=window,n=window.getSelection());const r=t._windowEditors[e.name],l=t._getSelectionRange();let s;if(r&&!t.$.fireEvent("actionStart",{name:e.name}).defaultPrevented){switch(l instanceof i.Range&&(n.removeAllRanges(),n.addRange(l)),e.name){case"editlink":case"createlink":case"hyperlink":s=t._handleLinksInsert(e);break;case"image":s=t._handleImageInsert(e);break;case"table":t._handleTableInsert(t._getItemOptionsViaWindow(e));break;case"paste":t._handlePasteViaWindow(e);break;case"video":s=t._handleVideoInsert(e);break;case"file":s=t._handleFileInsert(e)}return t.$.fireEvent("actionEnd",{name:e.name}),s?(s(),!1):void 0}}_focusFirstInputCallback(e,t){const a=this._windowEditors[e];if(a)return()=>{const e=a.querySelector(`.smart-editor-window-editor[type="${t}"] .smart-input[item-editor]`);e&&e.focus({preventScroll:!0})}}_fileUploadCompletedHandler(e){const t=this.$.window;let a;t&&t.opened&&t._target&&(a=t._target.item),e.stopPropagation(),this.$.fireEvent("imageUploadSuccess",Object.assign({target:e.target,toolbarItem:a},e.detail));const o=e.detail.fileURL,i=e.detail.serverResponse,n=t.querySelector('[type="url"] [item-editor]');o?(n.value=o,n._details=e.detail):i&&(Array.isArray(i)?e.detail.serverResponse[0].file_url?n.value=e.detail.serverResponse[0].file_url:e.detail.serverResponse[0].fileURL&&(n.value=e.detail.serverResponse[0].fileURL):e.detail.serverResponse.file_url?n.value=e.detail.serverResponse.file_url:e.detail.serverResponse.fileURL&&(n.value=e.detail.serverResponse.fileURL))}_fileUploadErrorHandler(e){const t=this.$.window;let a;t&&t.opened&&t._target&&(a=t._target.item),e.stopPropagation(),this.$.fireEvent("imageUploadFailed",Object.assign({target:e.target,toolbarItem:a},e.detail))}_replaceMatches(e,t){const a=this,o=a.$.editableElement;if(!e||!a._windowEditors||"html"!==a.editMode||o.classList.contains("smart-hidden"))return;const i=a._getItemOptionsViaWindow(e),n=a._windowEditors[e.name],r=n.querySelector('.smart-editor-window-editor[type="results"] smart-list-box[item-editor]'),l=n.querySelector('.smart-editor-window-editor[type="results"] label'),s=r.selectedIndexes;if(!i||!s||!s.length)return;const d=i.replaceWith,c=Array.from(o.querySelectorAll(".find-and-replace-match"));for(let e=0,a=c.length;e<a;e+=1){const a=c[e];(t||s.indexOf(e)>-1)&&(a.outerHTML=d)}t?r.dataSource=[]:s.forEach((e=>r.removeAt(e))),a._setFindAndReplaceLabel(l,r)}_findMatches(e){const t=this,a=t.$.editableElement,o=t._windowEditors,i=o?o.findandreplace:void 0,n=i.querySelector('.smart-editor-window-editor[type="results"] smart-list-box[item-editor]'),r=i.querySelector('.smart-editor-window-editor[type="results"] label'),l=i.querySelector('.smart-editor-window-editor[type="matchCase"] smart-check-box[item-editor]'),s=t.$.window.querySelectorAll(".smart-editor-window-button.replace");n&&"smart-list-box"===n.nodeName.toLowerCase()&&(n.dataSource=[]),t._findAndReplaceTimeout&&(clearTimeout(t._findAndReplaceTimeout),delete t._findAndReplaceTimeout);const d=Array.from(a.querySelectorAll(".find-and-replace-match"));for(let e=0,t=d.length;e<t;e+=1){const t=d[e];t.outerHTML=t.textContent}if("html"===t.editMode)if(e){n.dataSource=t._getFindMarkers(a,new RegExp(e,"gm"+(l.checked?"":"i")),[]),n.select("0"),t._setFindAndReplaceLabel(r,n);for(let e=0,t=s.length;e<t;e+=1)s[e].disabled=!1}else{t._setFindAndReplaceLabel(r);for(let e=0,t=s.length;e<t;e+=1)s[e].disabled=!0}}_clearSearchToolbar(){const e=this,t=e._searchToolbar;t&&!t.classList.contains("smart-visibility-hidden")&&(t.value="",delete e._lastSearchQuery)}_applySearching(e){const t=this,a=t.$.editableElement;if(t._lastSearchQuery===e||a.classList.contains("smart-hidden"))return;const o=t.$.contentContainer.querySelector(".smart-search-input-container");let i;t._findAndReplaceTimeout&&(clearTimeout(t._findAndReplaceTimeout),delete t._findAndReplaceTimeout);const n=Array.from(a.querySelectorAll(".find-and-replace-match"));for(let e=0,t=n.length;e<t;e+=1){const t=n[e];t.outerHTML=t.textContent}if("html"===t.editMode){if(e){i=t._getFindMarkers(a,new RegExp(e,"gmi"),[]).length;const o=a.querySelector(".find-and-replace-match");o&&(o.classList.add("selected"),t._scrollToMarker(o))}o&&(o.setAttribute("matches",i||0),o.setAttribute("selected",i?1:0)),t._lastSearchQuery=e}}_scrollToMarker(e){const t=this,a=t._searchToolbar,o=a&&!t._searchToolbar.classList.contains("smart-visibility-hidden")?a.offsetHeight:0,i=t.$.editableElement,n=i.getBoundingClientRect(),r=e.getBoundingClientRect(),l=i.scrollLeft,s=i.scrollTop,d=n.height,c=n.width,m=r.height,u=r.width,p=r.top-n.top+s,b=r.left-n.left+l;s+o>p||l>b?i.scrollTo(b-c,p-o-10):(s+d<p+m||l+c<b+u)&&i.scrollTo(b+u-c,p+m-d)}_setFindAndReplaceLabel(e,t){if(!e)return;const a=t?t.items.length:0;if(!t||!a)return e.removeAttribute("matches"),void e.removeAttribute("selected");if(e){const o=t.selectedIndexes[0];e.setAttribute("matches",a),e.setAttribute("selected",o?o+1:1)}}_getFindMarkers(e,t,a){const o=this,i=Array.from(e.childNodes);for(let e=0,n=i.length;e<n;e+=1){const n=i[e];if(n.childElementCount)o._getFindMarkers(n,t,a);else if(n.textContent){const e=document.createDocumentFragment(),o=n.textContent;let i,r=0;if(o.matchAll)i=Array.from(o.matchAll(t));else{let e;for(i=[];e=t.exec(o);)i.push(e)}if(i.forEach((t=>{const o=t.input,i=t.index,n=t[0],l=o.substring(r,i),s=a.length,d=document.createElement("span");l.length&&e.appendChild(document.createTextNode(l)),d.classList.add("find-and-replace-match"),d.setAttribute("match-id",s),d.textContent=n,e.appendChild(d);const c=o.substring(Math.max(0,i-10),i),m=o.substr(i+n.length,10);a.push({label:`${i>0?"...":""}${c}<b>${n}</b>${m}${i<o.length-1?"...":""}`,value:s}),r=i+n.length})),!e.childElementCount)continue;const l=n.textContent.substr(r);l&&e.appendChild(document.createTextNode(l)),n.nodeType===Node.TEXT_NODE?(n.parentElement.insertBefore(e,n),n.remove()):(n.innerHTML="",n.appendChild(e))}}return a}_handleMarkerSelection(e){const t=this,a=e.selectedValues[0],o=t.$.editableElement.querySelectorAll(`.find-and-replace-match.selected, .find-and-replace-match[match-id="${a}"]`);let i;for(let e=0,t=o.length;e<t;e+=1){const t=o[e];t.getAttribute("match-id")===a?(t.classList.add("selected"),i=t):t.classList.remove("selected")}i&&t._scrollToMarker(i);const n=t._windowEditors,r=n?n.findandreplace:void 0,l=r?r.querySelector('.smart-editor-window-editor[type="results"] label'):void 0;if(l){const t=e.selectedIndexes;l.setAttribute("selected",t.length?t[0]+1:0)}}_handleImageInsert(e){const t=this,a=t._getItemOptionsViaWindow(e),o=t.$.window;if(!o)return;"blockHtml"===t.editMode&&t._insertBlock();let i,n,r,l,s,d=o._target.itemTarget;if(a.file.length?(l=a.file[0],i=URL.createObjectURL(l)):a.url&&(i=a.url+""),!i&&a)return t._focusFirstInputCallback(e.name,"url");if("markdown"===t.editMode)return n=a.title?` "${a.title}"`:"",void t._insertMarkDown(`![${a.alt}](${i}${n})`);const c=t.$.iframe,m=t.$.editableElement,u=c?c.contentDocument:document;if(!d||"img"!==d.nodeName.toLowerCase()){const e=t.id+"newImage"+Math.random().toString(36).substr(2,5);s=u.execCommand("insertHTML",!1,`<img id="${e}"></img>`),d=m.querySelector("#"+e)}if(d&&"img"===d.nodeName.toLowerCase()){const e=a.display&&"inline"===a.display.toLowerCase()?"inline":"block",o=a.width+"",n=a.height+"";if(t._handleImgCaption(d,a),s&&(d.id=""),URL.revokeObjectURL(d.src),d.src=i,l&&(d.file=l,"base64"===t.imageFormat)){const e=new FileReader;e.readAsDataURL(l),e.onload=()=>d.src=e.result}if(t.uploadUrl&&t._fileUpload&&(d.name=i.replace(t.uploadUrl+"/",""),!t.autoUpload)){const e=e=>{t.$.fireEvent("imageUploadSuccess",e.detail);const a=e.detail.fileURL,o=e.detail.serverResponse;a?d.src=a:o&&(Array.isArray(o)?e.detail.serverResponse[0].file_url?d.src=e.detail.serverResponse[0].file_url:e.detail.serverResponse[0].fileURL&&(d.src=e.detail.serverResponse[0].fileURL):e.detail.serverResponse.file_url?d.src=e.detail.serverResponse.file_url:e.detail.serverResponse.fileURL&&(d.src=e.detail.serverResponse.fileURL))};t._fileUpload.onuploadcompleted=e,t._fileUpload.onuploaderror=e=>{console.error(e.detail)},t._fileUpload.uploadAll()}if(d.removeAttribute("width"),d.removeAttribute("height"),d.style.width=o&&"auto"!==o?parseFloat(o)+(o.indexOf("%")>-1?"%":"px"):"",d.style.height=n&&"auto"!==n?parseFloat(n)+(n.indexOf("%")>-1?"%":"px"):"",a.alt&&(d.alt=a.alt),a.title&&(d.title=a.title),a.alignment){const e=a.alignment.toLowerCase();r=e.indexOf("left")>-1?"left":e.indexOf("right")>-1?"right":"center"}d.setAttribute("resizable",a.resizable),d.setAttribute("draggable",a.draggable);const c=d.closest(".smart-editor-image-container");c?(c.setAttribute("alignment",r),c.setAttribute("display",e),d.removeAttribute("alignment"),d.removeAttribute("display")):(d.setAttribute("alignment",r),d.setAttribute("display",e))}}_handleFileInsert(e){const t=this,a=t._getItemOptionsViaWindow(e),o=t.$.window;if(!o)return;"blockHtml"===t.editMode&&t._insertBlock();let i,n,r,l,s=o._target.itemTarget;if(a.file.length?(r=a.file[0],i=URL.createObjectURL(r)):a.url&&(i=a.url+""),!i&&a)return t._focusFirstInputCallback(e.name,"url");if("markdown"===t.editMode)return n=a.title?` "${a.title}"`:"",void t._insertMarkDown(`![''](${i}${n})`);const d=t.$.iframe,c=t.$.editableElement,m=d?d.contentDocument:document;if(!s||"a"!==s.nodeName.toLowerCase()){const e=t.id+"newImage"+Math.random().toString(36).substr(2,5);t.$.contentContainer.dispatchEvent(new KeyboardEvent("keydown",{key:"Enter"})),l=m.execCommand("insertHTML",!1,`<a type=${r.type} href="${i}" id="${e}"><span></span>${r.name}</a>`),s=c.querySelector("#"+e)}if(s&&"a"===s.nodeName.toLowerCase()){if(l&&(s.id=""),URL.revokeObjectURL(s.src),s.src=i,r&&(s.file=r,"base64"===t.imageFormat)){const e=new FileReader;e.readAsDataURL(r),e.onload=()=>s.src=e.result}if(t.uploadUrl&&t._fileUpload&&(s.name=i.replace(t.uploadUrl+"/",""),!t.autoUpload)){const e=e=>{t.$.fireEvent("imageUploadSuccess",e.detail);const a=e.detail.fileURL,o=e.detail.serverResponse;a?s.src=a:o&&(Array.isArray(o)?e.detail.serverResponse[0].file_url?s.src=e.detail.serverResponse[0].file_url:e.detail.serverResponse[0].fileURL&&(s.src=e.detail.serverResponse[0].fileURL):e.detail.serverResponse.file_url?s.src=e.detail.serverResponse.file_url:e.detail.serverResponse.fileURL&&(s.src=e.detail.serverResponse.fileURL))};t._fileUpload.onuploadcompleted=e,t._fileUpload.onuploaderror=e=>{console.error(e.detail)},t._fileUpload.uploadAll()}s.classList.add("smart-editor-file"),s.href=s.src,r.name.indexOf(".pdf")>=0?s.classList.add("smart-icon-pdf"):r.name.indexOf(".png")>=0||r.name.indexOf(".jpg")>=0||r.name.indexOf(".jpeg")>=0||r.name.indexOf(".gif")>=0?s.classList.add("smart-icon-image"):r.name.indexOf(".tsv")>=0||r.name.indexOf(".txt")>=0||r.name.indexOf(".csv")>=0?s.classList.add("smart-icon-text"):r.name.indexOf(".xls")>=0||r.name.indexOf(".xlsx")>=0?s.classList.add("smart-icon-excel"):r.name.indexOf(".ppt")>=0?s.classList.add("smart-icon-powerpoint"):r.name.indexOf(".zip")>=0||r.name.indexOf(".rar")>=0||r.name.indexOf(".7z")>=0?s.classList.add("smart-icon-archive"):r.name.indexOf(".doc")>=0||r.name.indexOf(".docx")>=0?s.classList.add("smart-icon-word"):r.name.indexOf(".mp3")>=0?s.classList.add("smart-icon-music"):r.name.indexOf(".mp4")>=0||r.name.indexOf(".avi")>=0||r.name.indexOf(".mov")>=0||r.name.indexOf(".mp4")>=0||r.name.indexOf(".mpeg")>=0||r.name.indexOf(".webm")>=0?s.classList.add("smart-icon-video"):s.classList.add("smart-icon-file"),a.title&&(s.title=a.title)}}_handleVideoInsert(e){const t=this,a=t._getItemOptionsViaWindow(e),o=t.$.window;if(!o)return;"blockHtml"===t.editMode&&t._insertBlock();let i,n,r,l,s=o._target.itemTarget;if(a.file.length?(r=a.file[0],i=URL.createObjectURL(r),s&&"video"!==s.nodeName.toLowerCase()&&(s.remove(),s=void 0)):(a.src||a.videoUrl)&&(i=(a.src||a.videoUrl)+"",s&&"iframe"!==s.nodeName.toLowerCase()&&(s.remove(),s=void 0)),s&&s.file&&(r=s.file),!i&&!r&&a)return t._focusFirstInputCallback(e.name,"src");if("markdown"===t.editMode)return n=a.title?` "${a.title}"`:"",void t._insertMarkDown(`[![${a.alt}](${i||a.thumbnail||""})](${a.videoUrl} ${n})`);const d=t.$.iframe,c=t.$.editableElement,m=d?d.contentDocument:document;if(!r||s&&"video"===s.nodeName.toLowerCase()){if(!(r||s&&"iframe"===s.nodeName.toLowerCase())){const e=t.id+"newVideo"+Math.random().toString(36).substr(2,5);l=m.execCommand("insertHTML",!1,`<iframe id="${e}" frameborder="0" allowfullscreen></iframe>`),s=c.querySelector("#"+e)}}else{const e=t.id+"newVideo"+Math.random().toString(36).substr(2,5);l=m.execCommand("insertHTML",!1,`<video id="${e}"></video>`),s=c.querySelector("#"+e)}if(s){if(l&&s.removeAttribute("id"),URL.revokeObjectURL(s.src),s.controls=!0,s.frameborder=0,s.allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",t._handleVideoCaption(s,a),void 0!==a.width){const e=a.width+"";s.style.width=e?e+(e.indexOf("%")<0?"px":""):""}if(void 0!==a.height){const e=a.height+"";s.style.height=e?e+(e.indexOf("%")<0?"px":""):""}if(r){if(s.file===r)return;if(s.file=r,"base64"===t.imageFormat){const e=new FileReader;e.readAsDataURL(r),e.onload=()=>s.src=e.result}}else s.src!==i&&(s.src=i)}}_insertMarkDown(e,t,a){const o=this;if("markdown"!==o.editMode)return;const i=o.$.input,n=o._getSelectionRange(),r=n.selectionStart,l=n.selectionEnd;let s,d=i.value;if(void 0!==r&&r!==l&&(s=d.slice(r,l)),a){let t=d.lastIndexOf("\n",r-1)+1;for(;" "===d[t+1];)t++;i.value=d.slice(0,t)+e+d.slice(t)}else i.value=d.slice(0,i.selectionStart)+e+d.slice(i.selectionEnd);void 0!==r&&(void 0===t&&(t=r+e.length),s?a?o._setSelectionRange(i,r+e.length,l+e.length):(d=i.value,i.value=d.slice(0,t)+s+d.slice(t),o._setSelectionRange(i,t,t+s.length)):o._setSelectionRange(i,t,t)),o._refreshMarkdownPreview()}_removeMarkDown(e,t,a){const o=this,i=o.$.input,n=i.value,r=o._getSelectionRange(),l=r.selectionStart,s=r.selectionEnd,d=e.length;i.value=n.slice(0,t)+n.slice(t+d),o._setSelectionRange(i,l-d,s-d),a||o._refreshMarkdownPreview()}_handleLinksInsert(e){const t=this,a=t.$.window,o=t.editMode,i=t._getItemOptionsViaWindow(e);if(!i.address)return t._focusFirstInputCallback(e.name,"address");if("markdown"===o){let e;return e=i.title?`[${i.text}](${i.address}, "${i.title}")`:`[${i.text}](${i.address})`,void t._insertMarkDown(e)}const n=t.$.iframe,[r,l]=n?[n.contentDocument,n.contentWindow]:[document,window],s=l.getSelection();let d,c,m=s.anchorNode?s.anchorNode.parentElement:void 0,u=a&&a._target?a._target.itemTarget:void 0;u&&"img"===u.nodeName.toLowerCase()?(d=a._target.itemTarget,m=d.parentElement,m&&"a"===m.nodeName.toLowerCase()||(m=document.createElement("a"),d.parentElement.insertBefore(m,d),m.appendChild(d))):m=s.anchorNode?s.anchorNode.parentElement:void 0,i.address&&"a"!==m.nodeName.toLowerCase()&&(c=r.execCommand("createLink",!1,i.address),m=s.anchorNode.parentElement),"a"===m.nodeName.toLowerCase()&&(i.address?c||m.setAttribute("href",i.address):m.setAttribute("href",""),i.text?m.textContent=i.text:m.innerHTML||(m.textContent=i.address||""),m.title=i.title||"",m.target=i.target||"",d||s.selectAllChildren(m))}_refreshMarkdownPreview(){const e=this,t=e.$.input;if(e.$.contentContainer.hasAttribute("split-mode")){let a=t.value;e.$.editableElement.innerHTML=window.marked?window.marked(a):a}}_handleImgCaption(e,t){const a=this;if(!t)return;let o,i=e.closest(".smart-editor-image-container");const n=e.nodeName.toLowerCase(),r="video"===n||"iframe"===n&&e.src.indexOf("/embed")>-1;if(t.caption||r){if(i||(i=document.createElement("span"),i.classList.add("smart-editor-image-container"),i.setAttribute("draggable",!1),i.setAttribute("contenteditable",!1),e.hasAttribute("alignment")&&i.setAttribute("alignment",e.getAttribute("alignment")),e.hasAttribute("display")&&i.setAttribute("display",e.getAttribute("display")),e.parentElement.insertBefore(i,e),i.appendChild(e)),i.classList[r?"add":"remove"]("smart-editor-video-container"),o=i.querySelector(".smart-editor-image-caption"),o||(o=document.createElement("span"),o.setAttribute("contenteditable",!0),o.classList.add("smart-editor-image-caption"),i.appendChild(o)),o.textContent=t.caption,t.focusCaption)return delete a._toolbarItemClick,a._setSelectionRange(o),a._setResizeFrame(),void a.$.editableElement.scrollTo(o.offsetLeft,o.offsetTop)}else!t.caption&&i&&(i.hasAttribute("alignment")&&e.setAttribute("alignment",i.getAttribute("alignment")),i.hasAttribute("display")&&e.setAttribute("display",i.getAttribute("display")),i.parentElement.insertBefore(e,i),i.remove());a._resizeFrameObj&&a._resizeFrameObj.target&&a._setResizeFrame(a._resizeFrameObj.target,!0)}_handleVideoCaption(e,t){const a=this,o=e?e.nodeName.toLowerCase():void 0;if(!t||"video"!==o&&"iframe"!==o)return;let i=e.closest(".smart-editor-video-container");if(i||(i=document.createElement("span"),i.classList.add("smart-editor-image-container","smart-editor-video-container"),i.setAttribute("contenteditable",!1),e.parentElement.insertBefore(i,e),i.appendChild(e)),i.setAttribute("resizable",t.resizable),!1===t.draggable?i.setAttribute("draggable",!1):i.removeAttribute("draggable"),t.title&&(e.title=t.title),t.alignment){let e=t.alignment.toLowerCase();e=e.indexOf("left")>-1?"left":e.indexOf("right")>-1?"right":"center",i.setAttribute("alignment",e)}if(t.display){const e="inline"===t.display.toLowerCase()?"inline":"block";i.setAttribute("display",e)}if(t.caption){let e=i.querySelector(".smart-editor-image-caption");if(e||(e=document.createElement("span"),e.setAttribute("contenteditable",!0),e.classList.add("smart-editor-image-caption"),i.appendChild(e)),e.textContent=t.caption,t.focusCaption)return delete a._toolbarItemClick,a._setSelectionRange(e),a._setResizeFrame(),void a.$.editableElement.scrollTo(e.offsetLeft,e.offsetTop)}else if(!t.caption){let e=i.querySelector(".smart-editor-image-caption");e&&e.remove()}a._resizeFrameObj&&a._resizeFrameObj.target&&a._setResizeFrame(a._resizeFrameObj.target,!0)}_handleTableInsert(e){const t=this,a=t.editMode;if(!e)return;if("markdown"===a)return void t._insertTableMarkdown(e);"blockHtml"===t.editMode&&t._insertBlock();const o=t._getSelectionRange();let i,n,r,l;if(e.cells){const t=e.cells;[r,l]=[t[1],t[0]]}else{let t=o.startContainer;[r,l]=[parseInt(e.cols),parseInt(e.rows)],t.nodeType===Node.TEXT_NODE&&(t=t.parentElement),i=t&&t.closest&&t.closest(".smart-editor-editable table")}if(!i){const e=t.$.editableElement,a=t.$.iframe,r=(a?a.contentWindow:window).getSelection();r.removeAllRanges(),r.addRange(o);const l=t.id+"newTable"+Math.random().toString(36).substr(2,5);"blockHtml"===t.editMode&&t._currentBlock?(t._currentBlock.innerHTML+=`<table id="${l}"><tbody></tbody></table>`,n=!0):n=(a?a.contentDocument:document).execCommand("insertHTML",!1,`<table id="${l}"><tbody></tbody></table>`),i=e.querySelector("#"+l)}if(i&&"table"===i.nodeName.toLowerCase()){let a,o=i.querySelector("tbody");for(o?a=Array.from(o.children):(i.innerHTML="<tbody></tbody>",o=i.firstElementChild,a=[]);a.length>l;)a.pop().remove();for(let e=a.length,t=l;e<t;e+=1)a.push(document.createElement("tr"));for(let e=0,t=a.length;e<t;e+=1){const t=a[e],i=Array.from(t.children);for(;i.length>r;)i.pop().remove();for(let e=0,a=r;e<a;e+=1){let a=i[e];a||(a=t.appendChild(document.createElement("td")))}t.parentElement||o.appendChild(t)}void 0===e.tableheader?e.tableheader=!!i.querySelector("th"):void 0===e.altrows?e.altrows=i.hasAttribute("alternation"):void 0===e.dashedborders?e.dashedborders=i.hasAttribute("dashed-borders"):void 0===e.resizable&&(e.resizable="false"!==i.getAttribute("resizable")),t._handleTableHeader(i,e.tableheader),e.altrows?i.setAttribute("alternation",""):i.removeAttribute("alternation"),e.dashedborders?i.setAttribute("dashed-borders",""):i.removeAttribute("dashed-borders");const s=e.width,d=e.height;i.style.width=s?s+(s.indexOf("%")<0?"px":""):"",i.style.height=d?d+(d.indexOf("%")<0?"px":""):"",n&&i.removeAttribute("id"),i.setAttribute("aria-rowcount",l),i.setAttribute("aria-colcount",r),i.setAttribute("resizable",e.resizable)}t._setResizeFrame(i)}_insertTableMarkdown(e){const t=this,a=e.cells,[o,i]=a?[a[1],a[0]]:[parseInt(e.cols),parseInt(e.rows)],n=t.localize("alphabet"),r=t.localize("header"),l=t.localize("column");let s="";if(!1!==e.tableheader){let e="",t=Math.max(3,r.length)+3;for(;t>0;)e+="-",t--;for(let e=1;e<=o;e+=1)s+=`| ${r} ${e} `;s+="|\n";for(let t=0;t<o;t++)s+=`|${e} `;s+="|\n"}for(let e=0;e<i;e++){const t=n[Math.max(0,e-1)%n.length].toUpperCase();for(let e=1;e<=o;e+=1)s+=`| ${l} ${t} ${e} `;s+="|\n"}t._insertMarkDown(s)}_handleTableSelection(e){const t=this,a=t.$.editableElement;if(t._tableCell&&t._tableCell.removeAttribute("selected"),"false"!==a.getAttribute("contenteditable"))return e&&["th","td"].indexOf(e.nodeName.toLowerCase())>-1?(t._tableCell=e,void e.setAttribute("selected","")):void delete t._tableCell}_getItemOptionsViaWindow(e){const t=this._windowEditors[e.name];if(!t)return;const a=t.children;let o={};for(let e=0,t=a.length;e<t;e+=1){const t=a[e].getAttribute("type"),i=a[e].querySelector("[item-editor]");let n;if(t){if(i instanceof Smart.Input)if(void 0===i.$.input.dataValue&&i.dataSource&&i.dataSource.length){const e=i.dataSource[0];n="string"==typeof e?e:e.value||e.label}else n=i.$.input.dataValue||i.value;else i instanceof Smart.CheckBox||i instanceof Smart.RadioButton?n=i.checked:i instanceof Smart.FileUpload?n=i.value:i instanceof Smart.ListBox&&(n=i.selectedIndexes);o[t]=n}}return o}_closeToolbarItemDropDown(e){const t=this,a=()=>{e.opened||e.remove()};e&&(e.opened?(e.hasAnimation&&(e.removeEventListener("transitionend",a),e.addEventListener("transitionend",a,{once:!0})),e.close(),t._setAriaOwns(e)):a())}_openToolbarItemDropDown(e,t){const a=this,o=e.getBoundingClientRect();a._setupDropDown(e,t),t.style.width=o.width+"px",t.style.height=o.height+"px",e.contains(t)||e.appendChild(t),t.open(),a._setAriaOwns(t),a._setAriaControls(e,t)}_setupDropDown(e,t){const a=this,o=a.$.inlineToolbar,i=o&&o.contains(e)?a._inlineToolbarItemsObj:a._toolbarItemsObj,n=i?i[e.getAttribute("item-name")]:void 0;let r;if(n&&(r=n.dataSource),r||(r=[]),t instanceof Smart.ColorInput?(t.dropDownClassList=["smart-editor-color-input"],t.additionalColors=["#FF9EB7","#FFCFC9","#FFD66D","#FFEBB6","#93DF89","#D1F7C4","#9DC7FF","#D0F0FD","#CDAFFF","#ECE1FD","#FA9DE2","#FFDAF6","#CBCBCB","#EDEDED","#FFFFFF",""]):(t.dropDownClassList=["smart-editor-input"],t.dropDownHeight=310),t.classList.add("smart-editor-item-drop-down"),t.readonly=!0,t.dataSource=r,t.dropDownOpenMode="manual",t.dropDownButtonPosition=a.rightToLeft?"left":"right",void 0!==n.value){const e=n.name;t.value=e.indexOf("table")>-1||e.indexOf("paste")>-1?"":n.value+""}else t.value="";t.dropDownOpenPosition="auto"}_toggleToolbar(e){const t=this,a=t.$.toolbar,o=t.$.contentContainer,i=t.toolbarViewMode,n="toggle"===i,r=t.$.toolbarToggleButton,l=t.$.toolbarItemsPrimary,s=t.hasAnimation;a.style.transition=s&&n?"none":"",a.style.height="";const d=a.offsetHeight,c=o.offsetHeight;if(e&&"toggle"===i){if(r.removeAttribute("checked"),r.setAttribute("aria-pressed",!1),!a.hasAttribute("expanded"))return void(a.style.transition="");a.removeAttribute("expanded")}else{if(r.setAttribute("checked",""),r.setAttribute("aria-pressed",!0),a.hasAttribute("expanded"))return a.style.transition="",void(t.$.toolbarItemsSecondary.innerHTML&&t._refreshToolbarItems());"scroll"!==i?a.setAttribute("expanded",""):a.removeAttribute("expanded")}if(t._refreshToolbarItems(),"menu"!==t.toolbarMode)return void(a.hasAttribute("expanded")?(l.querySelector(".smart-editor-toolbar-tab[checked]")||t._selectToolbarTab(l.firstElementChild),t._toggleSecondaryToolbar(!0)):(t._selectToolbarTab(null),t._toggleSecondaryToolbar()));if(!n)return;const m=a.offsetHeight,u=t.$.inlineToolbar;u&&u.visible&&u.reposition(),t._resizeFrameObj&&t._setResizeFrame(t._resizeFrameObj.target),a.style.height=d+"px",o.style.height=c+"px",s?requestAnimationFrame((()=>{a.style.transition="",a.style.height=m+"px",o.style.height=c+d-m+"px",requestAnimationFrame((()=>a.style.height=o.style.height=""))})):(a.style.transition="",a.style.height=m+"px",o.style.height=c+d-m+"px",requestAnimationFrame((()=>a.style.height=o.style.height="")))}_predefPropertyGetter(e="value"){const t=this;Object.defineProperty(t,e,{get:function(){return t.context===t?t.properties[e].value:t._getCurrentValue()},set(a){t._properties[e].value=t._getCurrentValue(),t.updateProperty(t,t._properties[e],a)}})}_getCurrentValue(){const e=this;if("markdown"===e.editMode)return e.$.input.value;let t=e.$.editableElement.innerHTML;return e.enableHtmlEncode&&(t=t.replaceAll("<","&lt;").replaceAll(">","&gt;")),t=t.replaceAll("var(--smart-background-color)","inherit"),t=t.replaceAll("var(--smart-font-weight)","inherit"),t}_getInputValue(e,t){const a=this,o=a.$.input;return void 0===e&&(e=o.value),e=(e=(e=!t&&a.enableHtmlEncode?e.replaceAll("<","&lt;").replaceAll(">","&gt;"):e.replaceAll("&lt;","<").replaceAll("&gt;",">")).replaceAll("var(--smart-background-color)","inherit")).replaceAll("var(--smart-font-weight)","inherit"),a.content_css&&(e=e.replaceAll("<style>"+a.content_css+"</style>","")),e}_handleEditMode(e){const t=this,a=t.$.input,o=t.$.editableElement,i=t.editMode,n=t._toolbarItemsObj.sourcecode,r=!!n&&n.value;t._closePopups(),"html"===e?r?a.value=o.innerHTML:o.innerHTML=a.value:"markdown"===e&&(r?o.innerHTML=window.marked?window.marked(a.value):a.value:a.value=o.textContent,t._closeSearchToolbar()),t.$.contentContainer.hasAttribute("split-mode")||("markdown"===i?r?(a.classList.add("smart-hidden"),o.classList.remove("smart-hidden")):(a.classList.remove("smart-hidden"),o.classList.add("smart-hidden")):r?(a.classList.remove("smart-hidden"),o.classList.add("smart-hidden")):(a.classList.add("smart-hidden"),o.classList.remove("smart-hidden"))),t.readonly||t.disableEditing||t.$.editableElement.setAttribute("contenteditable","markdown"!==i)}_handleInputContent(e,t){const a=this,o=a.$.editableElement,i=a.$.input,n=a.editMode;if(!a.isRendered&&a.autoLoad){const e=window.localStorage.getItem("smartEditor"+a.id);e&&a.set("value",e)}const r=a.value;void 0===t&&r&&(t=r),void 0!==t?"html"===n||"blockHtml"===n?a.$.editableElement.innerHTML=t:a.$.input.value=t:t||"markdown"!==n||(a.$.input.value=a.$.editableElement.textContent),a.$.contentContainer.hasAttribute("split-mode")?"markdown"===n?o.innerHTML=window.marked?window.marked(i.value):i.value:i.value=o.innerHTML.trim():a.classList.contains("preview-mode")&&("markdown"===n?o.innerHTML=window.marked?window.marked(i.value):i.value:i.value=o.innerHTML),o.textContent.length&&o.innerText.length?(o.removeAttribute("show-placeholder"),a._handleContentFiltering()):o.setAttribute("show-placeholder",""),a._clearSearchToolbar()}_sanitize(e,t){return this.sanitized?t.replaceAll(/(<[\/]?script[>]?)|([on].*=['"`]?.*['"`]?)|(SRC=['"`]?javascript:['"`]?)/gim,""):t}_handleNodeContentFiltering(e){const t=this,a=t.contentFiltering;if("html"!==t.editMode&&"blockHtml"!==t.editMode)return;const o=a.tags.map((e=>e.trim())),i=a.attributes.map((e=>e.trim())),n=a.styleAttributes.map((e=>e.trim()));if(!o.length&&!i.length&&!n.length)return;const r=a.tagFilterMode,l=a.attributeFilterMode,s=a.styleAttributeFilterMode;let d=e.innerHTML;if(o.length){const e=new RegExp(/<\s*\/?\s*([a-z0-9]+).*?>/,"gmi");let t,a=[];for(;null!==(t=e.exec(d));){const e=t[1],i=o.indexOf(e)>-1;(i&&"blackList"===r||!i&&"whiteList"===r)&&a.push(t[0])}a.forEach((e=>d=d.replace(e,"")))}e.innerHTML=d;const c=t.$.editableElement.querySelectorAll("*");for(let e=0,t=c.length;e<t;e+=1){const t=c[e];if(i.length){const e=Array.from(t.attributes);for(let a=0,o=e.length;a<o;a+=1){const o=e[a].name,n=i.indexOf(o)>-1;(n&&"blackList"===l||!n&&"whiteList"===l)&&t.removeAttribute(o)}}if(n.length){const e=t.getAttribute("style");if(!e)continue;const a=e.split(";");let o=[];for(let e=0,t=a.length;e<t;e+=1){const t=a[e],i=t.indexOf(":"),r=n.indexOf(t.slice(0,i>0?i:void 0))>-1;(r&&"whiteList"===s||!r&&"blackList"===s)&&o.push(t)}a.length&&(o.length?t.setAttribute("style",o.join(";")):t.removeAttribute("style"))}}t._setCharCount()}_handleContentFiltering(){const e=this,t=e.contentFiltering;if("html"!==e.editMode&&"blockHtml"!==e.editMode)return;const a=t.tags.map((e=>e.trim())),o=t.attributes.map((e=>e.trim())),i=t.styleAttributes.map((e=>e.trim()));if(!a.length&&!o.length&&!i.length)return;const n=t.tagFilterMode,r=t.attributeFilterMode,l=t.styleAttributeFilterMode;let s=e.$.editableElement.innerHTML;if(a.length){const e=new RegExp(/<\s*\/?\s*([a-z0-9]+).*?>/,"gmi");let t,o=[];for(;null!==(t=e.exec(s));){const e=t[1],i=a.indexOf(e)>-1;(i&&"blackList"===n||!i&&"whiteList"===n)&&o.push(t[0])}o.forEach((e=>s=s.replace(e,"")))}e.$.editableElement.innerHTML=s;const d=e.$.editableElement.querySelectorAll("*");for(let e=0,t=d.length;e<t;e+=1){const t=d[e];if(o.length){const e=Array.from(t.attributes);for(let a=0,i=e.length;a<i;a+=1){const i=e[a].name,n=o.indexOf(i)>-1;(n&&"blackList"===r||!n&&"whiteList"===r)&&t.removeAttribute(i)}}if(i.length){const e=t.getAttribute("style");if(!e)continue;const a=e.split(";");let o=[];for(let e=0,t=a.length;e<t;e+=1){const t=a[e],n=t.indexOf(":"),r=i.indexOf(t.slice(0,n>0?n:void 0))>-1;(r&&"whiteList"===l||!r&&"blackList"===l)&&o.push(t)}a.length&&(o.length?t.setAttribute("style",o.join(";")):t.removeAttribute("style"))}}e._setCharCount()}_handleContextMenuItemClick(e,t){if(!t||!t.classList.contains("smart-editor-context-menu-item"))return;const a=this,o=a.$.inlineToolbar,i=t.getAttribute("value");if(!o)return;if(o.callback&&o.callback(i))return a.$.fireEvent("contextMenuItemClick",{originalEvent:e,value:i}),void a._closeContextMenu();const n=o.selector;switch(i){case"category":case"rewrite":case"continue_writing":case"fix_spelling_grammar":case"summarize":case"make_shorter":case"make_longer":case"explain":case"concise":case"professional":case"casual":case"funny":case"translate_english":case"translate_spanish":case"translate_portuguese":case"translate_italian":case"translate_dutch":case"translate_chinese":case"translate_korean":case"translate_japanese":case"translate_russian":{const e=window.getSelection();if(!e||0===e.rangeCount)return"";let t=e.focusNode;t&&("#text"===t.nodeName&&(t=t.parentElement),a._createAIPopup(t,i,((e,t)=>{if(t)a.replaceSelection(e);else{let t=window.getSelection();if(!t.rangeCount)return;let o=t.getRangeAt(0);o.collapse(!1),t.removeAllRanges(),t.addRange(o);const i=a._isControlPressed;a._isControlPressed=!0;const n=a._createEditorBlock(!1,!1);n.removeAttribute("empty"),n.removeAttribute("data-placeholder"),n.innerHTML=e,a._isControlPressed=i}a._aiPopup&&(a._aiPopup.remove(),delete a._aiPopup)})));break}case"imageProperties":a._openWindow({name:"image"},n.closest(".smart-editor-editable img"));break;case"fileProperties":a._openWindow({name:"file"},n.closest(".smart-editor-editable .file"));break;case"linkProperties":a._openWindow({name:"hyperlink"});break;case"tableProperties":a._openWindow({name:"table"},n.closest(".smart-editor-editable table"));break;case"videoProperties":{const e=n.closest(".smart-editor-video-container");if(e){const t=e.querySelectorAll(".smart-editor-video-container > video, .smart-editor-video-container > iframe");a._openWindow({name:"video"},t[0]||t[1])}break}case"insertRowAfter":case"insertRowBefore":case"deleteRow":a._handleTableRows(n.closest(".smart-editor-editable table"),{value:i});break;case"insertColumnLeft":case"insertColumnRight":case"deleteColumn":a._handleTableColumns(n.closest(".smart-editor-editable table"),{value:i});break;case"deleteImage":case"deleteTable":{const e=a._resizeFrameObj?a._resizeFrameObj.target:void 0;e&&a._deleteResizeFrameTarget(e);break}case"deleteVideo":{const e=n.closest(".smart-editor-video-container");if(e){const t=a._resizeFrameObj?a._resizeFrameObj.target:void 0;if(t===e){a._deleteResizeFrameTarget(t);break}e.remove()}break}case"userProperties":a.$.editableElement.getRootNode().execCommand("insertHTML",0,t.getAttribute("label"));break;case"createLink":a._openWindow({name:"hyperlink"},n.closest(".smart-editor-editable img"));break;case"deleteLink":a._handleLinkRemove(n);break;case"copyImage":a._handleImageCopy(n.closest(".smart-editor-editable img"));break;case"cutImage":a._handleImageCut(n.closest(".smart-editor-editable img"));break;case"copyVideo":a._handleImageCopy(n.closest(".smart-editor-video-container"));break;case"cutVideo":a._handleImageCut(n.closest(".smart-editor-video-container"));break;case"deleteTab":{const e=t.getAttribute("id");e&&a.$.tabs.deleteTab(e);break}case"copy":case"cut":case"paste":a._handleClipboardAction(i);break;case"caption":{const e=n.closest(".smart-editor-editable img");let t;if(e&&"img"===e.nodeName.toLowerCase()){const o=e.closest(".smart-editor-image-container");o&&o.querySelector(".smart-editor-image-caption")||(t=a.localize("captionPlaceholder")),a._handleImgCaption(e,{caption:t,focusCaption:!0})}else if(n.classList.contains("smart-editor-video-container")){const e=n.querySelectorAll(".smart-editor-video-container > video, .smart-editor-video-container > iframe");n.querySelector(".smart-editor-image-caption")||(t=a.localize("captionPlaceholder")),a._handleVideoCaption(e[0]||e[1],{caption:t,focusCaption:!0})}break}case"selectAll":a._selectAll();break;case"text":case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":case"user":case"emoji":case"twoColumns":case"callout":case"table":case"date":case"divider":case"page":case"task":case"image":case"video":case"file":case"blockquote":case"unorderedlist":case"ai":case"orderedlist":case"hyperlink":case"checklist":case"togglelist":{let e="",o=a._filterSortableMenuInput;if(o){let i=o.value;const n=t,r=n.getAttribute("name");let l=n.getAttribute("value"),s=n.getAttribute("label");"/"===i&&(i=""),i==="/"+a.localize("typeToFilter")&&(i=""),e={name:r,value:l,label:s},o.setValue(i,e)}break}case"pageLink":{const e=t;let o=e.getAttribute("id"),i=e.getAttribute("label");const n=a.$.editableElement.getRootNode().querySelector("#INSERTION_MARKER");n.removeAttribute("id"),n.id="",a._setSelectionRange(n),a._getSelectionRange().collapse();const r=document.createElement("span");r.classList.add("smart-editor-page-label"),r.innerHTML=i,r.setAttribute("data-id",o),n.parentElement.insertBefore(r,n);const l=document.createRange(),s=window.getSelection();l.setStartAfter(n),l.collapse(!0),s.removeAllRanges(),s.addRange(l);break}}a.$.fireEvent("contextMenuItemClick",{originalEvent:e,value:i}),a._closeContextMenu()}_handleImageCopy(e){const t=this;if(!e||"img"!==e.nodeName.toLowerCase()&&!e.classList.contains("smart-editor-video-container"))return;const a=t._createWhiteSpaceChar(e,e.classList.contains("smart-editor-video-container")?e:void 0);t._setSelectionRange(e),t.$.editableElement.getRootNode().execCommand("copy"),a&&a.remove()}_handleImageCut(e){const t=this;if(!e||"img"!==e.nodeName.toLowerCase()&&!e.classList.contains("smart-editor-video-container"))return;const a=t._createWhiteSpaceChar(e,e.classList.contains("smart-editor-video-container")?e:void 0);t._setSelectionRange(e),t.$.editableElement.getRootNode().execCommand("cut"),t._setResizeFrame(),a&&a.remove()}_createWhiteSpaceChar(e,t){if(!t)return;const a=document.createElement("span");return a.innerHTML="&nbsp;",a.classList.add("smart-editor-video-white-space"),e.appendChild(a),a}_handleInputElement(){const e=this,t=e.iframeSettings,a=e.$.contentContainer,o=e.$.container,i=e.$.editableElement,n=e.$.input,r=e.readonly,l=e.disableEditing;if(i.contentEditable=!r&&!l,n.readonly=r||l,e._handlePlaceholder(),e._closePopups(),t.enabled?e._handleIframeSettings():o.contains(a)||(o.appendChild(a),i.setAttribute("contenteditable",!0),e.$.iframe&&(e.$.iframe.remove(),e._removeIframeEventListeners(),delete e.$.iframe)),"markdown"===e.editMode){const t=e.$.editableElement;e.$.input.classList.remove("smart-hidden"),t.classList.add("smart-hidden")}}_handleToolbarMode(){const e=this,t=e.$.toolbar,a=e.$.toolbarItemsSecondary,o=e.toolbarMode;e.$.toolbarItemsPrimary.innerHTML=a.innerHTML="","menu"===o?(a.classList.remove("smart-drop-down"),a.style.top=a.style.height="",t.contains(a)||t.appendChild(a),e._refreshToolbarItems(e._getToolbarItems())):(e._setToolbarTabs(),e._setToolbarItemGroups(),e._toolbarItemsObj||(e._toolbarItemsObj={}),e._refreshToolbarItems()),e.toolbarOnFocus&&e._refreshToolbarPosition(),e._setToolbarGroupHeight()}_setToolbarTabs(){const e=this,t=e.toolbarRibbonConfig,a=e.$.toolbarToggleButton,o=e.$.toolbarItemsPrimary,i=o.querySelectorAll(".smart-editor-toolbar-tab"),n=document.createDocumentFragment();let r;for(let a=0,o=t.length;a<o;a+=1){const o=t[a];let l=i[a];l||(l=document.createElement("div")),l.classList.add("smart-editor-toolbar-tab"),l.setAttribute("tab-name",o.name),l.textContent=e.localize(o.name),!r&&l.hasAttribute("checked")&&(r=l),r!==l&&l.removeAttribute("checked"),l.classList[o.hidden?"add":"remove"]("smart-hidden"),n.appendChild(l)}a.hasAttribute("checked")&&!r&&n.children[0].setAttribute("checked",""),o.appendChild(n)}_setToolbarItemGroups(){const e=this,t=e.toolbarRibbonConfig,a=Array.from(e.$.toolbarItemsPrimary.querySelectorAll(".smart-editor-toolbar-tab")).find((e=>e.hasAttribute("checked")));if(!t||!a)return;const o=a.getAttribute("tab-name"),i=t.find((e=>e.name===o)),n=i?i.groups:null,r=e.$.toolbarItemsSecondary,l="singleLineRibbon"===e.toolbarMode;if(r.innerHTML="",!Array.isArray(n))return;const s=r.querySelectorAll(".smart-editor-toolbar-tab-group"),d=document.createDocumentFragment();for(let t=0,a=n.length;t<a;t+=1){const a=n[t],o=a.name;let i=s[t];if(i||(i=document.createElement("div")),l)i.innerHTML="",i.appendChild(e._getToolbarItems(e.$.toolbar,a.items));else{i.innerHTML='<div class="smart-editor-tab-group-container"></div><div class="smart-editor-tab-group-label"></div>';const t=i.firstElementChild;i.lastElementChild.innerHTML=e.localize(o),t.appendChild(e._getToolbarItems(e.$.toolbar,a.items))}i.classList.add("smart-editor-toolbar-tab-group"),i.setAttribute("group-name",o),d.appendChild(i)}r.appendChild(d),r.classList.remove("smart-visibility-hidden"),e._refreshToolbarTabs()}_refreshToolbarTabs(){const e=this,t=e._resizeFrameObj,a=Array.from(e.$.toolbarItemsPrimary.children).find((e=>"layouttab"===(e.getAttribute("tab-name")||"").toLowerCase()));if(!a)return;if(!t||!t.target||"singleLineRibbon"!==e.toolbarMode)return a.classList.add("smart-hidden"),void(a.hasAttribute("checked")&&e._selectToolbarTab(e.$.toolbarItemsPrimary.firstElementChild));const o=e.$.toolbarItemsSecondary.children,i=t.target,n=i.nodeName.toLowerCase();let r,l,s;for(let e=0,t=o.length;e<t;e+=1){const t=o[e],a=t.getAttribute("group-name");"tableGroup"===a?(l=t,l.classList.add("smart-hidden")):"imageGroup"===a?(r=t,r.classList.add("smart-hidden")):"videoGroup"===a&&(s=t,s.classList.add("smart-hidden"))}"table"===n?(a.classList.remove("smart-hidden"),l&&l.classList.remove("smart-hidden")):"img"===n?(a.classList.remove("smart-hidden"),r&&r.classList.remove("smart-hidden")):i.classList.contains("smart-editor-video-container")?(a.classList.remove("smart-hidden"),s&&s.classList.remove("smart-hidden")):a.classList.add("smart-hidden")}_handlePlaceholder(){const e=this.$.editableElement,t=this.placeholder;t?e.setAttribute("placeholder",t):e.removeAttribute("placeholder")}_handleIframeSettings(){const e=this;e.iframeSettings.enabled&&(()=>{let t=e.$.iframe;t||(t=e.$.iframe=document.createElement("iframe")),t.onload=()=>{e._handleIframeBody(),e._handleIframeAttributes(),e._handleIframeResources()},t.parentElement||e.$.container.appendChild(t),!t.contentWindow.marked&&window.marked&&(t.contentWindow.marked=window.marked)})()}_removeIframeEventListeners(){const e=this,t=e.$.iframe.contentDocument,a=e.$iframe;a&&(a.unlisten("down"),a.unlisten("move"),a.unlisten("up")),t.removeEventListener("dragstart",e._iframeDragStartHandler),t.removeEventListener("dragend",e._iframeDragEndHandler),t.removeEventListener("selectionchange",e._iframeSelectionChangeHandler)}_handleIframeBody(){const e=this,t=e.$.iframe.contentDocument,a=t.body;if(!a)return;let o=e.$iframe;a.classList.add("smart-editor","smart-element","smart-editor-iframe-body"),a.appendChild(e.$.contentContainer),e._updateIframeBody(),o||(o=e.$iframe=Smart.Utilities.Extend(a)),e._iframeDownHandler=t=>e._documentDownHandler.call(e,t),e._iframeMoveHandler=t=>e._documentMoveHandler.call(e,t),e._iframeUpHandler=t=>e._documentUpHandler.call(e,t),e._iframeDragStartHandler=t=>e._dragStartHandler.call(e,t),e._iframeDragEndHandler=t=>e._dragEndHandler.call(e,t),e._iframeSelectionChangeHandler=t=>e._selectionChangeHandler.call(e,t),e._removeIframeEventListeners(),o.listen("down",e._iframeDownHandler),o.listen("move",e._iframeMoveHandler),o.listen("up",e._iframeUpHandler),t.addEventListener("dragstart",e._iframeDragStartHandler),t.addEventListener("dragend",e._iframeDragEndHandler),t.addEventListener("selectionchange",e._iframeSelectionChangeHandler)}_updateIframeBody(){const e=this,t=e.$.iframe;if(!t)return;const a=t.contentDocument.body;a&&(e.rightToLeft?a.setAttribute("right-to-left",""):a.removeAttribute("right-to-left"),e.theme?a.setAttribute("theme",e.theme):a.removeAttribute("theme"),a.setAttribute("animation",e.animation))}_handleIframeAttributes(){const e=this,t=e.$.iframe,a=e.iframeSettings.attributes;if(!t)return;if(t.hasAttribute("title")||t.setAttribute("title",e.localize("iframeTitle")),!a||"object"!=typeof a)return;const o=e.$.editableElement;for(let e in a){const i=a[e];"readonly"===e?o.setAttribute("contenteditable",!i):t[e]=i}}_handleIframeResources(){const e=this,t=e.iframeSettings.resources,a=e.$.iframe;if(!a||"object"!=typeof t)return;const o=document.styleSheets,i=a.contentDocument,n=i.head,r=i.body;if(e.iframeSettings.copyStyles)for(let e in o){const t=o[e],i=t.ownerNode;"text/css"===t.type&&i&&["link","style"].indexOf(i.nodeName.toLocaleLowerCase())>-1&&a.contentDocument.head.appendChild(t.ownerNode.cloneNode())}for(let e in t){const a=e,o=t[e];let i;if((a+"").indexOf("style")>-1||"link"===a?(i=document.createElement("link"),i.rel="stylesheet",i.type="text/css","string"==typeof o&&(i.href=o)):"script"===a&&(i=document.createElement("script"),i.type="text/javascript","string"==typeof o&&(i.src=o)),"object"==typeof o&&"[object Object]"===o.toString())for(let e in o)i[e]=o[e];"module"===i.type?r.appendChild(i):n.appendChild(i)}}_handleMaxCharCount(){const e=this,t=e.$.input;null!==e.maxCharCount?t.maxLength=e.maxCharCount:t.removeAttribute("maxlength")}_getToolbarItems(e,t){const a=this;e||(e=a.$.toolbar),t||(t=a.toolbarItems);const o=e===a.$.toolbar?"toolbar":"inlineToolbar",i=e.querySelectorAll(".smart-editor-toolbar-item"),n=document.createDocumentFragment();for(let e=0,r=t.length;e<r;e+=1){const r=a._getToolbarItemDetails(o,t[e]),l=r.name,s=r.type;let d=i[e];if(d?"custom"===d.getAttribute("item-type")&&(d.innerHTML=""):(d=document.createElement("div"),d.classList.add("smart-editor-toolbar-item")),"color-input"===s)d.innerHTML||(d.innerHTML=`<div class="smart-editor-item-action-button" item-name="${l}"></div>\n <div class="smart-editor-item-drop-down-button"></div>`);else if("custom"===s){const e=r.template;d.innerHTML="",e&&e.closest&&!d.contains(e)?d.appendChild(e):"string"!=typeof e||d.innerHTML?"function"==typeof e&&e(d,r):d.innerHTML=e||""}else"toggle"===s&&(r.value?(d.setAttribute("checked",""),d.setAttribute("aria-pressed",!0)):(d.removeAttribute("checked"),d.setAttribute("aria-pressed",!1)),d.innerHTML&&(d.innerHTML=""));r.disabled||"paste"===l&&a._isFireFox?(d.setAttribute("disabled",""),d.setAttribute("aria-disabled",!0)):(d.removeAttribute("disabled"),d.removeAttribute("aria-disabled")),d.setAttribute("role","delimiter"===s?"separator":"button"),"color-input"===s||"drop-down"===s?d.setAttribute("aria-haspopup",!0):d.removeAttribute("aria-haspopup"),a._setItemValue(d,r),r.title?d.setAttribute("title",r.title):d.removeAttribute("title"),d.setAttribute("item-name",l),d.setAttribute("item-type",s),d.style.width=r.width||"",n.appendChild(d)}return n}_setItemValue(e,t){const a=this;let o=t.value;e&&t&&("button"===t.type?o?(e.setAttribute("checked",""),e.setAttribute("aria-pressed",!0)):(e.removeAttribute("checked"),e.setAttribute("aria-pressed",!1)):(o||"color-input"!==t.type?["fontname","formats"].indexOf(t.name)>-1&&(o=a.localize(t.value)||t.label||t.value):o="transparent",o?(e.setAttribute("item-value",o),e.style.setProperty("--item-value",o)):(e.removeAttribute("item-value"),e.style.removeProperty("--item-value"))))}_refreshToolbarItems(e){const t=this,a=t.$.toolbar,o=t.$.toolbarToggleButton,i=t.$.toolbarItemsPrimary,n=t.$.toolbarItemsSecondary;if("menu"===t.toolbarMode){if(i.scrollTop=i.scrollLeft=0,e)i.appendChild(e);else{const e=Array.from(n.children),t=document.createDocumentFragment(),a=e.length;for(let o=0;o<a;o+=1)t.appendChild(e[o]);a>0&&i.appendChild(t)}if("toggle"===t.toolbarViewMode){const e=i.offsetHeight;if(a.hasAttribute("expanded")){let t=[];e:for(;i.scrollHeight>e;){const e=i.lastElementChild;if(!e)break e;t.push(e),e.remove()}t.reverse();for(let e=0,a=t.length;e<a;e+=1)n.appendChild(t[e])}else i.scrollHeight===e&&o.classList.add("smart-visibility-hidden")}}else o.classList.remove("smart-visibility-hidden")}_resizeHandler(e){const t=this,a=t.$.inlineToolbar;if(e.target===t){if("toggle"===t.toolbarViewMode){const e=t.$.toolbarItemsPrimary,a=t.$.toolbarItemsSecondary;t.$.toolbar.hasAttribute("expanded")&&t._refreshToolbarItems();const o=t.$.toolbarToggleButton;e.scrollHeight!==e.offsetHeight||a.children.length?o.classList.remove("smart-visibility-hidden"):o.classList.add("smart-visibility-hidden")}if("menu"===t.toolbarMode||t.$.toolbarItemsSecondary.classList.contains("smart-visibility-hidden")||t._setToolbarGroupHeight(),a&&a.visible){const e=a.selector;e.classList.contains("smart-editor-toolbar-item")&&e.offsetTop>=t.$.toolbar.offsetHeight?a.close():a.reposition()}t._positionWindow(),t._refreshToolbarPosition(),t._resizeFrameObj&&t._setResizeFrame(t._resizeFrameObj.target)}}recycle(){this._positionWindow(),this._refreshToolbarPosition()}_setToolbarItemAttr(e,t,a){const o=this,i=o.$.toolbar,n=o.$.inlineToolbar,r=[o._toolbarItemsObj,o._inlineToolbarItemsObj];for(let o=0,l=r.length;o<l;o+=1){const l=r[o],s=l?l[e]:void 0;if(s){const o=l==l?i:n;if(s[t]=a,!o||!o.parentElement)continue;const r=o.querySelector(`.smart-editor-toolbar-item[item-name="${e}"]`);if(!r)continue;null==a||!1===a?(r.removeAttribute(t),"disabled"===t&&r.removeAttribute("aria-disabled")):(r.setAttribute(t,a),"disabled"===t&&r.setAttribute("aria-disabled",!0))}}}_setToolbarVisibility(){const e=this,t=e.$.toolbar,a=e.$.toolbarToggleButton;"toggle"!==e.toolbarViewMode||a.hasAttribute("checked")?t.setAttribute("expanded",""):t.removeAttribute("expanded")}_getToolbarItemDetails(e,t){const a=this;let o,i=a[`_${e}ItemsObj`];if(o="string"==typeof t?t:"object"==typeof t&&t.name?t.name+"":"",o=o.trim().toLowerCase(),i){if(void 0!==i[o])return i[o]}else i=a[`_${e}ItemsObj`]={};const n=i[o]={};return n.title=t.title||a.localize(o),n.name=o,n.toolbarName=e,n.advanced=!!t.advanced,n.inlineToolbarItems=t.inlineToolbarItems,a._setItemType(t,n,o),a._setItemData(t,n,o),a._setItemTemplate(t,n,o),a._setItemSpecifics(t,n,o),n}_setItemType(e,t,a){let o;if(t){switch(a){case"sourcecode":case"splitmode":case"fullscreen":o="toggle";break;case"alignment":case"fontname":case"fontsize":case"formats":case"tablerows":case"tablecolumns":case"tablevalign":case"tablestyle":o="drop-down";break;case"backgroundcolor":case"fontcolor":o="color-input";break;case"bold":case"italic":case"underline":case"strikethrough":case"delete":case"redo":case"undo":case"indent":case"outdent":case"openlink":case"editlink":case"createlink":case"removelink":case"hyperlink":case"cut":case"copy":case"image":case"video":case"file":case"lowercase":case"uppercase":case"print":case"caption":case"clearformat":case"table":case"tableheader":case"orderedlist":case"unorderedlist":case"checklist":case"subscript":case"superscript":case"findandreplace":case"ai":o="button";break;case"paste":o=t.advanced?"drop-down":"button";break;default:o="string"==typeof e?"delimiter":"custom"}t.type=o}}_setItemData(e,t,a){const o=this;let i,n;if(!t||!e)return;const r=t.type;let l=e.width;if("drop-down"===r||"color-input"===r){if("object"==typeof e&&(i=e.dataSource,void 0!==e.value&&(n=e.value+"")),i&&Array.isArray(i)||(i=o._getDefaultDataSource(a,t)),void 0===n&&("fontsize"===t.name&&(n=parseInt(window.getComputedStyle(o.$.editableElement).fontSize)),isNaN(n)&&i.length)){let e=i[0];"fontcolor"===t.name&&(e=i[i.length-1]),"backgroundcolor"===t.name&&(e="transparent"),n=e["alignment"===a?"value":"label"]||e}a.indexOf("table")>-1&&(n="")}void 0!==l&&("number"==typeof l?l+="px":(l+="",l.includes("%")||(l=parseFloat(e.width),l=isNaN(l)?"":l+"px"))),t.dataSource=i,"color-input"===r&&(t.additionalColors=["#FF9EB7","#FFCFC9","#FFD66D","#FFEBB6","#93DF89","#D1F7C4","#9DC7FF","#D0F0FD","#CDAFFF","#ECE1FD","#FA9DE2","#FFDAF6","#CBCBCB","#EDEDED","#FFFFFF",""]),t.value=n,t.disabled=!!e.disabled,t.width=l}_setItemSpecifics(e,t,a){if(!t||"object"!=typeof e)return;let o=e.editor,i=t.editor;if(i||(i=t.editor={}),!o)return;let n=[],r=[];switch(a){case"createlink":case"removelink":case"hyperlink":n=["address","text","target"];break;case"image":n=["allowedTypes","uploadUrl","removeUrl","path","display"],r=["draggable","resizable"];break;case"file":n=["allowedTypes","uploadUrl","removeUrl","path","display"];break;case"table":n=["cols","rows","tableheader"],r=["altrows","dashedborders","resizable"]}for(let e in o){let t=o[e];void 0!==t&&(n.indexOf(e)>-1?"display"===e?t="block"===t?"block":"inline":t+="":r.indexOf(e)>-1?t=!!t:"width"!==e&&"height"!==e||"string"==typeof t||(t+="px"),i[e]=t)}}_getDefaultDataSource(e,t){const a=this;let o=[];switch(e){case"alignment":o=[{label:a.localize("alignLeft"),value:"left",icon:"editor-icon"},{label:a.localize("alignCenter"),value:"center",icon:"editor-icon"},{label:a.localize("alignRight"),value:"right",icon:"editor-icon"}],t&&"toolbar"===t.toolbarName&&o.push({label:a.localize("alignJustify"),value:"justify",icon:"editor-icon"});break;case"display":o=[{label:a.localize("displayInline"),value:"inline"},{label:a.localize("displayBlock"),value:"block"}];break;case"fontname":["arial","Courier New","georgia","impact","Roboto","segoeUi","tahoma","timesNewRoman","verdana"].forEach((e=>{o.push({label:a.localize(e),value:e})}));break;case"fontsize":["8","10","12","14","18","24","36"].forEach((e=>{o.push({label:e,value:e})}));break;case"formats":["p","pre","blockquote","h1","h2","h3","h4","h5","h6"].forEach((e=>{o.push({label:a.localize(e),value:e})}));break;case"backgroundcolor":case"fontcolor":o=["#D50000","#E67C73","#F4511E","#F6BF26","#0B8043","#33B679","#3F51B5","#039BE5","#7986CB","#8C47FF","#8E24AA","#FF36C2","#616161","#454545","#949494","#000000"];break;case"paste":o=[{label:a.localize("plainText"),value:"plainText"},{label:a.localize("keepFormat"),value:"keepFormat"},{label:a.localize("cleanFormat"),value:"cleanFormat"}];break;case"target":o=[{label:a.localize("linkBlankDescr"),value:"_blank"},{label:a.localize("linkSelfDescr"),value:"_self"},{label:a.localize("linkParentDescr"),value:"_parent"},{label:a.localize("linkTopDescr"),value:"_top"},{label:a.localize("linkCustomDescr"),value:""}];break;case"tablerows":o=[{label:a.localize("insertRowBefore"),value:"insertRowBefore",icon:"editor-icon"},{label:a.localize("insertRowAfter"),value:"insertRowAfter",icon:"editor-icon"},{label:a.localize("deleteRow"),value:"deleteRow",icon:"editor-icon"}];break;case"tablecolumns":o=[{label:a.localize("insertColumnLeft"),value:"insertColumnLeft",icon:"editor-icon"},{label:a.localize("insertColumnRight"),value:"insertColumnRight",icon:"editor-icon"},{label:a.localize("deleteColumn"),value:"deleteColumn",icon:"editor-icon"}];break;case"tablevalign":o=[{label:a.localize("alignTop"),value:"top"},{label:a.localize("alignMiddle"),value:"middle"},{label:a.localize("alignBottom"),value:"bottom"}];break;case"tablestyle":o=[{label:a.localize("dashedborders"),value:"dashedborders"},{label:a.localize("altrows"),value:"altrows"}]}return o}_setItemTemplate(e,t){let a=e.template;t&&(a?(a&&a.closest?a="content"in a?document.importNode(a.content,!0):a:"function"==typeof a?a=a.bind(this):"string"==typeof a&&(a=document.getElementById(a)||a),t.template=a):delete t.template)}_setAriaSettings(){const e=this,t=e.$.input,a=e.$.editableElement;e.setAttribute("role","application"),e.setAttribute("aria-roledescription",e.localize("roleDescription")),e.$.toolbarToggleButton.setAttribute("aria-label",e.localize("toolbarButtonAriaLabel")),e.$.toolbarItemsPrimary.setAttribute("aria-label",e.localize("primaryToolbarAriaLabel")),e.$.toolbarItemsSecondary.setAttribute("aria-label",e.localize("secondaryToolbarAriaLabel")),t.setAttribute("aria-label",e.localize("inputAreaLabel")),t.id=e.id+"TextArea",a.id=e.id+"EditableElement",a.setAttribute("aria-label",e.localize("inputAriaLabel"))}_setAriaControls(e,t){const a=this;e&&e.nodeName&&(t.id||(t.id=a.id+"Popup"+Math.floor(65536*(1+Math.random())).toString(16).substring(1)),e.setAttribute("aria-controls",t.id))}_setAriaOwns(e){const t=this;if(!e)return;const a=e.id;let o=(t.getAttribute("aria-owns")||"").split(" ").filter((e=>e.length));const i=o.indexOf(a);if(i>-1){if(e.parentElement&&(e.opened||e.visible))return;o.splice(i,1)}else o.push(a);o.length?t.setAttribute("aria-owns",o.join(" ")):t.removeAttribute("aria-owns")}_setFocusable(){const e=this,t=e.$.editableElement;if(e.disabled||e.unfocusable)return void(t&&t.removeAttribute("tabindex"));const a=e.tabIndex>0?e.tabIndex:0;t&&(t.tabIndex=a)}_selectAll(){const e=this,t=e.$.input,a=e.$.editableElement;t.classList.contains("smart-hidden")||t.select(),a.classList.contains("smart-hidden")||e._setSelectionRange(a)}_selectStartHandler(e){const t=this,a=t._resizeFrameObj,o=t._inlineToolbarClickObj;(t._blockDragDetails&&t._blockDragDetails.line||a&&a.resizeDetails||o&&o.resizeDetails)&&e.preventDefault()}_selectionChangeHandler(e){const t=this;if(t.disabled||!e.target.getSelection)return;const a=e.target.getSelection().focusNode;if(t.$.contentContainer.contains(a)){if(t._ignoreSelectionChange||a.classList&&a.classList.contains("smart-search-input"))return;t._selectionChangeFired=!0,t._setSelectionRange(),t._updateToolbarItems(),t._isSelecting=!0,clearTimeout(t._selectingTimer),t._selectingTimer=setTimeout((()=>{delete t._isSelecting}),500),delete t._selectionChangeFired}}_selectToolbarTab(e){const t=this,a=t.$.toolbar,o=t.$.toolbarItemsPrimary,i=e&&!e.hasAttribute("checked"),n=o.querySelectorAll(".smart-editor-toolbar-tab");for(let t=0,a=n.length;t<a;t+=1){const a=n[t];e===a&&i?a.setAttribute("checked",""):a.removeAttribute("checked")}let r=t._tabSelectionBar;r||(t._tabSelectionBar=r=document.createElement("div"),r.classList.add("smart-editor-toolbar-tab-selection-bar")),r.classList.add("smart-visibility-hidden"),e&&e.hasAttribute("checked")?(a.setAttribute("toolbar-tab-selected",""),r.style.left=e.offsetLeft+"px",r.style.width=e.offsetWidth+"px",o.contains(r)||o.appendChild(r),t._setToolbarItemGroups(),requestAnimationFrame((()=>r.classList.remove("smart-visibility-hidden")))):a.removeAttribute("toolbar-tab-selected")}}),Smart("smart-table-picker",class extends Smart.BaseElement{static get properties(){return{columns:{value:10,type:"number"},messages:{extend:!0,value:{en:{buttonLabel:"Insert Table"}}},rows:{value:3,type:"number"},value:{value:[],type:"array"}}}static get listeners(){return{"tableGrid.mouseover":"_cellOver","tableGrid.mouseleave":"_cellLeave","tableGrid.click":"_cellOver"}}template(){return'<div id="container" role="presentation">\n <div id="tableGrid" class="smart-table-picker-grid" role="presentation"></div>\n <div class="smart-table-picker-separator" role="separator"></div>\n <smart-button id="tableButton" class="smart-table-picker-button" right-to-left="[[rightToLeft]]"></smart-button>\n </div>'}propertyChangedHandler(e,t,a){const o=this;switch(e){case"value":o._selectCell(a,t,!0);break;case"rows":case"columns":o._createTableGrid();break;case"messages":o._setTableButton();break;default:super.propertyChangedHandler(e,t,a)}}render(){const e=this;e._isMobile=Smart.Utilities.Core.isMobile,e._createTableGrid(),e._setTableButton(),e._setAria(),super.render()}_setAria(){this.setAttribute("role","grid")}_createTableGrid(){const e=this,t=e.$.tableGrid,a=e.columns,o=e.rows,i=t.children,n=document.createDocumentFragment();let r=i.length;for(;r>o;){const e=i[0];if(!e)break;e.remove(),r--}for(let e=r,t=o;e<t;e+=1){const e=document.createElement("div");e.setAttribute("role","row"),n.appendChild(e)}n.children.length&&t.appendChild(n);for(let e=0,t=o;e<t;e+=1){const t=i[e],o=t.children;let n=o.length;for(;n>a&&o[0];)o[0].remove(),n--;for(let e=n,o=a;e<o;e+=1){const e=document.createElement("span");e.setAttribute("role","gridcell"),e.classList.add("smart-table-picker-cell"),t.appendChild(e)}}e._selectCell(e.value)}_cellOver(e){const t=this,a=e.target;let o=[];if(!t.$.tableGrid.contains(a))return void t._selectCell(t.value);const i=a.closest(".smart-table-picker-cell");if(i){const a=i.parentElement,n=Array.from(a.children);o[0]=Math.max(0,Array.from(t.$.tableGrid.children).indexOf(a)+1),o[1]=Math.max(0,n.indexOf(i)+1),t._selectCell(o,t.value,"click"===e.type)}}_cellLeave(){this._selectCell(this.value)}_selectCell(e,t,a){const o=this,i=o.$.tableGrid,n=Array.from(i.children),r=n.length;let l=0,s=0;e&&(l=e[0]||0,s=e[1]||0);for(let e=0,t=r;e<t;e+=1){const t=n[e].children;if(l<e+1)for(let e=0,a=t.length;e<a;e+=1)t[e].removeAttribute("selected");else for(let e=0,a=t.length;e<a;e+=1)s>=e+1?t[e].setAttribute("selected",""):t[e].removeAttribute("selected")}i.setAttribute("value",l+"x"+s),a&&(void 0===t&&(t=o.value),o.set("value",[l,s]),t[0]===l&&t[1]===s||o.$.fireEvent("change",{value:e,oldValue:t}))}_setTableButton(){this.$.tableButton.innerHTML=this.localize("buttonLabel")}});
828
828
 
829
829
  /***/ }),
830
830
 
@@ -1015,7 +1015,7 @@ var __webpack_exports__ = {};
1015
1015
  /* harmony import */ var _smart_editor_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(7855);
1016
1016
  /* harmony import */ var _smart_editor_js__WEBPACK_IMPORTED_MODULE_19___default = /*#__PURE__*/__webpack_require__.n(_smart_editor_js__WEBPACK_IMPORTED_MODULE_19__);
1017
1017
 
1018
- /* Smart UI v23.1.1 (2025-05-29)
1018
+ /* Smart UI v23.1.19 (2025-06-17)
1019
1019
  Copyright (c) 2011-2025 jQWidgets.
1020
1020
  License: https://htmlelements.com/license/ */ //
1021
1021