json-edit-react 1.23.1 → 1.25.0-beta1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,3 +1,6 @@
1
+ <!-- This README was converted from GitHub-flavored Markdown to npm format. -->
2
+ <!-- Some elements may display differently on npmjs.com vs. GitHub. -->
3
+
1
4
  # json-edit-react
2
5
 
3
6
  <img width="60" alt="screenshot" src="image/logo192.png" style="float:left; margin-right: 1em;">
@@ -13,28 +16,29 @@ A [React](https://github.com/facebook/react) component for editing or viewing JS
13
16
 
14
17
  ### Features include:
15
18
 
16
- - edit individual values, or whole objects as JSON text
17
- - fine-grained control over which elements can be edited, deleted, or added to
18
- - full [JSON Schema](https://json-schema.org/) validation (using 3rd-party validation library)
19
- - customisable UI, through simple, pre-defined [themes](#themes--styles), specific CSS overrides for UI components, or by targeting CSS classes
20
- - self-contained — rendered with plain HTML/CSS, so no dependence on external UI libraries
21
- - search/filter data by key, value or custom function
22
- - provide your own [custom component](#custom-nodes) to integrate specialised UI for certain data.
23
- - [localisable](#localisation) UI
24
- - [Drag-n-drop](#drag-n-drop) editing
25
- - [Keyboard customisation](#keyboard-customisation)
19
+ - ✅ **Easy inline editing** of individual values or whole blocks of JSON text
20
+ - 🔒 **Granular control** – restrict edits, deletions, or additions per element
21
+ - 📏 **[JSON Schema](https://json-schema.org/) validation** (using 3rd-party validation library)
22
+ - 🎨 **Customisable UI** — built-in or custom [themes](#themes--styles), CSS overrides or targeted classes
23
+ - 📦 **Self-contained** — plain HTML/CSS, so no dependence on external UI libraries
24
+ - 🔍 **Search & filter** — find data by key, value or custom function
25
+ - 🚧 **[Custom components](#custom-nodes)** — replace specific nodes with specialised components (e.g. date picker, links, images)
26
+ - 🌏 **[Localisation](#localisation)** — easily translate UI labels and messages
27
+ - 🔄 **[Drag-n-drop](#drag-n-drop)** re-ordering within objects/arrays
28
+ - 🎹 **[Keyboard customisation](#keyboard-customisation)** — define your own key bindings
29
+ - 🎮 **[External control](#external-control-1)** via callbacks and triggers
30
+
31
+ 💡 Try the **[Live Demo](https://carlosnz.github.io/json-edit-react/)** to see these features in action!
26
32
 
27
33
  <img width="392" alt="screenshot" src="image/screenshot.png">
28
34
 
29
- > [!IMPORTANT]
30
- > Breaking changes:
31
- > - **Version 1.19.0** has a change to the `theme` input. Built-in themes must now
32
- > be imported separately and passed in, rather than just naming the theme as a
33
- > string. This is better for tree-shaking, so unused themes won't be bundled
34
- > with your build. See [Themes & Styles](#themes--styles)
35
- > - **Version 1.14.0** has a change which recommends you provide a `setData` prop
36
- > and not use `onUpdate` for updating your data externally. See [Managing
37
- > state](#managing-state).
35
+ <div style="padding: 8px; border-left: 4px solid #888; background-color: #f8f8f8; margin: 10px 0;">
36
+ ❗ **Important**
37
+
38
+ Breaking changes:
39
+ - **Version 1.19.0** has a change to the `theme` input. Built-in themes must now be imported separately and passed in, rather than just naming the theme as a string. This is better for tree-shaking, so unused themes won't be bundled with your build. See [Themes & Styles](#themes--styles).
40
+ - **Version 1.14.0** has a change which recommends you provide a `setData` prop and not use `onUpdate` for updating your data externally. See [Managing state](#managing-state).
41
+ </div>
38
42
 
39
43
  ## Contents <!-- omit in toc -->
40
44
  - [Installation](#installation)
@@ -46,6 +50,7 @@ A [React](https://github.com/facebook/react) component for editing or viewing JS
46
50
  - [Look and Feel / UI](#look-and-feel--ui)
47
51
  - [Search and Filtering](#search-and-filtering)
48
52
  - [Custom components \& overrides (incl. Localisation)](#custom-components--overrides-incl-localisation)
53
+ - [External control](#external-control)
49
54
  - [Miscellaneous](#miscellaneous)
50
55
  - [Managing state](#managing-state)
51
56
  - [Update functions](#update-functions)
@@ -70,6 +75,9 @@ A [React](https://github.com/facebook/react) component for editing or viewing JS
70
75
  - [Custom Text](#custom-text)
71
76
  - [Custom Buttons](#custom-buttons)
72
77
  - [Keyboard customisation](#keyboard-customisation)
78
+ - [External control](#external-control-1)
79
+ - [Event callbacks](#event-callbacks)
80
+ - [Event triggers](#event-triggers)
73
81
  - [Undo functionality](#undo-functionality)
74
82
  - [Exported helpers](#exported-helpers)
75
83
  - [Functions \& Components](#functions--components)
@@ -81,11 +89,13 @@ A [React](https://github.com/facebook/react) component for editing or viewing JS
81
89
 
82
90
  ## Installation
83
91
 
84
- `npm i json-edit-react`
92
+ ```sh
93
+ # Depending on your package manager:
85
94
 
86
- or
87
-
88
- `yarn add json-edit-react`
95
+ npm i json-edit-react
96
+ # OR
97
+ yarn add json-edit-react
98
+ ```
89
99
 
90
100
  ## Implementation
91
101
 
@@ -93,11 +103,12 @@ or
93
103
  import { JsonEditor } from 'json-edit-react'
94
104
 
95
105
  // In your React component:
96
- return
106
+ return (
97
107
  <JsonEditor
98
108
  data={ jsonData }
99
109
  setData={ setJsonData } // optional
100
110
  { ...otherProps } />
111
+ );
101
112
  ```
102
113
 
103
114
  ## Usage
@@ -153,25 +164,26 @@ The only *required* property is `data` (although you will need to provide a `set
153
164
 
154
165
  ### Look and Feel / UI
155
166
 
156
- | Prop | Type | Default | Description |
157
- | ----------------------- | --------------------------------- | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
158
- | `theme` | `ThemeInput` | `default` | Either one of the built-in themes (imported separately), or an object specifying some or all theme properties — see [Themes](#themes--styles). |
159
- | `icons` | `{[iconName]: JSX.Element, ... }` | `{ }` | Replace the built-in icons by specifying them here — see [Themes](#themes--styles). | |
160
- | `indent` | `number` | `3` | Specify the amount of indentation for each level of nesting in the displayed data. |
161
- | `collapse` | `boolean\|number\|FilterFunction` | `false` | Defines which nodes of the JSON tree will be displayed "opened" in the UI on load. If `boolean`, it'll be either all or none. A `number` specifies a nesting depth after which nodes will be closed. For more fine control a function can be provided — see [Filter functions](#filter-functions). |
162
- | `collapseAnimationTime` | `number` | `300` | Time (in milliseconds) for the transition animation when collapsing collection nodes. |
163
- | `rootName` | `string` | `"data"` | A name to display in the editor as the root of the data object. |
164
- | `showArrayIndices` | `boolean` | `true` | Whether or not to display the index (as a property key) for array elements. |
165
- | `showStringQuotes` | `boolean` | `true` | Whether or not to display string values in "quotes". |
166
- | `showCollectionCount` | `boolean\|"when-closed"` | `true` | Whether or not to display the number of items in each collection (object or array). |
167
- | `stringTruncate` | `number` | `250` | String values longer than this many characters will be displayed truncated (with `...`). The full string will always be visible when editing. |
168
- | `keySort` | `boolean\|CompareFunction` | `false` | If `true`, object keys will be ordered (using default JS `.sort()`). A [compare function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort) can also be provided to define sorting behaviour, except the input type should be a tuple of the key and the value of a node i.e. `(a: [string \| number, ValueData], b: [string \| number, ValueData]) => number` |
169
- | `minWidth` | `number\|string` (CSS value) | `250` | Minimum width for the editor container. |
170
- | `maxWidth` | `number\|string` (CSS value) | `600` | Maximum width for the editor container. |
171
- | `rootFontSize` | `number\|string` (CSS value) | `16px` | The "base" font size from which all other sizings are derived (in `em`s). By changing this you will scale the entire component container. |
172
- | `insertAtTop` | `boolean\| "object \| "array"` | `false` | If `true`, inserts new values at the *top* rather than bottom. Can set the behaviour just for arrays or objects by setting to `"object"` or `"array"` respectively. | |
173
- | `errorMessageTimeout` | `number` | `2500` | Time (in milliseconds) to display the error message in the UI. | |
174
- | `showErrorMessages` | `boolean ` | `true` | Whether or not the component should display its own error messages (you'd probably only want to disable this if you provided your own `onError` function) |
167
+ | Prop | Type | Default | Description |
168
+ | ----------------------- | ----------------------------------------- | -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
169
+ | `theme` | `ThemeInput` | `default` | Either one of the built-in themes (imported separately), or an object specifying some or all theme properties — see [Themes](#themes--styles). |
170
+ | `icons` | `{[iconName]: JSX.Element, ... }` | `{ }` | Replace the built-in icons by specifying them here — see [Themes](#themes--styles). | |
171
+ | `indent` | `number` | `3` | Specify the amount of indentation for each level of nesting in the displayed data. |
172
+ | `collapse` | `boolean\|number\|FilterFunction` | `false` | Defines which nodes of the JSON tree will be displayed "opened" in the UI on load. If `boolean`, it'll be either all or none. A `number` specifies a nesting depth after which nodes will be closed. For more fine control a function can be provided — see [Filter functions](#filter-functions). |
173
+ | `collapseAnimationTime` | `number` | `300` | Time (in milliseconds) for the transition animation when collapsing collection nodes. |
174
+ | `collapseClickZones` | `Array<"left" \| "header" \| "property">` | `["left", "header"]` | Aside from the <span style="font-size: 140%">`⌄`</span> icon, you can specify other regions of the UI to be clickable for collapsing/opening a collection. |
175
+ | `rootName` | `string` | `"data"` | A name to display in the editor as the root of the data object. |
176
+ | `showArrayIndices` | `boolean` | `true` | Whether or not to display the index (as a property key) for array elements. |
177
+ | `showStringQuotes` | `boolean` | `true` | Whether or not to display string values in "quotes". |
178
+ | `showCollectionCount` | `boolean\|"when-closed"` | `true` | Whether or not to display the number of items in each collection (object or array). |
179
+ | `stringTruncate` | `number` | `250` | String values longer than this many characters will be displayed truncated (with `...`). The full string will always be visible when editing. |
180
+ | `keySort` | `boolean\|CompareFunction` | `false` | If `true`, object keys will be ordered (using default JS `.sort()`). A [compare function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort) can also be provided to define sorting behaviour, except the input type should be a tuple of the key and the value of a node i.e. `(a: [string \| number, ValueData], b: [string \| number, ValueData]) => number` |
181
+ | `minWidth` | `number\|string` (CSS value) | `250` | Minimum width for the editor container. |
182
+ | `maxWidth` | `number\|string` (CSS value) | `600` | Maximum width for the editor container. |
183
+ | `rootFontSize` | `number\|string` (CSS value) | `16px` | The "base" font size from which all other sizings are derived (in `em`s). By changing this you will scale the entire component container. |
184
+ | `insertAtTop` | `boolean\| "object \| "array"` | `false` | If `true`, inserts new values at the *top* rather than bottom. Can set the behaviour just for arrays or objects by setting to `"object"` or `"array"` respectively. | |
185
+ | `errorMessageTimeout` | `number` | `2500` | Time (in milliseconds) to display the error message in the UI. | |
186
+ | `showErrorMessages` | `boolean ` | `true` | Whether or not the component should display its own error messages (you'd probably only want to disable this if you provided your own `onError` function) |
175
187
 
176
188
 
177
189
  ### Search and Filtering
@@ -194,7 +206,16 @@ The only *required* property is `data` (although you will need to provide a `set
194
206
  | `TextEditor` | `ReactComponent<TextEditorProps>` | | Pass a component to offer a custom text/code editor when editing full JSON object as text. [See details](#full-object-editing) |
195
207
  | `jsonParse` | `(input: string) => JsonData` | `JSON.parse` | When editing a block of JSON directly, you may wish to allow some "looser" input -- e.g. 'single quotes', trailing commas, or unquoted field names. In this case, you can provide a third-party JSON parsing method. I recommend [JSON5](https://json5.org/), which is what is used in the [Demo](https://carlosnz.github.io/json-edit-react/) |
196
208
  | `jsonStringify` | `(data: JsonData) => string` | `(data) => JSON.stringify(data, null, 2)` | Similarly, you can override the default presentation of the JSON string when starting editing JSON. You can supply different formatting parameters to the native `JSON.stringify()`, or provide a third-party option, like the aforementioned JSON5. |
197
- | `keyboardControls` | `KeyboardControls` | As explained [above](#usage) | Override some or all of the keyboard controls. See [Keyboard customisation](#keyboard-customisation) for details. | |
209
+ | `keyboardControls` | `KeyboardControls` | As explained [above](#usage) | Override some or all of the keyboard controls. See [Keyboard customisation](#keyboard-customisation) for details. |
210
+ ### External control
211
+
212
+ More detail [below](#external-control-1)
213
+
214
+ | Prop | Type | Default | Description |
215
+ | ------------------ | --------------------- | ------- | -------------------------------------------------------------------- |
216
+ | `onEditEvent` | `OnEditEventFunction` | none | Callback to execute whenever the user starts or stops editing a node |
217
+ | `onCollapse` | `OnCollapseFunction` | none | Callback to execute whenever the user collapses or opens a node |
218
+ | `externalTriggers` | `ExternalTriggers` | none | Specify a node to collapse/open, or to start/stop editing | |
198
219
 
199
220
  ### Miscellaneous
200
221
 
@@ -662,7 +683,9 @@ Custom nodes are provided in the `customNodeDefinitions` prop, as an array of ob
662
683
  showOnView // boolean, default true
663
684
  showEditTools // boolean, default true
664
685
  name // string (appears in Types selector)
665
- showInTypesSelector, // boolean (optional), default false
686
+ showInTypesSelector // boolean (optional), default false
687
+ passOriginalNode // boolean (optional), default false -- if `true` makes the original node
688
+ // for rendering within Custom Node
666
689
 
667
690
  // Only affects Collection nodes:
668
691
  showCollectionWrapper // boolean (optional), default true
@@ -673,7 +696,7 @@ Custom nodes are provided in the `customNodeDefinitions` prop, as an array of ob
673
696
 
674
697
  The `condition` is just a [Filter function](#filter-functions), with the same input parameters (`key`, `path`, `value`, etc.), and `element` is a React component. Every node in the data structure will be run through each condition function, and any that match will be replaced by your custom component. Note that if a node matches more than one custom definition conditions (from multiple components), the *first* one will be used, so place them in the array in priority order.
675
698
 
676
- The component will receive *all* the same props as a standard node component plus some additional ones — see [BaseNodeProps](https://github.com/CarlosNZ/json-edit-react/blob/b085f6391dabf574809f1040b11401c13344923d/src/types.ts#L219-L265) (common to all nodes) and [CustomNodeProps](https://github.com/CarlosNZ/json-edit-react/blob/b085f6391dabf574809f1040b11401c13344923d/src/types.ts#L275-L287) type definitions. Specifically, if you want to update the data structure from your custom node, you'll need to call the `setValue` method on your node's data value.
699
+ The component will receive *all* the same props as a standard node component plus some additional ones — see [BaseNodeProps](https://github.com/CarlosNZ/json-edit-react/blob/b085f6391dabf574809f1040b11401c13344923d/src/types.ts#L219-L265) (common to all nodes) and [CustomNodeProps](https://github.com/CarlosNZ/json-edit-react/blob/b085f6391dabf574809f1040b11401c13344923d/src/types.ts#L275-L287) type definitions. Specifically, if you want to update the data structure from your custom node, you'll need to call the `setValue` method on your node's data value. And if you enable `passOriginalNode` above, you'll also have access to `originalNode` and `originalNodeKey` in order to render the standard content (i.e. what would have been rendered if it wasn't intercepted by this Custom Node) -- this can be helpful if you want your Custom Node to just be the default content with a little extra decoration. (*Note:* you may need a little custom CSS to render these original node components identically to the default display.)
677
700
 
678
701
  You can pass additional props specific to your component, if required, through the `customNodeProps` object. A thorough example of a custom **Date Picker** is used in the demo (along with a couple of other more basic presentational ones), which you can inspect to see how to utilise the standard props and a couple of custom props. View the source code [here](https://github.com/CarlosNZ/json-edit-react/blob/main/demo/src/customComponents/DateTimePicker.tsx).
679
702
 
@@ -795,7 +818,74 @@ If (for example), you just wish to change the general "confirmation" action to "
795
818
  - If multiple modifiers are specified (in an array), *any* of them will be accepted (multi-modifier commands not currently supported)
796
819
  - You only need to specify values for `stringConfirm`, `numberConfirm`, and `booleanConfirm` if they should *differ* from your `confirm` value.
797
820
  - You won't be able to override system or browser behaviours: for example, on Mac "Ctrl-click" will perform a right-click, so using it as a click modifier won't work (hence we also accept "Meta"/"Cmd" as the default `clipboardModifier`).
798
-
821
+
822
+ ## External control
823
+
824
+ You can interact with the component externally, with event callbacks and triggers to set/get the collapse or editing state of any node.
825
+
826
+ ### Event callbacks
827
+
828
+ Pass in a function to the props `onEditEvent` and `onCollapse` if you want your app to be able to respond to these events.
829
+
830
+ The `onEditEvent` callback is executed whenever the user starts or stops editing a node, and has the following signature:
831
+
832
+ ```ts
833
+ type OnEditEventFunction =
834
+ (path: CollectionKey[] | null, isKey: boolean) => void
835
+ ```
836
+
837
+ The `path` will be an array representing the path components when starting to edit, and `null` when ending the edit. The `isKey` indicates whether the edit is for the property `key` rather than `value`.
838
+
839
+ The `onCollapse` callback is executed when user opens or collapses a node, and has the following signature:
840
+
841
+ ```ts
842
+ type OnCollapseFunction = (
843
+ {
844
+ path: CollectionKey[],
845
+ collapsed: boolean, // closing = true, opening = false
846
+ includeChildren: boolean // if was clicked with Modifier key to
847
+ // open/close all descendants as well
848
+ }
849
+ ) => void
850
+ ```
851
+
852
+ ### Event triggers
853
+
854
+ You can *trigger* collapse and editing actions by changing the the `externalTriggers` prop.
855
+
856
+ The shape of the `externalTriggers` object is:
857
+
858
+ ```ts
859
+ interface ExternalTriggers {
860
+ collapse?: CollapseState | CollapseState[]
861
+ edit?: EditState
862
+ }
863
+
864
+ // CollapseState same as `onCollapseFunction` (above) input
865
+ interface CollapseState {
866
+ path: CollectionKey[]
867
+ collapsed: boolean
868
+ includeChildren: boolean
869
+ }
870
+
871
+ interface EditState {
872
+ path?: CollectionKey[]
873
+ action?: 'accept' | 'cancel'
874
+ }
875
+ ```
876
+
877
+ For the `edit` trigger, the `path` is only required when *starting* to edit, and
878
+ the `action` is only required when *stopping* the edit, to determine whether the
879
+ component should cancel or submit the current changes.
880
+
881
+ <div style="padding: 8px; border-left: 4px solid #888; background-color: #f8f8f8; margin: 10px 0;">
882
+ ⚠️ **Warning**
883
+
884
+ Ensure that your `externalTriggers` object is stable (i.e. doesn't create new instances on each render) so as to not cause unwanted triggering -- you may need to wrap it in `useMemo`.
885
+ You should also be careful that your event callbacks and triggers don't cause an infinite loop!
886
+ </div>
887
+
888
+
799
889
  ## Undo functionality
800
890
 
801
891
  Even though Undo/Redo functionality is probably desirable in most cases, this is not built in to the component, for two main reasons:
@@ -823,7 +913,7 @@ A few helper functions, components and types that might be useful in your own im
823
913
  - `ThemeInput`: input type for the `theme` prop
824
914
  - `JsonEditorProps`: all input props for the Json Editor component
825
915
  - `JsonData`: main `data` object -- any valid JSON structure
826
- - [`UpdateFunction`](#update-functions), [`OnChangeFunction`](#onchange-function), [`OnErrorFunction`](#onerror-function) [`FilterFunction`](#filter-functions), [`CopyFunction`](#copy-function), [`SearchFilterFunction`](#searchfiltering), [`CompareFunction`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort),[`TypeFilterFunction`](#filter-functions), [`LocalisedString`](#localisation), [`CustomNodeDefinition`](#custom-nodes), [`CustomTextDefinitions`](#custom-text), [`CustomTextFunction`](#custom-text),
916
+ - [`UpdateFunction`](#update-functions), [`OnChangeFunction`](#onchange-function), [`OnErrorFunction`](#onerror-function) [`FilterFunction`](#filter-functions), [`CopyFunction`](#copy-function), [`SearchFilterFunction`](#searchfiltering), [`OnEditEventFunction`](#event-callbacks), [`OnCollapseFunction`](#event-callbacks), [`CompareFunction`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort),[`TypeFilterFunction`](#filter-functions), [`LocalisedString`](#localisation), [`CustomNodeDefinition`](#custom-nodes), [`CustomTextDefinitions`](#custom-text), [`CustomTextFunction`](#custom-text), [`ExternalTriggers`](#event-triggers)
827
917
  - `TranslateFunction`: function that takes a [localisation](#localisation) key and returns a translated string
828
918
  - `IconReplacements`: input type for the `icons` prop
829
919
  - `CollectionNodeProps`: all props passed internally to "collection" nodes (i.e. objects/arrays)
@@ -850,6 +940,9 @@ This component is heavily inspired by [react-json-view](https://github.com/mac-s
850
940
 
851
941
  ## Changelog
852
942
 
943
+ - **1.24.0**:
944
+ - Option to access (and render) the original node (and its key) within a [Custom Node](#custom-nodes) ([#180](https://github.com/CarlosNZ/json-edit-react/issues/180))
945
+ - Cancelling edit after changing type correctly reverts to previous value ([#122](https://github.com/CarlosNZ/json-edit-react/issues/122))
853
946
  - **1.23.1**: Fix bug where you could collapse a node by clicking inside a "new key" input field [#175](https://github.com/CarlosNZ/json-edit-react/issues/175)
854
947
  - **1.23.0**:
855
948
  - Add `viewOnly` prop as a shorthand for restricting all editing [#168](https://github.com/CarlosNZ/json-edit-react/issues/168)
@@ -1 +1 @@
1
- "use strict";var e=require("react/jsx-runtime"),t=require("react"),n=require("object-property-assigner"),r=require("object-property-extractor");function o(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}function a(e,t,n,r){return new(n||(n=Promise))((function(o,a){function i(e){try{l(r.next(e))}catch(e){a(e)}}function s(e){try{l(r.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,s)}l((r=r.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const i=({className:t,name:n,value:r,setValue:o,handleKeyPress:a,styles:i,textAreaRef:s})=>{if("string"!=typeof r)return null;const l="\n"===r.slice(-1)?r+".":r;return e.jsxs("div",{style:{display:"grid"},children:[e.jsx("textarea",{id:`${n}_textarea`,ref:s,style:Object.assign({height:"auto",gridArea:"1 / 1 / 2 / 2",overflowY:"auto",whiteSpace:"pre-wrap"},i),rows:1,className:t,name:`${n}_textarea`,value:r,onChange:e=>o(e.target.value),autoFocus:!0,onFocus:e=>{r.length<40&&e.target.select()},onKeyDown:a}),e.jsx("span",{className:t,style:Object.assign({visibility:"hidden",height:"auto",gridArea:"1 / 1 / 2 / 2",color:"red",opacity:.9,whiteSpace:"pre-wrap",overflowY:"auto",border:"1px solid transparent"},i),children:l})]})},s=e=>null!==e&&"object"==typeof e,l=(e,t,n,r="")=>{if(!n&&!r)return!0;switch(e){case"collection":if(n){if(n(t,r))return!0;if(!c(r,t,n))return!1}if(!n&&r&&!c(r,t))return!1;break;case"value":if(n&&!n(t,r))return!1;if(!n&&r&&!d(t,r))return!1}return!0},c=(e="",t,n=d)=>{const r=t.value;return Object.entries(r).some((([o,a])=>{const i=[...t.path,o],l=Object.assign(Object.assign({},t),{key:o,path:i,level:t.level+1,value:a,size:i.length,parentData:r});return s(a)?c(e,l,n):n(l,e)}))},d=(e,t="")=>{const{value:n}=e;if(null===n&&"null".includes(t.toLowerCase()))return!0;switch(typeof n){case"string":return n.toLowerCase().includes(t.toLowerCase());case"number":return!!String(n).includes(t);case"boolean":return n?"true".includes(t.toLowerCase())||"1"===t:"false".includes(t.toLowerCase())||"0"===t;default:return!1}},u=({key:e,path:t},n="")=>!!d({value:e},n)||!!t.some((e=>d({value:e},n))),p=(e,t)=>(null!=t?t:"")+e.map((e=>""===e?String.fromCharCode(0):e)).join("."),g=e=>e.shiftKey?"Shift":e.metaKey?"Meta":e.ctrlKey?"Control":e.altKey?"Alt":void 0,m=(e,t,n)=>{const r=e.key,o=g(e);if(Array.isArray(t))return!!o&&t.includes(o);const{key:a,modifier:i}=t;return("stringLineBreak"!==n||"Enter"!==r||"Shift"!==o||"Enter"!==a||!(null==i?void 0:i.includes("Shift")))&&(r===a&&(i===o||Array.isArray(i)&&i.includes(o)))},h={key:"Enter"},y={confirm:h,cancel:{key:"Escape"},objectConfirm:Object.assign(Object.assign({},h),{modifier:["Meta","Shift","Control"]}),objectLineBreak:h,stringConfirm:h,stringLineBreak:Object.assign(Object.assign({},h),{modifier:["Shift"]}),numberConfirm:h,numberUp:{key:"ArrowUp"},numberDown:{key:"ArrowDown"},tabForward:{key:"Tab"},tabBack:{key:"Tab",modifier:"Shift"},booleanConfirm:h,booleanToggle:{key:" "},clipboardModifier:["Meta","Control"],collapseModifier:["Alt"]},b=(e,t,n="next",o)=>{const a=t.slice(0,t.length-1),i=t.slice(-1)[0];if(void 0===i)return null;const l=r(e,a),c=j(l);Array.isArray(l)||o(c,(({key:e,value:t})=>[e,t]));const d=c.findIndex((e=>e.key===i)),u=c[d+("next"===n?1:-1)];return u?s(u.value)?0===Object.keys(u.value).length?b(e,[...a,u.key],n,o):f(e,[...a,u.key],n,o):[...a,u.key]:0===a.length?null:b(e,a,n,o)},f=(e,t,n="next",o)=>{const a=r(e,t);if(!s(a))return t;const i=Array.isArray(a)?a.map(((e,t)=>t)):Object.keys(a);o(i,(e=>[e,a]));const l="next"===n?i[0]:i[i.length-1];return f(e,[...t,l],n,o)},j=e=>Array.isArray(e)?e.map(((e,t)=>({index:t,value:e,key:t}))):Object.entries(e).map((([e,t],n)=>({key:e,value:t,index:n}))),v=(e,t)=>{var n,r,o,a;const i=e.current,s=null!==(n=null==i?void 0:i.selectionStart)&&void 0!==n?n:1/0,l=null!==(r=null==i?void 0:i.selectionEnd)&&void 0!==r?r:1/0,c=(null===(o=null==i?void 0:i.textContent)||void 0===o?void 0:o.slice(0,s))+t+(null===(a=null==i?void 0:i.textContent)||void 0===a?void 0:a.slice(l));return i.value=c,null==i||i.setSelectionRange(s+1,s+1),c},x={displayName:"Default",fragments:{edit:"rgb(42, 161, 152)"},styles:{container:{backgroundColor:"#f6f6f6",fontFamily:"monospace"},collection:{},collectionInner:{},collectionElement:{},dropZone:{},property:"#292929",bracket:{color:"rgb(0, 43, 54)",fontWeight:"bold"},itemCount:{color:"rgba(0, 0, 0, 0.3)",fontStyle:"italic"},string:"rgb(203, 75, 22)",number:"rgb(38, 139, 210)",boolean:"green",null:{color:"rgb(220, 50, 47)",fontVariant:"small-caps",fontWeight:"bold"},input:["#292929"],inputHighlight:"#b3d8ff",error:{fontSize:"0.8em",color:"red",fontWeight:"bold"},iconCollection:"rgb(0, 43, 54)",iconEdit:"edit",iconDelete:"rgb(203, 75, 22)",iconAdd:"edit",iconCopy:"rgb(38, 139, 210)",iconOk:"green",iconCancel:"rgb(203, 75, 22)"}},E=t.createContext({getStyles:()=>({}),icons:{}}),D=({theme:t=x,icons:n={},docRoot:r,children:o})=>{const a=C(t,r);return e.jsx(E.Provider,{value:{getStyles:(e,t)=>"function"==typeof a[e]?a[e](t):a[e],icons:n},children:o})},w=()=>t.useContext(E),C=(e,t)=>{var n,r,o,a;const i={},s=(Array.isArray(e)?e:[e]).map((e=>S(e)?k({fragments:{},styles:e},i):k(e,i))),l=k(x,{});Object.keys(l).forEach((e=>{const t=e;s.forEach((e=>{e[t]&&(l[t]=Object.assign(Object.assign({},l[t]),e[t]))}))}));const c=Object.assign({},l);return Object.entries(i).forEach((([e,t])=>{const n=e;c[n]=e=>{const r=t(e)||{};return Object.assign(Object.assign({},l[n]),r)}})),"function"!=typeof(null==c?void 0:c.inputHighlight)&&(null===(n=null==c?void 0:c.inputHighlight)||void 0===n?void 0:n.backgroundColor)&&t.style.setProperty("--jer-highlight-color",null===(r=null==c?void 0:c.inputHighlight)||void 0===r?void 0:r.backgroundColor),"function"!=typeof(null==c?void 0:c.iconCopy)&&(null===(o=null==c?void 0:c.iconCopy)||void 0===o?void 0:o.color)&&t.style.setProperty("--jer-icon-copy-color",null===(a=null==c?void 0:c.iconCopy)||void 0===a?void 0:a.color),c},k=(e,t)=>{const{fragments:n,styles:r}=e,o={};return Object.entries(r).forEach((([e,r])=>{const a=(Array.isArray(r)?r:[r]).reduce(((r,o)=>{var a,i;if("function"==typeof o)return t[e]=o,Object.assign({},r);if("string"==typeof o){const t=null!==(a=null==n?void 0:n[o])&&void 0!==a?a:o;return"string"==typeof t?Object.assign(Object.assign({},r),{[null!==(i=O[e])&&void 0!==i?i:"color"]:t}):Object.assign(Object.assign({},r),t)}return Object.assign(Object.assign({},r),o)}),{});o[e]=a})),o},S=e=>!("styles"in e),O={container:"backgroundColor",collection:"backgroundColor",collectionInner:"backgroundColor",collectionElement:"backgroundColor",dropZone:"borderColor",inputHighlight:"backgroundColor"},N=t.createContext({collapseState:null,setCollapseState:()=>{},doesPathMatch:()=>!1,currentlyEditingElement:null,setCurrentlyEditingElement:()=>{},previouslyEditedElement:null,setPreviouslyEditedElement:()=>{},areChildrenBeingEdited:()=>!1,dragSource:{path:null,pathString:null},setDragSource:()=>{},tabDirection:"next",setTabDirection:()=>{}}),A=({children:n})=>{const[r,o]=t.useState(null),[a,i]=t.useState(null),[s,l]=t.useState({path:null,pathString:null}),c=t.useRef(null),d=t.useRef("next"),u=t.useRef(null);return e.jsx(N.Provider,{value:{collapseState:r,setCollapseState:e=>{o(e),null!==e&&setTimeout((()=>o(null)),2e3)},doesPathMatch:e=>{if(null===r)return!1;for(const[t,n]of r.path.entries())if(n!==e[t])return!1;return!0},currentlyEditingElement:a,setCurrentlyEditingElement:(e,t)=>{const n="string"==typeof e||null===e?e:p(e,"key"===t?"key_":void 0);null!==a&&null!==n&&null!==c.current&&c.current(),i(n),c.current="function"==typeof t?t:null},areChildrenBeingEdited:e=>null!==a&&a.includes(e),previouslyEditedElement:u.current,setPreviouslyEditedElement:e=>{u.current=e},tabDirection:d.current,setTabDirection:e=>{d.current=e},dragSource:s,setDragSource:l},children:n})},T=()=>t.useContext(N),R="**INVALID_FUNCTION**",M=({nodeData:n,showStringQuotes:r=!0,stringTruncate:o=200,pathString:a,canEdit:i,setIsEditing:s,styles:l,translate:c})=>{const d=n.value,[u,p]=t.useState(!1),g=r?'"':"",m=d.length>o,h=()=>{i?s(!0):p(!u)};return e.jsxs("div",{id:`${a}_display`,onDoubleClick:h,onClick:e=>{(e.getModifierState("Control")||e.getModifierState("Meta"))&&h()},className:"jer-value-string",style:l,children:[g,m?u?e.jsxs(e.Fragment,{children:[e.jsxs("span",{children:[d,g]}),e.jsxs("span",{className:"jer-string-expansion jer-show-less",onClick:()=>p(!1),children:[" ",c("SHOW_LESS",n)]})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{children:d.slice(0,o-2).trimEnd()}),e.jsx("span",{className:"jer-string-expansion jer-ellipsis",onClick:()=>p(!0),children:"..."}),g]}):`${d}${g}`]})},P=n=>{var{value:r,setValue:a,isEditing:s,path:l,handleEdit:c,nodeData:d,handleKeyboard:u,keyboardCommon:g}=n,m=o(n,["value","setValue","isEditing","path","handleEdit","nodeData","handleKeyboard","keyboardCommon"]);const{getStyles:h}=w(),y=t.useRef(null),b=p(l);return s?e.jsx(i,{className:"jer-input-text",textAreaRef:y,name:b,value:r,setValue:a,isEditing:s,handleKeyPress:e=>{u(e,Object.assign({stringConfirm:c,stringLineBreak:()=>{const e=v(y,"\n");a(e)}},g))},styles:h("input",d)}):e.jsx(M,Object.assign({nodeData:d,pathString:b,styles:h("string",d)},m))},V=({value:t,setValue:n,isEditing:r,path:o,setIsEditing:a,handleEdit:i,nodeData:s,handleKeyboard:l,keyboardCommon:c})=>{const{getStyles:d}=w();return r?e.jsx("input",{className:"jer-input-number",type:"text",name:p(o),value:t,onChange:e=>n(e.target.value.replace(/[^0-9.-]/g,"")),autoFocus:!0,onFocus:e=>setTimeout((()=>e.target.select()),10),onKeyDown:e=>l(e,Object.assign({numberConfirm:i,numberUp:()=>n(Number(t)+1),numberDown:()=>n(Number(t)-1)},c)),style:Object.assign({width:String(t).length/1.5+2+"em"},d("input",s))}):e.jsx("span",{onDoubleClick:()=>a(!0),className:"jer-value-number",style:d("number",s),children:t})},F=({value:t,setValue:n,isEditing:r,path:o,setIsEditing:a,handleEdit:i,nodeData:s,handleKeyboard:l,keyboardCommon:c})=>{const{getStyles:d}=w();return r?e.jsx("input",{className:"jer-input-boolean",type:"checkbox",name:p(o),checked:t,onChange:()=>n(!t),onKeyDown:e=>{" "===e.key&&e.preventDefault(),l(e,Object.assign({booleanConfirm:i,booleanToggle:()=>n(!t)},c))},autoFocus:!0}):e.jsx("span",{onDoubleClick:()=>a(!0),className:"jer-value-boolean",style:d("boolean",s),children:String(t)})},z=({value:n,isEditing:r,setIsEditing:o,handleEdit:a,nodeData:i,handleKeyboard:s,keyboardCommon:l})=>{const{getStyles:c}=w(),d=t.useRef();t.useEffect((()=>{if(r)return d.current=window.setTimeout((()=>window.addEventListener("keydown",u)),100),()=>window.removeEventListener("keydown",u);window.clearTimeout(d.current)}),[r]);const u=e=>s(e,Object.assign({confirm:a},l));return e.jsx("div",{onDoubleClick:()=>o(!0),className:"jer-value-null",style:c("null",i),children:String(n)})},I=({value:t})=>{let n="Error!";switch(typeof t){case"string":t===R&&(n="Function");break;case"undefined":n="Undefined";break;case"symbol":n="Symbol"}return e.jsx("span",{className:"jer-value-invalid",children:n})},K=({size:t,style:n,className:r})=>e.jsxs("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:t,height:t,className:r,style:n,children:[e.jsx("path",{d:"M13 7h-2v4H7v2h4v4h2v-4h4v-2h-4z"}),e.jsx("path",{d:"M12 2C6.486 2 2 6.486 2 12s4.486 10 10 10 10-4.486 10-10S17.514 2 12 2zm0 18c-4.411 0-8-3.589-8-8s3.589-8 8-8 8 3.589 8 8-3.589 8-8 8z"})]}),L=({size:t,style:n,className:r})=>e.jsxs("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:t,height:t,className:r,style:n,transform:"translate(0, 0.5)",children:[e.jsx("path",{d:"M7 17.013l4.413-.015 9.632-9.54c.378-.378.586-.88.586-1.414s-.208-1.036-.586-1.414l-1.586-1.586c-.756-.756-2.075-.752-2.825-.003L7 12.583v4.43zM18.045 4.458l1.589 1.583-1.597 1.582-1.586-1.585 1.594-1.58zM9 13.417l6.03-5.973 1.586 1.586-6.029 5.971L9 15.006v-1.589z"}),e.jsx("path",{d:"M5 21h14c1.103 0 2-.897 2-2v-8.668l-2 2V19H8.158c-.026 0-.053.01-.079.01-.033 0-.066-.009-.1-.01H5V5h6.847l2-2H5c-1.103 0-2 .897-2 2v14c0 1.103.897 2 2 2z"})]}),_=({size:t,style:n,className:r})=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:t,height:t,className:r,style:n,children:e.jsx("path",{d:"M6 19a2 2 0 002 2h8a2 2 0 002-2V7H6v12m2.46-7.12l1.41-1.41L12 12.59l2.12-2.12 1.41 1.41L13.41 14l2.12 2.12-1.41 1.41L12 15.41l-2.12 2.12-1.41-1.41L10.59 14l-2.13-2.12M15.5 4l-1-1h-5l-1 1H5v2h14V4h-3.5z"})}),B=({size:t,style:n,className:r})=>e.jsxs("svg",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",width:t,height:t,className:r,style:n,children:[e.jsx("path",{d:"M9 2 H15 A1 1 0 0 1 16 3 V5 A1 1 0 0 1 15 6 H9 A1 1 0 0 1 8 5 V3 A1 1 0 0 1 9 2 z"}),e.jsx("path",{d:"M8 4H6a2 2 0 00-2 2v14a2 2 0 002 2h12a2 2 0 002-2v-2M16 4h2a2 2 0 012 2v4M21 14H11"}),e.jsx("path",{d:"M15 10l-4 4 4 4"})]}),W=({size:t,style:n,className:r})=>e.jsxs("svg",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",width:t,height:t,className:r,style:n,children:[e.jsx("path",{d:"M22 11.08V12a10 10 0 11-5.93-9.14"}),e.jsx("path",{d:"M22 4L12 14.01l-3-3"})]}),G=({size:t,style:n,className:r})=>e.jsx("svg",{baseProfile:"tiny",viewBox:"0 0 24 24",fill:"currentColor",width:t,height:t,className:r,style:n,children:e.jsx("path",{d:"M12 4c-4.411 0-8 3.589-8 8s3.589 8 8 8 8-3.589 8-8-3.589-8-8-8zm-5 8c0-.832.224-1.604.584-2.295l6.711 6.711A4.943 4.943 0 0112 17c-2.757 0-5-2.243-5-5zm9.416 2.295L9.705 7.584A4.943 4.943 0 0112 7c2.757 0 5 2.243 5 5 0 .832-.224 1.604-.584 2.295z"})}),H=({size:t,style:n,className:r})=>e.jsx("svg",{viewBox:"0 0 512 512",fill:"currentColor",width:t,height:t,className:r,style:n,children:e.jsx("path",{d:"M233.4 406.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L256 338.7 86.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z"})}),U=({name:t,nodeData:n,rotate:r})=>{var o,a,i,s,l,c,d;const{getStyles:u,icons:p}=w(),g={size:"1.4em",className:"jer-icon"};switch(t){case"add":return null!==(o=null==p?void 0:p.add)&&void 0!==o?o:e.jsx(K,Object.assign({},g,{style:u("iconAdd",n)}));case"edit":return null!==(a=null==p?void 0:p.edit)&&void 0!==a?a:e.jsx(L,Object.assign({},g,{style:u("iconEdit",n)}));case"delete":return null!==(i=null==p?void 0:p.delete)&&void 0!==i?i:e.jsx(_,Object.assign({},g,{style:u("iconDelete",n),size:"1.45em"}));case"copy":return null!==(s=null==p?void 0:p.copy)&&void 0!==s?s:e.jsx(B,Object.assign({},g,{style:u("iconCopy",n),size:"1.2em"}));case"ok":return null!==(l=null==p?void 0:p.ok)&&void 0!==l?l:e.jsx(W,Object.assign({},g,{style:Object.assign({fontSize:"90%"},u("iconOk",n))}));case"cancel":return null!==(c=null==p?void 0:p.cancel)&&void 0!==c?c:e.jsx(G,Object.assign({},g,{style:Object.assign({fontSize:"130%"},u("iconCancel",n))}));case"chevron":return null!==(d=null==p?void 0:p.chevron)&&void 0!==d?d:e.jsx(H,{size:"1em",style:u("iconCollection",n)});default:return e.jsx(e.Fragment,{})}},Y=({startEdit:n,handleDelete:r,handleAdd:o,enableClipboard:a,type:i,customButtons:s,nodeData:l,translate:c,keyboardControls:d,handleKeyboard:u})=>{const{getStyles:p}=w(),m=c("KEY_NEW",l),[h,y]=t.useState(!1),[b,f]=t.useState(m),{key:j,path:v,value:x}=l;return e.jsxs("div",{className:"jer-edit-buttons",style:{opacity:h?1:void 0},children:[a&&e.jsx("div",{onClick:e=>{var t;e.stopPropagation();let n,r,o="value",s="",l=null;if(a){const c=g(e);if(c&&d.clipboardModifier.includes(c)?(n=J(v),s=n,o="path"):(n=x,s=i?JSON.stringify(x,null,2):String(n)),!navigator.clipboard)return void("function"==typeof a&&a({success:!1,value:n,stringValue:s,path:v,key:j,type:o,errorMessage:"Can't access clipboard API"}));null===(t=navigator.clipboard)||void 0===t||t.writeText(s).then((()=>r=!0)).catch((e=>{r=!1,l=e.message})).finally((()=>{"function"==typeof a&&a({success:r,errorMessage:l,value:n,stringValue:s,path:v,key:j,type:o})}))}},className:"jer-copy-pulse",children:e.jsx(U,{name:"copy",nodeData:l})}),n&&e.jsx("div",{onClick:e=>{e.stopPropagation(),n()},children:e.jsx(U,{name:"edit",nodeData:l})}),r&&e.jsx("div",{onClick:e=>{e.stopPropagation(),r()},children:e.jsx(U,{name:"delete",nodeData:l})}),o&&e.jsx("div",{onClick:e=>{e.stopPropagation(),"object"===i?y(!0):o("")},children:e.jsx(U,{name:"add",nodeData:l})}),null==s?void 0:s.map((({Element:t,onClick:n},r)=>e.jsx("div",{onClick:e=>n&&n(l,e),children:e.jsx(t,{nodeData:l})},r))),h&&o&&"object"===i&&e.jsxs(e.Fragment,{children:[e.jsx("input",{className:"jer-input-new-key",type:"text",name:"new-object-key",value:b,onChange:e=>f(e.target.value),onClick:e=>e.stopPropagation(),autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>{u(e,{stringConfirm:()=>{o&&(y(!1),o(b),f(m))},cancel:()=>{y(!1),f(m)}})},style:p("input",l)}),e.jsx($,{onOk:e=>{b&&(e.stopPropagation(),y(!1),o(b))},onCancel:e=>{e.stopPropagation(),y(!1)},nodeData:l})]})]})},$=({onOk:t,onCancel:n,nodeData:r})=>e.jsxs("div",{className:"jer-confirm-buttons",children:[e.jsx("div",{onClick:t,children:e.jsx(U,{name:"ok",nodeData:r})}),e.jsx("div",{onClick:n,children:e.jsx(U,{name:"cancel",nodeData:r})})]}),J=e=>e.reduce(((e,t)=>"number"==typeof t?`${e}[${t}]`:""===e?t:`${e}.${t}`),""),X=["string","number","boolean","null","object","array"],Z=(e=[],t)=>{const n=e.filter((({condition:e})=>e(t)));if(0===n.length)return{};const r=n[0],{element:a,wrapperElement:i,customNodeProps:s,wrapperProps:l,hideKey:c=!1,showEditTools:d=!0,showOnEdit:u=!1,showOnView:p=!0,showCollectionWrapper:g=!0}=r,m=o(r,["element","wrapperElement","customNodeProps","wrapperProps","hideKey","showEditTools","showOnEdit","showOnView","showCollectionWrapper"]);return Object.assign({CustomNode:a,CustomWrapper:i,customNodeProps:s,wrapperProps:l,hideKey:c,showEditTools:d,showOnEdit:u,showOnView:p,showCollectionWrapper:g},m)},q=({props:e,collapsed:n})=>{const{data:r,nodeData:o,parentData:a,onEdit:i,onError:s,showErrorMessages:l,restrictEditFilter:c,restrictDeleteFilter:d,restrictAddFilter:u,restrictDragFilter:g,translate:m,errorMessageTimeout:h}=e,{currentlyEditingElement:y,setCurrentlyEditingElement:b}=T(),[f,j]=t.useState(null),v=Object.assign(Object.assign({},o),{collapsed:n}),{path:x,key:E,size:D}=v,w=p(x),C=t.useMemo((()=>!c(v)),[v]),k=t.useMemo((()=>!d(v)),[v]),S=t.useMemo((()=>!u(v)),[v]),O=t.useMemo((()=>!g(v)&&k&&null===y),[v]),N=e=>{l&&(j(e),setTimeout((()=>j(null)),h)),console.warn("Error",e)},A=t.useMemo((()=>(e,t)=>{N(e.message),s&&s({currentData:v.fullData,errorValue:t,currentValue:r,name:E,path:x,error:e})}),[s,l]),R=y===w,M=y===`key_${w}`,P="number"==typeof x.slice(-1)[0];return{pathString:w,nodeData:v,path:x,name:E,size:D,canEdit:C,canDelete:k,canAdd:S,canDrag:O,error:f,showError:N,onError:A,setError:j,handleEditKey:e=>{if(b(null),E===e)return;if(!a)return;const t=x.slice(0,-1);if(Object.keys(a).includes(e))return void A({code:"KEY_EXISTS",message:m("ERROR_KEY_EXISTS",v)},e);const n=Object.fromEntries(Object.entries(a).map((([t,n])=>t===E?[e,n]:[t,n])));i(n,t).then((t=>{t&&A({code:"UPDATE_ERROR",message:t},e)}))},derivedValues:{isEditing:R,isEditingKey:M,isArray:P,canEditKey:null!==a&&C&&S&&k&&!P}}},Q=({canDrag:n,canDragOnto:r,path:o,nodeData:a,onMove:i,onError:s,translate:l})=>{const{getStyles:c}=w(),{dragSource:d,setDragSource:u}=T(),[g,m]=t.useState(!1),h=p(o),y=t.useMemo((()=>n?{onDragStart:e=>{e.stopPropagation(),u({path:o,pathString:h})},onDragEnd:e=>{e.stopPropagation(),u({path:null,pathString:null})}}:{}),[n]),b=t.useMemo((()=>e=>r?{onDragOver:e=>{e.stopPropagation(),e.preventDefault()},onDrop:t=>{t.stopPropagation(),j(e),u({path:null,pathString:null}),m(!1)},onDragEnter:t=>{var n;t.stopPropagation(),h.startsWith(null!==(n=d.pathString)&&void 0!==n?n:"")||m(e)},onDragExit:e=>{e.stopPropagation(),m(!1)}}:{}),[d,r]),f=t.useMemo((()=>r&&null!==d.pathString?e.jsx("div",Object.assign({className:"jer-drop-target-bottom",style:{height:"50%",position:"absolute",width:"100%",top:"50%",zIndex:o.length}},b("below"))):null),[d,r]),j=e=>{var t,n;const r=null===(t=d.path)||void 0===t?void 0:t.slice(-1)[0],c=null===(n=d.path)||void 0===n?void 0:n.slice(0,-1).join("."),u=o.slice(0,-1).join(""),{parentData:p}=a;"string"==typeof r&&p&&!Array.isArray(p)&&Object.keys(p).includes(r)&&r in p&&c!==u?s({code:"KEY_EXISTS",message:l("ERROR_KEY_EXISTS",a)},r):i(d.path,o,e).then((e=>{e&&s({code:"UPDATE_ERROR",message:e},a.value)}))};return{dragSourceProps:y,getDropTargetProps:b,BottomDropTarget:f,DropTargetPadding:({position:t,nodeData:n})=>g===t?e.jsx("div",{className:"jer-drag-n-drop-padding",style:c("dropZone",n)}):null,handleDrop:j}},ee=(e,t,n)=>{var r,o,a;const i=parseInt(null!==(r=getComputedStyle(n.current).getPropertyValue("line-height"))&&void 0!==r?r:"16px"),s=(null!==(a=null===(o=t.current)||void 0===o?void 0:o.offsetWidth)&&void 0!==a?a:0)/(.5*i),l=JSON.stringify(e,null,2).replace(/\\n/g,"\n").split("\n").map((e=>Math.ceil(e.length/s))).reduce(((e,t)=>e+t),0)*i;return Math.min(l+30,window.innerHeight-50)},te=n=>{const{data:r,parentData:o,onEdit:a,onDelete:i,onChange:s,onMove:c,enableClipboard:d,canDragOnto:u,restrictTypeSelection:p,searchFilter:g,searchText:m,showLabel:h,stringTruncate:y,showStringQuotes:f,indent:j,translate:v,customNodeDefinitions:x,handleKeyboard:E,keyboardControls:D,sort:C}=n,{getStyles:k}=w(),{setCurrentlyEditingElement:S,setCollapseState:O,previouslyEditedElement:N,setPreviouslyEditedElement:A,tabDirection:M,setTabDirection:P}=T(),[V,F]=t.useState("function"==typeof r?R:r),{pathString:z,nodeData:I,path:K,name:L,canEdit:_,canDelete:B,canDrag:W,error:G,onError:H,handleEditKey:U,derivedValues:J}=q({props:n}),{dragSourceProps:ee,getDropTargetProps:te,BottomDropTarget:ae,DropTargetPadding:ie}=Q({canDrag:W,canDragOnto:u,path:K,nodeData:I,onMove:c,onError:H,translate:v}),se=Z(x,I),[le,ce]=t.useState(ne(r,se)),de=t.useCallback((e=>{if(!s)return void F(e);const t=s({currentData:I.fullData,newValue:e,currentValue:V,name:L,path:K});F(t)}),[s]);t.useEffect((()=>{F("function"==typeof r?R:r),ce(ne(r,se))}),[r,G]);const{CustomNode:ue,customNodeProps:pe,hideKey:ge,showEditTools:me=!0,showOnEdit:he,showOnView:ye}=se,be=[...X,...x.filter((({showInTypesSelector:e=!1,name:t})=>e&&!!t)).map((({name:e})=>e))],fe=t.useMemo((()=>{if("boolean"==typeof p)return p?[]:be;if(Array.isArray(p))return p;const e=p(I);return"boolean"==typeof e?e?[]:be:e}),[I,p]),{isEditing:je}=J,ve=l("value",I,g,m);if(je&&(!ve||!_)){const e=b(I.fullData,K,M,C);S(e||N)}if(!ve)return null;const xe=()=>{let e;switch(S(null),le){case"object":e={[v("DEFAULT_NEW_KEY",I)]:V};break;case"array":e=null!=V?V:[];break;case"number":{const t=Number(V);e=isNaN(t)?0:t;break}default:e=V}a(e,K).then((t=>{t&&H({code:"UPDATE_ERROR",message:t},e)}))},Ee=()=>{S(null),F(r)},{isEditingKey:De,canEditKey:we}=J,Ce=!je&&G,ke=je&&fe.length>0,Se="invalid"!==le&&!G&&me,Oe=h&&De,Ne=h&&!De&&!ge,Ae={value:V,parentData:o,setValue:de,isEditing:je,canEdit:_,setIsEditing:_?()=>S(K):()=>{},handleEdit:xe,handleCancel:Ee,path:K,stringTruncate:y,showStringQuotes:f,nodeData:I,translate:v,handleKeyboard:E,keyboardCommon:{cancel:Ee,tabForward:()=>{P("next"),A(z);const e=b(I.fullData,K,"next",C);e&&(xe(),S(e))},tabBack:()=>{P("prev"),A(z);const e=b(I.fullData,K,"prev",C);e&&(xe(),S(e))}}},Te=ue&&(je&&he||!je&&ye)?e.jsx(ue,Object.assign({},n,{value:V,customNodeProps:pe,setValue:de,handleEdit:xe,handleCancel:Ee,handleKeyPress:e=>E(e,{stringConfirm:xe,cancel:Ee}),isEditing:je,setIsEditing:()=>S(K),getStyles:k})):re(r,Ae);return e.jsxs("div",Object.assign({className:"jer-component jer-value-component",style:{marginLeft:j/2+"em",position:"relative"},draggable:W},ee,te("above"),{children:[ae,e.jsx(ie,{position:"above",nodeData:I}),e.jsxs("div",{className:"jer-value-main-row",style:{flexWrap:L.length>10?"wrap":"nowrap"},children:[Ne&&e.jsx("span",{className:"jer-key-text",style:Object.assign(Object.assign({},k("property",I)),{minWidth:`${Math.min(String(L).length+1,5)}ch`,flexShrink:L.length>10?1:0}),onDoubleClick:()=>we&&S(K,"key"),children:""===L?e.jsx("span",{className:K.length>0?"jer-empty-string":void 0}):`${L}:`}),Oe&&e.jsx("input",{className:"jer-input-text jer-key-edit",type:"text",name:z,defaultValue:L,autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>E(e,{stringConfirm:()=>U(e.target.value),cancel:Ee,tabForward:()=>{U(e.target.value),S(K)},tabBack:()=>{U(e.target.value),S(b(I.fullData,K,"prev",C))}}),style:{width:String(L).length/1.5+.5+"em"}}),e.jsxs("div",{className:"jer-value-and-buttons",children:[e.jsx("div",{className:"jer-input-component",children:Te}),je?e.jsx($,{onOk:xe,onCancel:Ee,nodeData:I}):Se&&e.jsx(Y,{startEdit:_?()=>S(K,Ee):void 0,handleDelete:B?()=>{i(V,K).then((e=>{e&&H({code:"DELETE_ERROR",message:e},V)}))}:void 0,enableClipboard:d,translate:v,customButtons:n.customButtons,nodeData:I,handleKeyboard:E,keyboardControls:D}),ke&&e.jsxs("div",{className:"jer-select",children:[e.jsx("select",{name:`${L}-type-select`,className:"jer-type-select",onChange:e=>(e=>{const t=x.find((t=>t.name===e));if(t)a(t.defaultValue,K),ce(e),S(null),O({path:K,collapsed:!1});else{const t=oe(V,e,v("DEFAULT_NEW_KEY",I),(null==se?void 0:se.CustomNode)?v("DEFAULT_STRING",I):void 0);a(t,K).then((e=>{e&&(H({code:"UPDATE_ERROR",message:e},t),S(null))}))}})(e.target.value),value:le,children:fe.map((t=>e.jsx("option",{value:t,children:t},t)))}),e.jsx("span",{className:"focus"})]}),Ce&&e.jsx("span",{className:"jer-error-slug",style:k("error",I),children:G})]})]}),e.jsx(ie,{position:"below",nodeData:I})]}))},ne=(e,t)=>(null==t?void 0:t.CustomNode)&&(null==t?void 0:t.name)&&t.showInTypesSelector?t.name:"string"==typeof e?"string":"number"==typeof e?"number":"boolean"==typeof e?"boolean":null===e?"null":"invalid",re=(t,n)=>{const r=ne(t),{value:o}=n;switch(r){case"string":return e.jsx(P,Object.assign({},n,{value:o}));case"number":return e.jsx(V,Object.assign({},n,{value:o}));case"boolean":return e.jsx(F,Object.assign({},n,{value:o}));case"null":return e.jsx(z,Object.assign({},n));default:return e.jsx(I,Object.assign({},n))}},oe=(e,t,n,r)=>{switch(t){case"string":return null!=r?r:String(e);case"number":{const t=Number(e);return isNaN(t)?0:t}case"boolean":return!!e;case"null":return null;case"object":return{[n]:e};case"array":return[e];default:return String(e)}},ae=n=>{const{getStyles:r}=w(),{collapseState:o,setCollapseState:c,doesPathMatch:d,currentlyEditingElement:u,setCurrentlyEditingElement:p,areChildrenBeingEdited:m}=T(),{mainContainerRef:h,data:y,nodeData:f,parentData:j,showCollectionCount:x,onEdit:E,onAdd:D,onDelete:C,canDragOnto:k,collapseFilter:S,collapseAnimationTime:O,onMove:N,enableClipboard:A,searchFilter:R,searchText:M,indent:P,sort:V,showArrayIndices:F,defaultValue:z,translate:I,customNodeDefinitions:K,jsonParse:L,jsonStringify:_,TextEditor:B,keyboardControls:W,handleKeyboard:G,insertAtTop:H}=n,[J,X]=t.useState(_(y)),ne=S(f),{contentRef:re,isAnimating:oe,maxHeight:ie,collapsed:se,animateCollapse:le,cssTransitionValue:ce}=((e,n,r,o)=>{const[a,i]=t.useState(r?0:void 0),[s,l]=t.useState(r),c=t.useRef(!1),d=t.useRef(null),u=t.useRef(0),p=t.useRef(),g=n/1e3+"s";return{contentRef:d,isAnimating:c.current,animateCollapse:t=>{var r,a;if(s!==t){switch(window.clearTimeout(p.current),c.current=!0,t){case!0:{const e=null!==(a=null===(r=d.current)||void 0===r?void 0:r.offsetHeight)&&void 0!==a?a:0;u.current=e,i(e),setTimeout((()=>{i(0)}),5);break}case!1:i(u.current||ee(e,d,o))}l(!s),p.current=window.setTimeout((()=>{c.current=!1,t||i(void 0)}),n)}},maxHeight:a,collapsed:s,cssTransitionValue:g}})(y,O,ne,h),{pathString:de,nodeData:ue,path:pe,name:ge,size:me,canEdit:he,canDelete:ye,canAdd:be,canDrag:fe,error:je,setError:ve,onError:xe,handleEditKey:Ee,derivedValues:De}=q({props:n,collapsed:se}),{dragSourceProps:we,getDropTargetProps:Ce,BottomDropTarget:ke,DropTargetPadding:Se}=Q({canDrag:fe,canDragOnto:k,path:pe,nodeData:ue,onMove:N,onError:xe,translate:I}),Oe=t.useRef(!ne),{isEditing:Ne,isEditingKey:Ae,isArray:Te,canEditKey:Re}=De;t.useEffect((()=>{X(_(y)),Ne&&p(null)}),[y]),t.useEffect((()=>{const e=S(ue)&&!Ne;Oe.current=!e,le(e)}),[S]),t.useEffect((()=>{null!==o&&d(pe)&&(Oe.current=!0,le(o.collapsed))}),[o]);const Me=t.useRef(null),Pe=t.useMemo((()=>(e,t)=>"function"!=typeof z?z:z(e,t)),[z]),{CustomNode:Ve,customNodeProps:Fe,CustomWrapper:ze,wrapperProps:Ie={},hideKey:Ke,showEditTools:Le=!0,showOnEdit:_e,showOnView:Be,showCollectionWrapper:We=!0}=t.useMemo((()=>Z(K,ue)),[y]),Ge=m(de);Ge&&se&&le(!1);if(!(l("collection",ue,R,M)||0===ue.level)&&!Ge)return null;const He=Array.isArray(y)?"array":"object",Ue="array"===He?{open:"[",close:"]"}:{open:"{",close:"}"},Ye=e=>{if("Tab"!==e.key||e.getModifierState("Shift"))G(e,{objectConfirm:Je,cancel:Ze});else{e.preventDefault();const t=v(Me,"\t");X(t)}},$e=e=>{const t=g(e);if(t&&W.collapseModifier.includes(t))return Oe.current=!0,void c({collapsed:!se,path:pe});u&&u.includes(de)||(Oe.current=!0,c(null),le(!se))},Je=()=>{try{const e=L(J);if(p(null),ve(null),JSON.stringify(e)===JSON.stringify(y))return;E(e,pe).then((t=>{t&&xe({code:"UPDATE_ERROR",message:t},e)}))}catch(e){xe({code:"INVALID_JSON",message:I("ERROR_INVALID_JSON",ue)},J)}},Xe=pe.length>0?()=>{C(y,pe).then((e=>{e&&xe({code:"DELETE_ERROR",message:e},y)}))}:void 0,Ze=()=>{p(null),ve(null),X(_(y))},qe="when-closed"===x?se:x,Qe=!Ne&&Le,et=(F||!Te)&&!Ke&&void 0!==ge,tt=Ve&&(Ne&&_e||!Ne&&Be),nt=Object.entries(y).map((([e,t])=>["array"===He?Number(e):e,t]));"object"===He&&V(nt,(e=>e));const rt=Oe.current?Ne?e.jsxs("div",{className:"jer-collection-text-edit",children:[B?e.jsx(B,{value:J,onChange:X,onKeyDown:e=>G(e,{objectConfirm:Je,cancel:Ze})}):e.jsx(i,{textAreaRef:Me,className:"jer-collection-text-area",name:de,value:J,setValue:X,isEditing:Ne,handleKeyPress:Ye,styles:r("input",ue)}),e.jsx("div",{className:"jer-collection-input-button-row",children:e.jsx($,{onOk:Je,onCancel:Ze,nodeData:ue})})]}):nt.map((([t,o],a)=>{const i={key:t,value:o,path:[...pe,t],level:pe.length+1,index:a,size:s(o)?Object.keys(o).length:1,parentData:y,fullData:ue.fullData};return e.jsx("div",{className:"jer-collection-element",style:r("collectionElement",i),children:s(o)?e.jsx(ae,Object.assign({},n,{data:o,parentData:y,nodeData:i,showCollectionCount:x,canDragOnto:he}),t):e.jsx(te,Object.assign({},n,{data:o,parentData:y,nodeData:i,canDragOnto:he,showLabel:"object"===He||F}),t)},t)})):null,ot=!!We&&(se&&!Ge);ot||(Oe.current=!0);const at=Object.assign(Object.assign({},n),{data:y,value:y,parentData:j,nodeData:ue,setValue:e=>a(void 0,void 0,void 0,(function*(){return yield E(e,pe)})),handleEdit:Je,handleCancel:Ze,handleKeyPress:Ye,isEditing:Ne,setIsEditing:()=>p(pe),getStyles:r,canDragOnto:he}),it=tt?e.jsx(Ve,Object.assign({customNodeProps:Fe},at,{children:rt})):rt,st=Ae?e.jsx("input",{className:"jer-input-text jer-key-edit",type:"text",name:de,defaultValue:ge,autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>G(e,{stringConfirm:()=>Ee(e.target.value),cancel:Ze,tabForward:()=>{Ee(e.target.value);const t=null==nt?void 0:nt[0][0];p(t?[...pe,t]:b(ue.fullData,pe,"next",V))},tabBack:()=>{Ee(e.target.value),p(b(ue.fullData,pe,"prev",V))}}),style:{width:String(ge).length/1.5+.5+"em"}}):et&&e.jsx("span",{className:"jer-key-text",style:r("property",ue),onClick:e=>e.stopPropagation(),onDoubleClick:()=>Re&&p(pe,"key"),children:""===ge?e.jsx("span",{className:pe.length>0?"jer-empty-string":void 0}):`${ge}:`}),lt=Qe&&e.jsx(Y,{startEdit:he?()=>{Oe.current=!0,p(pe)}:void 0,handleAdd:be?e=>{le(!1);const t=Pe(ue,e);if("array"===He){const e=H.array?0:y.length,n=H.array?{insert:!0}:{};D(t,[...pe,e],n).then((e=>{e&&xe({code:"ADD_ERROR",message:e},t)}))}else if(e in y)xe({code:"KEY_EXISTS",message:I("ERROR_KEY_EXISTS",ue)},e);else{const n=H.object?{insertBefore:0}:{};D(t,[...pe,e],n).then((e=>{e&&xe({code:"ADD_ERROR",message:e},t)}))}}:void 0,handleDelete:ye?Xe:void 0,enableClipboard:A,type:He,nodeData:ue,translate:I,customButtons:n.customButtons,keyboardControls:W,handleKeyboard:G}),ct=e.jsxs("div",Object.assign({className:"jer-component jer-collection-component",style:Object.assign(Object.assign({marginLeft:(0===pe.length?0:P/2)+"em"},r("collection",ue)),{position:"relative"}),draggable:fe},we,Ce("above"),{children:[e.jsx("div",{className:"jer-clickzone",style:{width:P/2+1+"em",zIndex:10+2*ue.level},onClick:e=>$e(e)}),!Ne&&ke,e.jsx(Se,{position:"above",nodeData:ue}),We?e.jsxs("div",{className:"jer-collection-header-row",style:{position:"relative"},onClick:e=>$e(e),children:[e.jsxs("div",{className:"jer-collection-name",children:[e.jsx("div",{className:"jer-collapse-icon jer-accordion-icon"+(se?" jer-rotate-90":""),style:{zIndex:11+2*ue.level,transition:ce},onClick:e=>$e(e),children:e.jsx(U,{name:"chevron",rotate:se,nodeData:ue})}),st,!Ne&&e.jsx("span",{className:"jer-brackets jer-bracket-open",style:r("bracket",ue),children:Ue.open})]}),!Ne&&qe&&e.jsx("div",{className:"jer-collection-item-count"+(qe?" jer-visible":" jer-hidden"),style:Object.assign(Object.assign({},r("itemCount",ue)),{transition:ce}),children:1===me?I("ITEM_SINGLE",Object.assign(Object.assign({},ue),{size:1}),1):I("ITEMS_MULTIPLE",ue,me)}),e.jsx("div",{className:"jer-brackets"+(ot?" jer-visible":" jer-hidden"),style:Object.assign(Object.assign({},r("bracket",ue)),{transition:ce}),children:Ue.close}),lt]}):Ke?e.jsx(e.Fragment,{}):e.jsxs("div",{className:"jer-collection-header-row",style:{position:"relative"},children:[st,lt]}),e.jsxs("div",{className:"jer-collection-inner",style:Object.assign(Object.assign({overflowY:ot||oe?"clip":"visible",maxHeight:Ge?void 0:ie},r("collectionInner",ue)),{transition:ce}),ref:re,children:[it,e.jsx("div",{className:Ne?"jer-collection-error-row":"jer-collection-error-row-edit",children:je&&e.jsx("span",{className:"jer-error-slug",style:r("error",ue),children:je})}),!Ne&&We&&e.jsx("div",{className:"jer-brackets jer-bracket-outside",style:Object.assign(Object.assign({},r("bracket",ue)),{marginLeft:(P<3?-1:P<6?-.5:0)+"em"}),children:Ue.close})]}),e.jsx(Se,{position:"below",nodeData:ue})]}));return ze?e.jsx(ze,Object.assign({customNodeProps:Ie},at,{children:ct})):ct},ie={ITEM_SINGLE:"{{count}} item",ITEMS_MULTIPLE:"{{count}} items",KEY_NEW:"Enter new key",ERROR_KEY_EXISTS:"Key already exists",ERROR_INVALID_JSON:"Invalid JSON",ERROR_UPDATE:"Update unsuccessful",ERROR_DELETE:"Delete unsuccessful",ERROR_ADD:"Adding node unsuccessful",DEFAULT_STRING:"New data!",DEFAULT_NEW_KEY:"key",SHOW_LESS:"(Show less)"},se=(e,t)=>(n,r,o)=>((e,t,n,r,o)=>{if(t[r]){const e=t[r](n);if(null!==e)return e}const a=r in e?e[r]:ie[r];return void 0===o?a:null==a?void 0:a.replace("{{count}}",String(o))})(e,t,r,n,o);var le=[],ce=[];!function(e,t){if(e&&"undefined"!=typeof document){var n,r=!0===t.prepend?"prepend":"append",o=!0===t.singleTag,a="string"==typeof t.container?document.querySelector(t.container):document.getElementsByTagName("head")[0];if(o){var i=le.indexOf(a);-1===i&&(i=le.push(a)-1,ce[i]={}),n=ce[i]&&ce[i][r]?ce[i][r]:ce[i][r]=s()}else n=s();65279===e.charCodeAt(0)&&(e=e.substring(1)),n.styleSheet?n.styleSheet.cssText+=e:n.appendChild(document.createTextNode(e))}function s(){var e=document.createElement("style");if(e.setAttribute("type","text/css"),t.attributes)for(var n=Object.keys(t.attributes),o=0;o<n.length;o++)e.setAttribute(n[o],t.attributes[n[o]]);var i="prepend"===r?"afterbegin":"beforeend";return a.insertAdjacentElement(i,e),e}}(':root{--jer-select-border:#b6b6b6;--jer-select-focus:#777;--jer-select-arrow:#777;--jer-form-border:1px solid #ededf0;--jer-form-border-focus:1px solid #e2e2e2;--jer-highlight-color:#b3d8ff}.jer-visible{opacity:1}.jer-hidden{opacity:0}.jer-select select{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:transparent;border:none;color:#000;cursor:inherit;font-family:inherit;font-size:.8em;line-height:inherit;margin:0;outline:none;padding:0 1em 0 0;z-index:1}select::-ms-expand{display:none}.jer-select{align-items:center;background-color:#fff;background-image:linear-gradient(0deg,#f9f9f9,#fff 33%);border:1px solid var(--jer-select-border);border-radius:.25em;cursor:pointer;display:grid;grid-template-areas:"select";line-height:1.1;max-width:15ch;min-width:12ch;padding:.25em .5em;position:relative}.jer-select select,.jer-select:after{grid-area:select}.jer-select:not(.jer-select--multiple):after{background-color:var(--jer-select-arrow);clip-path:polygon(100% 0,0 0,50% 100%);content:"";height:.5em;justify-self:end;width:.8em}select:focus+.focus{border:1px solid var(--jer-select-focus);border-radius:inherit;bottom:-1px;left:-1px;position:absolute;right:-1px;top:-1px}.jer-editor-container{border-radius:.5em;font-size:16px;line-height:1;padding:1em 1em 1em 2em;position:relative;text-align:left}.jer-editor-container textarea{border:var(--jer-form-border);border-radius:.3em;color:var(--jer-input-color);outline:none}.jer-editor-container textarea:focus{border:var(--jer-form-border-focus)}.jer-editor-container input{border:var(--jer-form-border);border-radius:.3em;font-family:inherit;outline:none}.jer-editor-container input:focus{border:var(--jer-form-border-focus)}.jer-editor-container ::selection{background-color:var(--jer-highlight-color)}.jer-collection-header-row,.jer-value-main-row{align-items:center;display:flex;gap:.3em;min-height:1.7em}.jer-collection-header-row{display:flex;flex-wrap:wrap}.jer-collapse-icon{left:-1.2em;position:absolute;top:.35em}.jer-collection-inner{position:relative}.jer-collection-text-edit{align-items:flex-start;display:flex;flex-direction:column;gap:.3em;line-height:1.1em}.jer-collection-text-area{font-family:inherit;font-size:.85em;max-height:40em;overflow:hidden;padding:.2em .5em 0;resize:both}.jer-collection-input-button-row{display:flex;font-size:150%;justify-content:flex-end;margin-top:.4em;width:100%}.jer-collection-error-row{bottom:.5em;position:absolute}.jer-error-slug{margin-left:1em}.jer-value-component{position:relative}.jer-value-main-row{display:flex;gap:0}.jer-value-and-buttons{align-items:center;display:flex;justify-content:flex-start;padding-left:.5em}.jer-value-error-row{position:absolute}.jer-value-string{line-height:1.3em;overflow-wrap:anywhere;white-space:pre-wrap;word-break:break-word}.jer-string-expansion{cursor:pointer;filter:saturate(50%);opacity:.6}.jer-show-less{font-size:80%}.jer-hyperlink{text-decoration:underline}.jer-input-text{font-family:inherit;font-size:.9em;height:1.4em;line-height:1.2em;margin:0;min-width:6em;overflow:hidden;padding:.25em .5em .2em;resize:none}.jer-input-boolean{margin-left:.3em;margin-right:.3em;transform:scale(1.5)}.jer-key-text{line-height:1.1em;white-space:pre-wrap;word-break:break-word}.jer-key-edit{font-size:inherit;font-size:.9em;padding:0 .3em}.jer-value-invalid{font-style:italic;opacity:.5}.jer-input-number{font-size:90%;min-width:3em}.jer-confirm-buttons,.jer-edit-buttons{align-items:center;cursor:pointer;display:flex;height:1em}.jer-input-buttons{gap:.4em}.jer-edit-buttons{gap:.4em;margin-left:.5em;opacity:0}.jer-confirm-buttons{gap:.2em;margin-left:.4em}.jer-edit-buttons:hover{opacity:1;position:relative}.jer-collection-header-row:hover>.jer-edit-buttons,.jer-value-and-buttons:hover>.jer-edit-buttons,.jer-value-main-row:hover>.jer-edit-buttons{opacity:1}.jer-copy-pulse{position:relative;transition:.3s}.jer-copy-pulse:hover{opacity:.85;transform:scale(1.2);transition:.3s}.jer-copy-pulse:after{border-radius:50%;box-shadow:0 0 15px 5px var(--jer-icon-copy-color);content:"";display:block;height:100%;left:0;opacity:0;position:absolute;top:0;transition:all .5s;width:100%}.jer-copy-pulse:active:after{border-radius:4em;box-shadow:0 0 0 0 var(--jer-icon-copy-color);left:0;opacity:1;position:absolute;top:0;transition:0s}.jer-copy-pulse:active{top:.07em}.jer-rotate-90{transform:rotate(-90deg)}.jer-icon:hover{opacity:.85;transform:scale(1.2);transition:.3s}.jer-empty-string:after{content:"<empty string>:";font-size:90%;font-style:italic}.jer-drag-n-drop-padding{border:1px dashed #e0e0e0;border-radius:.3em;height:.5em}.jer-clickzone{height:calc(100% - .8em);left:-1em;position:absolute;top:1.2em}',{});const de=({data:n,setData:r,rootName:o="root",onUpdate:i=(()=>{}),onEdit:l=i,onDelete:c=i,onAdd:d=i,onChange:u,onError:p,showErrorMessages:g=!0,enableClipboard:h=!0,indent:b=2,collapse:f=!1,collapseAnimationTime:j=300,showCollectionCount:v=!0,restrictEdit:x=!1,restrictDelete:E=!1,restrictAdd:D=!1,restrictTypeSelection:C=!1,restrictDrag:k=!0,viewOnly:S,searchFilter:O,searchText:N,searchDebounceTime:A=350,keySort:R=!1,showArrayIndices:M=!0,showStringQuotes:P=!0,defaultValue:V=null,minWidth:F=250,maxWidth:z="min(600px, 90vw)",rootFontSize:I,stringTruncate:K=250,translations:L={},className:_,id:B,customText:W={},customNodeDefinitions:G=[],customButtons:H=[],jsonParse:U=JSON.parse,jsonStringify:Y=(e=>JSON.stringify(e,null,2)),TextEditor:$,errorMessageTimeout:J=2500,keyboardControls:X={},insertAtTop:Z=!1})=>{const{getStyles:q}=w(),{setCurrentlyEditingElement:Q}=T(),ee=t.useCallback(pe(f),[f]),ne=t.useCallback(se(L,W),[L,W]),[re,oe]=t.useState(N),[ie,le]=(({setData:e,data:n})=>{const[r,o]=t.useState(e?void 0:n),a=t.useCallback((t=>{e?e(t):o(t)}),[e]);return t.useEffect((()=>{e||o(n)}),[n]),[e?n:r,a]})({setData:r,data:n}),ce=t.useRef(null);t.useEffect((()=>{Q(null);const e=setTimeout((()=>oe(N)),A);return()=>clearTimeout(e)}),[N,A]);const de={key:o,path:[],level:0,index:0,value:ie,size:"object"==typeof ie&&null!==ie?Object.keys(ie).length:1,parentData:null,fullData:ie},he=(e,t)=>a(void 0,void 0,void 0,(function*(){const n=yield e(t);if(!0===n||void 0===n)return void le(t.newData);const r=me(n)?n:["error",n],[o,a]=r;if("error"===o)return le(t.currentData),!1===a?ne("ERROR_UPDATE",de):String(a);le(a)})),ye=t.useMemo((()=>pe(x,S)),[x,S]),be=t.useMemo((()=>pe(E,S)),[E,S]),fe=t.useMemo((()=>pe(D,S)),[D,S]),je=t.useMemo((()=>pe(k,S)),[k,S]),ve=t.useMemo((()=>ge(O)),[O]),xe=t.useMemo((()=>(e=>{const t=Object.assign({},y);for(const n of Object.keys(y)){const r=n;if(e[r]){const o=e[r],a=["clipboardModifier","collapseModifier"].includes(n)?Array.isArray(o)?o:[o]:"string"==typeof o?{key:o}:o;t[r]=a,["stringConfirm","numberConfirm","booleanConfirm"].forEach((n=>{!e[n]&&e.confirm&&(t[n]=t.confirm)}))}}return t})(X)),[X]),Ee=t.useCallback(((e,t)=>((e,t,n)=>{const r=Object.entries(t);for(const[t,o]of r)if(m(n,e[t],t)){n.preventDefault(),o();break}})(xe,t,e)),[X]),De=t.useCallback(((e,t)=>{!1!==R&&("function"!=typeof R?e.sort(((e,n)=>{const r=t(e)[0],o=t(n)[0];return r<o?-1:r>o?1:0})):e.sort(((e,n)=>R(t(e),t(n)))))}),[R]),we={mainContainerRef:ce,name:o,nodeData:de,onEdit:(e,t)=>a(void 0,void 0,void 0,(function*(){const{currentData:n,newData:r,currentValue:o,newValue:a}=ue(ie,t,e,"update");if(o!==a)return yield he(l,{currentData:n,newData:r,currentValue:o,newValue:a,name:t.slice(-1)[0],path:t})})),onDelete:(e,t)=>a(void 0,void 0,void 0,(function*(){const{currentData:n,newData:r,currentValue:o,newValue:a}=ue(ie,t,e,"delete");return yield he(c,{currentData:n,newData:r,currentValue:o,newValue:a,name:t.slice(-1)[0],path:t})})),onAdd:(e,t,n)=>a(void 0,void 0,void 0,(function*(){const{currentData:r,newData:o,currentValue:a,newValue:i}=ue(ie,t,e,"add",n);return yield he(d,{currentData:r,newData:o,currentValue:a,newValue:i,name:t.slice(-1)[0],path:t})})),onChange:u,onError:p,showErrorMessages:g,onMove:(e,t,n)=>a(void 0,void 0,void 0,(function*(){if(null===e)return;const{currentData:r,newData:o,currentValue:a}=ue(ie,e,"","delete"),i=e.slice(-1)[0],s=t.slice(0,-1),c=t.slice(-1)[0];let d="number"==typeof c?"above"===n?c:c+1:"number"==typeof i?`arr_${i}`:i;e.slice(0,-1).join(".")===t.slice(0,-1).join(".")&&"number"==typeof i&&"number"==typeof d&&i<d&&(d-=1);const u="number"==typeof d?{insert:!0}:"above"===n?{insertBefore:c}:{insertAfter:c},{newData:p,newValue:g}=ue(o,[...s,d],a,"add",u);return yield he(l,{currentData:r,newData:p,currentValue:a,newValue:g,name:t.slice(-1)[0],path:t})})),showCollectionCount:v,collapseFilter:ee,collapseAnimationTime:j,restrictEditFilter:ye,restrictDeleteFilter:be,restrictAddFilter:fe,restrictTypeSelection:C,restrictDragFilter:je,canDragOnto:!1,searchFilter:ve,searchText:re,enableClipboard:h,keySort:R,sort:De,showArrayIndices:M,showStringQuotes:P,indent:b,defaultValue:V,stringTruncate:K,translate:ne,customNodeDefinitions:G,customButtons:H,parentData:null,jsonParse:U,jsonStringify:Y,TextEditor:$,errorMessageTimeout:J,handleKeyboard:Ee,keyboardControls:xe,insertAtTop:{object:!0===Z||"object"===Z,array:!0===Z||"array"===Z}},Ce=Object.assign(Object.assign({},q("container",de)),{minWidth:F,maxWidth:z});return Ce.fontSize=null!=I?I:Ce.fontSize,e.jsx("div",{id:B,ref:ce,className:`jer-editor-container ${null!=_?_:""}`,style:Ce,children:s(ie)?e.jsx(ae,Object.assign({data:ie},we)):e.jsx(te,Object.assign({data:ie,showLabel:!0},we))})},ue=(e,t,o,a,i={})=>{if(0===t.length)return{currentData:e,newData:o,currentValue:e,newValue:o};const s=Object.assign({remove:"delete"===a},i),l="add"!==a?r(e,t):void 0;return{currentData:e,newData:n(e,t,o,s),currentValue:l,newValue:"delete"!==a?o:void 0}},pe=(e,t)=>t?()=>!0:"boolean"==typeof e?()=>e:"number"==typeof e?({level:t})=>t>=e:e,ge=e=>{if(void 0!==e)return"value"===e?d:"key"===e?u:"all"===e?(e,t)=>d(e,t)||u(e,t):e},me=e=>Array.isArray(e)&&2===e.length&&["error","value"].includes(e[0]),he=t=>{var n;const{value:r,setIsEditing:o,getStyles:a,nodeData:i}=t,s=a("string",i),{canEdit:l}=q({props:t});return e.jsx("div",{onDoubleClick:()=>o(!0),onClick:e=>{(e.getModifierState("Control")||e.getModifierState("Meta"))&&o(!0)},className:"jer-value-string jer-hyperlink",style:s,children:e.jsx("a",{href:r,target:"_blank",rel:"noreferrer",style:{color:null!==(n=s.color)&&void 0!==n?n:void 0},children:e.jsx(M,Object.assign({},t,{nodeData:i,pathString:p(i.path),styles:s,canEdit:l}))})})},ye={condition:({value:e})=>"string"==typeof e&&/^https?:\/\/.+\..+$/.test(e),element:he,showOnView:!0,showOnEdit:!1};exports.assign=n,exports.extract=r,exports.IconAdd=K,exports.IconCancel=G,exports.IconChevron=H,exports.IconCopy=B,exports.IconDelete=_,exports.IconEdit=L,exports.IconOk=W,exports.JsonEditor=n=>{var r;const[o,a]=t.useState();return t.useEffect((()=>{const e=document.documentElement;a(e)}),[]),o?e.jsx(D,{theme:null!==(r=n.theme)&&void 0!==r?r:x,icons:n.icons,docRoot:o,children:e.jsx(A,{children:e.jsx(de,Object.assign({},n))})}):null},exports.LinkCustomComponent=he,exports.LinkCustomNodeDefinition=ye,exports.StringDisplay=M,exports.candyWrapperTheme={displayName:"Candy Wrapper",fragments:{minty:{backgroundColor:"#F1FAEE"},pale:{color:"#A8DADC"},mid:{color:"#457B9D"},dark:{color:"#1D3557"},pop:{color:"#E63946"},darkBlue:{color:"#2B2D42"}},styles:{container:"minty",property:"pop",dropZone:"#eb121217",bracket:"dark",itemCount:"pale",string:"mid",number:["darkBlue",{fontSize:"85%"}],boolean:["mid",{fontStyle:"italic",fontWeight:"bold",fontSize:"80%"}],null:["#cccccc",{fontWeight:"bold"}],input:{border:"1px solid rgb(115, 194, 198)"},iconCollection:"#1D3557",iconEdit:"#457B9D",iconDelete:"#E63946",iconAdd:"#2B2D42",iconCopy:"#1D3557",iconCancel:"#E63946"}},exports.defaultTheme=x,exports.githubDarkTheme={displayName:"Github Dark",styles:{container:{backgroundColor:"#0d1117",color:"white"},dropZone:"rgba(165, 214, 255, 0.17)",property:"#E6EDF3",bracket:"#56d364",itemCount:"#8B949E",string:"#A5D6FF",number:"#D2A8FF",boolean:{color:"#FF7B72",fontSize:"90%",fontWeight:"bold"},null:"green",iconCollection:"#D2A8FF",iconEdit:"#D2A8FF",iconDelete:"rgb(203, 75, 22)",iconAdd:"rgb(203, 75, 22)",iconCopy:"#A5D6FF",iconOk:"#56d364",iconCancel:"rgb(203, 75, 22)"}},exports.githubLightTheme={displayName:"Github Light",styles:{container:"white",property:"#1F2328",bracket:"#00802e",itemCount:"#8B949E",string:"#0A3069",number:"#953800",boolean:{color:"#CF222E",fontSize:"90%",fontWeight:"bold"},null:"#FF7B72",iconCollection:"#8250DF",iconEdit:"#8250DF",iconDelete:"rgb(203, 75, 22)",iconAdd:"#8250DF",iconCopy:"#57606A"}},exports.isCollection=s,exports.matchNode=d,exports.matchNodeKey=u,exports.monoDarkTheme={displayName:"Black & White",fragments:{lightText:{color:"white"},midGrey:"#5c5c5c"},styles:{container:["lightText",{backgroundColor:"black"}],dropZone:"#e0e0e029",property:"lightText",bracket:"midGrey",itemCount:"#4a4a4a",string:"#a8a8a8",number:"#666666",boolean:{color:"#848484",fontStyle:"italic"},null:"#333333",iconCollection:"midGrey",iconEdit:"midGrey",iconDelete:"midGrey",iconAdd:"midGrey",iconCopy:"midGrey",iconOk:"midGrey",iconCancel:"midGrey"}},exports.monoLightTheme={fragments:{midGrey:"#a3a3a3"},displayName:"White & Black",styles:{container:"white",property:"black",bracket:"midGrey",itemCount:"#b5b5b5",string:"#575757",number:"#999999",boolean:{color:"#7b7b7b",fontStyle:"italic"},null:"#cccccc",iconCollection:"midGrey",iconEdit:"midGrey",iconDelete:"midGrey",iconAdd:"midGrey",iconCopy:"midGrey",iconOk:"midGrey",iconCancel:"midGrey"}},exports.psychedelicTheme={displayName:"Psychedelic",fragments:{pale:{color:"#A8DADC"},fluroYellow:"rgb(242, 228, 21)",fluroGreen:"rgb(68, 255, 62)",hotPink:"#f7379a"},styles:{container:{backgroundColor:"unset",background:"linear-gradient(90deg, hsla(333, 100%, 53%, 1) 0%, hsla(33, 94%, 57%, 1) 100%)",color:"black"},dropZone:"fluroYellow",property:"black",bracket:"fluroYellow",itemCount:["pale",{opacity:.7}],string:"white",number:["#33d9ff",{fontSize:"90%",fontWeight:"bold"}],boolean:["fluroGreen",{fontWeight:"bold",fontSize:"80%"}],null:["black",{fontWeight:"bold",opacity:.3,backgroundColor:"rgb(255, 255, 255, 0.5)",padding:"0 0.4em",borderRadius:"0.4em"}],iconCollection:"fluroYellow",iconEdit:["black"],iconDelete:["white",{opacity:.5}],iconAdd:["white",{opacity:.5}],iconCopy:"rgb(32, 84, 242)",iconOk:"fluroGreen",iconCancel:"hotPink"}};
1
+ "use strict";var e=require("react/jsx-runtime"),t=require("react"),n=require("object-property-assigner"),r=require("object-property-extractor");function o(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}function a(e,t,n,r){return new(n||(n=Promise))((function(o,a){function i(e){try{l(r.next(e))}catch(e){a(e)}}function s(e){try{l(r.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,s)}l((r=r.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const i=({className:t,name:n,value:r,setValue:o,handleKeyPress:a,styles:i,textAreaRef:s})=>{if("string"!=typeof r)return null;const l="\n"===r.slice(-1)?r+".":r;return e.jsxs("div",{style:{display:"grid"},children:[e.jsx("textarea",{id:`${n}_textarea`,ref:s,style:Object.assign({height:"auto",gridArea:"1 / 1 / 2 / 2",overflowY:"auto",whiteSpace:"pre-wrap"},i),rows:1,className:t,name:`${n}_textarea`,value:r,onChange:e=>o(e.target.value),autoFocus:!0,onFocus:e=>{r.length<40&&e.target.select()},onKeyDown:a}),e.jsx("span",{className:t,style:Object.assign({visibility:"hidden",height:"auto",gridArea:"1 / 1 / 2 / 2",color:"red",opacity:.9,whiteSpace:"pre-wrap",overflowY:"auto",border:"1px solid transparent"},i),children:l})]})},s=e=>null!==e&&"object"==typeof e,l=(e,t,n,r="")=>{if(!n&&!r)return!0;switch(e){case"collection":if(n){if(n(t,r))return!0;if(!c(r,t,n))return!1}if(!n&&r&&!c(r,t))return!1;break;case"value":if(n&&!n(t,r))return!1;if(!n&&r&&!d(t,r))return!1}return!0},c=(e="",t,n=d)=>{const r=t.value;return Object.entries(r).some((([o,a])=>{const i=[...t.path,o],l=Object.assign(Object.assign({},t),{key:o,path:i,level:t.level+1,value:a,size:i.length,parentData:r});return s(a)?c(e,l,n):n(l,e)}))},d=(e,t="")=>{const{value:n}=e;if(null===n&&"null".includes(t.toLowerCase()))return!0;switch(typeof n){case"string":return n.toLowerCase().includes(t.toLowerCase());case"number":return!!String(n).includes(t);case"boolean":return n?"true".includes(t.toLowerCase())||"1"===t:"false".includes(t.toLowerCase())||"0"===t;default:return!1}},u=({key:e,path:t},n="")=>!!d({value:e},n)||!!t.some((e=>d({value:e},n))),p=(e,t)=>(null!=t?t:"")+e.map((e=>""===e?String.fromCharCode(0):e)).join("."),g=e=>e.shiftKey?"Shift":e.metaKey?"Meta":e.ctrlKey?"Control":e.altKey?"Alt":void 0,h=(e,t,n)=>{const r=e.key,o=g(e);if(Array.isArray(t))return!!o&&t.includes(o);const{key:a,modifier:i}=t;return("stringLineBreak"!==n||"Enter"!==r||"Shift"!==o||"Enter"!==a||!(null==i?void 0:i.includes("Shift")))&&(r===a&&(i===o||Array.isArray(i)&&i.includes(o)))},m={key:"Enter"},y={confirm:m,cancel:{key:"Escape"},objectConfirm:Object.assign(Object.assign({},m),{modifier:["Meta","Shift","Control"]}),objectLineBreak:m,stringConfirm:m,stringLineBreak:Object.assign(Object.assign({},m),{modifier:["Shift"]}),numberConfirm:m,numberUp:{key:"ArrowUp"},numberDown:{key:"ArrowDown"},tabForward:{key:"Tab"},tabBack:{key:"Tab",modifier:"Shift"},booleanConfirm:m,booleanToggle:{key:" "},clipboardModifier:["Meta","Control"],collapseModifier:["Alt"]},f=(e,t,n="next",o)=>{const a=t.slice(0,t.length-1),i=t.slice(-1)[0];if(void 0===i)return null;const l=r(e,a),c=j(l);Array.isArray(l)||o(c,(({key:e,value:t})=>[e,t]));const d=c.findIndex((e=>e.key===i)),u=c[d+("next"===n?1:-1)];return u?s(u.value)?0===Object.keys(u.value).length?f(e,[...a,u.key],n,o):b(e,[...a,u.key],n,o):[...a,u.key]:0===a.length?null:f(e,a,n,o)},b=(e,t,n="next",o)=>{const a=r(e,t);if(!s(a))return t;const i=Array.isArray(a)?a.map(((e,t)=>t)):Object.keys(a);o(i,(e=>[e,a]));const l="next"===n?i[0]:i[i.length-1];return b(e,[...t,l],n,o)},j=e=>Array.isArray(e)?e.map(((e,t)=>({index:t,value:e,key:t}))):Object.entries(e).map((([e,t],n)=>({key:e,value:t,index:n}))),v=(e,t)=>{var n,r,o,a;const i=e.current,s=null!==(n=null==i?void 0:i.selectionStart)&&void 0!==n?n:1/0,l=null!==(r=null==i?void 0:i.selectionEnd)&&void 0!==r?r:1/0,c=(null===(o=null==i?void 0:i.textContent)||void 0===o?void 0:o.slice(0,s))+t+(null===(a=null==i?void 0:i.textContent)||void 0===a?void 0:a.slice(l));return i.value=c,null==i||i.setSelectionRange(s+1,s+1),c},x={displayName:"Default",fragments:{edit:"rgb(42, 161, 152)"},styles:{container:{backgroundColor:"#f6f6f6",fontFamily:"monospace"},collection:{},collectionInner:{},collectionElement:{},dropZone:{},property:"#292929",bracket:{color:"rgb(0, 43, 54)",fontWeight:"bold"},itemCount:{color:"rgba(0, 0, 0, 0.3)",fontStyle:"italic"},string:"rgb(203, 75, 22)",number:"rgb(38, 139, 210)",boolean:"green",null:{color:"rgb(220, 50, 47)",fontVariant:"small-caps",fontWeight:"bold"},input:["#292929"],inputHighlight:"#b3d8ff",error:{fontSize:"0.8em",color:"red",fontWeight:"bold"},iconCollection:"rgb(0, 43, 54)",iconEdit:"edit",iconDelete:"rgb(203, 75, 22)",iconAdd:"edit",iconCopy:"rgb(38, 139, 210)",iconOk:"green",iconCancel:"rgb(203, 75, 22)"}},E=t.createContext({getStyles:()=>({}),icons:{}}),C=({theme:t=x,icons:n={},docRoot:r,children:o})=>{const a=w(t,r);return e.jsx(E.Provider,{value:{getStyles:(e,t)=>"function"==typeof a[e]?a[e](t):a[e],icons:n},children:o})},D=()=>t.useContext(E),w=(e,t)=>{var n,r,o,a;const i={},s=(Array.isArray(e)?e:[e]).map((e=>O(e)?k({fragments:{},styles:e},i):k(e,i))),l=k(x,{});Object.keys(l).forEach((e=>{const t=e;s.forEach((e=>{e[t]&&(l[t]=Object.assign(Object.assign({},l[t]),e[t]))}))}));const c=Object.assign({},l);return Object.entries(i).forEach((([e,t])=>{const n=e;c[n]=e=>{const r=t(e)||{};return Object.assign(Object.assign({},l[n]),r)}})),"function"!=typeof(null==c?void 0:c.inputHighlight)&&(null===(n=null==c?void 0:c.inputHighlight)||void 0===n?void 0:n.backgroundColor)&&t.style.setProperty("--jer-highlight-color",null===(r=null==c?void 0:c.inputHighlight)||void 0===r?void 0:r.backgroundColor),"function"!=typeof(null==c?void 0:c.iconCopy)&&(null===(o=null==c?void 0:c.iconCopy)||void 0===o?void 0:o.color)&&t.style.setProperty("--jer-icon-copy-color",null===(a=null==c?void 0:c.iconCopy)||void 0===a?void 0:a.color),c},k=(e,t)=>{const{fragments:n,styles:r}=e,o={};return Object.entries(r).forEach((([e,r])=>{const a=(Array.isArray(r)?r:[r]).reduce(((r,o)=>{var a,i;if("function"==typeof o)return t[e]=o,Object.assign({},r);if("string"==typeof o){const t=null!==(a=null==n?void 0:n[o])&&void 0!==a?a:o;return"string"==typeof t?Object.assign(Object.assign({},r),{[null!==(i=S[e])&&void 0!==i?i:"color"]:t}):Object.assign(Object.assign({},r),t)}return Object.assign(Object.assign({},r),o)}),{});o[e]=a})),o},O=e=>!("styles"in e),S={container:"backgroundColor",collection:"backgroundColor",collectionInner:"backgroundColor",collectionElement:"backgroundColor",dropZone:"borderColor",inputHighlight:"backgroundColor"},N=t.createContext(null),A=({children:n,onEditEvent:r,onCollapse:o})=>{const[a,i]=t.useState(null),[s,l]=t.useState(null),[c,d]=t.useState(null),[u,g]=t.useState({path:null,pathString:null}),h=t.useRef(null),m=t.useRef("next"),y=t.useRef(null);return e.jsx(N.Provider,{value:{collapseState:a,setCollapseState:e=>{i(e),o&&null!==e&&(Array.isArray(e)?e.forEach((e=>o(e))):o(e)),null!==e&&setTimeout((()=>i(null)),2e3)},getMatchingCollapseState:e=>{if(Array.isArray(a)){for(const t of a)if(R(e,t))return t;return null}return R(e,a)?a:null},currentlyEditingElement:s,setCurrentlyEditingElement:(e,t)=>{const n="string"==typeof e||null===e?e:p(e,"key"===t?"key_":void 0);null!==s&&null!==n&&null!==h.current&&h.current(),l(n),r&&r(e,"key"===t),h.current="function"==typeof t?t:null},areChildrenBeingEdited:e=>null!==s&&s.includes(e),previouslyEditedElement:y.current,setPreviouslyEditedElement:e=>{y.current=e},tabDirection:m.current,setTabDirection:e=>{m.current=e},previousValue:c,setPreviousValue:d,dragSource:u,setDragSource:g},children:n})},T=()=>{const e=t.useContext(N);if(!e)throw new Error("Missing Context Provider");return e},R=(e,t)=>{if(null===t)return!1;if(!t.includeChildren)return t.path.every(((t,n)=>e[n]===t))&&t.path.length===e.length;for(const[n,r]of t.path.entries())if(r!==e[n])return!1;return!0},M="**INVALID_FUNCTION**",P=({nodeData:n,showStringQuotes:r=!0,stringTruncate:o=200,pathString:a,canEdit:i,setIsEditing:s,styles:l,translate:c})=>{const d=n.value,[u,p]=t.useState(!1),g=r?'"':"",h=d.length>o,m=()=>{i?s(!0):p(!u)};return e.jsxs("div",{id:`${a}_display`,onDoubleClick:m,onClick:e=>{(e.getModifierState("Control")||e.getModifierState("Meta"))&&m()},className:"jer-value-string",style:l,children:[g,h?u?e.jsxs(e.Fragment,{children:[e.jsxs("span",{children:[d,g]}),e.jsxs("span",{className:"jer-string-expansion jer-show-less",onClick:()=>p(!1),children:[" ",c("SHOW_LESS",n)]})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{children:d.slice(0,o-2).trimEnd()}),e.jsx("span",{className:"jer-string-expansion jer-ellipsis",onClick:()=>p(!0),children:"..."}),g]}):`${d}${g}`]})},V=n=>{var{value:r,setValue:a,isEditing:s,path:l,handleEdit:c,nodeData:d,handleKeyboard:u,keyboardCommon:g}=n,h=o(n,["value","setValue","isEditing","path","handleEdit","nodeData","handleKeyboard","keyboardCommon"]);const{getStyles:m}=D(),y=t.useRef(null),f=p(l);return s?e.jsx(i,{className:"jer-input-text",textAreaRef:y,name:f,value:r,setValue:a,isEditing:s,handleKeyPress:e=>{u(e,Object.assign({stringConfirm:c,stringLineBreak:()=>{const e=v(y,"\n");a(e)}},g))},styles:m("input",d)}):e.jsx(P,Object.assign({nodeData:d,pathString:f,styles:m("string",d)},h))},K=({value:t,setValue:n,isEditing:r,path:o,setIsEditing:a,handleEdit:i,nodeData:s,handleKeyboard:l,keyboardCommon:c})=>{const{getStyles:d}=D();return r?e.jsx("input",{className:"jer-input-number",type:"text",name:p(o),value:t,onChange:e=>n(e.target.value.replace(/[^0-9.-]/g,"")),autoFocus:!0,onFocus:e=>setTimeout((()=>e.target.select()),10),onKeyDown:e=>l(e,Object.assign({numberConfirm:i,numberUp:()=>n(Number(t)+1),numberDown:()=>n(Number(t)-1)},c)),style:Object.assign({width:String(t).length/1.5+2+"em"},d("input",s))}):e.jsx("span",{onDoubleClick:()=>a(!0),className:"jer-value-number",style:d("number",s),children:t})},z=({value:t,setValue:n,isEditing:r,path:o,setIsEditing:a,handleEdit:i,nodeData:s,handleKeyboard:l,keyboardCommon:c})=>{const{getStyles:d}=D();return r?e.jsx("input",{className:"jer-input-boolean",type:"checkbox",name:p(o),checked:t,onChange:()=>n(!t),onKeyDown:e=>{" "===e.key&&e.preventDefault(),l(e,Object.assign({booleanConfirm:i,booleanToggle:()=>n(!t)},c))},autoFocus:!0}):e.jsx("span",{onDoubleClick:()=>a(!0),className:"jer-value-boolean",style:d("boolean",s),children:String(t)})},F=({value:n,isEditing:r,setIsEditing:o,handleEdit:a,nodeData:i,handleKeyboard:s,keyboardCommon:l})=>{const{getStyles:c}=D(),d=t.useRef();t.useEffect((()=>{if(r)return d.current=window.setTimeout((()=>window.addEventListener("keydown",u)),100),()=>window.removeEventListener("keydown",u);window.clearTimeout(d.current)}),[r]);const u=e=>s(e,Object.assign({confirm:a},l));return e.jsx("div",{onDoubleClick:()=>o(!0),className:"jer-value-null",style:c("null",i),children:String(n)})},I=({value:t})=>{let n="Error!";switch(typeof t){case"string":t===M&&(n="Function");break;case"undefined":n="Undefined";break;case"symbol":n="Symbol"}return e.jsx("span",{className:"jer-value-invalid",children:n})},L=({size:t,style:n,className:r})=>e.jsxs("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:t,height:t,className:r,style:n,children:[e.jsx("path",{d:"M13 7h-2v4H7v2h4v4h2v-4h4v-2h-4z"}),e.jsx("path",{d:"M12 2C6.486 2 2 6.486 2 12s4.486 10 10 10 10-4.486 10-10S17.514 2 12 2zm0 18c-4.411 0-8-3.589-8-8s3.589-8 8-8 8 3.589 8 8-3.589 8-8 8z"})]}),_=({size:t,style:n,className:r})=>e.jsxs("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:t,height:t,className:r,style:n,transform:"translate(0, 0.5)",children:[e.jsx("path",{d:"M7 17.013l4.413-.015 9.632-9.54c.378-.378.586-.88.586-1.414s-.208-1.036-.586-1.414l-1.586-1.586c-.756-.756-2.075-.752-2.825-.003L7 12.583v4.43zM18.045 4.458l1.589 1.583-1.597 1.582-1.586-1.585 1.594-1.58zM9 13.417l6.03-5.973 1.586 1.586-6.029 5.971L9 15.006v-1.589z"}),e.jsx("path",{d:"M5 21h14c1.103 0 2-.897 2-2v-8.668l-2 2V19H8.158c-.026 0-.053.01-.079.01-.033 0-.066-.009-.1-.01H5V5h6.847l2-2H5c-1.103 0-2 .897-2 2v14c0 1.103.897 2 2 2z"})]}),B=({size:t,style:n,className:r})=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:t,height:t,className:r,style:n,children:e.jsx("path",{d:"M6 19a2 2 0 002 2h8a2 2 0 002-2V7H6v12m2.46-7.12l1.41-1.41L12 12.59l2.12-2.12 1.41 1.41L13.41 14l2.12 2.12-1.41 1.41L12 15.41l-2.12 2.12-1.41-1.41L10.59 14l-2.13-2.12M15.5 4l-1-1h-5l-1 1H5v2h14V4h-3.5z"})}),W=({size:t,style:n,className:r})=>e.jsxs("svg",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",width:t,height:t,className:r,style:n,children:[e.jsx("path",{d:"M9 2 H15 A1 1 0 0 1 16 3 V5 A1 1 0 0 1 15 6 H9 A1 1 0 0 1 8 5 V3 A1 1 0 0 1 9 2 z"}),e.jsx("path",{d:"M8 4H6a2 2 0 00-2 2v14a2 2 0 002 2h12a2 2 0 002-2v-2M16 4h2a2 2 0 012 2v4M21 14H11"}),e.jsx("path",{d:"M15 10l-4 4 4 4"})]}),G=({size:t,style:n,className:r})=>e.jsxs("svg",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",width:t,height:t,className:r,style:n,children:[e.jsx("path",{d:"M22 11.08V12a10 10 0 11-5.93-9.14"}),e.jsx("path",{d:"M22 4L12 14.01l-3-3"})]}),H=({size:t,style:n,className:r})=>e.jsx("svg",{baseProfile:"tiny",viewBox:"0 0 24 24",fill:"currentColor",width:t,height:t,className:r,style:n,children:e.jsx("path",{d:"M12 4c-4.411 0-8 3.589-8 8s3.589 8 8 8 8-3.589 8-8-3.589-8-8-8zm-5 8c0-.832.224-1.604.584-2.295l6.711 6.711A4.943 4.943 0 0112 17c-2.757 0-5-2.243-5-5zm9.416 2.295L9.705 7.584A4.943 4.943 0 0112 7c2.757 0 5 2.243 5 5 0 .832-.224 1.604-.584 2.295z"})}),U=({size:t,style:n,className:r})=>e.jsx("svg",{viewBox:"0 0 512 512",fill:"currentColor",width:t,height:t,className:r,style:n,children:e.jsx("path",{d:"M233.4 406.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L256 338.7 86.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z"})}),Y=({name:t,nodeData:n,rotate:r})=>{var o,a,i,s,l,c,d;const{getStyles:u,icons:p}=D(),g={size:"1.4em",className:"jer-icon"};switch(t){case"add":return null!==(o=null==p?void 0:p.add)&&void 0!==o?o:e.jsx(L,Object.assign({},g,{style:u("iconAdd",n)}));case"edit":return null!==(a=null==p?void 0:p.edit)&&void 0!==a?a:e.jsx(_,Object.assign({},g,{style:u("iconEdit",n)}));case"delete":return null!==(i=null==p?void 0:p.delete)&&void 0!==i?i:e.jsx(B,Object.assign({},g,{style:u("iconDelete",n),size:"1.45em"}));case"copy":return null!==(s=null==p?void 0:p.copy)&&void 0!==s?s:e.jsx(W,Object.assign({},g,{style:u("iconCopy",n),size:"1.2em"}));case"ok":return null!==(l=null==p?void 0:p.ok)&&void 0!==l?l:e.jsx(G,Object.assign({},g,{style:Object.assign({fontSize:"90%"},u("iconOk",n))}));case"cancel":return null!==(c=null==p?void 0:p.cancel)&&void 0!==c?c:e.jsx(H,Object.assign({},g,{style:Object.assign({fontSize:"130%"},u("iconCancel",n))}));case"chevron":return null!==(d=null==p?void 0:p.chevron)&&void 0!==d?d:e.jsx(U,{size:"1em",style:u("iconCollection",n)});default:return e.jsx(e.Fragment,{})}},$=({startEdit:n,handleDelete:r,handleAdd:o,enableClipboard:a,type:i,customButtons:s,nodeData:l,translate:c,keyboardControls:d,handleKeyboard:u,editConfirmRef:p})=>{const{getStyles:h}=D(),m=c("KEY_NEW",l),[y,f]=t.useState(!1),[b,j]=t.useState(m),{key:v,path:x,value:E}=l;return e.jsxs("div",{className:"jer-edit-buttons",style:{opacity:y?1:void 0},children:[a&&e.jsx("div",{onClick:e=>{var t;e.stopPropagation();let n,r,o="value",s="",l=null;if(a){const c=g(e);if(c&&d.clipboardModifier.includes(c)?(n=Z(x),s=n,o="path"):(n=E,s=i?JSON.stringify(E,null,2):String(n)),!navigator.clipboard)return void("function"==typeof a&&a({success:!1,value:n,stringValue:s,path:x,key:v,type:o,errorMessage:"Can't access clipboard API"}));null===(t=navigator.clipboard)||void 0===t||t.writeText(s).then((()=>r=!0)).catch((e=>{r=!1,l=e.message})).finally((()=>{"function"==typeof a&&a({success:r,errorMessage:l,value:n,stringValue:s,path:x,key:v,type:o})}))}},className:"jer-copy-pulse",children:e.jsx(Y,{name:"copy",nodeData:l})}),n&&e.jsx("div",{onClick:e=>{e.stopPropagation(),n()},children:e.jsx(Y,{name:"edit",nodeData:l})}),r&&e.jsx("div",{onClick:e=>{e.stopPropagation(),r()},children:e.jsx(Y,{name:"delete",nodeData:l})}),o&&e.jsx("div",{onClick:e=>{e.stopPropagation(),"object"===i?f(!0):o("")},children:e.jsx(Y,{name:"add",nodeData:l})}),null==s?void 0:s.map((({Element:t,onClick:n},r)=>e.jsx("div",{onClick:e=>n&&n(l,e),children:e.jsx(t,{nodeData:l})},r))),y&&o&&"object"===i&&e.jsxs(e.Fragment,{children:[e.jsx("input",{className:"jer-input-new-key",type:"text",name:"new-object-key",value:b,onChange:e=>j(e.target.value),onClick:e=>e.stopPropagation(),autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>{u(e,{stringConfirm:()=>{o&&(f(!1),o(b),j(m))},cancel:()=>{f(!1),j(m)}})},style:h("input",l)}),e.jsx(J,{onOk:e=>{b&&(e.stopPropagation(),f(!1),o(b))},onCancel:e=>{e.stopPropagation(),f(!1)},nodeData:l,editConfirmRef:p})]})]})},J=({onOk:t,onCancel:n,nodeData:r,editConfirmRef:o})=>e.jsxs("div",{className:"jer-confirm-buttons",children:[e.jsx("div",{onClick:t,ref:o,children:e.jsx(Y,{name:"ok",nodeData:r})}),e.jsx("div",{onClick:n,children:e.jsx(Y,{name:"cancel",nodeData:r})})]}),Z=e=>e.reduce(((e,t)=>"number"==typeof t?`${e}[${t}]`:""===e?t:`${e}.${t}`),""),X=["string","number","boolean","null","object","array"],q=(e=[],t)=>{const n=e.filter((({condition:e})=>e(t)));if(0===n.length)return{};const r=n[0],{element:a,wrapperElement:i,customNodeProps:s,wrapperProps:l,hideKey:c=!1,showEditTools:d=!0,showOnEdit:u=!1,showOnView:p=!0,showCollectionWrapper:g=!0}=r,h=o(r,["element","wrapperElement","customNodeProps","wrapperProps","hideKey","showEditTools","showOnEdit","showOnView","showCollectionWrapper"]);return Object.assign({CustomNode:a,CustomWrapper:i,customNodeProps:s,wrapperProps:l,hideKey:c,showEditTools:d,showOnEdit:u,showOnView:p,showCollectionWrapper:g},h)},Q=({props:e,collapsed:n})=>{const{data:r,nodeData:o,parentData:a,onEdit:i,onError:s,showErrorMessages:l,restrictEditFilter:c,restrictDeleteFilter:d,restrictAddFilter:u,restrictDragFilter:g,translate:h,errorMessageTimeout:m}=e,{currentlyEditingElement:y,setCurrentlyEditingElement:f}=T(),[b,j]=t.useState(null),v=Object.assign(Object.assign({},o),{collapsed:n}),{path:x,key:E,size:C}=v,D=p(x),w=t.useMemo((()=>!c(v)),[v]),k=t.useMemo((()=>!d(v)),[v]),O=t.useMemo((()=>!u(v)),[v]),S=t.useMemo((()=>!g(v)&&k&&null===y),[v]),N=e=>{l&&(j(e),setTimeout((()=>j(null)),m)),console.warn("Error",e)},A=t.useMemo((()=>(e,t)=>{N(e.message),s&&s({currentData:v.fullData,errorValue:t,currentValue:r,name:E,path:x,error:e})}),[s,l]),R=y===D,M=y===`key_${D}`,P="number"==typeof x.slice(-1)[0];return{pathString:D,nodeData:v,path:x,name:E,size:C,canEdit:w,canDelete:k,canAdd:O,canDrag:S,error:b,showError:N,onError:A,setError:j,handleEditKey:e=>{if(f(null),E===e)return;if(!a)return;const t=x.slice(0,-1);if(Object.keys(a).includes(e))return void A({code:"KEY_EXISTS",message:h("ERROR_KEY_EXISTS",v)},e);const n=Object.fromEntries(Object.entries(a).map((([t,n])=>t===E?[e,n]:[t,n])));i(n,t).then((t=>{t&&A({code:"UPDATE_ERROR",message:t},e)}))},derivedValues:{isEditing:R,isEditingKey:M,isArray:P,canEditKey:null!==a&&w&&O&&k&&!P}}},ee=({canDrag:n,canDragOnto:r,path:o,nodeData:a,onMove:i,onError:s,translate:l})=>{const{getStyles:c}=D(),{dragSource:d,setDragSource:u}=T(),[g,h]=t.useState(!1),m=p(o),y=t.useMemo((()=>n?{onDragStart:e=>{e.stopPropagation(),u({path:o,pathString:m})},onDragEnd:e=>{e.stopPropagation(),u({path:null,pathString:null})}}:{}),[n]),f=t.useMemo((()=>e=>r?{onDragOver:e=>{e.stopPropagation(),e.preventDefault()},onDrop:t=>{t.stopPropagation(),j(e),u({path:null,pathString:null}),h(!1)},onDragEnter:t=>{var n;t.stopPropagation(),m.startsWith(null!==(n=d.pathString)&&void 0!==n?n:"")||h(e)},onDragExit:e=>{e.stopPropagation(),h(!1)}}:{}),[d,r]),b=t.useMemo((()=>r&&null!==d.pathString?e.jsx("div",Object.assign({className:"jer-drop-target-bottom",style:{height:"50%",position:"absolute",width:"100%",top:"50%",zIndex:o.length}},f("below"))):null),[d,r]),j=e=>{var t,n;const r=null===(t=d.path)||void 0===t?void 0:t.slice(-1)[0],c=null===(n=d.path)||void 0===n?void 0:n.slice(0,-1).join("."),u=o.slice(0,-1).join(""),{parentData:p}=a;"string"==typeof r&&p&&!Array.isArray(p)&&Object.keys(p).includes(r)&&r in p&&c!==u?s({code:"KEY_EXISTS",message:l("ERROR_KEY_EXISTS",a)},r):i(d.path,o,e).then((e=>{e&&s({code:"UPDATE_ERROR",message:e},a.value)}))};return{dragSourceProps:y,getDropTargetProps:f,BottomDropTarget:b,DropTargetPadding:({position:t,nodeData:n})=>g===t?e.jsx("div",{className:"jer-drag-n-drop-padding",style:c("dropZone",n)}):null,handleDrop:j}},te=(e,t,n)=>{var r,o,a;const i=parseInt(null!==(r=getComputedStyle(n.current).getPropertyValue("line-height"))&&void 0!==r?r:"16px"),s=(null!==(a=null===(o=t.current)||void 0===o?void 0:o.offsetWidth)&&void 0!==a?a:0)/(.5*i),l=JSON.stringify(e,null,2).replace(/\\n/g,"\n").split("\n").map((e=>Math.ceil(e.length/s))).reduce(((e,t)=>e+t),0)*i;return Math.min(l+30,window.innerHeight-50)},ne=({isEditingKey:t,canEditKey:n,pathString:r,path:o,name:a,handleKeyboard:i,handleEditKey:s,handleCancel:l,handleClick:c,keyValueArray:d,styles:u,getNextOrPrevious:p})=>{const{setCurrentlyEditingElement:g}=T();return t?e.jsx("input",{className:"jer-input-text jer-key-edit",type:"text",name:r,defaultValue:a,autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>i(e,{stringConfirm:()=>s(e.target.value),cancel:l,tabForward:()=>{if(s(e.target.value),d){const e=null==d?void 0:d[0][0];g(e?[...o,e]:p("next"))}else g(o)},tabBack:()=>{s(e.target.value),g(p("prev"))}}),style:{width:String(a).length/1.5+.5+"em"}}):e.jsxs("span",{className:"jer-key-text",style:Object.assign(Object.assign({},u),{minWidth:`${Math.min(String(a).length+1,5)}ch`,flexShrink:a.length>10?1:0}),onDoubleClick:()=>n&&g(o,"key"),onClick:c,children:[""===a?e.jsx("span",{className:o.length>0?"jer-empty-string":void 0}):`${a}`,e.jsx("span",{className:"jer-key-colon",children:":"})]})},re=n=>{const{data:r,parentData:o,onEdit:a,onDelete:i,onChange:s,onMove:c,enableClipboard:d,canDragOnto:u,restrictTypeSelection:p,searchFilter:g,searchText:h,showLabel:m,stringTruncate:y,showStringQuotes:b,indent:j,translate:v,customNodeDefinitions:x,handleKeyboard:E,keyboardControls:C,sort:w,editConfirmRef:k}=n,{getStyles:O}=D(),{setCurrentlyEditingElement:S,setCollapseState:N,previouslyEditedElement:A,setPreviouslyEditedElement:R,tabDirection:P,setTabDirection:V,previousValue:K,setPreviousValue:z}=T(),[F,I]=t.useState("function"==typeof r?M:r),{pathString:L,nodeData:_,path:B,name:W,canEdit:G,canDelete:H,canDrag:U,error:Y,onError:Z,handleEditKey:te,derivedValues:re}=Q({props:n}),{dragSourceProps:se,getDropTargetProps:le,BottomDropTarget:ce,DropTargetPadding:de}=ee({canDrag:U,canDragOnto:u,path:B,nodeData:_,onMove:c,onError:Z,translate:v}),ue=q(x,_),[pe,ge]=t.useState(oe(r,ue)),he=t.useCallback((e=>{if(!s)return void I(e);const t=s({currentData:_.fullData,newValue:e,currentValue:F,name:W,path:B});I(t)}),[s]);t.useEffect((()=>{I("function"==typeof r?M:r),ge(oe(r,ue))}),[r,Y]);const{CustomNode:me,customNodeProps:ye,hideKey:fe,showEditTools:be=!0,showOnEdit:je,showOnView:ve,passOriginalNode:xe}=ue,Ee=[...X,...x.filter((({showInTypesSelector:e=!1,name:t})=>e&&!!t)).map((({name:e})=>e))],Ce=t.useMemo((()=>{if("boolean"==typeof p)return p?[]:Ee;if(Array.isArray(p))return p;const e=p(_);return"boolean"==typeof e?e?[]:Ee:e}),[_,p]),{isEditing:De}=re,we=l("value",_,g,h);if(De&&(!we||!G)){const e=f(_.fullData,B,P,w);S(e||A)}if(!we)return null;const ke=()=>{let e;switch(S(null),z(null),pe){case"object":e={[v("DEFAULT_NEW_KEY",_)]:F};break;case"array":e=null!=F?F:[];break;case"number":{const t=Number(F);e=isNaN(t)?0:t;break}default:e=F}a(e,B).then((t=>{t&&Z({code:"UPDATE_ERROR",message:t},e)}))},Oe=()=>{S(null),null===K?(I(r),z(null)):a(K,B)},{isEditingKey:Se,canEditKey:Ne}=re,Ae=!De&&Y,Te=De&&Ce.length>0,Re="invalid"!==pe&&!Y&&be,Me=m&&!fe,Pe=me&&(De&&je||!De&&ve),Ve={value:F,parentData:o,setValue:he,isEditing:De,canEdit:G,setIsEditing:G?()=>S(B):()=>{},handleEdit:ke,handleCancel:Oe,path:B,stringTruncate:y,showStringQuotes:b,nodeData:_,translate:v,handleKeyboard:E,keyboardCommon:{cancel:Oe,tabForward:()=>{V("next"),R(L);const e=f(_.fullData,B,"next",w);e&&(ke(),S(e))},tabBack:()=>{V("prev"),R(L);const e=f(_.fullData,B,"prev",w);e&&(ke(),S(e))}}},Ke={canEditKey:Ne,isEditingKey:Se,pathString:L,path:B,name:W,handleKeyboard:E,handleEditKey:te,handleCancel:Oe,styles:O("property",_),getNextOrPrevious:e=>f(_.fullData,B,e,w)},ze=Pe?e.jsx(me,Object.assign({},n,{value:F,customNodeProps:ye,setValue:he,handleEdit:ke,handleCancel:Oe,handleKeyPress:e=>E(e,{stringConfirm:ke,cancel:Oe}),isEditing:De,setIsEditing:()=>S(B),getStyles:O,originalNode:xe?ae(r,Ve):void 0,originalNodeKey:xe?e.jsx(ne,Object.assign({},Ke)):void 0})):ae(r,Ve);return e.jsxs("div",Object.assign({className:"jer-component jer-value-component",style:{marginLeft:j/2+"em",position:"relative"},draggable:U},se,le("above"),{children:[ce,e.jsx(de,{position:"above",nodeData:_}),e.jsxs("div",{className:"jer-value-main-row",style:{flexWrap:W.length>10?"wrap":"nowrap"},children:[Me&&e.jsx(ne,Object.assign({},Ke)),e.jsxs("div",{className:"jer-value-and-buttons",children:[e.jsx("div",{className:"jer-input-component",children:ze}),De?e.jsx(J,{onOk:ke,onCancel:Oe,nodeData:_,editConfirmRef:k}):Re&&e.jsx($,{startEdit:G?()=>{z(F),S(B,Oe)}:void 0,handleDelete:H?()=>{i(F,B).then((e=>{e&&Z({code:"DELETE_ERROR",message:e},F)}))}:void 0,enableClipboard:d,translate:v,customButtons:n.customButtons,nodeData:_,handleKeyboard:E,keyboardControls:C,editConfirmRef:k}),Te&&e.jsxs("div",{className:"jer-select",children:[e.jsx("select",{name:`${W}-type-select`,className:"jer-type-select",onChange:e=>(e=>{const t=x.find((t=>t.name===e));if(t)a(t.defaultValue,B),ge(e),S(null),N({path:B,collapsed:!1,includeChildren:!1});else{const t=ie(F,e,v("DEFAULT_NEW_KEY",_),(null==ue?void 0:ue.CustomNode)?v("DEFAULT_STRING",_):void 0);a(t,B).then((e=>{e&&(Z({code:"UPDATE_ERROR",message:e},t),S(null))}))}})(e.target.value),value:pe,children:Ce.map((t=>e.jsx("option",{value:t,children:t},t)))}),e.jsx("span",{className:"focus"})]}),Ae&&e.jsx("span",{className:"jer-error-slug",style:O("error",_),children:Y})]})]}),e.jsx(de,{position:"below",nodeData:_})]}))},oe=(e,t)=>(null==t?void 0:t.CustomNode)&&(null==t?void 0:t.name)&&t.showInTypesSelector?t.name:"string"==typeof e?"string":"number"==typeof e?"number":"boolean"==typeof e?"boolean":null===e?"null":"invalid",ae=(t,n)=>{const r=oe(t),{value:o}=n;switch(r){case"string":return e.jsx(V,Object.assign({},n,{value:o}));case"number":return e.jsx(K,Object.assign({},n,{value:o}));case"boolean":return e.jsx(z,Object.assign({},n,{value:o}));case"null":return e.jsx(F,Object.assign({},n));default:return e.jsx(I,Object.assign({},n))}},ie=(e,t,n,r)=>{switch(t){case"string":return null!=r?r:String(e);case"number":{const t=Number(e);return isNaN(t)?0:t}case"boolean":return!!e;case"null":return null;case"object":return{[n]:e};case"array":return[e];default:return String(e)}},se=n=>{const{getStyles:r}=D(),{collapseState:o,setCollapseState:c,getMatchingCollapseState:d,currentlyEditingElement:u,setCurrentlyEditingElement:p,areChildrenBeingEdited:h,previousValue:m,setPreviousValue:y}=T(),{mainContainerRef:b,data:j,nodeData:x,parentData:E,showCollectionCount:C,onEdit:w,onAdd:k,onDelete:O,canDragOnto:S,collapseFilter:N,collapseAnimationTime:A,onMove:R,enableClipboard:M,searchFilter:P,searchText:V,indent:K,sort:z,showArrayIndices:F,defaultValue:I,translate:L,customNodeDefinitions:_,jsonParse:B,jsonStringify:W,TextEditor:G,keyboardControls:H,handleKeyboard:U,insertAtTop:Z,onCollapse:X,editConfirmRef:oe,collapseClickZones:ae}=n,[ie,le]=t.useState(W(j)),ce=N(x),{contentRef:de,isAnimating:ue,maxHeight:pe,collapsed:ge,animateCollapse:he,cssTransitionValue:me}=((e,n,r,o)=>{const[a,i]=t.useState(r?0:void 0),[s,l]=t.useState(r),c=t.useRef(!1),d=t.useRef(null),u=t.useRef(0),p=t.useRef(),g=n/1e3+"s";return{contentRef:d,isAnimating:c.current,animateCollapse:t=>{var r,a;if(s!==t){switch(window.clearTimeout(p.current),c.current=!0,t){case!0:{const e=null!==(a=null===(r=d.current)||void 0===r?void 0:r.offsetHeight)&&void 0!==a?a:0;u.current=e,i(e),setTimeout((()=>{i(0)}),5);break}case!1:i(u.current||te(e,d,o))}l(!s),p.current=window.setTimeout((()=>{c.current=!1,t||i(void 0)}),n)}},maxHeight:a,collapsed:s,cssTransitionValue:g}})(j,A,ce,b),{pathString:ye,nodeData:fe,path:be,name:je,size:ve,canEdit:xe,canDelete:Ee,canAdd:Ce,canDrag:De,error:we,setError:ke,onError:Oe,handleEditKey:Se,derivedValues:Ne}=Q({props:n,collapsed:ge}),{dragSourceProps:Ae,getDropTargetProps:Te,BottomDropTarget:Re,DropTargetPadding:Me}=ee({canDrag:De,canDragOnto:S,path:be,nodeData:fe,onMove:R,onError:Oe,translate:L}),Pe=t.useRef(!ce),{isEditing:Ve,isEditingKey:Ke,isArray:ze,canEditKey:Fe}=Ne;t.useEffect((()=>{le(W(j))}),[j]),t.useEffect((()=>{const e=N(fe)&&!Ve;Pe.current=!e,he(e)}),[N]),t.useEffect((()=>{if(null!==o){const e=d(be);e&&(Pe.current=!0,he(e.collapsed))}}),[o]);const Ie=t.useRef(null),Le=t.useMemo((()=>(e,t)=>"function"!=typeof I?I:I(e,t)),[I]),{CustomNode:_e,customNodeProps:Be,CustomWrapper:We,wrapperProps:Ge={},hideKey:He,showEditTools:Ue=!0,showOnEdit:Ye,showOnView:$e,showCollectionWrapper:Je=!0}=t.useMemo((()=>q(_,fe)),[j]),Ze=h(ye);Ze&&ge&&he(!1);if(!(l("collection",fe,P,V)||0===fe.level)&&!Ze)return null;const Xe=Array.isArray(j)?"array":"object",qe="array"===Xe?{open:"[",close:"]"}:{open:"{",close:"}"},Qe=e=>{if("Tab"!==e.key||e.getModifierState("Shift"))U(e,{objectConfirm:tt,cancel:rt});else{e.preventDefault();const t=v(Ie,"\t");le(t)}},et=e=>{e.stopPropagation();const t=g(e);if(t&&H.collapseModifier.includes(t))return Pe.current=!0,void c({collapsed:!ge,path:be,includeChildren:!0});u&&u.includes(ye)||(Pe.current=!0,c(null),X&&X({path:be,collapsed:!ge,includeChildren:!1}),he(!ge))},tt=()=>{try{const e=B(ie);if(p(null),y(null),ke(null),JSON.stringify(e)===JSON.stringify(j))return;w(e,be).then((t=>{t&&Oe({code:"UPDATE_ERROR",message:t},e)}))}catch(e){Oe({code:"INVALID_JSON",message:L("ERROR_INVALID_JSON",fe)},ie)}},nt=be.length>0?()=>{O(j,be).then((e=>{e&&Oe({code:"DELETE_ERROR",message:e},j)}))}:void 0,rt=()=>{p(null),null===m?(ke(null),le(W(j)),y(null)):w(m,be)},ot="when-closed"===C?ge:C,at=!Ve&&Ue,it=(F||!ze)&&!He&&void 0!==je,st=_e&&(Ve&&Ye||!Ve&&$e),lt=Object.entries(j).map((([e,t])=>["array"===Xe?Number(e):e,t]));"object"===Xe&&z(lt,(e=>e));const ct=Pe.current?Ve?e.jsxs("div",{className:"jer-collection-text-edit",children:[G?e.jsx(G,{value:ie,onChange:le,onKeyDown:e=>U(e,{objectConfirm:tt,cancel:rt})}):e.jsx(i,{textAreaRef:Ie,className:"jer-collection-text-area",name:ye,value:ie,setValue:le,isEditing:Ve,handleKeyPress:Qe,styles:r("input",fe)}),e.jsx("div",{className:"jer-collection-input-button-row",children:e.jsx(J,{onOk:tt,onCancel:rt,nodeData:fe,editConfirmRef:oe})})]}):lt.map((([t,o],a)=>{const i={key:t,value:o,path:[...be,t],level:be.length+1,index:a,size:s(o)?Object.keys(o).length:1,parentData:j,fullData:fe.fullData};return e.jsx("div",{className:"jer-collection-element",style:r("collectionElement",i),children:s(o)?e.jsx(se,Object.assign({},n,{data:o,parentData:j,nodeData:i,showCollectionCount:C,canDragOnto:xe}),t):e.jsx(re,Object.assign({},n,{data:o,parentData:j,nodeData:i,canDragOnto:xe,showLabel:"object"===Xe||F}),t)},t)})):null,dt=!!Je&&(ge&&!Ze);dt||(Pe.current=!0);const ut=Object.assign(Object.assign({},n),{data:j,value:j,parentData:E,nodeData:fe,setValue:e=>a(void 0,void 0,void 0,(function*(){return yield w(e,be)})),handleEdit:tt,handleCancel:rt,handleKeyPress:Qe,isEditing:Ve,setIsEditing:()=>p(be),getStyles:r,canDragOnto:xe}),pt=st?e.jsx(_e,Object.assign({customNodeProps:Be},ut,{children:ct})):ct,gt=at&&e.jsx($,{startEdit:xe?()=>{Pe.current=!0,y(null),p(be)}:void 0,handleAdd:Ce?e=>{he(!1);const t=Le(fe,e);if("array"===Xe){const e=Z.array?0:j.length,n=Z.array?{insert:!0}:{};k(t,[...be,e],n).then((e=>{e&&Oe({code:"ADD_ERROR",message:e},t)}))}else if(e in j)Oe({code:"KEY_EXISTS",message:L("ERROR_KEY_EXISTS",fe)},e);else{const n=Z.object?{insertBefore:0}:{};k(t,[...be,e],n).then((e=>{e&&Oe({code:"ADD_ERROR",message:e},t)}))}}:void 0,handleDelete:Ee?nt:void 0,enableClipboard:M,type:Xe,nodeData:fe,translate:L,customButtons:n.customButtons,keyboardControls:H,handleKeyboard:U,editConfirmRef:oe}),ht={canEditKey:Fe,isEditingKey:Ke,pathString:ye,path:be,name:je,handleKeyboard:U,handleEditKey:Se,handleCancel:rt,keyValueArray:lt,styles:r("property",fe),getNextOrPrevious:e=>f(fe.fullData,be,e,z),handleClick:ae.includes("property")?et:e=>e.stopPropagation()},mt=e.jsxs("div",Object.assign({className:"jer-component jer-collection-component",style:Object.assign(Object.assign({marginLeft:(0===be.length?0:K/2)+"em"},r("collection",fe)),{position:"relative"}),draggable:De},Ae,Te("above"),{children:[e.jsx("div",{className:"jer-clickzone",style:{width:K/2+1+"em",zIndex:10+2*fe.level},onClick:ae.includes("left")?et:void 0}),!Ve&&Re,e.jsx(Me,{position:"above",nodeData:fe}),Je?e.jsxs("div",{className:"jer-collection-header-row",style:{position:"relative"},onClick:ae.includes("header")?et:void 0,children:[e.jsxs("div",{className:"jer-collection-name",children:[e.jsx("div",{className:"jer-collapse-icon jer-accordion-icon"+(ge?" jer-rotate-90":""),style:{zIndex:11+2*fe.level,transition:me},onClick:et,children:e.jsx(Y,{name:"chevron",rotate:ge,nodeData:fe})}),it&&e.jsx(ne,Object.assign({},ht)),!Ve&&e.jsx("span",{className:"jer-brackets jer-bracket-open",style:r("bracket",fe),children:qe.open})]}),!Ve&&ot&&e.jsx("div",{className:"jer-collection-item-count"+(ot?" jer-visible":" jer-hidden"),style:Object.assign(Object.assign({},r("itemCount",fe)),{transition:me}),children:1===ve?L("ITEM_SINGLE",Object.assign(Object.assign({},fe),{size:1}),1):L("ITEMS_MULTIPLE",fe,ve)}),e.jsx("div",{className:"jer-brackets"+(dt?" jer-visible":" jer-hidden"),style:Object.assign(Object.assign({},r("bracket",fe)),{transition:me}),children:qe.close}),gt]}):He?e.jsx(e.Fragment,{}):e.jsxs("div",{className:"jer-collection-header-row",style:{position:"relative"},children:[e.jsx(ne,Object.assign({},ht)),gt]}),e.jsxs("div",{className:"jer-collection-inner",style:Object.assign(Object.assign({overflowY:dt||ue?"clip":"visible",maxHeight:Ze?void 0:pe},r("collectionInner",fe)),{transition:me}),ref:de,children:[pt,e.jsx("div",{className:Ve?"jer-collection-error-row":"jer-collection-error-row-edit",children:we&&e.jsx("span",{className:"jer-error-slug",style:r("error",fe),children:we})}),!Ve&&Je&&e.jsx("div",{className:"jer-brackets jer-bracket-outside",style:Object.assign(Object.assign({},r("bracket",fe)),{marginLeft:(K<3?-1:K<6?-.5:0)+"em"}),children:qe.close})]}),e.jsx(Me,{position:"below",nodeData:fe})]}));return We?e.jsx(We,Object.assign({customNodeProps:Ge},ut,{children:mt})):mt},le={ITEM_SINGLE:"{{count}} item",ITEMS_MULTIPLE:"{{count}} items",KEY_NEW:"Enter new key",ERROR_KEY_EXISTS:"Key already exists",ERROR_INVALID_JSON:"Invalid JSON",ERROR_UPDATE:"Update unsuccessful",ERROR_DELETE:"Delete unsuccessful",ERROR_ADD:"Adding node unsuccessful",DEFAULT_STRING:"New data!",DEFAULT_NEW_KEY:"key",SHOW_LESS:"(Show less)"},ce=(e,t)=>(n,r,o)=>((e,t,n,r,o)=>{if(t[r]){const e=t[r](n);if(null!==e)return e}const a=r in e?e[r]:le[r];return void 0===o?a:null==a?void 0:a.replace("{{count}}",String(o))})(e,t,r,n,o);var de=[],ue=[];!function(e,t){if(e&&"undefined"!=typeof document){var n,r=!0===t.prepend?"prepend":"append",o=!0===t.singleTag,a="string"==typeof t.container?document.querySelector(t.container):document.getElementsByTagName("head")[0];if(o){var i=de.indexOf(a);-1===i&&(i=de.push(a)-1,ue[i]={}),n=ue[i]&&ue[i][r]?ue[i][r]:ue[i][r]=s()}else n=s();65279===e.charCodeAt(0)&&(e=e.substring(1)),n.styleSheet?n.styleSheet.cssText+=e:n.appendChild(document.createTextNode(e))}function s(){var e=document.createElement("style");if(e.setAttribute("type","text/css"),t.attributes)for(var n=Object.keys(t.attributes),o=0;o<n.length;o++)e.setAttribute(n[o],t.attributes[n[o]]);var i="prepend"===r?"afterbegin":"beforeend";return a.insertAdjacentElement(i,e),e}}(':root{--jer-select-border:#b6b6b6;--jer-select-focus:#777;--jer-select-arrow:#777;--jer-form-border:1px solid #ededf0;--jer-form-border-focus:1px solid #e2e2e2;--jer-highlight-color:#b3d8ff}.jer-visible{opacity:1}.jer-hidden{opacity:0}.jer-select select{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:transparent;border:none;color:#000;cursor:inherit;font-family:inherit;font-size:.8em;line-height:inherit;margin:0;outline:none;padding:0 1em 0 0;z-index:1}select::-ms-expand{display:none}.jer-select{align-items:center;background-color:#fff;background-image:linear-gradient(0deg,#f9f9f9,#fff 33%);border:1px solid var(--jer-select-border);border-radius:.25em;cursor:pointer;display:grid;grid-template-areas:"select";line-height:1.1;max-width:15ch;min-width:12ch;padding:.25em .5em;position:relative}.jer-select select,.jer-select:after{grid-area:select}.jer-select:not(.jer-select--multiple):after{background-color:var(--jer-select-arrow);clip-path:polygon(100% 0,0 0,50% 100%);content:"";height:.5em;justify-self:end;width:.8em}select:focus+.focus{border:1px solid var(--jer-select-focus);border-radius:inherit;bottom:-1px;left:-1px;position:absolute;right:-1px;top:-1px}.jer-editor-container{border-radius:.5em;font-size:16px;line-height:1;padding:1em 1em 1em 2em;position:relative;text-align:left}.jer-editor-container textarea{border:var(--jer-form-border);border-radius:.3em;color:var(--jer-input-color);outline:none}.jer-editor-container textarea:focus{border:var(--jer-form-border-focus)}.jer-editor-container input{border:var(--jer-form-border);border-radius:.3em;font-family:inherit;outline:none}.jer-editor-container input:focus{border:var(--jer-form-border-focus)}.jer-editor-container ::selection{background-color:var(--jer-highlight-color)}.jer-collection-header-row,.jer-value-main-row{align-items:center;display:flex;gap:.3em;min-height:1.7em}.jer-collection-header-row{display:flex;flex-wrap:wrap}.jer-collapse-icon{left:-1.2em;position:absolute;top:.35em}.jer-collection-inner{position:relative}.jer-collection-text-edit{align-items:flex-start;display:flex;flex-direction:column;gap:.3em;line-height:1.1em}.jer-collection-text-area{font-family:inherit;font-size:.85em;max-height:40em;overflow:hidden;padding:.2em .5em 0;resize:both}.jer-collection-input-button-row{display:flex;font-size:150%;justify-content:flex-end;margin-top:.4em;width:100%}.jer-collection-error-row{bottom:.5em;position:absolute}.jer-error-slug{margin-left:1em}.jer-value-component{position:relative}.jer-value-main-row{display:flex;gap:0}.jer-value-and-buttons{align-items:center;display:flex;justify-content:flex-start;padding-left:.5em}.jer-value-error-row{position:absolute}.jer-value-string{line-height:1.3em;overflow-wrap:anywhere;white-space:pre-wrap;word-break:break-word}.jer-string-expansion{cursor:pointer;filter:saturate(50%);opacity:.6}.jer-show-less{font-size:80%}.jer-hyperlink{text-decoration:underline}.jer-input-text{font-family:inherit;font-size:.9em;height:1.4em;line-height:1.2em;margin:0;min-width:6em;overflow:hidden;padding:.25em .5em .2em;resize:none}.jer-input-boolean{margin-left:.3em;margin-right:.3em;transform:scale(1.5)}.jer-key-text{line-height:1.1em;white-space:pre-wrap;word-break:break-word}.jer-key-edit{font-size:inherit;font-size:.9em;padding:0 .3em}.jer-value-invalid{font-style:italic;opacity:.5}.jer-input-number{font-size:90%;min-width:3em}.jer-confirm-buttons,.jer-edit-buttons{align-items:center;cursor:pointer;display:flex;height:1em}.jer-input-buttons{gap:.4em}.jer-edit-buttons{gap:.4em;margin-left:.5em;opacity:0}.jer-confirm-buttons{gap:.2em;margin-left:.4em}.jer-edit-buttons:hover{opacity:1;position:relative}.jer-collection-header-row:hover>.jer-edit-buttons,.jer-value-and-buttons:hover>.jer-edit-buttons,.jer-value-main-row:hover>.jer-edit-buttons{opacity:1}.jer-copy-pulse{position:relative;transition:.3s}.jer-copy-pulse:hover{opacity:.85;transform:scale(1.2);transition:.3s}.jer-copy-pulse:after{border-radius:50%;box-shadow:0 0 15px 5px var(--jer-icon-copy-color);content:"";display:block;height:100%;left:0;opacity:0;position:absolute;top:0;transition:all .5s;width:100%}.jer-copy-pulse:active:after{border-radius:4em;box-shadow:0 0 0 0 var(--jer-icon-copy-color);left:0;opacity:1;position:absolute;top:0;transition:0s}.jer-copy-pulse:active{top:.07em}.jer-rotate-90{transform:rotate(-90deg)}.jer-icon:hover{opacity:.85;transform:scale(1.2);transition:.3s}.jer-empty-string:after{content:"<empty string>";font-size:90%;font-style:italic}.jer-drag-n-drop-padding{border:1px dashed #e0e0e0;border-radius:.3em;height:.5em}.jer-clickzone{height:calc(100% - .8em);left:-1em;position:absolute;top:1.2em}',{});const pe=({data:n,setData:r,rootName:o="root",onUpdate:i=(()=>{}),onEdit:l=i,onDelete:c=i,onAdd:d=i,onChange:u,onError:g,showErrorMessages:m=!0,enableClipboard:f=!0,indent:b=2,collapse:j=!1,collapseAnimationTime:v=300,showCollectionCount:x=!0,restrictEdit:E=!1,restrictDelete:C=!1,restrictAdd:w=!1,restrictTypeSelection:k=!1,restrictDrag:O=!0,viewOnly:S,searchFilter:N,searchText:A,searchDebounceTime:R=350,keySort:M=!1,showArrayIndices:P=!0,showStringQuotes:V=!0,defaultValue:K=null,minWidth:z=250,maxWidth:F="min(600px, 90vw)",rootFontSize:I,stringTruncate:L=250,translations:_={},className:B,id:W,customText:G={},customNodeDefinitions:H=[],customButtons:U=[],jsonParse:Y=JSON.parse,jsonStringify:$=(e=>JSON.stringify(e,null,2)),TextEditor:J,errorMessageTimeout:Z=2500,keyboardControls:X={},externalTriggers:q,insertAtTop:Q=!1,onCollapse:ee,collapseClickZones:te=["header","left"]})=>{const{getStyles:ne}=D(),{setCurrentlyEditingElement:oe}=T(),ae=t.useCallback(he(j),[j]),ie=t.useCallback(ce(_,G),[_,G]),[le,de]=t.useState(A),[ue,pe]=(({setData:e,data:n})=>{const[r,o]=t.useState(e?void 0:n),a=t.useCallback((t=>{e?e(t):o(t)}),[e]);return t.useEffect((()=>{e||o(n)}),[n]),[e?n:r,a]})({setData:r,data:n}),fe=t.useRef(null);t.useEffect((()=>{oe(null);const e=setTimeout((()=>de(A)),R);return()=>clearTimeout(e)}),[A,R]);const be={key:o,path:[],level:0,index:0,value:ue,size:"object"==typeof ue&&null!==ue?Object.keys(ue).length:1,parentData:null,fullData:ue},je=(e,t)=>a(void 0,void 0,void 0,(function*(){const n=yield e(t);if(!0===n||void 0===n)return void pe(t.newData);const r=ye(n)?n:["error",n],[o,a]=r;if("error"===o)return pe(t.currentData),!1===a?ie("ERROR_UPDATE",be):String(a);pe(a)})),ve=t.useMemo((()=>he(E,S)),[E,S]),xe=t.useMemo((()=>he(C,S)),[C,S]),Ee=t.useMemo((()=>he(w,S)),[w,S]),Ce=t.useMemo((()=>he(O,S)),[O,S]),De=t.useMemo((()=>me(N)),[N]),we=t.useMemo((()=>(e=>{const t=Object.assign({},y);for(const n of Object.keys(y)){const r=n;if(e[r]){const o=e[r],a=["clipboardModifier","collapseModifier"].includes(n)?Array.isArray(o)?o:[o]:"string"==typeof o?{key:o}:o;t[r]=a,["stringConfirm","numberConfirm","booleanConfirm"].forEach((n=>{!e[n]&&e.confirm&&(t[n]=t.confirm)}))}}return t})(X)),[X]),ke=t.useCallback(((e,t)=>((e,t,n)=>{const r=Object.entries(t);for(const[t,o]of r)if(h(n,e[t],t)){n.preventDefault(),o();break}})(we,t,e)),[X]),Oe=t.useRef(null);((e,n)=>{const{setCurrentlyEditingElement:r,currentlyEditingElement:o,setCollapseState:a}=T();t.useEffect((()=>{if(!e)return;const{collapse:t,edit:i}=e;t&&a(t);const s=!(null==i?void 0:i.path)||p(i.path)===o;switch(null==i?void 0:i.action){case"accept":s&&(n.current&&n.current.click(),r(null));break;case"cancel":s&&r(null);break;default:(null==i?void 0:i.path)&&r(i.path)}}),[e])})(q,Oe);const Se=t.useCallback(((e,t)=>{!1!==M&&("function"!=typeof M?e.sort(((e,n)=>{const r=t(e)[0],o=t(n)[0];return r<o?-1:r>o?1:0})):e.sort(((e,n)=>M(t(e),t(n)))))}),[M]),Ne={mainContainerRef:fe,name:o,nodeData:be,onEdit:(e,t)=>a(void 0,void 0,void 0,(function*(){const{currentData:n,newData:r,currentValue:o,newValue:a}=ge(ue,t,e,"update");if(o!==a)return yield je(l,{currentData:n,newData:r,currentValue:o,newValue:a,name:t.slice(-1)[0],path:t})})),onDelete:(e,t)=>a(void 0,void 0,void 0,(function*(){const{currentData:n,newData:r,currentValue:o,newValue:a}=ge(ue,t,e,"delete");return yield je(c,{currentData:n,newData:r,currentValue:o,newValue:a,name:t.slice(-1)[0],path:t})})),onAdd:(e,t,n)=>a(void 0,void 0,void 0,(function*(){const{currentData:r,newData:o,currentValue:a,newValue:i}=ge(ue,t,e,"add",n);return yield je(d,{currentData:r,newData:o,currentValue:a,newValue:i,name:t.slice(-1)[0],path:t})})),onChange:u,onError:g,showErrorMessages:m,onMove:(e,t,n)=>a(void 0,void 0,void 0,(function*(){if(null===e)return;const{currentData:r,newData:o,currentValue:a}=ge(ue,e,"","delete"),i=e.slice(-1)[0],s=t.slice(0,-1),c=t.slice(-1)[0];let d="number"==typeof c?"above"===n?c:c+1:"number"==typeof i?`arr_${i}`:i;e.slice(0,-1).join(".")===t.slice(0,-1).join(".")&&"number"==typeof i&&"number"==typeof d&&i<d&&(d-=1);const u="number"==typeof d?{insert:!0}:"above"===n?{insertBefore:c}:{insertAfter:c},{newData:p,newValue:g}=ge(o,[...s,d],a,"add",u);return yield je(l,{currentData:r,newData:p,currentValue:a,newValue:g,name:t.slice(-1)[0],path:t})})),showCollectionCount:x,collapseFilter:ae,collapseAnimationTime:v,restrictEditFilter:ve,restrictDeleteFilter:xe,restrictAddFilter:Ee,restrictTypeSelection:k,restrictDragFilter:Ce,canDragOnto:!1,searchFilter:De,searchText:le,enableClipboard:f,keySort:M,sort:Se,showArrayIndices:P,showStringQuotes:V,indent:b,defaultValue:K,stringTruncate:L,translate:ie,customNodeDefinitions:H,customButtons:U,parentData:null,jsonParse:Y,jsonStringify:$,TextEditor:J,errorMessageTimeout:Z,handleKeyboard:ke,keyboardControls:we,insertAtTop:{object:!0===Q||"object"===Q,array:!0===Q||"array"===Q},onCollapse:ee,editConfirmRef:Oe,collapseClickZones:te},Ae=Object.assign(Object.assign({},ne("container",be)),{minWidth:z,maxWidth:F});return Ae.fontSize=null!=I?I:Ae.fontSize,e.jsx("div",{id:W,ref:fe,className:`jer-editor-container ${null!=B?B:""}`,style:Ae,children:s(ue)?e.jsx(se,Object.assign({data:ue},Ne)):e.jsx(re,Object.assign({data:ue,showLabel:!0},Ne))})},ge=(e,t,o,a,i={})=>{if(0===t.length)return{currentData:e,newData:o,currentValue:e,newValue:o};const s=Object.assign({remove:"delete"===a},i),l="add"!==a?r(e,t):void 0;return{currentData:e,newData:n(e,t,o,s),currentValue:l,newValue:"delete"!==a?o:void 0}},he=(e,t)=>t?()=>!0:"boolean"==typeof e?()=>e:"number"==typeof e?({level:t})=>t>=e:e,me=e=>{if(void 0!==e)return"value"===e?d:"key"===e?u:"all"===e?(e,t)=>d(e,t)||u(e,t):e},ye=e=>Array.isArray(e)&&2===e.length&&["error","value"].includes(e[0]),fe=t=>{var n;const{value:r,setIsEditing:o,getStyles:a,nodeData:i}=t,s=a("string",i),{canEdit:l}=Q({props:t});return e.jsx("div",{onDoubleClick:()=>o(!0),onClick:e=>{(e.getModifierState("Control")||e.getModifierState("Meta"))&&o(!0)},className:"jer-value-string jer-hyperlink",style:s,children:e.jsx("a",{href:r,target:"_blank",rel:"noreferrer",style:{color:null!==(n=s.color)&&void 0!==n?n:void 0},children:e.jsx(P,Object.assign({},t,{nodeData:i,pathString:p(i.path),styles:s,canEdit:l}))})})},be={condition:({value:e})=>"string"==typeof e&&/^https?:\/\/.+\..+$/.test(e),element:fe,showOnView:!0,showOnEdit:!1};exports.assign=n,exports.extract=r,exports.IconAdd=L,exports.IconCancel=H,exports.IconChevron=U,exports.IconCopy=W,exports.IconDelete=B,exports.IconEdit=_,exports.IconOk=G,exports.JsonEditor=n=>{var r;const[o,a]=t.useState();return t.useEffect((()=>{const e=document.documentElement;a(e)}),[]),o?e.jsx(C,{theme:null!==(r=n.theme)&&void 0!==r?r:x,icons:n.icons,docRoot:o,children:e.jsx(A,{onEditEvent:n.onEditEvent,onCollapse:n.onCollapse,children:e.jsx(pe,Object.assign({},n))})}):null},exports.LinkCustomComponent=fe,exports.LinkCustomNodeDefinition=be,exports.StringDisplay=P,exports.candyWrapperTheme={displayName:"Candy Wrapper",fragments:{minty:{backgroundColor:"#F1FAEE"},pale:{color:"#A8DADC"},mid:{color:"#457B9D"},dark:{color:"#1D3557"},pop:{color:"#E63946"},darkBlue:{color:"#2B2D42"}},styles:{container:"minty",property:"pop",dropZone:"#eb121217",bracket:"dark",itemCount:"pale",string:"mid",number:["darkBlue",{fontSize:"85%"}],boolean:["mid",{fontStyle:"italic",fontWeight:"bold",fontSize:"80%"}],null:["#cccccc",{fontWeight:"bold"}],input:{border:"1px solid rgb(115, 194, 198)"},iconCollection:"#1D3557",iconEdit:"#457B9D",iconDelete:"#E63946",iconAdd:"#2B2D42",iconCopy:"#1D3557",iconCancel:"#E63946"}},exports.defaultTheme=x,exports.githubDarkTheme={displayName:"Github Dark",styles:{container:{backgroundColor:"#0d1117",color:"white"},dropZone:"rgba(165, 214, 255, 0.17)",property:"#E6EDF3",bracket:"#56d364",itemCount:"#8B949E",string:"#A5D6FF",number:"#D2A8FF",boolean:{color:"#FF7B72",fontSize:"90%",fontWeight:"bold"},null:"green",iconCollection:"#D2A8FF",iconEdit:"#D2A8FF",iconDelete:"rgb(203, 75, 22)",iconAdd:"rgb(203, 75, 22)",iconCopy:"#A5D6FF",iconOk:"#56d364",iconCancel:"rgb(203, 75, 22)"}},exports.githubLightTheme={displayName:"Github Light",styles:{container:"white",property:"#1F2328",bracket:"#00802e",itemCount:"#8B949E",string:"#0A3069",number:"#953800",boolean:{color:"#CF222E",fontSize:"90%",fontWeight:"bold"},null:"#FF7B72",iconCollection:"#8250DF",iconEdit:"#8250DF",iconDelete:"rgb(203, 75, 22)",iconAdd:"#8250DF",iconCopy:"#57606A"}},exports.isCollection=s,exports.matchNode=d,exports.matchNodeKey=u,exports.monoDarkTheme={displayName:"Black & White",fragments:{lightText:{color:"white"},midGrey:"#5c5c5c"},styles:{container:["lightText",{backgroundColor:"black"}],dropZone:"#e0e0e029",property:"lightText",bracket:"midGrey",itemCount:"#4a4a4a",string:"#a8a8a8",number:"#666666",boolean:{color:"#848484",fontStyle:"italic"},null:"#333333",iconCollection:"midGrey",iconEdit:"midGrey",iconDelete:"midGrey",iconAdd:"midGrey",iconCopy:"midGrey",iconOk:"midGrey",iconCancel:"midGrey"}},exports.monoLightTheme={fragments:{midGrey:"#a3a3a3"},displayName:"White & Black",styles:{container:"white",property:"black",bracket:"midGrey",itemCount:"#b5b5b5",string:"#575757",number:"#999999",boolean:{color:"#7b7b7b",fontStyle:"italic"},null:"#cccccc",iconCollection:"midGrey",iconEdit:"midGrey",iconDelete:"midGrey",iconAdd:"midGrey",iconCopy:"midGrey",iconOk:"midGrey",iconCancel:"midGrey"}},exports.psychedelicTheme={displayName:"Psychedelic",fragments:{pale:{color:"#A8DADC"},fluroYellow:"rgb(242, 228, 21)",fluroGreen:"rgb(68, 255, 62)",hotPink:"#f7379a"},styles:{container:{backgroundColor:"unset",background:"linear-gradient(90deg, hsla(333, 100%, 53%, 1) 0%, hsla(33, 94%, 57%, 1) 100%)",color:"black"},dropZone:"fluroYellow",property:"black",bracket:"fluroYellow",itemCount:["pale",{opacity:.7}],string:"white",number:["#33d9ff",{fontSize:"90%",fontWeight:"bold"}],boolean:["fluroGreen",{fontWeight:"bold",fontSize:"80%"}],null:["black",{fontWeight:"bold",opacity:.3,backgroundColor:"rgb(255, 255, 255, 0.5)",padding:"0 0.4em",borderRadius:"0.4em"}],iconCollection:"fluroYellow",iconEdit:["black"],iconDelete:["white",{opacity:.5}],iconAdd:["white",{opacity:.5}],iconCopy:"rgb(32, 84, 242)",iconOk:"fluroGreen",iconCancel:"hotPink"}};
package/build/index.d.ts CHANGED
@@ -19,6 +19,15 @@ declare const localisedStrings: {
19
19
  type LocalisedStrings = typeof localisedStrings;
20
20
  type TranslateFunction = (key: keyof LocalisedStrings, customData: NodeData, count?: number) => string;
21
21
 
22
+ interface EditState {
23
+ path?: CollectionKey[];
24
+ action?: 'accept' | 'cancel';
25
+ }
26
+ interface ExternalTriggers {
27
+ collapse?: CollapseState | CollapseState[];
28
+ edit?: EditState;
29
+ }
30
+
22
31
  type JsonData = CollectionData | ValueData;
23
32
  interface JsonEditorProps {
24
33
  data: JsonData;
@@ -67,6 +76,10 @@ interface JsonEditorProps {
67
76
  errorMessageTimeout?: number;
68
77
  keyboardControls?: KeyboardControls;
69
78
  insertAtTop?: boolean | 'array' | 'object';
79
+ collapseClickZones?: Array<'left' | 'header' | 'property'>;
80
+ onEditEvent?: OnEditEventFunction;
81
+ onCollapse?: OnCollapseFunction;
82
+ externalTriggers?: ExternalTriggers;
70
83
  }
71
84
  declare const DataTypes: readonly ["string", "number", "boolean", "null", "object", "array"];
72
85
  type DataType = (typeof DataTypes)[number] | 'invalid';
@@ -133,6 +146,13 @@ type CopyFunction = (input: {
133
146
  }) => void;
134
147
  type CompareFunction = (a: [string | number, unknown], b: [string | number, unknown]) => number;
135
148
  type SortFunction = <T>(arr: T[], nodeMap: (input: T) => [string | number, unknown]) => void;
149
+ type OnEditEventFunction = (path: CollectionKey[] | string | null, isKey: boolean) => void;
150
+ interface CollapseState {
151
+ path: CollectionKey[];
152
+ collapsed: boolean;
153
+ includeChildren: boolean;
154
+ }
155
+ type OnCollapseFunction = (input: CollapseState) => void;
136
156
  type InternalUpdateFunction = (value: unknown, path: CollectionKey[], options?: Options) => Promise<string | void>;
137
157
  type Position = 'above' | 'below';
138
158
  type InternalMoveFunction = (source: CollectionKey[] | null, dest: CollectionKey[], position: Position) => Promise<string | void>;
@@ -201,6 +221,7 @@ interface BaseNodeProps {
201
221
  errorMessageTimeout: number;
202
222
  keyboardControls: KeyboardControlsFull;
203
223
  handleKeyboard: (e: React.KeyboardEvent, eventMap: Partial<Record<keyof KeyboardControlsFull, () => void>>) => void;
224
+ editConfirmRef: React.RefObject<HTMLDivElement>;
204
225
  }
205
226
  interface CollectionNodeProps extends BaseNodeProps {
206
227
  mainContainerRef: React.MutableRefObject<Element>;
@@ -219,6 +240,8 @@ interface CollectionNodeProps extends BaseNodeProps {
219
240
  array: boolean;
220
241
  };
221
242
  TextEditor?: React.FC<TextEditorProps>;
243
+ onCollapse?: OnCollapseFunction;
244
+ collapseClickZones: Array<'left' | 'header' | 'property'>;
222
245
  }
223
246
  type ValueData = string | number | boolean;
224
247
  interface ValueNodeProps extends BaseNodeProps {
@@ -239,6 +262,8 @@ interface CustomNodeProps<T = Record<string, unknown>> extends BaseNodeProps {
239
262
  setIsEditing: React.Dispatch<React.SetStateAction<boolean>>;
240
263
  getStyles: (element: ThemeableElement, nodeData: NodeData) => React.CSSProperties;
241
264
  children?: JSX.Element | JSX.Element[] | null;
265
+ originalNode?: JSX.Element;
266
+ originalNodeKey?: JSX.Element;
242
267
  }
243
268
  interface CustomNodeDefinition<T = Record<string, unknown>, U = Record<string, unknown>> {
244
269
  condition: FilterFunction;
@@ -251,6 +276,7 @@ interface CustomNodeDefinition<T = Record<string, unknown>, U = Record<string, u
251
276
  showOnEdit?: boolean;
252
277
  showOnView?: boolean;
253
278
  showEditTools?: boolean;
279
+ passOriginalNode?: boolean;
254
280
  showCollectionWrapper?: boolean;
255
281
  wrapperElement?: React.FC<CustomNodeProps<U>>;
256
282
  wrapperProps?: Record<string, unknown>;
@@ -322,4 +348,4 @@ declare const monoLightTheme: Theme;
322
348
  declare const candyWrapperTheme: Theme;
323
349
  declare const psychedelicTheme: Theme;
324
350
 
325
- export { CollectionNodeProps, CompareFunction, CopyFunction, CustomNodeDefinition, CustomNodeProps, CustomTextDefinitions, CustomTextFunction, DataType, DefaultValueFunction, FilterFunction, IconAdd, IconCancel, IconChevron, IconCopy, IconDelete, IconEdit, IconOk, IconReplacements, JerError, JsonData, JsonEditor, JsonEditorProps, KeyboardControls, LinkCustomComponent, LinkCustomNodeDefinition, LocalisedStrings, NodeData, OnChangeFunction, OnErrorFunction, SearchFilterFunction, StringDisplay, TextEditorProps, Theme, ThemeInput, ThemeStyles, TranslateFunction, TypeFilterFunction, UpdateFunction, ValueNodeProps, candyWrapperTheme, defaultTheme, githubDarkTheme, githubLightTheme, isCollection, matchNode, matchNodeKey, monoDarkTheme, monoLightTheme, psychedelicTheme };
351
+ export { CollapseState, CollectionNodeProps, CompareFunction, CopyFunction, CustomNodeDefinition, CustomNodeProps, CustomTextDefinitions, CustomTextFunction, DataType, DefaultValueFunction, EditState, ExternalTriggers, FilterFunction, IconAdd, IconCancel, IconChevron, IconCopy, IconDelete, IconEdit, IconOk, IconReplacements, JerError, JsonData, JsonEditor, JsonEditorProps, KeyboardControls, LinkCustomComponent, LinkCustomNodeDefinition, LocalisedStrings, NodeData, OnChangeFunction, OnCollapseFunction, OnEditEventFunction, OnErrorFunction, SearchFilterFunction, StringDisplay, TextEditorProps, Theme, ThemeInput, ThemeStyles, TranslateFunction, TypeFilterFunction, UpdateFunction, ValueNodeProps, candyWrapperTheme, defaultTheme, githubDarkTheme, githubLightTheme, isCollection, matchNode, matchNodeKey, monoDarkTheme, monoLightTheme, psychedelicTheme };
@@ -1 +1 @@
1
- import{jsxs as e,jsx as t,Fragment as n}from"react/jsx-runtime";import{createContext as r,useContext as o,useState as a,useRef as i,useEffect as l,useMemo as s,useCallback as c}from"react";import d from"object-property-assigner";export{default as assign}from"object-property-assigner";import u from"object-property-extractor";export{default as extract}from"object-property-extractor";function p(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}function g(e,t,n,r){return new(n||(n=Promise))((function(o,a){function i(e){try{s(r.next(e))}catch(e){a(e)}}function l(e){try{s(r.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,l)}s((r=r.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const m=({className:n,name:r,value:o,setValue:a,handleKeyPress:i,styles:l,textAreaRef:s})=>{if("string"!=typeof o)return null;const c="\n"===o.slice(-1)?o+".":o;return e("div",{style:{display:"grid"},children:[t("textarea",{id:`${r}_textarea`,ref:s,style:Object.assign({height:"auto",gridArea:"1 / 1 / 2 / 2",overflowY:"auto",whiteSpace:"pre-wrap"},l),rows:1,className:n,name:`${r}_textarea`,value:o,onChange:e=>a(e.target.value),autoFocus:!0,onFocus:e=>{o.length<40&&e.target.select()},onKeyDown:i}),t("span",{className:n,style:Object.assign({visibility:"hidden",height:"auto",gridArea:"1 / 1 / 2 / 2",color:"red",opacity:.9,whiteSpace:"pre-wrap",overflowY:"auto",border:"1px solid transparent"},l),children:c})]})},h=e=>null!==e&&"object"==typeof e,y=(e,t,n,r="")=>{if(!n&&!r)return!0;switch(e){case"collection":if(n){if(n(t,r))return!0;if(!b(r,t,n))return!1}if(!n&&r&&!b(r,t))return!1;break;case"value":if(n&&!n(t,r))return!1;if(!n&&r&&!f(t,r))return!1}return!0},b=(e="",t,n=f)=>{const r=t.value;return Object.entries(r).some((([o,a])=>{const i=[...t.path,o],l=Object.assign(Object.assign({},t),{key:o,path:i,level:t.level+1,value:a,size:i.length,parentData:r});return h(a)?b(e,l,n):n(l,e)}))},f=(e,t="")=>{const{value:n}=e;if(null===n&&"null".includes(t.toLowerCase()))return!0;switch(typeof n){case"string":return n.toLowerCase().includes(t.toLowerCase());case"number":return!!String(n).includes(t);case"boolean":return n?"true".includes(t.toLowerCase())||"1"===t:"false".includes(t.toLowerCase())||"0"===t;default:return!1}},v=({key:e,path:t},n="")=>!!f({value:e},n)||!!t.some((e=>f({value:e},n))),j=(e,t)=>(null!=t?t:"")+e.map((e=>""===e?String.fromCharCode(0):e)).join("."),E=e=>e.shiftKey?"Shift":e.metaKey?"Meta":e.ctrlKey?"Control":e.altKey?"Alt":void 0,D=(e,t,n)=>{const r=e.key,o=E(e);if(Array.isArray(t))return!!o&&t.includes(o);const{key:a,modifier:i}=t;return("stringLineBreak"!==n||"Enter"!==r||"Shift"!==o||"Enter"!==a||!(null==i?void 0:i.includes("Shift")))&&(r===a&&(i===o||Array.isArray(i)&&i.includes(o)))},w={key:"Enter"},k={confirm:w,cancel:{key:"Escape"},objectConfirm:Object.assign(Object.assign({},w),{modifier:["Meta","Shift","Control"]}),objectLineBreak:w,stringConfirm:w,stringLineBreak:Object.assign(Object.assign({},w),{modifier:["Shift"]}),numberConfirm:w,numberUp:{key:"ArrowUp"},numberDown:{key:"ArrowDown"},tabForward:{key:"Tab"},tabBack:{key:"Tab",modifier:"Shift"},booleanConfirm:w,booleanToggle:{key:" "},clipboardModifier:["Meta","Control"],collapseModifier:["Alt"]},C=(e,t,n="next",r)=>{const o=t.slice(0,t.length-1),a=t.slice(-1)[0];if(void 0===a)return null;const i=u(e,o),l=S(i);Array.isArray(i)||r(l,(({key:e,value:t})=>[e,t]));const s=l.findIndex((e=>e.key===a)),c=l[s+("next"===n?1:-1)];return c?h(c.value)?0===Object.keys(c.value).length?C(e,[...o,c.key],n,r):O(e,[...o,c.key],n,r):[...o,c.key]:0===o.length?null:C(e,o,n,r)},O=(e,t,n="next",r)=>{const o=u(e,t);if(!h(o))return t;const a=Array.isArray(o)?o.map(((e,t)=>t)):Object.keys(o);r(a,(e=>[e,o]));const i="next"===n?a[0]:a[a.length-1];return O(e,[...t,i],n,r)},S=e=>Array.isArray(e)?e.map(((e,t)=>({index:t,value:e,key:t}))):Object.entries(e).map((([e,t],n)=>({key:e,value:t,index:n}))),N=(e,t)=>{var n,r,o,a;const i=e.current,l=null!==(n=null==i?void 0:i.selectionStart)&&void 0!==n?n:1/0,s=null!==(r=null==i?void 0:i.selectionEnd)&&void 0!==r?r:1/0,c=(null===(o=null==i?void 0:i.textContent)||void 0===o?void 0:o.slice(0,l))+t+(null===(a=null==i?void 0:i.textContent)||void 0===a?void 0:a.slice(s));return i.value=c,null==i||i.setSelectionRange(l+1,l+1),c},x={displayName:"Default",fragments:{edit:"rgb(42, 161, 152)"},styles:{container:{backgroundColor:"#f6f6f6",fontFamily:"monospace"},collection:{},collectionInner:{},collectionElement:{},dropZone:{},property:"#292929",bracket:{color:"rgb(0, 43, 54)",fontWeight:"bold"},itemCount:{color:"rgba(0, 0, 0, 0.3)",fontStyle:"italic"},string:"rgb(203, 75, 22)",number:"rgb(38, 139, 210)",boolean:"green",null:{color:"rgb(220, 50, 47)",fontVariant:"small-caps",fontWeight:"bold"},input:["#292929"],inputHighlight:"#b3d8ff",error:{fontSize:"0.8em",color:"red",fontWeight:"bold"},iconCollection:"rgb(0, 43, 54)",iconEdit:"edit",iconDelete:"rgb(203, 75, 22)",iconAdd:"edit",iconCopy:"rgb(38, 139, 210)",iconOk:"green",iconCancel:"rgb(203, 75, 22)"}},A=r({getStyles:()=>({}),icons:{}}),T=({theme:e=x,icons:n={},docRoot:r,children:o})=>{const a=R(e,r);return t(A.Provider,{value:{getStyles:(e,t)=>"function"==typeof a[e]?a[e](t):a[e],icons:n},children:o})},P=()=>o(A),R=(e,t)=>{var n,r,o,a;const i={},l=(Array.isArray(e)?e:[e]).map((e=>z(e)?V({fragments:{},styles:e},i):V(e,i))),s=V(x,{});Object.keys(s).forEach((e=>{const t=e;l.forEach((e=>{e[t]&&(s[t]=Object.assign(Object.assign({},s[t]),e[t]))}))}));const c=Object.assign({},s);return Object.entries(i).forEach((([e,t])=>{const n=e;c[n]=e=>{const r=t(e)||{};return Object.assign(Object.assign({},s[n]),r)}})),"function"!=typeof(null==c?void 0:c.inputHighlight)&&(null===(n=null==c?void 0:c.inputHighlight)||void 0===n?void 0:n.backgroundColor)&&t.style.setProperty("--jer-highlight-color",null===(r=null==c?void 0:c.inputHighlight)||void 0===r?void 0:r.backgroundColor),"function"!=typeof(null==c?void 0:c.iconCopy)&&(null===(o=null==c?void 0:c.iconCopy)||void 0===o?void 0:o.color)&&t.style.setProperty("--jer-icon-copy-color",null===(a=null==c?void 0:c.iconCopy)||void 0===a?void 0:a.color),c},V=(e,t)=>{const{fragments:n,styles:r}=e,o={};return Object.entries(r).forEach((([e,r])=>{const a=(Array.isArray(r)?r:[r]).reduce(((r,o)=>{var a,i;if("function"==typeof o)return t[e]=o,Object.assign({},r);if("string"==typeof o){const t=null!==(a=null==n?void 0:n[o])&&void 0!==a?a:o;return"string"==typeof t?Object.assign(Object.assign({},r),{[null!==(i=F[e])&&void 0!==i?i:"color"]:t}):Object.assign(Object.assign({},r),t)}return Object.assign(Object.assign({},r),o)}),{});o[e]=a})),o},z=e=>!("styles"in e),F={container:"backgroundColor",collection:"backgroundColor",collectionInner:"backgroundColor",collectionElement:"backgroundColor",dropZone:"borderColor",inputHighlight:"backgroundColor"},M=r({collapseState:null,setCollapseState:()=>{},doesPathMatch:()=>!1,currentlyEditingElement:null,setCurrentlyEditingElement:()=>{},previouslyEditedElement:null,setPreviouslyEditedElement:()=>{},areChildrenBeingEdited:()=>!1,dragSource:{path:null,pathString:null},setDragSource:()=>{},tabDirection:"next",setTabDirection:()=>{}}),K=({children:e})=>{const[n,r]=a(null),[o,l]=a(null),[s,c]=a({path:null,pathString:null}),d=i(null),u=i("next"),p=i(null);return t(M.Provider,{value:{collapseState:n,setCollapseState:e=>{r(e),null!==e&&setTimeout((()=>r(null)),2e3)},doesPathMatch:e=>{if(null===n)return!1;for(const[t,r]of n.path.entries())if(r!==e[t])return!1;return!0},currentlyEditingElement:o,setCurrentlyEditingElement:(e,t)=>{const n="string"==typeof e||null===e?e:j(e,"key"===t?"key_":void 0);null!==o&&null!==n&&null!==d.current&&d.current(),l(n),d.current="function"==typeof t?t:null},areChildrenBeingEdited:e=>null!==o&&o.includes(e),previouslyEditedElement:p.current,setPreviouslyEditedElement:e=>{p.current=e},tabDirection:u.current,setTabDirection:e=>{u.current=e},dragSource:s,setDragSource:c},children:e})},_=()=>o(M),L="**INVALID_FUNCTION**",I=({nodeData:r,showStringQuotes:o=!0,stringTruncate:i=200,pathString:l,canEdit:s,setIsEditing:c,styles:d,translate:u})=>{const p=r.value,[g,m]=a(!1),h=o?'"':"",y=p.length>i,b=()=>{s?c(!0):m(!g)};return e("div",{id:`${l}_display`,onDoubleClick:b,onClick:e=>{(e.getModifierState("Control")||e.getModifierState("Meta"))&&b()},className:"jer-value-string",style:d,children:[h,y?e(n,g?{children:[e("span",{children:[p,h]}),e("span",{className:"jer-string-expansion jer-show-less",onClick:()=>m(!1),children:[" ",u("SHOW_LESS",r)]})]}:{children:[t("span",{children:p.slice(0,i-2).trimEnd()}),t("span",{className:"jer-string-expansion jer-ellipsis",onClick:()=>m(!0),children:"..."}),h]}):`${p}${h}`]})},B=e=>{var{value:n,setValue:r,isEditing:o,path:a,handleEdit:l,nodeData:s,handleKeyboard:c,keyboardCommon:d}=e,u=p(e,["value","setValue","isEditing","path","handleEdit","nodeData","handleKeyboard","keyboardCommon"]);const{getStyles:g}=P(),h=i(null),y=j(a);return o?t(m,{className:"jer-input-text",textAreaRef:h,name:y,value:n,setValue:r,isEditing:o,handleKeyPress:e=>{c(e,Object.assign({stringConfirm:l,stringLineBreak:()=>{const e=N(h,"\n");r(e)}},d))},styles:g("input",s)}):t(I,Object.assign({nodeData:s,pathString:y,styles:g("string",s)},u))},W=({value:e,setValue:n,isEditing:r,path:o,setIsEditing:a,handleEdit:i,nodeData:l,handleKeyboard:s,keyboardCommon:c})=>{const{getStyles:d}=P();return r?t("input",{className:"jer-input-number",type:"text",name:j(o),value:e,onChange:e=>n(e.target.value.replace(/[^0-9.-]/g,"")),autoFocus:!0,onFocus:e=>setTimeout((()=>e.target.select()),10),onKeyDown:t=>s(t,Object.assign({numberConfirm:i,numberUp:()=>n(Number(e)+1),numberDown:()=>n(Number(e)-1)},c)),style:Object.assign({width:String(e).length/1.5+2+"em"},d("input",l))}):t("span",{onDoubleClick:()=>a(!0),className:"jer-value-number",style:d("number",l),children:e})},G=({value:e,setValue:n,isEditing:r,path:o,setIsEditing:a,handleEdit:i,nodeData:l,handleKeyboard:s,keyboardCommon:c})=>{const{getStyles:d}=P();return r?t("input",{className:"jer-input-boolean",type:"checkbox",name:j(o),checked:e,onChange:()=>n(!e),onKeyDown:t=>{" "===t.key&&t.preventDefault(),s(t,Object.assign({booleanConfirm:i,booleanToggle:()=>n(!e)},c))},autoFocus:!0}):t("span",{onDoubleClick:()=>a(!0),className:"jer-value-boolean",style:d("boolean",l),children:String(e)})},H=({value:e,isEditing:n,setIsEditing:r,handleEdit:o,nodeData:a,handleKeyboard:s,keyboardCommon:c})=>{const{getStyles:d}=P(),u=i();l((()=>{if(n)return u.current=window.setTimeout((()=>window.addEventListener("keydown",p)),100),()=>window.removeEventListener("keydown",p);window.clearTimeout(u.current)}),[n]);const p=e=>s(e,Object.assign({confirm:o},c));return t("div",{onDoubleClick:()=>r(!0),className:"jer-value-null",style:d("null",a),children:String(e)})},U=({value:e})=>{let n="Error!";switch(typeof e){case"string":e===L&&(n="Function");break;case"undefined":n="Undefined";break;case"symbol":n="Symbol"}return t("span",{className:"jer-value-invalid",children:n})},Y=({size:n,style:r,className:o})=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:n,height:n,className:o,style:r,children:[t("path",{d:"M13 7h-2v4H7v2h4v4h2v-4h4v-2h-4z"}),t("path",{d:"M12 2C6.486 2 2 6.486 2 12s4.486 10 10 10 10-4.486 10-10S17.514 2 12 2zm0 18c-4.411 0-8-3.589-8-8s3.589-8 8-8 8 3.589 8 8-3.589 8-8 8z"})]}),$=({size:n,style:r,className:o})=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:n,height:n,className:o,style:r,transform:"translate(0, 0.5)",children:[t("path",{d:"M7 17.013l4.413-.015 9.632-9.54c.378-.378.586-.88.586-1.414s-.208-1.036-.586-1.414l-1.586-1.586c-.756-.756-2.075-.752-2.825-.003L7 12.583v4.43zM18.045 4.458l1.589 1.583-1.597 1.582-1.586-1.585 1.594-1.58zM9 13.417l6.03-5.973 1.586 1.586-6.029 5.971L9 15.006v-1.589z"}),t("path",{d:"M5 21h14c1.103 0 2-.897 2-2v-8.668l-2 2V19H8.158c-.026 0-.053.01-.079.01-.033 0-.066-.009-.1-.01H5V5h6.847l2-2H5c-1.103 0-2 .897-2 2v14c0 1.103.897 2 2 2z"})]}),J=({size:e,style:n,className:r})=>t("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:e,height:e,className:r,style:n,children:t("path",{d:"M6 19a2 2 0 002 2h8a2 2 0 002-2V7H6v12m2.46-7.12l1.41-1.41L12 12.59l2.12-2.12 1.41 1.41L13.41 14l2.12 2.12-1.41 1.41L12 15.41l-2.12 2.12-1.41-1.41L10.59 14l-2.13-2.12M15.5 4l-1-1h-5l-1 1H5v2h14V4h-3.5z"})}),X=({size:n,style:r,className:o})=>e("svg",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",width:n,height:n,className:o,style:r,children:[t("path",{d:"M9 2 H15 A1 1 0 0 1 16 3 V5 A1 1 0 0 1 15 6 H9 A1 1 0 0 1 8 5 V3 A1 1 0 0 1 9 2 z"}),t("path",{d:"M8 4H6a2 2 0 00-2 2v14a2 2 0 002 2h12a2 2 0 002-2v-2M16 4h2a2 2 0 012 2v4M21 14H11"}),t("path",{d:"M15 10l-4 4 4 4"})]}),Z=({size:n,style:r,className:o})=>e("svg",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",width:n,height:n,className:o,style:r,children:[t("path",{d:"M22 11.08V12a10 10 0 11-5.93-9.14"}),t("path",{d:"M22 4L12 14.01l-3-3"})]}),Q=({size:e,style:n,className:r})=>t("svg",{baseProfile:"tiny",viewBox:"0 0 24 24",fill:"currentColor",width:e,height:e,className:r,style:n,children:t("path",{d:"M12 4c-4.411 0-8 3.589-8 8s3.589 8 8 8 8-3.589 8-8-3.589-8-8-8zm-5 8c0-.832.224-1.604.584-2.295l6.711 6.711A4.943 4.943 0 0112 17c-2.757 0-5-2.243-5-5zm9.416 2.295L9.705 7.584A4.943 4.943 0 0112 7c2.757 0 5 2.243 5 5 0 .832-.224 1.604-.584 2.295z"})}),q=({size:e,style:n,className:r})=>t("svg",{viewBox:"0 0 512 512",fill:"currentColor",width:e,height:e,className:r,style:n,children:t("path",{d:"M233.4 406.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L256 338.7 86.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z"})}),ee=({name:e,nodeData:r,rotate:o})=>{var a,i,l,s,c,d,u;const{getStyles:p,icons:g}=P(),m={size:"1.4em",className:"jer-icon"};switch(e){case"add":return null!==(a=null==g?void 0:g.add)&&void 0!==a?a:t(Y,Object.assign({},m,{style:p("iconAdd",r)}));case"edit":return null!==(i=null==g?void 0:g.edit)&&void 0!==i?i:t($,Object.assign({},m,{style:p("iconEdit",r)}));case"delete":return null!==(l=null==g?void 0:g.delete)&&void 0!==l?l:t(J,Object.assign({},m,{style:p("iconDelete",r),size:"1.45em"}));case"copy":return null!==(s=null==g?void 0:g.copy)&&void 0!==s?s:t(X,Object.assign({},m,{style:p("iconCopy",r),size:"1.2em"}));case"ok":return null!==(c=null==g?void 0:g.ok)&&void 0!==c?c:t(Z,Object.assign({},m,{style:Object.assign({fontSize:"90%"},p("iconOk",r))}));case"cancel":return null!==(d=null==g?void 0:g.cancel)&&void 0!==d?d:t(Q,Object.assign({},m,{style:Object.assign({fontSize:"130%"},p("iconCancel",r))}));case"chevron":return null!==(u=null==g?void 0:g.chevron)&&void 0!==u?u:t(q,{size:"1em",style:p("iconCollection",r)});default:return t(n,{})}},te=({startEdit:r,handleDelete:o,handleAdd:i,enableClipboard:l,type:s,customButtons:c,nodeData:d,translate:u,keyboardControls:p,handleKeyboard:g})=>{const{getStyles:m}=P(),h=u("KEY_NEW",d),[y,b]=a(!1),[f,v]=a(h),{key:j,path:D,value:w}=d;return e("div",{className:"jer-edit-buttons",style:{opacity:y?1:void 0},children:[l&&t("div",{onClick:e=>{var t;e.stopPropagation();let n,r,o="value",a="",i=null;if(l){const c=E(e);if(c&&p.clipboardModifier.includes(c)?(n=re(D),a=n,o="path"):(n=w,a=s?JSON.stringify(w,null,2):String(n)),!navigator.clipboard)return void("function"==typeof l&&l({success:!1,value:n,stringValue:a,path:D,key:j,type:o,errorMessage:"Can't access clipboard API"}));null===(t=navigator.clipboard)||void 0===t||t.writeText(a).then((()=>r=!0)).catch((e=>{r=!1,i=e.message})).finally((()=>{"function"==typeof l&&l({success:r,errorMessage:i,value:n,stringValue:a,path:D,key:j,type:o})}))}},className:"jer-copy-pulse",children:t(ee,{name:"copy",nodeData:d})}),r&&t("div",{onClick:e=>{e.stopPropagation(),r()},children:t(ee,{name:"edit",nodeData:d})}),o&&t("div",{onClick:e=>{e.stopPropagation(),o()},children:t(ee,{name:"delete",nodeData:d})}),i&&t("div",{onClick:e=>{e.stopPropagation(),"object"===s?b(!0):i("")},children:t(ee,{name:"add",nodeData:d})}),null==c?void 0:c.map((({Element:e,onClick:n},r)=>t("div",{onClick:e=>n&&n(d,e),children:t(e,{nodeData:d})},r))),y&&i&&"object"===s&&e(n,{children:[t("input",{className:"jer-input-new-key",type:"text",name:"new-object-key",value:f,onChange:e=>v(e.target.value),onClick:e=>e.stopPropagation(),autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>{g(e,{stringConfirm:()=>{i&&(b(!1),i(f),v(h))},cancel:()=>{b(!1),v(h)}})},style:m("input",d)}),t(ne,{onOk:e=>{f&&(e.stopPropagation(),b(!1),i(f))},onCancel:e=>{e.stopPropagation(),b(!1)},nodeData:d})]})]})},ne=({onOk:n,onCancel:r,nodeData:o})=>e("div",{className:"jer-confirm-buttons",children:[t("div",{onClick:n,children:t(ee,{name:"ok",nodeData:o})}),t("div",{onClick:r,children:t(ee,{name:"cancel",nodeData:o})})]}),re=e=>e.reduce(((e,t)=>"number"==typeof t?`${e}[${t}]`:""===e?t:`${e}.${t}`),""),oe=["string","number","boolean","null","object","array"],ae=(e=[],t)=>{const n=e.filter((({condition:e})=>e(t)));if(0===n.length)return{};const r=n[0],{element:o,wrapperElement:a,customNodeProps:i,wrapperProps:l,hideKey:s=!1,showEditTools:c=!0,showOnEdit:d=!1,showOnView:u=!0,showCollectionWrapper:g=!0}=r,m=p(r,["element","wrapperElement","customNodeProps","wrapperProps","hideKey","showEditTools","showOnEdit","showOnView","showCollectionWrapper"]);return Object.assign({CustomNode:o,CustomWrapper:a,customNodeProps:i,wrapperProps:l,hideKey:s,showEditTools:c,showOnEdit:d,showOnView:u,showCollectionWrapper:g},m)},ie=({props:e,collapsed:t})=>{const{data:n,nodeData:r,parentData:o,onEdit:i,onError:l,showErrorMessages:c,restrictEditFilter:d,restrictDeleteFilter:u,restrictAddFilter:p,restrictDragFilter:g,translate:m,errorMessageTimeout:h}=e,{currentlyEditingElement:y,setCurrentlyEditingElement:b}=_(),[f,v]=a(null),E=Object.assign(Object.assign({},r),{collapsed:t}),{path:D,key:w,size:k}=E,C=j(D),O=s((()=>!d(E)),[E]),S=s((()=>!u(E)),[E]),N=s((()=>!p(E)),[E]),x=s((()=>!g(E)&&S&&null===y),[E]),A=e=>{c&&(v(e),setTimeout((()=>v(null)),h)),console.warn("Error",e)},T=s((()=>(e,t)=>{A(e.message),l&&l({currentData:E.fullData,errorValue:t,currentValue:n,name:w,path:D,error:e})}),[l,c]),P=y===C,R=y===`key_${C}`,V="number"==typeof D.slice(-1)[0];return{pathString:C,nodeData:E,path:D,name:w,size:k,canEdit:O,canDelete:S,canAdd:N,canDrag:x,error:f,showError:A,onError:T,setError:v,handleEditKey:e=>{if(b(null),w===e)return;if(!o)return;const t=D.slice(0,-1);if(Object.keys(o).includes(e))return void T({code:"KEY_EXISTS",message:m("ERROR_KEY_EXISTS",E)},e);const n=Object.fromEntries(Object.entries(o).map((([t,n])=>t===w?[e,n]:[t,n])));i(n,t).then((t=>{t&&T({code:"UPDATE_ERROR",message:t},e)}))},derivedValues:{isEditing:P,isEditingKey:R,isArray:V,canEditKey:null!==o&&O&&N&&S&&!V}}},le=({canDrag:e,canDragOnto:n,path:r,nodeData:o,onMove:i,onError:l,translate:c})=>{const{getStyles:d}=P(),{dragSource:u,setDragSource:p}=_(),[g,m]=a(!1),h=j(r),y=s((()=>e?{onDragStart:e=>{e.stopPropagation(),p({path:r,pathString:h})},onDragEnd:e=>{e.stopPropagation(),p({path:null,pathString:null})}}:{}),[e]),b=s((()=>e=>n?{onDragOver:e=>{e.stopPropagation(),e.preventDefault()},onDrop:t=>{t.stopPropagation(),v(e),p({path:null,pathString:null}),m(!1)},onDragEnter:t=>{var n;t.stopPropagation(),h.startsWith(null!==(n=u.pathString)&&void 0!==n?n:"")||m(e)},onDragExit:e=>{e.stopPropagation(),m(!1)}}:{}),[u,n]),f=s((()=>n&&null!==u.pathString?t("div",Object.assign({className:"jer-drop-target-bottom",style:{height:"50%",position:"absolute",width:"100%",top:"50%",zIndex:r.length}},b("below"))):null),[u,n]),v=e=>{var t,n;const a=null===(t=u.path)||void 0===t?void 0:t.slice(-1)[0],s=null===(n=u.path)||void 0===n?void 0:n.slice(0,-1).join("."),d=r.slice(0,-1).join(""),{parentData:p}=o;"string"==typeof a&&p&&!Array.isArray(p)&&Object.keys(p).includes(a)&&a in p&&s!==d?l({code:"KEY_EXISTS",message:c("ERROR_KEY_EXISTS",o)},a):i(u.path,r,e).then((e=>{e&&l({code:"UPDATE_ERROR",message:e},o.value)}))};return{dragSourceProps:y,getDropTargetProps:b,BottomDropTarget:f,DropTargetPadding:({position:e,nodeData:n})=>g===e?t("div",{className:"jer-drag-n-drop-padding",style:d("dropZone",n)}):null,handleDrop:v}},se=(e,t,n)=>{var r,o,a;const i=parseInt(null!==(r=getComputedStyle(n.current).getPropertyValue("line-height"))&&void 0!==r?r:"16px"),l=(null!==(a=null===(o=t.current)||void 0===o?void 0:o.offsetWidth)&&void 0!==a?a:0)/(.5*i),s=JSON.stringify(e,null,2).replace(/\\n/g,"\n").split("\n").map((e=>Math.ceil(e.length/l))).reduce(((e,t)=>e+t),0)*i;return Math.min(s+30,window.innerHeight-50)},ce=n=>{const{data:r,parentData:o,onEdit:i,onDelete:d,onChange:u,onMove:p,enableClipboard:g,canDragOnto:m,restrictTypeSelection:h,searchFilter:b,searchText:f,showLabel:v,stringTruncate:j,showStringQuotes:E,indent:D,translate:w,customNodeDefinitions:k,handleKeyboard:O,keyboardControls:S,sort:N}=n,{getStyles:x}=P(),{setCurrentlyEditingElement:A,setCollapseState:T,previouslyEditedElement:R,setPreviouslyEditedElement:V,tabDirection:z,setTabDirection:F}=_(),[M,K]=a("function"==typeof r?L:r),{pathString:I,nodeData:B,path:W,name:G,canEdit:H,canDelete:U,canDrag:Y,error:$,onError:J,handleEditKey:X,derivedValues:Z}=ie({props:n}),{dragSourceProps:Q,getDropTargetProps:q,BottomDropTarget:ee,DropTargetPadding:re}=le({canDrag:Y,canDragOnto:m,path:W,nodeData:B,onMove:p,onError:J,translate:w}),se=ae(k,B),[ce,ge]=a(de(r,se)),me=c((e=>{if(!u)return void K(e);const t=u({currentData:B.fullData,newValue:e,currentValue:M,name:G,path:W});K(t)}),[u]);l((()=>{K("function"==typeof r?L:r),ge(de(r,se))}),[r,$]);const{CustomNode:he,customNodeProps:ye,hideKey:be,showEditTools:fe=!0,showOnEdit:ve,showOnView:je}=se,Ee=[...oe,...k.filter((({showInTypesSelector:e=!1,name:t})=>e&&!!t)).map((({name:e})=>e))],De=s((()=>{if("boolean"==typeof h)return h?[]:Ee;if(Array.isArray(h))return h;const e=h(B);return"boolean"==typeof e?e?[]:Ee:e}),[B,h]),{isEditing:we}=Z,ke=y("value",B,b,f);if(we&&(!ke||!H)){const e=C(B.fullData,W,z,N);A(e||R)}if(!ke)return null;const Ce=()=>{let e;switch(A(null),ce){case"object":e={[w("DEFAULT_NEW_KEY",B)]:M};break;case"array":e=null!=M?M:[];break;case"number":{const t=Number(M);e=isNaN(t)?0:t;break}default:e=M}i(e,W).then((t=>{t&&J({code:"UPDATE_ERROR",message:t},e)}))},Oe=()=>{A(null),K(r)},{isEditingKey:Se,canEditKey:Ne}=Z,xe=!we&&$,Ae=we&&De.length>0,Te="invalid"!==ce&&!$&&fe,Pe=v&&Se,Re=v&&!Se&&!be,Ve={value:M,parentData:o,setValue:me,isEditing:we,canEdit:H,setIsEditing:H?()=>A(W):()=>{},handleEdit:Ce,handleCancel:Oe,path:W,stringTruncate:j,showStringQuotes:E,nodeData:B,translate:w,handleKeyboard:O,keyboardCommon:{cancel:Oe,tabForward:()=>{F("next"),V(I);const e=C(B.fullData,W,"next",N);e&&(Ce(),A(e))},tabBack:()=>{F("prev"),V(I);const e=C(B.fullData,W,"prev",N);e&&(Ce(),A(e))}}},ze=he&&(we&&ve||!we&&je)?t(he,Object.assign({},n,{value:M,customNodeProps:ye,setValue:me,handleEdit:Ce,handleCancel:Oe,handleKeyPress:e=>O(e,{stringConfirm:Ce,cancel:Oe}),isEditing:we,setIsEditing:()=>A(W),getStyles:x})):ue(r,Ve);return e("div",Object.assign({className:"jer-component jer-value-component",style:{marginLeft:D/2+"em",position:"relative"},draggable:Y},Q,q("above"),{children:[ee,t(re,{position:"above",nodeData:B}),e("div",{className:"jer-value-main-row",style:{flexWrap:G.length>10?"wrap":"nowrap"},children:[Re&&t("span",{className:"jer-key-text",style:Object.assign(Object.assign({},x("property",B)),{minWidth:`${Math.min(String(G).length+1,5)}ch`,flexShrink:G.length>10?1:0}),onDoubleClick:()=>Ne&&A(W,"key"),children:""===G?t("span",{className:W.length>0?"jer-empty-string":void 0}):`${G}:`}),Pe&&t("input",{className:"jer-input-text jer-key-edit",type:"text",name:I,defaultValue:G,autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>O(e,{stringConfirm:()=>X(e.target.value),cancel:Oe,tabForward:()=>{X(e.target.value),A(W)},tabBack:()=>{X(e.target.value),A(C(B.fullData,W,"prev",N))}}),style:{width:String(G).length/1.5+.5+"em"}}),e("div",{className:"jer-value-and-buttons",children:[t("div",{className:"jer-input-component",children:ze}),we?t(ne,{onOk:Ce,onCancel:Oe,nodeData:B}):Te&&t(te,{startEdit:H?()=>A(W,Oe):void 0,handleDelete:U?()=>{d(M,W).then((e=>{e&&J({code:"DELETE_ERROR",message:e},M)}))}:void 0,enableClipboard:g,translate:w,customButtons:n.customButtons,nodeData:B,handleKeyboard:O,keyboardControls:S}),Ae&&e("div",{className:"jer-select",children:[t("select",{name:`${G}-type-select`,className:"jer-type-select",onChange:e=>(e=>{const t=k.find((t=>t.name===e));if(t)i(t.defaultValue,W),ge(e),A(null),T({path:W,collapsed:!1});else{const t=pe(M,e,w("DEFAULT_NEW_KEY",B),(null==se?void 0:se.CustomNode)?w("DEFAULT_STRING",B):void 0);i(t,W).then((e=>{e&&(J({code:"UPDATE_ERROR",message:e},t),A(null))}))}})(e.target.value),value:ce,children:De.map((e=>t("option",{value:e,children:e},e)))}),t("span",{className:"focus"})]}),xe&&t("span",{className:"jer-error-slug",style:x("error",B),children:$})]})]}),t(re,{position:"below",nodeData:B})]}))},de=(e,t)=>(null==t?void 0:t.CustomNode)&&(null==t?void 0:t.name)&&t.showInTypesSelector?t.name:"string"==typeof e?"string":"number"==typeof e?"number":"boolean"==typeof e?"boolean":null===e?"null":"invalid",ue=(e,n)=>{const r=de(e),{value:o}=n;switch(r){case"string":return t(B,Object.assign({},n,{value:o}));case"number":return t(W,Object.assign({},n,{value:o}));case"boolean":return t(G,Object.assign({},n,{value:o}));case"null":return t(H,Object.assign({},n));default:return t(U,Object.assign({},n))}},pe=(e,t,n,r)=>{switch(t){case"string":return null!=r?r:String(e);case"number":{const t=Number(e);return isNaN(t)?0:t}case"boolean":return!!e;case"null":return null;case"object":return{[n]:e};case"array":return[e];default:return String(e)}},ge=r=>{const{getStyles:o}=P(),{collapseState:c,setCollapseState:d,doesPathMatch:u,currentlyEditingElement:p,setCurrentlyEditingElement:b,areChildrenBeingEdited:f}=_(),{mainContainerRef:v,data:j,nodeData:D,parentData:w,showCollectionCount:k,onEdit:O,onAdd:S,onDelete:x,canDragOnto:A,collapseFilter:T,collapseAnimationTime:R,onMove:V,enableClipboard:z,searchFilter:F,searchText:M,indent:K,sort:L,showArrayIndices:I,defaultValue:B,translate:W,customNodeDefinitions:G,jsonParse:H,jsonStringify:U,TextEditor:Y,keyboardControls:$,handleKeyboard:J,insertAtTop:X}=r,[Z,Q]=a(U(j)),q=T(D),{contentRef:re,isAnimating:oe,maxHeight:de,collapsed:ue,animateCollapse:pe,cssTransitionValue:me}=((e,t,n,r)=>{const[o,l]=a(n?0:void 0),[s,c]=a(n),d=i(!1),u=i(null),p=i(0),g=i(),m=t/1e3+"s";return{contentRef:u,isAnimating:d.current,animateCollapse:n=>{var o,a;if(s!==n){switch(window.clearTimeout(g.current),d.current=!0,n){case!0:{const e=null!==(a=null===(o=u.current)||void 0===o?void 0:o.offsetHeight)&&void 0!==a?a:0;p.current=e,l(e),setTimeout((()=>{l(0)}),5);break}case!1:l(p.current||se(e,u,r))}c(!s),g.current=window.setTimeout((()=>{d.current=!1,n||l(void 0)}),t)}},maxHeight:o,collapsed:s,cssTransitionValue:m}})(j,R,q,v),{pathString:he,nodeData:ye,path:be,name:fe,size:ve,canEdit:je,canDelete:Ee,canAdd:De,canDrag:we,error:ke,setError:Ce,onError:Oe,handleEditKey:Se,derivedValues:Ne}=ie({props:r,collapsed:ue}),{dragSourceProps:xe,getDropTargetProps:Ae,BottomDropTarget:Te,DropTargetPadding:Pe}=le({canDrag:we,canDragOnto:A,path:be,nodeData:ye,onMove:V,onError:Oe,translate:W}),Re=i(!q),{isEditing:Ve,isEditingKey:ze,isArray:Fe,canEditKey:Me}=Ne;l((()=>{Q(U(j)),Ve&&b(null)}),[j]),l((()=>{const e=T(ye)&&!Ve;Re.current=!e,pe(e)}),[T]),l((()=>{null!==c&&u(be)&&(Re.current=!0,pe(c.collapsed))}),[c]);const Ke=i(null),_e=s((()=>(e,t)=>"function"!=typeof B?B:B(e,t)),[B]),{CustomNode:Le,customNodeProps:Ie,CustomWrapper:Be,wrapperProps:We={},hideKey:Ge,showEditTools:He=!0,showOnEdit:Ue,showOnView:Ye,showCollectionWrapper:$e=!0}=s((()=>ae(G,ye)),[j]),Je=f(he);Je&&ue&&pe(!1);if(!(y("collection",ye,F,M)||0===ye.level)&&!Je)return null;const Xe=Array.isArray(j)?"array":"object",Ze="array"===Xe?{open:"[",close:"]"}:{open:"{",close:"}"},Qe=e=>{if("Tab"!==e.key||e.getModifierState("Shift"))J(e,{objectConfirm:et,cancel:nt});else{e.preventDefault();const t=N(Ke,"\t");Q(t)}},qe=e=>{const t=E(e);if(t&&$.collapseModifier.includes(t))return Re.current=!0,void d({collapsed:!ue,path:be});p&&p.includes(he)||(Re.current=!0,d(null),pe(!ue))},et=()=>{try{const e=H(Z);if(b(null),Ce(null),JSON.stringify(e)===JSON.stringify(j))return;O(e,be).then((t=>{t&&Oe({code:"UPDATE_ERROR",message:t},e)}))}catch(e){Oe({code:"INVALID_JSON",message:W("ERROR_INVALID_JSON",ye)},Z)}},tt=be.length>0?()=>{x(j,be).then((e=>{e&&Oe({code:"DELETE_ERROR",message:e},j)}))}:void 0,nt=()=>{b(null),Ce(null),Q(U(j))},rt="when-closed"===k?ue:k,ot=!Ve&&He,at=(I||!Fe)&&!Ge&&void 0!==fe,it=Le&&(Ve&&Ue||!Ve&&Ye),lt=Object.entries(j).map((([e,t])=>["array"===Xe?Number(e):e,t]));"object"===Xe&&L(lt,(e=>e));const st=Re.current?Ve?e("div",{className:"jer-collection-text-edit",children:[Y?t(Y,{value:Z,onChange:Q,onKeyDown:e=>J(e,{objectConfirm:et,cancel:nt})}):t(m,{textAreaRef:Ke,className:"jer-collection-text-area",name:he,value:Z,setValue:Q,isEditing:Ve,handleKeyPress:Qe,styles:o("input",ye)}),t("div",{className:"jer-collection-input-button-row",children:t(ne,{onOk:et,onCancel:nt,nodeData:ye})})]}):lt.map((([e,n],a)=>{const i={key:e,value:n,path:[...be,e],level:be.length+1,index:a,size:h(n)?Object.keys(n).length:1,parentData:j,fullData:ye.fullData};return t("div",{className:"jer-collection-element",style:o("collectionElement",i),children:h(n)?t(ge,Object.assign({},r,{data:n,parentData:j,nodeData:i,showCollectionCount:k,canDragOnto:je}),e):t(ce,Object.assign({},r,{data:n,parentData:j,nodeData:i,canDragOnto:je,showLabel:"object"===Xe||I}),e)},e)})):null,ct=!!$e&&(ue&&!Je);ct||(Re.current=!0);const dt=Object.assign(Object.assign({},r),{data:j,value:j,parentData:w,nodeData:ye,setValue:e=>g(void 0,void 0,void 0,(function*(){return yield O(e,be)})),handleEdit:et,handleCancel:nt,handleKeyPress:Qe,isEditing:Ve,setIsEditing:()=>b(be),getStyles:o,canDragOnto:je}),ut=it?t(Le,Object.assign({customNodeProps:Ie},dt,{children:st})):st,pt=ze?t("input",{className:"jer-input-text jer-key-edit",type:"text",name:he,defaultValue:fe,autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>J(e,{stringConfirm:()=>Se(e.target.value),cancel:nt,tabForward:()=>{Se(e.target.value);const t=null==lt?void 0:lt[0][0];b(t?[...be,t]:C(ye.fullData,be,"next",L))},tabBack:()=>{Se(e.target.value),b(C(ye.fullData,be,"prev",L))}}),style:{width:String(fe).length/1.5+.5+"em"}}):at&&t("span",{className:"jer-key-text",style:o("property",ye),onClick:e=>e.stopPropagation(),onDoubleClick:()=>Me&&b(be,"key"),children:""===fe?t("span",{className:be.length>0?"jer-empty-string":void 0}):`${fe}:`}),gt=ot&&t(te,{startEdit:je?()=>{Re.current=!0,b(be)}:void 0,handleAdd:De?e=>{pe(!1);const t=_e(ye,e);if("array"===Xe){const e=X.array?0:j.length,n=X.array?{insert:!0}:{};S(t,[...be,e],n).then((e=>{e&&Oe({code:"ADD_ERROR",message:e},t)}))}else if(e in j)Oe({code:"KEY_EXISTS",message:W("ERROR_KEY_EXISTS",ye)},e);else{const n=X.object?{insertBefore:0}:{};S(t,[...be,e],n).then((e=>{e&&Oe({code:"ADD_ERROR",message:e},t)}))}}:void 0,handleDelete:Ee?tt:void 0,enableClipboard:z,type:Xe,nodeData:ye,translate:W,customButtons:r.customButtons,keyboardControls:$,handleKeyboard:J}),mt=e("div",Object.assign({className:"jer-component jer-collection-component",style:Object.assign(Object.assign({marginLeft:(0===be.length?0:K/2)+"em"},o("collection",ye)),{position:"relative"}),draggable:we},xe,Ae("above"),{children:[t("div",{className:"jer-clickzone",style:{width:K/2+1+"em",zIndex:10+2*ye.level},onClick:e=>qe(e)}),!Ve&&Te,t(Pe,{position:"above",nodeData:ye}),$e?e("div",{className:"jer-collection-header-row",style:{position:"relative"},onClick:e=>qe(e),children:[e("div",{className:"jer-collection-name",children:[t("div",{className:"jer-collapse-icon jer-accordion-icon"+(ue?" jer-rotate-90":""),style:{zIndex:11+2*ye.level,transition:me},onClick:e=>qe(e),children:t(ee,{name:"chevron",rotate:ue,nodeData:ye})}),pt,!Ve&&t("span",{className:"jer-brackets jer-bracket-open",style:o("bracket",ye),children:Ze.open})]}),!Ve&&rt&&t("div",{className:"jer-collection-item-count"+(rt?" jer-visible":" jer-hidden"),style:Object.assign(Object.assign({},o("itemCount",ye)),{transition:me}),children:1===ve?W("ITEM_SINGLE",Object.assign(Object.assign({},ye),{size:1}),1):W("ITEMS_MULTIPLE",ye,ve)}),t("div",{className:"jer-brackets"+(ct?" jer-visible":" jer-hidden"),style:Object.assign(Object.assign({},o("bracket",ye)),{transition:me}),children:Ze.close}),gt]}):Ge?t(n,{}):e("div",{className:"jer-collection-header-row",style:{position:"relative"},children:[pt,gt]}),e("div",{className:"jer-collection-inner",style:Object.assign(Object.assign({overflowY:ct||oe?"clip":"visible",maxHeight:Je?void 0:de},o("collectionInner",ye)),{transition:me}),ref:re,children:[ut,t("div",{className:Ve?"jer-collection-error-row":"jer-collection-error-row-edit",children:ke&&t("span",{className:"jer-error-slug",style:o("error",ye),children:ke})}),!Ve&&$e&&t("div",{className:"jer-brackets jer-bracket-outside",style:Object.assign(Object.assign({},o("bracket",ye)),{marginLeft:(K<3?-1:K<6?-.5:0)+"em"}),children:Ze.close})]}),t(Pe,{position:"below",nodeData:ye})]}));return Be?t(Be,Object.assign({customNodeProps:We},dt,{children:mt})):mt},me={ITEM_SINGLE:"{{count}} item",ITEMS_MULTIPLE:"{{count}} items",KEY_NEW:"Enter new key",ERROR_KEY_EXISTS:"Key already exists",ERROR_INVALID_JSON:"Invalid JSON",ERROR_UPDATE:"Update unsuccessful",ERROR_DELETE:"Delete unsuccessful",ERROR_ADD:"Adding node unsuccessful",DEFAULT_STRING:"New data!",DEFAULT_NEW_KEY:"key",SHOW_LESS:"(Show less)"},he=(e,t)=>(n,r,o)=>((e,t,n,r,o)=>{if(t[r]){const e=t[r](n);if(null!==e)return e}const a=r in e?e[r]:me[r];return void 0===o?a:null==a?void 0:a.replace("{{count}}",String(o))})(e,t,r,n,o);var ye=[],be=[];!function(e,t){if(e&&"undefined"!=typeof document){var n,r=!0===t.prepend?"prepend":"append",o=!0===t.singleTag,a="string"==typeof t.container?document.querySelector(t.container):document.getElementsByTagName("head")[0];if(o){var i=ye.indexOf(a);-1===i&&(i=ye.push(a)-1,be[i]={}),n=be[i]&&be[i][r]?be[i][r]:be[i][r]=l()}else n=l();65279===e.charCodeAt(0)&&(e=e.substring(1)),n.styleSheet?n.styleSheet.cssText+=e:n.appendChild(document.createTextNode(e))}function l(){var e=document.createElement("style");if(e.setAttribute("type","text/css"),t.attributes)for(var n=Object.keys(t.attributes),o=0;o<n.length;o++)e.setAttribute(n[o],t.attributes[n[o]]);var i="prepend"===r?"afterbegin":"beforeend";return a.insertAdjacentElement(i,e),e}}(':root{--jer-select-border:#b6b6b6;--jer-select-focus:#777;--jer-select-arrow:#777;--jer-form-border:1px solid #ededf0;--jer-form-border-focus:1px solid #e2e2e2;--jer-highlight-color:#b3d8ff}.jer-visible{opacity:1}.jer-hidden{opacity:0}.jer-select select{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:transparent;border:none;color:#000;cursor:inherit;font-family:inherit;font-size:.8em;line-height:inherit;margin:0;outline:none;padding:0 1em 0 0;z-index:1}select::-ms-expand{display:none}.jer-select{align-items:center;background-color:#fff;background-image:linear-gradient(0deg,#f9f9f9,#fff 33%);border:1px solid var(--jer-select-border);border-radius:.25em;cursor:pointer;display:grid;grid-template-areas:"select";line-height:1.1;max-width:15ch;min-width:12ch;padding:.25em .5em;position:relative}.jer-select select,.jer-select:after{grid-area:select}.jer-select:not(.jer-select--multiple):after{background-color:var(--jer-select-arrow);clip-path:polygon(100% 0,0 0,50% 100%);content:"";height:.5em;justify-self:end;width:.8em}select:focus+.focus{border:1px solid var(--jer-select-focus);border-radius:inherit;bottom:-1px;left:-1px;position:absolute;right:-1px;top:-1px}.jer-editor-container{border-radius:.5em;font-size:16px;line-height:1;padding:1em 1em 1em 2em;position:relative;text-align:left}.jer-editor-container textarea{border:var(--jer-form-border);border-radius:.3em;color:var(--jer-input-color);outline:none}.jer-editor-container textarea:focus{border:var(--jer-form-border-focus)}.jer-editor-container input{border:var(--jer-form-border);border-radius:.3em;font-family:inherit;outline:none}.jer-editor-container input:focus{border:var(--jer-form-border-focus)}.jer-editor-container ::selection{background-color:var(--jer-highlight-color)}.jer-collection-header-row,.jer-value-main-row{align-items:center;display:flex;gap:.3em;min-height:1.7em}.jer-collection-header-row{display:flex;flex-wrap:wrap}.jer-collapse-icon{left:-1.2em;position:absolute;top:.35em}.jer-collection-inner{position:relative}.jer-collection-text-edit{align-items:flex-start;display:flex;flex-direction:column;gap:.3em;line-height:1.1em}.jer-collection-text-area{font-family:inherit;font-size:.85em;max-height:40em;overflow:hidden;padding:.2em .5em 0;resize:both}.jer-collection-input-button-row{display:flex;font-size:150%;justify-content:flex-end;margin-top:.4em;width:100%}.jer-collection-error-row{bottom:.5em;position:absolute}.jer-error-slug{margin-left:1em}.jer-value-component{position:relative}.jer-value-main-row{display:flex;gap:0}.jer-value-and-buttons{align-items:center;display:flex;justify-content:flex-start;padding-left:.5em}.jer-value-error-row{position:absolute}.jer-value-string{line-height:1.3em;overflow-wrap:anywhere;white-space:pre-wrap;word-break:break-word}.jer-string-expansion{cursor:pointer;filter:saturate(50%);opacity:.6}.jer-show-less{font-size:80%}.jer-hyperlink{text-decoration:underline}.jer-input-text{font-family:inherit;font-size:.9em;height:1.4em;line-height:1.2em;margin:0;min-width:6em;overflow:hidden;padding:.25em .5em .2em;resize:none}.jer-input-boolean{margin-left:.3em;margin-right:.3em;transform:scale(1.5)}.jer-key-text{line-height:1.1em;white-space:pre-wrap;word-break:break-word}.jer-key-edit{font-size:inherit;font-size:.9em;padding:0 .3em}.jer-value-invalid{font-style:italic;opacity:.5}.jer-input-number{font-size:90%;min-width:3em}.jer-confirm-buttons,.jer-edit-buttons{align-items:center;cursor:pointer;display:flex;height:1em}.jer-input-buttons{gap:.4em}.jer-edit-buttons{gap:.4em;margin-left:.5em;opacity:0}.jer-confirm-buttons{gap:.2em;margin-left:.4em}.jer-edit-buttons:hover{opacity:1;position:relative}.jer-collection-header-row:hover>.jer-edit-buttons,.jer-value-and-buttons:hover>.jer-edit-buttons,.jer-value-main-row:hover>.jer-edit-buttons{opacity:1}.jer-copy-pulse{position:relative;transition:.3s}.jer-copy-pulse:hover{opacity:.85;transform:scale(1.2);transition:.3s}.jer-copy-pulse:after{border-radius:50%;box-shadow:0 0 15px 5px var(--jer-icon-copy-color);content:"";display:block;height:100%;left:0;opacity:0;position:absolute;top:0;transition:all .5s;width:100%}.jer-copy-pulse:active:after{border-radius:4em;box-shadow:0 0 0 0 var(--jer-icon-copy-color);left:0;opacity:1;position:absolute;top:0;transition:0s}.jer-copy-pulse:active{top:.07em}.jer-rotate-90{transform:rotate(-90deg)}.jer-icon:hover{opacity:.85;transform:scale(1.2);transition:.3s}.jer-empty-string:after{content:"<empty string>:";font-size:90%;font-style:italic}.jer-drag-n-drop-padding{border:1px dashed #e0e0e0;border-radius:.3em;height:.5em}.jer-clickzone{height:calc(100% - .8em);left:-1em;position:absolute;top:1.2em}',{});const fe=({data:e,setData:n,rootName:r="root",onUpdate:o=(()=>{}),onEdit:d=o,onDelete:u=o,onAdd:p=o,onChange:m,onError:y,showErrorMessages:b=!0,enableClipboard:f=!0,indent:v=2,collapse:j=!1,collapseAnimationTime:E=300,showCollectionCount:w=!0,restrictEdit:C=!1,restrictDelete:O=!1,restrictAdd:S=!1,restrictTypeSelection:N=!1,restrictDrag:x=!0,viewOnly:A,searchFilter:T,searchText:R,searchDebounceTime:V=350,keySort:z=!1,showArrayIndices:F=!0,showStringQuotes:M=!0,defaultValue:K=null,minWidth:L=250,maxWidth:I="min(600px, 90vw)",rootFontSize:B,stringTruncate:W=250,translations:G={},className:H,id:U,customText:Y={},customNodeDefinitions:$=[],customButtons:J=[],jsonParse:X=JSON.parse,jsonStringify:Z=(e=>JSON.stringify(e,null,2)),TextEditor:Q,errorMessageTimeout:q=2500,keyboardControls:ee={},insertAtTop:te=!1})=>{const{getStyles:ne}=P(),{setCurrentlyEditingElement:re}=_(),oe=c(Ee(j),[j]),ae=c(he(G,Y),[G,Y]),[ie,le]=a(R),[se,de]=(({setData:e,data:t})=>{const[n,r]=a(e?void 0:t),o=c((t=>{e?e(t):r(t)}),[e]);return l((()=>{e||r(t)}),[t]),[e?t:n,o]})({setData:n,data:e}),ue=i(null);l((()=>{re(null);const e=setTimeout((()=>le(R)),V);return()=>clearTimeout(e)}),[R,V]);const pe={key:r,path:[],level:0,index:0,value:se,size:"object"==typeof se&&null!==se?Object.keys(se).length:1,parentData:null,fullData:se},me=(e,t)=>g(void 0,void 0,void 0,(function*(){const n=yield e(t);if(!0===n||void 0===n)return void de(t.newData);const r=we(n)?n:["error",n],[o,a]=r;if("error"===o)return de(t.currentData),!1===a?ae("ERROR_UPDATE",pe):String(a);de(a)})),ye=s((()=>Ee(C,A)),[C,A]),be=s((()=>Ee(O,A)),[O,A]),fe=s((()=>Ee(S,A)),[S,A]),ve=s((()=>Ee(x,A)),[x,A]),ke=s((()=>De(T)),[T]),Ce=s((()=>(e=>{const t=Object.assign({},k);for(const n of Object.keys(k)){const r=n;if(e[r]){const o=e[r],a=["clipboardModifier","collapseModifier"].includes(n)?Array.isArray(o)?o:[o]:"string"==typeof o?{key:o}:o;t[r]=a,["stringConfirm","numberConfirm","booleanConfirm"].forEach((n=>{!e[n]&&e.confirm&&(t[n]=t.confirm)}))}}return t})(ee)),[ee]),Oe=c(((e,t)=>((e,t,n)=>{const r=Object.entries(t);for(const[t,o]of r)if(D(n,e[t],t)){n.preventDefault(),o();break}})(Ce,t,e)),[ee]),Se=c(((e,t)=>{!1!==z&&("function"!=typeof z?e.sort(((e,n)=>{const r=t(e)[0],o=t(n)[0];return r<o?-1:r>o?1:0})):e.sort(((e,n)=>z(t(e),t(n)))))}),[z]),Ne={mainContainerRef:ue,name:r,nodeData:pe,onEdit:(e,t)=>g(void 0,void 0,void 0,(function*(){const{currentData:n,newData:r,currentValue:o,newValue:a}=je(se,t,e,"update");if(o!==a)return yield me(d,{currentData:n,newData:r,currentValue:o,newValue:a,name:t.slice(-1)[0],path:t})})),onDelete:(e,t)=>g(void 0,void 0,void 0,(function*(){const{currentData:n,newData:r,currentValue:o,newValue:a}=je(se,t,e,"delete");return yield me(u,{currentData:n,newData:r,currentValue:o,newValue:a,name:t.slice(-1)[0],path:t})})),onAdd:(e,t,n)=>g(void 0,void 0,void 0,(function*(){const{currentData:r,newData:o,currentValue:a,newValue:i}=je(se,t,e,"add",n);return yield me(p,{currentData:r,newData:o,currentValue:a,newValue:i,name:t.slice(-1)[0],path:t})})),onChange:m,onError:y,showErrorMessages:b,onMove:(e,t,n)=>g(void 0,void 0,void 0,(function*(){if(null===e)return;const{currentData:r,newData:o,currentValue:a}=je(se,e,"","delete"),i=e.slice(-1)[0],l=t.slice(0,-1),s=t.slice(-1)[0];let c="number"==typeof s?"above"===n?s:s+1:"number"==typeof i?`arr_${i}`:i;e.slice(0,-1).join(".")===t.slice(0,-1).join(".")&&"number"==typeof i&&"number"==typeof c&&i<c&&(c-=1);const u="number"==typeof c?{insert:!0}:"above"===n?{insertBefore:s}:{insertAfter:s},{newData:p,newValue:g}=je(o,[...l,c],a,"add",u);return yield me(d,{currentData:r,newData:p,currentValue:a,newValue:g,name:t.slice(-1)[0],path:t})})),showCollectionCount:w,collapseFilter:oe,collapseAnimationTime:E,restrictEditFilter:ye,restrictDeleteFilter:be,restrictAddFilter:fe,restrictTypeSelection:N,restrictDragFilter:ve,canDragOnto:!1,searchFilter:ke,searchText:ie,enableClipboard:f,keySort:z,sort:Se,showArrayIndices:F,showStringQuotes:M,indent:v,defaultValue:K,stringTruncate:W,translate:ae,customNodeDefinitions:$,customButtons:J,parentData:null,jsonParse:X,jsonStringify:Z,TextEditor:Q,errorMessageTimeout:q,handleKeyboard:Oe,keyboardControls:Ce,insertAtTop:{object:!0===te||"object"===te,array:!0===te||"array"===te}},xe=Object.assign(Object.assign({},ne("container",pe)),{minWidth:L,maxWidth:I});return xe.fontSize=null!=B?B:xe.fontSize,t("div",{id:U,ref:ue,className:`jer-editor-container ${null!=H?H:""}`,style:xe,children:h(se)?t(ge,Object.assign({data:se},Ne)):t(ce,Object.assign({data:se,showLabel:!0},Ne))})},ve=e=>{var n;const[r,o]=a();return l((()=>{const e=document.documentElement;o(e)}),[]),r?t(T,{theme:null!==(n=e.theme)&&void 0!==n?n:x,icons:e.icons,docRoot:r,children:t(K,{children:t(fe,Object.assign({},e))})}):null},je=(e,t,n,r,o={})=>{if(0===t.length)return{currentData:e,newData:n,currentValue:e,newValue:n};const a=Object.assign({remove:"delete"===r},o),i="add"!==r?u(e,t):void 0;return{currentData:e,newData:d(e,t,n,a),currentValue:i,newValue:"delete"!==r?n:void 0}},Ee=(e,t)=>t?()=>!0:"boolean"==typeof e?()=>e:"number"==typeof e?({level:t})=>t>=e:e,De=e=>{if(void 0!==e)return"value"===e?f:"key"===e?v:"all"===e?(e,t)=>f(e,t)||v(e,t):e},we=e=>Array.isArray(e)&&2===e.length&&["error","value"].includes(e[0]),ke=e=>{var n;const{value:r,setIsEditing:o,getStyles:a,nodeData:i}=e,l=a("string",i),{canEdit:s}=ie({props:e});return t("div",{onDoubleClick:()=>o(!0),onClick:e=>{(e.getModifierState("Control")||e.getModifierState("Meta"))&&o(!0)},className:"jer-value-string jer-hyperlink",style:l,children:t("a",{href:r,target:"_blank",rel:"noreferrer",style:{color:null!==(n=l.color)&&void 0!==n?n:void 0},children:t(I,Object.assign({},e,{nodeData:i,pathString:j(i.path),styles:l,canEdit:s}))})})},Ce={condition:({value:e})=>"string"==typeof e&&/^https?:\/\/.+\..+$/.test(e),element:ke,showOnView:!0,showOnEdit:!1},Oe={displayName:"Github Dark",styles:{container:{backgroundColor:"#0d1117",color:"white"},dropZone:"rgba(165, 214, 255, 0.17)",property:"#E6EDF3",bracket:"#56d364",itemCount:"#8B949E",string:"#A5D6FF",number:"#D2A8FF",boolean:{color:"#FF7B72",fontSize:"90%",fontWeight:"bold"},null:"green",iconCollection:"#D2A8FF",iconEdit:"#D2A8FF",iconDelete:"rgb(203, 75, 22)",iconAdd:"rgb(203, 75, 22)",iconCopy:"#A5D6FF",iconOk:"#56d364",iconCancel:"rgb(203, 75, 22)"}},Se={displayName:"Github Light",styles:{container:"white",property:"#1F2328",bracket:"#00802e",itemCount:"#8B949E",string:"#0A3069",number:"#953800",boolean:{color:"#CF222E",fontSize:"90%",fontWeight:"bold"},null:"#FF7B72",iconCollection:"#8250DF",iconEdit:"#8250DF",iconDelete:"rgb(203, 75, 22)",iconAdd:"#8250DF",iconCopy:"#57606A"}},Ne={displayName:"Black & White",fragments:{lightText:{color:"white"},midGrey:"#5c5c5c"},styles:{container:["lightText",{backgroundColor:"black"}],dropZone:"#e0e0e029",property:"lightText",bracket:"midGrey",itemCount:"#4a4a4a",string:"#a8a8a8",number:"#666666",boolean:{color:"#848484",fontStyle:"italic"},null:"#333333",iconCollection:"midGrey",iconEdit:"midGrey",iconDelete:"midGrey",iconAdd:"midGrey",iconCopy:"midGrey",iconOk:"midGrey",iconCancel:"midGrey"}},xe={fragments:{midGrey:"#a3a3a3"},displayName:"White & Black",styles:{container:"white",property:"black",bracket:"midGrey",itemCount:"#b5b5b5",string:"#575757",number:"#999999",boolean:{color:"#7b7b7b",fontStyle:"italic"},null:"#cccccc",iconCollection:"midGrey",iconEdit:"midGrey",iconDelete:"midGrey",iconAdd:"midGrey",iconCopy:"midGrey",iconOk:"midGrey",iconCancel:"midGrey"}},Ae={displayName:"Candy Wrapper",fragments:{minty:{backgroundColor:"#F1FAEE"},pale:{color:"#A8DADC"},mid:{color:"#457B9D"},dark:{color:"#1D3557"},pop:{color:"#E63946"},darkBlue:{color:"#2B2D42"}},styles:{container:"minty",property:"pop",dropZone:"#eb121217",bracket:"dark",itemCount:"pale",string:"mid",number:["darkBlue",{fontSize:"85%"}],boolean:["mid",{fontStyle:"italic",fontWeight:"bold",fontSize:"80%"}],null:["#cccccc",{fontWeight:"bold"}],input:{border:"1px solid rgb(115, 194, 198)"},iconCollection:"#1D3557",iconEdit:"#457B9D",iconDelete:"#E63946",iconAdd:"#2B2D42",iconCopy:"#1D3557",iconCancel:"#E63946"}},Te={displayName:"Psychedelic",fragments:{pale:{color:"#A8DADC"},fluroYellow:"rgb(242, 228, 21)",fluroGreen:"rgb(68, 255, 62)",hotPink:"#f7379a"},styles:{container:{backgroundColor:"unset",background:"linear-gradient(90deg, hsla(333, 100%, 53%, 1) 0%, hsla(33, 94%, 57%, 1) 100%)",color:"black"},dropZone:"fluroYellow",property:"black",bracket:"fluroYellow",itemCount:["pale",{opacity:.7}],string:"white",number:["#33d9ff",{fontSize:"90%",fontWeight:"bold"}],boolean:["fluroGreen",{fontWeight:"bold",fontSize:"80%"}],null:["black",{fontWeight:"bold",opacity:.3,backgroundColor:"rgb(255, 255, 255, 0.5)",padding:"0 0.4em",borderRadius:"0.4em"}],iconCollection:"fluroYellow",iconEdit:["black"],iconDelete:["white",{opacity:.5}],iconAdd:["white",{opacity:.5}],iconCopy:"rgb(32, 84, 242)",iconOk:"fluroGreen",iconCancel:"hotPink"}};export{Y as IconAdd,Q as IconCancel,q as IconChevron,X as IconCopy,J as IconDelete,$ as IconEdit,Z as IconOk,ve as JsonEditor,ke as LinkCustomComponent,Ce as LinkCustomNodeDefinition,I as StringDisplay,Ae as candyWrapperTheme,x as defaultTheme,Oe as githubDarkTheme,Se as githubLightTheme,h as isCollection,f as matchNode,v as matchNodeKey,Ne as monoDarkTheme,xe as monoLightTheme,Te as psychedelicTheme};
1
+ import{jsxs as e,jsx as t,Fragment as n}from"react/jsx-runtime";import{createContext as r,useContext as o,useState as i,useRef as a,useEffect as l,useMemo as s,useCallback as c}from"react";import d from"object-property-assigner";export{default as assign}from"object-property-assigner";import u from"object-property-extractor";export{default as extract}from"object-property-extractor";function p(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}function g(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{s(r.next(e))}catch(e){i(e)}}function l(e){try{s(r.throw(e))}catch(e){i(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,l)}s((r=r.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const h=({className:n,name:r,value:o,setValue:i,handleKeyPress:a,styles:l,textAreaRef:s})=>{if("string"!=typeof o)return null;const c="\n"===o.slice(-1)?o+".":o;return e("div",{style:{display:"grid"},children:[t("textarea",{id:`${r}_textarea`,ref:s,style:Object.assign({height:"auto",gridArea:"1 / 1 / 2 / 2",overflowY:"auto",whiteSpace:"pre-wrap"},l),rows:1,className:n,name:`${r}_textarea`,value:o,onChange:e=>i(e.target.value),autoFocus:!0,onFocus:e=>{o.length<40&&e.target.select()},onKeyDown:a}),t("span",{className:n,style:Object.assign({visibility:"hidden",height:"auto",gridArea:"1 / 1 / 2 / 2",color:"red",opacity:.9,whiteSpace:"pre-wrap",overflowY:"auto",border:"1px solid transparent"},l),children:c})]})},m=e=>null!==e&&"object"==typeof e,y=(e,t,n,r="")=>{if(!n&&!r)return!0;switch(e){case"collection":if(n){if(n(t,r))return!0;if(!f(r,t,n))return!1}if(!n&&r&&!f(r,t))return!1;break;case"value":if(n&&!n(t,r))return!1;if(!n&&r&&!b(t,r))return!1}return!0},f=(e="",t,n=b)=>{const r=t.value;return Object.entries(r).some((([o,i])=>{const a=[...t.path,o],l=Object.assign(Object.assign({},t),{key:o,path:a,level:t.level+1,value:i,size:a.length,parentData:r});return m(i)?f(e,l,n):n(l,e)}))},b=(e,t="")=>{const{value:n}=e;if(null===n&&"null".includes(t.toLowerCase()))return!0;switch(typeof n){case"string":return n.toLowerCase().includes(t.toLowerCase());case"number":return!!String(n).includes(t);case"boolean":return n?"true".includes(t.toLowerCase())||"1"===t:"false".includes(t.toLowerCase())||"0"===t;default:return!1}},v=({key:e,path:t},n="")=>!!b({value:e},n)||!!t.some((e=>b({value:e},n))),j=(e,t)=>(null!=t?t:"")+e.map((e=>""===e?String.fromCharCode(0):e)).join("."),E=e=>e.shiftKey?"Shift":e.metaKey?"Meta":e.ctrlKey?"Control":e.altKey?"Alt":void 0,D=(e,t,n)=>{const r=e.key,o=E(e);if(Array.isArray(t))return!!o&&t.includes(o);const{key:i,modifier:a}=t;return("stringLineBreak"!==n||"Enter"!==r||"Shift"!==o||"Enter"!==i||!(null==a?void 0:a.includes("Shift")))&&(r===i&&(a===o||Array.isArray(a)&&a.includes(o)))},w={key:"Enter"},C={confirm:w,cancel:{key:"Escape"},objectConfirm:Object.assign(Object.assign({},w),{modifier:["Meta","Shift","Control"]}),objectLineBreak:w,stringConfirm:w,stringLineBreak:Object.assign(Object.assign({},w),{modifier:["Shift"]}),numberConfirm:w,numberUp:{key:"ArrowUp"},numberDown:{key:"ArrowDown"},tabForward:{key:"Tab"},tabBack:{key:"Tab",modifier:"Shift"},booleanConfirm:w,booleanToggle:{key:" "},clipboardModifier:["Meta","Control"],collapseModifier:["Alt"]},k=(e,t,n="next",r)=>{const o=t.slice(0,t.length-1),i=t.slice(-1)[0];if(void 0===i)return null;const a=u(e,o),l=S(a);Array.isArray(a)||r(l,(({key:e,value:t})=>[e,t]));const s=l.findIndex((e=>e.key===i)),c=l[s+("next"===n?1:-1)];return c?m(c.value)?0===Object.keys(c.value).length?k(e,[...o,c.key],n,r):O(e,[...o,c.key],n,r):[...o,c.key]:0===o.length?null:k(e,o,n,r)},O=(e,t,n="next",r)=>{const o=u(e,t);if(!m(o))return t;const i=Array.isArray(o)?o.map(((e,t)=>t)):Object.keys(o);r(i,(e=>[e,o]));const a="next"===n?i[0]:i[i.length-1];return O(e,[...t,a],n,r)},S=e=>Array.isArray(e)?e.map(((e,t)=>({index:t,value:e,key:t}))):Object.entries(e).map((([e,t],n)=>({key:e,value:t,index:n}))),N=(e,t)=>{var n,r,o,i;const a=e.current,l=null!==(n=null==a?void 0:a.selectionStart)&&void 0!==n?n:1/0,s=null!==(r=null==a?void 0:a.selectionEnd)&&void 0!==r?r:1/0,c=(null===(o=null==a?void 0:a.textContent)||void 0===o?void 0:o.slice(0,l))+t+(null===(i=null==a?void 0:a.textContent)||void 0===i?void 0:i.slice(s));return a.value=c,null==a||a.setSelectionRange(l+1,l+1),c},x={displayName:"Default",fragments:{edit:"rgb(42, 161, 152)"},styles:{container:{backgroundColor:"#f6f6f6",fontFamily:"monospace"},collection:{},collectionInner:{},collectionElement:{},dropZone:{},property:"#292929",bracket:{color:"rgb(0, 43, 54)",fontWeight:"bold"},itemCount:{color:"rgba(0, 0, 0, 0.3)",fontStyle:"italic"},string:"rgb(203, 75, 22)",number:"rgb(38, 139, 210)",boolean:"green",null:{color:"rgb(220, 50, 47)",fontVariant:"small-caps",fontWeight:"bold"},input:["#292929"],inputHighlight:"#b3d8ff",error:{fontSize:"0.8em",color:"red",fontWeight:"bold"},iconCollection:"rgb(0, 43, 54)",iconEdit:"edit",iconDelete:"rgb(203, 75, 22)",iconAdd:"edit",iconCopy:"rgb(38, 139, 210)",iconOk:"green",iconCancel:"rgb(203, 75, 22)"}},A=r({getStyles:()=>({}),icons:{}}),T=({theme:e=x,icons:n={},docRoot:r,children:o})=>{const i=P(e,r);return t(A.Provider,{value:{getStyles:(e,t)=>"function"==typeof i[e]?i[e](t):i[e],icons:n},children:o})},R=()=>o(A),P=(e,t)=>{var n,r,o,i;const a={},l=(Array.isArray(e)?e:[e]).map((e=>K(e)?V({fragments:{},styles:e},a):V(e,a))),s=V(x,{});Object.keys(s).forEach((e=>{const t=e;l.forEach((e=>{e[t]&&(s[t]=Object.assign(Object.assign({},s[t]),e[t]))}))}));const c=Object.assign({},s);return Object.entries(a).forEach((([e,t])=>{const n=e;c[n]=e=>{const r=t(e)||{};return Object.assign(Object.assign({},s[n]),r)}})),"function"!=typeof(null==c?void 0:c.inputHighlight)&&(null===(n=null==c?void 0:c.inputHighlight)||void 0===n?void 0:n.backgroundColor)&&t.style.setProperty("--jer-highlight-color",null===(r=null==c?void 0:c.inputHighlight)||void 0===r?void 0:r.backgroundColor),"function"!=typeof(null==c?void 0:c.iconCopy)&&(null===(o=null==c?void 0:c.iconCopy)||void 0===o?void 0:o.color)&&t.style.setProperty("--jer-icon-copy-color",null===(i=null==c?void 0:c.iconCopy)||void 0===i?void 0:i.color),c},V=(e,t)=>{const{fragments:n,styles:r}=e,o={};return Object.entries(r).forEach((([e,r])=>{const i=(Array.isArray(r)?r:[r]).reduce(((r,o)=>{var i,a;if("function"==typeof o)return t[e]=o,Object.assign({},r);if("string"==typeof o){const t=null!==(i=null==n?void 0:n[o])&&void 0!==i?i:o;return"string"==typeof t?Object.assign(Object.assign({},r),{[null!==(a=z[e])&&void 0!==a?a:"color"]:t}):Object.assign(Object.assign({},r),t)}return Object.assign(Object.assign({},r),o)}),{});o[e]=i})),o},K=e=>!("styles"in e),z={container:"backgroundColor",collection:"backgroundColor",collectionInner:"backgroundColor",collectionElement:"backgroundColor",dropZone:"borderColor",inputHighlight:"backgroundColor"},M=r(null),F=({children:e,onEditEvent:n,onCollapse:r})=>{const[o,l]=i(null),[s,c]=i(null),[d,u]=i(null),[p,g]=i({path:null,pathString:null}),h=a(null),m=a("next"),y=a(null);return t(M.Provider,{value:{collapseState:o,setCollapseState:e=>{l(e),r&&null!==e&&(Array.isArray(e)?e.forEach((e=>r(e))):r(e)),null!==e&&setTimeout((()=>l(null)),2e3)},getMatchingCollapseState:e=>{if(Array.isArray(o)){for(const t of o)if(L(e,t))return t;return null}return L(e,o)?o:null},currentlyEditingElement:s,setCurrentlyEditingElement:(e,t)=>{const r="string"==typeof e||null===e?e:j(e,"key"===t?"key_":void 0);null!==s&&null!==r&&null!==h.current&&h.current(),c(r),n&&n(e,"key"===t),h.current="function"==typeof t?t:null},areChildrenBeingEdited:e=>null!==s&&s.includes(e),previouslyEditedElement:y.current,setPreviouslyEditedElement:e=>{y.current=e},tabDirection:m.current,setTabDirection:e=>{m.current=e},previousValue:d,setPreviousValue:u,dragSource:p,setDragSource:g},children:e})},_=()=>{const e=o(M);if(!e)throw new Error("Missing Context Provider");return e},L=(e,t)=>{if(null===t)return!1;if(!t.includeChildren)return t.path.every(((t,n)=>e[n]===t))&&t.path.length===e.length;for(const[n,r]of t.path.entries())if(r!==e[n])return!1;return!0},I="**INVALID_FUNCTION**",B=({nodeData:r,showStringQuotes:o=!0,stringTruncate:a=200,pathString:l,canEdit:s,setIsEditing:c,styles:d,translate:u})=>{const p=r.value,[g,h]=i(!1),m=o?'"':"",y=p.length>a,f=()=>{s?c(!0):h(!g)};return e("div",{id:`${l}_display`,onDoubleClick:f,onClick:e=>{(e.getModifierState("Control")||e.getModifierState("Meta"))&&f()},className:"jer-value-string",style:d,children:[m,y?e(n,g?{children:[e("span",{children:[p,m]}),e("span",{className:"jer-string-expansion jer-show-less",onClick:()=>h(!1),children:[" ",u("SHOW_LESS",r)]})]}:{children:[t("span",{children:p.slice(0,a-2).trimEnd()}),t("span",{className:"jer-string-expansion jer-ellipsis",onClick:()=>h(!0),children:"..."}),m]}):`${p}${m}`]})},W=e=>{var{value:n,setValue:r,isEditing:o,path:i,handleEdit:l,nodeData:s,handleKeyboard:c,keyboardCommon:d}=e,u=p(e,["value","setValue","isEditing","path","handleEdit","nodeData","handleKeyboard","keyboardCommon"]);const{getStyles:g}=R(),m=a(null),y=j(i);return o?t(h,{className:"jer-input-text",textAreaRef:m,name:y,value:n,setValue:r,isEditing:o,handleKeyPress:e=>{c(e,Object.assign({stringConfirm:l,stringLineBreak:()=>{const e=N(m,"\n");r(e)}},d))},styles:g("input",s)}):t(B,Object.assign({nodeData:s,pathString:y,styles:g("string",s)},u))},G=({value:e,setValue:n,isEditing:r,path:o,setIsEditing:i,handleEdit:a,nodeData:l,handleKeyboard:s,keyboardCommon:c})=>{const{getStyles:d}=R();return r?t("input",{className:"jer-input-number",type:"text",name:j(o),value:e,onChange:e=>n(e.target.value.replace(/[^0-9.-]/g,"")),autoFocus:!0,onFocus:e=>setTimeout((()=>e.target.select()),10),onKeyDown:t=>s(t,Object.assign({numberConfirm:a,numberUp:()=>n(Number(e)+1),numberDown:()=>n(Number(e)-1)},c)),style:Object.assign({width:String(e).length/1.5+2+"em"},d("input",l))}):t("span",{onDoubleClick:()=>i(!0),className:"jer-value-number",style:d("number",l),children:e})},H=({value:e,setValue:n,isEditing:r,path:o,setIsEditing:i,handleEdit:a,nodeData:l,handleKeyboard:s,keyboardCommon:c})=>{const{getStyles:d}=R();return r?t("input",{className:"jer-input-boolean",type:"checkbox",name:j(o),checked:e,onChange:()=>n(!e),onKeyDown:t=>{" "===t.key&&t.preventDefault(),s(t,Object.assign({booleanConfirm:a,booleanToggle:()=>n(!e)},c))},autoFocus:!0}):t("span",{onDoubleClick:()=>i(!0),className:"jer-value-boolean",style:d("boolean",l),children:String(e)})},U=({value:e,isEditing:n,setIsEditing:r,handleEdit:o,nodeData:i,handleKeyboard:s,keyboardCommon:c})=>{const{getStyles:d}=R(),u=a();l((()=>{if(n)return u.current=window.setTimeout((()=>window.addEventListener("keydown",p)),100),()=>window.removeEventListener("keydown",p);window.clearTimeout(u.current)}),[n]);const p=e=>s(e,Object.assign({confirm:o},c));return t("div",{onDoubleClick:()=>r(!0),className:"jer-value-null",style:d("null",i),children:String(e)})},Y=({value:e})=>{let n="Error!";switch(typeof e){case"string":e===I&&(n="Function");break;case"undefined":n="Undefined";break;case"symbol":n="Symbol"}return t("span",{className:"jer-value-invalid",children:n})},$=({size:n,style:r,className:o})=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:n,height:n,className:o,style:r,children:[t("path",{d:"M13 7h-2v4H7v2h4v4h2v-4h4v-2h-4z"}),t("path",{d:"M12 2C6.486 2 2 6.486 2 12s4.486 10 10 10 10-4.486 10-10S17.514 2 12 2zm0 18c-4.411 0-8-3.589-8-8s3.589-8 8-8 8 3.589 8 8-3.589 8-8 8z"})]}),J=({size:n,style:r,className:o})=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:n,height:n,className:o,style:r,transform:"translate(0, 0.5)",children:[t("path",{d:"M7 17.013l4.413-.015 9.632-9.54c.378-.378.586-.88.586-1.414s-.208-1.036-.586-1.414l-1.586-1.586c-.756-.756-2.075-.752-2.825-.003L7 12.583v4.43zM18.045 4.458l1.589 1.583-1.597 1.582-1.586-1.585 1.594-1.58zM9 13.417l6.03-5.973 1.586 1.586-6.029 5.971L9 15.006v-1.589z"}),t("path",{d:"M5 21h14c1.103 0 2-.897 2-2v-8.668l-2 2V19H8.158c-.026 0-.053.01-.079.01-.033 0-.066-.009-.1-.01H5V5h6.847l2-2H5c-1.103 0-2 .897-2 2v14c0 1.103.897 2 2 2z"})]}),Z=({size:e,style:n,className:r})=>t("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:e,height:e,className:r,style:n,children:t("path",{d:"M6 19a2 2 0 002 2h8a2 2 0 002-2V7H6v12m2.46-7.12l1.41-1.41L12 12.59l2.12-2.12 1.41 1.41L13.41 14l2.12 2.12-1.41 1.41L12 15.41l-2.12 2.12-1.41-1.41L10.59 14l-2.13-2.12M15.5 4l-1-1h-5l-1 1H5v2h14V4h-3.5z"})}),X=({size:n,style:r,className:o})=>e("svg",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",width:n,height:n,className:o,style:r,children:[t("path",{d:"M9 2 H15 A1 1 0 0 1 16 3 V5 A1 1 0 0 1 15 6 H9 A1 1 0 0 1 8 5 V3 A1 1 0 0 1 9 2 z"}),t("path",{d:"M8 4H6a2 2 0 00-2 2v14a2 2 0 002 2h12a2 2 0 002-2v-2M16 4h2a2 2 0 012 2v4M21 14H11"}),t("path",{d:"M15 10l-4 4 4 4"})]}),Q=({size:n,style:r,className:o})=>e("svg",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",width:n,height:n,className:o,style:r,children:[t("path",{d:"M22 11.08V12a10 10 0 11-5.93-9.14"}),t("path",{d:"M22 4L12 14.01l-3-3"})]}),q=({size:e,style:n,className:r})=>t("svg",{baseProfile:"tiny",viewBox:"0 0 24 24",fill:"currentColor",width:e,height:e,className:r,style:n,children:t("path",{d:"M12 4c-4.411 0-8 3.589-8 8s3.589 8 8 8 8-3.589 8-8-3.589-8-8-8zm-5 8c0-.832.224-1.604.584-2.295l6.711 6.711A4.943 4.943 0 0112 17c-2.757 0-5-2.243-5-5zm9.416 2.295L9.705 7.584A4.943 4.943 0 0112 7c2.757 0 5 2.243 5 5 0 .832-.224 1.604-.584 2.295z"})}),ee=({size:e,style:n,className:r})=>t("svg",{viewBox:"0 0 512 512",fill:"currentColor",width:e,height:e,className:r,style:n,children:t("path",{d:"M233.4 406.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L256 338.7 86.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z"})}),te=({name:e,nodeData:r,rotate:o})=>{var i,a,l,s,c,d,u;const{getStyles:p,icons:g}=R(),h={size:"1.4em",className:"jer-icon"};switch(e){case"add":return null!==(i=null==g?void 0:g.add)&&void 0!==i?i:t($,Object.assign({},h,{style:p("iconAdd",r)}));case"edit":return null!==(a=null==g?void 0:g.edit)&&void 0!==a?a:t(J,Object.assign({},h,{style:p("iconEdit",r)}));case"delete":return null!==(l=null==g?void 0:g.delete)&&void 0!==l?l:t(Z,Object.assign({},h,{style:p("iconDelete",r),size:"1.45em"}));case"copy":return null!==(s=null==g?void 0:g.copy)&&void 0!==s?s:t(X,Object.assign({},h,{style:p("iconCopy",r),size:"1.2em"}));case"ok":return null!==(c=null==g?void 0:g.ok)&&void 0!==c?c:t(Q,Object.assign({},h,{style:Object.assign({fontSize:"90%"},p("iconOk",r))}));case"cancel":return null!==(d=null==g?void 0:g.cancel)&&void 0!==d?d:t(q,Object.assign({},h,{style:Object.assign({fontSize:"130%"},p("iconCancel",r))}));case"chevron":return null!==(u=null==g?void 0:g.chevron)&&void 0!==u?u:t(ee,{size:"1em",style:p("iconCollection",r)});default:return t(n,{})}},ne=({startEdit:r,handleDelete:o,handleAdd:a,enableClipboard:l,type:s,customButtons:c,nodeData:d,translate:u,keyboardControls:p,handleKeyboard:g,editConfirmRef:h})=>{const{getStyles:m}=R(),y=u("KEY_NEW",d),[f,b]=i(!1),[v,j]=i(y),{key:D,path:w,value:C}=d;return e("div",{className:"jer-edit-buttons",style:{opacity:f?1:void 0},children:[l&&t("div",{onClick:e=>{var t;e.stopPropagation();let n,r,o="value",i="",a=null;if(l){const c=E(e);if(c&&p.clipboardModifier.includes(c)?(n=oe(w),i=n,o="path"):(n=C,i=s?JSON.stringify(C,null,2):String(n)),!navigator.clipboard)return void("function"==typeof l&&l({success:!1,value:n,stringValue:i,path:w,key:D,type:o,errorMessage:"Can't access clipboard API"}));null===(t=navigator.clipboard)||void 0===t||t.writeText(i).then((()=>r=!0)).catch((e=>{r=!1,a=e.message})).finally((()=>{"function"==typeof l&&l({success:r,errorMessage:a,value:n,stringValue:i,path:w,key:D,type:o})}))}},className:"jer-copy-pulse",children:t(te,{name:"copy",nodeData:d})}),r&&t("div",{onClick:e=>{e.stopPropagation(),r()},children:t(te,{name:"edit",nodeData:d})}),o&&t("div",{onClick:e=>{e.stopPropagation(),o()},children:t(te,{name:"delete",nodeData:d})}),a&&t("div",{onClick:e=>{e.stopPropagation(),"object"===s?b(!0):a("")},children:t(te,{name:"add",nodeData:d})}),null==c?void 0:c.map((({Element:e,onClick:n},r)=>t("div",{onClick:e=>n&&n(d,e),children:t(e,{nodeData:d})},r))),f&&a&&"object"===s&&e(n,{children:[t("input",{className:"jer-input-new-key",type:"text",name:"new-object-key",value:v,onChange:e=>j(e.target.value),onClick:e=>e.stopPropagation(),autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>{g(e,{stringConfirm:()=>{a&&(b(!1),a(v),j(y))},cancel:()=>{b(!1),j(y)}})},style:m("input",d)}),t(re,{onOk:e=>{v&&(e.stopPropagation(),b(!1),a(v))},onCancel:e=>{e.stopPropagation(),b(!1)},nodeData:d,editConfirmRef:h})]})]})},re=({onOk:n,onCancel:r,nodeData:o,editConfirmRef:i})=>e("div",{className:"jer-confirm-buttons",children:[t("div",{onClick:n,ref:i,children:t(te,{name:"ok",nodeData:o})}),t("div",{onClick:r,children:t(te,{name:"cancel",nodeData:o})})]}),oe=e=>e.reduce(((e,t)=>"number"==typeof t?`${e}[${t}]`:""===e?t:`${e}.${t}`),""),ie=["string","number","boolean","null","object","array"],ae=(e=[],t)=>{const n=e.filter((({condition:e})=>e(t)));if(0===n.length)return{};const r=n[0],{element:o,wrapperElement:i,customNodeProps:a,wrapperProps:l,hideKey:s=!1,showEditTools:c=!0,showOnEdit:d=!1,showOnView:u=!0,showCollectionWrapper:g=!0}=r,h=p(r,["element","wrapperElement","customNodeProps","wrapperProps","hideKey","showEditTools","showOnEdit","showOnView","showCollectionWrapper"]);return Object.assign({CustomNode:o,CustomWrapper:i,customNodeProps:a,wrapperProps:l,hideKey:s,showEditTools:c,showOnEdit:d,showOnView:u,showCollectionWrapper:g},h)},le=({props:e,collapsed:t})=>{const{data:n,nodeData:r,parentData:o,onEdit:a,onError:l,showErrorMessages:c,restrictEditFilter:d,restrictDeleteFilter:u,restrictAddFilter:p,restrictDragFilter:g,translate:h,errorMessageTimeout:m}=e,{currentlyEditingElement:y,setCurrentlyEditingElement:f}=_(),[b,v]=i(null),E=Object.assign(Object.assign({},r),{collapsed:t}),{path:D,key:w,size:C}=E,k=j(D),O=s((()=>!d(E)),[E]),S=s((()=>!u(E)),[E]),N=s((()=>!p(E)),[E]),x=s((()=>!g(E)&&S&&null===y),[E]),A=e=>{c&&(v(e),setTimeout((()=>v(null)),m)),console.warn("Error",e)},T=s((()=>(e,t)=>{A(e.message),l&&l({currentData:E.fullData,errorValue:t,currentValue:n,name:w,path:D,error:e})}),[l,c]),R=y===k,P=y===`key_${k}`,V="number"==typeof D.slice(-1)[0];return{pathString:k,nodeData:E,path:D,name:w,size:C,canEdit:O,canDelete:S,canAdd:N,canDrag:x,error:b,showError:A,onError:T,setError:v,handleEditKey:e=>{if(f(null),w===e)return;if(!o)return;const t=D.slice(0,-1);if(Object.keys(o).includes(e))return void T({code:"KEY_EXISTS",message:h("ERROR_KEY_EXISTS",E)},e);const n=Object.fromEntries(Object.entries(o).map((([t,n])=>t===w?[e,n]:[t,n])));a(n,t).then((t=>{t&&T({code:"UPDATE_ERROR",message:t},e)}))},derivedValues:{isEditing:R,isEditingKey:P,isArray:V,canEditKey:null!==o&&O&&N&&S&&!V}}},se=({canDrag:e,canDragOnto:n,path:r,nodeData:o,onMove:a,onError:l,translate:c})=>{const{getStyles:d}=R(),{dragSource:u,setDragSource:p}=_(),[g,h]=i(!1),m=j(r),y=s((()=>e?{onDragStart:e=>{e.stopPropagation(),p({path:r,pathString:m})},onDragEnd:e=>{e.stopPropagation(),p({path:null,pathString:null})}}:{}),[e]),f=s((()=>e=>n?{onDragOver:e=>{e.stopPropagation(),e.preventDefault()},onDrop:t=>{t.stopPropagation(),v(e),p({path:null,pathString:null}),h(!1)},onDragEnter:t=>{var n;t.stopPropagation(),m.startsWith(null!==(n=u.pathString)&&void 0!==n?n:"")||h(e)},onDragExit:e=>{e.stopPropagation(),h(!1)}}:{}),[u,n]),b=s((()=>n&&null!==u.pathString?t("div",Object.assign({className:"jer-drop-target-bottom",style:{height:"50%",position:"absolute",width:"100%",top:"50%",zIndex:r.length}},f("below"))):null),[u,n]),v=e=>{var t,n;const i=null===(t=u.path)||void 0===t?void 0:t.slice(-1)[0],s=null===(n=u.path)||void 0===n?void 0:n.slice(0,-1).join("."),d=r.slice(0,-1).join(""),{parentData:p}=o;"string"==typeof i&&p&&!Array.isArray(p)&&Object.keys(p).includes(i)&&i in p&&s!==d?l({code:"KEY_EXISTS",message:c("ERROR_KEY_EXISTS",o)},i):a(u.path,r,e).then((e=>{e&&l({code:"UPDATE_ERROR",message:e},o.value)}))};return{dragSourceProps:y,getDropTargetProps:f,BottomDropTarget:b,DropTargetPadding:({position:e,nodeData:n})=>g===e?t("div",{className:"jer-drag-n-drop-padding",style:d("dropZone",n)}):null,handleDrop:v}},ce=(e,t,n)=>{var r,o,i;const a=parseInt(null!==(r=getComputedStyle(n.current).getPropertyValue("line-height"))&&void 0!==r?r:"16px"),l=(null!==(i=null===(o=t.current)||void 0===o?void 0:o.offsetWidth)&&void 0!==i?i:0)/(.5*a),s=JSON.stringify(e,null,2).replace(/\\n/g,"\n").split("\n").map((e=>Math.ceil(e.length/l))).reduce(((e,t)=>e+t),0)*a;return Math.min(s+30,window.innerHeight-50)},de=({isEditingKey:n,canEditKey:r,pathString:o,path:i,name:a,handleKeyboard:l,handleEditKey:s,handleCancel:c,handleClick:d,keyValueArray:u,styles:p,getNextOrPrevious:g})=>{const{setCurrentlyEditingElement:h}=_();return n?t("input",{className:"jer-input-text jer-key-edit",type:"text",name:o,defaultValue:a,autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>l(e,{stringConfirm:()=>s(e.target.value),cancel:c,tabForward:()=>{if(s(e.target.value),u){const e=null==u?void 0:u[0][0];h(e?[...i,e]:g("next"))}else h(i)},tabBack:()=>{s(e.target.value),h(g("prev"))}}),style:{width:String(a).length/1.5+.5+"em"}}):e("span",{className:"jer-key-text",style:Object.assign(Object.assign({},p),{minWidth:`${Math.min(String(a).length+1,5)}ch`,flexShrink:a.length>10?1:0}),onDoubleClick:()=>r&&h(i,"key"),onClick:d,children:[""===a?t("span",{className:i.length>0?"jer-empty-string":void 0}):`${a}`,t("span",{className:"jer-key-colon",children:":"})]})},ue=n=>{const{data:r,parentData:o,onEdit:a,onDelete:d,onChange:u,onMove:p,enableClipboard:g,canDragOnto:h,restrictTypeSelection:m,searchFilter:f,searchText:b,showLabel:v,stringTruncate:j,showStringQuotes:E,indent:D,translate:w,customNodeDefinitions:C,handleKeyboard:O,keyboardControls:S,sort:N,editConfirmRef:x}=n,{getStyles:A}=R(),{setCurrentlyEditingElement:T,setCollapseState:P,previouslyEditedElement:V,setPreviouslyEditedElement:K,tabDirection:z,setTabDirection:M,previousValue:F,setPreviousValue:L}=_(),[B,W]=i("function"==typeof r?I:r),{pathString:G,nodeData:H,path:U,name:Y,canEdit:$,canDelete:J,canDrag:Z,error:X,onError:Q,handleEditKey:q,derivedValues:ee}=le({props:n}),{dragSourceProps:te,getDropTargetProps:oe,BottomDropTarget:ce,DropTargetPadding:ue}=se({canDrag:Z,canDragOnto:h,path:U,nodeData:H,onMove:p,onError:Q,translate:w}),me=ae(C,H),[ye,fe]=i(pe(r,me)),be=c((e=>{if(!u)return void W(e);const t=u({currentData:H.fullData,newValue:e,currentValue:B,name:Y,path:U});W(t)}),[u]);l((()=>{W("function"==typeof r?I:r),fe(pe(r,me))}),[r,X]);const{CustomNode:ve,customNodeProps:je,hideKey:Ee,showEditTools:De=!0,showOnEdit:we,showOnView:Ce,passOriginalNode:ke}=me,Oe=[...ie,...C.filter((({showInTypesSelector:e=!1,name:t})=>e&&!!t)).map((({name:e})=>e))],Se=s((()=>{if("boolean"==typeof m)return m?[]:Oe;if(Array.isArray(m))return m;const e=m(H);return"boolean"==typeof e?e?[]:Oe:e}),[H,m]),{isEditing:Ne}=ee,xe=y("value",H,f,b);if(Ne&&(!xe||!$)){const e=k(H.fullData,U,z,N);T(e||V)}if(!xe)return null;const Ae=()=>{let e;switch(T(null),L(null),ye){case"object":e={[w("DEFAULT_NEW_KEY",H)]:B};break;case"array":e=null!=B?B:[];break;case"number":{const t=Number(B);e=isNaN(t)?0:t;break}default:e=B}a(e,U).then((t=>{t&&Q({code:"UPDATE_ERROR",message:t},e)}))},Te=()=>{T(null),null===F?(W(r),L(null)):a(F,U)},{isEditingKey:Re,canEditKey:Pe}=ee,Ve=!Ne&&X,Ke=Ne&&Se.length>0,ze="invalid"!==ye&&!X&&De,Me=v&&!Ee,Fe=ve&&(Ne&&we||!Ne&&Ce),_e={value:B,parentData:o,setValue:be,isEditing:Ne,canEdit:$,setIsEditing:$?()=>T(U):()=>{},handleEdit:Ae,handleCancel:Te,path:U,stringTruncate:j,showStringQuotes:E,nodeData:H,translate:w,handleKeyboard:O,keyboardCommon:{cancel:Te,tabForward:()=>{M("next"),K(G);const e=k(H.fullData,U,"next",N);e&&(Ae(),T(e))},tabBack:()=>{M("prev"),K(G);const e=k(H.fullData,U,"prev",N);e&&(Ae(),T(e))}}},Le={canEditKey:Pe,isEditingKey:Re,pathString:G,path:U,name:Y,handleKeyboard:O,handleEditKey:q,handleCancel:Te,styles:A("property",H),getNextOrPrevious:e=>k(H.fullData,U,e,N)},Ie=Fe?t(ve,Object.assign({},n,{value:B,customNodeProps:je,setValue:be,handleEdit:Ae,handleCancel:Te,handleKeyPress:e=>O(e,{stringConfirm:Ae,cancel:Te}),isEditing:Ne,setIsEditing:()=>T(U),getStyles:A,originalNode:ke?ge(r,_e):void 0,originalNodeKey:ke?t(de,Object.assign({},Le)):void 0})):ge(r,_e);return e("div",Object.assign({className:"jer-component jer-value-component",style:{marginLeft:D/2+"em",position:"relative"},draggable:Z},te,oe("above"),{children:[ce,t(ue,{position:"above",nodeData:H}),e("div",{className:"jer-value-main-row",style:{flexWrap:Y.length>10?"wrap":"nowrap"},children:[Me&&t(de,Object.assign({},Le)),e("div",{className:"jer-value-and-buttons",children:[t("div",{className:"jer-input-component",children:Ie}),Ne?t(re,{onOk:Ae,onCancel:Te,nodeData:H,editConfirmRef:x}):ze&&t(ne,{startEdit:$?()=>{L(B),T(U,Te)}:void 0,handleDelete:J?()=>{d(B,U).then((e=>{e&&Q({code:"DELETE_ERROR",message:e},B)}))}:void 0,enableClipboard:g,translate:w,customButtons:n.customButtons,nodeData:H,handleKeyboard:O,keyboardControls:S,editConfirmRef:x}),Ke&&e("div",{className:"jer-select",children:[t("select",{name:`${Y}-type-select`,className:"jer-type-select",onChange:e=>(e=>{const t=C.find((t=>t.name===e));if(t)a(t.defaultValue,U),fe(e),T(null),P({path:U,collapsed:!1,includeChildren:!1});else{const t=he(B,e,w("DEFAULT_NEW_KEY",H),(null==me?void 0:me.CustomNode)?w("DEFAULT_STRING",H):void 0);a(t,U).then((e=>{e&&(Q({code:"UPDATE_ERROR",message:e},t),T(null))}))}})(e.target.value),value:ye,children:Se.map((e=>t("option",{value:e,children:e},e)))}),t("span",{className:"focus"})]}),Ve&&t("span",{className:"jer-error-slug",style:A("error",H),children:X})]})]}),t(ue,{position:"below",nodeData:H})]}))},pe=(e,t)=>(null==t?void 0:t.CustomNode)&&(null==t?void 0:t.name)&&t.showInTypesSelector?t.name:"string"==typeof e?"string":"number"==typeof e?"number":"boolean"==typeof e?"boolean":null===e?"null":"invalid",ge=(e,n)=>{const r=pe(e),{value:o}=n;switch(r){case"string":return t(W,Object.assign({},n,{value:o}));case"number":return t(G,Object.assign({},n,{value:o}));case"boolean":return t(H,Object.assign({},n,{value:o}));case"null":return t(U,Object.assign({},n));default:return t(Y,Object.assign({},n))}},he=(e,t,n,r)=>{switch(t){case"string":return null!=r?r:String(e);case"number":{const t=Number(e);return isNaN(t)?0:t}case"boolean":return!!e;case"null":return null;case"object":return{[n]:e};case"array":return[e];default:return String(e)}},me=r=>{const{getStyles:o}=R(),{collapseState:c,setCollapseState:d,getMatchingCollapseState:u,currentlyEditingElement:p,setCurrentlyEditingElement:f,areChildrenBeingEdited:b,previousValue:v,setPreviousValue:j}=_(),{mainContainerRef:D,data:w,nodeData:C,parentData:O,showCollectionCount:S,onEdit:x,onAdd:A,onDelete:T,canDragOnto:P,collapseFilter:V,collapseAnimationTime:K,onMove:z,enableClipboard:M,searchFilter:F,searchText:L,indent:I,sort:B,showArrayIndices:W,defaultValue:G,translate:H,customNodeDefinitions:U,jsonParse:Y,jsonStringify:$,TextEditor:J,keyboardControls:Z,handleKeyboard:X,insertAtTop:Q,onCollapse:q,editConfirmRef:ee,collapseClickZones:oe}=r,[ie,pe]=i($(w)),ge=V(C),{contentRef:he,isAnimating:ye,maxHeight:fe,collapsed:be,animateCollapse:ve,cssTransitionValue:je}=((e,t,n,r)=>{const[o,l]=i(n?0:void 0),[s,c]=i(n),d=a(!1),u=a(null),p=a(0),g=a(),h=t/1e3+"s";return{contentRef:u,isAnimating:d.current,animateCollapse:n=>{var o,i;if(s!==n){switch(window.clearTimeout(g.current),d.current=!0,n){case!0:{const e=null!==(i=null===(o=u.current)||void 0===o?void 0:o.offsetHeight)&&void 0!==i?i:0;p.current=e,l(e),setTimeout((()=>{l(0)}),5);break}case!1:l(p.current||ce(e,u,r))}c(!s),g.current=window.setTimeout((()=>{d.current=!1,n||l(void 0)}),t)}},maxHeight:o,collapsed:s,cssTransitionValue:h}})(w,K,ge,D),{pathString:Ee,nodeData:De,path:we,name:Ce,size:ke,canEdit:Oe,canDelete:Se,canAdd:Ne,canDrag:xe,error:Ae,setError:Te,onError:Re,handleEditKey:Pe,derivedValues:Ve}=le({props:r,collapsed:be}),{dragSourceProps:Ke,getDropTargetProps:ze,BottomDropTarget:Me,DropTargetPadding:Fe}=se({canDrag:xe,canDragOnto:P,path:we,nodeData:De,onMove:z,onError:Re,translate:H}),_e=a(!ge),{isEditing:Le,isEditingKey:Ie,isArray:Be,canEditKey:We}=Ve;l((()=>{pe($(w))}),[w]),l((()=>{const e=V(De)&&!Le;_e.current=!e,ve(e)}),[V]),l((()=>{if(null!==c){const e=u(we);e&&(_e.current=!0,ve(e.collapsed))}}),[c]);const Ge=a(null),He=s((()=>(e,t)=>"function"!=typeof G?G:G(e,t)),[G]),{CustomNode:Ue,customNodeProps:Ye,CustomWrapper:$e,wrapperProps:Je={},hideKey:Ze,showEditTools:Xe=!0,showOnEdit:Qe,showOnView:qe,showCollectionWrapper:et=!0}=s((()=>ae(U,De)),[w]),tt=b(Ee);tt&&be&&ve(!1);if(!(y("collection",De,F,L)||0===De.level)&&!tt)return null;const nt=Array.isArray(w)?"array":"object",rt="array"===nt?{open:"[",close:"]"}:{open:"{",close:"}"},ot=e=>{if("Tab"!==e.key||e.getModifierState("Shift"))X(e,{objectConfirm:at,cancel:st});else{e.preventDefault();const t=N(Ge,"\t");pe(t)}},it=e=>{e.stopPropagation();const t=E(e);if(t&&Z.collapseModifier.includes(t))return _e.current=!0,void d({collapsed:!be,path:we,includeChildren:!0});p&&p.includes(Ee)||(_e.current=!0,d(null),q&&q({path:we,collapsed:!be,includeChildren:!1}),ve(!be))},at=()=>{try{const e=Y(ie);if(f(null),j(null),Te(null),JSON.stringify(e)===JSON.stringify(w))return;x(e,we).then((t=>{t&&Re({code:"UPDATE_ERROR",message:t},e)}))}catch(e){Re({code:"INVALID_JSON",message:H("ERROR_INVALID_JSON",De)},ie)}},lt=we.length>0?()=>{T(w,we).then((e=>{e&&Re({code:"DELETE_ERROR",message:e},w)}))}:void 0,st=()=>{f(null),null===v?(Te(null),pe($(w)),j(null)):x(v,we)},ct="when-closed"===S?be:S,dt=!Le&&Xe,ut=(W||!Be)&&!Ze&&void 0!==Ce,pt=Ue&&(Le&&Qe||!Le&&qe),gt=Object.entries(w).map((([e,t])=>["array"===nt?Number(e):e,t]));"object"===nt&&B(gt,(e=>e));const ht=_e.current?Le?e("div",{className:"jer-collection-text-edit",children:[J?t(J,{value:ie,onChange:pe,onKeyDown:e=>X(e,{objectConfirm:at,cancel:st})}):t(h,{textAreaRef:Ge,className:"jer-collection-text-area",name:Ee,value:ie,setValue:pe,isEditing:Le,handleKeyPress:ot,styles:o("input",De)}),t("div",{className:"jer-collection-input-button-row",children:t(re,{onOk:at,onCancel:st,nodeData:De,editConfirmRef:ee})})]}):gt.map((([e,n],i)=>{const a={key:e,value:n,path:[...we,e],level:we.length+1,index:i,size:m(n)?Object.keys(n).length:1,parentData:w,fullData:De.fullData};return t("div",{className:"jer-collection-element",style:o("collectionElement",a),children:m(n)?t(me,Object.assign({},r,{data:n,parentData:w,nodeData:a,showCollectionCount:S,canDragOnto:Oe}),e):t(ue,Object.assign({},r,{data:n,parentData:w,nodeData:a,canDragOnto:Oe,showLabel:"object"===nt||W}),e)},e)})):null,mt=!!et&&(be&&!tt);mt||(_e.current=!0);const yt=Object.assign(Object.assign({},r),{data:w,value:w,parentData:O,nodeData:De,setValue:e=>g(void 0,void 0,void 0,(function*(){return yield x(e,we)})),handleEdit:at,handleCancel:st,handleKeyPress:ot,isEditing:Le,setIsEditing:()=>f(we),getStyles:o,canDragOnto:Oe}),ft=pt?t(Ue,Object.assign({customNodeProps:Ye},yt,{children:ht})):ht,bt=dt&&t(ne,{startEdit:Oe?()=>{_e.current=!0,j(null),f(we)}:void 0,handleAdd:Ne?e=>{ve(!1);const t=He(De,e);if("array"===nt){const e=Q.array?0:w.length,n=Q.array?{insert:!0}:{};A(t,[...we,e],n).then((e=>{e&&Re({code:"ADD_ERROR",message:e},t)}))}else if(e in w)Re({code:"KEY_EXISTS",message:H("ERROR_KEY_EXISTS",De)},e);else{const n=Q.object?{insertBefore:0}:{};A(t,[...we,e],n).then((e=>{e&&Re({code:"ADD_ERROR",message:e},t)}))}}:void 0,handleDelete:Se?lt:void 0,enableClipboard:M,type:nt,nodeData:De,translate:H,customButtons:r.customButtons,keyboardControls:Z,handleKeyboard:X,editConfirmRef:ee}),vt={canEditKey:We,isEditingKey:Ie,pathString:Ee,path:we,name:Ce,handleKeyboard:X,handleEditKey:Pe,handleCancel:st,keyValueArray:gt,styles:o("property",De),getNextOrPrevious:e=>k(De.fullData,we,e,B),handleClick:oe.includes("property")?it:e=>e.stopPropagation()},jt=e("div",Object.assign({className:"jer-component jer-collection-component",style:Object.assign(Object.assign({marginLeft:(0===we.length?0:I/2)+"em"},o("collection",De)),{position:"relative"}),draggable:xe},Ke,ze("above"),{children:[t("div",{className:"jer-clickzone",style:{width:I/2+1+"em",zIndex:10+2*De.level},onClick:oe.includes("left")?it:void 0}),!Le&&Me,t(Fe,{position:"above",nodeData:De}),et?e("div",{className:"jer-collection-header-row",style:{position:"relative"},onClick:oe.includes("header")?it:void 0,children:[e("div",{className:"jer-collection-name",children:[t("div",{className:"jer-collapse-icon jer-accordion-icon"+(be?" jer-rotate-90":""),style:{zIndex:11+2*De.level,transition:je},onClick:it,children:t(te,{name:"chevron",rotate:be,nodeData:De})}),ut&&t(de,Object.assign({},vt)),!Le&&t("span",{className:"jer-brackets jer-bracket-open",style:o("bracket",De),children:rt.open})]}),!Le&&ct&&t("div",{className:"jer-collection-item-count"+(ct?" jer-visible":" jer-hidden"),style:Object.assign(Object.assign({},o("itemCount",De)),{transition:je}),children:1===ke?H("ITEM_SINGLE",Object.assign(Object.assign({},De),{size:1}),1):H("ITEMS_MULTIPLE",De,ke)}),t("div",{className:"jer-brackets"+(mt?" jer-visible":" jer-hidden"),style:Object.assign(Object.assign({},o("bracket",De)),{transition:je}),children:rt.close}),bt]}):Ze?t(n,{}):e("div",{className:"jer-collection-header-row",style:{position:"relative"},children:[t(de,Object.assign({},vt)),bt]}),e("div",{className:"jer-collection-inner",style:Object.assign(Object.assign({overflowY:mt||ye?"clip":"visible",maxHeight:tt?void 0:fe},o("collectionInner",De)),{transition:je}),ref:he,children:[ft,t("div",{className:Le?"jer-collection-error-row":"jer-collection-error-row-edit",children:Ae&&t("span",{className:"jer-error-slug",style:o("error",De),children:Ae})}),!Le&&et&&t("div",{className:"jer-brackets jer-bracket-outside",style:Object.assign(Object.assign({},o("bracket",De)),{marginLeft:(I<3?-1:I<6?-.5:0)+"em"}),children:rt.close})]}),t(Fe,{position:"below",nodeData:De})]}));return $e?t($e,Object.assign({customNodeProps:Je},yt,{children:jt})):jt},ye={ITEM_SINGLE:"{{count}} item",ITEMS_MULTIPLE:"{{count}} items",KEY_NEW:"Enter new key",ERROR_KEY_EXISTS:"Key already exists",ERROR_INVALID_JSON:"Invalid JSON",ERROR_UPDATE:"Update unsuccessful",ERROR_DELETE:"Delete unsuccessful",ERROR_ADD:"Adding node unsuccessful",DEFAULT_STRING:"New data!",DEFAULT_NEW_KEY:"key",SHOW_LESS:"(Show less)"},fe=(e,t)=>(n,r,o)=>((e,t,n,r,o)=>{if(t[r]){const e=t[r](n);if(null!==e)return e}const i=r in e?e[r]:ye[r];return void 0===o?i:null==i?void 0:i.replace("{{count}}",String(o))})(e,t,r,n,o);var be=[],ve=[];!function(e,t){if(e&&"undefined"!=typeof document){var n,r=!0===t.prepend?"prepend":"append",o=!0===t.singleTag,i="string"==typeof t.container?document.querySelector(t.container):document.getElementsByTagName("head")[0];if(o){var a=be.indexOf(i);-1===a&&(a=be.push(i)-1,ve[a]={}),n=ve[a]&&ve[a][r]?ve[a][r]:ve[a][r]=l()}else n=l();65279===e.charCodeAt(0)&&(e=e.substring(1)),n.styleSheet?n.styleSheet.cssText+=e:n.appendChild(document.createTextNode(e))}function l(){var e=document.createElement("style");if(e.setAttribute("type","text/css"),t.attributes)for(var n=Object.keys(t.attributes),o=0;o<n.length;o++)e.setAttribute(n[o],t.attributes[n[o]]);var a="prepend"===r?"afterbegin":"beforeend";return i.insertAdjacentElement(a,e),e}}(':root{--jer-select-border:#b6b6b6;--jer-select-focus:#777;--jer-select-arrow:#777;--jer-form-border:1px solid #ededf0;--jer-form-border-focus:1px solid #e2e2e2;--jer-highlight-color:#b3d8ff}.jer-visible{opacity:1}.jer-hidden{opacity:0}.jer-select select{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:transparent;border:none;color:#000;cursor:inherit;font-family:inherit;font-size:.8em;line-height:inherit;margin:0;outline:none;padding:0 1em 0 0;z-index:1}select::-ms-expand{display:none}.jer-select{align-items:center;background-color:#fff;background-image:linear-gradient(0deg,#f9f9f9,#fff 33%);border:1px solid var(--jer-select-border);border-radius:.25em;cursor:pointer;display:grid;grid-template-areas:"select";line-height:1.1;max-width:15ch;min-width:12ch;padding:.25em .5em;position:relative}.jer-select select,.jer-select:after{grid-area:select}.jer-select:not(.jer-select--multiple):after{background-color:var(--jer-select-arrow);clip-path:polygon(100% 0,0 0,50% 100%);content:"";height:.5em;justify-self:end;width:.8em}select:focus+.focus{border:1px solid var(--jer-select-focus);border-radius:inherit;bottom:-1px;left:-1px;position:absolute;right:-1px;top:-1px}.jer-editor-container{border-radius:.5em;font-size:16px;line-height:1;padding:1em 1em 1em 2em;position:relative;text-align:left}.jer-editor-container textarea{border:var(--jer-form-border);border-radius:.3em;color:var(--jer-input-color);outline:none}.jer-editor-container textarea:focus{border:var(--jer-form-border-focus)}.jer-editor-container input{border:var(--jer-form-border);border-radius:.3em;font-family:inherit;outline:none}.jer-editor-container input:focus{border:var(--jer-form-border-focus)}.jer-editor-container ::selection{background-color:var(--jer-highlight-color)}.jer-collection-header-row,.jer-value-main-row{align-items:center;display:flex;gap:.3em;min-height:1.7em}.jer-collection-header-row{display:flex;flex-wrap:wrap}.jer-collapse-icon{left:-1.2em;position:absolute;top:.35em}.jer-collection-inner{position:relative}.jer-collection-text-edit{align-items:flex-start;display:flex;flex-direction:column;gap:.3em;line-height:1.1em}.jer-collection-text-area{font-family:inherit;font-size:.85em;max-height:40em;overflow:hidden;padding:.2em .5em 0;resize:both}.jer-collection-input-button-row{display:flex;font-size:150%;justify-content:flex-end;margin-top:.4em;width:100%}.jer-collection-error-row{bottom:.5em;position:absolute}.jer-error-slug{margin-left:1em}.jer-value-component{position:relative}.jer-value-main-row{display:flex;gap:0}.jer-value-and-buttons{align-items:center;display:flex;justify-content:flex-start;padding-left:.5em}.jer-value-error-row{position:absolute}.jer-value-string{line-height:1.3em;overflow-wrap:anywhere;white-space:pre-wrap;word-break:break-word}.jer-string-expansion{cursor:pointer;filter:saturate(50%);opacity:.6}.jer-show-less{font-size:80%}.jer-hyperlink{text-decoration:underline}.jer-input-text{font-family:inherit;font-size:.9em;height:1.4em;line-height:1.2em;margin:0;min-width:6em;overflow:hidden;padding:.25em .5em .2em;resize:none}.jer-input-boolean{margin-left:.3em;margin-right:.3em;transform:scale(1.5)}.jer-key-text{line-height:1.1em;white-space:pre-wrap;word-break:break-word}.jer-key-edit{font-size:inherit;font-size:.9em;padding:0 .3em}.jer-value-invalid{font-style:italic;opacity:.5}.jer-input-number{font-size:90%;min-width:3em}.jer-confirm-buttons,.jer-edit-buttons{align-items:center;cursor:pointer;display:flex;height:1em}.jer-input-buttons{gap:.4em}.jer-edit-buttons{gap:.4em;margin-left:.5em;opacity:0}.jer-confirm-buttons{gap:.2em;margin-left:.4em}.jer-edit-buttons:hover{opacity:1;position:relative}.jer-collection-header-row:hover>.jer-edit-buttons,.jer-value-and-buttons:hover>.jer-edit-buttons,.jer-value-main-row:hover>.jer-edit-buttons{opacity:1}.jer-copy-pulse{position:relative;transition:.3s}.jer-copy-pulse:hover{opacity:.85;transform:scale(1.2);transition:.3s}.jer-copy-pulse:after{border-radius:50%;box-shadow:0 0 15px 5px var(--jer-icon-copy-color);content:"";display:block;height:100%;left:0;opacity:0;position:absolute;top:0;transition:all .5s;width:100%}.jer-copy-pulse:active:after{border-radius:4em;box-shadow:0 0 0 0 var(--jer-icon-copy-color);left:0;opacity:1;position:absolute;top:0;transition:0s}.jer-copy-pulse:active{top:.07em}.jer-rotate-90{transform:rotate(-90deg)}.jer-icon:hover{opacity:.85;transform:scale(1.2);transition:.3s}.jer-empty-string:after{content:"<empty string>";font-size:90%;font-style:italic}.jer-drag-n-drop-padding{border:1px dashed #e0e0e0;border-radius:.3em;height:.5em}.jer-clickzone{height:calc(100% - .8em);left:-1em;position:absolute;top:1.2em}',{});const je=({data:e,setData:n,rootName:r="root",onUpdate:o=(()=>{}),onEdit:d=o,onDelete:u=o,onAdd:p=o,onChange:h,onError:y,showErrorMessages:f=!0,enableClipboard:b=!0,indent:v=2,collapse:E=!1,collapseAnimationTime:w=300,showCollectionCount:k=!0,restrictEdit:O=!1,restrictDelete:S=!1,restrictAdd:N=!1,restrictTypeSelection:x=!1,restrictDrag:A=!0,viewOnly:T,searchFilter:P,searchText:V,searchDebounceTime:K=350,keySort:z=!1,showArrayIndices:M=!0,showStringQuotes:F=!0,defaultValue:L=null,minWidth:I=250,maxWidth:B="min(600px, 90vw)",rootFontSize:W,stringTruncate:G=250,translations:H={},className:U,id:Y,customText:$={},customNodeDefinitions:J=[],customButtons:Z=[],jsonParse:X=JSON.parse,jsonStringify:Q=(e=>JSON.stringify(e,null,2)),TextEditor:q,errorMessageTimeout:ee=2500,keyboardControls:te={},externalTriggers:ne,insertAtTop:re=!1,onCollapse:oe,collapseClickZones:ie=["header","left"]})=>{const{getStyles:ae}=R(),{setCurrentlyEditingElement:le}=_(),se=c(we(E),[E]),ce=c(fe(H,$),[H,$]),[de,pe]=i(V),[ge,he]=(({setData:e,data:t})=>{const[n,r]=i(e?void 0:t),o=c((t=>{e?e(t):r(t)}),[e]);return l((()=>{e||r(t)}),[t]),[e?t:n,o]})({setData:n,data:e}),ye=a(null);l((()=>{le(null);const e=setTimeout((()=>pe(V)),K);return()=>clearTimeout(e)}),[V,K]);const be={key:r,path:[],level:0,index:0,value:ge,size:"object"==typeof ge&&null!==ge?Object.keys(ge).length:1,parentData:null,fullData:ge},ve=(e,t)=>g(void 0,void 0,void 0,(function*(){const n=yield e(t);if(!0===n||void 0===n)return void he(t.newData);const r=ke(n)?n:["error",n],[o,i]=r;if("error"===o)return he(t.currentData),!1===i?ce("ERROR_UPDATE",be):String(i);he(i)})),je=s((()=>we(O,T)),[O,T]),Ee=s((()=>we(S,T)),[S,T]),Oe=s((()=>we(N,T)),[N,T]),Se=s((()=>we(A,T)),[A,T]),Ne=s((()=>Ce(P)),[P]),xe=s((()=>(e=>{const t=Object.assign({},C);for(const n of Object.keys(C)){const r=n;if(e[r]){const o=e[r],i=["clipboardModifier","collapseModifier"].includes(n)?Array.isArray(o)?o:[o]:"string"==typeof o?{key:o}:o;t[r]=i,["stringConfirm","numberConfirm","booleanConfirm"].forEach((n=>{!e[n]&&e.confirm&&(t[n]=t.confirm)}))}}return t})(te)),[te]),Ae=c(((e,t)=>((e,t,n)=>{const r=Object.entries(t);for(const[t,o]of r)if(D(n,e[t],t)){n.preventDefault(),o();break}})(xe,t,e)),[te]),Te=a(null);((e,t)=>{const{setCurrentlyEditingElement:n,currentlyEditingElement:r,setCollapseState:o}=_();l((()=>{if(!e)return;const{collapse:i,edit:a}=e;i&&o(i);const l=!(null==a?void 0:a.path)||j(a.path)===r;switch(null==a?void 0:a.action){case"accept":l&&(t.current&&t.current.click(),n(null));break;case"cancel":l&&n(null);break;default:(null==a?void 0:a.path)&&n(a.path)}}),[e])})(ne,Te);const Re=c(((e,t)=>{!1!==z&&("function"!=typeof z?e.sort(((e,n)=>{const r=t(e)[0],o=t(n)[0];return r<o?-1:r>o?1:0})):e.sort(((e,n)=>z(t(e),t(n)))))}),[z]),Pe={mainContainerRef:ye,name:r,nodeData:be,onEdit:(e,t)=>g(void 0,void 0,void 0,(function*(){const{currentData:n,newData:r,currentValue:o,newValue:i}=De(ge,t,e,"update");if(o!==i)return yield ve(d,{currentData:n,newData:r,currentValue:o,newValue:i,name:t.slice(-1)[0],path:t})})),onDelete:(e,t)=>g(void 0,void 0,void 0,(function*(){const{currentData:n,newData:r,currentValue:o,newValue:i}=De(ge,t,e,"delete");return yield ve(u,{currentData:n,newData:r,currentValue:o,newValue:i,name:t.slice(-1)[0],path:t})})),onAdd:(e,t,n)=>g(void 0,void 0,void 0,(function*(){const{currentData:r,newData:o,currentValue:i,newValue:a}=De(ge,t,e,"add",n);return yield ve(p,{currentData:r,newData:o,currentValue:i,newValue:a,name:t.slice(-1)[0],path:t})})),onChange:h,onError:y,showErrorMessages:f,onMove:(e,t,n)=>g(void 0,void 0,void 0,(function*(){if(null===e)return;const{currentData:r,newData:o,currentValue:i}=De(ge,e,"","delete"),a=e.slice(-1)[0],l=t.slice(0,-1),s=t.slice(-1)[0];let c="number"==typeof s?"above"===n?s:s+1:"number"==typeof a?`arr_${a}`:a;e.slice(0,-1).join(".")===t.slice(0,-1).join(".")&&"number"==typeof a&&"number"==typeof c&&a<c&&(c-=1);const u="number"==typeof c?{insert:!0}:"above"===n?{insertBefore:s}:{insertAfter:s},{newData:p,newValue:g}=De(o,[...l,c],i,"add",u);return yield ve(d,{currentData:r,newData:p,currentValue:i,newValue:g,name:t.slice(-1)[0],path:t})})),showCollectionCount:k,collapseFilter:se,collapseAnimationTime:w,restrictEditFilter:je,restrictDeleteFilter:Ee,restrictAddFilter:Oe,restrictTypeSelection:x,restrictDragFilter:Se,canDragOnto:!1,searchFilter:Ne,searchText:de,enableClipboard:b,keySort:z,sort:Re,showArrayIndices:M,showStringQuotes:F,indent:v,defaultValue:L,stringTruncate:G,translate:ce,customNodeDefinitions:J,customButtons:Z,parentData:null,jsonParse:X,jsonStringify:Q,TextEditor:q,errorMessageTimeout:ee,handleKeyboard:Ae,keyboardControls:xe,insertAtTop:{object:!0===re||"object"===re,array:!0===re||"array"===re},onCollapse:oe,editConfirmRef:Te,collapseClickZones:ie},Ve=Object.assign(Object.assign({},ae("container",be)),{minWidth:I,maxWidth:B});return Ve.fontSize=null!=W?W:Ve.fontSize,t("div",{id:Y,ref:ye,className:`jer-editor-container ${null!=U?U:""}`,style:Ve,children:m(ge)?t(me,Object.assign({data:ge},Pe)):t(ue,Object.assign({data:ge,showLabel:!0},Pe))})},Ee=e=>{var n;const[r,o]=i();return l((()=>{const e=document.documentElement;o(e)}),[]),r?t(T,{theme:null!==(n=e.theme)&&void 0!==n?n:x,icons:e.icons,docRoot:r,children:t(F,{onEditEvent:e.onEditEvent,onCollapse:e.onCollapse,children:t(je,Object.assign({},e))})}):null},De=(e,t,n,r,o={})=>{if(0===t.length)return{currentData:e,newData:n,currentValue:e,newValue:n};const i=Object.assign({remove:"delete"===r},o),a="add"!==r?u(e,t):void 0;return{currentData:e,newData:d(e,t,n,i),currentValue:a,newValue:"delete"!==r?n:void 0}},we=(e,t)=>t?()=>!0:"boolean"==typeof e?()=>e:"number"==typeof e?({level:t})=>t>=e:e,Ce=e=>{if(void 0!==e)return"value"===e?b:"key"===e?v:"all"===e?(e,t)=>b(e,t)||v(e,t):e},ke=e=>Array.isArray(e)&&2===e.length&&["error","value"].includes(e[0]),Oe=e=>{var n;const{value:r,setIsEditing:o,getStyles:i,nodeData:a}=e,l=i("string",a),{canEdit:s}=le({props:e});return t("div",{onDoubleClick:()=>o(!0),onClick:e=>{(e.getModifierState("Control")||e.getModifierState("Meta"))&&o(!0)},className:"jer-value-string jer-hyperlink",style:l,children:t("a",{href:r,target:"_blank",rel:"noreferrer",style:{color:null!==(n=l.color)&&void 0!==n?n:void 0},children:t(B,Object.assign({},e,{nodeData:a,pathString:j(a.path),styles:l,canEdit:s}))})})},Se={condition:({value:e})=>"string"==typeof e&&/^https?:\/\/.+\..+$/.test(e),element:Oe,showOnView:!0,showOnEdit:!1},Ne={displayName:"Github Dark",styles:{container:{backgroundColor:"#0d1117",color:"white"},dropZone:"rgba(165, 214, 255, 0.17)",property:"#E6EDF3",bracket:"#56d364",itemCount:"#8B949E",string:"#A5D6FF",number:"#D2A8FF",boolean:{color:"#FF7B72",fontSize:"90%",fontWeight:"bold"},null:"green",iconCollection:"#D2A8FF",iconEdit:"#D2A8FF",iconDelete:"rgb(203, 75, 22)",iconAdd:"rgb(203, 75, 22)",iconCopy:"#A5D6FF",iconOk:"#56d364",iconCancel:"rgb(203, 75, 22)"}},xe={displayName:"Github Light",styles:{container:"white",property:"#1F2328",bracket:"#00802e",itemCount:"#8B949E",string:"#0A3069",number:"#953800",boolean:{color:"#CF222E",fontSize:"90%",fontWeight:"bold"},null:"#FF7B72",iconCollection:"#8250DF",iconEdit:"#8250DF",iconDelete:"rgb(203, 75, 22)",iconAdd:"#8250DF",iconCopy:"#57606A"}},Ae={displayName:"Black & White",fragments:{lightText:{color:"white"},midGrey:"#5c5c5c"},styles:{container:["lightText",{backgroundColor:"black"}],dropZone:"#e0e0e029",property:"lightText",bracket:"midGrey",itemCount:"#4a4a4a",string:"#a8a8a8",number:"#666666",boolean:{color:"#848484",fontStyle:"italic"},null:"#333333",iconCollection:"midGrey",iconEdit:"midGrey",iconDelete:"midGrey",iconAdd:"midGrey",iconCopy:"midGrey",iconOk:"midGrey",iconCancel:"midGrey"}},Te={fragments:{midGrey:"#a3a3a3"},displayName:"White & Black",styles:{container:"white",property:"black",bracket:"midGrey",itemCount:"#b5b5b5",string:"#575757",number:"#999999",boolean:{color:"#7b7b7b",fontStyle:"italic"},null:"#cccccc",iconCollection:"midGrey",iconEdit:"midGrey",iconDelete:"midGrey",iconAdd:"midGrey",iconCopy:"midGrey",iconOk:"midGrey",iconCancel:"midGrey"}},Re={displayName:"Candy Wrapper",fragments:{minty:{backgroundColor:"#F1FAEE"},pale:{color:"#A8DADC"},mid:{color:"#457B9D"},dark:{color:"#1D3557"},pop:{color:"#E63946"},darkBlue:{color:"#2B2D42"}},styles:{container:"minty",property:"pop",dropZone:"#eb121217",bracket:"dark",itemCount:"pale",string:"mid",number:["darkBlue",{fontSize:"85%"}],boolean:["mid",{fontStyle:"italic",fontWeight:"bold",fontSize:"80%"}],null:["#cccccc",{fontWeight:"bold"}],input:{border:"1px solid rgb(115, 194, 198)"},iconCollection:"#1D3557",iconEdit:"#457B9D",iconDelete:"#E63946",iconAdd:"#2B2D42",iconCopy:"#1D3557",iconCancel:"#E63946"}},Pe={displayName:"Psychedelic",fragments:{pale:{color:"#A8DADC"},fluroYellow:"rgb(242, 228, 21)",fluroGreen:"rgb(68, 255, 62)",hotPink:"#f7379a"},styles:{container:{backgroundColor:"unset",background:"linear-gradient(90deg, hsla(333, 100%, 53%, 1) 0%, hsla(33, 94%, 57%, 1) 100%)",color:"black"},dropZone:"fluroYellow",property:"black",bracket:"fluroYellow",itemCount:["pale",{opacity:.7}],string:"white",number:["#33d9ff",{fontSize:"90%",fontWeight:"bold"}],boolean:["fluroGreen",{fontWeight:"bold",fontSize:"80%"}],null:["black",{fontWeight:"bold",opacity:.3,backgroundColor:"rgb(255, 255, 255, 0.5)",padding:"0 0.4em",borderRadius:"0.4em"}],iconCollection:"fluroYellow",iconEdit:["black"],iconDelete:["white",{opacity:.5}],iconAdd:["white",{opacity:.5}],iconCopy:"rgb(32, 84, 242)",iconOk:"fluroGreen",iconCancel:"hotPink"}};export{$ as IconAdd,q as IconCancel,ee as IconChevron,X as IconCopy,Z as IconDelete,J as IconEdit,Q as IconOk,Ee as JsonEditor,Oe as LinkCustomComponent,Se as LinkCustomNodeDefinition,B as StringDisplay,Re as candyWrapperTheme,x as defaultTheme,Ne as githubDarkTheme,xe as githubLightTheme,m as isCollection,b as matchNode,v as matchNodeKey,Ae as monoDarkTheme,Te as monoLightTheme,Pe as psychedelicTheme};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "json-edit-react",
3
- "version": "1.23.1",
3
+ "version": "1.25.0-beta1",
4
4
  "description": "React component for editing or viewing JSON/object data",
5
5
  "main": "build/index.cjs.js",
6
6
  "module": "build/index.esm.js",
@@ -28,7 +28,9 @@
28
28
  "build": "rimraf ./build && rollup -c && rimraf ./build/dts",
29
29
  "lint": "npx eslint \"src/**\"",
30
30
  "postbuild": "node ./scripts/cleanBuildTypes.cjs",
31
- "prepublish": "yarn build",
31
+ "prepareReadme": "python3 scripts/github-to-npm-markdown.py README.md -o .npm-readme.md",
32
+ "prepublishOnly": "yarn build && npm run prepareReadme && python3 scripts/use-npm-readme.py prepare",
33
+ "postpublish": "python3 scripts/use-npm-readme.py restore",
32
34
  "compile": "rimraf ./build && tsc",
33
35
  "release": "yarn publish",
34
36
  "release-demo": "cd demo && yarn deploy"