polaris_view_components 0.4.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (169) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +12 -2
  3. data/app/assets/javascripts/polaris_view_components/autocomplete_controller.js +136 -0
  4. data/app/assets/javascripts/polaris_view_components/button_controller.js +47 -0
  5. data/app/assets/javascripts/polaris_view_components/dropzone_controller.js +495 -0
  6. data/app/assets/javascripts/polaris_view_components/frame_controller.js +41 -0
  7. data/app/assets/javascripts/polaris_view_components/index.js +21 -1
  8. data/app/assets/javascripts/polaris_view_components/modal_controller.js +25 -0
  9. data/app/assets/javascripts/polaris_view_components/option_list_controller.js +41 -0
  10. data/app/assets/javascripts/polaris_view_components/polaris_controller.js +28 -0
  11. data/app/assets/javascripts/polaris_view_components/popover_controller.js +56 -0
  12. data/app/assets/javascripts/polaris_view_components/scrollable_controller.js +60 -0
  13. data/app/assets/javascripts/polaris_view_components/select_controller.js +6 -4
  14. data/app/assets/javascripts/polaris_view_components/text_field_controller.js +4 -0
  15. data/app/assets/javascripts/polaris_view_components/toast_controller.js +68 -0
  16. data/app/assets/javascripts/polaris_view_components/utils.js +23 -0
  17. data/app/assets/javascripts/polaris_view_components.js +2406 -5
  18. data/app/assets/stylesheets/polaris_view_components/custom.css +123 -0
  19. data/app/assets/stylesheets/polaris_view_components/shopify_navigation.css +0 -4
  20. data/app/assets/stylesheets/polaris_view_components.css +2162 -2019
  21. data/app/assets/stylesheets/polaris_view_components.postcss.css +1 -1
  22. data/app/components/polaris/action.rb +3 -3
  23. data/app/components/polaris/action_list/item_component.html.erb +35 -0
  24. data/app/components/polaris/action_list/item_component.rb +41 -0
  25. data/app/components/polaris/action_list/section_component.html.erb +16 -0
  26. data/app/components/polaris/action_list/section_component.rb +26 -0
  27. data/app/components/polaris/action_list_component.html.erb +13 -0
  28. data/app/components/polaris/action_list_component.rb +25 -0
  29. data/app/components/polaris/autocomplete/action_component.rb +7 -0
  30. data/app/components/polaris/autocomplete/option_component.rb +35 -0
  31. data/app/components/polaris/autocomplete/section_component.html.erb +9 -0
  32. data/app/components/polaris/autocomplete/section_component.rb +12 -0
  33. data/app/components/polaris/autocomplete_component.html.erb +30 -0
  34. data/app/components/polaris/autocomplete_component.rb +65 -0
  35. data/app/components/polaris/avatar_component.rb +2 -2
  36. data/app/components/polaris/badge_component.rb +2 -2
  37. data/app/components/polaris/banner_component.rb +8 -8
  38. data/app/components/polaris/base_button.rb +2 -2
  39. data/app/components/polaris/base_checkbox.rb +48 -0
  40. data/app/components/polaris/base_component.rb +1 -1
  41. data/app/components/polaris/base_radio_button.rb +38 -0
  42. data/app/components/polaris/button_component.html.erb +13 -0
  43. data/app/components/polaris/button_group_component.rb +8 -8
  44. data/app/components/polaris/callout_card_component.rb +6 -6
  45. data/app/components/polaris/caption_component.rb +3 -3
  46. data/app/components/polaris/card/header_component.rb +2 -2
  47. data/app/components/polaris/card/section_component.rb +8 -4
  48. data/app/components/polaris/card_component.html.erb +4 -0
  49. data/app/components/polaris/card_component.rb +6 -5
  50. data/app/components/polaris/character_count.rb +10 -10
  51. data/app/components/polaris/checkbox_component.html.erb +1 -5
  52. data/app/components/polaris/checkbox_component.rb +20 -13
  53. data/app/components/polaris/choice_component.rb +2 -2
  54. data/app/components/polaris/choice_list_component.rb +6 -6
  55. data/app/components/polaris/component.rb +6 -1
  56. data/app/components/polaris/data_table/cell_component.rb +4 -4
  57. data/app/components/polaris/data_table/column_component.rb +1 -1
  58. data/app/components/polaris/data_table_component.rb +4 -4
  59. data/app/components/polaris/description_list_component.rb +5 -5
  60. data/app/components/polaris/display_text_component.rb +3 -3
  61. data/app/components/polaris/dropzone_component.html.erb +156 -0
  62. data/app/components/polaris/dropzone_component.rb +150 -0
  63. data/app/components/polaris/empty_state_component.rb +4 -4
  64. data/app/components/polaris/exception_list/item_component.rb +3 -3
  65. data/app/components/polaris/exception_list_component.rb +2 -2
  66. data/app/components/polaris/filters_component.html.erb +35 -0
  67. data/app/components/polaris/filters_component.rb +91 -0
  68. data/app/components/polaris/footer_help_component.rb +2 -2
  69. data/app/components/polaris/form_layout/group_component.rb +5 -5
  70. data/app/components/polaris/form_layout/item_component.rb +2 -2
  71. data/app/components/polaris/form_layout_component.rb +4 -4
  72. data/app/components/polaris/frame/save_bar_component.html.erb +23 -0
  73. data/app/components/polaris/frame/save_bar_component.rb +31 -0
  74. data/app/components/polaris/frame/top_bar_component.html.erb +30 -0
  75. data/app/components/polaris/frame/top_bar_component.rb +18 -0
  76. data/app/components/polaris/frame_component.html.erb +44 -0
  77. data/app/components/polaris/frame_component.rb +33 -0
  78. data/app/components/polaris/heading_component.rb +2 -2
  79. data/app/components/polaris/headless_button.html.erb +13 -0
  80. data/app/components/polaris/headless_button.rb +18 -6
  81. data/app/components/polaris/icon_component.rb +3 -3
  82. data/app/components/polaris/index_table/cell_component.rb +22 -0
  83. data/app/components/polaris/index_table/column_component.rb +13 -0
  84. data/app/components/polaris/index_table_component.html.erb +28 -0
  85. data/app/components/polaris/index_table_component.rb +25 -0
  86. data/app/components/polaris/inline_error_component.html.erb +2 -2
  87. data/app/components/polaris/inline_error_component.rb +8 -2
  88. data/app/components/polaris/label_component.rb +3 -3
  89. data/app/components/polaris/labelled_component.rb +3 -3
  90. data/app/components/polaris/layout/annotated_section.rb +2 -2
  91. data/app/components/polaris/layout/section.rb +2 -2
  92. data/app/components/polaris/layout_component.rb +4 -4
  93. data/app/components/polaris/link_component.rb +4 -4
  94. data/app/components/polaris/list_component.rb +5 -5
  95. data/app/components/polaris/logo.rb +13 -0
  96. data/app/components/polaris/modal/section_component.rb +19 -0
  97. data/app/components/polaris/modal_component.html.erb +79 -0
  98. data/app/components/polaris/modal_component.rb +98 -0
  99. data/app/components/polaris/navigation/item_component.html.erb +31 -0
  100. data/app/components/polaris/navigation/item_component.rb +85 -0
  101. data/app/components/polaris/navigation/section_component.html.erb +17 -0
  102. data/app/components/polaris/navigation/section_component.rb +64 -0
  103. data/app/components/polaris/navigation_component.html.erb +29 -0
  104. data/app/components/polaris/navigation_component.rb +15 -0
  105. data/app/components/polaris/option_list/checkbox_component.html.erb +14 -0
  106. data/app/components/polaris/option_list/checkbox_component.rb +37 -0
  107. data/app/components/polaris/option_list/option_component.rb +24 -0
  108. data/app/components/polaris/option_list/radio_button_component.rb +54 -0
  109. data/app/components/polaris/option_list/section_component.html.erb +14 -0
  110. data/app/components/polaris/option_list/section_component.rb +53 -0
  111. data/app/components/polaris/option_list_component.html.erb +15 -0
  112. data/app/components/polaris/option_list_component.rb +67 -0
  113. data/app/components/polaris/page_actions_component.rb +22 -7
  114. data/app/components/polaris/page_component.rb +5 -5
  115. data/app/components/polaris/pagination_component.rb +2 -6
  116. data/app/components/polaris/popover/pane_component.html.erb +25 -0
  117. data/app/components/polaris/popover/pane_component.rb +20 -0
  118. data/app/components/polaris/popover/section_component.rb +19 -0
  119. data/app/components/polaris/popover_component.html.erb +31 -0
  120. data/app/components/polaris/popover_component.rb +113 -0
  121. data/app/components/polaris/progress_bar_component.rb +6 -6
  122. data/app/components/polaris/radio_button_component.html.erb +1 -6
  123. data/app/components/polaris/radio_button_component.rb +18 -8
  124. data/app/components/polaris/resource_item_component.html.erb +16 -6
  125. data/app/components/polaris/resource_item_component.rb +43 -10
  126. data/app/components/polaris/resource_list_component.html.erb +10 -0
  127. data/app/components/polaris/resource_list_component.rb +5 -11
  128. data/app/components/polaris/scrollable_component.html.erb +5 -0
  129. data/app/components/polaris/scrollable_component.rb +48 -0
  130. data/app/components/polaris/select_component.rb +11 -6
  131. data/app/components/polaris/setting_toggle_component.html.erb +10 -0
  132. data/app/components/polaris/setting_toggle_component.rb +24 -0
  133. data/app/components/polaris/shopify_navigation_component.rb +8 -8
  134. data/app/components/polaris/skeleton_body_text_component.rb +2 -2
  135. data/app/components/polaris/spacer_component.rb +4 -4
  136. data/app/components/polaris/spinner_component.rb +3 -3
  137. data/app/components/polaris/stack/item_component.rb +15 -0
  138. data/app/components/polaris/stack_component.rb +6 -22
  139. data/app/components/polaris/subheading_component.rb +2 -2
  140. data/app/components/polaris/tabs/tab_component.html.erb +10 -0
  141. data/app/components/polaris/tabs/tab_component.rb +34 -0
  142. data/app/components/polaris/tabs_component.html.erb +7 -0
  143. data/app/components/polaris/tabs_component.rb +37 -0
  144. data/app/components/polaris/tag_component.rb +3 -2
  145. data/app/components/polaris/text_container_component.rb +3 -3
  146. data/app/components/polaris/text_field_component.rb +25 -11
  147. data/app/components/polaris/text_style_component.rb +12 -3
  148. data/app/components/polaris/thumbnail_component.rb +3 -3
  149. data/app/components/polaris/toast_component.html.erb +21 -0
  150. data/app/components/polaris/toast_component.rb +40 -0
  151. data/app/components/polaris/top_bar/user_menu_component.html.erb +19 -0
  152. data/app/components/polaris/top_bar/user_menu_component.rb +9 -0
  153. data/app/components/polaris/visually_hidden_component.rb +1 -1
  154. data/app/helpers/polaris/form_builder.rb +44 -8
  155. data/app/helpers/polaris/url_helper.rb +3 -3
  156. data/app/helpers/polaris/view_helper.rb +37 -7
  157. data/app/validators/type_validator.rb +2 -2
  158. data/lib/generators/polaris_view_components/install_generator.rb +5 -5
  159. data/lib/polaris/view_components/engine.rb +16 -2
  160. data/lib/polaris/view_components/version.rb +1 -1
  161. data/lib/polaris_view_components.rb +1 -1
  162. metadata +85 -16
  163. data/app/components/polaris/application_component.rb +0 -35
  164. data/app/components/polaris/dropzone/component.html.erb +0 -72
  165. data/app/components/polaris/dropzone/component.rb +0 -128
  166. data/app/components/polaris/dropzone/controller.js +0 -226
  167. data/app/components/polaris/dropzone/utils.js +0 -57
  168. data/app/components/polaris/new_component.rb +0 -10
  169. data/app/helpers/polaris/conditional_helper.rb +0 -11
@@ -1,5 +1,2281 @@
1
1
  import { Controller } from "@hotwired/stimulus";
2
2
 
