@opennsw/jsonforms-renderers 0.5.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -26,6 +26,10 @@ export declare const CategorizationLayoutRenderer: ({ uischema, schema, path, re
26
26
 
27
27
  export declare const CategorizationLayoutTester: RankedTester;
28
28
 
29
+ export declare const ComputedControl: ComponentType<OwnPropsOfControl>;
30
+
31
+ export declare const ComputedControlTester: (uischema: UISchemaElement, schema: JsonSchema, context: TesterContext) => number;
32
+
29
33
  export declare const DateControl: ({ data, handleChange, path, label, required, errors, schema, enabled, visible, }: ControlProps) => JSX.Element | null;
30
34
 
31
35
  export declare const DateControlTester: RankedTester;
@@ -88,8 +92,9 @@ export declare interface SearchService {
88
92
  query: string;
89
93
  cursor?: unknown;
90
94
  signal: AbortSignal;
95
+ params?: Record<string, unknown>;
91
96
  }): Promise<SearchResult>;
92
- resolve?(value: string): Promise<SearchOption | undefined>;
97
+ resolve?(value: string, params?: Record<string, unknown>): Promise<SearchOption | undefined>;
93
98
  }
94
99
 
95
100
  export declare function SearchServiceProvider({ children, services, }: {
@@ -1 +1 @@
1
- /*! tailwindcss v4.3.1 | MIT License | https://tailwindcss.com */@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-border-style:solid;--tw-font-weight:initial;--tw-tracking:initial;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-duration:initial;--tw-ease:initial}}}@layer theme{:root,:host{--font-sans:ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--color-red-50:oklch(97.1% .013 17.38);--color-red-300:oklch(80.8% .114 19.571);--color-blue-50:oklch(97% .014 254.604);--color-blue-400:oklch(70.7% .165 254.624);--color-blue-500:oklch(62.3% .214 259.815);--color-gray-50:oklch(98.5% .002 247.839);--color-gray-300:oklch(87.2% .01 258.338);--color-gray-500:oklch(55.1% .027 264.364);--spacing:.25rem;--font-weight-semibold:600;--tracking-wide:.025em;--radius-lg:.5rem;--ease-in-out:cubic-bezier(.4, 0, .2, 1);--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;-moz-tab-size:4;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){-webkit-appearance:button;-moz-appearance:button;appearance:button}::file-selector-button{-webkit-appearance:button;-moz-appearance:button;appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.visible{visibility:visible}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.static{position:static}.sticky{position:sticky}.container{width:100%}@media(min-width:40rem){.container{max-width:40rem}}@media(min-width:48rem){.container{max-width:48rem}}@media(min-width:64rem){.container{max-width:64rem}}@media(min-width:80rem){.container{max-width:80rem}}@media(min-width:96rem){.container{max-width:96rem}}.mt-1{margin-top:var(--spacing)}.block{display:block}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline{display:inline}.table{display:table}.transform{transform:var(--tw-rotate-x,) var(--tw-rotate-y,) var(--tw-rotate-z,) var(--tw-skew-x,) var(--tw-skew-y,)}.resize{resize:both}.rounded-lg{border-radius:var(--radius-lg)}.border{border-style:var(--tw-border-style);border-width:1px}.border-2{border-style:var(--tw-border-style);border-width:2px}.border-dashed{--tw-border-style:dashed;border-style:dashed}.border-blue-500{border-color:var(--color-blue-500)}.border-gray-300{border-color:var(--color-gray-300)}.border-red-300{border-color:var(--color-red-300)}.bg-blue-50{background-color:var(--color-blue-50)}.bg-red-50{background-color:var(--color-red-50)}.p-6{padding:calc(var(--spacing) * 6)}.text-center{text-align:center}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-wide{--tw-tracking:var(--tracking-wide);letter-spacing:var(--tracking-wide)}.text-gray-500{color:var(--color-gray-500)}.lowercase{text-transform:lowercase}.uppercase{text-transform:uppercase}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.blur{--tw-blur:blur(8px);filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.invert{--tw-invert:invert(100%);filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-all{transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.duration-200{--tw-duration:.2s;transition-duration:.2s}.ease-in-out{--tw-ease:var(--ease-in-out);transition-timing-function:var(--ease-in-out)}@media(hover:hover){.hover\:border-blue-400:hover{border-color:var(--color-blue-400)}.hover\:bg-\(--gray-3\):hover{background-color:var(--gray-3)}.hover\:bg-gray-50:hover{background-color:var(--color-gray-50)}}}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@property --tw-duration{syntax:"*";inherits:false}@property --tw-ease{syntax:"*";inherits:false}
1
+ /*! tailwindcss v4.3.1 | MIT License | https://tailwindcss.com */@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-border-style:solid;--tw-font-weight:initial;--tw-tracking:initial;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-duration:initial;--tw-ease:initial}}}@layer theme{:root,:host{--font-sans:ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--color-red-50:oklch(97.1% .013 17.38);--color-red-300:oklch(80.8% .114 19.571);--color-blue-50:oklch(97% .014 254.604);--color-blue-400:oklch(70.7% .165 254.624);--color-blue-500:oklch(62.3% .214 259.815);--color-gray-50:oklch(98.5% .002 247.839);--color-gray-300:oklch(87.2% .01 258.338);--color-gray-500:oklch(55.1% .027 264.364);--spacing:.25rem;--font-weight-semibold:600;--tracking-wide:.025em;--radius-lg:.5rem;--ease-in-out:cubic-bezier(.4, 0, .2, 1);--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;-moz-tab-size:4;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){-webkit-appearance:button;-moz-appearance:button;appearance:button}::file-selector-button{-webkit-appearance:button;-moz-appearance:button;appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.visible{visibility:visible}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.static{position:static}.sticky{position:sticky}.container{width:100%}@media(min-width:40rem){.container{max-width:40rem}}@media(min-width:48rem){.container{max-width:48rem}}@media(min-width:64rem){.container{max-width:64rem}}@media(min-width:80rem){.container{max-width:80rem}}@media(min-width:96rem){.container{max-width:96rem}}.mt-1{margin-top:var(--spacing)}.block{display:block}.contents{display:contents}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline{display:inline}.table{display:table}.transform{transform:var(--tw-rotate-x,) var(--tw-rotate-y,) var(--tw-rotate-z,) var(--tw-skew-x,) var(--tw-skew-y,)}.resize{resize:both}.rounded-lg{border-radius:var(--radius-lg)}.border{border-style:var(--tw-border-style);border-width:1px}.border-2{border-style:var(--tw-border-style);border-width:2px}.border-dashed{--tw-border-style:dashed;border-style:dashed}.border-blue-500{border-color:var(--color-blue-500)}.border-gray-300{border-color:var(--color-gray-300)}.border-red-300{border-color:var(--color-red-300)}.bg-blue-50{background-color:var(--color-blue-50)}.bg-red-50{background-color:var(--color-red-50)}.p-6{padding:calc(var(--spacing) * 6)}.text-center{text-align:center}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-wide{--tw-tracking:var(--tracking-wide);letter-spacing:var(--tracking-wide)}.text-gray-500{color:var(--color-gray-500)}.lowercase{text-transform:lowercase}.uppercase{text-transform:uppercase}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.blur{--tw-blur:blur(8px);filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.invert{--tw-invert:invert(100%);filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.filter{filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-all{transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.duration-200{--tw-duration:.2s;transition-duration:.2s}.ease-in-out{--tw-ease:var(--ease-in-out);transition-timing-function:var(--ease-in-out)}@media(hover:hover){.hover\:border-blue-400:hover{border-color:var(--color-blue-400)}.hover\:bg-\(--gray-3\):hover{background-color:var(--gray-3)}.hover\:bg-gray-50:hover{background-color:var(--color-gray-50)}}}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@property --tw-duration{syntax:"*";inherits:false}@property --tw-ease{syntax:"*";inherits:false}
@@ -1,3 +1,3 @@
1
- "use strict";var ct=Object.create;var ge=Object.defineProperty;var at=Object.getOwnPropertyDescriptor;var ut=Object.getOwnPropertyNames;var dt=Object.getPrototypeOf,xt=Object.prototype.hasOwnProperty;var ft=(e,n,r)=>n in e?ge(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r;var ht=(e,n,r,a)=>{if(n&&typeof n=="object"||typeof n=="function")for(let h of ut(n))!xt.call(e,h)&&h!==r&&ge(e,h,{get:()=>n[h],enumerable:!(a=at(n,h))||a.enumerable});return e};var ve=(e,n,r)=>(r=e!=null?ct(dt(e)):{},ht(n||!e||!e.__esModule?ge(r,"default",{value:e,enumerable:!0}):r,e));var be=(e,n,r)=>ft(e,typeof n!="symbol"?n+"":n,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),v=require("react"),y=require("@jsonforms/core"),W=require("@jsonforms/react"),o=require("@radix-ui/themes"),_=require("@radix-ui/react-icons"),pt=require("dayjs"),je=require("@e965/xlsx"),Se=v.createContext(null);function gt({children:e,onUpload:n,getDownloadUrl:r}){const a={onUpload:n,getDownloadUrl:r};return t.jsx(Se.Provider,{value:a,children:e})}function Ae(){return v.useContext(Se)}const Fe=v.createContext(null);function mt({children:e,services:n}){const r=v.useMemo(()=>n,[n]);return t.jsx(Fe.Provider,{value:r,children:e})}function Ne(e){const n=v.useContext(Fe);return!n||!e?null:n[e]??null}const ce=(e,n,r,a=void 0)=>{v.useEffect(()=>{e===!1&&r(n,a)},[e,n,r,a])},ne=(e,n)=>e?e.split(`
1
+ "use strict";var wt=Object.create;var je=Object.defineProperty;var Ct=Object.getOwnPropertyDescriptor;var Rt=Object.getOwnPropertyNames;var Et=Object.getPrototypeOf,St=Object.prototype.hasOwnProperty;var At=(e,n,r)=>n in e?je(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r;var Ft=(e,n,r,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let x of Rt(n))!St.call(e,x)&&x!==r&&je(e,x,{get:()=>n[x],enumerable:!(i=Ct(n,x))||i.enumerable});return e};var Re=(e,n,r)=>(r=e!=null?wt(Et(e)):{},Ft(n||!e||!e.__esModule?je(r,"default",{value:e,enumerable:!0}):r,e));var Ee=(e,n,r)=>At(e,typeof n!="symbol"?n+"":n,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),v=require("react"),y=require("@jsonforms/core"),B=require("@jsonforms/react"),o=require("@radix-ui/themes"),ee=require("@radix-ui/react-icons"),Ot=require("dayjs"),Se=require("@e965/xlsx"),Me=v.createContext(null);function It({children:e,onUpload:n,getDownloadUrl:r}){const i={onUpload:n,getDownloadUrl:r};return t.jsx(Me.Provider,{value:i,children:e})}function ze(){return v.useContext(Me)}const De=v.createContext(null);function Nt({children:e,services:n}){const r=v.useMemo(()=>n,[n]);return t.jsx(De.Provider,{value:r,children:e})}function Ue(e){const n=v.useContext(De);return!n||!e?null:n[e]??null}const se=(e,n,r,i=void 0)=>{v.useEffect(()=>{e===!1&&r(n,i)},[e,n,r,i])},le=(e,n)=>e?e.split(`
2
2
  `).map(r=>r.trim()==="is a required property"?`${n||"This field"} is required`:r).join(`
3
- `):"",Ie=({data:e,handleChange:n,path:r,label:a,required:h,errors:d,uischema:u,schema:c,enabled:s,visible:i=!0})=>{var g;if(ce(i,r,n),i===!1)return null;const l=d.length===0;return t.jsx(o.Box,{mb:"4",children:t.jsxs(o.Flex,{direction:"column",gap:"1",children:[t.jsxs(o.Text,{as:"label",size:"2",weight:"bold",htmlFor:r,children:[a," ",h&&t.jsx(o.Text,{color:"red",children:"*"})]}),t.jsx(o.TextField.Root,{value:e||"",onChange:p=>n(r,p.target.value),disabled:!s,placeholder:(g=u.options)==null?void 0:g.placeholder,color:l?void 0:"red",id:r}),!l&&t.jsx(o.Text,{color:"red",size:"1",children:ne(d,a)}),c.description&&t.jsx(o.Text,{size:"1",color:"gray",children:c.description})]})})},Oe=y.rankWith(1,y.isStringControl),Tt=W.withJsonFormsControlProps(Ie),Le=({data:e,handleChange:n,path:r,label:a,required:h,errors:d,uischema:u,schema:c,enabled:s,visible:i=!0})=>{var p;if(ce(i,r,n),i===!1)return null;const l=d.length===0,g=f=>{if(f===""){n(r,void 0);return}const m=Number(f);isNaN(m)||n(r,m)};return t.jsx(o.Box,{mb:"4",children:t.jsxs(o.Flex,{direction:"column",gap:"1",children:[t.jsxs(o.Text,{as:"label",size:"2",weight:"bold",htmlFor:r,children:[a," ",h&&t.jsx(o.Text,{color:"red",children:"*"})]}),t.jsx(o.TextField.Root,{type:"number",value:e??"",onChange:f=>g(f.target.value),disabled:!s,placeholder:(p=u.options)==null?void 0:p.placeholder,color:l?void 0:"red",id:r}),!l&&t.jsx(o.Text,{color:"red",size:"1",children:ne(d,a)}),c.description&&t.jsx(o.Text,{size:"1",color:"gray",children:c.description})]})})},ke=y.rankWith(2,y.or(y.isNumberControl,y.isIntegerControl)),yt=W.withJsonFormsControlProps(Le),De=({data:e,handleChange:n,path:r,label:a,required:h,errors:d,schema:u,enabled:c,visible:s=!0})=>{if(ce(s,r,n),s===!1)return null;const i=d.length===0;return t.jsxs(o.Box,{mb:"4",children:[t.jsxs(o.Flex,{gap:"2",align:"center",children:[t.jsx(o.Checkbox,{checked:!!e,onCheckedChange:l=>n(r,l===!0),disabled:!c,id:r}),t.jsxs(o.Text,{as:"label",size:"2",htmlFor:r,children:[a," ",h&&"*"]})]}),!i&&t.jsx(o.Text,{color:"red",size:"1",className:"block mt-1",children:ne(d,a)}),u.description&&t.jsx(o.Text,{size:"1",color:"gray",className:"block mt-1",children:u.description})]})},Me=y.rankWith(2,y.isBooleanControl),vt=W.withJsonFormsControlProps(De),ze=({data:e,handleChange:n,path:r,label:a,required:h,errors:d,schema:u,enabled:c,visible:s=!0})=>{if(ce(s,r,n),s===!1)return null;const i=d.length===0;let l=[];u.enum?l=u.enum.map(p=>({value:p,label:String(p)})):u.oneOf&&(l=u.oneOf.map(p=>({value:p.const,label:p.title||String(p.const)})));const g=e;return t.jsx(o.Box,{mb:"4",children:t.jsxs(o.Flex,{direction:"column",gap:"1",children:[t.jsxs(o.Text,{as:"div",size:"2",weight:"bold",children:[a," ",h&&t.jsx(o.Text,{color:"red",children:"*"})]}),t.jsx(o.RadioGroup.Root,{value:g!==void 0?String(g):"",onValueChange:p=>{const f=l.find(m=>String(m.value)===p);f&&n(r,f.value)},disabled:!c,children:t.jsx(o.Flex,{direction:"row",style:{flexWrap:"wrap",columnGap:"clamp(14px, 3vw, 36px)",rowGap:"clamp(8px, 1.6vw, 14px)"},children:l.map(p=>t.jsxs(o.Flex,{align:"center",gap:"2",style:{minWidth:"max-content"},children:[t.jsx(o.RadioGroup.Item,{value:String(p.value)}),t.jsx(o.Text,{size:"2",color:c?void 0:"gray",children:p.label})]},String(p.value)))})}),!i&&t.jsx(o.Text,{color:"red",size:"1",children:ne(d,a)}),u.description&&t.jsx(o.Text,{size:"1",color:"gray",children:u.description})]})})},Ue=(e,n,r)=>{var h;return y.or(y.isEnumControl,y.isOneOfControl)(e,n,r)&&((h=e==null?void 0:e.options)==null?void 0:h.format)==="radio"?3:-1},bt=W.withJsonFormsControlProps(ze),Be=({data:e,handleChange:n,path:r,label:a,required:h,errors:d,schema:u,uischema:c,enabled:s,visible:i=!0})=>{var f;if(ce(i,r,n),i===!1)return null;const l=d.length===0;let g=[];u.enum?g=u.enum.map(m=>({value:String(m),label:String(m)})):u.oneOf&&(g=u.oneOf.map(m=>({value:String(m.const),label:m.title||String(m.const)})));const p=e!==void 0?String(e):"";return t.jsx(o.Box,{mb:"4",children:t.jsxs(o.Flex,{direction:"column",gap:"1",children:[t.jsxs(o.Text,{as:"label",size:"2",weight:"bold",htmlFor:r,children:[a," ",h&&t.jsx(o.Text,{color:"red",children:"*"})]}),t.jsxs(o.Select.Root,{value:p,onValueChange:m=>n(r,m),disabled:!s,children:[t.jsx(o.Select.Trigger,{placeholder:((f=c.options)==null?void 0:f.placeholder)||"Select an option",color:l?void 0:"red",id:r}),t.jsx(o.Select.Content,{children:g.map(m=>t.jsx(o.Select.Item,{value:m.value,children:m.label},m.value))})]}),!l&&t.jsx(o.Text,{color:"red",size:"1",children:ne(d,a)}),u.description&&t.jsx(o.Text,{size:"1",color:"gray",children:u.description})]})})},Pe=y.rankWith(2,y.or(y.isEnumControl,y.isOneOfControl)),jt=W.withJsonFormsControlProps(Be),Ct={"small-list":{fetchOnOpen:!0,searchable:!1,paginated:!1},"large-searchable-list":{fetchOnOpen:!0,searchable:!0,paginated:!1},"large-paginated-list":{fetchOnOpen:!1,searchable:!0,paginated:!0}},Et=({data:e,handleChange:n,path:r,label:a,required:h,errors:d,enabled:u,visible:c=!0,schema:s,uischema:i})=>{var xe;const l=(s==null?void 0:s["x-search"])??{service:""},g=l.service??"",p=l.mode??"large-paginated-list",f=Ct[p],m=(f==null?void 0:f.fetchOnOpen)??!1,R=Ne(g),F=g?R?f?null:`Invalid x-search.mode "${p}". Expected "small-list", "large-searchable-list", or "large-paginated-list".`:`Search service "${g}" is not registered.`:"Search not configured.",C=u!==!1,A=!d||d.length===0,[N,S]=v.useState(!1),[D,M]=v.useState(""),[ee,z]=v.useState([]),[oe,$]=v.useState(!1),[U,G]=v.useState(!1),[te,I]=v.useState(!1),[se,H]=v.useState(null),[le,J]=v.useState(void 0),q=v.useRef(void 0),re=v.useRef(null),T=v.useRef(null),w=v.useRef(null),L=v.useRef(void 0);v.useEffect(()=>{if(!e){J(void 0),L.current=void 0;return}if(L.current===e||(L.current=e,J({id:e,name:e}),!(R!=null&&R.resolve)))return;let x=!1;return R.resolve(e).then(j=>{!x&&j&&J(j)}).catch(()=>{}),()=>{x=!0}},[e,R]);const b=v.useCallback(async(x,j=!1)=>{var Z;if(!R){H("Search service not configured.");return}(Z=T.current)==null||Z.abort();const ie=new AbortController;T.current=ie,j?I(!0):(G(!0),I(!1),H(null));try{const Q=await R.search({query:x,cursor:j?q.current:void 0,signal:ie.signal}),k=Q.options??[];z(j?it=>[...it,...k]:k),q.current=Q.nextCursor,$(((f==null?void 0:f.paginated)??!1)&&Q.nextCursor!=null)}catch{if(ie.signal.aborted)return;H("Failed to load results. Please try again.")}finally{ie.signal.aborted||(j?I(!1):G(!1))}},[R,f==null?void 0:f.paginated]);if(v.useEffect(()=>{if(!N)return;const x=j=>{w.current&&!w.current.contains(j.target)&&S(!1)};return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[N]),v.useEffect(()=>{var x;N||((x=T.current)==null||x.abort(),M(""),z([]),$(!1),H(null),G(!1),I(!1),q.current=void 0)},[N]),v.useEffect(()=>{if(!N)return;if(!D&&!m){z([]),$(!1),H(null),q.current=void 0;return}re.current&&clearTimeout(re.current);const x=D?300:0;return re.current=setTimeout(()=>{z([]),$(!1),q.current=void 0,b(D)},x),()=>{re.current&&clearTimeout(re.current)}},[D,N,m,b]),ce(c,r,n,null),c===!1)return null;const B=()=>{M(""),z([]),$(!1),H(null),q.current=void 0,S(!0)},K=x=>{n(r,x.id),J(x),L.current=x.id,S(!1)},X=x=>{x.stopPropagation(),n(r,null),J(void 0)},Y=x=>{(x.key==="Enter"||x.key===" ")&&X(x)},pe=((xe=i==null?void 0:i.options)==null?void 0:xe.placeholder)??"Select an option";return t.jsx(o.Box,{mb:"4",children:t.jsxs(o.Flex,{direction:"column",gap:"1",children:[t.jsxs(o.Text,{as:"label",size:"2",weight:"bold",htmlFor:r,children:[a," ",h&&t.jsx(o.Text,{color:"red",children:"*"})]}),t.jsxs("div",{ref:w,style:{position:"relative"},children:[t.jsx(o.TextField.Root,{id:r,value:N?D:(le==null?void 0:le.name)??"",placeholder:N&&(f!=null&&f.searchable)?"Search...":pe,disabled:!C,readOnly:N&&!(f!=null&&f.searchable),style:A?void 0:{outline:"2px solid var(--red-7)",outlineOffset:"-1px"},onChange:x=>{f!=null&&f.searchable&&(M(x.target.value),N||B())},onFocus:()=>{C&&!N&&B()},onKeyDown:x=>{x.key==="Escape"&&S(!1)},children:t.jsx(o.TextField.Slot,{side:"right",children:t.jsxs(o.Flex,{align:"center",gap:"1",children:[e&&C&&t.jsx("span",{role:"button",tabIndex:0,onMouseDown:x=>x.preventDefault(),onClick:X,onKeyDown:Y,style:{lineHeight:1,color:"var(--gray-9)",padding:"0 2px",cursor:"pointer"},"aria-label":"Clear selection",children:"×"}),t.jsx(_.ChevronDownIcon,{style:{transform:N?"rotate(180deg)":void 0,transition:"transform 150ms"}})]})})}),N&&t.jsx(o.Box,{style:{position:"absolute",top:"calc(100% + 4px)",left:0,right:0,zIndex:50,background:"var(--color-panel-solid)",borderRadius:"var(--radius-3)",boxShadow:"var(--shadow-5)",border:"1px solid var(--gray-a6)",overflow:"hidden"},children:F?t.jsx(o.Box,{p:"3",children:t.jsx(o.Text,{size:"2",color:"gray",children:F})}):t.jsx(o.ScrollArea,{style:{maxHeight:240},children:t.jsxs(o.Box,{p:"1",children:[U&&t.jsx(o.Flex,{justify:"center",p:"4",children:t.jsx(o.Spinner,{})}),!U&&se&&t.jsx(o.Box,{px:"3",py:"2",children:t.jsx(o.Text,{size:"2",color:"red",children:se})}),!U&&!se&&ee.length===0&&t.jsx(o.Box,{px:"3",py:"2",children:t.jsx(o.Text,{size:"2",color:"gray",children:D||m?"No results found.":"Type to search…"})}),ee.map(x=>t.jsx(o.Box,{px:"3",py:"2",onMouseDown:j=>j.preventDefault(),onClick:()=>K(x),style:{cursor:"pointer",borderRadius:"var(--radius-2)",backgroundColor:x.id===e?"var(--accent-3)":void 0},className:"hover:bg-(--gray-3)",children:t.jsx(o.Text,{size:"2",children:x.name})},x.id)),(f==null?void 0:f.paginated)&&oe&&!te&&t.jsx(o.Box,{px:"3",py:"2",children:t.jsx(o.Button,{variant:"ghost",size:"1",style:{width:"100%"},onMouseDown:x=>x.preventDefault(),onClick:()=>void b(D,!0),children:"Load more"})}),te&&t.jsx(o.Flex,{justify:"center",p:"2",children:t.jsx(o.Spinner,{})})]})})})]}),!A&&t.jsx(o.Text,{color:"red",size:"1",children:ne(d,a)}),s.description&&t.jsx(o.Text,{size:"1",color:"gray",children:s.description})]})})},We=W.withJsonFormsControlProps(Et),$e=y.rankWith(3,y.schemaMatches(e=>{const n=e["x-search"];return e.type==="string"&&typeof(n==null?void 0:n.service)=="string"&&n.service!==""})),Rt=(e,n)=>pt(`${e}T${n}`).format(),wt=({path:e,label:n,required:r,errors:a,description:h,children:d})=>{const u=a.length===0;return t.jsx(o.Box,{mb:"4",children:t.jsxs(o.Flex,{direction:"column",gap:"1",children:[t.jsxs(o.Text,{as:"label",size:"2",weight:"bold",htmlFor:e,children:[n," ",r&&t.jsx(o.Text,{color:"red",children:"*"})]}),d,!u&&t.jsx(o.Text,{color:"red",size:"1",children:ne(a,n)}),h&&t.jsx(o.Text,{size:"1",color:"gray",children:h})]})})},_e=({data:e,handleChange:n,path:r,label:a,required:h,errors:d,schema:u,enabled:c,visible:s=!0})=>{if(v.useEffect(()=>{s===!1&&n(r,void 0)},[s,r,n]),s===!1)return null;const i=d.length===0,l=typeof e=="string"?e:"",g=C=>t.jsx(wt,{path:r,label:a,required:h,errors:d,description:u.description,children:C});if(u.format==="time")return g(t.jsx(o.TextField.Root,{type:"time",value:l,onChange:C=>n(r,C.target.value),disabled:!c,color:i?void 0:"red",id:r}));const p=u.format==="date-time",[f="",m=""]=l.split("T"),R=m.slice(0,5),F=(C,A)=>{if(!C){n(r,void 0);return}n(r,p?Rt(C,A||"00:00"):C)};return g(t.jsxs(o.Flex,{gap:"2",align:"center",children:[t.jsx(o.TextField.Root,{type:"date",value:f,disabled:!c,color:i?void 0:"red",onChange:C=>F(C.target.value,R),id:r,style:{flex:1}}),p&&t.jsx(o.TextField.Root,{type:"time",value:R,disabled:!c||!f,color:i?void 0:"red",onChange:C=>F(f,C.target.value),style:{flex:1}})]}))},Ve=y.rankWith(2,y.or(y.isDateControl,y.isDateTimeControl,y.isTimeControl)),St=W.withJsonFormsControlProps(_e),He=({uischema:e,schema:n,path:r,renderers:a,cells:h,enabled:d,visible:u=!0})=>{const s=e.elements;return u===!1?null:t.jsx(o.Flex,{direction:"column",gap:"4",children:s.map((i,l)=>t.jsx(W.JsonFormsDispatch,{uischema:i,schema:n,path:r,renderers:a,cells:h,enabled:d},`${r}-${l}`))})},Ge=y.rankWith(1,y.uiTypeIs("VerticalLayout")),Je=({uischema:e,schema:n,path:r,renderers:a,cells:h,enabled:d,visible:u=!0})=>{const s=e.elements;return u===!1?null:t.jsx(o.Flex,{direction:"row",gap:"4",children:s.map((i,l)=>t.jsx(o.Box,{style:{flex:1},children:t.jsx(W.JsonFormsDispatch,{uischema:i,schema:n,path:r,renderers:a,cells:h,enabled:d})},`${r}-${l}`))})},Ke=y.rankWith(1,y.uiTypeIs("HorizontalLayout")),Xe=({uischema:e,schema:n,path:r,renderers:a,cells:h,enabled:d,visible:u=!0})=>{const c=e,s=c.elements;return u===!1?null:t.jsxs(o.Box,{mb:"6",children:[c.label&&t.jsx(o.Heading,{size:"3",mb:"3",className:"text-gray-500 uppercase tracking-wide font-semibold",children:c.label}),t.jsx(o.Flex,{direction:"column",gap:"4",children:s.map((i,l)=>t.jsx(W.JsonFormsDispatch,{uischema:i,schema:n,path:r,renderers:a,cells:h,enabled:d},`${r}-${l}`))})]})},qe=y.rankWith(1,y.uiTypeIs("Group")),Ye=({uischema:e,schema:n,path:r,renderers:a,cells:h,enabled:d,visible:u=!0})=>{var p;const s=e.elements.filter(f=>f.type==="Category"),[i,l]=v.useState(((p=s[0])==null?void 0:p.label)||"");if(u===!1||!s.length)return null;const g=s.find(f=>f.label===i)?i:s[0].label;return t.jsxs(o.Tabs.Root,{value:g,onValueChange:l,children:[t.jsx(o.Tabs.List,{children:s.map((f,m)=>t.jsx(o.Tabs.Trigger,{value:f.label,children:f.label},`${r}-${m}`))}),t.jsx(o.Box,{pt:"3",children:s.map((f,m)=>t.jsx(o.Tabs.Content,{value:f.label,children:t.jsx(o.Flex,{direction:"column",gap:"4",children:f.elements.map((R,F)=>t.jsx(W.JsonFormsDispatch,{uischema:R,schema:n,path:r,renderers:a,cells:h,enabled:d},`${r}-${m}-${F}`))})},`${r}-${m}`))})]})},Ze=y.rankWith(1,y.uiTypeIs("Categorization"));function ue(e){return e>=1024*1024?`${(e/(1024*1024)).toFixed(0)} MB`:e>=1024?`${(e/1024).toFixed(0)} KB`:`${e} B`}function de(e){return e.split(",").map(n=>{if(n=n.trim(),n.endsWith("/*"))return n.split("/")[0].toUpperCase()+"S";if(n.startsWith("."))return n.slice(1).toUpperCase();const r=n.split("/")[1];return r?r.toUpperCase():n}).join(", ")}function At(e){return e?Array.isArray(e)?e:[e]:[]}const Ft=({data:e,handleChange:n,path:r,label:a,required:h,uischema:d,schema:u,enabled:c,errors:s,visible:i=!0})=>{const l=Ae();ce(i,r,n,null);const g=!s||s.length===0,p=(u==null?void 0:u["x-file"])??{},f=(d==null?void 0:d.options)??{},m=p.maxFiles??f.maxFiles??1,R=p.maxSize??f.maxSize??5*1024*1024,F=p.accept??f.accept??"image/*,application/pdf",C=m>1,A=c!==!1,[N,S]=v.useState(!1),[D,M]=v.useState(null),[ee,z]=v.useState({}),oe=v.useRef(new Set),$=v.useRef(null),U=At(e),G=U.length>=m;v.useEffect(()=>()=>{oe.current.forEach(T=>URL.revokeObjectURL(T)),oe.current.clear()},[]);const te=v.useCallback(async T=>{if(M(null),U.length>=m){M(`Maximum ${m} file${m>1?"s":""} allowed.`);return}if(T.size>R){M(`File exceeds the ${ue(R)} limit.`);return}if(!F.split(",").map(b=>b.trim()).some(b=>b==="*"||b==="*/*"?!0:b.endsWith("/*")?T.type.startsWith(b.slice(0,-1)):b.startsWith(".")?T.name.toLowerCase().endsWith(b.toLowerCase()):T.type===b)){M(`Invalid type. Accepted: ${de(F)}`);return}if(!(l!=null&&l.onUpload)){M("Upload service not configured.");return}try{const b=await l.onUpload(T),B=URL.createObjectURL(T);oe.current.add(B);const K={key:b.key,name:b.name??T.name,blobUrl:B};z(Y=>({...Y,[b.key]:K}));const X=[...U,b.key];n(r,C?X:X[0])}catch{M("Upload failed. Please try again."),$.current&&($.current.value="")}},[U,m,R,F,l,r,n,C]);if(i===!1)return null;const I=T=>{T.preventDefault(),T.stopPropagation(),!(!A||G)&&S(T.type==="dragenter"||T.type==="dragover")},se=T=>{var w;T.preventDefault(),T.stopPropagation(),S(!1),!(!A||G)&&(w=T.dataTransfer.files)!=null&&w[0]&&te(T.dataTransfer.files[0])},H=T=>{var w;(w=T.target.files)!=null&&w[0]&&(te(T.target.files[0]),T.target.value="")},le=T=>{if(!A)return;z(L=>{var K;const b={...L},B=(K=b[T])==null?void 0:K.blobUrl;return B&&(URL.revokeObjectURL(B),oe.current.delete(B)),delete b[T],b});const w=U.filter(L=>L!==T);n(r,C?w.length>0?w:null:w[0]??null)},J=async(T,w)=>{var B,K,X;T.preventDefault();const L=(B=ee[w])==null?void 0:B.blobUrl;if(L){(K=window.open(L,"_blank","noopener,noreferrer"))==null||K.focus();return}const b=window.open("","_blank");if(b)try{const Y=await((X=l==null?void 0:l.getDownloadUrl)==null?void 0:X.call(l,w));Y!=null&&Y.url?b.location.href=Y.url:b.close()}catch{b.close()}};if(!A&&U.length===0)return null;const q=m-U.length,re=A&&!G;return t.jsxs(o.Box,{mb:"4",children:[t.jsxs(o.Flex,{align:"center",justify:"between",mb:"2",children:[t.jsxs(o.Text,{as:"label",size:"2",weight:"bold",children:[a,h&&t.jsx(o.Text,{color:"red",children:" *"})]}),t.jsx(o.Text,{size:"1",color:"gray",children:C?`Up to ${m} files · ${ue(R)} each · ${de(F)}`:`${ue(R)} · ${de(F)}`})]}),U.map(T=>{var w;return t.jsx(o.Card,{size:"2",variant:"surface",mb:"2",children:t.jsxs(o.Flex,{align:"center",gap:"3",children:[t.jsx(o.Box,{style:{background:"var(--blue-3)",padding:8,borderRadius:6,color:"var(--blue-9)",flexShrink:0},children:t.jsx(_.FileTextIcon,{width:"20",height:"20"})}),t.jsx(o.Box,{style:{flex:1,overflow:"hidden"},children:t.jsx(o.Text,{size:"2",weight:"bold",style:{display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:((w=ee[T])==null?void 0:w.name)??"Uploaded File"})}),t.jsxs(o.Flex,{align:"center",gap:"2",style:{flexShrink:0},children:[t.jsx(o.Button,{variant:"soft",color:"blue",size:"1",onClick:L=>J(L,T),children:"View"}),t.jsx(_.CheckCircledIcon,{style:{color:"var(--green-9)",width:18,height:18}}),A&&t.jsx(o.IconButton,{variant:"ghost",color:"gray",onClick:()=>le(T),children:t.jsx(_.Cross2Icon,{})})]})]})},T)}),re&&t.jsxs("div",{role:"button",tabIndex:0,onClick:()=>{var T;return(T=$.current)==null?void 0:T.click()},onKeyDown:T=>{var w;(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),(w=$.current)==null||w.click())},onDragEnter:I,onDragLeave:I,onDragOver:I,onDrop:se,style:{cursor:"pointer"},className:["border-2 border-dashed rounded-lg p-6 text-center","transition-all duration-200 ease-in-out",N?"border-blue-500 bg-blue-50":D?"border-red-300 bg-red-50":"border-gray-300 hover:border-blue-400 hover:bg-gray-50"].join(" "),children:[t.jsx("input",{ref:$,type:"file",style:{display:"none"},accept:F,onChange:H}),t.jsx(o.Flex,{direction:"column",align:"center",gap:"2",children:D?t.jsxs(t.Fragment,{children:[t.jsx(_.ExclamationTriangleIcon,{style:{width:32,height:32,color:"var(--red-9)"}}),t.jsx(o.Text,{size:"2",color:"red",weight:"medium",children:D}),t.jsx(o.Text,{size:"1",color:"gray",children:"Click to try again"})]}):t.jsxs(t.Fragment,{children:[t.jsx(_.UploadIcon,{style:{width:32,height:32,color:"var(--gray-8)"}}),t.jsx(o.Text,{size:"2",weight:"medium",children:U.length>0?`Add another file (${q} remaining)`:"Click to upload or drag and drop"}),t.jsxs(o.Text,{size:"1",color:"gray",children:[ue(R)," max · ",de(F)]})]})})]}),A&&G&&C&&t.jsxs(o.Text,{size:"1",color:"gray",mt:"1",style:{display:"block",textAlign:"center"},children:["Maximum ",m," files uploaded. Remove one to replace it."]}),!g&&t.jsx(o.Text,{color:"red",size:"1",mt:"2",style:{display:"block"},children:ne(s,a)})]})},Qe=W.withJsonFormsControlProps(Ft),et=y.rankWith(10,y.and(y.schemaMatches(e=>{if(e.type==="string"&&e.format==="file")return!0;if(e.type==="array"){const n=e.items;return(n==null?void 0:n.type)==="string"&&(n==null?void 0:n.format)==="file"}return!1})));class Te extends Error{}function Nt(e,n){const r=je.read(e,{type:"array",cellDates:!0});if(r.SheetNames.length===0)throw new Te("This file has no sheets.");const a=n??r.SheetNames[0],h=r.Sheets[a];if(!h)throw new Te(`This file doesn't have a sheet named "${a}".`);const d=je.utils.sheet_to_json(h,{header:1,raw:!0,defval:null});return{sheetName:a,matrix:d,rowCount:d.length,colCount:Math.max(0,...d.map(u=>u.length))}}function It(e){let n=e+1,r="";for(;n>0;){const a=(n-1)%26;r=String.fromCharCode(65+a)+r,n=Math.floor((n-1)/26)}return r}class V extends Error{constructor(r,a){super(a??r);be(this,"code");this.code=r,this.name="FormulaError"}}const Ot=["IFS","IFERROR","AND","OR","NOT","ROUND","ROUNDUP","ROUNDDOWN","INDEX","VLOOKUP","HLOOKUP","SUM","AVERAGE","COUNT","DATE","TODAY"],Lt=["MAX","MIN","MAXA","MINA","MEDIAN","LARGE","SMALL","PERMUT","PERMUTATIONA","MATCH","SWITCH","SUBSTITUTE","TEXTJOIN","COUNTA","UPPER"],kt=["YEAR","MONTH","DAY","WEEKDAY"],Dt=["IF"],Mt=["CONCATENATE","CONCAT","LEN","TRIM","LOWER","LEFT","RIGHT","MID","FIND","SEARCH"],zt=new Set([...Ot,...Lt,...kt,...Mt,...Dt]),Ut=/"(?:[^"]|"")*"/g,Ce=new RegExp("(?<![A-Za-z0-9_.])([A-Za-z_][A-Za-z0-9_.]*)\\s*\\(","g");function Bt(e){const n=e.replace(Ut,a=>" ".repeat(a.length));Ce.lastIndex=0;let r;for(;(r=Ce.exec(n))!==null;){const a=r[1].toUpperCase();if(!zt.has(a))throw new V("NAME",`Function ${a} is not allowed.`)}}function Pt(e,n,r){let a=e;if(a==null)throw r.NA;if(typeof a=="object"&&!(a instanceof r)&&(a=n.retrieveRef(a)),a instanceof r)throw a;if(typeof a=="boolean")return a;if(typeof a=="number")return a!==0;throw r.VALUE}function tt(e){return e!==null&&typeof e=="object"&&"value"in e?e.value:e}function ae(e){const n=tt(e);return Array.isArray(n)?n.flat(1/0):[n]}function E(e){const n=tt(e);return Array.isArray(n)?n.flat(1/0)[0]:n}function he(e){return e===void 0?void 0:E(e)}function P(e){return e==null||e===""?"":typeof e=="boolean"?e?"TRUE":"FALSE":e instanceof Date?e.toLocaleDateString():String(e)}function Wt(e,n){return e instanceof n?e:new n(e.message||"#ERROR!")}function O(e){return e.find(n=>n instanceof Error)}function $t(e,n){const r=d=>{throw Wt(d,n)},a=(d,{checkArgsForErrors:u=!0}={})=>(...c)=>{const s=c.flatMap(ae);if(u){const l=O(s);l&&r(l)}const i=d(...s);return i instanceof Error?r(i):i},h=(d,{toText:u=!1}={})=>c=>{const s=E(c),i=O([s]);i&&r(i);const l=d(u?P(s):s);return l instanceof Error?r(l):l};return{IF:(d,u,c,s)=>{const i=Pt(u,d,n);if(c==null)throw n.NA;return i?c:s??!1},MAX:a(e.MAX),MIN:a(e.MIN),MAXA:a(e.MAXA),MINA:a(e.MINA),MEDIAN:a(e.MEDIAN),COUNTA:a(e.COUNTA,{checkArgsForErrors:!1}),LARGE:(d,u)=>{const c=ae(d),s=E(u),i=O([...c,s]);i&&r(i);const l=e.LARGE(c,s);return l instanceof Error?r(l):l},SMALL:(d,u)=>{const c=ae(d),s=E(u),i=O([...c,s]);i&&r(i);const l=e.SMALL(c,s);return l instanceof Error?r(l):l},PERMUT:(d,u)=>{const c=[E(d),E(u)],s=O(c);s&&r(s);const i=e.PERMUT(c[0],c[1]);return i instanceof Error?r(i):i},PERMUTATIONA:(d,u)=>{const c=[E(d),E(u)],s=O(c);s&&r(s);const i=e.PERMUTATIONA(c[0],c[1]);return i instanceof Error?r(i):i},MATCH:(d,u)=>{const c=E(d),s=ae(u),i=O([c,...s]);i&&r(i);const l=e.MATCH(c,s,0);return l instanceof Error?r(l):l},SWITCH:(...d)=>{const u=d.map(E),c=O(u);c&&r(c);const s=e.SWITCH(...u);return s instanceof Error?r(s):s},SUBSTITUTE:(d,u,c,s)=>{const i=[P(E(d)),P(E(u)),P(E(c))];s!==void 0&&i.push(E(s));const l=O(i);l&&r(l);const g=e.SUBSTITUTE(...i);return g instanceof Error?r(g):g},TEXTJOIN:(d,u,...c)=>{const s=P(E(d)),i=E(u),l=c.flatMap(ae).map(P),g=O([s,i]);g&&r(g);const p=e.TEXTJOIN(s,i,l);return p instanceof Error?r(p):p},UPPER:h(e.UPPER),YEAR:h(e.YEAR),MONTH:h(e.MONTH),DAY:h(e.DAY),WEEKDAY:(d,u)=>{const c=E(d),s=E(u),i=O([c]);i&&r(i);const l=e.WEEKDAY(c,s);return l instanceof Error?r(l):l},CONCATENATE:(...d)=>{const u=d.flatMap(ae),c=O(u);c&&r(c);const s=e.CONCATENATE(...u.map(P));return s instanceof Error?r(s):s},CONCAT:(...d)=>{const u=d.flatMap(ae),c=O(u);c&&r(c);const s=e.CONCAT(...u.map(P));return s instanceof Error?r(s):s},LEN:h(e.LEN,{toText:!0}),TRIM:h(e.TRIM,{toText:!0}),LOWER:h(e.LOWER,{toText:!0}),LEFT:(d,u)=>{const c=E(d),s=he(u),i=O([c]);i&&r(i);const l=e.LEFT(P(c),s);return l instanceof Error?r(l):l},RIGHT:(d,u)=>{const c=E(d),s=he(u),i=O([c]);i&&r(i);const l=e.RIGHT(P(c),s);return l instanceof Error?r(l):l},MID:(d,u,c)=>{const s=E(d),i=E(u),l=E(c),g=O([s,i,l]);g&&r(g);const p=e.MID(P(s),i,l);return p instanceof Error?r(p):p},FIND:(d,u,c)=>{const s=E(d),i=E(u),l=he(c),g=O([s,i]);g&&r(g);const p=e.FIND(P(s),P(i),l);return p instanceof Error?r(p):p},SEARCH:(d,u,c)=>{const s=E(d),i=E(u),l=he(c),g=O([s,i]);g&&r(g);const p=e.SEARCH(P(s),P(i),l);return p instanceof Error?r(p):p}}}const _t={"#REF!":"REF","#VALUE!":"VALUE","#DIV/0!":"DIV0","#NAME?":"NAME","#N/A":"NA","#NUM!":"NUM","#NULL!":"NULL"};function Ee(e){return _t[e.error]??"ERROR"}function Re(e,n){if(e instanceof V)return e;if(e instanceof n){const r=e.details;return r instanceof V?r:r instanceof n?new V(Ee(r),r.message):new V(Ee(e),e.message)}return new V("ERROR",e instanceof Error?e.message:void 0)}function Vt(e){return Math.max(0,...e.map(n=>(n==null?void 0:n.length)??0))}function Ht(e){return n=>{const r=e[n.row-1];if(n.row<1||n.col<1||r==null||n.col-1>=r.length)throw new V("REF");const a=r[n.col-1];return a==null||a===""?null:a}}function Gt(e){return n=>{const r=Math.min(n.from.row,n.to.row),a=Math.min(n.from.col,n.to.col),h=Math.max(n.from.row,n.to.row),d=Math.max(n.from.col,n.to.col),u=Vt(e);if(r>e.length||a>u)throw new V("REF");const c=Math.min(h,e.length),s=[];for(let i=r;i<=c;i++){const l=e[i-1],g=[];if(l!=null){const p=Math.min(d,l.length);for(let f=a;f<=p;f++){const m=l[f-1];g.push(m==null||m===""?null:m)}}s.push(g)}return s}}function Jt(e){if(e==null||e==="")return null;if(typeof e=="number"||typeof e=="string"||typeof e=="boolean"||e instanceof Date)return e;throw new V("VALUE")}async function Kt(e,n){if(typeof n!="string")throw new V("ERROR");const r=n.trim();if(r==="")throw new V("ERROR");const a=r.startsWith("=")?r.slice(1):r;Bt(a);const[h,d]=await Promise.all([import("fast-formula-parser"),import("@formulajs/formulajs")]),u=h.default??h,c=u.FormulaError,s=new u({onCell:Ht(e),onRange:Gt(e),functions:$t(d,c)});let i;try{i=s.parse(a,{row:1,col:1,sheet:"Sheet1"})}catch(l){throw Re(l,c)}if(i instanceof c)throw Re(i,c);return Jt(i)}const we={REF:"#REF!",VALUE:"#VALUE!",DIV0:"#DIV/0!",NAME:"#NAME?",ERROR:"#ERROR!",NA:"#N/A",NUM:"#NUM!",NULL:"#NULL!"};async function Xt(e,n){return e.length===0?n.map(r=>({label:(r==null?void 0:r.label)??"(unknown)",value:null,error:we.ERROR})):Promise.all(n.map(async r=>{try{if(!r||typeof r.label!="string"||typeof r.expression!="string")throw new V("ERROR");return{label:r.label,value:await Kt(e,r.expression)}}catch(a){const h=a instanceof V?a.code:"ERROR";return{label:(r==null?void 0:r.label)??"(unknown)",value:null,error:we[h]}}}))}const qt=".xlsx,.xls,.csv,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel,text/csv",Yt=10*1024*1024,me=200,Zt=50,Qt=[];function fe(e){return e==null||e===""?"":e instanceof Date?e.toLocaleDateString():String(e)}const er=({data:e,handleChange:n,path:r,label:a,required:h,schema:d,enabled:u,errors:c,visible:s=!0})=>{var xe;ce(s,r,n,null);const i=!c||c.length===0,l=u!==!1,g=(d==null?void 0:d["x-spreadsheet"])??{},p=(d==null?void 0:d["x-evaluate"])??Qt,f=g.accept??qt,m=g.maxSize??Yt,R=g.persistSheet!==!1,F=g.columnHeader===!0,C=g.rowHeader===!0,A=g.showSheet!==!1,N=g.sheetName,S=e??null,[D,M]=v.useState(()=>{var x;return S!=null&&S.sheet||(((x=S==null?void 0:S.derivations)==null?void 0:x.length)??0)>0?"ready":"empty"}),[ee,z]=v.useState(null),[oe,$]=v.useState(!1),[U,G]=v.useState(null),te=v.useRef(null),I=U??(S==null?void 0:S.sheet)??null,se=(S==null?void 0:S.derivations)??[],H=I!=null||S!=null,le=v.useCallback(async x=>{if(z(null),x.size>m){z(`File exceeds the ${ue(m)} limit.`);return}if(!f.split(",").map(k=>k.trim()).some(k=>k==="*"||k==="*/*"?!0:k.endsWith("/*")?x.type.startsWith(k.slice(0,-1)):k.startsWith(".")?x.name.toLowerCase().endsWith(k.toLowerCase()):x.type===k)){z(`Invalid type. Accepted: ${de(f)}`);return}M("parsing");let Z;try{const k=await x.arrayBuffer();Z=Nt(k,N).matrix}catch(k){M("error"),z(k instanceof Te?k.message:"This doesn't look like a valid spreadsheet. Please check the file and try again.");return}G(Z);const Q=await Xt(Z,p);n(r,R?{sheet:Z,derivations:Q}:{derivations:Q}),M("ready")},[f,m,R,N,p,r,n]);if(s===!1||!l&&!H)return null;const J=x=>{x.preventDefault(),x.stopPropagation(),l&&$(x.type==="dragenter"||x.type==="dragover")},q=x=>{var j;x.preventDefault(),x.stopPropagation(),$(!1),l&&(j=x.dataTransfer.files)!=null&&j[0]&&le(x.dataTransfer.files[0])},re=x=>{var j;(j=x.target.files)!=null&&j[0]&&(le(x.target.files[0]),x.target.value="")},T=()=>{l&&(G(null),z(null),M("empty"),n(r,null))},w=F?1:0,L=C?1:0,b=I?I.slice(w):[],B=b.slice(0,me),K=Math.min(Zt,Math.max(0,...B.map(x=>Math.max(0,x.length-L)))),X=Array.from({length:K},(x,j)=>j+L),Y=A&&I==null&&S!=null,pe=F&&C?fe((xe=I==null?void 0:I[0])==null?void 0:xe[0]):"";return t.jsxs(o.Box,{mb:"4",children:[t.jsxs(o.Flex,{align:"center",justify:"between",mb:"2",children:[t.jsxs(o.Text,{as:"label",size:"2",weight:"bold",children:[a,h&&t.jsx(o.Text,{color:"red",children:" *"})]}),t.jsxs(o.Text,{size:"1",color:"gray",children:[ue(m)," max · ",de(f)]})]}),H&&t.jsx(o.Card,{size:"2",variant:"surface",mb:"2",children:t.jsxs(o.Flex,{align:"center",gap:"3",children:[t.jsx(o.Box,{style:{background:"var(--blue-3)",padding:8,borderRadius:6,color:"var(--blue-9)",flexShrink:0},children:t.jsx(_.FileTextIcon,{width:"20",height:"20"})}),t.jsx(o.Box,{style:{flex:1},children:t.jsx(o.Text,{size:"2",weight:"bold",children:"Spreadsheet uploaded"})}),t.jsx(_.CheckCircledIcon,{style:{color:"var(--green-9)",width:18,height:18}}),l&&t.jsx(o.IconButton,{variant:"ghost",color:"gray",onClick:T,"aria-label":"Remove spreadsheet",children:t.jsx(_.Cross2Icon,{})})]})}),l&&t.jsxs("div",{role:"button",tabIndex:0,onClick:()=>{var x;return(x=te.current)==null?void 0:x.click()},onKeyDown:x=>{var j;(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),(j=te.current)==null||j.click())},onDragEnter:J,onDragLeave:J,onDragOver:J,onDrop:q,style:{cursor:"pointer"},className:["border-2 border-dashed rounded-lg p-6 text-center","transition-all duration-200 ease-in-out",oe?"border-blue-500 bg-blue-50":ee?"border-red-300 bg-red-50":"border-gray-300 hover:border-blue-400 hover:bg-gray-50"].join(" "),children:[t.jsx("input",{ref:te,type:"file",style:{display:"none"},accept:f,onChange:re}),t.jsx(o.Flex,{direction:"column",align:"center",gap:"2",children:D==="parsing"?t.jsxs(t.Fragment,{children:[t.jsx(o.Spinner,{size:"3"}),t.jsx(o.Text,{size:"2",color:"gray",children:"Parsing spreadsheet…"})]}):ee?t.jsxs(t.Fragment,{children:[t.jsx(_.ExclamationTriangleIcon,{style:{width:32,height:32,color:"var(--red-9)"}}),t.jsx(o.Text,{size:"2",color:"red",weight:"medium",children:ee}),t.jsx(o.Text,{size:"1",color:"gray",children:"Click to try again"})]}):t.jsxs(t.Fragment,{children:[t.jsx(_.UploadIcon,{style:{width:32,height:32,color:"var(--gray-8)"}}),t.jsx(o.Text,{size:"2",weight:"medium",children:H?"Click to upload a replacement":"Click to upload or drag and drop"}),t.jsxs(o.Text,{size:"1",color:"gray",children:[ue(m)," max · ",de(f)]})]})})]}),I&&A&&t.jsxs(o.Box,{mt:"3",children:[t.jsx(o.Box,{style:{overflow:"auto",maxHeight:420},children:t.jsxs(o.Table.Root,{variant:"surface",size:"1",children:[t.jsx(o.Table.Header,{children:t.jsxs(o.Table.Row,{children:[t.jsx(o.Table.ColumnHeaderCell,{children:pe}),X.map(x=>{var j;return t.jsx(o.Table.ColumnHeaderCell,{children:F?fe((j=I[0])==null?void 0:j[x]):It(x)},x)})]})}),t.jsx(o.Table.Body,{children:B.map((x,j)=>{var Z;const ie=w+j;return t.jsxs(o.Table.Row,{children:[t.jsx(o.Table.RowHeaderCell,{children:C?fe((Z=I[ie])==null?void 0:Z[0]):ie+1}),X.map(Q=>t.jsx(o.Table.Cell,{children:fe(x[Q])},Q))]},j)})})]})}),b.length>me&&t.jsxs(o.Text,{size:"1",color:"gray",mt:"1",style:{display:"block"},children:["Showing first ",me," of ",b.length," rows"]})]}),Y&&t.jsx(o.Text,{size:"2",color:"gray",mt:"3",style:{display:"block"},children:"Sheet preview not stored for this field — re-upload to view contents."}),se.length>0&&t.jsxs(o.Box,{mt:"3",children:[t.jsx(o.Text,{size:"2",weight:"bold",as:"div",mb:"1",children:"Computed values"}),t.jsx(o.Flex,{direction:"column",gap:"1",children:se.map((x,j)=>t.jsxs(o.Flex,{justify:"between",children:[t.jsx(o.Text,{size:"2",children:x.label}),x.error?t.jsx(o.Text,{size:"2",color:"red",children:x.error}):t.jsx(o.Text,{size:"2",children:fe(x.value)})]},j))})]}),!i&&t.jsx(o.Text,{color:"red",size:"1",mt:"2",style:{display:"block"},children:ne(c,a)})]})},rt=W.withJsonFormsControlProps(er),nt=y.rankWith(10,y.schemaMatches(e=>e.type==="object"&&typeof e["x-spreadsheet"]=="object")),tr=({data:e,path:n,schema:r,uischema:a,enabled:h,visible:d,addItem:u,removeItems:c,rootSchema:s,arraySchema:i})=>{const l=i?r:r.items,g=i||r;if(d===!1||!l||typeof l!="object"||Array.isArray(l))return null;const p=l,f=Array.isArray(e)?e:[],m=g.title||"Array Items",R=()=>{const C=y.createDefaultValue(p,s);u&&u(n,C)()},F=C=>{if(c){const A=c(n,[C]);A&&A()}};return t.jsx(o.Box,{mb:"6",children:t.jsxs(o.Flex,{direction:"column",gap:"4",children:[t.jsx(o.Text,{as:"div",size:"4",weight:"bold",children:m}),f.length===0&&t.jsx(o.Box,{py:"4",px:"4",style:{backgroundColor:"var(--gray-3)",borderRadius:"var(--radius-3)"},children:t.jsx(o.Text,{size:"2",color:"gray",children:"No items have been added yet."})}),f.map((C,A)=>{var S;const N=`${n}.${A}`;return t.jsx(o.Card,{size:"3",variant:"surface",children:t.jsxs(o.Flex,{direction:"column",gap:"4",children:[t.jsxs(o.Flex,{justify:"between",align:"center",children:[t.jsxs(o.Text,{size:"3",weight:"bold",children:["Item ",A+1]}),h&&t.jsxs(o.Button,{type:"button",color:"red",variant:"soft",onClick:()=>F(A),title:"Remove item",children:[t.jsx(_.TrashIcon,{}),"Remove"]})]}),t.jsx(o.Box,{children:t.jsx(W.JsonFormsDispatch,{schema:p,uischema:((S=a.options)==null?void 0:S.detail)||(p.type==="object"||p.properties?{type:"VerticalLayout",elements:Object.keys(p.properties||{}).map(D=>({type:"Control",scope:`#/properties/${D}`}))}:{type:"Control",scope:"#"}),path:N,enabled:h,renderers:void 0,cells:void 0})})]})},N)}),h&&t.jsx(o.Box,{mt:"2",children:t.jsxs(o.Button,{type:"button",variant:"surface",onClick:R,children:[t.jsx(_.PlusIcon,{}),"Add Item"]})})]})})},ye=W.withJsonFormsArrayControlProps(tr),ot=y.rankWith(3,y.isObjectArrayControl),st=({uischema:e,visible:n})=>{const r=e;return n===!1?null:t.jsx(o.Box,{mb:"4",children:t.jsx(o.Heading,{size:"4",children:r.text})})},lt=y.rankWith(1,y.uiTypeIs("Label")),rr=y.rankWith(3,y.isPrimitiveArrayControl),nr=[{tester:Oe,renderer:Tt},{tester:ke,renderer:yt},{tester:Me,renderer:vt},{tester:Ue,renderer:bt},{tester:$e,renderer:We},{tester:Pe,renderer:jt},{tester:Ve,renderer:St},{tester:Ge,renderer:He},{tester:Ke,renderer:Je},{tester:qe,renderer:Xe},{tester:Ze,renderer:Ye},{tester:et,renderer:Qe},{tester:nt,renderer:rt},{tester:ot,renderer:ye},{tester:rr,renderer:ye},{tester:lt,renderer:st}];exports.ArrayControl=ye;exports.ArrayControlTester=ot;exports.BooleanControl=De;exports.BooleanControlTester=Me;exports.CategorizationLayoutRenderer=Ye;exports.CategorizationLayoutTester=Ze;exports.DateControl=_e;exports.DateControlTester=Ve;exports.FileControl=Qe;exports.FileControlTester=et;exports.GroupLayoutRenderer=Xe;exports.GroupLayoutTester=qe;exports.HorizontalLayoutRenderer=Je;exports.HorizontalLayoutTester=Ke;exports.LabelRenderer=st;exports.LabelTester=lt;exports.NumberControl=Le;exports.NumberControlTester=ke;exports.RadioControl=ze;exports.RadioControlTester=Ue;exports.SearchSelectControl=We;exports.SearchSelectControlTester=$e;exports.SearchServiceProvider=mt;exports.SelectControl=Be;exports.SelectControlTester=Pe;exports.SpreadsheetControl=rt;exports.SpreadsheetControlTester=nt;exports.TextControl=Ie;exports.TextControlTester=Oe;exports.UploadProvider=gt;exports.VerticalLayoutRenderer=He;exports.VerticalLayoutTester=Ge;exports.radixRenderers=nr;exports.useSearchService=Ne;exports.useUpload=Ae;
3
+ `):"",Be=({data:e,handleChange:n,path:r,label:i,required:x,errors:c,uischema:l,schema:u,enabled:s,visible:a=!0})=>{var m;if(se(a,r,n),a===!1)return null;const d=c.length===0;return t.jsx(o.Box,{mb:"4",children:t.jsxs(o.Flex,{direction:"column",gap:"1",children:[t.jsxs(o.Text,{as:"label",size:"2",weight:"bold",htmlFor:r,children:[i," ",x&&t.jsx(o.Text,{color:"red",children:"*"})]}),t.jsx(o.TextField.Root,{value:e||"",onChange:h=>n(r,h.target.value),disabled:!s,placeholder:(m=l.options)==null?void 0:m.placeholder,color:d?void 0:"red",id:r}),!d&&t.jsx(o.Text,{color:"red",size:"1",children:le(c,i)}),u.description&&t.jsx(o.Text,{size:"1",color:"gray",children:u.description})]})})},Pe=y.rankWith(1,y.isStringControl),kt=B.withJsonFormsControlProps(Be),He=({data:e,handleChange:n,path:r,label:i,required:x,errors:c,uischema:l,schema:u,enabled:s,visible:a=!0})=>{var h;if(se(a,r,n),a===!1)return null;const d=c.length===0,m=p=>{if(p===""){n(r,void 0);return}const g=Number(p);isNaN(g)||n(r,g)};return t.jsx(o.Box,{mb:"4",children:t.jsxs(o.Flex,{direction:"column",gap:"1",children:[t.jsxs(o.Text,{as:"label",size:"2",weight:"bold",htmlFor:r,children:[i," ",x&&t.jsx(o.Text,{color:"red",children:"*"})]}),t.jsx(o.TextField.Root,{type:"number",value:e??"",onChange:p=>m(p.target.value),disabled:!s,placeholder:(h=l.options)==null?void 0:h.placeholder,color:d?void 0:"red",id:r}),!d&&t.jsx(o.Text,{color:"red",size:"1",children:le(c,i)}),u.description&&t.jsx(o.Text,{size:"1",color:"gray",children:u.description})]})})},We=y.rankWith(2,y.or(y.isNumberControl,y.isIntegerControl)),Lt=B.withJsonFormsControlProps(He),$e=({data:e,handleChange:n,path:r,label:i,required:x,errors:c,schema:l,enabled:u,visible:s=!0})=>{if(se(s,r,n),s===!1)return null;const a=c.length===0;return t.jsxs(o.Box,{mb:"4",children:[t.jsxs(o.Flex,{gap:"2",align:"center",children:[t.jsx(o.Checkbox,{checked:!!e,onCheckedChange:d=>n(r,d===!0),disabled:!u,id:r}),t.jsxs(o.Text,{as:"label",size:"2",htmlFor:r,children:[i," ",x&&"*"]})]}),!a&&t.jsx(o.Text,{color:"red",size:"1",className:"block mt-1",children:le(c,i)}),l.description&&t.jsx(o.Text,{size:"1",color:"gray",className:"block mt-1",children:l.description})]})},_e=y.rankWith(2,y.isBooleanControl),Mt=B.withJsonFormsControlProps($e),Ve=({data:e,handleChange:n,path:r,label:i,required:x,errors:c,schema:l,enabled:u,visible:s=!0})=>{if(se(s,r,n),s===!1)return null;const a=c.length===0;let d=[];l.enum?d=l.enum.map(h=>({value:h,label:String(h)})):l.oneOf&&(d=l.oneOf.map(h=>({value:h.const,label:h.title||String(h.const)})));const m=e;return t.jsx(o.Box,{mb:"4",children:t.jsxs(o.Flex,{direction:"column",gap:"1",children:[t.jsxs(o.Text,{as:"div",size:"2",weight:"bold",children:[i," ",x&&t.jsx(o.Text,{color:"red",children:"*"})]}),t.jsx(o.RadioGroup.Root,{value:m!==void 0?String(m):"",onValueChange:h=>{const p=d.find(g=>String(g.value)===h);p&&n(r,p.value)},disabled:!u,children:t.jsx(o.Flex,{direction:"row",style:{flexWrap:"wrap",columnGap:"clamp(14px, 3vw, 36px)",rowGap:"clamp(8px, 1.6vw, 14px)"},children:d.map(h=>t.jsxs(o.Flex,{align:"center",gap:"2",style:{minWidth:"max-content"},children:[t.jsx(o.RadioGroup.Item,{value:String(h.value)}),t.jsx(o.Text,{size:"2",color:u?void 0:"gray",children:h.label})]},String(h.value)))})}),!a&&t.jsx(o.Text,{color:"red",size:"1",children:le(c,i)}),l.description&&t.jsx(o.Text,{size:"1",color:"gray",children:l.description})]})})},Je=(e,n,r)=>{var x;return y.or(y.isEnumControl,y.isOneOfControl)(e,n,r)&&((x=e==null?void 0:e.options)==null?void 0:x.format)==="radio"?3:-1},zt=B.withJsonFormsControlProps(Ve),Ke=({data:e,handleChange:n,path:r,label:i,required:x,errors:c,schema:l,uischema:u,enabled:s,visible:a=!0})=>{var p;if(se(a,r,n),a===!1)return null;const d=c.length===0;let m=[];l.enum?m=l.enum.map(g=>({value:String(g),label:String(g)})):l.oneOf&&(m=l.oneOf.map(g=>({value:String(g.const),label:g.title||String(g.const)})));const h=e!==void 0?String(e):"";return t.jsx(o.Box,{mb:"4",children:t.jsxs(o.Flex,{direction:"column",gap:"1",children:[t.jsxs(o.Text,{as:"label",size:"2",weight:"bold",htmlFor:r,children:[i," ",x&&t.jsx(o.Text,{color:"red",children:"*"})]}),t.jsxs(o.Select.Root,{value:h,onValueChange:g=>n(r,g),disabled:!s,children:[t.jsx(o.Select.Trigger,{placeholder:((p=u.options)==null?void 0:p.placeholder)||"Select an option",color:d?void 0:"red",id:r}),t.jsx(o.Select.Content,{children:m.map(g=>t.jsx(o.Select.Item,{value:g.value,children:g.label},g.value))})]}),!d&&t.jsx(o.Text,{color:"red",size:"1",children:le(c,i)}),l.description&&t.jsx(o.Text,{size:"1",color:"gray",children:l.description})]})})},Ge=y.rankWith(2,y.or(y.isEnumControl,y.isOneOfControl)),Dt=B.withJsonFormsControlProps(Ke),Ut={"small-list":{fetchOnOpen:!0,searchable:!1,paginated:!1},"large-searchable-list":{fetchOnOpen:!0,searchable:!0,paginated:!1},"large-paginated-list":{fetchOnOpen:!1,searchable:!0,paginated:!0}},Bt=({data:e,handleChange:n,path:r,label:i,required:x,errors:c,enabled:l,visible:u=!0,schema:s,uischema:a})=>{var pe;const d=(s==null?void 0:s["x-search"])??{service:""},m=d.service??"",h=d.mode??"large-paginated-list",p=Ut[h],g=(p==null?void 0:p.fetchOnOpen)??!1,S=d.params,R=Ue(m),b=s.type==="object",w=b?typeof e=="string"?{value:e}:e??void 0:void 0,N=b?w==null?void 0:w.value:e,U=w==null?void 0:w.label,A=m?R?p?null:`Invalid x-search.mode "${h}". Expected "small-list", "large-searchable-list", or "large-paginated-list".`:`Search service "${m}" is not registered.`:"Search not configured.",H=l!==!1,V=!c||c.length===0,[O,E]=v.useState(!1),[L,P]=v.useState(""),[re,Y]=v.useState([]),[ne,J]=v.useState(!1),[X,Z]=v.useState(!1),[ce,te]=v.useState(!1),[ie,T]=v.useState(null),[I,M]=v.useState(void 0),C=v.useRef(void 0),z=v.useRef(null),K=v.useRef(null),q=v.useRef(null),W=v.useRef(void 0);v.useEffect(()=>{var j,G;if(!N){M(void 0),W.current=void 0;return}if(((j=W.current)==null?void 0:j.value)===N&&((G=W.current)==null?void 0:G.label)===U)return;if(W.current={value:N,label:U},b&&U){M({id:N,name:U});return}if(M({id:N,name:U??N}),!(R!=null&&R.resolve))return;let f=!1;return R.resolve(N,S).then(Q=>{!f&&Q&&M(Q)}).catch(()=>{}),()=>{f=!0}},[N,U,b,R,S]);const xe=v.useCallback(async(f,j=!1)=>{var Q;if(!R){T("Search service not configured.");return}(Q=K.current)==null||Q.abort();const G=new AbortController;K.current=G,j?te(!0):(Z(!0),te(!1),T(null));try{const oe=await R.search({query:f,cursor:j?C.current:void 0,signal:G.signal,params:S}),k=oe.options??[];Y(j?jt=>[...jt,...k]:k),C.current=oe.nextCursor,J(((p==null?void 0:p.paginated)??!1)&&oe.nextCursor!=null)}catch{if(G.signal.aborted)return;T("Failed to load results. Please try again.")}finally{G.signal.aborted||(j?te(!1):Z(!1))}},[R,p==null?void 0:p.paginated,S]);if(v.useEffect(()=>{if(!O)return;const f=j=>{q.current&&!q.current.contains(j.target)&&E(!1)};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[O]),v.useEffect(()=>{var f;O||((f=K.current)==null||f.abort(),P(""),Y([]),J(!1),T(null),Z(!1),te(!1),C.current=void 0)},[O]),v.useEffect(()=>{if(!O)return;if(!L&&!g){Y([]),J(!1),T(null),C.current=void 0;return}z.current&&clearTimeout(z.current);const f=L?300:0;return z.current=setTimeout(()=>{Y([]),J(!1),C.current=void 0,xe(L)},f),()=>{z.current&&clearTimeout(z.current)}},[L,O,g,xe]),se(u,r,n,b?void 0:null),u===!1)return null;const he=()=>{P(""),Y([]),J(!1),T(null),C.current=void 0,E(!0)},be=f=>{n(r,b?{value:f.id,label:f.name}:f.id),M(f),W.current={value:f.id,label:b?f.name:void 0},E(!1)},ge=f=>{f.stopPropagation(),n(r,b?void 0:null),M(void 0)},ve=f=>{(f.key==="Enter"||f.key===" ")&&ge(f)},Te=((pe=a==null?void 0:a.options)==null?void 0:pe.placeholder)??"Select an option";return t.jsx(o.Box,{mb:"4",children:t.jsxs(o.Flex,{direction:"column",gap:"1",children:[t.jsxs(o.Text,{as:"label",size:"2",weight:"bold",htmlFor:r,children:[i," ",x&&t.jsx(o.Text,{color:"red",children:"*"})]}),t.jsxs("div",{ref:q,style:{position:"relative"},children:[t.jsx(o.TextField.Root,{id:r,value:O?L:(I==null?void 0:I.name)??"",placeholder:O&&(p!=null&&p.searchable)?"Search...":Te,disabled:!H,readOnly:O&&!(p!=null&&p.searchable),style:V?void 0:{outline:"2px solid var(--red-7)",outlineOffset:"-1px"},onChange:f=>{p!=null&&p.searchable&&(P(f.target.value),O||he())},onFocus:()=>{H&&!O&&he()},onKeyDown:f=>{f.key==="Escape"&&E(!1)},children:t.jsx(o.TextField.Slot,{side:"right",children:t.jsxs(o.Flex,{align:"center",gap:"1",children:[N&&H&&t.jsx("span",{role:"button",tabIndex:0,onMouseDown:f=>f.preventDefault(),onClick:ge,onKeyDown:ve,style:{lineHeight:1,color:"var(--gray-9)",padding:"0 2px",cursor:"pointer"},"aria-label":"Clear selection",children:"×"}),t.jsx(ee.ChevronDownIcon,{style:{transform:O?"rotate(180deg)":void 0,transition:"transform 150ms"}})]})})}),O&&t.jsx(o.Box,{style:{position:"absolute",top:"calc(100% + 4px)",left:0,right:0,zIndex:50,background:"var(--color-panel-solid)",borderRadius:"var(--radius-3)",boxShadow:"var(--shadow-5)",border:"1px solid var(--gray-a6)",overflow:"hidden"},children:A?t.jsx(o.Box,{p:"3",children:t.jsx(o.Text,{size:"2",color:"gray",children:A})}):t.jsx(o.ScrollArea,{style:{maxHeight:240},children:t.jsxs(o.Box,{p:"1",children:[X&&t.jsx(o.Flex,{justify:"center",p:"4",children:t.jsx(o.Spinner,{})}),!X&&ie&&t.jsx(o.Box,{px:"3",py:"2",children:t.jsx(o.Text,{size:"2",color:"red",children:ie})}),!X&&!ie&&re.length===0&&t.jsx(o.Box,{px:"3",py:"2",children:t.jsx(o.Text,{size:"2",color:"gray",children:L||g?"No results found.":"Type to search…"})}),re.map(f=>t.jsx(o.Box,{px:"3",py:"2",onMouseDown:j=>j.preventDefault(),onClick:()=>be(f),style:{cursor:"pointer",borderRadius:"var(--radius-2)",backgroundColor:f.id===N?"var(--accent-3)":void 0},className:"hover:bg-(--gray-3)",children:t.jsx(o.Text,{size:"2",children:f.name})},f.id)),(p==null?void 0:p.paginated)&&ne&&!ce&&t.jsx(o.Box,{px:"3",py:"2",children:t.jsx(o.Button,{variant:"ghost",size:"1",style:{width:"100%"},onMouseDown:f=>f.preventDefault(),onClick:()=>void xe(L,!0),children:"Load more"})}),ce&&t.jsx(o.Flex,{justify:"center",p:"2",children:t.jsx(o.Spinner,{})})]})})})]}),!V&&t.jsx(o.Text,{color:"red",size:"1",children:le(c,i)}),s.description&&t.jsx(o.Text,{size:"1",color:"gray",children:s.description})]})})},Xe=B.withJsonFormsControlProps(Bt),qe=y.rankWith(3,y.schemaMatches(e=>{const n=e["x-search"];return(e.type==="string"||e.type==="object")&&typeof(n==null?void 0:n.service)=="string"&&n.service!==""})),Pt=(e,n)=>Ot(`${e}T${n}`).format(),Ht=({path:e,label:n,required:r,errors:i,description:x,children:c})=>{const l=i.length===0;return t.jsx(o.Box,{mb:"4",children:t.jsxs(o.Flex,{direction:"column",gap:"1",children:[t.jsxs(o.Text,{as:"label",size:"2",weight:"bold",htmlFor:e,children:[n," ",r&&t.jsx(o.Text,{color:"red",children:"*"})]}),c,!l&&t.jsx(o.Text,{color:"red",size:"1",children:le(i,n)}),x&&t.jsx(o.Text,{size:"1",color:"gray",children:x})]})})},Ye=({data:e,handleChange:n,path:r,label:i,required:x,errors:c,schema:l,enabled:u,visible:s=!0})=>{if(v.useEffect(()=>{s===!1&&n(r,void 0)},[s,r,n]),s===!1)return null;const a=c.length===0,d=typeof e=="string"?e:"",m=b=>t.jsx(Ht,{path:r,label:i,required:x,errors:c,description:l.description,children:b});if(l.format==="time")return m(t.jsx(o.TextField.Root,{type:"time",value:d,onChange:b=>n(r,b.target.value),disabled:!u,color:a?void 0:"red",id:r}));const h=l.format==="date-time",[p="",g=""]=d.split("T"),S=g.slice(0,5),R=(b,w)=>{if(!b){n(r,void 0);return}n(r,h?Pt(b,w||"00:00"):b)};return m(t.jsxs(o.Flex,{gap:"2",align:"center",children:[t.jsx(o.TextField.Root,{type:"date",value:p,disabled:!u,color:a?void 0:"red",onChange:b=>R(b.target.value,S),id:r,style:{flex:1}}),h&&t.jsx(o.TextField.Root,{type:"time",value:S,disabled:!u||!p,color:a?void 0:"red",onChange:b=>R(p,b.target.value),style:{flex:1}})]}))},Ze=y.rankWith(2,y.or(y.isDateControl,y.isDateTimeControl,y.isTimeControl)),Wt=B.withJsonFormsControlProps(Ye),Qe=({uischema:e,schema:n,path:r,renderers:i,cells:x,enabled:c,visible:l=!0})=>{const s=e.elements;return l===!1?null:t.jsx(o.Flex,{direction:"column",gap:"4",children:s.map((a,d)=>t.jsx(B.JsonFormsDispatch,{uischema:a,schema:n,path:r,renderers:i,cells:x,enabled:c},`${r}-${d}`))})},et=y.rankWith(1,y.uiTypeIs("VerticalLayout")),tt=({uischema:e,schema:n,path:r,renderers:i,cells:x,enabled:c,visible:l=!0})=>{const s=e.elements;return l===!1?null:t.jsx(o.Flex,{direction:"row",gap:"4",children:s.map((a,d)=>t.jsx(o.Box,{style:{flex:1},children:t.jsx(B.JsonFormsDispatch,{uischema:a,schema:n,path:r,renderers:i,cells:x,enabled:c})},`${r}-${d}`))})},rt=y.rankWith(1,y.uiTypeIs("HorizontalLayout")),nt=({uischema:e,schema:n,path:r,renderers:i,cells:x,enabled:c,visible:l=!0})=>{const u=e,s=u.elements;return l===!1?null:t.jsxs(o.Box,{mb:"6",children:[u.label&&t.jsx(o.Heading,{size:"3",mb:"3",className:"text-gray-500 uppercase tracking-wide font-semibold",children:u.label}),t.jsx(o.Flex,{direction:"column",gap:"4",children:s.map((a,d)=>t.jsx(B.JsonFormsDispatch,{uischema:a,schema:n,path:r,renderers:i,cells:x,enabled:c},`${r}-${d}`))})]})},ot=y.rankWith(1,y.uiTypeIs("Group")),st=({uischema:e,schema:n,path:r,renderers:i,cells:x,enabled:c,visible:l=!0})=>{var h;const s=e.elements.filter(p=>p.type==="Category"),[a,d]=v.useState(((h=s[0])==null?void 0:h.label)||"");if(l===!1||!s.length)return null;const m=s.find(p=>p.label===a)?a:s[0].label;return t.jsxs(o.Tabs.Root,{value:m,onValueChange:d,children:[t.jsx(o.Tabs.List,{children:s.map((p,g)=>t.jsx(o.Tabs.Trigger,{value:p.label,children:p.label},`${r}-${g}`))}),t.jsx(o.Box,{pt:"3",children:s.map((p,g)=>t.jsx(o.Tabs.Content,{value:p.label,children:t.jsx(o.Flex,{direction:"column",gap:"4",children:p.elements.map((S,R)=>t.jsx(B.JsonFormsDispatch,{uischema:S,schema:n,path:r,renderers:i,cells:x,enabled:c},`${r}-${g}-${R}`))})},`${r}-${g}`))})]})},lt=y.rankWith(1,y.uiTypeIs("Categorization"));function ue(e){return e>=1024*1024?`${(e/(1024*1024)).toFixed(0)} MB`:e>=1024?`${(e/1024).toFixed(0)} KB`:`${e} B`}function de(e){return e.split(",").map(n=>{if(n=n.trim(),n.endsWith("/*"))return n.split("/")[0].toUpperCase()+"S";if(n.startsWith("."))return n.slice(1).toUpperCase();const r=n.split("/")[1];return r?r.toUpperCase():n}).join(", ")}function $t(e){return e?Array.isArray(e)?e:[e]:[]}const _t=({data:e,handleChange:n,path:r,label:i,required:x,uischema:c,schema:l,enabled:u,errors:s,visible:a=!0})=>{const d=ze();se(a,r,n,null);const m=!s||s.length===0,h=(l==null?void 0:l["x-file"])??{},p=(c==null?void 0:c.options)??{},g=h.maxFiles??p.maxFiles??1,S=h.maxSize??p.maxSize??5*1024*1024,R=h.accept??p.accept??"image/*,application/pdf",b=g>1,w=u!==!1,[N,U]=v.useState(!1),[A,H]=v.useState(null),[V,O]=v.useState({}),E=v.useRef(new Set),L=v.useRef(null),P=$t(e),re=P.length>=g;v.useEffect(()=>()=>{E.current.forEach(T=>URL.revokeObjectURL(T)),E.current.clear()},[]);const Y=v.useCallback(async T=>{if(H(null),P.length>=g){H(`Maximum ${g} file${g>1?"s":""} allowed.`);return}if(T.size>S){H(`File exceeds the ${ue(S)} limit.`);return}if(!R.split(",").map(C=>C.trim()).some(C=>C==="*"||C==="*/*"?!0:C.endsWith("/*")?T.type.startsWith(C.slice(0,-1)):C.startsWith(".")?T.name.toLowerCase().endsWith(C.toLowerCase()):T.type===C)){H(`Invalid type. Accepted: ${de(R)}`);return}if(!(d!=null&&d.onUpload)){H("Upload service not configured.");return}try{const C=await d.onUpload(T),z=URL.createObjectURL(T);E.current.add(z);const K={key:C.key,name:C.name??T.name,blobUrl:z};O(W=>({...W,[C.key]:K}));const q=[...P,C.key];n(r,b?q:q[0])}catch{H("Upload failed. Please try again."),L.current&&(L.current.value="")}},[P,g,S,R,d,r,n,b]);if(a===!1)return null;const ne=T=>{T.preventDefault(),T.stopPropagation(),!(!w||re)&&U(T.type==="dragenter"||T.type==="dragover")},J=T=>{var I;T.preventDefault(),T.stopPropagation(),U(!1),!(!w||re)&&(I=T.dataTransfer.files)!=null&&I[0]&&Y(T.dataTransfer.files[0])},X=T=>{var I;(I=T.target.files)!=null&&I[0]&&(Y(T.target.files[0]),T.target.value="")},Z=T=>{if(!w)return;O(M=>{var K;const C={...M},z=(K=C[T])==null?void 0:K.blobUrl;return z&&(URL.revokeObjectURL(z),E.current.delete(z)),delete C[T],C});const I=P.filter(M=>M!==T);n(r,b?I.length>0?I:null:I[0]??null)},ce=async(T,I)=>{var z,K,q;T.preventDefault();const M=(z=V[I])==null?void 0:z.blobUrl;if(M){(K=window.open(M,"_blank","noopener,noreferrer"))==null||K.focus();return}const C=window.open("","_blank");if(C)try{const W=await((q=d==null?void 0:d.getDownloadUrl)==null?void 0:q.call(d,I));W!=null&&W.url?C.location.href=W.url:C.close()}catch{C.close()}};if(!w&&P.length===0)return null;const te=g-P.length,ie=w&&!re;return t.jsxs(o.Box,{mb:"4",children:[t.jsxs(o.Flex,{align:"center",justify:"between",mb:"2",children:[t.jsxs(o.Text,{as:"label",size:"2",weight:"bold",children:[i,x&&t.jsx(o.Text,{color:"red",children:" *"})]}),t.jsx(o.Text,{size:"1",color:"gray",children:b?`Up to ${g} files · ${ue(S)} each · ${de(R)}`:`${ue(S)} · ${de(R)}`})]}),P.map(T=>{var I;return t.jsx(o.Card,{size:"2",variant:"surface",mb:"2",children:t.jsxs(o.Flex,{align:"center",gap:"3",children:[t.jsx(o.Box,{style:{background:"var(--blue-3)",padding:8,borderRadius:6,color:"var(--blue-9)",flexShrink:0},children:t.jsx(ee.FileTextIcon,{width:"20",height:"20"})}),t.jsx(o.Box,{style:{flex:1,overflow:"hidden"},children:t.jsx(o.Text,{size:"2",weight:"bold",style:{display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:((I=V[T])==null?void 0:I.name)??"Uploaded File"})}),t.jsxs(o.Flex,{align:"center",gap:"2",style:{flexShrink:0},children:[t.jsx(o.Button,{variant:"soft",color:"blue",size:"1",onClick:M=>ce(M,T),children:"View"}),t.jsx(ee.CheckCircledIcon,{style:{color:"var(--green-9)",width:18,height:18}}),w&&t.jsx(o.IconButton,{variant:"ghost",color:"gray",onClick:()=>Z(T),children:t.jsx(ee.Cross2Icon,{})})]})]})},T)}),ie&&t.jsxs("div",{role:"button",tabIndex:0,onClick:()=>{var T;return(T=L.current)==null?void 0:T.click()},onKeyDown:T=>{var I;(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),(I=L.current)==null||I.click())},onDragEnter:ne,onDragLeave:ne,onDragOver:ne,onDrop:J,style:{cursor:"pointer"},className:["border-2 border-dashed rounded-lg p-6 text-center","transition-all duration-200 ease-in-out",N?"border-blue-500 bg-blue-50":A?"border-red-300 bg-red-50":"border-gray-300 hover:border-blue-400 hover:bg-gray-50"].join(" "),children:[t.jsx("input",{ref:L,type:"file",style:{display:"none"},accept:R,onChange:X}),t.jsx(o.Flex,{direction:"column",align:"center",gap:"2",children:A?t.jsxs(t.Fragment,{children:[t.jsx(ee.ExclamationTriangleIcon,{style:{width:32,height:32,color:"var(--red-9)"}}),t.jsx(o.Text,{size:"2",color:"red",weight:"medium",children:A}),t.jsx(o.Text,{size:"1",color:"gray",children:"Click to try again"})]}):t.jsxs(t.Fragment,{children:[t.jsx(ee.UploadIcon,{style:{width:32,height:32,color:"var(--gray-8)"}}),t.jsx(o.Text,{size:"2",weight:"medium",children:P.length>0?`Add another file (${te} remaining)`:"Click to upload or drag and drop"}),t.jsxs(o.Text,{size:"1",color:"gray",children:[ue(S)," max · ",de(R)]})]})})]}),w&&re&&b&&t.jsxs(o.Text,{size:"1",color:"gray",mt:"1",style:{display:"block",textAlign:"center"},children:["Maximum ",g," files uploaded. Remove one to replace it."]}),!m&&t.jsx(o.Text,{color:"red",size:"1",mt:"2",style:{display:"block"},children:le(s,i)})]})},it=B.withJsonFormsControlProps(_t),ct=y.rankWith(10,y.and(y.schemaMatches(e=>{if(e.type==="string"&&e.format==="file")return!0;if(e.type==="array"){const n=e.items;return(n==null?void 0:n.type)==="string"&&(n==null?void 0:n.format)==="file"}return!1})));function Vt(e,n){return e!==!1&&n!==!0}class we extends Error{}function Jt(e,n){const r=Se.read(e,{type:"array",cellDates:!0});if(r.SheetNames.length===0)throw new we("This file has no sheets.");const i=n??r.SheetNames[0],x=r.Sheets[i];if(!x)throw new we(`This file doesn't have a sheet named "${i}".`);const c=Se.utils.sheet_to_json(x,{header:1,raw:!0,defval:null});return{sheetName:i,matrix:c,rowCount:c.length,colCount:Math.max(0,...c.map(l=>l.length))}}function Kt(e){let n=e+1,r="";for(;n>0;){const i=(n-1)%26;r=String.fromCharCode(65+i)+r,n=Math.floor((n-1)/26)}return r}class _ extends Error{constructor(r,i){super(i??r);Ee(this,"code");this.code=r,this.name="FormulaError"}}const Gt=["IFS","IFERROR","AND","OR","NOT","ROUND","ROUNDUP","ROUNDDOWN","INDEX","VLOOKUP","HLOOKUP","SUM","AVERAGE","COUNT","DATE","TODAY"],Xt=["MAX","MIN","MAXA","MINA","MEDIAN","LARGE","SMALL","PERMUT","PERMUTATIONA","MATCH","SWITCH","SUBSTITUTE","TEXTJOIN","COUNTA","UPPER"],qt=["YEAR","MONTH","DAY","WEEKDAY"],Yt=["IF"],Zt=["CONCATENATE","CONCAT","LEN","TRIM","LOWER","LEFT","RIGHT","MID","FIND","SEARCH"],Qt=new Set([...Gt,...Xt,...qt,...Zt,...Yt]),er=/"(?:[^"]|"")*"/g,Ae=new RegExp("(?<![A-Za-z0-9_.])([A-Za-z_][A-Za-z0-9_.]*)\\s*\\(","g");function tr(e){const n=e.replace(er,i=>" ".repeat(i.length));Ae.lastIndex=0;let r;for(;(r=Ae.exec(n))!==null;){const i=r[1].toUpperCase();if(!Qt.has(i))throw new _("NAME",`Function ${i} is not allowed.`)}}function rr(e,n,r){let i=e;if(i==null)throw r.NA;if(typeof i=="object"&&!(i instanceof r)&&(i=n.retrieveRef(i)),i instanceof r)throw i;if(typeof i=="boolean")return i;if(typeof i=="number")return i!==0;throw r.VALUE}function at(e){return e!==null&&typeof e=="object"&&"value"in e?e.value:e}function ae(e){const n=at(e);return Array.isArray(n)?n.flat(1/0):[n]}function F(e){const n=at(e);return Array.isArray(n)?n.flat(1/0)[0]:n}function ye(e){return e===void 0?void 0:F(e)}function $(e){return e==null||e===""?"":typeof e=="boolean"?e?"TRUE":"FALSE":e instanceof Date?e.toLocaleDateString():String(e)}function nr(e,n){return e instanceof n?e:new n(e.message||"#ERROR!")}function D(e){return e.find(n=>n instanceof Error)}function or(e,n){const r=c=>{throw nr(c,n)},i=(c,{checkArgsForErrors:l=!0}={})=>(...u)=>{const s=u.flatMap(ae);if(l){const d=D(s);d&&r(d)}const a=c(...s);return a instanceof Error?r(a):a},x=(c,{toText:l=!1}={})=>u=>{const s=F(u),a=D([s]);a&&r(a);const d=c(l?$(s):s);return d instanceof Error?r(d):d};return{IF:(c,l,u,s)=>{const a=rr(l,c,n);if(u==null)throw n.NA;return a?u:s??!1},MAX:i(e.MAX),MIN:i(e.MIN),MAXA:i(e.MAXA),MINA:i(e.MINA),MEDIAN:i(e.MEDIAN),COUNTA:i(e.COUNTA,{checkArgsForErrors:!1}),LARGE:(c,l)=>{const u=ae(c),s=F(l),a=D([...u,s]);a&&r(a);const d=e.LARGE(u,s);return d instanceof Error?r(d):d},SMALL:(c,l)=>{const u=ae(c),s=F(l),a=D([...u,s]);a&&r(a);const d=e.SMALL(u,s);return d instanceof Error?r(d):d},PERMUT:(c,l)=>{const u=[F(c),F(l)],s=D(u);s&&r(s);const a=e.PERMUT(u[0],u[1]);return a instanceof Error?r(a):a},PERMUTATIONA:(c,l)=>{const u=[F(c),F(l)],s=D(u);s&&r(s);const a=e.PERMUTATIONA(u[0],u[1]);return a instanceof Error?r(a):a},MATCH:(c,l)=>{const u=F(c),s=ae(l),a=D([u,...s]);a&&r(a);const d=e.MATCH(u,s,0);return d instanceof Error?r(d):d},SWITCH:(...c)=>{const l=c.map(F),u=D(l);u&&r(u);const s=e.SWITCH(...l);return s instanceof Error?r(s):s},SUBSTITUTE:(c,l,u,s)=>{const a=[$(F(c)),$(F(l)),$(F(u))];s!==void 0&&a.push(F(s));const d=D(a);d&&r(d);const m=e.SUBSTITUTE(...a);return m instanceof Error?r(m):m},TEXTJOIN:(c,l,...u)=>{const s=$(F(c)),a=F(l),d=u.flatMap(ae).map($),m=D([s,a]);m&&r(m);const h=e.TEXTJOIN(s,a,d);return h instanceof Error?r(h):h},UPPER:x(e.UPPER),YEAR:x(e.YEAR),MONTH:x(e.MONTH),DAY:x(e.DAY),WEEKDAY:(c,l)=>{const u=F(c),s=F(l),a=D([u]);a&&r(a);const d=e.WEEKDAY(u,s);return d instanceof Error?r(d):d},CONCATENATE:(...c)=>{const l=c.flatMap(ae),u=D(l);u&&r(u);const s=e.CONCATENATE(...l.map($));return s instanceof Error?r(s):s},CONCAT:(...c)=>{const l=c.flatMap(ae),u=D(l);u&&r(u);const s=e.CONCAT(...l.map($));return s instanceof Error?r(s):s},LEN:x(e.LEN,{toText:!0}),TRIM:x(e.TRIM,{toText:!0}),LOWER:x(e.LOWER,{toText:!0}),LEFT:(c,l)=>{const u=F(c),s=ye(l),a=D([u]);a&&r(a);const d=e.LEFT($(u),s);return d instanceof Error?r(d):d},RIGHT:(c,l)=>{const u=F(c),s=ye(l),a=D([u]);a&&r(a);const d=e.RIGHT($(u),s);return d instanceof Error?r(d):d},MID:(c,l,u)=>{const s=F(c),a=F(l),d=F(u),m=D([s,a,d]);m&&r(m);const h=e.MID($(s),a,d);return h instanceof Error?r(h):h},FIND:(c,l,u)=>{const s=F(c),a=F(l),d=ye(u),m=D([s,a]);m&&r(m);const h=e.FIND($(s),$(a),d);return h instanceof Error?r(h):h},SEARCH:(c,l,u)=>{const s=F(c),a=F(l),d=ye(u),m=D([s,a]);m&&r(m);const h=e.SEARCH($(s),$(a),d);return h instanceof Error?r(h):h}}}const sr={"#REF!":"REF","#VALUE!":"VALUE","#DIV/0!":"DIV0","#NAME?":"NAME","#N/A":"NA","#NUM!":"NUM","#NULL!":"NULL"};function Fe(e){return sr[e.error]??"ERROR"}function Oe(e,n){if(e instanceof _)return e;if(e instanceof n){const r=e.details;return r instanceof _?r:r instanceof n?new _(Fe(r),r.message):new _(Fe(e),e.message)}return new _("ERROR",e instanceof Error?e.message:void 0)}function lr(e){return Math.max(0,...e.map(n=>(n==null?void 0:n.length)??0))}function ir(e){return n=>{const r=e[n.row-1];if(n.row<1||n.col<1||r==null||n.col-1>=r.length)throw new _("REF");const i=r[n.col-1];return i==null||i===""?null:i}}function cr(e){return n=>{const r=Math.min(n.from.row,n.to.row),i=Math.min(n.from.col,n.to.col),x=Math.max(n.from.row,n.to.row),c=Math.max(n.from.col,n.to.col),l=lr(e);if(r>e.length||i>l)throw new _("REF");const u=Math.min(x,e.length),s=[];for(let a=r;a<=u;a++){const d=e[a-1],m=[];if(d!=null){const h=Math.min(c,d.length);for(let p=i;p<=h;p++){const g=d[p-1];m.push(g==null||g===""?null:g)}}s.push(m)}return s}}function ar(e){if(e==null||e==="")return null;if(typeof e=="number"||typeof e=="string"||typeof e=="boolean"||e instanceof Date)return e;throw new _("VALUE")}async function ut(e,n){if(typeof e!="string")throw new _("ERROR");const r=e.trim();if(r==="")throw new _("ERROR");const i=r.startsWith("=")?r.slice(1):r;tr(i);const[x,c]=await Promise.all([import("fast-formula-parser"),import("@formulajs/formulajs")]),l=x.default??x,u=l.FormulaError,s=new l({...n,functions:or(c,u)});let a;try{a=s.parse(i,{row:1,col:1,sheet:"Sheet1"})}catch(d){throw Oe(d,u)}if(a instanceof u)throw Oe(a,u);return ar(a)}async function ur(e,n){return ut(n,{onCell:ir(e),onRange:cr(e)})}const Ie=-1;async function dr(e,n){const r=Object.keys(e);return ut(n,{onVariable:i=>{const x=r.indexOf(i);return x===-1?null:{row:Ie,col:x+1}},onCell:i=>{if(i.row===Ie)return e[r[i.col-1]]??null;throw new _("REF")},onRange:()=>{throw new _("REF")}})}const dt={REF:"#REF!",VALUE:"#VALUE!",DIV0:"#DIV/0!",NAME:"#NAME?",ERROR:"#ERROR!",NA:"#N/A",NUM:"#NUM!",NULL:"#NULL!"};function ft(e){const n=e instanceof _?e.code:"ERROR";return dt[n]}async function fr(e,n){return e.length===0?n.map(r=>({id:typeof(r==null?void 0:r.id)=="string"?r.id:"(unknown)",label:(r==null?void 0:r.label)??"(unknown)",value:null,error:dt.ERROR})):Promise.all(n.map(async r=>{try{if(!r||typeof r.label!="string"||typeof r.expression!="string"||typeof r.id!="string")throw new _("ERROR");return{id:r.id,label:r.label,value:await ur(e,r.expression)}}catch(i){return{id:typeof(r==null?void 0:r.id)=="string"?r.id:"(unknown)",label:(r==null?void 0:r.label)??"(unknown)",value:null,error:ft(i)}}}))}function xr(e,n={}){if(n.columnHeader&&n.rowHeader)throw new Error("x-spreadsheet: columnHeader and rowHeader cannot both be true — pick one orientation for the persisted sheet shape.");return n.columnHeader?hr(e):n.rowHeader?pr(e):e}function xt(e){return e==null||e===""?null:e instanceof Date?e.toISOString():String(e)}function ht(e,n){const r=new Set;for(const i of e)if(i!=null){if(r.has(i))throw new Error(`x-spreadsheet: duplicate ${n} value "${i}" — every ${n==="columnHeader"?"column header":"column-A value"} must be unique to shape as records.`);r.add(i)}}function hr(e){const[n,...r]=e;if(!n)return[];const i=n.map(xt);return ht(i,"columnHeader"),r.map(x=>{const c=Object.create(null);return i.forEach((l,u)=>{l!=null&&(c[l]=x[u]??null)}),c})}function pr(e){const n=e.map(x=>xt(x[0]));ht(n,"rowHeader");const r=Math.max(0,...e.map(x=>x.length)),i=Math.max(0,r-1);return Array.from({length:i},(x,c)=>{const l=c+1,u=Object.create(null);return n.forEach((s,a)=>{s!=null&&(u[s]=e[a][l]??null)}),u})}function Ne(e){return!Array.isArray(e[0])}async function mr(e,n,r={}){const i=await fr(e,n),x=Object.create(null);for(const{id:c,label:l,value:u,error:s}of i)x[c]=s===void 0?{label:l,value:u}:{label:l,value:u,error:s};return r.persistSheet===!1?{derivations:x}:{sheet:xr(e,r),derivations:x}}const gr=".xlsx,.xls,.csv,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel,text/csv",Tr=10*1024*1024,fe=200,ke=50,yr=[];function me(e){return e==null||e===""?"":e instanceof Date?e.toLocaleDateString():String(e)}const br=({data:e,handleChange:n,path:r,label:i,required:x,schema:c,enabled:l,readonly:u,errors:s,visible:a=!0})=>{se(a,r,n,null);const d=!s||s.length===0,m=Vt(l,u),h=(c==null?void 0:c["x-spreadsheet"])??{},p=(c==null?void 0:c["x-evaluate"])??yr,g=h.accept??gr,S=h.maxSize??Tr,R=h.persistSheet!==!1,b=h.columnHeader===!0,w=h.rowHeader===!0,N=h.showSheet!==!1,U=h.sheetName,A=e??null,[H,V]=v.useState(()=>A!=null&&A.sheet||Object.keys((A==null?void 0:A.derivations)??{}).length>0?"ready":"empty"),[O,E]=v.useState(null),[L,P]=v.useState(!1),[re,Y]=v.useState(null),ne=v.useRef(null),J=(A==null?void 0:A.sheet)??null,X=re??(J&&!Ne(J)?J:null),Z=re==null&&J&&Ne(J)?J:null,ce=(A==null?void 0:A.derivations)??{},te=X!=null||A!=null,ie=v.useCallback(async f=>{if(E(null),f.size>S){E(`File exceeds the ${ue(S)} limit.`);return}if(!g.split(",").map(k=>k.trim()).some(k=>k==="*"||k==="*/*"?!0:k.endsWith("/*")?f.type.startsWith(k.slice(0,-1)):k.startsWith(".")?f.name.toLowerCase().endsWith(k.toLowerCase()):f.type===k)){E(`Invalid type. Accepted: ${de(g)}`);return}V("parsing");let Q;try{const k=await f.arrayBuffer();Q=Jt(k,U).matrix}catch(k){V("error"),E(k instanceof we?k.message:"This doesn't look like a valid spreadsheet. Please check the file and try again.");return}Y(Q);let oe;try{oe=await mr(Q,p,{persistSheet:R,columnHeader:b,rowHeader:w})}catch(k){V("error"),E(k instanceof Error?k.message:"Failed to process the uploaded spreadsheet.");return}n(r,oe),V("ready")},[g,S,R,b,w,U,p,r,n]);if(a===!1)return null;if(b&&w)return t.jsxs(o.Box,{mb:"4",children:[t.jsx(o.Text,{as:"label",size:"2",weight:"bold",children:i}),t.jsx(o.Text,{size:"2",color:"red",style:{display:"block"},children:"Invalid x-spreadsheet config: columnHeader and rowHeader cannot both be true — pick one orientation."})]});if(!m&&!te)return null;const T=f=>{f.preventDefault(),f.stopPropagation(),m&&P(f.type==="dragenter"||f.type==="dragover")},I=f=>{var j;f.preventDefault(),f.stopPropagation(),P(!1),m&&(j=f.dataTransfer.files)!=null&&j[0]&&ie(f.dataTransfer.files[0])},M=f=>{var j;(j=f.target.files)!=null&&j[0]&&(ie(f.target.files[0]),f.target.value="")},C=()=>{m&&(Y(null),E(null),V("empty"),n(r,null))},z=b?1:0,K=w?1:0,q=X?X.slice(z):[],W=q.slice(0,fe),xe=Math.min(ke,Math.max(0,...W.map(f=>Math.max(0,f.length-K)))),he=Array.from({length:xe},(f,j)=>j+K),be=N&&X==null&&Z==null&&A!=null,ge="",ve=w&&!b,Te=Z?Z.slice(0,fe):[],pe=Array.from(new Set(Te.flatMap(f=>Object.keys(f)))).slice(0,ke);return t.jsxs(o.Box,{mb:"4",children:[t.jsxs(o.Flex,{align:"center",justify:"between",mb:"2",children:[t.jsxs(o.Flex,{align:"center",gap:"1",children:[t.jsxs(o.Text,{as:"label",size:"2",weight:"bold",children:[i,x&&t.jsx(o.Text,{color:"red",children:" *"})]}),te&&m&&t.jsxs(t.Fragment,{children:[t.jsx(o.Tooltip,{content:"Replace spreadsheet",children:t.jsx(o.IconButton,{variant:"ghost",size:"1",onClick:()=>{var f;return(f=ne.current)==null?void 0:f.click()},"aria-label":"Replace spreadsheet",children:t.jsx(ee.UploadIcon,{})})}),t.jsx(o.Tooltip,{content:"Remove spreadsheet",children:t.jsx(o.IconButton,{variant:"ghost",size:"1",color:"gray",onClick:C,"aria-label":"Remove spreadsheet",children:t.jsx(ee.Cross2Icon,{})})})]})]}),t.jsxs(o.Text,{size:"1",color:"gray",children:[ue(S)," max · ",de(g)]})]}),te&&O&&t.jsx(o.Text,{size:"2",color:"red",mb:"2",style:{display:"block"},children:O}),t.jsx("input",{ref:ne,type:"file",style:{display:"none"},accept:g,onChange:M}),m&&!te&&t.jsx("div",{role:"button",tabIndex:0,onClick:()=>{var f;return(f=ne.current)==null?void 0:f.click()},onKeyDown:f=>{var j;(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),(j=ne.current)==null||j.click())},onDragEnter:T,onDragLeave:T,onDragOver:T,onDrop:I,style:{cursor:"pointer"},className:["border-2 border-dashed rounded-lg p-6 text-center","transition-all duration-200 ease-in-out",L?"border-blue-500 bg-blue-50":O?"border-red-300 bg-red-50":"border-gray-300 hover:border-blue-400 hover:bg-gray-50"].join(" "),children:t.jsx(o.Flex,{direction:"column",align:"center",gap:"2",children:H==="parsing"?t.jsxs(t.Fragment,{children:[t.jsx(o.Spinner,{size:"3"}),t.jsx(o.Text,{size:"2",color:"gray",children:"Parsing spreadsheet…"})]}):O?t.jsxs(t.Fragment,{children:[t.jsx(ee.ExclamationTriangleIcon,{style:{width:32,height:32,color:"var(--red-9)"}}),t.jsx(o.Text,{size:"2",color:"red",weight:"medium",children:O}),t.jsx(o.Text,{size:"1",color:"gray",children:"Click to try again"})]}):t.jsxs(t.Fragment,{children:[t.jsx(ee.UploadIcon,{style:{width:32,height:32,color:"var(--gray-8)"}}),t.jsx(o.Text,{size:"2",weight:"medium",children:"Click to upload or drag and drop"}),t.jsxs(o.Text,{size:"1",color:"gray",children:[ue(S)," max · ",de(g)]})]})})}),X&&N&&t.jsxs(o.Box,{mt:"3",children:[t.jsx(o.Box,{style:{overflow:"auto",maxHeight:420},children:t.jsxs(o.Table.Root,{variant:"surface",size:"1",children:[!ve&&t.jsx(o.Table.Header,{children:t.jsxs(o.Table.Row,{children:[t.jsx(o.Table.ColumnHeaderCell,{children:ge}),he.map(f=>{var j;return t.jsx(o.Table.ColumnHeaderCell,{children:b?me((j=X[0])==null?void 0:j[f]):Kt(f)},f)})]})}),t.jsx(o.Table.Body,{children:W.map((f,j)=>{var Q;const G=z+j;return t.jsxs(o.Table.Row,{children:[t.jsx(o.Table.RowHeaderCell,{style:w?{fontWeight:700,background:"var(--gray-a3)"}:void 0,children:w?me((Q=X[G])==null?void 0:Q[0]):b?"":G+1}),he.map(oe=>t.jsx(o.Table.Cell,{children:me(f[oe])},oe))]},j)})})]})}),q.length>fe&&t.jsxs(o.Text,{size:"1",color:"gray",mt:"1",style:{display:"block"},children:["Showing first ",fe," of ",q.length," rows"]})]}),Z&&N&&t.jsxs(o.Box,{mt:"3",children:[t.jsx(o.Box,{style:{overflow:"auto",maxHeight:420},children:t.jsxs(o.Table.Root,{variant:"surface",size:"1",children:[t.jsx(o.Table.Header,{children:t.jsxs(o.Table.Row,{children:[t.jsx(o.Table.ColumnHeaderCell,{}),pe.map(f=>t.jsx(o.Table.ColumnHeaderCell,{children:f},f))]})}),t.jsx(o.Table.Body,{children:Te.map((f,j)=>t.jsxs(o.Table.Row,{children:[t.jsx(o.Table.RowHeaderCell,{children:j+1}),pe.map(G=>t.jsx(o.Table.Cell,{children:me(f[G])},G))]},j))})]})}),Z.length>fe&&t.jsxs(o.Text,{size:"1",color:"gray",mt:"1",style:{display:"block"},children:["Showing first ",fe," of ",Z.length," rows"]})]}),be&&t.jsx(o.Text,{size:"2",color:"gray",mt:"3",style:{display:"block"},children:"Sheet preview not stored for this field — re-upload to view contents."}),Object.keys(ce).length>0&&t.jsxs(o.Box,{mt:"3",children:[t.jsx(o.Text,{size:"2",weight:"bold",as:"div",mb:"1",children:"Computed values"}),t.jsx(o.Flex,{direction:"column",gap:"1",children:Object.entries(ce).map(([f,j])=>t.jsxs(o.Flex,{justify:"between",children:[t.jsx(o.Text,{size:"2",children:j.label}),j.error?t.jsx(o.Text,{size:"2",color:"red",children:j.error}):t.jsx(o.Text,{size:"2",children:me(j.value)})]},f))})]}),!d&&t.jsx(o.Text,{color:"red",size:"1",mt:"2",style:{display:"block"},children:le(s,i)})]})},pt=B.withJsonFormsControlProps(br),mt=y.rankWith(10,y.schemaMatches(e=>e.type==="object"&&typeof e["x-spreadsheet"]=="object"));function vr(e,n,r){const i={};for(const[x,c]of Object.entries(r)){const{path:l,default:u}=typeof c=="string"?{path:c,default:void 0}:c,s=n?`${n}.${l}`:l,a=y.Resolve.data(e,s);if(a==null){if(u===void 0)return;i[x]=u}else i[x]=a}return i}async function jr(e,n){try{return{status:"ok",value:await dr(e,n)}}catch(r){return{status:"error",error:ft(r)}}}function wr(e,n){return e==null?"":typeof e=="number"?e.toFixed(Cr(n)):e instanceof Date?e.toLocaleDateString():String(e)}function Cr(e){return Number.isFinite(e)?Math.min(100,Math.max(0,Math.trunc(e))):0}const Le="{value}",Rr=2,Er={},Sr=({data:e,handleChange:n,path:r,label:i,schema:x,visible:c=!0})=>{var H;se(c,r,n,null);const l=x==null?void 0:x["x-computed"],u=(l==null?void 0:l.inputs)??Er,s=(l==null?void 0:l.formula)??"",a=(l==null?void 0:l.format)??Le,d=(l==null?void 0:l.decimals)??Rr,m=B.useJsonForms(),h=r.split(".").slice(0,-1).join("."),p=vr((H=m.core)==null?void 0:H.data,h,u),g=p?JSON.stringify(p):null,S=m.readonly===!0,[R,b]=v.useState(()=>typeof e=="number"?"ok":"unavailable"),[w,N]=v.useState(()=>typeof e=="number"?e:null),[U,A]=v.useState(null);return v.useEffect(()=>{if(!c)return;let V=!1;const O=E=>{S||E!==(e??null)&&n(r,E)};if(p===void 0){b("unavailable"),A(null),N(null),O(null);return}return b(E=>E==="ok"?E:"loading"),jr(p,s).then(E=>{if(V)return;const L=E.status==="ok"&&typeof E.value=="number"&&Number.isFinite(E.value)?E.value:null;if(L===null){b("error"),A(E.status==="error"?E.error??"Unable to compute value.":"Computed value must be a number."),N(null),O(null);return}b("ok"),A(null),N(L),O(L)}),()=>{V=!0}},[g,s,c,S]),c===!1?null:t.jsx(o.Box,{mb:"4",children:t.jsxs(o.Flex,{direction:"column",gap:"1",children:[t.jsx(o.Text,{as:"label",size:"2",weight:"bold",children:i}),R==="unavailable"?t.jsx(o.Text,{size:"2",color:"gray",children:"Not yet available."}):R==="loading"?t.jsxs(o.Flex,{align:"center",gap:"2",children:[t.jsx(o.Spinner,{size:"1"}),t.jsx(o.Text,{size:"2",color:"gray",children:"Computing…"})]}):R==="error"?t.jsx(o.Text,{size:"2",color:"red",children:U}):t.jsx(o.Text,{size:"2",children:a.split(Le).join(wr(w,d))}),x.description&&t.jsx(o.Text,{size:"1",color:"gray",children:x.description})]})})},gt=B.withJsonFormsControlProps(Sr),Tt=y.rankWith(5,y.schemaMatches(e=>{const n=e["x-computed"];return e.type==="number"&&typeof n=="object"&&n!==null})),Ar=({data:e,path:n,schema:r,uischema:i,enabled:x,visible:c,addItem:l,removeItems:u,rootSchema:s,arraySchema:a})=>{const d=a?r:r.items,m=a||r;if(c===!1||!d||typeof d!="object"||Array.isArray(d))return null;const h=d,p=Array.isArray(e)?e:[],g=m.title||"Array Items",S=()=>{const b=y.createDefaultValue(h,s);l&&l(n,b)()},R=b=>{if(u){const w=u(n,[b]);w&&w()}};return t.jsx(o.Box,{mb:"6",children:t.jsxs(o.Flex,{direction:"column",gap:"4",children:[t.jsx(o.Text,{as:"div",size:"4",weight:"bold",children:g}),p.length===0&&t.jsx(o.Box,{py:"4",px:"4",style:{backgroundColor:"var(--gray-3)",borderRadius:"var(--radius-3)"},children:t.jsx(o.Text,{size:"2",color:"gray",children:"No items have been added yet."})}),p.map((b,w)=>{var U;const N=`${n}.${w}`;return t.jsx(o.Card,{size:"3",variant:"surface",children:t.jsxs(o.Flex,{direction:"column",gap:"4",children:[t.jsxs(o.Flex,{justify:"between",align:"center",children:[t.jsxs(o.Text,{size:"3",weight:"bold",children:["Item ",w+1]}),x&&t.jsxs(o.Button,{type:"button",color:"red",variant:"soft",onClick:()=>R(w),title:"Remove item",children:[t.jsx(ee.TrashIcon,{}),"Remove"]})]}),t.jsx(o.Box,{children:t.jsx(B.JsonFormsDispatch,{schema:h,uischema:((U=i.options)==null?void 0:U.detail)||(h.type==="object"||h.properties?{type:"VerticalLayout",elements:Object.keys(h.properties||{}).map(A=>({type:"Control",scope:`#/properties/${A}`}))}:{type:"Control",scope:"#"}),path:N,enabled:x,renderers:void 0,cells:void 0})})]})},N)}),x&&t.jsx(o.Box,{mt:"2",children:t.jsxs(o.Button,{type:"button",variant:"surface",onClick:S,children:[t.jsx(ee.PlusIcon,{}),"Add Item"]})})]})})},Ce=B.withJsonFormsArrayControlProps(Ar),yt=y.rankWith(3,y.isObjectArrayControl),bt=({uischema:e,visible:n})=>{const r=e;return n===!1?null:t.jsx(o.Box,{mb:"4",children:t.jsx(o.Heading,{size:"4",children:r.text})})},vt=y.rankWith(1,y.uiTypeIs("Label")),Fr=y.rankWith(3,y.isPrimitiveArrayControl),Or=[{tester:Pe,renderer:kt},{tester:We,renderer:Lt},{tester:_e,renderer:Mt},{tester:Je,renderer:zt},{tester:qe,renderer:Xe},{tester:Ge,renderer:Dt},{tester:Ze,renderer:Wt},{tester:et,renderer:Qe},{tester:rt,renderer:tt},{tester:ot,renderer:nt},{tester:lt,renderer:st},{tester:ct,renderer:it},{tester:mt,renderer:pt},{tester:Tt,renderer:gt},{tester:yt,renderer:Ce},{tester:Fr,renderer:Ce},{tester:vt,renderer:bt}];exports.ArrayControl=Ce;exports.ArrayControlTester=yt;exports.BooleanControl=$e;exports.BooleanControlTester=_e;exports.CategorizationLayoutRenderer=st;exports.CategorizationLayoutTester=lt;exports.ComputedControl=gt;exports.ComputedControlTester=Tt;exports.DateControl=Ye;exports.DateControlTester=Ze;exports.FileControl=it;exports.FileControlTester=ct;exports.GroupLayoutRenderer=nt;exports.GroupLayoutTester=ot;exports.HorizontalLayoutRenderer=tt;exports.HorizontalLayoutTester=rt;exports.LabelRenderer=bt;exports.LabelTester=vt;exports.NumberControl=He;exports.NumberControlTester=We;exports.RadioControl=Ve;exports.RadioControlTester=Je;exports.SearchSelectControl=Xe;exports.SearchSelectControlTester=qe;exports.SearchServiceProvider=Nt;exports.SelectControl=Ke;exports.SelectControlTester=Ge;exports.SpreadsheetControl=pt;exports.SpreadsheetControlTester=mt;exports.TextControl=Be;exports.TextControlTester=Pe;exports.UploadProvider=It;exports.VerticalLayoutRenderer=Qe;exports.VerticalLayoutTester=et;exports.radixRenderers=Or;exports.useSearchService=Ue;exports.useUpload=ze;