json-edit-react 2.0.1 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";var e=require("react/jsx-runtime"),t=require("react");const n=()=>{},r=e=>Array.isArray(e)?e:[e],o=e=>null!==e&&"object"==typeof e,a=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),s=e=>null!=e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof e.then,i=(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},l=e=>{if(e!==c){if(e&&"object"==typeof e)for(const t in e){const n=e[t],r=l(n);r!==n&&(e[t]=r)}return e}},c="__​undefined__",u=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}`,""),p=e=>1===e.length&&""===e[0]?"\0":e.map(e=>encodeURIComponent(String(e))).join("/"),m=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),h=(e,t)=>e.length>=t.length&&t.every((t,n)=>t===e[n]),f=(e,t,n,r,o)=>{if(!r)throw new Error(o??`Invalid property path: ${t}\nCouldn't access "${n}" in ${JSON.stringify(e)}`)},y=e=>Array.isArray(e),g=(e,t)=>e.filter((e,n)=>n!==t),v=(e,t,n,r={})=>{const{remove:o=!1,createNew:a=!0,noError:s=!1}=r,i=e,l=d(t),c={...r,remove:o,createNew:a,noError:s,fullData:i,fullPath:l},p=Array.isArray(t)?t:u(t);return y(e)&&o&&1===p.length?g(e,p[0]):b(e,p,n,c)},b=(e,t,n,r)=>{const o=a(e)?{...e}:null,s=y(e)?[...e]:null;if(0===t.length)return e;if(!o&&!s)throw new Error("Can't assign property -- invalid input object");const{createNew:i,remove:l,noError:c,fullData:u,fullPath:d}=r,p=t[0];if(s&&"string"==typeof p)return s.map(e=>b(e,t,n,r));if(1===t.length)return o&&"string"==typeof p?j(o,p,n,r)??o:s&&"number"==typeof p?(x(s,p,n,r),s):(f(u,d,p,c),e);const m=o||s||[];if(l&&2===t.length&&"number"==typeof t[1]){const e=m[p],n=t[1];return y(e)?m[p]=g(e,n):f(u,d,p,c,"Trying to remove an indexed item from an object that is not an array"),m}const h=t.slice(1);if(p in e){if(v=m[p],!y(v)&&!a(v)){if(!i)return f(u,d,p,c),m;m[p]={}}return m[p]=b(m[p],h,n,r),m}var v;if(i){const e="number"==typeof h[0]?[]:{};if(o)return m[p]=e,m[p]=b(m[p],h,n,r),m;if(s&&Array.isArray(m)){m.push(e);const t=m.length-1;return m[t]=b(m[t],h,n,r),m}}return f(u,d,p,c),m},j=(e,t,n,r)=>{const{remove:o,createNew:a,noError:s,insertAfter:i,insertBefore:l,fullData:c,fullPath:u}=r;if(void 0!==l||void 0!==i){const r=Object.entries(e);let o;return o="number"==typeof l?l:"number"==typeof i?i:r.findIndex(([e])=>e===(l??i)),void 0!==i&&o++,r.splice(o,0,[t,n]),Object.fromEntries(r)}const d=t in e;o?d?delete e[t]:f(c,u,t,s):a||d?e[t]=n:f(c,u,t,s)},x=(e,t,n,r)=>{const{noError:o,fullData:a,fullPath:s,createNew:i,insert:l}=r;l&&e.splice(t,0,n),t in e?e[t]=n:i?e.push(n):f(a,s,t,o)},w=(e,t,n)=>{const r=Array.isArray(t)?t:u(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=>w(e,r,n));if("object"!=typeof e||null===e||!(o in e))return E(e,o,n);const a=e[o];return 1===r.length?a:w(a,r.slice(1),n)},E=(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},C=(e,t,n="",r)=>{if(0===t.length)return{key:n,path:[],level:0,index:0,value:e,size:o(e)?Object.keys(e).length:1,parentData:null,fullData:e};const a=t[t.length-1],s=w(e,t),i=w(e,t.slice(0,-1))??null;let l=0;if(Array.isArray(i))l="number"==typeof a?a:Number(a);else if(i&&"object"==typeof i){const e=Object.entries(i);r?.(e,e=>e),l=e.findIndex(([e])=>e===a)}return{key:a,path:t,level:t.length,index:l,value:s,size:o(s)?Object.keys(s).length:null,parentData:i,fullData:e}},D="undefined"!=typeof window?t.useLayoutEffect:t.useEffect,S=({className:n,name:r,value:o,setValue:a,onKeyDown:s,styles:i,textAreaRef:l})=>{const c=t.useRef(null);if(D(()=>{const e=c.current;c.current=null;const t=l?.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,l]),"string"!=typeof o)return null;const u="\n"===o.slice(-1)?o+".":o;return e.jsxs("div",{style:{display:"grid"},children:[e.jsx("textarea",{id:`${r}_textarea`,ref:l,style:{height:"auto",gridArea:"1 / 1 / 2 / 2",overflowY:"auto",whiteSpace:"pre-wrap",...i},rows:1,className:n,name:`${r}_textarea`,value:o,onChange:e=>{const{value:t,selectionStart:n}=e.target;c.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:s}),e.jsx("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",...i},children:u})]})},k=e=>e.shiftKey?"Shift":e.metaKey?"Meta":e.ctrlKey?"Control":e.altKey?"Alt":void 0,O=(e,t,n)=>{if(!t)return!1;const r=e.key,o=k(e);if(Array.isArray(t))return!!o&&t.includes(o);const{key:a,modifier:s}=t;return("stringLineBreak"!==n||"Enter"!==r||"Shift"!==o||"Enter"!==a||!s?.includes("Shift"))&&r===a&&(s===o||Array.isArray(s)&&s.includes(o))},T={key:"Enter"},R={confirm:T,cancel:{key:"Escape"},objectConfirm:{...T,modifier:["Meta","Shift","Control"]},objectLineBreak:T,stringConfirm:T,stringLineBreak:{...T,modifier:["Shift"]},numberConfirm:T,numberUp:{key:"ArrowUp"},numberDown:{key:"ArrowDown"},tabForward:{key:"Tab"},tabBack:{key:"Tab",modifier:"Shift"},booleanConfirm:T,booleanToggle:{key:" "},clipboardModifier:["Meta","Control"],collapseModifier:["Alt"]},N=["stringConfirm","numberConfirm","booleanConfirm"],A=(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},P=(e,t,n="next",r,a)=>{const s=t.slice(0,t.length-1),i=t.slice(-1)[0];if(void 0===i)return null;const l=w(e,s),c=L(l);Array.isArray(l)||r(c,({key:e,value:t})=>[e,t]);const u=c.findIndex(e=>e.key===i),d=c[u+("next"===n?1:-1)];if(!d)return 0===s.length?null:P(e,s,n,r,a);let p;if(o(d.value)){if(0===Object.keys(d.value).length)return P(e,[...s,d.key],n,r,a);p=I(e,[...s,d.key],n,r)}else p=[...s,d.key];return p?a(C(e,p,"",r))?p:P(e,p,n,r,a):null},I=(e,t,n="next",r)=>{const a=w(e,t);if(!o(a))return t;const s=Array.isArray(a)?a.map((e,t)=>t):Object.keys(a);r(s,e=>[e,a]);const i="next"===n?s[0]:s[s.length-1];return I(e,[...t,i],n,r)},L=e=>Array.isArray(e)?e.map((e,t)=>({value:e,key:t})):Object.entries(e).map(([e,t])=>({key:e,value:t})),K={fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2},_={displayName:"Default",icons:{add:{content:/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx("path",{d:"M13 7h-2v4H7v2h4v4h2v-4h4v-2h-4z"}),/*#__PURE__*/e.jsx("path",{d:"M12 2C6.486 2 2 6.486 2 12s4.486 10 10 10 10-4.486 10-10S17.514 2 12 2zm0 18c-4.411 0-8-3.589-8-8s3.589-8 8-8 8 3.589 8 8-3.589 8-8 8z"})]})},edit:{content:/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx("path",{d:"M7 17.013l4.413-.015 9.632-9.54c.378-.378.586-.88.586-1.414s-.208-1.036-.586-1.414l-1.586-1.586c-.756-.756-2.075-.752-2.825-.003L7 12.583v4.43zM18.045 4.458l1.589 1.583-1.597 1.582-1.586-1.585 1.594-1.58zM9 13.417l6.03-5.973 1.586 1.586-6.029 5.971L9 15.006v-1.589z"}),/*#__PURE__*/e.jsx("path",{d:"M5 21h14c1.103 0 2-.897 2-2v-8.668l-2 2V19H8.158c-.026 0-.053.01-.079.01-.033 0-.066-.009-.1-.01H5V5h6.847l2-2H5c-1.103 0-2 .897-2 2v14c0 1.103.897 2 2 2z"})]}),svgProps:{transform:"translate(0, 0.5)"}},delete:{content:/*#__PURE__*/e.jsx("path",{d:"M6 19a2 2 0 002 2h8a2 2 0 002-2V7H6v12m2.46-7.12l1.41-1.41L12 12.59l2.12-2.12 1.41 1.41L13.41 14l2.12 2.12-1.41 1.41L12 15.41l-2.12 2.12-1.41-1.41L10.59 14l-2.13-2.12M15.5 4l-1-1h-5l-1 1H5v2h14V4h-3.5z"}),scale:1.04},copy:{content:/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx("path",{d:"M9 2 H15 A1 1 0 0 1 16 3 V5 A1 1 0 0 1 15 6 H9 A1 1 0 0 1 8 5 V3 A1 1 0 0 1 9 2 z"}),/*#__PURE__*/e.jsx("path",{d:"M8 4H6a2 2 0 00-2 2v14a2 2 0 002 2h12a2 2 0 002-2v-2M16 4h2a2 2 0 012 2v4M21 14H11"}),/*#__PURE__*/e.jsx("path",{d:"M15 10l-4 4 4 4"})]}),svgProps:K,scale:.86},ok:{content:/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx("path",{d:"M22 11.08V12a10 10 0 11-5.93-9.14"}),/*#__PURE__*/e.jsx("path",{d:"M22 4L12 14.01l-3-3"})]}),svgProps:K,scale:.9},cancel:{content:/*#__PURE__*/e.jsx("path",{d:"M12 4c-4.411 0-8 3.589-8 8s3.589 8 8 8 8-3.589 8-8-3.589-8-8-8zm-5 8c0-.832.224-1.604.584-2.295l6.711 6.711A4.943 4.943 0 0112 17c-2.757 0-5-2.243-5-5zm9.416 2.295L9.705 7.584A4.943 4.943 0 0112 7c2.757 0 5 2.243 5 5 0 .832-.224 1.604-.584 2.295z"}),svgProps:{baseProfile:"tiny"},scale:1.3},collection:{content:/*#__PURE__*/e.jsx("path",{d:"M233.4 406.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L256 338.7 86.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z"}),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"}},M={container:"backgroundColor",collection:"backgroundColor",collectionInner:"backgroundColor",collectionElement:"backgroundColor",headerRow:"backgroundColor",valueRow:"backgroundColor",dropZone:"borderColor",inputHighlight:"backgroundColor"},V=e=>[_,...r(e)].map(e=>"styles"in e?e:{styles:e}),F=e=>{const t={};for(const{icons:n}of V(e))n&&Object.assign(t,n);return t},z={getStyles:()=>({}),icons:/*#__PURE__*/F(_),cssVars:{}},B=t.createContext(z),H=({theme:n=_,children:r})=>{const o=t.useMemo(()=>(e=>{var t;const n=V(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?{[M[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],s=o[t];a[t]=s?e=>s.reduce((t,n)=>({...t,...n(e)??{}}),n):n}return a})(n),[n]),a=t.useMemo(()=>/*#__PURE__*/F(n),[n]),s=t.useMemo(()=>(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})(o),[o]),i=t.useCallback((e,t)=>((e,t,n)=>{const r=e[t];return"function"==typeof r?r(n):r??{}})(o,e,t),[o]),l=t.useMemo(()=>({getStyles:i,icons:a,cssVars:s}),[i,a,s]);return e.jsx(B.Provider,{value:l,children:r})},W=()=>t.useContext(B),Y={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"}},U=(e,t)=>Y[e][t]??null,$=(e,t)=>null!==e&&null!==t&&e.op===t.op&&m(e.path,t.path),J={active:null,settling:{}},X=t.createContext(null),Q=({children:n,onEditEvent:r,buildNodeDataFromPathRef:o,commitRef:a})=>{const i=t.useRef(r);i.current=r;const l=t.useRef(null);return null===l.current&&(l.current=((e,t,n)=>{let r=J;const o=new Set;let a=null,i=null,l=!1,c=0;const u=e=>{r=e,o.forEach(e=>e())},d=(t,n,r)=>{e.current?.({...t,...r,event:n})},f=(n,o,s)=>{if(!e.current)return;let l;try{l=t.current?.(n)}catch{return u({...r,active:null}),a=null,void(i=null)}l&&d(l,o,s)},y=(e,t)=>{var n;a=t?.cancelOp??null,i=t?.commitOp??null,n=e,$(r.active,n)&&r.active?.phase===n?.phase||u({...r,active:n});const o=U(e.op,"start");o&&f(e.path,o)},g=(e,t,o,s,l,c,h,f,y)=>{const g=p(e);if(!h()){if("cancel"===s.status||"error"===s.status){r.active&&m(r.active.path,e)&&("held"===r.active.phase||"editing"===r.active.phase)&&(u({...r,active:null}),a=null,i=null);const n=U(t,"cancel");return n&&d(f,n),"error"===s.status&&d(f,"updateError",{operation:t,error:s.error}),s}l()}if(r.settling[g]===o){switch((e=>{if(!(e in r.settling))return;const t={...r.settling};delete t[e],u({...r,settling:t})})(g),s.status){case"cancel":c();break;case"error":c(),d(f,"updateError",{operation:t,error:s.error});break;case"override":n.current?.applyValue(s.path,s.value),d(f,"updateSuccess",{operation:t,...y});break;case"commit":d(f,"updateSuccess",{operation:t,...y})}return s}};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,s=null!==o&&!$(o,n);if(s&&i)return void i(()=>y(n,t));const l=a;if(a=null,i=null,l&&l(),s&&$(r.active,o)){const e=U(o.op,"cancel");e&&f(o.path,e)}y(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&&u({...r,active:null});const t=U(e.op,"cancel");t&&f(e.path,t)}}finally{l=!1}},submit:e=>{const{op:t,path:o,instant:l,onCommit:m}=e,h=n.current;let y;try{y=h?.buildCommit(e)??null}catch{return $(r.active,{path:o,op:t})&&u({...r,active:null}),a=null,i=null,m?.(),Promise.resolve(void 0)}const v=y?.extra,b=p(o),j=++c;if(!l){const e=U(t,"submit");e&&f(o,e)}if(!y||y.isNoOp){$(r.active,{path:o,op:t})&&u({...r,active:null}),a=null,i=null;const e=U(t,"commit");return e&&(y?d(y.nodeData,e,v):f(o,e,v)),m?.(),Promise.resolve(void 0)}const{input:x,nodeData:w,apply:E,revert:C}=y,D=!!h?.runUpdate;let S=!1,k=!1;const O=()=>{if(S)return;S=!0,E(),a=null,i=null,$(r.active,{path:o,op:t})&&u({...r,active:null}),D&&((e,t)=>{u({...r,settling:{...r.settling,[e]:t}})})(b,j);const e=U(t,"commit");e&&d(w,e,v),m?.()},T={hold:()=>(k=!0,u({...r,active:{path:o,op:t,phase:"held",force:r.active?.force}}),()=>O())};if(!D)return O(),Promise.resolve(void 0);const R=h.runUpdate(x,T),N=s(R);if(!k&&!l&&!N)return Promise.resolve(g(o,t,j,R,O,C,()=>S,w,v));const A=N?R:Promise.resolve(R);let P;return k||(l?P=setTimeout(O,100):O()),A.then(e=>(clearTimeout(P),g(o,t,j,e,O,C,()=>S,w,v)))},areChildrenBeingEdited:e=>null!==r.active&&h(r.active.path,e)}})(i,o,a)),e.jsx(X.Provider,{value:l.current,children:n})},Z=()=>{const e=t.useContext(X);if(!e)throw new Error("Missing Editing Context Provider");return e},G=e=>{const n=Z();return t.useSyncExternalStore(n.subscribe,()=>e(n.getSnapshot()),()=>e(n.getServerSnapshot()))},q=t.createContext(null),ee=({children:n,onCollapse:o,buildNodeDataFromPathRef:a})=>{const[s,i]=t.useState({commands:null,version:0}),l=t.useRef(o);l.current=o;const c=t.useCallback(e=>{if(null===e)return void i(e=>null===e.commands?e:{commands:null,version:e.version});const t=r(e),n=t.map(e=>({...e,path:[...e.path]}));i(e=>({commands:n,version:e.version+1}));const o=l.current;o&&t.forEach(e=>{const t=a.current?.(e.path);t&&o({...t,collapsed:e.collapsed,includeChildren:e.includeChildren})})},[a]),u=t.useMemo(()=>({commands:s.commands,version:s.version,setCollapseState:c}),[s.commands,s.version,c]);return e.jsx(q.Provider,{value:u,children:n})},te=()=>{const e=t.useContext(q);if(!e)throw new Error("Missing Collapse Context Provider");return e},ne=(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},re=t.createContext(null),oe=({children:n})=>{const[r,o]=t.useState({path:null,canDelete:!1}),a=t.useRef(!1),s=t.useMemo(()=>({dragSource:r,setDragSource:o,armed:a}),[r]);return e.jsx(re.Provider,{value:s,children:n})},ae=({children:t,onEditEvent:n,onCollapse:r,buildNodeDataFromPathRef:o,commitRef:a})=>e.jsx(Q,{onEditEvent:n,buildNodeDataFromPathRef:o,commitRef:a,children:e.jsx(ee,{onCollapse:r,buildNodeDataFromPathRef:o,children:e.jsx(oe,{children:t})})}),se=t.createContext(void 0),ie=({value:t,children:n})=>e.jsx(se.Provider,{value:t,children:n}),le=()=>{const e=t.useContext(se);if(void 0===e)throw new Error("Missing FilterStateProvider");return e},ce=e=>{const t=le();return null===t||t.visiblePaths.has(p(e))},ue=e=>{const t=le();return null===t?null:t.visibleChildCounts.get(p(e))??null},de="**INVALID_FUNCTION**",pe=({nodeData:n,showStringQuotes:r=!0,stringTruncateLength:o=200,pathString:a,canEdit:s,setIsEditing:i,styles:l,translate:c,showIconTooltips:u=!1,value:d,TextWrapper:p=({children:e})=>e})=>{const m=d??n.value,[h,f]=t.useState(!1),y=r?'"':"",g=m.length>o,v=()=>{s?i(!0):f(!h)},b=c("SHOW_MORE",n);return e.jsxs("div",{id:`${a}_display`,onDoubleClick:v,onClick:e=>{(e.getModifierState("Control")||e.getModifierState("Meta"))&&v()},className:"jer-value-string",style:l,children:[y,g?h?e.jsxs(e.Fragment,{children:[e.jsx(p,{children:e.jsxs("span",{children:[m,y]})})," ",e.jsx("button",{type:"button",tabIndex:-1,className:"jer-string-expansion jer-show-less",onClick:()=>f(!1),children:c("SHOW_LESS",n)})]}):e.jsxs(e.Fragment,{children:[e.jsxs(p,{children:[e.jsx("span",{children:m.slice(0,o-2).trimEnd()})," "]}),e.jsx("button",{type:"button",tabIndex:-1,className:"jer-string-expansion jer-ellipsis",onClick:()=>f(!0),"aria-label":b,title:u?b:"",children:"..."}),y]}):e.jsx(p,{children:`${m}${y}`})]})},me=({styles:n,pathString:r,value:o,setValue:a,handleEdit:s,handleKeyboard:i,keyboardCommon:l})=>{const c=t.useRef(null);return e.jsx(S,{className:"jer-input-text",textAreaRef:c,name:r,value:o,setValue:a,onKeyDown:e=>{i(e,{stringConfirm:s,stringLineBreak:()=>{const e=A(c,"\n");a(e)},...l})},styles:n})},he=({isEditing:t,path:n,enumType:r,...o})=>{const{getStyles:a}=W(),s=p(n),{value:i,setValue:l,nodeData:c,handleEdit:u,handleKeyboard:d,keyboardCommon:m,Select:h}=o;return t&&r?e.jsx(h,{name:`${s}-value-select`,value:i,onChange:l,options:r.values,autoFocus:!0,onKeyDown:e=>d(e,{stringConfirm:u,...m})}):t?e.jsx(me,{styles:a("input",c),pathString:s,...o,setValue:o.setValue}):e.jsx(pe,{pathString:s,styles:a("string",c),...o})},fe=({value:t,setValue:n,isEditing:r,path:o,setIsEditing:a,handleEdit:s,nodeData:i,handleKeyboard:l,keyboardCommon:c})=>{const{getStyles:u}=W();return r?e.jsx("input",{className:"jer-input-number",type:"text",name:p(o),value:t,onChange:e=>n(e.target.value.replace(/[^0-9.-]/g,"")),autoFocus:!0,onFocus:e=>setTimeout(()=>e.target.select(),10),onKeyDown:e=>l(e,{numberConfirm:s,numberUp:()=>n(Number(t)+1),numberDown:()=>n(Number(t)-1),...c}),style:{width:String(t).length/1.5+2+"em",...u("input",i)}}):e.jsx("span",{onDoubleClick:()=>a(!0),className:"jer-value-number",style:u("number",i),children:t})},ye=({value:t,setValue:n,isEditing:r,path:o,setIsEditing:a,handleEdit:s,nodeData:i,handleKeyboard:l,keyboardCommon:c})=>{const{getStyles:u}=W();return"boolean"!=typeof t?null:r?e.jsx("input",{className:"jer-input-boolean",type:"checkbox",name:p(o),checked:t,onChange:()=>n(!t),onKeyDown:e=>{" "===e.key&&e.preventDefault(),l(e,{booleanConfirm:s,booleanToggle:()=>n(!t),...c})},autoFocus:!0}):e.jsx("span",{onDoubleClick:()=>a(!0),className:"jer-value-boolean",style:u("boolean",i),children:String(t)})},ge=(e,n)=>{const r=t.useRef(void 0),o=t.useRef(n);t.useEffect(()=>{o.current=n},[n]);const a=e=>{o.current(e)};t.useEffect(()=>{if(window.clearTimeout(r.current),e)return r.current=window.setTimeout(()=>{window.addEventListener("keydown",a)},100),()=>{window.clearTimeout(r.current),window.removeEventListener("keydown",a)}},[e])},ve=({value:t,isEditing:n,setIsEditing:r,handleEdit:o,nodeData:a,handleKeyboard:s,keyboardCommon:i})=>{const{getStyles:l}=W();return ge(n,e=>s(e,{confirm:o,...i})),e.jsx("div",{onDoubleClick:()=>r(!0),className:"jer-value-null",style:l("null",a),children:String(t)})},be=({value:t})=>{let n="Error!";switch(typeof t){case"string":t===de&&(n="Function");break;case"undefined":n="Undefined";break;case"symbol":n="Symbol"}return e.jsx("span",{className:"jer-value-invalid",children:n})},je=({scale:t=1,viewBox:n="0 0 24 24",fill:r="currentColor",children:o,...a})=>{const s=1.4*t+"em";return e.jsx("svg",{viewBox:n,fill:r,width:s,height:s,...a,children:o})},xe=({name:t,nodeData:n})=>{const{getStyles:r,icons:o}=W(),a=o[t],s=`icon${t[0].toUpperCase()}${t.slice(1)}`;return e.jsx(je,{viewBox:a.viewBox,...a.svgProps,scale:a.scale,className:"collection"===t?void 0:"jer-icon",style:r(s,n),children:a.content})},we=({startEdit:n,handleDelete:r,handleAdd:o,showClipboardButton:a,onCopy:s,type:i,customButtons:l,nodeData:c,translate:u,keyboardControls:p,handleKeyboard:h,editConfirmRef:f,getNewKeyOptions:y,jsonStringify:g,showIconTooltips:v,Select:b})=>{const{getStyles:j}=W(),{open:x,cancel:E}=Z(),C=u("KEY_NEW",c),[S,O]=t.useState(C),[T,R]=t.useState(!1),{path:N,value:A}=c,P=G(e=>{const t=e.active;return null!==t&&"add"===t.op&&m(t.path,N)}),I=Array.isArray(T);D(()=>{if(!P)return R(!1),void O(C);const e=Object.keys(w(c.fullData,N)),t=y?y(c)?.filter(t=>!e.includes(t)):null;t&&O(""),R(t??!0)},[P]);const L=()=>{o&&(I&&!S||o("array"===i?"":S))};return e.jsxs("div",{className:"jer-edit-buttons",style:{opacity:P?1:void 0},onClick:e=>e.stopPropagation(),children:[a&&e.jsx("button",{type:"button",tabIndex:-1,onClick:e=>{e.stopPropagation();let t,n,r="value",o="",i=null;if(a){const a=k(e);if(a&&p.clipboardModifier.includes(a)?(t=d(N),o=t,r="path"):(t=A,o="object"==typeof t?g(A):String(t)),!navigator.clipboard)return void s?.({...c,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,i=e.message}).finally(()=>{s?.({...c,success:n,stringValue:o,type:r,error:n?void 0:{code:"CLIPBOARD_ERROR",message:i??"Copy failed"}})})}},className:"jer-copy-pulse","aria-label":u("TOOLTIP_COPY",c),title:v?u("TOOLTIP_COPY",c):"",children:e.jsx(xe,{name:"copy",nodeData:c})}),n&&e.jsx("button",{type:"button",tabIndex:-1,onClick:n,"aria-label":u("TOOLTIP_EDIT",c),title:v?u("TOOLTIP_EDIT",c):"",children:e.jsx(xe,{name:"edit",nodeData:c})}),r&&e.jsx("button",{type:"button",tabIndex:-1,onClick:r,"aria-label":u("TOOLTIP_DELETE",c),title:v?u("TOOLTIP_DELETE",c):"",children:e.jsx(xe,{name:"delete",nodeData:c})}),o&&e.jsx("button",{type:"button",tabIndex:-1,onClick:()=>{"object"===i?x(N,{op:"add"}):o("")},"aria-label":u("TOOLTIP_ADD",c),title:v?u("TOOLTIP_ADD",c):"",children:e.jsx(xe,{name:"add",nodeData:c})}),l?.map(({Element:t,onClick:n,label:r},o)=>{const a=e=>n&&n(c,e);return r?e.jsx("button",{type:"button",tabIndex:-1,onClick:a,"aria-label":r,title:v?r:"",children:e.jsx(t,{nodeData:c})},o):e.jsx("div",{onClick:a,children:e.jsx(t,{nodeData:c})},o)}),P&&o&&"object"===i&&e.jsxs(e.Fragment,{children:[I?e.jsx(b,{name:"new-key-select",onChange:o,defaultValue:"",autoFocus:!0,onKeyDown:e=>h(e,{cancel:()=>E()}),placeholder:T.length>0?u("KEY_SELECT",c):u("NO_KEY_OPTIONS",c),options:T}):e.jsx("input",{className:"jer-input-new-key",type:"text",name:"new-object-key",value:S,onChange:e=>O(e.target.value),autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>{h(e,{stringConfirm:()=>L(),cancel:()=>E()})},style:j("input",c)}),e.jsx(Ee,{onOk:()=>L(),onCancel:()=>E(),nodeData:c,translate:u,showIconTooltips:v,editConfirmRef:f,hideOk:I})]})]})},Ee=({onOk:t,onCancel:n,nodeData:r,translate:o,showIconTooltips:a,editConfirmRef:s,hideOk:i=!1})=>e.jsxs("div",{className:"jer-confirm-buttons",children:[!i&&e.jsx("button",{type:"button",tabIndex:-1,onClick:t,"aria-label":o("TOOLTIP_OK",r),title:a?o("TOOLTIP_OK",r):"",ref:s,children:e.jsx(xe,{name:"ok",nodeData:r})}),e.jsx("button",{type:"button",tabIndex:-1,onClick:n,"aria-label":o("TOOLTIP_CANCEL",r),title:a?o("TOOLTIP_CANCEL",r):"",children:e.jsx(xe,{name:"cancel",nodeData:r})})]}),Ce=["string","number","boolean","null"],De=["object","array"],Se=[...Ce,...De],ke=e=>{const{component:t,wrapperComponent:n,keyComponent:r,showKey:o=!0,showEditTools:a=!0,showOnEdit:s=!1,showOnView:i=!0,showCollectionWrapper:l=!0,...c}=e;return{CustomComponent:t,CustomWrapperComponent:n,CustomKeyComponent:r,showKey:o,showEditTools:a,showOnEdit:s,showOnView:i,showCollectionWrapper:l,...c}},Oe=(e=[],t)=>{const n=e.find(({condition:e})=>e(t));return n?ke(n):{}},Te=({props:e,collapsed:n})=>{const{nodeData:r,parentData:o,onError:a,getLatestData:s,showErrorMessages:i,allowEditFilter:l,allowDeleteFilter:c,allowAddFilter:u,allowDragFilter:d,canAddHere:h,translate:f,errorDisplayTime:y,sort:g,arrayIndexStart:v,handleKeyboard:b,customNodeData:j}=e,{submit:x}=Z(),[w,E]=t.useState(null),C={...r,collapsed:n,visibleSize:ue(r.path)},{path:D,key:S,size:k}=C,O=p(D),T=G(e=>{const t=e.active;return null!==t&&"edit"===t.op&&m(t.path,D)}),R=G(e=>{const t=e.active;return null!==t&&"rename"===t.op&&m(t.path,D)}),N=G(e=>O in e.settling),A=l(C),I=c(C),L=u(C),K=d(C),_=e=>{i&&(E(e),setTimeout(()=>E(null),y)),console.warn("Error",e)},M=t.useRef(C);M.current=C;const V=t.useCallback((e,t)=>{_(e.message),a&&a({...M.current,fullData:s(),error:e,errorValue:t})},[a,i,s,y]),F=le(),z=t.useCallback(e=>(null===F||F.visiblePaths.has(p(e.path)))&&l(e),[F,l]),B=e=>P(s(),D,e,g,z),H=(e,t)=>{o&&(S!==e&&Object.keys(o).includes(e)?V({code:"KEY_EXISTS",message:f("ERROR_KEY_EXISTS",C)},e):x({op:"rename",path:D,newKey:e,onCommit:t}).then(t=>{"error"===t?.status&&V(t.error,e)}))},W="number"==typeof D.slice(-1)[0],Y=null!==o&&!W&&I&&h,U={isEditing:T,isEditingKey:R,isPending:N,isArray:W,canEditKey:Y},$=""===S&&D.length>0?f("EMPTY_STRING",C):null;return{pathString:O,nodeData:C,path:D,name:S,size:k,canEdit:A,canDelete:I,canAdd:L,canDrag:K,error:w,showError:_,onError:V,setError:E,handleEditKey:H,derivedValues:U,emptyStringKey:$,getNextOrPreviousAtPath:B,buildKeyDisplayProps:({handleCancel:e,getStyles:t,keyValueArray:n,handleClick:r})=>({canEditKey:Y,isEditingKey:R,pathString:O,path:D,name:S,arrayIndexStart:v,handleKeyboard:b,handleEditKey:H,handleCancel:e,styles:t("property",C),getNextOrPrevious:B,emptyStringKey:$,nodeData:C,customNodeData:j,getStyles:t,...void 0!==n?{keyValueArray:n}:{},...void 0!==r?{handleClick:r}:{}})}},Re=({canDrag:n,canDelete:r,canDragOnto:o,canAddHere:a,path:s,nodeData:i,onError:l,translate:c})=>{const{getStyles:u}=W(),{dragSource:d,setDragSource:p,armed:f}=(()=>{const e=t.useContext(re);if(!e)throw new Error("Missing DragSource Context Provider");return e})(),y=Z(),[g,v]=t.useState(!1),b=()=>null!==d.path&&!h(s,d.path)&&(m(d.path.slice(0,-1),s.slice(0,-1))?o:d.canDelete&&a),j=t.useMemo(()=>n?{onMouseDown:e=>{0===e.button&&null===y.getSnapshot().active&&(f.current=!0)},onMouseUp:()=>{f.current=!1},onDragStart:e=>{if(!f.current||null!==y.getSnapshot().active)return e.preventDefault(),void e.stopPropagation();f.current=!1,e.stopPropagation(),p({path:s,canDelete:r})},onDragEnd:e=>{f.current=!1,e.stopPropagation(),p({path:null,canDelete:!1})}}:{},[n,r,s]),x=t.useMemo(()=>e=>o||a?{onDragOver:e=>{e.stopPropagation(),b()&&e.preventDefault()},onDrop:t=>{t.stopPropagation(),E(e),p({path:null,canDelete:!1}),v(!1)},onDragEnter:t=>{t.stopPropagation(),b()&&v(e)},onDragExit:e=>{e.stopPropagation(),v(!1)}}:{},[d,o,a,s]),w=t.useMemo(()=>null!==d.path&&b()?e.jsx("div",{className:"jer-drop-target-bottom",style:{height:"50%",position:"absolute",width:"100%",top:"50%",zIndex:s.length},...x("below")}):null,[d,o,a,s.length]),E=e=>{if(null===d.path)return;if(!b())return;const t=d.path.slice(-1)[0],n=d.path.slice(0,-1),r=s.slice(0,-1),{parentData:o}=i;"string"==typeof t&&o&&!Array.isArray(o)&&Object.keys(o).includes(t)&&t in o&&!m(n,r)?l({code:"KEY_EXISTS",message:c("ERROR_KEY_EXISTS",i)},t):y.submit({op:"move",path:d.path,to:{path:s,position:e},instant:!0})};return{dragSourceProps:j,getDropTargetProps:x,BottomDropTarget:w,DropTargetPadding:({position:t,nodeData:n})=>g===t?e.jsx("div",{className:"jer-drag-n-drop-padding",style:u("dropZone",n)}):null,handleDrop:E}},Ne=({isEditingKey:n,canEditKey:r,pathString:o,path:a,name:s,arrayIndexStart:i,handleKeyboard:l,handleEditKey:c,handleCancel:u,handleClick:d,keyValueArray:p,styles:m,getNextOrPrevious:h,emptyStringKey:f,nodeData:y,customNodeData:g,getStyles:v})=>{const{open:b,cancel:j}=Z(),x=t.useRef(null),w=e=>c(x.current?.value??String(s),e),E="number"==typeof s?String(s+i):s;if(!n){const t={...m,minWidth:`${Math.min(E.length+1,5)}ch`,flexShrink:E.length>10?1:0};if(g?.CustomKeyComponent&&y&&v){const{CustomKeyComponent:n,componentProps:o}=g;return e.jsx(n,{nodeData:y,name:f??E,path:a,canEditKey:r,handleEditKey:e=>{r&&c(e)},startEditingKey:()=>{r&&b(a,{op:"rename",commitOp:w})},handleClick:d,styles:t,componentProps:o,getStyles:v})}return e.jsxs("span",{className:"jer-key-text",style:t,onDoubleClick:()=>r&&b(a,{op:"rename",commitOp:w}),onClick:d,children:[f?e.jsx("span",{className:"jer-empty-string",children:f}):E,""!==E||f?e.jsx("span",{className:"jer-key-colon",children:":"}):null]})}return e.jsx("input",{ref:x,className:"jer-input-text jer-key-edit",type:"text",name:o,defaultValue:E,autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>l(e,{stringConfirm:()=>c(e.target.value),cancel:u,tabForward:()=>{const t=e.target.value;c(t,()=>{if(p){const e=p?.[0][0],t=e?[...a,e]:h("next");t?b(t):j()}else b(a)})},tabBack:()=>{const t=e.target.value;c(t,()=>{const e=h("prev");e?b(e):j()})}}),style:{width:E.length/1.5+.5+"em"}})},Ae=new Set(["nodeData","customNodeData"]),Pe=(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||!m(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(!Ae.has(n)&&!Object.is(e[n],t[n]))return!1;return!0},Ie=r=>{const{data:o,parentData:a,onChange:s,showClipboardButton:l,onCopy:c,canDragOnto:u,canAddHere:d,allowTypeSelection:p,showLabel:h,stringTruncateLength:f,showStringQuotes:y,indent:g,translate:v,customNodeDefinitions:b,customNodeData:j,Select:x,handleKeyboard:w,keyboardControls:E,editConfirmRef:C,jsonStringify:D,showIconTooltips:S,getLatestData:k}=r,{getStyles:O}=W(),{open:T,cancel:R,submit:N,getSnapshot:A}=Z(),{setCollapseState:P}=te(),[I,L]=t.useState("function"==typeof o?de:o),{nodeData:K,path:_,name:M,canEdit:V,canDelete:F,canDrag:z,error:B,onError:H,setError:Y,derivedValues:U,getNextOrPreviousAtPath:$,buildKeyDisplayProps:J}=Te({props:r}),{dragSourceProps:X,getDropTargetProps:Q,BottomDropTarget:G,DropTargetPadding:q}=Re({canDrag:z,canDelete:F,canDragOnto:u,canAddHere:d,path:_,nodeData:K,onError:H,translate:v}),[ee,ne]=t.useState(_e(o,j)),re=t.useRef(I);re.current=I;const oe=t.useRef(K);oe.current=K;const ae=t.useCallback(e=>{if(!s)return void L(e);const t=s({...oe.current,value:re.current,fullData:k(),newValue:e});L(t)},[s,k]),se=()=>{L("function"==typeof o?de:o),ne(_e(o,j)),ue(i(o,ie))};t.useEffect(()=>{U.isEditing||se()},[o]);const ie=t.useMemo(()=>{const e=[...Se,...b.filter(({showInTypeSelector:e=!1,name:t})=>e&&!!t).map(({name:e})=>e)];if("boolean"==typeof p)return p?e:[];if(Array.isArray(p))return p;const t=p(K);return"boolean"==typeof t?t?e:[]:t},[K,p,b]),[le,ue]=t.useState(i(I,ie)),{isEditing:pe,isPending:me}=U,he=ce(_),fe=t.useRef(n);if(!he)return null;const ye=pe&&ee!==_e(o,j),ge=ye?b.find(e=>e.name===ee&&Ke(e)):void 0,ve=ge?ke(ge):j,{CustomComponent:be,componentProps:je,showKey:xe=!0,showEditTools:Ce=!0,showOnEdit:De,showOnView:Oe,passOriginalNode:Ae}=ve,Pe=be&&(void 0!==ge||!ye&&(pe&&De||!pe&&Oe)),Ie=e=>{P(null);const t=ye&&!ge?void 0:ve,n=t?.toStandardType?t.toStandardType(I):I,r=b.find(t=>t.name===e);if(r){const t="function"==typeof r.defaultValue?r.defaultValue(K):r.defaultValue;if(Ke(r)){let o=t;if(r.fromStandardType)try{o=r.fromStandardType(n,K,r.componentProps)}catch{}return L(o),ne(e),void ue(null)}return N({op:"edit",path:_,value:t}).then(Le(t)),void P({path:_,collapsed:!1,includeChildren:!1})}const o=ie.find(t=>t instanceof Object&&t.enum===e);if(o)return"string"==typeof I&&o.values.includes(I)||L(o.values[0]),ue(o),void ne(e);const a=Fe(n,e,v("DEFAULT_NEW_KEY",K));if("object"===e||"array"===e||"null"===e)return N({op:"edit",path:_,value:a}).then(Le(a)),void("null"!==e&&P({path:_,collapsed:!1,includeChildren:!1}));L(a),ne(e),ue(null)},Le=e=>t=>{if("error"===t?.status&&H(t.error,e),"error"===t?.status||"cancel"===t?.status){const e=A().active;"editing"===e?.phase&&m(e.path,_)||se()}},ze=(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(Pe&&ve.fromStandardType)try{r=ve.fromStandardType(I,K,ve.componentProps)}catch(e){return void H({code:"UPDATE_ERROR",message:e instanceof Error?e.message:String(e)},I)}else r="number"===ee?Ve(I):I;Y(null),ge&&P({path:_,collapsed:!1,includeChildren:!1}),N({op:"edit",path:_,value:r,onCommit:t}).then(Le(r))};fe.current=ze;const Be=()=>{Y(null),se(),R()},{isEditingKey:He}=U,We=!!B,Ye=pe&&ie.length>1,Ue=("invalid"!==ee||be)&&!B&&Ce,$e=h&&xe,Je=()=>T(_,{cancelOp:se,commitOp:e=>fe.current(void 0,e)}),Xe=V?Je:n,Qe=e=>()=>{const t=$(e);t&&ze(void 0,()=>T(t))},Ze={value:I,parentData:a,setValue:ae,isEditing:pe,canEdit:V,setIsEditing:Xe,handleEdit:ze,handleCancel:Be,path:_,stringTruncateLength:f,showStringQuotes:y,showIconTooltips:S,nodeData:K,enumType:le,translate:v,handleKeyboard:w,keyboardCommon:{cancel:Be,tabForward:Qe("next"),tabBack:Qe("prev")},Select:x},Ge={...J({handleCancel:Be,getStyles:O}),customNodeData:ve},qe=Pe?e.jsx(be,{...r,value:I,componentProps:je,setValue:ae,handleEdit:ze,handleCancel:Be,onKeyDown:e=>w(e,{stringConfirm:ze,cancel:Be}),isEditing:pe,isPending:me,setIsEditing:Xe,getStyles:O,originalNode:Ae?Me(o,ee,Ze):void 0,originalNodeKey:Ae?e.jsx(Ne,{...Ge,customNodeData:void 0}):void 0,canEdit:V,keyboardCommon:Ze.keyboardCommon}):Me(o,ee,Ze);return e.jsxs("div",{className:"jer-component jer-value-component",style:{marginLeft:null!==a?g/2+"em":0,position:"relative"},draggable:z&&!pe&&!He,...X,...Q("above"),children:[G,e.jsx(q,{position:"above",nodeData:K}),e.jsxs("div",{className:"jer-value-main-row",style:{...O("valueRow",K),flexWrap:M.length>10?"wrap":"nowrap"},children:[$e&&e.jsx(Ne,{...Ge}),e.jsxs("div",{className:"jer-value-and-buttons",children:[e.jsx("div",{className:"jer-input-component",children:qe}),pe?e.jsx(Ee,{onOk:ze,onCancel:Be,nodeData:K,translate:v,showIconTooltips:S,editConfirmRef:C}):Ue&&e.jsx(we,{startEdit:V?Je:void 0,handleDelete:F?()=>{N({op:"delete",path:_,instant:!0}).then(e=>{"error"===e?.status&&H(e.error,I)})}:void 0,showClipboardButton:l,onCopy:c,translate:v,customButtons:r.customButtons,nodeData:K,handleKeyboard:w,keyboardControls:E,editConfirmRef:C,jsonStringify:D,showIconTooltips:S,Select:x}),Ye&&e.jsx(x,{name:`${M}-type-select`,value:le?le.enum:ee,onChange:e=>Ie(e),options:ie.map(e=>e instanceof Object&&"enum"in e?e.enum:e)}),We&&e.jsx("span",{className:"jer-error-slug",style:O("error",K),children:B})]})]}),e.jsx(q,{position:"below",nodeData:K})]})},Le=/*#__PURE__*/t.memo(Ie,Pe),Ke=e=>!!e.editOnTypeSwitch&&!!e.component&&!!e.showOnEdit,_e=(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",Me=(t,n,r)=>{const o=Ce.includes(n)?n:"function"==typeof t?"invalid":_e(r.value),{value:a}=r;switch(o){case"string":return e.jsx(he,{...r,value:a});case"number":return e.jsx(fe,{...r,value:a});case"boolean":return e.jsx(ye,{...r,value:a});case"null":return e.jsx(ve,{...r});default:return e.jsx(be,{...r})}},Ve=e=>{if("symbol"==typeof e)return 0;const t=Number(e);return isNaN(t)?0:t},Fe=(e,t,n)=>{switch(t){case"string":return null==e?"":String(e);case"number":return Ve(e);case"boolean":return!!e;case"null":return null;case"object":return{[n]:e};case"array":return[e];default:return String(e)}},ze=r=>{const{getStyles:a}=W(),{open:s,cancel:i,submit:l,areChildrenBeingEdited:c,getSnapshot:u}=Z(),{setCollapseState:d}=te(),{mainContainerRef:p,data:f,nodeData:y,parentData:g,showCollectionCount:v,canDragOnto:b,canAddHere:j,collapseFilter:x,collapseAnimationTime:w,showClipboardButton:E,onCopy:C,showIconTooltips:D,indent:O,sort:T,showArrayIndexes:R,defaultValue:N,newKeyOptions:P,translate:I,customNodeDefinitions:L,customNodeData:K,jsonParse:_,jsonStringify:M,TextEditor:V,Select:F,keyboardControls:z,handleKeyboard:B,insertAtTop:H,onCollapse:Y,editConfirmRef:U,collapseClickZones:$,getLatestData:J}=r,[X,Q]=t.useState(null),q=x(y),{contentRef:ee,isAnimating:re,maxHeight:oe,collapsed:ae,animateCollapse:se,cssTransitionValue:ie}=((e,n,r,o,a)=>{const[s,i]=t.useState(r?0:void 0),[l,c]=t.useState(r),u=t.useRef(!1),d=t.useRef(null),p=t.useRef(0),m=t.useRef(0),h=n/1e3+"s",f=t.useCallback(t=>{if(l!==t){switch(window.clearTimeout(m.current),u.current=!0,t){case!0:{const e=d.current?.offsetHeight??0;p.current=e,i(e),setTimeout(()=>{i(0)},5);break}case!1:i(p.current||((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),s=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(s+30,window.innerHeight-50)})(e,d,o,a))}c(!l),m.current=window.setTimeout(()=>{u.current=!1,t||i(void 0)},n)}},[n,l,e,o,a]);return{contentRef:d,isAnimating:u.current,animateCollapse:f,maxHeight:s,collapsed:l,cssTransitionValue:h}})(f,w,q,p,M),{pathString:le,nodeData:ue,path:de,name:pe,size:me,canEdit:he,canDelete:fe,canAdd:ye,canDrag:ge,error:ve,setError:be,onError:je,derivedValues:Ce,buildKeyDisplayProps:De}=Te({props:r,collapsed:ae}),{dragSourceProps:Se,getDropTargetProps:ke,BottomDropTarget:Ae,DropTargetPadding:Pe}=Re({canDrag:ge,canDelete:fe,canDragOnto:b,canAddHere:j,path:de,nodeData:ue,onError:je,translate:I}),Ie=t.useRef(!q),{isEditing:Ke,isEditingKey:_e,isPending:Me,isArray:Ve}=Ce,Fe=(e=>{const n=t.useRef(e),r=!Object.is(n.current,e);return t.useEffect(()=>{n.current=e}),r})(x);t.useEffect(()=>{const e=x(ue)&&!Ke;Ie.current=!e,se(e),Fe&&d(null)},[x]),((e,n,r)=>{const{commands:o,version:a}=te(),s=t.useRef(0);t.useEffect(()=>{if(a===s.current)return;if(s.current=a,!o)return;let t;for(const n of o)ne(e,n)&&(t=n);t&&(t.collapsed||(n.current=!0),r(t.collapsed))},[a,o])})(de,Ie,se);const ze=t.useRef(null),He=t.useCallback(e=>Q(t=>"function"==typeof e?e(t??M(f)):e),[f,M]),We=t.useCallback(()=>Q(null),[]),Ye=t.useMemo(()=>Ke?X??M(f):null,[Ke,X,f,M]),Ue=t.useCallback((e,t)=>{if("function"!=typeof N)return N;const n=N(e,t);return void 0!==n?n:null},[N]),$e=t.useCallback(e=>P?"function"!=typeof P?P:P(e):null,[P]),{CustomComponent:Je,componentProps:Xe,CustomWrapperComponent:Qe,wrapperProps:Ze={},showKey:Ge=!0,showEditTools:qe=!0,showOnEdit:et,showOnView:tt,showCollectionWrapper:nt=!0,passOriginalNode:rt}=K,ot=G(e=>null!==e.active&&h(e.active.path,de));ot&&ae&&se(!1);const at=ce(de)||0===ue.level,st=t.useRef(n);if(!at&&!ot)return null;const{visibleSize:it}=ue,lt=Array.isArray(f)?"array":"object",ct="array"===lt?{open:"[",close:"]"}:{open:"{",close:"}"},ut=e=>{if("Tab"===e.key&&!e.getModifierState("Shift")&&e.target===ze.current){e.preventDefault();const t=A(ze,"\t");return void Q(t)}B(e,{objectConfirm:pt,cancel:ht})},dt=e=>{e.stopPropagation();const t=k(e);if(t&&z.collapseModifier.includes(t))return Ie.current=!0,void d({collapsed:!ae,path:de,includeChildren:!0});c(de)||(Ie.current=!0,Y&&Y({...ue,fullData:J(),collapsed:!ae,includeChildren:!1}),se(!ae))},pt=e=>{let t=f;if(null!==X)try{t=_(X)}catch{return void je({code:"INVALID_JSON",message:I("ERROR_INVALID_JSON",ue)},X)}be(null);const n="function"==typeof e?e:void 0;l({op:"edit",path:de,value:t,onCommit:()=>{We(),n?.()}}).then(e=>{if("error"===e?.status&&je(e.error,t),"error"===e?.status||"cancel"===e?.status){const e=u().active;"editing"===e?.phase&&m(e.path,de)||We()}})};st.current=pt;const mt=de.length>0?()=>{l({op:"delete",path:de,instant:!0}).then(e=>{"error"===e?.status&&je(e.error,f)})}:void 0,ht=()=>{i(),be(null),We()},ft="when-collapsed"===v?ae:"when-collapsed-or-filtered"===v?ae||null!=it:v,yt=!Ke&&qe,gt=(R||!Ve)&&Ge&&void 0!==pe,vt=Je&&(Ke&&et||!Ke&&tt),bt=Object.entries(f).map(([e,t])=>["array"===lt?Number(e):e,t]);"object"===lt&&T(bt,e=>e);const jt=!Ke||!!Je&&et,xt=()=>e.jsxs("div",{className:"jer-collection-text-edit"+(V?"-custom":""),children:[V?e.jsx(V,{value:Ye??"",onChange:Q,onKeyDown:e=>B(e,{objectConfirm:pt,cancel:ht})}):e.jsx(S,{textAreaRef:ze,className:"jer-collection-text-area",name:le,value:Ye??"",setValue:He,onKeyDown:ut,styles:a("input",ue)}),e.jsx("div",{className:"jer-collection-input-button-row",children:e.jsx(Ee,{onOk:pt,onCancel:ht,nodeData:ue,translate:I,showIconTooltips:D,editConfirmRef:U})})]}),wt=Ie.current?jt?bt.map(([t,n],s)=>{const i={key:t,value:n,path:[...de,t],level:de.length+1,index:s,size:o(n)?Object.keys(n).length:null,parentData:f,fullData:ue.fullData},l=Oe(L,i);return e.jsx("div",{className:"jer-collection-element",style:a("collectionElement",i),children:o(n)&&!l?.renderCollectionAsValue?e.jsx(Be,{...r,data:n,parentData:f,nodeData:i,canDragOnto:he,canAddHere:ye,customNodeData:l},t):e.jsx(Le,{...r,data:n,parentData:f,nodeData:i,canDragOnto:he,canAddHere:ye,showLabel:"object"===lt||R,customNodeData:l},t)},t)}):e.jsx(e.Fragment,{children:xt()}):null,Et=!!nt&&ae&&!ot;Et||(Ie.current=!0);const Ct=I(ae?"TOOLTIP_EXPAND":"TOOLTIP_COLLAPSE",ue),Dt=()=>({...r,data:f,value:f,parentData:g,nodeData:ue,setValue:e=>l({op:"edit",path:de,value:e}),handleEdit:pt,handleCancel:ht,onKeyDown:ut,isEditing:Ke,isPending:Me,setIsEditing:he?()=>s(de,{cancelOp:We,commitOp:e=>st.current(e)}):n,getStyles:a,canDragOnto:he,canAddHere:ye,canEdit:he,keyboardCommon:{}}),St=vt?e.jsx(Je,{componentProps:Xe,...Dt(),originalNode:rt&&Ke?xt():void 0,children:wt}):wt,kt=yt&&e.jsx(we,{startEdit:he?()=>{Ie.current=!0,s(de,{cancelOp:We,commitOp:e=>st.current(e)})}:void 0,handleAdd:ye?e=>{d(null),se(!1);const t=Ue(ue,e);if("array"===lt){const e=H.array?0:f.length,n=H.array?{insert:!0}:{};return void l({op:"add",path:de,key:e,value:t,options:n,instant:!0}).then(e=>{"error"===e?.status&&je(e.error,t)})}if(e in f)return je({code:"KEY_EXISTS",message:I("ERROR_KEY_EXISTS",ue)},e),void i();const n=H.object?{insertBefore:0}:{};l({op:"add",path:de,key:e,value:t,options:n}).then(e=>{"error"===e?.status&&je(e.error,t)})}:void 0,handleDelete:fe?mt:void 0,showClipboardButton:E,onCopy:C,type:lt,nodeData:ue,translate:I,customButtons:r.customButtons,keyboardControls:z,handleKeyboard:B,getNewKeyOptions:$e,editConfirmRef:U,jsonStringify:M,showIconTooltips:D,Select:F}),Ot=De({handleCancel:ht,getStyles:a,keyValueArray:bt,handleClick:$.includes("property")?dt:e=>e.stopPropagation()}),Tt=e.jsxs("div",{className:"jer-component jer-collection-component",style:{marginLeft:(0===de.length?0:O/2)+"em",...a("collection",ue),position:"relative"},draggable:ge&&!Ke&&!_e&&!ot,...Se,...ke("above"),children:[e.jsx("div",{className:"jer-clickzone",style:{width:O/2+1+"em",zIndex:10+2*ue.level},onClick:$.includes("left")?dt:void 0}),!Ke&&Ae,e.jsx(Pe,{position:"above",nodeData:ue}),nt?e.jsxs("div",{className:"jer-collection-header-row",style:{...a("headerRow",ue),position:"relative"},onClick:$.includes("header")?dt:void 0,children:[e.jsxs("div",{className:"jer-collection-name",children:[e.jsx("button",{type:"button",className:"jer-collapse-icon jer-accordion-icon"+(ae?" jer-rotate-90":""),style:{zIndex:11+2*ue.level,transition:ie},onClick:dt,tabIndex:-1,"aria-expanded":!ae,"aria-label":Ct,title:D?Ct:"",children:e.jsx(xe,{name:"collection",nodeData:ue})}),gt&&e.jsx(Ne,{...Ot}),!Ke&&e.jsx("span",{className:"jer-brackets jer-bracket-open",style:a("bracket",ue),children:ct.open})]}),!1!==v&&!Ke&&e.jsx("div",{className:"jer-collection-item-count"+(ft?" jer-visible":" jer-hidden"),style:{...a("itemCount",ue),transition:ie,transitionBehavior:"allow-discrete"},children:null!=it&&it!==me?I("ITEMS_FILTERED",ue,{visible:it,total:me}):1===me?I("ITEM_SINGLE",{...ue,size:1},1):I("ITEMS_MULTIPLE",ue,me)}),e.jsx("div",{className:"jer-brackets"+(Et?" jer-visible":" jer-hidden"),style:{...a("bracket",ue),transition:ie},children:ct.close}),kt]}):Ge?e.jsxs("div",{className:"jer-collection-header-row",style:{...a("headerRow",ue),position:"relative"},children:[e.jsx(Ne,{...Ot}),kt]}):e.jsx(e.Fragment,{}),e.jsxs("div",{className:"jer-collection-inner",style:{overflowY:Et||re?"clip":"visible",maxHeight:ot?void 0:oe,...a("collectionInner",ue),transition:ie},ref:ee,children:[St,e.jsx("div",{className:Ke?"jer-collection-error-row-edit":"jer-collection-error-row",children:ve&&e.jsx("span",{className:"jer-error-slug",style:a("error",ue),children:ve})}),!Ke&&nt&&e.jsx("div",{className:"jer-brackets jer-bracket-outside",style:a("bracket",ue),children:ct.close})]}),e.jsx(Pe,{position:"below",nodeData:ue})]});return Qe?e.jsx(Qe,{wrapperProps:Ze,...Dt(),children:Tt}):Tt},Be=/*#__PURE__*/t.memo(ze,Pe),He=({options:t,value:n,defaultValue:r,onChange:o,placeholder:a,className:s,...i})=>{const l=void 0!==n?{value:n}:{defaultValue:r??""};return e.jsxs("div",{className:"jer-select",children:[e.jsxs("select",{className:s??"jer-select-inner",onChange:e=>o(e.target.value),...i,...l,children:[void 0!==a&&e.jsx("option",{value:"",disabled:!0,children:a}),t.map(t=>e.jsx("option",{value:t,children:t},t))]}),e.jsx("span",{className:"focus"})]})},We=(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}},Ye=({key:e,path:t},n="")=>!!We({value:e},n)||!!t.some(e=>We({value:e},n)),Ue={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)",SHOW_MORE:"Show more",EMPTY_STRING:"<empty string>",TOOLTIP_COPY:"Copy to clipboard",TOOLTIP_EDIT:"Edit",TOOLTIP_DELETE:"Delete",TOOLTIP_ADD:"Add",TOOLTIP_OK:"OK",TOOLTIP_CANCEL:"Cancel",TOOLTIP_COLLAPSE:"Collapse",TOOLTIP_EXPAND:"Expand"};var $e=':root,:host{--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;padding:0 1em 0 0;margin:0;font-family:inherit;font-size:.8em;color:#000;cursor:inherit;line-height:inherit;z-index:1;outline:none}select::-ms-expand{display:none}.jer-select{display:grid;grid-template-areas:"select";align-items:center;position:relative;min-width:12ch;max-width:15ch;border:1px solid var(--jer-select-border);border-radius:.25em;padding:.25em .5em;cursor:pointer;line-height:1.1;background-color:#fff;background-image:linear-gradient(to top,#f9f9f9,#fff 33%)}.jer-select select,.jer-select:after{grid-area:select}.jer-select:not(.jer-select--multiple):after{content:"";justify-self:end;width:.8em;height:.5em;background-color:var(--jer-select-arrow);clip-path:polygon(100% 0%,0 0%,50% 100%)}select:focus+.focus{position:absolute;inset:-1px;border:1px solid var(--jer-select-focus);border-radius:inherit}.jer-select-inner{width:100%;text-overflow:ellipsis}.jer-editor-container{position:relative;font-size:16px;line-height:1;padding:1em 1em 1em 2em;border-radius:.5em;text-align:left}.jer-editor-container textarea{color:var(--jer-input-color);border:var(--jer-form-border);border-radius:.3em;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;outline:none;font-family:inherit}.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{display:flex;min-height:1.7em;gap:.3em;align-items:center}.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{position:absolute;left:-1.2em;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{display:flex;flex-direction:column;gap:.3em;align-items:flex-start;line-height:1.1em}.jer-collection-text-edit{width:fit-content}.jer-collection-text-area{box-sizing:content-box;resize:both;padding:.2em .5em 0;overflow:hidden;max-height:40em;line-height:1.25em;font-family:inherit;font-size:.85em}.jer-collection-input-button-row{display:flex;justify-content:flex-end;width:100%;font-size:150%;margin-top:.4em}.jer-collection-error-row-edit{position:absolute;bottom:.5em}.jer-error-slug{margin-left:1em}.jer-value-component{position:relative}.jer-value-and-buttons{display:flex;justify-content:flex-start;align-items:center;padding-left:.5em}.jer-value-error-row{position:absolute}.jer-value-string{line-height:1.3em;white-space:pre-wrap;overflow-wrap:anywhere;word-break:break-word}.jer-string-expansion{cursor:pointer;opacity:.6;filter:saturate(50%)}.jer-string-expansion.jer-show-less{font-size:80%}.jer-hyperlink{text-decoration:underline}.jer-input-text{box-sizing:content-box;resize:none;margin:0;height:1.4em;padding:.25em .5em .2em;min-width:6em;overflow:hidden;line-height:1.2em;font-family:inherit;font-size:.9em}.jer-input-boolean{transform:scale(1.5);margin-left:.3em;margin-right:.3em}.jer-key-text{word-break:break-word;line-height:1.1em;white-space:pre-wrap}.jer-key-edit{padding:0 .3em;font-size:inherit;font-size:.9em}.jer-value-invalid{opacity:.5;font-style:italic}.jer-input-number{min-width:3em;font-size:90%}.jer-edit-buttons,.jer-confirm-buttons{display:flex;align-items:center;cursor:pointer;height:1em;margin-right:.2em}.jer-edit-buttons>button,.jer-confirm-buttons>button,button.jer-collapse-icon,button.jer-string-expansion{appearance:none;background:none;border:none;margin:0;padding:0;font:inherit;color:inherit;vertical-align:baseline}.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{opacity:1}.jer-value-main-row:hover>.jer-edit-buttons{opacity:1}.jer-value-and-buttons:hover>.jer-edit-buttons{opacity:1}.jer-copy-pulse{position:relative;transition:.3s}.jer-copy-pulse:hover{opacity:.85;transition:.3s;transform:scale(1.2)}.jer-copy-pulse:after{content:"";display:block;position:absolute;border-radius:50%;left:0;top:0;width:100%;height:100%;opacity:0;transition:all .5s;box-shadow:0 0 15px 5px var(--jer-icon-copy-color)}.jer-copy-pulse:active:after{box-shadow:0 0 0 0 var(--jer-icon-copy-color);position:absolute;border-radius:4em;left:0;top:0;opacity:1;transition:0s}.jer-copy-pulse:active{top:.07em}.jer-icon:hover{opacity:.85;transition:.3s;transform:scale(1.2)}.jer-empty-string{font-style:italic;font-size:90%}.jer-drag-n-drop-padding{height:.5em;border:1px dashed #b4b4b4;border-radius:.3em}.jer-clickzone{position:absolute;left:-1em;top:1.2em;height:calc(100% - .8em)}';const Je="data-jer-styles",Xe=(e,t)=>JSON.stringify(e,t,2),Qe={edit:"ERROR_UPDATE",add:"ERROR_ADD",delete:"ERROR_DELETE",rename:"ERROR_RENAME",move:"ERROR_MOVE"},Ze={edit:"UPDATE_ERROR",add:"ADD_ERROR",delete:"DELETE_ERROR",rename:"RENAME_ERROR",move:"MOVE_ERROR"},Ge=e=>{const n=t.useRef(e);e&&(n.current=e);const r=t.useRef((...e)=>n.current(...e));return e?r.current:void 0},qe=[],et=["header","left"],tt={},nt={},rt={},ot=[],at=({data:i,setData:c,buildNodeDataFromPathRef:u,commitRef:d,rootName:m="root",onUpdate:h=n,onChange:f,onError:y,onEditEvent:g,showErrorMessages:v=!0,showClipboardButton:b=!0,onCopy:j,indent:x=2,collapse:E=3,collapseAnimationTime:D=300,showCollectionCount:S="when-collapsed-or-filtered",allowEdit:k=!0,allowDelete:T=!0,allowAdd:A=!0,allowTypeSelection:P=!0,allowDrag:I=!1,searchFilter:L,searchText:K,searchDebounceTime:_=350,sortKeys:M=!1,showArrayIndexes:V=!0,arrayIndexStart:F=0,showStringQuotes:z=!0,showIconTooltips:B=!1,defaultValue:H=null,newKeyOptions:Y,minWidth:U=250,maxWidth:$="min(600px, 90vw)",baseFontSize:J,stringTruncateLength:X=250,translations:Q=tt,className:G,id:q,customText:ee=nt,customNodeDefinitions:ne=qe,customButtons:re=ot,jsonParse:oe=JSON.parse,jsonStringify:ae=Xe,TextEditor:se,Select:le=He,errorDisplayTime:ce=2500,keyboardControls:ue=rt,editorRef:de,insertAtTop:pe=!1,onCollapse:me,collapseClickZones:he=et})=>{const{getStyles:fe,cssVars:ye}=W(),{open:ge,cancel:ve,getSnapshot:be}=Z(),je=t.useMemo(()=>lt(E),[E]),xe=t.useMemo(()=>((e,t)=>(n,r,o)=>((e,t,n,r,o)=>{if(t[r]){const e=t[r](n);if(null!==e)return e}let s=r in e?e[r]:Ue[r];if(void 0!==o){const e=a(o)?o:{count:o};for(const[t,n]of Object.entries(e))s=s?.replace(`{{${t}}}`,String(n))}return s})(e,t,r,n,o))(Q,ee),[Q,ee]),[we,Ee]=t.useState(K),Ce=t.useRef(null);t.useEffect(()=>{ve();const e=setTimeout(()=>Ee(K),_);return()=>clearTimeout(e)},[K,_]);const De=C(i,[],m),Se=t.useRef(i);Se.current=i;const ke=t.useRef(c);ke.current=c;const Te=t.useRef(xe);Te.current=xe;const Re=t.useRef(De);Re.current=De;const Ne=t.useRef(h);Ne.current=h;const Ae=t.useRef(m);Ae.current=m;const Pe=t.useRef(void 0),Ie=t.useCallback(()=>Se.current,[]),Ke=Ge(f),_e=Ge(y),Me=Ge(me),Ve=Ge(g),Fe=Ge(j),ze=t.useCallback(e=>{Se.current=e,ke.current(e)},[]),Ye=t.useCallback((e,t)=>{ze(it(Se.current,e,t,"update").newData)},[ze]),$e=t.useCallback(e=>{const t=Se.current,n=Ae.current,r=Pe.current,o=ze,{op:a,path:s}=e;switch(a){case"edit":{const{newData:a,currentValue:i,newValue:l}=it(t,s,e.value,"update"),c=C(t,s,n,r);return{input:{...c,newData:a,event:"edit",newValue:l},nodeData:c,isNoOp:i===l,apply:()=>o(a),revert:()=>o(it(Se.current,s,i,"update").newData)}}case"delete":{const{newData:e,currentValue:a}=it(t,s,"","delete"),i=C(t,s,n,r);return{input:{...i,newData:e,event:"delete"},nodeData:i,isNoOp:!1,apply:()=>o(e),revert:()=>o(it(Se.current,s,a,"add",{insert:!0,insertBefore:i.index}).newData)}}case"add":{const a=[...s,e.key],{newData:i,newValue:l}=it(t,a,e.value,"add",e.options),c=C(i,a,n,r);return{input:{...c,value:void 0,size:null,parentData:w(t,s)??null,fullData:t,newData:i,event:"add",newValue:l},nodeData:c,isNoOp:!1,apply:()=>o(i),revert:()=>o(it(Se.current,a,"","delete").newData)}}case"rename":{const a=s.slice(0,-1),i=s[s.length-1],{newKey:l}=e,c=w(t,a),u=Object.fromEntries(Object.entries(c).map(([e,t])=>e===i?[l,t]:[e,t])),{newData:d}=it(t,a,u,"update"),p=C(t,s,n,r);return{input:{...p,newData:d,event:"rename",newKey:l},nodeData:p,isNoOp:i===l,apply:()=>o(d),revert:()=>o(it(Se.current,a,c,"update").newData),extra:{oldKey:i,newKey:l}}}case"move":{const a=s,{path:i,position:l}=e.to,c=t,{newData:u,currentValue:d}=it(t,a,"","delete"),p=a.slice(-1)[0],m=i.slice(0,-1),h=i.slice(-1)[0];let f="number"==typeof h?"above"===l?h:h+1:"number"==typeof p?`arr_${p}`:p;a.slice(0,-1).join(".")===i.slice(0,-1).join(".")&&"number"==typeof p&&"number"==typeof f&&p<f&&(f-=1);const y="number"==typeof f?{insert:!0}:"above"===l?{insertBefore:h}:{insertAfter:h},g=[...m,f],{newData:v}=it(u,g,d,"add",y),b=C(t,a,n,r);return{input:{...b,newData:v,event:"move",newPath:g},nodeData:b,isNoOp:!1,apply:()=>o(v),revert:()=>o(c)}}}},[ze]),Je=t.useCallback((e,t)=>{const n=Ze[e.event],r=()=>Te.current(Qe[e.event],Re.current),o=e=>{const t=e instanceof Error&&e.message?e.message:"string"==typeof e&&e?e:r();return{status:"error",error:{code:n,message:t}}},a=t=>{if(!1===t)return{status:"error",error:{code:n,message:r()}};if(null===t)return{status:"cancel"};if(t&&"object"==typeof t){if(void 0!==t.error)return"string"==typeof t.error?{status:"error",error:{code:n,message:t.error}}:{status:"error",error:t.error};const r=void 0!==t.data,o=void 0!==t.value;if(r&&o&&console.warn("json-edit-react: onUpdate returned both { value } and { data }; { data } (whole-document) takes precedence and { value } is ignored."),r)return{status:"override",value:t.data,path:[]};if(o&&("edit"===e.event||"add"===e.event))return{status:"override",value:t.value,path:e.path}}return{status:"commit"}};let i;try{i=Ne.current(e,t)}catch(e){return o(e)}return s(i)?i.then(a,o):a(i)},[]),at=t.useMemo(()=>({runUpdate:h===n?void 0:Je,buildCommit:$e,applyValue:Ye}),[Je,$e,Ye,h]);d.current=at;const st=t.useMemo(()=>lt(k),[k]),dt=t.useMemo(()=>lt(T),[T]),pt=t.useMemo(()=>lt(A),[A]),mt=t.useMemo(()=>lt(I),[I]),ht=t.useMemo(()=>ct(L),[L]),ft=t.useMemo(()=>((e,t,n)=>{if(!t&&!n)return null;const r=new Set,a=new Map,s=t??We,i=n??"",l=e=>{let t=s(e,i);if(o(e.value)){let n=0;const r=Array.isArray(e.value),s=Object.entries(e.value);for(const[a,i]of s){const s=r?Number(a):a,c={key:s,path:[...e.path,s],level:e.level+1,index:n,value:i,size:o(i)?Object.keys(i).length:null,parentData:e.value,fullData:e.fullData};l(c)&&(t=!0,n++)}a.set(p(e.path),n)}return t&&r.add(p(e.path)),t};return l(e),{visiblePaths:r,visibleChildCounts:a}})(De,ht,we),[i,we,ht,m]),yt=t.useMemo(()=>(e=>{const t={...R};for(const n of Object.keys(R)){const o=n,a=e[o];if(void 0===a)continue;const s="clipboardModifier"===n||"collapseModifier"===n;if(null===a){t[o]=s?[]:null;continue}const i=(()=>s?r(a):"string"==typeof a?{key:a}:a)();t[o]=i}return N.forEach(n=>{void 0===e[n]&&void 0!==e.confirm&&(t[n]=t.confirm)}),t})(ue),[ue]),gt=t.useCallback((e,t)=>((e,t,n)=>{for(const[r,o]of Object.entries(t))if(O(n,e[r],r)){n.preventDefault(),o();break}})(yt,t,e),[yt]),vt=t.useMemo(()=>{const e=ut(ne,"stringifyReplacer");return t=>ae(t,e)},[ne,ae]),bt=t.useMemo(()=>{const e=ut(ne,"parseReviver");return t=>{const n=oe(t,e);return l(n)}},[ne,oe]),jt=t.useRef(null),{setCollapseState:xt}=te(),wt=t.useCallback((e,t)=>{!1!==M&&("function"!=typeof M?e.sort((e,n)=>{const r=t(e)[0],o=t(n)[0];return r<o?-1:r>o?1:0}):e.sort((e,n)=>M(t(e),t(n))))},[M]);Pe.current=wt;const Et=t.useCallback(e=>C(Ie(),e,Ae.current,Pe.current),[Ie]);u.current=Et,t.useImperativeHandle(de,()=>{const e=Symbol("path-missing");return{collapse:e=>xt(e),startEdit:({path:t,overrideRestrictions:n=!1})=>w(Ie(),t,e)===e?"PATH_NOT_FOUND":n||st(C(Ie(),t,m,wt))?(ge(t,{force:!0}),!0):"RESTRICTED",confirm:()=>{jt.current&&(jt.current.click(),"editing"!==be().active?.phase&&ve())},cancel:()=>ve()}},[xt,ge,ve,be,st,Ie,m,wt]);const Ct=Oe(ne,De),Dt=t.useMemo(()=>({object:!0===pe||"object"===pe,array:!0===pe||"array"===pe}),[pe]),St={mainContainerRef:Ce,name:m,nodeData:De,getLatestData:Ie,onChange:Ke,onError:_e,onEditEvent:Ve,showErrorMessages:v,showCollectionCount:S,collapseFilter:je,collapseAnimationTime:D,allowEditFilter:st,allowDeleteFilter:dt,allowAddFilter:pt,allowTypeSelection:P,allowDragFilter:mt,canDragOnto:!1,canAddHere:!1,showClipboardButton:b,onCopy:Fe,sortKeys:M,sort:wt,showArrayIndexes:V,arrayIndexStart:F,showStringQuotes:z,showIconTooltips:B,indent:x,defaultValue:H,newKeyOptions:Y,stringTruncateLength:X,translate:xe,customNodeDefinitions:ne,customNodeData:Ct,customButtons:re,parentData:null,jsonParse:bt,jsonStringify:vt,TextEditor:se,Select:le,errorDisplayTime:ce,handleKeyboard:gt,keyboardControls:yt,insertAtTop:Dt,onCollapse:Me,editConfirmRef:jt,collapseClickZones:he},kt={...fe("container",De),...ye,minWidth:U,maxWidth:$};return kt.fontSize=J??kt.fontSize,e.jsx("div",{id:q,ref:Ce,className:`jer-editor-container ${G??""}`,style:kt,children:e.jsx(ie,{value:ft,children:o(i)&&!Ct.renderCollectionAsValue?e.jsx(Be,{data:i,...St}):e.jsx(Le,{data:i,showLabel:!0,...St})})})};function st(n){t.useInsertionEffect(()=>{(()=>{if("undefined"==typeof document)return;const e=document.head.querySelector(`style[${Je}]`);if(e)return void(e.textContent!==$e&&(e.textContent=$e));const t=document.createElement("style");t.setAttribute(Je,""),t.textContent=$e,document.head.appendChild(t)})()},[]);const r=t.useRef(void 0),o=t.useRef(void 0),a=n;return e.jsx(H,{theme:a.theme??_,children:e.jsx(ae,{onEditEvent:a.onEditEvent,onCollapse:a.onCollapse,buildNodeDataFromPathRef:r,commitRef:o,children:e.jsx(at,{...a,buildNodeDataFromPathRef:r,commitRef:o})})})}const it=(e,t,n,r,o={})=>{if(0===t.length)return{currentData:e,newData:n,currentValue:e,newValue:n};const a={remove:"delete"===r,...o},s="add"!==r?w(e,t):void 0;return{currentData:e,newData:v(e,t,n,a),currentValue:s,newValue:"delete"!==r?n:void 0}},lt=e=>"boolean"==typeof e?()=>e:"number"==typeof e?({level:t})=>t>=e:e,ct=e=>{if(void 0!==e)return"value"===e?We:"key"===e?Ye:"all"===e?(e,t)=>We(e,t)||Ye(e,t):e},ut=(e,t)=>{const n="stringifyReplacer"===t?[e=>void 0===e?c: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}};exports.AutogrowTextArea=S,exports.IconSvg=je,exports.JsonEditor=st,exports.JsonViewer=function(r){const{editorRef:o,...a}=r,s=t.useRef(null);return t.useImperativeHandle(o,()=>({collapse:e=>s.current?.collapse(e)}),[]),e.jsx(st,{...a,editorRef:s,setData:n,allowEdit:!1,allowAdd:!1,allowDelete:!1,allowDrag:!1})},exports.StringDisplay=pe,exports.StringEdit=me,exports.assign=v,exports.collectionDataTypes=De,exports.defaultTheme=_,exports.extract=w,exports.isCollection=o,exports.matchNode=We,exports.matchNodeKey=Ye,exports.splitPropertyString=u,exports.standardDataTypes=Se,exports.toPathString=p,exports.useKeyboardListener=ge,exports.valueDataTypes=Ce;
1
+ "use strict";var e=require("react/jsx-runtime"),t=require("react");const n=()=>{},r=e=>Array.isArray(e)?e:[e],o=e=>null!==e&&"object"==typeof e,a=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),s=e=>null!=e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof e.then,i=(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},l=e=>{if(e!==c){if(e&&"object"==typeof e)for(const t in e){const n=e[t],r=l(n);r!==n&&(e[t]=r)}return e}},c="__​undefined__",u=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}`,""),p=e=>1===e.length&&""===e[0]?"\0":e.map(e=>encodeURIComponent(String(e))).join("/"),m=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),h=(e,t)=>e.length>=t.length&&t.every((t,n)=>t===e[n]),f=(e,t,n,r,o)=>{if(!r)throw new Error(o??`Invalid property path: ${t}\nCouldn't access "${n}" in ${JSON.stringify(e)}`)},y=e=>Array.isArray(e),g=(e,t)=>e.filter((e,n)=>n!==t),v=(e,t,n,r={})=>{const{remove:o=!1,createNew:a=!0,noError:s=!1}=r,i=e,l=d(t),c={...r,remove:o,createNew:a,noError:s,fullData:i,fullPath:l},p=Array.isArray(t)?t:u(t);return y(e)&&o&&1===p.length?g(e,p[0]):b(e,p,n,c)},b=(e,t,n,r)=>{const o=a(e)?{...e}:null,s=y(e)?[...e]:null;if(0===t.length)return e;if(!o&&!s)throw new Error("Can't assign property -- invalid input object");const{createNew:i,remove:l,noError:c,fullData:u,fullPath:d}=r,p=t[0];if(s&&"string"==typeof p)return s.map(e=>b(e,t,n,r));if(1===t.length)return o&&"string"==typeof p?j(o,p,n,r)??o:s&&"number"==typeof p?(x(s,p,n,r),s):(f(u,d,p,c),e);const m=o||s||[];if(l&&2===t.length&&"number"==typeof t[1]){const e=m[p],n=t[1];return y(e)?m[p]=g(e,n):f(u,d,p,c,"Trying to remove an indexed item from an object that is not an array"),m}const h=t.slice(1);if(p in e){if(v=m[p],!y(v)&&!a(v)){if(!i)return f(u,d,p,c),m;m[p]={}}return m[p]=b(m[p],h,n,r),m}var v;if(i){const e="number"==typeof h[0]?[]:{};if(o)return m[p]=e,m[p]=b(m[p],h,n,r),m;if(s&&Array.isArray(m)){m.push(e);const t=m.length-1;return m[t]=b(m[t],h,n,r),m}}return f(u,d,p,c),m},j=(e,t,n,r)=>{const{remove:o,createNew:a,noError:s,insertAfter:i,insertBefore:l,fullData:c,fullPath:u}=r;if(void 0!==l||void 0!==i){const r=Object.entries(e);let o;return o="number"==typeof l?l:"number"==typeof i?i:r.findIndex(([e])=>e===(l??i)),void 0!==i&&o++,r.splice(o,0,[t,n]),Object.fromEntries(r)}const d=t in e;o?d?delete e[t]:f(c,u,t,s):a||d?e[t]=n:f(c,u,t,s)},x=(e,t,n,r)=>{const{noError:o,fullData:a,fullPath:s,createNew:i,insert:l}=r;l&&e.splice(t,0,n),t in e?e[t]=n:i?e.push(n):f(a,s,t,o)},w=(e,t,n)=>{const r=Array.isArray(t)?t:u(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=>w(e,r,n));if("object"!=typeof e||null===e||!(o in e))return E(e,o,n);const a=e[o];return 1===r.length?a:w(a,r.slice(1),n)},E=(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},C=(e,t,n="",r)=>{if(0===t.length)return{key:n,path:[],level:0,index:0,value:e,size:o(e)?Object.keys(e).length:1,parentData:null,fullData:e};const a=t[t.length-1],s=w(e,t),i=w(e,t.slice(0,-1))??null;let l=0;if(Array.isArray(i))l="number"==typeof a?a:Number(a);else if(i&&"object"==typeof i){const e=Object.entries(i);r?.(e,e=>e),l=e.findIndex(([e])=>e===a)}return{key:a,path:t,level:t.length,index:l,value:s,size:o(s)?Object.keys(s).length:null,parentData:i,fullData:e}},D="undefined"!=typeof window?t.useLayoutEffect:t.useEffect,S=({className:n,name:r,value:o,setValue:a,onKeyDown:s,styles:i,textAreaRef:l})=>{const c=t.useRef(null);if(D(()=>{const e=c.current;c.current=null;const t=l?.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,l]),"string"!=typeof o)return null;const u="\n"===o.slice(-1)?o+".":o;return e.jsxs("div",{style:{display:"grid"},children:[e.jsx("textarea",{id:`${r}_textarea`,ref:l,style:{height:"auto",gridArea:"1 / 1 / 2 / 2",overflowY:"auto",whiteSpace:"pre-wrap",...i},rows:1,className:n,name:`${r}_textarea`,value:o,onChange:e=>{const{value:t,selectionStart:n}=e.target;c.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:s}),e.jsx("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",...i},children:u})]})},k=e=>e.shiftKey?"Shift":e.metaKey?"Meta":e.ctrlKey?"Control":e.altKey?"Alt":void 0,O=(e,t,n)=>{if(!t)return!1;const r=e.key,o=k(e);if(Array.isArray(t))return!!o&&t.includes(o);const{key:a,modifier:s}=t;return("stringLineBreak"!==n||"Enter"!==r||"Shift"!==o||"Enter"!==a||!s?.includes("Shift"))&&r===a&&(s===o||Array.isArray(s)&&s.includes(o))},T={key:"Enter"},R={confirm:T,cancel:{key:"Escape"},objectConfirm:{...T,modifier:["Meta","Shift","Control"]},objectLineBreak:T,stringConfirm:T,stringLineBreak:{...T,modifier:["Shift"]},numberConfirm:T,numberUp:{key:"ArrowUp"},numberDown:{key:"ArrowDown"},tabForward:{key:"Tab"},tabBack:{key:"Tab",modifier:"Shift"},booleanConfirm:T,booleanToggle:{key:" "},clipboardModifier:["Meta","Control"],collapseModifier:["Alt"]},N=["stringConfirm","numberConfirm","booleanConfirm"],A=(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},P=(e,t,n="next",r,a)=>{const s=t.slice(0,t.length-1),i=t.slice(-1)[0];if(void 0===i)return null;const l=w(e,s),c=L(l);Array.isArray(l)||r(c,({key:e,value:t})=>[e,t]);const u=c.findIndex(e=>e.key===i),d=c[u+("next"===n?1:-1)];if(!d)return 0===s.length?null:P(e,s,n,r,a);let p;if(o(d.value)){if(0===Object.keys(d.value).length)return P(e,[...s,d.key],n,r,a);p=I(e,[...s,d.key],n,r)}else p=[...s,d.key];return p?a(C(e,p,"",r))?p:P(e,p,n,r,a):null},I=(e,t,n="next",r)=>{const a=w(e,t);if(!o(a))return t;const s=Array.isArray(a)?a.map((e,t)=>t):Object.keys(a);r(s,e=>[e,a]);const i="next"===n?s[0]:s[s.length-1];return I(e,[...t,i],n,r)},L=e=>Array.isArray(e)?e.map((e,t)=>({value:e,key:t})):Object.entries(e).map(([e,t])=>({key:e,value:t})),K={fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2},_={displayName:"Default",icons:{add:{content:/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx("path",{d:"M13 7h-2v4H7v2h4v4h2v-4h4v-2h-4z"}),/*#__PURE__*/e.jsx("path",{d:"M12 2C6.486 2 2 6.486 2 12s4.486 10 10 10 10-4.486 10-10S17.514 2 12 2zm0 18c-4.411 0-8-3.589-8-8s3.589-8 8-8 8 3.589 8 8-3.589 8-8 8z"})]})},edit:{content:/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx("path",{d:"M7 17.013l4.413-.015 9.632-9.54c.378-.378.586-.88.586-1.414s-.208-1.036-.586-1.414l-1.586-1.586c-.756-.756-2.075-.752-2.825-.003L7 12.583v4.43zM18.045 4.458l1.589 1.583-1.597 1.582-1.586-1.585 1.594-1.58zM9 13.417l6.03-5.973 1.586 1.586-6.029 5.971L9 15.006v-1.589z"}),/*#__PURE__*/e.jsx("path",{d:"M5 21h14c1.103 0 2-.897 2-2v-8.668l-2 2V19H8.158c-.026 0-.053.01-.079.01-.033 0-.066-.009-.1-.01H5V5h6.847l2-2H5c-1.103 0-2 .897-2 2v14c0 1.103.897 2 2 2z"})]}),svgProps:{transform:"translate(0, 0.5)"}},delete:{content:/*#__PURE__*/e.jsx("path",{d:"M6 19a2 2 0 002 2h8a2 2 0 002-2V7H6v12m2.46-7.12l1.41-1.41L12 12.59l2.12-2.12 1.41 1.41L13.41 14l2.12 2.12-1.41 1.41L12 15.41l-2.12 2.12-1.41-1.41L10.59 14l-2.13-2.12M15.5 4l-1-1h-5l-1 1H5v2h14V4h-3.5z"}),scale:1.04},copy:{content:/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx("path",{d:"M9 2 H15 A1 1 0 0 1 16 3 V5 A1 1 0 0 1 15 6 H9 A1 1 0 0 1 8 5 V3 A1 1 0 0 1 9 2 z"}),/*#__PURE__*/e.jsx("path",{d:"M8 4H6a2 2 0 00-2 2v14a2 2 0 002 2h12a2 2 0 002-2v-2M16 4h2a2 2 0 012 2v4M21 14H11"}),/*#__PURE__*/e.jsx("path",{d:"M15 10l-4 4 4 4"})]}),svgProps:K,scale:.86},ok:{content:/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx("path",{d:"M22 11.08V12a10 10 0 11-5.93-9.14"}),/*#__PURE__*/e.jsx("path",{d:"M22 4L12 14.01l-3-3"})]}),svgProps:K,scale:.9},cancel:{content:/*#__PURE__*/e.jsx("path",{d:"M12 4c-4.411 0-8 3.589-8 8s3.589 8 8 8 8-3.589 8-8-3.589-8-8-8zm-5 8c0-.832.224-1.604.584-2.295l6.711 6.711A4.943 4.943 0 0112 17c-2.757 0-5-2.243-5-5zm9.416 2.295L9.705 7.584A4.943 4.943 0 0112 7c2.757 0 5 2.243 5 5 0 .832-.224 1.604-.584 2.295z"}),svgProps:{baseProfile:"tiny"},scale:1.3},collection:{content:/*#__PURE__*/e.jsx("path",{d:"M233.4 406.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L256 338.7 86.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z"}),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"}},M={container:"backgroundColor",collection:"backgroundColor",collectionInner:"backgroundColor",collectionElement:"backgroundColor",headerRow:"backgroundColor",valueRow:"backgroundColor",dropZone:"borderColor",inputHighlight:"backgroundColor"},V=e=>[_,...r(e)].map(e=>"styles"in e?e:{styles:e}),F=e=>{const t={};for(const{icons:n}of V(e))n&&Object.assign(t,n);return t},z={getStyles:()=>({}),icons:/*#__PURE__*/F(_),cssVars:{}},B=t.createContext(z),H=({theme:n=_,children:r})=>{const o=t.useMemo(()=>(e=>{var t;const n=V(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?{[M[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],s=o[t];a[t]=s?e=>s.reduce((t,n)=>({...t,...n(e)??{}}),n):n}return a})(n),[n]),a=t.useMemo(()=>/*#__PURE__*/F(n),[n]),s=t.useMemo(()=>(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})(o),[o]),i=t.useCallback((e,t)=>((e,t,n)=>{const r=e[t];return"function"==typeof r?r(n):r??{}})(o,e,t),[o]),l=t.useMemo(()=>({getStyles:i,icons:a,cssVars:s}),[i,a,s]);return e.jsx(B.Provider,{value:l,children:r})},W=()=>t.useContext(B),Y={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"}},U=(e,t)=>Y[e][t]??null,$=(e,t)=>null!==e&&null!==t&&e.op===t.op&&m(e.path,t.path),J={active:null,settling:{}},X=t.createContext(null),Q=({children:n,onEditEvent:r,buildNodeDataFromPathRef:o,commitRef:a})=>{const i=t.useRef(r);i.current=r;const l=t.useRef(null);return null===l.current&&(l.current=((e,t,n)=>{let r=J;const o=new Set;let a=null,i=null,l=!1,c=0;const u=e=>{r=e,o.forEach(e=>e())},d=(t,n,r)=>{e.current?.({...t,...r,event:n})},f=(n,o,s)=>{if(!e.current)return;let l;try{l=t.current?.(n)}catch{return u({...r,active:null}),a=null,void(i=null)}l&&d(l,o,s)},y=(e,t)=>{var n;a=t?.cancelOp??null,i=t?.commitOp??null,n=e,$(r.active,n)&&r.active?.phase===n?.phase||u({...r,active:n});const o=U(e.op,"start");o&&f(e.path,o)},g=(e,t,o,s,l,c,h,f,y)=>{const g=p(e);if(!h()){if("cancel"===s.status||"error"===s.status){r.active&&m(r.active.path,e)&&("held"===r.active.phase||"editing"===r.active.phase)&&(u({...r,active:null}),a=null,i=null);const n=U(t,"cancel");return n&&d(f,n),"error"===s.status&&d(f,"updateError",{operation:t,error:s.error}),s}l()}if(r.settling[g]===o){switch((e=>{if(!(e in r.settling))return;const t={...r.settling};delete t[e],u({...r,settling:t})})(g),s.status){case"cancel":c();break;case"error":c(),d(f,"updateError",{operation:t,error:s.error});break;case"override":n.current?.applyValue(s.path,s.value),d(f,"updateSuccess",{operation:t,...y});break;case"commit":d(f,"updateSuccess",{operation:t,...y})}return s}};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,s=null!==o&&!$(o,n);if(s&&i)return void i(()=>y(n,t));const l=a;if(a=null,i=null,l&&l(),s&&$(r.active,o)){const e=U(o.op,"cancel");e&&f(o.path,e)}y(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&&u({...r,active:null});const t=U(e.op,"cancel");t&&f(e.path,t)}}finally{l=!1}},submit:e=>{const{op:t,path:o,instant:l,onCommit:m}=e,h=n.current;let y;try{y=h?.buildCommit(e)??null}catch{return $(r.active,{path:o,op:t})&&u({...r,active:null}),a=null,i=null,m?.(),Promise.resolve(void 0)}const v=y?.extra,b=p(o),j=++c;if(!l){const e=U(t,"submit");e&&f(o,e)}if(!y||y.isNoOp){$(r.active,{path:o,op:t})&&u({...r,active:null}),a=null,i=null;const e=U(t,"commit");return e&&(y?d(y.nodeData,e,v):f(o,e,v)),m?.(),Promise.resolve(void 0)}const{input:x,nodeData:w,apply:E,revert:C}=y,D=!!h?.runUpdate;let S=!1,k=!1;const O=()=>{if(S)return;S=!0,E(),a=null,i=null,$(r.active,{path:o,op:t})&&u({...r,active:null}),D&&((e,t)=>{u({...r,settling:{...r.settling,[e]:t}})})(b,j);const e=U(t,"commit");e&&d(w,e,v),m?.()},T={hold:()=>(k=!0,u({...r,active:{path:o,op:t,phase:"held",force:r.active?.force}}),()=>O())};if(!D)return O(),Promise.resolve(void 0);const R=h.runUpdate(x,T),N=s(R);if(!k&&!l&&!N)return Promise.resolve(g(o,t,j,R,O,C,()=>S,w,v));const A=N?R:Promise.resolve(R);let P;return k||(l?P=setTimeout(O,100):O()),A.then(e=>(clearTimeout(P),g(o,t,j,e,O,C,()=>S,w,v)))},areChildrenBeingEdited:e=>null!==r.active&&h(r.active.path,e)}})(i,o,a)),e.jsx(X.Provider,{value:l.current,children:n})},Z=()=>{const e=t.useContext(X);if(!e)throw new Error("Missing Editing Context Provider");return e},G=e=>{const n=Z();return t.useSyncExternalStore(n.subscribe,()=>e(n.getSnapshot()),()=>e(n.getServerSnapshot()))},q=t.createContext(null),ee=({children:n,onCollapse:o,buildNodeDataFromPathRef:a})=>{const[s,i]=t.useState({commands:null,version:0}),l=t.useRef(o);l.current=o;const c=t.useCallback(e=>{if(null===e)return void i(e=>null===e.commands?e:{commands:null,version:e.version});const t=r(e),n=t.map(e=>({...e,path:[...e.path]}));i(e=>({commands:n,version:e.version+1}));const o=l.current;o&&t.forEach(e=>{const t=a.current?.(e.path);t&&o({...t,collapsed:e.collapsed,includeChildren:e.includeChildren})})},[a]),u=t.useMemo(()=>({commands:s.commands,version:s.version,setCollapseState:c}),[s.commands,s.version,c]);return e.jsx(q.Provider,{value:u,children:n})},te=()=>{const e=t.useContext(q);if(!e)throw new Error("Missing Collapse Context Provider");return e},ne=(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},re=t.createContext(null),oe=({children:n})=>{const[r,o]=t.useState({path:null,canDelete:!1}),a=t.useRef(!1),s=t.useMemo(()=>({dragSource:r,setDragSource:o,armed:a}),[r]);return e.jsx(re.Provider,{value:s,children:n})},ae=({children:t,onEditEvent:n,onCollapse:r,buildNodeDataFromPathRef:o,commitRef:a})=>e.jsx(Q,{onEditEvent:n,buildNodeDataFromPathRef:o,commitRef:a,children:e.jsx(ee,{onCollapse:r,buildNodeDataFromPathRef:o,children:e.jsx(oe,{children:t})})}),se=t.createContext(void 0),ie=({value:t,children:n})=>e.jsx(se.Provider,{value:t,children:n}),le=()=>{const e=t.useContext(se);if(void 0===e)throw new Error("Missing FilterStateProvider");return e},ce=e=>{const t=le();return null===t||t.visiblePaths.has(p(e))},ue=e=>{const t=le();return null===t?null:t.visibleChildCounts.get(p(e))??null},de="**INVALID_FUNCTION**",pe=({nodeData:n,showStringQuotes:r=!0,stringTruncateLength:o=200,pathString:a,canEdit:s,setIsEditing:i,styles:l,translate:c,showIconTooltips:u=!1,value:d,TextWrapper:p=({children:e})=>e})=>{const m=d??n.value,[h,f]=t.useState(!1),y=r?'"':"",g=m.length>o,v=()=>{s?i(!0):f(!h)},b=c("SHOW_MORE",n);return e.jsxs("div",{id:`${a}_display`,onDoubleClick:v,onClick:e=>{(e.getModifierState("Control")||e.getModifierState("Meta"))&&v()},className:"jer-value-string",style:l,children:[y,g?h?e.jsxs(e.Fragment,{children:[e.jsx(p,{children:e.jsxs("span",{children:[m,y]})})," ",e.jsx("button",{type:"button",tabIndex:-1,className:"jer-string-expansion jer-show-less",onClick:()=>f(!1),children:c("SHOW_LESS",n)})]}):e.jsxs(e.Fragment,{children:[e.jsxs(p,{children:[e.jsx("span",{children:m.slice(0,o-2).trimEnd()})," "]}),e.jsx("button",{type:"button",tabIndex:-1,className:"jer-string-expansion jer-ellipsis",onClick:()=>f(!0),"aria-label":b,title:u?b:"",children:"..."}),y]}):e.jsx(p,{children:`${m}${y}`})]})},me=({styles:n,pathString:r,value:o,setValue:a,handleEdit:s,handleKeyboard:i,keyboardCommon:l})=>{const c=t.useRef(null);return e.jsx(S,{className:"jer-input-text",textAreaRef:c,name:r,value:o,setValue:a,onKeyDown:e=>{i(e,{stringConfirm:s,stringLineBreak:()=>{const e=A(c,"\n");a(e)},...l})},styles:n})},he=({isEditing:t,path:n,enumType:r,...o})=>{const{getStyles:a}=W(),s=p(n),{value:i,setValue:l,nodeData:c,handleEdit:u,handleKeyboard:d,keyboardCommon:m,Select:h}=o;return t&&r?e.jsx(h,{name:`${s}-value-select`,value:i,onChange:l,options:r.values,autoFocus:!0,onKeyDown:e=>d(e,{stringConfirm:u,...m})}):t?e.jsx(me,{styles:a("input",c),pathString:s,...o,setValue:o.setValue}):e.jsx(pe,{pathString:s,styles:a("string",c),...o})},fe=({value:t,setValue:n,isEditing:r,path:o,setIsEditing:a,handleEdit:s,nodeData:i,handleKeyboard:l,keyboardCommon:c})=>{const{getStyles:u}=W();return r?e.jsx("input",{className:"jer-input-number",type:"text",name:p(o),value:t,onChange:e=>n(e.target.value.replace(/[^0-9.-]/g,"")),autoFocus:!0,onFocus:e=>setTimeout(()=>e.target.select(),10),onKeyDown:e=>l(e,{numberConfirm:s,numberUp:()=>n(Number(t)+1),numberDown:()=>n(Number(t)-1),...c}),style:{width:String(t).length/1.5+2+"em",...u("input",i)}}):e.jsx("span",{onDoubleClick:()=>a(!0),className:"jer-value-number",style:u("number",i),children:t})},ye=({value:t,setValue:n,isEditing:r,path:o,setIsEditing:a,handleEdit:s,nodeData:i,handleKeyboard:l,keyboardCommon:c})=>{const{getStyles:u}=W();return"boolean"!=typeof t?null:r?e.jsx("input",{className:"jer-input-boolean",type:"checkbox",name:p(o),checked:t,onChange:()=>n(!t),onKeyDown:e=>{" "===e.key&&e.preventDefault(),l(e,{booleanConfirm:s,booleanToggle:()=>n(!t),...c})},autoFocus:!0}):e.jsx("span",{onDoubleClick:()=>a(!0),className:"jer-value-boolean",style:u("boolean",i),children:String(t)})},ge=(e,n)=>{const r=t.useRef(void 0),o=t.useRef(n);t.useEffect(()=>{o.current=n},[n]);const a=e=>{o.current(e)};t.useEffect(()=>{if(window.clearTimeout(r.current),e)return r.current=window.setTimeout(()=>{window.addEventListener("keydown",a)},100),()=>{window.clearTimeout(r.current),window.removeEventListener("keydown",a)}},[e])},ve=({value:t,isEditing:n,setIsEditing:r,handleEdit:o,nodeData:a,handleKeyboard:s,keyboardCommon:i})=>{const{getStyles:l}=W();return ge(n,e=>s(e,{confirm:o,...i})),e.jsx("div",{onDoubleClick:()=>r(!0),className:"jer-value-null",style:l("null",a),children:String(t)})},be=({value:t})=>{let n="Error!";switch(typeof t){case"string":t===de&&(n="Function");break;case"undefined":n="Undefined";break;case"symbol":n="Symbol"}return e.jsx("span",{className:"jer-value-invalid",children:n})},je=({scale:t=1,viewBox:n="0 0 24 24",fill:r="currentColor",children:o,...a})=>{const s=1.4*t+"em";return e.jsx("svg",{viewBox:n,fill:r,width:s,height:s,...a,children:o})},xe=({name:t,nodeData:n})=>{const{getStyles:r,icons:o}=W(),a=o[t],s=`icon${t[0].toUpperCase()}${t.slice(1)}`;return e.jsx(je,{viewBox:a.viewBox,...a.svgProps,scale:a.scale,className:"collection"===t?void 0:"jer-icon",style:r(s,n),children:a.content})},we=({startEdit:n,handleDelete:r,handleAdd:o,showClipboardButton:a,onCopy:s,type:i,customButtons:l,nodeData:c,translate:u,keyboardControls:p,handleKeyboard:h,editConfirmRef:f,getNewKeyOptions:y,jsonStringify:g,showIconTooltips:v,Select:b})=>{const{getStyles:j}=W(),{open:x,cancel:E}=Z(),C=u("KEY_NEW",c),[S,O]=t.useState(C),[T,R]=t.useState(!1),{path:N,value:A}=c,P=G(e=>{const t=e.active;return null!==t&&"add"===t.op&&m(t.path,N)}),I=Array.isArray(T);D(()=>{if(!P)return R(!1),void O(C);const e=Object.keys(w(c.fullData,N)),t=y?y(c)?.filter(t=>!e.includes(t)):null;t&&O(""),R(t??!0)},[P]);const L=()=>{o&&(I&&!S||o("array"===i?"":S))};return e.jsxs("div",{className:"jer-edit-buttons",style:{opacity:P?1:void 0},onClick:e=>e.stopPropagation(),children:[a&&e.jsx("button",{type:"button",tabIndex:-1,onClick:e=>{e.stopPropagation();let t,n,r="value",o="",i=null;if(a){const a=k(e);if(a&&p.clipboardModifier.includes(a)?(t=d(N),o=t,r="path"):(t=A,o="object"==typeof t?g(A):String(t)),!navigator.clipboard)return void s?.({...c,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,i=e.message}).finally(()=>{s?.({...c,success:n,stringValue:o,type:r,error:n?void 0:{code:"CLIPBOARD_ERROR",message:i??"Copy failed"}})})}},className:"jer-copy-pulse","aria-label":u("TOOLTIP_COPY",c),title:v?u("TOOLTIP_COPY",c):"",children:e.jsx(xe,{name:"copy",nodeData:c})}),n&&e.jsx("button",{type:"button",tabIndex:-1,onClick:n,"aria-label":u("TOOLTIP_EDIT",c),title:v?u("TOOLTIP_EDIT",c):"",children:e.jsx(xe,{name:"edit",nodeData:c})}),r&&e.jsx("button",{type:"button",tabIndex:-1,onClick:r,"aria-label":u("TOOLTIP_DELETE",c),title:v?u("TOOLTIP_DELETE",c):"",children:e.jsx(xe,{name:"delete",nodeData:c})}),o&&e.jsx("button",{type:"button",tabIndex:-1,onClick:()=>{"object"===i?x(N,{op:"add"}):o("")},"aria-label":u("TOOLTIP_ADD",c),title:v?u("TOOLTIP_ADD",c):"",children:e.jsx(xe,{name:"add",nodeData:c})}),l?.map(({Element:t,onClick:n,label:r},o)=>{const a=e=>n&&n(c,e);return r?e.jsx("button",{type:"button",tabIndex:-1,onClick:a,"aria-label":r,title:v?r:"",children:e.jsx(t,{nodeData:c})},o):e.jsx("div",{onClick:a,children:e.jsx(t,{nodeData:c})},o)}),P&&o&&"object"===i&&e.jsxs(e.Fragment,{children:[I?e.jsx(b,{name:"new-key-select",onChange:o,defaultValue:"",autoFocus:!0,onKeyDown:e=>h(e,{cancel:()=>E()}),placeholder:T.length>0?u("KEY_SELECT",c):u("NO_KEY_OPTIONS",c),options:T}):e.jsx("input",{className:"jer-input-new-key",type:"text",name:"new-object-key",value:S,onChange:e=>O(e.target.value),autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>{h(e,{stringConfirm:()=>L(),cancel:()=>E()})},style:j("input",c)}),e.jsx(Ee,{onOk:()=>L(),onCancel:()=>E(),nodeData:c,translate:u,showIconTooltips:v,editConfirmRef:f,hideOk:I})]})]})},Ee=({onOk:t,onCancel:n,nodeData:r,translate:o,showIconTooltips:a,editConfirmRef:s,hideOk:i=!1})=>e.jsxs("div",{className:"jer-confirm-buttons",children:[!i&&e.jsx("button",{type:"button",tabIndex:-1,onClick:t,"aria-label":o("TOOLTIP_OK",r),title:a?o("TOOLTIP_OK",r):"",ref:s,children:e.jsx(xe,{name:"ok",nodeData:r})}),e.jsx("button",{type:"button",tabIndex:-1,onClick:n,"aria-label":o("TOOLTIP_CANCEL",r),title:a?o("TOOLTIP_CANCEL",r):"",children:e.jsx(xe,{name:"cancel",nodeData:r})})]}),Ce=["string","number","boolean","null"],De=["object","array"],Se=[...Ce,...De],ke=e=>{const{component:t,wrapperComponent:n,keyComponent:r,showKey:o=!0,showEditTools:a=!0,showOnEdit:s=!1,showOnView:i=!0,showCollectionWrapper:l=!0,...c}=e;return{CustomComponent:t,CustomWrapperComponent:n,CustomKeyComponent:r,showKey:o,showEditTools:a,showOnEdit:s,showOnView:i,showCollectionWrapper:l,...c}},Oe=(e=[],t)=>{const n=e.find(({condition:e})=>e(t));return n?ke(n):{}},Te=({props:e,collapsed:n})=>{const{nodeData:r,parentData:o,onError:a,getLatestData:s,showErrorMessages:i,allowEditFilter:l,allowDeleteFilter:c,allowAddFilter:u,allowDragFilter:d,canAddHere:h,translate:f,errorDisplayTime:y,sort:g,arrayIndexStart:v,handleKeyboard:b,customNodeData:j}=e,{submit:x}=Z(),[w,E]=t.useState(null),C={...r,collapsed:n,visibleSize:ue(r.path)},{path:D,key:S,size:k}=C,O=p(D),T=G(e=>{const t=e.active;return null!==t&&"edit"===t.op&&m(t.path,D)}),R=G(e=>{const t=e.active;return null!==t&&"rename"===t.op&&m(t.path,D)}),N=G(e=>O in e.settling),A=l(C),I=c(C),L=u(C),K=d(C),_=e=>{i&&(E(e),setTimeout(()=>E(null),y)),console.warn("Error",e)},M=t.useRef(C);M.current=C;const V=t.useCallback((e,t)=>{_(e.message),a&&a({...M.current,fullData:s(),error:e,errorValue:t})},[a,i,s,y]),F=le(),z=t.useCallback(e=>(null===F||F.visiblePaths.has(p(e.path)))&&l(e),[F,l]),B=e=>P(s(),D,e,g,z),H=(e,t)=>{o&&(S!==e&&Object.keys(o).includes(e)?V({code:"KEY_EXISTS",message:f("ERROR_KEY_EXISTS",C)},e):x({op:"rename",path:D,newKey:e,onCommit:t}).then(t=>{"error"===t?.status&&V(t.error,e)}))},W="number"==typeof D.slice(-1)[0],Y=null!==o&&!W&&I&&h,U={isEditing:T,isEditingKey:R,isPending:N,isArray:W,canEditKey:Y},$=""===S&&D.length>0?f("EMPTY_STRING",C):null;return{pathString:O,nodeData:C,path:D,name:S,size:k,canEdit:A,canDelete:I,canAdd:L,canDrag:K,error:w,showError:_,onError:V,setError:E,handleEditKey:H,derivedValues:U,emptyStringKey:$,getNextOrPreviousAtPath:B,buildKeyDisplayProps:({handleCancel:e,getStyles:t,keyValueArray:n,handleClick:r})=>({canEditKey:Y,isEditingKey:R,pathString:O,path:D,name:S,arrayIndexStart:v,handleKeyboard:b,handleEditKey:H,handleCancel:e,styles:t("property",C),getNextOrPrevious:B,emptyStringKey:$,nodeData:C,customNodeData:j,getStyles:t,...void 0!==n?{keyValueArray:n}:{},...void 0!==r?{handleClick:r}:{}})}},Re=({canDrag:n,canDelete:r,canDragOnto:o,canAddHere:a,path:s,nodeData:i,onError:l,translate:c})=>{const{getStyles:u}=W(),{dragSource:d,setDragSource:p,armed:f}=(()=>{const e=t.useContext(re);if(!e)throw new Error("Missing DragSource Context Provider");return e})(),y=Z(),[g,v]=t.useState(!1),b=()=>null!==d.path&&!h(s,d.path)&&(m(d.path.slice(0,-1),s.slice(0,-1))?o:d.canDelete&&a),j=t.useMemo(()=>n?{onMouseDown:e=>{0===e.button&&null===y.getSnapshot().active&&(f.current=!0)},onMouseUp:()=>{f.current=!1},onDragStart:e=>{if(!f.current||null!==y.getSnapshot().active)return e.preventDefault(),void e.stopPropagation();f.current=!1,e.stopPropagation(),p({path:s,canDelete:r})},onDragEnd:e=>{f.current=!1,e.stopPropagation(),p({path:null,canDelete:!1})}}:{},[n,r,s]),x=t.useMemo(()=>e=>o||a?{onDragOver:e=>{e.stopPropagation(),b()&&e.preventDefault()},onDrop:t=>{t.stopPropagation(),E(e),p({path:null,canDelete:!1}),v(!1)},onDragEnter:t=>{t.stopPropagation(),b()&&v(e)},onDragExit:e=>{e.stopPropagation(),v(!1)}}:{},[d,o,a,s]),w=t.useMemo(()=>null!==d.path&&b()?e.jsx("div",{className:"jer-drop-target-bottom",style:{height:"50%",position:"absolute",width:"100%",top:"50%",zIndex:s.length},...x("below")}):null,[d,o,a,s.length]),E=e=>{if(null===d.path)return;if(!b())return;const t=d.path.slice(-1)[0],n=d.path.slice(0,-1),r=s.slice(0,-1),{parentData:o}=i;"string"==typeof t&&o&&!Array.isArray(o)&&Object.keys(o).includes(t)&&t in o&&!m(n,r)?l({code:"KEY_EXISTS",message:c("ERROR_KEY_EXISTS",i)},t):y.submit({op:"move",path:d.path,to:{path:s,position:e},instant:!0})};return{dragSourceProps:j,getDropTargetProps:x,BottomDropTarget:w,DropTargetPadding:({position:t,nodeData:n})=>g===t?e.jsx("div",{className:"jer-drag-n-drop-padding",style:u("dropZone",n)}):null,handleDrop:E}},Ne=({isEditingKey:n,canEditKey:r,pathString:o,path:a,name:s,arrayIndexStart:i,handleKeyboard:l,handleEditKey:c,handleCancel:u,handleClick:d,keyValueArray:p,styles:m,getNextOrPrevious:h,emptyStringKey:f,nodeData:y,customNodeData:g,getStyles:v})=>{const{open:b,cancel:j}=Z(),x=t.useRef(null),w=e=>c(x.current?.value??String(s),e),E="number"==typeof s?String(s+i):s;if(!n){const t={...m,minWidth:`${Math.min(E.length+1,5)}ch`,flexShrink:E.length>10?1:0};if(g?.CustomKeyComponent&&y&&v){const{CustomKeyComponent:n,componentProps:o}=g;return e.jsx(n,{nodeData:y,name:f??E,path:a,canEditKey:r,handleEditKey:e=>{r&&c(e)},startEditingKey:()=>{r&&b(a,{op:"rename",commitOp:w})},handleClick:d,styles:t,componentProps:o,getStyles:v})}return e.jsxs("span",{className:"jer-key-text",style:t,onDoubleClick:()=>r&&b(a,{op:"rename",commitOp:w}),onClick:d,children:[f?e.jsx("span",{className:"jer-empty-string",children:f}):E,""!==E||f?e.jsx("span",{className:"jer-key-colon",children:":"}):null]})}return e.jsx("input",{ref:x,className:"jer-input-text jer-key-edit",type:"text",name:o,defaultValue:E,autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>l(e,{stringConfirm:()=>c(e.target.value),cancel:u,tabForward:()=>{const t=e.target.value;c(t,()=>{if(p){const e=p?.[0][0],t=e?[...a,e]:h("next");t?b(t):j()}else b(a)})},tabBack:()=>{const t=e.target.value;c(t,()=>{const e=h("prev");e?b(e):j()})}}),style:{width:E.length/1.5+.5+"em"}})},Ae=new Set(["nodeData","customNodeData"]),Pe=(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||!m(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(!Ae.has(n)&&!Object.is(e[n],t[n]))return!1;return!0},Ie=r=>{const{data:o,parentData:a,onChange:s,showClipboardButton:l,onCopy:c,canDragOnto:u,canAddHere:d,allowTypeSelection:p,showLabel:h,stringTruncateLength:f,showStringQuotes:y,indent:g,translate:v,customNodeDefinitions:b,customNodeData:j,Select:x,handleKeyboard:w,keyboardControls:E,editConfirmRef:C,jsonStringify:D,showIconTooltips:S,getLatestData:k}=r,{getStyles:O}=W(),{open:T,cancel:R,submit:N,getSnapshot:A}=Z(),{setCollapseState:P}=te(),[I,L]=t.useState("function"==typeof o?de:o),{nodeData:K,path:_,name:M,canEdit:V,canDelete:F,canDrag:z,error:B,onError:H,setError:Y,derivedValues:U,getNextOrPreviousAtPath:$,buildKeyDisplayProps:J}=Te({props:r}),{dragSourceProps:X,getDropTargetProps:Q,BottomDropTarget:G,DropTargetPadding:q}=Re({canDrag:z,canDelete:F,canDragOnto:u,canAddHere:d,path:_,nodeData:K,onError:H,translate:v}),[ee,ne]=t.useState(_e(o,j)),re=t.useRef(I);re.current=I;const oe=t.useRef(K);oe.current=K;const ae=t.useCallback(e=>{if(!s)return void L(e);const t=s({...oe.current,value:re.current,fullData:k(),newValue:e});L(t)},[s,k]),se=()=>{L("function"==typeof o?de:o),ne(_e(o,j)),ue(i(o,ie))};t.useEffect(()=>{U.isEditing||se()},[o]);const ie=t.useMemo(()=>{const e=[...Se,...b.filter(({showInTypeSelector:e=!1,name:t})=>e&&!!t).map(({name:e})=>e)];if("boolean"==typeof p)return p?e:[];if(Array.isArray(p))return p;const t=p(K);return"boolean"==typeof t?t?e:[]:t},[K,p,b]),[le,ue]=t.useState(i(I,ie)),{isEditing:pe,isPending:me}=U,he=ce(_),fe=t.useRef(n);if(!he)return null;const ye=pe&&ee!==_e(o,j),ge=ye?b.find(e=>e.name===ee&&Ke(e)):void 0,ve=ge?ke(ge):j,{CustomComponent:be,componentProps:je,showKey:xe=!0,showEditTools:Ce=!0,showOnEdit:De,showOnView:Oe,passOriginalNode:Ae}=ve,Pe=be&&(void 0!==ge||!ye&&(pe&&De||!pe&&Oe)),Ie=e=>{P(null);const t=ye&&!ge?void 0:ve,n=t?.toStandardType?t.toStandardType(I):I,r=b.find(t=>t.name===e);if(r){const t="function"==typeof r.defaultValue?r.defaultValue(K):r.defaultValue;if(Ke(r)){let o=t;if(r.fromStandardType)try{o=r.fromStandardType(n,K,r.componentProps)}catch{}return L(o),ne(e),void ue(null)}return N({op:"edit",path:_,value:t}).then(Le(t)),void P({path:_,collapsed:!1,includeChildren:!1})}const o=ie.find(t=>t instanceof Object&&t.enum===e);if(o)return"string"==typeof I&&o.values.includes(I)||L(o.values[0]),ue(o),void ne(e);const a=Fe(n,e,v("DEFAULT_NEW_KEY",K));if("object"===e||"array"===e||"null"===e)return N({op:"edit",path:_,value:a}).then(Le(a)),void("null"!==e&&P({path:_,collapsed:!1,includeChildren:!1}));L(a),ne(e),ue(null)},Le=e=>t=>{if("error"===t?.status&&H(t.error,e),"error"===t?.status||"cancel"===t?.status){const e=A().active;"editing"===e?.phase&&m(e.path,_)||se()}},ze=(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(Pe&&ve.fromStandardType)try{r=ve.fromStandardType(I,K,ve.componentProps)}catch(e){return void H({code:"UPDATE_ERROR",message:e instanceof Error?e.message:String(e)},I)}else r="number"===ee?Ve(I):I;Y(null),ge&&P({path:_,collapsed:!1,includeChildren:!1}),N({op:"edit",path:_,value:r,onCommit:t}).then(Le(r))};fe.current=ze;const Be=()=>{Y(null),se(),R()},{isEditingKey:He}=U,We=!!B,Ye=pe&&ie.length>1,Ue=("invalid"!==ee||be)&&!B&&Ce,$e=h&&xe,Je=()=>T(_,{cancelOp:se,commitOp:e=>fe.current(void 0,e)}),Xe=V?Je:n,Qe=e=>()=>{const t=$(e);t&&ze(void 0,()=>T(t))},Ze={value:I,parentData:a,setValue:ae,isEditing:pe,canEdit:V,setIsEditing:Xe,handleEdit:ze,handleCancel:Be,path:_,stringTruncateLength:f,showStringQuotes:y,showIconTooltips:S,nodeData:K,enumType:le,translate:v,handleKeyboard:w,keyboardCommon:{cancel:Be,tabForward:Qe("next"),tabBack:Qe("prev")},Select:x},Ge={...J({handleCancel:Be,getStyles:O}),customNodeData:ve},qe=Pe?e.jsx(be,{...r,value:I,componentProps:je,setValue:ae,handleEdit:ze,handleCancel:Be,onKeyDown:e=>w(e,{stringConfirm:ze,cancel:Be}),isEditing:pe,isPending:me,setIsEditing:Xe,getStyles:O,originalNode:Ae?Me(o,ee,Ze):void 0,originalNodeKey:Ae?e.jsx(Ne,{...Ge,customNodeData:void 0}):void 0,canEdit:V,keyboardCommon:Ze.keyboardCommon}):Me(o,ee,Ze);return e.jsxs("div",{className:"jer-component jer-value-component",style:{marginLeft:null!==a?g/2+"em":0,position:"relative"},draggable:z&&!pe&&!He,...X,...Q("above"),children:[G,e.jsx(q,{position:"above",nodeData:K}),e.jsxs("div",{className:"jer-value-main-row",style:{...O("valueRow",K),flexWrap:M.length>10?"wrap":"nowrap"},children:[$e&&e.jsx(Ne,{...Ge}),e.jsxs("div",{className:"jer-value-and-buttons",children:[e.jsx("div",{className:"jer-input-component",children:qe}),pe?e.jsx(Ee,{onOk:ze,onCancel:Be,nodeData:K,translate:v,showIconTooltips:S,editConfirmRef:C}):Ue&&e.jsx(we,{startEdit:V?Je:void 0,handleDelete:F?()=>{N({op:"delete",path:_,instant:!0}).then(e=>{"error"===e?.status&&H(e.error,I)})}:void 0,showClipboardButton:l,onCopy:c,translate:v,customButtons:r.customButtons,nodeData:K,handleKeyboard:w,keyboardControls:E,editConfirmRef:C,jsonStringify:D,showIconTooltips:S,Select:x}),Ye&&e.jsx(x,{name:`${M}-type-select`,value:le?le.enum:ee,onChange:e=>Ie(e),options:ie.map(e=>e instanceof Object&&"enum"in e?e.enum:e)}),We&&e.jsx("span",{className:"jer-error-slug",style:O("error",K),children:B})]})]}),e.jsx(q,{position:"below",nodeData:K})]})},Le=/*#__PURE__*/t.memo(Ie,Pe),Ke=e=>!!e.editOnTypeSwitch&&!!e.component&&!!e.showOnEdit,_e=(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",Me=(t,n,r)=>{const o=Ce.includes(n)?n:"function"==typeof t?"invalid":_e(r.value),{value:a}=r;switch(o){case"string":return e.jsx(he,{...r,value:a});case"number":return e.jsx(fe,{...r,value:a});case"boolean":return e.jsx(ye,{...r,value:a});case"null":return e.jsx(ve,{...r});default:return e.jsx(be,{...r})}},Ve=e=>{if("symbol"==typeof e)return 0;const t=Number(e);return isNaN(t)?0:t},Fe=(e,t,n)=>{switch(t){case"string":return null==e?"":String(e);case"number":return Ve(e);case"boolean":return!!e;case"null":return null;case"object":return{[n]:e};case"array":return[e];default:return String(e)}},ze=r=>{const{getStyles:a}=W(),{open:s,cancel:i,submit:l,areChildrenBeingEdited:c,getSnapshot:u}=Z(),{setCollapseState:d}=te(),{mainContainerRef:p,data:f,nodeData:y,parentData:g,showCollectionCount:v,canDragOnto:b,canAddHere:j,collapseFilter:x,collapseAnimationTime:w,showClipboardButton:E,onCopy:C,showIconTooltips:D,indent:O,sort:T,showArrayIndexes:R,defaultValue:N,newKeyOptions:P,translate:I,customNodeDefinitions:L,customNodeData:K,jsonParse:_,jsonStringify:M,TextEditor:V,Select:F,keyboardControls:z,handleKeyboard:B,insertAtTop:H,onCollapse:Y,editConfirmRef:U,collapseClickZones:$,getLatestData:J}=r,[X,Q]=t.useState(null),{showCollectionWrapper:q=!0}=K,ee=q&&x(y),{contentRef:re,isAnimating:oe,maxHeight:ae,collapsed:se,animateCollapse:ie,cssTransitionValue:le}=((e,n,r,o,a)=>{const[s,i]=t.useState(r?0:void 0),[l,c]=t.useState(r),u=t.useRef(!1),d=t.useRef(null),p=t.useRef(0),m=t.useRef(0),h=n/1e3+"s",f=t.useCallback(t=>{if(l!==t){switch(window.clearTimeout(m.current),u.current=!0,t){case!0:{const e=d.current?.offsetHeight??0;p.current=e,i(e),setTimeout(()=>{i(0)},5);break}case!1:i(p.current||((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),s=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(s+30,window.innerHeight-50)})(e,d,o,a))}c(!l),m.current=window.setTimeout(()=>{u.current=!1,t||i(void 0)},n)}},[n,l,e,o,a]);return{contentRef:d,isAnimating:u.current,animateCollapse:f,maxHeight:s,collapsed:l,cssTransitionValue:h}})(f,w,ee,p,M),{pathString:ue,nodeData:de,path:pe,name:me,size:he,canEdit:fe,canDelete:ye,canAdd:ge,canDrag:ve,error:be,setError:je,onError:Ce,derivedValues:De,buildKeyDisplayProps:Se}=Te({props:r,collapsed:se}),{dragSourceProps:ke,getDropTargetProps:Ae,BottomDropTarget:Pe,DropTargetPadding:Ie}=Re({canDrag:ve,canDelete:ye,canDragOnto:b,canAddHere:j,path:pe,nodeData:de,onError:Ce,translate:I}),Ke=t.useRef(!ee),{isEditing:_e,isEditingKey:Me,isPending:Ve,isArray:Fe}=De,ze=(e=>{const n=t.useRef(e),r=!Object.is(n.current,e);return t.useEffect(()=>{n.current=e}),r})(x);t.useEffect(()=>{const e=q&&x(de)&&!_e;Ke.current=!e,ie(e),ze&&d(null)},[x]),((e,n,r)=>{const{commands:o,version:a}=te(),s=t.useRef(0);t.useEffect(()=>{if(a===s.current)return;if(s.current=a,!o)return;let t;for(const n of o)ne(e,n)&&(t=n);t&&(t.collapsed||(n.current=!0),r(t.collapsed))},[a,o])})(pe,Ke,q?ie:n);const He=t.useRef(null),We=t.useCallback(e=>Q(t=>"function"==typeof e?e(t??M(f)):e),[f,M]),Ye=t.useCallback(()=>Q(null),[]),Ue=t.useMemo(()=>_e?X??M(f):null,[_e,X,f,M]),$e=t.useCallback((e,t)=>{if("function"!=typeof N)return N;const n=N(e,t);return void 0!==n?n:null},[N]),Je=t.useCallback(e=>P?"function"!=typeof P?P:P(e):null,[P]),{CustomComponent:Xe,componentProps:Qe,CustomWrapperComponent:Ze,wrapperProps:Ge={},showKey:qe=!0,showEditTools:et=!0,showOnEdit:tt,showOnView:nt,passOriginalNode:rt}=K,ot=G(e=>null!==e.active&&h(e.active.path,pe));!ot&&q||!se||ie(!1);const at=ce(pe)||0===de.level,st=t.useRef(n);if(!at&&!ot)return null;const{visibleSize:it}=de,lt=Array.isArray(f)?"array":"object",ct="array"===lt?{open:"[",close:"]"}:{open:"{",close:"}"},ut=e=>{if("Tab"===e.key&&!e.getModifierState("Shift")&&e.target===He.current){e.preventDefault();const t=A(He,"\t");return void Q(t)}B(e,{objectConfirm:pt,cancel:ht})},dt=e=>{if(e.stopPropagation(),!q)return;const t=k(e);if(t&&z.collapseModifier.includes(t))return Ke.current=!0,void d({collapsed:!se,path:pe,includeChildren:!0});c(pe)||(Ke.current=!0,Y&&Y({...de,fullData:J(),collapsed:!se,includeChildren:!1}),ie(!se))},pt=e=>{let t=f;if(null!==X)try{t=_(X)}catch{return void Ce({code:"INVALID_JSON",message:I("ERROR_INVALID_JSON",de)},X)}je(null);const n="function"==typeof e?e:void 0;l({op:"edit",path:pe,value:t,onCommit:()=>{Ye(),n?.()}}).then(e=>{if("error"===e?.status&&Ce(e.error,t),"error"===e?.status||"cancel"===e?.status){const e=u().active;"editing"===e?.phase&&m(e.path,pe)||Ye()}})};st.current=pt;const mt=pe.length>0?()=>{l({op:"delete",path:pe,instant:!0}).then(e=>{"error"===e?.status&&Ce(e.error,f)})}:void 0,ht=()=>{i(),je(null),Ye()},ft="when-collapsed"===v?se:"when-collapsed-or-filtered"===v?se||null!=it:v,yt=!_e&&et,gt=(R||!Fe)&&qe&&void 0!==me,vt=Xe&&(_e&&tt||!_e&&nt),bt=Object.entries(f).map(([e,t])=>["array"===lt?Number(e):e,t]);"object"===lt&&T(bt,e=>e);const jt=!_e||!!Xe&&tt,xt=()=>e.jsxs("div",{className:"jer-collection-text-edit"+(V?"-custom":""),children:[V?e.jsx(V,{value:Ue??"",onChange:Q,onKeyDown:e=>B(e,{objectConfirm:pt,cancel:ht})}):e.jsx(S,{textAreaRef:He,className:"jer-collection-text-area",name:ue,value:Ue??"",setValue:We,onKeyDown:ut,styles:a("input",de)}),e.jsx("div",{className:"jer-collection-input-button-row",children:e.jsx(Ee,{onOk:pt,onCancel:ht,nodeData:de,translate:I,showIconTooltips:D,editConfirmRef:U})})]}),wt=Ke.current?jt?bt.map(([t,n],s)=>{const i={key:t,value:n,path:[...pe,t],level:pe.length+1,index:s,size:o(n)?Object.keys(n).length:null,parentData:f,fullData:de.fullData},l=Oe(L,i);return e.jsx("div",{className:"jer-collection-element",style:a("collectionElement",i),children:o(n)&&!l?.renderCollectionAsValue?e.jsx(Be,{...r,data:n,parentData:f,nodeData:i,canDragOnto:fe,canAddHere:ge,customNodeData:l},t):e.jsx(Le,{...r,data:n,parentData:f,nodeData:i,canDragOnto:fe,canAddHere:ge,showLabel:"object"===lt||R,customNodeData:l},t)},t)}):e.jsx(e.Fragment,{children:xt()}):null,Et=!!q&&se&&!ot;Et||(Ke.current=!0);const Ct=I(se?"TOOLTIP_EXPAND":"TOOLTIP_COLLAPSE",de),Dt=()=>({...r,data:f,value:f,parentData:g,nodeData:de,setValue:e=>l({op:"edit",path:pe,value:e}),handleEdit:pt,handleCancel:ht,onKeyDown:ut,isEditing:_e,isPending:Ve,setIsEditing:fe?()=>s(pe,{cancelOp:Ye,commitOp:e=>st.current(e)}):n,getStyles:a,canDragOnto:fe,canAddHere:ge,canEdit:fe,keyboardCommon:{}}),St=vt?e.jsx(Xe,{componentProps:Qe,...Dt(),originalNode:rt&&_e?xt():void 0,children:wt}):wt,kt=yt&&e.jsx(we,{startEdit:fe?()=>{Ke.current=!0,s(pe,{cancelOp:Ye,commitOp:e=>st.current(e)})}:void 0,handleAdd:ge?e=>{d(null),ie(!1);const t=$e(de,e);if("array"===lt){const e=H.array?0:f.length,n=H.array?{insert:!0}:{};return void l({op:"add",path:pe,key:e,value:t,options:n,instant:!0}).then(e=>{"error"===e?.status&&Ce(e.error,t)})}if(e in f)return Ce({code:"KEY_EXISTS",message:I("ERROR_KEY_EXISTS",de)},e),void i();const n=H.object?{insertBefore:0}:{};l({op:"add",path:pe,key:e,value:t,options:n}).then(e=>{"error"===e?.status&&Ce(e.error,t)})}:void 0,handleDelete:ye?mt:void 0,showClipboardButton:E,onCopy:C,type:lt,nodeData:de,translate:I,customButtons:r.customButtons,keyboardControls:z,handleKeyboard:B,getNewKeyOptions:Je,editConfirmRef:U,jsonStringify:M,showIconTooltips:D,Select:F}),Ot=Se({handleCancel:ht,getStyles:a,keyValueArray:bt,handleClick:$.includes("property")?dt:e=>e.stopPropagation()}),Tt=e.jsxs("div",{className:"jer-component jer-collection-component",style:{marginLeft:(0===pe.length?0:O/2)+"em",...a("collection",de),position:"relative"},draggable:ve&&!_e&&!Me&&!ot,...ke,...Ae("above"),children:[q&&e.jsx("div",{className:"jer-clickzone",style:{width:O/2+1+"em",zIndex:10+2*de.level},onClick:$.includes("left")?dt:void 0}),!_e&&Pe,e.jsx(Ie,{position:"above",nodeData:de}),q?e.jsxs("div",{className:"jer-collection-header-row",style:{...a("headerRow",de),position:"relative"},onClick:$.includes("header")?dt:void 0,children:[e.jsxs("div",{className:"jer-collection-name",children:[e.jsx("button",{type:"button",className:"jer-collapse-icon jer-accordion-icon"+(se?" jer-rotate-90":""),style:{zIndex:11+2*de.level,transition:le},onClick:dt,tabIndex:-1,"aria-expanded":!se,"aria-label":Ct,title:D?Ct:"",children:e.jsx(xe,{name:"collection",nodeData:de})}),gt&&e.jsx(Ne,{...Ot}),!_e&&e.jsx("span",{className:"jer-brackets jer-bracket-open",style:a("bracket",de),children:ct.open})]}),!1!==v&&!_e&&e.jsx("div",{className:"jer-collection-item-count"+(ft?" jer-visible":" jer-hidden"),style:{...a("itemCount",de),transition:le,transitionBehavior:"allow-discrete"},children:null!=it&&it!==he?I("ITEMS_FILTERED",de,{visible:it,total:he}):1===he?I("ITEM_SINGLE",{...de,size:1},1):I("ITEMS_MULTIPLE",de,he)}),e.jsx("div",{className:"jer-brackets"+(Et?" jer-visible":" jer-hidden"),style:{...a("bracket",de),transition:le},children:ct.close}),kt]}):qe?e.jsxs("div",{className:"jer-collection-header-row",style:{...a("headerRow",de),position:"relative"},children:[e.jsx(Ne,{...Ot}),kt]}):e.jsx(e.Fragment,{}),e.jsxs("div",{className:"jer-collection-inner",style:{overflowY:Et||oe?"clip":"visible",maxHeight:ot?void 0:ae,...a("collectionInner",de),transition:le},ref:re,children:[St,e.jsx("div",{className:_e?"jer-collection-error-row-edit":"jer-collection-error-row",children:be&&e.jsx("span",{className:"jer-error-slug",style:a("error",de),children:be})}),!_e&&q&&e.jsx("div",{className:"jer-brackets jer-bracket-outside",style:a("bracket",de),children:ct.close})]}),e.jsx(Ie,{position:"below",nodeData:de})]});return Ze?e.jsx(Ze,{wrapperProps:Ge,...Dt(),children:Tt}):Tt},Be=/*#__PURE__*/t.memo(ze,Pe),He=({options:t,value:n,defaultValue:r,onChange:o,placeholder:a,className:s,...i})=>{const l=void 0!==n?{value:n}:{defaultValue:r??""};return e.jsxs("div",{className:"jer-select",children:[e.jsxs("select",{className:s??"jer-select-inner",onChange:e=>o(e.target.value),...i,...l,children:[void 0!==a&&e.jsx("option",{value:"",disabled:!0,children:a}),t.map(t=>e.jsx("option",{value:t,children:t},t))]}),e.jsx("span",{className:"focus"})]})},We=(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}},Ye=({key:e,path:t},n="")=>!!We({value:e},n)||!!t.some(e=>We({value:e},n)),Ue={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)",SHOW_MORE:"Show more",EMPTY_STRING:"<empty string>",TOOLTIP_COPY:"Copy to clipboard",TOOLTIP_EDIT:"Edit",TOOLTIP_DELETE:"Delete",TOOLTIP_ADD:"Add",TOOLTIP_OK:"OK",TOOLTIP_CANCEL:"Cancel",TOOLTIP_COLLAPSE:"Collapse",TOOLTIP_EXPAND:"Expand"};var $e=':root,:host{--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;padding:0 1em 0 0;margin:0;font-family:inherit;font-size:.8em;color:#000;cursor:inherit;line-height:inherit;z-index:1;outline:none}select::-ms-expand{display:none}.jer-select{display:grid;grid-template-areas:"select";align-items:center;position:relative;min-width:12ch;max-width:15ch;border:1px solid var(--jer-select-border);border-radius:.25em;padding:.25em .5em;cursor:pointer;line-height:1.1;background-color:#fff;background-image:linear-gradient(to top,#f9f9f9,#fff 33%)}.jer-select select,.jer-select:after{grid-area:select}.jer-select:not(.jer-select--multiple):after{content:"";justify-self:end;width:.8em;height:.5em;background-color:var(--jer-select-arrow);clip-path:polygon(100% 0%,0 0%,50% 100%)}select:focus+.focus{position:absolute;inset:-1px;border:1px solid var(--jer-select-focus);border-radius:inherit}.jer-select-inner{width:100%;text-overflow:ellipsis}.jer-editor-container{position:relative;font-size:16px;line-height:1;padding:1em 1em 1em 2em;border-radius:.5em;text-align:left}.jer-editor-container textarea{color:var(--jer-input-color);border:var(--jer-form-border);border-radius:.3em;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;outline:none;font-family:inherit}.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{display:flex;min-height:1.7em;gap:.3em;align-items:center}.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{position:absolute;left:-1.2em;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{display:flex;flex-direction:column;gap:.3em;align-items:flex-start;line-height:1.1em}.jer-collection-text-edit{width:fit-content}.jer-collection-text-area{box-sizing:content-box;resize:both;padding:.2em .5em 0;overflow:hidden;max-height:40em;line-height:1.25em;font-family:inherit;font-size:.85em}.jer-collection-input-button-row{display:flex;justify-content:flex-end;width:100%;font-size:150%;margin-top:.4em}.jer-collection-error-row-edit{position:absolute;bottom:.5em}.jer-error-slug{margin-left:1em}.jer-value-component{position:relative}.jer-value-and-buttons{display:flex;justify-content:flex-start;align-items:center;padding-left:.5em}.jer-value-error-row{position:absolute}.jer-value-string{line-height:1.3em;white-space:pre-wrap;overflow-wrap:anywhere;word-break:break-word}.jer-string-expansion{cursor:pointer;opacity:.6;filter:saturate(50%)}.jer-string-expansion.jer-show-less{font-size:80%}.jer-hyperlink{text-decoration:underline}.jer-input-text{box-sizing:content-box;resize:none;margin:0;height:1.4em;padding:.25em .5em .2em;min-width:6em;overflow:hidden;line-height:1.2em;font-family:inherit;font-size:.9em}.jer-input-boolean{transform:scale(1.5);margin-left:.3em;margin-right:.3em}.jer-key-text{word-break:break-word;line-height:1.1em;white-space:pre-wrap}.jer-key-edit{padding:0 .3em;font-size:inherit;font-size:.9em}.jer-value-invalid{opacity:.5;font-style:italic}.jer-input-number{min-width:3em;font-size:90%}.jer-edit-buttons,.jer-confirm-buttons{display:flex;align-items:center;cursor:pointer;height:1em;margin-right:.2em}.jer-edit-buttons>button,.jer-confirm-buttons>button,button.jer-collapse-icon,button.jer-string-expansion{appearance:none;background:none;border:none;margin:0;padding:0;font:inherit;color:inherit;vertical-align:baseline}.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{opacity:1}.jer-value-main-row:hover>.jer-edit-buttons{opacity:1}.jer-value-and-buttons:hover>.jer-edit-buttons{opacity:1}.jer-copy-pulse{position:relative;transition:.3s}.jer-copy-pulse:hover{opacity:.85;transition:.3s;transform:scale(1.2)}.jer-copy-pulse:after{content:"";display:block;position:absolute;border-radius:50%;left:0;top:0;width:100%;height:100%;opacity:0;transition:all .5s;box-shadow:0 0 15px 5px var(--jer-icon-copy-color)}.jer-copy-pulse:active:after{box-shadow:0 0 0 0 var(--jer-icon-copy-color);position:absolute;border-radius:4em;left:0;top:0;opacity:1;transition:0s}.jer-copy-pulse:active{top:.07em}.jer-icon:hover{opacity:.85;transition:.3s;transform:scale(1.2)}.jer-empty-string{font-style:italic;font-size:90%}.jer-drag-n-drop-padding{height:.5em;border:1px dashed #b4b4b4;border-radius:.3em}.jer-clickzone{position:absolute;left:-1em;top:1.2em;height:calc(100% - .8em)}';const Je="data-jer-styles",Xe=(e,t)=>JSON.stringify(e,t,2),Qe={edit:"ERROR_UPDATE",add:"ERROR_ADD",delete:"ERROR_DELETE",rename:"ERROR_RENAME",move:"ERROR_MOVE"},Ze={edit:"UPDATE_ERROR",add:"ADD_ERROR",delete:"DELETE_ERROR",rename:"RENAME_ERROR",move:"MOVE_ERROR"},Ge=e=>{const n=t.useRef(e);e&&(n.current=e);const r=t.useRef((...e)=>n.current(...e));return e?r.current:void 0},qe=[],et=["header","left"],tt={},nt={},rt={},ot=[],at=({data:i,setData:c,buildNodeDataFromPathRef:u,commitRef:d,rootName:m="root",onUpdate:h=n,onChange:f,onError:y,onEditEvent:g,showErrorMessages:v=!0,showClipboardButton:b=!0,onCopy:j,indent:x=2,collapse:E=3,collapseAnimationTime:D=300,showCollectionCount:S="when-collapsed-or-filtered",allowEdit:k=!0,allowDelete:T=!0,allowAdd:A=!0,allowTypeSelection:P=!0,allowDrag:I=!1,searchFilter:L,searchText:K,searchDebounceTime:_=350,sortKeys:M=!1,showArrayIndexes:V=!0,arrayIndexStart:F=0,showStringQuotes:z=!0,showIconTooltips:B=!1,defaultValue:H=null,newKeyOptions:Y,minWidth:U=250,maxWidth:$="min(600px, 90vw)",baseFontSize:J,stringTruncateLength:X=250,translations:Q=tt,className:G,id:q,customText:ee=nt,customNodeDefinitions:ne=qe,customButtons:re=ot,jsonParse:oe=JSON.parse,jsonStringify:ae=Xe,TextEditor:se,Select:le=He,errorDisplayTime:ce=2500,keyboardControls:ue=rt,editorRef:de,insertAtTop:pe=!1,onCollapse:me,collapseClickZones:he=et})=>{const{getStyles:fe,cssVars:ye}=W(),{open:ge,cancel:ve,getSnapshot:be}=Z(),je=t.useMemo(()=>lt(E),[E]),xe=t.useMemo(()=>((e,t)=>(n,r,o)=>((e,t,n,r,o)=>{if(t[r]){const e=t[r](n);if(null!==e)return e}let s=r in e?e[r]:Ue[r];if(void 0!==o){const e=a(o)?o:{count:o};for(const[t,n]of Object.entries(e))s=s?.replace(`{{${t}}}`,String(n))}return s})(e,t,r,n,o))(Q,ee),[Q,ee]),[we,Ee]=t.useState(K),Ce=t.useRef(null);t.useEffect(()=>{ve();const e=setTimeout(()=>Ee(K),_);return()=>clearTimeout(e)},[K,_]);const De=C(i,[],m),Se=t.useRef(i);Se.current=i;const ke=t.useRef(c);ke.current=c;const Te=t.useRef(xe);Te.current=xe;const Re=t.useRef(De);Re.current=De;const Ne=t.useRef(h);Ne.current=h;const Ae=t.useRef(m);Ae.current=m;const Pe=t.useRef(void 0),Ie=t.useCallback(()=>Se.current,[]),Ke=Ge(f),_e=Ge(y),Me=Ge(me),Ve=Ge(g),Fe=Ge(j),ze=t.useCallback(e=>{Se.current=e,ke.current(e)},[]),Ye=t.useCallback((e,t)=>{ze(it(Se.current,e,t,"update").newData)},[ze]),$e=t.useCallback(e=>{const t=Se.current,n=Ae.current,r=Pe.current,o=ze,{op:a,path:s}=e;switch(a){case"edit":{const{newData:a,currentValue:i,newValue:l}=it(t,s,e.value,"update"),c=C(t,s,n,r);return{input:{...c,newData:a,event:"edit",newValue:l},nodeData:c,isNoOp:i===l,apply:()=>o(a),revert:()=>o(it(Se.current,s,i,"update").newData)}}case"delete":{const{newData:e,currentValue:a}=it(t,s,"","delete"),i=C(t,s,n,r);return{input:{...i,newData:e,event:"delete"},nodeData:i,isNoOp:!1,apply:()=>o(e),revert:()=>o(it(Se.current,s,a,"add",{insert:!0,insertBefore:i.index}).newData)}}case"add":{const a=[...s,e.key],{newData:i,newValue:l}=it(t,a,e.value,"add",e.options),c=C(i,a,n,r);return{input:{...c,value:void 0,size:null,parentData:w(t,s)??null,fullData:t,newData:i,event:"add",newValue:l},nodeData:c,isNoOp:!1,apply:()=>o(i),revert:()=>o(it(Se.current,a,"","delete").newData)}}case"rename":{const a=s.slice(0,-1),i=s[s.length-1],{newKey:l}=e,c=w(t,a),u=Object.fromEntries(Object.entries(c).map(([e,t])=>e===i?[l,t]:[e,t])),{newData:d}=it(t,a,u,"update"),p=C(t,s,n,r);return{input:{...p,newData:d,event:"rename",newKey:l},nodeData:p,isNoOp:i===l,apply:()=>o(d),revert:()=>o(it(Se.current,a,c,"update").newData),extra:{oldKey:i,newKey:l}}}case"move":{const a=s,{path:i,position:l}=e.to,c=t,{newData:u,currentValue:d}=it(t,a,"","delete"),p=a.slice(-1)[0],m=i.slice(0,-1),h=i.slice(-1)[0];let f="number"==typeof h?"above"===l?h:h+1:"number"==typeof p?`arr_${p}`:p;a.slice(0,-1).join(".")===i.slice(0,-1).join(".")&&"number"==typeof p&&"number"==typeof f&&p<f&&(f-=1);const y="number"==typeof f?{insert:!0}:"above"===l?{insertBefore:h}:{insertAfter:h},g=[...m,f],{newData:v}=it(u,g,d,"add",y),b=C(t,a,n,r);return{input:{...b,newData:v,event:"move",newPath:g},nodeData:b,isNoOp:!1,apply:()=>o(v),revert:()=>o(c)}}}},[ze]),Je=t.useCallback((e,t)=>{const n=Ze[e.event],r=()=>Te.current(Qe[e.event],Re.current),o=e=>{const t=e instanceof Error&&e.message?e.message:"string"==typeof e&&e?e:r();return{status:"error",error:{code:n,message:t}}},a=t=>{if(!1===t)return{status:"error",error:{code:n,message:r()}};if(null===t)return{status:"cancel"};if(t&&"object"==typeof t){if(void 0!==t.error)return"string"==typeof t.error?{status:"error",error:{code:n,message:t.error}}:{status:"error",error:t.error};const r=void 0!==t.data,o=void 0!==t.value;if(r&&o&&console.warn("json-edit-react: onUpdate returned both { value } and { data }; { data } (whole-document) takes precedence and { value } is ignored."),r)return{status:"override",value:t.data,path:[]};if(o&&("edit"===e.event||"add"===e.event))return{status:"override",value:t.value,path:e.path}}return{status:"commit"}};let i;try{i=Ne.current(e,t)}catch(e){return o(e)}return s(i)?i.then(a,o):a(i)},[]),at=t.useMemo(()=>({runUpdate:h===n?void 0:Je,buildCommit:$e,applyValue:Ye}),[Je,$e,Ye,h]);d.current=at;const st=t.useMemo(()=>lt(k),[k]),dt=t.useMemo(()=>lt(T),[T]),pt=t.useMemo(()=>lt(A),[A]),mt=t.useMemo(()=>lt(I),[I]),ht=t.useMemo(()=>ct(L),[L]),ft=t.useMemo(()=>((e,t,n)=>{if(!t&&!n)return null;const r=new Set,a=new Map,s=t??We,i=n??"",l=e=>{let t=s(e,i);if(o(e.value)){let n=0;const r=Array.isArray(e.value),s=Object.entries(e.value);for(const[a,i]of s){const s=r?Number(a):a,c={key:s,path:[...e.path,s],level:e.level+1,index:n,value:i,size:o(i)?Object.keys(i).length:null,parentData:e.value,fullData:e.fullData};l(c)&&(t=!0,n++)}a.set(p(e.path),n)}return t&&r.add(p(e.path)),t};return l(e),{visiblePaths:r,visibleChildCounts:a}})(De,ht,we),[i,we,ht,m]),yt=t.useMemo(()=>(e=>{const t={...R};for(const n of Object.keys(R)){const o=n,a=e[o];if(void 0===a)continue;const s="clipboardModifier"===n||"collapseModifier"===n;if(null===a){t[o]=s?[]:null;continue}const i=(()=>s?r(a):"string"==typeof a?{key:a}:a)();t[o]=i}return N.forEach(n=>{void 0===e[n]&&void 0!==e.confirm&&(t[n]=t.confirm)}),t})(ue),[ue]),gt=t.useCallback((e,t)=>((e,t,n)=>{for(const[r,o]of Object.entries(t))if(O(n,e[r],r)){n.preventDefault(),o();break}})(yt,t,e),[yt]),vt=t.useMemo(()=>{const e=ut(ne,"stringifyReplacer");return t=>ae(t,e)},[ne,ae]),bt=t.useMemo(()=>{const e=ut(ne,"parseReviver");return t=>{const n=oe(t,e);return l(n)}},[ne,oe]),jt=t.useRef(null),{setCollapseState:xt}=te(),wt=t.useCallback((e,t)=>{!1!==M&&("function"!=typeof M?e.sort((e,n)=>{const r=t(e)[0],o=t(n)[0];return r<o?-1:r>o?1:0}):e.sort((e,n)=>M(t(e),t(n))))},[M]);Pe.current=wt;const Et=t.useCallback(e=>C(Ie(),e,Ae.current,Pe.current),[Ie]);u.current=Et,t.useImperativeHandle(de,()=>{const e=Symbol("path-missing");return{collapse:e=>xt(e),startEdit:({path:t,overrideRestrictions:n=!1})=>w(Ie(),t,e)===e?"PATH_NOT_FOUND":n||st(C(Ie(),t,m,wt))?(ge(t,{force:!0}),!0):"RESTRICTED",confirm:()=>{jt.current&&(jt.current.click(),"editing"!==be().active?.phase&&ve())},cancel:()=>ve()}},[xt,ge,ve,be,st,Ie,m,wt]);const Ct=Oe(ne,De),Dt=t.useMemo(()=>({object:!0===pe||"object"===pe,array:!0===pe||"array"===pe}),[pe]),St={mainContainerRef:Ce,name:m,nodeData:De,getLatestData:Ie,onChange:Ke,onError:_e,onEditEvent:Ve,showErrorMessages:v,showCollectionCount:S,collapseFilter:je,collapseAnimationTime:D,allowEditFilter:st,allowDeleteFilter:dt,allowAddFilter:pt,allowTypeSelection:P,allowDragFilter:mt,canDragOnto:!1,canAddHere:!1,showClipboardButton:b,onCopy:Fe,sortKeys:M,sort:wt,showArrayIndexes:V,arrayIndexStart:F,showStringQuotes:z,showIconTooltips:B,indent:x,defaultValue:H,newKeyOptions:Y,stringTruncateLength:X,translate:xe,customNodeDefinitions:ne,customNodeData:Ct,customButtons:re,parentData:null,jsonParse:bt,jsonStringify:vt,TextEditor:se,Select:le,errorDisplayTime:ce,handleKeyboard:gt,keyboardControls:yt,insertAtTop:Dt,onCollapse:Me,editConfirmRef:jt,collapseClickZones:he},kt={...fe("container",De),...ye,minWidth:U,maxWidth:$};return kt.fontSize=J??kt.fontSize,e.jsx("div",{id:q,ref:Ce,className:`jer-editor-container ${G??""}`,style:kt,children:e.jsx(ie,{value:ft,children:o(i)&&!Ct.renderCollectionAsValue?e.jsx(Be,{data:i,...St}):e.jsx(Le,{data:i,showLabel:!0,...St})})})};function st(n){t.useInsertionEffect(()=>{(()=>{if("undefined"==typeof document)return;const e=document.head.querySelector(`style[${Je}]`);if(e)return void(e.textContent!==$e&&(e.textContent=$e));const t=document.createElement("style");t.setAttribute(Je,""),t.textContent=$e,document.head.appendChild(t)})()},[]);const r=t.useRef(void 0),o=t.useRef(void 0),a=n;return e.jsx(H,{theme:a.theme??_,children:e.jsx(ae,{onEditEvent:a.onEditEvent,onCollapse:a.onCollapse,buildNodeDataFromPathRef:r,commitRef:o,children:e.jsx(at,{...a,buildNodeDataFromPathRef:r,commitRef:o})})})}const it=(e,t,n,r,o={})=>{if(0===t.length)return{currentData:e,newData:n,currentValue:e,newValue:n};const a={remove:"delete"===r,...o},s="add"!==r?w(e,t):void 0;return{currentData:e,newData:v(e,t,n,a),currentValue:s,newValue:"delete"!==r?n:void 0}},lt=e=>"boolean"==typeof e?()=>e:"number"==typeof e?({level:t})=>t>=e:e,ct=e=>{if(void 0!==e)return"value"===e?We:"key"===e?Ye:"all"===e?(e,t)=>We(e,t)||Ye(e,t):e},ut=(e,t)=>{const n="stringifyReplacer"===t?[e=>void 0===e?c: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}};exports.AutogrowTextArea=S,exports.IconSvg=je,exports.JsonEditor=st,exports.JsonViewer=function(r){const{editorRef:o,...a}=r,s=t.useRef(null);return t.useImperativeHandle(o,()=>({collapse:e=>s.current?.collapse(e)}),[]),e.jsx(st,{...a,editorRef:s,setData:n,allowEdit:!1,allowAdd:!1,allowDelete:!1,allowDrag:!1})},exports.StringDisplay=pe,exports.StringEdit=me,exports.assign=v,exports.collectionDataTypes=De,exports.defaultTheme=_,exports.extract=w,exports.isCollection=o,exports.matchNode=We,exports.matchNodeKey=Ye,exports.splitPropertyString=u,exports.standardDataTypes=Se,exports.toPathString=p,exports.useKeyboardListener=ge,exports.valueDataTypes=Ce;
@@ -1 +1 @@
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,useInsertionEffect as h,useImperativeHandle as m}from"react";const f=()=>{},y=e=>Array.isArray(e)?e:[e],g=e=>null!==e&&"object"==typeof e,v=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),b=e=>null!=e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof e.then,w=(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},D=e=>{if(e!==E){if(e&&"object"==typeof e)for(const t in e){const n=e[t],r=D(n);r!==n&&(e[t]=r)}return e}},E="__​undefined__",C=e=>e.split(/(\.|\[\d+\])/).filter(e=>"."!==e&&""!==e).map(e=>{const t=/\[(\d+)\]/.exec(e);return t?Number(t[1]):e}),j=e=>"string"==typeof e?e:"number"==typeof e?String(e):e.reduce((e,t)=>"number"==typeof t?`${e}[${t}]`:""===e?t:`${e}.${t}`,""),S=e=>1===e.length&&""===e[0]?"\0":e.map(e=>encodeURIComponent(String(e))).join("/"),O=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),k=(e,t)=>e.length>=t.length&&t.every((t,n)=>t===e[n]),T=(e,t,n,r,o)=>{if(!r)throw new Error(o??`Invalid property path: ${t}\nCouldn't access "${n}" in ${JSON.stringify(e)}`)},N=e=>Array.isArray(e),x=(e,t)=>e.filter((e,n)=>n!==t),R=(e,t,n,r={})=>{const{remove:o=!1,createNew:a=!0,noError:i=!1}=r,l=e,s=j(t),c={...r,remove:o,createNew:a,noError:i,fullData:l,fullPath:s},d=Array.isArray(t)?t:C(t);return N(e)&&o&&1===d.length?x(e,d[0]):A(e,d,n,c)},A=(e,t,n,r)=>{const o=v(e)?{...e}:null,a=N(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=>A(e,t,n,r));if(1===t.length)return o&&"string"==typeof u?P(o,u,n,r)??o:a&&"number"==typeof u?(I(a,u,n,r),a):(T(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 N(e)?p[u]=x(e,n):T(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],!N(m)&&!v(m)){if(!i)return T(c,d,u,s),p;p[u]={}}return p[u]=A(p[u],h,n,r),p}var m;if(i){const e="number"==typeof h[0]?[]:{};if(o)return p[u]=e,p[u]=A(p[u],h,n,r),p;if(a&&Array.isArray(p)){p.push(e);const t=p.length-1;return p[t]=A(p[t],h,n,r),p}}return T(c,d,u,s),p},P=(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;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]:T(c,d,t,i):a||u?e[t]=n:T(c,d,t,i)},I=(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):T(a,i,t,o)},L=(e,t,n)=>{const r=Array.isArray(t)?t:C(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=>L(e,r,n));if("object"!=typeof e||null===e||!(o in e))return K(e,o,n);const a=e[o];return 1===r.length?a:L(a,r.slice(1),n)},K=(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},_=(e,t,n="",r)=>{if(0===t.length)return{key:n,path:[],level:0,index:0,value:e,size:g(e)?Object.keys(e).length:1,parentData:null,fullData:e};const o=t[t.length-1],a=L(e,t),i=L(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:g(a)?Object.keys(a).length:null,parentData:i,fullData:e}},V="undefined"!=typeof window?o:a,M=({className:n,name:r,value:o,setValue:a,onKeyDown:l,styles:s,textAreaRef:c})=>{const d=i(null);if(V(()=>{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})]})},z=e=>e.shiftKey?"Shift":e.metaKey?"Meta":e.ctrlKey?"Control":e.altKey?"Alt":void 0,F=(e,t,n)=>{if(!t)return!1;const r=e.key,o=z(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))},B={key:"Enter"},H={confirm:B,cancel:{key:"Escape"},objectConfirm:{...B,modifier:["Meta","Shift","Control"]},objectLineBreak:B,stringConfirm:B,stringLineBreak:{...B,modifier:["Shift"]},numberConfirm:B,numberUp:{key:"ArrowUp"},numberDown:{key:"ArrowDown"},tabForward:{key:"Tab"},tabBack:{key:"Tab",modifier:"Shift"},booleanConfirm:B,booleanToggle:{key:" "},clipboardModifier:["Meta","Control"],collapseModifier:["Alt"]},W=["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=L(e,a),s=X(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(g(d.value)){if(0===Object.keys(d.value).length)return U(e,[...a,d.key],n,r,o);u=$(e,[...a,d.key],n,r)}else u=[...a,d.key];return u?o(_(e,u,"",r))?u:U(e,u,n,r,o):null},$=(e,t,n="next",r)=>{const o=L(e,t);if(!g(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 $(e,[...t,i],n,r)},X=e=>Array.isArray(e)?e.map((e,t)=>({value:e,key:t})):Object.entries(e).map(([e,t])=>({key:e,value:t})),J={fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2},Q={displayName:"Default",icons:{add:{content:/*#__PURE__*/e(n,{children:[/*#__PURE__*/t("path",{d:"M13 7h-2v4H7v2h4v4h2v-4h4v-2h-4z"}),/*#__PURE__*/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:/*#__PURE__*/e(n,{children:[/*#__PURE__*/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"}),/*#__PURE__*/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:/*#__PURE__*/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:/*#__PURE__*/e(n,{children:[/*#__PURE__*/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"}),/*#__PURE__*/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"}),/*#__PURE__*/t("path",{d:"M15 10l-4 4 4 4"})]}),svgProps:J,scale:.86},ok:{content:/*#__PURE__*/e(n,{children:[/*#__PURE__*/t("path",{d:"M22 11.08V12a10 10 0 11-5.93-9.14"}),/*#__PURE__*/t("path",{d:"M22 4L12 14.01l-3-3"})]}),svgProps:J,scale:.9},cancel:{content:/*#__PURE__*/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:/*#__PURE__*/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"}},Z={container:"backgroundColor",collection:"backgroundColor",collectionInner:"backgroundColor",collectionElement:"backgroundColor",headerRow:"backgroundColor",valueRow:"backgroundColor",dropZone:"borderColor",inputHighlight:"backgroundColor"},G=e=>[Q,...y(e)].map(e=>"styles"in e?e:{styles:e}),q=e=>{const t={};for(const{icons:n}of G(e))n&&Object.assign(t,n);return t},ee=/*#__PURE__*/l({getStyles:()=>({}),icons:/*#__PURE__*/q(Q),cssVars:{}}),te=({theme:e=Q,children:n})=>{const r=c(()=>(e=>{var t;const n=G(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?{[Z[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(()=>/*#__PURE__*/q(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(ee.Provider,{value:l,children:n})},ne=()=>s(ee),re={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"}},oe=(e,t)=>re[e][t]??null,ae=(e,t)=>null!==e&&null!==t&&e.op===t.op&&O(e.path,t.path),ie={active:null,settling:{}},le=/*#__PURE__*/l(null),se=({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=((e,t,n)=>{let r=ie;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,ae(r.active,n)&&r.active?.phase===n?.phase||c({...r,active:n});const o=oe(e.op,"start");o&&u(e.path,o)},h=(e,t,o,l,s,u,p,h,m)=>{const f=S(e);if(!p()){if("cancel"===l.status||"error"===l.status){r.active&&O(r.active.path,e)&&("held"===r.active.phase||"editing"===r.active.phase)&&(c({...r,active:null}),a=null,i=null);const n=oe(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&&!ae(o,n);if(l&&i)return void i(()=>p(n,t));const s=a;if(a=null,i=null,s&&s(),l&&ae(r.active,o)){const e=oe(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=oe(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 ae(r.active,{path:o,op:t})&&c({...r,active:null}),a=null,i=null,p?.(),Promise.resolve(void 0)}const y=f?.extra,g=S(o),v=++s;if(!l){const e=oe(t,"submit");e&&u(o,e)}if(!f||f.isNoOp){ae(r.active,{path:o,op:t})&&c({...r,active:null}),a=null,i=null;const e=oe(t,"commit");return e&&(f?d(f.nodeData,e,y):u(o,e,y)),p?.(),Promise.resolve(void 0)}const{input:w,nodeData:D,apply:E,revert:C}=f,j=!!m?.runUpdate;let O=!1,k=!1;const T=()=>{if(O)return;O=!0,E(),a=null,i=null,ae(r.active,{path:o,op:t})&&c({...r,active:null}),j&&((e,t)=>{c({...r,settling:{...r.settling,[e]:t}})})(g,v);const e=oe(t,"commit");e&&d(D,e,y),p?.()},N={hold:()=>(k=!0,c({...r,active:{path:o,op:t,phase:"held",force:r.active?.force}}),()=>T())};if(!j)return T(),Promise.resolve(void 0);const x=m.runUpdate(w,N),R=b(x);if(!k&&!l&&!R)return Promise.resolve(h(o,t,v,x,T,C,()=>O,D,y));const A=R?x:Promise.resolve(x);let P;return k||(l?P=setTimeout(T,100):T()),A.then(e=>(clearTimeout(P),h(o,t,v,e,T,C,()=>O,D,y)))},areChildrenBeingEdited:e=>null!==r.active&&k(r.active.path,e)}})(a,r,o)),t(le.Provider,{value:l.current,children:e})},ce=()=>{const e=s(le);if(!e)throw new Error("Missing Editing Context Provider");return e},de=e=>{const t=ce();return u(t.subscribe,()=>e(t.getSnapshot()),()=>e(t.getServerSnapshot()))},ue=/*#__PURE__*/l(null),pe=({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=y(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(ue.Provider,{value:u,children:e})},he=()=>{const e=s(ue);if(!e)throw new Error("Missing Collapse Context Provider");return e},me=(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},fe=/*#__PURE__*/l(null),ye=({children:e})=>{const[n,r]=p({path:null,canDelete:!1}),o=i(!1),a=c(()=>({dragSource:n,setDragSource:r,armed:o}),[n]);return t(fe.Provider,{value:a,children:e})},ge=({children:e,onEditEvent:n,onCollapse:r,buildNodeDataFromPathRef:o,commitRef:a})=>t(se,{onEditEvent:n,buildNodeDataFromPathRef:o,commitRef:a,children:t(pe,{onCollapse:r,buildNodeDataFromPathRef:o,children:t(ye,{children:e})})}),ve=/*#__PURE__*/l(void 0),be=({value:e,children:n})=>t(ve.Provider,{value:e,children:n}),we=()=>{const e=s(ve);if(void 0===e)throw new Error("Missing FilterStateProvider");return e},De=e=>{const t=we();return null===t||t.visiblePaths.has(S(e))},Ee=e=>{const t=we();return null===t?null:t.visibleChildCounts.get(S(e))??null},Ce="**INVALID_FUNCTION**",je=({nodeData:r,showStringQuotes:o=!0,stringTruncateLength:a=200,pathString:i,canEdit:l,setIsEditing:s,styles:c,translate:d,showIconTooltips:u=!1,value:h,TextWrapper:m=({children:e})=>e})=>{const f=h??r.value,[y,g]=p(!1),v=o?'"':"",b=f.length>a,w=()=>{l?s(!0):g(!y)},D=d("SHOW_MORE",r);return e("div",{id:`${i}_display`,onDoubleClick:w,onClick:e=>{(e.getModifierState("Control")||e.getModifierState("Meta"))&&w()},className:"jer-value-string",style:c,children:[v,b?e(n,y?{children:[t(m,{children:e("span",{children:[f,v]})})," ",t("button",{type:"button",tabIndex:-1,className:"jer-string-expansion jer-show-less",onClick:()=>g(!1),children:d("SHOW_LESS",r)})]}:{children:[e(m,{children:[t("span",{children:f.slice(0,a-2).trimEnd()})," "]}),t("button",{type:"button",tabIndex:-1,className:"jer-string-expansion jer-ellipsis",onClick:()=>g(!0),"aria-label":D,title:u?D:"",children:"..."}),v]}):t(m,{children:`${f}${v}`})]})},Se=({styles:e,pathString:n,value:r,setValue:o,handleEdit:a,handleKeyboard:l,keyboardCommon:s})=>{const c=i(null);return t(M,{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})},Oe=({isEditing:e,path:n,enumType:r,...o})=>{const{getStyles:a}=ne(),i=S(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(Se,{styles:a("input",c),pathString:i,...o,setValue:o.setValue}):t(je,{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}=ne();return r?t("input",{className:"jer-input-number",type:"text",name:S(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})},Te=({value:e,setValue:n,isEditing:r,path:o,setIsEditing:a,handleEdit:i,nodeData:l,handleKeyboard:s,keyboardCommon:c})=>{const{getStyles:d}=ne();return"boolean"!=typeof e?null:r?t("input",{className:"jer-input-boolean",type:"checkbox",name:S(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)})},Ne=(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])},xe=({value:e,isEditing:n,setIsEditing:r,handleEdit:o,nodeData:a,handleKeyboard:i,keyboardCommon:l})=>{const{getStyles:s}=ne();return Ne(n,e=>i(e,{confirm:o,...l})),t("div",{onDoubleClick:()=>r(!0),className:"jer-value-null",style:s("null",a),children:String(e)})},Re=({value:e})=>{let n="Error!";switch(typeof e){case"string":e===Ce&&(n="Function");break;case"undefined":n="Undefined";break;case"symbol":n="Symbol"}return t("span",{className:"jer-value-invalid",children:n})},Ae=({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}=ne(),a=o[e],i=`icon${e[0].toUpperCase()}${e.slice(1)}`;return t(Ae,{viewBox:a.viewBox,...a.svgProps,scale:a.scale,className:"collection"===e?void 0:"jer-icon",style:r(i,n),children:a.content})},Ie=({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}=ne(),{open:D,cancel:E}=ce(),C=u("KEY_NEW",d),[S,k]=p(C),[T,N]=p(!1),{path:x,value:R}=d,A=de(e=>{const t=e.active;return null!==t&&"add"===t.op&&O(t.path,x)}),P=Array.isArray(T);V(()=>{if(!A)return N(!1),void k(C);const e=Object.keys(L(d.fullData,x)),t=y?y(d)?.filter(t=>!e.includes(t)):null;t&&k(""),N(t??!0)},[A]);const I=()=>{a&&(P&&!S||a("array"===s?"":S))};return e("div",{className:"jer-edit-buttons",style:{opacity:A?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=z(e);if(i&&h.clipboardModifier.includes(i)?(t=j(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?D(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,label:r},o)=>{const a=e=>n&&n(d,e);return r?t("button",{type:"button",tabIndex:-1,onClick:a,"aria-label":r,title:v?r:"",children:t(e,{nodeData:d})},o):t("div",{onClick:a,children:t(e,{nodeData:d})},o)}),A&&a&&"object"===s&&e(n,{children:[P?t(b,{name:"new-key-select",onChange:a,defaultValue:"",autoFocus:!0,onKeyDown:e=>m(e,{cancel:()=>E()}),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:S,onChange:e=>k(e.target.value),autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>{m(e,{stringConfirm:()=>I(),cancel:()=>E()})},style:w("input",d)}),t(Le,{onOk:()=>I(),onCancel:()=>E(),nodeData:d,translate:u,showIconTooltips:v,editConfirmRef:f,hideOk:P})]})]})},Le=({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"],_e=["object","array"],Ve=[...Ke,..._e],Me=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}},ze=(e=[],t)=>{const n=e.find(({condition:e})=>e(t));return n?Me(n):{}},Fe=({props:e,collapsed:t})=>{const{nodeData:n,parentData:r,onError:o,getLatestData:a,showErrorMessages:l,allowEditFilter:s,allowDeleteFilter:c,allowAddFilter:u,allowDragFilter:h,canAddHere:m,translate:f,errorDisplayTime:y,sort:g,arrayIndexStart:v,handleKeyboard:b,customNodeData:w}=e,{submit:D}=ce(),[E,C]=p(null),j={...n,collapsed:t,visibleSize:Ee(n.path)},{path:k,key:T,size:N}=j,x=S(k),R=de(e=>{const t=e.active;return null!==t&&"edit"===t.op&&O(t.path,k)}),A=de(e=>{const t=e.active;return null!==t&&"rename"===t.op&&O(t.path,k)}),P=de(e=>x in e.settling),I=s(j),L=c(j),K=u(j),_=h(j),V=e=>{l&&(C(e),setTimeout(()=>C(null),y)),console.warn("Error",e)},M=i(j);M.current=j;const z=d((e,t)=>{V(e.message),o&&o({...M.current,fullData:a(),error:e,errorValue:t})},[o,l,a,y]),F=we(),B=d(e=>(null===F||F.visiblePaths.has(S(e.path)))&&s(e),[F,s]),H=e=>U(a(),k,e,g,B),W=(e,t)=>{r&&(T!==e&&Object.keys(r).includes(e)?z({code:"KEY_EXISTS",message:f("ERROR_KEY_EXISTS",j)},e):D({op:"rename",path:k,newKey:e,onCommit:t}).then(t=>{"error"===t?.status&&z(t.error,e)}))},Y="number"==typeof k.slice(-1)[0],$=null!==r&&!Y&&L&&m,X={isEditing:R,isEditingKey:A,isPending:P,isArray:Y,canEditKey:$},J=""===T&&k.length>0?f("EMPTY_STRING",j):null;return{pathString:x,nodeData:j,path:k,name:T,size:N,canEdit:I,canDelete:L,canAdd:K,canDrag:_,error:E,showError:V,onError:z,setError:C,handleEditKey:W,derivedValues:X,emptyStringKey:J,getNextOrPreviousAtPath:H,buildKeyDisplayProps:({handleCancel:e,getStyles:t,keyValueArray:n,handleClick:r})=>({canEditKey:$,isEditingKey:A,pathString:x,path:k,name:T,arrayIndexStart:v,handleKeyboard:b,handleEditKey:W,handleCancel:e,styles:t("property",j),getNextOrPrevious:H,emptyStringKey:J,nodeData:j,customNodeData:w,getStyles:t,...void 0!==n?{keyValueArray:n}:{},...void 0!==r?{handleClick:r}:{}})}},Be=({canDrag:e,canDelete:n,canDragOnto:r,canAddHere:o,path:a,nodeData:i,onError:l,translate:d})=>{const{getStyles:u}=ne(),{dragSource:h,setDragSource:m,armed:f}=(()=>{const e=s(fe);if(!e)throw new Error("Missing DragSource Context Provider");return e})(),y=ce(),[g,v]=p(!1),b=()=>null!==h.path&&!k(a,h.path)&&(O(h.path.slice(0,-1),a.slice(0,-1))?r:h.canDelete&&o),w=c(()=>e?{onMouseDown:e=>{0===e.button&&null===y.getSnapshot().active&&(f.current=!0)},onMouseUp:()=>{f.current=!1},onDragStart:e=>{if(!f.current||null!==y.getSnapshot().active)return e.preventDefault(),void e.stopPropagation();f.current=!1,e.stopPropagation(),m({path:a,canDelete:n})},onDragEnd:e=>{f.current=!1,e.stopPropagation(),m({path:null,canDelete:!1})}}:{},[e,n,a]),D=c(()=>e=>r||o?{onDragOver:e=>{e.stopPropagation(),b()&&e.preventDefault()},onDrop:t=>{t.stopPropagation(),C(e),m({path:null,canDelete:!1}),v(!1)},onDragEnter:t=>{t.stopPropagation(),b()&&v(e)},onDragExit:e=>{e.stopPropagation(),v(!1)}}:{},[h,r,o,a]),E=c(()=>null!==h.path&&b()?t("div",{className:"jer-drop-target-bottom",style:{height:"50%",position:"absolute",width:"100%",top:"50%",zIndex:a.length},...D("below")}):null,[h,r,o,a.length]),C=e=>{if(null===h.path)return;if(!b())return;const t=h.path.slice(-1)[0],n=h.path.slice(0,-1),r=a.slice(0,-1),{parentData:o}=i;"string"==typeof t&&o&&!Array.isArray(o)&&Object.keys(o).includes(t)&&t in o&&!O(n,r)?l({code:"KEY_EXISTS",message:d("ERROR_KEY_EXISTS",i)},t):y.submit({op:"move",path:h.path,to:{path:a,position:e},instant:!0})};return{dragSourceProps:w,getDropTargetProps:D,BottomDropTarget:E,DropTargetPadding:({position:e,nodeData:n})=>g===e?t("div",{className:"jer-drag-n-drop-padding",style:u("dropZone",n)}):null,handleDrop:C}},He=({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:D}=ce(),E=r.useRef(null),C=e=>d(E.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:E,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):D()}else w(i)})},tabBack:()=>{const t=e.target.value;d(t,()=>{const e=f("prev");e?w(e):D()})}}),style:{width:j.length/1.5+.5+"em"}})},We=new Set(["nodeData","customNodeData"]),Ye=(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||!O(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(!We.has(n)&&!Object.is(e[n],t[n]))return!1;return!0},Ue=n=>{const{data:r,parentData:o,onChange:l,showClipboardButton:s,onCopy:u,canDragOnto:h,canAddHere:m,allowTypeSelection:y,showLabel:g,stringTruncateLength:v,showStringQuotes:b,indent:D,translate:E,customNodeDefinitions:C,customNodeData:j,Select:S,handleKeyboard:k,keyboardControls:T,editConfirmRef:N,jsonStringify:x,showIconTooltips:R,getLatestData:A}=n,{getStyles:P}=ne(),{open:I,cancel:L,submit:K,getSnapshot:_}=ce(),{setCollapseState:V}=he(),[M,z]=p("function"==typeof r?Ce:r),{nodeData:F,path:B,name:H,canEdit:W,canDelete:Y,canDrag:U,error:$,onError:X,setError:J,derivedValues:Q,getNextOrPreviousAtPath:Z,buildKeyDisplayProps:G}=Fe({props:n}),{dragSourceProps:q,getDropTargetProps:ee,BottomDropTarget:te,DropTargetPadding:re}=Be({canDrag:U,canDelete:Y,canDragOnto:h,canAddHere:m,path:B,nodeData:F,onError:X,translate:E}),[oe,ae]=p(Je(r,j)),ie=i(M);ie.current=M;const le=i(F);le.current=F;const se=d(e=>{if(!l)return void z(e);const t=l({...le.current,value:ie.current,fullData:A(),newValue:e});z(t)},[l,A]),de=()=>{z("function"==typeof r?Ce:r),ae(Je(r,j)),me(w(r,ue))};a(()=>{Q.isEditing||de()},[r]);const ue=c(()=>{const e=[...Ve,...C.filter(({showInTypeSelector:e=!1,name:t})=>e&&!!t).map(({name:e})=>e)];if("boolean"==typeof y)return y?e:[];if(Array.isArray(y))return y;const t=y(F);return"boolean"==typeof t?t?e:[]:t},[F,y,C]),[pe,me]=p(w(M,ue)),{isEditing:fe,isPending:ye}=Q,ge=De(B),ve=i(f);if(!ge)return null;const be=fe&&oe!==Je(r,j),we=be?C.find(e=>e.name===oe&&Xe(e)):void 0,Ee=we?Me(we):j,{CustomComponent:je,componentProps:Se,showKey:Oe=!0,showEditTools:ke=!0,showOnEdit:Te,showOnView:Ne,passOriginalNode:xe}=Ee,Re=je&&(void 0!==we||!be&&(fe&&Te||!fe&&Ne)),Ae=e=>{V(null);const t=be&&!we?void 0:Ee,n=t?.toStandardType?t.toStandardType(M):M,r=C.find(t=>t.name===e);if(r){const t="function"==typeof r.defaultValue?r.defaultValue(F):r.defaultValue;if(Xe(r)){let o=t;if(r.fromStandardType)try{o=r.fromStandardType(n,F,r.componentProps)}catch{}return z(o),ae(e),void me(null)}return K({op:"edit",path:B,value:t}).then(Pe(t)),void V({path:B,collapsed:!1,includeChildren:!1})}const o=ue.find(t=>t instanceof Object&&t.enum===e);if(o)return"string"==typeof M&&o.values.includes(M)||z(o.values[0]),me(o),void ae(e);const a=Ge(n,e,E("DEFAULT_NEW_KEY",F));if("object"===e||"array"===e||"null"===e)return K({op:"edit",path:B,value:a}).then(Pe(a)),void("null"!==e&&V({path:B,collapsed:!1,includeChildren:!1}));z(a),ae(e),me(null)},Pe=e=>t=>{if("error"===t?.status&&X(t.error,e),"error"===t?.status||"cancel"===t?.status){const e=_().active;"editing"===e?.phase&&O(e.path,B)||de()}},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(Re&&Ee.fromStandardType)try{r=Ee.fromStandardType(M,F,Ee.componentProps)}catch(e){return void X({code:"UPDATE_ERROR",message:e instanceof Error?e.message:String(e)},M)}else r="number"===oe?Ze(M):M;J(null),we&&V({path:B,collapsed:!1,includeChildren:!1}),K({op:"edit",path:B,value:r,onCommit:t}).then(Pe(r))};ve.current=Ke;const _e=()=>{J(null),de(),L()},{isEditingKey:ze}=Q,We=!!$,Ye=fe&&ue.length>1,Ue=("invalid"!==oe||je)&&!$&&ke,$e=g&&Oe,qe=()=>I(B,{cancelOp:de,commitOp:e=>ve.current(void 0,e)}),et=W?qe:f,tt=e=>()=>{const t=Z(e);t&&Ke(void 0,()=>I(t))},nt={value:M,parentData:o,setValue:se,isEditing:fe,canEdit:W,setIsEditing:et,handleEdit:Ke,handleCancel:_e,path:B,stringTruncateLength:v,showStringQuotes:b,showIconTooltips:R,nodeData:F,enumType:pe,translate:E,handleKeyboard:k,keyboardCommon:{cancel:_e,tabForward:tt("next"),tabBack:tt("prev")},Select:S},rt={...G({handleCancel:_e,getStyles:P}),customNodeData:Ee},ot=Re?t(je,{...n,value:M,componentProps:Se,setValue:se,handleEdit:Ke,handleCancel:_e,onKeyDown:e=>k(e,{stringConfirm:Ke,cancel:_e}),isEditing:fe,isPending:ye,setIsEditing:et,getStyles:P,originalNode:xe?Qe(r,oe,nt):void 0,originalNodeKey:xe?t(He,{...rt,customNodeData:void 0}):void 0,canEdit:W,keyboardCommon:nt.keyboardCommon}):Qe(r,oe,nt);return e("div",{className:"jer-component jer-value-component",style:{marginLeft:null!==o?D/2+"em":0,position:"relative"},draggable:U&&!fe&&!ze,...q,...ee("above"),children:[te,t(re,{position:"above",nodeData:F}),e("div",{className:"jer-value-main-row",style:{...P("valueRow",F),flexWrap:H.length>10?"wrap":"nowrap"},children:[$e&&t(He,{...rt}),e("div",{className:"jer-value-and-buttons",children:[t("div",{className:"jer-input-component",children:ot}),fe?t(Le,{onOk:Ke,onCancel:_e,nodeData:F,translate:E,showIconTooltips:R,editConfirmRef:N}):Ue&&t(Ie,{startEdit:W?qe:void 0,handleDelete:Y?()=>{K({op:"delete",path:B,instant:!0}).then(e=>{"error"===e?.status&&X(e.error,M)})}:void 0,showClipboardButton:s,onCopy:u,translate:E,customButtons:n.customButtons,nodeData:F,handleKeyboard:k,keyboardControls:T,editConfirmRef:N,jsonStringify:x,showIconTooltips:R,Select:S}),Ye&&t(S,{name:`${H}-type-select`,value:pe?pe.enum:oe,onChange:e=>Ae(e),options:ue.map(e=>e instanceof Object&&"enum"in e?e.enum:e)}),We&&t("span",{className:"jer-error-slug",style:P("error",F),children:$})]})]}),t(re,{position:"below",nodeData:F})]})},$e=/*#__PURE__*/r.memo(Ue,Ye),Xe=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",Qe=(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(Oe,{...r,value:a});case"number":return t(ke,{...r,value:a});case"boolean":return t(Te,{...r,value:a});case"null":return t(xe,{...r});default:return t(Re,{...r})}},Ze=e=>{if("symbol"==typeof e)return 0;const t=Number(e);return isNaN(t)?0:t},Ge=(e,t,n)=>{switch(t){case"string":return null==e?"":String(e);case"number":return Ze(e);case"boolean":return!!e;case"null":return null;case"object":return{[n]:e};case"array":return[e];default:return String(e)}},qe=r=>{const{getStyles:o}=ne(),{open:l,cancel:s,submit:u,areChildrenBeingEdited:h,getSnapshot:m}=ce(),{setCollapseState:y}=he(),{mainContainerRef:v,data:b,nodeData:w,parentData:D,showCollectionCount:E,canDragOnto:C,canAddHere:j,collapseFilter:S,collapseAnimationTime:T,showClipboardButton:N,onCopy:x,showIconTooltips:R,indent:A,sort:P,showArrayIndexes:I,defaultValue:L,newKeyOptions:K,translate:_,customNodeDefinitions:V,customNodeData:F,jsonParse:B,jsonStringify:H,TextEditor:W,Select:U,keyboardControls:$,handleKeyboard:X,insertAtTop:J,onCollapse:Q,editConfirmRef:Z,collapseClickZones:G,getLatestData:q}=r,[ee,te]=p(null),re=S(w),{contentRef:oe,isAnimating:ae,maxHeight:ie,collapsed:le,animateCollapse:se,cssTransitionValue:ue}=((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||((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)})(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}})(b,T,re,v,H),{pathString:pe,nodeData:fe,path:ye,name:ge,size:ve,canEdit:be,canDelete:we,canAdd:Ee,canDrag:Ce,error:je,setError:Se,onError:Oe,derivedValues:ke,buildKeyDisplayProps:Te}=Fe({props:r,collapsed:le}),{dragSourceProps:Ne,getDropTargetProps:xe,BottomDropTarget:Re,DropTargetPadding:Ae}=Be({canDrag:Ce,canDelete:we,canDragOnto:C,canAddHere:j,path:ye,nodeData:fe,onError:Oe,translate:_}),Ke=i(!re),{isEditing:_e,isEditingKey:Ve,isPending:Me,isArray:We}=ke,Ye=(e=>{const t=i(e),n=!Object.is(t.current,e);return a(()=>{t.current=e}),n})(S);a(()=>{const e=S(fe)&&!_e;Ke.current=!e,se(e),Ye&&y(null)},[S]),((e,t,n)=>{const{commands:r,version:o}=he(),l=i(0);a(()=>{if(o===l.current)return;if(l.current=o,!r)return;let a;for(const t of r)me(e,t)&&(a=t);a&&(a.collapsed||(t.current=!0),n(a.collapsed))},[o,r])})(ye,Ke,se);const Ue=i(null),Xe=d(e=>te(t=>"function"==typeof e?e(t??H(b)):e),[b,H]),Je=d(()=>te(null),[]),Qe=c(()=>_e?ee??H(b):null,[_e,ee,b,H]),Ze=d((e,t)=>{if("function"!=typeof L)return L;const n=L(e,t);return void 0!==n?n:null},[L]),Ge=d(e=>K?"function"!=typeof K?K:K(e):null,[K]),{CustomComponent:qe,componentProps:tt,CustomWrapperComponent:nt,wrapperProps:rt={},showKey:ot=!0,showEditTools:at=!0,showOnEdit:it,showOnView:lt,showCollectionWrapper:st=!0,passOriginalNode:ct}=F,dt=de(e=>null!==e.active&&k(e.active.path,ye));dt&&le&&se(!1);const ut=De(ye)||0===fe.level,pt=i(f);if(!ut&&!dt)return null;const{visibleSize:ht}=fe,mt=Array.isArray(b)?"array":"object",ft="array"===mt?{open:"[",close:"]"}:{open:"{",close:"}"},yt=e=>{if("Tab"===e.key&&!e.getModifierState("Shift")&&e.target===Ue.current){e.preventDefault();const t=Y(Ue,"\t");return void te(t)}X(e,{objectConfirm:vt,cancel:wt})},gt=e=>{e.stopPropagation();const t=z(e);if(t&&$.collapseModifier.includes(t))return Ke.current=!0,void y({collapsed:!le,path:ye,includeChildren:!0});h(ye)||(Ke.current=!0,Q&&Q({...fe,fullData:q(),collapsed:!le,includeChildren:!1}),se(!le))},vt=e=>{let t=b;if(null!==ee)try{t=B(ee)}catch{return void Oe({code:"INVALID_JSON",message:_("ERROR_INVALID_JSON",fe)},ee)}Se(null);const n="function"==typeof e?e:void 0;u({op:"edit",path:ye,value:t,onCommit:()=>{Je(),n?.()}}).then(e=>{if("error"===e?.status&&Oe(e.error,t),"error"===e?.status||"cancel"===e?.status){const e=m().active;"editing"===e?.phase&&O(e.path,ye)||Je()}})};pt.current=vt;const bt=ye.length>0?()=>{u({op:"delete",path:ye,instant:!0}).then(e=>{"error"===e?.status&&Oe(e.error,b)})}:void 0,wt=()=>{s(),Se(null),Je()},Dt="when-collapsed"===E?le:"when-collapsed-or-filtered"===E?le||null!=ht:E,Et=!_e&&at,Ct=(I||!We)&&ot&&void 0!==ge,jt=qe&&(_e&&it||!_e&&lt),St=Object.entries(b).map(([e,t])=>["array"===mt?Number(e):e,t]);"object"===mt&&P(St,e=>e);const Ot=!_e||!!qe&&it,kt=()=>e("div",{className:"jer-collection-text-edit"+(W?"-custom":""),children:[W?t(W,{value:Qe??"",onChange:te,onKeyDown:e=>X(e,{objectConfirm:vt,cancel:wt})}):t(M,{textAreaRef:Ue,className:"jer-collection-text-area",name:pe,value:Qe??"",setValue:Xe,onKeyDown:yt,styles:o("input",fe)}),t("div",{className:"jer-collection-input-button-row",children:t(Le,{onOk:vt,onCancel:wt,nodeData:fe,translate:_,showIconTooltips:R,editConfirmRef:Z})})]}),Tt=Ke.current?Ot?St.map(([e,n],a)=>{const i={key:e,value:n,path:[...ye,e],level:ye.length+1,index:a,size:g(n)?Object.keys(n).length:null,parentData:b,fullData:fe.fullData},l=ze(V,i);return t("div",{className:"jer-collection-element",style:o("collectionElement",i),children:g(n)&&!l?.renderCollectionAsValue?t(et,{...r,data:n,parentData:b,nodeData:i,canDragOnto:be,canAddHere:Ee,customNodeData:l},e):t($e,{...r,data:n,parentData:b,nodeData:i,canDragOnto:be,canAddHere:Ee,showLabel:"object"===mt||I,customNodeData:l},e)},e)}):t(n,{children:kt()}):null,Nt=!!st&&le&&!dt;Nt||(Ke.current=!0);const xt=_(le?"TOOLTIP_EXPAND":"TOOLTIP_COLLAPSE",fe),Rt=()=>({...r,data:b,value:b,parentData:D,nodeData:fe,setValue:e=>u({op:"edit",path:ye,value:e}),handleEdit:vt,handleCancel:wt,onKeyDown:yt,isEditing:_e,isPending:Me,setIsEditing:be?()=>l(ye,{cancelOp:Je,commitOp:e=>pt.current(e)}):f,getStyles:o,canDragOnto:be,canAddHere:Ee,canEdit:be,keyboardCommon:{}}),At=jt?t(qe,{componentProps:tt,...Rt(),originalNode:ct&&_e?kt():void 0,children:Tt}):Tt,Pt=Et&&t(Ie,{startEdit:be?()=>{Ke.current=!0,l(ye,{cancelOp:Je,commitOp:e=>pt.current(e)})}:void 0,handleAdd:Ee?e=>{y(null),se(!1);const t=Ze(fe,e);if("array"===mt){const e=J.array?0:b.length,n=J.array?{insert:!0}:{};return void u({op:"add",path:ye,key:e,value:t,options:n,instant:!0}).then(e=>{"error"===e?.status&&Oe(e.error,t)})}if(e in b)return Oe({code:"KEY_EXISTS",message:_("ERROR_KEY_EXISTS",fe)},e),void s();const n=J.object?{insertBefore:0}:{};u({op:"add",path:ye,key:e,value:t,options:n}).then(e=>{"error"===e?.status&&Oe(e.error,t)})}:void 0,handleDelete:we?bt:void 0,showClipboardButton:N,onCopy:x,type:mt,nodeData:fe,translate:_,customButtons:r.customButtons,keyboardControls:$,handleKeyboard:X,getNewKeyOptions:Ge,editConfirmRef:Z,jsonStringify:H,showIconTooltips:R,Select:U}),It=Te({handleCancel:wt,getStyles:o,keyValueArray:St,handleClick:G.includes("property")?gt:e=>e.stopPropagation()}),Lt=e("div",{className:"jer-component jer-collection-component",style:{marginLeft:(0===ye.length?0:A/2)+"em",...o("collection",fe),position:"relative"},draggable:Ce&&!_e&&!Ve&&!dt,...Ne,...xe("above"),children:[t("div",{className:"jer-clickzone",style:{width:A/2+1+"em",zIndex:10+2*fe.level},onClick:G.includes("left")?gt:void 0}),!_e&&Re,t(Ae,{position:"above",nodeData:fe}),st?e("div",{className:"jer-collection-header-row",style:{...o("headerRow",fe),position:"relative"},onClick:G.includes("header")?gt:void 0,children:[e("div",{className:"jer-collection-name",children:[t("button",{type:"button",className:"jer-collapse-icon jer-accordion-icon"+(le?" jer-rotate-90":""),style:{zIndex:11+2*fe.level,transition:ue},onClick:gt,tabIndex:-1,"aria-expanded":!le,"aria-label":xt,title:R?xt:"",children:t(Pe,{name:"collection",nodeData:fe})}),Ct&&t(He,{...It}),!_e&&t("span",{className:"jer-brackets jer-bracket-open",style:o("bracket",fe),children:ft.open})]}),!1!==E&&!_e&&t("div",{className:"jer-collection-item-count"+(Dt?" jer-visible":" jer-hidden"),style:{...o("itemCount",fe),transition:ue,transitionBehavior:"allow-discrete"},children:null!=ht&&ht!==ve?_("ITEMS_FILTERED",fe,{visible:ht,total:ve}):1===ve?_("ITEM_SINGLE",{...fe,size:1},1):_("ITEMS_MULTIPLE",fe,ve)}),t("div",{className:"jer-brackets"+(Nt?" jer-visible":" jer-hidden"),style:{...o("bracket",fe),transition:ue},children:ft.close}),Pt]}):ot?e("div",{className:"jer-collection-header-row",style:{...o("headerRow",fe),position:"relative"},children:[t(He,{...It}),Pt]}):t(n,{}),e("div",{className:"jer-collection-inner",style:{overflowY:Nt||ae?"clip":"visible",maxHeight:dt?void 0:ie,...o("collectionInner",fe),transition:ue},ref:oe,children:[At,t("div",{className:_e?"jer-collection-error-row-edit":"jer-collection-error-row",children:je&&t("span",{className:"jer-error-slug",style:o("error",fe),children:je})}),!_e&&st&&t("div",{className:"jer-brackets jer-bracket-outside",style:o("bracket",fe),children:ft.close})]}),t(Ae,{position:"below",nodeData:fe})]});return nt?t(nt,{wrapperProps:rt,...Rt(),children:Lt}):Lt},et=/*#__PURE__*/r.memo(qe,Ye),tt=({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"})]}),nt=(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}},rt=({key:e,path:t},n="")=>!!nt({value:e},n)||!!t.some(e=>nt({value:e},n)),ot={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)",SHOW_MORE:"Show more",EMPTY_STRING:"<empty string>",TOOLTIP_COPY:"Copy to clipboard",TOOLTIP_EDIT:"Edit",TOOLTIP_DELETE:"Delete",TOOLTIP_ADD:"Add",TOOLTIP_OK:"OK",TOOLTIP_CANCEL:"Cancel",TOOLTIP_COLLAPSE:"Collapse",TOOLTIP_EXPAND:"Expand"};var at=':root,:host{--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;padding:0 1em 0 0;margin:0;font-family:inherit;font-size:.8em;color:#000;cursor:inherit;line-height:inherit;z-index:1;outline:none}select::-ms-expand{display:none}.jer-select{display:grid;grid-template-areas:"select";align-items:center;position:relative;min-width:12ch;max-width:15ch;border:1px solid var(--jer-select-border);border-radius:.25em;padding:.25em .5em;cursor:pointer;line-height:1.1;background-color:#fff;background-image:linear-gradient(to top,#f9f9f9,#fff 33%)}.jer-select select,.jer-select:after{grid-area:select}.jer-select:not(.jer-select--multiple):after{content:"";justify-self:end;width:.8em;height:.5em;background-color:var(--jer-select-arrow);clip-path:polygon(100% 0%,0 0%,50% 100%)}select:focus+.focus{position:absolute;inset:-1px;border:1px solid var(--jer-select-focus);border-radius:inherit}.jer-select-inner{width:100%;text-overflow:ellipsis}.jer-editor-container{position:relative;font-size:16px;line-height:1;padding:1em 1em 1em 2em;border-radius:.5em;text-align:left}.jer-editor-container textarea{color:var(--jer-input-color);border:var(--jer-form-border);border-radius:.3em;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;outline:none;font-family:inherit}.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{display:flex;min-height:1.7em;gap:.3em;align-items:center}.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{position:absolute;left:-1.2em;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{display:flex;flex-direction:column;gap:.3em;align-items:flex-start;line-height:1.1em}.jer-collection-text-edit{width:fit-content}.jer-collection-text-area{box-sizing:content-box;resize:both;padding:.2em .5em 0;overflow:hidden;max-height:40em;line-height:1.25em;font-family:inherit;font-size:.85em}.jer-collection-input-button-row{display:flex;justify-content:flex-end;width:100%;font-size:150%;margin-top:.4em}.jer-collection-error-row-edit{position:absolute;bottom:.5em}.jer-error-slug{margin-left:1em}.jer-value-component{position:relative}.jer-value-and-buttons{display:flex;justify-content:flex-start;align-items:center;padding-left:.5em}.jer-value-error-row{position:absolute}.jer-value-string{line-height:1.3em;white-space:pre-wrap;overflow-wrap:anywhere;word-break:break-word}.jer-string-expansion{cursor:pointer;opacity:.6;filter:saturate(50%)}.jer-string-expansion.jer-show-less{font-size:80%}.jer-hyperlink{text-decoration:underline}.jer-input-text{box-sizing:content-box;resize:none;margin:0;height:1.4em;padding:.25em .5em .2em;min-width:6em;overflow:hidden;line-height:1.2em;font-family:inherit;font-size:.9em}.jer-input-boolean{transform:scale(1.5);margin-left:.3em;margin-right:.3em}.jer-key-text{word-break:break-word;line-height:1.1em;white-space:pre-wrap}.jer-key-edit{padding:0 .3em;font-size:inherit;font-size:.9em}.jer-value-invalid{opacity:.5;font-style:italic}.jer-input-number{min-width:3em;font-size:90%}.jer-edit-buttons,.jer-confirm-buttons{display:flex;align-items:center;cursor:pointer;height:1em;margin-right:.2em}.jer-edit-buttons>button,.jer-confirm-buttons>button,button.jer-collapse-icon,button.jer-string-expansion{appearance:none;background:none;border:none;margin:0;padding:0;font:inherit;color:inherit;vertical-align:baseline}.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{opacity:1}.jer-value-main-row:hover>.jer-edit-buttons{opacity:1}.jer-value-and-buttons:hover>.jer-edit-buttons{opacity:1}.jer-copy-pulse{position:relative;transition:.3s}.jer-copy-pulse:hover{opacity:.85;transition:.3s;transform:scale(1.2)}.jer-copy-pulse:after{content:"";display:block;position:absolute;border-radius:50%;left:0;top:0;width:100%;height:100%;opacity:0;transition:all .5s;box-shadow:0 0 15px 5px var(--jer-icon-copy-color)}.jer-copy-pulse:active:after{box-shadow:0 0 0 0 var(--jer-icon-copy-color);position:absolute;border-radius:4em;left:0;top:0;opacity:1;transition:0s}.jer-copy-pulse:active{top:.07em}.jer-icon:hover{opacity:.85;transition:.3s;transform:scale(1.2)}.jer-empty-string{font-style:italic;font-size:90%}.jer-drag-n-drop-padding{height:.5em;border:1px dashed #b4b4b4;border-radius:.3em}.jer-clickzone{position:absolute;left:-1em;top:1.2em;height:calc(100% - .8em)}';const it="data-jer-styles",lt=(e,t)=>JSON.stringify(e,t,2),st={edit:"ERROR_UPDATE",add:"ERROR_ADD",delete:"ERROR_DELETE",rename:"ERROR_RENAME",move:"ERROR_MOVE"},ct={edit:"UPDATE_ERROR",add:"ADD_ERROR",delete:"DELETE_ERROR",rename:"RENAME_ERROR",move:"MOVE_ERROR"},dt=e=>{const t=i(e);e&&(t.current=e);const n=i((...e)=>t.current(...e));return e?n.current:void 0},ut=[],pt=["header","left"],ht={},mt={},ft={},yt=[],gt=({data:e,setData:n,buildNodeDataFromPathRef:r,commitRef:o,rootName:l="root",onUpdate:s=f,onChange:u,onError:h,onEditEvent:w,showErrorMessages:E=!0,showClipboardButton:C=!0,onCopy:j,indent:O=2,collapse:k=3,collapseAnimationTime:T=300,showCollectionCount:N="when-collapsed-or-filtered",allowEdit:x=!0,allowDelete:R=!0,allowAdd:A=!0,allowTypeSelection:P=!0,allowDrag:I=!1,searchFilter:K,searchText:V,searchDebounceTime:M=350,sortKeys:z=!1,showArrayIndexes:B=!0,arrayIndexStart:Y=0,showStringQuotes:U=!0,showIconTooltips:$=!1,defaultValue:X=null,newKeyOptions:J,minWidth:Q=250,maxWidth:Z="min(600px, 90vw)",baseFontSize:G,stringTruncateLength:q=250,translations:ee=ht,className:te,id:re,customText:oe=mt,customNodeDefinitions:ae=ut,customButtons:ie=yt,jsonParse:le=JSON.parse,jsonStringify:se=lt,TextEditor:de,Select:ue=tt,errorDisplayTime:pe=2500,keyboardControls:me=ft,editorRef:fe,insertAtTop:ye=!1,onCollapse:ge,collapseClickZones:ve=pt})=>{const{getStyles:we,cssVars:De}=ne(),{open:Ee,cancel:Ce,getSnapshot:je}=ce(),Se=c(()=>wt(k),[k]),Oe=c(()=>((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]:ot[r];if(void 0!==o){const e=v(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))(ee,oe),[ee,oe]),[ke,Te]=p(V),Ne=i(null);a(()=>{Ce();const e=setTimeout(()=>Te(V),M);return()=>clearTimeout(e)},[V,M]);const xe=_(e,[],l),Re=i(e);Re.current=e;const Ae=i(n);Ae.current=n;const Pe=i(Oe);Pe.current=Oe;const Ie=i(xe);Ie.current=xe;const Le=i(s);Le.current=s;const Ke=i(l);Ke.current=l;const _e=i(void 0),Ve=d(()=>Re.current,[]),Me=dt(u),Fe=dt(h),Be=dt(ge),He=dt(w),We=dt(j),Ye=d(e=>{Re.current=e,Ae.current(e)},[]),Ue=d((e,t)=>{Ye(bt(Re.current,e,t,"update").newData)},[Ye]),Xe=d(e=>{const t=Re.current,n=Ke.current,r=_e.current,o=Ye,{op:a,path:i}=e;switch(a){case"edit":{const{newData:a,currentValue:l,newValue:s}=bt(t,i,e.value,"update"),c=_(t,i,n,r);return{input:{...c,newData:a,event:"edit",newValue:s},nodeData:c,isNoOp:l===s,apply:()=>o(a),revert:()=>o(bt(Re.current,i,l,"update").newData)}}case"delete":{const{newData:e,currentValue:a}=bt(t,i,"","delete"),l=_(t,i,n,r);return{input:{...l,newData:e,event:"delete"},nodeData:l,isNoOp:!1,apply:()=>o(e),revert:()=>o(bt(Re.current,i,a,"add",{insert:!0,insertBefore:l.index}).newData)}}case"add":{const a=[...i,e.key],{newData:l,newValue:s}=bt(t,a,e.value,"add",e.options),c=_(l,a,n,r);return{input:{...c,value:void 0,size:null,parentData:L(t,i)??null,fullData:t,newData:l,event:"add",newValue:s},nodeData:c,isNoOp:!1,apply:()=>o(l),revert:()=>o(bt(Re.current,a,"","delete").newData)}}case"rename":{const a=i.slice(0,-1),l=i[i.length-1],{newKey:s}=e,c=L(t,a),d=Object.fromEntries(Object.entries(c).map(([e,t])=>e===l?[s,t]:[e,t])),{newData:u}=bt(t,a,d,"update"),p=_(t,i,n,r);return{input:{...p,newData:u,event:"rename",newKey:s},nodeData:p,isNoOp:l===s,apply:()=>o(u),revert:()=>o(bt(Re.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}=bt(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}=bt(d,g,u,"add",y),b=_(t,a,n,r);return{input:{...b,newData:v,event:"move",newPath:g},nodeData:b,isNoOp:!1,apply:()=>o(v),revert:()=>o(c)}}}},[Ye]),Je=d((e,t)=>{const n=ct[e.event],r=()=>Pe.current(st[e.event],Ie.current),o=e=>{const t=e instanceof Error&&e.message?e.message:"string"==typeof e&&e?e:r();return{status:"error",error:{code:n,message:t}}},a=t=>{if(!1===t)return{status:"error",error:{code:n,message:r()}};if(null===t)return{status:"cancel"};if(t&&"object"==typeof t){if(void 0!==t.error)return"string"==typeof t.error?{status:"error",error:{code:n,message:t.error}}:{status:"error",error:t.error};const r=void 0!==t.data,o=void 0!==t.value;if(r&&o&&console.warn("json-edit-react: onUpdate returned both { value } and { data }; { data } (whole-document) takes precedence and { value } is ignored."),r)return{status:"override",value:t.data,path:[]};if(o&&("edit"===e.event||"add"===e.event))return{status:"override",value:t.value,path:e.path}}return{status:"commit"}};let i;try{i=Le.current(e,t)}catch(e){return o(e)}return b(i)?i.then(a,o):a(i)},[]),Qe=c(()=>({runUpdate:s===f?void 0:Je,buildCommit:Xe,applyValue:Ue}),[Je,Xe,Ue,s]);o.current=Qe;const Ze=c(()=>wt(x),[x]),Ge=c(()=>wt(R),[R]),qe=c(()=>wt(A),[A]),rt=c(()=>wt(I),[I]),at=c(()=>Dt(K),[K]),it=c(()=>((e,t,n)=>{if(!t&&!n)return null;const r=new Set,o=new Map,a=t??nt,i=n??"",l=e=>{let t=a(e,i);if(g(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:g(i)?Object.keys(i).length:null,parentData:e.value,fullData:e.fullData};l(s)&&(t=!0,n++)}o.set(S(e.path),n)}return t&&r.add(S(e.path)),t};return l(e),{visiblePaths:r,visibleChildCounts:o}})(xe,at,ke),[e,ke,at,l]),gt=c(()=>(e=>{const t={...H};for(const n of Object.keys(H)){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?y(o):"string"==typeof o?{key:o}:o)();t[r]=i}return W.forEach(n=>{void 0===e[n]&&void 0!==e.confirm&&(t[n]=t.confirm)}),t})(me),[me]),vt=d((e,t)=>((e,t,n)=>{for(const[r,o]of Object.entries(t))if(F(n,e[r],r)){n.preventDefault(),o();break}})(gt,t,e),[gt]),Ct=c(()=>{const e=Et(ae,"stringifyReplacer");return t=>se(t,e)},[ae,se]),jt=c(()=>{const e=Et(ae,"parseReviver");return t=>{const n=le(t,e);return D(n)}},[ae,le]),St=i(null),{setCollapseState:Ot}=he(),kt=d((e,t)=>{!1!==z&&("function"!=typeof z?e.sort((e,n)=>{const r=t(e)[0],o=t(n)[0];return r<o?-1:r>o?1:0}):e.sort((e,n)=>z(t(e),t(n))))},[z]);_e.current=kt;const Tt=d(e=>_(Ve(),e,Ke.current,_e.current),[Ve]);r.current=Tt,m(fe,()=>{const e=Symbol("path-missing");return{collapse:e=>Ot(e),startEdit:({path:t,overrideRestrictions:n=!1})=>L(Ve(),t,e)===e?"PATH_NOT_FOUND":n||Ze(_(Ve(),t,l,kt))?(Ee(t,{force:!0}),!0):"RESTRICTED",confirm:()=>{St.current&&(St.current.click(),"editing"!==je().active?.phase&&Ce())},cancel:()=>Ce()}},[Ot,Ee,Ce,je,Ze,Ve,l,kt]);const Nt=ze(ae,xe),xt=c(()=>({object:!0===ye||"object"===ye,array:!0===ye||"array"===ye}),[ye]),Rt={mainContainerRef:Ne,name:l,nodeData:xe,getLatestData:Ve,onChange:Me,onError:Fe,onEditEvent:He,showErrorMessages:E,showCollectionCount:N,collapseFilter:Se,collapseAnimationTime:T,allowEditFilter:Ze,allowDeleteFilter:Ge,allowAddFilter:qe,allowTypeSelection:P,allowDragFilter:rt,canDragOnto:!1,canAddHere:!1,showClipboardButton:C,onCopy:We,sortKeys:z,sort:kt,showArrayIndexes:B,arrayIndexStart:Y,showStringQuotes:U,showIconTooltips:$,indent:O,defaultValue:X,newKeyOptions:J,stringTruncateLength:q,translate:Oe,customNodeDefinitions:ae,customNodeData:Nt,customButtons:ie,parentData:null,jsonParse:jt,jsonStringify:Ct,TextEditor:de,Select:ue,errorDisplayTime:pe,handleKeyboard:vt,keyboardControls:gt,insertAtTop:xt,onCollapse:Be,editConfirmRef:St,collapseClickZones:ve},At={...we("container",xe),...De,minWidth:Q,maxWidth:Z};return At.fontSize=G??At.fontSize,t("div",{id:re,ref:Ne,className:`jer-editor-container ${te??""}`,style:At,children:t(be,{value:it,children:g(e)&&!Nt.renderCollectionAsValue?t(et,{data:e,...Rt}):t($e,{data:e,showLabel:!0,...Rt})})})};function vt(e){h(()=>{(()=>{if("undefined"==typeof document)return;const e=document.head.querySelector(`style[${it}]`);if(e)return void(e.textContent!==at&&(e.textContent=at));const t=document.createElement("style");t.setAttribute(it,""),t.textContent=at,document.head.appendChild(t)})()},[]);const n=i(void 0),r=i(void 0),o=e;return t(te,{theme:o.theme??Q,children:t(ge,{onEditEvent:o.onEditEvent,onCollapse:o.onCollapse,buildNodeDataFromPathRef:n,commitRef:r,children:t(gt,{...o,buildNodeDataFromPathRef:n,commitRef:r})})})}const bt=(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?L(e,t):void 0;return{currentData:e,newData:R(e,t,n,a),currentValue:i,newValue:"delete"!==r?n:void 0}},wt=e=>"boolean"==typeof e?()=>e:"number"==typeof e?({level:t})=>t>=e:e,Dt=e=>{if(void 0!==e)return"value"===e?nt:"key"===e?rt:"all"===e?(e,t)=>nt(e,t)||rt(e,t):e},Et=(e,t)=>{const n="stringifyReplacer"===t?[e=>void 0===e?E: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 Ct(e){const{editorRef:n,...r}=e,o=i(null);return m(n,()=>({collapse:e=>o.current?.collapse(e)}),[]),t(vt,{...r,editorRef:o,setData:f,allowEdit:!1,allowAdd:!1,allowDelete:!1,allowDrag:!1})}export{M as AutogrowTextArea,Ae as IconSvg,vt as JsonEditor,Ct as JsonViewer,je as StringDisplay,Se as StringEdit,R as assign,_e as collectionDataTypes,Q as defaultTheme,L as extract,g as isCollection,nt as matchNode,rt as matchNodeKey,C as splitPropertyString,Ve as standardDataTypes,S as toPathString,Ne as useKeyboardListener,Ke as valueDataTypes};
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,useInsertionEffect as h,useImperativeHandle as m}from"react";const f=()=>{},y=e=>Array.isArray(e)?e:[e],g=e=>null!==e&&"object"==typeof e,v=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),b=e=>null!=e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof e.then,w=(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},D=e=>{if(e!==E){if(e&&"object"==typeof e)for(const t in e){const n=e[t],r=D(n);r!==n&&(e[t]=r)}return e}},E="__​undefined__",C=e=>e.split(/(\.|\[\d+\])/).filter(e=>"."!==e&&""!==e).map(e=>{const t=/\[(\d+)\]/.exec(e);return t?Number(t[1]):e}),j=e=>"string"==typeof e?e:"number"==typeof e?String(e):e.reduce((e,t)=>"number"==typeof t?`${e}[${t}]`:""===e?t:`${e}.${t}`,""),S=e=>1===e.length&&""===e[0]?"\0":e.map(e=>encodeURIComponent(String(e))).join("/"),O=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),k=(e,t)=>e.length>=t.length&&t.every((t,n)=>t===e[n]),T=(e,t,n,r,o)=>{if(!r)throw new Error(o??`Invalid property path: ${t}\nCouldn't access "${n}" in ${JSON.stringify(e)}`)},N=e=>Array.isArray(e),x=(e,t)=>e.filter((e,n)=>n!==t),R=(e,t,n,r={})=>{const{remove:o=!1,createNew:a=!0,noError:i=!1}=r,l=e,s=j(t),c={...r,remove:o,createNew:a,noError:i,fullData:l,fullPath:s},d=Array.isArray(t)?t:C(t);return N(e)&&o&&1===d.length?x(e,d[0]):A(e,d,n,c)},A=(e,t,n,r)=>{const o=v(e)?{...e}:null,a=N(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=>A(e,t,n,r));if(1===t.length)return o&&"string"==typeof u?P(o,u,n,r)??o:a&&"number"==typeof u?(I(a,u,n,r),a):(T(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 N(e)?p[u]=x(e,n):T(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],!N(m)&&!v(m)){if(!i)return T(c,d,u,s),p;p[u]={}}return p[u]=A(p[u],h,n,r),p}var m;if(i){const e="number"==typeof h[0]?[]:{};if(o)return p[u]=e,p[u]=A(p[u],h,n,r),p;if(a&&Array.isArray(p)){p.push(e);const t=p.length-1;return p[t]=A(p[t],h,n,r),p}}return T(c,d,u,s),p},P=(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;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]:T(c,d,t,i):a||u?e[t]=n:T(c,d,t,i)},I=(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):T(a,i,t,o)},L=(e,t,n)=>{const r=Array.isArray(t)?t:C(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=>L(e,r,n));if("object"!=typeof e||null===e||!(o in e))return K(e,o,n);const a=e[o];return 1===r.length?a:L(a,r.slice(1),n)},K=(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},_=(e,t,n="",r)=>{if(0===t.length)return{key:n,path:[],level:0,index:0,value:e,size:g(e)?Object.keys(e).length:1,parentData:null,fullData:e};const o=t[t.length-1],a=L(e,t),i=L(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:g(a)?Object.keys(a).length:null,parentData:i,fullData:e}},V="undefined"!=typeof window?o:a,M=({className:n,name:r,value:o,setValue:a,onKeyDown:l,styles:s,textAreaRef:c})=>{const d=i(null);if(V(()=>{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})]})},z=e=>e.shiftKey?"Shift":e.metaKey?"Meta":e.ctrlKey?"Control":e.altKey?"Alt":void 0,F=(e,t,n)=>{if(!t)return!1;const r=e.key,o=z(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))},B={key:"Enter"},H={confirm:B,cancel:{key:"Escape"},objectConfirm:{...B,modifier:["Meta","Shift","Control"]},objectLineBreak:B,stringConfirm:B,stringLineBreak:{...B,modifier:["Shift"]},numberConfirm:B,numberUp:{key:"ArrowUp"},numberDown:{key:"ArrowDown"},tabForward:{key:"Tab"},tabBack:{key:"Tab",modifier:"Shift"},booleanConfirm:B,booleanToggle:{key:" "},clipboardModifier:["Meta","Control"],collapseModifier:["Alt"]},W=["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=L(e,a),s=X(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(g(d.value)){if(0===Object.keys(d.value).length)return U(e,[...a,d.key],n,r,o);u=$(e,[...a,d.key],n,r)}else u=[...a,d.key];return u?o(_(e,u,"",r))?u:U(e,u,n,r,o):null},$=(e,t,n="next",r)=>{const o=L(e,t);if(!g(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 $(e,[...t,i],n,r)},X=e=>Array.isArray(e)?e.map((e,t)=>({value:e,key:t})):Object.entries(e).map(([e,t])=>({key:e,value:t})),J={fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2},Q={displayName:"Default",icons:{add:{content:/*#__PURE__*/e(n,{children:[/*#__PURE__*/t("path",{d:"M13 7h-2v4H7v2h4v4h2v-4h4v-2h-4z"}),/*#__PURE__*/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:/*#__PURE__*/e(n,{children:[/*#__PURE__*/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"}),/*#__PURE__*/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:/*#__PURE__*/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:/*#__PURE__*/e(n,{children:[/*#__PURE__*/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"}),/*#__PURE__*/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"}),/*#__PURE__*/t("path",{d:"M15 10l-4 4 4 4"})]}),svgProps:J,scale:.86},ok:{content:/*#__PURE__*/e(n,{children:[/*#__PURE__*/t("path",{d:"M22 11.08V12a10 10 0 11-5.93-9.14"}),/*#__PURE__*/t("path",{d:"M22 4L12 14.01l-3-3"})]}),svgProps:J,scale:.9},cancel:{content:/*#__PURE__*/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:/*#__PURE__*/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"}},Z={container:"backgroundColor",collection:"backgroundColor",collectionInner:"backgroundColor",collectionElement:"backgroundColor",headerRow:"backgroundColor",valueRow:"backgroundColor",dropZone:"borderColor",inputHighlight:"backgroundColor"},G=e=>[Q,...y(e)].map(e=>"styles"in e?e:{styles:e}),q=e=>{const t={};for(const{icons:n}of G(e))n&&Object.assign(t,n);return t},ee=/*#__PURE__*/l({getStyles:()=>({}),icons:/*#__PURE__*/q(Q),cssVars:{}}),te=({theme:e=Q,children:n})=>{const r=c(()=>(e=>{var t;const n=G(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?{[Z[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(()=>/*#__PURE__*/q(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(ee.Provider,{value:l,children:n})},ne=()=>s(ee),re={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"}},oe=(e,t)=>re[e][t]??null,ae=(e,t)=>null!==e&&null!==t&&e.op===t.op&&O(e.path,t.path),ie={active:null,settling:{}},le=/*#__PURE__*/l(null),se=({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=((e,t,n)=>{let r=ie;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,ae(r.active,n)&&r.active?.phase===n?.phase||c({...r,active:n});const o=oe(e.op,"start");o&&u(e.path,o)},h=(e,t,o,l,s,u,p,h,m)=>{const f=S(e);if(!p()){if("cancel"===l.status||"error"===l.status){r.active&&O(r.active.path,e)&&("held"===r.active.phase||"editing"===r.active.phase)&&(c({...r,active:null}),a=null,i=null);const n=oe(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&&!ae(o,n);if(l&&i)return void i(()=>p(n,t));const s=a;if(a=null,i=null,s&&s(),l&&ae(r.active,o)){const e=oe(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=oe(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 ae(r.active,{path:o,op:t})&&c({...r,active:null}),a=null,i=null,p?.(),Promise.resolve(void 0)}const y=f?.extra,g=S(o),v=++s;if(!l){const e=oe(t,"submit");e&&u(o,e)}if(!f||f.isNoOp){ae(r.active,{path:o,op:t})&&c({...r,active:null}),a=null,i=null;const e=oe(t,"commit");return e&&(f?d(f.nodeData,e,y):u(o,e,y)),p?.(),Promise.resolve(void 0)}const{input:w,nodeData:D,apply:E,revert:C}=f,j=!!m?.runUpdate;let O=!1,k=!1;const T=()=>{if(O)return;O=!0,E(),a=null,i=null,ae(r.active,{path:o,op:t})&&c({...r,active:null}),j&&((e,t)=>{c({...r,settling:{...r.settling,[e]:t}})})(g,v);const e=oe(t,"commit");e&&d(D,e,y),p?.()},N={hold:()=>(k=!0,c({...r,active:{path:o,op:t,phase:"held",force:r.active?.force}}),()=>T())};if(!j)return T(),Promise.resolve(void 0);const x=m.runUpdate(w,N),R=b(x);if(!k&&!l&&!R)return Promise.resolve(h(o,t,v,x,T,C,()=>O,D,y));const A=R?x:Promise.resolve(x);let P;return k||(l?P=setTimeout(T,100):T()),A.then(e=>(clearTimeout(P),h(o,t,v,e,T,C,()=>O,D,y)))},areChildrenBeingEdited:e=>null!==r.active&&k(r.active.path,e)}})(a,r,o)),t(le.Provider,{value:l.current,children:e})},ce=()=>{const e=s(le);if(!e)throw new Error("Missing Editing Context Provider");return e},de=e=>{const t=ce();return u(t.subscribe,()=>e(t.getSnapshot()),()=>e(t.getServerSnapshot()))},ue=/*#__PURE__*/l(null),pe=({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=y(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(ue.Provider,{value:u,children:e})},he=()=>{const e=s(ue);if(!e)throw new Error("Missing Collapse Context Provider");return e},me=(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},fe=/*#__PURE__*/l(null),ye=({children:e})=>{const[n,r]=p({path:null,canDelete:!1}),o=i(!1),a=c(()=>({dragSource:n,setDragSource:r,armed:o}),[n]);return t(fe.Provider,{value:a,children:e})},ge=({children:e,onEditEvent:n,onCollapse:r,buildNodeDataFromPathRef:o,commitRef:a})=>t(se,{onEditEvent:n,buildNodeDataFromPathRef:o,commitRef:a,children:t(pe,{onCollapse:r,buildNodeDataFromPathRef:o,children:t(ye,{children:e})})}),ve=/*#__PURE__*/l(void 0),be=({value:e,children:n})=>t(ve.Provider,{value:e,children:n}),we=()=>{const e=s(ve);if(void 0===e)throw new Error("Missing FilterStateProvider");return e},De=e=>{const t=we();return null===t||t.visiblePaths.has(S(e))},Ee=e=>{const t=we();return null===t?null:t.visibleChildCounts.get(S(e))??null},Ce="**INVALID_FUNCTION**",je=({nodeData:r,showStringQuotes:o=!0,stringTruncateLength:a=200,pathString:i,canEdit:l,setIsEditing:s,styles:c,translate:d,showIconTooltips:u=!1,value:h,TextWrapper:m=({children:e})=>e})=>{const f=h??r.value,[y,g]=p(!1),v=o?'"':"",b=f.length>a,w=()=>{l?s(!0):g(!y)},D=d("SHOW_MORE",r);return e("div",{id:`${i}_display`,onDoubleClick:w,onClick:e=>{(e.getModifierState("Control")||e.getModifierState("Meta"))&&w()},className:"jer-value-string",style:c,children:[v,b?e(n,y?{children:[t(m,{children:e("span",{children:[f,v]})})," ",t("button",{type:"button",tabIndex:-1,className:"jer-string-expansion jer-show-less",onClick:()=>g(!1),children:d("SHOW_LESS",r)})]}:{children:[e(m,{children:[t("span",{children:f.slice(0,a-2).trimEnd()})," "]}),t("button",{type:"button",tabIndex:-1,className:"jer-string-expansion jer-ellipsis",onClick:()=>g(!0),"aria-label":D,title:u?D:"",children:"..."}),v]}):t(m,{children:`${f}${v}`})]})},Se=({styles:e,pathString:n,value:r,setValue:o,handleEdit:a,handleKeyboard:l,keyboardCommon:s})=>{const c=i(null);return t(M,{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})},Oe=({isEditing:e,path:n,enumType:r,...o})=>{const{getStyles:a}=ne(),i=S(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(Se,{styles:a("input",c),pathString:i,...o,setValue:o.setValue}):t(je,{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}=ne();return r?t("input",{className:"jer-input-number",type:"text",name:S(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})},Te=({value:e,setValue:n,isEditing:r,path:o,setIsEditing:a,handleEdit:i,nodeData:l,handleKeyboard:s,keyboardCommon:c})=>{const{getStyles:d}=ne();return"boolean"!=typeof e?null:r?t("input",{className:"jer-input-boolean",type:"checkbox",name:S(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)})},Ne=(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])},xe=({value:e,isEditing:n,setIsEditing:r,handleEdit:o,nodeData:a,handleKeyboard:i,keyboardCommon:l})=>{const{getStyles:s}=ne();return Ne(n,e=>i(e,{confirm:o,...l})),t("div",{onDoubleClick:()=>r(!0),className:"jer-value-null",style:s("null",a),children:String(e)})},Re=({value:e})=>{let n="Error!";switch(typeof e){case"string":e===Ce&&(n="Function");break;case"undefined":n="Undefined";break;case"symbol":n="Symbol"}return t("span",{className:"jer-value-invalid",children:n})},Ae=({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}=ne(),a=o[e],i=`icon${e[0].toUpperCase()}${e.slice(1)}`;return t(Ae,{viewBox:a.viewBox,...a.svgProps,scale:a.scale,className:"collection"===e?void 0:"jer-icon",style:r(i,n),children:a.content})},Ie=({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}=ne(),{open:D,cancel:E}=ce(),C=u("KEY_NEW",d),[S,k]=p(C),[T,N]=p(!1),{path:x,value:R}=d,A=de(e=>{const t=e.active;return null!==t&&"add"===t.op&&O(t.path,x)}),P=Array.isArray(T);V(()=>{if(!A)return N(!1),void k(C);const e=Object.keys(L(d.fullData,x)),t=y?y(d)?.filter(t=>!e.includes(t)):null;t&&k(""),N(t??!0)},[A]);const I=()=>{a&&(P&&!S||a("array"===s?"":S))};return e("div",{className:"jer-edit-buttons",style:{opacity:A?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=z(e);if(i&&h.clipboardModifier.includes(i)?(t=j(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?D(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,label:r},o)=>{const a=e=>n&&n(d,e);return r?t("button",{type:"button",tabIndex:-1,onClick:a,"aria-label":r,title:v?r:"",children:t(e,{nodeData:d})},o):t("div",{onClick:a,children:t(e,{nodeData:d})},o)}),A&&a&&"object"===s&&e(n,{children:[P?t(b,{name:"new-key-select",onChange:a,defaultValue:"",autoFocus:!0,onKeyDown:e=>m(e,{cancel:()=>E()}),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:S,onChange:e=>k(e.target.value),autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>{m(e,{stringConfirm:()=>I(),cancel:()=>E()})},style:w("input",d)}),t(Le,{onOk:()=>I(),onCancel:()=>E(),nodeData:d,translate:u,showIconTooltips:v,editConfirmRef:f,hideOk:P})]})]})},Le=({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"],_e=["object","array"],Ve=[...Ke,..._e],Me=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}},ze=(e=[],t)=>{const n=e.find(({condition:e})=>e(t));return n?Me(n):{}},Fe=({props:e,collapsed:t})=>{const{nodeData:n,parentData:r,onError:o,getLatestData:a,showErrorMessages:l,allowEditFilter:s,allowDeleteFilter:c,allowAddFilter:u,allowDragFilter:h,canAddHere:m,translate:f,errorDisplayTime:y,sort:g,arrayIndexStart:v,handleKeyboard:b,customNodeData:w}=e,{submit:D}=ce(),[E,C]=p(null),j={...n,collapsed:t,visibleSize:Ee(n.path)},{path:k,key:T,size:N}=j,x=S(k),R=de(e=>{const t=e.active;return null!==t&&"edit"===t.op&&O(t.path,k)}),A=de(e=>{const t=e.active;return null!==t&&"rename"===t.op&&O(t.path,k)}),P=de(e=>x in e.settling),I=s(j),L=c(j),K=u(j),_=h(j),V=e=>{l&&(C(e),setTimeout(()=>C(null),y)),console.warn("Error",e)},M=i(j);M.current=j;const z=d((e,t)=>{V(e.message),o&&o({...M.current,fullData:a(),error:e,errorValue:t})},[o,l,a,y]),F=we(),B=d(e=>(null===F||F.visiblePaths.has(S(e.path)))&&s(e),[F,s]),H=e=>U(a(),k,e,g,B),W=(e,t)=>{r&&(T!==e&&Object.keys(r).includes(e)?z({code:"KEY_EXISTS",message:f("ERROR_KEY_EXISTS",j)},e):D({op:"rename",path:k,newKey:e,onCommit:t}).then(t=>{"error"===t?.status&&z(t.error,e)}))},Y="number"==typeof k.slice(-1)[0],$=null!==r&&!Y&&L&&m,X={isEditing:R,isEditingKey:A,isPending:P,isArray:Y,canEditKey:$},J=""===T&&k.length>0?f("EMPTY_STRING",j):null;return{pathString:x,nodeData:j,path:k,name:T,size:N,canEdit:I,canDelete:L,canAdd:K,canDrag:_,error:E,showError:V,onError:z,setError:C,handleEditKey:W,derivedValues:X,emptyStringKey:J,getNextOrPreviousAtPath:H,buildKeyDisplayProps:({handleCancel:e,getStyles:t,keyValueArray:n,handleClick:r})=>({canEditKey:$,isEditingKey:A,pathString:x,path:k,name:T,arrayIndexStart:v,handleKeyboard:b,handleEditKey:W,handleCancel:e,styles:t("property",j),getNextOrPrevious:H,emptyStringKey:J,nodeData:j,customNodeData:w,getStyles:t,...void 0!==n?{keyValueArray:n}:{},...void 0!==r?{handleClick:r}:{}})}},Be=({canDrag:e,canDelete:n,canDragOnto:r,canAddHere:o,path:a,nodeData:i,onError:l,translate:d})=>{const{getStyles:u}=ne(),{dragSource:h,setDragSource:m,armed:f}=(()=>{const e=s(fe);if(!e)throw new Error("Missing DragSource Context Provider");return e})(),y=ce(),[g,v]=p(!1),b=()=>null!==h.path&&!k(a,h.path)&&(O(h.path.slice(0,-1),a.slice(0,-1))?r:h.canDelete&&o),w=c(()=>e?{onMouseDown:e=>{0===e.button&&null===y.getSnapshot().active&&(f.current=!0)},onMouseUp:()=>{f.current=!1},onDragStart:e=>{if(!f.current||null!==y.getSnapshot().active)return e.preventDefault(),void e.stopPropagation();f.current=!1,e.stopPropagation(),m({path:a,canDelete:n})},onDragEnd:e=>{f.current=!1,e.stopPropagation(),m({path:null,canDelete:!1})}}:{},[e,n,a]),D=c(()=>e=>r||o?{onDragOver:e=>{e.stopPropagation(),b()&&e.preventDefault()},onDrop:t=>{t.stopPropagation(),C(e),m({path:null,canDelete:!1}),v(!1)},onDragEnter:t=>{t.stopPropagation(),b()&&v(e)},onDragExit:e=>{e.stopPropagation(),v(!1)}}:{},[h,r,o,a]),E=c(()=>null!==h.path&&b()?t("div",{className:"jer-drop-target-bottom",style:{height:"50%",position:"absolute",width:"100%",top:"50%",zIndex:a.length},...D("below")}):null,[h,r,o,a.length]),C=e=>{if(null===h.path)return;if(!b())return;const t=h.path.slice(-1)[0],n=h.path.slice(0,-1),r=a.slice(0,-1),{parentData:o}=i;"string"==typeof t&&o&&!Array.isArray(o)&&Object.keys(o).includes(t)&&t in o&&!O(n,r)?l({code:"KEY_EXISTS",message:d("ERROR_KEY_EXISTS",i)},t):y.submit({op:"move",path:h.path,to:{path:a,position:e},instant:!0})};return{dragSourceProps:w,getDropTargetProps:D,BottomDropTarget:E,DropTargetPadding:({position:e,nodeData:n})=>g===e?t("div",{className:"jer-drag-n-drop-padding",style:u("dropZone",n)}):null,handleDrop:C}},He=({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:D}=ce(),E=r.useRef(null),C=e=>d(E.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:E,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):D()}else w(i)})},tabBack:()=>{const t=e.target.value;d(t,()=>{const e=f("prev");e?w(e):D()})}}),style:{width:j.length/1.5+.5+"em"}})},We=new Set(["nodeData","customNodeData"]),Ye=(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||!O(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(!We.has(n)&&!Object.is(e[n],t[n]))return!1;return!0},Ue=n=>{const{data:r,parentData:o,onChange:l,showClipboardButton:s,onCopy:u,canDragOnto:h,canAddHere:m,allowTypeSelection:y,showLabel:g,stringTruncateLength:v,showStringQuotes:b,indent:D,translate:E,customNodeDefinitions:C,customNodeData:j,Select:S,handleKeyboard:k,keyboardControls:T,editConfirmRef:N,jsonStringify:x,showIconTooltips:R,getLatestData:A}=n,{getStyles:P}=ne(),{open:I,cancel:L,submit:K,getSnapshot:_}=ce(),{setCollapseState:V}=he(),[M,z]=p("function"==typeof r?Ce:r),{nodeData:F,path:B,name:H,canEdit:W,canDelete:Y,canDrag:U,error:$,onError:X,setError:J,derivedValues:Q,getNextOrPreviousAtPath:Z,buildKeyDisplayProps:G}=Fe({props:n}),{dragSourceProps:q,getDropTargetProps:ee,BottomDropTarget:te,DropTargetPadding:re}=Be({canDrag:U,canDelete:Y,canDragOnto:h,canAddHere:m,path:B,nodeData:F,onError:X,translate:E}),[oe,ae]=p(Je(r,j)),ie=i(M);ie.current=M;const le=i(F);le.current=F;const se=d(e=>{if(!l)return void z(e);const t=l({...le.current,value:ie.current,fullData:A(),newValue:e});z(t)},[l,A]),de=()=>{z("function"==typeof r?Ce:r),ae(Je(r,j)),me(w(r,ue))};a(()=>{Q.isEditing||de()},[r]);const ue=c(()=>{const e=[...Ve,...C.filter(({showInTypeSelector:e=!1,name:t})=>e&&!!t).map(({name:e})=>e)];if("boolean"==typeof y)return y?e:[];if(Array.isArray(y))return y;const t=y(F);return"boolean"==typeof t?t?e:[]:t},[F,y,C]),[pe,me]=p(w(M,ue)),{isEditing:fe,isPending:ye}=Q,ge=De(B),ve=i(f);if(!ge)return null;const be=fe&&oe!==Je(r,j),we=be?C.find(e=>e.name===oe&&Xe(e)):void 0,Ee=we?Me(we):j,{CustomComponent:je,componentProps:Se,showKey:Oe=!0,showEditTools:ke=!0,showOnEdit:Te,showOnView:Ne,passOriginalNode:xe}=Ee,Re=je&&(void 0!==we||!be&&(fe&&Te||!fe&&Ne)),Ae=e=>{V(null);const t=be&&!we?void 0:Ee,n=t?.toStandardType?t.toStandardType(M):M,r=C.find(t=>t.name===e);if(r){const t="function"==typeof r.defaultValue?r.defaultValue(F):r.defaultValue;if(Xe(r)){let o=t;if(r.fromStandardType)try{o=r.fromStandardType(n,F,r.componentProps)}catch{}return z(o),ae(e),void me(null)}return K({op:"edit",path:B,value:t}).then(Pe(t)),void V({path:B,collapsed:!1,includeChildren:!1})}const o=ue.find(t=>t instanceof Object&&t.enum===e);if(o)return"string"==typeof M&&o.values.includes(M)||z(o.values[0]),me(o),void ae(e);const a=Ge(n,e,E("DEFAULT_NEW_KEY",F));if("object"===e||"array"===e||"null"===e)return K({op:"edit",path:B,value:a}).then(Pe(a)),void("null"!==e&&V({path:B,collapsed:!1,includeChildren:!1}));z(a),ae(e),me(null)},Pe=e=>t=>{if("error"===t?.status&&X(t.error,e),"error"===t?.status||"cancel"===t?.status){const e=_().active;"editing"===e?.phase&&O(e.path,B)||de()}},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(Re&&Ee.fromStandardType)try{r=Ee.fromStandardType(M,F,Ee.componentProps)}catch(e){return void X({code:"UPDATE_ERROR",message:e instanceof Error?e.message:String(e)},M)}else r="number"===oe?Ze(M):M;J(null),we&&V({path:B,collapsed:!1,includeChildren:!1}),K({op:"edit",path:B,value:r,onCommit:t}).then(Pe(r))};ve.current=Ke;const _e=()=>{J(null),de(),L()},{isEditingKey:ze}=Q,We=!!$,Ye=fe&&ue.length>1,Ue=("invalid"!==oe||je)&&!$&&ke,$e=g&&Oe,qe=()=>I(B,{cancelOp:de,commitOp:e=>ve.current(void 0,e)}),et=W?qe:f,tt=e=>()=>{const t=Z(e);t&&Ke(void 0,()=>I(t))},nt={value:M,parentData:o,setValue:se,isEditing:fe,canEdit:W,setIsEditing:et,handleEdit:Ke,handleCancel:_e,path:B,stringTruncateLength:v,showStringQuotes:b,showIconTooltips:R,nodeData:F,enumType:pe,translate:E,handleKeyboard:k,keyboardCommon:{cancel:_e,tabForward:tt("next"),tabBack:tt("prev")},Select:S},rt={...G({handleCancel:_e,getStyles:P}),customNodeData:Ee},ot=Re?t(je,{...n,value:M,componentProps:Se,setValue:se,handleEdit:Ke,handleCancel:_e,onKeyDown:e=>k(e,{stringConfirm:Ke,cancel:_e}),isEditing:fe,isPending:ye,setIsEditing:et,getStyles:P,originalNode:xe?Qe(r,oe,nt):void 0,originalNodeKey:xe?t(He,{...rt,customNodeData:void 0}):void 0,canEdit:W,keyboardCommon:nt.keyboardCommon}):Qe(r,oe,nt);return e("div",{className:"jer-component jer-value-component",style:{marginLeft:null!==o?D/2+"em":0,position:"relative"},draggable:U&&!fe&&!ze,...q,...ee("above"),children:[te,t(re,{position:"above",nodeData:F}),e("div",{className:"jer-value-main-row",style:{...P("valueRow",F),flexWrap:H.length>10?"wrap":"nowrap"},children:[$e&&t(He,{...rt}),e("div",{className:"jer-value-and-buttons",children:[t("div",{className:"jer-input-component",children:ot}),fe?t(Le,{onOk:Ke,onCancel:_e,nodeData:F,translate:E,showIconTooltips:R,editConfirmRef:N}):Ue&&t(Ie,{startEdit:W?qe:void 0,handleDelete:Y?()=>{K({op:"delete",path:B,instant:!0}).then(e=>{"error"===e?.status&&X(e.error,M)})}:void 0,showClipboardButton:s,onCopy:u,translate:E,customButtons:n.customButtons,nodeData:F,handleKeyboard:k,keyboardControls:T,editConfirmRef:N,jsonStringify:x,showIconTooltips:R,Select:S}),Ye&&t(S,{name:`${H}-type-select`,value:pe?pe.enum:oe,onChange:e=>Ae(e),options:ue.map(e=>e instanceof Object&&"enum"in e?e.enum:e)}),We&&t("span",{className:"jer-error-slug",style:P("error",F),children:$})]})]}),t(re,{position:"below",nodeData:F})]})},$e=/*#__PURE__*/r.memo(Ue,Ye),Xe=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",Qe=(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(Oe,{...r,value:a});case"number":return t(ke,{...r,value:a});case"boolean":return t(Te,{...r,value:a});case"null":return t(xe,{...r});default:return t(Re,{...r})}},Ze=e=>{if("symbol"==typeof e)return 0;const t=Number(e);return isNaN(t)?0:t},Ge=(e,t,n)=>{switch(t){case"string":return null==e?"":String(e);case"number":return Ze(e);case"boolean":return!!e;case"null":return null;case"object":return{[n]:e};case"array":return[e];default:return String(e)}},qe=r=>{const{getStyles:o}=ne(),{open:l,cancel:s,submit:u,areChildrenBeingEdited:h,getSnapshot:m}=ce(),{setCollapseState:y}=he(),{mainContainerRef:v,data:b,nodeData:w,parentData:D,showCollectionCount:E,canDragOnto:C,canAddHere:j,collapseFilter:S,collapseAnimationTime:T,showClipboardButton:N,onCopy:x,showIconTooltips:R,indent:A,sort:P,showArrayIndexes:I,defaultValue:L,newKeyOptions:K,translate:_,customNodeDefinitions:V,customNodeData:F,jsonParse:B,jsonStringify:H,TextEditor:W,Select:U,keyboardControls:$,handleKeyboard:X,insertAtTop:J,onCollapse:Q,editConfirmRef:Z,collapseClickZones:G,getLatestData:q}=r,[ee,te]=p(null),{showCollectionWrapper:re=!0}=F,oe=re&&S(w),{contentRef:ae,isAnimating:ie,maxHeight:le,collapsed:se,animateCollapse:ue,cssTransitionValue:pe}=((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||((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)})(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}})(b,T,oe,v,H),{pathString:fe,nodeData:ye,path:ge,name:ve,size:be,canEdit:we,canDelete:Ee,canAdd:Ce,canDrag:je,error:Se,setError:Oe,onError:ke,derivedValues:Te,buildKeyDisplayProps:Ne}=Fe({props:r,collapsed:se}),{dragSourceProps:xe,getDropTargetProps:Re,BottomDropTarget:Ae,DropTargetPadding:Ke}=Be({canDrag:je,canDelete:Ee,canDragOnto:C,canAddHere:j,path:ge,nodeData:ye,onError:ke,translate:_}),_e=i(!oe),{isEditing:Ve,isEditingKey:Me,isPending:We,isArray:Ye}=Te,Ue=(e=>{const t=i(e),n=!Object.is(t.current,e);return a(()=>{t.current=e}),n})(S);a(()=>{const e=re&&S(ye)&&!Ve;_e.current=!e,ue(e),Ue&&y(null)},[S]),((e,t,n)=>{const{commands:r,version:o}=he(),l=i(0);a(()=>{if(o===l.current)return;if(l.current=o,!r)return;let a;for(const t of r)me(e,t)&&(a=t);a&&(a.collapsed||(t.current=!0),n(a.collapsed))},[o,r])})(ge,_e,re?ue:f);const Xe=i(null),Je=d(e=>te(t=>"function"==typeof e?e(t??H(b)):e),[b,H]),Qe=d(()=>te(null),[]),Ze=c(()=>Ve?ee??H(b):null,[Ve,ee,b,H]),Ge=d((e,t)=>{if("function"!=typeof L)return L;const n=L(e,t);return void 0!==n?n:null},[L]),qe=d(e=>K?"function"!=typeof K?K:K(e):null,[K]),{CustomComponent:tt,componentProps:nt,CustomWrapperComponent:rt,wrapperProps:ot={},showKey:at=!0,showEditTools:it=!0,showOnEdit:lt,showOnView:st,passOriginalNode:ct}=F,dt=de(e=>null!==e.active&&k(e.active.path,ge));!dt&&re||!se||ue(!1);const ut=De(ge)||0===ye.level,pt=i(f);if(!ut&&!dt)return null;const{visibleSize:ht}=ye,mt=Array.isArray(b)?"array":"object",ft="array"===mt?{open:"[",close:"]"}:{open:"{",close:"}"},yt=e=>{if("Tab"===e.key&&!e.getModifierState("Shift")&&e.target===Xe.current){e.preventDefault();const t=Y(Xe,"\t");return void te(t)}X(e,{objectConfirm:vt,cancel:wt})},gt=e=>{if(e.stopPropagation(),!re)return;const t=z(e);if(t&&$.collapseModifier.includes(t))return _e.current=!0,void y({collapsed:!se,path:ge,includeChildren:!0});h(ge)||(_e.current=!0,Q&&Q({...ye,fullData:q(),collapsed:!se,includeChildren:!1}),ue(!se))},vt=e=>{let t=b;if(null!==ee)try{t=B(ee)}catch{return void ke({code:"INVALID_JSON",message:_("ERROR_INVALID_JSON",ye)},ee)}Oe(null);const n="function"==typeof e?e:void 0;u({op:"edit",path:ge,value:t,onCommit:()=>{Qe(),n?.()}}).then(e=>{if("error"===e?.status&&ke(e.error,t),"error"===e?.status||"cancel"===e?.status){const e=m().active;"editing"===e?.phase&&O(e.path,ge)||Qe()}})};pt.current=vt;const bt=ge.length>0?()=>{u({op:"delete",path:ge,instant:!0}).then(e=>{"error"===e?.status&&ke(e.error,b)})}:void 0,wt=()=>{s(),Oe(null),Qe()},Dt="when-collapsed"===E?se:"when-collapsed-or-filtered"===E?se||null!=ht:E,Et=!Ve&&it,Ct=(I||!Ye)&&at&&void 0!==ve,jt=tt&&(Ve&&lt||!Ve&&st),St=Object.entries(b).map(([e,t])=>["array"===mt?Number(e):e,t]);"object"===mt&&P(St,e=>e);const Ot=!Ve||!!tt&&lt,kt=()=>e("div",{className:"jer-collection-text-edit"+(W?"-custom":""),children:[W?t(W,{value:Ze??"",onChange:te,onKeyDown:e=>X(e,{objectConfirm:vt,cancel:wt})}):t(M,{textAreaRef:Xe,className:"jer-collection-text-area",name:fe,value:Ze??"",setValue:Je,onKeyDown:yt,styles:o("input",ye)}),t("div",{className:"jer-collection-input-button-row",children:t(Le,{onOk:vt,onCancel:wt,nodeData:ye,translate:_,showIconTooltips:R,editConfirmRef:Z})})]}),Tt=_e.current?Ot?St.map(([e,n],a)=>{const i={key:e,value:n,path:[...ge,e],level:ge.length+1,index:a,size:g(n)?Object.keys(n).length:null,parentData:b,fullData:ye.fullData},l=ze(V,i);return t("div",{className:"jer-collection-element",style:o("collectionElement",i),children:g(n)&&!l?.renderCollectionAsValue?t(et,{...r,data:n,parentData:b,nodeData:i,canDragOnto:we,canAddHere:Ce,customNodeData:l},e):t($e,{...r,data:n,parentData:b,nodeData:i,canDragOnto:we,canAddHere:Ce,showLabel:"object"===mt||I,customNodeData:l},e)},e)}):t(n,{children:kt()}):null,Nt=!!re&&se&&!dt;Nt||(_e.current=!0);const xt=_(se?"TOOLTIP_EXPAND":"TOOLTIP_COLLAPSE",ye),Rt=()=>({...r,data:b,value:b,parentData:D,nodeData:ye,setValue:e=>u({op:"edit",path:ge,value:e}),handleEdit:vt,handleCancel:wt,onKeyDown:yt,isEditing:Ve,isPending:We,setIsEditing:we?()=>l(ge,{cancelOp:Qe,commitOp:e=>pt.current(e)}):f,getStyles:o,canDragOnto:we,canAddHere:Ce,canEdit:we,keyboardCommon:{}}),At=jt?t(tt,{componentProps:nt,...Rt(),originalNode:ct&&Ve?kt():void 0,children:Tt}):Tt,Pt=Et&&t(Ie,{startEdit:we?()=>{_e.current=!0,l(ge,{cancelOp:Qe,commitOp:e=>pt.current(e)})}:void 0,handleAdd:Ce?e=>{y(null),ue(!1);const t=Ge(ye,e);if("array"===mt){const e=J.array?0:b.length,n=J.array?{insert:!0}:{};return void u({op:"add",path:ge,key:e,value:t,options:n,instant:!0}).then(e=>{"error"===e?.status&&ke(e.error,t)})}if(e in b)return ke({code:"KEY_EXISTS",message:_("ERROR_KEY_EXISTS",ye)},e),void s();const n=J.object?{insertBefore:0}:{};u({op:"add",path:ge,key:e,value:t,options:n}).then(e=>{"error"===e?.status&&ke(e.error,t)})}:void 0,handleDelete:Ee?bt:void 0,showClipboardButton:N,onCopy:x,type:mt,nodeData:ye,translate:_,customButtons:r.customButtons,keyboardControls:$,handleKeyboard:X,getNewKeyOptions:qe,editConfirmRef:Z,jsonStringify:H,showIconTooltips:R,Select:U}),It=Ne({handleCancel:wt,getStyles:o,keyValueArray:St,handleClick:G.includes("property")?gt:e=>e.stopPropagation()}),Lt=e("div",{className:"jer-component jer-collection-component",style:{marginLeft:(0===ge.length?0:A/2)+"em",...o("collection",ye),position:"relative"},draggable:je&&!Ve&&!Me&&!dt,...xe,...Re("above"),children:[re&&t("div",{className:"jer-clickzone",style:{width:A/2+1+"em",zIndex:10+2*ye.level},onClick:G.includes("left")?gt:void 0}),!Ve&&Ae,t(Ke,{position:"above",nodeData:ye}),re?e("div",{className:"jer-collection-header-row",style:{...o("headerRow",ye),position:"relative"},onClick:G.includes("header")?gt:void 0,children:[e("div",{className:"jer-collection-name",children:[t("button",{type:"button",className:"jer-collapse-icon jer-accordion-icon"+(se?" jer-rotate-90":""),style:{zIndex:11+2*ye.level,transition:pe},onClick:gt,tabIndex:-1,"aria-expanded":!se,"aria-label":xt,title:R?xt:"",children:t(Pe,{name:"collection",nodeData:ye})}),Ct&&t(He,{...It}),!Ve&&t("span",{className:"jer-brackets jer-bracket-open",style:o("bracket",ye),children:ft.open})]}),!1!==E&&!Ve&&t("div",{className:"jer-collection-item-count"+(Dt?" jer-visible":" jer-hidden"),style:{...o("itemCount",ye),transition:pe,transitionBehavior:"allow-discrete"},children:null!=ht&&ht!==be?_("ITEMS_FILTERED",ye,{visible:ht,total:be}):1===be?_("ITEM_SINGLE",{...ye,size:1},1):_("ITEMS_MULTIPLE",ye,be)}),t("div",{className:"jer-brackets"+(Nt?" jer-visible":" jer-hidden"),style:{...o("bracket",ye),transition:pe},children:ft.close}),Pt]}):at?e("div",{className:"jer-collection-header-row",style:{...o("headerRow",ye),position:"relative"},children:[t(He,{...It}),Pt]}):t(n,{}),e("div",{className:"jer-collection-inner",style:{overflowY:Nt||ie?"clip":"visible",maxHeight:dt?void 0:le,...o("collectionInner",ye),transition:pe},ref:ae,children:[At,t("div",{className:Ve?"jer-collection-error-row-edit":"jer-collection-error-row",children:Se&&t("span",{className:"jer-error-slug",style:o("error",ye),children:Se})}),!Ve&&re&&t("div",{className:"jer-brackets jer-bracket-outside",style:o("bracket",ye),children:ft.close})]}),t(Ke,{position:"below",nodeData:ye})]});return rt?t(rt,{wrapperProps:ot,...Rt(),children:Lt}):Lt},et=/*#__PURE__*/r.memo(qe,Ye),tt=({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"})]}),nt=(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}},rt=({key:e,path:t},n="")=>!!nt({value:e},n)||!!t.some(e=>nt({value:e},n)),ot={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)",SHOW_MORE:"Show more",EMPTY_STRING:"<empty string>",TOOLTIP_COPY:"Copy to clipboard",TOOLTIP_EDIT:"Edit",TOOLTIP_DELETE:"Delete",TOOLTIP_ADD:"Add",TOOLTIP_OK:"OK",TOOLTIP_CANCEL:"Cancel",TOOLTIP_COLLAPSE:"Collapse",TOOLTIP_EXPAND:"Expand"};var at=':root,:host{--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;padding:0 1em 0 0;margin:0;font-family:inherit;font-size:.8em;color:#000;cursor:inherit;line-height:inherit;z-index:1;outline:none}select::-ms-expand{display:none}.jer-select{display:grid;grid-template-areas:"select";align-items:center;position:relative;min-width:12ch;max-width:15ch;border:1px solid var(--jer-select-border);border-radius:.25em;padding:.25em .5em;cursor:pointer;line-height:1.1;background-color:#fff;background-image:linear-gradient(to top,#f9f9f9,#fff 33%)}.jer-select select,.jer-select:after{grid-area:select}.jer-select:not(.jer-select--multiple):after{content:"";justify-self:end;width:.8em;height:.5em;background-color:var(--jer-select-arrow);clip-path:polygon(100% 0%,0 0%,50% 100%)}select:focus+.focus{position:absolute;inset:-1px;border:1px solid var(--jer-select-focus);border-radius:inherit}.jer-select-inner{width:100%;text-overflow:ellipsis}.jer-editor-container{position:relative;font-size:16px;line-height:1;padding:1em 1em 1em 2em;border-radius:.5em;text-align:left}.jer-editor-container textarea{color:var(--jer-input-color);border:var(--jer-form-border);border-radius:.3em;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;outline:none;font-family:inherit}.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{display:flex;min-height:1.7em;gap:.3em;align-items:center}.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{position:absolute;left:-1.2em;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{display:flex;flex-direction:column;gap:.3em;align-items:flex-start;line-height:1.1em}.jer-collection-text-edit{width:fit-content}.jer-collection-text-area{box-sizing:content-box;resize:both;padding:.2em .5em 0;overflow:hidden;max-height:40em;line-height:1.25em;font-family:inherit;font-size:.85em}.jer-collection-input-button-row{display:flex;justify-content:flex-end;width:100%;font-size:150%;margin-top:.4em}.jer-collection-error-row-edit{position:absolute;bottom:.5em}.jer-error-slug{margin-left:1em}.jer-value-component{position:relative}.jer-value-and-buttons{display:flex;justify-content:flex-start;align-items:center;padding-left:.5em}.jer-value-error-row{position:absolute}.jer-value-string{line-height:1.3em;white-space:pre-wrap;overflow-wrap:anywhere;word-break:break-word}.jer-string-expansion{cursor:pointer;opacity:.6;filter:saturate(50%)}.jer-string-expansion.jer-show-less{font-size:80%}.jer-hyperlink{text-decoration:underline}.jer-input-text{box-sizing:content-box;resize:none;margin:0;height:1.4em;padding:.25em .5em .2em;min-width:6em;overflow:hidden;line-height:1.2em;font-family:inherit;font-size:.9em}.jer-input-boolean{transform:scale(1.5);margin-left:.3em;margin-right:.3em}.jer-key-text{word-break:break-word;line-height:1.1em;white-space:pre-wrap}.jer-key-edit{padding:0 .3em;font-size:inherit;font-size:.9em}.jer-value-invalid{opacity:.5;font-style:italic}.jer-input-number{min-width:3em;font-size:90%}.jer-edit-buttons,.jer-confirm-buttons{display:flex;align-items:center;cursor:pointer;height:1em;margin-right:.2em}.jer-edit-buttons>button,.jer-confirm-buttons>button,button.jer-collapse-icon,button.jer-string-expansion{appearance:none;background:none;border:none;margin:0;padding:0;font:inherit;color:inherit;vertical-align:baseline}.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{opacity:1}.jer-value-main-row:hover>.jer-edit-buttons{opacity:1}.jer-value-and-buttons:hover>.jer-edit-buttons{opacity:1}.jer-copy-pulse{position:relative;transition:.3s}.jer-copy-pulse:hover{opacity:.85;transition:.3s;transform:scale(1.2)}.jer-copy-pulse:after{content:"";display:block;position:absolute;border-radius:50%;left:0;top:0;width:100%;height:100%;opacity:0;transition:all .5s;box-shadow:0 0 15px 5px var(--jer-icon-copy-color)}.jer-copy-pulse:active:after{box-shadow:0 0 0 0 var(--jer-icon-copy-color);position:absolute;border-radius:4em;left:0;top:0;opacity:1;transition:0s}.jer-copy-pulse:active{top:.07em}.jer-icon:hover{opacity:.85;transition:.3s;transform:scale(1.2)}.jer-empty-string{font-style:italic;font-size:90%}.jer-drag-n-drop-padding{height:.5em;border:1px dashed #b4b4b4;border-radius:.3em}.jer-clickzone{position:absolute;left:-1em;top:1.2em;height:calc(100% - .8em)}';const it="data-jer-styles",lt=(e,t)=>JSON.stringify(e,t,2),st={edit:"ERROR_UPDATE",add:"ERROR_ADD",delete:"ERROR_DELETE",rename:"ERROR_RENAME",move:"ERROR_MOVE"},ct={edit:"UPDATE_ERROR",add:"ADD_ERROR",delete:"DELETE_ERROR",rename:"RENAME_ERROR",move:"MOVE_ERROR"},dt=e=>{const t=i(e);e&&(t.current=e);const n=i((...e)=>t.current(...e));return e?n.current:void 0},ut=[],pt=["header","left"],ht={},mt={},ft={},yt=[],gt=({data:e,setData:n,buildNodeDataFromPathRef:r,commitRef:o,rootName:l="root",onUpdate:s=f,onChange:u,onError:h,onEditEvent:w,showErrorMessages:E=!0,showClipboardButton:C=!0,onCopy:j,indent:O=2,collapse:k=3,collapseAnimationTime:T=300,showCollectionCount:N="when-collapsed-or-filtered",allowEdit:x=!0,allowDelete:R=!0,allowAdd:A=!0,allowTypeSelection:P=!0,allowDrag:I=!1,searchFilter:K,searchText:V,searchDebounceTime:M=350,sortKeys:z=!1,showArrayIndexes:B=!0,arrayIndexStart:Y=0,showStringQuotes:U=!0,showIconTooltips:$=!1,defaultValue:X=null,newKeyOptions:J,minWidth:Q=250,maxWidth:Z="min(600px, 90vw)",baseFontSize:G,stringTruncateLength:q=250,translations:ee=ht,className:te,id:re,customText:oe=mt,customNodeDefinitions:ae=ut,customButtons:ie=yt,jsonParse:le=JSON.parse,jsonStringify:se=lt,TextEditor:de,Select:ue=tt,errorDisplayTime:pe=2500,keyboardControls:me=ft,editorRef:fe,insertAtTop:ye=!1,onCollapse:ge,collapseClickZones:ve=pt})=>{const{getStyles:we,cssVars:De}=ne(),{open:Ee,cancel:Ce,getSnapshot:je}=ce(),Se=c(()=>wt(k),[k]),Oe=c(()=>((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]:ot[r];if(void 0!==o){const e=v(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))(ee,oe),[ee,oe]),[ke,Te]=p(V),Ne=i(null);a(()=>{Ce();const e=setTimeout(()=>Te(V),M);return()=>clearTimeout(e)},[V,M]);const xe=_(e,[],l),Re=i(e);Re.current=e;const Ae=i(n);Ae.current=n;const Pe=i(Oe);Pe.current=Oe;const Ie=i(xe);Ie.current=xe;const Le=i(s);Le.current=s;const Ke=i(l);Ke.current=l;const _e=i(void 0),Ve=d(()=>Re.current,[]),Me=dt(u),Fe=dt(h),Be=dt(ge),He=dt(w),We=dt(j),Ye=d(e=>{Re.current=e,Ae.current(e)},[]),Ue=d((e,t)=>{Ye(bt(Re.current,e,t,"update").newData)},[Ye]),Xe=d(e=>{const t=Re.current,n=Ke.current,r=_e.current,o=Ye,{op:a,path:i}=e;switch(a){case"edit":{const{newData:a,currentValue:l,newValue:s}=bt(t,i,e.value,"update"),c=_(t,i,n,r);return{input:{...c,newData:a,event:"edit",newValue:s},nodeData:c,isNoOp:l===s,apply:()=>o(a),revert:()=>o(bt(Re.current,i,l,"update").newData)}}case"delete":{const{newData:e,currentValue:a}=bt(t,i,"","delete"),l=_(t,i,n,r);return{input:{...l,newData:e,event:"delete"},nodeData:l,isNoOp:!1,apply:()=>o(e),revert:()=>o(bt(Re.current,i,a,"add",{insert:!0,insertBefore:l.index}).newData)}}case"add":{const a=[...i,e.key],{newData:l,newValue:s}=bt(t,a,e.value,"add",e.options),c=_(l,a,n,r);return{input:{...c,value:void 0,size:null,parentData:L(t,i)??null,fullData:t,newData:l,event:"add",newValue:s},nodeData:c,isNoOp:!1,apply:()=>o(l),revert:()=>o(bt(Re.current,a,"","delete").newData)}}case"rename":{const a=i.slice(0,-1),l=i[i.length-1],{newKey:s}=e,c=L(t,a),d=Object.fromEntries(Object.entries(c).map(([e,t])=>e===l?[s,t]:[e,t])),{newData:u}=bt(t,a,d,"update"),p=_(t,i,n,r);return{input:{...p,newData:u,event:"rename",newKey:s},nodeData:p,isNoOp:l===s,apply:()=>o(u),revert:()=>o(bt(Re.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}=bt(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}=bt(d,g,u,"add",y),b=_(t,a,n,r);return{input:{...b,newData:v,event:"move",newPath:g},nodeData:b,isNoOp:!1,apply:()=>o(v),revert:()=>o(c)}}}},[Ye]),Je=d((e,t)=>{const n=ct[e.event],r=()=>Pe.current(st[e.event],Ie.current),o=e=>{const t=e instanceof Error&&e.message?e.message:"string"==typeof e&&e?e:r();return{status:"error",error:{code:n,message:t}}},a=t=>{if(!1===t)return{status:"error",error:{code:n,message:r()}};if(null===t)return{status:"cancel"};if(t&&"object"==typeof t){if(void 0!==t.error)return"string"==typeof t.error?{status:"error",error:{code:n,message:t.error}}:{status:"error",error:t.error};const r=void 0!==t.data,o=void 0!==t.value;if(r&&o&&console.warn("json-edit-react: onUpdate returned both { value } and { data }; { data } (whole-document) takes precedence and { value } is ignored."),r)return{status:"override",value:t.data,path:[]};if(o&&("edit"===e.event||"add"===e.event))return{status:"override",value:t.value,path:e.path}}return{status:"commit"}};let i;try{i=Le.current(e,t)}catch(e){return o(e)}return b(i)?i.then(a,o):a(i)},[]),Qe=c(()=>({runUpdate:s===f?void 0:Je,buildCommit:Xe,applyValue:Ue}),[Je,Xe,Ue,s]);o.current=Qe;const Ze=c(()=>wt(x),[x]),Ge=c(()=>wt(R),[R]),qe=c(()=>wt(A),[A]),rt=c(()=>wt(I),[I]),at=c(()=>Dt(K),[K]),it=c(()=>((e,t,n)=>{if(!t&&!n)return null;const r=new Set,o=new Map,a=t??nt,i=n??"",l=e=>{let t=a(e,i);if(g(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:g(i)?Object.keys(i).length:null,parentData:e.value,fullData:e.fullData};l(s)&&(t=!0,n++)}o.set(S(e.path),n)}return t&&r.add(S(e.path)),t};return l(e),{visiblePaths:r,visibleChildCounts:o}})(xe,at,ke),[e,ke,at,l]),gt=c(()=>(e=>{const t={...H};for(const n of Object.keys(H)){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?y(o):"string"==typeof o?{key:o}:o)();t[r]=i}return W.forEach(n=>{void 0===e[n]&&void 0!==e.confirm&&(t[n]=t.confirm)}),t})(me),[me]),vt=d((e,t)=>((e,t,n)=>{for(const[r,o]of Object.entries(t))if(F(n,e[r],r)){n.preventDefault(),o();break}})(gt,t,e),[gt]),Ct=c(()=>{const e=Et(ae,"stringifyReplacer");return t=>se(t,e)},[ae,se]),jt=c(()=>{const e=Et(ae,"parseReviver");return t=>{const n=le(t,e);return D(n)}},[ae,le]),St=i(null),{setCollapseState:Ot}=he(),kt=d((e,t)=>{!1!==z&&("function"!=typeof z?e.sort((e,n)=>{const r=t(e)[0],o=t(n)[0];return r<o?-1:r>o?1:0}):e.sort((e,n)=>z(t(e),t(n))))},[z]);_e.current=kt;const Tt=d(e=>_(Ve(),e,Ke.current,_e.current),[Ve]);r.current=Tt,m(fe,()=>{const e=Symbol("path-missing");return{collapse:e=>Ot(e),startEdit:({path:t,overrideRestrictions:n=!1})=>L(Ve(),t,e)===e?"PATH_NOT_FOUND":n||Ze(_(Ve(),t,l,kt))?(Ee(t,{force:!0}),!0):"RESTRICTED",confirm:()=>{St.current&&(St.current.click(),"editing"!==je().active?.phase&&Ce())},cancel:()=>Ce()}},[Ot,Ee,Ce,je,Ze,Ve,l,kt]);const Nt=ze(ae,xe),xt=c(()=>({object:!0===ye||"object"===ye,array:!0===ye||"array"===ye}),[ye]),Rt={mainContainerRef:Ne,name:l,nodeData:xe,getLatestData:Ve,onChange:Me,onError:Fe,onEditEvent:He,showErrorMessages:E,showCollectionCount:N,collapseFilter:Se,collapseAnimationTime:T,allowEditFilter:Ze,allowDeleteFilter:Ge,allowAddFilter:qe,allowTypeSelection:P,allowDragFilter:rt,canDragOnto:!1,canAddHere:!1,showClipboardButton:C,onCopy:We,sortKeys:z,sort:kt,showArrayIndexes:B,arrayIndexStart:Y,showStringQuotes:U,showIconTooltips:$,indent:O,defaultValue:X,newKeyOptions:J,stringTruncateLength:q,translate:Oe,customNodeDefinitions:ae,customNodeData:Nt,customButtons:ie,parentData:null,jsonParse:jt,jsonStringify:Ct,TextEditor:de,Select:ue,errorDisplayTime:pe,handleKeyboard:vt,keyboardControls:gt,insertAtTop:xt,onCollapse:Be,editConfirmRef:St,collapseClickZones:ve},At={...we("container",xe),...De,minWidth:Q,maxWidth:Z};return At.fontSize=G??At.fontSize,t("div",{id:re,ref:Ne,className:`jer-editor-container ${te??""}`,style:At,children:t(be,{value:it,children:g(e)&&!Nt.renderCollectionAsValue?t(et,{data:e,...Rt}):t($e,{data:e,showLabel:!0,...Rt})})})};function vt(e){h(()=>{(()=>{if("undefined"==typeof document)return;const e=document.head.querySelector(`style[${it}]`);if(e)return void(e.textContent!==at&&(e.textContent=at));const t=document.createElement("style");t.setAttribute(it,""),t.textContent=at,document.head.appendChild(t)})()},[]);const n=i(void 0),r=i(void 0),o=e;return t(te,{theme:o.theme??Q,children:t(ge,{onEditEvent:o.onEditEvent,onCollapse:o.onCollapse,buildNodeDataFromPathRef:n,commitRef:r,children:t(gt,{...o,buildNodeDataFromPathRef:n,commitRef:r})})})}const bt=(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?L(e,t):void 0;return{currentData:e,newData:R(e,t,n,a),currentValue:i,newValue:"delete"!==r?n:void 0}},wt=e=>"boolean"==typeof e?()=>e:"number"==typeof e?({level:t})=>t>=e:e,Dt=e=>{if(void 0!==e)return"value"===e?nt:"key"===e?rt:"all"===e?(e,t)=>nt(e,t)||rt(e,t):e},Et=(e,t)=>{const n="stringifyReplacer"===t?[e=>void 0===e?E: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 Ct(e){const{editorRef:n,...r}=e,o=i(null);return m(n,()=>({collapse:e=>o.current?.collapse(e)}),[]),t(vt,{...r,editorRef:o,setData:f,allowEdit:!1,allowAdd:!1,allowDelete:!1,allowDrag:!1})}export{M as AutogrowTextArea,Ae as IconSvg,vt as JsonEditor,Ct as JsonViewer,je as StringDisplay,Se as StringEdit,R as assign,_e as collectionDataTypes,Q as defaultTheme,L as extract,g as isCollection,nt as matchNode,rt as matchNodeKey,C as splitPropertyString,Ve as standardDataTypes,S as toPathString,Ne as useKeyboardListener,Ke as valueDataTypes};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "json-edit-react",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
4
4
  "description": "React component for editing or viewing JSON/object data",
5
5
  "main": "build/index.cjs.js",
6
6
  "module": "build/index.esm.js",