Search Regex - Version 3.0.0

Version Description

= 2.0 = * Entirely new rewrite of the plugin. Requires minimum PHP 5.6 and is compatible with all versions (tested up to 8.0).

= 3.0 = * Major update adding advanced search filters, modifications to any column, and a variety of actions (including exporting to SQL).

Download this release

Release Info

Developer johnny5
Plugin Icon 128x128 Search Regex
Version 3.0.0
Comparing to
See all releases

Code changes from version 2.4.1 to 3.0.0

Files changed (102) hide show
  1. api/api-replace.php +0 -117
  2. api/api-source.php +0 -310
  3. api/api.php +0 -53
  4. build/search-regex-version.php +5 -0
  5. build/search-regex.css +35 -0
  6. build/search-regex.js +8 -0
  7. build/search-regex.js.LICENSE.txt +110 -0
  8. includes/action/action-delete.php +40 -0
  9. includes/action/action-export.php +163 -0
  10. includes/action/action-global-replace.php +44 -0
  11. includes/action/action-modify.php +131 -0
  12. includes/action/action-nothing.php +19 -0
  13. includes/action/action-run.php +54 -0
  14. includes/action/class-action.php +171 -0
  15. includes/action/class-dynamic-column.php +242 -0
  16. includes/api/class-api.php +53 -0
  17. api/api-base.php → includes/api/class-route.php +192 -127
  18. api/api-plugin.php → includes/api/route/route-plugin.php +8 -4
  19. api/api-preset.php → includes/api/route/route-preset.php +47 -47
  20. api/api-search.php → includes/api/route/route-search.php +27 -18
  21. api/api-settings.php → includes/api/route/route-settings.php +34 -9
  22. includes/api/route/route-source.php +357 -0
  23. includes/context/class-context.php +100 -0
  24. includes/context/class-value-type.php +35 -0
  25. includes/context/context-add.php +24 -0
  26. includes/context/context-delete.php +24 -0
  27. includes/context/context-empty.php +25 -0
  28. includes/context/context-matched.php +20 -0
  29. includes/context/context-pair.php +84 -0
  30. includes/context/context-replace.php +74 -0
  31. includes/context/context-text.php +242 -0
  32. includes/context/context-value.php +111 -0
  33. includes/filter/class-global-filter.php +90 -0
  34. includes/filter/class-search-filter.php +394 -0
  35. includes/filter/filter-base.php +214 -0
  36. includes/filter/filter-date.php +126 -0
  37. includes/filter/filter-integer.php +181 -0
  38. includes/filter/filter-keyvalue.php +311 -0
  39. includes/filter/filter-member.php +192 -0
  40. includes/filter/filter-string.php +167 -0
  41. includes/modifier/class-modifier.php +175 -0
  42. includes/modifier/modifier-date.php +139 -0
  43. includes/modifier/modifier-integer.php +70 -0
  44. includes/modifier/modifier-keyvalue.php +127 -0
  45. includes/modifier/modifier-member.php +162 -0
  46. includes/modifier/modifier-string.php +260 -0
  47. search-regex-capabilities.php → includes/plugin/class-capabilities.php +4 -2
  48. includes/plugin/class-settings-base.php +91 -0
  49. includes/plugin/class-settings.php +147 -0
  50. includes/schema/class-column.php +183 -0
  51. includes/schema/class-schema.php +56 -0
  52. includes/schema/class-source.php +130 -0
  53. search-regex-admin.php → includes/search-regex-admin.php +134 -60
  54. search-regex-cli.php → includes/search-regex-cli.php +2 -0
  55. models/search-flags.php → includes/search/class-flags.php +29 -3
  56. includes/search/class-match-column.php +214 -0
  57. models/match.php → includes/search/class-match-text.php +34 -15
  58. models/preset.php → includes/search/class-preset.php +85 -29
  59. models/result.php → includes/search/class-result.php +50 -10
  60. includes/search/class-search.php +271 -0
  61. includes/search/class-totals.php +154 -0
  62. includes/source/class-autocomplete.php +124 -0
  63. includes/source/class-convert-values.php +145 -0
  64. includes/source/class-manager.php +274 -0
  65. includes/source/class-source.php +482 -0
  66. includes/source/core/source-comment-meta.php +33 -0
  67. includes/source/core/source-comment.php +269 -0
  68. includes/source/core/source-meta.php +135 -0
  69. includes/source/core/source-options.php +143 -0
  70. includes/source/core/source-post-meta.php +47 -0
  71. includes/source/core/source-post.php +441 -0
  72. includes/source/core/source-terms.php +145 -0
  73. includes/source/core/source-user-meta.php +47 -0
  74. includes/source/core/source-user.php +181 -0
  75. includes/source/plugin/source-redirection.php +537 -0
  76. includes/source/trait-has-meta.php +97 -0
  77. includes/source/trait-has-terms.php +98 -0
  78. includes/sql/class-from.php +41 -0
  79. includes/sql/class-group.php +29 -0
  80. includes/sql/class-query.php +273 -0
  81. includes/sql/class-sql.php +116 -0
  82. includes/sql/class-value.php +69 -0
  83. includes/sql/join/class-join.php +142 -0
  84. includes/sql/join/join-comment.php +86 -0
  85. includes/sql/join/join-meta.php +167 -0
  86. includes/sql/join/join-post.php +98 -0
  87. includes/sql/join/join-taxonomy.php +50 -0
  88. includes/sql/join/join-term.php +121 -0
  89. includes/sql/join/join-user.php +113 -0
  90. includes/sql/modifier/class-count.php +37 -0
  91. includes/sql/modifier/class-modifier.php +144 -0
  92. includes/sql/select/class-column.php +15 -0
  93. includes/sql/select/class-select.php +126 -0
  94. includes/sql/select/class-sum.php +67 -0
  95. includes/sql/where/class-where.php +92 -0
  96. includes/sql/where/where-and.php +14 -0
  97. includes/sql/where/where-date.php +44 -0
  98. includes/sql/where/where-in.php +45 -0
  99. includes/sql/where/where-integer.php +42 -0
  100. includes/sql/where/where-null.php +29 -0
  101. includes/sql/where/where-or.php +56 -0
  102. includes/sql/where/where-string.php +34 -0
api/api-replace.php DELETED
@@ -1,117 +0,0 @@
1
- <?php
2
-
3
- use SearchRegex\Search;
4
- use SearchRegex\Replace;
5
- use SearchRegex\Search_Flags;
6
- use SearchRegex\Search_Source;
7
- use SearchRegex\Source_Manager;
8
- use SearchRegex\Source_Flags;
9
-
10
- /**
11
- * @api {post} /search-regex/v1/replace Replace
12
- * @apiVersion 1.0.0
13
- * @apiName Replace
14
- * @apiDescription Updates the database with the replaced search phrase.
15
- *
16
- * @apiGroup Search
17
- *
18
- * @apiUse ReplaceQueryParams
19
- *
20
- * @apiUse SearchResults
21
- * @apiUse 401Error
22
- * @apiUse 404Error
23
- */
24
-
25
- /**
26
- * @apiDefine ReplaceQueryParams
27
- *
28
- * @apiParam (Query Parameter) {String} searchPhrase The search phrase
29
- * @apiParam (Query Parameter) {String} replacement The replacement phrase
30
- * @apiParam (Query Parameter) {Array} source The sources to search through. Currently only one source is supported
31
- * @apiParam (Query Parameter) {String} searchFlags[regex] Perform a regular expression search
32
- * @apiParam (Query Parameter) {String} searchFlags[case] Perform a case insensitive search
33
- * @apiParam (Query Parameter) {String} offset The current offset in the results
34
- * @apiParam (Query Parameter) {Integer=25,50,100,250,500} [perPage=25] The maximum number of results per page
35
- */
36
-
37
- /**
38
- * Search API endpoint
39
- */
40
- class Search_Regex_Api_Replace extends Search_Regex_Api_Route {
41
- /**
42
- * Return API paging args
43
- *
44
- * @internal
45
- * @return Array<String, Array>
46
- */
47
- private function get_replace_paging_params() {
48
- return [
49
- 'offset' => [
50
- 'description' => 'The current replace offset in the results',
51
- 'type' => 'string',
52
- 'required' => true,
53
- ],
54
- 'perPage' => [
55
- 'description' => 'The maximum number of results per page',
56
- 'type' => 'integer',
57
- 'default' => 25,
58
- 'maximum' => 5000,
59
- 'minimum' => 25,
60
- ],
61
- ];
62
- }
63
-
64
- /**
65
- * Search API endpoint constructor
66
- *
67
- * @param String $namespace Namespace.
68
- */
69
- public function __construct( $namespace ) {
70
- register_rest_route( $namespace, '/replace', [
71
- 'args' => array_merge(
72
- $this->get_search_params(),
73
- $this->get_replace_paging_params()
74
- ),
75
- $this->get_route( WP_REST_Server::EDITABLE, 'replaceAll', [ $this, 'permission_callback' ] ),
76
- ] );
77
- }
78
-
79
- /**
80
- * Perform a replacement on all rows
81
- *
82
- * @param WP_REST_Request $request The request.
83
- * @return WP_Error|array Return an array of results, or a WP_Error
84
- */
85
- public function replaceAll( WP_REST_Request $request ) {
86
- $params = $request->get_params();
87
-
88
- list( $search, $replacer ) = $this->get_search_replace( $params, $params['replacement'] );
89
-
90
- // Get all the rows to replace
91
- $results = $search->get_replace_results( $replacer, $params['offset'], $params['perPage'] );
92
- if ( $results instanceof WP_Error ) {
93
- return $results;
94
- }
95
-
96
- // Replace all the rows
97
- $replaced = $replacer->save_and_replace( $results['results'] );
98
- if ( is_wp_error( $replaced ) ) {
99
- return $replaced;
100
- }
101
-
102
- // This is 'protection' to stop things looping.
103
- if ( $results['next'] === $params['offset'] ) {
104
- $results['next'] = false;
105
- }
106
-
107
- // Return pointers to the next data
108
- return [
109
- 'replaced' => $replaced,
110
- 'progress' => [
111
- 'next' => $results['next'],
112
- 'rows' => $results['rows'],
113
- ],
114
- 'totals' => $results['totals'],
115
- ];
116
- }
117
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
api/api-source.php DELETED
@@ -1,310 +0,0 @@
1
- <?php
2
-
3
- use SearchRegex\Search;
4
- use SearchRegex\Replace;
5
- use SearchRegex\Search_Flags;
6
- use SearchRegex\Search_Source;
7
- use SearchRegex\Source_Manager;
8
- use SearchRegex\Source_Flags;
9
-
10
- /**
11
- * @api {get} /search-regex/v1/source List of sources
12
- * @apiVersion 1.0.0
13
- * @apiName GetSources
14
- * @apiDescription Return all the available sources
15
- *
16
- * @apiGroup Source
17
- *
18
- * @apiUse SearchResults
19
- * @apiUse 401Error
20
- * @apiUse 404Error
21
- */
22
-
23
- /**
24
- * @api {get} /search-regex/v1/source/:source/:rowId Load row
25
- * @apiName LoadRow
26
- * @apiDescription Load a row of data from one source. This can be used to get the full data for a particular search.
27
- *
28
- * @apiGroup Source
29
- *
30
- * @apiParam (URL) {String} :source The source
31
- * @apiParam (URL) {Integer} :rowId The source row ID
32
- *
33
- * @apiSuccess {String[]} result Associative array of `column_name` => `value`
34
- * @apiUse 401Error
35
- * @apiUse 404Error
36
- */
37
-
38
- /**
39
- * @api {post} /search-regex/v1/source/:source/:rowId Update row
40
- * @apiVersion 1.0.0
41
- * @apiName UpdateRow
42
- * @apiDescription Save data to a column of a row of a source, returning the same row back with modified data
43
- *
44
- * @apiGroup Source
45
- *
46
- * @apiParam (URL) {String} :source The source
47
- * @apiParam (URL) {Integer} :rowId The source row ID
48
- * @apiParam {String} columnId Column ID of the item to save content to
49
- * @apiParam {String} content The new content
50
- *
51
- * @apiUse SearchResult
52
- * @apiUse 401Error
53
- * @apiUse 404Error
54
- */
55
-
56
- /**
57
- * @api {post} /search-regex/v1/source/:source/:rowId/replace Replace a row
58
- * @apiVersion 1.0.0
59
- * @apiName ReplaceRow
60
- * @apiDescription Performs a replace on a row
61
- *
62
- * @apiGroup Source
63
- *
64
- * @apiParam (URL) {String} :source The source
65
- * @apiParam {Integer} :rowId Row ID of the item to replace
66
- * @apiParam {String} [columnId] Column ID of the item to replace
67
- * @apiParam {Integer} [posId] Positional ID of the item to replace
68
- *
69
- * @apiUse SearchResult
70
- * @apiUse 401Error
71
- * @apiUse 404Error
72
- */
73
-
74
- /**
75
- * @api {post} /search-regex/v1/source/:source/:rowId/delete Delete row
76
- * @apiVersion 1.0.0
77
- * @apiName DeleteRow
78
- * @apiDescription Removes an entire row of data from the source
79
- *
80
- * @apiGroup Source
81
- *
82
- * @apiParam (URL) {String} :source The source
83
- * @apiParam (URL) {Integer} :rowId The source row ID
84
- *
85
- * @apiSuccess {Bool} result `true` if deleted, `false` otherwise
86
- * @apiUse 401Error
87
- * @apiUse 404Error
88
- */
89
-
90
- /**
91
- * Search API endpoint
92
- */
93
- class Search_Regex_Api_Source extends Search_Regex_Api_Route {
94
- /**
95
- * Search API endpoint constructor
96
- *
97
- * @param String $namespace Namespace.
98
- */
99
- public function __construct( $namespace ) {
100
- register_rest_route( $namespace, '/source', [
101
- $this->get_route( WP_REST_Server::READABLE, 'getSources', [ $this, 'permission_callback' ] ),
102
- ] );
103
-
104
- register_rest_route( $namespace, '/source/(?P<source>[a-z\-\_]+)/(?P<rowId>[\d]+)', [
105
- $this->get_route( WP_REST_Server::READABLE, 'loadRow', [ $this, 'permission_callback' ] ),
106
- ] );
107
-
108
- $search_no_source = $this->get_search_params();
109
- unset( $search_no_source['source'] );
110
- register_rest_route( $namespace, '/source/(?P<source>[a-z\-]+)/(?P<rowId>[\d]+)', [
111
- 'args' => array_merge(
112
- $search_no_source,
113
- [
114
- 'columnId' => [
115
- 'description' => 'Column within the row to update',
116
- 'type' => 'string',
117
- 'required' => true,
118
- 'validate_callback' => [ $this, 'validate_replace_column' ],
119
- ],
120
- 'content' => [
121
- 'description' => 'The new content',
122
- 'type' => 'string',
123
- 'required' => true,
124
- ],
125
- ]
126
- ),
127
- $this->get_route( WP_REST_Server::EDITABLE, 'saveRow', [ $this, 'permission_callback' ] ),
128
- ] );
129
-
130
- register_rest_route( $namespace, '/source/(?P<source>[a-z\-\_]+)/(?P<rowId>[\d]+)/delete', [
131
- $this->get_route( WP_REST_Server::EDITABLE, 'deleteRow', [ $this, 'permission_callback' ] ),
132
- ] );
133
-
134
- register_rest_route( $namespace, '/source/(?P<source>[a-z\-\_]+)/(?P<rowId>[\d]+)/replace', [
135
- 'args' => array_merge(
136
- $this->get_search_params(),
137
- [
138
- 'rowId' => [
139
- 'description' => 'Optional row ID',
140
- 'type' => 'integer',
141
- 'default' => 0,
142
- ],
143
- 'columnId' => [
144
- 'description' => 'Optional column ID',
145
- 'type' => 'string',
146
- 'default' => null,
147
- 'validate_callback' => [ $this, 'validate_replace_column' ],
148
- ],
149
- 'posId' => [
150
- 'description' => 'Optional position ID',
151
- 'type' => 'integer',
152
- ],
153
- ]
154
- ),
155
- $this->get_route( WP_REST_Server::EDITABLE, 'replaceRow', [ $this, 'permission_callback' ] ),
156
- ] );
157
- }
158
-
159
- /**
160
- * Get list of all sources
161
- *
162
- * @param WP_REST_Request $request The request.
163
- * @return WP_Error|array Return an array of sources, or a WP_Error
164
- */
165
- public function getSources( WP_REST_Request $request ) {
166
- $sources = Source_Manager::get_all_sources();
167
-
168
- return array_map( function( $source ) {
169
- return [
170
- 'name' => $source['name'],
171
- 'label' => $source['label'],
172
- 'description' => $source['description'],
173
- 'type' => $source['type'],
174
- ];
175
- }, $sources );
176
- }
177
-
178
- /**
179
- * Perform a replacement on a row
180
- *
181
- * @param WP_REST_Request $request The request.
182
- * @return WP_Error|array Return an array of results, or a WP_Error
183
- */
184
- public function replaceRow( WP_REST_Request $request ) {
185
- $params = $request->get_params();
186
-
187
- $flags = new Search_Flags( $params['searchFlags'] );
188
- $sources = Source_Manager::get( $params['source'], $flags, new Source_Flags( $params['sourceFlags'] ) );
189
-
190
- // Get the Search/Replace pair, with our replacePhrase as the replacement value
191
- $search = new Search( $params['searchPhrase'], $sources, $flags );
192
- $replacer = new Replace( $params['replacePhrase'], $sources, $flags );
193
-
194
- // Get the row
195
- $results = $search->get_row( $sources[0], $params['rowId'], $replacer );
196
-
197
- if ( $results instanceof \WP_Error ) {
198
- return $results;
199
- }
200
-
201
- // Do the replacement
202
- $replaced = $replacer->save_and_replace( $results, isset( $params['columnId'] ) ? $params['columnId'] : null, isset( $params['posId'] ) ? intval( $params['posId'], 10 ) : null );
203
- if ( is_wp_error( $replaced ) ) {
204
- return $replaced;
205
- }
206
-
207
- // Get the row again
208
- $replacer = new Replace( $params['replacement'], $sources, $flags );
209
- $results = $search->get_row( $sources[0], $params['rowId'], $replacer );
210
-
211
- if ( $results instanceof \WP_Error ) {
212
- return $results;
213
- }
214
-
215
- return [
216
- 'result' => $search->results_to_json( $results ),
217
- ];
218
- }
219
-
220
- /**
221
- * Save data to a row and column within a source
222
- *
223
- * @param WP_REST_Request $request The request.
224
- * @return WP_Error|array Return an array of results, or a WP_Error
225
- */
226
- public function saveRow( WP_REST_Request $request ) {
227
- $params = $request->get_params();
228
-
229
- $flags = new Search_Flags( $params['searchFlags'] );
230
- $sources = Source_Manager::get( [ $params['source'] ], $flags, new Source_Flags( $params['sourceFlags'] ) );
231
-
232
- $result = $sources[0]->save( $params['rowId'], $params['columnId'], $params['content'] );
233
-
234
- if ( is_wp_error( $result ) ) {
235
- return $result;
236
- }
237
-
238
- $search = new Search( $params['searchPhrase'], $sources, $flags );
239
- $replacer = new Replace( $params['replacement'], $sources, $flags );
240
-
241
- $row = $search->get_row( $sources[0], $params['rowId'], $replacer );
242
- if ( is_wp_error( $row ) ) {
243
- return $row;
244
- }
245
-
246
- $results = $search->results_to_json( (array) $row );
247
-
248
- return [
249
- 'result' => count( $results ) > 0 ? $results[0] : [],
250
- ];
251
- }
252
-
253
- /**
254
- * Load all relevant data from a source's row
255
- *
256
- * @param WP_REST_Request $request The request.
257
- * @return WP_Error|array Return an array of results, or a WP_Error
258
- */
259
- public function loadRow( WP_REST_Request $request ) {
260
- $params = $request->get_params();
261
-
262
- $sources = Source_Manager::get( [ $params['source'] ], new Search_Flags(), new Source_Flags() );
263
- $row = $sources[0]->get_row( $params['rowId'] );
264
-
265
- if ( is_wp_error( $row ) ) {
266
- return $row;
267
- }
268
-
269
- return [
270
- 'result' => $row,
271
- ];
272
- }
273
-
274
- /**
275
- * Delete a row of data
276
- *
277
- * @param WP_REST_Request $request The request.
278
- * @return WP_Error|array Return an array of results, or a WP_Error
279
- */
280
- public function deleteRow( WP_REST_Request $request ) {
281
- $params = $request->get_params();
282
- $sources = Source_Manager::get( [ $params['source'] ], new Search_Flags(), new Source_Flags() );
283
-
284
- return $sources[0]->delete_row( $params['rowId'] );
285
- }
286
-
287
- /**
288
- * Validate the replacement column
289
- *
290
- * @param Array|String $value The value to validate.
291
- * @param WP_REST_Request $request The request.
292
- * @param Array $param The array of parameters.
293
- * @return Bool|WP_Error true or false
294
- */
295
- public function validate_replace_column( $value, WP_REST_Request $request, $param ) {
296
- $params = $request->get_params();
297
- $sources = Source_Manager::get( [ $params['source'] ], new Search_Flags(), new Source_Flags() );
298
- $columns = [];
299
-
300
- foreach ( $sources as $source ) {
301
- $columns = array_merge( $columns, $source->get_columns() );
302
- }
303
-
304
- if ( in_array( $value, $columns, true ) ) {
305
- return true;
306
- }
307
-
308
- return new WP_Error( 'rest_invalid_param', 'Invalid column detected', array( 'status' => 400 ) );
309
- }
310
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
api/api.php DELETED
@@ -1,53 +0,0 @@
1
- <?php
2
-
3
- require_once __DIR__ . '/api-base.php';
4
- require_once __DIR__ . '/api-search.php';
5
- require_once __DIR__ . '/api-replace.php';
6
- require_once __DIR__ . '/api-source.php';
7
- require_once __DIR__ . '/api-settings.php';
8
- require_once __DIR__ . '/api-plugin.php';
9
- require_once __DIR__ . '/api-preset.php';
10
-
11
- define( 'SEARCHREGEX_API_NAMESPACE', 'search-regex/v1' );
12
-
13
- class Search_Regex_Api {
14
- /**
15
- * Instance variable
16
- *
17
- * @var Search_Regex_Api|null
18
- **/
19
- private static $instance = null;
20
-
21
- /**
22
- * Array of endpoint routes
23
- *
24
- * @var Array
25
- **/
26
- private $routes = array();
27
-
28
- /**
29
- * Create API
30
- *
31
- * @return Search_Regex_Api
32
- */
33
- public static function init() {
34
- if ( is_null( self::$instance ) ) {
35
- self::$instance = new Search_Regex_Api();
36
- }
37
-
38
- return self::$instance;
39
- }
40
-
41
- public function __construct() {
42
- global $wpdb;
43
-
44
- $wpdb->hide_errors();
45
-
46
- $this->routes[] = new Search_Regex_Api_Search( SEARCHREGEX_API_NAMESPACE );
47
- $this->routes[] = new Search_Regex_Api_Replace( SEARCHREGEX_API_NAMESPACE );
48
- $this->routes[] = new Search_Regex_Api_Source( SEARCHREGEX_API_NAMESPACE );
49
- $this->routes[] = new Search_Regex_Api_Plugin( SEARCHREGEX_API_NAMESPACE );
50
- $this->routes[] = new Search_Regex_Api_Settings( SEARCHREGEX_API_NAMESPACE );
51
- $this->routes[] = new Search_Regex_Api_Preset( SEARCHREGEX_API_NAMESPACE );
52
- }
53
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
build/search-regex-version.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+
3
+ define( 'SEARCHREGEX_VERSION', '3.0.0' );
4
+ define( 'SEARCHREGEX_BUILD', 'ee0e657188bd207fe9fdc31d86c6c552' );
5
+ define( 'SEARCHREGEX_MIN_WP', '5.6' );
build/search-regex.css ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .wpl-badge{align-items:center;background-color:#ccc;border-radius:3px;color:#000;display:inline-flex;margin-bottom:4px;margin-top:4px;min-height:24px;padding:0 4px}.wpl-badge.wpl-badge__click{border:1px solid transparent;cursor:pointer}.wpl-badge.wpl-badge__click:hover{background-color:#949494;color:#fff}.wpl-badge .wpl-badge__close{background-color:transparent;border:none;cursor:pointer;margin-left:2px;text-align:center;vertical-align:middle;width:15px}.wpl-badge .wpl-badge__close:hover{color:#fff}.wpl-badge.wpl-badge__small .wpl-badge__content{max-width:100px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.wpl-badge.wpl-badge__disabled{opacity:.6}.wpl-badge.wpl-badge__disabled .wpl-badge__close{cursor:inherit}.wpl-badge:not(:last-child){margin-right:5px}
2
+ .wpl-popover__toggle{cursor:pointer;display:inline-block;flex:none!important}.wpl-popover__toggle__disabled{opacity:.4}
3
+ .wpl-popover__arrows{position:absolute;width:100%;z-index:10003}.wpl-popover__arrows:after,.wpl-popover__arrows:before{box-shadow:0 3px 30px rgba(30,30,30,.1);content:"";height:0;line-height:0;margin-left:10px;position:absolute;width:0}.wpl-popover__arrows:before{border:8px solid transparent;border-bottom:8px solid #ccc;border-top:none;top:-8px}.wpl-popover__arrows:after{border:8px solid transparent;border-bottom:8px solid #fff;border-top:none;top:-6px;z-index:10003}.wpl-popover__arrows.wpl-popover__arrows__right:after,.wpl-popover__arrows.wpl-popover__arrows__right:before{margin-right:10px;right:0}.wpl-popover__arrows.wpl-popover__arrows__centre:after,.wpl-popover__arrows.wpl-popover__arrows__centre:before{left:calc(50% - 16px)}.wpl-popover__content{background:#fff;border:1px solid #ccc;box-shadow:0 3px 30px rgba(30,30,30,.1);height:auto;max-height:400px;min-width:150px;overflow-y:auto;position:absolute;z-index:10002}
4
+ .wpl-dropdownbutton .wpl-popover__content h4{margin-top:5px}.wpl-dropdownbutton .wpl-popover__content h5{margin-bottom:5px;margin-top:0}.wpl-dropdownbutton .wpl-popover__content p:last-child{margin-bottom:0}.wpl-dropdownbutton li,.wpl-dropdownbutton ul{margin:0;padding:0;white-space:nowrap}.wpl-dropdownbutton a{color:#444;display:block;line-height:1.8;padding:5px 10px 5px 7px;text-decoration:none;width:auto}.wpl-dropdownbutton a:hover{background-color:#2684ff;color:#fff}.wpl-dropdownbutton svg{fill:#888;border-left:1px solid #ddd;display:inline-block;margin-left:5px;margin-right:-4px;padding-left:5px}.wpl-dropdownbutton h5{font-size:13px;font-weight:400;margin:0 10px 0 0;padding:0}.wpl-dropdownbutton .button{align-items:center;background-color:#fff;border-color:#7e8993;color:#32373c;display:flex;min-height:30px}.wpl-dropdownbutton__single h5{margin-right:0;text-align:center}.wpl-dropdownbutton__check{display:inline-block;width:16px}.wpl-dropdownbutton .wpl-dropdownbutton__button_enabled{background-color:#fff}.wpl-dropdownbutton .wpl-dropdownbutton__button_enabled svg{border-left:1px solid transparent;border-right:1px solid #ddd;padding-left:0;padding-right:4px;transform:rotate(180deg)}
5
+ .wpl-dropdownmenu{background-color:transparent;border:1px solid transparent;cursor:pointer;padding:0}.wpl-dropdownmenu svg{margin-top:3px}.wpl-dropdownmenu__menu{margin:5px 0 0;padding:0}.wpl-dropdownmenu__menu li>a,.wpl-dropdownmenu__menu li>div{color:#000;display:block;padding:5px 10px;text-decoration:none;width:100%}.wpl-dropdownmenu__menu li>a:hover,.wpl-dropdownmenu__menu li>div:hover{background-color:#ccc}
6
+ .wpl-dropdowntext{display:flex;position:relative}.wpl-dropdowntext input{width:100%}.wpl-dropdowntext .wpl-dropdowntext__loading{position:absolute;right:7px;top:2px}.wpl-dropdowntext .wpl-dropdowntext__loading svg{height:28px;opacity:.7;width:28px}.wpl-dropdowntext__max{display:none}.wpl-dropdowntext__suggestion input{width:100%}.wpl-dropdowntext__suggestion .wpl-badge{background-color:#4ab866;color:#fff;margin-left:5px;margin-right:5px}.wpl-dropdowntext__suggestion .wpl-badge .wpl-badge__content{font-weight:700}.wpl-dropdowntext__suggestion__hide input{display:none}.wpl-dropdowntext__suggestions .wpl-popover__content{line-height:1.8;padding:5px}.wpl-dropdowntext__suggestions .wpl-popover__content ul{list-style-type:none;margin:0;padding:0}.wpl-dropdowntext__suggestions .wpl-popover__content ul li{margin:0}.wpl-dropdowntext__suggestions .wpl-popover__content a{color:#333;display:block;padding:2px 3px;text-decoration:none}.wpl-dropdowntext__suggestions .wpl-popover__content a:hover{background-color:#deebff}
7
+ .wpl-multioption .wpl-popover__content{box-sizing:border-box;padding:10px;white-space:nowrap;z-index:10002}.wpl-multioption .wpl-popover__content h4{margin-top:5px}.wpl-multioption .wpl-popover__content h5{color:#999;margin-bottom:6px;margin-top:3px;text-transform:uppercase}.wpl-multioption .wpl-popover__content p{margin:2px 0 .8em!important}.wpl-multioption .wpl-popover__content p:first-child{margin-top:0}.wpl-multioption .wpl-popover__content p:last-child{margin-bottom:0!important}.wpl-multioption .wpl-popover__content label{display:inline-block;width:100%}.button.wpl-multioption__button,.wpl-multioption__button{align-items:center;background-color:#fff;border-color:#7e8993;box-shadow:none;box-sizing:border-box;color:#32373c;display:flex;height:30px;justify-content:space-between;max-width:500px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.button.wpl-multioption__button svg,.wpl-multioption__button svg{fill:#888;border-left:1px solid #ddd;display:inline-block;margin-left:5px;margin-right:-4px;padding-left:5px}.button.wpl-multioption__button h5,.wpl-multioption__button h5{font-size:13px;font-weight:400;margin:0 10px 0 0;padding:0}.button.wpl-multioption__button .wpl-badge,.wpl-multioption__button .wpl-badge{height:22px}.wpl-multioption__group:first-child{padding-top:7px}.wpl-multioption__group h5{margin:0}.wpl-multioption__group input[type=checkbox]{margin-right:7px}.actions .button.wpl-multioption__button{height:28px}.wpl-multioption__button.wpl-multioption__button_enabled{background-color:#fff}.wpl-multioption__button.wpl-multioption__button_enabled svg{border-left:1px solid transparent;border-right:1px solid #ddd;padding-left:0;padding-right:4px;transform:rotate(180deg)}.wpl-multioption__group{margin-bottom:20px}.wpl-multioption__group:last-child{margin-bottom:10px}.branch-4-9 .button.wpl-multioption__button,.branch-4-9 .wpl-dropdownbutton .button,.branch-5-0 .button.wpl-multioption__button,.branch-5-0 .wpl-dropdownbutton .button,.branch-5-1 .button.wpl-multioption__button,.branch-5-1 .wpl-dropdownbutton .button,.branch-5-2 .button.wpl-multioption__button,.branch-5-2 .wpl-dropdownbutton .button{border-color:#ddd}.branch-4-9 input[type=search],.branch-5-0 input[type=search],.branch-5-1 input[type=search],.branch-5-2 input[type=search]{height:30px}.branch-4-9 .actions .wpl-multioption__button .wpl-badge,.branch-4-9 .wpl-multioption,.branch-4-9 .wpl-multioption__button .wpl-badge,.branch-5-0 .actions .wpl-multioption__button .wpl-badge,.branch-5-0 .wpl-multioption,.branch-5-0 .wpl-multioption__button .wpl-badge,.branch-5-1 .actions .wpl-multioption__button .wpl-badge,.branch-5-1 .wpl-multioption,.branch-5-1 .wpl-multioption__button .wpl-badge,.branch-5-2 .actions .wpl-multioption__button .wpl-badge,.branch-5-2 .wpl-multioption,.branch-5-2 .wpl-multioption__button .wpl-badge{margin-top:1px!important}.actions .wpl-popover__content{margin-top:-1px}.wpl-multioption{padding:0 10px}.wpl-multioption p{white-space:nowrap}
8
+ .subsubsub-container:after,.subsubsub-container:before{content:"";display:table}.subsubsub-container:after{clear:both}
9
+ body.wpl-modal_shown{overflow:hidden}.wpl-modal_wrapper{width:100%}.wpl-modal_backdrop{background-color:#757575;opacity:.5;z-index:10000}.wpl-modal_backdrop,.wpl-modal_main{height:100%;left:0;position:fixed;top:0;width:100%}.wpl-modal_main{align-items:center;display:flex;flex-direction:row;flex-grow:1;justify-content:center;z-index:10001}.wpl-modal_main .wpl-click-outside,.wpl-modal_main .wpl-modal_content{max-height:90%;max-width:90%;min-height:100px;min-width:60%}.wpl-modal_main .wpl-modal_content{background:#fff;border:1px solid #e2e4e7;box-shadow:0 3px 30px rgba(25,30,35,.2);margin:0 auto;opacity:1;position:relative;transition:height .05s ease}.wpl-modal_main .wpl-modal_content h1{color:#1e1e1e!important;margin:0!important}.wpl-modal_main .wpl-modal_close button{background-color:#fff;border:none;border-radius:2px;cursor:pointer;padding-right:10px;padding-top:10px;position:absolute;right:0;top:0;z-index:10001}.wpl-modal_wrapper.wpl-modal_wrapper-padless .wpl-modal_content{padding:20px}.wpl-modal_wrapper-padding .wpl-modal_content{padding:10px}.wpl-modal_error h2{text-align:center}.wpl-modal_loading{display:flex;height:100px}.wpl-modal_loading>*{align-self:center;justify-content:center;margin-left:calc(50% - 30px);margin-top:40px}@media screen and (max-width:782px){.wpl-modal_main .wpl-modal_content{margin-right:10%;width:80%}}
10
+ .wpl-notice{border-top:1px solid #eee;bottom:25px;box-shadow:3px 3px 3px rgba(0,0,0,.2);cursor:pointer;font-weight:700;position:fixed;right:0;transition:width 1s ease-in-out}.wpl-notice p{padding-right:20px}.wpl-notice .closer{font-size:16px;opacity:.8;position:absolute;right:5px;top:10px}.wpl-notice.notice-shrunk{width:20px}.wpl-notice.notice-shrunk p{font-size:16px}.wpl-notice.notice-shrunk .closer{display:none}
11
+ @-webkit-keyframes wpl-loading-fade{0%{opacity:.5}50%{opacity:1}to{opacity:.5}}@keyframes wpl-loading-fade{0%{opacity:.5}50%{opacity:1}to{opacity:.5}}.wpl-placeholder__container{height:100px;position:relative;width:100%}.wpl-placeholder__loading{-webkit-animation:wpl-loading-fade 1.6s ease-in-out infinite;animation:wpl-loading-fade 1.6s ease-in-out infinite;background-color:#949494;bottom:16px;content:"";left:8px;padding-left:8px;padding-top:8px;position:absolute;right:8px;top:16px}.placeholder-inline{height:50px;position:relative;width:100%}.placeholder-inline .wpl-placeholder__loading{bottom:0;left:0;right:0;top:0}.loading-small{height:25px;width:25px}.tablenav-pages input.current-page{margin-left:2px;margin-right:2px;width:60px}.loader-wrapper{position:relative}.loader-textarea{height:100px}.wp-list-table .is-placeholder td{height:50px;position:relative}.wp-list-table .item-loading{opacity:.3}
12
+ .wpl-spinner__container{display:inline-block;position:relative}.wpl-spinner__item{-webkit-animation:wpl-scaleout 1s ease-in-out infinite;animation:wpl-scaleout 1s ease-in-out infinite;background-color:#1e1e1e;border-radius:100%;display:block;height:40px;left:10px;position:absolute;top:-25px;width:40px}@-webkit-keyframes wpl-scaleout{0%{-webkit-transform:scale(0)}to{opacity:0;-webkit-transform:scale(1)}}@keyframes wpl-scaleout{0%{transform:scale(0)}to{opacity:0;transform:scale(1)}}.spinner-small .wpl-spinner__item{height:20px;left:5px;top:-15px;width:20px}
13
+ .wpl-dropzone{border:3px dashed #bbb;border-radius:4px;box-sizing:border-box;color:#666;margin-bottom:10px;padding:10px 10px 15px;text-align:center;width:100%}.wpl-dropzone.wpl-dropzone__hover{border-color:#86bfd4}
14
+ .wpl-error{background:#fff;border-left:4px solid #dc3232;box-shadow:0 1px 1px 0 rgba(0,0,0,.1);margin:2em 0 15px;padding:1px 12px;width:97%}.wpl-error .closer{color:#333;cursor:pointer;float:right;font-size:18px;padding-top:5px}.wpl-error textarea{background-color:#eee;font-family:courier,Monaco,monospace;font-size:12px;width:100%}.wpl-error span code{background-color:transparent}.wpl-error h3{font-size:1.2em}.wpl-error ul{list-style-type:disc}.wpl-error ul li{margin-left:20px;padding:0}.wpl-error__mini h2{font-size:16px;font-weight:400}.wpl-error__mini h3{font-size:14px;font-weight:400}.wpl-error__highlight{background-color:#f7d85d;display:inline-block;margin:0;padding:3px 6px}.wpl-error__page{float:right;padding:5px}.wpl-error__page span{cursor:pointer;font-size:14px;padding-left:5px;padding-right:5px}
15
+ .inline-notice{background:#fff;border-left:4px solid #ffb900;box-shadow:0 1px 1px 0 rgba(0,0,0,.1);margin:5px 0 15px;padding:5px 12px}.inline-notice.inline-general{border-left-color:#46b450}.inline-error{border-color:#d94f4f}
16
+ .wpl-table th a{color:#444}.wpl-table td ul{list-style-type:disc;margin:15px 0 0;padding-left:20px}.wpl-table td li{line-height:1.6;margin-bottom:0}
17
+ .api-result-retry{clear:both;float:right}.api-result-log{background-color:#ddd;color:#111;margin:10px 0;padding:5px 10px;position:relative}.api-result-log .api-result-method_fail{background-color:#ff3860;color:#fff;margin-right:5px;padding:3px 5px}.api-result-log .api-result-method_pass{background-color:#4ab866;color:#fff;margin-right:5px;padding:3px 5px;width:150px}.api-result-log .dashicons{font-size:26px;height:26px;padding:0;vertical-align:middle;width:26px}.api-result-log .dashicons-no{color:#ff3860}.api-result-log .dashicons-yes{color:#4ab866}.api-result-log pre{background-color:#ccc;font-family:Courier New,Courier,monospace;padding:10px 15px}.api-result-log code{background-color:transparent}.api-result-log h4{font-size:14px;margin:5px 0 0}.api-result-log_details{display:flex}.api-result-log_details>div{width:95%}.api-result-log_details a{color:#111}.api-result-log_details a:hover{font-weight:700}.api-result-log_details pre{word-wrap:break-word;white-space:pre-wrap;white-space:-moz-pre-wrap;white-space:-pre-wrap;white-space:-o-pre-wrap}.api-result-hide{bottom:25px;position:absolute;right:5%}.api-result-select{position:absolute;right:10px;top:15px}.api-result-select span{background-color:#777;color:#fff;margin-left:10px;padding:5px 10px}.api-result-header{align-items:center;display:flex}.api-result-header .api-result-progress{margin:0 15px}.api-result-header .wpl-spinner__item{height:18px;top:-14px;width:18px}.api-result-header .api-result-status{background-color:#ddd;font-weight:700;left:0;padding:5px 10px;text-align:center;top:0}.api-result-header .api-result-status_good{background-color:#4ab866;color:#fff}.api-result-header .api-result-status_problem{background-color:#f7d85d}.api-result-header .api-result-status_failed{background-color:#ff3860;color:#fff}
18
+ .donation .donation-amount{float:left;margin-top:10px}.donation .donation-amount span{font-size:28px;margin-top:4px;vertical-align:bottom}.donation .donation-amount img{margin-bottom:-5px!important;width:24px!important}.donation .donation-amount:after{clear:both;content:"";display:block}.donation input[type=number]{margin-left:10px;width:60px}.donation td,.donation th{margin-bottom:0;padding-bottom:0}.donation input[type=submit]{margin-left:10px}.newsletter h3{margin-top:30px}
19
+ .github{margin-top:8px}.github a{text-decoration:none}.github img{margin-bottom:-10px;padding-right:10px}.searchregex-help ul{list-style:disc;margin-left:20px}
20
+ input.searchregex-integer-input{width:200px}
21
+ .react-datepicker-popper[data-placement^=bottom] .react-datepicker__triangle,.react-datepicker-popper[data-placement^=top] .react-datepicker__triangle,.react-datepicker__month-read-view--down-arrow,.react-datepicker__month-year-read-view--down-arrow,.react-datepicker__year-read-view--down-arrow{margin-left:-8px;position:absolute}.react-datepicker-popper[data-placement^=bottom] .react-datepicker__triangle,.react-datepicker-popper[data-placement^=bottom] .react-datepicker__triangle:before,.react-datepicker-popper[data-placement^=top] .react-datepicker__triangle,.react-datepicker-popper[data-placement^=top] .react-datepicker__triangle:before,.react-datepicker__month-read-view--down-arrow,.react-datepicker__month-read-view--down-arrow:before,.react-datepicker__month-year-read-view--down-arrow,.react-datepicker__month-year-read-view--down-arrow:before,.react-datepicker__year-read-view--down-arrow,.react-datepicker__year-read-view--down-arrow:before{border:8px solid transparent;box-sizing:content-box;height:0;position:absolute;width:1px}.react-datepicker-popper[data-placement^=bottom] .react-datepicker__triangle:before,.react-datepicker-popper[data-placement^=top] .react-datepicker__triangle:before,.react-datepicker__month-read-view--down-arrow:before,.react-datepicker__month-year-read-view--down-arrow:before,.react-datepicker__year-read-view--down-arrow:before{border-bottom-color:#aeaeae;border-width:8px;content:"";left:-8px;z-index:-1}.react-datepicker-popper[data-placement^=bottom] .react-datepicker__triangle{margin-top:-8px;top:0}.react-datepicker-popper[data-placement^=bottom] .react-datepicker__triangle,.react-datepicker-popper[data-placement^=bottom] .react-datepicker__triangle:before{border-bottom-color:#f0f0f0;border-top:none}.react-datepicker-popper[data-placement^=bottom] .react-datepicker__triangle:before{border-bottom-color:#aeaeae;top:-1px}.react-datepicker-popper[data-placement^=top] .react-datepicker__triangle,.react-datepicker__month-read-view--down-arrow,.react-datepicker__month-year-read-view--down-arrow,.react-datepicker__year-read-view--down-arrow{bottom:0;margin-bottom:-8px}.react-datepicker-popper[data-placement^=top] .react-datepicker__triangle,.react-datepicker-popper[data-placement^=top] .react-datepicker__triangle:before,.react-datepicker__month-read-view--down-arrow,.react-datepicker__month-read-view--down-arrow:before,.react-datepicker__month-year-read-view--down-arrow,.react-datepicker__month-year-read-view--down-arrow:before,.react-datepicker__year-read-view--down-arrow,.react-datepicker__year-read-view--down-arrow:before{border-bottom:none;border-top-color:#fff}.react-datepicker-popper[data-placement^=top] .react-datepicker__triangle:before,.react-datepicker__month-read-view--down-arrow:before,.react-datepicker__month-year-read-view--down-arrow:before,.react-datepicker__year-read-view--down-arrow:before{border-top-color:#aeaeae;bottom:-1px}.react-datepicker-wrapper{border:0;display:inline-block;padding:0}.react-datepicker{background-color:#fff;border:1px solid #aeaeae;border-radius:.3rem;color:#000;display:inline-block;font-family:Helvetica Neue,Helvetica,Arial,sans-serif;font-size:.8rem;position:relative}.react-datepicker--time-only .react-datepicker__triangle{left:35px}.react-datepicker--time-only .react-datepicker__time-container{border-left:0}.react-datepicker--time-only .react-datepicker__time,.react-datepicker--time-only .react-datepicker__time-box{border-bottom-left-radius:.3rem;border-bottom-right-radius:.3rem}.react-datepicker__triangle{left:50px;position:absolute}.react-datepicker-popper{z-index:1}.react-datepicker-popper[data-placement^=bottom]{margin-top:10px}.react-datepicker-popper[data-placement=bottom-end] .react-datepicker__triangle,.react-datepicker-popper[data-placement=top-end] .react-datepicker__triangle{left:auto;right:50px}.react-datepicker-popper[data-placement^=top]{margin-bottom:10px}.react-datepicker-popper[data-placement^=right]{margin-left:8px}.react-datepicker-popper[data-placement^=right] .react-datepicker__triangle{left:auto;right:42px}.react-datepicker-popper[data-placement^=left]{margin-right:8px}.react-datepicker-popper[data-placement^=left] .react-datepicker__triangle{left:42px;right:auto}.react-datepicker__header{background-color:#f0f0f0;border-bottom:1px solid #aeaeae;border-top-left-radius:.3rem;padding-top:8px;position:relative;text-align:center}.react-datepicker__header--time{padding-bottom:8px;padding-left:5px;padding-right:5px}.react-datepicker__header--time:not(.react-datepicker__header--time--only){border-top-left-radius:0}.react-datepicker__header:not(.react-datepicker__header--has-time-select){border-top-right-radius:.3rem}.react-datepicker__month-dropdown-container--scroll,.react-datepicker__month-dropdown-container--select,.react-datepicker__month-year-dropdown-container--scroll,.react-datepicker__month-year-dropdown-container--select,.react-datepicker__year-dropdown-container--scroll,.react-datepicker__year-dropdown-container--select{display:inline-block;margin:0 2px}.react-datepicker-time__header,.react-datepicker-year-header,.react-datepicker__current-month{color:#000;font-size:.944rem;font-weight:700;margin-top:0}.react-datepicker-time__header{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.react-datepicker__navigation{background:none;border:.45rem solid transparent;cursor:pointer;height:10px;line-height:1.7rem;overflow:hidden;padding:0;position:absolute;text-align:center;text-indent:-999em;top:10px;width:0;width:10px;z-index:1}.react-datepicker__navigation--previous{border-right-color:#ccc;left:10px}.react-datepicker__navigation--previous:hover{border-right-color:#b3b3b3}.react-datepicker__navigation--previous--disabled,.react-datepicker__navigation--previous--disabled:hover{border-right-color:#e6e6e6;cursor:default}.react-datepicker__navigation--next{border-left-color:#ccc;right:10px}.react-datepicker__navigation--next--with-time:not(.react-datepicker__navigation--next--with-today-button){right:95px}.react-datepicker__navigation--next:hover{border-left-color:#b3b3b3}.react-datepicker__navigation--next--disabled,.react-datepicker__navigation--next--disabled:hover{border-left-color:#e6e6e6;cursor:default}.react-datepicker__navigation--years{display:block;margin-left:auto;margin-right:auto;position:relative;top:0}.react-datepicker__navigation--years-previous{border-top-color:#ccc;top:4px}.react-datepicker__navigation--years-previous:hover{border-top-color:#b3b3b3}.react-datepicker__navigation--years-upcoming{border-bottom-color:#ccc;top:-4px}.react-datepicker__navigation--years-upcoming:hover{border-bottom-color:#b3b3b3}.react-datepicker__month-container{float:left}.react-datepicker__year{margin:.4rem;text-align:center}.react-datepicker__year-wrapper{display:flex;flex-wrap:wrap;max-width:180px}.react-datepicker__year .react-datepicker__year-text{display:inline-block;margin:2px;width:4rem}.react-datepicker__month{margin:.4rem;text-align:center}.react-datepicker__month .react-datepicker__month-text,.react-datepicker__month .react-datepicker__quarter-text{display:inline-block;margin:2px;width:4rem}.react-datepicker__input-time-container{clear:both;float:left;margin:5px 0 10px 15px;text-align:left;width:100%}.react-datepicker__input-time-container .react-datepicker-time__caption,.react-datepicker__input-time-container .react-datepicker-time__input-container{display:inline-block}.react-datepicker__input-time-container .react-datepicker-time__input-container .react-datepicker-time__input{display:inline-block;margin-left:10px}.react-datepicker__input-time-container .react-datepicker-time__input-container .react-datepicker-time__input input{width:85px}.react-datepicker__input-time-container .react-datepicker-time__input-container .react-datepicker-time__input input[type=time]::-webkit-inner-spin-button,.react-datepicker__input-time-container .react-datepicker-time__input-container .react-datepicker-time__input input[type=time]::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}.react-datepicker__input-time-container .react-datepicker-time__input-container .react-datepicker-time__input input[type=time]{-moz-appearance:textfield}.react-datepicker__input-time-container .react-datepicker-time__input-container .react-datepicker-time__delimiter{display:inline-block;margin-left:5px}.react-datepicker__time-container{border-left:1px solid #aeaeae;float:right;width:85px}.react-datepicker__time-container--with-today-button{border:1px solid #aeaeae;border-radius:.3rem;display:inline;position:absolute;right:-72px;top:0}.react-datepicker__time-container .react-datepicker__time{background:#fff;border-bottom-right-radius:.3rem;position:relative}.react-datepicker__time-container .react-datepicker__time .react-datepicker__time-box{border-bottom-right-radius:.3rem;margin:0 auto;overflow-x:hidden;text-align:center;width:85px}.react-datepicker__time-container .react-datepicker__time .react-datepicker__time-box ul.react-datepicker__time-list{box-sizing:content-box;height:calc(195px + .85rem);list-style:none;margin:0;overflow-y:scroll;padding-left:0;padding-right:0;width:100%}.react-datepicker__time-container .react-datepicker__time .react-datepicker__time-box ul.react-datepicker__time-list li.react-datepicker__time-list-item{height:30px;padding:5px 10px;white-space:nowrap}.react-datepicker__time-container .react-datepicker__time .react-datepicker__time-box ul.react-datepicker__time-list li.react-datepicker__time-list-item:hover{background-color:#f0f0f0;cursor:pointer}.react-datepicker__time-container .react-datepicker__time .react-datepicker__time-box ul.react-datepicker__time-list li.react-datepicker__time-list-item--selected{background-color:#216ba5;color:#fff;font-weight:700}.react-datepicker__time-container .react-datepicker__time .react-datepicker__time-box ul.react-datepicker__time-list li.react-datepicker__time-list-item--selected:hover{background-color:#216ba5}.react-datepicker__time-container .react-datepicker__time .react-datepicker__time-box ul.react-datepicker__time-list li.react-datepicker__time-list-item--disabled{color:#ccc}.react-datepicker__time-container .react-datepicker__time .react-datepicker__time-box ul.react-datepicker__time-list li.react-datepicker__time-list-item--disabled:hover{background-color:transparent;cursor:default}.react-datepicker__week-number{color:#ccc;display:inline-block;line-height:1.7rem;margin:.166rem;text-align:center;width:1.7rem}.react-datepicker__week-number.react-datepicker__week-number--clickable{cursor:pointer}.react-datepicker__week-number.react-datepicker__week-number--clickable:hover{background-color:#f0f0f0;border-radius:.3rem}.react-datepicker__day-names,.react-datepicker__week{white-space:nowrap}.react-datepicker__day,.react-datepicker__day-name,.react-datepicker__time-name{color:#000;display:inline-block;line-height:1.7rem;margin:.166rem;text-align:center;width:1.7rem}.react-datepicker__month--in-range,.react-datepicker__month--in-selecting-range,.react-datepicker__month--selected,.react-datepicker__quarter--in-range,.react-datepicker__quarter--in-selecting-range,.react-datepicker__quarter--selected{background-color:#216ba5;border-radius:.3rem;color:#fff}.react-datepicker__month--in-range:hover,.react-datepicker__month--in-selecting-range:hover,.react-datepicker__month--selected:hover,.react-datepicker__quarter--in-range:hover,.react-datepicker__quarter--in-selecting-range:hover,.react-datepicker__quarter--selected:hover{background-color:#1d5d90}.react-datepicker__month--disabled,.react-datepicker__quarter--disabled{color:#ccc;pointer-events:none}.react-datepicker__month--disabled:hover,.react-datepicker__quarter--disabled:hover{background-color:transparent;cursor:default}.react-datepicker__day,.react-datepicker__month-text,.react-datepicker__quarter-text,.react-datepicker__year-text{cursor:pointer}.react-datepicker__day:hover,.react-datepicker__month-text:hover,.react-datepicker__quarter-text:hover,.react-datepicker__year-text:hover{background-color:#f0f0f0;border-radius:.3rem}.react-datepicker__day--today,.react-datepicker__month-text--today,.react-datepicker__quarter-text--today,.react-datepicker__year-text--today{font-weight:700}.react-datepicker__day--highlighted,.react-datepicker__month-text--highlighted,.react-datepicker__quarter-text--highlighted,.react-datepicker__year-text--highlighted{background-color:#3dcc4a;border-radius:.3rem;color:#fff}.react-datepicker__day--highlighted:hover,.react-datepicker__month-text--highlighted:hover,.react-datepicker__quarter-text--highlighted:hover,.react-datepicker__year-text--highlighted:hover{background-color:#32be3f}.react-datepicker__day--highlighted-custom-1,.react-datepicker__month-text--highlighted-custom-1,.react-datepicker__quarter-text--highlighted-custom-1,.react-datepicker__year-text--highlighted-custom-1{color:#f0f}.react-datepicker__day--highlighted-custom-2,.react-datepicker__month-text--highlighted-custom-2,.react-datepicker__quarter-text--highlighted-custom-2,.react-datepicker__year-text--highlighted-custom-2{color:green}.react-datepicker__day--in-range,.react-datepicker__day--in-selecting-range,.react-datepicker__day--selected,.react-datepicker__month-text--in-range,.react-datepicker__month-text--in-selecting-range,.react-datepicker__month-text--selected,.react-datepicker__quarter-text--in-range,.react-datepicker__quarter-text--in-selecting-range,.react-datepicker__quarter-text--selected,.react-datepicker__year-text--in-range,.react-datepicker__year-text--in-selecting-range,.react-datepicker__year-text--selected{background-color:#216ba5;border-radius:.3rem;color:#fff}.react-datepicker__day--in-range:hover,.react-datepicker__day--in-selecting-range:hover,.react-datepicker__day--selected:hover,.react-datepicker__month-text--in-range:hover,.react-datepicker__month-text--in-selecting-range:hover,.react-datepicker__month-text--selected:hover,.react-datepicker__quarter-text--in-range:hover,.react-datepicker__quarter-text--in-selecting-range:hover,.react-datepicker__quarter-text--selected:hover,.react-datepicker__year-text--in-range:hover,.react-datepicker__year-text--in-selecting-range:hover,.react-datepicker__year-text--selected:hover{background-color:#1d5d90}.react-datepicker__day--keyboard-selected,.react-datepicker__month-text--keyboard-selected,.react-datepicker__quarter-text--keyboard-selected,.react-datepicker__year-text--keyboard-selected{background-color:#2a87d0;border-radius:.3rem;color:#fff}.react-datepicker__day--keyboard-selected:hover,.react-datepicker__month-text--keyboard-selected:hover,.react-datepicker__quarter-text--keyboard-selected:hover,.react-datepicker__year-text--keyboard-selected:hover{background-color:#1d5d90}.react-datepicker__day--in-selecting-range,.react-datepicker__month-text--in-selecting-range,.react-datepicker__quarter-text--in-selecting-range,.react-datepicker__year-text--in-selecting-range{background-color:rgba(33,107,165,.5)}.react-datepicker__month--selecting-range .react-datepicker__day--in-range,.react-datepicker__month--selecting-range .react-datepicker__month-text--in-range,.react-datepicker__month--selecting-range .react-datepicker__quarter-text--in-range,.react-datepicker__month--selecting-range .react-datepicker__year-text--in-range{background-color:#f0f0f0;color:#000}.react-datepicker__day--disabled,.react-datepicker__month-text--disabled,.react-datepicker__quarter-text--disabled,.react-datepicker__year-text--disabled{color:#ccc;cursor:default}.react-datepicker__day--disabled:hover,.react-datepicker__month-text--disabled:hover,.react-datepicker__quarter-text--disabled:hover,.react-datepicker__year-text--disabled:hover{background-color:transparent}.react-datepicker__month-text.react-datepicker__month--in-range:hover,.react-datepicker__month-text.react-datepicker__month--selected:hover,.react-datepicker__month-text.react-datepicker__quarter--in-range:hover,.react-datepicker__month-text.react-datepicker__quarter--selected:hover,.react-datepicker__quarter-text.react-datepicker__month--in-range:hover,.react-datepicker__quarter-text.react-datepicker__month--selected:hover,.react-datepicker__quarter-text.react-datepicker__quarter--in-range:hover,.react-datepicker__quarter-text.react-datepicker__quarter--selected:hover{background-color:#216ba5}.react-datepicker__month-text:hover,.react-datepicker__quarter-text:hover{background-color:#f0f0f0}.react-datepicker__input-container{display:inline-block;position:relative;width:100%}.react-datepicker__month-read-view,.react-datepicker__month-year-read-view,.react-datepicker__year-read-view{border:1px solid transparent;border-radius:.3rem}.react-datepicker__month-read-view:hover,.react-datepicker__month-year-read-view:hover,.react-datepicker__year-read-view:hover{cursor:pointer}.react-datepicker__month-read-view:hover .react-datepicker__month-read-view--down-arrow,.react-datepicker__month-read-view:hover .react-datepicker__year-read-view--down-arrow,.react-datepicker__month-year-read-view:hover .react-datepicker__month-read-view--down-arrow,.react-datepicker__month-year-read-view:hover .react-datepicker__year-read-view--down-arrow,.react-datepicker__year-read-view:hover .react-datepicker__month-read-view--down-arrow,.react-datepicker__year-read-view:hover .react-datepicker__year-read-view--down-arrow{border-top-color:#b3b3b3}.react-datepicker__month-read-view--down-arrow,.react-datepicker__month-year-read-view--down-arrow,.react-datepicker__year-read-view--down-arrow{border-top-color:#ccc;border-width:.45rem;float:right;margin-left:20px;position:relative;top:8px}.react-datepicker__month-dropdown,.react-datepicker__month-year-dropdown,.react-datepicker__year-dropdown{background-color:#f0f0f0;border:1px solid #aeaeae;border-radius:.3rem;left:25%;position:absolute;text-align:center;top:30px;width:50%;z-index:1}.react-datepicker__month-dropdown:hover,.react-datepicker__month-year-dropdown:hover,.react-datepicker__year-dropdown:hover{cursor:pointer}.react-datepicker__month-dropdown--scrollable,.react-datepicker__month-year-dropdown--scrollable,.react-datepicker__year-dropdown--scrollable{height:150px;overflow-y:scroll}.react-datepicker__month-option,.react-datepicker__month-year-option,.react-datepicker__year-option{display:block;line-height:20px;margin-left:auto;margin-right:auto;width:100%}.react-datepicker__month-option:first-of-type,.react-datepicker__month-year-option:first-of-type,.react-datepicker__year-option:first-of-type{border-top-left-radius:.3rem;border-top-right-radius:.3rem}.react-datepicker__month-option:last-of-type,.react-datepicker__month-year-option:last-of-type,.react-datepicker__year-option:last-of-type{border-bottom-left-radius:.3rem;border-bottom-right-radius:.3rem;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-datepicker__month-option:hover,.react-datepicker__month-year-option:hover,.react-datepicker__year-option:hover{background-color:#ccc}.react-datepicker__month-option:hover .react-datepicker__navigation--years-upcoming,.react-datepicker__month-year-option:hover .react-datepicker__navigation--years-upcoming,.react-datepicker__year-option:hover .react-datepicker__navigation--years-upcoming{border-bottom-color:#b3b3b3}.react-datepicker__month-option:hover .react-datepicker__navigation--years-previous,.react-datepicker__month-year-option:hover .react-datepicker__navigation--years-previous,.react-datepicker__year-option:hover .react-datepicker__navigation--years-previous{border-top-color:#b3b3b3}.react-datepicker__month-option--selected,.react-datepicker__month-year-option--selected,.react-datepicker__year-option--selected{left:15px;position:absolute}.react-datepicker__close-icon{background-color:transparent;border:0;cursor:pointer;display:table-cell;height:100%;outline:0;padding:0 6px 0 0;position:absolute;right:0;top:0;vertical-align:middle}.react-datepicker__close-icon:after{background-color:#216ba5;border-radius:50%;color:#fff;content:"×";cursor:pointer;display:table-cell;font-size:12px;height:16px;line-height:1;padding:2px;text-align:center;vertical-align:middle;width:16px}.react-datepicker__today-button{background:#f0f0f0;border-top:1px solid #aeaeae;clear:left;cursor:pointer;font-weight:700;padding:5px 0;text-align:center}.react-datepicker__portal{align-items:center;background-color:rgba(0,0,0,.8);display:flex;height:100vh;justify-content:center;left:0;position:fixed;top:0;width:100vw;z-index:2147483647}.react-datepicker__portal .react-datepicker__day,.react-datepicker__portal .react-datepicker__day-name,.react-datepicker__portal .react-datepicker__time-name{line-height:3rem;width:3rem}@media(max-height:550px),(max-width:400px){.react-datepicker__portal .react-datepicker__day,.react-datepicker__portal .react-datepicker__day-name,.react-datepicker__portal .react-datepicker__time-name{line-height:2rem;width:2rem}}.react-datepicker__portal .react-datepicker-time__header,.react-datepicker__portal .react-datepicker__current-month{font-size:1.44rem}.react-datepicker__portal .react-datepicker__navigation{border:.81rem solid transparent}.react-datepicker__portal .react-datepicker__navigation--previous{border-right-color:#ccc}.react-datepicker__portal .react-datepicker__navigation--previous:hover{border-right-color:#b3b3b3}.react-datepicker__portal .react-datepicker__navigation--previous--disabled,.react-datepicker__portal .react-datepicker__navigation--previous--disabled:hover{border-right-color:#e6e6e6;cursor:default}.react-datepicker__portal .react-datepicker__navigation--next{border-left-color:#ccc}.react-datepicker__portal .react-datepicker__navigation--next:hover{border-left-color:#b3b3b3}.react-datepicker__portal .react-datepicker__navigation--next--disabled,.react-datepicker__portal .react-datepicker__navigation--next--disabled:hover{border-left-color:#e6e6e6;cursor:default}
22
+ .searchregex-filter{align-items:center;display:flex;padding:8px 0}.searchregex-filter span{margin-right:10px}.searchregex-filters>.wpl-badge{margin-bottom:10px;margin-top:10px}.searchregex-filter__column{align-items:center;display:flex;justify-content:flex-start;position:relative}.searchregex-filter__column .searchregex-filter__type__integer{align-items:center}.searchregex-filter__column .searchregex-filter__type__integer .searchregex-integer-input input{width:100%}.searchregex-filter__name{align-items:center;display:flex;font-weight:700;margin-right:20px;min-width:180px}.searchregex-filter__name .dashicons{cursor:pointer}.searchregex-filter__item{align-items:flex-start;display:flex;margin-left:20px}.searchregex-filter__item p{margin:0}.searchregex-filter__item .dashicons-trash{cursor:pointer;margin-left:5px;margin-right:3px;padding-top:3px}.searchregex-filter__item input,.searchregex-filter__item select,.searchregex-filter__item textarea{margin-left:5px;margin-right:5px}.searchregex-filter__item select:first-child{margin-left:0}.searchregex-filter__item textarea{height:75px;width:100%}.searchregex-filter__item.searchregex-filter__type__integer input{width:100px}.searchregex-filter__content,.searchregex-filter__content .wpl-dropdowntext{width:100%}.searchregex-filter__content__multiple>.wpl-badge{margin:10px 21px}.searchregex-filter__content__multiple:before{background-color:#333;content:"";display:block;height:100%;position:absolute;top:0;width:3px}.searchregex-filter__type__date input{width:200px}.searchregex-filters__break:not(:last-child){height:30px}.searchregex-filter__keyvalue{width:100%}.searchregex-filter__keyvalue span{margin-top:2px;min-width:80px}.searchregex-filter__keyvalue__item{align-items:center;display:flex;margin-bottom:5px}.searchregex-filter__keyvalue__item .wpl-popover__toggle:last-child{margin-right:8px}.dashicons__disabled{cursor:inherit!important;opacity:.5}
23
+ .searchregex-modify{align-items:baseline;display:flex;margin-bottom:5px}.searchregex-modify .wpl-dropdowntext,.searchregex-modify input[type=text],.searchregex-modify select,.searchregex-modify textarea{margin-left:8px;margin-right:8px}.searchregex-modify .wpl-dropdowntext:last-child,.searchregex-modify input[type=text]:last-child,.searchregex-modify select:last-child,.searchregex-modify textarea:last-child{margin-bottom:0;margin-right:0}.searchregex-modify .wpl-dropdowntext>input[type=text]{margin-left:0;margin-right:0}.searchregex-modify .wpl-dropdowntext:last-of-type input[type=text]{margin-right:0}.searchregex-modify:first-child{margin-left:0}.searchregex-modify input[type=number]{width:100px}.searchregex-modify textarea{height:75px;width:100%}.searchregex-modify .wpl-dropdowntext{width:100%}.searchregex-modify .wpl-badge:not(:first-of-type){margin-left:5px}.searchregex-modify.searchregex-modify__keyvalue{display:block}.searchregex-modify.searchregex-modify__keyvalue .searchregex-filter__keyvalue__item{margin-bottom:5px}.searchregex-modify.searchregex-modify__keyvalue .searchregex-filter__keyvalue__item span:first-of-type{min-width:100px}.searchregex-modify.searchregex-modify__keyvalue .searchregex-filter__keyvalue__item .wpl-popover__toggle{margin-left:5px;margin-right:0}.searchregex-modify.searchregex-modify__keyvalue .searchregex-filter__keyvalue__item .dashicons{cursor:pointer;margin-left:5px}.searchregex-modify.searchregex-modify__keyvalue .searchregex-filter__keyvalue__item__value{align-items:baseline;margin-bottom:15px}.searchregex-modify.searchregex-modify__keyvalue textarea{margin-left:0}.searchregex-modify.searchregex-modify__keyvalue button,.searchregex-modify.searchregex-modify__keyvalue input[type=checkbox]{margin-left:5px}.searchregex-modify.searchregex-modify__string{display:inherit}.searchregex-modify.searchregex-modify__string textarea{height:200px}.searchregex-modify.searchregex-modify__string .searchregex-modify__string__row{align-items:flex-start;display:flex;margin-bottom:5px}.searchregex-modify__name{align-items:center;display:flex;font-weight:700;margin-right:20px;min-width:120px}.searchregex-modify__name .dashicons{cursor:pointer}
24
+ .searchregex-replace__modal .wpl-table{width:100%}.searchregex-replace__modal .wpl-table .searchregex-preset__tag th{text-align:left;vertical-align:inherit}.wpl-popover__content .searchregex-replace__action{align-items:center;display:flex;justify-content:space-between;margin-left:8px;margin-top:10px}.wpl-popover__content .searchregex-replace__action p{margin:0}.searchregex-replace__modal{font-weight:400;padding:13px;width:550px}.searchregex-replace__modal .searchregex-replace__action{justify-content:flex-end;margin-bottom:0}.searchregex-replace__modal .searchregex-replace__action input{margin-left:10px}.searchregex-replace__modal h5{font-size:14px;font-weight:700;margin:0 0 7px}.searchregex-replace__modal .wpl-badge:first-of-type{margin-left:0}.searchregex-replace__modal textarea{margin-left:0;max-width:100%;width:100%}.searchregex-replace__modal .searchregex-modify .wpl-badge{margin-bottom:5px}.searchregex-replace__modal input[type=text]{margin-left:0;width:100%}.searchregex-replace__modal .wpl-dropdowntext__suggestion{flex-wrap:wrap}.searchregex-replace__modal .wpl-dropdowntext__suggestion input[type=text]{margin-left:0}.searchregex-replace__modal .searchregex-list__encoded{color:#d94f4f;display:flex;justify-content:flex-end;margin-bottom:10px!important;margin-top:-10px}
25
+ .searchregex-search__action td{align-items:center;display:flex}.searchregex-search__action span{margin-left:8px;margin-right:8px}.searchregex-search__action select.searchregex-search__action__type{margin-right:10px}.searchregex-search__action .searchregex-search__action__modify{margin-left:10px;margin-right:10px}.searchregex-search__export input[type=text]{margin-right:10px;width:300px}
26
+ .searchregex-presets{margin-top:20px}.searchregex-presets .searchregex-preset__flags,.searchregex-presets .searchregex-preset__name{width:200px}.searchregex-presets table{padding:5px;width:100%}.searchregex-presets table h2{margin-bottom:5px;margin-top:0}.searchregex-presets table td,.searchregex-presets table th{padding:2px 0}.searchregex-presets table th{padding-top:8px;vertical-align:top;width:150px}.searchregex-presets table .searchregex-search__advanced__title td{padding-top:20px}.searchregex-presets table input[type=submit]{margin-right:10px}.searchregex-presets table p:not(:first-child){padding-top:4px}.searchregex-search__advanced input[type=text]{margin-left:5px;margin-right:10px;min-width:300px}.searchregex-preset__saving{opacity:.5}.searchregex-preset__tag th{vertical-align:top}.searchregex-preset__tag p{margin:1px 0}.searchregex-preset__tag input[type=text]{width:100%}.searchregex-presetactions{margin-bottom:20px;margin-top:20px}.searchregex-presetactions button.button{margin-right:10px}.searchregex-presetimport textarea{width:100%}
27
+ .searchregex-saved{display:flex}.wpl-modal_wrapper-padding .wpl-modal_content.searchregex-preset__name{padding:15px 20px}.searchregex-preset__name form{display:flex;justify-content:space-between}.searchregex-preset__name form input[type=text]{width:100%}.searchregex-preset__name form button.button,.searchregex-preset__name form input[type=submit]{margin-left:5px}
28
+ .searchregex-result__deleted,.searchregex-result__highlight,.searchregex-result__replaced{background-color:#f7d85d;cursor:pointer;display:inline;font-weight:700;padding:3px}.searchregex-result__replaced{background-color:#f38830}.searchregex-result__deleted{background-color:#e53e3e;color:#fff;font-weight:400;text-decoration:line-through}.searchregex-match{align-items:baseline;display:flex;justify-content:flex-start;line-height:2}.searchregex-match .searchregex-match__column{align-items:center;background-color:#ddd;border-radius:3px;display:flex;font-weight:700;margin-bottom:5px;margin-right:10px;padding:0 5px}.searchregex-match .searchregex-match__column__type{border-left:2px solid #999;display:inline-block;font-size:10px;margin-left:5px;padding-left:5px}.searchregex-match .wpl-badge,.searchregex-match span:not(.searchregex-result__highlight){margin-right:5px}
29
+ .searchregex-result__more{font-style:italic;margin-bottom:15px;margin-left:15px;margin-top:15px}.searchregex-result__updating{-webkit-animation:loading-fade 1.6s ease-in-out infinite;animation:loading-fade 1.6s ease-in-out infinite}.searchregex-result__updating .wpl-spinner__item{height:24px;margin-top:10px;width:24px}.searchregex-result h2{font-size:1.2em;font-weight:400;margin:0 0 10px;padding:0}.searchregex-match__column{cursor:pointer}.searchregex-match__column__disabled{cursor:auto}.searchregex-replace__inline{margin-bottom:10px;margin-top:5px}.searchregex-replace__inline .searchregex-match__column{visibility:hidden}.searchregex-replace__inline .searchregex-replace__action{margin-left:10px}.searchregex-replace__inline p.searchregex-replace__actions{margin-bottom:10px}.searchregex-replace__inline p.searchregex-replace__actions input[type=button]{margin-left:10px}.searchregex-replace__inline form{align-items:baseline;display:flex;justify-content:flex-start}.searchregex-replace__inline select{margin-left:0}.searchregex-replace__inline input[type=text]{margin-left:0;min-width:200px}.searchregex-list-replace{align-items:center;display:flex}.searchregex-list-replace .wpl-badge{margin-bottom:0;margin-top:0}.searchregex-list-replace .wpl-badge,.searchregex-list-replace .wpl-badge__content{overflow-wrap:break-word;text-overflow:ellipsis}.searchregex-list-replace span{margin-right:5px}.searchregex-list-replace .searchregex-list-replace__break{flex-basis:100%;padding-bottom:5px;padding-top:5px;text-align:left}.searchregex-list-replace__vertical{flex-wrap:wrap}.searchregex-list__novalue{font-style:italic}.searchregex-list__more{margin-left:10px!important}.widefat td .searchregex-match__list p{margin:0!important;padding:0!important}.searchregex-match__list{align-items:flex-start;margin-bottom:2px;margin-top:2px}.searchregex-match__list .wpl-badge{margin-bottom:0;margin-top:0;min-height:inherit}.searchregex-match__list span{overflow-wrap:anywhere}.searchregex-match__contexts{list-style-type:square;margin-bottom:0;margin-left:30px;margin-top:0}.searchregex-match__contexts li{line-height:1.9;margin-bottom:8px;margin-top:8px}.searchregex-match__contexts li>div{margin-bottom:0;margin-top:0;min-height:inherit}.searchregex-match__contexts .wpl-badge{background-color:#ddd;color:#555;font-size:12px}.searchregex-match__contexts li:first-of-type{margin-top:0}.searchregex-match__contexts .searchregex-list__match,.searchregex-match__list .searchregex-list__match{background-color:#f7d85d}.searchregex-match__contexts .searchregex-list__match.wpl-badge,.searchregex-match__list .searchregex-list__match.wpl-badge{margin-bottom:2px;margin-top:1px}td.searchregex-result__match>p{margin-left:30px}.searchregex-list__replace{background-color:#f38830;margin-right:0}.searchregex-list__warning{background-color:#f0b849}.searchregex-list__key{display:inline-block;font-family:monospace;margin-right:5px}.searchregex-list__value{display:inline;margin-left:5px;margin-right:0}.searchregex-list__string{margin-right:5px}.searchregex-list__string span{background-color:#f7d85d;font-weight:700;margin-right:0;padding:2px 3px}.searchregex-result__match .searchregex-list__add{background-color:#4ab866;color:#fff;margin-right:0}.searchregex-result__match .searchregex-list__delete{background-color:#d94f4f;color:#fff;margin-right:0;text-decoration:line-through}
30
+ .tablenav-pages{justify-content:space-between;padding:10px}.pagination-links,.tablenav-pages{align-items:center;display:flex}.pagination-links .button{margin:0 2px}.pagination-links .paging-input{margin:0 4px}.pagination-links .tablenav-paging-text{margin:0 5px}.searchregex-resultsdirty{background-color:#f0b849;border-radius:3px;display:inline-block;font-weight:700;padding:5px 8px}
31
+ .searchregex-result__table{width:100px}.searchregex-result__row{width:75px}.searchregex-result__matches{width:70px}.searchregex-result__column{width:100px}.searchregex-result__action{width:250px}.searchregex-result__action__dropdown.searchregex-result__action{width:50px}
32
+ .searchregex-replaceall{background-color:#fff;border:1px solid #ddd;border-radius:5px;box-shadow:0 1px 1px 0 rgba(0,0,0,.1);margin:50px auto 0;max-width:600px;padding:15px}.searchregex-replaceall svg{border-radius:3px;min-height:40px}.searchregex-replaceall h3{margin-top:0}.searchregex-replaceall__progress{align-items:center;display:flex;position:relative}.searchregex-replaceall__status{font-size:16px;font-weight:700;left:0;margin-top:-2px;position:absolute;text-align:center;width:100%}.searchregex-replaceall__container,.searchregex-replaceall__container svg{width:100%}.searchregex-replaceall__stats{text-align:center}.searchregex-replaceall__stats .wp-core-ui .button-primary{margin-top:20px}.rc-progress-line-path{transition:stroke-dashoffset 0s ease 0s,stroke-dasharray 1s ease .5s,stroke .5s linear!important}
33
+ .searchregex-loading{-webkit-animation:loading-fade 1.6s ease-in-out infinite;animation:loading-fade 1.6s ease-in-out infinite;opacity:.8}.searchregex-search table{table-layout:fixed;width:100%}.searchregex-search th{padding-top:5px;text-align:left;vertical-align:top;width:80px}.searchregex-search td{width:100%}.searchregex-search .inline-error{margin-top:20px}.searchregex-search__results td{align-items:center;display:flex}.searchregex-search__results td select{margin-right:5px}.searchregex-search__replace,.searchregex-search__search,.searchregex-search__source{margin-bottom:10px;width:100%}.searchregex-search__replace td,.searchregex-search__search td,.searchregex-search__source td{align-items:flex-start;display:flex;justify-content:flex-start}.searchregex-search__replace input[type=text],.searchregex-search__replace textarea,.searchregex-search__search input[type=text],.searchregex-search__search textarea,.searchregex-search__source input[type=text],.searchregex-search__source textarea{width:100%}.searchregex-search__replace .wpl-popover__toggle,.searchregex-search__replace select,.searchregex-search__search .wpl-popover__toggle,.searchregex-search__search select,.searchregex-search__source .wpl-popover__toggle,.searchregex-search__source select{margin-left:5px}.searchregex-search__replace textarea,.searchregex-search__search textarea,.searchregex-search__source textarea{margin-left:1px;min-height:30px;padding:4px 8px}.searchregex-search__replace>label,.searchregex-search__search>label,.searchregex-search__source>label{font-weight:700;width:60px}.searchregex-search__replace .wpl-popover__toggle,.searchregex-search__search .wpl-popover__toggle,.searchregex-search__source .wpl-popover__toggle{margin-left:1px;margin-right:5px}.searchregex-search__replace .wpl-popover__toggle button,.searchregex-search__search .wpl-popover__toggle button,.searchregex-search__source .wpl-popover__toggle button{margin-right:2px;min-width:200px}.searchregex-search__replace select,.searchregex-search__search select,.searchregex-search__source select{margin-right:0;min-width:150px}.searchregex-search__replace span,.searchregex-search__search span,.searchregex-search__source span{margin-left:10px;margin-right:5px}.searchregex-search__replace .wpl-badge.wpl-badge__small .wpl-badge__content,.searchregex-search__search .wpl-badge.wpl-badge__small .wpl-badge__content,.searchregex-search__source .wpl-badge.wpl-badge__small .wpl-badge__content{max-width:150px}.searchregex-search__search .wpl-popover__toggle{margin-left:5px;margin-right:0}.searchregex-search__source select{margin-right:10px}.searchregex-search__source td{align-items:center;display:flex}.searchregex-search__source__description{margin-left:5px}.searchregex-search__action{margin-top:10px}.searchregex-search__action button[type=submit]{margin-right:10px}.searchregex-search__action .wpl-spinner__item{height:28px;margin-top:10px;width:28px}.searchregex-search__tag__medium th{width:130px}.searchregex-search__tag__long th{width:200px}.searchregex-preset__description{font-size:14px;font-weight:400;margin-bottom:5px;margin-left:2px;margin-top:20px}
34
+ .wp-core-ui .button-delete{color:#fff}.wp-core-ui .button-delete,.wp-core-ui .button-delete:hover{background-color:#ff3860;border-color:transparent;box-shadow:none;text-shadow:none}.addTop{margin-top:20px}@media screen and (max-width:782px){.newsletter form input[type=email]{display:block;margin:5px 0;width:100%}.import select{margin:5px 0;width:100%}.plugin-importer button{width:100%}}.module-export{background-color:#fff!important;border:1px solid #ddd;font-family:courier,Monaco,monospace;margin-top:15px;padding:5px;width:100%}.redirect-edit .table-actions{align-items:center;display:flex;justify-content:flex-start;margin-left:1px;margin-top:2px}.redirect-edit .table-actions .redirection-edit_advanced{font-size:16px;text-decoration:none}.redirect-edit .table-actions .redirection-edit_advanced svg{padding-top:2px}.error{padding-bottom:10px!important}.notice{display:block!important}.database-switch{float:right}.database-switch a{color:#444;text-decoration:none}.database-switch a:hover{text-decoration:underline}
35
+ .react-error h1,.react-loading h1{color:#999;margin-top:150px;text-align:center}.react-loading{height:100%;position:absolute;width:100%}.react-loading-spinner{-webkit-animation:sk-scaleout-loading 1s ease-in-out infinite;animation:sk-scaleout-loading 1s ease-in-out infinite;background-color:#333;border-radius:100%;height:120px;left:50%;margin-left:-65px;position:absolute;width:120px}.react-error p{line-height:1;text-align:center}.react-error pre{border:1px solid #aaa}.react-error pre,p.versions{background-color:#fff;margin:0 auto;padding:10px;width:600px}p.versions{border:1px solid #ddd;color:#666;font-size:12px;line-height:1.6;text-align:left}@-webkit-keyframes sk-scaleout-loading{0%{-webkit-transform:scale(0)}to{opacity:0;-webkit-transform:scale(1)}}@keyframes sk-scaleout-loading{0%{transform:scale(0)}to{opacity:0;transform:scale(1)}}
build/search-regex.js ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ /*! Search Regex v3.0.0 - please refer to license.txt for license information */
2
+ (()=>{var e,t={7447:(e,t,n)=>{"use strict";var r=n(7418),a=60103;t.Fragment=60107;if("function"==typeof Symbol&&Symbol.for){var o=Symbol.for;a=o("react.element"),o("react.portal"),t.Fragment=o("react.fragment"),o("react.strict_mode"),o("react.profiler"),o("react.provider"),o("react.context"),o("react.forward_ref"),o("react.suspense"),o("react.memo"),o("react.lazy")}"function"==typeof Symbol&&Symbol.iterator;function l(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n]);return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var i={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},u={};function s(e,t,n){this.props=e,this.context=t,this.refs=u,this.updater=n||i}function c(){}function p(e,t,n){this.props=e,this.context=t,this.refs=u,this.updater=n||i}s.prototype.isReactComponent={},s.prototype.setState=function(e,t){if("object"!=typeof e&&"function"!=typeof e&&null!=e)throw Error(l(85));this.updater.enqueueSetState(this,e,t,"setState")},s.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},c.prototype=s.prototype;var d=p.prototype=new c;d.constructor=p,r(d,s.prototype),d.isPureReactComponent=!0;var f=null,h=Object.prototype.hasOwnProperty,m={key:!0,ref:!0,__self:!0,__source:!0};function g(e){return"object"==typeof e&&null!==e&&e.$$typeof===a}t.cloneElement=function(e,t,n){if(null==e)throw Error(l(267,e));var o=r({},e.props),i=e.key,u=e.ref,s=e._owner;if(null!=t){if(void 0!==t.ref&&(u=t.ref,s=f),void 0!==t.key&&(i=""+t.key),e.type&&e.type.defaultProps)var c=e.type.defaultProps;for(p in t)h.call(t,p)&&!m.hasOwnProperty(p)&&(o[p]=void 0===t[p]&&void 0!==c?c[p]:t[p])}var p=arguments.length-2;if(1===p)o.children=n;else if(1<p){c=Array(p);for(var d=0;d<p;d++)c[d]=arguments[d+2];o.children=c}return{$$typeof:a,type:e.type,key:i,ref:u,props:o,_owner:s}},t.createElement=function(e,t,n){var r,o={},l=null,i=null;if(null!=t)for(r in void 0!==t.ref&&(i=t.ref),void 0!==t.key&&(l=""+t.key),t)h.call(t,r)&&!m.hasOwnProperty(r)&&(o[r]=t[r]);var u=arguments.length-2;if(1===u)o.children=n;else if(1<u){for(var s=Array(u),c=0;c<u;c++)s[c]=arguments[c+2];o.children=s}if(e&&e.defaultProps)for(r in u=e.defaultProps)void 0===o[r]&&(o[r]=u[r]);return{$$typeof:a,type:e,key:l,ref:i,props:o,_owner:f}},t.isValidElement=g},7200:(e,t,n)=>{"use strict";e.exports=n(7447)},8363:(e,t)=>{"use strict";t.Z=function(e,t){if(e&&t){var n=Array.isArray(t)?t:t.split(","),r=e.name||"",a=(e.type||"").toLowerCase(),o=a.replace(/\/.*$/,"");return n.some((function(e){var t=e.trim().toLowerCase();return"."===t.charAt(0)?r.toLowerCase().endsWith(t):t.endsWith("/*")?o===t.replace(/\/.*$/,""):a===t}))}return!0}},2598:(e,t,n)=>{"use strict";var r=n(7200),a=n(745),o=n(9198),l=n.n(o),i=n(7294),u=n(1688),s=n(2798),c=n(3935);let p=function(e){e()};const d=()=>p,f=i.createContext(null);function h(){return(0,i.useContext)(f)}const m=()=>{throw new Error("uSES not initialized!")};let g=m;const y=(e,t)=>e===t;function v(e=f){const t=e===f?h:()=>(0,i.useContext)(e);return function(e,n=y){const{store:r,subscription:a,getServerState:o}=t(),l=g(a.addNestedSub,r.getState,o||r.getState,e,n);return(0,i.useDebugValue)(l),l}}const b=v();function w(){return w=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},w.apply(this,arguments)}function E(e,t){if(null==e)return{};var n,r,a={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(a[n]=e[n]);return a}var _=n(8679),x=n.n(_),S=n(2973);const k=["initMapStateToProps","initMapDispatchToProps","initMergeProps"];function C(e,t,n,r,{areStatesEqual:a,areOwnPropsEqual:o,areStatePropsEqual:l}){let i,u,s,c,p,d=!1;return function(f,h){return d?function(d,f){const h=!o(f,u),m=!a(d,i);return i=d,u=f,h&&m?(s=e(i,u),t.dependsOnOwnProps&&(c=t(r,u)),p=n(s,c,u),p):h?(e.dependsOnOwnProps&&(s=e(i,u)),t.dependsOnOwnProps&&(c=t(r,u)),p=n(s,c,u),p):m?function(){const t=e(i,u),r=!l(t,s);return s=t,r&&(p=n(s,c,u)),p}():p}(f,h):(i=f,u=h,s=e(i,u),c=t(r,u),p=n(s,c,u),d=!0,p)}}function D(e){return function(t){const n=e(t);function r(){return n}return r.dependsOnOwnProps=!1,r}}function O(e){return e.dependsOnOwnProps?Boolean(e.dependsOnOwnProps):1!==e.length}function P(e,t){return function(t,{displayName:n}){const r=function(e,t){return r.dependsOnOwnProps?r.mapToProps(e,t):r.mapToProps(e,void 0)};return r.dependsOnOwnProps=!0,r.mapToProps=function(t,n){r.mapToProps=e,r.dependsOnOwnProps=O(e);let a=r(t,n);return"function"==typeof a&&(r.mapToProps=a,r.dependsOnOwnProps=O(a),a=r(t,n)),a},r}}function T(e,t){return(n,r)=>{throw new Error(`Invalid value of type ${typeof e} for ${t} argument when connecting component ${r.wrappedComponentName}.`)}}function N(e,t,n){return w({},n,e,t)}const M={notify(){},get:()=>[]};function R(e,t){let n,r=M;function a(){l.onStateChange&&l.onStateChange()}function o(){n||(n=t?t.addNestedSub(a):e.subscribe(a),r=function(){const e=d();let t=null,n=null;return{clear(){t=null,n=null},notify(){e((()=>{let e=t;for(;e;)e.callback(),e=e.next}))},get(){let e=[],n=t;for(;n;)e.push(n),n=n.next;return e},subscribe(e){let r=!0,a=n={callback:e,next:null,prev:n};return a.prev?a.prev.next=a:t=a,function(){r&&null!==t&&(r=!1,a.next?a.next.prev=a.prev:n=a.prev,a.prev?a.prev.next=a.next:t=a.next)}}}}())}const l={addNestedSub:function(e){return o(),r.subscribe(e)},notifyNestedSubs:function(){r.notify()},handleChangeWrapper:a,isSubscribed:function(){return Boolean(n)},trySubscribe:o,tryUnsubscribe:function(){n&&(n(),n=void 0,r.clear(),r=M)},getListeners:()=>r};return l}const j="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?i.useLayoutEffect:i.useEffect;function A(e,t){return e===t?0!==e||0!==t||1/e==1/t:e!=e&&t!=t}function I(e,t){if(A(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r=0;r<n.length;r++)if(!Object.prototype.hasOwnProperty.call(t,n[r])||!A(e[n[r]],t[n[r]]))return!1;return!0}const F=["reactReduxForwardedRef"];let L=m;const U=[null,null];function z(e,t,n,r,a,o){e.current=r,n.current=!1,a.current&&(a.current=null,o())}function Y(e,t){return e===t}const W=function(e,t,n,{pure:r,areStatesEqual:a=Y,areOwnPropsEqual:o=I,areStatePropsEqual:l=I,areMergedPropsEqual:u=I,forwardRef:s=!1,context:c=f}={}){const p=c,d=function(e){return e?"function"==typeof e?P(e):T(e,"mapStateToProps"):D((()=>({})))}(e),h=function(e){return e&&"object"==typeof e?D((t=>function(e,t){const n={};for(const r in e){const a=e[r];"function"==typeof a&&(n[r]=(...e)=>t(a(...e)))}return n}(e,t))):e?"function"==typeof e?P(e):T(e,"mapDispatchToProps"):D((e=>({dispatch:e})))}(t),m=function(e){return e?"function"==typeof e?function(e){return function(t,{displayName:n,areMergedPropsEqual:r}){let a,o=!1;return function(t,n,l){const i=e(t,n,l);return o?r(i,a)||(a=i):(o=!0,a=i),a}}}(e):T(e,"mergeProps"):()=>N}(n),g=Boolean(e);return e=>{const t=e.displayName||e.name||"Component",n=`Connect(${t})`,r={shouldHandleStateChanges:g,displayName:n,wrappedComponentName:t,WrappedComponent:e,initMapStateToProps:d,initMapDispatchToProps:h,initMergeProps:m,areStatesEqual:a,areStatePropsEqual:l,areOwnPropsEqual:o,areMergedPropsEqual:u};function c(t){const[n,a,o]=(0,i.useMemo)((()=>{const{reactReduxForwardedRef:e}=t,n=E(t,F);return[t.context,e,n]}),[t]),l=(0,i.useMemo)((()=>n&&n.Consumer&&(0,S.isContextConsumer)(i.createElement(n.Consumer,null))?n:p),[n,p]),u=(0,i.useContext)(l),s=Boolean(t.store)&&Boolean(t.store.getState)&&Boolean(t.store.dispatch),c=Boolean(u)&&Boolean(u.store),d=s?t.store:u.store,f=c?u.getServerState:d.getState,h=(0,i.useMemo)((()=>function(e,t){let{initMapStateToProps:n,initMapDispatchToProps:r,initMergeProps:a}=t,o=E(t,k);return C(n(e,o),r(e,o),a(e,o),e,o)}(d.dispatch,r)),[d]),[m,y]=(0,i.useMemo)((()=>{if(!g)return U;const e=R(d,s?void 0:u.subscription),t=e.notifyNestedSubs.bind(e);return[e,t]}),[d,s,u]),v=(0,i.useMemo)((()=>s?u:w({},u,{subscription:m})),[s,u,m]),b=(0,i.useRef)(),_=(0,i.useRef)(o),x=(0,i.useRef)(),D=(0,i.useRef)(!1),O=((0,i.useRef)(!1),(0,i.useRef)(!1)),P=(0,i.useRef)();j((()=>(O.current=!0,()=>{O.current=!1})),[]);const T=(0,i.useMemo)((()=>()=>x.current&&o===_.current?x.current:h(d.getState(),o)),[d,o]),N=(0,i.useMemo)((()=>e=>m?function(e,t,n,r,a,o,l,i,u,s,c){if(!e)return()=>{};let p=!1,d=null;const f=()=>{if(p||!i.current)return;const e=t.getState();let n,f;try{n=r(e,a.current)}catch(e){f=e,d=e}f||(d=null),n===o.current?l.current||s():(o.current=n,u.current=n,l.current=!0,c())};return n.onStateChange=f,n.trySubscribe(),f(),()=>{if(p=!0,n.tryUnsubscribe(),n.onStateChange=null,d)throw d}}(g,d,m,h,_,b,D,O,x,y,e):()=>{}),[m]);var M,A;let I;M=z,A=[_,b,D,o,x,y],j((()=>M(...A)),undefined);try{I=L(N,T,f?()=>h(f(),o):T)}catch(e){throw P.current&&(e.message+=`\nThe error may be correlated with this previous error:\n${P.current.stack}\n\n`),e}j((()=>{P.current=void 0,x.current=void 0,b.current=I}));const Y=(0,i.useMemo)((()=>i.createElement(e,w({},I,{ref:a}))),[a,e,I]);return(0,i.useMemo)((()=>g?i.createElement(l.Provider,{value:v},Y):Y),[l,Y,v])}const f=i.memo(c);if(f.WrappedComponent=e,f.displayName=c.displayName=n,s){const t=i.forwardRef((function(e,t){return i.createElement(f,w({},e,{reactReduxForwardedRef:t}))}));return t.displayName=n,t.WrappedComponent=e,x()(t,e)}return x()(f,e)}},B=function({store:e,context:t,children:n,serverState:r}){const a=(0,i.useMemo)((()=>{const t=R(e);return{store:e,subscription:t,getServerState:r?()=>r:void 0}}),[e,r]),o=(0,i.useMemo)((()=>e.getState()),[e]);j((()=>{const{subscription:t}=a;return t.onStateChange=t.notifyNestedSubs,t.trySubscribe(),o!==e.getState()&&t.notifyNestedSubs(),()=>{t.tryUnsubscribe(),t.onStateChange=void 0}}),[a,o]);const l=t||f;return i.createElement(l.Provider,{value:a},n)};function H(e=f){const t=e===f?h:()=>(0,i.useContext)(e);return function(){const{store:e}=t();return e}}const q=H();function V(e=f){const t=e===f?q:H(e);return function(){return t().dispatch}}const $=V();var Z,Q;function K(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function G(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function X(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?G(Object(n),!0).forEach((function(t){K(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):G(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function J(e){return"Minified Redux error #"+e+"; visit https://redux.js.org/Errors?code="+e+" for the full message or use the non-minified dev environment for full errors. "}Z=s.useSyncExternalStoreWithSelector,g=Z,(e=>{L=e})(u.useSyncExternalStore),Q=c.unstable_batchedUpdates,p=Q;var ee="function"==typeof Symbol&&Symbol.observable||"@@observable",te=function(){return Math.random().toString(36).substring(7).split("").join(".")},ne={INIT:"@@redux/INIT"+te(),REPLACE:"@@redux/REPLACE"+te(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+te()}};function re(e){if("object"!=typeof e||null===e)return!1;for(var t=e;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function ae(e,t,n){var r;if("function"==typeof t&&"function"==typeof n||"function"==typeof n&&"function"==typeof arguments[3])throw new Error(J(0));if("function"==typeof t&&void 0===n&&(n=t,t=void 0),void 0!==n){if("function"!=typeof n)throw new Error(J(1));return n(ae)(e,t)}if("function"!=typeof e)throw new Error(J(2));var a=e,o=t,l=[],i=l,u=!1;function s(){i===l&&(i=l.slice())}function c(){if(u)throw new Error(J(3));return o}function p(e){if("function"!=typeof e)throw new Error(J(4));if(u)throw new Error(J(5));var t=!0;return s(),i.push(e),function(){if(t){if(u)throw new Error(J(6));t=!1,s();var n=i.indexOf(e);i.splice(n,1),l=null}}}function d(e){if(!re(e))throw new Error(J(7));if(void 0===e.type)throw new Error(J(8));if(u)throw new Error(J(9));try{u=!0,o=a(o,e)}finally{u=!1}for(var t=l=i,n=0;n<t.length;n++)(0,t[n])();return e}function f(e){if("function"!=typeof e)throw new Error(J(10));a=e,d({type:ne.REPLACE})}function h(){var e,t=p;return(e={subscribe:function(e){if("object"!=typeof e||null===e)throw new Error(J(11));function n(){e.next&&e.next(c())}return n(),{unsubscribe:t(n)}}})[ee]=function(){return this},e}return d({type:ne.INIT}),(r={dispatch:d,subscribe:p,getState:c,replaceReducer:f})[ee]=h,r}function oe(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return 0===t.length?function(e){return e}:1===t.length?t[0]:t.reduce((function(e,t){return function(){return e(t.apply(void 0,arguments))}}))}function le(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e){return function(){var n=e.apply(void 0,arguments),r=function(){throw new Error(J(15))},a={getState:n.getState,dispatch:function(){return r.apply(void 0,arguments)}},o=t.map((function(e){return e(a)}));return r=oe.apply(void 0,o)(n.dispatch),X(X({},n),{},{dispatch:r})}}}function ie(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function ue(e){return function(e){if(Array.isArray(e))return ie(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return ie(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ie(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function se(e){return se="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},se(e)}var ce="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];if(0!==t.length)return"object"===se(t[0])?oe:oe.apply(void 0,ue(t))};function pe(e){return function(t){var n=t.dispatch,r=t.getState;return function(t){return function(a){return"function"==typeof a?a(n,r,e):t(a)}}}}"undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION__&&window.__REDUX_DEVTOOLS_EXTENSION__;var de=pe();de.withExtraArgument=pe;const fe=de,he="SETTING_LOAD_START",me="SETTING_LOAD_SUCCESS",ge="SETTING_LOAD_FAILED",ye="SETTING_LOAD_STATUS",ve="SETTING_SAVING",be="SETTING_SAVED",we="SETTING_SAVE_FAILED",Ee="SETTING_API_FAILED",_e="SETTING_API_SUCCESS",xe="SETTING_API_TRY",Se="STATUS_IN_PROGRESS",ke="STATUS_FAILED",Ce="STATUS_COMPLETE",De="loading",Oe="fail";function Pe(e,t,n,r){const a=e[t]?{...e[t]}:[];return a[n]=r,{[t]:a}}const Te="SEARCH_START_FRESH",Ne="SEARCH_START_MORE",Me="SEARCH_FAIL",Re="SEARCH_COMPLETE",je="SEARCH_REPLACE_ROW",Ae="SEARCH_CANCEL",Ie="SEARCH_PERFORM_FRESH",Fe="SEARCH_PERFORM_MORE",Le="SEARCH_VALUES",Ue="SEARCH_DELETE_COMPLETE",ze="SEARCH_LOAD_ROW_COMPLETE",Ye="SEARCH_LABEL",We="forward",Be="backward",He="PRESET_SELECT",qe="PRESET_SAVE",Ve="PRESET_SAVED",$e="PRESET_SAVE_FAIL",Ze="PRESET_UPLOAD",Qe="PRESET_UPLOAD_COMPLETE",Ke="PRESET_UPLOAD_FAIL",Ge="PRESET_CLIPBOARD_FAIL",Xe="PRESET_SET_CLIPBOARD",Je="PRESET_CLEAR",et=wp.i18n,tt=e=>0===e?"Admin AJAX returned 0":"string"==typeof e?e:e.message?e.message:(console.error(e),"Unknown error "+("object"==typeof e?Object.keys(e):e));let nt=[];function rt(e,t,n){return{code:(r=e,"number"==typeof r?`${r}`:r.error_code?r.error_code:0===r?"admin-ajax":r.code?r.code:r.name?r.name:r.data&&r.data.error_code?r.data.error_code:r),message:tt(t),request:n,data:n.apiFetch.data?n.apiFetch.data:null,jsonData:e&&e.data?e.data:null};var r}const at=e=>{if(e.status>=200&&e.status<300)return e;throw e};function ot(e){return e.headers.get("x-wp-nonce")&&ut.nonceMiddleware&&(ut.nonceMiddleware.nonce=e.headers.get("x-wp-nonce")),e}const lt=e=>e.text();function it(e){return fetch(e.url,e).then(ot).then((t=>((e,t)=>(t.apiFetch={action:t.url.replace(/[\?&]_wpnonce=[a-f0-9]*/,"")+" "+t.method.toUpperCase(),body:"object"==typeof t.body?JSON.stringify(t.body):t.body},t.headers=e.headers,e.status&&void 0!==e.statusText&&(t.apiFetch.status=e.status,t.apiFetch.statusText=e.statusText),e))(t,e))).then(lt).then((t=>((e,t)=>(t.apiFetch.data=e,e))(t,e))).then((t=>((e,t)=>{if(""===e&&(t.apiFetch.status<200||t.apiFetch.status>300))return e;try{const n=JSON.parse(e.replace(/\ufeff/,""));if(0===n)throw rt("json-zero","Failed to get data",t);return n}catch(e){throw rt(e,e.message,t)}})(t,e))).then((t=>((e,t)=>{if(e.error||e.error_code)throw rt(e,e.message,t);if(t.apiFetch){const{status:n,statusText:r}=t.apiFetch;if(e.code&&e.message)throw rt(e,e,t);if(n<200||n>=300)throw rt(n,r,t)}return e})(t,e)))}function ut(e){const t=[...nt,it],n=e=>r=>{const a=t[e];return e===t.length-1?a(r):a(r,n(e+1))};return new Promise(((t,r)=>{n(0)(e).then(t).catch((n=>{if("rest_cookie_invalid_nonce"!==n.code)return r(n);window.fetch("admin-ajax.php?action=rest-nonce").then(at).then(lt).then((n=>{ut.nonceMiddleware.nonce=n,ut(e).then(t).catch(r)})).catch(r)}))}))}ut.getUrl=e=>ut.rootURLMiddleware({url:e},(e=>ut.nonceMiddleware(e,(e=>e.url)))),ut.use=function(e){nt.unshift(e)},ut.createNonceMiddleware=e=>{const t=function(e){function t(e,n){const{headers:r={}}=e;for(const a in r)if("x-wp-nonce"===a.toLowerCase()&&r[a]===t.nonce)return n(e);return n({...e,headers:{...r,"X-WP-Nonce":t.nonce}})}return t.nonce=e,t}(e);return ut.nonceMiddleware=t,t},ut.createRootURLMiddleware=e=>{const t=function(e){function t(t,n){return"http"===t.url.substr(0,4)?n(t):n({...t,url:(r=e,a=t.url,function(e){return e.replace("wp-json/wp-json","wp-json").replace("=/wp-json","=")}((o=function(e){return e.replace(/\/$/,"")}(r),l=function(e,t){return-1!==e.indexOf("?")?t.replace("?","&"):t}(r,function(e){return e.replace(/^\//,"")}(a)),o+"/"+l)))});var r,a,o,l}return t.rootURL=e,t}(e);return ut.rootURLMiddleware=t,t},ut.resetMiddlewares=()=>{nt=[]},ut.replaceRootURLMiddleware=e=>{for(let t=0;t<nt.length;t++)nt[t]===ut.rootURLMiddleware&&(nt[t]=ut.createRootURLMiddleware(e))};const st=ut,ct="wpwrap";function pt(e){let t=document.getElementById(e);if(null===t){const n=document.getElementById("wpbody");t=document.createElement("div"),n&&n.parentNode&&(t.setAttribute("id",e),n.parentNode.appendChild(t))}return t}var dt=n(129),ft=n.n(dt);const ht=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=e+"/";return Object.keys(t).length>0&&ft().stringify(t).length>0?n+(-1===n.indexOf("?")?"?":"&")+ft().stringify(t):n},mt=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return{headers:{Accept:"application/json, */*;q=0.1"},url:ht(e,t),credentials:"include",method:"get",redirect:"error"}},gt=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const r={headers:{"Content-Type":"application/json; charset=utf-8",Accept:"application/json, */*;q=0.1"},url:ht(e,n),credentials:"include",method:"post",body:"{}"};return Object.keys(t).length>0&&(r.body=JSON.stringify(t)),r};var yt=n(251),vt=n.n(yt);function bt(e,t){const n=Et(e,t,"?");document.location.search!==n&&history.pushState({},"",n)}function wt(e){return dt.parse(e?e.slice(1):document.location.search.slice(1))}function Et(e,t,n){const r=wt(n);for(const n in e){const a=vt()(t[n],e[n]);e[n]&&!a||"page"===n?r[n.toLowerCase()]=e[n]:a&&delete r[n.toLowerCase()]}return"?"+dt.stringify(r,{arrayFormat:"brackets",indices:!1})}function _t(e,t){return e.find((e=>e.id===t))}function xt(e,t){return e&&-1!==e.indexOf(t)}function St(e,t){if(t)for(let n=0;n<e.length;n++)if(-1!==t.indexOf(e[n].name))return!0;return!1}function kt(e,t){return t.value&&St(e,t.value)}function Ct(e,t){return void 0!==t.searchValue&&(St(e,t.searchValue)||St(e,t.replaceValue))}function Dt(e){const t=function(e){let t=0;for(let n=0;n<e.length;n++)t=Math.max(t,e[n].title.length);return t}(e);return{"searchregex-search__tag__short":t<12,"searchregex-search__tag__medium":t>=12&&t<30,"searchregex-search__tag__long":t>=30}}function Ot(e,t){return t.reduce(((e,t)=>e.replace(t.name,t.value)),e)}function Pt(e){if(!e)return null;const t=e.tags.map((e=>({name:e.name,value:""})));return{...e.search,searchPhrase:Ot(e.search.searchPhrase,t),replacement:Ot(e.search.replacement,t)}}const Tt=()=>[{value:"regex",label:(0,et.__)("Regular Expression","search-regex"),alt:(0,et.__)("Regex","search-regex")},{value:"case",label:(0,et.__)("Ignore Case","search-regex"),alt:(0,et.__)("Case","search-regex")},{value:"multi",label:(0,et.__)("Multiline","search-regex"),alt:(0,et.__)("Multi","search-regex")}],Nt=()=>[{value:25,label:(0,et.__)("25 per page","search-regex")},{value:50,label:(0,et.__)("50 per page","search-regex")},{value:100,label:(0,et.__)("100 per page","search-regex")},{value:250,label:(0,et.__)("250 per page","search-regex")},{value:500,label:(0,et.__)("500 per page","search-regex")},{value:1e3,label:(0,et.__)("1000 per page","search-regex")},{value:2e3,label:(0,et.__)("2000 per page","search-regex")}],Mt=e=>e.status===Ce||null===e.status||e.status===ke;function Rt(e){const{searchFlags:t,searchPhrase:n,filters:r}=e;if(-1!==t.indexOf("regex")&&n.length>0)return!0;for(let e=0;e<r.length;e++){const t=r[e];for(let e=0;e<t.items.length;e++){const n=t.items[e];if(n.flags&&-1!==n.flags.indexOf("regex"))return!0}}return!1}function jt(e){return{...e,replacement:(t=e.replacement,t||""),perPage:-1===e.perPage?250:e.perPage,...-1===e.perPage&&e.limit?{limit:null}:{}};var t}function At(){return{searchPhrase:"",searchFlags:["case"],replacement:"",source:["posts"],perPage:25,filters:It("posts"),action:"replace",actionOption:[],view:[]}}function It(e){return"posts"===e?[{type:"posts",items:[{column:"post_type",logic:"include",values:["post","page"]}]}]:"comment"===e?[{type:"comment",items:[{column:"comment_approved",logic:"exclude",values:["spam"]}]}]:[]}function Ft(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;const t=e||wt(),n={},r={searchphrase:"searchPhrase",searchflags:"searchFlags",source:"source",replacement:"replacement",perpage:"perPage",filters:"filters",view:"view"};if(Object.keys(r).forEach((e=>{t[e]&&(n[r[e]]=t[e])})),n.filters)try{n.filters=JSON.parse(n.filters)}catch(e){n.filters=[]}return n.view&&(n.view=n.view.split(",")),n}function Lt(e,t){return e.find((e=>e.type===t))}function Ut(e,t){return e.find((e=>e.column===t))}function zt(e,t,n){const r=Lt(e,t);return r?Ut(r.columns,n):null}function Yt(e){return e?{...e.search,...Pt(e)}:At()}function Wt(e,t){return{type:e,items:[{column:t.columns[0].column}]}}function Bt(e,t,n){for(let n=0;n<e.length;n++)if(e[n].value===t)return e[n].label;return n||t}function Ht(e,t){return e.map((e=>({label:t.find((t=>t.type===e)).name,value:e})))}function qt(e,t,n){const r=function(e,t){return t&&"member"===t.type?{values:e.contexts.filter((e=>"empty"!==e.type)).map((e=>e.replacement_value?e.replacement_value:e.value))}:{}}(e,t);return{column:t.column,operation:"",source:n,...r}}function Vt(e,t){if(e.isSaving&&!1!==t.progress.next)return!0;if(-1===e.search.perPage&&!1!==t.progress.next)return!0;if(Rt(e.search)){if(e.results.length+t.results.length>=e.search.perPage)return!1;if(e.searchDirection===We&&!1!==t.progress.next)return!0;if(e.searchDirection===Be&&!1!==t.progress.previous)return!0}return!1}const $t=()=>({...Zt(),results:[],totals:{matched_rows:0,matched_phrases:0,rows:0},progress:{}}),Zt=()=>({requestCount:0,status:null,replacing:[],canCancel:!1,showLoading:!1});function Qt(e,t,n){const r=t.custom||[];return{...t,...e,matched_rows:t.matched_rows+n,custom:e.custom?e.custom.map(((e,n)=>({name:e.name,value:t.custom&&t.custom[n]?t.custom[n].value+e.value:e.value}))):r}}function Kt(e,t){if(void 0!==t.replacement&&t.replacement===e.replacement)return!1;if(void 0!==t.actionOption&&"modify"===t.action){const{filters:n}=e.search;return t.actionOption.filter((e=>{const t=n.find((t=>t.type===e.source));return!t||!t.items.find((t=>t.column===e.column))})).length>0}return!0}function Gt(e,t){if(!Rt(e.search)||e.search.action)return{};const n=0===e.requestCount;return{next:e.searchDirection===We||n?t.progress.next:e.progress.next,previous:e.searchDirection===Be||n?t.progress.previous:e.progress.previous}}const Xt="MESSAGE_CLEAR_ERRORS",Jt="MESSAGE_CLEAR_NOTICES",en=(e,t)=>e.slice(0).concat([t]),tn=(e,t)=>e.slice(0).concat([t]),nn=e=>Math.max(0,e.inProgress-1),rn={SETTING_SAVED:(0,et.__)("Settings saved","search-regex"),SEARCH_DELETE_COMPLETE:(0,et.__)("Row deleted","search-regex"),SEARCH_REPLACE_COMPLETE:(0,et.__)("Row replaced","search-regex"),SEARCH_SAVE_ROW_COMPLETE:(0,et.__)("Row updated","search-regex"),PRESET_SAVED:(0,et.__)("Preset saved","search-regex"),PRESET_UPLOAD_COMPLETE:(0,et.__)("Preset uploaded","search-regex")};function an(e,t){return t.id?e.map((e=>e.id===t.id?{...e,...t.preset}:e)):e}const on=function(e){for(var t=Object.keys(e),n={},r=0;r<t.length;r++){var a=t[r];"function"==typeof e[a]&&(n[a]=e[a])}var o,l=Object.keys(n);try{!function(e){Object.keys(e).forEach((function(t){var n=e[t];if(void 0===n(void 0,{type:ne.INIT}))throw new Error(J(12));if(void 0===n(void 0,{type:ne.PROBE_UNKNOWN_ACTION()}))throw new Error(J(13))}))}(n)}catch(e){o=e}return function(e,t){if(void 0===e&&(e={}),o)throw o;for(var r=!1,a={},i=0;i<l.length;i++){var u=l[i],s=n[u],c=e[u],p=s(c,t);if(void 0===p)throw t&&t.type,new Error(J(14));a[u]=p,r=r||p!==c}return(r=r||l.length!==Object.keys(e).length)?a:e}}({settings:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;switch(t.type){case xe:return{...e,apiTest:{...e.apiTest,...Pe(e.apiTest,t.id,t.method,{status:De})}};case _e:return{...e,apiTest:{...e.apiTest,...Pe(e.apiTest,t.id,t.method,{status:"ok"})}};case Ee:return{...e,apiTest:{...e.apiTest,...Pe(e.apiTest,t.id,t.method,{status:Oe,error:t.error})}};case he:return{...e,loadStatus:Se};case me:return{...e,loadStatus:Ce,values:t.values};case ge:return{...e,loadStatus:ke,error:t.error};case ve:return{...e,saveStatus:Se,warning:!1};case be:return{...e,saveStatus:Ce,values:t.values,warning:!!t.warning&&t.warning};case we:return{...e,saveStatus:ke,error:t.error};case ye:return{...e,pluginStatus:t.pluginStatus}}return e},search:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;switch(t.type){case Ye:return{...e,labels:e.labels.filter((e=>e.labelId!==t.labelId)).concat(t.labelValue?[{value:t.labelId,label:t.labelValue}]:[])};case He:return{...e,...$t(),search:{...e.search,...Yt(t.preset)}};case Le:const n=Kt(e,t.searchValue)&&e.results.length>0;return{...e,search:{...e.search,...t.searchValue},resultsDirty:n};case Ae:return{...e,...t.clearAll?$t():Zt(),status:null,isSaving:!1};case Me:return{...e,...Zt(),status:ke,canCancel:!1,isSaving:!1};case Ie:case Te:return{...e,requestCount:0,resultsDirty:!1,status:Se,totals:0===t.page?{matched_rows:0,matched_phrases:0,rows:0}:e.totals,progress:0===t.page?{}:e.progress,results:[],searchDirection:t.searchDirection||We,showLoading:!0,isSaving:t.type===Ie};case Fe:case Ne:return Mt(e)?e:{...e,canCancel:!0,showLoading:!0};case Re:if(Mt(e))return e;const r=Vt(e,t);return{...e,results:e.searchDirection===We?e.results.concat(t.results):t.results.concat(e.results),progress:{...e.progress,...t.progress,...Gt(e,t),current:(e.progress.current?e.progress.current:0)+t.progress.rows,rows:(e.progress.rows?e.progress.rows:0)+t.progress.rows},totals:Qt(t.totals,e.totals,t.results.length),requestCount:e.requestCount+1,canCancel:r,showLoading:r,status:r?e.status:Ce};case ze:return{...e,replacing:e.replacing.filter((e=>e!==t.rowId)),results:e.results.map((e=>e.row_id===t.rowId?t.row:e)),status:Ce};case je:return{...e,replacing:e.replacing.concat(t.rowId),status:Se};case Ue:return{...e,results:e.results.filter((e=>e.row_id!==t.rowId)),replacing:e.replacing.filter((e=>e!==t.rowId)),status:Ce}}return e},message:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;switch(t.type){case $e:case Me:case ge:case we:case Ke:const n=en(e.errors,t.error);return console.error(t.error.message),{...e,errors:n,inProgress:nn(e)};case Ze:case qe:case je:case ve:return{...e,inProgress:e.inProgress+1};case Qe:case Ve:case Ue:case be:return{...e,notices:tn(e.notices,rn[t.type]),inProgress:nn(e)};case Jt:return{...e,notices:[]};case Te:case Ie:case Xt:return{...e,errors:[]}}return e},preset:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;switch(t.type){case Je:return{...e,error:null,uploadStatus:null,clipboardStatus:null};case Xe:return{...e,clipboard:t.clipboard};case Ge:return{...e,clipboardStatus:ke,errorContext:t.errorContext,error:t.error};case Ze:return{...e,clipboardStatus:null,imported:0,isUploading:!0,uploadStatus:Se};case Qe:return{...e,presets:t.presets,imported:t.import,uploadStatus:Ce,isUploading:!1,clipboard:""};case Ke:return{...e,uploadStatus:ke,isUploading:!1,error:t.error,clipboard:"",imported:0};case qe:return{...e,uploadStatus:Se,presets:t.id?an(e.presets,t):e.presets};case Ve:return{...e,presets:t.presets,currentPreset:t.current.id,clipboardStatus:null,uploadStatus:Ce,isUploading:!1,clipboard:""};case $e:return{...e,uploadStatus:ke};case He:return{...e,currentPreset:t.preset?t.preset.id:""}}return e}}),ln=on;var un=n(3162);function sn(e){return e.length>0?JSON.stringify(e,{arrayFormat:"brackets",indices:!1}):null}const cn=[fe,e=>t=>n=>{switch(n.type){case Re:const{search:t}=e.getState().search;n.isSave&&!1===n.progress.next&&"export"===t.action&&function(e,t){const n=function(e,t){return"json"===t?JSON.stringify(e):e.join("\n")}(e,t),r=function(e){return"json"===e?"export.json":"csv"===e?"export.csv":"sql"===e?"export.sql":"export.txt"}(t);(0,un.saveAs)(new Blob([n]),r)}(n.results,t.actionOption.format?t.actionOption.format:"json");break;case Te:!function(e,t,n){const{searchFlags:r,source:a,perPage:o,searchPhrase:l,filters:i,view:u}=e,s=n.presets.find((e=>e.id===n.currentPreset));s?bt({page:"search-regex.php",preset:s.id},{}):bt({page:"search-regex.php",searchPhrase:l,searchFlags:r,source:a,perPage:o,filters:sn(i),view:u.join(",")},{searchPhrase:"",searchFlags:["case"],source:["post","page"],perPage:25,sub:"search",filters:[],view:[]})}(n,e.getState().search,e.getState().preset);break;case He:if(n.currentOnly)break;n.preset?bt({page:"search-regex.php",preset:n.preset.id},wt()):function(e){const t=wt();delete t.preset;const n=0===Object.keys(t).length?"":"?"+dt.stringify(t,{arrayFormat:"brackets",indices:!1});document.location.search!==n&&history.pushState({},"",n)}()}return t(n)}];function pn(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=ae(ln,e,ce(le(...cn)));return t}function dn(){const e=SearchRegexi10n&&SearchRegexi10n.preload&&SearchRegexi10n.preload.pluginStatus?SearchRegexi10n.preload.pluginStatus:[];return{loadStatus:Se,saveStatus:!1,error:!1,pluginStatus:e,apiTest:{},database:SearchRegexi10n.database?SearchRegexi10n.database:{},values:SearchRegexi10n.settings?SearchRegexi10n.settings:{},api:SearchRegexi10n.api?SearchRegexi10n.api:[],warning:!1}}function fn(e,t){return"undefined"!=typeof SearchRegexi10n&&SearchRegexi10n.preload&&SearchRegexi10n.preload[e]?SearchRegexi10n.preload[e]:t}function hn(e,t,n){return t.find((t=>t.value===e||t.name===e))?e:n}function mn(e,t){return e.filter((e=>hn(e,t,!1)))}function gn(e,t){let n=[];return e.forEach((e=>{n=n.concat(e.sources.map((e=>e.name)))})),t.filter((e=>-1!==n.indexOf(e)))}function yn(e,t,n){return e.filter((e=>{const r=Lt(t,e.type);return!(!r||-1===n.indexOf(r.type))&&(e.items.filter((e=>void 0!==r.columns.find((t=>t.column===e.column)))).length=e.items.length)}))}function vn(e,t){return Array.isArray(e)?e.filter((e=>{const n=e.split("__");if(2===n.length){const e=Lt(t,n[0]);if(e)return void 0!==e.columns.find((e=>e.column===n[1]))}return!1})):[]}function bn(){const e=wt(),t=fn("sources",[]),n=function(e){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;const n=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:null)||fn("sources",[]),r=t||fn("schema",[]),{searchPhrase:a,searchFlags:o,replacement:l,perPage:i,view:u,action:s,actionOption:c}=e,p=gn(n,e.source.length>0?e.source:[]);return{searchPhrase:a,searchFlags:mn(o,Tt()),source:p,replacement:l,perPage:hn(parseInt(i,10),Nt(),25),filters:yn(e.filters,r,p),view:vn(u,r),action:s,actionOption:c}}({...At(),...Yt(fn("presets",[]).find((t=>t.id===e.preset||t.id===SearchRegexi10n.settings.defaultPreset))),...Ft()});return{results:[],resultsDirty:!1,replacing:[],search:n,searchDirection:null,labels:fn("labels",[]),requestCount:0,totals:{matched_rows:0,matched_phrases:0,rows:0},progress:{},status:null,showLoading:!1,isSaving:!1,sources:t,canCancel:!1,schema:fn("schema",[])}}function wn(){const e=wt(),{defaultPreset:t}=SearchRegexi10n.settings;return{presets:fn("presets",[]),currentPreset:e.preset?e.preset:t,uploadStatus:null,isUploading:!1,clipboardStatus:null,clipboard:"",error:null,errorContext:null,imported:0}}function En(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";const t=wt(e);return t.sub&&-1!==xn.indexOf(t.sub)?t.sub:xn[0]}const xn=["search","options","support","presets"];var Sn=n(4184),kn=n.n(Sn);const Cn=e=>{const{children:t,className:n,onClick:a=null,title:o="",onCancel:l,disabled:i=!1,small:u=!1}=e,s={title:o,onClick:a};return(0,r.createElement)("div",w({className:kn()("wpl-badge",n,{"wpl-badge__click":a,"wpl-badge__small":u,"wpl-badge__disabled":i})},s),(0,r.createElement)("div",{className:"wpl-badge__content"},t),l&&(0,r.createElement)("div",{className:"wpl-badge__close dashicons dashicons-no-alt",onClick:e=>{e.preventDefault(),!i&&l&&l(e)}}))};function Dn(e,t){return!(!t||t.contains(e.target)||"keydown"===e.type||e&&e.target&&(e.target.closest(".wpl-dropdowntext__suggestions")||e.target.closest(".wpl-multioption")))}function On(e){const t=(0,i.useRef)(null),{children:n,onOutside:a,className:o}=e,l=e=>{(Dn(e,t.current)||"Escape"===e.key)&&a(e)};return(0,i.useEffect)((()=>(addEventListener("mousedown",l),addEventListener("keydown",l),()=>{removeEventListener("mousedown",l),removeEventListener("keydown",l)})),[]),(0,r.createElement)("div",{className:o,ref:t},n)}function Pn(){return Pn=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Pn.apply(this,arguments)}var Tn="data-focus-lock",Nn="data-focus-lock-disabled";var Mn={width:"1px",height:"0px",padding:0,overflow:"hidden",position:"fixed",top:"1px",left:"1px"},Rn=function(e){var t=e.children;return i.createElement(i.Fragment,null,i.createElement("div",{key:"guard-first","data-focus-guard":!0,"data-focus-auto-guard":!0,style:Mn}),t,t&&i.createElement("div",{key:"guard-last","data-focus-guard":!0,"data-focus-auto-guard":!0,style:Mn}))};Rn.propTypes={},Rn.defaultProps={children:null};var jn=function(){return jn=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var a in t=arguments[n])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e},jn.apply(this,arguments)};function An(e,t,n,r){return new(n||(n=Promise))((function(a,o){function l(e){try{u(r.next(e))}catch(e){o(e)}}function i(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(l,i)}u((r=r.apply(e,t||[])).next())}))}function In(e,t){var n,r,a,o,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function i(o){return function(i){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;l;)try{if(n=1,r&&(a=2&o[0]?r.return:o[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,o[1])).done)return a;switch(r=0,a&&(o=[2&o[0],a.value]),o[0]){case 0:case 1:a=o;break;case 4:return l.label++,{value:o[1],done:!1};case 5:l.label++,r=o[1],o=[0];continue;case 7:o=l.ops.pop(),l.trys.pop();continue;default:if(!((a=(a=l.trys).length>0&&a[a.length-1])||6!==o[0]&&2!==o[0])){l=0;continue}if(3===o[0]&&(!a||o[1]>a[0]&&o[1]<a[3])){l.label=o[1];break}if(6===o[0]&&l.label<a[1]){l.label=a[1],a=o;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(o);break}a[2]&&l.ops.pop(),l.trys.pop();continue}o=t.call(e,l)}catch(e){o=[6,e],r=0}finally{n=a=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,i])}}}function Fn(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,a,o=n.call(e),l=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)l.push(r.value)}catch(e){a={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(a)throw a.error}}return l}function Ln(e,t,n){if(n||2===arguments.length)for(var r,a=0,o=t.length;a<o;a++)!r&&a in t||(r||(r=Array.prototype.slice.call(t,0,a)),r[a]=t[a]);return e.concat(r||Array.prototype.slice.call(t))}function Un(e){return e}function zn(e,t){void 0===t&&(t=Un);var n=[],r=!1,a={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(e){var a=t(e,r);return n.push(a),function(){n=n.filter((function(e){return e!==a}))}},assignSyncMedium:function(e){for(r=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){r=!0;var t=[];if(n.length){var a=n;n=[],a.forEach(e),t=n}var o=function(){var n=t;t=[],n.forEach(e)},l=function(){return Promise.resolve().then(o)};l(),n={push:function(e){t.push(e),l()},filter:function(e){return t=t.filter(e),n}}}};return a}function Yn(e,t){return void 0===t&&(t=Un),zn(e,t)}Object.create,Object.create;var Wn=Yn({},(function(e){return{target:e.target,currentTarget:e.currentTarget}})),Bn=Yn(),Hn=Yn(),qn=function(e){void 0===e&&(e={});var t=zn(null);return t.options=jn({async:!0,ssr:!1},e),t}({async:!0}),Vn=[],$n=i.forwardRef((function(e,t){var n,r=i.useState(),a=r[0],o=r[1],l=i.useRef(),u=i.useRef(!1),s=i.useRef(null),c=e.children,p=e.disabled,d=e.noFocusGuards,f=e.persistentFocus,h=e.crossFrame,m=e.autoFocus,g=(e.allowTextSelection,e.group),y=e.className,v=e.whiteList,b=e.hasPositiveIndices,w=e.shards,E=void 0===w?Vn:w,_=e.as,x=void 0===_?"div":_,S=e.lockProps,k=void 0===S?{}:S,C=e.sideCar,D=e.returnFocus,O=e.focusOptions,P=e.onActivation,T=e.onDeactivation,N=i.useState({})[0],M=i.useCallback((function(){s.current=s.current||document&&document.activeElement,l.current&&P&&P(l.current),u.current=!0}),[P]),R=i.useCallback((function(){u.current=!1,T&&T(l.current)}),[T]);(0,i.useEffect)((function(){p||(s.current=null)}),[]);var j,A,I,F,L,U=i.useCallback((function(e){var t=s.current;if(t&&t.focus){var n="function"==typeof D?D(t):D;if(n){var r="object"==typeof n?n:void 0;s.current=null,e?Promise.resolve().then((function(){return t.focus(r)})):t.focus(r)}}}),[D]),z=i.useCallback((function(e){u.current&&Wn.useMedium(e)}),[]),Y=Bn.useMedium,W=i.useCallback((function(e){l.current!==e&&(l.current=e,o(e))}),[]),B=Pn(((n={})[Nn]=p&&"disabled",n[Tn]=g,n),k),H=!0!==d,q=H&&"tail"!==d,V=(j=[t,W],I=A||null,F=function(e){return j.forEach((function(t){return function(e,t){return"function"==typeof e?e(t):e&&(e.current=t),e}(t,e)}))},(L=(0,i.useState)((function(){return{value:I,callback:F,facade:{get current(){return L.value},set current(e){var t=L.value;t!==e&&(L.value=e,L.callback(e,t))}}}}))[0]).callback=F,L.facade);return i.createElement(i.Fragment,null,H&&[i.createElement("div",{key:"guard-first","data-focus-guard":!0,tabIndex:p?-1:0,style:Mn}),b?i.createElement("div",{key:"guard-nearest","data-focus-guard":!0,tabIndex:p?-1:1,style:Mn}):null],!p&&i.createElement(C,{id:N,sideCar:qn,observed:a,disabled:p,persistentFocus:f,crossFrame:h,autoFocus:m,whiteList:v,shards:E,onActivation:M,onDeactivation:R,returnFocus:U,focusOptions:O}),i.createElement(x,Pn({ref:V},B,{className:y,onBlur:Y,onFocus:z}),c),q&&i.createElement("div",{"data-focus-guard":!0,tabIndex:p?-1:0,style:Mn}))}));$n.propTypes={},$n.defaultProps={children:void 0,disabled:!1,returnFocus:!1,focusOptions:void 0,noFocusGuards:!1,autoFocus:!0,persistentFocus:!1,crossFrame:!0,hasPositiveIndices:void 0,allowTextSelection:void 0,group:void 0,className:void 0,whiteList:void 0,shards:void 0,as:"div",lockProps:{},onActivation:void 0,onDeactivation:void 0};const Zn=$n;function Qn(e,t){return Qn=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},Qn(e,t)}var Kn=function(e){return e.parentNode&&e.parentNode.nodeType===Node.DOCUMENT_FRAGMENT_NODE?e.parentNode.host:e.parentNode},Gn=function(e){return e===document||e&&e.nodeType===Node.DOCUMENT_NODE},Xn=function(e,t){var n=e.get(t);if(void 0!==n)return n;var r=function(e,t){return!e||Gn(e)||!function(e){if(e.nodeType!==Node.ELEMENT_NODE)return!1;var t=window.getComputedStyle(e,null);return!(!t||!t.getPropertyValue||"none"!==t.getPropertyValue("display")&&"hidden"!==t.getPropertyValue("visibility"))}(e)&&t(Kn(e))}(t,Xn.bind(void 0,e));return e.set(t,r),r},Jn=function(e,t){var n=e.get(t);if(void 0!==n)return n;var r=function(e,t){return!(e&&!Gn(e))||!!rr(e)&&t(Kn(e))}(t,Jn.bind(void 0,e));return e.set(t,r),r},er=function(e){return e.dataset},tr=function(e){return"INPUT"===e.tagName},nr=function(e){return tr(e)&&"radio"===e.type},rr=function(e){var t=e.getAttribute("data-no-autofocus");return![!0,"true",""].includes(t)},ar=function(e){var t;return Boolean(e&&(null===(t=er(e))||void 0===t?void 0:t.focusGuard))},or=function(e){return!ar(e)},lr=function(e){return Boolean(e)},ir=function(e,t){return nr(e)&&e.name?function(e,t){return t.filter(nr).filter((function(t){return t.name===e.name})).filter((function(e){return e.checked}))[0]||e}(e,t):e},ur=function(e){return e[0]&&e.length>1?ir(e[0],e):e[0]},sr=function(e,t){return e.length>1?e.indexOf(ir(e[t],e)):t},cr="NEW_FOCUS",pr=function(e){for(var t=Array(e.length),n=0;n<e.length;++n)t[n]=e[n];return t},dr=function(e){return Array.isArray(e)?e:[e]},fr=function(e,t){var n=e.tabIndex-t.tabIndex,r=e.index-t.index;if(n){if(!e.tabIndex)return 1;if(!t.tabIndex)return-1}return n||r},hr=function(e,t,n){return pr(e).map((function(e,t){return{node:e,index:t,tabIndex:n&&-1===e.tabIndex?(e.dataset||{}).focusGuard?0:-1:e.tabIndex}})).filter((function(e){return!t||e.tabIndex>=0})).sort(fr)},mr=["button:enabled","select:enabled","textarea:enabled","input:enabled","a[href]","area[href]","summary","iframe","object","embed","audio[controls]","video[controls]","[tabindex]","[contenteditable]","[autofocus]"].join(","),gr="".concat(mr,", [data-focus-guard]"),yr=function(e,t){var n;return pr((null===(n=e.shadowRoot)||void 0===n?void 0:n.children)||e.children).reduce((function(e,n){return e.concat(n.matches(t?gr:mr)?[n]:[],yr(n))}),[])},vr=function(e,t){return e.reduce((function(e,n){return e.concat(yr(n,t),n.parentNode?pr(n.parentNode.querySelectorAll(mr)).filter((function(e){return e===n})):[])}),[])},br=function(e,t){return pr(e).filter((function(e){return Xn(t,e)})).filter((function(e){return function(e){return!((tr(e)||function(e){return"BUTTON"===e.tagName}(e))&&("hidden"===e.type||e.disabled))}(e)}))},wr=function(e,t){return void 0===t&&(t=new Map),pr(e).filter((function(e){return Jn(t,e)}))},Er=function(e,t,n){return hr(br(vr(e,n),t),!0,n)},_r=function(e,t){return hr(br(vr(e),t),!1)},xr=function(e,t){return(e.shadowRoot?xr(e.shadowRoot,t):Object.getPrototypeOf(e).contains.call(e,t))||pr(e.children).some((function(e){return xr(e,t)}))},Sr=function(e){return e.parentNode?Sr(e.parentNode):e},kr=function(e){return dr(e).filter(Boolean).reduce((function(e,t){var n=t.getAttribute(Tn);return e.push.apply(e,n?function(e){for(var t=new Set,n=e.length,r=0;r<n;r+=1)for(var a=r+1;a<n;a+=1){var o=e[r].compareDocumentPosition(e[a]);(o&Node.DOCUMENT_POSITION_CONTAINED_BY)>0&&t.add(a),(o&Node.DOCUMENT_POSITION_CONTAINS)>0&&t.add(r)}return e.filter((function(e,n){return!t.has(n)}))}(pr(Sr(t).querySelectorAll("[".concat(Tn,'="').concat(n,'"]:not([').concat(Nn,'="disabled"])')))):[t]),e}),[])},Cr=function(e){return e.activeElement?e.activeElement.shadowRoot?Cr(e.activeElement.shadowRoot):e.activeElement:void 0},Dr=function(){return document.activeElement?document.activeElement.shadowRoot?Cr(document.activeElement.shadowRoot):document.activeElement:void 0},Or=function(e,t){return void 0===t&&(t=[]),t.push(e),e.parentNode&&Or(e.parentNode.host||e.parentNode,t),t},Pr=function(e,t){for(var n=Or(e),r=Or(t),a=0;a<n.length;a+=1){var o=n[a];if(r.indexOf(o)>=0)return o}return!1},Tr=function(e,t,n){var r=dr(e),a=dr(t),o=r[0],l=!1;return a.filter(Boolean).forEach((function(e){l=Pr(l||e,e)||l,n.filter(Boolean).forEach((function(e){var t=Pr(o,e);t&&(l=!l||xr(t,l)?t:Pr(t,l))}))})),l},Nr=function(e,t){var n=document&&Dr(),r=kr(e).filter(or),a=Tr(n||e,e,r),o=new Map,l=_r(r,o),i=Er(r,o).filter((function(e){var t=e.node;return or(t)}));if(i[0]||(i=l)[0]){var u,s,c,p,d=_r([a],o).map((function(e){return e.node})),f=(u=d,s=i,c=new Map,s.forEach((function(e){return c.set(e.node,e)})),u.map((function(e){return c.get(e)})).filter(lr)),h=f.map((function(e){return e.node})),m=function(e,t,n,r){var a=e.length,o=e[0],l=e[a-1],i=ar(n);if(!(n&&e.indexOf(n)>=0)){var u,s,c=void 0!==n?t.indexOf(n):-1,p=r?t.indexOf(r):c,d=r?e.indexOf(r):-1,f=c-p,h=t.indexOf(o),m=t.indexOf(l),g=(u=t,s=new Set,u.forEach((function(e){return s.add(ir(e,u))})),u.filter((function(e){return s.has(e)}))),y=(void 0!==n?g.indexOf(n):-1)-(r?g.indexOf(r):c),v=sr(e,0),b=sr(e,a-1);return-1===c||-1===d?cr:!f&&d>=0?d:c<=h&&i&&Math.abs(f)>1?b:c>=m&&i&&Math.abs(f)>1?v:f&&Math.abs(y)>1?d:c<=h?b:c>m?v:f?Math.abs(f)>1?d:(a+d+f)%a:void 0}}(h,d,n,t);if(m===cr){var g=wr(l.map((function(e){return e.node}))).filter((p=function(e,t){return e.reduce((function(e,n){return e.concat(function(e,t){return br((n=e.querySelectorAll("[".concat("data-autofocus-inside","]")),pr(n).map((function(e){return vr([e])})).reduce((function(e,t){return e.concat(t)}),[])),t);var n}(n,t))}),[])}(r,o),function(e){var t;return e.autofocus||!!(null===(t=er(e))||void 0===t?void 0:t.autofocus)||p.indexOf(e)>=0}));return{node:g&&g.length?ur(g):ur(wr(h))}}return void 0===m?m:f[m]}},Mr=0,Rr=!1;const jr=function(e,t,n){void 0===n&&(n={});var r,a,o=Nr(e,t);if(!Rr&&o){if(Mr>2)return console.error("FocusLock: focus-fighting detected. Only one focus management system could be active. See https://github.com/theKashey/focus-lock/#focus-fighting"),Rr=!0,void setTimeout((function(){Rr=!1}),1);Mr++,r=o.node,a=n.focusOptions,"focus"in r&&r.focus(a),"contentWindow"in r&&r.contentWindow&&r.contentWindow.focus(),Mr--}};var Ar=function(e){var t=document&&Dr();return!(!t||t.dataset&&t.dataset.focusGuard)&&kr(e).some((function(e){return xr(e,t)||function(e){return Boolean(pr(e.querySelectorAll("iframe")).some((function(e){return e===document.activeElement})))}(e)}))};function Ir(e){var t=window.setImmediate;void 0!==t?t(e):setTimeout(e,1)}var Fr=null,Lr=null,Ur=null,zr=!1,Yr=function(){return!0};function Wr(e,t,n,r){var a=null,o=e;do{var l=r[o];if(l.guard)l.node.dataset.focusAutoGuard&&(a=l);else{if(!l.lockItem)break;if(o!==e)return;a=null}}while((o+=n)!==t);a&&(a.node.tabIndex=0)}var Br=function(e){return e&&"current"in e?e.current:e},Hr=function e(t,n,r){return n&&(n.host===t&&(!n.activeElement||r.contains(n.activeElement))||n.parentNode&&e(t,n.parentNode,r))},qr=function(){var e,t,n,r,a,o,l,i=!1;if(Fr){var u=Fr,s=u.observed,c=u.persistentFocus,p=u.autoFocus,d=u.shards,f=u.crossFrame,h=u.focusOptions,m=s||Ur&&Ur.portaledElement,g=document&&document.activeElement;if(m){var y=[m].concat(d.map(Br).filter(Boolean));if(g&&!function(e){return(Fr.whiteList||Yr)(e)}(g)||(c||(f?Boolean(zr):"meanwhile"===zr)||!function(){return document&&document.activeElement===document.body||!!(e=document&&Dr())&&pr(document.querySelectorAll("[".concat("data-no-focus-lock","]"))).some((function(t){return xr(t,e)}));var e}()||!Lr&&p)&&(m&&!(Ar(y)||g&&function(e,t){return t.some((function(t){return Hr(e,t,t)}))}(g,y)||(e=g,Ur&&Ur.portaledElement===e))&&(document&&!Lr&&g&&!p?(g.blur&&g.blur(),document.body.focus()):(i=jr(y,Lr,{focusOptions:h}),Ur={})),zr=!1,Lr=document&&document.activeElement),document){var v=document&&document.activeElement,b=(n=kr(t=y).filter(or),r=Tr(t,t,n),a=new Map,o=Er([r],a,!0),l=Er(n,a).filter((function(e){var t=e.node;return or(t)})).map((function(e){return e.node})),o.map((function(e){var t=e.node;return{node:t,index:e.index,lockItem:l.indexOf(t)>=0,guard:ar(t)}}))),w=b.map((function(e){return e.node})).indexOf(v);w>-1&&(b.filter((function(e){var t=e.guard,n=e.node;return t&&n.dataset.focusAutoGuard})).forEach((function(e){return e.node.removeAttribute("tabIndex")})),Wr(w,b.length,1,b),Wr(w,-1,-1,b))}}}return i},Vr=function(e){qr()&&e&&(e.stopPropagation(),e.preventDefault())},$r=function(){return Ir(qr)},Zr=function(){zr="just",setTimeout((function(){zr="meanwhile"}),0)};Wn.assignSyncMedium((function(e){var t=e.target,n=e.currentTarget;n.contains(t)||(Ur={observerNode:n,portaledElement:t})})),Bn.assignMedium($r),Hn.assignMedium((function(e){return e({moveFocusInside:jr,focusInside:Ar})}));const Qr=(Kr=function(e){return e.filter((function(e){return!e.disabled}))},Gr=function(e){var t=e.slice(-1)[0];t&&!Fr&&(document.addEventListener("focusin",Vr),document.addEventListener("focusout",$r),window.addEventListener("blur",Zr));var n=Fr,r=n&&t&&t.id===n.id;Fr=t,n&&!r&&(n.onDeactivation(),e.filter((function(e){return e.id===n.id})).length||n.returnFocus(!t)),t?(Lr=null,r&&n.observed===t.observed||t.onActivation(),qr(),Ir(qr)):(document.removeEventListener("focusin",Vr),document.removeEventListener("focusout",$r),window.removeEventListener("blur",Zr),Lr=null)},function(e){var t,n=[];function r(){t=Kr(n.map((function(e){return e.props}))),Gr(t)}var a,o,l,u=function(a){var o,l;function u(){return a.apply(this,arguments)||this}l=a,(o=u).prototype=Object.create(l.prototype),o.prototype.constructor=o,Qn(o,l),u.peek=function(){return t};var s=u.prototype;return s.componentDidMount=function(){n.push(this),r()},s.componentDidUpdate=function(){r()},s.componentWillUnmount=function(){var e=n.indexOf(this);n.splice(e,1),r()},s.render=function(){return i.createElement(e,this.props)},u}(i.PureComponent);return a=u,o="displayName",l="SideEffect("+function(e){return e.displayName||e.name||"Component"}(e)+")",o in a?Object.defineProperty(a,o,{value:l,enumerable:!0,configurable:!0,writable:!0}):a[o]=l,u})((function(){return null}));var Kr,Gr,Xr=i.forwardRef((function(e,t){return i.createElement(Zn,Pn({sideCar:Qr,ref:t},e))})),Jr=Zn.propTypes||{};Jr.sideCar,function(e,t){if(null==e)return{};var n,r,a={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(a[n]=e[n])}(Jr,["sideCar"]),Xr.propTypes={};const ea=Xr;function ta(e){if(null===e)return null;const{left:t,top:n,height:r}=e;return{left:t,top:n+r}}function na(e,t){return t?{...e,width:t.getBoundingClientRect().width}:e}function ra(e){let{style:t,align:n}=e;const a=kn()("wpl-popover__arrows",{"wpl-popover__arrows__left":"left"===n,"wpl-popover__arrows__right":"right"===n,"wpl-popover__arrows__centre":"centre"===n});return(0,r.createElement)("div",{className:a,style:t})}const aa=function(e){const{position:t,children:n,popoverPosition:a,align:o,valign:l,hasArrow:u}=e,[s,c]=(0,i.useState)({arrow:{},content:{visibility:"none",...t}}),p=(0,i.useCallback)((e=>{if(e){const n=function(e,t,n,r,a,o){if(null===e||null===t)return{};if(!a)return{...e,visibility:"hidden"};const l=e.width?e.width:a.getBoundingClientRect().width,i=t.parentWidth-l-20,u=function(e,t,n,r){return"right"===r?e+t-n:"centre"===r?e-n/2:e}(t.left,t.width,e.width?e.width:l,n);return{...e,left:Math.min(i,u),top:o?e.top+5:e.top}}(t,a,o,0,e,u);c({content:n,arrow:na(n,e)})}}),[t]);return(0,r.createElement)(r.Fragment,null,u&&(0,r.createElement)(ra,{style:s.arrow,align:o}),(0,r.createElement)("div",{className:"wpl-popover__content",style:{...s.content,visibility:t&&t.left?"visible":"hidden",...null!==e.style?e.style:{}},ref:p},n))};function oa(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"bottom";const n=document.getElementById(ct);if(null===e||null===n)return{};const r=n.getBoundingClientRect(),{height:a,width:o,left:l,top:i}=e.getBoundingClientRect();return{left:"bottom"===t?l-r.left:l+o/2-r.left-7,top:i-r.top+1,width:o,height:a,parentWidth:r.width,parentHeight:r.height,ref:e}}const la=function(e){const{children:t,className:n,align:a="left",valign:o="bottom",onClose:l,hasArrow:u=!1,popoverPosition:s,style:p=null,focusLock:d=!0}=e;return(0,i.useEffect)((()=>(window.addEventListener("resize",l),()=>{window.removeEventListener("resize",l)})),[]),(0,c.createPortal)((0,r.createElement)(On,{className:kn()("wpl-popover",n),onOutside:function(e){!1===Dn(e,s.ref)&&"Escape"!==e.key||l()}},(0,r.createElement)(ea,{returnFocus:!0,disabled:!d},(0,r.createElement)(aa,{position:ta(s),popoverPosition:s,align:a,hasArrow:u,valign:o,style:p},t))),pt("wpl-dropdown-portal"))},ia=function(e){const{renderContent:t,className:n,renderToggle:a,align:o="left",valign:l="bottom",hasArrow:u=!1,matchMinimum:s=!1,disabled:c=!1,onClose:p}=e,[d,f]=(0,i.useState)(!1),[h,m]=(0,i.useState)(null),g=(0,i.useRef)(null),y=e=>{const t=oa(g.current,l);e&&e.stopPropagation(),c||(m(t),f(!d))};return(0,r.createElement)(r.Fragment,null,(0,r.createElement)("div",{className:kn()("wpl-popover__toggle",n,c&&"wpl-popover__toggle__disabled"),ref:g,onKeyDown:function(e){e.key&&"Space"===e.code&&y()}},a(d,y)),d&&(0,r.createElement)(la,{align:o,valign:l,hasArrow:u,className:n,onClose:function(){f(!1),p&&p()},popoverPosition:h,style:s?{minWidth:h.width+"px"}:null},t((()=>f(!1)))))},ua=function(e){let{onClick:t}=e;return(0,r.createElement)("svg",{height:"20",width:"20",viewBox:"0 0 20 20","aria-hidden":"true",focusable:"false",onClick:t&&t},(0,r.createElement)("path",{d:"M4.516 7.548c0.436-0.446 1.043-0.481 1.576 0l3.908 3.747 3.908-3.747c0.533-0.481 1.141-0.446 1.574 0 0.436 0.445 0.408 1.197 0 1.615-0.406 0.418-4.695 4.502-4.695 4.502-0.217 0.223-0.502 0.335-0.787 0.335s-0.57-0.112-0.789-0.335c0 0-4.287-4.084-4.695-4.502s-0.436-1.17 0-1.615z"}))},sa=function(e){let{isOpen:t=!1}=e;return t?(0,r.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"24",height:"24",role:"img","aria-hidden":"true",focusable:"false"},(0,r.createElement)("path",{d:"M11 13h2v-2h-2v2zm-6 0h2v-2H5v2zm12-2v2h2v-2h-2z"})):(0,r.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"24",height:"24",role:"img","aria-hidden":"true",focusable:"false"},(0,r.createElement)("path",{d:"M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z"}))},ca=function(e){let{menu:t,align:n="right",disabled:a=!1}=e;return(0,r.createElement)(ia,{align:n,hasArrow:!0,renderToggle:(e,t)=>(0,r.createElement)("button",{type:"button",className:"wpl-dropdownmenu",onClick:t,disabled:a},(0,r.createElement)(sa,{isOpen:e})),renderContent:e=>(0,r.createElement)("ul",{className:"wpl-dropdownmenu__menu",onClick:e},t.map(((e,t)=>(0,r.createElement)("li",{key:t},e))))})};const pa=function(){return(0,r.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},(0,r.createElement)("circle",{transform:"translate(8 0)",cx:"0",cy:"16",r:"0"},(0,r.createElement)("animate",{attributeName:"r",values:"0; 4; 0; 0",dur:"1.2s",repeatCount:"indefinite",begin:"0",keyTimes:"0;0.2;0.7;1",keySplines:"0.2 0.2 0.4 0.8;0.2 0.6 0.4 0.8;0.2 0.6 0.4 0.8",calcMode:"spline"})),(0,r.createElement)("circle",{transform:"translate(16 0)",cx:"0",cy:"16",r:"0"},(0,r.createElement)("animate",{attributeName:"r",values:"0; 4; 0; 0",dur:"1.2s",repeatCount:"indefinite",begin:"0.3",keyTimes:"0;0.2;0.7;1",keySplines:"0.2 0.2 0.4 0.8;0.2 0.6 0.4 0.8;0.2 0.6 0.4 0.8",calcMode:"spline"})),(0,r.createElement)("circle",{transform:"translate(24 0)",cx:"0",cy:"16",r:"0"},(0,r.createElement)("animate",{attributeName:"r",values:"0; 4; 0; 0",dur:"1.2s",repeatCount:"indefinite",begin:"0.6",keyTimes:"0;0.2;0.7;1",keySplines:"0.2 0.2 0.4 0.8;0.2 0.6 0.4 0.8;0.2 0.6 0.4 0.8",calcMode:"spline"})))};var da=n(7763),fa=n.n(da);const ha=function(e){const{options:t,value:n,onSelect:a,onClose:o}=e;return(0,r.createElement)("ul",null,t.map(((e,t)=>(0,r.createElement)("li",{key:t},(0,r.createElement)("a",{href:"#",onClick:t=>function(e,t){e.preventDefault(),a(t),o()}(t,e)},(0,r.createElement)(fa(),{searchWords:[n],textToHighlight:e.title,autoEscape:!0}))))))},ma=function(e){const{placeholder:t="",onChange:n,value:a,fetchData:o,name:l="text",disabled:u=!1,className:s,maxChoices:c=-1,maxLength:p=0,canMakeRequest:d=(e=>e.length>0),onBlur:f,getLabel:h,setLabel:m,loadOnFocus:g=!1,onlyChoices:y=!1}=e,[v,b]=(0,i.useState)(!1),[w,E]=(0,i.useState)([]),[_,x]=(0,i.useState)(Array.isArray(a)?"":a),S=(0,i.useRef)(null),k={"wpl-dropdowntext__suggestion__hide":c>0&&Array.isArray(a)&&a.length>=c,"wpl-dropdowntext__suggestion":c>1},C=function(e,t,n){var r=this,a=(0,i.useRef)(null),o=(0,i.useRef)(0),l=(0,i.useRef)(null),u=(0,i.useRef)([]),s=(0,i.useRef)(),c=(0,i.useRef)(),p=(0,i.useRef)(e),d=(0,i.useRef)(!0);(0,i.useEffect)((function(){p.current=e}),[e]);var f=!t&&0!==t&&"undefined"!=typeof window;if("function"!=typeof e)throw new TypeError("Expected a function");t=+t||0;var h=!!(n=n||{}).leading,m=!("trailing"in n)||!!n.trailing,g="maxWait"in n,y=g?Math.max(+n.maxWait||0,t):null;(0,i.useEffect)((function(){return d.current=!0,function(){d.current=!1}}),[]);var v=(0,i.useMemo)((function(){var e=function(e){var t=u.current,n=s.current;return u.current=s.current=null,o.current=e,c.current=p.current.apply(n,t)},n=function(e,t){f&&cancelAnimationFrame(l.current),l.current=f?requestAnimationFrame(e):setTimeout(e,t)},i=function(e){if(!d.current)return!1;var n=e-a.current;return!a.current||n>=t||n<0||g&&e-o.current>=y},v=function(t){return l.current=null,m&&u.current?e(t):(u.current=s.current=null,c.current)},b=function e(){var r=Date.now();if(i(r))return v(r);if(d.current){var l=t-(r-a.current),u=g?Math.min(l,y-(r-o.current)):l;n(e,u)}},w=function(){var p=Date.now(),f=i(p);if(u.current=[].slice.call(arguments),s.current=r,a.current=p,f){if(!l.current&&d.current)return o.current=a.current,n(b,t),h?e(a.current):c.current;if(g)return n(b,t),e(a.current)}return l.current||n(b,t),c.current};return w.cancel=function(){l.current&&(f?cancelAnimationFrame(l.current):clearTimeout(l.current)),o.current=0,u.current=a.current=s.current=l.current=null},w.isPending=function(){return!!l.current},w.flush=function(){return l.current?v(Date.now()):c.current},w}),[h,g,t,y,m,f]);return v}(D,450);function D(e){o&&(b(!0),o(e).then((e=>{document.activeElement===S.current&&E(e),b(!1)})).catch((e=>{console.error("Failed to get suggestions: ",e),E([]),b(!1)})))}function O(e){if(h)return T(e).map((t=>h(t,e)))}function P(e){if(c>0){if(!T(a).find((t=>t===`${e.value}`))){const t=[`${e.value}`].concat(T(a).filter((t=>t!==`${e.value}`))).slice(0,c);n(1!==c||y?t:t[0],[e.title].concat(O(t).slice(1))),m(e.value,e.title)}x("")}else x(e.value),n(e.value,O(a));E([])}function T(e){return Array.isArray(e)?e:e?[e]:[]}return(0,i.useEffect)((()=>{a!==_&&x(Array.isArray(a)?"":a)}),[a]),(0,r.createElement)("div",{className:kn()("wpl-dropdowntext",s,k)},c>0&&T(a).map((e=>(0,r.createElement)(Cn,{key:e,title:e,onCancel:()=>function(e){const t=T(a).filter((t=>t!==e));m(e,null),Array.isArray(a)?n(1===c?t[0]:t,O(t)):n(""),S.current.focus()}(e),disabled:u},h?h(e,a):e))),(0,r.createElement)("input",{type:"text",className:kn()("regular-text",{"wpl-dropdowntext__max":c>=0&&T(a).length>=c}),name:l,value:_,disabled:u,onChange:function(e){x(e.target.value),c<1&&n(e.target.value),o&&C&&(d(e.target.value.trim())?C(e.target.value):E([]))},placeholder:t,ref:S,onFocus:function(){g&&0===a.length&&D("")},onBlur:function(e){if(e.relatedTarget&&e.relatedTarget.closest(".wpl-dropdowntext__suggestions"))return;const t=f?f(_):_;0===w.length?y?x(""):c>0&&o?P({value:t,label:t}):n(t):t!==_&&x(t),b(!1)},onKeyDown:function(e){"Enter"===e.code&&(b(!1),E([]))}}),v&&(0,r.createElement)("div",{className:"wpl-dropdowntext__loading"},(0,r.createElement)(pa,null)),w.length>0&&(0,r.createElement)(la,{align:"left",onClose:()=>E([]),popoverPosition:oa(S.current),className:"wpl-dropdowntext__suggestions",focusLock:!1},(0,r.createElement)(ha,{options:w,value:_,onSelect:P,onClose:()=>E([])})))},ga=e=>{let{option:t,onSelect:n,selected:a,label:o}=e;const{value:l,disabled:i=!1}=t;return(0,r.createElement)("p",null,(0,r.createElement)("label",{"aria-label":o||t.label},(0,r.createElement)("input",{type:"checkbox",name:l,onChange:n,checked:-1!==a.indexOf(String(l))||-1!==a.indexOf(parseInt(l,10)),disabled:i,tabIndex:0}),t.label))},ya=function(e){const{option:t,selected:n,onSelect:a}=e,{options:o,label:l}=t;return(0,r.createElement)("div",{className:"wpl-multioption__group"},(0,r.createElement)("h5",null,l),o.map(((e,t)=>(0,r.createElement)(ga,{option:e,onSelect:a,selected:n,label:l+" "+e.label,key:t}))))},va=function(e){const{option:t,selected:n,onApply:a,multiple:o}=e,{options:l}=t,i=e=>{const{checked:t,name:r,value:l}=e.target;a(t?o?n.concat([r]):[r]:n.filter((e=>e!==r)),r,0!==parseInt(l,10))};return l?(0,r.createElement)(ya,{option:t,selected:n,onSelect:i}):(0,r.createElement)(ga,{option:t,selected:n,onSelect:i})};function ba(e,t){for(let n=0;n<e.length;n++){const r=e[n];if(r.value===t||t===parseInt(r.value,10))return r;if(r.options){const e=ba(r.options,t);if(e)return e}}return null}function wa(e){const{selected:t,options:n,disabled:a,onApply:o}=e,l=e.customBadge?e.customBadge:e=>e,i=l(t);return 0===i.length?null:i.slice(0,3).map((e=>{const l=ba(n,e);return null===l?null:(0,r.createElement)(Cn,{key:e,small:!0,onCancel:n=>function(e,t,n,r){e.preventDefault(),e.stopPropagation(),t(r,n,!1)}(n,o,e,t.filter((t=>t!==e))),disabled:a},l.alt||l.label)})).concat([i.length>3?(0,r.createElement)("span",{key:"end"},"..."):null])}const Ea=function(e){const{options:t,selected:n,onApply:a,title:o="",badges:l=!1,disabled:i=!1,multiple:u=!1,className:s,hideTitle:c=!1}=e,p=wa(e);return(0,r.createElement)(ia,{renderToggle:(t,a)=>(0,r.createElement)("div",{className:kn()("button","action","wpl-multioption__button",i&&"wpl-multioption__disabled",t?"wpl-multioption__button_enabled":null),onClick:a,tabIndex:0,"aria-label":e["aria-label"]||o||""},function(e,t){return!1===t||0===e.length}(n,c)&&o.length>0&&(0,r.createElement)("h5",null,o),l&&p,(0,r.createElement)(ua,null)),disabled:i,align:"right",matchMinimum:!0,renderContent:()=>(0,r.createElement)("div",{className:kn()("wpl-multioption",s)},t.map(((e,t)=>(0,r.createElement)(va,{option:e,selected:n,key:t,onApply:a,multiple:u||e.multiple}))))})},_a=e=>{let{url:t,children:n,title:a,className:o}=e;return(0,r.createElement)("a",{href:t,target:"_blank",rel:"noopener noreferrer",title:a,className:o},n)},xa=e=>{const{item:t,isCurrent:n,onClick:a,isLast:o,urlBase:l}=e,i=l+(""===t.value?"":"&sub="+t.value);return(0,r.createElement)("li",null,(0,r.createElement)("a",{className:n?"current":"",href:i,onClick:e=>{e.preventDefault(),a(t.value,i)}},t.name)," ",!o&&"|"," ")},Sa=(e,t,n)=>e===t.value||e===n&&""===t.value,ka=e=>{const{onChangePage:t,menu:n,home:a,urlBase:o,currentPage:l}=e;return n.length<2?null:(0,r.createElement)("div",{className:"subsubsub-container"},(0,r.createElement)("ul",{className:"subsubsub"},n.map(((e,i)=>(0,r.createElement)(xa,{key:i,item:e,isCurrent:Sa(l,e,a),isLast:i===n.length-1,onClick:t,urlBase:o})))))},Ca=function(e){let{onClose:t,children:n,className:a}=e;return(0,r.createElement)(On,{className:"wpl-click-outside",onOutside:function(e){e.target.classList.contains("wpl-modal_main")&&t()}},(0,r.createElement)("div",{className:kn()("wpl-modal_content",a)},(0,r.createElement)("div",{className:"wpl-modal_close"},(0,r.createElement)("button",{type:"button",onClick:t},"✖")),n))},Da="wpl-modal_shown",Oa=function(e){const{padding:t=!0}=e;(0,i.useEffect)((()=>(document.body.classList.add(Da),()=>{document.body.classList.remove(Da)})));const n=kn()({"wpl-modal_wrapper":!0,"wpl-modal_wrapper-padding":t});return(0,r.createElement)("div",{className:n},(0,r.createElement)("div",{className:"wpl-modal_backdrop"}),(0,r.createElement)("div",{className:"wpl-modal_main"},(0,r.createElement)(Ca,e)))},Pa=e=>(0,c.createPortal)((0,r.createElement)(Oa,e),pt("wpl-modal"));let Ta=!1;function Na(e){let{notices:t}=e;return(0,r.createElement)(r.Fragment,null,t[t.length-1]+(t.length>1?" ("+t.length+")":""))}const Ma=function(e){const{notices:t,onClear:n,snackBarViewText:a}=e,[o,l]=(0,i.useState)(!1);if((0,i.useEffect)((()=>(t.length>0&&(clearTimeout(Ta),o?l(!1):Ta=setTimeout((()=>l(!0)),5e3)),()=>{clearTimeout(Ta)})),[t]),0===t.length)return null;const u=kn()("notice","notice-info","wpl-notice",o&&"wpl-notice_shrunk");return(0,r.createElement)("div",{className:u,onClick:function(){o?l(!1):n()}},(0,r.createElement)("div",{className:"closer"},(0,r.createElement)("span",{className:"dashicons dashicons-yes"})),(0,r.createElement)("p",null,o?(0,r.createElement)("span",{className:"dashicons dashicons-warning",title:a}):(0,r.createElement)(Na,{notices:t})))},Ra=()=>(0,r.createElement)("div",{className:"wpl-placeholder__container"},(0,r.createElement)("div",{className:"wpl-placeholder__loading"}));var ja=n(5697),Aa=n.n(ja);const Ia=e=>{const{value:t,label:n,disabled:a=!1}=e;return"object"==typeof t?(0,r.createElement)("optgroup",{label:n,disabled:a},t.map(((e,t)=>(0,r.createElement)(Ia,{label:e.label,value:e.value,disabled:e.disabled||!1,key:t})))):(0,r.createElement)("option",{value:t,disabled:a},n)},Fa=Ia,La=e=>{const{items:t,value:n,name:a,onChange:o,disabled:l=!1,className:i}=e;return(0,r.createElement)("select",{name:a,value:n,onChange:o,disabled:l,className:i},t.map(((e,t)=>(0,r.createElement)(Fa,{value:e.value,label:e.label,disabled:e.disabled||!1,key:t}))))};La.propTypes={items:Aa().array.isRequired,value:Aa().oneOfType([Aa().string,Aa().number]).isRequired,name:Aa().string.isRequired,onChange:Aa().func.isRequired,disabled:Aa().bool};const Ua=La,za=e=>{const{size:t=""}=e,n=kn()("wpl-spinner__container",t&&" spinner-"+t);return(0,r.createElement)("div",{className:n},(0,r.createElement)("span",{className:"wpl-spinner__item"}))};var Ya=new Map([["aac","audio/aac"],["abw","application/x-abiword"],["arc","application/x-freearc"],["avif","image/avif"],["avi","video/x-msvideo"],["azw","application/vnd.amazon.ebook"],["bin","application/octet-stream"],["bmp","image/bmp"],["bz","application/x-bzip"],["bz2","application/x-bzip2"],["cda","application/x-cdf"],["csh","application/x-csh"],["css","text/css"],["csv","text/csv"],["doc","application/msword"],["docx","application/vnd.openxmlformats-officedocument.wordprocessingml.document"],["eot","application/vnd.ms-fontobject"],["epub","application/epub+zip"],["gz","application/gzip"],["gif","image/gif"],["heic","image/heic"],["heif","image/heif"],["htm","text/html"],["html","text/html"],["ico","image/vnd.microsoft.icon"],["ics","text/calendar"],["jar","application/java-archive"],["jpeg","image/jpeg"],["jpg","image/jpeg"],["js","text/javascript"],["json","application/json"],["jsonld","application/ld+json"],["mid","audio/midi"],["midi","audio/midi"],["mjs","text/javascript"],["mp3","audio/mpeg"],["mp4","video/mp4"],["mpeg","video/mpeg"],["mpkg","application/vnd.apple.installer+xml"],["odp","application/vnd.oasis.opendocument.presentation"],["ods","application/vnd.oasis.opendocument.spreadsheet"],["odt","application/vnd.oasis.opendocument.text"],["oga","audio/ogg"],["ogv","video/ogg"],["ogx","application/ogg"],["opus","audio/opus"],["otf","font/otf"],["png","image/png"],["pdf","application/pdf"],["php","application/x-httpd-php"],["ppt","application/vnd.ms-powerpoint"],["pptx","application/vnd.openxmlformats-officedocument.presentationml.presentation"],["rar","application/vnd.rar"],["rtf","application/rtf"],["sh","application/x-sh"],["svg","image/svg+xml"],["swf","application/x-shockwave-flash"],["tar","application/x-tar"],["tif","image/tiff"],["tiff","image/tiff"],["ts","video/mp2t"],["ttf","font/ttf"],["txt","text/plain"],["vsd","application/vnd.visio"],["wav","audio/wav"],["weba","audio/webm"],["webm","video/webm"],["webp","image/webp"],["woff","font/woff"],["woff2","font/woff2"],["xhtml","application/xhtml+xml"],["xls","application/vnd.ms-excel"],["xlsx","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],["xml","application/xml"],["xul","application/vnd.mozilla.xul+xml"],["zip","application/zip"],["7z","application/x-7z-compressed"],["mkv","video/x-matroska"],["mov","video/quicktime"],["msg","application/vnd.ms-outlook"]]);function Wa(e,t){var n=function(e){var t=e.name;if(t&&-1!==t.lastIndexOf(".")&&!e.type){var n=t.split(".").pop().toLowerCase(),r=Ya.get(n);r&&Object.defineProperty(e,"type",{value:r,writable:!1,configurable:!1,enumerable:!0})}return e}(e);if("string"!=typeof n.path){var r=e.webkitRelativePath;Object.defineProperty(n,"path",{value:"string"==typeof t?t:"string"==typeof r&&r.length>0?r:e.name,writable:!1,configurable:!1,enumerable:!0})}return n}var Ba=[".DS_Store","Thumbs.db"];function Ha(e){return"object"==typeof e&&null!==e}function qa(e){return Qa(e.target.files).map((function(e){return Wa(e)}))}function Va(e){return An(this,void 0,void 0,(function(){return In(this,(function(t){switch(t.label){case 0:return[4,Promise.all(e.map((function(e){return e.getFile()})))];case 1:return[2,t.sent().map((function(e){return Wa(e)}))]}}))}))}function $a(e,t){return An(this,void 0,void 0,(function(){var n;return In(this,(function(r){switch(r.label){case 0:return e.items?(n=Qa(e.items).filter((function(e){return"file"===e.kind})),"drop"!==t?[2,n]:[4,Promise.all(n.map(Ka))]):[3,2];case 1:return[2,Za(Ga(r.sent()))];case 2:return[2,Za(Qa(e.files).map((function(e){return Wa(e)})))]}}))}))}function Za(e){return e.filter((function(e){return-1===Ba.indexOf(e.name)}))}function Qa(e){if(null===e)return[];for(var t=[],n=0;n<e.length;n++){var r=e[n];t.push(r)}return t}function Ka(e){if("function"!=typeof e.webkitGetAsEntry)return Xa(e);var t=e.webkitGetAsEntry();return t&&t.isDirectory?eo(t):Xa(e)}function Ga(e){return e.reduce((function(e,t){return Ln(Ln([],Fn(e),!1),Fn(Array.isArray(t)?Ga(t):[t]),!1)}),[])}function Xa(e){var t=e.getAsFile();if(!t)return Promise.reject("".concat(e," is not a File"));var n=Wa(t);return Promise.resolve(n)}function Ja(e){return An(this,void 0,void 0,(function(){return In(this,(function(t){return[2,e.isDirectory?eo(e):to(e)]}))}))}function eo(e){var t=e.createReader();return new Promise((function(e,n){var r=[];!function a(){var o=this;t.readEntries((function(t){return An(o,void 0,void 0,(function(){var o,l,i;return In(this,(function(u){switch(u.label){case 0:if(t.length)return[3,5];u.label=1;case 1:return u.trys.push([1,3,,4]),[4,Promise.all(r)];case 2:return o=u.sent(),e(o),[3,4];case 3:return l=u.sent(),n(l),[3,4];case 4:return[3,6];case 5:i=Promise.all(t.map(Ja)),r.push(i),a(),u.label=6;case 6:return[2]}}))}))}),(function(e){n(e)}))}()}))}function to(e){return An(this,void 0,void 0,(function(){return In(this,(function(t){return[2,new Promise((function(t,n){e.file((function(n){var r=Wa(n,e.fullPath);t(r)}),(function(e){n(e)}))}))]}))}))}var no=n(8363);function ro(e){return function(e){if(Array.isArray(e))return so(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||uo(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ao(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function oo(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ao(Object(n),!0).forEach((function(t){lo(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ao(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function lo(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function io(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,a,o=[],_n=!0,l=!1;try{for(n=n.call(e);!(_n=(r=n.next()).done)&&(o.push(r.value),!t||o.length!==t);_n=!0);}catch(e){l=!0,a=e}finally{try{_n||null==n.return||n.return()}finally{if(l)throw a}}return o}}(e,t)||uo(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function uo(e,t){if(e){if("string"==typeof e)return so(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?so(e,t):void 0}}function so(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var co=function(e){e=Array.isArray(e)&&1===e.length?e[0]:e;var t=Array.isArray(e)?"one of ".concat(e.join(", ")):e;return{code:"file-invalid-type",message:"File type must be ".concat(t)}},po=function(e){return{code:"file-too-large",message:"File is larger than ".concat(e," ").concat(1===e?"byte":"bytes")}},fo=function(e){return{code:"file-too-small",message:"File is smaller than ".concat(e," ").concat(1===e?"byte":"bytes")}},ho={code:"too-many-files",message:"Too many files"};function mo(e,t){var n="application/x-moz-file"===e.type||(0,no.Z)(e,t);return[n,n?null:co(t)]}function go(e,t,n){if(yo(e.size))if(yo(t)&&yo(n)){if(e.size>n)return[!1,po(n)];if(e.size<t)return[!1,fo(t)]}else{if(yo(t)&&e.size<t)return[!1,fo(t)];if(yo(n)&&e.size>n)return[!1,po(n)]}return[!0,null]}function yo(e){return null!=e}function vo(e){var t=e.files,n=e.accept,r=e.minSize,a=e.maxSize,o=e.multiple,l=e.maxFiles,i=e.validator;return!(!o&&t.length>1||o&&l>=1&&t.length>l)&&t.every((function(e){var t=io(mo(e,n),1)[0],o=io(go(e,r,a),1)[0],l=i?i(e):null;return t&&o&&!l}))}function bo(e){return"function"==typeof e.isPropagationStopped?e.isPropagationStopped():void 0!==e.cancelBubble&&e.cancelBubble}function wo(e){return e.dataTransfer?Array.prototype.some.call(e.dataTransfer.types,(function(e){return"Files"===e||"application/x-moz-file"===e})):!!e.target&&!!e.target.files}function Eo(e){e.preventDefault()}function _o(e){return-1!==e.indexOf("MSIE")||-1!==e.indexOf("Trident/")}function xo(e){return-1!==e.indexOf("Edge/")}function So(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:window.navigator.userAgent;return _o(e)||xo(e)}function ko(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),a=1;a<n;a++)r[a-1]=arguments[a];return t.some((function(t){return!bo(e)&&t&&t.apply(void 0,[e].concat(r)),bo(e)}))}}function Co(){return"showOpenFilePicker"in window}function Do(e){return yo(e)?[{accept:Object.entries(e).filter((function(e){var t=io(e,2),n=t[0],r=t[1],a=!0;return No(n)||(console.warn('Skipped "'.concat(n,'" because it is not a valid MIME type. Check https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types for a list of valid MIME types.')),a=!1),Array.isArray(r)&&r.every(Mo)||(console.warn('Skipped "'.concat(n,'" because an invalid file extension was provided.')),a=!1),a})).reduce((function(e,t){var n=io(t,2),r=n[0],a=n[1];return oo(oo({},e),{},lo({},r,a))}),{})}]:e}function Oo(e){if(yo(e))return Object.entries(e).reduce((function(e,t){var n=io(t,2),r=n[0],a=n[1];return[].concat(ro(e),[r],ro(a))}),[]).filter((function(e){return No(e)||Mo(e)})).join(",")}function Po(e){return e instanceof DOMException&&("AbortError"===e.name||e.code===e.ABORT_ERR)}function To(e){return e instanceof DOMException&&("SecurityError"===e.name||e.code===e.SECURITY_ERR)}function No(e){return"audio/*"===e||"video/*"===e||"image/*"===e||"text/*"===e||/\w+\/[-+.\w]+/g.test(e)}function Mo(e){return/^.*\.[\w]+$/.test(e)}var Ro=["children"],jo=["open"],Ao=["refKey","role","onKeyDown","onFocus","onBlur","onClick","onDragEnter","onDragOver","onDragLeave","onDrop"],Io=["refKey","onChange","onClick"];function Fo(e){return function(e){if(Array.isArray(e))return zo(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||Uo(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Lo(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,a,o=[],_n=!0,l=!1;try{for(n=n.call(e);!(_n=(r=n.next()).done)&&(o.push(r.value),!t||o.length!==t);_n=!0);}catch(e){l=!0,a=e}finally{try{_n||null==n.return||n.return()}finally{if(l)throw a}}return o}}(e,t)||Uo(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Uo(e,t){if(e){if("string"==typeof e)return zo(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?zo(e,t):void 0}}function zo(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Yo(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Wo(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Yo(Object(n),!0).forEach((function(t){Bo(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Yo(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Bo(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ho(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n,r,a={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}var qo=(0,i.forwardRef)((function(e,t){var n=e.children,r=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=Wo(Wo({},Vo),e),n=t.accept,r=t.disabled,a=t.getFilesFromEvent,o=t.maxSize,l=t.minSize,u=t.multiple,s=t.maxFiles,c=t.onDragEnter,p=t.onDragLeave,d=t.onDragOver,f=t.onDrop,h=t.onDropAccepted,m=t.onDropRejected,g=t.onFileDialogCancel,y=t.onFileDialogOpen,v=t.useFsAccessApi,b=t.autoFocus,w=t.preventDropOnDocument,E=t.noClick,_=t.noKeyboard,x=t.noDrag,S=t.noDragEventsBubbling,k=t.onError,C=t.validator,D=(0,i.useMemo)((function(){return Oo(n)}),[n]),O=(0,i.useMemo)((function(){return Do(n)}),[n]),P=(0,i.useMemo)((function(){return"function"==typeof y?y:Ko}),[y]),T=(0,i.useMemo)((function(){return"function"==typeof g?g:Ko}),[g]),N=(0,i.useRef)(null),M=(0,i.useRef)(null),R=Lo((0,i.useReducer)(Qo,Zo),2),j=R[0],A=R[1],I=j.isFocused,F=j.isFileDialogActive,L=(0,i.useRef)("undefined"!=typeof window&&window.isSecureContext&&v&&Co()),U=function(){!L.current&&F&&setTimeout((function(){M.current&&(M.current.files.length||(A({type:"closeDialog"}),T()))}),300)};(0,i.useEffect)((function(){return window.addEventListener("focus",U,!1),function(){window.removeEventListener("focus",U,!1)}}),[M,F,T,L]);var z=(0,i.useRef)([]),Y=function(e){N.current&&N.current.contains(e.target)||(e.preventDefault(),z.current=[])};(0,i.useEffect)((function(){return w&&(document.addEventListener("dragover",Eo,!1),document.addEventListener("drop",Y,!1)),function(){w&&(document.removeEventListener("dragover",Eo),document.removeEventListener("drop",Y))}}),[N,w]),(0,i.useEffect)((function(){return!r&&b&&N.current&&N.current.focus(),function(){}}),[N,b,r]);var W=(0,i.useCallback)((function(e){k?k(e):console.error(e)}),[k]),B=(0,i.useCallback)((function(e){e.preventDefault(),e.persist(),ne(e),z.current=[].concat(Fo(z.current),[e.target]),wo(e)&&Promise.resolve(a(e)).then((function(t){if(!bo(e)||S){var n=t.length,r=n>0&&vo({files:t,accept:D,minSize:l,maxSize:o,multiple:u,maxFiles:s,validator:C});A({isDragAccept:r,isDragReject:n>0&&!r,isDragActive:!0,type:"setDraggedFiles"}),c&&c(e)}})).catch((function(e){return W(e)}))}),[a,c,W,S,D,l,o,u,s,C]),H=(0,i.useCallback)((function(e){e.preventDefault(),e.persist(),ne(e);var t=wo(e);if(t&&e.dataTransfer)try{e.dataTransfer.dropEffect="copy"}catch(e){}return t&&d&&d(e),!1}),[d,S]),q=(0,i.useCallback)((function(e){e.preventDefault(),e.persist(),ne(e);var t=z.current.filter((function(e){return N.current&&N.current.contains(e)})),n=t.indexOf(e.target);-1!==n&&t.splice(n,1),z.current=t,t.length>0||(A({type:"setDraggedFiles",isDragActive:!1,isDragAccept:!1,isDragReject:!1}),wo(e)&&p&&p(e))}),[N,p,S]),V=(0,i.useCallback)((function(e,t){var n=[],r=[];e.forEach((function(e){var t=Lo(mo(e,D),2),a=t[0],i=t[1],u=Lo(go(e,l,o),2),s=u[0],c=u[1],p=C?C(e):null;if(a&&s&&!p)n.push(e);else{var d=[i,c];p&&(d=d.concat(p)),r.push({file:e,errors:d.filter((function(e){return e}))})}})),(!u&&n.length>1||u&&s>=1&&n.length>s)&&(n.forEach((function(e){r.push({file:e,errors:[ho]})})),n.splice(0)),A({acceptedFiles:n,fileRejections:r,type:"setFiles"}),f&&f(n,r,t),r.length>0&&m&&m(r,t),n.length>0&&h&&h(n,t)}),[A,u,D,l,o,s,f,h,m,C]),$=(0,i.useCallback)((function(e){e.preventDefault(),e.persist(),ne(e),z.current=[],wo(e)&&Promise.resolve(a(e)).then((function(t){bo(e)&&!S||V(t,e)})).catch((function(e){return W(e)})),A({type:"reset"})}),[a,V,W,S]),Z=(0,i.useCallback)((function(){if(L.current){A({type:"openDialog"}),P();var e={multiple:u,types:O};window.showOpenFilePicker(e).then((function(e){return a(e)})).then((function(e){V(e,null),A({type:"closeDialog"})})).catch((function(e){Po(e)?(T(e),A({type:"closeDialog"})):To(e)?(L.current=!1,M.current?(M.current.value=null,M.current.click()):W(new Error("Cannot open the file picker because the https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API is not supported and no <input> was provided."))):W(e)}))}else M.current&&(A({type:"openDialog"}),P(),M.current.value=null,M.current.click())}),[A,P,T,v,V,W,O,u]),Q=(0,i.useCallback)((function(e){N.current&&N.current.isEqualNode(e.target)&&(" "!==e.key&&"Enter"!==e.key&&32!==e.keyCode&&13!==e.keyCode||(e.preventDefault(),Z()))}),[N,Z]),K=(0,i.useCallback)((function(){A({type:"focus"})}),[]),G=(0,i.useCallback)((function(){A({type:"blur"})}),[]),X=(0,i.useCallback)((function(){E||(So()?setTimeout(Z,0):Z())}),[E,Z]),J=function(e){return r?null:e},ee=function(e){return _?null:J(e)},te=function(e){return x?null:J(e)},ne=function(e){S&&e.stopPropagation()},re=(0,i.useMemo)((function(){return function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.refKey,n=void 0===t?"ref":t,a=e.role,o=e.onKeyDown,l=e.onFocus,i=e.onBlur,u=e.onClick,s=e.onDragEnter,c=e.onDragOver,p=e.onDragLeave,d=e.onDrop,f=Ho(e,Ao);return Wo(Wo(Bo({onKeyDown:ee(ko(o,Q)),onFocus:ee(ko(l,K)),onBlur:ee(ko(i,G)),onClick:J(ko(u,X)),onDragEnter:te(ko(s,B)),onDragOver:te(ko(c,H)),onDragLeave:te(ko(p,q)),onDrop:te(ko(d,$)),role:"string"==typeof a&&""!==a?a:"presentation"},n,N),r||_?{}:{tabIndex:0}),f)}}),[N,Q,K,G,X,B,H,q,$,_,x,r]),ae=(0,i.useCallback)((function(e){e.stopPropagation()}),[]),oe=(0,i.useMemo)((function(){return function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.refKey,n=void 0===t?"ref":t,r=e.onChange,a=e.onClick,o=Ho(e,Io);return Wo(Wo({},Bo({accept:D,multiple:u,type:"file",style:{display:"none"},onChange:J(ko(r,$)),onClick:J(ko(a,ae)),tabIndex:-1},n,M)),o)}}),[M,n,u,$,r]);return Wo(Wo({},j),{},{isFocused:I&&!r,getRootProps:re,getInputProps:oe,rootRef:N,inputRef:M,open:J(Z)})}(Ho(e,Ro)),a=r.open,o=Ho(r,jo);return(0,i.useImperativeHandle)(t,(function(){return{open:a}}),[a]),i.createElement(i.Fragment,null,n(Wo(Wo({},o),{},{open:a})))}));qo.displayName="Dropzone";var Vo={disabled:!1,getFilesFromEvent:function(e){return An(this,void 0,void 0,(function(){return In(this,(function(t){return Ha(e)&&Ha(e.dataTransfer)?[2,$a(e.dataTransfer,e.type)]:Ha(n=e)&&Ha(n.target)?[2,qa(e)]:Array.isArray(e)&&e.every((function(e){return"getFile"in e&&"function"==typeof e.getFile}))?[2,Va(e)]:[2,[]];var n}))}))},maxSize:1/0,minSize:0,multiple:!0,maxFiles:0,preventDropOnDocument:!0,noClick:!1,noKeyboard:!1,noDrag:!1,noDragEventsBubbling:!1,validator:null,useFsAccessApi:!0,autoFocus:!1};qo.defaultProps=Vo,qo.propTypes={children:Aa().func,accept:Aa().objectOf(Aa().arrayOf(Aa().string)),multiple:Aa().bool,preventDropOnDocument:Aa().bool,noClick:Aa().bool,noKeyboard:Aa().bool,noDrag:Aa().bool,noDragEventsBubbling:Aa().bool,minSize:Aa().number,maxSize:Aa().number,maxFiles:Aa().number,disabled:Aa().bool,getFilesFromEvent:Aa().func,onFileDialogCancel:Aa().func,onFileDialogOpen:Aa().func,useFsAccessApi:Aa().bool,autoFocus:Aa().bool,onDragEnter:Aa().func,onDragLeave:Aa().func,onDragOver:Aa().func,onDrop:Aa().func,onDropAccepted:Aa().func,onDropRejected:Aa().func,onError:Aa().func,validator:Aa().func};const $o=qo;var Zo={isFocused:!1,isFileDialogActive:!1,isDragActive:!1,isDragAccept:!1,isDragReject:!1,acceptedFiles:[],fileRejections:[]};function Qo(e,t){switch(t.type){case"focus":return Wo(Wo({},e),{},{isFocused:!0});case"blur":return Wo(Wo({},e),{},{isFocused:!1});case"openDialog":return Wo(Wo({},Zo),{},{isFileDialogActive:!0});case"closeDialog":return Wo(Wo({},e),{},{isFileDialogActive:!1});case"setDraggedFiles":return Wo(Wo({},e),{},{isDragActive:t.isDragActive,isDragAccept:t.isDragAccept,isDragReject:t.isDragReject});case"setFiles":return Wo(Wo({},e),{},{acceptedFiles:t.acceptedFiles,fileRejections:t.fileRejections});case"reset":return Wo({},Zo);default:return e}}function Ko(){}const Go=function(e){const{hover:t,dropzone:n,renderUnselected:a,file:o,clearFile:l,onUpload:i,isUploading:u,isUploaded:s,renderSelected:c,renderUploaded:p,renderUploading:d,disabled:f,addFileText:h,uploadText:m,cancelText:g}=e,{getRootProps:y,getInputProps:v,open:b}=n,E=kn()("wpl-dropzone",{"wpl-dropzone__hover":t}),_=y({onClick:e=>e.stopPropagation(),onKeyDown:e=>{32!==e.keyCode&&13!==e.keyCode||e.stopPropagation()}});return(0,r.createElement)("div",w({},_,{className:E}),(0,r.createElement)("input",v()),(null===o||f&&!u)&&(0,r.createElement)(r.Fragment,null,a(b),(0,r.createElement)("button",{type:"button",className:"button-secondary",onClick:b,disabled:f},h)),null!==o&&!u&&!s&&(0,r.createElement)(r.Fragment,null,c(o),(0,r.createElement)("button",{className:"button-primary",onClick:()=>i(o)},m)," ",(0,r.createElement)("button",{className:"button-secondary",onClick:l},g)),null!==o&&u&&d(o),null!==o&&s&&p(l))},Xo=function(e){const[t,n]=(0,i.useState)(!1),[a,o]=(0,i.useState)(null);return(0,r.createElement)($o,{multiple:!1,onDrop:function(e){n(!1),o(e[0])},onDragLeave:()=>n(!1),onDragEnter:()=>n(!0)},(n=>(0,r.createElement)(Go,w({dropzone:n,hover:t,file:a,clearFile:()=>o(null)},e))))};function Jo(){return Jo=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Jo.apply(this,arguments)}const el=i.useLayoutEffect;var tl=function(e,t){"function"!=typeof e?e.current=t:e(t)};var nl={"min-height":"0","max-height":"none",height:"0",visibility:"hidden",overflow:"hidden",position:"absolute","z-index":"-1000",top:"0",right:"0"},rl=function(e){Object.keys(nl).forEach((function(t){e.style.setProperty(t,nl[t],"important")}))},al=null,ol=function(){},ll=["borderBottomWidth","borderLeftWidth","borderRightWidth","borderTopWidth","boxSizing","fontFamily","fontSize","fontStyle","fontWeight","letterSpacing","lineHeight","paddingBottom","paddingLeft","paddingRight","paddingTop","tabSize","textIndent","textRendering","textTransform","width","wordBreak"],il=!!document.documentElement.currentStyle,ul=function(e,t){var n=e.cacheMeasurements,r=e.maxRows,a=e.minRows,o=e.onChange,l=void 0===o?ol:o,u=e.onHeightChange,s=void 0===u?ol:u,c=function(e,t){if(null==e)return{};var n,r,a={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(a[n]=e[n]);return a}(e,["cacheMeasurements","maxRows","minRows","onChange","onHeightChange"]),p=void 0!==c.value,d=(0,i.useRef)(null),f=function(e,t){var n=(0,i.useRef)();return(0,i.useCallback)((function(r){e.current=r,n.current&&tl(n.current,null),n.current=t,t&&tl(t,r)}),[t])}(d,t),h=(0,i.useRef)(0),m=(0,i.useRef)(),g=function(){var e=d.current,t=n&&m.current?m.current:function(e){var t=window.getComputedStyle(e);if(null===t)return null;var n=function(e,t){return e.reduce((function(e,n){return e[n]=t[n],e}),{})}(ll,t),r=n.boxSizing;return""===r?null:(il&&"border-box"===r&&(n.width=parseFloat(n.width)+parseFloat(n.borderRightWidth)+parseFloat(n.borderLeftWidth)+parseFloat(n.paddingRight)+parseFloat(n.paddingLeft)+"px"),{sizingStyle:n,paddingSize:parseFloat(n.paddingBottom)+parseFloat(n.paddingTop),borderSize:parseFloat(n.borderBottomWidth)+parseFloat(n.borderTopWidth)})}(e);if(t){m.current=t;var o=function(e,t,n,r){void 0===n&&(n=1),void 0===r&&(r=1/0),al||((al=document.createElement("textarea")).setAttribute("tabindex","-1"),al.setAttribute("aria-hidden","true"),rl(al)),null===al.parentNode&&document.body.appendChild(al);var a=e.paddingSize,o=e.borderSize,l=e.sizingStyle,i=l.boxSizing;Object.keys(l).forEach((function(e){var t=e;al.style[t]=l[t]})),rl(al),al.value=t;var u=function(e,t){var n=e.scrollHeight;return"border-box"===t.sizingStyle.boxSizing?n+t.borderSize:n-t.paddingSize}(al,e);al.value="x";var s=al.scrollHeight-a,c=s*n;"border-box"===i&&(c=c+a+o),u=Math.max(c,u);var p=s*r;return"border-box"===i&&(p=p+a+o),[u=Math.min(p,u),s]}(t,e.value||e.placeholder||"x",a,r),l=o[0],i=o[1];h.current!==l&&(h.current=l,e.style.setProperty("height",l+"px","important"),s(l,{rowHeight:i}))}};return(0,i.useLayoutEffect)(g),function(e){var t,n,r=(t=e,n=i.useRef(t),el((function(){n.current=t})),n);(0,i.useLayoutEffect)((function(){var e=function(e){r.current(e)};return window.addEventListener("resize",e),function(){window.removeEventListener("resize",e)}}),[])}(g),(0,i.createElement)("textarea",Jo({},c,{onChange:function(e){p||g(),l(e)},ref:f}))};const sl=(0,i.forwardRef)(ul),cl=function(e){const{error:t,mini:n,context:a,renderDebug:o,versions:l,noParse:u=!1,details:s=[],locale:c}=e,[p,d]=(0,i.useState)(!n);if(!p)return(0,r.createElement)("p",null,(0,r.createElement)("button",{className:"button button-secondary",type:"button",onClick:()=>d(!0)},(0,et.__)("Show debug",c)));const f=u?[t]:function(e,t,n){const r=t?[t]:[],{request:a=!1,data:o}=e;r.push("");const{apiFetch:l}=a;return l&&l.status&&l.statusText&&(r.push("Action: "+l.action),l.body&&"{}"!==l.body&&r.push("Params: "+l.body),r.push("Code: "+l.status+" "+l.statusText),r.push("")),r.push("Error: "+function(e){return"string"==typeof e?e:0===e.code?e.message:e.data&&e.data.wpdb?`${e.message} (${e.code}): ${e.data.wpdb}`:e.code?`${e.message} (${e.code})`:e.message}(e)),o&&r.push("Raw: "+o),n&&(r.push(""),r.push("Context:"),r.push(n)),r}(t,l,a);return(0,r.createElement)(r.Fragment,null,(0,r.createElement)("h3",null,(0,et.__)("Debug Information",c)),o&&o(s.concat(f).join("\n")),(0,r.createElement)("p",null,(0,r.createElement)(sl,{readOnly:!0,cols:120,value:s.concat(f).join("\n"),maxRows:40,spellCheck:!1})))},pl=function(e){let{locale:t}=e;return(0,r.createElement)(r.Fragment,null,(0,r.createElement)("h2",null,(0,et.__)("You are using an old or cached session",t)),(0,r.createElement)("p",null,(0,et.__)("This is usually fixed by doing one of the following:",t)),(0,r.createElement)("ul",null,(0,r.createElement)("li",null,(0,et.__)("Reload the page - your current session is old.",t)),(0,r.createElement)("li",null,(0,et.__)("Log out, clear your browser cache, and log in again - your browser has cached an old session.",t)),(0,r.createElement)("li",null,(0,et.__)("Your admin pages are being cached. Clear this cache and try again. There may be multiple caches involved.",t))),(0,r.createElement)(cl,w({},props,{mini:!0})))};function dl(e){var t,n;return 404===(null==e||null===(t=e.request)||void 0===t||null===(n=t.apiFetch)||void 0===n?void 0:n.status)}function fl(e){return"disabled"===(null==e?void 0:e.code)||"rest_disabled"===(null==e?void 0:e.code)}function hl(e){return"rest_api_redirected"===(null==e?void 0:e.code)}function ml(e){return 0===e.code?e.message:e.data&&e.data.wpdb?(0,r.createElement)("span",null,`${e.message} (${e.code})`,": ",(0,r.createElement)("code",null,e.data.wpdb)):e.code?(0,r.createElement)(r.Fragment,null,e.message," (",(0,r.createElement)("code",null,e.code),")"):e.message}const gl=e=>{let{error:t,links:n,locale:a}=e;if("string"==typeof t)return(0,r.createElement)("p",null,t);if(function(e){return void 0!==e.code&&0===e.code}(t))return(0,r.createElement)("p",null,(0,et.__)("WordPress did not return a response. This could mean an error occurred or that the request was blocked. Please check your server error_log.",a));if(function(e){const{request:t,code:n}=e;return!!(t&&t.status&&n)&&(-1!==[400,401,403,405].indexOf(t.status)||"rest_no_route"===n)&&0===parseInt(n,10)}(t))return(0,r.createElement)(r.Fragment,null,(0,r.createElement)("p",null,ml(t)),(0,r.createElement)("p",null,(0,et.__)("Your REST API is probably being blocked by a security plugin. Please disable this, or configure it to allow REST API requests.",a)),(0,r.createElement)("p",null,(0,r.createElement)(_a,{url:n.api},(0,et.__)("Read this REST API guide for more information.",a))));if(dl(t))return(0,r.createElement)(r.Fragment,null,(0,r.createElement)("p",null,(0,et.__)("Your WordPress REST API is returning a 404 page. This is almost certainly an external plugin or server configuration issue.",a)),(0,r.createElement)("p",{className:"wpl-error__highlight"},(0,r.createElement)("strong",null,(0,et.__)("You will will need to fix this on your site. Redirection is not causing the error.",a))),(0,r.createElement)("ul",null,(0,r.createElement)("li",null,zl((0,et.__)("Can you access your {{api}}REST API{{/api}} without it redirecting?.",a),{api:(0,r.createElement)(_a,{url:n.rootUrl})})),(0,r.createElement)("li",null,zl((0,et.__)("Check your {{link}}Site Health{{/link}} and fix any issues.",a),{link:(0,r.createElement)(_a,{url:n.siteHealth})})),(0,r.createElement)("li",null,(0,et.__)("Your server configuration is blocking access to the REST API.",a)),(0,r.createElement)("li",null,(0,et.__)("A security plugin or firewall is blocking access. You will need to whitelist the REST API.",a))),(0,r.createElement)("p",null,(0,r.createElement)(_a,{url:n.api},(0,et.__)("Read this REST API guide for more information.",a))));if(hl(t))return(0,r.createElement)("p",null,(0,et.__)("Your REST API is being redirected. Please remove the redirection for the API.",a));if(function(e){var t,n,r;return(null==e||null===(t=e.request)||void 0===t?void 0:t.apiFetch)&&413===(null==e||null===(n=e.request)||void 0===n||null===(r=n.apiFetch)||void 0===r?void 0:r.status)}(t))return(0,r.createElement)("p",null,(0,et.__)("Your server has rejected the request for being too big. You will need to reconfigure it to continue.",a));if(function(e){return void 0===e.message}(t))return(0,r.createElement)("p",null,(0,et.__)("An unknown error occurred.",a));if(function(e){return e.data&&-1!==e.data.indexOf("<b>Deprecated</b>: Directive")}(t))return(0,r.createElement)(r.Fragment,null,(0,r.createElement)("p",null,ml(t)),(0,r.createElement)("p",null,(0,et.__)("Your REST API is showing a deprecated PHP error. Please fix this error.",a)));if(function(e){var t,n;return-1!==[500,502,503].indexOf(null==e||null===(t=e.request)||void 0===t||null===(n=t.apiFetch)||void 0===n?void 0:n.status)}(t))return(0,r.createElement)(r.Fragment,null,(0,r.createElement)("p",null,ml(t)),(0,r.createElement)("p",null,(0,et.__)("This could be a security plugin, or your server is out of memory or has an external error. Please check your server error log",a)),(0,r.createElement)("p",null,(0,r.createElement)(_a,{url:n.http},(0,et.__)("Read this REST API guide for more information.",a))));if(fl(t))return(0,r.createElement)("p",null,(0,et.__)("Your WordPress REST API has been disabled. You will need to enable it to continue.",a));if(function(e){const{message:t}=e;return"SyntaxError"===e.code}(t)){const e=function(e){const t=e.split("<br />").filter((e=>e)),n=e.lastIndexOf("}");return n!==e.length?e.substr(n+1).trim():t.slice(0,t.length-1).join(" ").trim()}("");return(0,r.createElement)(r.Fragment,null,(0,r.createElement)("p",null,ml(t)),(0,r.createElement)("p",null,(0,et.__)("WordPress returned an unexpected message. This could be a PHP error from another plugin, or data inserted by your theme.",a)),e.length>1&&(0,r.createElement)("p",null,(0,r.createElement)("strong",null,(0,et.__)("Possible cause",a),":")," ",(0,r.createElement)("code",null,e.substr(0,1e3))))}return function(e){var t;const n=null==e||null===(t=e.message)||void 0===t?void 0:t.toLowerCase();return!!n&&("failed to fetch"===n||"not allowed to request resource"===n||-1!==n.indexOf("networkerror"))}(t)?(0,r.createElement)(r.Fragment,null,(0,r.createElement)("p",null,ml(t)),(0,r.createElement)("p",null,(0,et.__)("Unable to make request due to browser security. This is typically because your WordPress and Site URL settings are inconsistent, or the request was blocked by your site CORS policy.",a)),(0,r.createElement)("p",null,(0,r.createElement)(_a,{url:n.url},(0,et.__)("Read this REST API guide for more information.",a)))):function(e){var t;const{headers:n}=null!==(t=null==e?void 0:e.request)&&void 0!==t?t:{};if(n)for(let[e,t]of n)if(-1!==e.toLowerCase().indexOf("cf-"))return!0;return!1}(t)?(0,r.createElement)(r.Fragment,null,(0,r.createElement)("p",null,ml(t)),(0,r.createElement)("p",null,(0,et.__)("Your REST API appears to be cached and this will cause problems. Please exclude your REST API from your caching system.",a))):(0,r.createElement)("p",null,ml(t))},yl=function(e){const{title:t,children:n,error:a,links:o,locale:l}=e,i=function(e){return!dl(e)&&!hl(e)&&!fl(e)}(a),u=function(e){return!!dl(e)||!!hl(e)||!!fl(e)}(a),s=!dl(a);return(0,r.createElement)(r.Fragment,null,(0,r.createElement)("h2",null,function(e,t,n){return dl(e)?(0,et.__)("REST API 404"):t||(0,et.__)("Something went wrong 🙁",n)}(a,t,l)),(0,r.createElement)("div",{className:"wpl-error__title"},(0,r.createElement)(gl,{error:a,links:o,locale:l})),i&&n,(0,r.createElement)(cl,w({},e,u?{mini:!0}:{},{renderDebug:s?null:e.renderDebug})))},vl=function(e){const{title:t,children:n,error:a,links:o,locale:l}=e;return(0,r.createElement)(r.Fragment,null,(0,r.createElement)("h2",null,t||(0,et.__)("Something went wrong 🙁",l)),(0,r.createElement)("div",{className:"wpl-error__detail"},(0,r.createElement)(gl,{error:a,links:o,locale:l})),n,(0,r.createElement)(cl,e))},bl=function(e){const{title:t,children:n,locale:a}=e;return(0,r.createElement)(r.Fragment,null,(0,r.createElement)("h2",null,t||(0,et.__)("Something went wrong 🙁",a)),n,(0,r.createElement)(cl,w({},e,{noParse:!0})))},wl=function(e){let{locale:t}=e;return(0,r.createElement)(r.Fragment,null,(0,r.createElement)("h2",null,(0,et.__)("Bad data",t)),(0,r.createElement)("p",null,(0,et.__)("There was a problem making a request to your site. This could indicate you provided data that did not match requirements, or that the plugin sent a bad request.",t)),(0,r.createElement)("p",null,(0,et.__)("Please review your data and try again.",t)),(0,r.createElement)(cl,w({},props,{mini:!0})))};function El(e){let{current:t,change:n,total:a}=e;return(0,r.createElement)("div",{className:"wpl-error__page"},t>0&&(0,r.createElement)("span",{onClick:()=>n(t-1)},"←"),`${t+1}/${a}`,t+1<a&&(0,r.createElement)("span",{onClick:()=>n(t+1)},"→"))}const _l=function(e){const{onClear:t,locale:n,mini:a=!1,type:o=""}=e,l=Array.isArray(e.errors)?e.errors:[e.errors],[u,s]=(0,i.useState)(0);if((0,i.useEffect)((()=>{!a&&l.length>0&&window.scrollTo(0,0)}),[l]),0===l.length)return null;const c=function(e,t){var n,r;return"rest_cookie_invalid_nonce"===e[0].code?pl:400===(null===(n=e[0])||void 0===n||null===(r=n.jsonData)||void 0===r?void 0:r.status)?wl:"error"===t?vl:"fixed"===t?bl:yl}(l,o);return(0,r.createElement)("div",{className:kn()("wpl-error",{"wpl-error__mini":a})},t&&(0,r.createElement)("div",{className:"closer",onClick:t},(0,r.createElement)("span",{className:"dashicons dashicons-no-alt"})),l.length>1&&(0,r.createElement)(El,{current:u,change:s,total:l.length}),(0,r.createElement)(c,w({error:l[u]},e)))};class xl extends i.Component{constructor(e){super(e),this.state={error:!1,stack:null,errorInfo:null}}static getDerivedStateFromError(e){return{error:!0}}componentDidCatch(e,t){this.setState({error:!0,stack:e,errorInfo:t}),console.error(e,t)}render(){const{error:e,stack:t,errorInfo:n}=this.state,{renderCrash:r,children:a,extra:o}=this.props;return e?r(t,n,o):a}}const Sl=xl,kl=function(e){let{level:t="notice",children:n,className:a}=e;return(0,r.createElement)("div",{className:kn()(`inline-notice inline-${t}`,a)},n)},Cl=e=>{let{className:t,children:n}=e;return(0,r.createElement)("table",{className:kn()("wpl-table",t)},(0,r.createElement)("tbody",null,n))},Dl=e=>{const{title:t,url:n=!1}=e;return(0,r.createElement)("tr",null,(0,r.createElement)("th",null,!n&&t,n&&(0,r.createElement)("a",{href:n,target:"_blank"},t)),(0,r.createElement)("td",null,e.children))},Ol=e=>{let{className:t,children:n,onSubmit:a}=e;return(0,r.createElement)("form",{className:t,onSubmit:function(e){e.preventDefault(),a()}},n)},Pl=function(e){const{isPrimary:t=!1,isSecondary:n=!0,isSubmit:a=!1,className:o,children:l,disabled:i=!1,isDestructive:u=!1,...s}=e,c=kn()("button",o,{"button-primary":t,"button-secondary":n,"button-delete":u});return(0,r.createElement)("button",w({className:c,disabled:i,type:a?"submit":"button"},s),l)};let Tl,Nl,Ml,Rl;const jl=/<(\/)?(\w+)\s*(\/)?>/g;function Al(e,t,n,r,a){return{element:e,tokenStart:t,tokenLength:n,prevOffset:r,leadingTextStart:a,children:[]}}function Il(e){const t=function(){const e=jl.exec(Tl);if(null===e)return["no-more-tokens"];const t=e.index,[n,r,a,o]=e,l=n.length;return o?["self-closed",a,t,l]:r?["closer",a,t,l]:["opener",a,t,l]}(),[n,a,o,l]=t,i=Rl.length,u=o>Nl?Nl:null;if(!e[a])return Fl(),!1;switch(n){case"no-more-tokens":if(0!==i){const{leadingTextStart:e,tokenStart:t}=Rl.pop();Ml.push(Tl.substr(e,t))}return Fl(),!1;case"self-closed":return 0===i?(null!==u&&Ml.push(Tl.substr(u,o-u)),Ml.push(e[a]),Nl=o+l,!0):(Ll(Al(e[a],o,l)),Nl=o+l,!0);case"opener":return Rl.push(Al(e[a],o,l,o+l,u)),Nl=o+l,!0;case"closer":if(1===i)return function(e){const{element:t,leadingTextStart:n,prevOffset:a,tokenStart:o,children:l}=Rl.pop(),i=e?Tl.substr(a,e-a):Tl.substr(a);i&&l.push(i),null!==n&&Ml.push(Tl.substr(n,o-n)),Ml.push((0,r.cloneElement)(t,null,...l))}(o),Nl=o+l,!0;const t=Rl.pop(),n=Tl.substr(t.prevOffset,o-t.prevOffset);t.children.push(n),t.prevOffset=o+l;const s=Al(t.element,t.tokenStart,t.tokenLength,o+l);return s.children=t.children,Ll(s),Nl=o+l,!0;default:return Fl(),!1}}function Fl(){const e=Tl.length-Nl;0!==e&&Ml.push(Tl.substr(Nl,e))}function Ll(e){const{element:t,tokenStart:n,tokenLength:a,prevOffset:o,children:l}=e,i=Rl[Rl.length-1],u=Tl.substr(i.prevOffset,n-i.prevOffset);u&&i.children.push(u),i.children.push((0,r.cloneElement)(t,null,...l)),i.prevOffset=o||n+a}const Ul=(e,t)=>{if(Tl=e,Nl=0,Ml=[],Rl=[],jl.lastIndex=0,!(e=>{const t="object"==typeof e,n=t&&Object.values(e);return t&&n.length&&n.every((e=>(0,r.isValidElement)(e)))})(t))throw new TypeError("The conversionMap provided is not valid. It must be an object with values that are WPElements");do{}while(Il(t));return(0,r.createElement)(r.Fragment,null,...Ml)};function zl(e,t){return Ul(e.replace(/\{\{/g,"<").replace(/\}\}/g,">"),t)}function Yl(e){return-1!==SearchRegexi10n.caps.pages.indexOf(e)}const Wl=function(e){const t="mailto:john@searchregex.com?subject=Search%20Regex%20Error&body="+encodeURIComponent(e),n="https://github.com/johngodley/search-regex/issues/new?title=Search%20Regex%20Error&body="+encodeURIComponent("```\n"+e+"\n```\n\n");return(0,r.createElement)(r.Fragment,null,(0,r.createElement)("p",{className:"wpl-error__highlight"},zl((0,et.__)("Please check the {{link}}support site{{/link}} before proceeding further.","search-regex"),{link:(0,r.createElement)(_a,{url:"https://searchregex.com/support/"})})),(0,r.createElement)("p",null,zl((0,et.__)("If that did not help then {{strong}}create an issue{{/strong}} or send it in an {{strong}}email{{/strong}}.","search-regex"),{strong:(0,r.createElement)("strong",null)})),(0,r.createElement)("p",null,(0,r.createElement)("a",{href:n,className:"button-primary"},(0,et.__)("Create An Issue","search-regex"))," ",(0,r.createElement)("a",{href:t,className:"button-secondary"},(0,et.__)("Email","search-regex"))),(0,r.createElement)("p",null,(0,et.__)("Include these details in your report along with a description of what you were doing and a screenshot.","search-regex")))};function Bl(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const Hl=function(e){const{request:t}=e.error,n=(e=>!!(e&&e.apiFetch.body&&e.apiFetch.body.length>500))(t),[a,o]=(0,i.useState)(n),l=e=>{e.preventDefault(),o(!a)};return t&&t.apiFetch.body?(0,r.createElement)(r.Fragment,null,a&&n&&(0,r.createElement)("a",{className:"api-result-hide",onClick:l,href:"#"},(0,et.__)("Show Full","search-regex")),!a&&n&&(0,r.createElement)("a",{className:"api-result-hide",onClick:l,href:"#"},(0,et.__)("Hide","search-regex")),(0,r.createElement)("pre",null,a?t.apiFetch.body.substr(0,500)+" ...":t.apiFetch.body)):null};function ql(){return{url:"https://searchregex.com/support/problems/rest-api/#url",http:"https://searchregex.com/support/problems/rest-api/#http",api:"https://searchregex.com/support/problems/rest-api/",rootUrl:SearchRegexi10n.api.WP_API_root,siteHealth:SearchRegexi10n.api.site_health}}function Vl(){return SearchRegexi10n.versions.split("\n").concat(["Query: "+document.location.search])}const $l=(e,t)=>{const n=(e=>e.code?e.code:e.name?e.name:null)(e);return(0,r.createElement)("div",{className:"api-result-log_details",key:t},(0,r.createElement)("p",null,(0,r.createElement)("span",{className:"dashicons dashicons-no"})),(0,r.createElement)("div",null,(0,r.createElement)("p",null,t.map(((t,n)=>(0,r.createElement)("span",{key:n,className:"api-result-method_fail"},t," ",e.data&&e.data.status))),n&&(0,r.createElement)("strong",null,n,": "),e.message),(0,r.createElement)(gl,{error:e,links:ql()}),(0,r.createElement)(Hl,{error:e})))},Zl=e=>(0,r.createElement)("p",{key:e},(0,r.createElement)("span",{className:"dashicons dashicons-yes"}),e.map(((e,t)=>(0,r.createElement)("span",{key:t,className:"api-result-method_pass"},e))),(0,et.__)("Working!","search-regex")),Ql=e=>e.code?e.code:0,Kl=e=>{let{result:t}=e;const n=[],{GET:r,POST:a}=t;return r.status===a.status&&Ql(r)===Ql(a)?("fail"===r.status?n.push($l(r.error,["GET","POST"])):n.push(Zl(["GET","POST"])),n):("fail"===r.status?n.push($l(r.error,["GET"])):n.push(Zl(["GET"])),"fail"===a.status?n.push($l(a.error,["POST"])):n.push(Zl(["POST"])),n)},Gl=e=>{let{item:t,result:n,routes:a,isCurrent:o,allowChange:l}=e;return(e=>0===Object.keys(e).length||"loading"===e.GET.status||"loading"===e.POST.status)(n)?null:(0,r.createElement)("div",{className:"api-result-log"},(0,r.createElement)("form",{className:"api-result-select",action:SearchRegexi10n.pluginRoot+"&sub=support",method:"POST"},l&&!o&&(0,r.createElement)("input",{type:"submit",className:"button button-secondary",value:(0,et.__)("Switch to this API","search-regex")}),l&&o&&(0,r.createElement)("span",null,(0,et.__)("Current API","search-regex")),(0,r.createElement)("input",{type:"hidden",name:"rest_api",value:t.value}),(0,r.createElement)("input",{type:"hidden",name:"_wpnonce",value:SearchRegexi10n.api.WP_API_nonce}),(0,r.createElement)("input",{type:"hidden",name:"action",value:"rest_api"})),(0,r.createElement)("h4",null,t.text),(0,r.createElement)("p",null,"URL: ",(0,r.createElement)("code",null,(0,r.createElement)(_a,{url:a[t.value]},a[t.value]))),(0,r.createElement)(Kl,{result:n}))},Xl={setting:{get:()=>mt("search-regex/v1/setting"),update:e=>gt("search-regex/v1/setting",e)},search:{perform:e=>gt("search-regex/v1/search",e)},preset:{save:(e,t)=>gt("search-regex/v1/preset",{...e,name:t}),update:e=>gt(`search-regex/v1/preset/id/${e.id}`,e),delete:e=>gt(`search-regex/v1/preset/id/${e}/delete`),export:()=>mt("search-regex/v1/preset",{force:!0}),upload:e=>((e,t,n)=>{const r=gt("search-regex/v1/preset/import",{});return delete r.headers["Content-Type"],r.body=new FormData,r.body.append("file",n),r})(0,0,e)},source:{deleteRow:(e,t)=>gt(`search-regex/v1/source/${e}/row/${t}/delete`),loadRow:(e,t)=>mt(`search-regex/v1/source/${e}/row/${t}`),saveRow:(e,t,n,r)=>gt(`search-regex/v1/source/${e}/row/${t}`,{...r,replacement:n}),complete:(e,t,n)=>mt(`search-regex/v1/source/${e}/complete/${t}`,{value:n})},plugin:{checkApi:function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const n=t?gt("search-regex/v1/plugin/test",{test:"ping"}):mt("search-regex/v1/plugin/test");return n.url="http"===e.substr(0,4)?e+n.url:n.url,n}}},Jl=Xl,ei=e=>t=>(st(Jl.setting.update(e)).then((e=>{t({type:be,values:e.settings,warning:e.warning})})).catch((e=>{t({type:we,error:e})})),t({type:ve,settings:e})),ti=(e,t)=>(n,r)=>{const a={..._t(r().preset.presets,e),...t};return n({type:qe,id:e,preset:t}),st(Jl.preset.update(a)).then((e=>{n({type:Ve,...e})})).catch((e=>{n({type:$e,error:e})}))},ni=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return{type:He,preset:e,currentOnly:t}},ri=e=>t=>(t({type:Ze}),st(Jl.preset.upload(e)).then((e=>{t({type:Qe,...e})})).catch((e=>{t({type:Ke,error:e})}))),ai=()=>[{value:0,label:(0,et.__)("Default REST API","search-regex")},{value:1,label:(0,et.__)("Raw REST API","search-regex")},{value:3,label:(0,et.__)("Relative REST API","search-regex")}],oi=W((function(e){const{values:t,saveStatus:n}=e.settings,{presets:r}=e.preset;return{values:t,saveStatus:n,presets:r}}),(function(e){return{onSaveSettings:(t,n)=>{e(ei(t)),n&&e(ni(n,!0))}}}))((function(e){const{saveStatus:t,values:n,onSaveSettings:a,presets:o}=e,[l,u]=(0,i.useState)(n.support),[s,c]=(0,i.useState)(n.defaultPreset),[p,d]=(0,i.useState)(n.rest_api);return(0,r.createElement)("form",{onSubmit:function(e){e.preventDefault(),a({support:l,defaultPreset:s,rest_api:p},o.find((e=>e.id===s)))}},(0,r.createElement)(Cl,{className:"form-table"},(0,r.createElement)(Dl,{title:""},(0,r.createElement)("label",null,(0,r.createElement)("input",{type:"checkbox",checked:l,name:"support",onChange:e=>u(e.target.checked)}),(0,r.createElement)("span",{className:"sub"},(0,et.__)("I'm a nice person and I have helped support the author of this plugin")))),(0,r.createElement)(Dl,{title:(0,et.__)("Default Preset","search-regex")},(0,r.createElement)("label",null,(0,r.createElement)(Ua,{items:[{value:0,label:(0,et.__)("No default preset","search-regex")}].concat(o.map((e=>({value:e.id,label:e.name})))),name:"defaultPreset",value:s,onChange:e=>c(e.target.value)})," ",(0,et.__)("Set a preset to use by default when Search Regex is loaded.","search-regex"))),(0,r.createElement)(Dl,{title:(0,et.__)("REST API","search-regex")},(0,r.createElement)(Ua,{items:ai(),name:"rest_api",onChange:e=>d(parseInt(e.target.value,10)),value:p})," ",(0,r.createElement)("span",{className:"sub"},(0,et.__)("How Search Regex uses the REST API - don't change unless necessary","search-regex")))),(0,r.createElement)("input",{className:"button-primary",type:"submit",name:"update",value:(0,et.__)("Update","search-regex"),disabled:t===Se}))})),li="ok",ii="fail",ui="loading",si="warning-current",ci="warning-not-selected";class pi extends i.Component{constructor(e){super(e),Bl(this,"onRetry",(e=>{e.preventDefault,this.setState({showing:!1}),this.onTry()})),Bl(this,"onShow",(()=>{this.setState({showing:!0})})),this.state={showing:!1}}componentDidMount(){this.onTry()}onTry(){const{routes:e}=this.props,t=Object.keys(e).map((t=>({id:t,url:e[t]})));this.props.onCheckApi(t.filter((e=>e)))}getPercent(e,t){if(0===Object.keys(e).length)return 0;const n=2*t.length;let r=0;for(let t=0;t<Object.keys(e).length;t++){const n=Object.keys(e)[t];e[n]&&e[n].GET&&e[n].GET.status!==ui&&r++,e[n]&&e[n].POST&&e[n].POST.status!==ui&&r++}return Math.round(r/n*100)}getApiStatus(e,t,n){const r=Object.keys(e).filter((t=>{return(n=e[t]).GET&&n.POST&&(n.GET.status===ii||n.POST.status===ii);var n})).length;return 0===r?"ok":r<t.length?(a=e[n]).GET&&a.POST&&a.GET.status===li&&a.POST.status===li?si:ci:"fail";var a}getApiStatusText(e){return e===li?(0,et.__)("Good","search-regex"):e===si?(0,et.__)("Working but some issues","search-regex"):e===ci?(0,et.__)("Not working but fixable","search-regex"):(0,et.__)("Unavailable","search-regex")}canShowProblem(e){const{showing:t}=this.state;return t||e===ii||e===ci}renderError(e){const t=this.canShowProblem(e);let n=(0,et.__)("There are some problems connecting to your REST API. It is not necessary to fix these problems and the plugin is able to work.","search-regex");return e===ii?n=(0,et.__)("Your REST API is not working and the plugin will not be able to continue until this is fixed.","search-regex"):e===ci&&(n=(0,et.__)("You are using a broken REST API route. Changing to a working API should fix the problem.","search-regex")),(0,r.createElement)("div",{className:"api-result-log"},(0,r.createElement)("p",null,(0,r.createElement)("strong",null,(0,et.__)("Summary","search-regex")),": ",n),!t&&(0,r.createElement)("p",null,(0,r.createElement)("button",{className:"button-secondary",type:"button",onClick:this.onShow},(0,et.__)("Show Problems","search-regex"))))}render(){const e=ai(),{apiTest:t,routes:n,current:a,allowChange:o}=this.props,{showing:l}=this.state,i=this.getPercent(t,e),u=this.getApiStatus(t,e,a),s=i>=100&&this.canShowProblem(u)||l,c=kn()({"api-result-status":!0,"api-result-status_good":u===li&&i>=100,"api-result-status_problem":u===si&&i>=100,"api-result-status_failed":(u===ii||u===ci)&&i>=100});return(0,r.createElement)("div",{className:"api-result-wrapper"},(0,r.createElement)("div",{className:"api-result-header"},(0,r.createElement)("strong",null,"REST API:"),(0,r.createElement)("div",{className:"api-result-progress"},(0,r.createElement)("span",{className:c},i<100&&(0,et.sprintf)((0,et.__)("Testing - %s%%","search-regex"),i),i>=100&&this.getApiStatusText(u)),i<100&&(0,r.createElement)(za,null)),i>=100&&u!==li&&(0,r.createElement)("button",{className:"button button-secondary api-result-retry",onClick:this.onRetry},(0,et.__)("Check Again","search-regex"))),i>=100&&u!==li&&this.renderError(u),s&&e.map(((e,l)=>{return(0,r.createElement)(Gl,{item:e,result:(i=t,u=e.value,i&&i[u]?i[u]:{}),routes:n,key:l,isCurrent:a===e.value,allowChange:o});var i,u})))}}const di=W((function(e){const{api:{routes:t,current:n},apiTest:r}=e.settings;return{apiTest:r,routes:t,current:n}}),(function(e){return{onCheckApi:t=>{e((e=>t=>{for(let n=0;n<e.length;n++){const{id:r,url:a}=e[n];t({type:xe,id:r,method:"GET"}),t({type:xe,id:r,method:"POST"}),setTimeout((()=>{st(Jl.plugin.checkApi(a)).then((()=>{t({type:_e,id:r,method:"GET"})})).catch((e=>{t({type:Ee,id:r,method:"GET",error:e})})),st(Jl.plugin.checkApi(a,!0)).then((()=>{t({type:_e,id:r,method:"POST"})})).catch((e=>{t({type:Ee,id:r,method:"POST",error:e})}))}),1e3)}})(t))}}}))(pi),fi=function(){return(0,r.createElement)(r.Fragment,null,(0,r.createElement)(di,null),(0,r.createElement)("h3",null,(0,et.__)("What do I do next?","search-regex")),(0,r.createElement)("ol",null,(0,r.createElement)("li",null,zl((0,et.__)("{{link}}Caching software{{/link}}, in particular Cloudflare, can cache the wrong thing. Try clearing all your caches.","search-regex"),{link:(0,r.createElement)(_a,{url:"https://searchregex.com/support/problems/cloudflare/"})})),(0,r.createElement)("li",null,zl((0,et.__)("{{link}}Please temporarily disable other plugins!{{/link}} This fixes so many problems.","search-regex"),{link:(0,r.createElement)(_a,{url:"https://searchregex.com/support/problems/plugins/"})})),(0,r.createElement)("li",null,zl((0,et.__)("If you are using WordPress 5.2 or newer then look at your {{link}}Site Health{{/link}} and resolve any issues.","search-regex"),{link:(0,r.createElement)(_a,{url:"/wp-admin/site-health.php"})}))))},hi=function(e,t,n){return(0,r.createElement)(_l,{errors:"",renderDebug:Wl,type:"fixed",links:ql(),details:Vl().concat([e,t?t.componentStack:""])},(0,r.createElement)("p",null,(0,et.__)("Search Regex is not working. Try clearing your browser cache and reloading this page.","search-regex")," "," ",(0,et.__)("If you are using a page caching plugin or service (CloudFlare, OVH, etc) then you can also try clearing that cache.","search-regex")),(0,r.createElement)("p",null,zl((0,et.__)("If that doesn't help, open your browser's error console and create a {{link}}new issue{{/link}} with the details.","search-regex"),{link:(0,r.createElement)(_a,{url:"https://github.com/johngodley/searchregex/issues"})})))},mi=function(e){const{page:t,setPage:n,children:r,onPageChange:a}=e,o=(0,i.useRef)();function l(){const e=En();n(e)}return(0,i.useEffect)((()=>(window.addEventListener("popstate",l),()=>{window.removeEventListener("popstate",l)})),[]),(0,i.useEffect)((()=>{a(),o.current&&o.current!==t&&history.pushState({},"",Et({sub:t},{sub:"search"},"?page=search-regex.php")),o.current=t}),[t]),r};class gi extends i.Component{constructor(e){super(e),this.onDonate=this.handleDonation.bind(this),this.onChange=this.handleChange.bind(this),this.onBlur=this.handleBlur.bind(this),this.onInput=this.handleInput.bind(this),this.state={support:e.support,amount:20}}handleBlur(){this.setState({amount:Math.max(16,this.state.amount)})}handleDonation(){this.setState({support:!1})}getReturnUrl(){return document.location.href+"#thanks"}handleChange(e){this.state.amount!==e.value&&this.setState({amount:parseInt(e.value,10)})}handleInput(e){const t=e.target.value?parseInt(e.target.value,10):16;this.setState({amount:t})}getAmountoji(e){const t=[[100,"😍"],[80,"😎"],[60,"😊"],[40,"😃"],[20,"😀"],[10,"🙂"]];for(let n=0;n<t.length;n++)if(e>=t[n][0])return t[n][1];return t[t.length-1][1]}renderSupported(){return(0,r.createElement)("div",null,(0,et.__)("You've supported this plugin - thank you!"),"  ",(0,r.createElement)("a",{href:"#",onClick:this.onDonate},(0,et.__)("I'd like to support some more.")))}renderUnsupported(){const e={16:""};for(let t=20;t<=100;t+=20)e[t]="";return(0,r.createElement)("div",null,(0,r.createElement)("p",null,zl((0,et.__)("Search Regex is free to use - life is wonderful and lovely! It has required a great deal of time and effort to develop and you can help support this development by {{strong}}making a small donation{{/strong}}.","search-regex"),{strong:(0,r.createElement)("strong",null)})," ",(0,et.__)("You get useful software and I get to carry on making it better.","search-regex")),(0,r.createElement)("input",{type:"hidden",name:"cmd",value:"_xclick"}),(0,r.createElement)("input",{type:"hidden",name:"business",value:"admin@urbangiraffe.com"}),(0,r.createElement)("input",{type:"hidden",name:"item_name",value:"Search Regex (WordPress Plugin)"}),(0,r.createElement)("input",{type:"hidden",name:"buyer_credit_promo_code",value:""}),(0,r.createElement)("input",{type:"hidden",name:"buyer_credit_product_category",value:""}),(0,r.createElement)("input",{type:"hidden",name:"buyer_credit_shipping_method",value:""}),(0,r.createElement)("input",{type:"hidden",name:"buyer_credit_user_address_change",value:""}),(0,r.createElement)("input",{type:"hidden",name:"no_shipping",value:"1"}),(0,r.createElement)("input",{type:"hidden",name:"return",value:this.getReturnUrl()}),(0,r.createElement)("input",{type:"hidden",name:"no_note",value:"1"}),(0,r.createElement)("input",{type:"hidden",name:"currency_code",value:"USD"}),(0,r.createElement)("input",{type:"hidden",name:"tax",value:"0"}),(0,r.createElement)("input",{type:"hidden",name:"lc",value:"US"}),(0,r.createElement)("input",{type:"hidden",name:"bn",value:"PP-DonationsBF"}),(0,r.createElement)("div",{className:"donation-amount"},"$",(0,r.createElement)("input",{type:"number",name:"amount",min:16,value:this.state.amount,onChange:this.onInput,onBlur:this.onBlur}),(0,r.createElement)("span",null,this.getAmountoji(this.state.amount)),(0,r.createElement)("input",{type:"submit",className:"button-primary",value:(0,et.__)("Support 💰","search-regex")})))}render(){const{support:e}=this.state;return(0,r.createElement)("form",{action:"https://www.paypal.com/cgi-bin/webscr",method:"post",className:"donation"},(0,r.createElement)(Cl,{className:"form-table"},(0,r.createElement)(Dl,{title:(0,et.__)("Plugin Support","search-regex")+":"},e?this.renderSupported():this.renderUnsupported())))}}Bl(gi,"propTypes",{support:Aa().bool.isRequired});const yi=gi,vi=W((function(e){const{values:t}=e.settings;return{values:t}}),null)((function(e){const{values:t}=e;return(0,r.createElement)("div",null,(0,r.createElement)(yi,{support:t.support}),(0,r.createElement)(oi,null))})),bi=()=>(0,r.createElement)("div",null,(0,r.createElement)("h2",null,(0,et.__)("Need more help?","search-regex")),(0,r.createElement)("p",null,zl((0,et.__)("Full documentation for Search Regex can be found at {{site}}https://searchregex.com{{/site}}.","search-regex"),{site:(0,r.createElement)(_a,{url:"https://searchregex.com/support/"})})),(0,r.createElement)("p",null,(0,r.createElement)("strong",null,zl((0,et.__)("If you want to report a bug please read the {{report}}Reporting Bugs{{/report}} guide.","search-regex"),{report:(0,r.createElement)(_a,{url:"https://searchregex.com/support/reporting-bugs/"})}))),(0,r.createElement)(kl,{level:"general"},(0,r.createElement)("p",{className:"github"},(0,r.createElement)(_a,{url:"https://github.com/johngodley/search-regex/issues"},(0,r.createElement)("img",{src:SearchRegexi10n.pluginBaseUrl+"/images/GitHub-Mark-64px.png",width:"32",height:"32"})),(0,r.createElement)(_a,{url:"https://github.com/johngodley/search-regex/issues"},"https://github.com/johngodley/search-regex/"))),(0,r.createElement)("p",null,(0,et.__)("Please note that any support is provide on as-time-is-available basis and is not guaranteed. I do not provide paid support.","search-regex")),(0,r.createElement)("p",null,zl((0,et.__)("If you want to submit information that you don't want in a public repository then send it directly via {{email}}email{{/email}} - include as much information as you can!","search-regex"),{email:(0,r.createElement)("a",{href:"mailto:john@searchregex.com?subject=Search%20Regex%20Issue&body="+encodeURIComponent("Search Regex: "+SearchRegexi10n.versions)})})),(0,r.createElement)("h2",null,(0,et.__)("Redirection","search-regex")),(0,r.createElement)("p",null,zl((0,et.__)("Like this plugin? You might want to consider {{link}}Redirection{{/link}}, a plugin to manage redirects, from the same author.","search-regex"),{link:(0,r.createElement)(_a,{url:"https://redirection.me"})}))),wi=function(){return(0,r.createElement)("div",{className:"searchregex-help"},(0,r.createElement)("h3",null,(0,et.__)("Quick Help","search-regex")),(0,r.createElement)("p",null,(0,et.__)("The following concepts are used by Search Regex:","search-regex")),(0,r.createElement)("ul",null,(0,r.createElement)("li",null,zl((0,et.__)("{{link}}Search Flags{{/link}} - additional qualifiers for your search, to enable case insensitivity, and to enable regular expression support.","search-regex"),{link:(0,r.createElement)(_a,{url:"https://searchregex.com/support/searching/"})})),(0,r.createElement)("li",null,zl((0,et.__)("{{link}}Regular expression{{/link}} - a way of defining a pattern for text matching. Provides more advanced matches.","search-regex"),{link:(0,r.createElement)(_a,{url:"https://searchregex.com/support/regular-expression/"})})),(0,r.createElement)("li",null,zl((0,et.__)("{{link}}Source{{/link}} - the source of data you wish to search. For example, posts, pages, or comments.","search-regex"),{link:(0,r.createElement)(_a,{url:"https://searchregex.com/support/search-source/"})})),(0,r.createElement)("li",null,zl((0,et.__)("{{link}}Source Flags{{/link}} - additional options for the selected source. For example, include post {{guid}}GUID{{/guid}} in the search.","search-regex"),{link:(0,r.createElement)(_a,{url:"https://searchregex.com/support/search-source/"}),guid:(0,r.createElement)(_a,{url:"https://deliciousbrains.com/wordpress-post-guids-sometimes-update/"})}))))},Ei=()=>(0,r.createElement)(r.Fragment,null,(0,r.createElement)(wi,null),(0,r.createElement)(bi,null));var _i=n(4855);const xi=function(e){const{value:t,onChange:n,disabled:a=!1,multiline:o=!1}=e;return o?(0,r.createElement)(sl,{value:t,name:"searchPhrase",cols:120,minRows:2,maxRows:5,onChange:e=>n(e.target.value),disabled:a,placeholder:(0,et.__)("Enter search phrase","search-regex")}):(0,r.createElement)("input",{value:t,type:"text",name:"searchPhrase",disabled:a,onChange:e=>n(e.target.value),placeholder:(0,et.__)("Optional global search phrase. Leave blank to use filters only.","search-regex")})};function Si(){return[{value:"equals",label:(0,et.__)("Equals","search-regex")},{value:"notequals",label:(0,et.__)("Not Equals","search-regex")},{value:"greater",label:(0,et.__)("Greater","search-regex")},{value:"less",label:(0,et.__)("Less","search-regex")},{value:"range",label:(0,et.__)("Range","search-regex")}]}function ki(){return[{value:"equals",label:(0,et.__)("Equals","search-regex")},{value:"notequals",label:(0,et.__)("Not Equals","search-regex")},{value:"contains",label:(0,et.__)("Contains","search-regex")},{value:"notcontains",label:(0,et.__)("Not contains","search-regex")},{value:"begins",label:(0,et.__)("Begins","search-regex")},{value:"ends",label:(0,et.__)("End","search-regex")}]}function Ci(e){return"member"===e?[{value:"include",label:(0,et.__)("Includes any","search-regex")},{value:"exclude",label:(0,et.__)("Excludes any","search-regex")}]:"string"===e?ki():"keyvalue"===e?[{value:"any",label:(0,et.__)("Any","search-regex")}].concat(ki()):"integer-join"===e?Si().concat([{value:"has",label:(0,et.__)("Has Owner","search-regex")},{value:"hasnot",label:(0,et.__)("No Owner","search-regex")}]):Si()}function Di(e){let{value:t,disabled:n,onChange:a,type:o}=e;return(0,r.createElement)(Ua,{name:"logic",items:Ci(o),disabled:n,value:t,onChange:e=>a(e.target.value)})}function Oi(e,t,n,r,a){const{search:o}=e.search,l=jt({...o,page:r,...a});return t({type:n,...l}),Ni(l,t)}function Pi(e,t,n,r,a,o){const{search:l,searchDirection:i=We}=e.search,u=jt({...l,page:r,perPage:a,searchDirection:i,...o});return t({type:n,...u}),Ni(u,t)}const Ti=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:We;return(n,r)=>Oi(r(),n,Te,e,{searchDirection:t})},Ni=(e,t)=>st(Jl.search.perform(e)).then((n=>{t({type:Re,...n,perPage:e.perPage,isSave:!!e.save})})).catch((e=>{t({type:Me,error:e})})),Mi=(e,t)=>(n,r)=>(st(Jl.source.saveRow(e.source,t,e,r().search.search)).then((e=>{n({type:ze,rowId:t,row:e.result})})).catch((e=>{n({type:Me,error:e})})),n({type:je,rowId:t})),Ri=e=>({type:Me,error:{message:e}}),ji=(e,t)=>({type:Ye,labelId:e,labelValue:t}),Ai=function(e){let{value:t,name:n,onChange:a,disabled:o,remote:l,column:i}=e;const{labels:u}=b((e=>e.search)),s=$();return(0,r.createElement)(ma,{name:n,className:"searchregex-integer-input",value:t,disabled:o,onBlur:function(e){const t=String(e).replace(/[^0-9]/g,"").trim();return t.length>0?String(parseInt(t,10)):""},onChange:e=>a({[n]:e}),fetchData:l,canMakeRequest:e=>e.length>0&&e.replace(/[0-9]/g,"").length>0,maxChoices:l?1:-1,onlyChoices:!!l,setLabel:(e,t)=>s(ji(i+"_"+e,t)),getLabel:(e,t)=>Bt(u,i+"_"+e,t)})},Ii=function(e){const{disabled:t,item:n,onChange:a,schema:o,fetchData:l}=e,{logic:i="equals",startValue:u="",endValue:s=""}=n,c="api"===o.options&&l,p="equals"===i||"notequals"===i?1:-1;return"has"===i||"hasnot"===i?(0,r.createElement)(Di,{type:"integer-join",value:i,disabled:t,onChange:e=>a({logic:e,startValue:"",endValue:""})}):(0,r.createElement)(r.Fragment,null,(0,r.createElement)(Di,{type:o.joined_by?"integer-join":"integer",value:i,disabled:t,onChange:e=>a({logic:e,startValue:"",endValue:""})}),"range"!==i&&(0,r.createElement)(Ai,{name:"startValue",column:n.column,value:u,onChange:a,disabled:t,remote:!!p&&c}),"range"===i&&zl((0,et.__)("between {{first/}} and {{second/}}","search-regex"),{first:(0,r.createElement)(Ai,{name:"startValue",value:u,onChange:a,disabled:t,remote:!1,column:n.column}),second:(0,r.createElement)(Ai,{name:"endValue",value:s,onChange:a,disabled:t,remote:!1,column:n.column})}))};Math.pow(10,8);var Fi=36e5;function Li(e,t){if(t.length<e)throw new TypeError(e+" argument"+(e>1?"s":"")+" required, but only "+t.length+" present")}function Ui(e){if(null===e||!0===e||!1===e)return NaN;var t=Number(e);return isNaN(t)?t:t<0?Math.ceil(t):Math.floor(t)}function zi(e,t){var n;Li(1,arguments);var r=Ui(null!==(n=null==t?void 0:t.additionalDigits)&&void 0!==n?n:2);if(2!==r&&1!==r&&0!==r)throw new RangeError("additionalDigits must be 0, 1 or 2");if("string"!=typeof e&&"[object String]"!==Object.prototype.toString.call(e))return new Date(NaN);var a,o=qi(e);if(o.date){var l=Vi(o.date,r);a=$i(l.restDateString,l.year)}if(!a||isNaN(a.getTime()))return new Date(NaN);var i,u=a.getTime(),s=0;if(o.time&&(s=Qi(o.time),isNaN(s)))return new Date(NaN);if(!o.timezone){var c=new Date(u+s),p=new Date(0);return p.setFullYear(c.getUTCFullYear(),c.getUTCMonth(),c.getUTCDate()),p.setHours(c.getUTCHours(),c.getUTCMinutes(),c.getUTCSeconds(),c.getUTCMilliseconds()),p}return i=Gi(o.timezone),isNaN(i)?new Date(NaN):new Date(u+s+i)}var Yi={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},Wi=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,Bi=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,Hi=/^([+-])(\d{2})(?::?(\d{2}))?$/;function qi(e){var t,n={},r=e.split(Yi.dateTimeDelimiter);if(r.length>2)return n;if(/:/.test(r[0])?t=r[0]:(n.date=r[0],t=r[1],Yi.timeZoneDelimiter.test(n.date)&&(n.date=e.split(Yi.timeZoneDelimiter)[0],t=e.substr(n.date.length,e.length))),t){var a=Yi.timezone.exec(t);a?(n.time=t.replace(a[1],""),n.timezone=a[1]):n.time=t}return n}function Vi(e,t){var n=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+t)+"})|(\\d{2}|[+-]\\d{"+(2+t)+"})$)"),r=e.match(n);if(!r)return{year:NaN,restDateString:""};var a=r[1]?parseInt(r[1]):null,o=r[2]?parseInt(r[2]):null;return{year:null===o?a:100*o,restDateString:e.slice((r[1]||r[2]).length)}}function $i(e,t){if(null===t)return new Date(NaN);var n=e.match(Wi);if(!n)return new Date(NaN);var r=!!n[4],a=Zi(n[1]),o=Zi(n[2])-1,l=Zi(n[3]),i=Zi(n[4]),u=Zi(n[5])-1;if(r)return function(e,t,n){return t>=1&&t<=53&&n>=0&&n<=6}(0,i,u)?function(e,t,n){var r=new Date(0);r.setUTCFullYear(e,0,4);var a=7*(t-1)+n+1-(r.getUTCDay()||7);return r.setUTCDate(r.getUTCDate()+a),r}(t,i,u):new Date(NaN);var s=new Date(0);return function(e,t,n){return t>=0&&t<=11&&n>=1&&n<=(Xi[t]||(Ji(e)?29:28))}(t,o,l)&&function(e,t){return t>=1&&t<=(Ji(e)?366:365)}(t,a)?(s.setUTCFullYear(t,o,Math.max(a,l)),s):new Date(NaN)}function Zi(e){return e?parseInt(e):1}function Qi(e){var t=e.match(Bi);if(!t)return NaN;var n=Ki(t[1]),r=Ki(t[2]),a=Ki(t[3]);return function(e,t,n){return 24===e?0===t&&0===n:n>=0&&n<60&&t>=0&&t<60&&e>=0&&e<25}(n,r,a)?n*Fi+6e4*r+1e3*a:NaN}function Ki(e){return e&&parseFloat(e.replace(",","."))||0}function Gi(e){if("Z"===e)return 0;var t=e.match(Hi);if(!t)return 0;var n="+"===t[1]?-1:1,r=parseInt(t[2]),a=t[3]&&parseInt(t[3])||0;return function(e,t){return t>=0&&t<=59}(0,a)?n*(r*Fi+6e4*a):NaN}var Xi=[31,null,31,30,31,30,31,31,30,31,30,31];function Ji(e){return e%400==0||e%4==0&&e%100!=0}const eu=function(e){const{disabled:t,item:n,onChange:a}=e,{logic:o="=",startValue:i=0,endValue:u=0}=n,s="string"==typeof i?zi(i):i,c="string"==typeof u?zi(u):u;return(0,r.createElement)(r.Fragment,null,(0,r.createElement)(Di,{type:"integer",value:o,disabled:t,onChange:e=>a({logic:e})}),"range"!==o&&(0,r.createElement)(l(),{disabled:t,selected:s,onChange:e=>a({startValue:e}),showTimeSelect:!0,dateFormat:"MMMM d, yyyy hh:mm"}),"range"===o&&zl((0,et.__)("between {{first/}} and {{second/}}","search-regex"),{first:(0,r.createElement)(l(),{selected:s,onChange:e=>a({startValue:e}),selectsStart:!0,startDate:s,endDate:c,showTimeSelect:!0,dateFormat:"MMMM d, yyyy hh:mm"}),second:(0,r.createElement)(l(),{selected:c,onChange:e=>a({endValue:e}),selectsEnd:!0,startDate:s,endDate:c,minDate:s,showTimeSelect:!0,dateFormat:"MMMM d, yyyy hh:mm"})}))},tu=function(e){const{flags:t,onChange:n,disabled:a,allowRegex:o=!0,allowMultiline:l=!1,allowCase:i=!0}=e,u=Tt().filter((e=>"regex"!==e.value||o)).filter((e=>"case"!==e.value||i)).filter((e=>"multi"!==e.value||l));return(0,r.createElement)(Ea,{options:u,selected:t,onApply:e=>n(e),title:(0,et.__)("Flags","search-regex"),disabled:a,multiple:!0,badges:!0})},nu=function(e){const{disabled:t,item:n,onChange:a,schema:o,fetchData:l}=e,{logic:i="equals",value:u="",flags:s=["case"]}=n,c="api"===o.options&&-1===s.indexOf("regex")&&l;return(0,r.createElement)(r.Fragment,null,(0,r.createElement)(Di,{type:"string",value:i,disabled:t,onChange:e=>a({logic:e,flags:["case"]})}),-1===s.indexOf("multi")?(0,r.createElement)(ma,{value:u,disabled:t,onChange:e=>a({value:e}),fetchData:c}):(0,r.createElement)("textarea",{value:u,disabled:t,onChange:e=>a({value:e.target.value})}),(0,r.createElement)(tu,{flags:s,disabled:t,onChange:e=>a({flags:e}),allowRegex:"equals"===i||"notcontains"===i,allowMultiline:o.multiline||!1}))};function ru(e,t,n){return""===t?-1===e.indexOf("")?[]:n:e.filter((e=>""!==e))}function au(e,t){return e.length===t?[""].concat(e):e}function ou(e){return[{value:"",label:(0,et.__)("All","search-regex")}].concat(e)}const lu=function(e){var t;const{disabled:n,item:a,onChange:o,schema:l,fetchData:i}=e,{logic:u="include",values:s=[],flags:c=["case"]}=a,p="api"===l.options&&i,{labels:d}=b((e=>e.search)),f=$(),h=(0,r.createElement)(Di,{type:"member",value:u,disabled:n,onChange:e=>o({logic:e,values:[]})});return"contains"===u||"notcontains"===u?(0,r.createElement)(r.Fragment,null,h,(0,r.createElement)(ma,{value:0===s.length?"":s[0],disabled:n,onChange:e=>o({values:[e]})}),(0,r.createElement)(tu,{flags:c,disabled:n,onChange:e=>o({flags:e}),allowRegex:!1,allowMultiline:!1})):p?(0,r.createElement)(r.Fragment,null,h,(0,r.createElement)(ma,{value:s,disabled:n,onChange:e=>o({values:e}),fetchData:p,loadOnFocus:l.preload,maxChoices:20,onlyChoices:!0,setLabel:(e,t)=>f(ji(l.column+"_"+e,t)),getLabel:e=>Bt(d,l.column+"_"+e)})):(0,r.createElement)(r.Fragment,null,h,!p&&(0,r.createElement)(Ea,{options:ou(l.options),selected:au(s,l.options.length),onApply:(e,t)=>o({values:ru(e,t,l.options.map((e=>e.value)))}),multiple:null===(t=l.multiple)||void 0===t||t,disabled:n,hideTitle:!0,title:l.title,badges:!0,customBadge:e=>e.length>=l.options.length?[""]:e}))},iu=function(e){const{disabled:t,item:n,onChange:a,schema:o,fetchData:l}=e,{key:i="",keyLogic:u="equals",keyFlags:s=["case"],value:c="",valueLogic:p="any",valueFlags:d=["case"]}=n,f="api"===o.options&&l;return(0,r.createElement)("div",{className:"searchregex-filter__keyvalue"},(0,r.createElement)("div",{className:"searchregex-filter__keyvalue__item"},(0,r.createElement)("span",null,(0,et.__)("Meta Key","search-regex")),(0,r.createElement)(Di,{type:"keyvalue",value:u,disabled:t,onChange:e=>a({keyLogic:e,key:"any"===e?"":i})}),(0,r.createElement)(ma,{value:i,disabled:t||"any"===u,onChange:e=>a({key:e}),fetchData:f,loadOnFocus:o.preload}),(0,r.createElement)(tu,{flags:s,disabled:t||"any"===u,onChange:e=>a({keyFlags:e}),allowRegex:!1,allowMultiline:!1})),(0,r.createElement)("div",{className:"searchregex-filter__keyvalue__item"},(0,r.createElement)("span",null,(0,et.__)("Meta Value","search-regex")),(0,r.createElement)(Di,{type:"keyvalue",value:p,disabled:t,onChange:e=>a({valueLogic:e,value:"any"===e?"":c})}),-1===d.indexOf("multi")?(0,r.createElement)(ma,{value:c,disabled:t||"any"===p,onChange:e=>a({value:e})}):(0,r.createElement)("textarea",{value:c,disabled:t||"any"===p,onChange:e=>a({value:e.target.value})}),(0,r.createElement)(tu,{flags:d,disabled:t||"any"===p,onChange:e=>a({valueFlags:e}),allowRegex:!1,allowMultiline:!0})))},uu=function(e){const{type:t}=e.schema;return"integer"===t?(0,r.createElement)(Ii,e):"date"===t?(0,r.createElement)(eu,e):"string"===t?(0,r.createElement)(nu,e):"member"===t?(0,r.createElement)(lu,e):"keyvalue"===t?(0,r.createElement)(iu,e):null};function su(e){return e.map((e=>({label:e.title,value:e.column})))}function cu(e){let{item:t,columns:n,disabled:a,onChange:o,schema:l,fetchData:i,onRemove:u}=e;return l?(0,r.createElement)("div",{className:kn()("searchregex-filter__item",`searchregex-filter__type__${l.type}`)},(0,r.createElement)(Ua,{name:"filter_type",items:su(n),value:t.column,disabled:a,onChange:e=>o({column:e.target.value})}),(0,r.createElement)("span",{onClick:a?()=>{}:u,className:kn()("dashicons","dashicons-trash",a&&"dashicons__disabled")}),(0,r.createElement)(uu,{schema:l,item:t,disabled:a,fetchData:i,onChange:e=>o({...t,...e})})):null}const pu=function(e){const{schema:t,items:n,disabled:a,onChange:o,onRemove:l,source:u}=e;return t?(0,r.createElement)("div",{className:"searchregex-filter__column"},(0,r.createElement)("div",{className:"searchregex-filter__name"},(0,r.createElement)("span",null,t.name),(0,r.createElement)("span",{onClick:a?()=>{}:l,className:kn()("dashicons","dashicons-trash",a&&"dashicons__disabled")})),(0,r.createElement)("div",{className:kn()("searchregex-filter__content",n.length>1&&"searchregex-filter__content__multiple")},n.map(((e,s)=>(0,r.createElement)(i.Fragment,{key:`${t.name}-${e.column}-${s}`},(0,r.createElement)(cu,{item:e,schema:t.columns.find((t=>e.column===t.column)),columns:t.columns,disabled:a,fetchData:t=>function(e,t){return st(Jl.source.complete(u,e,t))}(e.column,t),onChange:e=>o([...n.slice(0,s),e,...n.slice(s+1)]),onRemove:()=>{return e=s,void(1===n.length?l():o([...n.slice(0,e),...n.slice(e+1)]));var e}}),s!==n.length-1&&(0,r.createElement)(Cn,{disabled:a},(0,et.__)("OR","search-regex")))))),(0,r.createElement)("div",{className:"searchregex-filter__action"},(0,r.createElement)(Pl,{disabled:a||10===n.length,onClick:function(){o(n.concat([{column:n[n.length-1].column}]))}},(0,et.__)("Add sub-filter (OR)","search-regex")))):null},du=function(e){let{filters:t,disabled:n,onSetSearch:a,tags:o,presetFilters:l}=e;const u=b((e=>e.search.schema));function s(e){a({filters:e})}return 0===t.length?null:(0,r.createElement)("tr",null,(0,r.createElement)("th",null,(0,et.__)("Filters","search-regex")),(0,r.createElement)("td",null,(0,r.createElement)("div",{className:"searchregex-filters"},t.map(((e,a)=>{let{type:c,items:p}=e;const d=l.find((e=>e.type===c)),f=p.filter(((e,t)=>{if(d){const e=d.items[t];return!kt(o,e)}return!0}));return 0===f.length?null:(0,r.createElement)(i.Fragment,{key:c+"_"+a},(0,r.createElement)(pu,{type:c,schema:Lt(u,c),items:f,disabled:n,source:c,onChange:e=>s([...t.slice(0,a),{...t[a],items:e},...t.slice(a+1)]),onRemove:()=>s([...t.slice(0,a),...t.slice(a+1)])}),function(e,n){return e!==t.length-1&&t[e+1].type===n}(a,c)?(0,r.createElement)(Cn,{disabled:n},(0,et.__)("AND","search-regex")):(0,r.createElement)("div",{className:"searchregex-filters__break"}))})))))};function fu(e){return e.map((e=>({label:e.label,value:e.name,options:e.sources.map((e=>{let{label:t,name:n}=e;return{label:t,value:n}}))})))}const hu=function(e){const{disabled:t,columns:n,source:a,onSetSearch:o}=e,{schema:l}=b((e=>e.search)),u=function(e,t){return e.columns.filter((e=>void 0===e.modify||e.modify)).filter((e=>(void 0===t.find((t=>t.column===e.column))||void 0!==e.join||"keyvalue"===e.type)&&e)).map((e=>({label:e.title,value:e.column})))}(Lt(l,a),n),[s,c]=(0,i.useState)(u.length>0?u[0].value:"");return(0,i.useEffect)((()=>{c(u.length>0?u[0].value:"")}),[n]),0===u.length?null:(0,r.createElement)(r.Fragment,null,(0,r.createElement)("span",null,(0,et.__)("Column","search-regex")),(0,r.createElement)(Ua,{items:u,name:"modify",value:s,disabled:t,className:"searchregex-search__action__modify",onChange:e=>c(e.target.value)}),(0,r.createElement)(Pl,{disabled:t,onClick:function(){const e=function(e,t){const n=t.columns?Ut(t.columns,e):t,r=function(e){return"member"===e.type&&Array.isArray(e.options)?{values:[e.options[0].value]}:{}}(n);return{column:n.column,operation:"",source:t.type,...r}}(s||u[0].value,Lt(l,a));o({actionOption:n.concat([e])})}},(0,et.__)("Add","search-regex")))};function mu(e){return"member"===e?[{value:"replace",label:(0,et.__)("Replace With","search-regex")},{value:"include",label:(0,et.__)("Add","search-regex")},{value:"exclude",label:(0,et.__)("Remove","search-regex")}]:"string"===e?[{value:"set",label:(0,et.__)("Set Value","search-regex")},{value:"replace",label:(0,et.__)("Replace","search-regex")}]:"keyvalue"===e?[{value:"add",label:(0,et.__)("Add","search-regex")},{value:"remove",label:(0,et.__)("Remove","search-regex")}]:[{value:"set",label:(0,et.__)("Set Value","search-regex")},{value:"increment",label:(0,et.__)("Increment","search-regex")},{value:"decrement",label:(0,et.__)("Decrement","search-regex")}]}function gu(e){let{value:t,disabled:n,onChange:a,type:o,extraItems:l=[]}=e;return(0,r.createElement)(Ua,{name:"operation",items:mu(o).concat(l),disabled:n,value:t,onChange:e=>a(e.target.value)})}const yu=function(e){const{disabled:t,item:n,onChange:a,schema:o,fetchData:l,fixOperation:i}=e,{operation:u=i||"set",value:s=""}=n,c="api"===o.options&&l,{labels:p}=b((e=>e.search)),d=$();return c?(0,r.createElement)(ma,{value:""===s||void 0===s?[]:[s],disabled:t,onChange:(e,t)=>a(e?{value:e[0]}:{value:""},e?t[0]:""),fetchData:c,loadOnFocus:!0,maxChoices:1,onlyChoices:!0,setLabel:(e,t)=>d(ji(o.column+"_"+e,t)),getLabel:e=>Bt(p,o.column+"_"+e)}):(0,r.createElement)(r.Fragment,null,!i&&(0,r.createElement)(gu,{type:"integer",value:u,disabled:t,onChange:e=>a({operation:e,value:""})}),(0,r.createElement)(Ai,{name:"value",value:s,onChange:a,disabled:t,remote:c}))},vu=function(e){const{disabled:t,item:n,onChange:a,fixOperation:o}=e,{operation:i=o||"set",value:u="",unit:s="second"}=n;return(0,r.createElement)(r.Fragment,null,!o&&(0,r.createElement)(gu,{type:"date",value:i,disabled:t,onChange:e=>a({operation:e,unit:"second"})}),("set"===i||""===i)&&(0,r.createElement)(l(),{selected:u,onChange:e=>a({value:e}),showTimeSelect:!0,dateFormat:"MMMM d, yyyy hh:mm",withPortal:o}),"set"!==i&&""!==i&&(0,r.createElement)(r.Fragment,null,(0,r.createElement)("input",{type:"number",value:u,onChange:e=>a({value:e.target.value}),disabled:t}),(0,r.createElement)(Ua,{name:"unit",value:s,onChange:e=>a({unit:e.target.value}),disabled:t,items:[{value:"second",label:(0,et.__)("Seconds","search-regex")},{value:"minute",label:(0,et.__)("Minutes","search-regex")},{value:"hour",label:(0,et.__)("Hours","search-regex")},{value:"day",label:(0,et.__)("Days","search-regex")},{value:"week",label:(0,et.__)("Weeks","search-regex")},{value:"month",label:(0,et.__)("Months","search-regex")},{value:"year",label:(0,et.__)("Year","search-regex")}]})))};function bu(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function wu(e){return"begins"===e.logic||"ends"===e.logic||-1!==e.flags.indexOf("regex")?e.flags.concat(["regex"]):e.flags}function Eu(e){return"begins"===e.logic?"^"+bu(e.value):"ends"===e.logic?bu(e.value)+"$":e.value}const _u=function(e){const{disabled:t,item:n,onChange:a,schema:o,fetchData:l}=e,{operation:u="set",searchValue:s="",replaceValue:c="",searchFlags:p=["case"]}=n,[d,f]=(0,i.useState)("set"),h="api"===o.options&&-1===(m=p).indexOf("regex")&&-1===m.indexOf("multi")&&l;var m;const{filters:g,searchPhrase:y,searchFlags:v}=b((e=>e.search.search)),w=function(e,t,n,r){const a=[];n&&a.push({column:"global",value:n,logic:"contains",flags:r});for(let n=0;n<e.length;n++)if(e[n].type===t.source)for(let r=0;r<e[n].items.length;r++)if(e[n].items[r].column===t.column){const t=e[n].items[r];"notcontains"!==t.logic&&"notequals"!==t.logic&&t.value&&a.push(e[n].items[r])}return a}(g,n,y,v),E={value:s,disabled:t,onChange:e=>a({searchValue:e})},_={value:c,disabled:t,onChange:e=>a({replaceValue:e}),length:o.length?o.length:0};return(0,i.useEffect)((()=>{a(function(e,t){const n=t.find((t=>t.column+"-"+t.value===e));return{operation:n?"replace":e,searchValue:n?Eu(n):"",searchFlags:n?wu(n):[]}}(d,w))}),[d,g]),-1===p.indexOf("multi")&&(E.fetchData=h,_.fetchData=h),(0,r.createElement)(r.Fragment,null,(0,r.createElement)(gu,{type:"string",value:d,disabled:t,onChange:f,extraItems:w.map((e=>({value:e.column+"-"+e.value,label:(0,et.sprintf)((0,et.__)('Replace "%1s"',"search-regex"),e.value.substr(0,20))})))}),"replace"===u&&"replace"===d&&(0,r.createElement)(r.Fragment,null,(0,et.__)("Search","search-regex"),-1===p.indexOf("multi")?(0,r.createElement)(ma,E):(0,r.createElement)("textarea",E),(0,et.__)("Replace","search-regex")),-1===p.indexOf("multi")?(0,r.createElement)(ma,_):(0,r.createElement)("textarea",_),(o.multiline||"replace"===u&&"replace"===d)&&(0,r.createElement)(tu,{flags:p,disabled:t,onChange:e=>a({searchFlags:e}),allowRegex:"replace"===u,allowMultiline:o.multiline||!1,allowCase:"replace"===u}))},xu=function(e){const{disabled:t,item:n,onChange:a,schema:o,fetchData:l,fixOperation:i,localLabels:u=[]}=e,{operation:s="include",values:c=[]}=n,p="api"===o.options&&l,{labels:d}=b((e=>e.search)),f=$(),h=void 0!==o.join;return p?(0,r.createElement)(r.Fragment,null,h&&!i&&(0,r.createElement)(gu,{type:"member",value:s,disabled:t,onChange:e=>a({operation:e})}),(0,r.createElement)(ma,{value:c,disabled:t,onChange:(e,t)=>a({values:e,label:t}),fetchData:p,loadOnFocus:o.preload,maxChoices:h?20:1,onlyChoices:!0,setLabel:(e,t)=>f(ji(o.column+"_"+e,t)),getLabel:e=>Bt(d.concat(u),o.column+"_"+e)})):(0,r.createElement)(Ua,{name:"member",items:o.options,value:c.length>0?c[0]:o.options[0].value,disabled:t,onChange:e=>a({values:[e.target.value]})})},Su=function(e){const{disabled:t,item:n,onChange:a,schema:o,fetchData:l}=e,{operation:i="add",key:u="",value:s="",valueFlags:c=["case"]}=n,p="api"===o.options&&l;return(0,r.createElement)(r.Fragment,null,(0,r.createElement)(gu,{type:"keyvalue",value:i,disabled:t,onChange:e=>a({operation:e,key:"",value:""})}),(0,r.createElement)("div",{className:"searchregex-filter__keyvalue"},(0,r.createElement)("div",{className:"searchregex-filter__keyvalue__item"},(0,r.createElement)("span",null,(0,et.__)("Meta Key","search-regex")),"replace_key"===i&&(0,et.__)("Search","search-regex"),(0,r.createElement)(ma,{value:u,disabled:t,onChange:e=>a({key:e}),fetchData:p&&"replace_key"!==i?p:null,loadOnFocus:o.preload})),"remove"!==i&&(0,r.createElement)("div",{className:"searchregex-filter__keyvalue__item"},(0,r.createElement)("span",null,(0,et.__)("Meta Value","search-regex")),"replace_value"===i&&(0,et.__)("Search","search-regex"),-1===c.indexOf("multi")?(0,r.createElement)(ma,{value:s,disabled:t,onChange:e=>a({value:e})}):(0,r.createElement)("textarea",{value:s,disabled:t,onChange:e=>a({value:e.target.value})}),(0,r.createElement)(tu,{flags:c,disabled:t,onChange:e=>a({valueFlags:e}),allowRegex:!1,allowMultiline:!0,allowCase:!1}))))},ku=function(e){const{type:t}=e.schema;return"integer"===t?(0,r.createElement)(yu,e):"date"===t?(0,r.createElement)(vu,e):"string"===t?(0,r.createElement)(_u,e):"member"===t?(0,r.createElement)(xu,e):"keyvalue"===t?(0,r.createElement)(Su,e):null},Cu=function(e){const{disabled:t,schema:n,column:a,onRemove:o,onChange:l}=e;return(0,r.createElement)("div",{className:"searchregex-modify"},(0,r.createElement)("div",{className:"searchregex-modify__name"},(0,r.createElement)("span",null,n.title),o&&(0,r.createElement)("span",{onClick:t?()=>{}:o,className:kn()("dashicons","dashicons-trash",t&&"dashicons__disabled")})),(0,r.createElement)(ku,{disabled:t,schema:n,item:a,onChange:l,fetchData:function(e){return st(Jl.source.complete(a.source,a.column,e))}}))},Du=function(e){const{disabled:t,replacement:n,setReplace:a}=e,[o,l]=(0,i.useState)("single"),u={id:"replace",value:n,disabled:t||"remove"===o,placeholder:"remove"===o?(0,et.__)("Matched values will be removed","search-regex"):(0,et.__)("Enter replacement value","search-regex"),name:"replace",onChange:e=>{a({replacement:e.target.value})}};return(0,i.useEffect)((()=>{"remove"===o?a({replacement:null}):null===n&&a({replacement:""})}),[o]),(0,r.createElement)(r.Fragment,null,-1===o.indexOf("multi")?(0,r.createElement)("input",w({type:"text"},u)):(0,r.createElement)("textarea",u),(0,r.createElement)(Ua,{disabled:t,items:[{value:"",label:(0,et.__)("Single","search-regex")},{value:"multi",label:(0,et.__)("Multi","search-regex")},{value:"remove",label:(0,et.__)("Remove","search-regex")}],value:o,name:"search-flags",onChange:e=>l(e.target.value)}))};function Ou(e,t){return[{label:(0,et.__)("No action","search-regex"),value:"",desc:(0,et.__)("Just show matching results.","search-regex")},{label:(0,et.__)("Global Text Replace","search-regex"),value:"replace",desc:(0,et.__)("Replace the global search values.","search-regex")},{label:(0,et.__)("Modify Matches","search-regex"),value:"modify",desc:(0,et.__)("Perform changes to specific values of the matching results.","search-regex")},{label:(0,et.__)("Export Matches","search-regex"),value:"export",desc:(0,et.__)("Export matching results to JSON, CSV, or SQL.","search-regex"),disabled:!t},{label:(0,et.__)("Delete Matches","search-regex"),value:"delete",desc:(0,et.__)("Delete matching results.","search-regex")},{label:(0,et.__)("Run Action","search-regex"),value:"action",desc:(0,et.__)("Run a WordPress action for each matching result.","search-regex")}]}const Pu=function(e){var t,n,a,o;const{locked:l,tags:u,preset:s,headerClass:c,searchPhrase:p,disabled:d,sources:f,onSetSearch:h,search:m}=e,{schema:g}=b((e=>e.search)),{action:y="",actionOption:v={},replacement:w}=m,E=Ou(p&&p.length,1===f.length),_=E.find((e=>e.value===y))||E[0],[x,S]=(0,i.useState)(f.length>0?f[0]:""),k=Ht(f,g);return(0,i.useEffect)((()=>{_.disabled&&h({action:E[0].value,actionOption:[]}),S(f.length>0?f[0]:"")}),[f]),(0,r.createElement)(r.Fragment,null,!xt(l,"replacement")&&!St(u,null!==(t=null==s||null===(n=s.search)||void 0===n?void 0:n.replacement)&&void 0!==t?t:"")&&(0,r.createElement)("tr",{className:kn()("searchregex-search__action",c)},(0,r.createElement)("th",null,(0,et.__)("Action","search-regex")),(0,r.createElement)("td",null,(0,r.createElement)(Ua,{items:E,name:"action",value:y,disabled:d,className:"searchregex-search__action__type",onChange:e=>h({action:e.target.value,actionOption:[]})}),"modify"===y&&(0,r.createElement)(r.Fragment,null,(0,r.createElement)("span",null,(0,et.__)("Source","search-regex")),(0,r.createElement)(Ua,{disabled:d,name:"actionSource",value:x,onChange:e=>S(e.target.value),items:k}),(0,r.createElement)(hu,{columns:v,disabled:d,source:x,onSetSearch:h})),"export"===y&&(0,r.createElement)(r.Fragment,null,(0,r.createElement)("span",null,(0,et.__)("Export Format","search-regex")),(0,r.createElement)(Ua,{items:[{value:"json",label:(0,et.__)("JSON","search-regex")},{value:"csv",label:(0,et.__)("CSV","search-regex")},{value:"sql",label:(0,et.__)("SQL","search-regex")}],name:"export",value:v.format||"json",disabled:d,onChange:e=>h({actionOption:{format:e.target.value}})})),"action"===y&&(0,r.createElement)(r.Fragment,null,(0,r.createElement)("span",null,(0,et.__)("WordPress Action","search-regex")),(0,r.createElement)("input",{type:"text",className:"",value:v.hook||"",onChange:e=>h({actionOption:{hook:e.target.value}}),disabled:d})),(0,r.createElement)("span",null,_.desc))),"export"===y&&(0,r.createElement)("tr",{className:"searchregex-search__export"},(0,r.createElement)("th",null),(0,r.createElement)("td",null,(0,r.createElement)("p",null,(0,r.createElement)("label",null,(0,r.createElement)("input",{type:"checkbox",checked:v.selectedOnly||!1,onChange:e=>h({actionOption:{...v,selectedOnly:e.target.checked}})}),(0,et.__)("Only include selected columns","search-regex"))))),"modify"===y&&v.length>0&&(0,r.createElement)("tr",null,(0,r.createElement)("th",null),(0,r.createElement)("td",null,v.filter(((e,t)=>!Ct(u,function(e,t){return e?e.search.actionOption[t]:{}}(s,t)))).map(((e,t)=>(0,r.createElement)(Cu,{column:e,disabled:d,key:t+"-"+e.column,schema:zt(g,e.source,e.column),onRemove:()=>function(e){h({actionOption:v.filter((t=>t.column!==e.column))})}(e),onChange:(e,n)=>function(e,t,n){h({actionOption:[...v.slice(0,e),{...v[e],...t,...n?{label:n}:{}},...v.slice(e+1)]})}(t,e,n)}))))),"replace"===y&&!St(u,null!==(a=null==s||null===(o=s.search)||void 0===o?void 0:o.replacement)&&void 0!==a?a:"")&&(0,r.createElement)("tr",{className:"searchregex-search__replace"},(0,r.createElement)("th",null,(0,et.__)("Replace","search-regex")),(0,r.createElement)("td",null,(0,r.createElement)(Du,{replacement:w,locked:l,tags:u,preset:s,disabled:d,setReplace:h}))))};function Tu(e,t,n){return t.reduce(((e,t,r)=>function(e,t,n){const r=t.replace(/[.*+\-?^${}()|[\]\\]/g,"\\$&");return e.replace(new RegExp(r,"g"),n)}(e,t.name,n[r])),e)}function Nu(e,t,n){return{searchPhrase:Tu(e.searchPhrase,t,n),replacement:Tu(e.replacement,t,n),filters:e.filters.map((e=>({...e,items:e.items.map((e=>({...e,...void 0===e.value?{}:{value:Tu(e.value,t,n)}})))}))),actionOption:Array.isArray(e.actionOption)?e.actionOption.map((e=>void 0===e.searchValue?e:{...e,searchValue:Tu(e.searchValue,t,n),replaceValue:Tu(e.replaceValue,t,n)})):e.actionOption}}const Mu=function(e){const{search:t,values:n,onChange:a,className:o,tags:l,disabled:u=!1}=e,[s,c]=(0,i.useState)(l.map((e=>"")));return l.map(((e,i)=>(0,r.createElement)("tr",{className:kn()("searchregex-preset__tag",o),key:e.name},(0,r.createElement)("th",null,e.title),(0,r.createElement)("td",null,(0,r.createElement)("input",{type:"text",value:s[i],placeholder:e.title,onChange:e=>function(e,r){const o=s.slice(0,r).concat(e,s.slice(r+1));c(o),a({...n,...Nu(t,l,o)})}(e.target.value,i),disabled:u})))))};function Ru(e,t,n,r){return e.map((e=>{const a=Lt(t,e),o=a.columns.filter((t=>!function(e,t,n){return void 0!==e.find((e=>e.type===t&&e.items.find((e=>e.column===n))))}(n,e,t.column)&&!function(e,t,n){return!!Array.isArray(e)&&void 0!==e.find((e=>e.source===t&&e.column===n))}(r,e,t.column)));return o.length>0&&{value:e,label:a.name,options:o.map((t=>({value:e+"__"+t.column,label:t.title})))}})).filter(Boolean)}const ju=W((function(e){const{sources:t,schema:n}=e.search;return{sources:t,schema:n}}),null)((function(e){var t,n,a,o;let{search:l,onSetSearch:u,isBusy:s,sources:c,preset:p,schema:d}=e;const{searchPhrase:f,searchFlags:h,source:m,perPage:g,replacement:y,filters:v=[],actionOption:b,view:w=[]}=l,E=p?p.locked:[],_=p?p.tags:[],x=Dt(_),S=Pt(p),k=Ht(m,d),[C,D]=(0,i.useState)(k.length>0?k[0].value:""),O=function(e,t){if(0===t.length)return!0;let n=0,r=0;for(let a=0;a<e.length;a++)for(let o=0;o<e[a].items.length;o++)r++,n+=kt(t,e[a].items[o])?1:0;return n!==r}(v,_)&&!xt(E,"filters");return(0,i.useEffect)((()=>{-1===k.indexOf(C)&&D(k.length>0?k[0].value:"")}),[m]),(0,r.createElement)(r.Fragment,null,p&&p.description?(0,r.createElement)("tr",null,(0,r.createElement)("th",null),(0,r.createElement)("td",null,(0,r.createElement)("h3",{className:"searchregex-preset__description"},p.description))):null,(!xt(E,"source")||O)&&(0,r.createElement)("tr",{className:kn()("searchregex-search__source",x)},(0,r.createElement)("th",null,(0,et.__)("Source","search-regex")),(0,r.createElement)("td",null,!xt(E,"source")&&(0,r.createElement)(Ea,{options:fu(c),selected:m,onApply:(e,t)=>u(function(e,t){const n=function(e){return 0===e.length?["posts"]:e}(e),r=Ht(n,d).map((e=>e.value)),a=-1!==n.indexOf(t)?It(t).filter((e=>-1===r.indexOf(e.type))):[];return{source:n,filters:v.filter((e=>-1!==r.indexOf(e.type))).concat(a),actionOption:[],view:w.filter((e=>-1!==n.indexOf(e.split("__")[0])))}}(e,t)),multiple:!0,disabled:s,badges:!0,title:0===m.length?(0,et.__)("Source","search-regex"):"","aria-label":(0,et.__)("Sources","search-regex")}),O&&(0,r.createElement)(r.Fragment,null,(0,r.createElement)("span",null,(0,r.createElement)("strong",null,(0,et.__)("Filters","search-regex"))),(0,r.createElement)(Ua,{disabled:s,name:"filter",value:C,onChange:e=>D(e.target.value),items:k}),(0,r.createElement)(Pl,{onClick:function(){u({filters:v.concat(Wt(C,Lt(d,C)))})},disabled:s||v.length>=20},(0,et.__)("Add","search-regex"))))),O&&(0,r.createElement)(du,{filters:v,disabled:s,onSetSearch:u,tags:_,presetFilters:null!==(t=null==p||null===(n=p.search)||void 0===n?void 0:n.filters)&&void 0!==t?t:[]}),(!xt(E,"searchFlags")||!xt(E,"searchPhrase"))&&!St(_,null!==(a=null==p||null===(o=p.search)||void 0===o?void 0:o.searchPhrase)&&void 0!==a?a:"")&&(0,r.createElement)("tr",{className:kn()("searchregex-search__search",x)},(0,r.createElement)("th",null,(0,et.__)("Search","search-regex")),(0,r.createElement)("td",null,!xt(E,"searchPhrase")&&(0,r.createElement)(xi,{disabled:s,value:f,onChange:e=>u({searchPhrase:e}),multiline:-1!==h.indexOf("multi")}),!xt(E,"searchFlags")&&(0,r.createElement)(tu,{flags:h,disabled:s,onChange:e=>u({searchFlags:e}),allowMultiline:!0}))),p&&(0,r.createElement)(Mu,{disabled:s,search:p.search,values:l,onChange:e=>u(e),tags:_,className:x,key:p.id}),!xt(E,"action")&&function(e,t,n){if(!n||!Array.isArray(e)||0===t.length)return!0;let r=0,a=0;for(let n=0;n<e.length;n++)a++,r+=Ct(t,e[n])?1:0;return r!==a}(_,b,p)&&(0,r.createElement)(Pu,{locked:E,tags:_,preset:p,headerClass:x,searchPhrase:f,disabled:s,sources:m,onSetSearch:u,search:l}),(!xt(E,"perPage")||!xt(E,"view"))&&(0,r.createElement)("tr",{className:kn()("searchregex-search__results",x)},(0,r.createElement)("th",null,(0,et.__)("Results","search-regex")),(0,r.createElement)("td",null,!xt(E,"perPage")&&(0,r.createElement)(Ua,{name:"perPage",items:Nt(),value:g,onChange:e=>u({perPage:parseInt(e.target.value,10)}),disabled:s}),!xt(E,"view")&&m.length>0&&(0,r.createElement)(Ea,{options:Ru(m,d,v,b),selected:w,onApply:e=>u({view:e}),multiple:!0,disabled:s,title:(0,et.__)("View Columns","search-regex")}))),function(e,t,n){if(n){if(e!==n.searchPhrase&&""!==e)return!0;if(""!==t&&t!==n.replacement)return!0}return!1}(f,y,S)?(0,r.createElement)("tr",{className:kn()(x)},(0,r.createElement)("th",null),(0,r.createElement)("td",null,(0,r.createElement)("code",null,f),y&&(0,r.createElement)(r.Fragment,null," →  ",(0,r.createElement)("code",null,y)))):null)})),Au=function(e){const{preset:t,onCancel:n,onUpdate:a}=e,{name:o,search:l,locked:u,tags:s,description:c}=t,[p,d]=(0,i.useState)(l),[f,h]=(0,i.useState)(o),[m,g]=(0,i.useState)(c),[y,v]=(0,i.useState)(u),[b,w]=(0,i.useState)(0===s.length?[{name:"",title:""}]:s),E=[{value:"searchPhrase",label:(0,et.__)("Global Search","search-regex")},{value:"replacement",label:(0,et.__)("Global Replace","search-regex")},{value:"searchFlags",label:(0,et.__)("Global Search Flags","search-regex")},{value:"source",label:(0,et.__)("Source","search-regex")},{value:"perPage",label:(0,et.__)("Results per page","search-regex")},{value:"filters",label:(0,et.__)("Filters","search-regex")},{value:"action",label:(0,et.__)("Action","search-regex")},{value:"view",label:(0,et.__)("View Columns","search-regex")}];function _(e,t){w([...b.slice(0,e),{...b[e],...t},...b.slice(e+1)])}function x(e){return 1===e.length&&""===e[0].name&&""===e[0].title?[]:e}return(0,r.createElement)("td",{colSpan:3},(0,r.createElement)("table",null,(0,r.createElement)("tbody",null,(0,r.createElement)("tr",null,(0,r.createElement)("td",{colSpan:2},(0,r.createElement)("h2",null,(0,et.__)("Edit preset","search-regex")," "))),(0,r.createElement)("tr",{className:"searchregex-search__search"},(0,r.createElement)("th",null,(0,et.__)("Preset Name","search-regex")),(0,r.createElement)("td",null,(0,r.createElement)("input",{type:"text",value:f,onChange:e=>h(e.target.value),placeholder:(0,et.__)("Give the preset a name","search-regex")}))),(0,r.createElement)("tr",{className:"searchregex-search__search"},(0,r.createElement)("th",null,(0,et.__)("Preset Description","search-regex")),(0,r.createElement)("td",null,(0,r.createElement)("input",{type:"text",value:m,onChange:e=>g(e.target.value),placeholder:(0,et.__)("Describe the preset","search-regex")}))),(0,r.createElement)(ju,{search:p,onSetSearch:e=>d({...p,...e}),isBusy:!1}),(0,r.createElement)("tr",{className:"searchregex-search__advanced__title"},(0,r.createElement)("td",{colSpan:2},(0,r.createElement)("h2",null,(0,et.__)("Advanced preset","search-regex")," "))),(0,r.createElement)("tr",{className:"searchregex-search__advanced"},(0,r.createElement)("th",null,(0,et.__)("Locked Fields","search-regex")),(0,r.createElement)("td",null,(0,r.createElement)(Ea,{options:E,selected:y,onApply:e=>v(e),multiple:!0,title:(0,et.__)("Fields","search-regex"),badges:!0}),(0,r.createElement)("p",null,(0,et.__)("Locking a field removes it from the search form and prevents changes.","search-regex")))),(0,r.createElement)("tr",{className:"searchregex-search__advanced"},(0,r.createElement)("th",null,(0,et.__)("Tags","search-regex")),(0,r.createElement)("td",null,b.map(((e,t)=>(0,r.createElement)("p",{key:t},(0,r.createElement)("label",null,(0,et.__)("Title","search-regex"),(0,r.createElement)("input",{type:"text",placeholder:(0,et.__)("Enter tag title shown to user","search-regex"),value:e.title,onChange:e=>_(t,{title:e.target.value})})),(0,r.createElement)("label",null,(0,et.__)("Tag","search-regex"),(0,r.createElement)("input",{type:"text",placeholder:(0,et.__)("Enter tag which is used in the field","search-regex"),value:e.name,onChange:e=>_(t,{name:e.target.value})})),t<20&&(0,r.createElement)("button",{type:"button",onClick:()=>t===b.length-1?void w(b.concat({name:"",title:""})):function(e){w([...b.slice(0,e),...b.slice(e+1)])}(t)},t===b.length-1?"+":"-")))),(0,r.createElement)("p",null,(0,et.__)("A tag creates a custom input field. Insert the tag anywhere in the search, replace, text filter, or text action and when the preset is used it will be replaced with a custom text field with the tag label.")),(0,r.createElement)("p",null,zl((0,et.__)('For example, create tag {{code}}URL{{/code}} and title {{code}}Image URL{{/code}}. Your search could be {{code}}<img src="URL">{{/code}}. When the preset is used it will ask the user for the {{code}}Image URL{{/code}} instead of the full search phrase.',"search-regex"),{code:(0,r.createElement)("code",null)})))),(0,r.createElement)("tr",null,(0,r.createElement)("th",null),(0,r.createElement)("td",null,(0,r.createElement)("input",{type:"submit",className:"button button-primary",value:(0,et.__)("Save","search-regex"),onClick:e=>function(e){e.preventDefault(),a({name:f,description:m,search:p,tags:x(b),locked:y})}(e)}),(0,r.createElement)("button",{className:"button button-secondary",onClick:n,type:"button"},(0,et.__)("Cancel","search-regex")))))))};function Iu(e,t){for(let n=0;n<e.length;n++)for(let r=0;r<e[n].sources.length;r++)if(e[n].sources[r].name===t)return e[n].sources[r];return null}const Fu=W((function(e){const{sources:t}=e.search;return{sources:t}}),null)((function(e){const{sources:t,preset:n}=e,{search:a,locked:o}=n,l=[],{searchFlags:i,source:u}=a;for(let e=0;e<u.length;e++){const n=Iu(t,u[e]);n&&l.push(n.label)}for(let e=0;e<i.length;e++){const t=Tt().find((t=>t.value===i[e]));t&&"case"!==i[e]&&l.push(t.label)}return o.length>0&&l.push((0,et.__)("Locked fields","search-regex")),(0,r.createElement)("p",null,l.join(", "))}));function Lu(e,t,n){const a=e.split(t),o=[];for(let e=0;e<a.length;e++)e%2!=0&&o.push((0,r.createElement)("code",{title:n,key:`${t}-${e}`},t)),o.push(a[e]);return o}const Uu=function(e){let{phrase:t,tags:n}=e;return""===t?(0,r.createElement)("em",null,(0,et.__)("no phrase","search-regex")):null===t?(0,r.createElement)("em",null,(0,et.__)("remove phrase","search-regex")):function(e,t){let n=[`${e}`];for(let e=0;e<t.length;e++)for(let r=0;r<n.length;r++)"string"==typeof n[r]&&(n=n.slice(0,r).concat(Lu(n[r],t[e].name,t[e].title)).concat(n.slice(r+1)));return n}(t,n)},zu=function(e){const{children:t,preset:n}=e,{search:a,name:o,tags:l}=n,{searchPhrase:i,replacement:u,filters:s,action:c}=a,p=Ou(0,!0).find((e=>e.value===c));return(0,r.createElement)(r.Fragment,null,(0,r.createElement)("td",{className:"searchregex-preset__name"},o),(0,r.createElement)("td",{className:"searchregex-preset__search"},i.length>0&&(0,r.createElement)("p",null,(0,r.createElement)("strong",null,(0,et.__)("Search","search-regex")),": ",(0,r.createElement)(Uu,{phrase:i,tags:l})),s.length>0&&(0,r.createElement)("p",null,(0,r.createElement)("strong",null,(0,et.__)("Filters","search-regex")),": ",s.length),p&&(0,r.createElement)("p",null,(0,r.createElement)("strong",null,(0,et.__)("Action","search-regex")),": ",p.label),u.length>0&&(0,r.createElement)("p",null,(0,r.createElement)("strong",null,(0,et.__)("Replace","search-regex")),": ",(0,r.createElement)(Uu,{phrase:u,tags:l})),t),(0,r.createElement)("td",{className:"searchregex-preset__flags"},(0,r.createElement)(Fu,{preset:n})))};function Yu(e){let t={...e};return delete t.id,0===e.tags.length&&delete t.tags,0===e.locked.length&&delete t.locked,t}const Wu=W(null,(function(e){return{onDelete:t=>{e((e=>t=>(t({type:qe}),st(Jl.preset.delete(e)).then((e=>{t({type:Ve,...e})})).catch((e=>{t({type:$e,error:e})}))))(t))},onUpdatePreset:(t,n)=>{e(ti(t,n))}}}))((function(e){const[t,n]=(0,i.useState)(!1),[a,o]=(0,i.useState)(!1),{preset:l,onDelete:u,onUpdatePreset:s}=e,{id:c}=l;return(0,r.createElement)("tr",{className:t?"searchregex-preset__saving":""},a?(0,r.createElement)(Au,{preset:l,onCancel:()=>o(!1),onUpdate:function(e){s(c,e),o(!1)}}):(0,r.createElement)(zu,{preset:l},(0,r.createElement)("div",{className:"row-actions"},t?(0,r.createElement)(r.Fragment,null," "):(0,r.createElement)(r.Fragment,null,(0,r.createElement)("a",{href:"#",onClick:function(e){e.preventDefault(),o(!0)}},(0,et.__)("Edit","search-regex"))," ","|"," ",(0,r.createElement)("a",{href:"#",onClick:function(e){e.preventDefault(),confirm((0,et.__)("Are you sure you want to delete this preset?","search-regex"))&&(n(!0),u(c))}},(0,et.__)("Delete","search-regex"))," ","|"," ",(0,r.createElement)(_i.CopyToClipboard,{text:JSON.stringify(Yu(l))},(0,r.createElement)("a",{href:"#",onClick:e=>e.preventDefault()},(0,et.__)("Copy to clipboard","search-regex")))))))}));function Bu(e){let{debug:t}=e;return(0,r.createElement)(r.Fragment,null,(0,r.createElement)("p",null,(0,r.createElement)("a",{href:"mailto:john@searchregex.com?subject=Search%20Regex%20Error&body="+encodeURIComponent(t),className:"button-secondary"},(0,et.__)("Create An Issue","search-regex"))," ",(0,r.createElement)("a",{href:"https://github.com/johngodley/search-regex/issues/new?title=Search%20Regex%20Error&body="+encodeURIComponent(t),className:"button-secondary"},(0,et.__)("Email","search-regex"))))}const Hu=W((function(e){const{presets:t,clipboardStatus:n,uploadStatus:r,clipboard:a,isUploading:o,error:l,errorContext:i,imported:u}=e.preset,{sources:s}=e.search;return{error:l,errorContext:i,presets:t,sources:s,clipboardStatus:n,uploadStatus:r,clipboard:a,isUploading:o,imported:u}}),(function(e){return{onExport:()=>{e((e=>{const t=Jl.preset.export();document.location.href=st.getUrl(t.url)+"&_wpnonce="+SearchRegexi10n.api.WP_API_nonce,e({type:Je})}))},onUploadFile:t=>{e(ri(t))},onImportClipboard:t=>{var n;e((n=t,e=>{try{const t=JSON.parse(n),r=Array.isArray(t)?t:[t];return ri(new File([new Blob([JSON.stringify(r)])],"preset.json"))(e)}catch(t){return e({type:Ge,error:t,errorContext:n})}}))},onSetClipboard:t=>{e((e=>({type:Xe,clipboard:e}))(t))},onClearError:()=>{e({type:Je})}}}))((function(e){const{presets:t,onExport:n,clipboardStatus:a,uploadStatus:o,onUploadFile:l,onImportClipboard:i,clipboard:u,onSetClipboard:s,isUploading:c,onClearError:p,error:d,errorContext:f,imported:h}=e;return(0,r.createElement)(r.Fragment,null,(0,r.createElement)("table",{className:kn()("wp-list-table","widefat","fixed","striped","items","searchregex-presets")},(0,r.createElement)("thead",null,(0,r.createElement)("tr",null,(0,r.createElement)("th",{className:"searchregex-preset__name"},(0,et.__)("Name","search-regex")),(0,r.createElement)("th",{className:"searchregex-preset__search"},(0,et.__)("Search","search-regex")),(0,r.createElement)("th",{className:"searchregex-preset__flags"},(0,et.__)("Flags","search-regex")))),(0,r.createElement)("tbody",null,t.map((e=>(0,r.createElement)(Wu,{preset:e,key:e.id}))),0===t.length&&(0,r.createElement)("tr",null,(0,r.createElement)("td",{colSpan:3},(0,et.__)("There are no presets","search-regex"))))),(0,r.createElement)("p",null,(0,r.createElement)(_a,{url:"https://searchregex.com/preset/"},(0,et.__)("Download presets!","search-regex"))),(0,r.createElement)("div",{className:"searchregex-presetactions"},t.length>0&&(0,r.createElement)("button",{className:"button button-secondary",onClick:n},(0,et.__)("Export JSON","search-regex"))),(0,r.createElement)("h3",null,(0,et.__)("Import JSON","search-regex")),(0,r.createElement)("div",{className:"searchregex-presetimport"},(0,r.createElement)(Xo,{addFileText:(0,et.__)("Add file","search-regex"),uploadText:(0,et.__)("Upload","search-regex"),cancelText:(0,et.__)("Cancel","search-regex"),isUploading:c,isUploaded:o===Ce,disabled:a===Se||o===Se,renderUnselected:()=>(0,r.createElement)(r.Fragment,null,(0,r.createElement)("h3",null,(0,et.__)("Import a JSON file","search-regex")),(0,r.createElement)("p",null,(0,et.__)("Click 'Add File' or drag and drop here."))),renderSelected:e=>(0,r.createElement)(r.Fragment,null,(0,r.createElement)("h3",null,(0,et.__)("File selected","search-regex")),(0,r.createElement)("p",null,(0,r.createElement)("code",null,e.name))),renderUploading:e=>(0,r.createElement)(r.Fragment,null,(0,r.createElement)("h3",null,(0,et.__)("Importing","search-regex")),(0,r.createElement)("p",null,(0,r.createElement)("code",null,e.name)),(0,r.createElement)(Ra,null)),renderUploaded:e=>(0,r.createElement)(r.Fragment,null,(0,r.createElement)("h3",null,(0,et.sprintf)((0,et._n)("Uploaded %(total)d preset","Uploaded %(total)d presets",h,"search-regex"),{total:h})),(0,r.createElement)("button",{className:"button-secondary",onClick:e},(0,et.__)("Done","search-regex"))),onUpload:l}),(0,r.createElement)("h4",null,(0,et.__)("Import preset from clipboard","search-regex")),a===ke&&(0,r.createElement)(_l,{mini:!0,errors:[d],title:(0,et.__)("Unable to import preset","search-regex"),type:"error",onClear:p,context:f,renderDebug:Bu,versions:SearchRegexi10n.versions},(0,et.__)("Please check your JSON data is a valid preset. You may have copied it incorrectly, or pasted something that is not a preset.")),(0,r.createElement)("textarea",{placeholder:(0,et.__)("Paste preset JSON.","search-regex"),rows:3,value:u,onChange:e=>s(e.target.value),disabled:o===Se}),(0,r.createElement)("p",null,(0,r.createElement)("button",{disabled:o===Se||0===u.length,className:"button button-secondary",onClick:()=>i(u)},(0,et.__)("Import","search-regex"))),o===Se&&u&&(0,r.createElement)(za,null)))})),qu=W((function(e){const{presets:t,currentPreset:n,status:r}=e.preset,{search:a}=e.search;return{presets:t,currentPreset:n,search:a,status:r,searchStatus:e.search.status}}),(function(e){return{onChangePreset:t=>{e(ni(t))},onSavePreset:(t,n)=>{e(((e,t)=>(n,r)=>function(e,t,n){return e({type:qe}),st(Jl.preset.save(n,t)).then((t=>{e({type:Ve,...t})})).catch((t=>{e({type:$e,error:t})}))}(n,e,t))(t,n))},onUpdatePreset:(t,n)=>{e(ti(t,n))}}}))((function(e){const{presets:t,currentPreset:n,onChangePreset:a,onSavePreset:o,search:l,status:u,onUpdatePreset:s,searchStatus:c}=e,[p,d]=(0,i.useState)(!1),[f,h]=(0,i.useState)(""),m=[{label:(0,et.__)("Saving preset","search-regex"),value:""}],g=[{label:(0,et.__)("No preset","search-regex"),value:""}].concat(t.map((e=>({label:e.name.substr(0,50),value:e.id})))),y=[];return n&&"0"!==n||y.push((0,r.createElement)("a",{href:"#",onClick:e=>{e.preventDefault(),d(!0),h("")}},(0,et.__)("Save search as new preset","search-regex"))),n&&"0"!==n&&y.push((0,r.createElement)("a",{href:"#",onClick:e=>{e.preventDefault(),s(n,l)}},(0,et.__)("Update current preset","search-regex"))),(0,r.createElement)("div",{className:"searchregex-saved"},p&&(0,r.createElement)(Pa,{onClose:()=>d(!1),className:"searchregex-preset__name"},(0,r.createElement)("h2",null,(0,et.__)("Saving Preset","search-regex")),(0,r.createElement)("p",null,(0,et.__)("Enter a name for your preset","search-regex")),(0,r.createElement)("form",{onSubmit:e=>{e.preventDefault(),e.stopPropagation(),o(f,l),d(!1),h("")}},(0,r.createElement)("input",{type:"text",name:"name",autoFocus:!0,value:f,onChange:e=>h(e.target.value),placeholder:(0,et.__)("Enter preset name","search-regex")}),(0,r.createElement)("button",{className:"button button-primary",disabled:0===f.length},(0,et.__)("Save","search-regex")),(0,r.createElement)("button",{className:"button button-secondary",onClick:()=>d(!1),type:"button"},(0,et.__)("Cancel","search-regex")))),(0,r.createElement)(Ua,{name:"saved-search",value:n,disabled:u===Se||c===Se,items:u===Se?m:g,onChange:e=>{const n=t.find((t=>t.id===e.target.value));a(n)}}),(0,r.createElement)(ca,{menu:y,align:"left",disabled:u===Se}))})),Vu=W((function(e){const{search:t,replaceAll:n,status:r}=e.search,{presets:a,currentPreset:o}=e.preset;return{search:t,replaceAll:n,status:r,currentPreset:_t(a,o)}}),(function(e){return{onSetSearch:t=>{e((e=>({type:Le,searchValue:e}))(t))}}}))((function(e){let{search:t,onSetSearch:n,replaceAll:a,currentPreset:o,status:l}=e;const i=Dt(o?o.tags:[]);return(0,r.createElement)("table",null,(0,r.createElement)("tbody",null,(0,r.createElement)("tr",{className:kn()(i)},(0,r.createElement)("th",null,(0,et.__)("Preset","search-regex")),(0,r.createElement)("td",null,(0,r.createElement)(qu,null))),(0,r.createElement)(ju,{search:t,onSetSearch:n,isBusy:l===Se||a,preset:o})))}));function $u(e,t){return t.label?t.label:parseInt(t.value,10)}function Zu(e,t,n){return"delete"===e?{...t,type:"delete"}:"replace"===e?{type:"replace",value:t.context||t.value,value_label:t.context||t.value,replacement:n,replacement_label:n}:t}function Qu(e,t){return{key:Zu(t.type,e.key,t.key),value:Zu(t.type_value,e.value,t.value)}}function Ku(e,t,n){if("integer"===n.type&&!isNaN(parseInt(t.value,10))&&parseInt(e.value,10)!==parseInt(t.value,10))return{type:"replace",replacement_value:parseInt(t.value,10),replacement_label:$u(0,t)};if("member"===n.type&&t.values&&t.values[0]!==e.value&&"api"!==n.options){const e=n.options.find((e=>e.value===t.values[0]));return{type:"replace",replacement_value:t.values[0],replacement_label:e?e.label:t.values[0]}}return"date"===n.type&&t.value?{type:"replace",replacement_value:t.value.toDateString()+" "+t.value.toLocaleTimeString(),replacement_label:t.value.toDateString()+" "+t.value.toLocaleTimeString()}:"string"!==n.type||void 0===t.replaceValue||"string"===e.type&&!t.matchesOnly||t.originalValue&&t.originalValue.replace(/\r\n/g,"\n").trim()===t.replaceValue.replace(/\r\n/g,"\n").trim()||e.value===t.replaceValue?{}:t.matchesOnly?{...e,matches:e.matches.map((e=>({...e,replacement:t.replaceValue})))}:""===t.replaceValue?{type:"delete"}:{...e,type:"replace",replacement:t.replaceValue,replacement_label:t.replaceValue}}function Gu(e,t,n){if(!t)return e;const r=function(e,t,n){if("member"===n.type&&"api"===n.options){const n=e.filter((e=>"empty"!==e.type)).filter((e=>-1===t.values.indexOf(e.value))),r=e.filter((e=>-1!==t.values.indexOf(e.value))).filter((e=>"empty"!==e.type)),a=t.values.map(((e,n)=>!r.find((t=>t.value===e))&&{type:"add",value:e,value_label:t.label&&t.label[n]||e})).filter(Boolean);return r.concat(n.map((e=>({type:"delete",value:e.value,value_label:e.value_label})))).concat(a).map(((e,t)=>({...e,context_id:t})))}if("keyvalue"===n.type&&t.items)return e.map(((e,n)=>({...e,...0===t.items.length?{}:Qu(e,t.items[n])}))).concat(t.items.slice(e.length).map(((t,n)=>({type:"keyvalue",context_id:e.length+n,key:{type:"add",value:t.key,value_label:t.key},value:{type:"add",value:t.value,value_label:t.value}}))));if("string"===n.type&&!t.matchesOnly&&e.length>0&&"string"===e[0].type){const r=t.originalValue?t.originalValue:e[0].context,a={type:"value",value:r,value_label:r,context_id:e.length,hasMultiple:!0,value_type:e[0].value_type,value_length:r.length+1};return[{...a,...Ku(a,t,n)}]}return e}(e.contexts.map((e=>({...e,...Ku(e,t,n)}))),t,n);return{...e,context_count:r.length,contexts:r}}const Xu=function(){return(0,r.createElement)("div",{className:"searchregex-result__more"},(0,et.__)("Maximum number of matches exceeded and hidden from view. These will be included in any replacements.","search-regex"))};function Ju(e){return"php"===e?(0,et.__)("Serialized PHP","search-regex"):"json"===e?(0,et.__)("JSON","search-regex"):"blocks"===e?(0,et.__)("Blocks","search-regex"):"html"===e?(0,et.__)("HTML","search-regex"):null}const es=function(e){const{column:t,schema:n,setReplacement:a,replacement:o,toggle:l,disabled:i,canEdit:u,source:s,context:c}=e,{column_label:p}=t,d="keyvalue"===c.type?c.value:c,f=d.value_type?Ju(d.value_type):null;return(0,r.createElement)("div",{className:kn()("searchregex-match__column","searchregex-match__column__"+c.type,i||!u?"searchregex-match__column__disabled":null),title:f?(0,et.__)("This column contains special formatting. Modifying it could break the format.","search-regex"):(0,et.__)("Click to replace column","search-regex"),onClick:function(){if(i||!u)return;const e=qt(t,n,s);a(null===o?e:null),l&&l()}},p,f&&(0,r.createElement)("div",{className:"searchregex-match__column__type"},f))},ts=function(e){const{schema:t,replacement:n,disabled:a,setReplacement:o,fetchData:l}=e;return(0,r.createElement)(yu,{schema:t,disabled:a,item:n,fixOperation:"set",onChange:o,fetchData:l})},ns=function(e){const{schema:t,replacement:n,disabled:a,setReplacement:o}=e;return(0,r.createElement)(vu,{schema:t,disabled:a,item:n,fixOperation:"set",onChange:o})};function rs(e){return!!e.hasMultiple||void 0!==e.matches}function as(e){return"string"!==e.type&&e.value.length!==e.value_length}const os=function(e){const{schema:t,replacement:n,setReplacement:a,context:o,loadColumn:l}=e,{replaceValue:u=o.value,matchesOnly:s=!1,operation:c,hasMultiple:p=rs(o)}=n,[d,f]=(0,i.useState)(as(o)),[h,m]=(0,i.useState)(o.value);return(0,i.useEffect)((()=>{as(o)&&(f(!0),l().then((e=>{a({replaceValue:e.value,originalValue:e.value}),m(e.value),f(!1)})))}),[]),(0,i.useEffect)((()=>{d||a(s?{replaceValue:o.search,searchValue:o.search}:{replaceValue:h||o.value})}),[s]),d?(0,r.createElement)(Ra,null):(0,r.createElement)(r.Fragment,null,(0,r.createElement)("div",{className:"searchregex-modify__string__row"},!t.multiline||o.forceSingle||s?(0,r.createElement)("input",{type:"text",value:u||"",onChange:e=>a({replaceValue:e.target.value}),placeholder:(0,et.__)("Enter replacement","search-regex")}):(0,r.createElement)("textarea",{value:u||"",onChange:e=>a({replaceValue:e.target.value})})),p&&(0,r.createElement)("p",{className:"searchregex-modify__string__row"},(0,r.createElement)("label",null,(0,r.createElement)("input",{type:"checkbox",value:s,onChange:e=>a({matchesOnly:e.target.checked,operation:e.target.checked?"replace":"set",searchValue:e.target.checked?o.search:null,searchFlags:e.target.checked?o.flags:null,replaceValue:e.target.checked?o.search:h})})," ",(0,et.__)("Apply to matches only","search-regex"))))},ls=function(e){const{schema:t,replacement:n,disabled:a,setReplacement:o,fetchData:l,column:i}=e;return(0,r.createElement)(xu,{schema:t,disabled:a,item:n,fixOperation:"set",onChange:o,fetchData:l,localLabels:i.contexts.map((e=>({value:i.column_id+"_"+e.value,label:e.value_label})))})};function is(e){return e.context?e.context:e.value}function us(e){const{disabled:t,item:n,onChange:a,onAdd:o,onDelete:l,type:u,original:s,isNew:c=!1}=e,[p,d]=(0,i.useState)([]),f=Ju(n.value_type);return(0,r.createElement)(r.Fragment,null,(0,r.createElement)("div",{className:"searchregex-filter__keyvalue__item"},(0,r.createElement)("span",null,(0,et.__)("Meta Key","search-regex")),(0,r.createElement)("input",{type:"text",value:n.key,disabled:t||"delete"===n.type,placeholder:"add"===n.type?(0,et.__)("New meta key","search-regex"):"",onChange:e=>a({key:e.target.value,type:s&&is(s.key)===e.target.value?"value":u})}),"add"===u&&c&&(0,r.createElement)(Pl,{onClick:o},(0,et.__)("Add","search-regex")),"add"===u&&!c&&(0,r.createElement)(Pl,{onClick:l},(0,et.__)("Delete","search-regex")),"add"!==u&&(0,r.createElement)("input",{type:"checkbox",disabled:t,onChange:e=>l(e.target.checked),checked:"delete"!==n.type})),(0,r.createElement)("div",{className:"searchregex-filter__keyvalue__item searchregex-filter__keyvalue__item__value"},(0,r.createElement)("span",null,(0,et.__)("Meta Value","search-regex")),-1===p.indexOf("multi")?(0,r.createElement)("input",{type:"text",value:n.value,disabled:t||"delete"===n.type,onChange:e=>a({value:e.target.value,type_value:s&&is(s.value)===e.target.value?"value":u}),placeholder:"add"===n.type?(0,et.__)("New meta value","search-regex"):""}):(0,r.createElement)("textarea",{value:n.value,disabled:t||"delete"===n.type,onChange:e=>a({value:e.target.value,type_value:s&&is(s.value)===e.target.value?"value":u}),placeholder:"add"===n.type?(0,et.__)("New meta value","search-regex"):""}),(0,r.createElement)(tu,{flags:p,disabled:t||"delete"===n.type,onChange:d,allowRegex:!1,allowMultiline:!0,allowCase:!1})),f&&(0,r.createElement)("div",{className:"searchregex-list__encoded"},f))}const ss=function(e){const{schema:t,replacement:n,disabled:a,setReplacement:o,column:l,loadColumn:u}=e,[s,c]=(0,i.useState)(!0),[p,d]=(0,i.useState)(null);if((0,i.useEffect)((()=>{u().then((e=>{e?(o({items:e.items.map(((e,t)=>({type:"value",key:e.key,value:e.value,value_type:e.value_type})))}),d((e.items.length,{type:"add",key:"",value:"",type_value:"add"}))):o({items:[]}),c(!1)}))}),[]),s)return(0,r.createElement)(Ra,null);function f(e,t){o({items:[...n.items.slice(0,e),{...n.items[e],...t},...n.items.slice(e+1)]})}return(0,r.createElement)(r.Fragment,null,n.items.map(((e,t)=>(0,r.createElement)(us,{key:t,disabled:a,item:e,onChange:e=>f(t,e),type:"add"===e.type?"add":"replace",onDelete:e=>function(e,t){"add"===n.items[e].type?o({items:[...n.items.slice(0,e),...n.items.slice(e+1)]}):f(e,{key:l.contexts[e].key.value,value:l.contexts[e].value.value,type:t?"value":"delete",type_value:t?"value":"delete"})}(t,e),original:l.contexts[t]}))),p&&(0,r.createElement)(us,{disabled:a,item:p,type:"add",isNew:!0,onChange:e=>d({...p,...e}),onAdd:function(){o({items:n.items.concat(p)}),d((n.items.length,{type:"add",key:"",value:"",type_value:"add"}))}}))},cs=function(e){const{type:t}=e.schema;return"integer"===t?(0,r.createElement)(ts,e):"date"===t?(0,r.createElement)(ns,e):"string"===t?(0,r.createElement)(os,e):"member"===t?(0,r.createElement)(ls,e):"keyvalue"===t?(0,r.createElement)(ss,e):null},ps=function(e){const{disabled:t,schema:n,column:a,setReplacement:o,replacement:l,rowId:i,source:u,context:s}=e;return(0,r.createElement)(r.Fragment,null,(0,r.createElement)("h5",null,a.column_label),(0,r.createElement)("div",{className:"searchregex-modify searchregex-modify__"+n.type},(0,r.createElement)(cs,{disabled:t,schema:n,column:a,fetchData:function(e){return st(Jl.source.complete(u,a.column_id,e))},context:s,setReplacement:o,replacement:l,loadColumn:function(){return st(Jl.source.loadRow(u,i)).then((e=>e.result.find((e=>e.column===a.column_id))))}})))},ds=W((function(e){const{presets:t,currentPreset:n}=e.preset;return{preset:_t(t,n)}}),null)((function(e){const{setReplacement:t,replacement:n,canReplace:a,context:o,onSave:l,source:u,description:s,className:c,column:p,schema:d,onCancel:f,rowId:h}=e,m=(0,i.useRef)(null);return(0,i.useEffect)((()=>{setTimeout((()=>{if(m.current){const e=m.current.querySelector("input[type=text],textarea");e&&(e.focus(),e.select())}}),50)}),[m]),(0,r.createElement)("div",{className:"searchregex-replace__form",ref:m},(0,r.createElement)(Ol,{onSubmit:()=>l(n),className:c},(0,r.createElement)(ps,{schema:d,column:p,disabled:!1,setReplacement:t,replacement:n,source:u,context:o,rowId:h}),(0,r.createElement)("div",{className:"searchregex-replace__action"},s&&(0,r.createElement)("p",null,s),(0,r.createElement)("p",{className:"searchregex-replace__actions"},(0,r.createElement)("input",{type:"submit",className:"button button-primary",value:(0,et.__)("Replace","search-regex"),disabled:!a}),(0,r.createElement)("input",{type:"button",className:"button button-secondary",value:(0,et.__)("Cancel","search-regex"),onClick:f})))))})),fs=function(e){const{column:t,schema:n,replacement:a,save:o,disabled:l,source:i,rowId:u,children:s,context:c}=e,p=function(e,t,n){return null!==e&&e.column===t.column_id&&("integer"===n.type?!isNaN(parseInt(e.value,10))&&parseInt(t.contexts[0].value,10)!==parseInt(e.value,10):"member"===n.type?e.values&&e.values[0]!==t.contexts[0].value:"keyvalue"===n.type&&e.items?e.items.find((e=>function(e){return"value"!==e.type||"value"!==e.type_value}(e))):"string"===n.type?0===t.contexts.length?void 0!==e.replaceValue&&""!==e.replaceValue:(!e.originalValue||e.originalValue!==e.replaceValue)&&void 0!==e.replaceValue&&e.replaceValue!==(t.contexts[0].value||t.contexts[0].search):"date"===n.type&&void 0!==e.value)}(a,t,n),d=$();return(0,r.createElement)("div",{className:"searchregex-match searchregex-match__list"},(0,r.createElement)(ia,{renderToggle:(e,u)=>(0,r.createElement)(es,{column:t,schema:n,replacement:a,setReplacement:o,disabled:l,source:i,toggle:u,canEdit:!1!==n.modify,context:c}),hasArrow:!0,align:"centre",valign:"top",onClose:()=>o(null),renderContent:e=>(0,r.createElement)(ds,{setReplacement:o,replacement:a,context:c,canReplace:p,rowId:u,onSave:()=>function(e){e(),o(null),d(Mi(a,u))}(e),onCancel:()=>{o(null),e()},column:t,schema:n,source:i,className:"searchregex-replace__modal",description:Ju("keyvalue"===c.type?c.value.value_type:c.value_type)?(0,et.__)("Contains encoded data","search-regex"):""})}),s)},hs=(e,t)=>" ".replace(t.length);function ms(e,t){return e&&t.length>0?e.replace(/(\\?\$|\\?\\)+(\d{1,2})/g,((e,n,r)=>(r=parseInt(r,10),"\\$"===e.substr(0,2)?e.replace("\\",""):void 0!==t[r-1]?t[r-1]:e))):e}const gs=e=>{let{match:t,originalMatch:n}=e;return null===t?(0,r.createElement)("strike",null,n):String(t).replace(/\n/g,"↵").replace(/^(\s+)/,hs).replace(/(\s+)$/,hs)},ys=function(e){const{match:t,captures:n,replacement:a,rowId:o,canReplace:l,column:u,schema:s,onSave:c}=e,[p,d]=(0,i.useState)(null),f=[p?p.replaceValue:null,a,t].filter((e=>null!=e))[0],h=function(e,t){return""===e?"delete":e!==t?"replace":"match"}(f,t),m=e=>{d(null),e&&e()};return(0,r.createElement)(ia,{renderToggle:(e,a)=>(0,r.createElement)("span",{onClick:()=>function(e){d({...qt(u,s,s.source),replaceValue:t,operation:"replace"}),e()}(a),title:(0,et.__)("Click to replace match","search-regex"),className:kn()({"searchregex-result__replaced":"replace"===h,"searchregex-result__highlight":"match"===h,"searchregex-result__deleted":"delete"===h})},(0,r.createElement)(gs,{match:ms(""===f?t:f,n),originalMatch:t})),hasArrow:!0,onClose:m,align:"centre",valign:"bottom",renderContent:e=>(0,r.createElement)(ds,{setReplacement:e=>d({...p,...e}),replacement:p,canReplace:l,onCancel:()=>m(e),onSave:()=>function(e){c(p),m(e)}(e),column:u,schema:s,rowId:o,context:{value:t,type:"string",forceSingle:!0},className:"searchregex-replace__modal"})})};function vs(e){const{beforePhrase:t,onReplace:n,column:a,schema:o,setReplacement:l,rowId:i}=e,{match:u,pos_id:s,captures:c,replacement:p}=e.match;return(0,r.createElement)(r.Fragment,null,t,(0,r.createElement)(ys,{onSave:e=>n(e,u,i,s),match:u,replacement:p,captures:c,canReplace:!0,setReplacement:l,column:a,schema:o,rowId:i}))}const bs=W(null,(function(e){return{onReplace:(t,n,r,a)=>{e(Mi({...t,searchValue:n,posId:a},r))}}}))((function(e){const{matches:t,count:n,onReplace:a,source:o,column:l,schema:i,className:u,rowId:s,crop:c=[]}=e;let p=0;return(0,r.createElement)("div",{className:kn()("searchregex-match__context",u)},t.map(((e,t)=>{const n=p;return p=e.context_offset+e.match.length,(0,r.createElement)(vs,{match:e,key:e.pos_id,onReplace:a,beforePhrase:(0,r.createElement)(r.Fragment,null,c.start>0&&0===t&&(0,r.createElement)(r.Fragment,null,"… "),o.substring(n,e.context_offset)),column:l,schema:i,rowId:s})})),o.substring(p),c.end>0&&(0,r.createElement)(r.Fragment,null," …"),t.length!==n&&(0,r.createElement)(Xu,null))})),ws=500;function Es(e,t){return parseInt(t,10)>0?(0,et.sprintf)((0,et.__)("%(label)s (ID %(id)d)","search-regex"),{label:e,id:parseInt(t,10)}):e}const _s=function(e){const{context:t,rowId:n,column:a,schema:o,setReplacement:l,className:i}=e,{type:u}=t,s=Es(t.value_label||t.context||"",t.value),c=Es(t.replacement_label||"",t.replacement);if("replace"===u){const e=s.length>100||c.length>100;return(0,r.createElement)("div",{className:kn()("searchregex-list-replace",e&&"searchregex-list-replace__vertical",i)},(0,r.createElement)(Cn,{className:"searchregex-list__delete"},s.substring(0,ws)||(0,et.__)("No value","search-regex"),s.length>ws&&(0,r.createElement)("span",null,"...")),(0,r.createElement)("span",{className:kn()("dashicons",{"dashicons-arrow-right-alt":!e,"dashicons-arrow-down-alt":e,"searchregex-list-replace__break":e})}),0===c.length?(0,r.createElement)("span",{className:kn()("searchregex-list__value","searchregex-list__novalue",i)},(0,et.__)("Empty value","search-regex")):(0,r.createElement)(Cn,{className:"searchregex-list__add"},c.substring(0,ws),c.length>ws&&(0,r.createElement)("span",null,"...")))}return"empty"===u||"value"===u&&0===s.length?(0,r.createElement)("span",{className:kn()("searchregex-list__value","searchregex-list__novalue",i)},(0,et.__)("No value","search-regex")):"value"===u?(0,r.createElement)("div",{className:kn()(i)},s.substring(0,ws),s.length>ws&&(0,r.createElement)("span",null,"...")):"string"===u?(0,r.createElement)(bs,{source:t.context,crop:t.crop,matches:t.matches,count:t.match_count,setReplacement:l,rowId:n,column:a,schema:o,className:i}):(0,r.createElement)(Cn,{className:kn()("searchregex-list__"+u,i)},s)},xs=function e(t){let{context:n,rowId:a,column:o,schema:l,setReplacement:i,className:u}=t;return"keyvalue"===n.type?(0,r.createElement)(r.Fragment,null,(0,r.createElement)(e,{rowId:a,column:o,schema:l,setReplacement:i,context:n.key,className:"searchregex-list__key"}),"=",(0,r.createElement)(e,{rowId:a,column:o,schema:l,setReplacement:i,context:n.value,className:"searchregex-list__value"})):(0,r.createElement)(r.Fragment,null,(0,r.createElement)(_s,{context:n,rowId:a,column:o,schema:l,setReplacement:i,className:u}))};function Ss(e){let{context:t}=e;const n=Ju("keyvalue"===t.type?t.value.value_type:t.value_type);return"string"!==t.type&&n?(0,r.createElement)(Cn,null,n):null}const ks=function(e){const{rowId:t,source:n}=e,a={...e.schema,source:n},[o,l]=(0,i.useState)(null),[u,s]=(0,i.useState)(!1),c=Gu(e.column,o,a),{contexts:p,context_count:d}=c,f=0===p.length?[{type:"empty",context_id:0}]:p.slice(0,u?p.length:2),h=p.length-f.length;function m(e,t){l(null===e?e:{...o,...e,...t?{label:t}:{}})}return 1===f.length?(0,r.createElement)(fs,w({replacement:o,save:m},e,{context:f[0]}),(0,r.createElement)(xs,{rowId:t,column:c,schema:a,setReplacement:l,context:f[0]})):(0,r.createElement)(r.Fragment,null,(0,r.createElement)(fs,w({replacement:o,save:m},e,{context:f[0]})),(0,r.createElement)("ul",{className:"searchregex-match__contexts"},f.map((e=>(0,r.createElement)("li",{key:e.context_id},(0,r.createElement)(Ss,{context:e}),(0,r.createElement)(xs,{rowId:t,column:c,schema:a,setReplacement:l,context:e,key:e.context_id}))))),!u&&p.length>2&&(0,r.createElement)("p",null,(0,r.createElement)("button",{className:"button button-secondary",onClick:()=>s(!0),type:"button"},(0,et.sprintf)((0,et._n)("Show %s more","Show %s more",h,"search-regex"),new Intl.NumberFormat(window.SearchRegexi10n.locale).format(h)))),u&&p.length!==d&&(0,r.createElement)(Xu,null))},Cs=function(e){let{view:t,title:n}=e;const a=n||(0,et.__)("No title","search-regex");return t?(0,r.createElement)(_a,{url:t},a):a},Ds=function(e){const{result:t,disabled:n}=e,a=$(),{actions:o}=t,l=[],i={edit:(0,et.__)("Edit","search-regex"),view:(0,et.__)("View","search-regex")},u=Object.keys(o);for(let e=0;e<u.length;e++)i[u[e]]&&l.push((0,r.createElement)(_a,{url:o[u[e]],key:u[e]},i[u[e]]));return l.push((0,r.createElement)("a",{key:"delete",href:"#",onClick:function(e){var n,r;e.preventDefault(),a((n=t.source_type,r=t.row_id,e=>(st(Jl.source.deleteRow(n,r)).then((t=>{e({type:Ue,rowId:r})})).catch((t=>{e({type:Me,error:t})})),e({type:je,rowId:r}))))}},(0,et.__)("Delete database row","search-regex"))),(0,r.createElement)("div",{className:"row-actions"},n?(0,r.createElement)(r.Fragment,null," "):l.reduce(((e,t)=>[e," | ",t])))};function Os(e,t,n){if(e&&e.length>0&&"global"===e[0].column){const r=n.columns.find((e=>e.column===t.column_id));if(r&&r.global)return Gu(t,e[0],n)}const r=e.find((e=>e.column===t.column_id));return r?Gu(t,r,n):t}function Ps(e){let{action:t,actionOption:n,replacement:r}=e;return"modify"===t?n:"replace"===t?[{column:"global",operation:"replace",value:r}]:[]}const Ts=W((function(e,t){const{replacing:n,search:r,schema:a}=e.search;return{isReplacing:-1!==n.indexOf(t.result.row_id),globalReplacement:Ps(r),schema:Lt(a,t.result.source_type)}}),null)((function(e){const{result:t,globalReplacement:n,isReplacing:a,schema:o}=e,{columns:l,actions:i,row_id:u,source_name:s,source_type:c,title:p}=t;return(0,r.createElement)("tr",{className:kn()("searchregex-result",{"searchregex-result__updating":a})},(0,r.createElement)("td",{className:"searchregex-result__table"},(0,r.createElement)("span",{title:c},s)),(0,r.createElement)("td",{className:"searchregex-result__row"},new Intl.NumberFormat(window.SearchRegexi10n.locale).format(u)),(0,r.createElement)("td",{className:"searchregex-result__match"},(0,r.createElement)("h2",null,(0,r.createElement)(Cs,{view:i.view,title:p})),l.map((e=>(0,r.createElement)(ks,{column:Os(n,e,o),rowId:u,disabled:a,schema:Ut(o.columns,e.column_id),source:o.type,key:e.column_id}))),(0,r.createElement)(Ds,{result:t,disabled:a})))})),Ns=function(e){let{columns:t}=e;const n=[];for(let e=0;e<t;e++)n.push((0,r.createElement)("td",{key:e},(0,r.createElement)(Ra,null)));return(0,r.createElement)("tr",null,n)},Ms=function(e){let{columns:t}=e;return(0,r.createElement)("tr",null,(0,r.createElement)("td",{colSpan:t},(0,et.__)("No more matching results found.","search-regex")))},Rs=e=>{const{title:t,button:n,className:a,enabled:o,onClick:l}=e;return o?(0,r.createElement)("a",{className:a+" button",href:"#",onClick:e=>{e.preventDefault(),l()}},(0,r.createElement)("span",{className:"screen-reader-text"},t),(0,r.createElement)("span",{"aria-hidden":"true"},n)):(0,r.createElement)("span",{className:"tablenav-pages-navspan button disabled","aria-hidden":"true"},n)},js=W(null,(function(e){return{onChangePage:t=>{e(Ti(t))}}}))((function(e){const{progress:t,onChangePage:n,isLoading:a,matchedRows:o,perPage:l,noTotal:i=!1,total:u}=e,{current:s,previous:c,next:p}=t,d=Math.ceil(o/l),f=Math.ceil(s/l),h=p&&f<d;return(0,r.createElement)("div",{className:"tablenav-pages"},i&&(0,r.createElement)("div",null," "),!i&&(0,r.createElement)("div",{className:"displaying-num"},(0,et.sprintf)((0,et.__)("Matched rows: %(matches)s out of %(total)s total.","search-regex"),{matches:new Intl.NumberFormat(window.SearchRegexi10n.locale).format(o),total:new Intl.NumberFormat(window.SearchRegexi10n.locale).format(u)})," "),(0,r.createElement)("div",{className:"pagination-links"},(0,r.createElement)(Rs,{title:(0,et.__)("First page","search-regex"),button:"«",className:"first-page",enabled:!1!==c&&!a,onClick:()=>n(0)}),(0,r.createElement)(Rs,{title:(0,et.__)("Prev page","search-regex"),button:"‹",className:"prev-page",enabled:!1!==c&&!a,onClick:()=>n(c)}),(0,r.createElement)("span",{className:"tablenav-paging-text"},(0,et.sprintf)((0,et.__)("Page %(current)s of %(total)s","search-regex"),{current:new Intl.NumberFormat(window.SearchRegexi10n.locale).format(f),total:new Intl.NumberFormat(window.SearchRegexi10n.locale).format(d)})),(0,r.createElement)(Rs,{title:(0,et.__)("Next page","search-regex"),button:"›",className:"next-page",enabled:h&&!a,onClick:()=>n(p)}),(0,r.createElement)(Rs,{title:(0,et.__)("Last page","search-regex"),button:"»",className:"last-page",enabled:h&&!a,onClick:()=>n((d-1)*l)})))})),As=(e,t)=>!1===t?100:t/e*100,Is=(e,t)=>0===t?t:t/e*100,Fs=W((function(e){const{search:t}=e.search;return{search:t}}),(function(e){return{onChangePage:(t,n)=>{e(Ti(t,n))}}}))((function(e){const{total:t,progress:n,onChangePage:a,isLoading:o,searchDirection:l,noTotal:i=!1,totals:u}=e,{previous:s=!1,next:c=!1}=n;return(0,r.createElement)("div",{className:"tablenav-pages"},i&&(0,r.createElement)("div",null," "),!i&&(0,r.createElement)("div",{className:"displaying-num"},(0,et.sprintf)(
3
+ /* translators: %s: total number of rows searched */
4
+ (0,et._n)("%s database row in total","%s database rows in total",t,"search-regex"),new Intl.NumberFormat(window.SearchRegexi10n.locale).format(t))," — ",(0,et.sprintf)(
5
+ /* translators: %searched: number of rows searched and matched %phrases: number of phrases matched */
6
+ (0,et.__)("matched rows = %(searched)s, phrases = %(found)s","search-regex"),{searched:new Intl.NumberFormat(window.SearchRegexi10n.locale).format(u.matched_rows),found:new Intl.NumberFormat(window.SearchRegexi10n.locale).format(u.matched_phrases)})),(0,r.createElement)("div",{className:"pagination-links"},(0,r.createElement)(Rs,{title:(0,et.__)("First page","search-regex"),button:"«",className:"first-page",enabled:s&&!o,onClick:()=>a(0,We)}),(0,r.createElement)(Rs,{title:(0,et.__)("Prev page","search-regex"),button:"‹",className:"prev-page",enabled:s&&!o,onClick:()=>a(s,Be)}),(0,r.createElement)("span",{className:"tablenav-paging-text"},(0,et.sprintf)(
7
+ /* translators: %current: current percent progress */
8
+ (0,et.__)("Progress %(current)s%%","search-regex"),{current:new Intl.NumberFormat(window.SearchRegexi10n.locale).format(l===We?As(t,c):Is(t,0==c?s:c))})),(0,r.createElement)(Rs,{title:(0,et.__)("Next page","search-regex"),button:"›",className:"next-page",enabled:!1!==c&&!o,onClick:()=>a(c,We)})))})),Ls=function(e){const{totals:t,searchDirection:n,advanced:a,resultsDirty:o,progress:l}=e,{matched_rows:i,matched_phrases:u,rows:s}=t;return null!=i&&0!==i||l.next||l.prev?o?(0,r.createElement)("p",{className:"searchregex-resultsdirty"},(0,et.__)("Your search conditions have changed. Please refresh to see the latest results.","search-regex")):a?(0,r.createElement)(Fs,w({},e,{total:s,searchDirection:n})):(0,r.createElement)(js,w({},e,{matchedRows:i,matchedPhrases:u,total:s})):(0,r.createElement)("div",{className:"tablenav-pages"},(0,r.createElement)("div",{className:"displaying-num"}," "))};function Us(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,a,o=n.call(e),l=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)l.push(r.value)}catch(e){a={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(a)throw a.error}}return l}var zs,Ys="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==n.g?n.g:"undefined"!=typeof self?self:{},Ws=(function(e,t){var n="__lodash_hash_undefined__",r=9007199254740991,a="[object Arguments]",o="[object Array]",l="[object Boolean]",i="[object Date]",u="[object Error]",s="[object Function]",c="[object Map]",p="[object Number]",d="[object Object]",f="[object Promise]",h="[object RegExp]",m="[object Set]",g="[object String]",y="[object Symbol]",v="[object WeakMap]",b="[object ArrayBuffer]",w="[object DataView]",E=/^\[object .+?Constructor\]$/,_=/^(?:0|[1-9]\d*)$/,x={};x["[object Float32Array]"]=x["[object Float64Array]"]=x["[object Int8Array]"]=x["[object Int16Array]"]=x["[object Int32Array]"]=x["[object Uint8Array]"]=x["[object Uint8ClampedArray]"]=x["[object Uint16Array]"]=x["[object Uint32Array]"]=!0,x[a]=x[o]=x[b]=x[l]=x[w]=x[i]=x[u]=x[s]=x[c]=x[p]=x[d]=x[h]=x[m]=x[g]=x[v]=!1;var S="object"==typeof Ys&&Ys&&Ys.Object===Object&&Ys,k="object"==typeof self&&self&&self.Object===Object&&self,C=S||k||Function("return this")(),D=t&&!t.nodeType&&t,O=D&&e&&!e.nodeType&&e,P=O&&O.exports===D,T=P&&S.process,N=function(){try{return T&&T.binding&&T.binding("util")}catch(e){}}(),M=N&&N.isTypedArray;function R(e,t){for(var n=-1,r=null==e?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}function j(e){var t=-1,n=Array(e.size);return e.forEach((function(e,r){n[++t]=[r,e]})),n}function A(e){var t=-1,n=Array(e.size);return e.forEach((function(e){n[++t]=e})),n}var I,F,L,U=Array.prototype,z=Function.prototype,Y=Object.prototype,W=C["__core-js_shared__"],B=z.toString,H=Y.hasOwnProperty,q=(I=/[^.]+$/.exec(W&&W.keys&&W.keys.IE_PROTO||""))?"Symbol(src)_1."+I:"",V=Y.toString,$=RegExp("^"+B.call(H).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Z=P?C.Buffer:void 0,Q=C.Symbol,K=C.Uint8Array,G=Y.propertyIsEnumerable,X=U.splice,J=Q?Q.toStringTag:void 0,ee=Object.getOwnPropertySymbols,te=Z?Z.isBuffer:void 0,ne=(F=Object.keys,L=Object,function(e){return F(L(e))}),re=Ne(C,"DataView"),ae=Ne(C,"Map"),oe=Ne(C,"Promise"),le=Ne(C,"Set"),ie=Ne(C,"WeakMap"),ue=Ne(Object,"create"),se=Ae(re),ce=Ae(ae),pe=Ae(oe),de=Ae(le),fe=Ae(ie),he=Q?Q.prototype:void 0,me=he?he.valueOf:void 0;function ge(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function ye(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function ve(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function be(e){var t=-1,n=null==e?0:e.length;for(this.__data__=new ve;++t<n;)this.add(e[t])}function we(e){var t=this.__data__=new ye(e);this.size=t.size}function Ee(e,t){var n=Le(e),r=!n&&Fe(e),a=!n&&!r&&Ue(e),o=!n&&!r&&!a&&He(e),l=n||r||a||o,i=l?function(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}(e.length,String):[],u=i.length;for(var s in e)!t&&!H.call(e,s)||l&&("length"==s||a&&("offset"==s||"parent"==s)||o&&("buffer"==s||"byteLength"==s||"byteOffset"==s)||je(s,u))||i.push(s);return i}function _e(e,t){for(var n=e.length;n--;)if(Ie(e[n][0],t))return n;return-1}function xe(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":J&&J in Object(e)?function(e){var t=H.call(e,J),n=e[J];try{e[J]=void 0}catch(e){}var r=V.call(e);return t?e[J]=n:delete e[J],r}(e):function(e){return V.call(e)}(e)}function Se(e){return Be(e)&&xe(e)==a}function ke(e,t,n,r,s){return e===t||(null==e||null==t||!Be(e)&&!Be(t)?e!=e&&t!=t:function(e,t,n,r,s,f){var v=Le(e),E=Le(t),_=v?o:Re(e),x=E?o:Re(t),S=(_=_==a?d:_)==d,k=(x=x==a?d:x)==d,C=_==x;if(C&&Ue(e)){if(!Ue(t))return!1;v=!0,S=!1}if(C&&!S)return f||(f=new we),v||He(e)?Oe(e,t,n,r,s,f):function(e,t,n,r,a,o,s){switch(n){case w:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case b:return!(e.byteLength!=t.byteLength||!o(new K(e),new K(t)));case l:case i:case p:return Ie(+e,+t);case u:return e.name==t.name&&e.message==t.message;case h:case g:return e==t+"";case c:var d=j;case m:var f=1&r;if(d||(d=A),e.size!=t.size&&!f)return!1;var v=s.get(e);if(v)return v==t;r|=2,s.set(e,t);var E=Oe(d(e),d(t),r,a,o,s);return s.delete(e),E;case y:if(me)return me.call(e)==me.call(t)}return!1}(e,t,_,n,r,s,f);if(!(1&n)){var D=S&&H.call(e,"__wrapped__"),O=k&&H.call(t,"__wrapped__");if(D||O){var P=D?e.value():e,T=O?t.value():t;return f||(f=new we),s(P,T,n,r,f)}}return!!C&&(f||(f=new we),function(e,t,n,r,a,o){var l=1&n,i=Pe(e),u=i.length;if(u!=Pe(t).length&&!l)return!1;for(var s=u;s--;){var c=i[s];if(!(l?c in t:H.call(t,c)))return!1}var p=o.get(e);if(p&&o.get(t))return p==t;var d=!0;o.set(e,t),o.set(t,e);for(var f=l;++s<u;){var h=e[c=i[s]],m=t[c];if(r)var g=l?r(m,h,c,t,e,o):r(h,m,c,e,t,o);if(!(void 0===g?h===m||a(h,m,n,r,o):g)){d=!1;break}f||(f="constructor"==c)}if(d&&!f){var y=e.constructor,v=t.constructor;y==v||!("constructor"in e)||!("constructor"in t)||"function"==typeof y&&y instanceof y&&"function"==typeof v&&v instanceof v||(d=!1)}return o.delete(e),o.delete(t),d}(e,t,n,r,s,f))}(e,t,n,r,ke,s))}function Ce(e){return!(!We(e)||function(e){return!!q&&q in e}(e))&&(ze(e)?$:E).test(Ae(e))}function De(e){if(n=(t=e)&&t.constructor,t!==("function"==typeof n&&n.prototype||Y))return ne(e);var t,n,r=[];for(var a in Object(e))H.call(e,a)&&"constructor"!=a&&r.push(a);return r}function Oe(e,t,n,r,a,o){var l=1&n,i=e.length,u=t.length;if(i!=u&&!(l&&u>i))return!1;var s=o.get(e);if(s&&o.get(t))return s==t;var c=-1,p=!0,d=2&n?new be:void 0;for(o.set(e,t),o.set(t,e);++c<i;){var f=e[c],h=t[c];if(r)var m=l?r(h,f,c,t,e,o):r(f,h,c,e,t,o);if(void 0!==m){if(m)continue;p=!1;break}if(d){if(!R(t,(function(e,t){if(l=t,!d.has(l)&&(f===e||a(f,e,n,r,o)))return d.push(t);var l}))){p=!1;break}}else if(f!==h&&!a(f,h,n,r,o)){p=!1;break}}return o.delete(e),o.delete(t),p}function Pe(e){return function(e,t,n){var r=t(e);return Le(e)?r:function(e,t){for(var n=-1,r=t.length,a=e.length;++n<r;)e[a+n]=t[n];return e}(r,n(e))}(e,qe,Me)}function Te(e,t){var n,r,a=e.__data__;return("string"==(r=typeof(n=t))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?a["string"==typeof t?"string":"hash"]:a.map}function Ne(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return Ce(n)?n:void 0}ge.prototype.clear=function(){this.__data__=ue?ue(null):{},this.size=0},ge.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},ge.prototype.get=function(e){var t=this.__data__;if(ue){var r=t[e];return r===n?void 0:r}return H.call(t,e)?t[e]:void 0},ge.prototype.has=function(e){var t=this.__data__;return ue?void 0!==t[e]:H.call(t,e)},ge.prototype.set=function(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=ue&&void 0===t?n:t,this},ye.prototype.clear=function(){this.__data__=[],this.size=0},ye.prototype.delete=function(e){var t=this.__data__,n=_e(t,e);return!(n<0||(n==t.length-1?t.pop():X.call(t,n,1),--this.size,0))},ye.prototype.get=function(e){var t=this.__data__,n=_e(t,e);return n<0?void 0:t[n][1]},ye.prototype.has=function(e){return _e(this.__data__,e)>-1},ye.prototype.set=function(e,t){var n=this.__data__,r=_e(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this},ve.prototype.clear=function(){this.size=0,this.__data__={hash:new ge,map:new(ae||ye),string:new ge}},ve.prototype.delete=function(e){var t=Te(this,e).delete(e);return this.size-=t?1:0,t},ve.prototype.get=function(e){return Te(this,e).get(e)},ve.prototype.has=function(e){return Te(this,e).has(e)},ve.prototype.set=function(e,t){var n=Te(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this},be.prototype.add=be.prototype.push=function(e){return this.__data__.set(e,n),this},be.prototype.has=function(e){return this.__data__.has(e)},we.prototype.clear=function(){this.__data__=new ye,this.size=0},we.prototype.delete=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},we.prototype.get=function(e){return this.__data__.get(e)},we.prototype.has=function(e){return this.__data__.has(e)},we.prototype.set=function(e,t){var n=this.__data__;if(n instanceof ye){var r=n.__data__;if(!ae||r.length<199)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new ve(r)}return n.set(e,t),this.size=n.size,this};var Me=ee?function(e){return null==e?[]:(e=Object(e),function(e,t){for(var n=-1,r=null==e?0:e.length,a=0,o=[];++n<r;){var l=e[n];t(l,n,e)&&(o[a++]=l)}return o}(ee(e),(function(t){return G.call(e,t)})))}:function(){return[]},Re=xe;function je(e,t){return!!(t=null==t?r:t)&&("number"==typeof e||_.test(e))&&e>-1&&e%1==0&&e<t}function Ae(e){if(null!=e){try{return B.call(e)}catch(e){}try{return e+""}catch(e){}}return""}function Ie(e,t){return e===t||e!=e&&t!=t}(re&&Re(new re(new ArrayBuffer(1)))!=w||ae&&Re(new ae)!=c||oe&&Re(oe.resolve())!=f||le&&Re(new le)!=m||ie&&Re(new ie)!=v)&&(Re=function(e){var t=xe(e),n=t==d?e.constructor:void 0,r=n?Ae(n):"";if(r)switch(r){case se:return w;case ce:return c;case pe:return f;case de:return m;case fe:return v}return t});var Fe=Se(function(){return arguments}())?Se:function(e){return Be(e)&&H.call(e,"callee")&&!G.call(e,"callee")},Le=Array.isArray,Ue=te||function(){return!1};function ze(e){if(!We(e))return!1;var t=xe(e);return t==s||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}function Ye(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=r}function We(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function Be(e){return null!=e&&"object"==typeof e}var He=M?function(e){return function(t){return e(t)}}(M):function(e){return Be(e)&&Ye(e.length)&&!!x[xe(e)]};function qe(e){return null!=(t=e)&&Ye(t.length)&&!ze(t)?Ee(e):De(e);var t}e.exports=function(e,t){return ke(e,t)}}(zs={exports:{}},zs.exports),zs.exports);function Bs(e,t){var n=(void 0===t?{}:t).deep,r=void 0!==n&&n,a=(0,i.useRef)(e.length);e.length!==a.current&&console.warn("Length of array changed across renders, but should remain constant.");var o,l,u,s=r?Ws:Object.is,c=(o=e,l=(0,i.useRef)(),(0,i.useEffect)((function(){l.current=o}),[o]),l.current),p=(u=a.current,function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(Us(arguments[t]));return e}(Array(u).keys())).map((function(t){return c?s(e[t],c[t])?null:{prev:c[t],curr:e[t]}:{curr:e[t]}}));return p}let Hs=0;function qs(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1.2;return e>3?Math.min(2e3,Math.round(t*e*n)):t}function Vs(e){const t=(new Date).getTime();setTimeout((()=>{Hs=t,e()}),t-Hs>500?0:500)}const $s=W((function(e){const{results:t,status:n,progress:r,totals:a,requestCount:o,searchDirection:l,search:i,showLoading:u,resultsDirty:s}=e.search;return{results:t,status:n,progress:r,searchDirection:l,totals:a,requestCount:o,search:i,showLoading:u,resultsDirty:s}}),(function(e){return{onSearchMore:(t,n,r)=>{e(((e,t,n)=>(r,a)=>{Pi(a(),r,Ne,e,t,{limit:n})})(t,n,r))},onError:()=>{e(Ri((0,et.__)("Your search resulted in too many requests. Please narrow your search terms.","search-regex")))}}}))((function(e){const{results:t,totals:n,progress:a,status:o,requestCount:l,search:u,searchDirection:s,showLoading:c,resultsDirty:p,onError:d}=e,{perPage:f}=u,{onSearchMore:h}=e,m=Rt(u),g=o===Se,y=m&&((e,t,n,r)=>e===Se&&t>0&&n.length<r)(o,l,t,f)&&((e,t)=>e===We&&!1!==t.next||e===Be&&!1!==t.previous)(s,a);return function(e,t,n,r,a){(0,i.useEffect)((()=>{0!==t&&e&&(t>1e3&&a(),Vs((()=>r(qs(t,n)))))}),[t])}(y,l,f,(e=>h(s===We?a.next:a.previous,e,f-t.length)),d),(0,r.createElement)(r.Fragment,null,(0,r.createElement)(Ls,{totals:n,perPage:f,isLoading:g,progress:a,searchDirection:s,advanced:m,resultsDirty:p}),(0,r.createElement)("table",{className:kn()("wp-list-table","widefat","fixed","striped","items","searchregex-results")},(0,r.createElement)("thead",null,(0,r.createElement)("tr",null,(0,r.createElement)("th",{className:"searchregex-result__table"},(0,et.__)("Source","search-regex")),(0,r.createElement)("th",{className:"searchregex-result__row"},(0,et.__)("Row ID","search-regex")),(0,r.createElement)("th",{className:"searchregex-result__match"},(0,et.__)("Matched Content","search-regex")))),(0,r.createElement)("tbody",null,t.map((e=>(0,r.createElement)(Ts,{key:e.source_type+"-"+e.row_id,result:e}))),c&&(0,r.createElement)(Ns,{columns:3}),!g&&0===t.length&&(0,r.createElement)(Ms,{columns:3}))),(0,r.createElement)(Ls,{totals:n,perPage:f,isLoading:g,progress:a,searchDirection:s,noTotal:!0,advanced:m,resultsDirty:p}))}));function Zs(e,t,n){return"replace"===e&&n.length>0||"delete"===e||("modify"===e?t.length>0:"action"===e?t.hook&&t.hook.length>0:"export"===e||"global"===e)}const Qs=function(e){const{search:t,status:n,canCancel:a,resultsDirty:o,isSaving:l}=b((e=>e.search)),{action:i,actionOption:u,replacement:s}=t,c=$();return(0,r.createElement)("div",{className:"searchregex-search__action"},(0,r.createElement)(Pl,{isPrimary:!0,isSubmit:!0,disabled:n===Se||l,name:"search"},o?(0,et.__)("Refresh","search-regex"):(0,et.__)("Search","search-regex")),""!==i&&(0,r.createElement)(Pl,{isDestructive:!0,disabled:!Zs(i,u,s)||n===Se||l,onClick:()=>c((0,(e,t)=>Oi(t(),e,Ie,0,{save:!0})))},function(e){return"delete"===e?(0,et.__)("Delete Matches","search-regex"):"export"===e?(0,et.__)("Export Matches","search-regex"):"action"===e?(0,et.__)("Run Action","search-regex"):(0,et.__)("Replace All","search-regex")}(i)),(n===Se||l)&&a&&(0,r.createElement)(r.Fragment,null," ",(0,r.createElement)(Pl,{isDestructive:!0,onClick:()=>c({type:Ae,clearAll:!1})},(0,et.__)("Cancel","search-regex")),(0,r.createElement)(za,null)))};function Ks(){return Ks=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Ks.apply(this,arguments)}function Gs(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n,r,a={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}var Xs={className:"",percent:0,prefixCls:"rc-progress",strokeColor:"#2db7f5",strokeLinecap:"round",strokeWidth:1,style:{},trailColor:"#D9D9D9",trailWidth:1,gapPosition:"bottom"},Js=function(){var e=(0,i.useRef)([]),t=(0,i.useRef)(null);return(0,i.useEffect)((function(){var n=Date.now(),r=!1;e.current.forEach((function(e){if(e){r=!0;var a=e.style;a.transitionDuration=".3s, .3s, .3s, .06s",t.current&&n-t.current<100&&(a.transitionDuration="0s, 0s")}})),r&&(t.current=Date.now())})),e.current},ec=["className","percent","prefixCls","strokeColor","strokeLinecap","strokeWidth","style","trailColor","trailWidth","transition"],tc=function(e){var t=e.className,n=e.percent,r=e.prefixCls,a=e.strokeColor,o=e.strokeLinecap,l=e.strokeWidth,u=e.style,s=e.trailColor,c=e.trailWidth,p=e.transition,d=Gs(e,ec);delete d.gapPosition;var f=Array.isArray(n)?n:[n],h=Array.isArray(a)?a:[a],m=Js(),g=l/2,y=100-l/2,v="M ".concat("round"===o?g:0,",").concat(g,"\n L ").concat("round"===o?y:100,",").concat(g),b="0 0 100 ".concat(l),w=0;return i.createElement("svg",Ks({className:kn()("".concat(r,"-line"),t),viewBox:b,preserveAspectRatio:"none",style:u},d),i.createElement("path",{className:"".concat(r,"-line-trail"),d:v,strokeLinecap:o,stroke:s,strokeWidth:c||l,fillOpacity:"0"}),f.map((function(e,t){var n=1;switch(o){case"round":n=1-l/100;break;case"square":n=1-l/2/100;break;default:n=1}var a={strokeDasharray:"".concat(e*n,"px, 100px"),strokeDashoffset:"-".concat(w,"px"),transition:p||"stroke-dashoffset 0.3s ease 0s, stroke-dasharray .3s ease 0s, stroke 0.3s linear"},u=h[t]||h[h.length-1];return w+=e,i.createElement("path",{key:t,className:"".concat(r,"-line-path"),d:v,strokeLinecap:o,stroke:u,strokeWidth:l,fillOpacity:"0",ref:function(e){m[t]=e},style:a})})))};tc.defaultProps=Xs,tc.displayName="Line";const nc=tc;function rc(e){return rc="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},rc(e)}function ac(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var oc=0,lc=!("undefined"==typeof window||!window.document||!window.document.createElement);const ic=function(e){var t,n,r=(t=i.useState(),n=2,function(e){if(Array.isArray(e))return e}(t)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,a,o=[],_n=!0,l=!1;try{for(n=n.call(e);!(_n=(r=n.next()).done)&&(o.push(r.value),!t||o.length!==t);_n=!0);}catch(e){l=!0,a=e}finally{try{_n||null==n.return||n.return()}finally{if(l)throw a}}return o}}(t,n)||function(e,t){if(e){if("string"==typeof e)return ac(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ac(e,t):void 0}}(t,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),a=r[0],o=r[1];return i.useEffect((function(){var e;o("rc_progress_".concat((lc?(e=oc,oc+=1):e="TEST_OR_SSR",e)))}),[]),e||a};var uc=["id","prefixCls","steps","strokeWidth","trailWidth","gapDegree","gapPosition","trailColor","strokeLinecap","style","className","strokeColor","percent"];function sc(e){return+e.replace("%","")}function cc(e){var t=null!=e?e:[];return Array.isArray(t)?t:[t]}var pc=function(e,t,n,r,a,o,l,i,u,s){var c=arguments.length>10&&void 0!==arguments[10]?arguments[10]:0,p=n/100*360*((360-o)/360),d=0===o?0:{bottom:0,top:180,left:90,right:-90}[l],f=(100-r)/100*t;return"round"===u&&100!==r&&(f+=s/2)>=t&&(f=t-.01),{stroke:"string"==typeof i?i:void 0,strokeDasharray:"".concat(t,"px ").concat(e),strokeDashoffset:f+c,transform:"rotate(".concat(a+p+d,"deg)"),transformOrigin:"50% 50%",transition:"stroke-dashoffset .3s ease 0s, stroke-dasharray .3s ease 0s, stroke .3s, stroke-width .06s ease .3s, opacity .3s ease 0s",fillOpacity:0}},dc=function(e){var t,n,r,a=e.id,o=e.prefixCls,l=e.steps,u=e.strokeWidth,s=e.trailWidth,c=e.gapDegree,p=void 0===c?0:c,d=e.gapPosition,f=e.trailColor,h=e.strokeLinecap,m=e.style,g=e.className,y=e.strokeColor,v=e.percent,b=Gs(e,uc),w=ic(a),E="".concat(w,"-gradient"),_=50-u/2,x=2*Math.PI*_,S=p>0?90+p/2:-90,k=x*((360-p)/360),C="object"===rc(l)?l:{count:l,space:2},D=C.count,O=C.space,P=pc(x,k,0,100,S,p,d,f,h,u),T=cc(v),N=cc(y),M=N.find((function(e){return e&&"object"===rc(e)})),R=Js();return i.createElement("svg",Ks({className:kn()("".concat(o,"-circle"),g),viewBox:"0 0 ".concat(100," ").concat(100),style:m,id:a},b),M&&i.createElement("defs",null,i.createElement("linearGradient",{id:E,x1:"100%",y1:"0%",x2:"0%",y2:"0%"},Object.keys(M).sort((function(e,t){return sc(e)-sc(t)})).map((function(e,t){return i.createElement("stop",{key:t,offset:e,stopColor:M[e]})})))),!D&&i.createElement("circle",{className:"".concat(o,"-circle-trail"),r:_,cx:50,cy:50,stroke:f,strokeLinecap:h,strokeWidth:s||u,style:P}),D?(t=Math.round(D*(T[0]/100)),n=100/D,r=0,new Array(D).fill(null).map((function(e,a){var l=a<=t-1?N[0]:f,s=l&&"object"===rc(l)?"url(#".concat(E,")"):void 0,c=pc(x,k,r,n,S,p,d,l,"butt",u,O);return r+=100*(k-c.strokeDashoffset+O)/k,i.createElement("circle",{key:a,className:"".concat(o,"-circle-path"),r:_,cx:50,cy:50,stroke:s,strokeWidth:u,opacity:1,style:c,ref:function(e){R[a]=e}})}))):function(){var e=0;return T.map((function(t,n){var r=N[n]||N[N.length-1],a=r&&"object"===rc(r)?"url(#".concat(E,")"):void 0,l=pc(x,k,e,t,S,p,d,r,h,u);return e+=t,i.createElement("circle",{key:n,className:"".concat(o,"-circle-path"),r:_,cx:50,cy:50,stroke:a,strokeLinecap:h,strokeWidth:u,opacity:0===t?0:1,style:l,ref:function(e){R[n]=e}})})).reverse()}())};function fc(e,t){const n=new Intl.NumberFormat(window.SearchRegexi10n.locale).format(t);return"delete"===e?(0,et.sprintf)((0,et._n)("%s row deleted.","%s rows deleted.",t,"search-regex"),n):(0,et.sprintf)((0,et._n)("%s row.","%s rows.",t,"search-regex"),n)}function hc(e){let{totals:t,current:n}=e;const{custom:a=[]}=t;return a.length>0?a.map((e=>(0,r.createElement)("p",{key:e.name},fc(e.name,e.value)))):0===n?(0,r.createElement)("p",null," "):(0,r.createElement)("p",null,fc("rows",n))}dc.defaultProps=Xs,dc.displayName="Circle";const mc=W((function(e){const{progress:t,totals:n,requestCount:r,status:a,search:o}=e.search;return{status:a,progress:t,totals:n,requestCount:r,isAdvanced:Rt(o)}}),(function(e){return{onClear:()=>{e({type:Ae,clearAll:!0})},onNext:(t,n)=>{e(((e,t)=>(n,r)=>{Pi(r(),n,Fe,e,t,{save:!0})})(t,n))},onError:()=>{e(Ri((0,et.__)("Your search resulted in too many requests. Please narrow your search terms.","search-regex")))}}}))((function(e){const{progress:t,totals:n,requestCount:a,onNext:o,status:l,onClear:u,isAdvanced:s,onError:c}=e,p=((e,t)=>e?t.rows:t.matched_rows)(s,n),{current:d=0,next:f=0}=t,h=Math.min(100,l===Se?((e,t)=>t>0?Math.round(e/t*100):0)(!1===f?p:f,p):100);return function(e,t,n,r){const[a,o]=(0,i.useState)(0),l=Us(Bs([0],{deep:void 0!==(u={}.deep)&&u}),1)[0];var u;(0,i.useEffect)((()=>{0!==t&&e&&(t>1e3&&r(),l&&l.prev&&l.prev<l.curr?o(Math.max(0,a-5)):o(a+1),Vs((()=>n(qs(a,200)))))}),[t])}(!1!==t.next&&l===Se,a,(e=>o(t.next,e)),c),(0,r.createElement)("div",{className:"searchregex-replaceall"},(0,r.createElement)("h3",null,(0,et.__)("Progress","search-regex")),(0,r.createElement)("div",{className:"searchregex-replaceall__progress"},(0,r.createElement)("div",{className:"searchregex-replaceall__container"},(0,r.createElement)(nc,{percent:h,strokeWidth:4,trailWidth:4,strokeLinecap:"square"})),(0,r.createElement)("div",{className:"searchregex-replaceall__status"},`${h}%`)),(0,r.createElement)("div",{className:"searchregex-replaceall__stats"},(0,r.createElement)(hc,{totals:n,current:d}),l===Ce&&(0,r.createElement)("button",{type:"button",className:"button button-primary",onClick:u},(0,et.__)("Finished!","search-regex"))))})),gc=function(e){const{status:t,isSaving:n}=b((e=>e.search)),a=$();return(0,r.createElement)(r.Fragment,null,(0,r.createElement)(kl,{level:"warning"},(0,r.createElement)("p",null,(0,et.__)("Please backup your data before making modifications.","search-regex"))),(0,r.createElement)("p",null,(0,et.__)("Search and replace information in your database.","search-regex")),(0,r.createElement)("form",{className:"searchregex-search",onSubmit:e=>function(e){e.preventDefault(),a(Ti(0))}(e)},(0,r.createElement)(Vu,null),(0,r.createElement)(Qs,null)),null!==t&&t!==ke&&n&&(0,r.createElement)(mc,null),null!==t&&t!==ke&&!n&&(0,r.createElement)($s,null))},yc=function(e){let{page:t}=e;switch(t){case"support":return(0,r.createElement)(Ei,null);case"options":return(0,r.createElement)(vi,null);case"presets":return(0,r.createElement)(Hu,null)}return(0,r.createElement)(gc,null)},vc=function(){return(0,r.createElement)(_l,{errors:"",details:Vl().concat(["Buster: 3.0.0 === "+SearchRegexi10n.version]),type:"fixed",title:(0,et.__)("Cached Search Regex detected","search-regex"),links:ql()},(0,r.createElement)("p",null,(0,et.__)("Please clear your browser cache and reload this page.","search-regex")),(0,r.createElement)("p",null,(0,et.__)("If you are using a caching system such as Cloudflare then please read this: ","search-regex"),(0,r.createElement)(_a,{url:"https://searchregex.com/support/problems/cloudflare/"},(0,et.__)("clearing your cache.","search-regex"))))},bc=function(e){const{error:t,onClear:n}=e,a=t.jsonData,o="mailto:john@searchregex.com?subject=Search%20Regex%20Query%20Error&body="+encodeURIComponent(a),l="https://github.com/johngodley/search-regex/issues/new?title=Search%20Regex%20Query%20Error&body="+encodeURIComponent("```\n"+a+"\n```\n\n");return(0,r.createElement)("div",{className:"wpl-error"},(0,r.createElement)("div",{className:"closer",onClick:n},(0,r.createElement)("span",{className:"dashicons dashicons-no-alt"})),(0,r.createElement)("h2",null,(0,et.__)("Query Problem","search-regex")),(0,r.createElement)("p",null,(0,et.__)("A problem occurred with your last query. This is likely caused by a combination of search filters that haven't been handled properly.")),(0,r.createElement)("p",null,(0,r.createElement)("code",null,t.jsonData)),(0,r.createElement)("h3",null,(0,et.__)("What do I do next?","search-regex")),(0,r.createElement)("p",null,(0,r.createElement)("a",{href:l,className:"button-primary"},(0,et.__)("Create An Issue","search-regex"))," ",(0,r.createElement)("a",{href:o,className:"button-secondary"},(0,et.__)("Email","search-regex"))))},wc=function(){const{update_notice:e=!1}=SearchRegexi10n,t=$();return e&&("searchregex_cap_options",-1!==SearchRegexi10n.caps.capabilities.indexOf("searchregex_cap_options"))?(0,r.createElement)(kl,null,(0,r.createElement)("p",null,zl((0,et.sprintf)((0,et.__)("Version %s installed! Please read the {{url}}release notes{{/url}} for details.","search-regex"),e),{url:(0,r.createElement)(_a,{url:"https://searchregex.com/blog/searchregex-version-"+e.replace(".","-")+"/"})})," ",(0,r.createElement)(Pl,{onClick:function(){t(ei({update_notice:SearchRegexi10n.update_notice})),SearchRegexi10n.update_notice=!1}},(0,et.__)("OK","search-regex")))):null},Ec=W((function(e){const{message:{errors:t,notices:n}}=e;return{errors:t,notices:n}}),(function(e){return{onClearErrors:()=>{e({type:Xt})},onClearNotices:()=>{e({type:Jt})}}}))((function(e){const{onClearErrors:t,errors:n,onClearNotices:a,notices:o}=e,[l,u]=(0,i.useState)(En());return"3.0.0"!==SearchRegexi10n.version?(0,r.createElement)(vc,null):(0,r.createElement)(Sl,{renderCrash:hi,extra:{page:l}},(0,r.createElement)("div",{className:"wrap searchregex"},(0,r.createElement)(mi,{page:l,setPage:u,onPageChange:t},(0,r.createElement)("h1",{className:"wp-heading-inline"},{search:(0,et.__)("Search Regex","search-regex"),options:(0,et.__)("Options","search-regex"),support:(0,et.__)("Support","search-regex"),presets:(0,et.__)("Presets","search-regex")}[l]),(0,r.createElement)(wc,null),(0,r.createElement)(ka,{onChangePage:e=>u(""===e?"search":e),menu:[{name:(0,et.__)("Search & Replace","search-regex"),value:""},{name:(0,et.__)("Presets","search-regex"),value:"presets"},{name:(0,et.__)("Options","search-regex"),value:"options"},{name:(0,et.__)("Support","search-regex"),value:"support"}].filter((e=>Yl(e.value)||""===e.value&&Yl("search"))),home:"search",currentPage:l,urlBase:SearchRegexi10n.pluginRoot}),n.length>0&&"searchregex_database"===n[0].code?(0,r.createElement)(bc,{error:n[0],onClear:t}):(0,r.createElement)(_l,{errors:n,onClear:t,renderDebug:Wl,details:Vl(),links:ql()},(0,r.createElement)(fi,null)),(0,r.createElement)(yc,{page:l}),(0,r.createElement)(Ma,{notices:o,onClear:a}))))}));var _c,xc,Sc,kc,Cc,Dc;st.resetMiddlewares(),st.use(st.createRootURLMiddleware(null!==(_c=null===(xc=SearchRegexi10n)||void 0===xc||null===(Sc=xc.api)||void 0===Sc?void 0:Sc.WP_API_root)&&void 0!==_c?_c:"/wp-json/")),st.use(st.createNonceMiddleware(null!==(kc=null===(Cc=SearchRegexi10n)||void 0===Cc||null===(Dc=Cc.api)||void 0===Dc?void 0:Dc.WP_API_nonce)&&void 0!==kc?kc:""));const Oc=()=>(0,r.createElement)(B,{store:pn({settings:dn(),search:bn(),message:{errors:[],notices:[],inProgress:0,saving:[]},preset:wn()})},(0,r.createElement)(i.StrictMode,null,(0,r.createElement)(Ec,null)));if(document.querySelector("#react-ui")){const e=document.querySelector(".jquery-migrate-deprecation-notice");e&&e.remove(),(0,o.setDefaultLocale)(SearchRegexi10n.locale.replace("_","")),function(e){const t=document.getElementById("react-ui");t&&(0,a.s)(t).render((0,r.createElement)(Oc,null))}()}window.searchregex=SearchRegexi10n.version},1924:(e,t,n)=>{"use strict";var r=n(210),a=n(5559),o=a(r("String.prototype.indexOf"));e.exports=function(e,t){var n=r(e,!!t);return"function"==typeof n&&o(e,".prototype.")>-1?a(n):n}},5559:(e,t,n)=>{"use strict";var r=n(8612),a=n(210),o=a("%Function.prototype.apply%"),l=a("%Function.prototype.call%"),i=a("%Reflect.apply%",!0)||r.call(l,o),u=a("%Object.getOwnPropertyDescriptor%",!0),s=a("%Object.defineProperty%",!0),c=a("%Math.max%");if(s)try{s({},"a",{value:1})}catch(e){s=null}e.exports=function(e){var t=i(r,l,arguments);if(u&&s){var n=u(t,"length");n.configurable&&s(t,"length",{value:1+c(0,e.length-(arguments.length-1))})}return t};var p=function(){return i(r,o,arguments)};s?s(e.exports,"apply",{value:p}):e.exports.apply=p},4184:(e,t)=>{var n;!function(){"use strict";var r={}.hasOwnProperty;function a(){for(var e=[],t=0;t<arguments.length;t++){var n=arguments[t];if(n){var o=typeof n;if("string"===o||"number"===o)e.push(n);else if(Array.isArray(n)){if(n.length){var l=a.apply(null,n);l&&e.push(l)}}else if("object"===o)if(n.toString===Object.prototype.toString)for(var i in n)r.call(n,i)&&n[i]&&e.push(i);else e.push(n.toString())}}return e.join(" ")}e.exports?(a.default=a,e.exports=a):void 0===(n=function(){return a}.apply(t,[]))||(e.exports=n)}()},640:(e,t,n)=>{"use strict";var r=n(1742),a={"text/plain":"Text","text/html":"Url",default:"Text"};e.exports=function(e,t){var n,o,l,i,u,s,c=!1;t||(t={}),n=t.debug||!1;try{if(l=r(),i=document.createRange(),u=document.getSelection(),(s=document.createElement("span")).textContent=e,s.style.all="unset",s.style.position="fixed",s.style.top=0,s.style.clip="rect(0, 0, 0, 0)",s.style.whiteSpace="pre",s.style.webkitUserSelect="text",s.style.MozUserSelect="text",s.style.msUserSelect="text",s.style.userSelect="text",s.addEventListener("copy",(function(r){if(r.stopPropagation(),t.format)if(r.preventDefault(),void 0===r.clipboardData){n&&console.warn("unable to use e.clipboardData"),n&&console.warn("trying IE specific stuff"),window.clipboardData.clearData();var o=a[t.format]||a.default;window.clipboardData.setData(o,e)}else r.clipboardData.clearData(),r.clipboardData.setData(t.format,e);t.onCopy&&(r.preventDefault(),t.onCopy(r.clipboardData))})),document.body.appendChild(s),i.selectNodeContents(s),u.addRange(i),!document.execCommand("copy"))throw new Error("copy command was unsuccessful");c=!0}catch(r){n&&console.error("unable to copy using execCommand: ",r),n&&console.warn("trying IE specific stuff");try{window.clipboardData.setData(t.format||"text",e),t.onCopy&&t.onCopy(window.clipboardData),c=!0}catch(r){n&&console.error("unable to copy using clipboardData: ",r),n&&console.error("falling back to prompt"),o=function(e){var t=(/mac os x/i.test(navigator.userAgent)?"⌘":"Ctrl")+"+C";return e.replace(/#{\s*key\s*}/g,t)}("message"in t?t.message:"Copy to clipboard: #{key}, Enter"),window.prompt(o,e)}}finally{u&&("function"==typeof u.removeRange?u.removeRange(i):u.removeAllRanges()),s&&document.body.removeChild(s),l()}return c}},251:(e,t,n)=>{"use strict";var r=n(2215),a=n(2584),o=n(609),l=n(8420),i=n(6068),u=n(8326),s=n(8923),c=n(3679),p=n(210),d=n(1924),f=n(3483),h=n(3216),m=n(7478),g=n(6430),y=n(3533),v=d("Date.prototype.getTime"),b=Object.getPrototypeOf,w=d("Object.prototype.toString"),E=p("%Set%",!0),_=d("Map.prototype.has",!0),x=d("Map.prototype.get",!0),S=d("Map.prototype.size",!0),k=d("Set.prototype.add",!0),C=d("Set.prototype.delete",!0),D=d("Set.prototype.has",!0),O=d("Set.prototype.size",!0);function P(e,t,n,r){for(var a,o=h(e);(a=o.next())&&!a.done;)if(j(t,a.value,n,r))return C(e,a.value),!0;return!1}function T(e){return void 0===e?null:"object"!=typeof e?"symbol"!=typeof e&&("string"!=typeof e&&"number"!=typeof e||+e==+e):void 0}function N(e,t,n,r,a,o){var l=T(n);if(null!=l)return l;var i=x(t,l),u=y({},a,{strict:!1});return!(void 0===i&&!_(t,l)||!j(r,i,u,o))&&!_(e,l)&&j(r,i,u,o)}function M(e,t,n){var r=T(n);return null!=r?r:D(t,r)&&!D(e,r)}function R(e,t,n,r,a,o){for(var l,i,u=h(e);(l=u.next())&&!l.done;)if(j(n,i=l.value,a,o)&&j(r,x(t,i),a,o))return C(e,i),!0;return!1}function j(e,t,n,p){var d=n||{};if(d.strict?o(e,t):e===t)return!0;if(c(e)!==c(t))return!1;if(!e||!t||"object"!=typeof e&&"object"!=typeof t)return d.strict?o(e,t):e==t;var m,C=p.has(e),T=p.has(t);if(C&&T){if(p.get(e)===p.get(t))return!0}else m={};return C||p.set(e,m),T||p.set(t,m),function(e,t,n,o){var c,p;if(typeof e!=typeof t)return!1;if(null==e||null==t)return!1;if(w(e)!==w(t))return!1;if(a(e)!==a(t))return!1;if(u(e)!==u(t))return!1;var d=e instanceof Error,m=t instanceof Error;if(d!==m)return!1;if((d||m)&&(e.name!==t.name||e.message!==t.message))return!1;var C=l(e),T=l(t);if(C!==T)return!1;if((C||T)&&(e.source!==t.source||i(e)!==i(t)))return!1;var I=s(e),F=s(t);if(I!==F)return!1;if((I||F)&&v(e)!==v(t))return!1;if(n.strict&&b&&b(e)!==b(t))return!1;if(g(e)!==g(t))return!1;var L=A(e),U=A(t);if(L!==U)return!1;if(L||U){if(e.length!==t.length)return!1;for(c=0;c<e.length;c++)if(e[c]!==t[c])return!1;return!0}if(typeof e!=typeof t)return!1;var z=r(e),Y=r(t);if(z.length!==Y.length)return!1;for(z.sort(),Y.sort(),c=z.length-1;c>=0;c--)if(z[c]!=Y[c])return!1;for(c=z.length-1;c>=0;c--)if(!j(e[p=z[c]],t[p],n,o))return!1;var W=f(e),B=f(t);return W===B&&("Set"===W||"Set"===B?function(e,t,n,r){if(O(e)!==O(t))return!1;for(var a,o,l,i=h(e),u=h(t);(a=i.next())&&!a.done;)if(a.value&&"object"==typeof a.value)l||(l=new E),k(l,a.value);else if(!D(t,a.value)){if(n.strict)return!1;if(!M(e,t,a.value))return!1;l||(l=new E),k(l,a.value)}if(l){for(;(o=u.next())&&!o.done;)if(o.value&&"object"==typeof o.value){if(!P(l,o.value,n.strict,r))return!1}else if(!n.strict&&!D(e,o.value)&&!P(l,o.value,n.strict,r))return!1;return 0===O(l)}return!0}(e,t,n,o):"Map"!==W||function(e,t,n,r){if(S(e)!==S(t))return!1;for(var a,o,l,i,u,s,c=h(e),p=h(t);(a=c.next())&&!a.done;)if(i=a.value[0],u=a.value[1],i&&"object"==typeof i)l||(l=new E),k(l,i);else if(void 0===(s=x(t,i))&&!_(t,i)||!j(u,s,n,r)){if(n.strict)return!1;if(!N(e,t,i,u,n,r))return!1;l||(l=new E),k(l,i)}if(l){for(;(o=p.next())&&!o.done;)if(i=o.value[0],s=o.value[1],i&&"object"==typeof i){if(!R(l,e,i,s,n,r))return!1}else if(!(n.strict||e.has(i)&&j(x(e,i),s,n,r)||R(l,e,i,s,y({},n,{strict:!1}),r)))return!1;return 0===O(l)}return!0}(e,t,n,o))}(e,t,d,p)}function A(e){return!(!e||"object"!=typeof e||"number"!=typeof e.length||"function"!=typeof e.copy||"function"!=typeof e.slice||e.length>0&&"number"!=typeof e[0]||!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e)))}e.exports=function(e,t,n){return j(e,t,n,m())}},8326:e=>{var t={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==t.call(e)}},6005:e=>{"use strict";var t=Object,n=TypeError;e.exports=function(){if(null!=this&&this!==t(this))throw new n("RegExp.prototype.flags getter called on non-object");var e="";return this.hasIndices&&(e+="d"),this.global&&(e+="g"),this.ignoreCase&&(e+="i"),this.multiline&&(e+="m"),this.dotAll&&(e+="s"),this.unicode&&(e+="u"),this.sticky&&(e+="y"),e}},6068:(e,t,n)=>{"use strict";var r=n(4289),a=n(5559),o=n(6005),l=n(1706),i=n(3072),u=a(l());r(u,{getPolyfill:l,implementation:o,shim:i}),e.exports=u},1706:(e,t,n)=>{"use strict";var r=n(6005),a=n(4289).supportsDescriptors,o=Object.getOwnPropertyDescriptor;e.exports=function(){if(a&&"gim"===/a/gim.flags){var e=o(RegExp.prototype,"flags");if(e&&"function"==typeof e.get&&"boolean"==typeof/a/.dotAll)return e.get}return r}},3072:(e,t,n)=>{"use strict";var r=n(4289).supportsDescriptors,a=n(1706),o=Object.getOwnPropertyDescriptor,l=Object.defineProperty,i=TypeError,u=Object.getPrototypeOf,s=/a/;e.exports=function(){if(!r||!u)throw new i("RegExp.prototype.flags requires a true ES5 environment that supports property descriptors");var e=a(),t=u(s),n=o(t,"flags");return n&&n.get===e||l(t,"flags",{configurable:!0,enumerable:!1,get:e}),e}},4289:(e,t,n)=>{"use strict";var r=n(2215),a="function"==typeof Symbol&&"symbol"==typeof Symbol("foo"),o=Object.prototype.toString,l=Array.prototype.concat,i=Object.defineProperty,u=i&&function(){var e={};try{for(var t in i(e,"x",{enumerable:!1,value:e}),e)return!1;return e.x===e}catch(e){return!1}}(),s=function(e,t,n,r){var a;(!(t in e)||"function"==typeof(a=r)&&"[object Function]"===o.call(a)&&r())&&(u?i(e,t,{configurable:!0,enumerable:!1,value:n,writable:!0}):e[t]=n)},c=function(e,t){var n=arguments.length>2?arguments[2]:{},o=r(t);a&&(o=l.call(o,Object.getOwnPropertySymbols(t)));for(var i=0;i<o.length;i+=1)s(e,o[i],t[o[i]],n[o[i]])};c.supportsDescriptors=!!u,e.exports=c},5677:e=>{var t={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==t.call(e)}},3162:function(e,t,n){var r;void 0===(r=function(){"use strict";function t(e,t,n){var r=new XMLHttpRequest;r.open("GET",e),r.responseType="blob",r.onload=function(){i(r.response,t,n)},r.onerror=function(){console.error("could not download file")},r.send()}function r(e){var t=new XMLHttpRequest;t.open("HEAD",e,!1);try{t.send()}catch(e){}return 200<=t.status&&299>=t.status}function a(e){try{e.dispatchEvent(new MouseEvent("click"))}catch(n){var t=document.createEvent("MouseEvents");t.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),e.dispatchEvent(t)}}var o="object"==typeof window&&window.window===window?window:"object"==typeof self&&self.self===self?self:"object"==typeof n.g&&n.g.global===n.g?n.g:void 0,l=o.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),i=o.saveAs||("object"!=typeof window||window!==o?function(){}:"download"in HTMLAnchorElement.prototype&&!l?function(e,n,l){var i=o.URL||o.webkitURL,u=document.createElement("a");n=n||e.name||"download",u.download=n,u.rel="noopener","string"==typeof e?(u.href=e,u.origin===location.origin?a(u):r(u.href)?t(e,n,l):a(u,u.target="_blank")):(u.href=i.createObjectURL(e),setTimeout((function(){i.revokeObjectURL(u.href)}),4e4),setTimeout((function(){a(u)}),0))}:"msSaveOrOpenBlob"in navigator?function(e,n,o){if(n=n||e.name||"download","string"!=typeof e)navigator.msSaveOrOpenBlob(function(e,t){return void 0===t?t={autoBom:!1}:"object"!=typeof t&&(console.warn("Deprecated: Expected third argument to be a object"),t={autoBom:!t}),t.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob(["\ufeff",e],{type:e.type}):e}(e,o),n);else if(r(e))t(e,n,o);else{var l=document.createElement("a");l.href=e,l.target="_blank",setTimeout((function(){a(l)}))}}:function(e,n,r,a){if((a=a||open("","_blank"))&&(a.document.title=a.document.body.innerText="downloading..."),"string"==typeof e)return t(e,n,r);var i="application/octet-stream"===e.type,u=/constructor/i.test(o.HTMLElement)||o.safari,s=/CriOS\/[\d]+/.test(navigator.userAgent);if((s||i&&u||l)&&"undefined"!=typeof FileReader){var c=new FileReader;c.onloadend=function(){var e=c.result;e=s?e:e.replace(/^data:[^;]*;/,"data:attachment/file;"),a?a.location.href=e:location=e,a=null},c.readAsDataURL(e)}else{var p=o.URL||o.webkitURL,d=p.createObjectURL(e);a?a.location=d:location.href=d,a=null,setTimeout((function(){p.revokeObjectURL(d)}),4e4)}});o.saveAs=i.saveAs=i,e.exports=i}.apply(t,[]))||(e.exports=r)},9804:e=>{var t=Object.prototype.hasOwnProperty,n=Object.prototype.toString;e.exports=function(e,r,a){if("[object Function]"!==n.call(r))throw new TypeError("iterator must be a function");var o=e.length;if(o===+o)for(var l=0;l<o;l++)r.call(a,e[l],l,e);else for(var i in e)t.call(e,i)&&r.call(a,e[i],i,e)}},7648:e=>{"use strict";var t="Function.prototype.bind called on incompatible ",n=Array.prototype.slice,r=Object.prototype.toString,a="[object Function]";e.exports=function(e){var o=this;if("function"!=typeof o||r.call(o)!==a)throw new TypeError(t+o);for(var l,i=n.call(arguments,1),u=function(){if(this instanceof l){var t=o.apply(this,i.concat(n.call(arguments)));return Object(t)===t?t:this}return o.apply(e,i.concat(n.call(arguments)))},s=Math.max(0,o.length-i.length),c=[],p=0;p<s;p++)c.push("$"+p);if(l=Function("binder","return function ("+c.join(",")+"){ return binder.apply(this,arguments); }")(u),o.prototype){var d=function(){};d.prototype=o.prototype,l.prototype=new d,d.prototype=null}return l}},8612:(e,t,n)=>{"use strict";var r=n(7648);e.exports=Function.prototype.bind||r},210:(e,t,n)=>{"use strict";var r,a=SyntaxError,o=Function,l=TypeError,i=function(e){try{return o('"use strict"; return ('+e+").constructor;")()}catch(e){}},u=Object.getOwnPropertyDescriptor;if(u)try{u({},"")}catch(e){u=null}var s=function(){throw new l},c=u?function(){try{return s}catch(e){try{return u(arguments,"callee").get}catch(e){return s}}}():s,p=n(1405)(),d=Object.getPrototypeOf||function(e){return e.__proto__},f={},h="undefined"==typeof Uint8Array?r:d(Uint8Array),m={"%AggregateError%":"undefined"==typeof AggregateError?r:AggregateError,"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?r:ArrayBuffer,"%ArrayIteratorPrototype%":p?d([][Symbol.iterator]()):r,"%AsyncFromSyncIteratorPrototype%":r,"%AsyncFunction%":f,"%AsyncGenerator%":f,"%AsyncGeneratorFunction%":f,"%AsyncIteratorPrototype%":f,"%Atomics%":"undefined"==typeof Atomics?r:Atomics,"%BigInt%":"undefined"==typeof BigInt?r:BigInt,"%Boolean%":Boolean,"%DataView%":"undefined"==typeof DataView?r:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%eval%":eval,"%EvalError%":EvalError,"%Float32Array%":"undefined"==typeof Float32Array?r:Float32Array,"%Float64Array%":"undefined"==typeof Float64Array?r:Float64Array,"%FinalizationRegistry%":"undefined"==typeof FinalizationRegistry?r:FinalizationRegistry,"%Function%":o,"%GeneratorFunction%":f,"%Int8Array%":"undefined"==typeof Int8Array?r:Int8Array,"%Int16Array%":"undefined"==typeof Int16Array?r:Int16Array,"%Int32Array%":"undefined"==typeof Int32Array?r:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":p?d(d([][Symbol.iterator]())):r,"%JSON%":"object"==typeof JSON?JSON:r,"%Map%":"undefined"==typeof Map?r:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&p?d((new Map)[Symbol.iterator]()):r,"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":"undefined"==typeof Promise?r:Promise,"%Proxy%":"undefined"==typeof Proxy?r:Proxy,"%RangeError%":RangeError,"%ReferenceError%":ReferenceError,"%Reflect%":"undefined"==typeof Reflect?r:Reflect,"%RegExp%":RegExp,"%Set%":"undefined"==typeof Set?r:Set,"%SetIteratorPrototype%":"undefined"!=typeof Set&&p?d((new Set)[Symbol.iterator]()):r,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?r:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":p?d(""[Symbol.iterator]()):r,"%Symbol%":p?Symbol:r,"%SyntaxError%":a,"%ThrowTypeError%":c,"%TypedArray%":h,"%TypeError%":l,"%Uint8Array%":"undefined"==typeof Uint8Array?r:Uint8Array,"%Uint8ClampedArray%":"undefined"==typeof Uint8ClampedArray?r:Uint8ClampedArray,"%Uint16Array%":"undefined"==typeof Uint16Array?r:Uint16Array,"%Uint32Array%":"undefined"==typeof Uint32Array?r:Uint32Array,"%URIError%":URIError,"%WeakMap%":"undefined"==typeof WeakMap?r:WeakMap,"%WeakRef%":"undefined"==typeof WeakRef?r:WeakRef,"%WeakSet%":"undefined"==typeof WeakSet?r:WeakSet},g=function e(t){var n;if("%AsyncFunction%"===t)n=i("async function () {}");else if("%GeneratorFunction%"===t)n=i("function* () {}");else if("%AsyncGeneratorFunction%"===t)n=i("async function* () {}");else if("%AsyncGenerator%"===t){var r=e("%AsyncGeneratorFunction%");r&&(n=r.prototype)}else if("%AsyncIteratorPrototype%"===t){var a=e("%AsyncGenerator%");a&&(n=d(a.prototype))}return m[t]=n,n},y={"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},v=n(8612),b=n(7642),w=v.call(Function.call,Array.prototype.concat),E=v.call(Function.apply,Array.prototype.splice),_=v.call(Function.call,String.prototype.replace),x=v.call(Function.call,String.prototype.slice),S=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,k=/\\(\\)?/g,C=function(e){var t=x(e,0,1),n=x(e,-1);if("%"===t&&"%"!==n)throw new a("invalid intrinsic syntax, expected closing `%`");if("%"===n&&"%"!==t)throw new a("invalid intrinsic syntax, expected opening `%`");var r=[];return _(e,S,(function(e,t,n,a){r[r.length]=n?_(a,k,"$1"):t||e})),r},D=function(e,t){var n,r=e;if(b(y,r)&&(r="%"+(n=y[r])[0]+"%"),b(m,r)){var o=m[r];if(o===f&&(o=g(r)),void 0===o&&!t)throw new l("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:n,name:r,value:o}}throw new a("intrinsic "+e+" does not exist!")};e.exports=function(e,t){if("string"!=typeof e||0===e.length)throw new l("intrinsic name must be a non-empty string");if(arguments.length>1&&"boolean"!=typeof t)throw new l('"allowMissing" argument must be a boolean');var n=C(e),r=n.length>0?n[0]:"",o=D("%"+r+"%",t),i=o.name,s=o.value,c=!1,p=o.alias;p&&(r=p[0],E(n,w([0,1],p)));for(var d=1,f=!0;d<n.length;d+=1){var h=n[d],g=x(h,0,1),y=x(h,-1);if(('"'===g||"'"===g||"`"===g||'"'===y||"'"===y||"`"===y)&&g!==y)throw new a("property names with quotes must have matching quotes");if("constructor"!==h&&f||(c=!0),b(m,i="%"+(r+="."+h)+"%"))s=m[i];else if(null!=s){if(!(h in s)){if(!t)throw new l("base intrinsic for "+e+" exists, but the property is not available.");return}if(u&&d+1>=n.length){var v=u(s,h);s=(f=!!v)&&"get"in v&&!("originalValue"in v.get)?v.get:s[h]}else f=b(s,h),s=s[h];f&&!c&&(m[i]=s)}}return s}},932:(e,t,n)=>{"use strict";var r=n.g.BigInt;e.exports=function(){return"function"==typeof r&&"function"==typeof BigInt&&"bigint"==typeof r(42)&&"bigint"==typeof BigInt(42)}},1405:(e,t,n)=>{"use strict";var r="undefined"!=typeof Symbol&&Symbol,a=n(5419);e.exports=function(){return"function"==typeof r&&"function"==typeof Symbol&&"symbol"==typeof r("foo")&&"symbol"==typeof Symbol("bar")&&a()}},5419:e=>{"use strict";e.exports=function(){if("function"!=typeof Symbol||"function"!=typeof Object.getOwnPropertySymbols)return!1;if("symbol"==typeof Symbol.iterator)return!0;var e={},t=Symbol("test"),n=Object(t);if("string"==typeof t)return!1;if("[object Symbol]"!==Object.prototype.toString.call(t))return!1;if("[object Symbol]"!==Object.prototype.toString.call(n))return!1;for(t in e[t]=42,e)return!1;if("function"==typeof Object.keys&&0!==Object.keys(e).length)return!1;if("function"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(e).length)return!1;var r=Object.getOwnPropertySymbols(e);if(1!==r.length||r[0]!==t)return!1;if(!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){var a=Object.getOwnPropertyDescriptor(e,t);if(42!==a.value||!0!==a.enumerable)return!1}return!0}},6410:(e,t,n)=>{"use strict";var r=n(5419);e.exports=function(){return r()&&!!Symbol.toStringTag}},7642:(e,t,n)=>{"use strict";var r=n(8612);e.exports=r.call(Function.call,Object.prototype.hasOwnProperty)},8679:(e,t,n)=>{"use strict";var r=n(9864),a={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},o={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},l={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},i={};function u(e){return r.isMemo(e)?l:i[e.$$typeof]||a}i[r.ForwardRef]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},i[r.Memo]=l;var s=Object.defineProperty,c=Object.getOwnPropertyNames,p=Object.getOwnPropertySymbols,d=Object.getOwnPropertyDescriptor,f=Object.getPrototypeOf,h=Object.prototype;e.exports=function e(t,n,r){if("string"!=typeof n){if(h){var a=f(n);a&&a!==h&&e(t,a,r)}var l=c(n);p&&(l=l.concat(p(n)));for(var i=u(t),m=u(n),g=0;g<l.length;++g){var y=l[g];if(!(o[y]||r&&r[y]||m&&m[y]||i&&i[y])){var v=d(n,y);try{s(t,y,v)}catch(e){}}}}return t}},2584:(e,t,n)=>{"use strict";var r=n(6410)(),a=n(1924)("Object.prototype.toString"),o=function(e){return!(r&&e&&"object"==typeof e&&Symbol.toStringTag in e)&&"[object Arguments]"===a(e)},l=function(e){return!!o(e)||null!==e&&"object"==typeof e&&"number"==typeof e.length&&e.length>=0&&"[object Array]"!==a(e)&&"[object Function]"===a(e.callee)},i=function(){return o(arguments)}();o.isLegacyArguments=l,e.exports=i?o:l},3376:(e,t,n)=>{"use strict";if(n(932)()){var r=BigInt.prototype.valueOf;e.exports=function(e){return null!=e&&"boolean"!=typeof e&&"string"!=typeof e&&"number"!=typeof e&&"symbol"!=typeof e&&"function"!=typeof e&&("bigint"==typeof e||function(e){try{return r.call(e),!0}catch(e){}return!1}(e))}}else e.exports=function(e){return!1}},6814:(e,t,n)=>{"use strict";var r=n(1924),a=r("Boolean.prototype.toString"),o=r("Object.prototype.toString"),l=n(6410)();e.exports=function(e){return"boolean"==typeof e||null!==e&&"object"==typeof e&&(l&&Symbol.toStringTag in e?function(e){try{return a(e),!0}catch(e){return!1}}(e):"[object Boolean]"===o(e))}},8923:(e,t,n)=>{"use strict";var r=Date.prototype.getDay,a=Object.prototype.toString,o=n(6410)();e.exports=function(e){return"object"==typeof e&&null!==e&&(o?function(e){try{return r.call(e),!0}catch(e){return!1}}(e):"[object Date]"===a.call(e))}},8379:e=>{"use strict";var t,n="function"==typeof Map&&Map.prototype?Map:null,r="function"==typeof Set&&Set.prototype?Set:null;n||(t=function(e){return!1});var a=n?Map.prototype.has:null,o=r?Set.prototype.has:null;t||a||(t=function(e){return!1}),e.exports=t||function(e){if(!e||"object"!=typeof e)return!1;try{if(a.call(e),o)try{o.call(e)}catch(e){return!0}return e instanceof n}catch(e){}return!1}},4578:(e,t,n)=>{"use strict";var r=Number.prototype.toString,a=Object.prototype.toString,o=n(6410)();e.exports=function(e){return"number"==typeof e||"object"==typeof e&&(o?function(e){try{return r.call(e),!0}catch(e){return!1}}(e):"[object Number]"===a.call(e))}},8420:(e,t,n)=>{"use strict";var r,a,o,l,i=n(1924),u=n(6410)();if(u){r=i("Object.prototype.hasOwnProperty"),a=i("RegExp.prototype.exec"),o={};var s=function(){throw o};l={toString:s,valueOf:s},"symbol"==typeof Symbol.toPrimitive&&(l[Symbol.toPrimitive]=s)}var c=i("Object.prototype.toString"),p=Object.getOwnPropertyDescriptor;e.exports=u?function(e){if(!e||"object"!=typeof e)return!1;var t=p(e,"lastIndex");if(!t||!r(t,"value"))return!1;try{a(e,l)}catch(e){return e===o}}:function(e){return!(!e||"object"!=typeof e&&"function"!=typeof e)&&"[object RegExp]"===c(e)}},9572:e=>{"use strict";var t,n="function"==typeof Map&&Map.prototype?Map:null,r="function"==typeof Set&&Set.prototype?Set:null;r||(t=function(e){return!1});var a=n?Map.prototype.has:null,o=r?Set.prototype.has:null;t||o||(t=function(e){return!1}),e.exports=t||function(e){if(!e||"object"!=typeof e)return!1;try{if(o.call(e),a)try{a.call(e)}catch(e){return!0}return e instanceof r}catch(e){}return!1}},9981:(e,t,n)=>{"use strict";var r=String.prototype.valueOf,a=Object.prototype.toString,o=n(6410)();e.exports=function(e){return"string"==typeof e||"object"==typeof e&&(o?function(e){try{return r.call(e),!0}catch(e){return!1}}(e):"[object String]"===a.call(e))}},2636:(e,t,n)=>{"use strict";var r=Object.prototype.toString;if(n(1405)()){var a=Symbol.prototype.toString,o=/^Symbol\(.*\)$/;e.exports=function(e){if("symbol"==typeof e)return!0;if("[object Symbol]"!==r.call(e))return!1;try{return function(e){return"symbol"==typeof e.valueOf()&&o.test(a.call(e))}(e)}catch(e){return!1}}}else e.exports=function(e){return!1}},5692:(e,t,n)=>{"use strict";var r=n(9804),a=n(3083),o=n(1924),l=o("Object.prototype.toString"),i=n(6410)(),u="undefined"==typeof globalThis?n.g:globalThis,s=a(),c=o("Array.prototype.indexOf",!0)||function(e,t){for(var n=0;n<e.length;n+=1)if(e[n]===t)return n;return-1},p=o("String.prototype.slice"),d={},f=n(882),h=Object.getPrototypeOf;i&&f&&h&&r(s,(function(e){var t=new u[e];if(Symbol.toStringTag in t){var n=h(t),r=f(n,Symbol.toStringTag);if(!r){var a=h(n);r=f(a,Symbol.toStringTag)}d[e]=r.get}})),e.exports=function(e){if(!e||"object"!=typeof e)return!1;if(!i||!(Symbol.toStringTag in e)){var t=p(l(e),8,-1);return c(s,t)>-1}return!!f&&function(e){var t=!1;return r(d,(function(n,r){if(!t)try{t=n.call(e)===r}catch(e){}})),t}(e)}},1718:e=>{"use strict";var t,n="function"==typeof WeakMap&&WeakMap.prototype?WeakMap:null,r="function"==typeof WeakSet&&WeakSet.prototype?WeakSet:null;n||(t=function(e){return!1});var a=n?n.prototype.has:null,o=r?r.prototype.has:null;t||a||(t=function(e){return!1}),e.exports=t||function(e){if(!e||"object"!=typeof e)return!1;try{if(a.call(e,a),o)try{o.call(e,o)}catch(e){return!0}return e instanceof n}catch(e){}return!1}},5899:(e,t,n)=>{"use strict";var r=n(210),a=n(1924),o=r("%WeakSet%",!0),l=a("WeakSet.prototype.has",!0);if(l){var i=a("WeakMap.prototype.has",!0);e.exports=function(e){if(!e||"object"!=typeof e)return!1;try{if(l(e,l),i)try{i(e,i)}catch(e){return!0}return e instanceof o}catch(e){}return!1}}else e.exports=function(e){return!1}},7418:e=>{"use strict";var t=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable;function a(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}e.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map((function(e){return t[e]})).join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach((function(e){r[e]=e})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(e){return!1}}()?Object.assign:function(e,o){for(var l,i,u=a(e),s=1;s<arguments.length;s++){for(var c in l=Object(arguments[s]))n.call(l,c)&&(u[c]=l[c]);if(t){i=t(l);for(var p=0;p<i.length;p++)r.call(l,i[p])&&(u[i[p]]=l[i[p]])}}return u}},631:(e,t,n)=>{var r="function"==typeof Map&&Map.prototype,a=Object.getOwnPropertyDescriptor&&r?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,o=r&&a&&"function"==typeof a.get?a.get:null,l=r&&Map.prototype.forEach,i="function"==typeof Set&&Set.prototype,u=Object.getOwnPropertyDescriptor&&i?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,s=i&&u&&"function"==typeof u.get?u.get:null,c=i&&Set.prototype.forEach,p="function"==typeof WeakMap&&WeakMap.prototype?WeakMap.prototype.has:null,d="function"==typeof WeakSet&&WeakSet.prototype?WeakSet.prototype.has:null,f="function"==typeof WeakRef&&WeakRef.prototype?WeakRef.prototype.deref:null,h=Boolean.prototype.valueOf,m=Object.prototype.toString,g=Function.prototype.toString,y=String.prototype.match,v=String.prototype.slice,b=String.prototype.replace,w=String.prototype.toUpperCase,E=String.prototype.toLowerCase,_=RegExp.prototype.test,x=Array.prototype.concat,S=Array.prototype.join,k=Array.prototype.slice,C=Math.floor,D="function"==typeof BigInt?BigInt.prototype.valueOf:null,O=Object.getOwnPropertySymbols,P="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol.prototype.toString:null,T="function"==typeof Symbol&&"object"==typeof Symbol.iterator,N="function"==typeof Symbol&&Symbol.toStringTag&&(Symbol.toStringTag,1)?Symbol.toStringTag:null,M=Object.prototype.propertyIsEnumerable,R=("function"==typeof Reflect?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(e){return e.__proto__}:null);function j(e,t){if(e===1/0||e===-1/0||e!=e||e&&e>-1e3&&e<1e3||_.call(/e/,t))return t;var n=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if("number"==typeof e){var r=e<0?-C(-e):C(e);if(r!==e){var a=String(r),o=v.call(t,a.length+1);return b.call(a,n,"$&_")+"."+b.call(b.call(o,/([0-9]{3})/g,"$&_"),/_$/,"")}}return b.call(t,n,"$&_")}var A=n(4654).custom,I=A&&z(A)?A:null;function F(e,t,n){var r="double"===(n.quoteStyle||t)?'"':"'";return r+e+r}function L(e){return b.call(String(e),/"/g,"&quot;")}function U(e){return!("[object Array]"!==B(e)||N&&"object"==typeof e&&N in e)}function z(e){if(T)return e&&"object"==typeof e&&e instanceof Symbol;if("symbol"==typeof e)return!0;if(!e||"object"!=typeof e||!P)return!1;try{return P.call(e),!0}catch(e){}return!1}e.exports=function e(t,n,r,a){var i=n||{};if(W(i,"quoteStyle")&&"single"!==i.quoteStyle&&"double"!==i.quoteStyle)throw new TypeError('option "quoteStyle" must be "single" or "double"');if(W(i,"maxStringLength")&&("number"==typeof i.maxStringLength?i.maxStringLength<0&&i.maxStringLength!==1/0:null!==i.maxStringLength))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var u=!W(i,"customInspect")||i.customInspect;if("boolean"!=typeof u&&"symbol"!==u)throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(W(i,"indent")&&null!==i.indent&&"\t"!==i.indent&&!(parseInt(i.indent,10)===i.indent&&i.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(W(i,"numericSeparator")&&"boolean"!=typeof i.numericSeparator)throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var m=i.numericSeparator;if(void 0===t)return"undefined";if(null===t)return"null";if("boolean"==typeof t)return t?"true":"false";if("string"==typeof t)return q(t,i);if("number"==typeof t){if(0===t)return 1/0/t>0?"0":"-0";var w=String(t);return m?j(t,w):w}if("bigint"==typeof t){var _=String(t)+"n";return m?j(t,_):_}var C=void 0===i.depth?5:i.depth;if(void 0===r&&(r=0),r>=C&&C>0&&"object"==typeof t)return U(t)?"[Array]":"[Object]";var O,A=function(e,t){var n;if("\t"===e.indent)n="\t";else{if(!("number"==typeof e.indent&&e.indent>0))return null;n=S.call(Array(e.indent+1)," ")}return{base:n,prev:S.call(Array(t+1),n)}}(i,r);if(void 0===a)a=[];else if(H(a,t)>=0)return"[Circular]";function Y(t,n,o){if(n&&(a=k.call(a)).push(n),o){var l={depth:i.depth};return W(i,"quoteStyle")&&(l.quoteStyle=i.quoteStyle),e(t,l,r+1,a)}return e(t,i,r+1,a)}if("function"==typeof t){var V=function(e){if(e.name)return e.name;var t=y.call(g.call(e),/^function\s*([\w$]+)/);return t?t[1]:null}(t),X=G(t,Y);return"[Function"+(V?": "+V:" (anonymous)")+"]"+(X.length>0?" { "+S.call(X,", ")+" }":"")}if(z(t)){var J=T?b.call(String(t),/^(Symbol\(.*\))_[^)]*$/,"$1"):P.call(t);return"object"!=typeof t||T?J:$(J)}if((O=t)&&"object"==typeof O&&("undefined"!=typeof HTMLElement&&O instanceof HTMLElement||"string"==typeof O.nodeName&&"function"==typeof O.getAttribute)){for(var ee="<"+E.call(String(t.nodeName)),te=t.attributes||[],ne=0;ne<te.length;ne++)ee+=" "+te[ne].name+"="+F(L(te[ne].value),"double",i);return ee+=">",t.childNodes&&t.childNodes.length&&(ee+="..."),ee+"</"+E.call(String(t.nodeName))+">"}if(U(t)){if(0===t.length)return"[]";var re=G(t,Y);return A&&!function(e){for(var t=0;t<e.length;t++)if(H(e[t],"\n")>=0)return!1;return!0}(re)?"["+K(re,A)+"]":"[ "+S.call(re,", ")+" ]"}if(function(e){return!("[object Error]"!==B(e)||N&&"object"==typeof e&&N in e)}(t)){var ae=G(t,Y);return"cause"in t&&!M.call(t,"cause")?"{ ["+String(t)+"] "+S.call(x.call("[cause]: "+Y(t.cause),ae),", ")+" }":0===ae.length?"["+String(t)+"]":"{ ["+String(t)+"] "+S.call(ae,", ")+" }"}if("object"==typeof t&&u){if(I&&"function"==typeof t[I])return t[I]();if("symbol"!==u&&"function"==typeof t.inspect)return t.inspect()}if(function(e){if(!o||!e||"object"!=typeof e)return!1;try{o.call(e);try{s.call(e)}catch(e){return!0}return e instanceof Map}catch(e){}return!1}(t)){var oe=[];return l.call(t,(function(e,n){oe.push(Y(n,t,!0)+" => "+Y(e,t))})),Q("Map",o.call(t),oe,A)}if(function(e){if(!s||!e||"object"!=typeof e)return!1;try{s.call(e);try{o.call(e)}catch(e){return!0}return e instanceof Set}catch(e){}return!1}(t)){var le=[];return c.call(t,(function(e){le.push(Y(e,t))})),Q("Set",s.call(t),le,A)}if(function(e){if(!p||!e||"object"!=typeof e)return!1;try{p.call(e,p);try{d.call(e,d)}catch(e){return!0}return e instanceof WeakMap}catch(e){}return!1}(t))return Z("WeakMap");if(function(e){if(!d||!e||"object"!=typeof e)return!1;try{d.call(e,d);try{p.call(e,p)}catch(e){return!0}return e instanceof WeakSet}catch(e){}return!1}(t))return Z("WeakSet");if(function(e){if(!f||!e||"object"!=typeof e)return!1;try{return f.call(e),!0}catch(e){}return!1}(t))return Z("WeakRef");if(function(e){return!("[object Number]"!==B(e)||N&&"object"==typeof e&&N in e)}(t))return $(Y(Number(t)));if(function(e){if(!e||"object"!=typeof e||!D)return!1;try{return D.call(e),!0}catch(e){}return!1}(t))return $(Y(D.call(t)));if(function(e){return!("[object Boolean]"!==B(e)||N&&"object"==typeof e&&N in e)}(t))return $(h.call(t));if(function(e){return!("[object String]"!==B(e)||N&&"object"==typeof e&&N in e)}(t))return $(Y(String(t)));if(!function(e){return!("[object Date]"!==B(e)||N&&"object"==typeof e&&N in e)}(t)&&!function(e){return!("[object RegExp]"!==B(e)||N&&"object"==typeof e&&N in e)}(t)){var ie=G(t,Y),ue=R?R(t)===Object.prototype:t instanceof Object||t.constructor===Object,se=t instanceof Object?"":"null prototype",ce=!ue&&N&&Object(t)===t&&N in t?v.call(B(t),8,-1):se?"Object":"",pe=(ue||"function"!=typeof t.constructor?"":t.constructor.name?t.constructor.name+" ":"")+(ce||se?"["+S.call(x.call([],ce||[],se||[]),": ")+"] ":"");return 0===ie.length?pe+"{}":A?pe+"{"+K(ie,A)+"}":pe+"{ "+S.call(ie,", ")+" }"}return String(t)};var Y=Object.prototype.hasOwnProperty||function(e){return e in this};function W(e,t){return Y.call(e,t)}function B(e){return m.call(e)}function H(e,t){if(e.indexOf)return e.indexOf(t);for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1}function q(e,t){if(e.length>t.maxStringLength){var n=e.length-t.maxStringLength,r="... "+n+" more character"+(n>1?"s":"");return q(v.call(e,0,t.maxStringLength),t)+r}return F(b.call(b.call(e,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,V),"single",t)}function V(e){var t=e.charCodeAt(0),n={8:"b",9:"t",10:"n",12:"f",13:"r"}[t];return n?"\\"+n:"\\x"+(t<16?"0":"")+w.call(t.toString(16))}function $(e){return"Object("+e+")"}function Z(e){return e+" { ? }"}function Q(e,t,n,r){return e+" ("+t+") {"+(r?K(n,r):S.call(n,", "))+"}"}function K(e,t){if(0===e.length)return"";var n="\n"+t.prev+t.base;return n+S.call(e,","+n)+"\n"+t.prev}function G(e,t){var n=U(e),r=[];if(n){r.length=e.length;for(var a=0;a<e.length;a++)r[a]=W(e,a)?t(e[a],e):""}var o,l="function"==typeof O?O(e):[];if(T){o={};for(var i=0;i<l.length;i++)o["$"+l[i]]=l[i]}for(var u in e)W(e,u)&&(n&&String(Number(u))===u&&u<e.length||T&&o["$"+u]instanceof Symbol||(_.call(/[^\w$]/,u)?r.push(t(u,e)+": "+t(e[u],e)):r.push(u+": "+t(e[u],e))));if("function"==typeof O)for(var s=0;s<l.length;s++)M.call(e,l[s])&&r.push("["+t(l[s])+"]: "+t(e[l[s]],e));return r}},4244:e=>{"use strict";var t=function(e){return e!=e};e.exports=function(e,n){return 0===e&&0===n?1/e==1/n:e===n||!(!t(e)||!t(n))}},609:(e,t,n)=>{"use strict";var r=n(4289),a=n(5559),o=n(4244),l=n(5624),i=n(2281),u=a(l(),Object);r(u,{getPolyfill:l,implementation:o,shim:i}),e.exports=u},5624:(e,t,n)=>{"use strict";var r=n(4244);e.exports=function(){return"function"==typeof Object.is?Object.is:r}},2281:(e,t,n)=>{"use strict";var r=n(5624),a=n(4289);e.exports=function(){var e=r();return a(Object,{is:e},{is:function(){return Object.is!==e}}),e}},8987:(e,t,n)=>{"use strict";var r;if(!Object.keys){var a=Object.prototype.hasOwnProperty,o=Object.prototype.toString,l=n(1414),i=Object.prototype.propertyIsEnumerable,u=!i.call({toString:null},"toString"),s=i.call((function(){}),"prototype"),c=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],p=function(e){var t=e.constructor;return t&&t.prototype===e},d={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},f=function(){if("undefined"==typeof window)return!1;for(var e in window)try{if(!d["$"+e]&&a.call(window,e)&&null!==window[e]&&"object"==typeof window[e])try{p(window[e])}catch(e){return!0}}catch(e){return!0}return!1}();r=function(e){var t=null!==e&&"object"==typeof e,n="[object Function]"===o.call(e),r=l(e),i=t&&"[object String]"===o.call(e),d=[];if(!t&&!n&&!r)throw new TypeError("Object.keys called on a non-object");var h=s&&n;if(i&&e.length>0&&!a.call(e,0))for(var m=0;m<e.length;++m)d.push(String(m));if(r&&e.length>0)for(var g=0;g<e.length;++g)d.push(String(g));else for(var y in e)h&&"prototype"===y||!a.call(e,y)||d.push(String(y));if(u)for(var v=function(e){if("undefined"==typeof window||!f)return p(e);try{return p(e)}catch(e){return!1}}(e),b=0;b<c.length;++b)v&&"constructor"===c[b]||!a.call(e,c[b])||d.push(c[b]);return d}}e.exports=r},2215:(e,t,n)=>{"use strict";var r=Array.prototype.slice,a=n(1414),o=Object.keys,l=o?function(e){return o(e)}:n(8987),i=Object.keys;l.shim=function(){if(Object.keys){var e=function(){var e=Object.keys(arguments);return e&&e.length===arguments.length}(1,2);e||(Object.keys=function(e){return a(e)?i(r.call(e)):i(e)})}else Object.keys=l;return Object.keys||l},e.exports=l},1414:e=>{"use strict";var t=Object.prototype.toString;e.exports=function(e){var n=t.call(e),r="[object Arguments]"===n;return r||(r="[object Array]"!==n&&null!==e&&"object"==typeof e&&"number"==typeof e.length&&e.length>=0&&"[object Function]"===t.call(e.callee)),r}},2837:(e,t,n)=>{"use strict";var r=n(2215),a=function(e){return null!=e},o=n(5419)(),l=n(1924),i=Object,u=l("Array.prototype.push"),s=l("Object.prototype.propertyIsEnumerable"),c=o?Object.getOwnPropertySymbols:null;e.exports=function(e,t){if(!a(e))throw new TypeError("target must be an object");var n,l,p,d,f,h,m,g=i(e);for(n=1;n<arguments.length;++n){l=i(arguments[n]),d=r(l);var y=o&&(Object.getOwnPropertySymbols||c);if(y)for(f=y(l),p=0;p<f.length;++p)m=f[p],s(l,m)&&u(d,m);for(p=0;p<d.length;++p)h=l[m=d[p]],s(l,m)&&(g[m]=h)}return g}},3533:(e,t,n)=>{"use strict";var r=n(4289),a=n(5559),o=n(2837),l=n(8162),i=n(4489),u=a.apply(l()),s=function(e,t){return u(Object,arguments)};r(s,{getPolyfill:l,implementation:o,shim:i}),e.exports=s},8162:(e,t,n)=>{"use strict";var r=n(2837);e.exports=function(){return Object.assign?function(){if(!Object.assign)return!1;for(var e="abcdefghijklmnopqrst",t=e.split(""),n={},r=0;r<t.length;++r)n[t[r]]=t[r];var a=Object.assign({},n),o="";for(var l in a)o+=l;return e!==o}()||function(){if(!Object.assign||!Object.preventExtensions)return!1;var e=Object.preventExtensions({1:2});try{Object.assign(e,"xy")}catch(t){return"y"===e[1]}return!1}()?r:Object.assign:r}},4489:(e,t,n)=>{"use strict";var r=n(4289),a=n(8162);e.exports=function(){var e=a();return r(Object,{assign:e},{assign:function(){return Object.assign!==e}}),e}},2703:(e,t,n)=>{"use strict";var r=n(414);function a(){}function o(){}o.resetWarningCache=a,e.exports=function(){function e(e,t,n,a,o,l){if(l!==r){var i=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw i.name="Invariant Violation",i}}function t(){return e}e.isRequired=e;var n={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:o,resetWarningCache:a};return n.PropTypes=n,n}},5697:(e,t,n)=>{e.exports=n(2703)()},414:e=>{"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},5798:e=>{"use strict";var t=String.prototype.replace,n=/%20/g,r="RFC3986";e.exports={default:r,formatters:{RFC1738:function(e){return t.call(e,n,"+")},RFC3986:function(e){return String(e)}},RFC1738:"RFC1738",RFC3986:r}},129:(e,t,n)=>{"use strict";var r=n(8261),a=n(5235),o=n(5798);e.exports={formats:o,parse:a,stringify:r}},5235:(e,t,n)=>{"use strict";var r=n(2769),a=Object.prototype.hasOwnProperty,o=Array.isArray,l={allowDots:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decoder:r.decode,delimiter:"&",depth:5,ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},i=function(e){return e.replace(/&#(\d+);/g,(function(e,t){return String.fromCharCode(parseInt(t,10))}))},u=function(e,t){return e&&"string"==typeof e&&t.comma&&e.indexOf(",")>-1?e.split(","):e},s=function(e,t,n,r){if(e){var o=n.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,l=/(\[[^[\]]*])/g,i=n.depth>0&&/(\[[^[\]]*])/.exec(o),s=i?o.slice(0,i.index):o,c=[];if(s){if(!n.plainObjects&&a.call(Object.prototype,s)&&!n.allowPrototypes)return;c.push(s)}for(var p=0;n.depth>0&&null!==(i=l.exec(o))&&p<n.depth;){if(p+=1,!n.plainObjects&&a.call(Object.prototype,i[1].slice(1,-1))&&!n.allowPrototypes)return;c.push(i[1])}return i&&c.push("["+o.slice(i.index)+"]"),function(e,t,n,r){for(var a=r?t:u(t,n),o=e.length-1;o>=0;--o){var l,i=e[o];if("[]"===i&&n.parseArrays)l=[].concat(a);else{l=n.plainObjects?Object.create(null):{};var s="["===i.charAt(0)&&"]"===i.charAt(i.length-1)?i.slice(1,-1):i,c=parseInt(s,10);n.parseArrays||""!==s?!isNaN(c)&&i!==s&&String(c)===s&&c>=0&&n.parseArrays&&c<=n.arrayLimit?(l=[])[c]=a:"__proto__"!==s&&(l[s]=a):l={0:a}}a=l}return a}(c,t,n,r)}};e.exports=function(e,t){var n=function(e){if(!e)return l;if(null!==e.decoder&&void 0!==e.decoder&&"function"!=typeof e.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var t=void 0===e.charset?l.charset:e.charset;return{allowDots:void 0===e.allowDots?l.allowDots:!!e.allowDots,allowPrototypes:"boolean"==typeof e.allowPrototypes?e.allowPrototypes:l.allowPrototypes,allowSparse:"boolean"==typeof e.allowSparse?e.allowSparse:l.allowSparse,arrayLimit:"number"==typeof e.arrayLimit?e.arrayLimit:l.arrayLimit,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:l.charsetSentinel,comma:"boolean"==typeof e.comma?e.comma:l.comma,decoder:"function"==typeof e.decoder?e.decoder:l.decoder,delimiter:"string"==typeof e.delimiter||r.isRegExp(e.delimiter)?e.delimiter:l.delimiter,depth:"number"==typeof e.depth||!1===e.depth?+e.depth:l.depth,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof e.interpretNumericEntities?e.interpretNumericEntities:l.interpretNumericEntities,parameterLimit:"number"==typeof e.parameterLimit?e.parameterLimit:l.parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:"boolean"==typeof e.plainObjects?e.plainObjects:l.plainObjects,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:l.strictNullHandling}}(t);if(""===e||null==e)return n.plainObjects?Object.create(null):{};for(var c="string"==typeof e?function(e,t){var n,s={},c=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,p=t.parameterLimit===1/0?void 0:t.parameterLimit,d=c.split(t.delimiter,p),f=-1,h=t.charset;if(t.charsetSentinel)for(n=0;n<d.length;++n)0===d[n].indexOf("utf8=")&&("utf8=%E2%9C%93"===d[n]?h="utf-8":"utf8=%26%2310003%3B"===d[n]&&(h="iso-8859-1"),f=n,n=d.length);for(n=0;n<d.length;++n)if(n!==f){var m,g,y=d[n],v=y.indexOf("]="),b=-1===v?y.indexOf("="):v+1;-1===b?(m=t.decoder(y,l.decoder,h,"key"),g=t.strictNullHandling?null:""):(m=t.decoder(y.slice(0,b),l.decoder,h,"key"),g=r.maybeMap(u(y.slice(b+1),t),(function(e){return t.decoder(e,l.decoder,h,"value")}))),g&&t.interpretNumericEntities&&"iso-8859-1"===h&&(g=i(g)),y.indexOf("[]=")>-1&&(g=o(g)?[g]:g),a.call(s,m)?s[m]=r.combine(s[m],g):s[m]=g}return s}(e,n):e,p=n.plainObjects?Object.create(null):{},d=Object.keys(c),f=0;f<d.length;++f){var h=d[f],m=s(h,c[h],n,"string"==typeof e);p=r.merge(p,m,n)}return!0===n.allowSparse?p:r.compact(p)}},8261:(e,t,n)=>{"use strict";var r=n(7478),a=n(2769),o=n(5798),l=Object.prototype.hasOwnProperty,i={brackets:function(e){return e+"[]"},comma:"comma",indices:function(e,t){return e+"["+t+"]"},repeat:function(e){return e}},u=Array.isArray,s=String.prototype.split,c=Array.prototype.push,p=function(e,t){c.apply(e,u(t)?t:[t])},d=Date.prototype.toISOString,f=o.default,h={addQueryPrefix:!1,allowDots:!1,charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encoder:a.encode,encodeValuesOnly:!1,format:f,formatter:o.formatters[f],indices:!1,serializeDate:function(e){return d.call(e)},skipNulls:!1,strictNullHandling:!1},m={},g=function e(t,n,o,l,i,c,d,f,g,y,v,b,w,E,_,x){for(var S,k=t,C=x,D=0,O=!1;void 0!==(C=C.get(m))&&!O;){var P=C.get(t);if(D+=1,void 0!==P){if(P===D)throw new RangeError("Cyclic object value");O=!0}void 0===C.get(m)&&(D=0)}if("function"==typeof f?k=f(n,k):k instanceof Date?k=v(k):"comma"===o&&u(k)&&(k=a.maybeMap(k,(function(e){return e instanceof Date?v(e):e}))),null===k){if(i)return d&&!E?d(n,h.encoder,_,"key",b):n;k=""}if("string"==typeof(S=k)||"number"==typeof S||"boolean"==typeof S||"symbol"==typeof S||"bigint"==typeof S||a.isBuffer(k)){if(d){var T=E?n:d(n,h.encoder,_,"key",b);if("comma"===o&&E){for(var N=s.call(String(k),","),M="",R=0;R<N.length;++R)M+=(0===R?"":",")+w(d(N[R],h.encoder,_,"value",b));return[w(T)+(l&&u(k)&&1===N.length?"[]":"")+"="+M]}return[w(T)+"="+w(d(k,h.encoder,_,"value",b))]}return[w(n)+"="+w(String(k))]}var j,A=[];if(void 0===k)return A;if("comma"===o&&u(k))j=[{value:k.length>0?k.join(",")||null:void 0}];else if(u(f))j=f;else{var I=Object.keys(k);j=g?I.sort(g):I}for(var F=l&&u(k)&&1===k.length?n+"[]":n,L=0;L<j.length;++L){var U=j[L],z="object"==typeof U&&void 0!==U.value?U.value:k[U];if(!c||null!==z){var Y=u(k)?"function"==typeof o?o(F,U):F:F+(y?"."+U:"["+U+"]");x.set(t,D);var W=r();W.set(m,x),p(A,e(z,Y,o,l,i,c,d,f,g,y,v,b,w,E,_,W))}}return A};e.exports=function(e,t){var n,a=e,s=function(e){if(!e)return h;if(null!==e.encoder&&void 0!==e.encoder&&"function"!=typeof e.encoder)throw new TypeError("Encoder has to be a function.");var t=e.charset||h.charset;if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var n=o.default;if(void 0!==e.format){if(!l.call(o.formatters,e.format))throw new TypeError("Unknown format option provided.");n=e.format}var r=o.formatters[n],a=h.filter;return("function"==typeof e.filter||u(e.filter))&&(a=e.filter),{addQueryPrefix:"boolean"==typeof e.addQueryPrefix?e.addQueryPrefix:h.addQueryPrefix,allowDots:void 0===e.allowDots?h.allowDots:!!e.allowDots,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:h.charsetSentinel,delimiter:void 0===e.delimiter?h.delimiter:e.delimiter,encode:"boolean"==typeof e.encode?e.encode:h.encode,encoder:"function"==typeof e.encoder?e.encoder:h.encoder,encodeValuesOnly:"boolean"==typeof e.encodeValuesOnly?e.encodeValuesOnly:h.encodeValuesOnly,filter:a,format:n,formatter:r,serializeDate:"function"==typeof e.serializeDate?e.serializeDate:h.serializeDate,skipNulls:"boolean"==typeof e.skipNulls?e.skipNulls:h.skipNulls,sort:"function"==typeof e.sort?e.sort:null,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:h.strictNullHandling}}(t);"function"==typeof s.filter?a=(0,s.filter)("",a):u(s.filter)&&(n=s.filter);var c,d=[];if("object"!=typeof a||null===a)return"";c=t&&t.arrayFormat in i?t.arrayFormat:t&&"indices"in t?t.indices?"indices":"repeat":"indices";var f=i[c];if(t&&"commaRoundTrip"in t&&"boolean"!=typeof t.commaRoundTrip)throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var m="comma"===f&&t&&t.commaRoundTrip;n||(n=Object.keys(a)),s.sort&&n.sort(s.sort);for(var y=r(),v=0;v<n.length;++v){var b=n[v];s.skipNulls&&null===a[b]||p(d,g(a[b],b,f,m,s.strictNullHandling,s.skipNulls,s.encode?s.encoder:null,s.filter,s.sort,s.allowDots,s.serializeDate,s.format,s.formatter,s.encodeValuesOnly,s.charset,y))}var w=d.join(s.delimiter),E=!0===s.addQueryPrefix?"?":"";return s.charsetSentinel&&("iso-8859-1"===s.charset?E+="utf8=%26%2310003%3B&":E+="utf8=%E2%9C%93&"),w.length>0?E+w:""}},2769:(e,t,n)=>{"use strict";var r=n(5798),a=Object.prototype.hasOwnProperty,o=Array.isArray,l=function(){for(var e=[],t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e}(),i=function(e,t){for(var n=t&&t.plainObjects?Object.create(null):{},r=0;r<e.length;++r)void 0!==e[r]&&(n[r]=e[r]);return n};e.exports={arrayToObject:i,assign:function(e,t){return Object.keys(t).reduce((function(e,n){return e[n]=t[n],e}),e)},combine:function(e,t){return[].concat(e,t)},compact:function(e){for(var t=[{obj:{o:e},prop:"o"}],n=[],r=0;r<t.length;++r)for(var a=t[r],l=a.obj[a.prop],i=Object.keys(l),u=0;u<i.length;++u){var s=i[u],c=l[s];"object"==typeof c&&null!==c&&-1===n.indexOf(c)&&(t.push({obj:l,prop:s}),n.push(c))}return function(e){for(;e.length>1;){var t=e.pop(),n=t.obj[t.prop];if(o(n)){for(var r=[],a=0;a<n.length;++a)void 0!==n[a]&&r.push(n[a]);t.obj[t.prop]=r}}}(t),e},decode:function(e,t,n){var r=e.replace(/\+/g," ");if("iso-8859-1"===n)return r.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(r)}catch(e){return r}},encode:function(e,t,n,a,o){if(0===e.length)return e;var i=e;if("symbol"==typeof e?i=Symbol.prototype.toString.call(e):"string"!=typeof e&&(i=String(e)),"iso-8859-1"===n)return escape(i).replace(/%u[0-9a-f]{4}/gi,(function(e){return"%26%23"+parseInt(e.slice(2),16)+"%3B"}));for(var u="",s=0;s<i.length;++s){var c=i.charCodeAt(s);45===c||46===c||95===c||126===c||c>=48&&c<=57||c>=65&&c<=90||c>=97&&c<=122||o===r.RFC1738&&(40===c||41===c)?u+=i.charAt(s):c<128?u+=l[c]:c<2048?u+=l[192|c>>6]+l[128|63&c]:c<55296||c>=57344?u+=l[224|c>>12]+l[128|c>>6&63]+l[128|63&c]:(s+=1,c=65536+((1023&c)<<10|1023&i.charCodeAt(s)),u+=l[240|c>>18]+l[128|c>>12&63]+l[128|c>>6&63]+l[128|63&c])}return u},isBuffer:function(e){return!(!e||"object"!=typeof e||!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e)))},isRegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},maybeMap:function(e,t){if(o(e)){for(var n=[],r=0;r<e.length;r+=1)n.push(t(e[r]));return n}return t(e)},merge:function e(t,n,r){if(!n)return t;if("object"!=typeof n){if(o(t))t.push(n);else{if(!t||"object"!=typeof t)return[t,n];(r&&(r.plainObjects||r.allowPrototypes)||!a.call(Object.prototype,n))&&(t[n]=!0)}return t}if(!t||"object"!=typeof t)return[t].concat(n);var l=t;return o(t)&&!o(n)&&(l=i(t,r)),o(t)&&o(n)?(n.forEach((function(n,o){if(a.call(t,o)){var l=t[o];l&&"object"==typeof l&&n&&"object"==typeof n?t[o]=e(l,n,r):t.push(n)}else t[o]=n})),t):Object.keys(n).reduce((function(t,o){var l=n[o];return a.call(t,o)?t[o]=e(t[o],l,r):t[o]=l,t}),l)}}},4300:(e,t,n)=>{"use strict";function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.CopyToClipboard=void 0;var a=i(n(7294)),o=i(n(640)),l=["text","onCopy","options","children"];function i(e){return e&&e.__esModule?e:{default:e}}function u(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function s(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?u(Object(n),!0).forEach((function(t){g(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):u(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function c(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function p(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function d(e,t){return d=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},d(e,t)}function f(e,t){if(t&&("object"===r(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return h(e)}function h(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function m(e){return m=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},m(e)}function g(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var y=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&d(e,t)}(y,e);var t,n,r,i,u=(r=y,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=m(r);if(i){var n=m(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return f(this,e)});function y(){var e;c(this,y);for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return g(h(e=u.call.apply(u,[this].concat(n))),"onClick",(function(t){var n=e.props,r=n.text,l=n.onCopy,i=n.children,u=n.options,s=a.default.Children.only(i),c=(0,o.default)(r,u);l&&l(r,c),s&&s.props&&"function"==typeof s.props.onClick&&s.props.onClick(t)})),e}return t=y,(n=[{key:"render",value:function(){var e=this.props,t=(e.text,e.onCopy,e.options,e.children),n=function(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n,r,a={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}(e,l),r=a.default.Children.only(t);return a.default.cloneElement(r,s(s({},n),{},{onClick:this.onClick}))}}])&&p(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),y}(a.default.PureComponent);t.CopyToClipboard=y,g(y,"defaultProps",{onCopy:void 0,options:void 0})},4855:(e,t,n)=>{"use strict";var r=n(4300).CopyToClipboard;r.CopyToClipboard=r,e.exports=r},9198:function(e,t,n){!function(e,t,n,r,a,o,l,i,u,s,c,p,d,f,h,m,g,y,v,b,w,E,_,x,S,k,C,D,O,P,T,N,M,R,j,A,I,F,L,U,z,Y,W,B,H,q,V,$,Z,Q,K,G,X,J,ee,te,ne,re,ae,oe,le,ie,ue){"use strict";function se(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var ce=se(t),pe=se(r),de=se(a),fe=se(o),he=se(l),me=se(i),ge=se(u),ye=se(s),ve=se(c),be=se(p),we=se(d),Ee=se(m),_e=se(g),xe=se(y),Se=se(v),ke=se(b),Ce=se(w),De=se(E),Oe=se(_),Pe=se(x),Te=se(S),Ne=se(k),Me=se(C),Re=se(D),je=se(O),Ae=se(P),Ie=se(T),Fe=se(N),Le=se(M),Ue=se(R),ze=se(j),Ye=se(A),We=se(I),Be=se(F),He=se(L),qe=se(z),Ve=se(Y),$e=se(W),Ze=se(B),Qe=se(H),Ke=se(q),Ge=se(V),Xe=se(Q),Je=se(K),et=se(G),tt=se(X),nt=se(J),rt=se(ee),at=se(te),ot=se(ne),lt=se(re),it=se(ae),ut=se(oe),st=se(le),ct=se(ie);function pt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function dt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?pt(Object(n),!0).forEach((function(t){yt(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):pt(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function ft(e){return(ft="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ht(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function mt(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function gt(e,t,n){return t&&mt(e.prototype,t),n&&mt(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function yt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function vt(){return(vt=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function bt(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");Object.defineProperty(e,"prototype",{value:Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),writable:!1}),t&&Et(e,t)}function wt(e){return(wt=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function Et(e,t){return(Et=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function _t(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function xt(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return _t(e)}function St(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=wt(e);if(t){var a=wt(this).constructor;n=Reflect.construct(r,arguments,a)}else n=r.apply(this,arguments);return xt(this,n)}}function kt(e){return function(e){if(Array.isArray(e))return Ct(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return Ct(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ct(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ct(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Dt(e,t){switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});default:return t.date({width:"full"})}}function Ot(e,t){switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});default:return t.time({width:"full"})}}var Pt={p:Ot,P:function(e,t){var n,r=e.match(/(P+)(p+)?/)||[],a=r[1],o=r[2];if(!o)return Dt(e,t);switch(a){case"P":n=t.dateTime({width:"short"});break;case"PP":n=t.dateTime({width:"medium"});break;case"PPP":n=t.dateTime({width:"long"});break;default:n=t.dateTime({width:"full"})}return n.replace("{{date}}",Dt(a,t)).replace("{{time}}",Ot(o,t))}},Tt=12,Nt=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;function Mt(e){var t=e?"string"==typeof e||e instanceof String?ut.default(e):lt.default(e):new Date;return jt(t)?t:null}function Rt(e,t,n,r,a){var o=null,l=Xt(n)||Xt(Gt()),i=!0;return Array.isArray(t)?(t.forEach((function(t){var u=it.default(e,t,new Date,{locale:l});r&&(i=jt(u,a)&&e===At(u,t,n)),jt(u,a)&&i&&(o=u)})),o):(o=it.default(e,t,new Date,{locale:l}),r?i=jt(o)&&e===At(o,t,n):jt(o)||(t=t.match(Nt).map((function(e){var t=e[0];return"p"===t||"P"===t?l?(0,Pt[t])(e,l.formatLong):t:e})).join(""),e.length>0&&(o=it.default(e,t.slice(0,e.length),new Date)),jt(o)||(o=new Date(e))),jt(o)&&i?o:null)}function jt(e,t){return t=t||new Date("1/1/1000"),fe.default(e)&&!at.default(e,t)}function At(e,t,n){if("en"===n)return he.default(e,t,{awareOfUnicodeTokens:!0});var r=Xt(n);return n&&!r&&console.warn('A locale object was not found for the provided string ["'.concat(n,'"].')),!r&&Gt()&&Xt(Gt())&&(r=Xt(Gt())),he.default(e,t,{locale:r||null,awareOfUnicodeTokens:!0})}function It(e,t){var n=t.dateFormat,r=t.locale;return e&&At(e,Array.isArray(n)?n[0]:n,r)||""}function Ft(e,t){var n=t.hour,r=void 0===n?0:n,a=t.minute,o=void 0===a?0:a,l=t.second,i=void 0===l?0:l;return Fe.default(Ie.default(Ae.default(e,i),o),r)}function Lt(e,t){var n=t&&Xt(t)||Gt()&&Xt(Gt());return Te.default(e,n?{locale:n}:null)}function Ut(e,t){return At(e,"ddd",t)}function zt(e){return Ve.default(e)}function Yt(e,t,n){var r=Xt(t||Gt());return $e.default(e,{locale:r,weekStartsOn:n})}function Wt(e){return Ze.default(e)}function Bt(e){return Ke.default(e)}function Ht(e){return Qe.default(e)}function qt(e,t){return e&&t?tt.default(e,t):!e&&!t}function Vt(e,t){return e&&t?et.default(e,t):!e&&!t}function $t(e,t){return e&&t?nt.default(e,t):!e&&!t}function Zt(e,t){return e&&t?Je.default(e,t):!e&&!t}function Qt(e,t){return e&&t?Xe.default(e,t):!e&&!t}function Kt(e,t,n){var r,a=Ve.default(t),o=Ge.default(n);try{r=ot.default(e,{start:a,end:o})}catch(e){r=!1}return r}function Gt(){return("undefined"!=typeof window?window:globalThis).__localeId__}function Xt(e){if("string"==typeof e){var t="undefined"!=typeof window?window:globalThis;return t.__localeData__?t.__localeData__[e]:null}return e}function Jt(e,t){return At(Le.default(Mt(),e),"LLLL",t)}function en(e,t){return At(Le.default(Mt(),e),"LLL",t)}function tn(e,t){return At(Ue.default(Mt(),e),"QQQ",t)}function nn(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.minDate,r=t.maxDate,a=t.excludeDates,o=t.excludeDateIntervals,l=t.includeDates,i=t.includeDateIntervals,u=t.filterDate;return cn(e,{minDate:n,maxDate:r})||a&&a.some((function(t){return Zt(e,t)}))||o&&o.some((function(t){var n=t.start,r=t.end;return ot.default(e,{start:n,end:r})}))||l&&!l.some((function(t){return Zt(e,t)}))||i&&!i.some((function(t){var n=t.start,r=t.end;return ot.default(e,{start:n,end:r})}))||u&&!u(Mt(e))||!1}function rn(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.excludeDates,r=t.excludeDateIntervals;return r&&r.length>0?r.some((function(t){var n=t.start,r=t.end;return ot.default(e,{start:n,end:r})})):n&&n.some((function(t){return Zt(e,t)}))||!1}function an(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.minDate,r=t.maxDate,a=t.excludeDates,o=t.includeDates,l=t.filterDate;return cn(e,{minDate:n,maxDate:r})||a&&a.some((function(t){return Vt(e,t)}))||o&&!o.some((function(t){return Vt(e,t)}))||l&&!l(Mt(e))||!1}function on(e,t,n,r){var a=Re.default(e),o=Ne.default(e),l=Re.default(t),i=Ne.default(t),u=Re.default(r);return a===l&&a===u?o<=n&&n<=i:a<l?u===a&&o<=n||u===l&&i>=n||u<l&&u>a:void 0}function ln(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.minDate,r=t.maxDate,a=t.excludeDates,o=t.includeDates,l=t.filterDate;return cn(e,{minDate:n,maxDate:r})||a&&a.some((function(t){return $t(e,t)}))||o&&!o.some((function(t){return $t(e,t)}))||l&&!l(Mt(e))||!1}function un(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.minDate,r=t.maxDate;return cn(new Date(e,0,1),{minDate:n,maxDate:r})||!1}function sn(e,t,n,r){var a=Re.default(e),o=Me.default(e),l=Re.default(t),i=Me.default(t),u=Re.default(r);return a===l&&a===u?o<=n&&n<=i:a<l?u===a&&o<=n||u===l&&i>=n||u<l&&u>a:void 0}function cn(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.minDate,r=t.maxDate;return n&&Be.default(e,n)<0||r&&Be.default(e,r)>0}function pn(e,t){return t.some((function(t){return De.default(t)===De.default(e)&&Ce.default(t)===Ce.default(e)}))}function dn(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.excludeTimes,r=t.includeTimes,a=t.filterTime;return n&&pn(e,n)||r&&!pn(e,r)||a&&!a(e)||!1}function fn(e,t){var n=t.minTime,r=t.maxTime;if(!n||!r)throw new Error("Both minTime and maxTime props required");var a,o=Mt(),l=Fe.default(Ie.default(o,Ce.default(e)),De.default(e)),i=Fe.default(Ie.default(o,Ce.default(n)),De.default(n)),u=Fe.default(Ie.default(o,Ce.default(r)),De.default(r));try{a=!ot.default(l,{start:i,end:u})}catch(e){a=!1}return a}function hn(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.minDate,r=t.includeDates,a=xe.default(e,1);return n&&He.default(n,a)>0||r&&r.every((function(e){return He.default(e,a)>0}))||!1}function mn(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.maxDate,r=t.includeDates,a=be.default(e,1);return n&&He.default(a,n)>0||r&&r.every((function(e){return He.default(a,e)>0}))||!1}function gn(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.minDate,r=t.includeDates,a=Se.default(e,1);return n&&qe.default(n,a)>0||r&&r.every((function(e){return qe.default(e,a)>0}))||!1}function yn(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.maxDate,r=t.includeDates,a=we.default(e,1);return n&&qe.default(a,n)>0||r&&r.every((function(e){return qe.default(a,e)>0}))||!1}function vn(e){var t=e.minDate,n=e.includeDates;if(n&&t){var r=n.filter((function(e){return Be.default(e,t)>=0}));return Ye.default(r)}return n?Ye.default(n):t}function bn(e){var t=e.maxDate,n=e.includeDates;if(n&&t){var r=n.filter((function(e){return Be.default(e,t)<=0}));return We.default(r)}return n?We.default(n):t}function wn(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"react-datepicker__day--highlighted",n=new Map,r=0,a=e.length;r<a;r++){var o=e[r];if(de.default(o)){var l=At(o,"MM.dd.yyyy"),i=n.get(l)||[];i.includes(t)||(i.push(t),n.set(l,i))}else if("object"===ft(o)){var u=Object.keys(o),s=u[0],c=o[u[0]];if("string"==typeof s&&c.constructor===Array)for(var p=0,d=c.length;p<d;p++){var f=At(c[p],"MM.dd.yyyy"),h=n.get(f)||[];h.includes(s)||(h.push(s),n.set(f,h))}}}return n}function En(e,t,n,r,a){for(var o=a.length,l=[],i=0;i<o;i++){var u=me.default(ge.default(e,De.default(a[i])),Ce.default(a[i])),s=me.default(e,(n+1)*r);rt.default(u,t)&&at.default(u,s)&&l.push(a[i])}return l}function xn(e){return e<10?"0".concat(e):"".concat(e)}function Sn(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Tt,n=Math.ceil(Re.default(e)/t)*t;return{startPeriod:n-(t-1),endPeriod:n}}function kn(e,t,n,r){for(var a=[],o=0;o<2*t+1;o++){var l=e+t-o,i=!0;n&&(i=Re.default(n)<=l),r&&i&&(i=Re.default(r)>=l),i&&a.push(l)}return a}var Cn=function(e){bt(r,e);var n=St(r);function r(e){var a;ht(this,r),yt(_t(a=n.call(this,e)),"renderOptions",(function(){var e=a.props.year,t=a.state.yearsList.map((function(t){return ce.default.createElement("div",{className:e===t?"react-datepicker__year-option react-datepicker__year-option--selected_year":"react-datepicker__year-option",key:t,onClick:a.onChange.bind(_t(a),t),"aria-selected":e===t?"true":void 0},e===t?ce.default.createElement("span",{className:"react-datepicker__year-option--selected"},"✓"):"",t)})),n=a.props.minDate?Re.default(a.props.minDate):null,r=a.props.maxDate?Re.default(a.props.maxDate):null;return r&&a.state.yearsList.find((function(e){return e===r}))||t.unshift(ce.default.createElement("div",{className:"react-datepicker__year-option",key:"upcoming",onClick:a.incrementYears},ce.default.createElement("a",{className:"react-datepicker__navigation react-datepicker__navigation--years react-datepicker__navigation--years-upcoming"}))),n&&a.state.yearsList.find((function(e){return e===n}))||t.push(ce.default.createElement("div",{className:"react-datepicker__year-option",key:"previous",onClick:a.decrementYears},ce.default.createElement("a",{className:"react-datepicker__navigation react-datepicker__navigation--years react-datepicker__navigation--years-previous"}))),t})),yt(_t(a),"onChange",(function(e){a.props.onChange(e)})),yt(_t(a),"handleClickOutside",(function(){a.props.onCancel()})),yt(_t(a),"shiftYears",(function(e){var t=a.state.yearsList.map((function(t){return t+e}));a.setState({yearsList:t})})),yt(_t(a),"incrementYears",(function(){return a.shiftYears(1)})),yt(_t(a),"decrementYears",(function(){return a.shiftYears(-1)}));var o=e.yearDropdownItemNumber,l=e.scrollableYearDropdown,i=o||(l?10:5);return a.state={yearsList:kn(a.props.year,i,a.props.minDate,a.props.maxDate)},a.dropdownRef=t.createRef(),a}return gt(r,[{key:"componentDidMount",value:function(){var e=this.dropdownRef.current;e&&(e.scrollTop=e.scrollHeight/2-e.clientHeight/2)}},{key:"render",value:function(){var e=pe.default({"react-datepicker__year-dropdown":!0,"react-datepicker__year-dropdown--scrollable":this.props.scrollableYearDropdown});return ce.default.createElement("div",{className:e,ref:this.dropdownRef},this.renderOptions())}}]),r}(ce.default.Component),Dn=st.default(Cn),On=function(e){bt(n,e);var t=St(n);function n(){var e;ht(this,n);for(var r=arguments.length,a=new Array(r),o=0;o<r;o++)a[o]=arguments[o];return yt(_t(e=t.call.apply(t,[this].concat(a))),"state",{dropdownVisible:!1}),yt(_t(e),"renderSelectOptions",(function(){for(var t=e.props.minDate?Re.default(e.props.minDate):1900,n=e.props.maxDate?Re.default(e.props.maxDate):2100,r=[],a=t;a<=n;a++)r.push(ce.default.createElement("option",{key:a,value:a},a));return r})),yt(_t(e),"onSelectChange",(function(t){e.onChange(t.target.value)})),yt(_t(e),"renderSelectMode",(function(){return ce.default.createElement("select",{value:e.props.year,className:"react-datepicker__year-select",onChange:e.onSelectChange},e.renderSelectOptions())})),yt(_t(e),"renderReadView",(function(t){return ce.default.createElement("div",{key:"read",style:{visibility:t?"visible":"hidden"},className:"react-datepicker__year-read-view",onClick:function(t){return e.toggleDropdown(t)}},ce.default.createElement("span",{className:"react-datepicker__year-read-view--down-arrow"}),ce.default.createElement("span",{className:"react-datepicker__year-read-view--selected-year"},e.props.year))})),yt(_t(e),"renderDropdown",(function(){return ce.default.createElement(Dn,{key:"dropdown",year:e.props.year,onChange:e.onChange,onCancel:e.toggleDropdown,minDate:e.props.minDate,maxDate:e.props.maxDate,scrollableYearDropdown:e.props.scrollableYearDropdown,yearDropdownItemNumber:e.props.yearDropdownItemNumber})})),yt(_t(e),"renderScrollMode",(function(){var t=e.state.dropdownVisible,n=[e.renderReadView(!t)];return t&&n.unshift(e.renderDropdown()),n})),yt(_t(e),"onChange",(function(t){e.toggleDropdown(),t!==e.props.year&&e.props.onChange(t)})),yt(_t(e),"toggleDropdown",(function(t){e.setState({dropdownVisible:!e.state.dropdownVisible},(function(){e.props.adjustDateOnChange&&e.handleYearChange(e.props.date,t)}))})),yt(_t(e),"handleYearChange",(function(t,n){e.onSelect(t,n),e.setOpen()})),yt(_t(e),"onSelect",(function(t,n){e.props.onSelect&&e.props.onSelect(t,n)})),yt(_t(e),"setOpen",(function(){e.props.setOpen&&e.props.setOpen(!0)})),e}return gt(n,[{key:"render",value:function(){var e;switch(this.props.dropdownMode){case"scroll":e=this.renderScrollMode();break;case"select":e=this.renderSelectMode()}return ce.default.createElement("div",{className:"react-datepicker__year-dropdown-container react-datepicker__year-dropdown-container--".concat(this.props.dropdownMode)},e)}}]),n}(ce.default.Component),Pn=function(e){bt(n,e);var t=St(n);function n(){var e;ht(this,n);for(var r=arguments.length,a=new Array(r),o=0;o<r;o++)a[o]=arguments[o];return yt(_t(e=t.call.apply(t,[this].concat(a))),"isSelectedMonth",(function(t){return e.props.month===t})),yt(_t(e),"renderOptions",(function(){return e.props.monthNames.map((function(t,n){return ce.default.createElement("div",{className:e.isSelectedMonth(n)?"react-datepicker__month-option react-datepicker__month-option--selected_month":"react-datepicker__month-option",key:t,onClick:e.onChange.bind(_t(e),n),"aria-selected":e.isSelectedMonth(n)?"true":void 0},e.isSelectedMonth(n)?ce.default.createElement("span",{className:"react-datepicker__month-option--selected"},"✓"):"",t)}))})),yt(_t(e),"onChange",(function(t){return e.props.onChange(t)})),yt(_t(e),"handleClickOutside",(function(){return e.props.onCancel()})),e}return gt(n,[{key:"render",value:function(){return ce.default.createElement("div",{className:"react-datepicker__month-dropdown"},this.renderOptions())}}]),n}(ce.default.Component),Tn=st.default(Pn),Nn=function(e){bt(n,e);var t=St(n);function n(){var e;ht(this,n);for(var r=arguments.length,a=new Array(r),o=0;o<r;o++)a[o]=arguments[o];return yt(_t(e=t.call.apply(t,[this].concat(a))),"state",{dropdownVisible:!1}),yt(_t(e),"renderSelectOptions",(function(e){return e.map((function(e,t){return ce.default.createElement("option",{key:t,value:t},e)}))})),yt(_t(e),"renderSelectMode",(function(t){return ce.default.createElement("select",{value:e.props.month,className:"react-datepicker__month-select",onChange:function(t){return e.onChange(t.target.value)}},e.renderSelectOptions(t))})),yt(_t(e),"renderReadView",(function(t,n){return ce.default.createElement("div",{key:"read",style:{visibility:t?"visible":"hidden"},className:"react-datepicker__month-read-view",onClick:e.toggleDropdown},ce.default.createElement("span",{className:"react-datepicker__month-read-view--down-arrow"}),ce.default.createElement("span",{className:"react-datepicker__month-read-view--selected-month"},n[e.props.month]))})),yt(_t(e),"renderDropdown",(function(t){return ce.default.createElement(Tn,{key:"dropdown",month:e.props.month,monthNames:t,onChange:e.onChange,onCancel:e.toggleDropdown})})),yt(_t(e),"renderScrollMode",(function(t){var n=e.state.dropdownVisible,r=[e.renderReadView(!n,t)];return n&&r.unshift(e.renderDropdown(t)),r})),yt(_t(e),"onChange",(function(t){e.toggleDropdown(),t!==e.props.month&&e.props.onChange(t)})),yt(_t(e),"toggleDropdown",(function(){return e.setState({dropdownVisible:!e.state.dropdownVisible})})),e}return gt(n,[{key:"render",value:function(){var e,t=this,n=[0,1,2,3,4,5,6,7,8,9,10,11].map(this.props.useShortMonthInDropdown?function(e){return en(e,t.props.locale)}:function(e){return Jt(e,t.props.locale)});switch(this.props.dropdownMode){case"scroll":e=this.renderScrollMode(n);break;case"select":e=this.renderSelectMode(n)}return ce.default.createElement("div",{className:"react-datepicker__month-dropdown-container react-datepicker__month-dropdown-container--".concat(this.props.dropdownMode)},e)}}]),n}(ce.default.Component);function Mn(e,t){for(var n=[],r=Wt(e),a=Wt(t);!rt.default(r,a);)n.push(Mt(r)),r=be.default(r,1);return n}var Rn=function(e){bt(n,e);var t=St(n);function n(e){var r;return ht(this,n),yt(_t(r=t.call(this,e)),"renderOptions",(function(){return r.state.monthYearsList.map((function(e){var t=je.default(e),n=qt(r.props.date,e)&&Vt(r.props.date,e);return ce.default.createElement("div",{className:n?"react-datepicker__month-year-option--selected_month-year":"react-datepicker__month-year-option",key:t,onClick:r.onChange.bind(_t(r),t),"aria-selected":n?"true":void 0},n?ce.default.createElement("span",{className:"react-datepicker__month-year-option--selected"},"✓"):"",At(e,r.props.dateFormat,r.props.locale))}))})),yt(_t(r),"onChange",(function(e){return r.props.onChange(e)})),yt(_t(r),"handleClickOutside",(function(){r.props.onCancel()})),r.state={monthYearsList:Mn(r.props.minDate,r.props.maxDate)},r}return gt(n,[{key:"render",value:function(){var e=pe.default({"react-datepicker__month-year-dropdown":!0,"react-datepicker__month-year-dropdown--scrollable":this.props.scrollableMonthYearDropdown});return ce.default.createElement("div",{className:e},this.renderOptions())}}]),n}(ce.default.Component),jn=st.default(Rn),An=function(e){bt(n,e);var t=St(n);function n(){var e;ht(this,n);for(var r=arguments.length,a=new Array(r),o=0;o<r;o++)a[o]=arguments[o];return yt(_t(e=t.call.apply(t,[this].concat(a))),"state",{dropdownVisible:!1}),yt(_t(e),"renderSelectOptions",(function(){for(var t=Wt(e.props.minDate),n=Wt(e.props.maxDate),r=[];!rt.default(t,n);){var a=je.default(t);r.push(ce.default.createElement("option",{key:a,value:a},At(t,e.props.dateFormat,e.props.locale))),t=be.default(t,1)}return r})),yt(_t(e),"onSelectChange",(function(t){e.onChange(t.target.value)})),yt(_t(e),"renderSelectMode",(function(){return ce.default.createElement("select",{value:je.default(Wt(e.props.date)),className:"react-datepicker__month-year-select",onChange:e.onSelectChange},e.renderSelectOptions())})),yt(_t(e),"renderReadView",(function(t){var n=At(e.props.date,e.props.dateFormat,e.props.locale);return ce.default.createElement("div",{key:"read",style:{visibility:t?"visible":"hidden"},className:"react-datepicker__month-year-read-view",onClick:function(t){return e.toggleDropdown(t)}},ce.default.createElement("span",{className:"react-datepicker__month-year-read-view--down-arrow"}),ce.default.createElement("span",{className:"react-datepicker__month-year-read-view--selected-month-year"},n))})),yt(_t(e),"renderDropdown",(function(){return ce.default.createElement(jn,{key:"dropdown",date:e.props.date,dateFormat:e.props.dateFormat,onChange:e.onChange,onCancel:e.toggleDropdown,minDate:e.props.minDate,maxDate:e.props.maxDate,scrollableMonthYearDropdown:e.props.scrollableMonthYearDropdown,locale:e.props.locale})})),yt(_t(e),"renderScrollMode",(function(){var t=e.state.dropdownVisible,n=[e.renderReadView(!t)];return t&&n.unshift(e.renderDropdown()),n})),yt(_t(e),"onChange",(function(t){e.toggleDropdown();var n=Mt(parseInt(t));qt(e.props.date,n)&&Vt(e.props.date,n)||e.props.onChange(n)})),yt(_t(e),"toggleDropdown",(function(){return e.setState({dropdownVisible:!e.state.dropdownVisible})})),e}return gt(n,[{key:"render",value:function(){var e;switch(this.props.dropdownMode){case"scroll":e=this.renderScrollMode();break;case"select":e=this.renderSelectMode()}return ce.default.createElement("div",{className:"react-datepicker__month-year-dropdown-container react-datepicker__month-year-dropdown-container--".concat(this.props.dropdownMode)},e)}}]),n}(ce.default.Component),In=function(e){bt(n,e);var t=St(n);function n(){var e;ht(this,n);for(var r=arguments.length,a=new Array(r),o=0;o<r;o++)a[o]=arguments[o];return yt(_t(e=t.call.apply(t,[this].concat(a))),"dayEl",ce.default.createRef()),yt(_t(e),"handleClick",(function(t){!e.isDisabled()&&e.props.onClick&&e.props.onClick(t)})),yt(_t(e),"handleMouseEnter",(function(t){!e.isDisabled()&&e.props.onMouseEnter&&e.props.onMouseEnter(t)})),yt(_t(e),"handleOnKeyDown",(function(t){" "===t.key&&(t.preventDefault(),t.key="Enter"),e.props.handleOnKeyDown(t)})),yt(_t(e),"isSameDay",(function(t){return Zt(e.props.day,t)})),yt(_t(e),"isKeyboardSelected",(function(){return!e.props.disabledKeyboardNavigation&&!e.isSameDay(e.props.selected)&&e.isSameDay(e.props.preSelection)})),yt(_t(e),"isDisabled",(function(){return nn(e.props.day,e.props)})),yt(_t(e),"isExcluded",(function(){return rn(e.props.day,e.props)})),yt(_t(e),"getHighLightedClass",(function(t){var n=e.props,r=n.day,a=n.highlightDates;if(!a)return!1;var o=At(r,"MM.dd.yyyy");return a.get(o)})),yt(_t(e),"isInRange",(function(){var t=e.props,n=t.day,r=t.startDate,a=t.endDate;return!(!r||!a)&&Kt(n,r,a)})),yt(_t(e),"isInSelectingRange",(function(){var t,n=e.props,r=n.day,a=n.selectsStart,o=n.selectsEnd,l=n.selectsRange,i=n.selectsDisabledDaysInRange,u=n.startDate,s=n.endDate,c=null!==(t=e.props.selectingDate)&&void 0!==t?t:e.props.preSelection;return!(!(a||o||l)||!c||!i&&e.isDisabled())&&(a&&s&&(at.default(c,s)||Qt(c,s))?Kt(r,c,s):(o&&u&&(rt.default(c,u)||Qt(c,u))||!(!l||!u||s||!rt.default(c,u)&&!Qt(c,u)))&&Kt(r,u,c))})),yt(_t(e),"isSelectingRangeStart",(function(){var t;if(!e.isInSelectingRange())return!1;var n=e.props,r=n.day,a=n.startDate,o=n.selectsStart,l=null!==(t=e.props.selectingDate)&&void 0!==t?t:e.props.preSelection;return Zt(r,o?l:a)})),yt(_t(e),"isSelectingRangeEnd",(function(){var t;if(!e.isInSelectingRange())return!1;var n=e.props,r=n.day,a=n.endDate,o=n.selectsEnd,l=null!==(t=e.props.selectingDate)&&void 0!==t?t:e.props.preSelection;return Zt(r,o?l:a)})),yt(_t(e),"isRangeStart",(function(){var t=e.props,n=t.day,r=t.startDate,a=t.endDate;return!(!r||!a)&&Zt(r,n)})),yt(_t(e),"isRangeEnd",(function(){var t=e.props,n=t.day,r=t.startDate,a=t.endDate;return!(!r||!a)&&Zt(a,n)})),yt(_t(e),"isWeekend",(function(){var t=Oe.default(e.props.day);return 0===t||6===t})),yt(_t(e),"isAfterMonth",(function(){return void 0!==e.props.month&&(e.props.month+1)%12===Ne.default(e.props.day)})),yt(_t(e),"isBeforeMonth",(function(){return void 0!==e.props.month&&(Ne.default(e.props.day)+1)%12===e.props.month})),yt(_t(e),"isCurrentDay",(function(){return e.isSameDay(Mt())})),yt(_t(e),"isSelected",(function(){return e.isSameDay(e.props.selected)})),yt(_t(e),"getClassNames",(function(t){var n=e.props.dayClassName?e.props.dayClassName(t):void 0;return pe.default("react-datepicker__day",n,"react-datepicker__day--"+Ut(e.props.day),{"react-datepicker__day--disabled":e.isDisabled(),"react-datepicker__day--excluded":e.isExcluded(),"react-datepicker__day--selected":e.isSelected(),"react-datepicker__day--keyboard-selected":e.isKeyboardSelected(),"react-datepicker__day--range-start":e.isRangeStart(),"react-datepicker__day--range-end":e.isRangeEnd(),"react-datepicker__day--in-range":e.isInRange(),"react-datepicker__day--in-selecting-range":e.isInSelectingRange(),"react-datepicker__day--selecting-range-start":e.isSelectingRangeStart(),"react-datepicker__day--selecting-range-end":e.isSelectingRangeEnd(),"react-datepicker__day--today":e.isCurrentDay(),"react-datepicker__day--weekend":e.isWeekend(),"react-datepicker__day--outside-month":e.isAfterMonth()||e.isBeforeMonth()},e.getHighLightedClass("react-datepicker__day--highlighted"))})),yt(_t(e),"getAriaLabel",(function(){var t=e.props,n=t.day,r=t.ariaLabelPrefixWhenEnabled,a=void 0===r?"Choose":r,o=t.ariaLabelPrefixWhenDisabled,l=void 0===o?"Not available":o,i=e.isDisabled()||e.isExcluded()?l:a;return"".concat(i," ").concat(At(n,"PPPP",e.props.locale))})),yt(_t(e),"getTabIndex",(function(t,n){var r=t||e.props.selected,a=n||e.props.preSelection;return e.isKeyboardSelected()||e.isSameDay(r)&&Zt(a,r)?0:-1})),yt(_t(e),"handleFocusDay",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=!1;0===e.getTabIndex()&&!t.isInputFocused&&e.isSameDay(e.props.preSelection)&&(document.activeElement&&document.activeElement!==document.body||(n=!0),e.props.inline&&!e.props.shouldFocusDayInline&&(n=!1),e.props.containerRef&&e.props.containerRef.current&&e.props.containerRef.current.contains(document.activeElement)&&document.activeElement.classList.contains("react-datepicker__day")&&(n=!0)),n&&e.dayEl.current.focus({preventScroll:!0})})),yt(_t(e),"renderDayContents",(function(){return e.props.monthShowsDuplicateDaysEnd&&e.isAfterMonth()||e.props.monthShowsDuplicateDaysStart&&e.isBeforeMonth()?null:e.props.renderDayContents?e.props.renderDayContents(Pe.default(e.props.day),e.props.day):Pe.default(e.props.day)})),yt(_t(e),"render",(function(){return ce.default.createElement("div",{ref:e.dayEl,className:e.getClassNames(e.props.day),onKeyDown:e.handleOnKeyDown,onClick:e.handleClick,onMouseEnter:e.handleMouseEnter,tabIndex:e.getTabIndex(),"aria-label":e.getAriaLabel(),role:"option","aria-disabled":e.isDisabled(),"aria-current":e.isCurrentDay()?"date":void 0,"aria-selected":e.isSelected()},e.renderDayContents())})),e}return gt(n,[{key:"componentDidMount",value:function(){this.handleFocusDay()}},{key:"componentDidUpdate",value:function(e){this.handleFocusDay(e)}}]),n}(ce.default.Component),Fn=function(e){bt(n,e);var t=St(n);function n(){var e;ht(this,n);for(var r=arguments.length,a=new Array(r),o=0;o<r;o++)a[o]=arguments[o];return yt(_t(e=t.call.apply(t,[this].concat(a))),"handleClick",(function(t){e.props.onClick&&e.props.onClick(t)})),e}return gt(n,[{key:"render",value:function(){var e=this.props,t=e.weekNumber,n=e.ariaLabelPrefix,r=void 0===n?"week ":n,a={"react-datepicker__week-number":!0,"react-datepicker__week-number--clickable":!!e.onClick};return ce.default.createElement("div",{className:pe.default(a),"aria-label":"".concat(r," ").concat(this.props.weekNumber),onClick:this.handleClick},t)}}]),n}(ce.default.Component),Ln=function(e){bt(n,e);var t=St(n);function n(){var e;ht(this,n);for(var r=arguments.length,a=new Array(r),o=0;o<r;o++)a[o]=arguments[o];return yt(_t(e=t.call.apply(t,[this].concat(a))),"handleDayClick",(function(t,n){e.props.onDayClick&&e.props.onDayClick(t,n)})),yt(_t(e),"handleDayMouseEnter",(function(t){e.props.onDayMouseEnter&&e.props.onDayMouseEnter(t)})),yt(_t(e),"handleWeekClick",(function(t,n,r){"function"==typeof e.props.onWeekSelect&&e.props.onWeekSelect(t,n,r),e.props.shouldCloseOnSelect&&e.props.setOpen(!1)})),yt(_t(e),"formatWeekNumber",(function(t){return e.props.formatWeekNumber?e.props.formatWeekNumber(t):Lt(t)})),yt(_t(e),"renderDays",(function(){var t=Yt(e.props.day,e.props.locale,e.props.calendarStartDay),n=[],r=e.formatWeekNumber(t);if(e.props.showWeekNumber){var a=e.props.onWeekSelect?e.handleWeekClick.bind(_t(e),t,r):void 0;n.push(ce.default.createElement(Fn,{key:"W",weekNumber:r,onClick:a,ariaLabelPrefix:e.props.ariaLabelPrefix}))}return n.concat([0,1,2,3,4,5,6].map((function(n){var r=ye.default(t,n);return ce.default.createElement(In,{ariaLabelPrefixWhenEnabled:e.props.chooseDayAriaLabelPrefix,ariaLabelPrefixWhenDisabled:e.props.disabledDayAriaLabelPrefix,key:r.valueOf(),day:r,month:e.props.month,onClick:e.handleDayClick.bind(_t(e),r),onMouseEnter:e.handleDayMouseEnter.bind(_t(e),r),minDate:e.props.minDate,maxDate:e.props.maxDate,excludeDates:e.props.excludeDates,excludeDateIntervals:e.props.excludeDateIntervals,includeDates:e.props.includeDates,includeDateIntervals:e.props.includeDateIntervals,highlightDates:e.props.highlightDates,selectingDate:e.props.selectingDate,filterDate:e.props.filterDate,preSelection:e.props.preSelection,selected:e.props.selected,selectsStart:e.props.selectsStart,selectsEnd:e.props.selectsEnd,selectsRange:e.props.selectsRange,selectsDisabledDaysInRange:e.props.selectsDisabledDaysInRange,startDate:e.props.startDate,endDate:e.props.endDate,dayClassName:e.props.dayClassName,renderDayContents:e.props.renderDayContents,disabledKeyboardNavigation:e.props.disabledKeyboardNavigation,handleOnKeyDown:e.props.handleOnKeyDown,isInputFocused:e.props.isInputFocused,containerRef:e.props.containerRef,inline:e.props.inline,shouldFocusDayInline:e.props.shouldFocusDayInline,monthShowsDuplicateDaysEnd:e.props.monthShowsDuplicateDaysEnd,monthShowsDuplicateDaysStart:e.props.monthShowsDuplicateDaysStart,locale:e.props.locale})})))})),e}return gt(n,[{key:"render",value:function(){return ce.default.createElement("div",{className:"react-datepicker__week"},this.renderDays())}}],[{key:"defaultProps",get:function(){return{shouldCloseOnSelect:!0}}}]),n}(ce.default.Component),Un=function(e){bt(n,e);var t=St(n);function n(){var e;ht(this,n);for(var r=arguments.length,a=new Array(r),o=0;o<r;o++)a[o]=arguments[o];return yt(_t(e=t.call.apply(t,[this].concat(a))),"MONTH_REFS",kt(Array(12)).map((function(){return ce.default.createRef()}))),yt(_t(e),"isDisabled",(function(t){return nn(t,e.props)})),yt(_t(e),"isExcluded",(function(t){return rn(t,e.props)})),yt(_t(e),"handleDayClick",(function(t,n){e.props.onDayClick&&e.props.onDayClick(t,n,e.props.orderInDisplay)})),yt(_t(e),"handleDayMouseEnter",(function(t){e.props.onDayMouseEnter&&e.props.onDayMouseEnter(t)})),yt(_t(e),"handleMouseLeave",(function(){e.props.onMouseLeave&&e.props.onMouseLeave()})),yt(_t(e),"isRangeStartMonth",(function(t){var n=e.props,r=n.day,a=n.startDate,o=n.endDate;return!(!a||!o)&&Vt(Le.default(r,t),a)})),yt(_t(e),"isRangeStartQuarter",(function(t){var n=e.props,r=n.day,a=n.startDate,o=n.endDate;return!(!a||!o)&&$t(Ue.default(r,t),a)})),yt(_t(e),"isRangeEndMonth",(function(t){var n=e.props,r=n.day,a=n.startDate,o=n.endDate;return!(!a||!o)&&Vt(Le.default(r,t),o)})),yt(_t(e),"isRangeEndQuarter",(function(t){var n=e.props,r=n.day,a=n.startDate,o=n.endDate;return!(!a||!o)&&$t(Ue.default(r,t),o)})),yt(_t(e),"isWeekInMonth",(function(t){var n=e.props.day,r=ye.default(t,6);return Vt(t,n)||Vt(r,n)})),yt(_t(e),"isCurrentMonth",(function(e,t){return Re.default(e)===Re.default(Mt())&&t===Ne.default(Mt())})),yt(_t(e),"isSelectedMonth",(function(e,t,n){return Ne.default(e)===t&&Re.default(e)===Re.default(n)})),yt(_t(e),"isSelectedQuarter",(function(e,t,n){return Me.default(e)===t&&Re.default(e)===Re.default(n)})),yt(_t(e),"renderWeeks",(function(){for(var t=[],n=e.props.fixedHeight,r=0,a=!1,o=Yt(Wt(e.props.day),e.props.locale,e.props.calendarStartDay);t.push(ce.default.createElement(Ln,{ariaLabelPrefix:e.props.weekAriaLabelPrefix,chooseDayAriaLabelPrefix:e.props.chooseDayAriaLabelPrefix,disabledDayAriaLabelPrefix:e.props.disabledDayAriaLabelPrefix,key:r,day:o,month:Ne.default(e.props.day),onDayClick:e.handleDayClick,onDayMouseEnter:e.handleDayMouseEnter,onWeekSelect:e.props.onWeekSelect,formatWeekNumber:e.props.formatWeekNumber,locale:e.props.locale,minDate:e.props.minDate,maxDate:e.props.maxDate,excludeDates:e.props.excludeDates,excludeDateIntervals:e.props.excludeDateIntervals,includeDates:e.props.includeDates,includeDateIntervals:e.props.includeDateIntervals,inline:e.props.inline,shouldFocusDayInline:e.props.shouldFocusDayInline,highlightDates:e.props.highlightDates,selectingDate:e.props.selectingDate,filterDate:e.props.filterDate,preSelection:e.props.preSelection,selected:e.props.selected,selectsStart:e.props.selectsStart,selectsEnd:e.props.selectsEnd,selectsRange:e.props.selectsRange,selectsDisabledDaysInRange:e.props.selectsDisabledDaysInRange,showWeekNumber:e.props.showWeekNumbers,startDate:e.props.startDate,endDate:e.props.endDate,dayClassName:e.props.dayClassName,setOpen:e.props.setOpen,shouldCloseOnSelect:e.props.shouldCloseOnSelect,disabledKeyboardNavigation:e.props.disabledKeyboardNavigation,renderDayContents:e.props.renderDayContents,handleOnKeyDown:e.props.handleOnKeyDown,isInputFocused:e.props.isInputFocused,containerRef:e.props.containerRef,calendarStartDay:e.props.calendarStartDay,monthShowsDuplicateDaysEnd:e.props.monthShowsDuplicateDaysEnd,monthShowsDuplicateDaysStart:e.props.monthShowsDuplicateDaysStart})),!a;){r++,o=ve.default(o,1);var l=n&&r>=6,i=!n&&!e.isWeekInMonth(o);if(l||i){if(!e.props.peekNextMonth)break;a=!0}}return t})),yt(_t(e),"onMonthClick",(function(t,n){e.handleDayClick(Wt(Le.default(e.props.day,n)),t)})),yt(_t(e),"handleMonthNavigation",(function(t,n){e.isDisabled(n)||e.isExcluded(n)||(e.props.setPreSelection(n),e.MONTH_REFS[t].current&&e.MONTH_REFS[t].current.focus())})),yt(_t(e),"onMonthKeyDown",(function(t,n){var r=t.key;if(!e.props.disabledKeyboardNavigation)switch(r){case"Enter":e.onMonthClick(t,n),e.props.setPreSelection(e.props.selected);break;case"ArrowRight":e.handleMonthNavigation(11===n?0:n+1,be.default(e.props.preSelection,1));break;case"ArrowLeft":e.handleMonthNavigation(0===n?11:n-1,xe.default(e.props.preSelection,1))}})),yt(_t(e),"onQuarterClick",(function(t,n){e.handleDayClick(Ht(Ue.default(e.props.day,n)),t)})),yt(_t(e),"getMonthClassNames",(function(t){var n=e.props,r=n.day,a=n.startDate,o=n.endDate,l=n.selected,i=n.minDate,u=n.maxDate,s=n.preSelection,c=n.monthClassName,p=c?c(r):void 0;return pe.default("react-datepicker__month-text","react-datepicker__month-".concat(t),p,{"react-datepicker__month--disabled":(i||u)&&an(Le.default(r,t),e.props),"react-datepicker__month--selected":e.isSelectedMonth(r,t,l),"react-datepicker__month-text--keyboard-selected":Ne.default(s)===t,"react-datepicker__month--in-range":on(a,o,t,r),"react-datepicker__month--range-start":e.isRangeStartMonth(t),"react-datepicker__month--range-end":e.isRangeEndMonth(t),"react-datepicker__month-text--today":e.isCurrentMonth(r,t)})})),yt(_t(e),"getTabIndex",(function(t){var n=Ne.default(e.props.preSelection);return e.props.disabledKeyboardNavigation||t!==n?"-1":"0"})),yt(_t(e),"getAriaLabel",(function(t){var n=e.props,r=n.chooseDayAriaLabelPrefix,a=void 0===r?"Choose":r,o=n.disabledDayAriaLabelPrefix,l=void 0===o?"Not available":o,i=n.day,u=Le.default(i,t),s=e.isDisabled(u)||e.isExcluded(u)?l:a;return"".concat(s," ").concat(At(u,"MMMM yyyy"))})),yt(_t(e),"getQuarterClassNames",(function(t){var n=e.props,r=n.day,a=n.startDate,o=n.endDate,l=n.selected,i=n.minDate,u=n.maxDate;return pe.default("react-datepicker__quarter-text","react-datepicker__quarter-".concat(t),{"react-datepicker__quarter--disabled":(i||u)&&ln(Ue.default(r,t),e.props),"react-datepicker__quarter--selected":e.isSelectedQuarter(r,t,l),"react-datepicker__quarter--in-range":sn(a,o,t,r),"react-datepicker__quarter--range-start":e.isRangeStartQuarter(t),"react-datepicker__quarter--range-end":e.isRangeEndQuarter(t)})})),yt(_t(e),"renderMonths",(function(){var t=e.props,n=t.showFullMonthYearPicker,r=t.showTwoColumnMonthYearPicker,a=t.showFourColumnMonthYearPicker,o=t.locale,l=t.day,i=t.selected;return(a?[[0,1,2,3],[4,5,6,7],[8,9,10,11]]:r?[[0,1],[2,3],[4,5],[6,7],[8,9],[10,11]]:[[0,1,2],[3,4,5],[6,7,8],[9,10,11]]).map((function(t,r){return ce.default.createElement("div",{className:"react-datepicker__month-wrapper",key:r},t.map((function(t,r){return ce.default.createElement("div",{ref:e.MONTH_REFS[t],key:r,onClick:function(n){e.onMonthClick(n,t)},onKeyDown:function(n){e.onMonthKeyDown(n,t)},tabIndex:e.getTabIndex(t),className:e.getMonthClassNames(t),role:"option","aria-label":e.getAriaLabel(t),"aria-current":e.isCurrentMonth(l,t)?"date":void 0,"aria-selected":e.isSelectedMonth(l,t,i)},n?Jt(t,o):en(t,o))})))}))})),yt(_t(e),"renderQuarters",(function(){var t=e.props,n=t.day,r=t.selected;return ce.default.createElement("div",{className:"react-datepicker__quarter-wrapper"},[1,2,3,4].map((function(t,a){return ce.default.createElement("div",{key:a,role:"option",onClick:function(n){e.onQuarterClick(n,t)},className:e.getQuarterClassNames(t),"aria-selected":e.isSelectedQuarter(n,t,r)},tn(t,e.props.locale))})))})),yt(_t(e),"getClassNames",(function(){var t=e.props;t.day;var n=t.selectingDate,r=t.selectsStart,a=t.selectsEnd,o=t.showMonthYearPicker,l=t.showQuarterYearPicker;return pe.default("react-datepicker__month",{"react-datepicker__month--selecting-range":n&&(r||a)},{"react-datepicker__monthPicker":o},{"react-datepicker__quarterPicker":l})})),e}return gt(n,[{key:"render",value:function(){var e=this.props,t=e.showMonthYearPicker,n=e.showQuarterYearPicker,r=e.day,a=e.ariaLabelPrefix,o=void 0===a?"month ":a;return ce.default.createElement("div",{className:this.getClassNames(),onMouseLeave:this.handleMouseLeave,"aria-label":"".concat(o," ").concat(At(r,"yyyy-MM")),role:"listbox"},t?this.renderMonths():n?this.renderQuarters():this.renderWeeks())}}]),n}(ce.default.Component),zn=function(e){bt(n,e);var t=St(n);function n(){var e;ht(this,n);for(var r=arguments.length,a=new Array(r),o=0;o<r;o++)a[o]=arguments[o];return yt(_t(e=t.call.apply(t,[this].concat(a))),"state",{height:null}),yt(_t(e),"handleClick",(function(t){(e.props.minTime||e.props.maxTime)&&fn(t,e.props)||(e.props.excludeTimes||e.props.includeTimes||e.props.filterTime)&&dn(t,e.props)||e.props.onChange(t)})),yt(_t(e),"isSelectedTime",(function(t,n,r){return e.props.selected&&n===De.default(t)&&r===Ce.default(t)})),yt(_t(e),"liClasses",(function(t,n,r){var a=["react-datepicker__time-list-item",e.props.timeClassName?e.props.timeClassName(t,n,r):void 0];return e.isSelectedTime(t,n,r)&&a.push("react-datepicker__time-list-item--selected"),((e.props.minTime||e.props.maxTime)&&fn(t,e.props)||(e.props.excludeTimes||e.props.includeTimes||e.props.filterTime)&&dn(t,e.props))&&a.push("react-datepicker__time-list-item--disabled"),e.props.injectTimes&&(60*De.default(t)+Ce.default(t))%e.props.intervals!=0&&a.push("react-datepicker__time-list-item--injected"),a.join(" ")})),yt(_t(e),"handleOnKeyDown",(function(t,n){" "===t.key&&(t.preventDefault(),t.key="Enter"),"Enter"===t.key&&e.handleClick(n),e.props.handleOnKeyDown(t)})),yt(_t(e),"renderTimes",(function(){for(var t=[],n=e.props.format?e.props.format:"p",r=e.props.intervals,a=zt(Mt(e.props.selected)),o=1440/r,l=e.props.injectTimes&&e.props.injectTimes.sort((function(e,t){return e-t})),i=e.props.selected||e.props.openToDate||Mt(),u=De.default(i),s=Ce.default(i),c=Fe.default(Ie.default(a,s),u),p=0;p<o;p++){var d=me.default(a,p*r);if(t.push(d),l){var f=En(a,d,p,r,l);t=t.concat(f)}}return t.map((function(t,r){return ce.default.createElement("li",{key:r,onClick:e.handleClick.bind(_t(e),t),className:e.liClasses(t,u,s),ref:function(n){(at.default(t,c)||Qt(t,c))&&(e.centerLi=n)},onKeyDown:function(n){e.handleOnKeyDown(n,t)},tabIndex:"0","aria-selected":e.isSelectedTime(t,u,s)?"true":void 0},At(t,n,e.props.locale))}))})),e}return gt(n,[{key:"componentDidMount",value:function(){this.list.scrollTop=n.calcCenterPosition(this.props.monthRef?this.props.monthRef.clientHeight-this.header.clientHeight:this.list.clientHeight,this.centerLi),this.props.monthRef&&this.header&&this.setState({height:this.props.monthRef.clientHeight-this.header.clientHeight})}},{key:"render",value:function(){var e=this,t=this.state.height;return ce.default.createElement("div",{className:"react-datepicker__time-container ".concat(this.props.todayButton?"react-datepicker__time-container--with-today-button":"")},ce.default.createElement("div",{className:"react-datepicker__header react-datepicker__header--time ".concat(this.props.showTimeSelectOnly?"react-datepicker__header--time--only":""),ref:function(t){e.header=t}},ce.default.createElement("div",{className:"react-datepicker-time__header"},this.props.timeCaption)),ce.default.createElement("div",{className:"react-datepicker__time"},ce.default.createElement("div",{className:"react-datepicker__time-box"},ce.default.createElement("ul",{className:"react-datepicker__time-list",ref:function(t){e.list=t},style:t?{height:t}:{},tabIndex:"0"},this.renderTimes()))))}}],[{key:"defaultProps",get:function(){return{intervals:30,onTimeChange:function(){},todayButton:null,timeCaption:"Time"}}}]),n}(ce.default.Component);yt(zn,"calcCenterPosition",(function(e,t){return t.offsetTop-(e/2-t.clientHeight/2)}));var Yn=function(e){bt(n,e);var t=St(n);function n(e){var r;return ht(this,n),yt(_t(r=t.call(this,e)),"YEAR_REFS",kt(Array(r.props.yearItemNumber)).map((function(){return ce.default.createRef()}))),yt(_t(r),"isDisabled",(function(e){return nn(e,r.props)})),yt(_t(r),"isExcluded",(function(e){return rn(e,r.props)})),yt(_t(r),"updateFocusOnPaginate",(function(e){var t=function(){this.YEAR_REFS[e].current.focus()}.bind(_t(r));window.requestAnimationFrame(t)})),yt(_t(r),"handleYearClick",(function(e,t){r.props.onDayClick&&r.props.onDayClick(e,t)})),yt(_t(r),"handleYearNavigation",(function(e,t){var n=r.props,a=n.date,o=n.yearItemNumber,l=Sn(a,o).startPeriod;r.isDisabled(t)||r.isExcluded(t)||(r.props.setPreSelection(t),e-l==-1?r.updateFocusOnPaginate(o-1):e-l===o?r.updateFocusOnPaginate(0):r.YEAR_REFS[e-l].current.focus())})),yt(_t(r),"isSameDay",(function(e,t){return Zt(e,t)})),yt(_t(r),"isCurrentYear",(function(e){return e===Re.default(Mt())})),yt(_t(r),"isKeyboardSelected",(function(e){var t=Bt(ze.default(r.props.date,e));return!r.props.disabledKeyboardNavigation&&!r.props.inline&&!Zt(t,Bt(r.props.selected))&&Zt(t,Bt(r.props.preSelection))})),yt(_t(r),"onYearClick",(function(e,t){var n=r.props.date;r.handleYearClick(Bt(ze.default(n,t)),e)})),yt(_t(r),"onYearKeyDown",(function(e,t){var n=e.key;if(!r.props.disabledKeyboardNavigation)switch(n){case"Enter":r.onYearClick(e,t),r.props.setPreSelection(r.props.selected);break;case"ArrowRight":r.handleYearNavigation(t+1,we.default(r.props.preSelection,1));break;case"ArrowLeft":r.handleYearNavigation(t-1,Se.default(r.props.preSelection,1))}})),yt(_t(r),"getYearClassNames",(function(e){var t=r.props,n=t.minDate,a=t.maxDate,o=t.selected;return pe.default("react-datepicker__year-text",{"react-datepicker__year-text--selected":e===Re.default(o),"react-datepicker__year-text--disabled":(n||a)&&un(e,r.props),"react-datepicker__year-text--keyboard-selected":r.isKeyboardSelected(e),"react-datepicker__year-text--today":r.isCurrentYear(e)})})),yt(_t(r),"getYearTabIndex",(function(e){return r.props.disabledKeyboardNavigation?"-1":e===Re.default(r.props.preSelection)?"0":"-1"})),r}return gt(n,[{key:"render",value:function(){for(var e=this,t=[],n=this.props,r=Sn(n.date,n.yearItemNumber),a=r.startPeriod,o=r.endPeriod,l=function(n){t.push(ce.default.createElement("div",{ref:e.YEAR_REFS[n-a],onClick:function(t){e.onYearClick(t,n)},onKeyDown:function(t){e.onYearKeyDown(t,n)},tabIndex:e.getYearTabIndex(n),className:e.getYearClassNames(n),key:n,"aria-current":e.isCurrentYear(n)?"date":void 0},n))},i=a;i<=o;i++)l(i);return ce.default.createElement("div",{className:"react-datepicker__year"},ce.default.createElement("div",{className:"react-datepicker__year-wrapper"},t))}}]),n}(ce.default.Component),Wn=function(e){bt(n,e);var t=St(n);function n(e){var r;return ht(this,n),yt(_t(r=t.call(this,e)),"onTimeChange",(function(e){r.setState({time:e});var t=new Date;t.setHours(e.split(":")[0]),t.setMinutes(e.split(":")[1]),r.props.onChange(t)})),yt(_t(r),"renderTimeInput",(function(){var e=r.state.time,t=r.props,n=t.date,a=t.timeString,o=t.customTimeInput;return o?ce.default.cloneElement(o,{date:n,value:e,onChange:r.onTimeChange}):ce.default.createElement("input",{type:"time",className:"react-datepicker-time__input",placeholder:"Time",name:"time-input",required:!0,value:e,onChange:function(e){r.onTimeChange(e.target.value||a)}})})),r.state={time:r.props.timeString},r}return gt(n,[{key:"render",value:function(){return ce.default.createElement("div",{className:"react-datepicker__input-time-container"},ce.default.createElement("div",{className:"react-datepicker-time__caption"},this.props.timeInputLabel),ce.default.createElement("div",{className:"react-datepicker-time__input-container"},ce.default.createElement("div",{className:"react-datepicker-time__input"},this.renderTimeInput())))}}],[{key:"getDerivedStateFromProps",value:function(e,t){return e.timeString!==t.time?{time:e.timeString}:null}}]),n}(ce.default.Component);function Bn(e){var t=e.className,n=e.children,r=e.showPopperArrow,a=e.arrowProps,o=void 0===a?{}:a;return ce.default.createElement("div",{className:t},r&&ce.default.createElement("div",vt({className:"react-datepicker__triangle"},o)),n)}var Hn=["react-datepicker__year-select","react-datepicker__month-select","react-datepicker__month-year-select"],qn=function(e){bt(n,e);var t=St(n);function n(e){var r;return ht(this,n),yt(_t(r=t.call(this,e)),"handleClickOutside",(function(e){r.props.onClickOutside(e)})),yt(_t(r),"setClickOutsideRef",(function(){return r.containerRef.current})),yt(_t(r),"handleDropdownFocus",(function(e){(function(){var e=((arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).className||"").split(/\s+/);return Hn.some((function(t){return e.indexOf(t)>=0}))})(e.target)&&r.props.onDropdownFocus()})),yt(_t(r),"getDateInView",(function(){var e=r.props,t=e.preSelection,n=e.selected,a=e.openToDate,o=vn(r.props),l=bn(r.props),i=Mt();return a||n||t||(o&&at.default(i,o)?o:l&&rt.default(i,l)?l:i)})),yt(_t(r),"increaseMonth",(function(){r.setState((function(e){var t=e.date;return{date:be.default(t,1)}}),(function(){return r.handleMonthChange(r.state.date)}))})),yt(_t(r),"decreaseMonth",(function(){r.setState((function(e){var t=e.date;return{date:xe.default(t,1)}}),(function(){return r.handleMonthChange(r.state.date)}))})),yt(_t(r),"handleDayClick",(function(e,t,n){r.props.onSelect(e,t,n),r.props.setPreSelection&&r.props.setPreSelection(e)})),yt(_t(r),"handleDayMouseEnter",(function(e){r.setState({selectingDate:e}),r.props.onDayMouseEnter&&r.props.onDayMouseEnter(e)})),yt(_t(r),"handleMonthMouseLeave",(function(){r.setState({selectingDate:null}),r.props.onMonthMouseLeave&&r.props.onMonthMouseLeave()})),yt(_t(r),"handleYearChange",(function(e){r.props.onYearChange&&r.props.onYearChange(e),r.props.adjustDateOnChange&&(r.props.onSelect&&r.props.onSelect(e),r.props.setOpen&&r.props.setOpen(!0)),r.props.setPreSelection&&r.props.setPreSelection(e)})),yt(_t(r),"handleMonthChange",(function(e){r.props.onMonthChange&&r.props.onMonthChange(e),r.props.adjustDateOnChange&&(r.props.onSelect&&r.props.onSelect(e),r.props.setOpen&&r.props.setOpen(!0)),r.props.setPreSelection&&r.props.setPreSelection(e)})),yt(_t(r),"handleMonthYearChange",(function(e){r.handleYearChange(e),r.handleMonthChange(e)})),yt(_t(r),"changeYear",(function(e){r.setState((function(t){var n=t.date;return{date:ze.default(n,e)}}),(function(){return r.handleYearChange(r.state.date)}))})),yt(_t(r),"changeMonth",(function(e){r.setState((function(t){var n=t.date;return{date:Le.default(n,e)}}),(function(){return r.handleMonthChange(r.state.date)}))})),yt(_t(r),"changeMonthYear",(function(e){r.setState((function(t){var n=t.date;return{date:ze.default(Le.default(n,Ne.default(e)),Re.default(e))}}),(function(){return r.handleMonthYearChange(r.state.date)}))})),yt(_t(r),"header",(function(){var e=Yt(arguments.length>0&&void 0!==arguments[0]?arguments[0]:r.state.date,r.props.locale,r.props.calendarStartDay),t=[];return r.props.showWeekNumbers&&t.push(ce.default.createElement("div",{key:"W",className:"react-datepicker__day-name"},r.props.weekLabel||"#")),t.concat([0,1,2,3,4,5,6].map((function(t){var n=ye.default(e,t),a=r.formatWeekday(n,r.props.locale),o=r.props.weekDayClassName?r.props.weekDayClassName(n):void 0;return ce.default.createElement("div",{key:t,className:pe.default("react-datepicker__day-name",o)},a)})))})),yt(_t(r),"formatWeekday",(function(e,t){return r.props.formatWeekDay?function(e,t,n){return t(At(e,"EEEE",n))}(e,r.props.formatWeekDay,t):r.props.useWeekdaysShort?function(e,t){return At(e,"EEE",t)}(e,t):function(e,t){return At(e,"EEEEEE",t)}(e,t)})),yt(_t(r),"decreaseYear",(function(){r.setState((function(e){var t=e.date;return{date:Se.default(t,r.props.showYearPicker?r.props.yearItemNumber:1)}}),(function(){return r.handleYearChange(r.state.date)}))})),yt(_t(r),"renderPreviousButton",(function(){if(!r.props.renderCustomHeader){var e;switch(!0){case r.props.showMonthYearPicker:e=gn(r.state.date,r.props);break;case r.props.showYearPicker:e=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.minDate,r=t.yearItemNumber,a=void 0===r?Tt:r,o=Sn(Bt(Se.default(e,a)),a).endPeriod,l=n&&Re.default(n);return l&&l>o||!1}(r.state.date,r.props);break;default:e=hn(r.state.date,r.props)}if((r.props.forceShowMonthNavigation||r.props.showDisabledMonthNavigation||!e)&&!r.props.showTimeSelectOnly){var t=["react-datepicker__navigation","react-datepicker__navigation--previous"],n=r.decreaseMonth;(r.props.showMonthYearPicker||r.props.showQuarterYearPicker||r.props.showYearPicker)&&(n=r.decreaseYear),e&&r.props.showDisabledMonthNavigation&&(t.push("react-datepicker__navigation--previous--disabled"),n=null);var a=r.props.showMonthYearPicker||r.props.showQuarterYearPicker||r.props.showYearPicker,o=r.props,l=o.previousMonthButtonLabel,i=o.previousYearButtonLabel,u=r.props,s=u.previousMonthAriaLabel,c=void 0===s?"string"==typeof l?l:"Previous Month":s,p=u.previousYearAriaLabel,d=void 0===p?"string"==typeof i?i:"Previous Year":p;return ce.default.createElement("button",{type:"button",className:t.join(" "),onClick:n,onKeyDown:r.props.handleOnKeyDown,"aria-label":a?d:c},ce.default.createElement("span",{className:["react-datepicker__navigation-icon","react-datepicker__navigation-icon--previous"].join(" ")},a?r.props.previousYearButtonLabel:r.props.previousMonthButtonLabel))}}})),yt(_t(r),"increaseYear",(function(){r.setState((function(e){var t=e.date;return{date:we.default(t,r.props.showYearPicker?r.props.yearItemNumber:1)}}),(function(){return r.handleYearChange(r.state.date)}))})),yt(_t(r),"renderNextButton",(function(){if(!r.props.renderCustomHeader){var e;switch(!0){case r.props.showMonthYearPicker:e=yn(r.state.date,r.props);break;case r.props.showYearPicker:e=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.maxDate,r=t.yearItemNumber,a=void 0===r?Tt:r,o=Sn(we.default(e,a),a).startPeriod,l=n&&Re.default(n);return l&&l<o||!1}(r.state.date,r.props);break;default:e=mn(r.state.date,r.props)}if((r.props.forceShowMonthNavigation||r.props.showDisabledMonthNavigation||!e)&&!r.props.showTimeSelectOnly){var t=["react-datepicker__navigation","react-datepicker__navigation--next"];r.props.showTimeSelect&&t.push("react-datepicker__navigation--next--with-time"),r.props.todayButton&&t.push("react-datepicker__navigation--next--with-today-button");var n=r.increaseMonth;(r.props.showMonthYearPicker||r.props.showQuarterYearPicker||r.props.showYearPicker)&&(n=r.increaseYear),e&&r.props.showDisabledMonthNavigation&&(t.push("react-datepicker__navigation--next--disabled"),n=null);var a=r.props.showMonthYearPicker||r.props.showQuarterYearPicker||r.props.showYearPicker,o=r.props,l=o.nextMonthButtonLabel,i=o.nextYearButtonLabel,u=r.props,s=u.nextMonthAriaLabel,c=void 0===s?"string"==typeof l?l:"Next Month":s,p=u.nextYearAriaLabel,d=void 0===p?"string"==typeof i?i:"Next Year":p;return ce.default.createElement("button",{type:"button",className:t.join(" "),onClick:n,onKeyDown:r.props.handleOnKeyDown,"aria-label":a?d:c},ce.default.createElement("span",{className:["react-datepicker__navigation-icon","react-datepicker__navigation-icon--next"].join(" ")},a?r.props.nextYearButtonLabel:r.props.nextMonthButtonLabel))}}})),yt(_t(r),"renderCurrentMonth",(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:r.state.date,t=["react-datepicker__current-month"];return r.props.showYearDropdown&&t.push("react-datepicker__current-month--hasYearDropdown"),r.props.showMonthDropdown&&t.push("react-datepicker__current-month--hasMonthDropdown"),r.props.showMonthYearDropdown&&t.push("react-datepicker__current-month--hasMonthYearDropdown"),ce.default.createElement("div",{className:t.join(" ")},At(e,r.props.dateFormat,r.props.locale))})),yt(_t(r),"renderYearDropdown",(function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(r.props.showYearDropdown&&!e)return ce.default.createElement(On,{adjustDateOnChange:r.props.adjustDateOnChange,date:r.state.date,onSelect:r.props.onSelect,setOpen:r.props.setOpen,dropdownMode:r.props.dropdownMode,onChange:r.changeYear,minDate:r.props.minDate,maxDate:r.props.maxDate,year:Re.default(r.state.date),scrollableYearDropdown:r.props.scrollableYearDropdown,yearDropdownItemNumber:r.props.yearDropdownItemNumber})})),yt(_t(r),"renderMonthDropdown",(function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(r.props.showMonthDropdown&&!e)return ce.default.createElement(Nn,{dropdownMode:r.props.dropdownMode,locale:r.props.locale,onChange:r.changeMonth,month:Ne.default(r.state.date),useShortMonthInDropdown:r.props.useShortMonthInDropdown})})),yt(_t(r),"renderMonthYearDropdown",(function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(r.props.showMonthYearDropdown&&!e)return ce.default.createElement(An,{dropdownMode:r.props.dropdownMode,locale:r.props.locale,dateFormat:r.props.dateFormat,onChange:r.changeMonthYear,minDate:r.props.minDate,maxDate:r.props.maxDate,date:r.state.date,scrollableMonthYearDropdown:r.props.scrollableMonthYearDropdown})})),yt(_t(r),"renderTodayButton",(function(){if(r.props.todayButton&&!r.props.showTimeSelectOnly)return ce.default.createElement("div",{className:"react-datepicker__today-button",onClick:function(e){return r.props.onSelect(Ve.default(Mt()),e)}},r.props.todayButton)})),yt(_t(r),"renderDefaultHeader",(function(e){var t=e.monthDate,n=e.i;return ce.default.createElement("div",{className:"react-datepicker__header ".concat(r.props.showTimeSelect?"react-datepicker__header--has-time-select":"")},r.renderCurrentMonth(t),ce.default.createElement("div",{className:"react-datepicker__header__dropdown react-datepicker__header__dropdown--".concat(r.props.dropdownMode),onFocus:r.handleDropdownFocus},r.renderMonthDropdown(0!==n),r.renderMonthYearDropdown(0!==n),r.renderYearDropdown(0!==n)),ce.default.createElement("div",{className:"react-datepicker__day-names"},r.header(t)))})),yt(_t(r),"renderCustomHeader",(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.monthDate,n=e.i;if(r.props.showTimeSelect&&!r.state.monthContainer||r.props.showTimeSelectOnly)return null;var a=hn(r.state.date,r.props),o=mn(r.state.date,r.props),l=gn(r.state.date,r.props),i=yn(r.state.date,r.props),u=!r.props.showMonthYearPicker&&!r.props.showQuarterYearPicker&&!r.props.showYearPicker;return ce.default.createElement("div",{className:"react-datepicker__header react-datepicker__header--custom",onFocus:r.props.onDropdownFocus},r.props.renderCustomHeader(dt(dt({},r.state),{},{customHeaderCount:n,monthDate:t,changeMonth:r.changeMonth,changeYear:r.changeYear,decreaseMonth:r.decreaseMonth,increaseMonth:r.increaseMonth,decreaseYear:r.decreaseYear,increaseYear:r.increaseYear,prevMonthButtonDisabled:a,nextMonthButtonDisabled:o,prevYearButtonDisabled:l,nextYearButtonDisabled:i})),u&&ce.default.createElement("div",{className:"react-datepicker__day-names"},r.header(t)))})),yt(_t(r),"renderYearHeader",(function(){var e=r.state.date,t=r.props,n=t.showYearPicker,a=Sn(e,t.yearItemNumber),o=a.startPeriod,l=a.endPeriod;return ce.default.createElement("div",{className:"react-datepicker__header react-datepicker-year-header"},n?"".concat(o," - ").concat(l):Re.default(e))})),yt(_t(r),"renderHeader",(function(e){switch(!0){case void 0!==r.props.renderCustomHeader:return r.renderCustomHeader(e);case r.props.showMonthYearPicker||r.props.showQuarterYearPicker||r.props.showYearPicker:return r.renderYearHeader(e);default:return r.renderDefaultHeader(e)}})),yt(_t(r),"renderMonths",(function(){if(!r.props.showTimeSelectOnly&&!r.props.showYearPicker){for(var e=[],t=r.props.showPreviousMonths?r.props.monthsShown-1:0,n=xe.default(r.state.date,t),a=0;a<r.props.monthsShown;++a){var o=a-r.props.monthSelectedIn,l=be.default(n,o),i="month-".concat(a),u=a<r.props.monthsShown-1,s=a>0;e.push(ce.default.createElement("div",{key:i,ref:function(e){r.monthContainer=e},className:"react-datepicker__month-container"},r.renderHeader({monthDate:l,i:a}),ce.default.createElement(Un,{chooseDayAriaLabelPrefix:r.props.chooseDayAriaLabelPrefix,disabledDayAriaLabelPrefix:r.props.disabledDayAriaLabelPrefix,weekAriaLabelPrefix:r.props.weekAriaLabelPrefix,ariaLabelPrefix:r.props.monthAriaLabelPrefix,onChange:r.changeMonthYear,day:l,dayClassName:r.props.dayClassName,calendarStartDay:r.props.calendarStartDay,monthClassName:r.props.monthClassName,onDayClick:r.handleDayClick,handleOnKeyDown:r.props.handleOnDayKeyDown,onDayMouseEnter:r.handleDayMouseEnter,onMouseLeave:r.handleMonthMouseLeave,onWeekSelect:r.props.onWeekSelect,orderInDisplay:a,formatWeekNumber:r.props.formatWeekNumber,locale:r.props.locale,minDate:r.props.minDate,maxDate:r.props.maxDate,excludeDates:r.props.excludeDates,excludeDateIntervals:r.props.excludeDateIntervals,highlightDates:r.props.highlightDates,selectingDate:r.state.selectingDate,includeDates:r.props.includeDates,includeDateIntervals:r.props.includeDateIntervals,inline:r.props.inline,shouldFocusDayInline:r.props.shouldFocusDayInline,fixedHeight:r.props.fixedHeight,filterDate:r.props.filterDate,preSelection:r.props.preSelection,setPreSelection:r.props.setPreSelection,selected:r.props.selected,selectsStart:r.props.selectsStart,selectsEnd:r.props.selectsEnd,selectsRange:r.props.selectsRange,selectsDisabledDaysInRange:r.props.selectsDisabledDaysInRange,showWeekNumbers:r.props.showWeekNumbers,startDate:r.props.startDate,endDate:r.props.endDate,peekNextMonth:r.props.peekNextMonth,setOpen:r.props.setOpen,shouldCloseOnSelect:r.props.shouldCloseOnSelect,renderDayContents:r.props.renderDayContents,disabledKeyboardNavigation:r.props.disabledKeyboardNavigation,showMonthYearPicker:r.props.showMonthYearPicker,showFullMonthYearPicker:r.props.showFullMonthYearPicker,showTwoColumnMonthYearPicker:r.props.showTwoColumnMonthYearPicker,showFourColumnMonthYearPicker:r.props.showFourColumnMonthYearPicker,showYearPicker:r.props.showYearPicker,showQuarterYearPicker:r.props.showQuarterYearPicker,isInputFocused:r.props.isInputFocused,containerRef:r.containerRef,monthShowsDuplicateDaysEnd:u,monthShowsDuplicateDaysStart:s})))}return e}})),yt(_t(r),"renderYears",(function(){if(!r.props.showTimeSelectOnly)return r.props.showYearPicker?ce.default.createElement("div",{className:"react-datepicker__year--container"},r.renderHeader(),ce.default.createElement(Yn,vt({onDayClick:r.handleDayClick,date:r.state.date},r.props))):void 0})),yt(_t(r),"renderTimeSection",(function(){if(r.props.showTimeSelect&&(r.state.monthContainer||r.props.showTimeSelectOnly))return ce.default.createElement(zn,{selected:r.props.selected,openToDate:r.props.openToDate,onChange:r.props.onTimeChange,timeClassName:r.props.timeClassName,format:r.props.timeFormat,includeTimes:r.props.includeTimes,intervals:r.props.timeIntervals,minTime:r.props.minTime,maxTime:r.props.maxTime,excludeTimes:r.props.excludeTimes,filterTime:r.props.filterTime,timeCaption:r.props.timeCaption,todayButton:r.props.todayButton,showMonthDropdown:r.props.showMonthDropdown,showMonthYearDropdown:r.props.showMonthYearDropdown,showYearDropdown:r.props.showYearDropdown,withPortal:r.props.withPortal,monthRef:r.state.monthContainer,injectTimes:r.props.injectTimes,locale:r.props.locale,handleOnKeyDown:r.props.handleOnKeyDown,showTimeSelectOnly:r.props.showTimeSelectOnly})})),yt(_t(r),"renderInputTimeSection",(function(){var e=new Date(r.props.selected),t=jt(e)&&Boolean(r.props.selected)?"".concat(xn(e.getHours()),":").concat(xn(e.getMinutes())):"";if(r.props.showTimeInput)return ce.default.createElement(Wn,{date:e,timeString:t,timeInputLabel:r.props.timeInputLabel,onChange:r.props.onTimeChange,customTimeInput:r.props.customTimeInput})})),r.containerRef=ce.default.createRef(),r.state={date:r.getDateInView(),selectingDate:null,monthContainer:null},r}return gt(n,[{key:"componentDidMount",value:function(){this.props.showTimeSelect&&(this.assignMonthContainer=void this.setState({monthContainer:this.monthContainer}))}},{key:"componentDidUpdate",value:function(e){this.props.preSelection&&!Zt(this.props.preSelection,e.preSelection)?this.setState({date:this.props.preSelection}):this.props.openToDate&&!Zt(this.props.openToDate,e.openToDate)&&this.setState({date:this.props.openToDate})}},{key:"render",value:function(){var e=this.props.container||Bn;return ce.default.createElement("div",{ref:this.containerRef},ce.default.createElement(e,{className:pe.default("react-datepicker",this.props.className,{"react-datepicker--time-only":this.props.showTimeSelectOnly}),showPopperArrow:this.props.showPopperArrow,arrowProps:this.props.arrowProps},this.renderPreviousButton(),this.renderNextButton(),this.renderMonths(),this.renderYears(),this.renderTodayButton(),this.renderTimeSection(),this.renderInputTimeSection(),this.props.children))}}],[{key:"defaultProps",get:function(){return{onDropdownFocus:function(){},monthsShown:1,monthSelectedIn:0,forceShowMonthNavigation:!1,timeCaption:"Time",previousYearButtonLabel:"Previous Year",nextYearButtonLabel:"Next Year",previousMonthButtonLabel:"Previous Month",nextMonthButtonLabel:"Next Month",customTimeInput:null,yearItemNumber:Tt}}}]),n}(ce.default.Component),Vn=function(e){bt(n,e);var t=St(n);function n(e){var r;return ht(this,n),(r=t.call(this,e)).el=document.createElement("div"),r}return gt(n,[{key:"componentDidMount",value:function(){this.portalRoot=(this.props.portalHost||document).getElementById(this.props.portalId),this.portalRoot||(this.portalRoot=document.createElement("div"),this.portalRoot.setAttribute("id",this.props.portalId),(this.props.portalHost||document.body).appendChild(this.portalRoot)),this.portalRoot.appendChild(this.el)}},{key:"componentWillUnmount",value:function(){this.portalRoot.removeChild(this.el)}},{key:"render",value:function(){return ct.default.createPortal(this.props.children,this.el)}}]),n}(ce.default.Component),$n=function(e){return!e.disabled&&-1!==e.tabIndex},Zn=function(e){bt(n,e);var t=St(n);function n(e){var r;return ht(this,n),yt(_t(r=t.call(this,e)),"getTabChildren",(function(){return Array.prototype.slice.call(r.tabLoopRef.current.querySelectorAll("[tabindex], a, button, input, select, textarea"),1,-1).filter($n)})),yt(_t(r),"handleFocusStart",(function(e){var t=r.getTabChildren();t&&t.length>1&&t[t.length-1].focus()})),yt(_t(r),"handleFocusEnd",(function(e){var t=r.getTabChildren();t&&t.length>1&&t[0].focus()})),r.tabLoopRef=ce.default.createRef(),r}return gt(n,[{key:"render",value:function(){return this.props.enableTabLoop?ce.default.createElement("div",{className:"react-datepicker__tab-loop",ref:this.tabLoopRef},ce.default.createElement("div",{className:"react-datepicker__tab-loop__start",tabIndex:"0",onFocus:this.handleFocusStart}),this.props.children,ce.default.createElement("div",{className:"react-datepicker__tab-loop__end",tabIndex:"0",onFocus:this.handleFocusEnd})):this.props.children}}],[{key:"defaultProps",get:function(){return{enableTabLoop:!0}}}]),n}(ce.default.Component),Qn=function(e){bt(n,e);var t=St(n);function n(){return ht(this,n),t.apply(this,arguments)}return gt(n,[{key:"render",value:function(){var e,t=this.props,n=t.className,r=t.wrapperClassName,a=t.hidePopper,o=t.popperComponent,l=t.popperModifiers,i=t.popperPlacement,u=t.popperProps,s=t.targetComponent,c=t.enableTabLoop,p=t.popperOnKeyDown,d=t.portalId,f=t.portalHost;if(!a){var h=pe.default("react-datepicker-popper",n);e=ce.default.createElement(ue.Popper,vt({modifiers:l,placement:i},u),(function(e){var t=e.ref,n=e.style,r=e.placement,a=e.arrowProps;return ce.default.createElement(Zn,{enableTabLoop:c},ce.default.createElement("div",{ref:t,style:n,className:h,"data-placement":r,onKeyDown:p},ce.default.cloneElement(o,{arrowProps:a})))}))}this.props.popperContainer&&(e=ce.default.createElement(this.props.popperContainer,{},e)),d&&!a&&(e=ce.default.createElement(Vn,{portalId:d,portalHost:f},e));var m=pe.default("react-datepicker-wrapper",r);return ce.default.createElement(ue.Manager,{className:"react-datepicker-manager"},ce.default.createElement(ue.Reference,null,(function(e){var t=e.ref;return ce.default.createElement("div",{ref:t,className:m},s)})),e)}}],[{key:"defaultProps",get:function(){return{hidePopper:!0,popperModifiers:[],popperProps:{},popperPlacement:"bottom-start"}}}]),n}(ce.default.Component),Kn="react-datepicker-ignore-onclickoutside",Gn=st.default(qn),Xn="Date input not valid.",Jn=function(e){bt(n,e);var t=St(n);function n(e){var r;return ht(this,n),yt(_t(r=t.call(this,e)),"getPreSelection",(function(){return r.props.openToDate?r.props.openToDate:r.props.selectsEnd&&r.props.startDate?r.props.startDate:r.props.selectsStart&&r.props.endDate?r.props.endDate:Mt()})),yt(_t(r),"calcInitialState",(function(){var e,t=r.getPreSelection(),n=vn(r.props),a=bn(r.props),o=n&&at.default(t,Ve.default(n))?n:a&&rt.default(t,Ge.default(a))?a:t;return{open:r.props.startOpen||!1,preventFocus:!1,preSelection:null!==(e=r.props.selectsRange?r.props.startDate:r.props.selected)&&void 0!==e?e:o,highlightDates:wn(r.props.highlightDates),focused:!1,shouldFocusDayInline:!1}})),yt(_t(r),"clearPreventFocusTimeout",(function(){r.preventFocusTimeout&&clearTimeout(r.preventFocusTimeout)})),yt(_t(r),"setFocus",(function(){r.input&&r.input.focus&&r.input.focus({preventScroll:!0})})),yt(_t(r),"setBlur",(function(){r.input&&r.input.blur&&r.input.blur(),r.cancelFocusInput()})),yt(_t(r),"setOpen",(function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];r.setState({open:e,preSelection:e&&r.state.open?r.state.preSelection:r.calcInitialState().preSelection,lastPreSelectChange:tr},(function(){e||r.setState((function(e){return{focused:!!t&&e.focused}}),(function(){!t&&r.setBlur(),r.setState({inputValue:null})}))}))})),yt(_t(r),"inputOk",(function(){return de.default(r.state.preSelection)})),yt(_t(r),"isCalendarOpen",(function(){return void 0===r.props.open?r.state.open&&!r.props.disabled&&!r.props.readOnly:r.props.open})),yt(_t(r),"handleFocus",(function(e){r.state.preventFocus||(r.props.onFocus(e),r.props.preventOpenOnFocus||r.props.readOnly||r.setOpen(!0)),r.setState({focused:!0})})),yt(_t(r),"cancelFocusInput",(function(){clearTimeout(r.inputFocusTimeout),r.inputFocusTimeout=null})),yt(_t(r),"deferFocusInput",(function(){r.cancelFocusInput(),r.inputFocusTimeout=setTimeout((function(){return r.setFocus()}),1)})),yt(_t(r),"handleDropdownFocus",(function(){r.cancelFocusInput()})),yt(_t(r),"handleBlur",(function(e){(!r.state.open||r.props.withPortal||r.props.showTimeInput)&&r.props.onBlur(e),r.setState({focused:!1})})),yt(_t(r),"handleCalendarClickOutside",(function(e){r.props.inline||r.setOpen(!1),r.props.onClickOutside(e),r.props.withPortal&&e.preventDefault()})),yt(_t(r),"handleChange",(function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var a=t[0];if(!r.props.onChangeRaw||(r.props.onChangeRaw.apply(_t(r),t),"function"==typeof a.isDefaultPrevented&&!a.isDefaultPrevented())){r.setState({inputValue:a.target.value,lastPreSelectChange:er});var o=Rt(a.target.value,r.props.dateFormat,r.props.locale,r.props.strictParsing,r.props.minDate);!o&&a.target.value||r.setSelected(o,a,!0)}})),yt(_t(r),"handleSelect",(function(e,t,n){if(r.setState({preventFocus:!0},(function(){return r.preventFocusTimeout=setTimeout((function(){return r.setState({preventFocus:!1})}),50),r.preventFocusTimeout})),r.props.onChangeRaw&&r.props.onChangeRaw(t),r.setSelected(e,t,!1,n),!r.props.shouldCloseOnSelect||r.props.showTimeSelect)r.setPreSelection(e);else if(!r.props.inline){r.props.selectsRange||r.setOpen(!1);var a=r.props,o=a.startDate,l=a.endDate;!o||l||at.default(e,o)||r.setOpen(!1)}})),yt(_t(r),"setSelected",(function(e,t,n,a){var o=e;if(null===o||!nn(o,r.props)){var l=r.props,i=l.onChange,u=l.selectsRange,s=l.startDate,c=l.endDate;if(!Qt(r.props.selected,o)||r.props.allowSameDay||u)if(null!==o&&(!r.props.selected||n&&(r.props.showTimeSelect||r.props.showTimeSelectOnly||r.props.showTimeInput)||(o=Ft(o,{hour:De.default(r.props.selected),minute:Ce.default(r.props.selected),second:ke.default(r.props.selected)})),r.props.inline||r.setState({preSelection:o}),r.props.focusSelectedMonth||r.setState({monthSelectedIn:a})),u){var p=s&&c;s||c?s&&!c&&(at.default(o,s)?i([o,null],t):i([s,o],t)):i([o,null],t),p&&i([o,null],t)}else i(o,t);n||(r.props.onSelect(o,t),r.setState({inputValue:null}))}})),yt(_t(r),"setPreSelection",(function(e){var t=void 0!==r.props.minDate,n=void 0!==r.props.maxDate,a=!0;if(e){var o=Ve.default(e);if(t&&n)a=Kt(e,r.props.minDate,r.props.maxDate);else if(t){var l=Ve.default(r.props.minDate);a=rt.default(e,l)||Qt(o,l)}else if(n){var i=Ge.default(r.props.maxDate);a=at.default(e,i)||Qt(o,i)}}a&&r.setState({preSelection:e})})),yt(_t(r),"handleTimeChange",(function(e){var t=Ft(r.props.selected?r.props.selected:r.getPreSelection(),{hour:De.default(e),minute:Ce.default(e)});r.setState({preSelection:t}),r.props.onChange(t),r.props.shouldCloseOnSelect&&r.setOpen(!1),r.props.showTimeInput&&r.setOpen(!0),r.setState({inputValue:null})})),yt(_t(r),"onInputClick",(function(){r.props.disabled||r.props.readOnly||r.setOpen(!0),r.props.onInputClick()})),yt(_t(r),"onInputKeyDown",(function(e){r.props.onKeyDown(e);var t=e.key;if(r.state.open||r.props.inline||r.props.preventOpenOnFocus){if(r.state.open){if("ArrowDown"===t||"ArrowUp"===t){e.preventDefault();var n=r.calendar.componentNode&&r.calendar.componentNode.querySelector('.react-datepicker__day[tabindex="0"]');return void(n&&n.focus({preventScroll:!0}))}var a=Mt(r.state.preSelection);"Enter"===t?(e.preventDefault(),r.inputOk()&&r.state.lastPreSelectChange===tr?(r.handleSelect(a,e),!r.props.shouldCloseOnSelect&&r.setPreSelection(a)):r.setOpen(!1)):"Escape"===t&&(e.preventDefault(),r.setOpen(!1)),r.inputOk()||r.props.onInputError({code:1,msg:Xn})}}else"ArrowDown"!==t&&"ArrowUp"!==t&&"Enter"!==t||r.onInputClick()})),yt(_t(r),"onDayKeyDown",(function(e){r.props.onKeyDown(e);var t=e.key,n=Mt(r.state.preSelection);if("Enter"===t)e.preventDefault(),r.handleSelect(n,e),!r.props.shouldCloseOnSelect&&r.setPreSelection(n);else if("Escape"===t)e.preventDefault(),r.setOpen(!1),r.inputOk()||r.props.onInputError({code:1,msg:Xn});else if(!r.props.disabledKeyboardNavigation){var a;switch(t){case"ArrowLeft":a=Ee.default(n,1);break;case"ArrowRight":a=ye.default(n,1);break;case"ArrowUp":a=_e.default(n,1);break;case"ArrowDown":a=ve.default(n,1);break;case"PageUp":a=xe.default(n,1);break;case"PageDown":a=be.default(n,1);break;case"Home":a=Se.default(n,1);break;case"End":a=we.default(n,1)}if(!a)return void(r.props.onInputError&&r.props.onInputError({code:1,msg:Xn}));if(e.preventDefault(),r.setState({lastPreSelectChange:tr}),r.props.adjustDateOnChange&&r.setSelected(a),r.setPreSelection(a),r.props.inline){var o=Ne.default(n),l=Ne.default(a),i=Re.default(n),u=Re.default(a);o!==l||i!==u?r.setState({shouldFocusDayInline:!0}):r.setState({shouldFocusDayInline:!1})}}})),yt(_t(r),"onPopperKeyDown",(function(e){"Escape"===e.key&&(e.preventDefault(),r.setState({preventFocus:!0},(function(){r.setOpen(!1),setTimeout((function(){r.setFocus(),r.setState({preventFocus:!1})}))})))})),yt(_t(r),"onClearClick",(function(e){e&&e.preventDefault&&e.preventDefault(),r.props.selectsRange?r.props.onChange([null,null],e):r.props.onChange(null,e),r.setState({inputValue:null})})),yt(_t(r),"clear",(function(){r.onClearClick()})),yt(_t(r),"onScroll",(function(e){"boolean"==typeof r.props.closeOnScroll&&r.props.closeOnScroll?e.target!==document&&e.target!==document.documentElement&&e.target!==document.body||r.setOpen(!1):"function"==typeof r.props.closeOnScroll&&r.props.closeOnScroll(e)&&r.setOpen(!1)})),yt(_t(r),"renderCalendar",(function(){return r.props.inline||r.isCalendarOpen()?ce.default.createElement(Gn,{ref:function(e){r.calendar=e},locale:r.props.locale,calendarStartDay:r.props.calendarStartDay,chooseDayAriaLabelPrefix:r.props.chooseDayAriaLabelPrefix,disabledDayAriaLabelPrefix:r.props.disabledDayAriaLabelPrefix,weekAriaLabelPrefix:r.props.weekAriaLabelPrefix,monthAriaLabelPrefix:r.props.monthAriaLabelPrefix,adjustDateOnChange:r.props.adjustDateOnChange,setOpen:r.setOpen,shouldCloseOnSelect:r.props.shouldCloseOnSelect,dateFormat:r.props.dateFormatCalendar,useWeekdaysShort:r.props.useWeekdaysShort,formatWeekDay:r.props.formatWeekDay,dropdownMode:r.props.dropdownMode,selected:r.props.selected,preSelection:r.state.preSelection,onSelect:r.handleSelect,onWeekSelect:r.props.onWeekSelect,openToDate:r.props.openToDate,minDate:r.props.minDate,maxDate:r.props.maxDate,selectsStart:r.props.selectsStart,selectsEnd:r.props.selectsEnd,selectsRange:r.props.selectsRange,startDate:r.props.startDate,endDate:r.props.endDate,excludeDates:r.props.excludeDates,excludeDateIntervals:r.props.excludeDateIntervals,filterDate:r.props.filterDate,onClickOutside:r.handleCalendarClickOutside,formatWeekNumber:r.props.formatWeekNumber,highlightDates:r.state.highlightDates,includeDates:r.props.includeDates,includeDateIntervals:r.props.includeDateIntervals,includeTimes:r.props.includeTimes,injectTimes:r.props.injectTimes,inline:r.props.inline,shouldFocusDayInline:r.state.shouldFocusDayInline,peekNextMonth:r.props.peekNextMonth,showMonthDropdown:r.props.showMonthDropdown,showPreviousMonths:r.props.showPreviousMonths,useShortMonthInDropdown:r.props.useShortMonthInDropdown,showMonthYearDropdown:r.props.showMonthYearDropdown,showWeekNumbers:r.props.showWeekNumbers,showYearDropdown:r.props.showYearDropdown,withPortal:r.props.withPortal,forceShowMonthNavigation:r.props.forceShowMonthNavigation,showDisabledMonthNavigation:r.props.showDisabledMonthNavigation,scrollableYearDropdown:r.props.scrollableYearDropdown,scrollableMonthYearDropdown:r.props.scrollableMonthYearDropdown,todayButton:r.props.todayButton,weekLabel:r.props.weekLabel,outsideClickIgnoreClass:Kn,fixedHeight:r.props.fixedHeight,monthsShown:r.props.monthsShown,monthSelectedIn:r.state.monthSelectedIn,onDropdownFocus:r.handleDropdownFocus,onMonthChange:r.props.onMonthChange,onYearChange:r.props.onYearChange,dayClassName:r.props.dayClassName,weekDayClassName:r.props.weekDayClassName,monthClassName:r.props.monthClassName,timeClassName:r.props.timeClassName,showTimeSelect:r.props.showTimeSelect,showTimeSelectOnly:r.props.showTimeSelectOnly,onTimeChange:r.handleTimeChange,timeFormat:r.props.timeFormat,timeIntervals:r.props.timeIntervals,minTime:r.props.minTime,maxTime:r.props.maxTime,excludeTimes:r.props.excludeTimes,filterTime:r.props.filterTime,timeCaption:r.props.timeCaption,className:r.props.calendarClassName,container:r.props.calendarContainer,yearItemNumber:r.props.yearItemNumber,yearDropdownItemNumber:r.props.yearDropdownItemNumber,previousMonthAriaLabel:r.props.previousMonthAriaLabel,previousMonthButtonLabel:r.props.previousMonthButtonLabel,nextMonthAriaLabel:r.props.nextMonthAriaLabel,nextMonthButtonLabel:r.props.nextMonthButtonLabel,previousYearAriaLabel:r.props.previousYearAriaLabel,previousYearButtonLabel:r.props.previousYearButtonLabel,nextYearAriaLabel:r.props.nextYearAriaLabel,nextYearButtonLabel:r.props.nextYearButtonLabel,timeInputLabel:r.props.timeInputLabel,disabledKeyboardNavigation:r.props.disabledKeyboardNavigation,renderCustomHeader:r.props.renderCustomHeader,popperProps:r.props.popperProps,renderDayContents:r.props.renderDayContents,onDayMouseEnter:r.props.onDayMouseEnter,onMonthMouseLeave:r.props.onMonthMouseLeave,selectsDisabledDaysInRange:r.props.selectsDisabledDaysInRange,showTimeInput:r.props.showTimeInput,showMonthYearPicker:r.props.showMonthYearPicker,showFullMonthYearPicker:r.props.showFullMonthYearPicker,showTwoColumnMonthYearPicker:r.props.showTwoColumnMonthYearPicker,showFourColumnMonthYearPicker:r.props.showFourColumnMonthYearPicker,showYearPicker:r.props.showYearPicker,showQuarterYearPicker:r.props.showQuarterYearPicker,showPopperArrow:r.props.showPopperArrow,excludeScrollbar:r.props.excludeScrollbar,handleOnKeyDown:r.props.onKeyDown,handleOnDayKeyDown:r.onDayKeyDown,isInputFocused:r.state.focused,customTimeInput:r.props.customTimeInput,setPreSelection:r.setPreSelection},r.props.children):null})),yt(_t(r),"renderDateInput",(function(){var e,t=pe.default(r.props.className,yt({},Kn,r.state.open)),n=r.props.customInput||ce.default.createElement("input",{type:"text"}),a=r.props.customInputRef||"ref",o="string"==typeof r.props.value?r.props.value:"string"==typeof r.state.inputValue?r.state.inputValue:r.props.selectsRange?function(e,t,n){if(!e)return"";var r=It(e,n),a=t?It(t,n):"";return"".concat(r," - ").concat(a)}(r.props.startDate,r.props.endDate,r.props):It(r.props.selected,r.props);return ce.default.cloneElement(n,(yt(e={},a,(function(e){r.input=e})),yt(e,"value",o),yt(e,"onBlur",r.handleBlur),yt(e,"onChange",r.handleChange),yt(e,"onClick",r.onInputClick),yt(e,"onFocus",r.handleFocus),yt(e,"onKeyDown",r.onInputKeyDown),yt(e,"id",r.props.id),yt(e,"name",r.props.name),yt(e,"autoFocus",r.props.autoFocus),yt(e,"placeholder",r.props.placeholderText),yt(e,"disabled",r.props.disabled),yt(e,"autoComplete",r.props.autoComplete),yt(e,"className",pe.default(n.props.className,t)),yt(e,"title",r.props.title),yt(e,"readOnly",r.props.readOnly),yt(e,"required",r.props.required),yt(e,"tabIndex",r.props.tabIndex),yt(e,"aria-describedby",r.props.ariaDescribedBy),yt(e,"aria-invalid",r.props.ariaInvalid),yt(e,"aria-labelledby",r.props.ariaLabelledBy),yt(e,"aria-required",r.props.ariaRequired),e))})),yt(_t(r),"renderClearButton",(function(){var e=r.props,t=e.isClearable,n=e.selected,a=e.startDate,o=e.endDate,l=e.clearButtonTitle,i=e.clearButtonClassName,u=void 0===i?"":i,s=e.ariaLabelClose,c=void 0===s?"Close":s;return!t||null==n&&null==a&&null==o?null:ce.default.createElement("button",{type:"button",className:"react-datepicker__close-icon ".concat(u).trim(),"aria-label":c,onClick:r.onClearClick,title:l,tabIndex:-1})})),r.state=r.calcInitialState(),r}return gt(n,[{key:"componentDidMount",value:function(){window.addEventListener("scroll",this.onScroll,!0)}},{key:"componentDidUpdate",value:function(e,t){var n,r;e.inline&&(n=e.selected,r=this.props.selected,n&&r?Ne.default(n)!==Ne.default(r)||Re.default(n)!==Re.default(r):n!==r)&&this.setPreSelection(this.props.selected),void 0!==this.state.monthSelectedIn&&e.monthsShown!==this.props.monthsShown&&this.setState({monthSelectedIn:0}),e.highlightDates!==this.props.highlightDates&&this.setState({highlightDates:wn(this.props.highlightDates)}),t.focused||Qt(e.selected,this.props.selected)||this.setState({inputValue:null}),t.open!==this.state.open&&(!1===t.open&&!0===this.state.open&&this.props.onCalendarOpen(),!0===t.open&&!1===this.state.open&&this.props.onCalendarClose())}},{key:"componentWillUnmount",value:function(){this.clearPreventFocusTimeout(),window.removeEventListener("scroll",this.onScroll,!0)}},{key:"renderInputContainer",value:function(){return ce.default.createElement("div",{className:"react-datepicker__input-container"},this.renderDateInput(),this.renderClearButton())}},{key:"render",value:function(){var e=this.renderCalendar();if(this.props.inline)return e;if(this.props.withPortal){var t=this.state.open?ce.default.createElement("div",{className:"react-datepicker__portal"},e):null;return this.state.open&&this.props.portalId&&(t=ce.default.createElement(Vn,{portalId:this.props.portalId,portalHost:this.props.portalHost},t)),ce.default.createElement("div",null,this.renderInputContainer(),t)}return ce.default.createElement(Qn,{className:this.props.popperClassName,wrapperClassName:this.props.wrapperClassName,hidePopper:!this.isCalendarOpen(),portalId:this.props.portalId,portalHost:this.props.portalHost,popperModifiers:this.props.popperModifiers,targetComponent:this.renderInputContainer(),popperContainer:this.props.popperContainer,popperComponent:e,popperPlacement:this.props.popperPlacement,popperProps:this.props.popperProps,popperOnKeyDown:this.onPopperKeyDown,enableTabLoop:this.props.enableTabLoop})}}],[{key:"defaultProps",get:function(){return{allowSameDay:!1,dateFormat:"MM/dd/yyyy",dateFormatCalendar:"LLLL yyyy",onChange:function(){},disabled:!1,disabledKeyboardNavigation:!1,dropdownMode:"scroll",onFocus:function(){},onBlur:function(){},onKeyDown:function(){},onInputClick:function(){},onSelect:function(){},onClickOutside:function(){},onMonthChange:function(){},onCalendarOpen:function(){},onCalendarClose:function(){},preventOpenOnFocus:!1,onYearChange:function(){},onInputError:function(){},monthsShown:1,readOnly:!1,withPortal:!1,selectsDisabledDaysInRange:!1,shouldCloseOnSelect:!0,showTimeSelect:!1,showTimeInput:!1,showPreviousMonths:!1,showMonthYearPicker:!1,showFullMonthYearPicker:!1,showTwoColumnMonthYearPicker:!1,showFourColumnMonthYearPicker:!1,showYearPicker:!1,showQuarterYearPicker:!1,strictParsing:!1,timeIntervals:30,timeCaption:"Time",previousMonthAriaLabel:"Previous Month",previousMonthButtonLabel:"Previous Month",nextMonthAriaLabel:"Next Month",nextMonthButtonLabel:"Next Month",previousYearAriaLabel:"Previous Year",previousYearButtonLabel:"Previous Year",nextYearAriaLabel:"Next Year",nextYearButtonLabel:"Next Year",timeInputLabel:"Time",enableTabLoop:!0,yearItemNumber:Tt,renderDayContents:function(e){return e},focusSelectedMonth:!1,showPopperArrow:!0,excludeScrollbar:!0,customTimeInput:null,calendarStartDay:void 0}}}]),n}(ce.default.Component),er="input",tr="navigate";e.CalendarContainer=Bn,e.default=Jn,e.getDefaultLocale=Gt,e.registerLocale=function(e,t){var n="undefined"!=typeof window?window:globalThis;n.__localeData__||(n.__localeData__={}),n.__localeData__[e]=t},e.setDefaultLocale=function(e){("undefined"!=typeof window?window:globalThis).__localeId__=e},Object.defineProperty(e,"__esModule",{value:!0})}(t,n(7294),n(5697),n(4184),n(5910),n(893),n(8296),n(7976),n(4803),n(6860),n(918),n(6563),n(2355),n(5001),n(5088),n(3151),n(8195),n(8990),n(3264),n(8720),n(8576),n(5340),n(3686),n(8021),n(1359),n(3122),n(1950),n(1061),n(4815),n(2465),n(9250),n(1896),n(9278),n(9605),n(27),n(7945),n(9919),n(7782),n(3160),n(1617),n(5662),n(2693),n(4570),n(1680),n(6247),n(8956),n(9324),n(5786),n(6438),n(4497),n(9098),n(5654),n(9712),n(2504),n(4260),n(9144),n(7622),n(9420),n(4065),n(7182),n(8949),n(3935),n(5455))},2732:(e,t,n)=>{"use strict";function r(e,t){switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});default:return t.date({width:"full"})}}function a(e,t){switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});default:return t.time({width:"full"})}}n.d(t,{Z:()=>o});const o={p:a,P:function(e,t){var n,o=e.match(/(P+)(p+)?/)||[],l=o[1],i=o[2];if(!i)return r(e,t);switch(l){case"P":n=t.dateTime({width:"short"});break;case"PP":n=t.dateTime({width:"medium"});break;case"PPP":n=t.dateTime({width:"long"});break;default:n=t.dateTime({width:"full"})}return n.replace("{{date}}",r(l,t)).replace("{{time}}",a(i,t))}}},5288:(e,t,n)=>{"use strict";function r(e){var t=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return t.setUTCFullYear(e.getFullYear()),e.getTime()-t.getTime()}n.d(t,{Z:()=>r})},3286:(e,t,n)=>{"use strict";n.d(t,{Z:()=>s});var r=n(9420),a=n(9158),o=n(3908),l=n(8642);function i(e){(0,l.Z)(1,arguments);var t=(0,o.Z)(e),n=new Date(0);n.setUTCFullYear(t,0,4),n.setUTCHours(0,0,0,0);var r=(0,a.Z)(n);return r}var u=6048e5;function s(e){(0,l.Z)(1,arguments);var t=(0,r.default)(e),n=(0,a.Z)(t).getTime()-i(t).getTime();return Math.round(n/u)+1}},3908:(e,t,n)=>{"use strict";n.d(t,{Z:()=>l});var r=n(9420),a=n(8642),o=n(9158);function l(e){(0,a.Z)(1,arguments);var t=(0,r.default)(e),n=t.getUTCFullYear(),l=new Date(0);l.setUTCFullYear(n+1,0,4),l.setUTCHours(0,0,0,0);var i=(0,o.Z)(l),u=new Date(0);u.setUTCFullYear(n,0,4),u.setUTCHours(0,0,0,0);var s=(0,o.Z)(u);return t.getTime()>=i.getTime()?n+1:t.getTime()>=s.getTime()?n:n-1}},2117:(e,t,n)=>{"use strict";n.d(t,{Z:()=>c});var r=n(9420),a=n(6773),o=n(4468),l=n(8642),i=n(565);function u(e,t){(0,l.Z)(1,arguments);var n=t||{},r=n.locale,u=r&&r.options&&r.options.firstWeekContainsDate,s=null==u?1:(0,i.Z)(u),c=null==n.firstWeekContainsDate?s:(0,i.Z)(n.firstWeekContainsDate),p=(0,o.Z)(e,t),d=new Date(0);d.setUTCFullYear(p,0,c),d.setUTCHours(0,0,0,0);var f=(0,a.Z)(d,t);return f}var s=6048e5;function c(e,t){(0,l.Z)(1,arguments);var n=(0,r.default)(e),o=(0,a.Z)(n,t).getTime()-u(n,t).getTime();return Math.round(o/s)+1}},4468:(e,t,n)=>{"use strict";n.d(t,{Z:()=>i});var r=n(9420),a=n(8642),o=n(6773),l=n(565);function i(e,t){(0,a.Z)(1,arguments);var n=(0,r.default)(e),i=n.getUTCFullYear(),u=t||{},s=u.locale,c=s&&s.options&&s.options.firstWeekContainsDate,p=null==c?1:(0,l.Z)(c),d=null==u.firstWeekContainsDate?p:(0,l.Z)(u.firstWeekContainsDate);if(!(d>=1&&d<=7))throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");var f=new Date(0);f.setUTCFullYear(i+1,0,d),f.setUTCHours(0,0,0,0);var h=(0,o.Z)(f,t),m=new Date(0);m.setUTCFullYear(i,0,d),m.setUTCHours(0,0,0,0);var g=(0,o.Z)(m,t);return n.getTime()>=h.getTime()?i+1:n.getTime()>=g.getTime()?i:i-1}},8607:(e,t,n)=>{"use strict";n.d(t,{Do:()=>l,Iu:()=>o,qp:()=>i});var r=["D","DD"],a=["YY","YYYY"];function o(e){return-1!==r.indexOf(e)}function l(e){return-1!==a.indexOf(e)}function i(e,t,n){if("YYYY"===e)throw new RangeError("Use `yyyy` instead of `YYYY` (in `".concat(t,"`) for formatting years to the input `").concat(n,"`; see: https://git.io/fxCyr"));if("YY"===e)throw new RangeError("Use `yy` instead of `YY` (in `".concat(t,"`) for formatting years to the input `").concat(n,"`; see: https://git.io/fxCyr"));if("D"===e)throw new RangeError("Use `d` instead of `D` (in `".concat(t,"`) for formatting days of the month to the input `").concat(n,"`; see: https://git.io/fxCyr"));if("DD"===e)throw new RangeError("Use `dd` instead of `DD` (in `".concat(t,"`) for formatting days of the month to the input `").concat(n,"`; see: https://git.io/fxCyr"))}},8642:(e,t,n)=>{"use strict";function r(e,t){if(t.length<e)throw new TypeError(e+" argument"+(e>1?"s":"")+" required, but only "+t.length+" present")}n.d(t,{Z:()=>r})},9158:(e,t,n)=>{"use strict";n.d(t,{Z:()=>o});var r=n(9420),a=n(8642);function o(e){(0,a.Z)(1,arguments);var t=1,n=(0,r.default)(e),o=n.getUTCDay(),l=(o<t?7:0)+o-t;return n.setUTCDate(n.getUTCDate()-l),n.setUTCHours(0,0,0,0),n}},6773:(e,t,n)=>{"use strict";n.d(t,{Z:()=>l});var r=n(9420),a=n(8642),o=n(565);function l(e,t){(0,a.Z)(1,arguments);var n=t||{},l=n.locale,i=l&&l.options&&l.options.weekStartsOn,u=null==i?0:(0,o.Z)(i),s=null==n.weekStartsOn?u:(0,o.Z)(n.weekStartsOn);if(!(s>=0&&s<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var c=(0,r.default)(e),p=c.getUTCDay(),d=(p<s?7:0)+p-s;return c.setUTCDate(c.getUTCDate()-d),c.setUTCHours(0,0,0,0),c}},565:(e,t,n)=>{"use strict";function r(e){if(null===e||!0===e||!1===e)return NaN;var t=Number(e);return isNaN(t)?t:t<0?Math.ceil(t):Math.floor(t)}n.d(t,{Z:()=>r})},6860:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>l});var r=n(565),a=n(9420),o=n(8642);function l(e,t){(0,o.Z)(2,arguments);var n=(0,a.default)(e),l=(0,r.Z)(t);return isNaN(l)?new Date(NaN):l?(n.setDate(n.getDate()+l),n):n}},4803:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>i});var r=n(565),a=n(8487),o=n(8642),l=36e5;function i(e,t){(0,o.Z)(2,arguments);var n=(0,r.Z)(t);return(0,a.Z)(e,n*l)}},8487:(e,t,n)=>{"use strict";n.d(t,{Z:()=>l});var r=n(565),a=n(9420),o=n(8642);function l(e,t){(0,o.Z)(2,arguments);var n=(0,a.default)(e).getTime(),l=(0,r.Z)(t);return new Date(n+l)}},7976:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>l});var r=n(565),a=n(8487),o=n(8642);function l(e,t){(0,o.Z)(2,arguments);var n=(0,r.Z)(t);return(0,a.Z)(e,6e4*n)}},6563:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>l});var r=n(565),a=n(9420),o=n(8642);function l(e,t){(0,o.Z)(2,arguments);var n=(0,a.default)(e),l=(0,r.Z)(t);if(isNaN(l))return new Date(NaN);if(!l)return n;var i=n.getDate(),u=new Date(n.getTime());u.setMonth(n.getMonth()+l+1,0);var s=u.getDate();return i>=s?u:(n.setFullYear(u.getFullYear(),u.getMonth(),i),n)}},918:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>l});var r=n(565),a=n(6860),o=n(8642);function l(e,t){(0,o.Z)(2,arguments);var n=(0,r.Z)(t),l=7*n;return(0,a.default)(e,l)}},2355:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>l});var r=n(565),a=n(6563),o=n(8642);function l(e,t){(0,o.Z)(2,arguments);var n=(0,r.Z)(t);return(0,a.default)(e,12*n)}},7782:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>i});var r=n(5288),a=n(2693),o=n(8642),l=864e5;function i(e,t){(0,o.Z)(2,arguments);var n=(0,a.default)(e),i=(0,a.default)(t),u=n.getTime()-(0,r.Z)(n),s=i.getTime()-(0,r.Z)(i);return Math.round((u-s)/l)}},3160:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>o});var r=n(9420),a=n(8642);function o(e,t){(0,a.Z)(2,arguments);var n=(0,r.default)(e),o=(0,r.default)(t),l=n.getFullYear()-o.getFullYear(),i=n.getMonth()-o.getMonth();return 12*l+i}},1617:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>i});var r=n(4570),a=n(5288),o=n(8642),l=6048e5;function i(e,t,n){(0,o.Z)(2,arguments);var i=(0,r.default)(e,n),u=(0,r.default)(t,n),s=i.getTime()-(0,a.Z)(i),c=u.getTime()-(0,a.Z)(u);return Math.round((s-c)/l)}},5662:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>o});var r=n(9420),a=n(8642);function o(e,t){(0,a.Z)(2,arguments);var n=(0,r.default)(e),o=(0,r.default)(t);return n.getFullYear()-o.getFullYear()}},9324:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>o});var r=n(9420),a=n(8642);function o(e){(0,a.Z)(1,arguments);var t=(0,r.default)(e);return t.setHours(23,59,59,999),t}},6438:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>o});var r=n(9420),a=n(8642);function o(e){(0,a.Z)(1,arguments);var t=(0,r.default)(e),n=t.getMonth();return t.setFullYear(t.getFullYear(),n+1,0),t.setHours(23,59,59,999),t}},5786:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>l});var r=n(9420),a=n(565),o=n(8642);function l(e,t){(0,o.Z)(1,arguments);var n=t||{},l=n.locale,i=l&&l.options&&l.options.weekStartsOn,u=null==i?0:(0,a.Z)(i),s=null==n.weekStartsOn?u:(0,a.Z)(n.weekStartsOn);if(!(s>=0&&s<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var c=(0,r.default)(e),p=c.getDay(),d=6+(p<s?-7:0)-(p-s);return c.setDate(c.getDate()+d),c.setHours(23,59,59,999),c}},8296:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>A});var r=n(893),a=n(1218),o=n(7464),l=n(9420),i=n(8642),u=864e5,s=n(3286),c=n(3908),p=n(2117),d=n(4468);function f(e,t){for(var n=e<0?"-":"",r=Math.abs(e).toString();r.length<t;)r="0"+r;return n+r}const h=function(e,t){var n=e.getUTCFullYear(),r=n>0?n:1-n;return f("yy"===t?r%100:r,t.length)},m=function(e,t){var n=e.getUTCMonth();return"M"===t?String(n+1):f(n+1,2)},g=function(e,t){return f(e.getUTCDate(),t.length)},y=function(e,t){return f(e.getUTCHours()%12||12,t.length)},v=function(e,t){return f(e.getUTCHours(),t.length)},b=function(e,t){return f(e.getUTCMinutes(),t.length)},w=function(e,t){return f(e.getUTCSeconds(),t.length)},E=function(e,t){var n=t.length,r=e.getUTCMilliseconds();return f(Math.floor(r*Math.pow(10,n-3)),t.length)};function _(e,t){var n=e>0?"-":"+",r=Math.abs(e),a=Math.floor(r/60),o=r%60;if(0===o)return n+String(a);var l=t||"";return n+String(a)+l+f(o,2)}function x(e,t){return e%60==0?(e>0?"-":"+")+f(Math.abs(e)/60,2):S(e,t)}function S(e,t){var n=t||"",r=e>0?"-":"+",a=Math.abs(e);return r+f(Math.floor(a/60),2)+n+f(a%60,2)}const k={G:function(e,t,n){var r=e.getUTCFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return n.era(r,{width:"abbreviated"});case"GGGGG":return n.era(r,{width:"narrow"});default:return n.era(r,{width:"wide"})}},y:function(e,t,n){if("yo"===t){var r=e.getUTCFullYear(),a=r>0?r:1-r;return n.ordinalNumber(a,{unit:"year"})}return h(e,t)},Y:function(e,t,n,r){var a=(0,d.Z)(e,r),o=a>0?a:1-a;return"YY"===t?f(o%100,2):"Yo"===t?n.ordinalNumber(o,{unit:"year"}):f(o,t.length)},R:function(e,t){return f((0,c.Z)(e),t.length)},u:function(e,t){return f(e.getUTCFullYear(),t.length)},Q:function(e,t,n){var r=Math.ceil((e.getUTCMonth()+1)/3);switch(t){case"Q":return String(r);case"QQ":return f(r,2);case"Qo":return n.ordinalNumber(r,{unit:"quarter"});case"QQQ":return n.quarter(r,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(r,{width:"narrow",context:"formatting"});default:return n.quarter(r,{width:"wide",context:"formatting"})}},q:function(e,t,n){var r=Math.ceil((e.getUTCMonth()+1)/3);switch(t){case"q":return String(r);case"qq":return f(r,2);case"qo":return n.ordinalNumber(r,{unit:"quarter"});case"qqq":return n.quarter(r,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(r,{width:"narrow",context:"standalone"});default:return n.quarter(r,{width:"wide",context:"standalone"})}},M:function(e,t,n){var r=e.getUTCMonth();switch(t){case"M":case"MM":return m(e,t);case"Mo":return n.ordinalNumber(r+1,{unit:"month"});case"MMM":return n.month(r,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(r,{width:"narrow",context:"formatting"});default:return n.month(r,{width:"wide",context:"formatting"})}},L:function(e,t,n){var r=e.getUTCMonth();switch(t){case"L":return String(r+1);case"LL":return f(r+1,2);case"Lo":return n.ordinalNumber(r+1,{unit:"month"});case"LLL":return n.month(r,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(r,{width:"narrow",context:"standalone"});default:return n.month(r,{width:"wide",context:"standalone"})}},w:function(e,t,n,r){var a=(0,p.Z)(e,r);return"wo"===t?n.ordinalNumber(a,{unit:"week"}):f(a,t.length)},I:function(e,t,n){var r=(0,s.Z)(e);return"Io"===t?n.ordinalNumber(r,{unit:"week"}):f(r,t.length)},d:function(e,t,n){return"do"===t?n.ordinalNumber(e.getUTCDate(),{unit:"date"}):g(e,t)},D:function(e,t,n){var r=function(e){(0,i.Z)(1,arguments);var t=(0,l.default)(e),n=t.getTime();t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0);var r=t.getTime(),a=n-r;return Math.floor(a/u)+1}(e);return"Do"===t?n.ordinalNumber(r,{unit:"dayOfYear"}):f(r,t.length)},E:function(e,t,n){var r=e.getUTCDay();switch(t){case"E":case"EE":case"EEE":return n.day(r,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(r,{width:"short",context:"formatting"});default:return n.day(r,{width:"wide",context:"formatting"})}},e:function(e,t,n,r){var a=e.getUTCDay(),o=(a-r.weekStartsOn+8)%7||7;switch(t){case"e":return String(o);case"ee":return f(o,2);case"eo":return n.ordinalNumber(o,{unit:"day"});case"eee":return n.day(a,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(a,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(a,{width:"short",context:"formatting"});default:return n.day(a,{width:"wide",context:"formatting"})}},c:function(e,t,n,r){var a=e.getUTCDay(),o=(a-r.weekStartsOn+8)%7||7;switch(t){case"c":return String(o);case"cc":return f(o,t.length);case"co":return n.ordinalNumber(o,{unit:"day"});case"ccc":return n.day(a,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(a,{width:"narrow",context:"standalone"});case"cccccc":return n.day(a,{width:"short",context:"standalone"});default:return n.day(a,{width:"wide",context:"standalone"})}},i:function(e,t,n){var r=e.getUTCDay(),a=0===r?7:r;switch(t){case"i":return String(a);case"ii":return f(a,t.length);case"io":return n.ordinalNumber(a,{unit:"day"});case"iii":return n.day(r,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(r,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(r,{width:"short",context:"formatting"});default:return n.day(r,{width:"wide",context:"formatting"})}},a:function(e,t,n){var r=e.getUTCHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(r,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(r,{width:"narrow",context:"formatting"});default:return n.dayPeriod(r,{width:"wide",context:"formatting"})}},b:function(e,t,n){var r,a=e.getUTCHours();switch(r=12===a?"noon":0===a?"midnight":a/12>=1?"pm":"am",t){case"b":case"bb":return n.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(r,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(r,{width:"narrow",context:"formatting"});default:return n.dayPeriod(r,{width:"wide",context:"formatting"})}},B:function(e,t,n){var r,a=e.getUTCHours();switch(r=a>=17?"evening":a>=12?"afternoon":a>=4?"morning":"night",t){case"B":case"BB":case"BBB":return n.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(r,{width:"narrow",context:"formatting"});default:return n.dayPeriod(r,{width:"wide",context:"formatting"})}},h:function(e,t,n){if("ho"===t){var r=e.getUTCHours()%12;return 0===r&&(r=12),n.ordinalNumber(r,{unit:"hour"})}return y(e,t)},H:function(e,t,n){return"Ho"===t?n.ordinalNumber(e.getUTCHours(),{unit:"hour"}):v(e,t)},K:function(e,t,n){var r=e.getUTCHours()%12;return"Ko"===t?n.ordinalNumber(r,{unit:"hour"}):f(r,t.length)},k:function(e,t,n){var r=e.getUTCHours();return 0===r&&(r=24),"ko"===t?n.ordinalNumber(r,{unit:"hour"}):f(r,t.length)},m:function(e,t,n){return"mo"===t?n.ordinalNumber(e.getUTCMinutes(),{unit:"minute"}):b(e,t)},s:function(e,t,n){return"so"===t?n.ordinalNumber(e.getUTCSeconds(),{unit:"second"}):w(e,t)},S:function(e,t){return E(e,t)},X:function(e,t,n,r){var a=(r._originalDate||e).getTimezoneOffset();if(0===a)return"Z";switch(t){case"X":return x(a);case"XXXX":case"XX":return S(a);default:return S(a,":")}},x:function(e,t,n,r){var a=(r._originalDate||e).getTimezoneOffset();switch(t){case"x":return x(a);case"xxxx":case"xx":return S(a);default:return S(a,":")}},O:function(e,t,n,r){var a=(r._originalDate||e).getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+_(a,":");default:return"GMT"+S(a,":")}},z:function(e,t,n,r){var a=(r._originalDate||e).getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+_(a,":");default:return"GMT"+S(a,":")}},t:function(e,t,n,r){var a=r._originalDate||e;return f(Math.floor(a.getTime()/1e3),t.length)},T:function(e,t,n,r){return f((r._originalDate||e).getTime(),t.length)}};var C=n(2732),D=n(5288),O=n(8607),P=n(565),T=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,N=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,M=/^'([^]*?)'?$/,R=/''/g,j=/[a-zA-Z]/;function A(e,t,n){(0,i.Z)(2,arguments);var u=String(t),s=n||{},c=s.locale||a.Z,p=c.options&&c.options.firstWeekContainsDate,d=null==p?1:(0,P.Z)(p),f=null==s.firstWeekContainsDate?d:(0,P.Z)(s.firstWeekContainsDate);if(!(f>=1&&f<=7))throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");var h=c.options&&c.options.weekStartsOn,m=null==h?0:(0,P.Z)(h),g=null==s.weekStartsOn?m:(0,P.Z)(s.weekStartsOn);if(!(g>=0&&g<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");if(!c.localize)throw new RangeError("locale must contain localize property");if(!c.formatLong)throw new RangeError("locale must contain formatLong property");var y=(0,l.default)(e);if(!(0,r.default)(y))throw new RangeError("Invalid time value");var v=(0,D.Z)(y),b=(0,o.Z)(y,v),w={firstWeekContainsDate:f,weekStartsOn:g,locale:c,_originalDate:y},E=u.match(N).map((function(e){var t=e[0];return"p"===t||"P"===t?(0,C.Z[t])(e,c.formatLong,w):e})).join("").match(T).map((function(n){if("''"===n)return"'";var r=n[0];if("'"===r)return I(n);var a=k[r];if(a)return!s.useAdditionalWeekYearTokens&&(0,O.Do)(n)&&(0,O.qp)(n,t,e),!s.useAdditionalDayOfYearTokens&&(0,O.Iu)(n)&&(0,O.qp)(n,t,e),a(b,n,c.localize,w);if(r.match(j))throw new RangeError("Format string contains an unescaped latin alphabet character `"+r+"`");return n})).join("");return E}function I(e){return e.match(M)[1].replace(R,"'")}},8021:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>o});var r=n(9420),a=n(8642);function o(e){(0,a.Z)(1,arguments);var t=(0,r.default)(e),n=t.getDate();return n}},3686:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>o});var r=n(9420),a=n(8642);function o(e){(0,a.Z)(1,arguments);var t=(0,r.default)(e),n=t.getDay();return n}},5340:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>o});var r=n(9420),a=n(8642);function o(e){(0,a.Z)(1,arguments);var t=(0,r.default)(e),n=t.getHours();return n}},1359:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>c});var r=n(9420),a=n(4570),o=n(8642);function l(e){return(0,o.Z)(1,arguments),(0,a.default)(e,{weekStartsOn:1})}function i(e){(0,o.Z)(1,arguments);var t=(0,r.default)(e),n=t.getFullYear(),a=new Date(0);a.setFullYear(n+1,0,4),a.setHours(0,0,0,0);var i=l(a),u=new Date(0);u.setFullYear(n,0,4),u.setHours(0,0,0,0);var s=l(u);return t.getTime()>=i.getTime()?n+1:t.getTime()>=s.getTime()?n:n-1}function u(e){(0,o.Z)(1,arguments);var t=i(e),n=new Date(0);n.setFullYear(t,0,4),n.setHours(0,0,0,0);var r=l(n);return r}var s=6048e5;function c(e){(0,o.Z)(1,arguments);var t=(0,r.default)(e),n=l(t).getTime()-u(t).getTime();return Math.round(n/s)+1}},8576:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>o});var r=n(9420),a=n(8642);function o(e){(0,a.Z)(1,arguments);var t=(0,r.default)(e),n=t.getMinutes();return n}},3122:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>o});var r=n(9420),a=n(8642);function o(e){(0,a.Z)(1,arguments);var t=(0,r.default)(e),n=t.getMonth();return n}},1950:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>o});var r=n(9420),a=n(8642);function o(e){(0,a.Z)(1,arguments);var t=(0,r.default)(e),n=Math.floor(t.getMonth()/3)+1;return n}},8720:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>o});var r=n(9420),a=n(8642);function o(e){(0,a.Z)(1,arguments);var t=(0,r.default)(e),n=t.getSeconds();return n}},4815:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>o});var r=n(9420),a=n(8642);function o(e){(0,a.Z)(1,arguments);var t=(0,r.default)(e),n=t.getTime();return n}},1061:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>o});var r=n(9420),a=n(8642);function o(e){return(0,a.Z)(1,arguments),(0,r.default)(e).getFullYear()}},4260:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>o});var r=n(9420),a=n(8642);function o(e,t){(0,a.Z)(2,arguments);var n=(0,r.default)(e),o=(0,r.default)(t);return n.getTime()>o.getTime()}},9144:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>o});var r=n(9420),a=n(8642);function o(e,t){(0,a.Z)(2,arguments);var n=(0,r.default)(e),o=(0,r.default)(t);return n.getTime()<o.getTime()}},5910:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>a});var r=n(8642);function a(e){return(0,r.Z)(1,arguments),e instanceof Date||"object"==typeof e&&"[object Date]"===Object.prototype.toString.call(e)}},4497:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>o});var r=n(9420),a=n(8642);function o(e,t){(0,a.Z)(2,arguments);var n=(0,r.default)(e),o=(0,r.default)(t);return n.getTime()===o.getTime()}},9098:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>o});var r=n(2693),a=n(8642);function o(e,t){(0,a.Z)(2,arguments);var n=(0,r.default)(e),o=(0,r.default)(t);return n.getTime()===o.getTime()}},5654:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>o});var r=n(9420),a=n(8642);function o(e,t){(0,a.Z)(2,arguments);var n=(0,r.default)(e),o=(0,r.default)(t);return n.getFullYear()===o.getFullYear()&&n.getMonth()===o.getMonth()}},2504:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>o});var r=n(6247),a=n(8642);function o(e,t){(0,a.Z)(2,arguments);var n=(0,r.default)(e),o=(0,r.default)(t);return n.getTime()===o.getTime()}},9712:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>o});var r=n(9420),a=n(8642);function o(e,t){(0,a.Z)(2,arguments);var n=(0,r.default)(e),o=(0,r.default)(t);return n.getFullYear()===o.getFullYear()}},893:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>l});var r=n(5910),a=n(9420),o=n(8642);function l(e){if((0,o.Z)(1,arguments),!(0,r.default)(e)&&"number"!=typeof e)return!1;var t=(0,a.default)(e);return!isNaN(Number(t))}},7622:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>o});var r=n(9420),a=n(8642);function o(e,t){(0,a.Z)(2,arguments);var n=(0,r.default)(e).getTime(),o=(0,r.default)(t.start).getTime(),l=(0,r.default)(t.end).getTime();if(!(o<=l))throw new RangeError("Invalid interval");return n>=o&&n<=l}},1218:(e,t,n)=>{"use strict";n.d(t,{Z:()=>d});var r={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}};function a(e){return function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.width?String(t.width):e.defaultWidth,r=e.formats[n]||e.formats[e.defaultWidth];return r}}var o,l={date:a({formats:{full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},defaultWidth:"full"}),time:a({formats:{full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},defaultWidth:"full"}),dateTime:a({formats:{full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},i={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"};function u(e){return function(t,n){var r,a=n||{};if("formatting"===(a.context?String(a.context):"standalone")&&e.formattingValues){var o=e.defaultFormattingWidth||e.defaultWidth,l=a.width?String(a.width):o;r=e.formattingValues[l]||e.formattingValues[o]}else{var i=e.defaultWidth,u=a.width?String(a.width):e.defaultWidth;r=e.values[u]||e.values[i]}return r[e.argumentCallback?e.argumentCallback(t):t]}}function s(e){return function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=n.width,a=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],o=t.match(a);if(!o)return null;var l,i=o[0],u=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],s=Array.isArray(u)?p(u,(function(e){return e.test(i)})):c(u,(function(e){return e.test(i)}));l=e.valueCallback?e.valueCallback(s):s,l=n.valueCallback?n.valueCallback(l):l;var d=t.slice(i.length);return{value:l,rest:d}}}function c(e,t){for(var n in e)if(e.hasOwnProperty(n)&&t(e[n]))return n}function p(e,t){for(var n=0;n<e.length;n++)if(t(e[n]))return n}const d={code:"en-US",formatDistance:function(e,t,n){var a,o=r[e];return a="string"==typeof o?o:1===t?o.one:o.other.replace("{{count}}",t.toString()),null!=n&&n.addSuffix?n.comparison&&n.comparison>0?"in "+a:a+" ago":a},formatLong:l,formatRelative:function(e,t,n,r){return i[e]},localize:{ordinalNumber:function(e,t){var n=Number(e),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},era:u({values:{narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},defaultWidth:"wide"}),quarter:u({values:{narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},defaultWidth:"wide",argumentCallback:function(e){return e-1}}),month:u({values:{narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},defaultWidth:"wide"}),day:u({values:{narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},defaultWidth:"wide"}),dayPeriod:u({values:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},defaultWidth:"wide",formattingValues:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},defaultFormattingWidth:"wide"})},match:{ordinalNumber:(o={matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:function(e){return parseInt(e,10)}},function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=e.match(o.matchPattern);if(!n)return null;var r=n[0],a=e.match(o.parsePattern);if(!a)return null;var l=o.valueCallback?o.valueCallback(a[0]):a[0];l=t.valueCallback?t.valueCallback(l):l;var i=e.slice(r.length);return{value:l,rest:i}}),era:s({matchPatterns:{narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},defaultMatchWidth:"wide",parsePatterns:{any:[/^b/i,/^(a|c)/i]},defaultParseWidth:"any"}),quarter:s({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},defaultMatchWidth:"wide",parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:"any",valueCallback:function(e){return e+1}}),month:s({matchPatterns:{narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},defaultParseWidth:"any"}),day:s({matchPatterns:{narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},defaultParseWidth:"any"}),dayPeriod:s({matchPatterns:{narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},defaultMatchWidth:"any",parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},defaultParseWidth:"any"})},options:{weekStartsOn:0,firstWeekContainsDate:1}}},9919:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>o});var r=n(9420),a=n(8642);function o(e){var t,n;if((0,a.Z)(1,arguments),e&&"function"==typeof e.forEach)t=e;else{if("object"!=typeof e||null===e)return new Date(NaN);t=Array.prototype.slice.call(e)}return t.forEach((function(e){var t=(0,r.default)(e);(void 0===n||n<t||isNaN(Number(t)))&&(n=t)})),n||new Date(NaN)}},7945:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>o});var r=n(9420),a=n(8642);function o(e){var t,n;if((0,a.Z)(1,arguments),e&&"function"==typeof e.forEach)t=e;else{if("object"!=typeof e||null===e)return new Date(NaN);t=Array.prototype.slice.call(e)}return t.forEach((function(e){var t=(0,r.default)(e);(void 0===n||n>t||isNaN(t.getDate()))&&(n=t)})),n||new Date(NaN)}},4065:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>oe});var r=n(1218),a=n(7464),o=n(9420);function l(e,t){if(null==e)throw new TypeError("assign requires that input parameter not be null or undefined");for(var n in t=t||{})Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}var i=n(2732),u=n(5288),s=n(8607),c=n(565),p=n(4468),d=n(8642);function f(e,t,n){(0,d.Z)(2,arguments);var r=n||{},a=r.locale,l=a&&a.options&&a.options.weekStartsOn,i=null==l?0:(0,c.Z)(l),u=null==r.weekStartsOn?i:(0,c.Z)(r.weekStartsOn);if(!(u>=0&&u<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var s=(0,o.default)(e),p=(0,c.Z)(t),f=s.getUTCDay(),h=p%7,m=(h+7)%7,g=(m<u?7:0)+p-f;return s.setUTCDate(s.getUTCDate()+g),s}var h=n(3286),m=n(2117),g=n(9158),y=n(6773),v=/^(1[0-2]|0?\d)/,b=/^(3[0-1]|[0-2]?\d)/,w=/^(36[0-6]|3[0-5]\d|[0-2]?\d?\d)/,E=/^(5[0-3]|[0-4]?\d)/,_=/^(2[0-3]|[0-1]?\d)/,x=/^(2[0-4]|[0-1]?\d)/,S=/^(1[0-1]|0?\d)/,k=/^(1[0-2]|0?\d)/,C=/^[0-5]?\d/,D=/^[0-5]?\d/,O=/^\d/,P=/^\d{1,2}/,T=/^\d{1,3}/,N=/^\d{1,4}/,M=/^-?\d+/,R=/^-?\d/,j=/^-?\d{1,2}/,A=/^-?\d{1,3}/,I=/^-?\d{1,4}/,F=/^([+-])(\d{2})(\d{2})?|Z/,L=/^([+-])(\d{2})(\d{2})|Z/,U=/^([+-])(\d{2})(\d{2})((\d{2}))?|Z/,z=/^([+-])(\d{2}):(\d{2})|Z/,Y=/^([+-])(\d{2}):(\d{2})(:(\d{2}))?|Z/;function W(e,t,n){var r=t.match(e);if(!r)return null;var a=parseInt(r[0],10);return{value:n?n(a):a,rest:t.slice(r[0].length)}}function B(e,t){var n=t.match(e);return n?"Z"===n[0]?{value:0,rest:t.slice(1)}:{value:("+"===n[1]?1:-1)*(36e5*(n[2]?parseInt(n[2],10):0)+6e4*(n[3]?parseInt(n[3],10):0)+1e3*(n[5]?parseInt(n[5],10):0)),rest:t.slice(n[0].length)}:null}function H(e,t){return W(M,e,t)}function q(e,t,n){switch(e){case 1:return W(O,t,n);case 2:return W(P,t,n);case 3:return W(T,t,n);case 4:return W(N,t,n);default:return W(new RegExp("^\\d{1,"+e+"}"),t,n)}}function V(e,t,n){switch(e){case 1:return W(R,t,n);case 2:return W(j,t,n);case 3:return W(A,t,n);case 4:return W(I,t,n);default:return W(new RegExp("^-?\\d{1,"+e+"}"),t,n)}}function $(e){switch(e){case"morning":return 4;case"evening":return 17;case"pm":case"noon":case"afternoon":return 12;default:return 0}}function Z(e,t){var n,r=t>0,a=r?t:1-t;if(a<=50)n=e||100;else{var o=a+50;n=e+100*Math.floor(o/100)-(e>=o%100?100:0)}return r?n:1-n}var Q=[31,28,31,30,31,30,31,31,30,31,30,31],K=[31,29,31,30,31,30,31,31,30,31,30,31];function G(e){return e%400==0||e%4==0&&e%100!=0}const X={G:{priority:140,parse:function(e,t,n,r){switch(t){case"G":case"GG":case"GGG":return n.era(e,{width:"abbreviated"})||n.era(e,{width:"narrow"});case"GGGGG":return n.era(e,{width:"narrow"});default:return n.era(e,{width:"wide"})||n.era(e,{width:"abbreviated"})||n.era(e,{width:"narrow"})}},set:function(e,t,n,r){return t.era=n,e.setUTCFullYear(n,0,1),e.setUTCHours(0,0,0,0),e},incompatibleTokens:["R","u","t","T"]},y:{priority:130,parse:function(e,t,n,r){var a=function(e){return{year:e,isTwoDigitYear:"yy"===t}};switch(t){case"y":return q(4,e,a);case"yo":return n.ordinalNumber(e,{unit:"year",valueCallback:a});default:return q(t.length,e,a)}},validate:function(e,t,n){return t.isTwoDigitYear||t.year>0},set:function(e,t,n,r){var a=e.getUTCFullYear();if(n.isTwoDigitYear){var o=Z(n.year,a);return e.setUTCFullYear(o,0,1),e.setUTCHours(0,0,0,0),e}var l="era"in t&&1!==t.era?1-n.year:n.year;return e.setUTCFullYear(l,0,1),e.setUTCHours(0,0,0,0),e},incompatibleTokens:["Y","R","u","w","I","i","e","c","t","T"]},Y:{priority:130,parse:function(e,t,n,r){var a=function(e){return{year:e,isTwoDigitYear:"YY"===t}};switch(t){case"Y":return q(4,e,a);case"Yo":return n.ordinalNumber(e,{unit:"year",valueCallback:a});default:return q(t.length,e,a)}},validate:function(e,t,n){return t.isTwoDigitYear||t.year>0},set:function(e,t,n,r){var a=(0,p.Z)(e,r);if(n.isTwoDigitYear){var o=Z(n.year,a);return e.setUTCFullYear(o,0,r.firstWeekContainsDate),e.setUTCHours(0,0,0,0),(0,y.Z)(e,r)}var l="era"in t&&1!==t.era?1-n.year:n.year;return e.setUTCFullYear(l,0,r.firstWeekContainsDate),e.setUTCHours(0,0,0,0),(0,y.Z)(e,r)},incompatibleTokens:["y","R","u","Q","q","M","L","I","d","D","i","t","T"]},R:{priority:130,parse:function(e,t,n,r){return V("R"===t?4:t.length,e)},set:function(e,t,n,r){var a=new Date(0);return a.setUTCFullYear(n,0,4),a.setUTCHours(0,0,0,0),(0,g.Z)(a)},incompatibleTokens:["G","y","Y","u","Q","q","M","L","w","d","D","e","c","t","T"]},u:{priority:130,parse:function(e,t,n,r){return V("u"===t?4:t.length,e)},set:function(e,t,n,r){return e.setUTCFullYear(n,0,1),e.setUTCHours(0,0,0,0),e},incompatibleTokens:["G","y","Y","R","w","I","i","e","c","t","T"]},Q:{priority:120,parse:function(e,t,n,r){switch(t){case"Q":case"QQ":return q(t.length,e);case"Qo":return n.ordinalNumber(e,{unit:"quarter"});case"QQQ":return n.quarter(e,{width:"abbreviated",context:"formatting"})||n.quarter(e,{width:"narrow",context:"formatting"});case"QQQQQ":return n.quarter(e,{width:"narrow",context:"formatting"});default:return n.quarter(e,{width:"wide",context:"formatting"})||n.quarter(e,{width:"abbreviated",context:"formatting"})||n.quarter(e,{width:"narrow",context:"formatting"})}},validate:function(e,t,n){return t>=1&&t<=4},set:function(e,t,n,r){return e.setUTCMonth(3*(n-1),1),e.setUTCHours(0,0,0,0),e},incompatibleTokens:["Y","R","q","M","L","w","I","d","D","i","e","c","t","T"]},q:{priority:120,parse:function(e,t,n,r){switch(t){case"q":case"qq":return q(t.length,e);case"qo":return n.ordinalNumber(e,{unit:"quarter"});case"qqq":return n.quarter(e,{width:"abbreviated",context:"standalone"})||n.quarter(e,{width:"narrow",context:"standalone"});case"qqqqq":return n.quarter(e,{width:"narrow",context:"standalone"});default:return n.quarter(e,{width:"wide",context:"standalone"})||n.quarter(e,{width:"abbreviated",context:"standalone"})||n.quarter(e,{width:"narrow",context:"standalone"})}},validate:function(e,t,n){return t>=1&&t<=4},set:function(e,t,n,r){return e.setUTCMonth(3*(n-1),1),e.setUTCHours(0,0,0,0),e},incompatibleTokens:["Y","R","Q","M","L","w","I","d","D","i","e","c","t","T"]},M:{priority:110,parse:function(e,t,n,r){var a=function(e){return e-1};switch(t){case"M":return W(v,e,a);case"MM":return q(2,e,a);case"Mo":return n.ordinalNumber(e,{unit:"month",valueCallback:a});case"MMM":return n.month(e,{width:"abbreviated",context:"formatting"})||n.month(e,{width:"narrow",context:"formatting"});case"MMMMM":return n.month(e,{width:"narrow",context:"formatting"});default:return n.month(e,{width:"wide",context:"formatting"})||n.month(e,{width:"abbreviated",context:"formatting"})||n.month(e,{width:"narrow",context:"formatting"})}},validate:function(e,t,n){return t>=0&&t<=11},set:function(e,t,n,r){return e.setUTCMonth(n,1),e.setUTCHours(0,0,0,0),e},incompatibleTokens:["Y","R","q","Q","L","w","I","D","i","e","c","t","T"]},L:{priority:110,parse:function(e,t,n,r){var a=function(e){return e-1};switch(t){case"L":return W(v,e,a);case"LL":return q(2,e,a);case"Lo":return n.ordinalNumber(e,{unit:"month",valueCallback:a});case"LLL":return n.month(e,{width:"abbreviated",context:"standalone"})||n.month(e,{width:"narrow",context:"standalone"});case"LLLLL":return n.month(e,{width:"narrow",context:"standalone"});default:return n.month(e,{width:"wide",context:"standalone"})||n.month(e,{width:"abbreviated",context:"standalone"})||n.month(e,{width:"narrow",context:"standalone"})}},validate:function(e,t,n){return t>=0&&t<=11},set:function(e,t,n,r){return e.setUTCMonth(n,1),e.setUTCHours(0,0,0,0),e},incompatibleTokens:["Y","R","q","Q","M","w","I","D","i","e","c","t","T"]},w:{priority:100,parse:function(e,t,n,r){switch(t){case"w":return W(E,e);case"wo":return n.ordinalNumber(e,{unit:"week"});default:return q(t.length,e)}},validate:function(e,t,n){return t>=1&&t<=53},set:function(e,t,n,r){return(0,y.Z)(function(e,t,n){(0,d.Z)(2,arguments);var r=(0,o.default)(e),a=(0,c.Z)(t),l=(0,m.Z)(r,n)-a;return r.setUTCDate(r.getUTCDate()-7*l),r}(e,n,r),r)},incompatibleTokens:["y","R","u","q","Q","M","L","I","d","D","i","t","T"]},I:{priority:100,parse:function(e,t,n,r){switch(t){case"I":return W(E,e);case"Io":return n.ordinalNumber(e,{unit:"week"});default:return q(t.length,e)}},validate:function(e,t,n){return t>=1&&t<=53},set:function(e,t,n,r){return(0,g.Z)(function(e,t){(0,d.Z)(2,arguments);var n=(0,o.default)(e),r=(0,c.Z)(t),a=(0,h.Z)(n)-r;return n.setUTCDate(n.getUTCDate()-7*a),n}(e,n,r),r)},incompatibleTokens:["y","Y","u","q","Q","M","L","w","d","D","e","c","t","T"]},d:{priority:90,subPriority:1,parse:function(e,t,n,r){switch(t){case"d":return W(b,e);case"do":return n.ordinalNumber(e,{unit:"date"});default:return q(t.length,e)}},validate:function(e,t,n){var r=G(e.getUTCFullYear()),a=e.getUTCMonth();return r?t>=1&&t<=K[a]:t>=1&&t<=Q[a]},set:function(e,t,n,r){return e.setUTCDate(n),e.setUTCHours(0,0,0,0),e},incompatibleTokens:["Y","R","q","Q","w","I","D","i","e","c","t","T"]},D:{priority:90,subPriority:1,parse:function(e,t,n,r){switch(t){case"D":case"DD":return W(w,e);case"Do":return n.ordinalNumber(e,{unit:"date"});default:return q(t.length,e)}},validate:function(e,t,n){return G(e.getUTCFullYear())?t>=1&&t<=366:t>=1&&t<=365},set:function(e,t,n,r){return e.setUTCMonth(0,n),e.setUTCHours(0,0,0,0),e},incompatibleTokens:["Y","R","q","Q","M","L","w","I","d","E","i","e","c","t","T"]},E:{priority:90,parse:function(e,t,n,r){switch(t){case"E":case"EE":case"EEE":return n.day(e,{width:"abbreviated",context:"formatting"})||n.day(e,{width:"short",context:"formatting"})||n.day(e,{width:"narrow",context:"formatting"});case"EEEEE":return n.day(e,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(e,{width:"short",context:"formatting"})||n.day(e,{width:"narrow",context:"formatting"});default:return n.day(e,{width:"wide",context:"formatting"})||n.day(e,{width:"abbreviated",context:"formatting"})||n.day(e,{width:"short",context:"formatting"})||n.day(e,{width:"narrow",context:"formatting"})}},validate:function(e,t,n){return t>=0&&t<=6},set:function(e,t,n,r){return(e=f(e,n,r)).setUTCHours(0,0,0,0),e},incompatibleTokens:["D","i","e","c","t","T"]},e:{priority:90,parse:function(e,t,n,r){var a=function(e){var t=7*Math.floor((e-1)/7);return(e+r.weekStartsOn+6)%7+t};switch(t){case"e":case"ee":return q(t.length,e,a);case"eo":return n.ordinalNumber(e,{unit:"day",valueCallback:a});case"eee":return n.day(e,{width:"abbreviated",context:"formatting"})||n.day(e,{width:"short",context:"formatting"})||n.day(e,{width:"narrow",context:"formatting"});case"eeeee":return n.day(e,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(e,{width:"short",context:"formatting"})||n.day(e,{width:"narrow",context:"formatting"});default:return n.day(e,{width:"wide",context:"formatting"})||n.day(e,{width:"abbreviated",context:"formatting"})||n.day(e,{width:"short",context:"formatting"})||n.day(e,{width:"narrow",context:"formatting"})}},validate:function(e,t,n){return t>=0&&t<=6},set:function(e,t,n,r){return(e=f(e,n,r)).setUTCHours(0,0,0,0),e},incompatibleTokens:["y","R","u","q","Q","M","L","I","d","D","E","i","c","t","T"]},c:{priority:90,parse:function(e,t,n,r){var a=function(e){var t=7*Math.floor((e-1)/7);return(e+r.weekStartsOn+6)%7+t};switch(t){case"c":case"cc":return q(t.length,e,a);case"co":return n.ordinalNumber(e,{unit:"day",valueCallback:a});case"ccc":return n.day(e,{width:"abbreviated",context:"standalone"})||n.day(e,{width:"short",context:"standalone"})||n.day(e,{width:"narrow",context:"standalone"});case"ccccc":return n.day(e,{width:"narrow",context:"standalone"});case"cccccc":return n.day(e,{width:"short",context:"standalone"})||n.day(e,{width:"narrow",context:"standalone"});default:return n.day(e,{width:"wide",context:"standalone"})||n.day(e,{width:"abbreviated",context:"standalone"})||n.day(e,{width:"short",context:"standalone"})||n.day(e,{width:"narrow",context:"standalone"})}},validate:function(e,t,n){return t>=0&&t<=6},set:function(e,t,n,r){return(e=f(e,n,r)).setUTCHours(0,0,0,0),e},incompatibleTokens:["y","R","u","q","Q","M","L","I","d","D","E","i","e","t","T"]},i:{priority:90,parse:function(e,t,n,r){var a=function(e){return 0===e?7:e};switch(t){case"i":case"ii":return q(t.length,e);case"io":return n.ordinalNumber(e,{unit:"day"});case"iii":return n.day(e,{width:"abbreviated",context:"formatting",valueCallback:a})||n.day(e,{width:"short",context:"formatting",valueCallback:a})||n.day(e,{width:"narrow",context:"formatting",valueCallback:a});case"iiiii":return n.day(e,{width:"narrow",context:"formatting",valueCallback:a});case"iiiiii":return n.day(e,{width:"short",context:"formatting",valueCallback:a})||n.day(e,{width:"narrow",context:"formatting",valueCallback:a});default:return n.day(e,{width:"wide",context:"formatting",valueCallback:a})||n.day(e,{width:"abbreviated",context:"formatting",valueCallback:a})||n.day(e,{width:"short",context:"formatting",valueCallback:a})||n.day(e,{width:"narrow",context:"formatting",valueCallback:a})}},validate:function(e,t,n){return t>=1&&t<=7},set:function(e,t,n,r){return e=function(e,t){(0,d.Z)(2,arguments);var n=(0,c.Z)(t);n%7==0&&(n-=7);var r=1,a=(0,o.default)(e),l=a.getUTCDay(),i=((n%7+7)%7<r?7:0)+n-l;return a.setUTCDate(a.getUTCDate()+i),a}(e,n,r),e.setUTCHours(0,0,0,0),e},incompatibleTokens:["y","Y","u","q","Q","M","L","w","d","D","E","e","c","t","T"]},a:{priority:80,parse:function(e,t,n,r){switch(t){case"a":case"aa":case"aaa":return n.dayPeriod(e,{width:"abbreviated",context:"formatting"})||n.dayPeriod(e,{width:"narrow",context:"formatting"});case"aaaaa":return n.dayPeriod(e,{width:"narrow",context:"formatting"});default:return n.dayPeriod(e,{width:"wide",context:"formatting"})||n.dayPeriod(e,{width:"abbreviated",context:"formatting"})||n.dayPeriod(e,{width:"narrow",context:"formatting"})}},set:function(e,t,n,r){return e.setUTCHours($(n),0,0,0),e},incompatibleTokens:["b","B","H","k","t","T"]},b:{priority:80,parse:function(e,t,n,r){switch(t){case"b":case"bb":case"bbb":return n.dayPeriod(e,{width:"abbreviated",context:"formatting"})||n.dayPeriod(e,{width:"narrow",context:"formatting"});case"bbbbb":return n.dayPeriod(e,{width:"narrow",context:"formatting"});default:return n.dayPeriod(e,{width:"wide",context:"formatting"})||n.dayPeriod(e,{width:"abbreviated",context:"formatting"})||n.dayPeriod(e,{width:"narrow",context:"formatting"})}},set:function(e,t,n,r){return e.setUTCHours($(n),0,0,0),e},incompatibleTokens:["a","B","H","k","t","T"]},B:{priority:80,parse:function(e,t,n,r){switch(t){case"B":case"BB":case"BBB":return n.dayPeriod(e,{width:"abbreviated",context:"formatting"})||n.dayPeriod(e,{width:"narrow",context:"formatting"});case"BBBBB":return n.dayPeriod(e,{width:"narrow",context:"formatting"});default:return n.dayPeriod(e,{width:"wide",context:"formatting"})||n.dayPeriod(e,{width:"abbreviated",context:"formatting"})||n.dayPeriod(e,{width:"narrow",context:"formatting"})}},set:function(e,t,n,r){return e.setUTCHours($(n),0,0,0),e},incompatibleTokens:["a","b","t","T"]},h:{priority:70,parse:function(e,t,n,r){switch(t){case"h":return W(k,e);case"ho":return n.ordinalNumber(e,{unit:"hour"});default:return q(t.length,e)}},validate:function(e,t,n){return t>=1&&t<=12},set:function(e,t,n,r){var a=e.getUTCHours()>=12;return a&&n<12?e.setUTCHours(n+12,0,0,0):a||12!==n?e.setUTCHours(n,0,0,0):e.setUTCHours(0,0,0,0),e},incompatibleTokens:["H","K","k","t","T"]},H:{priority:70,parse:function(e,t,n,r){switch(t){case"H":return W(_,e);case"Ho":return n.ordinalNumber(e,{unit:"hour"});default:return q(t.length,e)}},validate:function(e,t,n){return t>=0&&t<=23},set:function(e,t,n,r){return e.setUTCHours(n,0,0,0),e},incompatibleTokens:["a","b","h","K","k","t","T"]},K:{priority:70,parse:function(e,t,n,r){switch(t){case"K":return W(S,e);case"Ko":return n.ordinalNumber(e,{unit:"hour"});default:return q(t.length,e)}},validate:function(e,t,n){return t>=0&&t<=11},set:function(e,t,n,r){return e.getUTCHours()>=12&&n<12?e.setUTCHours(n+12,0,0,0):e.setUTCHours(n,0,0,0),e},incompatibleTokens:["h","H","k","t","T"]},k:{priority:70,parse:function(e,t,n,r){switch(t){case"k":return W(x,e);case"ko":return n.ordinalNumber(e,{unit:"hour"});default:return q(t.length,e)}},validate:function(e,t,n){return t>=1&&t<=24},set:function(e,t,n,r){var a=n<=24?n%24:n;return e.setUTCHours(a,0,0,0),e},incompatibleTokens:["a","b","h","H","K","t","T"]},m:{priority:60,parse:function(e,t,n,r){switch(t){case"m":return W(C,e);case"mo":return n.ordinalNumber(e,{unit:"minute"});default:return q(t.length,e)}},validate:function(e,t,n){return t>=0&&t<=59},set:function(e,t,n,r){return e.setUTCMinutes(n,0,0),e},incompatibleTokens:["t","T"]},s:{priority:50,parse:function(e,t,n,r){switch(t){case"s":return W(D,e);case"so":return n.ordinalNumber(e,{unit:"second"});default:return q(t.length,e)}},validate:function(e,t,n){return t>=0&&t<=59},set:function(e,t,n,r){return e.setUTCSeconds(n,0),e},incompatibleTokens:["t","T"]},S:{priority:30,parse:function(e,t,n,r){return q(t.length,e,(function(e){return Math.floor(e*Math.pow(10,3-t.length))}))},set:function(e,t,n,r){return e.setUTCMilliseconds(n),e},incompatibleTokens:["t","T"]},X:{priority:10,parse:function(e,t,n,r){switch(t){case"X":return B(F,e);case"XX":return B(L,e);case"XXXX":return B(U,e);case"XXXXX":return B(Y,e);default:return B(z,e)}},set:function(e,t,n,r){return t.timestampIsSet?e:new Date(e.getTime()-n)},incompatibleTokens:["t","T","x"]},x:{priority:10,parse:function(e,t,n,r){switch(t){case"x":return B(F,e);case"xx":return B(L,e);case"xxxx":return B(U,e);case"xxxxx":return B(Y,e);default:return B(z,e)}},set:function(e,t,n,r){return t.timestampIsSet?e:new Date(e.getTime()-n)},incompatibleTokens:["t","T","X"]},t:{priority:40,parse:function(e,t,n,r){return H(e)},set:function(e,t,n,r){return[new Date(1e3*n),{timestampIsSet:!0}]},incompatibleTokens:"*"},T:{priority:20,parse:function(e,t,n,r){return H(e)},set:function(e,t,n,r){return[new Date(n),{timestampIsSet:!0}]},incompatibleTokens:"*"}};var J=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,ee=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,te=/^'([^]*?)'?$/,ne=/''/g,re=/\S/,ae=/[a-zA-Z]/;function oe(e,t,n,p){(0,d.Z)(3,arguments);var f=String(e),h=String(t),m=p||{},g=m.locale||r.Z;if(!g.match)throw new RangeError("locale must contain match property");var y=g.options&&g.options.firstWeekContainsDate,v=null==y?1:(0,c.Z)(y),b=null==m.firstWeekContainsDate?v:(0,c.Z)(m.firstWeekContainsDate);if(!(b>=1&&b<=7))throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");var w=g.options&&g.options.weekStartsOn,E=null==w?0:(0,c.Z)(w),_=null==m.weekStartsOn?E:(0,c.Z)(m.weekStartsOn);if(!(_>=0&&_<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");if(""===h)return""===f?(0,o.default)(n):new Date(NaN);var x,S={firstWeekContainsDate:b,weekStartsOn:_,locale:g},k=[{priority:10,subPriority:-1,set:le,index:0}],C=h.match(ee).map((function(e){var t=e[0];return"p"===t||"P"===t?(0,i.Z[t])(e,g.formatLong,S):e})).join("").match(J),D=[];for(x=0;x<C.length;x++){var O=C[x];!m.useAdditionalWeekYearTokens&&(0,s.Do)(O)&&(0,s.qp)(O,h,e),!m.useAdditionalDayOfYearTokens&&(0,s.Iu)(O)&&(0,s.qp)(O,h,e);var P=O[0],T=X[P];if(T){var N=T.incompatibleTokens;if(Array.isArray(N)){for(var M=void 0,R=0;R<D.length;R++){var j=D[R].token;if(-1!==N.indexOf(j)||j===P){M=D[R];break}}if(M)throw new RangeError("The format string mustn't contain `".concat(M.fullToken,"` and `").concat(O,"` at the same time"))}else if("*"===T.incompatibleTokens&&D.length)throw new RangeError("The format string mustn't contain `".concat(O,"` and any other token at the same time"));D.push({token:P,fullToken:O});var A=T.parse(f,O,g.match,S);if(!A)return new Date(NaN);k.push({priority:T.priority,subPriority:T.subPriority||0,set:T.set,validate:T.validate,value:A.value,index:k.length}),f=A.rest}else{if(P.match(ae))throw new RangeError("Format string contains an unescaped latin alphabet character `"+P+"`");if("''"===O?O="'":"'"===P&&(O=ie(O)),0!==f.indexOf(O))return new Date(NaN);f=f.slice(O.length)}}if(f.length>0&&re.test(f))return new Date(NaN);var I=k.map((function(e){return e.priority})).sort((function(e,t){return t-e})).filter((function(e,t,n){return n.indexOf(e)===t})).map((function(e){return k.filter((function(t){return t.priority===e})).sort((function(e,t){return t.subPriority-e.subPriority}))})).map((function(e){return e[0]})),F=(0,o.default)(n);if(isNaN(F))return new Date(NaN);var L=(0,a.Z)(F,(0,u.Z)(F)),U={};for(x=0;x<I.length;x++){var z=I[x];if(z.validate&&!z.validate(L,z.value,S))return new Date(NaN);var Y=z.set(L,U,z.value,S);Y[0]?(L=Y[0],l(U,Y[1])):L=Y}return L}function le(e,t){if(t.timestampIsSet)return e;var n=new Date(0);return n.setFullYear(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()),n.setHours(e.getUTCHours(),e.getUTCMinutes(),e.getUTCSeconds(),e.getUTCMilliseconds()),n}function ie(e){return e.match(te)[1].replace(ne,"'")}},7182:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>l}),Math.pow(10,8);var r=36e5,a=n(8642),o=n(565);function l(e,t){(0,a.Z)(1,arguments);var n=t||{},r=null==n.additionalDigits?2:(0,o.Z)(n.additionalDigits);if(2!==r&&1!==r&&0!==r)throw new RangeError("additionalDigits must be 0, 1 or 2");if("string"!=typeof e&&"[object String]"!==Object.prototype.toString.call(e))return new Date(NaN);var l,i=p(e);if(i.date){var u=d(i.date,r);l=f(u.restDateString,u.year)}if(!l||isNaN(l.getTime()))return new Date(NaN);var s,c=l.getTime(),h=0;if(i.time&&(h=m(i.time),isNaN(h)))return new Date(NaN);if(!i.timezone){var g=new Date(c+h),v=new Date(0);return v.setFullYear(g.getUTCFullYear(),g.getUTCMonth(),g.getUTCDate()),v.setHours(g.getUTCHours(),g.getUTCMinutes(),g.getUTCSeconds(),g.getUTCMilliseconds()),v}return s=y(i.timezone),isNaN(s)?new Date(NaN):new Date(c+h+s)}var i={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},u=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,s=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,c=/^([+-])(\d{2})(?::?(\d{2}))?$/;function p(e){var t,n={},r=e.split(i.dateTimeDelimiter);if(r.length>2)return n;if(/:/.test(r[0])?t=r[0]:(n.date=r[0],t=r[1],i.timeZoneDelimiter.test(n.date)&&(n.date=e.split(i.timeZoneDelimiter)[0],t=e.substr(n.date.length,e.length))),t){var a=i.timezone.exec(t);a?(n.time=t.replace(a[1],""),n.timezone=a[1]):n.time=t}return n}function d(e,t){var n=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+t)+"})|(\\d{2}|[+-]\\d{"+(2+t)+"})$)"),r=e.match(n);if(!r)return{year:NaN,restDateString:""};var a=r[1]?parseInt(r[1]):null,o=r[2]?parseInt(r[2]):null;return{year:null===o?a:100*o,restDateString:e.slice((r[1]||r[2]).length)}}function f(e,t){if(null===t)return new Date(NaN);var n=e.match(u);if(!n)return new Date(NaN);var r=!!n[4],a=h(n[1]),o=h(n[2])-1,l=h(n[3]),i=h(n[4]),s=h(n[5])-1;if(r)return function(e,t,n){return t>=1&&t<=53&&n>=0&&n<=6}(0,i,s)?function(e,t,n){var r=new Date(0);r.setUTCFullYear(e,0,4);var a=7*(t-1)+n+1-(r.getUTCDay()||7);return r.setUTCDate(r.getUTCDate()+a),r}(t,i,s):new Date(NaN);var c=new Date(0);return function(e,t,n){return t>=0&&t<=11&&n>=1&&n<=(v[t]||(b(e)?29:28))}(t,o,l)&&function(e,t){return t>=1&&t<=(b(e)?366:365)}(t,a)?(c.setUTCFullYear(t,o,Math.max(a,l)),c):new Date(NaN)}function h(e){return e?parseInt(e):1}function m(e){var t=e.match(s);if(!t)return NaN;var n=g(t[1]),a=g(t[2]),o=g(t[3]);return function(e,t,n){return 24===e?0===t&&0===n:n>=0&&n<60&&t>=0&&t<60&&e>=0&&e<25}(n,a,o)?n*r+6e4*a+1e3*o:NaN}function g(e){return e&&parseFloat(e.replace(",","."))||0}function y(e){if("Z"===e)return 0;var t=e.match(c);if(!t)return 0;var n="+"===t[1]?-1:1,a=parseInt(t[2]),o=t[3]&&parseInt(t[3])||0;return function(e,t){return t>=0&&t<=59}(0,o)?n*(a*r+6e4*o):NaN}var v=[31,null,31,30,31,30,31,31,30,31,30,31];function b(e){return e%400==0||e%4==0&&e%100!=0}},1896:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>l});var r=n(565),a=n(9420),o=n(8642);function l(e,t){(0,o.Z)(2,arguments);var n=(0,a.default)(e),l=(0,r.Z)(t);return n.setHours(l),n}},9250:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>l});var r=n(565),a=n(9420),o=n(8642);function l(e,t){(0,o.Z)(2,arguments);var n=(0,a.default)(e),l=(0,r.Z)(t);return n.setMinutes(l),n}},9278:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>i});var r=n(565),a=n(9420),o=n(8642);function l(e){(0,o.Z)(1,arguments);var t=(0,a.default)(e),n=t.getFullYear(),r=t.getMonth(),l=new Date(0);return l.setFullYear(n,r+1,0),l.setHours(0,0,0,0),l.getDate()}function i(e,t){(0,o.Z)(2,arguments);var n=(0,a.default)(e),i=(0,r.Z)(t),u=n.getFullYear(),s=n.getDate(),c=new Date(0);c.setFullYear(u,i,15),c.setHours(0,0,0,0);var p=l(c);return n.setMonth(i,Math.min(s,p)),n}},9605:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>i});var r=n(565),a=n(9420),o=n(9278),l=n(8642);function i(e,t){(0,l.Z)(2,arguments);var n=(0,a.default)(e),i=(0,r.Z)(t),u=Math.floor(n.getMonth()/3)+1,s=i-u;return(0,o.default)(n,n.getMonth()+3*s)}},2465:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>l});var r=n(565),a=n(9420),o=n(8642);function l(e,t){(0,o.Z)(2,arguments);var n=(0,a.default)(e),l=(0,r.Z)(t);return n.setSeconds(l),n}},27:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>l});var r=n(565),a=n(9420),o=n(8642);function l(e,t){(0,o.Z)(2,arguments);var n=(0,a.default)(e),l=(0,r.Z)(t);return isNaN(n.getTime())?new Date(NaN):(n.setFullYear(l),n)}},2693:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>o});var r=n(9420),a=n(8642);function o(e){(0,a.Z)(1,arguments);var t=(0,r.default)(e);return t.setHours(0,0,0,0),t}},1680:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>o});var r=n(9420),a=n(8642);function o(e){(0,a.Z)(1,arguments);var t=(0,r.default)(e);return t.setDate(1),t.setHours(0,0,0,0),t}},6247:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>o});var r=n(9420),a=n(8642);function o(e){(0,a.Z)(1,arguments);var t=(0,r.default)(e),n=t.getMonth(),o=n-n%3;return t.setMonth(o,1),t.setHours(0,0,0,0),t}},4570:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>l});var r=n(9420),a=n(565),o=n(8642);function l(e,t){(0,o.Z)(1,arguments);var n=t||{},l=n.locale,i=l&&l.options&&l.options.weekStartsOn,u=null==i?0:(0,a.Z)(i),s=null==n.weekStartsOn?u:(0,a.Z)(n.weekStartsOn);if(!(s>=0&&s<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var c=(0,r.default)(e),p=c.getDay(),d=(p<s?7:0)+p-s;return c.setDate(c.getDate()-d),c.setHours(0,0,0,0),c}},8956:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>o});var r=n(9420),a=n(8642);function o(e){(0,a.Z)(1,arguments);var t=(0,r.default)(e),n=new Date(0);return n.setFullYear(t.getFullYear(),0,1),n.setHours(0,0,0,0),n}},3151:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>l});var r=n(565),a=n(6860),o=n(8642);function l(e,t){(0,o.Z)(2,arguments);var n=(0,r.Z)(t);return(0,a.default)(e,-n)}},5088:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>l});var r=n(565),a=n(4803),o=n(8642);function l(e,t){(0,o.Z)(2,arguments);var n=(0,r.Z)(t);return(0,a.default)(e,-n)}},7464:(e,t,n)=>{"use strict";n.d(t,{Z:()=>l});var r=n(565),a=n(8487),o=n(8642);function l(e,t){(0,o.Z)(2,arguments);var n=(0,r.Z)(t);return(0,a.Z)(e,-n)}},5001:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>l});var r=n(565),a=n(7976),o=n(8642);function l(e,t){(0,o.Z)(2,arguments);var n=(0,r.Z)(t);return(0,a.default)(e,-n)}},8990:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>l});var r=n(565),a=n(6563),o=n(8642);function l(e,t){(0,o.Z)(2,arguments);var n=(0,r.Z)(t);return(0,a.default)(e,-n)}},8195:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>l});var r=n(565),a=n(918),o=n(8642);function l(e,t){(0,o.Z)(2,arguments);var n=(0,r.Z)(t);return(0,a.default)(e,-n)}},3264:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>l});var r=n(565),a=n(2355),o=n(8642);function l(e,t){(0,o.Z)(2,arguments);var n=(0,r.Z)(t);return(0,a.default)(e,-n)}},9420:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>a});var r=n(8642);function a(e){(0,r.Z)(1,arguments);var t=Object.prototype.toString.call(e);return e instanceof Date||"object"==typeof e&&"[object Date]"===t?new Date(e.getTime()):"number"==typeof e||"[object Number]"===t?new Date(e):("string"!=typeof e&&"[object String]"!==t||"undefined"==typeof console||(console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://git.io/fjule"),console.warn((new Error).stack)),new Date(NaN))}},4448:(e,t,n)=>{"use strict";var r=n(7294),a=n(4142);function o(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n]);return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var l=new Set,i={};function u(e,t){s(e,t),s(e+"Capture",t)}function s(e,t){for(i[e]=t,e=0;e<t.length;e++)l.add(t[e])}var c=!("undefined"==typeof window||void 0===window.document||void 0===window.document.createElement),p=Object.prototype.hasOwnProperty,d=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,f={},h={};function m(e,t,n,r,a,o,l){this.acceptsBooleans=2===t||3===t||4===t,this.attributeName=r,this.attributeNamespace=a,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=o,this.removeEmptyString=l}var g={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach((function(e){g[e]=new m(e,0,!1,e,null,!1,!1)})),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach((function(e){var t=e[0];g[t]=new m(t,1,!1,e[1],null,!1,!1)})),["contentEditable","draggable","spellCheck","value"].forEach((function(e){g[e]=new m(e,2,!1,e.toLowerCase(),null,!1,!1)})),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach((function(e){g[e]=new m(e,2,!1,e,null,!1,!1)})),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach((function(e){g[e]=new m(e,3,!1,e.toLowerCase(),null,!1,!1)})),["checked","multiple","muted","selected"].forEach((function(e){g[e]=new m(e,3,!0,e,null,!1,!1)})),["capture","download"].forEach((function(e){g[e]=new m(e,4,!1,e,null,!1,!1)})),["cols","rows","size","span"].forEach((function(e){g[e]=new m(e,6,!1,e,null,!1,!1)})),["rowSpan","start"].forEach((function(e){g[e]=new m(e,5,!1,e.toLowerCase(),null,!1,!1)}));var y=/[\-:]([a-z])/g;function v(e){return e[1].toUpperCase()}function b(e,t,n,r){var a=g.hasOwnProperty(t)?g[t]:null;(null!==a?0!==a.type:r||!(2<t.length)||"o"!==t[0]&&"O"!==t[0]||"n"!==t[1]&&"N"!==t[1])&&(function(e,t,n,r){if(null==t||function(e,t,n,r){if(null!==n&&0===n.type)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return!r&&(null!==n?!n.acceptsBooleans:"data-"!==(e=e.toLowerCase().slice(0,5))&&"aria-"!==e);default:return!1}}(e,t,n,r))return!0;if(r)return!1;if(null!==n)switch(n.type){case 3:return!t;case 4:return!1===t;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}(t,n,a,r)&&(n=null),r||null===a?function(e){return!!p.call(h,e)||!p.call(f,e)&&(d.test(e)?h[e]=!0:(f[e]=!0,!1))}(t)&&(null===n?e.removeAttribute(t):e.setAttribute(t,""+n)):a.mustUseProperty?e[a.propertyName]=null===n?3!==a.type&&"":n:(t=a.attributeName,r=a.attributeNamespace,null===n?e.removeAttribute(t):(n=3===(a=a.type)||4===a&&!0===n?"":""+n,r?e.setAttributeNS(r,t,n):e.setAttribute(t,n))))}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach((function(e){var t=e.replace(y,v);g[t]=new m(t,1,!1,e,null,!1,!1)})),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach((function(e){var t=e.replace(y,v);g[t]=new m(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)})),["xml:base","xml:lang","xml:space"].forEach((function(e){var t=e.replace(y,v);g[t]=new m(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)})),["tabIndex","crossOrigin"].forEach((function(e){g[e]=new m(e,1,!1,e.toLowerCase(),null,!1,!1)})),g.xlinkHref=new m("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach((function(e){g[e]=new m(e,1,!1,e.toLowerCase(),null,!0,!0)}));var w=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,E=Symbol.for("react.element"),_=Symbol.for("react.portal"),x=Symbol.for("react.fragment"),S=Symbol.for("react.strict_mode"),k=Symbol.for("react.profiler"),C=Symbol.for("react.provider"),D=Symbol.for("react.context"),O=Symbol.for("react.forward_ref"),P=Symbol.for("react.suspense"),T=Symbol.for("react.suspense_list"),N=Symbol.for("react.memo"),M=Symbol.for("react.lazy");Symbol.for("react.scope"),Symbol.for("react.debug_trace_mode");var R=Symbol.for("react.offscreen");Symbol.for("react.legacy_hidden"),Symbol.for("react.cache"),Symbol.for("react.tracing_marker");var j=Symbol.iterator;function A(e){return null===e||"object"!=typeof e?null:"function"==typeof(e=j&&e[j]||e["@@iterator"])?e:null}var I,F=Object.assign;function L(e){if(void 0===I)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);I=t&&t[1]||""}return"\n"+I+e}var U=!1;function z(e,t){if(!e||U)return"";U=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(t)if(t=function(){throw Error()},Object.defineProperty(t.prototype,"props",{set:function(){throw Error()}}),"object"==typeof Reflect&&Reflect.construct){try{Reflect.construct(t,[])}catch(e){var r=e}Reflect.construct(e,[],t)}else{try{t.call()}catch(e){r=e}e.call(t.prototype)}else{try{throw Error()}catch(e){r=e}e()}}catch(t){if(t&&r&&"string"==typeof t.stack){for(var a=t.stack.split("\n"),o=r.stack.split("\n"),l=a.length-1,i=o.length-1;1<=l&&0<=i&&a[l]!==o[i];)i--;for(;1<=l&&0<=i;l--,i--)if(a[l]!==o[i]){if(1!==l||1!==i)do{if(l--,0>--i||a[l]!==o[i]){var u="\n"+a[l].replace(" at new "," at ");return e.displayName&&u.includes("<anonymous>")&&(u=u.replace("<anonymous>",e.displayName)),u}}while(1<=l&&0<=i);break}}}finally{U=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?L(e):""}function Y(e){switch(e.tag){case 5:return L(e.type);case 16:return L("Lazy");case 13:return L("Suspense");case 19:return L("SuspenseList");case 0:case 2:case 15:return z(e.type,!1);case 11:return z(e.type.render,!1);case 1:return z(e.type,!0);default:return""}}function W(e){if(null==e)return null;if("function"==typeof e)return e.displayName||e.name||null;if("string"==typeof e)return e;switch(e){case x:return"Fragment";case _:return"Portal";case k:return"Profiler";case S:return"StrictMode";case P:return"Suspense";case T:return"SuspenseList"}if("object"==typeof e)switch(e.$$typeof){case D:return(e.displayName||"Context")+".Consumer";case C:return(e._context.displayName||"Context")+".Provider";case O:var t=e.render;return(e=e.displayName)||(e=""!==(e=t.displayName||t.name||"")?"ForwardRef("+e+")":"ForwardRef"),e;case N:return null!==(t=e.displayName||null)?t:W(e.type)||"Memo";case M:t=e._payload,e=e._init;try{return W(e(t))}catch(e){}}return null}function B(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=(e=t.render).displayName||e.name||"",t.displayName||(""!==e?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return W(t);case 8:return t===S?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if("function"==typeof t)return t.displayName||t.name||null;if("string"==typeof t)return t}return null}function H(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":case"object":return e;default:return""}}function q(e){var t=e.type;return(e=e.nodeName)&&"input"===e.toLowerCase()&&("checkbox"===t||"radio"===t)}function V(e){e._valueTracker||(e._valueTracker=function(e){var t=q(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&void 0!==n&&"function"==typeof n.get&&"function"==typeof n.set){var a=n.get,o=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return a.call(this)},set:function(e){r=""+e,o.call(this,e)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(e){r=""+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}(e))}function $(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=q(e)?e.checked?"true":"false":e.value),(e=r)!==n&&(t.setValue(e),!0)}function Z(e){if(void 0===(e=e||("undefined"!=typeof document?document:void 0)))return null;try{return e.activeElement||e.body}catch(t){return e.body}}function Q(e,t){var n=t.checked;return F({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:null!=n?n:e._wrapperState.initialChecked})}function K(e,t){var n=null==t.defaultValue?"":t.defaultValue,r=null!=t.checked?t.checked:t.defaultChecked;n=H(null!=t.value?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:"checkbox"===t.type||"radio"===t.type?null!=t.checked:null!=t.value}}function G(e,t){null!=(t=t.checked)&&b(e,"checked",t,!1)}function X(e,t){G(e,t);var n=H(t.value),r=t.type;if(null!=n)"number"===r?(0===n&&""===e.value||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if("submit"===r||"reset"===r)return void e.removeAttribute("value");t.hasOwnProperty("value")?ee(e,t.type,n):t.hasOwnProperty("defaultValue")&&ee(e,t.type,H(t.defaultValue)),null==t.checked&&null!=t.defaultChecked&&(e.defaultChecked=!!t.defaultChecked)}function J(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!("submit"!==r&&"reset"!==r||void 0!==t.value&&null!==t.value))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}""!==(n=e.name)&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,""!==n&&(e.name=n)}function ee(e,t,n){"number"===t&&Z(e.ownerDocument)===e||(null==n?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var te=Array.isArray;function ne(e,t,n,r){if(e=e.options,t){t={};for(var a=0;a<n.length;a++)t["$"+n[a]]=!0;for(n=0;n<e.length;n++)a=t.hasOwnProperty("$"+e[n].value),e[n].selected!==a&&(e[n].selected=a),a&&r&&(e[n].defaultSelected=!0)}else{for(n=""+H(n),t=null,a=0;a<e.length;a++){if(e[a].value===n)return e[a].selected=!0,void(r&&(e[a].defaultSelected=!0));null!==t||e[a].disabled||(t=e[a])}null!==t&&(t.selected=!0)}}function re(e,t){if(null!=t.dangerouslySetInnerHTML)throw Error(o(91));return F({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function ae(e,t){var n=t.value;if(null==n){if(n=t.children,t=t.defaultValue,null!=n){if(null!=t)throw Error(o(92));if(te(n)){if(1<n.length)throw Error(o(93));n=n[0]}t=n}null==t&&(t=""),n=t}e._wrapperState={initialValue:H(n)}}function oe(e,t){var n=H(t.value),r=H(t.defaultValue);null!=n&&((n=""+n)!==e.value&&(e.value=n),null==t.defaultValue&&e.defaultValue!==n&&(e.defaultValue=n)),null!=r&&(e.defaultValue=""+r)}function le(e){var t=e.textContent;t===e._wrapperState.initialValue&&""!==t&&null!==t&&(e.value=t)}function ie(e){switch(e){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function ue(e,t){return null==e||"http://www.w3.org/1999/xhtml"===e?ie(t):"http://www.w3.org/2000/svg"===e&&"foreignObject"===t?"http://www.w3.org/1999/xhtml":e}var se,ce,pe=(ce=function(e,t){if("http://www.w3.org/2000/svg"!==e.namespaceURI||"innerHTML"in e)e.innerHTML=t;else{for((se=se||document.createElement("div")).innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=se.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}},"undefined"!=typeof MSApp&&MSApp.execUnsafeLocalFunction?function(e,t,n,r){MSApp.execUnsafeLocalFunction((function(){return ce(e,t)}))}:ce);function de(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&3===n.nodeType)return void(n.nodeValue=t)}e.textContent=t}var fe={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},he=["Webkit","ms","Moz","O"];function me(e,t,n){return null==t||"boolean"==typeof t||""===t?"":n||"number"!=typeof t||0===t||fe.hasOwnProperty(e)&&fe[e]?(""+t).trim():t+"px"}function ge(e,t){for(var n in e=e.style,t)if(t.hasOwnProperty(n)){var r=0===n.indexOf("--"),a=me(n,t[n],r);"float"===n&&(n="cssFloat"),r?e.setProperty(n,a):e[n]=a}}Object.keys(fe).forEach((function(e){he.forEach((function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),fe[t]=fe[e]}))}));var ye=F({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function ve(e,t){if(t){if(ye[e]&&(null!=t.children||null!=t.dangerouslySetInnerHTML))throw Error(o(137,e));if(null!=t.dangerouslySetInnerHTML){if(null!=t.children)throw Error(o(60));if("object"!=typeof t.dangerouslySetInnerHTML||!("__html"in t.dangerouslySetInnerHTML))throw Error(o(61))}if(null!=t.style&&"object"!=typeof t.style)throw Error(o(62))}}function be(e,t){if(-1===e.indexOf("-"))return"string"==typeof t.is;switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var we=null;function Ee(e){return(e=e.target||e.srcElement||window).correspondingUseElement&&(e=e.correspondingUseElement),3===e.nodeType?e.parentNode:e}var _e=null,xe=null,Se=null;function ke(e){if(e=wa(e)){if("function"!=typeof _e)throw Error(o(280));var t=e.stateNode;t&&(t=_a(t),_e(e.stateNode,e.type,t))}}function Ce(e){xe?Se?Se.push(e):Se=[e]:xe=e}function De(){if(xe){var e=xe,t=Se;if(Se=xe=null,ke(e),t)for(e=0;e<t.length;e++)ke(t[e])}}function Oe(e,t){return e(t)}function Pe(){}var Te=!1;function Ne(e,t,n){if(Te)return e(t,n);Te=!0;try{return Oe(e,t,n)}finally{Te=!1,(null!==xe||null!==Se)&&(Pe(),De())}}function Me(e,t){var n=e.stateNode;if(null===n)return null;var r=_a(n);if(null===r)return null;n=r[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(r=!r.disabled)||(r=!("button"===(e=e.type)||"input"===e||"select"===e||"textarea"===e)),e=!r;break e;default:e=!1}if(e)return null;if(n&&"function"!=typeof n)throw Error(o(231,t,typeof n));return n}var Re=!1;if(c)try{var je={};Object.defineProperty(je,"passive",{get:function(){Re=!0}}),window.addEventListener("test",je,je),window.removeEventListener("test",je,je)}catch(ce){Re=!1}function Ae(e,t,n,r,a,o,l,i,u){var s=Array.prototype.slice.call(arguments,3);try{t.apply(n,s)}catch(e){this.onError(e)}}var Ie=!1,Fe=null,Le=!1,Ue=null,ze={onError:function(e){Ie=!0,Fe=e}};function Ye(e,t,n,r,a,o,l,i,u){Ie=!1,Fe=null,Ae.apply(ze,arguments)}function We(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do{0!=(4098&(t=e).flags)&&(n=t.return),e=t.return}while(e)}return 3===t.tag?n:null}function Be(e){if(13===e.tag){var t=e.memoizedState;if(null===t&&null!==(e=e.alternate)&&(t=e.memoizedState),null!==t)return t.dehydrated}return null}function He(e){if(We(e)!==e)throw Error(o(188))}function qe(e){return null!==(e=function(e){var t=e.alternate;if(!t){if(null===(t=We(e)))throw Error(o(188));return t!==e?null:e}for(var n=e,r=t;;){var a=n.return;if(null===a)break;var l=a.alternate;if(null===l){if(null!==(r=a.return)){n=r;continue}break}if(a.child===l.child){for(l=a.child;l;){if(l===n)return He(a),e;if(l===r)return He(a),t;l=l.sibling}throw Error(o(188))}if(n.return!==r.return)n=a,r=l;else{for(var i=!1,u=a.child;u;){if(u===n){i=!0,n=a,r=l;break}if(u===r){i=!0,r=a,n=l;break}u=u.sibling}if(!i){for(u=l.child;u;){if(u===n){i=!0,n=l,r=a;break}if(u===r){i=!0,r=l,n=a;break}u=u.sibling}if(!i)throw Error(o(189))}}if(n.alternate!==r)throw Error(o(190))}if(3!==n.tag)throw Error(o(188));return n.stateNode.current===n?e:t}(e))?Ve(e):null}function Ve(e){if(5===e.tag||6===e.tag)return e;for(e=e.child;null!==e;){var t=Ve(e);if(null!==t)return t;e=e.sibling}return null}var $e=a.unstable_scheduleCallback,Ze=a.unstable_cancelCallback,Qe=a.unstable_shouldYield,Ke=a.unstable_requestPaint,Ge=a.unstable_now,Xe=a.unstable_getCurrentPriorityLevel,Je=a.unstable_ImmediatePriority,et=a.unstable_UserBlockingPriority,tt=a.unstable_NormalPriority,nt=a.unstable_LowPriority,rt=a.unstable_IdlePriority,at=null,ot=null,lt=Math.clz32?Math.clz32:function(e){return 0==(e>>>=0)?32:31-(it(e)/ut|0)|0},it=Math.log,ut=Math.LN2,st=64,ct=4194304;function pt(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return 4194240&e;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return 130023424&e;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function dt(e,t){var n=e.pendingLanes;if(0===n)return 0;var r=0,a=e.suspendedLanes,o=e.pingedLanes,l=268435455&n;if(0!==l){var i=l&~a;0!==i?r=pt(i):0!=(o&=l)&&(r=pt(o))}else 0!=(l=n&~a)?r=pt(l):0!==o&&(r=pt(o));if(0===r)return 0;if(0!==t&&t!==r&&0==(t&a)&&((a=r&-r)>=(o=t&-t)||16===a&&0!=(4194240&o)))return t;if(0!=(4&r)&&(r|=16&n),0!==(t=e.entangledLanes))for(e=e.entanglements,t&=r;0<t;)a=1<<(n=31-lt(t)),r|=e[n],t&=~a;return r}function ft(e,t){switch(e){case 1:case 2:case 4:return t+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;default:return-1}}function ht(e){return 0!=(e=-1073741825&e.pendingLanes)?e:1073741824&e?1073741824:0}function mt(){var e=st;return 0==(4194240&(st<<=1))&&(st=64),e}function gt(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function yt(e,t,n){e.pendingLanes|=t,536870912!==t&&(e.suspendedLanes=0,e.pingedLanes=0),(e=e.eventTimes)[t=31-lt(t)]=n}function vt(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-lt(n),a=1<<r;a&t|e[r]&t&&(e[r]|=t),n&=~a}}var bt=0;function wt(e){return 1<(e&=-e)?4<e?0!=(268435455&e)?16:536870912:4:1}var Et,_t,xt,St,kt,Ct=!1,Dt=[],Ot=null,Pt=null,Tt=null,Nt=new Map,Mt=new Map,Rt=[],jt="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function At(e,t){switch(e){case"focusin":case"focusout":Ot=null;break;case"dragenter":case"dragleave":Pt=null;break;case"mouseover":case"mouseout":Tt=null;break;case"pointerover":case"pointerout":Nt.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Mt.delete(t.pointerId)}}function It(e,t,n,r,a,o){return null===e||e.nativeEvent!==o?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:o,targetContainers:[a]},null!==t&&null!==(t=wa(t))&&_t(t),e):(e.eventSystemFlags|=r,t=e.targetContainers,null!==a&&-1===t.indexOf(a)&&t.push(a),e)}function Ft(e){var t=ba(e.target);if(null!==t){var n=We(t);if(null!==n)if(13===(t=n.tag)){if(null!==(t=Be(n)))return e.blockedOn=t,void kt(e.priority,(function(){xt(n)}))}else if(3===t&&n.stateNode.current.memoizedState.isDehydrated)return void(e.blockedOn=3===n.tag?n.stateNode.containerInfo:null)}e.blockedOn=null}function Lt(e){if(null!==e.blockedOn)return!1;for(var t=e.targetContainers;0<t.length;){var n=Qt(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(null!==n)return null!==(t=wa(n))&&_t(t),e.blockedOn=n,!1;var r=new(n=e.nativeEvent).constructor(n.type,n);we=r,n.target.dispatchEvent(r),we=null,t.shift()}return!0}function Ut(e,t,n){Lt(e)&&n.delete(t)}function zt(){Ct=!1,null!==Ot&&Lt(Ot)&&(Ot=null),null!==Pt&&Lt(Pt)&&(Pt=null),null!==Tt&&Lt(Tt)&&(Tt=null),Nt.forEach(Ut),Mt.forEach(Ut)}function Yt(e,t){e.blockedOn===t&&(e.blockedOn=null,Ct||(Ct=!0,a.unstable_scheduleCallback(a.unstable_NormalPriority,zt)))}function Wt(e){function t(t){return Yt(t,e)}if(0<Dt.length){Yt(Dt[0],e);for(var n=1;n<Dt.length;n++){var r=Dt[n];r.blockedOn===e&&(r.blockedOn=null)}}for(null!==Ot&&Yt(Ot,e),null!==Pt&&Yt(Pt,e),null!==Tt&&Yt(Tt,e),Nt.forEach(t),Mt.forEach(t),n=0;n<Rt.length;n++)(r=Rt[n]).blockedOn===e&&(r.blockedOn=null);for(;0<Rt.length&&null===(n=Rt[0]).blockedOn;)Ft(n),null===n.blockedOn&&Rt.shift()}var Bt=w.ReactCurrentBatchConfig,Ht=!0;function qt(e,t,n,r){var a=bt,o=Bt.transition;Bt.transition=null;try{bt=1,$t(e,t,n,r)}finally{bt=a,Bt.transition=o}}function Vt(e,t,n,r){var a=bt,o=Bt.transition;Bt.transition=null;try{bt=4,$t(e,t,n,r)}finally{bt=a,Bt.transition=o}}function $t(e,t,n,r){if(Ht){var a=Qt(e,t,n,r);if(null===a)qr(e,t,r,Zt,n),At(e,r);else if(function(e,t,n,r,a){switch(t){case"focusin":return Ot=It(Ot,e,t,n,r,a),!0;case"dragenter":return Pt=It(Pt,e,t,n,r,a),!0;case"mouseover":return Tt=It(Tt,e,t,n,r,a),!0;case"pointerover":var o=a.pointerId;return Nt.set(o,It(Nt.get(o)||null,e,t,n,r,a)),!0;case"gotpointercapture":return o=a.pointerId,Mt.set(o,It(Mt.get(o)||null,e,t,n,r,a)),!0}return!1}(a,e,t,n,r))r.stopPropagation();else if(At(e,r),4&t&&-1<jt.indexOf(e)){for(;null!==a;){var o=wa(a);if(null!==o&&Et(o),null===(o=Qt(e,t,n,r))&&qr(e,t,r,Zt,n),o===a)break;a=o}null!==a&&r.stopPropagation()}else qr(e,t,r,null,n)}}var Zt=null;function Qt(e,t,n,r){if(Zt=null,null!==(e=ba(e=Ee(r))))if(null===(t=We(e)))e=null;else if(13===(n=t.tag)){if(null!==(e=Be(t)))return e;e=null}else if(3===n){if(t.stateNode.current.memoizedState.isDehydrated)return 3===t.tag?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null);return Zt=e,null}function Kt(e){switch(e){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(Xe()){case Je:return 1;case et:return 4;case tt:case nt:return 16;case rt:return 536870912;default:return 16}default:return 16}}var Gt=null,Xt=null,Jt=null;function en(){if(Jt)return Jt;var e,t,n=Xt,r=n.length,a="value"in Gt?Gt.value:Gt.textContent,o=a.length;for(e=0;e<r&&n[e]===a[e];e++);var l=r-e;for(t=1;t<=l&&n[r-t]===a[o-t];t++);return Jt=a.slice(e,1<t?1-t:void 0)}function tn(e){var t=e.keyCode;return"charCode"in e?0===(e=e.charCode)&&13===t&&(e=13):e=t,10===e&&(e=13),32<=e||13===e?e:0}function nn(){return!0}function rn(){return!1}function an(e){function t(t,n,r,a,o){for(var l in this._reactName=t,this._targetInst=r,this.type=n,this.nativeEvent=a,this.target=o,this.currentTarget=null,e)e.hasOwnProperty(l)&&(t=e[l],this[l]=t?t(a):a[l]);return this.isDefaultPrevented=(null!=a.defaultPrevented?a.defaultPrevented:!1===a.returnValue)?nn:rn,this.isPropagationStopped=rn,this}return F(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():"unknown"!=typeof e.returnValue&&(e.returnValue=!1),this.isDefaultPrevented=nn)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():"unknown"!=typeof e.cancelBubble&&(e.cancelBubble=!0),this.isPropagationStopped=nn)},persist:function(){},isPersistent:nn}),t}var on,ln,un,sn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},cn=an(sn),pn=F({},sn,{view:0,detail:0}),dn=an(pn),fn=F({},pn,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Cn,button:0,buttons:0,relatedTarget:function(e){return void 0===e.relatedTarget?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==un&&(un&&"mousemove"===e.type?(on=e.screenX-un.screenX,ln=e.screenY-un.screenY):ln=on=0,un=e),on)},movementY:function(e){return"movementY"in e?e.movementY:ln}}),hn=an(fn),mn=an(F({},fn,{dataTransfer:0})),gn=an(F({},pn,{relatedTarget:0})),yn=an(F({},sn,{animationName:0,elapsedTime:0,pseudoElement:0})),vn=F({},sn,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),bn=an(vn),wn=an(F({},sn,{data:0})),En={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},xn={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},Sn={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function kn(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):!!(e=Sn[e])&&!!t[e]}function Cn(){return kn}var Dn=F({},pn,{key:function(e){if(e.key){var t=En[e.key]||e.key;if("Unidentified"!==t)return t}return"keypress"===e.type?13===(e=tn(e))?"Enter":String.fromCharCode(e):"keydown"===e.type||"keyup"===e.type?xn[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Cn,charCode:function(e){return"keypress"===e.type?tn(e):0},keyCode:function(e){return"keydown"===e.type||"keyup"===e.type?e.keyCode:0},which:function(e){return"keypress"===e.type?tn(e):"keydown"===e.type||"keyup"===e.type?e.keyCode:0}}),On=an(Dn),Pn=an(F({},fn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),Tn=an(F({},pn,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Cn})),Nn=an(F({},sn,{propertyName:0,elapsedTime:0,pseudoElement:0})),Mn=F({},fn,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),Rn=an(Mn),jn=[9,13,27,32],An=c&&"CompositionEvent"in window,In=null;c&&"documentMode"in document&&(In=document.documentMode);var Fn=c&&"TextEvent"in window&&!In,Ln=c&&(!An||In&&8<In&&11>=In),Un=String.fromCharCode(32),zn=!1;function Yn(e,t){switch(e){case"keyup":return-1!==jn.indexOf(t.keyCode);case"keydown":return 229!==t.keyCode;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Wn(e){return"object"==typeof(e=e.detail)&&"data"in e?e.data:null}var Bn=!1,Hn={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function qn(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return"input"===t?!!Hn[e.type]:"textarea"===t}function Vn(e,t,n,r){Ce(r),0<(t=$r(t,"onChange")).length&&(n=new cn("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var $n=null,Zn=null;function Qn(e){Ur(e,0)}function Kn(e){if($(Ea(e)))return e}function Gn(e,t){if("change"===e)return t}var Xn=!1;if(c){var Jn;if(c){var er="oninput"in document;if(!er){var tr=document.createElement("div");tr.setAttribute("oninput","return;"),er="function"==typeof tr.oninput}Jn=er}else Jn=!1;Xn=Jn&&(!document.documentMode||9<document.documentMode)}function nr(){$n&&($n.detachEvent("onpropertychange",rr),Zn=$n=null)}function rr(e){if("value"===e.propertyName&&Kn(Zn)){var t=[];Vn(t,Zn,e,Ee(e)),Ne(Qn,t)}}function ar(e,t,n){"focusin"===e?(nr(),Zn=n,($n=t).attachEvent("onpropertychange",rr)):"focusout"===e&&nr()}function or(e){if("selectionchange"===e||"keyup"===e||"keydown"===e)return Kn(Zn)}function lr(e,t){if("click"===e)return Kn(t)}function ir(e,t){if("input"===e||"change"===e)return Kn(t)}var ur="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t};function sr(e,t){if(ur(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var a=n[r];if(!p.call(t,a)||!ur(e[a],t[a]))return!1}return!0}function cr(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function pr(e,t){var n,r=cr(e);for(e=0;r;){if(3===r.nodeType){if(n=e+r.textContent.length,e<=t&&n>=t)return{node:r,offset:t-e};e=n}e:{for(;r;){if(r.nextSibling){r=r.nextSibling;break e}r=r.parentNode}r=void 0}r=cr(r)}}function dr(e,t){return!(!e||!t)&&(e===t||(!e||3!==e.nodeType)&&(t&&3===t.nodeType?dr(e,t.parentNode):"contains"in e?e.contains(t):!!e.compareDocumentPosition&&!!(16&e.compareDocumentPosition(t))))}function fr(){for(var e=window,t=Z();t instanceof e.HTMLIFrameElement;){try{var n="string"==typeof t.contentWindow.location.href}catch(e){n=!1}if(!n)break;t=Z((e=t.contentWindow).document)}return t}function hr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&("input"===t&&("text"===e.type||"search"===e.type||"tel"===e.type||"url"===e.type||"password"===e.type)||"textarea"===t||"true"===e.contentEditable)}function mr(e){var t=fr(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&dr(n.ownerDocument.documentElement,n)){if(null!==r&&hr(n))if(t=r.start,void 0===(e=r.end)&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if((e=(t=n.ownerDocument||document)&&t.defaultView||window).getSelection){e=e.getSelection();var a=n.textContent.length,o=Math.min(r.start,a);r=void 0===r.end?o:Math.min(r.end,a),!e.extend&&o>r&&(a=r,r=o,o=a),a=pr(n,o);var l=pr(n,r);a&&l&&(1!==e.rangeCount||e.anchorNode!==a.node||e.anchorOffset!==a.offset||e.focusNode!==l.node||e.focusOffset!==l.offset)&&((t=t.createRange()).setStart(a.node,a.offset),e.removeAllRanges(),o>r?(e.addRange(t),e.extend(l.node,l.offset)):(t.setEnd(l.node,l.offset),e.addRange(t)))}for(t=[],e=n;e=e.parentNode;)1===e.nodeType&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for("function"==typeof n.focus&&n.focus(),n=0;n<t.length;n++)(e=t[n]).element.scrollLeft=e.left,e.element.scrollTop=e.top}}var gr=c&&"documentMode"in document&&11>=document.documentMode,yr=null,vr=null,br=null,wr=!1;function Er(e,t,n){var r=n.window===n?n.document:9===n.nodeType?n:n.ownerDocument;wr||null==yr||yr!==Z(r)||(r="selectionStart"in(r=yr)&&hr(r)?{start:r.selectionStart,end:r.selectionEnd}:{anchorNode:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection()).anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset},br&&sr(br,r)||(br=r,0<(r=$r(vr,"onSelect")).length&&(t=new cn("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=yr)))}function _r(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var xr={animationend:_r("Animation","AnimationEnd"),animationiteration:_r("Animation","AnimationIteration"),animationstart:_r("Animation","AnimationStart"),transitionend:_r("Transition","TransitionEnd")},Sr={},kr={};function Cr(e){if(Sr[e])return Sr[e];if(!xr[e])return e;var t,n=xr[e];for(t in n)if(n.hasOwnProperty(t)&&t in kr)return Sr[e]=n[t];return e}c&&(kr=document.createElement("div").style,"AnimationEvent"in window||(delete xr.animationend.animation,delete xr.animationiteration.animation,delete xr.animationstart.animation),"TransitionEvent"in window||delete xr.transitionend.transition);var Dr=Cr("animationend"),Or=Cr("animationiteration"),Pr=Cr("animationstart"),Tr=Cr("transitionend"),Nr=new Map,Mr="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function Rr(e,t){Nr.set(e,t),u(t,[e])}for(var jr=0;jr<Mr.length;jr++){var Ar=Mr[jr];Rr(Ar.toLowerCase(),"on"+(Ar[0].toUpperCase()+Ar.slice(1)))}Rr(Dr,"onAnimationEnd"),Rr(Or,"onAnimationIteration"),Rr(Pr,"onAnimationStart"),Rr("dblclick","onDoubleClick"),Rr("focusin","onFocus"),Rr("focusout","onBlur"),Rr(Tr,"onTransitionEnd"),s("onMouseEnter",["mouseout","mouseover"]),s("onMouseLeave",["mouseout","mouseover"]),s("onPointerEnter",["pointerout","pointerover"]),s("onPointerLeave",["pointerout","pointerover"]),u("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),u("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),u("onBeforeInput",["compositionend","keypress","textInput","paste"]),u("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),u("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),u("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Ir="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),Fr=new Set("cancel close invalid load scroll toggle".split(" ").concat(Ir));function Lr(e,t,n){var r=e.type||"unknown-event";e.currentTarget=n,function(e,t,n,r,a,l,i,u,s){if(Ye.apply(this,arguments),Ie){if(!Ie)throw Error(o(198));var c=Fe;Ie=!1,Fe=null,Le||(Le=!0,Ue=c)}}(r,t,void 0,e),e.currentTarget=null}function Ur(e,t){t=0!=(4&t);for(var n=0;n<e.length;n++){var r=e[n],a=r.event;r=r.listeners;e:{var o=void 0;if(t)for(var l=r.length-1;0<=l;l--){var i=r[l],u=i.instance,s=i.currentTarget;if(i=i.listener,u!==o&&a.isPropagationStopped())break e;Lr(a,i,s),o=u}else for(l=0;l<r.length;l++){if(u=(i=r[l]).instance,s=i.currentTarget,i=i.listener,u!==o&&a.isPropagationStopped())break e;Lr(a,i,s),o=u}}}if(Le)throw e=Ue,Le=!1,Ue=null,e}function zr(e,t){var n=t[ga];void 0===n&&(n=t[ga]=new Set);var r=e+"__bubble";n.has(r)||(Hr(t,e,2,!1),n.add(r))}function Yr(e,t,n){var r=0;t&&(r|=4),Hr(n,e,r,t)}var Wr="_reactListening"+Math.random().toString(36).slice(2);function Br(e){if(!e[Wr]){e[Wr]=!0,l.forEach((function(t){"selectionchange"!==t&&(Fr.has(t)||Yr(t,!1,e),Yr(t,!0,e))}));var t=9===e.nodeType?e:e.ownerDocument;null===t||t[Wr]||(t[Wr]=!0,Yr("selectionchange",!1,t))}}function Hr(e,t,n,r){switch(Kt(t)){case 1:var a=qt;break;case 4:a=Vt;break;default:a=$t}n=a.bind(null,t,n,e),a=void 0,!Re||"touchstart"!==t&&"touchmove"!==t&&"wheel"!==t||(a=!0),r?void 0!==a?e.addEventListener(t,n,{capture:!0,passive:a}):e.addEventListener(t,n,!0):void 0!==a?e.addEventListener(t,n,{passive:a}):e.addEventListener(t,n,!1)}function qr(e,t,n,r,a){var o=r;if(0==(1&t)&&0==(2&t)&&null!==r)e:for(;;){if(null===r)return;var l=r.tag;if(3===l||4===l){var i=r.stateNode.containerInfo;if(i===a||8===i.nodeType&&i.parentNode===a)break;if(4===l)for(l=r.return;null!==l;){var u=l.tag;if((3===u||4===u)&&((u=l.stateNode.containerInfo)===a||8===u.nodeType&&u.parentNode===a))return;l=l.return}for(;null!==i;){if(null===(l=ba(i)))return;if(5===(u=l.tag)||6===u){r=o=l;continue e}i=i.parentNode}}r=r.return}Ne((function(){var r=o,a=Ee(n),l=[];e:{var i=Nr.get(e);if(void 0!==i){var u=cn,s=e;switch(e){case"keypress":if(0===tn(n))break e;case"keydown":case"keyup":u=On;break;case"focusin":s="focus",u=gn;break;case"focusout":s="blur",u=gn;break;case"beforeblur":case"afterblur":u=gn;break;case"click":if(2===n.button)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":u=hn;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":u=mn;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":u=Tn;break;case Dr:case Or:case Pr:u=yn;break;case Tr:u=Nn;break;case"scroll":u=dn;break;case"wheel":u=Rn;break;case"copy":case"cut":case"paste":u=bn;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":u=Pn}var c=0!=(4&t),p=!c&&"scroll"===e,d=c?null!==i?i+"Capture":null:i;c=[];for(var f,h=r;null!==h;){var m=(f=h).stateNode;if(5===f.tag&&null!==m&&(f=m,null!==d&&null!=(m=Me(h,d))&&c.push(Vr(h,m,f))),p)break;h=h.return}0<c.length&&(i=new u(i,s,null,n,a),l.push({event:i,listeners:c}))}}if(0==(7&t)){if(u="mouseout"===e||"pointerout"===e,(!(i="mouseover"===e||"pointerover"===e)||n===we||!(s=n.relatedTarget||n.fromElement)||!ba(s)&&!s[ma])&&(u||i)&&(i=a.window===a?a:(i=a.ownerDocument)?i.defaultView||i.parentWindow:window,u?(u=r,null!==(s=(s=n.relatedTarget||n.toElement)?ba(s):null)&&(s!==(p=We(s))||5!==s.tag&&6!==s.tag)&&(s=null)):(u=null,s=r),u!==s)){if(c=hn,m="onMouseLeave",d="onMouseEnter",h="mouse","pointerout"!==e&&"pointerover"!==e||(c=Pn,m="onPointerLeave",d="onPointerEnter",h="pointer"),p=null==u?i:Ea(u),f=null==s?i:Ea(s),(i=new c(m,h+"leave",u,n,a)).target=p,i.relatedTarget=f,m=null,ba(a)===r&&((c=new c(d,h+"enter",s,n,a)).target=f,c.relatedTarget=p,m=c),p=m,u&&s)e:{for(d=s,h=0,f=c=u;f;f=Zr(f))h++;for(f=0,m=d;m;m=Zr(m))f++;for(;0<h-f;)c=Zr(c),h--;for(;0<f-h;)d=Zr(d),f--;for(;h--;){if(c===d||null!==d&&c===d.alternate)break e;c=Zr(c),d=Zr(d)}c=null}else c=null;null!==u&&Qr(l,i,u,c,!1),null!==s&&null!==p&&Qr(l,p,s,c,!0)}if("select"===(u=(i=r?Ea(r):window).nodeName&&i.nodeName.toLowerCase())||"input"===u&&"file"===i.type)var g=Gn;else if(qn(i))if(Xn)g=ir;else{g=or;var y=ar}else(u=i.nodeName)&&"input"===u.toLowerCase()&&("checkbox"===i.type||"radio"===i.type)&&(g=lr);switch(g&&(g=g(e,r))?Vn(l,g,n,a):(y&&y(e,i,r),"focusout"===e&&(y=i._wrapperState)&&y.controlled&&"number"===i.type&&ee(i,"number",i.value)),y=r?Ea(r):window,e){case"focusin":(qn(y)||"true"===y.contentEditable)&&(yr=y,vr=r,br=null);break;case"focusout":br=vr=yr=null;break;case"mousedown":wr=!0;break;case"contextmenu":case"mouseup":case"dragend":wr=!1,Er(l,n,a);break;case"selectionchange":if(gr)break;case"keydown":case"keyup":Er(l,n,a)}var v;if(An)e:{switch(e){case"compositionstart":var b="onCompositionStart";break e;case"compositionend":b="onCompositionEnd";break e;case"compositionupdate":b="onCompositionUpdate";break e}b=void 0}else Bn?Yn(e,n)&&(b="onCompositionEnd"):"keydown"===e&&229===n.keyCode&&(b="onCompositionStart");b&&(Ln&&"ko"!==n.locale&&(Bn||"onCompositionStart"!==b?"onCompositionEnd"===b&&Bn&&(v=en()):(Xt="value"in(Gt=a)?Gt.value:Gt.textContent,Bn=!0)),0<(y=$r(r,b)).length&&(b=new wn(b,e,null,n,a),l.push({event:b,listeners:y}),(v||null!==(v=Wn(n)))&&(b.data=v))),(v=Fn?function(e,t){switch(e){case"compositionend":return Wn(t);case"keypress":return 32!==t.which?null:(zn=!0,Un);case"textInput":return(e=t.data)===Un&&zn?null:e;default:return null}}(e,n):function(e,t){if(Bn)return"compositionend"===e||!An&&Yn(e,t)?(e=en(),Jt=Xt=Gt=null,Bn=!1,e):null;switch(e){case"paste":default:return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return Ln&&"ko"!==t.locale?null:t.data}}(e,n))&&0<(r=$r(r,"onBeforeInput")).length&&(a=new wn("onBeforeInput","beforeinput",null,n,a),l.push({event:a,listeners:r}),a.data=v)}Ur(l,t)}))}function Vr(e,t,n){return{instance:e,listener:t,currentTarget:n}}function $r(e,t){for(var n=t+"Capture",r=[];null!==e;){var a=e,o=a.stateNode;5===a.tag&&null!==o&&(a=o,null!=(o=Me(e,n))&&r.unshift(Vr(e,o,a)),null!=(o=Me(e,t))&&r.push(Vr(e,o,a))),e=e.return}return r}function Zr(e){if(null===e)return null;do{e=e.return}while(e&&5!==e.tag);return e||null}function Qr(e,t,n,r,a){for(var o=t._reactName,l=[];null!==n&&n!==r;){var i=n,u=i.alternate,s=i.stateNode;if(null!==u&&u===r)break;5===i.tag&&null!==s&&(i=s,a?null!=(u=Me(n,o))&&l.unshift(Vr(n,u,i)):a||null!=(u=Me(n,o))&&l.push(Vr(n,u,i))),n=n.return}0!==l.length&&e.push({event:t,listeners:l})}var Kr=/\r\n?/g,Gr=/\u0000|\uFFFD/g;function Xr(e){return("string"==typeof e?e:""+e).replace(Kr,"\n").replace(Gr,"")}function Jr(e,t,n){if(t=Xr(t),Xr(e)!==t&&n)throw Error(o(425))}function ea(){}var ta=null,na=null;function ra(e,t){return"textarea"===e||"noscript"===e||"string"==typeof t.children||"number"==typeof t.children||"object"==typeof t.dangerouslySetInnerHTML&&null!==t.dangerouslySetInnerHTML&&null!=t.dangerouslySetInnerHTML.__html}var aa="function"==typeof setTimeout?setTimeout:void 0,oa="function"==typeof clearTimeout?clearTimeout:void 0,la="function"==typeof Promise?Promise:void 0,ia="function"==typeof queueMicrotask?queueMicrotask:void 0!==la?function(e){return la.resolve(null).then(e).catch(ua)}:aa;function ua(e){setTimeout((function(){throw e}))}function sa(e,t){var n=t,r=0;do{var a=n.nextSibling;if(e.removeChild(n),a&&8===a.nodeType)if("/$"===(n=a.data)){if(0===r)return e.removeChild(a),void Wt(t);r--}else"$"!==n&&"$?"!==n&&"$!"!==n||r++;n=a}while(n);Wt(t)}function ca(e){for(;null!=e;e=e.nextSibling){var t=e.nodeType;if(1===t||3===t)break;if(8===t){if("$"===(t=e.data)||"$!"===t||"$?"===t)break;if("/$"===t)return null}}return e}function pa(e){e=e.previousSibling;for(var t=0;e;){if(8===e.nodeType){var n=e.data;if("$"===n||"$!"===n||"$?"===n){if(0===t)return e;t--}else"/$"===n&&t++}e=e.previousSibling}return null}var da=Math.random().toString(36).slice(2),fa="__reactFiber$"+da,ha="__reactProps$"+da,ma="__reactContainer$"+da,ga="__reactEvents$"+da,ya="__reactListeners$"+da,va="__reactHandles$"+da;function ba(e){var t=e[fa];if(t)return t;for(var n=e.parentNode;n;){if(t=n[ma]||n[fa]){if(n=t.alternate,null!==t.child||null!==n&&null!==n.child)for(e=pa(e);null!==e;){if(n=e[fa])return n;e=pa(e)}return t}n=(e=n).parentNode}return null}function wa(e){return!(e=e[fa]||e[ma])||5!==e.tag&&6!==e.tag&&13!==e.tag&&3!==e.tag?null:e}function Ea(e){if(5===e.tag||6===e.tag)return e.stateNode;throw Error(o(33))}function _a(e){return e[ha]||null}var xa=[],Sa=-1;function ka(e){return{current:e}}function Ca(e){0>Sa||(e.current=xa[Sa],xa[Sa]=null,Sa--)}function Da(e,t){Sa++,xa[Sa]=e.current,e.current=t}var Oa={},Pa=ka(Oa),Ta=ka(!1),Na=Oa;function Ma(e,t){var n=e.type.contextTypes;if(!n)return Oa;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var a,o={};for(a in n)o[a]=t[a];return r&&((e=e.stateNode).__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=o),o}function Ra(e){return null!=e.childContextTypes}function ja(){Ca(Ta),Ca(Pa)}function Aa(e,t,n){if(Pa.current!==Oa)throw Error(o(168));Da(Pa,t),Da(Ta,n)}function Ia(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,"function"!=typeof r.getChildContext)return n;for(var a in r=r.getChildContext())if(!(a in t))throw Error(o(108,B(e)||"Unknown",a));return F({},n,r)}function Fa(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Oa,Na=Pa.current,Da(Pa,e),Da(Ta,Ta.current),!0}function La(e,t,n){var r=e.stateNode;if(!r)throw Error(o(169));n?(e=Ia(e,t,Na),r.__reactInternalMemoizedMergedChildContext=e,Ca(Ta),Ca(Pa),Da(Pa,e)):Ca(Ta),Da(Ta,n)}var Ua=null,za=!1,Ya=!1;function Wa(e){null===Ua?Ua=[e]:Ua.push(e)}function Ba(){if(!Ya&&null!==Ua){Ya=!0;var e=0,t=bt;try{var n=Ua;for(bt=1;e<n.length;e++){var r=n[e];do{r=r(!0)}while(null!==r)}Ua=null,za=!1}catch(t){throw null!==Ua&&(Ua=Ua.slice(e+1)),$e(Je,Ba),t}finally{bt=t,Ya=!1}}return null}var Ha=[],qa=0,Va=null,$a=0,Za=[],Qa=0,Ka=null,Ga=1,Xa="";function Ja(e,t){Ha[qa++]=$a,Ha[qa++]=Va,Va=e,$a=t}function eo(e,t,n){Za[Qa++]=Ga,Za[Qa++]=Xa,Za[Qa++]=Ka,Ka=e;var r=Ga;e=Xa;var a=32-lt(r)-1;r&=~(1<<a),n+=1;var o=32-lt(t)+a;if(30<o){var l=a-a%5;o=(r&(1<<l)-1).toString(32),r>>=l,a-=l,Ga=1<<32-lt(t)+a|n<<a|r,Xa=o+e}else Ga=1<<o|n<<a|r,Xa=e}function to(e){null!==e.return&&(Ja(e,1),eo(e,1,0))}function no(e){for(;e===Va;)Va=Ha[--qa],Ha[qa]=null,$a=Ha[--qa],Ha[qa]=null;for(;e===Ka;)Ka=Za[--Qa],Za[Qa]=null,Xa=Za[--Qa],Za[Qa]=null,Ga=Za[--Qa],Za[Qa]=null}var ro=null,ao=null,oo=!1,lo=null;function io(e,t){var n=Ms(5,null,null,0);n.elementType="DELETED",n.stateNode=t,n.return=e,null===(t=e.deletions)?(e.deletions=[n],e.flags|=16):t.push(n)}function uo(e,t){switch(e.tag){case 5:var n=e.type;return null!==(t=1!==t.nodeType||n.toLowerCase()!==t.nodeName.toLowerCase()?null:t)&&(e.stateNode=t,ro=e,ao=ca(t.firstChild),!0);case 6:return null!==(t=""===e.pendingProps||3!==t.nodeType?null:t)&&(e.stateNode=t,ro=e,ao=null,!0);case 13:return null!==(t=8!==t.nodeType?null:t)&&(n=null!==Ka?{id:Ga,overflow:Xa}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},(n=Ms(18,null,null,0)).stateNode=t,n.return=e,e.child=n,ro=e,ao=null,!0);default:return!1}}function so(e){return 0!=(1&e.mode)&&0==(128&e.flags)}function co(e){if(oo){var t=ao;if(t){var n=t;if(!uo(e,t)){if(so(e))throw Error(o(418));t=ca(n.nextSibling);var r=ro;t&&uo(e,t)?io(r,n):(e.flags=-4097&e.flags|2,oo=!1,ro=e)}}else{if(so(e))throw Error(o(418));e.flags=-4097&e.flags|2,oo=!1,ro=e}}}function po(e){for(e=e.return;null!==e&&5!==e.tag&&3!==e.tag&&13!==e.tag;)e=e.return;ro=e}function fo(e){if(e!==ro)return!1;if(!oo)return po(e),oo=!0,!1;var t;if((t=3!==e.tag)&&!(t=5!==e.tag)&&(t="head"!==(t=e.type)&&"body"!==t&&!ra(e.type,e.memoizedProps)),t&&(t=ao)){if(so(e))throw ho(),Error(o(418));for(;t;)io(e,t),t=ca(t.nextSibling)}if(po(e),13===e.tag){if(!(e=null!==(e=e.memoizedState)?e.dehydrated:null))throw Error(o(317));e:{for(e=e.nextSibling,t=0;e;){if(8===e.nodeType){var n=e.data;if("/$"===n){if(0===t){ao=ca(e.nextSibling);break e}t--}else"$"!==n&&"$!"!==n&&"$?"!==n||t++}e=e.nextSibling}ao=null}}else ao=ro?ca(e.stateNode.nextSibling):null;return!0}function ho(){for(var e=ao;e;)e=ca(e.nextSibling)}function mo(){ao=ro=null,oo=!1}function go(e){null===lo?lo=[e]:lo.push(e)}var yo=w.ReactCurrentBatchConfig;function vo(e,t){if(e&&e.defaultProps){for(var n in t=F({},t),e=e.defaultProps)void 0===t[n]&&(t[n]=e[n]);return t}return t}var bo=ka(null),wo=null,Eo=null,_o=null;function xo(){_o=Eo=wo=null}function So(e){var t=bo.current;Ca(bo),e._currentValue=t}function ko(e,t,n){for(;null!==e;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,null!==r&&(r.childLanes|=t)):null!==r&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function Co(e,t){wo=e,_o=Eo=null,null!==(e=e.dependencies)&&null!==e.firstContext&&(0!=(e.lanes&t)&&(Ei=!0),e.firstContext=null)}function Do(e){var t=e._currentValue;if(_o!==e)if(e={context:e,memoizedValue:t,next:null},null===Eo){if(null===wo)throw Error(o(308));Eo=e,wo.dependencies={lanes:0,firstContext:e}}else Eo=Eo.next=e;return t}var Oo=null;function Po(e){null===Oo?Oo=[e]:Oo.push(e)}function To(e,t,n,r){var a=t.interleaved;return null===a?(n.next=n,Po(t)):(n.next=a.next,a.next=n),t.interleaved=n,No(e,r)}function No(e,t){e.lanes|=t;var n=e.alternate;for(null!==n&&(n.lanes|=t),n=e,e=e.return;null!==e;)e.childLanes|=t,null!==(n=e.alternate)&&(n.childLanes|=t),n=e,e=e.return;return 3===n.tag?n.stateNode:null}var Mo=!1;function Ro(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function jo(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Ao(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Io(e,t,n){var r=e.updateQueue;if(null===r)return null;if(r=r.shared,0!=(2&Pu)){var a=r.pending;return null===a?t.next=t:(t.next=a.next,a.next=t),r.pending=t,No(e,n)}return null===(a=r.interleaved)?(t.next=t,Po(r)):(t.next=a.next,a.next=t),r.interleaved=t,No(e,n)}function Fo(e,t,n){if(null!==(t=t.updateQueue)&&(t=t.shared,0!=(4194240&n))){var r=t.lanes;n|=r&=e.pendingLanes,t.lanes=n,vt(e,n)}}function Lo(e,t){var n=e.updateQueue,r=e.alternate;if(null!==r&&n===(r=r.updateQueue)){var a=null,o=null;if(null!==(n=n.firstBaseUpdate)){do{var l={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};null===o?a=o=l:o=o.next=l,n=n.next}while(null!==n);null===o?a=o=t:o=o.next=t}else a=o=t;return n={baseState:r.baseState,firstBaseUpdate:a,lastBaseUpdate:o,shared:r.shared,effects:r.effects},void(e.updateQueue=n)}null===(e=n.lastBaseUpdate)?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function Uo(e,t,n,r){var a=e.updateQueue;Mo=!1;var o=a.firstBaseUpdate,l=a.lastBaseUpdate,i=a.shared.pending;if(null!==i){a.shared.pending=null;var u=i,s=u.next;u.next=null,null===l?o=s:l.next=s,l=u;var c=e.alternate;null!==c&&(i=(c=c.updateQueue).lastBaseUpdate)!==l&&(null===i?c.firstBaseUpdate=s:i.next=s,c.lastBaseUpdate=u)}if(null!==o){var p=a.baseState;for(l=0,c=s=u=null,i=o;;){var d=i.lane,f=i.eventTime;if((r&d)===d){null!==c&&(c=c.next={eventTime:f,lane:0,tag:i.tag,payload:i.payload,callback:i.callback,next:null});e:{var h=e,m=i;switch(d=t,f=n,m.tag){case 1:if("function"==typeof(h=m.payload)){p=h.call(f,p,d);break e}p=h;break e;case 3:h.flags=-65537&h.flags|128;case 0:if(null==(d="function"==typeof(h=m.payload)?h.call(f,p,d):h))break e;p=F({},p,d);break e;case 2:Mo=!0}}null!==i.callback&&0!==i.lane&&(e.flags|=64,null===(d=a.effects)?a.effects=[i]:d.push(i))}else f={eventTime:f,lane:d,tag:i.tag,payload:i.payload,callback:i.callback,next:null},null===c?(s=c=f,u=p):c=c.next=f,l|=d;if(null===(i=i.next)){if(null===(i=a.shared.pending))break;i=(d=i).next,d.next=null,a.lastBaseUpdate=d,a.shared.pending=null}}if(null===c&&(u=p),a.baseState=u,a.firstBaseUpdate=s,a.lastBaseUpdate=c,null!==(t=a.shared.interleaved)){a=t;do{l|=a.lane,a=a.next}while(a!==t)}else null===o&&(a.shared.lanes=0);Fu|=l,e.lanes=l,e.memoizedState=p}}function zo(e,t,n){if(e=t.effects,t.effects=null,null!==e)for(t=0;t<e.length;t++){var r=e[t],a=r.callback;if(null!==a){if(r.callback=null,r=n,"function"!=typeof a)throw Error(o(191,a));a.call(r)}}}var Yo=(new r.Component).refs;function Wo(e,t,n,r){n=null==(n=n(r,t=e.memoizedState))?t:F({},t,n),e.memoizedState=n,0===e.lanes&&(e.updateQueue.baseState=n)}var Bo={isMounted:function(e){return!!(e=e._reactInternals)&&We(e)===e},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=ts(),a=ns(e),o=Ao(r,a);o.payload=t,null!=n&&(o.callback=n),null!==(t=Io(e,o,a))&&(rs(t,e,a,r),Fo(t,e,a))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=ts(),a=ns(e),o=Ao(r,a);o.tag=1,o.payload=t,null!=n&&(o.callback=n),null!==(t=Io(e,o,a))&&(rs(t,e,a,r),Fo(t,e,a))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=ts(),r=ns(e),a=Ao(n,r);a.tag=2,null!=t&&(a.callback=t),null!==(t=Io(e,a,r))&&(rs(t,e,r,n),Fo(t,e,r))}};function Ho(e,t,n,r,a,o,l){return"function"==typeof(e=e.stateNode).shouldComponentUpdate?e.shouldComponentUpdate(r,o,l):!(t.prototype&&t.prototype.isPureReactComponent&&sr(n,r)&&sr(a,o))}function qo(e,t,n){var r=!1,a=Oa,o=t.contextType;return"object"==typeof o&&null!==o?o=Do(o):(a=Ra(t)?Na:Pa.current,o=(r=null!=(r=t.contextTypes))?Ma(e,a):Oa),t=new t(n,o),e.memoizedState=null!==t.state&&void 0!==t.state?t.state:null,t.updater=Bo,e.stateNode=t,t._reactInternals=e,r&&((e=e.stateNode).__reactInternalMemoizedUnmaskedChildContext=a,e.__reactInternalMemoizedMaskedChildContext=o),t}function Vo(e,t,n,r){e=t.state,"function"==typeof t.componentWillReceiveProps&&t.componentWillReceiveProps(n,r),"function"==typeof t.UNSAFE_componentWillReceiveProps&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&Bo.enqueueReplaceState(t,t.state,null)}function $o(e,t,n,r){var a=e.stateNode;a.props=n,a.state=e.memoizedState,a.refs=Yo,Ro(e);var o=t.contextType;"object"==typeof o&&null!==o?a.context=Do(o):(o=Ra(t)?Na:Pa.current,a.context=Ma(e,o)),a.state=e.memoizedState,"function"==typeof(o=t.getDerivedStateFromProps)&&(Wo(e,t,o,n),a.state=e.memoizedState),"function"==typeof t.getDerivedStateFromProps||"function"==typeof a.getSnapshotBeforeUpdate||"function"!=typeof a.UNSAFE_componentWillMount&&"function"!=typeof a.componentWillMount||(t=a.state,"function"==typeof a.componentWillMount&&a.componentWillMount(),"function"==typeof a.UNSAFE_componentWillMount&&a.UNSAFE_componentWillMount(),t!==a.state&&Bo.enqueueReplaceState(a,a.state,null),Uo(e,n,a,r),a.state=e.memoizedState),"function"==typeof a.componentDidMount&&(e.flags|=4194308)}function Zo(e,t,n){if(null!==(e=n.ref)&&"function"!=typeof e&&"object"!=typeof e){if(n._owner){if(n=n._owner){if(1!==n.tag)throw Error(o(309));var r=n.stateNode}if(!r)throw Error(o(147,e));var a=r,l=""+e;return null!==t&&null!==t.ref&&"function"==typeof t.ref&&t.ref._stringRef===l?t.ref:(t=function(e){var t=a.refs;t===Yo&&(t=a.refs={}),null===e?delete t[l]:t[l]=e},t._stringRef=l,t)}if("string"!=typeof e)throw Error(o(284));if(!n._owner)throw Error(o(290,e))}return e}function Qo(e,t){throw e=Object.prototype.toString.call(t),Error(o(31,"[object Object]"===e?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function Ko(e){return(0,e._init)(e._payload)}function Go(e){function t(t,n){if(e){var r=t.deletions;null===r?(t.deletions=[n],t.flags|=16):r.push(n)}}function n(n,r){if(!e)return null;for(;null!==r;)t(n,r),r=r.sibling;return null}function r(e,t){for(e=new Map;null!==t;)null!==t.key?e.set(t.key,t):e.set(t.index,t),t=t.sibling;return e}function a(e,t){return(e=js(e,t)).index=0,e.sibling=null,e}function l(t,n,r){return t.index=r,e?null!==(r=t.alternate)?(r=r.index)<n?(t.flags|=2,n):r:(t.flags|=2,n):(t.flags|=1048576,n)}function i(t){return e&&null===t.alternate&&(t.flags|=2),t}function u(e,t,n,r){return null===t||6!==t.tag?((t=Ls(n,e.mode,r)).return=e,t):((t=a(t,n)).return=e,t)}function s(e,t,n,r){var o=n.type;return o===x?p(e,t,n.props.children,r,n.key):null!==t&&(t.elementType===o||"object"==typeof o&&null!==o&&o.$$typeof===M&&Ko(o)===t.type)?((r=a(t,n.props)).ref=Zo(e,t,n),r.return=e,r):((r=As(n.type,n.key,n.props,null,e.mode,r)).ref=Zo(e,t,n),r.return=e,r)}function c(e,t,n,r){return null===t||4!==t.tag||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?((t=Us(n,e.mode,r)).return=e,t):((t=a(t,n.children||[])).return=e,t)}function p(e,t,n,r,o){return null===t||7!==t.tag?((t=Is(n,e.mode,r,o)).return=e,t):((t=a(t,n)).return=e,t)}function d(e,t,n){if("string"==typeof t&&""!==t||"number"==typeof t)return(t=Ls(""+t,e.mode,n)).return=e,t;if("object"==typeof t&&null!==t){switch(t.$$typeof){case E:return(n=As(t.type,t.key,t.props,null,e.mode,n)).ref=Zo(e,null,t),n.return=e,n;case _:return(t=Us(t,e.mode,n)).return=e,t;case M:return d(e,(0,t._init)(t._payload),n)}if(te(t)||A(t))return(t=Is(t,e.mode,n,null)).return=e,t;Qo(e,t)}return null}function f(e,t,n,r){var a=null!==t?t.key:null;if("string"==typeof n&&""!==n||"number"==typeof n)return null!==a?null:u(e,t,""+n,r);if("object"==typeof n&&null!==n){switch(n.$$typeof){case E:return n.key===a?s(e,t,n,r):null;case _:return n.key===a?c(e,t,n,r):null;case M:return f(e,t,(a=n._init)(n._payload),r)}if(te(n)||A(n))return null!==a?null:p(e,t,n,r,null);Qo(e,n)}return null}function h(e,t,n,r,a){if("string"==typeof r&&""!==r||"number"==typeof r)return u(t,e=e.get(n)||null,""+r,a);if("object"==typeof r&&null!==r){switch(r.$$typeof){case E:return s(t,e=e.get(null===r.key?n:r.key)||null,r,a);case _:return c(t,e=e.get(null===r.key?n:r.key)||null,r,a);case M:return h(e,t,n,(0,r._init)(r._payload),a)}if(te(r)||A(r))return p(t,e=e.get(n)||null,r,a,null);Qo(t,r)}return null}function m(a,o,i,u){for(var s=null,c=null,p=o,m=o=0,g=null;null!==p&&m<i.length;m++){p.index>m?(g=p,p=null):g=p.sibling;var y=f(a,p,i[m],u);if(null===y){null===p&&(p=g);break}e&&p&&null===y.alternate&&t(a,p),o=l(y,o,m),null===c?s=y:c.sibling=y,c=y,p=g}if(m===i.length)return n(a,p),oo&&Ja(a,m),s;if(null===p){for(;m<i.length;m++)null!==(p=d(a,i[m],u))&&(o=l(p,o,m),null===c?s=p:c.sibling=p,c=p);return oo&&Ja(a,m),s}for(p=r(a,p);m<i.length;m++)null!==(g=h(p,a,m,i[m],u))&&(e&&null!==g.alternate&&p.delete(null===g.key?m:g.key),o=l(g,o,m),null===c?s=g:c.sibling=g,c=g);return e&&p.forEach((function(e){return t(a,e)})),oo&&Ja(a,m),s}function g(a,i,u,s){var c=A(u);if("function"!=typeof c)throw Error(o(150));if(null==(u=c.call(u)))throw Error(o(151));for(var p=c=null,m=i,g=i=0,y=null,v=u.next();null!==m&&!v.done;g++,v=u.next()){m.index>g?(y=m,m=null):y=m.sibling;var b=f(a,m,v.value,s);if(null===b){null===m&&(m=y);break}e&&m&&null===b.alternate&&t(a,m),i=l(b,i,g),null===p?c=b:p.sibling=b,p=b,m=y}if(v.done)return n(a,m),oo&&Ja(a,g),c;if(null===m){for(;!v.done;g++,v=u.next())null!==(v=d(a,v.value,s))&&(i=l(v,i,g),null===p?c=v:p.sibling=v,p=v);return oo&&Ja(a,g),c}for(m=r(a,m);!v.done;g++,v=u.next())null!==(v=h(m,a,g,v.value,s))&&(e&&null!==v.alternate&&m.delete(null===v.key?g:v.key),i=l(v,i,g),null===p?c=v:p.sibling=v,p=v);return e&&m.forEach((function(e){return t(a,e)})),oo&&Ja(a,g),c}return function e(r,o,l,u){if("object"==typeof l&&null!==l&&l.type===x&&null===l.key&&(l=l.props.children),"object"==typeof l&&null!==l){switch(l.$$typeof){case E:e:{for(var s=l.key,c=o;null!==c;){if(c.key===s){if((s=l.type)===x){if(7===c.tag){n(r,c.sibling),(o=a(c,l.props.children)).return=r,r=o;break e}}else if(c.elementType===s||"object"==typeof s&&null!==s&&s.$$typeof===M&&Ko(s)===c.type){n(r,c.sibling),(o=a(c,l.props)).ref=Zo(r,c,l),o.return=r,r=o;break e}n(r,c);break}t(r,c),c=c.sibling}l.type===x?((o=Is(l.props.children,r.mode,u,l.key)).return=r,r=o):((u=As(l.type,l.key,l.props,null,r.mode,u)).ref=Zo(r,o,l),u.return=r,r=u)}return i(r);case _:e:{for(c=l.key;null!==o;){if(o.key===c){if(4===o.tag&&o.stateNode.containerInfo===l.containerInfo&&o.stateNode.implementation===l.implementation){n(r,o.sibling),(o=a(o,l.children||[])).return=r,r=o;break e}n(r,o);break}t(r,o),o=o.sibling}(o=Us(l,r.mode,u)).return=r,r=o}return i(r);case M:return e(r,o,(c=l._init)(l._payload),u)}if(te(l))return m(r,o,l,u);if(A(l))return g(r,o,l,u);Qo(r,l)}return"string"==typeof l&&""!==l||"number"==typeof l?(l=""+l,null!==o&&6===o.tag?(n(r,o.sibling),(o=a(o,l)).return=r,r=o):(n(r,o),(o=Ls(l,r.mode,u)).return=r,r=o),i(r)):n(r,o)}}var Xo=Go(!0),Jo=Go(!1),el={},tl=ka(el),nl=ka(el),rl=ka(el);function al(e){if(e===el)throw Error(o(174));return e}function ol(e,t){switch(Da(rl,t),Da(nl,e),Da(tl,el),e=t.nodeType){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:ue(null,"");break;default:t=ue(t=(e=8===e?t.parentNode:t).namespaceURI||null,e=e.tagName)}Ca(tl),Da(tl,t)}function ll(){Ca(tl),Ca(nl),Ca(rl)}function il(e){al(rl.current);var t=al(tl.current),n=ue(t,e.type);t!==n&&(Da(nl,e),Da(tl,n))}function ul(e){nl.current===e&&(Ca(tl),Ca(nl))}var sl=ka(0);function cl(e){for(var t=e;null!==t;){if(13===t.tag){var n=t.memoizedState;if(null!==n&&(null===(n=n.dehydrated)||"$?"===n.data||"$!"===n.data))return t}else if(19===t.tag&&void 0!==t.memoizedProps.revealOrder){if(0!=(128&t.flags))return t}else if(null!==t.child){t.child.return=t,t=t.child;continue}if(t===e)break;for(;null===t.sibling;){if(null===t.return||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var pl=[];function dl(){for(var e=0;e<pl.length;e++)pl[e]._workInProgressVersionPrimary=null;pl.length=0}var fl=w.ReactCurrentDispatcher,hl=w.ReactCurrentBatchConfig,ml=0,gl=null,yl=null,vl=null,bl=!1,wl=!1,El=0,_l=0;function xl(){throw Error(o(321))}function Sl(e,t){if(null===t)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!ur(e[n],t[n]))return!1;return!0}function kl(e,t,n,r,a,l){if(ml=l,gl=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,fl.current=null===e||null===e.memoizedState?ui:si,e=n(r,a),wl){l=0;do{if(wl=!1,El=0,25<=l)throw Error(o(301));l+=1,vl=yl=null,t.updateQueue=null,fl.current=ci,e=n(r,a)}while(wl)}if(fl.current=ii,t=null!==yl&&null!==yl.next,ml=0,vl=yl=gl=null,bl=!1,t)throw Error(o(300));return e}function Cl(){var e=0!==El;return El=0,e}function Dl(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return null===vl?gl.memoizedState=vl=e:vl=vl.next=e,vl}function Ol(){if(null===yl){var e=gl.alternate;e=null!==e?e.memoizedState:null}else e=yl.next;var t=null===vl?gl.memoizedState:vl.next;if(null!==t)vl=t,yl=e;else{if(null===e)throw Error(o(310));e={memoizedState:(yl=e).memoizedState,baseState:yl.baseState,baseQueue:yl.baseQueue,queue:yl.queue,next:null},null===vl?gl.memoizedState=vl=e:vl=vl.next=e}return vl}function Pl(e,t){return"function"==typeof t?t(e):t}function Tl(e){var t=Ol(),n=t.queue;if(null===n)throw Error(o(311));n.lastRenderedReducer=e;var r=yl,a=r.baseQueue,l=n.pending;if(null!==l){if(null!==a){var i=a.next;a.next=l.next,l.next=i}r.baseQueue=a=l,n.pending=null}if(null!==a){l=a.next,r=r.baseState;var u=i=null,s=null,c=l;do{var p=c.lane;if((ml&p)===p)null!==s&&(s=s.next={lane:0,action:c.action,hasEagerState:c.hasEagerState,eagerState:c.eagerState,next:null}),r=c.hasEagerState?c.eagerState:e(r,c.action);else{var d={lane:p,action:c.action,hasEagerState:c.hasEagerState,eagerState:c.eagerState,next:null};null===s?(u=s=d,i=r):s=s.next=d,gl.lanes|=p,Fu|=p}c=c.next}while(null!==c&&c!==l);null===s?i=r:s.next=u,ur(r,t.memoizedState)||(Ei=!0),t.memoizedState=r,t.baseState=i,t.baseQueue=s,n.lastRenderedState=r}if(null!==(e=n.interleaved)){a=e;do{l=a.lane,gl.lanes|=l,Fu|=l,a=a.next}while(a!==e)}else null===a&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function Nl(e){var t=Ol(),n=t.queue;if(null===n)throw Error(o(311));n.lastRenderedReducer=e;var r=n.dispatch,a=n.pending,l=t.memoizedState;if(null!==a){n.pending=null;var i=a=a.next;do{l=e(l,i.action),i=i.next}while(i!==a);ur(l,t.memoizedState)||(Ei=!0),t.memoizedState=l,null===t.baseQueue&&(t.baseState=l),n.lastRenderedState=l}return[l,r]}function Ml(){}function Rl(e,t){var n=gl,r=Ol(),a=t(),l=!ur(r.memoizedState,a);if(l&&(r.memoizedState=a,Ei=!0),r=r.queue,ql(Il.bind(null,n,r,e),[e]),r.getSnapshot!==t||l||null!==vl&&1&vl.memoizedState.tag){if(n.flags|=2048,zl(9,Al.bind(null,n,r,a,t),void 0,null),null===Tu)throw Error(o(349));0!=(30&ml)||jl(n,t,a)}return a}function jl(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},null===(t=gl.updateQueue)?(t={lastEffect:null,stores:null},gl.updateQueue=t,t.stores=[e]):null===(n=t.stores)?t.stores=[e]:n.push(e)}function Al(e,t,n,r){t.value=n,t.getSnapshot=r,Fl(t)&&Ll(e)}function Il(e,t,n){return n((function(){Fl(t)&&Ll(e)}))}function Fl(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!ur(e,n)}catch(e){return!0}}function Ll(e){var t=No(e,1);null!==t&&rs(t,e,1,-1)}function Ul(e){var t=Dl();return"function"==typeof e&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Pl,lastRenderedState:e},t.queue=e,e=e.dispatch=ri.bind(null,gl,e),[t.memoizedState,e]}function zl(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},null===(t=gl.updateQueue)?(t={lastEffect:null,stores:null},gl.updateQueue=t,t.lastEffect=e.next=e):null===(n=t.lastEffect)?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e),e}function Yl(){return Ol().memoizedState}function Wl(e,t,n,r){var a=Dl();gl.flags|=e,a.memoizedState=zl(1|t,n,void 0,void 0===r?null:r)}function Bl(e,t,n,r){var a=Ol();r=void 0===r?null:r;var o=void 0;if(null!==yl){var l=yl.memoizedState;if(o=l.destroy,null!==r&&Sl(r,l.deps))return void(a.memoizedState=zl(t,n,o,r))}gl.flags|=e,a.memoizedState=zl(1|t,n,o,r)}function Hl(e,t){return Wl(8390656,8,e,t)}function ql(e,t){return Bl(2048,8,e,t)}function Vl(e,t){return Bl(4,2,e,t)}function $l(e,t){return Bl(4,4,e,t)}function Zl(e,t){return"function"==typeof t?(e=e(),t(e),function(){t(null)}):null!=t?(e=e(),t.current=e,function(){t.current=null}):void 0}function Ql(e,t,n){return n=null!=n?n.concat([e]):null,Bl(4,4,Zl.bind(null,t,e),n)}function Kl(){}function Gl(e,t){var n=Ol();t=void 0===t?null:t;var r=n.memoizedState;return null!==r&&null!==t&&Sl(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function Xl(e,t){var n=Ol();t=void 0===t?null:t;var r=n.memoizedState;return null!==r&&null!==t&&Sl(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function Jl(e,t,n){return 0==(21&ml)?(e.baseState&&(e.baseState=!1,Ei=!0),e.memoizedState=n):(ur(n,t)||(n=mt(),gl.lanes|=n,Fu|=n,e.baseState=!0),t)}function ei(e,t){var n=bt;bt=0!==n&&4>n?n:4,e(!0);var r=hl.transition;hl.transition={};try{e(!1),t()}finally{bt=n,hl.transition=r}}function ti(){return Ol().memoizedState}function ni(e,t,n){var r=ns(e);n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},ai(e)?oi(t,n):null!==(n=To(e,t,n,r))&&(rs(n,e,r,ts()),li(n,t,r))}function ri(e,t,n){var r=ns(e),a={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(ai(e))oi(t,a);else{var o=e.alternate;if(0===e.lanes&&(null===o||0===o.lanes)&&null!==(o=t.lastRenderedReducer))try{var l=t.lastRenderedState,i=o(l,n);if(a.hasEagerState=!0,a.eagerState=i,ur(i,l)){var u=t.interleaved;return null===u?(a.next=a,Po(t)):(a.next=u.next,u.next=a),void(t.interleaved=a)}}catch(e){}null!==(n=To(e,t,a,r))&&(rs(n,e,r,a=ts()),li(n,t,r))}}function ai(e){var t=e.alternate;return e===gl||null!==t&&t===gl}function oi(e,t){wl=bl=!0;var n=e.pending;null===n?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function li(e,t,n){if(0!=(4194240&n)){var r=t.lanes;n|=r&=e.pendingLanes,t.lanes=n,vt(e,n)}}var ii={readContext:Do,useCallback:xl,useContext:xl,useEffect:xl,useImperativeHandle:xl,useInsertionEffect:xl,useLayoutEffect:xl,useMemo:xl,useReducer:xl,useRef:xl,useState:xl,useDebugValue:xl,useDeferredValue:xl,useTransition:xl,useMutableSource:xl,useSyncExternalStore:xl,useId:xl,unstable_isNewReconciler:!1},ui={readContext:Do,useCallback:function(e,t){return Dl().memoizedState=[e,void 0===t?null:t],e},useContext:Do,useEffect:Hl,useImperativeHandle:function(e,t,n){return n=null!=n?n.concat([e]):null,Wl(4194308,4,Zl.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Wl(4194308,4,e,t)},useInsertionEffect:function(e,t){return Wl(4,2,e,t)},useMemo:function(e,t){var n=Dl();return t=void 0===t?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Dl();return t=void 0!==n?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=ni.bind(null,gl,e),[r.memoizedState,e]},useRef:function(e){return e={current:e},Dl().memoizedState=e},useState:Ul,useDebugValue:Kl,useDeferredValue:function(e){return Dl().memoizedState=e},useTransition:function(){var e=Ul(!1),t=e[0];return e=ei.bind(null,e[1]),Dl().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=gl,a=Dl();if(oo){if(void 0===n)throw Error(o(407));n=n()}else{if(n=t(),null===Tu)throw Error(o(349));0!=(30&ml)||jl(r,t,n)}a.memoizedState=n;var l={value:n,getSnapshot:t};return a.queue=l,Hl(Il.bind(null,r,l,e),[e]),r.flags|=2048,zl(9,Al.bind(null,r,l,n,t),void 0,null),n},useId:function(){var e=Dl(),t=Tu.identifierPrefix;if(oo){var n=Xa;t=":"+t+"R"+(n=(Ga&~(1<<32-lt(Ga)-1)).toString(32)+n),0<(n=El++)&&(t+="H"+n.toString(32)),t+=":"}else t=":"+t+"r"+(n=_l++).toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},si={readContext:Do,useCallback:Gl,useContext:Do,useEffect:ql,useImperativeHandle:Ql,useInsertionEffect:Vl,useLayoutEffect:$l,useMemo:Xl,useReducer:Tl,useRef:Yl,useState:function(){return Tl(Pl)},useDebugValue:Kl,useDeferredValue:function(e){return Jl(Ol(),yl.memoizedState,e)},useTransition:function(){return[Tl(Pl)[0],Ol().memoizedState]},useMutableSource:Ml,useSyncExternalStore:Rl,useId:ti,unstable_isNewReconciler:!1},ci={readContext:Do,useCallback:Gl,useContext:Do,useEffect:ql,useImperativeHandle:Ql,useInsertionEffect:Vl,useLayoutEffect:$l,useMemo:Xl,useReducer:Nl,useRef:Yl,useState:function(){return Nl(Pl)},useDebugValue:Kl,useDeferredValue:function(e){var t=Ol();return null===yl?t.memoizedState=e:Jl(t,yl.memoizedState,e)},useTransition:function(){return[Nl(Pl)[0],Ol().memoizedState]},useMutableSource:Ml,useSyncExternalStore:Rl,useId:ti,unstable_isNewReconciler:!1};function pi(e,t){try{var n="",r=t;do{n+=Y(r),r=r.return}while(r);var a=n}catch(e){a="\nError generating stack: "+e.message+"\n"+e.stack}return{value:e,source:t,stack:a,digest:null}}function di(e,t,n){return{value:e,source:null,stack:null!=n?n:null,digest:null!=t?t:null}}function fi(e,t){try{console.error(t.value)}catch(e){setTimeout((function(){throw e}))}}var hi="function"==typeof WeakMap?WeakMap:Map;function mi(e,t,n){(n=Ao(-1,n)).tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){qu||(qu=!0,Vu=r),fi(0,t)},n}function gi(e,t,n){(n=Ao(-1,n)).tag=3;var r=e.type.getDerivedStateFromError;if("function"==typeof r){var a=t.value;n.payload=function(){return r(a)},n.callback=function(){fi(0,t)}}var o=e.stateNode;return null!==o&&"function"==typeof o.componentDidCatch&&(n.callback=function(){fi(0,t),"function"!=typeof r&&(null===$u?$u=new Set([this]):$u.add(this));var e=t.stack;this.componentDidCatch(t.value,{componentStack:null!==e?e:""})}),n}function yi(e,t,n){var r=e.pingCache;if(null===r){r=e.pingCache=new hi;var a=new Set;r.set(t,a)}else void 0===(a=r.get(t))&&(a=new Set,r.set(t,a));a.has(n)||(a.add(n),e=Cs.bind(null,e,t,n),t.then(e,e))}function vi(e){do{var t;if((t=13===e.tag)&&(t=null===(t=e.memoizedState)||null!==t.dehydrated),t)return e;e=e.return}while(null!==e);return null}function bi(e,t,n,r,a){return 0==(1&e.mode)?(e===t?e.flags|=65536:(e.flags|=128,n.flags|=131072,n.flags&=-52805,1===n.tag&&(null===n.alternate?n.tag=17:((t=Ao(-1,1)).tag=2,Io(n,t,1))),n.lanes|=1),e):(e.flags|=65536,e.lanes=a,e)}var wi=w.ReactCurrentOwner,Ei=!1;function _i(e,t,n,r){t.child=null===e?Jo(t,null,n,r):Xo(t,e.child,n,r)}function xi(e,t,n,r,a){n=n.render;var o=t.ref;return Co(t,a),r=kl(e,t,n,r,o,a),n=Cl(),null===e||Ei?(oo&&n&&to(t),t.flags|=1,_i(e,t,r,a),t.child):(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~a,qi(e,t,a))}function Si(e,t,n,r,a){if(null===e){var o=n.type;return"function"!=typeof o||Rs(o)||void 0!==o.defaultProps||null!==n.compare||void 0!==n.defaultProps?((e=As(n.type,null,r,t,t.mode,a)).ref=t.ref,e.return=t,t.child=e):(t.tag=15,t.type=o,ki(e,t,o,r,a))}if(o=e.child,0==(e.lanes&a)){var l=o.memoizedProps;if((n=null!==(n=n.compare)?n:sr)(l,r)&&e.ref===t.ref)return qi(e,t,a)}return t.flags|=1,(e=js(o,r)).ref=t.ref,e.return=t,t.child=e}function ki(e,t,n,r,a){if(null!==e){var o=e.memoizedProps;if(sr(o,r)&&e.ref===t.ref){if(Ei=!1,t.pendingProps=r=o,0==(e.lanes&a))return t.lanes=e.lanes,qi(e,t,a);0!=(131072&e.flags)&&(Ei=!0)}}return Oi(e,t,n,r,a)}function Ci(e,t,n){var r=t.pendingProps,a=r.children,o=null!==e?e.memoizedState:null;if("hidden"===r.mode)if(0==(1&t.mode))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},Da(ju,Ru),Ru|=n;else{if(0==(1073741824&n))return e=null!==o?o.baseLanes|n:n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,Da(ju,Ru),Ru|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=null!==o?o.baseLanes:n,Da(ju,Ru),Ru|=r}else null!==o?(r=o.baseLanes|n,t.memoizedState=null):r=n,Da(ju,Ru),Ru|=r;return _i(e,t,a,n),t.child}function Di(e,t){var n=t.ref;(null===e&&null!==n||null!==e&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function Oi(e,t,n,r,a){var o=Ra(n)?Na:Pa.current;return o=Ma(t,o),Co(t,a),n=kl(e,t,n,r,o,a),r=Cl(),null===e||Ei?(oo&&r&&to(t),t.flags|=1,_i(e,t,n,a),t.child):(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~a,qi(e,t,a))}function Pi(e,t,n,r,a){if(Ra(n)){var o=!0;Fa(t)}else o=!1;if(Co(t,a),null===t.stateNode)Hi(e,t),qo(t,n,r),$o(t,n,r,a),r=!0;else if(null===e){var l=t.stateNode,i=t.memoizedProps;l.props=i;var u=l.context,s=n.contextType;s="object"==typeof s&&null!==s?Do(s):Ma(t,s=Ra(n)?Na:Pa.current);var c=n.getDerivedStateFromProps,p="function"==typeof c||"function"==typeof l.getSnapshotBeforeUpdate;p||"function"!=typeof l.UNSAFE_componentWillReceiveProps&&"function"!=typeof l.componentWillReceiveProps||(i!==r||u!==s)&&Vo(t,l,r,s),Mo=!1;var d=t.memoizedState;l.state=d,Uo(t,r,l,a),u=t.memoizedState,i!==r||d!==u||Ta.current||Mo?("function"==typeof c&&(Wo(t,n,c,r),u=t.memoizedState),(i=Mo||Ho(t,n,i,r,d,u,s))?(p||"function"!=typeof l.UNSAFE_componentWillMount&&"function"!=typeof l.componentWillMount||("function"==typeof l.componentWillMount&&l.componentWillMount(),"function"==typeof l.UNSAFE_componentWillMount&&l.UNSAFE_componentWillMount()),"function"==typeof l.componentDidMount&&(t.flags|=4194308)):("function"==typeof l.componentDidMount&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=u),l.props=r,l.state=u,l.context=s,r=i):("function"==typeof l.componentDidMount&&(t.flags|=4194308),r=!1)}else{l=t.stateNode,jo(e,t),i=t.memoizedProps,s=t.type===t.elementType?i:vo(t.type,i),l.props=s,p=t.pendingProps,d=l.context,u="object"==typeof(u=n.contextType)&&null!==u?Do(u):Ma(t,u=Ra(n)?Na:Pa.current);var f=n.getDerivedStateFromProps;(c="function"==typeof f||"function"==typeof l.getSnapshotBeforeUpdate)||"function"!=typeof l.UNSAFE_componentWillReceiveProps&&"function"!=typeof l.componentWillReceiveProps||(i!==p||d!==u)&&Vo(t,l,r,u),Mo=!1,d=t.memoizedState,l.state=d,Uo(t,r,l,a);var h=t.memoizedState;i!==p||d!==h||Ta.current||Mo?("function"==typeof f&&(Wo(t,n,f,r),h=t.memoizedState),(s=Mo||Ho(t,n,s,r,d,h,u)||!1)?(c||"function"!=typeof l.UNSAFE_componentWillUpdate&&"function"!=typeof l.componentWillUpdate||("function"==typeof l.componentWillUpdate&&l.componentWillUpdate(r,h,u),"function"==typeof l.UNSAFE_componentWillUpdate&&l.UNSAFE_componentWillUpdate(r,h,u)),"function"==typeof l.componentDidUpdate&&(t.flags|=4),"function"==typeof l.getSnapshotBeforeUpdate&&(t.flags|=1024)):("function"!=typeof l.componentDidUpdate||i===e.memoizedProps&&d===e.memoizedState||(t.flags|=4),"function"!=typeof l.getSnapshotBeforeUpdate||i===e.memoizedProps&&d===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=h),l.props=r,l.state=h,l.context=u,r=s):("function"!=typeof l.componentDidUpdate||i===e.memoizedProps&&d===e.memoizedState||(t.flags|=4),"function"!=typeof l.getSnapshotBeforeUpdate||i===e.memoizedProps&&d===e.memoizedState||(t.flags|=1024),r=!1)}return Ti(e,t,n,r,o,a)}function Ti(e,t,n,r,a,o){Di(e,t);var l=0!=(128&t.flags);if(!r&&!l)return a&&La(t,n,!1),qi(e,t,o);r=t.stateNode,wi.current=t;var i=l&&"function"!=typeof n.getDerivedStateFromError?null:r.render();return t.flags|=1,null!==e&&l?(t.child=Xo(t,e.child,null,o),t.child=Xo(t,null,i,o)):_i(e,t,i,o),t.memoizedState=r.state,a&&La(t,n,!0),t.child}function Ni(e){var t=e.stateNode;t.pendingContext?Aa(0,t.pendingContext,t.pendingContext!==t.context):t.context&&Aa(0,t.context,!1),ol(e,t.containerInfo)}function Mi(e,t,n,r,a){return mo(),go(a),t.flags|=256,_i(e,t,n,r),t.child}var Ri,ji,Ai,Ii={dehydrated:null,treeContext:null,retryLane:0};function Fi(e){return{baseLanes:e,cachePool:null,transitions:null}}function Li(e,t,n){var r,a=t.pendingProps,l=sl.current,i=!1,u=0!=(128&t.flags);if((r=u)||(r=(null===e||null!==e.memoizedState)&&0!=(2&l)),r?(i=!0,t.flags&=-129):null!==e&&null===e.memoizedState||(l|=1),Da(sl,1&l),null===e)return co(t),null!==(e=t.memoizedState)&&null!==(e=e.dehydrated)?(0==(1&t.mode)?t.lanes=1:"$!"===e.data?t.lanes=8:t.lanes=1073741824,null):(u=a.children,e=a.fallback,i?(a=t.mode,i=t.child,u={mode:"hidden",children:u},0==(1&a)&&null!==i?(i.childLanes=0,i.pendingProps=u):i=Fs(u,a,0,null),e=Is(e,a,n,null),i.return=t,e.return=t,i.sibling=e,t.child=i,t.child.memoizedState=Fi(n),t.memoizedState=Ii,e):Ui(t,u));if(null!==(l=e.memoizedState)&&null!==(r=l.dehydrated))return function(e,t,n,r,a,l,i){if(n)return 256&t.flags?(t.flags&=-257,zi(e,t,i,r=di(Error(o(422))))):null!==t.memoizedState?(t.child=e.child,t.flags|=128,null):(l=r.fallback,a=t.mode,r=Fs({mode:"visible",children:r.children},a,0,null),(l=Is(l,a,i,null)).flags|=2,r.return=t,l.return=t,r.sibling=l,t.child=r,0!=(1&t.mode)&&Xo(t,e.child,null,i),t.child.memoizedState=Fi(i),t.memoizedState=Ii,l);if(0==(1&t.mode))return zi(e,t,i,null);if("$!"===a.data){if(r=a.nextSibling&&a.nextSibling.dataset)var u=r.dgst;return r=u,zi(e,t,i,r=di(l=Error(o(419)),r,void 0))}if(u=0!=(i&e.childLanes),Ei||u){if(null!==(r=Tu)){switch(i&-i){case 4:a=2;break;case 16:a=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:a=32;break;case 536870912:a=268435456;break;default:a=0}0!==(a=0!=(a&(r.suspendedLanes|i))?0:a)&&a!==l.retryLane&&(l.retryLane=a,No(e,a),rs(r,e,a,-1))}return gs(),zi(e,t,i,r=di(Error(o(421))))}return"$?"===a.data?(t.flags|=128,t.child=e.child,t=Os.bind(null,e),a._reactRetry=t,null):(e=l.treeContext,ao=ca(a.nextSibling),ro=t,oo=!0,lo=null,null!==e&&(Za[Qa++]=Ga,Za[Qa++]=Xa,Za[Qa++]=Ka,Ga=e.id,Xa=e.overflow,Ka=t),(t=Ui(t,r.children)).flags|=4096,t)}(e,t,u,a,r,l,n);if(i){i=a.fallback,u=t.mode,r=(l=e.child).sibling;var s={mode:"hidden",children:a.children};return 0==(1&u)&&t.child!==l?((a=t.child).childLanes=0,a.pendingProps=s,t.deletions=null):(a=js(l,s)).subtreeFlags=14680064&l.subtreeFlags,null!==r?i=js(r,i):(i=Is(i,u,n,null)).flags|=2,i.return=t,a.return=t,a.sibling=i,t.child=a,a=i,i=t.child,u=null===(u=e.child.memoizedState)?Fi(n):{baseLanes:u.baseLanes|n,cachePool:null,transitions:u.transitions},i.memoizedState=u,i.childLanes=e.childLanes&~n,t.memoizedState=Ii,a}return e=(i=e.child).sibling,a=js(i,{mode:"visible",children:a.children}),0==(1&t.mode)&&(a.lanes=n),a.return=t,a.sibling=null,null!==e&&(null===(n=t.deletions)?(t.deletions=[e],t.flags|=16):n.push(e)),t.child=a,t.memoizedState=null,a}function Ui(e,t){return(t=Fs({mode:"visible",children:t},e.mode,0,null)).return=e,e.child=t}function zi(e,t,n,r){return null!==r&&go(r),Xo(t,e.child,null,n),(e=Ui(t,t.pendingProps.children)).flags|=2,t.memoizedState=null,e}function Yi(e,t,n){e.lanes|=t;var r=e.alternate;null!==r&&(r.lanes|=t),ko(e.return,t,n)}function Wi(e,t,n,r,a){var o=e.memoizedState;null===o?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:a}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=a)}function Bi(e,t,n){var r=t.pendingProps,a=r.revealOrder,o=r.tail;if(_i(e,t,r.children,n),0!=(2&(r=sl.current)))r=1&r|2,t.flags|=128;else{if(null!==e&&0!=(128&e.flags))e:for(e=t.child;null!==e;){if(13===e.tag)null!==e.memoizedState&&Yi(e,n,t);else if(19===e.tag)Yi(e,n,t);else if(null!==e.child){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;null===e.sibling;){if(null===e.return||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(Da(sl,r),0==(1&t.mode))t.memoizedState=null;else switch(a){case"forwards":for(n=t.child,a=null;null!==n;)null!==(e=n.alternate)&&null===cl(e)&&(a=n),n=n.sibling;null===(n=a)?(a=t.child,t.child=null):(a=n.sibling,n.sibling=null),Wi(t,!1,a,n,o);break;case"backwards":for(n=null,a=t.child,t.child=null;null!==a;){if(null!==(e=a.alternate)&&null===cl(e)){t.child=a;break}e=a.sibling,a.sibling=n,n=a,a=e}Wi(t,!0,n,null,o);break;case"together":Wi(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function Hi(e,t){0==(1&t.mode)&&null!==e&&(e.alternate=null,t.alternate=null,t.flags|=2)}function qi(e,t,n){if(null!==e&&(t.dependencies=e.dependencies),Fu|=t.lanes,0==(n&t.childLanes))return null;if(null!==e&&t.child!==e.child)throw Error(o(153));if(null!==t.child){for(n=js(e=t.child,e.pendingProps),t.child=n,n.return=t;null!==e.sibling;)e=e.sibling,(n=n.sibling=js(e,e.pendingProps)).return=t;n.sibling=null}return t.child}function Vi(e,t){if(!oo)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;null!==t;)null!==t.alternate&&(n=t),t=t.sibling;null===n?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var r=null;null!==n;)null!==n.alternate&&(r=n),n=n.sibling;null===r?t||null===e.tail?e.tail=null:e.tail.sibling=null:r.sibling=null}}function $i(e){var t=null!==e.alternate&&e.alternate.child===e.child,n=0,r=0;if(t)for(var a=e.child;null!==a;)n|=a.lanes|a.childLanes,r|=14680064&a.subtreeFlags,r|=14680064&a.flags,a.return=e,a=a.sibling;else for(a=e.child;null!==a;)n|=a.lanes|a.childLanes,r|=a.subtreeFlags,r|=a.flags,a.return=e,a=a.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function Zi(e,t,n){var r=t.pendingProps;switch(no(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return $i(t),null;case 1:case 17:return Ra(t.type)&&ja(),$i(t),null;case 3:return r=t.stateNode,ll(),Ca(Ta),Ca(Pa),dl(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),null!==e&&null!==e.child||(fo(t)?t.flags|=4:null===e||e.memoizedState.isDehydrated&&0==(256&t.flags)||(t.flags|=1024,null!==lo&&(is(lo),lo=null))),$i(t),null;case 5:ul(t);var a=al(rl.current);if(n=t.type,null!==e&&null!=t.stateNode)ji(e,t,n,r),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(null===t.stateNode)throw Error(o(166));return $i(t),null}if(e=al(tl.current),fo(t)){r=t.stateNode,n=t.type;var l=t.memoizedProps;switch(r[fa]=t,r[ha]=l,e=0!=(1&t.mode),n){case"dialog":zr("cancel",r),zr("close",r);break;case"iframe":case"object":case"embed":zr("load",r);break;case"video":case"audio":for(a=0;a<Ir.length;a++)zr(Ir[a],r);break;case"source":zr("error",r);break;case"img":case"image":case"link":zr("error",r),zr("load",r);break;case"details":zr("toggle",r);break;case"input":K(r,l),zr("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!l.multiple},zr("invalid",r);break;case"textarea":ae(r,l),zr("invalid",r)}for(var u in ve(n,l),a=null,l)if(l.hasOwnProperty(u)){var s=l[u];"children"===u?"string"==typeof s?r.textContent!==s&&(!0!==l.suppressHydrationWarning&&Jr(r.textContent,s,e),a=["children",s]):"number"==typeof s&&r.textContent!==""+s&&(!0!==l.suppressHydrationWarning&&Jr(r.textContent,s,e),a=["children",""+s]):i.hasOwnProperty(u)&&null!=s&&"onScroll"===u&&zr("scroll",r)}switch(n){case"input":V(r),J(r,l,!0);break;case"textarea":V(r),le(r);break;case"select":case"option":break;default:"function"==typeof l.onClick&&(r.onclick=ea)}r=a,t.updateQueue=r,null!==r&&(t.flags|=4)}else{u=9===a.nodeType?a:a.ownerDocument,"http://www.w3.org/1999/xhtml"===e&&(e=ie(n)),"http://www.w3.org/1999/xhtml"===e?"script"===n?((e=u.createElement("div")).innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):"string"==typeof r.is?e=u.createElement(n,{is:r.is}):(e=u.createElement(n),"select"===n&&(u=e,r.multiple?u.multiple=!0:r.size&&(u.size=r.size))):e=u.createElementNS(e,n),e[fa]=t,e[ha]=r,Ri(e,t),t.stateNode=e;e:{switch(u=be(n,r),n){case"dialog":zr("cancel",e),zr("close",e),a=r;break;case"iframe":case"object":case"embed":zr("load",e),a=r;break;case"video":case"audio":for(a=0;a<Ir.length;a++)zr(Ir[a],e);a=r;break;case"source":zr("error",e),a=r;break;case"img":case"image":case"link":zr("error",e),zr("load",e),a=r;break;case"details":zr("toggle",e),a=r;break;case"input":K(e,r),a=Q(e,r),zr("invalid",e);break;case"option":default:a=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},a=F({},r,{value:void 0}),zr("invalid",e);break;case"textarea":ae(e,r),a=re(e,r),zr("invalid",e)}for(l in ve(n,a),s=a)if(s.hasOwnProperty(l)){var c=s[l];"style"===l?ge(e,c):"dangerouslySetInnerHTML"===l?null!=(c=c?c.__html:void 0)&&pe(e,c):"children"===l?"string"==typeof c?("textarea"!==n||""!==c)&&de(e,c):"number"==typeof c&&de(e,""+c):"suppressContentEditableWarning"!==l&&"suppressHydrationWarning"!==l&&"autoFocus"!==l&&(i.hasOwnProperty(l)?null!=c&&"onScroll"===l&&zr("scroll",e):null!=c&&b(e,l,c,u))}switch(n){case"input":V(e),J(e,r,!1);break;case"textarea":V(e),le(e);break;case"option":null!=r.value&&e.setAttribute("value",""+H(r.value));break;case"select":e.multiple=!!r.multiple,null!=(l=r.value)?ne(e,!!r.multiple,l,!1):null!=r.defaultValue&&ne(e,!!r.multiple,r.defaultValue,!0);break;default:"function"==typeof a.onClick&&(e.onclick=ea)}switch(n){case"button":case"input":case"select":case"textarea":r=!!r.autoFocus;break e;case"img":r=!0;break e;default:r=!1}}r&&(t.flags|=4)}null!==t.ref&&(t.flags|=512,t.flags|=2097152)}return $i(t),null;case 6:if(e&&null!=t.stateNode)Ai(0,t,e.memoizedProps,r);else{if("string"!=typeof r&&null===t.stateNode)throw Error(o(166));if(n=al(rl.current),al(tl.current),fo(t)){if(r=t.stateNode,n=t.memoizedProps,r[fa]=t,(l=r.nodeValue!==n)&&null!==(e=ro))switch(e.tag){case 3:Jr(r.nodeValue,n,0!=(1&e.mode));break;case 5:!0!==e.memoizedProps.suppressHydrationWarning&&Jr(r.nodeValue,n,0!=(1&e.mode))}l&&(t.flags|=4)}else(r=(9===n.nodeType?n:n.ownerDocument).createTextNode(r))[fa]=t,t.stateNode=r}return $i(t),null;case 13:if(Ca(sl),r=t.memoizedState,null===e||null!==e.memoizedState&&null!==e.memoizedState.dehydrated){if(oo&&null!==ao&&0!=(1&t.mode)&&0==(128&t.flags))ho(),mo(),t.flags|=98560,l=!1;else if(l=fo(t),null!==r&&null!==r.dehydrated){if(null===e){if(!l)throw Error(o(318));if(!(l=null!==(l=t.memoizedState)?l.dehydrated:null))throw Error(o(317));l[fa]=t}else mo(),0==(128&t.flags)&&(t.memoizedState=null),t.flags|=4;$i(t),l=!1}else null!==lo&&(is(lo),lo=null),l=!0;if(!l)return 65536&t.flags?t:null}return 0!=(128&t.flags)?(t.lanes=n,t):((r=null!==r)!=(null!==e&&null!==e.memoizedState)&&r&&(t.child.flags|=8192,0!=(1&t.mode)&&(null===e||0!=(1&sl.current)?0===Au&&(Au=3):gs())),null!==t.updateQueue&&(t.flags|=4),$i(t),null);case 4:return ll(),null===e&&Br(t.stateNode.containerInfo),$i(t),null;case 10:return So(t.type._context),$i(t),null;case 19:if(Ca(sl),null===(l=t.memoizedState))return $i(t),null;if(r=0!=(128&t.flags),null===(u=l.rendering))if(r)Vi(l,!1);else{if(0!==Au||null!==e&&0!=(128&e.flags))for(e=t.child;null!==e;){if(null!==(u=cl(e))){for(t.flags|=128,Vi(l,!1),null!==(r=u.updateQueue)&&(t.updateQueue=r,t.flags|=4),t.subtreeFlags=0,r=n,n=t.child;null!==n;)e=r,(l=n).flags&=14680066,null===(u=l.alternate)?(l.childLanes=0,l.lanes=e,l.child=null,l.subtreeFlags=0,l.memoizedProps=null,l.memoizedState=null,l.updateQueue=null,l.dependencies=null,l.stateNode=null):(l.childLanes=u.childLanes,l.lanes=u.lanes,l.child=u.child,l.subtreeFlags=0,l.deletions=null,l.memoizedProps=u.memoizedProps,l.memoizedState=u.memoizedState,l.updateQueue=u.updateQueue,l.type=u.type,e=u.dependencies,l.dependencies=null===e?null:{lanes:e.lanes,firstContext:e.firstContext}),n=n.sibling;return Da(sl,1&sl.current|2),t.child}e=e.sibling}null!==l.tail&&Ge()>Bu&&(t.flags|=128,r=!0,Vi(l,!1),t.lanes=4194304)}else{if(!r)if(null!==(e=cl(u))){if(t.flags|=128,r=!0,null!==(n=e.updateQueue)&&(t.updateQueue=n,t.flags|=4),Vi(l,!0),null===l.tail&&"hidden"===l.tailMode&&!u.alternate&&!oo)return $i(t),null}else 2*Ge()-l.renderingStartTime>Bu&&1073741824!==n&&(t.flags|=128,r=!0,Vi(l,!1),t.lanes=4194304);l.isBackwards?(u.sibling=t.child,t.child=u):(null!==(n=l.last)?n.sibling=u:t.child=u,l.last=u)}return null!==l.tail?(t=l.tail,l.rendering=t,l.tail=t.sibling,l.renderingStartTime=Ge(),t.sibling=null,n=sl.current,Da(sl,r?1&n|2:1&n),t):($i(t),null);case 22:case 23:return ds(),r=null!==t.memoizedState,null!==e&&null!==e.memoizedState!==r&&(t.flags|=8192),r&&0!=(1&t.mode)?0!=(1073741824&Ru)&&($i(t),6&t.subtreeFlags&&(t.flags|=8192)):$i(t),null;case 24:case 25:return null}throw Error(o(156,t.tag))}function Qi(e,t){switch(no(t),t.tag){case 1:return Ra(t.type)&&ja(),65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 3:return ll(),Ca(Ta),Ca(Pa),dl(),0!=(65536&(e=t.flags))&&0==(128&e)?(t.flags=-65537&e|128,t):null;case 5:return ul(t),null;case 13:if(Ca(sl),null!==(e=t.memoizedState)&&null!==e.dehydrated){if(null===t.alternate)throw Error(o(340));mo()}return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 19:return Ca(sl),null;case 4:return ll(),null;case 10:return So(t.type._context),null;case 22:case 23:return ds(),null;default:return null}}Ri=function(e,t){for(var n=t.child;null!==n;){if(5===n.tag||6===n.tag)e.appendChild(n.stateNode);else if(4!==n.tag&&null!==n.child){n.child.return=n,n=n.child;continue}if(n===t)break;for(;null===n.sibling;){if(null===n.return||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}},ji=function(e,t,n,r){var a=e.memoizedProps;if(a!==r){e=t.stateNode,al(tl.current);var o,l=null;switch(n){case"input":a=Q(e,a),r=Q(e,r),l=[];break;case"select":a=F({},a,{value:void 0}),r=F({},r,{value:void 0}),l=[];break;case"textarea":a=re(e,a),r=re(e,r),l=[];break;default:"function"!=typeof a.onClick&&"function"==typeof r.onClick&&(e.onclick=ea)}for(c in ve(n,r),n=null,a)if(!r.hasOwnProperty(c)&&a.hasOwnProperty(c)&&null!=a[c])if("style"===c){var u=a[c];for(o in u)u.hasOwnProperty(o)&&(n||(n={}),n[o]="")}else"dangerouslySetInnerHTML"!==c&&"children"!==c&&"suppressContentEditableWarning"!==c&&"suppressHydrationWarning"!==c&&"autoFocus"!==c&&(i.hasOwnProperty(c)?l||(l=[]):(l=l||[]).push(c,null));for(c in r){var s=r[c];if(u=null!=a?a[c]:void 0,r.hasOwnProperty(c)&&s!==u&&(null!=s||null!=u))if("style"===c)if(u){for(o in u)!u.hasOwnProperty(o)||s&&s.hasOwnProperty(o)||(n||(n={}),n[o]="");for(o in s)s.hasOwnProperty(o)&&u[o]!==s[o]&&(n||(n={}),n[o]=s[o])}else n||(l||(l=[]),l.push(c,n)),n=s;else"dangerouslySetInnerHTML"===c?(s=s?s.__html:void 0,u=u?u.__html:void 0,null!=s&&u!==s&&(l=l||[]).push(c,s)):"children"===c?"string"!=typeof s&&"number"!=typeof s||(l=l||[]).push(c,""+s):"suppressContentEditableWarning"!==c&&"suppressHydrationWarning"!==c&&(i.hasOwnProperty(c)?(null!=s&&"onScroll"===c&&zr("scroll",e),l||u===s||(l=[])):(l=l||[]).push(c,s))}n&&(l=l||[]).push("style",n);var c=l;(t.updateQueue=c)&&(t.flags|=4)}},Ai=function(e,t,n,r){n!==r&&(t.flags|=4)};var Ki=!1,Gi=!1,Xi="function"==typeof WeakSet?WeakSet:Set,Ji=null;function eu(e,t){var n=e.ref;if(null!==n)if("function"==typeof n)try{n(null)}catch(n){ks(e,t,n)}else n.current=null}function tu(e,t,n){try{n()}catch(n){ks(e,t,n)}}var nu=!1;function ru(e,t,n){var r=t.updateQueue;if(null!==(r=null!==r?r.lastEffect:null)){var a=r=r.next;do{if((a.tag&e)===e){var o=a.destroy;a.destroy=void 0,void 0!==o&&tu(t,n,o)}a=a.next}while(a!==r)}}function au(e,t){if(null!==(t=null!==(t=t.updateQueue)?t.lastEffect:null)){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function ou(e){var t=e.ref;if(null!==t){var n=e.stateNode;e.tag,e=n,"function"==typeof t?t(e):t.current=e}}function lu(e){var t=e.alternate;null!==t&&(e.alternate=null,lu(t)),e.child=null,e.deletions=null,e.sibling=null,5===e.tag&&null!==(t=e.stateNode)&&(delete t[fa],delete t[ha],delete t[ga],delete t[ya],delete t[va]),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function iu(e){return 5===e.tag||3===e.tag||4===e.tag}function uu(e){e:for(;;){for(;null===e.sibling;){if(null===e.return||iu(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;5!==e.tag&&6!==e.tag&&18!==e.tag;){if(2&e.flags)continue e;if(null===e.child||4===e.tag)continue e;e.child.return=e,e=e.child}if(!(2&e.flags))return e.stateNode}}function su(e,t,n){var r=e.tag;if(5===r||6===r)e=e.stateNode,t?8===n.nodeType?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(8===n.nodeType?(t=n.parentNode).insertBefore(e,n):(t=n).appendChild(e),null!=(n=n._reactRootContainer)||null!==t.onclick||(t.onclick=ea));else if(4!==r&&null!==(e=e.child))for(su(e,t,n),e=e.sibling;null!==e;)su(e,t,n),e=e.sibling}function cu(e,t,n){var r=e.tag;if(5===r||6===r)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(4!==r&&null!==(e=e.child))for(cu(e,t,n),e=e.sibling;null!==e;)cu(e,t,n),e=e.sibling}var pu=null,du=!1;function fu(e,t,n){for(n=n.child;null!==n;)hu(e,t,n),n=n.sibling}function hu(e,t,n){if(ot&&"function"==typeof ot.onCommitFiberUnmount)try{ot.onCommitFiberUnmount(at,n)}catch(e){}switch(n.tag){case 5:Gi||eu(n,t);case 6:var r=pu,a=du;pu=null,fu(e,t,n),du=a,null!==(pu=r)&&(du?(e=pu,n=n.stateNode,8===e.nodeType?e.parentNode.removeChild(n):e.removeChild(n)):pu.removeChild(n.stateNode));break;case 18:null!==pu&&(du?(e=pu,n=n.stateNode,8===e.nodeType?sa(e.parentNode,n):1===e.nodeType&&sa(e,n),Wt(e)):sa(pu,n.stateNode));break;case 4:r=pu,a=du,pu=n.stateNode.containerInfo,du=!0,fu(e,t,n),pu=r,du=a;break;case 0:case 11:case 14:case 15:if(!Gi&&null!==(r=n.updateQueue)&&null!==(r=r.lastEffect)){a=r=r.next;do{var o=a,l=o.destroy;o=o.tag,void 0!==l&&(0!=(2&o)||0!=(4&o))&&tu(n,t,l),a=a.next}while(a!==r)}fu(e,t,n);break;case 1:if(!Gi&&(eu(n,t),"function"==typeof(r=n.stateNode).componentWillUnmount))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(e){ks(n,t,e)}fu(e,t,n);break;case 21:fu(e,t,n);break;case 22:1&n.mode?(Gi=(r=Gi)||null!==n.memoizedState,fu(e,t,n),Gi=r):fu(e,t,n);break;default:fu(e,t,n)}}function mu(e){var t=e.updateQueue;if(null!==t){e.updateQueue=null;var n=e.stateNode;null===n&&(n=e.stateNode=new Xi),t.forEach((function(t){var r=Ps.bind(null,e,t);n.has(t)||(n.add(t),t.then(r,r))}))}}function gu(e,t){var n=t.deletions;if(null!==n)for(var r=0;r<n.length;r++){var a=n[r];try{var l=e,i=t,u=i;e:for(;null!==u;){switch(u.tag){case 5:pu=u.stateNode,du=!1;break e;case 3:case 4:pu=u.stateNode.containerInfo,du=!0;break e}u=u.return}if(null===pu)throw Error(o(160));hu(l,i,a),pu=null,du=!1;var s=a.alternate;null!==s&&(s.return=null),a.return=null}catch(e){ks(a,t,e)}}if(12854&t.subtreeFlags)for(t=t.child;null!==t;)yu(t,e),t=t.sibling}function yu(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(gu(t,e),vu(e),4&r){try{ru(3,e,e.return),au(3,e)}catch(t){ks(e,e.return,t)}try{ru(5,e,e.return)}catch(t){ks(e,e.return,t)}}break;case 1:gu(t,e),vu(e),512&r&&null!==n&&eu(n,n.return);break;case 5:if(gu(t,e),vu(e),512&r&&null!==n&&eu(n,n.return),32&e.flags){var a=e.stateNode;try{de(a,"")}catch(t){ks(e,e.return,t)}}if(4&r&&null!=(a=e.stateNode)){var l=e.memoizedProps,i=null!==n?n.memoizedProps:l,u=e.type,s=e.updateQueue;if(e.updateQueue=null,null!==s)try{"input"===u&&"radio"===l.type&&null!=l.name&&G(a,l),be(u,i);var c=be(u,l);for(i=0;i<s.length;i+=2){var p=s[i],d=s[i+1];"style"===p?ge(a,d):"dangerouslySetInnerHTML"===p?pe(a,d):"children"===p?de(a,d):b(a,p,d,c)}switch(u){case"input":X(a,l);break;case"textarea":oe(a,l);break;case"select":var f=a._wrapperState.wasMultiple;a._wrapperState.wasMultiple=!!l.multiple;var h=l.value;null!=h?ne(a,!!l.multiple,h,!1):f!==!!l.multiple&&(null!=l.defaultValue?ne(a,!!l.multiple,l.defaultValue,!0):ne(a,!!l.multiple,l.multiple?[]:"",!1))}a[ha]=l}catch(t){ks(e,e.return,t)}}break;case 6:if(gu(t,e),vu(e),4&r){if(null===e.stateNode)throw Error(o(162));a=e.stateNode,l=e.memoizedProps;try{a.nodeValue=l}catch(t){ks(e,e.return,t)}}break;case 3:if(gu(t,e),vu(e),4&r&&null!==n&&n.memoizedState.isDehydrated)try{Wt(t.containerInfo)}catch(t){ks(e,e.return,t)}break;case 4:default:gu(t,e),vu(e);break;case 13:gu(t,e),vu(e),8192&(a=e.child).flags&&(l=null!==a.memoizedState,a.stateNode.isHidden=l,!l||null!==a.alternate&&null!==a.alternate.memoizedState||(Wu=Ge())),4&r&&mu(e);break;case 22:if(p=null!==n&&null!==n.memoizedState,1&e.mode?(Gi=(c=Gi)||p,gu(t,e),Gi=c):gu(t,e),vu(e),8192&r){if(c=null!==e.memoizedState,(e.stateNode.isHidden=c)&&!p&&0!=(1&e.mode))for(Ji=e,p=e.child;null!==p;){for(d=Ji=p;null!==Ji;){switch(h=(f=Ji).child,f.tag){case 0:case 11:case 14:case 15:ru(4,f,f.return);break;case 1:eu(f,f.return);var m=f.stateNode;if("function"==typeof m.componentWillUnmount){r=f,n=f.return;try{t=r,m.props=t.memoizedProps,m.state=t.memoizedState,m.componentWillUnmount()}catch(e){ks(r,n,e)}}break;case 5:eu(f,f.return);break;case 22:if(null!==f.memoizedState){_u(d);continue}}null!==h?(h.return=f,Ji=h):_u(d)}p=p.sibling}e:for(p=null,d=e;;){if(5===d.tag){if(null===p){p=d;try{a=d.stateNode,c?"function"==typeof(l=a.style).setProperty?l.setProperty("display","none","important"):l.display="none":(u=d.stateNode,i=null!=(s=d.memoizedProps.style)&&s.hasOwnProperty("display")?s.display:null,u.style.display=me("display",i))}catch(t){ks(e,e.return,t)}}}else if(6===d.tag){if(null===p)try{d.stateNode.nodeValue=c?"":d.memoizedProps}catch(t){ks(e,e.return,t)}}else if((22!==d.tag&&23!==d.tag||null===d.memoizedState||d===e)&&null!==d.child){d.child.return=d,d=d.child;continue}if(d===e)break e;for(;null===d.sibling;){if(null===d.return||d.return===e)break e;p===d&&(p=null),d=d.return}p===d&&(p=null),d.sibling.return=d.return,d=d.sibling}}break;case 19:gu(t,e),vu(e),4&r&&mu(e);case 21:}}function vu(e){var t=e.flags;if(2&t){try{e:{for(var n=e.return;null!==n;){if(iu(n)){var r=n;break e}n=n.return}throw Error(o(160))}switch(r.tag){case 5:var a=r.stateNode;32&r.flags&&(de(a,""),r.flags&=-33),cu(e,uu(e),a);break;case 3:case 4:var l=r.stateNode.containerInfo;su(e,uu(e),l);break;default:throw Error(o(161))}}catch(t){ks(e,e.return,t)}e.flags&=-3}4096&t&&(e.flags&=-4097)}function bu(e,t,n){Ji=e,wu(e,t,n)}function wu(e,t,n){for(var r=0!=(1&e.mode);null!==Ji;){var a=Ji,o=a.child;if(22===a.tag&&r){var l=null!==a.memoizedState||Ki;if(!l){var i=a.alternate,u=null!==i&&null!==i.memoizedState||Gi;i=Ki;var s=Gi;if(Ki=l,(Gi=u)&&!s)for(Ji=a;null!==Ji;)u=(l=Ji).child,22===l.tag&&null!==l.memoizedState?xu(a):null!==u?(u.return=l,Ji=u):xu(a);for(;null!==o;)Ji=o,wu(o,t,n),o=o.sibling;Ji=a,Ki=i,Gi=s}Eu(e)}else 0!=(8772&a.subtreeFlags)&&null!==o?(o.return=a,Ji=o):Eu(e)}}function Eu(e){for(;null!==Ji;){var t=Ji;if(0!=(8772&t.flags)){var n=t.alternate;try{if(0!=(8772&t.flags))switch(t.tag){case 0:case 11:case 15:Gi||au(5,t);break;case 1:var r=t.stateNode;if(4&t.flags&&!Gi)if(null===n)r.componentDidMount();else{var a=t.elementType===t.type?n.memoizedProps:vo(t.type,n.memoizedProps);r.componentDidUpdate(a,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var l=t.updateQueue;null!==l&&zo(t,l,r);break;case 3:var i=t.updateQueue;if(null!==i){if(n=null,null!==t.child)switch(t.child.tag){case 5:case 1:n=t.child.stateNode}zo(t,i,n)}break;case 5:var u=t.stateNode;if(null===n&&4&t.flags){n=u;var s=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":s.autoFocus&&n.focus();break;case"img":s.src&&(n.src=s.src)}}break;case 6:case 4:case 12:case 19:case 17:case 21:case 22:case 23:case 25:break;case 13:if(null===t.memoizedState){var c=t.alternate;if(null!==c){var p=c.memoizedState;if(null!==p){var d=p.dehydrated;null!==d&&Wt(d)}}}break;default:throw Error(o(163))}Gi||512&t.flags&&ou(t)}catch(e){ks(t,t.return,e)}}if(t===e){Ji=null;break}if(null!==(n=t.sibling)){n.return=t.return,Ji=n;break}Ji=t.return}}function _u(e){for(;null!==Ji;){var t=Ji;if(t===e){Ji=null;break}var n=t.sibling;if(null!==n){n.return=t.return,Ji=n;break}Ji=t.return}}function xu(e){for(;null!==Ji;){var t=Ji;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{au(4,t)}catch(e){ks(t,n,e)}break;case 1:var r=t.stateNode;if("function"==typeof r.componentDidMount){var a=t.return;try{r.componentDidMount()}catch(e){ks(t,a,e)}}var o=t.return;try{ou(t)}catch(e){ks(t,o,e)}break;case 5:var l=t.return;try{ou(t)}catch(e){ks(t,l,e)}}}catch(e){ks(t,t.return,e)}if(t===e){Ji=null;break}var i=t.sibling;if(null!==i){i.return=t.return,Ji=i;break}Ji=t.return}}var Su,ku=Math.ceil,Cu=w.ReactCurrentDispatcher,Du=w.ReactCurrentOwner,Ou=w.ReactCurrentBatchConfig,Pu=0,Tu=null,Nu=null,Mu=0,Ru=0,ju=ka(0),Au=0,Iu=null,Fu=0,Lu=0,Uu=0,zu=null,Yu=null,Wu=0,Bu=1/0,Hu=null,qu=!1,Vu=null,$u=null,Zu=!1,Qu=null,Ku=0,Gu=0,Xu=null,Ju=-1,es=0;function ts(){return 0!=(6&Pu)?Ge():-1!==Ju?Ju:Ju=Ge()}function ns(e){return 0==(1&e.mode)?1:0!=(2&Pu)&&0!==Mu?Mu&-Mu:null!==yo.transition?(0===es&&(es=mt()),es):0!==(e=bt)?e:e=void 0===(e=window.event)?16:Kt(e.type)}function rs(e,t,n,r){if(50<Gu)throw Gu=0,Xu=null,Error(o(185));yt(e,n,r),0!=(2&Pu)&&e===Tu||(e===Tu&&(0==(2&Pu)&&(Lu|=n),4===Au&&us(e,Mu)),as(e,r),1===n&&0===Pu&&0==(1&t.mode)&&(Bu=Ge()+500,za&&Ba()))}function as(e,t){var n=e.callbackNode;!function(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,a=e.expirationTimes,o=e.pendingLanes;0<o;){var l=31-lt(o),i=1<<l,u=a[l];-1===u?0!=(i&n)&&0==(i&r)||(a[l]=ft(i,t)):u<=t&&(e.expiredLanes|=i),o&=~i}}(e,t);var r=dt(e,e===Tu?Mu:0);if(0===r)null!==n&&Ze(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(null!=n&&Ze(n),1===t)0===e.tag?function(e){za=!0,Wa(e)}(ss.bind(null,e)):Wa(ss.bind(null,e)),ia((function(){0==(6&Pu)&&Ba()})),n=null;else{switch(wt(r)){case 1:n=Je;break;case 4:n=et;break;case 16:default:n=tt;break;case 536870912:n=rt}n=Ts(n,os.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function os(e,t){if(Ju=-1,es=0,0!=(6&Pu))throw Error(o(327));var n=e.callbackNode;if(xs()&&e.callbackNode!==n)return null;var r=dt(e,e===Tu?Mu:0);if(0===r)return null;if(0!=(30&r)||0!=(r&e.expiredLanes)||t)t=ys(e,r);else{t=r;var a=Pu;Pu|=2;var l=ms();for(Tu===e&&Mu===t||(Hu=null,Bu=Ge()+500,fs(e,t));;)try{bs();break}catch(t){hs(e,t)}xo(),Cu.current=l,Pu=a,null!==Nu?t=0:(Tu=null,Mu=0,t=Au)}if(0!==t){if(2===t&&0!==(a=ht(e))&&(r=a,t=ls(e,a)),1===t)throw n=Iu,fs(e,0),us(e,r),as(e,Ge()),n;if(6===t)us(e,r);else{if(a=e.current.alternate,0==(30&r)&&!function(e){for(var t=e;;){if(16384&t.flags){var n=t.updateQueue;if(null!==n&&null!==(n=n.stores))for(var r=0;r<n.length;r++){var a=n[r],o=a.getSnapshot;a=a.value;try{if(!ur(o(),a))return!1}catch(e){return!1}}}if(n=t.child,16384&t.subtreeFlags&&null!==n)n.return=t,t=n;else{if(t===e)break;for(;null===t.sibling;){if(null===t.return||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}(a)&&(2===(t=ys(e,r))&&0!==(l=ht(e))&&(r=l,t=ls(e,l)),1===t))throw n=Iu,fs(e,0),us(e,r),as(e,Ge()),n;switch(e.finishedWork=a,e.finishedLanes=r,t){case 0:case 1:throw Error(o(345));case 2:case 5:_s(e,Yu,Hu);break;case 3:if(us(e,r),(130023424&r)===r&&10<(t=Wu+500-Ge())){if(0!==dt(e,0))break;if(((a=e.suspendedLanes)&r)!==r){ts(),e.pingedLanes|=e.suspendedLanes&a;break}e.timeoutHandle=aa(_s.bind(null,e,Yu,Hu),t);break}_s(e,Yu,Hu);break;case 4:if(us(e,r),(4194240&r)===r)break;for(t=e.eventTimes,a=-1;0<r;){var i=31-lt(r);l=1<<i,(i=t[i])>a&&(a=i),r&=~l}if(r=a,10<(r=(120>(r=Ge()-r)?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*ku(r/1960))-r)){e.timeoutHandle=aa(_s.bind(null,e,Yu,Hu),r);break}_s(e,Yu,Hu);break;default:throw Error(o(329))}}}return as(e,Ge()),e.callbackNode===n?os.bind(null,e):null}function ls(e,t){var n=zu;return e.current.memoizedState.isDehydrated&&(fs(e,t).flags|=256),2!==(e=ys(e,t))&&(t=Yu,Yu=n,null!==t&&is(t)),e}function is(e){null===Yu?Yu=e:Yu.push.apply(Yu,e)}function us(e,t){for(t&=~Uu,t&=~Lu,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-lt(t),r=1<<n;e[n]=-1,t&=~r}}function ss(e){if(0!=(6&Pu))throw Error(o(327));xs();var t=dt(e,0);if(0==(1&t))return as(e,Ge()),null;var n=ys(e,t);if(0!==e.tag&&2===n){var r=ht(e);0!==r&&(t=r,n=ls(e,r))}if(1===n)throw n=Iu,fs(e,0),us(e,t),as(e,Ge()),n;if(6===n)throw Error(o(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,_s(e,Yu,Hu),as(e,Ge()),null}function cs(e,t){var n=Pu;Pu|=1;try{return e(t)}finally{0===(Pu=n)&&(Bu=Ge()+500,za&&Ba())}}function ps(e){null!==Qu&&0===Qu.tag&&0==(6&Pu)&&xs();var t=Pu;Pu|=1;var n=Ou.transition,r=bt;try{if(Ou.transition=null,bt=1,e)return e()}finally{bt=r,Ou.transition=n,0==(6&(Pu=t))&&Ba()}}function ds(){Ru=ju.current,Ca(ju)}function fs(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(-1!==n&&(e.timeoutHandle=-1,oa(n)),null!==Nu)for(n=Nu.return;null!==n;){var r=n;switch(no(r),r.tag){case 1:null!=(r=r.type.childContextTypes)&&ja();break;case 3:ll(),Ca(Ta),Ca(Pa),dl();break;case 5:ul(r);break;case 4:ll();break;case 13:case 19:Ca(sl);break;case 10:So(r.type._context);break;case 22:case 23:ds()}n=n.return}if(Tu=e,Nu=e=js(e.current,null),Mu=Ru=t,Au=0,Iu=null,Uu=Lu=Fu=0,Yu=zu=null,null!==Oo){for(t=0;t<Oo.length;t++)if(null!==(r=(n=Oo[t]).interleaved)){n.interleaved=null;var a=r.next,o=n.pending;if(null!==o){var l=o.next;o.next=a,r.next=l}n.pending=r}Oo=null}return e}function hs(e,t){for(;;){var n=Nu;try{if(xo(),fl.current=ii,bl){for(var r=gl.memoizedState;null!==r;){var a=r.queue;null!==a&&(a.pending=null),r=r.next}bl=!1}if(ml=0,vl=yl=gl=null,wl=!1,El=0,Du.current=null,null===n||null===n.return){Au=1,Iu=t,Nu=null;break}e:{var l=e,i=n.return,u=n,s=t;if(t=Mu,u.flags|=32768,null!==s&&"object"==typeof s&&"function"==typeof s.then){var c=s,p=u,d=p.tag;if(0==(1&p.mode)&&(0===d||11===d||15===d)){var f=p.alternate;f?(p.updateQueue=f.updateQueue,p.memoizedState=f.memoizedState,p.lanes=f.lanes):(p.updateQueue=null,p.memoizedState=null)}var h=vi(i);if(null!==h){h.flags&=-257,bi(h,i,u,0,t),1&h.mode&&yi(l,c,t),s=c;var m=(t=h).updateQueue;if(null===m){var g=new Set;g.add(s),t.updateQueue=g}else m.add(s);break e}if(0==(1&t)){yi(l,c,t),gs();break e}s=Error(o(426))}else if(oo&&1&u.mode){var y=vi(i);if(null!==y){0==(65536&y.flags)&&(y.flags|=256),bi(y,i,u,0,t),go(pi(s,u));break e}}l=s=pi(s,u),4!==Au&&(Au=2),null===zu?zu=[l]:zu.push(l),l=i;do{switch(l.tag){case 3:l.flags|=65536,t&=-t,l.lanes|=t,Lo(l,mi(0,s,t));break e;case 1:u=s;var v=l.type,b=l.stateNode;if(0==(128&l.flags)&&("function"==typeof v.getDerivedStateFromError||null!==b&&"function"==typeof b.componentDidCatch&&(null===$u||!$u.has(b)))){l.flags|=65536,t&=-t,l.lanes|=t,Lo(l,gi(l,u,t));break e}}l=l.return}while(null!==l)}Es(n)}catch(e){t=e,Nu===n&&null!==n&&(Nu=n=n.return);continue}break}}function ms(){var e=Cu.current;return Cu.current=ii,null===e?ii:e}function gs(){0!==Au&&3!==Au&&2!==Au||(Au=4),null===Tu||0==(268435455&Fu)&&0==(268435455&Lu)||us(Tu,Mu)}function ys(e,t){var n=Pu;Pu|=2;var r=ms();for(Tu===e&&Mu===t||(Hu=null,fs(e,t));;)try{vs();break}catch(t){hs(e,t)}if(xo(),Pu=n,Cu.current=r,null!==Nu)throw Error(o(261));return Tu=null,Mu=0,Au}function vs(){for(;null!==Nu;)ws(Nu)}function bs(){for(;null!==Nu&&!Qe();)ws(Nu)}function ws(e){var t=Su(e.alternate,e,Ru);e.memoizedProps=e.pendingProps,null===t?Es(e):Nu=t,Du.current=null}function Es(e){var t=e;do{var n=t.alternate;if(e=t.return,0==(32768&t.flags)){if(null!==(n=Zi(n,t,Ru)))return void(Nu=n)}else{if(null!==(n=Qi(n,t)))return n.flags&=32767,void(Nu=n);if(null===e)return Au=6,void(Nu=null);e.flags|=32768,e.subtreeFlags=0,e.deletions=null}if(null!==(t=t.sibling))return void(Nu=t);Nu=t=e}while(null!==t);0===Au&&(Au=5)}function _s(e,t,n){var r=bt,a=Ou.transition;try{Ou.transition=null,bt=1,function(e,t,n,r){do{xs()}while(null!==Qu);if(0!=(6&Pu))throw Error(o(327));n=e.finishedWork;var a=e.finishedLanes;if(null===n)return null;if(e.finishedWork=null,e.finishedLanes=0,n===e.current)throw Error(o(177));e.callbackNode=null,e.callbackPriority=0;var l=n.lanes|n.childLanes;if(function(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0<n;){var a=31-lt(n),o=1<<a;t[a]=0,r[a]=-1,e[a]=-1,n&=~o}}(e,l),e===Tu&&(Nu=Tu=null,Mu=0),0==(2064&n.subtreeFlags)&&0==(2064&n.flags)||Zu||(Zu=!0,Ts(tt,(function(){return xs(),null}))),l=0!=(15990&n.flags),0!=(15990&n.subtreeFlags)||l){l=Ou.transition,Ou.transition=null;var i=bt;bt=1;var u=Pu;Pu|=4,Du.current=null,function(e,t){if(ta=Ht,hr(e=fr())){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{var r=(n=(n=e.ownerDocument)&&n.defaultView||window).getSelection&&n.getSelection();if(r&&0!==r.rangeCount){n=r.anchorNode;var a=r.anchorOffset,l=r.focusNode;r=r.focusOffset;try{n.nodeType,l.nodeType}catch(e){n=null;break e}var i=0,u=-1,s=-1,c=0,p=0,d=e,f=null;t:for(;;){for(var h;d!==n||0!==a&&3!==d.nodeType||(u=i+a),d!==l||0!==r&&3!==d.nodeType||(s=i+r),3===d.nodeType&&(i+=d.nodeValue.length),null!==(h=d.firstChild);)f=d,d=h;for(;;){if(d===e)break t;if(f===n&&++c===a&&(u=i),f===l&&++p===r&&(s=i),null!==(h=d.nextSibling))break;f=(d=f).parentNode}d=h}n=-1===u||-1===s?null:{start:u,end:s}}else n=null}n=n||{start:0,end:0}}else n=null;for(na={focusedElem:e,selectionRange:n},Ht=!1,Ji=t;null!==Ji;)if(e=(t=Ji).child,0!=(1028&t.subtreeFlags)&&null!==e)e.return=t,Ji=e;else for(;null!==Ji;){t=Ji;try{var m=t.alternate;if(0!=(1024&t.flags))switch(t.tag){case 0:case 11:case 15:case 5:case 6:case 4:case 17:break;case 1:if(null!==m){var g=m.memoizedProps,y=m.memoizedState,v=t.stateNode,b=v.getSnapshotBeforeUpdate(t.elementType===t.type?g:vo(t.type,g),y);v.__reactInternalSnapshotBeforeUpdate=b}break;case 3:var w=t.stateNode.containerInfo;1===w.nodeType?w.textContent="":9===w.nodeType&&w.documentElement&&w.removeChild(w.documentElement);break;default:throw Error(o(163))}}catch(e){ks(t,t.return,e)}if(null!==(e=t.sibling)){e.return=t.return,Ji=e;break}Ji=t.return}m=nu,nu=!1}(e,n),yu(n,e),mr(na),Ht=!!ta,na=ta=null,e.current=n,bu(n,e,a),Ke(),Pu=u,bt=i,Ou.transition=l}else e.current=n;if(Zu&&(Zu=!1,Qu=e,Ku=a),0===(l=e.pendingLanes)&&($u=null),function(e){if(ot&&"function"==typeof ot.onCommitFiberRoot)try{ot.onCommitFiberRoot(at,e,void 0,128==(128&e.current.flags))}catch(e){}}(n.stateNode),as(e,Ge()),null!==t)for(r=e.onRecoverableError,n=0;n<t.length;n++)r((a=t[n]).value,{componentStack:a.stack,digest:a.digest});if(qu)throw qu=!1,e=Vu,Vu=null,e;0!=(1&Ku)&&0!==e.tag&&xs(),0!=(1&(l=e.pendingLanes))?e===Xu?Gu++:(Gu=0,Xu=e):Gu=0,Ba()}(e,t,n,r)}finally{Ou.transition=a,bt=r}return null}function xs(){if(null!==Qu){var e=wt(Ku),t=Ou.transition,n=bt;try{if(Ou.transition=null,bt=16>e?16:e,null===Qu)var r=!1;else{if(e=Qu,Qu=null,Ku=0,0!=(6&Pu))throw Error(o(331));var a=Pu;for(Pu|=4,Ji=e.current;null!==Ji;){var l=Ji,i=l.child;if(0!=(16&Ji.flags)){var u=l.deletions;if(null!==u){for(var s=0;s<u.length;s++){var c=u[s];for(Ji=c;null!==Ji;){var p=Ji;switch(p.tag){case 0:case 11:case 15:ru(8,p,l)}var d=p.child;if(null!==d)d.return=p,Ji=d;else for(;null!==Ji;){var f=(p=Ji).sibling,h=p.return;if(lu(p),p===c){Ji=null;break}if(null!==f){f.return=h,Ji=f;break}Ji=h}}}var m=l.alternate;if(null!==m){var g=m.child;if(null!==g){m.child=null;do{var y=g.sibling;g.sibling=null,g=y}while(null!==g)}}Ji=l}}if(0!=(2064&l.subtreeFlags)&&null!==i)i.return=l,Ji=i;else e:for(;null!==Ji;){if(0!=(2048&(l=Ji).flags))switch(l.tag){case 0:case 11:case 15:ru(9,l,l.return)}var v=l.sibling;if(null!==v){v.return=l.return,Ji=v;break e}Ji=l.return}}var b=e.current;for(Ji=b;null!==Ji;){var w=(i=Ji).child;if(0!=(2064&i.subtreeFlags)&&null!==w)w.return=i,Ji=w;else e:for(i=b;null!==Ji;){if(0!=(2048&(u=Ji).flags))try{switch(u.tag){case 0:case 11:case 15:au(9,u)}}catch(e){ks(u,u.return,e)}if(u===i){Ji=null;break e}var E=u.sibling;if(null!==E){E.return=u.return,Ji=E;break e}Ji=u.return}}if(Pu=a,Ba(),ot&&"function"==typeof ot.onPostCommitFiberRoot)try{ot.onPostCommitFiberRoot(at,e)}catch(e){}r=!0}return r}finally{bt=n,Ou.transition=t}}return!1}function Ss(e,t,n){e=Io(e,t=mi(0,t=pi(n,t),1),1),t=ts(),null!==e&&(yt(e,1,t),as(e,t))}function ks(e,t,n){if(3===e.tag)Ss(e,e,n);else for(;null!==t;){if(3===t.tag){Ss(t,e,n);break}if(1===t.tag){var r=t.stateNode;if("function"==typeof t.type.getDerivedStateFromError||"function"==typeof r.componentDidCatch&&(null===$u||!$u.has(r))){t=Io(t,e=gi(t,e=pi(n,e),1),1),e=ts(),null!==t&&(yt(t,1,e),as(t,e));break}}t=t.return}}function Cs(e,t,n){var r=e.pingCache;null!==r&&r.delete(t),t=ts(),e.pingedLanes|=e.suspendedLanes&n,Tu===e&&(Mu&n)===n&&(4===Au||3===Au&&(130023424&Mu)===Mu&&500>Ge()-Wu?fs(e,0):Uu|=n),as(e,t)}function Ds(e,t){0===t&&(0==(1&e.mode)?t=1:(t=ct,0==(130023424&(ct<<=1))&&(ct=4194304)));var n=ts();null!==(e=No(e,t))&&(yt(e,t,n),as(e,n))}function Os(e){var t=e.memoizedState,n=0;null!==t&&(n=t.retryLane),Ds(e,n)}function Ps(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,a=e.memoizedState;null!==a&&(n=a.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(o(314))}null!==r&&r.delete(t),Ds(e,n)}function Ts(e,t){return $e(e,t)}function Ns(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ms(e,t,n,r){return new Ns(e,t,n,r)}function Rs(e){return!(!(e=e.prototype)||!e.isReactComponent)}function js(e,t){var n=e.alternate;return null===n?((n=Ms(e.tag,t,e.key,e.mode)).elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=14680064&e.flags,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=null===t?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function As(e,t,n,r,a,l){var i=2;if(r=e,"function"==typeof e)Rs(e)&&(i=1);else if("string"==typeof e)i=5;else e:switch(e){case x:return Is(n.children,a,l,t);case S:i=8,a|=8;break;case k:return(e=Ms(12,n,t,2|a)).elementType=k,e.lanes=l,e;case P:return(e=Ms(13,n,t,a)).elementType=P,e.lanes=l,e;case T:return(e=Ms(19,n,t,a)).elementType=T,e.lanes=l,e;case R:return Fs(n,a,l,t);default:if("object"==typeof e&&null!==e)switch(e.$$typeof){case C:i=10;break e;case D:i=9;break e;case O:i=11;break e;case N:i=14;break e;case M:i=16,r=null;break e}throw Error(o(130,null==e?e:typeof e,""))}return(t=Ms(i,n,t,a)).elementType=e,t.type=r,t.lanes=l,t}function Is(e,t,n,r){return(e=Ms(7,e,r,t)).lanes=n,e}function Fs(e,t,n,r){return(e=Ms(22,e,r,t)).elementType=R,e.lanes=n,e.stateNode={isHidden:!1},e}function Ls(e,t,n){return(e=Ms(6,e,null,t)).lanes=n,e}function Us(e,t,n){return(t=Ms(4,null!==e.children?e.children:[],e.key,t)).lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function zs(e,t,n,r,a){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=gt(0),this.expirationTimes=gt(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=gt(0),this.identifierPrefix=r,this.onRecoverableError=a,this.mutableSourceEagerHydrationData=null}function Ys(e,t,n,r,a,o,l,i,u){return e=new zs(e,t,n,i,u),1===t?(t=1,!0===o&&(t|=8)):t=0,o=Ms(3,null,null,t),e.current=o,o.stateNode=e,o.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Ro(o),e}function Ws(e,t,n){var r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null;return{$$typeof:_,key:null==r?null:""+r,children:e,containerInfo:t,implementation:n}}function Bs(e){if(!e)return Oa;e:{if(We(e=e._reactInternals)!==e||1!==e.tag)throw Error(o(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(Ra(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(null!==t);throw Error(o(171))}if(1===e.tag){var n=e.type;if(Ra(n))return Ia(e,n,t)}return t}function Hs(e,t,n,r,a,o,l,i,u){return(e=Ys(n,r,!0,e,0,o,0,i,u)).context=Bs(null),n=e.current,(o=Ao(r=ts(),a=ns(n))).callback=null!=t?t:null,Io(n,o,a),e.current.lanes=a,yt(e,a,r),as(e,r),e}function qs(e,t,n,r){var a=t.current,o=ts(),l=ns(a);return n=Bs(n),null===t.context?t.context=n:t.pendingContext=n,(t=Ao(o,l)).payload={element:e},null!==(r=void 0===r?null:r)&&(t.callback=r),null!==(e=Io(a,t,l))&&(rs(e,a,l,o),Fo(e,a,l)),l}function Vs(e){return(e=e.current).child?(e.child.tag,e.child.stateNode):null}function $s(e,t){if(null!==(e=e.memoizedState)&&null!==e.dehydrated){var n=e.retryLane;e.retryLane=0!==n&&n<t?n:t}}function Zs(e,t){$s(e,t),(e=e.alternate)&&$s(e,t)}Su=function(e,t,n){if(null!==e)if(e.memoizedProps!==t.pendingProps||Ta.current)Ei=!0;else{if(0==(e.lanes&n)&&0==(128&t.flags))return Ei=!1,function(e,t,n){switch(t.tag){case 3:Ni(t),mo();break;case 5:il(t);break;case 1:Ra(t.type)&&Fa(t);break;case 4:ol(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,a=t.memoizedProps.value;Da(bo,r._currentValue),r._currentValue=a;break;case 13:if(null!==(r=t.memoizedState))return null!==r.dehydrated?(Da(sl,1&sl.current),t.flags|=128,null):0!=(n&t.child.childLanes)?Li(e,t,n):(Da(sl,1&sl.current),null!==(e=qi(e,t,n))?e.sibling:null);Da(sl,1&sl.current);break;case 19:if(r=0!=(n&t.childLanes),0!=(128&e.flags)){if(r)return Bi(e,t,n);t.flags|=128}if(null!==(a=t.memoizedState)&&(a.rendering=null,a.tail=null,a.lastEffect=null),Da(sl,sl.current),r)break;return null;case 22:case 23:return t.lanes=0,Ci(e,t,n)}return qi(e,t,n)}(e,t,n);Ei=0!=(131072&e.flags)}else Ei=!1,oo&&0!=(1048576&t.flags)&&eo(t,$a,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Hi(e,t),e=t.pendingProps;var a=Ma(t,Pa.current);Co(t,n),a=kl(null,t,r,e,a,n);var l=Cl();return t.flags|=1,"object"==typeof a&&null!==a&&"function"==typeof a.render&&void 0===a.$$typeof?(t.tag=1,t.memoizedState=null,t.updateQueue=null,Ra(r)?(l=!0,Fa(t)):l=!1,t.memoizedState=null!==a.state&&void 0!==a.state?a.state:null,Ro(t),a.updater=Bo,t.stateNode=a,a._reactInternals=t,$o(t,r,e,n),t=Ti(null,t,r,!0,l,n)):(t.tag=0,oo&&l&&to(t),_i(null,t,a,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Hi(e,t),e=t.pendingProps,r=(a=r._init)(r._payload),t.type=r,a=t.tag=function(e){if("function"==typeof e)return Rs(e)?1:0;if(null!=e){if((e=e.$$typeof)===O)return 11;if(e===N)return 14}return 2}(r),e=vo(r,e),a){case 0:t=Oi(null,t,r,e,n);break e;case 1:t=Pi(null,t,r,e,n);break e;case 11:t=xi(null,t,r,e,n);break e;case 14:t=Si(null,t,r,vo(r.type,e),n);break e}throw Error(o(306,r,""))}return t;case 0:return r=t.type,a=t.pendingProps,Oi(e,t,r,a=t.elementType===r?a:vo(r,a),n);case 1:return r=t.type,a=t.pendingProps,Pi(e,t,r,a=t.elementType===r?a:vo(r,a),n);case 3:e:{if(Ni(t),null===e)throw Error(o(387));r=t.pendingProps,a=(l=t.memoizedState).element,jo(e,t),Uo(t,r,null,n);var i=t.memoizedState;if(r=i.element,l.isDehydrated){if(l={element:r,isDehydrated:!1,cache:i.cache,pendingSuspenseBoundaries:i.pendingSuspenseBoundaries,transitions:i.transitions},t.updateQueue.baseState=l,t.memoizedState=l,256&t.flags){t=Mi(e,t,r,n,a=pi(Error(o(423)),t));break e}if(r!==a){t=Mi(e,t,r,n,a=pi(Error(o(424)),t));break e}for(ao=ca(t.stateNode.containerInfo.firstChild),ro=t,oo=!0,lo=null,n=Jo(t,null,r,n),t.child=n;n;)n.flags=-3&n.flags|4096,n=n.sibling}else{if(mo(),r===a){t=qi(e,t,n);break e}_i(e,t,r,n)}t=t.child}return t;case 5:return il(t),null===e&&co(t),r=t.type,a=t.pendingProps,l=null!==e?e.memoizedProps:null,i=a.children,ra(r,a)?i=null:null!==l&&ra(r,l)&&(t.flags|=32),Di(e,t),_i(e,t,i,n),t.child;case 6:return null===e&&co(t),null;case 13:return Li(e,t,n);case 4:return ol(t,t.stateNode.containerInfo),r=t.pendingProps,null===e?t.child=Xo(t,null,r,n):_i(e,t,r,n),t.child;case 11:return r=t.type,a=t.pendingProps,xi(e,t,r,a=t.elementType===r?a:vo(r,a),n);case 7:return _i(e,t,t.pendingProps,n),t.child;case 8:case 12:return _i(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,a=t.pendingProps,l=t.memoizedProps,i=a.value,Da(bo,r._currentValue),r._currentValue=i,null!==l)if(ur(l.value,i)){if(l.children===a.children&&!Ta.current){t=qi(e,t,n);break e}}else for(null!==(l=t.child)&&(l.return=t);null!==l;){var u=l.dependencies;if(null!==u){i=l.child;for(var s=u.firstContext;null!==s;){if(s.context===r){if(1===l.tag){(s=Ao(-1,n&-n)).tag=2;var c=l.updateQueue;if(null!==c){var p=(c=c.shared).pending;null===p?s.next=s:(s.next=p.next,p.next=s),c.pending=s}}l.lanes|=n,null!==(s=l.alternate)&&(s.lanes|=n),ko(l.return,n,t),u.lanes|=n;break}s=s.next}}else if(10===l.tag)i=l.type===t.type?null:l.child;else if(18===l.tag){if(null===(i=l.return))throw Error(o(341));i.lanes|=n,null!==(u=i.alternate)&&(u.lanes|=n),ko(i,n,t),i=l.sibling}else i=l.child;if(null!==i)i.return=l;else for(i=l;null!==i;){if(i===t){i=null;break}if(null!==(l=i.sibling)){l.return=i.return,i=l;break}i=i.return}l=i}_i(e,t,a.children,n),t=t.child}return t;case 9:return a=t.type,r=t.pendingProps.children,Co(t,n),r=r(a=Do(a)),t.flags|=1,_i(e,t,r,n),t.child;case 14:return a=vo(r=t.type,t.pendingProps),Si(e,t,r,a=vo(r.type,a),n);case 15:return ki(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:vo(r,a),Hi(e,t),t.tag=1,Ra(r)?(e=!0,Fa(t)):e=!1,Co(t,n),qo(t,r,a),$o(t,r,a,n),Ti(null,t,r,!0,e,n);case 19:return Bi(e,t,n);case 22:return Ci(e,t,n)}throw Error(o(156,t.tag))};var Qs="function"==typeof reportError?reportError:function(e){console.error(e)};function Ks(e){this._internalRoot=e}function Gs(e){this._internalRoot=e}function Xs(e){return!(!e||1!==e.nodeType&&9!==e.nodeType&&11!==e.nodeType)}function Js(e){return!(!e||1!==e.nodeType&&9!==e.nodeType&&11!==e.nodeType&&(8!==e.nodeType||" react-mount-point-unstable "!==e.nodeValue))}function ec(){}function tc(e,t,n,r,a){var o=n._reactRootContainer;if(o){var l=o;if("function"==typeof a){var i=a;a=function(){var e=Vs(l);i.call(e)}}qs(t,l,e,a)}else l=function(e,t,n,r,a){if(a){if("function"==typeof r){var o=r;r=function(){var e=Vs(l);o.call(e)}}var l=Hs(t,r,e,0,null,!1,0,"",ec);return e._reactRootContainer=l,e[ma]=l.current,Br(8===e.nodeType?e.parentNode:e),ps(),l}for(;a=e.lastChild;)e.removeChild(a);if("function"==typeof r){var i=r;r=function(){var e=Vs(u);i.call(e)}}var u=Ys(e,0,!1,null,0,!1,0,"",ec);return e._reactRootContainer=u,e[ma]=u.current,Br(8===e.nodeType?e.parentNode:e),ps((function(){qs(t,u,n,r)})),u}(n,t,e,a,r);return Vs(l)}Gs.prototype.render=Ks.prototype.render=function(e){var t=this._internalRoot;if(null===t)throw Error(o(409));qs(e,t,null,null)},Gs.prototype.unmount=Ks.prototype.unmount=function(){var e=this._internalRoot;if(null!==e){this._internalRoot=null;var t=e.containerInfo;ps((function(){qs(null,e,null,null)})),t[ma]=null}},Gs.prototype.unstable_scheduleHydration=function(e){if(e){var t=St();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Rt.length&&0!==t&&t<Rt[n].priority;n++);Rt.splice(n,0,e),0===n&&Ft(e)}},Et=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=pt(t.pendingLanes);0!==n&&(vt(t,1|n),as(t,Ge()),0==(6&Pu)&&(Bu=Ge()+500,Ba()))}break;case 13:ps((function(){var t=No(e,1);if(null!==t){var n=ts();rs(t,e,1,n)}})),Zs(e,1)}},_t=function(e){if(13===e.tag){var t=No(e,134217728);null!==t&&rs(t,e,134217728,ts()),Zs(e,134217728)}},xt=function(e){if(13===e.tag){var t=ns(e),n=No(e,t);null!==n&&rs(n,e,t,ts()),Zs(e,t)}},St=function(){return bt},kt=function(e,t){var n=bt;try{return bt=e,t()}finally{bt=n}},_e=function(e,t,n){switch(t){case"input":if(X(e,n),t=n.name,"radio"===n.type&&null!=t){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll("input[name="+JSON.stringify(""+t)+'][type="radio"]'),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var a=_a(r);if(!a)throw Error(o(90));$(r),X(r,a)}}}break;case"textarea":oe(e,n);break;case"select":null!=(t=n.value)&&ne(e,!!n.multiple,t,!1)}},Oe=cs,Pe=ps;var nc={usingClientEntryPoint:!1,Events:[wa,Ea,_a,Ce,De,cs]},rc={findFiberByHostInstance:ba,bundleType:0,version:"18.2.0",rendererPackageName:"react-dom"},ac={bundleType:rc.bundleType,version:rc.version,rendererPackageName:rc.rendererPackageName,rendererConfig:rc.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:w.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return null===(e=qe(e))?null:e.stateNode},findFiberByHostInstance:rc.findFiberByHostInstance||function(){return null},findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.2.0-next-9e3b772b8-20220608"};if("undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__){var oc=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!oc.isDisabled&&oc.supportsFiber)try{at=oc.inject(ac),ot=oc}catch(ce){}}t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=nc,t.createPortal=function(e,t){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null;if(!Xs(t))throw Error(o(200));return Ws(e,t,null,n)},t.createRoot=function(e,t){if(!Xs(e))throw Error(o(299));var n=!1,r="",a=Qs;return null!=t&&(!0===t.unstable_strictMode&&(n=!0),void 0!==t.identifierPrefix&&(r=t.identifierPrefix),void 0!==t.onRecoverableError&&(a=t.onRecoverableError)),t=Ys(e,1,!1,null,0,n,0,r,a),e[ma]=t.current,Br(8===e.nodeType?e.parentNode:e),new Ks(t)},t.findDOMNode=function(e){if(null==e)return null;if(1===e.nodeType)return e;var t=e._reactInternals;if(void 0===t){if("function"==typeof e.render)throw Error(o(188));throw e=Object.keys(e).join(","),Error(o(268,e))}return null===(e=qe(t))?null:e.stateNode},t.flushSync=function(e){return ps(e)},t.hydrate=function(e,t,n){if(!Js(t))throw Error(o(200));return tc(null,e,t,!0,n)},t.hydrateRoot=function(e,t,n){if(!Xs(e))throw Error(o(405));var r=null!=n&&n.hydratedSources||null,a=!1,l="",i=Qs;if(null!=n&&(!0===n.unstable_strictMode&&(a=!0),void 0!==n.identifierPrefix&&(l=n.identifierPrefix),void 0!==n.onRecoverableError&&(i=n.onRecoverableError)),t=Hs(t,null,e,1,null!=n?n:null,a,0,l,i),e[ma]=t.current,Br(e),r)for(e=0;e<r.length;e++)a=(a=(n=r[e])._getVersion)(n._source),null==t.mutableSourceEagerHydrationData?t.mutableSourceEagerHydrationData=[n,a]:t.mutableSourceEagerHydrationData.push(n,a);return new Gs(t)},t.render=function(e,t,n){if(!Js(t))throw Error(o(200));return tc(null,e,t,!1,n)},t.unmountComponentAtNode=function(e){if(!Js(e))throw Error(o(40));return!!e._reactRootContainer&&(ps((function(){tc(null,null,e,!1,(function(){e._reactRootContainer=null,e[ma]=null}))})),!0)},t.unstable_batchedUpdates=cs,t.unstable_renderSubtreeIntoContainer=function(e,t,n,r){if(!Js(n))throw Error(o(200));if(null==e||void 0===e._reactInternals)throw Error(o(38));return tc(e,t,n,!1,r)},t.version="18.2.0-next-9e3b772b8-20220608"},745:(e,t,n)=>{"use strict";var r=n(3935);t.s=r.createRoot,r.hydrateRoot},3935:(e,t,n)=>{"use strict";!function e(){if("undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(e){console.error(e)}}(),e.exports=n(4448)},4203:(e,t)=>{"use strict";function n(e,t){var n=e.length;e.push(t);e:for(;0<n;){var r=n-1>>>1,a=e[r];if(!(0<o(a,t)))break e;e[r]=t,e[n]=a,n=r}}function r(e){return 0===e.length?null:e[0]}function a(e){if(0===e.length)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;e:for(var r=0,a=e.length,l=a>>>1;r<l;){var i=2*(r+1)-1,u=e[i],s=i+1,c=e[s];if(0>o(u,n))s<a&&0>o(c,u)?(e[r]=c,e[s]=n,r=s):(e[r]=u,e[i]=n,r=i);else{if(!(s<a&&0>o(c,n)))break e;e[r]=c,e[s]=n,r=s}}}return t}function o(e,t){var n=e.sortIndex-t.sortIndex;return 0!==n?n:e.id-t.id}if("object"==typeof performance&&"function"==typeof performance.now){var l=performance;t.unstable_now=function(){return l.now()}}else{var i=Date,u=i.now();t.unstable_now=function(){return i.now()-u}}var s=[],c=[],p=1,d=null,f=3,h=!1,m=!1,g=!1,y="function"==typeof setTimeout?setTimeout:null,v="function"==typeof clearTimeout?clearTimeout:null,b="undefined"!=typeof setImmediate?setImmediate:null;function w(e){for(var t=r(c);null!==t;){if(null===t.callback)a(c);else{if(!(t.startTime<=e))break;a(c),t.sortIndex=t.expirationTime,n(s,t)}t=r(c)}}function E(e){if(g=!1,w(e),!m)if(null!==r(s))m=!0,R(_);else{var t=r(c);null!==t&&j(E,t.startTime-e)}}function _(e,n){m=!1,g&&(g=!1,v(C),C=-1),h=!0;var o=f;try{for(w(n),d=r(s);null!==d&&(!(d.expirationTime>n)||e&&!P());){var l=d.callback;if("function"==typeof l){d.callback=null,f=d.priorityLevel;var i=l(d.expirationTime<=n);n=t.unstable_now(),"function"==typeof i?d.callback=i:d===r(s)&&a(s),w(n)}else a(s);d=r(s)}if(null!==d)var u=!0;else{var p=r(c);null!==p&&j(E,p.startTime-n),u=!1}return u}finally{d=null,f=o,h=!1}}"undefined"!=typeof navigator&&void 0!==navigator.scheduling&&void 0!==navigator.scheduling.isInputPending&&navigator.scheduling.isInputPending.bind(navigator.scheduling);var x,S=!1,k=null,C=-1,D=5,O=-1;function P(){return!(t.unstable_now()-O<D)}function T(){if(null!==k){var e=t.unstable_now();O=e;var n=!0;try{n=k(!0,e)}finally{n?x():(S=!1,k=null)}}else S=!1}if("function"==typeof b)x=function(){b(T)};else if("undefined"!=typeof MessageChannel){var N=new MessageChannel,M=N.port2;N.port1.onmessage=T,x=function(){M.postMessage(null)}}else x=function(){y(T,0)};function R(e){k=e,S||(S=!0,x())}function j(e,n){C=y((function(){e(t.unstable_now())}),n)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(e){e.callback=null},t.unstable_continueExecution=function(){m||h||(m=!0,R(_))},t.unstable_forceFrameRate=function(e){0>e||125<e?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):D=0<e?Math.floor(1e3/e):5},t.unstable_getCurrentPriorityLevel=function(){return f},t.unstable_getFirstCallbackNode=function(){return r(s)},t.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},t.unstable_pauseExecution=function(){},t.unstable_requestPaint=function(){},t.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},t.unstable_scheduleCallback=function(e,a,o){var l=t.unstable_now();switch(o="object"==typeof o&&null!==o&&"number"==typeof(o=o.delay)&&0<o?l+o:l,e){case 1:var i=-1;break;case 2:i=250;break;case 5:i=1073741823;break;case 4:i=1e4;break;default:i=5e3}return e={id:p++,callback:a,priorityLevel:e,startTime:o,expirationTime:i=o+i,sortIndex:-1},o>l?(e.sortIndex=o,n(c,e),null===r(s)&&e===r(c)&&(g?(v(C),C=-1):g=!0,j(E,o-l))):(e.sortIndex=i,n(s,e),m||h||(m=!0,R(_))),e},t.unstable_shouldYield=P,t.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}},4142:(e,t,n)=>{"use strict";e.exports=n(4203)},9590:e=>{var t="undefined"!=typeof Element,n="function"==typeof Map,r="function"==typeof Set,a="function"==typeof ArrayBuffer&&!!ArrayBuffer.isView;function o(e,l){if(e===l)return!0;if(e&&l&&"object"==typeof e&&"object"==typeof l){if(e.constructor!==l.constructor)return!1;var i,u,s,c;if(Array.isArray(e)){if((i=e.length)!=l.length)return!1;for(u=i;0!=u--;)if(!o(e[u],l[u]))return!1;return!0}if(n&&e instanceof Map&&l instanceof Map){if(e.size!==l.size)return!1;for(c=e.entries();!(u=c.next()).done;)if(!l.has(u.value[0]))return!1;for(c=e.entries();!(u=c.next()).done;)if(!o(u.value[1],l.get(u.value[0])))return!1;return!0}if(r&&e instanceof Set&&l instanceof Set){if(e.size!==l.size)return!1;for(c=e.entries();!(u=c.next()).done;)if(!l.has(u.value[0]))return!1;return!0}if(a&&ArrayBuffer.isView(e)&&ArrayBuffer.isView(l)){if((i=e.length)!=l.length)return!1;for(u=i;0!=u--;)if(e[u]!==l[u])return!1;return!0}if(e.constructor===RegExp)return e.source===l.source&&e.flags===l.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===l.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===l.toString();if((i=(s=Object.keys(e)).length)!==Object.keys(l).length)return!1;for(u=i;0!=u--;)if(!Object.prototype.hasOwnProperty.call(l,s[u]))return!1;if(t&&e instanceof Element)return!1;for(u=i;0!=u--;)if(("_owner"!==s[u]&&"__v"!==s[u]&&"__o"!==s[u]||!e.$$typeof)&&!o(e[s[u]],l[s[u]]))return!1;return!0}return e!=e&&l!=l}e.exports=function(e,t){try{return o(e,t)}catch(e){if((e.message||"").match(/stack|recursion/i))return console.warn("react-fast-compare cannot handle circular refs"),!1;throw e}}},7763:(e,t,n)=>{e.exports=function(e){var t={};function n(r){if(t[r])return t[r].exports;var a=t[r]={exports:{},id:r,loaded:!1};return e[r].call(a.exports,a,a.exports,n),a.loaded=!0,a.exports}return n.m=e,n.c=t,n.p="",n(0)}([function(e,t,n){e.exports=n(1)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r,a=(r=n(2))&&r.__esModule?r:{default:r};t.default=a.default,e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e};function a(e){return e&&e.__esModule?e:{default:e}}t.default=s;var o=n(3),l=a(n(4)),i=n(14),u=a(n(15));function s(e){var t=e.activeClassName,n=void 0===t?"":t,a=e.activeIndex,l=void 0===a?-1:a,s=e.activeStyle,c=e.autoEscape,p=e.caseSensitive,d=void 0!==p&&p,f=e.className,h=e.findChunks,m=e.highlightClassName,g=void 0===m?"":m,y=e.highlightStyle,v=void 0===y?{}:y,b=e.highlightTag,w=void 0===b?"mark":b,E=e.sanitize,_=e.searchWords,x=e.textToHighlight,S=e.unhighlightClassName,k=void 0===S?"":S,C=e.unhighlightStyle,D=function(e,t){var n={};for(var r in e)t.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}(e,["activeClassName","activeIndex","activeStyle","autoEscape","caseSensitive","className","findChunks","highlightClassName","highlightStyle","highlightTag","sanitize","searchWords","textToHighlight","unhighlightClassName","unhighlightStyle"]),O=(0,o.findAll)({autoEscape:c,caseSensitive:d,findChunks:h,sanitize:E,searchWords:_,textToHighlight:x}),P=w,T=-1,N="",M=void 0,R=(0,u.default)((function(e){var t={};for(var n in e)t[n.toLowerCase()]=e[n];return t}));return(0,i.createElement)("span",r({className:f},D,{children:O.map((function(e,t){var r=x.substr(e.start,e.end-e.start);if(e.highlight){T++;var a;a="object"==typeof g?d?g[r]:(g=R(g))[r.toLowerCase()]:g;var o=T===+l;N=a+" "+(o?n:""),M=!0===o&&null!=s?Object.assign({},v,s):v;var u={children:r,className:N,key:t,style:M};return"string"!=typeof P&&(u.highlightIndex=T),(0,i.createElement)(P,u)}return(0,i.createElement)("span",{children:r,className:k,key:t,style:C})}))}))}s.propTypes={activeClassName:l.default.string,activeIndex:l.default.number,activeStyle:l.default.object,autoEscape:l.default.bool,className:l.default.string,findChunks:l.default.func,highlightClassName:l.default.oneOfType([l.default.object,l.default.string]),highlightStyle:l.default.object,highlightTag:l.default.oneOfType([l.default.node,l.default.func,l.default.string]),sanitize:l.default.func,searchWords:l.default.arrayOf(l.default.oneOfType([l.default.string,l.default.instanceOf(RegExp)])).isRequired,textToHighlight:l.default.string.isRequired,unhighlightClassName:l.default.string,unhighlightStyle:l.default.object},e.exports=t.default},function(e,t){e.exports=function(e){var t={};function n(r){if(t[r])return t[r].exports;var a=t[r]={exports:{},id:r,loaded:!1};return e[r].call(a.exports,a,a.exports,n),a.loaded=!0,a.exports}return n.m=e,n.c=t,n.p="",n(0)}([function(e,t,n){e.exports=n(1)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(2);Object.defineProperty(t,"combineChunks",{enumerable:!0,get:function(){return r.combineChunks}}),Object.defineProperty(t,"fillInChunks",{enumerable:!0,get:function(){return r.fillInChunks}}),Object.defineProperty(t,"findAll",{enumerable:!0,get:function(){return r.findAll}}),Object.defineProperty(t,"findChunks",{enumerable:!0,get:function(){return r.findChunks}})},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.findAll=function(e){var t=e.autoEscape,o=e.caseSensitive,l=void 0!==o&&o,i=e.findChunks,u=void 0===i?r:i,s=e.sanitize,c=e.searchWords,p=e.textToHighlight;return a({chunksToHighlight:n({chunks:u({autoEscape:t,caseSensitive:l,sanitize:s,searchWords:c,textToHighlight:p})}),totalLength:p?p.length:0})};var n=t.combineChunks=function(e){var t=e.chunks;return t.sort((function(e,t){return e.start-t.start})).reduce((function(e,t){if(0===e.length)return[t];var n=e.pop();if(t.start<=n.end){var r=Math.max(n.end,t.end);e.push({start:n.start,end:r})}else e.push(n,t);return e}),[])},r=function(e){var t=e.autoEscape,n=e.caseSensitive,r=e.sanitize,a=void 0===r?o:r,l=e.searchWords,i=e.textToHighlight;return i=a(i),l.filter((function(e){return e})).reduce((function(e,r){r=a(r),t&&(r=r.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"));for(var o=new RegExp(r,n?"g":"gi"),l=void 0;l=o.exec(i);){var u=l.index,s=o.lastIndex;s>u&&e.push({start:u,end:s}),l.index==o.lastIndex&&o.lastIndex++}return e}),[])};t.findChunks=r;var a=t.fillInChunks=function(e){var t=e.chunksToHighlight,n=e.totalLength,r=[],a=function(e,t,n){t-e>0&&r.push({start:e,end:t,highlight:n})};if(0===t.length)a(0,n,!1);else{var o=0;t.forEach((function(e){a(o,e.start,!1),a(e.start,e.end,!0),o=e.end})),a(o,n,!1)}return r};function o(e){return e}}])},function(e,t,n){(function(t){if("production"!==t.env.NODE_ENV){var r="function"==typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103;e.exports=n(6)((function(e){return"object"==typeof e&&null!==e&&e.$$typeof===r}),!0)}else e.exports=n(13)()}).call(t,n(5))},function(e,t){var n,r,a=e.exports={};function o(){throw new Error("setTimeout has not been defined")}function l(){throw new Error("clearTimeout has not been defined")}function i(e){if(n===setTimeout)return setTimeout(e,0);if((n===o||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:o}catch(e){n=o}try{r="function"==typeof clearTimeout?clearTimeout:l}catch(e){r=l}}();var u,s=[],c=!1,p=-1;function d(){c&&u&&(c=!1,u.length?s=u.concat(s):p=-1,s.length&&f())}function f(){if(!c){var e=i(d);c=!0;for(var t=s.length;t;){for(u=s,s=[];++p<t;)u&&u[p].run();p=-1,t=s.length}u=null,c=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===l||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function h(e,t){this.fun=e,this.array=t}function m(){}a.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];s.push(new h(e,t)),1!==s.length||c||i(f)},h.prototype.run=function(){this.fun.apply(null,this.array)},a.title="browser",a.browser=!0,a.env={},a.argv=[],a.version="",a.versions={},a.on=m,a.addListener=m,a.once=m,a.off=m,a.removeListener=m,a.removeAllListeners=m,a.emit=m,a.prependListener=m,a.prependOnceListener=m,a.listeners=function(e){return[]},a.binding=function(e){throw new Error("process.binding is not supported")},a.cwd=function(){return"/"},a.chdir=function(e){throw new Error("process.chdir is not supported")},a.umask=function(){return 0}},function(e,t,n){(function(t){"use strict";var r=n(7),a=n(8),o=n(9),l=n(10),i=n(11),u=n(12);e.exports=function(e,n){var s="function"==typeof Symbol&&Symbol.iterator,c="<<anonymous>>",p={array:h("array"),bool:h("boolean"),func:h("function"),number:h("number"),object:h("object"),string:h("string"),symbol:h("symbol"),any:f(r.thatReturnsNull),arrayOf:function(e){return f((function(t,n,r,a,o){if("function"!=typeof e)return new d("Property `"+o+"` of component `"+r+"` has invalid PropType notation inside arrayOf.");var l=t[n];if(!Array.isArray(l))return new d("Invalid "+a+" `"+o+"` of type `"+g(l)+"` supplied to `"+r+"`, expected an array.");for(var u=0;u<l.length;u++){var s=e(l,u,r,a,o+"["+u+"]",i);if(s instanceof Error)return s}return null}))},element:f((function(t,n,r,a,o){var l=t[n];return e(l)?null:new d("Invalid "+a+" `"+o+"` of type `"+g(l)+"` supplied to `"+r+"`, expected a single ReactElement.")})),instanceOf:function(e){return f((function(t,n,r,a,o){if(!(t[n]instanceof e)){var l=e.name||c;return new d("Invalid "+a+" `"+o+"` of type `"+((i=t[n]).constructor&&i.constructor.name?i.constructor.name:c)+"` supplied to `"+r+"`, expected instance of `"+l+"`.")}var i;return null}))},node:f((function(e,t,n,r,a){return m(e[t])?null:new d("Invalid "+r+" `"+a+"` supplied to `"+n+"`, expected a ReactNode.")})),objectOf:function(e){return f((function(t,n,r,a,o){if("function"!=typeof e)return new d("Property `"+o+"` of component `"+r+"` has invalid PropType notation inside objectOf.");var l=t[n],u=g(l);if("object"!==u)return new d("Invalid "+a+" `"+o+"` of type `"+u+"` supplied to `"+r+"`, expected an object.");for(var s in l)if(l.hasOwnProperty(s)){var c=e(l,s,r,a,o+"."+s,i);if(c instanceof Error)return c}return null}))},oneOf:function(e){return Array.isArray(e)?f((function(t,n,r,a,o){for(var l=t[n],i=0;i<e.length;i++)if(u=l,s=e[i],u===s?0!==u||1/u==1/s:u!=u&&s!=s)return null;var u,s;return new d("Invalid "+a+" `"+o+"` of value `"+l+"` supplied to `"+r+"`, expected one of "+JSON.stringify(e)+".")})):("production"!==t.env.NODE_ENV&&o(!1,"Invalid argument supplied to oneOf, expected an instance of array."),r.thatReturnsNull)},oneOfType:function(e){if(!Array.isArray(e))return"production"!==t.env.NODE_ENV&&o(!1,"Invalid argument supplied to oneOfType, expected an instance of array."),r.thatReturnsNull;for(var n=0;n<e.length;n++){var a=e[n];if("function"!=typeof a)return o(!1,"Invalid argument supplied to oneOfType. Expected an array of check functions, but received %s at index %s.",v(a),n),r.thatReturnsNull}return f((function(t,n,r,a,o){for(var l=0;l<e.length;l++)if(null==(0,e[l])(t,n,r,a,o,i))return null;return new d("Invalid "+a+" `"+o+"` supplied to `"+r+"`.")}))},shape:function(e){return f((function(t,n,r,a,o){var l=t[n],u=g(l);if("object"!==u)return new d("Invalid "+a+" `"+o+"` of type `"+u+"` supplied to `"+r+"`, expected `object`.");for(var s in e){var c=e[s];if(c){var p=c(l,s,r,a,o+"."+s,i);if(p)return p}}return null}))},exact:function(e){return f((function(t,n,r,a,o){var u=t[n],s=g(u);if("object"!==s)return new d("Invalid "+a+" `"+o+"` of type `"+s+"` supplied to `"+r+"`, expected `object`.");var c=l({},t[n],e);for(var p in c){var f=e[p];if(!f)return new d("Invalid "+a+" `"+o+"` key `"+p+"` supplied to `"+r+"`.\nBad object: "+JSON.stringify(t[n],null," ")+"\nValid keys: "+JSON.stringify(Object.keys(e),null," "));var h=f(u,p,r,a,o+"."+p,i);if(h)return h}return null}))}};function d(e){this.message=e,this.stack=""}function f(e){if("production"!==t.env.NODE_ENV)var r={},l=0;function u(u,s,p,f,h,m,g){if(f=f||c,m=m||p,g!==i)if(n)a(!1,"Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");else if("production"!==t.env.NODE_ENV&&"undefined"!=typeof console){var y=f+":"+p;!r[y]&&l<3&&(o(!1,"You are manually calling a React.PropTypes validation function for the `%s` prop on `%s`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details.",m,f),r[y]=!0,l++)}return null==s[p]?u?null===s[p]?new d("The "+h+" `"+m+"` is marked as required in `"+f+"`, but its value is `null`."):new d("The "+h+" `"+m+"` is marked as required in `"+f+"`, but its value is `undefined`."):null:e(s,p,f,h,m)}var s=u.bind(null,!1);return s.isRequired=u.bind(null,!0),s}function h(e){return f((function(t,n,r,a,o,l){var i=t[n];return g(i)!==e?new d("Invalid "+a+" `"+o+"` of type `"+y(i)+"` supplied to `"+r+"`, expected `"+e+"`."):null}))}function m(t){switch(typeof t){case"number":case"string":case"undefined":return!0;case"boolean":return!t;case"object":if(Array.isArray(t))return t.every(m);if(null===t||e(t))return!0;var n=function(e){var t=e&&(s&&e[s]||e["@@iterator"]);if("function"==typeof t)return t}(t);if(!n)return!1;var r,a=n.call(t);if(n!==t.entries){for(;!(r=a.next()).done;)if(!m(r.value))return!1}else for(;!(r=a.next()).done;){var o=r.value;if(o&&!m(o[1]))return!1}return!0;default:return!1}}function g(e){var t=typeof e;return Array.isArray(e)?"array":e instanceof RegExp?"object":function(e,t){return"symbol"===e||"Symbol"===t["@@toStringTag"]||"function"==typeof Symbol&&t instanceof Symbol}(t,e)?"symbol":t}function y(e){if(null==e)return""+e;var t=g(e);if("object"===t){if(e instanceof Date)return"date";if(e instanceof RegExp)return"regexp"}return t}function v(e){var t=y(e);switch(t){case"array":case"object":return"an "+t;case"boolean":case"date":case"regexp":return"a "+t;default:return t}}return d.prototype=Error.prototype,p.checkPropTypes=u,p.PropTypes=p,p}}).call(t,n(5))},function(e,t){"use strict";function n(e){return function(){return e}}var r=function(){};r.thatReturns=n,r.thatReturnsFalse=n(!1),r.thatReturnsTrue=n(!0),r.thatReturnsNull=n(null),r.thatReturnsThis=function(){return this},r.thatReturnsArgument=function(e){return e},e.exports=r},function(e,t,n){(function(t){"use strict";var n=function(e){};"production"!==t.env.NODE_ENV&&(n=function(e){if(void 0===e)throw new Error("invariant requires an error message argument")}),e.exports=function(e,t,r,a,o,l,i,u){if(n(t),!e){var s;if(void 0===t)s=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var c=[r,a,o,l,i,u],p=0;(s=new Error(t.replace(/%s/g,(function(){return c[p++]})))).name="Invariant Violation"}throw s.framesToPop=1,s}}}).call(t,n(5))},function(e,t,n){(function(t){"use strict";var r=n(7);if("production"!==t.env.NODE_ENV){var a=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];var a=0,o="Warning: "+e.replace(/%s/g,(function(){return n[a++]}));"undefined"!=typeof console&&console.error(o);try{throw new Error(o)}catch(e){}};r=function(e,t){if(void 0===t)throw new Error("`warning(condition, format, ...args)` requires a warning message argument");if(0!==t.indexOf("Failed Composite propType: ")&&!e){for(var n=arguments.length,r=Array(n>2?n-2:0),o=2;o<n;o++)r[o-2]=arguments[o];a.apply(void 0,[t].concat(r))}}}e.exports=r}).call(t,n(5))},function(e,t){"use strict";var n=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,a=Object.prototype.propertyIsEnumerable;function o(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}e.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map((function(e){return t[e]})).join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach((function(e){r[e]=e})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(e){return!1}}()?Object.assign:function(e,t){for(var l,i,u=o(e),s=1;s<arguments.length;s++){for(var c in l=Object(arguments[s]))r.call(l,c)&&(u[c]=l[c]);if(n){i=n(l);for(var p=0;p<i.length;p++)a.call(l,i[p])&&(u[i[p]]=l[i[p]])}}return u}},function(e,t){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},function(e,t,n){(function(t){"use strict";if("production"!==t.env.NODE_ENV)var r=n(8),a=n(9),o=n(11),l={};e.exports=function(e,n,i,u,s){if("production"!==t.env.NODE_ENV)for(var c in e)if(e.hasOwnProperty(c)){var p;try{r("function"==typeof e[c],"%s: %s type `%s` is invalid; it must be a function, usually from the `prop-types` package, but received `%s`.",u||"React class",i,c,typeof e[c]),p=e[c](n,c,u,i,null,o)}catch(e){p=e}if(a(!p||p instanceof Error,"%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",u||"React class",i,c,typeof p),p instanceof Error&&!(p.message in l)){l[p.message]=!0;var d=s?s():"";a(!1,"Failed %s type: %s%s",i,p.message,null!=d?d:"")}}}}).call(t,n(5))},function(e,t,n){"use strict";var r=n(7),a=n(8),o=n(11);e.exports=function(){function e(e,t,n,r,l,i){i!==o&&a(!1,"Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types")}function t(){return e}e.isRequired=e;var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t};return n.checkPropTypes=r,n.PropTypes=n,n}},function(e,t){e.exports=n(7294)},function(e,t){"use strict";var n=function(e,t){return e===t};e.exports=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:n,r=void 0,a=[],o=void 0,l=!1,i=function(e,n){return t(e,a[n])},u=function(){for(var t=arguments.length,n=Array(t),u=0;u<t;u++)n[u]=arguments[u];return l&&r===this&&n.length===a.length&&n.every(i)?o:(l=!0,r=this,a=n,o=e.apply(this,n))};return u}}])},9921:(e,t)=>{"use strict";var n="function"==typeof Symbol&&Symbol.for,r=n?Symbol.for("react.element"):60103,a=n?Symbol.for("react.portal"):60106,o=n?Symbol.for("react.fragment"):60107,l=n?Symbol.for("react.strict_mode"):60108,i=n?Symbol.for("react.profiler"):60114,u=n?Symbol.for("react.provider"):60109,s=n?Symbol.for("react.context"):60110,c=n?Symbol.for("react.async_mode"):60111,p=n?Symbol.for("react.concurrent_mode"):60111,d=n?Symbol.for("react.forward_ref"):60112,f=n?Symbol.for("react.suspense"):60113,h=n?Symbol.for("react.suspense_list"):60120,m=n?Symbol.for("react.memo"):60115,g=n?Symbol.for("react.lazy"):60116,y=n?Symbol.for("react.block"):60121,v=n?Symbol.for("react.fundamental"):60117,b=n?Symbol.for("react.responder"):60118,w=n?Symbol.for("react.scope"):60119;function E(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case r:switch(e=e.type){case c:case p:case o:case i:case l:case f:return e;default:switch(e=e&&e.$$typeof){case s:case d:case g:case m:case u:return e;default:return t}}case a:return t}}}function _(e){return E(e)===p}t.AsyncMode=c,t.ConcurrentMode=p,t.ContextConsumer=s,t.ContextProvider=u,t.Element=r,t.ForwardRef=d,t.Fragment=o,t.Lazy=g,t.Memo=m,t.Portal=a,t.Profiler=i,t.StrictMode=l,t.Suspense=f,t.isAsyncMode=function(e){return _(e)||E(e)===c},t.isConcurrentMode=_,t.isContextConsumer=function(e){return E(e)===s},t.isContextProvider=function(e){return E(e)===u},t.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===r},t.isForwardRef=function(e){return E(e)===d},t.isFragment=function(e){return E(e)===o},t.isLazy=function(e){return E(e)===g},t.isMemo=function(e){return E(e)===m},t.isPortal=function(e){return E(e)===a},t.isProfiler=function(e){return E(e)===i},t.isStrictMode=function(e){return E(e)===l},t.isSuspense=function(e){return E(e)===f},t.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===o||e===p||e===i||e===l||e===f||e===h||"object"==typeof e&&null!==e&&(e.$$typeof===g||e.$$typeof===m||e.$$typeof===u||e.$$typeof===s||e.$$typeof===d||e.$$typeof===v||e.$$typeof===b||e.$$typeof===w||e.$$typeof===y)},t.typeOf=E},9864:(e,t,n)=>{"use strict";e.exports=n(9921)},8949:(e,t,n)=>{"use strict";n.r(t),n.d(t,{IGNORE_CLASS_NAME:()=>h,default:()=>g});var r=n(7294),a=n(3935);function o(e,t){return o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},o(e,t)}function l(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function i(e,t,n){return e===t||(e.correspondingElement?e.correspondingElement.classList.contains(n):e.classList.contains(n))}var u,s,c=(void 0===u&&(u=0),function(){return++u}),p={},d={},f=["touchstart","touchmove"],h="ignore-react-onclickoutside";function m(e,t){var n=null;return-1!==f.indexOf(t)&&s&&(n={passive:!e.props.preventDefault}),n}const g=function(e,t){var n,u,f=e.displayName||e.name||"Component";return u=n=function(n){var u,h;function g(e){var r;return(r=n.call(this,e)||this).__outsideClickHandler=function(e){if("function"!=typeof r.__clickOutsideHandlerProp){var t=r.getInstance();if("function"!=typeof t.props.handleClickOutside){if("function"!=typeof t.handleClickOutside)throw new Error("WrappedComponent: "+f+" lacks a handleClickOutside(event) function for processing outside click events.");t.handleClickOutside(e)}else t.props.handleClickOutside(e)}else r.__clickOutsideHandlerProp(e)},r.__getComponentNode=function(){var e=r.getInstance();return t&&"function"==typeof t.setClickOutsideRef?t.setClickOutsideRef()(e):"function"==typeof e.setClickOutsideRef?e.setClickOutsideRef():(0,a.findDOMNode)(e)},r.enableOnClickOutside=function(){if("undefined"!=typeof document&&!d[r._uid]){void 0===s&&(s=function(){if("undefined"!=typeof window&&"function"==typeof window.addEventListener){var e=!1,t=Object.defineProperty({},"passive",{get:function(){e=!0}}),n=function(){};return window.addEventListener("testPassiveEventSupport",n,t),window.removeEventListener("testPassiveEventSupport",n,t),e}}()),d[r._uid]=!0;var e=r.props.eventTypes;e.forEach||(e=[e]),p[r._uid]=function(e){var t;null!==r.componentNode&&(r.props.preventDefault&&e.preventDefault(),r.props.stopPropagation&&e.stopPropagation(),r.props.excludeScrollbar&&(t=e,document.documentElement.clientWidth<=t.clientX||document.documentElement.clientHeight<=t.clientY)||function(e,t,n){if(e===t)return!0;for(;e.parentNode||e.host;){if(e.parentNode&&i(e,t,n))return!0;e=e.parentNode||e.host}return e}(e.composed&&e.composedPath&&e.composedPath().shift()||e.target,r.componentNode,r.props.outsideClickIgnoreClass)===document&&r.__outsideClickHandler(e))},e.forEach((function(e){document.addEventListener(e,p[r._uid],m(l(r),e))}))}},r.disableOnClickOutside=function(){delete d[r._uid];var e=p[r._uid];if(e&&"undefined"!=typeof document){var t=r.props.eventTypes;t.forEach||(t=[t]),t.forEach((function(t){return document.removeEventListener(t,e,m(l(r),t))})),delete p[r._uid]}},r.getRef=function(e){return r.instanceRef=e},r._uid=c(),r}h=n,(u=g).prototype=Object.create(h.prototype),u.prototype.constructor=u,o(u,h);var y=g.prototype;return y.getInstance=function(){if(e.prototype&&!e.prototype.isReactComponent)return this;var t=this.instanceRef;return t.getInstance?t.getInstance():t},y.componentDidMount=function(){if("undefined"!=typeof document&&document.createElement){var e=this.getInstance();if(t&&"function"==typeof t.handleClickOutside&&(this.__clickOutsideHandlerProp=t.handleClickOutside(e),"function"!=typeof this.__clickOutsideHandlerProp))throw new Error("WrappedComponent: "+f+" lacks a function for processing outside click events specified by the handleClickOutside config option.");this.componentNode=this.__getComponentNode(),this.props.disableOnClickOutside||this.enableOnClickOutside()}},y.componentDidUpdate=function(){this.componentNode=this.__getComponentNode()},y.componentWillUnmount=function(){this.disableOnClickOutside()},y.render=function(){var t=this.props;t.excludeScrollbar;var n=function(e,t){if(null==e)return{};var n,r,a={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(a[n]=e[n]);return a}(t,["excludeScrollbar"]);return e.prototype&&e.prototype.isReactComponent?n.ref=this.getRef:n.wrappedRef=this.getRef,n.disableOnClickOutside=this.disableOnClickOutside,n.enableOnClickOutside=this.enableOnClickOutside,(0,r.createElement)(e,n)},g}(r.Component),n.displayName="OnClickOutside("+f+")",n.defaultProps={eventTypes:["mousedown","touchstart"],excludeScrollbar:t&&t.excludeScrollbar||!1,outsideClickIgnoreClass:h,preventDefault:!1,stopPropagation:!1},n.getClass=function(){return e.getClass?e.getClass():e},u}},5455:(e,t,n)=>{"use strict";n.r(t),n.d(t,{Manager:()=>l,Popper:()=>Ce,Reference:()=>Pe,usePopper:()=>_e});var r=n(7294),a=r.createContext(),o=r.createContext();function l(e){var t=e.children,n=r.useState(null),l=n[0],i=n[1],u=r.useRef(!1);r.useEffect((function(){return function(){u.current=!0}}),[]);var s=r.useCallback((function(e){u.current||i(e)}),[]);return r.createElement(a.Provider,{value:l},r.createElement(o.Provider,{value:s},t))}var i=function(e){return Array.isArray(e)?e[0]:e},u=function(e){if("function"==typeof e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return e.apply(void 0,n)}},s=function(e,t){if("function"==typeof e)return u(e,t);null!=e&&(e.current=t)},c=function(e){return e.reduce((function(e,t){var n=t[0],r=t[1];return e[n]=r,e}),{})},p="undefined"!=typeof window&&window.document&&window.document.createElement?r.useLayoutEffect:r.useEffect,d=n(3935);function f(e){if(null==e)return window;if("[object Window]"!==e.toString()){var t=e.ownerDocument;return t&&t.defaultView||window}return e}function h(e){return e instanceof f(e).Element||e instanceof Element}function m(e){return e instanceof f(e).HTMLElement||e instanceof HTMLElement}function g(e){return"undefined"!=typeof ShadowRoot&&(e instanceof f(e).ShadowRoot||e instanceof ShadowRoot)}var y=Math.max,v=Math.min,b=Math.round;function w(e,t){void 0===t&&(t=!1);var n=e.getBoundingClientRect(),r=1,a=1;if(m(e)&&t){var o=e.offsetHeight,l=e.offsetWidth;l>0&&(r=b(n.width)/l||1),o>0&&(a=b(n.height)/o||1)}return{width:n.width/r,height:n.height/a,top:n.top/a,right:n.right/r,bottom:n.bottom/a,left:n.left/r,x:n.left/r,y:n.top/a}}function E(e){var t=f(e);return{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function _(e){return e?(e.nodeName||"").toLowerCase():null}function x(e){return((h(e)?e.ownerDocument:e.document)||window.document).documentElement}function S(e){return w(x(e)).left+E(e).scrollLeft}function k(e){return f(e).getComputedStyle(e)}function C(e){var t=k(e),n=t.overflow,r=t.overflowX,a=t.overflowY;return/auto|scroll|overlay|hidden/.test(n+a+r)}function D(e,t,n){void 0===n&&(n=!1);var r,a,o=m(t),l=m(t)&&function(e){var t=e.getBoundingClientRect(),n=b(t.width)/e.offsetWidth||1,r=b(t.height)/e.offsetHeight||1;return 1!==n||1!==r}(t),i=x(t),u=w(e,l),s={scrollLeft:0,scrollTop:0},c={x:0,y:0};return(o||!o&&!n)&&(("body"!==_(t)||C(i))&&(s=(r=t)!==f(r)&&m(r)?{scrollLeft:(a=r).scrollLeft,scrollTop:a.scrollTop}:E(r)),m(t)?((c=w(t,!0)).x+=t.clientLeft,c.y+=t.clientTop):i&&(c.x=S(i))),{x:u.left+s.scrollLeft-c.x,y:u.top+s.scrollTop-c.y,width:u.width,height:u.height}}function O(e){var t=w(e),n=e.offsetWidth,r=e.offsetHeight;return Math.abs(t.width-n)<=1&&(n=t.width),Math.abs(t.height-r)<=1&&(r=t.height),{x:e.offsetLeft,y:e.offsetTop,width:n,height:r}}function P(e){return"html"===_(e)?e:e.assignedSlot||e.parentNode||(g(e)?e.host:null)||x(e)}function T(e){return["html","body","#document"].indexOf(_(e))>=0?e.ownerDocument.body:m(e)&&C(e)?e:T(P(e))}function N(e,t){var n;void 0===t&&(t=[]);var r=T(e),a=r===(null==(n=e.ownerDocument)?void 0:n.body),o=f(r),l=a?[o].concat(o.visualViewport||[],C(r)?r:[]):r,i=t.concat(l);return a?i:i.concat(N(P(l)))}function M(e){return["table","td","th"].indexOf(_(e))>=0}function R(e){return m(e)&&"fixed"!==k(e).position?e.offsetParent:null}function j(e){for(var t=f(e),n=R(e);n&&M(n)&&"static"===k(n).position;)n=R(n);return n&&("html"===_(n)||"body"===_(n)&&"static"===k(n).position)?t:n||function(e){var t=-1!==navigator.userAgent.toLowerCase().indexOf("firefox");if(-1!==navigator.userAgent.indexOf("Trident")&&m(e)&&"fixed"===k(e).position)return null;var n=P(e);for(g(n)&&(n=n.host);m(n)&&["html","body"].indexOf(_(n))<0;){var r=k(n);if("none"!==r.transform||"none"!==r.perspective||"paint"===r.contain||-1!==["transform","perspective"].indexOf(r.willChange)||t&&"filter"===r.willChange||t&&r.filter&&"none"!==r.filter)return n;n=n.parentNode}return null}(e)||t}var A="top",I="bottom",F="right",L="left",U="auto",z=[A,I,F,L],Y="start",W="end",B="viewport",H="popper",q=z.reduce((function(e,t){return e.concat([t+"-"+Y,t+"-"+W])}),[]),V=[].concat(z,[U]).reduce((function(e,t){return e.concat([t,t+"-"+Y,t+"-"+W])}),[]),$=["beforeRead","read","afterRead","beforeMain","main","afterMain","beforeWrite","write","afterWrite"];function Z(e){var t=new Map,n=new Set,r=[];function a(e){n.add(e.name),[].concat(e.requires||[],e.requiresIfExists||[]).forEach((function(e){if(!n.has(e)){var r=t.get(e);r&&a(r)}})),r.push(e)}return e.forEach((function(e){t.set(e.name,e)})),e.forEach((function(e){n.has(e.name)||a(e)})),r}var Q={placement:"bottom",modifiers:[],strategy:"absolute"};function K(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return!t.some((function(e){return!(e&&"function"==typeof e.getBoundingClientRect)}))}function G(e){void 0===e&&(e={});var t=e,n=t.defaultModifiers,r=void 0===n?[]:n,a=t.defaultOptions,o=void 0===a?Q:a;return function(e,t,n){void 0===n&&(n=o);var a,l,i={placement:"bottom",orderedModifiers:[],options:Object.assign({},Q,o),modifiersData:{},elements:{reference:e,popper:t},attributes:{},styles:{}},u=[],s=!1,c={state:i,setOptions:function(n){var a="function"==typeof n?n(i.options):n;p(),i.options=Object.assign({},o,i.options,a),i.scrollParents={reference:h(e)?N(e):e.contextElement?N(e.contextElement):[],popper:N(t)};var l,s,d=function(e){var t=Z(e);return $.reduce((function(e,n){return e.concat(t.filter((function(e){return e.phase===n})))}),[])}((l=[].concat(r,i.options.modifiers),s=l.reduce((function(e,t){var n=e[t.name];return e[t.name]=n?Object.assign({},n,t,{options:Object.assign({},n.options,t.options),data:Object.assign({},n.data,t.data)}):t,e}),{}),Object.keys(s).map((function(e){return s[e]}))));return i.orderedModifiers=d.filter((function(e){return e.enabled})),i.orderedModifiers.forEach((function(e){var t=e.name,n=e.options,r=void 0===n?{}:n,a=e.effect;if("function"==typeof a){var o=a({state:i,name:t,instance:c,options:r});u.push(o||function(){})}})),c.update()},forceUpdate:function(){if(!s){var e=i.elements,t=e.reference,n=e.popper;if(K(t,n)){i.rects={reference:D(t,j(n),"fixed"===i.options.strategy),popper:O(n)},i.reset=!1,i.placement=i.options.placement,i.orderedModifiers.forEach((function(e){return i.modifiersData[e.name]=Object.assign({},e.data)}));for(var r=0;r<i.orderedModifiers.length;r++)if(!0!==i.reset){var a=i.orderedModifiers[r],o=a.fn,l=a.options,u=void 0===l?{}:l,p=a.name;"function"==typeof o&&(i=o({state:i,options:u,name:p,instance:c})||i)}else i.reset=!1,r=-1}}},update:(a=function(){return new Promise((function(e){c.forceUpdate(),e(i)}))},function(){return l||(l=new Promise((function(e){Promise.resolve().then((function(){l=void 0,e(a())}))}))),l}),destroy:function(){p(),s=!0}};if(!K(e,t))return c;function p(){u.forEach((function(e){return e()})),u=[]}return c.setOptions(n).then((function(e){!s&&n.onFirstUpdate&&n.onFirstUpdate(e)})),c}}var X={passive:!0};function J(e){return e.split("-")[0]}function ee(e){return e.split("-")[1]}function te(e){return["top","bottom"].indexOf(e)>=0?"x":"y"}function ne(e){var t,n=e.reference,r=e.element,a=e.placement,o=a?J(a):null,l=a?ee(a):null,i=n.x+n.width/2-r.width/2,u=n.y+n.height/2-r.height/2;switch(o){case A:t={x:i,y:n.y-r.height};break;case I:t={x:i,y:n.y+n.height};break;case F:t={x:n.x+n.width,y:u};break;case L:t={x:n.x-r.width,y:u};break;default:t={x:n.x,y:n.y}}var s=o?te(o):null;if(null!=s){var c="y"===s?"height":"width";switch(l){case Y:t[s]=t[s]-(n[c]/2-r[c]/2);break;case W:t[s]=t[s]+(n[c]/2-r[c]/2)}}return t}var re={top:"auto",right:"auto",bottom:"auto",left:"auto"};function ae(e){var t,n=e.popper,r=e.popperRect,a=e.placement,o=e.variation,l=e.offsets,i=e.position,u=e.gpuAcceleration,s=e.adaptive,c=e.roundOffsets,p=e.isFixed,d=l.x,h=void 0===d?0:d,m=l.y,g=void 0===m?0:m,y="function"==typeof c?c({x:h,y:g}):{x:h,y:g};h=y.x,g=y.y;var v=l.hasOwnProperty("x"),w=l.hasOwnProperty("y"),E=L,_=A,S=window;if(s){var C=j(n),D="clientHeight",O="clientWidth";C===f(n)&&"static"!==k(C=x(n)).position&&"absolute"===i&&(D="scrollHeight",O="scrollWidth"),C=C,(a===A||(a===L||a===F)&&o===W)&&(_=I,g-=(p&&C===S&&S.visualViewport?S.visualViewport.height:C[D])-r.height,g*=u?1:-1),a!==L&&(a!==A&&a!==I||o!==W)||(E=F,h-=(p&&C===S&&S.visualViewport?S.visualViewport.width:C[O])-r.width,h*=u?1:-1)}var P,T=Object.assign({position:i},s&&re),N=!0===c?function(e){var t=e.x,n=e.y,r=window.devicePixelRatio||1;return{x:b(t*r)/r||0,y:b(n*r)/r||0}}({x:h,y:g}):{x:h,y:g};return h=N.x,g=N.y,u?Object.assign({},T,((P={})[_]=w?"0":"",P[E]=v?"0":"",P.transform=(S.devicePixelRatio||1)<=1?"translate("+h+"px, "+g+"px)":"translate3d("+h+"px, "+g+"px, 0)",P)):Object.assign({},T,((t={})[_]=w?g+"px":"",t[E]=v?h+"px":"",t.transform="",t))}var oe={left:"right",right:"left",bottom:"top",top:"bottom"};function le(e){return e.replace(/left|right|bottom|top/g,(function(e){return oe[e]}))}var ie={start:"end",end:"start"};function ue(e){return e.replace(/start|end/g,(function(e){return ie[e]}))}function se(e,t){var n=t.getRootNode&&t.getRootNode();if(e.contains(t))return!0;if(n&&g(n)){var r=t;do{if(r&&e.isSameNode(r))return!0;r=r.parentNode||r.host}while(r)}return!1}function ce(e){return Object.assign({},e,{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height})}function pe(e,t){return t===B?ce(function(e){var t=f(e),n=x(e),r=t.visualViewport,a=n.clientWidth,o=n.clientHeight,l=0,i=0;return r&&(a=r.width,o=r.height,/^((?!chrome|android).)*safari/i.test(navigator.userAgent)||(l=r.offsetLeft,i=r.offsetTop)),{width:a,height:o,x:l+S(e),y:i}}(e)):h(t)?function(e){var t=w(e);return t.top=t.top+e.clientTop,t.left=t.left+e.clientLeft,t.bottom=t.top+e.clientHeight,t.right=t.left+e.clientWidth,t.width=e.clientWidth,t.height=e.clientHeight,t.x=t.left,t.y=t.top,t}(t):ce(function(e){var t,n=x(e),r=E(e),a=null==(t=e.ownerDocument)?void 0:t.body,o=y(n.scrollWidth,n.clientWidth,a?a.scrollWidth:0,a?a.clientWidth:0),l=y(n.scrollHeight,n.clientHeight,a?a.scrollHeight:0,a?a.clientHeight:0),i=-r.scrollLeft+S(e),u=-r.scrollTop;return"rtl"===k(a||n).direction&&(i+=y(n.clientWidth,a?a.clientWidth:0)-o),{width:o,height:l,x:i,y:u}}(x(e)))}function de(e){return Object.assign({},{top:0,right:0,bottom:0,left:0},e)}function fe(e,t){return t.reduce((function(t,n){return t[n]=e,t}),{})}function he(e,t){void 0===t&&(t={});var n=t,r=n.placement,a=void 0===r?e.placement:r,o=n.boundary,l=void 0===o?"clippingParents":o,i=n.rootBoundary,u=void 0===i?B:i,s=n.elementContext,c=void 0===s?H:s,p=n.altBoundary,d=void 0!==p&&p,f=n.padding,g=void 0===f?0:f,b=de("number"!=typeof g?g:fe(g,z)),E=c===H?"reference":H,S=e.rects.popper,C=e.elements[d?E:c],D=function(e,t,n){var r="clippingParents"===t?function(e){var t=N(P(e)),n=["absolute","fixed"].indexOf(k(e).position)>=0&&m(e)?j(e):e;return h(n)?t.filter((function(e){return h(e)&&se(e,n)&&"body"!==_(e)})):[]}(e):[].concat(t),a=[].concat(r,[n]),o=a[0],l=a.reduce((function(t,n){var r=pe(e,n);return t.top=y(r.top,t.top),t.right=v(r.right,t.right),t.bottom=v(r.bottom,t.bottom),t.left=y(r.left,t.left),t}),pe(e,o));return l.width=l.right-l.left,l.height=l.bottom-l.top,l.x=l.left,l.y=l.top,l}(h(C)?C:C.contextElement||x(e.elements.popper),l,u),O=w(e.elements.reference),T=ne({reference:O,element:S,strategy:"absolute",placement:a}),M=ce(Object.assign({},S,T)),R=c===H?M:O,L={top:D.top-R.top+b.top,bottom:R.bottom-D.bottom+b.bottom,left:D.left-R.left+b.left,right:R.right-D.right+b.right},U=e.modifiersData.offset;if(c===H&&U){var Y=U[a];Object.keys(L).forEach((function(e){var t=[F,I].indexOf(e)>=0?1:-1,n=[A,I].indexOf(e)>=0?"y":"x";L[e]+=Y[n]*t}))}return L}function me(e,t,n){return y(e,v(t,n))}function ge(e,t,n){return void 0===n&&(n={x:0,y:0}),{top:e.top-t.height-n.y,right:e.right-t.width+n.x,bottom:e.bottom-t.height+n.y,left:e.left-t.width-n.x}}function ye(e){return[A,F,I,L].some((function(t){return e[t]>=0}))}var ve=G({defaultModifiers:[{name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:function(e){var t=e.state,n=e.instance,r=e.options,a=r.scroll,o=void 0===a||a,l=r.resize,i=void 0===l||l,u=f(t.elements.popper),s=[].concat(t.scrollParents.reference,t.scrollParents.popper);return o&&s.forEach((function(e){e.addEventListener("scroll",n.update,X)})),i&&u.addEventListener("resize",n.update,X),function(){o&&s.forEach((function(e){e.removeEventListener("scroll",n.update,X)})),i&&u.removeEventListener("resize",n.update,X)}},data:{}},{name:"popperOffsets",enabled:!0,phase:"read",fn:function(e){var t=e.state,n=e.name;t.modifiersData[n]=ne({reference:t.rects.reference,element:t.rects.popper,strategy:"absolute",placement:t.placement})},data:{}},{name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:function(e){var t=e.state,n=e.options,r=n.gpuAcceleration,a=void 0===r||r,o=n.adaptive,l=void 0===o||o,i=n.roundOffsets,u=void 0===i||i,s={placement:J(t.placement),variation:ee(t.placement),popper:t.elements.popper,popperRect:t.rects.popper,gpuAcceleration:a,isFixed:"fixed"===t.options.strategy};null!=t.modifiersData.popperOffsets&&(t.styles.popper=Object.assign({},t.styles.popper,ae(Object.assign({},s,{offsets:t.modifiersData.popperOffsets,position:t.options.strategy,adaptive:l,roundOffsets:u})))),null!=t.modifiersData.arrow&&(t.styles.arrow=Object.assign({},t.styles.arrow,ae(Object.assign({},s,{offsets:t.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:u})))),t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-placement":t.placement})},data:{}},{name:"applyStyles",enabled:!0,phase:"write",fn:function(e){var t=e.state;Object.keys(t.elements).forEach((function(e){var n=t.styles[e]||{},r=t.attributes[e]||{},a=t.elements[e];m(a)&&_(a)&&(Object.assign(a.style,n),Object.keys(r).forEach((function(e){var t=r[e];!1===t?a.removeAttribute(e):a.setAttribute(e,!0===t?"":t)})))}))},effect:function(e){var t=e.state,n={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(t.elements.popper.style,n.popper),t.styles=n,t.elements.arrow&&Object.assign(t.elements.arrow.style,n.arrow),function(){Object.keys(t.elements).forEach((function(e){var r=t.elements[e],a=t.attributes[e]||{},o=Object.keys(t.styles.hasOwnProperty(e)?t.styles[e]:n[e]).reduce((function(e,t){return e[t]="",e}),{});m(r)&&_(r)&&(Object.assign(r.style,o),Object.keys(a).forEach((function(e){r.removeAttribute(e)})))}))}},requires:["computeStyles"]},{name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:function(e){var t=e.state,n=e.options,r=e.name,a=n.offset,o=void 0===a?[0,0]:a,l=V.reduce((function(e,n){return e[n]=function(e,t,n){var r=J(e),a=[L,A].indexOf(r)>=0?-1:1,o="function"==typeof n?n(Object.assign({},t,{placement:e})):n,l=o[0],i=o[1];return l=l||0,i=(i||0)*a,[L,F].indexOf(r)>=0?{x:i,y:l}:{x:l,y:i}}(n,t.rects,o),e}),{}),i=l[t.placement],u=i.x,s=i.y;null!=t.modifiersData.popperOffsets&&(t.modifiersData.popperOffsets.x+=u,t.modifiersData.popperOffsets.y+=s),t.modifiersData[r]=l}},{name:"flip",enabled:!0,phase:"main",fn:function(e){var t=e.state,n=e.options,r=e.name;if(!t.modifiersData[r]._skip){for(var a=n.mainAxis,o=void 0===a||a,l=n.altAxis,i=void 0===l||l,u=n.fallbackPlacements,s=n.padding,c=n.boundary,p=n.rootBoundary,d=n.altBoundary,f=n.flipVariations,h=void 0===f||f,m=n.allowedAutoPlacements,g=t.options.placement,y=J(g),v=u||(y!==g&&h?function(e){if(J(e)===U)return[];var t=le(e);return[ue(e),t,ue(t)]}(g):[le(g)]),b=[g].concat(v).reduce((function(e,n){return e.concat(J(n)===U?function(e,t){void 0===t&&(t={});var n=t,r=n.placement,a=n.boundary,o=n.rootBoundary,l=n.padding,i=n.flipVariations,u=n.allowedAutoPlacements,s=void 0===u?V:u,c=ee(r),p=c?i?q:q.filter((function(e){return ee(e)===c})):z,d=p.filter((function(e){return s.indexOf(e)>=0}));0===d.length&&(d=p);var f=d.reduce((function(t,n){return t[n]=he(e,{placement:n,boundary:a,rootBoundary:o,padding:l})[J(n)],t}),{});return Object.keys(f).sort((function(e,t){return f[e]-f[t]}))}(t,{placement:n,boundary:c,rootBoundary:p,padding:s,flipVariations:h,allowedAutoPlacements:m}):n)}),[]),w=t.rects.reference,E=t.rects.popper,_=new Map,x=!0,S=b[0],k=0;k<b.length;k++){var C=b[k],D=J(C),O=ee(C)===Y,P=[A,I].indexOf(D)>=0,T=P?"width":"height",N=he(t,{placement:C,boundary:c,rootBoundary:p,altBoundary:d,padding:s}),M=P?O?F:L:O?I:A;w[T]>E[T]&&(M=le(M));var R=le(M),j=[];if(o&&j.push(N[D]<=0),i&&j.push(N[M]<=0,N[R]<=0),j.every((function(e){return e}))){S=C,x=!1;break}_.set(C,j)}if(x)for(var W=function(e){var t=b.find((function(t){var n=_.get(t);if(n)return n.slice(0,e).every((function(e){return e}))}));if(t)return S=t,"break"},B=h?3:1;B>0&&"break"!==W(B);B--);t.placement!==S&&(t.modifiersData[r]._skip=!0,t.placement=S,t.reset=!0)}},requiresIfExists:["offset"],data:{_skip:!1}},{name:"preventOverflow",enabled:!0,phase:"main",fn:function(e){var t=e.state,n=e.options,r=e.name,a=n.mainAxis,o=void 0===a||a,l=n.altAxis,i=void 0!==l&&l,u=n.boundary,s=n.rootBoundary,c=n.altBoundary,p=n.padding,d=n.tether,f=void 0===d||d,h=n.tetherOffset,m=void 0===h?0:h,g=he(t,{boundary:u,rootBoundary:s,padding:p,altBoundary:c}),b=J(t.placement),w=ee(t.placement),E=!w,_=te(b),x="x"===_?"y":"x",S=t.modifiersData.popperOffsets,k=t.rects.reference,C=t.rects.popper,D="function"==typeof m?m(Object.assign({},t.rects,{placement:t.placement})):m,P="number"==typeof D?{mainAxis:D,altAxis:D}:Object.assign({mainAxis:0,altAxis:0},D),T=t.modifiersData.offset?t.modifiersData.offset[t.placement]:null,N={x:0,y:0};if(S){if(o){var M,R="y"===_?A:L,U="y"===_?I:F,z="y"===_?"height":"width",W=S[_],B=W+g[R],H=W-g[U],q=f?-C[z]/2:0,V=w===Y?k[z]:C[z],$=w===Y?-C[z]:-k[z],Z=t.elements.arrow,Q=f&&Z?O(Z):{width:0,height:0},K=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:{top:0,right:0,bottom:0,left:0},G=K[R],X=K[U],ne=me(0,k[z],Q[z]),re=E?k[z]/2-q-ne-G-P.mainAxis:V-ne-G-P.mainAxis,ae=E?-k[z]/2+q+ne+X+P.mainAxis:$+ne+X+P.mainAxis,oe=t.elements.arrow&&j(t.elements.arrow),le=oe?"y"===_?oe.clientTop||0:oe.clientLeft||0:0,ie=null!=(M=null==T?void 0:T[_])?M:0,ue=W+ae-ie,se=me(f?v(B,W+re-ie-le):B,W,f?y(H,ue):H);S[_]=se,N[_]=se-W}if(i){var ce,pe="x"===_?A:L,de="x"===_?I:F,fe=S[x],ge="y"===x?"height":"width",ye=fe+g[pe],ve=fe-g[de],be=-1!==[A,L].indexOf(b),we=null!=(ce=null==T?void 0:T[x])?ce:0,Ee=be?ye:fe-k[ge]-C[ge]-we+P.altAxis,_e=be?fe+k[ge]+C[ge]-we-P.altAxis:ve,xe=f&&be?function(e,t,n){var r=me(e,t,n);return r>n?n:r}(Ee,fe,_e):me(f?Ee:ye,fe,f?_e:ve);S[x]=xe,N[x]=xe-fe}t.modifiersData[r]=N}},requiresIfExists:["offset"]},{name:"arrow",enabled:!0,phase:"main",fn:function(e){var t,n=e.state,r=e.name,a=e.options,o=n.elements.arrow,l=n.modifiersData.popperOffsets,i=J(n.placement),u=te(i),s=[L,F].indexOf(i)>=0?"height":"width";if(o&&l){var c=function(e,t){return de("number"!=typeof(e="function"==typeof e?e(Object.assign({},t.rects,{placement:t.placement})):e)?e:fe(e,z))}(a.padding,n),p=O(o),d="y"===u?A:L,f="y"===u?I:F,h=n.rects.reference[s]+n.rects.reference[u]-l[u]-n.rects.popper[s],m=l[u]-n.rects.reference[u],g=j(o),y=g?"y"===u?g.clientHeight||0:g.clientWidth||0:0,v=h/2-m/2,b=c[d],w=y-p[s]-c[f],E=y/2-p[s]/2+v,_=me(b,E,w),x=u;n.modifiersData[r]=((t={})[x]=_,t.centerOffset=_-E,t)}},effect:function(e){var t=e.state,n=e.options.element,r=void 0===n?"[data-popper-arrow]":n;null!=r&&("string"!=typeof r||(r=t.elements.popper.querySelector(r)))&&se(t.elements.popper,r)&&(t.elements.arrow=r)},requires:["popperOffsets"],requiresIfExists:["preventOverflow"]},{name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:function(e){var t=e.state,n=e.name,r=t.rects.reference,a=t.rects.popper,o=t.modifiersData.preventOverflow,l=he(t,{elementContext:"reference"}),i=he(t,{altBoundary:!0}),u=ge(l,r),s=ge(i,a,o),c=ye(u),p=ye(s);t.modifiersData[n]={referenceClippingOffsets:u,popperEscapeOffsets:s,isReferenceHidden:c,hasPopperEscaped:p},t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-reference-hidden":c,"data-popper-escaped":p})}}]}),be=n(9590),we=n.n(be),Ee=[],_e=function(e,t,n){void 0===n&&(n={});var a=r.useRef(null),o={onFirstUpdate:n.onFirstUpdate,placement:n.placement||"bottom",strategy:n.strategy||"absolute",modifiers:n.modifiers||Ee},l=r.useState({styles:{popper:{position:o.strategy,left:"0",top:"0"},arrow:{position:"absolute"}},attributes:{}}),i=l[0],u=l[1],s=r.useMemo((function(){return{name:"updateState",enabled:!0,phase:"write",fn:function(e){var t=e.state,n=Object.keys(t.elements);d.flushSync((function(){u({styles:c(n.map((function(e){return[e,t.styles[e]||{}]}))),attributes:c(n.map((function(e){return[e,t.attributes[e]]})))})}))},requires:["computeStyles"]}}),[]),f=r.useMemo((function(){var e={onFirstUpdate:o.onFirstUpdate,placement:o.placement,strategy:o.strategy,modifiers:[].concat(o.modifiers,[s,{name:"applyStyles",enabled:!1}])};return we()(a.current,e)?a.current||e:(a.current=e,e)}),[o.onFirstUpdate,o.placement,o.strategy,o.modifiers,s]),h=r.useRef();return p((function(){h.current&&h.current.setOptions(f)}),[f]),p((function(){if(null!=e&&null!=t){var r=(n.createPopper||ve)(e,t,f);return h.current=r,function(){r.destroy(),h.current=null}}}),[e,t,n.createPopper]),{state:h.current?h.current.state:null,styles:i.styles,attributes:i.attributes,update:h.current?h.current.update:null,forceUpdate:h.current?h.current.forceUpdate:null}},xe=function(){},Se=function(){return Promise.resolve(null)},ke=[];function Ce(e){var t=e.placement,n=void 0===t?"bottom":t,o=e.strategy,l=void 0===o?"absolute":o,u=e.modifiers,c=void 0===u?ke:u,p=e.referenceElement,d=e.onFirstUpdate,f=e.innerRef,h=e.children,m=r.useContext(a),g=r.useState(null),y=g[0],v=g[1],b=r.useState(null),w=b[0],E=b[1];r.useEffect((function(){s(f,y)}),[f,y]);var _=r.useMemo((function(){return{placement:n,strategy:l,onFirstUpdate:d,modifiers:[].concat(c,[{name:"arrow",enabled:null!=w,options:{element:w}}])}}),[n,l,d,c,w]),x=_e(p||m,y,_),S=x.state,k=x.styles,C=x.forceUpdate,D=x.update,O=r.useMemo((function(){return{ref:v,style:k.popper,placement:S?S.placement:n,hasPopperEscaped:S&&S.modifiersData.hide?S.modifiersData.hide.hasPopperEscaped:null,isReferenceHidden:S&&S.modifiersData.hide?S.modifiersData.hide.isReferenceHidden:null,arrowProps:{style:k.arrow,ref:E},forceUpdate:C||xe,update:D||Se}}),[v,E,n,S,k,D,C]);return i(h)(O)}var De=n(2473),Oe=n.n(De);function Pe(e){var t=e.children,n=e.innerRef,a=r.useContext(o),l=r.useCallback((function(e){s(n,e),u(a,e)}),[n,a]);return r.useEffect((function(){return function(){return s(n,null)}}),[]),r.useEffect((function(){Oe()(Boolean(a),"`Reference` should not be used outside of a `Manager` component.")}),[a]),i(t)({ref:l})}},8359:(e,t)=>{"use strict";var n=Symbol.for("react.element"),r=Symbol.for("react.portal"),a=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),u=Symbol.for("react.context"),s=Symbol.for("react.server_context"),c=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),h=Symbol.for("react.lazy");Symbol.for("react.offscreen");Symbol.for("react.module.reference"),t.isContextConsumer=function(e){return function(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case n:switch(e=e.type){case a:case l:case o:case p:case d:return e;default:switch(e=e&&e.$$typeof){case s:case u:case c:case h:case f:case i:return e;default:return t}}case r:return t}}}(e)===u}},2973:(e,t,n)=>{"use strict";e.exports=n(8359)},2408:(e,t)=>{"use strict";var n=Symbol.for("react.element"),r=Symbol.for("react.portal"),a=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),u=Symbol.for("react.context"),s=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),p=Symbol.for("react.memo"),d=Symbol.for("react.lazy"),f=Symbol.iterator,h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},m=Object.assign,g={};function y(e,t,n){this.props=e,this.context=t,this.refs=g,this.updater=n||h}function v(){}function b(e,t,n){this.props=e,this.context=t,this.refs=g,this.updater=n||h}y.prototype.isReactComponent={},y.prototype.setState=function(e,t){if("object"!=typeof e&&"function"!=typeof e&&null!=e)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")},y.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},v.prototype=y.prototype;var w=b.prototype=new v;w.constructor=b,m(w,y.prototype),w.isPureReactComponent=!0;var E=Array.isArray,_=Object.prototype.hasOwnProperty,x={current:null},S={key:!0,ref:!0,__self:!0,__source:!0};function k(e,t,r){var a,o={},l=null,i=null;if(null!=t)for(a in void 0!==t.ref&&(i=t.ref),void 0!==t.key&&(l=""+t.key),t)_.call(t,a)&&!S.hasOwnProperty(a)&&(o[a]=t[a]);var u=arguments.length-2;if(1===u)o.children=r;else if(1<u){for(var s=Array(u),c=0;c<u;c++)s[c]=arguments[c+2];o.children=s}if(e&&e.defaultProps)for(a in u=e.defaultProps)void 0===o[a]&&(o[a]=u[a]);return{$$typeof:n,type:e,key:l,ref:i,props:o,_owner:x.current}}function C(e){return"object"==typeof e&&null!==e&&e.$$typeof===n}var D=/\/+/g;function O(e,t){return"object"==typeof e&&null!==e&&null!=e.key?function(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,(function(e){return t[e]}))}(""+e.key):t.toString(36)}function P(e,t,a,o,l){var i=typeof e;"undefined"!==i&&"boolean"!==i||(e=null);var u=!1;if(null===e)u=!0;else switch(i){case"string":case"number":u=!0;break;case"object":switch(e.$$typeof){case n:case r:u=!0}}if(u)return l=l(u=e),e=""===o?"."+O(u,0):o,E(l)?(a="",null!=e&&(a=e.replace(D,"$&/")+"/"),P(l,t,a,"",(function(e){return e}))):null!=l&&(C(l)&&(l=function(e,t){return{$$typeof:n,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}(l,a+(!l.key||u&&u.key===l.key?"":(""+l.key).replace(D,"$&/")+"/")+e)),t.push(l)),1;if(u=0,o=""===o?".":o+":",E(e))for(var s=0;s<e.length;s++){var c=o+O(i=e[s],s);u+=P(i,t,a,c,l)}else if(c=function(e){return null===e||"object"!=typeof e?null:"function"==typeof(e=f&&e[f]||e["@@iterator"])?e:null}(e),"function"==typeof c)for(e=c.call(e),s=0;!(i=e.next()).done;)u+=P(i=i.value,t,a,c=o+O(i,s++),l);else if("object"===i)throw t=String(e),Error("Objects are not valid as a React child (found: "+("[object Object]"===t?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.");return u}function T(e,t,n){if(null==e)return e;var r=[],a=0;return P(e,r,"","",(function(e){return t.call(n,e,a++)})),r}function N(e){if(-1===e._status){var t=e._result;(t=t()).then((function(t){0!==e._status&&-1!==e._status||(e._status=1,e._result=t)}),(function(t){0!==e._status&&-1!==e._status||(e._status=2,e._result=t)})),-1===e._status&&(e._status=0,e._result=t)}if(1===e._status)return e._result.default;throw e._result}var M={current:null},R={transition:null},j={ReactCurrentDispatcher:M,ReactCurrentBatchConfig:R,ReactCurrentOwner:x};t.Children={map:T,forEach:function(e,t,n){T(e,(function(){t.apply(this,arguments)}),n)},count:function(e){var t=0;return T(e,(function(){t++})),t},toArray:function(e){return T(e,(function(e){return e}))||[]},only:function(e){if(!C(e))throw Error("React.Children.only expected to receive a single React element child.");return e}},t.Component=y,t.Fragment=a,t.Profiler=l,t.PureComponent=b,t.StrictMode=o,t.Suspense=c,t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=j,t.cloneElement=function(e,t,r){if(null==e)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var a=m({},e.props),o=e.key,l=e.ref,i=e._owner;if(null!=t){if(void 0!==t.ref&&(l=t.ref,i=x.current),void 0!==t.key&&(o=""+t.key),e.type&&e.type.defaultProps)var u=e.type.defaultProps;for(s in t)_.call(t,s)&&!S.hasOwnProperty(s)&&(a[s]=void 0===t[s]&&void 0!==u?u[s]:t[s])}var s=arguments.length-2;if(1===s)a.children=r;else if(1<s){u=Array(s);for(var c=0;c<s;c++)u[c]=arguments[c+2];a.children=u}return{$$typeof:n,type:e.type,key:o,ref:l,props:a,_owner:i}},t.createContext=function(e){return(e={$$typeof:u,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null}).Provider={$$typeof:i,_context:e},e.Consumer=e},t.createElement=k,t.createFactory=function(e){var t=k.bind(null,e);return t.type=e,t},t.createRef=function(){return{current:null}},t.forwardRef=function(e){return{$$typeof:s,render:e}},t.isValidElement=C,t.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:N}},t.memo=function(e,t){return{$$typeof:p,type:e,compare:void 0===t?null:t}},t.startTransition=function(e){var t=R.transition;R.transition={};try{e()}finally{R.transition=t}},t.unstable_act=function(){throw Error("act(...) is not supported in production builds of React.")},t.useCallback=function(e,t){return M.current.useCallback(e,t)},t.useContext=function(e){return M.current.useContext(e)},t.useDebugValue=function(){},t.useDeferredValue=function(e){return M.current.useDeferredValue(e)},t.useEffect=function(e,t){return M.current.useEffect(e,t)},t.useId=function(){return M.current.useId()},t.useImperativeHandle=function(e,t,n){return M.current.useImperativeHandle(e,t,n)},t.useInsertionEffect=function(e,t){return M.current.useInsertionEffect(e,t)},t.useLayoutEffect=function(e,t){return M.current.useLayoutEffect(e,t)},t.useMemo=function(e,t){return M.current.useMemo(e,t)},t.useReducer=function(e,t,n){return M.current.useReducer(e,t,n)},t.useRef=function(e){return M.current.useRef(e)},t.useState=function(e){return M.current.useState(e)},t.useSyncExternalStore=function(e,t,n){return M.current.useSyncExternalStore(e,t,n)},t.useTransition=function(){return M.current.useTransition()},t.version="18.2.0"},7294:(e,t,n)=>{"use strict";e.exports=n(2408)},7478:(e,t,n)=>{"use strict";var r=n(210),a=n(1924),o=n(631),l=r("%TypeError%"),i=r("%WeakMap%",!0),u=r("%Map%",!0),s=a("WeakMap.prototype.get",!0),c=a("WeakMap.prototype.set",!0),p=a("WeakMap.prototype.has",!0),d=a("Map.prototype.get",!0),f=a("Map.prototype.set",!0),h=a("Map.prototype.has",!0),m=function(e,t){for(var n,r=e;null!==(n=r.next);r=n)if(n.key===t)return r.next=n.next,n.next=e.next,e.next=n,n};e.exports=function(){var e,t,n,r={assert:function(e){if(!r.has(e))throw new l("Side channel does not contain "+o(e))},get:function(r){if(i&&r&&("object"==typeof r||"function"==typeof r)){if(e)return s(e,r)}else if(u){if(t)return d(t,r)}else if(n)return function(e,t){var n=m(e,t);return n&&n.value}(n,r)},has:function(r){if(i&&r&&("object"==typeof r||"function"==typeof r)){if(e)return p(e,r)}else if(u){if(t)return h(t,r)}else if(n)return function(e,t){return!!m(e,t)}(n,r);return!1},set:function(r,a){i&&r&&("object"==typeof r||"function"==typeof r)?(e||(e=new i),c(e,r,a)):u?(t||(t=new u),f(t,r,a)):(n||(n={key:{},next:null}),function(e,t,n){var r=m(e,t);r?r.value=n:e.next={key:t,next:e.next,value:n}}(n,r,a))}};return r}},1742:e=>{e.exports=function(){var e=document.getSelection();if(!e.rangeCount)return function(){};for(var t=document.activeElement,n=[],r=0;r<e.rangeCount;r++)n.push(e.getRangeAt(r));switch(t.tagName.toUpperCase()){case"INPUT":case"TEXTAREA":t.blur();break;default:t=null}return e.removeAllRanges(),function(){"Caret"===e.type&&e.removeAllRanges(),e.rangeCount||n.forEach((function(t){e.addRange(t)})),t&&t.focus()}}},3250:(e,t,n)=>{"use strict";var r=n(7294),a="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},o=r.useState,l=r.useEffect,i=r.useLayoutEffect,u=r.useDebugValue;function s(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!a(e,n)}catch(e){return!0}}var c="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(e,t){return t()}:function(e,t){var n=t(),r=o({inst:{value:n,getSnapshot:t}}),a=r[0].inst,c=r[1];return i((function(){a.value=n,a.getSnapshot=t,s(a)&&c({inst:a})}),[e,n,t]),l((function(){return s(a)&&c({inst:a}),e((function(){s(a)&&c({inst:a})}))}),[e]),u(n),n};t.useSyncExternalStore=void 0!==r.useSyncExternalStore?r.useSyncExternalStore:c},139:(e,t,n)=>{"use strict";var r=n(7294),a=n(1688),o="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},l=a.useSyncExternalStore,i=r.useRef,u=r.useEffect,s=r.useMemo,c=r.useDebugValue;t.useSyncExternalStoreWithSelector=function(e,t,n,r,a){var p=i(null);if(null===p.current){var d={hasValue:!1,value:null};p.current=d}else d=p.current;p=s((function(){function e(e){if(!u){if(u=!0,l=e,e=r(e),void 0!==a&&d.hasValue){var t=d.value;if(a(t,e))return i=t}return i=e}if(t=i,o(l,e))return t;var n=r(e);return void 0!==a&&a(t,n)?t:(l=e,i=n)}var l,i,u=!1,s=void 0===n?null:n;return[function(){return e(t())},null===s?void 0:function(){return e(s())}]}),[t,n,r,a]);var f=l(e,p[0],p[1]);return u((function(){d.hasValue=!0,d.value=f}),[f]),c(f),f}},1688:(e,t,n)=>{"use strict";e.exports=n(3250)},2798:(e,t,n)=>{"use strict";e.exports=n(139)},2473:e=>{"use strict";e.exports=function(){}},3679:(e,t,n)=>{"use strict";var r=n(9981),a=n(4578),o=n(6814),l=n(2636),i=n(3376);e.exports=function(e){return null==e||"object"!=typeof e&&"function"!=typeof e?null:r(e)?"String":a(e)?"Number":o(e)?"Boolean":l(e)?"Symbol":i(e)?"BigInt":void 0}},6430:(e,t,n)=>{"use strict";var r=n(9804),a=n(3083),o=n(1924),l=o("Object.prototype.toString"),i=n(6410)(),u="undefined"==typeof globalThis?n.g:globalThis,s=a(),c=o("String.prototype.slice"),p={},d=n(882),f=Object.getPrototypeOf;i&&d&&f&&r(s,(function(e){if("function"==typeof u[e]){var t=new u[e];if(Symbol.toStringTag in t){var n=f(t),r=d(n,Symbol.toStringTag);if(!r){var a=f(n);r=d(a,Symbol.toStringTag)}p[e]=r.get}}}));var h=n(5692);e.exports=function(e){return!!h(e)&&(i&&Symbol.toStringTag in e?function(e){var t=!1;return r(p,(function(n,r){if(!t)try{var a=n.call(e);a===r&&(t=a)}catch(e){}})),t}(e):c(l(e),8,-1))}},4654:()=>{},3083:(e,t,n)=>{"use strict";var r=["BigInt64Array","BigUint64Array","Float32Array","Float64Array","Int16Array","Int32Array","Int8Array","Uint16Array","Uint32Array","Uint8Array","Uint8ClampedArray"],a="undefined"==typeof globalThis?n.g:globalThis;e.exports=function(){for(var e=[],t=0;t<r.length;t++)"function"==typeof a[r[t]]&&(e[e.length]=r[t]);return e}},882:(e,t,n)=>{"use strict";var r=n(210)("%Object.getOwnPropertyDescriptor%",!0);if(r)try{r([],"length")}catch(e){r=null}e.exports=r},3216:(e,t,n)=>{"use strict";var r=n(2584);if(n(1405)()||n(5419)()){var a=Symbol.iterator;e.exports=function(e){return null!=e&&void 0!==e[a]?e[a]():r(e)?Array.prototype[a].call(e):void 0}}else{var o=n(5677),l=n(9981),i=n(210),u=i("%Map%",!0),s=i("%Set%",!0),c=n(1924),p=c("Array.prototype.push"),d=c("String.prototype.charCodeAt"),f=c("String.prototype.slice"),h=function(e){var t=0;return{next:function(){var n,r=t>=e.length;return r||(n=e[t],t+=1),{done:r,value:n}}}},m=function(e,t){if(o(e)||r(e))return h(e);if(l(e)){var n=0;return{next:function(){var t=function(e,t){if(t+1>=e.length)return t+1;var n=d(e,t);if(n<55296||n>56319)return t+1;var r=d(e,t+1);return r<56320||r>57343?t+1:t+2}(e,n),r=f(e,n,t);return n=t,{done:t>e.length,value:r}}}}return t&&void 0!==e["_es6-shim iterator_"]?e["_es6-shim iterator_"]():void 0};if(u||s){var g=n(8379),y=n(9572),v=c("Map.prototype.forEach",!0),b=c("Set.prototype.forEach",!0);if("undefined"==typeof process||!process.versions||!process.versions.node)var w=c("Map.prototype.iterator",!0),E=c("Set.prototype.iterator",!0),_=function(e){var t=!1;return{next:function(){try{return{done:t,value:t?void 0:e.next()}}catch(e){return t=!0,{done:!0,value:void 0}}}}};var x=c("Map.prototype.@@iterator",!0)||c("Map.prototype._es6-shim iterator_",!0),S=c("Set.prototype.@@iterator",!0)||c("Set.prototype._es6-shim iterator_",!0);e.exports=function(e){return function(e){if(g(e)){if(w)return _(w(e));if(x)return x(e);if(v){var t=[];return v(e,(function(e,n){p(t,[n,e])})),h(t)}}if(y(e)){if(E)return _(E(e));if(S)return S(e);if(b){var n=[];return b(e,(function(e){p(n,e)})),h(n)}}}(e)||m(e)}}else e.exports=function(e){if(null!=e)return m(e,!0)}}},3483:(e,t,n)=>{"use strict";var r=n(8379),a=n(9572),o=n(1718),l=n(5899);e.exports=function(e){if(e&&"object"==typeof e){if(r(e))return"Map";if(a(e))return"Set";if(o(e))return"WeakMap";if(l(e))return"WeakSet"}return!1}}},n={};function r(e){var a=n[e];if(void 0!==a)return a.exports;var o=n[e]={exports:{}};return t[e].call(o.exports,o,o.exports,r),o.exports}r.m=t,e=[],r.O=(t,n,a,o)=>{if(!n){var l=1/0;for(c=0;c<e.length;c++){for(var[n,a,o]=e[c],i=!0,u=0;u<n.length;u++)(!1&o||l>=o)&&Object.keys(r.O).every((e=>r.O[e](n[u])))?n.splice(u--,1):(i=!1,o<l&&(l=o));if(i){e.splice(c--,1);var s=a();void 0!==s&&(t=s)}}return t}o=o||0;for(var c=e.length;c>0&&e[c-1][2]>o;c--)e[c]=e[c-1];e[c]=[n,a,o]},r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e={826:0,431:0};r.O.j=t=>0===e[t];var t=(t,n)=>{var a,o,[l,i,u]=n,s=0;if(l.some((t=>0!==e[t]))){for(a in i)r.o(i,a)&&(r.m[a]=i[a]);if(u)var c=u(r)}for(t&&t(n);s<l.length;s++)o=l[s],r.o(e,o)&&e[o]&&e[o][0](),e[o]=0;return r.O(c)},n=globalThis.webpackChunksearch_regex=globalThis.webpackChunksearch_regex||[];n.forEach(t.bind(null,0)),n.push=t.bind(null,n.push.bind(n))})();var a=r.O(void 0,[431],(()=>r(2598)));a=r.O(a)})();
build/search-regex.js.LICENSE.txt ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ object-assign
3
+ (c) Sindre Sorhus
4
+ @license MIT
5
+ */
6
+
7
+ /*
8
+ object-assign
9
+ (c) Sindre Sorhus
10
+ @license MIT
11
+ */
12
+
13
+ /*!
14
+ Copyright (c) 2018 Jed Watson.
15
+ Licensed under the MIT License (MIT), see
16
+ http://jedwatson.github.io/classnames
17
+ */
18
+
19
+ /*! *****************************************************************************
20
+ Copyright (c) Microsoft Corporation. All rights reserved.
21
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
22
+ this file except in compliance with the License. You may obtain a copy of the
23
+ License at http://www.apache.org/licenses/LICENSE-2.0
24
+
25
+ THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
26
+ KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
27
+ WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
28
+ MERCHANTABLITY OR NON-INFRINGEMENT.
29
+
30
+ See the Apache Version 2.0 License for specific language governing permissions
31
+ and limitations under the License.
32
+ ***************************************************************************** */
33
+
34
+ /**
35
+ * @license React
36
+ * react-dom.production.min.js
37
+ *
38
+ * Copyright (c) Facebook, Inc. and its affiliates.
39
+ *
40
+ * This source code is licensed under the MIT license found in the
41
+ * LICENSE file in the root directory of this source tree.
42
+ */
43
+
44
+ /**
45
+ * @license React
46
+ * react-is.production.min.js
47
+ *
48
+ * Copyright (c) Facebook, Inc. and its affiliates.
49
+ *
50
+ * This source code is licensed under the MIT license found in the
51
+ * LICENSE file in the root directory of this source tree.
52
+ */
53
+
54
+ /**
55
+ * @license React
56
+ * react.production.min.js
57
+ *
58
+ * Copyright (c) Facebook, Inc. and its affiliates.
59
+ *
60
+ * This source code is licensed under the MIT license found in the
61
+ * LICENSE file in the root directory of this source tree.
62
+ */
63
+
64
+ /**
65
+ * @license React
66
+ * scheduler.production.min.js
67
+ *
68
+ * Copyright (c) Facebook, Inc. and its affiliates.
69
+ *
70
+ * This source code is licensed under the MIT license found in the
71
+ * LICENSE file in the root directory of this source tree.
72
+ */
73
+
74
+ /**
75
+ * @license React
76
+ * use-sync-external-store-shim.production.min.js
77
+ *
78
+ * Copyright (c) Facebook, Inc. and its affiliates.
79
+ *
80
+ * This source code is licensed under the MIT license found in the
81
+ * LICENSE file in the root directory of this source tree.
82
+ */
83
+
84
+ /**
85
+ * @license React
86
+ * use-sync-external-store-shim/with-selector.production.min.js
87
+ *
88
+ * Copyright (c) Facebook, Inc. and its affiliates.
89
+ *
90
+ * This source code is licensed under the MIT license found in the
91
+ * LICENSE file in the root directory of this source tree.
92
+ */
93
+
94
+ /** @license React v16.13.1
95
+ * react-is.production.min.js
96
+ *
97
+ * Copyright (c) Facebook, Inc. and its affiliates.
98
+ *
99
+ * This source code is licensed under the MIT license found in the
100
+ * LICENSE file in the root directory of this source tree.
101
+ */
102
+
103
+ /** @license React v17.0.2
104
+ * react.production.min.js
105
+ *
106
+ * Copyright (c) Facebook, Inc. and its affiliates.
107
+ *
108
+ * This source code is licensed under the MIT license found in the
109
+ * LICENSE file in the root directory of this source tree.
110
+ */
includes/action/action-delete.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Action\Type;
4
+
5
+ use SearchRegex\Action\Action;
6
+ use SearchRegex\Source;
7
+ use SearchRegex\Plugin;
8
+
9
+ /**
10
+ * Action to delete rows
11
+ */
12
+ class Delete extends Action {
13
+ /**
14
+ * Track how many rows have been deleted
15
+ *
16
+ * @var integer
17
+ */
18
+ private $deleted = 0;
19
+
20
+ public function to_json() {
21
+ return [
22
+ 'action' => 'delete',
23
+ ];
24
+ }
25
+
26
+ public function perform( $row_id, array $row, Source\Source $source, array $columns ) {
27
+ if ( $this->should_save() ) {
28
+ $this->deleted++;
29
+
30
+ $this->log_action( 'Delete: ' . $source->get_table_name() . ' row ' . (string) $row_id );
31
+
32
+ /** @psalm-suppress UndefinedFunction */
33
+ if ( Plugin\Settings::init()->can_save() ) {
34
+ $source->delete_row( $row_id );
35
+ }
36
+ }
37
+
38
+ return $columns;
39
+ }
40
+ }
includes/action/action-export.php ADDED
@@ -0,0 +1,163 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Action\Type;
4
+
5
+ use SearchRegex\Sql;
6
+ use SearchRegex\Action;
7
+ use SearchRegex\Schema;
8
+ use SearchRegex\Search;
9
+
10
+ class Export extends Action\Action {
11
+ const ALLOWED_FORMATS = [ 'json', 'csv', 'sql' ];
12
+
13
+ /**
14
+ * Export format
15
+ *
16
+ * @var string
17
+ */
18
+ private $format = 'json';
19
+
20
+ /**
21
+ * Table being exported
22
+ *
23
+ * @var string
24
+ */
25
+ private $table = 'table';
26
+
27
+ /**
28
+ * Export only the selected columns
29
+ *
30
+ * @var boolean
31
+ */
32
+ private $selected_only = false;
33
+
34
+ /**
35
+ * Constructor
36
+ *
37
+ * @param array|string $options Options.
38
+ * @param Schema\Schema $schema Schema.
39
+ */
40
+ public function __construct( $options, Schema\Schema $schema ) {
41
+ if ( isset( $options['format'] ) && in_array( $options['format'], self::ALLOWED_FORMATS, true ) ) {
42
+ $this->format = $options['format'];
43
+ }
44
+
45
+ if ( isset( $options['selectedOnly'] ) && $options['selectedOnly'] ) {
46
+ $this->selected_only = true;
47
+ }
48
+
49
+ parent::__construct( $options, $schema );
50
+ }
51
+
52
+ public function to_json() {
53
+ return [
54
+ 'action' => 'export',
55
+ 'actionOption' => [
56
+ 'format' => $this->format,
57
+ 'selectedOnly' => $this->selected_only,
58
+ ],
59
+ ];
60
+ }
61
+
62
+ public function get_view_columns() {
63
+ if ( ! $this->selected_only ) {
64
+ return array_map( function( $column ) {
65
+ return $this->schema->get_type() . '__' . $column->get_column();
66
+ }, $this->schema->get_columns() );
67
+ }
68
+
69
+ return [];
70
+ }
71
+
72
+ public function should_save() {
73
+ return false;
74
+ }
75
+
76
+ public function get_results( array $results ) {
77
+ if ( ! $this->save ) {
78
+ return parent::get_results( $results );
79
+ }
80
+
81
+ // Convert to whatever the chosen format is
82
+ $results['results'] = array_map( function( $item ) {
83
+ if ( $this->format === 'json' ) {
84
+ return $this->convert_to_json( $item );
85
+ } elseif ( $this->format === 'csv' ) {
86
+ return $this->convert_to_csv( $item );
87
+ } elseif ( $this->format === 'sql' ) {
88
+ return $this->convert_to_sql( $item );
89
+ }
90
+
91
+ return $item;
92
+ }, $results['results'] );
93
+
94
+ return $results;
95
+ }
96
+
97
+ /**
98
+ * Convert Result to JSON
99
+ *
100
+ * @param Search\Result $result Result.
101
+ * @return string
102
+ */
103
+ private function convert_to_json( Search\Result $result ) {
104
+ $data = [];
105
+
106
+ foreach ( $result->get_columns() as $column ) {
107
+ $data[ Sql\Value::column( $column->get_column_id() )->get_value() ] = $column->get_value();
108
+ }
109
+
110
+ return $data;
111
+ }
112
+
113
+ /**
114
+ * Convert Result to SQL
115
+ *
116
+ * @param Search\Result $result Result.
117
+ * @return string
118
+ */
119
+ private function convert_to_sql( Search\Result $result ) {
120
+ $values = array_map( function( $column ) {
121
+ global $wpdb;
122
+
123
+ $column_schema = $this->schema->get_column( $column->get_column_id() );
124
+
125
+ if ( $column_schema && $column_schema->get_type() === 'integer' ) {
126
+ return $wpdb->prepare( '%d', $column->get_value() );
127
+ }
128
+
129
+ return $wpdb->prepare( '%s', $column->get_value() );
130
+ }, $result->get_columns() );
131
+
132
+ $names = array_map( function( $column ) {
133
+ return Sql\Value::column( $column->get_column_id() )->get_value();
134
+ }, $result->get_columns() );
135
+
136
+ return "INSERT INTO {$this->schema->get_table()} (" . implode( ', ', $names ) . ') VALUES(' . implode( ', ', $values ) . ');';
137
+ }
138
+
139
+ /**
140
+ * Convert a Result to CSV
141
+ *
142
+ * @param Search\Result $result Result.
143
+ * @return string
144
+ */
145
+ private function convert_to_csv( Search\Result $result ) {
146
+ $csv = array_map( function( $column ) {
147
+ return $column->get_value();
148
+ }, $result->get_columns() );
149
+
150
+ // phpcs:ignore
151
+ $handle = fopen( 'php://memory', 'r+' );
152
+
153
+ fputcsv( $handle, $csv );
154
+ rewind( $handle );
155
+
156
+ $result = stream_get_contents( $handle );
157
+
158
+ // phpcs:ignore
159
+ fclose( $handle );
160
+
161
+ return trim( $result );
162
+ }
163
+ }
includes/action/action-global-replace.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Action\Type;
4
+
5
+ use SearchRegex\Schema;
6
+
7
+ /**
8
+ * Global replace. This emulates the previous searchregex
9
+ */
10
+ class Global_Replace extends Modify {
11
+ /**
12
+ * Constructor
13
+ *
14
+ * @param array|string $options Options.
15
+ * @param Schema\Schema $schema Schema.
16
+ */
17
+ public function __construct( $options, Schema\Schema $schema ) {
18
+ $converted = [];
19
+
20
+ if ( is_array( $options ) ) {
21
+ foreach ( $schema->get_sources() as $source ) {
22
+ foreach ( $source->get_global_columns() as $column ) {
23
+ $converted[] = [
24
+ 'column' => $column->get_column(),
25
+ 'source' => $source->get_type(),
26
+ 'operation' => 'replace',
27
+ 'searchValue' => $options['search'],
28
+ 'replaceValue' => $options['replacement'],
29
+ 'searchFlags' => $options['flags'],
30
+ ];
31
+ }
32
+ }
33
+ }
34
+
35
+ parent::__construct( $converted, $schema );
36
+ }
37
+
38
+ public function to_json() {
39
+ return [
40
+ 'action' => 'replace',
41
+ 'actionOption' => [],
42
+ ];
43
+ }
44
+ }
includes/action/action-modify.php ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Action\Type;
4
+
5
+ use SearchRegex\Action;
6
+ use SearchRegex\Source;
7
+ use SearchRegex\Schema;
8
+ use SearchRegex\Modifier;
9
+
10
+ /**
11
+ * Perform modification of columns
12
+ */
13
+ class Modify extends Action\Action {
14
+ /**
15
+ * Columns that are to be modified
16
+ *
17
+ * @var Modifier[]
18
+ */
19
+ private $columns = [];
20
+
21
+ /**
22
+ * Dynamic shortcode handler
23
+ *
24
+ * @var Dynamic_Column|null
25
+ */
26
+ private $dynamic_column = null;
27
+
28
+ /**
29
+ * Constructor
30
+ *
31
+ * @param array|string $options Options.
32
+ * @param Schema\Schema $schema Schema.
33
+ */
34
+ public function __construct( $options, Schema\Schema $schema ) {
35
+ if ( is_array( $options ) ) {
36
+ foreach ( $options as $option ) {
37
+ $source_schema = $schema->get_for_source( isset( $option['source'] ) ? $option['source'] : '' );
38
+
39
+ if ( $source_schema ) {
40
+ $column = Modifier\Modifier::create( $option, $source_schema );
41
+
42
+ if ( $column && $column->is_valid() ) {
43
+ $this->columns[] = $column;
44
+ }
45
+ }
46
+ }
47
+ }
48
+
49
+ if ( count( $this->columns ) > 0 ) {
50
+ $this->dynamic_column = new Action\Dynamic_Column();
51
+ }
52
+
53
+ parent::__construct( $options, $schema );
54
+ }
55
+
56
+ public function get_view_columns() {
57
+ /** @psalm-suppress UnusedClosureParam */
58
+ $remember = function( $return, $tag, $attr ) {
59
+ if ( $tag === 'column' ) {
60
+ if ( isset( $attr['name'] ) ) {
61
+ return 'column::' . $attr['name'] . ' ';
62
+ } elseif ( isset( $attr[0] ) ) {
63
+ return 'column::' . $attr[0] . ' ';
64
+ }
65
+ }
66
+
67
+ return '';
68
+ };
69
+
70
+ add_filter( 'pre_do_shortcode_tag', $remember, 10, 4 );
71
+
72
+ $views = array_map( function( $column ) {
73
+ if ( ! $column instanceof Modifier\Modify_String ) {
74
+ return false;
75
+ }
76
+
77
+ $replace = $column->get_replace_value();
78
+ if ( $replace === null ) {
79
+ return false;
80
+ }
81
+
82
+ if ( has_shortcode( $replace, 'column' ) ) {
83
+ $result = do_shortcode( $replace );
84
+
85
+ if ( preg_match_all( '/column::(.*?)\s/', $result, $matches ) > 0 ) {
86
+ foreach ( $matches[1] as $match ) {
87
+ return $column->get_schema()->get_source() . '__' . $match;
88
+ }
89
+ }
90
+ }
91
+
92
+ return false;
93
+ }, $this->columns );
94
+
95
+ /** @psalm-suppress TooManyArguments */
96
+ remove_filter( 'pre_do_shortcode_tag', $remember, 10, 4 );
97
+
98
+ $modify = array_map( function( $column ) {
99
+ return $column->get_source_name() . '__' . $column->get_column_name();
100
+ }, $this->columns );
101
+
102
+ return array_values( array_filter( array_merge( $views, $modify ) ) );
103
+ }
104
+
105
+ public function to_json() {
106
+ return [
107
+ 'action' => 'modify',
108
+ 'actionOption' => array_map( function( $column ) {
109
+ return $column->to_json();
110
+ }, $this->columns ),
111
+ ];
112
+ }
113
+
114
+ public function perform( $row_id, array $row, Source\Source $source, array $columns ) {
115
+ foreach ( $columns as $pos => $column ) {
116
+ foreach ( $this->columns as $action_column ) {
117
+ if ( $source->is_type( $action_column->get_source_name() ) && $action_column->is_for_column( $column->get_column_id() ) ) {
118
+ $value = $action_column->get_row_data( $row );
119
+
120
+ if ( $value ) {
121
+ $columns[ $pos ] = $action_column->perform( $row_id, $value, $source, $column, $row, $this->should_save() );
122
+ }
123
+
124
+ break;
125
+ }
126
+ }
127
+ }
128
+
129
+ return $columns;
130
+ }
131
+ }
includes/action/action-nothing.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Action\Type;
4
+
5
+ use SearchRegex\Action\Action;
6
+
7
+ /**
8
+ * Action to do nothing.
9
+ */
10
+ class Nothing extends Action {
11
+ public function __construct() {
12
+ }
13
+
14
+ public function to_json() {
15
+ return [
16
+ 'action' => 'nothing',
17
+ ];
18
+ }
19
+ }
includes/action/action-run.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Action\Type;
4
+
5
+ use SearchRegex\Sql;
6
+ use SearchRegex\Action\Action;
7
+ use SearchRegex\Schema;
8
+ use SearchRegex\Source;
9
+
10
+ class Run extends Action {
11
+ /**
12
+ * Hook name
13
+ *
14
+ * @var string|false
15
+ */
16
+ private $hook = false;
17
+
18
+ /**
19
+ * Constructor
20
+ *
21
+ * @param array|string $options Options.
22
+ * @param Schema\Schema $schema Schema.
23
+ */
24
+ public function __construct( $options, Schema\Schema $schema ) {
25
+ if ( is_array( $options ) && isset( $options['hook'] ) && has_action( $options['hook'] ) ) {
26
+ $this->hook = preg_replace( '/[A-Za-z0-9_-]/', '', $options['hook'] );
27
+ }
28
+
29
+ parent::__construct( $options, $schema );
30
+ }
31
+
32
+ public function to_json() {
33
+ return [
34
+ 'action' => 'action',
35
+ 'actionOption' => [
36
+ 'hook' => $this->hook,
37
+ ],
38
+ ];
39
+ }
40
+
41
+ public function should_save() {
42
+ return false;
43
+ }
44
+
45
+ public function perform( $row_id, array $row, Source\Source $source, array $columns ) {
46
+ if ( ! $this->hook || ! $this->should_save() ) {
47
+ return $columns;
48
+ }
49
+
50
+ do_action( $this->hook, $row, $row_id, $source, $columns );
51
+
52
+ return $columns;
53
+ }
54
+ }
includes/action/class-action.php ADDED
@@ -0,0 +1,171 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Action;
4
+
5
+ use SearchRegex\Sql;
6
+ use SearchRegex\Action\Type;
7
+ use SearchRegex\Schema;
8
+ use SearchRegex\Source;
9
+
10
+ require_once __DIR__ . '/action-nothing.php';
11
+ require_once __DIR__ . '/action-modify.php';
12
+ require_once __DIR__ . '/action-delete.php';
13
+ require_once __DIR__ . '/action-export.php';
14
+ require_once __DIR__ . '/action-run.php';
15
+ require_once __DIR__ . '/action-global-replace.php';
16
+ require_once __DIR__ . '/class-dynamic-column.php';
17
+
18
+ /**
19
+ * Perform an action on a result
20
+ */
21
+ abstract class Action {
22
+ /**
23
+ * Schema
24
+ *
25
+ * @var Schema\Source
26
+ */
27
+ protected $schema;
28
+
29
+ /**
30
+ * Should this action save data to the database?
31
+ *
32
+ * @var boolean
33
+ */
34
+ protected $save = false;
35
+
36
+ /**
37
+ * Constructor
38
+ *
39
+ * @param array|string $options Options.
40
+ * @param Schema\Schema $schema Schema.
41
+ */
42
+ public function __construct( $options, Schema\Schema $schema ) {
43
+ // Always the first one
44
+ $this->schema = $schema->get_sources()[0];
45
+ }
46
+
47
+ /**
48
+ * Create an action
49
+ *
50
+ * @param string $action_type Type of action.
51
+ * @param array|string $action_options Array of action options.
52
+ * @param Schema\Schema $schema Schema for all sources.
53
+ * @return Action
54
+ */
55
+ public static function create( $action_type, $action_options, Schema\Schema $schema ) {
56
+ if ( $action_type === 'modify' && is_array( $action_options ) ) {
57
+ return new Type\Modify( $action_options, $schema );
58
+ } elseif ( $action_type === 'replace' ) {
59
+ return new Type\Global_Replace( $action_options, $schema );
60
+ } elseif ( $action_type === 'delete' ) {
61
+ return new Type\Delete( $action_options, $schema );
62
+ } elseif ( $action_type === 'export' ) {
63
+ return new Type\Export( $action_options, $schema );
64
+ } elseif ( $action_type === 'action' ) {
65
+ return new Type\Run( $action_options, $schema );
66
+ }
67
+
68
+ return new Type\Nothing( $action_options, $schema );
69
+ }
70
+
71
+ /**
72
+ * Convert action to JSON
73
+ *
74
+ * @return array
75
+ */
76
+ abstract public function to_json();
77
+
78
+ /**
79
+ * Perform the action
80
+ *
81
+ * @param integer $row_id Row ID.
82
+ * @param array $row Data for row.
83
+ * @param Source\Source $source Source.
84
+ * @param array<Search\Column> $columns Contexts.
85
+ * @return array<Search\Column>|\WP_Error
86
+ */
87
+ public function perform( $row_id, array $row, Source\Source $source, array $columns ) {
88
+ return $columns;
89
+ }
90
+
91
+ /**
92
+ * Get the results from the action.
93
+ *
94
+ * @param array $results Results.
95
+ * @return array
96
+ */
97
+ public function get_results( array $results ) {
98
+ $json = [];
99
+
100
+ foreach ( $results['results'] as $result ) {
101
+ $json[] = $result->to_json();
102
+ }
103
+
104
+ $results['results'] = $json;
105
+
106
+ return $results;
107
+ }
108
+
109
+ /**
110
+ * Change the save mode
111
+ *
112
+ * @param boolean $mode Save.
113
+ * @return void
114
+ */
115
+ public function set_save_mode( $mode ) {
116
+ $this->save = $mode;
117
+ }
118
+
119
+ /**
120
+ * Get any columns we need to view for this action.
121
+ *
122
+ * @return list<string>
123
+ */
124
+ public function get_view_columns() {
125
+ return [];
126
+ }
127
+
128
+ /**
129
+ * Should this action save to the database?
130
+ *
131
+ * @return boolean
132
+ */
133
+ public function should_save() {
134
+ return $this->save;
135
+ }
136
+
137
+ /**
138
+ * Debug helper function. Logs an action.
139
+ *
140
+ * @param string $title Log title.
141
+ * @return void
142
+ */
143
+ protected function log_action( $title ) {
144
+ if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
145
+ // phpcs:ignore
146
+ error_log( $title );
147
+ }
148
+ }
149
+
150
+ /**
151
+ * Get the action options
152
+ *
153
+ * @param string|array $options Options.
154
+ * @return array
155
+ */
156
+ public static function get_options( $options ) {
157
+ if ( ! is_array( $options ) ) {
158
+ return [];
159
+ }
160
+
161
+ if ( isset( $options['action'] ) && $options['action'] === 'replace' ) {
162
+ return [
163
+ 'search' => $options['searchPhrase'],
164
+ 'replacement' => $options['replacement'],
165
+ 'flags' => $options['searchFlags'],
166
+ ];
167
+ }
168
+
169
+ return isset( $options['actionOption'] ) ? $options['actionOption'] : [];
170
+ }
171
+ }
includes/action/class-dynamic-column.php ADDED
@@ -0,0 +1,242 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Action;
4
+
5
+ use SearchRegex\Sql;
6
+ use SearchRegex\Schema;
7
+ use SearchRegex\Source;
8
+
9
+ /**
10
+ * Dynamic data in columns (via shortcodes)
11
+ */
12
+ class Dynamic_Column {
13
+ const LOOP_MAX = 10;
14
+
15
+ /**
16
+ * Array of supported shortcodes
17
+ *
18
+ * @var string[]
19
+ */
20
+ private $shortcodes;
21
+
22
+ /**
23
+ * Array of standard WP shortcodes
24
+ *
25
+ * @var string[]
26
+ */
27
+ private $old_shortcodes = [];
28
+
29
+ /**
30
+ * Row ID
31
+ *
32
+ * @var integer
33
+ */
34
+ private $row_id = 0;
35
+
36
+ /**
37
+ * Row value
38
+ *
39
+ * @var string
40
+ */
41
+ private $row_value = '';
42
+
43
+ /**
44
+ * Raw row data
45
+ *
46
+ * @var string[]
47
+ */
48
+ private $raw = [];
49
+
50
+ /**
51
+ * Source schema
52
+ *
53
+ * @var Schema\Source|null
54
+ */
55
+ private $schema = null;
56
+
57
+ /**
58
+ * Recursion level protection
59
+ *
60
+ * @var integer
61
+ */
62
+ private $level = 0;
63
+
64
+ public function __construct() {
65
+ add_filter( 'searchregex_text', [ $this, 'replace_text' ], 10, 5 );
66
+
67
+ $this->shortcodes = apply_filters( 'searchregex_shortcodes', [
68
+ 'md5',
69
+ 'upper',
70
+ 'lower',
71
+ 'dashes',
72
+ 'underscores',
73
+ 'column',
74
+ 'value',
75
+ 'date',
76
+ ] );
77
+
78
+ global $shortcode_tags;
79
+
80
+ $this->old_shortcodes = array_merge( [], $shortcode_tags );
81
+
82
+ remove_all_shortcodes();
83
+
84
+ foreach ( $this->shortcodes as $code ) {
85
+ add_shortcode( $code, [ $this, 'do_shortcode' ] );
86
+ }
87
+ }
88
+
89
+ public function __destruct() {
90
+ /** @psalm-suppress all */
91
+ global $shortcode_tags;
92
+
93
+ // Restore shortcodes
94
+ // phpcs:ignore
95
+ $shortcode_tags = array_merge( [], $this->old_shortcodes );
96
+ }
97
+
98
+ /**
99
+ * Replace shortcodes in a value
100
+ *
101
+ * @param string $text Replacement text, including shortcodes.
102
+ * @param integer $row_id Row ID.
103
+ * @param string $row_value Row value.
104
+ * @param string[] $raw Raw row data.
105
+ * @param Schema\Source $schema Schema.
106
+ * @return string
107
+ */
108
+ public function replace_text( $text, $row_id, $row_value, array $raw, Schema\Source $schema ) {
109
+ // Keep track of these in the object
110
+ $this->row_id = $row_id;
111
+ $this->row_value = $row_value;
112
+ $this->raw = $raw;
113
+ $this->level = 0;
114
+ $this->schema = $schema;
115
+
116
+ return do_shortcode( $text );
117
+ }
118
+
119
+ /**
120
+ * Peform a shortcode
121
+ *
122
+ * @param array $attrs Shortcode attributes.
123
+ * @param string $content Shortcode content.
124
+ * @param string $tag Shortcode tag.
125
+ * @return string
126
+ */
127
+ public function do_shortcode( $attrs, $content, $tag ) {
128
+ if ( $this->schema === null ) {
129
+ return '';
130
+ }
131
+
132
+ $this->level++;
133
+ if ( $this->level > self::LOOP_MAX ) {
134
+ return '';
135
+ }
136
+
137
+ switch ( $tag ) {
138
+ case 'md5':
139
+ return md5( do_shortcode( $content ) );
140
+
141
+ case 'upper':
142
+ return strtoupper( do_shortcode( $content ) );
143
+
144
+ case 'lower':
145
+ return strtolower( do_shortcode( $content ) );
146
+
147
+ case 'dashes':
148
+ return str_replace( [ '_', ' ' ], '-', do_shortcode( $content ) );
149
+
150
+ case 'underscores':
151
+ return str_replace( [ '-', ' ' ], '_', do_shortcode( $content ) );
152
+
153
+ case 'date':
154
+ return date( isset( $attrs['format'] ) ? $attrs['format'] : 'r' );
155
+
156
+ case 'value':
157
+ return $this->row_value;
158
+
159
+ case 'column':
160
+ $name = '';
161
+
162
+ if ( isset( $attrs['name'] ) ) {
163
+ $name = $attrs['name'];
164
+ } elseif ( isset( $attrs[0] ) ) {
165
+ $name = $attrs[0];
166
+ }
167
+
168
+ if ( $name && isset( $this->raw[ $name ] ) ) {
169
+ $schema = $this->schema->get_column( $name );
170
+
171
+ if ( $schema ) {
172
+ return $this->get_schema_value( $schema, $attrs, $this->raw[ $name ] );
173
+ }
174
+
175
+ return $this->raw[ $name ];
176
+ }
177
+
178
+ $schema = $this->schema->get_column( $name );
179
+ if ( $schema && $schema->get_join_column() ) {
180
+ return $this->get_schema_join( $schema, $this->row_id, $attrs );
181
+ }
182
+
183
+ return '';
184
+ }
185
+
186
+ /**
187
+ * @psalm-suppress TooManyArguments
188
+ */
189
+ return apply_filters( 'searchregex_do_shortcode', '', $tag, $attrs, $content );
190
+ }
191
+
192
+ /**
193
+ * Get schema join
194
+ *
195
+ * @param Schema\Column $schema Schema.
196
+ * @param integer $row_id Row ID.
197
+ * @param array $attrs Shortcode attributes.
198
+ * @return string
199
+ */
200
+ private function get_schema_join( Schema\Column $schema, $row_id, array $attrs ) {
201
+ $format = isset( $attrs['format'] ) ? $attrs['format'] : 'label';
202
+
203
+ if ( $schema->get_column() === 'category' || $schema->get_column() === 'post_tag' ) {
204
+ $seperator = isset( $attrs['seperator'] ) ? $attrs['seperator'] : ', ';
205
+ $join = new Sql\Sql\Join\Term( $schema->get_column() );
206
+
207
+ return $join->get_value( $row_id, $format, $seperator );
208
+ }
209
+
210
+ return '';
211
+ }
212
+
213
+ /**
214
+ * Get a label from a schema column
215
+ *
216
+ * @param Schema\Column $schema Schema.
217
+ * @param array $attrs Shortcode attributes.
218
+ * @param string $row_value Row value.
219
+ * @return string
220
+ */
221
+ private function get_schema_value( Schema\Column $schema, array $attrs, $row_value ) {
222
+ if ( $schema->get_type() === 'date' && isset( $attrs['format'] ) ) {
223
+ return date( $attrs['format'], intval( mysql2date( 'U', $row_value ), 10 ) );
224
+ }
225
+
226
+ if ( $schema->get_type() === 'member' && isset( $attrs['format'] ) && $attrs['format'] === 'label' ) {
227
+ $option = $schema->get_option_label( $row_value );
228
+
229
+ if ( $option ) {
230
+ return $option;
231
+ }
232
+ }
233
+
234
+ if ( $schema->get_joined_by() || $schema->get_join_column() ) {
235
+ $convert = new Source\Convert_Values();
236
+
237
+ return $convert->convert( $schema, $row_value );
238
+ }
239
+
240
+ return $row_value;
241
+ }
242
+ }
includes/api/class-api.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Api;
4
+
5
+ require_once __DIR__ . '/class-route.php';
6
+ require_once __DIR__ . '/route/route-search.php';
7
+ require_once __DIR__ . '/route/route-source.php';
8
+ require_once __DIR__ . '/route/route-settings.php';
9
+ require_once __DIR__ . '/route/route-plugin.php';
10
+ require_once __DIR__ . '/route/route-preset.php';
11
+
12
+ class Api {
13
+ const SEARCHREGEX_API_NAMESPACE = 'search-regex/v1';
14
+
15
+ /**
16
+ * Instance variable
17
+ *
18
+ * @var Api|null
19
+ **/
20
+ private static $instance = null;
21
+
22
+ /**
23
+ * Array of endpoint routes
24
+ *
25
+ * @var Array
26
+ **/
27
+ private $routes = array();
28
+
29
+ /**
30
+ * Create API
31
+ *
32
+ * @return Api
33
+ */
34
+ public static function init() {
35
+ if ( is_null( self::$instance ) ) {
36
+ self::$instance = new Api();
37
+ }
38
+
39
+ return self::$instance;
40
+ }
41
+
42
+ public function __construct() {
43
+ global $wpdb;
44
+
45
+ $wpdb->hide_errors();
46
+
47
+ $this->routes[] = new Route\Search_Route( self::SEARCHREGEX_API_NAMESPACE );
48
+ $this->routes[] = new Route\Source_Route( self::SEARCHREGEX_API_NAMESPACE );
49
+ $this->routes[] = new Route\Plugin_Route( self::SEARCHREGEX_API_NAMESPACE );
50
+ $this->routes[] = new Route\Settings_Route( self::SEARCHREGEX_API_NAMESPACE );
51
+ $this->routes[] = new Route\Preset_Route( self::SEARCHREGEX_API_NAMESPACE );
52
+ }
53
+ }
api/api-base.php → includes/api/class-route.php RENAMED
@@ -1,24 +1,62 @@
1
  <?php
2
 
3
- use SearchRegex\Search_Flags;
4
- use SearchRegex\Source_Manager;
5
- use SearchRegex\Source_Flags;
6
  use SearchRegex\Search;
7
  use SearchRegex\Replace;
 
 
 
 
8
 
9
  /**
10
- * @apiDefine SearchQueryParams Search query
11
- * Query parameters for a search
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  *
13
  * @apiSuccess {Object[]} results All the search results
14
  * @apiSuccess {Integer} results.row_id The result row ID
15
  * @apiSuccess {String} results.source_type The result source type
16
  * @apiSuccess {String} results.source_name A displayable version of `source_type`
 
 
17
  * @apiSuccess {Object[]} results.columns An array of columns with matches
18
  * @apiSuccess {String} results.columns.column_id A column ID
19
  * @apiSuccess {String} results.columns.column_label A displayable name for the `column_id`
 
 
20
  * @apiSuccess {Object[]} results.columns.contexts An array of search contexts containing the search matches. This has a maximum size and cropping may occur (see `context_count`)
21
  * @apiSuccess {String} results.columns.contexts.context_id A context ID
 
22
  * @apiSuccess {String} results.columns.contexts.context The section of text from the column that contains all the matches in this context
23
  * @apiSuccess {Object[]} results.columns.contexts.matches The matched phrases contained within this context. This has a maximum size and cropping may occur (see `match_count`)
24
  * @apiSuccess {Integer} results.columns.contexts.matches.pos_id The position of the match within the row
@@ -27,11 +65,6 @@ use SearchRegex\Replace;
27
  * @apiSuccess {String} results.columns.contexts.matches.replacement The matched phrase with the replacement applied to it
28
  * @apiSuccess {String[]} results.columns.contexts.matches.captures If a regular expression search then this will contain any captured groups
29
  * @apiSuccess {Integer} results.columns.contexts.match_count The total number of matched phrases, including any that have been cropped.
30
- * @apiSuccess {Integer} results.columns.context_count The total possible number of contexts, including any from `contexts` that are cropped
31
- * @apiSuccess {String} results.columns.match_count The number of matches
32
- * @apiSuccess {String} results.columns.replacement The search phrase
33
- * @apiSuccess {Object[]} results.actions An array of actions that can be performed on this result
34
- * @apiSuccess {String} results.title A title for the result
35
  * @apiSuccess {Object[]} totals The totals for this search
36
  * @apiSuccess {Integer} totals.current The current search offset
37
  * @apiSuccess {Integer} totals.rows The total number of rows for the source, including non-matches
@@ -45,18 +78,20 @@ use SearchRegex\Replace;
45
  */
46
 
47
  /**
48
- * @apiDefine SearchResults Search results
49
- * Results for a Search Regex search
50
  *
51
- * @apiSuccess {Object[]} results All the search results
52
- * @apiSuccess {Integer} results.row_id The result row ID
53
- * @apiSuccess {String} results.source_type The result source type
54
- * @apiSuccess {String} results.source_name A displayable version of `source_type`
55
  * @apiSuccess {Object[]} results.columns An array of columns with matches
56
  * @apiSuccess {String} results.columns.column_id A column ID
57
  * @apiSuccess {String} results.columns.column_label A displayable name for the `column_id`
 
 
58
  * @apiSuccess {Object[]} results.columns.contexts An array of search contexts containing the search matches. This has a maximum size and cropping may occur (see `context_count`)
59
  * @apiSuccess {String} results.columns.contexts.context_id A context ID
 
60
  * @apiSuccess {String} results.columns.contexts.context The section of text from the column that contains all the matches in this context
61
  * @apiSuccess {Object[]} results.columns.contexts.matches The matched phrases contained within this context. This has a maximum size and cropping may occur (see `match_count`)
62
  * @apiSuccess {Integer} results.columns.contexts.matches.pos_id The position of the match within the row
@@ -65,48 +100,9 @@ use SearchRegex\Replace;
65
  * @apiSuccess {String} results.columns.contexts.matches.replacement The matched phrase with the replacement applied to it
66
  * @apiSuccess {String[]} results.columns.contexts.matches.captures If a regular expression search then this will contain any captured groups
67
  * @apiSuccess {Integer} results.columns.contexts.match_count The total number of matched phrases, including any that have been cropped.
68
- * @apiSuccess {Integer} results.columns.context_count The total possible number of contexts, including any from `contexts` that are cropped
69
- * @apiSuccess {String} results.columns.match_count The number of matches
70
- * @apiSuccess {String} results.columns.replacement The search phrase
71
- * @apiSuccess {Object[]} results.actions An array of actions that can be performed on this result
72
- * @apiSuccess {String} results.title A title for the result
73
- * @apiSuccess {Object[]} totals The totals for this search
74
- * @apiSuccess {Integer} totals.current The current search offset
75
- * @apiSuccess {Integer} totals.rows The total number of rows for the source, including non-matches
76
- * @apiSuccess {Integer} totals.matched_rows The number of matched rows if known, or `-1` if a regular expression match and unknown
77
- * @apiSuccess {Integer} totals.matched_phrases The number of matched phraes if known, or `-1` if a regular expression match and unknown
78
- * @apiSuccess {Object[]} progress The current search progress, and the previous and next set of results
79
- * @apiSuccess {Integer} progress.current The current search offset
80
- * @apiSuccess {Integer} progress.rows The number of rows contained within this result set
81
- * @apiSuccess {Integer} progress.previous The offset for the previous set of results
82
- * @apiSuccess {Integer} progress.next The offset for the next set of results
83
- */
84
-
85
- /**
86
- * @apiDefine SearchResult Search results
87
- * Results for a Search Regex search
88
- *
89
- * @apiSuccess {Integer} result.row_id The result row ID
90
- * @apiSuccess {String} result.source_type The result source type
91
- * @apiSuccess {String} result.source_name A displayable version of `source_type`
92
- * @apiSuccess {Object[]} result.columns An array of columns with matches
93
- * @apiSuccess {String} result.columns.column_id A column ID
94
- * @apiSuccess {String} result.columns.column_label A displayable name for the `column_id`
95
- * @apiSuccess {String} result.columns.match_count The total number of matches across all contexts in this column
96
- * @apiSuccess {String} result.columns.replacement The column with all matches replaced
97
- * @apiSuccess {Integer} result.columns.context_count The total possible number of contexts, including any from `contexts` that are cropped
98
- * @apiSuccess {Object[]} result.columns.contexts An array of search contexts containing the search matches. This has a maximum size and cropping may occur (see `context_count`)
99
- * @apiSuccess {String} result.columns.contexts.context_id A context ID
100
- * @apiSuccess {String} result.columns.contexts.context The section of text from the column that contains all the matches in this context
101
- * @apiSuccess {Integer} result.columns.contexts.match_count The total number of matched phrases, including any that have been cropped.
102
- * @apiSuccess {Object[]} result.columns.contexts.matches The matched phrases contained within this context. This has a maximum size and cropping may occur (see `match_count`)
103
- * @apiSuccess {Integer} result.columns.contexts.matches.pos_id The position of the match within the row
104
- * @apiSuccess {Integer} result.columns.contexts.matches.context_offset The position of the match within the context
105
- * @apiSuccess {String} result.columns.contexts.matches.match The matched phrase
106
- * @apiSuccess {String} result.columns.contexts.matches.replacement The matched phrase with the replacement applied to it
107
- * @apiSuccess {String[]} result.columns.contexts.matches.captures If a regular expression search then this will contain any captured groups
108
- * @apiSuccess {Object[]} result.actions An array of actions that can be performed on this result
109
- * @apiSuccess {String} result.title A title for the result
110
  */
111
 
112
  /**
@@ -159,15 +155,16 @@ use SearchRegex\Replace;
159
  /**
160
  * Base class for Search Regex API endpoints
161
  */
162
- class Search_Regex_Api_Route {
163
  /**
164
  * Checks a capability
165
  *
166
- * @param WP_REST_Request $request Request.
167
  * @return Bool
168
  */
169
- public function permission_callback( WP_REST_Request $request ) {
170
- return Search_Regex_Capabilities::has_access( Search_Regex_Capabilities::CAP_SEARCHREGEX_SEARCH );
 
171
  }
172
 
173
  /**
@@ -196,12 +193,6 @@ class Search_Regex_Api_Route {
196
  'searchPhrase' => [
197
  'description' => 'The search phrase',
198
  'type' => 'string',
199
- 'validate_callback' => [ $this, 'validate_search' ],
200
- 'required' => true,
201
- ],
202
- 'replacement' => [
203
- 'description' => 'The replacement phrase',
204
- 'type' => 'string',
205
  'default' => '',
206
  ],
207
  'source' => [
@@ -213,23 +204,40 @@ class Search_Regex_Api_Route {
213
  'validate_callback' => [ $this, 'validate_source' ],
214
  'required' => true,
215
  ],
216
- 'sourceFlags' => [
217
- 'description' => 'Source flags',
218
  'type' => 'array',
219
  'items' => [
220
  'type' => 'string',
221
  ],
222
  'default' => [],
223
- 'validate_callback' => [ $this, 'validate_source_flags' ],
224
  ],
225
- 'searchFlags' => [
226
- 'description' => 'Search flags',
 
 
 
 
 
 
227
  'type' => 'array',
228
  'items' => [
229
  'type' => 'string',
230
  ],
231
  'default' => [],
232
- 'validate_callback' => [ $this, 'validate_search_flags' ],
 
 
 
 
 
 
 
 
 
 
 
233
  ],
234
  ];
235
  }
@@ -237,89 +245,112 @@ class Search_Regex_Api_Route {
237
  /**
238
  * Helper to return a search and replace object
239
  *
240
- * @param Array $params Array of params.
241
- * @param String $replacement Replacement value.
242
- * @return Array{Search,Replace} Search and Replace objects
243
  */
244
- protected function get_search_replace( $params, $replacement ) {
245
- // Get basics
246
- $flags = new Search_Flags( $params['searchFlags'] );
247
- $sources = Source_Manager::get( $params['source'], $flags, new Source_Flags( $params['sourceFlags'] ) );
 
 
248
 
249
- // Create a search and replacer
250
- $search = new Search( $params['searchPhrase'], $sources, $flags );
251
- $replacer = new Replace( $replacement, $sources, $flags );
 
 
 
 
 
 
252
 
253
- return [ $search, $replacer ];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
254
  }
255
 
256
  /**
257
  * Validate that the search flags are correct
258
  *
259
- * @param Array|String $value The value to validate.
260
- * @param WP_REST_Request $request The request.
261
- * @param Array $param The array of parameters.
262
- * @return WP_Error|Bool true or false
263
  */
264
- public function validate_search_flags( $value, WP_REST_Request $request, $param ) {
265
  if ( is_array( $value ) ) {
266
- $source = new Search_Flags( $value );
267
 
268
  if ( count( $source->get_flags() ) === count( $value ) ) {
269
  return true;
270
  }
271
  }
272
 
273
- return new WP_Error( 'rest_invalid_param', 'Invalid search flag detected', array( 'status' => 400 ) );
274
  }
275
 
276
  /**
277
- * Validate that the source flags are correct
278
  *
279
  * @param Array|String $value The value to validate.
280
- * @param WP_REST_Request $request The request.
281
  * @param Array $param The array of parameters.
282
- * @return Bool|WP_Error true or false
283
  */
284
- public function validate_source_flags( $value, WP_REST_Request $request, $param ) {
285
  if ( is_array( $value ) ) {
286
- $params = $request->get_params();
287
- $search = isset( $params['search'] ) ? $params['search'] : $params;
288
- $sources = Source_Manager::get( is_array( $search['source'] ) ? $search['source'] : [ $search['source'] ], new Search_Flags(), new Source_Flags( $value ) );
289
-
290
- // Get the sanitized flags from all the sources
291
- $allowed = [];
292
- foreach ( $sources as $source ) {
293
- $allowed = array_merge( $allowed, array_keys( $source->get_supported_flags() ) );
294
  }
295
 
296
- // Make it unique, as some sources can use the same flag
297
- $allowed = array_values( array_unique( $allowed ) );
298
 
299
- // Filter the value by this allowed list
300
- $filtered_value = array_filter( $value, function( $item ) use ( $allowed ) {
301
- return in_array( $item, $allowed, true );
302
- } );
303
 
304
- // Any flags missing?
305
- if ( count( $filtered_value ) === count( $value ) ) {
306
- return true;
307
- }
 
 
 
 
 
 
 
308
  }
309
 
310
- return new WP_Error( 'rest_invalid_param', 'Invalid source flag detected', array( 'status' => 400 ) );
311
  }
312
 
313
  /**
314
  * Validate that the source is valid
315
  *
316
  * @param Array|String $value The value to validate.
317
- * @param WP_REST_Request $request The request.
318
  * @param Array $param The array of parameters.
319
  * @return Bool|WP_Error true or false
320
  */
321
- public function validate_source( $value, WP_REST_Request $request, $param ) {
322
- $allowed = Source_Manager::get_all_source_names();
323
 
324
  add_filter( 'wp_revisions_to_keep', [ $this, 'disable_post_revisions' ] );
325
  add_filter( 'wp_insert_post_data', [ $this, 'wp_insert_post_data' ] );
@@ -336,21 +367,34 @@ class Search_Regex_Api_Route {
336
  return true;
337
  }
338
 
339
- return new WP_Error( 'rest_invalid_param', 'Invalid source detected', array( 'status' => 400 ) );
340
  }
341
 
342
  /**
343
- * Validate that the search parameter is correct
344
  *
345
- * @param String $value The value to validate.
346
- * @param WP_REST_Request $request The request.
347
- * @param Array $param The array of parameters.
348
- * @return Bool true or false
349
  */
350
- public function validate_search( $value, WP_REST_Request $request, $param ) {
351
- $value = trim( $value );
 
 
352
 
353
- return strlen( $value ) > 0;
 
 
 
 
 
 
 
 
 
 
 
354
  }
355
 
356
  /**
@@ -378,4 +422,25 @@ class Search_Regex_Api_Route {
378
 
379
  return $data;
380
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
381
  }
1
  <?php
2
 
3
+ namespace SearchRegex\Api;
4
+
5
+ use SearchRegex\Source;
6
  use SearchRegex\Search;
7
  use SearchRegex\Replace;
8
+ use SearchRegex\Filter;
9
+ use SearchRegex\Action;
10
+ use SearchRegex\Schema;
11
+ use SearchRegex\Plugin;
12
 
13
  /**
14
+ * @apiDefine SearchQueryParams Search parameters
15
+ *
16
+ * The `replacement` and `searchFlags` are only used if a global `searchPhrase` is provided. This is a backwards-compatible global search and replace
17
+ *
18
+ * @apiParam (Search Query) {Integer} [page=0] Page to search
19
+ * @apiParam (Search Query) {Integer} [perPage=25] Number of results per page
20
+ * @apiParam (Search Query) {String="forward","backward"} [searchDirection=forward] Direction to search. Only needed for regular expression searches
21
+ * @apiParam (Search Query) {String="nothing","modify","replace","delete","export"} [action="nothing"] Action to perform on the search results, or do nothing
22
+ * @apiParam (Search Query) {Object} [actionOption] Options for the action
23
+ * @apiParam (Search Query) {String} [replacement=""] Global replacement value
24
+ * @apiParam (Search Query) {String[]} [searchFlags="case"] Flags for the global replacement
25
+ * @apiParam (Search Query) {String[]} source The search sources to perform the search over
26
+ * @apiParam (Search Query) {String[]} [view] Any additional columns to return data for. Specified in the format `source__column`
27
+ * @apiParam (Search Filter) {Object[]} [filters] Additional column filters. Each `filter` is `AND`ed together, so all must match for a row to be considered a match.
28
+ * @apiParam (Search Filter) {Object[]} [filters.items] Filters for columns within the source. These are `OR`ed together.
29
+ * @apiParam (Search Filter) {String} [filters.items.column] Column name. The column determines what other values should be present in the filter
30
+ * @apiParam (Search Filter) {String} [filters.items.logic] Logic for the filter. Date and integer supports 'equals', 'notequals', 'greater', 'less', 'range'. String supports 'equals', 'notequals', 'contains', 'notcontains', 'begins', 'ends'. Member supports `include` and `exclude`
31
+ * @apiParam (Search Filter) {Integer|Date} [filters.items.startValue] Lower value for a range, or single value for `integer` or `date`
32
+ * @apiParam (Search Filter) {Integer|Date} [filters.items.endValue] Upper value for a range
33
+ * @apiParam (Search Filter) {String} [filters.items.key] Key for a keyvalue pair
34
+ * @apiParam (Search Filter) {String} [filters.items.value] Value for a keyvalue pair
35
+ * @apiParam (Search Filter) {String} [filters.items.keyLogic] Logic for the filter (see `string`)
36
+ * @apiParam (Search Filter) {String} [filters.items.valueLogic] Logic for the filter (see `string`)
37
+ * @apiParam (Search Filter) {String} [filters.items.value] Single value for a string
38
+ * @apiParam (Search Filter) {String[]} [filters.items.values] Values for `member`
39
+ * @apiParam (Search Filter) {String} [filters.items.flags] Search flags for `string` or `keyvalue`
40
+ */
41
+
42
+ /**
43
+ * @apiDefine SearchResults Search results
44
+ * Results for a Search Regex search
45
  *
46
  * @apiSuccess {Object[]} results All the search results
47
  * @apiSuccess {Integer} results.row_id The result row ID
48
  * @apiSuccess {String} results.source_type The result source type
49
  * @apiSuccess {String} results.source_name A displayable version of `source_type`
50
+ * @apiSuccess {Object[]} results.actions An array of actions that can be performed on this result
51
+ * @apiSuccess {String} results.title A title for the result
52
  * @apiSuccess {Object[]} results.columns An array of columns with matches
53
  * @apiSuccess {String} results.columns.column_id A column ID
54
  * @apiSuccess {String} results.columns.column_label A displayable name for the `column_id`
55
+ * @apiSuccess {Integer} results.columns.context_count The total possible number of contexts, including any from `contexts` that are cropped
56
+ * @apiSuccess {String} results.columns.match_count The number of matches
57
  * @apiSuccess {Object[]} results.columns.contexts An array of search contexts containing the search matches. This has a maximum size and cropping may occur (see `context_count`)
58
  * @apiSuccess {String} results.columns.contexts.context_id A context ID
59
+ * @apiSuccess {String="value","add","delete","empty","keyvalue","replace","string"} results.columns.contexts.type The context type. This determines what other data is available
60
  * @apiSuccess {String} results.columns.contexts.context The section of text from the column that contains all the matches in this context
61
  * @apiSuccess {Object[]} results.columns.contexts.matches The matched phrases contained within this context. This has a maximum size and cropping may occur (see `match_count`)
62
  * @apiSuccess {Integer} results.columns.contexts.matches.pos_id The position of the match within the row
65
  * @apiSuccess {String} results.columns.contexts.matches.replacement The matched phrase with the replacement applied to it
66
  * @apiSuccess {String[]} results.columns.contexts.matches.captures If a regular expression search then this will contain any captured groups
67
  * @apiSuccess {Integer} results.columns.contexts.match_count The total number of matched phrases, including any that have been cropped.
 
 
 
 
 
68
  * @apiSuccess {Object[]} totals The totals for this search
69
  * @apiSuccess {Integer} totals.current The current search offset
70
  * @apiSuccess {Integer} totals.rows The total number of rows for the source, including non-matches
78
  */
79
 
80
  /**
81
+ * @apiDefine SearchResult Single search result
 
82
  *
83
+ * @apiSuccess {Object} result A result
84
+ * @apiSuccess {Integer} result.row_id Row ID
85
+ * @apiSuccess {String} result.source_type The source type (i.e. 'posts')
86
+ * @apiSuccess {String} result.source_name Source name suitable for display (i.e. 'Posts')
87
  * @apiSuccess {Object[]} results.columns An array of columns with matches
88
  * @apiSuccess {String} results.columns.column_id A column ID
89
  * @apiSuccess {String} results.columns.column_label A displayable name for the `column_id`
90
+ * @apiSuccess {Integer} results.columns.context_count The total possible number of contexts, including any from `contexts` that are cropped
91
+ * @apiSuccess {String} results.columns.match_count The number of matches
92
  * @apiSuccess {Object[]} results.columns.contexts An array of search contexts containing the search matches. This has a maximum size and cropping may occur (see `context_count`)
93
  * @apiSuccess {String} results.columns.contexts.context_id A context ID
94
+ * @apiSuccess {String="value","add","delete","empty","keyvalue","replace","string"} results.columns.contexts.type The context type. This determines what other data is available
95
  * @apiSuccess {String} results.columns.contexts.context The section of text from the column that contains all the matches in this context
96
  * @apiSuccess {Object[]} results.columns.contexts.matches The matched phrases contained within this context. This has a maximum size and cropping may occur (see `match_count`)
97
  * @apiSuccess {Integer} results.columns.contexts.matches.pos_id The position of the match within the row
100
  * @apiSuccess {String} results.columns.contexts.matches.replacement The matched phrase with the replacement applied to it
101
  * @apiSuccess {String[]} results.columns.contexts.matches.captures If a regular expression search then this will contain any captured groups
102
  * @apiSuccess {Integer} results.columns.contexts.match_count The total number of matched phrases, including any that have been cropped.
103
+ * @apiSuccess {Object[]} result.actions
104
+ * @apiSuccess {String} result.title - Title for this result
105
+ * @apiSuccess {Integer} result.match_count - Number of matches in this result
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
  */
107
 
108
  /**
155
  /**
156
  * Base class for Search Regex API endpoints
157
  */
158
+ class Route {
159
  /**
160
  * Checks a capability
161
  *
162
+ * @param \WP_REST_Request $request Request.
163
  * @return Bool
164
  */
165
+ public function permission_callback( \WP_REST_Request $request ) {
166
+ /** @psalm-suppress UndefinedClass */
167
+ return Plugin\Capabilities::has_access( Plugin\Capabilities::CAP_SEARCHREGEX_SEARCH );
168
  }
169
 
170
  /**
193
  'searchPhrase' => [
194
  'description' => 'The search phrase',
195
  'type' => 'string',
 
 
 
 
 
 
196
  'default' => '',
197
  ],
198
  'source' => [
204
  'validate_callback' => [ $this, 'validate_source' ],
205
  'required' => true,
206
  ],
207
+ 'searchFlags' => [
208
+ 'description' => 'Search flags',
209
  'type' => 'array',
210
  'items' => [
211
  'type' => 'string',
212
  ],
213
  'default' => [],
214
+ 'validate_callback' => [ $this, 'validate_search_flags' ],
215
  ],
216
+ 'filters' => [
217
+ 'description' => 'Search filters',
218
+ 'type' => 'array',
219
+ 'validate_callback' => [ $this, 'validate_filters' ],
220
+ 'default' => [],
221
+ ],
222
+ 'view' => [
223
+ 'description' => 'Additional columns to view',
224
  'type' => 'array',
225
  'items' => [
226
  'type' => 'string',
227
  ],
228
  'default' => [],
229
+ 'validate_callback' => [ $this, 'validate_view' ],
230
+ ],
231
+ 'action' => [
232
+ 'description' => 'Action to perform on the search',
233
+ 'type' => 'string',
234
+ 'default' => 'nothing',
235
+ 'validate_callback' => [ $this, 'validate_action' ],
236
+ ],
237
+ 'actionOption' => [
238
+ 'description' => 'Options for the action',
239
+ 'type' => 'object',
240
+ 'default' => [],
241
  ],
242
  ];
243
  }
245
  /**
246
  * Helper to return a search and replace object
247
  *
248
+ * @param Array $params Array of params.
249
+ * @return Array{Search,Action} Search and Replace objects
 
250
  */
251
+ protected function get_search_replace( $params ) {
252
+ $schema = new Schema\Schema( Source\Manager::get_schema( $params['source'] ) );
253
+ $filters = isset( $params['filters'] ) ? Filter\Filter::create( $params['filters'], $schema ) : [];
254
+
255
+ // Create the actions for the search
256
+ $action = Action\Action::create( isset( $params['action'] ) ? $params['action'] : '', Action\Action::get_options( $params ), $schema );
257
 
258
+ // Convert global search to filters
259
+ if ( isset( $params['searchPhrase'] ) && $params['searchPhrase'] ) {
260
+ $filters[] = new Filter\Global_Filter( $params['searchPhrase'], $params['searchFlags'] );
261
+ }
262
+
263
+ // Are we doing the action for real or just a dry run?
264
+ if ( isset( $params['save'] ) && $params['save'] ) {
265
+ $action->set_save_mode( true );
266
+ }
267
 
268
+ // Add any view columns
269
+ $columns = $action->get_view_columns();
270
+ if ( isset( $params['view'] ) ) {
271
+ $columns = array_unique( array_merge( $columns, $params['view'] ) );
272
+ }
273
+
274
+ $filters = Filter\Filter::get_missing_column_filters( $schema, $filters, $columns );
275
+
276
+ // Get sources
277
+ $sources = Source\Manager::get( $params['source'], $filters );
278
+
279
+ // Create the search, using the filters
280
+ $search = new Search\Search( $sources );
281
+
282
+ return [ $search, $action ];
283
  }
284
 
285
  /**
286
  * Validate that the search flags are correct
287
  *
288
+ * @param Array|String $value The value to validate.
289
+ * @param \WP_REST_Request $request The request.
290
+ * @param Array $param The array of parameters.
291
+ * @return \WP_Error|Bool true or false
292
  */
293
+ public function validate_search_flags( $value, \WP_REST_Request $request, $param ) {
294
  if ( is_array( $value ) ) {
295
+ $source = new Search\Flags( $value );
296
 
297
  if ( count( $source->get_flags() ) === count( $value ) ) {
298
  return true;
299
  }
300
  }
301
 
302
+ return new \WP_Error( 'rest_invalid_param', 'Invalid search flag detected', array( 'status' => 400 ) );
303
  }
304
 
305
  /**
306
+ * Validate that the view columns are valid
307
  *
308
  * @param Array|String $value The value to validate.
309
+ * @param \WP_REST_Request $request The request.
310
  * @param Array $param The array of parameters.
311
+ * @return \WP_Error|Bool true or false
312
  */
313
+ public function validate_view( $value, \WP_REST_Request $request, $param ) {
314
  if ( is_array( $value ) ) {
315
+ foreach ( $value as $view ) {
316
+ $parts = explode( '__', $view );
317
+ if ( count( $parts ) !== 2 ) {
318
+ return new \WP_Error( 'rest_invalid_param', 'Invalid view parameter', array( 'status' => 400 ) );
319
+ }
 
 
 
320
  }
321
 
322
+ return true;
323
+ }
324
 
325
+ return new \WP_Error( 'rest_invalid_param', 'Invalid view parameter', array( 'status' => 400 ) );
326
+ }
 
 
327
 
328
+ /**
329
+ * Validate that the view columns are valid
330
+ *
331
+ * @param Array|String $value The value to validate.
332
+ * @param \WP_REST_Request $request The request.
333
+ * @param Array $param The array of parameters.
334
+ * @return \WP_Error|Bool true or false
335
+ */
336
+ public function validate_action( $value, \WP_REST_Request $request, $param ) {
337
+ if ( in_array( $value, [ 'modify', 'replace', 'delete', 'export', 'nothing', 'action', '' ], true ) ) {
338
+ return true;
339
  }
340
 
341
+ return new \WP_Error( 'rest_invalid_param', 'Invalid view parameter', array( 'status' => 400 ) );
342
  }
343
 
344
  /**
345
  * Validate that the source is valid
346
  *
347
  * @param Array|String $value The value to validate.
348
+ * @param \WP_REST_Request $request The request.
349
  * @param Array $param The array of parameters.
350
  * @return Bool|WP_Error true or false
351
  */
352
+ public function validate_source( $value, \WP_REST_Request $request, $param ) {
353
+ $allowed = Source\Manager::get_all_source_names();
354
 
355
  add_filter( 'wp_revisions_to_keep', [ $this, 'disable_post_revisions' ] );
356
  add_filter( 'wp_insert_post_data', [ $this, 'wp_insert_post_data' ] );
367
  return true;
368
  }
369
 
370
+ return new \WP_Error( 'rest_invalid_param', 'Invalid source detected', array( 'status' => 400 ) );
371
  }
372
 
373
  /**
374
+ * Validate supplied filters
375
  *
376
+ * @param string|array $value Value.
377
+ * @param \WP_REST_Request $request Request.
378
+ * @param array $param Params.
379
+ * @return boolean
380
  */
381
+ public function validate_filters( $value, \WP_REST_Request $request, $param ) {
382
+ if ( ! is_array( $value ) ) {
383
+ return false;
384
+ }
385
 
386
+ foreach ( $value as $filter ) {
387
+ if ( ! is_array( $filter ) ) {
388
+ return false;
389
+ }
390
+
391
+ // Check type and items are present
392
+ if ( ! isset( $filter['type'] ) || ! isset( $filter['items'] ) ) {
393
+ return false;
394
+ }
395
+ }
396
+
397
+ return true;
398
  }
399
 
400
  /**
422
 
423
  return $data;
424
  }
425
+
426
+ /**
427
+ * Does the array contain the supplied keys?
428
+ *
429
+ * @param array $keys Keys.
430
+ * @param array|string $item Item.
431
+ * @return true|\WP_Error
432
+ */
433
+ protected function contains_keys( array $keys, $item ) {
434
+ if ( ! is_array( $item ) ) {
435
+ return new \WP_Error( 'rest_invalid_param', 'Item is not an array', [ 'status' => 400 ] );
436
+ }
437
+
438
+ foreach ( $keys as $key ) {
439
+ if ( ! isset( $item[ $key ] ) ) {
440
+ return new \WP_Error( 'rest_invalid_param', 'Item does not contain key ' . $key, [ 'status' => 400 ] );
441
+ }
442
+ }
443
+
444
+ return true;
445
+ }
446
  }
api/api-plugin.php → includes/api/route/route-plugin.php RENAMED
@@ -1,9 +1,13 @@
1
  <?php
2
 
 
 
 
 
3
  /**
4
  * 'Plugin' functions for Search Regex
5
  */
6
- class Search_Regex_Api_Plugin extends Search_Regex_Api_Route {
7
  /**
8
  * Plugin API endpoint constructor
9
  *
@@ -11,17 +15,17 @@ class Search_Regex_Api_Plugin extends Search_Regex_Api_Route {
11
  */
12
  public function __construct( $namespace ) {
13
  register_rest_route( $namespace, '/plugin/test', array(
14
- $this->get_route( WP_REST_Server::ALLMETHODS, 'route_test', [ $this, 'permission_callback' ] ),
15
  ) );
16
  }
17
 
18
  /**
19
  * Test the API
20
  *
21
- * @param WP_REST_Request $request Request.
22
  * @return Array
23
  */
24
- public function route_test( WP_REST_Request $request ) {
25
  return array(
26
  'success' => true,
27
  );
1
  <?php
2
 
3
+ namespace SearchRegex\Api\Route;
4
+
5
+ use SearchRegex\Api;
6
+
7
  /**
8
  * 'Plugin' functions for Search Regex
9
  */
10
+ class Plugin_Route extends Api\Route {
11
  /**
12
  * Plugin API endpoint constructor
13
  *
15
  */
16
  public function __construct( $namespace ) {
17
  register_rest_route( $namespace, '/plugin/test', array(
18
+ $this->get_route( \WP_REST_Server::ALLMETHODS, 'route_test', [ $this, 'permission_callback' ] ),
19
  ) );
20
  }
21
 
22
  /**
23
  * Test the API
24
  *
25
+ * @param \WP_REST_Request $request Request.
26
  * @return Array
27
  */
28
+ public function route_test( \WP_REST_Request $request ) {
29
  return array(
30
  'success' => true,
31
  );
api/api-preset.php → includes/api/route/route-preset.php RENAMED
@@ -1,6 +1,9 @@
1
  <?php
2
 
3
- use SearchRegex\Preset;
 
 
 
4
 
5
  /**
6
  * @api {get} /search-regex/v1/preset Get presets
@@ -116,7 +119,7 @@ use SearchRegex\Preset;
116
  /**
117
  * Search API endpoint
118
  */
119
- class Search_Regex_Api_Preset extends Search_Regex_Api_Route {
120
  /**
121
  * Get preset API params
122
  *
@@ -176,87 +179,86 @@ class Search_Regex_Api_Preset extends Search_Regex_Api_Route {
176
  */
177
  public function __construct( $namespace ) {
178
  register_rest_route( $namespace, '/preset', [
179
- 'args' => [],
180
- $this->get_route( WP_REST_Server::READABLE, 'route_list', [ $this, 'permission_callback' ] ),
181
  ] );
182
 
183
  register_rest_route( $namespace, '/preset', [
184
  'args' => $this->get_preset_params(),
185
- $this->get_route( WP_REST_Server::EDITABLE, 'route_create', [ $this, 'permission_callback' ] ),
186
  ] );
187
 
188
- register_rest_route( $namespace, '/preset/(?P<id>[A-Za-z0-9]+)', [
189
- 'args' => $this->get_preset_params(),
190
- $this->get_route( WP_REST_Server::EDITABLE, 'route_update', [ $this, 'permission_callback' ] ),
191
  ] );
192
 
193
- register_rest_route( $namespace, '/preset/(?P<id>[A-Za-z0-9]+)/delete', [
194
- $this->get_route( WP_REST_Server::EDITABLE, 'route_delete', [ $this, 'permission_callback' ] ),
 
195
  ] );
196
 
197
- register_rest_route( $namespace, '/preset/import', [
198
- $this->get_route( WP_REST_Server::EDITABLE, 'route_import', [ $this, 'permission_callback' ] ),
199
  ] );
200
  }
201
 
202
  /**
203
  * Create a new preset
204
  *
205
- * @param WP_REST_Request $request API request.
206
  * @return array|\WP_Error
207
  */
208
- public function route_create( WP_REST_Request $request ) {
209
  $params = $request->get_params();
210
 
211
- $preset = new Preset( $params );
212
- $name = $preset->create();
213
 
214
  return [
215
  'current' => $preset->to_json(),
216
- 'presets' => Preset::get_all(),
217
  ];
218
  }
219
 
220
  /**
221
  * Import presets from an upload
222
  *
223
- * @param WP_REST_Request $request API request.
224
  * @return array|\WP_Error
225
  */
226
- public function route_import( WP_REST_Request $request ) {
227
  $upload = $request->get_file_params();
228
  $upload = isset( $upload['file'] ) ? $upload['file'] : false;
229
 
230
  if ( $upload && is_uploaded_file( $upload['tmp_name'] ) ) {
231
- $imported = Preset::import( $upload['tmp_name'] );
232
 
233
  if ( $imported > 0 ) {
234
  return [
235
- 'presets' => Preset::get_all(),
236
  'import' => $imported,
237
  ];
238
  }
239
  }
240
 
241
- return new WP_Error( 'searchregex_import_preset', 'Invalid import file' );
242
  }
243
 
244
  /**
245
  * Update an existing preset
246
  *
247
- * @param WP_REST_Request $request API request.
248
  * @return array|\WP_Error
249
  */
250
- public function route_update( WP_REST_Request $request ) {
251
  $params = $request->get_params();
252
 
253
- $preset = Preset::get( $params['id'] );
254
  if ( $preset ) {
255
- $name = $preset->update( $params );
256
 
257
  return [
258
  'current' => $preset->to_json(),
259
- 'presets' => Preset::get_all(),
260
  ];
261
  }
262
 
@@ -266,19 +268,19 @@ class Search_Regex_Api_Preset extends Search_Regex_Api_Route {
266
  /**
267
  * Delete an existing preset
268
  *
269
- * @param WP_REST_Request $request API request.
270
  * @return array|\WP_Error
271
  */
272
- public function route_delete( WP_REST_Request $request ) {
273
  $params = $request->get_params();
274
 
275
- $preset = Preset::get( $params['id'] );
276
  if ( $preset ) {
277
  $preset->delete();
278
 
279
  return [
280
  'current' => $preset->to_json(),
281
- 'presets' => Preset::get_all(),
282
  ];
283
  }
284
 
@@ -288,10 +290,10 @@ class Search_Regex_Api_Preset extends Search_Regex_Api_Route {
288
  /**
289
  * Return a list of presets
290
  *
291
- * @param WP_REST_Request $request API request.
292
  * @return array
293
  */
294
- public function route_list( WP_REST_Request $request ) {
295
  $params = $request->get_params();
296
 
297
  if ( isset( $params['force'] ) ) {
@@ -311,11 +313,11 @@ class Search_Regex_Api_Preset extends Search_Regex_Api_Route {
311
  }
312
 
313
  return $preset;
314
- }, Preset::get_all() );
315
  }
316
 
317
  return [
318
- 'presets' => Preset::get_all(),
319
  ];
320
  }
321
 
@@ -323,12 +325,12 @@ class Search_Regex_Api_Preset extends Search_Regex_Api_Route {
323
  * Validate that the locked params are valid
324
  *
325
  * @param Array|String $value The value to validate.
326
- * @param WP_REST_Request $request The request.
327
  * @param Array $param The array of parameters.
328
- * @return WP_Error|Bool true or false
329
  */
330
- public function validate_locked( $value, WP_REST_Request $request, $param ) {
331
- $preset = new Preset();
332
 
333
  if ( is_array( $value ) ) {
334
  $filtered = array_filter( $value, function( $item ) use ( $preset ) {
@@ -340,22 +342,20 @@ class Search_Regex_Api_Preset extends Search_Regex_Api_Route {
340
  }
341
  }
342
 
343
- return new WP_Error( 'rest_invalid_param', 'Invalid locked params', array( 'status' => 400 ) );
344
  }
345
 
346
  /**
347
  * Validate that the tag params are valid
348
  *
349
  * @param Array|String $value The value to validate.
350
- * @param WP_REST_Request $request The request.
351
  * @param Array $param The array of parameters.
352
- * @return WP_Error|Bool true or false
353
  */
354
- public function validate_tags( $value, WP_REST_Request $request, $param ) {
355
- $preset = new Preset();
356
-
357
  if ( is_array( $value ) ) {
358
- $filtered = array_filter( $value, function( $item ) use ( $preset ) {
359
  return isset( $item['name'] ) && isset( $item['title'] );
360
  } );
361
 
@@ -364,6 +364,6 @@ class Search_Regex_Api_Preset extends Search_Regex_Api_Route {
364
  }
365
  }
366
 
367
- return new WP_Error( 'rest_invalid_param', 'Invalid tag params', array( 'status' => 400 ) );
368
  }
369
  }
1
  <?php
2
 
3
+ namespace SearchRegex\Api\Route;
4
+
5
+ use SearchRegex\Search;
6
+ use SearchRegex\Api;
7
 
8
  /**
9
  * @api {get} /search-regex/v1/preset Get presets
119
  /**
120
  * Search API endpoint
121
  */
122
+ class Preset_Route extends Api\Route {
123
  /**
124
  * Get preset API params
125
  *
179
  */
180
  public function __construct( $namespace ) {
181
  register_rest_route( $namespace, '/preset', [
182
+ $this->get_route( \WP_REST_Server::READABLE, 'route_list', [ $this, 'permission_callback' ] ),
 
183
  ] );
184
 
185
  register_rest_route( $namespace, '/preset', [
186
  'args' => $this->get_preset_params(),
187
+ $this->get_route( \WP_REST_Server::EDITABLE, 'route_create', [ $this, 'permission_callback' ] ),
188
  ] );
189
 
190
+ register_rest_route( $namespace, '/preset/import', [
191
+ $this->get_route( \WP_REST_Server::EDITABLE, 'route_import', [ $this, 'permission_callback' ] ),
 
192
  ] );
193
 
194
+ register_rest_route( $namespace, '/preset/id/(?P<id>[A-Za-z0-9]+)', [
195
+ 'args' => $this->get_preset_params(),
196
+ $this->get_route( \WP_REST_Server::EDITABLE, 'route_update', [ $this, 'permission_callback' ] ),
197
  ] );
198
 
199
+ register_rest_route( $namespace, '/preset/id/(?P<id>[A-Za-z0-9]+)/delete', [
200
+ $this->get_route( \WP_REST_Server::EDITABLE, 'route_delete', [ $this, 'permission_callback' ] ),
201
  ] );
202
  }
203
 
204
  /**
205
  * Create a new preset
206
  *
207
+ * @param \WP_REST_Request $request API request.
208
  * @return array|\WP_Error
209
  */
210
+ public function route_create( \WP_REST_Request $request ) {
211
  $params = $request->get_params();
212
 
213
+ $preset = new Search\Preset( $params );
214
+ $preset->create();
215
 
216
  return [
217
  'current' => $preset->to_json(),
218
+ 'presets' => Search\Preset::get_all(),
219
  ];
220
  }
221
 
222
  /**
223
  * Import presets from an upload
224
  *
225
+ * @param \WP_REST_Request $request API request.
226
  * @return array|\WP_Error
227
  */
228
+ public function route_import( \WP_REST_Request $request ) {
229
  $upload = $request->get_file_params();
230
  $upload = isset( $upload['file'] ) ? $upload['file'] : false;
231
 
232
  if ( $upload && is_uploaded_file( $upload['tmp_name'] ) ) {
233
+ $imported = Search\Preset::import( $upload['tmp_name'] );
234
 
235
  if ( $imported > 0 ) {
236
  return [
237
+ 'presets' => Search\Preset::get_all(),
238
  'import' => $imported,
239
  ];
240
  }
241
  }
242
 
243
+ return new \WP_Error( 'searchregex_import_preset', 'Invalid import file' );
244
  }
245
 
246
  /**
247
  * Update an existing preset
248
  *
249
+ * @param \WP_REST_Request $request API request.
250
  * @return array|\WP_Error
251
  */
252
+ public function route_update( \WP_REST_Request $request ) {
253
  $params = $request->get_params();
254
 
255
+ $preset = Search\Preset::get( $params['id'] );
256
  if ( $preset ) {
257
+ $preset->update( $params );
258
 
259
  return [
260
  'current' => $preset->to_json(),
261
+ 'presets' => Search\Preset::get_all(),
262
  ];
263
  }
264
 
268
  /**
269
  * Delete an existing preset
270
  *
271
+ * @param \WP_REST_Request $request API request.
272
  * @return array|\WP_Error
273
  */
274
+ public function route_delete( \WP_REST_Request $request ) {
275
  $params = $request->get_params();
276
 
277
+ $preset = Search\Preset::get( $params['id'] );
278
  if ( $preset ) {
279
  $preset->delete();
280
 
281
  return [
282
  'current' => $preset->to_json(),
283
+ 'presets' => Search\Preset::get_all(),
284
  ];
285
  }
286
 
290
  /**
291
  * Return a list of presets
292
  *
293
+ * @param \WP_REST_Request $request API request.
294
  * @return array
295
  */
296
+ public function route_list( \WP_REST_Request $request ) {
297
  $params = $request->get_params();
298
 
299
  if ( isset( $params['force'] ) ) {
313
  }
314
 
315
  return $preset;
316
+ }, Search\Preset::get_all() );
317
  }
318
 
319
  return [
320
+ 'presets' => Search\Preset::get_all(),
321
  ];
322
  }
323
 
325
  * Validate that the locked params are valid
326
  *
327
  * @param Array|String $value The value to validate.
328
+ * @param \WP_REST_Request $request The request.
329
  * @param Array $param The array of parameters.
330
+ * @return \WP_Error|Bool true or false
331
  */
332
+ public function validate_locked( $value, \WP_REST_Request $request, $param ) {
333
+ $preset = new Search\Preset();
334
 
335
  if ( is_array( $value ) ) {
336
  $filtered = array_filter( $value, function( $item ) use ( $preset ) {
342
  }
343
  }
344
 
345
+ return new \WP_Error( 'rest_invalid_param', 'Invalid locked params', array( 'status' => 400 ) );
346
  }
347
 
348
  /**
349
  * Validate that the tag params are valid
350
  *
351
  * @param Array|String $value The value to validate.
352
+ * @param \WP_REST_Request $request The request.
353
  * @param Array $param The array of parameters.
354
+ * @return \WP_Error|Bool true or false
355
  */
356
+ public function validate_tags( $value, \WP_REST_Request $request, $param ) {
 
 
357
  if ( is_array( $value ) ) {
358
+ $filtered = array_filter( $value, function( $item ) {
359
  return isset( $item['name'] ) && isset( $item['title'] );
360
  } );
361
 
364
  }
365
  }
366
 
367
+ return new \WP_Error( 'rest_invalid_param', 'Invalid tag params', array( 'status' => 400 ) );
368
  }
369
  }
api/api-search.php → includes/api/route/route-search.php RENAMED
@@ -1,22 +1,33 @@
1
  <?php
2
 
 
 
3
  use SearchRegex\Search;
4
  use SearchRegex\Saved_Search;
 
5
 
6
  /**
7
  * @api {post} /search-regex/v1/search Search
8
  * @apiVersion 1.0.0
9
  * @apiName Search
10
- * @apiDescription This performs the search matching of a search phrase in a search source. The search is designed to not timeout and exhaust server memory, and sometimes
11
  * requires the client to perform multiple requests to get a full set of results.
12
  *
13
- * A search source typically represents a WordPress database table. For example, posts, options, or comments. Some sources also represents part of
14
- * a database table, such as custom post types.
 
 
 
 
 
15
  *
16
- * Searching operates in two modes - simple (non-regular expression) or advanced (regular expression). Simple searching provides feedback on how many results
17
- * match the search phrase, while advanced searching requires you to search through the entire table. It should be noted that while a full result set will be returned
18
- * for simple searching, unless no more matches are found, advanced searching may return empty results. This indicates you need to keep on searching until the end of the source,
19
- * or until results are returned. This gives the client the ability to cancel a search if it is taking too long.
 
 
 
20
  *
21
  * Searches are returned as an array of results. Every result contains a matched phrase. Each result contains the source name (`source_name`) and row ID (`row_id`) and a number of
22
  * matched columns. These represent the searchable columns within a source database table.
@@ -34,7 +45,6 @@ use SearchRegex\Saved_Search;
34
  * @apiGroup Search
35
  *
36
  * @apiUse SearchQueryParams
37
- *
38
  * @apiUse SearchResults
39
  * @apiUse 401Error
40
  * @apiUse 404Error
@@ -43,7 +53,7 @@ use SearchRegex\Saved_Search;
43
  /**
44
  * Search API endpoint
45
  */
46
- class Search_Regex_Api_Search extends Search_Regex_Api_Route {
47
  /**
48
  * Return API paging args
49
  *
@@ -93,27 +103,26 @@ class Search_Regex_Api_Search extends Search_Regex_Api_Route {
93
  $this->get_search_params(),
94
  $this->get_paging_params()
95
  ),
96
- $this->get_route( WP_REST_Server::EDITABLE, 'route_search', [ $this, 'permission_callback' ] ),
97
  ] );
98
  }
99
 
100
  /**
101
  * Search for matches
102
  *
103
- * @param WP_REST_Request $request The request.
104
- * @return WP_Error|array Return an array of results, or a WP_Error
105
  */
106
- public function route_search( WP_REST_Request $request ) {
107
  $params = $request->get_params();
108
 
109
- list( $search, $replacer ) = $this->get_search_replace( $params, $params['replacement'] );
110
 
111
- $results = $search->get_search_results( $replacer, $params['page'], $params['perPage'], $params['limit'] );
112
- if ( $results instanceof WP_Error ) {
113
  return $results;
114
  }
115
 
116
- $results['results'] = $search->results_to_json( $results['results'] );
117
- return $results;
118
  }
119
  }
1
  <?php
2
 
3
+ namespace SearchRegex\Api\Route;
4
+
5
  use SearchRegex\Search;
6
  use SearchRegex\Saved_Search;
7
+ use SearchRegex\Api;
8
 
9
  /**
10
  * @api {post} /search-regex/v1/search Search
11
  * @apiVersion 1.0.0
12
  * @apiName Search
13
+ * @apiDescription This performs the search matching of a set of search conditions. The search is designed to not timeout and exhaust server memory, and sometimes
14
  * requires the client to perform multiple requests to get a full set of results.
15
  *
16
+ * A search `source` typically represents a WordPress database table. For example, posts, options, or comments.
17
+ *
18
+ * Search conditions can be added through:
19
+ * - A global search phrase (`searchPhrase` and `searchFlags`). This searches the common text columns of sources and is a quick way to get results
20
+ * - Search filters. These are conditions applied to specific columns within a source. Filters can be arranged so they are `OR`ed and `AND`ed together in any combination.
21
+ *
22
+ * A global search can be combined with search filters.
23
  *
24
+ * Searching operates in two modes:
25
+ * - simple (non-regular expression)
26
+ * - advanced (regular expression)
27
+ *
28
+ * The mode determines what how result sets are returned. In a simple search a query will return fixed size pages of results. In an advanced search, a query may not return a full page of results.
29
+ * This is because the advanced mode retrieves a set of rows from the database, and then returns the matching rows. This allows regular expressions to be used. A simple search uses SQL to only retrieve
30
+ * matching rows.
31
  *
32
  * Searches are returned as an array of results. Every result contains a matched phrase. Each result contains the source name (`source_name`) and row ID (`row_id`) and a number of
33
  * matched columns. These represent the searchable columns within a source database table.
45
  * @apiGroup Search
46
  *
47
  * @apiUse SearchQueryParams
 
48
  * @apiUse SearchResults
49
  * @apiUse 401Error
50
  * @apiUse 404Error
53
  /**
54
  * Search API endpoint
55
  */
56
+ class Search_Route extends Api\Route {
57
  /**
58
  * Return API paging args
59
  *
103
  $this->get_search_params(),
104
  $this->get_paging_params()
105
  ),
106
+ $this->get_route( \WP_REST_Server::EDITABLE, 'route_search', [ $this, 'permission_callback' ] ),
107
  ] );
108
  }
109
 
110
  /**
111
  * Search for matches
112
  *
113
+ * @param \WP_REST_Request $request The request.
114
+ * @return \WP_Error|array Return an array of results, or a \WP_Error
115
  */
116
+ public function route_search( \WP_REST_Request $request ) {
117
  $params = $request->get_params();
118
 
119
+ list( $search, $action ) = $this->get_search_replace( $params );
120
 
121
+ $results = $search->get_search_results( $action, $params['page'], $params['perPage'], $params['limit'] );
122
+ if ( $results instanceof \WP_Error ) {
123
  return $results;
124
  }
125
 
126
+ return $action->get_results( $results );
 
127
  }
128
  }
api/api-settings.php → includes/api/route/route-settings.php RENAMED
@@ -1,4 +1,10 @@
1
  <?php
 
 
 
 
 
 
2
  /**
3
  * @api {get} /search-regex/v1/setting Get settings
4
  * @apiVersion 1.0.0
@@ -50,7 +56,7 @@
50
  /**
51
  * Settings API endpoint
52
  */
53
- class Search_Regex_Api_Settings extends Search_Regex_Api_Route {
54
  /**
55
  * Create API endpoints with the given namespace
56
  *
@@ -58,33 +64,52 @@ class Search_Regex_Api_Settings extends Search_Regex_Api_Route {
58
  */
59
  public function __construct( $namespace ) {
60
  register_rest_route( $namespace, '/setting', array(
61
- $this->get_route( WP_REST_Server::READABLE, 'route_settings', [ $this, 'permission_callback' ] ),
62
- $this->get_route( WP_REST_Server::EDITABLE, 'route_save_settings', [ $this, 'permission_callback' ] ),
63
  ) );
64
  }
65
 
66
  /**
67
  * Get settings
68
  *
69
- * @param WP_REST_Request $request Request.
70
  * @return Array Settings
71
  */
72
- public function route_settings( WP_REST_Request $request ) {
 
 
73
  return [
74
- 'settings' => searchregex_get_options(),
75
  ];
76
  }
77
 
78
  /**
79
  * Set settings
80
  *
81
- * @param WP_REST_Request $request Request.
82
  * @return Array Settings
83
  */
84
- public function route_save_settings( WP_REST_Request $request ) {
85
  $params = $request->get_params();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
 
87
- searchregex_set_options( $params );
88
 
89
  return $this->route_settings( $request );
90
  }
1
  <?php
2
+
3
+ namespace SearchRegex\Api\Route;
4
+
5
+ use SearchRegex\Api;
6
+ use SearchRegex\Plugin;
7
+
8
  /**
9
  * @api {get} /search-regex/v1/setting Get settings
10
  * @apiVersion 1.0.0
56
  /**
57
  * Settings API endpoint
58
  */
59
+ class Settings_Route extends Api\Route {
60
  /**
61
  * Create API endpoints with the given namespace
62
  *
64
  */
65
  public function __construct( $namespace ) {
66
  register_rest_route( $namespace, '/setting', array(
67
+ $this->get_route( \WP_REST_Server::READABLE, 'route_settings', [ $this, 'permission_callback' ] ),
68
+ $this->get_route( \WP_REST_Server::EDITABLE, 'route_save_settings', [ $this, 'permission_callback' ] ),
69
  ) );
70
  }
71
 
72
  /**
73
  * Get settings
74
  *
75
+ * @param \WP_REST_Request $request Request.
76
  * @return Array Settings
77
  */
78
+ public function route_settings( \WP_REST_Request $request ) {
79
+ $settings = Plugin\Settings::init();
80
+
81
  return [
82
+ 'settings' => $settings->get_as_json(),
83
  ];
84
  }
85
 
86
  /**
87
  * Set settings
88
  *
89
+ * @param \WP_REST_Request $request Request.
90
  * @return Array Settings
91
  */
92
+ public function route_save_settings( \WP_REST_Request $request ) {
93
  $params = $request->get_params();
94
+ $settings = Plugin\Settings::init();
95
+
96
+ if ( isset( $params['rest_api'] ) ) {
97
+ $settings->set_rest_api( $params['rest_api'] );
98
+ }
99
+
100
+ if ( isset( $params['support'] ) ) {
101
+ $settings->set_is_supported( $params['support'] );
102
+ }
103
+
104
+ if ( isset( $params['defaultPreset'] ) ) {
105
+ $settings->set_default_preset( $params['defaultPreset'] );
106
+ }
107
+
108
+ if ( isset( $params['update_notice'] ) ) {
109
+ $settings->set_latest_version();
110
+ }
111
 
112
+ $settings->save();
113
 
114
  return $this->route_settings( $request );
115
  }
includes/api/route/route-source.php ADDED
@@ -0,0 +1,357 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Api\Route;
4
+
5
+ use SearchRegex\Search;
6
+ use SearchRegex\Replace;
7
+ use SearchRegex\Source;
8
+ use SearchRegex\Source\Manager;
9
+ use SearchRegex\Api;
10
+
11
+ /**
12
+ * @apiDefine ColumnData Data for a column
13
+ * Data for a column. Each item of data contains either `value` or `items`, but not both.
14
+ *
15
+ * @apiSuccess {Object[]} column - Column data
16
+ * @apiSuccess {String} column.column - Name of the column
17
+ * @apiSuccess {String} [column.value] - Column value
18
+ * @apiSuccess {Object[]} [column.items] - Array of key/value pairs
19
+ * @apiSuccess {String} column.items.key - Key value
20
+ * @apiSuccess {String} column.items.value - Value
21
+ * @apiSuccess {String} column.items.value_type - Type of the value
22
+ */
23
+
24
+ /**
25
+ * @api {get} /search-regex/v1/source List of sources
26
+ * @apiVersion 1.0.0
27
+ * @apiName GetSources
28
+ * @apiDescription Return all the available sources
29
+ *
30
+ * @apiGroup Source
31
+ *
32
+ * @apiUse SearchResults
33
+ * @apiUse 401Error
34
+ * @apiUse 404Error
35
+ */
36
+
37
+ /**
38
+ * @api {get} /search-regex/v1/source/:source/:rowId Load row
39
+ * @apiName LoadRow
40
+ * @apiDescription Load a row of data from one source. This can be used to get the full data for a particular search.
41
+ *
42
+ * @apiGroup Source
43
+ *
44
+ * @apiParam (URL) {String} :source The source
45
+ * @apiParam (URL) {Integer} :rowId The source row ID
46
+ *
47
+ * @apiUse ColumnData
48
+ * @apiUse 401Error
49
+ * @apiUse 404Error
50
+ */
51
+
52
+ /**
53
+ * @api {post} /search-regex/v1/source/:source/:rowId Save row
54
+ * @apiName SaveRow
55
+ * @apiDescription Save a row of data to a source.
56
+ *
57
+ * @apiGroup Source
58
+ *
59
+ * @apiParam (URL) {String} :source The source
60
+ * @apiParam (URL) {Integer} :rowId The source row ID
61
+ * @apiParam (Post Data) {Object} replacement The replacement data
62
+ * @apiParam (Post Data) {String} replacement.column The column name to perform a replace in
63
+ * @apiParam (Post Data) {String} [replacement.operation] Operation appropriate to the type of column (i.e. 'set').
64
+ * @apiParam (Post Data) {String[]} [replacement.values] Values for the operation
65
+ * @apiParam (Post Data) {String[]} [replacement.searchValue] Search value
66
+ * @apiParam (Post Data) {String[]} [replacement.replaceValue] Replace value
67
+ * @apiParam (Post Data) {Object[]} [replacement.items] Array of replacement items
68
+ * @apiParam (Post Data) {String} [replacement.items.type] Type of replacement
69
+ * @apiParam (Post Data) {String} [replacement.items.key] Key
70
+ * @apiParam (Post Data) {String} [replacement.items.value] Value
71
+ *
72
+ * @apiUse SearchResult
73
+ * @apiUse 401Error
74
+ * @apiUse 404Error
75
+ */
76
+
77
+ /**
78
+ * @api {post} /search-regex/v1/source/:source/:rowId/delete Delete row
79
+ * @apiVersion 1.0.0
80
+ * @apiName DeleteRow
81
+ * @apiDescription Removes an entire row of data from the source
82
+ *
83
+ * @apiGroup Source
84
+ *
85
+ * @apiParam (URL) {String} :source The source
86
+ * @apiParam (URL) {Integer} :rowId The source row ID
87
+ * @apiParam (Search Query) {Integer} page Page to search
88
+ * @apiParam (Search Query) {Integer} perPage Number of results per page
89
+ * @apiParam (Search Query) {String="forward","backward"} [searchDirection=forward] Direction to search. Only needed for regular expression searches
90
+ *
91
+ * @apiSuccess {Bool} result `true` if deleted, `false` otherwise
92
+ * @apiUse 401Error
93
+ * @apiUse 404Error
94
+ */
95
+
96
+ /**
97
+ * Search API endpoint
98
+ */
99
+ class Source_Route extends Api\Route {
100
+ const AUTOCOMPLETE_MAX = 50;
101
+ const AUTOCOMPLETE_TRIM_BEFORE = 10;
102
+
103
+ /**
104
+ * API schema for source validation.
105
+ *
106
+ * @return array
107
+ */
108
+ private function get_source_params() {
109
+ return [
110
+ 'source' => [
111
+ 'validate_callback' => [ $this, 'validate_source' ],
112
+ 'sanitize_callback' => [ $this, 'sanitize_row_source' ],
113
+ ],
114
+ ];
115
+ }
116
+
117
+ /**
118
+ * Search API endpoint constructor
119
+ *
120
+ * @param String $namespace Namespace.
121
+ */
122
+ public function __construct( $namespace ) {
123
+ register_rest_route( $namespace, '/source', [
124
+ $this->get_route( \WP_REST_Server::READABLE, 'getSources', [ $this, 'permission_callback' ] ),
125
+ ] );
126
+
127
+ register_rest_route( $namespace, '/source/(?P<source>[a-z\-\_]+)/complete/(?P<column>[a-z\-\_]+)', [
128
+ 'args' => array_merge(
129
+ $this->get_source_params(),
130
+ [
131
+ 'value' => [
132
+ 'description' => 'Auto complete value',
133
+ 'type' => 'string',
134
+ 'required' => true,
135
+ ],
136
+ ]
137
+ ),
138
+ $this->get_route( \WP_REST_Server::READABLE, 'autoComplete', [ $this, 'permission_callback' ] ),
139
+ ] );
140
+
141
+ register_rest_route( $namespace, '/source/(?P<source>[a-z\-\_]+)/row/(?P<rowId>[\d]+)', [
142
+ 'args' => $this->get_source_params(),
143
+ $this->get_route( \WP_REST_Server::READABLE, 'loadRow', [ $this, 'permission_callback' ] ),
144
+ ] );
145
+
146
+ register_rest_route( $namespace, '/source/(?P<source>[a-z\-\_]+)/row/(?P<rowId>[\d]+)', [
147
+ 'args' => array_merge(
148
+ [
149
+ 'replacement' => [
150
+ 'description' => 'Row replacement. A single action.',
151
+ 'type' => 'object',
152
+ 'validate_callback' => [ $this, 'validate_replacement' ],
153
+ 'required' => true,
154
+ ],
155
+ ],
156
+ $this->get_source_params(),
157
+ $this->get_search_params()
158
+ ),
159
+ $this->get_route( \WP_REST_Server::EDITABLE, 'saveRow', [ $this, 'permission_callback' ] ),
160
+ ] );
161
+
162
+ register_rest_route( $namespace, '/source/(?P<source>[a-z\-\_]+)/row/(?P<rowId>[\d]+)/delete', [
163
+ 'args' => $this->get_source_params(),
164
+ $this->get_route( \WP_REST_Server::EDITABLE, 'deleteRow', [ $this, 'permission_callback' ] ),
165
+ ] );
166
+ }
167
+
168
+ /**
169
+ * Sanitize the source so it's a single source in an array, suitable for use with the search functions
170
+ *
171
+ * @param string|array $value Source name.
172
+ * @param \WP_REST_Request $request Request object.
173
+ * @param string $param Param name.
174
+ * @return string[]
175
+ */
176
+ public function sanitize_row_source( $value, \WP_REST_Request $request, $param ) {
177
+ if ( is_array( $value ) ) {
178
+ return array_slice( $value, 0, 1 );
179
+ }
180
+
181
+ return [ $value ];
182
+ }
183
+
184
+ /**
185
+ * Validate the replacement.
186
+ *
187
+ * @param string|array $value Source name.
188
+ * @param \WP_REST_Request $request Request object.
189
+ * @param string $param Param name.
190
+ * @return true|WP_Error
191
+ */
192
+ public function validate_replacement( $value, \WP_REST_Request $request, $param ) {
193
+ $result = $this->contains_keys( [ 'column' ], $value );
194
+ if ( is_wp_error( $result ) ) {
195
+ return $result;
196
+ }
197
+
198
+ if ( isset( $value['items'] ) ) {
199
+ foreach ( $value['items'] as $item ) {
200
+ $result = $this->contains_keys( [ 'value', 'key' ], $item );
201
+
202
+ if ( is_wp_error( $result ) ) {
203
+ return $result;
204
+ }
205
+ }
206
+ }
207
+
208
+ if ( isset( $value['values'] ) && ! is_array( $value['values'] ) ) {
209
+ return new \WP_Error( 'rest_invalid_param', 'Item is not an array', [ 'status' => 400 ] );
210
+ }
211
+
212
+ return true;
213
+ }
214
+
215
+ /**
216
+ * Get list of all sources
217
+ *
218
+ * @param \WP_REST_Request $request The request.
219
+ * @return \WP_Error|array Return an array of sources, or a \WP_Error
220
+ */
221
+ public function getSources( \WP_REST_Request $request ) {
222
+ $sources = Source\Manager::get_all_sources();
223
+
224
+ return array_map( function( $source ) {
225
+ return [
226
+ 'name' => $source['name'],
227
+ 'label' => $source['label'],
228
+ 'description' => $source['description'],
229
+ 'type' => $source['type'],
230
+ ];
231
+ }, $sources );
232
+ }
233
+
234
+ /**
235
+ * Perform a replacement on a row
236
+ *
237
+ * @param \WP_REST_Request $request The request.
238
+ * @return \WP_Error|array Return an array of results, or a \WP_Error
239
+ */
240
+ public function saveRow( \WP_REST_Request $request ) {
241
+ $params = $request->get_params();
242
+ $replace = [
243
+ 'action' => 'modify',
244
+ 'actionOption' => [
245
+ $params['replacement'],
246
+ ],
247
+ ];
248
+
249
+ [ $search, $action ] = $this->get_search_replace( array_merge( $params, $replace ) );
250
+
251
+ // Get the results for the search/replace
252
+ $results = $search->get_row( $params['rowId'], $action );
253
+ if ( $results instanceof \WP_Error ) {
254
+ return $results;
255
+ }
256
+
257
+ if ( count( $results ) === 0 ) {
258
+ return new \WP_Error( 'rest_invalid_param', 'No matching row', [ 'status' => 400 ] );
259
+ }
260
+
261
+ // Save the changes
262
+ $results = $search->save_changes( $results[0] );
263
+ if ( $results instanceof \WP_Error ) {
264
+ return $results;
265
+ }
266
+
267
+ // Get the row again, with the original search conditions
268
+ [ $search, $action ] = $this->get_search_replace( $params );
269
+ $results = $search->get_row( $params['rowId'], $action );
270
+ if ( $results instanceof \WP_Error ) {
271
+ return $results;
272
+ }
273
+
274
+ return [
275
+ 'result' => $action->get_results( [ 'results' => $results ] )['results'][0],
276
+ ];
277
+ }
278
+
279
+ /**
280
+ * Load all relevant data from a source's row
281
+ *
282
+ * @param \WP_REST_Request $request The request.
283
+ * @return \WP_Error|array Return an array of results, or a \WP_Error
284
+ */
285
+ public function loadRow( \WP_REST_Request $request ) {
286
+ $params = $request->get_params();
287
+ $sources = Source\Manager::get( $params['source'], [] );
288
+ $row = $sources[0]->get_row_columns( $params['rowId'] );
289
+
290
+ if ( is_wp_error( $row ) ) {
291
+ return $row;
292
+ }
293
+
294
+ return [
295
+ 'result' => $row,
296
+ ];
297
+ }
298
+
299
+ /**
300
+ * Delete a row of data
301
+ *
302
+ * @param \WP_REST_Request $request The request.
303
+ * @return \WP_Error|array Return an array of results, or a \WP_Error
304
+ */
305
+ public function deleteRow( \WP_REST_Request $request ) {
306
+ $params = $request->get_params();
307
+ $sources = Source\Manager::get( $params['source'], [] );
308
+
309
+ return $sources[0]->delete_row( $params['rowId'] );
310
+ }
311
+
312
+ /**
313
+ * Autocomplete some value and return suggestions appropriate to the source and column
314
+ *
315
+ * @param \WP_REST_Request $request The request.
316
+ * @return \WP_Error|array Return an array of results, or a \WP_Error
317
+ */
318
+ public function autoComplete( \WP_REST_Request $request ) {
319
+ $params = $request->get_params();
320
+ $sources = Source\Manager::get( $params['source'], [] );
321
+
322
+ // Validate the column
323
+ foreach ( $sources[0]->get_schema_for_source()['columns'] as $column ) {
324
+ if ( $column['column'] === $params['column'] && $column['options'] === 'api' ) {
325
+ // Get autocomplete results
326
+ $rows = $sources[0]->autocomplete( $column, $params['value'] );
327
+ $results = [];
328
+
329
+ foreach ( $rows as $row ) {
330
+ $result = [
331
+ 'value' => $row->id,
332
+ 'title' => str_replace( [ '\n', '\r', '\t' ], '', $row->value ),
333
+ ];
334
+
335
+ // Trim content to context
336
+ if ( strlen( $result['title'] ) > self::AUTOCOMPLETE_MAX && strlen( $params['value'] ) > 0 ) {
337
+ $pos = strpos( $result['title'], $params['value'] );
338
+
339
+ if ( $pos !== false ) {
340
+ $result['title'] = '...' . substr( $result['title'], max( 0, $pos - self::AUTOCOMPLETE_TRIM_BEFORE ), self::AUTOCOMPLETE_MAX ) . '...';
341
+ }
342
+ } elseif ( strlen( $result['title'] ) > self::AUTOCOMPLETE_MAX ) {
343
+ $result['title'] = substr( $result['title'], 0, self::AUTOCOMPLETE_MAX ) . '...';
344
+ }
345
+
346
+ $results[] = $result;
347
+ }
348
+
349
+ // Return to user
350
+ return apply_filters( 'searchregex_autocomplete_results', $results );
351
+ }
352
+ }
353
+
354
+ // Invalid column
355
+ return new \WP_Error( 'rest_invalid_param', 'Unknown column ' . $params['column'], [ 'status' => 400 ] );
356
+ }
357
+ }
includes/context/class-context.php ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Context;
4
+
5
+ require_once __DIR__ . '/class-value-type.php';
6
+ require_once __DIR__ . '/context-value.php';
7
+ require_once __DIR__ . '/context-matched.php';
8
+ require_once __DIR__ . '/context-add.php';
9
+ require_once __DIR__ . '/context-delete.php';
10
+ require_once __DIR__ . '/context-pair.php';
11
+ require_once __DIR__ . '/context-empty.php';
12
+ require_once __DIR__ . '/context-replace.php';
13
+ require_once __DIR__ . '/context-text.php';
14
+
15
+ /**
16
+ * A group of matches within the same area of a column
17
+ */
18
+ abstract class Context {
19
+ /**
20
+ * Context ID
21
+ *
22
+ * @var Int
23
+ **/
24
+ protected $context_id = 0;
25
+
26
+ /**
27
+ * Create a Context_String with a given context ID
28
+ *
29
+ * @param int $context_id Context ID.
30
+ */
31
+ public function __construct( $context_id = 0 ) {
32
+ $this->context_id = $context_id;
33
+ }
34
+
35
+ /**
36
+ * Set the context ID
37
+ *
38
+ * @param integer $context_id New context ID.
39
+ * @return void
40
+ */
41
+ public function set_context_id( $context_id ) {
42
+ $this->context_id = $context_id;
43
+ }
44
+
45
+ /**
46
+ * Is the context the same type as this context?
47
+ *
48
+ * @param Context $context Context to compare.
49
+ * @return boolean
50
+ */
51
+ public function is_equal( Context $context ) {
52
+ return $this->get_type() === $context->get_type();
53
+ }
54
+
55
+ /**
56
+ * Has this been matched?
57
+ *
58
+ * @return boolean
59
+ */
60
+ public function is_matched() {
61
+ return false;
62
+ }
63
+
64
+ /**
65
+ * Get number of matches
66
+ *
67
+ * @return integer
68
+ */
69
+ public function get_match_count() {
70
+ return 1;
71
+ }
72
+
73
+ /**
74
+ * Does this need saving?
75
+ *
76
+ * @return boolean
77
+ */
78
+ public function needs_saving() {
79
+ return false;
80
+ }
81
+
82
+ /**
83
+ * Convert the Context_String to to_json
84
+ *
85
+ * @return array JSON
86
+ */
87
+ public function to_json() {
88
+ return [
89
+ 'context_id' => $this->context_id,
90
+ 'type' => $this->get_type(),
91
+ ];
92
+ }
93
+
94
+ /**
95
+ * Get context type
96
+ *
97
+ * @return string
98
+ */
99
+ abstract public function get_type();
100
+ }
includes/context/class-value-type.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Context;
4
+
5
+ /**
6
+ * Represents the type of a particular value
7
+ */
8
+ class Value_Type {
9
+ const VALUE_TEXT = 'text';
10
+ const VALUE_PHP = 'php';
11
+ const VALUE_JSON = 'json';
12
+ const VALUE_BLOCKS = 'blocks';
13
+ const VALUE_HTML = 'html';
14
+
15
+ /**
16
+ * Get the type for the value
17
+ *
18
+ * @param string $value Value.
19
+ * @return string
20
+ */
21
+ public static function get( $value ) {
22
+ // Detect type
23
+ if ( is_serialized( $value ) ) {
24
+ return self::VALUE_PHP;
25
+ } elseif ( preg_match( '/^[\[\|\{]/', $value ) ) {
26
+ return self::VALUE_JSON;
27
+ } elseif ( strpos( $value, '<!-- wp:' ) !== false ) {
28
+ return self::VALUE_BLOCKS;
29
+ } elseif ( preg_match( '@</.*?>@', $value ) ) {
30
+ return self::VALUE_HTML;
31
+ }
32
+
33
+ return self::VALUE_TEXT;
34
+ }
35
+ }
includes/context/context-add.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Context\Type;
4
+
5
+ use SearchRegex\Context;
6
+
7
+ /**
8
+ * A context has been added.
9
+ */
10
+ class Add extends Context\Type\Value {
11
+ const TYPE_ADD = 'add';
12
+
13
+ public function get_type() {
14
+ return self::TYPE_ADD;
15
+ }
16
+
17
+ public function is_matched() {
18
+ return true;
19
+ }
20
+
21
+ public function needs_saving() {
22
+ return true;
23
+ }
24
+ }
includes/context/context-delete.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Context\Type;
4
+
5
+ use SearchRegex\Context;
6
+
7
+ /**
8
+ * Context for a deleted value
9
+ */
10
+ class Delete extends Context\Type\Value {
11
+ const TYPE_DELETE = 'delete';
12
+
13
+ public function get_type() {
14
+ return self::TYPE_DELETE;
15
+ }
16
+
17
+ public function is_matched() {
18
+ return true;
19
+ }
20
+
21
+ public function needs_saving() {
22
+ return true;
23
+ }
24
+ }
includes/context/context-empty.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Context\Type;
4
+
5
+ use SearchRegex\Context;
6
+
7
+ /**
8
+ * Context for an empty value (i.e. null)
9
+ */
10
+ class Empty_Type extends Context\Context {
11
+ const TYPE_EMPTY = 'empty';
12
+
13
+ public function get_type() {
14
+ return self::TYPE_EMPTY;
15
+ }
16
+
17
+ /**
18
+ * Get the value
19
+ *
20
+ * @return string
21
+ */
22
+ public function get_value() {
23
+ return '';
24
+ }
25
+ }
includes/context/context-matched.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Context\Type;
4
+
5
+ use SearchRegex\Context;
6
+
7
+ /**
8
+ * Context for a matched value
9
+ */
10
+ class Matched extends Context\Type\Value {
11
+ const TYPE_MATCH = 'match';
12
+
13
+ public function get_type() {
14
+ return self::TYPE_MATCH;
15
+ }
16
+
17
+ public function is_matched() {
18
+ return true;
19
+ }
20
+ }
includes/context/context-pair.php ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Context\Type;
4
+
5
+ use SearchRegex\Context;
6
+
7
+ /**
8
+ * Context for a keyvalue pair
9
+ */
10
+ class Pair extends Context\Context {
11
+ const TYPE_PAIR = 'keyvalue';
12
+
13
+ /**
14
+ * Key
15
+ *
16
+ * @var Context\Context
17
+ * @readonly
18
+ */
19
+ private $key;
20
+
21
+ /**
22
+ * Value
23
+ *
24
+ * @var Context\Context
25
+ * @readonly
26
+ */
27
+ private $value;
28
+
29
+ public function __construct( Context\Context $key, Context\Context $value ) {
30
+ $this->key = $key;
31
+ $this->value = $value;
32
+ }
33
+
34
+ /**
35
+ * Get the key
36
+ *
37
+ * @return Context\Context
38
+ */
39
+ public function get_key() {
40
+ return $this->key;
41
+ }
42
+
43
+ /**
44
+ * Get the value
45
+ *
46
+ * @return Context\Context
47
+ */
48
+ public function get_value() {
49
+ return $this->value;
50
+ }
51
+
52
+ public function get_type() {
53
+ return self::TYPE_PAIR;
54
+ }
55
+
56
+ public function to_json() {
57
+ $key = $this->key->to_json();
58
+ $value = $this->value->to_json();
59
+
60
+ unset( $key['context_id'] );
61
+ unset( $value['context_id'] );
62
+
63
+ return array_merge( parent::to_json(), [
64
+ 'key' => $key,
65
+ 'value' => $value,
66
+ ] );
67
+ }
68
+
69
+ public function is_equal( Context\Context $context ) {
70
+ if ( parent::is_equal( $context ) && $context instanceof Context\Type\Pair ) {
71
+ return $this->key->is_equal( $context->key ) && $this->value->is_equal( $context->value );
72
+ }
73
+
74
+ return false;
75
+ }
76
+
77
+ public function is_matched() {
78
+ return $this->key->is_matched() || $this->value->is_matched();
79
+ }
80
+
81
+ public function needs_saving() {
82
+ return $this->key->needs_saving() || $this->value->needs_saving();
83
+ }
84
+ }
includes/context/context-replace.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Context\Type;
4
+
5
+ use SearchRegex\Context;
6
+
7
+ /**
8
+ * Context when something has been replaced
9
+ */
10
+ class Replace extends Context\Type\Value {
11
+ const TYPE_REPLACE = 'replace';
12
+
13
+ /**
14
+ * Replacement value
15
+ *
16
+ * @var string|integer|null
17
+ */
18
+ private $replacement = null;
19
+
20
+ /**
21
+ * Replacement value type
22
+ *
23
+ * @var string|null
24
+ */
25
+ private $replacement_label = null;
26
+
27
+ /**
28
+ * Set the replacement
29
+ *
30
+ * @param string|integer $value Value.
31
+ * @param string $label Label.
32
+ * @return void
33
+ */
34
+ public function set_replacement( $value, $label = null ) {
35
+ $this->replacement = $value;
36
+ $this->replacement_label = $label ? $label : (string) $value;
37
+ }
38
+
39
+ public function get_type() {
40
+ return self::TYPE_REPLACE;
41
+ }
42
+
43
+ /**
44
+ * Get the replacement value
45
+ *
46
+ * @return string|null|integer
47
+ */
48
+ public function get_replacement() {
49
+ return $this->replacement;
50
+ }
51
+
52
+ public function is_matched() {
53
+ return true;
54
+ }
55
+
56
+ public function needs_saving() {
57
+ return true;
58
+ }
59
+
60
+ public function to_json() {
61
+ return array_merge( parent::to_json(), [
62
+ 'replacement' => $this->restrict_value( $this->replacement === null ? '' : (string) $this->replacement ),
63
+ 'replacement_label' => $this->restrict_value( $this->replacement_label === null ? '' : $this->replacement_label ),
64
+ ] );
65
+ }
66
+
67
+ public function is_equal( Context\Context $context ) {
68
+ if ( parent::is_equal( $context ) && $context instanceof Context\Type\Replace ) {
69
+ return $this->replacement === $context->replacement;
70
+ }
71
+
72
+ return false;
73
+ }
74
+ }
includes/context/context-text.php ADDED
@@ -0,0 +1,242 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Context\Type;
4
+
5
+ use SearchRegex\Context;
6
+ use SearchRegex\Search;
7
+
8
+ /**
9
+ * Context for a substring(s) in a string
10
+ */
11
+ class Text extends Context\Context {
12
+ const TYPE_STRING = 'string';
13
+ const MATCH_LIMIT = 100;
14
+ const CONTEXT_RANGE = 100;
15
+ const CHARS_BEFORE = 50;
16
+ const CHARS_AFTER = 60;
17
+
18
+ /**
19
+ * Context
20
+ *
21
+ * @var Text|null
22
+ **/
23
+ private $context = null;
24
+
25
+ /**
26
+ * Crop values
27
+ *
28
+ * @var array
29
+ */
30
+ private $context_crop = [];
31
+
32
+ /**
33
+ * Array of matches
34
+ *
35
+ * @var Search\Text[]
36
+ **/
37
+ private $matches = [];
38
+
39
+ /**
40
+ * Text being searched
41
+ *
42
+ * @var string
43
+ */
44
+ private $search;
45
+
46
+ /**
47
+ * Search flags
48
+ *
49
+ * @var Search\Flags
50
+ */
51
+ private $flags;
52
+
53
+ /**
54
+ * Value type
55
+ *
56
+ * @var string
57
+ */
58
+ private $value_type = '';
59
+
60
+ /**
61
+ * Number of matches
62
+ *
63
+ * @var integer
64
+ */
65
+ private $match_count = 0;
66
+
67
+ /**
68
+ * Constructor
69
+ *
70
+ * @param string $search Search.
71
+ * @param Search\Flags $flags Flags.
72
+ */
73
+ public function __construct( $search, Search\Flags $flags ) {
74
+ $this->search = '';
75
+ $this->flags = new Search\Flags();
76
+ $this->set_search( $search, $flags );
77
+ }
78
+
79
+ /**
80
+ * Set the search
81
+ *
82
+ * @param string $search Search.
83
+ * @param Search\Flags $flags Flags.
84
+ * @return void
85
+ */
86
+ public function set_search( $search, Search\Flags $flags ) {
87
+ $this->search = $search;
88
+ $this->flags = $flags;
89
+ }
90
+
91
+ /**
92
+ * Set the value type
93
+ *
94
+ * @param string $type Type.
95
+ * @return void
96
+ */
97
+ public function set_type( $type ) {
98
+ $this->value_type = $type;
99
+ }
100
+
101
+ /**
102
+ * Return the number of matches within this context
103
+ *
104
+ * @return Int Match count
105
+ */
106
+ public function get_match_count() {
107
+ return $this->match_count;
108
+ }
109
+
110
+ public function is_matched() {
111
+ return true;
112
+ }
113
+
114
+ public function needs_saving() {
115
+ return true;
116
+ }
117
+
118
+ /**
119
+ * Convert the Context\Type\Text to to_json
120
+ *
121
+ * @return array JSON
122
+ */
123
+ public function to_json() {
124
+ $matches = [];
125
+
126
+ foreach ( $this->matches as $match ) {
127
+ $matches[] = $match->to_json();
128
+ }
129
+
130
+ return array_merge(
131
+ parent::to_json(),
132
+ [
133
+ 'context' => $this->context,
134
+ 'crop' => $this->context_crop,
135
+ 'search' => $this->search,
136
+ 'flags' => $this->flags->to_json(),
137
+ 'matches' => $matches,
138
+ 'match_count' => $this->match_count,
139
+ 'value_type' => $this->value_type,
140
+ ]
141
+ );
142
+ }
143
+
144
+ /**
145
+ * Determine if the Match object is within this context.
146
+ *
147
+ * @param Search\Text $match The match to check.
148
+ * @return Bool true if within the context, false otherwise
149
+ */
150
+ public function is_within_context( Search\Text $match ) {
151
+ if ( count( $this->matches ) === 0 ) {
152
+ return true;
153
+ }
154
+
155
+ $last_match = $this->matches[ count( $this->matches ) - 1 ];
156
+
157
+ return $match->get_position() - $last_match->get_position() < self::CONTEXT_RANGE;
158
+ }
159
+
160
+ /**
161
+ * Add a Match to this context
162
+ *
163
+ * @param Search\Text $match The match to do.
164
+ * @param Text $value The column value.
165
+ * @return void
166
+ */
167
+ public function add_match( Search\Text $match, $value ) {
168
+ $this->match_count++;
169
+
170
+ if ( count( $this->matches ) === self::MATCH_LIMIT ) {
171
+ return;
172
+ }
173
+
174
+ // Add match to list
175
+ $this->matches[] = $match;
176
+
177
+ // Expand the context to include everything from the first to last match
178
+ $start_pos = max( 0, $this->matches[0]->get_position() - self::CHARS_BEFORE );
179
+
180
+ $end_pos = $match->get_position() + strlen( $match->get_matched_text() ) + self::CHARS_AFTER;
181
+
182
+ $this->context = mb_substr( $value, $start_pos, $end_pos - $start_pos, 'UTF-8' );
183
+ $this->context_crop = [];
184
+
185
+ if ( $start_pos > 0 ) {
186
+ $this->context_crop['start'] = $start_pos;
187
+ }
188
+
189
+ if ( $end_pos < strlen( $value ) ) {
190
+ $this->context_crop['end'] = $end_pos;
191
+ }
192
+
193
+ // Finally update the match
194
+ $match->set_context( $match->get_position() - $start_pos );
195
+ }
196
+
197
+ /**
198
+ * Find the Match that exists at the given position
199
+ *
200
+ * @param int $pos_id Position.
201
+ * @return Search\Text|Bool Match at position
202
+ */
203
+ public function get_match_at_position( $pos_id ) {
204
+ foreach ( $this->matches as $match ) {
205
+ if ( $match->get_position() === $pos_id ) {
206
+ return $match;
207
+ }
208
+ }
209
+
210
+ return false;
211
+ }
212
+
213
+ public function get_type() {
214
+ return self::TYPE_STRING;
215
+ }
216
+
217
+ /**
218
+ * Get value
219
+ *
220
+ * @return string|null
221
+ */
222
+ public function get_value() {
223
+ return $this->context;
224
+ }
225
+
226
+ public function is_equal( Context\Context $context ) {
227
+ if ( parent::is_equal( $context ) && $context instanceof Context\Type\Text ) {
228
+ return $this->context === $context->context;
229
+ }
230
+
231
+ return false;
232
+ }
233
+
234
+ /**
235
+ * Get matches from this context
236
+ *
237
+ * @return Search\Text[]
238
+ */
239
+ public function get_matches() {
240
+ return $this->matches;
241
+ }
242
+ }
includes/context/context-value.php ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Context\Type;
4
+
5
+ use SearchRegex\Context;
6
+
7
+ /**
8
+ * Context that contains a value.
9
+ */
10
+ class Value extends Context\Context {
11
+ const TYPE_VALUE = 'value';
12
+ const MAX_LENGTH = 200;
13
+
14
+ /**
15
+ * The value
16
+ *
17
+ * @var string|integer
18
+ * @readonly
19
+ */
20
+ protected $value;
21
+
22
+ /**
23
+ * Type of the value
24
+ *
25
+ * @var string
26
+ */
27
+ protected $value_type;
28
+
29
+ /**
30
+ * Label for the value, if appropriate.
31
+ *
32
+ * @var string
33
+ */
34
+ protected $value_label;
35
+
36
+ /**
37
+ * Value length. If the value has been cropped this will be longer than the length in `value`
38
+ *
39
+ * @var integer
40
+ */
41
+ protected $value_length;
42
+
43
+ /**
44
+ * Constructor
45
+ *
46
+ * @param string|integer $value Value.
47
+ * @param string $label Label.
48
+ */
49
+ public function __construct( $value, $label = null ) {
50
+ parent::__construct();
51
+
52
+ $this->value_type = Context\Value_Type::get( (string) $value );
53
+ $this->value = "$value";
54
+ $this->value_label = $label === null ? (string) $value : $label;
55
+ $this->value_length = strlen( (string) $value );
56
+ }
57
+
58
+ /**
59
+ * Restrict the value to the max length
60
+ *
61
+ * @param string $value Value to restrict.
62
+ * @return string
63
+ */
64
+ protected function restrict_value( $value ) {
65
+ return mb_substr( $value, 0, self::MAX_LENGTH );
66
+ }
67
+
68
+ public function get_type() {
69
+ return self::TYPE_VALUE;
70
+ }
71
+
72
+ /**
73
+ * Get value
74
+ *
75
+ * @return string|integer
76
+ */
77
+ public function get_value() {
78
+ return $this->value;
79
+ }
80
+
81
+ /**
82
+ * Get value type
83
+ *
84
+ * @return string
85
+ */
86
+ public function get_value_type() {
87
+ return $this->value_type;
88
+ }
89
+
90
+ public function is_equal( Context\Context $context ) {
91
+ if ( parent::is_equal( $context ) && $context instanceof Context\Type\Value ) {
92
+ return $this->value === $context->value;
93
+ }
94
+
95
+ return false;
96
+ }
97
+
98
+ /**
99
+ * Convert the Context\Type\Text to to_json
100
+ *
101
+ * @return array JSON
102
+ */
103
+ public function to_json() {
104
+ return array_merge( parent::to_json(), [
105
+ 'value' => $this->restrict_value( (string) $this->value ),
106
+ 'value_type' => $this->value_type,
107
+ 'value_label' => $this->restrict_value( $this->value_label ),
108
+ 'value_length' => $this->value_length,
109
+ ] );
110
+ }
111
+ }
includes/filter/class-global-filter.php ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Filter;
4
+
5
+ use SearchRegex\Schema;
6
+ use SearchRegex\Source;
7
+
8
+ /**
9
+ * A global search filter that performs a string match on any column marked 'global' in the schema
10
+ */
11
+ class Global_Filter extends Filter {
12
+ /**
13
+ * Global search phrase
14
+ *
15
+ * @readonly
16
+ * @var string
17
+ */
18
+ private $search_phrase = '';
19
+
20
+ /**
21
+ * Global search flags
22
+ *
23
+ * @readonly
24
+ * @var string[]
25
+ */
26
+ private $search_flags = [];
27
+
28
+ /**
29
+ * Constructor
30
+ *
31
+ * @param string $search_phrase Search.
32
+ * @param string[] $search_flags Search flags.
33
+ */
34
+ public function __construct( $search_phrase, $search_flags ) {
35
+ $this->search_phrase = $search_phrase;
36
+ $this->search_flags = $search_flags;
37
+ }
38
+
39
+ /**
40
+ * Is this filter for a given source?
41
+ *
42
+ * @param string $source Source name.
43
+ * @return boolean
44
+ */
45
+ public function is_for_source( $source ) {
46
+ return true;
47
+ }
48
+
49
+ /**
50
+ * Is this filter for this column?
51
+ *
52
+ * @param Schema\Column $column Column.
53
+ * @return boolean
54
+ */
55
+ public function is_for( Schema\Column $column ) {
56
+ return $column->is_global();
57
+ }
58
+
59
+ /**
60
+ * Get the filter items
61
+ *
62
+ * @param Source\Source $source Source.
63
+ * @return list<Filter\Filter_Item>
64
+ */
65
+ public function get_items( Source\Source $source ) {
66
+ $schema = new Schema\Source( $source->get_schema_for_source() );
67
+ $items = [];
68
+
69
+ foreach ( $schema->get_global_columns() as $column ) {
70
+ $filter = [
71
+ 'column' => $column->get_column(),
72
+ 'flags' => $this->search_flags,
73
+ 'value' => $this->search_phrase,
74
+ 'logic' => 'contains',
75
+ ];
76
+
77
+ $items[] = new Type\Filter_String( $filter, $column );
78
+ }
79
+
80
+ return array_merge( $items, $this->items );
81
+ }
82
+
83
+ public function has_column( $column, Schema\Column $schema ) {
84
+ return $schema->is_global();
85
+ }
86
+
87
+ public function is_advanced() {
88
+ return in_array( 'regex', $this->search_flags, true );
89
+ }
90
+ }
includes/filter/class-search-filter.php ADDED
@@ -0,0 +1,394 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Filter;
4
+
5
+ use SearchRegex\Filter\Type;
6
+ use SearchRegex\Sql;
7
+ use SearchRegex\Action;
8
+ use SearchRegex\Schema;
9
+ use SearchRegex\Source;
10
+ use SearchRegex\Search;
11
+
12
+ require_once __DIR__ . '/filter-base.php';
13
+ require_once __DIR__ . '/filter-integer.php';
14
+ require_once __DIR__ . '/filter-member.php';
15
+ require_once __DIR__ . '/filter-string.php';
16
+ require_once __DIR__ . '/filter-date.php';
17
+ require_once __DIR__ . '/filter-keyvalue.php';
18
+ require_once __DIR__ . '/class-global-filter.php';
19
+
20
+ /**
21
+ * Filters a search
22
+ */
23
+ class Filter {
24
+ const MAX_OR_FILTERS = 10; // Matches MAX_OR_FILTERS in client
25
+ const MAX_AND_FILTERS = 20;
26
+
27
+ /**
28
+ * Filters for this column, each to be ORd together
29
+ *
30
+ * @var list<Type\Filter_Type>
31
+ */
32
+ protected $items = [];
33
+
34
+ /**
35
+ * Column schema
36
+ *
37
+ * @readonly
38
+ * @var Schema\Source|null
39
+ */
40
+ protected $schema = null;
41
+
42
+ /**
43
+ * Create the filter
44
+ *
45
+ * @param array $data Filter data.
46
+ * @param Schema\Schema $schema Schema data.
47
+ * @return void
48
+ */
49
+ public function __construct( array $data, Schema\Schema $schema ) {
50
+ if ( isset( $data['type'] ) ) {
51
+ $this->schema = $schema->get_for_source( $data['type'] );
52
+ }
53
+
54
+ if ( isset( $data['items'] ) && $this->schema ) {
55
+ foreach ( array_slice( $data['items'], 0, self::MAX_OR_FILTERS ) as $item ) {
56
+ $column_schema = isset( $item['column'] ) ? $this->schema->get_column( $item['column'] ) : false;
57
+
58
+ if ( $column_schema ) {
59
+ $item = Type\Filter_Type::create( $item, $column_schema );
60
+
61
+ if ( $item && $item->is_valid() ) {
62
+ $this->items[] = $item;
63
+ }
64
+ }
65
+ }
66
+ }
67
+ }
68
+
69
+ /**
70
+ * Add a Type\Filter_Type
71
+ *
72
+ * @param Type\Filter_Type $item Item to add.
73
+ * @return void
74
+ */
75
+ public function add_item( Type\Filter_Type $item ) {
76
+ $this->items[] = $item;
77
+ }
78
+
79
+ /**
80
+ * Create a Filter object
81
+ *
82
+ * @param array $json JSON data.
83
+ * @param Schema\Schema $schema Schema for filter.
84
+ * @return list<Filter>
85
+ */
86
+ public static function create( array $json, Schema\Schema $schema ) {
87
+ // Get basics
88
+ $filters = array_map( function( $filter ) use ( $schema ) {
89
+ $new_filter = new Filter( $filter, $schema );
90
+
91
+ if ( $new_filter->is_valid() ) {
92
+ return $new_filter;
93
+ }
94
+
95
+ return false;
96
+ }, array_slice( $json, 0, self::MAX_AND_FILTERS ) );
97
+
98
+ return array_values( array_filter( $filters ) );
99
+ }
100
+
101
+ /**
102
+ * Is this filter valid?
103
+ *
104
+ * @return boolean
105
+ */
106
+ public function is_valid() {
107
+ if ( ! $this->schema ) {
108
+ return false;
109
+ }
110
+
111
+ if ( count( $this->items ) === 0 ) {
112
+ return false;
113
+ }
114
+
115
+ return true;
116
+ }
117
+
118
+ /**
119
+ * Is this filter for a given source?
120
+ *
121
+ * @param string $source Source name.
122
+ * @return boolean
123
+ */
124
+ public function is_for_source( $source ) {
125
+ if ( $this->schema ) {
126
+ return $this->schema->get_type() === $source;
127
+ }
128
+
129
+ return false;
130
+ }
131
+
132
+ /**
133
+ * Get the filter items
134
+ *
135
+ * @param Source\Source $source Optional source.
136
+ * @return list<Type\Filter_Type>
137
+ */
138
+ public function get_items( Source\Source $source ) {
139
+ return $this->items;
140
+ }
141
+
142
+ /**
143
+ * Does this filter have the given column?
144
+ *
145
+ * @param string|object $column Column.
146
+ * @param Schema\Column $schema Schema.
147
+ * @return boolean
148
+ */
149
+ public function has_column( $column, Schema\Column $schema ) {
150
+ $column_name = is_object( $column ) ? $column->get_column_name() : $column;
151
+
152
+ foreach ( $this->items as $item ) {
153
+ if ( in_array( $column_name, $item->get_actual_columns(), true ) ) {
154
+ return true;
155
+ }
156
+ }
157
+
158
+ return false;
159
+ }
160
+
161
+ /**
162
+ * Get all columns for this filter.
163
+ *
164
+ * @return string[]
165
+ */
166
+ public function get_columns() {
167
+ $columns = [];
168
+
169
+ foreach ( $this->items as $item ) {
170
+ $columns = array_merge( $columns, $item->get_columns() );
171
+ }
172
+
173
+ return array_unique( $columns );
174
+ }
175
+
176
+ /**
177
+ * Get array of Search\Column objects that match this filter.
178
+ *
179
+ * @param array<Search\Column> $existing Existing array.
180
+ * @param Source\Source $source Source.
181
+ * @param array $row Raw data from the row.
182
+ * @param Action\Action $action Action.
183
+ * @return array<Search\Column>
184
+ */
185
+ public function get_matching_filter( array $existing, Source\Source $source, array $row, Action\Action $action ) {
186
+ $match_count = 0; // The number of items that must match
187
+ $matched_count = 0; // The number of matching items that matched
188
+
189
+ // At least one matching filter must match
190
+ foreach ( $this->get_items( $source ) as $item ) {
191
+ $match_count += $item->is_matching() ? 1 : 0;
192
+ $column_values = $item->get_values_for_row( $row );
193
+
194
+ foreach ( $column_values as $column => $value ) {
195
+ $contexts = $item->get_column_data( $column, $value, $source, $action );
196
+
197
+ if ( isset( $existing[ $column ] ) ) {
198
+ $existing[ $column ]->add_contexts_if_matching( $contexts );
199
+ } else {
200
+ $existing[ $column ] = new Search\Column( $column, $source->get_column_label( $column ), $contexts, $column_values );
201
+ }
202
+
203
+ $matched_count += count( array_filter( $contexts, function( $item ) {
204
+ return $item->is_matched();
205
+ } ) );
206
+ }
207
+ }
208
+
209
+ if ( ( $match_count > 0 && $matched_count > 0 ) || ( $match_count === 0 && $matched_count === 0 ) ) {
210
+ return $existing;
211
+ }
212
+
213
+ return [];
214
+ }
215
+
216
+ /**
217
+ * Get an Sql\Query for this filter.
218
+ *
219
+ * @param Source\Source $source Source.
220
+ * @return Sql\Query
221
+ */
222
+ public function get_query( Source\Source $source ) {
223
+ $query = new Sql\Query();
224
+ $wheres = [];
225
+
226
+ foreach ( $this->get_items( $source ) as $filter ) {
227
+ $new_query = $filter->get_query();
228
+
229
+ if ( $filter->is_advanced() ) {
230
+ $query->add_select_only( $new_query );
231
+ } else {
232
+ $new_query = $filter->modify_query( $new_query );
233
+
234
+ $wheres = array_merge( $wheres, $query->add_query_except_where( $new_query ) );
235
+ }
236
+ }
237
+
238
+ $query->add_where( new Sql\Where\Where_Or( $wheres ) );
239
+ return $query;
240
+ }
241
+
242
+ /**
243
+ * Get an array of filters as SQL. Each filter is ANDed with the next
244
+ *
245
+ * @param array<Filter> $filters Filters.
246
+ * @param Source\Source $source Source.
247
+ * @return Sql\Query
248
+ */
249
+ public static function get_as_query( array $filters, Source\Source $source ) {
250
+ $query = new Sql\Query();
251
+
252
+ foreach ( $filters as $filter ) {
253
+ $query->add_query( $filter->get_query( $source ) );
254
+ }
255
+
256
+ return $query;
257
+ }
258
+
259
+ /**
260
+ * Get the results as Search\Text
261
+ *
262
+ * @param Source\Source $source Source.
263
+ * @param array $row Row data.
264
+ * @param Action\Action $action Action.
265
+ * @return Search\Column[]
266
+ */
267
+ public static function get_result_matches( Source\Source $source, $row, Action\Action $action ) {
268
+ $filters = $source->get_filters();
269
+ $matched = [];
270
+
271
+ // Get each filter group. There must be one 'match' in each group
272
+ foreach ( $filters as $filter ) {
273
+ $matched = $filter->get_matching_filter( $matched, $source, $row, $action );
274
+
275
+ if ( count( $matched ) === 0 ) {
276
+ return [];
277
+ }
278
+ }
279
+
280
+ return $matched;
281
+ }
282
+
283
+ /**
284
+ * Is this an advanced filter?
285
+ *
286
+ * @return boolean
287
+ */
288
+ public function is_advanced() {
289
+ foreach ( $this->items as $item ) {
290
+ if ( $item->is_advanced() ) {
291
+ return true;
292
+ }
293
+ }
294
+
295
+ return false;
296
+ }
297
+
298
+ /**
299
+ * Get an array of Filter objects to retrieve data from any column that is otherwise missing. For example, for 'view columns'. If a column is already present then a filter will
300
+ * not be crearted.
301
+ *
302
+ * @param Schema\Schema $schema Schema for all sources.
303
+ * @param array<Filter> $filters Filters.
304
+ * @param array<string> $view Array of column names in format `source__column`.
305
+ * @return array<Filter>
306
+ */
307
+ public static function get_missing_column_filters( Schema\Schema $schema, array $filters, array $view ) {
308
+ $filter_columns = [];
309
+
310
+ foreach ( $filters as $filter ) {
311
+ foreach ( $filter->items as $item ) {
312
+ if ( $filter->schema ) {
313
+ $filter_columns[] = $filter->schema->get_type() . '__' . $item->get_schema()->get_column();
314
+ }
315
+ }
316
+ }
317
+
318
+ // Get any column that isn't defined by a filter
319
+ $missing = array_diff( $view, $filter_columns );
320
+
321
+ $new_filter = [];
322
+
323
+ foreach ( $missing as $view_item ) {
324
+ $parts = explode( '__', $view_item );
325
+
326
+ if ( count( $parts ) === 2 ) {
327
+ $found = false;
328
+ $source = $schema->get_for_source( $parts[0] );
329
+ if ( ! $source ) {
330
+ continue;
331
+ }
332
+
333
+ $column = $source->get_column( $parts[1] );
334
+ if ( ! $column ) {
335
+ continue;
336
+ }
337
+
338
+ foreach ( $filters as $filter ) {
339
+ if ( $filter->is_for_source( $parts[0] ) ) {
340
+ if ( ! $filter->has_column( $parts[1], $column ) ) {
341
+ // Add to existing filter for this source and column
342
+ $new_item = Type\Filter_Type::create( [], $column );
343
+
344
+ if ( $new_item ) {
345
+ $new_item->set_non_matching();
346
+ $filter->add_item( $new_item );
347
+ }
348
+ }
349
+
350
+ $found = true;
351
+ break;
352
+ }
353
+ }
354
+
355
+ if ( ! $found ) {
356
+ if ( ! isset( $new_filter[ $parts[0] ] ) ) {
357
+ $new_filter[ $parts[0] ] = new Filter( [ 'type' => $parts[0] ], $schema );
358
+ }
359
+
360
+ $new_item = Type\Filter_Type::create( [], $column );
361
+
362
+ if ( $new_item ) {
363
+ $new_item->set_non_matching();
364
+ $new_filter[ $parts[0] ]->add_item( $new_item );
365
+ }
366
+ }
367
+ }
368
+ }
369
+
370
+ if ( count( $new_filter ) > 0 ) {
371
+ return array_merge( $filters, array_values( $new_filter ) );
372
+ }
373
+
374
+ return $filters;
375
+ }
376
+
377
+ /**
378
+ * Convert to a JSON object
379
+ *
380
+ * @return array
381
+ */
382
+ public function to_json() {
383
+ if ( ! $this->schema ) {
384
+ return [];
385
+ }
386
+
387
+ return [
388
+ 'type' => $this->schema->get_type(),
389
+ 'items' => array_map( function( $item ) {
390
+ return $item->to_json();
391
+ }, $this->items ),
392
+ ];
393
+ }
394
+ }
includes/filter/filter-base.php ADDED
@@ -0,0 +1,214 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Filter\Type;
4
+
5
+ use SearchRegex\Sql;
6
+ use SearchRegex\Source;
7
+ use SearchRegex\Context;
8
+ use SearchRegex\Action;
9
+ use SearchRegex\Schema;
10
+
11
+ /**
12
+ * A column search filter.
13
+ */
14
+ abstract class Filter_Type {
15
+ /**
16
+ * Column schema
17
+ *
18
+ * @readonly
19
+ * @var Schema\Column
20
+ */
21
+ protected $schema;
22
+
23
+ /**
24
+ * Should this filter check for matches?
25
+ *
26
+ * @var boolean
27
+ */
28
+ private $is_matching = true;
29
+
30
+ /**
31
+ * Constructor
32
+ *
33
+ * @param array $item Filter item data.
34
+ * @param Schema\Column $schema Column schema.
35
+ */
36
+ public function __construct( array $item, Schema\Column $schema ) {
37
+ $this->schema = $schema;
38
+ }
39
+
40
+ /**
41
+ * Mark this filter as non-matching
42
+ *
43
+ * @return void
44
+ */
45
+ public function set_non_matching() {
46
+ $this->is_matching = false;
47
+ }
48
+
49
+ /**
50
+ * Is this filter a matching filter?
51
+ *
52
+ * @return boolean
53
+ */
54
+ public function is_matching() {
55
+ return $this->is_matching;
56
+ }
57
+
58
+ /**
59
+ * Get the columns for this filter
60
+ *
61
+ * @return list<string>
62
+ */
63
+ public function get_columns() {
64
+ return [ $this->schema->get_column() ];
65
+ }
66
+
67
+ /**
68
+ * Get the actual columns for this filter
69
+ *
70
+ * @return list<string>
71
+ */
72
+ public function get_actual_columns() {
73
+ return [ $this->schema->get_column() ];
74
+ }
75
+
76
+ /**
77
+ * Get the column schema
78
+ *
79
+ * @return Schema\Column
80
+ */
81
+ public function get_schema() {
82
+ return $this->schema;
83
+ }
84
+
85
+ /**
86
+ * Create an appropriate Filter\Filter_Item object
87
+ *
88
+ * @param array $item Filter item data.
89
+ * @param Schema\Column $schema Column schema.
90
+ * @return Filter\Filter_Item|false
91
+ */
92
+ public static function create( array $item, Schema\Column $schema ) {
93
+ if ( $schema->get_type() === 'string' ) {
94
+ return new Filter_String( $item, $schema );
95
+ }
96
+
97
+ if ( $schema->get_type() === 'integer' ) {
98
+ return new Filter_Integer( $item, $schema );
99
+ }
100
+
101
+ if ( $schema->get_type() === 'member' ) {
102
+ return new Filter_Member( $item, $schema );
103
+ }
104
+
105
+ if ( $schema->get_type() === 'date' ) {
106
+ return new Filter_Date( $item, $schema );
107
+ }
108
+
109
+ if ( $schema->get_type() === 'keyvalue' ) {
110
+ return new Filter_Keyvalue( $item, $schema );
111
+ }
112
+
113
+ return false;
114
+ }
115
+
116
+ /**
117
+ * Is this filter item valid?
118
+ *
119
+ * @return boolean
120
+ */
121
+ public function is_valid() {
122
+ return true;
123
+ }
124
+
125
+ /**
126
+ * Convert the filter to JSON
127
+ *
128
+ * @return array
129
+ */
130
+ abstract public function to_json();
131
+
132
+ /**
133
+ * Get this filter as a SQL statement. Each item within the filter is ORed together
134
+ *
135
+ * @return Sql\Query
136
+ */
137
+ abstract public function get_query();
138
+
139
+ /**
140
+ * Get the filter match context
141
+ *
142
+ * @param string $column Column name.
143
+ * @param string $value Row value.
144
+ * @param Source\Source $source Source.
145
+ * @param Action\Action $action Action.
146
+ * @return Context\Context[]
147
+ */
148
+ abstract public function get_column_data( $column, $value, Source\Source $source, Action\Action $action );
149
+
150
+ /**
151
+ * Get a matched Context\Context
152
+ *
153
+ * @param Source\Source $source Source.
154
+ * @param string $value Value.
155
+ * @param string $label Label for value.
156
+ * @return list<Context\Context>
157
+ */
158
+ public function get_matched_context( Source\Source $source, $value, $label = null ) {
159
+ return [ new Context\Type\Matched( $value, $label ? $label : $source->convert_result_value( $this->schema, $value ) ) ];
160
+ }
161
+
162
+ /**
163
+ * Get a unmatched Context\Context
164
+ *
165
+ * @param Source\Source $source Source.
166
+ * @param string $value Value.
167
+ * @param string $label Label for value.
168
+ * @return list<Context\Context>
169
+ */
170
+ public function get_unmatched_context( Source\Source $source, $value, $label = null ) {
171
+ if ( ! $label ) {
172
+ $label = $source->convert_result_value( $this->schema, $value );
173
+ }
174
+
175
+ return [ new Context\Type\Value( $value, $label ) ];
176
+ }
177
+
178
+ /**
179
+ * Does this filter require advanced searching?
180
+ *
181
+ * @return boolean
182
+ */
183
+ public function is_advanced() {
184
+ return false;
185
+ }
186
+
187
+ /**
188
+ * Get the columns this filter uses from a row of data
189
+ *
190
+ * @param array $row Row of data from database.
191
+ * @return array<string,string>
192
+ */
193
+ public function get_values_for_row( array $row ) {
194
+ $values = [];
195
+
196
+ foreach ( $this->get_actual_columns() as $column ) {
197
+ if ( array_key_exists( $column, $row ) ) {
198
+ $values[ $column ] = $row[ $column ];
199
+ }
200
+ }
201
+
202
+ return $values;
203
+ }
204
+
205
+ /**
206
+ * Modify the query for this filter.
207
+ *
208
+ * @param Sql\Query $query Query.
209
+ * @return Sql\Query
210
+ */
211
+ public function modify_query( Sql\Query $query ) {
212
+ return $query;
213
+ }
214
+ }
includes/filter/filter-date.php ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Filter\Type;
4
+
5
+ use SearchRegex\Sql;
6
+ use SearchRegex\Action;
7
+ use SearchRegex\Source;
8
+ use SearchRegex\Schema;
9
+
10
+ /**
11
+ * Filter a date column.
12
+ */
13
+ class Filter_Date extends Filter_Type {
14
+ const LOGIC = [ 'equals', 'notequals', 'greater', 'less', 'range' ];
15
+
16
+ /**
17
+ * Date value to filter on, or start date in a range
18
+ *
19
+ * @readonly
20
+ * @var integer|false
21
+ */
22
+ protected $start_value = false;
23
+
24
+ /**
25
+ * End date value in a range
26
+ *
27
+ * @readonly
28
+ * @var integer|false
29
+ */
30
+ protected $end_value = false;
31
+
32
+ /**
33
+ * Logic to perform against the date
34
+ *
35
+ * @readonly
36
+ * @var string
37
+ */
38
+ protected $logic = 'equals';
39
+
40
+ /**
41
+ * Constructor
42
+ *
43
+ * @param array $item JSON settings.
44
+ * @param Schema\Column $schema Schema.
45
+ */
46
+ public function __construct( array $item, Schema\Column $schema ) {
47
+ parent::__construct( $item, $schema );
48
+
49
+ if ( isset( $item['startValue'] ) ) {
50
+ $this->start_value = strtotime( $item['startValue'] );
51
+ }
52
+
53
+ if ( isset( $item['endValue'] ) ) {
54
+ $this->end_value = strtotime( $item['endValue'] );
55
+ }
56
+
57
+ if ( isset( $item['logic'] ) && in_array( strtolower( $item['logic'] ), self::LOGIC, true ) ) {
58
+ $this->logic = strtolower( $item['logic'] );
59
+ }
60
+ }
61
+
62
+ public function to_json() {
63
+ return [
64
+ 'column' => $this->schema->get_column(),
65
+ 'startValue' => $this->start_value,
66
+ 'endValue' => $this->end_value,
67
+ 'logic' => $this->logic,
68
+ ];
69
+ }
70
+
71
+ public function is_valid() {
72
+ if ( $this->logic === 'range' ) {
73
+ return $this->start_value !== false && $this->end_value !== false && parent::is_valid();
74
+ }
75
+
76
+ return $this->start_value !== false && parent::is_valid();
77
+ }
78
+
79
+ public function get_query() {
80
+ $query = new Sql\Query();
81
+ $select = new Sql\Select\Select_Column( $this->schema );
82
+
83
+ if ( $this->start_value !== false ) {
84
+ if ( $this->logic === 'range' && $this->end_value !== false ) {
85
+ $lower = new Sql\Where\Where_Date( $select, '>', $this->start_value );
86
+ $upper = new Sql\Where\Where_Date( $select, '<', $this->end_value );
87
+
88
+ $where = new Sql\Where\Where_And( [ $lower, $upper ] );
89
+ } else {
90
+ $where = new Sql\Where\Where_Date( $select, $this->logic, $this->start_value );
91
+ }
92
+
93
+ $query->add_where( $where );
94
+ }
95
+
96
+ $query->add_select( $select );
97
+
98
+ return $query;
99
+ }
100
+
101
+ public function get_column_data( $column, $value, Source\Source $source, Action\Action $action ) {
102
+ $date = mysql2date( 'U', $value );
103
+
104
+ if ( $this->start_value !== false ) {
105
+ $matched = false;
106
+
107
+ if ( $this->logic === 'equals' ) {
108
+ $matched = $date === $this->start_value;
109
+ } elseif ( $this->logic === 'notequals' ) {
110
+ $matched = $date !== $this->start_value;
111
+ } elseif ( $this->logic === 'greater' ) {
112
+ $matched = $date > $this->start_value;
113
+ } elseif ( $this->logic === 'less' ) {
114
+ $matched = $date < $this->start_value;
115
+ } elseif ( $this->logic === 'range' ) {
116
+ $matched = $date > $this->start_value && $date < $this->end_value;
117
+ }
118
+
119
+ if ( $matched ) {
120
+ return $this->get_matched_context( $source, $value );
121
+ }
122
+ }
123
+
124
+ return $this->get_unmatched_context( $source, $value );
125
+ }
126
+ }
includes/filter/filter-integer.php ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Filter\Type;
4
+
5
+ use SearchRegex\Sql;
6
+ use SearchRegex\Source;
7
+ use SearchRegex\Action;
8
+ use SearchRegex\Schema;
9
+
10
+ /**
11
+ * Filter a number column.
12
+ */
13
+ class Filter_Integer extends Filter_Type {
14
+ const LOGIC = [ 'equals', 'notequals', 'greater', 'less', 'range', 'notrange', 'has', 'hasnot' ];
15
+
16
+ /**
17
+ * Number value to filter on, or start number in a range
18
+ *
19
+ * @readonly
20
+ * @var integer
21
+ */
22
+ protected $start_value = 0;
23
+
24
+ /**
25
+ * End number in a range
26
+ *
27
+ * @readonly
28
+ * @var integer
29
+ */
30
+ protected $end_value = 0;
31
+
32
+ /**
33
+ * Logic to filter with
34
+ *
35
+ * @readonly
36
+ * @var string
37
+ */
38
+ protected $logic = 'equals';
39
+
40
+ /**
41
+ * Does this filter have all the correct values?
42
+ *
43
+ * @readonly
44
+ * @var boolean
45
+ */
46
+ protected $has_value = false;
47
+
48
+ /**
49
+ * Join object
50
+ *
51
+ * @readonly
52
+ * @var Sql\Join|null
53
+ */
54
+ protected $join = null;
55
+
56
+ public function __construct( array $item, Schema\Column $schema ) {
57
+ parent::__construct( $item, $schema );
58
+
59
+ if ( isset( $item['startValue'] ) && $item['startValue'] !== '' ) {
60
+ $this->start_value = intval( $item['startValue'], 10 );
61
+ $this->has_value = true;
62
+ }
63
+
64
+ if ( isset( $item['endValue'] ) && $item['endValue'] !== '' ) {
65
+ $this->end_value = max( intval( $item['endValue'], 10 ), $this->start_value );
66
+ $this->has_value = true;
67
+ }
68
+
69
+ if ( isset( $item['logic'] ) && in_array( strtolower( $item['logic'] ), self::LOGIC, true ) ) {
70
+ $this->logic = strtolower( $item['logic'] );
71
+ }
72
+
73
+ $joined_by = $schema->get_joined_by();
74
+ if ( ( $this->logic === 'has' || $this->logic === 'hasnot' ) && $joined_by !== null ) {
75
+ $this->join = Sql\Join\Join::create( $joined_by, $schema->get_source() );
76
+
77
+ if ( $this->join && ( $this->join instanceof Sql\Join\Comment || $this->join instanceof Sql\Join\Post || $this->join instanceof Sql\Join\User ) ) {
78
+ $this->join->set_logic( $this->logic );
79
+ $this->has_value = true;
80
+ }
81
+ }
82
+ }
83
+
84
+ public function to_json() {
85
+ return [
86
+ 'column' => $this->schema->get_column(),
87
+ 'startValue' => $this->start_value,
88
+ 'endValue' => $this->end_value,
89
+ 'logic' => $this->logic,
90
+ ];
91
+ }
92
+
93
+ public function is_valid() {
94
+ return $this->has_value;
95
+ }
96
+
97
+ /**
98
+ * Get integer value
99
+ *
100
+ * @return integer
101
+ */
102
+ public function get_value() {
103
+ return $this->start_value;
104
+ }
105
+
106
+ public function get_query() {
107
+ $query = new Sql\Query();
108
+ $select = new Sql\Select\Select_Column( $this->schema );
109
+
110
+ if ( $this->is_valid() ) {
111
+ $where = false;
112
+
113
+ if ( $this->logic === 'range' ) {
114
+ $lower = new Sql\Where\Where_Integer( $select, '>=', $this->start_value );
115
+ $upper = new Sql\Where\Where_Integer( $select, '<=', $this->end_value );
116
+
117
+ $where = new Sql\Where\Where_And( [ $lower, $upper ] );
118
+ } elseif ( $this->logic === 'notrange' ) {
119
+ $lower = new Sql\Where\Where_Integer( $select, '<=', $this->start_value );
120
+ $upper = new Sql\Where\Where_Integer( $select, '>=', $this->end_value );
121
+
122
+ $where = new Sql\Where\Where_Or( [ $lower, $upper ] );
123
+ } elseif ( $this->logic !== 'has' && $this->logic !== 'hasnot' ) {
124
+ $where = new Sql\Where\Where_Integer( $select, $this->logic, $this->start_value );
125
+ }
126
+
127
+ if ( $this->join ) {
128
+ $query->add_join( $this->join );
129
+ } elseif ( $where ) {
130
+ $query->add_where( $where );
131
+ }
132
+ }
133
+
134
+ $query->add_select( $select );
135
+
136
+ return $query;
137
+ }
138
+
139
+ public function get_column_data( $column, $value, Source\Source $source, Action\Action $action ) {
140
+ $value = intval( $value, 10 );
141
+
142
+ if ( $this->has_value ) {
143
+ $matched = false;
144
+
145
+ if ( $this->logic === 'equals' ) {
146
+ $matched = $this->start_value === $value;
147
+ } elseif ( $this->logic === 'notequals' ) {
148
+ $matched = $this->start_value !== $value;
149
+ } elseif ( $this->logic === 'greater' ) {
150
+ $matched = $value > $this->start_value;
151
+ } elseif ( $this->logic === 'less' ) {
152
+ $matched = $value < $this->start_value;
153
+ } elseif ( $this->logic === 'range' ) {
154
+ $matched = $value >= $this->start_value && $value <= $this->end_value;
155
+ } elseif ( $this->logic === 'notrange' ) {
156
+ $matched = $value <= $this->start_value || $value >= $this->end_value;
157
+ } elseif ( $this->logic === 'has' || $this->logic === 'hasnot' ) {
158
+ // Logic is done in SQL
159
+ $matched = true;
160
+ }
161
+
162
+ if ( $matched ) {
163
+ return $this->get_matched_context( $source, (string) $value );
164
+ }
165
+ }
166
+
167
+ return $this->get_unmatched_context( $source, (string) $value );
168
+ }
169
+
170
+ public function modify_query( Sql\Query $query ) {
171
+ if ( $this->join ) {
172
+ $where = $this->join->get_where();
173
+
174
+ if ( $where ) {
175
+ $query->add_where( $where );
176
+ }
177
+ }
178
+
179
+ return $query;
180
+ }
181
+ }
includes/filter/filter-keyvalue.php ADDED
@@ -0,0 +1,311 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Filter\Type;
4
+
5
+ use SearchRegex\Sql;
6
+ use SearchRegex\Source;
7
+ use SearchRegex\Action;
8
+ use SearchRegex\Schema;
9
+ use SearchRegex\Search;
10
+
11
+ /**
12
+ * Filter a key/value column (meta data)
13
+ */
14
+ class Filter_Keyvalue extends Filter_Type {
15
+ /**
16
+ * Logic to use for key
17
+ *
18
+ * @readonly
19
+ * @var string
20
+ */
21
+ private $key_logic = 'any';
22
+
23
+ /**
24
+ * Logic to use for value
25
+ *
26
+ * @readonly
27
+ * @var string
28
+ */
29
+ private $value_logic = 'any';
30
+
31
+ /**
32
+ * Key value
33
+ *
34
+ * @readonly
35
+ * @var string|null
36
+ */
37
+ private $key = null;
38
+
39
+ /**
40
+ * Key value flags
41
+ *
42
+ * @readonly
43
+ * @var Search\Flags
44
+ */
45
+ private $key_flags;
46
+
47
+ /**
48
+ * Value
49
+ *
50
+ * @readonly
51
+ * @var string|null
52
+ */
53
+ private $value = null;
54
+
55
+ /**
56
+ * Value flags
57
+ *
58
+ * @readonly
59
+ * @var Search\Flags
60
+ */
61
+ private $value_flags;
62
+
63
+ /**
64
+ * Key join
65
+ *
66
+ * @readonly
67
+ * @var Sql\Join\Meta|null
68
+ */
69
+ private $join_key = null;
70
+
71
+ /**
72
+ * Value join
73
+ *
74
+ * @readonly
75
+ * @var Sql\Join\Meta|null
76
+ */
77
+ private $join_value = null;
78
+
79
+ public function __construct( array $item, Schema\Column $schema ) {
80
+ parent::__construct( $item, $schema );
81
+
82
+ if ( ! empty( $item['key'] ) ) {
83
+ $this->key = $item['key'];
84
+ }
85
+
86
+ if ( ! empty( $item['value'] ) ) {
87
+ $this->value = $item['value'];
88
+ }
89
+
90
+ if ( isset( $item['keyLogic'] ) && in_array( strtolower( $item['keyLogic'] ), Filter\Filter_String::LOGIC, true ) ) {
91
+ $this->key_logic = strtolower( $item['keyLogic'] );
92
+ }
93
+
94
+ if ( isset( $item['valueLogic'] ) && in_array( strtolower( $item['valueLogic'] ), Filter\Filter_String::LOGIC, true ) ) {
95
+ $this->value_logic = strtolower( $item['valueLogic'] );
96
+ }
97
+
98
+ if ( isset( $item['keyLogic'] ) && $item['keyLogic'] === 'any' ) {
99
+ $this->key = null;
100
+ }
101
+
102
+ if ( isset( $item['valueLogic'] ) && $item['valueLogic'] === 'any' ) {
103
+ $this->value = null;
104
+ }
105
+
106
+ $joiner = $schema->get_join_column();
107
+ if ( $joiner !== null ) {
108
+ if ( $this->key || $this->key_logic === 'any' ) {
109
+ $join = Sql\Join\Join::create( $schema->get_column() . '_key', $joiner );
110
+
111
+ if ( $join instanceof Sql\Join\Meta ) {
112
+ $this->join_key = $join;
113
+ }
114
+ }
115
+
116
+ if ( $this->value || $this->value_logic === 'any' ) {
117
+ $join = Sql\Join\Join::create( $schema->get_column() . '_value', $joiner );
118
+
119
+ if ( $join instanceof Sql\Join\Meta ) {
120
+ $this->join_value = $join;
121
+ }
122
+ }
123
+ }
124
+
125
+ $this->key_flags = new Search\Flags( isset( $item['keyFlags'] ) ? $item['keyFlags'] : [ 'case' ] );
126
+ $this->value_flags = new Search\Flags( isset( $item['valueFlags'] ) ? $item['valueFlags'] : [ 'case' ] );
127
+ }
128
+
129
+ public function set_non_matching() {
130
+ parent::set_non_matching();
131
+
132
+ if ( $this->join_key ) {
133
+ $this->join_key->set_non_matching();
134
+ }
135
+
136
+ if ( $this->join_value ) {
137
+ $this->join_value->set_non_matching();
138
+ }
139
+ }
140
+
141
+ public function to_json() {
142
+ return [
143
+ 'column' => $this->schema->get_column(),
144
+ 'key' => $this->key,
145
+ 'value' => $this->value,
146
+ 'keyLogic' => $this->key_logic,
147
+ 'valueLogic' => $this->value_logic,
148
+ 'keyFlags' => $this->key_flags->to_json(),
149
+ 'valueFlags' => $this->value_flags->to_json(),
150
+ ];
151
+ }
152
+
153
+ public function is_valid() {
154
+ return $this->key || $this->value;
155
+ }
156
+
157
+ public function get_values_for_row( $row ) {
158
+ if ( isset( $row['meta_id'] ) && $this->join_key !== null ) {
159
+ if ( $row['meta_id'] === '0' ) {
160
+ return [ 'meta' => implode( ',', $this->join_key->get_all_values( intval( array_values( $row )[0], 10 ) ) ) ];
161
+ }
162
+
163
+ return [ 'meta' => $row['meta_id'] ];
164
+ }
165
+
166
+ return [];
167
+ }
168
+
169
+ public function get_query() {
170
+ $query = new Sql\Query();
171
+
172
+ if ( $this->join_key ) {
173
+ $query->add_join( $this->join_key );
174
+ }
175
+
176
+ if ( $this->join_value ) {
177
+ $query->add_join( $this->join_value );
178
+ }
179
+
180
+ if ( $this->is_valid() ) {
181
+ $wheres = [];
182
+
183
+ if ( $this->key && $this->join_key !== null ) {
184
+ $wheres[] = new Sql\Where\Where_String( new Sql\Select\Select( Sql\Value::table( $this->join_key->get_table() ), Sql\Value::column( $this->schema->get_column() . '_key' ), Sql\Value::column( 'meta' ) ), $this->key_logic, $this->key, $this->key_flags );
185
+ }
186
+
187
+ if ( $this->value && $this->join_value !== null ) {
188
+ $wheres[] = new Sql\Where\Where_String( new Sql\Select\Select( Sql\Value::table( $this->join_value->get_table() ), Sql\Value::column( $this->schema->get_column() . '_value' ), Sql\Value::column( 'meta' ) ), $this->value_logic, $this->value, $this->value_flags );
189
+ }
190
+
191
+ $query->add_select( new Sql\Select\Select_Column( $this->schema ) );
192
+ $query->add_where( new Sql\Where\Where_And( $wheres ) );
193
+ }
194
+
195
+ return $query;
196
+ }
197
+
198
+ public function get_column_data( $column, $value, Source\Source $source, Action\Action $action ) {
199
+ $meta_contexts = [];
200
+ $raw_values = array_values( array_filter( explode( ',', $value ) ) );
201
+ if ( count( $raw_values ) === 0 ) {
202
+ return [];
203
+ }
204
+
205
+ $raw_values = array_map( 'intval', $raw_values );
206
+ $meta_values = [];
207
+ if ( $this->join_key ) {
208
+ $meta_values = $this->join_key->get_values( $raw_values );
209
+ } elseif ( $this->join_value ) {
210
+ $meta_values = $this->join_value->get_values( $raw_values );
211
+ }
212
+
213
+ foreach ( $raw_values as $pos => $value ) {
214
+ $meta_contexts[ $value ] = [
215
+ 'key' => [],
216
+ 'value' => [],
217
+ ];
218
+
219
+ // Get the key
220
+ if ( $this->join_key ) {
221
+ $context = $this->get_value_context( $source, $action, $this->schema->get_column() . '_key', $meta_values[ $pos ]->meta_key );
222
+
223
+ if ( count( $context ) > 0 ) {
224
+ $meta_contexts[ $value ]['key'] = $context[0];
225
+ }
226
+ }
227
+
228
+ // Get the value
229
+ if ( $this->join_value ) {
230
+ $context = $this->get_value_context( $source, $action, $this->schema->get_column() . '_value', $meta_values[ $pos ]->meta_value );
231
+
232
+ if ( count( $context ) > 0 ) {
233
+ $meta_contexts[ $value ]['value'] = $context[0];
234
+ }
235
+ }
236
+ }
237
+
238
+ // Merge the contexts together
239
+ $contexts = [];
240
+ foreach ( $meta_contexts as $context ) {
241
+ if ( $this->join_key && $this->join_value && $context['key'] instanceof Context\Type\Value && $context['value'] instanceof Context\Type\Value ) {
242
+ $contexts[] = new Context\Type\Pair( $context['key'], $context['value'] );
243
+ } elseif ( $this->join_key ) {
244
+ $contexts[] = $context['key'];
245
+ } elseif ( $this->join_value ) {
246
+ $contexts[] = $context['value'];
247
+ }
248
+ }
249
+
250
+ $contexts = array_filter( $contexts );
251
+
252
+ foreach ( $contexts as $pos => $context ) {
253
+ $context->set_context_id( $pos );
254
+ }
255
+
256
+ return $contexts;
257
+ }
258
+
259
+ /**
260
+ * Get contexts for a value
261
+ *
262
+ * @param Source\Source $source Source.
263
+ * @param Action $action Action.
264
+ * @param string $column Column.
265
+ * @param string $label Label.
266
+ * @return array
267
+ */
268
+ private function get_value_context( Source\Source $source, Action\Action $action, $column, $label ) {
269
+ // We can shortcut equals or notequals
270
+ if ( $column === $this->schema->get_column() . '_key' && $this->key !== null ) {
271
+ return $this->get_value( $source, $action, $this->key_logic, $this->key, $this->key_flags, $label );
272
+ }
273
+
274
+ if ( $this->value !== null ) {
275
+ return $this->get_value( $source, $action, $this->value_logic, $this->value, $this->value_flags, $label );
276
+ }
277
+
278
+ return [];
279
+ }
280
+
281
+ /**
282
+ * Get context for a keyvalue match
283
+ *
284
+ * @param Source\Source $source Source.
285
+ * @param Action\Action $action Action.
286
+ * @param string $logic Logic.
287
+ * @param string $match_value Value.
288
+ * @param Search\Flags $flags Flags.
289
+ * @param string $label Label.
290
+ * @return Context\Context[]
291
+ */
292
+ private function get_value( Source\Source $source, Action\Action $action, $logic, $match_value, $flags, $label ) {
293
+ $matched = $label === $match_value;
294
+ $equal_match = $logic === 'equals' && $matched;
295
+ $notequal_unmatched = $logic === 'notequals' && ! $matched;
296
+
297
+ if ( $equal_match || $notequal_unmatched ) {
298
+ return $this->get_matched_context( $source, $label, $label );
299
+ }
300
+
301
+ $equal_unmatch = $logic === 'equals' && ! $matched;
302
+ $notequal_matched = $logic === 'notequals' && $matched;
303
+ if ( $equal_unmatch || $notequal_matched || $logic === 'any' ) {
304
+ return $this->get_unmatched_context( $source, $label, $label );
305
+ }
306
+
307
+ $string = new Filter\Filter_String( [], $this->schema );
308
+
309
+ return $string->get_match( $source, $action, $logic, $match_value, $label, $flags );
310
+ }
311
+ }
includes/filter/filter-member.php ADDED
@@ -0,0 +1,192 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Filter\Type;
4
+
5
+ use SearchRegex\Sql;
6
+ use SearchRegex\Source;
7
+ use SearchRegex\Action;
8
+ use SearchRegex\Context\Type;
9
+ use SearchRegex\Schema;
10
+
11
+ /**
12
+ * Filter on a member column
13
+ */
14
+ class Filter_Member extends Filter_Type {
15
+ const LOGIC = [ 'include', 'exclude' ];
16
+
17
+ /**
18
+ * List of values
19
+ *
20
+ * @readonly
21
+ * @var list<string>
22
+ */
23
+ private $values = [];
24
+
25
+ /**
26
+ * Logic to filter with
27
+ *
28
+ * @readonly
29
+ * @var string
30
+ */
31
+ private $logic = 'include';
32
+
33
+ /**
34
+ * Join
35
+ *
36
+ * @var Sql\Join|null
37
+ */
38
+ private $join = null;
39
+
40
+ public function __construct( array $item, Schema\Column $schema ) {
41
+ parent::__construct( $item, $schema );
42
+
43
+ if ( isset( $item['values'] ) && is_array( $item['values'] ) && count( $item['values'] ) > 0 ) {
44
+ $this->values = array_map( function( $item ) {
45
+ if ( is_numeric( $item ) ) {
46
+ return intval( $item, 10 );
47
+ }
48
+
49
+ return $item;
50
+ }, $item['values'] );
51
+ }
52
+
53
+ if ( isset( $item['logic'] ) && in_array( strtolower( $item['logic'] ), self::LOGIC, true ) ) {
54
+ $this->logic = strtolower( $item['logic'] );
55
+ }
56
+
57
+ if ( $this->schema->get_join_column() ) {
58
+ $this->join = Sql\Join\Join::create( $this->schema->get_column(), $schema->get_source() );
59
+ }
60
+ }
61
+
62
+ public function set_non_matching() {
63
+ parent::set_non_matching();
64
+
65
+ if ( $this->join ) {
66
+ $this->join->set_non_matching();
67
+ }
68
+ }
69
+
70
+ public function to_json() {
71
+ return [
72
+ 'column' => $this->schema->get_column(),
73
+ 'values' => $this->values,
74
+ 'logic' => $this->logic,
75
+ ];
76
+ }
77
+
78
+ /**
79
+ * Get all the member values
80
+ *
81
+ * @return array
82
+ */
83
+ public function get_values() {
84
+ return $this->values;
85
+ }
86
+
87
+ public function is_valid() {
88
+ return count( $this->values ) > 0 && parent::is_valid();
89
+ }
90
+
91
+ public function get_query() {
92
+ $query = new Sql\Query();
93
+ $select = new Sql\Select\Select_Column( $this->schema );
94
+
95
+ if ( $this->join ) {
96
+ $query->add_join( $this->join );
97
+ }
98
+
99
+ if ( $this->is_valid() ) {
100
+ $where = new Sql\Where\Where_In( $select, $this->logic === 'exclude' ? 'NOT IN' : 'IN', $this->values );
101
+ $query->add_where( $where );
102
+ }
103
+
104
+ $query->add_select( $select );
105
+ return $query;
106
+ }
107
+
108
+ public function get_values_for_row( $row ) {
109
+ $values = parent::get_values_for_row( $row );
110
+
111
+ if ( ! $this->join instanceof Sql\Join\Meta && ! $this->join instanceof Sql\Join\Term ) {
112
+ return $values;
113
+ }
114
+
115
+ if ( isset( $values[ $this->schema->get_column() ] ) && count( $values ) === 1 && $values[ $this->schema->get_column() ] === '0' ) {
116
+ return [ $this->schema->get_column() => implode( ',', $this->join->get_all_values( intval( array_values( $row )[0], 10 ) ) ) ];
117
+ }
118
+
119
+ return $values;
120
+ }
121
+
122
+ public function get_column_data( $column, $value, Source\Source $source, Action\Action $action ) {
123
+ if ( $this->join ) {
124
+ $values = explode( ',', $value );
125
+ } else {
126
+ $values = [ $value ];
127
+ }
128
+
129
+ $contexts = [];
130
+ foreach ( $values as $value ) {
131
+ $contexts = array_merge( $contexts, $this->get_value_context( $value, $source ) );
132
+ }
133
+
134
+ foreach ( $contexts as $pos => $context ) {
135
+ $context->set_context_id( $pos );
136
+ }
137
+
138
+ // If everything is unmatched then return nothing, otherwise return something
139
+ return $contexts;
140
+ }
141
+
142
+ /**
143
+ * Get context for value
144
+ *
145
+ * @param string|integer $value Value.
146
+ * @param Source\Source $source Source.
147
+ * @return Context\Context[]
148
+ */
149
+ private function get_value_context( $value, Source\Source $source ) {
150
+ if ( is_numeric( $value ) ) {
151
+ $value = intval( $value, 10 );
152
+ }
153
+
154
+ if ( count( $this->values ) > 0 ) {
155
+ $matched = in_array( $value, $this->values, true );
156
+
157
+ if ( $this->logic === 'exclude' && ! $matched ) {
158
+ return $this->get_matched_context( $source, (string) $value );
159
+ }
160
+
161
+ if ( $this->logic === 'include' && $matched ) {
162
+ return $this->get_matched_context( $source, (string) $value );
163
+ }
164
+
165
+ if ( $this->join ) {
166
+ $label = $this->join->get_join_value( (string) $value );
167
+
168
+ return $this->get_unmatched_context( $source, (string) $value, $label );
169
+ }
170
+ }
171
+
172
+ if ( $this->join && $value === '' ) {
173
+ return [ new Type\Empty_Type() ];
174
+ }
175
+
176
+ return $this->get_unmatched_context( $source, (string) $value );
177
+ }
178
+
179
+ public function modify_query( Sql\Query $query ) {
180
+ if ( $this->join !== null ) {
181
+ $join_wheres = $this->join->get_where();
182
+
183
+ if ( $join_wheres ) {
184
+ $where = new Sql\Where\Where_And( array_merge( $query->get_where(), [ $join_wheres ] ) );
185
+ $query->reset_where();
186
+ $query->add_where( $where );
187
+ }
188
+ }
189
+
190
+ return $query;
191
+ }
192
+ }
includes/filter/filter-string.php ADDED
@@ -0,0 +1,167 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Filter\Type;
4
+
5
+ use SearchRegex\Sql;
6
+ use SearchRegex\Source;
7
+ use SearchRegex\Action;
8
+ use SearchRegex\Schema;
9
+ use SearchRegex\Search;
10
+
11
+ /**
12
+ * Filter a string column
13
+ */
14
+ class Filter_String extends Filter_Type {
15
+ const BEFORE = '<SEARCHREGEX>';
16
+ const AFTER = '</SEARCHREGEX>';
17
+ const LOGIC = [ 'equals', 'notequals', 'contains', 'notcontains', 'begins', 'ends' ];
18
+
19
+ /**
20
+ * The value
21
+ *
22
+ * @readonly
23
+ * @var string
24
+ */
25
+ private $value = '';
26
+
27
+ /**
28
+ * Filter logic
29
+ *
30
+ * @readonly
31
+ * @var string
32
+ */
33
+ private $logic = 'equals';
34
+
35
+ /**
36
+ * Search flags
37
+ *
38
+ * @readonly
39
+ * @var Search\Flags
40
+ */
41
+ private $flags;
42
+
43
+ /**
44
+ * Does this filter have everything it needs?
45
+ *
46
+ * @var boolean
47
+ */
48
+ private $has_value = false;
49
+
50
+ public function __construct( array $item, Schema\Column $schema ) {
51
+ parent::__construct( $item, $schema );
52
+
53
+ if ( isset( $item['value'] ) && is_string( $item['value'] ) ) {
54
+ $this->value = $item['value'];
55
+ $this->has_value = true;
56
+ }
57
+
58
+ if ( isset( $item['logic'] ) && in_array( strtolower( $item['logic'] ), self::LOGIC, true ) ) {
59
+ $this->logic = strtolower( $item['logic'] );
60
+ }
61
+
62
+ $this->flags = new Search\Flags( isset( $item['flags'] ) ? $item['flags'] : [ 'case' ] );
63
+ }
64
+
65
+ public function to_json() {
66
+ return [
67
+ 'column' => $this->schema->get_column(),
68
+ 'value' => $this->value,
69
+ 'logic' => $this->logic,
70
+ 'flags' => $this->flags->to_json(),
71
+ ];
72
+ }
73
+
74
+ public function is_valid() {
75
+ return $this->logic && $this->has_value && parent::is_valid();
76
+ }
77
+
78
+ public function get_query() {
79
+ $query = new Sql\Query();
80
+ $select = new Sql\Select\Select_Column( $this->schema );
81
+
82
+ $query->add_select( $select );
83
+
84
+ if ( $this->is_valid() ) {
85
+ $where = new Sql\Where\Where_String( $select, $this->logic, $this->value, $this->flags );
86
+ $query->add_where( $where );
87
+ }
88
+
89
+ return $query;
90
+ }
91
+
92
+ public function get_column_data( $column, $value, Source\Source $source, Action\Action $action ) {
93
+ return $this->get_match( $source, $action, $this->logic, $this->value, $value ? $value : '', $this->flags );
94
+ }
95
+
96
+ /**
97
+ * Match this filter against a string
98
+ *
99
+ * @param Source\Source $source Source.
100
+ * @param Action $action Action.
101
+ * @param string $logic Logic.
102
+ * @param string $original_value Original value.
103
+ * @param string $row_value Current value.
104
+ * @param Search\Flags $flags Flags.
105
+ * @return list<Context\Context>
106
+ */
107
+ public function get_match( Source\Source $source, Action\Action $action, $logic, $original_value, $row_value, Search\Flags $flags, $replacements = [] ) {
108
+ if ( $original_value ) {
109
+ $flag_copy = Search\Flags::copy( $flags );
110
+ $value = $original_value;
111
+
112
+ // Turn a plain match into a regex for easy matching
113
+ if ( ! $flag_copy->is_regex() ) {
114
+ $start = '^';
115
+ $end = '$';
116
+
117
+ if ( $logic === 'contains' || $logic === 'notcontains' || $logic === 'ends' ) {
118
+ $start = '';
119
+ }
120
+
121
+ if ( $logic === 'contains' || $logic === 'notcontains' || $logic === 'begins' ) {
122
+ $end = '';
123
+ }
124
+
125
+ $flag_copy->set_regex();
126
+ $value = $start . preg_quote( $original_value, null ) . $end;
127
+ }
128
+
129
+ // Do we have a match?
130
+ $contexts = Search\Text::get_all( $value, $flag_copy, $replacements, $row_value );
131
+ if ( count( $contexts ) > 0 ) {
132
+ if ( $logic === 'notcontains' || $logic === 'notequals' ) {
133
+ return $this->get_unmatched_context( $source, $row_value );
134
+ }
135
+
136
+ if ( $row_value !== '' ) {
137
+ // Set the original flags and search terms
138
+ return array_map( function( $context ) use ( $flags, $original_value ) {
139
+ $context->set_search( $original_value, $flags );
140
+ return $context;
141
+ }, $contexts );
142
+ }
143
+ }
144
+
145
+ // Return the value itself
146
+ if ( $logic === 'notcontains' || $logic === 'notequals' ) {
147
+ // This 'matches'
148
+ return $this->get_matched_context( $source, $row_value );
149
+ }
150
+ }
151
+
152
+ return $this->get_unmatched_context( $source, $row_value );
153
+ }
154
+
155
+ public function is_advanced() {
156
+ return $this->flags->is_regex();
157
+ }
158
+
159
+ /**
160
+ * Get string value
161
+ *
162
+ * @return string
163
+ */
164
+ public function get_value() {
165
+ return $this->value;
166
+ }
167
+ }
includes/modifier/class-modifier.php ADDED
@@ -0,0 +1,175 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Modifier;
4
+
5
+ use SearchRegex\Schema;
6
+ use SearchRegex\Modifier\Value;
7
+ use SearchRegex\Search;
8
+ use SearchRegex\Source;
9
+
10
+ require_once __DIR__ . '/modifier-string.php';
11
+ require_once __DIR__ . '/modifier-member.php';
12
+ require_once __DIR__ . '/modifier-integer.php';
13
+ require_once __DIR__ . '/modifier-date.php';
14
+ require_once __DIR__ . '/modifier-keyvalue.php';
15
+
16
+ /**
17
+ * Modify a column
18
+ */
19
+ abstract class Modifier {
20
+ /**
21
+ * Operation to perform
22
+ *
23
+ * @var string|null
24
+ */
25
+ protected $operation = null;
26
+
27
+ /**
28
+ * Schema
29
+ *
30
+ * @var Schema\Column
31
+ */
32
+ protected $schema;
33
+
34
+ /**
35
+ * Constructor
36
+ *
37
+ * @param array $option Modification options.
38
+ * @param Schema\Column $schema Schema.
39
+ */
40
+ public function __construct( array $option, Schema\Column $schema ) {
41
+ $this->schema = $schema;
42
+ $this->operation = '';
43
+ }
44
+
45
+ /**
46
+ * The schema source name
47
+ *
48
+ * @return string
49
+ */
50
+ public function get_source_name() {
51
+ return $this->schema->get_source();
52
+ }
53
+
54
+ /**
55
+ * Get schema column name.
56
+ *
57
+ * @return string
58
+ */
59
+ public function get_column_name() {
60
+ return $this->schema->get_column();
61
+ }
62
+
63
+ /**
64
+ * Get schema
65
+ *
66
+ * @return Schema\Column
67
+ */
68
+ public function get_schema() {
69
+ return $this->schema;
70
+ }
71
+
72
+ /**
73
+ * Does the column match?
74
+ *
75
+ * @param string $column Column.
76
+ * @return boolean
77
+ */
78
+ public function is_for_column( $column ) {
79
+ return $this->get_column_name() === $column;
80
+ }
81
+
82
+ /**
83
+ * Get the data for this column
84
+ *
85
+ * @param array $row Array of database columns.
86
+ * @return string|false
87
+ */
88
+ public function get_row_data( array $row ) {
89
+ if ( isset( $row[ $this->get_column_name() ] ) ) {
90
+ return $row[ $this->get_column_name() ];
91
+ }
92
+
93
+ return false;
94
+ }
95
+
96
+ /**
97
+ * Create a column modifier
98
+ *
99
+ * @param array $option Options.
100
+ * @param Schema\Source $schema Schema.
101
+ * @return Modifier|null
102
+ */
103
+ public static function create( $option, Schema\Source $schema ) {
104
+ $column = $schema->get_column( isset( $option['column'] ) ? $option['column'] : '' );
105
+ if ( ! $column ) {
106
+ return null;
107
+ }
108
+
109
+ if ( $column->get_type() === 'integer' ) {
110
+ return new Value\Integer_Value( $option, $column );
111
+ }
112
+
113
+ if ( $column->get_type() === 'string' ) {
114
+ return new Value\String_Value( $option, $column );
115
+ }
116
+
117
+ if ( $column->get_type() === 'date' ) {
118
+ return new Value\Date_Value( $option, $column );
119
+ }
120
+
121
+ if ( $column->get_type() === 'member' ) {
122
+ return new Value\Member_Value( $option, $column );
123
+ }
124
+
125
+ if ( $column->get_type() === 'keyvalue' ) {
126
+ return new Value\Keyvalue_Value( $option, $column );
127
+ }
128
+
129
+ return null;
130
+ }
131
+
132
+ /**
133
+ * Is this modifier valid?
134
+ *
135
+ * @return boolean
136
+ */
137
+ public function is_valid() {
138
+ return $this->operation !== null;
139
+ }
140
+
141
+ /**
142
+ * Get changes for this modifier and value
143
+ *
144
+ * @param string $value Value.
145
+ * @return array|null
146
+ */
147
+ public function get_change( $value ) {
148
+ return null;
149
+ }
150
+
151
+ /**
152
+ * Convert the modifier to JSON
153
+ *
154
+ * @return array
155
+ */
156
+ public function to_json() {
157
+ return [
158
+ 'column' => $this->get_column_name(),
159
+ 'source' => $this->get_source_name(),
160
+ ];
161
+ }
162
+
163
+ /**
164
+ * Perform the modifier on a column
165
+ *
166
+ * @param integer $row_id Row ID.
167
+ * @param string $row_value Row value.
168
+ * @param Source\Source $source Source.
169
+ * @param Search\Column $column Column.
170
+ * @param array $raw Raw database data.
171
+ * @param boolean $save_mode Is the save mode enabled.
172
+ * @return Search\Column
173
+ */
174
+ abstract public function perform( $row_id, $row_value, Source\Source $source, Search\Column $column, array $raw, $save_mode );
175
+ }
includes/modifier/modifier-date.php ADDED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Modifier\Value;
4
+
5
+ use SearchRegex\Sql;
6
+ use SearchRegex\Schema;
7
+ use SearchRegex\Search;
8
+ use SearchRegex\Modifier;
9
+ use SearchRegex\Source;
10
+ use SearchRegex\Context;
11
+
12
+ /**
13
+ * Modify a date column
14
+ */
15
+ class Date_Value extends Modifier\Modifier {
16
+ const UNITS = [ 'second', 'minute', 'hour', 'day', 'week', 'month', 'year' ];
17
+
18
+ /**
19
+ * Date value
20
+ *
21
+ * @var integer|null
22
+ */
23
+ private $value = null;
24
+
25
+ /**
26
+ * Units of the value
27
+ *
28
+ * @var 'second'|'minute'|'hour'|'day'|'week'|'month'|'year'
29
+ */
30
+ private $unit = 'hour';
31
+
32
+ public function __construct( array $option, Schema\Column $schema ) {
33
+ parent::__construct( $option, $schema );
34
+
35
+ $this->operation = 'set';
36
+ if ( isset( $option['operation'] ) && in_array( $option['operation'], [ 'set', 'increment', 'decrement' ], true ) ) {
37
+ $this->operation = $option['operation'];
38
+ }
39
+
40
+ if ( isset( $option['value'] ) ) {
41
+ $this->value = $this->operation === 'set' ? strtotime( $option['value'] ) : intval( $option['value'], 10 );
42
+ }
43
+
44
+ if ( isset( $option['unit'] ) && in_array( $option['unit'], self::UNITS, true ) && $this->operation !== 'set' ) {
45
+ $this->unit = $option['unit'];
46
+ }
47
+ }
48
+
49
+ public function to_json() {
50
+ return array_merge(
51
+ parent::to_json(),
52
+ [
53
+ 'operation' => $this->operation,
54
+ 'value' => $this->value,
55
+ 'unit' => $this->unit,
56
+ ]
57
+ );
58
+ }
59
+
60
+ /**
61
+ * Perform a date operation - add or subtract
62
+ *
63
+ * @param integer $value1 Value 1.
64
+ * @param integer $value2 Value 2.
65
+ * @return integer
66
+ */
67
+ private function perform_operation( $value1, $value2 ) {
68
+ if ( $this->operation === 'increment' ) {
69
+ return $value1 + $value2;
70
+ }
71
+
72
+ return $value1 - $value2;
73
+ }
74
+
75
+ /**
76
+ * Apply a unit calculation to a date
77
+ *
78
+ * @param string $unit Unit.
79
+ * @param integer $date Date.
80
+ * @return integer
81
+ */
82
+ private function get_changed_date( $unit, $date ) {
83
+ $hour = intval( date( 'G', $date ), 10 );
84
+ $minute = intval( date( 'i', $date ), 10 );
85
+ $second = intval( date( 's', $date ), 10 );
86
+ $month = intval( date( 'n', $date ), 10 );
87
+ $day = intval( date( 'j', $date ), 10 );
88
+ $year = intval( date( 'Y', $date ), 10 );
89
+
90
+ if ( $this->value === null ) {
91
+ return 0;
92
+ }
93
+
94
+ if ( $unit === 'second' ) {
95
+ $second = $this->perform_operation( $second, $this->value );
96
+ } elseif ( $unit === 'minute' ) {
97
+ $minute = $this->perform_operation( $minute, $this->value );
98
+ } elseif ( $unit === 'hour' ) {
99
+ $hour = $this->perform_operation( $hour, $this->value );
100
+ } elseif ( $unit === 'day' ) {
101
+ $day = $this->perform_operation( $day, $this->value );
102
+ } elseif ( $unit === 'week' ) {
103
+ $day = $this->perform_operation( $day, $this->value * 7 );
104
+ } elseif ( $unit === 'month' ) {
105
+ $month = $this->perform_operation( $month, $this->value );
106
+ } elseif ( $unit === 'year' ) {
107
+ $year = $this->perform_operation( $year, $this->value );
108
+ }
109
+
110
+ return mktime( $hour, $minute, $second, $month, $day, $year );
111
+ }
112
+
113
+ public function perform( $row_id, $row_value, Source\Source $source, Search\Column $column, array $raw, $save_mode ) {
114
+ // Go through contexts and find the matching action that modifies it
115
+ if ( count( $column->get_contexts() ) === 1 ) {
116
+ $context = $column->get_contexts()[0];
117
+ if ( ! $context instanceof Context\Type\Value ) {
118
+ return $column;
119
+ }
120
+
121
+ $date = $this->value;
122
+ $value = $context->get_value();
123
+ $mysql_date = mysql2date( 'U', (string) $value );
124
+
125
+ if ( $this->operation === 'increment' || $this->operation === 'decrement' ) {
126
+ $date = $this->get_changed_date( $this->unit, intval( $mysql_date, 10 ) );
127
+ }
128
+
129
+ if ( $date !== $value && $date !== null ) {
130
+ $context = new Context\Type\Replace( $value );
131
+ $date = date( 'Y-m-d H:i:s', $date );
132
+ $context->set_replacement( $date, $source->convert_result_value( $this->schema, $date ) );
133
+ $column->set_contexts( [ $context ] );
134
+ }
135
+ }
136
+
137
+ return $column;
138
+ }
139
+ }
includes/modifier/modifier-integer.php ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Modifier\Value;
4
+
5
+ use SearchRegex\Schema;
6
+ use SearchRegex\Search;
7
+ use SearchRegex\Source;
8
+ use SearchRegex\Modifier;
9
+ use SearchRegex\Context;
10
+
11
+ class Integer_Value extends Modifier\Modifier {
12
+ /**
13
+ * Modification Value
14
+ *
15
+ * @var integer|null
16
+ */
17
+ private $value = null;
18
+
19
+ public function __construct( array $option, Schema\Column $schema ) {
20
+ parent::__construct( $option, $schema );
21
+
22
+ if ( isset( $option['value'] ) ) {
23
+ $this->value = intval( $option['value'], 10 );
24
+ }
25
+
26
+ $this->operation = 'set';
27
+ if ( isset( $option['operation'] ) && in_array( $option['operation'], [ 'set', 'increment', 'decrement' ], true ) ) {
28
+ $this->operation = $option['operation'];
29
+ }
30
+ }
31
+
32
+ public function to_json() {
33
+ return array_merge(
34
+ parent::to_json(),
35
+ [
36
+ 'operation' => $this->operation,
37
+ 'value' => $this->value,
38
+ ]
39
+ );
40
+ }
41
+
42
+ public function perform( $row_id, $row_value, Source\Source $source, Search\Column $column, array $raw, $save_mode ) {
43
+ // Go through contexts and find the matching action that modifies it
44
+ if ( count( $column->get_contexts() ) === 1 && $this->value !== null ) {
45
+ $context = $column->get_contexts()[0];
46
+ if ( ! $context instanceof Context\Type\Value ) {
47
+ return $column;
48
+ }
49
+
50
+ $value = $context->get_value();
51
+
52
+ if ( $this->operation === 'increment' ) {
53
+ $replacement = intval( $value, 10 ) + $this->value;
54
+ $context = new Context\Type\Replace( $value );
55
+ $context->set_replacement( "{$replacement}", $source->convert_result_value( $this->schema, (string) $replacement ) );
56
+ } elseif ( $this->operation === 'decrement' ) {
57
+ $replacement = max( 0, intval( $value, 10 ) - $this->value );
58
+ $context = new Context\Type\Replace( $value );
59
+ $context->set_replacement( "{$replacement}", $source->convert_result_value( $this->schema, (string) $replacement ) );
60
+ } elseif ( intval( $this->value, 10 ) !== intval( $value, 10 ) ) {
61
+ $context = new Context\Type\Replace( $value );
62
+ $context->set_replacement( "{$this->value}", $source->convert_result_value( $this->schema, (string) $this->value ) );
63
+ }
64
+
65
+ $column->set_contexts( [ $context ] );
66
+ }
67
+
68
+ return $column;
69
+ }
70
+ }
includes/modifier/modifier-keyvalue.php ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Modifier\Value;
4
+
5
+ use SearchRegex\Schema;
6
+ use SearchRegex\Search;
7
+ use SearchRegex\Modifier;
8
+ use SearchRegex\Source;
9
+ use SearchRegex\Context;
10
+
11
+ class Key_Value extends Modifier\Modifier {
12
+ /**
13
+ * Array of key/value pairs
14
+ *
15
+ * @var array
16
+ */
17
+ private $items = [];
18
+
19
+ public function __construct( array $option, Schema\Column $schema ) {
20
+ parent::__construct( $option, $schema );
21
+
22
+ $this->operation = 'add';
23
+ if ( isset( $option['operation'] ) && in_array( $option['operation'], [ 'add', 'remove' ], true ) ) {
24
+ $this->operation = $option['operation'];
25
+ }
26
+
27
+ if ( isset( $option['items'] ) ) {
28
+ $this->items = array_values( array_filter( array_map( [ $this, 'add_item' ], $option['items'] ) ) );
29
+ }
30
+
31
+ if ( isset( $option['key'] ) ) {
32
+ $this->items = [ $this->add_item( $option ) ];
33
+ }
34
+ }
35
+
36
+ public function to_json() {
37
+ return array_merge(
38
+ parent::to_json(),
39
+ [
40
+ 'operation' => $this->operation,
41
+ 'items' => $this->items,
42
+ ]
43
+ );
44
+ }
45
+
46
+ public function get_row_data( array $row ) {
47
+ if ( isset( $row['meta_id'] ) ) {
48
+ return $row['meta_id'];
49
+ }
50
+
51
+ return false;
52
+ }
53
+
54
+ /**
55
+ * Add an item to the list of items if it is valid, otherwise return null
56
+ *
57
+ * @param array|string $item Item.
58
+ * @return array|null
59
+ */
60
+ public function add_item( $item ) {
61
+ if ( ! is_array( $item ) ) {
62
+ return null;
63
+ }
64
+
65
+ $new_item = [];
66
+ if ( isset( $item['key'] ) && isset( $item['value'] ) ) {
67
+ $new_item['key'] = $item['key'];
68
+ $new_item['value'] = $item['value'];
69
+
70
+ if ( isset( $item['type'] ) ) {
71
+ $new_item['type'] = $item['type'];
72
+ }
73
+
74
+ $new_item['value_type'] = 'value';
75
+ if ( isset( $item['value_type'] ) ) {
76
+ $new_item['value_type'] = $item['value_type'];
77
+ }
78
+
79
+ return $new_item;
80
+ }
81
+
82
+ return null;
83
+ }
84
+
85
+ public function is_for_column( $column ) {
86
+ return $column === $this->schema->get_column() . '_key' || $column === $this->schema->get_column() . '_value' || $column === $this->schema->get_column();
87
+ }
88
+
89
+ public function perform( $row_id, $row_value, Source\Source $source, Search\Column $column, array $raw, $save_mode ) {
90
+ $replace = [];
91
+
92
+ // Go through contexts and find the matching action that modifies it
93
+ foreach ( $column->get_contexts() as $pos => $context ) {
94
+ $match = $this->items[ $pos ];
95
+
96
+ if ( $match['type'] === 'delete' ) {
97
+ $replace[] = new Context\Type\Pair( new Context\Type\Delete( $match['key'] ), new Context\Type\Delete( $match['value'] ) );
98
+ } elseif ( $context instanceof Context\Type\Pair && ( $match['type'] === 'replace' || $match['value_type'] === 'replace' ) ) {
99
+ $key = $context->get_key();
100
+
101
+ if ( $match['type'] === 'replace' && $key instanceof Context\Type\Value ) {
102
+ $key = new Context\Type\Replace( $key->get_value() );
103
+ $key->set_replacement( $match['key'] );
104
+ }
105
+
106
+ $value = $context->get_value();
107
+ if ( $match['value_type'] === 'replace' && $value instanceof Context\Type\Value ) {
108
+ $value = new Context\Type\Replace( $value->get_value() );
109
+ $value->set_replacement( $match['value'] );
110
+ }
111
+
112
+ $replace[] = new Context\Type\Pair( $key, $value );
113
+ } else {
114
+ $replace[] = $context;
115
+ }
116
+ }
117
+
118
+ // Go through items and add any new ones
119
+ foreach ( array_slice( $this->items, count( $column->get_contexts() ) ) as $item ) {
120
+ $replace[] = new Context\Type\Pair( new Context\Type\Add( $item['key'] ), new Context\Type\Add( $item['value'] ) );
121
+ }
122
+
123
+ $column->set_contexts( $replace );
124
+
125
+ return $column;
126
+ }
127
+ }
includes/modifier/modifier-member.php ADDED
@@ -0,0 +1,162 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Modifier\Value;
4
+
5
+ use SearchRegex\Schema;
6
+ use SearchRegex\Search;
7
+ use SearchRegex\Source;
8
+ use SearchRegex\Modifier;
9
+ use SearchRegex\Context;
10
+
11
+ /**
12
+ * Modifier for member columns
13
+ */
14
+ class Member_Value extends Modifier\Modifier {
15
+ /**
16
+ * Array of values
17
+ *
18
+ * @var array<string|integer>
19
+ */
20
+ private $values = [];
21
+
22
+ public function __construct( array $option, Schema\Column $schema ) {
23
+ parent::__construct( $option, $schema );
24
+
25
+ $this->operation = 'replace';
26
+ if ( isset( $option['operation'] ) && in_array( $option['operation'], [ 'replace', 'include', 'exclude' ], true ) ) {
27
+ $this->operation = $option['operation'];
28
+ }
29
+
30
+ if ( $schema->get_options() ) {
31
+ $this->values = [ $schema->get_options()[0]['value'] ];
32
+ }
33
+
34
+ if ( isset( $option['values'] ) && is_array( $option['values'] ) ) {
35
+ $this->values = array_map( [ $this, 'get_value' ], $option['values'] );
36
+ }
37
+ }
38
+
39
+ public function to_json() {
40
+ return array_merge(
41
+ parent::to_json(),
42
+ [
43
+ 'operation' => $this->operation,
44
+ 'values' => $this->values,
45
+ ]
46
+ );
47
+ }
48
+
49
+ /**
50
+ * Determine if it's a numeric of string value and get the appropriate value.
51
+ *
52
+ * @param string|integer $value Value.
53
+ * @return string|integer
54
+ */
55
+ private function get_value( $value ) {
56
+ if ( is_numeric( $value ) ) {
57
+ return intval( $value, 10 );
58
+ }
59
+
60
+ return $value;
61
+ }
62
+
63
+ /**
64
+ * Get the Match_Contexs for the values
65
+ *
66
+ * @param Source\Source $source Source.
67
+ * @param array $values Values.
68
+ * @param callable $cb Functionc allback.
69
+ * @return list<object>
70
+ */
71
+ private function get_contexts( Source\Source $source, array $values, $cb ) {
72
+ $contexts = [];
73
+
74
+ foreach ( $values as $row_value ) {
75
+ /** @psalm-suppress UndefinedClass */
76
+ $contexts[] = new $cb( $row_value, $source->convert_result_value( $this->schema, $row_value ) );
77
+ }
78
+
79
+ return $contexts;
80
+ }
81
+
82
+ /**
83
+ * Get all values that we are not matching
84
+ *
85
+ * @param array<string|integer> $action_values Values to check for.
86
+ * @param array<string|integer> $column_values Values to check against.
87
+ * @return array
88
+ */
89
+ private function get_exclude( $action_values, $column_values ) {
90
+ // Remove any that we're excluding
91
+ $same = array_intersect( $action_values, $column_values );
92
+ $delete = array_diff( $column_values, $action_values );
93
+
94
+ return [ $same, $delete ];
95
+ }
96
+
97
+ /**
98
+ * Get all values that we are matching
99
+ *
100
+ * @param array<string|integer> $action_values Values to check for.
101
+ * @param array<string|integer> $column_values Values to check against.
102
+ * @return array<string|integer>
103
+ */
104
+ private function get_include( $action_values, $column_values ) {
105
+ return array_diff( $action_values, $column_values );
106
+ }
107
+
108
+ public function perform( $row_id, $row_value, Source\Source $source, Search\Column $column, array $raw, $save_mode ) {
109
+ $action_values = $this->values;
110
+ $column_values = array_map(
111
+ function( $context ) {
112
+ return $this->get_value( $context instanceof Context\Type\Value ? $context->get_value() : '' );
113
+ },
114
+ $column->get_contexts()
115
+ );
116
+ $column_values = array_values( array_filter( $column_values ) );
117
+
118
+ // Now create a set of arrays for members that are the same, added, deleted, and updated
119
+ $same = $column_values;
120
+ $add = [];
121
+ $delete = [];
122
+ $updated = [];
123
+
124
+ if ( $this->operation === 'replace' ) {
125
+ $same = array_intersect( $action_values, $column_values );
126
+ $delete = array_diff( $column_values, $action_values );
127
+ $add = array_diff( $action_values, $column_values );
128
+
129
+ // Which one of the 'deletes' can 'replace' an 'add'
130
+ foreach ( $add as $pos => $value ) {
131
+ if ( count( $delete ) > 0 ) {
132
+ $context = new Context\Type\Replace( $delete[0], $source->convert_result_value( $this->schema, (string) $delete[0] ) );
133
+ $context->set_replacement( (string) $value, $source->convert_result_value( $this->schema, (string) $value ) );
134
+ $updated[] = $context;
135
+
136
+ unset( $add[ $pos ] );
137
+ unset( $delete[0] );
138
+ $delete = array_values( $delete );
139
+ }
140
+ }
141
+
142
+ $add = array_values( $add );
143
+ } elseif ( $this->operation === 'exclude' ) {
144
+ list( $same, $delete ) = $this->get_exclude( $action_values, $column_values );
145
+ } elseif ( $this->operation === 'include' ) {
146
+ $add = $this->get_include( $action_values, $column_values );
147
+ }
148
+
149
+ // Replace existing contexts with the new ones
150
+ /** @psalm-suppress all */
151
+ $contexts = array_merge(
152
+ $this->get_contexts( $source, $same, '\SearchRegex\Context\Type\Value' ),
153
+ $this->get_contexts( $source, $add, '\SearchRegex\Context\Type\Add' ),
154
+ $this->get_contexts( $source, $delete, '\SearchRegex\Context\Type\Delete' ),
155
+ $updated,
156
+ );
157
+
158
+ /** @psalm-suppress ArgumentTypeCoercion */
159
+ $column->set_contexts( $contexts );
160
+ return $column;
161
+ }
162
+ }
includes/modifier/modifier-string.php ADDED
@@ -0,0 +1,260 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Modifier\Value;
4
+
5
+ use SearchRegex\Modifier;
6
+ use SearchRegex\Schema;
7
+ use SearchRegex\Source;
8
+ use SearchRegex\Search;
9
+ use SearchRegex\Context;
10
+ use SearchRegex\Filter;
11
+ use SearchRegex\Action;
12
+
13
+ /**
14
+ * Modify a string
15
+ */
16
+ class String_Value extends Modifier\Modifier {
17
+ const BEFORE = '<SEARCHREGEX>';
18
+ const AFTER = '</SEARCHREGEX>';
19
+
20
+ /**
21
+ * Value to search for. Only used in a search/replace
22
+ *
23
+ * @var string|null
24
+ */
25
+ private $search_value = null;
26
+
27
+ /**
28
+ * Value to replace, or the column value in a 'set'
29
+ *
30
+ * @var string|null
31
+ */
32
+ private $replace_value = null;
33
+
34
+ /**
35
+ * Search flags
36
+ *
37
+ * @var Search\Flags
38
+ */
39
+ private $search_flags;
40
+
41
+ /**
42
+ * Position within the column to replace
43
+ *
44
+ * @var integer|null
45
+ */
46
+ private $pos_id = null;
47
+
48
+ public function __construct( array $option, Schema\Column $schema ) {
49
+ parent::__construct( $option, $schema );
50
+
51
+ if ( isset( $option['searchValue'] ) && is_string( $option['searchValue'] ) ) {
52
+ $this->search_value = $option['searchValue'];
53
+ }
54
+
55
+ if ( isset( $option['replaceValue'] ) && is_string( $option['replaceValue'] ) ) {
56
+ $this->replace_value = $option['replaceValue'];
57
+ }
58
+
59
+ $this->operation = 'set';
60
+ if ( isset( $option['operation'] ) && in_array( $option['operation'], [ 'set', 'replace' ], true ) ) {
61
+ $this->operation = $option['operation'];
62
+ }
63
+
64
+ if ( isset( $option['posId'] ) ) {
65
+ $this->pos_id = intval( $option['posId'], 10 );
66
+ }
67
+
68
+ $flags = isset( $option['searchFlags'] ) ? $option['searchFlags'] : [ 'case' ];
69
+ if ( ! is_array( $flags ) ) {
70
+ $flags = [ $flags ];
71
+ }
72
+
73
+ $this->search_flags = new Search\Flags( $flags );
74
+ }
75
+
76
+ public function is_valid() {
77
+ if ( $this->operation === 'replace' && $this->search_value && strlen( $this->search_value ) === 0 ) {
78
+ return false;
79
+ }
80
+
81
+ return parent::is_valid();
82
+ }
83
+
84
+ public function to_json() {
85
+ return array_merge(
86
+ parent::to_json(),
87
+ [
88
+ 'operation' => $this->operation,
89
+ 'searchValue' => $this->search_value,
90
+ 'replaceValue' => $this->replace_value,
91
+ 'searchFlags' => $this->search_flags->to_json(),
92
+ ]
93
+ );
94
+ }
95
+
96
+ /**
97
+ * Return all the replace positions - the positions within the content where the search is matched.
98
+ *
99
+ * @param string $value Value to search and replace within.
100
+ * @return Array Array of match positions
101
+ */
102
+ public function get_replace_positions( $value ) {
103
+ if ( ! $this->search_value || ! $this->replace_value ) {
104
+ return [];
105
+ }
106
+
107
+ $replace_value = $this->replace_value;
108
+ if ( ! $this->search_flags->is_regex() ) {
109
+ // Escape the replace value, in case it has a $ in it
110
+ $replace_value = \preg_replace( '/(?<!\\\)\$/', '\\$', $this->replace_value );
111
+ }
112
+
113
+ // Global replace
114
+ $result = $this->replace_all( $this->search_value, self::BEFORE . $replace_value . self::AFTER, $value );
115
+
116
+ // Split into array
117
+ $pattern = '@' . self::BEFORE . '(.*?)' . self::AFTER . '@';
118
+ if ( $this->search_flags->is_case_insensitive() ) {
119
+ $pattern .= 'i';
120
+ }
121
+
122
+ if ( \preg_match_all( $pattern, $result, $searches ) > 0 ) {
123
+ return $searches[1];
124
+ }
125
+
126
+ return [];
127
+ }
128
+
129
+ /**
130
+ * Perform a global replacement
131
+ *
132
+ * @internal
133
+ * @param String $search Search string.
134
+ * @param String $replace Replacement value.
135
+ * @param String $value Content to replace.
136
+ * @return String
137
+ */
138
+ private function replace_all( $search, $replace, $value ) {
139
+ $pattern = Search\Text::get_pattern( $search, $this->search_flags );
140
+
141
+ if ( ! $this->search_flags->is_regex() && is_serialized( $value ) ) {
142
+ $serial = '/s:(\d*):"(.*?)";/s';
143
+
144
+ return preg_replace_callback( $serial, function( $matches ) use ( $search, $replace ) {
145
+ if ( strpos( $matches[2], $search ) !== false ) {
146
+ $replaced = str_replace( $search, $replace, $matches[2] );
147
+
148
+ return 's:' . (string) strlen( $replaced ) . ':"' . $replaced . '";';
149
+ }
150
+
151
+ return $matches[0];
152
+ }, $value );
153
+ }
154
+
155
+ // Global replace
156
+ return preg_replace( $pattern, $replace, $value );
157
+ }
158
+
159
+ public function perform( $row_id, $row_value, Source\Source $source, Search\Column $column, array $raw, $save_mode ) {
160
+ if ( $this->operation === 'set' ) {
161
+ // Identical - just return value
162
+ if ( $this->replace_value === $row_value ) {
163
+ return $column;
164
+ }
165
+
166
+ /**
167
+ * @psalm-suppress TooManyArguments
168
+ */
169
+ $value = apply_filters( 'searchregex_text', $this->replace_value, $row_id, $row_value, $raw, $source->get_schema_item() );
170
+
171
+ if ( $value !== $row_value ) {
172
+ $replacement = new Context\Type\Replace( $row_value );
173
+ $replacement->set_replacement( $value );
174
+ $column->set_contexts( [ $replacement ] );
175
+ }
176
+
177
+ return $column;
178
+ }
179
+
180
+ if ( ! $this->search_value ) {
181
+ return $column;
182
+ }
183
+
184
+ if ( $this->pos_id === null ) {
185
+ if ( ! $this->replace_value ) {
186
+ return $column;
187
+ }
188
+
189
+ // When not saving we need to return the individual replacements. If saving then we want to return the whole text
190
+ if ( $save_mode ) {
191
+ $global_replace = $this->replace_all( $this->search_value, $this->replace_value, $row_value );
192
+
193
+ /**
194
+ * @psalm-suppress TooManyArguments
195
+ */
196
+ $value = apply_filters( 'searchregex_text', $global_replace, $row_id, $row_value, $raw, $source->get_schema_item() );
197
+
198
+ // Global replace
199
+ if ( $row_value !== $value ) {
200
+ $replacement = new Context\Type\Replace( $row_value );
201
+ $replacement->set_replacement( $value );
202
+ $column->set_contexts( [ $replacement ] );
203
+ }
204
+
205
+ return $column;
206
+ }
207
+
208
+ $replacements = $this->get_replace_positions( $row_value );
209
+
210
+ $filter = new Filter\Type\Filter_String( [
211
+ 'value' => $this->search_value,
212
+ 'logic' => 'contains',
213
+ 'flags' => $this->search_flags->to_json(),
214
+ ], $this->schema );
215
+ $matches = $filter->get_match( $source, new Action\Type\Nothing(), 'contains', $this->search_value, $row_value, $this->search_flags, $replacements );
216
+
217
+ // If we replaced anything then update the context with our new matches, otherwise just return whatever we have
218
+ if ( ( count( $matches ) === 1 && ! $matches[0] instanceof Context\Type\Value ) || count( $matches ) > 1 ) {
219
+ $column->set_contexts( $matches );
220
+ }
221
+
222
+ return $column;
223
+ }
224
+
225
+ // Replace a specific position
226
+ $replacements = $this->get_replace_positions( $row_value );
227
+ $contexts = Search\Text::get_all( $this->search_value, $this->search_flags, $replacements, $row_value );
228
+
229
+ foreach ( $contexts as $context ) {
230
+ $match = $context->get_match_at_position( $this->pos_id );
231
+
232
+ if ( is_object( $match ) ) {
233
+ /**
234
+ * @psalm-suppress TooManyArguments
235
+ */
236
+ $value = apply_filters( 'searchregex_text', $match->replace_at_position( $row_value ), $row_id, $row_value, $raw, $source->get_schema_item() );
237
+
238
+ // Need to replace the match with the result in the raw data
239
+ if ( $row_value !== $value ) {
240
+ $context = new Context\Type\Replace( $row_value );
241
+ $context->set_replacement( $value );
242
+ $column->set_contexts( [ $context ] );
243
+ }
244
+
245
+ return $column;
246
+ }
247
+ }
248
+
249
+ return $column;
250
+ }
251
+
252
+ /**
253
+ * Get replacement value
254
+ *
255
+ * @return string|null
256
+ */
257
+ public function get_replace_value() {
258
+ return $this->replace_value;
259
+ }
260
+ }
search-regex-capabilities.php → includes/plugin/class-capabilities.php RENAMED
@@ -1,5 +1,7 @@
1
  <?php
2
 
 
 
3
  /**
4
  * Search Regex capabilities
5
  *
@@ -29,7 +31,7 @@
29
  * Note some capabilities may give access to data from others. For example, when viewing a page of redirects via `searchregex_cap_redirect_manage`
30
  * the client will need to access group data.
31
  */
32
- class Search_Regex_Capabilities {
33
  const FILTER_ALL = 'searchregex_capability_all';
34
  const FILTER_PAGES = 'searchregex_capability_pages';
35
  const FILTER_CAPABILITY = 'searchregex_capability_check';
@@ -49,7 +51,7 @@ class Search_Regex_Capabilities {
49
  /**
50
  * Determine if the current user has access to a named capability.
51
  *
52
- * @param string $cap_name The capability to check for. See Search_Regex_Capabilities for constants.
53
  * @return boolean
54
  */
55
  public static function has_access( $cap_name ) {
1
  <?php
2
 
3
+ namespace SearchRegex\Plugin;
4
+
5
  /**
6
  * Search Regex capabilities
7
  *
31
  * Note some capabilities may give access to data from others. For example, when viewing a page of redirects via `searchregex_cap_redirect_manage`
32
  * the client will need to access group data.
33
  */
34
+ class Capabilities {
35
  const FILTER_ALL = 'searchregex_capability_all';
36
  const FILTER_PAGES = 'searchregex_capability_pages';
37
  const FILTER_CAPABILITY = 'searchregex_capability_check';
51
  /**
52
  * Determine if the current user has access to a named capability.
53
  *
54
+ * @param string $cap_name The capability to check for. See Capabilities for constants.
55
  * @return boolean
56
  */
57
  public static function has_access( $cap_name ) {
includes/plugin/class-settings-base.php ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Plugin;
4
+
5
+ abstract class Plugin_Settings {
6
+ /** @var null|Plugin_Settings */
7
+ protected static $instance = null;
8
+
9
+ /**
10
+ * Settings
11
+ *
12
+ * @var array
13
+ */
14
+ protected $settings = [];
15
+
16
+ // Don't allow this to be created directly
17
+ public function __construct() {
18
+ $this->settings = $this->load();
19
+
20
+ $defaults = $this->get_defaults();
21
+
22
+ foreach ( $defaults as $key => $value ) {
23
+ if ( ! isset( $this->settings[ $key ] ) ) {
24
+ $this->settings[ $key ] = $value;
25
+ }
26
+ }
27
+
28
+ // Remove any expired settings
29
+ foreach ( array_keys( $this->settings ) as $key ) {
30
+ if ( ! isset( $defaults[ $key ] ) ) {
31
+ unset( $this->settings[ $key ] );
32
+ }
33
+ }
34
+ }
35
+
36
+ abstract protected function get_setting_name();
37
+
38
+ /**
39
+ * Get default Search Regex options
40
+ *
41
+ * @return Array
42
+ */
43
+ protected function get_defaults() {
44
+ return [];
45
+ }
46
+
47
+ /**
48
+ * Return Search Regex options
49
+ *
50
+ * @param String $name Name of setting.
51
+ * @param mixed $default Default value.
52
+ * @return mixed Data to return
53
+ */
54
+ protected function get( $name, $default = false ) {
55
+ if ( isset( $this->settings[ $name ] ) ) {
56
+ return $this->settings[ $name ];
57
+ }
58
+
59
+ return $default;
60
+ }
61
+
62
+ /**
63
+ * Set Search Regex options. Can be passed as many options as necessary and the rest will be unchanged
64
+ *
65
+ * @param Array $settings Array of name => value.
66
+ * @return void
67
+ */
68
+ protected function set( array $settings ) {
69
+ $this->settings = array_merge( $this->settings, $settings );
70
+ }
71
+
72
+ protected function get_save_data( array $settings ) {
73
+ return $settings;
74
+ }
75
+
76
+ public function save() {
77
+ \update_option( $this->get_setting_name(), $this->get_save_data( $this->settings ) );
78
+ }
79
+
80
+ protected function load() {
81
+ return \get_option( $this->get_setting_name() );
82
+ }
83
+
84
+ public function delete() {
85
+ \delete_option( $this->get_setting_name() );
86
+ }
87
+
88
+ public function get_as_json() {
89
+ return $this->settings;
90
+ }
91
+ }
includes/plugin/class-settings.php ADDED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Plugin;
4
+
5
+ require_once __DIR__ . '/class-settings-base.php';
6
+
7
+ class Settings extends Plugin_Settings {
8
+ /** @var String */
9
+ const OPTION_NAME = 'searchregex_options';
10
+
11
+ /** @var String */
12
+ const API_JSON = 0;
13
+
14
+ /** @var String */
15
+ const API_JSON_INDEX = 1;
16
+
17
+ /** @var String */
18
+ const API_JSON_RELATIVE = 3;
19
+
20
+ /**
21
+ * Initialize the object
22
+ *
23
+ * @return Admin
24
+ */
25
+ public static function init() {
26
+ if ( is_null( self::$instance ) ) {
27
+ self::$instance = new self();
28
+ }
29
+
30
+ return self::$instance;
31
+ }
32
+
33
+ protected function get_setting_name() {
34
+ return self::OPTION_NAME;
35
+ }
36
+
37
+ protected function load() {
38
+ return \apply_filters( 'searchregex_load_options', parent::load() );
39
+ }
40
+
41
+ protected function get_save_data( array $settings ) {
42
+ return \apply_filters( 'searchregex_save_options', $settings );
43
+ }
44
+
45
+ /**
46
+ * Get default Search Regex options
47
+ *
48
+ * @return Array
49
+ */
50
+ protected function get_defaults() {
51
+ $defaults = [
52
+ 'support' => false,
53
+ 'rest_api' => self::API_JSON,
54
+ 'defaultPreset' => 0,
55
+ 'update_notice' => 0,
56
+ ];
57
+
58
+ return \apply_filters( 'searchregex_default_options', $defaults );
59
+ }
60
+
61
+ public function set_rest_api( $rest_api ) {
62
+ $rest_api = intval( $rest_api, 10 );
63
+
64
+ if ( in_array( $rest_api, array( 0, 1, 2, 3, 4 ), true ) ) {
65
+ $this->settings['rest_api'] = $rest_api;
66
+ }
67
+ }
68
+
69
+ public function set_is_supported( $is_supported ) {
70
+ $this->settings['support'] = $is_supported ? true : false;
71
+ }
72
+
73
+ public function set_latest_version() {
74
+ $major_version = explode( '-', SEARCHREGEX_VERSION )[0]; // Remove any beta suffix
75
+ $major_version = implode( '.', array_slice( explode( '.', SEARCHREGEX_VERSION ), 0, 2 ) );
76
+
77
+ $this->settings['update_notice'] = $major_version;
78
+ }
79
+
80
+ public function set_default_preset( $preset_id ) {
81
+ $this->settings['defaultPreset'] = preg_replace( '/[^A-Fa-f0-9]*/', '', $preset_id );
82
+ }
83
+
84
+ public function is_new_version( $major_version ) {
85
+ return version_compare( $this->get( 'update_notice', '0' ), $major_version ) < 0;
86
+ }
87
+
88
+ public function is_supported() {
89
+ return $this->get( 'support' ) ? true : false;
90
+ }
91
+
92
+ public function get_rest_api( $type = false ) {
93
+ if ( $type === false ) {
94
+ $type = $this->get( 'rest_api' );
95
+ }
96
+
97
+ return intval( $type, 10 );
98
+ }
99
+
100
+ /**
101
+ * Get the configured REST API
102
+ *
103
+ * @param boolean $type Type of API.
104
+ * @return String API URL
105
+ */
106
+ public function get_rest_api_url( $type = false ) {
107
+ $type = $this->get_rest_api( $type );
108
+ $url = \get_rest_url(); // API_JSON
109
+
110
+ if ( $type === self::API_JSON_INDEX ) {
111
+ $url = \home_url( '/index.php?rest_route=/' );
112
+ } elseif ( $type === self::API_JSON_RELATIVE ) {
113
+ $relative = \wp_parse_url( $url, PHP_URL_PATH );
114
+
115
+ if ( $relative ) {
116
+ $url = $relative;
117
+ }
118
+ }
119
+
120
+ return $url;
121
+ }
122
+
123
+ public function get_available_rest_api() {
124
+ return [
125
+ self::API_JSON => $this->get_rest_api_url( self::API_JSON ),
126
+ self::API_JSON_INDEX => $this->get_rest_api_url( self::API_JSON_INDEX ),
127
+ self::API_JSON_RELATIVE => $this->get_rest_api_url( self::API_JSON_RELATIVE ),
128
+ ];
129
+ }
130
+
131
+ public function get_default_preset() {
132
+ return $this->get( 'defaultPreset' );
133
+ }
134
+
135
+ /**
136
+ * Can we save data to the database? Useful for disabling saves during debugging
137
+ *
138
+ * @return boolean
139
+ */
140
+ public function can_save() {
141
+ if ( defined( 'SEARCHREGEX_DEBUG' ) && SEARCHREGEX_DEBUG ) {
142
+ return false;
143
+ }
144
+
145
+ return true;
146
+ }
147
+ }
includes/schema/class-column.php ADDED
@@ -0,0 +1,183 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Schema;
4
+
5
+ /**
6
+ * Helper to represent the schema for a column
7
+ */
8
+ class Column {
9
+ /**
10
+ * Column name
11
+ *
12
+ * @var string
13
+ */
14
+ private $column = '';
15
+
16
+ /**
17
+ * Column type
18
+ *
19
+ * @var 'integer'|'string'|'date'|'member'|'keyvalue'
20
+ */
21
+ private $type = 'string';
22
+
23
+ /**
24
+ * Is this a global column?
25
+ *
26
+ * @var boolean
27
+ */
28
+ private $global = false;
29
+
30
+ /**
31
+ * Join column, if any
32
+ *
33
+ * @var string
34
+ */
35
+ private $join = '';
36
+
37
+ /**
38
+ * Joined by column
39
+ *
40
+ * @var string
41
+ */
42
+ private $joined_by = '';
43
+
44
+ /**
45
+ * Any options, if this is a member type
46
+ *
47
+ * @var array<array{value: string, label: string}>
48
+ */
49
+ private $options = [];
50
+
51
+ /**
52
+ * Source name for this column
53
+ *
54
+ * @var Source
55
+ */
56
+ private $source;
57
+
58
+ /**
59
+ * Constructor
60
+ *
61
+ * @param array $schema JSON.
62
+ * @param Source $source Source.
63
+ */
64
+ public function __construct( $schema, Source $source ) {
65
+ $this->source = $source;
66
+
67
+ if ( isset( $schema['type'] ) ) {
68
+ $this->type = $schema['type'];
69
+ }
70
+
71
+ if ( isset( $schema['column'] ) ) {
72
+ $this->column = $schema['column'];
73
+ }
74
+
75
+ if ( isset( $schema['global'] ) ) {
76
+ $this->global = $schema['global'];
77
+ }
78
+
79
+ if ( isset( $schema['join'] ) ) {
80
+ $this->join = $schema['join'];
81
+ }
82
+
83
+ if ( isset( $schema['joined_by'] ) ) {
84
+ $this->joined_by = $schema['joined_by'];
85
+ }
86
+
87
+ if ( isset( $schema['options'] ) && is_array( $schema['options'] ) ) {
88
+ $this->options = $schema['options'];
89
+ }
90
+ }
91
+
92
+ /**
93
+ * Get source name
94
+ *
95
+ * @return string
96
+ */
97
+ public function get_source() {
98
+ return $this->source->get_type();
99
+ }
100
+
101
+ /**
102
+ * Get table name
103
+ *
104
+ * @return string
105
+ */
106
+ public function get_table() {
107
+ return $this->source->get_table();
108
+ }
109
+
110
+ /**
111
+ * Get column type
112
+ *
113
+ * @return string
114
+ */
115
+ public function get_type() {
116
+ return $this->type;
117
+ }
118
+
119
+ /**
120
+ * Get column
121
+ *
122
+ * @return string
123
+ */
124
+ public function get_column() {
125
+ return $this->column;
126
+ }
127
+
128
+ /**
129
+ * Get column join
130
+ *
131
+ * @return string|null
132
+ */
133
+ public function get_join_column() {
134
+ return $this->join;
135
+ }
136
+
137
+ /**
138
+ * Get column joined by
139
+ *
140
+ * @return string|null
141
+ */
142
+ public function get_joined_by() {
143
+ return $this->joined_by;
144
+ }
145
+
146
+ /**
147
+ * Get column options
148
+ *
149
+ * @return array
150
+ */
151
+ public function get_options() {
152
+ return $this->options;
153
+ }
154
+
155
+ /**
156
+ * Get label for a particular column, or false
157
+ *
158
+ * @param string $value Value name.
159
+ * @return string|false
160
+ */
161
+ public function get_option_label( $value ) {
162
+ $options = $this->get_options();
163
+
164
+ if ( $options ) {
165
+ foreach ( $options as $option ) {
166
+ if ( $option['value'] === $value ) {
167
+ return $option['label'];
168
+ }
169
+ }
170
+ }
171
+
172
+ return false;
173
+ }
174
+
175
+ /**
176
+ * Is this a global column?
177
+ *
178
+ * @return boolean
179
+ */
180
+ public function is_global() {
181
+ return $this->global;
182
+ }
183
+ }
includes/schema/class-schema.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Schema;
4
+
5
+ require_once __DIR__ . '/class-source.php';
6
+ require_once __DIR__ . '/class-column.php';
7
+
8
+ /**
9
+ * Helper object to load a source schema and provide access functions
10
+ */
11
+ class Schema {
12
+ /**
13
+ * Array of Source objects
14
+ *
15
+ * @var array<string, Source>
16
+ */
17
+ private $schema = [];
18
+
19
+ /**
20
+ * Constructor
21
+ *
22
+ * @param array $source_schema JSON schema.
23
+ */
24
+ public function __construct( array $source_schema ) {
25
+ foreach ( $source_schema as $schema ) {
26
+ $schema = new Source( $schema );
27
+
28
+ if ( $schema->get_type() ) {
29
+ $this->schema[ $schema->get_type() ] = $schema;
30
+ }
31
+ }
32
+ }
33
+
34
+ /**
35
+ * Get Source for a source.
36
+ *
37
+ * @param string $source_name Source name.
38
+ * @return Source|null
39
+ */
40
+ public function get_for_source( $source_name ) {
41
+ if ( isset( $this->schema[ $source_name ] ) ) {
42
+ return $this->schema[ $source_name ];
43
+ }
44
+
45
+ return null;
46
+ }
47
+
48
+ /**
49
+ * Get list of all sources
50
+ *
51
+ * @return list<Source>
52
+ */
53
+ public function get_sources() {
54
+ return array_values( $this->schema );
55
+ }
56
+ }
includes/schema/class-source.php ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Schema;
4
+
5
+ /**
6
+ * Helper to represent the schema for a source
7
+ */
8
+ class Source {
9
+ /**
10
+ * Source type
11
+ *
12
+ * @var string
13
+ */
14
+ private $type = '';
15
+
16
+ /**
17
+ * Source label
18
+ *
19
+ * @var string
20
+ */
21
+ private $name = '';
22
+
23
+ /**
24
+ * Source table
25
+ *
26
+ * @var string
27
+ */
28
+ private $table = '';
29
+
30
+ /**
31
+ * Array of Column objects
32
+ *
33
+ * @var Column[]
34
+ */
35
+ private $columns = [];
36
+
37
+ /**
38
+ * Constructor
39
+ *
40
+ * @param array $schema_json JSON.
41
+ */
42
+ public function __construct( array $schema_json ) {
43
+ if ( isset( $schema_json['type'] ) ) {
44
+ $this->type = $schema_json['type'];
45
+ }
46
+
47
+ if ( isset( $schema_json['name'] ) ) {
48
+ $this->name = $schema_json['name'];
49
+ }
50
+
51
+ if ( isset( $schema_json['table'] ) ) {
52
+ $this->table = $schema_json['table'];
53
+ }
54
+
55
+ if ( isset( $schema_json['columns'] ) && is_array( $schema_json['columns'] ) ) {
56
+ foreach ( $schema_json['columns'] as $column ) {
57
+ if ( isset( $column['column'] ) ) {
58
+ $this->columns[ $column['column'] ] = new Column( $column, $this );
59
+ }
60
+ }
61
+ }
62
+ }
63
+
64
+ /**
65
+ * Get Column for a column
66
+ *
67
+ * @param string $column_name Name of column.
68
+ * @return Column|null
69
+ */
70
+ public function get_column( $column_name ) {
71
+ if ( isset( $this->columns[ $column_name ] ) ) {
72
+ return $this->columns[ $column_name ];
73
+ }
74
+
75
+ return null;
76
+ }
77
+
78
+ /**
79
+ * Get all columns
80
+ *
81
+ * @return array<Column>
82
+ */
83
+ public function get_columns() {
84
+ return array_values( $this->columns );
85
+ }
86
+
87
+ /**
88
+ * Get all global columns
89
+ *
90
+ * @return array<Column>
91
+ */
92
+ public function get_global_columns() {
93
+ return array_filter( $this->columns, function( $column ) {
94
+ return $column->is_global();
95
+ } );
96
+ }
97
+
98
+ /**
99
+ * Get all joined columns
100
+ *
101
+ * @return array<Column>
102
+ */
103
+ public function get_join_columns() {
104
+ return array_filter(
105
+ $this->columns,
106
+ /** @psalm-suppress all */
107
+ function( Column $column ) {
108
+ return $column->get_join_column();
109
+ }
110
+ );
111
+ }
112
+
113
+ /**
114
+ * Get table name
115
+ *
116
+ * @return string
117
+ */
118
+ public function get_table() {
119
+ return $this->table;
120
+ }
121
+
122
+ /**
123
+ * Get type of source
124
+ *
125
+ * @return string
126
+ */
127
+ public function get_type() {
128
+ return $this->type;
129
+ }
130
+ }
search-regex-admin.php → includes/search-regex-admin.php RENAMED
@@ -1,26 +1,32 @@
1
  <?php
2
 
3
- require_once __DIR__ . '/models/search.php';
4
- require_once __DIR__ . '/models/replace.php';
5
- require_once __DIR__ . '/models/result.php';
6
-
7
- use SearchRegex\Source_Manager;
8
- use SearchRegex\Search_Flags;
9
- use SearchRegex\Source_Flags;
10
- use SearchRegex\Preset;
11
-
12
- class Search_Regex_Admin {
13
- /** @var null|Search_Regex_Admin */
 
 
 
 
 
 
14
  private static $instance = null;
15
 
16
  /**
17
  * Initialize the object
18
  *
19
- * @return Search_Regex_Admin
20
  */
21
  public static function init() {
22
  if ( is_null( self::$instance ) ) {
23
- self::$instance = new Search_Regex_Admin();
24
  }
25
 
26
  return self::$instance;
@@ -33,8 +39,20 @@ class Search_Regex_Admin {
33
  add_action( 'admin_menu', [ $this, 'admin_menu' ] );
34
  add_action( 'plugin_action_links_' . basename( dirname( SEARCHREGEX_FILE ) ) . '/' . basename( SEARCHREGEX_FILE ), [ $this, 'plugin_settings' ], 10, 4 );
35
  add_filter( 'searchregex_result_actions', [ $this, 'extra_actions' ], 10, 3 );
 
 
 
 
 
 
 
 
 
 
 
 
36
 
37
- register_uninstall_hook( SEARCHREGEX_FILE, [ 'Search_Regex_Admin', 'plugin_uninstall' ] );
38
  }
39
 
40
  /**
@@ -43,7 +61,8 @@ class Search_Regex_Admin {
43
  * @return void
44
  */
45
  public static function plugin_uninstall() {
46
- delete_option( SEARCHREGEX_OPTION );
 
47
  delete_option( Preset::OPTION_NAME );
48
  }
49
 
@@ -81,7 +100,8 @@ class Search_Regex_Admin {
81
  * @return String
82
  */
83
  private function get_first_available_page_url() {
84
- $pages = Search_Regex_Capabilities::get_available_pages();
 
85
 
86
  if ( count( $pages ) > 0 ) {
87
  return $this->get_plugin_url() . ( $pages[0] === 'search' ? '' : '&sub=' . rawurlencode( $pages[0] ) );
@@ -113,55 +133,58 @@ class Search_Regex_Admin {
113
 
114
  $build = SEARCHREGEX_VERSION . '-' . SEARCHREGEX_BUILD;
115
  $preload = $this->get_preload_data();
116
- $options = searchregex_get_options();
 
117
  $versions = array(
118
  'Plugin: ' . SEARCHREGEX_VERSION,
119
  'WordPress: ' . $wp_version . ' (' . ( is_multisite() ? 'multi' : 'single' ) . ')',
120
  'PHP: ' . phpversion() . ' ' . ini_get( 'memory_limit' ) . ' ' . ini_get( 'max_execution_time' ) . 's',
121
  'Browser: ' . $this->get_user_agent(),
122
  'JavaScript: ' . plugin_dir_url( SEARCHREGEX_FILE ) . 'search-regex.js',
123
- 'REST API: ' . searchregex_get_rest_api(),
124
  );
125
 
126
- if ( defined( 'SEARCHREGEX_DEV_MODE' ) && SEARCHREGEX_DEV_MODE ) {
127
- wp_enqueue_script( 'search-regex', 'http://localhost:3312/search-regex.js', array(), $build, true );
128
- } else {
129
- wp_enqueue_script( 'search-regex', plugin_dir_url( SEARCHREGEX_FILE ) . 'search-regex.js', array(), $build, true );
130
- }
131
 
132
- wp_enqueue_style( 'search-regex', plugin_dir_url( SEARCHREGEX_FILE ) . 'search-regex.css', array(), $build );
 
133
 
134
- $translations = $this->get_i18n_data();
 
 
 
 
 
 
 
 
 
135
 
136
  wp_localize_script( 'search-regex', 'SearchRegexi10n', array(
137
  'api' => [
138
- 'WP_API_root' => esc_url_raw( searchregex_get_rest_api() ),
139
  'WP_API_nonce' => wp_create_nonce( 'wp_rest' ),
140
  'site_health' => admin_url( 'site-health.php' ),
141
- 'current' => $options['rest_api'],
142
- 'routes' => [
143
- SEARCHREGEX_API_JSON => searchregex_get_rest_api( SEARCHREGEX_API_JSON ),
144
- SEARCHREGEX_API_JSON_INDEX => searchregex_get_rest_api( SEARCHREGEX_API_JSON_INDEX ),
145
- SEARCHREGEX_API_JSON_RELATIVE => searchregex_get_rest_api( SEARCHREGEX_API_JSON_RELATIVE ),
146
- ],
147
  ],
148
  'pluginBaseUrl' => plugins_url( '', SEARCHREGEX_FILE ),
149
  'pluginRoot' => $this->get_plugin_url(),
150
- 'locale' => [
151
- 'translations' => $translations,
152
- 'localeSlug' => get_locale(),
153
- 'Plural-Forms' => isset( $translations['plural-forms'] ) ? $translations['plural-forms'] : 'nplurals=2; plural=n != 1;',
154
- ],
155
- 'settings' => $options,
156
  'preload' => $preload,
157
  'versions' => implode( "\n", $versions ),
158
  'version' => SEARCHREGEX_VERSION,
159
  'caps' => [
160
- 'pages' => Search_Regex_Capabilities::get_available_pages(),
161
- 'capabilities' => Search_Regex_Capabilities::get_all_capabilities(),
162
  ],
 
163
  ) );
164
 
 
 
165
  $this->add_help_tab();
166
  }
167
 
@@ -187,9 +210,7 @@ class Search_Regex_Admin {
187
  * @return void
188
  */
189
  private function set_rest_api( $api ) {
190
- if ( $api >= 0 && $api <= SEARCHREGEX_API_JSON_RELATIVE ) {
191
- searchregex_set_options( array( 'rest_api' => intval( $api, 10 ) ) );
192
- }
193
  }
194
 
195
  /**
@@ -198,21 +219,63 @@ class Search_Regex_Admin {
198
  * @return Array
199
  */
200
  private function get_preload_data() {
201
- $all = Source_Manager::get_all_source_names();
202
- $handlers = Source_Manager::get( $all, new Search_Flags(), new Source_Flags() );
203
- $flags = [];
204
-
205
- foreach ( $handlers as $source ) {
206
- $flags[ $source->get_type() ] = $source->get_supported_flags();
207
- }
208
 
209
  return [
210
- 'sources' => Source_Manager::get_all_grouped(),
211
- 'source_flags' => $flags,
212
- 'presets' => Preset::get_all(),
 
213
  ];
214
  }
215
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
216
  /**
217
  * Replace links
218
  *
@@ -299,7 +362,9 @@ class Search_Regex_Admin {
299
  * @return void
300
  */
301
  public function admin_menu() {
302
- $hook = add_management_page( 'Search Regex', 'Search Regex', Search_Regex_Capabilities::get_plugin_access(), basename( SEARCHREGEX_FILE ), [ $this, 'admin_screen' ] );
 
 
303
  if ( $hook ) {
304
  add_action( 'load-' . $hook, [ $this, 'searchregex_head' ] );
305
  }
@@ -326,7 +391,8 @@ class Search_Regex_Admin {
326
  * @return void
327
  */
328
  public function admin_screen() {
329
- if ( count( Search_Regex_Capabilities::get_all_capabilities() ) === 0 ) {
 
330
  die( 'You do not have sufficient permissions to access this page.' );
331
  }
332
 
@@ -466,7 +532,8 @@ class Search_Regex_Admin {
466
  }
467
 
468
  // Are we allowed to access this page?
469
- if ( in_array( $page, Search_Regex_Capabilities::get_available_pages(), true ) ) {
 
470
  // phpcs:ignore
471
  return $page;
472
  }
@@ -474,7 +541,15 @@ class Search_Regex_Admin {
474
  return false;
475
  }
476
 
477
- public function extra_actions( $actions, $type, $result ) {
 
 
 
 
 
 
 
 
478
  if ( $type === 'tablepress_table' ) {
479
  $tables = json_decode( get_option( 'tablepress_tables' ), true );
480
 
@@ -492,6 +567,5 @@ class Search_Regex_Admin {
492
  }
493
  }
494
 
495
- register_activation_hook( SEARCHREGEX_FILE, array( 'Search_Regex_Admin', 'plugin_activated' ) );
496
-
497
- add_action( 'init', array( 'Search_Regex_Admin', 'init' ) );
1
  <?php
2
 
3
+ namespace SearchRegex\Admin;
4
+
5
+ use SearchRegex\Source;
6
+ use SearchRegex\Search;
7
+ use SearchRegex\Plugin;
8
+
9
+ require_once __DIR__ . '/search/class-search.php';
10
+ require_once __DIR__ . '/filter/class-search-filter.php';
11
+ require_once __DIR__ . '/modifier/class-modifier.php';
12
+ require_once __DIR__ . '/source/class-source.php';
13
+ require_once __DIR__ . '/schema/class-schema.php';
14
+ require_once __DIR__ . '/context/class-context.php';
15
+ require_once __DIR__ . '/action/class-action.php';
16
+ require_once __DIR__ . '/sql/class-sql.php';
17
+
18
+ class Admin {
19
+ /** @var null|Admin */
20
  private static $instance = null;
21
 
22
  /**
23
  * Initialize the object
24
  *
25
+ * @return Admin
26
  */
27
  public static function init() {
28
  if ( is_null( self::$instance ) ) {
29
+ self::$instance = new self();
30
  }
31
 
32
  return self::$instance;
39
  add_action( 'admin_menu', [ $this, 'admin_menu' ] );
40
  add_action( 'plugin_action_links_' . basename( dirname( SEARCHREGEX_FILE ) ) . '/' . basename( SEARCHREGEX_FILE ), [ $this, 'plugin_settings' ], 10, 4 );
41
  add_filter( 'searchregex_result_actions', [ $this, 'extra_actions' ], 10, 3 );
42
+ add_filter( 'load_script_translation_file', [ $this, 'load_script_translation_file' ], 10, 3 );
43
+
44
+ register_uninstall_hook( SEARCHREGEX_FILE, [ '\SearchRegex\Admin\Admin', 'plugin_uninstall' ] );
45
+ }
46
+
47
+ /**
48
+ * Massage the Search Regex WP translations.
49
+ */
50
+ public function load_script_translation_file( $file, $handle, $domain ) {
51
+ if ( $domain === 'search-regex' ) {
52
+ return preg_replace( '/-\w*\./', '.', $file );
53
+ }
54
 
55
+ return $file;
56
  }
57
 
58
  /**
61
  * @return void
62
  */
63
  public static function plugin_uninstall() {
64
+ /** @psalm-suppress UndefinedConstant */
65
+ Plugin\Settings::init()->delete();
66
  delete_option( Preset::OPTION_NAME );
67
  }
68
 
100
  * @return String
101
  */
102
  private function get_first_available_page_url() {
103
+ /** @psalm-suppress UndefinedClass */
104
+ $pages = Plugin\Capabilities::get_available_pages();
105
 
106
  if ( count( $pages ) > 0 ) {
107
  return $this->get_plugin_url() . ( $pages[0] === 'search' ? '' : '&sub=' . rawurlencode( $pages[0] ) );
133
 
134
  $build = SEARCHREGEX_VERSION . '-' . SEARCHREGEX_BUILD;
135
  $preload = $this->get_preload_data();
136
+ $settings = Plugin\Settings::init();
137
+
138
  $versions = array(
139
  'Plugin: ' . SEARCHREGEX_VERSION,
140
  'WordPress: ' . $wp_version . ' (' . ( is_multisite() ? 'multi' : 'single' ) . ')',
141
  'PHP: ' . phpversion() . ' ' . ini_get( 'memory_limit' ) . ' ' . ini_get( 'max_execution_time' ) . 's',
142
  'Browser: ' . $this->get_user_agent(),
143
  'JavaScript: ' . plugin_dir_url( SEARCHREGEX_FILE ) . 'search-regex.js',
144
+ 'REST API: ' . $settings->get_rest_api_url(),
145
  );
146
 
147
+ wp_enqueue_script( 'search-regex', plugin_dir_url( SEARCHREGEX_FILE ) . 'build/search-regex.js', [], $build, true );
148
+ wp_enqueue_style( 'search-regex', plugin_dir_url( SEARCHREGEX_FILE ) . 'build/search-regex.css', [], $build );
 
 
 
149
 
150
+ /** @psalm-suppress UndefinedClass */
151
+ $pages = Plugin\Capabilities::get_available_pages();
152
 
153
+ /** @psalm-suppress UndefinedClass */
154
+ $caps = Plugin\Capabilities::get_all_capabilities();
155
+
156
+ $is_new = false;
157
+ $major_version = implode( '.', array_slice( explode( '.', SEARCHREGEX_VERSION ), 0, 2 ) );
158
+
159
+ // phpcs:ignore
160
+ if ( isset( $_GET['page'] ) && $_GET['page'] === 'search-regex.php' && strpos( SEARCHREGEX_VERSION, '-beta' ) === false ) {
161
+ $is_new = $settings->is_new_version( SEARCHREGEX_VERSION );
162
+ }
163
 
164
  wp_localize_script( 'search-regex', 'SearchRegexi10n', array(
165
  'api' => [
166
+ 'WP_API_root' => esc_url_raw( $settings->get_rest_api_url() ),
167
  'WP_API_nonce' => wp_create_nonce( 'wp_rest' ),
168
  'site_health' => admin_url( 'site-health.php' ),
169
+ 'current' => $settings->get_rest_api(),
170
+ 'routes' => $settings->get_available_rest_api(),
 
 
 
 
171
  ],
172
  'pluginBaseUrl' => plugins_url( '', SEARCHREGEX_FILE ),
173
  'pluginRoot' => $this->get_plugin_url(),
174
+ 'locale' => str_replace( '_', '-', get_locale() ),
175
+ 'settings' => $settings->get_as_json(),
 
 
 
 
176
  'preload' => $preload,
177
  'versions' => implode( "\n", $versions ),
178
  'version' => SEARCHREGEX_VERSION,
179
  'caps' => [
180
+ 'pages' => $pages,
181
+ 'capabilities' => $caps,
182
  ],
183
+ 'update_notice' => $is_new ? $major_version : false,
184
  ) );
185
 
186
+ wp_set_script_translations( 'search-regex', 'search-regex', plugin_dir_path( SEARCHREGEX_FILE ) . 'languages/json/' );
187
+
188
  $this->add_help_tab();
189
  }
190
 
210
  * @return void
211
  */
212
  private function set_rest_api( $api ) {
213
+ Plugin\Settings::init()->set_rest_api( intval( $api, 10 ) );
 
 
214
  }
215
 
216
  /**
219
  * @return Array
220
  */
221
  private function get_preload_data() {
222
+ $schema = Source\Manager::get_schema();
223
+ $presets = Search\Preset::get_all();
 
 
 
 
 
224
 
225
  return [
226
+ 'sources' => Source\Manager::get_all_grouped(),
227
+ 'presets' => $presets,
228
+ 'schema' => $schema,
229
+ 'labels' => $this->get_preload_labels( $presets ),
230
  ];
231
  }
232
 
233
+ /**
234
+ * Get the preloaded labels.
235
+ *
236
+ * @param array $presets
237
+ * @return array
238
+ */
239
+ private function get_preload_labels( array $presets ) {
240
+ $preload = [];
241
+ $filters_to_preload = [];
242
+
243
+ if ( isset( $_GET['filters'] ) ) {
244
+ $filters = json_decode( stripslashes( $_GET['filters'] ), true );
245
+ $filters_to_preload = array_merge( $filters_to_preload, $filters );
246
+ }
247
+
248
+ foreach ( $presets as $preset ) {
249
+ if ( isset( $preset['search']['filters'] ) ) {
250
+ $filters_to_preload = array_merge( $filters_to_preload, $preset['search']['filters'] );
251
+ }
252
+
253
+ if ( isset( $preset['search']['action'] ) && $preset['search']['action'] === 'modify' && is_array( $preset['search']['actionOption'] ) ) {
254
+ $filters_to_preload = array_merge( $filters_to_preload, array_map( function( $action ) {
255
+ return [
256
+ 'type' => $action['source'],
257
+ 'items' => [
258
+ array_merge(
259
+ [ 'column' => $action['column'] ],
260
+ $action
261
+ ),
262
+ ],
263
+ ];
264
+ }, $preset['search']['actionOption'] ) );
265
+ }
266
+ }
267
+
268
+ foreach ( $filters_to_preload as $filter ) {
269
+ if ( is_array( $filter ) && isset( $filter['type'] ) && isset( $filter['items'] ) ) {
270
+ foreach ( $filter['items'] as $filt ) {
271
+ $preload = array_merge( $preload, Source\Manager::get_schema_preload( $filter['type'], $filt ) );
272
+ }
273
+ }
274
+ }
275
+
276
+ return array_values( array_filter( $preload ) );
277
+ }
278
+
279
  /**
280
  * Replace links
281
  *
362
  * @return void
363
  */
364
  public function admin_menu() {
365
+ /** @psalm-suppress UndefinedClass */
366
+ $access = Plugin\Capabilities::get_plugin_access();
367
+ $hook = add_management_page( 'Search Regex', 'Search Regex', $access, basename( SEARCHREGEX_FILE ), [ $this, 'admin_screen' ] );
368
  if ( $hook ) {
369
  add_action( 'load-' . $hook, [ $this, 'searchregex_head' ] );
370
  }
391
  * @return void
392
  */
393
  public function admin_screen() {
394
+ /** @psalm-suppress UndefinedClass */
395
+ if ( count( Plugin\Capabilities::get_all_capabilities() ) === 0 ) {
396
  die( 'You do not have sufficient permissions to access this page.' );
397
  }
398
 
532
  }
533
 
534
  // Are we allowed to access this page?
535
+ /** @psalm-suppress UndefinedClass */
536
+ if ( in_array( $page, Plugin\Capabilities::get_available_pages(), true ) ) {
537
  // phpcs:ignore
538
  return $page;
539
  }
541
  return false;
542
  }
543
 
544
+ /**
545
+ * Get any extra actions that might be needed.
546
+ *
547
+ * @param array $actions Actions.
548
+ * @param string $type Type.
549
+ * @param object $result Result.
550
+ * @return array
551
+ */
552
+ public function extra_actions( array $actions, $type, $result ) {
553
  if ( $type === 'tablepress_table' ) {
554
  $tables = json_decode( get_option( 'tablepress_tables' ), true );
555
 
567
  }
568
  }
569
 
570
+ register_activation_hook( SEARCHREGEX_FILE, array( '\SearchRegex\Admin\Admin', 'plugin_activated' ) );
571
+ add_action( 'init', array( '\SearchRegex\Admin\Admin', 'init' ) );
 
search-regex-cli.php → includes/search-regex-cli.php RENAMED
@@ -1,4 +1,6 @@
1
  <?php
2
 
 
 
3
  if ( defined( 'WP_CLI' ) && WP_CLI ) {
4
  }
1
  <?php
2
 
3
+ namespace SearchRegex\Cli;
4
+
5
  if ( defined( 'WP_CLI' ) && WP_CLI ) {
6
  }
models/search-flags.php → includes/search/class-flags.php RENAMED
@@ -1,16 +1,16 @@
1
  <?php
2
 
3
- namespace SearchRegex;
4
 
5
  /**
6
  * Represents flags for a particular search
7
  */
8
- class Search_Flags {
9
  /** @var String[] */
10
  private $flags = [];
11
 
12
  /**
13
- * Create a Source_Flags object with an array of flag strings
14
  *
15
  * @param Array $flags Array of flag values.
16
  */
@@ -25,6 +25,16 @@ class Search_Flags {
25
  } );
26
  }
27
 
 
 
 
 
 
 
 
 
 
 
28
  /**
29
  * Is the flag set?
30
  *
@@ -53,6 +63,17 @@ class Search_Flags {
53
  return $this->has_flag( 'case' );
54
  }
55
 
 
 
 
 
 
 
 
 
 
 
 
56
  /**
57
  * Get all the flags
58
  *
@@ -62,6 +83,11 @@ class Search_Flags {
62
  return $this->flags;
63
  }
64
 
 
 
 
 
 
65
  public function to_json() {
66
  return $this->flags;
67
  }
1
  <?php
2
 
3
+ namespace SearchRegex\Search;
4
 
5
  /**
6
  * Represents flags for a particular search
7
  */
8
+ class Flags {
9
  /** @var String[] */
10
  private $flags = [];
11
 
12
  /**
13
+ * Create a Flags object with an array of flag strings
14
  *
15
  * @param Array $flags Array of flag values.
16
  */
25
  } );
26
  }
27
 
28
+ /**
29
+ * Duplicate a search flag object
30
+ *
31
+ * @param Flags $flags Flags.
32
+ * @return Flags
33
+ */
34
+ public static function copy( Flags $flags ) {
35
+ return new Flags( $flags->flags );
36
+ }
37
+
38
  /**
39
  * Is the flag set?
40
  *
63
  return $this->has_flag( 'case' );
64
  }
65
 
66
+ /**
67
+ * Set the regex flag
68
+ *
69
+ * @return void
70
+ */
71
+ public function set_regex() {
72
+ if ( ! $this->is_regex() ) {
73
+ $this->flags[] = 'regex';
74
+ }
75
+ }
76
+
77
  /**
78
  * Get all the flags
79
  *
83
  return $this->flags;
84
  }
85
 
86
+ /**
87
+ * Convert the flags to JSON
88
+ *
89
+ * @return array
90
+ */
91
  public function to_json() {
92
  return $this->flags;
93
  }
includes/search/class-match-column.php ADDED
@@ -0,0 +1,214 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Search;
4
+
5
+ use SearchRegex\Context;
6
+
7
+ class Column {
8
+ const CONTEXT_LIMIT = 20;
9
+
10
+ /**
11
+ * Column ID
12
+ *
13
+ * @readonly
14
+ * @var string
15
+ **/
16
+ private $column_id;
17
+
18
+ /**
19
+ * Column label
20
+ *
21
+ * @readonly
22
+ * @var string
23
+ **/
24
+ private $column_label;
25
+
26
+ /**
27
+ * Array of match contexts
28
+ *
29
+ * @var Context\Context[]
30
+ **/
31
+ private $contexts = [];
32
+
33
+ /**
34
+ * Total number of match contexts
35
+ *
36
+ * @var int
37
+ **/
38
+ private $context_count;
39
+
40
+ /**
41
+ * Total number of matches
42
+ *
43
+ * @var int
44
+ **/
45
+ private $match_count;
46
+
47
+ /**
48
+ * Raw data for this column
49
+ *
50
+ * @readonly
51
+ * @var array
52
+ */
53
+ private $raw;
54
+
55
+ /**
56
+ * Create a Match Column, which contains an array of Context\Type\Text items for a particular database column.
57
+ *
58
+ * @param string $column_id Column ID.
59
+ * @param string $column_label Descriptive column label, shown to the user.
60
+ * @param array<Context\Context> $contexts Contexts.
61
+ * @param array $raw Raw data.
62
+ */
63
+ public function __construct( $column_id, $column_label, array $contexts, array $raw ) {
64
+ $this->match_count = 0;
65
+ $this->column_id = $column_id;
66
+ $this->column_label = $column_label;
67
+ $this->raw = $raw;
68
+ $this->context_count = 0;
69
+
70
+ $this->set_contexts( $contexts );
71
+ }
72
+
73
+ /**
74
+ * Get contexts
75
+ *
76
+ * @return array<Context\Context>
77
+ */
78
+ public function get_contexts() {
79
+ return $this->contexts;
80
+ }
81
+
82
+ /**
83
+ * Add contexts if:
84
+ * - there are no contexts and it is unmatched
85
+ * - the contexts match
86
+ *
87
+ * The aim is to ensure that we either have all matches, or one unmatched
88
+ *
89
+ * @param array<Context\Context> $contexts Contexts.
90
+ * @return void
91
+ */
92
+ public function add_contexts_if_matching( array $contexts ) {
93
+ $this->add_contexts( $contexts );
94
+
95
+ // Ensure if we have any matches then there are no unmatched
96
+ $matched = array_filter( $this->contexts, function( $context ) {
97
+ return $context->is_matched();
98
+ } );
99
+
100
+ if ( count( $matched ) > 0 ) {
101
+ // Remove unmatched
102
+ $this->set_contexts( $matched );
103
+ }
104
+ }
105
+
106
+ /**
107
+ * Add contexts to the column, ensuring we don't have duplicates
108
+ *
109
+ * @param array<Context\Context> $contexts Contexts.
110
+ * @return void
111
+ */
112
+ public function add_contexts( array $contexts ) {
113
+ foreach ( $contexts as $context ) {
114
+ $found = false;
115
+
116
+ // Remove duplicates
117
+ foreach ( $this->contexts as $existing ) {
118
+ if ( $existing->is_equal( $context ) ) {
119
+ $found = true;
120
+ break;
121
+ }
122
+ }
123
+
124
+ if ( ! $found ) {
125
+ $context->set_context_id( count( $this->contexts ) );
126
+
127
+ $this->contexts[] = $context;
128
+ $this->match_count += $context->get_match_count();
129
+ }
130
+ }
131
+
132
+ $this->context_count = count( $this->contexts );
133
+ $this->contexts = array_slice( $this->contexts, 0, self::CONTEXT_LIMIT );
134
+ }
135
+
136
+ /**
137
+ * Set the context array
138
+ *
139
+ * @param Context\Context[] $contexts Array of contexts.
140
+ * @return void
141
+ */
142
+ public function set_contexts( array $contexts ) {
143
+ $this->contexts = [];
144
+ $this->add_contexts( $contexts );
145
+ }
146
+
147
+ /**
148
+ * Convert the Context\Type\Text to JSON
149
+ *
150
+ * @return Array{column_id: string, column_label: string, contexts: array, context_count: int, match_count: int} JSON data
151
+ */
152
+ public function to_json() {
153
+ return [
154
+ 'column_id' => $this->column_id,
155
+ 'column_label' => $this->column_label,
156
+ 'contexts' => array_map( function( $item ) {
157
+ return $item->to_json();
158
+ }, $this->contexts ),
159
+ 'context_count' => $this->context_count,
160
+ 'match_count' => $this->match_count,
161
+ ];
162
+ }
163
+
164
+ /**
165
+ * Get column ID
166
+ *
167
+ * @return String Column ID
168
+ */
169
+ public function get_column_id() {
170
+ return $this->column_id;
171
+ }
172
+
173
+ /**
174
+ * Get match count
175
+ *
176
+ * @return Int Match count
177
+ */
178
+ public function get_match_count() {
179
+ return $this->match_count;
180
+ }
181
+
182
+ /**
183
+ * Get contexts that have changed
184
+ *
185
+ * @param array $raw Raw data.
186
+ * @return array<Context\Context>
187
+ */
188
+ public function get_changes( array $raw ) {
189
+ return array_values( array_filter( $this->contexts, function( $context ) {
190
+ return $context->needs_saving();
191
+ } ) );
192
+ }
193
+
194
+ /**
195
+ * Get contexts that have not changed
196
+ *
197
+ * @param array $raw Raw data.
198
+ * @return array<Context\Context>
199
+ */
200
+ public function get_same( array $raw ) {
201
+ return array_values( array_filter( $this->contexts, function( $context ) {
202
+ return ! $context->needs_saving();
203
+ } ) );
204
+ }
205
+
206
+ /**
207
+ * Get the value for this column
208
+ *
209
+ * @return string
210
+ */
211
+ public function get_value() {
212
+ return array_values( $this->raw )[0];
213
+ }
214
+ }
models/match.php → includes/search/class-match-text.php RENAMED
@@ -1,16 +1,17 @@
1
  <?php
2
 
3
- namespace SearchRegex;
4
 
5
- use SearchRegex\Match_Context;
6
 
7
  /**
8
  * Represents a single match
9
  */
10
- class Match {
11
  /**
12
  * Position ID
13
  *
 
14
  * @var Int
15
  **/
16
  private $pos_id;
@@ -18,6 +19,7 @@ class Match {
18
  /**
19
  * Matched string
20
  *
 
21
  * @var String
22
  **/
23
  private $match;
@@ -32,9 +34,9 @@ class Match {
32
  /**
33
  * Replacement
34
  *
35
- * @var String
36
  **/
37
- private $replacement;
38
 
39
  /**
40
  * Array of captured data
@@ -50,13 +52,23 @@ class Match {
50
  * @param int $match_offset The offset within the column.
51
  * @param String $replacement The replaced value, if one is supplied.
52
  */
53
- public function __construct( $match, $match_offset, $replacement ) {
54
  $this->pos_id = intval( $match_offset, 10 );
55
- $this->match = $match;
56
  $this->replacement = $replacement;
57
  $this->captures = [];
58
  }
59
 
 
 
 
 
 
 
 
 
 
 
60
  /**
61
  * Add a regular expression capture value
62
  *
@@ -114,10 +126,10 @@ class Match {
114
  * Encode a search as a regular expression
115
  *
116
  * @param String $search Search phrase.
117
- * @param Search_Flags $flags Is this regular expression.
118
  * @return String Encoded search phrase
119
  */
120
- public static function get_pattern( $search, Search_Flags $flags ) {
121
  $pattern = \preg_quote( $search, '@' );
122
 
123
  if ( $flags->is_regex() ) {
@@ -138,17 +150,18 @@ class Match {
138
  * Get all matches for a search phrase on a column
139
  *
140
  * @param String $search The search phrase.
141
- * @param Search_Flags $flags Any search flags.
142
  * @param Array $replacements A matching set of replacements.
143
  * @param String $column_value The content to match.
144
  * @return Array Array of Match contexts
145
  */
146
- public static function get_all( $search, Search_Flags $flags, array $replacements, $column_value ) {
147
  $pattern = self::get_pattern( $search, $flags );
148
  $contexts = [];
149
 
150
  if ( \preg_match_all( $pattern, $column_value, $searches, PREG_OFFSET_CAPTURE ) > 0 ) {
151
- $current_context = new Match_Context( 0 );
 
152
  $contexts[] = $current_context;
153
 
154
  // Go through each search match and create a Match
@@ -157,7 +170,7 @@ class Match {
157
  $pos = mb_strlen( substr( $column_value, 0, $match[1] ), 'utf-8' );
158
 
159
  // Create a match
160
- $match = new Match( $match[0], $pos, isset( $replacements[ $match_pos ] ) ? $replacements[ $match_pos ] : '' );
161
 
162
  // Add any captures
163
  foreach ( array_slice( $searches, 1 ) as $capture ) {
@@ -167,7 +180,9 @@ class Match {
167
  // Is the match within range of the current context
168
  if ( ! $current_context->is_within_context( $match ) ) {
169
  // No - create a new context
170
- $current_context = new Match_Context( count( $contexts ) );
 
 
171
  $contexts[] = $current_context;
172
  }
173
 
@@ -186,6 +201,10 @@ class Match {
186
  * @return String The $text value, with the replacement inserted at the Match position
187
  */
188
  public function replace_at_position( $text ) {
189
- return mb_substr( $text, 0, $this->pos_id, 'UTF-8' ) . $this->replacement . mb_substr( $text, $this->pos_id + mb_strlen( $this->match, 'UTF-8' ), null, 'UTF-8' );
 
 
 
 
190
  }
191
  }
1
  <?php
2
 
3
+ namespace SearchRegex\Search;
4
 
5
+ use SearchRegex\Context;
6
 
7
  /**
8
  * Represents a single match
9
  */
10
+ class Text {
11
  /**
12
  * Position ID
13
  *
14
+ * @readonly
15
  * @var Int
16
  **/
17
  private $pos_id;
19
  /**
20
  * Matched string
21
  *
22
+ * @readonly
23
  * @var String
24
  **/
25
  private $match;
34
  /**
35
  * Replacement
36
  *
37
+ * @var String|null
38
  **/
39
+ private $replacement = null;
40
 
41
  /**
42
  * Array of captured data
52
  * @param int $match_offset The offset within the column.
53
  * @param String $replacement The replaced value, if one is supplied.
54
  */
55
+ public function __construct( $match, $match_offset = 0, $replacement = null ) {
56
  $this->pos_id = intval( $match_offset, 10 );
57
+ $this->match = "$match";
58
  $this->replacement = $replacement;
59
  $this->captures = [];
60
  }
61
 
62
+ /**
63
+ * Set the replacement text for this match
64
+ *
65
+ * @param string $replacement Replacement text.
66
+ * @return void
67
+ */
68
+ public function set_replacement( $replacement ) {
69
+ $this->replacement = $replacement;
70
+ }
71
+
72
  /**
73
  * Add a regular expression capture value
74
  *
126
  * Encode a search as a regular expression
127
  *
128
  * @param String $search Search phrase.
129
+ * @param Search\Flags $flags Is this regular expression.
130
  * @return String Encoded search phrase
131
  */
132
+ public static function get_pattern( $search, Flags $flags ) {
133
  $pattern = \preg_quote( $search, '@' );
134
 
135
  if ( $flags->is_regex() ) {
150
  * Get all matches for a search phrase on a column
151
  *
152
  * @param String $search The search phrase.
153
+ * @param Search\Flags $flags Any search flags.
154
  * @param Array $replacements A matching set of replacements.
155
  * @param String $column_value The content to match.
156
  * @return Array Array of Match contexts
157
  */
158
+ public static function get_all( $search, Flags $flags, array $replacements, $column_value ) {
159
  $pattern = self::get_pattern( $search, $flags );
160
  $contexts = [];
161
 
162
  if ( \preg_match_all( $pattern, $column_value, $searches, PREG_OFFSET_CAPTURE ) > 0 ) {
163
+ $current_context = new Context\Type\Text( $search, $flags );
164
+ $current_context->set_type( Context\Value_Type::get( $column_value ) );
165
  $contexts[] = $current_context;
166
 
167
  // Go through each search match and create a Match
170
  $pos = mb_strlen( substr( $column_value, 0, $match[1] ), 'utf-8' );
171
 
172
  // Create a match
173
+ $match = new self( $match[0], $pos, isset( $replacements[ $match_pos ] ) ? $replacements[ $match_pos ] : null );
174
 
175
  // Add any captures
176
  foreach ( array_slice( $searches, 1 ) as $capture ) {
180
  // Is the match within range of the current context
181
  if ( ! $current_context->is_within_context( $match ) ) {
182
  // No - create a new context
183
+ $current_context = new Context\Type\Text( $search, $flags );
184
+ $current_context->set_type( Context\Value_Type::get( $column_value ) );
185
+ $current_context->set_context_id( count( $contexts ) );
186
  $contexts[] = $current_context;
187
  }
188
 
201
  * @return String The $text value, with the replacement inserted at the Match position
202
  */
203
  public function replace_at_position( $text ) {
204
+ if ( $this->replacement !== null ) {
205
+ return mb_substr( $text, 0, $this->pos_id, 'UTF-8' ) . $this->replacement . mb_substr( $text, $this->pos_id + mb_strlen( $this->match, 'UTF-8' ), null, 'UTF-8' );
206
+ }
207
+
208
+ return $text;
209
  }
210
  }
models/preset.php → includes/search/class-preset.php RENAMED
@@ -1,6 +1,11 @@
1
  <?php
2
 
3
- namespace SearchRegex;
 
 
 
 
 
4
 
5
  /**
6
  * A saved search
@@ -35,17 +40,10 @@ class Preset {
35
  /**
36
  * Array of search flags
37
  *
38
- * @var Search_Flags
39
  */
40
  private $search_flags;
41
 
42
- /**
43
- * Array of source flags
44
- *
45
- * @var Source_Flags
46
- */
47
- private $source_flags;
48
-
49
  /**
50
  * Array of source names
51
  *
@@ -88,6 +86,27 @@ class Preset {
88
  */
89
  private $locked = [];
90
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
  /**
92
  * Create a preset
93
  *
@@ -95,8 +114,7 @@ class Preset {
95
  */
96
  public function __construct( array $params = [] ) {
97
  $this->id = isset( $params['id'] ) ? $params['id'] : uniqid();
98
- $this->search_flags = new Search_Flags();
99
- $this->source_flags = new Source_Flags();
100
 
101
  $this->set_values( $params );
102
  }
@@ -194,6 +212,9 @@ class Preset {
194
  'source',
195
  'sourceFlags',
196
  'perPage',
 
 
 
197
  ];
198
  }
199
 
@@ -216,8 +237,6 @@ class Preset {
216
  * @return void
217
  */
218
  private function set_search( array $search ) {
219
- $allowed_flags = [];
220
-
221
  if ( isset( $search['searchPhrase'] ) ) {
222
  $this->search = $search['searchPhrase'];
223
  }
@@ -231,17 +250,13 @@ class Preset {
231
  }
232
 
233
  if ( isset( $search['searchFlags'] ) && is_array( $search['searchFlags'] ) ) {
234
- $this->search_flags = new Search_Flags( $search['searchFlags'] );
235
- }
236
-
237
- if ( isset( $search['sourceFlags'] ) && is_array( $search['sourceFlags'] ) ) {
238
- $this->source_flags = new Source_Flags( $search['sourceFlags'] );
239
  }
240
 
241
  // Sanitize sources and ensure source flags are allowed by those sources
242
  if ( isset( $search['source'] ) && is_array( $search['source'] ) ) {
243
  $sources = array_map( function( $source ) {
244
- $sources = Source_Manager::get( [ $source ], $this->search_flags, $this->source_flags );
245
  if ( $sources ) {
246
  return $source;
247
  }
@@ -249,9 +264,35 @@ class Preset {
249
  return false;
250
  }, $search['source'] );
251
  $this->source = array_values( array_filter( $sources ) );
252
- } else {
253
- // No source, no flags
254
- $this->source_flags->set_allowed_flags( [] );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
255
  }
256
  }
257
 
@@ -330,18 +371,32 @@ class Preset {
330
  * @return Array
331
  */
332
  public function to_json() {
333
- return [
334
- 'id' => $this->id,
335
- 'name' => \html_entity_decode( $this->name ),
336
- 'description' => \html_entity_decode( $this->description ),
337
- 'search' => [
338
  'searchPhrase' => $this->search,
339
  'replacement' => $this->replacement,
340
  'perPage' => $this->per_page,
341
  'searchFlags' => $this->search_flags->to_json(),
342
- 'sourceFlags' => $this->source_flags->to_json(),
343
  'source' => $this->source,
 
 
 
 
344
  ],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
345
  'locked' => $this->locked,
346
  'tags' => $this->tags,
347
  ];
@@ -409,6 +464,7 @@ class Preset {
409
  * @return integer Number of presets imported
410
  */
411
  public static function import( $filename ) {
 
412
  $file = file_get_contents( $filename );
413
 
414
  if ( $file ) {
@@ -421,7 +477,7 @@ class Preset {
421
  $preset = new Preset( $params );
422
 
423
  if ( $preset->is_valid() ) {
424
- $name = $preset->create();
425
  $imported++;
426
  }
427
  }
1
  <?php
2
 
3
+ namespace SearchRegex\Search;
4
+
5
+ use SearchRegex\Action;
6
+ use SearchRegex\Schema;
7
+ use SearchRegex\Source;
8
+ use SearchRegex\Filter;
9
 
10
  /**
11
  * A saved search
40
  /**
41
  * Array of search flags
42
  *
43
+ * @var Flags
44
  */
45
  private $search_flags;
46
 
 
 
 
 
 
 
 
47
  /**
48
  * Array of source names
49
  *
86
  */
87
  private $locked = [];
88
 
89
+ /**
90
+ * Preset action
91
+ *
92
+ * @var Action\Action|null
93
+ */
94
+ private $action = null;
95
+
96
+ /**
97
+ * Filters
98
+ *
99
+ * @var Filter\Filter[]
100
+ */
101
+ private $filters = [];
102
+
103
+ /**
104
+ * View
105
+ *
106
+ * @var string[]
107
+ */
108
+ private $view = [];
109
+
110
  /**
111
  * Create a preset
112
  *
114
  */
115
  public function __construct( array $params = [] ) {
116
  $this->id = isset( $params['id'] ) ? $params['id'] : uniqid();
117
+ $this->search_flags = new Flags();
 
118
 
119
  $this->set_values( $params );
120
  }
212
  'source',
213
  'sourceFlags',
214
  'perPage',
215
+ 'filters',
216
+ 'action',
217
+ 'view',
218
  ];
219
  }
220
 
237
  * @return void
238
  */
239
  private function set_search( array $search ) {
 
 
240
  if ( isset( $search['searchPhrase'] ) ) {
241
  $this->search = $search['searchPhrase'];
242
  }
250
  }
251
 
252
  if ( isset( $search['searchFlags'] ) && is_array( $search['searchFlags'] ) ) {
253
+ $this->search_flags = new Flags( $search['searchFlags'] );
 
 
 
 
254
  }
255
 
256
  // Sanitize sources and ensure source flags are allowed by those sources
257
  if ( isset( $search['source'] ) && is_array( $search['source'] ) ) {
258
  $sources = array_map( function( $source ) {
259
+ $sources = Source\Manager::get( [ $source ], [] );
260
  if ( $sources ) {
261
  return $source;
262
  }
264
  return false;
265
  }, $search['source'] );
266
  $this->source = array_values( array_filter( $sources ) );
267
+ }
268
+
269
+ $schema = new Schema\Schema( Source\Manager::get_schema( $this->source ) );
270
+
271
+ // If there is a replacement then default to global replace, for backwards compatability
272
+ $this->action = new Action\Type\Nothing( [], $schema );
273
+
274
+ if ( $this->search !== '' ) {
275
+ $this->action = new Action\Type\Global_Replace( [
276
+ 'search' => $this->search,
277
+ 'replacement' => $this->replacement,
278
+ 'flags' => $this->search_flags->to_json(),
279
+ ], $schema );
280
+ }
281
+
282
+ if ( isset( $search['action'] ) ) {
283
+ $this->action = Action\Action::create( $search['action'], Action\Action::get_options( $search ), $schema );
284
+ }
285
+
286
+ if ( isset( $search['filters'] ) && is_array( $search['filters'] ) ) {
287
+ $this->filters = Filter\Filter::create( $search['filters'], $schema );
288
+ }
289
+
290
+ if ( isset( $search['view'] ) && is_array( $search['view'] ) ) {
291
+ $this->view = array_values( array_filter( $search['view'], function( $view ) {
292
+ $parts = explode( '__', $view );
293
+
294
+ return count( $parts ) === 2;
295
+ } ) );
296
  }
297
  }
298
 
371
  * @return Array
372
  */
373
  public function to_json() {
374
+ $search = array_merge(
375
+ [
 
 
 
376
  'searchPhrase' => $this->search,
377
  'replacement' => $this->replacement,
378
  'perPage' => $this->per_page,
379
  'searchFlags' => $this->search_flags->to_json(),
 
380
  'source' => $this->source,
381
+ 'filters' => array_map( function( $filter ) {
382
+ return $filter->to_json();
383
+ }, $this->filters ),
384
+ 'view' => $this->view,
385
  ],
386
+ $this->action === null ? [] : $this->action->to_json()
387
+ );
388
+
389
+ // Remove replace value if not a global replace
390
+ if ( $search['action'] !== 'replace' ) {
391
+ $search['replacement'] = '';
392
+ $search['searchFlags'] = [];
393
+ }
394
+
395
+ return [
396
+ 'id' => $this->id,
397
+ 'name' => \html_entity_decode( $this->name ),
398
+ 'description' => \html_entity_decode( $this->description ),
399
+ 'search' => $search,
400
  'locked' => $this->locked,
401
  'tags' => $this->tags,
402
  ];
464
  * @return integer Number of presets imported
465
  */
466
  public static function import( $filename ) {
467
+ // phpcs:ignore
468
  $file = file_get_contents( $filename );
469
 
470
  if ( $file ) {
477
  $preset = new Preset( $params );
478
 
479
  if ( $preset->is_valid() ) {
480
+ $preset->create();
481
  $imported++;
482
  }
483
  }
models/result.php → includes/search/class-result.php RENAMED
@@ -1,6 +1,8 @@
1
  <?php
2
 
3
- namespace SearchRegex;
 
 
4
 
5
  /**
6
  * Contains all information for a search result - a database row that contains matches
@@ -37,7 +39,7 @@ class Result {
37
  /**
38
  * Array of columns with matches
39
  *
40
- * @var Match_Column[]
41
  **/
42
  private $columns;
43
 
@@ -56,16 +58,14 @@ class Result {
56
  private $actions = [];
57
 
58
  /**
59
- * Create the result given a row ID, the Search_Source, a set of columns, and the raw database data.
60
  *
61
  * @param Int $row_id Database row ID.
62
- * @param Search_Source $source The search source.
63
- * @param Array $columns Array of Match_Column objects.
64
  * @param Array $raw Raw row data.
65
  */
66
- public function __construct( $row_id, Search_Source $source, array $columns, $raw ) {
67
- global $wpdb;
68
-
69
  $this->row_id = $row_id;
70
  $this->columns = $columns;
71
  $this->raw = $raw;
@@ -74,6 +74,20 @@ class Result {
74
  $this->result_title = isset( $raw[ $source->get_title_column() ] ) ? $raw[ $source->get_title_column() ] : false;
75
  /** @psalm-suppress TooManyArguments */
76
  $this->actions = \apply_filters( 'searchregex_result_actions', $source->get_actions( $this ), $this->source_type, $this );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  }
78
 
79
  /**
@@ -92,9 +106,12 @@ class Result {
92
  'row_id' => $this->row_id,
93
  'source_type' => $this->source_type,
94
  'source_name' => $this->source_name,
 
95
  'columns' => $columns,
 
96
  'actions' => $this->actions,
97
  'title' => html_entity_decode( $this->result_title ),
 
98
  'match_count' => \array_reduce( $columns, function( $carry, $column ) {
99
  return $carry + $column['match_count'];
100
  }, 0 ),
@@ -102,9 +119,9 @@ class Result {
102
  }
103
 
104
  /**
105
- * Get the Match_Column array
106
  *
107
- * @return Array Match_Column array
108
  */
109
  public function get_columns() {
110
  return $this->columns;
@@ -136,4 +153,27 @@ class Result {
136
  public function get_source_type() {
137
  return $this->source_type;
138
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
  }
1
  <?php
2
 
3
+ namespace SearchRegex\Search;
4
+
5
+ use SearchRegex\Source;
6
 
7
  /**
8
  * Contains all information for a search result - a database row that contains matches
39
  /**
40
  * Array of columns with matches
41
  *
42
+ * @var Search\Column[]
43
  **/
44
  private $columns;
45
 
58
  private $actions = [];
59
 
60
  /**
61
+ * Create the result given a row ID, the Source\Source, a set of columns, and the raw database data.
62
  *
63
  * @param Int $row_id Database row ID.
64
+ * @param Source\Source $source The search source.
65
+ * @param Array $columns Array of Search\Column objects.
66
  * @param Array $raw Raw row data.
67
  */
68
+ public function __construct( $row_id, Source\Source $source, array $columns, $raw ) {
 
 
69
  $this->row_id = $row_id;
70
  $this->columns = $columns;
71
  $this->raw = $raw;
74
  $this->result_title = isset( $raw[ $source->get_title_column() ] ) ? $raw[ $source->get_title_column() ] : false;
75
  /** @psalm-suppress TooManyArguments */
76
  $this->actions = \apply_filters( 'searchregex_result_actions', $source->get_actions( $this ), $this->source_type, $this );
77
+
78
+ // Get columns as positional values
79
+ $schema = $source->get_schema_order();
80
+
81
+ usort( $this->columns, function( $a, $b ) use ( $schema ) {
82
+ $a = $schema[ $a->get_column_id() ];
83
+ $b = $schema[ $b->get_column_id() ];
84
+
85
+ if ( $a === $b ) {
86
+ return 0;
87
+ }
88
+
89
+ return $a < $b ? -1 : 1;
90
+ } );
91
  }
92
 
93
  /**
106
  'row_id' => $this->row_id,
107
  'source_type' => $this->source_type,
108
  'source_name' => $this->source_name,
109
+
110
  'columns' => $columns,
111
+
112
  'actions' => $this->actions,
113
  'title' => html_entity_decode( $this->result_title ),
114
+
115
  'match_count' => \array_reduce( $columns, function( $carry, $column ) {
116
  return $carry + $column['match_count'];
117
  }, 0 ),
119
  }
120
 
121
  /**
122
+ * Get the Search\Column array
123
  *
124
+ * @return Array Search\Column array
125
  */
126
  public function get_columns() {
127
  return $this->columns;
153
  public function get_source_type() {
154
  return $this->source_type;
155
  }
156
+
157
+ /**
158
+ * Get array of changes for this result
159
+ *
160
+ * @return array
161
+ */
162
+ public function get_updates() {
163
+ $updates = [];
164
+
165
+ foreach ( $this->columns as $column ) {
166
+ $change = $column->get_changes( $this->raw );
167
+ $same = $column->get_same( $this->raw );
168
+
169
+ if ( count( $change ) > 0 ) {
170
+ $updates[ $column->get_column_id() ] = [
171
+ 'change' => $change,
172
+ 'same' => $same,
173
+ ];
174
+ }
175
+ }
176
+
177
+ return $updates;
178
+ }
179
  }
includes/search/class-search.php ADDED
@@ -0,0 +1,271 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Search;
4
+
5
+ use SearchRegex\Action;
6
+ use SearchRegex\Filter;
7
+
8
+ require_once __DIR__ . '/class-match-text.php';
9
+ require_once __DIR__ . '/class-match-column.php';
10
+ require_once __DIR__ . '/class-flags.php';
11
+ require_once __DIR__ . '/class-totals.php';
12
+ require_once __DIR__ . '/class-preset.php';
13
+ require_once __DIR__ . '/class-result.php';
14
+
15
+ /**
16
+ * Perform a search
17
+ */
18
+ class Search {
19
+ /**
20
+ * The sources to search across.
21
+ *
22
+ * @var list<Source\Source>
23
+ **/
24
+ private $sources = [];
25
+
26
+ /**
27
+ * Create a Search object, with a search value, an array of sources, and some search flags
28
+ *
29
+ * @param Array $sources Array of Source\Source objects. Only one is supported.
30
+ */
31
+ public function __construct( array $sources ) {
32
+ $this->sources = $sources;
33
+ }
34
+
35
+ /**
36
+ * Get a single database row
37
+ *
38
+ * @param integer $row_id Row ID to return.
39
+ * @param Action\Action $action Action.
40
+ * @return \WP_Error|Array Return a single database row, or \WP_Error on error
41
+ */
42
+ public function get_row( $row_id, Action\Action $action ) {
43
+ $results = $this->sources[0]->get_row( $row_id );
44
+
45
+ // Error
46
+ if ( is_wp_error( $results ) ) {
47
+ return $results;
48
+ }
49
+
50
+ return $this->convert_rows_to_results( [
51
+ [
52
+ 'results' => $results,
53
+ 'source_pos' => 0,
54
+ ],
55
+ ], $action );
56
+ }
57
+
58
+ /**
59
+ * Perform the search, returning a result array that contains the totals, the progress, and an array of Result objects
60
+ *
61
+ * @param Action\Action $action The action to perform on the search.
62
+ * @param int $offset Current page offset.
63
+ * @param int $per_page Per page limit.
64
+ * @param int $limit Max number of results.
65
+ * @return Array|\WP_Error Array containing `totals`, `progress`, and `results`
66
+ */
67
+ public function get_search_results( Action\Action $action, $offset, $per_page, $limit = 0 ) {
68
+ $totals = new Totals();
69
+
70
+ // Get total results
71
+ $result = $totals->get_totals( $this->sources );
72
+ if ( $result instanceof \WP_Error ) {
73
+ return $result;
74
+ }
75
+
76
+ // Get the data
77
+ $rows = $this->get_search_data( $offset, $per_page, $totals );
78
+ if ( $rows instanceof \WP_Error ) {
79
+ return $rows;
80
+ }
81
+
82
+ // Convert it to Results, performing any action along the way
83
+ $results = $this->convert_rows_to_results( $rows, $action );
84
+ if ( $results instanceof \WP_Error ) {
85
+ return $results;
86
+ }
87
+
88
+ // Calculate the prev/next pages of results
89
+ $previous = max( 0, $offset - $per_page );
90
+ $next = $totals->get_next_page( $offset + $per_page );
91
+
92
+ // We always go in $per_page groups, but we need to limit if we only need a few more to fill a result set
93
+ if ( $limit > 0 && $limit < count( $results ) ) {
94
+ $next = min( $offset + $limit, $next );
95
+ $results = array_slice( $results, 0, $limit );
96
+ }
97
+
98
+ if ( $next === $offset ) {
99
+ $next = false;
100
+ }
101
+
102
+ if ( $previous === $offset ) {
103
+ $previous = false;
104
+ }
105
+
106
+ return [
107
+ 'results' => $action->should_save() ? [] : $results,
108
+ 'totals' => $totals->to_json(),
109
+ 'progress' => [
110
+ 'current' => $offset,
111
+ 'rows' => count( $results ),
112
+ 'previous' => $previous,
113
+ 'next' => $next,
114
+ ],
115
+ ];
116
+ }
117
+
118
+ /**
119
+ * Get totals for source
120
+ *
121
+ * @param Totals $totals Totals.
122
+ * @param Source\Source $source Source.
123
+ * @return integer
124
+ */
125
+ protected function get_total_for_source( Totals $totals, Source\Source $source ) {
126
+ return $totals->get_total_rows_for_source( $source->get_type() );
127
+ }
128
+
129
+ /**
130
+ * Get the match data for a search. We merge all result sets for all sources together, and then paginate across them.
131
+ *
132
+ * @param Int $absolute_offset Absolute page offset across all sources (assuming they don't change).
133
+ * @param Int $limit Page limit.
134
+ * @param Totals $totals Source totals.
135
+ * @return \WP_Error|Array Data array
136
+ */
137
+ public function get_search_data( $absolute_offset, $limit, Totals $totals ) {
138
+ $results = [];
139
+ $current_offset = 0;
140
+ $remaining_limit = $limit;
141
+
142
+ // Go through each row and see if our $absolute_offset + $limit is within it's result set
143
+ foreach ( $this->sources as $source_pos => $source ) {
144
+ // Get total number of rows for this source
145
+ $num_rows = $totals->get_matched_rows_for_source( $source->get_type() );
146
+
147
+ // Are we within the correct result set?
148
+ if ( $num_rows > 0 && $current_offset + $num_rows >= $absolute_offset ) {
149
+ // Adjust for the current source offset
150
+ $source_offset = max( 0, $absolute_offset - $current_offset );
151
+
152
+ // Read up to our remaining limit, or the remaining number of rows
153
+ $source_limit = min( $remaining_limit, $num_rows - $source_offset );
154
+ $source_results = $source->get_matched_rows( $source_offset, $source_limit );
155
+
156
+ // Check for an error
157
+ if ( $source_results instanceof \WP_Error ) {
158
+ return $source_results;
159
+ }
160
+
161
+ // Subtract the rows we've read from this source. There could be rows in another source to read
162
+ $remaining_limit -= $source_limit;
163
+ $current_offset = $source_offset + count( $source_results );
164
+
165
+ // Append to merged set
166
+ $results[] = [
167
+ 'source_pos' => $source_pos,
168
+ 'results' => $source_results,
169
+ ];
170
+
171
+ if ( $remaining_limit <= 0 ) {
172
+ break;
173
+ }
174
+ } else {
175
+ // Move on to the next absolute offset
176
+ $current_offset += $num_rows;
177
+ }
178
+ }
179
+
180
+ return $results;
181
+ }
182
+
183
+ /**
184
+ * Convert database rows into Result objects
185
+ *
186
+ * @internal
187
+ * @param array $source_results Array of row data.
188
+ * @param Action\Action $action Action\Action object.
189
+ * @return Result[]|\WP_Error Array of results
190
+ */
191
+ public function convert_rows_to_results( array $source_results, Action\Action $action ) {
192
+ $results = [];
193
+
194
+ // Loop over the source results, extracting the source and results for that source
195
+ foreach ( $source_results as $result ) {
196
+ $source = $this->sources[ $result['source_pos'] ];
197
+ $rows = $result['results'];
198
+
199
+ // Loop over the results for the source
200
+ foreach ( $rows as $row ) {
201
+ $result = $this->convert_search_results( $action, $row, $source );
202
+
203
+ if ( $result instanceof \WP_Error ) {
204
+ return $result;
205
+ }
206
+
207
+ if ( $result ) {
208
+ if ( $action->should_save() ) {
209
+ $this->save_changes( $result );
210
+ }
211
+
212
+ $results[] = $result;
213
+ }
214
+ }
215
+ }
216
+
217
+ return $results;
218
+ }
219
+
220
+ /**
221
+ * Convert a database row into a Result, after performing any action
222
+ *
223
+ * @param Action\Action $action Action\Action.
224
+ * @param array $row Data.
225
+ * @param Source\Source $source Source.
226
+ * @return Result|\WP_Error|false
227
+ */
228
+ private function convert_search_results( Action\Action $action, $row, $source ) {
229
+ // Get the matches
230
+ $matches = Filter\Filter::get_result_matches( $source, $row, $action );
231
+ $row_id = intval( array_values( $row )[0], 10 );
232
+
233
+ // Perform the actions, if we are saving
234
+ $matches = $action->perform( $row_id, $row, $source, $matches );
235
+ if ( $matches instanceof \WP_Error ) {
236
+ return $matches;
237
+ }
238
+
239
+ if ( count( $matches ) > 0 ) {
240
+ return new Result( $row_id, $source, $matches, $row );
241
+ }
242
+
243
+ if ( count( $source->get_filters() ) === 0 ) {
244
+ // No filters - just return the row as-is
245
+ return new Result( $row_id, $source, [], $row );
246
+ }
247
+
248
+ return false;
249
+ }
250
+
251
+ /**
252
+ * Save a set of changes on results.
253
+ *
254
+ * @param Result $result Result.
255
+ * @return boolean|\WP_Error
256
+ */
257
+ public function save_changes( Result $result ) {
258
+ foreach ( $this->sources as $source ) {
259
+ if ( $source->is_type( $result->get_source_type() ) ) {
260
+ $updates = $result->get_updates();
261
+
262
+ if ( count( $updates ) > 0 ) {
263
+ return $source->save( $result->get_row_id(), $updates );
264
+ }
265
+ }
266
+ }
267
+
268
+ // No changes
269
+ return false;
270
+ }
271
+ }
includes/search/class-totals.php ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Search;
4
+
5
+ /**
6
+ * Collects totals for a search across multiple sources
7
+ */
8
+ class Totals {
9
+ /**
10
+ * Total rows and matches
11
+ *
12
+ * @var array<string,array{rows: int, matched_rows: int}>
13
+ */
14
+ private $totals = [];
15
+
16
+ /**
17
+ * `true` if we have a regex search anywhere, `false` othewise
18
+ *
19
+ * @var boolean
20
+ */
21
+ private $has_advanced = false;
22
+
23
+ /**
24
+ * The grand totals across all sources
25
+ *
26
+ * @var array{rows: int, matched_rows: int}
27
+ */
28
+ private $grand_totals = [
29
+ 'rows' => 0,
30
+ 'matched_rows' => 0,
31
+ ];
32
+
33
+ /**
34
+ * Look through an array of Source\Source objects and see if anything is an advanced search
35
+ *
36
+ * @param array<Source\Source> $sources Sources.
37
+ * @return void
38
+ */
39
+ private function set_advanced( array $sources ) {
40
+ $advanced = array_filter( $sources, function( $source ) {
41
+ return $source->has_advanced_filter();
42
+ } );
43
+
44
+ $this->has_advanced = count( $advanced ) > 0;
45
+ }
46
+
47
+ /**
48
+ * Get total number of matches and rows across each source
49
+ *
50
+ * @param array<Source\Source> $sources Sources.
51
+ * @return \WP_Error|Bool Array of totals
52
+ */
53
+ public function get_totals( array $sources ) {
54
+ $this->set_advanced( $sources );
55
+
56
+ // Loop over each source
57
+ foreach ( $sources as $source ) {
58
+ // Get number of matching rows
59
+ $rows = $source->get_total_rows();
60
+ if ( $rows instanceof \WP_Error ) {
61
+ return $rows;
62
+ }
63
+
64
+ $name = $source->get_type();
65
+
66
+ // Basic total for each source
67
+ $this->totals[ $name ] = [
68
+ 'rows' => intval( $rows, 10 ),
69
+ 'matched_rows' => 0,
70
+ ];
71
+
72
+ // If we have no advanced searches then we get the matched phrase totals
73
+ if ( ! $this->has_advanced ) {
74
+ $matches = $source->get_global_match_total( $source->get_filters() );
75
+ if ( $matches instanceof \WP_Error ) {
76
+ return $matches;
77
+ }
78
+
79
+ $this->totals[ $name ]['matched_rows'] += intval( $matches['rows'], 10 );
80
+ }
81
+
82
+ // Add to grand totals
83
+ $this->add_to_grand_total( $this->totals[ $name ] );
84
+ }
85
+
86
+ return true;
87
+ }
88
+
89
+ /**
90
+ * Add a source total to the grand total
91
+ *
92
+ * @param array{rows: int, matched_rows: int} $total The source totals.
93
+ * @return void
94
+ */
95
+ private function add_to_grand_total( $total ) {
96
+ $this->grand_totals['rows'] += $total['rows'];
97
+ $this->grand_totals['matched_rows'] += $total['matched_rows'];
98
+ }
99
+
100
+ /**
101
+ * Get total rows for a source
102
+ *
103
+ * @param String $source_name Source name.
104
+ * @return integer Number of matches for the row
105
+ */
106
+ public function get_total_rows_for_source( $source_name ) {
107
+ if ( isset( $this->totals[ $source_name ] ) ) {
108
+ return $this->totals[ $source_name ]['rows'];
109
+ }
110
+
111
+ return 0;
112
+ }
113
+
114
+ /**
115
+ * Get total matched rows for a source
116
+ *
117
+ * @param String $source_name Source name.
118
+ * @return Int Number of matches for the row
119
+ */
120
+ public function get_matched_rows_for_source( $source_name ) {
121
+ if ( $this->has_advanced ) {
122
+ return $this->get_total_rows_for_source( $source_name );
123
+ }
124
+
125
+ if ( isset( $this->totals[ $source_name ] ) ) {
126
+ return $this->totals[ $source_name ]['matched_rows'];
127
+ }
128
+
129
+ return 0;
130
+ }
131
+
132
+ /**
133
+ * Get the next page offset.
134
+ *
135
+ * @param Int $next_offset The offset of the next page.
136
+ * @return Int|false Next offset, or false if no next offset
137
+ */
138
+ public function get_next_page( $next_offset ) {
139
+ if ( $this->has_advanced ) {
140
+ return $next_offset >= $this->grand_totals['rows'] ? false : $next_offset;
141
+ }
142
+
143
+ return $next_offset >= $this->grand_totals['matched_rows'] ? false : $next_offset;
144
+ }
145
+
146
+ /**
147
+ * Return the grand totals as JSON
148
+ *
149
+ * @return array{rows: int, matched_rows: int}
150
+ */
151
+ public function to_json() {
152
+ return $this->grand_totals;
153
+ }
154
+ }
includes/source/class-autocomplete.php ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Source;
4
+
5
+ use SearchRegex\Sql;
6
+
7
+ /**
8
+ * Provides autocomplete functions
9
+ *
10
+ * @psalm-immutable
11
+ */
12
+ class Autocomplete {
13
+ /**
14
+ * Autocomplete a user name
15
+ *
16
+ * @param string $value Value.
17
+ * @return list<object{id: string, value: string}>
18
+ */
19
+ public static function get_user( $value ) {
20
+ global $wpdb;
21
+
22
+ return $wpdb->get_results( $wpdb->prepare( "SELECT ID as id,display_name as value FROM {$wpdb->users} WHERE display_name LIKE %s LIMIT %d", '%' . $wpdb->esc_like( $value ) . '%', Source::AUTOCOMPLETE_LIMIT ) );
23
+ }
24
+
25
+ /**
26
+ * Autocomplete a post title
27
+ *
28
+ * @param string $value Value.
29
+ * @param Sql\Sql\Value $id_column ID column.
30
+ * @param Sql\Sql\Value $search_column Search column.
31
+ * @return list<object{id: string, value: string}>
32
+ */
33
+ public static function get_post( $value, Sql\Sql\Value $id_column, Sql\Sql\Value $search_column ) {
34
+ global $wpdb;
35
+
36
+ $type_sql = "AND post_status != 'inherit'"; // Ignore attachments
37
+
38
+ $column = $id_column->get_value();
39
+ $search = $search_column->get_value();
40
+
41
+ // phpcs:ignore
42
+ return $wpdb->get_results( $wpdb->prepare( "SELECT {$column} as id,post_title as value FROM {$wpdb->posts} WHERE {$search} LIKE %s {$type_sql} LIMIT %d", '%' . $wpdb->esc_like( $value ) . '%', Source::AUTOCOMPLETE_LIMIT ) );
43
+ }
44
+
45
+ /**
46
+ * Autocomplete a term (tag or category)
47
+ *
48
+ * @param string $type Term term (post_tag or category).
49
+ * @param string $value Value.
50
+ * @return list<object{id: string, value: string}>
51
+ */
52
+ private static function get_terms( $type, $value ) {
53
+ $results = [];
54
+ $terms = get_terms( [
55
+ 'taxonomy' => $type,
56
+ 'hide_empty' => false,
57
+ 'number' => Source::AUTOCOMPLETE_LIMIT,
58
+ 'search' => $value,
59
+ ] );
60
+
61
+ if ( ! is_array( $terms ) ) {
62
+ return [];
63
+ }
64
+
65
+ foreach ( $terms as $term ) {
66
+ if ( is_object( $term ) ) {
67
+ $results[] = (object) [
68
+ 'id' => $term->term_id,
69
+ 'value' => $term->name,
70
+ ];
71
+ }
72
+ }
73
+
74
+ return $results;
75
+ }
76
+
77
+ /**
78
+ * Autocomplete a category
79
+ *
80
+ * @param string $value Value.
81
+ * @return list<object{id: string, value: string}>
82
+ */
83
+ public static function get_category( $value ) {
84
+ return self::get_terms( 'category', $value );
85
+ }
86
+
87
+ /**
88
+ * Autocomplete a tag
89
+ *
90
+ * @param string $value Value.
91
+ * @return list<object{id: string, value: string}>
92
+ */
93
+ public static function get_tag( $value ) {
94
+ return self::get_terms( 'post_tag', $value );
95
+ }
96
+
97
+ /**
98
+ * Autocomplete meta data
99
+ *
100
+ * @param Sql\Sql\Value $table Meta table.
101
+ * @param string $value Value.
102
+ * @return list<object{id: string, value: string}>
103
+ */
104
+ public static function get_meta( Sql\Sql\Value $table, $value ) {
105
+ global $wpdb;
106
+
107
+ $table = $wpdb->prefix . $table->get_value();
108
+
109
+ // phpcs:ignore
110
+ return $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT meta_key as id,meta_key as value FROM {$table} WHERE meta_key LIKE %s LIMIT %d", '%' . $wpdb->esc_like( $value ) . '%', Source::AUTOCOMPLETE_LIMIT ) );
111
+ }
112
+
113
+ /**
114
+ * Autocomplete a comment
115
+ *
116
+ * @param string $value Value.
117
+ * @return list<object{id: string, value: string}>
118
+ */
119
+ public static function get_comment( $value ) {
120
+ global $wpdb;
121
+
122
+ return $wpdb->get_results( $wpdb->prepare( "SELECT comment_ID as id,comment_content as value FROM {$wpdb->comments} WHERE comment_content LIKE %s LIMIT %d", '%' . $wpdb->esc_like( $value ) . '%', Source::AUTOCOMPLETE_LIMIT ) );
123
+ }
124
+ }
includes/source/class-convert-values.php ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Source;
4
+
5
+ use SearchRegex\Schema;
6
+
7
+ /**
8
+ * Convert a value to a label
9
+ */
10
+ class Convert_Values {
11
+ /**
12
+ * Perform the conversion on the column and value
13
+ *
14
+ * @param Schema\Column $column Column.
15
+ * @param string|integer $value Value.
16
+ * @return string
17
+ */
18
+ public function convert( Schema\Column $column, $value ) {
19
+ $func = 'get_' . $column->get_column();
20
+
21
+ if ( method_exists( $this, $func ) ) {
22
+ return $this->$func( $column, $value );
23
+ }
24
+
25
+ $func = 'get_' . $column->get_type();
26
+
27
+ if ( method_exists( $this, $func ) ) {
28
+ return $this->$func( $column, $value );
29
+ }
30
+
31
+ return (string) $value;
32
+ }
33
+
34
+ /**
35
+ * Get a post tag given the ID
36
+ *
37
+ * @param Schema\Column $column Column.
38
+ * @param integer $value Value.
39
+ * @return string
40
+ */
41
+ public function get_post_tag( $column, $value ) {
42
+ return $this->get_term( $column, $value );
43
+ }
44
+
45
+ /**
46
+ * Get a post category given the ID
47
+ *
48
+ * @param Schema\Column $column Column.
49
+ * @param integer $value Value.
50
+ * @return string
51
+ */
52
+ public function get_category( $column, $value ) {
53
+ return $this->get_term( $column, $value );
54
+ }
55
+
56
+ /**
57
+ * Get a term name given the ID
58
+ *
59
+ * @param Schema\Column $column Column.
60
+ * @param integer $value Value.
61
+ * @return string
62
+ */
63
+ public function get_term( $column, $value ) {
64
+ $term = get_term( $value, $column->get_column() );
65
+
66
+ if ( $term && ! $term instanceof \WP_Error && is_object( $term ) ) {
67
+ return $term->name;
68
+ }
69
+
70
+ return (string) $value;
71
+ }
72
+
73
+ /**
74
+ * Get a post type given the name
75
+ *
76
+ * @param Schema\Column $column Column.
77
+ * @param integer $value Value.
78
+ * @return string
79
+ */
80
+ public function get_post_type( $column, $value ) {
81
+ $names = get_post_types( [ 'name' => $value ], 'objects' );
82
+
83
+ if ( isset( $names[ $value ] ) && is_object( $names[ $value ] ) ) {
84
+ return $names[ $value ]->label;
85
+ }
86
+
87
+ return (string) $value;
88
+ }
89
+
90
+ /**
91
+ * Get a user given the ID
92
+ *
93
+ * @param Schema\Column $column Column.
94
+ * @param string $value Value.
95
+ * @return string
96
+ */
97
+ public function get_post_author( $column, $value ) {
98
+ return $this->get_user( $column, $value );
99
+ }
100
+
101
+ /**
102
+ * Get a user given the ID
103
+ *
104
+ * @param Schema\Column|string $column Column.
105
+ * @param string $value Value.
106
+ * @return string
107
+ */
108
+ public function get_user( $column, $value ) {
109
+ $user = get_userdata( intval( $value, 10 ) );
110
+
111
+ if ( $user ) {
112
+ return $user->display_name;
113
+ }
114
+
115
+ return $value;
116
+ }
117
+
118
+ /**
119
+ * Get a post title given the ID
120
+ *
121
+ * @param Schema\Column $column Column.
122
+ * @param integer $value Value.
123
+ * @return string
124
+ */
125
+ public function get_post_title( $column, $value ) {
126
+ $post = get_post( $value );
127
+
128
+ if ( is_object( $post ) ) {
129
+ return $post->post_title;
130
+ }
131
+
132
+ return (string) $value;
133
+ }
134
+
135
+ /**
136
+ * Get a date in user's date format
137
+ *
138
+ * @param Schema\Column $column Column.
139
+ * @param string $value Value.
140
+ * @return string
141
+ */
142
+ public function get_date( $column, $value ) {
143
+ return date( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), intval( mysql2date( 'U', $value ), 10 ) );
144
+ }
145
+ }
includes/source/class-manager.php ADDED
@@ -0,0 +1,274 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Source;
4
+
5
+ use SearchRegex\Source;
6
+ use SearchRegex\Schema;
7
+ use SearchRegex\Filter\Type;
8
+
9
+ /**
10
+ * Create Source objects
11
+ */
12
+ class Manager {
13
+ /**
14
+ * Return all the core source types
15
+ *
16
+ * @return Array
17
+ */
18
+ private static function get_core_sources() {
19
+ $sources = [
20
+ [
21
+ 'name' => 'posts',
22
+ 'class' => 'SearchRegex\Source\Core\Post',
23
+ 'label' => __( 'Posts (core & custom)', 'search-regex' ),
24
+ 'type' => 'core',
25
+ ],
26
+ [
27
+ 'name' => 'comment',
28
+ 'class' => 'SearchRegex\Source\Core\Comment',
29
+ 'label' => __( 'Comments', 'search-regex' ),
30
+ 'type' => 'core',
31
+ ],
32
+ [
33
+ 'name' => 'user',
34
+ 'class' => 'SearchRegex\Source\Core\User',
35
+ 'label' => __( 'Users', 'search-regex' ),
36
+ 'type' => 'core',
37
+ ],
38
+ [
39
+ 'name' => 'options',
40
+ 'class' => 'SearchRegex\Source\Core\Options',
41
+ 'label' => __( 'WordPress Options', 'search-regex' ),
42
+ 'type' => 'core',
43
+ ],
44
+ ];
45
+
46
+ return apply_filters( 'searchregex_sources_core', $sources );
47
+ }
48
+
49
+ /**
50
+ * Return all the advanced source types
51
+ *
52
+ * @return Array
53
+ */
54
+ private static function get_advanced_sources() {
55
+ $sources = [
56
+ [
57
+ 'name' => 'post-meta',
58
+ 'class' => 'SearchRegex\Source\Core\Post_Meta',
59
+ 'label' => __( 'Post Meta', 'search-regex' ),
60
+ 'type' => 'advanced',
61
+ ],
62
+ [
63
+ 'name' => 'comment-meta',
64
+ 'class' => 'SearchRegex\Source\Core\Comment_Meta',
65
+ 'label' => __( 'Comment Meta', 'search-regex' ),
66
+ 'type' => 'advanced',
67
+ ],
68
+ [
69
+ 'name' => 'user-meta',
70
+ 'class' => 'SearchRegex\Source\Core\User_Meta',
71
+ 'label' => __( 'User Meta', 'search-regex' ),
72
+ 'type' => 'advanced',
73
+ ],
74
+ [
75
+ 'name' => 'terms',
76
+ 'class' => 'SearchRegex\Source\Core\Terms',
77
+ 'label' => __( 'Terms', 'search-regex' ),
78
+ 'type' => 'advanced',
79
+ ],
80
+ ];
81
+
82
+ return apply_filters( 'searchregex_sources_advanced', $sources );
83
+ }
84
+
85
+ /**
86
+ * Return an array of all the database sources. Note this is filtered with `searchregex_sources`
87
+ *
88
+ * @return Array The array of database sources as name => class
89
+ */
90
+ public static function get_all_sources() {
91
+ $core_sources = self::get_core_sources();
92
+ $advanced_sources = self::get_advanced_sources();
93
+
94
+ // Load custom stuff here
95
+ $plugin_sources = glob( __DIR__ . '/plugin/*.php' );
96
+ foreach ( $plugin_sources as $plugin ) {
97
+ /**
98
+ * @psalm-suppress UnresolvableInclude
99
+ */
100
+ require_once $plugin;
101
+ }
102
+
103
+ $plugin_sources = apply_filters( 'searchregex_sources_plugin', [] );
104
+ $plugin_sources = array_map( function( $source ) {
105
+ $source['type'] = 'plugin';
106
+ return $source;
107
+ }, $plugin_sources );
108
+
109
+ return array_values(
110
+ array_merge(
111
+ array_values( $core_sources ),
112
+ array_values( $advanced_sources ),
113
+ array_values( $plugin_sources )
114
+ )
115
+ );
116
+ }
117
+
118
+ /**
119
+ * Get schema for a list of sources
120
+ *
121
+ * @param array $sources Sources.
122
+ * @return Schema\Source[]
123
+ */
124
+ public static function get_schema( array $sources = [] ) {
125
+ $all = self::get_all_source_names();
126
+ $handlers = self::get( $all, [] );
127
+ $schema = [];
128
+
129
+ foreach ( $handlers as $source ) {
130
+ $newschema = $source->get_schema_for_source();
131
+ $newschema['type'] = $source->get_type() === 'post' ? 'posts' : $source->get_type();
132
+
133
+ if ( count( $sources ) === 0 || in_array( $source->get_type(), $sources, true ) ) {
134
+ $schema[] = $newschema;
135
+ }
136
+ }
137
+
138
+ return apply_filters( 'searchregex_schema_source', $schema );
139
+ }
140
+
141
+ /**
142
+ * Get all the sources grouped into 'core', 'posttype', and 'plugin' groups.
143
+ *
144
+ * @return Array Associative array of sources, grouped by type
145
+ */
146
+ public static function get_all_grouped() {
147
+ $sources = self::get_all_sources();
148
+
149
+ $groups = [
150
+ [
151
+ 'name' => 'core',
152
+ 'label' => __( 'Standard', 'search-regex' ),
153
+ 'sources' => array_values( array_filter( $sources, function( $source ) {
154
+ return $source['type'] === 'core';
155
+ } ) ),
156
+ ],
157
+ [
158
+ 'name' => 'advanced',
159
+ 'label' => __( 'Advanced', 'search-regex' ),
160
+ 'sources' => array_values( array_filter( $sources, function( $source ) {
161
+ return $source['type'] === 'advanced';
162
+ } ) ),
163
+ ],
164
+ [
165
+ 'name' => 'plugin',
166
+ 'label' => __( 'Plugins', 'search-regex' ),
167
+ 'sources' => array_values( array_filter( $sources, function( $source ) {
168
+ return $source['type'] === 'plugin';
169
+ } ) ),
170
+ ],
171
+ ];
172
+
173
+ return array_values( array_filter( apply_filters( 'searchregex_source_groups', $groups ), function( $group ) {
174
+ return count( $group['sources'] ) > 0;
175
+ } ) );
176
+ }
177
+
178
+ /**
179
+ * Return a particular Source object for the given name
180
+ *
181
+ * @param String $source Source name.
182
+ * @param array<Filter\Filter> $filters Search filters.
183
+ * @return object|null
184
+ */
185
+ private static function get_handler_for_source( $source, array $filters ) {
186
+ $sources = self::get_all_sources();
187
+
188
+ foreach ( $sources as $handler ) {
189
+ if ( $handler['name'] === $source ) {
190
+ // Only use the filters for this source
191
+ $filters = array_filter( $filters, function( $filter ) use ( $source ) {
192
+ return $filter->is_for_source( $source );
193
+ } );
194
+
195
+ // Create the source
196
+ return new $handler['class']( $handler, $filters );
197
+ }
198
+ }
199
+
200
+ return null;
201
+ }
202
+
203
+ /**
204
+ * Return a list of all source names only. This can be used for checking a name is allowed.
205
+ *
206
+ * @return Array Array of source names
207
+ */
208
+ public static function get_all_source_names() {
209
+ $sources = self::get_all_sources();
210
+
211
+ return array_map( function( $source ) {
212
+ return $source['name'];
213
+ }, $sources );
214
+ }
215
+
216
+ /**
217
+ * Get all the specified sources as source objects
218
+ *
219
+ * @param Array $sources Array of source names.
220
+ * @param array<Filter\Filter> $filters Search filters.
221
+ * @return Array The array of source objects
222
+ */
223
+ public static function get( $sources, array $filters ) {
224
+ $handlers = [];
225
+
226
+ // Create handlers for everything else
227
+ foreach ( $sources as $source ) {
228
+ $handler = self::get_handler_for_source( $source, $filters );
229
+
230
+ if ( $handler ) {
231
+ $handlers[] = $handler;
232
+ }
233
+ }
234
+
235
+ return $handlers;
236
+ }
237
+
238
+ /**
239
+ * Get preload data for a source.
240
+ *
241
+ * @param string $source_name Source.
242
+ * @param array $filter Filter JSON.
243
+ * @return array
244
+ */
245
+ public static function get_schema_preload( $source_name, array $filter ) {
246
+ $source = self::get_handler_for_source( $source_name, [] );
247
+
248
+ if ( $source ) {
249
+ $schema = $source->get_schema();
250
+
251
+ foreach ( $schema['columns'] as $column ) {
252
+ if ( isset( $filter['column'] ) && $column['column'] === $filter['column'] ) {
253
+ $preload = false;
254
+ if ( $column['type'] === 'member' ) {
255
+ $preload = true;
256
+ } elseif ( $column['type'] === 'integer' && ( ! isset( $filter['logic'] ) || ( $filter['logic'] === 'equals' || $filter['logic'] === 'notequals' ) ) ) {
257
+ $preload = true;
258
+ }
259
+
260
+ if ( $preload ) {
261
+ $schema = new Schema\Source( $source->get_schema() );
262
+ $filter = Type\Filter_Type::create( $filter, new Schema\Column( $column, $schema ) );
263
+
264
+ if ( $filter ) {
265
+ return $source->get_filter_preload( $column, $filter );
266
+ }
267
+ }
268
+ }
269
+ }
270
+ }
271
+
272
+ return [];
273
+ }
274
+ }
includes/source/class-source.php ADDED
@@ -0,0 +1,482 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Source;
4
+
5
+ use SearchRegex\Search_Regex;
6
+ use SearchRegex\Sql;
7
+ use SearchRegex\Schema;
8
+ use SearchRegex\Search;
9
+ use SearchRegex\Filter;
10
+ use SearchRegex\Context;
11
+
12
+ require_once __DIR__ . '/class-manager.php';
13
+ require_once __DIR__ . '/class-convert-values.php';
14
+ require_once __DIR__ . '/class-autocomplete.php';
15
+ require_once __DIR__ . '/trait-has-meta.php';
16
+ require_once __DIR__ . '/trait-has-terms.php';
17
+ require_once __DIR__ . '/core/source-meta.php';
18
+ require_once __DIR__ . '/core/source-post.php';
19
+ require_once __DIR__ . '/core/source-post-meta.php';
20
+ require_once __DIR__ . '/core/source-user.php';
21
+ require_once __DIR__ . '/core/source-user-meta.php';
22
+ require_once __DIR__ . '/core/source-terms.php';
23
+ require_once __DIR__ . '/core/source-comment.php';
24
+ require_once __DIR__ . '/core/source-comment-meta.php';
25
+ require_once __DIR__ . '/core/source-options.php';
26
+
27
+ /**
28
+ * Represents a source of data that can be searched. Typically maps directly to a database table
29
+ */
30
+ abstract class Source {
31
+ const AUTOCOMPLETE_LIMIT = 50;
32
+
33
+ /**
34
+ * Search filters
35
+ *
36
+ * @var array<Filter\Filter>
37
+ */
38
+ protected $filters;
39
+
40
+ /**
41
+ * The source type
42
+ *
43
+ * @var String
44
+ **/
45
+ protected $source_type;
46
+
47
+ /**
48
+ * The source type name
49
+ *
50
+ * @var String
51
+ **/
52
+ protected $source_name;
53
+
54
+ /**
55
+ * Create a Source\Source object
56
+ *
57
+ * @param Array $handler Source handler information - an array of `name`, `class`, `label`, and `type`.
58
+ * @param array<Filter\Filter> $filters Array of Filter\Filter objects for this source.
59
+ */
60
+ public function __construct( array $handler, array $filters ) {
61
+ $this->filters = $filters;
62
+ $this->source_type = isset( $handler['name'] ) ? $handler['name'] : 'unknown';
63
+ $this->source_name = isset( $handler['label'] ) ? $handler['label'] : $this->source_type;
64
+ }
65
+
66
+ /**
67
+ * Return the source type
68
+ *
69
+ * @param Array $row Database row, used in some sources to determine the type.
70
+ * @return String Source type
71
+ */
72
+ public function get_type( array $row = [] ) {
73
+ return $this->source_type;
74
+ }
75
+
76
+ /**
77
+ * Return true if the source matches the type, false otherwise
78
+ *
79
+ * @param String $type Source type.
80
+ * @return boolean
81
+ */
82
+ public function is_type( $type ) {
83
+ return $this->source_type === $type;
84
+ }
85
+
86
+ /**
87
+ * Return the source name
88
+ *
89
+ * @param Array $row Database row, used in some sources to determine the type.
90
+ * @return String A user viewable source name
91
+ */
92
+ public function get_name( array $row = [] ) {
93
+ return $this->source_name;
94
+ }
95
+
96
+ /**
97
+ * Return the associated Filter\Filter items
98
+ *
99
+ * @return list<Filter\Filter> Filter\Filter objects
100
+ */
101
+ public function get_search_filters() {
102
+ return $this->filters;
103
+ }
104
+
105
+ /**
106
+ * Return an array of additional columns to return in a search. These aren't searched, and can be used by the source.
107
+ *
108
+ * @return Array The array of column names
109
+ */
110
+ public function get_info_columns() {
111
+ return [
112
+ new Sql\Select\Select( Sql\Value::table( $this->get_table_name() ), Sql\Value::column( $this->get_title_column() ) ),
113
+ ];
114
+ }
115
+
116
+ /**
117
+ * Return an the table's ID column name
118
+ *
119
+ * @return String The table's ID column name
120
+ */
121
+ abstract public function get_table_id();
122
+
123
+ /**
124
+ * Return the column name used as a visible title for the source. For example, a post would have `post_title`
125
+ *
126
+ * @return String Column used for the title
127
+ */
128
+ abstract public function get_title_column();
129
+
130
+ /**
131
+ * Return the table name
132
+ *
133
+ * @return String The table name for the source
134
+ */
135
+ abstract public function get_table_name();
136
+
137
+ /**
138
+ * Return a visible label for the column. This is shown to the user and should be more descriptive than the column name itself
139
+ *
140
+ * @param String $column Column name.
141
+ * @return String Column label
142
+ */
143
+ public function get_column_label( $column ) {
144
+ foreach ( $this->get_schema()['columns'] as $schema_column ) {
145
+ if ( $schema_column['column'] === $column ) {
146
+ return $schema_column['title'];
147
+ }
148
+ }
149
+
150
+ return $column;
151
+ }
152
+
153
+ /**
154
+ * Get an array of actions for a given row
155
+ *
156
+ * @param Search\Result $result The Search\Result object containing the row from the source.
157
+ * @return Array An array of action type => action URL
158
+ */
159
+ public function get_actions( Search\Result $result ) {
160
+ return [];
161
+ }
162
+
163
+ /**
164
+ * Get the total number of matches for this search
165
+ *
166
+ * @param Filter\Filter[] $filters Search string.
167
+ * @return Array{matches: int, rows: int}|\WP_Error The number of matches as an array of 'matches' and 'rows', or \WP_Error on error
168
+ */
169
+ public function get_global_match_total( array $filters ) {
170
+ $query = Filter\Filter::get_as_query( $filters, $this );
171
+ $query->add_from( new Sql\From( Sql\Value::column( $this->get_table_name() ) ) );
172
+
173
+ $sql = new Sql\Builder();
174
+
175
+ $result = $sql->get_result( $query, new Sql\Modifier\Select_Count_Id( Sql\Value::table( $this->get_table_name() ), Sql\Value::column( $this->get_table_id() ) ) );
176
+ if ( $result instanceof \WP_Error ) {
177
+ return $result;
178
+ }
179
+
180
+ return [
181
+ 'matches' => isset( $result->match_total ) ? intval( $result->match_total, 10 ) : 0,
182
+ 'rows' => intval( $result->match_rows, 10 ),
183
+ ];
184
+ }
185
+
186
+ /**
187
+ * Get total number of rows for this source
188
+ *
189
+ * @return Int|\WP_Error The number of rows, or \WP_Error on error
190
+ */
191
+ public function get_total_rows() {
192
+ $sql = new Sql\Builder();
193
+
194
+ $query = new Sql\Query();
195
+ $query->add_select( new Sql\Select\Select( Sql\Value::table( $this->get_table_name() ), Sql\Value::safe_raw( 'COUNT(*)' ) ) );
196
+ $query->add_from( new Sql\From( Sql\Value::column( $this->get_table_name() ) ) );
197
+
198
+ return $sql->get_count( $query );
199
+ }
200
+
201
+ /**
202
+ * Get a single row from the source
203
+ *
204
+ * @param int $row_id The row ID.
205
+ * @return array|\WP_Error The database row, or \WP_Error on error
206
+ */
207
+ public function get_row( $row_id ) {
208
+ $builder = new Sql\Builder();
209
+
210
+ // Create query
211
+ $query = new Sql\Query();
212
+ $query->add_selects( $this->get_query_selects() );
213
+ $query->add_from( new Sql\From( Sql\Value::column( $this->get_table_name() ) ) );
214
+
215
+ // Add the filters except the where
216
+ $query->add_query_except_where( Filter\Filter::get_as_query( $this->filters, $this ) );
217
+
218
+ // Add our row ID
219
+ $query->add_where( new Sql\Where\Where_Integer( new Sql\Select\Select( Sql\Value::table( $this->get_table_name() ), Sql\Value::column( $this->get_table_id() ) ), 'equals', $row_id ) );
220
+
221
+ return $builder->get_search( $query );
222
+ }
223
+
224
+ /**
225
+ * Get columns for a single row
226
+ *
227
+ * @param int $row_id The row ID.
228
+ * @return array|\WP_Error
229
+ */
230
+ public function get_row_columns( $row_id ) {
231
+ global $wpdb;
232
+
233
+ $columns = array_filter( $this->get_schema()['columns'], function( $column ) {
234
+ if ( isset( $column['join'] ) ) {
235
+ return false;
236
+ }
237
+
238
+ if ( isset( $column['modify'] ) && $column['modify'] === false ) {
239
+ return false;
240
+ }
241
+
242
+ return true;
243
+ } );
244
+
245
+ $columns = array_map( function( $column ) {
246
+ return $column['column'];
247
+ }, $columns );
248
+
249
+ // Known query
250
+ // phpcs:ignore
251
+ $row = $wpdb->get_row( $wpdb->prepare( "SELECT " . implode( ',', $columns ) . " FROM {$this->get_table_name()} WHERE {$this->get_table_id()}=%d", $row_id ), ARRAY_A );
252
+ if ( $row === null ) {
253
+ return new \WP_Error( 'searchregex_database', 'No row for ' . (string) $row_id, 401 );
254
+ }
255
+
256
+ // Convert it, then get other stuff
257
+ $row_columns = [];
258
+ foreach ( $row as $column => $value ) {
259
+ $row_columns[] = [
260
+ 'column' => $column,
261
+ 'value' => $value,
262
+ ];
263
+ }
264
+
265
+ return $row_columns;
266
+ }
267
+
268
+ /**
269
+ * Get a set of matching rows
270
+ *
271
+ * @param int $offset The row offset.
272
+ * @param int $limit The number of rows to return.
273
+ * @return Array|\WP_Error The database rows, or \WP_Error on error
274
+ */
275
+ public function get_matched_rows( $offset, $limit ) {
276
+ $builder = new Sql\Builder();
277
+
278
+ // Create query
279
+ $query = new Sql\Query();
280
+ $query->add_selects( $this->get_query_selects() );
281
+ $query->add_from( new Sql\From( Sql\Value::column( $this->get_table_name() ) ) );
282
+ $query->set_paging( $offset, $limit );
283
+ $query->set_order( $this->get_table_name() . '.' . $this->get_table_id() );
284
+
285
+ // Add filters
286
+ $query->add_query( Filter\Filter::get_as_query( $this->filters, $this ) );
287
+
288
+ return $builder->get_search( $query );
289
+ }
290
+
291
+ /**
292
+ * Can we replace this column?
293
+ *
294
+ * @param string $column Column name.
295
+ * @return boolean
296
+ */
297
+ private function can_replace_column( $column ) {
298
+ foreach ( $this->get_schema()['columns'] as $column_schema ) {
299
+ if ( $column_schema['column'] === $column ) {
300
+ return ! isset( $column_schema['modify'] ) || $column_schema['modify'];
301
+ }
302
+ }
303
+
304
+ return false;
305
+ }
306
+
307
+ /**
308
+ * Get array of columns to change
309
+ *
310
+ * @param array $updates Array of updates.
311
+ * @return array Array of column name => replacement
312
+ */
313
+ protected function get_columns_to_change( array $updates ) {
314
+ $columns = [];
315
+
316
+ foreach ( $updates as $column => $update ) {
317
+ foreach ( $update['change'] as $change ) {
318
+ if ( $change->get_type() === Context\Type\Replace::TYPE_REPLACE && $this->can_replace_column( $column ) ) {
319
+ $columns[ $column ] = $change->get_replacement();
320
+ }
321
+ }
322
+ }
323
+
324
+ return $columns;
325
+ }
326
+
327
+ /**
328
+ * Save a replacement to the database
329
+ *
330
+ * @param int $row_id The row ID to save.
331
+ * @param array $changes The value to save to the column in the row.
332
+ * @return Bool|\WP_Error True on success, or \WP_Error on error
333
+ */
334
+ abstract public function save( $row_id, array $changes );
335
+
336
+ /**
337
+ * Delete a row from the source
338
+ *
339
+ * @param int $row_id The row ID.
340
+ * @return Bool|\WP_Error true on success, or \WP_Error on error
341
+ */
342
+ abstract public function delete_row( $row_id );
343
+
344
+ /**
345
+ * Returns database columns in SQL format
346
+ *
347
+ * @internal
348
+ * @return Sql\Select\Select[] SQL string
349
+ */
350
+ protected function get_query_selects() {
351
+ return array_merge(
352
+ // Table ID column
353
+ [ new Sql\Select\Select( Sql\Value::table( $this->get_table_name() ), Sql\Value::column( $this->get_table_id() ) ) ],
354
+ // Any extra 'info' columns
355
+ $this->get_info_columns(),
356
+ );
357
+ }
358
+
359
+ /**
360
+ * Get source filters
361
+ *
362
+ * @return Filter\Filter[]
363
+ */
364
+ public function get_filters() {
365
+ return $this->filters;
366
+ }
367
+
368
+ /**
369
+ * Get schema for a source
370
+ *
371
+ * @return array
372
+ */
373
+ public function get_schema_for_source() {
374
+ return apply_filters( 'searchregex_schema_item', $this->get_schema() );
375
+ }
376
+
377
+ /**
378
+ * Get the columns in the order they are defined in the schema, suitable for ordering results
379
+ *
380
+ * @return array
381
+ */
382
+ public function get_schema_order() {
383
+ $schema = $this->get_schema_for_source();
384
+ $values = range( 0, count( $schema['columns'] ) - 1 );
385
+ $keys = array_map( function( $column ) {
386
+ return $column['column'];
387
+ }, $schema['columns'] );
388
+
389
+ return array_combine( $keys, $values );
390
+ }
391
+
392
+ /**
393
+ * Internal function to get schema, which is then filtered by `get_schema_for_source`
394
+ *
395
+ * @return array
396
+ */
397
+ abstract protected function get_schema();
398
+
399
+ /**
400
+ * Get the schema as a Schema\Source object
401
+ *
402
+ * @return Schema\Source
403
+ */
404
+ public function get_schema_item() {
405
+ return new Schema\Source( $this->get_schema() );
406
+ }
407
+
408
+ /**
409
+ * Get any preloadable data for the given filter
410
+ *
411
+ * @param array $schema Schema.
412
+ * @param Filter\Filter $filter Filter.
413
+ * @return array
414
+ */
415
+ public function get_filter_preload( $schema, $filter ) {
416
+ return [];
417
+ }
418
+
419
+ /**
420
+ * Perform autocompletion on a column and a value
421
+ *
422
+ * @param array $column Column.
423
+ * @param string $value Value.
424
+ * @return array
425
+ */
426
+ abstract public function autocomplete( array $column, $value );
427
+
428
+ /**
429
+ * Does this source have any advanced filters?
430
+ *
431
+ * @return boolean
432
+ */
433
+ public function has_advanced_filter() {
434
+ foreach ( $this->filters as $filter ) {
435
+ if ( $filter->is_advanced() ) {
436
+ return true;
437
+ }
438
+ }
439
+
440
+ return false;
441
+ }
442
+
443
+ /**
444
+ * Try and convert the column value into a text label. For example, user ID to user name
445
+ *
446
+ * @param Schema\Column $schema Schema.
447
+ * @param string $value Column value.
448
+ * @return string Column label, or column value.
449
+ */
450
+ public function convert_result_value( Schema\Column $schema, $value ) {
451
+ if ( $schema->get_options() ) {
452
+ foreach ( $schema->get_options() as $option ) {
453
+ /** @psalm-suppress DocblockTypeContradiction */
454
+ if ( $option['value'] === $value || intval( $option['value'], 10 ) === $value ) {
455
+ return $option['label'];
456
+ }
457
+ }
458
+ }
459
+
460
+ if ( $schema->get_source() ) {
461
+ $convert = new Convert_Values();
462
+
463
+ return $convert->convert( $schema, $value );
464
+ }
465
+
466
+ return $value;
467
+ }
468
+
469
+ /**
470
+ * Helper function to log actions if WP_DEBUG is enabled
471
+ *
472
+ * @param string $title Log title.
473
+ * @param array|string|integer $update Log data.
474
+ * @return void
475
+ */
476
+ protected function log_save( $title, $update ) {
477
+ if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
478
+ // phpcs:ignore
479
+ error_log( $title . ': ' . print_r( $update, true ) );
480
+ }
481
+ }
482
+ }
includes/source/core/source-comment-meta.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Source\Core;
4
+
5
+ use SearchRegex\Source;
6
+
7
+ class Comment_Meta extends Meta {
8
+ public function get_table_name() {
9
+ global $wpdb;
10
+
11
+ return $wpdb->commentmeta;
12
+ }
13
+
14
+ public function get_meta_object_id() {
15
+ return 'comment_id';
16
+ }
17
+
18
+ public function get_meta_table() {
19
+ return 'comment';
20
+ }
21
+
22
+ public function get_meta_name() {
23
+ return __( 'Comment Meta', 'search-regex' );
24
+ }
25
+
26
+ public function autocomplete( $column, $value ) {
27
+ if ( $column['column'] === $this->get_meta_object_id() ) {
28
+ return Source\Autocomplete::get_comment( $value );
29
+ }
30
+
31
+ return parent::autocomplete( $column, $value );
32
+ }
33
+ }
includes/source/core/source-comment.php ADDED
@@ -0,0 +1,269 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Source\Core;
4
+
5
+ use SearchRegex\Source;
6
+ use SearchRegex\Search;
7
+ use SearchRegex\Sql;
8
+ use SearchRegex\Plugin;
9
+
10
+ /**
11
+ * Source for comments
12
+ */
13
+ class Comment extends Source\Source {
14
+ use Source\HasMeta;
15
+
16
+ public function get_actions( Search\Result $result ) {
17
+ $id = $result->get_row_id();
18
+ $link = get_edit_comment_link( $id );
19
+ $comment = get_comment( $id );
20
+
21
+ if ( $link && is_object( $comment ) ) {
22
+ $view = get_comment_link( $comment );
23
+
24
+ return array_filter( [
25
+ 'edit' => str_replace( '&amp;', '&', $link ),
26
+ 'view' => $view,
27
+ ] );
28
+ }
29
+
30
+ return [];
31
+ }
32
+
33
+ public function get_table_id() {
34
+ return 'comment_ID';
35
+ }
36
+
37
+ public function get_table_name() {
38
+ global $wpdb;
39
+
40
+ return $wpdb->comments;
41
+ }
42
+
43
+ public function get_title_column() {
44
+ return 'comment_author';
45
+ }
46
+
47
+ public function get_row_columns( $row_id ) {
48
+ $meta = $this->get_meta( get_comment_meta( $row_id ) );
49
+ $row_columns = parent::get_row_columns( $row_id );
50
+ if ( $row_columns instanceof \WP_Error ) {
51
+ return $row_columns;
52
+ }
53
+
54
+ return array_merge(
55
+ $row_columns,
56
+ count( $meta ) > 0 ? [ $meta ] : [],
57
+ );
58
+ }
59
+
60
+ public function save( $row_id, array $changes ) {
61
+ $comment = $this->get_columns_to_change( $changes );
62
+ $comment['ID'] = $row_id;
63
+
64
+ $this->process_meta( $row_id, 'comment', $changes );
65
+
66
+ if ( count( $comment ) > 1 ) {
67
+ // wp_update_comment expects slashes to be present, which are then removed
68
+ if ( isset( $comment['comment_content'] ) ) {
69
+ $comment['comment_content'] = wp_slash( $comment['comment_content'] );
70
+ }
71
+
72
+ $this->log_save( 'comment', $comment );
73
+
74
+ $result = true;
75
+
76
+ /** @psalm-suppress UndefinedFunction */
77
+ if ( Plugin\Settings::init()->can_save() ) {
78
+ $result = wp_update_comment( $comment );
79
+ }
80
+
81
+ if ( $result ) {
82
+ return true;
83
+ }
84
+
85
+ return new \WP_Error( 'searchregex', 'Failed to update comment.' );
86
+ }
87
+
88
+ return true;
89
+ }
90
+
91
+ public function delete_row( $row_id ) {
92
+ $this->log_save( 'delete comment', $row_id );
93
+
94
+ /** @psalm-suppress UndefinedFunction */
95
+ if ( Plugin\Settings::init()->can_save() ) {
96
+ if ( wp_delete_comment( $row_id, true ) ) {
97
+ return true;
98
+ }
99
+
100
+ return new \WP_Error( 'searchregex_delete', 'Failed to delete comment', 401 );
101
+ }
102
+
103
+ return true;
104
+ }
105
+
106
+ public function autocomplete( $column, $value ) {
107
+ global $wpdb;
108
+
109
+ if ( ! isset( $column['column'] ) ) {
110
+ return [];
111
+ }
112
+
113
+ if ( $column['column'] === 'comment_post_ID' ) {
114
+ return Source\Autocomplete::get_post( $value, Sql\Value::column( 'ID' ), Sql\Value::column( 'post_title' ) );
115
+ }
116
+
117
+ if ( $column['column'] === 'user_id' ) {
118
+ return Source\Autocomplete::get_user( $value );
119
+ }
120
+
121
+ if ( $column['column'] === 'meta' ) {
122
+ return Source\Autocomplete::get_meta( Sql\Value::table( 'commentmeta' ), $value );
123
+ }
124
+
125
+ if ( $column['column'] === 'comment_parent' ) {
126
+ return Source\Autocomplete::get_comment( $value );
127
+ }
128
+
129
+ // General text searches
130
+ if ( $column['column'] === 'comment_author' || $column['column'] === 'comment_author_email' ) {
131
+ // phpcs:ignore
132
+ return $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT " . $column['column'] . " as id," . $column['column'] . " as value FROM {$wpdb->comments} WHERE " . $column['column'] . " LIKE %s LIMIT %d", '%' . $wpdb->esc_like( $value ) . '%', self::AUTOCOMPLETE_LIMIT ) );
133
+ }
134
+
135
+ return [];
136
+ }
137
+
138
+ public function get_schema() {
139
+ global $wpdb;
140
+
141
+ return [
142
+ 'name' => __( 'Comments', 'search-regex' ),
143
+ 'table' => $wpdb->comments,
144
+ 'columns' => [
145
+ [
146
+ 'column' => 'comment_ID',
147
+ 'type' => 'integer',
148
+ 'title' => __( 'ID', 'search-regex' ),
149
+ 'modify' => false,
150
+ ],
151
+ [
152
+ 'column' => 'comment_post_ID',
153
+ 'type' => 'integer',
154
+ 'title' => __( 'Post ID', 'search-regex' ),
155
+ 'options' => 'api',
156
+ 'joined_by' => 'post',
157
+ ],
158
+ [
159
+ 'column' => 'comment_author',
160
+ 'type' => 'string',
161
+ 'title' => __( 'Author', 'search-regex' ),
162
+ 'options' => 'api',
163
+ 'global' => true,
164
+ ],
165
+ [
166
+ 'column' => 'comment_author_email',
167
+ 'type' => 'string',
168
+ 'title' => __( 'Email', 'search-regex' ),
169
+ 'options' => 'api',
170
+ 'global' => true,
171
+ ],
172
+ [
173
+ 'column' => 'comment_author_url',
174
+ 'type' => 'string',
175
+ 'title' => __( 'URL', 'search-regex' ),
176
+ 'global' => true,
177
+ ],
178
+ [
179
+ 'column' => 'comment_content',
180
+ 'type' => 'string',
181
+ 'title' => __( 'Content', 'search-regex' ),
182
+ 'multiline' => true,
183
+ 'global' => true,
184
+ ],
185
+ [
186
+ 'column' => 'comment_author_IP',
187
+ 'type' => 'string',
188
+ 'title' => __( 'IP', 'search-regex' ),
189
+ ],
190
+ [
191
+ 'column' => 'comment_date',
192
+ 'type' => 'date',
193
+ 'title' => __( 'Date', 'search-regex' ),
194
+ 'source' => 'date',
195
+ ],
196
+ [
197
+ 'column' => 'comment_date_gmt',
198
+ 'type' => 'date',
199
+ 'title' => __( 'Date GMT', 'search-regex' ),
200
+ 'source' => 'date',
201
+ ],
202
+ [
203
+ 'column' => 'comment_approved',
204
+ 'type' => 'member',
205
+ 'options' => [
206
+ [
207
+ 'value' => '0',
208
+ 'label' => __( 'Unapproved', 'search-regex' ),
209
+ ],
210
+ [
211
+ 'value' => '1',
212
+ 'label' => __( 'Approved', 'search-regex' ),
213
+ ],
214
+ [
215
+ 'value' => 'spam',
216
+ 'label' => __( 'Spam', 'search-regex' ),
217
+ ],
218
+ ],
219
+ 'title' => __( 'Approval Status', 'search-regex' ),
220
+ ],
221
+ [
222
+ 'column' => 'comment_agent',
223
+ 'type' => 'string',
224
+ 'title' => __( 'User Agent', 'search-regex' ),
225
+ ],
226
+ [
227
+ 'column' => 'comment_type',
228
+ 'type' => 'member',
229
+ 'title' => __( 'Type', 'search-regex' ),
230
+ 'options' => [
231
+ [
232
+ 'value' => 'pingback',
233
+ 'label' => __( 'Pingback', 'search-regex' ),
234
+ ],
235
+ [
236
+ 'value' => 'trackback',
237
+ 'label' => __( 'Trackback', 'search-regex' ),
238
+ ],
239
+ [
240
+ 'value' => 'comment',
241
+ 'label' => __( 'Comment', 'search-regex' ),
242
+ ],
243
+ ],
244
+ ],
245
+ [
246
+ 'column' => 'comment_parent',
247
+ 'type' => 'integer',
248
+ 'title' => __( 'Parent Comment', 'search-regex' ),
249
+ 'options' => 'api',
250
+ ],
251
+ [
252
+ 'column' => 'user_id',
253
+ 'type' => 'integer',
254
+ 'title' => __( 'User ID', 'search-regex' ),
255
+ 'options' => 'api',
256
+ 'source' => 'user',
257
+ 'joined_by' => 'user',
258
+ ],
259
+ [
260
+ 'column' => 'meta',
261
+ 'type' => 'keyvalue',
262
+ 'title' => __( 'Comment meta', 'search-regex' ),
263
+ 'options' => 'api',
264
+ 'join' => 'commentmeta',
265
+ ],
266
+ ],
267
+ ];
268
+ }
269
+ }
includes/source/core/source-meta.php ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Source\Core;
4
+
5
+ use SearchRegex\Source;
6
+ use SearchRegex\Sql;
7
+ use SearchRegex\Plugin;
8
+
9
+ abstract class Meta extends Source\Source {
10
+ public function get_table_id() {
11
+ return 'meta_id';
12
+ }
13
+
14
+ public function get_title_column() {
15
+ return 'meta_key';
16
+ }
17
+
18
+ /**
19
+ * Label for the meta-data
20
+ *
21
+ * @return string
22
+ */
23
+ abstract public function get_meta_name();
24
+
25
+ /**
26
+ * Return the meta object ID name
27
+ *
28
+ * @return String
29
+ */
30
+ abstract public function get_meta_object_id();
31
+
32
+ /**
33
+ * Return the meta table name
34
+ *
35
+ * @return String
36
+ */
37
+ abstract public function get_meta_table();
38
+
39
+ public function save( $row_id, array $changes ) {
40
+ global $wpdb;
41
+
42
+ $meta = $this->get_columns_to_change( $changes );
43
+
44
+ if ( count( $meta ) > 0 ) {
45
+ $this->log_save( 'meta', $meta );
46
+
47
+ // This does all the sanitization
48
+ $result = true;
49
+
50
+ /** @psalm-suppress UndefinedFunction */
51
+ if ( Plugin\Settings::init()->can_save() ) {
52
+ $result = $wpdb->update( $this->get_meta_table(), $meta, [ $this->get_table_id() => $row_id ] );
53
+ if ( $result === null ) {
54
+ return new \WP_Error( 'searchregex', 'Failed to update meta data: ' . $this->get_meta_table() );
55
+ }
56
+
57
+ // Clear any cache
58
+ wp_cache_delete( $this->get_meta_object_id(), $this->get_meta_table() . '_meta' );
59
+ }
60
+
61
+ return $result;
62
+ }
63
+
64
+ return true;
65
+ }
66
+
67
+ public function delete_row( $row_id ) {
68
+ global $wpdb;
69
+
70
+ $this->log_save( 'delete meta', $row_id );
71
+
72
+ /** @psalm-suppress UndefinedFunction */
73
+ if ( Plugin\Settings::init()->can_save() ) {
74
+ $result = $wpdb->delete( $this->get_table_name(), [ $this->get_table_id() => $row_id ] );
75
+
76
+ if ( $result ) {
77
+ wp_cache_delete( $this->get_meta_object_id(), $this->get_meta_table() . '_meta' );
78
+ return true;
79
+ }
80
+
81
+ return new \WP_Error( 'searchregex_delete', 'Failed to delete meta', 401 );
82
+ }
83
+
84
+ return true;
85
+ }
86
+
87
+ /**
88
+ * Perform autocompletion on a column and a value
89
+ *
90
+ * @param array $column Column.
91
+ * @param string $value Value.
92
+ * @return array
93
+ */
94
+ public function autocomplete( array $column, $value ) {
95
+ global $wpdb;
96
+
97
+ if ( in_array( $column['column'], [ 'meta_key', 'meta_value' ], true ) ) {
98
+ // phpcs:ignore
99
+ return $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT " . $column['column'] . " as id," . $column['column'] . " as value FROM {$this->get_table_name()} WHERE " . $column['column'] . " LIKE %s LIMIT %d", '%' . $wpdb->esc_like( $value ) . '%', self::AUTOCOMPLETE_LIMIT ) );
100
+ }
101
+
102
+ return [];
103
+ }
104
+
105
+ public function get_schema() {
106
+ return [
107
+ 'name' => $this->get_meta_name(),
108
+ 'table' => $this->get_table_name(),
109
+ 'columns' => [
110
+ [
111
+ 'column' => $this->get_meta_object_id(),
112
+ 'type' => 'integer',
113
+ 'title' => __( 'Owner ID', 'search-regex' ),
114
+ 'options' => 'api',
115
+ 'joined_by' => $this->get_meta_table(),
116
+ ],
117
+ [
118
+ 'column' => 'meta_key',
119
+ 'type' => 'string',
120
+ 'title' => __( 'Meta Key', 'search-regex' ),
121
+ 'options' => 'api',
122
+ 'global' => true,
123
+ ],
124
+ [
125
+ 'column' => 'meta_value',
126
+ 'type' => 'string',
127
+ 'title' => __( 'Meta Value', 'search-regex' ),
128
+ 'options' => 'api',
129
+ 'multiline' => true,
130
+ 'global' => true,
131
+ ],
132
+ ],
133
+ ];
134
+ }
135
+ }
includes/source/core/source-options.php ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Source\Core;
4
+
5
+ use SearchRegex\Source;
6
+ use SearchRegex\Sql;
7
+ use SearchRegex\Plugin;
8
+
9
+ /**
10
+ * Source for WP options
11
+ */
12
+ class Options extends Source\Source {
13
+ public function get_table_id() {
14
+ return 'option_id';
15
+ }
16
+
17
+ public function get_table_name() {
18
+ global $wpdb;
19
+
20
+ return $wpdb->options;
21
+ }
22
+
23
+ public function get_title_column() {
24
+ return 'option_name';
25
+ }
26
+
27
+ public function save( $row_id, array $changes ) {
28
+ global $wpdb;
29
+
30
+ // Get current option name. The table name is a known sanitized value
31
+ // phpcs:ignore
32
+ $row = $wpdb->get_row( $wpdb->prepare( "SELECT option_name,option_value,autoload FROM {$this->get_table_name()} WHERE option_id=%d", $row_id ) );
33
+ if ( ! $row ) {
34
+ return new \WP_Error( 'searchregex', 'Unable to update option' );
35
+ }
36
+
37
+ $option = $this->get_columns_to_change( $changes );
38
+
39
+ if ( count( $option ) > 0 ) {
40
+ $this->log_save( 'option', $option );
41
+
42
+ // This does all the sanitization
43
+ /** @psalm-suppress UndefinedFunction */
44
+ if ( Plugin\Settings::init()->can_save() ) {
45
+ if ( isset( $option['option_name'] ) ) {
46
+ // Changing the option name. Delete the current option and then recreate with the new option. This ensures it is correctly sanitized
47
+ delete_option( $row->option_name );
48
+ }
49
+
50
+ // This handles all sanitization
51
+ if ( update_option( $row->option_name, $option['option_value'], isset( $option['autoload'] ) ? $option['autoload'] : null ) ) {
52
+ return true;
53
+ }
54
+ }
55
+
56
+ return new \WP_Error( 'searchregex', 'Failed to update option.' );
57
+ }
58
+
59
+ return true;
60
+ }
61
+
62
+ public function delete_row( $row_id ) {
63
+ global $wpdb;
64
+
65
+ $this->log_save( 'delete option', $row_id );
66
+
67
+ /** @psalm-suppress UndefinedFunction */
68
+ if ( Plugin\Settings::init()->can_save() ) {
69
+ // Get the option name for the row. This is so we can use the WP delete_option and have the cache cleared
70
+ // phpcs:ignore
71
+ $row = $wpdb->get_row( $wpdb->prepare( "SELECT option_name,option_value,autoload FROM {$this->get_table_name()} WHERE option_id=%d", $row_id ) );
72
+ if ( $row ) {
73
+ if ( delete_option( $row->option_name ) ) {
74
+ return true;
75
+ }
76
+ }
77
+
78
+ return new \WP_Error( 'searchregex_delete', 'Failed to delete option', 401 );
79
+ }
80
+
81
+ return true;
82
+ }
83
+
84
+ public function autocomplete( $column, $value ) {
85
+ global $wpdb;
86
+
87
+ /** @psalm-suppress InvalidArrayOffset */
88
+ if ( in_array( $column['column'], [ 'option_name', 'option_value' ], true ) ) {
89
+ // phpcs:ignore
90
+ return $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT " . $column['column'] . " as id," . $column['column'] . " as value FROM {$wpdb->options} WHERE " . $column['column'] . " LIKE %s LIMIT %d", '%' . $wpdb->esc_like( $value ) . '%', self::AUTOCOMPLETE_LIMIT ) );
91
+ }
92
+
93
+ return [];
94
+ }
95
+
96
+ public function get_schema() {
97
+ global $wpdb;
98
+
99
+ return [
100
+ 'name' => __( 'Options', 'search-regex' ),
101
+ 'table' => $wpdb->options,
102
+ 'columns' => [
103
+ [
104
+ 'column' => 'option_id',
105
+ 'type' => 'integer',
106
+ 'title' => __( 'ID', 'search-regex' ),
107
+ 'modify' => false,
108
+ ],
109
+ [
110
+ 'column' => 'option_name',
111
+ 'type' => 'string',
112
+ 'title' => __( 'Name', 'search-regex' ),
113
+ 'options' => 'api',
114
+ 'global' => true,
115
+ ],
116
+ [
117
+ 'column' => 'option_value',
118
+ 'type' => 'string',
119
+ 'title' => __( 'Value', 'search-regex' ),
120
+ 'options' => 'api',
121
+ 'multiline' => true,
122
+ 'global' => true,
123
+ ],
124
+ [
125
+ 'column' => 'autoload',
126
+ 'type' => 'member',
127
+ 'options' => [
128
+ [
129
+ 'value' => 'yes',
130
+ 'label' => __( 'Is autoload', 'search-regex' ),
131
+ ],
132
+ [
133
+ 'value' => 'no',
134
+ 'label' => __( 'Is not autoload', 'search-regex' ),
135
+ ],
136
+ ],
137
+ 'title' => __( 'Autoload', 'search-regex' ),
138
+ 'multiple' => false,
139
+ ],
140
+ ],
141
+ ];
142
+ }
143
+ }
includes/source/core/source-post-meta.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Source\Core;
4
+
5
+ use SearchRegex\Source;
6
+ use SearchRegex\Schema;
7
+ use SearchRegex\Sql\Sql\Value;
8
+
9
+ class Post_Meta extends Meta {
10
+ public function get_table_name() {
11
+ global $wpdb;
12
+
13
+ return $wpdb->postmeta;
14
+ }
15
+
16
+ public function get_meta_object_id() {
17
+ return 'post_id';
18
+ }
19
+
20
+ public function get_meta_table() {
21
+ return 'post';
22
+ }
23
+
24
+ public function get_meta_name() {
25
+ return __( 'Post Meta', 'search-regex' );
26
+ }
27
+
28
+ public function autocomplete( $column, $value ) {
29
+ if ( $column['column'] === $this->get_meta_object_id() ) {
30
+ return Source\Autocomplete::get_post( $value, Sql\Value::column( 'ID' ), Sql\Value::column( 'post_title' ) );
31
+ }
32
+
33
+ return parent::autocomplete( $column, $value );
34
+ }
35
+
36
+ public function convert_result_value( Schema\Column $schema, $value ) {
37
+ if ( $schema->get_column() === 'post_id' ) {
38
+ $post = get_post( intval( $value, 10 ) );
39
+
40
+ if ( is_object( $post ) ) {
41
+ return $post->post_title;
42
+ }
43
+ }
44
+
45
+ return parent::convert_result_value( $schema, $value );
46
+ }
47
+ }
includes/source/core/source-post.php ADDED
@@ -0,0 +1,441 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Source\Core;
4
+
5
+ use SearchRegex\Source;
6
+ use SearchRegex\Search;
7
+ use SearchRegex\Filter\Filter_Member;
8
+ use SearchRegex\Sql;
9
+ use SearchRegex\Plugin;
10
+
11
+ /**
12
+ * Source for posts, pages, and other custom post types
13
+ */
14
+ class Post extends Source\Source {
15
+ use Source\HasMeta;
16
+ use Source\HasTerms;
17
+
18
+ public function get_name( array $row = [] ) {
19
+ $post_type = isset( $row['post_type'] ) ? $this->get_post_type( $row['post_type'] ) : false;
20
+ if ( $post_type ) {
21
+ return $post_type['label'];
22
+ }
23
+
24
+ // Handle post types when it's not registered
25
+ return isset( $row['post_type'] ) ? ucwords( $row['post_type'] ) : $this->source_name;
26
+ }
27
+
28
+ /**
29
+ * Get the custom post type from the source
30
+ *
31
+ * @param String $post_type Source post type.
32
+ * @return null|Array
33
+ */
34
+ private function get_post_type( $post_type ) {
35
+ $post_types = get_post_types( [], 'objects' );
36
+
37
+ foreach ( $post_types as $type ) {
38
+ if ( is_object( $type ) && $type->name === $post_type ) {
39
+ return [
40
+ 'value' => $type->name,
41
+ 'label' => $type->label,
42
+ ];
43
+ }
44
+ }
45
+
46
+ return null;
47
+ }
48
+
49
+ public function get_actions( Search\Result $result ) {
50
+ $edit = get_edit_post_link( $result->get_row_id(), '' );
51
+ $view = get_permalink( $result->get_row_id() );
52
+
53
+ if ( $edit ) {
54
+ return [
55
+ 'edit' => $edit,
56
+ 'view' => $view,
57
+ ];
58
+ }
59
+
60
+ return [];
61
+ }
62
+
63
+ public function get_info_columns() {
64
+ return [
65
+ new Sql\Select\Select( Sql\Value::table( $this->get_table_name() ), Sql\Value::column( $this->get_title_column() ) ),
66
+ new Sql\Select\Select( Sql\Value::table( $this->get_table_name() ), Sql\Value::column( 'post_type' ) ), // We need this to show the 'source'
67
+ ];
68
+ }
69
+
70
+ public function get_title_column() {
71
+ return 'post_title';
72
+ }
73
+
74
+ public function get_table_id() {
75
+ return 'ID';
76
+ }
77
+
78
+ public function get_table_name() {
79
+ global $wpdb;
80
+
81
+ return $wpdb->posts;
82
+ }
83
+
84
+ public function get_row_columns( $row_id ) {
85
+ $extra = [];
86
+ $meta = $this->get_meta( get_post_meta( $row_id ) );
87
+ if ( count( $meta ) > 0 ) {
88
+ $extra = [ $meta ];
89
+ }
90
+
91
+ $object_terms = wp_get_object_terms( $row_id, [ 'post_tag', 'category' ] );
92
+ if ( $object_terms instanceof \WP_Error ) {
93
+ return [];
94
+ }
95
+
96
+ $extra = array_merge( $extra, $this->get_terms( $object_terms ) );
97
+ $columns = parent::get_row_columns( $row_id );
98
+
99
+ if ( $columns instanceof \WP_Error ) {
100
+ return $columns;
101
+ }
102
+
103
+ return array_merge( $columns, $extra );
104
+ }
105
+
106
+ public function save( $row_id, array $changes ) {
107
+ $post = $this->get_columns_to_change( $changes );
108
+ $post['ID'] = $row_id;
109
+
110
+ $this->process_meta( $row_id, 'post', $changes );
111
+ $this->process_terms( $row_id, 'post', $changes );
112
+
113
+ if ( count( $post ) > 1 ) {
114
+ // wp_update_post expects slashes to be present, which are then removed
115
+ if ( isset( $post['post_content'] ) ) {
116
+ $post['post_content'] = wp_slash( $post['post_content'] );
117
+ }
118
+
119
+ if ( isset( $post['post_excerpt'] ) ) {
120
+ $post['post_excerpt'] = wp_slash( $post['post_excerpt'] );
121
+ }
122
+
123
+ $this->log_save( 'post', $post );
124
+
125
+ // This does all the sanitization
126
+ $result = true;
127
+
128
+ /** @psalm-suppress UndefinedFunction */
129
+ if ( Plugin\Settings::init()->can_save() ) {
130
+ $result = wp_update_post( $post );
131
+ }
132
+
133
+ if ( $result ) {
134
+ return true;
135
+ }
136
+
137
+ return new \WP_Error( 'searchregex', 'Failed to update post.' );
138
+ }
139
+
140
+ return true;
141
+ }
142
+
143
+ public function delete_row( $row_id ) {
144
+ $this->log_save( 'delete post', $row_id );
145
+
146
+ /** @psalm-suppress UndefinedFunction */
147
+ if ( Plugin\Settings::init()->can_save() ) {
148
+ if ( wp_delete_post( $row_id, true ) ) {
149
+ return true;
150
+ }
151
+
152
+ return new \WP_Error( 'searchregex_delete', 'Failed to delete post', 401 );
153
+ }
154
+
155
+ return true;
156
+ }
157
+
158
+ public function autocomplete( $column, $value ) {
159
+ if ( $column['column'] === 'post_author' ) {
160
+ return Source\Autocomplete::get_user( $value );
161
+ }
162
+
163
+ if ( $column['column'] === 'post_parent' ) {
164
+ return Source\Autocomplete::get_post( $value, Sql\Value::column( 'ID' ), Sql\Value::column( 'post_title' ) );
165
+ }
166
+
167
+ if ( $column['column'] === 'category' ) {
168
+ return Source\Autocomplete::get_category( $value );
169
+ }
170
+
171
+ if ( $column['column'] === 'post_tag' ) {
172
+ return Source\Autocomplete::get_tag( $value );
173
+ }
174
+
175
+ if ( $column['column'] === 'meta' ) {
176
+ return Source\Autocomplete::get_meta( Sql\Value::table( 'postmeta' ), $value );
177
+ }
178
+
179
+ // General text
180
+ if ( in_array( $column['column'], [ 'post_title', 'post_name', 'guid', 'post_mime_type' ], true ) ) {
181
+ return Source\Autocomplete::get_post( $value, Sql\Value::column( $column['column'] ), Sql\Value::column( $column['column'] ) );
182
+ }
183
+
184
+ return [];
185
+ }
186
+
187
+ public function get_filter_preload( $schema, $filter ) {
188
+ /** @psalm-suppress DocblockTypeContradiction */
189
+ if ( $filter instanceof Filter\Filter_Member && ( $schema['column'] === 'category' || $schema['column'] === 'post_tag' ) ) {
190
+ $preload = [];
191
+
192
+ foreach ( $filter->get_values() as $value ) {
193
+ $term = get_term( intval( $value, 10 ), $schema['column'] );
194
+
195
+ if ( is_object( $term ) && ! $term instanceof \WP_Error ) {
196
+ $preload[] = [
197
+ 'label' => $term->name,
198
+ 'value' => $schema['column'] . '_' . (string) intval( $value, 10 ),
199
+ ];
200
+ }
201
+ }
202
+
203
+ return $preload;
204
+ } elseif ( $schema['column'] === 'post_author' && ( $filter instanceof Filter\Filter_Integer || $filter instanceof Filter\Filter_String ) ) {
205
+ $convert = new Source\Convert_Values();
206
+
207
+ return [
208
+ [
209
+ 'label' => $convert->get_user( '', (string) $filter->get_value() ),
210
+ 'value' => $schema['column'] . '_' . (string) $filter->get_value(),
211
+ ],
212
+ ];
213
+ }
214
+
215
+ return [];
216
+ }
217
+
218
+ public function get_schema() {
219
+ global $wpdb;
220
+
221
+ $stati = get_post_stati();
222
+ $statuses = [];
223
+
224
+ foreach ( array_keys( $stati ) as $status ) {
225
+ $statuses[] = [
226
+ 'value' => $status,
227
+ 'label' => $status,
228
+ ];
229
+ }
230
+
231
+ return [
232
+ 'name' => __( 'Posts (core & custom)', 'search-regex' ),
233
+ 'table' => $wpdb->posts,
234
+ 'columns' => [
235
+ [
236
+ 'column' => 'ID',
237
+ 'type' => 'integer',
238
+ 'title' => __( 'ID', 'search-regex' ),
239
+ 'modify' => false,
240
+ ],
241
+ [
242
+ 'column' => 'post_title',
243
+ 'type' => 'string',
244
+ 'title' => __( 'Title', 'search-regex' ),
245
+ 'options' => 'api',
246
+ 'global' => true,
247
+ 'source' => 'post_title',
248
+ ],
249
+ [
250
+ 'column' => 'post_name',
251
+ 'type' => 'string',
252
+ 'title' => __( 'Slug', 'search-regex' ),
253
+ 'options' => 'api',
254
+ 'length' => 200,
255
+ 'global' => true,
256
+ ],
257
+ [
258
+ 'column' => 'post_type',
259
+ 'type' => 'member',
260
+ 'options' => $this->get_all_custom_post_types(),
261
+ 'title' => __( 'Post Type', 'search-regex' ),
262
+ 'source' => 'post_type',
263
+ ],
264
+ [
265
+ 'column' => 'post_content',
266
+ 'type' => 'string',
267
+ 'title' => __( 'Content', 'search-regex' ),
268
+ 'multiline' => true,
269
+ 'global' => true,
270
+ ],
271
+ [
272
+ 'column' => 'post_author',
273
+ 'type' => 'integer',
274
+ 'options' => 'api',
275
+ 'title' => __( 'Author', 'search-regex' ),
276
+ 'source' => 'user',
277
+ 'joined_by' => 'user',
278
+ ],
279
+ [
280
+ 'column' => 'post_date',
281
+ 'type' => 'date',
282
+ 'title' => __( 'Date', 'search-regex' ),
283
+ 'source' => 'date',
284
+ ],
285
+ [
286
+ 'column' => 'post_date_gmt',
287
+ 'type' => 'date',
288
+ 'title' => __( 'Date GMT', 'search-regex' ),
289
+ 'source' => 'date',
290
+ ],
291
+ [
292
+ 'column' => 'post_excerpt',
293
+ 'type' => 'string',
294
+ 'title' => __( 'Excerpt', 'search-regex' ),
295
+ 'multiline' => true,
296
+ ],
297
+ [
298
+ 'column' => 'post_status',
299
+ 'type' => 'member',
300
+ 'options' => $statuses,
301
+ 'title' => __( 'Post Status', 'search-regex' ),
302
+ ],
303
+ [
304
+ 'column' => 'comment_status',
305
+ 'type' => 'member',
306
+ 'options' => [
307
+ [
308
+ 'value' => 'open',
309
+ 'label' => __( 'Open', 'search-regex' ),
310
+ ],
311
+ [
312
+ 'value' => 'closed',
313
+ 'label' => __( 'Closed', 'search-regex' ),
314
+ ],
315
+ ],
316
+ 'title' => __( 'Comment Status', 'search-regex' ),
317
+ 'multiple' => false,
318
+ ],
319
+ [
320
+ 'column' => 'ping_status',
321
+ 'type' => 'member',
322
+ 'options' => [
323
+ [
324
+ 'value' => 'open',
325
+ 'label' => __( 'Open', 'search-regex' ),
326
+ ],
327
+ [
328
+ 'value' => 'closed',
329
+ 'label' => __( 'Closed', 'search-regex' ),
330
+ ],
331
+ ],
332
+ 'title' => __( 'Ping Status', 'search-regex' ),
333
+ 'multiple' => false,
334
+ ],
335
+ [
336
+ 'column' => 'post_password',
337
+ 'type' => 'member',
338
+ 'options' => [
339
+ [
340
+ 'value' => 'password',
341
+ 'label' => __( 'Has password', 'search-regex' ),
342
+ ],
343
+ [
344
+ 'value' => 'nopassword',
345
+ 'label' => __( 'Has no password', 'search-regex' ),
346
+ ],
347
+ ],
348
+ 'title' => __( 'Password', 'search-regex' ),
349
+ 'multiple' => false,
350
+ 'modify' => false,
351
+ ],
352
+ [
353
+ 'column' => 'post_modified',
354
+ 'type' => 'date',
355
+ 'title' => __( 'Modified', 'search-regex' ),
356
+ 'source' => 'date',
357
+ ],
358
+ [
359
+ 'column' => 'post_modified_gmt',
360
+ 'type' => 'date',
361
+ 'title' => __( 'Modified GMT', 'search-regex' ),
362
+ 'source' => 'date',
363
+ ],
364
+ [
365
+ 'column' => 'post_parent',
366
+ 'type' => 'integer',
367
+ 'title' => __( 'Parent', 'search-regex' ),
368
+ 'options' => 'api',
369
+ 'source' => 'post_title',
370
+ 'joined_by' => 'post',
371
+ ],
372
+ [
373
+ 'column' => 'guid',
374
+ 'type' => 'string',
375
+ 'title' => __( 'GUID', 'search-regex' ),
376
+ 'options' => 'api',
377
+ 'length' => 255,
378
+ ],
379
+ [
380
+ 'column' => 'post_mime_type',
381
+ 'type' => 'string',
382
+ 'title' => __( 'MIME', 'search-regex' ),
383
+ 'options' => 'api',
384
+ 'length' => 100,
385
+ ],
386
+ [
387
+ 'column' => 'comment_count',
388
+ 'type' => 'integer',
389
+ 'title' => __( 'Comment Count', 'search-regex' ),
390
+ 'modify' => false,
391
+ ],
392
+ [
393
+ 'column' => 'category',
394
+ 'type' => 'member',
395
+ 'title' => __( 'Post Category', 'search-regex' ),
396
+ 'options' => 'api',
397
+ 'preload' => true,
398
+ 'join' => 'taxonomy',
399
+ 'source' => 'term',
400
+ ],
401
+ [
402
+ 'column' => 'post_tag',
403
+ 'type' => 'member',
404
+ 'title' => __( 'Post Tag', 'search-regex' ),
405
+ 'options' => 'api',
406
+ 'preload' => true,
407
+ 'join' => 'taxonomy',
408
+ 'source' => 'term',
409
+ ],
410
+ [
411
+ 'column' => 'meta',
412
+ 'type' => 'keyvalue',
413
+ 'title' => __( 'Post Meta', 'search-regex' ),
414
+ 'options' => 'api',
415
+ 'join' => 'postmeta',
416
+ ],
417
+ ],
418
+ ];
419
+ }
420
+
421
+ /**
422
+ * Get list of all custom post types that have a label
423
+ *
424
+ * @return array
425
+ */
426
+ private function get_all_custom_post_types() {
427
+ $post_types = get_post_types( [], 'objects' );
428
+ $post_sources = [];
429
+
430
+ foreach ( $post_types as $type ) {
431
+ if ( is_object( $type ) && strlen( $type->label ) > 0 ) {
432
+ $post_sources[] = [
433
+ 'value' => $type->name,
434
+ 'label' => $type->label,
435
+ ];
436
+ }
437
+ }
438
+
439
+ return apply_filters( 'searchregex_sources_posttype', $post_sources );
440
+ }
441
+ }
includes/source/core/source-terms.php ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Source\Core;
4
+
5
+ use SearchRegex\Source;
6
+ use SearchRegex\Result;
7
+ use SearchRegex\Sql;
8
+ use SearchRegex\Plugin;
9
+
10
+ /**
11
+ * Term source
12
+ */
13
+ class Terms extends Source\Source {
14
+ public function get_table_id() {
15
+ return 'term_id';
16
+ }
17
+
18
+ public function get_table_name() {
19
+ global $wpdb;
20
+
21
+ return $wpdb->prefix . 'terms';
22
+ }
23
+
24
+ public function get_title_column() {
25
+ return 'name';
26
+ }
27
+
28
+ public function save( $row_id, array $changes ) {
29
+ $term = $this->get_columns_to_change( $changes );
30
+
31
+ if ( count( $term ) > 0 ) {
32
+ $existing = get_term( $row_id );
33
+ if ( $existing === null || $existing instanceof \WP_Error ) {
34
+ return new \WP_Error( 'searchregex', 'Failed to update term.' );
35
+ }
36
+
37
+ if ( isset( $term['name'] ) ) {
38
+ $term['description'] = $term['name'];
39
+ unset( $term['name'] );
40
+ }
41
+
42
+ $this->log_save( 'term', array_merge( [ 'term_id' => $row_id ], $term ) );
43
+
44
+ // This does all the sanitization
45
+ $result = true;
46
+
47
+ /** @psalm-suppress UndefinedFunction */
48
+ if ( Plugin\Settings::init()->can_save() && is_object( $existing ) ) {
49
+ $result = wp_update_term( $row_id, $existing->taxonomy, $term );
50
+ }
51
+
52
+ if ( $result ) {
53
+ return true;
54
+ }
55
+
56
+ return new \WP_Error( 'searchregex', 'Failed to update term.' );
57
+ }
58
+
59
+ return true;
60
+ }
61
+
62
+ public function delete_row( $row_id ) {
63
+ $this->log_save( 'delete term', $row_id );
64
+
65
+ /** @psalm-suppress UndefinedFunction */
66
+ if ( Plugin\Settings::init()->can_save() ) {
67
+ $term = get_term( $row_id );
68
+ if ( $term instanceof \WP_Term && wp_delete_term( $row_id, $term->taxonomy ) ) {
69
+ return true;
70
+ }
71
+
72
+ return new \WP_Error( 'searchregex_delete', 'Failed to delete term', 401 );
73
+ }
74
+
75
+ return true;
76
+ }
77
+
78
+ public function autocomplete( $column, $value ) {
79
+ global $wpdb;
80
+
81
+ if ( $column['column'] === 'name' ) {
82
+ // phpcs:ignore
83
+ return $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT name as id,name as value FROM {$this->get_table_name()} WHERE name LIKE %s LIMIT %d", '%' . $wpdb->esc_like( $value ) . '%', self::AUTOCOMPLETE_LIMIT ) );
84
+ }
85
+
86
+ if ( $column['column'] === 'slug' ) {
87
+ // phpcs:ignore
88
+ return $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT slug as id,slug as value FROM {$this->get_table_name()} WHERE slug LIKE %s LIMIT %d", '%' . $wpdb->esc_like( $value ) . '%', self::AUTOCOMPLETE_LIMIT ) );
89
+ }
90
+
91
+ return [];
92
+ }
93
+
94
+ public function get_schema() {
95
+ global $wpdb;
96
+
97
+ $taxonomies = [];
98
+ $taxes = get_taxonomies( [], 'object' );
99
+
100
+ foreach ( $taxes as $tax ) {
101
+ if ( is_object( $tax ) ) {
102
+ $taxonomies[] = [
103
+ 'value' => $tax->name,
104
+ 'label' => $tax->label,
105
+ ];
106
+ }
107
+ }
108
+
109
+ return [
110
+ 'name' => __( 'Terms', 'search-regex' ),
111
+ 'table' => $wpdb->prefix . 'terms',
112
+ 'columns' => [
113
+ [
114
+ 'column' => 'term_id',
115
+ 'type' => 'integer',
116
+ 'title' => __( 'ID', 'search-regex' ),
117
+ 'options' => 'api',
118
+ 'modify' => false,
119
+ ],
120
+ [
121
+ 'column' => 'name',
122
+ 'type' => 'string',
123
+ 'title' => __( 'Name', 'search-regex' ),
124
+ 'options' => 'api',
125
+ 'global' => true,
126
+ ],
127
+ [
128
+ 'column' => 'slug',
129
+ 'type' => 'string',
130
+ 'title' => __( 'Slug', 'search-regex' ),
131
+ 'options' => 'api',
132
+ 'global' => true,
133
+ ],
134
+ [
135
+ 'column' => 'taxonomy',
136
+ 'type' => 'member',
137
+ 'title' => __( 'Taxonomy', 'search-regex' ),
138
+ 'options' => $taxonomies,
139
+ 'join' => 'taxonomy',
140
+ 'modify' => false,
141
+ ],
142
+ ],
143
+ ];
144
+ }
145
+ }
includes/source/core/source-user-meta.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Source\Core;
4
+
5
+ use SearchRegex\Source;
6
+
7
+ /**
8
+ * User meta data
9
+ */
10
+ class User_Meta extends Meta {
11
+ public function get_table_name() {
12
+ global $wpdb;
13
+
14
+ return $wpdb->prefix . 'usermeta';
15
+ }
16
+
17
+ public function get_table_id() {
18
+ return 'umeta_id';
19
+ }
20
+
21
+ public function get_meta_object_id() {
22
+ return 'user_id';
23
+ }
24
+
25
+ public function get_meta_table() {
26
+ return 'user';
27
+ }
28
+
29
+ public function get_meta_name() {
30
+ return __( 'User Meta', 'search-regex' );
31
+ }
32
+
33
+ /**
34
+ * Perform autocompletion on a column and a value
35
+ *
36
+ * @param array $column Column.
37
+ * @param string $value Value.
38
+ * @return array
39
+ */
40
+ public function autocomplete( array $column, $value ) {
41
+ if ( isset( $column['column'] ) && $column['column'] === $this->get_meta_object_id() ) {
42
+ return Source\Autocomplete::get_user( $value );
43
+ }
44
+
45
+ return parent::autocomplete( $column, $value );
46
+ }
47
+ }
includes/source/core/source-user.php ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Source\Core;
4
+
5
+ use SearchRegex\Source;
6
+ use SearchRegex\Search;
7
+ use SearchRegex\Sql;
8
+ use SearchRegex\Plugin;
9
+
10
+ /**
11
+ * User source
12
+ */
13
+ class User extends Source\Source {
14
+ use Source\HasMeta;
15
+
16
+ public function get_table_id() {
17
+ return 'ID';
18
+ }
19
+
20
+ public function get_table_name() {
21
+ global $wpdb;
22
+
23
+ return $wpdb->users;
24
+ }
25
+
26
+ public function get_actions( Search\Result $result ) {
27
+ return [
28
+ 'edit' => get_edit_profile_url( $result->get_row_id(), 'admin' ),
29
+ ];
30
+ }
31
+
32
+ public function get_title_column() {
33
+ return 'user_nicename';
34
+ }
35
+
36
+ public function get_row_columns( $row_id ) {
37
+ $meta = $this->get_meta( get_user_meta( $row_id ) );
38
+ $parent = parent::get_row_columns( $row_id );
39
+
40
+ if ( $parent instanceof \WP_Error ) {
41
+ return $parent;
42
+ }
43
+
44
+ return array_merge(
45
+ $parent,
46
+ count( $meta ) > 0 ? [ $meta ] : [],
47
+ );
48
+ }
49
+
50
+ public function save( $row_id, array $changes ) {
51
+ $user = $this->get_columns_to_change( $changes );
52
+ $user['ID'] = $row_id;
53
+
54
+ $this->process_meta( $row_id, 'user', $changes );
55
+
56
+ if ( count( $user ) > 1 ) {
57
+ $this->log_save( 'user', $user );
58
+
59
+ $result = true;
60
+
61
+ /** @psalm-suppress UndefinedFunction */
62
+ if ( Plugin\Settings::init()->can_save() ) {
63
+ $result = wp_update_user( $user );
64
+ }
65
+
66
+ if ( $result ) {
67
+ return true;
68
+ }
69
+
70
+ return new \WP_Error( 'searchregex', 'Failed to update user.' );
71
+ }
72
+
73
+ return true;
74
+ }
75
+
76
+ public function delete_row( $row_id ) {
77
+ $this->log_save( 'delete comment', $row_id );
78
+
79
+ /** @psalm-suppress UndefinedFunction */
80
+ if ( Plugin\Settings::init()->can_save() ) {
81
+ if ( wp_delete_user( $row_id ) ) {
82
+ return true;
83
+ }
84
+
85
+ return new \WP_Error( 'searchregex_delete', 'Failed to delete user', 401 );
86
+ }
87
+
88
+ return true;
89
+ }
90
+
91
+ public function autocomplete( $column, $value ) {
92
+ global $wpdb;
93
+
94
+ if ( $column['column'] === 'ID' ) {
95
+ return $wpdb->get_results( $wpdb->prepare( "SELECT ID as id,user_login as value FROM {$wpdb->users} WHERE user_login LIKE %s LIMIT %d", '%' . $wpdb->esc_like( $value ) . '%', self::AUTOCOMPLETE_LIMIT ) );
96
+ }
97
+
98
+ $user_fields = [
99
+ 'user_login',
100
+ 'user_nicename',
101
+ 'display_name',
102
+ 'user_email',
103
+ ];
104
+
105
+ if ( in_array( $column['column'], $user_fields, true ) ) {
106
+ // phpcs:ignore
107
+ return $wpdb->get_results( $wpdb->prepare( "SELECT " . $column['column'] . " as id," . $column['column'] . " as value FROM {$wpdb->users} WHERE " . $column['column'] . " LIKE %s LIMIT %d", '%' . $wpdb->esc_like( $value ) . '%', self::AUTOCOMPLETE_LIMIT ) );
108
+ }
109
+
110
+ if ( $column['column'] === 'meta' ) {
111
+ return Autocomplete::get_meta( Sql\Value::table( 'usermeta' ), $value );
112
+ }
113
+
114
+ return [];
115
+ }
116
+
117
+ public function get_schema() {
118
+ global $wpdb;
119
+
120
+ return [
121
+ 'name' => __( 'Users', 'search-regex' ),
122
+ 'table' => $wpdb->users,
123
+ 'columns' => [
124
+ [
125
+ 'column' => 'ID',
126
+ 'type' => 'integer',
127
+ 'title' => __( 'ID', 'search-regex' ),
128
+ 'options' => 'api',
129
+ 'modify' => false,
130
+ ],
131
+ [
132
+ 'column' => 'user_login',
133
+ 'type' => 'string',
134
+ 'title' => __( 'Login', 'search-regex' ),
135
+ 'options' => 'api',
136
+ 'modify' => false,
137
+ ],
138
+ [
139
+ 'column' => 'user_nicename',
140
+ 'type' => 'string',
141
+ 'title' => __( 'Nicename', 'search-regex' ),
142
+ 'options' => 'api',
143
+ 'global' => true,
144
+ ],
145
+ [
146
+ 'column' => 'display_name',
147
+ 'type' => 'string',
148
+ 'title' => __( 'Display Name', 'search-regex' ),
149
+ 'options' => 'api',
150
+ 'global' => true,
151
+ ],
152
+ [
153
+ 'column' => 'user_email',
154
+ 'type' => 'string',
155
+ 'title' => __( 'Email', 'search-regex' ),
156
+ 'options' => 'api',
157
+ ],
158
+ [
159
+ 'column' => 'user_url',
160
+ 'type' => 'string',
161
+ 'title' => __( 'URL', 'search-regex' ),
162
+ 'options' => 'api',
163
+ 'global' => true,
164
+ ],
165
+ [
166
+ 'column' => 'user_registered',
167
+ 'type' => 'date',
168
+ 'title' => __( 'Registered', 'search-regex' ),
169
+ 'source' => 'date',
170
+ ],
171
+ [
172
+ 'column' => 'meta',
173
+ 'type' => 'keyvalue',
174
+ 'title' => __( 'User meta', 'search-regex' ),
175
+ 'options' => 'api',
176
+ 'join' => 'usermeta',
177
+ ],
178
+ ],
179
+ ];
180
+ }
181
+ }
includes/source/plugin/source-redirection.php ADDED
@@ -0,0 +1,537 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Source\Plugin;
4
+
5
+ use SearchRegex\Source;
6
+ use SearchRegex\Search;
7
+ use SearchRegex\Sql;
8
+ use SearchRegex\Schema;
9
+ use SearchRegex\Filter;
10
+ use SearchRegex\Plugin;
11
+
12
+ /**
13
+ * Source: Redirection items
14
+ */
15
+ class Redirection extends Source\Source {
16
+ public function get_actions( Search\Result $result ) {
17
+ $edit = admin_url( 'tools.php?page=redirection.php' );
18
+
19
+ return [
20
+ 'edit' => $edit,
21
+ ];
22
+ }
23
+
24
+ public function get_table_id() {
25
+ return 'id';
26
+ }
27
+
28
+ public function get_table_name() {
29
+ global $wpdb;
30
+
31
+ return $wpdb->prefix . 'redirection_items';
32
+ }
33
+
34
+ public function get_title_column() {
35
+ return 'url';
36
+ }
37
+
38
+ private function get_item( $row_id ) {
39
+ if ( class_exists( '\Redirection\Module\Module' ) ) {
40
+ return \Redirection\Redirect\Redirect::get_by_id( $row_id );
41
+ }
42
+
43
+ return \Red_Item::get_by_id( $row_id );
44
+ }
45
+
46
+ private function delete_item( $row_id ) {
47
+ if ( class_exists( '\Redirection\Module\Module' ) ) {
48
+ return \Redirection\Redirect\Redirect::delete( $row_id );
49
+ }
50
+
51
+ return \Red_Item::delete( $row_id );
52
+ }
53
+
54
+ public function save( $row_id, array $changes ) {
55
+ $redirect = $this->get_columns_to_change( $changes );
56
+
57
+ if ( count( $redirect ) > 0 ) {
58
+ $item = $this->get_item( $row_id );
59
+
60
+ if ( ! $item instanceof \WP_Error ) {
61
+ $this->log_save( 'redirect', array_merge( [ 'id' => $row_id ], $redirect ) );
62
+
63
+ $json = $item->to_json();
64
+ $json = array_merge( $json, $redirect );
65
+
66
+ $result = true;
67
+
68
+ /** @psalm-suppress UndefinedFunction */
69
+ if ( Plugin\Settings::init()->can_save() ) {
70
+ $result = $item->update( $json );
71
+ }
72
+
73
+ if ( $result ) {
74
+ return true;
75
+ }
76
+ }
77
+
78
+ return new \WP_Error( 'searchregex', 'Failed to update redirection' );
79
+ }
80
+
81
+ return true;
82
+ }
83
+
84
+ public function delete_row( $row_id ) {
85
+ $this->log_save( 'delete redirection', $row_id );
86
+
87
+ /** @psalm-suppress UndefinedFunction */
88
+ if ( Plugin\Settings::init()->can_save() ) {
89
+ if ( $this->delete_item( $row_id ) ) {
90
+ return true;
91
+ }
92
+
93
+ return new \WP_Error( 'searchregex_delete', 'Failed to delete comment', 401 );
94
+ }
95
+
96
+ return true;
97
+ }
98
+
99
+ public function get_filter_preload( $schema, $filter ) {
100
+ global $wpdb;
101
+
102
+ /** @psalm-suppress DocblockTypeContradiction */
103
+ if ( $schema['column'] === 'group_id' && $filter instanceof Filter\Filter_Member ) {
104
+ $preload = [];
105
+
106
+ foreach ( $filter->get_values() as $value ) {
107
+ $group = $wpdb->get_var( $wpdb->prepare( "SELECT name FROM {$wpdb->prefix}redirection_groups WHERE id=%d", $value ) );
108
+
109
+ if ( $group ) {
110
+ $preload[] = [
111
+ 'label' => $group,
112
+ 'value' => $schema['column'] . '_' . (string) intval( $value, 10 ),
113
+ ];
114
+ }
115
+ }
116
+
117
+ return $preload;
118
+ }
119
+
120
+ return [];
121
+ }
122
+
123
+ public function autocomplete( $column, $value ) {
124
+ global $wpdb;
125
+
126
+ if ( $column['column'] === 'url' ) {
127
+ return $wpdb->get_results( $wpdb->prepare( "SELECT url as id,url as value FROM {$wpdb->prefix}redirection_items WHERE url LIKE %s LIMIT 50", '%' . $wpdb->esc_like( $value ) . '%' ) );
128
+ }
129
+
130
+ if ( $column['column'] === 'group_id' ) {
131
+ return $wpdb->get_results( $wpdb->prepare( "SELECT id as id, name as value FROM {$wpdb->prefix}redirection_groups WHERE name LIKE %s LIMIT 50", '%' . $wpdb->esc_like( $value ) . '%' ) );
132
+ }
133
+
134
+ return [];
135
+ }
136
+
137
+ public function get_schema() {
138
+ global $wpdb;
139
+
140
+ return [
141
+ 'name' => __( 'Redirection', 'search-regex' ),
142
+ 'table' => $wpdb->prefix . 'redirection_items',
143
+ 'columns' => [
144
+ [
145
+ 'column' => 'id',
146
+ 'type' => 'integer',
147
+ 'title' => __( 'ID', 'search-regex' ),
148
+ 'modify' => false,
149
+ ],
150
+ [
151
+ 'column' => 'url',
152
+ 'type' => 'string',
153
+ 'title' => __( 'Source URL', 'search-regex' ),
154
+ 'options' => 'api',
155
+ 'global' => true,
156
+ ],
157
+ [
158
+ 'column' => 'match_url',
159
+ 'type' => 'string',
160
+ 'title' => __( 'Source URL (matching)', 'search-regex' ),
161
+ 'options' => 'api',
162
+ 'global' => true,
163
+ ],
164
+ [
165
+ 'column' => 'last_count',
166
+ 'type' => 'integer',
167
+ 'title' => __( 'Hit Count', 'search-regex' ),
168
+ ],
169
+ [
170
+ 'column' => 'last_access',
171
+ 'type' => 'date',
172
+ 'title' => __( 'Last Access', 'search-regex' ),
173
+ ],
174
+ [
175
+ 'column' => 'group_id',
176
+ 'type' => 'member',
177
+ 'title' => __( 'Group', 'search-regex' ),
178
+ 'options' => 'api',
179
+ 'preload' => true,
180
+ ],
181
+ [
182
+ 'column' => 'status',
183
+ 'type' => 'member',
184
+ 'title' => __( 'Status', 'search-regex' ),
185
+ 'options' => [
186
+ [
187
+ 'value' => 'enabled',
188
+ 'label' => __( 'Enabled', 'search-regex' ),
189
+ ],
190
+ [
191
+ 'value' => 'disabled',
192
+ 'label' => __( 'Disabled', 'search-regex' ),
193
+ ],
194
+ ],
195
+ ],
196
+ [
197
+ 'column' => 'position',
198
+ 'type' => 'integer',
199
+ 'title' => __( 'Position', 'search-regex' ),
200
+ ],
201
+ [
202
+ 'column' => 'action_code',
203
+ 'type' => 'member',
204
+ 'title' => __( 'HTTP Code', 'search-regex' ),
205
+ 'options' => $this->get_http_codes(),
206
+ ],
207
+ [
208
+ 'column' => 'title',
209
+ 'type' => 'string',
210
+ 'title' => __( 'Title', 'search-regex' ),
211
+ 'global' => true,
212
+ ],
213
+ // [
214
+ // 'column' => 'action_type',
215
+ // 'type' => 'member',
216
+ // 'title' => __( 'Action Type', 'search-regex' ),
217
+ // 'options' => $this->get_action_types(),
218
+ // ],
219
+ // [
220
+ // 'column' => 'match_type',
221
+ // 'type' => 'member',
222
+ // 'title' => __( 'Match Type', 'search-regex' ),
223
+ // 'options' => $this->get_match_types(),
224
+ // ],
225
+ [
226
+ 'column' => 'action_data',
227
+ 'type' => 'string',
228
+ 'title' => __( 'Target', 'search-regex' ),
229
+ 'global' => true,
230
+ ],
231
+ ],
232
+ ];
233
+ }
234
+
235
+ private function get_available_actions() {
236
+ if ( class_exists( '\Redirection\Module\Module' ) ) {
237
+ return \Redirection\Action\Action::available();
238
+ }
239
+
240
+ return \Red_Action::available();
241
+ }
242
+
243
+ private function create_action( $action, $code ) {
244
+ if ( class_exists( '\Redirection\Module\Module' ) ) {
245
+ return \Redirection\Action\Action::create( $action, $code );
246
+ }
247
+
248
+ return \Red_Action::create( $action, $code );
249
+ }
250
+
251
+ /**
252
+ * Get action types
253
+ *
254
+ * @return array
255
+ */
256
+ private function get_action_types() {
257
+ $types = $this->get_available_actions();
258
+ $actions = [];
259
+
260
+ foreach ( array_keys( $types ) as $type ) {
261
+ $obj = $this->create_action( $type, 301 );
262
+ $actions[] = [
263
+ 'value' => $type,
264
+ 'label' => $obj->name(),
265
+ ];
266
+ }
267
+
268
+ return $actions;
269
+ }
270
+
271
+ private function get_available_matches() {
272
+ if ( class_exists( '\Redirection\Module\Module' ) ) {
273
+ return \Redirection\Match\Match::available();
274
+ }
275
+
276
+ return \Red_Match::available();
277
+ }
278
+
279
+ private function create_match( $type ) {
280
+ if ( class_exists( '\Redirection\Module\Module' ) ) {
281
+ return \Redirection\Match\Match::create( $type );
282
+ }
283
+
284
+ return \Red_Match::create( $type );
285
+ }
286
+
287
+ /**
288
+ * Get match types
289
+ *
290
+ * @return array
291
+ */
292
+ private function get_match_types() {
293
+ $types = $this->get_available_matches();
294
+ $actions = [];
295
+
296
+ foreach ( array_keys( $types ) as $type ) {
297
+ $obj = $this->create_match( $type );
298
+ $actions[] = [
299
+ 'value' => $type,
300
+ 'label' => $obj->name(),
301
+ ];
302
+ }
303
+
304
+ return $actions;
305
+ }
306
+
307
+ /**
308
+ * Get all supported HTTP codes
309
+ *
310
+ * @return array
311
+ */
312
+ private function get_http_codes() {
313
+ $codes = [ 301, 302, 303, 304, 307, 308, 400, 401, 403, 404, 410, 418, 451, 500, 501, 502, 503, 504 ];
314
+ $http = [];
315
+
316
+ foreach ( $codes as $code ) {
317
+ $http[] = [
318
+ 'value' => "$code",
319
+ 'label' => "$code",
320
+ ];
321
+ }
322
+
323
+ return $http;
324
+ }
325
+
326
+ private function get_group( $group_id ) {
327
+ if ( class_exists( '\Redirection\Module\Module' ) ) {
328
+ return \Redirection\Redirect\Group::get( $group_id );
329
+ }
330
+
331
+ return Red_Group::get( $group_id );
332
+ }
333
+
334
+ public function convert_result_value( Schema\Column $schema, $value ) {
335
+ if ( $schema->get_column() === 'group_id' ) {
336
+ $group = $this->get_group( $value );
337
+ if ( $group ) {
338
+ return $group->get_name();
339
+ }
340
+ }
341
+
342
+ if ( $schema->get_column() === 'last_access' && $value === '1970-01-01 00:00:00' ) {
343
+ return __( 'Not accessed', 'search-regex' );
344
+ }
345
+
346
+ return parent::convert_result_value( $schema, $value );
347
+ }
348
+ }
349
+
350
+ /**
351
+ * Source: Redirection groups
352
+ */
353
+ // phpcs:ignore
354
+ class Redirection_Groups_Search_Regex extends Source\Source {
355
+ public function get_table_id() {
356
+ return 'id';
357
+ }
358
+
359
+ public function get_table_name() {
360
+ global $wpdb;
361
+
362
+ return $wpdb->prefix . 'redirection_groups';
363
+ }
364
+
365
+ public function get_title_column() {
366
+ return 'name';
367
+ }
368
+
369
+ private function get_group( $group_id ) {
370
+ if ( class_exists( '\Redirection\Module\Module' ) ) {
371
+ return \Redirection\Redirect\Group::get( $group_id );
372
+ }
373
+
374
+ return \Red_Group::get( $group_id );
375
+ }
376
+
377
+ private function delete_group( $group_id ) {
378
+ if ( class_exists( '\Redirection\Module\Module' ) ) {
379
+ return \Redirection\Redirect\Group::delete( $group_id );
380
+ }
381
+
382
+ return \Red_Group::delete( $group_id );
383
+ }
384
+
385
+ public function save( $row_id, array $changes ) {
386
+ $redirect = $this->get_columns_to_change( $changes );
387
+
388
+ if ( count( $redirect ) > 0 ) {
389
+ $item = $this->get_groupt( $row_id );
390
+
391
+ if ( ! is_wp_error( $item ) ) {
392
+ $this->log_save( 'redirect', array_merge( [ 'id' => $row_id ], $redirect ) );
393
+
394
+ $json = $item->to_json();
395
+ $json = array_merge( $json, $redirect );
396
+
397
+ $result = true;
398
+
399
+ /** @psalm-suppress UndefinedFunction */
400
+ if ( Plugin\Settings::init()->can_save() ) {
401
+ $result = $item->update( $json );
402
+ }
403
+
404
+ if ( $result ) {
405
+ return true;
406
+ }
407
+ }
408
+
409
+ return new \WP_Error( 'searchregex', 'Failed to update redirection group' );
410
+ }
411
+
412
+ return true;
413
+ }
414
+
415
+ public function delete_row( $row_id ) {
416
+ $this->log_save( 'delete redirection group', $row_id );
417
+
418
+ /** @psalm-suppress UndefinedFunction */
419
+ if ( Plugin\Settings::init()->can_save() ) {
420
+ if ( $this->delete_group( $row_id ) ) {
421
+ return true;
422
+ }
423
+
424
+ return new \WP_Error( 'searchregex_delete', 'Failed to delete comment', 401 );
425
+ }
426
+
427
+ return true;
428
+ }
429
+
430
+ public function autocomplete( $column, $value ) {
431
+ global $wpdb;
432
+
433
+ if ( isset( $column['column'] ) && $column['column'] === 'name' ) {
434
+ return $wpdb->get_results( $wpdb->prepare( "SELECT name as id,name as value FROM {$wpdb->prefix}redirection_groups WHERE name LIKE %s LIMIT 50", '%' . $wpdb->esc_like( $value ) . '%' ) );
435
+ }
436
+
437
+ return [];
438
+ }
439
+
440
+ public function get_schema() {
441
+ global $wpdb;
442
+
443
+ if ( class_exists( '\Redirection\Module\Module' ) ) {
444
+ /** @psalm-suppress UndefinedClass */
445
+ $wp_id = \Redirection\Module\WordPress::MODULE_ID;
446
+
447
+ /** @psalm-suppress UndefinedClass */
448
+ $apache_id = \Redirection\Module\Apache::MODULE_ID;
449
+
450
+ /** @psalm-suppress UndefinedClass */
451
+ $nginx_id = \Redirection\Module\Nginx::MODULE_ID;
452
+ } else {
453
+ /** @psalm-suppress UndefinedClass */
454
+ $wp_id = \WordPress_Module::MODULE_ID;
455
+
456
+ /** @psalm-suppress UndefinedClass */
457
+ $apache_id = \Apache_Module::MODULE_ID;
458
+
459
+ /** @psalm-suppress UndefinedClass */
460
+ $nginx_id = \Nginx_Module::MODULE_ID;
461
+ }
462
+
463
+ return [
464
+ 'name' => __( 'Redirection Groups', 'search-regex' ),
465
+ 'table' => $wpdb->prefix . 'redirection_groups',
466
+ 'columns' => [
467
+ [
468
+ 'column' => 'id',
469
+ 'type' => 'integer',
470
+ 'title' => __( 'ID', 'search-regex' ),
471
+ 'modify' => false,
472
+ ],
473
+ [
474
+ 'column' => 'name',
475
+ 'type' => 'string',
476
+ 'title' => __( 'Name', 'search-regex' ),
477
+ 'options' => 'api',
478
+ 'global' => true,
479
+ ],
480
+ [
481
+ 'column' => 'module_id',
482
+ 'type' => 'member',
483
+ 'title' => __( 'Module', 'search-regex' ),
484
+ 'options' => [
485
+ [
486
+ 'value' => $wp_id,
487
+ 'label' => __( 'WordPress', 'search-regex' ),
488
+ ],
489
+ [
490
+ 'value' => $apache_id,
491
+ 'label' => __( 'Apache', 'search-regex' ),
492
+ ],
493
+ [
494
+ 'value' => $nginx_id,
495
+ 'label' => __( 'Nginx', 'search-regex' ),
496
+ ],
497
+ ],
498
+ ],
499
+ [
500
+ 'column' => 'status',
501
+ 'type' => 'member',
502
+ 'title' => __( 'Status', 'search-regex' ),
503
+ 'options' => [
504
+ [
505
+ 'value' => 'enabled',
506
+ 'label' => __( 'Enabled', 'search-regex' ),
507
+ ],
508
+ [
509
+ 'value' => 'disabled',
510
+ 'label' => __( 'Disabled', 'search-regex' ),
511
+ ],
512
+ ],
513
+ ],
514
+ ],
515
+ ];
516
+ }
517
+ }
518
+
519
+ // add_filter( 'searchregex_sources_plugin', function( $plugins ) {
520
+ // // Only show if Redirection is loaded
521
+ // if ( defined( 'REDIRECTION_VERSION' ) ) {
522
+ // $plugins[] = [
523
+ // 'name' => 'redirection',
524
+ // 'label' => __( 'Redirection', 'search-regex' ),
525
+ // 'class' => 'SearchRegex\Source\Plugin\Redirection',
526
+ // 'type' => 'plugin',
527
+ // ];
528
+ // $plugins[] = [
529
+ // 'name' => 'redirection-groups',
530
+ // 'label' => __( 'Redirection Groups', 'search-regex' ),
531
+ // 'class' => 'SearchRegex\Source\Plugin\Redirection_Groups_Search_Regex',
532
+ // 'type' => 'plugin',
533
+ // ];
534
+ // }
535
+
536
+ // return $plugins;
537
+ // } );
includes/source/trait-has-meta.php ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Source;
4
+
5
+ use SearchRegex\Context\Type;
6
+ use SearchRegex\Plugin;
7
+
8
+ /**
9
+ * Provides meta table support to sources
10
+ */
11
+ trait HasMeta {
12
+ /**
13
+ * Process meta data in any updates
14
+ *
15
+ * @param integer $row_id Row ID.
16
+ * @param string $type Type of meta data.
17
+ * @param array $updates Array of updates.
18
+ * @return void
19
+ */
20
+ protected function process_meta( $row_id, $type, array $updates ) {
21
+ foreach ( $updates as $column => $update ) {
22
+ if ( $column === 'meta' ) {
23
+ $this->set_meta( $row_id, $type, $update['change'] );
24
+ }
25
+ }
26
+ }
27
+
28
+ /**
29
+ * Get meta data
30
+ *
31
+ * @param array $meta Meta data.
32
+ * @return array
33
+ */
34
+ private function get_meta( array $meta ) {
35
+ $items = array_map( function( $item ) use ( $meta ) {
36
+ $value = new Type\Value( $meta[ $item ][0] );
37
+
38
+ return [
39
+ 'key' => $item,
40
+ 'value' => $meta[ $item ][0],
41
+ 'value_type' => $value->get_value_type(),
42
+ ];
43
+ }, array_keys( $meta ) );
44
+
45
+ return [
46
+ 'column' => 'meta',
47
+ 'items' => $items,
48
+ ];
49
+ }
50
+
51
+ /**
52
+ * Set meta data
53
+ *
54
+ * @param integer $row_id Row ID.
55
+ * @param string $meta_type Type of meta data.
56
+ * @param array $update Array of updates.
57
+ * @return void
58
+ */
59
+ private function set_meta( $row_id, $meta_type, $update ) {
60
+ foreach ( $update as $meta ) {
61
+ $key = $meta->get_key();
62
+ $value = $meta->get_value();
63
+
64
+ // Delete a meta if we are changing the key, or deleting it
65
+ if ( $key->get_type() === Type\Replace::TYPE_REPLACE || $key->get_type() === Type\Delete::TYPE_DELETE ) {
66
+ $this->log_save( $meta_type . ' meta delete', (string) $row_id . ' = ' . $key->get_value() . ' = ' . $value->get_value() );
67
+
68
+ /** @psalm-suppress UndefinedFunction */
69
+ if ( Plugin\Settings::init()->can_save() ) {
70
+ delete_metadata( $meta_type, $row_id, $key->get_value(), $value->get_value() );
71
+ }
72
+ }
73
+
74
+ // Update the meta if we are changing the key, or replacing the value
75
+ if ( $value->get_type() === Type\Replace::TYPE_REPLACE || $key->get_type() === Type\Replace::TYPE_REPLACE ) {
76
+ $key_value = $key->get_type() === Type\Replace::TYPE_REPLACE ? $key->get_replacement() : $key->get_value();
77
+ $value_value = $value->get_type() === Type\Replace::TYPE_REPLACE ? $value->get_replacement() : $value->get_value();
78
+
79
+ $this->log_save( $meta_type . ' meta update', (string) $row_id . ' = ' . $key_value . ' => ' . $value_value );
80
+
81
+ /** @psalm-suppress UndefinedFunction */
82
+ if ( Plugin\Settings::init()->can_save() ) {
83
+ update_metadata( $meta_type, $row_id, $key_value, $value_value );
84
+ }
85
+ }
86
+
87
+ if ( $key->get_type() === Type\Add::TYPE_ADD ) {
88
+ $this->log_save( $meta_type . ' meta add', (string) $row_id . ' = ' . $key->get_value() . ' => ' . $value->get_value() );
89
+
90
+ /** @psalm-suppress UndefinedFunction */
91
+ if ( Plugin\Settings::init()->can_save() ) {
92
+ update_metadata( $meta_type, $row_id, $key->get_value(), $value->get_value() );
93
+ }
94
+ }
95
+ }
96
+ }
97
+ }
includes/source/trait-has-terms.php ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Source;
4
+
5
+ use SearchRegex\Context\Type;
6
+ use SearchRegex\Plugin;
7
+
8
+ /**
9
+ * Trait to add term support to a source
10
+ */
11
+ trait HasTerms {
12
+ /**
13
+ * Look for term changes and process them
14
+ *
15
+ * @param integer $row_id Row ID.
16
+ * @param string $type Type.
17
+ * @param array $updates Array of updates.
18
+ * @return void
19
+ */
20
+ protected function process_terms( $row_id, $type, array $updates ) {
21
+ foreach ( $updates as $column => $update ) {
22
+ if ( $column === 'category' || $column === 'post_tag' ) {
23
+ $this->set_terms( $row_id, $column, $update );
24
+ }
25
+ }
26
+ }
27
+
28
+ /**
29
+ * Get the terms as an array of value/label
30
+ *
31
+ * @param array $terms Terms.
32
+ * @return array
33
+ */
34
+ private function get_terms( array $terms ) {
35
+ $cats = [];
36
+ $tags = [];
37
+ $extra = [];
38
+
39
+ foreach ( $terms as $term ) {
40
+ if ( $term->taxonomy === 'category' ) {
41
+ $cats[] = [
42
+ 'value' => $term->slug,
43
+ 'label' => $term->name,
44
+ ];
45
+ } else {
46
+ $tags[] = [
47
+ 'value' => $term->slug,
48
+ 'label' => $term->name,
49
+ ];
50
+ }
51
+ }
52
+
53
+ if ( count( $tags ) > 0 ) {
54
+ $extra[] = [
55
+ 'column' => 'post_tag',
56
+ 'items' => $tags,
57
+ ];
58
+ }
59
+
60
+ if ( count( $cats ) > 0 ) {
61
+ $extra[] = [
62
+ 'column' => 'category',
63
+ 'items' => $cats,
64
+ ];
65
+ }
66
+
67
+ return $extra;
68
+ }
69
+
70
+ /**
71
+ * Perform term changes on an object
72
+ *
73
+ * @param integer $row_id Row ID.
74
+ * @param string $column Column to change.
75
+ * @param array $update Changes.
76
+ * @return void
77
+ */
78
+ private function set_terms( $row_id, $column, array $update ) {
79
+ // Get all term IDs that haven't changed
80
+ $term_ids = array_map( function( $item ) {
81
+ return intval( $item->get_value(), 10 );
82
+ }, $update['same'] );
83
+
84
+ // Get all term IDs that have changed
85
+ foreach ( $update['change'] as $change ) {
86
+ if ( $change->get_type() === Type\Add::TYPE_ADD ) {
87
+ $term_ids[] = intval( $change->get_value(), 10 );
88
+ }
89
+ }
90
+
91
+ $this->log_save( 'term ' . $column, $term_ids );
92
+
93
+ /** @psalm-suppress UndefinedFunction */
94
+ if ( Plugin\Settings::init()->can_save() ) {
95
+ wp_set_object_terms( $row_id, $term_ids, $column, false );
96
+ }
97
+ }
98
+ }
includes/sql/class-from.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Sql;
4
+
5
+ /**
6
+ * Sql FROM
7
+ */
8
+ class From {
9
+ /**
10
+ * Table name
11
+ *
12
+ * @readonly
13
+ * @var string
14
+ */
15
+ private $table;
16
+
17
+ /**
18
+ * Table alias
19
+ *
20
+ * @var string|null
21
+ */
22
+ private $alias = null;
23
+
24
+ public function __construct( Value $table, Value $alias = null ) {
25
+ $this->table = $table->get_value();
26
+ $this->alias = $alias ? $alias->get_value() : null;
27
+ }
28
+
29
+ /**
30
+ * Get the FROM as SQL
31
+ *
32
+ * @return string
33
+ */
34
+ public function get_as_sql() {
35
+ if ( $this->alias && $this->alias !== $this->table ) {
36
+ return $this->table . ' AS ' . $this->alias;
37
+ }
38
+
39
+ return $this->table;
40
+ }
41
+ }
includes/sql/class-group.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Sql;
4
+
5
+ /**
6
+ * Sql grouping
7
+ */
8
+ class Group {
9
+ /**
10
+ * Group name
11
+ *
12
+ * @readonly
13
+ * @var string
14
+ */
15
+ private $group;
16
+
17
+ public function __construct( Value $group ) {
18
+ $this->group = $group->get_value();
19
+ }
20
+
21
+ /**
22
+ * Get the group name
23
+ *
24
+ * @return string
25
+ */
26
+ public function get_as_sql() {
27
+ return $this->group;
28
+ }
29
+ }
includes/sql/class-query.php ADDED
@@ -0,0 +1,273 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Sql;
4
+
5
+ /**
6
+ * SQL Query class
7
+ */
8
+ class Query {
9
+ /**
10
+ * Array of Where\Where objects
11
+ *
12
+ * @var array
13
+ */
14
+ private $where = [];
15
+
16
+ /**
17
+ * Array of Select\Select objects
18
+ *
19
+ * @var Select\Select[]
20
+ */
21
+ private $select = [];
22
+
23
+ /**
24
+ * Array of From objects
25
+ *
26
+ * @var From[]
27
+ */
28
+ private $from = [];
29
+
30
+ /**
31
+ * Array of group objects
32
+ *
33
+ * @var Group[]
34
+ */
35
+ private $group = [];
36
+
37
+ /**
38
+ * Array of joins
39
+ *
40
+ * @var Join\Join[]
41
+ */
42
+ private $joins = [];
43
+
44
+ /**
45
+ * Current page offset
46
+ *
47
+ * @var integer|null
48
+ */
49
+ private $offset = null;
50
+
51
+ /**
52
+ * Query limit
53
+ *
54
+ * @var integer|null
55
+ */
56
+ private $limit = null;
57
+
58
+ /**
59
+ * Query order
60
+ *
61
+ * @var string|null
62
+ */
63
+ private $order = null;
64
+
65
+ /**
66
+ * Query order direction
67
+ *
68
+ * @var String
69
+ */
70
+ private $order_direction = 'ASC';
71
+
72
+ /**
73
+ * Set the query order
74
+ *
75
+ * @param String $order Column to order on.
76
+ * @param 'ASC'|'DESC' $order_direction Direction of ordering.
77
+ * @return void
78
+ */
79
+ public function set_order( $order, $order_direction = 'ASC' ) {
80
+ $order_direction = strtoupper( $order_direction );
81
+ $this->order = $order;
82
+
83
+ if ( in_array( $order_direction, [ 'ASC', 'DESC' ], true ) ) {
84
+ $this->order_direction = $order_direction;
85
+ }
86
+ }
87
+
88
+ /**
89
+ * Set the query page parameters.
90
+ *
91
+ * @param integer $offset Current offset.
92
+ * @param integer $limit Current limit.
93
+ * @return void
94
+ */
95
+ public function set_paging( $offset, $limit ) {
96
+ $this->offset = intval( $offset, 10 );
97
+ $this->limit = intval( $limit, 10 );
98
+ }
99
+
100
+ /**
101
+ * Add Where\Where to the query
102
+ *
103
+ * @param Where\Where $where Where\Where.
104
+ * @return void
105
+ */
106
+ public function add_where( Where\Where $where ) {
107
+ $this->where[] = $where;
108
+ }
109
+
110
+ /**
111
+ * Reset all the Where\Where objects
112
+ *
113
+ * @return void
114
+ */
115
+ public function reset_where() {
116
+ $this->where = [];
117
+ }
118
+
119
+ /**
120
+ * Get the Where\Where objects
121
+ *
122
+ * @return list<Where\Where>
123
+ */
124
+ public function get_where() {
125
+ return $this->where;
126
+ }
127
+
128
+ /**
129
+ * Add Select\Select to query
130
+ *
131
+ * @param Select\Select $select Select.
132
+ * @return void
133
+ */
134
+ public function add_select( Select\Select $select ) {
135
+ $this->select[] = $select;
136
+ }
137
+
138
+ /**
139
+ * Add array of Select\Select objects
140
+ *
141
+ * @param Select\Select[] $selects Selects.
142
+ * @return void
143
+ */
144
+ public function add_selects( array $selects ) {
145
+ $this->select = array_merge( $this->select, $selects );
146
+ }
147
+
148
+ /**
149
+ * Add From to query.
150
+ *
151
+ * @param From $from From.
152
+ * @return void
153
+ */
154
+ public function add_from( From $from ) {
155
+ $this->from[] = $from;
156
+ }
157
+
158
+ /**
159
+ * Add Join to query.
160
+ *
161
+ * @param Join\Join $join Join.
162
+ * @return void
163
+ */
164
+ public function add_join( Join\Join $join ) {
165
+ $this->joins[] = $join;
166
+ }
167
+
168
+ /**
169
+ * Add Group to query
170
+ *
171
+ * @param Group $group Group.
172
+ * @return void
173
+ */
174
+ public function add_group( Group $group ) {
175
+ $this->group[] = $group;
176
+ }
177
+
178
+ /**
179
+ * Add the selects from another query
180
+ *
181
+ * @param Query $query Query.
182
+ * @return void
183
+ */
184
+ public function add_select_only( Query $query ) {
185
+ $this->select = array_merge( $this->select, $query->select );
186
+ }
187
+
188
+ /**
189
+ * Add everything from a query except the WHERE, and return the WHERE
190
+ *
191
+ * @param Query $query Query.
192
+ * @return Where\Where[]
193
+ */
194
+ public function add_query_except_where( Query $query ) {
195
+ $this->select = array_merge( $this->select, $query->select );
196
+ $this->from = array_merge( $this->from, $query->from );
197
+ $this->group = array_merge( $this->group, $query->group );
198
+ $this->joins = array_merge( $this->joins, $query->joins );
199
+ return $query->where;
200
+ }
201
+
202
+ /**
203
+ * Add another query
204
+ *
205
+ * @param Query $query Query.
206
+ * @return void
207
+ */
208
+ public function add_query( Query $query ) {
209
+ $this->where = array_merge( $this->where, $query->where );
210
+ $this->select = array_merge( $this->select, $query->select );
211
+ $this->from = array_merge( $this->from, $query->from );
212
+ $this->group = array_merge( $this->group, $query->group );
213
+ $this->joins = array_merge( $this->joins, $query->joins );
214
+ }
215
+
216
+ /**
217
+ * Get the query as a SQL statement
218
+ *
219
+ * @param Modifier\Modifier $modifier Modifier for the query.
220
+ * @return string
221
+ */
222
+ public function get_as_sql( Modifier\Modifier $modifier = null ) {
223
+ global $wpdb;
224
+
225
+ if ( $modifier === null ) {
226
+ $modifier = new Modifier\Modifier();
227
+ }
228
+
229
+ $select = array_unique( $modifier->get_select( $this->select, $this->joins ) );
230
+ $from = array_unique( $modifier->get_from( $this->from, $this->joins ) );
231
+ $where = $modifier->get_where( $this->where, $this->joins );
232
+ $group = array_unique( $modifier->get_group( $this->group, $this->joins ) );
233
+
234
+ // SELECT select FROM from joins WHERE where group order limit
235
+ $sql = [
236
+ 'SELECT',
237
+ implode( ', ', array_unique( $select ) ),
238
+ 'FROM',
239
+ implode( ' ', array_unique( $from ) ),
240
+ ];
241
+
242
+ $sql = array_merge( $sql, $this->get_query_section( 'WHERE', $where, ' AND ' ) );
243
+ $sql = array_merge( $sql, $this->get_query_section( 'GROUP BY', $group ) );
244
+
245
+ if ( $this->order ) {
246
+ $sql[] = 'ORDER BY';
247
+ $sql[] = $this->order;
248
+ $sql[] = $this->order_direction;
249
+ }
250
+
251
+ if ( $this->offset !== null ) {
252
+ $sql[] = $wpdb->prepare( 'LIMIT %d,%d', $this->offset, $this->limit );
253
+ }
254
+
255
+ return implode( ' ', $sql );
256
+ }
257
+
258
+ /**
259
+ * Get a group of SQL statements with a space between them
260
+ *
261
+ * @param string $label SQL label.
262
+ * @param array $values Group of statements.
263
+ * @param string $separator Seperator for statements.
264
+ * @return array<string>
265
+ */
266
+ private function get_query_section( $label, array $values, $separator = ' ' ) {
267
+ if ( count( $values ) > 0 ) {
268
+ return [ $label . ' ' . implode( $separator, $values ) ];
269
+ }
270
+
271
+ return [];
272
+ }
273
+ }
includes/sql/class-sql.php ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Sql;
4
+
5
+ require_once __DIR__ . '/class-from.php';
6
+ require_once __DIR__ . '/class-group.php';
7
+ require_once __DIR__ . '/class-query.php';
8
+ require_once __DIR__ . '/class-value.php';
9
+
10
+ require_once __DIR__ . '/where/class-where.php';
11
+ require_once __DIR__ . '/select/class-select.php';
12
+ require_once __DIR__ . '/modifier/class-modifier.php';
13
+ require_once __DIR__ . '/join/class-join.php';
14
+
15
+ /**
16
+ * Perform SQL queries on the database.
17
+ */
18
+ class Builder {
19
+ /**
20
+ * Get the wpdb error
21
+ *
22
+ * @param string $sql SQL statement.
23
+ * @return \WP_Error
24
+ */
25
+ private function get_db_error( $sql ) {
26
+ global $wpdb;
27
+
28
+ $error = $wpdb->last_error ? $wpdb->last_error : 'Unknown error';
29
+
30
+ return new \WP_Error( 'searchregex_database', $error, preg_replace( '/\{.*?\}/', '%', $sql ) );
31
+ }
32
+
33
+ /**
34
+ * Get total number of matching rows from a table using the filters
35
+ *
36
+ * @param Query $query Query.
37
+ * @return Int|\WP_Error The number of rows, or \WP_Error on error
38
+ */
39
+ public function get_count( Query $query ) {
40
+ global $wpdb;
41
+
42
+ $sql = $query->get_as_sql();
43
+
44
+ $this->log_sql( 'SQL get_count', $sql );
45
+
46
+ // This is a known and validated query
47
+ // phpcs:ignore
48
+ $result = $wpdb->get_var( $sql );
49
+ if ( $result === null ) {
50
+ return $this->get_db_error( $sql );
51
+ }
52
+
53
+ return intval( $result, 10 );
54
+ }
55
+
56
+ /**
57
+ * Get single row
58
+ *
59
+ * @param Query $query Query.
60
+ * @param Modifier\Modifier $modifier Modifier.
61
+ * @return object|\WP_Error
62
+ */
63
+ public function get_result( Query $query, Modifier\Modifier $modifier = null ) {
64
+ global $wpdb;
65
+
66
+ $sql = $query->get_as_sql( $modifier );
67
+
68
+ $this->log_sql( 'SQL get_result', $sql );
69
+
70
+ // Known query
71
+ // phpcs:ignore
72
+ $result = $wpdb->get_row( $sql );
73
+ if ( $result === null ) {
74
+ return $this->get_db_error( $sql );
75
+ }
76
+
77
+ return $result;
78
+ }
79
+
80
+ /**
81
+ * Get multiple rows
82
+ *
83
+ * @param Query $query Query.
84
+ * @return array|\WP_Error
85
+ */
86
+ public function get_search( Query $query ) {
87
+ global $wpdb;
88
+
89
+ // phpcs:ignore
90
+ $sql = $query->get_as_sql();
91
+ $this->log_sql( 'SQL get_search', $sql );
92
+
93
+ // This is a known and validated query
94
+ // phpcs:ignore
95
+ $results = $wpdb->get_results( $sql, ARRAY_A );
96
+ if ( $results === false || $wpdb->last_error ) {
97
+ return $this->get_db_error( $sql );
98
+ }
99
+
100
+ return $results;
101
+ }
102
+
103
+ /**
104
+ * Internal SQL debug function
105
+ *
106
+ * @param string $title Description for this SQL.
107
+ * @param string $query SQL.
108
+ * @return void
109
+ */
110
+ private function log_sql( $title, $query ) {
111
+ if ( defined( 'WP_DEBUG' ) && WP_DEBUG && ! defined( 'SEARCHREGEX_TESTS' ) ) {
112
+ // phpcs:ignore
113
+ error_log( $title . ': ' . preg_replace( '/\{.*?\}/', '%', $query ) );
114
+ }
115
+ }
116
+ }
includes/sql/class-value.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Sql;
4
+
5
+ /**
6
+ * A simple sanitizer for table names, column names, and raw (pre-sanitized) names. This shouldn't be treated as a replacement for $wpdb->prepare, and is just
7
+ * a way of being extra-paranoid when forming queries with known column and table names.
8
+ */
9
+ class Value {
10
+ /**
11
+ * Underlying value
12
+ *
13
+ * @readonly
14
+ * @var string
15
+ */
16
+ private $value;
17
+
18
+ /**
19
+ * Constructor
20
+ *
21
+ * @param string $value Value.
22
+ */
23
+ public function __construct( $value ) {
24
+ $this->value = $value;
25
+ }
26
+
27
+ /**
28
+ * Get the sanitized value.
29
+ *
30
+ * @return string
31
+ */
32
+ public function get_value() {
33
+ return $this->value;
34
+ }
35
+
36
+ /**
37
+ * Create a Value with a known sanitized value. You should only use this when you are sure the value is safe.
38
+ *
39
+ * @param string $value Value.
40
+ * @return Value
41
+ */
42
+ public static function safe_raw( $value ) {
43
+ return new Value( $value );
44
+ }
45
+
46
+ /**
47
+ * Create a Value for a SQL column. Performs column sanitization and allows for column aliases
48
+ *
49
+ * @param string $column Column name.
50
+ * @return Value
51
+ */
52
+ public static function column( $column ) {
53
+ $column = preg_replace( '/[^ A-Za-z0-9_\-\.]/', '', $column );
54
+
55
+ return new Value( $column );
56
+ }
57
+
58
+ /**
59
+ * Create a Value for a SQL table name. Performs table name sanitization.
60
+ *
61
+ * @param string $table Table name.
62
+ * @return Value
63
+ */
64
+ public static function table( $table ) {
65
+ $table = preg_replace( '/[^A-Za-z0-9_\-]/', '', $table );
66
+
67
+ return new Value( $table );
68
+ }
69
+ }
includes/sql/join/class-join.php ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Sql\Join;
4
+
5
+ use SearchRegex\Sql;
6
+
7
+ require_once __DIR__ . '/join-meta.php';
8
+ require_once __DIR__ . '/join-term.php';
9
+ require_once __DIR__ . '/join-taxonomy.php';
10
+ require_once __DIR__ . '/join-post.php';
11
+ require_once __DIR__ . '/join-user.php';
12
+ require_once __DIR__ . '/join-comment.php';
13
+
14
+ /**
15
+ * SQL join
16
+ */
17
+ abstract class Join {
18
+ /**
19
+ * Does this require matching?
20
+ *
21
+ * @var boolean
22
+ */
23
+ protected $is_matching = true;
24
+
25
+ /**
26
+ * Column to join on
27
+ *
28
+ * @var string
29
+ */
30
+ protected $column;
31
+
32
+ /**
33
+ * Create a Join object
34
+ *
35
+ * @param string $column Column to join on.
36
+ * @param string $source Source.
37
+ * @return Join|null
38
+ */
39
+ public static function create( $column, $source ) {
40
+ if ( $column === 'category' || $column === 'post_tag' ) {
41
+ return new Term( $column );
42
+ }
43
+
44
+ if ( $column === 'meta_key' || $column === 'meta_value' || $column === 'meta' ) {
45
+ return new Meta( $column, $source );
46
+ }
47
+
48
+ if ( $column === 'taxonomy' ) {
49
+ return new Taxonomy( $column );
50
+ }
51
+
52
+ if ( $column === 'post' ) {
53
+ return new Post( $column, $source );
54
+ }
55
+
56
+ if ( $column === 'user' ) {
57
+ return new User( $column, $source );
58
+ }
59
+
60
+ if ( $column === 'comment' ) {
61
+ return new Comment( $column );
62
+ }
63
+
64
+ return null;
65
+ }
66
+
67
+ /**
68
+ * Get SQL for join FROM, or false if no FROM
69
+ *
70
+ * @return Sql\From|false
71
+ */
72
+ public function get_from() {
73
+ return false;
74
+ }
75
+
76
+ /**
77
+ * Get SQL for join GROUP, or false if no GROUP
78
+ *
79
+ * @return Sql\Group|false
80
+ */
81
+ public function get_group() {
82
+ return false;
83
+ }
84
+
85
+ /**
86
+ * Get SQL for join SELECT, or false if no SELECT
87
+ *
88
+ * @return Sql\Select\Select|false
89
+ */
90
+ public function get_select() {
91
+ return false;
92
+ }
93
+
94
+ /**
95
+ * Get SQL for join WHERE, or false if no WHERE
96
+ *
97
+ * @return Sql\Where|false
98
+ */
99
+ public function get_where() {
100
+ return false;
101
+ }
102
+
103
+ /**
104
+ * Get join column
105
+ *
106
+ * @return string
107
+ */
108
+ public function get_column() {
109
+ return $this->column;
110
+ }
111
+
112
+ /**
113
+ * Set this join as non-matching
114
+ *
115
+ * @return void
116
+ */
117
+ public function set_non_matching() {
118
+ $this->is_matching = false;
119
+ }
120
+
121
+ /**
122
+ * Get the column in the joined table
123
+ *
124
+ * @return string
125
+ */
126
+ abstract public function get_join_column();
127
+
128
+ /**
129
+ * Get the joined value
130
+ *
131
+ * @param string $value Value.
132
+ * @return string
133
+ */
134
+ abstract public function get_join_value( $value );
135
+
136
+ /**
137
+ * Get table we are joining on
138
+ *
139
+ * @return string
140
+ */
141
+ abstract public function get_table();
142
+ }
includes/sql/join/join-comment.php ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Sql\Join;
4
+
5
+ use SearchRegex\Source;
6
+ use SearchRegex\Sql;
7
+
8
+ /**
9
+ * Join on comments table
10
+ */
11
+ class Comment extends Join {
12
+ /**
13
+ * Join logic
14
+ *
15
+ * @var string|false
16
+ */
17
+ private $logic = false;
18
+
19
+ /**
20
+ * Join table
21
+ *
22
+ * @var string
23
+ */
24
+ private $join_table;
25
+
26
+ /**
27
+ * Constructor
28
+ *
29
+ * @param string $column Column.
30
+ */
31
+ public function __construct( $column ) {
32
+ global $wpdb;
33
+
34
+ $this->column = 'comment_id';
35
+ $this->join_table = $wpdb->commentmeta;
36
+ }
37
+
38
+ /**
39
+ * Set the logic for this join
40
+ *
41
+ * @param string $logic Logic.
42
+ * @return void
43
+ */
44
+ public function set_logic( $logic ) {
45
+ $this->logic = $logic;
46
+ }
47
+
48
+ public function get_select() {
49
+ global $wpdb;
50
+
51
+ return new Sql\Select\Select( Sql\Value::table( $wpdb->comments ), Sql\Value::column( 'comment_id' ), null, true );
52
+ }
53
+
54
+ public function get_from() {
55
+ global $wpdb;
56
+
57
+ $table = Sql\Value::table( $this->join_table );
58
+ $column = Sql\Value::column( $this->get_join_column() );
59
+
60
+ return new Sql\From( Sql\Value::safe_raw( sprintf( "LEFT JOIN {$wpdb->comments} ON {$wpdb->comments}.comment_id=%s.%s", $table->get_value(), $column->get_value() ) ) );
61
+ }
62
+
63
+ public function get_join_column() {
64
+ return 'comment_id';
65
+ }
66
+
67
+ public function get_where() {
68
+ global $wpdb;
69
+
70
+ if ( $this->logic ) {
71
+ return new Sql\Where\Where_Null( new Sql\Select\Select( Sql\Value::table( $wpdb->comments ), Sql\Value::column( 'comment_id' ) ), $this->logic );
72
+ }
73
+
74
+ return false;
75
+ }
76
+
77
+ public function get_table() {
78
+ global $wpdb;
79
+
80
+ return $wpdb->comments;
81
+ }
82
+
83
+ public function get_join_value( $value ) {
84
+ return "$value";
85
+ }
86
+ }
includes/sql/join/join-meta.php ADDED
@@ -0,0 +1,167 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Sql\Join;
4
+
5
+ use SearchRegex\Source;
6
+ use SearchRegex\Sql;
7
+
8
+ /**
9
+ * Join on meta table
10
+ */
11
+ class Meta extends Join {
12
+ /**
13
+ * Source
14
+ *
15
+ * @var string
16
+ */
17
+ private $source;
18
+
19
+ /**
20
+ * Meta table name
21
+ *
22
+ * @var string
23
+ */
24
+ private $meta_table;
25
+
26
+ /**
27
+ * Source table name
28
+ *
29
+ * @var string
30
+ */
31
+ private $source_table;
32
+
33
+ /**
34
+ * ID column to join on
35
+ *
36
+ * @var string
37
+ */
38
+ private $join_id;
39
+
40
+ /**
41
+ * Table to join on
42
+ *
43
+ * @var string
44
+ */
45
+ private $table_id;
46
+
47
+ /**
48
+ * Column to group by
49
+ *
50
+ * @var string
51
+ */
52
+ private $group_id;
53
+
54
+ /**
55
+ * ID in meta table to join on
56
+ *
57
+ * @var string
58
+ */
59
+ private $meta_id;
60
+
61
+ /**
62
+ * Constructor
63
+ *
64
+ * @param string $meta_type Meta type.
65
+ * @param string $source Source.
66
+ */
67
+ public function __construct( $meta_type, $source ) {
68
+ global $wpdb;
69
+
70
+ $this->column = $meta_type;
71
+ $this->source = $source;
72
+ $this->source_table = '';
73
+ $this->meta_id = 'meta_id';
74
+ $this->group_id = '';
75
+ $this->table_id = '';
76
+ $this->meta_table = '';
77
+ $this->table_id = 'ID';
78
+ $this->join_id = '';
79
+
80
+ if ( $source === 'postmeta' ) {
81
+ $this->meta_table = $wpdb->postmeta;
82
+ $this->source_table = $wpdb->posts;
83
+ $this->join_id = 'post_id';
84
+ $this->group_id = $wpdb->posts . '.ID';
85
+ } elseif ( $source === 'commentmeta' ) {
86
+ $this->meta_table = $wpdb->commentmeta;
87
+ $this->source_table = $wpdb->comments;
88
+ $this->join_id = 'comment_id';
89
+ $this->group_id = $wpdb->comments . '.comment_ID';
90
+ $this->table_id = 'comment_id';
91
+ } elseif ( $source === 'usermeta' ) {
92
+ $this->meta_table = $wpdb->usermeta;
93
+ $this->source_table = $wpdb->users;
94
+ $this->join_id = 'user_id';
95
+ $this->group_id = $wpdb->users . '.ID';
96
+ $this->meta_id = 'umeta_id';
97
+ }
98
+ }
99
+
100
+ public function get_select() {
101
+ return new Sql\Select\Select( Sql\Value::table( $this->meta_table ), Sql\Value::column( '0' ), Sql\Value::column( 'meta_id' ) );
102
+ }
103
+
104
+ public function get_group() {
105
+ return new Sql\Group( Sql\Value::column( $this->group_id ) );
106
+ }
107
+
108
+ public function get_from() {
109
+ if ( $this->is_matching ) {
110
+ return new Sql\From( Sql\Value::safe_raw( sprintf( 'LEFT JOIN %s AS meta ON %s.%s = meta.%s', $this->meta_table, $this->source_table, $this->table_id, $this->join_id ) ) );
111
+ }
112
+
113
+ return false;
114
+ }
115
+
116
+ public function get_join_column() {
117
+ return 'meta.' . $this->column;
118
+ }
119
+
120
+ public function get_join_value( $meta_id ) {
121
+ global $wpdb;
122
+
123
+ if ( $this->column === 'meta_key' ) {
124
+ // phpcs:ignore
125
+ return $wpdb->get_var( $wpdb->prepare( "SELECT meta_key FROM {$this->meta_table} WHERE {$this->meta_id}=%d", $meta_id ) );
126
+ }
127
+
128
+ // phpcs:ignore
129
+ return $wpdb->get_var( $wpdb->prepare( "SELECT meta_value FROM {$this->meta_table} WHERE {$this->meta_id}=%d", $meta_id ) );
130
+ }
131
+
132
+ /**
133
+ * Get meta values
134
+ *
135
+ * @param array $values Meta ID values.
136
+ * @return array
137
+ */
138
+ public function get_values( array $values ) {
139
+ global $wpdb;
140
+
141
+ $in = new Sql\Where\Where_In( new Sql\Select\Select( Sql\Value::table( $this->meta_table ), Sql\Value::column( $this->column ) ), 'IN', $values );
142
+
143
+ // phpcs:ignore
144
+ return $wpdb->get_results( "SELECT meta_key,meta_value FROM {$this->meta_table} WHERE {$this->meta_id} IN ". $in->get_value() );
145
+ }
146
+
147
+ public function get_column() {
148
+ return 'meta';
149
+ }
150
+
151
+ /**
152
+ * Get all the values for this join
153
+ *
154
+ * @param integer $row_id Row ID.
155
+ * @return array
156
+ */
157
+ public function get_all_values( $row_id ) {
158
+ global $wpdb;
159
+
160
+ // phpcs:ignore
161
+ return $wpdb->get_col( $wpdb->prepare( "SELECT {$this->meta_id} FROM {$this->get_table()} WHERE {$this->join_id} = %d", $row_id ) );
162
+ }
163
+
164
+ public function get_table() {
165
+ return $this->meta_table;
166
+ }
167
+ }
includes/sql/join/join-post.php ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Sql\Join;
4
+
5
+ use SearchRegex\Source;
6
+ use SearchRegex\Sql;
7
+
8
+ /**
9
+ * Join on the post table
10
+ */
11
+ class Post extends Join {
12
+ /**
13
+ * Join logic
14
+ *
15
+ * @var string
16
+ */
17
+ private $logic;
18
+
19
+ /**
20
+ * Source
21
+ *
22
+ * @var string
23
+ */
24
+ private $source;
25
+
26
+ /**
27
+ * Column to join
28
+ *
29
+ * @var string
30
+ */
31
+ private $join_column;
32
+
33
+ /**
34
+ * Constructor
35
+ *
36
+ * @param string $column Column.
37
+ * @param string $source Source.
38
+ */
39
+ public function __construct( $column, $source ) {
40
+ global $wpdb;
41
+
42
+ $this->column = $column;
43
+ $this->source = $wpdb->postmeta;
44
+ $this->join_column = '';
45
+ $this->logic = '';
46
+
47
+ if ( $source === 'post-meta' ) {
48
+ $this->join_column = 'post_id';
49
+ } elseif ( $source === 'comment-meta' ) {
50
+ $this->join_column = 'comment_ID';
51
+ $this->source = $wpdb->commentmeta;
52
+ } elseif ( $source === 'comment' ) {
53
+ $this->source = $wpdb->comments;
54
+ $this->join_column = 'comment_post_ID';
55
+ }
56
+ }
57
+
58
+ /**
59
+ * Set the logic for this join
60
+ *
61
+ * @param string $logic Logic.
62
+ * @return void
63
+ */
64
+ public function set_logic( $logic ) {
65
+ $this->logic = $logic;
66
+ }
67
+
68
+ public function get_select() {
69
+ return new Sql\Select\Select( Sql\Value::table( $this->source ), Sql\Value::column( $this->join_column ), null, true );
70
+ }
71
+
72
+ public function get_from() {
73
+ global $wpdb;
74
+
75
+ $source = Sql\Value::table( $this->source );
76
+ $column = Sql\Value::column( $this->join_column );
77
+
78
+ return new Sql\From( Sql\Value::safe_raw( sprintf( "LEFT JOIN {$wpdb->posts} ON {$wpdb->posts}.ID=%s.%s", $source->get_value(), $column->get_value() ) ) );
79
+ }
80
+
81
+ public function get_join_column() {
82
+ return $this->join_column;
83
+ }
84
+
85
+ public function get_where() {
86
+ global $wpdb;
87
+
88
+ return new Sql\Where_Null( new Sql\Select\Select( Sql\Value::table( $wpdb->posts ), Sql\Value::column( 'ID' ) ), $this->logic );
89
+ }
90
+
91
+ public function get_join_value( $value ) {
92
+ return "$value";
93
+ }
94
+
95
+ public function get_table() {
96
+ return $this->source;
97
+ }
98
+ }
includes/sql/join/join-taxonomy.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Sql\Join;
4
+
5
+ use SearchRegex\Source;
6
+ use SearchRegex\Sql;
7
+
8
+ /**
9
+ * Joins taxonomy table
10
+ */
11
+ class Taxonomy extends Join {
12
+ /**
13
+ * Constructor
14
+ *
15
+ * @param string $term_type Type of taxonomy.
16
+ */
17
+ public function __construct( $term_type ) {
18
+ $this->column = $term_type;
19
+ }
20
+
21
+ public function get_select() {
22
+ global $wpdb;
23
+
24
+ return new Sql\Select\Select( Sql\Value::table( $wpdb->prefix . 'term_taxonomy' ), Sql\Value::column( 'taxonomy' ) );
25
+ }
26
+
27
+ public function get_from() {
28
+ global $wpdb;
29
+
30
+ return new Sql\From( Sql\Value::safe_raw( sprintf( 'INNER JOIN %sterm_taxonomy AS tt ON (%sterms.term_id = tt.term_id)', $wpdb->prefix, $wpdb->prefix ) ) );
31
+ }
32
+
33
+ public function get_join_column() {
34
+ return 'tt.taxonomy';
35
+ }
36
+
37
+ public function get_join_value( $value ) {
38
+ $tax = get_taxonomy( $value );
39
+
40
+ if ( $tax && ! is_wp_error( $tax ) ) {
41
+ return $tax->label;
42
+ }
43
+
44
+ return "$value";
45
+ }
46
+
47
+ public function get_table() {
48
+ return '';
49
+ }
50
+ }
includes/sql/join/join-term.php ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Sql\Join;
4
+
5
+ use SearchRegex\Source;
6
+ use SearchRegex\Sql;
7
+
8
+ /**
9
+ * Join on terms
10
+ */
11
+ class Term extends Join {
12
+ /**
13
+ * Constructor
14
+ *
15
+ * @param string $term_type Type of taxonomy.
16
+ */
17
+ public function __construct( $term_type ) {
18
+ $this->column = $term_type;
19
+ }
20
+
21
+ public function get_where() {
22
+ if ( $this->is_matching ) {
23
+ return new Sql\Where\Where_String( new Sql\Select\Select( Sql\Value::column( 'tt' ), Sql\Value::column( 'taxonomy' ) ), '=', $this->column );
24
+ }
25
+
26
+ return false;
27
+ }
28
+
29
+ public function get_select() {
30
+ return new Sql\Select\Select( Sql\Value::column( 'tt' ), Sql\Value::column( '0' ), Sql\Value::column( $this->column ) );
31
+ }
32
+
33
+ public function get_group() {
34
+ global $wpdb;
35
+
36
+ return new Sql\Group( Sql\Value::column( "{$wpdb->posts}.ID" ) );
37
+ }
38
+
39
+ public function get_from() {
40
+ global $wpdb;
41
+
42
+ if ( $this->is_matching ) {
43
+ return new Sql\From( Sql\Value::safe_raw( sprintf( 'INNER JOIN %sterm_relationships AS tr ON (%s.ID = tr.object_id) INNER JOIN %sterm_taxonomy AS tt ON tt.term_taxonomy_id=tr.term_taxonomy_id', $wpdb->prefix, $wpdb->posts, $wpdb->prefix ) ) );
44
+ }
45
+
46
+ return false;
47
+ }
48
+
49
+ public function get_join_column() {
50
+ return 'tr.term_taxonomy_id';
51
+ }
52
+
53
+ public function get_join_value( $value ) {
54
+ $term = get_term( intval( $value, 10 ) );
55
+ if ( $term instanceof \WP_Error ) {
56
+ return "$value";
57
+ }
58
+
59
+ if ( is_object( $term ) && $term->taxonomy === $this->column ) {
60
+ return $term->name;
61
+ }
62
+
63
+ return "$value";
64
+ }
65
+
66
+ /**
67
+ * Get all term values
68
+ *
69
+ * @param integer $row_id Row ID.
70
+ * @return integer[]
71
+ */
72
+ public function get_all_values( $row_id ) {
73
+ return wp_get_post_terms( $row_id, $this->column, [ 'fields' => 'ids' ] );
74
+ }
75
+
76
+ public function get_table() {
77
+ return '';
78
+ }
79
+
80
+ /**
81
+ * Get the value
82
+ *
83
+ * @param integer $row_id Row ID.
84
+ * @param string $type Term type.
85
+ * @param string $seperator How to seperate the terms.
86
+ * @return string
87
+ */
88
+ public function get_value( $row_id, $type, $seperator ) {
89
+ $terms = wp_get_post_terms( $row_id, $this->column, [ 'fields' => 'all' ] );
90
+ if ( $terms instanceof \WP_Error ) {
91
+ return '';
92
+ }
93
+
94
+ $group = array_map( function( $term ) use ( $type ) {
95
+ if ( $type === 'slug' ) {
96
+ return $term->slug;
97
+ }
98
+
99
+ if ( $type === 'url' ) {
100
+ return get_term_link( $term );
101
+ }
102
+
103
+ if ( $type === 'link' ) {
104
+ $link = get_term_link( $term );
105
+ if ( $link instanceof \WP_Error ) {
106
+ return '';
107
+ }
108
+
109
+ return '<a href="' . esc_url( $link ) . '">' . $term->name . '</a>';
110
+ }
111
+
112
+ if ( $type === 'description' ) {
113
+ return $term->description;
114
+ }
115
+
116
+ return $term->name;
117
+ }, $terms );
118
+
119
+ return implode( $seperator, $group );
120
+ }
121
+ }
includes/sql/join/join-user.php ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Sql\Join;
4
+
5
+ use SearchRegex\Source;
6
+ use SearchRegex\Sql;
7
+
8
+ /**
9
+ * Undocumented class
10
+ */
11
+ class User extends Join {
12
+ /**
13
+ * Join logic
14
+ *
15
+ * @var string
16
+ */
17
+ private $logic = '';
18
+
19
+ /**
20
+ * Join table
21
+ *
22
+ * @var string
23
+ */
24
+ private $join_table = '';
25
+
26
+ /**
27
+ * Join column
28
+ *
29
+ * @var string
30
+ */
31
+ private $join_column;
32
+
33
+ /**
34
+ * Join to
35
+ *
36
+ * @var string
37
+ */
38
+ private $join_to;
39
+
40
+ /**
41
+ * Join to column
42
+ *
43
+ * @var string
44
+ */
45
+ private $join_to_column = '';
46
+
47
+ /**
48
+ * Constructor
49
+ *
50
+ * @param string $column Column.
51
+ * @param string $source Source.
52
+ */
53
+ public function __construct( $column, $source ) {
54
+ global $wpdb;
55
+
56
+ $this->column = $column;
57
+ $this->join_column = 'user_id';
58
+ $this->join_to_column = 'ID';
59
+ $this->join_to = $wpdb->users;
60
+
61
+ if ( $source === 'comment' ) {
62
+ $this->join_table = $wpdb->comments;
63
+ $this->join_column = 'user_id';
64
+ } elseif ( $source === 'posts' ) {
65
+ $this->join_table = $wpdb->posts;
66
+ $this->join_column = 'post_author';
67
+ } elseif ( $source === 'users' ) {
68
+ $this->join_table = $wpdb->users;
69
+ $this->join_to_column = 'ID';
70
+ } elseif ( $source === 'user-meta' ) {
71
+ $this->join_table = $wpdb->usermeta;
72
+ $this->join_column = 'user_id';
73
+ }
74
+ }
75
+
76
+ /**
77
+ * Set the logic
78
+ *
79
+ * @param string $logic Logic.
80
+ * @return void
81
+ */
82
+ public function set_logic( $logic ) {
83
+ $this->logic = $logic;
84
+ }
85
+
86
+ public function get_select() {
87
+ return new Sql\Select\Select( Sql\Value::table( $this->join_table ), Sql\Value::column( $this->join_column ), null, true );
88
+ }
89
+
90
+ public function get_from() {
91
+ global $wpdb;
92
+
93
+ $table = Sql\Value::table( $this->join_table );
94
+ $column = Sql\Value::column( $this->join_column );
95
+ return new Sql\From( Sql\Value::safe_raw( sprintf( "LEFT JOIN {$wpdb->users} ON {$wpdb->users}.ID=%s.%s", $table->get_value(), $column->get_value() ) ) );
96
+ }
97
+
98
+ public function get_join_column() {
99
+ return $this->join_column;
100
+ }
101
+
102
+ public function get_where() {
103
+ return new Sql\Where\Where_Null( new Sql\Select\Select( Sql\Value::table( $this->join_to ), Sql\Value::column( $this->join_to_column ) ), $this->logic );
104
+ }
105
+
106
+ public function get_join_value( $value ) {
107
+ return "$value";
108
+ }
109
+
110
+ public function get_table() {
111
+ return $this->join_table;
112
+ }
113
+ }
includes/sql/modifier/class-count.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Sql\Modifier;
4
+
5
+ use SearchRegex\Sql;
6
+
7
+ /**
8
+ * Perform a COUNT of a query
9
+ */
10
+ class Select_Count_Id extends Modifier {
11
+ /**
12
+ * Column to modify
13
+ *
14
+ * @readonly
15
+ * @var string
16
+ */
17
+ private $column;
18
+
19
+ /**
20
+ * Constructor
21
+ *
22
+ * @param Sql\Value $table Table name.
23
+ * @param Sql\Value $table_id Table ID.
24
+ * @param string $alias Count alias.
25
+ */
26
+ public function __construct( Sql\Value $table, Sql\Value $table_id, $alias = 'match_rows' ) {
27
+ $this->column = 'COUNT(' . $table->get_value() . '.' . $table_id->get_value() . ") AS $alias";
28
+ }
29
+
30
+ public function get_select( array $select, array $joins ) {
31
+ return [ $this->column ];
32
+ }
33
+
34
+ public function get_group( array $group, array $joins ) {
35
+ return [];
36
+ }
37
+ }
includes/sql/modifier/class-modifier.php ADDED
@@ -0,0 +1,144 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Sql\Modifier;
4
+
5
+ require_once __DIR__ . '/class-count.php';
6
+
7
+ /**
8
+ * Modifies an SQL query
9
+ */
10
+ class Modifier {
11
+ /**
12
+ * Get the SQL for an array of queries
13
+ *
14
+ * @param array $queries Queries.
15
+ * @return array
16
+ */
17
+ protected function get_queries( array $queries ) {
18
+ $queries = array_filter(
19
+ array_map(
20
+ function( $query ) {
21
+ if ( $query ) {
22
+ return $query->get_as_sql();
23
+ }
24
+
25
+ return false;
26
+ },
27
+ $queries
28
+ )
29
+ );
30
+
31
+ return array_values( $queries );
32
+ }
33
+
34
+ /**
35
+ * Get the JOIN for the columns
36
+ *
37
+ * @param array $joins SQL joins.
38
+ * @param string $column Column name.
39
+ * @return array
40
+ */
41
+ protected function get_joins( array $joins, $column ) {
42
+ return $this->get_queries(
43
+ array_map(
44
+ function( $join ) use ( $column ) {
45
+ return $join->$column();
46
+ },
47
+ $joins
48
+ )
49
+ );
50
+ }
51
+
52
+ /**
53
+ * Remove any joined column from the select list
54
+ *
55
+ * @param array $items Items.
56
+ * @param array $joins Joins.
57
+ * @return array
58
+ */
59
+ protected function remove_join_columns( array $items, array $joins ) {
60
+ return array_filter( $items, function( $item ) use ( $joins ) {
61
+ foreach ( $joins as $join ) {
62
+ if ( $item->is_column_match( $join->get_column() ) ) {
63
+ return false;
64
+ }
65
+ }
66
+
67
+ return true;
68
+ } );
69
+ }
70
+
71
+ /**
72
+ * Update column name of any joined column
73
+ *
74
+ * @param array $items Items.
75
+ * @param array $joins Joins.
76
+ * @return array
77
+ */
78
+ protected function replace_join_columns( array $items, array $joins ) {
79
+ foreach ( $joins as $join ) {
80
+ foreach ( $items as $item ) {
81
+ $item->update_column( $join->get_column(), $join->get_join_column() );
82
+ }
83
+ }
84
+
85
+ return $items;
86
+ }
87
+
88
+ /**
89
+ * Get modified selects
90
+ *
91
+ * @param array $select Select items.
92
+ * @param array $joins Joins.
93
+ * @return array
94
+ */
95
+ public function get_select( array $select, array $joins ) {
96
+ $selects = $this->remove_join_columns( $select, $joins );
97
+ $join_selects = $this->get_joins( $joins, 'get_select' );
98
+
99
+ if ( count( $join_selects ) > 0 ) {
100
+ // With a join we need to prefix all columns with the table name to avoid SQL ambiquity
101
+ array_walk( $selects, function( $item ) {
102
+ $item->set_prefix_required();
103
+ } );
104
+ }
105
+
106
+ return array_merge( $this->get_queries( $selects ), $join_selects );
107
+ }
108
+
109
+ /**
110
+ * Get modified WHERE
111
+ *
112
+ * @param array $where Where items.
113
+ * @param array $joins Joins.
114
+ * @return array
115
+ */
116
+ public function get_where( array $where, array $joins ) {
117
+ $where_columns = $this->replace_join_columns( $where, $joins );
118
+ $queries = $this->get_queries( $where_columns );
119
+
120
+ return $queries;
121
+ }
122
+
123
+ /**
124
+ * Get modified FROM
125
+ *
126
+ * @param array $from From items.
127
+ * @param array $joins Joins.
128
+ * @return array
129
+ */
130
+ public function get_from( array $from, array $joins ) {
131
+ return array_merge( $this->get_queries( $from ), $this->get_joins( $joins, 'get_from' ) );
132
+ }
133
+
134
+ /**
135
+ * Get modified GROUP
136
+ *
137
+ * @param array $group Group items.
138
+ * @param array $joins Joins.
139
+ * @return array
140
+ */
141
+ public function get_group( array $group, array $joins ) {
142
+ return array_merge( $this->get_queries( $group ), $this->get_joins( $joins, 'get_group' ) );
143
+ }
144
+ }
includes/sql/select/class-column.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Sql\Select;
4
+
5
+ use SearchRegex\Schema;
6
+ use SearchRegex\Sql;
7
+
8
+ /**
9
+ * SQL SELECT for a Schema\Column
10
+ */
11
+ class Select_Column extends Select {
12
+ public function __construct( Schema\Column $column, Sql\Value $alias = null ) {
13
+ parent::__construct( Sql\Value::table( $column->get_table() ), Sql\Value::column( $column->get_column() ), $alias );
14
+ }
15
+ }
includes/sql/select/class-select.php ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Sql\Select;
4
+
5
+ use SearchRegex\Sql;
6
+
7
+ require_once __DIR__ . '/class-column.php';
8
+ require_once __DIR__ . '/class-sum.php';
9
+
10
+ /**
11
+ * SQL SELECT
12
+ */
13
+ class Select {
14
+ /**
15
+ * Column name
16
+ *
17
+ * @var string
18
+ */
19
+ protected $column;
20
+
21
+ /**
22
+ * Column alias
23
+ *
24
+ * @readonly
25
+ * @var string|null
26
+ */
27
+ protected $alias = null;
28
+
29
+ /**
30
+ * Table name
31
+ *
32
+ * @var string
33
+ */
34
+ protected $table;
35
+
36
+ /**
37
+ * SQL prefix
38
+ *
39
+ * @var boolean
40
+ */
41
+ protected $prefix_sql = false;
42
+
43
+ /**
44
+ * Constructor
45
+ *
46
+ * @param Sql\Value $table Table name.
47
+ * @param Sql\Value $column Column name.
48
+ * @param Sql\Value|null $alias Table alias.
49
+ * @param boolean $prefix_required Whether we need to prefix the SQL with the table name.
50
+ */
51
+ public function __construct( Sql\Value $table, Sql\Value $column, Sql\Value $alias = null, $prefix_required = false ) {
52
+ $this->table = $table->get_value();
53
+ $this->column = $column->get_value();
54
+ $this->alias = $alias ? $alias->get_value() : null;
55
+ $this->prefix_sql = $prefix_required;
56
+ }
57
+
58
+ /**
59
+ * Get as SQL
60
+ *
61
+ * @return string
62
+ */
63
+ public function get_as_sql() {
64
+ $sql = $this->column;
65
+
66
+ if ( $this->prefix_sql && $this->table ) {
67
+ $sql = $this->table . '.' . $sql;
68
+ }
69
+
70
+ if ( $this->alias && $this->alias !== $this->column ) {
71
+ $sql .= ' AS ' . $this->alias;
72
+ }
73
+
74
+ return $sql;
75
+ }
76
+
77
+ /**
78
+ * Get the column or aliased column
79
+ *
80
+ * @return string
81
+ */
82
+ public function get_column_or_alias() {
83
+ if ( $this->alias ) {
84
+ return $this->alias . '.' . $this->column;
85
+ }
86
+
87
+ if ( $this->table ) {
88
+ return $this->table . '.' . $this->column;
89
+ }
90
+
91
+ return $this->column;
92
+ }
93
+
94
+ /**
95
+ * Update the column
96
+ *
97
+ * @param string $column Column.
98
+ * @param string $updated_column Updated column.
99
+ * @return void
100
+ */
101
+ public function update_column( $column, $updated_column ) {
102
+ if ( $this->is_column_match( $column ) ) {
103
+ $this->column = $updated_column;
104
+ $this->table = '';
105
+ }
106
+ }
107
+
108
+ /**
109
+ * Does this match the column?
110
+ *
111
+ * @param string $column Column to match.
112
+ * @return boolean
113
+ */
114
+ public function is_column_match( $column ) {
115
+ return $this->column === $column;
116
+ }
117
+
118
+ /**
119
+ * Mark that we need the column to be prefixed with table name
120
+ *
121
+ * @return void
122
+ */
123
+ public function set_prefix_required() {
124
+ $this->prefix_sql = true;
125
+ }
126
+ }
includes/sql/select/class-sum.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Sql\Select;
4
+
5
+ use SearchRegex\Schema;
6
+
7
+ /**
8
+ * @psalm-suppress all
9
+ */
10
+ class Select_Phrases extends Select_Column {
11
+ /**
12
+ * Values
13
+ *
14
+ * @var array
15
+ */
16
+ private $values = [];
17
+
18
+ public function __construct( Schema\Column $column, Sql\Value $alias = null ) {
19
+ parent::__construct( $column, Sql\Value::column( 'match_total' ) );
20
+
21
+ if ( $alias !== null ) {
22
+ // Not sanitized until later
23
+ $this->values = [
24
+ [
25
+ 'column' => $column->get_column(),
26
+ 'value' => $alias->get_value(),
27
+ ],
28
+ ];
29
+ }
30
+ }
31
+
32
+ public function get_as_sql() {
33
+ return '';
34
+ }
35
+
36
+ /**
37
+ * Add
38
+ *
39
+ * @param Select_Phrases $phrase Phrase.
40
+ * @return void
41
+ */
42
+ public function add_sum( Select_Phrases $phrase ) {
43
+ $this->values = array_merge( $this->values, $phrase->values );
44
+ }
45
+
46
+ /**
47
+ * Get SELECT
48
+ *
49
+ * @return string
50
+ */
51
+ public function get_select_sql() {
52
+ global $wpdb;
53
+
54
+ $sum = [];
55
+
56
+ foreach ( $this->values as $item ) {
57
+ $column = $item['column'];
58
+ $value = $item['value'];
59
+ $cropped = mb_substr( $value, 0, mb_strlen( $value, 'UTF-8' ) - 1, 'UTF-8' );
60
+
61
+ // phpcs:ignore
62
+ $sum[] = $wpdb->prepare( "SUM(CHAR_LENGTH($column) - CHAR_LENGTH(REPLACE(UPPER($column), UPPER(%s), UPPER(%s))))", $value, $cropped );
63
+ }
64
+
65
+ return implode( ' + ', $sum ) . ( $this->alias ? ' as ' . $this->alias : '' );
66
+ }
67
+ }
includes/sql/where/class-where.php ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Sql\Where;
4
+
5
+ use SearchRegex\Sql;
6
+
7
+ require_once __DIR__ . '/where-or.php';
8
+ require_once __DIR__ . '/where-and.php';
9
+ require_once __DIR__ . '/where-integer.php';
10
+ require_once __DIR__ . '/where-string.php';
11
+ require_once __DIR__ . '/where-date.php';
12
+ require_once __DIR__ . '/where-in.php';
13
+ require_once __DIR__ . '/where-null.php';
14
+
15
+ /**
16
+ * SQL WHERE
17
+ */
18
+ class Where {
19
+ /**
20
+ * Column
21
+ *
22
+ * @readonly
23
+ * @var Sql\Select\Select|null
24
+ */
25
+ protected $column = null;
26
+
27
+ /**
28
+ * WHERE logic
29
+ *
30
+ * @readonly
31
+ * @var string
32
+ */
33
+ protected $logic = '=';
34
+
35
+ /**
36
+ * WHERE value
37
+ *
38
+ * @readonly
39
+ * @var string|integer|array
40
+ */
41
+ protected $value = '';
42
+
43
+ /**
44
+ * Constructor
45
+ *
46
+ * @param Sql\Select\Select $column Column.
47
+ * @param string $logic Logic.
48
+ * @param string|integer|array $value Value.
49
+ */
50
+ protected function __construct( Sql\Select\Select $column, $logic, $value = '' ) {
51
+ $this->column = $column;
52
+ $this->value = $value; // Sanitized in get_value
53
+ $this->logic = $logic;
54
+ }
55
+
56
+ /**
57
+ * Get as SQL
58
+ *
59
+ * @return string
60
+ */
61
+ public function get_as_sql() {
62
+ if ( $this->column !== null ) {
63
+ return $this->column->get_column_or_alias() . ' ' . $this->logic . ' ' . $this->get_value();
64
+ }
65
+
66
+ return '';
67
+ }
68
+
69
+ /**
70
+ * Change the column
71
+ *
72
+ * @param string $column Column.
73
+ * @param string $updated_column New column.
74
+ * @return void
75
+ */
76
+ public function update_column( $column, $updated_column ) {
77
+ if ( $this->column !== null ) {
78
+ $this->column->update_column( $column, $updated_column );
79
+ }
80
+ }
81
+
82
+ /**
83
+ * Get the WHERE value
84
+ *
85
+ * @return string
86
+ */
87
+ public function get_value() {
88
+ global $wpdb;
89
+
90
+ return $wpdb->prepare( '%s', $this->value );
91
+ }
92
+ }
includes/sql/where/where-and.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Sql\Where;
4
+
5
+ use SearchRegex\Sql;
6
+
7
+ /**
8
+ * AND a group of WHERE statements together
9
+ */
10
+ class Where_And extends Where_Or {
11
+ public function get_as_sql() {
12
+ return $this->get_group( 'AND' );
13
+ }
14
+ }
includes/sql/where/where-date.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Sql\Where;
4
+
5
+ use SearchRegex\Sql;
6
+
7
+ /**
8
+ * WHERE for a date
9
+ */
10
+ class Where_Date extends Where {
11
+ /**
12
+ * Constructor
13
+ *
14
+ * @param Sql\Select\Select $column Column.
15
+ * @param string $logic Logic.
16
+ * @param integer $value Value.
17
+ */
18
+ public function __construct( Sql\Select\Select $column, $logic, $value ) {
19
+ $map = [
20
+ 'notequals' => '!=',
21
+ 'greater' => '>',
22
+ 'less' => '<',
23
+ ];
24
+
25
+ $logic_sql = '=';
26
+ if ( isset( $map[ $logic ] ) ) {
27
+ $logic_sql = $map[ $logic ];
28
+ }
29
+
30
+ if ( in_array( $logic, [ '=', '>', '<', '!=', '<=', '>=' ], true ) ) {
31
+ $logic_sql = $logic;
32
+ }
33
+
34
+ $value = date( 'Y-m-d H:i:s', intval( $value, 10 ) );
35
+
36
+ parent::__construct( $column, $logic_sql, $value );
37
+ }
38
+
39
+ public function get_value() {
40
+ global $wpdb;
41
+
42
+ return $wpdb->prepare( '%s', $this->value );
43
+ }
44
+ }
includes/sql/where/where-in.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Sql\Where;
4
+
5
+ use SearchRegex\Sql;
6
+
7
+ /**
8
+ * WHERE for a IN
9
+ */
10
+ class Where_In extends Where {
11
+ /**
12
+ * Constructor
13
+ *
14
+ * @param Sql\Select\Select $column Column.
15
+ * @param string $logic Logic.
16
+ * @param array $value Value.
17
+ */
18
+ public function __construct( Sql\Select\Select $column, $logic, $value ) {
19
+ $logic_sql = 'IN';
20
+
21
+ if ( $logic === 'NOT IN' ) {
22
+ $logic_sql = 'NOT IN';
23
+ }
24
+
25
+ parent::__construct( $column, $logic_sql, $value );
26
+ }
27
+
28
+ public function get_value() {
29
+ global $wpdb;
30
+
31
+ if ( ! is_array( $this->value ) ) {
32
+ return '';
33
+ }
34
+
35
+ $values = array_map( function( $item ) use ( $wpdb ) {
36
+ if ( is_numeric( $item ) ) {
37
+ return $wpdb->prepare( '%d', $item );
38
+ }
39
+
40
+ return $wpdb->prepare( '%s', $item );
41
+ }, $this->value );
42
+
43
+ return '(' . implode( ', ', $values ) . ')';
44
+ }
45
+ }
includes/sql/where/where-integer.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Sql\Where;
4
+
5
+ use SearchRegex\Sql;
6
+
7
+ /**
8
+ * WHERE for an integer
9
+ */
10
+ class Where_Integer extends Where {
11
+ /**
12
+ * Constructor
13
+ *
14
+ * @param Sql\Select\Select $column Column.
15
+ * @param string $logic Logic.
16
+ * @param integer $value Value.
17
+ */
18
+ public function __construct( Sql\Select\Select $column, $logic, $value ) {
19
+ $map = [
20
+ 'notequals' => '!=',
21
+ 'greater' => '>',
22
+ 'less' => '<',
23
+ ];
24
+
25
+ $logic_sql = '=';
26
+ if ( isset( $map[ $logic ] ) ) {
27
+ $logic_sql = $map[ $logic ];
28
+ }
29
+
30
+ if ( in_array( $logic, [ '=', '>', '<', '!=', '<=', '>=' ], true ) ) {
31
+ $logic_sql = $logic;
32
+ }
33
+
34
+ parent::__construct( $column, $logic_sql, intval( $value, 10 ) );
35
+ }
36
+
37
+ public function get_value() {
38
+ global $wpdb;
39
+
40
+ return $wpdb->prepare( '%d', $this->value );
41
+ }
42
+ }
includes/sql/where/where-null.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Sql\Where;
4
+
5
+ use SearchRegex\Sql;
6
+
7
+ /**
8
+ * WHERE for a null value
9
+ */
10
+ class Where_Null extends Where {
11
+ /**
12
+ * Constructor
13
+ *
14
+ * @param Sql\Select\Select $column Column.
15
+ * @param string $logic Logic.
16
+ */
17
+ public function __construct( Sql\Select\Select $column, $logic ) {
18
+ $logic_sql = 'IS';
19
+ if ( $logic === 'has' ) {
20
+ $logic_sql = 'IS NOT';
21
+ }
22
+
23
+ parent::__construct( $column, $logic_sql, 'NULL' );
24
+ }
25
+
26
+ public function get_value() {
27
+ return 'NULL';
28
+ }
29
+ }
includes/sql/where/where-or.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Sql\Where;
4
+
5
+ use SearchRegex\Sql;
6
+
7
+ class Where_Or extends Where {
8
+ /**
9
+ * Array of WHERE objects that will be ORd together
10
+ *
11
+ * @readonly
12
+ * @var array<Where>
13
+ */
14
+ protected $wheres = [];
15
+
16
+ /**
17
+ * Constructor
18
+ *
19
+ * @param array<Where> $wheres Wheres.
20
+ */
21
+ public function __construct( array $wheres ) {
22
+ $this->wheres = $wheres;
23
+ }
24
+
25
+ /**
26
+ * Get the WHEREs as a group
27
+ *
28
+ * @param string $logic Logic.
29
+ * @return string
30
+ */
31
+ protected function get_group( $logic ) {
32
+ $start = '';
33
+ $end = '';
34
+
35
+ if ( count( $this->wheres ) > 1 ) {
36
+ $start = '(';
37
+ $end = ')';
38
+ }
39
+
40
+ $sql = array_map( function( $where ) {
41
+ return $where->get_as_sql();
42
+ }, $this->wheres );
43
+
44
+ return $start . implode( ' ' . $logic . ' ', $sql ) . $end;
45
+ }
46
+
47
+ public function get_as_sql() {
48
+ return $this->get_group( 'OR' );
49
+ }
50
+
51
+ public function update_column( $column, $updated_column ) {
52
+ foreach ( $this->wheres as $where ) {
53
+ $where->update_column( $column, $updated_column );
54
+ }
55
+ }
56
+ }
includes/sql/where/where-string.php ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace SearchRegex\Sql\Where;
4
+
5
+ use SearchRegex\Search;
6
+ use SearchRegex\Sql;
7
+
8
+ /**
9
+ * WHERE for a string
10
+ */
11
+ class Where_String extends Where {
12
+ /**
13
+ * Prefix for the value
14
+ *
15
+ * @readonly
16
+ * @var string
17
+ */
18
+ private $before = '';
19
+
20
+ /**
21
+ * Postfix for the value
22
+ *
23
+ * @readonly
24
+ * @var string
25
+ */
26
+ private $after = '';
27
+
28
+ /**
29
+ * Constructor
30
+ *
31
+ * @param Sql\Select\Select $column Column.
32
+ * @param string $logic Logic.
33
+ * @param string $value Value.
34
+ * @param Se