Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

json-edit-react

Package Overview
Dependencies
Maintainers
0
Versions
76
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-edit-react - npm Package Compare versions

Comparing version 1.16.1 to 1.16.2

2

build/index.cjs.js

@@ -1,1 +0,1 @@

"use strict";var e=require("react/jsx-runtime"),t=require("react"),n=require("object-property-assigner"),r=require("object-property-extractor");function o(e,t,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 a=({className:t,name:n,value:r,setValue:o,handleKeyPress:a,styles:i})=>{if("string"!=typeof r)return null;const s="\n"===r.slice(-1)?r+".":r;return e.jsxs("div",{style:{display:"grid"},children:[e.jsx("textarea",{id:`${n}_textarea`,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:s})]})},i=e=>null!==e&&"object"==typeof e,s=(e,t,n,r="")=>{if(!n&&!r)return!0;switch(e){case"collection":if(n){if(n(t,r))return!0;if(!l(r,t,n))return!1}if(!n&&r&&!l(r,t))return!1;break;case"value":if(n&&!n(t,r))return!1;if(!n&&r&&!c(t,r))return!1}return!0},l=(e="",t,n=c)=>{const r=t.value;return Object.entries(r).some((([o,a])=>{const s=[...t.path,o],c=Object.assign(Object.assign({},t),{key:o,path:s,level:t.level+1,value:a,size:s.length,parentData:r});return i(a)?l(e,c,n):n(c,e)}))},c=(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}},d=({key:e,path:t},n="")=>!!c({value:e},n)||!!t.some((e=>c({value:e},n))),u=(e,t=200)=>"string"==typeof e?e.length<t?e:`${e.slice(0,t-2).trim()}...`:e,p=e=>e.map((e=>""===e?String.fromCharCode(0):e)).join("."),g={default:{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)"}},githubDark:{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)"}},githubLight:{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"}},monoDark:{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"}},monoLight:{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"}},candyWrapper:{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"}},psychedelic:{displayName:"Psychedelic",fragments:{minty:{backgroundColor:"#F1FAEE"},pale:{color:"#A8DADC"},mid:{color:"#457B9D"},dark:{color:"#1D3557"},pop:{color:"#E63946"},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"}}},m=g.default,h=t.createContext({getStyles:()=>({}),icons:{}}),y=({theme:t="default",icons:n={},children:r})=>{const o=b(t);return e.jsx(h.Provider,{value:{getStyles:(e,t)=>"function"==typeof o[e]?o[e](t):o[e],icons:n},children:r})},j=()=>t.useContext(h),b=e=>{var t,n,r,o;const a={},i=(Array.isArray(e)?e:[e]).map((t=>"default"===e?{}:"string"==typeof t?f(g[t],a):v(t)?f({fragments:{},styles:t},a):f(t,a))),s=f(m,{});Object.keys(s).forEach((e=>{const t=e;i.forEach((e=>{e[t]&&(s[t]=Object.assign(Object.assign({},s[t]),e[t]))}))}));const l=Object.assign({},s);return Object.entries(a).forEach((([e,t])=>{const n=e;l[n]=e=>{const r=t(e)||{};return Object.assign(Object.assign({},s[n]),r)}})),"function"!=typeof(null==l?void 0:l.inputHighlight)&&(null===(t=null==l?void 0:l.inputHighlight)||void 0===t?void 0:t.backgroundColor)&&document.documentElement.style.setProperty("--jer-highlight-color",null===(n=null==l?void 0:l.inputHighlight)||void 0===n?void 0:n.backgroundColor),"function"!=typeof(null==l?void 0:l.iconCopy)&&(null===(r=null==l?void 0:l.iconCopy)||void 0===r?void 0:r.color)&&document.documentElement.style.setProperty("--jer-icon-copy-color",null===(o=null==l?void 0:l.iconCopy)||void 0===o?void 0:o.color),l},f=(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;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),{[x[e]]:t}):Object.assign(Object.assign({},r),t)}return Object.assign(Object.assign({},r),o)}),{});o[e]=a})),o},v=e=>!("styles"in e),x={container:"backgroundColor",collection:"backgroundColor",collectionInner:"backgroundColor",collectionElement:"backgroundColor",dropZone:"borderColor",property:"color",bracket:"color",itemCount:"color",string:"color",number:"color",boolean:"color",null:"color",input:"color",inputHighlight:"backgroundColor",error:"color",iconCollection:"color",iconEdit:"color",iconDelete:"color",iconAdd:"color",iconCopy:"color",iconOk:"color",iconCancel:"color"},E="**INVALID_FUNCTION**",D=({value:t,setValue:n,isEditing:r,path:o,setIsEditing:i,handleEdit:s,handleCancel:l,stringTruncate:c,showStringQuotes:d,nodeData:g})=>{const{getStyles:m}=j(),h=p(o),y=d?'"':"";return r?e.jsx(a,{className:"jer-input-text",name:h,value:t,setValue:n,isEditing:r,handleKeyPress:e=>{"Enter"!==e.key||e.shiftKey?"Escape"===e.key&&l():s()},styles:m("input",g)}):e.jsxs("div",{id:`${h}_display`,onDoubleClick:()=>i(!0),onClick:e=>{(e.getModifierState("Control")||e.getModifierState("Meta"))&&i(!0)},className:"jer-value-string",style:m("string",g),children:[y,u(t,c),y]})},w=({value:t,setValue:n,isEditing:r,path:o,setIsEditing:a,handleEdit:i,handleCancel:s,nodeData:l})=>{const{getStyles:c}=j();return r?e.jsx("input",{className:"jer-input-number",type:"text",name:p(o),value:t,onChange:e=>n(e.target.value.replace(/[^0-9.-]/g,"")),autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>{switch(e.key){case"Enter":i();break;case"Escape":s();break;case"ArrowUp":e.preventDefault(),n(Number(t)+1);break;case"ArrowDown":e.preventDefault(),n(Number(t)-1)}},style:Object.assign({width:String(t).length/1.5+2+"em"},c("input",l))}):e.jsx("span",{onDoubleClick:()=>a(!0),className:"jer-value-number",style:c("number",l),children:t})},k=({value:t,setValue:n,isEditing:r,path:o,setIsEditing:a,handleEdit:i,handleCancel:s,nodeData:l})=>{const{getStyles:c}=j();return r?e.jsx("input",{className:"jer-input-boolean",type:"checkbox",name:p(o),checked:t,onChange:()=>n(!t),onKeyDown:e=>{"Enter"===e.key?i():"Escape"===e.key&&s()},autoFocus:!0}):e.jsx("span",{onDoubleClick:()=>a(!0),className:"jer-value-boolean",style:c("boolean",l),children:String(t)})},C=({value:n,isEditing:r,setIsEditing:o,handleEdit:a,handleCancel:i,nodeData:s})=>{const{getStyles:l}=j();t.useEffect((()=>(r&&document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c))),[r]);const c=e=>{"Enter"===e.key?a():"Escape"===e.key&&i()};return e.jsx("div",{onDoubleClick:()=>o(!0),className:"jer-value-null",style:l("null",s),children:String(n)})},S=({value:t})=>{let n="Error!";switch(typeof t){case"string":t===E&&(n="Function");break;case"undefined":n="Undefined";break;case"symbol":n="Symbol"}return e.jsx("span",{className:"jer-value-invalid",children:n})},O=({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"})]}),N=({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"})]}),A=({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"})}),T=({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"})]}),P=({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"})]}),R=({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"})}),V=({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"})}),F=({name:t,nodeData:n,rotate:r})=>{var o,a,i,s,l,c,d;const{getStyles:u,icons:p}=j(),g={size:"1.4em",className:"jer-icon"};switch(t){case"add":return null!==(o=null==p?void 0:p.add)&&void 0!==o?o:e.jsx(O,Object.assign({},g,{style:u("iconAdd",n)}));case"edit":return null!==(a=null==p?void 0:p.edit)&&void 0!==a?a:e.jsx(N,Object.assign({},g,{style:u("iconEdit",n)}));case"delete":return null!==(i=null==p?void 0:p.delete)&&void 0!==i?i:e.jsx(A,Object.assign({},g,{style:u("iconDelete",n),size:"1.45em"}));case"copy":return null!==(s=null==p?void 0:p.copy)&&void 0!==s?s:e.jsx(T,Object.assign({},g,{style:u("iconCopy",n),size:"1.2em"}));case"ok":return null!==(l=null==p?void 0:p.ok)&&void 0!==l?l:e.jsx(P,Object.assign({},g,{style:Object.assign({fontSize:"90%"},u("iconOk",n))}));case"cancel":return null!==(c=null==p?void 0:p.cancel)&&void 0!==c?c:e.jsx(R,Object.assign({},g,{style:Object.assign({fontSize:"130%"},u("iconCancel",n))}));case"chevron":return null!==(d=null==p?void 0:p.chevron)&&void 0!==d?d:e.jsx(V,{size:"1em",style:u("iconCollection",n)});default:return e.jsx(e.Fragment,{})}},z=({startEdit:n,handleDelete:r,handleAdd:o,enableClipboard:a,type:i,customButtons:s,nodeData:l,translate:c})=>{const{getStyles:d}=j(),u=c("KEY_NEW",l),[p,g]=t.useState(!1),[m,h]=t.useState(u),{key:y,path:b,value:f}=l;return e.jsxs("div",{className:"jer-edit-buttons",style:{opacity:p?1:void 0},children:[a&&e.jsx("div",{onClick:e=>{e.stopPropagation();let t,n="value",r="";if(a){if(!0===(e.ctrlKey||e.metaKey))t=I(b),r=t,n="path";else t=f,r=i?JSON.stringify(f,null,2):String(t);navigator.clipboard.writeText(r)}"function"==typeof a&&a({value:t,stringValue:r,path:b,key:y,type:n})},className:"jer-copy-pulse",children:e.jsx(F,{name:"copy",nodeData:l})}),n&&e.jsx("div",{onClick:e=>{e.stopPropagation(),n()},children:e.jsx(F,{name:"edit",nodeData:l})}),r&&e.jsx("div",{onClick:e=>{e.stopPropagation(),r()},children:e.jsx(F,{name:"delete",nodeData:l})}),o&&e.jsx("div",{onClick:e=>{e.stopPropagation(),"object"===i?g(!0):o("")},children:e.jsx(F,{name:"add",nodeData:l})}),null==s?void 0:s.map((({Element:t,onClick:n},r)=>e.jsx("div",{onClick:e=>n(l,e),children:e.jsx(t,{})},r))),p&&o&&"object"===i&&e.jsxs(e.Fragment,{children:[e.jsx("input",{className:"jer-input-new-key",type:"text",name:"new-object-key",value:m,onChange:e=>h(e.target.value),autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>{"Enter"===e.key&&o?(g(!1),o(m),h(u)):"Escape"===e.key&&(g(!1),h(u))},style:d("input",l)}),e.jsx(M,{onOk:()=>{m&&(g(!1),o(m))},onCancel:()=>{g(!1)},nodeData:l})]})]})},M=({onOk:t,onCancel:n,nodeData:r})=>e.jsxs("div",{className:"jer-confirm-buttons",children:[e.jsx("div",{onClick:t,children:e.jsx(F,{name:"ok",nodeData:r})}),e.jsx("div",{onClick:n,children:e.jsx(F,{name:"cancel",nodeData:r})})]}),I=e=>e.reduce(((e,t)=>"number"==typeof t?`${e}[${t}]`:""===e?t:`${e}.${t}`),""),_=["string","number","boolean","null","object","array"],L=(e=[],t)=>{const n=e.filter((({condition:e})=>e(t)));if(0===n.length)return{};const r=n[0],{element:o,wrapperElement:a,customNodeProps:i,wrapperProps:s,hideKey:l=!1,showEditTools:c=!0,showOnEdit:d=!1,showOnView:u=!0,showCollectionWrapper:p=!0}=r,g=function(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}(r,["element","wrapperElement","customNodeProps","wrapperProps","hideKey","showEditTools","showOnEdit","showOnView","showCollectionWrapper"]);return Object.assign({CustomNode:o,CustomWrapper:a,customNodeProps:i,wrapperProps:s,hideKey:l,showEditTools:c,showOnEdit:d,showOnView:u,showCollectionWrapper:p},g)},K=t.createContext({collapseState:null,setCollapseState:()=>{},doesPathMatch:()=>!1,currentlyEditingElement:null,setCurrentlyEditingElement:()=>{},areChildrenBeingEdited:()=>!1,dragSource:{path:null,pathString:null},setDragSource:()=>{}}),B=({children:n})=>{const[r,o]=t.useState(null),[a,i]=t.useState(null),[s,l]=t.useState({path:null,pathString:null});return e.jsx(K.Provider,{value:{collapseState:r,setCollapseState:e=>{o(e),null!==e&&setTimeout((()=>o(null)),2e3)},doesPathMatch:e=>{if(null===r)return!1;for(const[t,n]of r.path.entries())if(n!==e[t])return!1;return!0},currentlyEditingElement:a,setCurrentlyEditingElement:i,areChildrenBeingEdited:e=>null!==a&&a.includes(e),dragSource:s,setDragSource:l},children:n})},W=()=>t.useContext(K),G=({props:e,collapsed:n})=>{const{data:r,nodeData:o,parentData:a,onEdit:i,onError:s,showErrorMessages:l,restrictEditFilter:c,restrictDeleteFilter:d,restrictAddFilter:u,restrictDragFilter:g,translate:m}=e,{currentlyEditingElement:h,setCurrentlyEditingElement:y}=W(),[j,b]=t.useState(null),f=Object.assign(Object.assign({},o),{collapsed:n}),{path:v,key:x,size:E}=f,D=p(v),w=t.useMemo((()=>!c(f)),[f]),k=t.useMemo((()=>!d(f)),[f]),C=t.useMemo((()=>!u(f)),[f]),S=t.useMemo((()=>!g(f)&&k&&null===h),[f]),O=e=>{l&&(b(e),setTimeout((()=>b(null)),2500)),console.warn("Error",e)},N=t.useMemo((()=>(e,t)=>{O(e.message),s&&s({currentData:f.fullData,errorValue:t,currentValue:r,name:x,path:v,error:e})}),[s,l]),A=h===D,T=h===`key_${D}`,P="number"==typeof v.slice(-1)[0];return{pathString:D,nodeData:f,path:v,name:x,size:E,canEdit:w,canDelete:k,canAdd:C,canDrag:S,error:j,showError:O,onError:N,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 N({code:"KEY_EXISTS",message:m("ERROR_KEY_EXISTS",f)},e);const n=Object.fromEntries(Object.entries(a).map((([t,n])=>t===x?[e,n]:[t,n])));i(n,t).then((t=>{t&&N({code:"UPDATE_ERROR",message:t},e)}))},derivedValues:{isEditing:A,isEditingKey:T,isArray:P,canEditKey:null!==a&&w&&C&&k&&!P}}},H=({canDrag:n,canDragOnto:r,path:o,nodeData:a,onMove:i,onError:s,translate:l})=>{const{getStyles:c}=j(),{dragSource:d,setDragSource:u}=W(),[g,m]=t.useState(!1),h=p(o),y=t.useMemo((()=>n?{onDragStart:e=>{e.stopPropagation(),u({path:o,pathString:h})},onDragEnd:e=>{e.stopPropagation(),u({path:null,pathString:null})}}:{}),[n]),b=t.useMemo((()=>e=>r?{onDragOver:e=>{e.stopPropagation(),e.preventDefault()},onDrop:t=>{t.stopPropagation(),v(e),u({path:null,pathString:null}),m(!1)},onDragEnter:t=>{var n;t.stopPropagation(),h.startsWith(null!==(n=d.pathString)&&void 0!==n?n:"")||m(e)},onDragExit:e=>{e.stopPropagation(),m(!1)}}:{}),[d,r]),f=t.useMemo((()=>r&&null!==d.pathString?e.jsx("div",Object.assign({className:"jer-drop-target-bottom",style:{height:"50%",position:"absolute",width:"100%",top:"50%",zIndex:o.length}},b("below"))):null),[d,r]),v=e=>{var t,n;const r=null===(t=d.path)||void 0===t?void 0:t.slice(-1)[0],c=null===(n=d.path)||void 0===n?void 0:n.slice(0,-1).join("."),u=o.slice(0,-1).join(""),{parentData:p}=a;"string"==typeof r&&p&&!Array.isArray(p)&&Object.keys(p).includes(r)&&r in p&&c!==u?s({code:"KEY_EXISTS",message:l("ERROR_KEY_EXISTS",a)},r):i(d.path,o,e).then((e=>{e&&s({code:"UPDATE_ERROR",message:e},a.value)}))};return{dragSourceProps:y,getDropTargetProps:b,BottomDropTarget:f,DropTargetPadding:({position:t,nodeData:n})=>g===t?e.jsx("div",{className:"jer-drag-n-drop-padding",style:c("dropZone",n)}):null,handleDrop:v}},U=(e,t)=>{var n,r;const o=document.getElementsByClassName("jer-editor-container"),a=parseInt(o.length>0?getComputedStyle(o[0]).getPropertyValue("line-height"):"16px"),i=(null!==(r=null===(n=t.current)||void 0===n?void 0:n.offsetWidth)&&void 0!==r?r:0)/(.5*a),s=JSON.stringify(e,null,2).replace(/\\n/g,"\n").split("\n").map((e=>Math.ceil(e.length/i))).reduce(((e,t)=>e+t),0)*a;return Math.min(s+30,window.innerHeight-50)},Y=n=>{const{data:r,parentData:o,onEdit:a,onDelete:i,onChange:l,onMove:c,enableClipboard:d,canDragOnto:u,restrictTypeSelection:p,searchFilter:g,searchText:m,showLabel:h,stringTruncate:y,showStringQuotes:b,indent:f,translate:v,customNodeDefinitions:x}=n,{getStyles:D}=j(),{setCurrentlyEditingElement:w,setCollapseState:k}=W(),[C,S]=t.useState("function"==typeof r?E:r),{pathString:O,nodeData:N,path:A,name:T,canEdit:P,canDelete:R,canDrag:V,error:F,onError:I,handleEditKey:K,derivedValues:B}=G({props:n}),{dragSourceProps:U,getDropTargetProps:Y,BottomDropTarget:Z,DropTargetPadding:q}=H({canDrag:V,canDragOnto:u,path:A,nodeData:N,onMove:c,onError:I,translate:v}),Q=L(x,N),[ee,te]=t.useState($(r,Q)),ne=t.useCallback((e=>{if(!l)return void S(e);const t=l({currentData:N.fullData,newValue:e,currentValue:C,name:T,path:A});S(t)}),[l]);t.useEffect((()=>{S("function"==typeof r?E:r),te($(r,Q))}),[r,F]);const{CustomNode:re,customNodeProps:oe,hideKey:ae,showEditTools:ie=!0,showOnEdit:se,showOnView:le}=Q,ce=[..._,...x.filter((({showInTypesSelector:e=!1,name:t})=>e&&!!t)).map((({name:e})=>e))],de=t.useMemo((()=>{if("boolean"==typeof p)return p?[]:ce;if(Array.isArray(p))return p;const e=p(N);return"boolean"==typeof e?e?[]:ce:e}),[N,p]);if(!s("value",N,g,m))return null;const ue=()=>{let e;switch(w(null),ee){case"object":e={[v("DEFAULT_NEW_KEY",N)]:C};break;case"array":e=null!=C?C:[];break;case"number":{const t=Number(C);e=isNaN(t)?0:t;break}default:e=C}a(e,A).then((t=>{t&&I({code:"UPDATE_ERROR",message:t},e)}))},pe=()=>{w(null),S(r),te($(r,Q))},{isEditing:ge,isEditingKey:me,canEditKey:he}=B,ye=!ge&&F,je=ge&&de.length>0,be="invalid"!==ee&&!F&&ie,fe=h&&me,ve=h&&!me&&!ae,xe={value:C,parentData:o,setValue:ne,isEditing:ge,setIsEditing:P?()=>w(O):()=>{},handleEdit:ue,handleCancel:pe,path:A,stringTruncate:y,showStringQuotes:b,nodeData:N,translate:v},Ee=re&&(ge&&se||!ge&&le)?e.jsx(re,Object.assign({},n,{value:C,customNodeProps:oe,setValue:ne,handleEdit:ue,handleCancel:pe,handleKeyPress:e=>{"Enter"===e.key?ue():"Escape"===e.key&&pe()},isEditing:ge,setIsEditing:()=>w(O),getStyles:D})):J($(r),xe);return e.jsxs("div",Object.assign({className:"jer-component jer-value-component",style:{marginLeft:f/2+"em",position:"relative"},draggable:V},U,Y("above"),{children:[Z,e.jsx(q,{position:"above",nodeData:N}),e.jsxs("div",{className:"jer-value-main-row",style:{flexWrap:T.length>10?"wrap":"nowrap"},children:[ve&&e.jsx("span",{className:"jer-key-text",style:Object.assign(Object.assign({},D("property",N)),{minWidth:`${Math.min(String(T).length+1,5)}ch`,flexShrink:T.length>10?1:0}),onDoubleClick:()=>he&&w(`key_${O}`),children:""===T?e.jsx("span",{className:A.length>0?"jer-empty-string":void 0}):`${T}:`}),fe&&e.jsx("input",{className:"jer-input-text jer-key-edit",type:"text",name:O,defaultValue:T,autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>{"Enter"===e.key?K(e.target.value):"Escape"===e.key&&pe()},style:{width:String(T).length/1.5+.5+"em"}}),e.jsxs("div",{className:"jer-value-and-buttons",children:[e.jsx("div",{className:"jer-input-component",children:Ee}),ge?e.jsx(M,{onOk:ue,onCancel:pe,nodeData:N}):be&&e.jsx(z,{startEdit:P?()=>w(O):void 0,handleDelete:R?()=>{i(C,A).then((e=>{e&&I({code:"DELETE_ERROR",message:e},C)}))}:void 0,enableClipboard:d,translate:v,customButtons:n.customButtons,nodeData:N}),je&&e.jsxs("div",{className:"jer-select",children:[e.jsx("select",{name:`${T}-type-select`,className:"jer-type-select",onChange:e=>(e=>{const t=x.find((t=>t.name===e));if(t)a(t.defaultValue,A),te(e),w(null),k({path:A,collapsed:!1});else{const t=X(C,e,v("DEFAULT_NEW_KEY",N),(null==Q?void 0:Q.CustomNode)?v("DEFAULT_STRING",N):void 0);ne(t),a(t,A).then((e=>{e&&(I({code:"UPDATE_ERROR",message:e},t),w(null))}))}})(e.target.value),value:ee,children:de.map((t=>e.jsx("option",{value:t,children:t},t)))}),e.jsx("span",{className:"focus"})]}),ye&&e.jsx("span",{className:"jer-error-slug",style:D("error",N),children:F})]})]}),e.jsx(q,{position:"below",nodeData:N})]}))},$=(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",J=(t,n)=>{const r=n.value;switch(t){case"string":return e.jsx(D,Object.assign({},n,{value:r}));case"number":return e.jsx(w,Object.assign({},n,{value:r}));case"boolean":return e.jsx(k,Object.assign({},n,{value:r}));case"null":return e.jsx(C,Object.assign({},n));default:return e.jsx(S,Object.assign({},n))}},X=(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)}},Z=n=>{const{getStyles:l}=j(),{collapseState:c,setCollapseState:d,doesPathMatch:u,currentlyEditingElement:p,setCurrentlyEditingElement:g,areChildrenBeingEdited:m}=W(),{data:h,nodeData:y,parentData:b,showCollectionCount:f,onEdit:v,onAdd:x,onDelete:E,canDragOnto:D,collapseFilter:w,collapseAnimationTime:k,onMove:C,enableClipboard:S,searchFilter:O,searchText:N,indent:A,keySort:T,showArrayIndices:P,defaultValue:R,translate:V,customNodeDefinitions:I,jsonParse:_,jsonStringify:K}=n,[B,$]=t.useState(K(h)),J=w(y),{contentRef:X,isAnimating:q,maxHeight:Q,collapsed:ee,animateCollapse:te}=((e,n,r)=>{const[o,a]=t.useState(r?0:void 0),[i,s]=t.useState(r),l=t.useRef(!1),c=t.useRef(null),d=t.useRef(0),u=t.useRef();return{contentRef:c,isAnimating:l.current,animateCollapse:t=>{var r,o;if(i!==t){switch(window.clearTimeout(u.current),l.current=!0,t){case!0:{const e=null!==(o=null===(r=c.current)||void 0===r?void 0:r.offsetHeight)&&void 0!==o?o:0;d.current=e,a(e),setTimeout((()=>{a(0)}),5);break}case!1:a(d.current||U(e,c))}s(!i),u.current=window.setTimeout((()=>{l.current=!1,t||a(void 0)}),n)}},maxHeight:o,collapsed:i}})(h,k,J),{pathString:ne,nodeData:re,path:oe,name:ae,size:ie,canEdit:se,canDelete:le,canAdd:ce,canDrag:de,error:ue,setError:pe,onError:ge,handleEditKey:me,derivedValues:he}=G({props:n,collapsed:ee}),{dragSourceProps:ye,getDropTargetProps:je,BottomDropTarget:be,DropTargetPadding:fe}=H({canDrag:de,canDragOnto:D,path:oe,nodeData:re,onMove:C,onError:ge,translate:V}),ve=t.useRef(!J);t.useEffect((()=>{$(K(h))}),[h]),t.useEffect((()=>{const e=w(re)&&!he.isEditing;ve.current=!e,te(e)}),[w]),t.useEffect((()=>{null!==c&&u(oe)&&(ve.current=!0,te(c.collapsed))}),[c]);const xe=t.useMemo((()=>e=>"function"!=typeof R?R:R(e)),[R]),{CustomNode:Ee,customNodeProps:De,CustomWrapper:we,wrapperProps:ke={},hideKey:Ce,showEditTools:Se=!0,showOnEdit:Oe,showOnView:Ne,showCollectionWrapper:Ae=!0}=t.useMemo((()=>L(I,re)),[]);if(!s("collection",re,O,N)&&re.level>0)return null;const Te=Array.isArray(h)?"array":"object",Pe="array"===Te?{open:"[",close:"]"}:{open:"{",close:"}"},Re=e=>{"Enter"===e.key&&(e.metaKey||e.shiftKey||e.ctrlKey)?Fe():"Escape"===e.key&&Me()},Ve=e=>{if(e.getModifierState("Alt"))return ve.current=!0,void d({collapsed:!ee,path:oe});p&&p.includes(ne)||(ve.current=!0,d(null),te(!ee))},Fe=()=>{try{const e=_(B);if(g(null),pe(null),JSON.stringify(e)===JSON.stringify(h))return;v(e,oe).then((t=>{t&&ge({code:"UPDATE_ERROR",message:t},e)}))}catch(e){ge({code:"INVALID_JSON",message:V("ERROR_INVALID_JSON",re)},B)}},ze=oe.length>0?()=>{E(h,oe).then((e=>{e&&ge({code:"DELETE_ERROR",message:e},r(h,oe))}))}:void 0,Me=()=>{g(null),pe(null),$(K(h))},{isEditing:Ie,isEditingKey:_e,isArray:Le,canEditKey:Ke}=he,Be="when-closed"===f?ee:f,We=!Ie&&Se,Ge=(P||!Le)&&!Ce&&void 0!==ae,He=Ee&&(Ie&&Oe||!Ie&&Ne),Ue=T&&"object"===Te,Ye=Object.entries(h).map((([e,t])=>["array"===Te?Number(e):e,t]));Ue&&Ye.sort("function"==typeof T?(e,t)=>T(e[0],t[0]):void 0);const $e=ve.current?Ie?e.jsx("div",{className:"jer-collection-text-edit",children:e.jsxs("div",{children:[e.jsx(a,{className:"jer-collection-text-area",name:ne,value:B,setValue:$,isEditing:Ie,handleKeyPress:Re,styles:l("input",re)}),e.jsx("div",{className:"jer-collection-input-button-row",children:e.jsx(M,{onOk:Fe,onCancel:Me,nodeData:re})})]})}):Ye.map((([t,r],o)=>{const a={key:t,value:r,path:[...oe,t],level:oe.length+1,index:o,size:i(r)?Object.keys(r).length:1,parentData:h,fullData:re.fullData};return e.jsx("div",{className:"jer-collection-element",style:l("collectionElement",a),children:i(r)?e.jsx(Z,Object.assign({},n,{data:r,parentData:h,nodeData:a,showCollectionCount:f,canDragOnto:se}),t):e.jsx(Y,Object.assign({},n,{data:r,parentData:h,nodeData:a,canDragOnto:se,showLabel:"object"===Te||P}),t)},t)})):null,Je=!!Ae&&ee;Je||(ve.current=!0);const Xe=Object.assign(Object.assign({},n),{data:h,value:h,parentData:b,nodeData:re,setValue:e=>o(void 0,void 0,void 0,(function*(){return yield v(e,oe)})),handleEdit:Fe,handleCancel:Me,handleKeyPress:Re,isEditing:Ie,setIsEditing:()=>g(ne),getStyles:l,canDragOnto:se}),Ze=He?e.jsx(Ee,Object.assign({customNodeProps:De},Xe,{children:$e})):$e,qe=_e?e.jsx("input",{className:"jer-input-text jer-key-edit",type:"text",name:ne,defaultValue:ae,autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>{"Enter"===e.key?me(e.target.value):"Escape"===e.key&&Me()},style:{width:String(ae).length/1.5+.5+"em"}}):Ge&&e.jsx("span",{className:"jer-key-text",style:l("property",re),onClick:e=>e.stopPropagation(),onDoubleClick:()=>Ke&&g(`key_${ne}`),children:""===ae?e.jsx("span",{className:oe.length>0?"jer-empty-string":void 0}):`${ae}:`}),Qe=We&&e.jsx(z,{startEdit:se?()=>{ve.current=!0,g(ne)}:void 0,handleAdd:ce?e=>{te(!1);const t=xe(re);"array"===Te?x(t,[...oe,h.length]).then((e=>{e&&ge({code:"ADD_ERROR",message:e},t)})):e in h?ge({code:"KEY_EXISTS",message:V("ERROR_KEY_EXISTS",re)},e):x(t,[...oe,e]).then((e=>{e&&ge({code:"ADD_ERROR",message:e},t)}))}:void 0,handleDelete:le?ze:void 0,enableClipboard:S,type:Te,nodeData:re,translate:V,customButtons:n.customButtons}),et=e.jsxs("div",Object.assign({className:"jer-component jer-collection-component",style:Object.assign(Object.assign({marginLeft:(0===oe.length?0:A/2)+"em"},l("collection",re)),{position:"relative"}),draggable:de},ye,je("above"),{children:[e.jsx("div",{className:"jer-clickzone",style:{width:A/2+1+"em",zIndex:10+2*re.level},onClick:e=>Ve(e)}),!Ie&&be,e.jsx(fe,{position:"above",nodeData:re}),Ae?e.jsxs("div",{className:"jer-collection-header-row",style:{position:"relative"},onClick:e=>Ve(e),children:[e.jsxs("div",{className:"jer-collection-name",children:[e.jsx("div",{className:"jer-collapse-icon jer-accordion-icon"+(ee?" jer-rotate-90":""),style:{zIndex:11+2*re.level},onClick:e=>Ve(e),children:e.jsx(F,{name:"chevron",rotate:ee,nodeData:re})}),qe,!Ie&&e.jsx("span",{className:"jer-brackets jer-bracket-open",style:l("bracket",re),children:Pe.open})]}),!Ie&&Be&&e.jsx("div",{className:"jer-collection-item-count"+(Be?" jer-visible":" jer-hidden"),style:l("itemCount",re),children:1===ie?V("ITEM_SINGLE",Object.assign(Object.assign({},re),{size:1}),1):V("ITEMS_MULTIPLE",re,ie)}),e.jsx("div",{className:"jer-brackets"+(Je?" jer-visible":" jer-hidden"),style:l("bracket",re),children:Pe.close}),Qe]}):Ce?e.jsx(e.Fragment,{}):e.jsxs("div",{className:"jer-collection-header-row",style:{position:"relative"},children:[qe,Qe]}),e.jsxs("div",{className:"jer-collection-inner",style:Object.assign({overflowY:Je||q?"clip":"visible",maxHeight:m(ne)?void 0:Q},l("collectionInner",re)),ref:X,children:[Ze,e.jsx("div",{className:Ie?"jer-collection-error-row":"jer-collection-error-row-edit",children:ue&&e.jsx("span",{className:"jer-error-slug",style:l("error",re),children:ue})}),!Ie&&Ae&&e.jsx("div",{className:"jer-brackets jer-bracket-outside",style:Object.assign(Object.assign({},l("bracket",re)),{marginLeft:(A<3?-1:A<6?-.5:0)+"em"}),children:Pe.close})]}),e.jsx(fe,{position:"below",nodeData:re})]}));return we?e.jsx(we,Object.assign({customNodeProps:ke},Xe,{children:et})):et},q={ITEM_SINGLE:"{{count}} item",ITEMS_MULTIPLE:"{{count}} items",KEY_NEW:"Enter new key",ERROR_KEY_EXISTS:"Key already exists",ERROR_INVALID_JSON:"Invalid JSON",ERROR_UPDATE:"Update unsuccessful",ERROR_DELETE:"Delete unsuccessful",ERROR_ADD:"Adding node unsuccessful",DEFAULT_STRING:"New data!",DEFAULT_NEW_KEY:"key"},Q=(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]:q[r];return void 0===o?a:null==a?void 0:a.replace("{{count}}",String(o))})(e,t,r,n,o);var ee=[],te=[];!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=ee.indexOf(a);-1===i&&(i=ee.push(a)-1,te[i]={}),n=te[i]&&te[i][r]?te[i][r]:te[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-expand-transition-time:0.3s;--jer-highlight-color:#b3d8ff}.jer-visible{opacity:1}.jer-hidden,.jer-visible{transition:var(--jer-expand-transition-time)}.jer-hidden{opacity:0}.jer-select select{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:transparent;border:none;color:#000;cursor:inherit;font-family:inherit;font-size:.8em;line-height:inherit;margin:0;outline:none;padding:0 1em 0 0;z-index:1}select::-ms-expand{display:none}.jer-select{align-items:center;background-color:#fff;background-image:linear-gradient(0deg,#f9f9f9,#fff 33%);border:1px solid var(--jer-select-border);border-radius:.25em;cursor:pointer;display:grid;grid-template-areas:"select";line-height:1.1;max-width:15ch;min-width:12ch;padding:.25em .5em;position:relative}.jer-select select,.jer-select:after{grid-area:select}.jer-select:not(.jer-select--multiple):after{background-color:var(--jer-select-arrow);clip-path:polygon(100% 0,0 0,50% 100%);content:"";height:.5em;justify-self:end;width:.8em}select:focus+.focus{border:1px solid var(--jer-select-focus);border-radius:inherit;bottom:-1px;left:-1px;position:absolute;right:-1px;top:-1px}.jer-editor-container{border-radius:.5em;font-size:16px;line-height:1;padding:1em 1em 1em 2em;position:relative;text-align:left}.jer-editor-container textarea{border:var(--jer-form-border);border-radius:.3em;color:var(--jer-input-color);outline:none}.jer-editor-container textarea:focus{border:var(--jer-form-border-focus)}.jer-editor-container input{border:var(--jer-form-border);border-radius:.3em;font-family:inherit;outline:none}.jer-editor-container input:focus{border:var(--jer-form-border-focus)}.jer-editor-container ::selection{background-color:var(--jer-highlight-color)}.jer-collection-header-row,.jer-value-main-row{align-items:center;display:flex;gap:.3em;min-height:1.7em}.jer-collection-header-row{display:flex;flex-wrap:wrap}.jer-collapse-icon{left:-1.2em;position:absolute;top:.35em}.jer-collection-inner{position:relative;transition:var(--jer-expand-transition-time)}.jer-collection-text-edit{align-items:flex-start;display:flex;flex-direction:column;gap:.3em}.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}.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}.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:transform var(--jer-expand-transition-time)}.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-accordion-icon,.jer-rotate-90{transition:transform var(--jer-expand-transition-time)}.jer-icon:hover{opacity:.85;transform:scale(1.2);transition:.3s}.jer-empty-string:after{content:"<empty string>:";font-size:90%;font-style:italic}.jer-drag-n-drop-padding{border:1px dashed #e0e0e0;border-radius:.3em;height:.5em}.jer-clickzone{height:calc(100% - .8em);left:-1em;position:absolute;top:1.2em}',{});const ne=({data:n,setData:r,rootName:a="root",onUpdate:s=(()=>{}),onEdit:l=s,onDelete:c=s,onAdd:d=s,onChange:u,onError:p,showErrorMessages:g=!0,enableClipboard:m=!0,indent:h=2,collapse:y=!1,collapseAnimationTime:b=300,showCollectionCount:f=!0,restrictEdit:v=!1,restrictDelete:x=!1,restrictAdd:E=!1,restrictTypeSelection:D=!1,restrictDrag:w=!0,searchFilter:k,searchText:C,searchDebounceTime:S=350,keySort:O=!1,showArrayIndices:N=!0,showStringQuotes:A=!0,defaultValue:T=null,minWidth:P=250,maxWidth:R="min(600px, 90vw)",rootFontSize:V,stringTruncate:F=250,translations:z={},className:M,id:I,customText:_={},customNodeDefinitions:L=[],customButtons:K=[],jsonParse:B=JSON.parse,jsonStringify:W=(e=>JSON.stringify(e,null,2))})=>{const{getStyles:G}=j(),H=t.useCallback(oe(y),[y]),U=t.useCallback(Q(z,_),[z,_]),[$,J]=t.useState(C),[X,q]=(({setData:e,data:n})=>{const[r,o]=t.useState(e?void 0:n),a=t.useCallback((t=>{e?e(t):o(t)}),[e]);return t.useEffect((()=>{e||o(n)}),[n]),[e?n:r,a]})({setData:r,data:n}),ee=document.querySelector(":root"),te=getComputedStyle(document.documentElement).getPropertyValue("--jer-expand-transition-time");1e3*parseFloat(te)!==b&&(null==ee||ee.style.setProperty("--jer-expand-transition-time",b/1e3+"s")),t.useEffect((()=>{const e=setTimeout((()=>J(C)),S);return()=>clearTimeout(e)}),[C,S]);const ne={key:a,path:[],level:0,index:0,value:X,size:"object"==typeof X&&null!==X?Object.keys(X).length:1,parentData:null,fullData:X},se=(e,t)=>o(void 0,void 0,void 0,(function*(){const n=yield e(t);if(!0===n||void 0===n)return void q(t.newData);const r=ie(n)?n:["error",n],[o,a]=r;if("error"===o)return q(t.currentData),!1===a?U("ERROR_UPDATE",ne):String(a);q(a)})),le=t.useMemo((()=>oe(v)),[v]),ce=t.useMemo((()=>oe(x)),[x]),de=t.useMemo((()=>oe(E)),[E]),ue=t.useMemo((()=>oe(w)),[w]),pe=t.useMemo((()=>ae(k)),[k]),ge={name:a,nodeData:ne,onEdit:(e,t)=>o(void 0,void 0,void 0,(function*(){const{currentData:n,newData:r,currentValue:o,newValue:a}=re(X,t,e,"update");if(o!==a)return yield se(l,{currentData:n,newData:r,currentValue:o,newValue:a,name:t.slice(-1)[0],path:t})})),onDelete:(e,t)=>o(void 0,void 0,void 0,(function*(){const{currentData:n,newData:r,currentValue:o,newValue:a}=re(X,t,e,"delete");return yield se(c,{currentData:n,newData:r,currentValue:o,newValue:a,name:t.slice(-1)[0],path:t})})),onAdd:(e,t)=>o(void 0,void 0,void 0,(function*(){const{currentData:n,newData:r,currentValue:o,newValue:a}=re(X,t,e,"add");return yield se(d,{currentData:n,newData:r,currentValue:o,newValue:a,name:t.slice(-1)[0],path:t})})),onChange:u,onError:p,showErrorMessages:g,onMove:(e,t,n)=>o(void 0,void 0,void 0,(function*(){if(null===e)return;const{currentData:r,newData:o,currentValue:a}=re(X,e,"","delete"),i=e.slice(-1)[0],s=t.slice(0,-1),c=t.slice(-1)[0];let d="number"==typeof c?"above"===n?c:c+1:"number"==typeof i?`arr_${i}`:i;e.slice(0,-1).join(".")===t.slice(0,-1).join(".")&&"number"==typeof i&&"number"==typeof d&&i<d&&(d-=1);const u="number"==typeof d?{insert:!0}:"above"===n?{insertBefore:c}:{insertAfter:c},{newData:p,newValue:g}=re(o,[...s,d],a,"add",u);return yield se(l,{currentData:r,newData:p,currentValue:a,newValue:g,name:t.slice(-1)[0],path:t})})),showCollectionCount:f,collapseFilter:H,collapseAnimationTime:b,restrictEditFilter:le,restrictDeleteFilter:ce,restrictAddFilter:de,restrictTypeSelection:D,restrictDragFilter:ue,canDragOnto:!1,searchFilter:pe,searchText:$,enableClipboard:m,keySort:O,showArrayIndices:N,showStringQuotes:A,indent:h,defaultValue:T,stringTruncate:F,translate:U,customNodeDefinitions:L,customButtons:K,parentData:null,jsonParse:B,jsonStringify:W},me=Object.assign(Object.assign({},G("container",ne)),{minWidth:P,maxWidth:R});return me.fontSize=null!=V?V:me.fontSize,e.jsx("div",{id:I,className:"jer-editor-container "+M,style:me,children:i(X)?e.jsx(Z,Object.assign({data:X},ge)):e.jsx(Y,Object.assign({data:X,showLabel:!0},ge))})},re=(e,t,o,a,i={})=>{if(0===t.length)return{currentData:e,newData:o,currentValue:e,newValue:o};const s=Object.assign({remove:"delete"===a},i),l="add"!==a?r(e,t):void 0;return{currentData:e,newData:n(e,t,o,s),currentValue:l,newValue:"delete"!==a?o:void 0}},oe=e=>"boolean"==typeof e?()=>e:"number"==typeof e?({level:t})=>t>=e:e,ae=e=>{if(void 0!==e)return"value"===e?c:"key"===e?d:"all"===e?(e,t)=>c(e,t)||d(e,t):e},ie=e=>Array.isArray(e)&&2===e.length&&["error","value"].includes(e[0]),se=({value:t,setIsEditing:n,getStyles:r,customNodeProps:o,nodeData:a})=>{var i,s;const l=null!==(i=null==o?void 0:o.stringTruncate)&&void 0!==i?i:100,c=r("string",a);return e.jsx("div",{onDoubleClick:()=>n(!0),onClick:e=>{(e.getModifierState("Control")||e.getModifierState("Meta"))&&n(!0)},className:"jer-value-string jer-hyperlink",style:c,children:e.jsxs("a",{href:t,target:"_blank",rel:"noreferrer",style:{color:null!==(s=c.color)&&void 0!==s?s:void 0},children:['"',u(t,l),'"']})})},le={condition:({value:e})=>"string"==typeof e&&/^https?:\/\/.+\..+$/.test(e),element:se,showOnView:!0,showOnEdit:!1};exports.assign=n,exports.extract=r,exports.IconAdd=O,exports.IconCancel=R,exports.IconChevron=V,exports.IconCopy=T,exports.IconDelete=A,exports.IconEdit=N,exports.IconOk=P,exports.JsonEditor=t=>e.jsx(y,{theme:t.theme,icons:t.icons,children:e.jsx(B,{children:e.jsx(ne,Object.assign({},t))})}),exports.LinkCustomComponent=se,exports.LinkCustomNodeDefinition=le,exports.isCollection=i,exports.matchNode=c,exports.matchNodeKey=d,exports.themes=g,exports.truncate=u;
"use strict";var e=require("react/jsx-runtime"),t=require("react"),n=require("object-property-assigner"),r=require("object-property-extractor");function o(e,t,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 a=({className:t,name:n,value:r,setValue:o,handleKeyPress:a,styles:i})=>{if("string"!=typeof r)return null;const s="\n"===r.slice(-1)?r+".":r;return e.jsxs("div",{style:{display:"grid"},children:[e.jsx("textarea",{id:`${n}_textarea`,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:s})]})},i=e=>null!==e&&"object"==typeof e,s=(e,t,n,r="")=>{if(!n&&!r)return!0;switch(e){case"collection":if(n){if(n(t,r))return!0;if(!l(r,t,n))return!1}if(!n&&r&&!l(r,t))return!1;break;case"value":if(n&&!n(t,r))return!1;if(!n&&r&&!c(t,r))return!1}return!0},l=(e="",t,n=c)=>{const r=t.value;return Object.entries(r).some((([o,a])=>{const s=[...t.path,o],c=Object.assign(Object.assign({},t),{key:o,path:s,level:t.level+1,value:a,size:s.length,parentData:r});return i(a)?l(e,c,n):n(c,e)}))},c=(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}},d=({key:e,path:t},n="")=>!!c({value:e},n)||!!t.some((e=>c({value:e},n))),u=(e,t=200)=>"string"==typeof e?e.length<t?e:`${e.slice(0,t-2).trim()}...`:e,p=e=>e.map((e=>""===e?String.fromCharCode(0):e)).join("."),g={default:{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)"}},githubDark:{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)"}},githubLight:{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"}},monoDark:{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"}},monoLight:{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"}},candyWrapper:{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"}},psychedelic:{displayName:"Psychedelic",fragments:{minty:{backgroundColor:"#F1FAEE"},pale:{color:"#A8DADC"},mid:{color:"#457B9D"},dark:{color:"#1D3557"},pop:{color:"#E63946"},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"}}},m=g.default,h=t.createContext({getStyles:()=>({}),icons:{}}),y=({theme:t="default",icons:n={},children:r})=>{const o=b(t);return e.jsx(h.Provider,{value:{getStyles:(e,t)=>"function"==typeof o[e]?o[e](t):o[e],icons:n},children:r})},j=()=>t.useContext(h),b=e=>{var t,n,r,o;const a={},i=(Array.isArray(e)?e:[e]).map((t=>"default"===e?{}:"string"==typeof t?f(g[t],a):v(t)?f({fragments:{},styles:t},a):f(t,a))),s=f(m,{});Object.keys(s).forEach((e=>{const t=e;i.forEach((e=>{e[t]&&(s[t]=Object.assign(Object.assign({},s[t]),e[t]))}))}));const l=Object.assign({},s);return Object.entries(a).forEach((([e,t])=>{const n=e;l[n]=e=>{const r=t(e)||{};return Object.assign(Object.assign({},s[n]),r)}})),"function"!=typeof(null==l?void 0:l.inputHighlight)&&(null===(t=null==l?void 0:l.inputHighlight)||void 0===t?void 0:t.backgroundColor)&&document.documentElement.style.setProperty("--jer-highlight-color",null===(n=null==l?void 0:l.inputHighlight)||void 0===n?void 0:n.backgroundColor),"function"!=typeof(null==l?void 0:l.iconCopy)&&(null===(r=null==l?void 0:l.iconCopy)||void 0===r?void 0:r.color)&&document.documentElement.style.setProperty("--jer-icon-copy-color",null===(o=null==l?void 0:l.iconCopy)||void 0===o?void 0:o.color),l},f=(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;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),{[x[e]]:t}):Object.assign(Object.assign({},r),t)}return Object.assign(Object.assign({},r),o)}),{});o[e]=a})),o},v=e=>!("styles"in e),x={container:"backgroundColor",collection:"backgroundColor",collectionInner:"backgroundColor",collectionElement:"backgroundColor",dropZone:"borderColor",property:"color",bracket:"color",itemCount:"color",string:"color",number:"color",boolean:"color",null:"color",input:"color",inputHighlight:"backgroundColor",error:"color",iconCollection:"color",iconEdit:"color",iconDelete:"color",iconAdd:"color",iconCopy:"color",iconOk:"color",iconCancel:"color"},E="**INVALID_FUNCTION**",D=({value:t,setValue:n,isEditing:r,path:o,setIsEditing:i,handleEdit:s,handleCancel:l,stringTruncate:c,showStringQuotes:d,nodeData:g})=>{const{getStyles:m}=j(),h=p(o),y=d?'"':"";return r?e.jsx(a,{className:"jer-input-text",name:h,value:t,setValue:n,isEditing:r,handleKeyPress:e=>{"Enter"!==e.key||e.shiftKey?"Escape"===e.key&&l():s()},styles:m("input",g)}):e.jsxs("div",{id:`${h}_display`,onDoubleClick:()=>i(!0),onClick:e=>{(e.getModifierState("Control")||e.getModifierState("Meta"))&&i(!0)},className:"jer-value-string",style:m("string",g),children:[y,u(t,c),y]})},w=({value:t,setValue:n,isEditing:r,path:o,setIsEditing:a,handleEdit:i,handleCancel:s,nodeData:l})=>{const{getStyles:c}=j();return r?e.jsx("input",{className:"jer-input-number",type:"text",name:p(o),value:t,onChange:e=>n(e.target.value.replace(/[^0-9.-]/g,"")),autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>{switch(e.key){case"Enter":i();break;case"Escape":s();break;case"ArrowUp":e.preventDefault(),n(Number(t)+1);break;case"ArrowDown":e.preventDefault(),n(Number(t)-1)}},style:Object.assign({width:String(t).length/1.5+2+"em"},c("input",l))}):e.jsx("span",{onDoubleClick:()=>a(!0),className:"jer-value-number",style:c("number",l),children:t})},k=({value:t,setValue:n,isEditing:r,path:o,setIsEditing:a,handleEdit:i,handleCancel:s,nodeData:l})=>{const{getStyles:c}=j();return r?e.jsx("input",{className:"jer-input-boolean",type:"checkbox",name:p(o),checked:t,onChange:()=>n(!t),onKeyDown:e=>{"Enter"===e.key?i():"Escape"===e.key&&s()},autoFocus:!0}):e.jsx("span",{onDoubleClick:()=>a(!0),className:"jer-value-boolean",style:c("boolean",l),children:String(t)})},C=({value:n,isEditing:r,setIsEditing:o,handleEdit:a,handleCancel:i,nodeData:s})=>{const{getStyles:l}=j();t.useEffect((()=>(r&&document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c))),[r]);const c=e=>{"Enter"===e.key?a():"Escape"===e.key&&i()};return e.jsx("div",{onDoubleClick:()=>o(!0),className:"jer-value-null",style:l("null",s),children:String(n)})},S=({value:t})=>{let n="Error!";switch(typeof t){case"string":t===E&&(n="Function");break;case"undefined":n="Undefined";break;case"symbol":n="Symbol"}return e.jsx("span",{className:"jer-value-invalid",children:n})},O=({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"})]}),N=({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"})]}),A=({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"})}),T=({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"})]}),P=({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"})]}),R=({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"})}),M=({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"})}),V=({name:t,nodeData:n,rotate:r})=>{var o,a,i,s,l,c,d;const{getStyles:u,icons:p}=j(),g={size:"1.4em",className:"jer-icon"};switch(t){case"add":return null!==(o=null==p?void 0:p.add)&&void 0!==o?o:e.jsx(O,Object.assign({},g,{style:u("iconAdd",n)}));case"edit":return null!==(a=null==p?void 0:p.edit)&&void 0!==a?a:e.jsx(N,Object.assign({},g,{style:u("iconEdit",n)}));case"delete":return null!==(i=null==p?void 0:p.delete)&&void 0!==i?i:e.jsx(A,Object.assign({},g,{style:u("iconDelete",n),size:"1.45em"}));case"copy":return null!==(s=null==p?void 0:p.copy)&&void 0!==s?s:e.jsx(T,Object.assign({},g,{style:u("iconCopy",n),size:"1.2em"}));case"ok":return null!==(l=null==p?void 0:p.ok)&&void 0!==l?l:e.jsx(P,Object.assign({},g,{style:Object.assign({fontSize:"90%"},u("iconOk",n))}));case"cancel":return null!==(c=null==p?void 0:p.cancel)&&void 0!==c?c:e.jsx(R,Object.assign({},g,{style:Object.assign({fontSize:"130%"},u("iconCancel",n))}));case"chevron":return null!==(d=null==p?void 0:p.chevron)&&void 0!==d?d:e.jsx(M,{size:"1em",style:u("iconCollection",n)});default:return e.jsx(e.Fragment,{})}},F=({startEdit:n,handleDelete:r,handleAdd:o,enableClipboard:a,type:i,customButtons:s,nodeData:l,translate:c})=>{const{getStyles:d}=j(),u=c("KEY_NEW",l),[p,g]=t.useState(!1),[m,h]=t.useState(u),{key:y,path:b,value:f}=l;return e.jsxs("div",{className:"jer-edit-buttons",style:{opacity:p?1:void 0},children:[a&&e.jsx("div",{onClick:e=>{e.stopPropagation();let t,n="value",r="";if(a){if(!0===(e.ctrlKey||e.metaKey))t=I(b),r=t,n="path";else t=f,r=i?JSON.stringify(f,null,2):String(t);navigator.clipboard.writeText(r)}"function"==typeof a&&a({value:t,stringValue:r,path:b,key:y,type:n})},className:"jer-copy-pulse",children:e.jsx(V,{name:"copy",nodeData:l})}),n&&e.jsx("div",{onClick:e=>{e.stopPropagation(),n()},children:e.jsx(V,{name:"edit",nodeData:l})}),r&&e.jsx("div",{onClick:e=>{e.stopPropagation(),r()},children:e.jsx(V,{name:"delete",nodeData:l})}),o&&e.jsx("div",{onClick:e=>{e.stopPropagation(),"object"===i?g(!0):o("")},children:e.jsx(V,{name:"add",nodeData:l})}),null==s?void 0:s.map((({Element:t,onClick:n},r)=>e.jsx("div",{onClick:e=>n(l,e),children:e.jsx(t,{})},r))),p&&o&&"object"===i&&e.jsxs(e.Fragment,{children:[e.jsx("input",{className:"jer-input-new-key",type:"text",name:"new-object-key",value:m,onChange:e=>h(e.target.value),autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>{"Enter"===e.key&&o?(g(!1),o(m),h(u)):"Escape"===e.key&&(g(!1),h(u))},style:d("input",l)}),e.jsx(z,{onOk:e=>{m&&(e.stopPropagation(),g(!1),o(m))},onCancel:e=>{e.stopPropagation(),g(!1)},nodeData:l})]})]})},z=({onOk:t,onCancel:n,nodeData:r})=>e.jsxs("div",{className:"jer-confirm-buttons",children:[e.jsx("div",{onClick:t,children:e.jsx(V,{name:"ok",nodeData:r})}),e.jsx("div",{onClick:n,children:e.jsx(V,{name:"cancel",nodeData:r})})]}),I=e=>e.reduce(((e,t)=>"number"==typeof t?`${e}[${t}]`:""===e?t:`${e}.${t}`),""),_=["string","number","boolean","null","object","array"],L=(e=[],t)=>{const n=e.filter((({condition:e})=>e(t)));if(0===n.length)return{};const r=n[0],{element:o,wrapperElement:a,customNodeProps:i,wrapperProps:s,hideKey:l=!1,showEditTools:c=!0,showOnEdit:d=!1,showOnView:u=!0,showCollectionWrapper:p=!0}=r,g=function(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}(r,["element","wrapperElement","customNodeProps","wrapperProps","hideKey","showEditTools","showOnEdit","showOnView","showCollectionWrapper"]);return Object.assign({CustomNode:o,CustomWrapper:a,customNodeProps:i,wrapperProps:s,hideKey:l,showEditTools:c,showOnEdit:d,showOnView:u,showCollectionWrapper:p},g)},K=t.createContext({collapseState:null,setCollapseState:()=>{},doesPathMatch:()=>!1,currentlyEditingElement:null,setCurrentlyEditingElement:()=>{},areChildrenBeingEdited:()=>!1,dragSource:{path:null,pathString:null},setDragSource:()=>{}}),B=({children:n})=>{const[r,o]=t.useState(null),[a,i]=t.useState(null),[s,l]=t.useState({path:null,pathString:null});return e.jsx(K.Provider,{value:{collapseState:r,setCollapseState:e=>{o(e),null!==e&&setTimeout((()=>o(null)),2e3)},doesPathMatch:e=>{if(null===r)return!1;for(const[t,n]of r.path.entries())if(n!==e[t])return!1;return!0},currentlyEditingElement:a,setCurrentlyEditingElement:i,areChildrenBeingEdited:e=>null!==a&&a.includes(e),dragSource:s,setDragSource:l},children:n})},W=()=>t.useContext(K),G=({props:e,collapsed:n})=>{const{data:r,nodeData:o,parentData:a,onEdit:i,onError:s,showErrorMessages:l,restrictEditFilter:c,restrictDeleteFilter:d,restrictAddFilter:u,restrictDragFilter:g,translate:m,errorMessageTimeout:h}=e,{currentlyEditingElement:y,setCurrentlyEditingElement:j}=W(),[b,f]=t.useState(null),v=Object.assign(Object.assign({},o),{collapsed:n}),{path:x,key:E,size:D}=v,w=p(x),k=t.useMemo((()=>!c(v)),[v]),C=t.useMemo((()=>!d(v)),[v]),S=t.useMemo((()=>!u(v)),[v]),O=t.useMemo((()=>!g(v)&&C&&null===y),[v]),N=e=>{l&&(f(e),setTimeout((()=>f(null)),h)),console.warn("Error",e)},A=t.useMemo((()=>(e,t)=>{N(e.message),s&&s({currentData:v.fullData,errorValue:t,currentValue:r,name:E,path:x,error:e})}),[s,l]),T=y===w,P=y===`key_${w}`,R="number"==typeof x.slice(-1)[0];return{pathString:w,nodeData:v,path:x,name:E,size:D,canEdit:k,canDelete:C,canAdd:S,canDrag:O,error:b,showError:N,onError:A,setError:f,handleEditKey:e=>{if(j(null),E===e)return;if(!a)return;const t=x.slice(0,-1);if(Object.keys(a).includes(e))return void A({code:"KEY_EXISTS",message:m("ERROR_KEY_EXISTS",v)},e);const n=Object.fromEntries(Object.entries(a).map((([t,n])=>t===E?[e,n]:[t,n])));i(n,t).then((t=>{t&&A({code:"UPDATE_ERROR",message:t},e)}))},derivedValues:{isEditing:T,isEditingKey:P,isArray:R,canEditKey:null!==a&&k&&S&&C&&!R}}},H=({canDrag:n,canDragOnto:r,path:o,nodeData:a,onMove:i,onError:s,translate:l})=>{const{getStyles:c}=j(),{dragSource:d,setDragSource:u}=W(),[g,m]=t.useState(!1),h=p(o),y=t.useMemo((()=>n?{onDragStart:e=>{e.stopPropagation(),u({path:o,pathString:h})},onDragEnd:e=>{e.stopPropagation(),u({path:null,pathString:null})}}:{}),[n]),b=t.useMemo((()=>e=>r?{onDragOver:e=>{e.stopPropagation(),e.preventDefault()},onDrop:t=>{t.stopPropagation(),v(e),u({path:null,pathString:null}),m(!1)},onDragEnter:t=>{var n;t.stopPropagation(),h.startsWith(null!==(n=d.pathString)&&void 0!==n?n:"")||m(e)},onDragExit:e=>{e.stopPropagation(),m(!1)}}:{}),[d,r]),f=t.useMemo((()=>r&&null!==d.pathString?e.jsx("div",Object.assign({className:"jer-drop-target-bottom",style:{height:"50%",position:"absolute",width:"100%",top:"50%",zIndex:o.length}},b("below"))):null),[d,r]),v=e=>{var t,n;const r=null===(t=d.path)||void 0===t?void 0:t.slice(-1)[0],c=null===(n=d.path)||void 0===n?void 0:n.slice(0,-1).join("."),u=o.slice(0,-1).join(""),{parentData:p}=a;"string"==typeof r&&p&&!Array.isArray(p)&&Object.keys(p).includes(r)&&r in p&&c!==u?s({code:"KEY_EXISTS",message:l("ERROR_KEY_EXISTS",a)},r):i(d.path,o,e).then((e=>{e&&s({code:"UPDATE_ERROR",message:e},a.value)}))};return{dragSourceProps:y,getDropTargetProps:b,BottomDropTarget:f,DropTargetPadding:({position:t,nodeData:n})=>g===t?e.jsx("div",{className:"jer-drag-n-drop-padding",style:c("dropZone",n)}):null,handleDrop:v}},U=(e,t)=>{var n,r;const o=document.getElementsByClassName("jer-editor-container"),a=parseInt(o.length>0?getComputedStyle(o[0]).getPropertyValue("line-height"):"16px"),i=(null!==(r=null===(n=t.current)||void 0===n?void 0:n.offsetWidth)&&void 0!==r?r:0)/(.5*a),s=JSON.stringify(e,null,2).replace(/\\n/g,"\n").split("\n").map((e=>Math.ceil(e.length/i))).reduce(((e,t)=>e+t),0)*a;return Math.min(s+30,window.innerHeight-50)},Y=n=>{const{data:r,parentData:o,onEdit:a,onDelete:i,onChange:l,onMove:c,enableClipboard:d,canDragOnto:u,restrictTypeSelection:p,searchFilter:g,searchText:m,showLabel:h,stringTruncate:y,showStringQuotes:b,indent:f,translate:v,customNodeDefinitions:x}=n,{getStyles:D}=j(),{setCurrentlyEditingElement:w,setCollapseState:k}=W(),[C,S]=t.useState("function"==typeof r?E:r),{pathString:O,nodeData:N,path:A,name:T,canEdit:P,canDelete:R,canDrag:M,error:V,onError:I,handleEditKey:K,derivedValues:B}=G({props:n}),{dragSourceProps:U,getDropTargetProps:Y,BottomDropTarget:Z,DropTargetPadding:q}=H({canDrag:M,canDragOnto:u,path:A,nodeData:N,onMove:c,onError:I,translate:v}),Q=L(x,N),[ee,te]=t.useState($(r,Q)),ne=t.useCallback((e=>{if(!l)return void S(e);const t=l({currentData:N.fullData,newValue:e,currentValue:C,name:T,path:A});S(t)}),[l]);t.useEffect((()=>{S("function"==typeof r?E:r),te($(r,Q))}),[r,V]);const{CustomNode:re,customNodeProps:oe,hideKey:ae,showEditTools:ie=!0,showOnEdit:se,showOnView:le}=Q,ce=[..._,...x.filter((({showInTypesSelector:e=!1,name:t})=>e&&!!t)).map((({name:e})=>e))],de=t.useMemo((()=>{if("boolean"==typeof p)return p?[]:ce;if(Array.isArray(p))return p;const e=p(N);return"boolean"==typeof e?e?[]:ce:e}),[N,p]);if(!s("value",N,g,m))return null;const ue=()=>{let e;switch(w(null),ee){case"object":e={[v("DEFAULT_NEW_KEY",N)]:C};break;case"array":e=null!=C?C:[];break;case"number":{const t=Number(C);e=isNaN(t)?0:t;break}default:e=C}a(e,A).then((t=>{t&&I({code:"UPDATE_ERROR",message:t},e)}))},pe=()=>{w(null),S(r),te($(r,Q))},{isEditing:ge,isEditingKey:me,canEditKey:he}=B,ye=!ge&&V,je=ge&&de.length>0,be="invalid"!==ee&&!V&&ie,fe=h&&me,ve=h&&!me&&!ae,xe={value:C,parentData:o,setValue:ne,isEditing:ge,setIsEditing:P?()=>w(O):()=>{},handleEdit:ue,handleCancel:pe,path:A,stringTruncate:y,showStringQuotes:b,nodeData:N,translate:v},Ee=re&&(ge&&se||!ge&&le)?e.jsx(re,Object.assign({},n,{value:C,customNodeProps:oe,setValue:ne,handleEdit:ue,handleCancel:pe,handleKeyPress:e=>{"Enter"===e.key?ue():"Escape"===e.key&&pe()},isEditing:ge,setIsEditing:()=>w(O),getStyles:D})):J($(r),xe);return e.jsxs("div",Object.assign({className:"jer-component jer-value-component",style:{marginLeft:f/2+"em",position:"relative"},draggable:M},U,Y("above"),{children:[Z,e.jsx(q,{position:"above",nodeData:N}),e.jsxs("div",{className:"jer-value-main-row",style:{flexWrap:T.length>10?"wrap":"nowrap"},children:[ve&&e.jsx("span",{className:"jer-key-text",style:Object.assign(Object.assign({},D("property",N)),{minWidth:`${Math.min(String(T).length+1,5)}ch`,flexShrink:T.length>10?1:0}),onDoubleClick:()=>he&&w(`key_${O}`),children:""===T?e.jsx("span",{className:A.length>0?"jer-empty-string":void 0}):`${T}:`}),fe&&e.jsx("input",{className:"jer-input-text jer-key-edit",type:"text",name:O,defaultValue:T,autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>{"Enter"===e.key?K(e.target.value):"Escape"===e.key&&pe()},style:{width:String(T).length/1.5+.5+"em"}}),e.jsxs("div",{className:"jer-value-and-buttons",children:[e.jsx("div",{className:"jer-input-component",children:Ee}),ge?e.jsx(z,{onOk:ue,onCancel:pe,nodeData:N}):be&&e.jsx(F,{startEdit:P?()=>w(O):void 0,handleDelete:R?()=>{i(C,A).then((e=>{e&&I({code:"DELETE_ERROR",message:e},C)}))}:void 0,enableClipboard:d,translate:v,customButtons:n.customButtons,nodeData:N}),je&&e.jsxs("div",{className:"jer-select",children:[e.jsx("select",{name:`${T}-type-select`,className:"jer-type-select",onChange:e=>(e=>{const t=x.find((t=>t.name===e));if(t)a(t.defaultValue,A),te(e),w(null),k({path:A,collapsed:!1});else{const t=X(C,e,v("DEFAULT_NEW_KEY",N),(null==Q?void 0:Q.CustomNode)?v("DEFAULT_STRING",N):void 0);ne(t),a(t,A).then((e=>{e&&(I({code:"UPDATE_ERROR",message:e},t),w(null))}))}})(e.target.value),value:ee,children:de.map((t=>e.jsx("option",{value:t,children:t},t)))}),e.jsx("span",{className:"focus"})]}),ye&&e.jsx("span",{className:"jer-error-slug",style:D("error",N),children:V})]})]}),e.jsx(q,{position:"below",nodeData:N})]}))},$=(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",J=(t,n)=>{const r=n.value;switch(t){case"string":return e.jsx(D,Object.assign({},n,{value:r}));case"number":return e.jsx(w,Object.assign({},n,{value:r}));case"boolean":return e.jsx(k,Object.assign({},n,{value:r}));case"null":return e.jsx(C,Object.assign({},n));default:return e.jsx(S,Object.assign({},n))}},X=(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)}},Z=n=>{const{getStyles:l}=j(),{collapseState:c,setCollapseState:d,doesPathMatch:u,currentlyEditingElement:p,setCurrentlyEditingElement:g,areChildrenBeingEdited:m}=W(),{data:h,nodeData:y,parentData:b,showCollectionCount:f,onEdit:v,onAdd:x,onDelete:E,canDragOnto:D,collapseFilter:w,collapseAnimationTime:k,onMove:C,enableClipboard:S,searchFilter:O,searchText:N,indent:A,keySort:T,showArrayIndices:P,defaultValue:R,translate:M,customNodeDefinitions:I,jsonParse:_,jsonStringify:K}=n,[B,$]=t.useState(K(h)),J=w(y),{contentRef:X,isAnimating:q,maxHeight:Q,collapsed:ee,animateCollapse:te}=((e,n,r)=>{const[o,a]=t.useState(r?0:void 0),[i,s]=t.useState(r),l=t.useRef(!1),c=t.useRef(null),d=t.useRef(0),u=t.useRef();return{contentRef:c,isAnimating:l.current,animateCollapse:t=>{var r,o;if(i!==t){switch(window.clearTimeout(u.current),l.current=!0,t){case!0:{const e=null!==(o=null===(r=c.current)||void 0===r?void 0:r.offsetHeight)&&void 0!==o?o:0;d.current=e,a(e),setTimeout((()=>{a(0)}),5);break}case!1:a(d.current||U(e,c))}s(!i),u.current=window.setTimeout((()=>{l.current=!1,t||a(void 0)}),n)}},maxHeight:o,collapsed:i}})(h,k,J),{pathString:ne,nodeData:re,path:oe,name:ae,size:ie,canEdit:se,canDelete:le,canAdd:ce,canDrag:de,error:ue,setError:pe,onError:ge,handleEditKey:me,derivedValues:he}=G({props:n,collapsed:ee}),{dragSourceProps:ye,getDropTargetProps:je,BottomDropTarget:be,DropTargetPadding:fe}=H({canDrag:de,canDragOnto:D,path:oe,nodeData:re,onMove:C,onError:ge,translate:M}),ve=t.useRef(!J);t.useEffect((()=>{$(K(h))}),[h]),t.useEffect((()=>{const e=w(re)&&!he.isEditing;ve.current=!e,te(e)}),[w]),t.useEffect((()=>{null!==c&&u(oe)&&(ve.current=!0,te(c.collapsed))}),[c]);const xe=t.useMemo((()=>e=>"function"!=typeof R?R:R(e)),[R]),{CustomNode:Ee,customNodeProps:De,CustomWrapper:we,wrapperProps:ke={},hideKey:Ce,showEditTools:Se=!0,showOnEdit:Oe,showOnView:Ne,showCollectionWrapper:Ae=!0}=t.useMemo((()=>L(I,re)),[]);if(!s("collection",re,O,N)&&re.level>0)return null;const Te=Array.isArray(h)?"array":"object",Pe="array"===Te?{open:"[",close:"]"}:{open:"{",close:"}"},Re=e=>{"Enter"===e.key&&(e.metaKey||e.shiftKey||e.ctrlKey)?Ve():"Escape"===e.key&&ze()},Me=e=>{if(e.getModifierState("Alt"))return ve.current=!0,void d({collapsed:!ee,path:oe});p&&p.includes(ne)||(ve.current=!0,d(null),te(!ee))},Ve=()=>{try{const e=_(B);if(g(null),pe(null),JSON.stringify(e)===JSON.stringify(h))return;v(e,oe).then((t=>{t&&ge({code:"UPDATE_ERROR",message:t},e)}))}catch(e){ge({code:"INVALID_JSON",message:M("ERROR_INVALID_JSON",re)},B)}},Fe=oe.length>0?()=>{E(h,oe).then((e=>{e&&ge({code:"DELETE_ERROR",message:e},r(h,oe))}))}:void 0,ze=()=>{g(null),pe(null),$(K(h))},{isEditing:Ie,isEditingKey:_e,isArray:Le,canEditKey:Ke}=he,Be="when-closed"===f?ee:f,We=!Ie&&Se,Ge=(P||!Le)&&!Ce&&void 0!==ae,He=Ee&&(Ie&&Oe||!Ie&&Ne),Ue=T&&"object"===Te,Ye=Object.entries(h).map((([e,t])=>["array"===Te?Number(e):e,t]));Ue&&Ye.sort("function"==typeof T?(e,t)=>T(e[0],t[0]):void 0);const $e=ve.current?Ie?e.jsx("div",{className:"jer-collection-text-edit",children:e.jsxs("div",{children:[e.jsx(a,{className:"jer-collection-text-area",name:ne,value:B,setValue:$,isEditing:Ie,handleKeyPress:Re,styles:l("input",re)}),e.jsx("div",{className:"jer-collection-input-button-row",children:e.jsx(z,{onOk:Ve,onCancel:ze,nodeData:re})})]})}):Ye.map((([t,r],o)=>{const a={key:t,value:r,path:[...oe,t],level:oe.length+1,index:o,size:i(r)?Object.keys(r).length:1,parentData:h,fullData:re.fullData};return e.jsx("div",{className:"jer-collection-element",style:l("collectionElement",a),children:i(r)?e.jsx(Z,Object.assign({},n,{data:r,parentData:h,nodeData:a,showCollectionCount:f,canDragOnto:se}),t):e.jsx(Y,Object.assign({},n,{data:r,parentData:h,nodeData:a,canDragOnto:se,showLabel:"object"===Te||P}),t)},t)})):null,Je=!!Ae&&ee;Je||(ve.current=!0);const Xe=Object.assign(Object.assign({},n),{data:h,value:h,parentData:b,nodeData:re,setValue:e=>o(void 0,void 0,void 0,(function*(){return yield v(e,oe)})),handleEdit:Ve,handleCancel:ze,handleKeyPress:Re,isEditing:Ie,setIsEditing:()=>g(ne),getStyles:l,canDragOnto:se}),Ze=He?e.jsx(Ee,Object.assign({customNodeProps:De},Xe,{children:$e})):$e,qe=_e?e.jsx("input",{className:"jer-input-text jer-key-edit",type:"text",name:ne,defaultValue:ae,autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>{"Enter"===e.key?me(e.target.value):"Escape"===e.key&&ze()},style:{width:String(ae).length/1.5+.5+"em"}}):Ge&&e.jsx("span",{className:"jer-key-text",style:l("property",re),onClick:e=>e.stopPropagation(),onDoubleClick:()=>Ke&&g(`key_${ne}`),children:""===ae?e.jsx("span",{className:oe.length>0?"jer-empty-string":void 0}):`${ae}:`}),Qe=We&&e.jsx(F,{startEdit:se?()=>{ve.current=!0,g(ne)}:void 0,handleAdd:ce?e=>{te(!1);const t=xe(re);"array"===Te?x(t,[...oe,h.length]).then((e=>{e&&ge({code:"ADD_ERROR",message:e},t)})):e in h?ge({code:"KEY_EXISTS",message:M("ERROR_KEY_EXISTS",re)},e):x(t,[...oe,e]).then((e=>{e&&ge({code:"ADD_ERROR",message:e},t)}))}:void 0,handleDelete:le?Fe:void 0,enableClipboard:S,type:Te,nodeData:re,translate:M,customButtons:n.customButtons}),et=e.jsxs("div",Object.assign({className:"jer-component jer-collection-component",style:Object.assign(Object.assign({marginLeft:(0===oe.length?0:A/2)+"em"},l("collection",re)),{position:"relative"}),draggable:de},ye,je("above"),{children:[e.jsx("div",{className:"jer-clickzone",style:{width:A/2+1+"em",zIndex:10+2*re.level},onClick:e=>Me(e)}),!Ie&&be,e.jsx(fe,{position:"above",nodeData:re}),Ae?e.jsxs("div",{className:"jer-collection-header-row",style:{position:"relative"},onClick:e=>Me(e),children:[e.jsxs("div",{className:"jer-collection-name",children:[e.jsx("div",{className:"jer-collapse-icon jer-accordion-icon"+(ee?" jer-rotate-90":""),style:{zIndex:11+2*re.level},onClick:e=>Me(e),children:e.jsx(V,{name:"chevron",rotate:ee,nodeData:re})}),qe,!Ie&&e.jsx("span",{className:"jer-brackets jer-bracket-open",style:l("bracket",re),children:Pe.open})]}),!Ie&&Be&&e.jsx("div",{className:"jer-collection-item-count"+(Be?" jer-visible":" jer-hidden"),style:l("itemCount",re),children:1===ie?M("ITEM_SINGLE",Object.assign(Object.assign({},re),{size:1}),1):M("ITEMS_MULTIPLE",re,ie)}),e.jsx("div",{className:"jer-brackets"+(Je?" jer-visible":" jer-hidden"),style:l("bracket",re),children:Pe.close}),Qe]}):Ce?e.jsx(e.Fragment,{}):e.jsxs("div",{className:"jer-collection-header-row",style:{position:"relative"},children:[qe,Qe]}),e.jsxs("div",{className:"jer-collection-inner",style:Object.assign({overflowY:Je||q?"clip":"visible",maxHeight:m(ne)?void 0:Q},l("collectionInner",re)),ref:X,children:[Ze,e.jsx("div",{className:Ie?"jer-collection-error-row":"jer-collection-error-row-edit",children:ue&&e.jsx("span",{className:"jer-error-slug",style:l("error",re),children:ue})}),!Ie&&Ae&&e.jsx("div",{className:"jer-brackets jer-bracket-outside",style:Object.assign(Object.assign({},l("bracket",re)),{marginLeft:(A<3?-1:A<6?-.5:0)+"em"}),children:Pe.close})]}),e.jsx(fe,{position:"below",nodeData:re})]}));return we?e.jsx(we,Object.assign({customNodeProps:ke},Xe,{children:et})):et},q={ITEM_SINGLE:"{{count}} item",ITEMS_MULTIPLE:"{{count}} items",KEY_NEW:"Enter new key",ERROR_KEY_EXISTS:"Key already exists",ERROR_INVALID_JSON:"Invalid JSON",ERROR_UPDATE:"Update unsuccessful",ERROR_DELETE:"Delete unsuccessful",ERROR_ADD:"Adding node unsuccessful",DEFAULT_STRING:"New data!",DEFAULT_NEW_KEY:"key"},Q=(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]:q[r];return void 0===o?a:null==a?void 0:a.replace("{{count}}",String(o))})(e,t,r,n,o);var ee=[],te=[];!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=ee.indexOf(a);-1===i&&(i=ee.push(a)-1,te[i]={}),n=te[i]&&te[i][r]?te[i][r]:te[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-expand-transition-time:0.3s;--jer-highlight-color:#b3d8ff}.jer-visible{opacity:1}.jer-hidden,.jer-visible{transition:var(--jer-expand-transition-time)}.jer-hidden{opacity:0}.jer-select select{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:transparent;border:none;color:#000;cursor:inherit;font-family:inherit;font-size:.8em;line-height:inherit;margin:0;outline:none;padding:0 1em 0 0;z-index:1}select::-ms-expand{display:none}.jer-select{align-items:center;background-color:#fff;background-image:linear-gradient(0deg,#f9f9f9,#fff 33%);border:1px solid var(--jer-select-border);border-radius:.25em;cursor:pointer;display:grid;grid-template-areas:"select";line-height:1.1;max-width:15ch;min-width:12ch;padding:.25em .5em;position:relative}.jer-select select,.jer-select:after{grid-area:select}.jer-select:not(.jer-select--multiple):after{background-color:var(--jer-select-arrow);clip-path:polygon(100% 0,0 0,50% 100%);content:"";height:.5em;justify-self:end;width:.8em}select:focus+.focus{border:1px solid var(--jer-select-focus);border-radius:inherit;bottom:-1px;left:-1px;position:absolute;right:-1px;top:-1px}.jer-editor-container{border-radius:.5em;font-size:16px;line-height:1;padding:1em 1em 1em 2em;position:relative;text-align:left}.jer-editor-container textarea{border:var(--jer-form-border);border-radius:.3em;color:var(--jer-input-color);outline:none}.jer-editor-container textarea:focus{border:var(--jer-form-border-focus)}.jer-editor-container input{border:var(--jer-form-border);border-radius:.3em;font-family:inherit;outline:none}.jer-editor-container input:focus{border:var(--jer-form-border-focus)}.jer-editor-container ::selection{background-color:var(--jer-highlight-color)}.jer-collection-header-row,.jer-value-main-row{align-items:center;display:flex;gap:.3em;min-height:1.7em}.jer-collection-header-row{display:flex;flex-wrap:wrap}.jer-collapse-icon{left:-1.2em;position:absolute;top:.35em}.jer-collection-inner{position:relative;transition:var(--jer-expand-transition-time)}.jer-collection-text-edit{align-items:flex-start;display:flex;flex-direction:column;gap:.3em}.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}.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}.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:transform var(--jer-expand-transition-time)}.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-accordion-icon,.jer-rotate-90{transition:transform var(--jer-expand-transition-time)}.jer-icon:hover{opacity:.85;transform:scale(1.2);transition:.3s}.jer-empty-string:after{content:"<empty string>:";font-size:90%;font-style:italic}.jer-drag-n-drop-padding{border:1px dashed #e0e0e0;border-radius:.3em;height:.5em}.jer-clickzone{height:calc(100% - .8em);left:-1em;position:absolute;top:1.2em}',{});const ne=({data:n,setData:r,rootName:a="root",onUpdate:s=(()=>{}),onEdit:l=s,onDelete:c=s,onAdd:d=s,onChange:u,onError:p,showErrorMessages:g=!0,enableClipboard:m=!0,indent:h=2,collapse:y=!1,collapseAnimationTime:b=300,showCollectionCount:f=!0,restrictEdit:v=!1,restrictDelete:x=!1,restrictAdd:E=!1,restrictTypeSelection:D=!1,restrictDrag:w=!0,searchFilter:k,searchText:C,searchDebounceTime:S=350,keySort:O=!1,showArrayIndices:N=!0,showStringQuotes:A=!0,defaultValue:T=null,minWidth:P=250,maxWidth:R="min(600px, 90vw)",rootFontSize:M,stringTruncate:V=250,translations:F={},className:z,id:I,customText:_={},customNodeDefinitions:L=[],customButtons:K=[],jsonParse:B=JSON.parse,jsonStringify:W=(e=>JSON.stringify(e,null,2)),errorMessageTimeout:G=2500})=>{const{getStyles:H}=j(),U=t.useCallback(oe(y),[y]),$=t.useCallback(Q(F,_),[F,_]),[J,X]=t.useState(C),[q,ee]=(({setData:e,data:n})=>{const[r,o]=t.useState(e?void 0:n),a=t.useCallback((t=>{e?e(t):o(t)}),[e]);return t.useEffect((()=>{e||o(n)}),[n]),[e?n:r,a]})({setData:r,data:n}),te=document.querySelector(":root"),ne=getComputedStyle(document.documentElement).getPropertyValue("--jer-expand-transition-time");1e3*parseFloat(ne)!==b&&(null==te||te.style.setProperty("--jer-expand-transition-time",b/1e3+"s")),t.useEffect((()=>{const e=setTimeout((()=>X(C)),S);return()=>clearTimeout(e)}),[C,S]);const se={key:a,path:[],level:0,index:0,value:q,size:"object"==typeof q&&null!==q?Object.keys(q).length:1,parentData:null,fullData:q},le=(e,t)=>o(void 0,void 0,void 0,(function*(){const n=yield e(t);if(!0===n||void 0===n)return void ee(t.newData);const r=ie(n)?n:["error",n],[o,a]=r;if("error"===o)return ee(t.currentData),!1===a?$("ERROR_UPDATE",se):String(a);ee(a)})),ce=t.useMemo((()=>oe(v)),[v]),de=t.useMemo((()=>oe(x)),[x]),ue=t.useMemo((()=>oe(E)),[E]),pe=t.useMemo((()=>oe(w)),[w]),ge=t.useMemo((()=>ae(k)),[k]),me={name:a,nodeData:se,onEdit:(e,t)=>o(void 0,void 0,void 0,(function*(){const{currentData:n,newData:r,currentValue:o,newValue:a}=re(q,t,e,"update");if(o!==a)return yield le(l,{currentData:n,newData:r,currentValue:o,newValue:a,name:t.slice(-1)[0],path:t})})),onDelete:(e,t)=>o(void 0,void 0,void 0,(function*(){const{currentData:n,newData:r,currentValue:o,newValue:a}=re(q,t,e,"delete");return yield le(c,{currentData:n,newData:r,currentValue:o,newValue:a,name:t.slice(-1)[0],path:t})})),onAdd:(e,t)=>o(void 0,void 0,void 0,(function*(){const{currentData:n,newData:r,currentValue:o,newValue:a}=re(q,t,e,"add");return yield le(d,{currentData:n,newData:r,currentValue:o,newValue:a,name:t.slice(-1)[0],path:t})})),onChange:u,onError:p,showErrorMessages:g,onMove:(e,t,n)=>o(void 0,void 0,void 0,(function*(){if(null===e)return;const{currentData:r,newData:o,currentValue:a}=re(q,e,"","delete"),i=e.slice(-1)[0],s=t.slice(0,-1),c=t.slice(-1)[0];let d="number"==typeof c?"above"===n?c:c+1:"number"==typeof i?`arr_${i}`:i;e.slice(0,-1).join(".")===t.slice(0,-1).join(".")&&"number"==typeof i&&"number"==typeof d&&i<d&&(d-=1);const u="number"==typeof d?{insert:!0}:"above"===n?{insertBefore:c}:{insertAfter:c},{newData:p,newValue:g}=re(o,[...s,d],a,"add",u);return yield le(l,{currentData:r,newData:p,currentValue:a,newValue:g,name:t.slice(-1)[0],path:t})})),showCollectionCount:f,collapseFilter:U,collapseAnimationTime:b,restrictEditFilter:ce,restrictDeleteFilter:de,restrictAddFilter:ue,restrictTypeSelection:D,restrictDragFilter:pe,canDragOnto:!1,searchFilter:ge,searchText:J,enableClipboard:m,keySort:O,showArrayIndices:N,showStringQuotes:A,indent:h,defaultValue:T,stringTruncate:V,translate:$,customNodeDefinitions:L,customButtons:K,parentData:null,jsonParse:B,jsonStringify:W,errorMessageTimeout:G},he=Object.assign(Object.assign({},H("container",se)),{minWidth:P,maxWidth:R});return he.fontSize=null!=M?M:he.fontSize,e.jsx("div",{id:I,className:"jer-editor-container "+z,style:he,children:i(q)?e.jsx(Z,Object.assign({data:q},me)):e.jsx(Y,Object.assign({data:q,showLabel:!0},me))})},re=(e,t,o,a,i={})=>{if(0===t.length)return{currentData:e,newData:o,currentValue:e,newValue:o};const s=Object.assign({remove:"delete"===a},i),l="add"!==a?r(e,t):void 0;return{currentData:e,newData:n(e,t,o,s),currentValue:l,newValue:"delete"!==a?o:void 0}},oe=e=>"boolean"==typeof e?()=>e:"number"==typeof e?({level:t})=>t>=e:e,ae=e=>{if(void 0!==e)return"value"===e?c:"key"===e?d:"all"===e?(e,t)=>c(e,t)||d(e,t):e},ie=e=>Array.isArray(e)&&2===e.length&&["error","value"].includes(e[0]),se=({value:t,setIsEditing:n,getStyles:r,customNodeProps:o,nodeData:a})=>{var i,s;const l=null!==(i=null==o?void 0:o.stringTruncate)&&void 0!==i?i:100,c=r("string",a);return e.jsx("div",{onDoubleClick:()=>n(!0),onClick:e=>{(e.getModifierState("Control")||e.getModifierState("Meta"))&&n(!0)},className:"jer-value-string jer-hyperlink",style:c,children:e.jsxs("a",{href:t,target:"_blank",rel:"noreferrer",style:{color:null!==(s=c.color)&&void 0!==s?s:void 0},children:['"',u(t,l),'"']})})},le={condition:({value:e})=>"string"==typeof e&&/^https?:\/\/.+\..+$/.test(e),element:se,showOnView:!0,showOnEdit:!1};exports.assign=n,exports.extract=r,exports.IconAdd=O,exports.IconCancel=R,exports.IconChevron=M,exports.IconCopy=T,exports.IconDelete=A,exports.IconEdit=N,exports.IconOk=P,exports.JsonEditor=t=>e.jsx(y,{theme:t.theme,icons:t.icons,children:e.jsx(B,{children:e.jsx(ne,Object.assign({},t))})}),exports.LinkCustomComponent=se,exports.LinkCustomNodeDefinition=le,exports.isCollection=i,exports.matchNode=c,exports.matchNodeKey=d,exports.themes=g,exports.truncate=u;

@@ -63,2 +63,3 @@ import React$1 from 'react';

jsonStringify?: (input: JsonData) => string;
errorMessageTimeout?: number;
}

