json-edit-react 1.25.0-beta1 → 1.25.0
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 +31 -976
- package/README_npm.md +15 -0
- package/README_npm_output.md +96 -0
- package/build/index.cjs.js +1 -1
- package/build/index.d.ts +19 -8
- package/build/index.esm.js +1 -1
- package/package.json +4 -4
package/README_npm.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<!-- The README that will appear on the package's NPM page: https://www.npmjs.com/package/json-edit-react
|
|
2
|
+
On publish, this file is temporarily renamed to the main README so it gets published to npm,
|
|
3
|
+
then renamed back to this file, so the primary README remains published to Github repo.
|
|
4
|
+
|
|
5
|
+
The {{BLOCKS}} below are replaced from the equivalent blocks in the main README file when the
|
|
6
|
+
`yarn prepareReadme` script is run (which also happens before publish).
|
|
7
|
+
-->
|
|
8
|
+
|
|
9
|
+
{{NPM INTRO}}
|
|
10
|
+
|
|
11
|
+
{{NPM USAGE}}
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
For **FULL DOCUMENTATION**, visit [https://github.com/CarlosNZ/json-edit-react](https://github.com/CarlosNZ/json-edit-react?tab=readme-ov-file#json-edit-react)
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
<!-- The README that will appear on the package's NPM page: https://www.npmjs.com/package/json-edit-react
|
|
2
|
+
On publish, this file is temporarily renamed to the main README so it gets published to npm,
|
|
3
|
+
then renamed back to this file, so the primary README remains published to Github repo.
|
|
4
|
+
|
|
5
|
+
The {{BLOCKS}} below are replaced from the equivalent blocks in the main README file when the
|
|
6
|
+
`yarn prepareReadme` script is run (which also happens before publish).
|
|
7
|
+
-->
|
|
8
|
+
|
|
9
|
+
<img width="60" alt="screenshot" src="image/logo192.png" style="float:left; margin-right: 1em;">
|
|
10
|
+
|
|
11
|
+
A highly-configurable [React](https://github.com/facebook/react) component for editing or viewing JSON/object data
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [Explore the Demo](https://carlosnz.github.io/json-edit-react/) <!-- omit in toc -->
|
|
15
|
+
|
|
16
|
+

|
|
17
|
+

|
|
18
|
+

|
|
19
|
+
|
|
20
|
+
### Features include:
|
|
21
|
+
|
|
22
|
+
- ✅ **Easy inline editing** of individual values or whole blocks of JSON text
|
|
23
|
+
- 🔒 **Granular control** – restrict edits, deletions, or additions per element
|
|
24
|
+
- 📏 **[JSON Schema](https://json-schema.org/) validation** (using 3rd-party validation library)
|
|
25
|
+
- 🎨 **Customisable UI** — built-in or custom [themes](https://github.com/CarlosNZ/json-edit-react#themes--styles), CSS overrides or targeted classes
|
|
26
|
+
- 📦 **Self-contained** — plain HTML/CSS, so no dependence on external UI libraries
|
|
27
|
+
- 🔍 **Search & filter** — find data by key, value or custom function
|
|
28
|
+
- 🚧 **[Custom components](https://github.com/CarlosNZ/json-edit-react#custom-nodes)** — replace specific nodes with specialised components (e.g. date picker, links, images)
|
|
29
|
+
- 🌏 **[Localisation](https://github.com/CarlosNZ/json-edit-react#localisation)** — easily translate UI labels and messages
|
|
30
|
+
- 🔄 **[Drag-n-drop](https://github.com/CarlosNZ/json-edit-react#drag-n-drop)** re-ordering within objects/arrays
|
|
31
|
+
- 🎹 **[Keyboard customisation](https://github.com/CarlosNZ/json-edit-react#keyboard-customisation)** — define your own key bindings
|
|
32
|
+
- 🎮 **[External control](https://github.com/CarlosNZ/json-edit-react#external-control-1)** via callbacks and triggers
|
|
33
|
+
|
|
34
|
+
💡 Try the **[Live Demo](https://carlosnz.github.io/json-edit-react/)** to see these features in action!
|
|
35
|
+
|
|
36
|
+
<img width="392" alt="screenshot" src="image/screenshot.png">
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
<div style="background-color: #f6f8fa; border-left: 4px solid #d63384; padding: 15px; margin: 15px 0; border-radius: 3px;">
|
|
40
|
+
<p style="margin: 0 0 10px 0; color: #d63384;">
|
|
41
|
+
<strong>🚨 IMPORTANT:</strong>
|
|
42
|
+
</p>
|
|
43
|
+
|
|
44
|
+
Breaking changes:
|
|
45
|
+
- **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](https://github.com/CarlosNZ/json-edit-react#themes--styles).
|
|
46
|
+
- **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](https://github.com/CarlosNZ/json-edit-react#managing-state).
|
|
47
|
+
</div>
|
|
48
|
+
|
|
49
|
+
## Installation
|
|
50
|
+
|
|
51
|
+
```sh
|
|
52
|
+
# Depending on your package manager:
|
|
53
|
+
|
|
54
|
+
npm i json-edit-react
|
|
55
|
+
# OR
|
|
56
|
+
yarn add json-edit-react
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Implementation
|
|
60
|
+
|
|
61
|
+
```jsx
|
|
62
|
+
import { JsonEditor } from 'json-edit-react'
|
|
63
|
+
|
|
64
|
+
// In your React component:
|
|
65
|
+
return (
|
|
66
|
+
<JsonEditor
|
|
67
|
+
data={ jsonData }
|
|
68
|
+
setData={ setJsonData } // optional
|
|
69
|
+
{ ...otherProps } />
|
|
70
|
+
);
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Usage
|
|
74
|
+
|
|
75
|
+
**(for end user)**
|
|
76
|
+
|
|
77
|
+
It's pretty self explanatory (click the "edit" icon to edit, etc.), but there are a few not-so-obvious ways of interacting with the editor:
|
|
78
|
+
|
|
79
|
+
- **Double-click** a value (or a key) to edit it
|
|
80
|
+
- When editing a string, use `Cmd/Ctrl/Shift-Enter` to add a new line (`Enter` submits the value)
|
|
81
|
+
- It's the opposite when editing a full object/array node (which you do by **clicking "edit"** on an object or array value) — `Enter` for new line, and `Cmd/Ctrl/Shift-Enter` for submit
|
|
82
|
+
- `Escape` to **cancel** editing
|
|
83
|
+
- When clicking the "**clipboard**" icon, holding down `Cmd/Ctrl` will copy the *path* to the selected node rather than its value
|
|
84
|
+
- When opening/closing a node, hold down "Alt/Option" to open/close *all* child nodes at once
|
|
85
|
+
- For Number inputs, **arrow-up** and **down** keys will increment/decrement the value
|
|
86
|
+
- For Boolean inputs, **space bar** will toggle the value
|
|
87
|
+
- Easily navigate to the next or previous node for editing using the `Tab`/`Shift-Tab` keys.
|
|
88
|
+
- **Drag and drop** items to change the structure or modify display order
|
|
89
|
+
- When editing is not permitted, double-clicking a string value will expand the text to the full value if it is truncated due to length (there is also a clickable "..." for long strings)
|
|
90
|
+
- **JSON text input** can accept "looser" input, if an additional JSON parsing method is provided (e.g. [JSON5](https://json5.org/)). See `jsonParse` prop.
|
|
91
|
+
|
|
92
|
+
[Have a play with the Demo app](https://carlosnz.github.io/json-edit-react/) to get a feel for it!
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
For **FULL DOCUMENTATION**, visit [https://github.com/CarlosNZ/json-edit-react](https://github.com/CarlosNZ/json-edit-react?tab=readme-ov-file#json-edit-react)
|
package/build/index.cjs.js
CHANGED
|
@@ -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,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"}};
|
|
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"]},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}),m=t.useRef(null),h=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!==m.current&&m.current(),l(n),r&&r(e,"key"===t),m.current="function"==typeof t?t:null},areChildrenBeingEdited:e=>null!==s&&s.includes(e),previouslyEditedElement:y.current,setPreviouslyEditedElement:e=>{y.current=e},tabDirection:h.current,setTabDirection:e=>{h.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},K="**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?'"':"",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}`]})},M=n=>{var{value:r,setValue:a,isEditing:s,path:l,handleEdit:c,nodeData:d,handleKeyboard:u,keyboardCommon:g,enumType:m}=n,h=o(n,["value","setValue","isEditing","path","handleEdit","nodeData","handleKeyboard","keyboardCommon","enumType"]);const{getStyles:y}=D(),f=t.useRef(null),b=p(l);return s&&m?e.jsxs("div",{className:"jer-select jer-select-enums",children:[e.jsx("select",{name:`${b}-value-select`,className:"jer-select-inner",onChange:e=>a(e.target.value),value:r,autoFocus:!0,onKeyDown:e=>{u(e,Object.assign({stringConfirm:c},g))},children:m.values.map((t=>e.jsx("option",{value:t,children:t},t)))}),e.jsx("span",{className:"focus"})]}):s?e.jsx(i,{className:"jer-input-text",textAreaRef:f,name:b,value:r,setValue:a,isEditing:s,handleKeyPress:e=>{u(e,Object.assign({stringConfirm:c,stringLineBreak:()=>{const e=v(f,"\n");a(e)}},g))},styles:y("input",d)}):e.jsx(P,Object.assign({nodeData:d,pathString:b,styles:y("string",d)},h))},V=({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})},F=({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)})},z=({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)})},_=({value:t})=>{let n="Error!";switch(typeof t){case"string":t===K&&(n="Function");break;case"undefined":n="Undefined";break;case"symbol":n="Symbol"}return e.jsx("span",{className:"jer-value-invalid",children:n})},I=({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"})]}),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"})]}),Y=({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}=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(I,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(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(Y,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,{})}},$=({startEdit:n,handleDelete:o,handleAdd:a,enableClipboard:i,type:s,customButtons:l,nodeData:c,translate:d,keyboardControls:u,handleKeyboard:p,editConfirmRef:m,getNewKeyOptions:h})=>{const{getStyles:y}=D(),f=d("KEY_NEW",c),[b,j]=t.useState(f),[v,x]=t.useState(!1),{key:E,path:C,value:w}=c,k=Array.isArray(v),O=e=>{var t;if(!e)return void x(!1);const n=Object.keys(r(c.fullData,C)),o=h?null===(t=h(c))||void 0===t?void 0:t.filter((e=>!n.includes(e))):null;o&&j(""),x(null==o||o)};return e.jsxs("div",{className:"jer-edit-buttons",style:{opacity:v?1:void 0},onClick:e=>e.stopPropagation(),children:[i&&e.jsx("div",{onClick:e=>{var t;e.stopPropagation();let n,r,o="value",a="",l=null;if(i){const c=g(e);if(c&&u.clipboardModifier.includes(c)?(n=Z(C),a=n,o="path"):(n=w,a=s?JSON.stringify(w,null,2):String(n)),!navigator.clipboard)return void("function"==typeof i&&i({success:!1,value:n,stringValue:a,path:C,key:E,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,l=e.message})).finally((()=>{"function"==typeof i&&i({success:r,errorMessage:l,value:n,stringValue:a,path:C,key:E,type:o})}))}},className:"jer-copy-pulse",children:e.jsx(U,{name:"copy",nodeData:c})}),n&&e.jsx("div",{onClick:n,children:e.jsx(U,{name:"edit",nodeData:c})}),o&&e.jsx("div",{onClick:o,children:e.jsx(U,{name:"delete",nodeData:c})}),a&&e.jsx("div",{onClick:()=>{"object"===s?O(!0):a("")},children:e.jsx(U,{name:"add",nodeData:c})}),null==l?void 0:l.map((({Element:t,onClick:n},r)=>e.jsx("div",{onClick:e=>n&&n(c,e),children:e.jsx(t,{nodeData:c})},r))),v&&a&&"object"===s&&e.jsxs(e.Fragment,{children:[k?e.jsxs("div",{className:"jer-select jer-select-keys",children:[e.jsxs("select",{name:"new-key-select",className:"jer-select-inner",onChange:e=>{a(e.target.value),O(!1)},defaultValue:"",autoFocus:!0,onKeyDown:e=>{p(e,{cancel:()=>O(!1)})},children:[e.jsx("option",{value:"",disabled:!0,children:v.length>0?d("KEY_SELECT",c):d("NO_KEY_OPTIONS",c)}),v.map((t=>e.jsx("option",{value:t,children:t},t)))]}),e.jsx("span",{className:"focus"})]}):e.jsx("input",{className:"jer-input-new-key",type:"text",name:"new-object-key",value:b,onChange:e=>j(e.target.value),autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>{p(e,{stringConfirm:()=>{a&&(O(!1),a(b),j(f))},cancel:()=>{O(!1),j(f)}})},style:y("input",c)}),e.jsx(J,{onOk:()=>{k&&!b||(O(!1),a(b))},onCancel:()=>{O(!1)},nodeData:c,editConfirmRef:m,hideOk:k})]})]})},J=({onOk:t,onCancel:n,nodeData:r,editConfirmRef:o,hideOk:a=!1})=>e.jsxs("div",{className:"jer-confirm-buttons",children:[!a&&e.jsx("div",{onClick:t,ref:o,children:e.jsx(U,{name:"ok",nodeData:r})}),e.jsx("div",{onClick:n,children:e.jsx(U,{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,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: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)),h)),console.warn("Error",e)},A=t.useCallback(((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,K=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: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:K,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,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]),f=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]),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:m,showLabel:h,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:M,previousValue:V,setPreviousValue:F}=T(),[z,_]=t.useState("function"==typeof r?K:r),{pathString:I,nodeData:L,path:B,name:W,canEdit:G,canDelete:Y,canDrag:H,error:U,onError:Z,handleEditKey:te,derivedValues:re}=Q({props:n}),{dragSourceProps:se,getDropTargetProps:le,BottomDropTarget:ce,DropTargetPadding:de}=ee({canDrag:H,canDragOnto:u,path:B,nodeData:L,onMove:c,onError:Z,translate:v}),ue=q(x,L),[pe,ge]=t.useState(oe(r,ue)),me=t.useCallback((e=>{if(!s)return void _(e);const t=s({currentData:L.fullData,newValue:e,currentValue:z,name:W,path:B});_(t)}),[s]);t.useEffect((()=>{_("function"==typeof r?K:r),ge(oe(r,ue))}),[r,U]);const{CustomNode:he,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(L);return"boolean"==typeof e?e?[]:Ee:e}),[L,p]),[De,we]=t.useState(((e,t)=>{var n;if("string"!=typeof e)return null;const r=t.filter((t=>t instanceof Object&&t.enum&&t.values.includes(e)&&t.matchPriority));return r.sort(((e,t)=>{var n,r;return(null!==(n=t.matchPriority)&&void 0!==n?n:0)-(null!==(r=e.matchPriority)&&void 0!==r?r:0)})),null!==(n=r[0])&&void 0!==n?n:null})(z,Ce)),{isEditing:ke}=re,Oe=l("value",L,g,m);if(ke&&(!Oe||!G)){const e=f(L.fullData,B,P,w);S(e||A)}if(!Oe)return null;const Se=()=>{let e;switch(S(null),F(null),pe){case"object":e={[v("DEFAULT_NEW_KEY",L)]:z};break;case"array":e=null!=z?z:[];break;case"number":{const t=Number(z);e=isNaN(t)?0:t;break}default:e=z}a(e,B).then((t=>{t&&Z({code:"UPDATE_ERROR",message:t},e)}))},Ne=()=>{S(null),null===V?(_(r),F(null)):a(V,B)},{isEditingKey:Ae,canEditKey:Te}=re,Re=!ke&&U,Ke=ke&&Ce.length>1,Pe="invalid"!==pe&&!U&&be,Me=h&&!fe,Ve=he&&(ke&&je||!ke&&ve),Fe={value:z,parentData:o,setValue:me,isEditing:ke,canEdit:G,setIsEditing:G?()=>S(B):()=>{},handleEdit:Se,handleCancel:Ne,path:B,stringTruncate:y,showStringQuotes:b,nodeData:L,enumType:De,translate:v,handleKeyboard:E,keyboardCommon:{cancel:Ne,tabForward:()=>{M("next"),R(I);const e=f(L.fullData,B,"next",w);e&&(Se(),S(e))},tabBack:()=>{M("prev"),R(I);const e=f(L.fullData,B,"prev",w);e&&(Se(),S(e))}}},ze={canEditKey:Te,isEditingKey:Ae,pathString:I,path:B,name:W,handleKeyboard:E,handleEditKey:te,handleCancel:Ne,styles:O("property",L),getNextOrPrevious:e=>f(L.fullData,B,e,w)},_e=Ve?e.jsx(he,Object.assign({},n,{value:z,customNodeProps:ye,setValue:me,handleEdit:Se,handleCancel:Ne,handleKeyPress:e=>E(e,{stringConfirm:Se,cancel:Ne}),isEditing:ke,setIsEditing:()=>S(B),getStyles:O,originalNode:xe?ae(r,Fe):void 0,originalNodeKey:xe?e.jsx(ne,Object.assign({},ze)):void 0})):ae(r,Fe);return e.jsxs("div",Object.assign({className:"jer-component jer-value-component",style:{marginLeft:j/2+"em",position:"relative"},draggable:H},se,le("above"),{children:[ce,e.jsx(de,{position:"above",nodeData:L}),e.jsxs("div",{className:"jer-value-main-row",style:{flexWrap:W.length>10?"wrap":"nowrap"},children:[Me&&e.jsx(ne,Object.assign({},ze)),e.jsxs("div",{className:"jer-value-and-buttons",children:[e.jsx("div",{className:"jer-input-component",children:_e}),ke?e.jsx(J,{onOk:Se,onCancel:Ne,nodeData:L,editConfirmRef:k}):Pe&&e.jsx($,{startEdit:G?()=>{F(z),S(B,Ne)}:void 0,handleDelete:Y?()=>{i(z,B).then((e=>{e&&Z({code:"DELETE_ERROR",message:e},z)}))}:void 0,enableClipboard:d,translate:v,customButtons:n.customButtons,nodeData:L,handleKeyboard:E,keyboardControls:C,editConfirmRef:k}),Ke&&e.jsxs("div",{className:"jer-select jer-select-types",children:[e.jsx("select",{name:`${W}-type-select`,className:"jer-select-inner",onChange:e=>(e=>{const t=x.find((t=>t.name===e));if(t)return a(t.defaultValue,B),ge(e),we(null),S(null),void N({path:B,collapsed:!1,includeChildren:!1});const n=Ce.find((t=>t instanceof Object&&t.enum===e));if(n)return"string"==typeof z&&n.values.includes(z)||a(n.values[0],B).then((e=>{e&&(Z({code:"UPDATE_ERROR",message:e},r),S(null))})),void we(n);const r=ie(z,e,v("DEFAULT_NEW_KEY",L),(null==ue?void 0:ue.CustomNode)?v("DEFAULT_STRING",L):void 0);a(r,B).then((e=>{e?(Z({code:"UPDATE_ERROR",message:e},r),S(null)):we(null)}))})(e.target.value),value:De?De.enum:pe,children:Ce.map((t=>t instanceof Object&&"enum"in t?e.jsx("option",{value:t.enum,children:t.enum},t.enum):e.jsx("option",{value:t,children:t},t)))}),e.jsx("span",{className:"focus"})]}),Re&&e.jsx("span",{className:"jer-error-slug",style:O("error",L),children:U})]})]}),e.jsx(de,{position:"below",nodeData:L})]}))},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(M,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(_,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:m,previousValue:h,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:K,searchFilter:P,searchText:M,indent:V,sort:F,showArrayIndices:z,defaultValue:_,newKeyOptions:I,translate:L,customNodeDefinitions:B,jsonParse:W,jsonStringify:G,TextEditor:Y,keyboardControls:H,handleKeyboard:Z,insertAtTop:X,onCollapse:oe,editConfirmRef:ae,collapseClickZones:ie}=n,[le,ce]=t.useState(G(j)),de=N(x),{contentRef:ue,isAnimating:pe,maxHeight:ge,collapsed:me,animateCollapse:he,cssTransitionValue:ye}=((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,de,b),{pathString:fe,nodeData:be,path:je,name:ve,size:xe,canEdit:Ee,canDelete:Ce,canAdd:De,canDrag:we,error:ke,setError:Oe,onError:Se,handleEditKey:Ne,derivedValues:Ae}=Q({props:n,collapsed:me}),{dragSourceProps:Te,getDropTargetProps:Re,BottomDropTarget:Ke,DropTargetPadding:Pe}=ee({canDrag:we,canDragOnto:S,path:je,nodeData:be,onMove:R,onError:Se,translate:L}),Me=t.useRef(!de),{isEditing:Ve,isEditingKey:Fe,isArray:ze,canEditKey:_e}=Ae;t.useEffect((()=>{ce(G(j))}),[j]),t.useEffect((()=>{const e=N(be)&&!Ve;Me.current=!e,he(e)}),[N]),t.useEffect((()=>{if(null!==o){const e=d(je);e&&(Me.current=!0,he(e.collapsed))}}),[o]);const Ie=t.useRef(null),Le=t.useCallback(((e,t)=>{if("function"!=typeof _)return _;const n=_(e,t);return void 0!==n?n:null}),[_]),Be=t.useCallback((e=>I?"function"!=typeof I?I:I(e):null),[I]),{CustomNode:We,customNodeProps:Ge,CustomWrapper:Ye,wrapperProps:He={},hideKey:Ue,showEditTools:$e=!0,showOnEdit:Je,showOnView:Ze,showCollectionWrapper:Xe=!0}=t.useMemo((()=>q(B,be)),[j]),qe=m(fe);qe&&me&&he(!1);if(!(l("collection",be,P,M)||0===be.level)&&!qe)return null;const Qe=Array.isArray(j)?"array":"object",et="array"===Qe?{open:"[",close:"]"}:{open:"{",close:"}"},tt=e=>{if("Tab"!==e.key||e.getModifierState("Shift"))Z(e,{objectConfirm:rt,cancel:at});else{e.preventDefault();const t=v(Ie,"\t");ce(t)}},nt=e=>{e.stopPropagation();const t=g(e);if(t&&H.collapseModifier.includes(t))return Me.current=!0,void c({collapsed:!me,path:je,includeChildren:!0});u&&u.includes(fe)||(Me.current=!0,c(null),oe&&oe({path:je,collapsed:!me,includeChildren:!1}),he(!me))},rt=()=>{try{const e=W(le);if(p(null),y(null),Oe(null),JSON.stringify(e)===JSON.stringify(j))return;w(e,je).then((t=>{t&&Se({code:"UPDATE_ERROR",message:t},e)}))}catch(e){Se({code:"INVALID_JSON",message:L("ERROR_INVALID_JSON",be)},le)}},ot=je.length>0?()=>{O(j,je).then((e=>{e&&Se({code:"DELETE_ERROR",message:e},j)}))}:void 0,at=()=>{p(null),null===h?(Oe(null),ce(G(j)),y(null)):w(h,je)},it="when-closed"===C?me:C,st=!Ve&&$e,lt=(z||!ze)&&!Ue&&void 0!==ve,ct=We&&(Ve&&Je||!Ve&&Ze),dt=Object.entries(j).map((([e,t])=>["array"===Qe?Number(e):e,t]));"object"===Qe&&F(dt,(e=>e));const ut=Me.current?Ve?e.jsxs("div",{className:"jer-collection-text-edit",children:[Y?e.jsx(Y,{value:le,onChange:ce,onKeyDown:e=>Z(e,{objectConfirm:rt,cancel:at})}):e.jsx(i,{textAreaRef:Ie,className:"jer-collection-text-area",name:fe,value:le,setValue:ce,isEditing:Ve,handleKeyPress:tt,styles:r("input",be)}),e.jsx("div",{className:"jer-collection-input-button-row",children:e.jsx(J,{onOk:rt,onCancel:at,nodeData:be,editConfirmRef:ae})})]}):dt.map((([t,o],a)=>{const i={key:t,value:o,path:[...je,t],level:je.length+1,index:a,size:s(o)?Object.keys(o).length:1,parentData:j,fullData:be.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:Ee}),t):e.jsx(re,Object.assign({},n,{data:o,parentData:j,nodeData:i,canDragOnto:Ee,showLabel:"object"===Qe||z}),t)},t)})):null,pt=!!Xe&&(me&&!qe);pt||(Me.current=!0);const gt=Object.assign(Object.assign({},n),{data:j,value:j,parentData:E,nodeData:be,setValue:e=>a(void 0,void 0,void 0,(function*(){return yield w(e,je)})),handleEdit:rt,handleCancel:at,handleKeyPress:tt,isEditing:Ve,setIsEditing:()=>p(je),getStyles:r,canDragOnto:Ee}),mt=ct?e.jsx(We,Object.assign({customNodeProps:Ge},gt,{children:ut})):ut,ht=st&&e.jsx($,{startEdit:Ee?()=>{Me.current=!0,y(null),p(je)}:void 0,handleAdd:De?e=>{he(!1);const t=Le(be,e);if("array"===Qe){const e=X.array?0:j.length,n=X.array?{insert:!0}:{};k(t,[...je,e],n).then((e=>{e&&Se({code:"ADD_ERROR",message:e},t)}))}else if(e in j)Se({code:"KEY_EXISTS",message:L("ERROR_KEY_EXISTS",be)},e);else{const n=X.object?{insertBefore:0}:{};k(t,[...je,e],n).then((e=>{e&&Se({code:"ADD_ERROR",message:e},t)}))}}:void 0,handleDelete:Ce?ot:void 0,enableClipboard:K,type:Qe,nodeData:be,translate:L,customButtons:n.customButtons,keyboardControls:H,handleKeyboard:Z,getNewKeyOptions:Be,editConfirmRef:ae}),yt={canEditKey:_e,isEditingKey:Fe,pathString:fe,path:je,name:ve,handleKeyboard:Z,handleEditKey:Ne,handleCancel:at,keyValueArray:dt,styles:r("property",be),getNextOrPrevious:e=>f(be.fullData,je,e,F),handleClick:ie.includes("property")?nt:e=>e.stopPropagation()},ft=e.jsxs("div",Object.assign({className:"jer-component jer-collection-component",style:Object.assign(Object.assign({marginLeft:(0===je.length?0:V/2)+"em"},r("collection",be)),{position:"relative"}),draggable:we},Te,Re("above"),{children:[e.jsx("div",{className:"jer-clickzone",style:{width:V/2+1+"em",zIndex:10+2*be.level},onClick:ie.includes("left")?nt:void 0}),!Ve&&Ke,e.jsx(Pe,{position:"above",nodeData:be}),Xe?e.jsxs("div",{className:"jer-collection-header-row",style:{position:"relative"},onClick:ie.includes("header")?nt:void 0,children:[e.jsxs("div",{className:"jer-collection-name",children:[e.jsx("div",{className:"jer-collapse-icon jer-accordion-icon"+(me?" jer-rotate-90":""),style:{zIndex:11+2*be.level,transition:ye},onClick:nt,children:e.jsx(U,{name:"chevron",rotate:me,nodeData:be})}),lt&&e.jsx(ne,Object.assign({},yt)),!Ve&&e.jsx("span",{className:"jer-brackets jer-bracket-open",style:r("bracket",be),children:et.open})]}),!Ve&&it&&e.jsx("div",{className:"jer-collection-item-count"+(it?" jer-visible":" jer-hidden"),style:Object.assign(Object.assign({},r("itemCount",be)),{transition:ye}),children:1===xe?L("ITEM_SINGLE",Object.assign(Object.assign({},be),{size:1}),1):L("ITEMS_MULTIPLE",be,xe)}),e.jsx("div",{className:"jer-brackets"+(pt?" jer-visible":" jer-hidden"),style:Object.assign(Object.assign({},r("bracket",be)),{transition:ye}),children:et.close}),ht]}):Ue?e.jsx(e.Fragment,{}):e.jsxs("div",{className:"jer-collection-header-row",style:{position:"relative"},children:[e.jsx(ne,Object.assign({},yt)),ht]}),e.jsxs("div",{className:"jer-collection-inner",style:Object.assign(Object.assign({overflowY:pt||pe?"clip":"visible",maxHeight:qe?void 0:ge},r("collectionInner",be)),{transition:ye}),ref:ue,children:[mt,e.jsx("div",{className:Ve?"jer-collection-error-row":"jer-collection-error-row-edit",children:ke&&e.jsx("span",{className:"jer-error-slug",style:r("error",be),children:ke})}),!Ve&&Xe&&e.jsx("div",{className:"jer-brackets jer-bracket-outside",style:Object.assign(Object.assign({},r("bracket",be)),{marginLeft:(V<3?-1:V<6?-.5:0)+"em"}),children:et.close})]}),e.jsx(Pe,{position:"below",nodeData:be})]}));return Ye?e.jsx(Ye,Object.assign({customNodeProps:He},gt,{children:ft})):ft},le={ITEM_SINGLE:"{{count}} item",ITEMS_MULTIPLE:"{{count}} items",KEY_NEW:"Enter new key",KEY_SELECT:"Select key",NO_KEY_OPTIONS:"No key options",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-select-inner{text-overflow:ellipsis;width:100%}.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:h=!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:K=!1,showArrayIndices:P=!0,showStringQuotes:M=!0,defaultValue:V=null,newKeyOptions:F,minWidth:z=250,maxWidth:_="min(600px, 90vw)",rootFontSize:I,stringTruncate:L=250,translations:B={},className:W,id:G,customText:Y={},customNodeDefinitions:H=[],customButtons:U=[],jsonParse:$=JSON.parse,jsonStringify:J=(e=>JSON.stringify(e,null,2)),TextEditor:Z,errorMessageTimeout:X=2500,keyboardControls:q={},externalTriggers:Q,insertAtTop:ee=!1,onCollapse:te,collapseClickZones:ne=["header","left"]})=>{const{getStyles:oe}=D(),{setCurrentlyEditingElement:ae}=T(),ie=t.useCallback(me(j),[j]),le=t.useCallback(ce(B,Y),[B,Y]),[de,ue]=t.useState(A),[pe,fe]=(({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}),be=t.useRef(null);t.useEffect((()=>{ae(null);const e=setTimeout((()=>ue(A)),R);return()=>clearTimeout(e)}),[A,R]);const je={key:o,path:[],level:0,index:0,value:pe,size:"object"==typeof pe&&null!==pe?Object.keys(pe).length:1,parentData:null,fullData:pe},ve=(e,t)=>a(void 0,void 0,void 0,(function*(){const n=yield e(t);if(!0===n||void 0===n)return void fe(t.newData);const r=ye(n)?n:["error",n],[o,a]=r;if("error"===o)return fe(t.currentData),!1===a?le("ERROR_UPDATE",je):String(a);fe(a)})),xe=t.useMemo((()=>me(E,S)),[E,S]),Ee=t.useMemo((()=>me(C,S)),[C,S]),Ce=t.useMemo((()=>me(w,S)),[w,S]),De=t.useMemo((()=>me(O,S)),[O,S]),we=t.useMemo((()=>he(N)),[N]),ke=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})(q)),[q]),Oe=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}})(ke,t,e)),[q]),Se=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,Se);const Ne=t.useCallback(((e,t)=>{!1!==K&&("function"!=typeof K?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)=>K(t(e),t(n)))))}),[K]),Ae={mainContainerRef:be,name:o,nodeData:je,onEdit:(e,t)=>a(void 0,void 0,void 0,(function*(){const{currentData:n,newData:r,currentValue:o,newValue:a}=ge(pe,t,e,"update");if(o!==a)return yield ve(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(pe,t,e,"delete");return yield ve(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(pe,t,e,"add",n);return yield ve(d,{currentData:r,newData:o,currentValue:a,newValue:i,name:t.slice(-1)[0],path:t})})),onChange:u,onError:g,showErrorMessages:h,onMove:(e,t,n)=>a(void 0,void 0,void 0,(function*(){if(null===e)return;const{currentData:r,newData:o,currentValue:a}=ge(pe,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 ve(l,{currentData:r,newData:p,currentValue:a,newValue:g,name:t.slice(-1)[0],path:t})})),showCollectionCount:x,collapseFilter:ie,collapseAnimationTime:v,restrictEditFilter:xe,restrictDeleteFilter:Ee,restrictAddFilter:Ce,restrictTypeSelection:k,restrictDragFilter:De,canDragOnto:!1,searchFilter:we,searchText:de,enableClipboard:f,keySort:K,sort:Ne,showArrayIndices:P,showStringQuotes:M,indent:b,defaultValue:V,newKeyOptions:F,stringTruncate:L,translate:le,customNodeDefinitions:H,customButtons:U,parentData:null,jsonParse:$,jsonStringify:J,TextEditor:Z,errorMessageTimeout:X,handleKeyboard:Oe,keyboardControls:ke,insertAtTop:{object:!0===ee||"object"===ee,array:!0===ee||"array"===ee},onCollapse:te,editConfirmRef:Se,collapseClickZones:ne},Te=Object.assign(Object.assign({},oe("container",je)),{minWidth:z,maxWidth:_});return Te.fontSize=null!=I?I:Te.fontSize,e.jsx("div",{id:G,ref:be,className:`jer-editor-container ${null!=W?W:""}`,style:Te,children:s(pe)?e.jsx(se,Object.assign({data:pe},Ae)):e.jsx(re,Object.assign({data:pe,showLabel:!0},Ae))})},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}},me=(e,t)=>t?()=>!0:"boolean"==typeof e?()=>e:"number"==typeof e?({level:t})=>t>=e:e,he=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=I,exports.IconCancel=Y,exports.IconChevron=H,exports.IconCopy=W,exports.IconDelete=B,exports.IconEdit=L,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"}},exports.standardDataTypes=X;
|
package/build/index.d.ts
CHANGED
|
@@ -7,6 +7,8 @@ declare const localisedStrings: {
|
|
|
7
7
|
ITEM_SINGLE: string;
|
|
8
8
|
ITEMS_MULTIPLE: string;
|
|
9
9
|
KEY_NEW: string;
|
|
10
|
+
KEY_SELECT: string;
|
|
11
|
+
NO_KEY_OPTIONS: string;
|
|
10
12
|
ERROR_KEY_EXISTS: string;
|
|
11
13
|
ERROR_INVALID_JSON: string;
|
|
12
14
|
ERROR_UPDATE: string;
|
|
@@ -52,7 +54,7 @@ interface JsonEditorProps {
|
|
|
52
54
|
restrictEdit?: boolean | FilterFunction;
|
|
53
55
|
restrictDelete?: boolean | FilterFunction;
|
|
54
56
|
restrictAdd?: boolean | FilterFunction;
|
|
55
|
-
restrictTypeSelection?: boolean |
|
|
57
|
+
restrictTypeSelection?: boolean | TypeOptions | TypeFilterFunction;
|
|
56
58
|
restrictDrag?: boolean | FilterFunction;
|
|
57
59
|
viewOnly?: boolean;
|
|
58
60
|
searchText?: string;
|
|
@@ -61,7 +63,8 @@ interface JsonEditorProps {
|
|
|
61
63
|
keySort?: boolean | CompareFunction;
|
|
62
64
|
showArrayIndices?: boolean;
|
|
63
65
|
showStringQuotes?: boolean;
|
|
64
|
-
defaultValue?:
|
|
66
|
+
defaultValue?: string | number | boolean | null | object | DefaultValueFunction;
|
|
67
|
+
newKeyOptions?: string[] | NewKeyOptionsFunction;
|
|
65
68
|
minWidth?: string | number;
|
|
66
69
|
maxWidth?: string | number;
|
|
67
70
|
rootFontSize?: string | number;
|
|
@@ -81,10 +84,16 @@ interface JsonEditorProps {
|
|
|
81
84
|
onCollapse?: OnCollapseFunction;
|
|
82
85
|
externalTriggers?: ExternalTriggers;
|
|
83
86
|
}
|
|
84
|
-
declare const
|
|
85
|
-
type DataType = (typeof
|
|
87
|
+
declare const standardDataTypes: readonly ["string", "number", "boolean", "null", "object", "array"];
|
|
88
|
+
type DataType = (typeof standardDataTypes)[number] | 'invalid';
|
|
86
89
|
type CollectionKey = string | number;
|
|
87
90
|
type CollectionData = object | unknown[];
|
|
91
|
+
interface EnumDefinition {
|
|
92
|
+
enum: string;
|
|
93
|
+
values: string[];
|
|
94
|
+
matchPriority?: number;
|
|
95
|
+
}
|
|
96
|
+
type TypeOptions = Array<DataType | string | EnumDefinition>;
|
|
88
97
|
type ErrorString = string;
|
|
89
98
|
interface IconReplacements {
|
|
90
99
|
add?: JSX.Element;
|
|
@@ -130,10 +139,11 @@ type OnErrorFunction = (props: {
|
|
|
130
139
|
error: JerError;
|
|
131
140
|
}) => unknown;
|
|
132
141
|
type FilterFunction = (input: NodeData) => boolean;
|
|
133
|
-
type TypeFilterFunction = (input: NodeData) => boolean |
|
|
142
|
+
type TypeFilterFunction = (input: NodeData) => boolean | TypeOptions;
|
|
134
143
|
type CustomTextFunction = (input: NodeData) => string | null;
|
|
135
|
-
type DefaultValueFunction = (input: NodeData) => unknown;
|
|
144
|
+
type DefaultValueFunction = (input: NodeData, newKey?: string) => unknown;
|
|
136
145
|
type SearchFilterFunction = (inputData: NodeData, searchText: string) => boolean;
|
|
146
|
+
type NewKeyOptionsFunction = (input: NodeData) => string[] | null | void;
|
|
137
147
|
type CopyType = 'path' | 'value';
|
|
138
148
|
type CopyFunction = (input: {
|
|
139
149
|
success: boolean;
|
|
@@ -211,7 +221,7 @@ interface BaseNodeProps {
|
|
|
211
221
|
canDragOnto: boolean;
|
|
212
222
|
searchFilter?: SearchFilterFunction;
|
|
213
223
|
searchText?: string;
|
|
214
|
-
restrictTypeSelection: boolean |
|
|
224
|
+
restrictTypeSelection: boolean | TypeOptions | TypeFilterFunction;
|
|
215
225
|
stringTruncate: number;
|
|
216
226
|
indent: number;
|
|
217
227
|
sort: SortFunction;
|
|
@@ -233,6 +243,7 @@ interface CollectionNodeProps extends BaseNodeProps {
|
|
|
233
243
|
showCollectionCount: boolean | 'when-closed';
|
|
234
244
|
showStringQuotes: boolean;
|
|
235
245
|
defaultValue: unknown;
|
|
246
|
+
newKeyOptions?: string[] | NewKeyOptionsFunction;
|
|
236
247
|
jsonParse: (input: string) => JsonData;
|
|
237
248
|
jsonStringify: (data: JsonData) => string;
|
|
238
249
|
insertAtTop: {
|
|
@@ -348,4 +359,4 @@ declare const monoLightTheme: Theme;
|
|
|
348
359
|
declare const candyWrapperTheme: Theme;
|
|
349
360
|
declare const psychedelicTheme: Theme;
|
|
350
361
|
|
|
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 };
|
|
362
|
+
export { CollapseState, CollectionNodeProps, CompareFunction, CopyFunction, CustomNodeDefinition, CustomNodeProps, CustomTextDefinitions, CustomTextFunction, DataType, DefaultValueFunction, EditState, EnumDefinition, ExternalTriggers, FilterFunction, IconAdd, IconCancel, IconChevron, IconCopy, IconDelete, IconEdit, IconOk, IconReplacements, JerError, JsonData, JsonEditor, JsonEditorProps, KeyboardControls, LinkCustomComponent, LinkCustomNodeDefinition, LocalisedStrings, NewKeyOptionsFunction, 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, standardDataTypes };
|