json-edit-react 1.30.1 → 2.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/index.cjs.js +1 -1
- package/build/index.d.ts +285 -210
- package/build/index.esm.js +1 -1
- package/build/style.css +500 -0
- package/package.json +5 -53
package/build/index.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as t,Fragment as n}from"react/jsx-runtime";import{createContext as r,useContext as o,useState as i,useRef as a,useEffect as l,useCallback as s,useMemo as c}from"react";function d(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}function u(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{s(r.next(e))}catch(e){i(e)}}function l(e){try{s(r.throw(e))}catch(e){i(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,l)}s((r=r.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const p=e=>e.split(/(\.|\[\d+\])/).filter((e=>"."!==e&&""!==e)).map((e=>{const t=/\[(\d+)\]/.exec(e);return t?Number(t[1]):e})),g=(e,t,n)=>{const r=Array.isArray(t)?t:p(t);if(0===r.length)return e;const o=r[0];if(Array.isArray(e)&&"number"!=typeof o&&e.length>0)return e.map((e=>g(e,r,n)));if("object"!=typeof e||null===e||!(o in e))return m(e,o,n);const i=e[o];return 1===r.length?i:g(i,r.slice(1),n)},m=(e,t,n)=>{if(void 0===n)throw new Error(`Unable to extract object property\nLooking for property: ${t}\nIn object: ${JSON.stringify(e)}`);return n},h=(e,t,n,r,o)=>{if(!r)throw new Error(null!=o?o:`Invalid property path: ${t}\nCouldn't access "${n}" in ${JSON.stringify(e)}`)},y=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),f=e=>Array.isArray(e),b=(e,t)=>e.filter(((e,n)=>n!==t)),v=(e,t,n,r={})=>{const{remove:o=!1,createNew:i=!0,noError:a=!1}=r,l=e,s="string"==typeof(c=t)?c:"number"==typeof c?String(c):c.reduce(((e,t)=>"number"==typeof t?`${e}[${t}]`:""===e?t:`${e}.${t}`),"");var c;const d=Object.assign(Object.assign({},r),{remove:o,createNew:i,noError:a,fullData:l,fullPath:s}),u=Array.isArray(t)?t:p(t);return f(e)&&o&&1===u.length?b(e,u[0]):j(e,u,n,d)},j=(e,t,n,r)=>{const o=y(e)?Object.assign({},e):null,i=f(e)?[...e]:null;if(0===t.length)return e;if(!o&&!i)throw new Error("Can't assign property -- invalid input object");const{createNew:a,remove:l,noError:s,fullData:c,fullPath:d}=r,u=t[0];if(i&&"string"==typeof u)return i.map((e=>j(e,t,n,r)));if(1===t.length){if(o&&"string"==typeof u){const e=E(o,u,n,r);return null!=e?e:o}return i&&"number"==typeof u?(w(i,u,n,r),i):(h(c,d,u,s),e)}const p=o||i||[];if(l&&2===t.length&&"number"==typeof t[1]){const e=p[u],n=t[1];return f(e)?p[u]=b(e,n):h(c,d,u,s,"Trying to remove an indexed item from an object that is not an array"),p}const g=t.slice(1);if(u in e){if(m=p[u],!f(m)&&!y(m)){if(!a)return h(c,d,u,s),p;p[u]={}}return p[u]=j(p[u],g,n,r),p}var m;if(a){const e="number"==typeof g[0]?[]:{};if(o)return p[u]=e,p[u]=j(p[u],g,n,r),p;if(i&&Array.isArray(p)){p.push(e);const t=p.length-1;return p[t]=j(p[t],g,n,r),p}}return h(c,d,u,s),p},E=(e,t,n,r)=>{const{remove:o,createNew:i,noError:a,insertAfter:l,insertBefore:s,fullData:c,fullPath:d}=r;if(void 0!==s||void 0!==l){const r=Object.entries(e);let o=1/0;return o="number"==typeof s?s:"number"==typeof l?l:r.findIndex((([e])=>e===(null!=s?s:l))),void 0!==l&&o++,r.splice(o,0,[t,n]),Object.fromEntries(r)}const u=t in e;o?u?delete e[t]:h(c,d,t,a):i||u?e[t]=n:h(c,d,t,a)},w=(e,t,n,r)=>{const{noError:o,fullData:i,fullPath:a,createNew:l,insert:s}=r;s&&e.splice(t,0,n),t in e?e[t]=n:l?e.push(n):h(i,a,t,o)},D=({className:n,name:r,value:o,setValue:i,handleKeyPress:a,styles:l,textAreaRef:s})=>{if("string"!=typeof o)return null;const c="\n"===o.slice(-1)?o+".":o;return e("div",{style:{display:"grid"},children:[t("textarea",{id:`${r}_textarea`,ref:s,style:Object.assign({height:"auto",gridArea:"1 / 1 / 2 / 2",overflowY:"auto",whiteSpace:"pre-wrap"},l),rows:1,className:n,name:`${r}_textarea`,value:o,onChange:e=>i(e.target.value),autoFocus:!0,onFocus:e=>{o.length<40&&e.target.select()},onKeyDown:a}),t("span",{className:n,style:Object.assign({visibility:"hidden",height:"auto",gridArea:"1 / 1 / 2 / 2",color:"red",opacity:.9,whiteSpace:"pre-wrap",overflowY:"auto",border:"1px solid transparent"},l),children:c})]})},C=e=>null!==e&&"object"==typeof e,O=(e,t,n,r="")=>{if(!n&&!r)return!0;switch(e){case"collection":if(n){if(n(t,r))return!0;if(!k(r,t,n))return!1}if(!n&&r&&!k(r,t))return!1;break;case"value":if(n&&!n(t,r))return!1;if(!n&&r&&!S(t,r))return!1}return!0},k=(e="",t,n=S)=>{const r=t.value;return Object.entries(r).some((([o,i])=>{const a=[...t.path,o],l=Object.assign(Object.assign({},t),{key:o,path:a,level:t.level+1,value:i,size:a.length,parentData:r});return C(i)?k(e,l,n):n(l,e)}))},S=(e,t="")=>{const{value:n}=e;if(null===n&&"null".includes(t.toLowerCase()))return!0;switch(typeof n){case"string":return n.toLowerCase().includes(t.toLowerCase());case"number":return!!String(n).includes(t);case"boolean":return n?"true".includes(t.toLowerCase())||"1"===t:"false".includes(t.toLowerCase())||"0"===t;default:return!1}},N=({key:e,path:t},n="")=>!!S({value:e},n)||!!t.some((e=>S({value:e},n))),T=(e,t)=>(null!=t?t:"")+e.map((e=>""===e?String.fromCharCode(0):e)).join("."),A=e=>e.shiftKey?"Shift":e.metaKey?"Meta":e.ctrlKey?"Control":e.altKey?"Alt":void 0,x=(e,t,n)=>{const r=e.key,o=A(e);if(Array.isArray(t))return!!o&&t.includes(o);const{key:i,modifier:a}=t;return("stringLineBreak"!==n||"Enter"!==r||"Shift"!==o||"Enter"!==i||!(null==a?void 0:a.includes("Shift")))&&(r===i&&(a===o||Array.isArray(a)&&a.includes(o)))},P={key:"Enter"},K={confirm:P,cancel:{key:"Escape"},objectConfirm:Object.assign(Object.assign({},P),{modifier:["Meta","Shift","Control"]}),objectLineBreak:P,stringConfirm:P,stringLineBreak:Object.assign(Object.assign({},P),{modifier:["Shift"]}),numberConfirm:P,numberUp:{key:"ArrowUp"},numberDown:{key:"ArrowDown"},tabForward:{key:"Tab"},tabBack:{key:"Tab",modifier:"Shift"},booleanConfirm:P,booleanToggle:{key:" "},clipboardModifier:["Meta","Control"],collapseModifier:["Alt"]},R=(e,t,n="next",r)=>{const o=t.slice(0,t.length-1),i=t.slice(-1)[0];if(void 0===i)return null;const a=g(e,o),l=V(a);Array.isArray(a)||r(l,(({key:e,value:t})=>[e,t]));const s=l.findIndex((e=>e.key===i)),c=l[s+("next"===n?1:-1)];return c?C(c.value)?0===Object.keys(c.value).length?R(e,[...o,c.key],n,r):I(e,[...o,c.key],n,r):[...o,c.key]:0===o.length?null:R(e,o,n,r)},I=(e,t,n="next",r)=>{const o=g(e,t);if(!C(o))return t;const i=Array.isArray(o)?o.map(((e,t)=>t)):Object.keys(o);r(i,(e=>[e,o]));const a="next"===n?i[0]:i[i.length-1];return I(e,[...t,a],n,r)},V=e=>Array.isArray(e)?e.map(((e,t)=>({index:t,value:e,key:t}))):Object.entries(e).map((([e,t],n)=>({key:e,value:t,index:n}))),_=(e,t)=>{var n,r,o,i;const a=e.current,l=null!==(n=null==a?void 0:a.selectionStart)&&void 0!==n?n:1/0,s=null!==(r=null==a?void 0:a.selectionEnd)&&void 0!==r?r:1/0,c=(null===(o=null==a?void 0:a.textContent)||void 0===o?void 0:o.slice(0,l))+t+(null===(i=null==a?void 0:a.textContent)||void 0===i?void 0:i.slice(s));return a.value=c,null==a||a.setSelectionRange(l+1,l+1),c},F=e=>{if(e!==L){if(Array.isArray(e))return e.map((e=>F(e)));if(e&&"object"==typeof e)for(const t in e)e[t]=F(e[t]);return e}},L="__undefined__",z={displayName:"Default",fragments:{edit:"rgb(42, 161, 152)"},styles:{container:{backgroundColor:"#f6f6f6",fontFamily:"monospace"},collection:{},collectionInner:{},collectionElement:{},dropZone:{},property:"#292929",bracket:{color:"rgb(0, 43, 54)",fontWeight:"bold"},itemCount:{color:"rgba(0, 0, 0, 0.3)",fontStyle:"italic"},string:"rgb(203, 75, 22)",number:"rgb(38, 139, 210)",boolean:"green",null:{color:"rgb(220, 50, 47)",fontVariant:"small-caps",fontWeight:"bold"},input:["#292929"],inputHighlight:"#b3d8ff",error:{fontSize:"0.8em",color:"red",fontWeight:"bold"},iconCollection:"rgb(0, 43, 54)",iconEdit:"edit",iconDelete:"rgb(203, 75, 22)",iconAdd:"edit",iconCopy:"rgb(38, 139, 210)",iconOk:"green",iconCancel:"rgb(203, 75, 22)"}},M=r({getStyles:()=>({}),icons:{}}),B=({theme:e=z,icons:n={},docRoot:r,children:o})=>{const i=G(e,r);return t(M.Provider,{value:{getStyles:(e,t)=>"function"==typeof i[e]?i[e](t):i[e],icons:n},children:o})},W=()=>o(M),G=(e,t)=>{var n,r,o,i;const a={},l=(Array.isArray(e)?e:[e]).map((e=>$(e)?Y({fragments:{},styles:e},a):Y(e,a))),s=Y(z,{});Object.keys(s).forEach((e=>{const t=e;l.forEach((e=>{e[t]&&(s[t]=Object.assign(Object.assign({},s[t]),e[t]))}))}));const c=Object.assign({},s);return Object.entries(a).forEach((([e,t])=>{const n=e;c[n]=e=>{const r=t(e)||{};return Object.assign(Object.assign({},s[n]),r)}})),"function"!=typeof(null==c?void 0:c.inputHighlight)&&(null===(n=null==c?void 0:c.inputHighlight)||void 0===n?void 0:n.backgroundColor)&&t.style.setProperty("--jer-highlight-color",null===(r=null==c?void 0:c.inputHighlight)||void 0===r?void 0:r.backgroundColor),"function"!=typeof(null==c?void 0:c.iconCopy)&&(null===(o=null==c?void 0:c.iconCopy)||void 0===o?void 0:o.color)&&t.style.setProperty("--jer-icon-copy-color",null===(i=null==c?void 0:c.iconCopy)||void 0===i?void 0:i.color),c},Y=(e,t)=>{const{fragments:n,styles:r}=e,o={};return Object.entries(r).forEach((([e,r])=>{const i=(Array.isArray(r)?r:[r]).reduce(((r,o)=>{var i,a;if("function"==typeof o)return t[e]=o,Object.assign({},r);if("string"==typeof o){const t=null!==(i=null==n?void 0:n[o])&&void 0!==i?i:o;return"string"==typeof t?Object.assign(Object.assign({},r),{[null!==(a=U[e])&&void 0!==a?a:"color"]:t}):Object.assign(Object.assign({},r),t)}return Object.assign(Object.assign({},r),o)}),{});o[e]=i})),o},$=e=>!("styles"in e),U={container:"backgroundColor",collection:"backgroundColor",collectionInner:"backgroundColor",collectionElement:"backgroundColor",dropZone:"borderColor",inputHighlight:"backgroundColor"},H=r(null),Z=({children:e,onEditEvent:n,onCollapse:r})=>{const[o,l]=i(null),[s,c]=i(null),[d,u]=i(null),[p,g]=i({path:null,pathString:null}),m=a(null),h=a("next"),y=a(null);return t(H.Provider,{value:{collapseState:o,setCollapseState:e=>{l(e),r&&null!==e&&(Array.isArray(e)?e.forEach((e=>r(e))):r(e)),null!==e&&setTimeout((()=>l(null)),2e3)},getMatchingCollapseState:e=>{if(Array.isArray(o)){for(const t of o)if(X(e,t))return t;return null}return X(e,o)?o:null},currentlyEditingElement:s,setCurrentlyEditingElement:(e,t)=>{const r="string"==typeof e||null===e?e:T(e,"key"===t?"key_":void 0);null!==s&&null!==r&&null!==m.current&&m.current(),c(r),n&&(Array.isArray(e)||null===e)&&n(e,"key"===t),m.current="function"==typeof t?t:null},areChildrenBeingEdited:e=>null!==s&&s.includes(e),previouslyEditedElement:y.current,setPreviouslyEditedElement:e=>{y.current=e},tabDirection:h.current,setTabDirection:e=>{h.current=e},previousValue:d,setPreviousValue:u,dragSource:p,setDragSource:g},children:e})},J=()=>{const e=o(H);if(!e)throw new Error("Missing Context Provider");return e},X=(e,t)=>{if(null===t)return!1;if(!t.includeChildren)return t.path.every(((t,n)=>e[n]===t))&&t.path.length===e.length;for(const[n,r]of t.path.entries())if(r!==e[n])return!1;return!0},Q="**INVALID_FUNCTION**",q=({nodeData:r,showStringQuotes:o=!0,stringTruncate:a=200,pathString:l,canEdit:s,setIsEditing:c,styles:d,translate:u,value:p,TextWrapper:g=({children:e})=>e})=>{const m=null!=p?p:r.value,[h,y]=i(!1),f=o?'"':"",b=m.length>a,v=()=>{s?c(!0):y(!h)};return e("div",{id:`${l}_display`,onDoubleClick:v,onClick:e=>{(e.getModifierState("Control")||e.getModifierState("Meta"))&&v()},className:"jer-value-string",style:d,children:[f,b?e(n,h?{children:[t(g,{children:e("span",{children:[m,f]})}),e("span",{className:"jer-string-expansion jer-show-less",onClick:()=>y(!1),children:[" ",u("SHOW_LESS",r)]})]}:{children:[e(g,{children:[t("span",{children:m.slice(0,a-2).trimEnd()})," "]}),t("span",{className:"jer-string-expansion jer-ellipsis",onClick:()=>y(!0),children:"..."}),f]}):t(g,{children:`${m}${f}`})]})},ee=({styles:e,pathString:n,value:r,setValue:o,handleEdit:i,handleKeyboard:l,keyboardCommon:s})=>{const c=a(null);return t(D,{className:"jer-input-text",textAreaRef:c,name:n,value:r,setValue:o,handleKeyPress:e=>{l(e,Object.assign({stringConfirm:i,stringLineBreak:()=>{const e=_(c,"\n");o(e)}},s))},styles:e})},te=n=>{var{isEditing:r,path:o,enumType:i}=n,a=d(n,["isEditing","path","enumType"]);const{getStyles:l}=W(),s=T(o),{value:c,setValue:u,nodeData:p,handleEdit:g,handleKeyboard:m,keyboardCommon:h}=a;return r&&i?e("div",{className:"jer-select jer-select-enums",children:[t("select",{name:`${s}-value-select`,className:"jer-select-inner",onChange:e=>u(e.target.value),value:c,autoFocus:!0,onKeyDown:e=>{m(e,Object.assign({stringConfirm:g},h))},children:i.values.map((e=>t("option",{value:e,children:e},e)))}),t("span",{className:"focus"})]}):r?t(ee,Object.assign({styles:l("input",p),pathString:s},a,{setValue:a.setValue})):t(q,Object.assign({pathString:s,styles:l("string",p)},a))},ne=({value:e,setValue:n,isEditing:r,path:o,setIsEditing:i,handleEdit:a,nodeData:l,handleKeyboard:s,keyboardCommon:c})=>{const{getStyles:d}=W();return r?t("input",{className:"jer-input-number",type:"text",name:T(o),value:e,onChange:e=>n(e.target.value.replace(/[^0-9.-]/g,"")),autoFocus:!0,onFocus:e=>setTimeout((()=>e.target.select()),10),onKeyDown:t=>s(t,Object.assign({numberConfirm:a,numberUp:()=>n(Number(e)+1),numberDown:()=>n(Number(e)-1)},c)),style:Object.assign({width:String(e).length/1.5+2+"em"},d("input",l))}):t("span",{onDoubleClick:()=>i(!0),className:"jer-value-number",style:d("number",l),children:e})},re=({value:e,setValue:n,isEditing:r,path:o,setIsEditing:i,handleEdit:a,nodeData:l,handleKeyboard:s,keyboardCommon:c})=>{const{getStyles:d}=W();return"boolean"!=typeof e?null:r?t("input",{className:"jer-input-boolean",type:"checkbox",name:T(o),checked:e,onChange:()=>n(!e),onKeyDown:t=>{" "===t.key&&t.preventDefault(),s(t,Object.assign({booleanConfirm:a,booleanToggle:()=>n(!e)},c))},autoFocus:!0}):t("span",{onDoubleClick:()=>i(!0),className:"jer-value-boolean",style:d("boolean",l),children:String(e)})},oe=(e,t)=>{const n=a(void 0),r=a(t);l((()=>{r.current=t}),[t]);const o=e=>{r.current(e)};l((()=>{if(window.clearTimeout(n.current),e)return n.current=window.setTimeout((()=>{window.addEventListener("keydown",o)}),100),()=>{window.clearTimeout(n.current),window.removeEventListener("keydown",o)}}),[e])},ie=({value:e,isEditing:n,setIsEditing:r,handleEdit:o,nodeData:i,handleKeyboard:a,keyboardCommon:l})=>{const{getStyles:s}=W();return oe(n,(e=>a(e,Object.assign({confirm:o},l)))),t("div",{onDoubleClick:()=>r(!0),className:"jer-value-null",style:s("null",i),children:String(e)})},ae=({value:e})=>{let n="Error!";switch(typeof e){case"string":e===Q&&(n="Function");break;case"undefined":n="Undefined";break;case"symbol":n="Symbol"}return t("span",{className:"jer-value-invalid",children:n})},le=({size:n,style:r,className:o})=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:n,height:n,className:o,style:r,children:[t("path",{d:"M13 7h-2v4H7v2h4v4h2v-4h4v-2h-4z"}),t("path",{d:"M12 2C6.486 2 2 6.486 2 12s4.486 10 10 10 10-4.486 10-10S17.514 2 12 2zm0 18c-4.411 0-8-3.589-8-8s3.589-8 8-8 8 3.589 8 8-3.589 8-8 8z"})]}),se=({size:n,style:r,className:o})=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:n,height:n,className:o,style:r,transform:"translate(0, 0.5)",children:[t("path",{d:"M7 17.013l4.413-.015 9.632-9.54c.378-.378.586-.88.586-1.414s-.208-1.036-.586-1.414l-1.586-1.586c-.756-.756-2.075-.752-2.825-.003L7 12.583v4.43zM18.045 4.458l1.589 1.583-1.597 1.582-1.586-1.585 1.594-1.58zM9 13.417l6.03-5.973 1.586 1.586-6.029 5.971L9 15.006v-1.589z"}),t("path",{d:"M5 21h14c1.103 0 2-.897 2-2v-8.668l-2 2V19H8.158c-.026 0-.053.01-.079.01-.033 0-.066-.009-.1-.01H5V5h6.847l2-2H5c-1.103 0-2 .897-2 2v14c0 1.103.897 2 2 2z"})]}),ce=({size:e,style:n,className:r})=>t("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:e,height:e,className:r,style:n,children:t("path",{d:"M6 19a2 2 0 002 2h8a2 2 0 002-2V7H6v12m2.46-7.12l1.41-1.41L12 12.59l2.12-2.12 1.41 1.41L13.41 14l2.12 2.12-1.41 1.41L12 15.41l-2.12 2.12-1.41-1.41L10.59 14l-2.13-2.12M15.5 4l-1-1h-5l-1 1H5v2h14V4h-3.5z"})}),de=({size:n,style:r,className:o})=>e("svg",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",width:n,height:n,className:o,style:r,children:[t("path",{d:"M9 2 H15 A1 1 0 0 1 16 3 V5 A1 1 0 0 1 15 6 H9 A1 1 0 0 1 8 5 V3 A1 1 0 0 1 9 2 z"}),t("path",{d:"M8 4H6a2 2 0 00-2 2v14a2 2 0 002 2h12a2 2 0 002-2v-2M16 4h2a2 2 0 012 2v4M21 14H11"}),t("path",{d:"M15 10l-4 4 4 4"})]}),ue=({size:n,style:r,className:o})=>e("svg",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",width:n,height:n,className:o,style:r,children:[t("path",{d:"M22 11.08V12a10 10 0 11-5.93-9.14"}),t("path",{d:"M22 4L12 14.01l-3-3"})]}),pe=({size:e,style:n,className:r})=>t("svg",{baseProfile:"tiny",viewBox:"0 0 24 24",fill:"currentColor",width:e,height:e,className:r,style:n,children:t("path",{d:"M12 4c-4.411 0-8 3.589-8 8s3.589 8 8 8 8-3.589 8-8-3.589-8-8-8zm-5 8c0-.832.224-1.604.584-2.295l6.711 6.711A4.943 4.943 0 0112 17c-2.757 0-5-2.243-5-5zm9.416 2.295L9.705 7.584A4.943 4.943 0 0112 7c2.757 0 5 2.243 5 5 0 .832-.224 1.604-.584 2.295z"})}),ge=({size:e,style:n,className:r})=>t("svg",{viewBox:"0 0 512 512",fill:"currentColor",width:e,height:e,className:r,style:n,children:t("path",{d:"M233.4 406.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L256 338.7 86.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z"})}),me=({name:e,nodeData:r})=>{var o,i,a,l,s,c,d;const{getStyles:u,icons:p}=W(),g={size:"1.4em",className:"jer-icon"};switch(e){case"add":return null!==(o=null==p?void 0:p.add)&&void 0!==o?o:t(le,Object.assign({},g,{style:u("iconAdd",r)}));case"edit":return null!==(i=null==p?void 0:p.edit)&&void 0!==i?i:t(se,Object.assign({},g,{style:u("iconEdit",r)}));case"delete":return null!==(a=null==p?void 0:p.delete)&&void 0!==a?a:t(ce,Object.assign({},g,{style:u("iconDelete",r),size:"1.45em"}));case"copy":return null!==(l=null==p?void 0:p.copy)&&void 0!==l?l:t(de,Object.assign({},g,{style:u("iconCopy",r),size:"1.2em"}));case"ok":return null!==(s=null==p?void 0:p.ok)&&void 0!==s?s:t(ue,Object.assign({},g,{style:Object.assign({fontSize:"90%"},u("iconOk",r))}));case"cancel":return null!==(c=null==p?void 0:p.cancel)&&void 0!==c?c:t(pe,Object.assign({},g,{style:Object.assign({fontSize:"130%"},u("iconCancel",r))}));case"chevron":return null!==(d=null==p?void 0:p.chevron)&&void 0!==d?d:t(ge,{size:"1em",style:u("iconCollection",r)});default:return t(n,{})}},he=({startEdit:r,handleDelete:o,handleAdd:a,enableClipboard:l,type:s,customButtons:c,nodeData:d,translate:u,keyboardControls:p,handleKeyboard:m,editConfirmRef:h,getNewKeyOptions:y,jsonStringify:f,onEditEvent:b,showIconTooltips:v})=>{const{getStyles:j}=W(),E=u("KEY_NEW",d),[w,D]=i(E),[C,O]=i(!1),{key:k,path:S,value:N}=d,T=Array.isArray(C),x=e=>{var t;if(b&&b(e?[...S,null]:null,e),!e)return void O(!1);const n=Object.keys(g(d.fullData,S)),r=y?null===(t=y(d))||void 0===t?void 0:t.filter((e=>!n.includes(e))):null;r&&D(""),O(null==r||r)};return e("div",{className:"jer-edit-buttons",style:{opacity:C?1:void 0},onClick:e=>e.stopPropagation(),children:[l&&t("div",{onClick:e=>{var t;e.stopPropagation();let n,r,o="value",i="",a=null;if(l){const s=A(e);if(s&&p.clipboardModifier.includes(s)?(n=fe(S),i=n,o="path"):(n=N,i="object"==typeof n?f(N):String(n)),!navigator.clipboard)return void("function"==typeof l&&l({success:!1,value:n,stringValue:i,path:S,key:k,type:o,errorMessage:"Can't access clipboard API"}));null===(t=navigator.clipboard)||void 0===t||t.writeText(i).then((()=>r=!0)).catch((e=>{r=!1,a=e.message})).finally((()=>{"function"==typeof l&&l({success:r,errorMessage:a,value:n,stringValue:i,path:S,key:k,type:o})}))}},className:"jer-copy-pulse",title:v?u("TOOLTIP_COPY",d):"",children:t(me,{name:"copy",nodeData:d})}),r&&t("div",{onClick:r,title:v?u("TOOLTIP_EDIT",d):"",children:t(me,{name:"edit",nodeData:d})}),o&&t("div",{onClick:o,title:v?u("TOOLTIP_DELETE",d):"",children:t(me,{name:"delete",nodeData:d})}),a&&t("div",{onClick:()=>{"object"===s?x(!0):a("")},title:v?u("TOOLTIP_ADD",d):"",children:t(me,{name:"add",nodeData:d})}),null==c?void 0:c.map((({Element:e,onClick:n},r)=>t("div",{onClick:e=>n&&n(d,e),children:t(e,{nodeData:d})},r))),C&&a&&"object"===s&&e(n,{children:[T?e("div",{className:"jer-select jer-select-keys",children:[e("select",{name:"new-key-select",className:"jer-select-inner",onChange:e=>{a(e.target.value),x(!1)},defaultValue:"",autoFocus:!0,onKeyDown:e=>{m(e,{cancel:()=>x(!1)})},children:[t("option",{value:"",disabled:!0,children:C.length>0?u("KEY_SELECT",d):u("NO_KEY_OPTIONS",d)}),C.map((e=>t("option",{value:e,children:e},e)))]}),t("span",{className:"focus"})]}):t("input",{className:"jer-input-new-key",type:"text",name:"new-object-key",value:w,onChange:e=>D(e.target.value),autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>{m(e,{stringConfirm:()=>{a&&(x(!1),a(w),D(E))},cancel:()=>{x(!1),D(E)}})},style:j("input",d)}),t(ye,{onOk:()=>{T&&!w||(x(!1),a(w))},onCancel:()=>{x(!1)},nodeData:d,editConfirmRef:h,hideOk:T})]})]})},ye=({onOk:n,onCancel:r,nodeData:o,editConfirmRef:i,hideOk:a=!1})=>e("div",{className:"jer-confirm-buttons",children:[!a&&t("div",{onClick:n,ref:i,children:t(me,{name:"ok",nodeData:o})}),t("div",{onClick:r,children:t(me,{name:"cancel",nodeData:o})})]}),fe=e=>e.reduce(((e,t)=>"number"==typeof t?`${e}[${t}]`:""===e?t:`${e}.${t}`),""),be=["string","number","boolean","null","object","array"],ve=({props:e,collapsed:t})=>{const{data:n,nodeData:r,parentData:o,onEdit:a,onError:l,showErrorMessages:c,restrictEditFilter:d,restrictDeleteFilter:u,restrictAddFilter:p,restrictDragFilter:g,translate:m,errorMessageTimeout:h}=e,{currentlyEditingElement:y,setCurrentlyEditingElement:f}=J(),[b,v]=i(null),j=Object.assign(Object.assign({},r),{collapsed:t}),{path:E,key:w,size:D}=j,C=T(E),O=!d(j),k=!u(j),S=!p(j),N=!g(j)&&k&&null===y,A=e=>{c&&(v(e),setTimeout((()=>v(null)),h)),console.warn("Error",e)},x=s(((e,t)=>{A(e.message),l&&l({currentData:j.fullData,errorValue:t,currentValue:n,name:w,path:E,error:e})}),[l,c]),P=y===C,K=y===`key_${C}`,R="number"==typeof E.slice(-1)[0],I={isEditing:P,isEditingKey:K,isArray:R,canEditKey:null!==o&&O&&S&&k&&!R},V=""===w&&E.length>0?m("EMPTY_STRING",j):null;return{pathString:C,nodeData:j,path:E,name:w,size:D,canEdit:O,canDelete:k,canAdd:S,canDrag:N,error:b,showError:A,onError:x,setError:v,handleEditKey:e=>{if(f(null),w===e)return;if(!o)return;const t=E.slice(0,-1);if(Object.keys(o).includes(e))return void x({code:"KEY_EXISTS",message:m("ERROR_KEY_EXISTS",j)},e);const n=Object.fromEntries(Object.entries(o).map((([t,n])=>t===w?[e,n]:[t,n])));a(n,t).then((t=>{t&&x({code:"UPDATE_ERROR",message:t},e)}))},derivedValues:I,emptyStringKey:V}},je=({canDrag:e,canDragOnto:n,path:r,nodeData:o,onMove:a,onError:l,translate:s})=>{const{getStyles:d}=W(),{dragSource:u,setDragSource:p}=J(),[g,m]=i(!1),h=T(r),y=c((()=>e?{onDragStart:e=>{e.stopPropagation(),p({path:r,pathString:h})},onDragEnd:e=>{e.stopPropagation(),p({path:null,pathString:null})}}:{}),[e,h]),f=c((()=>e=>n?{onDragOver:e=>{e.stopPropagation(),e.preventDefault()},onDrop:t=>{t.stopPropagation(),v(e),p({path:null,pathString:null}),m(!1)},onDragEnter:t=>{var n;t.stopPropagation(),h.startsWith(null!==(n=u.pathString)&&void 0!==n?n:"")||m(e)},onDragExit:e=>{e.stopPropagation(),m(!1)}}:{}),[u,n,h]),b=c((()=>n&&null!==u.pathString?t("div",Object.assign({className:"jer-drop-target-bottom",style:{height:"50%",position:"absolute",width:"100%",top:"50%",zIndex:r.length}},f("below"))):null),[u,n,r.length]),v=e=>{var t,n;const i=null===(t=u.path)||void 0===t?void 0:t.slice(-1)[0],c=null===(n=u.path)||void 0===n?void 0:n.slice(0,-1).join("."),d=r.slice(0,-1).join(""),{parentData:p}=o;"string"==typeof i&&p&&!Array.isArray(p)&&Object.keys(p).includes(i)&&i in p&&c!==d?l({code:"KEY_EXISTS",message:s("ERROR_KEY_EXISTS",o)},i):a(u.path,r,e).then((e=>{e&&l({code:"UPDATE_ERROR",message:e},o.value)}))};return{dragSourceProps:y,getDropTargetProps:f,BottomDropTarget:b,DropTargetPadding:({position:e,nodeData:n})=>g===e?t("div",{className:"jer-drag-n-drop-padding",style:d("dropZone",n)}):null,handleDrop:v}},Ee=(e,t,n,r)=>{var o,i,a;if(!t.current)return 0;const l=parseInt(null!==(o=getComputedStyle(n.current).getPropertyValue("line-height"))&&void 0!==o?o:"16px"),s=(null!==(a=null===(i=t.current)||void 0===i?void 0:i.offsetWidth)&&void 0!==a?a:0)/(.5*l),c=r(e).replace(/\\n/g,"\n").split("\n").map((e=>Math.ceil(e.length/s))).reduce(((e,t)=>e+t),0)*l;return Math.min(c+30,window.innerHeight-50)},we=({isEditingKey:n,canEditKey:r,pathString:o,path:i,name:a,arrayIndexFromOne:l,handleKeyboard:s,handleEditKey:c,handleCancel:d,handleClick:u,keyValueArray:p,styles:g,getNextOrPrevious:m,emptyStringKey:h,nodeData:y,customNodeData:f,getStyles:b})=>{const{setCurrentlyEditingElement:v}=J(),j="number"==typeof a?String(a+(l?1:0)):a;if(!n){const n=Object.assign(Object.assign({},g),{minWidth:`${Math.min(j.length+1,5)}ch`,flexShrink:j.length>10?1:0});if((null==f?void 0:f.CustomKey)&&y&&b){const{CustomKey:e,customNodeProps:o}=f;return t(e,{nodeData:y,name:null!=h?h:j,path:i,canEditKey:r,handleEditKey:e=>{r&&c(e)},setIsEditingKey:()=>{r&&v(i,"key")},handleClick:u,styles:n,customNodeProps:o,getStyles:b})}return e("span",{className:"jer-key-text",style:n,onDoubleClick:()=>r&&v(i,"key"),onClick:u,children:[h?t("span",{className:"jer-empty-string",children:h}):j,""!==j||h?t("span",{className:"jer-key-colon",children:":"}):null]})}return t("input",{className:"jer-input-text jer-key-edit",type:"text",name:o,defaultValue:j,autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>s(e,{stringConfirm:()=>c(e.target.value),cancel:d,tabForward:()=>{if(c(e.target.value),p){const e=null==p?void 0:p[0][0];v(e?[...i,e]:m("next"))}else v(i)},tabBack:()=>{c(e.target.value),v(m("prev"))}}),style:{width:j.length/1.5+.5+"em"}})},De=n=>{const{data:r,parentData:o,onEdit:a,onDelete:d,onChange:u,onMove:p,enableClipboard:g,canDragOnto:m,restrictTypeSelection:h,searchFilter:y,searchText:f,showLabel:b,stringTruncate:v,showStringQuotes:j,arrayIndexFromOne:E,indent:w,translate:D,customNodeDefinitions:C,customNodeData:k,handleKeyboard:S,keyboardControls:N,sort:T,editConfirmRef:A,jsonStringify:x,showIconTooltips:P}=n,{getStyles:K}=W(),{setCurrentlyEditingElement:I,setCollapseState:V,previouslyEditedElement:_,setPreviouslyEditedElement:F,tabDirection:L,setTabDirection:z,previousValue:M,setPreviousValue:B}=J(),[G,Y]=i("function"==typeof r?Q:r),{pathString:$,nodeData:U,path:H,name:Z,canEdit:X,canDelete:q,canDrag:ee,error:te,onError:ne,handleEditKey:re,emptyStringKey:oe,derivedValues:ie}=ve({props:n}),{dragSourceProps:ae,getDropTargetProps:le,BottomDropTarget:se,DropTargetPadding:ce}=je({canDrag:ee,canDragOnto:m,path:H,nodeData:U,onMove:p,onError:ne,translate:D}),[de,ue]=i(Ce(r,k)),pe=s((e=>{if(!u)return void Y(e);const t=u({currentData:U.fullData,newValue:e,currentValue:G,name:Z,path:H});Y(t)}),[u]);l((()=>{Y("function"==typeof r?Q:r),ue(Ce(r,k))}),[r,te]);const{CustomNode:ge,customNodeProps:me,hideKey:fe,showEditTools:Ee=!0,showOnEdit:De,showOnView:Se,passOriginalNode:Ne}=k,Te=[...be,...C.filter((({showInTypesSelector:e=!1,name:t})=>e&&!!t)).map((({name:e})=>e))],Ae=c((()=>{if("boolean"==typeof h)return h?[]:Te;if(Array.isArray(h))return h;const e=h(U);return"boolean"==typeof e?e?[]:Te:e}),[U,h]),[xe,Pe]=i(((e,t)=>{var n;if("string"!=typeof e)return null;const r=t.filter((t=>t instanceof Object&&t.enum&&t.values.includes(e)&&t.matchPriority));return r.sort(((e,t)=>{var n,r;return(null!==(n=t.matchPriority)&&void 0!==n?n:0)-(null!==(r=e.matchPriority)&&void 0!==r?r:0)})),null!==(n=r[0])&&void 0!==n?n:null})(G,Ae)),{isEditing:Ke}=ie,Re=O("value",U,y,f);if(Ke&&(!Re||!X)){const e=R(U.fullData,H,L,T);I(e||_)}if(!Re)return null;const Ie=e=>{let t;if(I(null),B(null),void 0===e||(e=>e&&"object"==typeof e&&"type"in e&&"target"in e&&"preventDefault"in e&&"function"==typeof e.preventDefault)(e))switch(de){case"object":t={[D("DEFAULT_NEW_KEY",U)]:G};break;case"array":t=null!=G?G:[];break;case"number":{const e=Number(G);t=isNaN(e)?0:e;break}default:t=G}else t=e;a(t,H).then((e=>{e&&ne({code:"UPDATE_ERROR",message:e},t)}))},Ve=()=>{I(null),null===M?(Y(r),B(null)):a(M,H)},{isEditingKey:_e,canEditKey:Fe}=ie,Le=!Ke&&te,ze=Ke&&Ae.length>1,Me=("invalid"!==de||ge)&&!te&&Ee,Be=b&&!fe,We=ge&&(Ke&&De||!Ke&&Se),Ge={value:G,parentData:o,setValue:pe,isEditing:Ke,canEdit:X,setIsEditing:X?()=>I(H):()=>{},handleEdit:Ie,handleCancel:Ve,path:H,stringTruncate:v,showStringQuotes:j,nodeData:U,enumType:xe,translate:D,handleKeyboard:S,keyboardCommon:{cancel:Ve,tabForward:()=>{z("next"),F($);const e=R(U.fullData,H,"next",T);e&&(Ie(),I(e))},tabBack:()=>{z("prev"),F($);const e=R(U.fullData,H,"prev",T);e&&(Ie(),I(e))}}},Ye={canEditKey:Fe,isEditingKey:_e,pathString:$,path:H,name:Z,arrayIndexFromOne:E,handleKeyboard:S,handleEditKey:re,handleCancel:Ve,styles:K("property",U),getNextOrPrevious:e=>R(U.fullData,H,e,T),emptyStringKey:oe,nodeData:U,customNodeData:k,getStyles:K},$e=We?t(ge,Object.assign({},n,{value:G,customNodeProps:me,setValue:pe,handleEdit:Ie,handleCancel:Ve,handleKeyPress:e=>S(e,{stringConfirm:Ie,cancel:Ve}),isEditing:Ke,setIsEditing:()=>I(H),getStyles:K,originalNode:Ne?Oe(r,Ge):void 0,originalNodeKey:Ne?t(we,Object.assign({},Ye,{customNodeData:void 0})):void 0,canEdit:X,keyboardCommon:Ge.keyboardCommon,onError:ne})):Oe(r,Ge);return e("div",Object.assign({className:"jer-component jer-value-component",style:{marginLeft:null!==o?w/2+"em":0,position:"relative"},draggable:ee},ae,le("above"),{children:[se,t(ce,{position:"above",nodeData:U}),e("div",{className:"jer-value-main-row",style:{flexWrap:Z.length>10?"wrap":"nowrap"},children:[Be&&t(we,Object.assign({},Ye)),e("div",{className:"jer-value-and-buttons",children:[t("div",{className:"jer-input-component",children:$e}),Ke?t(ye,{onOk:Ie,onCancel:Ve,nodeData:U,editConfirmRef:A}):Me&&t(he,{startEdit:X?()=>{B(M),I(H,Ve)}:void 0,handleDelete:q?()=>{d(G,H).then((e=>{e&&ne({code:"DELETE_ERROR",message:e},G)}))}:void 0,enableClipboard:g,translate:D,customButtons:n.customButtons,nodeData:U,handleKeyboard:S,keyboardControls:N,editConfirmRef:A,jsonStringify:x,showIconTooltips:P}),ze&&e("div",{className:"jer-select jer-select-types",children:[t("select",{name:`${Z}-type-select`,className:"jer-select-inner",onChange:e=>(e=>{const t=C.find((t=>t.name===e));if(t)return a(t.defaultValue,H),ue(e),Pe(null),I(null),void V({path:H,collapsed:!1,includeChildren:!1});const n=Ae.find((t=>t instanceof Object&&t.enum===e));if(n)return"string"==typeof G&&n.values.includes(G)||a(n.values[0],H).then((e=>{e&&(ne({code:"UPDATE_ERROR",message:e},r),I(null))})),void Pe(n);const r=ke(G,e,D("DEFAULT_NEW_KEY",U),(null==k?void 0:k.CustomNode)?D("DEFAULT_STRING",U):void 0);["string","number","boolean"].includes(e)||I(null),a(r,H).then((e=>{e?(ne({code:"UPDATE_ERROR",message:e},r),I(null)):Pe(null)}))})(e.target.value),value:xe?xe.enum:de,children:Ae.map((e=>e instanceof Object&&"enum"in e?t("option",{value:e.enum,children:e.enum},e.enum):t("option",{value:e,children:e},e)))}),t("span",{className:"focus"})]}),Le&&t("span",{className:"jer-error-slug",style:K("error",U),children:te})]})]}),t(ce,{position:"below",nodeData:U})]}))},Ce=(e,t)=>(null==t?void 0:t.CustomNode)&&(null==t?void 0:t.name)&&t.showInTypesSelector?t.name:"string"==typeof e?"string":"number"==typeof e?"number":"boolean"==typeof e?"boolean":null===e?"null":"invalid",Oe=(e,n)=>{const r=Ce(e),{value:o}=n;switch(r){case"string":return t(te,Object.assign({},n,{value:o}));case"number":return t(ne,Object.assign({},n,{value:o}));case"boolean":return t(re,Object.assign({},n,{value:o}));case"null":return t(ie,Object.assign({},n));default:return t(ae,Object.assign({},n))}},ke=(e,t,n,r)=>{switch(t){case"string":return null!=r?r:String(e);case"number":{const t=Number(e);return isNaN(t)?0:t}case"boolean":return!!e;case"null":return null;case"object":return{[n]:e};case"array":return[e];default:return String(e)}},Se=(e=[],t)=>{const n=e.filter((({condition:e})=>e(t)));if(0===n.length)return{};const r=n[0],{element:o,wrapperElement:i,customKey:a,customNodeProps:l,wrapperProps:s,hideKey:c=!1,showEditTools:u=!0,showOnEdit:p=!1,showOnView:g=!0,showCollectionWrapper:m=!0}=r,h=d(r,["element","wrapperElement","customKey","customNodeProps","wrapperProps","hideKey","showEditTools","showOnEdit","showOnView","showCollectionWrapper"]);return Object.assign({CustomNode:o,CustomWrapper:i,CustomKey:a,customNodeProps:l,wrapperProps:s,hideKey:c,showEditTools:u,showOnEdit:p,showOnView:g,showCollectionWrapper:m},h)},Ne=r=>{const{getStyles:o}=W(),{collapseState:c,setCollapseState:d,getMatchingCollapseState:p,currentlyEditingElement:g,setCurrentlyEditingElement:m,areChildrenBeingEdited:h,previousValue:y,setPreviousValue:f}=J(),{mainContainerRef:b,data:v,nodeData:j,parentData:E,showCollectionCount:w,onEdit:k,onAdd:S,onDelete:N,canDragOnto:T,collapseFilter:x,collapseAnimationTime:P,onMove:K,enableClipboard:I,onEditEvent:V,showIconTooltips:F,searchFilter:L,searchText:z,indent:M,sort:B,showArrayIndices:G,arrayIndexFromOne:Y,defaultValue:$,newKeyOptions:U,translate:H,customNodeDefinitions:Z,customNodeData:X,jsonParse:Q,jsonStringify:q,TextEditor:ee,keyboardControls:te,handleKeyboard:ne,insertAtTop:re,onCollapse:oe,editConfirmRef:ie,collapseClickZones:ae}=r,[le,se]=i(q(v)),ce=x(j),{contentRef:de,isAnimating:ue,maxHeight:pe,collapsed:ge,animateCollapse:fe,cssTransitionValue:be}=((e,t,n,r,o)=>{const[l,c]=i(n?0:void 0),[d,u]=i(n),p=a(!1),g=a(null),m=a(0),h=a(0),y=t/1e3+"s",f=s((n=>{var i,a;if(d!==n){switch(window.clearTimeout(h.current),p.current=!0,n){case!0:{const e=null!==(a=null===(i=g.current)||void 0===i?void 0:i.offsetHeight)&&void 0!==a?a:0;m.current=e,c(e),setTimeout((()=>{c(0)}),5);break}case!1:c(m.current||Ee(e,g,r,o))}u(!d),h.current=window.setTimeout((()=>{p.current=!1,n||c(void 0)}),t)}}),[t,d,e,r,o]);return{contentRef:g,isAnimating:p.current,animateCollapse:f,maxHeight:l,collapsed:d,cssTransitionValue:y}})(v,P,ce,b,q),{pathString:Ce,nodeData:Oe,path:ke,name:Te,size:Ae,canEdit:xe,canDelete:Pe,canAdd:Ke,canDrag:Re,error:Ie,setError:Ve,onError:_e,handleEditKey:Fe,emptyStringKey:Le,derivedValues:ze}=ve({props:r,collapsed:ge}),{dragSourceProps:Me,getDropTargetProps:Be,BottomDropTarget:We,DropTargetPadding:Ge}=je({canDrag:Re,canDragOnto:T,path:ke,nodeData:Oe,onMove:K,onError:_e,translate:H}),Ye=a(!ce),{isEditing:$e,isEditingKey:Ue,isArray:He,canEditKey:Ze}=ze;l((()=>{se(q(v))}),[v]),l((()=>{const e=x(Oe)&&!$e;Ye.current=!e,fe(e)}),[x]),l((()=>{if(null!==c){const e=p(ke);e&&(Ye.current=!0,fe(e.collapsed))}}),[c]);const Je=a(null),Xe=s(((e,t)=>{if("function"!=typeof $)return $;const n=$(e,t);return void 0!==n?n:null}),[$]),Qe=s((e=>U?"function"!=typeof U?U:U(e):null),[U]),{CustomNode:qe,customNodeProps:et,CustomWrapper:tt,wrapperProps:nt={},hideKey:rt,showEditTools:ot=!0,showOnEdit:it,showOnView:at,showCollectionWrapper:lt=!0}=X,st=h(Ce);st&&ge&&fe(!1);if(!(O("collection",Oe,L,z)||0===Oe.level)&&!st)return null;const ct=Array.isArray(v)?"array":"object",dt="array"===ct?{open:"[",close:"]"}:{open:"{",close:"}"},ut=e=>{if("Tab"!==e.key||e.getModifierState("Shift"))ne(e,{objectConfirm:gt,cancel:ht});else{e.preventDefault();const t=_(Je,"\t");se(t)}},pt=e=>{e.stopPropagation();const t=A(e);if(t&&te.collapseModifier.includes(t))return Ye.current=!0,void d({collapsed:!ge,path:ke,includeChildren:!0});g&&g.includes(Ce)||(Ye.current=!0,d(null),oe&&oe({path:ke,collapsed:!ge,includeChildren:!1}),fe(!ge))},gt=()=>{try{const e=Q(le);if(m(null),f(null),Ve(null),q(e)===q(v))return;k(e,ke).then((t=>{t&&_e({code:"UPDATE_ERROR",message:t},e)}))}catch(e){_e({code:"INVALID_JSON",message:H("ERROR_INVALID_JSON",Oe)},le)}},mt=ke.length>0?()=>{N(v,ke).then((e=>{e&&_e({code:"DELETE_ERROR",message:e},v)}))}:void 0,ht=()=>{m(null),null===y?(Ve(null),se(q(v)),f(null)):k(y,ke)},yt="when-closed"===w?ge:w,ft=!$e&&ot,bt=(G||!He)&&!rt&&void 0!==Te,vt=qe&&($e&&it||!$e&&at),jt=Object.entries(v).map((([e,t])=>["array"===ct?Number(e):e,t]));"object"===ct&&B(jt,(e=>e));const Et=Ye.current?$e?e("div",{className:"jer-collection-text-edit",children:[ee?t(ee,{value:le,onChange:se,onKeyDown:e=>ne(e,{objectConfirm:gt,cancel:ht})}):t(D,{textAreaRef:Je,className:"jer-collection-text-area",name:Ce,value:le,setValue:se,handleKeyPress:ut,styles:o("input",Oe)}),t("div",{className:"jer-collection-input-button-row",children:t(ye,{onOk:gt,onCancel:ht,nodeData:Oe,editConfirmRef:ie})})]}):jt.map((([e,n],i)=>{const a={key:e,value:n,path:[...ke,e],level:ke.length+1,index:i,size:C(n)?Object.keys(n).length:null,parentData:v,fullData:Oe.fullData},l=Se(Z,a);return t("div",{className:"jer-collection-element",style:o("collectionElement",a),children:C(n)&&!(null==l?void 0:l.renderCollectionAsValue)?t(Ne,Object.assign({},r,{data:n,parentData:v,nodeData:a,showCollectionCount:w,canDragOnto:xe,customNodeData:l}),e):t(De,Object.assign({},r,{data:n,parentData:v,nodeData:a,canDragOnto:xe,showLabel:"object"===ct||G,customNodeData:l}),e)},e)})):null,wt=!!lt&&(ge&&!st);wt||(Ye.current=!0);const Dt=Object.assign(Object.assign({},r),{data:v,value:v,parentData:E,nodeData:Oe,setValue:e=>u(void 0,void 0,void 0,(function*(){return yield k(e,ke)})),handleEdit:gt,handleCancel:ht,handleKeyPress:ut,isEditing:$e,setIsEditing:()=>m(ke),getStyles:o,canDragOnto:xe,canEdit:xe,keyboardCommon:{},onError:_e}),Ct=vt?t(qe,Object.assign({customNodeProps:et},Dt,{children:Et})):Et,Ot=ft&&t(he,{startEdit:xe?()=>{Ye.current=!0,f(null),m(ke)}:void 0,handleAdd:Ke?e=>{fe(!1);const t=Xe(Oe,e);if("array"===ct){const e=re.array?0:v.length,n=re.array?{insert:!0}:{};S(t,[...ke,e],n).then((e=>{e&&_e({code:"ADD_ERROR",message:e},t)}))}else if(e in v)_e({code:"KEY_EXISTS",message:H("ERROR_KEY_EXISTS",Oe)},e);else{const n=re.object?{insertBefore:0}:{};S(t,[...ke,e],n).then((e=>{e&&_e({code:"ADD_ERROR",message:e},t)}))}}:void 0,handleDelete:Pe?mt:void 0,enableClipboard:I,type:ct,nodeData:Oe,translate:H,customButtons:r.customButtons,keyboardControls:te,handleKeyboard:ne,getNewKeyOptions:Qe,editConfirmRef:ie,jsonStringify:q,onEditEvent:V,showIconTooltips:F}),kt={canEditKey:Ze,isEditingKey:Ue,pathString:Ce,path:ke,name:Te,arrayIndexFromOne:Y,handleKeyboard:ne,handleEditKey:Fe,handleCancel:ht,keyValueArray:jt,styles:o("property",Oe),getNextOrPrevious:e=>R(Oe.fullData,ke,e,B),handleClick:ae.includes("property")?pt:e=>e.stopPropagation(),emptyStringKey:Le,nodeData:Oe,customNodeData:X,getStyles:o},St=e("div",Object.assign({className:"jer-component jer-collection-component",style:Object.assign(Object.assign({marginLeft:(0===ke.length?0:M/2)+"em"},o("collection",Oe)),{position:"relative"}),draggable:Re},Me,Be("above"),{children:[t("div",{className:"jer-clickzone",style:{width:M/2+1+"em",zIndex:10+2*Oe.level},onClick:ae.includes("left")?pt:void 0}),!$e&&We,t(Ge,{position:"above",nodeData:Oe}),lt?e("div",{className:"jer-collection-header-row",style:{position:"relative"},onClick:ae.includes("header")?pt:void 0,children:[e("div",{className:"jer-collection-name",children:[t("div",{className:"jer-collapse-icon jer-accordion-icon"+(ge?" jer-rotate-90":""),style:{zIndex:11+2*Oe.level,transition:be},onClick:pt,children:t(me,{name:"chevron",rotate:ge,nodeData:Oe})}),bt&&t(we,Object.assign({},kt)),!$e&&t("span",{className:"jer-brackets jer-bracket-open",style:o("bracket",Oe),children:dt.open})]}),!$e&&yt&&t("div",{className:"jer-collection-item-count"+(yt?" jer-visible":" jer-hidden"),style:Object.assign(Object.assign({},o("itemCount",Oe)),{transition:be}),children:1===Ae?H("ITEM_SINGLE",Object.assign(Object.assign({},Oe),{size:1}),1):H("ITEMS_MULTIPLE",Oe,Ae)}),t("div",{className:"jer-brackets"+(wt?" jer-visible":" jer-hidden"),style:Object.assign(Object.assign({},o("bracket",Oe)),{transition:be}),children:dt.close}),Ot]}):rt?t(n,{}):e("div",{className:"jer-collection-header-row",style:{position:"relative"},children:[t(we,Object.assign({},kt)),Ot]}),e("div",{className:"jer-collection-inner",style:Object.assign(Object.assign({overflowY:wt||ue?"clip":"visible",maxHeight:st?void 0:pe},o("collectionInner",Oe)),{transition:be}),ref:de,children:[Ct,t("div",{className:$e?"jer-collection-error-row":"jer-collection-error-row-edit",children:Ie&&t("span",{className:"jer-error-slug",style:o("error",Oe),children:Ie})}),!$e&<&&t("div",{className:"jer-brackets jer-bracket-outside",style:Object.assign(Object.assign({},o("bracket",Oe)),{marginLeft:(M<3?-1:M<6?-.5:0)+"em"}),children:dt.close})]}),t(Ge,{position:"below",nodeData:Oe})]}));return tt?t(tt,Object.assign({customNodeProps:nt},Dt,{children:St})):St},Te={ITEM_SINGLE:"{{count}} item",ITEMS_MULTIPLE:"{{count}} items",KEY_NEW:"Enter new key",KEY_SELECT:"Select key",NO_KEY_OPTIONS:"No key options",ERROR_KEY_EXISTS:"Key already exists",ERROR_INVALID_JSON:"Invalid JSON",ERROR_UPDATE:"Update unsuccessful",ERROR_DELETE:"Delete unsuccessful",ERROR_ADD:"Adding node unsuccessful",DEFAULT_STRING:"New data!",DEFAULT_NEW_KEY:"key",SHOW_LESS:"(Show less)",EMPTY_STRING:"<empty string>",TOOLTIP_COPY:"Copy to clipboard",TOOLTIP_EDIT:"Edit",TOOLTIP_DELETE:"Delete",TOOLTIP_ADD:"Add"},Ae=(e,t)=>(n,r,o)=>((e,t,n,r,o)=>{if(t[r]){const e=t[r](n);if(null!==e)return e}const i=r in e?e[r]:Te[r];return void 0===o?i:null==i?void 0:i.replace("{{count}}",String(o))})(e,t,r,n,o);var xe=[],Pe=[];!function(e,t){if(e&&"undefined"!=typeof document){var n,r=!0===t.prepend?"prepend":"append",o=!0===t.singleTag,i="string"==typeof t.container?document.querySelector(t.container):document.getElementsByTagName("head")[0];if(o){var a=xe.indexOf(i);-1===a&&(a=xe.push(i)-1,Pe[a]={}),n=Pe[a]&&Pe[a][r]?Pe[a][r]:Pe[a][r]=l()}else n=l();65279===e.charCodeAt(0)&&(e=e.substring(1)),n.styleSheet?n.styleSheet.cssText+=e:n.appendChild(document.createTextNode(e))}function l(){var e=document.createElement("style");if(e.setAttribute("type","text/css"),t.attributes)for(var n=Object.keys(t.attributes),o=0;o<n.length;o++)e.setAttribute(n[o],t.attributes[n[o]]);var a="prepend"===r?"afterbegin":"beforeend";return i.insertAdjacentElement(a,e),e}}(':root{--jer-select-border:#b6b6b6;--jer-select-focus:#777;--jer-select-arrow:#777;--jer-form-border:1px solid #ededf0;--jer-form-border-focus:1px solid #e2e2e2;--jer-highlight-color:#b3d8ff}.jer-visible{opacity:1}.jer-hidden{opacity:0}.jer-select select{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:transparent;border:none;color:#000;cursor:inherit;font-family:inherit;font-size:.8em;line-height:inherit;margin:0;outline:none;padding:0 1em 0 0;z-index:1}select::-ms-expand{display:none}.jer-select{align-items:center;background-color:#fff;background-image:linear-gradient(0deg,#f9f9f9,#fff 33%);border:1px solid var(--jer-select-border);border-radius:.25em;cursor:pointer;display:grid;grid-template-areas:"select";line-height:1.1;max-width:15ch;min-width:12ch;padding:.25em .5em;position:relative}.jer-select select,.jer-select:after{grid-area:select}.jer-select:not(.jer-select--multiple):after{background-color:var(--jer-select-arrow);clip-path:polygon(100% 0,0 0,50% 100%);content:"";height:.5em;justify-self:end;width:.8em}select:focus+.focus{border:1px solid var(--jer-select-focus);border-radius:inherit;bottom:-1px;left:-1px;position:absolute;right:-1px;top:-1px}.jer-select-inner{text-overflow:ellipsis;width:100%}.jer-editor-container{border-radius:.5em;font-size:16px;line-height:1;padding:1em 1em 1em 2em;position:relative;text-align:left}.jer-editor-container textarea{border:var(--jer-form-border);border-radius:.3em;color:var(--jer-input-color);outline:none}.jer-editor-container textarea:focus{border:var(--jer-form-border-focus)}.jer-editor-container input{border:var(--jer-form-border);border-radius:.3em;font-family:inherit;outline:none}.jer-editor-container input:focus{border:var(--jer-form-border-focus)}.jer-editor-container ::selection{background-color:var(--jer-highlight-color)}.jer-collection-header-row,.jer-value-main-row{align-items:center;display:flex;gap:.3em;min-height:1.7em}.jer-collection-header-row{display:flex;flex-wrap:wrap}.jer-bracket-outside{padding-left:.5em}.jer-collapse-icon{left:-1.2em;position:absolute;top:.35em}.jer-collection-inner{position:relative}.jer-collection-text-edit{align-items:flex-start;display:flex;flex-direction:column;gap:.3em;line-height:1.1em}.jer-collection-text-area{font-family:inherit;font-size:.85em;max-height:40em;overflow:hidden;padding:.2em .5em 0;resize:both}.jer-collection-input-button-row{display:flex;font-size:150%;justify-content:flex-end;margin-top:.4em;width:100%}.jer-collection-error-row{bottom:.5em;position:absolute}.jer-error-slug{margin-left:1em}.jer-value-component{position:relative}.jer-value-main-row{display:flex;gap:0}.jer-value-and-buttons{align-items:center;display:flex;justify-content:flex-start;padding-left:.5em}.jer-value-error-row{position:absolute}.jer-value-string{line-height:1.3em;overflow-wrap:anywhere;white-space:pre-wrap;word-break:break-word}.jer-string-expansion{cursor:pointer;filter:saturate(50%);opacity:.6}.jer-show-less{font-size:80%}.jer-hyperlink{text-decoration:underline}.jer-input-text{font-family:inherit;font-size:.9em;height:1.4em;line-height:1.2em;margin:0;min-width:6em;overflow:hidden;padding:.25em .5em .2em;resize:none}.jer-input-boolean{margin-left:.3em;margin-right:.3em;transform:scale(1.5)}.jer-key-text{line-height:1.1em;white-space:pre-wrap;word-break:break-word}.jer-key-edit{font-size:inherit;font-size:.9em;padding:0 .3em}.jer-value-invalid{font-style:italic;opacity:.5}.jer-input-number{font-size:90%;min-width:3em}.jer-confirm-buttons,.jer-edit-buttons{align-items:center;cursor:pointer;display:flex;height:1em}.jer-input-buttons{gap:.4em}.jer-edit-buttons{gap:.4em;margin-left:.5em;opacity:0}.jer-confirm-buttons{gap:.2em;margin-left:.4em}.jer-edit-buttons:hover{opacity:1;position:relative}.jer-collection-header-row:hover>.jer-edit-buttons,.jer-value-and-buttons:hover>.jer-edit-buttons,.jer-value-main-row:hover>.jer-edit-buttons{opacity:1}.jer-copy-pulse{position:relative;transition:.3s}.jer-copy-pulse:hover{opacity:.85;transform:scale(1.2);transition:.3s}.jer-copy-pulse:after{border-radius:50%;box-shadow:0 0 15px 5px var(--jer-icon-copy-color);content:"";display:block;height:100%;left:0;opacity:0;position:absolute;top:0;transition:all .5s;width:100%}.jer-copy-pulse:active:after{border-radius:4em;box-shadow:0 0 0 0 var(--jer-icon-copy-color);left:0;opacity:1;position:absolute;top:0;transition:0s}.jer-copy-pulse:active{top:.07em}.jer-rotate-90{transform:rotate(-90deg)}.jer-icon:hover{opacity:.85;transform:scale(1.2);transition:.3s}.jer-empty-string{font-size:90%;font-style:italic}.jer-drag-n-drop-padding{border:1px dashed #e0e0e0;border-radius:.3em;height:.5em}.jer-clickzone{height:calc(100% - .8em);left:-1em;position:absolute;top:1.2em}',{});const Ke=(e,t)=>JSON.stringify(e,t,2),Re=({data:e,setData:n,rootName:r="root",onUpdate:o=()=>{},onEdit:d=o,onDelete:p=o,onAdd:g=o,onChange:m,onError:h,onEditEvent:y,showErrorMessages:f=!0,enableClipboard:b=!0,indent:v=2,collapse:j=!1,collapseAnimationTime:E=300,showCollectionCount:w=!0,restrictEdit:D=!1,restrictDelete:O=!1,restrictAdd:k=!1,restrictTypeSelection:S=!1,restrictDrag:N=!0,viewOnly:A,searchFilter:P,searchText:R,searchDebounceTime:I=350,keySort:V=!1,showArrayIndices:_=!0,arrayIndexFromOne:L=!1,showStringQuotes:z=!0,showIconTooltips:M=!1,defaultValue:B=null,newKeyOptions:G,minWidth:Y=250,maxWidth:$="min(600px, 90vw)",rootFontSize:U,stringTruncate:H=250,translations:Z={},className:X,id:Q,customText:q={},customNodeDefinitions:ee=[],customButtons:te=[],jsonParse:ne=JSON.parse,jsonStringify:re=Ke,TextEditor:oe,errorMessageTimeout:ie=2500,keyboardControls:ae={},externalTriggers:le,insertAtTop:se=!1,onCollapse:ce,collapseClickZones:de=["header","left"]})=>{const{getStyles:ue}=W(),{setCurrentlyEditingElement:pe}=J(),ge=c((()=>_e(j)),[j]),me=c((()=>Ae(Z,q)),[Z,q]),[he,ye]=i(R),[fe,be]=(({setData:e,data:t})=>{const[n,r]=i(e?void 0:t),o=s((t=>{e?e(t):r(t)}),[e]);return l((()=>{e||r(t)}),[t]),[e?t:n,o]})({setData:n,data:e}),ve=a(null);l((()=>{pe(null);const e=setTimeout((()=>ye(R)),I);return()=>clearTimeout(e)}),[R,I]);const je={key:r,path:[],level:0,index:0,value:fe,size:"object"==typeof fe&&null!==fe?Object.keys(fe).length:1,parentData:null,fullData:fe},Ee=(e,t)=>u(void 0,void 0,void 0,(function*(){const n=yield e(t);if(!0===n||void 0===n)return void be(t.newData);const r=Le(n)?n:["error",n],[o,i]=r;if("error"===o)return be(t.currentData),!1===i?me("ERROR_UPDATE",je):String(i);be(i)})),we=c((()=>_e(D,A)),[D,A]),Ce=c((()=>_e(O,A)),[O,A]),Oe=c((()=>_e(k,A)),[k,A]),ke=c((()=>_e(N,A)),[N,A]),Te=c((()=>Fe(P)),[P]),xe=c((()=>(e=>{const t=Object.assign({},K);for(const n of Object.keys(K)){const r=n;if(e[r]){const o=e[r],i=["clipboardModifier","collapseModifier"].includes(n)?Array.isArray(o)?o:[o]:"string"==typeof o?{key:o}:o;t[r]=i,["stringConfirm","numberConfirm","booleanConfirm"].forEach((n=>{!e[n]&&e.confirm&&(t[n]=t.confirm)}))}}return t})(ae)),[ae]),Pe=s(((e,t)=>((e,t,n)=>{const r=Object.entries(t);for(const[t,o]of r)if(x(n,e[t],t)){n.preventDefault(),o();break}})(xe,t,e)),[xe]),Re=c((()=>{const e=ze(ee,"stringifyReplacer");return t=>re(t,e)}),[ee,re]),Ie=c((()=>{const e=ze(ee,"parseReviver");return t=>{const n=ne(t,e);return F(n)}}),[ee,ne]),Me=a(null);((e,t)=>{const{setCurrentlyEditingElement:n,currentlyEditingElement:r,setCollapseState:o}=J();l((()=>{if(!e)return;const{collapse:i,edit:a}=e;i&&o(i);const l=!(null==a?void 0:a.path)||T(a.path)===r;switch(null==a?void 0:a.action){case"accept":l&&(t.current&&t.current.click(),n(null));break;case"cancel":l&&n(null);break;default:(null==a?void 0:a.path)&&n(a.path)}}),[e])})(le,Me);const Be=s(((e,t)=>{!1!==V&&("function"!=typeof V?e.sort(((e,n)=>{const r=t(e)[0],o=t(n)[0];return r<o?-1:r>o?1:0})):e.sort(((e,n)=>V(t(e),t(n)))))}),[V]),We=Se(ee,je),Ge={mainContainerRef:ve,name:r,nodeData:je,onEdit:(e,t)=>u(void 0,void 0,void 0,(function*(){const{currentData:n,newData:r,currentValue:o,newValue:i}=Ve(fe,t,e,"update");if(o!==i)return yield Ee(d,{currentData:n,newData:r,currentValue:o,newValue:i,name:t.slice(-1)[0],path:t})})),onDelete:(e,t)=>u(void 0,void 0,void 0,(function*(){const{currentData:n,newData:r,currentValue:o,newValue:i}=Ve(fe,t,e,"delete");return yield Ee(p,{currentData:n,newData:r,currentValue:o,newValue:i,name:t.slice(-1)[0],path:t})})),onAdd:(e,t,n)=>u(void 0,void 0,void 0,(function*(){const{currentData:r,newData:o,currentValue:i,newValue:a}=Ve(fe,t,e,"add",n);return yield Ee(g,{currentData:r,newData:o,currentValue:i,newValue:a,name:t.slice(-1)[0],path:t})})),onChange:m,onError:h,onEditEvent:y,showErrorMessages:f,onMove:(e,t,n)=>u(void 0,void 0,void 0,(function*(){if(null===e)return;const{currentData:r,newData:o,currentValue:i}=Ve(fe,e,"","delete"),a=e.slice(-1)[0],l=t.slice(0,-1),s=t.slice(-1)[0];let c="number"==typeof s?"above"===n?s:s+1:"number"==typeof a?`arr_${a}`:a;e.slice(0,-1).join(".")===t.slice(0,-1).join(".")&&"number"==typeof a&&"number"==typeof c&&a<c&&(c-=1);const u="number"==typeof c?{insert:!0}:"above"===n?{insertBefore:s}:{insertAfter:s},{newData:p,newValue:g}=Ve(o,[...l,c],i,"add",u);return yield Ee(d,{currentData:r,newData:p,currentValue:i,newValue:g,name:t.slice(-1)[0],path:t})})),showCollectionCount:w,collapseFilter:ge,collapseAnimationTime:E,restrictEditFilter:we,restrictDeleteFilter:Ce,restrictAddFilter:Oe,restrictTypeSelection:S,restrictDragFilter:ke,canDragOnto:!1,searchFilter:Te,searchText:he,enableClipboard:b,keySort:V,sort:Be,showArrayIndices:_,arrayIndexFromOne:L,showStringQuotes:z,showIconTooltips:M,indent:v,defaultValue:B,newKeyOptions:G,stringTruncate:H,translate:me,customNodeDefinitions:ee,customNodeData:We,customButtons:te,parentData:null,jsonParse:Ie,jsonStringify:Re,TextEditor:oe,errorMessageTimeout:ie,handleKeyboard:Pe,keyboardControls:xe,insertAtTop:{object:!0===se||"object"===se,array:!0===se||"array"===se},onCollapse:ce,editConfirmRef:Me,collapseClickZones:de},Ye=Object.assign(Object.assign({},ue("container",je)),{minWidth:Y,maxWidth:$});return Ye.fontSize=null!=U?U:Ye.fontSize,t("div",{id:Q,ref:ve,className:`jer-editor-container ${null!=X?X:""}`,style:Ye,children:C(fe)&&!We.renderCollectionAsValue?t(Ne,Object.assign({data:fe},Ge)):t(De,Object.assign({data:fe,showLabel:!0},Ge))})},Ie=e=>{var n;const[r,o]=i();return l((()=>{const e=document.documentElement;o(e)}),[]),r?t(B,{theme:null!==(n=e.theme)&&void 0!==n?n:z,icons:e.icons,docRoot:r,children:t(Z,{onEditEvent:e.onEditEvent,onCollapse:e.onCollapse,children:t(Re,Object.assign({},e))})}):null},Ve=(e,t,n,r,o={})=>{if(0===t.length)return{currentData:e,newData:n,currentValue:e,newValue:n};const i=Object.assign({remove:"delete"===r},o),a="add"!==r?g(e,t):void 0;return{currentData:e,newData:v(e,t,n,i),currentValue:a,newValue:"delete"!==r?n:void 0}},_e=(e,t)=>t?()=>!0:"boolean"==typeof e?()=>e:"number"==typeof e?({level:t})=>t>=e:e,Fe=e=>{if(void 0!==e)return"value"===e?S:"key"===e?N:"all"===e?(e,t)=>S(e,t)||N(e,t):e},Le=e=>Array.isArray(e)&&2===e.length&&["error","value"].includes(e[0]),ze=(e,t)=>{const n="stringifyReplacer"===t?[e=>void 0===e?L:e]:[];if(n.push(...e.map((e=>e[t])).filter((e=>!!e))),0!==n.length)return(e,t)=>{let r=t;for(const e of n)r=e(r);return r}},Me=e=>{var n;const{value:r,setIsEditing:o,getStyles:i,nodeData:a}=e,l=i("string",a);return t("div",{onDoubleClick:()=>o(!0),onClick:e=>{(e.getModifierState("Control")||e.getModifierState("Meta"))&&o(!0)},className:"jer-value-string jer-hyperlink",style:l,children:t("a",{href:r,target:"_blank",rel:"noreferrer",style:{color:null!==(n=l.color)&&void 0!==n?n:void 0},children:t(q,Object.assign({},e,{pathString:T(a.path),styles:l,value:a.value}))})})},Be={condition:({value:e})=>"string"==typeof e&&/^https?:\/\/.+\..+$/.test(e),element:Me,showOnView:!0,showOnEdit:!1},We={displayName:"Github Dark",styles:{container:{backgroundColor:"#0d1117",color:"white"},dropZone:"rgba(165, 214, 255, 0.17)",property:"#E6EDF3",bracket:"#56d364",itemCount:"#8B949E",string:"#A5D6FF",number:"#D2A8FF",boolean:{color:"#FF7B72",fontSize:"90%",fontWeight:"bold"},null:"green",iconCollection:"#D2A8FF",iconEdit:"#D2A8FF",iconDelete:"rgb(203, 75, 22)",iconAdd:"rgb(203, 75, 22)",iconCopy:"#A5D6FF",iconOk:"#56d364",iconCancel:"rgb(203, 75, 22)"}},Ge={displayName:"Github Light",styles:{container:"white",property:"#1F2328",bracket:"#00802e",itemCount:"#8B949E",string:"#0A3069",number:"#953800",boolean:{color:"#CF222E",fontSize:"90%",fontWeight:"bold"},null:"#FF7B72",iconCollection:"#8250DF",iconEdit:"#8250DF",iconDelete:"rgb(203, 75, 22)",iconAdd:"#8250DF",iconCopy:"#57606A"}},Ye={displayName:"Black & White",fragments:{lightText:{color:"white"},midGrey:"#5c5c5c"},styles:{container:["lightText",{backgroundColor:"black"}],dropZone:"#e0e0e029",property:"lightText",bracket:"midGrey",itemCount:"#4a4a4a",string:"#a8a8a8",number:"#666666",boolean:{color:"#848484",fontStyle:"italic"},null:"#333333",iconCollection:"midGrey",iconEdit:"midGrey",iconDelete:"midGrey",iconAdd:"midGrey",iconCopy:"midGrey",iconOk:"midGrey",iconCancel:"midGrey"}},$e={fragments:{midGrey:"#a3a3a3"},displayName:"White & Black",styles:{container:"white",property:"black",bracket:"midGrey",itemCount:"#b5b5b5",string:"#575757",number:"#999999",boolean:{color:"#7b7b7b",fontStyle:"italic"},null:"#cccccc",iconCollection:"midGrey",iconEdit:"midGrey",iconDelete:"midGrey",iconAdd:"midGrey",iconCopy:"midGrey",iconOk:"midGrey",iconCancel:"midGrey"}},Ue={displayName:"Candy Wrapper",fragments:{minty:{backgroundColor:"#F1FAEE"},pale:{color:"#A8DADC"},mid:{color:"#457B9D"},dark:{color:"#1D3557"},pop:{color:"#E63946"},darkBlue:{color:"#2B2D42"}},styles:{container:"minty",property:"pop",dropZone:"#eb121217",bracket:"dark",itemCount:"pale",string:"mid",number:["darkBlue",{fontSize:"85%"}],boolean:["mid",{fontStyle:"italic",fontWeight:"bold",fontSize:"80%"}],null:["#cccccc",{fontWeight:"bold"}],input:{border:"1px solid rgb(115, 194, 198)"},iconCollection:"#1D3557",iconEdit:"#457B9D",iconDelete:"#E63946",iconAdd:"#2B2D42",iconCopy:"#1D3557",iconCancel:"#E63946"}},He={displayName:"Psychedelic",fragments:{pale:{color:"#A8DADC"},fluroYellow:"rgb(242, 228, 21)",fluroGreen:"rgb(68, 255, 62)",hotPink:"#f7379a"},styles:{container:{backgroundColor:"unset",background:"linear-gradient(90deg, hsla(333, 100%, 53%, 1) 0%, hsla(33, 94%, 57%, 1) 100%)",color:"black"},dropZone:"fluroYellow",property:"black",bracket:"fluroYellow",itemCount:["pale",{opacity:.7}],string:"white",number:["#33d9ff",{fontSize:"90%",fontWeight:"bold"}],boolean:["fluroGreen",{fontWeight:"bold",fontSize:"80%"}],null:["black",{fontWeight:"bold",opacity:.3,backgroundColor:"rgb(255, 255, 255, 0.5)",padding:"0 0.4em",borderRadius:"0.4em"}],iconCollection:"fluroYellow",iconEdit:["black"],iconDelete:["white",{opacity:.5}],iconAdd:["white",{opacity:.5}],iconCopy:"rgb(32, 84, 242)",iconOk:"fluroGreen",iconCancel:"hotPink"}};export{le as IconAdd,pe as IconCancel,ge as IconChevron,de as IconCopy,ce as IconDelete,se as IconEdit,ue as IconOk,Ie as JsonEditor,Me as LinkCustomComponent,Be as LinkCustomNodeDefinition,q as StringDisplay,ee as StringEdit,v as assign,Ue as candyWrapperTheme,z as defaultTheme,g as extract,We as githubDarkTheme,Ge as githubLightTheme,C as isCollection,S as matchNode,N as matchNodeKey,Ye as monoDarkTheme,$e as monoLightTheme,He as psychedelicTheme,be as standardDataTypes,T as toPathString,oe as useKeyboardListener};
|
|
1
|
+
import{jsxs as e,jsx as t,Fragment as n}from"react/jsx-runtime";import r,{useLayoutEffect as o,useEffect as a,useRef as i,createContext as l,useContext as s,useMemo as c,useCallback as d,useSyncExternalStore as u,useState as p,useImperativeHandle as h}from"react";const m=()=>{},f=e=>Array.isArray(e)?e:[e],y=e=>null!==e&&"object"==typeof e,g=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),v=(e,t)=>{if("string"!=typeof e)return null;const n=t.filter(t=>t instanceof Object&&t.enum&&t.values.includes(e)&&t.matchPriority);return n.sort((e,t)=>(t.matchPriority??0)-(e.matchPriority??0)),n[0]??null},b=e=>{if(e!==w){if(e&&"object"==typeof e)for(const t in e){const n=e[t],r=b(n);r!==n&&(e[t]=r)}return e}},w="__undefined__",E=e=>e.split(/(\.|\[\d+\])/).filter(e=>"."!==e&&""!==e).map(e=>{const t=/\[(\d+)\]/.exec(e);return t?Number(t[1]):e}),D=e=>"string"==typeof e?e:"number"==typeof e?String(e):e.reduce((e,t)=>"number"==typeof t?`${e}[${t}]`:""===e?t:`${e}.${t}`,""),C=e=>1===e.length&&""===e[0]?"\0":e.map(e=>encodeURIComponent(String(e))).join("/"),j=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),S=(e,t)=>e.length>=t.length&&t.every((t,n)=>t===e[n]),k=(e,t,n,r,o)=>{if(!r)throw new Error(o??`Invalid property path: ${t}\nCouldn't access "${n}" in ${JSON.stringify(e)}`)},O=e=>Array.isArray(e),T=(e,t)=>e.filter((e,n)=>n!==t),N=(e,t,n,r={})=>{const{remove:o=!1,createNew:a=!0,noError:i=!1}=r,l=e,s=D(t),c={...r,remove:o,createNew:a,noError:i,fullData:l,fullPath:s},d=Array.isArray(t)?t:E(t);return O(e)&&o&&1===d.length?T(e,d[0]):x(e,d,n,c)},x=(e,t,n,r)=>{const o=g(e)?{...e}:null,a=O(e)?[...e]:null;if(0===t.length)return e;if(!o&&!a)throw new Error("Can't assign property -- invalid input object");const{createNew:i,remove:l,noError:s,fullData:c,fullPath:d}=r,u=t[0];if(a&&"string"==typeof u)return a.map(e=>x(e,t,n,r));if(1===t.length){if(o&&"string"==typeof u){return R(o,u,n,r)??o}return a&&"number"==typeof u?(P(a,u,n,r),a):(k(c,d,u,s),e)}const p=o||a||[];if(l&&2===t.length&&"number"==typeof t[1]){const e=p[u],n=t[1];return O(e)?p[u]=T(e,n):k(c,d,u,s,"Trying to remove an indexed item from an object that is not an array"),p}const h=t.slice(1);if(u in e){if(m=p[u],!O(m)&&!g(m)){if(!i)return k(c,d,u,s),p;p[u]={}}return p[u]=x(p[u],h,n,r),p}var m;if(i){const e="number"==typeof h[0]?[]:{};if(o)return p[u]=e,p[u]=x(p[u],h,n,r),p;if(a&&Array.isArray(p)){p.push(e);const t=p.length-1;return p[t]=x(p[t],h,n,r),p}}return k(c,d,u,s),p},R=(e,t,n,r)=>{const{remove:o,createNew:a,noError:i,insertAfter:l,insertBefore:s,fullData:c,fullPath:d}=r;if(void 0!==s||void 0!==l){const r=Object.entries(e);let o=1/0;return o="number"==typeof s?s:"number"==typeof l?l:r.findIndex(([e])=>e===(s??l)),void 0!==l&&o++,r.splice(o,0,[t,n]),Object.fromEntries(r)}const u=t in e;o?u?delete e[t]:k(c,d,t,i):a||u?e[t]=n:k(c,d,t,i)},P=(e,t,n,r)=>{const{noError:o,fullData:a,fullPath:i,createNew:l,insert:s}=r;s&&e.splice(t,0,n),t in e?e[t]=n:l?e.push(n):k(a,i,t,o)},A=(e,t,n)=>{const r=Array.isArray(t)?t:E(t);if(0===r.length)return e;const o=r[0];if(Array.isArray(e)&&"number"!=typeof o&&e.length>0)return e.map(e=>A(e,r,n));if("object"!=typeof e||null===e||!(o in e))return I(e,o,n);const a=e[o];return 1===r.length?a:A(a,r.slice(1),n)},I=(e,t,n)=>{if(void 0===n)throw new Error(`Unable to extract object property\nLooking for property: ${t}\nIn object: ${JSON.stringify(e)}`);return n},K=(e,t,n="",r)=>{if(0===t.length)return{key:n,path:[],level:0,index:0,value:e,size:y(e)?Object.keys(e).length:1,parentData:null,fullData:e};const o=t[t.length-1],a=A(e,t),i=A(e,t.slice(0,-1))??null;let l=0;if(Array.isArray(i))l="number"==typeof o?o:Number(o);else if(i&&"object"==typeof i){const e=Object.entries(i);r?.(e,e=>e),l=e.findIndex(([e])=>e===o)}return{key:o,path:t,level:t.length,index:l,value:a,size:y(a)?Object.keys(a).length:null,parentData:i,fullData:e}},L="undefined"!=typeof window?o:a,_=({className:n,name:r,value:o,setValue:a,onKeyDown:l,styles:s,textAreaRef:c})=>{const d=i(null);if(L(()=>{const e=d.current;d.current=null;const t=c?.current;if(!e||!t)return;const n=e.start+o.length-e.sourceLength,r=Math.max(0,Math.min(n,o.length));t.selectionStart!==r&&t.setSelectionRange(r,r)},[o,c]),"string"!=typeof o)return null;const u="\n"===o.slice(-1)?o+".":o;return e("div",{style:{display:"grid"},children:[t("textarea",{id:`${r}_textarea`,ref:c,style:{height:"auto",gridArea:"1 / 1 / 2 / 2",overflowY:"auto",whiteSpace:"pre-wrap",...s},rows:1,className:n,name:`${r}_textarea`,value:o,onChange:e=>{const{value:t,selectionStart:n}=e.target;d.current=null!==n&&n<t.length?{start:n,sourceLength:t.length}:null,a(t)},autoFocus:!0,onFocus:e=>{o.length<40&&e.target.select()},onKeyDown:l}),t("span",{className:n,style:{visibility:"hidden",height:"auto",gridArea:"1 / 1 / 2 / 2",color:"red",opacity:.9,whiteSpace:"pre-wrap",overflowY:"auto",border:"1px solid transparent",...s},children:u})]})},V=e=>e.shiftKey?"Shift":e.metaKey?"Meta":e.ctrlKey?"Control":e.altKey?"Alt":void 0,M=(e,t,n)=>{if(!t)return!1;const r=e.key,o=V(e);if(Array.isArray(t))return!!o&&t.includes(o);const{key:a,modifier:i}=t;return("stringLineBreak"!==n||"Enter"!==r||"Shift"!==o||"Enter"!==a||!i?.includes("Shift"))&&(r===a&&(i===o||Array.isArray(i)&&i.includes(o)))},z={key:"Enter"},F={confirm:z,cancel:{key:"Escape"},objectConfirm:{...z,modifier:["Meta","Shift","Control"]},objectLineBreak:z,stringConfirm:z,stringLineBreak:{...z,modifier:["Shift"]},numberConfirm:z,numberUp:{key:"ArrowUp"},numberDown:{key:"ArrowDown"},tabForward:{key:"Tab"},tabBack:{key:"Tab",modifier:"Shift"},booleanConfirm:z,booleanToggle:{key:" "},clipboardModifier:["Meta","Control"],collapseModifier:["Alt"]},B=["stringConfirm","numberConfirm","booleanConfirm"],Y=(e,t)=>{const n=e.current,r=n.selectionStart??1/0,o=n.selectionEnd??1/0,a=n.value.slice(0,r)+t+n.value.slice(o);return n.value=a,n.setSelectionRange(r+1,r+1),a},U=(e,t,n="next",r,o)=>{const a=t.slice(0,t.length-1),i=t.slice(-1)[0];if(void 0===i)return null;const l=A(e,a),s=$(l);Array.isArray(l)||r(s,({key:e,value:t})=>[e,t]);const c=s.findIndex(e=>e.key===i),d=s[c+("next"===n?1:-1)];if(!d)return 0===a.length?null:U(e,a,n,r,o);let u;if(y(d.value)){if(0===Object.keys(d.value).length)return U(e,[...a,d.key],n,r,o);u=W(e,[...a,d.key],n,r)}else u=[...a,d.key];return u?o(K(e,u,"",r))?u:U(e,u,n,r,o):null},W=(e,t,n="next",r)=>{const o=A(e,t);if(!y(o))return t;const a=Array.isArray(o)?o.map((e,t)=>t):Object.keys(o);r(a,e=>[e,o]);const i="next"===n?a[0]:a[a.length-1];return W(e,[...t,i],n,r)},$=e=>Array.isArray(e)?e.map((e,t)=>({value:e,key:t})):Object.entries(e).map(([e,t])=>({key:e,value:t})),H={fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2},J={displayName:"Default",icons:{add:{content:e(n,{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"})]})},edit:{content:e(n,{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"})]}),svgProps:{transform:"translate(0, 0.5)"}},delete:{content: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"}),scale:1.04},copy:{content:e(n,{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"})]}),svgProps:H,scale:.86},ok:{content:e(n,{children:[t("path",{d:"M22 11.08V12a10 10 0 11-5.93-9.14"}),t("path",{d:"M22 4L12 14.01l-3-3"})]}),svgProps:H,scale:.9},cancel:{content: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"}),svgProps:{baseProfile:"tiny"},scale:1.3},collection:{content: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"}),viewBox:"0 0 512 512",scale:.7}},styles:{container:{backgroundColor:"#f6f6f6",fontFamily:"monospace"},property:"#292929",bracket:{color:"#002b36",fontWeight:"bold"},itemCount:{color:"#0000004d",fontStyle:"italic"},string:"#cb4b16",number:"#268bd2",boolean:"green",null:{color:"#dc322f",fontVariant:"small-caps",fontWeight:"bold"},input:["#292929"],inputHighlight:"#b3d8ff",error:{fontSize:"0.8em",color:"red",fontWeight:"bold"},iconCollection:"#002b36",iconEdit:"#2aa198",iconDelete:"#cb4b16",iconAdd:"#2aa198",iconCopy:"#268bd2",iconOk:"green",iconCancel:"#cb4b16"}},X={container:"backgroundColor",collection:"backgroundColor",collectionElement:"backgroundColor",headerRow:"backgroundColor",valueRow:"backgroundColor",dropZone:"borderColor",inputHighlight:"backgroundColor"},Q=e=>[J,...f(e)].map(e=>"styles"in e?e:{styles:e}),Z=e=>{const t={};for(const{icons:n}of Q(e))n&&Object.assign(t,n);return t},G=l({getStyles:()=>({}),icons:Z(J),cssVars:{}}),q=({theme:e=J,children:n})=>{const r=c(()=>(e=>{var t;const n=Q(e),r={},o={};for(const{fragments:e,styles:t}of n)for(const n in t){const a=n;for(const n of[].concat(t[a]))if("function"==typeof n)(o[a]??(o[a]=[])).push(n);else{const t="string"==typeof n?e?.[n]??n:n;r[a]={...r[a],..."string"==typeof t?{[X[a]??"color"]:t}:t}}}for(const e in o)r[t=e]??(r[t]={});const a={};for(const e in r){const t=e,n=r[t],i=o[t];a[t]=i?e=>i.reduce((t,n)=>({...t,...n(e)??{}}),n):n}return a})(e),[e]),o=c(()=>Z(e),[e]),a=c(()=>(e=>{const{inputHighlight:t,iconCopy:n}=e,r={};return"function"!=typeof t&&t?.backgroundColor&&(r["--jer-highlight-color"]=t.backgroundColor),"function"!=typeof n&&n?.color&&(r["--jer-icon-copy-color"]=n.color),r})(r),[r]),i=d((e,t)=>((e,t,n)=>{const r=e[t];return"function"==typeof r?r(n):r??{}})(r,e,t),[r]),l=c(()=>({getStyles:i,icons:o,cssVars:a}),[i,o,a]);return t(G.Provider,{value:l,children:n})},ee=()=>s(G),te={edit:{start:"startEdit",submit:"submitEdit",cancel:"cancelEdit",commit:"commitEdit"},add:{start:"startAdd",submit:"submitAdd",cancel:"cancelAdd",commit:"commitAdd"},rename:{start:"startRename",submit:"submitRename",cancel:"cancelRename",commit:"commitRename"},delete:{commit:"delete"},move:{commit:"move"}},ne=(e,t)=>te[e][t]??null,re=(e,t)=>null!==e&&null!==t&&e.op===t.op&&j(e.path,t.path),oe={active:null,settling:{}},ae=(e,t,n)=>{let r=oe;const o=new Set;let a=null,i=null,l=!1,s=0;const c=e=>{r=e,o.forEach(e=>e())},d=(t,n,r)=>{e.current?.({...t,...r,event:n})},u=(n,o,l)=>{if(!e.current)return;let s;try{s=t.current?.(n)}catch{return c({...r,active:null}),a=null,void(i=null)}s&&d(s,o,l)},p=(e,t)=>{var n;a=t?.cancelOp??null,i=t?.commitOp??null,n=e,re(r.active,n)&&r.active?.phase===n?.phase||c({...r,active:n});const o=ne(e.op,"start");o&&u(e.path,o)},h=(e,t,o,l,s,u,p,h,m)=>{const f=C(e);if(!p()){if("cancel"===l.status||"error"===l.status){"held"===r.active?.phase&&j(r.active.path,e)&&(c({...r,active:null}),a=null,i=null);const n=ne(t,"cancel");return n&&d(h,n),"error"===l.status&&d(h,"updateError",{operation:t,error:l.error}),l}s()}if(r.settling[f]===o){switch((e=>{if(!(e in r.settling))return;const t={...r.settling};delete t[e],c({...r,settling:t})})(f),l.status){case"cancel":u();break;case"error":u(),d(h,"updateError",{operation:t,error:l.error});break;case"override":n.current?.applyValue(l.path,l.value),d(h,"updateSuccess",{operation:t,...m});break;case"commit":d(h,"updateSuccess",{operation:t,...m})}return l}};return{subscribe:e=>(o.add(e),()=>o.delete(e)),getSnapshot:()=>r,getServerSnapshot:()=>r,open:(e,t)=>{if("held"===r.active?.phase)return;const n={path:e,op:t?.op??"edit",phase:"editing",force:t?.force},o=r.active,l=null!==o&&!re(o,n);if(l&&i)return void i(()=>p(n,t));const s=a;if(a=null,i=null,s&&s(),l&&re(r.active,o)){const e=ne(o.op,"cancel");e&&u(o.path,e)}p(n,t)},cancel:()=>{if(l)return;if("held"===r.active?.phase)return;const e=r.active;l=!0;try{const t=a;if(a=null,i=null,t&&t(),null!==e){null!==r.active&&c({...r,active:null});const t=ne(e.op,"cancel");t&&u(e.path,t)}}finally{l=!1}},submit:e=>{const{op:t,path:o,instant:l,onCommit:p}=e,m=n.current;let f;try{f=m?.buildCommit(e)??null}catch{return re(r.active,{path:o,op:t})&&c({...r,active:null}),a=null,i=null,p?.(),Promise.resolve(void 0)}const y=f?.extra,g=C(o),v=++s;if(!l){const e=ne(t,"submit");e&&u(o,e)}if(!f||f.isNoOp){re(r.active,{path:o,op:t})&&c({...r,active:null}),a=null,i=null;const e=ne(t,"commit");return e&&(f?d(f.nodeData,e,y):u(o,e,y)),p?.(),Promise.resolve(void 0)}const{input:b,nodeData:w,apply:E,revert:D}=f,j=!!m?.runUpdate;let S=!1,k=!1;const O=()=>{if(S)return;S=!0,E(),a=null,i=null,re(r.active,{path:o,op:t})&&c({...r,active:null}),j&&((e,t)=>{c({...r,settling:{...r.settling,[e]:t}})})(g,v);const e=ne(t,"commit");e&&d(w,e,y),p?.()},T={hold:()=>(k=!0,c({...r,active:{path:o,op:t,phase:"held",force:r.active?.force}}),()=>O())};if(!j)return O(),Promise.resolve(void 0);const N=m.runUpdate(b,T);let x;return k||(l?x=setTimeout(O,100):O()),N.then(e=>(clearTimeout(x),h(o,t,v,e,O,D,()=>S,w,y)))},areChildrenBeingEdited:e=>null!==r.active&&S(r.active.path,e)}},ie=l(null),le=({children:e,onEditEvent:n,buildNodeDataFromPathRef:r,commitRef:o})=>{const a=i(n);a.current=n;const l=i(null);return null===l.current&&(l.current=ae(a,r,o)),t(ie.Provider,{value:l.current,children:e})},se=()=>{const e=s(ie);if(!e)throw new Error("Missing Editing Context Provider");return e},ce=e=>{const t=se();return u(t.subscribe,()=>e(t.getSnapshot()),()=>e(t.getServerSnapshot()))},de=l(null),ue=({children:e,onCollapse:n,buildNodeDataFromPathRef:r})=>{const[o,a]=p({commands:null,version:0}),l=i(n);l.current=n;const s=d(e=>{if(null===e)return void a(e=>null===e.commands?e:{commands:null,version:e.version});const t=f(e),n=t.map(e=>({...e,path:[...e.path]}));a(e=>({commands:n,version:e.version+1}));const o=l.current;o&&t.forEach(e=>{const t=r.current?.(e.path);t&&o({...t,collapsed:e.collapsed,includeChildren:e.includeChildren})})},[r]),u=c(()=>({commands:o.commands,version:o.version,setCollapseState:s}),[o.commands,o.version,s]);return t(de.Provider,{value:u,children:e})},pe=()=>{const e=s(de);if(!e)throw new Error("Missing Collapse Context Provider");return e},he=(e,t)=>{if(!t.includeChildren)return t.path.length===e.length&&t.path.every((t,n)=>e[n]===t);for(const[n,r]of t.path.entries())if(r!==e[n])return!1;return!0},me=l(null),fe=({children:e})=>{const[n,r]=p({path:null}),o=i(!1),a=c(()=>({dragSource:n,setDragSource:r,armed:o}),[n]);return t(me.Provider,{value:a,children:e})},ye=({children:e,onEditEvent:n,onCollapse:r,buildNodeDataFromPathRef:o,commitRef:a})=>t(le,{onEditEvent:n,buildNodeDataFromPathRef:o,commitRef:a,children:t(ue,{onCollapse:r,buildNodeDataFromPathRef:o,children:t(fe,{children:e})})}),ge=l(void 0),ve=({value:e,children:n})=>t(ge.Provider,{value:e,children:n}),be=()=>{const e=s(ge);if(void 0===e)throw new Error("Missing FilterStateProvider");return e},we=e=>{const t=be();return null===t||t.visiblePaths.has(C(e))},Ee=e=>{const t=be();return null===t?null:t.visibleChildCounts.get(C(e))??null},De="**INVALID_FUNCTION**",Ce=({nodeData:r,showStringQuotes:o=!0,stringTruncateLength:a=200,pathString:i,canEdit:l,setIsEditing:s,styles:c,translate:d,value:u,TextWrapper:h=({children:e})=>e})=>{const m=u??r.value,[f,y]=p(!1),g=o?'"':"",v=m.length>a,b=()=>{l?s(!0):y(!f)};return e("div",{id:`${i}_display`,onDoubleClick:b,onClick:e=>{(e.getModifierState("Control")||e.getModifierState("Meta"))&&b()},className:"jer-value-string",style:c,children:[g,v?e(n,f?{children:[t(h,{children:e("span",{children:[m,g]})}),e("span",{className:"jer-string-expansion jer-show-less",onClick:()=>y(!1),children:[" ",d("SHOW_LESS",r)]})]}:{children:[e(h,{children:[t("span",{children:m.slice(0,a-2).trimEnd()})," "]}),t("span",{className:"jer-string-expansion jer-ellipsis",onClick:()=>y(!0),children:"..."}),g]}):t(h,{children:`${m}${g}`})]})},je=({styles:e,pathString:n,value:r,setValue:o,handleEdit:a,handleKeyboard:l,keyboardCommon:s})=>{const c=i(null);return t(_,{className:"jer-input-text",textAreaRef:c,name:n,value:r,setValue:o,onKeyDown:e=>{l(e,{stringConfirm:a,stringLineBreak:()=>{const e=Y(c,"\n");o(e)},...s})},styles:e})},Se=({isEditing:e,path:n,enumType:r,...o})=>{const{getStyles:a}=ee(),i=C(n),{value:l,setValue:s,nodeData:c,handleEdit:d,handleKeyboard:u,keyboardCommon:p,Select:h}=o;return e&&r?t(h,{name:`${i}-value-select`,value:l,onChange:s,options:r.values,autoFocus:!0,onKeyDown:e=>u(e,{stringConfirm:d,...p})}):e?t(je,{styles:a("input",c),pathString:i,...o,setValue:o.setValue}):t(Ce,{pathString:i,styles:a("string",c),...o})},ke=({value:e,setValue:n,isEditing:r,path:o,setIsEditing:a,handleEdit:i,nodeData:l,handleKeyboard:s,keyboardCommon:c})=>{const{getStyles:d}=ee();return r?t("input",{className:"jer-input-number",type:"text",name:C(o),value:e,onChange:e=>n(e.target.value.replace(/[^0-9.-]/g,"")),autoFocus:!0,onFocus:e=>setTimeout(()=>e.target.select(),10),onKeyDown:t=>s(t,{numberConfirm:i,numberUp:()=>n(Number(e)+1),numberDown:()=>n(Number(e)-1),...c}),style:{width:String(e).length/1.5+2+"em",...d("input",l)}}):t("span",{onDoubleClick:()=>a(!0),className:"jer-value-number",style:d("number",l),children:e})},Oe=({value:e,setValue:n,isEditing:r,path:o,setIsEditing:a,handleEdit:i,nodeData:l,handleKeyboard:s,keyboardCommon:c})=>{const{getStyles:d}=ee();return"boolean"!=typeof e?null:r?t("input",{className:"jer-input-boolean",type:"checkbox",name:C(o),checked:e,onChange:()=>n(!e),onKeyDown:t=>{" "===t.key&&t.preventDefault(),s(t,{booleanConfirm:i,booleanToggle:()=>n(!e),...c})},autoFocus:!0}):t("span",{onDoubleClick:()=>a(!0),className:"jer-value-boolean",style:d("boolean",l),children:String(e)})},Te=(e,t)=>{const n=i(void 0),r=i(t);a(()=>{r.current=t},[t]);const o=e=>{r.current(e)};a(()=>{if(window.clearTimeout(n.current),e)return n.current=window.setTimeout(()=>{window.addEventListener("keydown",o)},100),()=>{window.clearTimeout(n.current),window.removeEventListener("keydown",o)}},[e])},Ne=({value:e,isEditing:n,setIsEditing:r,handleEdit:o,nodeData:a,handleKeyboard:i,keyboardCommon:l})=>{const{getStyles:s}=ee();return Te(n,e=>i(e,{confirm:o,...l})),t("div",{onDoubleClick:()=>r(!0),className:"jer-value-null",style:s("null",a),children:String(e)})},xe=({value:e})=>{let n="Error!";switch(typeof e){case"string":e===De&&(n="Function");break;case"undefined":n="Undefined";break;case"symbol":n="Symbol"}return t("span",{className:"jer-value-invalid",children:n})},Re=({scale:e=1,viewBox:n="0 0 24 24",fill:r="currentColor",children:o,...a})=>{const i=1.4*e+"em";return t("svg",{viewBox:n,fill:r,width:i,height:i,...a,children:o})},Pe=({name:e,nodeData:n})=>{const{getStyles:r,icons:o}=ee(),a=o[e],i=`icon${e[0].toUpperCase()}${e.slice(1)}`;return t(Re,{viewBox:a.viewBox,...a.svgProps,scale:a.scale,className:"collection"===e?void 0:"jer-icon",style:r(i,n),children:a.content})},Ae=({startEdit:r,handleDelete:o,handleAdd:a,showClipboardButton:i,onCopy:l,type:s,customButtons:c,nodeData:d,translate:u,keyboardControls:h,handleKeyboard:m,editConfirmRef:f,getNewKeyOptions:y,jsonStringify:g,showIconTooltips:v,Select:b})=>{const{getStyles:w}=ee(),{open:E,cancel:C}=se(),S=u("KEY_NEW",d),[k,O]=p(S),[T,N]=p(!1),{path:x,value:R}=d,P=ce(e=>{const t=e.active;return null!==t&&"add"===t.op&&j(t.path,x)}),I=Array.isArray(T);L(()=>{if(!P)return N(!1),void O(S);const e=Object.keys(A(d.fullData,x)),t=y?y(d)?.filter(t=>!e.includes(t)):null;t&&O(""),N(t??!0)},[P]);const K=()=>{a&&(I&&!k||a("array"===s?"":k))};return e("div",{className:"jer-edit-buttons",style:{opacity:P?1:void 0},onClick:e=>e.stopPropagation(),children:[i&&t("button",{type:"button",tabIndex:-1,onClick:e=>{e.stopPropagation();let t,n,r="value",o="",a=null;if(i){const i=V(e);if(i&&h.clipboardModifier.includes(i)?(t=D(x),o=t,r="path"):(t=R,o="object"==typeof t?g(R):String(t)),!navigator.clipboard)return void l?.({...d,success:!1,stringValue:o,type:r,error:{code:"CLIPBOARD_ERROR",message:"Can't access clipboard API"}});navigator.clipboard?.writeText(o).then(()=>n=!0).catch(e=>{n=!1,a=e.message}).finally(()=>{l?.({...d,success:n,stringValue:o,type:r,error:n?void 0:{code:"CLIPBOARD_ERROR",message:a??"Copy failed"}})})}},className:"jer-copy-pulse","aria-label":u("TOOLTIP_COPY",d),title:v?u("TOOLTIP_COPY",d):"",children:t(Pe,{name:"copy",nodeData:d})}),r&&t("button",{type:"button",tabIndex:-1,onClick:r,"aria-label":u("TOOLTIP_EDIT",d),title:v?u("TOOLTIP_EDIT",d):"",children:t(Pe,{name:"edit",nodeData:d})}),o&&t("button",{type:"button",tabIndex:-1,onClick:o,"aria-label":u("TOOLTIP_DELETE",d),title:v?u("TOOLTIP_DELETE",d):"",children:t(Pe,{name:"delete",nodeData:d})}),a&&t("button",{type:"button",tabIndex:-1,onClick:()=>{"object"===s?E(x,{op:"add"}):a("")},"aria-label":u("TOOLTIP_ADD",d),title:v?u("TOOLTIP_ADD",d):"",children:t(Pe,{name:"add",nodeData:d})}),c?.map(({Element:e,onClick:n},r)=>t("div",{onClick:e=>n&&n(d,e),children:t(e,{nodeData:d})},r)),P&&a&&"object"===s&&e(n,{children:[I?t(b,{name:"new-key-select",onChange:a,defaultValue:"",autoFocus:!0,onKeyDown:e=>m(e,{cancel:()=>C()}),placeholder:T.length>0?u("KEY_SELECT",d):u("NO_KEY_OPTIONS",d),options:T}):t("input",{className:"jer-input-new-key",type:"text",name:"new-object-key",value:k,onChange:e=>O(e.target.value),autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>{m(e,{stringConfirm:()=>K(),cancel:()=>C()})},style:w("input",d)}),t(Ie,{onOk:()=>K(),onCancel:()=>C(),nodeData:d,translate:u,showIconTooltips:v,editConfirmRef:f,hideOk:I})]})]})},Ie=({onOk:n,onCancel:r,nodeData:o,translate:a,showIconTooltips:i,editConfirmRef:l,hideOk:s=!1})=>e("div",{className:"jer-confirm-buttons",children:[!s&&t("button",{type:"button",tabIndex:-1,onClick:n,"aria-label":a("TOOLTIP_OK",o),title:i?a("TOOLTIP_OK",o):"",ref:l,children:t(Pe,{name:"ok",nodeData:o})}),t("button",{type:"button",tabIndex:-1,onClick:r,"aria-label":a("TOOLTIP_CANCEL",o),title:i?a("TOOLTIP_CANCEL",o):"",children:t(Pe,{name:"cancel",nodeData:o})})]}),Ke=["string","number","boolean","null"],Le=["object","array"],_e=[...Ke,...Le],Ve=e=>{const{component:t,wrapperComponent:n,keyComponent:r,showKey:o=!0,showEditTools:a=!0,showOnEdit:i=!1,showOnView:l=!0,showCollectionWrapper:s=!0,...c}=e;return{CustomComponent:t,CustomWrapperComponent:n,CustomKeyComponent:r,showKey:o,showEditTools:a,showOnEdit:i,showOnView:l,showCollectionWrapper:s,...c}},Me=(e=[],t)=>{const n=e.find(({condition:e})=>e(t));return n?Ve(n):{}},ze=({props:e,collapsed:t})=>{const{nodeData:n,parentData:r,onError:o,getLatestData:a,showErrorMessages:l,allowEditFilter:s,allowDeleteFilter:c,allowAddFilter:u,allowDragFilter:h,translate:m,errorDisplayTime:f,sort:y,arrayIndexStart:g,handleKeyboard:v,customNodeData:b}=e,{submit:w}=se(),[E,D]=p(null),S={...n,collapsed:t,visibleSize:Ee(n.path)},{path:k,key:O,size:T}=S,N=C(k),x=ce(e=>{const t=e.active;return null!==t&&"edit"===t.op&&j(t.path,k)}),R=ce(e=>{const t=e.active;return null!==t&&"rename"===t.op&&j(t.path,k)}),P=ce(e=>N in e.settling),A=s(S),I=c(S),K=u(S),L=h(S)&&I,_=e=>{l&&(D(e),setTimeout(()=>D(null),f)),console.warn("Error",e)},V=i(S);V.current=S;const M=d((e,t)=>{_(e.message),o&&o({...V.current,fullData:a(),error:e,errorValue:t})},[o,l,a,f]),z=be(),F=d(e=>(null===z||z.visiblePaths.has(C(e.path)))&&s(e),[z,s]),B=e=>U(a(),k,e,y,F),Y=(e,t)=>{r&&(O!==e&&Object.keys(r).includes(e)?M({code:"KEY_EXISTS",message:m("ERROR_KEY_EXISTS",S)},e):w({op:"rename",path:k,newKey:e,onCommit:t}).then(t=>{"error"===t?.status&&M(t.error,e)}))},W="number"==typeof k.slice(-1)[0],$=null!==r&&A&&K&&I&&!W,H={isEditing:x,isEditingKey:R,isPending:P,isArray:W,canEditKey:$},J=""===O&&k.length>0?m("EMPTY_STRING",S):null;return{pathString:N,nodeData:S,path:k,name:O,size:T,canEdit:A,canDelete:I,canAdd:K,canDrag:L,error:E,showError:_,onError:M,setError:D,handleEditKey:Y,derivedValues:H,emptyStringKey:J,getNextOrPreviousAtPath:B,buildKeyDisplayProps:({handleCancel:e,getStyles:t,keyValueArray:n,handleClick:r})=>({canEditKey:$,isEditingKey:R,pathString:N,path:k,name:O,arrayIndexStart:g,handleKeyboard:v,handleEditKey:Y,handleCancel:e,styles:t("property",S),getNextOrPrevious:B,emptyStringKey:J,nodeData:S,customNodeData:b,getStyles:t,...void 0!==n?{keyValueArray:n}:{},...void 0!==r?{handleClick:r}:{}})}},Fe=({canDrag:e,canDragOnto:n,path:r,nodeData:o,onError:a,translate:i})=>{const{getStyles:l}=ee(),{dragSource:d,setDragSource:u,armed:h}=(()=>{const e=s(me);if(!e)throw new Error("Missing DragSource Context Provider");return e})(),m=se(),[f,y]=p(!1),g=c(()=>e?{onMouseDown:e=>{0===e.button&&null===m.getSnapshot().active&&(h.current=!0)},onMouseUp:()=>{h.current=!1},onDragStart:e=>{if(!h.current||null!==m.getSnapshot().active)return e.preventDefault(),void e.stopPropagation();h.current=!1,e.stopPropagation(),u({path:r})},onDragEnd:e=>{h.current=!1,e.stopPropagation(),u({path:null})}}:{},[e,r]),v=c(()=>e=>n?{onDragOver:e=>{e.stopPropagation(),e.preventDefault()},onDrop:t=>{t.stopPropagation(),w(e),u({path:null}),y(!1)},onDragEnter:t=>{t.stopPropagation(),null!==d.path&&S(r,d.path)||y(e)},onDragExit:e=>{e.stopPropagation(),y(!1)}}:{},[d,n,r]),b=c(()=>n&&null!==d.path?t("div",{className:"jer-drop-target-bottom",style:{height:"50%",position:"absolute",width:"100%",top:"50%",zIndex:r.length},...v("below")}):null,[d,n,r.length]),w=e=>{if(null===d.path)return;if(S(r,d.path))return;const t=d.path.slice(-1)[0],n=d.path.slice(0,-1),l=r.slice(0,-1),{parentData:s}=o;"string"==typeof t&&s&&!Array.isArray(s)&&Object.keys(s).includes(t)&&t in s&&!j(n,l)?a({code:"KEY_EXISTS",message:i("ERROR_KEY_EXISTS",o)},t):m.submit({op:"move",path:d.path,to:{path:r,position:e},instant:!0})};return{dragSourceProps:g,getDropTargetProps:v,BottomDropTarget:b,DropTargetPadding:({position:e,nodeData:n})=>f===e?t("div",{className:"jer-drag-n-drop-padding",style:l("dropZone",n)}):null,handleDrop:w}},Be=(e,t,n,r)=>{if(!t.current)return 0;const o=parseInt(getComputedStyle(n.current).getPropertyValue("line-height"))||16,a=(t.current?.offsetWidth??0)/(.5*o),i=r(e).replace(/\\n/g,"\n").split("\n").map(e=>Math.ceil(e.length/a)).reduce((e,t)=>e+t,0)*o;return Math.min(i+30,window.innerHeight-50)},Ye=({isEditingKey:n,canEditKey:o,pathString:a,path:i,name:l,arrayIndexStart:s,handleKeyboard:c,handleEditKey:d,handleCancel:u,handleClick:p,keyValueArray:h,styles:m,getNextOrPrevious:f,emptyStringKey:y,nodeData:g,customNodeData:v,getStyles:b})=>{const{open:w,cancel:E}=se(),D=r.useRef(null),C=e=>d(D.current?.value??String(l),e),j="number"==typeof l?String(l+s):l;if(!n){const n={...m,minWidth:`${Math.min(j.length+1,5)}ch`,flexShrink:j.length>10?1:0};if(v?.CustomKeyComponent&&g&&b){const{CustomKeyComponent:e,componentProps:r}=v;return t(e,{nodeData:g,name:y??j,path:i,canEditKey:o,handleEditKey:e=>{o&&d(e)},startEditingKey:()=>{o&&w(i,{op:"rename",commitOp:C})},handleClick:p,styles:n,componentProps:r,getStyles:b})}return e("span",{className:"jer-key-text",style:n,onDoubleClick:()=>o&&w(i,{op:"rename",commitOp:C}),onClick:p,children:[y?t("span",{className:"jer-empty-string",children:y}):j,""!==j||y?t("span",{className:"jer-key-colon",children:":"}):null]})}return t("input",{ref:D,className:"jer-input-text jer-key-edit",type:"text",name:a,defaultValue:j,autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>c(e,{stringConfirm:()=>d(e.target.value),cancel:u,tabForward:()=>{const t=e.target.value;d(t,()=>{if(h){const e=h?.[0][0],t=e?[...i,e]:f("next");t?w(t):E()}else w(i)})},tabBack:()=>{const t=e.target.value;d(t,()=>{const e=f("prev");e?w(e):E()})}}),style:{width:j.length/1.5+.5+"em"}})},Ue=new Set(["nodeData","customNodeData"]),We=(e,t)=>{if(n=e.nodeData,r=t.nodeData,n.key!==r.key||n.index!==r.index||n.level!==r.level||n.size!==r.size||!j(n.path,r.path))return!1;var n,r;const o=Object.keys(t);if(o.length!==Object.keys(e).length)return!1;for(const n of o)if(!Ue.has(n)&&!Object.is(e[n],t[n]))return!1;return!0},$e=r.memo(n=>{const{data:r,parentData:o,onChange:l,showClipboardButton:s,onCopy:u,canDragOnto:h,allowTypeSelection:f,showLabel:y,stringTruncateLength:g,showStringQuotes:b,indent:w,translate:E,customNodeDefinitions:D,customNodeData:C,Select:S,handleKeyboard:k,keyboardControls:O,editConfirmRef:T,jsonStringify:N,showIconTooltips:x,getLatestData:R}=n,{getStyles:P}=ee(),{open:A,cancel:I,submit:K,getSnapshot:L}=se(),{setCollapseState:_}=pe(),[V,M]=p("function"==typeof r?De:r),{nodeData:z,path:F,name:B,canEdit:Y,canDelete:U,canDrag:W,error:$,onError:H,setError:J,derivedValues:X,getNextOrPreviousAtPath:Q,buildKeyDisplayProps:Z}=ze({props:n}),{dragSourceProps:G,getDropTargetProps:q,BottomDropTarget:te,DropTargetPadding:ne}=Fe({canDrag:W,canDragOnto:h,path:F,nodeData:z,onError:H,translate:E}),[re,oe]=p(Je(r,C)),ae=i(V);ae.current=V;const ie=i(z);ie.current=z;const le=d(e=>{if(!l)return void M(e);const t=l({...ie.current,value:ae.current,fullData:R(),newValue:e});M(t)},[l,R]),ce=()=>{M("function"==typeof r?De:r),oe(Je(r,C)),he(v(r,de))};a(()=>{X.isEditing||ce()},[r]);const de=c(()=>{const e=[..._e,...D.filter(({showInTypeSelector:e=!1,name:t})=>e&&!!t).map(({name:e})=>e)];if("boolean"==typeof f)return f?e:[];if(Array.isArray(f))return f;const t=f(z);return"boolean"==typeof t?t?e:[]:t},[z,f,D]),[ue,he]=p(v(V,de)),{isEditing:me,isPending:fe}=X,ye=we(F),ge=i(m);if(!ye)return null;const ve=me&&re!==Je(r,C),be=ve?D.find(e=>e.name===re&&He(e)):void 0,Ee=be?Ve(be):C,{CustomComponent:Ce,componentProps:je,showKey:Se=!0,showEditTools:ke=!0,showOnEdit:Oe,showOnView:Te,passOriginalNode:Ne}=Ee,xe=Ce&&(void 0!==be||!ve&&(me&&Oe||!me&&Te)),Re=e=>{_(null);const t=ve&&!be?void 0:Ee,n=t?.toStandardType?t.toStandardType(V):V,r=D.find(t=>t.name===e);if(r){if(He(r)){let t=r.defaultValue;if(r.fromStandardType)try{t=r.fromStandardType(n,z,r.componentProps)}catch{}return M(t),oe(e),void he(null)}return K({op:"edit",path:F,value:r.defaultValue}).then(Pe(r.defaultValue)),void _({path:F,collapsed:!1,includeChildren:!1})}const o=de.find(t=>t instanceof Object&&t.enum===e);if(o)return"string"==typeof V&&o.values.includes(V)||M(o.values[0]),he(o),void oe(e);const a=Ze(n,e,E("DEFAULT_NEW_KEY",z));if("object"===e||"array"===e||"null"===e)return K({op:"edit",path:F,value:a}).then(Pe(a)),void("null"!==e&&_({path:F,collapsed:!1,includeChildren:!1}));M(a),oe(e),he(null)},Pe=e=>t=>{if("error"===t?.status&&H(t.error,e),"error"===t?.status||"cancel"===t?.status){const e=L().active;"editing"===e?.phase&&j(e.path,F)||ce()}},Ke=(e,t)=>{const n=void 0!==e&&!(e=>e&&"object"==typeof e&&"type"in e&&"target"in e&&"preventDefault"in e&&"function"==typeof e.preventDefault)(e);let r;if(n)r=e;else if(xe&&Ee.fromStandardType)try{r=Ee.fromStandardType(V,z,Ee.componentProps)}catch(e){return void H({code:"UPDATE_ERROR",message:e instanceof Error?e.message:String(e)},V)}else r="number"===re?Qe(V):V;J(null),be&&_({path:F,collapsed:!1,includeChildren:!1}),K({op:"edit",path:F,value:r,onCommit:t}).then(Pe(r))};ge.current=Ke;const Le=()=>{J(null),ce(),I()},{isEditingKey:Me}=X,Be=!!$,Ue=me&&de.length>1,We=("invalid"!==re||Ce)&&!$&&ke,$e=y&&Se,Ge=()=>A(F,{cancelOp:ce,commitOp:e=>ge.current(void 0,e)}),qe=Y?Ge:m,et=e=>()=>{const t=Q(e);t&&Ke(void 0,()=>A(t))},tt={value:V,parentData:o,setValue:le,isEditing:me,canEdit:Y,setIsEditing:qe,handleEdit:Ke,handleCancel:Le,path:F,stringTruncateLength:g,showStringQuotes:b,nodeData:z,enumType:ue,translate:E,handleKeyboard:k,keyboardCommon:{cancel:Le,tabForward:et("next"),tabBack:et("prev")},Select:S},nt={...Z({handleCancel:Le,getStyles:P}),customNodeData:Ee},rt=xe?t(Ce,{...n,value:V,componentProps:je,setValue:le,handleEdit:Ke,handleCancel:Le,onKeyDown:e=>k(e,{stringConfirm:Ke,cancel:Le}),isEditing:me,isPending:fe,setIsEditing:qe,getStyles:P,originalNode:Ne?Xe(r,re,tt):void 0,originalNodeKey:Ne?t(Ye,{...nt,customNodeData:void 0}):void 0,canEdit:Y,keyboardCommon:tt.keyboardCommon}):Xe(r,re,tt);return e("div",{className:"jer-component jer-value-component",style:{marginLeft:null!==o?w/2+"em":0,position:"relative"},draggable:W&&!me&&!Me,...G,...q("above"),children:[te,t(ne,{position:"above",nodeData:z}),e("div",{className:"jer-value-main-row",style:{...P("valueRow",z),flexWrap:B.length>10?"wrap":"nowrap"},children:[$e&&t(Ye,{...nt}),e("div",{className:"jer-value-and-buttons",children:[t("div",{className:"jer-input-component",children:rt}),me?t(Ie,{onOk:Ke,onCancel:Le,nodeData:z,translate:E,showIconTooltips:x,editConfirmRef:T}):We&&t(Ae,{startEdit:Y?Ge:void 0,handleDelete:U?()=>{K({op:"delete",path:F,instant:!0}).then(e=>{"error"===e?.status&&H(e.error,V)})}:void 0,showClipboardButton:s,onCopy:u,translate:E,customButtons:n.customButtons,nodeData:z,handleKeyboard:k,keyboardControls:O,editConfirmRef:T,jsonStringify:N,showIconTooltips:x,Select:S}),Ue&&t(S,{name:`${B}-type-select`,value:ue?ue.enum:re,onChange:e=>Re(e),options:de.map(e=>e instanceof Object&&"enum"in e?e.enum:e)}),Be&&t("span",{className:"jer-error-slug",style:P("error",z),children:$})]})]}),t(ne,{position:"below",nodeData:z})]})},We),He=e=>!!e.editOnTypeSwitch&&!!e.component&&!!e.showOnEdit,Je=(e,t)=>t?.CustomComponent&&t?.name&&t.showInTypeSelector?t.name:"string"==typeof e?"string":"number"==typeof e?"number":"boolean"==typeof e?"boolean":null===e?"null":"invalid",Xe=(e,n,r)=>{const o=Ke.includes(n)?n:"function"==typeof e?"invalid":Je(r.value),{value:a}=r;switch(o){case"string":return t(Se,{...r,value:a});case"number":return t(ke,{...r,value:a});case"boolean":return t(Oe,{...r,value:a});case"null":return t(Ne,{...r});default:return t(xe,{...r})}},Qe=e=>{if("symbol"==typeof e)return 0;const t=Number(e);return isNaN(t)?0:t},Ze=(e,t,n)=>{switch(t){case"string":return null==e?"":String(e);case"number":return Qe(e);case"boolean":return!!e;case"null":return null;case"object":return{[n]:e};case"array":return[e];default:return String(e)}},Ge=r.memo(r=>{const{getStyles:o}=ee(),{open:l,cancel:s,submit:u,areChildrenBeingEdited:h}=se(),{setCollapseState:f}=pe(),{mainContainerRef:g,data:v,nodeData:b,parentData:w,showCollectionCount:E,canDragOnto:D,collapseFilter:C,collapseAnimationTime:j,showClipboardButton:k,onCopy:O,showIconTooltips:T,indent:N,sort:x,showArrayIndexes:R,defaultValue:P,newKeyOptions:A,translate:I,customNodeDefinitions:K,customNodeData:L,jsonParse:M,jsonStringify:z,TextEditor:F,Select:B,keyboardControls:U,handleKeyboard:W,insertAtTop:$,onCollapse:H,editConfirmRef:J,collapseClickZones:X,getLatestData:Q}=r,[Z,G]=p(null),q=C(b),{contentRef:te,isAnimating:ne,maxHeight:re,collapsed:oe,animateCollapse:ae,cssTransitionValue:ie}=((e,t,n,r,o)=>{const[a,l]=p(n?0:void 0),[s,c]=p(n),u=i(!1),h=i(null),m=i(0),f=i(0),y=t/1e3+"s",g=d(n=>{if(s!==n){switch(window.clearTimeout(f.current),u.current=!0,n){case!0:{const e=h.current?.offsetHeight??0;m.current=e,l(e),setTimeout(()=>{l(0)},5);break}case!1:l(m.current||Be(e,h,r,o))}c(!s),f.current=window.setTimeout(()=>{u.current=!1,n||l(void 0)},t)}},[t,s,e,r,o]);return{contentRef:h,isAnimating:u.current,animateCollapse:g,maxHeight:a,collapsed:s,cssTransitionValue:y}})(v,j,q,g,z),{pathString:le,nodeData:de,path:ue,name:me,size:fe,canEdit:ye,canDelete:ge,canAdd:ve,canDrag:be,error:Ee,setError:De,onError:Ce,derivedValues:je,buildKeyDisplayProps:Se}=ze({props:r,collapsed:oe}),{dragSourceProps:ke,getDropTargetProps:Oe,BottomDropTarget:Te,DropTargetPadding:Ne}=Fe({canDrag:be,canDragOnto:D,path:ue,nodeData:de,onError:Ce,translate:I}),xe=i(!q),{isEditing:Re,isEditingKey:Ke,isPending:Le,isArray:_e}=je,Ve=(e=>{const t=i(e),n=!Object.is(t.current,e);return a(()=>{t.current=e}),n})(C);a(()=>{const e=C(de)&&!Re;xe.current=!e,ae(e),Ve&&f(null)},[C]),((e,t,n)=>{const{commands:r,version:o}=pe(),l=i(0);a(()=>{if(o===l.current)return;if(l.current=o,!r)return;let a;for(const t of r)he(e,t)&&(a=t);a&&(a.collapsed||(t.current=!0),n(a.collapsed))},[o,r])})(ue,xe,ae);const Ue=i(null),We=d(e=>G(t=>"function"==typeof e?e(t??z(v)):e),[v,z]),He=d(()=>G(null),[]),Je=c(()=>Re?Z??z(v):null,[Re,Z,v,z]),Xe=d((e,t)=>{if("function"!=typeof P)return P;const n=P(e,t);return void 0!==n?n:null},[P]),Qe=d(e=>A?"function"!=typeof A?A:A(e):null,[A]),{CustomComponent:Ze,componentProps:qe,CustomWrapperComponent:et,wrapperProps:tt={},showKey:nt=!0,showEditTools:rt=!0,showOnEdit:ot,showOnView:at,showCollectionWrapper:it=!0}=L,lt=ce(e=>null!==e.active&&S(e.active.path,ue));lt&&oe&&ae(!1);const st=we(ue)||0===de.level,ct=i(m);if(!st&&!lt)return null;const{visibleSize:dt}=de,ut=Array.isArray(v)?"array":"object",pt="array"===ut?{open:"[",close:"]"}:{open:"{",close:"}"},ht=e=>{if("Tab"===e.key&&!e.getModifierState("Shift")){e.preventDefault();const t=Y(Ue,"\t");return void G(t)}W(e,{objectConfirm:ft,cancel:gt})},mt=e=>{e.stopPropagation();const t=V(e);if(t&&U.collapseModifier.includes(t))return xe.current=!0,void f({collapsed:!oe,path:ue,includeChildren:!0});h(ue)||(xe.current=!0,H&&H({...de,fullData:Q(),collapsed:!oe,includeChildren:!1}),ae(!oe))},ft=e=>{const t=Je??z(v);let n;try{n=M(t)}catch{return void Ce({code:"INVALID_JSON",message:I("ERROR_INVALID_JSON",de)},t)}De(null);const r="function"==typeof e?e:void 0;u({op:"edit",path:ue,value:n,onCommit:()=>{He(),r?.()}}).then(e=>{"error"===e?.status&&Ce(e.error,n)})};ct.current=ft;const yt=ue.length>0?()=>{u({op:"delete",path:ue,instant:!0}).then(e=>{"error"===e?.status&&Ce(e.error,v)})}:void 0,gt=()=>{s(),De(null),He()},vt="when-collapsed"===E?oe:"when-collapsed-or-filtered"===E?oe||null!=dt:E,bt=!Re&&rt,wt=(R||!_e)&&nt&&void 0!==me,Et=Ze&&(Re&&ot||!Re&&at),Dt=Object.entries(v).map(([e,t])=>["array"===ut?Number(e):e,t]);"object"===ut&&x(Dt,e=>e);const Ct=xe.current?Re?e("div",{className:"jer-collection-text-edit"+(F?"-custom":""),children:[F?t(F,{value:Je??"",onChange:G,onKeyDown:e=>W(e,{objectConfirm:ft,cancel:gt})}):t(_,{textAreaRef:Ue,className:"jer-collection-text-area",name:le,value:Je??"",setValue:We,onKeyDown:ht,styles:o("input",de)}),t("div",{className:"jer-collection-input-button-row",children:t(Ie,{onOk:ft,onCancel:gt,nodeData:de,translate:I,showIconTooltips:T,editConfirmRef:J})})]}):Dt.map(([e,n],a)=>{const i={key:e,value:n,path:[...ue,e],level:ue.length+1,index:a,size:y(n)?Object.keys(n).length:null,parentData:v,fullData:de.fullData},l=Me(K,i);return t("div",{className:"jer-collection-element",style:o("collectionElement",i),children:y(n)&&!l?.renderCollectionAsValue?t(Ge,{...r,data:n,parentData:v,nodeData:i,canDragOnto:ye,customNodeData:l},e):t($e,{...r,data:n,parentData:v,nodeData:i,canDragOnto:ye,showLabel:"object"===ut||R,customNodeData:l},e)},e)}):null,jt=!!it&&(oe&&!lt);jt||(xe.current=!0);const St=()=>({...r,data:v,value:v,parentData:w,nodeData:de,setValue:e=>u({op:"edit",path:ue,value:e}),handleEdit:ft,handleCancel:gt,onKeyDown:ht,isEditing:Re,isPending:Le,setIsEditing:ye?()=>l(ue,{cancelOp:He,commitOp:e=>ct.current(e)}):m,getStyles:o,canDragOnto:ye,canEdit:ye,keyboardCommon:{}}),kt=Et?t(Ze,{componentProps:qe,...St(),children:Ct}):Ct,Ot=bt&&t(Ae,{startEdit:ye?()=>{xe.current=!0,l(ue,{cancelOp:He,commitOp:e=>ct.current(e)})}:void 0,handleAdd:ve?e=>{f(null),ae(!1);const t=Xe(de,e);if("array"===ut){const e=$.array?0:v.length,n=$.array?{insert:!0}:{};return void u({op:"add",path:ue,key:e,value:t,options:n,instant:!0}).then(e=>{"error"===e?.status&&Ce(e.error,t)})}if(e in v)return Ce({code:"KEY_EXISTS",message:I("ERROR_KEY_EXISTS",de)},e),void s();const n=$.object?{insertBefore:0}:{};u({op:"add",path:ue,key:e,value:t,options:n}).then(e=>{"error"===e?.status&&Ce(e.error,t)})}:void 0,handleDelete:ge?yt:void 0,showClipboardButton:k,onCopy:O,type:ut,nodeData:de,translate:I,customButtons:r.customButtons,keyboardControls:U,handleKeyboard:W,getNewKeyOptions:Qe,editConfirmRef:J,jsonStringify:z,showIconTooltips:T,Select:B}),Tt=Se({handleCancel:gt,getStyles:o,keyValueArray:Dt,handleClick:X.includes("property")?mt:e=>e.stopPropagation()}),Nt=e("div",{className:"jer-component jer-collection-component",style:{marginLeft:(0===ue.length?0:N/2)+"em",...o("collection",de),position:"relative"},draggable:be&&!Re&&!Ke&&!lt,...ke,...Oe("above"),children:[t("div",{className:"jer-clickzone",style:{width:N/2+1+"em",zIndex:10+2*de.level},onClick:X.includes("left")?mt:void 0}),!Re&&Te,t(Ne,{position:"above",nodeData:de}),it?e("div",{className:"jer-collection-header-row",style:{...o("headerRow",de),position:"relative"},onClick:X.includes("header")?mt:void 0,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*de.level,transition:ie},onClick:mt,children:t(Pe,{name:"collection",nodeData:de})}),wt&&t(Ye,{...Tt}),!Re&&t("span",{className:"jer-brackets jer-bracket-open",style:o("bracket",de),children:pt.open})]}),!1!==E&&!Re&&t("div",{className:"jer-collection-item-count"+(vt?" jer-visible":" jer-hidden"),style:{...o("itemCount",de),transition:ie,transitionBehavior:"allow-discrete"},children:null!=dt&&dt!==fe?I("ITEMS_FILTERED",de,{visible:dt,total:fe}):1===fe?I("ITEM_SINGLE",{...de,size:1},1):I("ITEMS_MULTIPLE",de,fe)}),t("div",{className:"jer-brackets"+(jt?" jer-visible":" jer-hidden"),style:{...o("bracket",de),transition:ie},children:pt.close}),Ot]}):nt?e("div",{className:"jer-collection-header-row",style:{...o("headerRow",de),position:"relative"},children:[t(Ye,{...Tt}),Ot]}):t(n,{}),e("div",{className:"jer-collection-inner",style:{overflowY:jt||ne?"clip":"visible",maxHeight:lt?void 0:re,transition:ie},ref:te,children:[kt,t("div",{className:Re?"jer-collection-error-row-edit":"jer-collection-error-row",children:Ee&&t("span",{className:"jer-error-slug",style:o("error",de),children:Ee})}),!Re&&it&&t("div",{className:"jer-brackets jer-bracket-outside",style:o("bracket",de),children:pt.close})]}),t(Ne,{position:"below",nodeData:de})]});return et?t(et,{wrapperProps:tt,...St(),children:Nt}):Nt},We),qe=({options:n,value:r,defaultValue:o,onChange:a,placeholder:i,className:l,...s})=>e("div",{className:"jer-select",children:[e("select",{className:l??"jer-select-inner",onChange:e=>a(e.target.value),...s,...void 0!==r?{value:r}:{defaultValue:o??""},children:[void 0!==i&&t("option",{value:"",disabled:!0,children:i}),n.map(e=>t("option",{value:e,children:e},e))]}),t("span",{className:"focus"})]}),et=(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}},tt=({key:e,path:t},n="")=>!!et({value:e},n)||!!t.some(e=>et({value:e},n)),nt={ITEM_SINGLE:"{{count}} item",ITEMS_MULTIPLE:"{{count}} items",ITEMS_FILTERED:"{{visible}} of {{total}} items",KEY_NEW:"Enter new key",KEY_SELECT:"Select key",NO_KEY_OPTIONS:"No key options",ERROR_KEY_EXISTS:"Key already exists",ERROR_INVALID_JSON:"Invalid JSON",ERROR_UPDATE:"Update unsuccessful",ERROR_DELETE:"Delete unsuccessful",ERROR_ADD:"Adding node unsuccessful",ERROR_RENAME:"Rename unsuccessful",ERROR_MOVE:"Move unsuccessful",DEFAULT_NEW_KEY:"key",SHOW_LESS:"(Show less)",EMPTY_STRING:"<empty string>",TOOLTIP_COPY:"Copy to clipboard",TOOLTIP_EDIT:"Edit",TOOLTIP_DELETE:"Delete",TOOLTIP_ADD:"Add",TOOLTIP_OK:"OK",TOOLTIP_CANCEL:"Cancel"},rt=(e,t)=>(n,r,o)=>((e,t,n,r,o)=>{if(t[r]){const e=t[r](n);if(null!==e)return e}let a=r in e?e[r]:nt[r];if(void 0!==o){const e=g(o)?o:{count:o};for(const[t,n]of Object.entries(e))a=a?.replace(`{{${t}}}`,String(n))}return a})(e,t,r,n,o);var ot=[],at=[];!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=ot.indexOf(a);-1===i&&(i=ot.push(a)-1,at[i]={}),n=at[i]&&at[i][r]?at[i][r]:at[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}}(':host,:root{--jer-select-border:#b6b6b6;--jer-select-focus:#777;--jer-select-arrow:#777;--jer-form-border:1px solid #ededf0;--jer-form-border-focus:1px solid #e2e2e2;--jer-highlight-color:#b3d8ff;--jer-icon-copy-color:#268bd2}.jer-visible{opacity:1}.jer-hidden{opacity:0}.jer-select select{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:transparent;border:none;color:#000;cursor:inherit;font-family:inherit;font-size:.8em;line-height:inherit;margin:0;outline:none;padding:0 1em 0 0;z-index:1}select::-ms-expand{display:none}.jer-select{align-items:center;background-color:#fff;background-image:linear-gradient(0deg,#f9f9f9,#fff 33%);border:1px solid var(--jer-select-border);border-radius:.25em;cursor:pointer;display:grid;grid-template-areas:"select";line-height:1.1;max-width:15ch;min-width:12ch;padding:.25em .5em;position:relative}.jer-select select,.jer-select:after{grid-area:select}.jer-select:not(.jer-select--multiple):after{background-color:var(--jer-select-arrow);clip-path:polygon(100% 0,0 0,50% 100%);content:"";height:.5em;justify-self:end;width:.8em}select:focus+.focus{border:1px solid var(--jer-select-focus);border-radius:inherit;bottom:-1px;left:-1px;position:absolute;right:-1px;top:-1px}.jer-select-inner{text-overflow:ellipsis;width:100%}.jer-editor-container{border-radius:.5em;font-size:16px;line-height:1;padding:1em 1em 1em 2em;position:relative;text-align:left}.jer-editor-container textarea{border:var(--jer-form-border);border-radius:.3em;color:var(--jer-input-color);outline:none}.jer-editor-container textarea:focus{border:var(--jer-form-border-focus)}.jer-editor-container input{border:var(--jer-form-border);border-radius:.3em;font-family:inherit;outline:none}.jer-editor-container input:focus{border:var(--jer-form-border-focus)}.jer-editor-container ::selection{background-color:var(--jer-highlight-color)}.jer-collection-header-row,.jer-value-main-row{align-items:center;display:flex;gap:.3em;min-height:1.7em}.jer-collection-header-row{flex-wrap:wrap}.jer-value-main-row{gap:0}.jer-bracket-outside{padding-left:0}.jer-collection-item-count{display:none}.jer-collection-item-count.jer-visible{display:block}@starting-style{.jer-collection-item-count.jer-visible{opacity:0}}.jer-collapse-icon{left:-1.2em;position:absolute;top:50%;transform:translateY(-50%)}.jer-collapse-icon.jer-rotate-90{transform:translateY(-50%) rotate(-90deg)}.jer-collection-inner{position:relative}.jer-collection-text-edit,.jer-collection-text-edit-custom{align-items:flex-start;display:flex;flex-direction:column;gap:.3em;line-height:1.1em}.jer-collection-text-edit{width:fit-content}.jer-collection-text-area{box-sizing:content-box;font-family:inherit;font-size:.85em;line-height:1.25em;max-height:40em;overflow:hidden;padding:.2em .5em 0;resize:both}.jer-collection-input-button-row{display:flex;font-size:150%;justify-content:flex-end;margin-top:.4em;width:100%}.jer-collection-error-row-edit{bottom:.5em;position:absolute}.jer-error-slug{margin-left:1em}.jer-value-component{position:relative}.jer-value-and-buttons{align-items:center;display:flex;justify-content:flex-start;padding-left:.5em}.jer-value-error-row{position:absolute}.jer-value-string{line-height:1.3em;overflow-wrap:anywhere;white-space:pre-wrap;word-break:break-word}.jer-string-expansion{cursor:pointer;filter:saturate(50%);opacity:.6}.jer-show-less{font-size:80%}.jer-hyperlink{text-decoration:underline}.jer-input-text{box-sizing:content-box;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;margin-right:.2em}.jer-confirm-buttons>button,.jer-edit-buttons>button{appearance:none;background:none;border:none;color:inherit;font:inherit;margin:0;padding:0}.jer-input-buttons{gap:.4em}.jer-edit-buttons{gap:.4em;margin-left:.5em;opacity:0}.jer-confirm-buttons{gap:.2em;margin-left:.4em}.jer-edit-buttons:hover{opacity:1;position:relative}.jer-collection-header-row:hover>.jer-edit-buttons,.jer-value-and-buttons:hover>.jer-edit-buttons,.jer-value-main-row:hover>.jer-edit-buttons{opacity:1}.jer-copy-pulse{position:relative;transition:.3s}.jer-copy-pulse:hover{opacity:.85;transform:scale(1.2);transition:.3s}.jer-copy-pulse:after{border-radius:50%;box-shadow:0 0 15px 5px var(--jer-icon-copy-color);content:"";display:block;height:100%;left:0;opacity:0;position:absolute;top:0;transition:all .5s;width:100%}.jer-copy-pulse:active:after{border-radius:4em;box-shadow:0 0 0 0 var(--jer-icon-copy-color);left:0;opacity:1;position:absolute;top:0;transition:0s}.jer-copy-pulse:active{top:.07em}.jer-icon:hover{opacity:.85;transform:scale(1.2);transition:.3s}.jer-empty-string{font-size:90%;font-style:italic}.jer-drag-n-drop-padding{border:1px dashed #b4b4b4;border-radius:.3em;height:.5em}.jer-clickzone{height:calc(100% - .8em);left:-1em;position:absolute;top:1.2em}',{});const it=(e,t)=>JSON.stringify(e,t,2),lt={edit:"ERROR_UPDATE",add:"ERROR_ADD",delete:"ERROR_DELETE",rename:"ERROR_RENAME",move:"ERROR_MOVE"},st={edit:"UPDATE_ERROR",add:"ADD_ERROR",delete:"DELETE_ERROR",rename:"RENAME_ERROR",move:"MOVE_ERROR"},ct=e=>{const t=i(e);e&&(t.current=e);const n=i((...e)=>t.current(...e));return e?n.current:void 0},dt=[],ut=["header","left"],pt={},ht={},mt={},ft=[],yt=({data:e,setData:n,buildNodeDataFromPathRef:r,commitRef:o,rootName:l="root",onUpdate:s=m,onChange:u,onError:g,onEditEvent:v,showErrorMessages:w=!0,showClipboardButton:E=!0,onCopy:D,indent:j=2,collapse:S=3,collapseAnimationTime:k=300,showCollectionCount:O="when-collapsed-or-filtered",allowEdit:T=!0,allowDelete:N=!0,allowAdd:x=!0,allowTypeSelection:R=!0,allowDrag:P=!1,searchFilter:I,searchText:L,searchDebounceTime:_=350,sortKeys:V=!1,showArrayIndexes:z=!0,arrayIndexStart:Y=0,showStringQuotes:U=!0,showIconTooltips:W=!1,defaultValue:$=null,newKeyOptions:H,minWidth:J=250,maxWidth:X="min(600px, 90vw)",baseFontSize:Q,stringTruncateLength:Z=250,translations:G=pt,className:q,id:te,customText:ne=ht,customNodeDefinitions:re=dt,customButtons:oe=ft,jsonParse:ae=JSON.parse,jsonStringify:ie=it,TextEditor:le,Select:ce=qe,errorDisplayTime:de=2500,keyboardControls:ue=mt,editorRef:he,insertAtTop:me=!1,onCollapse:fe,collapseClickZones:ye=ut})=>{const{getStyles:ge,cssVars:be}=ee(),{open:we,cancel:Ee,getSnapshot:De}=se(),Ce=c(()=>bt(S),[S]),je=c(()=>rt(G,ne),[G,ne]),[Se,ke]=p(L),Oe=i(null);a(()=>{Ee();const e=setTimeout(()=>ke(L),_);return()=>clearTimeout(e)},[L,_]);const Te=K(e,[],l),Ne=i(e);Ne.current=e;const xe=i(n);xe.current=n;const Re=i(je);Re.current=je;const Pe=i(Te);Pe.current=Te;const Ae=i(s);Ae.current=s;const Ie=i(l);Ie.current=l;const Ke=i(void 0),Le=d(()=>Ne.current,[]),_e=ct(u),Ve=ct(g),ze=ct(fe),Fe=ct(v),Be=ct(D),Ye=d(e=>{Ne.current=e,xe.current(e)},[]),Ue=d((e,t)=>{Ye(vt(Ne.current,e,t,"update").newData)},[Ye]),We=d(e=>{const t=Ne.current,n=Ie.current,r=Ke.current,o=Ye,{op:a,path:i}=e;switch(a){case"edit":{const{newData:a,currentValue:l,newValue:s}=vt(t,i,e.value,"update"),c=K(t,i,n,r);return{input:{...c,newData:a,event:"edit",newValue:s},nodeData:c,isNoOp:l===s,apply:()=>o(a),revert:()=>o(vt(Ne.current,i,l,"update").newData)}}case"delete":{const{newData:e,currentValue:a}=vt(t,i,"","delete"),l=K(t,i,n,r);return{input:{...l,newData:e,event:"delete"},nodeData:l,isNoOp:!1,apply:()=>o(e),revert:()=>o(vt(Ne.current,i,a,"add",{insert:!0,insertBefore:l.index}).newData)}}case"add":{const a=[...i,e.key],{newData:l,newValue:s}=vt(t,a,e.value,"add",e.options),c=K(l,a,n,r);return{input:{...c,value:void 0,size:null,parentData:A(t,i)??null,fullData:t,newData:l,event:"add",newValue:s},nodeData:c,isNoOp:!1,apply:()=>o(l),revert:()=>o(vt(Ne.current,a,"","delete").newData)}}case"rename":{const a=i.slice(0,-1),l=i[i.length-1],{newKey:s}=e,c=A(t,a),d=Object.fromEntries(Object.entries(c).map(([e,t])=>e===l?[s,t]:[e,t])),{newData:u}=vt(t,a,d,"update"),p=K(t,i,n,r);return{input:{...p,newData:u,event:"rename",newKey:s},nodeData:p,isNoOp:l===s,apply:()=>o(u),revert:()=>o(vt(Ne.current,a,c,"update").newData),extra:{oldKey:l,newKey:s}}}case"move":{const a=i,{path:l,position:s}=e.to,c=t,{newData:d,currentValue:u}=vt(t,a,"","delete"),p=a.slice(-1)[0],h=l.slice(0,-1),m=l.slice(-1)[0];let f="number"==typeof m?"above"===s?m:m+1:"number"==typeof p?`arr_${p}`:p;a.slice(0,-1).join(".")===l.slice(0,-1).join(".")&&"number"==typeof p&&"number"==typeof f&&p<f&&(f-=1);const y="number"==typeof f?{insert:!0}:"above"===s?{insertBefore:m}:{insertAfter:m},g=[...h,f],{newData:v}=vt(d,g,u,"add",y),b=K(t,a,n,r);return{input:{...b,newData:v,event:"move",newPath:g},nodeData:b,isNoOp:!1,apply:()=>o(v),revert:()=>o(c)}}}},[Ye]),He=d(async(e,t)=>{const n=st[e.event],r=()=>Re.current(lt[e.event],Pe.current);let o;try{o=await Ae.current(e,t)}catch(e){return{status:"error",error:{code:n,message:e instanceof Error&&e.message?e.message:"string"==typeof e&&e?e:r()}}}if(!1===o)return{status:"error",error:{code:n,message:r()}};if(null===o)return{status:"cancel"};if(o&&"object"==typeof o){if(void 0!==o.error)return"string"==typeof o.error?{status:"error",error:{code:n,message:o.error}}:{status:"error",error:o.error};const t=void 0!==o.data,r=void 0!==o.value;if(t&&r&&console.warn("json-edit-react: onUpdate returned both { value } and { data }; { data } (whole-document) takes precedence and { value } is ignored."),t)return{status:"override",value:o.data,path:[]};if(r&&("edit"===e.event||"add"===e.event))return{status:"override",value:o.value,path:e.path}}return{status:"commit"}},[]),Je=c(()=>({runUpdate:s===m?void 0:He,buildCommit:We,applyValue:Ue}),[He,We,Ue,s]);o.current=Je;const Xe=c(()=>bt(T),[T]),Qe=c(()=>bt(N),[N]),Ze=c(()=>bt(x),[x]),tt=c(()=>bt(P),[P]),nt=c(()=>wt(I),[I]),ot=c(()=>((e,t,n)=>{if(!t&&!n)return null;const r=new Set,o=new Map,a=t??et,i=n??"",l=e=>{let t=a(e,i);if(y(e.value)){let n=0;const r=Array.isArray(e.value),a=Object.entries(e.value);for(const[o,i]of a){const a=r?Number(o):o,s={key:a,path:[...e.path,a],level:e.level+1,index:n,value:i,size:y(i)?Object.keys(i).length:null,parentData:e.value,fullData:e.fullData};l(s)&&(t=!0,n++)}o.set(C(e.path),n)}return t&&r.add(C(e.path)),t};return l(e),{visiblePaths:r,visibleChildCounts:o}})(Te,nt,Se),[e,Se,nt,l]),at=c(()=>(e=>{const t={...F};for(const n of Object.keys(F)){const r=n,o=e[r];if(void 0===o)continue;const a="clipboardModifier"===n||"collapseModifier"===n;if(null===o){t[r]=a?[]:null;continue}const i=(()=>a?f(o):"string"==typeof o?{key:o}:o)();t[r]=i}return B.forEach(n=>{void 0===e[n]&&void 0!==e.confirm&&(t[n]=t.confirm)}),t})(ue),[ue]),yt=d((e,t)=>((e,t,n)=>{for(const[r,o]of Object.entries(t))if(M(n,e[r],r)){n.preventDefault(),o();break}})(at,t,e),[at]),gt=c(()=>{const e=Et(re,"stringifyReplacer");return t=>ie(t,e)},[re,ie]),Dt=c(()=>{const e=Et(re,"parseReviver");return t=>{const n=ae(t,e);return b(n)}},[re,ae]),Ct=i(null),{setCollapseState:jt}=pe(),St=d((e,t)=>{!1!==V&&("function"!=typeof V?e.sort((e,n)=>{const r=t(e)[0],o=t(n)[0];return r<o?-1:r>o?1:0}):e.sort((e,n)=>V(t(e),t(n))))},[V]);Ke.current=St;const kt=d(e=>K(Le(),e,Ie.current,Ke.current),[Le]);r.current=kt,h(he,()=>{const e=Symbol("path-missing");return{collapse:e=>jt(e),startEdit:({path:t,overrideRestrictions:n=!1})=>A(Le(),t,e)===e?"PATH_NOT_FOUND":n||Xe(K(Le(),t,l,St))?(we(t,{force:!0}),!0):"RESTRICTED",confirm:()=>{Ct.current&&(Ct.current.click(),"editing"!==De().active?.phase&&Ee())},cancel:()=>Ee()}},[jt,we,Ee,De,Xe,Le,l,St]);const Ot=Me(re,Te),Tt=c(()=>({object:!0===me||"object"===me,array:!0===me||"array"===me}),[me]),Nt={mainContainerRef:Oe,name:l,nodeData:Te,getLatestData:Le,onChange:_e,onError:Ve,onEditEvent:Fe,showErrorMessages:w,showCollectionCount:O,collapseFilter:Ce,collapseAnimationTime:k,allowEditFilter:Xe,allowDeleteFilter:Qe,allowAddFilter:Ze,allowTypeSelection:R,allowDragFilter:tt,canDragOnto:!1,showClipboardButton:E,onCopy:Be,sortKeys:V,sort:St,showArrayIndexes:z,arrayIndexStart:Y,showStringQuotes:U,showIconTooltips:W,indent:j,defaultValue:$,newKeyOptions:H,stringTruncateLength:Z,translate:je,customNodeDefinitions:re,customNodeData:Ot,customButtons:oe,parentData:null,jsonParse:Dt,jsonStringify:gt,TextEditor:le,Select:ce,errorDisplayTime:de,handleKeyboard:yt,keyboardControls:at,insertAtTop:Tt,onCollapse:ze,editConfirmRef:Ct,collapseClickZones:ye},xt={...ge("container",Te),...be,minWidth:J,maxWidth:X};return xt.fontSize=Q??xt.fontSize,t("div",{id:te,ref:Oe,className:`jer-editor-container ${q??""}`,style:xt,children:t(ve,{value:ot,children:y(e)&&!Ot.renderCollectionAsValue?t(Ge,{data:e,...Nt}):t($e,{data:e,showLabel:!0,...Nt})})})};function gt(e){const n=i(void 0),r=i(void 0),o=e;return t(q,{theme:o.theme??J,children:t(ye,{onEditEvent:o.onEditEvent,onCollapse:o.onCollapse,buildNodeDataFromPathRef:n,commitRef:r,children:t(yt,{...o,buildNodeDataFromPathRef:n,commitRef:r})})})}const vt=(e,t,n,r,o={})=>{if(0===t.length)return{currentData:e,newData:n,currentValue:e,newValue:n};const a={remove:"delete"===r,...o},i="add"!==r?A(e,t):void 0;return{currentData:e,newData:N(e,t,n,a),currentValue:i,newValue:"delete"!==r?n:void 0}},bt=e=>"boolean"==typeof e?()=>e:"number"==typeof e?({level:t})=>t>=e:e,wt=e=>{if(void 0!==e)return"value"===e?et:"key"===e?tt:"all"===e?(e,t)=>et(e,t)||tt(e,t):e},Et=(e,t)=>{const n="stringifyReplacer"===t?[e=>void 0===e?w:e]:[];if(n.push(...e.map(e=>e[t]).filter(e=>!!e)),0!==n.length)return(e,t)=>{let r=t;for(const e of n)r=e(r);return r}};function Dt(e){const{editorRef:n,...r}=e,o=i(null);return h(n,()=>({collapse:e=>o.current?.collapse(e)}),[]),t(gt,{...r,editorRef:o,setData:m,allowEdit:!1,allowAdd:!1,allowDelete:!1,allowDrag:!1})}export{_ as AutogrowTextArea,Re as IconSvg,gt as JsonEditor,Dt as JsonViewer,Ce as StringDisplay,je as StringEdit,N as assign,Le as collectionDataTypes,J as defaultTheme,A as extract,y as isCollection,et as matchNode,tt as matchNodeKey,E as splitPropertyString,_e as standardDataTypes,C as toPathString,Te as useKeyboardListener,Ke as valueDataTypes};
|