avo 2.36.1 → 2.36.3
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of avo might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/app/components/avo/fields/location_field/show_component.html.erb +1 -1
- data/app/components/avo/index/grid_item_component.html.erb +1 -1
- data/app/components/avo/resource_component.rb +1 -3
- data/app/components/avo/views/resource_edit_component.html.erb +1 -1
- data/app/components/avo/views/resource_index_component.html.erb +1 -1
- data/app/components/avo/views/resource_show_component.html.erb +15 -13
- data/app/components/avo/views/resource_show_component.rb +4 -0
- data/app/controllers/avo/attachments_controller.rb +1 -1
- data/app/controllers/avo/search_controller.rb +2 -3
- data/app/javascript/js/controllers/fields/easy_mde_controller.js +1 -0
- data/lib/avo/base_resource.rb +4 -8
- data/lib/avo/concerns/has_fields.rb +10 -2
- data/lib/avo/concerns/visible_items.rb +5 -5
- data/lib/avo/fields/base_field.rb +9 -0
- data/lib/avo/fields/location_field.rb +10 -1
- data/lib/avo/resources/controls/action.rb +8 -3
- data/lib/avo/version.rb +1 -1
- data/public/avo-assets/avo.base.js +1 -1
- data/public/avo-assets/avo.base.js.map +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 27f20585320045ee577bd03be710186c9567d5c074ee46fe02be7d9c75c9ddb4
|
4
|
+
data.tar.gz: f4feef65d5ec1e9c32c008248a66be6b3648c05e81f3788e3e44cdbb4ae11d25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c6091673e94cc0c5dc4f80c7fb5d9d51d26dcb217f63a4c9cb348a8c95613dcec876c9d3f531e97be9afe6bdf3ae4663749c7ed906b68462cef2ca3bd7dba8fc
|
7
|
+
data.tar.gz: 6b4534ab29b1c76db996a58a4374fbfeba989bf8a8c390d2692335a2e03d176465364d32bb96cd0b2c3a0b3f0bb26330341f47794047d65df7049b16c15f97e2
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
avo (2.36.
|
4
|
+
avo (2.36.3)
|
5
5
|
actionview (>= 6.0)
|
6
6
|
active_link_to
|
7
7
|
activerecord (>= 6.0)
|
@@ -422,7 +422,7 @@ GEM
|
|
422
422
|
tzinfo (2.0.6)
|
423
423
|
concurrent-ruby (~> 1.0)
|
424
424
|
unicode-display_width (2.4.0)
|
425
|
-
view_component (3.
|
425
|
+
view_component (3.4.0)
|
426
426
|
activesupport (>= 5.2.0, < 8.0)
|
427
427
|
concurrent-ruby (~> 1.0)
|
428
428
|
method_source (~> 1.0)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<%= field_wrapper **field_wrapper_args do %>
|
2
2
|
<% if field.value_present? %>
|
3
|
-
<%= js_map [{latitude: field.value[0], longitude: field.value[1]}], id: "location-map" %>
|
3
|
+
<%= js_map [{latitude: field.value[0], longitude: field.value[1]}], id: "location-map", zoom: field.zoom, controls: true %>
|
4
4
|
<% else %>
|
5
5
|
—
|
6
6
|
<% end %>
|
@@ -13,7 +13,7 @@
|
|
13
13
|
<% elsif cover.respond_to?(:to_image) && cover.to_image.present? %>
|
14
14
|
<%= link_to_if cover.link_to_resource, image_tag(cover.to_image, class: 'absolute h-full w-full object-cover'), resource_view_path, class: 'absolute h-full w-full object-cover', title: title.value %>
|
15
15
|
<% elsif cover.type == 'file' %>
|
16
|
-
<% if cover.value
|
16
|
+
<% if cover.value&.attached? && cover.value.representable? %>
|
17
17
|
<%= link_to_if cover.link_to_resource, image_tag(helpers.main_app.url_for(cover.value.variant(resize_to_limit: [480, 480])), class: 'absolute h-full w-full object-cover'), resource_view_path, class: 'absolute h-full w-full object-cover', title: title.value %>
|
18
18
|
<% else %>
|
19
19
|
<%= link_to resource_view_path do %>
|
@@ -37,9 +37,7 @@ class Avo::ResourceComponent < Avo::BaseComponent
|
|
37
37
|
@resource.authorization.authorize_action(:destroy, raise_exception: false)
|
38
38
|
end
|
39
39
|
|
40
|
-
def
|
41
|
-
return false if @actions.blank?
|
42
|
-
|
40
|
+
def can_act_on?
|
43
41
|
return authorize_association_for(:act_on) if @reflection.present?
|
44
42
|
|
45
43
|
@resource.authorization.authorize_action(:act_on, raise_exception: false) && !has_reflection_and_is_read_only
|
@@ -40,7 +40,7 @@
|
|
40
40
|
<%= t('avo.delete').capitalize %>
|
41
41
|
<% end %>
|
42
42
|
<% end %>
|
43
|
-
<% if
|
43
|
+
<% if can_act_on? %>
|
44
44
|
<%= render Avo::ActionsComponent.new actions: @actions, resource: @resource, view: @view %>
|
45
45
|
<% end %>
|
46
46
|
<% if can_see_the_save_button? %>
|
@@ -16,7 +16,7 @@
|
|
16
16
|
<%= t('avo.attach_item', item: singular_resource_name).capitalize %>
|
17
17
|
<% end %>
|
18
18
|
<% end %>
|
19
|
-
<% if
|
19
|
+
<% if can_act_on? %>
|
20
20
|
<%= render Avo::ActionsComponent.new actions: @actions, resource: @resource, view: @view %>
|
21
21
|
<% end %>
|
22
22
|
<% if can_see_the_create_button? %>
|
@@ -39,7 +39,7 @@
|
|
39
39
|
<%= control.label %>
|
40
40
|
<% end %>
|
41
41
|
<% end %>
|
42
|
-
<% elsif
|
42
|
+
<% elsif can_act_on? && control.actions_list? %>
|
43
43
|
<%= render Avo::ActionsComponent.new actions: @actions, resource: @resource, view: @view, exclude: control.exclude, include: control.include, style: control.style, color: control.color, label: control.label %>
|
44
44
|
<% elsif control.edit_button? %>
|
45
45
|
<% if @resource.authorization.authorize_action(:edit, raise_exception: false) %>
|
@@ -55,17 +55,19 @@
|
|
55
55
|
<% end %>
|
56
56
|
<% end %>
|
57
57
|
<% elsif control.action? %>
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
58
|
+
<% if render_action_control?(control.action) %>
|
59
|
+
<%= a_link control.path,
|
60
|
+
color: control.color,
|
61
|
+
style: control.style,
|
62
|
+
icon: control.icon,
|
63
|
+
title: control.title,
|
64
|
+
data: {
|
65
|
+
tippy: control.title ? :tooltip : nil,
|
66
|
+
'turbo-frame': 'actions_show',
|
67
|
+
'action': 'click->actions-picker#visitAction',
|
68
|
+
} do %>
|
69
|
+
<%= control.label %>
|
70
|
+
<% end %>
|
69
71
|
<% end %>
|
70
72
|
<% elsif control.link_to? %>
|
71
73
|
<%= a_link control.path,
|
@@ -140,7 +142,7 @@
|
|
140
142
|
<%= t('avo.delete').capitalize %>
|
141
143
|
<% end %>
|
142
144
|
<% end %>
|
143
|
-
<% if
|
145
|
+
<% if can_act_on? %>
|
144
146
|
<%= render Avo::ActionsComponent.new actions: @actions, resource: @resource, view: @view %>
|
145
147
|
<% end %>
|
146
148
|
<% if @resource.authorization.authorize_action(:edit, raise_exception: false) %>
|
@@ -45,6 +45,10 @@ class Avo::Views::ResourceShowComponent < Avo::ResourceComponent
|
|
45
45
|
helpers.edit_resource_path(model: @resource.model, resource: @resource, **args)
|
46
46
|
end
|
47
47
|
|
48
|
+
def render_action_control?(action)
|
49
|
+
can_act_on? && action.visible_in_view(parent_resource: @parent_resource)
|
50
|
+
end
|
51
|
+
|
48
52
|
private
|
49
53
|
|
50
54
|
# In development and test environments we shoudl show the invalid field errors
|
@@ -7,7 +7,7 @@ module Avo
|
|
7
7
|
before_action :set_model, only: [:destroy, :create]
|
8
8
|
|
9
9
|
def create
|
10
|
-
blob = ActiveStorage::Blob.create_and_upload! io: params[:file], filename: params[:filename]
|
10
|
+
blob = ActiveStorage::Blob.create_and_upload! io: params[:file].to_io, filename: params[:filename]
|
11
11
|
association_name = BaseResource.valid_attachment_name(@model, params[:attachment_key])
|
12
12
|
|
13
13
|
if association_name.blank?
|
@@ -182,9 +182,8 @@ module Avo
|
|
182
182
|
def fetch_parent
|
183
183
|
return unless params[:via_reflection_id].present?
|
184
184
|
|
185
|
-
|
186
|
-
|
187
|
-
parent_class.find params[:via_reflection_id]
|
185
|
+
parent_resource = ::Avo::App.get_resource_by_model_name params[:via_reflection_class]
|
186
|
+
parent_resource.find_record params[:via_reflection_id], params: params
|
188
187
|
end
|
189
188
|
end
|
190
189
|
end
|
data/lib/avo/base_resource.rb
CHANGED
@@ -377,11 +377,9 @@ module Avo
|
|
377
377
|
!field.computed
|
378
378
|
end
|
379
379
|
.map do |field|
|
380
|
-
id = field.id
|
381
380
|
value = field.value
|
382
381
|
|
383
382
|
if field.type == "belongs_to"
|
384
|
-
id = field.foreign_key.to_sym
|
385
383
|
|
386
384
|
reflection = @model._reflections[@params[:via_relation]]
|
387
385
|
|
@@ -398,17 +396,15 @@ module Avo
|
|
398
396
|
end
|
399
397
|
end
|
400
398
|
|
401
|
-
[
|
399
|
+
[field, value]
|
402
400
|
end
|
403
401
|
.to_h
|
404
|
-
.select do |
|
402
|
+
.select do |_, value|
|
405
403
|
value.present?
|
406
404
|
end
|
407
405
|
|
408
|
-
default_values.each do |
|
409
|
-
|
410
|
-
@model.send("#{id}=", value)
|
411
|
-
end
|
406
|
+
default_values.each do |field, value|
|
407
|
+
field.assign_value record: @model, value: value
|
412
408
|
end
|
413
409
|
end
|
414
410
|
|
@@ -294,8 +294,10 @@ module Avo
|
|
294
294
|
panelfull_items.grep(Avo::TabGroup).each do |tab_group|
|
295
295
|
tab_group.items.grep(Avo::Tab).each do |tab|
|
296
296
|
tab.items.grep(Avo::Panel).each do |panel|
|
297
|
-
panel.items.grep(Avo::Fields::BelongsToField)
|
298
|
-
|
297
|
+
set_target_to_top panel.items.grep(Avo::Fields::BelongsToField)
|
298
|
+
|
299
|
+
panel.items.grep(Avo::Row).each do |row|
|
300
|
+
set_target_to_top row.items.grep(Avo::Fields::BelongsToField)
|
299
301
|
end
|
300
302
|
end
|
301
303
|
end
|
@@ -315,6 +317,12 @@ module Avo
|
|
315
317
|
|
316
318
|
private
|
317
319
|
|
320
|
+
def set_target_to_top(fields)
|
321
|
+
fields.each do |field|
|
322
|
+
field.target = :_top
|
323
|
+
end
|
324
|
+
end
|
325
|
+
|
318
326
|
def check_license
|
319
327
|
if !Rails.env.production? && App.license.present? && App.license.lacks(:resource_tools)
|
320
328
|
# Add error message to let the developer know the resource tool will not be available in a production environment.
|
@@ -27,11 +27,11 @@ module Avo
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def visible(item)
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
30
|
+
return item.visible? unless item.is_field?
|
31
|
+
|
32
|
+
return false if item.respond_to?(:authorized?) && item.resource.present? && !item.authorized?
|
33
|
+
|
34
|
+
item.visible? && item.visible_on?(view)
|
35
35
|
end
|
36
36
|
|
37
37
|
def visible?
|
@@ -273,6 +273,15 @@ module Avo
|
|
273
273
|
!is_readonly? && visible?
|
274
274
|
end
|
275
275
|
|
276
|
+
# Used by Avo to fill the record with the default value on :new and :edit views
|
277
|
+
def assign_value(record:, value:)
|
278
|
+
id = type == "belongs_to" ? foreign_key : database_id
|
279
|
+
|
280
|
+
if record.send(id).nil?
|
281
|
+
record.send("#{id}=", value)
|
282
|
+
end
|
283
|
+
end
|
284
|
+
|
276
285
|
private
|
277
286
|
|
278
287
|
def model_or_class(model)
|
@@ -3,13 +3,14 @@
|
|
3
3
|
module Avo
|
4
4
|
module Fields
|
5
5
|
class LocationField < BaseField
|
6
|
-
attr_reader :stored_as
|
6
|
+
attr_reader :stored_as, :zoom
|
7
7
|
|
8
8
|
def initialize(id, **args, &block)
|
9
9
|
hide_on :index
|
10
10
|
super(id, **args, &block)
|
11
11
|
|
12
12
|
@stored_as = args[:stored_as].present? ? args[:stored_as] : nil # You can pass it an array of db columns [:latitude, :longitude]
|
13
|
+
@zoom = args[:zoom].present? ? args[:zoom].to_i : 15
|
13
14
|
end
|
14
15
|
|
15
16
|
def value_as_array?
|
@@ -72,6 +73,14 @@ module Avo
|
|
72
73
|
|
73
74
|
value.present?
|
74
75
|
end
|
76
|
+
|
77
|
+
def assign_value(record:, value:)
|
78
|
+
return super if stored_as.blank?
|
79
|
+
|
80
|
+
stored_as.each_with_index do |database_id, index|
|
81
|
+
record.send("#{database_id}=", value[index])
|
82
|
+
end
|
83
|
+
end
|
75
84
|
end
|
76
85
|
end
|
77
86
|
end
|
@@ -4,17 +4,22 @@ module Avo
|
|
4
4
|
class Action < BaseControl
|
5
5
|
attr_reader :klass
|
6
6
|
|
7
|
-
def initialize(klass,
|
7
|
+
def initialize(klass, record: nil, resource: nil, view: nil, **args)
|
8
8
|
super(**args)
|
9
9
|
|
10
10
|
@klass = klass
|
11
11
|
@resource = resource
|
12
|
-
@
|
12
|
+
@record = record
|
13
13
|
@view = view
|
14
14
|
end
|
15
15
|
|
16
16
|
def action
|
17
|
-
@instance ||= @klass.new(
|
17
|
+
@instance ||= @klass.new(
|
18
|
+
model: @record,
|
19
|
+
resource: @resource,
|
20
|
+
view: @view,
|
21
|
+
arguments: @resource.get_action_arguments(klass)
|
22
|
+
)
|
18
23
|
end
|
19
24
|
|
20
25
|
def path
|
data/lib/avo/version.rb
CHANGED
@@ -659,7 +659,7 @@ Please report this to https://github.com/markedjs/marked.`,r){var i="<p>An error
|
|
659
659
|
-----
|
660
660
|
|
661
661
|
`]},urt={link:"URL for the link:",image:"URL of the image:"},crt={locale:"en-US",format:{hour:"2-digit",minute:"2-digit"}},frt={bold:"**",code:"```",italic:"*"},hrt={sbInit:"Attach files by drag and dropping or pasting from clipboard.",sbOnDragEnter:"Drop image to upload it.",sbOnDrop:"Uploading image #images_names#...",sbProgress:"Uploading #file_name#: #progress#%",sbOnUploaded:"Uploaded #image_name#",sizeUnits:" B, KB, MB"},drt={noFileGiven:"You must select a file.",typeNotAllowed:"This image type is not allowed.",fileTooLarge:`Image #image_name# is too big (#image_size#).
|
662
|
-
Maximum file size is #image_max_size#.`,importError:"Something went wrong when uploading the image #image_name#."};function xn(r){r=r||{},r.parent=this;var e=!0;if(r.autoDownloadFontAwesome===!1&&(e=!1),r.autoDownloadFontAwesome!==!0)for(var t=document.styleSheets,n=0;n<t.length;n++)!t[n].href||t[n].href.indexOf("//maxcdn.bootstrapcdn.com/font-awesome/")>-1&&(e=!1);if(e){var i=document.createElement("link");i.rel="stylesheet",i.href="https://maxcdn.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css",document.getElementsByTagName("head")[0].appendChild(i)}if(r.element)this.element=r.element;else if(r.element===null){console.log("EasyMDE: Error. No element was found.");return}if(r.toolbar===void 0){r.toolbar=[];for(var s in d0)Object.prototype.hasOwnProperty.call(d0,s)&&(s.indexOf("separator-")!=-1&&r.toolbar.push("|"),(d0[s].default===!0||r.showIcons&&r.showIcons.constructor===Array&&r.showIcons.indexOf(s)!=-1)&&r.toolbar.push(s))}if(Object.prototype.hasOwnProperty.call(r,"previewClass")||(r.previewClass="editor-preview"),Object.prototype.hasOwnProperty.call(r,"status")||(r.status=["autosave","lines","words","cursor"],r.uploadImage&&r.status.unshift("upload-image")),r.previewRender||(r.previewRender=function(h){return this.parent.markdown(h)}),r.parsingConfig=Tg({highlightFormatting:!0},r.parsingConfig||{}),r.insertTexts=Tg({},lrt,r.insertTexts||{}),r.promptTexts=Tg({},urt,r.promptTexts||{}),r.blockStyles=Tg({},frt,r.blockStyles||{}),r.autosave!=null&&(r.autosave.timeFormat=Tg({},crt,r.autosave.timeFormat||{})),r.iconClassMap=Tg({},_s,r.iconClassMap||{}),r.shortcuts=Tg({},ert,r.shortcuts||{}),r.maxHeight=r.maxHeight||void 0,r.direction=r.direction||"ltr",typeof r.maxHeight<"u"?r.minHeight=r.maxHeight:r.minHeight=r.minHeight||"300px",r.errorCallback=r.errorCallback||function(h){alert(h)},r.uploadImage=r.uploadImage||!1,r.imageMaxSize=r.imageMaxSize||2097152,r.imageAccept=r.imageAccept||"image/png, image/jpeg, image/gif, image/avif",r.imageTexts=Tg({},hrt,r.imageTexts||{}),r.errorMessages=Tg({},drt,r.errorMessages||{}),r.imagePathAbsolute=r.imagePathAbsolute||!1,r.imageCSRFName=r.imageCSRFName||"csrfmiddlewaretoken",r.imageCSRFHeader=r.imageCSRFHeader||!1,r.autosave!=null&&r.autosave.unique_id!=null&&r.autosave.unique_id!=""&&(r.autosave.uniqueId=r.autosave.unique_id),r.overlayMode&&r.overlayMode.combine===void 0&&(r.overlayMode.combine=!0),this.options=r,this.render(),r.initialValue&&(!this.options.autosave||this.options.autosave.foundSavedValue!==!0)&&this.value(r.initialValue),r.uploadImage){var l=this;this.codemirror.on("dragenter",function(h,b){l.updateStatusBar("upload-image",l.options.imageTexts.sbOnDragEnter),b.stopPropagation(),b.preventDefault()}),this.codemirror.on("dragend",function(h,b){l.updateStatusBar("upload-image",l.options.imageTexts.sbInit),b.stopPropagation(),b.preventDefault()}),this.codemirror.on("dragleave",function(h,b){l.updateStatusBar("upload-image",l.options.imageTexts.sbInit),b.stopPropagation(),b.preventDefault()}),this.codemirror.on("dragover",function(h,b){l.updateStatusBar("upload-image",l.options.imageTexts.sbOnDragEnter),b.stopPropagation(),b.preventDefault()}),this.codemirror.on("drop",function(h,b){b.stopPropagation(),b.preventDefault(),r.imageUploadFunction?l.uploadImagesUsingCustomFunction(r.imageUploadFunction,b.dataTransfer.files):l.uploadImages(b.dataTransfer.files)}),this.codemirror.on("paste",function(h,b){r.imageUploadFunction?l.uploadImagesUsingCustomFunction(r.imageUploadFunction,b.clipboardData.files):l.uploadImages(b.clipboardData.files)})}}xn.prototype.uploadImages=function(r,e,t){if(r.length!==0){for(var n=[],i=0;i<r.length;i++)n.push(r[i].name),this.uploadImage(r[i],e,t);this.updateStatusBar("upload-image",this.options.imageTexts.sbOnDrop.replace("#images_names#",n.join(", ")))}};xn.prototype.uploadImagesUsingCustomFunction=function(r,e){if(e.length!==0){for(var t=[],n=0;n<e.length;n++)t.push(e[n].name),this.uploadImageUsingCustomFunction(r,e[n]);this.updateStatusBar("upload-image",this.options.imageTexts.sbOnDrop.replace("#images_names#",t.join(", ")))}};xn.prototype.updateStatusBar=function(r,e){if(!!this.gui.statusbar){var t=this.gui.statusbar.getElementsByClassName(r);t.length===1?this.gui.statusbar.getElementsByClassName(r)[0].textContent=e:t.length===0?console.log("EasyMDE: status bar item "+r+" was not found."):console.log("EasyMDE: Several status bar items named "+r+" was found.")}};xn.prototype.markdown=function(r){if(TB){var e;if(this.options&&this.options.renderingConfig&&this.options.renderingConfig.markedOptions?e=this.options.renderingConfig.markedOptions:e={},this.options&&this.options.renderingConfig&&this.options.renderingConfig.singleLineBreaks===!1?e.breaks=!1:e.breaks=!0,this.options&&this.options.renderingConfig&&this.options.renderingConfig.codeSyntaxHighlighting===!0){var t=this.options.renderingConfig.hljs||window.hljs;t&&(e.highlight=function(i,s){return s&&t.getLanguage(s)?t.highlight(s,i).value:t.highlightAuto(i).value})}TB.setOptions(e);var n=TB.parse(r);return this.options.renderingConfig&&typeof this.options.renderingConfig.sanitizerFunction=="function"&&(n=this.options.renderingConfig.sanitizerFunction.call(this,n)),n=rrt(n),n=nrt(n),n}};xn.prototype.render=function(r){if(r||(r=this.element||document.getElementsByTagName("textarea")[0]),this._rendered&&this._rendered===r)return;this.element=r;var e=this.options,t=this,n={};for(var i in e.shortcuts)e.shortcuts[i]!==null&&QS[i]!==null&&function(X){n[dhe(e.shortcuts[X])]=function(){var te=QS[X];typeof te=="function"?te(t):typeof te=="string"&&window.open(te,"_blank")}}(i);n.Enter="newlineAndIndentContinueMarkdownList",n.Tab="tabAndIndentMarkdownList",n["Shift-Tab"]="shiftTabAndUnindentMarkdownList",n.Esc=function(X){X.getOption("fullScreen")&&p0(t)},this.documentOnKeyDown=function(X){X=X||window.event,X.keyCode==27&&t.codemirror.getOption("fullScreen")&&p0(t)},document.addEventListener("keydown",this.documentOnKeyDown,!1);var s,l;e.overlayMode?(Qx.defineMode("overlay-mode",function(X){return Qx.overlayMode(Qx.getMode(X,e.spellChecker!==!1?"spell-checker":"gfm"),e.overlayMode.mode,e.overlayMode.combine)}),s="overlay-mode",l=e.parsingConfig,l.gitHubSpice=!1):(s=e.parsingConfig,s.name="gfm",s.gitHubSpice=!1),e.spellChecker!==!1&&(s="spell-checker",l=e.parsingConfig,l.name="gfm",l.gitHubSpice=!1,typeof e.spellChecker=="function"?e.spellChecker({codeMirrorInstance:Qx}):Jtt({codeMirrorInstance:Qx}));function h(X,te,ne){return{addNew:!1}}if(this.codemirror=Qx.fromTextArea(r,{mode:s,backdrop:l,theme:e.theme!=null?e.theme:"easymde",tabSize:e.tabSize!=null?e.tabSize:2,indentUnit:e.tabSize!=null?e.tabSize:2,indentWithTabs:e.indentWithTabs!==!1,lineNumbers:e.lineNumbers===!0,autofocus:e.autofocus===!0,extraKeys:n,direction:e.direction,lineWrapping:e.lineWrapping!==!1,allowDropFileTypes:["text/plain"],placeholder:e.placeholder||r.getAttribute("placeholder")||"",styleSelectedText:e.styleSelectedText!=null?e.styleSelectedText:!EB(),scrollbarStyle:e.scrollbarStyle!=null?e.scrollbarStyle:"native",configureMouse:h,inputStyle:e.inputStyle!=null?e.inputStyle:EB()?"contenteditable":"textarea",spellcheck:e.nativeSpellcheck!=null?e.nativeSpellcheck:!0,autoRefresh:e.autoRefresh!=null?e.autoRefresh:!1}),this.codemirror.getScrollerElement().style.minHeight=e.minHeight,typeof e.maxHeight<"u"&&(this.codemirror.getScrollerElement().style.height=e.maxHeight),e.forceSync===!0){var b=this.codemirror;b.on("change",function(){b.save()})}this.gui={};var k=document.createElement("div");k.classList.add("EasyMDEContainer"),k.setAttribute("role","application");var E=this.codemirror.getWrapperElement();E.parentNode.insertBefore(k,E),k.appendChild(E),e.toolbar!==!1&&(this.gui.toolbar=this.createToolbar()),e.status!==!1&&(this.gui.statusbar=this.createStatusbar()),e.autosave!=null&&e.autosave.enabled===!0&&(this.autosave(),this.codemirror.on("change",function(){clearTimeout(t._autosave_timeout),t._autosave_timeout=setTimeout(function(){t.autosave()},t.options.autosave.submit_delay||t.options.autosave.delay||1e3)}));function L(X,te){var ne,de=window.getComputedStyle(document.querySelector(".CodeMirror-sizer")).width.replace("px","");return X<de?ne=te+"px":ne=te/X*100+"%",ne}var q=this;function B(X,te){X.setAttribute("data-img-src",te.url),X.setAttribute("style","--bg-image:url("+te.url+");--width:"+te.naturalWidth+"px;--height:"+L(te.naturalWidth,te.naturalHeight)),q.codemirror.setSize()}function j(){!e.previewImagesInEditor||k.querySelectorAll(".cm-image-marker").forEach(function(X){var te=X.parentElement;if(!!te.innerText.match(/^!\[.*?\]\(.*\)/g)&&!te.hasAttribute("data-img-src")){var ne=te.innerText.match("\\((.*)\\)");if(window.EMDEimagesCache||(window.EMDEimagesCache={}),ne&&ne.length>=2){var de=ne[1];if(e.imagesPreviewHandler){var _=e.imagesPreviewHandler(ne[1]);typeof _=="string"&&(de=_)}if(window.EMDEimagesCache[de])B(te,window.EMDEimagesCache[de]);else{var ye=document.createElement("img");ye.onload=function(){window.EMDEimagesCache[de]={naturalWidth:ye.naturalWidth,naturalHeight:ye.naturalHeight,url:de},B(te,window.EMDEimagesCache[de])},ye.src=de}}}})}this.codemirror.on("update",function(){j()}),this.gui.sideBySide=this.createSideBySide(),this._rendered=this.element,(e.autofocus===!0||r.autofocus)&&this.codemirror.focus();var U=this.codemirror;setTimeout(function(){U.refresh()}.bind(U),0)};xn.prototype.cleanup=function(){document.removeEventListener("keydown",this.documentOnKeyDown)};function yhe(){if(typeof localStorage=="object")try{localStorage.setItem("smde_localStorage",1),localStorage.removeItem("smde_localStorage")}catch{return!1}else return!1;return!0}xn.prototype.autosave=function(){if(yhe()){var r=this;if(this.options.autosave.uniqueId==null||this.options.autosave.uniqueId==""){console.log("EasyMDE: You must set a uniqueId to use the autosave feature");return}this.options.autosave.binded!==!0&&(r.element.form!=null&&r.element.form!=null&&r.element.form.addEventListener("submit",function(){clearTimeout(r.autosaveTimeoutId),r.autosaveTimeoutId=void 0,localStorage.removeItem("smde_"+r.options.autosave.uniqueId)}),this.options.autosave.binded=!0),this.options.autosave.loaded!==!0&&(typeof localStorage.getItem("smde_"+this.options.autosave.uniqueId)=="string"&&localStorage.getItem("smde_"+this.options.autosave.uniqueId)!=""&&(this.codemirror.setValue(localStorage.getItem("smde_"+this.options.autosave.uniqueId)),this.options.autosave.foundSavedValue=!0),this.options.autosave.loaded=!0);var e=r.value();e!==""?localStorage.setItem("smde_"+this.options.autosave.uniqueId,e):localStorage.removeItem("smde_"+this.options.autosave.uniqueId);var t=document.getElementById("autosaved");if(t!=null&&t!=null&&t!=""){var n=new Date,i=new Intl.DateTimeFormat([this.options.autosave.timeFormat.locale,"en-US"],this.options.autosave.timeFormat.format).format(n),s=this.options.autosave.text==null?"Autosaved: ":this.options.autosave.text;t.innerHTML=s+i}}else console.log("EasyMDE: localStorage not available, cannot autosave")};xn.prototype.clearAutosavedValue=function(){if(yhe()){if(this.options.autosave==null||this.options.autosave.uniqueId==null||this.options.autosave.uniqueId==""){console.log("EasyMDE: You must set a uniqueId to clear the autosave value");return}localStorage.removeItem("smde_"+this.options.autosave.uniqueId)}else console.log("EasyMDE: localStorage not available, cannot autosave")};xn.prototype.openBrowseFileWindow=function(r,e){var t=this,n=this.gui.toolbar.getElementsByClassName("imageInput")[0];n.click();function i(s){t.options.imageUploadFunction?t.uploadImagesUsingCustomFunction(t.options.imageUploadFunction,s.target.files):t.uploadImages(s.target.files,r,e),n.removeEventListener("change",i)}n.addEventListener("change",i)};xn.prototype.uploadImage=function(r,e,t){var n=this;e=e||function(k){mhe(n,k)};function i(b){n.updateStatusBar("upload-image",b),setTimeout(function(){n.updateStatusBar("upload-image",n.options.imageTexts.sbInit)},1e4),t&&typeof t=="function"&&t(b),n.options.errorCallback(b)}function s(b){var k=n.options.imageTexts.sizeUnits.split(",");return b.replace("#image_name#",r.name).replace("#image_size#",AD(r.size,k)).replace("#image_max_size#",AD(n.options.imageMaxSize,k))}if(r.size>this.options.imageMaxSize){i(s(this.options.errorMessages.fileTooLarge));return}var l=new FormData;l.append("image",r),n.options.imageCSRFToken&&!n.options.imageCSRFHeader&&l.append(n.options.imageCSRFName,n.options.imageCSRFToken);var h=new XMLHttpRequest;h.upload.onprogress=function(b){if(b.lengthComputable){var k=""+Math.round(b.loaded*100/b.total);n.updateStatusBar("upload-image",n.options.imageTexts.sbProgress.replace("#file_name#",r.name).replace("#progress#",k))}},h.open("POST",this.options.imageUploadEndpoint),n.options.imageCSRFToken&&n.options.imageCSRFHeader&&h.setRequestHeader(n.options.imageCSRFName,n.options.imageCSRFToken),h.onload=function(){try{var b=JSON.parse(this.responseText)}catch{console.error("EasyMDE: The server did not return a valid json."),i(s(n.options.errorMessages.importError));return}this.status===200&&b&&!b.error&&b.data&&b.data.filePath?e((n.options.imagePathAbsolute?"":window.location.origin+"/")+b.data.filePath):b.error&&b.error in n.options.errorMessages?i(s(n.options.errorMessages[b.error])):b.error?i(s(b.error)):(console.error("EasyMDE: Received an unexpected response after uploading the image."+this.status+" ("+this.statusText+")"),i(s(n.options.errorMessages.importError)))},h.onerror=function(b){console.error("EasyMDE: An unexpected error occurred when trying to upload the image."+b.target.status+" ("+b.target.statusText+")"),i(n.options.errorMessages.importError)},h.send(l)};xn.prototype.uploadImageUsingCustomFunction=function(r,e){var t=this;function n(l){mhe(t,l)}function i(l){var h=s(l);t.updateStatusBar("upload-image",h),setTimeout(function(){t.updateStatusBar("upload-image",t.options.imageTexts.sbInit)},1e4),t.options.errorCallback(h)}function s(l){var h=t.options.imageTexts.sizeUnits.split(",");return l.replace("#image_name#",e.name).replace("#image_size#",AD(e.size,h)).replace("#image_max_size#",AD(t.options.imageMaxSize,h))}r.apply(this,[e,n,i])};xn.prototype.setPreviewMaxHeight=function(){var r=this.codemirror,e=r.getWrapperElement(),t=e.nextSibling,n=parseInt(window.getComputedStyle(e).paddingTop),i=parseInt(window.getComputedStyle(e).borderTopWidth),s=parseInt(this.options.maxHeight),l=s+n*2+i*2,h=l.toString()+"px";t.style.height=h};xn.prototype.createSideBySide=function(){var r=this.codemirror,e=r.getWrapperElement(),t=e.nextSibling;if(!t||!t.classList.contains("editor-preview-side")){if(t=document.createElement("div"),t.className="editor-preview-side",this.options.previewClass)if(Array.isArray(this.options.previewClass))for(var n=0;n<this.options.previewClass.length;n++)t.classList.add(this.options.previewClass[n]);else typeof this.options.previewClass=="string"&&t.classList.add(this.options.previewClass);e.parentNode.insertBefore(t,e.nextSibling)}if(typeof this.options.maxHeight<"u"&&this.setPreviewMaxHeight(),this.options.syncSideBySidePreviewScroll===!1)return t;var i=!1,s=!1;return r.on("scroll",function(l){if(i){i=!1;return}s=!0;var h=l.getScrollInfo().height-l.getScrollInfo().clientHeight,b=parseFloat(l.getScrollInfo().top)/h,k=(t.scrollHeight-t.clientHeight)*b;t.scrollTop=k}),t.onscroll=function(){if(s){s=!1;return}i=!0;var l=t.scrollHeight-t.clientHeight,h=parseFloat(t.scrollTop)/l,b=(r.getScrollInfo().height-r.getScrollInfo().clientHeight)*h;r.scrollTo(0,b)},t};xn.prototype.createToolbar=function(r){if(r=r||this.options.toolbar,!(!r||r.length===0)){var e;for(e=0;e<r.length;e++)d0[r[e]]!=null&&(r[e]=d0[r[e]]);var t=document.createElement("div");t.className="editor-toolbar",t.setAttribute("role","toolbar");var n=this,i={};for(n.toolbar=r,e=0;e<r.length;e++)if(!(r[e].name=="guide"&&n.options.toolbarGuideIcon===!1)&&!(n.options.hideIcons&&n.options.hideIcons.indexOf(r[e].name)!=-1)&&!((r[e].name=="fullscreen"||r[e].name=="side-by-side")&&EB())){if(r[e]==="|"){for(var s=!1,l=e+1;l<r.length;l++)r[l]!=="|"&&(!n.options.hideIcons||n.options.hideIcons.indexOf(r[l].name)==-1)&&(s=!0);if(!s)continue}(function(k){var E;if(k==="|"?E=ort():k.children?E=irt(k,n.options.toolbarTips,n.options.shortcuts,n):E=ED(k,!0,n.options.toolbarTips,n.options.shortcuts,"button",n),i[k.name||k]=E,t.appendChild(E),k.name==="upload-image"){var L=document.createElement("input");L.className="imageInput",L.type="file",L.multiple=!0,L.name="image",L.accept=n.options.imageAccept,L.style.display="none",L.style.opacity=0,t.appendChild(L)}})(r[e])}n.toolbar_div=t,n.toolbarElements=i;var h=this.codemirror;h.on("cursorActivity",function(){var k=Bv(h);for(var E in i)(function(L){var q=i[L];k[L]?q.classList.add("active"):L!="fullscreen"&&L!="side-by-side"&&q.classList.remove("active")})(E)});var b=h.getWrapperElement();return b.parentNode.insertBefore(t,b),t}};xn.prototype.createStatusbar=function(r){r=r||this.options.status;var e=this.options,t=this.codemirror;if(!(!r||r.length===0)){var n=[],i,s,l,h;for(i=0;i<r.length;i++)if(s=void 0,l=void 0,h=void 0,typeof r[i]=="object")n.push({className:r[i].className,defaultValue:r[i].defaultValue,onUpdate:r[i].onUpdate,onActivity:r[i].onActivity});else{var b=r[i];b==="words"?(h=function(B){B.innerHTML=fhe(t.getValue())},s=function(B){B.innerHTML=fhe(t.getValue())}):b==="lines"?(h=function(B){B.innerHTML=t.lineCount()},s=function(B){B.innerHTML=t.lineCount()}):b==="cursor"?(h=function(B){B.innerHTML="1:1"},l=function(B){var j=t.getCursor(),U=j.line+1,X=j.ch+1;B.innerHTML=U+":"+X}):b==="autosave"?h=function(B){e.autosave!=null&&e.autosave.enabled===!0&&B.setAttribute("id","autosaved")}:b==="upload-image"&&(h=function(B){B.innerHTML=e.imageTexts.sbInit}),n.push({className:b,defaultValue:h,onUpdate:s,onActivity:l})}var k=document.createElement("div");for(k.className="editor-statusbar",i=0;i<n.length;i++){var E=n[i],L=document.createElement("span");L.className=E.className,typeof E.defaultValue=="function"&&E.defaultValue(L),typeof E.onUpdate=="function"&&this.codemirror.on("update",function(B,j){return function(){j.onUpdate(B)}}(L,E)),typeof E.onActivity=="function"&&this.codemirror.on("cursorActivity",function(B,j){return function(){j.onActivity(B)}}(L,E)),k.appendChild(L)}var q=this.codemirror.getWrapperElement();return q.parentNode.insertBefore(k,q.nextSibling),k}};xn.prototype.value=function(r){var e=this.codemirror;if(r===void 0)return e.getValue();if(e.getDoc().setValue(r),this.isPreviewActive()){var t=e.getWrapperElement(),n=t.lastChild,i=this.options.previewRender(r,n);i!==null&&(n.innerHTML=i)}return this};xn.toggleBold=DD;xn.toggleItalic=OD;xn.toggleStrikethrough=ID;xn.toggleBlockquote=LD;xn.toggleHeadingSmaller=ek;xn.toggleHeadingBigger=PD;xn.toggleHeading1=RD;xn.toggleHeading2=FD;xn.toggleHeading3=qD;xn.toggleHeading4=AB;xn.toggleHeading5=DB;xn.toggleHeading6=OB;xn.toggleCodeBlock=MD;xn.toggleUnorderedList=ND;xn.toggleOrderedList=zD;xn.cleanBlock=BD;xn.drawLink=jD;xn.drawImage=UD;xn.drawUploadedImage=IB;xn.drawTable=HD;xn.drawHorizontalRule=WD;xn.undo=VD;xn.redo=$D;xn.togglePreview=GD;xn.toggleSideBySide=e_;xn.toggleFullScreen=p0;xn.prototype.toggleBold=function(){DD(this)};xn.prototype.toggleItalic=function(){OD(this)};xn.prototype.toggleStrikethrough=function(){ID(this)};xn.prototype.toggleBlockquote=function(){LD(this)};xn.prototype.toggleHeadingSmaller=function(){ek(this)};xn.prototype.toggleHeadingBigger=function(){PD(this)};xn.prototype.toggleHeading1=function(){RD(this)};xn.prototype.toggleHeading2=function(){FD(this)};xn.prototype.toggleHeading3=function(){qD(this)};xn.prototype.toggleHeading4=function(){AB(this)};xn.prototype.toggleHeading5=function(){DB(this)};xn.prototype.toggleHeading6=function(){OB(this)};xn.prototype.toggleCodeBlock=function(){MD(this)};xn.prototype.toggleUnorderedList=function(){ND(this)};xn.prototype.toggleOrderedList=function(){zD(this)};xn.prototype.cleanBlock=function(){BD(this)};xn.prototype.drawLink=function(){jD(this)};xn.prototype.drawImage=function(){UD(this)};xn.prototype.drawUploadedImage=function(){IB(this)};xn.prototype.drawTable=function(){HD(this)};xn.prototype.drawHorizontalRule=function(){WD(this)};xn.prototype.undo=function(){VD(this)};xn.prototype.redo=function(){$D(this)};xn.prototype.togglePreview=function(){GD(this)};xn.prototype.toggleSideBySide=function(){e_(this)};xn.prototype.toggleFullScreen=function(){p0(this)};xn.prototype.isPreviewActive=function(){var r=this.codemirror,e=r.getWrapperElement(),t=e.lastChild;return t.classList.contains("editor-preview-active")};xn.prototype.isSideBySideActive=function(){var r=this.codemirror,e=r.getWrapperElement(),t=e.nextSibling;return t.classList.contains("editor-preview-active-side")};xn.prototype.isFullscreenActive=function(){var r=this.codemirror;return r.getOption("fullScreen")};xn.prototype.getState=function(){var r=this.codemirror;return Bv(r)};xn.prototype.toTextArea=function(){var r=this.codemirror,e=r.getWrapperElement(),t=e.parentNode;t&&(this.gui.toolbar&&t.removeChild(this.gui.toolbar),this.gui.statusbar&&t.removeChild(this.gui.statusbar),this.gui.sideBySide&&t.removeChild(this.gui.sideBySide)),t.parentNode.insertBefore(e,t),t.remove(),r.toTextArea(),this.autosaveTimeoutId&&(clearTimeout(this.autosaveTimeoutId),this.autosaveTimeoutId=void 0,this.clearAutosavedValue())};bhe.exports=xn});var _he,KD,whe=Xe(()=>{No();_he=ta(xhe()),KD=class extends pn{get view(){return this.elementTarget.dataset.view}get componentOptions(){try{return JSON.parse(this.elementTarget.dataset.componentOptions)}catch(r){return{}}}connect(){let r={element:this.elementTarget,spellChecker:this.componentOptions.spell_checker};this.view==="show"&&(r.toolbar=!1,r.status=!1);let e=new _he.default(r);this.view==="show"&&(e.codemirror.options.readOnly=!0)}};Qr(KD,"targets",["element"])});var YD,She=Xe(()=>{No();YD=class extends pn{showContent(r){this.contentTarget.classList.toggle("hidden"),r.target.classList.add("hidden")}};Qr(YD,"targets",["content"])});var tk,khe=Xe(()=>{No();tk=class extends pn{connect(){this.resourceName=this.element.dataset.resourceName}toggle(r){let e=!!r.target.checked;document.querySelectorAll(`[data-controller="item-selector"][data-resource-name="${this.resourceName}"] input[type=checkbox]`).forEach(t=>t.checked!==e&&t.click()),this.selectAllEnabled()&&(this.selectAllOverlay(e),e||this.resetUnselected())}selectRow(){let r=!0;this.itemCheckboxTargets.forEach(e=>r=r&&e.checked),this.checkboxTarget.checked=r,this.selectAllEnabled()&&(this.selectAllOverlay(r),this.resetUnselected())}selectAll(r){r.preventDefault(),this.selectedAllValue=!this.selectedAllValue,this.unselectedMessageTarget.classList.toggle("hidden"),this.selectedMessageTarget.classList.toggle("hidden")}resetUnselected(){this.selectedAllValue=!1,this.unselectedMessageTarget.classList.remove("hidden"),this.selectedMessageTarget.classList.add("hidden")}selectAllOverlay(r){r?this.selectAllOverlayTarget.classList.remove("hidden"):this.selectAllOverlayTarget.classList.add("hidden")}selectAllEnabled(){return this.pageCountValue>1&&this.selectedAllQueryValue!=="select_all_disabled"}};Qr(tk,"targets",["itemCheckbox","checkbox","selectAllOverlay","unselectedMessage","selectedMessage"]),Qr(tk,"values",{pageCount:Number,selectedAll:Boolean,selectedAllQuery:String})});var ZD,Che=Xe(()=>{No();ZD=class extends pn{constructor(){super(...arguments);Qr(this,"checkbox",{});Qr(this,"enabledClasses",["text-black"]);Qr(this,"disabledClasses",["text-gray-500"])}get actionsPanelPresent(){return this.actionsButtonElement!==null}get currentIds(){try{return JSON.parse(this.stateHolderElement.dataset.selectedResources)}catch(r){return[]}}get actionLinks(){return document.querySelectorAll('.js-actions-dropdown a[data-actions-picker-target="resourceAction"]')}set currentIds(r){this.stateHolderElement.dataset.selectedResources=JSON.stringify(r),this.actionsPanelPresent&&(r.length>0?this.enableResourceActions():this.disableResourceActions())}connect(){this.resourceName=this.element.dataset.resourceName,this.resourceId=this.element.dataset.resourceId,this.actionsButtonElement=document.querySelector(`[data-actions-dropdown-button="${this.resourceName}"]`),this.stateHolderElement=document.querySelector(`[data-selected-resources-name="${this.resourceName}"]`)}addToSelected(){let r=this.currentIds;r.push(this.resourceId),this.currentIds=r}removeFromSelected(){this.currentIds=this.currentIds.filter(r=>r.toString()!==this.resourceId)}toggle(r){this.checkbox=r.target,this.checkbox.checked?this.addToSelected():this.removeFromSelected()}enableResourceActions(){this.actionLinks.forEach(r=>{r.classList.add(...this.enabledClasses),r.classList.remove(...this.disabledClasses),r.setAttribute("data-href",r.getAttribute("href")),r.dataset.disabled=!1})}disableResourceActions(){this.actionLinks.forEach(r=>{r.classList.remove(...this.enabledClasses),r.classList.add(...this.disabledClasses),r.setAttribute("href",r.getAttribute("data-href")),r.dataset.disabled=!0})}};Qr(ZD,"targets",["panel"])});var XD,The=Xe(()=>{No();Lx();XD=class extends pn{constructor(){super(...arguments);Qr(this,"fieldValue",[]);Qr(this,"options",{})}get keyInputDisabled(){return!this.options.editable||this.options.disable_editing_keys}get valueInputDisabled(){return!this.options.editable}connect(){this.setOptions();try{let r=JSON.parse(this.inputTarget.value);Object.keys(r).forEach(e=>this.fieldValue.push([e,r[e]]))}catch(r){this.fieldValue=[]}this.updateKeyValueComponent()}addRow(){this.options.disable_adding_rows||!this.options.editable||(this.fieldValue.push(["",""]),this.updateKeyValueComponent(),this.focusLastRow())}deleteRow(r){if(this.options.disable_deleting_rows||!this.options.editable)return;let{index:e}=r.params;this.fieldValue.splice(e,1),this.updateTextareaInput(),this.updateKeyValueComponent()}focusLastRow(){return this.rowsTarget.querySelector(".flex.key-value-row:last-child .key-value-input-key").focus()}valueFieldUpdated(r){let{value:e}=r.target,{index:t}=r.target.dataset;this.fieldValue[t][1]=e,this.updateTextareaInput()}keyFieldUpdated(r){let{value:e}=r.target,{index:t}=r.target.dataset;this.fieldValue[t][0]=e,this.updateTextareaInput()}updateTextareaInput(){if(!this.hasInputTarget)return;let r={};this.fieldValue&&this.fieldValue.length>0&&(r=Object.assign(...this.fieldValue.map(([e,t])=>({[e]:t})))),this.inputTarget.innerText=JSON.stringify(r),this.inputTarget.dispatchEvent(new Event("input"))}updateKeyValueComponent(){let r="",e=0;this.fieldValue.forEach(t=>{let[n,i]=t;r+=this.interpolatedRow(n,i,e),e++}),this.rowsTarget.innerHTML=r,window.initTippy()}interpolatedRow(r,e,t){let n=`<div class="flex key-value-row">
|
662
|
+
Maximum file size is #image_max_size#.`,importError:"Something went wrong when uploading the image #image_name#."};function xn(r){r=r||{},r.parent=this;var e=!0;if(r.autoDownloadFontAwesome===!1&&(e=!1),r.autoDownloadFontAwesome!==!0)for(var t=document.styleSheets,n=0;n<t.length;n++)!t[n].href||t[n].href.indexOf("//maxcdn.bootstrapcdn.com/font-awesome/")>-1&&(e=!1);if(e){var i=document.createElement("link");i.rel="stylesheet",i.href="https://maxcdn.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css",document.getElementsByTagName("head")[0].appendChild(i)}if(r.element)this.element=r.element;else if(r.element===null){console.log("EasyMDE: Error. No element was found.");return}if(r.toolbar===void 0){r.toolbar=[];for(var s in d0)Object.prototype.hasOwnProperty.call(d0,s)&&(s.indexOf("separator-")!=-1&&r.toolbar.push("|"),(d0[s].default===!0||r.showIcons&&r.showIcons.constructor===Array&&r.showIcons.indexOf(s)!=-1)&&r.toolbar.push(s))}if(Object.prototype.hasOwnProperty.call(r,"previewClass")||(r.previewClass="editor-preview"),Object.prototype.hasOwnProperty.call(r,"status")||(r.status=["autosave","lines","words","cursor"],r.uploadImage&&r.status.unshift("upload-image")),r.previewRender||(r.previewRender=function(h){return this.parent.markdown(h)}),r.parsingConfig=Tg({highlightFormatting:!0},r.parsingConfig||{}),r.insertTexts=Tg({},lrt,r.insertTexts||{}),r.promptTexts=Tg({},urt,r.promptTexts||{}),r.blockStyles=Tg({},frt,r.blockStyles||{}),r.autosave!=null&&(r.autosave.timeFormat=Tg({},crt,r.autosave.timeFormat||{})),r.iconClassMap=Tg({},_s,r.iconClassMap||{}),r.shortcuts=Tg({},ert,r.shortcuts||{}),r.maxHeight=r.maxHeight||void 0,r.direction=r.direction||"ltr",typeof r.maxHeight<"u"?r.minHeight=r.maxHeight:r.minHeight=r.minHeight||"300px",r.errorCallback=r.errorCallback||function(h){alert(h)},r.uploadImage=r.uploadImage||!1,r.imageMaxSize=r.imageMaxSize||2097152,r.imageAccept=r.imageAccept||"image/png, image/jpeg, image/gif, image/avif",r.imageTexts=Tg({},hrt,r.imageTexts||{}),r.errorMessages=Tg({},drt,r.errorMessages||{}),r.imagePathAbsolute=r.imagePathAbsolute||!1,r.imageCSRFName=r.imageCSRFName||"csrfmiddlewaretoken",r.imageCSRFHeader=r.imageCSRFHeader||!1,r.autosave!=null&&r.autosave.unique_id!=null&&r.autosave.unique_id!=""&&(r.autosave.uniqueId=r.autosave.unique_id),r.overlayMode&&r.overlayMode.combine===void 0&&(r.overlayMode.combine=!0),this.options=r,this.render(),r.initialValue&&(!this.options.autosave||this.options.autosave.foundSavedValue!==!0)&&this.value(r.initialValue),r.uploadImage){var l=this;this.codemirror.on("dragenter",function(h,b){l.updateStatusBar("upload-image",l.options.imageTexts.sbOnDragEnter),b.stopPropagation(),b.preventDefault()}),this.codemirror.on("dragend",function(h,b){l.updateStatusBar("upload-image",l.options.imageTexts.sbInit),b.stopPropagation(),b.preventDefault()}),this.codemirror.on("dragleave",function(h,b){l.updateStatusBar("upload-image",l.options.imageTexts.sbInit),b.stopPropagation(),b.preventDefault()}),this.codemirror.on("dragover",function(h,b){l.updateStatusBar("upload-image",l.options.imageTexts.sbOnDragEnter),b.stopPropagation(),b.preventDefault()}),this.codemirror.on("drop",function(h,b){b.stopPropagation(),b.preventDefault(),r.imageUploadFunction?l.uploadImagesUsingCustomFunction(r.imageUploadFunction,b.dataTransfer.files):l.uploadImages(b.dataTransfer.files)}),this.codemirror.on("paste",function(h,b){r.imageUploadFunction?l.uploadImagesUsingCustomFunction(r.imageUploadFunction,b.clipboardData.files):l.uploadImages(b.clipboardData.files)})}}xn.prototype.uploadImages=function(r,e,t){if(r.length!==0){for(var n=[],i=0;i<r.length;i++)n.push(r[i].name),this.uploadImage(r[i],e,t);this.updateStatusBar("upload-image",this.options.imageTexts.sbOnDrop.replace("#images_names#",n.join(", ")))}};xn.prototype.uploadImagesUsingCustomFunction=function(r,e){if(e.length!==0){for(var t=[],n=0;n<e.length;n++)t.push(e[n].name),this.uploadImageUsingCustomFunction(r,e[n]);this.updateStatusBar("upload-image",this.options.imageTexts.sbOnDrop.replace("#images_names#",t.join(", ")))}};xn.prototype.updateStatusBar=function(r,e){if(!!this.gui.statusbar){var t=this.gui.statusbar.getElementsByClassName(r);t.length===1?this.gui.statusbar.getElementsByClassName(r)[0].textContent=e:t.length===0?console.log("EasyMDE: status bar item "+r+" was not found."):console.log("EasyMDE: Several status bar items named "+r+" was found.")}};xn.prototype.markdown=function(r){if(TB){var e;if(this.options&&this.options.renderingConfig&&this.options.renderingConfig.markedOptions?e=this.options.renderingConfig.markedOptions:e={},this.options&&this.options.renderingConfig&&this.options.renderingConfig.singleLineBreaks===!1?e.breaks=!1:e.breaks=!0,this.options&&this.options.renderingConfig&&this.options.renderingConfig.codeSyntaxHighlighting===!0){var t=this.options.renderingConfig.hljs||window.hljs;t&&(e.highlight=function(i,s){return s&&t.getLanguage(s)?t.highlight(s,i).value:t.highlightAuto(i).value})}TB.setOptions(e);var n=TB.parse(r);return this.options.renderingConfig&&typeof this.options.renderingConfig.sanitizerFunction=="function"&&(n=this.options.renderingConfig.sanitizerFunction.call(this,n)),n=rrt(n),n=nrt(n),n}};xn.prototype.render=function(r){if(r||(r=this.element||document.getElementsByTagName("textarea")[0]),this._rendered&&this._rendered===r)return;this.element=r;var e=this.options,t=this,n={};for(var i in e.shortcuts)e.shortcuts[i]!==null&&QS[i]!==null&&function(X){n[dhe(e.shortcuts[X])]=function(){var te=QS[X];typeof te=="function"?te(t):typeof te=="string"&&window.open(te,"_blank")}}(i);n.Enter="newlineAndIndentContinueMarkdownList",n.Tab="tabAndIndentMarkdownList",n["Shift-Tab"]="shiftTabAndUnindentMarkdownList",n.Esc=function(X){X.getOption("fullScreen")&&p0(t)},this.documentOnKeyDown=function(X){X=X||window.event,X.keyCode==27&&t.codemirror.getOption("fullScreen")&&p0(t)},document.addEventListener("keydown",this.documentOnKeyDown,!1);var s,l;e.overlayMode?(Qx.defineMode("overlay-mode",function(X){return Qx.overlayMode(Qx.getMode(X,e.spellChecker!==!1?"spell-checker":"gfm"),e.overlayMode.mode,e.overlayMode.combine)}),s="overlay-mode",l=e.parsingConfig,l.gitHubSpice=!1):(s=e.parsingConfig,s.name="gfm",s.gitHubSpice=!1),e.spellChecker!==!1&&(s="spell-checker",l=e.parsingConfig,l.name="gfm",l.gitHubSpice=!1,typeof e.spellChecker=="function"?e.spellChecker({codeMirrorInstance:Qx}):Jtt({codeMirrorInstance:Qx}));function h(X,te,ne){return{addNew:!1}}if(this.codemirror=Qx.fromTextArea(r,{mode:s,backdrop:l,theme:e.theme!=null?e.theme:"easymde",tabSize:e.tabSize!=null?e.tabSize:2,indentUnit:e.tabSize!=null?e.tabSize:2,indentWithTabs:e.indentWithTabs!==!1,lineNumbers:e.lineNumbers===!0,autofocus:e.autofocus===!0,extraKeys:n,direction:e.direction,lineWrapping:e.lineWrapping!==!1,allowDropFileTypes:["text/plain"],placeholder:e.placeholder||r.getAttribute("placeholder")||"",styleSelectedText:e.styleSelectedText!=null?e.styleSelectedText:!EB(),scrollbarStyle:e.scrollbarStyle!=null?e.scrollbarStyle:"native",configureMouse:h,inputStyle:e.inputStyle!=null?e.inputStyle:EB()?"contenteditable":"textarea",spellcheck:e.nativeSpellcheck!=null?e.nativeSpellcheck:!0,autoRefresh:e.autoRefresh!=null?e.autoRefresh:!1}),this.codemirror.getScrollerElement().style.minHeight=e.minHeight,typeof e.maxHeight<"u"&&(this.codemirror.getScrollerElement().style.height=e.maxHeight),e.forceSync===!0){var b=this.codemirror;b.on("change",function(){b.save()})}this.gui={};var k=document.createElement("div");k.classList.add("EasyMDEContainer"),k.setAttribute("role","application");var E=this.codemirror.getWrapperElement();E.parentNode.insertBefore(k,E),k.appendChild(E),e.toolbar!==!1&&(this.gui.toolbar=this.createToolbar()),e.status!==!1&&(this.gui.statusbar=this.createStatusbar()),e.autosave!=null&&e.autosave.enabled===!0&&(this.autosave(),this.codemirror.on("change",function(){clearTimeout(t._autosave_timeout),t._autosave_timeout=setTimeout(function(){t.autosave()},t.options.autosave.submit_delay||t.options.autosave.delay||1e3)}));function L(X,te){var ne,de=window.getComputedStyle(document.querySelector(".CodeMirror-sizer")).width.replace("px","");return X<de?ne=te+"px":ne=te/X*100+"%",ne}var q=this;function B(X,te){X.setAttribute("data-img-src",te.url),X.setAttribute("style","--bg-image:url("+te.url+");--width:"+te.naturalWidth+"px;--height:"+L(te.naturalWidth,te.naturalHeight)),q.codemirror.setSize()}function j(){!e.previewImagesInEditor||k.querySelectorAll(".cm-image-marker").forEach(function(X){var te=X.parentElement;if(!!te.innerText.match(/^!\[.*?\]\(.*\)/g)&&!te.hasAttribute("data-img-src")){var ne=te.innerText.match("\\((.*)\\)");if(window.EMDEimagesCache||(window.EMDEimagesCache={}),ne&&ne.length>=2){var de=ne[1];if(e.imagesPreviewHandler){var _=e.imagesPreviewHandler(ne[1]);typeof _=="string"&&(de=_)}if(window.EMDEimagesCache[de])B(te,window.EMDEimagesCache[de]);else{var ye=document.createElement("img");ye.onload=function(){window.EMDEimagesCache[de]={naturalWidth:ye.naturalWidth,naturalHeight:ye.naturalHeight,url:de},B(te,window.EMDEimagesCache[de])},ye.src=de}}}})}this.codemirror.on("update",function(){j()}),this.gui.sideBySide=this.createSideBySide(),this._rendered=this.element,(e.autofocus===!0||r.autofocus)&&this.codemirror.focus();var U=this.codemirror;setTimeout(function(){U.refresh()}.bind(U),0)};xn.prototype.cleanup=function(){document.removeEventListener("keydown",this.documentOnKeyDown)};function yhe(){if(typeof localStorage=="object")try{localStorage.setItem("smde_localStorage",1),localStorage.removeItem("smde_localStorage")}catch{return!1}else return!1;return!0}xn.prototype.autosave=function(){if(yhe()){var r=this;if(this.options.autosave.uniqueId==null||this.options.autosave.uniqueId==""){console.log("EasyMDE: You must set a uniqueId to use the autosave feature");return}this.options.autosave.binded!==!0&&(r.element.form!=null&&r.element.form!=null&&r.element.form.addEventListener("submit",function(){clearTimeout(r.autosaveTimeoutId),r.autosaveTimeoutId=void 0,localStorage.removeItem("smde_"+r.options.autosave.uniqueId)}),this.options.autosave.binded=!0),this.options.autosave.loaded!==!0&&(typeof localStorage.getItem("smde_"+this.options.autosave.uniqueId)=="string"&&localStorage.getItem("smde_"+this.options.autosave.uniqueId)!=""&&(this.codemirror.setValue(localStorage.getItem("smde_"+this.options.autosave.uniqueId)),this.options.autosave.foundSavedValue=!0),this.options.autosave.loaded=!0);var e=r.value();e!==""?localStorage.setItem("smde_"+this.options.autosave.uniqueId,e):localStorage.removeItem("smde_"+this.options.autosave.uniqueId);var t=document.getElementById("autosaved");if(t!=null&&t!=null&&t!=""){var n=new Date,i=new Intl.DateTimeFormat([this.options.autosave.timeFormat.locale,"en-US"],this.options.autosave.timeFormat.format).format(n),s=this.options.autosave.text==null?"Autosaved: ":this.options.autosave.text;t.innerHTML=s+i}}else console.log("EasyMDE: localStorage not available, cannot autosave")};xn.prototype.clearAutosavedValue=function(){if(yhe()){if(this.options.autosave==null||this.options.autosave.uniqueId==null||this.options.autosave.uniqueId==""){console.log("EasyMDE: You must set a uniqueId to clear the autosave value");return}localStorage.removeItem("smde_"+this.options.autosave.uniqueId)}else console.log("EasyMDE: localStorage not available, cannot autosave")};xn.prototype.openBrowseFileWindow=function(r,e){var t=this,n=this.gui.toolbar.getElementsByClassName("imageInput")[0];n.click();function i(s){t.options.imageUploadFunction?t.uploadImagesUsingCustomFunction(t.options.imageUploadFunction,s.target.files):t.uploadImages(s.target.files,r,e),n.removeEventListener("change",i)}n.addEventListener("change",i)};xn.prototype.uploadImage=function(r,e,t){var n=this;e=e||function(k){mhe(n,k)};function i(b){n.updateStatusBar("upload-image",b),setTimeout(function(){n.updateStatusBar("upload-image",n.options.imageTexts.sbInit)},1e4),t&&typeof t=="function"&&t(b),n.options.errorCallback(b)}function s(b){var k=n.options.imageTexts.sizeUnits.split(",");return b.replace("#image_name#",r.name).replace("#image_size#",AD(r.size,k)).replace("#image_max_size#",AD(n.options.imageMaxSize,k))}if(r.size>this.options.imageMaxSize){i(s(this.options.errorMessages.fileTooLarge));return}var l=new FormData;l.append("image",r),n.options.imageCSRFToken&&!n.options.imageCSRFHeader&&l.append(n.options.imageCSRFName,n.options.imageCSRFToken);var h=new XMLHttpRequest;h.upload.onprogress=function(b){if(b.lengthComputable){var k=""+Math.round(b.loaded*100/b.total);n.updateStatusBar("upload-image",n.options.imageTexts.sbProgress.replace("#file_name#",r.name).replace("#progress#",k))}},h.open("POST",this.options.imageUploadEndpoint),n.options.imageCSRFToken&&n.options.imageCSRFHeader&&h.setRequestHeader(n.options.imageCSRFName,n.options.imageCSRFToken),h.onload=function(){try{var b=JSON.parse(this.responseText)}catch{console.error("EasyMDE: The server did not return a valid json."),i(s(n.options.errorMessages.importError));return}this.status===200&&b&&!b.error&&b.data&&b.data.filePath?e((n.options.imagePathAbsolute?"":window.location.origin+"/")+b.data.filePath):b.error&&b.error in n.options.errorMessages?i(s(n.options.errorMessages[b.error])):b.error?i(s(b.error)):(console.error("EasyMDE: Received an unexpected response after uploading the image."+this.status+" ("+this.statusText+")"),i(s(n.options.errorMessages.importError)))},h.onerror=function(b){console.error("EasyMDE: An unexpected error occurred when trying to upload the image."+b.target.status+" ("+b.target.statusText+")"),i(n.options.errorMessages.importError)},h.send(l)};xn.prototype.uploadImageUsingCustomFunction=function(r,e){var t=this;function n(l){mhe(t,l)}function i(l){var h=s(l);t.updateStatusBar("upload-image",h),setTimeout(function(){t.updateStatusBar("upload-image",t.options.imageTexts.sbInit)},1e4),t.options.errorCallback(h)}function s(l){var h=t.options.imageTexts.sizeUnits.split(",");return l.replace("#image_name#",e.name).replace("#image_size#",AD(e.size,h)).replace("#image_max_size#",AD(t.options.imageMaxSize,h))}r.apply(this,[e,n,i])};xn.prototype.setPreviewMaxHeight=function(){var r=this.codemirror,e=r.getWrapperElement(),t=e.nextSibling,n=parseInt(window.getComputedStyle(e).paddingTop),i=parseInt(window.getComputedStyle(e).borderTopWidth),s=parseInt(this.options.maxHeight),l=s+n*2+i*2,h=l.toString()+"px";t.style.height=h};xn.prototype.createSideBySide=function(){var r=this.codemirror,e=r.getWrapperElement(),t=e.nextSibling;if(!t||!t.classList.contains("editor-preview-side")){if(t=document.createElement("div"),t.className="editor-preview-side",this.options.previewClass)if(Array.isArray(this.options.previewClass))for(var n=0;n<this.options.previewClass.length;n++)t.classList.add(this.options.previewClass[n]);else typeof this.options.previewClass=="string"&&t.classList.add(this.options.previewClass);e.parentNode.insertBefore(t,e.nextSibling)}if(typeof this.options.maxHeight<"u"&&this.setPreviewMaxHeight(),this.options.syncSideBySidePreviewScroll===!1)return t;var i=!1,s=!1;return r.on("scroll",function(l){if(i){i=!1;return}s=!0;var h=l.getScrollInfo().height-l.getScrollInfo().clientHeight,b=parseFloat(l.getScrollInfo().top)/h,k=(t.scrollHeight-t.clientHeight)*b;t.scrollTop=k}),t.onscroll=function(){if(s){s=!1;return}i=!0;var l=t.scrollHeight-t.clientHeight,h=parseFloat(t.scrollTop)/l,b=(r.getScrollInfo().height-r.getScrollInfo().clientHeight)*h;r.scrollTo(0,b)},t};xn.prototype.createToolbar=function(r){if(r=r||this.options.toolbar,!(!r||r.length===0)){var e;for(e=0;e<r.length;e++)d0[r[e]]!=null&&(r[e]=d0[r[e]]);var t=document.createElement("div");t.className="editor-toolbar",t.setAttribute("role","toolbar");var n=this,i={};for(n.toolbar=r,e=0;e<r.length;e++)if(!(r[e].name=="guide"&&n.options.toolbarGuideIcon===!1)&&!(n.options.hideIcons&&n.options.hideIcons.indexOf(r[e].name)!=-1)&&!((r[e].name=="fullscreen"||r[e].name=="side-by-side")&&EB())){if(r[e]==="|"){for(var s=!1,l=e+1;l<r.length;l++)r[l]!=="|"&&(!n.options.hideIcons||n.options.hideIcons.indexOf(r[l].name)==-1)&&(s=!0);if(!s)continue}(function(k){var E;if(k==="|"?E=ort():k.children?E=irt(k,n.options.toolbarTips,n.options.shortcuts,n):E=ED(k,!0,n.options.toolbarTips,n.options.shortcuts,"button",n),i[k.name||k]=E,t.appendChild(E),k.name==="upload-image"){var L=document.createElement("input");L.className="imageInput",L.type="file",L.multiple=!0,L.name="image",L.accept=n.options.imageAccept,L.style.display="none",L.style.opacity=0,t.appendChild(L)}})(r[e])}n.toolbar_div=t,n.toolbarElements=i;var h=this.codemirror;h.on("cursorActivity",function(){var k=Bv(h);for(var E in i)(function(L){var q=i[L];k[L]?q.classList.add("active"):L!="fullscreen"&&L!="side-by-side"&&q.classList.remove("active")})(E)});var b=h.getWrapperElement();return b.parentNode.insertBefore(t,b),t}};xn.prototype.createStatusbar=function(r){r=r||this.options.status;var e=this.options,t=this.codemirror;if(!(!r||r.length===0)){var n=[],i,s,l,h;for(i=0;i<r.length;i++)if(s=void 0,l=void 0,h=void 0,typeof r[i]=="object")n.push({className:r[i].className,defaultValue:r[i].defaultValue,onUpdate:r[i].onUpdate,onActivity:r[i].onActivity});else{var b=r[i];b==="words"?(h=function(B){B.innerHTML=fhe(t.getValue())},s=function(B){B.innerHTML=fhe(t.getValue())}):b==="lines"?(h=function(B){B.innerHTML=t.lineCount()},s=function(B){B.innerHTML=t.lineCount()}):b==="cursor"?(h=function(B){B.innerHTML="1:1"},l=function(B){var j=t.getCursor(),U=j.line+1,X=j.ch+1;B.innerHTML=U+":"+X}):b==="autosave"?h=function(B){e.autosave!=null&&e.autosave.enabled===!0&&B.setAttribute("id","autosaved")}:b==="upload-image"&&(h=function(B){B.innerHTML=e.imageTexts.sbInit}),n.push({className:b,defaultValue:h,onUpdate:s,onActivity:l})}var k=document.createElement("div");for(k.className="editor-statusbar",i=0;i<n.length;i++){var E=n[i],L=document.createElement("span");L.className=E.className,typeof E.defaultValue=="function"&&E.defaultValue(L),typeof E.onUpdate=="function"&&this.codemirror.on("update",function(B,j){return function(){j.onUpdate(B)}}(L,E)),typeof E.onActivity=="function"&&this.codemirror.on("cursorActivity",function(B,j){return function(){j.onActivity(B)}}(L,E)),k.appendChild(L)}var q=this.codemirror.getWrapperElement();return q.parentNode.insertBefore(k,q.nextSibling),k}};xn.prototype.value=function(r){var e=this.codemirror;if(r===void 0)return e.getValue();if(e.getDoc().setValue(r),this.isPreviewActive()){var t=e.getWrapperElement(),n=t.lastChild,i=this.options.previewRender(r,n);i!==null&&(n.innerHTML=i)}return this};xn.toggleBold=DD;xn.toggleItalic=OD;xn.toggleStrikethrough=ID;xn.toggleBlockquote=LD;xn.toggleHeadingSmaller=ek;xn.toggleHeadingBigger=PD;xn.toggleHeading1=RD;xn.toggleHeading2=FD;xn.toggleHeading3=qD;xn.toggleHeading4=AB;xn.toggleHeading5=DB;xn.toggleHeading6=OB;xn.toggleCodeBlock=MD;xn.toggleUnorderedList=ND;xn.toggleOrderedList=zD;xn.cleanBlock=BD;xn.drawLink=jD;xn.drawImage=UD;xn.drawUploadedImage=IB;xn.drawTable=HD;xn.drawHorizontalRule=WD;xn.undo=VD;xn.redo=$D;xn.togglePreview=GD;xn.toggleSideBySide=e_;xn.toggleFullScreen=p0;xn.prototype.toggleBold=function(){DD(this)};xn.prototype.toggleItalic=function(){OD(this)};xn.prototype.toggleStrikethrough=function(){ID(this)};xn.prototype.toggleBlockquote=function(){LD(this)};xn.prototype.toggleHeadingSmaller=function(){ek(this)};xn.prototype.toggleHeadingBigger=function(){PD(this)};xn.prototype.toggleHeading1=function(){RD(this)};xn.prototype.toggleHeading2=function(){FD(this)};xn.prototype.toggleHeading3=function(){qD(this)};xn.prototype.toggleHeading4=function(){AB(this)};xn.prototype.toggleHeading5=function(){DB(this)};xn.prototype.toggleHeading6=function(){OB(this)};xn.prototype.toggleCodeBlock=function(){MD(this)};xn.prototype.toggleUnorderedList=function(){ND(this)};xn.prototype.toggleOrderedList=function(){zD(this)};xn.prototype.cleanBlock=function(){BD(this)};xn.prototype.drawLink=function(){jD(this)};xn.prototype.drawImage=function(){UD(this)};xn.prototype.drawUploadedImage=function(){IB(this)};xn.prototype.drawTable=function(){HD(this)};xn.prototype.drawHorizontalRule=function(){WD(this)};xn.prototype.undo=function(){VD(this)};xn.prototype.redo=function(){$D(this)};xn.prototype.togglePreview=function(){GD(this)};xn.prototype.toggleSideBySide=function(){e_(this)};xn.prototype.toggleFullScreen=function(){p0(this)};xn.prototype.isPreviewActive=function(){var r=this.codemirror,e=r.getWrapperElement(),t=e.lastChild;return t.classList.contains("editor-preview-active")};xn.prototype.isSideBySideActive=function(){var r=this.codemirror,e=r.getWrapperElement(),t=e.nextSibling;return t.classList.contains("editor-preview-active-side")};xn.prototype.isFullscreenActive=function(){var r=this.codemirror;return r.getOption("fullScreen")};xn.prototype.getState=function(){var r=this.codemirror;return Bv(r)};xn.prototype.toTextArea=function(){var r=this.codemirror,e=r.getWrapperElement(),t=e.parentNode;t&&(this.gui.toolbar&&t.removeChild(this.gui.toolbar),this.gui.statusbar&&t.removeChild(this.gui.statusbar),this.gui.sideBySide&&t.removeChild(this.gui.sideBySide)),t.parentNode.insertBefore(e,t),t.remove(),r.toTextArea(),this.autosaveTimeoutId&&(clearTimeout(this.autosaveTimeoutId),this.autosaveTimeoutId=void 0,this.clearAutosavedValue())};bhe.exports=xn});var _he,KD,whe=Xe(()=>{No();_he=ta(xhe()),KD=class extends pn{get view(){return this.elementTarget.dataset.view}get componentOptions(){try{return JSON.parse(this.elementTarget.dataset.componentOptions)}catch(r){return{}}}connect(){let r={element:this.elementTarget,spellChecker:this.componentOptions.spell_checker,autoRefresh:{delay:500}};this.view==="show"&&(r.toolbar=!1,r.status=!1);let e=new _he.default(r);this.view==="show"&&(e.codemirror.options.readOnly=!0)}};Qr(KD,"targets",["element"])});var YD,She=Xe(()=>{No();YD=class extends pn{showContent(r){this.contentTarget.classList.toggle("hidden"),r.target.classList.add("hidden")}};Qr(YD,"targets",["content"])});var tk,khe=Xe(()=>{No();tk=class extends pn{connect(){this.resourceName=this.element.dataset.resourceName}toggle(r){let e=!!r.target.checked;document.querySelectorAll(`[data-controller="item-selector"][data-resource-name="${this.resourceName}"] input[type=checkbox]`).forEach(t=>t.checked!==e&&t.click()),this.selectAllEnabled()&&(this.selectAllOverlay(e),e||this.resetUnselected())}selectRow(){let r=!0;this.itemCheckboxTargets.forEach(e=>r=r&&e.checked),this.checkboxTarget.checked=r,this.selectAllEnabled()&&(this.selectAllOverlay(r),this.resetUnselected())}selectAll(r){r.preventDefault(),this.selectedAllValue=!this.selectedAllValue,this.unselectedMessageTarget.classList.toggle("hidden"),this.selectedMessageTarget.classList.toggle("hidden")}resetUnselected(){this.selectedAllValue=!1,this.unselectedMessageTarget.classList.remove("hidden"),this.selectedMessageTarget.classList.add("hidden")}selectAllOverlay(r){r?this.selectAllOverlayTarget.classList.remove("hidden"):this.selectAllOverlayTarget.classList.add("hidden")}selectAllEnabled(){return this.pageCountValue>1&&this.selectedAllQueryValue!=="select_all_disabled"}};Qr(tk,"targets",["itemCheckbox","checkbox","selectAllOverlay","unselectedMessage","selectedMessage"]),Qr(tk,"values",{pageCount:Number,selectedAll:Boolean,selectedAllQuery:String})});var ZD,Che=Xe(()=>{No();ZD=class extends pn{constructor(){super(...arguments);Qr(this,"checkbox",{});Qr(this,"enabledClasses",["text-black"]);Qr(this,"disabledClasses",["text-gray-500"])}get actionsPanelPresent(){return this.actionsButtonElement!==null}get currentIds(){try{return JSON.parse(this.stateHolderElement.dataset.selectedResources)}catch(r){return[]}}get actionLinks(){return document.querySelectorAll('.js-actions-dropdown a[data-actions-picker-target="resourceAction"]')}set currentIds(r){this.stateHolderElement.dataset.selectedResources=JSON.stringify(r),this.actionsPanelPresent&&(r.length>0?this.enableResourceActions():this.disableResourceActions())}connect(){this.resourceName=this.element.dataset.resourceName,this.resourceId=this.element.dataset.resourceId,this.actionsButtonElement=document.querySelector(`[data-actions-dropdown-button="${this.resourceName}"]`),this.stateHolderElement=document.querySelector(`[data-selected-resources-name="${this.resourceName}"]`)}addToSelected(){let r=this.currentIds;r.push(this.resourceId),this.currentIds=r}removeFromSelected(){this.currentIds=this.currentIds.filter(r=>r.toString()!==this.resourceId)}toggle(r){this.checkbox=r.target,this.checkbox.checked?this.addToSelected():this.removeFromSelected()}enableResourceActions(){this.actionLinks.forEach(r=>{r.classList.add(...this.enabledClasses),r.classList.remove(...this.disabledClasses),r.setAttribute("data-href",r.getAttribute("href")),r.dataset.disabled=!1})}disableResourceActions(){this.actionLinks.forEach(r=>{r.classList.remove(...this.enabledClasses),r.classList.add(...this.disabledClasses),r.setAttribute("href",r.getAttribute("data-href")),r.dataset.disabled=!0})}};Qr(ZD,"targets",["panel"])});var XD,The=Xe(()=>{No();Lx();XD=class extends pn{constructor(){super(...arguments);Qr(this,"fieldValue",[]);Qr(this,"options",{})}get keyInputDisabled(){return!this.options.editable||this.options.disable_editing_keys}get valueInputDisabled(){return!this.options.editable}connect(){this.setOptions();try{let r=JSON.parse(this.inputTarget.value);Object.keys(r).forEach(e=>this.fieldValue.push([e,r[e]]))}catch(r){this.fieldValue=[]}this.updateKeyValueComponent()}addRow(){this.options.disable_adding_rows||!this.options.editable||(this.fieldValue.push(["",""]),this.updateKeyValueComponent(),this.focusLastRow())}deleteRow(r){if(this.options.disable_deleting_rows||!this.options.editable)return;let{index:e}=r.params;this.fieldValue.splice(e,1),this.updateTextareaInput(),this.updateKeyValueComponent()}focusLastRow(){return this.rowsTarget.querySelector(".flex.key-value-row:last-child .key-value-input-key").focus()}valueFieldUpdated(r){let{value:e}=r.target,{index:t}=r.target.dataset;this.fieldValue[t][1]=e,this.updateTextareaInput()}keyFieldUpdated(r){let{value:e}=r.target,{index:t}=r.target.dataset;this.fieldValue[t][0]=e,this.updateTextareaInput()}updateTextareaInput(){if(!this.hasInputTarget)return;let r={};this.fieldValue&&this.fieldValue.length>0&&(r=Object.assign(...this.fieldValue.map(([e,t])=>({[e]:t})))),this.inputTarget.innerText=JSON.stringify(r),this.inputTarget.dispatchEvent(new Event("input"))}updateKeyValueComponent(){let r="",e=0;this.fieldValue.forEach(t=>{let[n,i]=t;r+=this.interpolatedRow(n,i,e),e++}),this.rowsTarget.innerHTML=r,window.initTippy()}interpolatedRow(r,e,t){let n=`<div class="flex key-value-row">
|
663
663
|
${this.inputField("key",t,r,e)}
|
664
664
|
${this.inputField("value",t,r,e)}`;return this.options.editable&&(n+=`<a
|
665
665
|
href="javascript:void(0);"
|