@@ -159,2 +160,3 @@ declare const DataTypes: readonly ["string", "number", "boolean", "null", "object", "array"];

customButtons: CustomButtonDefinition[];
errorMessageTimeout: number;
}

@@ -161,0 +163,0 @@ interface CollectionNodeProps extends BaseNodeProps {

@@ -1,1 +0,1 @@

import{jsxs as e,jsx as t,Fragment as n}from"react/jsx-runtime";import{createContext as r,useContext as o,useEffect as a,useState as i,useMemo as l,useCallback as s,useRef as c}from"react";import d from"object-property-assigner";export{default as assign}from"object-property-assigner";import u from"object-property-extractor";export{default as extract}from"object-property-extractor";function p(e,t,n,r){return new(n||(n=Promise))((function(o,a){function i(e){try{s(r.next(e))}catch(e){a(e)}}function l(e){try{s(r.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,l)}s((r=r.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const g=({className:n,name:r,value:o,setValue:a,handleKeyPress:i,styles:l})=>{if("string"!=typeof o)return null;const s="\n"===o.slice(-1)?o+".":o;return e("div",{style:{display:"grid"},children:[t("textarea",{id:`${r}_textarea`,style:Object.assign({height:"auto",gridArea:"1 / 1 / 2 / 2",overflowY:"auto",whiteSpace:"pre-wrap"},l),rows:1,className:n,name:`${r}_textarea`,value:o,onChange:e=>a(e.target.value),autoFocus:!0,onFocus:e=>{o.length<40&&e.target.select()},onKeyDown:i}),t("span",{className:n,style:Object.assign({visibility:"hidden",height:"auto",gridArea:"1 / 1 / 2 / 2",color:"red",opacity:.9,whiteSpace:"pre-wrap",overflowY:"auto",border:"1px solid transparent"},l),children:s})]})},h=e=>null!==e&&"object"==typeof e,m=(e,t,n,r="")=>{if(!n&&!r)return!0;switch(e){case"collection":if(n){if(n(t,r))return!0;if(!y(r,t,n))return!1}if(!n&&r&&!y(r,t))return!1;break;case"value":if(n&&!n(t,r))return!1;if(!n&&r&&!b(t,r))return!1}return!0},y=(e="",t,n=b)=>{const r=t.value;return Object.entries(r).some((([o,a])=>{const i=[...t.path,o],l=Object.assign(Object.assign({},t),{key:o,path:i,level:t.level+1,value:a,size:i.length,parentData:r});return h(a)?y(e,l,n):n(l,e)}))},b=(e,t="")=>{const{value:n}=e;if(null===n&&"null".includes(t.toLowerCase()))return!0;switch(typeof n){case"string":return n.toLowerCase().includes(t.toLowerCase());case"number":return!!String(n).includes(t);case"boolean":return n?"true".includes(t.toLowerCase())||"1"===t:"false".includes(t.toLowerCase())||"0"===t;default:return!1}},f=({key:e,path:t},n="")=>!!b({value:e},n)||!!t.some((e=>b({value:e},n))),v=(e,t=200)=>"string"==typeof e?e.length<t?e:`${e.slice(0,t-2).trim()}...`:e,j=e=>e.map((e=>""===e?String.fromCharCode(0):e)).join("."),E={default:{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)"}},githubDark:{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)"}},githubLight:{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"}},monoDark:{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"}},monoLight:{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"}},candyWrapper:{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"}},psychedelic:{displayName:"Psychedelic",fragments:{minty:{backgroundColor:"#F1FAEE"},pale:{color:"#A8DADC"},mid:{color:"#457B9D"},dark:{color:"#1D3557"},pop:{color:"#E63946"},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"}}},D=E.default,w=r({getStyles:()=>({}),icons:{}}),k=({theme:e="default",icons:n={},children:r})=>{const o=O(e);return t(w.Provider,{value:{getStyles:(e,t)=>"function"==typeof o[e]?o[e](t):o[e],icons:n},children:r})},C=()=>o(w),O=e=>{var t,n,r,o;const a={},i=(Array.isArray(e)?e:[e]).map((t=>"default"===e?{}:"string"==typeof t?S(E[t],a):N(t)?S({fragments:{},styles:t},a):S(t,a))),l=S(D,{});Object.keys(l).forEach((e=>{const t=e;i.forEach((e=>{e[t]&&(l[t]=Object.assign(Object.assign({},l[t]),e[t]))}))}));const s=Object.assign({},l);return Object.entries(a).forEach((([e,t])=>{const n=e;s[n]=e=>{const r=t(e)||{};return Object.assign(Object.assign({},l[n]),r)}})),"function"!=typeof(null==s?void 0:s.inputHighlight)&&(null===(t=null==s?void 0:s.inputHighlight)||void 0===t?void 0:t.backgroundColor)&&document.documentElement.style.setProperty("--jer-highlight-color",null===(n=null==s?void 0:s.inputHighlight)||void 0===n?void 0:n.backgroundColor),"function"!=typeof(null==s?void 0:s.iconCopy)&&(null===(r=null==s?void 0:s.iconCopy)||void 0===r?void 0:r.color)&&document.documentElement.style.setProperty("--jer-icon-copy-color",null===(o=null==s?void 0:s.iconCopy)||void 0===o?void 0:o.color),s},S=(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;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),{[x[e]]:t}):Object.assign(Object.assign({},r),t)}return Object.assign(Object.assign({},r),o)}),{});o[e]=a})),o},N=e=>!("styles"in e),x={container:"backgroundColor",collection:"backgroundColor",collectionInner:"backgroundColor",collectionElement:"backgroundColor",dropZone:"borderColor",property:"color",bracket:"color",itemCount:"color",string:"color",number:"color",boolean:"color",null:"color",input:"color",inputHighlight:"backgroundColor",error:"color",iconCollection:"color",iconEdit:"color",iconDelete:"color",iconAdd:"color",iconCopy:"color",iconOk:"color",iconCancel:"color"},A="**INVALID_FUNCTION**",T=({value:n,setValue:r,isEditing:o,path:a,setIsEditing:i,handleEdit:l,handleCancel:s,stringTruncate:c,showStringQuotes:d,nodeData:u})=>{const{getStyles:p}=C(),h=j(a),m=d?'"':"";return o?t(g,{className:"jer-input-text",name:h,value:n,setValue:r,isEditing:o,handleKeyPress:e=>{"Enter"!==e.key||e.shiftKey?"Escape"===e.key&&s():l()},styles:p("input",u)}):e("div",{id:`${h}_display`,onDoubleClick:()=>i(!0),onClick:e=>{(e.getModifierState("Control")||e.getModifierState("Meta"))&&i(!0)},className:"jer-value-string",style:p("string",u),children:[m,v(n,c),m]})},P=({value:e,setValue:n,isEditing:r,path:o,setIsEditing:a,handleEdit:i,handleCancel:l,nodeData:s})=>{const{getStyles:c}=C();return r?t("input",{className:"jer-input-number",type:"text",name:j(o),value:e,onChange:e=>n(e.target.value.replace(/[^0-9.-]/g,"")),autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:t=>{switch(t.key){case"Enter":i();break;case"Escape":l();break;case"ArrowUp":t.preventDefault(),n(Number(e)+1);break;case"ArrowDown":t.preventDefault(),n(Number(e)-1)}},style:Object.assign({width:String(e).length/1.5+2+"em"},c("input",s))}):t("span",{onDoubleClick:()=>a(!0),className:"jer-value-number",style:c("number",s),children:e})},V=({value:e,setValue:n,isEditing:r,path:o,setIsEditing:a,handleEdit:i,handleCancel:l,nodeData:s})=>{const{getStyles:c}=C();return r?t("input",{className:"jer-input-boolean",type:"checkbox",name:j(o),checked:e,onChange:()=>n(!e),onKeyDown:e=>{"Enter"===e.key?i():"Escape"===e.key&&l()},autoFocus:!0}):t("span",{onDoubleClick:()=>a(!0),className:"jer-value-boolean",style:c("boolean",s),children:String(e)})},R=({value:e,isEditing:n,setIsEditing:r,handleEdit:o,handleCancel:i,nodeData:l})=>{const{getStyles:s}=C();a((()=>(n&&document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c))),[n]);const c=e=>{"Enter"===e.key?o():"Escape"===e.key&&i()};return t("div",{onDoubleClick:()=>r(!0),className:"jer-value-null",style:s("null",l),children:String(e)})},z=({value:e})=>{let n="Error!";switch(typeof e){case"string":e===A&&(n="Function");break;case"undefined":n="Undefined";break;case"symbol":n="Symbol"}return t("span",{className:"jer-value-invalid",children:n})},F=({size:n,style:r,className:o})=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:n,height:n,className:o,style:r,children:[t("path",{d:"M13 7h-2v4H7v2h4v4h2v-4h4v-2h-4z"}),t("path",{d:"M12 2C6.486 2 2 6.486 2 12s4.486 10 10 10 10-4.486 10-10S17.514 2 12 2zm0 18c-4.411 0-8-3.589-8-8s3.589-8 8-8 8 3.589 8 8-3.589 8-8 8z"})]}),_=({size:n,style:r,className:o})=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:n,height:n,className:o,style:r,transform:"translate(0, 0.5)",children:[t("path",{d:"M7 17.013l4.413-.015 9.632-9.54c.378-.378.586-.88.586-1.414s-.208-1.036-.586-1.414l-1.586-1.586c-.756-.756-2.075-.752-2.825-.003L7 12.583v4.43zM18.045 4.458l1.589 1.583-1.597 1.582-1.586-1.585 1.594-1.58zM9 13.417l6.03-5.973 1.586 1.586-6.029 5.971L9 15.006v-1.589z"}),t("path",{d:"M5 21h14c1.103 0 2-.897 2-2v-8.668l-2 2V19H8.158c-.026 0-.053.01-.079.01-.033 0-.066-.009-.1-.01H5V5h6.847l2-2H5c-1.103 0-2 .897-2 2v14c0 1.103.897 2 2 2z"})]}),I=({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"})}),L=({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"})]}),M=({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"})]}),K=({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"})}),B=({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"})}),W=({name:e,nodeData:r,rotate:o})=>{var a,i,l,s,c,d,u;const{getStyles:p,icons:g}=C(),h={size:"1.4em",className:"jer-icon"};switch(e){case"add":return null!==(a=null==g?void 0:g.add)&&void 0!==a?a:t(F,Object.assign({},h,{style:p("iconAdd",r)}));case"edit":return null!==(i=null==g?void 0:g.edit)&&void 0!==i?i:t(_,Object.assign({},h,{style:p("iconEdit",r)}));case"delete":return null!==(l=null==g?void 0:g.delete)&&void 0!==l?l:t(I,Object.assign({},h,{style:p("iconDelete",r),size:"1.45em"}));case"copy":return null!==(s=null==g?void 0:g.copy)&&void 0!==s?s:t(L,Object.assign({},h,{style:p("iconCopy",r),size:"1.2em"}));case"ok":return null!==(c=null==g?void 0:g.ok)&&void 0!==c?c:t(M,Object.assign({},h,{style:Object.assign({fontSize:"90%"},p("iconOk",r))}));case"cancel":return null!==(d=null==g?void 0:g.cancel)&&void 0!==d?d:t(K,Object.assign({},h,{style:Object.assign({fontSize:"130%"},p("iconCancel",r))}));case"chevron":return null!==(u=null==g?void 0:g.chevron)&&void 0!==u?u:t(B,{size:"1em",style:p("iconCollection",r)});default:return t(n,{})}},G=({startEdit:r,handleDelete:o,handleAdd:a,enableClipboard:l,type:s,customButtons:c,nodeData:d,translate:u})=>{const{getStyles:p}=C(),g=u("KEY_NEW",d),[h,m]=i(!1),[y,b]=i(g),{key:f,path:v,value:j}=d;return e("div",{className:"jer-edit-buttons",style:{opacity:h?1:void 0},children:[l&&t("div",{onClick:e=>{e.stopPropagation();let t,n="value",r="";if(l){if(!0===(e.ctrlKey||e.metaKey))t=U(v),r=t,n="path";else t=j,r=s?JSON.stringify(j,null,2):String(t);navigator.clipboard.writeText(r)}"function"==typeof l&&l({value:t,stringValue:r,path:v,key:f,type:n})},className:"jer-copy-pulse",children:t(W,{name:"copy",nodeData:d})}),r&&t("div",{onClick:e=>{e.stopPropagation(),r()},children:t(W,{name:"edit",nodeData:d})}),o&&t("div",{onClick:e=>{e.stopPropagation(),o()},children:t(W,{name:"delete",nodeData:d})}),a&&t("div",{onClick:e=>{e.stopPropagation(),"object"===s?m(!0):a("")},children:t(W,{name:"add",nodeData:d})}),null==c?void 0:c.map((({Element:e,onClick:n},r)=>t("div",{onClick:e=>n(d,e),children:t(e,{})},r))),h&&a&&"object"===s&&e(n,{children:[t("input",{className:"jer-input-new-key",type:"text",name:"new-object-key",value:y,onChange:e=>b(e.target.value),autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>{"Enter"===e.key&&a?(m(!1),a(y),b(g)):"Escape"===e.key&&(m(!1),b(g))},style:p("input",d)}),t(H,{onOk:()=>{y&&(m(!1),a(y))},onCancel:()=>{m(!1)},nodeData:d})]})]})},H=({onOk:n,onCancel:r,nodeData:o})=>e("div",{className:"jer-confirm-buttons",children:[t("div",{onClick:n,children:t(W,{name:"ok",nodeData:o})}),t("div",{onClick:r,children:t(W,{name:"cancel",nodeData:o})})]}),U=e=>e.reduce(((e,t)=>"number"==typeof t?`${e}[${t}]`:""===e?t:`${e}.${t}`),""),Y=["string","number","boolean","null","object","array"],$=(e=[],t)=>{const n=e.filter((({condition:e})=>e(t)));if(0===n.length)return{};const r=n[0],{element:o,wrapperElement:a,customNodeProps:i,wrapperProps:l,hideKey:s=!1,showEditTools:c=!0,showOnEdit:d=!1,showOnView:u=!0,showCollectionWrapper:p=!0}=r,g=function(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}(r,["element","wrapperElement","customNodeProps","wrapperProps","hideKey","showEditTools","showOnEdit","showOnView","showCollectionWrapper"]);return Object.assign({CustomNode:o,CustomWrapper:a,customNodeProps:i,wrapperProps:l,hideKey:s,showEditTools:c,showOnEdit:d,showOnView:u,showCollectionWrapper:p},g)},J=r({collapseState:null,setCollapseState:()=>{},doesPathMatch:()=>!1,currentlyEditingElement:null,setCurrentlyEditingElement:()=>{},areChildrenBeingEdited:()=>!1,dragSource:{path:null,pathString:null},setDragSource:()=>{}}),X=({children:e})=>{const[n,r]=i(null),[o,a]=i(null),[l,s]=i({path:null,pathString:null});return t(J.Provider,{value:{collapseState:n,setCollapseState:e=>{r(e),null!==e&&setTimeout((()=>r(null)),2e3)},doesPathMatch:e=>{if(null===n)return!1;for(const[t,r]of n.path.entries())if(r!==e[t])return!1;return!0},currentlyEditingElement:o,setCurrentlyEditingElement:a,areChildrenBeingEdited:e=>null!==o&&o.includes(e),dragSource:l,setDragSource:s},children:e})},Z=()=>o(J),Q=({props:e,collapsed:t})=>{const{data:n,nodeData:r,parentData:o,onEdit:a,onError:s,showErrorMessages:c,restrictEditFilter:d,restrictDeleteFilter:u,restrictAddFilter:p,restrictDragFilter:g,translate:h}=e,{currentlyEditingElement:m,setCurrentlyEditingElement:y}=Z(),[b,f]=i(null),v=Object.assign(Object.assign({},r),{collapsed:t}),{path:E,key:D,size:w}=v,k=j(E),C=l((()=>!d(v)),[v]),O=l((()=>!u(v)),[v]),S=l((()=>!p(v)),[v]),N=l((()=>!g(v)&&O&&null===m),[v]),x=e=>{c&&(f(e),setTimeout((()=>f(null)),2500)),console.warn("Error",e)},A=l((()=>(e,t)=>{x(e.message),s&&s({currentData:v.fullData,errorValue:t,currentValue:n,name:D,path:E,error:e})}),[s,c]),T=m===k,P=m===`key_${k}`,V="number"==typeof E.slice(-1)[0];return{pathString:k,nodeData:v,path:E,name:D,size:w,canEdit:C,canDelete:O,canAdd:S,canDrag:N,error:b,showError:x,onError:A,setError:f,handleEditKey:e=>{if(y(null),D===e)return;if(!o)return;const t=E.slice(0,-1);if(Object.keys(o).includes(e))return void A({code:"KEY_EXISTS",message:h("ERROR_KEY_EXISTS",v)},e);const n=Object.fromEntries(Object.entries(o).map((([t,n])=>t===D?[e,n]:[t,n])));a(n,t).then((t=>{t&&A({code:"UPDATE_ERROR",message:t},e)}))},derivedValues:{isEditing:T,isEditingKey:P,isArray:V,canEditKey:null!==o&&C&&S&&O&&!V}}},q=({canDrag:e,canDragOnto:n,path:r,nodeData:o,onMove:a,onError:s,translate:c})=>{const{getStyles:d}=C(),{dragSource:u,setDragSource:p}=Z(),[g,h]=i(!1),m=j(r),y=l((()=>e?{onDragStart:e=>{e.stopPropagation(),p({path:r,pathString:m})},onDragEnd:e=>{e.stopPropagation(),p({path:null,pathString:null})}}:{}),[e]),b=l((()=>e=>n?{onDragOver:e=>{e.stopPropagation(),e.preventDefault()},onDrop:t=>{t.stopPropagation(),v(e),p({path:null,pathString:null}),h(!1)},onDragEnter:t=>{var n;t.stopPropagation(),m.startsWith(null!==(n=u.pathString)&&void 0!==n?n:"")||h(e)},onDragExit:e=>{e.stopPropagation(),h(!1)}}:{}),[u,n]),f=l((()=>n&&null!==u.pathString?t("div",Object.assign({className:"jer-drop-target-bottom",style:{height:"50%",position:"absolute",width:"100%",top:"50%",zIndex:r.length}},b("below"))):null),[u,n]),v=e=>{var t,n;const i=null===(t=u.path)||void 0===t?void 0:t.slice(-1)[0],l=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&&l!==d?s({code:"KEY_EXISTS",message:c("ERROR_KEY_EXISTS",o)},i):a(u.path,r,e).then((e=>{e&&s({code:"UPDATE_ERROR",message:e},o.value)}))};return{dragSourceProps:y,getDropTargetProps:b,BottomDropTarget:f,DropTargetPadding:({position:e,nodeData:n})=>g===e?t("div",{className:"jer-drag-n-drop-padding",style:d("dropZone",n)}):null,handleDrop:v}},ee=(e,t)=>{var n,r;const o=document.getElementsByClassName("jer-editor-container"),a=parseInt(o.length>0?getComputedStyle(o[0]).getPropertyValue("line-height"):"16px"),i=(null!==(r=null===(n=t.current)||void 0===n?void 0:n.offsetWidth)&&void 0!==r?r:0)/(.5*a),l=JSON.stringify(e,null,2).replace(/\\n/g,"\n").split("\n").map((e=>Math.ceil(e.length/i))).reduce(((e,t)=>e+t),0)*a;return Math.min(l+30,window.innerHeight-50)},te=n=>{const{data:r,parentData:o,onEdit:c,onDelete:d,onChange:u,onMove:p,enableClipboard:g,canDragOnto:h,restrictTypeSelection:y,searchFilter:b,searchText:f,showLabel:v,stringTruncate:j,showStringQuotes:E,indent:D,translate:w,customNodeDefinitions:k}=n,{getStyles:O}=C(),{setCurrentlyEditingElement:S,setCollapseState:N}=Z(),[x,T]=i("function"==typeof r?A:r),{pathString:P,nodeData:V,path:R,name:z,canEdit:F,canDelete:_,canDrag:I,error:L,onError:M,handleEditKey:K,derivedValues:B}=Q({props:n}),{dragSourceProps:W,getDropTargetProps:U,BottomDropTarget:J,DropTargetPadding:X}=q({canDrag:I,canDragOnto:h,path:R,nodeData:V,onMove:p,onError:M,translate:w}),ee=$(k,V),[te,ae]=i(ne(r,ee)),ie=s((e=>{if(!u)return void T(e);const t=u({currentData:V.fullData,newValue:e,currentValue:x,name:z,path:R});T(t)}),[u]);a((()=>{T("function"==typeof r?A:r),ae(ne(r,ee))}),[r,L]);const{CustomNode:le,customNodeProps:se,hideKey:ce,showEditTools:de=!0,showOnEdit:ue,showOnView:pe}=ee,ge=[...Y,...k.filter((({showInTypesSelector:e=!1,name:t})=>e&&!!t)).map((({name:e})=>e))],he=l((()=>{if("boolean"==typeof y)return y?[]:ge;if(Array.isArray(y))return y;const e=y(V);return"boolean"==typeof e?e?[]:ge:e}),[V,y]);if(!m("value",V,b,f))return null;const me=()=>{let e;switch(S(null),te){case"object":e={[w("DEFAULT_NEW_KEY",V)]:x};break;case"array":e=null!=x?x:[];break;case"number":{const t=Number(x);e=isNaN(t)?0:t;break}default:e=x}c(e,R).then((t=>{t&&M({code:"UPDATE_ERROR",message:t},e)}))},ye=()=>{S(null),T(r),ae(ne(r,ee))},{isEditing:be,isEditingKey:fe,canEditKey:ve}=B,je=!be&&L,Ee=be&&he.length>0,De="invalid"!==te&&!L&&de,we=v&&fe,ke=v&&!fe&&!ce,Ce={value:x,parentData:o,setValue:ie,isEditing:be,setIsEditing:F?()=>S(P):()=>{},handleEdit:me,handleCancel:ye,path:R,stringTruncate:j,showStringQuotes:E,nodeData:V,translate:w},Oe=le&&(be&&ue||!be&&pe)?t(le,Object.assign({},n,{value:x,customNodeProps:se,setValue:ie,handleEdit:me,handleCancel:ye,handleKeyPress:e=>{"Enter"===e.key?me():"Escape"===e.key&&ye()},isEditing:be,setIsEditing:()=>S(P),getStyles:O})):re(ne(r),Ce);return e("div",Object.assign({className:"jer-component jer-value-component",style:{marginLeft:D/2+"em",position:"relative"},draggable:I},W,U("above"),{children:[J,t(X,{position:"above",nodeData:V}),e("div",{className:"jer-value-main-row",style:{flexWrap:z.length>10?"wrap":"nowrap"},children:[ke&&t("span",{className:"jer-key-text",style:Object.assign(Object.assign({},O("property",V)),{minWidth:`${Math.min(String(z).length+1,5)}ch`,flexShrink:z.length>10?1:0}),onDoubleClick:()=>ve&&S(`key_${P}`),children:""===z?t("span",{className:R.length>0?"jer-empty-string":void 0}):`${z}:`}),we&&t("input",{className:"jer-input-text jer-key-edit",type:"text",name:P,defaultValue:z,autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>{"Enter"===e.key?K(e.target.value):"Escape"===e.key&&ye()},style:{width:String(z).length/1.5+.5+"em"}}),e("div",{className:"jer-value-and-buttons",children:[t("div",{className:"jer-input-component",children:Oe}),be?t(H,{onOk:me,onCancel:ye,nodeData:V}):De&&t(G,{startEdit:F?()=>S(P):void 0,handleDelete:_?()=>{d(x,R).then((e=>{e&&M({code:"DELETE_ERROR",message:e},x)}))}:void 0,enableClipboard:g,translate:w,customButtons:n.customButtons,nodeData:V}),Ee&&e("div",{className:"jer-select",children:[t("select",{name:`${z}-type-select`,className:"jer-type-select",onChange:e=>(e=>{const t=k.find((t=>t.name===e));if(t)c(t.defaultValue,R),ae(e),S(null),N({path:R,collapsed:!1});else{const t=oe(x,e,w("DEFAULT_NEW_KEY",V),(null==ee?void 0:ee.CustomNode)?w("DEFAULT_STRING",V):void 0);ie(t),c(t,R).then((e=>{e&&(M({code:"UPDATE_ERROR",message:e},t),S(null))}))}})(e.target.value),value:te,children:he.map((e=>t("option",{value:e,children:e},e)))}),t("span",{className:"focus"})]}),je&&t("span",{className:"jer-error-slug",style:O("error",V),children:L})]})]}),t(X,{position:"below",nodeData:V})]}))},ne=(e,t)=>(null==t?void 0:t.CustomNode)&&(null==t?void 0:t.name)&&t.showInTypesSelector?t.name:"string"==typeof e?"string":"number"==typeof e?"number":"boolean"==typeof e?"boolean":null===e?"null":"invalid",re=(e,n)=>{const r=n.value;switch(e){case"string":return t(T,Object.assign({},n,{value:r}));case"number":return t(P,Object.assign({},n,{value:r}));case"boolean":return t(V,Object.assign({},n,{value:r}));case"null":return t(R,Object.assign({},n));default:return t(z,Object.assign({},n))}},oe=(e,t,n,r)=>{switch(t){case"string":return null!=r?r:String(e);case"number":{const t=Number(e);return isNaN(t)?0:t}case"boolean":return!!e;case"null":return null;case"object":return{[n]:e};case"array":return[e];default:return String(e)}},ae=r=>{const{getStyles:o}=C(),{collapseState:s,setCollapseState:d,doesPathMatch:y,currentlyEditingElement:b,setCurrentlyEditingElement:f,areChildrenBeingEdited:v}=Z(),{data:j,nodeData:E,parentData:D,showCollectionCount:w,onEdit:k,onAdd:O,onDelete:S,canDragOnto:N,collapseFilter:x,collapseAnimationTime:A,onMove:T,enableClipboard:P,searchFilter:V,searchText:R,indent:z,keySort:F,showArrayIndices:_,defaultValue:I,translate:L,customNodeDefinitions:M,jsonParse:K,jsonStringify:B}=r,[U,Y]=i(B(j)),J=x(E),{contentRef:X,isAnimating:ne,maxHeight:re,collapsed:oe,animateCollapse:ie}=((e,t,n)=>{const[r,o]=i(n?0:void 0),[a,l]=i(n),s=c(!1),d=c(null),u=c(0),p=c();return{contentRef:d,isAnimating:s.current,animateCollapse:n=>{var r,i;if(a!==n){switch(window.clearTimeout(p.current),s.current=!0,n){case!0:{const e=null!==(i=null===(r=d.current)||void 0===r?void 0:r.offsetHeight)&&void 0!==i?i:0;u.current=e,o(e),setTimeout((()=>{o(0)}),5);break}case!1:o(u.current||ee(e,d))}l(!a),p.current=window.setTimeout((()=>{s.current=!1,n||o(void 0)}),t)}},maxHeight:r,collapsed:a}})(j,A,J),{pathString:le,nodeData:se,path:ce,name:de,size:ue,canEdit:pe,canDelete:ge,canAdd:he,canDrag:me,error:ye,setError:be,onError:fe,handleEditKey:ve,derivedValues:je}=Q({props:r,collapsed:oe}),{dragSourceProps:Ee,getDropTargetProps:De,BottomDropTarget:we,DropTargetPadding:ke}=q({canDrag:me,canDragOnto:N,path:ce,nodeData:se,onMove:T,onError:fe,translate:L}),Ce=c(!J);a((()=>{Y(B(j))}),[j]),a((()=>{const e=x(se)&&!je.isEditing;Ce.current=!e,ie(e)}),[x]),a((()=>{null!==s&&y(ce)&&(Ce.current=!0,ie(s.collapsed))}),[s]);const Oe=l((()=>e=>"function"!=typeof I?I:I(e)),[I]),{CustomNode:Se,customNodeProps:Ne,CustomWrapper:xe,wrapperProps:Ae={},hideKey:Te,showEditTools:Pe=!0,showOnEdit:Ve,showOnView:Re,showCollectionWrapper:ze=!0}=l((()=>$(M,se)),[]);if(!m("collection",se,V,R)&&se.level>0)return null;const Fe=Array.isArray(j)?"array":"object",_e="array"===Fe?{open:"[",close:"]"}:{open:"{",close:"}"},Ie=e=>{"Enter"===e.key&&(e.metaKey||e.shiftKey||e.ctrlKey)?Me():"Escape"===e.key&&Be()},Le=e=>{if(e.getModifierState("Alt"))return Ce.current=!0,void d({collapsed:!oe,path:ce});b&&b.includes(le)||(Ce.current=!0,d(null),ie(!oe))},Me=()=>{try{const e=K(U);if(f(null),be(null),JSON.stringify(e)===JSON.stringify(j))return;k(e,ce).then((t=>{t&&fe({code:"UPDATE_ERROR",message:t},e)}))}catch(e){fe({code:"INVALID_JSON",message:L("ERROR_INVALID_JSON",se)},U)}},Ke=ce.length>0?()=>{S(j,ce).then((e=>{e&&fe({code:"DELETE_ERROR",message:e},u(j,ce))}))}:void 0,Be=()=>{f(null),be(null),Y(B(j))},{isEditing:We,isEditingKey:Ge,isArray:He,canEditKey:Ue}=je,Ye="when-closed"===w?oe:w,$e=!We&&Pe,Je=(_||!He)&&!Te&&void 0!==de,Xe=Se&&(We&&Ve||!We&&Re),Ze=F&&"object"===Fe,Qe=Object.entries(j).map((([e,t])=>["array"===Fe?Number(e):e,t]));Ze&&Qe.sort("function"==typeof F?(e,t)=>F(e[0],t[0]):void 0);const qe=Ce.current?We?t("div",{className:"jer-collection-text-edit",children:e("div",{children:[t(g,{className:"jer-collection-text-area",name:le,value:U,setValue:Y,isEditing:We,handleKeyPress:Ie,styles:o("input",se)}),t("div",{className:"jer-collection-input-button-row",children:t(H,{onOk:Me,onCancel:Be,nodeData:se})})]})}):Qe.map((([e,n],a)=>{const i={key:e,value:n,path:[...ce,e],level:ce.length+1,index:a,size:h(n)?Object.keys(n).length:1,parentData:j,fullData:se.fullData};return t("div",{className:"jer-collection-element",style:o("collectionElement",i),children:h(n)?t(ae,Object.assign({},r,{data:n,parentData:j,nodeData:i,showCollectionCount:w,canDragOnto:pe}),e):t(te,Object.assign({},r,{data:n,parentData:j,nodeData:i,canDragOnto:pe,showLabel:"object"===Fe||_}),e)},e)})):null,et=!!ze&&oe;et||(Ce.current=!0);const tt=Object.assign(Object.assign({},r),{data:j,value:j,parentData:D,nodeData:se,setValue:e=>p(void 0,void 0,void 0,(function*(){return yield k(e,ce)})),handleEdit:Me,handleCancel:Be,handleKeyPress:Ie,isEditing:We,setIsEditing:()=>f(le),getStyles:o,canDragOnto:pe}),nt=Xe?t(Se,Object.assign({customNodeProps:Ne},tt,{children:qe})):qe,rt=Ge?t("input",{className:"jer-input-text jer-key-edit",type:"text",name:le,defaultValue:de,autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>{"Enter"===e.key?ve(e.target.value):"Escape"===e.key&&Be()},style:{width:String(de).length/1.5+.5+"em"}}):Je&&t("span",{className:"jer-key-text",style:o("property",se),onClick:e=>e.stopPropagation(),onDoubleClick:()=>Ue&&f(`key_${le}`),children:""===de?t("span",{className:ce.length>0?"jer-empty-string":void 0}):`${de}:`}),ot=$e&&t(G,{startEdit:pe?()=>{Ce.current=!0,f(le)}:void 0,handleAdd:he?e=>{ie(!1);const t=Oe(se);"array"===Fe?O(t,[...ce,j.length]).then((e=>{e&&fe({code:"ADD_ERROR",message:e},t)})):e in j?fe({code:"KEY_EXISTS",message:L("ERROR_KEY_EXISTS",se)},e):O(t,[...ce,e]).then((e=>{e&&fe({code:"ADD_ERROR",message:e},t)}))}:void 0,handleDelete:ge?Ke:void 0,enableClipboard:P,type:Fe,nodeData:se,translate:L,customButtons:r.customButtons}),at=e("div",Object.assign({className:"jer-component jer-collection-component",style:Object.assign(Object.assign({marginLeft:(0===ce.length?0:z/2)+"em"},o("collection",se)),{position:"relative"}),draggable:me},Ee,De("above"),{children:[t("div",{className:"jer-clickzone",style:{width:z/2+1+"em",zIndex:10+2*se.level},onClick:e=>Le(e)}),!We&&we,t(ke,{position:"above",nodeData:se}),ze?e("div",{className:"jer-collection-header-row",style:{position:"relative"},onClick:e=>Le(e),children:[e("div",{className:"jer-collection-name",children:[t("div",{className:"jer-collapse-icon jer-accordion-icon"+(oe?" jer-rotate-90":""),style:{zIndex:11+2*se.level},onClick:e=>Le(e),children:t(W,{name:"chevron",rotate:oe,nodeData:se})}),rt,!We&&t("span",{className:"jer-brackets jer-bracket-open",style:o("bracket",se),children:_e.open})]}),!We&&Ye&&t("div",{className:"jer-collection-item-count"+(Ye?" jer-visible":" jer-hidden"),style:o("itemCount",se),children:1===ue?L("ITEM_SINGLE",Object.assign(Object.assign({},se),{size:1}),1):L("ITEMS_MULTIPLE",se,ue)}),t("div",{className:"jer-brackets"+(et?" jer-visible":" jer-hidden"),style:o("bracket",se),children:_e.close}),ot]}):Te?t(n,{}):e("div",{className:"jer-collection-header-row",style:{position:"relative"},children:[rt,ot]}),e("div",{className:"jer-collection-inner",style:Object.assign({overflowY:et||ne?"clip":"visible",maxHeight:v(le)?void 0:re},o("collectionInner",se)),ref:X,children:[nt,t("div",{className:We?"jer-collection-error-row":"jer-collection-error-row-edit",children:ye&&t("span",{className:"jer-error-slug",style:o("error",se),children:ye})}),!We&&ze&&t("div",{className:"jer-brackets jer-bracket-outside",style:Object.assign(Object.assign({},o("bracket",se)),{marginLeft:(z<3?-1:z<6?-.5:0)+"em"}),children:_e.close})]}),t(ke,{position:"below",nodeData:se})]}));return xe?t(xe,Object.assign({customNodeProps:Ae},tt,{children:at})):at},ie={ITEM_SINGLE:"{{count}} item",ITEMS_MULTIPLE:"{{count}} items",KEY_NEW:"Enter new key",ERROR_KEY_EXISTS:"Key already exists",ERROR_INVALID_JSON:"Invalid JSON",ERROR_UPDATE:"Update unsuccessful",ERROR_DELETE:"Delete unsuccessful",ERROR_ADD:"Adding node unsuccessful",DEFAULT_STRING:"New data!",DEFAULT_NEW_KEY:"key"},le=(e,t)=>(n,r,o)=>((e,t,n,r,o)=>{if(t[r]){const e=t[r](n);if(null!==e)return e}const a=r in e?e[r]:ie[r];return void 0===o?a:null==a?void 0:a.replace("{{count}}",String(o))})(e,t,r,n,o);var se=[],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=se.indexOf(a);-1===i&&(i=se.push(a)-1,ce[i]={}),n=ce[i]&&ce[i][r]?ce[i][r]:ce[i][r]=l()}else n=l();65279===e.charCodeAt(0)&&(e=e.substring(1)),n.styleSheet?n.styleSheet.cssText+=e:n.appendChild(document.createTextNode(e))}function l(){var e=document.createElement("style");if(e.setAttribute("type","text/css"),t.attributes)for(var n=Object.keys(t.attributes),o=0;o<n.length;o++)e.setAttribute(n[o],t.attributes[n[o]]);var i="prepend"===r?"afterbegin":"beforeend";return a.insertAdjacentElement(i,e),e}}(':root{--jer-select-border:#b6b6b6;--jer-select-focus:#777;--jer-select-arrow:#777;--jer-form-border:1px solid #ededf0;--jer-form-border-focus:1px solid #e2e2e2;--jer-expand-transition-time:0.3s;--jer-highlight-color:#b3d8ff}.jer-visible{opacity:1}.jer-hidden,.jer-visible{transition:var(--jer-expand-transition-time)}.jer-hidden{opacity:0}.jer-select select{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:transparent;border:none;color:#000;cursor:inherit;font-family:inherit;font-size:.8em;line-height:inherit;margin:0;outline:none;padding:0 1em 0 0;z-index:1}select::-ms-expand{display:none}.jer-select{align-items:center;background-color:#fff;background-image:linear-gradient(0deg,#f9f9f9,#fff 33%);border:1px solid var(--jer-select-border);border-radius:.25em;cursor:pointer;display:grid;grid-template-areas:"select";line-height:1.1;max-width:15ch;min-width:12ch;padding:.25em .5em;position:relative}.jer-select select,.jer-select:after{grid-area:select}.jer-select:not(.jer-select--multiple):after{background-color:var(--jer-select-arrow);clip-path:polygon(100% 0,0 0,50% 100%);content:"";height:.5em;justify-self:end;width:.8em}select:focus+.focus{border:1px solid var(--jer-select-focus);border-radius:inherit;bottom:-1px;left:-1px;position:absolute;right:-1px;top:-1px}.jer-editor-container{border-radius:.5em;font-size:16px;line-height:1;padding:1em 1em 1em 2em;position:relative;text-align:left}.jer-editor-container textarea{border:var(--jer-form-border);border-radius:.3em;color:var(--jer-input-color);outline:none}.jer-editor-container textarea:focus{border:var(--jer-form-border-focus)}.jer-editor-container input{border:var(--jer-form-border);border-radius:.3em;font-family:inherit;outline:none}.jer-editor-container input:focus{border:var(--jer-form-border-focus)}.jer-editor-container ::selection{background-color:var(--jer-highlight-color)}.jer-collection-header-row,.jer-value-main-row{align-items:center;display:flex;gap:.3em;min-height:1.7em}.jer-collection-header-row{display:flex;flex-wrap:wrap}.jer-collapse-icon{left:-1.2em;position:absolute;top:.35em}.jer-collection-inner{position:relative;transition:var(--jer-expand-transition-time)}.jer-collection-text-edit{align-items:flex-start;display:flex;flex-direction:column;gap:.3em}.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}.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}.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:transform var(--jer-expand-transition-time)}.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-accordion-icon,.jer-rotate-90{transition:transform var(--jer-expand-transition-time)}.jer-icon:hover{opacity:.85;transform:scale(1.2);transition:.3s}.jer-empty-string:after{content:"<empty string>:";font-size:90%;font-style:italic}.jer-drag-n-drop-padding{border:1px dashed #e0e0e0;border-radius:.3em;height:.5em}.jer-clickzone{height:calc(100% - .8em);left:-1em;position:absolute;top:1.2em}',{});const de=({data:e,setData:n,rootName:r="root",onUpdate:o=(()=>{}),onEdit:c=o,onDelete:d=o,onAdd:u=o,onChange:g,onError:m,showErrorMessages:y=!0,enableClipboard:b=!0,indent:f=2,collapse:v=!1,collapseAnimationTime:j=300,showCollectionCount:E=!0,restrictEdit:D=!1,restrictDelete:w=!1,restrictAdd:k=!1,restrictTypeSelection:O=!1,restrictDrag:S=!0,searchFilter:N,searchText:x,searchDebounceTime:A=350,keySort:T=!1,showArrayIndices:P=!0,showStringQuotes:V=!0,defaultValue:R=null,minWidth:z=250,maxWidth:F="min(600px, 90vw)",rootFontSize:_,stringTruncate:I=250,translations:L={},className:M,id:K,customText:B={},customNodeDefinitions:W=[],customButtons:G=[],jsonParse:H=JSON.parse,jsonStringify:U=(e=>JSON.stringify(e,null,2))})=>{const{getStyles:Y}=C(),$=s(ge(v),[v]),J=s(le(L,B),[L,B]),[X,Z]=i(x),[Q,q]=(({setData:e,data:t})=>{const[n,r]=i(e?void 0:t),o=s((t=>{e?e(t):r(t)}),[e]);return a((()=>{e||r(t)}),[t]),[e?t:n,o]})({setData:n,data:e}),ee=document.querySelector(":root"),ne=getComputedStyle(document.documentElement).getPropertyValue("--jer-expand-transition-time");1e3*parseFloat(ne)!==j&&(null==ee||ee.style.setProperty("--jer-expand-transition-time",j/1e3+"s")),a((()=>{const e=setTimeout((()=>Z(x)),A);return()=>clearTimeout(e)}),[x,A]);const re={key:r,path:[],level:0,index:0,value:Q,size:"object"==typeof Q&&null!==Q?Object.keys(Q).length:1,parentData:null,fullData:Q},oe=(e,t)=>p(void 0,void 0,void 0,(function*(){const n=yield e(t);if(!0===n||void 0===n)return void q(t.newData);const r=me(n)?n:["error",n],[o,a]=r;if("error"===o)return q(t.currentData),!1===a?J("ERROR_UPDATE",re):String(a);q(a)})),ie=l((()=>ge(D)),[D]),se=l((()=>ge(w)),[w]),ce=l((()=>ge(k)),[k]),de=l((()=>ge(S)),[S]),ue=l((()=>he(N)),[N]),ye={name:r,nodeData:re,onEdit:(e,t)=>p(void 0,void 0,void 0,(function*(){const{currentData:n,newData:r,currentValue:o,newValue:a}=pe(Q,t,e,"update");if(o!==a)return yield oe(c,{currentData:n,newData:r,currentValue:o,newValue:a,name:t.slice(-1)[0],path:t})})),onDelete:(e,t)=>p(void 0,void 0,void 0,(function*(){const{currentData:n,newData:r,currentValue:o,newValue:a}=pe(Q,t,e,"delete");return yield oe(d,{currentData:n,newData:r,currentValue:o,newValue:a,name:t.slice(-1)[0],path:t})})),onAdd:(e,t)=>p(void 0,void 0,void 0,(function*(){const{currentData:n,newData:r,currentValue:o,newValue:a}=pe(Q,t,e,"add");return yield oe(u,{currentData:n,newData:r,currentValue:o,newValue:a,name:t.slice(-1)[0],path:t})})),onChange:g,onError:m,showErrorMessages:y,onMove:(e,t,n)=>p(void 0,void 0,void 0,(function*(){if(null===e)return;const{currentData:r,newData:o,currentValue:a}=pe(Q,e,"","delete"),i=e.slice(-1)[0],l=t.slice(0,-1),s=t.slice(-1)[0];let d="number"==typeof s?"above"===n?s:s+1:"number"==typeof i?`arr_${i}`:i;e.slice(0,-1).join(".")===t.slice(0,-1).join(".")&&"number"==typeof i&&"number"==typeof d&&i<d&&(d-=1);const u="number"==typeof d?{insert:!0}:"above"===n?{insertBefore:s}:{insertAfter:s},{newData:p,newValue:g}=pe(o,[...l,d],a,"add",u);return yield oe(c,{currentData:r,newData:p,currentValue:a,newValue:g,name:t.slice(-1)[0],path:t})})),showCollectionCount:E,collapseFilter:$,collapseAnimationTime:j,restrictEditFilter:ie,restrictDeleteFilter:se,restrictAddFilter:ce,restrictTypeSelection:O,restrictDragFilter:de,canDragOnto:!1,searchFilter:ue,searchText:X,enableClipboard:b,keySort:T,showArrayIndices:P,showStringQuotes:V,indent:f,defaultValue:R,stringTruncate:I,translate:J,customNodeDefinitions:W,customButtons:G,parentData:null,jsonParse:H,jsonStringify:U},be=Object.assign(Object.assign({},Y("container",re)),{minWidth:z,maxWidth:F});return be.fontSize=null!=_?_:be.fontSize,t("div",{id:K,className:"jer-editor-container "+M,style:be,children:h(Q)?t(ae,Object.assign({data:Q},ye)):t(te,Object.assign({data:Q,showLabel:!0},ye))})},ue=e=>t(k,{theme:e.theme,icons:e.icons,children:t(X,{children:t(de,Object.assign({},e))})}),pe=(e,t,n,r,o={})=>{if(0===t.length)return{currentData:e,newData:n,currentValue:e,newValue:n};const a=Object.assign({remove:"delete"===r},o),i="add"!==r?u(e,t):void 0;return{currentData:e,newData:d(e,t,n,a),currentValue:i,newValue:"delete"!==r?n:void 0}},ge=e=>"boolean"==typeof e?()=>e:"number"==typeof e?({level:t})=>t>=e:e,he=e=>{if(void 0!==e)return"value"===e?b:"key"===e?f:"all"===e?(e,t)=>b(e,t)||f(e,t):e},me=e=>Array.isArray(e)&&2===e.length&&["error","value"].includes(e[0]),ye=({value:n,setIsEditing:r,getStyles:o,customNodeProps:a,nodeData:i})=>{var l,s;const c=null!==(l=null==a?void 0:a.stringTruncate)&&void 0!==l?l:100,d=o("string",i);return t("div",{onDoubleClick:()=>r(!0),onClick:e=>{(e.getModifierState("Control")||e.getModifierState("Meta"))&&r(!0)},className:"jer-value-string jer-hyperlink",style:d,children:e("a",{href:n,target:"_blank",rel:"noreferrer",style:{color:null!==(s=d.color)&&void 0!==s?s:void 0},children:['"',v(n,c),'"']})})},be={condition:({value:e})=>"string"==typeof e&&/^https?:\/\/.+\..+$/.test(e),element:ye,showOnView:!0,showOnEdit:!1};export{F as IconAdd,K as IconCancel,B as IconChevron,L as IconCopy,I as IconDelete,_ as IconEdit,M as IconOk,ue as JsonEditor,ye as LinkCustomComponent,be as LinkCustomNodeDefinition,h as isCollection,b as matchNode,f as matchNodeKey,E as themes,v as truncate};
import{jsxs as e,jsx as t,Fragment as n}from"react/jsx-runtime";import{createContext as r,useContext as o,useEffect as a,useState as i,useMemo as l,useCallback as s,useRef as c}from"react";import d from"object-property-assigner";export{default as assign}from"object-property-assigner";import u from"object-property-extractor";export{default as extract}from"object-property-extractor";function p(e,t,n,r){return new(n||(n=Promise))((function(o,a){function i(e){try{s(r.next(e))}catch(e){a(e)}}function l(e){try{s(r.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,l)}s((r=r.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const g=({className:n,name:r,value:o,setValue:a,handleKeyPress:i,styles:l})=>{if("string"!=typeof o)return null;const s="\n"===o.slice(-1)?o+".":o;return e("div",{style:{display:"grid"},children:[t("textarea",{id:`${r}_textarea`,style:Object.assign({height:"auto",gridArea:"1 / 1 / 2 / 2",overflowY:"auto",whiteSpace:"pre-wrap"},l),rows:1,className:n,name:`${r}_textarea`,value:o,onChange:e=>a(e.target.value),autoFocus:!0,onFocus:e=>{o.length<40&&e.target.select()},onKeyDown:i}),t("span",{className:n,style:Object.assign({visibility:"hidden",height:"auto",gridArea:"1 / 1 / 2 / 2",color:"red",opacity:.9,whiteSpace:"pre-wrap",overflowY:"auto",border:"1px solid transparent"},l),children:s})]})},m=e=>null!==e&&"object"==typeof e,h=(e,t,n,r="")=>{if(!n&&!r)return!0;switch(e){case"collection":if(n){if(n(t,r))return!0;if(!y(r,t,n))return!1}if(!n&&r&&!y(r,t))return!1;break;case"value":if(n&&!n(t,r))return!1;if(!n&&r&&!b(t,r))return!1}return!0},y=(e="",t,n=b)=>{const r=t.value;return Object.entries(r).some((([o,a])=>{const i=[...t.path,o],l=Object.assign(Object.assign({},t),{key:o,path:i,level:t.level+1,value:a,size:i.length,parentData:r});return m(a)?y(e,l,n):n(l,e)}))},b=(e,t="")=>{const{value:n}=e;if(null===n&&"null".includes(t.toLowerCase()))return!0;switch(typeof n){case"string":return n.toLowerCase().includes(t.toLowerCase());case"number":return!!String(n).includes(t);case"boolean":return n?"true".includes(t.toLowerCase())||"1"===t:"false".includes(t.toLowerCase())||"0"===t;default:return!1}},f=({key:e,path:t},n="")=>!!b({value:e},n)||!!t.some((e=>b({value:e},n))),v=(e,t=200)=>"string"==typeof e?e.length<t?e:`${e.slice(0,t-2).trim()}...`:e,j=e=>e.map((e=>""===e?String.fromCharCode(0):e)).join("."),E={default:{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)"}},githubDark:{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)"}},githubLight:{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"}},monoDark:{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"}},monoLight:{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"}},candyWrapper:{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"}},psychedelic:{displayName:"Psychedelic",fragments:{minty:{backgroundColor:"#F1FAEE"},pale:{color:"#A8DADC"},mid:{color:"#457B9D"},dark:{color:"#1D3557"},pop:{color:"#E63946"},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"}}},D=E.default,w=r({getStyles:()=>({}),icons:{}}),k=({theme:e="default",icons:n={},children:r})=>{const o=O(e);return t(w.Provider,{value:{getStyles:(e,t)=>"function"==typeof o[e]?o[e](t):o[e],icons:n},children:r})},C=()=>o(w),O=e=>{var t,n,r,o;const a={},i=(Array.isArray(e)?e:[e]).map((t=>"default"===e?{}:"string"==typeof t?S(E[t],a):N(t)?S({fragments:{},styles:t},a):S(t,a))),l=S(D,{});Object.keys(l).forEach((e=>{const t=e;i.forEach((e=>{e[t]&&(l[t]=Object.assign(Object.assign({},l[t]),e[t]))}))}));const s=Object.assign({},l);return Object.entries(a).forEach((([e,t])=>{const n=e;s[n]=e=>{const r=t(e)||{};return Object.assign(Object.assign({},l[n]),r)}})),"function"!=typeof(null==s?void 0:s.inputHighlight)&&(null===(t=null==s?void 0:s.inputHighlight)||void 0===t?void 0:t.backgroundColor)&&document.documentElement.style.setProperty("--jer-highlight-color",null===(n=null==s?void 0:s.inputHighlight)||void 0===n?void 0:n.backgroundColor),"function"!=typeof(null==s?void 0:s.iconCopy)&&(null===(r=null==s?void 0:s.iconCopy)||void 0===r?void 0:r.color)&&document.documentElement.style.setProperty("--jer-icon-copy-color",null===(o=null==s?void 0:s.iconCopy)||void 0===o?void 0:o.color),s},S=(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;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),{[x[e]]:t}):Object.assign(Object.assign({},r),t)}return Object.assign(Object.assign({},r),o)}),{});o[e]=a})),o},N=e=>!("styles"in e),x={container:"backgroundColor",collection:"backgroundColor",collectionInner:"backgroundColor",collectionElement:"backgroundColor",dropZone:"borderColor",property:"color",bracket:"color",itemCount:"color",string:"color",number:"color",boolean:"color",null:"color",input:"color",inputHighlight:"backgroundColor",error:"color",iconCollection:"color",iconEdit:"color",iconDelete:"color",iconAdd:"color",iconCopy:"color",iconOk:"color",iconCancel:"color"},A="**INVALID_FUNCTION**",T=({value:n,setValue:r,isEditing:o,path:a,setIsEditing:i,handleEdit:l,handleCancel:s,stringTruncate:c,showStringQuotes:d,nodeData:u})=>{const{getStyles:p}=C(),m=j(a),h=d?'"':"";return o?t(g,{className:"jer-input-text",name:m,value:n,setValue:r,isEditing:o,handleKeyPress:e=>{"Enter"!==e.key||e.shiftKey?"Escape"===e.key&&s():l()},styles:p("input",u)}):e("div",{id:`${m}_display`,onDoubleClick:()=>i(!0),onClick:e=>{(e.getModifierState("Control")||e.getModifierState("Meta"))&&i(!0)},className:"jer-value-string",style:p("string",u),children:[h,v(n,c),h]})},P=({value:e,setValue:n,isEditing:r,path:o,setIsEditing:a,handleEdit:i,handleCancel:l,nodeData:s})=>{const{getStyles:c}=C();return r?t("input",{className:"jer-input-number",type:"text",name:j(o),value:e,onChange:e=>n(e.target.value.replace(/[^0-9.-]/g,"")),autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:t=>{switch(t.key){case"Enter":i();break;case"Escape":l();break;case"ArrowUp":t.preventDefault(),n(Number(e)+1);break;case"ArrowDown":t.preventDefault(),n(Number(e)-1)}},style:Object.assign({width:String(e).length/1.5+2+"em"},c("input",s))}):t("span",{onDoubleClick:()=>a(!0),className:"jer-value-number",style:c("number",s),children:e})},V=({value:e,setValue:n,isEditing:r,path:o,setIsEditing:a,handleEdit:i,handleCancel:l,nodeData:s})=>{const{getStyles:c}=C();return r?t("input",{className:"jer-input-boolean",type:"checkbox",name:j(o),checked:e,onChange:()=>n(!e),onKeyDown:e=>{"Enter"===e.key?i():"Escape"===e.key&&l()},autoFocus:!0}):t("span",{onDoubleClick:()=>a(!0),className:"jer-value-boolean",style:c("boolean",s),children:String(e)})},R=({value:e,isEditing:n,setIsEditing:r,handleEdit:o,handleCancel:i,nodeData:l})=>{const{getStyles:s}=C();a((()=>(n&&document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c))),[n]);const c=e=>{"Enter"===e.key?o():"Escape"===e.key&&i()};return t("div",{onDoubleClick:()=>r(!0),className:"jer-value-null",style:s("null",l),children:String(e)})},z=({value:e})=>{let n="Error!";switch(typeof e){case"string":e===A&&(n="Function");break;case"undefined":n="Undefined";break;case"symbol":n="Symbol"}return t("span",{className:"jer-value-invalid",children:n})},F=({size:n,style:r,className:o})=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:n,height:n,className:o,style:r,children:[t("path",{d:"M13 7h-2v4H7v2h4v4h2v-4h4v-2h-4z"}),t("path",{d:"M12 2C6.486 2 2 6.486 2 12s4.486 10 10 10 10-4.486 10-10S17.514 2 12 2zm0 18c-4.411 0-8-3.589-8-8s3.589-8 8-8 8 3.589 8 8-3.589 8-8 8z"})]}),_=({size:n,style:r,className:o})=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:n,height:n,className:o,style:r,transform:"translate(0, 0.5)",children:[t("path",{d:"M7 17.013l4.413-.015 9.632-9.54c.378-.378.586-.88.586-1.414s-.208-1.036-.586-1.414l-1.586-1.586c-.756-.756-2.075-.752-2.825-.003L7 12.583v4.43zM18.045 4.458l1.589 1.583-1.597 1.582-1.586-1.585 1.594-1.58zM9 13.417l6.03-5.973 1.586 1.586-6.029 5.971L9 15.006v-1.589z"}),t("path",{d:"M5 21h14c1.103 0 2-.897 2-2v-8.668l-2 2V19H8.158c-.026 0-.053.01-.079.01-.033 0-.066-.009-.1-.01H5V5h6.847l2-2H5c-1.103 0-2 .897-2 2v14c0 1.103.897 2 2 2z"})]}),I=({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"})}),M=({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"})]}),L=({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"})]}),K=({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"})}),B=({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"})}),W=({name:e,nodeData:r,rotate:o})=>{var a,i,l,s,c,d,u;const{getStyles:p,icons:g}=C(),m={size:"1.4em",className:"jer-icon"};switch(e){case"add":return null!==(a=null==g?void 0:g.add)&&void 0!==a?a:t(F,Object.assign({},m,{style:p("iconAdd",r)}));case"edit":return null!==(i=null==g?void 0:g.edit)&&void 0!==i?i:t(_,Object.assign({},m,{style:p("iconEdit",r)}));case"delete":return null!==(l=null==g?void 0:g.delete)&&void 0!==l?l:t(I,Object.assign({},m,{style:p("iconDelete",r),size:"1.45em"}));case"copy":return null!==(s=null==g?void 0:g.copy)&&void 0!==s?s:t(M,Object.assign({},m,{style:p("iconCopy",r),size:"1.2em"}));case"ok":return null!==(c=null==g?void 0:g.ok)&&void 0!==c?c:t(L,Object.assign({},m,{style:Object.assign({fontSize:"90%"},p("iconOk",r))}));case"cancel":return null!==(d=null==g?void 0:g.cancel)&&void 0!==d?d:t(K,Object.assign({},m,{style:Object.assign({fontSize:"130%"},p("iconCancel",r))}));case"chevron":return null!==(u=null==g?void 0:g.chevron)&&void 0!==u?u:t(B,{size:"1em",style:p("iconCollection",r)});default:return t(n,{})}},G=({startEdit:r,handleDelete:o,handleAdd:a,enableClipboard:l,type:s,customButtons:c,nodeData:d,translate:u})=>{const{getStyles:p}=C(),g=u("KEY_NEW",d),[m,h]=i(!1),[y,b]=i(g),{key:f,path:v,value:j}=d;return e("div",{className:"jer-edit-buttons",style:{opacity:m?1:void 0},children:[l&&t("div",{onClick:e=>{e.stopPropagation();let t,n="value",r="";if(l){if(!0===(e.ctrlKey||e.metaKey))t=U(v),r=t,n="path";else t=j,r=s?JSON.stringify(j,null,2):String(t);navigator.clipboard.writeText(r)}"function"==typeof l&&l({value:t,stringValue:r,path:v,key:f,type:n})},className:"jer-copy-pulse",children:t(W,{name:"copy",nodeData:d})}),r&&t("div",{onClick:e=>{e.stopPropagation(),r()},children:t(W,{name:"edit",nodeData:d})}),o&&t("div",{onClick:e=>{e.stopPropagation(),o()},children:t(W,{name:"delete",nodeData:d})}),a&&t("div",{onClick:e=>{e.stopPropagation(),"object"===s?h(!0):a("")},children:t(W,{name:"add",nodeData:d})}),null==c?void 0:c.map((({Element:e,onClick:n},r)=>t("div",{onClick:e=>n(d,e),children:t(e,{})},r))),m&&a&&"object"===s&&e(n,{children:[t("input",{className:"jer-input-new-key",type:"text",name:"new-object-key",value:y,onChange:e=>b(e.target.value),autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>{"Enter"===e.key&&a?(h(!1),a(y),b(g)):"Escape"===e.key&&(h(!1),b(g))},style:p("input",d)}),t(H,{onOk:e=>{y&&(e.stopPropagation(),h(!1),a(y))},onCancel:e=>{e.stopPropagation(),h(!1)},nodeData:d})]})]})},H=({onOk:n,onCancel:r,nodeData:o})=>e("div",{className:"jer-confirm-buttons",children:[t("div",{onClick:n,children:t(W,{name:"ok",nodeData:o})}),t("div",{onClick:r,children:t(W,{name:"cancel",nodeData:o})})]}),U=e=>e.reduce(((e,t)=>"number"==typeof t?`${e}[${t}]`:""===e?t:`${e}.${t}`),""),Y=["string","number","boolean","null","object","array"],$=(e=[],t)=>{const n=e.filter((({condition:e})=>e(t)));if(0===n.length)return{};const r=n[0],{element:o,wrapperElement:a,customNodeProps:i,wrapperProps:l,hideKey:s=!1,showEditTools:c=!0,showOnEdit:d=!1,showOnView:u=!0,showCollectionWrapper:p=!0}=r,g=function(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}(r,["element","wrapperElement","customNodeProps","wrapperProps","hideKey","showEditTools","showOnEdit","showOnView","showCollectionWrapper"]);return Object.assign({CustomNode:o,CustomWrapper:a,customNodeProps:i,wrapperProps:l,hideKey:s,showEditTools:c,showOnEdit:d,showOnView:u,showCollectionWrapper:p},g)},J=r({collapseState:null,setCollapseState:()=>{},doesPathMatch:()=>!1,currentlyEditingElement:null,setCurrentlyEditingElement:()=>{},areChildrenBeingEdited:()=>!1,dragSource:{path:null,pathString:null},setDragSource:()=>{}}),X=({children:e})=>{const[n,r]=i(null),[o,a]=i(null),[l,s]=i({path:null,pathString:null});return t(J.Provider,{value:{collapseState:n,setCollapseState:e=>{r(e),null!==e&&setTimeout((()=>r(null)),2e3)},doesPathMatch:e=>{if(null===n)return!1;for(const[t,r]of n.path.entries())if(r!==e[t])return!1;return!0},currentlyEditingElement:o,setCurrentlyEditingElement:a,areChildrenBeingEdited:e=>null!==o&&o.includes(e),dragSource:l,setDragSource:s},children:e})},Z=()=>o(J),Q=({props:e,collapsed:t})=>{const{data:n,nodeData:r,parentData:o,onEdit:a,onError:s,showErrorMessages:c,restrictEditFilter:d,restrictDeleteFilter:u,restrictAddFilter:p,restrictDragFilter:g,translate:m,errorMessageTimeout:h}=e,{currentlyEditingElement:y,setCurrentlyEditingElement:b}=Z(),[f,v]=i(null),E=Object.assign(Object.assign({},r),{collapsed:t}),{path:D,key:w,size:k}=E,C=j(D),O=l((()=>!d(E)),[E]),S=l((()=>!u(E)),[E]),N=l((()=>!p(E)),[E]),x=l((()=>!g(E)&&S&&null===y),[E]),A=e=>{c&&(v(e),setTimeout((()=>v(null)),h)),console.warn("Error",e)},T=l((()=>(e,t)=>{A(e.message),s&&s({currentData:E.fullData,errorValue:t,currentValue:n,name:w,path:D,error:e})}),[s,c]),P=y===C,V=y===`key_${C}`,R="number"==typeof D.slice(-1)[0];return{pathString:C,nodeData:E,path:D,name:w,size:k,canEdit:O,canDelete:S,canAdd:N,canDrag:x,error:f,showError:A,onError:T,setError:v,handleEditKey:e=>{if(b(null),w===e)return;if(!o)return;const t=D.slice(0,-1);if(Object.keys(o).includes(e))return void T({code:"KEY_EXISTS",message:m("ERROR_KEY_EXISTS",E)},e);const n=Object.fromEntries(Object.entries(o).map((([t,n])=>t===w?[e,n]:[t,n])));a(n,t).then((t=>{t&&T({code:"UPDATE_ERROR",message:t},e)}))},derivedValues:{isEditing:P,isEditingKey:V,isArray:R,canEditKey:null!==o&&O&&N&&S&&!R}}},q=({canDrag:e,canDragOnto:n,path:r,nodeData:o,onMove:a,onError:s,translate:c})=>{const{getStyles:d}=C(),{dragSource:u,setDragSource:p}=Z(),[g,m]=i(!1),h=j(r),y=l((()=>e?{onDragStart:e=>{e.stopPropagation(),p({path:r,pathString:h})},onDragEnd:e=>{e.stopPropagation(),p({path:null,pathString:null})}}:{}),[e]),b=l((()=>e=>n?{onDragOver:e=>{e.stopPropagation(),e.preventDefault()},onDrop:t=>{t.stopPropagation(),v(e),p({path:null,pathString:null}),m(!1)},onDragEnter:t=>{var n;t.stopPropagation(),h.startsWith(null!==(n=u.pathString)&&void 0!==n?n:"")||m(e)},onDragExit:e=>{e.stopPropagation(),m(!1)}}:{}),[u,n]),f=l((()=>n&&null!==u.pathString?t("div",Object.assign({className:"jer-drop-target-bottom",style:{height:"50%",position:"absolute",width:"100%",top:"50%",zIndex:r.length}},b("below"))):null),[u,n]),v=e=>{var t,n;const i=null===(t=u.path)||void 0===t?void 0:t.slice(-1)[0],l=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&&l!==d?s({code:"KEY_EXISTS",message:c("ERROR_KEY_EXISTS",o)},i):a(u.path,r,e).then((e=>{e&&s({code:"UPDATE_ERROR",message:e},o.value)}))};return{dragSourceProps:y,getDropTargetProps:b,BottomDropTarget:f,DropTargetPadding:({position:e,nodeData:n})=>g===e?t("div",{className:"jer-drag-n-drop-padding",style:d("dropZone",n)}):null,handleDrop:v}},ee=(e,t)=>{var n,r;const o=document.getElementsByClassName("jer-editor-container"),a=parseInt(o.length>0?getComputedStyle(o[0]).getPropertyValue("line-height"):"16px"),i=(null!==(r=null===(n=t.current)||void 0===n?void 0:n.offsetWidth)&&void 0!==r?r:0)/(.5*a),l=JSON.stringify(e,null,2).replace(/\\n/g,"\n").split("\n").map((e=>Math.ceil(e.length/i))).reduce(((e,t)=>e+t),0)*a;return Math.min(l+30,window.innerHeight-50)},te=n=>{const{data:r,parentData:o,onEdit:c,onDelete:d,onChange:u,onMove:p,enableClipboard:g,canDragOnto:m,restrictTypeSelection:y,searchFilter:b,searchText:f,showLabel:v,stringTruncate:j,showStringQuotes:E,indent:D,translate:w,customNodeDefinitions:k}=n,{getStyles:O}=C(),{setCurrentlyEditingElement:S,setCollapseState:N}=Z(),[x,T]=i("function"==typeof r?A:r),{pathString:P,nodeData:V,path:R,name:z,canEdit:F,canDelete:_,canDrag:I,error:M,onError:L,handleEditKey:K,derivedValues:B}=Q({props:n}),{dragSourceProps:W,getDropTargetProps:U,BottomDropTarget:J,DropTargetPadding:X}=q({canDrag:I,canDragOnto:m,path:R,nodeData:V,onMove:p,onError:L,translate:w}),ee=$(k,V),[te,ae]=i(ne(r,ee)),ie=s((e=>{if(!u)return void T(e);const t=u({currentData:V.fullData,newValue:e,currentValue:x,name:z,path:R});T(t)}),[u]);a((()=>{T("function"==typeof r?A:r),ae(ne(r,ee))}),[r,M]);const{CustomNode:le,customNodeProps:se,hideKey:ce,showEditTools:de=!0,showOnEdit:ue,showOnView:pe}=ee,ge=[...Y,...k.filter((({showInTypesSelector:e=!1,name:t})=>e&&!!t)).map((({name:e})=>e))],me=l((()=>{if("boolean"==typeof y)return y?[]:ge;if(Array.isArray(y))return y;const e=y(V);return"boolean"==typeof e?e?[]:ge:e}),[V,y]);if(!h("value",V,b,f))return null;const he=()=>{let e;switch(S(null),te){case"object":e={[w("DEFAULT_NEW_KEY",V)]:x};break;case"array":e=null!=x?x:[];break;case"number":{const t=Number(x);e=isNaN(t)?0:t;break}default:e=x}c(e,R).then((t=>{t&&L({code:"UPDATE_ERROR",message:t},e)}))},ye=()=>{S(null),T(r),ae(ne(r,ee))},{isEditing:be,isEditingKey:fe,canEditKey:ve}=B,je=!be&&M,Ee=be&&me.length>0,De="invalid"!==te&&!M&&de,we=v&&fe,ke=v&&!fe&&!ce,Ce={value:x,parentData:o,setValue:ie,isEditing:be,setIsEditing:F?()=>S(P):()=>{},handleEdit:he,handleCancel:ye,path:R,stringTruncate:j,showStringQuotes:E,nodeData:V,translate:w},Oe=le&&(be&&ue||!be&&pe)?t(le,Object.assign({},n,{value:x,customNodeProps:se,setValue:ie,handleEdit:he,handleCancel:ye,handleKeyPress:e=>{"Enter"===e.key?he():"Escape"===e.key&&ye()},isEditing:be,setIsEditing:()=>S(P),getStyles:O})):re(ne(r),Ce);return e("div",Object.assign({className:"jer-component jer-value-component",style:{marginLeft:D/2+"em",position:"relative"},draggable:I},W,U("above"),{children:[J,t(X,{position:"above",nodeData:V}),e("div",{className:"jer-value-main-row",style:{flexWrap:z.length>10?"wrap":"nowrap"},children:[ke&&t("span",{className:"jer-key-text",style:Object.assign(Object.assign({},O("property",V)),{minWidth:`${Math.min(String(z).length+1,5)}ch`,flexShrink:z.length>10?1:0}),onDoubleClick:()=>ve&&S(`key_${P}`),children:""===z?t("span",{className:R.length>0?"jer-empty-string":void 0}):`${z}:`}),we&&t("input",{className:"jer-input-text jer-key-edit",type:"text",name:P,defaultValue:z,autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>{"Enter"===e.key?K(e.target.value):"Escape"===e.key&&ye()},style:{width:String(z).length/1.5+.5+"em"}}),e("div",{className:"jer-value-and-buttons",children:[t("div",{className:"jer-input-component",children:Oe}),be?t(H,{onOk:he,onCancel:ye,nodeData:V}):De&&t(G,{startEdit:F?()=>S(P):void 0,handleDelete:_?()=>{d(x,R).then((e=>{e&&L({code:"DELETE_ERROR",message:e},x)}))}:void 0,enableClipboard:g,translate:w,customButtons:n.customButtons,nodeData:V}),Ee&&e("div",{className:"jer-select",children:[t("select",{name:`${z}-type-select`,className:"jer-type-select",onChange:e=>(e=>{const t=k.find((t=>t.name===e));if(t)c(t.defaultValue,R),ae(e),S(null),N({path:R,collapsed:!1});else{const t=oe(x,e,w("DEFAULT_NEW_KEY",V),(null==ee?void 0:ee.CustomNode)?w("DEFAULT_STRING",V):void 0);ie(t),c(t,R).then((e=>{e&&(L({code:"UPDATE_ERROR",message:e},t),S(null))}))}})(e.target.value),value:te,children:me.map((e=>t("option",{value:e,children:e},e)))}),t("span",{className:"focus"})]}),je&&t("span",{className:"jer-error-slug",style:O("error",V),children:M})]})]}),t(X,{position:"below",nodeData:V})]}))},ne=(e,t)=>(null==t?void 0:t.CustomNode)&&(null==t?void 0:t.name)&&t.showInTypesSelector?t.name:"string"==typeof e?"string":"number"==typeof e?"number":"boolean"==typeof e?"boolean":null===e?"null":"invalid",re=(e,n)=>{const r=n.value;switch(e){case"string":return t(T,Object.assign({},n,{value:r}));case"number":return t(P,Object.assign({},n,{value:r}));case"boolean":return t(V,Object.assign({},n,{value:r}));case"null":return t(R,Object.assign({},n));default:return t(z,Object.assign({},n))}},oe=(e,t,n,r)=>{switch(t){case"string":return null!=r?r:String(e);case"number":{const t=Number(e);return isNaN(t)?0:t}case"boolean":return!!e;case"null":return null;case"object":return{[n]:e};case"array":return[e];default:return String(e)}},ae=r=>{const{getStyles:o}=C(),{collapseState:s,setCollapseState:d,doesPathMatch:y,currentlyEditingElement:b,setCurrentlyEditingElement:f,areChildrenBeingEdited:v}=Z(),{data:j,nodeData:E,parentData:D,showCollectionCount:w,onEdit:k,onAdd:O,onDelete:S,canDragOnto:N,collapseFilter:x,collapseAnimationTime:A,onMove:T,enableClipboard:P,searchFilter:V,searchText:R,indent:z,keySort:F,showArrayIndices:_,defaultValue:I,translate:M,customNodeDefinitions:L,jsonParse:K,jsonStringify:B}=r,[U,Y]=i(B(j)),J=x(E),{contentRef:X,isAnimating:ne,maxHeight:re,collapsed:oe,animateCollapse:ie}=((e,t,n)=>{const[r,o]=i(n?0:void 0),[a,l]=i(n),s=c(!1),d=c(null),u=c(0),p=c();return{contentRef:d,isAnimating:s.current,animateCollapse:n=>{var r,i;if(a!==n){switch(window.clearTimeout(p.current),s.current=!0,n){case!0:{const e=null!==(i=null===(r=d.current)||void 0===r?void 0:r.offsetHeight)&&void 0!==i?i:0;u.current=e,o(e),setTimeout((()=>{o(0)}),5);break}case!1:o(u.current||ee(e,d))}l(!a),p.current=window.setTimeout((()=>{s.current=!1,n||o(void 0)}),t)}},maxHeight:r,collapsed:a}})(j,A,J),{pathString:le,nodeData:se,path:ce,name:de,size:ue,canEdit:pe,canDelete:ge,canAdd:me,canDrag:he,error:ye,setError:be,onError:fe,handleEditKey:ve,derivedValues:je}=Q({props:r,collapsed:oe}),{dragSourceProps:Ee,getDropTargetProps:De,BottomDropTarget:we,DropTargetPadding:ke}=q({canDrag:he,canDragOnto:N,path:ce,nodeData:se,onMove:T,onError:fe,translate:M}),Ce=c(!J);a((()=>{Y(B(j))}),[j]),a((()=>{const e=x(se)&&!je.isEditing;Ce.current=!e,ie(e)}),[x]),a((()=>{null!==s&&y(ce)&&(Ce.current=!0,ie(s.collapsed))}),[s]);const Oe=l((()=>e=>"function"!=typeof I?I:I(e)),[I]),{CustomNode:Se,customNodeProps:Ne,CustomWrapper:xe,wrapperProps:Ae={},hideKey:Te,showEditTools:Pe=!0,showOnEdit:Ve,showOnView:Re,showCollectionWrapper:ze=!0}=l((()=>$(L,se)),[]);if(!h("collection",se,V,R)&&se.level>0)return null;const Fe=Array.isArray(j)?"array":"object",_e="array"===Fe?{open:"[",close:"]"}:{open:"{",close:"}"},Ie=e=>{"Enter"===e.key&&(e.metaKey||e.shiftKey||e.ctrlKey)?Le():"Escape"===e.key&&Be()},Me=e=>{if(e.getModifierState("Alt"))return Ce.current=!0,void d({collapsed:!oe,path:ce});b&&b.includes(le)||(Ce.current=!0,d(null),ie(!oe))},Le=()=>{try{const e=K(U);if(f(null),be(null),JSON.stringify(e)===JSON.stringify(j))return;k(e,ce).then((t=>{t&&fe({code:"UPDATE_ERROR",message:t},e)}))}catch(e){fe({code:"INVALID_JSON",message:M("ERROR_INVALID_JSON",se)},U)}},Ke=ce.length>0?()=>{S(j,ce).then((e=>{e&&fe({code:"DELETE_ERROR",message:e},u(j,ce))}))}:void 0,Be=()=>{f(null),be(null),Y(B(j))},{isEditing:We,isEditingKey:Ge,isArray:He,canEditKey:Ue}=je,Ye="when-closed"===w?oe:w,$e=!We&&Pe,Je=(_||!He)&&!Te&&void 0!==de,Xe=Se&&(We&&Ve||!We&&Re),Ze=F&&"object"===Fe,Qe=Object.entries(j).map((([e,t])=>["array"===Fe?Number(e):e,t]));Ze&&Qe.sort("function"==typeof F?(e,t)=>F(e[0],t[0]):void 0);const qe=Ce.current?We?t("div",{className:"jer-collection-text-edit",children:e("div",{children:[t(g,{className:"jer-collection-text-area",name:le,value:U,setValue:Y,isEditing:We,handleKeyPress:Ie,styles:o("input",se)}),t("div",{className:"jer-collection-input-button-row",children:t(H,{onOk:Le,onCancel:Be,nodeData:se})})]})}):Qe.map((([e,n],a)=>{const i={key:e,value:n,path:[...ce,e],level:ce.length+1,index:a,size:m(n)?Object.keys(n).length:1,parentData:j,fullData:se.fullData};return t("div",{className:"jer-collection-element",style:o("collectionElement",i),children:m(n)?t(ae,Object.assign({},r,{data:n,parentData:j,nodeData:i,showCollectionCount:w,canDragOnto:pe}),e):t(te,Object.assign({},r,{data:n,parentData:j,nodeData:i,canDragOnto:pe,showLabel:"object"===Fe||_}),e)},e)})):null,et=!!ze&&oe;et||(Ce.current=!0);const tt=Object.assign(Object.assign({},r),{data:j,value:j,parentData:D,nodeData:se,setValue:e=>p(void 0,void 0,void 0,(function*(){return yield k(e,ce)})),handleEdit:Le,handleCancel:Be,handleKeyPress:Ie,isEditing:We,setIsEditing:()=>f(le),getStyles:o,canDragOnto:pe}),nt=Xe?t(Se,Object.assign({customNodeProps:Ne},tt,{children:qe})):qe,rt=Ge?t("input",{className:"jer-input-text jer-key-edit",type:"text",name:le,defaultValue:de,autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>{"Enter"===e.key?ve(e.target.value):"Escape"===e.key&&Be()},style:{width:String(de).length/1.5+.5+"em"}}):Je&&t("span",{className:"jer-key-text",style:o("property",se),onClick:e=>e.stopPropagation(),onDoubleClick:()=>Ue&&f(`key_${le}`),children:""===de?t("span",{className:ce.length>0?"jer-empty-string":void 0}):`${de}:`}),ot=$e&&t(G,{startEdit:pe?()=>{Ce.current=!0,f(le)}:void 0,handleAdd:me?e=>{ie(!1);const t=Oe(se);"array"===Fe?O(t,[...ce,j.length]).then((e=>{e&&fe({code:"ADD_ERROR",message:e},t)})):e in j?fe({code:"KEY_EXISTS",message:M("ERROR_KEY_EXISTS",se)},e):O(t,[...ce,e]).then((e=>{e&&fe({code:"ADD_ERROR",message:e},t)}))}:void 0,handleDelete:ge?Ke:void 0,enableClipboard:P,type:Fe,nodeData:se,translate:M,customButtons:r.customButtons}),at=e("div",Object.assign({className:"jer-component jer-collection-component",style:Object.assign(Object.assign({marginLeft:(0===ce.length?0:z/2)+"em"},o("collection",se)),{position:"relative"}),draggable:he},Ee,De("above"),{children:[t("div",{className:"jer-clickzone",style:{width:z/2+1+"em",zIndex:10+2*se.level},onClick:e=>Me(e)}),!We&&we,t(ke,{position:"above",nodeData:se}),ze?e("div",{className:"jer-collection-header-row",style:{position:"relative"},onClick:e=>Me(e),children:[e("div",{className:"jer-collection-name",children:[t("div",{className:"jer-collapse-icon jer-accordion-icon"+(oe?" jer-rotate-90":""),style:{zIndex:11+2*se.level},onClick:e=>Me(e),children:t(W,{name:"chevron",rotate:oe,nodeData:se})}),rt,!We&&t("span",{className:"jer-brackets jer-bracket-open",style:o("bracket",se),children:_e.open})]}),!We&&Ye&&t("div",{className:"jer-collection-item-count"+(Ye?" jer-visible":" jer-hidden"),style:o("itemCount",se),children:1===ue?M("ITEM_SINGLE",Object.assign(Object.assign({},se),{size:1}),1):M("ITEMS_MULTIPLE",se,ue)}),t("div",{className:"jer-brackets"+(et?" jer-visible":" jer-hidden"),style:o("bracket",se),children:_e.close}),ot]}):Te?t(n,{}):e("div",{className:"jer-collection-header-row",style:{position:"relative"},children:[rt,ot]}),e("div",{className:"jer-collection-inner",style:Object.assign({overflowY:et||ne?"clip":"visible",maxHeight:v(le)?void 0:re},o("collectionInner",se)),ref:X,children:[nt,t("div",{className:We?"jer-collection-error-row":"jer-collection-error-row-edit",children:ye&&t("span",{className:"jer-error-slug",style:o("error",se),children:ye})}),!We&&ze&&t("div",{className:"jer-brackets jer-bracket-outside",style:Object.assign(Object.assign({},o("bracket",se)),{marginLeft:(z<3?-1:z<6?-.5:0)+"em"}),children:_e.close})]}),t(ke,{position:"below",nodeData:se})]}));return xe?t(xe,Object.assign({customNodeProps:Ae},tt,{children:at})):at},ie={ITEM_SINGLE:"{{count}} item",ITEMS_MULTIPLE:"{{count}} items",KEY_NEW:"Enter new key",ERROR_KEY_EXISTS:"Key already exists",ERROR_INVALID_JSON:"Invalid JSON",ERROR_UPDATE:"Update unsuccessful",ERROR_DELETE:"Delete unsuccessful",ERROR_ADD:"Adding node unsuccessful",DEFAULT_STRING:"New data!",DEFAULT_NEW_KEY:"key"},le=(e,t)=>(n,r,o)=>((e,t,n,r,o)=>{if(t[r]){const e=t[r](n);if(null!==e)return e}const a=r in e?e[r]:ie[r];return void 0===o?a:null==a?void 0:a.replace("{{count}}",String(o))})(e,t,r,n,o);var se=[],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=se.indexOf(a);-1===i&&(i=se.push(a)-1,ce[i]={}),n=ce[i]&&ce[i][r]?ce[i][r]:ce[i][r]=l()}else n=l();65279===e.charCodeAt(0)&&(e=e.substring(1)),n.styleSheet?n.styleSheet.cssText+=e:n.appendChild(document.createTextNode(e))}function l(){var e=document.createElement("style");if(e.setAttribute("type","text/css"),t.attributes)for(var n=Object.keys(t.attributes),o=0;o<n.length;o++)e.setAttribute(n[o],t.attributes[n[o]]);var i="prepend"===r?"afterbegin":"beforeend";return a.insertAdjacentElement(i,e),e}}(':root{--jer-select-border:#b6b6b6;--jer-select-focus:#777;--jer-select-arrow:#777;--jer-form-border:1px solid #ededf0;--jer-form-border-focus:1px solid #e2e2e2;--jer-expand-transition-time:0.3s;--jer-highlight-color:#b3d8ff}.jer-visible{opacity:1}.jer-hidden,.jer-visible{transition:var(--jer-expand-transition-time)}.jer-hidden{opacity:0}.jer-select select{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:transparent;border:none;color:#000;cursor:inherit;font-family:inherit;font-size:.8em;line-height:inherit;margin:0;outline:none;padding:0 1em 0 0;z-index:1}select::-ms-expand{display:none}.jer-select{align-items:center;background-color:#fff;background-image:linear-gradient(0deg,#f9f9f9,#fff 33%);border:1px solid var(--jer-select-border);border-radius:.25em;cursor:pointer;display:grid;grid-template-areas:"select";line-height:1.1;max-width:15ch;min-width:12ch;padding:.25em .5em;position:relative}.jer-select select,.jer-select:after{grid-area:select}.jer-select:not(.jer-select--multiple):after{background-color:var(--jer-select-arrow);clip-path:polygon(100% 0,0 0,50% 100%);content:"";height:.5em;justify-self:end;width:.8em}select:focus+.focus{border:1px solid var(--jer-select-focus);border-radius:inherit;bottom:-1px;left:-1px;position:absolute;right:-1px;top:-1px}.jer-editor-container{border-radius:.5em;font-size:16px;line-height:1;padding:1em 1em 1em 2em;position:relative;text-align:left}.jer-editor-container textarea{border:var(--jer-form-border);border-radius:.3em;color:var(--jer-input-color);outline:none}.jer-editor-container textarea:focus{border:var(--jer-form-border-focus)}.jer-editor-container input{border:var(--jer-form-border);border-radius:.3em;font-family:inherit;outline:none}.jer-editor-container input:focus{border:var(--jer-form-border-focus)}.jer-editor-container ::selection{background-color:var(--jer-highlight-color)}.jer-collection-header-row,.jer-value-main-row{align-items:center;display:flex;gap:.3em;min-height:1.7em}.jer-collection-header-row{display:flex;flex-wrap:wrap}.jer-collapse-icon{left:-1.2em;position:absolute;top:.35em}.jer-collection-inner{position:relative;transition:var(--jer-expand-transition-time)}.jer-collection-text-edit{align-items:flex-start;display:flex;flex-direction:column;gap:.3em}.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}.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}.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:transform var(--jer-expand-transition-time)}.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-accordion-icon,.jer-rotate-90{transition:transform var(--jer-expand-transition-time)}.jer-icon:hover{opacity:.85;transform:scale(1.2);transition:.3s}.jer-empty-string:after{content:"<empty string>:";font-size:90%;font-style:italic}.jer-drag-n-drop-padding{border:1px dashed #e0e0e0;border-radius:.3em;height:.5em}.jer-clickzone{height:calc(100% - .8em);left:-1em;position:absolute;top:1.2em}',{});const de=({data:e,setData:n,rootName:r="root",onUpdate:o=(()=>{}),onEdit:c=o,onDelete:d=o,onAdd:u=o,onChange:g,onError:h,showErrorMessages:y=!0,enableClipboard:b=!0,indent:f=2,collapse:v=!1,collapseAnimationTime:j=300,showCollectionCount:E=!0,restrictEdit:D=!1,restrictDelete:w=!1,restrictAdd:k=!1,restrictTypeSelection:O=!1,restrictDrag:S=!0,searchFilter:N,searchText:x,searchDebounceTime:A=350,keySort:T=!1,showArrayIndices:P=!0,showStringQuotes:V=!0,defaultValue:R=null,minWidth:z=250,maxWidth:F="min(600px, 90vw)",rootFontSize:_,stringTruncate:I=250,translations:M={},className:L,id:K,customText:B={},customNodeDefinitions:W=[],customButtons:G=[],jsonParse:H=JSON.parse,jsonStringify:U=(e=>JSON.stringify(e,null,2)),errorMessageTimeout:Y=2500})=>{const{getStyles:$}=C(),J=s(ge(v),[v]),X=s(le(M,B),[M,B]),[Z,Q]=i(x),[q,ee]=(({setData:e,data:t})=>{const[n,r]=i(e?void 0:t),o=s((t=>{e?e(t):r(t)}),[e]);return a((()=>{e||r(t)}),[t]),[e?t:n,o]})({setData:n,data:e}),ne=document.querySelector(":root"),re=getComputedStyle(document.documentElement).getPropertyValue("--jer-expand-transition-time");1e3*parseFloat(re)!==j&&(null==ne||ne.style.setProperty("--jer-expand-transition-time",j/1e3+"s")),a((()=>{const e=setTimeout((()=>Q(x)),A);return()=>clearTimeout(e)}),[x,A]);const oe={key:r,path:[],level:0,index:0,value:q,size:"object"==typeof q&&null!==q?Object.keys(q).length:1,parentData:null,fullData:q},ie=(e,t)=>p(void 0,void 0,void 0,(function*(){const n=yield e(t);if(!0===n||void 0===n)return void ee(t.newData);const r=he(n)?n:["error",n],[o,a]=r;if("error"===o)return ee(t.currentData),!1===a?X("ERROR_UPDATE",oe):String(a);ee(a)})),se=l((()=>ge(D)),[D]),ce=l((()=>ge(w)),[w]),de=l((()=>ge(k)),[k]),ue=l((()=>ge(S)),[S]),ye=l((()=>me(N)),[N]),be={name:r,nodeData:oe,onEdit:(e,t)=>p(void 0,void 0,void 0,(function*(){const{currentData:n,newData:r,currentValue:o,newValue:a}=pe(q,t,e,"update");if(o!==a)return yield ie(c,{currentData:n,newData:r,currentValue:o,newValue:a,name:t.slice(-1)[0],path:t})})),onDelete:(e,t)=>p(void 0,void 0,void 0,(function*(){const{currentData:n,newData:r,currentValue:o,newValue:a}=pe(q,t,e,"delete");return yield ie(d,{currentData:n,newData:r,currentValue:o,newValue:a,name:t.slice(-1)[0],path:t})})),onAdd:(e,t)=>p(void 0,void 0,void 0,(function*(){const{currentData:n,newData:r,currentValue:o,newValue:a}=pe(q,t,e,"add");return yield ie(u,{currentData:n,newData:r,currentValue:o,newValue:a,name:t.slice(-1)[0],path:t})})),onChange:g,onError:h,showErrorMessages:y,onMove:(e,t,n)=>p(void 0,void 0,void 0,(function*(){if(null===e)return;const{currentData:r,newData:o,currentValue:a}=pe(q,e,"","delete"),i=e.slice(-1)[0],l=t.slice(0,-1),s=t.slice(-1)[0];let d="number"==typeof s?"above"===n?s:s+1:"number"==typeof i?`arr_${i}`:i;e.slice(0,-1).join(".")===t.slice(0,-1).join(".")&&"number"==typeof i&&"number"==typeof d&&i<d&&(d-=1);const u="number"==typeof d?{insert:!0}:"above"===n?{insertBefore:s}:{insertAfter:s},{newData:p,newValue:g}=pe(o,[...l,d],a,"add",u);return yield ie(c,{currentData:r,newData:p,currentValue:a,newValue:g,name:t.slice(-1)[0],path:t})})),showCollectionCount:E,collapseFilter:J,collapseAnimationTime:j,restrictEditFilter:se,restrictDeleteFilter:ce,restrictAddFilter:de,restrictTypeSelection:O,restrictDragFilter:ue,canDragOnto:!1,searchFilter:ye,searchText:Z,enableClipboard:b,keySort:T,showArrayIndices:P,showStringQuotes:V,indent:f,defaultValue:R,stringTruncate:I,translate:X,customNodeDefinitions:W,customButtons:G,parentData:null,jsonParse:H,jsonStringify:U,errorMessageTimeout:Y},fe=Object.assign(Object.assign({},$("container",oe)),{minWidth:z,maxWidth:F});return fe.fontSize=null!=_?_:fe.fontSize,t("div",{id:K,className:"jer-editor-container "+L,style:fe,children:m(q)?t(ae,Object.assign({data:q},be)):t(te,Object.assign({data:q,showLabel:!0},be))})},ue=e=>t(k,{theme:e.theme,icons:e.icons,children:t(X,{children:t(de,Object.assign({},e))})}),pe=(e,t,n,r,o={})=>{if(0===t.length)return{currentData:e,newData:n,currentValue:e,newValue:n};const a=Object.assign({remove:"delete"===r},o),i="add"!==r?u(e,t):void 0;return{currentData:e,newData:d(e,t,n,a),currentValue:i,newValue:"delete"!==r?n:void 0}},ge=e=>"boolean"==typeof e?()=>e:"number"==typeof e?({level:t})=>t>=e:e,me=e=>{if(void 0!==e)return"value"===e?b:"key"===e?f:"all"===e?(e,t)=>b(e,t)||f(e,t):e},he=e=>Array.isArray(e)&&2===e.length&&["error","value"].includes(e[0]),ye=({value:n,setIsEditing:r,getStyles:o,customNodeProps:a,nodeData:i})=>{var l,s;const c=null!==(l=null==a?void 0:a.stringTruncate)&&void 0!==l?l:100,d=o("string",i);return t("div",{onDoubleClick:()=>r(!0),onClick:e=>{(e.getModifierState("Control")||e.getModifierState("Meta"))&&r(!0)},className:"jer-value-string jer-hyperlink",style:d,children:e("a",{href:n,target:"_blank",rel:"noreferrer",style:{color:null!==(s=d.color)&&void 0!==s?s:void 0},children:['"',v(n,c),'"']})})},be={condition:({value:e})=>"string"==typeof e&&/^https?:\/\/.+\..+$/.test(e),element:ye,showOnView:!0,showOnEdit:!1};export{F as IconAdd,K as IconCancel,B as IconChevron,M as IconCopy,I as IconDelete,_ as IconEdit,L as IconOk,ue as JsonEditor,ye as LinkCustomComponent,be as LinkCustomNodeDefinition,m as isCollection,b as matchNode,f as matchNodeKey,E as themes,v as truncate};
{
"name": "json-edit-react",
"version": "1.16.1",
"version": "1.16.2",
"description": "React component for editing or viewing JSON/object data",
"main": "build/index.cjs.js",
"module": "build/index.esm.js",
"type": "module",
"sideEffects": false,

@@ -9,0 +8,0 @@ "types": "build/index.d.ts",

@@ -150,2 +150,3 @@ # json-edit-react

| `jsonStringify` | `(data: JsonData) => string` | `(data) => JSON.stringify(data, null, 2)` | Similarly, you can override the default presentation of the JSON string when starting editing JSON. You can supply different formatting parameters to the native `JSON.stringify()`, or provide a third-party option, like the aforementioned JSON5. |
| `errorMessageTimeout` | `number` | `2500` | Time (in milliseconds) to display the error message in the UI. | |

@@ -152,0 +153,0 @@ ## Managing state

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc