json-edit-react 1.30.1 → 1.30.2
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 +17 -0
- package/build/index.cjs.js +1 -1
- package/build/index.esm.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -40,6 +40,23 @@ A highly-configurable [React](https://github.com/facebook/react) component for e
|
|
|
40
40
|
|
|
41
41
|
<img width="392" alt="screenshot" src="image/screenshot.png">
|
|
42
42
|
|
|
43
|
+
|
|
44
|
+
----
|
|
45
|
+
|
|
46
|
+
> **📣️ ANNOUNCEMENT**
|
|
47
|
+
>
|
|
48
|
+
> V2 of **json-edit-react** is now available in beta, with significant refactors and performance improvements.
|
|
49
|
+
> ```
|
|
50
|
+
> npm install json-edit-react@beta
|
|
51
|
+
> yarn add json-edit-react@beta
|
|
52
|
+
> pnpm add json-edit-react@beta
|
|
53
|
+
> ```
|
|
54
|
+
> ❗️ If you're upgrading from V1, be sure to read the [migration guide](https://github.com/CarlosNZ/json-edit-react/blob/main/migration-guide.md).
|
|
55
|
+
>
|
|
56
|
+
> 📖️ **[FULL DOCS](https://github.com/CarlosNZ/json-edit-react/blob/main/README_V2.md)**
|
|
57
|
+
>
|
|
58
|
+
> If you've got any suggestions, please join the discussion [here](https://github.com/CarlosNZ/json-edit-react/discussions/198).
|
|
59
|
+
|
|
43
60
|
<img width="838" alt="breaking changes" src="image/admonition_npm.png">
|
|
44
61
|
|
|
45
62
|
## Installation
|
package/build/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("react/jsx-runtime"),t=require("react");function n(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 r(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 o=e=>e.split(/(\.|\[\d+\])/).filter((e=>"."!==e&&""!==e)).map((e=>{const t=/\[(\d+)\]/.exec(e);return t?Number(t[1]):e})),a=(e,t,n)=>{const r=Array.isArray(t)?t:o(t);if(0===r.length)return e;const s=r[0];if(Array.isArray(e)&&"number"!=typeof s&&e.length>0)return e.map((e=>a(e,r,n)));if("object"!=typeof e||null===e||!(s in e))return i(e,s,n);const l=e[s];return 1===r.length?l:a(l,r.slice(1),n)},i=(e,t,n)=>{if(void 0===n)throw new Error(`Unable to extract object property\nLooking for property: ${t}\nIn object: ${JSON.stringify(e)}`);return n},s=(e,t,n,r,o)=>{if(!r)throw new Error(null!=o?o:`Invalid property path: ${t}\nCouldn't access "${n}" in ${JSON.stringify(e)}`)},l=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),c=e=>Array.isArray(e),d=(e,t)=>e.filter(((e,n)=>n!==t)),u=(e,t,n,r={})=>{const{remove:a=!1,createNew:i=!0,noError:s=!1}=r,l=e,u="string"==typeof(m=t)?m:"number"==typeof m?String(m):m.reduce(((e,t)=>"number"==typeof t?`${e}[${t}]`:""===e?t:`${e}.${t}`),"");var m;const g=Object.assign(Object.assign({},r),{remove:a,createNew:i,noError:s,fullData:l,fullPath:u}),h=Array.isArray(t)?t:o(t);return c(e)&&a&&1===h.length?d(e,h[0]):p(e,h,n,g)},p=(e,t,n,r)=>{const o=l(e)?Object.assign({},e):null,a=c(e)?[...e]:null;if(0===t.length)return e;if(!o&&!a)throw new Error("Can't assign property -- invalid input object");const{createNew:i,remove:u,noError:h,fullData:y,fullPath:f}=r,b=t[0];if(a&&"string"==typeof b)return a.map((e=>p(e,t,n,r)));if(1===t.length){if(o&&"string"==typeof b){const e=m(o,b,n,r);return null!=e?e:o}return a&&"number"==typeof b?(g(a,b,n,r),a):(s(y,f,b,h),e)}const j=o||a||[];if(u&&2===t.length&&"number"==typeof t[1]){const e=j[b],n=t[1];return c(e)?j[b]=d(e,n):s(y,f,b,h,"Trying to remove an indexed item from an object that is not an array"),j}const v=t.slice(1);if(b in e){if(E=j[b],!c(E)&&!l(E)){if(!i)return s(y,f,b,h),j;j[b]={}}return j[b]=p(j[b],v,n,r),j}var E;if(i){const e="number"==typeof v[0]?[]:{};if(o)return j[b]=e,j[b]=p(j[b],v,n,r),j;if(a&&Array.isArray(j)){j.push(e);const t=j.length-1;return j[t]=p(j[t],v,n,r),j}}return s(y,f,b,h),j},m=(e,t,n,r)=>{const{remove:o,createNew:a,noError:i,insertAfter:l,insertBefore:c,fullData:d,fullPath:u}=r;if(void 0!==c||void 0!==l){const r=Object.entries(e);let o=1/0;return o="number"==typeof c?c:"number"==typeof l?l:r.findIndex((([e])=>e===(null!=c?c:l))),void 0!==l&&o++,r.splice(o,0,[t,n]),Object.fromEntries(r)}const p=t in e;o?p?delete e[t]:s(d,u,t,i):a||p?e[t]=n:s(d,u,t,i)},g=(e,t,n,r)=>{const{noError:o,fullData:a,fullPath:i,createNew:l,insert:c}=r;c&&e.splice(t,0,n),t in e?e[t]=n:l?e.push(n):s(a,i,t,o)},h=({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})]})},y=e=>null!==e&&"object"==typeof e,f=(e,t,n,r="")=>{if(!n&&!r)return!0;switch(e){case"collection":if(n){if(n(t,r))return!0;if(!b(r,t,n))return!1}if(!n&&r&&!b(r,t))return!1;break;case"value":if(n&&!n(t,r))return!1;if(!n&&r&&!j(t,r))return!1}return!0},b=(e="",t,n=j)=>{const r=t.value;return Object.entries(r).some((([o,a])=>{const i=[...t.path,o],s=Object.assign(Object.assign({},t),{key:o,path:i,level:t.level+1,value:a,size:i.length,parentData:r});return y(a)?b(e,s,n):n(s,e)}))},j=(e,t="")=>{const{value:n}=e;if(null===n&&"null".includes(t.toLowerCase()))return!0;switch(typeof n){case"string":return n.toLowerCase().includes(t.toLowerCase());case"number":return!!String(n).includes(t);case"boolean":return n?"true".includes(t.toLowerCase())||"1"===t:"false".includes(t.toLowerCase())||"0"===t;default:return!1}},v=({key:e,path:t},n="")=>!!j({value:e},n)||!!t.some((e=>j({value:e},n))),E=(e,t)=>(null!=t?t:"")+e.map((e=>""===e?String.fromCharCode(0):e)).join("."),x=e=>e.shiftKey?"Shift":e.metaKey?"Meta":e.ctrlKey?"Control":e.altKey?"Alt":void 0,D=(e,t,n)=>{const r=e.key,o=x(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)))},C={key:"Enter"},w={confirm:C,cancel:{key:"Escape"},objectConfirm:Object.assign(Object.assign({},C),{modifier:["Meta","Shift","Control"]}),objectLineBreak:C,stringConfirm:C,stringLineBreak:Object.assign(Object.assign({},C),{modifier:["Shift"]}),numberConfirm:C,numberUp:{key:"ArrowUp"},numberDown:{key:"ArrowDown"},tabForward:{key:"Tab"},tabBack:{key:"Tab",modifier:"Shift"},booleanConfirm:C,booleanToggle:{key:" "},clipboardModifier:["Meta","Control"],collapseModifier:["Alt"]},k=(e,t,n="next",r)=>{const o=t.slice(0,t.length-1),i=t.slice(-1)[0];if(void 0===i)return null;const s=a(e,o),l=S(s);Array.isArray(s)||r(l,(({key:e,value:t})=>[e,t]));const c=l.findIndex((e=>e.key===i)),d=l[c+("next"===n?1:-1)];return d?y(d.value)?0===Object.keys(d.value).length?k(e,[...o,d.key],n,r):O(e,[...o,d.key],n,r):[...o,d.key]:0===o.length?null:k(e,o,n,r)},O=(e,t,n="next",r)=>{const o=a(e,t);if(!y(o))return t;const i=Array.isArray(o)?o.map(((e,t)=>t)):Object.keys(o);r(i,(e=>[e,o]));const s="next"===n?i[0]:i[i.length-1];return O(e,[...t,s],n,r)},S=e=>Array.isArray(e)?e.map(((e,t)=>({index:t,value:e,key:t}))):Object.entries(e).map((([e,t],n)=>({key:e,value:t,index:n}))),N=(e,t)=>{var n,r,o,a;const i=e.current,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},T=e=>{if(e!==A){if(Array.isArray(e))return e.map((e=>T(e)));if(e&&"object"==typeof e)for(const t in e)e[t]=T(e[t]);return e}},A="__undefined__",R={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)"}},P=t.createContext({getStyles:()=>({}),icons:{}}),K=({theme:t=R,icons:n={},docRoot:r,children:o})=>{const a=V(t,r);return e.jsx(P.Provider,{value:{getStyles:(e,t)=>"function"==typeof a[e]?a[e](t):a[e],icons:n},children:o})},I=()=>t.useContext(P),V=(e,t)=>{var n,r,o,a;const i={},s=(Array.isArray(e)?e:[e]).map((e=>_(e)?M({fragments:{},styles:e},i):M(e,i))),l=M(R,{});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},M=(e,t)=>{const{fragments:n,styles:r}=e,o={};return Object.entries(r).forEach((([e,r])=>{const a=(Array.isArray(r)?r:[r]).reduce(((r,o)=>{var a,i;if("function"==typeof o)return t[e]=o,Object.assign({},r);if("string"==typeof o){const t=null!==(a=null==n?void 0:n[o])&&void 0!==a?a:o;return"string"==typeof t?Object.assign(Object.assign({},r),{[null!==(i=F[e])&&void 0!==i?i:"color"]:t}):Object.assign(Object.assign({},r),t)}return Object.assign(Object.assign({},r),o)}),{});o[e]=a})),o},_=e=>!("styles"in e),F={container:"backgroundColor",collection:"backgroundColor",collectionInner:"backgroundColor",collectionElement:"backgroundColor",dropZone:"borderColor",inputHighlight:"backgroundColor"},L=t.createContext(null),z=({children:n,onEditEvent:r,onCollapse:o})=>{const[a,i]=t.useState(null),[s,l]=t.useState(null),[c,d]=t.useState(null),[u,p]=t.useState({path:null,pathString:null}),m=t.useRef(null),g=t.useRef("next"),h=t.useRef(null);return e.jsx(L.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(W(e,t))return t;return null}return W(e,a)?a:null},currentlyEditingElement:s,setCurrentlyEditingElement:(e,t)=>{const n="string"==typeof e||null===e?e:E(e,"key"===t?"key_":void 0);null!==s&&null!==n&&null!==m.current&&m.current(),l(n),r&&(Array.isArray(e)||null===e)&&r(e,"key"===t),m.current="function"==typeof t?t:null},areChildrenBeingEdited:e=>null!==s&&s.includes(e),previouslyEditedElement:h.current,setPreviouslyEditedElement:e=>{h.current=e},tabDirection:g.current,setTabDirection:e=>{g.current=e},previousValue:c,setPreviousValue:d,dragSource:u,setDragSource:p},children:n})},B=()=>{const e=t.useContext(L);if(!e)throw new Error("Missing Context Provider");return e},W=(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},G="**INVALID_FUNCTION**",Y=({nodeData:n,showStringQuotes:r=!0,stringTruncate:o=200,pathString:a,canEdit:i,setIsEditing:s,styles:l,translate:c,value:d,TextWrapper:u=({children:e})=>e})=>{const p=null!=d?d:n.value,[m,g]=t.useState(!1),h=r?'"':"",y=p.length>o,f=()=>{i?s(!0):g(!m)};return e.jsxs("div",{id:`${a}_display`,onDoubleClick:f,onClick:e=>{(e.getModifierState("Control")||e.getModifierState("Meta"))&&f()},className:"jer-value-string",style:l,children:[h,y?m?e.jsxs(e.Fragment,{children:[e.jsx(u,{children:e.jsxs("span",{children:[p,h]})}),e.jsxs("span",{className:"jer-string-expansion jer-show-less",onClick:()=>g(!1),children:[" ",c("SHOW_LESS",n)]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(u,{children:[e.jsx("span",{children:p.slice(0,o-2).trimEnd()})," "]}),e.jsx("span",{className:"jer-string-expansion jer-ellipsis",onClick:()=>g(!0),children:"..."}),h]}):e.jsx(u,{children:`${p}${h}`})]})},$=({styles:n,pathString:r,value:o,setValue:a,handleEdit:i,handleKeyboard:s,keyboardCommon:l})=>{const c=t.useRef(null);return e.jsx(h,{className:"jer-input-text",textAreaRef:c,name:r,value:o,setValue:a,handleKeyPress:e=>{s(e,Object.assign({stringConfirm:i,stringLineBreak:()=>{const e=N(c,"\n");a(e)}},l))},styles:n})},U=t=>{var{isEditing:r,path:o,enumType:a}=t,i=n(t,["isEditing","path","enumType"]);const{getStyles:s}=I(),l=E(o),{value:c,setValue:d,nodeData:u,handleEdit:p,handleKeyboard:m,keyboardCommon:g}=i;return r&&a?e.jsxs("div",{className:"jer-select jer-select-enums",children:[e.jsx("select",{name:`${l}-value-select`,className:"jer-select-inner",onChange:e=>d(e.target.value),value:c,autoFocus:!0,onKeyDown:e=>{m(e,Object.assign({stringConfirm:p},g))},children:a.values.map((t=>e.jsx("option",{value:t,children:t},t)))}),e.jsx("span",{className:"focus"})]}):r?e.jsx($,Object.assign({styles:s("input",u),pathString:l},i,{setValue:i.setValue})):e.jsx(Y,Object.assign({pathString:l,styles:s("string",u)},i))},H=({value:t,setValue:n,isEditing:r,path:o,setIsEditing:a,handleEdit:i,nodeData:s,handleKeyboard:l,keyboardCommon:c})=>{const{getStyles:d}=I();return r?e.jsx("input",{className:"jer-input-number",type:"text",name:E(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}=I();return"boolean"!=typeof t?null:r?e.jsx("input",{className:"jer-input-boolean",type:"checkbox",name:E(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)})},J=(e,n)=>{const r=t.useRef(void 0),o=t.useRef(n);t.useEffect((()=>{o.current=n}),[n]);const a=e=>{o.current(e)};t.useEffect((()=>{if(window.clearTimeout(r.current),e)return r.current=window.setTimeout((()=>{window.addEventListener("keydown",a)}),100),()=>{window.clearTimeout(r.current),window.removeEventListener("keydown",a)}}),[e])},X=({value:t,isEditing:n,setIsEditing:r,handleEdit:o,nodeData:a,handleKeyboard:i,keyboardCommon:s})=>{const{getStyles:l}=I();return J(n,(e=>i(e,Object.assign({confirm:o},s)))),e.jsx("div",{onDoubleClick:()=>r(!0),className:"jer-value-null",style:l("null",a),children:String(t)})},Q=({value:t})=>{let n="Error!";switch(typeof t){case"string":t===G&&(n="Function");break;case"undefined":n="Undefined";break;case"symbol":n="Symbol"}return e.jsx("span",{className:"jer-value-invalid",children:n})},q=({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"})]}),ee=({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"})]}),te=({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"})}),ne=({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"})]}),re=({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"})]}),oe=({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"})}),ae=({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"})}),ie=({name:t,nodeData:n})=>{var r,o,a,i,s,l,c;const{getStyles:d,icons:u}=I(),p={size:"1.4em",className:"jer-icon"};switch(t){case"add":return null!==(r=null==u?void 0:u.add)&&void 0!==r?r:e.jsx(q,Object.assign({},p,{style:d("iconAdd",n)}));case"edit":return null!==(o=null==u?void 0:u.edit)&&void 0!==o?o:e.jsx(ee,Object.assign({},p,{style:d("iconEdit",n)}));case"delete":return null!==(a=null==u?void 0:u.delete)&&void 0!==a?a:e.jsx(te,Object.assign({},p,{style:d("iconDelete",n),size:"1.45em"}));case"copy":return null!==(i=null==u?void 0:u.copy)&&void 0!==i?i:e.jsx(ne,Object.assign({},p,{style:d("iconCopy",n),size:"1.2em"}));case"ok":return null!==(s=null==u?void 0:u.ok)&&void 0!==s?s:e.jsx(re,Object.assign({},p,{style:Object.assign({fontSize:"90%"},d("iconOk",n))}));case"cancel":return null!==(l=null==u?void 0:u.cancel)&&void 0!==l?l:e.jsx(oe,Object.assign({},p,{style:Object.assign({fontSize:"130%"},d("iconCancel",n))}));case"chevron":return null!==(c=null==u?void 0:u.chevron)&&void 0!==c?c:e.jsx(ae,{size:"1em",style:d("iconCollection",n)});default:return e.jsx(e.Fragment,{})}},se=({startEdit:n,handleDelete:r,handleAdd:o,enableClipboard:i,type:s,customButtons:l,nodeData:c,translate:d,keyboardControls:u,handleKeyboard:p,editConfirmRef:m,getNewKeyOptions:g,jsonStringify:h,onEditEvent:y,showIconTooltips:f})=>{const{getStyles:b}=I(),j=d("KEY_NEW",c),[v,E]=t.useState(j),[D,C]=t.useState(!1),{key:w,path:k,value:O}=c,S=Array.isArray(D),N=e=>{var t;if(y&&y(e?[...k,null]:null,e),!e)return void C(!1);const n=Object.keys(a(c.fullData,k)),r=g?null===(t=g(c))||void 0===t?void 0:t.filter((e=>!n.includes(e))):null;r&&E(""),C(null==r||r)};return e.jsxs("div",{className:"jer-edit-buttons",style:{opacity:D?1:void 0},onClick:e=>e.stopPropagation(),children:[i&&e.jsx("div",{onClick:e=>{var t;e.stopPropagation();let n,r,o="value",a="",s=null;if(i){const l=x(e);if(l&&u.clipboardModifier.includes(l)?(n=ce(k),a=n,o="path"):(n=O,a="object"==typeof n?h(O):String(n)),!navigator.clipboard)return void("function"==typeof i&&i({success:!1,value:n,stringValue:a,path:k,key:w,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,s=e.message})).finally((()=>{"function"==typeof i&&i({success:r,errorMessage:s,value:n,stringValue:a,path:k,key:w,type:o})}))}},className:"jer-copy-pulse",title:f?d("TOOLTIP_COPY",c):"",children:e.jsx(ie,{name:"copy",nodeData:c})}),n&&e.jsx("div",{onClick:n,title:f?d("TOOLTIP_EDIT",c):"",children:e.jsx(ie,{name:"edit",nodeData:c})}),r&&e.jsx("div",{onClick:r,title:f?d("TOOLTIP_DELETE",c):"",children:e.jsx(ie,{name:"delete",nodeData:c})}),o&&e.jsx("div",{onClick:()=>{"object"===s?N(!0):o("")},title:f?d("TOOLTIP_ADD",c):"",children:e.jsx(ie,{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))),D&&o&&"object"===s&&e.jsxs(e.Fragment,{children:[S?e.jsxs("div",{className:"jer-select jer-select-keys",children:[e.jsxs("select",{name:"new-key-select",className:"jer-select-inner",onChange:e=>{o(e.target.value),N(!1)},defaultValue:"",autoFocus:!0,onKeyDown:e=>{p(e,{cancel:()=>N(!1)})},children:[e.jsx("option",{value:"",disabled:!0,children:D.length>0?d("KEY_SELECT",c):d("NO_KEY_OPTIONS",c)}),D.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:v,onChange:e=>E(e.target.value),autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>{p(e,{stringConfirm:()=>{o&&(N(!1),o(v),E(j))},cancel:()=>{N(!1),E(j)}})},style:b("input",c)}),e.jsx(le,{onOk:()=>{S&&!v||(N(!1),o(v))},onCancel:()=>{N(!1)},nodeData:c,editConfirmRef:m,hideOk:S})]})]})},le=({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(ie,{name:"ok",nodeData:r})}),e.jsx("div",{onClick:n,children:e.jsx(ie,{name:"cancel",nodeData:r})})]}),ce=e=>e.reduce(((e,t)=>"number"==typeof t?`${e}[${t}]`:""===e?t:`${e}.${t}`),""),de=["string","number","boolean","null","object","array"],ue=({props:e,collapsed:n})=>{const{data:r,nodeData:o,parentData:a,onEdit:i,onError:s,showErrorMessages:l,restrictEditFilter:c,restrictDeleteFilter:d,restrictAddFilter:u,restrictDragFilter:p,translate:m,errorMessageTimeout:g}=e,{currentlyEditingElement:h,setCurrentlyEditingElement:y}=B(),[f,b]=t.useState(null),j=Object.assign(Object.assign({},o),{collapsed:n}),{path:v,key:x,size:D}=j,C=E(v),w=!c(j),k=!d(j),O=!u(j),S=!p(j)&&k&&null===h,N=e=>{l&&(b(e),setTimeout((()=>b(null)),g)),console.warn("Error",e)},T=t.useCallback(((e,t)=>{N(e.message),s&&s({currentData:j.fullData,errorValue:t,currentValue:r,name:x,path:v,error:e})}),[s,l]),A=h===C,R=h===`key_${C}`,P="number"==typeof v.slice(-1)[0],K={isEditing:A,isEditingKey:R,isArray:P,canEditKey:null!==a&&w&&O&&k&&!P},I=""===x&&v.length>0?m("EMPTY_STRING",j):null;return{pathString:C,nodeData:j,path:v,name:x,size:D,canEdit:w,canDelete:k,canAdd:O,canDrag:S,error:f,showError:N,onError:T,setError:b,handleEditKey:e=>{if(y(null),x===e)return;if(!a)return;const t=v.slice(0,-1);if(Object.keys(a).includes(e))return void T({code:"KEY_EXISTS",message:m("ERROR_KEY_EXISTS",j)},e);const n=Object.fromEntries(Object.entries(a).map((([t,n])=>t===x?[e,n]:[t,n])));i(n,t).then((t=>{t&&T({code:"UPDATE_ERROR",message:t},e)}))},derivedValues:K,emptyStringKey:I}},pe=({canDrag:n,canDragOnto:r,path:o,nodeData:a,onMove:i,onError:s,translate:l})=>{const{getStyles:c}=I(),{dragSource:d,setDragSource:u}=B(),[p,m]=t.useState(!1),g=E(o),h=t.useMemo((()=>n?{onDragStart:e=>{e.stopPropagation(),u({path:o,pathString:g})},onDragEnd:e=>{e.stopPropagation(),u({path:null,pathString:null})}}:{}),[n,g]),y=t.useMemo((()=>e=>r?{onDragOver:e=>{e.stopPropagation(),e.preventDefault()},onDrop:t=>{t.stopPropagation(),b(e),u({path:null,pathString:null}),m(!1)},onDragEnter:t=>{var n;t.stopPropagation(),g.startsWith(null!==(n=d.pathString)&&void 0!==n?n:"")||m(e)},onDragExit:e=>{e.stopPropagation(),m(!1)}}:{}),[d,r,g]),f=t.useMemo((()=>r&&null!==d.pathString?e.jsx("div",Object.assign({className:"jer-drop-target-bottom",style:{height:"50%",position:"absolute",width:"100%",top:"50%",zIndex:o.length}},y("below"))):null),[d,r,o.length]),b=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:h,getDropTargetProps:y,BottomDropTarget:f,DropTargetPadding:({position:t,nodeData:n})=>p===t?e.jsx("div",{className:"jer-drag-n-drop-padding",style:c("dropZone",n)}):null,handleDrop:b}},me=(e,t,n,r)=>{var o,a,i;if(!t.current)return 0;const s=parseInt(null!==(o=getComputedStyle(n.current).getPropertyValue("line-height"))&&void 0!==o?o:"16px"),l=(null!==(i=null===(a=t.current)||void 0===a?void 0:a.offsetWidth)&&void 0!==i?i:0)/(.5*s),c=r(e).replace(/\\n/g,"\n").split("\n").map((e=>Math.ceil(e.length/l))).reduce(((e,t)=>e+t),0)*s;return Math.min(c+30,window.innerHeight-50)},ge=({isEditingKey:t,canEditKey:n,pathString:r,path:o,name:a,arrayIndexFromOne:i,handleKeyboard:s,handleEditKey:l,handleCancel:c,handleClick:d,keyValueArray:u,styles:p,getNextOrPrevious:m,emptyStringKey:g,nodeData:h,customNodeData:y,getStyles:f})=>{const{setCurrentlyEditingElement:b}=B(),j="number"==typeof a?String(a+(i?1:0)):a;if(!t){const t=Object.assign(Object.assign({},p),{minWidth:`${Math.min(j.length+1,5)}ch`,flexShrink:j.length>10?1:0});if((null==y?void 0:y.CustomKey)&&h&&f){const{CustomKey:r,customNodeProps:a}=y;return e.jsx(r,{nodeData:h,name:null!=g?g:j,path:o,canEditKey:n,handleEditKey:e=>{n&&l(e)},setIsEditingKey:()=>{n&&b(o,"key")},handleClick:d,styles:t,customNodeProps:a,getStyles:f})}return e.jsxs("span",{className:"jer-key-text",style:t,onDoubleClick:()=>n&&b(o,"key"),onClick:d,children:[g?e.jsx("span",{className:"jer-empty-string",children:g}):j,""!==j||g?e.jsx("span",{className:"jer-key-colon",children:":"}):null]})}return e.jsx("input",{className:"jer-input-text jer-key-edit",type:"text",name:r,defaultValue:j,autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>s(e,{stringConfirm:()=>l(e.target.value),cancel:c,tabForward:()=>{if(l(e.target.value),u){const e=null==u?void 0:u[0][0];b(e?[...o,e]:m("next"))}else b(o)},tabBack:()=>{l(e.target.value),b(m("prev"))}}),style:{width:j.length/1.5+.5+"em"}})},he=n=>{const{data:r,parentData:o,onEdit:a,onDelete:i,onChange:s,onMove:l,enableClipboard:c,canDragOnto:d,restrictTypeSelection:u,searchFilter:p,searchText:m,showLabel:g,stringTruncate:h,showStringQuotes:y,arrayIndexFromOne:b,indent:j,translate:v,customNodeDefinitions:E,customNodeData:x,handleKeyboard:D,keyboardControls:C,sort:w,editConfirmRef:O,jsonStringify:S,showIconTooltips:N}=n,{getStyles:T}=I(),{setCurrentlyEditingElement:A,setCollapseState:R,previouslyEditedElement:P,setPreviouslyEditedElement:K,tabDirection:V,setTabDirection:M,previousValue:_,setPreviousValue:F}=B(),[L,z]=t.useState("function"==typeof r?G:r),{pathString:W,nodeData:Y,path:$,name:U,canEdit:H,canDelete:Z,canDrag:J,error:X,onError:Q,handleEditKey:q,emptyStringKey:ee,derivedValues:te}=ue({props:n}),{dragSourceProps:ne,getDropTargetProps:re,BottomDropTarget:oe,DropTargetPadding:ae}=pe({canDrag:J,canDragOnto:d,path:$,nodeData:Y,onMove:l,onError:Q,translate:v}),[ie,ce]=t.useState(ye(r,x)),me=t.useCallback((e=>{if(!s)return void z(e);const t=s({currentData:Y.fullData,newValue:e,currentValue:L,name:U,path:$});z(t)}),[s]);t.useEffect((()=>{z("function"==typeof r?G:r),ce(ye(r,x))}),[r,X]);const{CustomNode:he,customNodeProps:je,hideKey:ve,showEditTools:Ee=!0,showOnEdit:xe,showOnView:De,passOriginalNode:Ce}=x,we=[...de,...E.filter((({showInTypesSelector:e=!1,name:t})=>e&&!!t)).map((({name:e})=>e))],ke=t.useMemo((()=>{if("boolean"==typeof u)return u?[]:we;if(Array.isArray(u))return u;const e=u(Y);return"boolean"==typeof e?e?[]:we:e}),[Y,u]),[Oe,Se]=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})(L,ke)),{isEditing:Ne}=te,Te=f("value",Y,p,m);if(Ne&&(!Te||!H)){const e=k(Y.fullData,$,V,w);A(e||P)}if(!Te)return null;const Ae=e=>{let t;if(A(null),F(null),void 0===e||(e=>e&&"object"==typeof e&&"type"in e&&"target"in e&&"preventDefault"in e&&"function"==typeof e.preventDefault)(e))switch(ie){case"object":t={[v("DEFAULT_NEW_KEY",Y)]:L};break;case"array":t=null!=L?L:[];break;case"number":{const e=Number(L);t=isNaN(e)?0:e;break}default:t=L}else t=e;a(t,$).then((e=>{e&&Q({code:"UPDATE_ERROR",message:e},t)}))},Re=()=>{A(null),null===_?(z(r),F(null)):a(_,$)},{isEditingKey:Pe,canEditKey:Ke}=te,Ie=!Ne&&X,Ve=Ne&&ke.length>1,Me=("invalid"!==ie||he)&&!X&&Ee,_e=g&&!ve,Fe=he&&(Ne&&xe||!Ne&&De),Le={value:L,parentData:o,setValue:me,isEditing:Ne,canEdit:H,setIsEditing:H?()=>A($):()=>{},handleEdit:Ae,handleCancel:Re,path:$,stringTruncate:h,showStringQuotes:y,nodeData:Y,enumType:Oe,translate:v,handleKeyboard:D,keyboardCommon:{cancel:Re,tabForward:()=>{M("next"),K(W);const e=k(Y.fullData,$,"next",w);e&&(Ae(),A(e))},tabBack:()=>{M("prev"),K(W);const e=k(Y.fullData,$,"prev",w);e&&(Ae(),A(e))}}},ze={canEditKey:Ke,isEditingKey:Pe,pathString:W,path:$,name:U,arrayIndexFromOne:b,handleKeyboard:D,handleEditKey:q,handleCancel:Re,styles:T("property",Y),getNextOrPrevious:e=>k(Y.fullData,$,e,w),emptyStringKey:ee,nodeData:Y,customNodeData:x,getStyles:T},Be=Fe?e.jsx(he,Object.assign({},n,{value:L,customNodeProps:je,setValue:me,handleEdit:Ae,handleCancel:Re,handleKeyPress:e=>D(e,{stringConfirm:Ae,cancel:Re}),isEditing:Ne,setIsEditing:()=>A($),getStyles:T,originalNode:Ce?fe(r,Le):void 0,originalNodeKey:Ce?e.jsx(ge,Object.assign({},ze,{customNodeData:void 0})):void 0,canEdit:H,keyboardCommon:Le.keyboardCommon,onError:Q})):fe(r,Le);return e.jsxs("div",Object.assign({className:"jer-component jer-value-component",style:{marginLeft:null!==o?j/2+"em":0,position:"relative"},draggable:J},ne,re("above"),{children:[oe,e.jsx(ae,{position:"above",nodeData:Y}),e.jsxs("div",{className:"jer-value-main-row",style:{flexWrap:U.length>10?"wrap":"nowrap"},children:[_e&&e.jsx(ge,Object.assign({},ze)),e.jsxs("div",{className:"jer-value-and-buttons",children:[e.jsx("div",{className:"jer-input-component",children:Be}),Ne?e.jsx(le,{onOk:Ae,onCancel:Re,nodeData:Y,editConfirmRef:O}):Me&&e.jsx(se,{startEdit:H?()=>{F(_),A($,Re)}:void 0,handleDelete:Z?()=>{i(L,$).then((e=>{e&&Q({code:"DELETE_ERROR",message:e},L)}))}:void 0,enableClipboard:c,translate:v,customButtons:n.customButtons,nodeData:Y,handleKeyboard:D,keyboardControls:C,editConfirmRef:O,jsonStringify:S,showIconTooltips:N}),Ve&&e.jsxs("div",{className:"jer-select jer-select-types",children:[e.jsx("select",{name:`${U}-type-select`,className:"jer-select-inner",onChange:e=>(e=>{const t=E.find((t=>t.name===e));if(t)return a(t.defaultValue,$),ce(e),Se(null),A(null),void R({path:$,collapsed:!1,includeChildren:!1});const n=ke.find((t=>t instanceof Object&&t.enum===e));if(n)return"string"==typeof L&&n.values.includes(L)||a(n.values[0],$).then((e=>{e&&(Q({code:"UPDATE_ERROR",message:e},r),A(null))})),void Se(n);const r=be(L,e,v("DEFAULT_NEW_KEY",Y),(null==x?void 0:x.CustomNode)?v("DEFAULT_STRING",Y):void 0);["string","number","boolean"].includes(e)||A(null),a(r,$).then((e=>{e?(Q({code:"UPDATE_ERROR",message:e},r),A(null)):Se(null)}))})(e.target.value),value:Oe?Oe.enum:ie,children:ke.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"})]}),Ie&&e.jsx("span",{className:"jer-error-slug",style:T("error",Y),children:X})]})]}),e.jsx(ae,{position:"below",nodeData:Y})]}))},ye=(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",fe=(t,n)=>{const r=ye(t),{value:o}=n;switch(r){case"string":return e.jsx(U,Object.assign({},n,{value:o}));case"number":return e.jsx(H,Object.assign({},n,{value:o}));case"boolean":return e.jsx(Z,Object.assign({},n,{value:o}));case"null":return e.jsx(X,Object.assign({},n));default:return e.jsx(Q,Object.assign({},n))}},be=(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)}},je=(e=[],t)=>{const r=e.filter((({condition:e})=>e(t)));if(0===r.length)return{};const o=r[0],{element:a,wrapperElement:i,customKey:s,customNodeProps:l,wrapperProps:c,hideKey:d=!1,showEditTools:u=!0,showOnEdit:p=!1,showOnView:m=!0,showCollectionWrapper:g=!0}=o,h=n(o,["element","wrapperElement","customKey","customNodeProps","wrapperProps","hideKey","showEditTools","showOnEdit","showOnView","showCollectionWrapper"]);return Object.assign({CustomNode:a,CustomWrapper:i,CustomKey:s,customNodeProps:l,wrapperProps:c,hideKey:d,showEditTools:u,showOnEdit:p,showOnView:m,showCollectionWrapper:g},h)},ve=n=>{const{getStyles:o}=I(),{collapseState:a,setCollapseState:i,getMatchingCollapseState:s,currentlyEditingElement:l,setCurrentlyEditingElement:c,areChildrenBeingEdited:d,previousValue:u,setPreviousValue:p}=B(),{mainContainerRef:m,data:g,nodeData:b,parentData:j,showCollectionCount:v,onEdit:E,onAdd:D,onDelete:C,canDragOnto:w,collapseFilter:O,collapseAnimationTime:S,onMove:T,enableClipboard:A,onEditEvent:R,showIconTooltips:P,searchFilter:K,searchText:V,indent:M,sort:_,showArrayIndices:F,arrayIndexFromOne:L,defaultValue:z,newKeyOptions:W,translate:G,customNodeDefinitions:Y,customNodeData:$,jsonParse:U,jsonStringify:H,TextEditor:Z,keyboardControls:J,handleKeyboard:X,insertAtTop:Q,onCollapse:q,editConfirmRef:ee,collapseClickZones:te}=n,[ne,re]=t.useState(H(g)),oe=O(b),{contentRef:ae,isAnimating:ce,maxHeight:de,collapsed:ye,animateCollapse:fe,cssTransitionValue:be}=((e,n,r,o,a)=>{const[i,s]=t.useState(r?0:void 0),[l,c]=t.useState(r),d=t.useRef(!1),u=t.useRef(null),p=t.useRef(0),m=t.useRef(0),g=n/1e3+"s",h=t.useCallback((t=>{var r,i;if(l!==t){switch(window.clearTimeout(m.current),d.current=!0,t){case!0:{const e=null!==(i=null===(r=u.current)||void 0===r?void 0:r.offsetHeight)&&void 0!==i?i:0;p.current=e,s(e),setTimeout((()=>{s(0)}),5);break}case!1:s(p.current||me(e,u,o,a))}c(!l),m.current=window.setTimeout((()=>{d.current=!1,t||s(void 0)}),n)}}),[n,l,e,o,a]);return{contentRef:u,isAnimating:d.current,animateCollapse:h,maxHeight:i,collapsed:l,cssTransitionValue:g}})(g,S,oe,m,H),{pathString:Ee,nodeData:xe,path:De,name:Ce,size:we,canEdit:ke,canDelete:Oe,canAdd:Se,canDrag:Ne,error:Te,setError:Ae,onError:Re,handleEditKey:Pe,emptyStringKey:Ke,derivedValues:Ie}=ue({props:n,collapsed:ye}),{dragSourceProps:Ve,getDropTargetProps:Me,BottomDropTarget:_e,DropTargetPadding:Fe}=pe({canDrag:Ne,canDragOnto:w,path:De,nodeData:xe,onMove:T,onError:Re,translate:G}),Le=t.useRef(!oe),{isEditing:ze,isEditingKey:Be,isArray:We,canEditKey:Ge}=Ie;t.useEffect((()=>{re(H(g))}),[g]),t.useEffect((()=>{const e=O(xe)&&!ze;Le.current=!e,fe(e)}),[O]),t.useEffect((()=>{if(null!==a){const e=s(De);e&&(Le.current=!0,fe(e.collapsed))}}),[a]);const Ye=t.useRef(null),$e=t.useCallback(((e,t)=>{if("function"!=typeof z)return z;const n=z(e,t);return void 0!==n?n:null}),[z]),Ue=t.useCallback((e=>W?"function"!=typeof W?W:W(e):null),[W]),{CustomNode:He,customNodeProps:Ze,CustomWrapper:Je,wrapperProps:Xe={},hideKey:Qe,showEditTools:qe=!0,showOnEdit:et,showOnView:tt,showCollectionWrapper:nt=!0}=$,rt=d(Ee);rt&&ye&&fe(!1);if(!(f("collection",xe,K,V)||0===xe.level)&&!rt)return null;const ot=Array.isArray(g)?"array":"object",at="array"===ot?{open:"[",close:"]"}:{open:"{",close:"}"},it=e=>{if("Tab"!==e.key||e.getModifierState("Shift"))X(e,{objectConfirm:lt,cancel:dt});else{e.preventDefault();const t=N(Ye,"\t");re(t)}},st=e=>{e.stopPropagation();const t=x(e);if(t&&J.collapseModifier.includes(t))return Le.current=!0,void i({collapsed:!ye,path:De,includeChildren:!0});l&&l.includes(Ee)||(Le.current=!0,i(null),q&&q({path:De,collapsed:!ye,includeChildren:!1}),fe(!ye))},lt=()=>{try{const e=U(ne);if(c(null),p(null),Ae(null),H(e)===H(g))return;E(e,De).then((t=>{t&&Re({code:"UPDATE_ERROR",message:t},e)}))}catch(e){Re({code:"INVALID_JSON",message:G("ERROR_INVALID_JSON",xe)},ne)}},ct=De.length>0?()=>{C(g,De).then((e=>{e&&Re({code:"DELETE_ERROR",message:e},g)}))}:void 0,dt=()=>{c(null),null===u?(Ae(null),re(H(g)),p(null)):E(u,De)},ut="when-closed"===v?ye:v,pt=!ze&&qe,mt=(F||!We)&&!Qe&&void 0!==Ce,gt=He&&(ze&&et||!ze&&tt),ht=Object.entries(g).map((([e,t])=>["array"===ot?Number(e):e,t]));"object"===ot&&_(ht,(e=>e));const yt=Le.current?ze?e.jsxs("div",{className:"jer-collection-text-edit",children:[Z?e.jsx(Z,{value:ne,onChange:re,onKeyDown:e=>X(e,{objectConfirm:lt,cancel:dt})}):e.jsx(h,{textAreaRef:Ye,className:"jer-collection-text-area",name:Ee,value:ne,setValue:re,handleKeyPress:it,styles:o("input",xe)}),e.jsx("div",{className:"jer-collection-input-button-row",children:e.jsx(le,{onOk:lt,onCancel:dt,nodeData:xe,editConfirmRef:ee})})]}):ht.map((([t,r],a)=>{const i={key:t,value:r,path:[...De,t],level:De.length+1,index:a,size:y(r)?Object.keys(r).length:null,parentData:g,fullData:xe.fullData},s=je(Y,i);return e.jsx("div",{className:"jer-collection-element",style:o("collectionElement",i),children:y(r)&&!(null==s?void 0:s.renderCollectionAsValue)?e.jsx(ve,Object.assign({},n,{data:r,parentData:g,nodeData:i,showCollectionCount:v,canDragOnto:ke,customNodeData:s}),t):e.jsx(he,Object.assign({},n,{data:r,parentData:g,nodeData:i,canDragOnto:ke,showLabel:"object"===ot||F,customNodeData:s}),t)},t)})):null,ft=!!nt&&(ye&&!rt);ft||(Le.current=!0);const bt=Object.assign(Object.assign({},n),{data:g,value:g,parentData:j,nodeData:xe,setValue:e=>r(void 0,void 0,void 0,(function*(){return yield E(e,De)})),handleEdit:lt,handleCancel:dt,handleKeyPress:it,isEditing:ze,setIsEditing:()=>c(De),getStyles:o,canDragOnto:ke,canEdit:ke,keyboardCommon:{},onError:Re}),jt=gt?e.jsx(He,Object.assign({customNodeProps:Ze},bt,{children:yt})):yt,vt=pt&&e.jsx(se,{startEdit:ke?()=>{Le.current=!0,p(null),c(De)}:void 0,handleAdd:Se?e=>{fe(!1);const t=$e(xe,e);if("array"===ot){const e=Q.array?0:g.length,n=Q.array?{insert:!0}:{};D(t,[...De,e],n).then((e=>{e&&Re({code:"ADD_ERROR",message:e},t)}))}else if(e in g)Re({code:"KEY_EXISTS",message:G("ERROR_KEY_EXISTS",xe)},e);else{const n=Q.object?{insertBefore:0}:{};D(t,[...De,e],n).then((e=>{e&&Re({code:"ADD_ERROR",message:e},t)}))}}:void 0,handleDelete:Oe?ct:void 0,enableClipboard:A,type:ot,nodeData:xe,translate:G,customButtons:n.customButtons,keyboardControls:J,handleKeyboard:X,getNewKeyOptions:Ue,editConfirmRef:ee,jsonStringify:H,onEditEvent:R,showIconTooltips:P}),Et={canEditKey:Ge,isEditingKey:Be,pathString:Ee,path:De,name:Ce,arrayIndexFromOne:L,handleKeyboard:X,handleEditKey:Pe,handleCancel:dt,keyValueArray:ht,styles:o("property",xe),getNextOrPrevious:e=>k(xe.fullData,De,e,_),handleClick:te.includes("property")?st:e=>e.stopPropagation(),emptyStringKey:Ke,nodeData:xe,customNodeData:$,getStyles:o},xt=e.jsxs("div",Object.assign({className:"jer-component jer-collection-component",style:Object.assign(Object.assign({marginLeft:(0===De.length?0:M/2)+"em"},o("collection",xe)),{position:"relative"}),draggable:Ne},Ve,Me("above"),{children:[e.jsx("div",{className:"jer-clickzone",style:{width:M/2+1+"em",zIndex:10+2*xe.level},onClick:te.includes("left")?st:void 0}),!ze&&_e,e.jsx(Fe,{position:"above",nodeData:xe}),nt?e.jsxs("div",{className:"jer-collection-header-row",style:{position:"relative"},onClick:te.includes("header")?st:void 0,children:[e.jsxs("div",{className:"jer-collection-name",children:[e.jsx("div",{className:"jer-collapse-icon jer-accordion-icon"+(ye?" jer-rotate-90":""),style:{zIndex:11+2*xe.level,transition:be},onClick:st,children:e.jsx(ie,{name:"chevron",rotate:ye,nodeData:xe})}),mt&&e.jsx(ge,Object.assign({},Et)),!ze&&e.jsx("span",{className:"jer-brackets jer-bracket-open",style:o("bracket",xe),children:at.open})]}),!ze&&ut&&e.jsx("div",{className:"jer-collection-item-count"+(ut?" jer-visible":" jer-hidden"),style:Object.assign(Object.assign({},o("itemCount",xe)),{transition:be}),children:1===we?G("ITEM_SINGLE",Object.assign(Object.assign({},xe),{size:1}),1):G("ITEMS_MULTIPLE",xe,we)}),e.jsx("div",{className:"jer-brackets"+(ft?" jer-visible":" jer-hidden"),style:Object.assign(Object.assign({},o("bracket",xe)),{transition:be}),children:at.close}),vt]}):Qe?e.jsx(e.Fragment,{}):e.jsxs("div",{className:"jer-collection-header-row",style:{position:"relative"},children:[e.jsx(ge,Object.assign({},Et)),vt]}),e.jsxs("div",{className:"jer-collection-inner",style:Object.assign(Object.assign({overflowY:ft||ce?"clip":"visible",maxHeight:rt?void 0:de},o("collectionInner",xe)),{transition:be}),ref:ae,children:[jt,e.jsx("div",{className:ze?"jer-collection-error-row":"jer-collection-error-row-edit",children:Te&&e.jsx("span",{className:"jer-error-slug",style:o("error",xe),children:Te})}),!ze&&nt&&e.jsx("div",{className:"jer-brackets jer-bracket-outside",style:Object.assign(Object.assign({},o("bracket",xe)),{marginLeft:(M<3?-1:M<6?-.5:0)+"em"}),children:at.close})]}),e.jsx(Fe,{position:"below",nodeData:xe})]}));return Je?e.jsx(Je,Object.assign({customNodeProps:Xe},bt,{children:xt})):xt},Ee={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)",EMPTY_STRING:"<empty string>",TOOLTIP_COPY:"Copy to clipboard",TOOLTIP_EDIT:"Edit",TOOLTIP_DELETE:"Delete",TOOLTIP_ADD:"Add"},xe=(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]:Ee[r];return void 0===o?a:null==a?void 0:a.replace("{{count}}",String(o))})(e,t,r,n,o);var De=[],Ce=[];!function(e,t){if(e&&"undefined"!=typeof document){var n,r=!0===t.prepend?"prepend":"append",o=!0===t.singleTag,a="string"==typeof t.container?document.querySelector(t.container):document.getElementsByTagName("head")[0];if(o){var i=De.indexOf(a);-1===i&&(i=De.push(a)-1,Ce[i]={}),n=Ce[i]&&Ce[i][r]?Ce[i][r]:Ce[i][r]=s()}else n=s();65279===e.charCodeAt(0)&&(e=e.substring(1)),n.styleSheet?n.styleSheet.cssText+=e:n.appendChild(document.createTextNode(e))}function s(){var e=document.createElement("style");if(e.setAttribute("type","text/css"),t.attributes)for(var n=Object.keys(t.attributes),o=0;o<n.length;o++)e.setAttribute(n[o],t.attributes[n[o]]);var i="prepend"===r?"afterbegin":"beforeend";return a.insertAdjacentElement(i,e),e}}(':root{--jer-select-border:#b6b6b6;--jer-select-focus:#777;--jer-select-arrow:#777;--jer-form-border:1px solid #ededf0;--jer-form-border-focus:1px solid #e2e2e2;--jer-highlight-color:#b3d8ff}.jer-visible{opacity:1}.jer-hidden{opacity:0}.jer-select select{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:transparent;border:none;color:#000;cursor:inherit;font-family:inherit;font-size:.8em;line-height:inherit;margin:0;outline:none;padding:0 1em 0 0;z-index:1}select::-ms-expand{display:none}.jer-select{align-items:center;background-color:#fff;background-image:linear-gradient(0deg,#f9f9f9,#fff 33%);border:1px solid var(--jer-select-border);border-radius:.25em;cursor:pointer;display:grid;grid-template-areas:"select";line-height:1.1;max-width:15ch;min-width:12ch;padding:.25em .5em;position:relative}.jer-select select,.jer-select:after{grid-area:select}.jer-select:not(.jer-select--multiple):after{background-color:var(--jer-select-arrow);clip-path:polygon(100% 0,0 0,50% 100%);content:"";height:.5em;justify-self:end;width:.8em}select:focus+.focus{border:1px solid var(--jer-select-focus);border-radius:inherit;bottom:-1px;left:-1px;position:absolute;right:-1px;top:-1px}.jer-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-bracket-outside{padding-left:.5em}.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{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 we=(e,t)=>JSON.stringify(e,t,2),ke=({data:n,setData:o,rootName:a="root",onUpdate:i=()=>{},onEdit:s=i,onDelete:l=i,onAdd:c=i,onChange:d,onError:u,onEditEvent:p,showErrorMessages:m=!0,enableClipboard:g=!0,indent:h=2,collapse:f=!1,collapseAnimationTime:b=300,showCollectionCount:j=!0,restrictEdit:v=!1,restrictDelete:x=!1,restrictAdd:C=!1,restrictTypeSelection:k=!1,restrictDrag:O=!0,viewOnly:S,searchFilter:N,searchText:A,searchDebounceTime:R=350,keySort:P=!1,showArrayIndices:K=!0,arrayIndexFromOne:V=!1,showStringQuotes:M=!0,showIconTooltips:_=!1,defaultValue:F=null,newKeyOptions:L,minWidth:z=250,maxWidth:W="min(600px, 90vw)",rootFontSize:G,stringTruncate:Y=250,translations:$={},className:U,id:H,customText:Z={},customNodeDefinitions:J=[],customButtons:X=[],jsonParse:Q=JSON.parse,jsonStringify:q=we,TextEditor:ee,errorMessageTimeout:te=2500,keyboardControls:ne={},externalTriggers:re,insertAtTop:oe=!1,onCollapse:ae,collapseClickZones:ie=["header","left"]})=>{const{getStyles:se}=I(),{setCurrentlyEditingElement:le}=B(),ce=t.useMemo((()=>Se(f)),[f]),de=t.useMemo((()=>xe($,Z)),[$,Z]),[ue,pe]=t.useState(A),[me,ge]=(({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:o,data:n}),ye=t.useRef(null);t.useEffect((()=>{le(null);const e=setTimeout((()=>pe(A)),R);return()=>clearTimeout(e)}),[A,R]);const fe={key:a,path:[],level:0,index:0,value:me,size:"object"==typeof me&&null!==me?Object.keys(me).length:1,parentData:null,fullData:me},be=(e,t)=>r(void 0,void 0,void 0,(function*(){const n=yield e(t);if(!0===n||void 0===n)return void ge(t.newData);const r=Te(n)?n:["error",n],[o,a]=r;if("error"===o)return ge(t.currentData),!1===a?de("ERROR_UPDATE",fe):String(a);ge(a)})),Ee=t.useMemo((()=>Se(v,S)),[v,S]),De=t.useMemo((()=>Se(x,S)),[x,S]),Ce=t.useMemo((()=>Se(C,S)),[C,S]),ke=t.useMemo((()=>Se(O,S)),[O,S]),Re=t.useMemo((()=>Ne(N)),[N]),Pe=t.useMemo((()=>(e=>{const t=Object.assign({},w);for(const n of Object.keys(w)){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})(ne)),[ne]),Ke=t.useCallback(((e,t)=>((e,t,n)=>{const r=Object.entries(t);for(const[t,o]of r)if(D(n,e[t],t)){n.preventDefault(),o();break}})(Pe,t,e)),[Pe]),Ie=t.useMemo((()=>{const e=Ae(J,"stringifyReplacer");return t=>q(t,e)}),[J,q]),Ve=t.useMemo((()=>{const e=Ae(J,"parseReviver");return t=>{const n=Q(t,e);return T(n)}}),[J,Q]),Me=t.useRef(null);((e,n)=>{const{setCurrentlyEditingElement:r,currentlyEditingElement:o,setCollapseState:a}=B();t.useEffect((()=>{if(!e)return;const{collapse:t,edit:i}=e;t&&a(t);const s=!(null==i?void 0:i.path)||E(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])})(re,Me);const _e=t.useCallback(((e,t)=>{!1!==P&&("function"!=typeof P?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)=>P(t(e),t(n)))))}),[P]),Fe=je(J,fe),Le={mainContainerRef:ye,name:a,nodeData:fe,onEdit:(e,t)=>r(void 0,void 0,void 0,(function*(){const{currentData:n,newData:r,currentValue:o,newValue:a}=Oe(me,t,e,"update");if(o!==a)return yield be(s,{currentData:n,newData:r,currentValue:o,newValue:a,name:t.slice(-1)[0],path:t})})),onDelete:(e,t)=>r(void 0,void 0,void 0,(function*(){const{currentData:n,newData:r,currentValue:o,newValue:a}=Oe(me,t,e,"delete");return yield be(l,{currentData:n,newData:r,currentValue:o,newValue:a,name:t.slice(-1)[0],path:t})})),onAdd:(e,t,n)=>r(void 0,void 0,void 0,(function*(){const{currentData:r,newData:o,currentValue:a,newValue:i}=Oe(me,t,e,"add",n);return yield be(c,{currentData:r,newData:o,currentValue:a,newValue:i,name:t.slice(-1)[0],path:t})})),onChange:d,onError:u,onEditEvent:p,showErrorMessages:m,onMove:(e,t,n)=>r(void 0,void 0,void 0,(function*(){if(null===e)return;const{currentData:r,newData:o,currentValue:a}=Oe(me,e,"","delete"),i=e.slice(-1)[0],l=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:m}=Oe(o,[...l,d],a,"add",u);return yield be(s,{currentData:r,newData:p,currentValue:a,newValue:m,name:t.slice(-1)[0],path:t})})),showCollectionCount:j,collapseFilter:ce,collapseAnimationTime:b,restrictEditFilter:Ee,restrictDeleteFilter:De,restrictAddFilter:Ce,restrictTypeSelection:k,restrictDragFilter:ke,canDragOnto:!1,searchFilter:Re,searchText:ue,enableClipboard:g,keySort:P,sort:_e,showArrayIndices:K,arrayIndexFromOne:V,showStringQuotes:M,showIconTooltips:_,indent:h,defaultValue:F,newKeyOptions:L,stringTruncate:Y,translate:de,customNodeDefinitions:J,customNodeData:Fe,customButtons:X,parentData:null,jsonParse:Ve,jsonStringify:Ie,TextEditor:ee,errorMessageTimeout:te,handleKeyboard:Ke,keyboardControls:Pe,insertAtTop:{object:!0===oe||"object"===oe,array:!0===oe||"array"===oe},onCollapse:ae,editConfirmRef:Me,collapseClickZones:ie},ze=Object.assign(Object.assign({},se("container",fe)),{minWidth:z,maxWidth:W});return ze.fontSize=null!=G?G:ze.fontSize,e.jsx("div",{id:H,ref:ye,className:`jer-editor-container ${null!=U?U:""}`,style:ze,children:y(me)&&!Fe.renderCollectionAsValue?e.jsx(ve,Object.assign({data:me},Le)):e.jsx(he,Object.assign({data:me,showLabel:!0},Le))})},Oe=(e,t,n,r,o={})=>{if(0===t.length)return{currentData:e,newData:n,currentValue:e,newValue:n};const i=Object.assign({remove:"delete"===r},o),s="add"!==r?a(e,t):void 0;return{currentData:e,newData:u(e,t,n,i),currentValue:s,newValue:"delete"!==r?n:void 0}},Se=(e,t)=>t?()=>!0:"boolean"==typeof e?()=>e:"number"==typeof e?({level:t})=>t>=e:e,Ne=e=>{if(void 0!==e)return"value"===e?j:"key"===e?v:"all"===e?(e,t)=>j(e,t)||v(e,t):e},Te=e=>Array.isArray(e)&&2===e.length&&["error","value"].includes(e[0]),Ae=(e,t)=>{const n="stringifyReplacer"===t?[e=>void 0===e?A:e]:[];if(n.push(...e.map((e=>e[t])).filter((e=>!!e))),0!==n.length)return(e,t)=>{let r=t;for(const e of n)r=e(r);return r}},Re=t=>{var n;const{value:r,setIsEditing:o,getStyles:a,nodeData:i}=t,s=a("string",i);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(Y,Object.assign({},t,{pathString:E(i.path),styles:s,value:i.value}))})})},Pe={condition:({value:e})=>"string"==typeof e&&/^https?:\/\/.+\..+$/.test(e),element:Re,showOnView:!0,showOnEdit:!1};exports.IconAdd=q,exports.IconCancel=oe,exports.IconChevron=ae,exports.IconCopy=ne,exports.IconDelete=te,exports.IconEdit=ee,exports.IconOk=re,exports.JsonEditor=n=>{var r;const[o,a]=t.useState();return t.useEffect((()=>{const e=document.documentElement;a(e)}),[]),o?e.jsx(K,{theme:null!==(r=n.theme)&&void 0!==r?r:R,icons:n.icons,docRoot:o,children:e.jsx(z,{onEditEvent:n.onEditEvent,onCollapse:n.onCollapse,children:e.jsx(ke,Object.assign({},n))})}):null},exports.LinkCustomComponent=Re,exports.LinkCustomNodeDefinition=Pe,exports.StringDisplay=Y,exports.StringEdit=$,exports.assign=u,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=R,exports.extract=a,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=y,exports.matchNode=j,exports.matchNodeKey=v,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=de,exports.toPathString=E,exports.useKeyboardListener=J;
|
|
1
|
+
"use strict";var e=require("react/jsx-runtime"),t=require("react");function n(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 r(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 o=e=>e.split(/(\.|\[\d+\])/).filter(e=>"."!==e&&""!==e).map(e=>{const t=/\[(\d+)\]/.exec(e);return t?Number(t[1]):e}),a=(e,t,n)=>{const r=Array.isArray(t)?t:o(t);if(0===r.length)return e;const s=r[0];if(Array.isArray(e)&&"number"!=typeof s&&e.length>0)return e.map(e=>a(e,r,n));if("object"!=typeof e||null===e||!(s in e))return i(e,s,n);const l=e[s];return 1===r.length?l:a(l,r.slice(1),n)},i=(e,t,n)=>{if(void 0===n)throw new Error(`Unable to extract object property\nLooking for property: ${t}\nIn object: ${JSON.stringify(e)}`);return n},s=(e,t,n,r,o)=>{if(!r)throw new Error(null!=o?o:`Invalid property path: ${t}\nCouldn't access "${n}" in ${JSON.stringify(e)}`)},l=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),c=e=>Array.isArray(e),d=(e,t)=>e.filter((e,n)=>n!==t),u=(e,t,n,r={})=>{const{remove:a=!1,createNew:i=!0,noError:s=!1}=r,l=e,u="string"==typeof(m=t)?m:"number"==typeof m?String(m):m.reduce((e,t)=>"number"==typeof t?`${e}[${t}]`:""===e?t:`${e}.${t}`,"");var m;const g=Object.assign(Object.assign({},r),{remove:a,createNew:i,noError:s,fullData:l,fullPath:u}),h=Array.isArray(t)?t:o(t);return c(e)&&a&&1===h.length?d(e,h[0]):p(e,h,n,g)},p=(e,t,n,r)=>{const o=l(e)?Object.assign({},e):null,a=c(e)?[...e]:null;if(0===t.length)return e;if(!o&&!a)throw new Error("Can't assign property -- invalid input object");const{createNew:i,remove:u,noError:h,fullData:y,fullPath:f}=r,b=t[0];if(a&&"string"==typeof b)return a.map(e=>p(e,t,n,r));if(1===t.length){if(o&&"string"==typeof b){const e=m(o,b,n,r);return null!=e?e:o}return a&&"number"==typeof b?(g(a,b,n,r),a):(s(y,f,b,h),e)}const j=o||a||[];if(u&&2===t.length&&"number"==typeof t[1]){const e=j[b],n=t[1];return c(e)?j[b]=d(e,n):s(y,f,b,h,"Trying to remove an indexed item from an object that is not an array"),j}const v=t.slice(1);if(b in e){if(E=j[b],!c(E)&&!l(E)){if(!i)return s(y,f,b,h),j;j[b]={}}return j[b]=p(j[b],v,n,r),j}var E;if(i){const e="number"==typeof v[0]?[]:{};if(o)return j[b]=e,j[b]=p(j[b],v,n,r),j;if(a&&Array.isArray(j)){j.push(e);const t=j.length-1;return j[t]=p(j[t],v,n,r),j}}return s(y,f,b,h),j},m=(e,t,n,r)=>{const{remove:o,createNew:a,noError:i,insertAfter:l,insertBefore:c,fullData:d,fullPath:u}=r;if(void 0!==c||void 0!==l){const r=Object.entries(e);let o=1/0;return o="number"==typeof c?c:"number"==typeof l?l:r.findIndex(([e])=>e===(null!=c?c:l)),void 0!==l&&o++,r.splice(o,0,[t,n]),Object.fromEntries(r)}const p=t in e;o?p?delete e[t]:s(d,u,t,i):a||p?e[t]=n:s(d,u,t,i)},g=(e,t,n,r)=>{const{noError:o,fullData:a,fullPath:i,createNew:l,insert:c}=r;c&&e.splice(t,0,n),t in e?e[t]=n:l?e.push(n):s(a,i,t,o)},h=({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})]})},y=e=>null!==e&&"object"==typeof e,f=(e,t,n,r="")=>{if(!n&&!r)return!0;switch(e){case"collection":if(n){if(n(t,r))return!0;if(!b(r,t,n))return!1}if(!n&&r&&!b(r,t))return!1;break;case"value":if(n&&!n(t,r))return!1;if(!n&&r&&!j(t,r))return!1}return!0},b=(e="",t,n=j)=>{const r=t.value;return Object.entries(r).some(([o,a])=>{const i=[...t.path,o],s=Object.assign(Object.assign({},t),{key:o,path:i,level:t.level+1,value:a,size:i.length,parentData:r});return y(a)?b(e,s,n):n(s,e)})},j=(e,t="")=>{const{value:n}=e;if(null===n&&"null".includes(t.toLowerCase()))return!0;switch(typeof n){case"string":return n.toLowerCase().includes(t.toLowerCase());case"number":return!!String(n).includes(t);case"boolean":return n?"true".includes(t.toLowerCase())||"1"===t:"false".includes(t.toLowerCase())||"0"===t;default:return!1}},v=({key:e,path:t},n="")=>!!j({value:e},n)||!!t.some(e=>j({value:e},n)),E=(e,t)=>(null!=t?t:"")+e.map(e=>""===e?String.fromCharCode(0):e).join("."),x=e=>e.shiftKey?"Shift":e.metaKey?"Meta":e.ctrlKey?"Control":e.altKey?"Alt":void 0,D=(e,t,n)=>{const r=e.key,o=x(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)))},C={key:"Enter"},w={confirm:C,cancel:{key:"Escape"},objectConfirm:Object.assign(Object.assign({},C),{modifier:["Meta","Shift","Control"]}),objectLineBreak:C,stringConfirm:C,stringLineBreak:Object.assign(Object.assign({},C),{modifier:["Shift"]}),numberConfirm:C,numberUp:{key:"ArrowUp"},numberDown:{key:"ArrowDown"},tabForward:{key:"Tab"},tabBack:{key:"Tab",modifier:"Shift"},booleanConfirm:C,booleanToggle:{key:" "},clipboardModifier:["Meta","Control"],collapseModifier:["Alt"]},k=(e,t,n="next",r)=>{const o=t.slice(0,t.length-1),i=t.slice(-1)[0];if(void 0===i)return null;const s=a(e,o),l=S(s);Array.isArray(s)||r(l,({key:e,value:t})=>[e,t]);const c=l.findIndex(e=>e.key===i),d=l[c+("next"===n?1:-1)];return d?y(d.value)?0===Object.keys(d.value).length?k(e,[...o,d.key],n,r):O(e,[...o,d.key],n,r):[...o,d.key]:0===o.length?null:k(e,o,n,r)},O=(e,t,n="next",r)=>{const o=a(e,t);if(!y(o))return t;const i=Array.isArray(o)?o.map((e,t)=>t):Object.keys(o);r(i,e=>[e,o]);const s="next"===n?i[0]:i[i.length-1];return O(e,[...t,s],n,r)},S=e=>Array.isArray(e)?e.map((e,t)=>({index:t,value:e,key:t})):Object.entries(e).map(([e,t],n)=>({key:e,value:t,index:n})),N=(e,t)=>{var n,r,o,a;const i=e.current,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},T=e=>{if(e!==A){if(Array.isArray(e))return e.map(e=>T(e));if(e&&"object"==typeof e)for(const t in e)e[t]=T(e[t]);return e}},A="__undefined__",R={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)"}},P=t.createContext({getStyles:()=>({}),icons:{}}),K=({theme:t=R,icons:n={},docRoot:r,children:o})=>{const a=V(t,r);return e.jsx(P.Provider,{value:{getStyles:(e,t)=>"function"==typeof a[e]?a[e](t):a[e],icons:n},children:o})},I=()=>t.useContext(P),V=(e,t)=>{var n,r,o,a;const i={},s=(Array.isArray(e)?e:[e]).map(e=>_(e)?M({fragments:{},styles:e},i):M(e,i)),l=M(R,{});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},M=(e,t)=>{const{fragments:n,styles:r}=e,o={};return Object.entries(r).forEach(([e,r])=>{const a=(Array.isArray(r)?r:[r]).reduce((r,o)=>{var a,i;if("function"==typeof o)return t[e]=o,Object.assign({},r);if("string"==typeof o){const t=null!==(a=null==n?void 0:n[o])&&void 0!==a?a:o;return"string"==typeof t?Object.assign(Object.assign({},r),{[null!==(i=F[e])&&void 0!==i?i:"color"]:t}):Object.assign(Object.assign({},r),t)}return Object.assign(Object.assign({},r),o)},{});o[e]=a}),o},_=e=>!("styles"in e),F={container:"backgroundColor",collection:"backgroundColor",collectionInner:"backgroundColor",collectionElement:"backgroundColor",dropZone:"borderColor",inputHighlight:"backgroundColor"},L=t.createContext(null),z=({children:n,onEditEvent:r,onCollapse:o})=>{const[a,i]=t.useState(null),[s,l]=t.useState(null),[c,d]=t.useState(null),[u,p]=t.useState({path:null,pathString:null}),m=t.useRef(null),g=t.useRef("next"),h=t.useRef(null);return e.jsx(L.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(W(e,t))return t;return null}return W(e,a)?a:null},currentlyEditingElement:s,setCurrentlyEditingElement:(e,t)=>{const n="string"==typeof e||null===e?e:E(e,"key"===t?"key_":void 0);null!==s&&null!==n&&null!==m.current&&m.current(),l(n),r&&(Array.isArray(e)||null===e)&&r(e,"key"===t),m.current="function"==typeof t?t:null},areChildrenBeingEdited:e=>null!==s&&s.includes(e),previouslyEditedElement:h.current,setPreviouslyEditedElement:e=>{h.current=e},tabDirection:g.current,setTabDirection:e=>{g.current=e},previousValue:c,setPreviousValue:d,dragSource:u,setDragSource:p},children:n})},B=()=>{const e=t.useContext(L);if(!e)throw new Error("Missing Context Provider");return e},W=(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},G="**INVALID_FUNCTION**",Y=({nodeData:n,showStringQuotes:r=!0,stringTruncate:o=200,pathString:a,canEdit:i,setIsEditing:s,styles:l,translate:c,value:d,TextWrapper:u=({children:e})=>e})=>{const p=null!=d?d:n.value,[m,g]=t.useState(!1),h=r?'"':"",y=p.length>o,f=()=>{i?s(!0):g(!m)};return e.jsxs("div",{id:`${a}_display`,onDoubleClick:f,onClick:e=>{(e.getModifierState("Control")||e.getModifierState("Meta"))&&f()},className:"jer-value-string",style:l,children:[h,y?m?e.jsxs(e.Fragment,{children:[e.jsx(u,{children:e.jsxs("span",{children:[p,h]})}),e.jsxs("span",{className:"jer-string-expansion jer-show-less",onClick:()=>g(!1),children:[" ",c("SHOW_LESS",n)]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(u,{children:[e.jsx("span",{children:p.slice(0,o-2).trimEnd()})," "]}),e.jsx("span",{className:"jer-string-expansion jer-ellipsis",onClick:()=>g(!0),children:"..."}),h]}):e.jsx(u,{children:`${p}${h}`})]})},$=({styles:n,pathString:r,value:o,setValue:a,handleEdit:i,handleKeyboard:s,keyboardCommon:l})=>{const c=t.useRef(null);return e.jsx(h,{className:"jer-input-text",textAreaRef:c,name:r,value:o,setValue:a,handleKeyPress:e=>{s(e,Object.assign({stringConfirm:i,stringLineBreak:()=>{const e=N(c,"\n");a(e)}},l))},styles:n})},U=t=>{var{isEditing:r,path:o,enumType:a}=t,i=n(t,["isEditing","path","enumType"]);const{getStyles:s}=I(),l=E(o),{value:c,setValue:d,nodeData:u,handleEdit:p,handleKeyboard:m,keyboardCommon:g}=i;return r&&a?e.jsxs("div",{className:"jer-select jer-select-enums",children:[e.jsx("select",{name:`${l}-value-select`,className:"jer-select-inner",onChange:e=>d(e.target.value),value:c,autoFocus:!0,onKeyDown:e=>{m(e,Object.assign({stringConfirm:p},g))},children:a.values.map(t=>e.jsx("option",{value:t,children:t},t))}),e.jsx("span",{className:"focus"})]}):r?e.jsx($,Object.assign({styles:s("input",u),pathString:l},i,{setValue:i.setValue})):e.jsx(Y,Object.assign({pathString:l,styles:s("string",u)},i))},H=({value:t,setValue:n,isEditing:r,path:o,setIsEditing:a,handleEdit:i,nodeData:s,handleKeyboard:l,keyboardCommon:c})=>{const{getStyles:d}=I();return r?e.jsx("input",{className:"jer-input-number",type:"text",name:E(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}=I();return"boolean"!=typeof t?null:r?e.jsx("input",{className:"jer-input-boolean",type:"checkbox",name:E(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)})},J=(e,n)=>{const r=t.useRef(void 0),o=t.useRef(n);t.useEffect(()=>{o.current=n},[n]);const a=e=>{o.current(e)};t.useEffect(()=>{if(window.clearTimeout(r.current),e)return r.current=window.setTimeout(()=>{window.addEventListener("keydown",a)},100),()=>{window.clearTimeout(r.current),window.removeEventListener("keydown",a)}},[e])},X=({value:t,isEditing:n,setIsEditing:r,handleEdit:o,nodeData:a,handleKeyboard:i,keyboardCommon:s})=>{const{getStyles:l}=I();return J(n,e=>i(e,Object.assign({confirm:o},s))),e.jsx("div",{onDoubleClick:()=>r(!0),className:"jer-value-null",style:l("null",a),children:String(t)})},Q=({value:t})=>{let n="Error!";switch(typeof t){case"string":t===G&&(n="Function");break;case"undefined":n="Undefined";break;case"symbol":n="Symbol"}return e.jsx("span",{className:"jer-value-invalid",children:n})},q=({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"})]}),ee=({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"})]}),te=({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"})}),ne=({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"})]}),re=({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"})]}),oe=({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"})}),ae=({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"})}),ie=({name:t,nodeData:n})=>{var r,o,a,i,s,l,c;const{getStyles:d,icons:u}=I(),p={size:"1.4em",className:"jer-icon"};switch(t){case"add":return null!==(r=null==u?void 0:u.add)&&void 0!==r?r:e.jsx(q,Object.assign({},p,{style:d("iconAdd",n)}));case"edit":return null!==(o=null==u?void 0:u.edit)&&void 0!==o?o:e.jsx(ee,Object.assign({},p,{style:d("iconEdit",n)}));case"delete":return null!==(a=null==u?void 0:u.delete)&&void 0!==a?a:e.jsx(te,Object.assign({},p,{style:d("iconDelete",n),size:"1.45em"}));case"copy":return null!==(i=null==u?void 0:u.copy)&&void 0!==i?i:e.jsx(ne,Object.assign({},p,{style:d("iconCopy",n),size:"1.2em"}));case"ok":return null!==(s=null==u?void 0:u.ok)&&void 0!==s?s:e.jsx(re,Object.assign({},p,{style:Object.assign({fontSize:"90%"},d("iconOk",n))}));case"cancel":return null!==(l=null==u?void 0:u.cancel)&&void 0!==l?l:e.jsx(oe,Object.assign({},p,{style:Object.assign({fontSize:"130%"},d("iconCancel",n))}));case"chevron":return null!==(c=null==u?void 0:u.chevron)&&void 0!==c?c:e.jsx(ae,{size:"1em",style:d("iconCollection",n)});default:return e.jsx(e.Fragment,{})}},se=({startEdit:n,handleDelete:r,handleAdd:o,enableClipboard:i,type:s,customButtons:l,nodeData:c,translate:d,keyboardControls:u,handleKeyboard:p,editConfirmRef:m,getNewKeyOptions:g,jsonStringify:h,onEditEvent:y,showIconTooltips:f})=>{const{getStyles:b}=I(),j=d("KEY_NEW",c),[v,E]=t.useState(j),[D,C]=t.useState(!1),{key:w,path:k,value:O}=c,S=Array.isArray(D),N=e=>{var t;if(y&&y(e?[...k,null]:null,e),!e)return void C(!1);const n=Object.keys(a(c.fullData,k)),r=g?null===(t=g(c))||void 0===t?void 0:t.filter(e=>!n.includes(e)):null;r&&E(""),C(null==r||r)};return e.jsxs("div",{className:"jer-edit-buttons",style:{opacity:D?1:void 0},onClick:e=>e.stopPropagation(),children:[i&&e.jsx("div",{onClick:e=>{var t;e.stopPropagation();let n,r,o="value",a="",s=null;if(i){const l=x(e);if(l&&u.clipboardModifier.includes(l)?(n=ce(k),a=n,o="path"):(n=O,a="object"==typeof n?h(O):String(n)),!navigator.clipboard)return void("function"==typeof i&&i({success:!1,value:n,stringValue:a,path:k,key:w,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,s=e.message}).finally(()=>{"function"==typeof i&&i({success:r,errorMessage:s,value:n,stringValue:a,path:k,key:w,type:o})})}},className:"jer-copy-pulse",title:f?d("TOOLTIP_COPY",c):"",children:e.jsx(ie,{name:"copy",nodeData:c})}),n&&e.jsx("div",{onClick:n,title:f?d("TOOLTIP_EDIT",c):"",children:e.jsx(ie,{name:"edit",nodeData:c})}),r&&e.jsx("div",{onClick:r,title:f?d("TOOLTIP_DELETE",c):"",children:e.jsx(ie,{name:"delete",nodeData:c})}),o&&e.jsx("div",{onClick:()=>{"object"===s?N(!0):o("")},title:f?d("TOOLTIP_ADD",c):"",children:e.jsx(ie,{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)),D&&o&&"object"===s&&e.jsxs(e.Fragment,{children:[S?e.jsxs("div",{className:"jer-select jer-select-keys",children:[e.jsxs("select",{name:"new-key-select",className:"jer-select-inner",onChange:e=>{o(e.target.value),N(!1)},defaultValue:"",autoFocus:!0,onKeyDown:e=>{p(e,{cancel:()=>N(!1)})},children:[e.jsx("option",{value:"",disabled:!0,children:D.length>0?d("KEY_SELECT",c):d("NO_KEY_OPTIONS",c)}),D.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:v,onChange:e=>E(e.target.value),autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>{p(e,{stringConfirm:()=>{o&&(N(!1),o(v),E(j))},cancel:()=>{N(!1),E(j)}})},style:b("input",c)}),e.jsx(le,{onOk:()=>{S&&!v||(N(!1),o(v))},onCancel:()=>{N(!1)},nodeData:c,editConfirmRef:m,hideOk:S})]})]})},le=({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(ie,{name:"ok",nodeData:r})}),e.jsx("div",{onClick:n,children:e.jsx(ie,{name:"cancel",nodeData:r})})]}),ce=e=>e.reduce((e,t)=>"number"==typeof t?`${e}[${t}]`:""===e?t:`${e}.${t}`,""),de=["string","number","boolean","null","object","array"],ue=({props:e,collapsed:n})=>{const{data:r,nodeData:o,parentData:a,onEdit:i,onError:s,showErrorMessages:l,restrictEditFilter:c,restrictDeleteFilter:d,restrictAddFilter:u,restrictDragFilter:p,translate:m,errorMessageTimeout:g}=e,{currentlyEditingElement:h,setCurrentlyEditingElement:y}=B(),[f,b]=t.useState(null),j=Object.assign(Object.assign({},o),{collapsed:n}),{path:v,key:x,size:D}=j,C=E(v),w=!c(j),k=!d(j),O=!u(j),S=!p(j)&&k&&null===h,N=e=>{l&&(b(e),setTimeout(()=>b(null),g)),console.warn("Error",e)},T=t.useCallback((e,t)=>{N(e.message),s&&s({currentData:j.fullData,errorValue:t,currentValue:r,name:x,path:v,error:e})},[s,l]),A=h===C,R=h===`key_${C}`,P="number"==typeof v.slice(-1)[0],K={isEditing:A,isEditingKey:R,isArray:P,canEditKey:null!==a&&w&&O&&k&&!P},I=""===x&&v.length>0?m("EMPTY_STRING",j):null;return{pathString:C,nodeData:j,path:v,name:x,size:D,canEdit:w,canDelete:k,canAdd:O,canDrag:S,error:f,showError:N,onError:T,setError:b,handleEditKey:e=>{if(y(null),x===e)return;if(!a)return;const t=v.slice(0,-1);if(Object.keys(a).includes(e))return void T({code:"KEY_EXISTS",message:m("ERROR_KEY_EXISTS",j)},e);const n=Object.fromEntries(Object.entries(a).map(([t,n])=>t===x?[e,n]:[t,n]));i(n,t).then(t=>{t&&T({code:"UPDATE_ERROR",message:t},e)})},derivedValues:K,emptyStringKey:I}},pe=({canDrag:n,canDragOnto:r,path:o,nodeData:a,onMove:i,onError:s,translate:l})=>{const{getStyles:c}=I(),{dragSource:d,setDragSource:u}=B(),[p,m]=t.useState(!1),g=E(o),h=t.useMemo(()=>n?{onDragStart:e=>{e.stopPropagation(),u({path:o,pathString:g})},onDragEnd:e=>{e.stopPropagation(),u({path:null,pathString:null})}}:{},[n,g]),y=t.useMemo(()=>e=>r?{onDragOver:e=>{e.stopPropagation(),e.preventDefault()},onDrop:t=>{t.stopPropagation(),b(e),u({path:null,pathString:null}),m(!1)},onDragEnter:t=>{var n;t.stopPropagation(),g.startsWith(null!==(n=d.pathString)&&void 0!==n?n:"")||m(e)},onDragExit:e=>{e.stopPropagation(),m(!1)}}:{},[d,r,g]),f=t.useMemo(()=>r&&null!==d.pathString?e.jsx("div",Object.assign({className:"jer-drop-target-bottom",style:{height:"50%",position:"absolute",width:"100%",top:"50%",zIndex:o.length}},y("below"))):null,[d,r,o.length]),b=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:h,getDropTargetProps:y,BottomDropTarget:f,DropTargetPadding:({position:t,nodeData:n})=>p===t?e.jsx("div",{className:"jer-drag-n-drop-padding",style:c("dropZone",n)}):null,handleDrop:b}},me=(e,t,n,r)=>{var o,a,i;if(!t.current)return 0;const s=parseInt(null!==(o=getComputedStyle(n.current).getPropertyValue("line-height"))&&void 0!==o?o:"16px"),l=(null!==(i=null===(a=t.current)||void 0===a?void 0:a.offsetWidth)&&void 0!==i?i:0)/(.5*s),c=r(e).replace(/\\n/g,"\n").split("\n").map(e=>Math.ceil(e.length/l)).reduce((e,t)=>e+t,0)*s;return Math.min(c+30,window.innerHeight-50)},ge=({isEditingKey:t,canEditKey:n,pathString:r,path:o,name:a,arrayIndexFromOne:i,handleKeyboard:s,handleEditKey:l,handleCancel:c,handleClick:d,keyValueArray:u,styles:p,getNextOrPrevious:m,emptyStringKey:g,nodeData:h,customNodeData:y,getStyles:f})=>{const{setCurrentlyEditingElement:b}=B(),j="number"==typeof a?String(a+(i?1:0)):a;if(!t){const t=Object.assign(Object.assign({},p),{minWidth:`${Math.min(j.length+1,5)}ch`,flexShrink:j.length>10?1:0});if((null==y?void 0:y.CustomKey)&&h&&f){const{CustomKey:r,customNodeProps:a}=y;return e.jsx(r,{nodeData:h,name:null!=g?g:j,path:o,canEditKey:n,handleEditKey:e=>{n&&l(e)},setIsEditingKey:()=>{n&&b(o,"key")},handleClick:d,styles:t,customNodeProps:a,getStyles:f})}return e.jsxs("span",{className:"jer-key-text",style:t,onDoubleClick:()=>n&&b(o,"key"),onClick:d,children:[g?e.jsx("span",{className:"jer-empty-string",children:g}):j,""!==j||g?e.jsx("span",{className:"jer-key-colon",children:":"}):null]})}return e.jsx("input",{className:"jer-input-text jer-key-edit",type:"text",name:r,defaultValue:j,autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>s(e,{stringConfirm:()=>l(e.target.value),cancel:c,tabForward:()=>{if(l(e.target.value),u){const e=null==u?void 0:u[0][0];b(e?[...o,e]:m("next"))}else b(o)},tabBack:()=>{l(e.target.value),b(m("prev"))}}),style:{width:j.length/1.5+.5+"em"}})},he=n=>{const{data:r,parentData:o,onEdit:a,onDelete:i,onChange:s,onMove:l,enableClipboard:c,canDragOnto:d,restrictTypeSelection:u,searchFilter:p,searchText:m,showLabel:g,stringTruncate:h,showStringQuotes:y,arrayIndexFromOne:b,indent:j,translate:v,customNodeDefinitions:E,customNodeData:x,handleKeyboard:D,keyboardControls:C,sort:w,editConfirmRef:O,jsonStringify:S,showIconTooltips:N}=n,{getStyles:T}=I(),{setCurrentlyEditingElement:A,setCollapseState:R,previouslyEditedElement:P,setPreviouslyEditedElement:K,tabDirection:V,setTabDirection:M,previousValue:_,setPreviousValue:F}=B(),[L,z]=t.useState("function"==typeof r?G:r),{pathString:W,nodeData:Y,path:$,name:U,canEdit:H,canDelete:Z,canDrag:J,error:X,onError:Q,handleEditKey:q,emptyStringKey:ee,derivedValues:te}=ue({props:n}),{dragSourceProps:ne,getDropTargetProps:re,BottomDropTarget:oe,DropTargetPadding:ae}=pe({canDrag:J,canDragOnto:d,path:$,nodeData:Y,onMove:l,onError:Q,translate:v}),[ie,ce]=t.useState(ye(r,x)),me=t.useCallback(e=>{if(!s)return void z(e);const t=s({currentData:Y.fullData,newValue:e,currentValue:L,name:U,path:$});z(t)},[s]);t.useEffect(()=>{z("function"==typeof r?G:r),ce(ye(r,x))},[r,X]);const{CustomNode:he,customNodeProps:je,hideKey:ve,showEditTools:Ee=!0,showOnEdit:xe,showOnView:De,passOriginalNode:Ce}=x,we=[...de,...E.filter(({showInTypesSelector:e=!1,name:t})=>e&&!!t).map(({name:e})=>e)],ke=t.useMemo(()=>{if("boolean"==typeof u)return u?[]:we;if(Array.isArray(u))return u;const e=u(Y);return"boolean"==typeof e?e?[]:we:e},[Y,u]),[Oe,Se]=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})(L,ke)),{isEditing:Ne}=te,Te=f("value",Y,p,m);if(Ne&&(!Te||!H)){const e=k(Y.fullData,$,V,w);A(e||P)}if(!Te)return null;const Ae=e=>{let t;if(A(null),F(null),void 0===e||(e=>e&&"object"==typeof e&&"type"in e&&"target"in e&&"preventDefault"in e&&"function"==typeof e.preventDefault)(e))switch(ie){case"object":t={[v("DEFAULT_NEW_KEY",Y)]:L};break;case"array":t=null!=L?L:[];break;case"number":{const e=Number(L);t=isNaN(e)?0:e;break}default:t=L}else t=e;a(t,$).then(e=>{e&&Q({code:"UPDATE_ERROR",message:e},t)})},Re=()=>{A(null),null===_?(z(r),F(null)):a(_,$)},{isEditingKey:Pe,canEditKey:Ke}=te,Ie=!Ne&&X,Ve=Ne&&ke.length>1,Me=("invalid"!==ie||he)&&!X&&Ee,_e=g&&!ve,Fe=he&&(Ne&&xe||!Ne&&De),Le={value:L,parentData:o,setValue:me,isEditing:Ne,canEdit:H,setIsEditing:H?()=>A($):()=>{},handleEdit:Ae,handleCancel:Re,path:$,stringTruncate:h,showStringQuotes:y,nodeData:Y,enumType:Oe,translate:v,handleKeyboard:D,keyboardCommon:{cancel:Re,tabForward:()=>{M("next"),K(W);const e=k(Y.fullData,$,"next",w);e&&(Ae(),A(e))},tabBack:()=>{M("prev"),K(W);const e=k(Y.fullData,$,"prev",w);e&&(Ae(),A(e))}}},ze={canEditKey:Ke,isEditingKey:Pe,pathString:W,path:$,name:U,arrayIndexFromOne:b,handleKeyboard:D,handleEditKey:q,handleCancel:Re,styles:T("property",Y),getNextOrPrevious:e=>k(Y.fullData,$,e,w),emptyStringKey:ee,nodeData:Y,customNodeData:x,getStyles:T},Be=Fe?e.jsx(he,Object.assign({},n,{value:L,customNodeProps:je,setValue:me,handleEdit:Ae,handleCancel:Re,handleKeyPress:e=>D(e,{stringConfirm:Ae,cancel:Re}),isEditing:Ne,setIsEditing:()=>A($),getStyles:T,originalNode:Ce?fe(r,Le):void 0,originalNodeKey:Ce?e.jsx(ge,Object.assign({},ze,{customNodeData:void 0})):void 0,canEdit:H,keyboardCommon:Le.keyboardCommon,onError:Q})):fe(r,Le);return e.jsxs("div",Object.assign({className:"jer-component jer-value-component",style:{marginLeft:null!==o?j/2+"em":0,position:"relative"},draggable:J},ne,re("above"),{children:[oe,e.jsx(ae,{position:"above",nodeData:Y}),e.jsxs("div",{className:"jer-value-main-row",style:{flexWrap:U.length>10?"wrap":"nowrap"},children:[_e&&e.jsx(ge,Object.assign({},ze)),e.jsxs("div",{className:"jer-value-and-buttons",children:[e.jsx("div",{className:"jer-input-component",children:Be}),Ne?e.jsx(le,{onOk:Ae,onCancel:Re,nodeData:Y,editConfirmRef:O}):Me&&e.jsx(se,{startEdit:H?()=>{F(_),A($,Re)}:void 0,handleDelete:Z?()=>{i(L,$).then(e=>{e&&Q({code:"DELETE_ERROR",message:e},L)})}:void 0,enableClipboard:c,translate:v,customButtons:n.customButtons,nodeData:Y,handleKeyboard:D,keyboardControls:C,editConfirmRef:O,jsonStringify:S,showIconTooltips:N}),Ve&&e.jsxs("div",{className:"jer-select jer-select-types",children:[e.jsx("select",{name:`${U}-type-select`,className:"jer-select-inner",onChange:e=>(e=>{const t=E.find(t=>t.name===e);if(t)return a(t.defaultValue,$),ce(e),Se(null),A(null),void R({path:$,collapsed:!1,includeChildren:!1});const n=ke.find(t=>t instanceof Object&&t.enum===e);if(n)return"string"==typeof L&&n.values.includes(L)||a(n.values[0],$).then(e=>{e&&(Q({code:"UPDATE_ERROR",message:e},r),A(null))}),void Se(n);const r=be(L,e,v("DEFAULT_NEW_KEY",Y),(null==x?void 0:x.CustomNode)?v("DEFAULT_STRING",Y):void 0);["string","number","boolean"].includes(e)||A(null),a(r,$).then(e=>{e?(Q({code:"UPDATE_ERROR",message:e},r),A(null)):Se(null)})})(e.target.value),value:Oe?Oe.enum:ie,children:ke.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"})]}),Ie&&e.jsx("span",{className:"jer-error-slug",style:T("error",Y),children:X})]})]}),e.jsx(ae,{position:"below",nodeData:Y})]}))},ye=(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",fe=(t,n)=>{const r=ye(t),{value:o}=n;switch(r){case"string":return e.jsx(U,Object.assign({},n,{value:o}));case"number":return e.jsx(H,Object.assign({},n,{value:o}));case"boolean":return e.jsx(Z,Object.assign({},n,{value:o}));case"null":return e.jsx(X,Object.assign({},n));default:return e.jsx(Q,Object.assign({},n))}},be=(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)}},je=(e=[],t)=>{const r=e.filter(({condition:e})=>e(t));if(0===r.length)return{};const o=r[0],{element:a,wrapperElement:i,customKey:s,customNodeProps:l,wrapperProps:c,hideKey:d=!1,showEditTools:u=!0,showOnEdit:p=!1,showOnView:m=!0,showCollectionWrapper:g=!0}=o,h=n(o,["element","wrapperElement","customKey","customNodeProps","wrapperProps","hideKey","showEditTools","showOnEdit","showOnView","showCollectionWrapper"]);return Object.assign({CustomNode:a,CustomWrapper:i,CustomKey:s,customNodeProps:l,wrapperProps:c,hideKey:d,showEditTools:u,showOnEdit:p,showOnView:m,showCollectionWrapper:g},h)},ve=n=>{const{getStyles:o}=I(),{collapseState:a,setCollapseState:i,getMatchingCollapseState:s,currentlyEditingElement:l,setCurrentlyEditingElement:c,areChildrenBeingEdited:d,previousValue:u,setPreviousValue:p}=B(),{mainContainerRef:m,data:g,nodeData:b,parentData:j,showCollectionCount:v,onEdit:E,onAdd:D,onDelete:C,canDragOnto:w,collapseFilter:O,collapseAnimationTime:S,onMove:T,enableClipboard:A,onEditEvent:R,showIconTooltips:P,searchFilter:K,searchText:V,indent:M,sort:_,showArrayIndices:F,arrayIndexFromOne:L,defaultValue:z,newKeyOptions:W,translate:G,customNodeDefinitions:Y,customNodeData:$,jsonParse:U,jsonStringify:H,TextEditor:Z,keyboardControls:J,handleKeyboard:X,insertAtTop:Q,onCollapse:q,editConfirmRef:ee,collapseClickZones:te}=n,[ne,re]=t.useState(H(g)),oe=O(b),{contentRef:ae,isAnimating:ce,maxHeight:de,collapsed:ye,animateCollapse:fe,cssTransitionValue:be}=((e,n,r,o,a)=>{const[i,s]=t.useState(r?0:void 0),[l,c]=t.useState(r),d=t.useRef(!1),u=t.useRef(null),p=t.useRef(0),m=t.useRef(0),g=n/1e3+"s",h=t.useCallback(t=>{var r,i;if(l!==t){switch(window.clearTimeout(m.current),d.current=!0,t){case!0:{const e=null!==(i=null===(r=u.current)||void 0===r?void 0:r.offsetHeight)&&void 0!==i?i:0;p.current=e,s(e),setTimeout(()=>{s(0)},5);break}case!1:s(p.current||me(e,u,o,a))}c(!l),m.current=window.setTimeout(()=>{d.current=!1,t||s(void 0)},n)}},[n,l,e,o,a]);return{contentRef:u,isAnimating:d.current,animateCollapse:h,maxHeight:i,collapsed:l,cssTransitionValue:g}})(g,S,oe,m,H),{pathString:Ee,nodeData:xe,path:De,name:Ce,size:we,canEdit:ke,canDelete:Oe,canAdd:Se,canDrag:Ne,error:Te,setError:Ae,onError:Re,handleEditKey:Pe,emptyStringKey:Ke,derivedValues:Ie}=ue({props:n,collapsed:ye}),{dragSourceProps:Ve,getDropTargetProps:Me,BottomDropTarget:_e,DropTargetPadding:Fe}=pe({canDrag:Ne,canDragOnto:w,path:De,nodeData:xe,onMove:T,onError:Re,translate:G}),Le=t.useRef(!oe),{isEditing:ze,isEditingKey:Be,isArray:We,canEditKey:Ge}=Ie;t.useEffect(()=>{re(H(g))},[g]),t.useEffect(()=>{const e=O(xe)&&!ze;Le.current=!e,fe(e)},[O]),t.useEffect(()=>{if(null!==a){const e=s(De);e&&(Le.current=!0,fe(e.collapsed))}},[a]);const Ye=t.useRef(null),$e=t.useCallback((e,t)=>{if("function"!=typeof z)return z;const n=z(e,t);return void 0!==n?n:null},[z]),Ue=t.useCallback(e=>W?"function"!=typeof W?W:W(e):null,[W]),{CustomNode:He,customNodeProps:Ze,CustomWrapper:Je,wrapperProps:Xe={},hideKey:Qe,showEditTools:qe=!0,showOnEdit:et,showOnView:tt,showCollectionWrapper:nt=!0}=$,rt=d(Ee);rt&&ye&&fe(!1);if(!(f("collection",xe,K,V)||0===xe.level)&&!rt)return null;const ot=Array.isArray(g)?"array":"object",at="array"===ot?{open:"[",close:"]"}:{open:"{",close:"}"},it=e=>{if("Tab"===e.key&&!e.getModifierState("Shift")){e.preventDefault();const t=N(Ye,"\t");return void re(t)}X(e,{objectConfirm:lt,cancel:dt})},st=e=>{e.stopPropagation();const t=x(e);if(t&&J.collapseModifier.includes(t))return Le.current=!0,void i({collapsed:!ye,path:De,includeChildren:!0});l&&l.includes(Ee)||(Le.current=!0,i(null),q&&q({path:De,collapsed:!ye,includeChildren:!1}),fe(!ye))},lt=()=>{try{const e=U(ne);if(c(null),p(null),Ae(null),H(e)===H(g))return;E(e,De).then(t=>{t&&Re({code:"UPDATE_ERROR",message:t},e)})}catch(e){Re({code:"INVALID_JSON",message:G("ERROR_INVALID_JSON",xe)},ne)}},ct=De.length>0?()=>{C(g,De).then(e=>{e&&Re({code:"DELETE_ERROR",message:e},g)})}:void 0,dt=()=>{c(null),null===u?(Ae(null),re(H(g)),p(null)):E(u,De)},ut="when-closed"===v?ye:v,pt=!ze&&qe,mt=(F||!We)&&!Qe&&void 0!==Ce,gt=He&&(ze&&et||!ze&&tt),ht=Object.entries(g).map(([e,t])=>["array"===ot?Number(e):e,t]);"object"===ot&&_(ht,e=>e);const yt=Le.current?ze?e.jsxs("div",{className:"jer-collection-text-edit",children:[Z?e.jsx(Z,{value:ne,onChange:re,onKeyDown:e=>X(e,{objectConfirm:lt,cancel:dt})}):e.jsx(h,{textAreaRef:Ye,className:"jer-collection-text-area",name:Ee,value:ne,setValue:re,handleKeyPress:it,styles:o("input",xe)}),e.jsx("div",{className:"jer-collection-input-button-row",children:e.jsx(le,{onOk:lt,onCancel:dt,nodeData:xe,editConfirmRef:ee})})]}):ht.map(([t,r],a)=>{const i={key:t,value:r,path:[...De,t],level:De.length+1,index:a,size:y(r)?Object.keys(r).length:null,parentData:g,fullData:xe.fullData},s=je(Y,i);return e.jsx("div",{className:"jer-collection-element",style:o("collectionElement",i),children:y(r)&&!(null==s?void 0:s.renderCollectionAsValue)?e.jsx(ve,Object.assign({},n,{data:r,parentData:g,nodeData:i,showCollectionCount:v,canDragOnto:ke,customNodeData:s}),t):e.jsx(he,Object.assign({},n,{data:r,parentData:g,nodeData:i,canDragOnto:ke,showLabel:"object"===ot||F,customNodeData:s}),t)},t)}):null,ft=!!nt&&(ye&&!rt);ft||(Le.current=!0);const bt=Object.assign(Object.assign({},n),{data:g,value:g,parentData:j,nodeData:xe,setValue:e=>r(void 0,void 0,void 0,function*(){return yield E(e,De)}),handleEdit:lt,handleCancel:dt,handleKeyPress:it,isEditing:ze,setIsEditing:()=>c(De),getStyles:o,canDragOnto:ke,canEdit:ke,keyboardCommon:{},onError:Re}),jt=gt?e.jsx(He,Object.assign({customNodeProps:Ze},bt,{children:yt})):yt,vt=pt&&e.jsx(se,{startEdit:ke?()=>{Le.current=!0,p(null),c(De)}:void 0,handleAdd:Se?e=>{fe(!1);const t=$e(xe,e);if("array"===ot){const e=Q.array?0:g.length,n=Q.array?{insert:!0}:{};D(t,[...De,e],n).then(e=>{e&&Re({code:"ADD_ERROR",message:e},t)})}else if(e in g)Re({code:"KEY_EXISTS",message:G("ERROR_KEY_EXISTS",xe)},e);else{const n=Q.object?{insertBefore:0}:{};D(t,[...De,e],n).then(e=>{e&&Re({code:"ADD_ERROR",message:e},t)})}}:void 0,handleDelete:Oe?ct:void 0,enableClipboard:A,type:ot,nodeData:xe,translate:G,customButtons:n.customButtons,keyboardControls:J,handleKeyboard:X,getNewKeyOptions:Ue,editConfirmRef:ee,jsonStringify:H,onEditEvent:R,showIconTooltips:P}),Et={canEditKey:Ge,isEditingKey:Be,pathString:Ee,path:De,name:Ce,arrayIndexFromOne:L,handleKeyboard:X,handleEditKey:Pe,handleCancel:dt,keyValueArray:ht,styles:o("property",xe),getNextOrPrevious:e=>k(xe.fullData,De,e,_),handleClick:te.includes("property")?st:e=>e.stopPropagation(),emptyStringKey:Ke,nodeData:xe,customNodeData:$,getStyles:o},xt=e.jsxs("div",Object.assign({className:"jer-component jer-collection-component",style:Object.assign(Object.assign({marginLeft:(0===De.length?0:M/2)+"em"},o("collection",xe)),{position:"relative"}),draggable:Ne},Ve,Me("above"),{children:[e.jsx("div",{className:"jer-clickzone",style:{width:M/2+1+"em",zIndex:10+2*xe.level},onClick:te.includes("left")?st:void 0}),!ze&&_e,e.jsx(Fe,{position:"above",nodeData:xe}),nt?e.jsxs("div",{className:"jer-collection-header-row",style:{position:"relative"},onClick:te.includes("header")?st:void 0,children:[e.jsxs("div",{className:"jer-collection-name",children:[e.jsx("div",{className:"jer-collapse-icon jer-accordion-icon"+(ye?" jer-rotate-90":""),style:{zIndex:11+2*xe.level,transition:be},onClick:st,children:e.jsx(ie,{name:"chevron",rotate:ye,nodeData:xe})}),mt&&e.jsx(ge,Object.assign({},Et)),!ze&&e.jsx("span",{className:"jer-brackets jer-bracket-open",style:o("bracket",xe),children:at.open})]}),!ze&&ut&&e.jsx("div",{className:"jer-collection-item-count"+(ut?" jer-visible":" jer-hidden"),style:Object.assign(Object.assign({},o("itemCount",xe)),{transition:be}),children:1===we?G("ITEM_SINGLE",Object.assign(Object.assign({},xe),{size:1}),1):G("ITEMS_MULTIPLE",xe,we)}),e.jsx("div",{className:"jer-brackets"+(ft?" jer-visible":" jer-hidden"),style:Object.assign(Object.assign({},o("bracket",xe)),{transition:be}),children:at.close}),vt]}):Qe?e.jsx(e.Fragment,{}):e.jsxs("div",{className:"jer-collection-header-row",style:{position:"relative"},children:[e.jsx(ge,Object.assign({},Et)),vt]}),e.jsxs("div",{className:"jer-collection-inner",style:Object.assign(Object.assign({overflowY:ft||ce?"clip":"visible",maxHeight:rt?void 0:de},o("collectionInner",xe)),{transition:be}),ref:ae,children:[jt,e.jsx("div",{className:ze?"jer-collection-error-row":"jer-collection-error-row-edit",children:Te&&e.jsx("span",{className:"jer-error-slug",style:o("error",xe),children:Te})}),!ze&&nt&&e.jsx("div",{className:"jer-brackets jer-bracket-outside",style:o("bracket",xe),children:at.close})]}),e.jsx(Fe,{position:"below",nodeData:xe})]}));return Je?e.jsx(Je,Object.assign({customNodeProps:Xe},bt,{children:xt})):xt},Ee={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)",EMPTY_STRING:"<empty string>",TOOLTIP_COPY:"Copy to clipboard",TOOLTIP_EDIT:"Edit",TOOLTIP_DELETE:"Delete",TOOLTIP_ADD:"Add"},xe=(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]:Ee[r];return void 0===o?a:null==a?void 0:a.replace("{{count}}",String(o))})(e,t,r,n,o);var De=[],Ce=[];!function(e,t){if(e&&"undefined"!=typeof document){var n,r=!0===t.prepend?"prepend":"append",o=!0===t.singleTag,a="string"==typeof t.container?document.querySelector(t.container):document.getElementsByTagName("head")[0];if(o){var i=De.indexOf(a);-1===i&&(i=De.push(a)-1,Ce[i]={}),n=Ce[i]&&Ce[i][r]?Ce[i][r]:Ce[i][r]=s()}else n=s();65279===e.charCodeAt(0)&&(e=e.substring(1)),n.styleSheet?n.styleSheet.cssText+=e:n.appendChild(document.createTextNode(e))}function s(){var e=document.createElement("style");if(e.setAttribute("type","text/css"),t.attributes)for(var n=Object.keys(t.attributes),o=0;o<n.length;o++)e.setAttribute(n[o],t.attributes[n[o]]);var i="prepend"===r?"afterbegin":"beforeend";return a.insertAdjacentElement(i,e),e}}(':root{--jer-select-border:#b6b6b6;--jer-select-focus:#777;--jer-select-arrow:#777;--jer-form-border:1px solid #ededf0;--jer-form-border-focus:1px solid #e2e2e2;--jer-highlight-color:#b3d8ff}.jer-visible{opacity:1}.jer-hidden{opacity:0}.jer-select select{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:transparent;border:none;color:#000;cursor:inherit;font-family:inherit;font-size:.8em;line-height:inherit;margin:0;outline:none;padding:0 1em 0 0;z-index:1}select::-ms-expand{display:none}.jer-select{align-items:center;background-color:#fff;background-image:linear-gradient(0deg,#f9f9f9,#fff 33%);border:1px solid var(--jer-select-border);border-radius:.25em;cursor:pointer;display:grid;grid-template-areas:"select";line-height:1.1;max-width:15ch;min-width:12ch;padding:.25em .5em;position:relative}.jer-select select,.jer-select:after{grid-area:select}.jer-select:not(.jer-select--multiple):after{background-color:var(--jer-select-arrow);clip-path:polygon(100% 0,0 0,50% 100%);content:"";height:.5em;justify-self:end;width:.8em}select:focus+.focus{border:1px solid var(--jer-select-focus);border-radius:inherit;bottom:-1px;left:-1px;position:absolute;right:-1px;top:-1px}.jer-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-bracket-outside{padding-left:0}.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{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 we=(e,t)=>JSON.stringify(e,t,2),ke=({data:n,setData:o,rootName:a="root",onUpdate:i=()=>{},onEdit:s=i,onDelete:l=i,onAdd:c=i,onChange:d,onError:u,onEditEvent:p,showErrorMessages:m=!0,enableClipboard:g=!0,indent:h=2,collapse:f=!1,collapseAnimationTime:b=300,showCollectionCount:j=!0,restrictEdit:v=!1,restrictDelete:x=!1,restrictAdd:C=!1,restrictTypeSelection:k=!1,restrictDrag:O=!0,viewOnly:S,searchFilter:N,searchText:A,searchDebounceTime:R=350,keySort:P=!1,showArrayIndices:K=!0,arrayIndexFromOne:V=!1,showStringQuotes:M=!0,showIconTooltips:_=!1,defaultValue:F=null,newKeyOptions:L,minWidth:z=250,maxWidth:W="min(600px, 90vw)",rootFontSize:G,stringTruncate:Y=250,translations:$={},className:U,id:H,customText:Z={},customNodeDefinitions:J=[],customButtons:X=[],jsonParse:Q=JSON.parse,jsonStringify:q=we,TextEditor:ee,errorMessageTimeout:te=2500,keyboardControls:ne={},externalTriggers:re,insertAtTop:oe=!1,onCollapse:ae,collapseClickZones:ie=["header","left"]})=>{const{getStyles:se}=I(),{setCurrentlyEditingElement:le}=B(),ce=t.useMemo(()=>Se(f),[f]),de=t.useMemo(()=>xe($,Z),[$,Z]),[ue,pe]=t.useState(A),[me,ge]=(({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:o,data:n}),ye=t.useRef(null);t.useEffect(()=>{le(null);const e=setTimeout(()=>pe(A),R);return()=>clearTimeout(e)},[A,R]);const fe={key:a,path:[],level:0,index:0,value:me,size:"object"==typeof me&&null!==me?Object.keys(me).length:1,parentData:null,fullData:me},be=(e,t)=>r(void 0,void 0,void 0,function*(){const n=yield e(t);if(!0===n||void 0===n)return void ge(t.newData);const r=Te(n)?n:["error",n],[o,a]=r;if("error"===o)return ge(t.currentData),!1===a?de("ERROR_UPDATE",fe):String(a);ge(a)}),Ee=t.useMemo(()=>Se(v,S),[v,S]),De=t.useMemo(()=>Se(x,S),[x,S]),Ce=t.useMemo(()=>Se(C,S),[C,S]),ke=t.useMemo(()=>Se(O,S),[O,S]),Re=t.useMemo(()=>Ne(N),[N]),Pe=t.useMemo(()=>(e=>{const t=Object.assign({},w);for(const n of Object.keys(w)){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})(ne),[ne]),Ke=t.useCallback((e,t)=>((e,t,n)=>{const r=Object.entries(t);for(const[t,o]of r)if(D(n,e[t],t)){n.preventDefault(),o();break}})(Pe,t,e),[Pe]),Ie=t.useMemo(()=>{const e=Ae(J,"stringifyReplacer");return t=>q(t,e)},[J,q]),Ve=t.useMemo(()=>{const e=Ae(J,"parseReviver");return t=>{const n=Q(t,e);return T(n)}},[J,Q]),Me=t.useRef(null);((e,n)=>{const{setCurrentlyEditingElement:r,currentlyEditingElement:o,setCollapseState:a}=B();t.useEffect(()=>{if(!e)return;const{collapse:t,edit:i}=e;t&&a(t);const s=!(null==i?void 0:i.path)||E(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])})(re,Me);const _e=t.useCallback((e,t)=>{!1!==P&&("function"!=typeof P?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)=>P(t(e),t(n))))},[P]),Fe=je(J,fe),Le={mainContainerRef:ye,name:a,nodeData:fe,onEdit:(e,t)=>r(void 0,void 0,void 0,function*(){const{currentData:n,newData:r,currentValue:o,newValue:a}=Oe(me,t,e,"update");if(o!==a)return yield be(s,{currentData:n,newData:r,currentValue:o,newValue:a,name:t.slice(-1)[0],path:t})}),onDelete:(e,t)=>r(void 0,void 0,void 0,function*(){const{currentData:n,newData:r,currentValue:o,newValue:a}=Oe(me,t,e,"delete");return yield be(l,{currentData:n,newData:r,currentValue:o,newValue:a,name:t.slice(-1)[0],path:t})}),onAdd:(e,t,n)=>r(void 0,void 0,void 0,function*(){const{currentData:r,newData:o,currentValue:a,newValue:i}=Oe(me,t,e,"add",n);return yield be(c,{currentData:r,newData:o,currentValue:a,newValue:i,name:t.slice(-1)[0],path:t})}),onChange:d,onError:u,onEditEvent:p,showErrorMessages:m,onMove:(e,t,n)=>r(void 0,void 0,void 0,function*(){if(null===e)return;const{currentData:r,newData:o,currentValue:a}=Oe(me,e,"","delete"),i=e.slice(-1)[0],l=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:m}=Oe(o,[...l,d],a,"add",u);return yield be(s,{currentData:r,newData:p,currentValue:a,newValue:m,name:t.slice(-1)[0],path:t})}),showCollectionCount:j,collapseFilter:ce,collapseAnimationTime:b,restrictEditFilter:Ee,restrictDeleteFilter:De,restrictAddFilter:Ce,restrictTypeSelection:k,restrictDragFilter:ke,canDragOnto:!1,searchFilter:Re,searchText:ue,enableClipboard:g,keySort:P,sort:_e,showArrayIndices:K,arrayIndexFromOne:V,showStringQuotes:M,showIconTooltips:_,indent:h,defaultValue:F,newKeyOptions:L,stringTruncate:Y,translate:de,customNodeDefinitions:J,customNodeData:Fe,customButtons:X,parentData:null,jsonParse:Ve,jsonStringify:Ie,TextEditor:ee,errorMessageTimeout:te,handleKeyboard:Ke,keyboardControls:Pe,insertAtTop:{object:!0===oe||"object"===oe,array:!0===oe||"array"===oe},onCollapse:ae,editConfirmRef:Me,collapseClickZones:ie},ze=Object.assign(Object.assign({},se("container",fe)),{minWidth:z,maxWidth:W});return ze.fontSize=null!=G?G:ze.fontSize,e.jsx("div",{id:H,ref:ye,className:`jer-editor-container ${null!=U?U:""}`,style:ze,children:y(me)&&!Fe.renderCollectionAsValue?e.jsx(ve,Object.assign({data:me},Le)):e.jsx(he,Object.assign({data:me,showLabel:!0},Le))})},Oe=(e,t,n,r,o={})=>{if(0===t.length)return{currentData:e,newData:n,currentValue:e,newValue:n};const i=Object.assign({remove:"delete"===r},o),s="add"!==r?a(e,t):void 0;return{currentData:e,newData:u(e,t,n,i),currentValue:s,newValue:"delete"!==r?n:void 0}},Se=(e,t)=>t?()=>!0:"boolean"==typeof e?()=>e:"number"==typeof e?({level:t})=>t>=e:e,Ne=e=>{if(void 0!==e)return"value"===e?j:"key"===e?v:"all"===e?(e,t)=>j(e,t)||v(e,t):e},Te=e=>Array.isArray(e)&&2===e.length&&["error","value"].includes(e[0]),Ae=(e,t)=>{const n="stringifyReplacer"===t?[e=>void 0===e?A:e]:[];if(n.push(...e.map(e=>e[t]).filter(e=>!!e)),0!==n.length)return(e,t)=>{let r=t;for(const e of n)r=e(r);return r}},Re=t=>{var n;const{value:r,setIsEditing:o,getStyles:a,nodeData:i}=t,s=a("string",i);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(Y,Object.assign({},t,{pathString:E(i.path),styles:s,value:i.value}))})})},Pe={condition:({value:e})=>"string"==typeof e&&/^https?:\/\/.+\..+$/.test(e),element:Re,showOnView:!0,showOnEdit:!1};exports.IconAdd=q,exports.IconCancel=oe,exports.IconChevron=ae,exports.IconCopy=ne,exports.IconDelete=te,exports.IconEdit=ee,exports.IconOk=re,exports.JsonEditor=n=>{var r;const[o,a]=t.useState();return t.useEffect(()=>{const e=document.documentElement;a(e)},[]),o?e.jsx(K,{theme:null!==(r=n.theme)&&void 0!==r?r:R,icons:n.icons,docRoot:o,children:e.jsx(z,{onEditEvent:n.onEditEvent,onCollapse:n.onCollapse,children:e.jsx(ke,Object.assign({},n))})}):null},exports.LinkCustomComponent=Re,exports.LinkCustomNodeDefinition=Pe,exports.StringDisplay=Y,exports.StringEdit=$,exports.assign=u,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=R,exports.extract=a,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=y,exports.matchNode=j,exports.matchNodeKey=v,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=de,exports.toPathString=E,exports.useKeyboardListener=J;
|
package/build/index.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as t,Fragment as n}from"react/jsx-runtime";import{createContext as r,useContext as o,useState as i,useRef as a,useEffect as l,useCallback as s,useMemo as c}from"react";function d(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 u(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{s(r.next(e))}catch(e){i(e)}}function l(e){try{s(r.throw(e))}catch(e){i(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,l)}s((r=r.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const p=e=>e.split(/(\.|\[\d+\])/).filter((e=>"."!==e&&""!==e)).map((e=>{const t=/\[(\d+)\]/.exec(e);return t?Number(t[1]):e})),g=(e,t,n)=>{const r=Array.isArray(t)?t:p(t);if(0===r.length)return e;const o=r[0];if(Array.isArray(e)&&"number"!=typeof o&&e.length>0)return e.map((e=>g(e,r,n)));if("object"!=typeof e||null===e||!(o in e))return m(e,o,n);const i=e[o];return 1===r.length?i:g(i,r.slice(1),n)},m=(e,t,n)=>{if(void 0===n)throw new Error(`Unable to extract object property\nLooking for property: ${t}\nIn object: ${JSON.stringify(e)}`);return n},h=(e,t,n,r,o)=>{if(!r)throw new Error(null!=o?o:`Invalid property path: ${t}\nCouldn't access "${n}" in ${JSON.stringify(e)}`)},y=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),f=e=>Array.isArray(e),b=(e,t)=>e.filter(((e,n)=>n!==t)),v=(e,t,n,r={})=>{const{remove:o=!1,createNew:i=!0,noError:a=!1}=r,l=e,s="string"==typeof(c=t)?c:"number"==typeof c?String(c):c.reduce(((e,t)=>"number"==typeof t?`${e}[${t}]`:""===e?t:`${e}.${t}`),"");var c;const d=Object.assign(Object.assign({},r),{remove:o,createNew:i,noError:a,fullData:l,fullPath:s}),u=Array.isArray(t)?t:p(t);return f(e)&&o&&1===u.length?b(e,u[0]):j(e,u,n,d)},j=(e,t,n,r)=>{const o=y(e)?Object.assign({},e):null,i=f(e)?[...e]:null;if(0===t.length)return e;if(!o&&!i)throw new Error("Can't assign property -- invalid input object");const{createNew:a,remove:l,noError:s,fullData:c,fullPath:d}=r,u=t[0];if(i&&"string"==typeof u)return i.map((e=>j(e,t,n,r)));if(1===t.length){if(o&&"string"==typeof u){const e=E(o,u,n,r);return null!=e?e:o}return i&&"number"==typeof u?(w(i,u,n,r),i):(h(c,d,u,s),e)}const p=o||i||[];if(l&&2===t.length&&"number"==typeof t[1]){const e=p[u],n=t[1];return f(e)?p[u]=b(e,n):h(c,d,u,s,"Trying to remove an indexed item from an object that is not an array"),p}const g=t.slice(1);if(u in e){if(m=p[u],!f(m)&&!y(m)){if(!a)return h(c,d,u,s),p;p[u]={}}return p[u]=j(p[u],g,n,r),p}var m;if(a){const e="number"==typeof g[0]?[]:{};if(o)return p[u]=e,p[u]=j(p[u],g,n,r),p;if(i&&Array.isArray(p)){p.push(e);const t=p.length-1;return p[t]=j(p[t],g,n,r),p}}return h(c,d,u,s),p},E=(e,t,n,r)=>{const{remove:o,createNew:i,noError:a,insertAfter:l,insertBefore:s,fullData:c,fullPath:d}=r;if(void 0!==s||void 0!==l){const r=Object.entries(e);let o=1/0;return o="number"==typeof s?s:"number"==typeof l?l:r.findIndex((([e])=>e===(null!=s?s:l))),void 0!==l&&o++,r.splice(o,0,[t,n]),Object.fromEntries(r)}const u=t in e;o?u?delete e[t]:h(c,d,t,a):i||u?e[t]=n:h(c,d,t,a)},w=(e,t,n,r)=>{const{noError:o,fullData:i,fullPath:a,createNew:l,insert:s}=r;s&&e.splice(t,0,n),t in e?e[t]=n:l?e.push(n):h(i,a,t,o)},D=({className:n,name:r,value:o,setValue:i,handleKeyPress:a,styles:l,textAreaRef:s})=>{if("string"!=typeof o)return null;const c="\n"===o.slice(-1)?o+".":o;return e("div",{style:{display:"grid"},children:[t("textarea",{id:`${r}_textarea`,ref:s,style:Object.assign({height:"auto",gridArea:"1 / 1 / 2 / 2",overflowY:"auto",whiteSpace:"pre-wrap"},l),rows:1,className:n,name:`${r}_textarea`,value:o,onChange:e=>i(e.target.value),autoFocus:!0,onFocus:e=>{o.length<40&&e.target.select()},onKeyDown:a}),t("span",{className:n,style:Object.assign({visibility:"hidden",height:"auto",gridArea:"1 / 1 / 2 / 2",color:"red",opacity:.9,whiteSpace:"pre-wrap",overflowY:"auto",border:"1px solid transparent"},l),children:c})]})},C=e=>null!==e&&"object"==typeof e,O=(e,t,n,r="")=>{if(!n&&!r)return!0;switch(e){case"collection":if(n){if(n(t,r))return!0;if(!k(r,t,n))return!1}if(!n&&r&&!k(r,t))return!1;break;case"value":if(n&&!n(t,r))return!1;if(!n&&r&&!S(t,r))return!1}return!0},k=(e="",t,n=S)=>{const r=t.value;return Object.entries(r).some((([o,i])=>{const a=[...t.path,o],l=Object.assign(Object.assign({},t),{key:o,path:a,level:t.level+1,value:i,size:a.length,parentData:r});return C(i)?k(e,l,n):n(l,e)}))},S=(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}},N=({key:e,path:t},n="")=>!!S({value:e},n)||!!t.some((e=>S({value:e},n))),T=(e,t)=>(null!=t?t:"")+e.map((e=>""===e?String.fromCharCode(0):e)).join("."),A=e=>e.shiftKey?"Shift":e.metaKey?"Meta":e.ctrlKey?"Control":e.altKey?"Alt":void 0,x=(e,t,n)=>{const r=e.key,o=A(e);if(Array.isArray(t))return!!o&&t.includes(o);const{key:i,modifier:a}=t;return("stringLineBreak"!==n||"Enter"!==r||"Shift"!==o||"Enter"!==i||!(null==a?void 0:a.includes("Shift")))&&(r===i&&(a===o||Array.isArray(a)&&a.includes(o)))},P={key:"Enter"},K={confirm:P,cancel:{key:"Escape"},objectConfirm:Object.assign(Object.assign({},P),{modifier:["Meta","Shift","Control"]}),objectLineBreak:P,stringConfirm:P,stringLineBreak:Object.assign(Object.assign({},P),{modifier:["Shift"]}),numberConfirm:P,numberUp:{key:"ArrowUp"},numberDown:{key:"ArrowDown"},tabForward:{key:"Tab"},tabBack:{key:"Tab",modifier:"Shift"},booleanConfirm:P,booleanToggle:{key:" "},clipboardModifier:["Meta","Control"],collapseModifier:["Alt"]},R=(e,t,n="next",r)=>{const o=t.slice(0,t.length-1),i=t.slice(-1)[0];if(void 0===i)return null;const a=g(e,o),l=V(a);Array.isArray(a)||r(l,(({key:e,value:t})=>[e,t]));const s=l.findIndex((e=>e.key===i)),c=l[s+("next"===n?1:-1)];return c?C(c.value)?0===Object.keys(c.value).length?R(e,[...o,c.key],n,r):I(e,[...o,c.key],n,r):[...o,c.key]:0===o.length?null:R(e,o,n,r)},I=(e,t,n="next",r)=>{const o=g(e,t);if(!C(o))return t;const i=Array.isArray(o)?o.map(((e,t)=>t)):Object.keys(o);r(i,(e=>[e,o]));const a="next"===n?i[0]:i[i.length-1];return I(e,[...t,a],n,r)},V=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}))),_=(e,t)=>{var n,r,o,i;const a=e.current,l=null!==(n=null==a?void 0:a.selectionStart)&&void 0!==n?n:1/0,s=null!==(r=null==a?void 0:a.selectionEnd)&&void 0!==r?r:1/0,c=(null===(o=null==a?void 0:a.textContent)||void 0===o?void 0:o.slice(0,l))+t+(null===(i=null==a?void 0:a.textContent)||void 0===i?void 0:i.slice(s));return a.value=c,null==a||a.setSelectionRange(l+1,l+1),c},F=e=>{if(e!==L){if(Array.isArray(e))return e.map((e=>F(e)));if(e&&"object"==typeof e)for(const t in e)e[t]=F(e[t]);return e}},L="__undefined__",z={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)"}},M=r({getStyles:()=>({}),icons:{}}),B=({theme:e=z,icons:n={},docRoot:r,children:o})=>{const i=G(e,r);return t(M.Provider,{value:{getStyles:(e,t)=>"function"==typeof i[e]?i[e](t):i[e],icons:n},children:o})},W=()=>o(M),G=(e,t)=>{var n,r,o,i;const a={},l=(Array.isArray(e)?e:[e]).map((e=>$(e)?Y({fragments:{},styles:e},a):Y(e,a))),s=Y(z,{});Object.keys(s).forEach((e=>{const t=e;l.forEach((e=>{e[t]&&(s[t]=Object.assign(Object.assign({},s[t]),e[t]))}))}));const c=Object.assign({},s);return Object.entries(a).forEach((([e,t])=>{const n=e;c[n]=e=>{const r=t(e)||{};return Object.assign(Object.assign({},s[n]),r)}})),"function"!=typeof(null==c?void 0:c.inputHighlight)&&(null===(n=null==c?void 0:c.inputHighlight)||void 0===n?void 0:n.backgroundColor)&&t.style.setProperty("--jer-highlight-color",null===(r=null==c?void 0:c.inputHighlight)||void 0===r?void 0:r.backgroundColor),"function"!=typeof(null==c?void 0:c.iconCopy)&&(null===(o=null==c?void 0:c.iconCopy)||void 0===o?void 0:o.color)&&t.style.setProperty("--jer-icon-copy-color",null===(i=null==c?void 0:c.iconCopy)||void 0===i?void 0:i.color),c},Y=(e,t)=>{const{fragments:n,styles:r}=e,o={};return Object.entries(r).forEach((([e,r])=>{const i=(Array.isArray(r)?r:[r]).reduce(((r,o)=>{var i,a;if("function"==typeof o)return t[e]=o,Object.assign({},r);if("string"==typeof o){const t=null!==(i=null==n?void 0:n[o])&&void 0!==i?i:o;return"string"==typeof t?Object.assign(Object.assign({},r),{[null!==(a=U[e])&&void 0!==a?a:"color"]:t}):Object.assign(Object.assign({},r),t)}return Object.assign(Object.assign({},r),o)}),{});o[e]=i})),o},$=e=>!("styles"in e),U={container:"backgroundColor",collection:"backgroundColor",collectionInner:"backgroundColor",collectionElement:"backgroundColor",dropZone:"borderColor",inputHighlight:"backgroundColor"},H=r(null),Z=({children:e,onEditEvent:n,onCollapse:r})=>{const[o,l]=i(null),[s,c]=i(null),[d,u]=i(null),[p,g]=i({path:null,pathString:null}),m=a(null),h=a("next"),y=a(null);return t(H.Provider,{value:{collapseState:o,setCollapseState:e=>{l(e),r&&null!==e&&(Array.isArray(e)?e.forEach((e=>r(e))):r(e)),null!==e&&setTimeout((()=>l(null)),2e3)},getMatchingCollapseState:e=>{if(Array.isArray(o)){for(const t of o)if(X(e,t))return t;return null}return X(e,o)?o:null},currentlyEditingElement:s,setCurrentlyEditingElement:(e,t)=>{const r="string"==typeof e||null===e?e:T(e,"key"===t?"key_":void 0);null!==s&&null!==r&&null!==m.current&&m.current(),c(r),n&&(Array.isArray(e)||null===e)&&n(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:d,setPreviousValue:u,dragSource:p,setDragSource:g},children:e})},J=()=>{const e=o(H);if(!e)throw new Error("Missing Context Provider");return e},X=(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},Q="**INVALID_FUNCTION**",q=({nodeData:r,showStringQuotes:o=!0,stringTruncate:a=200,pathString:l,canEdit:s,setIsEditing:c,styles:d,translate:u,value:p,TextWrapper:g=({children:e})=>e})=>{const m=null!=p?p:r.value,[h,y]=i(!1),f=o?'"':"",b=m.length>a,v=()=>{s?c(!0):y(!h)};return e("div",{id:`${l}_display`,onDoubleClick:v,onClick:e=>{(e.getModifierState("Control")||e.getModifierState("Meta"))&&v()},className:"jer-value-string",style:d,children:[f,b?e(n,h?{children:[t(g,{children:e("span",{children:[m,f]})}),e("span",{className:"jer-string-expansion jer-show-less",onClick:()=>y(!1),children:[" ",u("SHOW_LESS",r)]})]}:{children:[e(g,{children:[t("span",{children:m.slice(0,a-2).trimEnd()})," "]}),t("span",{className:"jer-string-expansion jer-ellipsis",onClick:()=>y(!0),children:"..."}),f]}):t(g,{children:`${m}${f}`})]})},ee=({styles:e,pathString:n,value:r,setValue:o,handleEdit:i,handleKeyboard:l,keyboardCommon:s})=>{const c=a(null);return t(D,{className:"jer-input-text",textAreaRef:c,name:n,value:r,setValue:o,handleKeyPress:e=>{l(e,Object.assign({stringConfirm:i,stringLineBreak:()=>{const e=_(c,"\n");o(e)}},s))},styles:e})},te=n=>{var{isEditing:r,path:o,enumType:i}=n,a=d(n,["isEditing","path","enumType"]);const{getStyles:l}=W(),s=T(o),{value:c,setValue:u,nodeData:p,handleEdit:g,handleKeyboard:m,keyboardCommon:h}=a;return r&&i?e("div",{className:"jer-select jer-select-enums",children:[t("select",{name:`${s}-value-select`,className:"jer-select-inner",onChange:e=>u(e.target.value),value:c,autoFocus:!0,onKeyDown:e=>{m(e,Object.assign({stringConfirm:g},h))},children:i.values.map((e=>t("option",{value:e,children:e},e)))}),t("span",{className:"focus"})]}):r?t(ee,Object.assign({styles:l("input",p),pathString:s},a,{setValue:a.setValue})):t(q,Object.assign({pathString:s,styles:l("string",p)},a))},ne=({value:e,setValue:n,isEditing:r,path:o,setIsEditing:i,handleEdit:a,nodeData:l,handleKeyboard:s,keyboardCommon:c})=>{const{getStyles:d}=W();return r?t("input",{className:"jer-input-number",type:"text",name:T(o),value:e,onChange:e=>n(e.target.value.replace(/[^0-9.-]/g,"")),autoFocus:!0,onFocus:e=>setTimeout((()=>e.target.select()),10),onKeyDown:t=>s(t,Object.assign({numberConfirm:a,numberUp:()=>n(Number(e)+1),numberDown:()=>n(Number(e)-1)},c)),style:Object.assign({width:String(e).length/1.5+2+"em"},d("input",l))}):t("span",{onDoubleClick:()=>i(!0),className:"jer-value-number",style:d("number",l),children:e})},re=({value:e,setValue:n,isEditing:r,path:o,setIsEditing:i,handleEdit:a,nodeData:l,handleKeyboard:s,keyboardCommon:c})=>{const{getStyles:d}=W();return"boolean"!=typeof e?null:r?t("input",{className:"jer-input-boolean",type:"checkbox",name:T(o),checked:e,onChange:()=>n(!e),onKeyDown:t=>{" "===t.key&&t.preventDefault(),s(t,Object.assign({booleanConfirm:a,booleanToggle:()=>n(!e)},c))},autoFocus:!0}):t("span",{onDoubleClick:()=>i(!0),className:"jer-value-boolean",style:d("boolean",l),children:String(e)})},oe=(e,t)=>{const n=a(void 0),r=a(t);l((()=>{r.current=t}),[t]);const o=e=>{r.current(e)};l((()=>{if(window.clearTimeout(n.current),e)return n.current=window.setTimeout((()=>{window.addEventListener("keydown",o)}),100),()=>{window.clearTimeout(n.current),window.removeEventListener("keydown",o)}}),[e])},ie=({value:e,isEditing:n,setIsEditing:r,handleEdit:o,nodeData:i,handleKeyboard:a,keyboardCommon:l})=>{const{getStyles:s}=W();return oe(n,(e=>a(e,Object.assign({confirm:o},l)))),t("div",{onDoubleClick:()=>r(!0),className:"jer-value-null",style:s("null",i),children:String(e)})},ae=({value:e})=>{let n="Error!";switch(typeof e){case"string":e===Q&&(n="Function");break;case"undefined":n="Undefined";break;case"symbol":n="Symbol"}return t("span",{className:"jer-value-invalid",children:n})},le=({size:n,style:r,className:o})=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:n,height:n,className:o,style:r,children:[t("path",{d:"M13 7h-2v4H7v2h4v4h2v-4h4v-2h-4z"}),t("path",{d:"M12 2C6.486 2 2 6.486 2 12s4.486 10 10 10 10-4.486 10-10S17.514 2 12 2zm0 18c-4.411 0-8-3.589-8-8s3.589-8 8-8 8 3.589 8 8-3.589 8-8 8z"})]}),se=({size:n,style:r,className:o})=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:n,height:n,className:o,style:r,transform:"translate(0, 0.5)",children:[t("path",{d:"M7 17.013l4.413-.015 9.632-9.54c.378-.378.586-.88.586-1.414s-.208-1.036-.586-1.414l-1.586-1.586c-.756-.756-2.075-.752-2.825-.003L7 12.583v4.43zM18.045 4.458l1.589 1.583-1.597 1.582-1.586-1.585 1.594-1.58zM9 13.417l6.03-5.973 1.586 1.586-6.029 5.971L9 15.006v-1.589z"}),t("path",{d:"M5 21h14c1.103 0 2-.897 2-2v-8.668l-2 2V19H8.158c-.026 0-.053.01-.079.01-.033 0-.066-.009-.1-.01H5V5h6.847l2-2H5c-1.103 0-2 .897-2 2v14c0 1.103.897 2 2 2z"})]}),ce=({size:e,style:n,className:r})=>t("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:e,height:e,className:r,style:n,children:t("path",{d:"M6 19a2 2 0 002 2h8a2 2 0 002-2V7H6v12m2.46-7.12l1.41-1.41L12 12.59l2.12-2.12 1.41 1.41L13.41 14l2.12 2.12-1.41 1.41L12 15.41l-2.12 2.12-1.41-1.41L10.59 14l-2.13-2.12M15.5 4l-1-1h-5l-1 1H5v2h14V4h-3.5z"})}),de=({size:n,style:r,className:o})=>e("svg",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",width:n,height:n,className:o,style:r,children:[t("path",{d:"M9 2 H15 A1 1 0 0 1 16 3 V5 A1 1 0 0 1 15 6 H9 A1 1 0 0 1 8 5 V3 A1 1 0 0 1 9 2 z"}),t("path",{d:"M8 4H6a2 2 0 00-2 2v14a2 2 0 002 2h12a2 2 0 002-2v-2M16 4h2a2 2 0 012 2v4M21 14H11"}),t("path",{d:"M15 10l-4 4 4 4"})]}),ue=({size:n,style:r,className:o})=>e("svg",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",width:n,height:n,className:o,style:r,children:[t("path",{d:"M22 11.08V12a10 10 0 11-5.93-9.14"}),t("path",{d:"M22 4L12 14.01l-3-3"})]}),pe=({size:e,style:n,className:r})=>t("svg",{baseProfile:"tiny",viewBox:"0 0 24 24",fill:"currentColor",width:e,height:e,className:r,style:n,children:t("path",{d:"M12 4c-4.411 0-8 3.589-8 8s3.589 8 8 8 8-3.589 8-8-3.589-8-8-8zm-5 8c0-.832.224-1.604.584-2.295l6.711 6.711A4.943 4.943 0 0112 17c-2.757 0-5-2.243-5-5zm9.416 2.295L9.705 7.584A4.943 4.943 0 0112 7c2.757 0 5 2.243 5 5 0 .832-.224 1.604-.584 2.295z"})}),ge=({size:e,style:n,className:r})=>t("svg",{viewBox:"0 0 512 512",fill:"currentColor",width:e,height:e,className:r,style:n,children:t("path",{d:"M233.4 406.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L256 338.7 86.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z"})}),me=({name:e,nodeData:r})=>{var o,i,a,l,s,c,d;const{getStyles:u,icons:p}=W(),g={size:"1.4em",className:"jer-icon"};switch(e){case"add":return null!==(o=null==p?void 0:p.add)&&void 0!==o?o:t(le,Object.assign({},g,{style:u("iconAdd",r)}));case"edit":return null!==(i=null==p?void 0:p.edit)&&void 0!==i?i:t(se,Object.assign({},g,{style:u("iconEdit",r)}));case"delete":return null!==(a=null==p?void 0:p.delete)&&void 0!==a?a:t(ce,Object.assign({},g,{style:u("iconDelete",r),size:"1.45em"}));case"copy":return null!==(l=null==p?void 0:p.copy)&&void 0!==l?l:t(de,Object.assign({},g,{style:u("iconCopy",r),size:"1.2em"}));case"ok":return null!==(s=null==p?void 0:p.ok)&&void 0!==s?s:t(ue,Object.assign({},g,{style:Object.assign({fontSize:"90%"},u("iconOk",r))}));case"cancel":return null!==(c=null==p?void 0:p.cancel)&&void 0!==c?c:t(pe,Object.assign({},g,{style:Object.assign({fontSize:"130%"},u("iconCancel",r))}));case"chevron":return null!==(d=null==p?void 0:p.chevron)&&void 0!==d?d:t(ge,{size:"1em",style:u("iconCollection",r)});default:return t(n,{})}},he=({startEdit:r,handleDelete:o,handleAdd:a,enableClipboard:l,type:s,customButtons:c,nodeData:d,translate:u,keyboardControls:p,handleKeyboard:m,editConfirmRef:h,getNewKeyOptions:y,jsonStringify:f,onEditEvent:b,showIconTooltips:v})=>{const{getStyles:j}=W(),E=u("KEY_NEW",d),[w,D]=i(E),[C,O]=i(!1),{key:k,path:S,value:N}=d,T=Array.isArray(C),x=e=>{var t;if(b&&b(e?[...S,null]:null,e),!e)return void O(!1);const n=Object.keys(g(d.fullData,S)),r=y?null===(t=y(d))||void 0===t?void 0:t.filter((e=>!n.includes(e))):null;r&&D(""),O(null==r||r)};return e("div",{className:"jer-edit-buttons",style:{opacity:C?1:void 0},onClick:e=>e.stopPropagation(),children:[l&&t("div",{onClick:e=>{var t;e.stopPropagation();let n,r,o="value",i="",a=null;if(l){const s=A(e);if(s&&p.clipboardModifier.includes(s)?(n=fe(S),i=n,o="path"):(n=N,i="object"==typeof n?f(N):String(n)),!navigator.clipboard)return void("function"==typeof l&&l({success:!1,value:n,stringValue:i,path:S,key:k,type:o,errorMessage:"Can't access clipboard API"}));null===(t=navigator.clipboard)||void 0===t||t.writeText(i).then((()=>r=!0)).catch((e=>{r=!1,a=e.message})).finally((()=>{"function"==typeof l&&l({success:r,errorMessage:a,value:n,stringValue:i,path:S,key:k,type:o})}))}},className:"jer-copy-pulse",title:v?u("TOOLTIP_COPY",d):"",children:t(me,{name:"copy",nodeData:d})}),r&&t("div",{onClick:r,title:v?u("TOOLTIP_EDIT",d):"",children:t(me,{name:"edit",nodeData:d})}),o&&t("div",{onClick:o,title:v?u("TOOLTIP_DELETE",d):"",children:t(me,{name:"delete",nodeData:d})}),a&&t("div",{onClick:()=>{"object"===s?x(!0):a("")},title:v?u("TOOLTIP_ADD",d):"",children:t(me,{name:"add",nodeData:d})}),null==c?void 0:c.map((({Element:e,onClick:n},r)=>t("div",{onClick:e=>n&&n(d,e),children:t(e,{nodeData:d})},r))),C&&a&&"object"===s&&e(n,{children:[T?e("div",{className:"jer-select jer-select-keys",children:[e("select",{name:"new-key-select",className:"jer-select-inner",onChange:e=>{a(e.target.value),x(!1)},defaultValue:"",autoFocus:!0,onKeyDown:e=>{m(e,{cancel:()=>x(!1)})},children:[t("option",{value:"",disabled:!0,children:C.length>0?u("KEY_SELECT",d):u("NO_KEY_OPTIONS",d)}),C.map((e=>t("option",{value:e,children:e},e)))]}),t("span",{className:"focus"})]}):t("input",{className:"jer-input-new-key",type:"text",name:"new-object-key",value:w,onChange:e=>D(e.target.value),autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>{m(e,{stringConfirm:()=>{a&&(x(!1),a(w),D(E))},cancel:()=>{x(!1),D(E)}})},style:j("input",d)}),t(ye,{onOk:()=>{T&&!w||(x(!1),a(w))},onCancel:()=>{x(!1)},nodeData:d,editConfirmRef:h,hideOk:T})]})]})},ye=({onOk:n,onCancel:r,nodeData:o,editConfirmRef:i,hideOk:a=!1})=>e("div",{className:"jer-confirm-buttons",children:[!a&&t("div",{onClick:n,ref:i,children:t(me,{name:"ok",nodeData:o})}),t("div",{onClick:r,children:t(me,{name:"cancel",nodeData:o})})]}),fe=e=>e.reduce(((e,t)=>"number"==typeof t?`${e}[${t}]`:""===e?t:`${e}.${t}`),""),be=["string","number","boolean","null","object","array"],ve=({props:e,collapsed:t})=>{const{data:n,nodeData:r,parentData:o,onEdit:a,onError:l,showErrorMessages:c,restrictEditFilter:d,restrictDeleteFilter:u,restrictAddFilter:p,restrictDragFilter:g,translate:m,errorMessageTimeout:h}=e,{currentlyEditingElement:y,setCurrentlyEditingElement:f}=J(),[b,v]=i(null),j=Object.assign(Object.assign({},r),{collapsed:t}),{path:E,key:w,size:D}=j,C=T(E),O=!d(j),k=!u(j),S=!p(j),N=!g(j)&&k&&null===y,A=e=>{c&&(v(e),setTimeout((()=>v(null)),h)),console.warn("Error",e)},x=s(((e,t)=>{A(e.message),l&&l({currentData:j.fullData,errorValue:t,currentValue:n,name:w,path:E,error:e})}),[l,c]),P=y===C,K=y===`key_${C}`,R="number"==typeof E.slice(-1)[0],I={isEditing:P,isEditingKey:K,isArray:R,canEditKey:null!==o&&O&&S&&k&&!R},V=""===w&&E.length>0?m("EMPTY_STRING",j):null;return{pathString:C,nodeData:j,path:E,name:w,size:D,canEdit:O,canDelete:k,canAdd:S,canDrag:N,error:b,showError:A,onError:x,setError:v,handleEditKey:e=>{if(f(null),w===e)return;if(!o)return;const t=E.slice(0,-1);if(Object.keys(o).includes(e))return void x({code:"KEY_EXISTS",message:m("ERROR_KEY_EXISTS",j)},e);const n=Object.fromEntries(Object.entries(o).map((([t,n])=>t===w?[e,n]:[t,n])));a(n,t).then((t=>{t&&x({code:"UPDATE_ERROR",message:t},e)}))},derivedValues:I,emptyStringKey:V}},je=({canDrag:e,canDragOnto:n,path:r,nodeData:o,onMove:a,onError:l,translate:s})=>{const{getStyles:d}=W(),{dragSource:u,setDragSource:p}=J(),[g,m]=i(!1),h=T(r),y=c((()=>e?{onDragStart:e=>{e.stopPropagation(),p({path:r,pathString:h})},onDragEnd:e=>{e.stopPropagation(),p({path:null,pathString:null})}}:{}),[e,h]),f=c((()=>e=>n?{onDragOver:e=>{e.stopPropagation(),e.preventDefault()},onDrop:t=>{t.stopPropagation(),v(e),p({path:null,pathString:null}),m(!1)},onDragEnter:t=>{var n;t.stopPropagation(),h.startsWith(null!==(n=u.pathString)&&void 0!==n?n:"")||m(e)},onDragExit:e=>{e.stopPropagation(),m(!1)}}:{}),[u,n,h]),b=c((()=>n&&null!==u.pathString?t("div",Object.assign({className:"jer-drop-target-bottom",style:{height:"50%",position:"absolute",width:"100%",top:"50%",zIndex:r.length}},f("below"))):null),[u,n,r.length]),v=e=>{var t,n;const i=null===(t=u.path)||void 0===t?void 0:t.slice(-1)[0],c=null===(n=u.path)||void 0===n?void 0:n.slice(0,-1).join("."),d=r.slice(0,-1).join(""),{parentData:p}=o;"string"==typeof i&&p&&!Array.isArray(p)&&Object.keys(p).includes(i)&&i in p&&c!==d?l({code:"KEY_EXISTS",message:s("ERROR_KEY_EXISTS",o)},i):a(u.path,r,e).then((e=>{e&&l({code:"UPDATE_ERROR",message:e},o.value)}))};return{dragSourceProps:y,getDropTargetProps:f,BottomDropTarget:b,DropTargetPadding:({position:e,nodeData:n})=>g===e?t("div",{className:"jer-drag-n-drop-padding",style:d("dropZone",n)}):null,handleDrop:v}},Ee=(e,t,n,r)=>{var o,i,a;if(!t.current)return 0;const l=parseInt(null!==(o=getComputedStyle(n.current).getPropertyValue("line-height"))&&void 0!==o?o:"16px"),s=(null!==(a=null===(i=t.current)||void 0===i?void 0:i.offsetWidth)&&void 0!==a?a:0)/(.5*l),c=r(e).replace(/\\n/g,"\n").split("\n").map((e=>Math.ceil(e.length/s))).reduce(((e,t)=>e+t),0)*l;return Math.min(c+30,window.innerHeight-50)},we=({isEditingKey:n,canEditKey:r,pathString:o,path:i,name:a,arrayIndexFromOne:l,handleKeyboard:s,handleEditKey:c,handleCancel:d,handleClick:u,keyValueArray:p,styles:g,getNextOrPrevious:m,emptyStringKey:h,nodeData:y,customNodeData:f,getStyles:b})=>{const{setCurrentlyEditingElement:v}=J(),j="number"==typeof a?String(a+(l?1:0)):a;if(!n){const n=Object.assign(Object.assign({},g),{minWidth:`${Math.min(j.length+1,5)}ch`,flexShrink:j.length>10?1:0});if((null==f?void 0:f.CustomKey)&&y&&b){const{CustomKey:e,customNodeProps:o}=f;return t(e,{nodeData:y,name:null!=h?h:j,path:i,canEditKey:r,handleEditKey:e=>{r&&c(e)},setIsEditingKey:()=>{r&&v(i,"key")},handleClick:u,styles:n,customNodeProps:o,getStyles:b})}return e("span",{className:"jer-key-text",style:n,onDoubleClick:()=>r&&v(i,"key"),onClick:u,children:[h?t("span",{className:"jer-empty-string",children:h}):j,""!==j||h?t("span",{className:"jer-key-colon",children:":"}):null]})}return t("input",{className:"jer-input-text jer-key-edit",type:"text",name:o,defaultValue:j,autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>s(e,{stringConfirm:()=>c(e.target.value),cancel:d,tabForward:()=>{if(c(e.target.value),p){const e=null==p?void 0:p[0][0];v(e?[...i,e]:m("next"))}else v(i)},tabBack:()=>{c(e.target.value),v(m("prev"))}}),style:{width:j.length/1.5+.5+"em"}})},De=n=>{const{data:r,parentData:o,onEdit:a,onDelete:d,onChange:u,onMove:p,enableClipboard:g,canDragOnto:m,restrictTypeSelection:h,searchFilter:y,searchText:f,showLabel:b,stringTruncate:v,showStringQuotes:j,arrayIndexFromOne:E,indent:w,translate:D,customNodeDefinitions:C,customNodeData:k,handleKeyboard:S,keyboardControls:N,sort:T,editConfirmRef:A,jsonStringify:x,showIconTooltips:P}=n,{getStyles:K}=W(),{setCurrentlyEditingElement:I,setCollapseState:V,previouslyEditedElement:_,setPreviouslyEditedElement:F,tabDirection:L,setTabDirection:z,previousValue:M,setPreviousValue:B}=J(),[G,Y]=i("function"==typeof r?Q:r),{pathString:$,nodeData:U,path:H,name:Z,canEdit:X,canDelete:q,canDrag:ee,error:te,onError:ne,handleEditKey:re,emptyStringKey:oe,derivedValues:ie}=ve({props:n}),{dragSourceProps:ae,getDropTargetProps:le,BottomDropTarget:se,DropTargetPadding:ce}=je({canDrag:ee,canDragOnto:m,path:H,nodeData:U,onMove:p,onError:ne,translate:D}),[de,ue]=i(Ce(r,k)),pe=s((e=>{if(!u)return void Y(e);const t=u({currentData:U.fullData,newValue:e,currentValue:G,name:Z,path:H});Y(t)}),[u]);l((()=>{Y("function"==typeof r?Q:r),ue(Ce(r,k))}),[r,te]);const{CustomNode:ge,customNodeProps:me,hideKey:fe,showEditTools:Ee=!0,showOnEdit:De,showOnView:Se,passOriginalNode:Ne}=k,Te=[...be,...C.filter((({showInTypesSelector:e=!1,name:t})=>e&&!!t)).map((({name:e})=>e))],Ae=c((()=>{if("boolean"==typeof h)return h?[]:Te;if(Array.isArray(h))return h;const e=h(U);return"boolean"==typeof e?e?[]:Te:e}),[U,h]),[xe,Pe]=i(((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})(G,Ae)),{isEditing:Ke}=ie,Re=O("value",U,y,f);if(Ke&&(!Re||!X)){const e=R(U.fullData,H,L,T);I(e||_)}if(!Re)return null;const Ie=e=>{let t;if(I(null),B(null),void 0===e||(e=>e&&"object"==typeof e&&"type"in e&&"target"in e&&"preventDefault"in e&&"function"==typeof e.preventDefault)(e))switch(de){case"object":t={[D("DEFAULT_NEW_KEY",U)]:G};break;case"array":t=null!=G?G:[];break;case"number":{const e=Number(G);t=isNaN(e)?0:e;break}default:t=G}else t=e;a(t,H).then((e=>{e&&ne({code:"UPDATE_ERROR",message:e},t)}))},Ve=()=>{I(null),null===M?(Y(r),B(null)):a(M,H)},{isEditingKey:_e,canEditKey:Fe}=ie,Le=!Ke&&te,ze=Ke&&Ae.length>1,Me=("invalid"!==de||ge)&&!te&&Ee,Be=b&&!fe,We=ge&&(Ke&&De||!Ke&&Se),Ge={value:G,parentData:o,setValue:pe,isEditing:Ke,canEdit:X,setIsEditing:X?()=>I(H):()=>{},handleEdit:Ie,handleCancel:Ve,path:H,stringTruncate:v,showStringQuotes:j,nodeData:U,enumType:xe,translate:D,handleKeyboard:S,keyboardCommon:{cancel:Ve,tabForward:()=>{z("next"),F($);const e=R(U.fullData,H,"next",T);e&&(Ie(),I(e))},tabBack:()=>{z("prev"),F($);const e=R(U.fullData,H,"prev",T);e&&(Ie(),I(e))}}},Ye={canEditKey:Fe,isEditingKey:_e,pathString:$,path:H,name:Z,arrayIndexFromOne:E,handleKeyboard:S,handleEditKey:re,handleCancel:Ve,styles:K("property",U),getNextOrPrevious:e=>R(U.fullData,H,e,T),emptyStringKey:oe,nodeData:U,customNodeData:k,getStyles:K},$e=We?t(ge,Object.assign({},n,{value:G,customNodeProps:me,setValue:pe,handleEdit:Ie,handleCancel:Ve,handleKeyPress:e=>S(e,{stringConfirm:Ie,cancel:Ve}),isEditing:Ke,setIsEditing:()=>I(H),getStyles:K,originalNode:Ne?Oe(r,Ge):void 0,originalNodeKey:Ne?t(we,Object.assign({},Ye,{customNodeData:void 0})):void 0,canEdit:X,keyboardCommon:Ge.keyboardCommon,onError:ne})):Oe(r,Ge);return e("div",Object.assign({className:"jer-component jer-value-component",style:{marginLeft:null!==o?w/2+"em":0,position:"relative"},draggable:ee},ae,le("above"),{children:[se,t(ce,{position:"above",nodeData:U}),e("div",{className:"jer-value-main-row",style:{flexWrap:Z.length>10?"wrap":"nowrap"},children:[Be&&t(we,Object.assign({},Ye)),e("div",{className:"jer-value-and-buttons",children:[t("div",{className:"jer-input-component",children:$e}),Ke?t(ye,{onOk:Ie,onCancel:Ve,nodeData:U,editConfirmRef:A}):Me&&t(he,{startEdit:X?()=>{B(M),I(H,Ve)}:void 0,handleDelete:q?()=>{d(G,H).then((e=>{e&&ne({code:"DELETE_ERROR",message:e},G)}))}:void 0,enableClipboard:g,translate:D,customButtons:n.customButtons,nodeData:U,handleKeyboard:S,keyboardControls:N,editConfirmRef:A,jsonStringify:x,showIconTooltips:P}),ze&&e("div",{className:"jer-select jer-select-types",children:[t("select",{name:`${Z}-type-select`,className:"jer-select-inner",onChange:e=>(e=>{const t=C.find((t=>t.name===e));if(t)return a(t.defaultValue,H),ue(e),Pe(null),I(null),void V({path:H,collapsed:!1,includeChildren:!1});const n=Ae.find((t=>t instanceof Object&&t.enum===e));if(n)return"string"==typeof G&&n.values.includes(G)||a(n.values[0],H).then((e=>{e&&(ne({code:"UPDATE_ERROR",message:e},r),I(null))})),void Pe(n);const r=ke(G,e,D("DEFAULT_NEW_KEY",U),(null==k?void 0:k.CustomNode)?D("DEFAULT_STRING",U):void 0);["string","number","boolean"].includes(e)||I(null),a(r,H).then((e=>{e?(ne({code:"UPDATE_ERROR",message:e},r),I(null)):Pe(null)}))})(e.target.value),value:xe?xe.enum:de,children:Ae.map((e=>e instanceof Object&&"enum"in e?t("option",{value:e.enum,children:e.enum},e.enum):t("option",{value:e,children:e},e)))}),t("span",{className:"focus"})]}),Le&&t("span",{className:"jer-error-slug",style:K("error",U),children:te})]})]}),t(ce,{position:"below",nodeData:U})]}))},Ce=(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",Oe=(e,n)=>{const r=Ce(e),{value:o}=n;switch(r){case"string":return t(te,Object.assign({},n,{value:o}));case"number":return t(ne,Object.assign({},n,{value:o}));case"boolean":return t(re,Object.assign({},n,{value:o}));case"null":return t(ie,Object.assign({},n));default:return t(ae,Object.assign({},n))}},ke=(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=(e=[],t)=>{const n=e.filter((({condition:e})=>e(t)));if(0===n.length)return{};const r=n[0],{element:o,wrapperElement:i,customKey:a,customNodeProps:l,wrapperProps:s,hideKey:c=!1,showEditTools:u=!0,showOnEdit:p=!1,showOnView:g=!0,showCollectionWrapper:m=!0}=r,h=d(r,["element","wrapperElement","customKey","customNodeProps","wrapperProps","hideKey","showEditTools","showOnEdit","showOnView","showCollectionWrapper"]);return Object.assign({CustomNode:o,CustomWrapper:i,CustomKey:a,customNodeProps:l,wrapperProps:s,hideKey:c,showEditTools:u,showOnEdit:p,showOnView:g,showCollectionWrapper:m},h)},Ne=r=>{const{getStyles:o}=W(),{collapseState:c,setCollapseState:d,getMatchingCollapseState:p,currentlyEditingElement:g,setCurrentlyEditingElement:m,areChildrenBeingEdited:h,previousValue:y,setPreviousValue:f}=J(),{mainContainerRef:b,data:v,nodeData:j,parentData:E,showCollectionCount:w,onEdit:k,onAdd:S,onDelete:N,canDragOnto:T,collapseFilter:x,collapseAnimationTime:P,onMove:K,enableClipboard:I,onEditEvent:V,showIconTooltips:F,searchFilter:L,searchText:z,indent:M,sort:B,showArrayIndices:G,arrayIndexFromOne:Y,defaultValue:$,newKeyOptions:U,translate:H,customNodeDefinitions:Z,customNodeData:X,jsonParse:Q,jsonStringify:q,TextEditor:ee,keyboardControls:te,handleKeyboard:ne,insertAtTop:re,onCollapse:oe,editConfirmRef:ie,collapseClickZones:ae}=r,[le,se]=i(q(v)),ce=x(j),{contentRef:de,isAnimating:ue,maxHeight:pe,collapsed:ge,animateCollapse:fe,cssTransitionValue:be}=((e,t,n,r,o)=>{const[l,c]=i(n?0:void 0),[d,u]=i(n),p=a(!1),g=a(null),m=a(0),h=a(0),y=t/1e3+"s",f=s((n=>{var i,a;if(d!==n){switch(window.clearTimeout(h.current),p.current=!0,n){case!0:{const e=null!==(a=null===(i=g.current)||void 0===i?void 0:i.offsetHeight)&&void 0!==a?a:0;m.current=e,c(e),setTimeout((()=>{c(0)}),5);break}case!1:c(m.current||Ee(e,g,r,o))}u(!d),h.current=window.setTimeout((()=>{p.current=!1,n||c(void 0)}),t)}}),[t,d,e,r,o]);return{contentRef:g,isAnimating:p.current,animateCollapse:f,maxHeight:l,collapsed:d,cssTransitionValue:y}})(v,P,ce,b,q),{pathString:Ce,nodeData:Oe,path:ke,name:Te,size:Ae,canEdit:xe,canDelete:Pe,canAdd:Ke,canDrag:Re,error:Ie,setError:Ve,onError:_e,handleEditKey:Fe,emptyStringKey:Le,derivedValues:ze}=ve({props:r,collapsed:ge}),{dragSourceProps:Me,getDropTargetProps:Be,BottomDropTarget:We,DropTargetPadding:Ge}=je({canDrag:Re,canDragOnto:T,path:ke,nodeData:Oe,onMove:K,onError:_e,translate:H}),Ye=a(!ce),{isEditing:$e,isEditingKey:Ue,isArray:He,canEditKey:Ze}=ze;l((()=>{se(q(v))}),[v]),l((()=>{const e=x(Oe)&&!$e;Ye.current=!e,fe(e)}),[x]),l((()=>{if(null!==c){const e=p(ke);e&&(Ye.current=!0,fe(e.collapsed))}}),[c]);const Je=a(null),Xe=s(((e,t)=>{if("function"!=typeof $)return $;const n=$(e,t);return void 0!==n?n:null}),[$]),Qe=s((e=>U?"function"!=typeof U?U:U(e):null),[U]),{CustomNode:qe,customNodeProps:et,CustomWrapper:tt,wrapperProps:nt={},hideKey:rt,showEditTools:ot=!0,showOnEdit:it,showOnView:at,showCollectionWrapper:lt=!0}=X,st=h(Ce);st&&ge&&fe(!1);if(!(O("collection",Oe,L,z)||0===Oe.level)&&!st)return null;const ct=Array.isArray(v)?"array":"object",dt="array"===ct?{open:"[",close:"]"}:{open:"{",close:"}"},ut=e=>{if("Tab"!==e.key||e.getModifierState("Shift"))ne(e,{objectConfirm:gt,cancel:ht});else{e.preventDefault();const t=_(Je,"\t");se(t)}},pt=e=>{e.stopPropagation();const t=A(e);if(t&&te.collapseModifier.includes(t))return Ye.current=!0,void d({collapsed:!ge,path:ke,includeChildren:!0});g&&g.includes(Ce)||(Ye.current=!0,d(null),oe&&oe({path:ke,collapsed:!ge,includeChildren:!1}),fe(!ge))},gt=()=>{try{const e=Q(le);if(m(null),f(null),Ve(null),q(e)===q(v))return;k(e,ke).then((t=>{t&&_e({code:"UPDATE_ERROR",message:t},e)}))}catch(e){_e({code:"INVALID_JSON",message:H("ERROR_INVALID_JSON",Oe)},le)}},mt=ke.length>0?()=>{N(v,ke).then((e=>{e&&_e({code:"DELETE_ERROR",message:e},v)}))}:void 0,ht=()=>{m(null),null===y?(Ve(null),se(q(v)),f(null)):k(y,ke)},yt="when-closed"===w?ge:w,ft=!$e&&ot,bt=(G||!He)&&!rt&&void 0!==Te,vt=qe&&($e&&it||!$e&&at),jt=Object.entries(v).map((([e,t])=>["array"===ct?Number(e):e,t]));"object"===ct&&B(jt,(e=>e));const Et=Ye.current?$e?e("div",{className:"jer-collection-text-edit",children:[ee?t(ee,{value:le,onChange:se,onKeyDown:e=>ne(e,{objectConfirm:gt,cancel:ht})}):t(D,{textAreaRef:Je,className:"jer-collection-text-area",name:Ce,value:le,setValue:se,handleKeyPress:ut,styles:o("input",Oe)}),t("div",{className:"jer-collection-input-button-row",children:t(ye,{onOk:gt,onCancel:ht,nodeData:Oe,editConfirmRef:ie})})]}):jt.map((([e,n],i)=>{const a={key:e,value:n,path:[...ke,e],level:ke.length+1,index:i,size:C(n)?Object.keys(n).length:null,parentData:v,fullData:Oe.fullData},l=Se(Z,a);return t("div",{className:"jer-collection-element",style:o("collectionElement",a),children:C(n)&&!(null==l?void 0:l.renderCollectionAsValue)?t(Ne,Object.assign({},r,{data:n,parentData:v,nodeData:a,showCollectionCount:w,canDragOnto:xe,customNodeData:l}),e):t(De,Object.assign({},r,{data:n,parentData:v,nodeData:a,canDragOnto:xe,showLabel:"object"===ct||G,customNodeData:l}),e)},e)})):null,wt=!!lt&&(ge&&!st);wt||(Ye.current=!0);const Dt=Object.assign(Object.assign({},r),{data:v,value:v,parentData:E,nodeData:Oe,setValue:e=>u(void 0,void 0,void 0,(function*(){return yield k(e,ke)})),handleEdit:gt,handleCancel:ht,handleKeyPress:ut,isEditing:$e,setIsEditing:()=>m(ke),getStyles:o,canDragOnto:xe,canEdit:xe,keyboardCommon:{},onError:_e}),Ct=vt?t(qe,Object.assign({customNodeProps:et},Dt,{children:Et})):Et,Ot=ft&&t(he,{startEdit:xe?()=>{Ye.current=!0,f(null),m(ke)}:void 0,handleAdd:Ke?e=>{fe(!1);const t=Xe(Oe,e);if("array"===ct){const e=re.array?0:v.length,n=re.array?{insert:!0}:{};S(t,[...ke,e],n).then((e=>{e&&_e({code:"ADD_ERROR",message:e},t)}))}else if(e in v)_e({code:"KEY_EXISTS",message:H("ERROR_KEY_EXISTS",Oe)},e);else{const n=re.object?{insertBefore:0}:{};S(t,[...ke,e],n).then((e=>{e&&_e({code:"ADD_ERROR",message:e},t)}))}}:void 0,handleDelete:Pe?mt:void 0,enableClipboard:I,type:ct,nodeData:Oe,translate:H,customButtons:r.customButtons,keyboardControls:te,handleKeyboard:ne,getNewKeyOptions:Qe,editConfirmRef:ie,jsonStringify:q,onEditEvent:V,showIconTooltips:F}),kt={canEditKey:Ze,isEditingKey:Ue,pathString:Ce,path:ke,name:Te,arrayIndexFromOne:Y,handleKeyboard:ne,handleEditKey:Fe,handleCancel:ht,keyValueArray:jt,styles:o("property",Oe),getNextOrPrevious:e=>R(Oe.fullData,ke,e,B),handleClick:ae.includes("property")?pt:e=>e.stopPropagation(),emptyStringKey:Le,nodeData:Oe,customNodeData:X,getStyles:o},St=e("div",Object.assign({className:"jer-component jer-collection-component",style:Object.assign(Object.assign({marginLeft:(0===ke.length?0:M/2)+"em"},o("collection",Oe)),{position:"relative"}),draggable:Re},Me,Be("above"),{children:[t("div",{className:"jer-clickzone",style:{width:M/2+1+"em",zIndex:10+2*Oe.level},onClick:ae.includes("left")?pt:void 0}),!$e&&We,t(Ge,{position:"above",nodeData:Oe}),lt?e("div",{className:"jer-collection-header-row",style:{position:"relative"},onClick:ae.includes("header")?pt:void 0,children:[e("div",{className:"jer-collection-name",children:[t("div",{className:"jer-collapse-icon jer-accordion-icon"+(ge?" jer-rotate-90":""),style:{zIndex:11+2*Oe.level,transition:be},onClick:pt,children:t(me,{name:"chevron",rotate:ge,nodeData:Oe})}),bt&&t(we,Object.assign({},kt)),!$e&&t("span",{className:"jer-brackets jer-bracket-open",style:o("bracket",Oe),children:dt.open})]}),!$e&&yt&&t("div",{className:"jer-collection-item-count"+(yt?" jer-visible":" jer-hidden"),style:Object.assign(Object.assign({},o("itemCount",Oe)),{transition:be}),children:1===Ae?H("ITEM_SINGLE",Object.assign(Object.assign({},Oe),{size:1}),1):H("ITEMS_MULTIPLE",Oe,Ae)}),t("div",{className:"jer-brackets"+(wt?" jer-visible":" jer-hidden"),style:Object.assign(Object.assign({},o("bracket",Oe)),{transition:be}),children:dt.close}),Ot]}):rt?t(n,{}):e("div",{className:"jer-collection-header-row",style:{position:"relative"},children:[t(we,Object.assign({},kt)),Ot]}),e("div",{className:"jer-collection-inner",style:Object.assign(Object.assign({overflowY:wt||ue?"clip":"visible",maxHeight:st?void 0:pe},o("collectionInner",Oe)),{transition:be}),ref:de,children:[Ct,t("div",{className:$e?"jer-collection-error-row":"jer-collection-error-row-edit",children:Ie&&t("span",{className:"jer-error-slug",style:o("error",Oe),children:Ie})}),!$e&<&&t("div",{className:"jer-brackets jer-bracket-outside",style:Object.assign(Object.assign({},o("bracket",Oe)),{marginLeft:(M<3?-1:M<6?-.5:0)+"em"}),children:dt.close})]}),t(Ge,{position:"below",nodeData:Oe})]}));return tt?t(tt,Object.assign({customNodeProps:nt},Dt,{children:St})):St},Te={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)",EMPTY_STRING:"<empty string>",TOOLTIP_COPY:"Copy to clipboard",TOOLTIP_EDIT:"Edit",TOOLTIP_DELETE:"Delete",TOOLTIP_ADD:"Add"},Ae=(e,t)=>(n,r,o)=>((e,t,n,r,o)=>{if(t[r]){const e=t[r](n);if(null!==e)return e}const i=r in e?e[r]:Te[r];return void 0===o?i:null==i?void 0:i.replace("{{count}}",String(o))})(e,t,r,n,o);var xe=[],Pe=[];!function(e,t){if(e&&"undefined"!=typeof document){var n,r=!0===t.prepend?"prepend":"append",o=!0===t.singleTag,i="string"==typeof t.container?document.querySelector(t.container):document.getElementsByTagName("head")[0];if(o){var a=xe.indexOf(i);-1===a&&(a=xe.push(i)-1,Pe[a]={}),n=Pe[a]&&Pe[a][r]?Pe[a][r]:Pe[a][r]=l()}else n=l();65279===e.charCodeAt(0)&&(e=e.substring(1)),n.styleSheet?n.styleSheet.cssText+=e:n.appendChild(document.createTextNode(e))}function l(){var e=document.createElement("style");if(e.setAttribute("type","text/css"),t.attributes)for(var n=Object.keys(t.attributes),o=0;o<n.length;o++)e.setAttribute(n[o],t.attributes[n[o]]);var a="prepend"===r?"afterbegin":"beforeend";return i.insertAdjacentElement(a,e),e}}(':root{--jer-select-border:#b6b6b6;--jer-select-focus:#777;--jer-select-arrow:#777;--jer-form-border:1px solid #ededf0;--jer-form-border-focus:1px solid #e2e2e2;--jer-highlight-color:#b3d8ff}.jer-visible{opacity:1}.jer-hidden{opacity:0}.jer-select select{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:transparent;border:none;color:#000;cursor:inherit;font-family:inherit;font-size:.8em;line-height:inherit;margin:0;outline:none;padding:0 1em 0 0;z-index:1}select::-ms-expand{display:none}.jer-select{align-items:center;background-color:#fff;background-image:linear-gradient(0deg,#f9f9f9,#fff 33%);border:1px solid var(--jer-select-border);border-radius:.25em;cursor:pointer;display:grid;grid-template-areas:"select";line-height:1.1;max-width:15ch;min-width:12ch;padding:.25em .5em;position:relative}.jer-select select,.jer-select:after{grid-area:select}.jer-select:not(.jer-select--multiple):after{background-color:var(--jer-select-arrow);clip-path:polygon(100% 0,0 0,50% 100%);content:"";height:.5em;justify-self:end;width:.8em}select:focus+.focus{border:1px solid var(--jer-select-focus);border-radius:inherit;bottom:-1px;left:-1px;position:absolute;right:-1px;top:-1px}.jer-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-bracket-outside{padding-left:.5em}.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{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 Ke=(e,t)=>JSON.stringify(e,t,2),Re=({data:e,setData:n,rootName:r="root",onUpdate:o=()=>{},onEdit:d=o,onDelete:p=o,onAdd:g=o,onChange:m,onError:h,onEditEvent:y,showErrorMessages:f=!0,enableClipboard:b=!0,indent:v=2,collapse:j=!1,collapseAnimationTime:E=300,showCollectionCount:w=!0,restrictEdit:D=!1,restrictDelete:O=!1,restrictAdd:k=!1,restrictTypeSelection:S=!1,restrictDrag:N=!0,viewOnly:A,searchFilter:P,searchText:R,searchDebounceTime:I=350,keySort:V=!1,showArrayIndices:_=!0,arrayIndexFromOne:L=!1,showStringQuotes:z=!0,showIconTooltips:M=!1,defaultValue:B=null,newKeyOptions:G,minWidth:Y=250,maxWidth:$="min(600px, 90vw)",rootFontSize:U,stringTruncate:H=250,translations:Z={},className:X,id:Q,customText:q={},customNodeDefinitions:ee=[],customButtons:te=[],jsonParse:ne=JSON.parse,jsonStringify:re=Ke,TextEditor:oe,errorMessageTimeout:ie=2500,keyboardControls:ae={},externalTriggers:le,insertAtTop:se=!1,onCollapse:ce,collapseClickZones:de=["header","left"]})=>{const{getStyles:ue}=W(),{setCurrentlyEditingElement:pe}=J(),ge=c((()=>_e(j)),[j]),me=c((()=>Ae(Z,q)),[Z,q]),[he,ye]=i(R),[fe,be]=(({setData:e,data:t})=>{const[n,r]=i(e?void 0:t),o=s((t=>{e?e(t):r(t)}),[e]);return l((()=>{e||r(t)}),[t]),[e?t:n,o]})({setData:n,data:e}),ve=a(null);l((()=>{pe(null);const e=setTimeout((()=>ye(R)),I);return()=>clearTimeout(e)}),[R,I]);const je={key:r,path:[],level:0,index:0,value:fe,size:"object"==typeof fe&&null!==fe?Object.keys(fe).length:1,parentData:null,fullData:fe},Ee=(e,t)=>u(void 0,void 0,void 0,(function*(){const n=yield e(t);if(!0===n||void 0===n)return void be(t.newData);const r=Le(n)?n:["error",n],[o,i]=r;if("error"===o)return be(t.currentData),!1===i?me("ERROR_UPDATE",je):String(i);be(i)})),we=c((()=>_e(D,A)),[D,A]),Ce=c((()=>_e(O,A)),[O,A]),Oe=c((()=>_e(k,A)),[k,A]),ke=c((()=>_e(N,A)),[N,A]),Te=c((()=>Fe(P)),[P]),xe=c((()=>(e=>{const t=Object.assign({},K);for(const n of Object.keys(K)){const r=n;if(e[r]){const o=e[r],i=["clipboardModifier","collapseModifier"].includes(n)?Array.isArray(o)?o:[o]:"string"==typeof o?{key:o}:o;t[r]=i,["stringConfirm","numberConfirm","booleanConfirm"].forEach((n=>{!e[n]&&e.confirm&&(t[n]=t.confirm)}))}}return t})(ae)),[ae]),Pe=s(((e,t)=>((e,t,n)=>{const r=Object.entries(t);for(const[t,o]of r)if(x(n,e[t],t)){n.preventDefault(),o();break}})(xe,t,e)),[xe]),Re=c((()=>{const e=ze(ee,"stringifyReplacer");return t=>re(t,e)}),[ee,re]),Ie=c((()=>{const e=ze(ee,"parseReviver");return t=>{const n=ne(t,e);return F(n)}}),[ee,ne]),Me=a(null);((e,t)=>{const{setCurrentlyEditingElement:n,currentlyEditingElement:r,setCollapseState:o}=J();l((()=>{if(!e)return;const{collapse:i,edit:a}=e;i&&o(i);const l=!(null==a?void 0:a.path)||T(a.path)===r;switch(null==a?void 0:a.action){case"accept":l&&(t.current&&t.current.click(),n(null));break;case"cancel":l&&n(null);break;default:(null==a?void 0:a.path)&&n(a.path)}}),[e])})(le,Me);const Be=s(((e,t)=>{!1!==V&&("function"!=typeof V?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)=>V(t(e),t(n)))))}),[V]),We=Se(ee,je),Ge={mainContainerRef:ve,name:r,nodeData:je,onEdit:(e,t)=>u(void 0,void 0,void 0,(function*(){const{currentData:n,newData:r,currentValue:o,newValue:i}=Ve(fe,t,e,"update");if(o!==i)return yield Ee(d,{currentData:n,newData:r,currentValue:o,newValue:i,name:t.slice(-1)[0],path:t})})),onDelete:(e,t)=>u(void 0,void 0,void 0,(function*(){const{currentData:n,newData:r,currentValue:o,newValue:i}=Ve(fe,t,e,"delete");return yield Ee(p,{currentData:n,newData:r,currentValue:o,newValue:i,name:t.slice(-1)[0],path:t})})),onAdd:(e,t,n)=>u(void 0,void 0,void 0,(function*(){const{currentData:r,newData:o,currentValue:i,newValue:a}=Ve(fe,t,e,"add",n);return yield Ee(g,{currentData:r,newData:o,currentValue:i,newValue:a,name:t.slice(-1)[0],path:t})})),onChange:m,onError:h,onEditEvent:y,showErrorMessages:f,onMove:(e,t,n)=>u(void 0,void 0,void 0,(function*(){if(null===e)return;const{currentData:r,newData:o,currentValue:i}=Ve(fe,e,"","delete"),a=e.slice(-1)[0],l=t.slice(0,-1),s=t.slice(-1)[0];let c="number"==typeof s?"above"===n?s:s+1:"number"==typeof a?`arr_${a}`:a;e.slice(0,-1).join(".")===t.slice(0,-1).join(".")&&"number"==typeof a&&"number"==typeof c&&a<c&&(c-=1);const u="number"==typeof c?{insert:!0}:"above"===n?{insertBefore:s}:{insertAfter:s},{newData:p,newValue:g}=Ve(o,[...l,c],i,"add",u);return yield Ee(d,{currentData:r,newData:p,currentValue:i,newValue:g,name:t.slice(-1)[0],path:t})})),showCollectionCount:w,collapseFilter:ge,collapseAnimationTime:E,restrictEditFilter:we,restrictDeleteFilter:Ce,restrictAddFilter:Oe,restrictTypeSelection:S,restrictDragFilter:ke,canDragOnto:!1,searchFilter:Te,searchText:he,enableClipboard:b,keySort:V,sort:Be,showArrayIndices:_,arrayIndexFromOne:L,showStringQuotes:z,showIconTooltips:M,indent:v,defaultValue:B,newKeyOptions:G,stringTruncate:H,translate:me,customNodeDefinitions:ee,customNodeData:We,customButtons:te,parentData:null,jsonParse:Ie,jsonStringify:Re,TextEditor:oe,errorMessageTimeout:ie,handleKeyboard:Pe,keyboardControls:xe,insertAtTop:{object:!0===se||"object"===se,array:!0===se||"array"===se},onCollapse:ce,editConfirmRef:Me,collapseClickZones:de},Ye=Object.assign(Object.assign({},ue("container",je)),{minWidth:Y,maxWidth:$});return Ye.fontSize=null!=U?U:Ye.fontSize,t("div",{id:Q,ref:ve,className:`jer-editor-container ${null!=X?X:""}`,style:Ye,children:C(fe)&&!We.renderCollectionAsValue?t(Ne,Object.assign({data:fe},Ge)):t(De,Object.assign({data:fe,showLabel:!0},Ge))})},Ie=e=>{var n;const[r,o]=i();return l((()=>{const e=document.documentElement;o(e)}),[]),r?t(B,{theme:null!==(n=e.theme)&&void 0!==n?n:z,icons:e.icons,docRoot:r,children:t(Z,{onEditEvent:e.onEditEvent,onCollapse:e.onCollapse,children:t(Re,Object.assign({},e))})}):null},Ve=(e,t,n,r,o={})=>{if(0===t.length)return{currentData:e,newData:n,currentValue:e,newValue:n};const i=Object.assign({remove:"delete"===r},o),a="add"!==r?g(e,t):void 0;return{currentData:e,newData:v(e,t,n,i),currentValue:a,newValue:"delete"!==r?n:void 0}},_e=(e,t)=>t?()=>!0:"boolean"==typeof e?()=>e:"number"==typeof e?({level:t})=>t>=e:e,Fe=e=>{if(void 0!==e)return"value"===e?S:"key"===e?N:"all"===e?(e,t)=>S(e,t)||N(e,t):e},Le=e=>Array.isArray(e)&&2===e.length&&["error","value"].includes(e[0]),ze=(e,t)=>{const n="stringifyReplacer"===t?[e=>void 0===e?L:e]:[];if(n.push(...e.map((e=>e[t])).filter((e=>!!e))),0!==n.length)return(e,t)=>{let r=t;for(const e of n)r=e(r);return r}},Me=e=>{var n;const{value:r,setIsEditing:o,getStyles:i,nodeData:a}=e,l=i("string",a);return t("div",{onDoubleClick:()=>o(!0),onClick:e=>{(e.getModifierState("Control")||e.getModifierState("Meta"))&&o(!0)},className:"jer-value-string jer-hyperlink",style:l,children:t("a",{href:r,target:"_blank",rel:"noreferrer",style:{color:null!==(n=l.color)&&void 0!==n?n:void 0},children:t(q,Object.assign({},e,{pathString:T(a.path),styles:l,value:a.value}))})})},Be={condition:({value:e})=>"string"==typeof e&&/^https?:\/\/.+\..+$/.test(e),element:Me,showOnView:!0,showOnEdit:!1},We={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)"}},Ge={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"}},Ye={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"}},$e={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"}},Ue={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"}},He={displayName:"Psychedelic",fragments:{pale:{color:"#A8DADC"},fluroYellow:"rgb(242, 228, 21)",fluroGreen:"rgb(68, 255, 62)",hotPink:"#f7379a"},styles:{container:{backgroundColor:"unset",background:"linear-gradient(90deg, hsla(333, 100%, 53%, 1) 0%, hsla(33, 94%, 57%, 1) 100%)",color:"black"},dropZone:"fluroYellow",property:"black",bracket:"fluroYellow",itemCount:["pale",{opacity:.7}],string:"white",number:["#33d9ff",{fontSize:"90%",fontWeight:"bold"}],boolean:["fluroGreen",{fontWeight:"bold",fontSize:"80%"}],null:["black",{fontWeight:"bold",opacity:.3,backgroundColor:"rgb(255, 255, 255, 0.5)",padding:"0 0.4em",borderRadius:"0.4em"}],iconCollection:"fluroYellow",iconEdit:["black"],iconDelete:["white",{opacity:.5}],iconAdd:["white",{opacity:.5}],iconCopy:"rgb(32, 84, 242)",iconOk:"fluroGreen",iconCancel:"hotPink"}};export{le as IconAdd,pe as IconCancel,ge as IconChevron,de as IconCopy,ce as IconDelete,se as IconEdit,ue as IconOk,Ie as JsonEditor,Me as LinkCustomComponent,Be as LinkCustomNodeDefinition,q as StringDisplay,ee as StringEdit,v as assign,Ue as candyWrapperTheme,z as defaultTheme,g as extract,We as githubDarkTheme,Ge as githubLightTheme,C as isCollection,S as matchNode,N as matchNodeKey,Ye as monoDarkTheme,$e as monoLightTheme,He as psychedelicTheme,be as standardDataTypes,T as toPathString,oe as useKeyboardListener};
|
|
1
|
+
import{jsxs as e,jsx as t,Fragment as n}from"react/jsx-runtime";import{createContext as r,useContext as o,useState as i,useRef as a,useEffect as l,useCallback as s,useMemo as c}from"react";function d(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 u(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(e){try{s(r.next(e))}catch(e){i(e)}}function l(e){try{s(r.throw(e))}catch(e){i(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,l)}s((r=r.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const p=e=>e.split(/(\.|\[\d+\])/).filter(e=>"."!==e&&""!==e).map(e=>{const t=/\[(\d+)\]/.exec(e);return t?Number(t[1]):e}),g=(e,t,n)=>{const r=Array.isArray(t)?t:p(t);if(0===r.length)return e;const o=r[0];if(Array.isArray(e)&&"number"!=typeof o&&e.length>0)return e.map(e=>g(e,r,n));if("object"!=typeof e||null===e||!(o in e))return m(e,o,n);const i=e[o];return 1===r.length?i:g(i,r.slice(1),n)},m=(e,t,n)=>{if(void 0===n)throw new Error(`Unable to extract object property\nLooking for property: ${t}\nIn object: ${JSON.stringify(e)}`);return n},h=(e,t,n,r,o)=>{if(!r)throw new Error(null!=o?o:`Invalid property path: ${t}\nCouldn't access "${n}" in ${JSON.stringify(e)}`)},y=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),f=e=>Array.isArray(e),b=(e,t)=>e.filter((e,n)=>n!==t),v=(e,t,n,r={})=>{const{remove:o=!1,createNew:i=!0,noError:a=!1}=r,l=e,s="string"==typeof(c=t)?c:"number"==typeof c?String(c):c.reduce((e,t)=>"number"==typeof t?`${e}[${t}]`:""===e?t:`${e}.${t}`,"");var c;const d=Object.assign(Object.assign({},r),{remove:o,createNew:i,noError:a,fullData:l,fullPath:s}),u=Array.isArray(t)?t:p(t);return f(e)&&o&&1===u.length?b(e,u[0]):j(e,u,n,d)},j=(e,t,n,r)=>{const o=y(e)?Object.assign({},e):null,i=f(e)?[...e]:null;if(0===t.length)return e;if(!o&&!i)throw new Error("Can't assign property -- invalid input object");const{createNew:a,remove:l,noError:s,fullData:c,fullPath:d}=r,u=t[0];if(i&&"string"==typeof u)return i.map(e=>j(e,t,n,r));if(1===t.length){if(o&&"string"==typeof u){const e=E(o,u,n,r);return null!=e?e:o}return i&&"number"==typeof u?(w(i,u,n,r),i):(h(c,d,u,s),e)}const p=o||i||[];if(l&&2===t.length&&"number"==typeof t[1]){const e=p[u],n=t[1];return f(e)?p[u]=b(e,n):h(c,d,u,s,"Trying to remove an indexed item from an object that is not an array"),p}const g=t.slice(1);if(u in e){if(m=p[u],!f(m)&&!y(m)){if(!a)return h(c,d,u,s),p;p[u]={}}return p[u]=j(p[u],g,n,r),p}var m;if(a){const e="number"==typeof g[0]?[]:{};if(o)return p[u]=e,p[u]=j(p[u],g,n,r),p;if(i&&Array.isArray(p)){p.push(e);const t=p.length-1;return p[t]=j(p[t],g,n,r),p}}return h(c,d,u,s),p},E=(e,t,n,r)=>{const{remove:o,createNew:i,noError:a,insertAfter:l,insertBefore:s,fullData:c,fullPath:d}=r;if(void 0!==s||void 0!==l){const r=Object.entries(e);let o=1/0;return o="number"==typeof s?s:"number"==typeof l?l:r.findIndex(([e])=>e===(null!=s?s:l)),void 0!==l&&o++,r.splice(o,0,[t,n]),Object.fromEntries(r)}const u=t in e;o?u?delete e[t]:h(c,d,t,a):i||u?e[t]=n:h(c,d,t,a)},w=(e,t,n,r)=>{const{noError:o,fullData:i,fullPath:a,createNew:l,insert:s}=r;s&&e.splice(t,0,n),t in e?e[t]=n:l?e.push(n):h(i,a,t,o)},D=({className:n,name:r,value:o,setValue:i,handleKeyPress:a,styles:l,textAreaRef:s})=>{if("string"!=typeof o)return null;const c="\n"===o.slice(-1)?o+".":o;return e("div",{style:{display:"grid"},children:[t("textarea",{id:`${r}_textarea`,ref:s,style:Object.assign({height:"auto",gridArea:"1 / 1 / 2 / 2",overflowY:"auto",whiteSpace:"pre-wrap"},l),rows:1,className:n,name:`${r}_textarea`,value:o,onChange:e=>i(e.target.value),autoFocus:!0,onFocus:e=>{o.length<40&&e.target.select()},onKeyDown:a}),t("span",{className:n,style:Object.assign({visibility:"hidden",height:"auto",gridArea:"1 / 1 / 2 / 2",color:"red",opacity:.9,whiteSpace:"pre-wrap",overflowY:"auto",border:"1px solid transparent"},l),children:c})]})},C=e=>null!==e&&"object"==typeof e,O=(e,t,n,r="")=>{if(!n&&!r)return!0;switch(e){case"collection":if(n){if(n(t,r))return!0;if(!k(r,t,n))return!1}if(!n&&r&&!k(r,t))return!1;break;case"value":if(n&&!n(t,r))return!1;if(!n&&r&&!S(t,r))return!1}return!0},k=(e="",t,n=S)=>{const r=t.value;return Object.entries(r).some(([o,i])=>{const a=[...t.path,o],l=Object.assign(Object.assign({},t),{key:o,path:a,level:t.level+1,value:i,size:a.length,parentData:r});return C(i)?k(e,l,n):n(l,e)})},S=(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}},N=({key:e,path:t},n="")=>!!S({value:e},n)||!!t.some(e=>S({value:e},n)),T=(e,t)=>(null!=t?t:"")+e.map(e=>""===e?String.fromCharCode(0):e).join("."),A=e=>e.shiftKey?"Shift":e.metaKey?"Meta":e.ctrlKey?"Control":e.altKey?"Alt":void 0,x=(e,t,n)=>{const r=e.key,o=A(e);if(Array.isArray(t))return!!o&&t.includes(o);const{key:i,modifier:a}=t;return("stringLineBreak"!==n||"Enter"!==r||"Shift"!==o||"Enter"!==i||!(null==a?void 0:a.includes("Shift")))&&(r===i&&(a===o||Array.isArray(a)&&a.includes(o)))},P={key:"Enter"},K={confirm:P,cancel:{key:"Escape"},objectConfirm:Object.assign(Object.assign({},P),{modifier:["Meta","Shift","Control"]}),objectLineBreak:P,stringConfirm:P,stringLineBreak:Object.assign(Object.assign({},P),{modifier:["Shift"]}),numberConfirm:P,numberUp:{key:"ArrowUp"},numberDown:{key:"ArrowDown"},tabForward:{key:"Tab"},tabBack:{key:"Tab",modifier:"Shift"},booleanConfirm:P,booleanToggle:{key:" "},clipboardModifier:["Meta","Control"],collapseModifier:["Alt"]},R=(e,t,n="next",r)=>{const o=t.slice(0,t.length-1),i=t.slice(-1)[0];if(void 0===i)return null;const a=g(e,o),l=V(a);Array.isArray(a)||r(l,({key:e,value:t})=>[e,t]);const s=l.findIndex(e=>e.key===i),c=l[s+("next"===n?1:-1)];return c?C(c.value)?0===Object.keys(c.value).length?R(e,[...o,c.key],n,r):I(e,[...o,c.key],n,r):[...o,c.key]:0===o.length?null:R(e,o,n,r)},I=(e,t,n="next",r)=>{const o=g(e,t);if(!C(o))return t;const i=Array.isArray(o)?o.map((e,t)=>t):Object.keys(o);r(i,e=>[e,o]);const a="next"===n?i[0]:i[i.length-1];return I(e,[...t,a],n,r)},V=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})),_=(e,t)=>{var n,r,o,i;const a=e.current,l=null!==(n=null==a?void 0:a.selectionStart)&&void 0!==n?n:1/0,s=null!==(r=null==a?void 0:a.selectionEnd)&&void 0!==r?r:1/0,c=(null===(o=null==a?void 0:a.textContent)||void 0===o?void 0:o.slice(0,l))+t+(null===(i=null==a?void 0:a.textContent)||void 0===i?void 0:i.slice(s));return a.value=c,null==a||a.setSelectionRange(l+1,l+1),c},F=e=>{if(e!==L){if(Array.isArray(e))return e.map(e=>F(e));if(e&&"object"==typeof e)for(const t in e)e[t]=F(e[t]);return e}},L="__undefined__",z={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)"}},M=r({getStyles:()=>({}),icons:{}}),B=({theme:e=z,icons:n={},docRoot:r,children:o})=>{const i=G(e,r);return t(M.Provider,{value:{getStyles:(e,t)=>"function"==typeof i[e]?i[e](t):i[e],icons:n},children:o})},W=()=>o(M),G=(e,t)=>{var n,r,o,i;const a={},l=(Array.isArray(e)?e:[e]).map(e=>$(e)?Y({fragments:{},styles:e},a):Y(e,a)),s=Y(z,{});Object.keys(s).forEach(e=>{const t=e;l.forEach(e=>{e[t]&&(s[t]=Object.assign(Object.assign({},s[t]),e[t]))})});const c=Object.assign({},s);return Object.entries(a).forEach(([e,t])=>{const n=e;c[n]=e=>{const r=t(e)||{};return Object.assign(Object.assign({},s[n]),r)}}),"function"!=typeof(null==c?void 0:c.inputHighlight)&&(null===(n=null==c?void 0:c.inputHighlight)||void 0===n?void 0:n.backgroundColor)&&t.style.setProperty("--jer-highlight-color",null===(r=null==c?void 0:c.inputHighlight)||void 0===r?void 0:r.backgroundColor),"function"!=typeof(null==c?void 0:c.iconCopy)&&(null===(o=null==c?void 0:c.iconCopy)||void 0===o?void 0:o.color)&&t.style.setProperty("--jer-icon-copy-color",null===(i=null==c?void 0:c.iconCopy)||void 0===i?void 0:i.color),c},Y=(e,t)=>{const{fragments:n,styles:r}=e,o={};return Object.entries(r).forEach(([e,r])=>{const i=(Array.isArray(r)?r:[r]).reduce((r,o)=>{var i,a;if("function"==typeof o)return t[e]=o,Object.assign({},r);if("string"==typeof o){const t=null!==(i=null==n?void 0:n[o])&&void 0!==i?i:o;return"string"==typeof t?Object.assign(Object.assign({},r),{[null!==(a=U[e])&&void 0!==a?a:"color"]:t}):Object.assign(Object.assign({},r),t)}return Object.assign(Object.assign({},r),o)},{});o[e]=i}),o},$=e=>!("styles"in e),U={container:"backgroundColor",collection:"backgroundColor",collectionInner:"backgroundColor",collectionElement:"backgroundColor",dropZone:"borderColor",inputHighlight:"backgroundColor"},H=r(null),Z=({children:e,onEditEvent:n,onCollapse:r})=>{const[o,l]=i(null),[s,c]=i(null),[d,u]=i(null),[p,g]=i({path:null,pathString:null}),m=a(null),h=a("next"),y=a(null);return t(H.Provider,{value:{collapseState:o,setCollapseState:e=>{l(e),r&&null!==e&&(Array.isArray(e)?e.forEach(e=>r(e)):r(e)),null!==e&&setTimeout(()=>l(null),2e3)},getMatchingCollapseState:e=>{if(Array.isArray(o)){for(const t of o)if(X(e,t))return t;return null}return X(e,o)?o:null},currentlyEditingElement:s,setCurrentlyEditingElement:(e,t)=>{const r="string"==typeof e||null===e?e:T(e,"key"===t?"key_":void 0);null!==s&&null!==r&&null!==m.current&&m.current(),c(r),n&&(Array.isArray(e)||null===e)&&n(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:d,setPreviousValue:u,dragSource:p,setDragSource:g},children:e})},J=()=>{const e=o(H);if(!e)throw new Error("Missing Context Provider");return e},X=(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},Q="**INVALID_FUNCTION**",q=({nodeData:r,showStringQuotes:o=!0,stringTruncate:a=200,pathString:l,canEdit:s,setIsEditing:c,styles:d,translate:u,value:p,TextWrapper:g=({children:e})=>e})=>{const m=null!=p?p:r.value,[h,y]=i(!1),f=o?'"':"",b=m.length>a,v=()=>{s?c(!0):y(!h)};return e("div",{id:`${l}_display`,onDoubleClick:v,onClick:e=>{(e.getModifierState("Control")||e.getModifierState("Meta"))&&v()},className:"jer-value-string",style:d,children:[f,b?e(n,h?{children:[t(g,{children:e("span",{children:[m,f]})}),e("span",{className:"jer-string-expansion jer-show-less",onClick:()=>y(!1),children:[" ",u("SHOW_LESS",r)]})]}:{children:[e(g,{children:[t("span",{children:m.slice(0,a-2).trimEnd()})," "]}),t("span",{className:"jer-string-expansion jer-ellipsis",onClick:()=>y(!0),children:"..."}),f]}):t(g,{children:`${m}${f}`})]})},ee=({styles:e,pathString:n,value:r,setValue:o,handleEdit:i,handleKeyboard:l,keyboardCommon:s})=>{const c=a(null);return t(D,{className:"jer-input-text",textAreaRef:c,name:n,value:r,setValue:o,handleKeyPress:e=>{l(e,Object.assign({stringConfirm:i,stringLineBreak:()=>{const e=_(c,"\n");o(e)}},s))},styles:e})},te=n=>{var{isEditing:r,path:o,enumType:i}=n,a=d(n,["isEditing","path","enumType"]);const{getStyles:l}=W(),s=T(o),{value:c,setValue:u,nodeData:p,handleEdit:g,handleKeyboard:m,keyboardCommon:h}=a;return r&&i?e("div",{className:"jer-select jer-select-enums",children:[t("select",{name:`${s}-value-select`,className:"jer-select-inner",onChange:e=>u(e.target.value),value:c,autoFocus:!0,onKeyDown:e=>{m(e,Object.assign({stringConfirm:g},h))},children:i.values.map(e=>t("option",{value:e,children:e},e))}),t("span",{className:"focus"})]}):r?t(ee,Object.assign({styles:l("input",p),pathString:s},a,{setValue:a.setValue})):t(q,Object.assign({pathString:s,styles:l("string",p)},a))},ne=({value:e,setValue:n,isEditing:r,path:o,setIsEditing:i,handleEdit:a,nodeData:l,handleKeyboard:s,keyboardCommon:c})=>{const{getStyles:d}=W();return r?t("input",{className:"jer-input-number",type:"text",name:T(o),value:e,onChange:e=>n(e.target.value.replace(/[^0-9.-]/g,"")),autoFocus:!0,onFocus:e=>setTimeout(()=>e.target.select(),10),onKeyDown:t=>s(t,Object.assign({numberConfirm:a,numberUp:()=>n(Number(e)+1),numberDown:()=>n(Number(e)-1)},c)),style:Object.assign({width:String(e).length/1.5+2+"em"},d("input",l))}):t("span",{onDoubleClick:()=>i(!0),className:"jer-value-number",style:d("number",l),children:e})},re=({value:e,setValue:n,isEditing:r,path:o,setIsEditing:i,handleEdit:a,nodeData:l,handleKeyboard:s,keyboardCommon:c})=>{const{getStyles:d}=W();return"boolean"!=typeof e?null:r?t("input",{className:"jer-input-boolean",type:"checkbox",name:T(o),checked:e,onChange:()=>n(!e),onKeyDown:t=>{" "===t.key&&t.preventDefault(),s(t,Object.assign({booleanConfirm:a,booleanToggle:()=>n(!e)},c))},autoFocus:!0}):t("span",{onDoubleClick:()=>i(!0),className:"jer-value-boolean",style:d("boolean",l),children:String(e)})},oe=(e,t)=>{const n=a(void 0),r=a(t);l(()=>{r.current=t},[t]);const o=e=>{r.current(e)};l(()=>{if(window.clearTimeout(n.current),e)return n.current=window.setTimeout(()=>{window.addEventListener("keydown",o)},100),()=>{window.clearTimeout(n.current),window.removeEventListener("keydown",o)}},[e])},ie=({value:e,isEditing:n,setIsEditing:r,handleEdit:o,nodeData:i,handleKeyboard:a,keyboardCommon:l})=>{const{getStyles:s}=W();return oe(n,e=>a(e,Object.assign({confirm:o},l))),t("div",{onDoubleClick:()=>r(!0),className:"jer-value-null",style:s("null",i),children:String(e)})},ae=({value:e})=>{let n="Error!";switch(typeof e){case"string":e===Q&&(n="Function");break;case"undefined":n="Undefined";break;case"symbol":n="Symbol"}return t("span",{className:"jer-value-invalid",children:n})},le=({size:n,style:r,className:o})=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:n,height:n,className:o,style:r,children:[t("path",{d:"M13 7h-2v4H7v2h4v4h2v-4h4v-2h-4z"}),t("path",{d:"M12 2C6.486 2 2 6.486 2 12s4.486 10 10 10 10-4.486 10-10S17.514 2 12 2zm0 18c-4.411 0-8-3.589-8-8s3.589-8 8-8 8 3.589 8 8-3.589 8-8 8z"})]}),se=({size:n,style:r,className:o})=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:n,height:n,className:o,style:r,transform:"translate(0, 0.5)",children:[t("path",{d:"M7 17.013l4.413-.015 9.632-9.54c.378-.378.586-.88.586-1.414s-.208-1.036-.586-1.414l-1.586-1.586c-.756-.756-2.075-.752-2.825-.003L7 12.583v4.43zM18.045 4.458l1.589 1.583-1.597 1.582-1.586-1.585 1.594-1.58zM9 13.417l6.03-5.973 1.586 1.586-6.029 5.971L9 15.006v-1.589z"}),t("path",{d:"M5 21h14c1.103 0 2-.897 2-2v-8.668l-2 2V19H8.158c-.026 0-.053.01-.079.01-.033 0-.066-.009-.1-.01H5V5h6.847l2-2H5c-1.103 0-2 .897-2 2v14c0 1.103.897 2 2 2z"})]}),ce=({size:e,style:n,className:r})=>t("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:e,height:e,className:r,style:n,children:t("path",{d:"M6 19a2 2 0 002 2h8a2 2 0 002-2V7H6v12m2.46-7.12l1.41-1.41L12 12.59l2.12-2.12 1.41 1.41L13.41 14l2.12 2.12-1.41 1.41L12 15.41l-2.12 2.12-1.41-1.41L10.59 14l-2.13-2.12M15.5 4l-1-1h-5l-1 1H5v2h14V4h-3.5z"})}),de=({size:n,style:r,className:o})=>e("svg",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",width:n,height:n,className:o,style:r,children:[t("path",{d:"M9 2 H15 A1 1 0 0 1 16 3 V5 A1 1 0 0 1 15 6 H9 A1 1 0 0 1 8 5 V3 A1 1 0 0 1 9 2 z"}),t("path",{d:"M8 4H6a2 2 0 00-2 2v14a2 2 0 002 2h12a2 2 0 002-2v-2M16 4h2a2 2 0 012 2v4M21 14H11"}),t("path",{d:"M15 10l-4 4 4 4"})]}),ue=({size:n,style:r,className:o})=>e("svg",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",width:n,height:n,className:o,style:r,children:[t("path",{d:"M22 11.08V12a10 10 0 11-5.93-9.14"}),t("path",{d:"M22 4L12 14.01l-3-3"})]}),pe=({size:e,style:n,className:r})=>t("svg",{baseProfile:"tiny",viewBox:"0 0 24 24",fill:"currentColor",width:e,height:e,className:r,style:n,children:t("path",{d:"M12 4c-4.411 0-8 3.589-8 8s3.589 8 8 8 8-3.589 8-8-3.589-8-8-8zm-5 8c0-.832.224-1.604.584-2.295l6.711 6.711A4.943 4.943 0 0112 17c-2.757 0-5-2.243-5-5zm9.416 2.295L9.705 7.584A4.943 4.943 0 0112 7c2.757 0 5 2.243 5 5 0 .832-.224 1.604-.584 2.295z"})}),ge=({size:e,style:n,className:r})=>t("svg",{viewBox:"0 0 512 512",fill:"currentColor",width:e,height:e,className:r,style:n,children:t("path",{d:"M233.4 406.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L256 338.7 86.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z"})}),me=({name:e,nodeData:r})=>{var o,i,a,l,s,c,d;const{getStyles:u,icons:p}=W(),g={size:"1.4em",className:"jer-icon"};switch(e){case"add":return null!==(o=null==p?void 0:p.add)&&void 0!==o?o:t(le,Object.assign({},g,{style:u("iconAdd",r)}));case"edit":return null!==(i=null==p?void 0:p.edit)&&void 0!==i?i:t(se,Object.assign({},g,{style:u("iconEdit",r)}));case"delete":return null!==(a=null==p?void 0:p.delete)&&void 0!==a?a:t(ce,Object.assign({},g,{style:u("iconDelete",r),size:"1.45em"}));case"copy":return null!==(l=null==p?void 0:p.copy)&&void 0!==l?l:t(de,Object.assign({},g,{style:u("iconCopy",r),size:"1.2em"}));case"ok":return null!==(s=null==p?void 0:p.ok)&&void 0!==s?s:t(ue,Object.assign({},g,{style:Object.assign({fontSize:"90%"},u("iconOk",r))}));case"cancel":return null!==(c=null==p?void 0:p.cancel)&&void 0!==c?c:t(pe,Object.assign({},g,{style:Object.assign({fontSize:"130%"},u("iconCancel",r))}));case"chevron":return null!==(d=null==p?void 0:p.chevron)&&void 0!==d?d:t(ge,{size:"1em",style:u("iconCollection",r)});default:return t(n,{})}},he=({startEdit:r,handleDelete:o,handleAdd:a,enableClipboard:l,type:s,customButtons:c,nodeData:d,translate:u,keyboardControls:p,handleKeyboard:m,editConfirmRef:h,getNewKeyOptions:y,jsonStringify:f,onEditEvent:b,showIconTooltips:v})=>{const{getStyles:j}=W(),E=u("KEY_NEW",d),[w,D]=i(E),[C,O]=i(!1),{key:k,path:S,value:N}=d,T=Array.isArray(C),x=e=>{var t;if(b&&b(e?[...S,null]:null,e),!e)return void O(!1);const n=Object.keys(g(d.fullData,S)),r=y?null===(t=y(d))||void 0===t?void 0:t.filter(e=>!n.includes(e)):null;r&&D(""),O(null==r||r)};return e("div",{className:"jer-edit-buttons",style:{opacity:C?1:void 0},onClick:e=>e.stopPropagation(),children:[l&&t("div",{onClick:e=>{var t;e.stopPropagation();let n,r,o="value",i="",a=null;if(l){const s=A(e);if(s&&p.clipboardModifier.includes(s)?(n=fe(S),i=n,o="path"):(n=N,i="object"==typeof n?f(N):String(n)),!navigator.clipboard)return void("function"==typeof l&&l({success:!1,value:n,stringValue:i,path:S,key:k,type:o,errorMessage:"Can't access clipboard API"}));null===(t=navigator.clipboard)||void 0===t||t.writeText(i).then(()=>r=!0).catch(e=>{r=!1,a=e.message}).finally(()=>{"function"==typeof l&&l({success:r,errorMessage:a,value:n,stringValue:i,path:S,key:k,type:o})})}},className:"jer-copy-pulse",title:v?u("TOOLTIP_COPY",d):"",children:t(me,{name:"copy",nodeData:d})}),r&&t("div",{onClick:r,title:v?u("TOOLTIP_EDIT",d):"",children:t(me,{name:"edit",nodeData:d})}),o&&t("div",{onClick:o,title:v?u("TOOLTIP_DELETE",d):"",children:t(me,{name:"delete",nodeData:d})}),a&&t("div",{onClick:()=>{"object"===s?x(!0):a("")},title:v?u("TOOLTIP_ADD",d):"",children:t(me,{name:"add",nodeData:d})}),null==c?void 0:c.map(({Element:e,onClick:n},r)=>t("div",{onClick:e=>n&&n(d,e),children:t(e,{nodeData:d})},r)),C&&a&&"object"===s&&e(n,{children:[T?e("div",{className:"jer-select jer-select-keys",children:[e("select",{name:"new-key-select",className:"jer-select-inner",onChange:e=>{a(e.target.value),x(!1)},defaultValue:"",autoFocus:!0,onKeyDown:e=>{m(e,{cancel:()=>x(!1)})},children:[t("option",{value:"",disabled:!0,children:C.length>0?u("KEY_SELECT",d):u("NO_KEY_OPTIONS",d)}),C.map(e=>t("option",{value:e,children:e},e))]}),t("span",{className:"focus"})]}):t("input",{className:"jer-input-new-key",type:"text",name:"new-object-key",value:w,onChange:e=>D(e.target.value),autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>{m(e,{stringConfirm:()=>{a&&(x(!1),a(w),D(E))},cancel:()=>{x(!1),D(E)}})},style:j("input",d)}),t(ye,{onOk:()=>{T&&!w||(x(!1),a(w))},onCancel:()=>{x(!1)},nodeData:d,editConfirmRef:h,hideOk:T})]})]})},ye=({onOk:n,onCancel:r,nodeData:o,editConfirmRef:i,hideOk:a=!1})=>e("div",{className:"jer-confirm-buttons",children:[!a&&t("div",{onClick:n,ref:i,children:t(me,{name:"ok",nodeData:o})}),t("div",{onClick:r,children:t(me,{name:"cancel",nodeData:o})})]}),fe=e=>e.reduce((e,t)=>"number"==typeof t?`${e}[${t}]`:""===e?t:`${e}.${t}`,""),be=["string","number","boolean","null","object","array"],ve=({props:e,collapsed:t})=>{const{data:n,nodeData:r,parentData:o,onEdit:a,onError:l,showErrorMessages:c,restrictEditFilter:d,restrictDeleteFilter:u,restrictAddFilter:p,restrictDragFilter:g,translate:m,errorMessageTimeout:h}=e,{currentlyEditingElement:y,setCurrentlyEditingElement:f}=J(),[b,v]=i(null),j=Object.assign(Object.assign({},r),{collapsed:t}),{path:E,key:w,size:D}=j,C=T(E),O=!d(j),k=!u(j),S=!p(j),N=!g(j)&&k&&null===y,A=e=>{c&&(v(e),setTimeout(()=>v(null),h)),console.warn("Error",e)},x=s((e,t)=>{A(e.message),l&&l({currentData:j.fullData,errorValue:t,currentValue:n,name:w,path:E,error:e})},[l,c]),P=y===C,K=y===`key_${C}`,R="number"==typeof E.slice(-1)[0],I={isEditing:P,isEditingKey:K,isArray:R,canEditKey:null!==o&&O&&S&&k&&!R},V=""===w&&E.length>0?m("EMPTY_STRING",j):null;return{pathString:C,nodeData:j,path:E,name:w,size:D,canEdit:O,canDelete:k,canAdd:S,canDrag:N,error:b,showError:A,onError:x,setError:v,handleEditKey:e=>{if(f(null),w===e)return;if(!o)return;const t=E.slice(0,-1);if(Object.keys(o).includes(e))return void x({code:"KEY_EXISTS",message:m("ERROR_KEY_EXISTS",j)},e);const n=Object.fromEntries(Object.entries(o).map(([t,n])=>t===w?[e,n]:[t,n]));a(n,t).then(t=>{t&&x({code:"UPDATE_ERROR",message:t},e)})},derivedValues:I,emptyStringKey:V}},je=({canDrag:e,canDragOnto:n,path:r,nodeData:o,onMove:a,onError:l,translate:s})=>{const{getStyles:d}=W(),{dragSource:u,setDragSource:p}=J(),[g,m]=i(!1),h=T(r),y=c(()=>e?{onDragStart:e=>{e.stopPropagation(),p({path:r,pathString:h})},onDragEnd:e=>{e.stopPropagation(),p({path:null,pathString:null})}}:{},[e,h]),f=c(()=>e=>n?{onDragOver:e=>{e.stopPropagation(),e.preventDefault()},onDrop:t=>{t.stopPropagation(),v(e),p({path:null,pathString:null}),m(!1)},onDragEnter:t=>{var n;t.stopPropagation(),h.startsWith(null!==(n=u.pathString)&&void 0!==n?n:"")||m(e)},onDragExit:e=>{e.stopPropagation(),m(!1)}}:{},[u,n,h]),b=c(()=>n&&null!==u.pathString?t("div",Object.assign({className:"jer-drop-target-bottom",style:{height:"50%",position:"absolute",width:"100%",top:"50%",zIndex:r.length}},f("below"))):null,[u,n,r.length]),v=e=>{var t,n;const i=null===(t=u.path)||void 0===t?void 0:t.slice(-1)[0],c=null===(n=u.path)||void 0===n?void 0:n.slice(0,-1).join("."),d=r.slice(0,-1).join(""),{parentData:p}=o;"string"==typeof i&&p&&!Array.isArray(p)&&Object.keys(p).includes(i)&&i in p&&c!==d?l({code:"KEY_EXISTS",message:s("ERROR_KEY_EXISTS",o)},i):a(u.path,r,e).then(e=>{e&&l({code:"UPDATE_ERROR",message:e},o.value)})};return{dragSourceProps:y,getDropTargetProps:f,BottomDropTarget:b,DropTargetPadding:({position:e,nodeData:n})=>g===e?t("div",{className:"jer-drag-n-drop-padding",style:d("dropZone",n)}):null,handleDrop:v}},Ee=(e,t,n,r)=>{var o,i,a;if(!t.current)return 0;const l=parseInt(null!==(o=getComputedStyle(n.current).getPropertyValue("line-height"))&&void 0!==o?o:"16px"),s=(null!==(a=null===(i=t.current)||void 0===i?void 0:i.offsetWidth)&&void 0!==a?a:0)/(.5*l),c=r(e).replace(/\\n/g,"\n").split("\n").map(e=>Math.ceil(e.length/s)).reduce((e,t)=>e+t,0)*l;return Math.min(c+30,window.innerHeight-50)},we=({isEditingKey:n,canEditKey:r,pathString:o,path:i,name:a,arrayIndexFromOne:l,handleKeyboard:s,handleEditKey:c,handleCancel:d,handleClick:u,keyValueArray:p,styles:g,getNextOrPrevious:m,emptyStringKey:h,nodeData:y,customNodeData:f,getStyles:b})=>{const{setCurrentlyEditingElement:v}=J(),j="number"==typeof a?String(a+(l?1:0)):a;if(!n){const n=Object.assign(Object.assign({},g),{minWidth:`${Math.min(j.length+1,5)}ch`,flexShrink:j.length>10?1:0});if((null==f?void 0:f.CustomKey)&&y&&b){const{CustomKey:e,customNodeProps:o}=f;return t(e,{nodeData:y,name:null!=h?h:j,path:i,canEditKey:r,handleEditKey:e=>{r&&c(e)},setIsEditingKey:()=>{r&&v(i,"key")},handleClick:u,styles:n,customNodeProps:o,getStyles:b})}return e("span",{className:"jer-key-text",style:n,onDoubleClick:()=>r&&v(i,"key"),onClick:u,children:[h?t("span",{className:"jer-empty-string",children:h}):j,""!==j||h?t("span",{className:"jer-key-colon",children:":"}):null]})}return t("input",{className:"jer-input-text jer-key-edit",type:"text",name:o,defaultValue:j,autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>s(e,{stringConfirm:()=>c(e.target.value),cancel:d,tabForward:()=>{if(c(e.target.value),p){const e=null==p?void 0:p[0][0];v(e?[...i,e]:m("next"))}else v(i)},tabBack:()=>{c(e.target.value),v(m("prev"))}}),style:{width:j.length/1.5+.5+"em"}})},De=n=>{const{data:r,parentData:o,onEdit:a,onDelete:d,onChange:u,onMove:p,enableClipboard:g,canDragOnto:m,restrictTypeSelection:h,searchFilter:y,searchText:f,showLabel:b,stringTruncate:v,showStringQuotes:j,arrayIndexFromOne:E,indent:w,translate:D,customNodeDefinitions:C,customNodeData:k,handleKeyboard:S,keyboardControls:N,sort:T,editConfirmRef:A,jsonStringify:x,showIconTooltips:P}=n,{getStyles:K}=W(),{setCurrentlyEditingElement:I,setCollapseState:V,previouslyEditedElement:_,setPreviouslyEditedElement:F,tabDirection:L,setTabDirection:z,previousValue:M,setPreviousValue:B}=J(),[G,Y]=i("function"==typeof r?Q:r),{pathString:$,nodeData:U,path:H,name:Z,canEdit:X,canDelete:q,canDrag:ee,error:te,onError:ne,handleEditKey:re,emptyStringKey:oe,derivedValues:ie}=ve({props:n}),{dragSourceProps:ae,getDropTargetProps:le,BottomDropTarget:se,DropTargetPadding:ce}=je({canDrag:ee,canDragOnto:m,path:H,nodeData:U,onMove:p,onError:ne,translate:D}),[de,ue]=i(Ce(r,k)),pe=s(e=>{if(!u)return void Y(e);const t=u({currentData:U.fullData,newValue:e,currentValue:G,name:Z,path:H});Y(t)},[u]);l(()=>{Y("function"==typeof r?Q:r),ue(Ce(r,k))},[r,te]);const{CustomNode:ge,customNodeProps:me,hideKey:fe,showEditTools:Ee=!0,showOnEdit:De,showOnView:Se,passOriginalNode:Ne}=k,Te=[...be,...C.filter(({showInTypesSelector:e=!1,name:t})=>e&&!!t).map(({name:e})=>e)],Ae=c(()=>{if("boolean"==typeof h)return h?[]:Te;if(Array.isArray(h))return h;const e=h(U);return"boolean"==typeof e?e?[]:Te:e},[U,h]),[xe,Pe]=i(((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})(G,Ae)),{isEditing:Ke}=ie,Re=O("value",U,y,f);if(Ke&&(!Re||!X)){const e=R(U.fullData,H,L,T);I(e||_)}if(!Re)return null;const Ie=e=>{let t;if(I(null),B(null),void 0===e||(e=>e&&"object"==typeof e&&"type"in e&&"target"in e&&"preventDefault"in e&&"function"==typeof e.preventDefault)(e))switch(de){case"object":t={[D("DEFAULT_NEW_KEY",U)]:G};break;case"array":t=null!=G?G:[];break;case"number":{const e=Number(G);t=isNaN(e)?0:e;break}default:t=G}else t=e;a(t,H).then(e=>{e&&ne({code:"UPDATE_ERROR",message:e},t)})},Ve=()=>{I(null),null===M?(Y(r),B(null)):a(M,H)},{isEditingKey:_e,canEditKey:Fe}=ie,Le=!Ke&&te,ze=Ke&&Ae.length>1,Me=("invalid"!==de||ge)&&!te&&Ee,Be=b&&!fe,We=ge&&(Ke&&De||!Ke&&Se),Ge={value:G,parentData:o,setValue:pe,isEditing:Ke,canEdit:X,setIsEditing:X?()=>I(H):()=>{},handleEdit:Ie,handleCancel:Ve,path:H,stringTruncate:v,showStringQuotes:j,nodeData:U,enumType:xe,translate:D,handleKeyboard:S,keyboardCommon:{cancel:Ve,tabForward:()=>{z("next"),F($);const e=R(U.fullData,H,"next",T);e&&(Ie(),I(e))},tabBack:()=>{z("prev"),F($);const e=R(U.fullData,H,"prev",T);e&&(Ie(),I(e))}}},Ye={canEditKey:Fe,isEditingKey:_e,pathString:$,path:H,name:Z,arrayIndexFromOne:E,handleKeyboard:S,handleEditKey:re,handleCancel:Ve,styles:K("property",U),getNextOrPrevious:e=>R(U.fullData,H,e,T),emptyStringKey:oe,nodeData:U,customNodeData:k,getStyles:K},$e=We?t(ge,Object.assign({},n,{value:G,customNodeProps:me,setValue:pe,handleEdit:Ie,handleCancel:Ve,handleKeyPress:e=>S(e,{stringConfirm:Ie,cancel:Ve}),isEditing:Ke,setIsEditing:()=>I(H),getStyles:K,originalNode:Ne?Oe(r,Ge):void 0,originalNodeKey:Ne?t(we,Object.assign({},Ye,{customNodeData:void 0})):void 0,canEdit:X,keyboardCommon:Ge.keyboardCommon,onError:ne})):Oe(r,Ge);return e("div",Object.assign({className:"jer-component jer-value-component",style:{marginLeft:null!==o?w/2+"em":0,position:"relative"},draggable:ee},ae,le("above"),{children:[se,t(ce,{position:"above",nodeData:U}),e("div",{className:"jer-value-main-row",style:{flexWrap:Z.length>10?"wrap":"nowrap"},children:[Be&&t(we,Object.assign({},Ye)),e("div",{className:"jer-value-and-buttons",children:[t("div",{className:"jer-input-component",children:$e}),Ke?t(ye,{onOk:Ie,onCancel:Ve,nodeData:U,editConfirmRef:A}):Me&&t(he,{startEdit:X?()=>{B(M),I(H,Ve)}:void 0,handleDelete:q?()=>{d(G,H).then(e=>{e&&ne({code:"DELETE_ERROR",message:e},G)})}:void 0,enableClipboard:g,translate:D,customButtons:n.customButtons,nodeData:U,handleKeyboard:S,keyboardControls:N,editConfirmRef:A,jsonStringify:x,showIconTooltips:P}),ze&&e("div",{className:"jer-select jer-select-types",children:[t("select",{name:`${Z}-type-select`,className:"jer-select-inner",onChange:e=>(e=>{const t=C.find(t=>t.name===e);if(t)return a(t.defaultValue,H),ue(e),Pe(null),I(null),void V({path:H,collapsed:!1,includeChildren:!1});const n=Ae.find(t=>t instanceof Object&&t.enum===e);if(n)return"string"==typeof G&&n.values.includes(G)||a(n.values[0],H).then(e=>{e&&(ne({code:"UPDATE_ERROR",message:e},r),I(null))}),void Pe(n);const r=ke(G,e,D("DEFAULT_NEW_KEY",U),(null==k?void 0:k.CustomNode)?D("DEFAULT_STRING",U):void 0);["string","number","boolean"].includes(e)||I(null),a(r,H).then(e=>{e?(ne({code:"UPDATE_ERROR",message:e},r),I(null)):Pe(null)})})(e.target.value),value:xe?xe.enum:de,children:Ae.map(e=>e instanceof Object&&"enum"in e?t("option",{value:e.enum,children:e.enum},e.enum):t("option",{value:e,children:e},e))}),t("span",{className:"focus"})]}),Le&&t("span",{className:"jer-error-slug",style:K("error",U),children:te})]})]}),t(ce,{position:"below",nodeData:U})]}))},Ce=(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",Oe=(e,n)=>{const r=Ce(e),{value:o}=n;switch(r){case"string":return t(te,Object.assign({},n,{value:o}));case"number":return t(ne,Object.assign({},n,{value:o}));case"boolean":return t(re,Object.assign({},n,{value:o}));case"null":return t(ie,Object.assign({},n));default:return t(ae,Object.assign({},n))}},ke=(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=(e=[],t)=>{const n=e.filter(({condition:e})=>e(t));if(0===n.length)return{};const r=n[0],{element:o,wrapperElement:i,customKey:a,customNodeProps:l,wrapperProps:s,hideKey:c=!1,showEditTools:u=!0,showOnEdit:p=!1,showOnView:g=!0,showCollectionWrapper:m=!0}=r,h=d(r,["element","wrapperElement","customKey","customNodeProps","wrapperProps","hideKey","showEditTools","showOnEdit","showOnView","showCollectionWrapper"]);return Object.assign({CustomNode:o,CustomWrapper:i,CustomKey:a,customNodeProps:l,wrapperProps:s,hideKey:c,showEditTools:u,showOnEdit:p,showOnView:g,showCollectionWrapper:m},h)},Ne=r=>{const{getStyles:o}=W(),{collapseState:c,setCollapseState:d,getMatchingCollapseState:p,currentlyEditingElement:g,setCurrentlyEditingElement:m,areChildrenBeingEdited:h,previousValue:y,setPreviousValue:f}=J(),{mainContainerRef:b,data:v,nodeData:j,parentData:E,showCollectionCount:w,onEdit:k,onAdd:S,onDelete:N,canDragOnto:T,collapseFilter:x,collapseAnimationTime:P,onMove:K,enableClipboard:I,onEditEvent:V,showIconTooltips:F,searchFilter:L,searchText:z,indent:M,sort:B,showArrayIndices:G,arrayIndexFromOne:Y,defaultValue:$,newKeyOptions:U,translate:H,customNodeDefinitions:Z,customNodeData:X,jsonParse:Q,jsonStringify:q,TextEditor:ee,keyboardControls:te,handleKeyboard:ne,insertAtTop:re,onCollapse:oe,editConfirmRef:ie,collapseClickZones:ae}=r,[le,se]=i(q(v)),ce=x(j),{contentRef:de,isAnimating:ue,maxHeight:pe,collapsed:ge,animateCollapse:fe,cssTransitionValue:be}=((e,t,n,r,o)=>{const[l,c]=i(n?0:void 0),[d,u]=i(n),p=a(!1),g=a(null),m=a(0),h=a(0),y=t/1e3+"s",f=s(n=>{var i,a;if(d!==n){switch(window.clearTimeout(h.current),p.current=!0,n){case!0:{const e=null!==(a=null===(i=g.current)||void 0===i?void 0:i.offsetHeight)&&void 0!==a?a:0;m.current=e,c(e),setTimeout(()=>{c(0)},5);break}case!1:c(m.current||Ee(e,g,r,o))}u(!d),h.current=window.setTimeout(()=>{p.current=!1,n||c(void 0)},t)}},[t,d,e,r,o]);return{contentRef:g,isAnimating:p.current,animateCollapse:f,maxHeight:l,collapsed:d,cssTransitionValue:y}})(v,P,ce,b,q),{pathString:Ce,nodeData:Oe,path:ke,name:Te,size:Ae,canEdit:xe,canDelete:Pe,canAdd:Ke,canDrag:Re,error:Ie,setError:Ve,onError:_e,handleEditKey:Fe,emptyStringKey:Le,derivedValues:ze}=ve({props:r,collapsed:ge}),{dragSourceProps:Me,getDropTargetProps:Be,BottomDropTarget:We,DropTargetPadding:Ge}=je({canDrag:Re,canDragOnto:T,path:ke,nodeData:Oe,onMove:K,onError:_e,translate:H}),Ye=a(!ce),{isEditing:$e,isEditingKey:Ue,isArray:He,canEditKey:Ze}=ze;l(()=>{se(q(v))},[v]),l(()=>{const e=x(Oe)&&!$e;Ye.current=!e,fe(e)},[x]),l(()=>{if(null!==c){const e=p(ke);e&&(Ye.current=!0,fe(e.collapsed))}},[c]);const Je=a(null),Xe=s((e,t)=>{if("function"!=typeof $)return $;const n=$(e,t);return void 0!==n?n:null},[$]),Qe=s(e=>U?"function"!=typeof U?U:U(e):null,[U]),{CustomNode:qe,customNodeProps:et,CustomWrapper:tt,wrapperProps:nt={},hideKey:rt,showEditTools:ot=!0,showOnEdit:it,showOnView:at,showCollectionWrapper:lt=!0}=X,st=h(Ce);st&&ge&&fe(!1);if(!(O("collection",Oe,L,z)||0===Oe.level)&&!st)return null;const ct=Array.isArray(v)?"array":"object",dt="array"===ct?{open:"[",close:"]"}:{open:"{",close:"}"},ut=e=>{if("Tab"===e.key&&!e.getModifierState("Shift")){e.preventDefault();const t=_(Je,"\t");return void se(t)}ne(e,{objectConfirm:gt,cancel:ht})},pt=e=>{e.stopPropagation();const t=A(e);if(t&&te.collapseModifier.includes(t))return Ye.current=!0,void d({collapsed:!ge,path:ke,includeChildren:!0});g&&g.includes(Ce)||(Ye.current=!0,d(null),oe&&oe({path:ke,collapsed:!ge,includeChildren:!1}),fe(!ge))},gt=()=>{try{const e=Q(le);if(m(null),f(null),Ve(null),q(e)===q(v))return;k(e,ke).then(t=>{t&&_e({code:"UPDATE_ERROR",message:t},e)})}catch(e){_e({code:"INVALID_JSON",message:H("ERROR_INVALID_JSON",Oe)},le)}},mt=ke.length>0?()=>{N(v,ke).then(e=>{e&&_e({code:"DELETE_ERROR",message:e},v)})}:void 0,ht=()=>{m(null),null===y?(Ve(null),se(q(v)),f(null)):k(y,ke)},yt="when-closed"===w?ge:w,ft=!$e&&ot,bt=(G||!He)&&!rt&&void 0!==Te,vt=qe&&($e&&it||!$e&&at),jt=Object.entries(v).map(([e,t])=>["array"===ct?Number(e):e,t]);"object"===ct&&B(jt,e=>e);const Et=Ye.current?$e?e("div",{className:"jer-collection-text-edit",children:[ee?t(ee,{value:le,onChange:se,onKeyDown:e=>ne(e,{objectConfirm:gt,cancel:ht})}):t(D,{textAreaRef:Je,className:"jer-collection-text-area",name:Ce,value:le,setValue:se,handleKeyPress:ut,styles:o("input",Oe)}),t("div",{className:"jer-collection-input-button-row",children:t(ye,{onOk:gt,onCancel:ht,nodeData:Oe,editConfirmRef:ie})})]}):jt.map(([e,n],i)=>{const a={key:e,value:n,path:[...ke,e],level:ke.length+1,index:i,size:C(n)?Object.keys(n).length:null,parentData:v,fullData:Oe.fullData},l=Se(Z,a);return t("div",{className:"jer-collection-element",style:o("collectionElement",a),children:C(n)&&!(null==l?void 0:l.renderCollectionAsValue)?t(Ne,Object.assign({},r,{data:n,parentData:v,nodeData:a,showCollectionCount:w,canDragOnto:xe,customNodeData:l}),e):t(De,Object.assign({},r,{data:n,parentData:v,nodeData:a,canDragOnto:xe,showLabel:"object"===ct||G,customNodeData:l}),e)},e)}):null,wt=!!lt&&(ge&&!st);wt||(Ye.current=!0);const Dt=Object.assign(Object.assign({},r),{data:v,value:v,parentData:E,nodeData:Oe,setValue:e=>u(void 0,void 0,void 0,function*(){return yield k(e,ke)}),handleEdit:gt,handleCancel:ht,handleKeyPress:ut,isEditing:$e,setIsEditing:()=>m(ke),getStyles:o,canDragOnto:xe,canEdit:xe,keyboardCommon:{},onError:_e}),Ct=vt?t(qe,Object.assign({customNodeProps:et},Dt,{children:Et})):Et,Ot=ft&&t(he,{startEdit:xe?()=>{Ye.current=!0,f(null),m(ke)}:void 0,handleAdd:Ke?e=>{fe(!1);const t=Xe(Oe,e);if("array"===ct){const e=re.array?0:v.length,n=re.array?{insert:!0}:{};S(t,[...ke,e],n).then(e=>{e&&_e({code:"ADD_ERROR",message:e},t)})}else if(e in v)_e({code:"KEY_EXISTS",message:H("ERROR_KEY_EXISTS",Oe)},e);else{const n=re.object?{insertBefore:0}:{};S(t,[...ke,e],n).then(e=>{e&&_e({code:"ADD_ERROR",message:e},t)})}}:void 0,handleDelete:Pe?mt:void 0,enableClipboard:I,type:ct,nodeData:Oe,translate:H,customButtons:r.customButtons,keyboardControls:te,handleKeyboard:ne,getNewKeyOptions:Qe,editConfirmRef:ie,jsonStringify:q,onEditEvent:V,showIconTooltips:F}),kt={canEditKey:Ze,isEditingKey:Ue,pathString:Ce,path:ke,name:Te,arrayIndexFromOne:Y,handleKeyboard:ne,handleEditKey:Fe,handleCancel:ht,keyValueArray:jt,styles:o("property",Oe),getNextOrPrevious:e=>R(Oe.fullData,ke,e,B),handleClick:ae.includes("property")?pt:e=>e.stopPropagation(),emptyStringKey:Le,nodeData:Oe,customNodeData:X,getStyles:o},St=e("div",Object.assign({className:"jer-component jer-collection-component",style:Object.assign(Object.assign({marginLeft:(0===ke.length?0:M/2)+"em"},o("collection",Oe)),{position:"relative"}),draggable:Re},Me,Be("above"),{children:[t("div",{className:"jer-clickzone",style:{width:M/2+1+"em",zIndex:10+2*Oe.level},onClick:ae.includes("left")?pt:void 0}),!$e&&We,t(Ge,{position:"above",nodeData:Oe}),lt?e("div",{className:"jer-collection-header-row",style:{position:"relative"},onClick:ae.includes("header")?pt:void 0,children:[e("div",{className:"jer-collection-name",children:[t("div",{className:"jer-collapse-icon jer-accordion-icon"+(ge?" jer-rotate-90":""),style:{zIndex:11+2*Oe.level,transition:be},onClick:pt,children:t(me,{name:"chevron",rotate:ge,nodeData:Oe})}),bt&&t(we,Object.assign({},kt)),!$e&&t("span",{className:"jer-brackets jer-bracket-open",style:o("bracket",Oe),children:dt.open})]}),!$e&&yt&&t("div",{className:"jer-collection-item-count"+(yt?" jer-visible":" jer-hidden"),style:Object.assign(Object.assign({},o("itemCount",Oe)),{transition:be}),children:1===Ae?H("ITEM_SINGLE",Object.assign(Object.assign({},Oe),{size:1}),1):H("ITEMS_MULTIPLE",Oe,Ae)}),t("div",{className:"jer-brackets"+(wt?" jer-visible":" jer-hidden"),style:Object.assign(Object.assign({},o("bracket",Oe)),{transition:be}),children:dt.close}),Ot]}):rt?t(n,{}):e("div",{className:"jer-collection-header-row",style:{position:"relative"},children:[t(we,Object.assign({},kt)),Ot]}),e("div",{className:"jer-collection-inner",style:Object.assign(Object.assign({overflowY:wt||ue?"clip":"visible",maxHeight:st?void 0:pe},o("collectionInner",Oe)),{transition:be}),ref:de,children:[Ct,t("div",{className:$e?"jer-collection-error-row":"jer-collection-error-row-edit",children:Ie&&t("span",{className:"jer-error-slug",style:o("error",Oe),children:Ie})}),!$e&<&&t("div",{className:"jer-brackets jer-bracket-outside",style:o("bracket",Oe),children:dt.close})]}),t(Ge,{position:"below",nodeData:Oe})]}));return tt?t(tt,Object.assign({customNodeProps:nt},Dt,{children:St})):St},Te={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)",EMPTY_STRING:"<empty string>",TOOLTIP_COPY:"Copy to clipboard",TOOLTIP_EDIT:"Edit",TOOLTIP_DELETE:"Delete",TOOLTIP_ADD:"Add"},Ae=(e,t)=>(n,r,o)=>((e,t,n,r,o)=>{if(t[r]){const e=t[r](n);if(null!==e)return e}const i=r in e?e[r]:Te[r];return void 0===o?i:null==i?void 0:i.replace("{{count}}",String(o))})(e,t,r,n,o);var xe=[],Pe=[];!function(e,t){if(e&&"undefined"!=typeof document){var n,r=!0===t.prepend?"prepend":"append",o=!0===t.singleTag,i="string"==typeof t.container?document.querySelector(t.container):document.getElementsByTagName("head")[0];if(o){var a=xe.indexOf(i);-1===a&&(a=xe.push(i)-1,Pe[a]={}),n=Pe[a]&&Pe[a][r]?Pe[a][r]:Pe[a][r]=l()}else n=l();65279===e.charCodeAt(0)&&(e=e.substring(1)),n.styleSheet?n.styleSheet.cssText+=e:n.appendChild(document.createTextNode(e))}function l(){var e=document.createElement("style");if(e.setAttribute("type","text/css"),t.attributes)for(var n=Object.keys(t.attributes),o=0;o<n.length;o++)e.setAttribute(n[o],t.attributes[n[o]]);var a="prepend"===r?"afterbegin":"beforeend";return i.insertAdjacentElement(a,e),e}}(':root{--jer-select-border:#b6b6b6;--jer-select-focus:#777;--jer-select-arrow:#777;--jer-form-border:1px solid #ededf0;--jer-form-border-focus:1px solid #e2e2e2;--jer-highlight-color:#b3d8ff}.jer-visible{opacity:1}.jer-hidden{opacity:0}.jer-select select{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:transparent;border:none;color:#000;cursor:inherit;font-family:inherit;font-size:.8em;line-height:inherit;margin:0;outline:none;padding:0 1em 0 0;z-index:1}select::-ms-expand{display:none}.jer-select{align-items:center;background-color:#fff;background-image:linear-gradient(0deg,#f9f9f9,#fff 33%);border:1px solid var(--jer-select-border);border-radius:.25em;cursor:pointer;display:grid;grid-template-areas:"select";line-height:1.1;max-width:15ch;min-width:12ch;padding:.25em .5em;position:relative}.jer-select select,.jer-select:after{grid-area:select}.jer-select:not(.jer-select--multiple):after{background-color:var(--jer-select-arrow);clip-path:polygon(100% 0,0 0,50% 100%);content:"";height:.5em;justify-self:end;width:.8em}select:focus+.focus{border:1px solid var(--jer-select-focus);border-radius:inherit;bottom:-1px;left:-1px;position:absolute;right:-1px;top:-1px}.jer-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-bracket-outside{padding-left:0}.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{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 Ke=(e,t)=>JSON.stringify(e,t,2),Re=({data:e,setData:n,rootName:r="root",onUpdate:o=()=>{},onEdit:d=o,onDelete:p=o,onAdd:g=o,onChange:m,onError:h,onEditEvent:y,showErrorMessages:f=!0,enableClipboard:b=!0,indent:v=2,collapse:j=!1,collapseAnimationTime:E=300,showCollectionCount:w=!0,restrictEdit:D=!1,restrictDelete:O=!1,restrictAdd:k=!1,restrictTypeSelection:S=!1,restrictDrag:N=!0,viewOnly:A,searchFilter:P,searchText:R,searchDebounceTime:I=350,keySort:V=!1,showArrayIndices:_=!0,arrayIndexFromOne:L=!1,showStringQuotes:z=!0,showIconTooltips:M=!1,defaultValue:B=null,newKeyOptions:G,minWidth:Y=250,maxWidth:$="min(600px, 90vw)",rootFontSize:U,stringTruncate:H=250,translations:Z={},className:X,id:Q,customText:q={},customNodeDefinitions:ee=[],customButtons:te=[],jsonParse:ne=JSON.parse,jsonStringify:re=Ke,TextEditor:oe,errorMessageTimeout:ie=2500,keyboardControls:ae={},externalTriggers:le,insertAtTop:se=!1,onCollapse:ce,collapseClickZones:de=["header","left"]})=>{const{getStyles:ue}=W(),{setCurrentlyEditingElement:pe}=J(),ge=c(()=>_e(j),[j]),me=c(()=>Ae(Z,q),[Z,q]),[he,ye]=i(R),[fe,be]=(({setData:e,data:t})=>{const[n,r]=i(e?void 0:t),o=s(t=>{e?e(t):r(t)},[e]);return l(()=>{e||r(t)},[t]),[e?t:n,o]})({setData:n,data:e}),ve=a(null);l(()=>{pe(null);const e=setTimeout(()=>ye(R),I);return()=>clearTimeout(e)},[R,I]);const je={key:r,path:[],level:0,index:0,value:fe,size:"object"==typeof fe&&null!==fe?Object.keys(fe).length:1,parentData:null,fullData:fe},Ee=(e,t)=>u(void 0,void 0,void 0,function*(){const n=yield e(t);if(!0===n||void 0===n)return void be(t.newData);const r=Le(n)?n:["error",n],[o,i]=r;if("error"===o)return be(t.currentData),!1===i?me("ERROR_UPDATE",je):String(i);be(i)}),we=c(()=>_e(D,A),[D,A]),Ce=c(()=>_e(O,A),[O,A]),Oe=c(()=>_e(k,A),[k,A]),ke=c(()=>_e(N,A),[N,A]),Te=c(()=>Fe(P),[P]),xe=c(()=>(e=>{const t=Object.assign({},K);for(const n of Object.keys(K)){const r=n;if(e[r]){const o=e[r],i=(()=>["clipboardModifier","collapseModifier"].includes(n)?Array.isArray(o)?o:[o]:"string"==typeof o?{key:o}:o)();t[r]=i,["stringConfirm","numberConfirm","booleanConfirm"].forEach(n=>{!e[n]&&e.confirm&&(t[n]=t.confirm)})}}return t})(ae),[ae]),Pe=s((e,t)=>((e,t,n)=>{const r=Object.entries(t);for(const[t,o]of r)if(x(n,e[t],t)){n.preventDefault(),o();break}})(xe,t,e),[xe]),Re=c(()=>{const e=ze(ee,"stringifyReplacer");return t=>re(t,e)},[ee,re]),Ie=c(()=>{const e=ze(ee,"parseReviver");return t=>{const n=ne(t,e);return F(n)}},[ee,ne]),Me=a(null);((e,t)=>{const{setCurrentlyEditingElement:n,currentlyEditingElement:r,setCollapseState:o}=J();l(()=>{if(!e)return;const{collapse:i,edit:a}=e;i&&o(i);const l=!(null==a?void 0:a.path)||T(a.path)===r;switch(null==a?void 0:a.action){case"accept":l&&(t.current&&t.current.click(),n(null));break;case"cancel":l&&n(null);break;default:(null==a?void 0:a.path)&&n(a.path)}},[e])})(le,Me);const Be=s((e,t)=>{!1!==V&&("function"!=typeof V?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)=>V(t(e),t(n))))},[V]),We=Se(ee,je),Ge={mainContainerRef:ve,name:r,nodeData:je,onEdit:(e,t)=>u(void 0,void 0,void 0,function*(){const{currentData:n,newData:r,currentValue:o,newValue:i}=Ve(fe,t,e,"update");if(o!==i)return yield Ee(d,{currentData:n,newData:r,currentValue:o,newValue:i,name:t.slice(-1)[0],path:t})}),onDelete:(e,t)=>u(void 0,void 0,void 0,function*(){const{currentData:n,newData:r,currentValue:o,newValue:i}=Ve(fe,t,e,"delete");return yield Ee(p,{currentData:n,newData:r,currentValue:o,newValue:i,name:t.slice(-1)[0],path:t})}),onAdd:(e,t,n)=>u(void 0,void 0,void 0,function*(){const{currentData:r,newData:o,currentValue:i,newValue:a}=Ve(fe,t,e,"add",n);return yield Ee(g,{currentData:r,newData:o,currentValue:i,newValue:a,name:t.slice(-1)[0],path:t})}),onChange:m,onError:h,onEditEvent:y,showErrorMessages:f,onMove:(e,t,n)=>u(void 0,void 0,void 0,function*(){if(null===e)return;const{currentData:r,newData:o,currentValue:i}=Ve(fe,e,"","delete"),a=e.slice(-1)[0],l=t.slice(0,-1),s=t.slice(-1)[0];let c="number"==typeof s?"above"===n?s:s+1:"number"==typeof a?`arr_${a}`:a;e.slice(0,-1).join(".")===t.slice(0,-1).join(".")&&"number"==typeof a&&"number"==typeof c&&a<c&&(c-=1);const u="number"==typeof c?{insert:!0}:"above"===n?{insertBefore:s}:{insertAfter:s},{newData:p,newValue:g}=Ve(o,[...l,c],i,"add",u);return yield Ee(d,{currentData:r,newData:p,currentValue:i,newValue:g,name:t.slice(-1)[0],path:t})}),showCollectionCount:w,collapseFilter:ge,collapseAnimationTime:E,restrictEditFilter:we,restrictDeleteFilter:Ce,restrictAddFilter:Oe,restrictTypeSelection:S,restrictDragFilter:ke,canDragOnto:!1,searchFilter:Te,searchText:he,enableClipboard:b,keySort:V,sort:Be,showArrayIndices:_,arrayIndexFromOne:L,showStringQuotes:z,showIconTooltips:M,indent:v,defaultValue:B,newKeyOptions:G,stringTruncate:H,translate:me,customNodeDefinitions:ee,customNodeData:We,customButtons:te,parentData:null,jsonParse:Ie,jsonStringify:Re,TextEditor:oe,errorMessageTimeout:ie,handleKeyboard:Pe,keyboardControls:xe,insertAtTop:{object:!0===se||"object"===se,array:!0===se||"array"===se},onCollapse:ce,editConfirmRef:Me,collapseClickZones:de},Ye=Object.assign(Object.assign({},ue("container",je)),{minWidth:Y,maxWidth:$});return Ye.fontSize=null!=U?U:Ye.fontSize,t("div",{id:Q,ref:ve,className:`jer-editor-container ${null!=X?X:""}`,style:Ye,children:C(fe)&&!We.renderCollectionAsValue?t(Ne,Object.assign({data:fe},Ge)):t(De,Object.assign({data:fe,showLabel:!0},Ge))})},Ie=e=>{var n;const[r,o]=i();return l(()=>{const e=document.documentElement;o(e)},[]),r?t(B,{theme:null!==(n=e.theme)&&void 0!==n?n:z,icons:e.icons,docRoot:r,children:t(Z,{onEditEvent:e.onEditEvent,onCollapse:e.onCollapse,children:t(Re,Object.assign({},e))})}):null},Ve=(e,t,n,r,o={})=>{if(0===t.length)return{currentData:e,newData:n,currentValue:e,newValue:n};const i=Object.assign({remove:"delete"===r},o),a="add"!==r?g(e,t):void 0;return{currentData:e,newData:v(e,t,n,i),currentValue:a,newValue:"delete"!==r?n:void 0}},_e=(e,t)=>t?()=>!0:"boolean"==typeof e?()=>e:"number"==typeof e?({level:t})=>t>=e:e,Fe=e=>{if(void 0!==e)return"value"===e?S:"key"===e?N:"all"===e?(e,t)=>S(e,t)||N(e,t):e},Le=e=>Array.isArray(e)&&2===e.length&&["error","value"].includes(e[0]),ze=(e,t)=>{const n="stringifyReplacer"===t?[e=>void 0===e?L:e]:[];if(n.push(...e.map(e=>e[t]).filter(e=>!!e)),0!==n.length)return(e,t)=>{let r=t;for(const e of n)r=e(r);return r}},Me=e=>{var n;const{value:r,setIsEditing:o,getStyles:i,nodeData:a}=e,l=i("string",a);return t("div",{onDoubleClick:()=>o(!0),onClick:e=>{(e.getModifierState("Control")||e.getModifierState("Meta"))&&o(!0)},className:"jer-value-string jer-hyperlink",style:l,children:t("a",{href:r,target:"_blank",rel:"noreferrer",style:{color:null!==(n=l.color)&&void 0!==n?n:void 0},children:t(q,Object.assign({},e,{pathString:T(a.path),styles:l,value:a.value}))})})},Be={condition:({value:e})=>"string"==typeof e&&/^https?:\/\/.+\..+$/.test(e),element:Me,showOnView:!0,showOnEdit:!1},We={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)"}},Ge={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"}},Ye={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"}},$e={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"}},Ue={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"}},He={displayName:"Psychedelic",fragments:{pale:{color:"#A8DADC"},fluroYellow:"rgb(242, 228, 21)",fluroGreen:"rgb(68, 255, 62)",hotPink:"#f7379a"},styles:{container:{backgroundColor:"unset",background:"linear-gradient(90deg, hsla(333, 100%, 53%, 1) 0%, hsla(33, 94%, 57%, 1) 100%)",color:"black"},dropZone:"fluroYellow",property:"black",bracket:"fluroYellow",itemCount:["pale",{opacity:.7}],string:"white",number:["#33d9ff",{fontSize:"90%",fontWeight:"bold"}],boolean:["fluroGreen",{fontWeight:"bold",fontSize:"80%"}],null:["black",{fontWeight:"bold",opacity:.3,backgroundColor:"rgb(255, 255, 255, 0.5)",padding:"0 0.4em",borderRadius:"0.4em"}],iconCollection:"fluroYellow",iconEdit:["black"],iconDelete:["white",{opacity:.5}],iconAdd:["white",{opacity:.5}],iconCopy:"rgb(32, 84, 242)",iconOk:"fluroGreen",iconCancel:"hotPink"}};export{le as IconAdd,pe as IconCancel,ge as IconChevron,de as IconCopy,ce as IconDelete,se as IconEdit,ue as IconOk,Ie as JsonEditor,Me as LinkCustomComponent,Be as LinkCustomNodeDefinition,q as StringDisplay,ee as StringEdit,v as assign,Ue as candyWrapperTheme,z as defaultTheme,g as extract,We as githubDarkTheme,Ge as githubLightTheme,C as isCollection,S as matchNode,N as matchNodeKey,Ye as monoDarkTheme,$e as monoLightTheme,He as psychedelicTheme,be as standardDataTypes,T as toPathString,oe as useKeyboardListener};
|