3
+ import { get } from "@rails/request.js";
4
+
5
+ function debounce$1(fn, wait) {
6
+ let timeoutId;
7
+ return (...args) => {
8
+ clearTimeout(timeoutId);
9
+ timeoutId = setTimeout((() => fn.apply(this, args)), wait);
10
+ };
11
+ }
12
+
13
+ function formatBytes(bytes, decimals) {
14
+ if (bytes == 0) return "0 Bytes";
15
+ const k = 1024, dm = decimals || 2, sizes = [ "Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB" ], i = Math.floor(Math.log(bytes) / Math.log(k));
16
+ return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + " " + sizes[i];
17
+ }
18
+
19
+ class Autocomplete extends Controller {
20
+ static targets=[ "popover", "input", "results", "option", "emptyState" ];
21
+ static values={
22
+ url: String,
23
+ selected: Array
24
+ };
25
+ connect() {
26
+ this.inputTarget.addEventListener("input", this.onInputChange);
27
+ }
28
+ disconnect() {
29
+ this.inputTarget.removeEventListener("input", this.onInputChange);
30
+ }
31
+ toggle() {
32
+ if (this.isRemote && this.visibleOptions.length == 0 && this.value.length == 0) {
33
+ this.fetchResults();
34
+ } else {
35
+ this.handleResults();
36
+ }
37
+ }
38
+ select(event) {
39
+ const input = event.currentTarget;
40
+ const label = input.closest("li").dataset.label;
41
+ const changeEvent = new CustomEvent("polaris-autocomplete:change", {
42
+ detail: {
43
+ value: input.value,
44
+ label: label,
45
+ selected: input.checked
46
+ }
47
+ });
48
+ this.element.dispatchEvent(changeEvent);
49
+ }
50
+ onInputChange=debounce$1((() => {
51
+ if (this.isRemote) {
52
+ this.fetchResults();
53
+ } else {
54
+ this.filterOptions();
55
+ }
56
+ }), 200);
57
+ reset() {
58
+ this.inputTarget.value = "";
59
+ this.optionTargets.forEach((option => {
60
+ option.classList.add("Polaris--hidden");
61
+ }));
62
+ this.handleResults();
63
+ }
64
+ get isRemote() {
65
+ return this.urlValue.length > 0;
66
+ }
67
+ get popoverController() {
68
+ return this.application.getControllerForElementAndIdentifier(this.popoverTarget, "polaris-popover");
69
+ }
70
+ get value() {
71
+ return this.inputTarget.value;
72
+ }
73
+ get visibleOptions() {
74
+ return this.optionTargets.filter((option => !option.classList.contains("Polaris--hidden")));
75
+ }
76
+ handleResults() {
77
+ if (this.visibleOptions.length > 0) {
78
+ this.hideEmptyState();
79
+ this.popoverController.show();
80
+ this.checkSelected();
81
+ } else if (this.value.length > 0 && this.hasEmptyStateTarget) {
82
+ this.showEmptyState();
83
+ } else {
84
+ this.popoverController.forceHide();
85
+ }
86
+ }
87
+ filterOptions() {
88
+ if (this.value === "") {
89
+ this.optionTargets.forEach((option => {
90
+ option.classList.remove("Polaris--hidden");
91
+ }));
92
+ } else {
93
+ const filterRegex = new RegExp(this.value, "i");
94
+ this.optionTargets.forEach((option => {
95
+ if (option.dataset.label.match(filterRegex)) {
96
+ option.classList.remove("Polaris--hidden");
97
+ } else {
98
+ option.classList.add("Polaris--hidden");
99
+ }
100
+ }));
101
+ }
102
+ this.handleResults();
103
+ }
104
+ async fetchResults() {
105
+ const response = await get(this.urlValue, {
106
+ query: {
107
+ q: this.value
108
+ }
109
+ });
110
+ if (response.ok) {
111
+ const results = await response.html;
112
+ this.resultsTarget.innerHTML = results;
113
+ this.handleResults();
114
+ }
115
+ }
116
+ showEmptyState() {
117
+ if (this.hasEmptyStateTarget) {
118
+ this.resultsTarget.classList.add("Polaris--hidden");
119
+ this.emptyStateTarget.classList.remove("Polaris--hidden");
120
+ }
121
+ }
122
+ hideEmptyState() {
123
+ if (this.hasEmptyStateTarget) {
124
+ this.emptyStateTarget.classList.add("Polaris--hidden");
125
+ this.resultsTarget.classList.remove("Polaris--hidden");
126
+ }
127
+ }
128
+ checkSelected() {
129
+ this.visibleOptions.forEach((option => {
130
+ const input = option.querySelector("input");
131
+ if (!input) return;
132
+ input.checked = this.selectedValue.includes(input.value);
133
+ }));
134
+ }
135
+ }
136
+
137
+ class Button extends Controller {
138
+ disable(event) {
139
+ if (this.button.disabled) {
140
+ event.preventDefault();
141
+ } else {
142
+ this.button.disabled = true;
143
+ this.button.classList.add("Polaris-Button--disabled", "Polaris-Button--loading");
144
+ this.buttonContent.insertAdjacentHTML("afterbegin", this.spinnerHTML);
145
+ }
146
+ }
147
+ enable() {
148
+ if (this.button.disabled) {
149
+ this.button.disabled = false;
150
+ this.button.classList.remove("Polaris-Button--disabled", "Polaris-Button--loading");
151
+ if (this.spinner) this.spinner.remove();
152
+ }
153
+ }
154
+ get button() {
155
+ return this.element;
156
+ }
157
+ get buttonContent() {
158
+ return this.button.querySelector(".Polaris-Button__Content");
159
+ }
160
+ get spinner() {
161
+ return this.button.querySelector(".Polaris-Button__Spinner");
162
+ }
163
+ get spinnerHTML() {
164
+ return `\n <span class="Polaris-Button__Spinner">\n <span class="Polaris-Spinner Polaris-Spinner--sizeSmall">\n <svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">\n <path d="M7.229 1.173a9.25 9.25 0 1011.655 11.412 1.25 1.25 0 10-2.4-.698 6.75 6.75 0 11-8.506-8.329 1.25 1.25 0 10-.75-2.385z"></path>\n </svg>\n </span>\n </span>\n `;
165
+ }
166
+ }
167
+
168
+ const dragEvents = [ "dragover", "dragenter", "drop" ];
169
+
170
+ const SIZES = {
171
+ SMALL: "small",
172
+ MEDIUM: "medium",
173
+ LARGE: "large",
174
+ EXTRA_LARGE: "extraLarge"
175
+ };
176
+
177
+ class Dropzone extends Controller {
178
+ static targets=[ "container", "fileUpload", "loader", "input", "preview", "previewTemplate", "itemTemplate", "overlay", "errorOverlay" ];
179
+ static classes=[ "disabled" ];
180
+ static values={
181
+ accept: String,
182
+ allowMultiple: Boolean,
183
+ disabled: Boolean,
184
+ dropOnPage: Boolean,
185
+ focused: Boolean,
186
+ renderPreview: Boolean,
187
+ size: String
188
+ };
189
+ files=[];
190
+ acceptedFiles=[];
191
+ rejectedFiles=[];
192
+ _dragging=false;
193
+ dragTargets=[];
194
+ previewRendered=false;
195
+ _size="large";
196
+ connect() {
197
+ document.body.addEventListener("click", this.onExternalTriggerClick);
198
+ addEventListener("resize", this.onWindowResize);
199
+ addEventListener("direct-uploads:start", this.onDirectUploadsStart);
200
+ addEventListener("direct-uploads:end", this.onDirectUploadsEnd);
201
+ addEventListener("direct-upload:initialize", this.onDirectUploadInitialize);
202
+ addEventListener("direct-upload:start", this.onDirectUploadStart);
203
+ addEventListener("direct-upload:progress", this.onDirectUploadProgress);
204
+ addEventListener("direct-upload:error", this.onDirectUploadError);
205
+ addEventListener("direct-upload:end", this.onDirectUploadEnd);
206
+ this.onWindowResize();
207
+ }
208
+ disconnect() {
209
+ document.body.removeEventListener("click", this.onExternalTriggerClick);
210
+ removeEventListener("resize", this.onWindowResize);
211
+ removeEventListener("direct-uploads:start", this.onDirectUploadsStart);
212
+ removeEventListener("direct-uploads:end", this.onDirectUploadsEnd);
213
+ removeEventListener("direct-upload:initialize", this.onDirectUploadInitialize);
214
+ removeEventListener("direct-upload:start", this.onDirectUploadStart);
215
+ removeEventListener("direct-upload:progress", this.onDirectUploadProgress);
216
+ removeEventListener("direct-upload:error", this.onDirectUploadError);
217
+ removeEventListener("direct-upload:end", this.onDirectUploadEnd);
218
+ }
219
+ onExternalTriggerClick=event => {
220
+ const trigger = event.target.closest(`[data-${this.identifier}-external-target="trigger"]`);
221
+ if (!trigger) return;
222
+ event.preventDefault();
223
+ this.onClick();
224
+ };
225
+ onWindowResize=debounce$1((() => {
226
+ const size = this.calculateSize();
227
+ if (size !== this.size) {
228
+ this.size = size;
229
+ }
230
+ }), 50);
231
+ onBlur() {
232
+ this.focusedValue = false;
233
+ }
234
+ onChange(e) {
235
+ this.stopEvent(e);
236
+ if (this.disabled) return;
237
+ this.clearFiles();
238
+ const fileList = getDataTransferFiles(e);
239
+ const {files: files, acceptedFiles: acceptedFiles, rejectedFiles: rejectedFiles} = this.getValidatedFiles(fileList);
240
+ this.dragTargets = [];
241
+ this.files = files;
242
+ this.acceptedFiles = acceptedFiles;
243
+ this.rejectedFiles = rejectedFiles;
244
+ this.render();
245
+ }
246
+ onDragOver(e) {
247
+ this.stopEvent(e);
248
+ if (this.disabled) return;
249
+ }
250
+ onDragEnter(e) {
251
+ this.stopEvent(e);
252
+ if (this.disabled) return;
253
+ if (e.target && !this.dragTargets.includes(e.target)) {
254
+ this.dragTargets.push(e.target);
255
+ }
256
+ if (this.dragging) return;
257
+ this.dragging = true;
258
+ }
259
+ onDragLeave(e) {
260
+ this.stopEvent(e);
261
+ if (this.disabled) return;
262
+ this.dragTargets = this.dragTargets.filter((el => {
263
+ const compareNode = this.element;
264
+ return el !== e.target && compareNode && compareNode.contains(el);
265
+ }));
266
+ if (this.dragTargets.length > 0) return;
267
+ this.dragging = false;
268
+ }
269
+ onDrop(e) {
270
+ this.stopEvent(e);
271
+ if (this.disabled) return;
272
+ this.dragging = false;
273
+ this.onChange(e);
274
+ }
275
+ onFocus() {
276
+ this.focusedValue = true;
277
+ }
278
+ onClick() {
279
+ if (this.disabledValue) return;
280
+ this.open();
281
+ }
282
+ onDirectUploadsStart=() => {
283
+ this.disable();
284
+ };
285
+ onDirectUploadsEnd=() => {
286
+ this.enable();
287
+ this.clearFiles();
288
+ this.loaderTarget.classList.remove("Polaris--hidden");
289
+ };
290
+ onDirectUploadInitialize=event => {
291
+ const {target: target, detail: detail} = event;
292
+ const {id: id, file: file} = detail;
293
+ const dropzone = target.closest(".Polaris-DropZone");
294
+ if (!dropzone) return;
295
+ const content = dropzone.querySelector(`[data-file-name="${file.name}"]`);
296
+ const progressBar = content.parentElement.querySelector('[data-target="progress-bar"]');
297
+ progressBar.id = `direct-upload-${id}`;
298
+ };
299
+ onDirectUploadStart=event => {
300
+ const {id: id} = event.detail;
301
+ const progressBar = document.getElementById(`direct-upload-${id}`);
302
+ if (!progressBar) return;
303
+ progressBar.classList.remove("Polaris--hidden");
304
+ };
305
+ onDirectUploadProgress=event => {
306
+ const {id: id, progress: progress} = event.detail;
307
+ const progressBar = document.getElementById(`direct-upload-${id}`);
308
+ if (!progressBar) return;
309
+ const progressElement = progressBar.querySelector(".Polaris-ProgressBar__Indicator");
310
+ progressElement.style.width = `${progress}%`;
311
+ };
312
+ onDirectUploadError=event => {
313
+ const {id: id, error: error} = event.detail;
314
+ const progressBar = document.getElementById(`direct-upload-${id}`);
315
+ if (!progressBar) return;
316
+ event.preventDefault();
317
+ progressBar.classList.add("Polaris--hidden");
318
+ const uploadError = progressBar.parentElement.querySelector('[data-target="upload-error"]');
319
+ const errorIcon = uploadError.querySelector(".Polaris-InlineError__Icon");
320
+ if (errorIcon) errorIcon.remove();
321
+ uploadError.classList.remove("Polaris--hidden");
322
+ };
323
+ onDirectUploadEnd=event => {
324
+ const {id: id} = event.detail;
325
+ const progressBar = document.getElementById(`direct-upload-${id}`);
326
+ if (!progressBar) return;
327
+ progressBar.classList.add("Polaris-ProgressBar--colorSuccess");
328
+ };
329
+ open() {
330
+ this.inputTarget.click();
331
+ }
332
+ focusedValueChanged() {
333
+ this.element.classList.toggle("Polaris-DropZone--focused", this.focusedValue);
334
+ }
335
+ stopEvent(e) {
336
+ e.preventDefault();
337
+ e.stopPropagation();
338
+ }
339
+ getValidatedFiles(files) {
340
+ const acceptedFiles = [];
341
+ const rejectedFiles = [];
342
+ Array.from(files).forEach((file => {
343
+ if (fileAccepted(file, this.acceptValue)) {
344
+ acceptedFiles.push(file);
345
+ } else {
346
+ rejectedFiles.push(file);
347
+ }
348
+ }));
349
+ if (!this.allowMultipleValue) {
350
+ acceptedFiles.splice(1, acceptedFiles.length);
351
+ rejectedFiles.push(...acceptedFiles.slice(1));
352
+ }
353
+ return {
354
+ files: files,
355
+ acceptedFiles: acceptedFiles,
356
+ rejectedFiles: rejectedFiles
357
+ };
358
+ }
359
+ render() {
360
+ if (this.files.length === 0) {
361
+ this.toggleFileUpload(true);
362
+ this.toggleErrorOverlay(false);
363
+ } else if (this.rejectedFiles.length > 0) {
364
+ this.toggleFileUpload(false);
365
+ this.toggleErrorOverlay(true);
366
+ const dropRejectedEvent = new CustomEvent("polaris-dropzone:drop-rejected", {
367
+ detail: {
368
+ rejectedFiles: this.rejectedFiles
369
+ }
370
+ });
371
+ this.element.dispatchEvent(dropRejectedEvent);
372
+ } else if (this.acceptedFiles.length > 0) {
373
+ if (this.renderPreviewValue) {
374
+ this.renderUploadedFiles();
375
+ this.toggleFileUpload(false);
376
+ }
377
+ this.toggleErrorOverlay(false);
378
+ const dropAcceptedEvent = new CustomEvent("polaris-dropzone:drop-accepted", {
379
+ detail: {
380
+ acceptedFiles: this.acceptedFiles
381
+ }
382
+ });
383
+ this.element.dispatchEvent(dropAcceptedEvent);
384
+ }
385
+ const dropEvent = new CustomEvent("polaris-dropzone:drop", {
386
+ detail: {
387
+ files: this.files,
388
+ acceptedFiles: this.acceptedFiles,
389
+ rejectedFiles: this.rejectedFiles
390
+ }
391
+ });
392
+ this.element.dispatchEvent(dropEvent);
393
+ }
394
+ renderUploadedFiles() {
395
+ if (this.acceptedFiles.length === 0) return;
396
+ const clone = this.previewTemplateTarget.content.cloneNode(true);
397
+ const filesTarget = clone.querySelector(".target");
398
+ let files = this.acceptedFiles;
399
+ if (this.sizeValue == "small") files = [ files[0] ];
400
+ files.map((file => this.renderFile(file))).forEach((fragment => filesTarget.parentNode.appendChild(fragment)));
401
+ filesTarget.remove();
402
+ this.containerTarget.prepend(clone);
403
+ this.previewRendered = true;
404
+ }
405
+ toggleFileUpload(show = false) {
406
+ this.fileUploadTarget.classList.toggle("Polaris-VisuallyHidden", !show);
407
+ }
408
+ toggleErrorOverlay(show = false) {
409
+ this.errorOverlayTarget.classList.toggle("Polaris-VisuallyHidden", !show);
410
+ this.element.classList.toggle("Polaris-DropZone--hasError", show);
411
+ }
412
+ renderFile(file) {
413
+ const validImageTypes = [ "image/gif", "image/jpeg", "image/png" ];
414
+ const clone = this.itemTemplateTarget.content.cloneNode(true);
415
+ const [icon, thumbnail, content, fileSize] = [ clone.querySelector('[data-target="icon"]'), clone.querySelector('[data-target="thumbnail"]'), clone.querySelector('[data-target="content"]'), clone.querySelector('[data-target="file-size"]') ];
416
+ if (validImageTypes.includes(file.type)) {
417
+ const img = thumbnail.querySelector("img");
418
+ img.alt = file.name;
419
+ img.src = window.URL.createObjectURL(file);
420
+ icon.remove();
421
+ } else {
422
+ thumbnail.remove();
423
+ }
424
+ if (this.sizeValue != "small") {
425
+ content.insertAdjacentText("afterbegin", file.name);
426
+ content.setAttribute("data-file-name", file.name);
427
+ fileSize.textContent = formatBytes(file.size);
428
+ }
429
+ return clone;
430
+ }
431
+ clearFiles() {
432
+ if (!this.previewRendered) return;
433
+ this.acceptedFiles = [];
434
+ this.files = [];
435
+ this.rejectedFiles = [];
436
+ if (!this.hasPreviewTarget) return;
437
+ this.previewTarget.remove();
438
+ this.previewRendered = false;
439
+ }
440
+ calculateSize() {
441
+ const width = this.element.getBoundingClientRect().width;
442
+ let size = SIZES.LARGE;
443
+ if (width < 100) {
444
+ size = SIZES.SMALL;
445
+ } else if (width < 160) {
446
+ size = SIZES.MEDIUM;
447
+ } else if (width > 300) {
448
+ size = SIZES.EXTRA_LARGE;
449
+ }
450
+ this.size = size;
451
+ return size;
452
+ }
453
+ getSizeClass(size = "large") {
454
+ return this.sizeClassesSchema[size] || this.sizeClassesSchema.large;
455
+ }
456
+ disable() {
457
+ this.disabled = true;
458
+ this.element.classList.add(this.disabledClass);
459
+ this.inputTarget.disabled = true;
460
+ }
461
+ enable() {
462
+ this.disabled = false;
463
+ this.element.classList.remove(this.disabledClass);
464
+ this.inputTarget.disabled = false;
465
+ }
466
+ get fileListRendered() {
467
+ return this.element.querySelector("[data-rendered]");
468
+ }
469
+ get dropNode() {
470
+ return this.dropOnPageValue ? document : this.element;
471
+ }
472
+ get disabled() {
473
+ return this.disabledValue;
474
+ }
475
+ set disabled(val) {
476
+ this.disabledValue = val;
477
+ }
478
+ get dragging() {
479
+ return this._dragging;
480
+ }
481
+ set dragging(val) {
482
+ this._dragging = val;
483
+ this.element.classList.toggle("Polaris-DropZone--isDragging", val);
484
+ this.overlayTarget.classList.toggle("Polaris-VisuallyHidden", !val);
485
+ }
486
+ get sizeClassesSchema() {
487
+ return {
488
+ [SIZES.SMALL]: "Polaris-DropZone--sizeSmall",
489
+ [SIZES.MEDIUM]: "Polaris-DropZone--sizeMedium",
490
+ [SIZES.LARGE]: "Polaris-DropZone--sizeLarge",
491
+ [SIZES.EXTRA_LARGE]: "Polaris-DropZone--sizeExtraLarge"
492
+ };
493
+ }
494
+ get size() {
495
+ return this._size;
496
+ }
497
+ set size(val) {
498
+ this._size = val;
499
+ const sizeClassesToRemove = Object.values(this.sizeClassesSchema);
500
+ sizeClassesToRemove.forEach((className => this.element.classList.remove(className)));
501
+ this.element.classList.add(this.getSizeClass(val));
502
+ }
503
+ }
504
+
505
+ function fileAccepted(file, accept) {
506
+ return file.type === "application/x-moz-file" || accepts(file, accept);
507
+ }
508
+
509
+ function getDataTransferFiles(event) {
510
+ if (isDragEvent(event) && event.dataTransfer) {
511
+ const dt = event.dataTransfer;
512
+ if (dt.files && dt.files.length) {
513
+ return Array.from(dt.files);
514
+ } else if (dt.items && dt.items.length) {
515
+ return Array.from(dt.items);
516
+ }
517
+ } else if (isChangeEvent(event) && event.target.files) {
518
+ return Array.from(event.target.files);
519
+ }
520
+ return [];
521
+ }
522
+
523
+ function accepts(file, acceptedFiles = [ "" ]) {
524
+ if (file && acceptedFiles) {
525
+ const fileName = file.name || "";
526
+ const mimeType = file.type || "";
527
+ const baseMimeType = mimeType.replace(/\/.*$/, "");
528
+ const acceptedFilesArray = Array.isArray(acceptedFiles) ? acceptedFiles : acceptedFiles.split(",");
529
+ return acceptedFilesArray.some((type => {
530
+ const validType = type.trim();
531
+ if (validType.startsWith(".")) {
532
+ return fileName.toLowerCase().endsWith(validType.toLowerCase());
533
+ } else if (validType.endsWith("/*")) {
534
+ return baseMimeType === validType.replace(/\/.*$/, "");
535
+ }
536
+ return mimeType === validType;
537
+ }));
538
+ }
539
+ return true;
540
+ }
541
+
542
+ function isDragEvent(event) {
543
+ return dragEvents.indexOf(event.type) > 0;
544
+ }
545
+
546
+ function isChangeEvent(event) {
547
+ return event.type === "change";
548
+ }
549
+
550
+ const alpineNames = {
551
+ enterFromClass: "enter",
552
+ enterActiveClass: "enterStart",
553
+ enterToClass: "enterEnd",
554
+ leaveFromClass: "leave",
555
+ leaveActiveClass: "leaveStart",
556
+ leaveToClass: "leaveEnd"
557
+ };
558
+
559
+ const defaultOptions = {
560
+ transitioned: false,
561
+ hiddenClass: "hidden",
562
+ preserveOriginalClass: true,
563
+ removeToClasses: true
564
+ };
565
+
566
+ const useTransition = (controller, options = {}) => {
567
+ var _a, _b, _c;
568
+ const targetName = controller.element.dataset.transitionTarget;
569
+ let targetFromAttribute;
570
+ if (targetName) {
571
+ targetFromAttribute = controller[`${targetName}Target`];
572
+ }
573
+ const targetElement = (options === null || options === void 0 ? void 0 : options.element) || targetFromAttribute || controller.element;
574
+ if (!(targetElement instanceof HTMLElement || targetElement instanceof SVGElement)) return;
575
+ const dataset = targetElement.dataset;
576
+ const leaveAfter = parseInt(dataset.leaveAfter || "") || options.leaveAfter || 0;
577
+ const {transitioned: transitioned, hiddenClass: hiddenClass, preserveOriginalClass: preserveOriginalClass, removeToClasses: removeToClasses} = Object.assign(defaultOptions, options);
578
+ const controllerEnter = (_a = controller.enter) === null || _a === void 0 ? void 0 : _a.bind(controller);
579
+ const controllerLeave = (_b = controller.leave) === null || _b === void 0 ? void 0 : _b.bind(controller);
580
+ const controllerToggleTransition = (_c = controller.toggleTransition) === null || _c === void 0 ? void 0 : _c.bind(controller);
581
+ async function enter(event) {
582
+ if (controller.transitioned) return;
583
+ controller.transitioned = true;
584
+ controllerEnter && controllerEnter(event);
585
+ const enterFromClasses = getAttribute("enterFrom", options, dataset);
586
+ const enterActiveClasses = getAttribute("enterActive", options, dataset);
587
+ const enterToClasses = getAttribute("enterTo", options, dataset);
588
+ const leaveToClasses = getAttribute("leaveTo", options, dataset);
589
+ if (!!hiddenClass) {
590
+ targetElement.classList.remove(hiddenClass);
591
+ }
592
+ if (!removeToClasses) {
593
+ removeClasses(targetElement, leaveToClasses);
594
+ }
595
+ await transition(targetElement, enterFromClasses, enterActiveClasses, enterToClasses, hiddenClass, preserveOriginalClass, removeToClasses);
596
+ if (leaveAfter > 0) {
597
+ setTimeout((() => {
598
+ leave(event);
599
+ }), leaveAfter);
600
+ }
601
+ }
602
+ async function leave(event) {
603
+ if (!controller.transitioned) return;
604
+ controller.transitioned = false;
605
+ controllerLeave && controllerLeave(event);
606
+ const leaveFromClasses = getAttribute("leaveFrom", options, dataset);
607
+ const leaveActiveClasses = getAttribute("leaveActive", options, dataset);
608
+ const leaveToClasses = getAttribute("leaveTo", options, dataset);
609
+ const enterToClasses = getAttribute("enterTo", options, dataset);
610
+ if (!removeToClasses) {
611
+ removeClasses(targetElement, enterToClasses);
612
+ }
613
+ await transition(targetElement, leaveFromClasses, leaveActiveClasses, leaveToClasses, hiddenClass, preserveOriginalClass, removeToClasses);
614
+ if (!!hiddenClass) {
615
+ targetElement.classList.add(hiddenClass);
616
+ }
617
+ }
618
+ function toggleTransition(event) {
619
+ controllerToggleTransition && controllerToggleTransition(event);
620
+ if (controller.transitioned) {
621
+ leave();
622
+ } else {
623
+ enter();
624
+ }
625
+ }
626
+ async function transition(element, initialClasses, activeClasses, endClasses, hiddenClass, preserveOriginalClass, removeEndClasses) {
627
+ const stashedClasses = [];
628
+ if (preserveOriginalClass) {
629
+ initialClasses.forEach((cls => element.classList.contains(cls) && cls !== hiddenClass && stashedClasses.push(cls)));
630
+ activeClasses.forEach((cls => element.classList.contains(cls) && cls !== hiddenClass && stashedClasses.push(cls)));
631
+ endClasses.forEach((cls => element.classList.contains(cls) && cls !== hiddenClass && stashedClasses.push(cls)));
632
+ }
633
+ addClasses(element, initialClasses);
634
+ removeClasses(element, stashedClasses);
635
+ addClasses(element, activeClasses);
636
+ await nextAnimationFrame();
637
+ removeClasses(element, initialClasses);
638
+ addClasses(element, endClasses);
639
+ await afterTransition(element);
640
+ removeClasses(element, activeClasses);
641
+ if (removeEndClasses) {
642
+ removeClasses(element, endClasses);
643
+ }
644
+ addClasses(element, stashedClasses);
645
+ }
646
+ function initialState() {
647
+ controller.transitioned = transitioned;
648
+ if (transitioned) {
649
+ if (!!hiddenClass) {
650
+ targetElement.classList.remove(hiddenClass);
651
+ }
652
+ enter();
653
+ } else {
654
+ if (!!hiddenClass) {
655
+ targetElement.classList.add(hiddenClass);
656
+ }
657
+ leave();
658
+ }
659
+ }
660
+ function addClasses(element, classes) {
661
+ if (classes.length > 0) {
662
+ element.classList.add(...classes);
663
+ }
664
+ }
665
+ function removeClasses(element, classes) {
666
+ if (classes.length > 0) {
667
+ element.classList.remove(...classes);
668
+ }
669
+ }
670
+ initialState();
671
+ Object.assign(controller, {
672
+ enter: enter,
673
+ leave: leave,
674
+ toggleTransition: toggleTransition
675
+ });
676
+ return [ enter, leave, toggleTransition ];
677
+ };
678
+
679
+ function getAttribute(name, options, dataset) {
680
+ const datasetName = `transition${name[0].toUpperCase()}${name.substr(1)}`;
681
+ const datasetAlpineName = alpineNames[name];
682
+ const classes = options[name] || dataset[datasetName] || dataset[datasetAlpineName] || " ";
683
+ return isEmpty(classes) ? [] : classes.split(" ");
684
+ }
685
+
686
+ async function afterTransition(element) {
687
+ return new Promise((resolve => {
688
+ const duration = Number(getComputedStyle(element).transitionDuration.split(",")[0].replace("s", "")) * 1e3;
689
+ setTimeout((() => {
690
+ resolve(duration);
691
+ }), duration);
692
+ }));
693
+ }
694
+
695
+ async function nextAnimationFrame() {
696
+ return new Promise((resolve => {
697
+ requestAnimationFrame((() => {
698
+ requestAnimationFrame(resolve);
699
+ }));
700
+ }));
701
+ }
702
+
703
+ function isEmpty(str) {
704
+ return str.length === 0 || !str.trim();
705
+ }
706
+
707
+ class Frame extends Controller {
708
+ static targets=[ "navigationOverlay", "navigation", "saveBar" ];
709
+ connect() {
710
+ if (!this.hasNavigationTarget) {
711
+ return;
712
+ }
713
+ useTransition(this, {
714
+ element: this.navigationTarget,
715
+ enterFrom: "Polaris-Frame__Navigation--enter",
716
+ enterTo: "Polaris-Frame__Navigation--visible Polaris-Frame__Navigation--enterActive",
717
+ leaveActive: "Polaris-Frame__Navigation--exitActive",
718
+ leaveFrom: "Polaris-Frame__Navigation--exit",
719
+ leaveTo: "",
720
+ removeToClasses: false,
721
+ hiddenClass: false
722
+ });
723
+ }
724
+ openMenu() {
725
+ this.enter();
726
+ this.navigationOverlayTarget.classList.add("Polaris-Backdrop", "Polaris-Backdrop--belowNavigation");
727
+ }
728
+ closeMenu() {
729
+ this.leave();
730
+ this.navigationOverlayTarget.classList.remove("Polaris-Backdrop", "Polaris-Backdrop--belowNavigation");
731
+ }
732
+ showSaveBar() {
733
+ this.saveBarTarget.classList.add("Polaris-Frame-CSSAnimation--endFade");
734
+ }
735
+ hideSaveBar() {
736
+ this.saveBarTarget.classList.remove("Polaris-Frame-CSSAnimation--endFade");
737
+ }
738
+ }
739
+
740
+ class Modal extends Controller {
741
+ static classes=[ "hidden", "backdrop" ];
742
+ static values={
743
+ open: Boolean
744
+ };
745
+ connect() {
746
+ if (this.openValue) {
747
+ this.open();
748
+ }
749
+ }
750
+ open() {
751
+ this.element.classList.remove(this.hiddenClass);
752
+ this.element.insertAdjacentHTML("afterend", `<div class="${this.backdropClass}"></div>`);
753
+ this.backdrop = this.element.nextElementSibling;
754
+ }
755
+ close() {
756
+ this.element.classList.add(this.hiddenClass);
757
+ this.backdrop.remove();
758
+ }
759
+ }
760
+
761
+ class OptionList extends Controller {
762
+ static targets=[ "radioButton" ];
763
+ static classes=[ "selected" ];
764
+ connect() {
765
+ this.updateSelected();
766
+ }
767
+ update(event) {
768
+ const target = event.currentTarget;
769
+ target.classList.add(this.selectedClass);
770
+ this.deselectAll(target);
771
+ }
772
+ updateSelected() {
773
+ this.radioButtonTargets.forEach((element => {
774
+ const input = element.querySelector("input[type=radio]");
775
+ if (input.checked) {
776
+ element.classList.add(this.selectedClass);
777
+ } else {
778
+ element.classList.remove(this.selectedClass);
779
+ }
780
+ }));
781
+ }
782
+ deselectAll(target) {
783
+ this.radioButtonTargets.forEach((element => {
784
+ if (!element.isEqualNode(target)) {
785
+ const input = element.querySelector("input[type=radio]");
786
+ input.checked = false;
787
+ element.classList.remove(this.selectedClass);
788
+ }
789
+ }));
790
+ }
791
+ }
792
+
793
+ class Polaris extends Controller {
794
+ openModal() {
795
+ this.findElement("modal").open();
796
+ }
797
+ disableButton() {
798
+ this.findElement("button").disable();
799
+ }
800
+ enableButton() {
801
+ this.findElement("button").enable();
802
+ }
803
+ showToast() {
804
+ this.findElement("toast").show();
805
+ }
806
+ findElement(type) {
807
+ const targetId = this.element.dataset.target.replace("#", "");
808
+ const target = document.getElementById(targetId);
809
+ const controllerName = `polaris-${type}`;
810
+ return this.application.getControllerForElementAndIdentifier(target, controllerName);
811
+ }
812
+ }
813
+
814
+ var top = "top";
815
+
816
+ var bottom = "bottom";
817
+
818
+ var right = "right";
819
+
820
+ var left = "left";
821
+
822
+ var auto = "auto";
823
+
824
+ var basePlacements = [ top, bottom, right, left ];
825
+
826
+ var start = "start";
827
+
828
+ var end = "end";
829
+
830
+ var clippingParents = "clippingParents";
831
+
832
+ var viewport = "viewport";
833
+
834
+ var popper = "popper";
835
+
836
+ var reference = "reference";
837
+
838
+ var variationPlacements = basePlacements.reduce((function(acc, placement) {
839
+ return acc.concat([ placement + "-" + start, placement + "-" + end ]);
840
+ }), []);
841
+
842
+ var placements = [].concat(basePlacements, [ auto ]).reduce((function(acc, placement) {
843
+ return acc.concat([ placement, placement + "-" + start, placement + "-" + end ]);
844
+ }), []);
845
+
846
+ var beforeRead = "beforeRead";
847
+
848
+ var read = "read";
849
+
850
+ var afterRead = "afterRead";
851
+
852
+ var beforeMain = "beforeMain";
853
+
854
+ var main = "main";
855
+
856
+ var afterMain = "afterMain";
857
+
858
+ var beforeWrite = "beforeWrite";
859
+
860
+ var write = "write";
861
+
862
+ var afterWrite = "afterWrite";
863
+
864
+ var modifierPhases = [ beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite ];
865
+
866
+ function getNodeName(element) {
867
+ return element ? (element.nodeName || "").toLowerCase() : null;
868
+ }
869
+
870
+ function getWindow(node) {
871
+ if (node == null) {
872
+ return window;
873
+ }
874
+ if (node.toString() !== "[object Window]") {
875
+ var ownerDocument = node.ownerDocument;
876
+ return ownerDocument ? ownerDocument.defaultView || window : window;
877
+ }
878
+ return node;
879
+ }
880
+
881
+ function isElement(node) {
882
+ var OwnElement = getWindow(node).Element;
883
+ return node instanceof OwnElement || node instanceof Element;
884
+ }
885
+
886
+ function isHTMLElement(node) {
887
+ var OwnElement = getWindow(node).HTMLElement;
888
+ return node instanceof OwnElement || node instanceof HTMLElement;
889
+ }
890
+
891
+ function isShadowRoot(node) {
892
+ if (typeof ShadowRoot === "undefined") {
893
+ return false;
894
+ }
895
+ var OwnElement = getWindow(node).ShadowRoot;
896
+ return node instanceof OwnElement || node instanceof ShadowRoot;
897
+ }
898
+
899
+ function applyStyles(_ref) {
900
+ var state = _ref.state;
901
+ Object.keys(state.elements).forEach((function(name) {
902
+ var style = state.styles[name] || {};
903
+ var attributes = state.attributes[name] || {};
904
+ var element = state.elements[name];
905
+ if (!isHTMLElement(element) || !getNodeName(element)) {
906
+ return;
907
+ }
908
+ Object.assign(element.style, style);
909
+ Object.keys(attributes).forEach((function(name) {
910
+ var value = attributes[name];
911
+ if (value === false) {
912
+ element.removeAttribute(name);
913
+ } else {
914
+ element.setAttribute(name, value === true ? "" : value);
915
+ }
916
+ }));
917
+ }));
918
+ }
919
+
920
+ function effect$2(_ref2) {
921
+ var state = _ref2.state;
922
+ var initialStyles = {
923
+ popper: {
924
+ position: state.options.strategy,
925
+ left: "0",
926
+ top: "0",
927
+ margin: "0"
928
+ },
929
+ arrow: {
930
+ position: "absolute"
931
+ },
932
+ reference: {}
933
+ };
934
+ Object.assign(state.elements.popper.style, initialStyles.popper);
935
+ state.styles = initialStyles;
936
+ if (state.elements.arrow) {
937
+ Object.assign(state.elements.arrow.style, initialStyles.arrow);
938
+ }
939
+ return function() {
940
+ Object.keys(state.elements).forEach((function(name) {
941
+ var element = state.elements[name];
942
+ var attributes = state.attributes[name] || {};
943
+ var styleProperties = Object.keys(state.styles.hasOwnProperty(name) ? state.styles[name] : initialStyles[name]);
944
+ var style = styleProperties.reduce((function(style, property) {
945
+ style[property] = "";
946
+ return style;
947
+ }), {});
948
+ if (!isHTMLElement(element) || !getNodeName(element)) {
949
+ return;
950
+ }
951
+ Object.assign(element.style, style);
952
+ Object.keys(attributes).forEach((function(attribute) {
953
+ element.removeAttribute(attribute);
954
+ }));
955
+ }));
956
+ };
957
+ }
958
+
959
+ var applyStyles$1 = {
960
+ name: "applyStyles",
961
+ enabled: true,
962
+ phase: "write",
963
+ fn: applyStyles,
964
+ effect: effect$2,
965
+ requires: [ "computeStyles" ]
966
+ };
967
+
968
+ function getBasePlacement(placement) {
969
+ return placement.split("-")[0];
970
+ }
971
+
972
+ var max = Math.max;
973
+
974
+ var min = Math.min;
975
+
976
+ var round = Math.round;
977
+
978
+ function getBoundingClientRect(element, includeScale) {
979
+ if (includeScale === void 0) {
980
+ includeScale = false;
981
+ }
982
+ var rect = element.getBoundingClientRect();
983
+ var scaleX = 1;
984
+ var scaleY = 1;
985
+ if (isHTMLElement(element) && includeScale) {
986
+ var offsetHeight = element.offsetHeight;
987
+ var offsetWidth = element.offsetWidth;
988
+ if (offsetWidth > 0) {
989
+ scaleX = round(rect.width) / offsetWidth || 1;
990
+ }
991
+ if (offsetHeight > 0) {
992
+ scaleY = round(rect.height) / offsetHeight || 1;
993
+ }
994
+ }
995
+ return {
996
+ width: rect.width / scaleX,
997
+ height: rect.height / scaleY,
998
+ top: rect.top / scaleY,
999
+ right: rect.right / scaleX,
1000
+ bottom: rect.bottom / scaleY,
1001
+ left: rect.left / scaleX,
1002
+ x: rect.left / scaleX,
1003
+ y: rect.top / scaleY
1004
+ };
1005
+ }
1006
+
1007
+ function getLayoutRect(element) {
1008
+ var clientRect = getBoundingClientRect(element);
1009
+ var width = element.offsetWidth;
1010
+ var height = element.offsetHeight;
1011
+ if (Math.abs(clientRect.width - width) <= 1) {
1012
+ width = clientRect.width;
1013
+ }
1014
+ if (Math.abs(clientRect.height - height) <= 1) {
1015
+ height = clientRect.height;
1016
+ }
1017
+ return {
1018
+ x: element.offsetLeft,
1019
+ y: element.offsetTop,
1020
+ width: width,
1021
+ height: height
1022
+ };
1023
+ }
1024
+
1025
+ function contains(parent, child) {
1026
+ var rootNode = child.getRootNode && child.getRootNode();
1027
+ if (parent.contains(child)) {
1028
+ return true;
1029
+ } else if (rootNode && isShadowRoot(rootNode)) {
1030
+ var next = child;
1031
+ do {
1032
+ if (next && parent.isSameNode(next)) {
1033
+ return true;
1034
+ }
1035
+ next = next.parentNode || next.host;
1036
+ } while (next);
1037
+ }
1038
+ return false;
1039
+ }
1040
+
1041
+ function getComputedStyle$1(element) {
1042
+ return getWindow(element).getComputedStyle(element);
1043
+ }
1044
+
1045
+ function isTableElement(element) {
1046
+ return [ "table", "td", "th" ].indexOf(getNodeName(element)) >= 0;
1047
+ }
1048
+
1049
+ function getDocumentElement(element) {
1050
+ return ((isElement(element) ? element.ownerDocument : element.document) || window.document).documentElement;
1051
+ }
1052
+
1053
+ function getParentNode(element) {
1054
+ if (getNodeName(element) === "html") {
1055
+ return element;
1056
+ }
1057
+ return element.assignedSlot || element.parentNode || (isShadowRoot(element) ? element.host : null) || getDocumentElement(element);
1058
+ }
1059
+
1060
+ function getTrueOffsetParent(element) {
1061
+ if (!isHTMLElement(element) || getComputedStyle$1(element).position === "fixed") {
1062
+ return null;
1063
+ }
1064
+ return element.offsetParent;
1065
+ }
1066
+
1067
+ function getContainingBlock(element) {
1068
+ var isFirefox = navigator.userAgent.toLowerCase().indexOf("firefox") !== -1;
1069
+ var isIE = navigator.userAgent.indexOf("Trident") !== -1;
1070
+ if (isIE && isHTMLElement(element)) {
1071
+ var elementCss = getComputedStyle$1(element);
1072
+ if (elementCss.position === "fixed") {
1073
+ return null;
1074
+ }
1075
+ }
1076
+ var currentNode = getParentNode(element);
1077
+ while (isHTMLElement(currentNode) && [ "html", "body" ].indexOf(getNodeName(currentNode)) < 0) {
1078
+ var css = getComputedStyle$1(currentNode);
1079
+ if (css.transform !== "none" || css.perspective !== "none" || css.contain === "paint" || [ "transform", "perspective" ].indexOf(css.willChange) !== -1 || isFirefox && css.willChange === "filter" || isFirefox && css.filter && css.filter !== "none") {
1080
+ return currentNode;
1081
+ } else {
1082
+ currentNode = currentNode.parentNode;
1083
+ }
1084
+ }
1085
+ return null;
1086
+ }
1087
+
1088
+ function getOffsetParent(element) {
1089
+ var window = getWindow(element);
1090
+ var offsetParent = getTrueOffsetParent(element);
1091
+ while (offsetParent && isTableElement(offsetParent) && getComputedStyle$1(offsetParent).position === "static") {
1092
+ offsetParent = getTrueOffsetParent(offsetParent);
1093
+ }
1094
+ if (offsetParent && (getNodeName(offsetParent) === "html" || getNodeName(offsetParent) === "body" && getComputedStyle$1(offsetParent).position === "static")) {
1095
+ return window;
1096
+ }
1097
+ return offsetParent || getContainingBlock(element) || window;
1098
+ }
1099
+
1100
+ function getMainAxisFromPlacement(placement) {
1101
+ return [ "top", "bottom" ].indexOf(placement) >= 0 ? "x" : "y";
1102
+ }
1103
+
1104
+ function within(min$1, value, max$1) {
1105
+ return max(min$1, min(value, max$1));
1106
+ }
1107
+
1108
+ function withinMaxClamp(min, value, max) {
1109
+ var v = within(min, value, max);
1110
+ return v > max ? max : v;
1111
+ }
1112
+
1113
+ function getFreshSideObject() {
1114
+ return {
1115
+ top: 0,
1116
+ right: 0,
1117
+ bottom: 0,
1118
+ left: 0
1119
+ };
1120
+ }
1121
+
1122
+ function mergePaddingObject(paddingObject) {
1123
+ return Object.assign({}, getFreshSideObject(), paddingObject);
1124
+ }
1125
+
1126
+ function expandToHashMap(value, keys) {
1127
+ return keys.reduce((function(hashMap, key) {
1128
+ hashMap[key] = value;
1129
+ return hashMap;
1130
+ }), {});
1131
+ }
1132
+
1133
+ var toPaddingObject = function toPaddingObject(padding, state) {
1134
+ padding = typeof padding === "function" ? padding(Object.assign({}, state.rects, {
1135
+ placement: state.placement
1136
+ })) : padding;
1137
+ return mergePaddingObject(typeof padding !== "number" ? padding : expandToHashMap(padding, basePlacements));
1138
+ };
1139
+
1140
+ function arrow(_ref) {
1141
+ var _state$modifiersData$;
1142
+ var state = _ref.state, name = _ref.name, options = _ref.options;
1143
+ var arrowElement = state.elements.arrow;
1144
+ var popperOffsets = state.modifiersData.popperOffsets;
1145
+ var basePlacement = getBasePlacement(state.placement);
1146
+ var axis = getMainAxisFromPlacement(basePlacement);
1147
+ var isVertical = [ left, right ].indexOf(basePlacement) >= 0;
1148
+ var len = isVertical ? "height" : "width";
1149
+ if (!arrowElement || !popperOffsets) {
1150
+ return;
1151
+ }
1152
+ var paddingObject = toPaddingObject(options.padding, state);
1153
+ var arrowRect = getLayoutRect(arrowElement);
1154
+ var minProp = axis === "y" ? top : left;
1155
+ var maxProp = axis === "y" ? bottom : right;
1156
+ var endDiff = state.rects.reference[len] + state.rects.reference[axis] - popperOffsets[axis] - state.rects.popper[len];
1157
+ var startDiff = popperOffsets[axis] - state.rects.reference[axis];
1158
+ var arrowOffsetParent = getOffsetParent(arrowElement);
1159
+ var clientSize = arrowOffsetParent ? axis === "y" ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
1160
+ var centerToReference = endDiff / 2 - startDiff / 2;
1161
+ var min = paddingObject[minProp];
1162
+ var max = clientSize - arrowRect[len] - paddingObject[maxProp];
1163
+ var center = clientSize / 2 - arrowRect[len] / 2 + centerToReference;
1164
+ var offset = within(min, center, max);
1165
+ var axisProp = axis;
1166
+ state.modifiersData[name] = (_state$modifiersData$ = {}, _state$modifiersData$[axisProp] = offset,
1167
+ _state$modifiersData$.centerOffset = offset - center, _state$modifiersData$);
1168
+ }
1169
+
1170
+ function effect$1(_ref2) {
1171
+ var state = _ref2.state, options = _ref2.options;
1172
+ var _options$element = options.element, arrowElement = _options$element === void 0 ? "[data-popper-arrow]" : _options$element;
1173
+ if (arrowElement == null) {
1174
+ return;
1175
+ }
1176
+ if (typeof arrowElement === "string") {
1177
+ arrowElement = state.elements.popper.querySelector(arrowElement);
1178
+ if (!arrowElement) {
1179
+ return;
1180
+ }
1181
+ }
1182
+ if (!contains(state.elements.popper, arrowElement)) {
1183
+ return;
1184
+ }
1185
+ state.elements.arrow = arrowElement;
1186
+ }
1187
+
1188
+ var arrow$1 = {
1189
+ name: "arrow",
1190
+ enabled: true,
1191
+ phase: "main",
1192
+ fn: arrow,
1193
+ effect: effect$1,
1194
+ requires: [ "popperOffsets" ],
1195
+ requiresIfExists: [ "preventOverflow" ]
1196
+ };
1197
+
1198
+ function getVariation(placement) {
1199
+ return placement.split("-")[1];
1200
+ }
1201
+
1202
+ var unsetSides = {
1203
+ top: "auto",
1204
+ right: "auto",
1205
+ bottom: "auto",
1206
+ left: "auto"
1207
+ };
1208
+
1209
+ function roundOffsetsByDPR(_ref) {
1210
+ var x = _ref.x, y = _ref.y;
1211
+ var win = window;
1212
+ var dpr = win.devicePixelRatio || 1;
1213
+ return {
1214
+ x: round(x * dpr) / dpr || 0,
1215
+ y: round(y * dpr) / dpr || 0
1216
+ };
1217
+ }
1218
+
1219
+ function mapToStyles(_ref2) {
1220
+ var _Object$assign2;
1221
+ var popper = _ref2.popper, popperRect = _ref2.popperRect, placement = _ref2.placement, variation = _ref2.variation, offsets = _ref2.offsets, position = _ref2.position, gpuAcceleration = _ref2.gpuAcceleration, adaptive = _ref2.adaptive, roundOffsets = _ref2.roundOffsets, isFixed = _ref2.isFixed;
1222
+ var _offsets$x = offsets.x, x = _offsets$x === void 0 ? 0 : _offsets$x, _offsets$y = offsets.y, y = _offsets$y === void 0 ? 0 : _offsets$y;
1223
+ var _ref3 = typeof roundOffsets === "function" ? roundOffsets({
1224
+ x: x,
1225
+ y: y
1226
+ }) : {
1227
+ x: x,
1228
+ y: y
1229
+ };
1230
+ x = _ref3.x;
1231
+ y = _ref3.y;
1232
+ var hasX = offsets.hasOwnProperty("x");
1233
+ var hasY = offsets.hasOwnProperty("y");
1234
+ var sideX = left;
1235
+ var sideY = top;
1236
+ var win = window;
1237
+ if (adaptive) {
1238
+ var offsetParent = getOffsetParent(popper);
1239
+ var heightProp = "clientHeight";
1240
+ var widthProp = "clientWidth";
1241
+ if (offsetParent === getWindow(popper)) {
1242
+ offsetParent = getDocumentElement(popper);
1243
+ if (getComputedStyle$1(offsetParent).position !== "static" && position === "absolute") {
1244
+ heightProp = "scrollHeight";
1245
+ widthProp = "scrollWidth";
1246
+ }
1247
+ }
1248
+ offsetParent = offsetParent;
1249
+ if (placement === top || (placement === left || placement === right) && variation === end) {
1250
+ sideY = bottom;
1251
+ var offsetY = isFixed && win.visualViewport ? win.visualViewport.height : offsetParent[heightProp];
1252
+ y -= offsetY - popperRect.height;
1253
+ y *= gpuAcceleration ? 1 : -1;
1254
+ }
1255
+ if (placement === left || (placement === top || placement === bottom) && variation === end) {
1256
+ sideX = right;
1257
+ var offsetX = isFixed && win.visualViewport ? win.visualViewport.width : offsetParent[widthProp];
1258
+ x -= offsetX - popperRect.width;
1259
+ x *= gpuAcceleration ? 1 : -1;
1260
+ }
1261
+ }
1262
+ var commonStyles = Object.assign({
1263
+ position: position
1264
+ }, adaptive && unsetSides);
1265
+ var _ref4 = roundOffsets === true ? roundOffsetsByDPR({
1266
+ x: x,
1267
+ y: y
1268
+ }) : {
1269
+ x: x,
1270
+ y: y
1271
+ };
1272
+ x = _ref4.x;
1273
+ y = _ref4.y;
1274
+ if (gpuAcceleration) {
1275
+ var _Object$assign;
1276
+ return Object.assign({}, commonStyles, (_Object$assign = {}, _Object$assign[sideY] = hasY ? "0" : "",
1277
+ _Object$assign[sideX] = hasX ? "0" : "", _Object$assign.transform = (win.devicePixelRatio || 1) <= 1 ? "translate(" + x + "px, " + y + "px)" : "translate3d(" + x + "px, " + y + "px, 0)",
1278
+ _Object$assign));
1279
+ }
1280
+ return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : "",
1281
+ _Object$assign2[sideX] = hasX ? x + "px" : "", _Object$assign2.transform = "", _Object$assign2));
1282
+ }
1283
+
1284
+ function computeStyles(_ref5) {
1285
+ var state = _ref5.state, options = _ref5.options;
1286
+ var _options$gpuAccelerat = options.gpuAcceleration, gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat, _options$adaptive = options.adaptive, adaptive = _options$adaptive === void 0 ? true : _options$adaptive, _options$roundOffsets = options.roundOffsets, roundOffsets = _options$roundOffsets === void 0 ? true : _options$roundOffsets;
1287
+ var commonStyles = {
1288
+ placement: getBasePlacement(state.placement),
1289
+ variation: getVariation(state.placement),
1290
+ popper: state.elements.popper,
1291
+ popperRect: state.rects.popper,
1292
+ gpuAcceleration: gpuAcceleration,
1293
+ isFixed: state.options.strategy === "fixed"
1294
+ };
1295
+ if (state.modifiersData.popperOffsets != null) {
1296
+ state.styles.popper = Object.assign({}, state.styles.popper, mapToStyles(Object.assign({}, commonStyles, {
1297
+ offsets: state.modifiersData.popperOffsets,
1298
+ position: state.options.strategy,
1299
+ adaptive: adaptive,
1300
+ roundOffsets: roundOffsets
1301
+ })));
1302
+ }
1303
+ if (state.modifiersData.arrow != null) {
1304
+ state.styles.arrow = Object.assign({}, state.styles.arrow, mapToStyles(Object.assign({}, commonStyles, {
1305
+ offsets: state.modifiersData.arrow,
1306
+ position: "absolute",
1307
+ adaptive: false,
1308
+ roundOffsets: roundOffsets
1309
+ })));
1310
+ }
1311
+ state.attributes.popper = Object.assign({}, state.attributes.popper, {
1312
+ "data-popper-placement": state.placement
1313
+ });
1314
+ }
1315
+
1316
+ var computeStyles$1 = {
1317
+ name: "computeStyles",
1318
+ enabled: true,
1319
+ phase: "beforeWrite",
1320
+ fn: computeStyles,
1321
+ data: {}
1322
+ };
1323
+
1324
+ var passive = {
1325
+ passive: true
1326
+ };
1327
+
1328
+ function effect(_ref) {
1329
+ var state = _ref.state, instance = _ref.instance, options = _ref.options;
1330
+ var _options$scroll = options.scroll, scroll = _options$scroll === void 0 ? true : _options$scroll, _options$resize = options.resize, resize = _options$resize === void 0 ? true : _options$resize;
1331
+ var window = getWindow(state.elements.popper);
1332
+ var scrollParents = [].concat(state.scrollParents.reference, state.scrollParents.popper);
1333
+ if (scroll) {
1334
+ scrollParents.forEach((function(scrollParent) {
1335
+ scrollParent.addEventListener("scroll", instance.update, passive);
1336
+ }));
1337
+ }
1338
+ if (resize) {
1339
+ window.addEventListener("resize", instance.update, passive);
1340
+ }
1341
+ return function() {
1342
+ if (scroll) {
1343
+ scrollParents.forEach((function(scrollParent) {
1344
+ scrollParent.removeEventListener("scroll", instance.update, passive);
1345
+ }));
1346
+ }
1347
+ if (resize) {
1348
+ window.removeEventListener("resize", instance.update, passive);
1349
+ }
1350
+ };
1351
+ }
1352
+
1353
+ var eventListeners = {
1354
+ name: "eventListeners",
1355
+ enabled: true,
1356
+ phase: "write",
1357
+ fn: function fn() {},
1358
+ effect: effect,
1359
+ data: {}
1360
+ };
1361
+
1362
+ var hash$1 = {
1363
+ left: "right",
1364
+ right: "left",
1365
+ bottom: "top",
1366
+ top: "bottom"
1367
+ };
1368
+
1369
+ function getOppositePlacement(placement) {
1370
+ return placement.replace(/left|right|bottom|top/g, (function(matched) {
1371
+ return hash$1[matched];
1372
+ }));
1373
+ }
1374
+
1375
+ var hash = {
1376
+ start: "end",
1377
+ end: "start"
1378
+ };
1379
+
1380
+ function getOppositeVariationPlacement(placement) {
1381
+ return placement.replace(/start|end/g, (function(matched) {
1382
+ return hash[matched];
1383
+ }));
1384
+ }
1385
+
1386
+ function getWindowScroll(node) {
1387
+ var win = getWindow(node);
1388
+ var scrollLeft = win.pageXOffset;
1389
+ var scrollTop = win.pageYOffset;
1390
+ return {
1391
+ scrollLeft: scrollLeft,
1392
+ scrollTop: scrollTop
1393
+ };
1394
+ }
1395
+
1396
+ function getWindowScrollBarX(element) {
1397
+ return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
1398
+ }
1399
+
1400
+ function getViewportRect(element) {
1401
+ var win = getWindow(element);
1402
+ var html = getDocumentElement(element);
1403
+ var visualViewport = win.visualViewport;
1404
+ var width = html.clientWidth;
1405
+ var height = html.clientHeight;
1406
+ var x = 0;
1407
+ var y = 0;
1408
+ if (visualViewport) {
1409
+ width = visualViewport.width;
1410
+ height = visualViewport.height;
1411
+ if (!/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
1412
+ x = visualViewport.offsetLeft;
1413
+ y = visualViewport.offsetTop;
1414
+ }
1415
+ }
1416
+ return {
1417
+ width: width,
1418
+ height: height,
1419
+ x: x + getWindowScrollBarX(element),
1420
+ y: y
1421
+ };
1422
+ }
1423
+
1424
+ function getDocumentRect(element) {
1425
+ var _element$ownerDocumen;
1426
+ var html = getDocumentElement(element);
1427
+ var winScroll = getWindowScroll(element);
1428
+ var body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
1429
+ var width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
1430
+ var height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
1431
+ var x = -winScroll.scrollLeft + getWindowScrollBarX(element);
1432
+ var y = -winScroll.scrollTop;
1433
+ if (getComputedStyle$1(body || html).direction === "rtl") {
1434
+ x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
1435
+ }
1436
+ return {
1437
+ width: width,
1438
+ height: height,
1439
+ x: x,
1440
+ y: y
1441
+ };
1442
+ }
1443
+
1444
+ function isScrollParent(element) {
1445
+ var _getComputedStyle = getComputedStyle$1(element), overflow = _getComputedStyle.overflow, overflowX = _getComputedStyle.overflowX, overflowY = _getComputedStyle.overflowY;
1446
+ return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
1447
+ }
1448
+
1449
+ function getScrollParent(node) {
1450
+ if ([ "html", "body", "#document" ].indexOf(getNodeName(node)) >= 0) {
1451
+ return node.ownerDocument.body;
1452
+ }
1453
+ if (isHTMLElement(node) && isScrollParent(node)) {
1454
+ return node;
1455
+ }
1456
+ return getScrollParent(getParentNode(node));
1457
+ }
1458
+
1459
+ function listScrollParents(element, list) {
1460
+ var _element$ownerDocumen;
1461
+ if (list === void 0) {
1462
+ list = [];
1463
+ }
1464
+ var scrollParent = getScrollParent(element);
1465
+ var isBody = scrollParent === ((_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body);
1466
+ var win = getWindow(scrollParent);
1467
+ var target = isBody ? [ win ].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
1468
+ var updatedList = list.concat(target);
1469
+ return isBody ? updatedList : updatedList.concat(listScrollParents(getParentNode(target)));
1470
+ }
1471
+
1472
+ function rectToClientRect(rect) {
1473
+ return Object.assign({}, rect, {
1474
+ left: rect.x,
1475
+ top: rect.y,
1476
+ right: rect.x + rect.width,
1477
+ bottom: rect.y + rect.height
1478
+ });
1479
+ }
1480
+
1481
+ function getInnerBoundingClientRect(element) {
1482
+ var rect = getBoundingClientRect(element);
1483
+ rect.top = rect.top + element.clientTop;
1484
+ rect.left = rect.left + element.clientLeft;
1485
+ rect.bottom = rect.top + element.clientHeight;
1486
+ rect.right = rect.left + element.clientWidth;
1487
+ rect.width = element.clientWidth;
1488
+ rect.height = element.clientHeight;
1489
+ rect.x = rect.left;
1490
+ rect.y = rect.top;
1491
+ return rect;
1492
+ }
1493
+
1494
+ function getClientRectFromMixedType(element, clippingParent) {
1495
+ return clippingParent === viewport ? rectToClientRect(getViewportRect(element)) : isElement(clippingParent) ? getInnerBoundingClientRect(clippingParent) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
1496
+ }
1497
+
1498
+ function getClippingParents(element) {
1499
+ var clippingParents = listScrollParents(getParentNode(element));
1500
+ var canEscapeClipping = [ "absolute", "fixed" ].indexOf(getComputedStyle$1(element).position) >= 0;
1501
+ var clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
1502
+ if (!isElement(clipperElement)) {
1503
+ return [];
1504
+ }
1505
+ return clippingParents.filter((function(clippingParent) {
1506
+ return isElement(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== "body";
1507
+ }));
1508
+ }
1509
+
1510
+ function getClippingRect(element, boundary, rootBoundary) {
1511
+ var mainClippingParents = boundary === "clippingParents" ? getClippingParents(element) : [].concat(boundary);
1512
+ var clippingParents = [].concat(mainClippingParents, [ rootBoundary ]);
1513
+ var firstClippingParent = clippingParents[0];
1514
+ var clippingRect = clippingParents.reduce((function(accRect, clippingParent) {
1515
+ var rect = getClientRectFromMixedType(element, clippingParent);
1516
+ accRect.top = max(rect.top, accRect.top);
1517
+ accRect.right = min(rect.right, accRect.right);
1518
+ accRect.bottom = min(rect.bottom, accRect.bottom);
1519
+ accRect.left = max(rect.left, accRect.left);
1520
+ return accRect;
1521
+ }), getClientRectFromMixedType(element, firstClippingParent));
1522
+ clippingRect.width = clippingRect.right - clippingRect.left;
1523
+ clippingRect.height = clippingRect.bottom - clippingRect.top;
1524
+ clippingRect.x = clippingRect.left;
1525
+ clippingRect.y = clippingRect.top;
1526
+ return clippingRect;
1527
+ }
1528
+
1529
+ function computeOffsets(_ref) {
1530
+ var reference = _ref.reference, element = _ref.element, placement = _ref.placement;
1531
+ var basePlacement = placement ? getBasePlacement(placement) : null;
1532
+ var variation = placement ? getVariation(placement) : null;
1533
+ var commonX = reference.x + reference.width / 2 - element.width / 2;
1534
+ var commonY = reference.y + reference.height / 2 - element.height / 2;
1535
+ var offsets;
1536
+ switch (basePlacement) {
1537
+ case top:
1538
+ offsets = {
1539
+ x: commonX,
1540
+ y: reference.y - element.height
1541
+ };
1542
+ break;
1543
+
1544
+ case bottom:
1545
+ offsets = {
1546
+ x: commonX,
1547
+ y: reference.y + reference.height
1548
+ };
1549
+ break;
1550
+
1551
+ case right:
1552
+ offsets = {
1553
+ x: reference.x + reference.width,
1554
+ y: commonY
1555
+ };
1556
+ break;
1557
+
1558
+ case left:
1559
+ offsets = {
1560
+ x: reference.x - element.width,
1561
+ y: commonY
1562
+ };
1563
+ break;
1564
+
1565
+ default:
1566
+ offsets = {
1567
+ x: reference.x,
1568
+ y: reference.y
1569
+ };
1570
+ }
1571
+ var mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null;
1572
+ if (mainAxis != null) {
1573
+ var len = mainAxis === "y" ? "height" : "width";
1574
+ switch (variation) {
1575
+ case start:
1576
+ offsets[mainAxis] = offsets[mainAxis] - (reference[len] / 2 - element[len] / 2);
1577
+ break;
1578
+
1579
+ case end:
1580
+ offsets[mainAxis] = offsets[mainAxis] + (reference[len] / 2 - element[len] / 2);
1581
+ break;
1582
+ }
1583
+ }
1584
+ return offsets;
1585
+ }
1586
+
1587
+ function detectOverflow(state, options) {
1588
+ if (options === void 0) {
1589
+ options = {};
1590
+ }
1591
+ var _options = options, _options$placement = _options.placement, placement = _options$placement === void 0 ? state.placement : _options$placement, _options$boundary = _options.boundary, boundary = _options$boundary === void 0 ? clippingParents : _options$boundary, _options$rootBoundary = _options.rootBoundary, rootBoundary = _options$rootBoundary === void 0 ? viewport : _options$rootBoundary, _options$elementConte = _options.elementContext, elementContext = _options$elementConte === void 0 ? popper : _options$elementConte, _options$altBoundary = _options.altBoundary, altBoundary = _options$altBoundary === void 0 ? false : _options$altBoundary, _options$padding = _options.padding, padding = _options$padding === void 0 ? 0 : _options$padding;
1592
+ var paddingObject = mergePaddingObject(typeof padding !== "number" ? padding : expandToHashMap(padding, basePlacements));
1593
+ var altContext = elementContext === popper ? reference : popper;
1594
+ var popperRect = state.rects.popper;
1595
+ var element = state.elements[altBoundary ? altContext : elementContext];
1596
+ var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary);
1597
+ var referenceClientRect = getBoundingClientRect(state.elements.reference);
1598
+ var popperOffsets = computeOffsets({
1599
+ reference: referenceClientRect,
1600
+ element: popperRect,
1601
+ strategy: "absolute",
1602
+ placement: placement
1603
+ });
1604
+ var popperClientRect = rectToClientRect(Object.assign({}, popperRect, popperOffsets));
1605
+ var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect;
1606
+ var overflowOffsets = {
1607
+ top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
1608
+ bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
1609
+ left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
1610
+ right: elementClientRect.right - clippingClientRect.right + paddingObject.right
1611
+ };
1612
+ var offsetData = state.modifiersData.offset;
1613
+ if (elementContext === popper && offsetData) {
1614
+ var offset = offsetData[placement];
1615
+ Object.keys(overflowOffsets).forEach((function(key) {
1616
+ var multiply = [ right, bottom ].indexOf(key) >= 0 ? 1 : -1;
1617
+ var axis = [ top, bottom ].indexOf(key) >= 0 ? "y" : "x";
1618
+ overflowOffsets[key] += offset[axis] * multiply;
1619
+ }));
1620
+ }
1621
+ return overflowOffsets;
1622
+ }
1623
+
1624
+ function computeAutoPlacement(state, options) {
1625
+ if (options === void 0) {
1626
+ options = {};
1627
+ }
1628
+ var _options = options, placement = _options.placement, boundary = _options.boundary, rootBoundary = _options.rootBoundary, padding = _options.padding, flipVariations = _options.flipVariations, _options$allowedAutoP = _options.allowedAutoPlacements, allowedAutoPlacements = _options$allowedAutoP === void 0 ? placements : _options$allowedAutoP;
1629
+ var variation = getVariation(placement);
1630
+ var placements$1 = variation ? flipVariations ? variationPlacements : variationPlacements.filter((function(placement) {
1631
+ return getVariation(placement) === variation;
1632
+ })) : basePlacements;
1633
+ var allowedPlacements = placements$1.filter((function(placement) {
1634
+ return allowedAutoPlacements.indexOf(placement) >= 0;
1635
+ }));
1636
+ if (allowedPlacements.length === 0) {
1637
+ allowedPlacements = placements$1;
1638
+ }
1639
+ var overflows = allowedPlacements.reduce((function(acc, placement) {
1640
+ acc[placement] = detectOverflow(state, {
1641
+ placement: placement,
1642
+ boundary: boundary,
1643
+ rootBoundary: rootBoundary,
1644
+ padding: padding
1645
+ })[getBasePlacement(placement)];
1646
+ return acc;
1647
+ }), {});
1648
+ return Object.keys(overflows).sort((function(a, b) {
1649
+ return overflows[a] - overflows[b];
1650
+ }));
1651
+ }
1652
+
1653
+ function getExpandedFallbackPlacements(placement) {
1654
+ if (getBasePlacement(placement) === auto) {
1655
+ return [];
1656
+ }
1657
+ var oppositePlacement = getOppositePlacement(placement);
1658
+ return [ getOppositeVariationPlacement(placement), oppositePlacement, getOppositeVariationPlacement(oppositePlacement) ];
1659
+ }
1660
+
1661
+ function flip(_ref) {
1662
+ var state = _ref.state, options = _ref.options, name = _ref.name;
1663
+ if (state.modifiersData[name]._skip) {
1664
+ return;
1665
+ }
1666
+ var _options$mainAxis = options.mainAxis, checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis, _options$altAxis = options.altAxis, checkAltAxis = _options$altAxis === void 0 ? true : _options$altAxis, specifiedFallbackPlacements = options.fallbackPlacements, padding = options.padding, boundary = options.boundary, rootBoundary = options.rootBoundary, altBoundary = options.altBoundary, _options$flipVariatio = options.flipVariations, flipVariations = _options$flipVariatio === void 0 ? true : _options$flipVariatio, allowedAutoPlacements = options.allowedAutoPlacements;
1667
+ var preferredPlacement = state.options.placement;
1668
+ var basePlacement = getBasePlacement(preferredPlacement);
1669
+ var isBasePlacement = basePlacement === preferredPlacement;
1670
+ var fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipVariations ? [ getOppositePlacement(preferredPlacement) ] : getExpandedFallbackPlacements(preferredPlacement));
1671
+ var placements = [ preferredPlacement ].concat(fallbackPlacements).reduce((function(acc, placement) {
1672
+ return acc.concat(getBasePlacement(placement) === auto ? computeAutoPlacement(state, {
1673
+ placement: placement,
1674
+ boundary: boundary,
1675
+ rootBoundary: rootBoundary,
1676
+ padding: padding,
1677
+ flipVariations: flipVariations,
1678
+ allowedAutoPlacements: allowedAutoPlacements
1679
+ }) : placement);
1680
+ }), []);
1681
+ var referenceRect = state.rects.reference;
1682
+ var popperRect = state.rects.popper;
1683
+ var checksMap = new Map;
1684
+ var makeFallbackChecks = true;
1685
+ var firstFittingPlacement = placements[0];
1686
+ for (var i = 0; i < placements.length; i++) {
1687
+ var placement = placements[i];
1688
+ var _basePlacement = getBasePlacement(placement);
1689
+ var isStartVariation = getVariation(placement) === start;
1690
+ var isVertical = [ top, bottom ].indexOf(_basePlacement) >= 0;
1691
+ var len = isVertical ? "width" : "height";
1692
+ var overflow = detectOverflow(state, {
1693
+ placement: placement,
1694
+ boundary: boundary,
1695
+ rootBoundary: rootBoundary,
1696
+ altBoundary: altBoundary,
1697
+ padding: padding
1698
+ });
1699
+ var mainVariationSide = isVertical ? isStartVariation ? right : left : isStartVariation ? bottom : top;
1700
+ if (referenceRect[len] > popperRect[len]) {
1701
+ mainVariationSide = getOppositePlacement(mainVariationSide);
1702
+ }
1703
+ var altVariationSide = getOppositePlacement(mainVariationSide);
1704
+ var checks = [];
1705
+ if (checkMainAxis) {
1706
+ checks.push(overflow[_basePlacement] <= 0);
1707
+ }
1708
+ if (checkAltAxis) {
1709
+ checks.push(overflow[mainVariationSide] <= 0, overflow[altVariationSide] <= 0);
1710
+ }
1711
+ if (checks.every((function(check) {
1712
+ return check;
1713
+ }))) {
1714
+ firstFittingPlacement = placement;
1715
+ makeFallbackChecks = false;
1716
+ break;
1717
+ }
1718
+ checksMap.set(placement, checks);
1719
+ }
1720
+ if (makeFallbackChecks) {
1721
+ var numberOfChecks = flipVariations ? 3 : 1;
1722
+ var _loop = function _loop(_i) {
1723
+ var fittingPlacement = placements.find((function(placement) {
1724
+ var checks = checksMap.get(placement);
1725
+ if (checks) {
1726
+ return checks.slice(0, _i).every((function(check) {
1727
+ return check;
1728
+ }));
1729
+ }
1730
+ }));
1731
+ if (fittingPlacement) {
1732
+ firstFittingPlacement = fittingPlacement;
1733
+ return "break";
1734
+ }
1735
+ };
1736
+ for (var _i = numberOfChecks; _i > 0; _i--) {
1737
+ var _ret = _loop(_i);
1738
+ if (_ret === "break") break;
1739
+ }
1740
+ }
1741
+ if (state.placement !== firstFittingPlacement) {
1742
+ state.modifiersData[name]._skip = true;
1743
+ state.placement = firstFittingPlacement;
1744
+ state.reset = true;
1745
+ }
1746
+ }
1747
+
1748
+ var flip$1 = {
1749
+ name: "flip",
1750
+ enabled: true,
1751
+ phase: "main",
1752
+ fn: flip,
1753
+ requiresIfExists: [ "offset" ],
1754
+ data: {
1755
+ _skip: false
1756
+ }
1757
+ };
1758
+
1759
+ function getSideOffsets(overflow, rect, preventedOffsets) {
1760
+ if (preventedOffsets === void 0) {
1761
+ preventedOffsets = {
1762
+ x: 0,
1763
+ y: 0
1764
+ };
1765
+ }
1766
+ return {
1767
+ top: overflow.top - rect.height - preventedOffsets.y,
1768
+ right: overflow.right - rect.width + preventedOffsets.x,
1769
+ bottom: overflow.bottom - rect.height + preventedOffsets.y,
1770
+ left: overflow.left - rect.width - preventedOffsets.x
1771
+ };
1772
+ }
1773
+
1774
+ function isAnySideFullyClipped(overflow) {
1775
+ return [ top, right, bottom, left ].some((function(side) {
1776
+ return overflow[side] >= 0;
1777
+ }));
1778
+ }
1779
+
1780
+ function hide(_ref) {
1781
+ var state = _ref.state, name = _ref.name;
1782
+ var referenceRect = state.rects.reference;
1783
+ var popperRect = state.rects.popper;
1784
+ var preventedOffsets = state.modifiersData.preventOverflow;
1785
+ var referenceOverflow = detectOverflow(state, {
1786
+ elementContext: "reference"
1787
+ });
1788
+ var popperAltOverflow = detectOverflow(state, {
1789
+ altBoundary: true
1790
+ });
1791
+ var referenceClippingOffsets = getSideOffsets(referenceOverflow, referenceRect);
1792
+ var popperEscapeOffsets = getSideOffsets(popperAltOverflow, popperRect, preventedOffsets);
1793
+ var isReferenceHidden = isAnySideFullyClipped(referenceClippingOffsets);
1794
+ var hasPopperEscaped = isAnySideFullyClipped(popperEscapeOffsets);
1795
+ state.modifiersData[name] = {
1796
+ referenceClippingOffsets: referenceClippingOffsets,
1797
+ popperEscapeOffsets: popperEscapeOffsets,
1798
+ isReferenceHidden: isReferenceHidden,
1799
+ hasPopperEscaped: hasPopperEscaped
1800
+ };
1801
+ state.attributes.popper = Object.assign({}, state.attributes.popper, {
1802
+ "data-popper-reference-hidden": isReferenceHidden,
1803
+ "data-popper-escaped": hasPopperEscaped
1804
+ });
1805
+ }
1806
+
1807
+ var hide$1 = {
1808
+ name: "hide",
1809
+ enabled: true,
1810
+ phase: "main",
1811
+ requiresIfExists: [ "preventOverflow" ],
1812
+ fn: hide
1813
+ };
1814
+
1815
+ function distanceAndSkiddingToXY(placement, rects, offset) {
1816
+ var basePlacement = getBasePlacement(placement);
1817
+ var invertDistance = [ left, top ].indexOf(basePlacement) >= 0 ? -1 : 1;
1818
+ var _ref = typeof offset === "function" ? offset(Object.assign({}, rects, {
1819
+ placement: placement
1820
+ })) : offset, skidding = _ref[0], distance = _ref[1];
1821
+ skidding = skidding || 0;
1822
+ distance = (distance || 0) * invertDistance;
1823
+ return [ left, right ].indexOf(basePlacement) >= 0 ? {
1824
+ x: distance,
1825
+ y: skidding
1826
+ } : {
1827
+ x: skidding,
1828
+ y: distance
1829
+ };
1830
+ }
1831
+
1832
+ function offset(_ref2) {
1833
+ var state = _ref2.state, options = _ref2.options, name = _ref2.name;
1834
+ var _options$offset = options.offset, offset = _options$offset === void 0 ? [ 0, 0 ] : _options$offset;
1835
+ var data = placements.reduce((function(acc, placement) {
1836
+ acc[placement] = distanceAndSkiddingToXY(placement, state.rects, offset);
1837
+ return acc;
1838
+ }), {});
1839
+ var _data$state$placement = data[state.placement], x = _data$state$placement.x, y = _data$state$placement.y;
1840
+ if (state.modifiersData.popperOffsets != null) {
1841
+ state.modifiersData.popperOffsets.x += x;
1842
+ state.modifiersData.popperOffsets.y += y;
1843
+ }
1844
+ state.modifiersData[name] = data;
1845
+ }
1846
+
1847
+ var offset$1 = {
1848
+ name: "offset",
1849
+ enabled: true,
1850
+ phase: "main",
1851
+ requires: [ "popperOffsets" ],
1852
+ fn: offset
1853
+ };
1854
+
1855
+ function popperOffsets(_ref) {
1856
+ var state = _ref.state, name = _ref.name;
1857
+ state.modifiersData[name] = computeOffsets({
1858
+ reference: state.rects.reference,
1859
+ element: state.rects.popper,
1860
+ strategy: "absolute",
1861
+ placement: state.placement
1862
+ });
1863
+ }
1864
+
1865
+ var popperOffsets$1 = {
1866
+ name: "popperOffsets",
1867
+ enabled: true,
1868
+ phase: "read",
1869
+ fn: popperOffsets,
1870
+ data: {}
1871
+ };
1872
+
1873
+ function getAltAxis(axis) {
1874
+ return axis === "x" ? "y" : "x";
1875
+ }
1876
+
1877
+ function preventOverflow(_ref) {
1878
+ var state = _ref.state, options = _ref.options, name = _ref.name;
1879
+ var _options$mainAxis = options.mainAxis, checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis, _options$altAxis = options.altAxis, checkAltAxis = _options$altAxis === void 0 ? false : _options$altAxis, boundary = options.boundary, rootBoundary = options.rootBoundary, altBoundary = options.altBoundary, padding = options.padding, _options$tether = options.tether, tether = _options$tether === void 0 ? true : _options$tether, _options$tetherOffset = options.tetherOffset, tetherOffset = _options$tetherOffset === void 0 ? 0 : _options$tetherOffset;
1880
+ var overflow = detectOverflow(state, {
1881
+ boundary: boundary,
1882
+ rootBoundary: rootBoundary,
1883
+ padding: padding,
1884
+ altBoundary: altBoundary
1885
+ });
1886
+ var basePlacement = getBasePlacement(state.placement);
1887
+ var variation = getVariation(state.placement);
1888
+ var isBasePlacement = !variation;
1889
+ var mainAxis = getMainAxisFromPlacement(basePlacement);
1890
+ var altAxis = getAltAxis(mainAxis);
1891
+ var popperOffsets = state.modifiersData.popperOffsets;
1892
+ var referenceRect = state.rects.reference;
1893
+ var popperRect = state.rects.popper;
1894
+ var tetherOffsetValue = typeof tetherOffset === "function" ? tetherOffset(Object.assign({}, state.rects, {
1895
+ placement: state.placement
1896
+ })) : tetherOffset;
1897
+ var normalizedTetherOffsetValue = typeof tetherOffsetValue === "number" ? {
1898
+ mainAxis: tetherOffsetValue,
1899
+ altAxis: tetherOffsetValue
1900
+ } : Object.assign({
1901
+ mainAxis: 0,
1902
+ altAxis: 0
1903
+ }, tetherOffsetValue);
1904
+ var offsetModifierState = state.modifiersData.offset ? state.modifiersData.offset[state.placement] : null;
1905
+ var data = {
1906
+ x: 0,
1907
+ y: 0
1908
+ };
1909
+ if (!popperOffsets) {
1910
+ return;
1911
+ }
1912
+ if (checkMainAxis) {
1913
+ var _offsetModifierState$;
1914
+ var mainSide = mainAxis === "y" ? top : left;
1915
+ var altSide = mainAxis === "y" ? bottom : right;
1916
+ var len = mainAxis === "y" ? "height" : "width";
1917
+ var offset = popperOffsets[mainAxis];
1918
+ var min$1 = offset + overflow[mainSide];
1919
+ var max$1 = offset - overflow[altSide];
1920
+ var additive = tether ? -popperRect[len] / 2 : 0;
1921
+ var minLen = variation === start ? referenceRect[len] : popperRect[len];
1922
+ var maxLen = variation === start ? -popperRect[len] : -referenceRect[len];
1923
+ var arrowElement = state.elements.arrow;
1924
+ var arrowRect = tether && arrowElement ? getLayoutRect(arrowElement) : {
1925
+ width: 0,
1926
+ height: 0
1927
+ };
1928
+ var arrowPaddingObject = state.modifiersData["arrow#persistent"] ? state.modifiersData["arrow#persistent"].padding : getFreshSideObject();
1929
+ var arrowPaddingMin = arrowPaddingObject[mainSide];
1930
+ var arrowPaddingMax = arrowPaddingObject[altSide];
1931
+ var arrowLen = within(0, referenceRect[len], arrowRect[len]);
1932
+ var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis : minLen - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis;
1933
+ var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis : maxLen + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis;
1934
+ var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow);
1935
+ var clientOffset = arrowOffsetParent ? mainAxis === "y" ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;
1936
+ var offsetModifierValue = (_offsetModifierState$ = offsetModifierState == null ? void 0 : offsetModifierState[mainAxis]) != null ? _offsetModifierState$ : 0;
1937
+ var tetherMin = offset + minOffset - offsetModifierValue - clientOffset;
1938
+ var tetherMax = offset + maxOffset - offsetModifierValue;
1939
+ var preventedOffset = within(tether ? min(min$1, tetherMin) : min$1, offset, tether ? max(max$1, tetherMax) : max$1);
1940
+ popperOffsets[mainAxis] = preventedOffset;
1941
+ data[mainAxis] = preventedOffset - offset;
1942
+ }
1943
+ if (checkAltAxis) {
1944
+ var _offsetModifierState$2;
1945
+ var _mainSide = mainAxis === "x" ? top : left;
1946
+ var _altSide = mainAxis === "x" ? bottom : right;
1947
+ var _offset = popperOffsets[altAxis];
1948
+ var _len = altAxis === "y" ? "height" : "width";
1949
+ var _min = _offset + overflow[_mainSide];
1950
+ var _max = _offset - overflow[_altSide];
1951
+ var isOriginSide = [ top, left ].indexOf(basePlacement) !== -1;
1952
+ var _offsetModifierValue = (_offsetModifierState$2 = offsetModifierState == null ? void 0 : offsetModifierState[altAxis]) != null ? _offsetModifierState$2 : 0;
1953
+ var _tetherMin = isOriginSide ? _min : _offset - referenceRect[_len] - popperRect[_len] - _offsetModifierValue + normalizedTetherOffsetValue.altAxis;
1954
+ var _tetherMax = isOriginSide ? _offset + referenceRect[_len] + popperRect[_len] - _offsetModifierValue - normalizedTetherOffsetValue.altAxis : _max;
1955
+ var _preventedOffset = tether && isOriginSide ? withinMaxClamp(_tetherMin, _offset, _tetherMax) : within(tether ? _tetherMin : _min, _offset, tether ? _tetherMax : _max);
1956
+ popperOffsets[altAxis] = _preventedOffset;
1957
+ data[altAxis] = _preventedOffset - _offset;
1958
+ }
1959
+ state.modifiersData[name] = data;
1960
+ }
1961
+
1962
+ var preventOverflow$1 = {
1963
+ name: "preventOverflow",
1964
+ enabled: true,
1965
+ phase: "main",
1966
+ fn: preventOverflow,
1967
+ requiresIfExists: [ "offset" ]
1968
+ };
1969
+
1970
+ function getHTMLElementScroll(element) {
1971
+ return {
1972
+ scrollLeft: element.scrollLeft,
1973
+ scrollTop: element.scrollTop
1974
+ };
1975
+ }
1976
+
1977
+ function getNodeScroll(node) {
1978
+ if (node === getWindow(node) || !isHTMLElement(node)) {
1979
+ return getWindowScroll(node);
1980
+ } else {
1981
+ return getHTMLElementScroll(node);
1982
+ }
1983
+ }
1984
+
1985
+ function isElementScaled(element) {
1986
+ var rect = element.getBoundingClientRect();
1987
+ var scaleX = round(rect.width) / element.offsetWidth || 1;
1988
+ var scaleY = round(rect.height) / element.offsetHeight || 1;
1989
+ return scaleX !== 1 || scaleY !== 1;
1990
+ }
1991
+
1992
+ function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
1993
+ if (isFixed === void 0) {
1994
+ isFixed = false;
1995
+ }
1996
+ var isOffsetParentAnElement = isHTMLElement(offsetParent);
1997
+ var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent);
1998
+ var documentElement = getDocumentElement(offsetParent);
1999
+ var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled);
2000
+ var scroll = {
2001
+ scrollLeft: 0,
2002
+ scrollTop: 0
2003
+ };
2004
+ var offsets = {
2005
+ x: 0,
2006
+ y: 0
2007
+ };
2008
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
2009
+ if (getNodeName(offsetParent) !== "body" || isScrollParent(documentElement)) {
2010
+ scroll = getNodeScroll(offsetParent);
2011
+ }
2012
+ if (isHTMLElement(offsetParent)) {
2013
+ offsets = getBoundingClientRect(offsetParent, true);
2014
+ offsets.x += offsetParent.clientLeft;
2015
+ offsets.y += offsetParent.clientTop;
2016
+ } else if (documentElement) {
2017
+ offsets.x = getWindowScrollBarX(documentElement);
2018
+ }
2019
+ }
2020
+ return {
2021
+ x: rect.left + scroll.scrollLeft - offsets.x,
2022
+ y: rect.top + scroll.scrollTop - offsets.y,
2023
+ width: rect.width,
2024
+ height: rect.height
2025
+ };
2026
+ }
2027
+
2028
+ function order(modifiers) {
2029
+ var map = new Map;
2030
+ var visited = new Set;
2031
+ var result = [];
2032
+ modifiers.forEach((function(modifier) {
2033
+ map.set(modifier.name, modifier);
2034
+ }));
2035
+ function sort(modifier) {
2036
+ visited.add(modifier.name);
2037
+ var requires = [].concat(modifier.requires || [], modifier.requiresIfExists || []);
2038
+ requires.forEach((function(dep) {
2039
+ if (!visited.has(dep)) {
2040
+ var depModifier = map.get(dep);
2041
+ if (depModifier) {
2042
+ sort(depModifier);
2043
+ }
2044
+ }
2045
+ }));
2046
+ result.push(modifier);
2047
+ }
2048
+ modifiers.forEach((function(modifier) {
2049
+ if (!visited.has(modifier.name)) {
2050
+ sort(modifier);
2051
+ }
2052
+ }));
2053
+ return result;
2054
+ }
2055
+
2056
+ function orderModifiers(modifiers) {
2057
+ var orderedModifiers = order(modifiers);
2058
+ return modifierPhases.reduce((function(acc, phase) {
2059
+ return acc.concat(orderedModifiers.filter((function(modifier) {
2060
+ return modifier.phase === phase;
2061
+ })));
2062
+ }), []);
2063
+ }
2064
+
2065
+ function debounce(fn) {
2066
+ var pending;
2067
+ return function() {
2068
+ if (!pending) {
2069
+ pending = new Promise((function(resolve) {
2070
+ Promise.resolve().then((function() {
2071
+ pending = undefined;
2072
+ resolve(fn());
2073
+ }));
2074
+ }));
2075
+ }
2076
+ return pending;
2077
+ };
2078
+ }
2079
+
2080
+ function mergeByName(modifiers) {
2081
+ var merged = modifiers.reduce((function(merged, current) {
2082
+ var existing = merged[current.name];
2083
+ merged[current.name] = existing ? Object.assign({}, existing, current, {
2084
+ options: Object.assign({}, existing.options, current.options),
2085
+ data: Object.assign({}, existing.data, current.data)
2086
+ }) : current;
2087
+ return merged;
2088
+ }), {});
2089
+ return Object.keys(merged).map((function(key) {
2090
+ return merged[key];
2091
+ }));
2092
+ }
2093
+
2094
+ var DEFAULT_OPTIONS = {
2095
+ placement: "bottom",
2096
+ modifiers: [],
2097
+ strategy: "absolute"
2098
+ };
2099
+
2100
+ function areValidElements() {
2101
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2102
+ args[_key] = arguments[_key];
2103
+ }
2104
+ return !args.some((function(element) {
2105
+ return !(element && typeof element.getBoundingClientRect === "function");
2106
+ }));
2107
+ }
2108
+
2109
+ function popperGenerator(generatorOptions) {
2110
+ if (generatorOptions === void 0) {
2111
+ generatorOptions = {};
2112
+ }
2113
+ var _generatorOptions = generatorOptions, _generatorOptions$def = _generatorOptions.defaultModifiers, defaultModifiers = _generatorOptions$def === void 0 ? [] : _generatorOptions$def, _generatorOptions$def2 = _generatorOptions.defaultOptions, defaultOptions = _generatorOptions$def2 === void 0 ? DEFAULT_OPTIONS : _generatorOptions$def2;
2114
+ return function createPopper(reference, popper, options) {
2115
+ if (options === void 0) {
2116
+ options = defaultOptions;
2117
+ }
2118
+ var state = {
2119
+ placement: "bottom",
2120
+ orderedModifiers: [],
2121
+ options: Object.assign({}, DEFAULT_OPTIONS, defaultOptions),
2122
+ modifiersData: {},
2123
+ elements: {
2124
+ reference: reference,
2125
+ popper: popper
2126
+ },
2127
+ attributes: {},
2128
+ styles: {}
2129
+ };
2130
+ var effectCleanupFns = [];
2131
+ var isDestroyed = false;
2132
+ var instance = {
2133
+ state: state,
2134
+ setOptions: function setOptions(setOptionsAction) {
2135
+ var options = typeof setOptionsAction === "function" ? setOptionsAction(state.options) : setOptionsAction;
2136
+ cleanupModifierEffects();
2137
+ state.options = Object.assign({}, defaultOptions, state.options, options);
2138
+ state.scrollParents = {
2139
+ reference: isElement(reference) ? listScrollParents(reference) : reference.contextElement ? listScrollParents(reference.contextElement) : [],
2140
+ popper: listScrollParents(popper)
2141
+ };
2142
+ var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers, state.options.modifiers)));
2143
+ state.orderedModifiers = orderedModifiers.filter((function(m) {
2144
+ return m.enabled;
2145
+ }));
2146
+ runModifierEffects();
2147
+ return instance.update();
2148
+ },
2149
+ forceUpdate: function forceUpdate() {
2150
+ if (isDestroyed) {
2151
+ return;
2152
+ }
2153
+ var _state$elements = state.elements, reference = _state$elements.reference, popper = _state$elements.popper;
2154
+ if (!areValidElements(reference, popper)) {
2155
+ return;
2156
+ }
2157
+ state.rects = {
2158
+ reference: getCompositeRect(reference, getOffsetParent(popper), state.options.strategy === "fixed"),
2159
+ popper: getLayoutRect(popper)
2160
+ };
2161
+ state.reset = false;
2162
+ state.placement = state.options.placement;
2163
+ state.orderedModifiers.forEach((function(modifier) {
2164
+ return state.modifiersData[modifier.name] = Object.assign({}, modifier.data);
2165
+ }));
2166
+ for (var index = 0; index < state.orderedModifiers.length; index++) {
2167
+ if (state.reset === true) {
2168
+ state.reset = false;
2169
+ index = -1;
2170
+ continue;
2171
+ }
2172
+ var _state$orderedModifie = state.orderedModifiers[index], fn = _state$orderedModifie.fn, _state$orderedModifie2 = _state$orderedModifie.options, _options = _state$orderedModifie2 === void 0 ? {} : _state$orderedModifie2, name = _state$orderedModifie.name;
2173
+ if (typeof fn === "function") {
2174
+ state = fn({
2175
+ state: state,
2176
+ options: _options,
2177
+ name: name,
2178
+ instance: instance
2179
+ }) || state;
2180
+ }
2181
+ }
2182
+ },
2183
+ update: debounce((function() {
2184
+ return new Promise((function(resolve) {
2185
+ instance.forceUpdate();
2186
+ resolve(state);
2187
+ }));
2188
+ })),
2189
+ destroy: function destroy() {
2190
+ cleanupModifierEffects();
2191
+ isDestroyed = true;
2192
+ }
2193
+ };
2194
+ if (!areValidElements(reference, popper)) {
2195
+ return instance;
2196
+ }
2197
+ instance.setOptions(options).then((function(state) {
2198
+ if (!isDestroyed && options.onFirstUpdate) {
2199
+ options.onFirstUpdate(state);
2200
+ }
2201
+ }));
2202
+ function runModifierEffects() {
2203
+ state.orderedModifiers.forEach((function(_ref3) {
2204
+ var name = _ref3.name, _ref3$options = _ref3.options, options = _ref3$options === void 0 ? {} : _ref3$options, effect = _ref3.effect;
2205
+ if (typeof effect === "function") {
2206
+ var cleanupFn = effect({
2207
+ state: state,
2208
+ name: name,
2209
+ instance: instance,
2210
+ options: options
2211
+ });
2212
+ var noopFn = function noopFn() {};
2213
+ effectCleanupFns.push(cleanupFn || noopFn);
2214
+ }
2215
+ }));
2216
+ }
2217
+ function cleanupModifierEffects() {
2218
+ effectCleanupFns.forEach((function(fn) {
2219
+ return fn();
2220
+ }));
2221
+ effectCleanupFns = [];
2222
+ }
2223
+ return instance;
2224
+ };
2225
+ }
2226
+
2227
+ var defaultModifiers = [ eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1, offset$1, flip$1, preventOverflow$1, arrow$1, hide$1 ];
2228
+
2229
+ var createPopper = popperGenerator({
2230
+ defaultModifiers: defaultModifiers
2231
+ });
2232
+
2233
+ class Popover extends Controller {
2234
+ static targets=[ "activator", "popover" ];
2235
+ static classes=[ "open", "closed" ];
2236
+ static values={
2237
+ placement: String,
2238
+ active: Boolean
2239
+ };
2240
+ connect() {
2241
+ this.popper = createPopper(this.activatorTarget, this.popoverTarget, {
2242
+ placement: this.placementValue,
2243
+ modifiers: [ {
2244
+ name: "offset",
2245
+ options: {
2246
+ offset: [ 0, 5 ]
2247
+ }
2248
+ }, {
2249
+ name: "flip",
2250
+ options: {
2251
+ allowedAutoPlacements: [ "top-start", "bottom-start", "top-end", "bottom-end" ]
2252
+ }
2253
+ } ]
2254
+ });
2255
+ if (this.activeValue) {
2256
+ this.show();
2257
+ }
2258
+ }
2259
+ toggle() {
2260
+ this.popoverTarget.classList.toggle(this.closedClass);
2261
+ this.popoverTarget.classList.toggle(this.openClass);
2262
+ }
2263
+ async show() {
2264
+ this.popoverTarget.classList.remove(this.closedClass);
2265
+ this.popoverTarget.classList.add(this.openClass);
2266
+ await this.popper.update();
2267
+ }
2268
+ hide(event) {
2269
+ if (!this.element.contains(event.target) && !this.popoverTarget.classList.contains(this.closedClass)) {
2270
+ this.forceHide();
2271
+ }
2272
+ }
2273
+ forceHide() {
2274
+ this.popoverTarget.classList.remove(this.openClass);
2275
+ this.popoverTarget.classList.add(this.closedClass);
2276
+ }
2277
+ }
2278
+
3
2279
  class ResourceItem extends Controller {
4
2280
  static targets=[ "link" ];
5
2281
  open(event) {
@@ -12,11 +2288,65 @@ class ResourceItem extends Controller {
12
2288
  }
13
2289
  }
14
2290
 
2291
+ class Scrollable extends Controller {
2292
+ static targets=[ "topEdge", "bottomEdge" ];
2293
+ static classes=[ "topShadow", "bottomShadow" ];
2294
+ static values={
2295
+ shadow: Boolean
2296
+ };
2297
+ initialize() {
2298
+ this.topEdgeReached = false;
2299
+ this.bottomEdgeReached = true;
2300
+ }
2301
+ connect() {
2302
+ if (this.shadowValue) {
2303
+ this.observer = new IntersectionObserver(this.handleIntersection);
2304
+ this.observer.observe(this.topEdgeTarget);
2305
+ this.observer.observe(this.bottomEdgeTarget);
2306
+ }
2307
+ }
2308
+ disconnect() {
2309
+ if (this.shadowValue) {
2310
+ this.observer.disconnect();
2311
+ }
2312
+ }
2313
+ handleIntersection=entries => {
2314
+ entries.forEach((entry => {
2315
+ const target = entry.target.dataset.polarisScrollableTarget;
2316
+ switch (target) {
2317
+ case "topEdge":
2318
+ this.topEdgeReached = entry.isIntersecting;
2319
+ break;
2320
+
2321
+ case "bottomEdge":
2322
+ this.bottomEdgeReached = entry.isIntersecting;
2323
+ break;
2324
+ }
2325
+ }));
2326
+ this.updateShadows();
2327
+ };
2328
+ updateShadows() {
2329
+ if (!this.topEdgeReached && !this.bottomEdgeReached) {
2330
+ this.element.classList.add(this.topShadowClass, this.bottomShadowClass);
2331
+ } else if (this.topEdgeReached && this.bottomEdgeReached) {
2332
+ this.element.classList.remove(this.topShadowClass, this.bottomShadowClass);
2333
+ } else if (this.topEdgeReached) {
2334
+ this.element.classList.remove(this.topShadowClass);
2335
+ this.element.classList.add(this.bottomShadowClass);
2336
+ } else if (this.bottomEdgeReached) {
2337
+ this.element.classList.add(this.topShadowClass);
2338
+ this.element.classList.remove(this.bottomShadowClass);
2339
+ }
2340
+ }
2341
+ }
2342
+
15
2343
  class Select extends Controller {
16
- static targets=[ "selectedOption" ];
17
- update(event) {
18
- const select = event.currentTarget;
19
- const option = select.options[select.selectedIndex];
2344
+ static targets=[ "select", "selectedOption" ];
2345
+ connect() {
2346
+ this.update();
2347
+ }
2348
+ update() {
2349
+ const option = this.selectTarget.options[this.selectTarget.selectedIndex];
20
2350
  this.selectedOptionTarget.innerText = option.text;
21
2351
  }
22
2352
  }
@@ -93,15 +2423,86 @@ class TextField extends Controller {
93
2423
  return;
94
2424
  }
95
2425
  const decimalPlaces = Math.max(dpl(numericValue), dpl(this.stepValue));
2426
+ const oldValue = this.value;
96
2427
  const newValue = Math.min(Number(this.maxValue), Math.max(numericValue + steps * this.stepValue, Number(this.minValue)));
97
2428
  this.value = String(newValue.toFixed(decimalPlaces));
2429
+ if (this.value != oldValue) {
2430
+ this.inputTarget.dispatchEvent(new Event("change"));
2431
+ }
2432
+ }
2433
+ }
2434
+
2435
+ class Toast extends Controller {
2436
+ static activeClass="Polaris-Frame-ToastManager--toastWrapperEnterDone";
2437
+ static defaultDuration=5e3;
2438
+ static defaultDurationWithAction=1e4;
2439
+ static values={
2440
+ hidden: Boolean,
2441
+ duration: Number,
2442
+ hasAction: Boolean
2443
+ };
2444
+ connect() {
2445
+ if (!this.hiddenValue) {
2446
+ this.show();
2447
+ }
2448
+ }
2449
+ show=() => {
2450
+ this.element.dataset.position = this.position;
2451
+ this.element.style.cssText = this.getStyle(this.position);
2452
+ this.element.classList.add(this.constructor.activeClass);
2453
+ setTimeout(this.close, this.timeoutDuration);
2454
+ };
2455
+ close=() => {
2456
+ this.element.classList.remove(this.constructor.activeClass);
2457
+ this.element.addEventListener("transitionend", this.updatePositions, false);
2458
+ };
2459
+ updatePositions=() => {
2460
+ this.visibleToasts.sort(((a, b) => parseInt(a.dataset.position) - parseInt(b.dataset.position))).forEach(((toast, index) => {
2461
+ const position = index + 1;
2462
+ toast.dataset.position = position;
2463
+ toast.style.cssText = this.getStyle(position);
2464
+ }));
2465
+ this.element.removeEventListener("transitionend", this.updatePositions, false);
2466
+ };
2467
+ getStyle(position) {
2468
+ const translateIn = -80 * position;
2469
+ const translateOut = 150 - 80 * position;
2470
+ return `--toast-translate-y-in: ${translateIn}px; --toast-translate-y-out: ${translateOut}px;`;
2471
+ }
2472
+ get timeoutDuration() {
2473
+ if (this.durationValue > 0) {
2474
+ return this.durationValue;
2475
+ } else if (this.hasActionValue) {
2476
+ return this.constructor.defaultDurationWithAction;
2477
+ } else {
2478
+ return this.constructor.defaultDuration;
2479
+ }
2480
+ }
2481
+ get toastManager() {
2482
+ return this.element.closest(".Polaris-Frame-ToastManager");
2483
+ }
2484
+ get visibleToasts() {
2485
+ return [ ...this.toastManager.querySelectorAll(`.${this.constructor.activeClass}`) ];
2486
+ }
2487
+ get position() {
2488
+ return this.visibleToasts.filter((el => !this.element.isEqualNode(el))).length + 1;
98
2489
  }
99
2490
  }
100
2491
 
101
2492
  function registerPolarisControllers(application) {
2493
+ application.register("polaris-autocomplete", Autocomplete);
2494
+ application.register("polaris-button", Button);
2495
+ application.register("polaris-dropzone", Dropzone);
2496
+ application.register("polaris-frame", Frame);
2497
+ application.register("polaris-modal", Modal);
2498
+ application.register("polaris-option-list", OptionList);
2499
+ application.register("polaris", Polaris);
2500
+ application.register("polaris-popover", Popover);
102
2501
  application.register("polaris-resource-item", ResourceItem);
2502
+ application.register("polaris-scrollable", Scrollable);
103
2503
  application.register("polaris-select", Select);
104
2504
  application.register("polaris-text-field", TextField);
2505
+ application.register("polaris-toast", Toast);
105
2506
  }
106
2507
 
107
- export { ResourceItem, Select, TextField, registerPolarisControllers };
2508
+ export { Frame, Modal, Polaris, Popover, ResourceItem, Scrollable, Select, TextField, registerPolarisControllers };