@vertesia/ui 0.79.2 → 0.79.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/esm/core/components/MenuList.js +2 -5
- package/lib/esm/core/components/MenuList.js.map +1 -1
- package/lib/esm/core/components/SelectBox.js +1 -1
- package/lib/esm/core/components/SelectBox.js.map +1 -1
- package/lib/esm/core/components/index.js +1 -2
- package/lib/esm/core/components/index.js.map +1 -1
- package/lib/esm/core/components/shadcn/dialog.js +16 -2
- package/lib/esm/core/components/shadcn/dialog.js.map +1 -1
- package/lib/esm/core/components/shadcn/filters/filter/SelectFilter.js +6 -9
- package/lib/esm/core/components/shadcn/filters/filter/SelectFilter.js.map +1 -1
- package/lib/esm/core/components/shadcn/filters/filterBar.js +1 -1
- package/lib/esm/core/components/shadcn/filters/filterBar.js.map +1 -1
- package/lib/esm/core/components/shadcn/popover.js +1 -1
- package/lib/esm/core/components/shadcn/popover.js.map +1 -1
- package/lib/esm/core/components/shadcn/selectBox.js +1 -1
- package/lib/esm/core/components/shadcn/selectBox.js.map +1 -1
- package/lib/esm/core/hooks/CompositeState.js +1 -139
- package/lib/esm/core/hooks/CompositeState.js.map +1 -1
- package/lib/esm/env/index.js +3 -0
- package/lib/esm/env/index.js.map +1 -1
- package/lib/esm/features/agent/PayloadBuilder.js +55 -80
- package/lib/esm/features/agent/PayloadBuilder.js.map +1 -1
- package/lib/esm/features/agent/chat/ModernAgentOutput/AllMessagesMixed.js +1 -1
- package/lib/esm/features/agent/chat/ModernAgentOutput/AllMessagesMixed.js.map +1 -1
- package/lib/esm/features/agent/chat/ModernAgentOutput/Header.js +1 -1
- package/lib/esm/features/agent/chat/ModernAgentOutput/Header.js.map +1 -1
- package/lib/esm/features/agent/chat/ModernAgentOutput/WorkstreamTabs.js +2 -2
- package/lib/esm/features/agent/chat/ModernAgentOutput/WorkstreamTabs.js.map +1 -1
- package/lib/esm/features/facets/CollectionsFacetsNav.js +5 -1
- package/lib/esm/features/facets/CollectionsFacetsNav.js.map +1 -1
- package/lib/esm/features/layout/GenericPageNavHeader.js +5 -2
- package/lib/esm/features/layout/GenericPageNavHeader.js.map +1 -1
- package/lib/esm/features/store/collections/EditCollectionView.js +7 -18
- package/lib/esm/features/store/collections/EditCollectionView.js.map +1 -1
- package/lib/esm/features/store/collections/index.js +0 -2
- package/lib/esm/features/store/collections/index.js.map +1 -1
- package/lib/esm/features/store/objects/DocumentSearchResults.js +1 -8
- package/lib/esm/features/store/objects/DocumentSearchResults.js.map +1 -1
- package/lib/esm/features/store/objects/components/useDownloadObject.js +2 -2
- package/lib/esm/features/store/objects/components/useDownloadObject.js.map +1 -1
- package/lib/esm/features/user/UserInfo.js +0 -2
- package/lib/esm/features/user/UserInfo.js.map +1 -1
- package/lib/esm/router/HistoryNavigator.js +22 -2
- package/lib/esm/router/HistoryNavigator.js.map +1 -1
- package/lib/esm/session/UserSession.js +0 -1
- package/lib/esm/session/UserSession.js.map +1 -1
- package/lib/esm/session/UserSessionProvider.js +2 -9
- package/lib/esm/session/UserSessionProvider.js.map +1 -1
- package/lib/esm/session/auth/composable.js +67 -66
- package/lib/esm/session/auth/composable.js.map +1 -1
- package/lib/esm/shell/apps/AppProjectSelector.js +2 -2
- package/lib/esm/shell/apps/AppProjectSelector.js.map +1 -1
- package/lib/esm/shell/login/UserInfo.js +2 -1
- package/lib/esm/shell/login/UserInfo.js.map +1 -1
- package/lib/esm/shell/login/UserSessionMenu.js +7 -1
- package/lib/esm/shell/login/UserSessionMenu.js.map +1 -1
- package/lib/esm/widgets/form/Form.js +5 -1
- package/lib/esm/widgets/form/Form.js.map +1 -1
- package/lib/esm/widgets/form/ManagedObject.js +0 -4
- package/lib/esm/widgets/form/ManagedObject.js.map +1 -1
- package/lib/esm/widgets/schema-editor/ManagedSchema.js +0 -3
- package/lib/esm/widgets/schema-editor/ManagedSchema.js.map +1 -1
- package/lib/esm/widgets/schema-editor/json-schema4-utils.js +1 -1
- package/lib/esm/widgets/schema-editor/json-schema4-utils.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/core/components/index.d.ts +1 -2
- package/lib/types/core/components/index.d.ts.map +1 -1
- package/lib/types/core/components/shadcn/dialog.d.ts +2 -1
- package/lib/types/core/components/shadcn/dialog.d.ts.map +1 -1
- package/lib/types/core/components/shadcn/filters/filterBar.d.ts.map +1 -1
- package/lib/types/core/components/shadcn/popover.d.ts +0 -7
- package/lib/types/core/components/shadcn/popover.d.ts.map +1 -1
- package/lib/types/core/components/shadcn/selectBox.d.ts.map +1 -1
- package/lib/types/core/hooks/CompositeState.d.ts +6 -115
- package/lib/types/core/hooks/CompositeState.d.ts.map +1 -1
- package/lib/types/env/index.d.ts +2 -2
- package/lib/types/env/index.d.ts.map +1 -1
- package/lib/types/features/agent/PayloadBuilder.d.ts +19 -11
- package/lib/types/features/agent/PayloadBuilder.d.ts.map +1 -1
- package/lib/types/features/facets/CollectionsFacetsNav.d.ts.map +1 -1
- package/lib/types/features/layout/GenericPageNavHeader.d.ts.map +1 -1
- package/lib/types/features/store/collections/EditCollectionView.d.ts.map +1 -1
- package/lib/types/features/store/collections/index.d.ts +0 -2
- package/lib/types/features/store/collections/index.d.ts.map +1 -1
- package/lib/types/features/store/objects/DocumentSearchResults.d.ts.map +1 -1
- package/lib/types/features/store/objects/components/useDownloadObject.d.ts +1 -1
- package/lib/types/features/store/objects/components/useDownloadObject.d.ts.map +1 -1
- package/lib/types/features/user/UserInfo.d.ts.map +1 -1
- package/lib/types/router/HistoryNavigator.d.ts +3 -0
- package/lib/types/router/HistoryNavigator.d.ts.map +1 -1
- package/lib/types/session/UserSession.d.ts.map +1 -1
- package/lib/types/session/UserSessionProvider.d.ts.map +1 -1
- package/lib/types/session/auth/composable.d.ts.map +1 -1
- package/lib/types/shell/login/UserInfo.d.ts.map +1 -1
- package/lib/types/shell/login/UserSessionMenu.d.ts.map +1 -1
- package/lib/types/widgets/form/Form.d.ts.map +1 -1
- package/lib/types/widgets/form/ManagedObject.d.ts.map +1 -1
- package/lib/types/widgets/schema-editor/ManagedSchema.d.ts.map +1 -1
- package/lib/vertesia-ui-core.js +1 -1
- package/lib/vertesia-ui-core.js.map +1 -1
- package/lib/vertesia-ui-env.js +1 -1
- package/lib/vertesia-ui-env.js.map +1 -1
- package/lib/vertesia-ui-features.js +1 -1
- package/lib/vertesia-ui-features.js.map +1 -1
- package/lib/vertesia-ui-router.js +1 -1
- package/lib/vertesia-ui-router.js.map +1 -1
- package/lib/vertesia-ui-session.js +1 -1
- package/lib/vertesia-ui-session.js.map +1 -1
- package/lib/vertesia-ui-shell.js +1 -1
- package/lib/vertesia-ui-shell.js.map +1 -1
- package/lib/vertesia-ui-widgets.js +1 -1
- package/lib/vertesia-ui-widgets.js.map +1 -1
- package/package.json +7 -7
- package/src/core/components/MenuList.tsx +3 -6
- package/src/core/components/shadcn/dialog.tsx +19 -1
- package/src/core/components/shadcn/filters/filter/SelectFilter.tsx +31 -31
- package/src/core/components/shadcn/filters/filterBar.tsx +1 -0
- package/src/core/components/shadcn/selectBox.tsx +1 -0
- package/src/env/index.ts +7 -2
- package/src/features/facets/CollectionsFacetsNav.tsx +5 -1
- package/src/features/layout/GenericPageNavHeader.tsx +5 -2
- package/src/features/store/collections/EditCollectionView.tsx +2 -2
- package/src/features/store/objects/DocumentSearchResults.tsx +2 -1
- package/src/router/HistoryNavigator.ts +30 -2
- package/src/shell/login/UserInfo.tsx +2 -0
- package/src/shell/login/UserSessionMenu.tsx +12 -1
- package/src/widgets/form/Form.tsx +6 -1
- package/src/widgets/schema-editor/ManagedSchema.ts +0 -3
- package/src/widgets/schema-editor/json-schema4-utils.ts +1 -1
- package/lib/esm/core/components/TagsInput.js +0 -194
- package/lib/esm/core/components/TagsInput.js.map +0 -1
- package/lib/esm/features/store/collections/SharedPropsEditor.js +0 -40
- package/lib/esm/features/store/collections/SharedPropsEditor.js.map +0 -1
- package/lib/esm/features/store/collections/SyncMemberHeadsToggle.js +0 -35
- package/lib/esm/features/store/collections/SyncMemberHeadsToggle.js.map +0 -1
- package/lib/types/core/components/TagsInput.d.ts +0 -16
- package/lib/types/core/components/TagsInput.d.ts.map +0 -1
- package/lib/types/features/store/collections/SharedPropsEditor.d.ts +0 -7
- package/lib/types/features/store/collections/SharedPropsEditor.d.ts.map +0 -1
- package/lib/types/features/store/collections/SyncMemberHeadsToggle.d.ts +0 -7
- package/lib/types/features/store/collections/SyncMemberHeadsToggle.d.ts.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as e,jsxs as t,Fragment as r}from"react/jsx-runtime";import n from"debounce";import s,{useRef as i,useEffect as a,useMemo as o,createContext as l,useContext as c,useState as d,Children as h,isValidElement as u}from"react";import{EditorView as p}from"@codemirror/view";import{useSafeLayoutEffect as m,Styles as f,FormItem as g,Button as y,DotBadge as v,Table as b,VTooltip as x,VSelectBox as w,VModal as N,VModalTitle as k,ModalBody as C,ModalFooter as j,useFlag as S,useClickOutside as O,useToast as A}from"@vertesia/ui/core";import{Text as P,EditorState as $}from"@codemirror/state";import{Plus as T,Trash2 as E,Info as I,AlignLeft as q,SquarePen as M,ChevronDown as L,ChevronRight as D,UploadIcon as z,CheckCircleIcon as F,AlertCircleIcon as R,XCircleIcon as _}from"lucide-react";import V from"clsx";import U from"ajv";import{ObjectWalker as K}from"@vertesia/json";import B from"react-markdown";import W from"remark-gfm";import{visit as H,SKIP as G}from"unist-util-visit";import{offset as X,shift as Z,flip as Y}from"@floating-ui/dom";import{useFloating as J,autoUpdate as Q,useDismiss as ee,useClick as te,useHover as re,useInteractions as ne,useTransitionStyles as se,FloatingPortal as ie,FloatingFocusManager as ae,safePolygon as oe}from"@floating-ui/react";import{isNil as le,omit as ce,isEqual as de}from"lodash-es";import{XMLParser as he,XMLValidator as ue}from"fast-xml-parser";let pe=null;class me{editor;constructor(e){this.editor=e}setValue(e){this.editor.dispatch({changes:{from:0,to:this.editor.state.doc.length,insert:e||""}})}getValue(){return this.editor.state.doc.toString()}}const fe=[p.theme({"&":{fontSize:"14px",fontFamily:"monospace"},".cm-content":{fontFamily:"inherit"},".cm-scroller":{fontFamily:"inherit"},".cm-gutters":{backgroundColor:"transparent",color:"#ddd"},".cm-focused":{outline:"none"},".cm-cursor":{borderLeft:"2px solid #808080",borderLeftColor:"#808080",animation:"blink 1.2s step-start infinite"},"@keyframes blink":{"50%":{opacity:0}}}),p.lineWrapping];function ge({onChange:t,value:r,className:s,editorRef:l,extensions:c,debounceTimeout:d=0}){const h=i(null),u=i(void 0);a((()=>{if(t)return u.current=d>0?n(t,d):t,()=>{u.current=void 0}}),[t,d]);const f=o((()=>e("div",{ref:h,className:s})),[s]);return m((()=>{if(h.current){let t=[...fe,(e=e=>{u.current?.(e)},p.updateListener.of((t=>{t.docChanged&&e(t)})))];Array.isArray(c)?t=t.concat(c):c&&t.push(c);const n=((e="",t=[])=>{const r="string"==typeof e?P.of(e.split("\n")):e;return pe?pe.doc.toString()!==r.toString()&&(pe=$.create({doc:r,extensions:t})):pe=$.create({doc:r,extensions:t}),pe})(r,t),s=new p({state:n,parent:h.current}),i=new me(s);return l&&(l.current=i),()=>{s.destroy(),l&&(l.current=void 0)}}var e}),[f,c]),f}const ye=l(void 0),ve=ye.Provider;function be(){const e=c(ye);if(!e)throw new Error("useFieldSet must be used within a Form or FieldSet element");return e}class xe{object;components;disabled;constructor(e,t={},r=!1){this.object=e,this.components=t,this.disabled=r}}const we=l(void 0);function Ne(){const e=c(we);if(!e)throw new Error("useForm must be used within a Form element");return e}const ke=we.Provider,Ce=s.forwardRef((({object:t,type:r="text",onChange:n,...s},i)=>{const[a,o]=d(null!=t.value?String(t.value):""),[l,c]=d(t.schema.isBoolean&&!0===t.value);s.className?s.className=V(f.INPUT,s.className):s.className=f.INPUT;const h=e=>{s.disabled||(o(e.target.value),t.schema.isBoolean?(t.value=e.target.checked,c(t.value)):t.value=e.target.value,n&&n(e))};return"textarea"===r?e("textarea",{ref:i,...s,value:a,onChange:h}):e("input","checkbox"===r?{ref:i,...s,type:"checkbox",checked:l,onChange:h,className:"form-check-input"}:{ref:i,...s,type:r,value:a,onChange:h})}));function je({object:t,components:r,onSubmit:n,children:s,onChange:i,disabled:a}){return t.observer=i,e(ke,{value:new xe(t,r||{},a??!1),children:e("form",{className:"w-full",onSubmit:e=>{e.stopPropagation(),e.preventDefault(),n&&n(t.value)},children:s})})}function Se(){const t=Ne();return e("div",{className:"flex flex-col gap-4 w-full",children:t.object.properties.map(Ae)})}function Oe({children:r,...n}){return t(je,{...n,children:[e(Se,{}),r]})}function Ae(t){return t.isList?e(Te,{object:t},t.name):t.isObject?e($e,{object:t},t.name):e(Pe,{object:t},t.name)}function Pe({object:t,editor:r,inline:n=!1}){r||(r=t.schema.editor);const{components:s,disabled:i}=Ne(),a=r&&s[r]||Ce,o=t.getInputType();"checkbox"===o&&(n=!0);return e(g,{label:t.title,required:t.schema.isRequired,description:t.schema.description,className:V("flex",n?"flex-row items-center":"flex-col"),children:!t.isListItem&&e(a,{object:t,type:o,onChange:e=>{if(i)return;const{value:r}=e.target;t.value=t.schema.isNumber?parseFloat(r):r},disabled:i})})}function $e({object:r}){return t("div",{className:"flex flex-col gap-4 my-4 py-2 pl-4 border-l-4 border-l-solid border-l-slate-100 dark:border-l-slate-600",children:[!r.isListItem&&e("div",{className:"text-gray-900 dark:text-gray-200 font-semibold",children:r.title}),r.properties.map(Ae)]})}function Te({object:r}){const[n,s]=d(r.value||[]),{disabled:i}=Ne();return t("div",{className:"flex flex-col gap-4 my-4 py-2 pl-4 border-l-4 border-l-solid border-l-slate-100 darK:border-l-slate-600",children:[!r.isListItem&&e("div",{className:"text-gray-900 dark:text-gray-200 font-semibold",children:r.title}),r.items.map(((t,a)=>e(Ee,{object:t,list:r,onDelete:()=>(e=>{i||(r.remove(e),s([...r.value]))})(a),disabled:i},`${a}-${n[a]??""}`))),e("div",{children:t(y,{variant:"secondary",onClick:()=>{i||(r.add(),s([...r.value]))},disabled:i,children:[e(T,{className:"size-6"})," Add"]})})]})}function Ee({list:r,object:n,onDelete:s,disabled:i}){return t("div",{className:"flex gap-2 w-full",children:[e("div",{className:"flex-1",children:(a=n,o=r.schema.arraySchema.editor,a.isList?e(Te,{object:a}):a.isObject?e($e,{object:a}):e(Pe,{object:a,editor:o}))}),e(y,{variant:"secondary",onClick:s,disabled:i,children:e(E,{className:"size-4"})})]});var a,o}class Ie{schema;properties={};_validator;constructor(e){this.schema=e||{type:"object",properties:{}},this.load()}get validator(){if(!this._validator){const e=new U({allErrors:!0,strict:!1});this._validator=e.compile(this.schema)}return this._validator}load(){if(this.schema.properties){const e=this.schema.properties;Object.keys(e).forEach((t=>{this.loadProperty(t,e[t])}))}}hasProperties(){return Object.keys(this.properties).length>0}get title(){return this.schema.title||this.schema.name}get description(){return this.schema.description}loadProperty(e,t){let r;return r="array"===t.type?new Me(this,e,t):new qe(this,e,t),this.properties[e]=r,r}get type(){return this.schema.type}validate(e){return this.validator(e)?null:this.validator.errors||[]}addProperty(e,t,r=!1){"object"!==this.schema.type&&(this.schema.type="object"),this.schema.properties||(this.schema.properties={});const n="string"==typeof t?"object"===(s=t)?{type:"object",properties:{}}:"array"===s?{type:"array",items:{}}:{type:s}:t;var s;const i=this.loadProperty(e,n);return this.schema.properties[i.name]=i.schema,r&&(i.isRequired=!0),i}removeProperty(e){this.schema.properties&&(delete this.schema.properties[e],Array.isArray(this.schema.required)&&(this.schema.required=this.schema.required.filter((t=>t!==e)))),delete this.properties[e]}getProperty(e){return this.properties[e]}get editor(){return this.schema.editor}}class qe extends Ie{parent;name;constructor(e,t,r){if(super(r),this.parent=e,this.name=t,"array"===r.type)throw new Error("Array property must be instantiated using ArrayPropertySchema");"object"!==r.type||r.properties||(r.properties={})}get isMulti(){return!1}get isReadOnly(){return!!this.schema.readOnly}set isReadOnly(e){this.schema.readOnly=e}get defaultValue(){return this.schema.default}set defaultValue(e){this.schema.default=e}get enum(){return this.schema.enum}set enum(e){this.schema.enum=e}get isRequired(){const e=this.parent.schema.required;return!!e&&e.includes(this.name)}set isRequired(e){let t=Array.isArray(this.parent.schema.required)?this.parent.schema.required:[];t=e?t.concat(this.name):t.filter((e=>e!==this.name)),this.parent.schema.required=t}get type(){return this.schema.type}set type(e){this.schema.type!==e&&(this.schema.type=e,"object"!==e&&(this.properties={},this.schema.properties=void 0))}remove(){this.parent.removeProperty(this.name)}get isBoolean(){return"boolean"===this.type}get isString(){return"string"===this.type}get isNumber(){return"number"===this.type||"integer"===this.type}get isObject(){return"object"===this.type}}class Me extends qe{arraySchema;constructor(e,t,r){super(e,t,function(e){if("array"!==e.type)throw new Error("Expecting an array schema");if(e.items){if(Array.isArray(e.items))throw new Error("Tuple arrays are not supported")}else e.items={};return e.items}(r)),this.arraySchema=r}get isMulti(){return!0}}function Le(e){return(e=e.replace(/_/g," ").replace(/([a-z0-9])&([A-Z])/g,"$1 $2"))[0].toUpperCase()+e.slice(1)}function De(e,t){if(t.editor)return t.editor;if(t.schema.format)return t.schema.format;switch(t.type){case"number":case"integer":return"number";case"boolean":return"checkbox";default:return"text"}}class ze{parent;schema;name;observer;constructor(e,t,r){this.parent=e,this.schema=t,this.name=r}get isRoot(){return!this.parent}get root(){return this.parent?this.parent.root:this}get path(){return this.parent?this.parent.path.concat(this.name):[]}get isScalar(){return!1}get isListItem(){return!1}get isObject(){return!1}get isList(){return!1}get title(){return this.schema.title||Le(this.name)}onChange(e){this.observer&&!1===this.observer(this)||this.parent&&this.parent.onChange(e)}}class Fe extends ze{constructor(e,t,r){super(e,t,r)}get isObject(){return!0}getProperty(e){const t=this.schema.properties[e];return t.isMulti?new Ue(this,t,this.getOrInitArrayProperty(e)):t.isObject?new _e(this,t,t.name,this.getOrInitObjectProperty(e)):new Ve(this,t)}getOrInitObjectProperty(e){let t=this.value[e];return t||(this.value[e]=t={}),t}getOrInitArrayProperty(e){let t=this.value[e];return t||(this.value[e]=t=[]),t}setPropertyValue(e,t){return this.value[e]!==t&&(this.value[e]=t,!0)}getPropertyValue(e){return this.value[e]}get properties(){const e=[];for(const t of Object.values(this.schema.properties))t.isMulti?e.push(new Ue(this,t,this.getOrInitArrayProperty(t.name))):t.isObject?e.push(new _e(this,t,t.name,this.getOrInitObjectProperty(t.name))):e.push(new Ve(this,t));return e}[Symbol.iterator](){return this.properties[Symbol.iterator]()}}class Re extends Fe{value;constructor(e,t={}){super(null,e instanceof Ie?e:new Ie(e),"#root"),this.value=t}}class _e extends Fe{value;constructor(e,t,r,n){super(e,t,r),this.value=n}}class Ve extends ze{constructor(e,t){super(e,t,t.name),void 0===e.value[this.name]&&void 0!==t.defaultValue&&(e.value[this.name]=t.defaultValue)}get isScalar(){return!0}set value(e){this.parent.setPropertyValue(this.name,e)&&this.onChange(this)}get value(){return this.parent.getPropertyValue(this.name)}getInputType(){return De(this.name,this.schema)}}class Ue extends ze{value;items=[];constructor(e,t,r){super(e,t,t.name),this.value=r;for(const e of this.value)this.add()}get isList(){return!0}newItem(e){return this.schema.isObject?new Ke(this,e):new Be(this,e)}add(){const e=this.newItem(this.items.length);return this.items.push(e),e}remove(e){const t=this.value;if(e>=0&&e<this.items.length){this.items.splice(e,1);for(let e=0,t=this.items.length;e<t;e++){const t=this.items[e];t.index=e,t.name=String(e)}}Array.isArray(t)&&e>=0&&e<t.length&&(t.splice(e,1),this.onChange(this))}[Symbol.iterator](){return this.items[Symbol.iterator]()}item(e){if(e<0||e>=this.value.length)return;const t=this.value[e];return this.schema.isObject?new _e(this,this.schema,String(e),t):new Be(this,e)}trim(){for(;void 0===this.items[this.items.length-1];)this.items.pop()}}class Ke extends Fe{index;key;constructor(e,t){super(e,e.schema,String(t)),this.index=t,void 0===e.value[t]&&(e.value[t]={}),this.key=this.name+"@"+Date.now()}get isListItem(){return!0}set value(e){this.parent.value[this.index]=e}get value(){return this.parent.value[this.index]}}class Be extends ze{index;key;constructor(e,t){super(e,e.schema,String(t)),this.index=t,void 0===e.value[t]&&void 0!==e.schema.defaultValue&&(e.value[t]=e.schema.defaultValue),this.key=this.name+"@"+Date.now()}get isScalar(){return!0}get isListItem(){return!0}set value(e){this.parent.value[this.index]=e}get value(){return this.parent.value[this.index]}getInputType(){return De(this.name,this.schema)}}function We({label:t,required:r,children:n}){return e(g,{label:t,required:r,children:n})}function He({children:t}){return e("p",{className:"mt-2 text-sm text-gray-500",children:t})}function Ge({children:t}){return e("p",{className:"mt-2 text-sm text-red-600",children:t})}const Xe="text-pink-500 dark:text-pink-400",Ze="text-purple-500 dark:text-purple-400",Ye="text-blue-500 dark:text-blue-400",Je={code:"bg-gray-100 dark:bg-slate-800 whitespace-pre-wrap p-4 rounded-lg font-mono",comma:Xe,assign:Xe,startObject:Xe,endObject:Xe,startArray:Xe,endArray:Xe,boolean:Ze,null:Ze,key:Ye,index:Ye,string:"text-orange-500 dark:text-orange-400",number:"text-green-500 dark:text-green-400"};class Qe{renderer;parent;key;indent;result=[];constructor(e,t,r,n){this.renderer=e,this.parent=t,this.key=r,this.indent=n}get classMap(){return this.renderer.classMap}writeKey(e){const t=typeof e;"string"===t?(this.result.length>0&&this.result.push(`<span class='${this.classMap.comma}'>,\n</span>`),this.indent&&this.result.push(this.indent),this.result.push(`<span class="${this.classMap.key}">"${e}"</span><span class='${this.classMap.assign}'>: </span>`)):"number"===t&&(this.result.length>0&&this.result.push(`<span class='${this.classMap.comma}'>,\n</span>`),this.indent&&this.result.push(this.indent))}pushValue(e,t){if(this.writeKey(e),null===t)this.result.push(`<span class='${this.classMap.null}'>null</span>`);else if(t instanceof Qe)this.result.push(t.renderStart()+t.renderValue()+t.renderEnd());else{let e;const r=typeof t;"string"===r?(t=(t=`"${t}"`).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),e=this.classMap.string):"number"===r?e=this.classMap.number:"boolean"===r&&(e=this.classMap.boolean),this.result.push(`<span class='${e}'>${t}</span>`)}}renderValue(){return this.result.join("")}}class et extends Qe{constructor(e,t,r,n){super(e,t,r,n)}renderStart(){return`<span class='${this.classMap.startObject}'>{\n</span>`}renderEnd(){const e=this.result.length>0?"\n":"";return`<span class='${this.classMap.endObject}'>${e}${this.parent?.indent||""}}</span>`}}class tt extends Qe{constructor(e,t,r,n){super(e,t,r,n)}renderStart(){return`<span class='${this.classMap.startArray}'>[\n</span>`}renderEnd(){const e=this.result.length>0?"\n":"";return`<span class='${this.classMap.endArray}'>${e}${this.parent?.indent||""}]</span>`}}class rt{classMap;tab;stack=[];block=new et(this,void 0,"","");constructor(e=Je,t=" "){this.classMap=e,this.tab=t}onStartObject(e){const t=new et(this,this.block,e,this.block.indent+this.tab);this.stack.push(this.block),this.block=t}onEndObject(){const e=this.block;this.block=this.stack.pop(),this.block.pushValue(e.key,e)}onStartIteration(e){const t=new tt(this,this.block,e,this.block.indent+this.tab);this.stack.push(this.block),this.block=t}onEndIteration(){const e=this.block;this.block=this.stack.pop(),this.block.pushValue(e.key,e)}onValue(e,t){this.block.pushValue(e,t)}}function nt({data:t,className:r,classMap:n}){const[s,i]=d();return a((()=>{i(function(t,r,n){const s=new rt(r);(new K).walk(t,s);const i=s.block.renderValue();return e("div",{className:n,dangerouslySetInnerHTML:{__html:`<div class='${s.classMap.code}' style='overflow-x: scroll'>${i}</div>`}})}(t,n,r))}),[t]),s}function st({value:t}){return e("div",{className:"flex flex-col gap-4",children:Object.entries(t).map((([t,r])=>e(ot,{name:t,value:r},t)))})}function it({name:t}){return e("div",{className:"text-md font-semibold",children:Le(t)})}function at({children:t,className:r}){return e("div",{className:V("flex flex-col gap-4 py-2 pl-4 border-l-4 border-l-solid border-l-slate-100 dark:border-l-slate-600",r),children:t})}function ot({name:r,value:n}){const s=ht(n);switch(s.type){case dt.Inline:return t("div",{className:"w-full flex gap-2",children:[e(it,{name:r+":"}),e("p",{children:s.value})]});case dt.Paragraph:return t("div",{children:[e(it,{name:r}),e("p",{children:s.value})]});case dt.Prose:return t("div",{className:"prose dark:prose-invert",children:[e(it,{name:r}),e("div",{className:"vprose dark:prose-invert",children:s.value})]});case dt.Array:return e(lt,{name:r,value:n});case dt.Object:return t("div",{children:[e(it,{name:r}),e(at,{className:"mt-2",children:Object.entries(n).map((([t,r])=>e(ot,{name:t,value:r},t)))})]})}}function lt({name:r,value:n}){const s=n.join(" ").length,i=s/n.length,a="string"==typeof n[0]&&(s<80||s<400&&i<32),o=n.length>9;return t("div",a?{className:"flex gap-2 flex-wrap",children:[r&&e(it,{name:r+":"}),n.map(((t,r)=>e(v,{children:String(t)},r)))]}:{children:[r&&e(it,{name:r}),e("div",{className:"flex flex-col gap-2",children:n.map(((t,r)=>e(ct,{index:r,value:t,useBullet:o},r)))})]})}function ct({index:r,value:n,useBullet:s}){const i=s?e("span",{className:"text-xl",children:"•"}):t("span",{children:[r+1,"."]}),a=ht(n);let o;switch(a.type){case dt.Object:o=e(at,{children:Object.entries(n).map((([t,r])=>e(ot,{name:t,value:r},t)))});break;case dt.Array:o=e(lt,{value:n});break;case dt.Prose:o=e("div",{className:"prose dark:prose-invert",children:a.value});break;default:o=e("div",{children:a.value})}return t("div",{className:"flex gap-4 hover:bg-slate-50 dark:hover:bg-slate-800 py-2 pr-2 pl-4",children:[e("div",{className:"font-semibold text-gray-600 dark:text-gray-400",children:i}),e("div",{children:o})]})}var dt;function ht(e){if(null==e)return{value:"-",type:dt.Inline};if(Array.isArray(e))return{value:e,type:dt.Array};const t=typeof e;if("string"===t){const t=e.length;let r;return t<80?r=dt.Inline:t>400?r=dt.Prose:(r=dt.Paragraph,e=e.replace(/(?:\n\n)+/g,"\n\n")),{type:r,value:e}}return"number"===t||"boolean"===t?{value:String(e),type:dt.Inline}:{value:e,type:dt.Object}}function ut({value:t,viewCode:r=!1}){return t?e("div",{className:"relative w-full",children:r?e(nt,{data:t}):e(st,{value:t})}):e("pre",{className:"whitespace-pre-wrap",children:"No Data to display"})}function pt(){return e=>{H(e,"html",((e,t,r)=>{if(e.value&&/<!--[\s\S]*?-->/.test(e.value)&&r&&"number"==typeof t&&r.children)return r.children.splice(t,1),[G,t]}))}}function mt({children:t,components:r,remarkPlugins:n=[],removeComments:s=!0}){const i=[W,...n];return s&&i.push(pt),e(B,{remarkPlugins:i,components:r,children:t})}!function(e){e[e.Inline=0]="Inline",e[e.Paragraph=1]="Paragraph",e[e.Prose=2]="Prose",e[e.Array=3]="Array",e[e.Object=4]="Object"}(dt||(dt={}));const ft=l(void 0);function gt(){return c(ft)}const yt=Symbol("__SLOT_NAME");function vt(e,t){const r=[];return h.forEach(e,(e=>{!function(e,t,r){let n;u(e)&&(n=e.type[yt])?r[n]=e:t.push(e)}(e,r,t)})),r.length>1?r:r[0]}function bt(e,t){t[yt]=e}function xt(e){return e?"boolean"==typeof e?{enabled:e}:e:{enabled:!1}}function wt(t){const r={};if(vt(t.children,r),!r.content)throw new Error("Popover must provide a content slot");const n=r.trigger?.props,s=r.content.props;return e(Nt,{...t,trigger:n,content:s})}function Nt({middleware:r,offset:n,trigger:s,dismiss:i=!0,content:a,placement:o,strategy:l,zIndex:c=40}){const[h,u]=d(!1),p=J({open:h,placement:o,strategy:l,onOpenChange:u,middleware:r||[X(n||4),Z(),Y()],whileElementsMounted:Q}),{floatingStyles:m,refs:{setReference:f,setFloating:g},context:y}=p,v=ee(y,xt(i)),b=te(y,xt(!(x=s)||x.hover||x.click?x?.click:{enabled:!0}));var x;const w=re(y,xt(function(e){return!0===e?.hover?{enabled:!0,handleClose:oe({blockPointerEvents:!0}),restMs:0}:e?.hover}(s))),{getReferenceProps:N,getFloatingProps:k}=ne([v,b,w]),{isMounted:C,styles:j}=se(y,a.transition);return t(ft.Provider,{value:{...p,close:()=>u(!1)},children:[s&&e("div",{className:V(s.className,"inline-block"),ref:f,...N(),children:s.children}),e(ie,{children:C&&e("div",{ref:g,style:{...m,zIndex:c},...k(),children:e(ae,{context:y,children:e("div",{className:V(a.className,"bg-popover rounded-md text-popover-foreground max-w-md"),style:j,children:a.children})})})})]})}function kt(e){return null}function Ct(e){return null}function jt({percent:t}){return e("div",{className:"w-full bg-gray-200 rounded-full h-2.5 dark:bg-gray-700",children:e("div",{className:"bg-blue-600 h-2.5 rounded-full",style:{width:`${t}%`}})})}function St({className:r,properties:n}){return e(b,{className:r,children:e("tbody",{children:n.map((r=>t("tr",{children:[t("td",{className:"w-1/3 font-semibold gap-2",children:[e("span",{children:r.name}),r.description&&e(x,{description:r.description,placement:"top",children:e(I,{className:"size-3 ml-2 text-muted-foreground"})})]}),e("td",{className:"w-2/3",children:r.value??"undefined"})]},r.name)))})})}var Ot;function At(e,t){let r="any"===t.name?void 0:t.isNullable?[t.name,"null"]:t.name;if(t.isArray)if(e.type="array",e.properties=void 0,!e.items||Array.isArray(e.items))e.items={type:r,properties:t.isObject?{}:void 0};else{const n=e.items;n.type=r,t.isObject&&!n.properties&&(n.properties={})}else e.type=r,e.items=void 0,t.isObject?e.properties||(e.properties={}):e.properties=void 0}function Pt(e){let t,r=!1,n=!1;const s=e.type;if(Array.isArray(s))for(const e of s)"null"===e?r=!0:t||(t=e);else t=s;t||(t="any"),"array"===t&&(n=!0,t=function(e){if(!e)return"any";let t;t=Array.isArray(e)?$t(e[0].type):$t(e.type);"array"!==t&&"null"!==t||(t="any");return t}(e.items));let i=t;switch(e.editor||e.format){case"textarea":i="text";break;case"media":i="media";break;case"document":i="document"}return{isNullable:r,isArray:n,isObject:"object"===t,name:i}}function $t(e){return e?Array.isArray(e)?e.find((e=>"null"!==e))||"any":e:"any"}bt("trigger",kt),bt("content",Ct),wt.Trigger=kt,wt.Content=Ct,function(e){e.string="string",e.number="number",e.integer="integer",e.boolean="boolean",e.object="object",e.any="any",e.text="text",e.media="media",e.document="document"}(Ot||(Ot={}));let Tt=0;class Et{source;onChange=()=>{};schema;root;constructor(e,t){this.schema=e?"string"==typeof e?JSON.parse(e):e:{title:t,type:"object",properties:{}},this.schema.properties||(this.schema.properties={}),this.root=new It("",this.schema,this),this.root.loadChildren()}get isEmpty(){return!this.root.children||0===this.root.children.length}get children(){return this.root.children}reload(){return this.root=new It("",this.schema,this),this.root.loadChildren(),this.onChange?.(this),this}withSource(e,t){return this.source={uri:t,name:e},this}withChangeListener(e){return this.onChange=e,this}replaceSchema(e){this.schema=e||{title:this.schema.title,type:"object",properties:{}},this.reload()}clone(){const e=new Et(this.schema);return e.source=this.source,this.onChange&&e.withChangeListener(this.onChange),e}}class It{schema;loader;parent;name;isRequired=!1;type;children;constructor(e,t,r,n){if(this.schema=t,this.loader=r,this.parent=n,this.name=e,this.type=Pt(t),this.parent){let t=this.parent._getPropertiesSchema().required;this.isRequired=!(!t||!Array.isArray(t))&&t.includes(e)}}get title(){return this.schema.title}set title(e){this.schema.title=e}get description(){return this.schema.description}set description(e){this.schema.description=e}get isParent(){return this.type.isObject}get isNew(){return!!this.schema.isNew}set isNew(e){e?this.schema.isNew=!0:delete this.schema.isNew}resetIsNew(){const e=this.isNew;return this.isNew=!1,e}getNameSignature(){return`${this.name}${this.isRequired?"":"?"}`}getTypeSignature(){return`${this.type.name}${this.type.isArray?"[]":""}${this.type.isNullable?"?":""}`}getSignature(){return`${this.getNameSignature()}: ${this.getTypeSignature()}`}reloadTree(){this.loader.reload()}loadChildren(){this.children=[],this.schema.items&&this.schema.items.properties?this._loadChildren(this.schema.items.properties):this.schema.properties&&this._loadChildren(this.schema.properties)}_loadChildren(e){for(const t of Object.keys(e)){const r=e[t],n=new It(t,r,this.loader,this);this.children.push(n),n.isParent&&n.loadChildren()}}_getPropertiesSchema(){return this.type.isArray&&this.type.isObject?this.schema.items:this.schema}findAvailableChildName(e){const t=this._getPropertiesSchema().properties||{};let r;do{r=e+ ++Tt}while(t[r]);return r}addChild(e,t,r=!1){if(!this.type.isObject)throw new Error("Cannot add child to a non object node");this.children||(this.children=[]);const n=function(e,t,r,n=!1){if("object"!==e.type)throw new Error("Cannot add property to a non-object schema");e.properties||(e.properties={});const s={};return At(s,r),e.properties[t]=s,n&&(Array.isArray(e.required)?function(e,t){e.includes(t)||e.push(t)}(e.required,t):e.required=[t]),s}(this._getPropertiesSchema(),e,t,r),s=new It(e,n,this.loader,this);return this.children.push(s),s}remove(){if(this.parent&&this.parent.type.isObject){return function(e,t){e.properties&&(delete e.properties[t],Array.isArray(e.required)&&(e.required=e.required.filter((e=>e!==t))))}(this.parent._getPropertiesSchema(),this.name),this.parent.children&&(this.parent.children=this.parent.children.filter((e=>e.name!==this.name))),!0}return!1}update(e){let t=!1;null!=e.name&&this.name!==e.name&&(this.parent&&function(e,t,r){if(e.properties){const n=e.properties,s={};for(const e of Object.keys(n)){const i=n[e];e===t?s[r]=i:s[e]=i}e.properties=s}e.required&&(e.required=e.required.map((e=>e===t?r:e)))}(this.parent._getPropertiesSchema(),this.name,e.name),this.name=e.name,t=!0),null!=e.isRequired&&this.isRequired!==e.isRequired&&(this.parent&&function(e,t,r){if(Array.isArray(e.required)){const n=e.required.indexOf(t);r?n<0&&e.required.push(t):n>-1&&e.required.splice(n,1)}else r&&(e.required=[t])}(this.parent._getPropertiesSchema(),this.name,e.isRequired),this.isRequired=e.isRequired,t=!0);let r=e.type?.name;"any"===r&&(r=void 0);const n=r!==this.schema.type;return e.type&&(At(this.schema,e.type),this.type=e.type,this.type.isObject?this.children||(this.children=[]):this.children=void 0,t=!0),this.schema.editor&&null===e.editor?(this.schema.editor=void 0,this.schema.format=void 0,t=!0):e.editor?(this.schema.editor=e.editor,this.schema.format=e.editor,t=!0):n&&(this.schema.editor=void 0,this.schema.format=void 0,t=!0),e.description!==this.description&&(this.description=e.description,t=!0),t}getUpdateFromNameAndTypeSignature(e,t){let r=e.trim(),n=!0;r.endsWith("?")&&(r=r.substring(0,r.length-1).trim(),n=!1);const s=function(e){let t=!1,r=!1;(e=e.trim()).endsWith("?")&&(r=!0,e=e.substring(0,e.length-1).trim()),e.endsWith("[]")&&(t=!0,e=e.substring(0,e.length-2).trim());const n=Ot[e];if(!n)throw new Error(`Unknown type "${e}"`);return{name:n,isArray:t,isNullable:r,isObject:n===Ot.object}}(t);let i;return"text"===s.name?(s.name=Ot.string,i="textarea"):"media"===s.name?(s.name=Ot.any,i="media"):"document"===s.name?(s.name=Ot.any,i="document"):i=null,{name:r,type:s,isRequired:n,editor:i}}updateFromNameAndTypeSignature(e,t){return this.update(this.getUpdateFromNameAndTypeSignature(e,t))}updateFromSignature(e){const t=(e=e.trim()).indexOf(":");if(t<0)throw new Error("Expecting a name and a type separated by a colon");const r=e.substring(0,t),n=e.substring(t+1);return this.updateFromNameAndTypeSignature(r,n)}}function qt(e){return{name:e.getNameSignature(),type:e.getTypeSignature(),description:e.description}}const Mt=function(){const e=Object.values(Ot),t=[...e];for(const r of e)t.push(r+"[]");return e.sort(),t}();function Lt({value:r,onChange:n,onCancel:s,onSave:i}){const[a,o]=d(!1);if(!r)return null;return t("div",{className:"flex items-center",children:[e("div",{className:"flex-1",children:e(Dt,{value:r.name,onChange:e=>{n({...r,name:e})},onCancel:s,onSave:i})}),e("div",{className:"px-1 font-semibold",children:":"}),e("div",{className:"flex-1",children:e(zt,{value:r.type,onChange:e=>{n({...r,type:e})},onCancel:s,onSave:i})}),t("div",{children:[e(y,{variant:"ghost",size:"xs",onClick:()=>o(!0),title:"Edit description",children:e(q,{className:"size-4"})}),e(Ft,{value:r.description,isOpen:a,onClose:e=>{void 0!==e&&"string"==typeof e&&n({...r,description:e},!0),o(!1)}})]})]})}function Dt({value:t,onChange:r,onCancel:n,onSave:s}){const o=i(null);a((()=>{o.current?.focus()}),[]);return e("input",{onKeyUp:e=>{switch(e.key){case"Enter":s?.();break;case"Escape":n?.()}},ref:o,value:t,onChange:e=>{r(e.target.value)},className:f.INPUT_UNSTYLED,style:{fontSize:"inherit",width:"",display:"inline"}})}function zt({value:t,onChange:r,onCancel:n,onSave:s}){return e(w,{className:f.INPUT_UNSTYLED,options:Mt,value:t||"",onBlur:()=>{s?.()},onChange:r,onKeyDown:(e,t)=>{t||("Enter"===e.key?s?.():"Escape"===e.key&&n?.())},popupClass:"schema-type-suggest-popup z-90"})}function Ft({value:r,isOpen:n,onClose:s}){return t(N,{isOpen:n,onClose:s,children:[e(k,{children:"Edit description"}),e(Rt,{value:r,onSave:s})]})}function Rt({value:n,onSave:s}){const o=i(null),[l,c]=d(n||"");return a((()=>{o.current&&o.current.focus()}),[o.current]),t(r,{children:[e(C,{className:"h-max",children:e("textarea",{ref:o,className:"dark:bg-gray-800 w-full h-full dark:text-white",value:l,onChange:e=>c(e.target.value)})}),e(j,{children:e(y,{onClick:()=>s(l),children:"Save Changes"})})]})}function _t({value:r}){return r?t("div",{className:"w-full flex items-baseline",children:[e("div",{children:r.name||""}),e("div",{className:"ml-2 text-sm text-muted",children:r.type||""})]}):null}function Vt(e){const[t,r]=d(new Et(e||{type:"object",properties:{}}).withChangeListener((e=>{r(e.clone())})));return t}const Ut="block text-sm sm:leading-6 rounded-md border-0 py-1.5 px-4",Kt=`${Ut} hover:shadow-xs hover:ring-1 hover:ring-inset hover:ring-ring`,Bt=`${Ut} shadow-xs ring-1 ring-inset ring-ring`;function Wt({value:r,onChange:n,onDelete:s,outlineOnHover:i=!1,editOnClick:a=!0,placeholder:o,viewer:l,editor:c,skipClickOutside:h,isEditing:u=!1,readonly:p=!1,onValidate:m}){const{on:f,off:g,isOn:y}=S(u),[v,b]=d();return t("div",{className:"",children:[y&&!p?e(Gt,{value:r,onSave:e=>{if(m){const t=m(e);if(t)return void b(t);b(void 0)}n(e)&&g()},onCancel:g,editor:c,skipClickOutside:e=>!!h&&h(e)}):e(Ht,{value:r,onEdit:f,viewer:l,placeholder:o,outlineOnHover:i,editOnClick:a,onDelete:s,readonly:p}),v&&e("div",{className:"text-red-500 text-sm",children:v})]})}function Ht({viewer:r,value:n,onEdit:s,editOnClick:i,outlineOnHover:a,placeholder:o,onDelete:l,readonly:c}){const d="invisible group-hover:visible";return t("div",{tabIndex:0,onKeyUp:e=>{"Enter"===e.key&&s()},onClick:()=>{i&&s()},className:V("flex justify-start items-center group",a?Kt:Ut,{"cursor-pointer":i}),children:[e(r,{value:n,placeholder:o}),t("div",{className:"ml-auto flex space-x-2",children:[!c&&l&&e(y,{variant:"ghost",size:"sm",className:d,onClick:l,children:e(E,{className:"size-4"})}),c?null:e(y,{variant:"ghost",size:"sm",className:d,onClick:s,children:e(M,{className:"size-4"})})]})]})}function Gt({editor:t,value:r,onSave:n,onCancel:s,skipClickOutside:a}){const[o,l]=d(r),c=i(r),[h,u]=d(null),p=()=>{n(c.current)},m=O(p,a);return e("div",{ref:m,children:e("div",{className:Bt,children:e("div",{className:"w-full",onClick:e=>e.stopPropagation(),children:e(t,{value:o,onChange:(e,t=!1)=>{l(e),c.current=e,t&&(h&&clearTimeout(h),u(setTimeout((()=>{n(e)}),500)))},onSave:p,onCancel:s})})})})}function Xt(e){const t=e.target;return!(!t.closest||!t.closest(".schema-type-suggest-popup"))}function Zt({schema:r,readonly:n=!1}){return t("ul",{className:"",children:[r.children.map((e=>Yt(e,n))),n?null:e(rr,{parent:r.root})]})}function Yt(t,r){return t.isParent?e(Qt,{property:t,readonly:r},t.name):e(Jt,{node:t,readonly:r},t.name)}function Jt({node:t,readonly:r}){return e("li",{children:e(tr,{property:t,readonly:r})})}function Qt({property:r,readonly:n}){const[s,i]=d(!0);return t("li",{children:[t("div",{className:"flex items-center w-full",children:[e("button",{onClick:()=>i(!s),children:e(s?L:D,{className:"size-4"})}),e("div",{className:"flex-1",children:e(tr,{property:r,readonly:n})})]}),s&&t("ul",{className:"ml-4 border-l border-gray-400 border-dashed",children:[(r.children||[]).map((e=>Yt(e,n))),n?null:e(rr,{parent:r})]})]})}function er(e){return e?/^[a-zA-Z0-9_]+[?]?$/.test(e)?void 0:"Only letters, numbers, underscores or question mark are allowed (a-zA-Z0-9_?)":"Name is required"}function tr({property:t,readonly:r}){const n=A(),s=t.resetIsNew(),i=qt(t);return e(Wt,{value:i,onChange:e=>{try{e.description&&"string"!=typeof e.description&&(e.description=void 0);const r=t.getUpdateFromNameAndTypeSignature(e.name,e.type);t.update({...r,description:e.description})&&t.reloadTree()}catch(e){return n({status:"error",title:"Invalid property declaration",description:e.message,duration:9e3}),!1}return!0},onDelete:()=>{t.remove(),t.reloadTree()},editor:Lt,viewer:_t,outlineOnHover:!0,isEditing:s,skipClickOutside:Xt,readonly:r,onValidate:e=>er(e.name)})}function rr({parent:r}){return t(y,{variant:"ghost",onClick:()=>{const e=r.findAvailableChildName("new_property_");r.addChild(e,{isObject:!1,isArray:!1,isNullable:!1,name:Ot.string},!0).isNew=!0,r.reloadTree()},children:[e(T,{className:"size-4"}),"Add property"]})}function nr({content:t,...r}){const n=i(null);return a((()=>{if(!n.current)return;const e=(new DOMParser).parseFromString(t,"image/svg+xml").querySelector("svg");if(!e)return console.warn("SvgIcon: No <svg> element found in provided string"),void(n.current.innerHTML="");r&&Object.entries(r).forEach((([t,r])=>{if(null==r)return;const n="className"===t?"class":t;e.setAttribute(n,String(r))})),n.current.innerHTML="",n.current.appendChild(e)}),[t,r]),e("span",{ref:n})}function sr(t){return r=>e(nr,{content:t,...r})}function ir({onDrop:r,message:n,buttonLabel:s="Upload Files",allowFolders:a=!0,className:o=""}){const[l,c]=d(!1),h=i(null),u=i(null);return t("div",{className:`flex flex-col items-center justify-center py-12 border-2 rounded-lg transition-colors ${l?"border-color-primary bg-color-primary/10":"border-dashed border-color-border"} ${o}`,onDragOver:e=>{e.preventDefault(),e.dataTransfer.types.includes("Files")&&c(!0)},onDragLeave:e=>{e.preventDefault(),u.current&&!u.current.contains(e.relatedTarget)&&c(!1)},onDrop:async e=>{if(e.preventDefault(),c(!1),e.dataTransfer.items&&e.dataTransfer.items.length>0){const t=Array.from(e.dataTransfer.items),n=[],s=new Set,i=async e=>{if(e.isFile){const t=await new Promise((t=>{e.file((r=>{Object.defineProperty(r,"webkitRelativePath",{writable:!0,value:e.fullPath.substring(1)}),t(r)}))}));!t.name.startsWith(".")&&t.size>0&&n.push(t);const r=e.fullPath.substring(1).split("/").slice(0,-1).join("/");r&&s.add(r)}else if(e.isDirectory){const t=e.createReader(),r=await new Promise((e=>{t.readEntries((t=>{e(t)}))}));await Promise.all(r.map(i));const n=e.fullPath.substring(1);n&&s.add(n)}};try{if(await Promise.all(t.map((e=>{const t=e.webkitGetAsEntry?e.webkitGetAsEntry():e;return t?i(t):Promise.resolve()}))),n.length>0){const e=new Set(Array.from(s).map((e=>e.split("/")[0])).filter(Boolean)).size,t=n.length;let i="";i=e>0?1===e?`Preparing to upload 1 folder with ${t} files...`:`Preparing to upload ${e} folders with ${t} files...`:`Preparing to upload ${t} file${1===t?"":"s"}...`,r(n,{count:n.length,message:i})}}catch(t){console.error("Error processing dropped files:",t);const n=Array.from(e.dataTransfer.files);n.length>0&&r(n)}}else if(e.dataTransfer.files&&e.dataTransfer.files.length>0){const t=Array.from(e.dataTransfer.files);r(t)}},children:[e(z,{className:"h-12 w-12 mb-3 transition-colors "+(l?"text-primary":"text-muted/50")}),e("p",{className:"text-color-muted-foreground",children:n}),t("div",{className:"mt-4 text-center",children:[t("div",{className:"text-sm text-muted mb-2",children:["Drag and drop files",a?" or folders":""," here, or"]}),t(y,{onClick:()=>{h.current&&h.current.click()},children:[e(z,{className:"h-4 w-4 mr-2"}),s]}),e("input",{type:"file",ref:h,onChange:e=>{if(e.target.files&&e.target.files.length>0){const t=Array.from(e.target.files);if(t.some((e=>e.webkitRelativePath&&e.webkitRelativePath.includes("/")))){const e=new Set(t.map((e=>e.webkitRelativePath?.split("/")[0])).filter(Boolean)).size,n=t.length,s=1===e?`Preparing to upload 1 folder with ${n} files...`:`Preparing to upload ${e} folders with ${n} files...`,i={count:t.length,message:s};r(t,i)}else{const e={count:t.length,message:`Preparing to upload ${t.length} file${1===t.length?"":"s"}...`};r(t,e)}}},multiple:!0,webkitdirectory:a?"":void 0,directory:a?"":void 0,className:"hidden"})]})]})}function ar({title:r,count:n,icon:s=e(F,{className:"h-4 w-4 text-green-500"}),items:i}){const[a,o]=d(!1);return t("div",{className:"border border-color-border rounded-md overflow-hidden",children:[t("div",{className:"flex items-center justify-between p-3 bg-color-muted/10 cursor-pointer",onClick:()=>o(!a),children:[t("div",{className:"flex items-center",children:[e("span",{className:"mr-2",children:s}),e("span",{className:"font-medium",children:r}),e("span",{className:"ml-2 px-2 py-0.5 bg-color-muted/20 rounded-full text-xs",children:n})]}),e("button",{className:"text-muted",children:e("svg",{className:"h-5 w-5 transition-transform "+(a?"transform rotate-180":""),fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})})]}),a&&e("div",{className:"p-3 border-t border-color-border max-h-48 overflow-y-auto",children:i.length>0?e("ul",{className:"space-y-1",children:i.map(((t,r)=>e("li",{className:"text-sm py-1 px-2 rounded hover:bg-color-muted/10",children:t},r)))}):e("div",{className:"text-sm text-muted py-2",children:"No items to display"})})]})}function or({files:r,className:n="",location:s,collection:i}){const a=r.filter((e=>"success"===e.status)),o=r.filter((e=>"updated"===e.status)),l=r.filter((e=>"skipped"===e.status)),c=r.filter((e=>"failed"===e.status)),d=a.length,h=o.length,u=l.length,p=c.length,m=r.length;return t("div",{className:`flex flex-col py-2 ${n}`,children:[t("div",{className:"flex items-center mb-4",children:[e("div",{className:"size-8 mr-4 rounded-full bg-success/10 flex items-center justify-center",children:e(F,{className:"size-4 text-success"})}),e("div",{children:t("p",{className:"text-muted",children:[m," file",1!==m?"s":""," processed",i?` in collection '${i}'`:"",s?` in folder '${s}'`:""]})})]}),t("div",{className:"space-y-3 mt-2",children:[d>0&&e(ar,{title:"Successfully Uploaded",count:d,icon:e(F,{className:"h-4 w-4 text-green-500"}),items:a.map((e=>e.name))}),h>0&&e(ar,{title:"Successfully Updated",count:h,icon:e(F,{className:"h-4 w-4 text-blue-500"}),items:o.map((e=>e.name))}),u>0&&e(ar,{title:"Skipped (Already Existed)",count:u,icon:e(R,{className:"h-4 w-4 text-amber-500"}),items:l.map((e=>e.name))}),p>0&&e(ar,{title:"Failed to Upload",count:p,icon:e(_,{className:"h-4 w-4 text-red-500"}),items:c.map((e=>e.name))})]})]})}const lr="#text",cr="#comment",dr="#cdata",hr="DECLARATION_TAG",ur={tagColor:"#d43900",textColor:"#333",attributeKeyColor:"#2a7ab0",attributeValueColor:"#008000",separatorColor:"#333",commentColor:"#aaa",cdataColor:"#1d781d",fontFamily:"monospace"},pr=l({theme:ur,collapsible:!1,indentSize:2}),mr=()=>c(pr),fr=new he({preserveOrder:!0,ignoreAttributes:!1,attributeNamePrefix:"",allowBooleanAttributes:!0,commentPropName:cr,cdataPropName:dr,parseTagValue:!1});function gr(r){const{indentation:n,children:s,isInline:i}=r,{theme:a}=mr();return t("div",{style:{color:a.cdataColor},children:[e("span",{children:`${n}<![CDATA[`}),s,e("span",{children:`${i?"":n}]]>`})]})}function yr(t){const{collapsible:r,theme:n}=mr(),{collapsed:s}=t;return r?e("span",{style:{position:"relative"},children:e("span",{style:{position:"absolute",right:"0",border:0,padding:0,background:"none"},children:e(vr,{fill:n.separatorColor,style:{transform:`rotate(${s?0:90}deg)`,transition:"transform 0.2s"}})})}):null}function vr({...t}){return e("svg",{width:"16px",height:"16px",viewBox:"0 0 24 24",...t,children:e("path",{d:"M9 17.898C9 18.972 10.2649 19.546 11.0731 18.8388L17.3838 13.3169C18.1806 12.6197 18.1806 11.3801 17.3838 10.6829L11.0731 5.16108C10.2649 4.45388 9 5.02785 9 6.1018V17.898Z"})})}function br(e){const{collapsible:t,initialCollapsedDepth:r}=mr(),[n,s]=d((()=>!(le(r)||!t)&&e>=r));return a((()=>{s(!(le(r)||!t)&&e>=r)}),[r,e,t]),{collapsed:n,buttonProps:t?{onClick:()=>s((e=>!e)),role:"button",style:{cursor:"pointer"}}:{}}}function xr(r){const{indentation:n,children:s,isInline:i,level:a}=r,{theme:o}=mr(),{collapsed:l,buttonProps:c}=br(a);return t("div",{style:{color:o.commentColor},children:[t("span",{...c,children:[e("span",{children:n}),e(yr,{collapsed:l}),e("span",{children:"\x3c!-- "})]}),!l&&s,l&&"...",e("span",{children:`${i||l?" ":n}--\x3e`})]})}function wr(r){const{attributes:n}=r,{theme:s}=mr();return n?e("span",{children:Object.entries(n).map((([r,n])=>t("span",{children:[e("span",{style:{color:s.attributeKeyColor},children:` ${r}`}),e("span",{style:{color:s.separatorColor},children:"="}),e("span",{style:{color:s.attributeValueColor},children:`"${n}"`})]},`attribute-${r}`)))}):null}function Nr(r){const{indentation:n,tagKey:s,attributes:i}=r,{theme:a}=mr();return t("div",{children:[e("span",{style:{color:a.separatorColor},children:`${n}<?`}),e("span",{style:{color:a.tagColor},children:`${s.slice(1)}`}),e(wr,{attributes:i}),e("span",{style:{color:a.separatorColor},children:"?>"})]})}function kr(e){return"string"==typeof e&&e.includes("\n")}function Cr(e){const t=e[":@"],r=ce(e,":@"),[[n,s]]=Object.entries(r),i=function(e){switch(e){case lr:case dr:case cr:return e;default:return e.startsWith("?")?hr:"TAG"}}(n);return{attributes:t,tagKey:n,subElements:s,type:i}}function jr(e){return!!e&&Object.keys(e).length>0}function Sr(n){const{indentation:s,tagKey:i,attributes:a,children:o,isInline:l,hasChildren:c,level:d}=n,{collapsed:h,buttonProps:u}=br(d),{theme:p}=mr();return t("div",{children:[t("span",{...u,children:[e("span",{children:s}),e(yr,{collapsed:h}),e("span",{style:{color:p.separatorColor},children:"<"}),e("span",{style:{color:p.tagColor},children:`${i}`}),!h&&e(wr,{attributes:a}),h&&jr(a)&&" ...",e("span",{style:{color:p.separatorColor},children:c?">":" />"})]}),c&&t(r,{children:[!h&&o,h&&"...",e("span",{style:{color:p.separatorColor},children:`${l||h?"":s}</`}),e("span",{style:{color:p.tagColor},children:`${i}`}),e("span",{style:{color:p.separatorColor},children:">"})]})]})}function Or(t){const{hasSiblings:r,text:n,indentation:s,isText:i}=t,{theme:a}=mr(),o=i?{color:a.textColor}:void 0;return kr(n)||r?e("div",{style:o,children:n.split("\n").filter((e=>!!e.trim())).map(((t,r)=>e("div",{children:`${s}${t.trim()}`},`${r}`)))}):e("span",{style:o,children:n})}function Ar(t){const{elements:n,level:s=0,isText:i=!0}=t,{indentSize:a}=mr();return Array.isArray(n)&&0!==n.length?e(r,{children:n.map(((t,r)=>{const{tagKey:o,attributes:l,subElements:c,type:d}=Cr(t),h=n.length>1,u=function(e,t){return new Array(t*e+1).join(" ")}(a,s),p=`${s}-${r}`,m=function(e){return"string"!=typeof e&&1===e.length&&lr in e[0]&&!kr(e[0][lr])}(c);switch(d){case lr:return e(Or,{text:c,indentation:u,hasSiblings:h,isText:i},p);case cr:return e(xr,{isInline:m,indentation:u,level:s,children:e(Ar,{elements:c,level:s+1,isText:!1})},p);case dr:return e(gr,{indentation:u,isInline:m,children:e(Ar,{elements:c,level:s+1,isText:!1})},p);case hr:return e(Nr,{indentation:u,tagKey:o,attributes:l},p);default:return e(Sr,{indentation:u,tagKey:o,attributes:l,isInline:m,hasChildren:c.length>0,level:s,children:e(Ar,{elements:c,level:s+1})},p)}}))}):null}function Pr(){return e("div",{children:"Invalid XML!"})}function $r(t){const{theme:r,xml:n,collapsible:s=!1,indentSize:i=2,invalidXml:l,initalCollapsedDepth:c,initialCollapsedDepth:h}=t,[u,p]=d((()=>({...ur,...r}))),{json:m,valid:f}=function(e){return o((()=>{try{if(!ue.validate(e))throw new Error("Invalid XML!");const t=fr.parse(e);if("string"==typeof e&&e.trim().length>0&&0===t.length)throw new Error("Invalid XML!");return{json:t,valid:!0}}catch(e){return{json:null,valid:!1,errorMessage:`Fail to parse: ${e.message}`}}}),[e])}(n),g=o((()=>({theme:u,collapsible:s,indentSize:i,initialCollapsedDepth:h??c})),[u,s,i,c,h]);return a((()=>{p((e=>{const t={...ur,...r};return de(t,e)?e:t}))}),[r]),f?e(pr.Provider,{value:g,children:e("div",{className:"rxv-container",style:{whiteSpace:"pre-wrap",fontFamily:u.fontFamily,overflowWrap:"break-word"},children:e(Ar,{elements:m})})}):l||e(Pr,{})}export{Me as ArrayPropertySchema,ge as CodeMirrorEditor,ir as DropZone,me as EditorApi,ve as FieldSetContextProvider,je as Form,xe as FormContext,ke as FormContextProvider,Ge as FormError,He as FormHelper,We as FormLabel,Oe as GeneratedForm,Ce as Input,nt as JSONCode,ut as JSONDisplay,st as JSONView,Ke as ManageObjectEntry,Ue as ManagedListProperty,Re as ManagedObject,Fe as ManagedObjectBase,_e as ManagedObjectProperty,Ve as ManagedProperty,Be as ManagedScalarEntry,Et as ManagedSchema,mt as MarkdownRenderer,ze as Node,wt as Popover,ft as PopoverContext,jt as Progress,St as PropertiesView,Lt as PropertyEditor,Dt as PropertyNameEditor,qe as PropertySchema,_t as PropertyViewer,Pe as ScalarField,Ie as Schema,Zt as SchemaEditor,It as SchemaNode,nr as SvgIcon,ar as UploadResultCategory,or as UploadSummary,$r as XMLViewer,Le as computeTitleFromName,sr as createSvgIcon,qt as getEditableSchemaProperty,be as useFieldSet,Ne as useForm,gt as usePopoverContext,Vt as useSchema,er as validatePropertyName};
|
|
1
|
+
import{jsx as e,jsxs as t,Fragment as r}from"react/jsx-runtime";import n from"debounce";import s,{useRef as i,useEffect as a,useMemo as o,createContext as l,useContext as c,useState as d,Children as h,isValidElement as u}from"react";import{EditorView as p}from"@codemirror/view";import{useSafeLayoutEffect as m,Styles as f,FormItem as g,Button as y,DotBadge as v,Table as b,VTooltip as x,VSelectBox as w,VModal as N,VModalTitle as k,ModalBody as C,ModalFooter as j,useFlag as S,useClickOutside as O,useToast as A}from"@vertesia/ui/core";import{Text as P,EditorState as $}from"@codemirror/state";import{Plus as T,Trash2 as E,Info as I,AlignLeft as q,SquarePen as M,ChevronDown as L,ChevronRight as D,UploadIcon as z,CheckCircleIcon as F,AlertCircleIcon as R,XCircleIcon as _}from"lucide-react";import V from"clsx";import U from"ajv";import{ObjectWalker as K}from"@vertesia/json";import B from"react-markdown";import W from"remark-gfm";import{visit as H,SKIP as G}from"unist-util-visit";import{offset as X,shift as Z,flip as Y}from"@floating-ui/dom";import{useFloating as J,autoUpdate as Q,useDismiss as ee,useClick as te,useHover as re,useInteractions as ne,useTransitionStyles as se,FloatingPortal as ie,FloatingFocusManager as ae,safePolygon as oe}from"@floating-ui/react";import{isNil as le,omit as ce,isEqual as de}from"lodash-es";import{XMLParser as he,XMLValidator as ue}from"fast-xml-parser";let pe=null;class me{editor;constructor(e){this.editor=e}setValue(e){this.editor.dispatch({changes:{from:0,to:this.editor.state.doc.length,insert:e||""}})}getValue(){return this.editor.state.doc.toString()}}const fe=[p.theme({"&":{fontSize:"14px",fontFamily:"monospace"},".cm-content":{fontFamily:"inherit"},".cm-scroller":{fontFamily:"inherit"},".cm-gutters":{backgroundColor:"transparent",color:"#ddd"},".cm-focused":{outline:"none"},".cm-cursor":{borderLeft:"2px solid #808080",borderLeftColor:"#808080",animation:"blink 1.2s step-start infinite"},"@keyframes blink":{"50%":{opacity:0}}}),p.lineWrapping];function ge({onChange:t,value:r,className:s,editorRef:l,extensions:c,debounceTimeout:d=0}){const h=i(null),u=i(void 0);a((()=>{if(t)return u.current=d>0?n(t,d):t,()=>{u.current=void 0}}),[t,d]);const f=o((()=>e("div",{ref:h,className:s})),[s]);return m((()=>{if(h.current){let t=[...fe,(e=e=>{u.current?.(e)},p.updateListener.of((t=>{t.docChanged&&e(t)})))];Array.isArray(c)?t=t.concat(c):c&&t.push(c);const n=((e="",t=[])=>{const r="string"==typeof e?P.of(e.split("\n")):e;return pe?pe.doc.toString()!==r.toString()&&(pe=$.create({doc:r,extensions:t})):pe=$.create({doc:r,extensions:t}),pe})(r,t),s=new p({state:n,parent:h.current}),i=new me(s);return l&&(l.current=i),()=>{s.destroy(),l&&(l.current=void 0)}}var e}),[f,c]),f}const ye=l(void 0),ve=ye.Provider;function be(){const e=c(ye);if(!e)throw new Error("useFieldSet must be used within a Form or FieldSet element");return e}class xe{object;components;disabled;constructor(e,t={},r=!1){this.object=e,this.components=t,this.disabled=r}}const we=l(void 0);function Ne(){const e=c(we);if(!e)throw new Error("useForm must be used within a Form element");return e}const ke=we.Provider,Ce=s.forwardRef((({object:t,type:r="text",onChange:n,...s},i)=>{const[a,o]=d(null!=t.value?String(t.value):""),[l,c]=d(t.schema.isBoolean&&!0===t.value);s.className?s.className=V(f.INPUT,s.className):s.className=f.INPUT;const h=e=>{s.disabled||(o(e.target.value),t.schema.isBoolean?(t.value=e.target.checked,c(t.value)):t.value=e.target.value,n&&n(e))};return"textarea"===r?e("textarea",{ref:i,...s,value:a,onChange:h}):e("input","checkbox"===r?{ref:i,...s,type:"checkbox",checked:l,onChange:h,className:"form-check-input"}:{ref:i,...s,type:r,value:a,onChange:h})}));function je({object:t,components:r,onSubmit:n,children:s,onChange:i,disabled:a}){return t.observer=i,e(ke,{value:new xe(t,r||{},a??!1),children:e("form",{className:"w-full",onSubmit:e=>{e.stopPropagation(),e.preventDefault(),n&&n(t.value)},children:s})})}function Se(){const t=Ne();return e("div",{className:"flex flex-col gap-4 w-full",children:t.object.properties.map(Ae)})}function Oe({children:r,...n}){return t(je,{...n,children:[e(Se,{}),r]})}function Ae(t){return t.isList?e(Te,{object:t},t.name):t.isObject?e($e,{object:t},t.name):e(Pe,{object:t},t.name)}function Pe({object:t,editor:r,inline:n=!1}){r||(r=t.schema.editor);const{components:s,disabled:i}=Ne(),a=r&&s[r]||Ce,o=t.getInputType();"checkbox"===o&&(n=!0);const l=e=>{if(i)return;const{value:r}=e.target;t.value=t.schema.isNumber?parseFloat(r):r};return t.isListItem?e(a,{object:t,type:o,onChange:l}):e(g,{label:t.title,required:t.schema.isRequired,description:t.schema.description,className:V("flex",n?"flex-row items-center":"flex-col"),children:e(a,{object:t,type:o,onChange:l})})}function $e({object:r}){return t("div",{className:"flex flex-col gap-4 my-4 py-2 pl-4 border-l-4 border-l-solid border-l-slate-100 dark:border-l-slate-600",children:[!r.isListItem&&e("div",{className:"text-gray-900 dark:text-gray-200 font-semibold",children:r.title}),r.properties.map(Ae)]})}function Te({object:r}){const[n,s]=d(r.value||[]),{disabled:i}=Ne();return t("div",{className:"flex flex-col gap-4 my-4 py-2 pl-4 border-l-4 border-l-solid border-l-slate-100 darK:border-l-slate-600",children:[!r.isListItem&&e("div",{className:"text-gray-900 dark:text-gray-200 font-semibold",children:r.title}),r.items.map(((t,a)=>e(Ee,{object:t,list:r,onDelete:()=>(e=>{i||(r.remove(e),s([...r.value]))})(a),disabled:i},`${a}-${n[a]??""}`))),e("div",{children:t(y,{variant:"secondary",onClick:()=>{i||(r.add(),s([...r.value]))},disabled:i,children:[e(T,{className:"size-6"})," Add"]})})]})}function Ee({list:r,object:n,onDelete:s,disabled:i}){return t("div",{className:"flex gap-2 w-full",children:[e("div",{className:"flex-1",children:(a=n,o=r.schema.arraySchema.editor,a.isList?e(Te,{object:a}):a.isObject?e($e,{object:a}):e(Pe,{object:a,editor:o}))}),e(y,{variant:"secondary",onClick:s,disabled:i,children:e(E,{className:"size-4"})})]});var a,o}class Ie{schema;properties={};_validator;constructor(e){this.schema=e||{type:"object",properties:{}},this.load()}get validator(){if(!this._validator){const e=new U({allErrors:!0,strict:!1});this._validator=e.compile(this.schema)}return this._validator}load(){if(this.schema.properties){const e=this.schema.properties;Object.keys(e).forEach((t=>{this.loadProperty(t,e[t])}))}}hasProperties(){return Object.keys(this.properties).length>0}get title(){return this.schema.title||this.schema.name}get description(){return this.schema.description}loadProperty(e,t){let r;return r="array"===t.type?new Me(this,e,t):new qe(this,e,t),this.properties[e]=r,r}get type(){return this.schema.type}validate(e){return this.validator(e)?null:this.validator.errors||[]}addProperty(e,t,r=!1){"object"!==this.schema.type&&(this.schema.type="object"),this.schema.properties||(this.schema.properties={});const n="string"==typeof t?"object"===(s=t)?{type:"object",properties:{}}:"array"===s?{type:"array",items:{}}:{type:s}:t;var s;const i=this.loadProperty(e,n);return this.schema.properties[i.name]=i.schema,r&&(i.isRequired=!0),i}removeProperty(e){this.schema.properties&&(delete this.schema.properties[e],Array.isArray(this.schema.required)&&(this.schema.required=this.schema.required.filter((t=>t!==e)))),delete this.properties[e]}getProperty(e){return this.properties[e]}get editor(){return this.schema.editor}}class qe extends Ie{parent;name;constructor(e,t,r){if(super(r),this.parent=e,this.name=t,"array"===r.type)throw new Error("Array property must be instantiated using ArrayPropertySchema");"object"!==r.type||r.properties||(r.properties={})}get isMulti(){return!1}get isReadOnly(){return!!this.schema.readOnly}set isReadOnly(e){this.schema.readOnly=e}get defaultValue(){return this.schema.default}set defaultValue(e){this.schema.default=e}get enum(){return this.schema.enum}set enum(e){this.schema.enum=e}get isRequired(){const e=this.parent.schema.required;return!!e&&e.includes(this.name)}set isRequired(e){let t=Array.isArray(this.parent.schema.required)?this.parent.schema.required:[];t=e?t.concat(this.name):t.filter((e=>e!==this.name)),this.parent.schema.required=t}get type(){return this.schema.type}set type(e){this.schema.type!==e&&(this.schema.type=e,"object"!==e&&(this.properties={},this.schema.properties=void 0))}remove(){this.parent.removeProperty(this.name)}get isBoolean(){return"boolean"===this.type}get isString(){return"string"===this.type}get isNumber(){return"number"===this.type||"integer"===this.type}get isObject(){return"object"===this.type}}class Me extends qe{arraySchema;constructor(e,t,r){super(e,t,function(e){if("array"!==e.type)throw new Error("Expecting an array schema");if(e.items){if(Array.isArray(e.items))throw new Error("Tuple arrays are not supported")}else e.items={};return e.items}(r)),this.arraySchema=r}get isMulti(){return!0}}function Le(e){return(e=e.replace(/_/g," ").replace(/([a-z0-9])&([A-Z])/g,"$1 $2"))[0].toUpperCase()+e.slice(1)}function De(e,t){if(t.editor)return t.editor;switch(t.type){case"number":case"integer":return"number";case"boolean":return"checkbox";default:return"text"}}class ze{parent;schema;name;observer;constructor(e,t,r){this.parent=e,this.schema=t,this.name=r}get isRoot(){return!this.parent}get root(){return this.parent?this.parent.root:this}get path(){return this.parent?this.parent.path.concat(this.name):[]}get isScalar(){return!1}get isListItem(){return!1}get isObject(){return!1}get isList(){return!1}get title(){return this.schema.title||Le(this.name)}onChange(e){this.observer&&!1===this.observer(this)||this.parent&&this.parent.onChange(e)}}class Fe extends ze{constructor(e,t,r){super(e,t,r)}get isObject(){return!0}getProperty(e){const t=this.schema.properties[e];return t.isMulti?new Ue(this,t,this.getOrInitArrayProperty(e)):t.isObject?new _e(this,t,t.name,this.getOrInitObjectProperty(e)):new Ve(this,t)}getOrInitObjectProperty(e){let t=this.value[e];return t||(this.value[e]=t={}),t}getOrInitArrayProperty(e){let t=this.value[e];return t||(this.value[e]=t=[]),t}setPropertyValue(e,t){return this.value[e]!==t&&(this.value[e]=t,!0)}getPropertyValue(e){return this.value[e]}get properties(){const e=[];for(const t of Object.values(this.schema.properties))t.isMulti?e.push(new Ue(this,t,this.getOrInitArrayProperty(t.name))):t.isObject?e.push(new _e(this,t,t.name,this.getOrInitObjectProperty(t.name))):e.push(new Ve(this,t));return e}[Symbol.iterator](){return this.properties[Symbol.iterator]()}}class Re extends Fe{value;constructor(e,t={}){super(null,e instanceof Ie?e:new Ie(e),"#root"),this.value=t}}class _e extends Fe{value;constructor(e,t,r,n){super(e,t,r),this.value=n}}class Ve extends ze{constructor(e,t){super(e,t,t.name),void 0===e.value[this.name]&&void 0!==t.defaultValue&&(e.value[this.name]=t.defaultValue)}get isScalar(){return!0}set value(e){this.parent.setPropertyValue(this.name,e)&&this.onChange(this)}get value(){return this.parent.getPropertyValue(this.name)}getInputType(){return De(this.name,this.schema)}}class Ue extends ze{value;items=[];constructor(e,t,r){super(e,t,t.name),this.value=r;for(const e of this.value)this.add()}get isList(){return!0}newItem(e){return this.schema.isObject?new Ke(this,e):new Be(this,e)}add(){const e=this.newItem(this.items.length);return this.items.push(e),e}remove(e){const t=this.value;if(e>=0&&e<this.items.length){this.items.splice(e,1);for(let e=0,t=this.items.length;e<t;e++){const t=this.items[e];t.index=e,t.name=String(e)}}Array.isArray(t)&&e>=0&&e<t.length&&(t.splice(e,1),this.onChange(this))}[Symbol.iterator](){return this.items[Symbol.iterator]()}item(e){if(e<0||e>=this.value.length)return;const t=this.value[e];return this.schema.isObject?new _e(this,this.schema,String(e),t):new Be(this,e)}trim(){for(;void 0===this.items[this.items.length-1];)this.items.pop()}}class Ke extends Fe{index;key;constructor(e,t){super(e,e.schema,String(t)),this.index=t,void 0===e.value[t]&&(e.value[t]={}),this.key=this.name+"@"+Date.now()}get isListItem(){return!0}set value(e){this.parent.value[this.index]=e}get value(){return this.parent.value[this.index]}}class Be extends ze{index;key;constructor(e,t){super(e,e.schema,String(t)),this.index=t,void 0===e.value[t]&&void 0!==e.schema.defaultValue&&(e.value[t]=e.schema.defaultValue),this.key=this.name+"@"+Date.now()}get isScalar(){return!0}get isListItem(){return!0}set value(e){this.parent.value[this.index]=e}get value(){return this.parent.value[this.index]}getInputType(){return De(this.name,this.schema)}}function We({label:t,required:r,children:n}){return e(g,{label:t,required:r,children:n})}function He({children:t}){return e("p",{className:"mt-2 text-sm text-gray-500",children:t})}function Ge({children:t}){return e("p",{className:"mt-2 text-sm text-red-600",children:t})}const Xe="text-pink-500 dark:text-pink-400",Ze="text-purple-500 dark:text-purple-400",Ye="text-blue-500 dark:text-blue-400",Je={code:"bg-gray-100 dark:bg-slate-800 whitespace-pre-wrap p-4 rounded-lg font-mono",comma:Xe,assign:Xe,startObject:Xe,endObject:Xe,startArray:Xe,endArray:Xe,boolean:Ze,null:Ze,key:Ye,index:Ye,string:"text-orange-500 dark:text-orange-400",number:"text-green-500 dark:text-green-400"};class Qe{renderer;parent;key;indent;result=[];constructor(e,t,r,n){this.renderer=e,this.parent=t,this.key=r,this.indent=n}get classMap(){return this.renderer.classMap}writeKey(e){const t=typeof e;"string"===t?(this.result.length>0&&this.result.push(`<span class='${this.classMap.comma}'>,\n</span>`),this.indent&&this.result.push(this.indent),this.result.push(`<span class="${this.classMap.key}">"${e}"</span><span class='${this.classMap.assign}'>: </span>`)):"number"===t&&(this.result.length>0&&this.result.push(`<span class='${this.classMap.comma}'>,\n</span>`),this.indent&&this.result.push(this.indent))}pushValue(e,t){if(this.writeKey(e),null===t)this.result.push(`<span class='${this.classMap.null}'>null</span>`);else if(t instanceof Qe)this.result.push(t.renderStart()+t.renderValue()+t.renderEnd());else{let e;const r=typeof t;"string"===r?(t=(t=`"${t}"`).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),e=this.classMap.string):"number"===r?e=this.classMap.number:"boolean"===r&&(e=this.classMap.boolean),this.result.push(`<span class='${e}'>${t}</span>`)}}renderValue(){return this.result.join("")}}class et extends Qe{constructor(e,t,r,n){super(e,t,r,n)}renderStart(){return`<span class='${this.classMap.startObject}'>{\n</span>`}renderEnd(){const e=this.result.length>0?"\n":"";return`<span class='${this.classMap.endObject}'>${e}${this.parent?.indent||""}}</span>`}}class tt extends Qe{constructor(e,t,r,n){super(e,t,r,n)}renderStart(){return`<span class='${this.classMap.startArray}'>[\n</span>`}renderEnd(){const e=this.result.length>0?"\n":"";return`<span class='${this.classMap.endArray}'>${e}${this.parent?.indent||""}]</span>`}}class rt{classMap;tab;stack=[];block=new et(this,void 0,"","");constructor(e=Je,t=" "){this.classMap=e,this.tab=t}onStartObject(e){const t=new et(this,this.block,e,this.block.indent+this.tab);this.stack.push(this.block),this.block=t}onEndObject(){const e=this.block;this.block=this.stack.pop(),this.block.pushValue(e.key,e)}onStartIteration(e){const t=new tt(this,this.block,e,this.block.indent+this.tab);this.stack.push(this.block),this.block=t}onEndIteration(){const e=this.block;this.block=this.stack.pop(),this.block.pushValue(e.key,e)}onValue(e,t){this.block.pushValue(e,t)}}function nt({data:t,className:r,classMap:n}){const[s,i]=d();return a((()=>{i(function(t,r,n){const s=new rt(r);(new K).walk(t,s);const i=s.block.renderValue();return e("div",{className:n,dangerouslySetInnerHTML:{__html:`<div class='${s.classMap.code}' style='overflow-x: scroll'>${i}</div>`}})}(t,n,r))}),[t]),s}function st({value:t}){return e("div",{className:"flex flex-col gap-4",children:Object.entries(t).map((([t,r])=>e(ot,{name:t,value:r},t)))})}function it({name:t}){return e("div",{className:"text-md font-semibold",children:Le(t)})}function at({children:t,className:r}){return e("div",{className:V("flex flex-col gap-4 py-2 pl-4 border-l-4 border-l-solid border-l-slate-100 dark:border-l-slate-600",r),children:t})}function ot({name:r,value:n}){const s=ht(n);switch(s.type){case dt.Inline:return t("div",{className:"w-full flex gap-2",children:[e(it,{name:r+":"}),e("p",{children:s.value})]});case dt.Paragraph:return t("div",{children:[e(it,{name:r}),e("p",{children:s.value})]});case dt.Prose:return t("div",{className:"prose dark:prose-invert",children:[e(it,{name:r}),e("div",{className:"vprose dark:prose-invert",children:s.value})]});case dt.Array:return e(lt,{name:r,value:n});case dt.Object:return t("div",{children:[e(it,{name:r}),e(at,{className:"mt-2",children:Object.entries(n).map((([t,r])=>e(ot,{name:t,value:r},t)))})]})}}function lt({name:r,value:n}){const s=n.join(" ").length,i=s/n.length,a="string"==typeof n[0]&&(s<80||s<400&&i<32),o=n.length>9;return t("div",a?{className:"flex gap-2 flex-wrap",children:[r&&e(it,{name:r+":"}),n.map(((t,r)=>e(v,{children:String(t)},r)))]}:{children:[r&&e(it,{name:r}),e("div",{className:"flex flex-col gap-2",children:n.map(((t,r)=>e(ct,{index:r,value:t,useBullet:o},r)))})]})}function ct({index:r,value:n,useBullet:s}){const i=s?e("span",{className:"text-xl",children:"•"}):t("span",{children:[r+1,"."]}),a=ht(n);let o;switch(a.type){case dt.Object:o=e(at,{children:Object.entries(n).map((([t,r])=>e(ot,{name:t,value:r},t)))});break;case dt.Array:o=e(lt,{value:n});break;case dt.Prose:o=e("div",{className:"prose dark:prose-invert",children:a.value});break;default:o=e("div",{children:a.value})}return t("div",{className:"flex gap-4 hover:bg-slate-50 dark:hover:bg-slate-800 py-2 pr-2 pl-4",children:[e("div",{className:"font-semibold text-gray-600 dark:text-gray-400",children:i}),e("div",{children:o})]})}var dt;function ht(e){if(null==e)return{value:"-",type:dt.Inline};if(Array.isArray(e))return{value:e,type:dt.Array};const t=typeof e;if("string"===t){const t=e.length;let r;return t<80?r=dt.Inline:t>400?r=dt.Prose:(r=dt.Paragraph,e=e.replace(/(?:\n\n)+/g,"\n\n")),{type:r,value:e}}return"number"===t||"boolean"===t?{value:String(e),type:dt.Inline}:{value:e,type:dt.Object}}function ut({value:t,viewCode:r=!1}){return t?e("div",{className:"relative w-full",children:r?e(nt,{data:t}):e(st,{value:t})}):e("pre",{className:"whitespace-pre-wrap",children:"No Data to display"})}function pt(){return e=>{H(e,"html",((e,t,r)=>{if(e.value&&/<!--[\s\S]*?-->/.test(e.value)&&r&&"number"==typeof t&&r.children)return r.children.splice(t,1),[G,t]}))}}function mt({children:t,components:r,remarkPlugins:n=[],removeComments:s=!0}){const i=[W,...n];return s&&i.push(pt),e(B,{remarkPlugins:i,components:r,children:t})}!function(e){e[e.Inline=0]="Inline",e[e.Paragraph=1]="Paragraph",e[e.Prose=2]="Prose",e[e.Array=3]="Array",e[e.Object=4]="Object"}(dt||(dt={}));const ft=l(void 0);function gt(){return c(ft)}const yt=Symbol("__SLOT_NAME");function vt(e,t){const r=[];return h.forEach(e,(e=>{!function(e,t,r){let n;u(e)&&(n=e.type[yt])?r[n]=e:t.push(e)}(e,r,t)})),r.length>1?r:r[0]}function bt(e,t){t[yt]=e}function xt(e){return e?"boolean"==typeof e?{enabled:e}:e:{enabled:!1}}function wt(t){const r={};if(vt(t.children,r),!r.content)throw new Error("Popover must provide a content slot");const n=r.trigger?.props,s=r.content.props;return e(Nt,{...t,trigger:n,content:s})}function Nt({middleware:r,offset:n,trigger:s,dismiss:i=!0,content:a,placement:o,strategy:l,zIndex:c=40}){const[h,u]=d(!1),p=J({open:h,placement:o,strategy:l,onOpenChange:u,middleware:r||[X(n||4),Z(),Y()],whileElementsMounted:Q}),{floatingStyles:m,refs:{setReference:f,setFloating:g},context:y}=p,v=ee(y,xt(i)),b=te(y,xt(!(x=s)||x.hover||x.click?x?.click:{enabled:!0}));var x;const w=re(y,xt(function(e){return!0===e?.hover?{enabled:!0,handleClose:oe({blockPointerEvents:!0}),restMs:0}:e?.hover}(s))),{getReferenceProps:N,getFloatingProps:k}=ne([v,b,w]),{isMounted:C,styles:j}=se(y,a.transition);return t(ft.Provider,{value:{...p,close:()=>u(!1)},children:[s&&e("div",{className:V(s.className,"inline-block"),ref:f,...N(),children:s.children}),e(ie,{children:C&&e("div",{ref:g,style:{...m,zIndex:c},...k(),children:e(ae,{context:y,children:e("div",{className:V(a.className,"bg-popover rounded-md text-popover-foreground max-w-md"),style:j,children:a.children})})})})]})}function kt(e){return null}function Ct(e){return null}function jt({percent:t}){return e("div",{className:"w-full bg-gray-200 rounded-full h-2.5 dark:bg-gray-700",children:e("div",{className:"bg-blue-600 h-2.5 rounded-full",style:{width:`${t}%`}})})}function St({className:r,properties:n}){return e(b,{className:r,children:e("tbody",{children:n.map((r=>t("tr",{children:[t("td",{className:"w-1/3 font-semibold gap-2",children:[e("span",{children:r.name}),r.description&&e(x,{description:r.description,placement:"top",children:e(I,{className:"size-3 ml-2 text-muted-foreground"})})]}),e("td",{className:"w-2/3",children:r.value??"undefined"})]},r.name)))})})}var Ot;function At(e,t){let r="any"===t.name?void 0:t.isNullable?[t.name,"null"]:t.name;if(t.isArray)if(e.type="array",e.properties=void 0,!e.items||Array.isArray(e.items))e.items={type:r,properties:t.isObject?{}:void 0};else{const n=e.items;n.type=r,t.isObject&&!n.properties&&(n.properties={})}else e.type=r,e.items=void 0,t.isObject?e.properties||(e.properties={}):e.properties=void 0}function Pt(e){let t,r=!1,n=!1;const s=e.type;if(Array.isArray(s))for(const e of s)"null"===e?r=!0:t||(t=e);else t=s;t||(t="any"),"array"===t&&(n=!0,t=function(e){if(!e)return"any";let t;t=Array.isArray(e)?$t(e[0].type):$t(e.type);"array"!==t&&"null"!==t||(t="any");return t}(e.items));let i=t;switch(e.editor){case"textarea":i="text";break;case"media":i="media";break;case"document":i="document"}return{isNullable:r,isArray:n,isObject:"object"===t,name:i}}function $t(e){return e?Array.isArray(e)?e.find((e=>"null"!==e))||"any":e:"any"}bt("trigger",kt),bt("content",Ct),wt.Trigger=kt,wt.Content=Ct,function(e){e.string="string",e.number="number",e.integer="integer",e.boolean="boolean",e.object="object",e.any="any",e.text="text",e.media="media",e.document="document"}(Ot||(Ot={}));let Tt=0;class Et{source;onChange=()=>{};schema;root;constructor(e,t){this.schema=e?"string"==typeof e?JSON.parse(e):e:{title:t,type:"object",properties:{}},this.schema.properties||(this.schema.properties={}),this.root=new It("",this.schema,this),this.root.loadChildren()}get isEmpty(){return!this.root.children||0===this.root.children.length}get children(){return this.root.children}reload(){return this.root=new It("",this.schema,this),this.root.loadChildren(),this.onChange?.(this),this}withSource(e,t){return this.source={uri:t,name:e},this}withChangeListener(e){return this.onChange=e,this}replaceSchema(e){this.schema=e||{title:this.schema.title,type:"object",properties:{}},this.reload()}clone(){const e=new Et(this.schema);return e.source=this.source,this.onChange&&e.withChangeListener(this.onChange),e}}class It{schema;loader;parent;name;isRequired=!1;type;children;constructor(e,t,r,n){if(this.schema=t,this.loader=r,this.parent=n,this.name=e,this.type=Pt(t),this.parent){let t=this.parent._getPropertiesSchema().required;this.isRequired=!(!t||!Array.isArray(t))&&t.includes(e)}}get title(){return this.schema.title}set title(e){this.schema.title=e}get description(){return this.schema.description}set description(e){this.schema.description=e}get isParent(){return this.type.isObject}get isNew(){return!!this.schema.isNew}set isNew(e){e?this.schema.isNew=!0:delete this.schema.isNew}resetIsNew(){const e=this.isNew;return this.isNew=!1,e}getNameSignature(){return`${this.name}${this.isRequired?"":"?"}`}getTypeSignature(){return`${this.type.name}${this.type.isArray?"[]":""}${this.type.isNullable?"?":""}`}getSignature(){return`${this.getNameSignature()}: ${this.getTypeSignature()}`}reloadTree(){this.loader.reload()}loadChildren(){this.children=[],this.schema.items&&this.schema.items.properties?this._loadChildren(this.schema.items.properties):this.schema.properties&&this._loadChildren(this.schema.properties)}_loadChildren(e){for(const t of Object.keys(e)){const r=e[t],n=new It(t,r,this.loader,this);this.children.push(n),n.isParent&&n.loadChildren()}}_getPropertiesSchema(){return this.type.isArray&&this.type.isObject?this.schema.items:this.schema}findAvailableChildName(e){const t=this._getPropertiesSchema().properties||{};let r;do{r=e+ ++Tt}while(t[r]);return r}addChild(e,t,r=!1){if(!this.type.isObject)throw new Error("Cannot add child to a non object node");this.children||(this.children=[]);const n=function(e,t,r,n=!1){if("object"!==e.type)throw new Error("Cannot add property to a non-object schema");e.properties||(e.properties={});const s={};return At(s,r),e.properties[t]=s,n&&(Array.isArray(e.required)?function(e,t){e.includes(t)||e.push(t)}(e.required,t):e.required=[t]),s}(this._getPropertiesSchema(),e,t,r),s=new It(e,n,this.loader,this);return this.children.push(s),s}remove(){if(this.parent&&this.parent.type.isObject){return function(e,t){e.properties&&(delete e.properties[t],Array.isArray(e.required)&&(e.required=e.required.filter((e=>e!==t))))}(this.parent._getPropertiesSchema(),this.name),this.parent.children&&(this.parent.children=this.parent.children.filter((e=>e.name!==this.name))),!0}return!1}update(e){let t=!1;null!=e.name&&this.name!==e.name&&(this.parent&&function(e,t,r){if(e.properties){const n=e.properties,s={};for(const e of Object.keys(n)){const i=n[e];e===t?s[r]=i:s[e]=i}e.properties=s}e.required&&(e.required=e.required.map((e=>e===t?r:e)))}(this.parent._getPropertiesSchema(),this.name,e.name),this.name=e.name,t=!0),null!=e.isRequired&&this.isRequired!==e.isRequired&&(this.parent&&function(e,t,r){if(Array.isArray(e.required)){const n=e.required.indexOf(t);r?n<0&&e.required.push(t):n>-1&&e.required.splice(n,1)}else r&&(e.required=[t])}(this.parent._getPropertiesSchema(),this.name,e.isRequired),this.isRequired=e.isRequired,t=!0);let r=e.type?.name;"any"===r&&(r=void 0);const n=r!==this.schema.type;return e.type&&(At(this.schema,e.type),this.type=e.type,this.type.isObject?this.children||(this.children=[]):this.children=void 0,t=!0),this.schema.editor&&null===e.editor?(this.schema.editor=void 0,t=!0):e.editor?(this.schema.editor=e.editor,t=!0):n&&(this.schema.editor=void 0,t=!0),e.description!==this.description&&(this.description=e.description,t=!0),t}getUpdateFromNameAndTypeSignature(e,t){let r=e.trim(),n=!0;r.endsWith("?")&&(r=r.substring(0,r.length-1).trim(),n=!1);const s=function(e){let t=!1,r=!1;(e=e.trim()).endsWith("?")&&(r=!0,e=e.substring(0,e.length-1).trim()),e.endsWith("[]")&&(t=!0,e=e.substring(0,e.length-2).trim());const n=Ot[e];if(!n)throw new Error(`Unknown type "${e}"`);return{name:n,isArray:t,isNullable:r,isObject:n===Ot.object}}(t);let i;return"text"===s.name?(s.name=Ot.string,i="textarea"):"media"===s.name?(s.name=Ot.any,i="media"):"document"===s.name?(s.name=Ot.any,i="document"):i=null,{name:r,type:s,isRequired:n,editor:i}}updateFromNameAndTypeSignature(e,t){return this.update(this.getUpdateFromNameAndTypeSignature(e,t))}updateFromSignature(e){const t=(e=e.trim()).indexOf(":");if(t<0)throw new Error("Expecting a name and a type separated by a colon");const r=e.substring(0,t),n=e.substring(t+1);return this.updateFromNameAndTypeSignature(r,n)}}function qt(e){return{name:e.getNameSignature(),type:e.getTypeSignature(),description:e.description}}const Mt=function(){const e=Object.values(Ot),t=[...e];for(const r of e)t.push(r+"[]");return e.sort(),t}();function Lt({value:r,onChange:n,onCancel:s,onSave:i}){const[a,o]=d(!1);if(!r)return null;return t("div",{className:"flex items-center",children:[e("div",{className:"flex-1",children:e(Dt,{value:r.name,onChange:e=>{n({...r,name:e})},onCancel:s,onSave:i})}),e("div",{className:"px-1 font-semibold",children:":"}),e("div",{className:"flex-1",children:e(zt,{value:r.type,onChange:e=>{n({...r,type:e})},onCancel:s,onSave:i})}),t("div",{children:[e(y,{variant:"ghost",size:"xs",onClick:()=>o(!0),title:"Edit description",children:e(q,{className:"size-4"})}),e(Ft,{value:r.description,isOpen:a,onClose:e=>{void 0!==e&&"string"==typeof e&&n({...r,description:e},!0),o(!1)}})]})]})}function Dt({value:t,onChange:r,onCancel:n,onSave:s}){const o=i(null);a((()=>{o.current?.focus()}),[]);return e("input",{onKeyUp:e=>{switch(e.key){case"Enter":s?.();break;case"Escape":n?.()}},ref:o,value:t,onChange:e=>{r(e.target.value)},className:f.INPUT_UNSTYLED,style:{fontSize:"inherit",width:"",display:"inline"}})}function zt({value:t,onChange:r,onCancel:n,onSave:s}){return e(w,{className:f.INPUT_UNSTYLED,options:Mt,value:t||"",onBlur:()=>{s?.()},onChange:r,onKeyDown:(e,t)=>{t||("Enter"===e.key?s?.():"Escape"===e.key&&n?.())},popupClass:"schema-type-suggest-popup z-90"})}function Ft({value:r,isOpen:n,onClose:s}){return t(N,{isOpen:n,onClose:s,children:[e(k,{children:"Edit description"}),e(Rt,{value:r,onSave:s})]})}function Rt({value:n,onSave:s}){const o=i(null),[l,c]=d(n||"");return a((()=>{o.current&&o.current.focus()}),[o.current]),t(r,{children:[e(C,{className:"h-max",children:e("textarea",{ref:o,className:"dark:bg-gray-800 w-full h-full dark:text-white",value:l,onChange:e=>c(e.target.value)})}),e(j,{children:e(y,{onClick:()=>s(l),children:"Save Changes"})})]})}function _t({value:r}){return r?t("div",{className:"w-full flex items-baseline",children:[e("div",{children:r.name||""}),e("div",{className:"ml-2 text-sm text-muted",children:r.type||""})]}):null}function Vt(e){const[t,r]=d(new Et(e||{type:"object",properties:{}}).withChangeListener((e=>{r(e.clone())})));return t}const Ut="block text-sm sm:leading-6 rounded-md border-0 py-1.5 px-4",Kt=`${Ut} hover:shadow-xs hover:ring-1 hover:ring-inset hover:ring-ring`,Bt=`${Ut} shadow-xs ring-1 ring-inset ring-ring`;function Wt({value:r,onChange:n,onDelete:s,outlineOnHover:i=!1,editOnClick:a=!0,placeholder:o,viewer:l,editor:c,skipClickOutside:h,isEditing:u=!1,readonly:p=!1,onValidate:m}){const{on:f,off:g,isOn:y}=S(u),[v,b]=d();return t("div",{className:"",children:[y&&!p?e(Gt,{value:r,onSave:e=>{if(m){const t=m(e);if(t)return void b(t);b(void 0)}n(e)&&g()},onCancel:g,editor:c,skipClickOutside:e=>!!h&&h(e)}):e(Ht,{value:r,onEdit:f,viewer:l,placeholder:o,outlineOnHover:i,editOnClick:a,onDelete:s,readonly:p}),v&&e("div",{className:"text-red-500 text-sm",children:v})]})}function Ht({viewer:r,value:n,onEdit:s,editOnClick:i,outlineOnHover:a,placeholder:o,onDelete:l,readonly:c}){const d="invisible group-hover:visible";return t("div",{tabIndex:0,onKeyUp:e=>{"Enter"===e.key&&s()},onClick:()=>{i&&s()},className:V("flex justify-start items-center group",a?Kt:Ut,{"cursor-pointer":i}),children:[e(r,{value:n,placeholder:o}),t("div",{className:"ml-auto flex space-x-2",children:[!c&&l&&e(y,{variant:"ghost",size:"sm",className:d,onClick:l,children:e(E,{className:"size-4"})}),c?null:e(y,{variant:"ghost",size:"sm",className:d,onClick:s,children:e(M,{className:"size-4"})})]})]})}function Gt({editor:t,value:r,onSave:n,onCancel:s,skipClickOutside:a}){const[o,l]=d(r),c=i(r),[h,u]=d(null),p=()=>{n(c.current)},m=O(p,a);return e("div",{ref:m,children:e("div",{className:Bt,children:e("div",{className:"w-full",onClick:e=>e.stopPropagation(),children:e(t,{value:o,onChange:(e,t=!1)=>{l(e),c.current=e,t&&(h&&clearTimeout(h),u(setTimeout((()=>{n(e)}),500)))},onSave:p,onCancel:s})})})})}function Xt(e){const t=e.target;return!(!t.closest||!t.closest(".schema-type-suggest-popup"))}function Zt({schema:r,readonly:n=!1}){return t("ul",{className:"",children:[r.children.map((e=>Yt(e,n))),n?null:e(rr,{parent:r.root})]})}function Yt(t,r){return t.isParent?e(Qt,{property:t,readonly:r},t.name):e(Jt,{node:t,readonly:r},t.name)}function Jt({node:t,readonly:r}){return e("li",{children:e(tr,{property:t,readonly:r})})}function Qt({property:r,readonly:n}){const[s,i]=d(!0);return t("li",{children:[t("div",{className:"flex items-center w-full",children:[e("button",{onClick:()=>i(!s),children:e(s?L:D,{className:"size-4"})}),e("div",{className:"flex-1",children:e(tr,{property:r,readonly:n})})]}),s&&t("ul",{className:"ml-4 border-l border-gray-400 border-dashed",children:[(r.children||[]).map((e=>Yt(e,n))),n?null:e(rr,{parent:r})]})]})}function er(e){return e?/^[a-zA-Z0-9_]+[?]?$/.test(e)?void 0:"Only letters, numbers, underscores or question mark are allowed (a-zA-Z0-9_?)":"Name is required"}function tr({property:t,readonly:r}){const n=A(),s=t.resetIsNew(),i=qt(t);return e(Wt,{value:i,onChange:e=>{try{e.description&&"string"!=typeof e.description&&(e.description=void 0);const r=t.getUpdateFromNameAndTypeSignature(e.name,e.type);t.update({...r,description:e.description})&&t.reloadTree()}catch(e){return n({status:"error",title:"Invalid property declaration",description:e.message,duration:9e3}),!1}return!0},onDelete:()=>{t.remove(),t.reloadTree()},editor:Lt,viewer:_t,outlineOnHover:!0,isEditing:s,skipClickOutside:Xt,readonly:r,onValidate:e=>er(e.name)})}function rr({parent:r}){return t(y,{variant:"ghost",onClick:()=>{const e=r.findAvailableChildName("new_property_");r.addChild(e,{isObject:!1,isArray:!1,isNullable:!1,name:Ot.string},!0).isNew=!0,r.reloadTree()},children:[e(T,{className:"size-4"}),"Add property"]})}function nr({content:t,...r}){const n=i(null);return a((()=>{if(!n.current)return;const e=(new DOMParser).parseFromString(t,"image/svg+xml").querySelector("svg");if(!e)return console.warn("SvgIcon: No <svg> element found in provided string"),void(n.current.innerHTML="");r&&Object.entries(r).forEach((([t,r])=>{if(null==r)return;const n="className"===t?"class":t;e.setAttribute(n,String(r))})),n.current.innerHTML="",n.current.appendChild(e)}),[t,r]),e("span",{ref:n})}function sr(t){return r=>e(nr,{content:t,...r})}function ir({onDrop:r,message:n,buttonLabel:s="Upload Files",allowFolders:a=!0,className:o=""}){const[l,c]=d(!1),h=i(null),u=i(null);return t("div",{className:`flex flex-col items-center justify-center py-12 border-2 rounded-lg transition-colors ${l?"border-color-primary bg-color-primary/10":"border-dashed border-color-border"} ${o}`,onDragOver:e=>{e.preventDefault(),e.dataTransfer.types.includes("Files")&&c(!0)},onDragLeave:e=>{e.preventDefault(),u.current&&!u.current.contains(e.relatedTarget)&&c(!1)},onDrop:async e=>{if(e.preventDefault(),c(!1),e.dataTransfer.items&&e.dataTransfer.items.length>0){const t=Array.from(e.dataTransfer.items),n=[],s=new Set,i=async e=>{if(e.isFile){const t=await new Promise((t=>{e.file((r=>{Object.defineProperty(r,"webkitRelativePath",{writable:!0,value:e.fullPath.substring(1)}),t(r)}))}));!t.name.startsWith(".")&&t.size>0&&n.push(t);const r=e.fullPath.substring(1).split("/").slice(0,-1).join("/");r&&s.add(r)}else if(e.isDirectory){const t=e.createReader(),r=await new Promise((e=>{t.readEntries((t=>{e(t)}))}));await Promise.all(r.map(i));const n=e.fullPath.substring(1);n&&s.add(n)}};try{if(await Promise.all(t.map((e=>{const t=e.webkitGetAsEntry?e.webkitGetAsEntry():e;return t?i(t):Promise.resolve()}))),n.length>0){const e=new Set(Array.from(s).map((e=>e.split("/")[0])).filter(Boolean)).size,t=n.length;let i="";i=e>0?1===e?`Preparing to upload 1 folder with ${t} files...`:`Preparing to upload ${e} folders with ${t} files...`:`Preparing to upload ${t} file${1===t?"":"s"}...`,r(n,{count:n.length,message:i})}}catch(t){console.error("Error processing dropped files:",t);const n=Array.from(e.dataTransfer.files);n.length>0&&r(n)}}else if(e.dataTransfer.files&&e.dataTransfer.files.length>0){const t=Array.from(e.dataTransfer.files);r(t)}},children:[e(z,{className:"h-12 w-12 mb-3 transition-colors "+(l?"text-primary":"text-muted/50")}),e("p",{className:"text-color-muted-foreground",children:n}),t("div",{className:"mt-4 text-center",children:[t("div",{className:"text-sm text-muted mb-2",children:["Drag and drop files",a?" or folders":""," here, or"]}),t(y,{onClick:()=>{h.current&&h.current.click()},children:[e(z,{className:"h-4 w-4 mr-2"}),s]}),e("input",{type:"file",ref:h,onChange:e=>{if(e.target.files&&e.target.files.length>0){const t=Array.from(e.target.files);if(t.some((e=>e.webkitRelativePath&&e.webkitRelativePath.includes("/")))){const e=new Set(t.map((e=>e.webkitRelativePath?.split("/")[0])).filter(Boolean)).size,n=t.length,s=1===e?`Preparing to upload 1 folder with ${n} files...`:`Preparing to upload ${e} folders with ${n} files...`,i={count:t.length,message:s};r(t,i)}else{const e={count:t.length,message:`Preparing to upload ${t.length} file${1===t.length?"":"s"}...`};r(t,e)}}},multiple:!0,webkitdirectory:a?"":void 0,directory:a?"":void 0,className:"hidden"})]})]})}function ar({title:r,count:n,icon:s=e(F,{className:"h-4 w-4 text-green-500"}),items:i}){const[a,o]=d(!1);return t("div",{className:"border border-color-border rounded-md overflow-hidden",children:[t("div",{className:"flex items-center justify-between p-3 bg-color-muted/10 cursor-pointer",onClick:()=>o(!a),children:[t("div",{className:"flex items-center",children:[e("span",{className:"mr-2",children:s}),e("span",{className:"font-medium",children:r}),e("span",{className:"ml-2 px-2 py-0.5 bg-color-muted/20 rounded-full text-xs",children:n})]}),e("button",{className:"text-muted",children:e("svg",{className:"h-5 w-5 transition-transform "+(a?"transform rotate-180":""),fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})})]}),a&&e("div",{className:"p-3 border-t border-color-border max-h-48 overflow-y-auto",children:i.length>0?e("ul",{className:"space-y-1",children:i.map(((t,r)=>e("li",{className:"text-sm py-1 px-2 rounded hover:bg-color-muted/10",children:t},r)))}):e("div",{className:"text-sm text-muted py-2",children:"No items to display"})})]})}function or({files:r,className:n="",location:s,collection:i}){const a=r.filter((e=>"success"===e.status)),o=r.filter((e=>"updated"===e.status)),l=r.filter((e=>"skipped"===e.status)),c=r.filter((e=>"failed"===e.status)),d=a.length,h=o.length,u=l.length,p=c.length,m=r.length;return t("div",{className:`flex flex-col py-2 ${n}`,children:[t("div",{className:"flex items-center mb-4",children:[e("div",{className:"size-8 mr-4 rounded-full bg-success/10 flex items-center justify-center",children:e(F,{className:"size-4 text-success"})}),e("div",{children:t("p",{className:"text-muted",children:[m," file",1!==m?"s":""," processed",i?` in collection '${i}'`:"",s?` in folder '${s}'`:""]})})]}),t("div",{className:"space-y-3 mt-2",children:[d>0&&e(ar,{title:"Successfully Uploaded",count:d,icon:e(F,{className:"h-4 w-4 text-green-500"}),items:a.map((e=>e.name))}),h>0&&e(ar,{title:"Successfully Updated",count:h,icon:e(F,{className:"h-4 w-4 text-blue-500"}),items:o.map((e=>e.name))}),u>0&&e(ar,{title:"Skipped (Already Existed)",count:u,icon:e(R,{className:"h-4 w-4 text-amber-500"}),items:l.map((e=>e.name))}),p>0&&e(ar,{title:"Failed to Upload",count:p,icon:e(_,{className:"h-4 w-4 text-red-500"}),items:c.map((e=>e.name))})]})]})}const lr="#text",cr="#comment",dr="#cdata",hr="DECLARATION_TAG",ur={tagColor:"#d43900",textColor:"#333",attributeKeyColor:"#2a7ab0",attributeValueColor:"#008000",separatorColor:"#333",commentColor:"#aaa",cdataColor:"#1d781d",fontFamily:"monospace"},pr=l({theme:ur,collapsible:!1,indentSize:2}),mr=()=>c(pr),fr=new he({preserveOrder:!0,ignoreAttributes:!1,attributeNamePrefix:"",allowBooleanAttributes:!0,commentPropName:cr,cdataPropName:dr,parseTagValue:!1});function gr(r){const{indentation:n,children:s,isInline:i}=r,{theme:a}=mr();return t("div",{style:{color:a.cdataColor},children:[e("span",{children:`${n}<![CDATA[`}),s,e("span",{children:`${i?"":n}]]>`})]})}function yr(t){const{collapsible:r,theme:n}=mr(),{collapsed:s}=t;return r?e("span",{style:{position:"relative"},children:e("span",{style:{position:"absolute",right:"0",border:0,padding:0,background:"none"},children:e(vr,{fill:n.separatorColor,style:{transform:`rotate(${s?0:90}deg)`,transition:"transform 0.2s"}})})}):null}function vr({...t}){return e("svg",{width:"16px",height:"16px",viewBox:"0 0 24 24",...t,children:e("path",{d:"M9 17.898C9 18.972 10.2649 19.546 11.0731 18.8388L17.3838 13.3169C18.1806 12.6197 18.1806 11.3801 17.3838 10.6829L11.0731 5.16108C10.2649 4.45388 9 5.02785 9 6.1018V17.898Z"})})}function br(e){const{collapsible:t,initialCollapsedDepth:r}=mr(),[n,s]=d((()=>!(le(r)||!t)&&e>=r));return a((()=>{s(!(le(r)||!t)&&e>=r)}),[r,e,t]),{collapsed:n,buttonProps:t?{onClick:()=>s((e=>!e)),role:"button",style:{cursor:"pointer"}}:{}}}function xr(r){const{indentation:n,children:s,isInline:i,level:a}=r,{theme:o}=mr(),{collapsed:l,buttonProps:c}=br(a);return t("div",{style:{color:o.commentColor},children:[t("span",{...c,children:[e("span",{children:n}),e(yr,{collapsed:l}),e("span",{children:"\x3c!-- "})]}),!l&&s,l&&"...",e("span",{children:`${i||l?" ":n}--\x3e`})]})}function wr(r){const{attributes:n}=r,{theme:s}=mr();return n?e("span",{children:Object.entries(n).map((([r,n])=>t("span",{children:[e("span",{style:{color:s.attributeKeyColor},children:` ${r}`}),e("span",{style:{color:s.separatorColor},children:"="}),e("span",{style:{color:s.attributeValueColor},children:`"${n}"`})]},`attribute-${r}`)))}):null}function Nr(r){const{indentation:n,tagKey:s,attributes:i}=r,{theme:a}=mr();return t("div",{children:[e("span",{style:{color:a.separatorColor},children:`${n}<?`}),e("span",{style:{color:a.tagColor},children:`${s.slice(1)}`}),e(wr,{attributes:i}),e("span",{style:{color:a.separatorColor},children:"?>"})]})}function kr(e){return"string"==typeof e&&e.includes("\n")}function Cr(e){const t=e[":@"],r=ce(e,":@"),[[n,s]]=Object.entries(r),i=function(e){switch(e){case lr:case dr:case cr:return e;default:return e.startsWith("?")?hr:"TAG"}}(n);return{attributes:t,tagKey:n,subElements:s,type:i}}function jr(e){return!!e&&Object.keys(e).length>0}function Sr(n){const{indentation:s,tagKey:i,attributes:a,children:o,isInline:l,hasChildren:c,level:d}=n,{collapsed:h,buttonProps:u}=br(d),{theme:p}=mr();return t("div",{children:[t("span",{...u,children:[e("span",{children:s}),e(yr,{collapsed:h}),e("span",{style:{color:p.separatorColor},children:"<"}),e("span",{style:{color:p.tagColor},children:`${i}`}),!h&&e(wr,{attributes:a}),h&&jr(a)&&" ...",e("span",{style:{color:p.separatorColor},children:c?">":" />"})]}),c&&t(r,{children:[!h&&o,h&&"...",e("span",{style:{color:p.separatorColor},children:`${l||h?"":s}</`}),e("span",{style:{color:p.tagColor},children:`${i}`}),e("span",{style:{color:p.separatorColor},children:">"})]})]})}function Or(t){const{hasSiblings:r,text:n,indentation:s,isText:i}=t,{theme:a}=mr(),o=i?{color:a.textColor}:void 0;return kr(n)||r?e("div",{style:o,children:n.split("\n").filter((e=>!!e.trim())).map(((t,r)=>e("div",{children:`${s}${t.trim()}`},`${r}`)))}):e("span",{style:o,children:n})}function Ar(t){const{elements:n,level:s=0,isText:i=!0}=t,{indentSize:a}=mr();return Array.isArray(n)&&0!==n.length?e(r,{children:n.map(((t,r)=>{const{tagKey:o,attributes:l,subElements:c,type:d}=Cr(t),h=n.length>1,u=function(e,t){return new Array(t*e+1).join(" ")}(a,s),p=`${s}-${r}`,m=function(e){return"string"!=typeof e&&1===e.length&&lr in e[0]&&!kr(e[0][lr])}(c);switch(d){case lr:return e(Or,{text:c,indentation:u,hasSiblings:h,isText:i},p);case cr:return e(xr,{isInline:m,indentation:u,level:s,children:e(Ar,{elements:c,level:s+1,isText:!1})},p);case dr:return e(gr,{indentation:u,isInline:m,children:e(Ar,{elements:c,level:s+1,isText:!1})},p);case hr:return e(Nr,{indentation:u,tagKey:o,attributes:l},p);default:return e(Sr,{indentation:u,tagKey:o,attributes:l,isInline:m,hasChildren:c.length>0,level:s,children:e(Ar,{elements:c,level:s+1})},p)}}))}):null}function Pr(){return e("div",{children:"Invalid XML!"})}function $r(t){const{theme:r,xml:n,collapsible:s=!1,indentSize:i=2,invalidXml:l,initalCollapsedDepth:c,initialCollapsedDepth:h}=t,[u,p]=d((()=>({...ur,...r}))),{json:m,valid:f}=function(e){return o((()=>{try{if(!ue.validate(e))throw new Error("Invalid XML!");const t=fr.parse(e);if("string"==typeof e&&e.trim().length>0&&0===t.length)throw new Error("Invalid XML!");return{json:t,valid:!0}}catch(e){return{json:null,valid:!1,errorMessage:`Fail to parse: ${e.message}`}}}),[e])}(n),g=o((()=>({theme:u,collapsible:s,indentSize:i,initialCollapsedDepth:h??c})),[u,s,i,c,h]);return a((()=>{p((e=>{const t={...ur,...r};return de(t,e)?e:t}))}),[r]),f?e(pr.Provider,{value:g,children:e("div",{className:"rxv-container",style:{whiteSpace:"pre-wrap",fontFamily:u.fontFamily,overflowWrap:"break-word"},children:e(Ar,{elements:m})})}):l||e(Pr,{})}export{Me as ArrayPropertySchema,ge as CodeMirrorEditor,ir as DropZone,me as EditorApi,ve as FieldSetContextProvider,je as Form,xe as FormContext,ke as FormContextProvider,Ge as FormError,He as FormHelper,We as FormLabel,Oe as GeneratedForm,Ce as Input,nt as JSONCode,ut as JSONDisplay,st as JSONView,Ke as ManageObjectEntry,Ue as ManagedListProperty,Re as ManagedObject,Fe as ManagedObjectBase,_e as ManagedObjectProperty,Ve as ManagedProperty,Be as ManagedScalarEntry,Et as ManagedSchema,mt as MarkdownRenderer,ze as Node,wt as Popover,ft as PopoverContext,jt as Progress,St as PropertiesView,Lt as PropertyEditor,Dt as PropertyNameEditor,qe as PropertySchema,_t as PropertyViewer,Pe as ScalarField,Ie as Schema,Zt as SchemaEditor,It as SchemaNode,nr as SvgIcon,ar as UploadResultCategory,or as UploadSummary,$r as XMLViewer,Le as computeTitleFromName,sr as createSvgIcon,qt as getEditableSchemaProperty,be as useFieldSet,Ne as useForm,gt as usePopoverContext,Vt as useSchema,er as validatePropertyName};
|
|
2
2
|
//# sourceMappingURL=vertesia-ui-widgets.js.map
|