@overmap-ai/forms 1.0.17-master.2 → 1.0.17-master.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/forms/typings.d.ts +1 -2
- package/dist/forms.js +32 -8
- package/dist/forms.umd.cjs +1 -1
- package/package.json +5 -2
- package/.husky/pre-commit +0 -6
- package/.prettierrc.json +0 -10
- package/.storybook/StoryDecorator.tsx +0 -22
- package/.storybook/main.ts +0 -20
- package/.storybook/palettes/green.css +0 -66
- package/.storybook/palettes/red.css +0 -66
- package/.storybook/preview.css +0 -39
- package/.storybook/preview.tsx +0 -31
- package/.storybook/tailwind-theme/accentPalette.css +0 -181
- package/.storybook/tailwind-theme/backgrounds.css +0 -11
- package/.storybook/tailwind-theme/basePalette.css +0 -178
- package/dev/publish-alpha.sh +0 -13
- package/dev/publish-patch.sh +0 -3
- package/eslint.config.js +0 -56
- package/src/ColorPicker/ColorPicker.tsx +0 -47
- package/src/ColorPicker/index.ts +0 -1
- package/src/FileBadge/FileBadge.tsx +0 -27
- package/src/FileBadge/index.ts +0 -1
- package/src/FileCard/FileCard.stories.tsx +0 -69
- package/src/FileCard/FileCard.tsx +0 -53
- package/src/FileCard/index.ts +0 -1
- package/src/FileIcon/FileIcon.tsx +0 -31
- package/src/FileIcon/index.ts +0 -1
- package/src/FileViewer/FileViewerProvider.stories.tsx +0 -50
- package/src/FileViewer/FileViewerProvider.tsx +0 -72
- package/src/FileViewer/context.ts +0 -11
- package/src/FileViewer/index.ts +0 -3
- package/src/FileViewer/typings.ts +0 -5
- package/src/ImageCard/ImageCard.stories.tsx +0 -94
- package/src/ImageCard/ImageCard.tsx +0 -82
- package/src/ImageCard/index.ts +0 -1
- package/src/ImageMarkup/ImageMarkup.stories.tsx +0 -65
- package/src/ImageMarkup/ImageMarkup.tsx +0 -268
- package/src/ImageMarkup/index.ts +0 -1
- package/src/ImageViewer/ImageViewer.stories.tsx +0 -57
- package/src/ImageViewer/ImageViewer.tsx +0 -124
- package/src/ImageViewer/constants.ts +0 -1
- package/src/ImageViewer/index.ts +0 -2
- package/src/PDFViewer/PDFViewer.stories.tsx +0 -55
- package/src/PDFViewer/PDFViewer.tsx +0 -170
- package/src/PDFViewer/constants.ts +0 -1
- package/src/PDFViewer/index.ts +0 -2
- package/src/SpreadsheetViewer/SpreadsheetViewer.stories.tsx +0 -55
- package/src/SpreadsheetViewer/SpreadsheetViewer.tsx +0 -162
- package/src/SpreadsheetViewer/constants.ts +0 -8
- package/src/SpreadsheetViewer/index.ts +0 -2
- package/src/forms/builder/DropDispatch.ts +0 -84
- package/src/forms/builder/FieldActions.tsx +0 -155
- package/src/forms/builder/FieldBuilder.tsx +0 -386
- package/src/forms/builder/FieldSectionWithActions.tsx +0 -260
- package/src/forms/builder/FieldWithActions.tsx +0 -129
- package/src/forms/builder/FieldsEditor.tsx +0 -180
- package/src/forms/builder/FormBuilder.stories.tsx +0 -105
- package/src/forms/builder/FormBuilder.tsx +0 -237
- package/src/forms/builder/constants.ts +0 -18
- package/src/forms/builder/hooks.tsx +0 -24
- package/src/forms/builder/index.ts +0 -2
- package/src/forms/builder/typings.ts +0 -18
- package/src/forms/builder/utils.ts +0 -229
- package/src/forms/constants.ts +0 -9
- package/src/forms/constantsJsx.tsx +0 -67
- package/src/forms/fields/BaseField/BaseField.ts +0 -152
- package/src/forms/fields/BaseField/hooks.tsx +0 -60
- package/src/forms/fields/BaseField/index.ts +0 -4
- package/src/forms/fields/BaseField/layouts.tsx +0 -100
- package/src/forms/fields/BaseField/typings.ts +0 -9
- package/src/forms/fields/BooleanField/BooleanField.tsx +0 -48
- package/src/forms/fields/BooleanField/BooleanInput.tsx +0 -54
- package/src/forms/fields/BooleanField/index.ts +0 -2
- package/src/forms/fields/CustomField/CustomField.tsx +0 -45
- package/src/forms/fields/CustomField/FieldInputClonerField/FieldInputCloner.tsx +0 -25
- package/src/forms/fields/CustomField/FieldInputClonerField/FieldInputClonerField.tsx +0 -26
- package/src/forms/fields/CustomField/FieldInputClonerField/index.ts +0 -3
- package/src/forms/fields/CustomField/FieldInputClonerField/typings.ts +0 -8
- package/src/forms/fields/CustomField/index.ts +0 -1
- package/src/forms/fields/DateField/DateField.tsx +0 -42
- package/src/forms/fields/DateField/DateInput.tsx +0 -39
- package/src/forms/fields/DateField/index.ts +0 -2
- package/src/forms/fields/FieldSection/FieldSection.tsx +0 -173
- package/src/forms/fields/FieldSection/FieldSectionLayout.tsx +0 -56
- package/src/forms/fields/FieldSection/index.ts +0 -1
- package/src/forms/fields/MultiStringField/MultiStringField.tsx +0 -90
- package/src/forms/fields/MultiStringField/MultiStringInput.tsx +0 -207
- package/src/forms/fields/MultiStringField/index.ts +0 -2
- package/src/forms/fields/NumberField/NumberField.tsx +0 -173
- package/src/forms/fields/NumberField/NumberInput.tsx +0 -44
- package/src/forms/fields/NumberField/index.ts +0 -2
- package/src/forms/fields/QrField/QrField.tsx +0 -38
- package/src/forms/fields/QrField/QrInput.module.sass +0 -5
- package/src/forms/fields/QrField/QrInput.tsx +0 -144
- package/src/forms/fields/QrField/index.ts +0 -2
- package/src/forms/fields/SelectField/BaseSelectField.ts +0 -73
- package/src/forms/fields/SelectField/MultiSelectField.tsx +0 -53
- package/src/forms/fields/SelectField/MultiSelectInput.tsx +0 -80
- package/src/forms/fields/SelectField/SelectField.tsx +0 -49
- package/src/forms/fields/SelectField/SelectInput.tsx +0 -69
- package/src/forms/fields/SelectField/index.ts +0 -4
- package/src/forms/fields/StringOrTextFields/StringField/StringField.tsx +0 -61
- package/src/forms/fields/StringOrTextFields/StringField/StringInput.tsx +0 -41
- package/src/forms/fields/StringOrTextFields/StringField/index.ts +0 -2
- package/src/forms/fields/StringOrTextFields/StringOrTextField.ts +0 -143
- package/src/forms/fields/StringOrTextFields/TextField/TextField.tsx +0 -52
- package/src/forms/fields/StringOrTextFields/TextField/TextInput.tsx +0 -42
- package/src/forms/fields/StringOrTextFields/TextField/index.ts +0 -2
- package/src/forms/fields/StringOrTextFields/index.ts +0 -2
- package/src/forms/fields/UploadField/UploadField.tsx +0 -156
- package/src/forms/fields/UploadField/UploadInput.tsx +0 -220
- package/src/forms/fields/UploadField/index.ts +0 -2
- package/src/forms/fields/UploadField/utils.ts +0 -17
- package/src/forms/fields/constants.ts +0 -43
- package/src/forms/fields/hooks.tsx +0 -26
- package/src/forms/fields/index.ts +0 -12
- package/src/forms/fields/typings.ts +0 -45
- package/src/forms/fields/utils.ts +0 -125
- package/src/forms/index.ts +0 -5
- package/src/forms/renderer/FormRenderer/FormRenderer.stories.tsx +0 -142
- package/src/forms/renderer/FormRenderer/FormRenderer.tsx +0 -135
- package/src/forms/renderer/PatchForm/Field.tsx +0 -41
- package/src/forms/renderer/PatchForm/PatchForm.stories.tsx +0 -91
- package/src/forms/renderer/PatchForm/Provider.tsx +0 -119
- package/src/forms/renderer/PatchForm/index.ts +0 -2
- package/src/forms/renderer/index.ts +0 -2
- package/src/forms/typings.ts +0 -162
- package/src/forms/utils.ts +0 -69
- package/src/index.ts +0 -11
- package/src/vite-env.d.ts +0 -1
- package/tailwind.config.ts +0 -8
- package/tsconfig.json +0 -26
- package/tsconfig.node.json +0 -10
- package/vite.config.ts +0 -23
package/dist/forms/typings.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Marker } from '@overmap-ai/core';
|
|
2
1
|
import { HTMLInputTypeAttribute } from 'react';
|
|
3
2
|
import { AnyField, BaseField } from './fields';
|
|
4
3
|
/**
|
|
@@ -28,7 +27,7 @@ export interface BaseSerializedField<TIdentifier extends FieldTypeIdentifier = F
|
|
|
28
27
|
image?: File | Promise<File>;
|
|
29
28
|
}
|
|
30
29
|
/** All the possible field values */
|
|
31
|
-
export type FieldValue = string | number | boolean | string[] | File[] | Date |
|
|
30
|
+
export type FieldValue = string | number | boolean | string[] | File[] | Date | null;
|
|
32
31
|
export interface SerializedCondition<TValue extends FieldValue = FieldValue> {
|
|
33
32
|
identifier: string;
|
|
34
33
|
value: TValue;
|
package/dist/forms.js
CHANGED
|
@@ -1362,8 +1362,14 @@ const Ii = F((t) => {
|
|
|
1362
1362
|
u.disconnect();
|
|
1363
1363
|
};
|
|
1364
1364
|
}, [f]), /* @__PURE__ */ l(Ke, { open: !0, onOpenChange: e, children: /* @__PURE__ */ v(Ye, { children: [
|
|
1365
|
-
/* @__PURE__ */ l(
|
|
1366
|
-
|
|
1365
|
+
/* @__PURE__ */ l(
|
|
1366
|
+
Qe,
|
|
1367
|
+
{
|
|
1368
|
+
className: "light:bg-(--black-a6) fixed inset-0 dark:bg-(--black-a8)",
|
|
1369
|
+
"data-floating-content": ""
|
|
1370
|
+
}
|
|
1371
|
+
),
|
|
1372
|
+
/* @__PURE__ */ l(Je, { className: "fixed inset-0", "data-floating-content": "", children: /* @__PURE__ */ v("div", { className: "flex h-full w-full flex-col", children: [
|
|
1367
1373
|
/* @__PURE__ */ l("div", { className: "flex h-max w-full items-center bg-(--color-background) p-2", children: /* @__PURE__ */ l(ge, { className: "w-full", accentColor: "base", variant: "soft", children: /* @__PURE__ */ v("div", { className: "grid w-full grid-cols-3", children: [
|
|
1368
1374
|
/* @__PURE__ */ v("div", { className: "flex justify-start gap-2 items-center", children: [
|
|
1369
1375
|
/* @__PURE__ */ l(A, { onClick: e, "aria-label": "close", children: /* @__PURE__ */ l(L, { icon: "RiCloseLine" }) }),
|
|
@@ -1419,8 +1425,14 @@ const Il = {
|
|
|
1419
1425
|
e && e(n);
|
|
1420
1426
|
}, [n, e]);
|
|
1421
1427
|
return /* @__PURE__ */ l(Ke, { open: !0, onOpenChange: i, children: /* @__PURE__ */ v(Ye, { children: [
|
|
1422
|
-
/* @__PURE__ */ l(
|
|
1423
|
-
|
|
1428
|
+
/* @__PURE__ */ l(
|
|
1429
|
+
Qe,
|
|
1430
|
+
{
|
|
1431
|
+
className: "light:bg-(--black-a6) fixed inset-0 dark:bg-(--black-a8)",
|
|
1432
|
+
"data-floating-content": ""
|
|
1433
|
+
}
|
|
1434
|
+
),
|
|
1435
|
+
/* @__PURE__ */ l(Je, { className: "fixed inset-0", "data-floating-content": "", children: /* @__PURE__ */ v("div", { className: "flex h-full w-full flex-col items-center", children: [
|
|
1424
1436
|
/* @__PURE__ */ l("div", { className: "h-max w-full shrink-0 items-center bg-(--color-background) p-2", children: /* @__PURE__ */ l(ge, { className: "flex items-center gap-1", variant: "soft", accentColor: "base", children: /* @__PURE__ */ v("div", { className: "grid w-full grid-cols-3", children: [
|
|
1425
1437
|
/* @__PURE__ */ v("div", { className: "w-full gap-2 flex items-center", children: [
|
|
1426
1438
|
/* @__PURE__ */ l(A, { onClick: i, "aria-label": "close", children: /* @__PURE__ */ l(L, { icon: "RiCloseLine" }) }),
|
|
@@ -1519,8 +1531,14 @@ const Di = [
|
|
|
1519
1531
|
y !== 0 && d(o[y - 1]);
|
|
1520
1532
|
}, [c, o]);
|
|
1521
1533
|
return /* @__PURE__ */ l(Ke, { open: !0, onOpenChange: e, children: /* @__PURE__ */ v(Ye, { children: [
|
|
1522
|
-
/* @__PURE__ */ l(
|
|
1523
|
-
|
|
1534
|
+
/* @__PURE__ */ l(
|
|
1535
|
+
Qe,
|
|
1536
|
+
{
|
|
1537
|
+
className: "light:bg-(--black-a6) fixed inset-0 dark:bg-(--black-a8)",
|
|
1538
|
+
"data-floating-content": ""
|
|
1539
|
+
}
|
|
1540
|
+
),
|
|
1541
|
+
/* @__PURE__ */ l(Je, { className: "fixed inset-0", "data-floating-content": "", children: /* @__PURE__ */ v("div", { className: "flex h-full w-full flex-col overflow-hidden", children: [
|
|
1524
1542
|
/* @__PURE__ */ l("div", { className: "h-max w-full shrink-0 bg-(--color-background) p-2", children: /* @__PURE__ */ l(ge, { size: "md", variant: "soft", accentColor: "base", children: /* @__PURE__ */ v("div", { className: "grid w-full grid-cols-3", children: [
|
|
1525
1543
|
/* @__PURE__ */ v("div", { className: "flex gap-2 items-center", children: [
|
|
1526
1544
|
/* @__PURE__ */ l(A, { onClick: e, "aria-label": "close", children: /* @__PURE__ */ l(L, { icon: "RiCloseLine" }) }),
|
|
@@ -4593,8 +4611,14 @@ const fa = F((t) => {
|
|
|
4593
4611
|
St(n);
|
|
4594
4612
|
}, [n]);
|
|
4595
4613
|
return /* @__PURE__ */ l(Ke, { open: !0, onOpenChange: e, children: /* @__PURE__ */ v(Ye, { children: [
|
|
4596
|
-
/* @__PURE__ */ l(
|
|
4597
|
-
|
|
4614
|
+
/* @__PURE__ */ l(
|
|
4615
|
+
Qe,
|
|
4616
|
+
{
|
|
4617
|
+
className: "light:bg-(--black-a6) fixed inset-0 dark:bg-(--black-a8)",
|
|
4618
|
+
"data-floating-content": ""
|
|
4619
|
+
}
|
|
4620
|
+
),
|
|
4621
|
+
/* @__PURE__ */ l(Je, { className: "fixed inset-0", "data-floating-content": "", children: /* @__PURE__ */ v(Z, { children: [
|
|
4598
4622
|
u && /* @__PURE__ */ l(
|
|
4599
4623
|
"canvas",
|
|
4600
4624
|
{
|
package/dist/forms.umd.cjs
CHANGED
|
@@ -42,4 +42,4 @@
|
|
|
42
42
|
|
|
43
43
|
If you want to hide the \`${n.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
44
44
|
|
|
45
|
-
For more information, see https://radix-ui.com/primitives/docs/components/${n.docsSlug}`;return v.useEffect(()=>{t&&(document.getElementById(t)||console.error(e))},[e,t]),null},Po="DialogDescriptionWarning",Mo=({contentRef:t,descriptionId:n})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${ur(Po).contentName}}.`;return v.useEffect(()=>{var a;const o=(a=t.current)==null?void 0:a.getAttribute("aria-describedby");n&&o&&(document.getElementById(n)||console.warn(r))},[r,t,n]),null},Me=tr,Ae=ir,Oe=or,Be=ar;const jt=d.memo(t=>{const{file:n,onClose:e,onDelete:r}=t,{md:o}=u.useViewportSize(),a=d.useRef(null),l=d.useRef(null),s=d.useRef(null),p=d.useCallback(()=>{if(!l.current||!a.current||!s.current)return;const h=s.current.height-l.current.clientHeight,m=s.current.width-l.current.clientWidth;h>=0||m>=0?m>h?(a.current.style.width=`${l.current.clientWidth}px`,a.current.style.height="unset"):(a.current.style.height=`${l.current.clientHeight}px`,a.current.style.width="unset"):(a.current.style.width=`${s.current.width}px`,a.current.style.height=`${s.current.height}px`)},[]),c=d.useCallback(()=>{r&&r(n)},[n,r]),f=d.useCallback(()=>{U.downloadFile(n)},[n]);return d.useLayoutEffect(()=>{const h=new Image;h.onload=()=>{s.current={width:h.width,height:h.height},p()},h.src=URL.createObjectURL(n)},[p,n]),d.useLayoutEffect(()=>{if(!l.current)return;const h=new ResizeObserver(()=>{p()});return h.observe(l.current),()=>{h.disconnect()}},[p]),i.jsx(Me,{open:!0,onOpenChange:e,children:i.jsxs(Ae,{children:[i.jsx(Oe,{className:"light:bg-(--black-a6) fixed inset-0 dark:bg-(--black-a8)"}),i.jsx(Be,{className:"fixed inset-0",children:i.jsxs("div",{className:"flex h-full w-full flex-col",children:[i.jsx("div",{className:"flex h-max w-full items-center bg-(--color-background) p-2",children:i.jsx(u.ButtonGroup,{className:"w-full",accentColor:"base",variant:"soft",children:i.jsxs("div",{className:"grid w-full grid-cols-3",children:[i.jsxs("div",{className:"flex justify-start gap-2 items-center",children:[i.jsx(u.IconButton,{onClick:e,"aria-label":"close",children:i.jsx(u.RiIcon,{icon:"RiCloseLine"})}),i.jsx(u.IconButton,{onClick:f,"aria-label":"close",children:i.jsx(u.RiIcon,{icon:"RiDownload2Line"})})]}),i.jsx("div",{className:"flex justify-center",children:i.jsx(ze,{file:n,accentColor:"base",truncateLength:o?void 0:25})}),i.jsx("div",{className:"flex justify-end",children:!!r&&i.jsx(u.IconButton,{onClick:c,"aria-label":"close",children:i.jsx(u.RiIcon,{icon:"RiDeleteBin2Line"})})})]})})}),i.jsx("div",{className:"h-full w-full overflow-hidden p-5",children:i.jsx("div",{className:"flex h-full w-full items-center justify-center overflow-hidden",ref:l,children:i.jsx("img",{ref:a,src:URL.createObjectURL(n),alt:""})})})]})})]})})});jt.displayName="ImageViewer";const Ut=["application/pdf"];bt.pdfjs.GlobalWorkerOptions.workerSrc=new URL("pdfjs-dist/build/pdf.worker.min.js",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:xt&&xt.tagName.toUpperCase()==="SCRIPT"&&xt.src||new URL("forms.umd.cjs",document.baseURI).href).toString();const Ao={initial:.6,xs:.8,sm:.9,md:1,lg:1.1,xl:1.1},Wt=d.memo(t=>{const{file:n,onDelete:e,onClose:r}=t,[o,a]=d.useState(null),[l,s]=d.useState(0),[p,c]=d.useState(!1),{lg:f,size:h}=u.useViewportSize();d.useEffect(()=>{s(0),c(!1),a(null)},[n]);const m=d.useCallback(w=>{s(0),a(w)},[]),y=d.useCallback(()=>{c(!0)},[]),x=d.useCallback(()=>{!o||l===o.numPages-1||s(w=>w+1)},[l,o]),g=d.useCallback(()=>{U.downloadFile(n)},[n]),b=d.useCallback(()=>{l!==0&&s(w=>w-1)},[l]),E=d.useCallback(()=>{e&&e(n)},[n,e]);return i.jsx(Me,{open:!0,onOpenChange:r,children:i.jsxs(Ae,{children:[i.jsx(Oe,{className:"light:bg-(--black-a6) fixed inset-0 dark:bg-(--black-a8)"}),i.jsx(Be,{className:"fixed inset-0",children:i.jsxs("div",{className:"flex h-full w-full flex-col items-center",children:[i.jsx("div",{className:"h-max w-full shrink-0 items-center bg-(--color-background) p-2",children:i.jsx(u.ButtonGroup,{className:"flex items-center gap-1",variant:"soft",accentColor:"base",children:i.jsxs("div",{className:"grid w-full grid-cols-3",children:[i.jsxs("div",{className:"w-full gap-2 flex items-center",children:[i.jsx(u.IconButton,{onClick:r,"aria-label":"close",children:i.jsx(u.RiIcon,{icon:"RiCloseLine"})}),i.jsx(u.IconButton,{onClick:g,"aria-label":"download",children:i.jsx(u.RiIcon,{icon:"RiDownload2Line"})})]}),i.jsx("div",{className:"flex justify-center",children:i.jsx(ze,{file:n,accentColor:"base",truncateLength:f?void 0:25})}),i.jsx("div",{className:"flex justify-end",children:!!e&&i.jsx(u.IconButton,{onClick:E,"aria-label":"delete",children:i.jsx(u.RiIcon,{icon:"RiDeleteBin2Line"})})})]})})}),i.jsxs("div",{className:"relative flex h-full w-full flex-col items-center gap-2 p-3",children:[!o&&!p&&i.jsx(fr,{}),i.jsx("div",{className:"flex h-max max-h-full w-max max-w-full flex-col items-center justify-center overflow-auto [scrollbar-color:var(--base-6)_transparent] [scrollbar-width:thin]",children:i.jsxs(bt.Document,{className:"relative",file:n,onLoadSuccess:m,onLoadError:y,error:"",loading:"",children:[i.jsx(bt.Page,{scale:Ao[h],pageIndex:l}),!!o&&!p&&i.jsx("div",{className:"absolute top-0 z-[2] flex w-full justify-center py-2",children:i.jsxs(u.ButtonGroup,{variant:"solid",accentColor:"base",size:"sm",children:[i.jsx(u.IconButton,{onClick:b,"aria-label":"previous page",children:i.jsx(u.RiIcon,{icon:"RiArrowLeftLine"})}),i.jsxs(u.Badge,{accentColor:"base",style:{borderRadius:0},variant:"solid",children:[l+1,"/",o.numPages]}),i.jsx(u.IconButton,{onClick:x,"aria-label":"next-page",children:i.jsx(u.RiIcon,{icon:"RiArrowRightLine"})})]})})]})}),p&&i.jsx(hr,{})]})]})})]})})});Wt.displayName="PDFViewer";const fr=d.memo(()=>i.jsx("div",{className:"absolute flex h-full w-full items-center justify-center",children:i.jsx(u.Spinner,{})}));fr.displayName="SpinnerComponent";const hr=d.memo(()=>i.jsxs("div",{className:"flex h-[70%] w-[40%] flex-col items-center justify-center rounded-md border border-(--base-a6) bg-(--base-2)",children:[i.jsx(u.RiIcon,{icon:"RiFileWarningLine",size:40}),i.jsx("span",{className:"text-sm font-light text-(--accent-a11)","data-accent-color":"base",children:"Failed to load"})]}));hr.displayName="ErrorComponent";const qt=["text/csv","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-excel"],Ht=d.memo(t=>{const{file:n,onClose:e,onDelete:r}=t,{md:o}=u.useViewportSize(),[a,l]=d.useState([]),[s,p]=d.useState({}),[c,f]=d.useState(),[h,m]=d.useState({rowLabels:[],columnLabels:[],data:[[]]}),y=d.useMemo(()=>d.lazy(()=>import("react-spreadsheet")),[n,c]);d.useEffect(()=>{n.arrayBuffer().then(w=>{const{SheetNames:S,Sheets:I}=In.read(w);l(S),p(I),f(S[0])})},[n]),d.useEffect(()=>{if(!c)return;const w=s[c],S=In.utils.sheet_to_json(w),I=Object.keys(S[0]??{}).splice(1),F=S.map(T=>Object.values(T)[0]),L=S.map(T=>I.map(D=>({value:T[D],readOnly:!0})));m({rowLabels:F,columnLabels:I,data:L})},[c,s]);const x=d.useCallback(()=>{r&&r(n)},[n,r]),g=d.useCallback(()=>{U.downloadFile(n)},[n]),b=d.useCallback(()=>{if(!c)throw new Error(`Expected an activeSheet, got ${c}`);const w=a.indexOf(c);if(w<0)throw new Error(`Expected activeSheet to be present in sheets, ${c} not found in ${a.join(", ")}`);w!==a.length-1&&f(a[w+1])},[c,a]),E=d.useCallback(()=>{if(!c)throw new Error(`Expected an activeSheet, got ${c}`);const w=a.indexOf(c);if(w<0)throw new Error(`Expected activeSheet to be present in sheets, ${c} not found in ${a.join(", ")}`);w!==0&&f(a[w-1])},[c,a]);return i.jsx(Me,{open:!0,onOpenChange:e,children:i.jsxs(Ae,{children:[i.jsx(Oe,{className:"light:bg-(--black-a6) fixed inset-0 dark:bg-(--black-a8)"}),i.jsx(Be,{className:"fixed inset-0",children:i.jsxs("div",{className:"flex h-full w-full flex-col overflow-hidden",children:[i.jsx("div",{className:"h-max w-full shrink-0 bg-(--color-background) p-2",children:i.jsx(u.ButtonGroup,{size:"md",variant:"soft",accentColor:"base",children:i.jsxs("div",{className:"grid w-full grid-cols-3",children:[i.jsxs("div",{className:"flex gap-2 items-center",children:[i.jsx(u.IconButton,{onClick:e,"aria-label":"close",children:i.jsx(u.RiIcon,{icon:"RiCloseLine"})}),i.jsx(u.IconButton,{onClick:g,"aria-label":"download",children:i.jsx(u.RiIcon,{icon:"RiDownload2Line"})})]}),i.jsx("div",{className:"flex justify-center",children:i.jsx(ze,{file:n,accentColor:"base",truncateLength:o?void 0:25})}),i.jsx("div",{className:"flex justify-end gap-2",children:!!r&&i.jsx(u.IconButton,{"aria-label":"delete",onClick:x,children:i.jsx(u.RiIcon,{icon:"RiDeleteBin2Line"})})})]})})}),i.jsx("div",{className:"flex h-full w-full flex-col items-center gap-3 overflow-hidden p-2",children:i.jsxs(d.Suspense,{fallback:i.jsx(u.Spinner,{}),children:[i.jsx("div",{className:"flex h-max max-h-[calc(100%-50px)] w-max max-w-full overflow-auto [scrollbar-color:var(--base-6)_transparent] [scrollbar-width:thin]",children:i.jsx(y,{className:"z-[1] h-full",data:h.data,rowLabels:h.rowLabels,columnLabels:h.columnLabels})}),i.jsx("div",{className:"flex h-max shrink-0 bg-(--base-2)",children:i.jsxs(u.ButtonGroup,{className:"flex items-center",variant:"solid",accentColor:"base",size:"sm",children:[i.jsx(u.IconButton,{"aria-label":"previous",onClick:E,children:i.jsx(u.RiIcon,{icon:"RiArrowLeftLine"})}),i.jsx(u.Badge,{variant:"solid",size:"sm",style:{borderRadius:0},accentColor:"base",children:c}),i.jsx(u.IconButton,{"aria-label":"next",onClick:b,children:i.jsx(u.RiIcon,{icon:"RiArrowRightLine"})})]})})]})})]})})]})})});Ht.displayName="SpreadsheetViewer";const _e=d.memo(t=>{const{fileType:n}=t,e=d.useMemo(()=>qt.includes(n)?i.jsx(u.RiIcon,{icon:"RiFileExcelLine"}):Ut.includes(n)?i.jsx(u.RiIcon,{icon:"RiFilePdfLine"}):Et.includes(n)?i.jsx(u.RiIcon,{icon:"RiFileImageLine"}):i.jsx(u.RiIcon,{icon:"RiFileLine"}),[n]);return i.jsx("div",{className:"h-max w-max",children:e})});_e.displayName="FileIcon";const ze=d.memo(t=>{const{file:n,truncateLength:e,hideName:r=!1,...o}=t,a=d.useMemo(()=>e!==void 0?U.truncate(n.name,e):n.name,[n.name,e]);return i.jsxs(u.Badge,{...o,children:[i.jsx(_e,{fileType:n.type}),!r&&a]})});ze.displayName="FileBadge";function pr(t){var n,e,r="";if(typeof t=="string"||typeof t=="number")r+=t;else if(typeof t=="object")if(Array.isArray(t)){var o=t.length;for(n=0;n<o;n++)t[n]&&(e=pr(t[n]))&&(r&&(r+=" "),r+=e)}else for(e in t)t[e]&&(r&&(r+=" "),r+=e);return r}function Oo(){for(var t,n,e=0,r="",o=arguments.length;e<o;e++)(t=arguments[e])&&(n=pr(t))&&(r&&(r+=" "),r+=n);return r}const we=Oo,Gt=d.memo(d.forwardRef((t,n)=>{const{file:e,className:r,error:o,truncateLength:a,rightSlot:l,...s}=t,p=d.useMemo(()=>{if(e)return a!==void 0?U.truncate(e.name,a):e.name},[e,a]);return i.jsxs("div",{className:we(r,"flex h-5 w-full items-center gap-2 rounded-md border border-(--base-a6) bg-(--base-2) text-sm py-1 px-2 h-max",{"text-(--gray-11)":o}),ref:n,...s,children:[o?i.jsx(u.RiIcon,{icon:"RiFileWarningLine"}):i.jsx(_e,{fileType:(e==null?void 0:e.type)??""}),o||(e?p:i.jsx("div",{className:"flex w-full justify-center",children:i.jsx(u.Spinner,{})})),l]})}));Gt.displayName="FileCard";const Xt=d.createContext(()=>{throw new Error("No FileViewerProvider found")}),mr=()=>d.useContext(Xt),gr=d.memo(t=>{const{children:n}=t,[e,r]=d.useState(null),[o,a]=d.useState(null),l=d.useCallback(()=>{r(null),a(null)},[]),s=d.useCallback(f=>{r(f(l))},[l]),p=d.useCallback(()=>{e&&(e.onClose&&e.onClose(),l())},[l,e]);d.useEffect(()=>{if(!e)return;const{file:f}=e;if(qt.includes(f.type)){a("spreadsheet");return}if(Ut.includes(f.type)){a("pdf");return}if(Et.includes(f.type)){a("image");return}},[e]);const c=d.useMemo(()=>s,[s]);return i.jsxs(Xt.Provider,{value:c,children:[n,e&&i.jsxs(i.Fragment,{children:[o==="spreadsheet"&&i.jsx(Ht,{file:e.file,onDelete:e.onDelete,onClose:p}),o==="pdf"&&i.jsx(Wt,{file:e.file,onDelete:e.onDelete,onClose:p}),o==="image"&&i.jsx(jt,{file:e.file,onDelete:e.onDelete,onClose:p})]})]})});gr.displayName="FileViewerProvider";const tt=500,be=1e4,$={danger:"danger",warning:"warning",info:"base",success:"success"};class Kt{constructor(n){N(this,"type");N(this,"identifier");N(this,"description");const{description:e=null,identifier:r,type:o}=n;this.identifier=r,this.description=e,this.type=o}getId(){return this.identifier}static deserialize(n){throw new Error(`${this.name} must implement deserialize.`)}_serialize(){if(!this.identifier)throw new Error("Field identifier must be set before serializing.");return{type:this.type,identifier:this.identifier,description:this.description}}}const K={label:"",description:"",required:!1};class q extends Kt{constructor(e){const{label:r,required:o,image:a,fieldValidators:l=[],formValidators:s=[],...p}=e;super(p);N(this,"required");N(this,"formValidators");N(this,"fieldValidators");N(this,"label");N(this,"image");N(this,"onlyValidateAfterTouched",!0);this.label=r,this.required=o,this.image=a,this.fieldValidators=l,this.formValidators=s}static getFieldCreationSchema(){return[]}isBlank(e){return e==null||e===""}getValueFromChangeEvent(e){return e.target.value}getError(e,r){if(this.required&&this.isBlank(e))return"This field is required.";for(const o of this.getFieldValidators()){const a=o(e);if(a)return a}if(r)for(const o of this.getFormValidators()){const a=o(e,r);if(a)return a}}_serialize(){return{...super._serialize(),label:this.label,required:this.required,image:this.image}}getFieldValidators(){return[...this.fieldValidators]}getFormValidators(){return[...this.formValidators]}encodeValueToJson(e){return JSON.stringify(e)}decodeJsonToValue(e){return JSON.parse(e)}}N(q,"fieldTypeName"),N(q,"fieldTypeDescription");const _=t=>{const{id:n,field:e,formId:r,size:o,showInputOnly:a,internal:l,...s}=t,[p,c,f]=j.useField(e.getId()),{touched:h}=c,m=c.error??e.description,y=c.error?"danger":void 0,x=n??`${r}-${e.getId()}-input`,g=`${x}-label`,b=e.required?`${e.label} *`:e.label,E=d.useMemo(()=>({...p,onChange:I=>{const F=e.getValueFromChangeEvent(I);f.setValue(F,!1).then(),(h||!e.onlyValidateAfterTouched)&&f.setError(e.getError(F))},onBlur:I=>{f.setTouched(!0,!1).then(),f.setError(e.getError(e.getValueFromChangeEvent(I)))}}),[e,p,f,h]);return console.debug("severity",y),[{helpText:m,size:o,severity:y,inputId:x,labelId:g,label:b,showInputOnly:a,internal:l,fieldProps:E,helpers:f,field:e},{...s,"aria-labelledby":g}]};var nt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Bo(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var rt={exports:{}},_o=rt.exports,vr;function zo(){return vr||(vr=1,function(t,n){(function(e,r){r()})(_o,function(){function e(c,f){return typeof f>"u"?f={autoBom:!1}:typeof f!="object"&&(console.warn("Deprecated: Expected third argument to be a object"),f={autoBom:!f}),f.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(c.type)?new Blob(["\uFEFF",c],{type:c.type}):c}function r(c,f,h){var m=new XMLHttpRequest;m.open("GET",c),m.responseType="blob",m.onload=function(){p(m.response,f,h)},m.onerror=function(){console.error("could not download file")},m.send()}function o(c){var f=new XMLHttpRequest;f.open("HEAD",c,!1);try{f.send()}catch{}return 200<=f.status&&299>=f.status}function a(c){try{c.dispatchEvent(new MouseEvent("click"))}catch{var f=document.createEvent("MouseEvents");f.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),c.dispatchEvent(f)}}var l=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof nt=="object"&&nt.global===nt?nt:void 0,s=l.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),p=l.saveAs||(typeof window!="object"||window!==l?function(){}:"download"in HTMLAnchorElement.prototype&&!s?function(c,f,h){var m=l.URL||l.webkitURL,y=document.createElement("a");f=f||c.name||"download",y.download=f,y.rel="noopener",typeof c=="string"?(y.href=c,y.origin===location.origin?a(y):o(y.href)?r(c,f,h):a(y,y.target="_blank")):(y.href=m.createObjectURL(c),setTimeout(function(){m.revokeObjectURL(y.href)},4e4),setTimeout(function(){a(y)},0))}:"msSaveOrOpenBlob"in navigator?function(c,f,h){if(f=f||c.name||"download",typeof c!="string")navigator.msSaveOrOpenBlob(e(c,h),f);else if(o(c))r(c,f,h);else{var m=document.createElement("a");m.href=c,m.target="_blank",setTimeout(function(){a(m)})}}:function(c,f,h,m){if(m=m||open("","_blank"),m&&(m.document.title=m.document.body.innerText="downloading..."),typeof c=="string")return r(c,f,h);var y=c.type==="application/octet-stream",x=/constructor/i.test(l.HTMLElement)||l.safari,g=/CriOS\/[\d]+/.test(navigator.userAgent);if((g||y&&x||s)&&typeof FileReader<"u"){var b=new FileReader;b.onloadend=function(){var S=b.result;S=g?S:S.replace(/^data:[^;]*;/,"data:attachment/file;"),m?m.location.href=S:location=S,m=null},b.readAsDataURL(c)}else{var E=l.URL||l.webkitURL,w=E.createObjectURL(c);m?m.location=w:location.href=w,m=null,setTimeout(function(){E.revokeObjectURL(w)},4e4)}});l.saveAs=p.saveAs=p,t.exports=p})}(rt)),rt.exports}var yr=zo();const $o=Bo(yr),Qt=d.memo(t=>{const{file:n,url:e,name:r,setShowPreview:o}=t,a=d.useCallback(l=>{l.stopPropagation();const s=new Blob([n]);$o(s,r)},[r,n]);return i.jsxs(i.Fragment,{children:[i.jsx("button",{className:"fixed top-0 left-0 z-[5000] h-full w-full bg-[rgba(0,0,0,0.85)] bg-black",type:"button",onClick:()=>{o(!1)},children:i.jsx("img",{className:"absolute top-[50%] left-[50%] z-[5001] max-h-[calc(100%-120px)] max-w-svw translate-x-[-50%] translate-y-[50%] object-contain",src:e,alt:r,onClick:l=>{l.stopPropagation()}})}),i.jsxs("div",{className:"fixed top-0 left-0 z-[5001] flex w-full items-center bg-(--color-background)",children:[i.jsx(u.IconButton,{className:"min-w-[50px]",variant:"soft","aria-label":"Exit preview",onClick:()=>{o(!1)},children:i.jsx(u.RiIcon,{icon:"RiArrowLeftLine"})}),i.jsx("span",{className:"grow text-center",children:r}),i.jsx(u.IconButton,{className:"min-w-[50px]",variant:"soft","aria-label":`Download ${r}`,onClick:a,children:i.jsx(u.RiIcon,{icon:"RiDownload2Line"})})]})]})});Qt.displayName="FullScreenImagePreview";const Z=t=>{const{className:n,label:e,children:r,size:o,severity:a,inputId:l,labelId:s,image:p}=t,[c,f]=d.useState(void 0),[h,m]=d.useState(!1),y=a?$[a]:"base";console.debug(a,y),d.useEffect(()=>{p instanceof Promise?p.then(f).catch(console.error):f(p)},[p]);const x=c?URL.createObjectURL(c):void 0;return i.jsxs("div",{className:"flex flex-col gap-2",children:[c&&i.jsxs(i.Fragment,{children:[i.jsx("img",{className:"h-[100px] w-full min-w-[300px] cursor-pointer rounded-md object-cover",src:x,alt:c.name,onClick:()=>{m(!0)}}),h&&i.jsx(Qt,{file:c,url:x,name:c.name,setShowPreview:m})]}),i.jsxs("label",{className:we(n,"flex flex-col gap-1"),htmlFor:l,children:[i.jsx(u.Text,{accentColor:y,size:o,id:s,weight:"medium",children:e}),r]})]})},Yt=t=>{const{helpText:n,children:e,severity:r}=t,o=r?$[r]:"base";return i.jsxs("div",{className:"flex flex-col gap-1",children:[e,i.jsx("div",{className:"flex flex-col w-full",children:i.jsx(u.Text,{accentColor:o,size:"xs",children:n})})]})},R=t=>{const{children:n,...e}=t;return i.jsx(Yt,{...e,children:n})},ko=[!0,"true"],Jt=d.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:l,fieldProps:s},p]=_(t);let[{helpText:c,label:f}]=_(t);c=a?null:c,f=a?"":f;const h=o?$[o]:void 0,m=ko.includes(s.value);return i.jsx(R,{helpText:c,severity:o,children:i.jsx(Z,{size:r,severity:o,inputId:n,labelId:e,label:f,image:a?void 0:l.image,className:"align-center flex-row-reverse justify-end gap-2",children:i.jsx(u.Checkbox.Root,{...p,...s,id:n,accentColor:h,value:m.toString(),checked:m,onCheckedChange:s.onChange,onChange:void 0,onBlur:void 0,variant:"soft",children:i.jsx(u.Checkbox.Indicator,{children:i.jsx(u.RiIcon,{icon:"RiCheckLine"})})})})})});Jt.displayName="BooleanInput";const wr={...K,type:"boolean"},xe=class xe extends q{constructor(e){super({...e,type:"boolean"});N(this,"onlyValidateAfterTouched",!1)}isBlank(e){return this.required&&!e}getValueFromChangeEvent(e){return typeof e=="boolean"?e:e.target.checked}serialize(){return super._serialize()}static deserialize(e){if(e.type!=="boolean")throw new Error("Type mismatch.");return new xe(e)}getInput(e){return i.jsx(Jt,{...e,field:this})}};N(xe,"fieldTypeName","Checkbox"),N(xe,"fieldTypeDescription","Perfect for both optional and required yes/no questions."),N(xe,"Icon",W.RiCheckboxCircleLine);let Ce=xe;const Zt=d.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:l,fieldProps:s},p]=_(t);let[{helpText:c,label:f}]=_(t);c=a?null:c,f=a?"":f;const h=o?$[o]:void 0,m=s.value?s.value.split("T")[0]:"";return i.jsx(R,{helpText:c,severity:o,children:i.jsx(Z,{size:r,severity:o,inputId:n,labelId:e,label:f,image:a?void 0:l.image,children:i.jsx(u.Input.Root,{accentColor:h,variant:"soft",children:i.jsx(u.Input.Field,{...p,type:"date",id:n,color:h,value:m})})})})});Zt.displayName="DateInput";const br={...K,type:"date"},Ie=class Ie extends q{constructor(e){super({...e,type:"date"});N(this,"onlyValidateAfterTouched",!1)}serialize(){return super._serialize()}getValueFromChangeEvent(e){return new Date(e.target.value).toISOString()}static deserialize(e){if(e.type!=="date")throw new Error("Type mismatch.");return new Ie(e)}getInput(e){return i.jsx(Zt,{field:this,...e})}};N(Ie,"fieldTypeName","Date"),N(Ie,"fieldTypeDescription","Allows specifying a date."),N(Ie,"Icon",W.RiCalendarLine);let it=Ie;const Cr=d.memo(t=>{const{field:n,...e}=t,[{value:r}]=j.useField(n.options.clonedFieldIdentifier),o=d.useMemo(()=>{const a=n.options.getFieldToClone(r);return a?pt(a):null},[n.options,r]);return Rt(o,e)});Cr.displayName="FieldInputCloner";const Vo={...K,type:"custom"};class ot extends q{constructor(e,r){super({...e,type:"custom"});N(this,"Component");N(this,"options");this.options=e,this.Component=r}serialize(){throw new Error("Serializing only supported for public input types.")}getInput(e){const r=this.Component;return i.jsx(r,{field:this,...e})}}N(ot,"fieldTypeName","Custom"),N(ot,"fieldTypeDescription","Allows re-rendering of field already in the form");class jo extends ot{constructor(n){super(n,Cr)}}const Rt=(t,n)=>d.useMemo(()=>!n||!t?null:t.getInput(n),[t,n]),$e=(t,n)=>{const e=d.useMemo(()=>t.map(r=>i.jsx("div",{children:r.getInput(n)},r.getId())),[t,n]);return i.jsx("div",{className:"flex flex-col gap-2",children:e})},at=(t="",n=[])=>({type:"section",fields:n,identifier:t,label:null,condition:null,conditional:!1}),Uo=t=>{if(!t)return;const n=t.fields;let e=[];const r=[];for(const o of n)o.type==="section"?(e.length>0&&(r.push(at(`AUTO_section-${n.indexOf(o)}`,e)),e=[]),r.push(o)):e.push(o);return e.length>0&&r.push(at("AUTO_section-last",e)),{...t,fields:r,description:t.description??""}};function en(t,n,e){const r=Array.from(t),[o]=r.splice(n,1);if(!o)throw new Error("Could not find field to reorder.");return r.splice(e,0,o),r}function xr(t,n,e){const r=Array.from(t??[]);return r.splice(n,0,e),r}function lt(t,n){const e=Array.from(t);return e.splice(n,1),e}const tn=(t,n)=>{const e=new Date;return`${U.slugify(n)}-${e.getTime()}`},Ir=(t,n)=>{if(!n)return null;for(const e of t)if(e.type==="section"){const r=Ir(e.fields,n);if(r)return r}else if(e.identifier===n)return e;return null},Er=(t,n)=>t.filter((e,r)=>r<n).flatMap(e=>e.fields),st=(t,n,e,r,o)=>{const{label:a}=e,l={...e,identifier:tn(null,a)},s=Y(r,t);if(s===void 0)throw new Error("Parent path must point to an existing field.");if(!Array.isArray(s))throw new Error("Parent path must point to an array.");const p=xr(s,n,l);o(t,p).then()},Wo=(t,n,e)=>{const r={...at(),label:""};st("fields",t,r,n,e)},nn=()=>{const{showError:t}=u.useToast(),n=d.useCallback((r,o,a,l,s,p)=>{const c=r[o];if(!c)throw new Error("Could not find section context.");let f=typeof c.conditionIndex<"u"?Math.max(c.conditionIndex+1,l):l;for(const h of Object.values(r))h.conditionIndex===a&&(f=Math.min(f,h.index-1));if(f!==l){t({title:"Could not reorder sections",description:"Sections with conditions must be below the fields they reference."});return}p("fields",en(s.fields,a,f))},[t]),e=d.useCallback((r,o,a,l,s,p,c)=>{var f;if(!(r!=null&&r.fields)||!l)throw new Error("Could not find section with fields.");if(r.identifier===l.identifier)c(`fields.${o}.fields`,en(r.fields,a,p)).then();else{const h=r.fields[a];if(!h)throw new Error("Could not find field to reorder.");if(((f=l.condition)==null?void 0:f.identifier)===h.identifier){t({title:"Could not reorder field",description:"Field must be above the section whose condition references it."});return}c(`fields.${o}.fields`,lt(r.fields,a)).then(),c(`fields.${s}.fields`,xr(l.fields,p,h)).then()}},[t]);return{reorderSection:n,reorderField:e}},rn=d.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:l,fieldProps:s,internal:p},c]=_(t);let[{helpText:f,label:h}]=_(t);f=a?null:f,h=a?"":h;const m=o?$[o]:void 0,y=d.useMemo(()=>Array.isArray(s.value)?s.value:[],[s.value]),{onChange:x,onBlur:g}=s,b=`${n}-droppable`,{disabled:E}=c,[w,S]=d.useState(""),[I,F]=d.useState(""),L=I||f,T=I?$.danger:m,D=d.useCallback(M=>{x(M),g(M)},[x,g]),A=d.useCallback(M=>{y.findIndex(k=>k===M.target.value.trim())>=0?F("All options must be unique"):M.target.value?F(""):F("Option cannot be empty"),S(M.target.value)},[S,y]),B=d.useCallback(()=>{if(I)return;if(!w.trim()){F("Option cannot be empty");return}const M=w.trim();D([...y,M]),S("")},[w,I,D,y]),X=d.useCallback(M=>{M.key==="Enter"&&(M.preventDefault(),B())},[B]),Q=d.useCallback(M=>{D(lt(y,M))},[y,D]),z=d.useCallback(M=>{if(!M.destination)return;const k=M.source.index,se=M.destination.index;D(en(y,k,se))},[D,y]);return i.jsx(ie.DragDropContext,{onDragEnd:z,children:i.jsxs("div",{className:"flex flex-col gap-2",children:[i.jsx(R,{helpText:L,severity:o,children:i.jsx(Z,{size:r,severity:o,inputId:n,labelId:e,label:h,image:a?void 0:l.image,children:(!E||y.length===0)&&i.jsxs("div",{className:"flex gap-2",children:[i.jsx("div",{className:"grow",children:i.jsx(u.Input.Root,{accentColor:T,variant:p?"outline":"soft",children:i.jsx(u.Input.Field,{...c,...s,value:w,onChange:A,onKeyDown:X,id:n,placeholder:l.placeholder,onBlur:void 0})})}),i.jsx(u.IconButton,{type:"button","aria-label":"Add option",disabled:!!I||E,onClick:B,children:i.jsx(u.RiIcon,{icon:"RiAddLine"})})]})})}),i.jsx(ie.Droppable,{droppableId:b,children:M=>i.jsxs("div",{className:"flex flex-col",...M.droppableProps,ref:M.innerRef,children:[y.map((k,se)=>i.jsx(ie.Draggable,{draggableId:`${k}-draggable`,index:se,isDragDisabled:E,children:({draggableProps:Ue,dragHandleProps:We,innerRef:re})=>i.jsxs(u.Badge,{...We,...Ue,ref:re,className:"mb-1 flex items-center justify-between gap-2",accentColor:"base",size:"md",variant:"soft",children:[i.jsx("span",{children:typeof k=="object"&&"label"in k?k.label:k}),i.jsx(u.IconButton,{size:"sm",variant:"ghost",type:"button","aria-label":"Delete option",accentColor:"base",disabled:E,onClick:()=>{Q(se)},children:i.jsx(u.RiIcon,{icon:"RiCloseLargeLine"})})]})},k)),M.placeholder]})})]})})});rn.displayName="MultiStringInput";const Sr={...K,type:"multi-string",minimum_length:0,maximum_length:null},Ee=class Ee extends q{constructor(e){const{minimum_length:r,maximum_length:o,placeholder:a,...l}=e;super({...l,type:"multi-string"});N(this,"minLength");N(this,"maxLength");N(this,"onlyValidateAfterTouched",!1);N(this,"placeholder");this.minLength=r??0,this.maxLength=o??1/0,this.placeholder=a??"Press enter to add a new option"}getValueFromChangeEvent(e){if(Array.isArray(e))return e;throw new Error("Expected an array.")}getInput(e){return i.jsx(rn,{field:this,...e})}serialize(){return{...super._serialize(),minimum_length:this.minLength,maximum_length:this.maxLength,placeholder:this.placeholder}}isBlank(e){return super.isBlank(e)||e.length===0}getFieldValidators(){const e=super.getFieldValidators();return e.push(r=>{if(Array.isArray(r)&&r.length<this.minLength)return`Must have at least ${this.minLength} options.`}),e.push(r=>{if(Array.isArray(r)&&r.length>this.maxLength)return`Must have at most ${this.maxLength} options.`}),e}static deserialize(e){if(e.type!=="multi-string")throw new Error("Type mismatch.");return new Ee(e)}};N(Ee,"fieldTypeName","Multi-string"),N(Ee,"fieldTypeDescription","Allows the user to provide multiple unique strings."),N(Ee,"Icon",W.RiListCheck);let ke=Ee;const on=d.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:l,fieldProps:s},p]=_(t);let[{helpText:c,label:f}]=_(t);c=a?null:c,f=a?"":f;const h=o?$[o]:void 0;return i.jsx(R,{helpText:c,severity:o,children:i.jsx(Z,{size:r,severity:o,inputId:n,labelId:e,label:f,image:a?void 0:l.image,children:i.jsx(u.Input.Root,{accentColor:h,variant:"soft",children:i.jsx(u.Input.Field,{...p,...s,type:"number",id:n,placeholder:l.placeholder,min:l.minimum,max:l.maximum,step:l.integers?1:.1})})})})});on.displayName="NumberInput";const Nr={...K,type:"number",minimum:Number.MIN_SAFE_INTEGER,maximum:Number.MAX_SAFE_INTEGER,integers:!1},Fr=t=>"fields"in t,te=class te extends q{constructor(e){const{minimum:r=Number.MIN_SAFE_INTEGER,maximum:o=Number.MAX_SAFE_INTEGER,integers:a=!1,placeholder:l="Enter a number",...s}=e;super({...s,type:"number"});N(this,"minimum");N(this,"maximum");N(this,"integers");N(this,"placeholder");this.minimum=r,this.maximum=o,this.integers=a,this.placeholder=l}getValueFromChangeEvent(e){const r=Number.parseFloat(e.target.value);return Number.isNaN(r)?"":r}static getFieldCreationSchema(e=""){const r=e&&`${e}.`;return[{field:new te({label:"Minimum",description:"Minimum value",integers:!0,required:!1,identifier:`${r}minimum`,formValidators:[this._validateMin(e)]}),showDirectly:!1},{field:new te({label:"Maximum",description:"Maximum value",integers:!0,required:!1,identifier:`${r}maximum`,formValidators:[this._validateMax(e)]}),showDirectly:!1},{field:new Ce({label:"Integers",description:"Whole numbers only",required:!1,identifier:`${r}integers`}),showDirectly:!1}]}getFieldValidators(){const e=super.getFieldValidators(),r=this.minimum,o=this.maximum;return typeof r=="number"&&e.push(a=>{if(typeof a=="number"&&a<r)return`Must be at least ${this.minimum}.`}),typeof o=="number"&&e.push(a=>{if(typeof a=="number"&&a>o)return`Must be at most ${this.maximum}.`}),this.integers&&e.push(a=>{if(typeof a=="number"&&!Number.isInteger(a))return"Must be a whole number."}),e}serialize(){return{...super._serialize(),minimum:this.minimum,maximum:this.maximum,integers:this.integers,placeholder:this.placeholder}}static deserialize(e){if(e.type!=="number")throw new Error("Type mismatch.");return new te(e)}getInput(e){return i.jsx(on,{field:this,...e})}};N(te,"fieldTypeName","Number"),N(te,"fieldTypeDescription","Allows specifying a number within a given range."),N(te,"Icon",W.RiHashtag),N(te,"_validateMin",e=>(r,o)=>{const a=Fr(o)?Y(o,e):o;return typeof a.maximum=="number"&&typeof r=="number"&&a.maximum<r?"Minimum cannot be greater than minimum.":null}),N(te,"_validateMax",e=>(r,o)=>{const a=Fr(o)?Y(o,e):o;return typeof a.minimum=="number"&&typeof r=="number"&&a.minimum>r?"Maximum cannot be less than minimum.":null});let le=te;const an=d.memo(t=>{const[{inputId:n,labelId:e,label:r,helpText:o,size:a,severity:l,showInputOnly:s,field:p,fieldProps:c},f]=_(t),[h,m]=d.useState(!1),y=c.value,x=d.useCallback(w=>{c.onChange({target:{value:w}}),m(!1)},[c]),g=d.useCallback(()=>{c.onChange({target:{value:""}})},[c]),b=d.useCallback(()=>{m(!0)},[]),E=d.useCallback(()=>{m(!1)},[]);return i.jsx(R,{helpText:o,severity:l,children:i.jsxs(Z,{size:a,severity:l,inputId:n,labelId:e,label:r,image:s?void 0:p.image,className:"flex-col items-start justify-start gap-1",children:[i.jsx(Me,{open:h,onOpenChange:m,children:i.jsxs(Ae,{children:[i.jsx(Oe,{className:"light:bg-(--black-a6) fixed inset-0 dark:bg-(--black-a8)"}),i.jsx(Be,{className:"fixed inset-0",children:i.jsx(ln,{onQrScan:x,onClose:E})})]})}),i.jsxs("div",{className:"flex w-max items-center gap-1",children:[i.jsxs(u.Button,{...f,variant:"soft",onClick:b,children:[i.jsx(u.RiIcon,{icon:"RiQrCodeLine"}),"Scan"]}),y&&i.jsx("span",{className:"text-xs text-(--accent-a11)","data-accent-color":"primary",children:i.jsx(u.RiIcon,{icon:"RiCheckLine",style:{verticalAlign:"bottom"}})})]}),!!y&&i.jsx(u.Card,{children:i.jsxs("div",{className:"w-max items-center gap-2",children:[i.jsx("code",{className:"bg-(--base-a3)",children:y}),i.jsx(u.IconButton,{accentColor:"base",variant:"ghost","aria-label":"delete",size:"sm",onClick:g,children:i.jsx(u.RiIcon,{icon:"RiCloseLine"})})]})})]})})});an.displayName="QrInput";const ln=d.memo(t=>{const{onQrScan:n,onClose:e}=t,r=d.useRef(null),[o,a]=d.useState(!1);return d.useEffect(()=>{if(!r.current)return;const l=new Jr(r.current,s=>{const p=s.data;n(p),l.destroy()},{highlightCodeOutline:!0,highlightScanRegion:!0,maxScansPerSecond:1});a(!0),l.start().finally(()=>{a(!1)})},[n]),i.jsxs("div",{className:"relative flex h-full w-full flex-col justify-center gap-2 bg-(--color-background)",children:[i.jsx("div",{className:"absolute top-0 flex w-full p-2",children:i.jsx(u.IconButton,{"aria-label":"close",variant:"soft",accentColor:"base",onClick:e,children:i.jsx(u.RiIcon,{icon:"RiCloseLine"})})}),i.jsxs("div",{className:"relative max-h-full max-w-full",children:[i.jsx("video",{ref:r,style:{width:"100%",height:"100%"}}),o&&i.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-(--color-background)",children:i.jsx(u.Spinner,{})})]})]})});ln.displayName="QrScanner";const Tr={...K,type:"qr"},Se=class Se extends q{constructor(e){super({...e,type:"qr"});N(this,"onlyValidateAfterTouched",!1)}serialize(){return super._serialize()}static deserialize(e){if(e.type!=="qr")throw new Error("Type mismatch.");return new Se(e)}getInput(e){return i.jsx(an,{...e,field:this})}};N(Se,"fieldTypeName","QR"),N(Se,"fieldTypeDescription","Used for scanning/reading QR codes."),N(Se,"Icon",W.RiQrCodeLine);let ct=Se;class Lr extends q{constructor(e){const{placeholder:r="",...o}=e;super(o);N(this,"options");N(this,"onlyValidateAfterTouched",!1);N(this,"placeholder");this.placeholder=r;const a=new Set;this.options=e.options.map(l=>(typeof l=="string"&&(l={label:l,value:l}),a.add(l.label),l)),a.size!==e.options.length&&console.error(`${e.options.length-a.size} duplicate identifiers found in options. This may cause unexpected behavior. Options:`,e.options)}_serialize(){return{...super._serialize(),options:this.options,placeholder:this.placeholder}}static getFieldCreationSchema(e=""){const r=e&&`${e}.`;return[{field:new ke({label:"Options",description:"List possible options for the user to select from.",required:!0,identifier:`${r}options`,minimum_length:2}),showDirectly:!0}]}}const qo=t=>t?Array.isArray(t)?t:[t]:[],sn=d.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:l,fieldProps:s},p]=_(t),{onChange:c,onBlur:f}=s;let[{helpText:h,label:m}]=_(t);h=a?null:h,m=a?"":m;const y=d.useMemo(()=>qo(s.value),[s.value]),x=d.useCallback(g=>{c(g),f(g)},[c,f]);return i.jsx(R,{helpText:h,severity:o,children:i.jsx(Z,{size:r,severity:o,inputId:n,labelId:e,label:m,image:a?void 0:l.image,children:i.jsxs(u.Menu.Root,{children:[i.jsx(u.Menu.ClickTrigger,{children:i.jsxs(u.Button,{id:n,className:"!justify-between",name:s.name,variant:"soft",...p,children:[y.length>0?y.join(", "):l.placeholder,i.jsx(u.RiIcon,{icon:"RiArrowDownSLine"})]})}),i.jsx(u.Menu.Content,{children:i.jsxs(u.Menu.MultiSelectGroup,{values:y,onValuesChange:x,children:[i.jsxs(u.Menu.SelectAllItem,{allValues:l.options.map(({value:g})=>g),children:[i.jsx(u.Menu.SelectAllIndicator,{children:g=>g?i.jsx(u.RiIcon,{icon:"RiSubtractLine"}):i.jsx(u.RiIcon,{icon:"RiCheckLine"})}),"Select all"]}),l.options.map(g=>i.jsxs(u.Menu.MultiSelectItem,{value:g.value,children:[i.jsx(u.Menu.SelectedIndicator,{children:i.jsx(u.RiIcon,{icon:"RiCheckLine"})}),g.label]},g.value))]})})]})})})});sn.displayName="MultiSelectInput";const Dr={...K,type:"multi-select",options:[]},Ne=class Ne extends Lr{constructor(n){const{placeholder:e="Select one or more...",...r}=n;super({...r,placeholder:e,type:"multi-select"})}getValueFromChangeEvent(n){if(Array.isArray(n))return n;throw new Error("Expected an array.")}isBlank(n){return super.isBlank(n)||n.length===0}serialize(){return super._serialize()}static deserialize(n){if(n.type!=="multi-select")throw new Error("Type mismatch.");return new Ne(n)}getInput(n){return i.jsx(sn,{field:this,...n})}};N(Ne,"fieldTypeName","Multi-select"),N(Ne,"fieldTypeDescription","Allows the user to select a multiple options from a list of options."),N(Ne,"Icon",W.RiCheckboxLine);let Ve=Ne;const cn=d.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:l,fieldProps:s},p]=_(t),{onChange:c,onBlur:f}=s;let[{helpText:h,label:m}]=_(t);h=a?null:h,m=a?"":m;const y=d.useCallback(g=>{c(g),f(g)},[c,f]),x=o?$[o]:void 0;return i.jsx(R,{helpText:h,severity:o,children:i.jsx(Z,{size:r,severity:o,inputId:n,labelId:e,label:m,image:a?void 0:l.image,children:i.jsxs(u.Menu.Root,{children:[i.jsx(u.Menu.ClickTrigger,{children:i.jsxs(u.Button,{...s,className:"!justify-between",id:n,name:s.name,accentColor:x,variant:"soft",...p,children:[s.value?s.value:l.placeholder,i.jsx(u.RiIcon,{icon:"RiArrowDownSLine"})]})}),i.jsx(u.Menu.Content,{children:i.jsx(u.Menu.SelectGroup,{value:s.value,onValueChange:y,children:l.options.map(g=>i.jsxs(u.Menu.SelectItem,{value:g.value,children:[i.jsx(u.Menu.SelectedIndicator,{children:i.jsx(u.RiIcon,{icon:"RiCheckLine"})}),g.label]},g.value))})})]})})})});cn.displayName="SelectInput";const Pr={...K,type:"select",options:[]},Fe=class Fe extends Lr{constructor(n){const{placeholder:e="Select one...",...r}=n;super({...r,placeholder:e,type:"select"})}getValueFromChangeEvent(n){return typeof n=="string"?n:n.target.value}serialize(){return super._serialize()}static deserialize(n){if(n.type!=="select")throw new Error("Type mismatch.");return new Fe(n)}getInput(n){return i.jsx(cn,{field:this,...n})}};N(Fe,"fieldTypeName","Dropdown"),N(Fe,"fieldTypeDescription","Allows the user to select a single option from a list of options."),N(Fe,"Icon",W.RiMenuFoldLine);let je=Fe;const Mr=t=>"fields"in t;class dt extends q{constructor(e){const{minLength:r,maxLength:o,placeholder:a="",...l}=e;super(l);N(this,"minLength");N(this,"maxLength");N(this,"placeholder");this.minLength=r?Math.max(r,0):void 0,this.maxLength=o?Math.max(o,0):be,this.placeholder=a}static getFieldCreationSchema(e=""){const r=e&&`${e}.`;return[{field:new le({label:"Minimum length",description:"Minimum number of characters",required:!1,identifier:`${r}minimum_length`,minimum:0,maximum:100,formValidators:[this._validateMin(e)],integers:!0}),showDirectly:!1},{field:new le({label:"Maximum length",description:"Maximum number of characters",required:!1,identifier:`${r}maximum_length`,minimum:1,maximum:be,formValidators:[this._validateMax(e)],integers:!0}),showDirectly:!1}]}getFieldValidators(){const e=super.getFieldValidators();return this.minLength&&e.push(r=>{if(this.minLength&&(!r||r.length<this.minLength))return!this.required&&!r?null:`Minimum ${this.minLength} character(s).`}),this.maxLength&&e.push(r=>{if(typeof r=="string"&&this.maxLength&&r.length>this.maxLength)return`Maximum ${this.maxLength} character(s).`}),e}_serialize(){if(!this.identifier)throw new Error("Field identifier must be set before serializing.");return{...super._serialize(),minimum_length:this.minLength,maximum_length:this.maxLength,placeholder:this.placeholder}}}N(dt,"_validateMin",e=>(r,o)=>{const a=Mr(o)?Y(o,e):o;return typeof a.maximum_length=="number"&&typeof r=="number"&&a.maximum_length<r?"Minimum cannot be greater than maximum.":null}),N(dt,"_validateMax",e=>(r,o)=>{if(typeof r!="number")return null;const{minimum_length:a}=Mr(o)?Y(o,e):o;return typeof a!="number"?null:a>r?"Maximum cannot be less than minimum.":null});const dn=d.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:l,fieldProps:s},p]=_(t);let[{helpText:c,label:f}]=_(t);c=a?null:c,f=a?"":f;const h=o?$[o]:void 0;return i.jsx(R,{helpText:c,severity:o,children:i.jsx(Z,{size:r,severity:o,inputId:n,labelId:e,label:f,image:a?void 0:l.image,children:i.jsx(u.Input.Root,{accentColor:h,variant:"soft",children:i.jsx(u.Input.Field,{...p,...s,type:l.inputType,id:n,placeholder:l.placeholder})})})})});dn.displayName="StringInput";const Ar={...K,type:"string",maximum_length:tt,input_type:"text"},Te=class Te extends dt{constructor(e){const{inputType:r="text",...o}=e,a=e.maxLength?Math.min(tt,e.maxLength):tt,l=e.minLength?Math.min(e.minLength,a):void 0;super({...o,maxLength:a,minLength:l,type:"string"});N(this,"inputType");this.inputType=r}serialize(){return{...super._serialize(),input_type:this.inputType}}static deserialize(e){if(e.type!=="string")throw new Error("Type mismatch.");const{maximum_length:r,minimum_length:o,input_type:a,...l}=e;return new Te({...l,maxLength:r,minLength:o,inputType:a,placeholder:"Enter a short description"})}getInput(e){return i.jsx(dn,{field:this,...e})}};N(Te,"fieldTypeName","Short Text"),N(Te,"fieldTypeDescription",`Short text fields can hold up to ${tt} characters on a single line.`),N(Te,"Icon",W.RiInputField);let ut=Te;const un=d.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:l,fieldProps:s},p]=_(t);let[{helpText:c,label:f}]=_(t);c=a?null:c,f=a?"":f;const h=o?$[o]:void 0;return i.jsx(R,{helpText:c,severity:o,children:i.jsx(Z,{size:r,severity:o,inputId:n,labelId:e,label:f,image:a?void 0:l.image,children:i.jsx(u.TextArea,{...p,...s,className:"field-sizing-content",resize:"vertical",id:n,placeholder:l.placeholder,accentColor:h,variant:"soft"})})})});un.displayName="TextInput";const Or={...K,type:"text",maximum_length:be},Le=class Le extends dt{constructor(n){const e=n.maxLength?Math.min(be,n.maxLength):be,r=n.minLength?Math.min(n.minLength,e):void 0;super({...n,maxLength:e,minLength:r,type:"text"})}serialize(){return super._serialize()}static deserialize(n){if(n.type!=="text")throw new Error("Type mismatch.");const{maximum_length:e,minimum_length:r,...o}=n;return new Le({...o,maxLength:e,minLength:r,placeholder:"Enter a description"})}getInput(n){return i.jsx(un,{field:this,...n})}};N(Le,"fieldTypeName","Paragraph"),N(Le,"fieldTypeDescription",`Paragraph fields can hold up to ${be} characters and can have multiple lines.`),N(Le,"Icon",W.RiAlignJustify);let ft=Le;const Br=d.memo(d.forwardRef((t,n)=>{const{file:e,alt:r,error:o,rightSlot:a,className:l,truncateLength:s,...p}=t,c=d.useRef(null),f=d.useRef(null),h=u.useSize(c);d.useLayoutEffect(()=>{!f.current||!h||(f.current.style.height=`${h.height*4}px`)},[h]);const m=d.useMemo(()=>{if(e)return s!==void 0?U.truncate(e.name,s):e.name},[e,s]);return i.jsxs("div",{className:we(l,"relative flex h-max w-full flex-col gap-0 overflow-hidden rounded-md border items-center border-(--base-a6)"),ref:n,...p,children:[!e&&!o&&i.jsx("div",{className:"absolute flex h-full w-full flex-col items-center justify-center",children:i.jsx(u.Spinner,{})}),i.jsx("div",{ref:f,className:"-m-4 flex max-w-full items-center justify-center overflow-hidden bg-clip-padding",children:e&&!o&&i.jsx("img",{className:"max-w-full object-cover",src:URL.createObjectURL(e),alt:r??e.name})}),i.jsxs("div",{className:we("flex h-max w-full items-center gap-1 bg-(--base-2) px-2 py-1",{"bg-transparent":!e}),ref:c,children:[o?i.jsx(u.RiIcon,{icon:"RiFileWarningLine"}):e&&i.jsx(_e,{fileType:e.type}),o??m,a]})]})})),Ho=t=>{const n=["byte","kilobyte","megabyte"];let e=t,r=0;for(;e>1e3&&r<n.length-1;)e/=1e3,r++;return new Intl.NumberFormat([],{maximumFractionDigits:Math.max(0,r-1),style:"unit",unit:n[r]}).format(e)},_r=d.memo(t=>{var F;const[{inputId:n,labelId:e,size:r,severity:o,helpText:a,showInputOnly:l,field:s,fieldProps:p},c]=_(t),{onChange:f}=p;let[{label:h}]=_(t);h=l?"":h;const m=o?$[o]:void 0,y=d.useRef(null),{value:x}=p,g=d.useMemo(()=>l?null:a||(s.maxFileSize?`Maximum file size: ${s.maxFileSize}MB`:null),[s.maxFileSize,a,l]),b=d.useCallback(()=>{var L;(L=y.current)==null||L.click()},[]),E=d.useCallback(L=>{const T=[...x];T.splice(L,1),f({target:{files:T}})},[x,f]),w=x?"Select new files":"Select files",S=x?"Select new file":"Select a file",I=s.maxFiles>1?w:S;return i.jsxs("div",{className:"flex flex-col gap-2",children:[i.jsx(R,{helpText:g,severity:o,children:i.jsxs(Z,{size:r,severity:o,inputId:n,labelId:e,label:h,image:l?void 0:s.image,children:[i.jsx("div",{className:"flex gap-2",children:i.jsxs(u.Button,{...c,className:"w-max",variant:"soft",onClick:b,id:"upload-input-upload-button",children:[i.jsx(u.RiIcon,{icon:"RiUpload2Line"})," ",I]})}),i.jsx("input",{...c,type:"file",ref:y,id:n,accept:(F=s.extensions)==null?void 0:F.join(","),multiple:s.maxFiles>1,color:m,style:{display:"none"},...p,value:""})]})}),Array.isArray(x)&&x.length>0&&i.jsx("div",{className:"flex h-max flex-col gap-2",children:x.map((L,T)=>i.jsx(zr,{field:s,file:L,onRemove:()=>{E(T)},disabled:c.disabled},T))})]})});_r.displayName="UploadInput";const zr=d.memo(t=>{const{file:n,field:e,onRemove:r,disabled:o}=t,[a,l]=d.useState(null),s=mr(),p=d.useMemo(()=>a&&e.getError([a]),[e,a]),{url:c,name:f}=d.useMemo(()=>{let g=null,b,E;return a!=null&&a.type.startsWith("image/")&&(g=URL.createObjectURL(a)),a?(b=a.name,E=Ho(a.size)):(b="Downloading...",E="..."),{url:g,name:b,size:E}},[a]);d.useEffect(()=>{n instanceof Promise?n.then(l).catch(console.error):l(n)},[n]);const h=d.useCallback(g=>{if(g.stopPropagation(),!a)throw new Error("Cannot download a file that is not resolved.");const b=new Blob([a]);yr.saveAs(b,f)},[f,a]),m=d.useCallback(g=>{g.stopPropagation(),r()},[r]),y=d.useCallback(()=>{a&&s(g=>({file:a,onDelete:o?void 0:()=>{r(),g()}}))},[o,r,s,a]),x=d.useMemo(()=>i.jsxs(u.ButtonGroup,{variant:"ghost",accentColor:"base",size:"sm",children:[i.jsx(u.IconButton,{"aria-label":`Download ${f}`,onClick:h,disabled:!a,children:i.jsx(u.RiIcon,{icon:"RiDownload2Line"})}),!o&&i.jsx(u.IconButton,{"aria-label":`Remove ${f}`,disabled:o,onClick:m,children:i.jsx(u.RiIcon,{icon:"RiCloseLargeLine"})})]}),[o,m,h,f,a]);return c?i.jsx(Br,{style:{cursor:"pointer"},onClick:y,file:a,error:p??void 0,rightSlot:x}):i.jsx(Gt,{style:{cursor:"pointer"},onClick:y,file:a,error:p??void 0,rightSlot:x})});zr.displayName="DisplayFile";const Go={...K,type:"upload",extensions:[],maximum_size:void 0,maximum_files:1},De=class De extends q{constructor(e){const{extensions:r,maximum_files:o,maximum_size:a,...l}=e;super({...l,type:"upload"});N(this,"extensions");N(this,"maxFileSize");N(this,"maxFiles");N(this,"onlyValidateAfterTouched",!1);this.maxFileSize=typeof a=="number"?a:void 0,this.maxFiles=Math.max(typeof o=="number"?o:1,1),this.extensions=r}getValueFromChangeEvent(e){return Array.from(e.target.files||[])}isBlank(e){return super.isBlank(e)||e.length===0}static getFieldCreationSchema(e=""){const r=e&&`${e}.`;return[{field:new le({label:"How many files can be uploaded?",description:"By default, only one file can be uploaded.",required:!1,minimum:1,maximum:10,identifier:`${r}maximum_files`,integers:!0}),showDirectly:!1},{field:new le({label:"What is the maximum size of each file?",description:`Maximum file size in megabytes (between 1MB–${ht}MB).`,required:!1,identifier:`${r}maximum_size`,minimum:1,maximum:ht,integers:!0}),showDirectly:!1},{field:new Ve({label:"Accepted file types",description:"Types of allowed files to upload. If left blank, all files will be accepted.",required:!1,identifier:`${r}extensions`,options:[{value:"image/*",label:"Images"},{value:"audio/*",label:"Audio files"},{value:"video/*",label:"Videos"},{value:"text/*",label:"Text files"},{value:"application/*",label:"Application files (includes PDFs and Word documents)"}]}),showDirectly:!1}]}getFieldValidators(){const e=super.getFieldValidators(),r=this.maxFileSize??ht,o=r*1e3*1e3,a=this.maxFiles||1;return e.push(l=>{if(l&&l.some(s=>s.size>o))return`Files must be at most ${r}MB.`}),e.push(l=>{if(l&&l.length>a)return`You can only upload ${a} files.`}),e}serialize(){return{...super._serialize(),extensions:this.extensions,maximum_size:this.maxFileSize,maximum_files:this.maxFiles}}static deserialize(e){if(e.type!=="upload")throw new Error("Type mismatch.");return new De(e)}getInput(e){return i.jsx(_r,{field:this,...e})}};N(De,"fieldTypeName","Upload"),N(De,"fieldTypeDescription","Allows a file to be uploaded."),N(De,"Icon",W.RiUpload2Line);let fn=De;const hn={date:it,number:le,boolean:Ce,select:je,string:ut,text:ft,custom:ot,upload:fn,qr:ct,"multi-string":ke,"multi-select":Ve},Xo={date:br,number:Nr,boolean:wr,select:Pr,string:Ar,text:Or,custom:Vo,upload:Go,qr:Tr,"multi-string":Sr,"multi-select":Dr},ht=50,Ko=ht*1e3*1e3,pn=t=>{const n=t.type;return hn[n].deserialize(t)},pt=t=>t.type==="section"?H.deserialize(t):pn(t);function $r(t,n={}){const{readonly:e=!1}=n;return{title:t.title,description:t.description,fields:t.fields.map(r=>pt(r)),meta:{readonly:e}}}function mn(t){const n=[];for(const e of t.fields)if(e instanceof H)for(const r of e.fields)n.push(r);else{if(!(e instanceof q))throw new Error(`Invalid field type: ${e.type}`);n.push(e)}return n}function Qo(t,n){const e=mn(t),r={};for(const o of e){const a=n[o.identifier]??null;a!==null?r[o.identifier]=o.decodeJsonToValue(a):r[o.identifier]=a}return r}function Yo(t,n){const e=mn(t),r={};for(const o of e){const a=n[o.identifier];r[o.identifier]=o.encodeValueToJson(a)}return r}function mt(t){return Array.isArray(t)&&t.some(n=>n instanceof File||n instanceof Promise)}function gn(t,n){if(!t)return!0;if(mt(n)||mt(t.value))throw new Error("Conditions do not support file uploads");const e=Array.isArray(n)?n.map(o=>typeof o=="string"?o:o.value):n,r=Array.isArray(t.value)?t.value.map(o=>typeof o=="string"?o:o.value):t.value;if(Array.isArray(r)&&Array.isArray(e)){for(const o of r)if(!e.includes(o))return!1;return!0}return r===n}const kr=d.memo(t=>{const{field:n,...e}=t,{label:r,description:o,fields:a,condition:l}=n,{values:s,setFieldValue:p}=j.useFormikContext(),c=l!=null&&l.identifier?Y(s,l.identifier):void 0,f=d.useMemo(()=>c===void 0||gn(l,c),[l,c]);d.useEffect(()=>{if(!f)for(const m of a)p(m.getId(),"").then()},[f,a,p]);const h=$e(a,e);return f?i.jsx(u.Card,{children:i.jsxs("div",{className:"flex flex-col gap-6",children:[i.jsxs("div",{className:"flex flex-col",children:[i.jsx(u.Heading,{size:"lg",children:r}),i.jsx(u.Text,{accentColor:"base",children:o})]}),h]})}):null});kr.displayName="FieldSectionLayout";const Pe=class Pe extends Kt{constructor(e){const{label:r=null,fields:o,condition:a=null,conditional:l,...s}=e;super({...s,type:"section"});N(this,"label");N(this,"fields");N(this,"condition");this.fields=o,this.condition=a,this.label=r,l===!1&&(this.condition=null)}static getFieldCreationSchema(e,r=""){if(e.length===0)return[];const o=r&&`${r}.`;return[{field:new Ce({label:"Conditionally render section",identifier:`${o}conditional`,required:!1}),showDirectly:!0},{field:new Pe({label:"Conditional settings",identifier:`${o}conditional-settings`,condition:{identifier:`${o}conditional`,value:!0},fields:[new je({label:"Field",description:"The field to use for the condition.",options:e.map(a=>!a.label||a.type==="upload"?null:{label:a.label,value:a.identifier}).filter(a=>!!a),identifier:`${o}condition.identifier`,required:!0}),new jo({label:"Value",identifier:`${o}condition.value`,required:!0,clonedFieldIdentifier:`${o}condition.identifier`,getFieldToClone(a){if(!a)return null;const l=e.find(s=>s.identifier===a);return l?{...l,label:"Value",identifier:`${o}condition.value`,description:"The value to compare against.",required:l.type!=="boolean"}:(console.error("Could not find field with identifier",a),null)}})]}),showDirectly:!1}]}static deserialize(e){if(e.type!=="section")throw new Error("Invalid type");if(!Array.isArray(e.fields))throw new Error(`Invalid fields: ${e.fields} (not an array)`);const r=e.fields.map(pn);return new Pe({...e,fields:r})}conditional(){return this.condition!==null}serialize(){return{...super._serialize(),label:this.label,condition:this.condition,conditional:this.conditional(),fields:this.fields.map(e=>e.serialize())}}getErrors(e){const r={};for(const o of this.fields){const a=o.getId(),l=o.getError(Y(e,a),e);l&&Ct(r,o.getId(),l)}return r}getInput(e){return i.jsx(kr,{field:this,...e})}};N(Pe,"fieldTypeName","Section"),N(Pe,"fieldTypeDescription","Sections can be useful for grouping fields together. They can also be conditionally shown or hidden.");let H=Pe;const fe=t=>Object.keys(t).length>0,gt=(t,n)=>{const e={};for(const r of t.fields)if(r instanceof H){if(r.condition){const{identifier:o}=r.condition;if(!gn(r.condition,Y(n,o)))continue}Object.assign(e,r.getErrors(n))}else{if(!(r instanceof q))throw new Error("Invalid field type");const o=r.getId(),a=r.getError(Y(n,o),n);a&&Ct(e,o,a)}if(fe(e))return e},Jo=[null,void 0],vt=(t,n)=>t.reduce((e,r)=>r instanceof H?{...e,...vt(r.fields,n)}:(Jo.includes(Y(e,r.getId()))&&Ct(e,r.getId(),""),e),Zr(n)),Zo=()=>{throw new Error("onSubmit must be provided if form is not readonly.")},Vr=d.memo(d.forwardRef((t,n)=>{const{schema:e,values:r={},onSubmit:o=Zo,submitText:a="Submit",cancelText:l,onCancel:s,onDirty:p,onDirtyChange:c,hideTitle:f=!e.title,hideDescription:h,className:m,buttonProps:y}=t,{readonly:x}=e.meta,g=d.useMemo(()=>crypto.randomUUID(),[]),b=j.useFormik({initialValues:vt(e.fields,r),onSubmit:o,validate:F=>gt(e,F),validateOnBlur:!1,validateOnChange:!1}),{dirty:E}=b,w=d.useMemo(()=>typeof e.title=="string"?i.jsx(u.Heading,{size:"lg",children:e.title}):e.title,[e.title]),S=d.useMemo(()=>typeof e.description=="string"?i.jsx(u.Text,{accentColor:"base",children:e.description}):e.description,[e.description]),I=$e(e.fields,{formId:g,disabled:x});return d.useEffect(()=>{E&&p&&p(),c&&c(E)},[E,p,c]),i.jsx(j.FormikProvider,{value:b,children:i.jsxs("form",{id:g,ref:n,className:we(m,"flex flex-col gap-2"),onSubmit:b.handleSubmit,children:[!f&&i.jsx(u.Card,{children:i.jsxs("div",{className:"flex flex-col gap-1",children:[w,!h&&S]})}),I,!x&&i.jsxs("div",{className:"flex items-center justify-end gap-2",children:[l&&i.jsxs(u.Button,{accentColor:$.danger,...y,type:"button",onClick:s,children:[i.jsx(u.RiIcon,{icon:"RiCloseLine"}),l]}),i.jsxs(u.Button,{...y,type:"submit",disabled:!b.isValid,accentColor:"success",children:[i.jsx(u.RiIcon,{icon:"RiCheckLine"}),a]})]})]})})})),he=d.memo(t=>{const{name:n,render:e}=t,{submitForm:r}=j.useFormikContext(),[o,a,l]=j.useField(n),s=d.useMemo(()=>{const p=c=>{l.setValue(c,!1)};return e({value:o.value,meta:a,setValue:p,patchValue:()=>{r()}})},[e,o.value,a,r,l]);return i.jsx(i.Fragment,{children:s})});he.displayName="PatchField";const Ro=d.memo(d.forwardRef((t,n)=>{const{children:e,schema:r,values:o,onPatch:a,onError:l,requiresDiff:s=!0,onDirtyChange:p,...c}=t,f=d.useMemo(()=>vt(r.fields,o),[r.fields,o]),h=d.useCallback(w=>{const S={};for(const I in w){const F=w[I];F!==f[I]&&F!==void 0&&(S[I]=F)}return S},[f]),m=d.useCallback(w=>{const S=h(w);s&&!fe(S)||a(S)},[h,a,s]),y=d.useCallback(w=>{const S=gt(r,w);if(S&&l(S),p){const I=h(w);p(fe(I))}return S},[r,p,l,h]),x=j.useFormik({initialValues:f,onSubmit:m,validate:y,validateOnBlur:!1,validateOnChange:!1}),g=d.useCallback(()=>{if(p){const w=h(x.values);fe(w)&&p(!0)}},[x.values,h,p]),{errors:b,resetForm:E}=x;return d.useEffect(()=>{fe(b)&&E({values:f,errors:{}})},[b,f,E]),i.jsx(j.FormikProvider,{value:x,children:i.jsx("form",{...c,ref:n,onSubmit:x.handleSubmit,onChange:g,children:e})})})),yt="form-builder",ea=[["string","text"],["select","multi-select","upload","qr"],["boolean","date","number","multi-string"]],vn={...hn,section:H},ta=(t,n)=>{var r;const e={...t};switch(n.type){case"release":for(const o in e)e[o].disabled=!1;return e;case"hold":for(const o in e)(r=e[o])!=null&&r.conditionFields.has(n.fieldId)&&(e[o].disabled=!0);return e;case"update":return n.state}},na=(t,n)=>{if(n)for(let e=0;e<t.length;e++){const r=t[e];if(r){for(const o of r.fields)if(o.identifier===n)return e}}},jr=t=>{var e,r,o;const n={};for(let a=0;a<t.length;a++){const l=t[a];if(!l)throw new Error("Field is undefined.");const s=a>0?(e=n[t[a-1].identifier])==null?void 0:e.conditionFields:void 0,p=new Set(s);(r=l.condition)!=null&&r.identifier&&p.add(l.condition.identifier),n[l.identifier]={disabled:!1,conditionFields:p,conditionIndex:na(t,(o=l.condition)==null?void 0:o.identifier),index:a,label:l.label}}return n},yn=d.memo(t=>{const{index:n,type:e,sectionIndex:r,remove:o,duplicate:a,move:l,upload:s}=t;if(e!=="section"&&!s)throw new Error("Upload function prop must be defined for non-section fields.");const{values:p}=j.useFormikContext(),c=d.useRef(null),f=d.useMemo(()=>{const h=[{Icon:W.RiFileCopyLine,key:"duplicate",text:"Duplicate",buttonProps:{onClick:a}}];return n!==0&&h.push({Icon:W.RiDeleteBin2Line,key:"delete",text:"Delete",buttonProps:{onClick:o}}),e!=="section"&&h.unshift({Icon:W.RiImageLine,key:"upload",text:"Upload image",buttonProps:{onClick:()=>{var m;(m=c.current)==null||m.click()}}}),(r===void 0&&n!==p.fields.length-1||r!==void 0&&(r<p.fields.length-1||n!==p.fields[r].fields.length-1))&&h.unshift({Icon:W.RiArrowDownLine,key:"moveDown",text:"Move down",buttonProps:{onClick:()=>{l("down")}}}),(r===void 0&&n!==0||r!==void 0&&(r!==0||n!==0))&&h.unshift({Icon:W.RiArrowUpLine,key:"moveUp",text:"Move up",buttonProps:{onClick:()=>{l("up")}}}),h},[a,n,l,o,r,e,p.fields]);return i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"mx-2 flex hidden flex-col gap-5 sm:block",children:f.map(h=>{const m=h.Icon;return i.jsx(u.IconButton,{type:"button",variant:"ghost",accentColor:h.key.startsWith("move")?"base":void 0,"aria-label":h.text,...h.buttonProps,children:i.jsx(m,{})},h.key)})}),i.jsx("div",{className:"sm:hidden",children:i.jsxs(u.Menu.Root,{children:[i.jsx(u.Menu.ClickTrigger,{children:i.jsx(u.IconButton,{variant:"ghost","aria-label":"Actions menu",children:i.jsx(u.RiIcon,{icon:"RiMore2Line"})})}),i.jsx(u.Menu.Content,{children:f.map(h=>{var y;const m=h.Icon;return i.jsxs(u.Menu.Item,{onClick:(y=h.buttonProps)==null?void 0:y.onClick,children:[i.jsx(m,{}),h.text]},h.key)})})]})}),e!=="section"&&i.jsx("input",{style:{display:"none"},ref:c,type:"file",accept:"image/*",onChange:s})]})});yn.displayName="FieldActions";const Ur=(t=()=>null)=>d.useMemo(()=>ea.map(n=>n.map(e=>{const r=hn[e],o=r.Icon;return{children:r.fieldTypeName,leftSlot:i.jsx(o,{}),value:e,onSelect:()=>{t(e)}}})),[t]),pe=t=>t.type==="section",wn=d.memo(t=>{const{popoverInputs:n,hasError:e}=t;return i.jsxs(u.Popover.Root,{children:[i.jsx(u.Popover.Trigger,{children:i.jsxs(u.Button,{variant:"soft",size:"sm","aria-label":"settings",...e&&{color:$.danger},children:[i.jsx(u.RiIcon,{icon:"RiSettings2Line"}),i.jsx("span",{children:"Settings"})]},"settings")}),i.jsx(u.Popover.Content,{size:"sm",children:i.jsx("div",{className:"flex max-w-[240px] flex-col",children:n})})]})});wn.displayName="FieldSettingsPopover";const bn=d.memo(t=>{var re,wt,Cn,Kr,Qr,Yr;const{parentPath:n,index:e,initial:r,conditionalSourceFields:o}=t,{values:a,setFieldValue:l,errors:s}=j.useFormikContext(),p=Ur(),c=d.useRef(null),f=576,[h,m]=d.useState(c.current&&c.current.getBoundingClientRect().width>=f);d.useEffect(()=>{const P=c.current;if(P){const O=new ResizeObserver(G=>{G[0]&&m(G[0].contentRect.width>=f)});return O.observe(P),()=>{O.disconnect()}}},[]);const[y,x]=d.useState(void 0),[g,b]=d.useState(!1);d.useEffect(()=>{pe(r)?x(void 0):r.image instanceof Promise?r.image.then(x).catch(console.error):x(r.image)},[r]);const E=y?URL.createObjectURL(y):void 0,w=d.useCallback(P=>{P.stopPropagation();const{image:O,...G}=r;l(`${n}.${e}`,G).then()},[e,r,n,l]);d.useEffect(()=>{pe(r)&&!r.conditional&&l(`${n}.${e}.condition`,null).then()},[e,r,n,l]);const S=d.useMemo(()=>{var P,O;return pe(r)?(O=Ir(a.fields,(P=r.condition)==null?void 0:P.identifier))==null?void 0:O.label:void 0},[r,a.fields]),I=pe(r)?Array.isArray((re=r.condition)==null?void 0:re.value)?"contains all of":"equals":void 0;let F;if(pe(r)){if(mt((wt=r.condition)==null?void 0:wt.value))throw new Error("File values are not supported for conditions.");F=Array.isArray((Cn=r.condition)==null?void 0:Cn.value)?r.condition.value.map(P=>typeof P=="string"?P:P.label).join(", "):(Qr=(Kr=r.condition)==null?void 0:Kr.value)==null?void 0:Qr.toString()}const L=d.useCallback(P=>{P.target.parentNode instanceof HTMLElement&&(P.target.parentNode.dataset.replicatedValue=P.target.value)},[]),T=d.useCallback(P=>{P.target.parentNode instanceof HTMLElement&&(P.target.parentNode.dataset.replicatedValue=P.target.value)},[]),D=r.type,A=vn[D],[B,X]=d.useMemo(()=>{let P=[],O=[];if(A===H){if(o===void 0)throw new Error("Conditional source fields must be provided when changing sections.");const G=A.getFieldCreationSchema(o,`${n}.${e}`);P=P.concat(G.filter(V=>V.showDirectly).map(V=>V.field)),O=O.concat(G.filter(V=>!V.showDirectly).map(V=>V.field))}else{if(!(A.prototype instanceof q))throw new Error(`Field must be an instance of BaseField. Got ${A.toString()}.`);const G=A.getFieldCreationSchema(`${n}.${e}`);h?(P=[...P,...G.filter(V=>V.showDirectly).map(V=>V.field)],O=[...O,...G.filter(V=>!V.showDirectly).map(V=>V.field)]):O=[...O,...G.map(V=>V.field)]}return[P,O]},[A,o,n,e,h]),Q=$e(B,{formId:yt,disabled:!1,internal:!0,...A===H&&{size:"sm"}}),z=$e(X,{formId:yt,disabled:!1});let M=X.length>0;pe(r)&&X.length>0&&(M=r.conditional);const k=X.some(P=>{const O=Y(s,A===H?`${n}.${e}.condition`:P.getId());return O&&(typeof O!="object"||fe(O))}),se=k?$.danger:void 0,Ue=d.useMemo(()=>pt(r),[r]),We=Rt(Ue,{formId:yt,showInputOnly:!1});return i.jsx("div",{className:"flex grow items-center w-full",ref:c,children:i.jsxs("div",{className:"flex w-full flex-col gap-4",children:[A===H&&i.jsxs("div",{className:"flex flex-col gap-2",children:[B.length>0&&Q,i.jsxs("div",{className:"flex items-center gap-4",children:[M&&i.jsx(wn,{popoverInputs:z,hasError:k}),pe(r)&&r.conditional&&i.jsx("span",{className:"text-sm text-(--accent-a11)","data-accent-color":se,children:i.jsxs("em",{children:["Display only if ",i.jsx("strong",{children:S})," ",I," ",i.jsx("strong",{children:F})]})})]})]}),A!==H&&i.jsxs("div",{className:"flex gap-2 w-full justify-between",children:[i.jsxs("div",{className:"flex gap-2 items-center",children:[i.jsx(u.Badge,{className:"w-fit",accentColor:"base",variant:"soft",children:(Yr=p.flat().find(P=>P.value===D))==null?void 0:Yr.children}),i.jsx(he,{name:`${n}.${e}.required`,render:({setValue:P,value:O})=>i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(u.Checkbox.Root,{checked:O,onCheckedChange:P,variant:"soft",children:i.jsx(u.Checkbox.Indicator,{children:i.jsx(u.RiIcon,{icon:"RiCheckLine"})})}),i.jsx(u.Text,{size:"sm",accentColor:"base",children:"Required field"})]})})]}),M&&i.jsx(wn,{popoverInputs:z,hasError:k})]}),y&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"group relative inline-block w-full min-w-[300px]",children:[i.jsx("img",{className:"h-[100px] w-full min-w-[300px] cursor-pointer rounded-md object-cover",src:E,alt:y.name,onClick:()=>{b(!0)}}),i.jsx(u.IconButton,{className:"absolute top-2 right-2 hidden group-hover:not-disabled:flex",variant:"solid",accentColor:$.danger,"aria-label":"delete",onClick:w,children:i.jsx(u.RiIcon,{icon:"RiDeleteBin2Line"})})]}),g&&i.jsx(Qt,{file:y,url:E,name:y.name,setShowPreview:b})]}),i.jsx(he,{name:`${n}.${e}.label`,render:({setValue:P,value:O})=>i.jsx(u.Input.Root,{size:"md",variant:"outline",children:i.jsx(u.Input.Field,{placeholder:D==="section"?"Enter a section label (optional)":"Enter your question",value:O,onChange:G=>{P(G.target.value)},onInput:L,maxLength:200})})}),i.jsx(he,{name:`${n}.${e}.description`,render:({setValue:P,value:O})=>i.jsx(u.TextArea,{className:"field-sizing-content grow",placeholder:`Enter a ${D==="section"?"section":"field"} description (optional)`,value:O,onChange:G=>{P(G.target.value)},onInput:T,resize:"none",maxLength:1e3,variant:"outline"})}),A!==H&&B.length>0&&i.jsx("div",{className:"w-full",children:Q}),A!==H&&i.jsxs(i.Fragment,{children:[i.jsx(u.Separator,{size:"full"}),i.jsxs("div",{className:"flex flex-col gap-2",children:[i.jsx(u.Text,{accentColor:"base",children:"Field preview"}),i.jsx("div",{children:We})]})]})]})})});bn.displayName="FieldBuilder";const Wr=d.memo(t=>{const{field:n,index:e,sectionIndex:r,remove:o}=t,{setFieldValue:a,values:l}=j.useFormikContext(),{reorderField:s}=nn(),{showError:p}=u.useToast(),c=`fields.${r}.fields`,f=d.useMemo(()=>({index:e,parentPath:c,initial:n}),[n,e,c]),h=d.useCallback(()=>{const x=n.label??"Unlabelled field",g={...n,label:x};st(c,e+1,g,l,a)},[n,c,e,l,a]),m=d.useCallback(x=>{const g=r,b=l.fields[g];let E=r,w=x==="up"?e-1:e+1;x==="up"&&e===0?(E=r-1,w=l.fields[E].fields.length):x==="down"&&e===b.fields.length-1&&(E=r+1,w=0);const S=l.fields[E];s(b,g,e,S,E,w,a)},[r,l.fields,e,s,a]),y=d.useCallback(x=>{const{files:g}=x.target;if(!g||g.length!==1)return;const b=g.item(0);if(b){if(b.size>Ko){p({title:"File upload error",description:`The file ${b.name} exceeded the maximum file size`});return}a(`${c}.${e}`,{...n,image:b}).then()}},[n,e,c,a,p]);return i.jsx(ie.Draggable,{draggableId:n.identifier,index:e,children:x=>i.jsx(u.Card,{ref:x.innerRef,...x.draggableProps,...x.dragHandleProps,className:"mb-4",children:i.jsxs("div",{className:"flex items-center justify-between gap-4 w-full",children:[i.jsx(bn,{...f}),i.jsx(yn,{index:e,type:n.type,sectionIndex:r,remove:o,duplicate:h,move:m,upload:y})]})})})});Wr.displayName="FieldWithActions";const qr=d.memo(t=>{var S;const{field:n,index:e,dropState:r,fieldsOnly:o}=t,a=(S=r[n.identifier])==null?void 0:S.disabled,{setFieldValue:l,values:s}=j.useFormikContext(),p=u.useAlertDialog(),{reorderSection:c}=nn(),f=d.useCallback((I,F)=>{for(const L of I){const T=F.indexOf(L);l(`fields.${T}.condition`,null).then(),l(`fields.${T}.conditional`,!1).then()}},[l]),h=d.useCallback(I=>{var T;const F=n.fields[I];if(!F)throw new Error("Could not find field to remove.");const L=[];for(const D of s.fields)((T=D.condition)==null?void 0:T.identifier)===F.identifier&&L.push(D);return{removing:F,affectedSections:L,action:()=>l(`fields.${e}.fields`,lt(n.fields,I))}},[n.fields,s.fields,l,e]),m=d.useCallback(I=>{const{affectedSections:F,action:L,removing:T}=h(I),D=()=>{L().then(),f(F,s.fields)};if(F.length>0){const A=F.map(B=>B.label).join(", ");p({title:"Remove condition?",description:`${T.label} is being used as a condition, deleting it will remove the condition from the ${A} section(s).`,action:"Remove",onAction:D});return}D()},[h,f,s.fields,p]),y=d.useCallback(()=>{const F=n.fields.map((Q,z)=>h(z)).flatMap(Q=>Q.affectedSections),L=F.length?"Remove fields and conditions?":"Remove fields?",T=n.fields.length,D=F.map(Q=>Q.label).join(", "),A=F.length?`Deleting this section will remove the ${T} field(s) it contains and will remove the conditions from following sections: ${D}`:`Deleting this section will remove the ${T} field(s) it contains.`,B=lt(s.fields,e),X=()=>l("fields",B);if(F.length>0){p({title:L,description:A,action:"Remove",onAction:()=>{X().then(()=>{f(F,B)})}});return}X().then()},[n.fields,s.fields,e,h,l,p,f]),x=d.useCallback(I=>{const F=I==="up"?e-1:e+1;c(r,n.identifier,e,F,s,l)},[e,c,r,n.identifier,s,l]),g=d.useMemo(()=>({index:e,parentPath:"fields",initial:n,conditionalSourceFields:Er(s.fields,e)}),[n,e,s.fields]),b=d.useCallback(()=>{const I=n.label??"Untitled section",F=n.fields.map(T=>({...T,identifier:tn(null,T.label)})),L={...n,label:I,fields:F};st("fields",e+1,L,s,l)},[n,e,s,l]),E=d.useCallback(I=>{st(`fields.${e}.fields`,n.fields.length,Xo[I],s,l)},[e,n.fields.length,s,l]),w=Ur(E);return i.jsx(ie.Draggable,{draggableId:n.identifier,index:e,children:I=>i.jsx(u.Card,{ref:I.innerRef,...I.draggableProps,...I.dragHandleProps,variant:"outline",className:"mb-4 w-full",children:i.jsxs("div",{className:"flex items-center justify-between gap-3 w-full",children:[i.jsxs("div",{className:"flex grow flex-col gap-2 w-full",children:[!o&&i.jsx(bn,{...g}),i.jsx(ie.Droppable,{droppableId:n.identifier,type:"SECTION",isDropDisabled:a,children:F=>i.jsxs("div",{className:"flex flex-col gap-0 w-full",ref:F.innerRef,...F.droppableProps,children:[n.fields.map((L,T)=>i.jsx(Wr,{field:L,index:T,sectionIndex:e,remove:()=>{m(T)}},L.identifier)),F.placeholder,i.jsxs(u.Menu.Root,{children:[i.jsx(u.Menu.ClickTrigger,{children:i.jsxs(u.Button,{type:"button",variant:"solid",children:[i.jsx(u.RiIcon,{icon:"RiAddLine"})," Add field"]})}),i.jsx(u.Menu.Content,{children:w.flat().map(L=>i.jsxs(u.Menu.Item,{onSelect:L.onSelect,children:[L.leftSlot,L.children]},L.value))})]})]})})]}),!o&&i.jsx(yn,{index:e,type:n.type,remove:y,duplicate:b,move:x})]})})})});qr.displayName="FieldSectionWithActions";const Hr=(t,n)=>{for(const[e,r]of Object.entries(t))if(r.identifier===n)return[r,e]},Gr=d.memo(t=>{const{fieldsOnly:n}=t,{values:e,setFieldValue:r}=j.useFormikContext(),[o,a]=d.useReducer(ta,e.fields,jr),{reorderSection:l,reorderField:s}=nn();d.useEffect(()=>{a({type:"update",state:jr(e.fields)})},[a,e.fields]);const p=d.useCallback(h=>{h.type==="SECTION"&&a({type:"hold",fieldId:h.draggableId})},[]),c=d.useCallback(h=>{const{source:m,destination:y,type:x,reason:g,draggableId:b}=h;if(a({type:"release"}),!y||g==="CANCEL")return;if(x==="ROOT"){l(o,b,m.index,y.index,e,r);return}if(x!=="SECTION")throw new Error("Unexpected droppable type.");const[E,w]=Hr(e.fields,m.droppableId)??[],[S,I]=Hr(e.fields,y.droppableId)??[];s(E,w,m.index,S,I,y.index,r)},[e,s,r,l,o]),f=d.useCallback(h=>{Wo(h+1,e,r)},[e,r]);return i.jsx(ie.DragDropContext,{onDragStart:p,onDragEnd:c,children:i.jsx(ie.Droppable,{droppableId:"droppable",type:"ROOT",children:h=>i.jsxs("div",{className:"flex flex-col gap-0",ref:h.innerRef,...h.droppableProps,children:[e.fields.map((m,y)=>i.jsxs(d.Fragment,{children:[i.jsx(qr,{field:m,index:y,dropState:o,fieldsOnly:n}),!n&&i.jsxs(u.Button,{className:"mb-4",type:"button",variant:"soft",accentColor:"base",onClick:()=>{f(y)},children:[i.jsx(u.RiIcon,{icon:"RiAddLine"})," Add section"]})]},m.identifier)),h.placeholder]})})})});Gr.displayName="FieldsEditor";const ra=()=>{alert("This is a form preview, your data will not be saved.")},ia=d.memo(d.forwardRef((t,n)=>{const{onCancel:e,onSave:r,revision:o,initialTitle:a,showExplainerText:l=!0,showFormTitle:s=!0,fieldsOnly:p=!1,showTabs:c=!0,tabsListClassName:f,hydrateRevisionWithImages:h}=t,{showError:m}=u.useToast(),y=d.useCallback(w=>{const S={};w.title||(S.title="Title is required."),(!w.fields||w.fields.length===0)&&(S.fields="At least one field is required.");let I=[];for(const[L,T]of w.fields.entries()){const A=vn.section.getFieldCreationSchema(Er(w.fields,L),`fields.${L}`).map(B=>B.field);I=[...I,...A];for(const[B,X]of T.fields.entries()){const z=vn[X.type].getFieldCreationSchema(`fields.${L}.fields.${B}`).map(M=>M.field);I=[...I,...z]}}const F=gt({fields:I},w);if(F&&(S.fields=F.fields),fe(S))return m({title:"Some form settings are invalid",description:"Please check settings highlighted in red."}),S},[m]),x=d.useMemo(()=>({title:a??"",description:"",fields:[{...at(tn(null,"")),label:""}]}),[a]),g=o?h(o):void 0,b=j.useFormik({initialValues:Uo(g)??x,validate:y,onSubmit:r,validateOnChange:!1,validateOnBlur:!1}),E=d.useMemo(()=>$r(b.values),[b.values]);return i.jsx(u.Tabs.Root,{ref:n,defaultValue:"edit",children:i.jsxs("div",{className:"flex flex-col gap-2",children:[c&&i.jsxs(u.Tabs.List,{className:we("sticky top-0 z-[2000] flex bg-(--color-background)",f),children:[i.jsx(u.Tabs.Trigger,{className:"grow",value:"edit",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(u.RiIcon,{icon:"RiPencilLine"}),"Edit form"]})}),i.jsx(u.Tabs.Trigger,{className:"grow",value:"preview",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(u.RiIcon,{icon:"RiEyeLine"}),"Preview form"]})})]}),i.jsxs(u.Tabs.Content,{value:"edit",children:[l&&i.jsxs("span",{children:["Create your form using various field types. Sections can be"," ",i.jsx("strong",{children:"conditionally rendered"})," based on"," ",i.jsx("strong",{children:"answers to fields in preceding sections. "})]}),i.jsxs("form",{className:"mt-3 flex flex-col gap-2",id:yt,onSubmit:b.handleSubmit,children:[i.jsxs(j.FormikProvider,{value:b,children:[s&&i.jsxs(i.Fragment,{children:[i.jsx(he,{name:"title",render:({setValue:w,value:S,meta:I})=>i.jsx(Yt,{severity:"danger",helpText:I.error??null,children:i.jsx(u.Input.Root,{variant:"outline",size:"lg",accentColor:I.error?$.danger:"primary",children:i.jsx(u.Input.Field,{placeholder:"Form title",value:S,onChange:F=>{w(F.target.value)},maxLength:100})})})}),i.jsx(he,{name:"description",render:({setValue:w,value:S})=>i.jsx(u.TextArea,{className:"field-sizing-content",placeholder:"Explain the purpose of this form",value:S,onChange:I=>{w(I.target.value)},resize:"vertical",maxLength:1e3})})]}),i.jsx(Gr,{fieldsOnly:p}),i.jsx("span",{"data-accent-color":$.danger,className:"text-xs text-(--accent-a11)",children:typeof b.errors.fields=="string"&&b.errors.fields})]}),i.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e&&i.jsx(u.Button,{type:"button",variant:"solid",accentColor:"base",onClick:e,children:"Cancel"}),i.jsx(u.Button,{type:"submit",children:"Save form"})]})]})]}),i.jsx(u.Tabs.Content,{value:"preview",children:i.jsx(Vr,{schema:E,onSubmit:ra,hideTitle:!s})})]})})})),oa=Object.values(U.Colors),aa=1;async function la(t,n,e,r){const o=t.getContext("2d",{}),a=new Image(r.width,r.height),l=new Image(r.width,r.height),s=new U.DeferredPromise;return a.onload=function(){o.drawImage(a,0,0,r.width,r.height),l.src=URL.createObjectURL(e),l.onload=async function(){o.drawImage(l,0,0,r.width,r.height);const p=t.toDataURL("image/jpeg",aa),c=await U.fileToBlob(p),f=new File([c],n.name,{type:"image/jpeg"});s.resolve(f)}},a.src=URL.createObjectURL(n),s}const Xr=d.memo(t=>{const{file:n,onClose:e,onSave:r,onDelete:o,dirty:a,onDirty:l}=t;n.objectURL||(n.objectURL=URL.createObjectURL(n));const s=d.useRef(null),p=d.useRef(null),[c,f]=d.useState(U.Colors.red),[h,m]=d.useState(null),[y,x]=d.useState(!1),[g,b]=d.useState(!1),E=d.useRef(null),w=u.useSize(E);d.useEffect(()=>{const z=new Image;z.onload=function(){m({width:z.naturalWidth,height:z.naturalHeight})},z.src=URL.createObjectURL(n)},[n]),d.useEffect(()=>{!g&&(w!=null&&w.width)&&w.height&&b(!0)},[w,g]);const S=d.useCallback(async()=>{a||e();const z=s.current;if(!z)return;if(!h)throw new Error("Original image size not loaded yet");const M=await z.exportImage("png"),k=new Image(h.width,h.height);k.onload=async function(){const se=await U.fileToBlob(M),Ue=new File([se],n.name,{type:n.type}),We=p.current,re=await la(We,n,Ue,h);re.objectURL=URL.createObjectURL(re);const wt=await U.hashFile(n);await U.hashFile(re)!==wt&&r(re),x(!1),e()},x(!0),k.src=M},[a,n,e,r,h]),I=d.useCallback(()=>{o(n)},[n,o]),F=d.useCallback(()=>{e()},[e]),L=d.useCallback(()=>{l(!0)},[l]),T=d.useCallback(()=>{s.current&&s.current.redo()},[]),D=d.useCallback(()=>{s.current&&s.current.undo()},[]),A=d.useCallback(()=>{s.current&&(l(!1),s.current.clearCanvas())},[l]),B=d.useCallback(z=>{s.current&&s.current.eraseMode(z)},[]),X=d.useCallback(()=>{S()},[S]),Q=d.useCallback(()=>{U.downloadFile(n)},[n]);return i.jsx(Me,{open:!0,onOpenChange:e,children:i.jsxs(Ae,{children:[i.jsx(Oe,{className:"light:bg-(--black-a6) fixed inset-0 dark:bg-(--black-a8)"}),i.jsx(Be,{className:"fixed inset-0",children:i.jsxs(i.Fragment,{children:[h&&i.jsx("canvas",{style:{display:"none"},id:"attachment-markup-canvas",ref:p,width:h.width,height:h.height}),i.jsxs("div",{className:"relative flex h-full w-full flex-col",children:[i.jsx("div",{className:"flex h-8 w-full items-center bg-(--color-background) px-2",children:i.jsx(u.ButtonGroup,{accentColor:"base",size:"md",variant:"soft",children:i.jsxs("div",{className:"grid w-full grid-cols-3",children:[i.jsxs("div",{className:"flex gap-2",children:[i.jsx(u.IconButton,{"aria-label":"close",onClick:F,children:i.jsx(u.RiIcon,{icon:"RiCloseLine"})}),i.jsx(u.IconButton,{"aria-label":`Download ${n.name}`,onClick:Q,children:i.jsx(u.RiIcon,{icon:"RiDownload2Line"})})]}),i.jsxs("div",{className:"flex items-center justify-center gap-2",children:[i.jsx(It,{selectedColor:c,allColors:oa,onFinish:f,trigger:i.jsx(u.IconButton,{"aria-label":"Markup color picker",type:"button",variant:"solid",style:{backgroundColor:c},children:" "})}),i.jsx(u.IconToggleButton,{defaultPressed:!1,"aria-label":"erase",onPressedChange:B,children:i.jsx(u.RiIcon,{icon:"RiEraserFill"})}),i.jsx(u.Separator,{orientation:"vertical",size:"full"}),i.jsx(u.IconButton,{"aria-label":"undo",onClick:D,children:i.jsx(u.RiIcon,{icon:"RiArrowGoBackLine"})}),i.jsx(u.IconButton,{"aria-label":"undo",onClick:T,children:i.jsx(u.RiIcon,{icon:"RiArrowGoForwardLine"})}),i.jsx(u.IconButton,{"aria-label":"undo all",onClick:A,children:i.jsx(u.RiIcon,{icon:"RiLoopLeftLine"})})]}),i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(u.IconButton,{"aria-label":"Save markup",accentColor:"primary",onClick:X,children:i.jsx(u.RiIcon,{icon:"RiSaveLine"})}),i.jsx(u.IconButton,{"aria-label":"Delete attachment",onClick:I,children:i.jsx(u.RiIcon,{icon:"RiDeleteBin2Line"})})]})]})})}),i.jsxs("div",{className:"relative flex w-full grow items-center justify-center p-4",children:[i.jsx("img",{className:"translate-xmax-h-[calc(100%-130px)] pointer-events-none invisible absolute top-[50%] left-[50%] max-w-svw translate-x-[-50%] translate-y-[-50%] object-contain",alt:"Photo attachment",ref:E,src:n.objectURL}),y?i.jsx(u.Spinner,{}):i.jsx(Rr.ReactSketchCanvas,{backgroundImage:n.objectURL,ref:s,width:`${(w==null?void 0:w.width)||0}px`,height:`${(w==null?void 0:w.height)||0}px`,onStroke:L,strokeColor:c},g?"1":"0")]})]})]})})]})})});Xr.displayName="AttachmentEditor",C.BaseField=q,C.BaseFormElement=Kt,C.BooleanField=Ce,C.BooleanInput=Jt,C.ColorPicker=It,C.DateField=it,C.DateInput=Zt,C.FieldSection=H,C.FileBadge=ze,C.FileCard=Gt,C.FileIcon=_e,C.FileViewerContext=Xt,C.FileViewerProvider=gr,C.FormBuilder=ia,C.FormRenderer=Vr,C.ImageCard=Br,C.ImageMarkup=Xr,C.ImageViewer=jt,C.InputWithHelpText=Yt,C.InputWithLabel=Z,C.InputWithLabelAndHelpText=R,C.MultiSelectField=Ve,C.MultiSelectInput=sn,C.MultiStringField=ke,C.MultiStringInput=rn,C.NumberField=le,C.NumberInput=on,C.PDFViewer=Wt,C.PatchField=he,C.PatchFormProvider=Ro,C.QrField=ct,C.QrInput=an,C.QrScanner=ln,C.SUPPORTED_IMAGE_FILE_TYPES=Et,C.SUPPORTED_PDF_FILE_TYPES=Ut,C.SUPPORTED_SPREADSHEET_FILE_EXTENSIONS=qt,C.SelectField=je,C.SelectInput=cn,C.SpreadsheetViewer=Ht,C.StringField=ut,C.StringInput=dn,C.TextField=ft,C.TextInput=un,C.decodeFormValues=Qo,C.deserialize=pt,C.deserializeField=pn,C.emptyBaseField=K,C.emptyBooleanField=wr,C.emptyDateField=br,C.emptyMultiSelectField=Dr,C.emptyMultiStringField=Sr,C.emptyNumberField=Nr,C.emptyQrField=Tr,C.emptySelectField=Pr,C.emptyStringField=Ar,C.emptyTextField=Or,C.encodeFormValues=Yo,C.flattenFields=mn,C.formRevisionToSchema=$r,C.initialFormValues=vt,C.isConditionMet=gn,C.useFieldInput=Rt,C.useFieldInputs=$e,C.useFileViewer=mr,C.useFormikInput=_,C.validateForm=gt,C.valueIsFile=mt,Object.defineProperty(C,Symbol.toStringTag,{value:"Module"})});
|
|
45
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${n.docsSlug}`;return v.useEffect(()=>{t&&(document.getElementById(t)||console.error(e))},[e,t]),null},Po="DialogDescriptionWarning",Mo=({contentRef:t,descriptionId:n})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${ur(Po).contentName}}.`;return v.useEffect(()=>{var a;const o=(a=t.current)==null?void 0:a.getAttribute("aria-describedby");n&&o&&(document.getElementById(n)||console.warn(r))},[r,t,n]),null},Me=tr,Ae=ir,Oe=or,Be=ar;const jt=d.memo(t=>{const{file:n,onClose:e,onDelete:r}=t,{md:o}=u.useViewportSize(),a=d.useRef(null),l=d.useRef(null),s=d.useRef(null),p=d.useCallback(()=>{if(!l.current||!a.current||!s.current)return;const h=s.current.height-l.current.clientHeight,m=s.current.width-l.current.clientWidth;h>=0||m>=0?m>h?(a.current.style.width=`${l.current.clientWidth}px`,a.current.style.height="unset"):(a.current.style.height=`${l.current.clientHeight}px`,a.current.style.width="unset"):(a.current.style.width=`${s.current.width}px`,a.current.style.height=`${s.current.height}px`)},[]),c=d.useCallback(()=>{r&&r(n)},[n,r]),f=d.useCallback(()=>{U.downloadFile(n)},[n]);return d.useLayoutEffect(()=>{const h=new Image;h.onload=()=>{s.current={width:h.width,height:h.height},p()},h.src=URL.createObjectURL(n)},[p,n]),d.useLayoutEffect(()=>{if(!l.current)return;const h=new ResizeObserver(()=>{p()});return h.observe(l.current),()=>{h.disconnect()}},[p]),i.jsx(Me,{open:!0,onOpenChange:e,children:i.jsxs(Ae,{children:[i.jsx(Oe,{className:"light:bg-(--black-a6) fixed inset-0 dark:bg-(--black-a8)","data-floating-content":""}),i.jsx(Be,{className:"fixed inset-0","data-floating-content":"",children:i.jsxs("div",{className:"flex h-full w-full flex-col",children:[i.jsx("div",{className:"flex h-max w-full items-center bg-(--color-background) p-2",children:i.jsx(u.ButtonGroup,{className:"w-full",accentColor:"base",variant:"soft",children:i.jsxs("div",{className:"grid w-full grid-cols-3",children:[i.jsxs("div",{className:"flex justify-start gap-2 items-center",children:[i.jsx(u.IconButton,{onClick:e,"aria-label":"close",children:i.jsx(u.RiIcon,{icon:"RiCloseLine"})}),i.jsx(u.IconButton,{onClick:f,"aria-label":"close",children:i.jsx(u.RiIcon,{icon:"RiDownload2Line"})})]}),i.jsx("div",{className:"flex justify-center",children:i.jsx(ze,{file:n,accentColor:"base",truncateLength:o?void 0:25})}),i.jsx("div",{className:"flex justify-end",children:!!r&&i.jsx(u.IconButton,{onClick:c,"aria-label":"close",children:i.jsx(u.RiIcon,{icon:"RiDeleteBin2Line"})})})]})})}),i.jsx("div",{className:"h-full w-full overflow-hidden p-5",children:i.jsx("div",{className:"flex h-full w-full items-center justify-center overflow-hidden",ref:l,children:i.jsx("img",{ref:a,src:URL.createObjectURL(n),alt:""})})})]})})]})})});jt.displayName="ImageViewer";const Ut=["application/pdf"];bt.pdfjs.GlobalWorkerOptions.workerSrc=new URL("pdfjs-dist/build/pdf.worker.min.js",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:xt&&xt.tagName.toUpperCase()==="SCRIPT"&&xt.src||new URL("forms.umd.cjs",document.baseURI).href).toString();const Ao={initial:.6,xs:.8,sm:.9,md:1,lg:1.1,xl:1.1},Wt=d.memo(t=>{const{file:n,onDelete:e,onClose:r}=t,[o,a]=d.useState(null),[l,s]=d.useState(0),[p,c]=d.useState(!1),{lg:f,size:h}=u.useViewportSize();d.useEffect(()=>{s(0),c(!1),a(null)},[n]);const m=d.useCallback(w=>{s(0),a(w)},[]),y=d.useCallback(()=>{c(!0)},[]),x=d.useCallback(()=>{!o||l===o.numPages-1||s(w=>w+1)},[l,o]),g=d.useCallback(()=>{U.downloadFile(n)},[n]),b=d.useCallback(()=>{l!==0&&s(w=>w-1)},[l]),E=d.useCallback(()=>{e&&e(n)},[n,e]);return i.jsx(Me,{open:!0,onOpenChange:r,children:i.jsxs(Ae,{children:[i.jsx(Oe,{className:"light:bg-(--black-a6) fixed inset-0 dark:bg-(--black-a8)","data-floating-content":""}),i.jsx(Be,{className:"fixed inset-0","data-floating-content":"",children:i.jsxs("div",{className:"flex h-full w-full flex-col items-center",children:[i.jsx("div",{className:"h-max w-full shrink-0 items-center bg-(--color-background) p-2",children:i.jsx(u.ButtonGroup,{className:"flex items-center gap-1",variant:"soft",accentColor:"base",children:i.jsxs("div",{className:"grid w-full grid-cols-3",children:[i.jsxs("div",{className:"w-full gap-2 flex items-center",children:[i.jsx(u.IconButton,{onClick:r,"aria-label":"close",children:i.jsx(u.RiIcon,{icon:"RiCloseLine"})}),i.jsx(u.IconButton,{onClick:g,"aria-label":"download",children:i.jsx(u.RiIcon,{icon:"RiDownload2Line"})})]}),i.jsx("div",{className:"flex justify-center",children:i.jsx(ze,{file:n,accentColor:"base",truncateLength:f?void 0:25})}),i.jsx("div",{className:"flex justify-end",children:!!e&&i.jsx(u.IconButton,{onClick:E,"aria-label":"delete",children:i.jsx(u.RiIcon,{icon:"RiDeleteBin2Line"})})})]})})}),i.jsxs("div",{className:"relative flex h-full w-full flex-col items-center gap-2 p-3",children:[!o&&!p&&i.jsx(fr,{}),i.jsx("div",{className:"flex h-max max-h-full w-max max-w-full flex-col items-center justify-center overflow-auto [scrollbar-color:var(--base-6)_transparent] [scrollbar-width:thin]",children:i.jsxs(bt.Document,{className:"relative",file:n,onLoadSuccess:m,onLoadError:y,error:"",loading:"",children:[i.jsx(bt.Page,{scale:Ao[h],pageIndex:l}),!!o&&!p&&i.jsx("div",{className:"absolute top-0 z-[2] flex w-full justify-center py-2",children:i.jsxs(u.ButtonGroup,{variant:"solid",accentColor:"base",size:"sm",children:[i.jsx(u.IconButton,{onClick:b,"aria-label":"previous page",children:i.jsx(u.RiIcon,{icon:"RiArrowLeftLine"})}),i.jsxs(u.Badge,{accentColor:"base",style:{borderRadius:0},variant:"solid",children:[l+1,"/",o.numPages]}),i.jsx(u.IconButton,{onClick:x,"aria-label":"next-page",children:i.jsx(u.RiIcon,{icon:"RiArrowRightLine"})})]})})]})}),p&&i.jsx(hr,{})]})]})})]})})});Wt.displayName="PDFViewer";const fr=d.memo(()=>i.jsx("div",{className:"absolute flex h-full w-full items-center justify-center",children:i.jsx(u.Spinner,{})}));fr.displayName="SpinnerComponent";const hr=d.memo(()=>i.jsxs("div",{className:"flex h-[70%] w-[40%] flex-col items-center justify-center rounded-md border border-(--base-a6) bg-(--base-2)",children:[i.jsx(u.RiIcon,{icon:"RiFileWarningLine",size:40}),i.jsx("span",{className:"text-sm font-light text-(--accent-a11)","data-accent-color":"base",children:"Failed to load"})]}));hr.displayName="ErrorComponent";const qt=["text/csv","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-excel"],Ht=d.memo(t=>{const{file:n,onClose:e,onDelete:r}=t,{md:o}=u.useViewportSize(),[a,l]=d.useState([]),[s,p]=d.useState({}),[c,f]=d.useState(),[h,m]=d.useState({rowLabels:[],columnLabels:[],data:[[]]}),y=d.useMemo(()=>d.lazy(()=>import("react-spreadsheet")),[n,c]);d.useEffect(()=>{n.arrayBuffer().then(w=>{const{SheetNames:S,Sheets:I}=In.read(w);l(S),p(I),f(S[0])})},[n]),d.useEffect(()=>{if(!c)return;const w=s[c],S=In.utils.sheet_to_json(w),I=Object.keys(S[0]??{}).splice(1),F=S.map(T=>Object.values(T)[0]),L=S.map(T=>I.map(D=>({value:T[D],readOnly:!0})));m({rowLabels:F,columnLabels:I,data:L})},[c,s]);const x=d.useCallback(()=>{r&&r(n)},[n,r]),g=d.useCallback(()=>{U.downloadFile(n)},[n]),b=d.useCallback(()=>{if(!c)throw new Error(`Expected an activeSheet, got ${c}`);const w=a.indexOf(c);if(w<0)throw new Error(`Expected activeSheet to be present in sheets, ${c} not found in ${a.join(", ")}`);w!==a.length-1&&f(a[w+1])},[c,a]),E=d.useCallback(()=>{if(!c)throw new Error(`Expected an activeSheet, got ${c}`);const w=a.indexOf(c);if(w<0)throw new Error(`Expected activeSheet to be present in sheets, ${c} not found in ${a.join(", ")}`);w!==0&&f(a[w-1])},[c,a]);return i.jsx(Me,{open:!0,onOpenChange:e,children:i.jsxs(Ae,{children:[i.jsx(Oe,{className:"light:bg-(--black-a6) fixed inset-0 dark:bg-(--black-a8)","data-floating-content":""}),i.jsx(Be,{className:"fixed inset-0","data-floating-content":"",children:i.jsxs("div",{className:"flex h-full w-full flex-col overflow-hidden",children:[i.jsx("div",{className:"h-max w-full shrink-0 bg-(--color-background) p-2",children:i.jsx(u.ButtonGroup,{size:"md",variant:"soft",accentColor:"base",children:i.jsxs("div",{className:"grid w-full grid-cols-3",children:[i.jsxs("div",{className:"flex gap-2 items-center",children:[i.jsx(u.IconButton,{onClick:e,"aria-label":"close",children:i.jsx(u.RiIcon,{icon:"RiCloseLine"})}),i.jsx(u.IconButton,{onClick:g,"aria-label":"download",children:i.jsx(u.RiIcon,{icon:"RiDownload2Line"})})]}),i.jsx("div",{className:"flex justify-center",children:i.jsx(ze,{file:n,accentColor:"base",truncateLength:o?void 0:25})}),i.jsx("div",{className:"flex justify-end gap-2",children:!!r&&i.jsx(u.IconButton,{"aria-label":"delete",onClick:x,children:i.jsx(u.RiIcon,{icon:"RiDeleteBin2Line"})})})]})})}),i.jsx("div",{className:"flex h-full w-full flex-col items-center gap-3 overflow-hidden p-2",children:i.jsxs(d.Suspense,{fallback:i.jsx(u.Spinner,{}),children:[i.jsx("div",{className:"flex h-max max-h-[calc(100%-50px)] w-max max-w-full overflow-auto [scrollbar-color:var(--base-6)_transparent] [scrollbar-width:thin]",children:i.jsx(y,{className:"z-[1] h-full",data:h.data,rowLabels:h.rowLabels,columnLabels:h.columnLabels})}),i.jsx("div",{className:"flex h-max shrink-0 bg-(--base-2)",children:i.jsxs(u.ButtonGroup,{className:"flex items-center",variant:"solid",accentColor:"base",size:"sm",children:[i.jsx(u.IconButton,{"aria-label":"previous",onClick:E,children:i.jsx(u.RiIcon,{icon:"RiArrowLeftLine"})}),i.jsx(u.Badge,{variant:"solid",size:"sm",style:{borderRadius:0},accentColor:"base",children:c}),i.jsx(u.IconButton,{"aria-label":"next",onClick:b,children:i.jsx(u.RiIcon,{icon:"RiArrowRightLine"})})]})})]})})]})})]})})});Ht.displayName="SpreadsheetViewer";const _e=d.memo(t=>{const{fileType:n}=t,e=d.useMemo(()=>qt.includes(n)?i.jsx(u.RiIcon,{icon:"RiFileExcelLine"}):Ut.includes(n)?i.jsx(u.RiIcon,{icon:"RiFilePdfLine"}):Et.includes(n)?i.jsx(u.RiIcon,{icon:"RiFileImageLine"}):i.jsx(u.RiIcon,{icon:"RiFileLine"}),[n]);return i.jsx("div",{className:"h-max w-max",children:e})});_e.displayName="FileIcon";const ze=d.memo(t=>{const{file:n,truncateLength:e,hideName:r=!1,...o}=t,a=d.useMemo(()=>e!==void 0?U.truncate(n.name,e):n.name,[n.name,e]);return i.jsxs(u.Badge,{...o,children:[i.jsx(_e,{fileType:n.type}),!r&&a]})});ze.displayName="FileBadge";function pr(t){var n,e,r="";if(typeof t=="string"||typeof t=="number")r+=t;else if(typeof t=="object")if(Array.isArray(t)){var o=t.length;for(n=0;n<o;n++)t[n]&&(e=pr(t[n]))&&(r&&(r+=" "),r+=e)}else for(e in t)t[e]&&(r&&(r+=" "),r+=e);return r}function Oo(){for(var t,n,e=0,r="",o=arguments.length;e<o;e++)(t=arguments[e])&&(n=pr(t))&&(r&&(r+=" "),r+=n);return r}const we=Oo,Gt=d.memo(d.forwardRef((t,n)=>{const{file:e,className:r,error:o,truncateLength:a,rightSlot:l,...s}=t,p=d.useMemo(()=>{if(e)return a!==void 0?U.truncate(e.name,a):e.name},[e,a]);return i.jsxs("div",{className:we(r,"flex h-5 w-full items-center gap-2 rounded-md border border-(--base-a6) bg-(--base-2) text-sm py-1 px-2 h-max",{"text-(--gray-11)":o}),ref:n,...s,children:[o?i.jsx(u.RiIcon,{icon:"RiFileWarningLine"}):i.jsx(_e,{fileType:(e==null?void 0:e.type)??""}),o||(e?p:i.jsx("div",{className:"flex w-full justify-center",children:i.jsx(u.Spinner,{})})),l]})}));Gt.displayName="FileCard";const Xt=d.createContext(()=>{throw new Error("No FileViewerProvider found")}),mr=()=>d.useContext(Xt),gr=d.memo(t=>{const{children:n}=t,[e,r]=d.useState(null),[o,a]=d.useState(null),l=d.useCallback(()=>{r(null),a(null)},[]),s=d.useCallback(f=>{r(f(l))},[l]),p=d.useCallback(()=>{e&&(e.onClose&&e.onClose(),l())},[l,e]);d.useEffect(()=>{if(!e)return;const{file:f}=e;if(qt.includes(f.type)){a("spreadsheet");return}if(Ut.includes(f.type)){a("pdf");return}if(Et.includes(f.type)){a("image");return}},[e]);const c=d.useMemo(()=>s,[s]);return i.jsxs(Xt.Provider,{value:c,children:[n,e&&i.jsxs(i.Fragment,{children:[o==="spreadsheet"&&i.jsx(Ht,{file:e.file,onDelete:e.onDelete,onClose:p}),o==="pdf"&&i.jsx(Wt,{file:e.file,onDelete:e.onDelete,onClose:p}),o==="image"&&i.jsx(jt,{file:e.file,onDelete:e.onDelete,onClose:p})]})]})});gr.displayName="FileViewerProvider";const tt=500,be=1e4,$={danger:"danger",warning:"warning",info:"base",success:"success"};class Kt{constructor(n){N(this,"type");N(this,"identifier");N(this,"description");const{description:e=null,identifier:r,type:o}=n;this.identifier=r,this.description=e,this.type=o}getId(){return this.identifier}static deserialize(n){throw new Error(`${this.name} must implement deserialize.`)}_serialize(){if(!this.identifier)throw new Error("Field identifier must be set before serializing.");return{type:this.type,identifier:this.identifier,description:this.description}}}const K={label:"",description:"",required:!1};class q extends Kt{constructor(e){const{label:r,required:o,image:a,fieldValidators:l=[],formValidators:s=[],...p}=e;super(p);N(this,"required");N(this,"formValidators");N(this,"fieldValidators");N(this,"label");N(this,"image");N(this,"onlyValidateAfterTouched",!0);this.label=r,this.required=o,this.image=a,this.fieldValidators=l,this.formValidators=s}static getFieldCreationSchema(){return[]}isBlank(e){return e==null||e===""}getValueFromChangeEvent(e){return e.target.value}getError(e,r){if(this.required&&this.isBlank(e))return"This field is required.";for(const o of this.getFieldValidators()){const a=o(e);if(a)return a}if(r)for(const o of this.getFormValidators()){const a=o(e,r);if(a)return a}}_serialize(){return{...super._serialize(),label:this.label,required:this.required,image:this.image}}getFieldValidators(){return[...this.fieldValidators]}getFormValidators(){return[...this.formValidators]}encodeValueToJson(e){return JSON.stringify(e)}decodeJsonToValue(e){return JSON.parse(e)}}N(q,"fieldTypeName"),N(q,"fieldTypeDescription");const _=t=>{const{id:n,field:e,formId:r,size:o,showInputOnly:a,internal:l,...s}=t,[p,c,f]=j.useField(e.getId()),{touched:h}=c,m=c.error??e.description,y=c.error?"danger":void 0,x=n??`${r}-${e.getId()}-input`,g=`${x}-label`,b=e.required?`${e.label} *`:e.label,E=d.useMemo(()=>({...p,onChange:I=>{const F=e.getValueFromChangeEvent(I);f.setValue(F,!1).then(),(h||!e.onlyValidateAfterTouched)&&f.setError(e.getError(F))},onBlur:I=>{f.setTouched(!0,!1).then(),f.setError(e.getError(e.getValueFromChangeEvent(I)))}}),[e,p,f,h]);return console.debug("severity",y),[{helpText:m,size:o,severity:y,inputId:x,labelId:g,label:b,showInputOnly:a,internal:l,fieldProps:E,helpers:f,field:e},{...s,"aria-labelledby":g}]};var nt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Bo(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var rt={exports:{}},_o=rt.exports,vr;function zo(){return vr||(vr=1,function(t,n){(function(e,r){r()})(_o,function(){function e(c,f){return typeof f>"u"?f={autoBom:!1}:typeof f!="object"&&(console.warn("Deprecated: Expected third argument to be a object"),f={autoBom:!f}),f.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(c.type)?new Blob(["\uFEFF",c],{type:c.type}):c}function r(c,f,h){var m=new XMLHttpRequest;m.open("GET",c),m.responseType="blob",m.onload=function(){p(m.response,f,h)},m.onerror=function(){console.error("could not download file")},m.send()}function o(c){var f=new XMLHttpRequest;f.open("HEAD",c,!1);try{f.send()}catch{}return 200<=f.status&&299>=f.status}function a(c){try{c.dispatchEvent(new MouseEvent("click"))}catch{var f=document.createEvent("MouseEvents");f.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),c.dispatchEvent(f)}}var l=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof nt=="object"&&nt.global===nt?nt:void 0,s=l.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),p=l.saveAs||(typeof window!="object"||window!==l?function(){}:"download"in HTMLAnchorElement.prototype&&!s?function(c,f,h){var m=l.URL||l.webkitURL,y=document.createElement("a");f=f||c.name||"download",y.download=f,y.rel="noopener",typeof c=="string"?(y.href=c,y.origin===location.origin?a(y):o(y.href)?r(c,f,h):a(y,y.target="_blank")):(y.href=m.createObjectURL(c),setTimeout(function(){m.revokeObjectURL(y.href)},4e4),setTimeout(function(){a(y)},0))}:"msSaveOrOpenBlob"in navigator?function(c,f,h){if(f=f||c.name||"download",typeof c!="string")navigator.msSaveOrOpenBlob(e(c,h),f);else if(o(c))r(c,f,h);else{var m=document.createElement("a");m.href=c,m.target="_blank",setTimeout(function(){a(m)})}}:function(c,f,h,m){if(m=m||open("","_blank"),m&&(m.document.title=m.document.body.innerText="downloading..."),typeof c=="string")return r(c,f,h);var y=c.type==="application/octet-stream",x=/constructor/i.test(l.HTMLElement)||l.safari,g=/CriOS\/[\d]+/.test(navigator.userAgent);if((g||y&&x||s)&&typeof FileReader<"u"){var b=new FileReader;b.onloadend=function(){var S=b.result;S=g?S:S.replace(/^data:[^;]*;/,"data:attachment/file;"),m?m.location.href=S:location=S,m=null},b.readAsDataURL(c)}else{var E=l.URL||l.webkitURL,w=E.createObjectURL(c);m?m.location=w:location.href=w,m=null,setTimeout(function(){E.revokeObjectURL(w)},4e4)}});l.saveAs=p.saveAs=p,t.exports=p})}(rt)),rt.exports}var yr=zo();const $o=Bo(yr),Qt=d.memo(t=>{const{file:n,url:e,name:r,setShowPreview:o}=t,a=d.useCallback(l=>{l.stopPropagation();const s=new Blob([n]);$o(s,r)},[r,n]);return i.jsxs(i.Fragment,{children:[i.jsx("button",{className:"fixed top-0 left-0 z-[5000] h-full w-full bg-[rgba(0,0,0,0.85)] bg-black",type:"button",onClick:()=>{o(!1)},children:i.jsx("img",{className:"absolute top-[50%] left-[50%] z-[5001] max-h-[calc(100%-120px)] max-w-svw translate-x-[-50%] translate-y-[50%] object-contain",src:e,alt:r,onClick:l=>{l.stopPropagation()}})}),i.jsxs("div",{className:"fixed top-0 left-0 z-[5001] flex w-full items-center bg-(--color-background)",children:[i.jsx(u.IconButton,{className:"min-w-[50px]",variant:"soft","aria-label":"Exit preview",onClick:()=>{o(!1)},children:i.jsx(u.RiIcon,{icon:"RiArrowLeftLine"})}),i.jsx("span",{className:"grow text-center",children:r}),i.jsx(u.IconButton,{className:"min-w-[50px]",variant:"soft","aria-label":`Download ${r}`,onClick:a,children:i.jsx(u.RiIcon,{icon:"RiDownload2Line"})})]})]})});Qt.displayName="FullScreenImagePreview";const Z=t=>{const{className:n,label:e,children:r,size:o,severity:a,inputId:l,labelId:s,image:p}=t,[c,f]=d.useState(void 0),[h,m]=d.useState(!1),y=a?$[a]:"base";console.debug(a,y),d.useEffect(()=>{p instanceof Promise?p.then(f).catch(console.error):f(p)},[p]);const x=c?URL.createObjectURL(c):void 0;return i.jsxs("div",{className:"flex flex-col gap-2",children:[c&&i.jsxs(i.Fragment,{children:[i.jsx("img",{className:"h-[100px] w-full min-w-[300px] cursor-pointer rounded-md object-cover",src:x,alt:c.name,onClick:()=>{m(!0)}}),h&&i.jsx(Qt,{file:c,url:x,name:c.name,setShowPreview:m})]}),i.jsxs("label",{className:we(n,"flex flex-col gap-1"),htmlFor:l,children:[i.jsx(u.Text,{accentColor:y,size:o,id:s,weight:"medium",children:e}),r]})]})},Yt=t=>{const{helpText:n,children:e,severity:r}=t,o=r?$[r]:"base";return i.jsxs("div",{className:"flex flex-col gap-1",children:[e,i.jsx("div",{className:"flex flex-col w-full",children:i.jsx(u.Text,{accentColor:o,size:"xs",children:n})})]})},R=t=>{const{children:n,...e}=t;return i.jsx(Yt,{...e,children:n})},ko=[!0,"true"],Jt=d.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:l,fieldProps:s},p]=_(t);let[{helpText:c,label:f}]=_(t);c=a?null:c,f=a?"":f;const h=o?$[o]:void 0,m=ko.includes(s.value);return i.jsx(R,{helpText:c,severity:o,children:i.jsx(Z,{size:r,severity:o,inputId:n,labelId:e,label:f,image:a?void 0:l.image,className:"align-center flex-row-reverse justify-end gap-2",children:i.jsx(u.Checkbox.Root,{...p,...s,id:n,accentColor:h,value:m.toString(),checked:m,onCheckedChange:s.onChange,onChange:void 0,onBlur:void 0,variant:"soft",children:i.jsx(u.Checkbox.Indicator,{children:i.jsx(u.RiIcon,{icon:"RiCheckLine"})})})})})});Jt.displayName="BooleanInput";const wr={...K,type:"boolean"},xe=class xe extends q{constructor(e){super({...e,type:"boolean"});N(this,"onlyValidateAfterTouched",!1)}isBlank(e){return this.required&&!e}getValueFromChangeEvent(e){return typeof e=="boolean"?e:e.target.checked}serialize(){return super._serialize()}static deserialize(e){if(e.type!=="boolean")throw new Error("Type mismatch.");return new xe(e)}getInput(e){return i.jsx(Jt,{...e,field:this})}};N(xe,"fieldTypeName","Checkbox"),N(xe,"fieldTypeDescription","Perfect for both optional and required yes/no questions."),N(xe,"Icon",W.RiCheckboxCircleLine);let Ce=xe;const Zt=d.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:l,fieldProps:s},p]=_(t);let[{helpText:c,label:f}]=_(t);c=a?null:c,f=a?"":f;const h=o?$[o]:void 0,m=s.value?s.value.split("T")[0]:"";return i.jsx(R,{helpText:c,severity:o,children:i.jsx(Z,{size:r,severity:o,inputId:n,labelId:e,label:f,image:a?void 0:l.image,children:i.jsx(u.Input.Root,{accentColor:h,variant:"soft",children:i.jsx(u.Input.Field,{...p,type:"date",id:n,color:h,value:m})})})})});Zt.displayName="DateInput";const br={...K,type:"date"},Ie=class Ie extends q{constructor(e){super({...e,type:"date"});N(this,"onlyValidateAfterTouched",!1)}serialize(){return super._serialize()}getValueFromChangeEvent(e){return new Date(e.target.value).toISOString()}static deserialize(e){if(e.type!=="date")throw new Error("Type mismatch.");return new Ie(e)}getInput(e){return i.jsx(Zt,{field:this,...e})}};N(Ie,"fieldTypeName","Date"),N(Ie,"fieldTypeDescription","Allows specifying a date."),N(Ie,"Icon",W.RiCalendarLine);let it=Ie;const Cr=d.memo(t=>{const{field:n,...e}=t,[{value:r}]=j.useField(n.options.clonedFieldIdentifier),o=d.useMemo(()=>{const a=n.options.getFieldToClone(r);return a?pt(a):null},[n.options,r]);return Rt(o,e)});Cr.displayName="FieldInputCloner";const Vo={...K,type:"custom"};class ot extends q{constructor(e,r){super({...e,type:"custom"});N(this,"Component");N(this,"options");this.options=e,this.Component=r}serialize(){throw new Error("Serializing only supported for public input types.")}getInput(e){const r=this.Component;return i.jsx(r,{field:this,...e})}}N(ot,"fieldTypeName","Custom"),N(ot,"fieldTypeDescription","Allows re-rendering of field already in the form");class jo extends ot{constructor(n){super(n,Cr)}}const Rt=(t,n)=>d.useMemo(()=>!n||!t?null:t.getInput(n),[t,n]),$e=(t,n)=>{const e=d.useMemo(()=>t.map(r=>i.jsx("div",{children:r.getInput(n)},r.getId())),[t,n]);return i.jsx("div",{className:"flex flex-col gap-2",children:e})},at=(t="",n=[])=>({type:"section",fields:n,identifier:t,label:null,condition:null,conditional:!1}),Uo=t=>{if(!t)return;const n=t.fields;let e=[];const r=[];for(const o of n)o.type==="section"?(e.length>0&&(r.push(at(`AUTO_section-${n.indexOf(o)}`,e)),e=[]),r.push(o)):e.push(o);return e.length>0&&r.push(at("AUTO_section-last",e)),{...t,fields:r,description:t.description??""}};function en(t,n,e){const r=Array.from(t),[o]=r.splice(n,1);if(!o)throw new Error("Could not find field to reorder.");return r.splice(e,0,o),r}function xr(t,n,e){const r=Array.from(t??[]);return r.splice(n,0,e),r}function lt(t,n){const e=Array.from(t);return e.splice(n,1),e}const tn=(t,n)=>{const e=new Date;return`${U.slugify(n)}-${e.getTime()}`},Ir=(t,n)=>{if(!n)return null;for(const e of t)if(e.type==="section"){const r=Ir(e.fields,n);if(r)return r}else if(e.identifier===n)return e;return null},Er=(t,n)=>t.filter((e,r)=>r<n).flatMap(e=>e.fields),st=(t,n,e,r,o)=>{const{label:a}=e,l={...e,identifier:tn(null,a)},s=Y(r,t);if(s===void 0)throw new Error("Parent path must point to an existing field.");if(!Array.isArray(s))throw new Error("Parent path must point to an array.");const p=xr(s,n,l);o(t,p).then()},Wo=(t,n,e)=>{const r={...at(),label:""};st("fields",t,r,n,e)},nn=()=>{const{showError:t}=u.useToast(),n=d.useCallback((r,o,a,l,s,p)=>{const c=r[o];if(!c)throw new Error("Could not find section context.");let f=typeof c.conditionIndex<"u"?Math.max(c.conditionIndex+1,l):l;for(const h of Object.values(r))h.conditionIndex===a&&(f=Math.min(f,h.index-1));if(f!==l){t({title:"Could not reorder sections",description:"Sections with conditions must be below the fields they reference."});return}p("fields",en(s.fields,a,f))},[t]),e=d.useCallback((r,o,a,l,s,p,c)=>{var f;if(!(r!=null&&r.fields)||!l)throw new Error("Could not find section with fields.");if(r.identifier===l.identifier)c(`fields.${o}.fields`,en(r.fields,a,p)).then();else{const h=r.fields[a];if(!h)throw new Error("Could not find field to reorder.");if(((f=l.condition)==null?void 0:f.identifier)===h.identifier){t({title:"Could not reorder field",description:"Field must be above the section whose condition references it."});return}c(`fields.${o}.fields`,lt(r.fields,a)).then(),c(`fields.${s}.fields`,xr(l.fields,p,h)).then()}},[t]);return{reorderSection:n,reorderField:e}},rn=d.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:l,fieldProps:s,internal:p},c]=_(t);let[{helpText:f,label:h}]=_(t);f=a?null:f,h=a?"":h;const m=o?$[o]:void 0,y=d.useMemo(()=>Array.isArray(s.value)?s.value:[],[s.value]),{onChange:x,onBlur:g}=s,b=`${n}-droppable`,{disabled:E}=c,[w,S]=d.useState(""),[I,F]=d.useState(""),L=I||f,T=I?$.danger:m,D=d.useCallback(M=>{x(M),g(M)},[x,g]),A=d.useCallback(M=>{y.findIndex(k=>k===M.target.value.trim())>=0?F("All options must be unique"):M.target.value?F(""):F("Option cannot be empty"),S(M.target.value)},[S,y]),B=d.useCallback(()=>{if(I)return;if(!w.trim()){F("Option cannot be empty");return}const M=w.trim();D([...y,M]),S("")},[w,I,D,y]),X=d.useCallback(M=>{M.key==="Enter"&&(M.preventDefault(),B())},[B]),Q=d.useCallback(M=>{D(lt(y,M))},[y,D]),z=d.useCallback(M=>{if(!M.destination)return;const k=M.source.index,se=M.destination.index;D(en(y,k,se))},[D,y]);return i.jsx(ie.DragDropContext,{onDragEnd:z,children:i.jsxs("div",{className:"flex flex-col gap-2",children:[i.jsx(R,{helpText:L,severity:o,children:i.jsx(Z,{size:r,severity:o,inputId:n,labelId:e,label:h,image:a?void 0:l.image,children:(!E||y.length===0)&&i.jsxs("div",{className:"flex gap-2",children:[i.jsx("div",{className:"grow",children:i.jsx(u.Input.Root,{accentColor:T,variant:p?"outline":"soft",children:i.jsx(u.Input.Field,{...c,...s,value:w,onChange:A,onKeyDown:X,id:n,placeholder:l.placeholder,onBlur:void 0})})}),i.jsx(u.IconButton,{type:"button","aria-label":"Add option",disabled:!!I||E,onClick:B,children:i.jsx(u.RiIcon,{icon:"RiAddLine"})})]})})}),i.jsx(ie.Droppable,{droppableId:b,children:M=>i.jsxs("div",{className:"flex flex-col",...M.droppableProps,ref:M.innerRef,children:[y.map((k,se)=>i.jsx(ie.Draggable,{draggableId:`${k}-draggable`,index:se,isDragDisabled:E,children:({draggableProps:Ue,dragHandleProps:We,innerRef:re})=>i.jsxs(u.Badge,{...We,...Ue,ref:re,className:"mb-1 flex items-center justify-between gap-2",accentColor:"base",size:"md",variant:"soft",children:[i.jsx("span",{children:typeof k=="object"&&"label"in k?k.label:k}),i.jsx(u.IconButton,{size:"sm",variant:"ghost",type:"button","aria-label":"Delete option",accentColor:"base",disabled:E,onClick:()=>{Q(se)},children:i.jsx(u.RiIcon,{icon:"RiCloseLargeLine"})})]})},k)),M.placeholder]})})]})})});rn.displayName="MultiStringInput";const Sr={...K,type:"multi-string",minimum_length:0,maximum_length:null},Ee=class Ee extends q{constructor(e){const{minimum_length:r,maximum_length:o,placeholder:a,...l}=e;super({...l,type:"multi-string"});N(this,"minLength");N(this,"maxLength");N(this,"onlyValidateAfterTouched",!1);N(this,"placeholder");this.minLength=r??0,this.maxLength=o??1/0,this.placeholder=a??"Press enter to add a new option"}getValueFromChangeEvent(e){if(Array.isArray(e))return e;throw new Error("Expected an array.")}getInput(e){return i.jsx(rn,{field:this,...e})}serialize(){return{...super._serialize(),minimum_length:this.minLength,maximum_length:this.maxLength,placeholder:this.placeholder}}isBlank(e){return super.isBlank(e)||e.length===0}getFieldValidators(){const e=super.getFieldValidators();return e.push(r=>{if(Array.isArray(r)&&r.length<this.minLength)return`Must have at least ${this.minLength} options.`}),e.push(r=>{if(Array.isArray(r)&&r.length>this.maxLength)return`Must have at most ${this.maxLength} options.`}),e}static deserialize(e){if(e.type!=="multi-string")throw new Error("Type mismatch.");return new Ee(e)}};N(Ee,"fieldTypeName","Multi-string"),N(Ee,"fieldTypeDescription","Allows the user to provide multiple unique strings."),N(Ee,"Icon",W.RiListCheck);let ke=Ee;const on=d.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:l,fieldProps:s},p]=_(t);let[{helpText:c,label:f}]=_(t);c=a?null:c,f=a?"":f;const h=o?$[o]:void 0;return i.jsx(R,{helpText:c,severity:o,children:i.jsx(Z,{size:r,severity:o,inputId:n,labelId:e,label:f,image:a?void 0:l.image,children:i.jsx(u.Input.Root,{accentColor:h,variant:"soft",children:i.jsx(u.Input.Field,{...p,...s,type:"number",id:n,placeholder:l.placeholder,min:l.minimum,max:l.maximum,step:l.integers?1:.1})})})})});on.displayName="NumberInput";const Nr={...K,type:"number",minimum:Number.MIN_SAFE_INTEGER,maximum:Number.MAX_SAFE_INTEGER,integers:!1},Fr=t=>"fields"in t,te=class te extends q{constructor(e){const{minimum:r=Number.MIN_SAFE_INTEGER,maximum:o=Number.MAX_SAFE_INTEGER,integers:a=!1,placeholder:l="Enter a number",...s}=e;super({...s,type:"number"});N(this,"minimum");N(this,"maximum");N(this,"integers");N(this,"placeholder");this.minimum=r,this.maximum=o,this.integers=a,this.placeholder=l}getValueFromChangeEvent(e){const r=Number.parseFloat(e.target.value);return Number.isNaN(r)?"":r}static getFieldCreationSchema(e=""){const r=e&&`${e}.`;return[{field:new te({label:"Minimum",description:"Minimum value",integers:!0,required:!1,identifier:`${r}minimum`,formValidators:[this._validateMin(e)]}),showDirectly:!1},{field:new te({label:"Maximum",description:"Maximum value",integers:!0,required:!1,identifier:`${r}maximum`,formValidators:[this._validateMax(e)]}),showDirectly:!1},{field:new Ce({label:"Integers",description:"Whole numbers only",required:!1,identifier:`${r}integers`}),showDirectly:!1}]}getFieldValidators(){const e=super.getFieldValidators(),r=this.minimum,o=this.maximum;return typeof r=="number"&&e.push(a=>{if(typeof a=="number"&&a<r)return`Must be at least ${this.minimum}.`}),typeof o=="number"&&e.push(a=>{if(typeof a=="number"&&a>o)return`Must be at most ${this.maximum}.`}),this.integers&&e.push(a=>{if(typeof a=="number"&&!Number.isInteger(a))return"Must be a whole number."}),e}serialize(){return{...super._serialize(),minimum:this.minimum,maximum:this.maximum,integers:this.integers,placeholder:this.placeholder}}static deserialize(e){if(e.type!=="number")throw new Error("Type mismatch.");return new te(e)}getInput(e){return i.jsx(on,{field:this,...e})}};N(te,"fieldTypeName","Number"),N(te,"fieldTypeDescription","Allows specifying a number within a given range."),N(te,"Icon",W.RiHashtag),N(te,"_validateMin",e=>(r,o)=>{const a=Fr(o)?Y(o,e):o;return typeof a.maximum=="number"&&typeof r=="number"&&a.maximum<r?"Minimum cannot be greater than minimum.":null}),N(te,"_validateMax",e=>(r,o)=>{const a=Fr(o)?Y(o,e):o;return typeof a.minimum=="number"&&typeof r=="number"&&a.minimum>r?"Maximum cannot be less than minimum.":null});let le=te;const an=d.memo(t=>{const[{inputId:n,labelId:e,label:r,helpText:o,size:a,severity:l,showInputOnly:s,field:p,fieldProps:c},f]=_(t),[h,m]=d.useState(!1),y=c.value,x=d.useCallback(w=>{c.onChange({target:{value:w}}),m(!1)},[c]),g=d.useCallback(()=>{c.onChange({target:{value:""}})},[c]),b=d.useCallback(()=>{m(!0)},[]),E=d.useCallback(()=>{m(!1)},[]);return i.jsx(R,{helpText:o,severity:l,children:i.jsxs(Z,{size:a,severity:l,inputId:n,labelId:e,label:r,image:s?void 0:p.image,className:"flex-col items-start justify-start gap-1",children:[i.jsx(Me,{open:h,onOpenChange:m,children:i.jsxs(Ae,{children:[i.jsx(Oe,{className:"light:bg-(--black-a6) fixed inset-0 dark:bg-(--black-a8)"}),i.jsx(Be,{className:"fixed inset-0",children:i.jsx(ln,{onQrScan:x,onClose:E})})]})}),i.jsxs("div",{className:"flex w-max items-center gap-1",children:[i.jsxs(u.Button,{...f,variant:"soft",onClick:b,children:[i.jsx(u.RiIcon,{icon:"RiQrCodeLine"}),"Scan"]}),y&&i.jsx("span",{className:"text-xs text-(--accent-a11)","data-accent-color":"primary",children:i.jsx(u.RiIcon,{icon:"RiCheckLine",style:{verticalAlign:"bottom"}})})]}),!!y&&i.jsx(u.Card,{children:i.jsxs("div",{className:"w-max items-center gap-2",children:[i.jsx("code",{className:"bg-(--base-a3)",children:y}),i.jsx(u.IconButton,{accentColor:"base",variant:"ghost","aria-label":"delete",size:"sm",onClick:g,children:i.jsx(u.RiIcon,{icon:"RiCloseLine"})})]})})]})})});an.displayName="QrInput";const ln=d.memo(t=>{const{onQrScan:n,onClose:e}=t,r=d.useRef(null),[o,a]=d.useState(!1);return d.useEffect(()=>{if(!r.current)return;const l=new Jr(r.current,s=>{const p=s.data;n(p),l.destroy()},{highlightCodeOutline:!0,highlightScanRegion:!0,maxScansPerSecond:1});a(!0),l.start().finally(()=>{a(!1)})},[n]),i.jsxs("div",{className:"relative flex h-full w-full flex-col justify-center gap-2 bg-(--color-background)",children:[i.jsx("div",{className:"absolute top-0 flex w-full p-2",children:i.jsx(u.IconButton,{"aria-label":"close",variant:"soft",accentColor:"base",onClick:e,children:i.jsx(u.RiIcon,{icon:"RiCloseLine"})})}),i.jsxs("div",{className:"relative max-h-full max-w-full",children:[i.jsx("video",{ref:r,style:{width:"100%",height:"100%"}}),o&&i.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-(--color-background)",children:i.jsx(u.Spinner,{})})]})]})});ln.displayName="QrScanner";const Tr={...K,type:"qr"},Se=class Se extends q{constructor(e){super({...e,type:"qr"});N(this,"onlyValidateAfterTouched",!1)}serialize(){return super._serialize()}static deserialize(e){if(e.type!=="qr")throw new Error("Type mismatch.");return new Se(e)}getInput(e){return i.jsx(an,{...e,field:this})}};N(Se,"fieldTypeName","QR"),N(Se,"fieldTypeDescription","Used for scanning/reading QR codes."),N(Se,"Icon",W.RiQrCodeLine);let ct=Se;class Lr extends q{constructor(e){const{placeholder:r="",...o}=e;super(o);N(this,"options");N(this,"onlyValidateAfterTouched",!1);N(this,"placeholder");this.placeholder=r;const a=new Set;this.options=e.options.map(l=>(typeof l=="string"&&(l={label:l,value:l}),a.add(l.label),l)),a.size!==e.options.length&&console.error(`${e.options.length-a.size} duplicate identifiers found in options. This may cause unexpected behavior. Options:`,e.options)}_serialize(){return{...super._serialize(),options:this.options,placeholder:this.placeholder}}static getFieldCreationSchema(e=""){const r=e&&`${e}.`;return[{field:new ke({label:"Options",description:"List possible options for the user to select from.",required:!0,identifier:`${r}options`,minimum_length:2}),showDirectly:!0}]}}const qo=t=>t?Array.isArray(t)?t:[t]:[],sn=d.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:l,fieldProps:s},p]=_(t),{onChange:c,onBlur:f}=s;let[{helpText:h,label:m}]=_(t);h=a?null:h,m=a?"":m;const y=d.useMemo(()=>qo(s.value),[s.value]),x=d.useCallback(g=>{c(g),f(g)},[c,f]);return i.jsx(R,{helpText:h,severity:o,children:i.jsx(Z,{size:r,severity:o,inputId:n,labelId:e,label:m,image:a?void 0:l.image,children:i.jsxs(u.Menu.Root,{children:[i.jsx(u.Menu.ClickTrigger,{children:i.jsxs(u.Button,{id:n,className:"!justify-between",name:s.name,variant:"soft",...p,children:[y.length>0?y.join(", "):l.placeholder,i.jsx(u.RiIcon,{icon:"RiArrowDownSLine"})]})}),i.jsx(u.Menu.Content,{children:i.jsxs(u.Menu.MultiSelectGroup,{values:y,onValuesChange:x,children:[i.jsxs(u.Menu.SelectAllItem,{allValues:l.options.map(({value:g})=>g),children:[i.jsx(u.Menu.SelectAllIndicator,{children:g=>g?i.jsx(u.RiIcon,{icon:"RiSubtractLine"}):i.jsx(u.RiIcon,{icon:"RiCheckLine"})}),"Select all"]}),l.options.map(g=>i.jsxs(u.Menu.MultiSelectItem,{value:g.value,children:[i.jsx(u.Menu.SelectedIndicator,{children:i.jsx(u.RiIcon,{icon:"RiCheckLine"})}),g.label]},g.value))]})})]})})})});sn.displayName="MultiSelectInput";const Dr={...K,type:"multi-select",options:[]},Ne=class Ne extends Lr{constructor(n){const{placeholder:e="Select one or more...",...r}=n;super({...r,placeholder:e,type:"multi-select"})}getValueFromChangeEvent(n){if(Array.isArray(n))return n;throw new Error("Expected an array.")}isBlank(n){return super.isBlank(n)||n.length===0}serialize(){return super._serialize()}static deserialize(n){if(n.type!=="multi-select")throw new Error("Type mismatch.");return new Ne(n)}getInput(n){return i.jsx(sn,{field:this,...n})}};N(Ne,"fieldTypeName","Multi-select"),N(Ne,"fieldTypeDescription","Allows the user to select a multiple options from a list of options."),N(Ne,"Icon",W.RiCheckboxLine);let Ve=Ne;const cn=d.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:l,fieldProps:s},p]=_(t),{onChange:c,onBlur:f}=s;let[{helpText:h,label:m}]=_(t);h=a?null:h,m=a?"":m;const y=d.useCallback(g=>{c(g),f(g)},[c,f]),x=o?$[o]:void 0;return i.jsx(R,{helpText:h,severity:o,children:i.jsx(Z,{size:r,severity:o,inputId:n,labelId:e,label:m,image:a?void 0:l.image,children:i.jsxs(u.Menu.Root,{children:[i.jsx(u.Menu.ClickTrigger,{children:i.jsxs(u.Button,{...s,className:"!justify-between",id:n,name:s.name,accentColor:x,variant:"soft",...p,children:[s.value?s.value:l.placeholder,i.jsx(u.RiIcon,{icon:"RiArrowDownSLine"})]})}),i.jsx(u.Menu.Content,{children:i.jsx(u.Menu.SelectGroup,{value:s.value,onValueChange:y,children:l.options.map(g=>i.jsxs(u.Menu.SelectItem,{value:g.value,children:[i.jsx(u.Menu.SelectedIndicator,{children:i.jsx(u.RiIcon,{icon:"RiCheckLine"})}),g.label]},g.value))})})]})})})});cn.displayName="SelectInput";const Pr={...K,type:"select",options:[]},Fe=class Fe extends Lr{constructor(n){const{placeholder:e="Select one...",...r}=n;super({...r,placeholder:e,type:"select"})}getValueFromChangeEvent(n){return typeof n=="string"?n:n.target.value}serialize(){return super._serialize()}static deserialize(n){if(n.type!=="select")throw new Error("Type mismatch.");return new Fe(n)}getInput(n){return i.jsx(cn,{field:this,...n})}};N(Fe,"fieldTypeName","Dropdown"),N(Fe,"fieldTypeDescription","Allows the user to select a single option from a list of options."),N(Fe,"Icon",W.RiMenuFoldLine);let je=Fe;const Mr=t=>"fields"in t;class dt extends q{constructor(e){const{minLength:r,maxLength:o,placeholder:a="",...l}=e;super(l);N(this,"minLength");N(this,"maxLength");N(this,"placeholder");this.minLength=r?Math.max(r,0):void 0,this.maxLength=o?Math.max(o,0):be,this.placeholder=a}static getFieldCreationSchema(e=""){const r=e&&`${e}.`;return[{field:new le({label:"Minimum length",description:"Minimum number of characters",required:!1,identifier:`${r}minimum_length`,minimum:0,maximum:100,formValidators:[this._validateMin(e)],integers:!0}),showDirectly:!1},{field:new le({label:"Maximum length",description:"Maximum number of characters",required:!1,identifier:`${r}maximum_length`,minimum:1,maximum:be,formValidators:[this._validateMax(e)],integers:!0}),showDirectly:!1}]}getFieldValidators(){const e=super.getFieldValidators();return this.minLength&&e.push(r=>{if(this.minLength&&(!r||r.length<this.minLength))return!this.required&&!r?null:`Minimum ${this.minLength} character(s).`}),this.maxLength&&e.push(r=>{if(typeof r=="string"&&this.maxLength&&r.length>this.maxLength)return`Maximum ${this.maxLength} character(s).`}),e}_serialize(){if(!this.identifier)throw new Error("Field identifier must be set before serializing.");return{...super._serialize(),minimum_length:this.minLength,maximum_length:this.maxLength,placeholder:this.placeholder}}}N(dt,"_validateMin",e=>(r,o)=>{const a=Mr(o)?Y(o,e):o;return typeof a.maximum_length=="number"&&typeof r=="number"&&a.maximum_length<r?"Minimum cannot be greater than maximum.":null}),N(dt,"_validateMax",e=>(r,o)=>{if(typeof r!="number")return null;const{minimum_length:a}=Mr(o)?Y(o,e):o;return typeof a!="number"?null:a>r?"Maximum cannot be less than minimum.":null});const dn=d.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:l,fieldProps:s},p]=_(t);let[{helpText:c,label:f}]=_(t);c=a?null:c,f=a?"":f;const h=o?$[o]:void 0;return i.jsx(R,{helpText:c,severity:o,children:i.jsx(Z,{size:r,severity:o,inputId:n,labelId:e,label:f,image:a?void 0:l.image,children:i.jsx(u.Input.Root,{accentColor:h,variant:"soft",children:i.jsx(u.Input.Field,{...p,...s,type:l.inputType,id:n,placeholder:l.placeholder})})})})});dn.displayName="StringInput";const Ar={...K,type:"string",maximum_length:tt,input_type:"text"},Te=class Te extends dt{constructor(e){const{inputType:r="text",...o}=e,a=e.maxLength?Math.min(tt,e.maxLength):tt,l=e.minLength?Math.min(e.minLength,a):void 0;super({...o,maxLength:a,minLength:l,type:"string"});N(this,"inputType");this.inputType=r}serialize(){return{...super._serialize(),input_type:this.inputType}}static deserialize(e){if(e.type!=="string")throw new Error("Type mismatch.");const{maximum_length:r,minimum_length:o,input_type:a,...l}=e;return new Te({...l,maxLength:r,minLength:o,inputType:a,placeholder:"Enter a short description"})}getInput(e){return i.jsx(dn,{field:this,...e})}};N(Te,"fieldTypeName","Short Text"),N(Te,"fieldTypeDescription",`Short text fields can hold up to ${tt} characters on a single line.`),N(Te,"Icon",W.RiInputField);let ut=Te;const un=d.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:l,fieldProps:s},p]=_(t);let[{helpText:c,label:f}]=_(t);c=a?null:c,f=a?"":f;const h=o?$[o]:void 0;return i.jsx(R,{helpText:c,severity:o,children:i.jsx(Z,{size:r,severity:o,inputId:n,labelId:e,label:f,image:a?void 0:l.image,children:i.jsx(u.TextArea,{...p,...s,className:"field-sizing-content",resize:"vertical",id:n,placeholder:l.placeholder,accentColor:h,variant:"soft"})})})});un.displayName="TextInput";const Or={...K,type:"text",maximum_length:be},Le=class Le extends dt{constructor(n){const e=n.maxLength?Math.min(be,n.maxLength):be,r=n.minLength?Math.min(n.minLength,e):void 0;super({...n,maxLength:e,minLength:r,type:"text"})}serialize(){return super._serialize()}static deserialize(n){if(n.type!=="text")throw new Error("Type mismatch.");const{maximum_length:e,minimum_length:r,...o}=n;return new Le({...o,maxLength:e,minLength:r,placeholder:"Enter a description"})}getInput(n){return i.jsx(un,{field:this,...n})}};N(Le,"fieldTypeName","Paragraph"),N(Le,"fieldTypeDescription",`Paragraph fields can hold up to ${be} characters and can have multiple lines.`),N(Le,"Icon",W.RiAlignJustify);let ft=Le;const Br=d.memo(d.forwardRef((t,n)=>{const{file:e,alt:r,error:o,rightSlot:a,className:l,truncateLength:s,...p}=t,c=d.useRef(null),f=d.useRef(null),h=u.useSize(c);d.useLayoutEffect(()=>{!f.current||!h||(f.current.style.height=`${h.height*4}px`)},[h]);const m=d.useMemo(()=>{if(e)return s!==void 0?U.truncate(e.name,s):e.name},[e,s]);return i.jsxs("div",{className:we(l,"relative flex h-max w-full flex-col gap-0 overflow-hidden rounded-md border items-center border-(--base-a6)"),ref:n,...p,children:[!e&&!o&&i.jsx("div",{className:"absolute flex h-full w-full flex-col items-center justify-center",children:i.jsx(u.Spinner,{})}),i.jsx("div",{ref:f,className:"-m-4 flex max-w-full items-center justify-center overflow-hidden bg-clip-padding",children:e&&!o&&i.jsx("img",{className:"max-w-full object-cover",src:URL.createObjectURL(e),alt:r??e.name})}),i.jsxs("div",{className:we("flex h-max w-full items-center gap-1 bg-(--base-2) px-2 py-1",{"bg-transparent":!e}),ref:c,children:[o?i.jsx(u.RiIcon,{icon:"RiFileWarningLine"}):e&&i.jsx(_e,{fileType:e.type}),o??m,a]})]})})),Ho=t=>{const n=["byte","kilobyte","megabyte"];let e=t,r=0;for(;e>1e3&&r<n.length-1;)e/=1e3,r++;return new Intl.NumberFormat([],{maximumFractionDigits:Math.max(0,r-1),style:"unit",unit:n[r]}).format(e)},_r=d.memo(t=>{var F;const[{inputId:n,labelId:e,size:r,severity:o,helpText:a,showInputOnly:l,field:s,fieldProps:p},c]=_(t),{onChange:f}=p;let[{label:h}]=_(t);h=l?"":h;const m=o?$[o]:void 0,y=d.useRef(null),{value:x}=p,g=d.useMemo(()=>l?null:a||(s.maxFileSize?`Maximum file size: ${s.maxFileSize}MB`:null),[s.maxFileSize,a,l]),b=d.useCallback(()=>{var L;(L=y.current)==null||L.click()},[]),E=d.useCallback(L=>{const T=[...x];T.splice(L,1),f({target:{files:T}})},[x,f]),w=x?"Select new files":"Select files",S=x?"Select new file":"Select a file",I=s.maxFiles>1?w:S;return i.jsxs("div",{className:"flex flex-col gap-2",children:[i.jsx(R,{helpText:g,severity:o,children:i.jsxs(Z,{size:r,severity:o,inputId:n,labelId:e,label:h,image:l?void 0:s.image,children:[i.jsx("div",{className:"flex gap-2",children:i.jsxs(u.Button,{...c,className:"w-max",variant:"soft",onClick:b,id:"upload-input-upload-button",children:[i.jsx(u.RiIcon,{icon:"RiUpload2Line"})," ",I]})}),i.jsx("input",{...c,type:"file",ref:y,id:n,accept:(F=s.extensions)==null?void 0:F.join(","),multiple:s.maxFiles>1,color:m,style:{display:"none"},...p,value:""})]})}),Array.isArray(x)&&x.length>0&&i.jsx("div",{className:"flex h-max flex-col gap-2",children:x.map((L,T)=>i.jsx(zr,{field:s,file:L,onRemove:()=>{E(T)},disabled:c.disabled},T))})]})});_r.displayName="UploadInput";const zr=d.memo(t=>{const{file:n,field:e,onRemove:r,disabled:o}=t,[a,l]=d.useState(null),s=mr(),p=d.useMemo(()=>a&&e.getError([a]),[e,a]),{url:c,name:f}=d.useMemo(()=>{let g=null,b,E;return a!=null&&a.type.startsWith("image/")&&(g=URL.createObjectURL(a)),a?(b=a.name,E=Ho(a.size)):(b="Downloading...",E="..."),{url:g,name:b,size:E}},[a]);d.useEffect(()=>{n instanceof Promise?n.then(l).catch(console.error):l(n)},[n]);const h=d.useCallback(g=>{if(g.stopPropagation(),!a)throw new Error("Cannot download a file that is not resolved.");const b=new Blob([a]);yr.saveAs(b,f)},[f,a]),m=d.useCallback(g=>{g.stopPropagation(),r()},[r]),y=d.useCallback(()=>{a&&s(g=>({file:a,onDelete:o?void 0:()=>{r(),g()}}))},[o,r,s,a]),x=d.useMemo(()=>i.jsxs(u.ButtonGroup,{variant:"ghost",accentColor:"base",size:"sm",children:[i.jsx(u.IconButton,{"aria-label":`Download ${f}`,onClick:h,disabled:!a,children:i.jsx(u.RiIcon,{icon:"RiDownload2Line"})}),!o&&i.jsx(u.IconButton,{"aria-label":`Remove ${f}`,disabled:o,onClick:m,children:i.jsx(u.RiIcon,{icon:"RiCloseLargeLine"})})]}),[o,m,h,f,a]);return c?i.jsx(Br,{style:{cursor:"pointer"},onClick:y,file:a,error:p??void 0,rightSlot:x}):i.jsx(Gt,{style:{cursor:"pointer"},onClick:y,file:a,error:p??void 0,rightSlot:x})});zr.displayName="DisplayFile";const Go={...K,type:"upload",extensions:[],maximum_size:void 0,maximum_files:1},De=class De extends q{constructor(e){const{extensions:r,maximum_files:o,maximum_size:a,...l}=e;super({...l,type:"upload"});N(this,"extensions");N(this,"maxFileSize");N(this,"maxFiles");N(this,"onlyValidateAfterTouched",!1);this.maxFileSize=typeof a=="number"?a:void 0,this.maxFiles=Math.max(typeof o=="number"?o:1,1),this.extensions=r}getValueFromChangeEvent(e){return Array.from(e.target.files||[])}isBlank(e){return super.isBlank(e)||e.length===0}static getFieldCreationSchema(e=""){const r=e&&`${e}.`;return[{field:new le({label:"How many files can be uploaded?",description:"By default, only one file can be uploaded.",required:!1,minimum:1,maximum:10,identifier:`${r}maximum_files`,integers:!0}),showDirectly:!1},{field:new le({label:"What is the maximum size of each file?",description:`Maximum file size in megabytes (between 1MB–${ht}MB).`,required:!1,identifier:`${r}maximum_size`,minimum:1,maximum:ht,integers:!0}),showDirectly:!1},{field:new Ve({label:"Accepted file types",description:"Types of allowed files to upload. If left blank, all files will be accepted.",required:!1,identifier:`${r}extensions`,options:[{value:"image/*",label:"Images"},{value:"audio/*",label:"Audio files"},{value:"video/*",label:"Videos"},{value:"text/*",label:"Text files"},{value:"application/*",label:"Application files (includes PDFs and Word documents)"}]}),showDirectly:!1}]}getFieldValidators(){const e=super.getFieldValidators(),r=this.maxFileSize??ht,o=r*1e3*1e3,a=this.maxFiles||1;return e.push(l=>{if(l&&l.some(s=>s.size>o))return`Files must be at most ${r}MB.`}),e.push(l=>{if(l&&l.length>a)return`You can only upload ${a} files.`}),e}serialize(){return{...super._serialize(),extensions:this.extensions,maximum_size:this.maxFileSize,maximum_files:this.maxFiles}}static deserialize(e){if(e.type!=="upload")throw new Error("Type mismatch.");return new De(e)}getInput(e){return i.jsx(_r,{field:this,...e})}};N(De,"fieldTypeName","Upload"),N(De,"fieldTypeDescription","Allows a file to be uploaded."),N(De,"Icon",W.RiUpload2Line);let fn=De;const hn={date:it,number:le,boolean:Ce,select:je,string:ut,text:ft,custom:ot,upload:fn,qr:ct,"multi-string":ke,"multi-select":Ve},Xo={date:br,number:Nr,boolean:wr,select:Pr,string:Ar,text:Or,custom:Vo,upload:Go,qr:Tr,"multi-string":Sr,"multi-select":Dr},ht=50,Ko=ht*1e3*1e3,pn=t=>{const n=t.type;return hn[n].deserialize(t)},pt=t=>t.type==="section"?H.deserialize(t):pn(t);function $r(t,n={}){const{readonly:e=!1}=n;return{title:t.title,description:t.description,fields:t.fields.map(r=>pt(r)),meta:{readonly:e}}}function mn(t){const n=[];for(const e of t.fields)if(e instanceof H)for(const r of e.fields)n.push(r);else{if(!(e instanceof q))throw new Error(`Invalid field type: ${e.type}`);n.push(e)}return n}function Qo(t,n){const e=mn(t),r={};for(const o of e){const a=n[o.identifier]??null;a!==null?r[o.identifier]=o.decodeJsonToValue(a):r[o.identifier]=a}return r}function Yo(t,n){const e=mn(t),r={};for(const o of e){const a=n[o.identifier];r[o.identifier]=o.encodeValueToJson(a)}return r}function mt(t){return Array.isArray(t)&&t.some(n=>n instanceof File||n instanceof Promise)}function gn(t,n){if(!t)return!0;if(mt(n)||mt(t.value))throw new Error("Conditions do not support file uploads");const e=Array.isArray(n)?n.map(o=>typeof o=="string"?o:o.value):n,r=Array.isArray(t.value)?t.value.map(o=>typeof o=="string"?o:o.value):t.value;if(Array.isArray(r)&&Array.isArray(e)){for(const o of r)if(!e.includes(o))return!1;return!0}return r===n}const kr=d.memo(t=>{const{field:n,...e}=t,{label:r,description:o,fields:a,condition:l}=n,{values:s,setFieldValue:p}=j.useFormikContext(),c=l!=null&&l.identifier?Y(s,l.identifier):void 0,f=d.useMemo(()=>c===void 0||gn(l,c),[l,c]);d.useEffect(()=>{if(!f)for(const m of a)p(m.getId(),"").then()},[f,a,p]);const h=$e(a,e);return f?i.jsx(u.Card,{children:i.jsxs("div",{className:"flex flex-col gap-6",children:[i.jsxs("div",{className:"flex flex-col",children:[i.jsx(u.Heading,{size:"lg",children:r}),i.jsx(u.Text,{accentColor:"base",children:o})]}),h]})}):null});kr.displayName="FieldSectionLayout";const Pe=class Pe extends Kt{constructor(e){const{label:r=null,fields:o,condition:a=null,conditional:l,...s}=e;super({...s,type:"section"});N(this,"label");N(this,"fields");N(this,"condition");this.fields=o,this.condition=a,this.label=r,l===!1&&(this.condition=null)}static getFieldCreationSchema(e,r=""){if(e.length===0)return[];const o=r&&`${r}.`;return[{field:new Ce({label:"Conditionally render section",identifier:`${o}conditional`,required:!1}),showDirectly:!0},{field:new Pe({label:"Conditional settings",identifier:`${o}conditional-settings`,condition:{identifier:`${o}conditional`,value:!0},fields:[new je({label:"Field",description:"The field to use for the condition.",options:e.map(a=>!a.label||a.type==="upload"?null:{label:a.label,value:a.identifier}).filter(a=>!!a),identifier:`${o}condition.identifier`,required:!0}),new jo({label:"Value",identifier:`${o}condition.value`,required:!0,clonedFieldIdentifier:`${o}condition.identifier`,getFieldToClone(a){if(!a)return null;const l=e.find(s=>s.identifier===a);return l?{...l,label:"Value",identifier:`${o}condition.value`,description:"The value to compare against.",required:l.type!=="boolean"}:(console.error("Could not find field with identifier",a),null)}})]}),showDirectly:!1}]}static deserialize(e){if(e.type!=="section")throw new Error("Invalid type");if(!Array.isArray(e.fields))throw new Error(`Invalid fields: ${e.fields} (not an array)`);const r=e.fields.map(pn);return new Pe({...e,fields:r})}conditional(){return this.condition!==null}serialize(){return{...super._serialize(),label:this.label,condition:this.condition,conditional:this.conditional(),fields:this.fields.map(e=>e.serialize())}}getErrors(e){const r={};for(const o of this.fields){const a=o.getId(),l=o.getError(Y(e,a),e);l&&Ct(r,o.getId(),l)}return r}getInput(e){return i.jsx(kr,{field:this,...e})}};N(Pe,"fieldTypeName","Section"),N(Pe,"fieldTypeDescription","Sections can be useful for grouping fields together. They can also be conditionally shown or hidden.");let H=Pe;const fe=t=>Object.keys(t).length>0,gt=(t,n)=>{const e={};for(const r of t.fields)if(r instanceof H){if(r.condition){const{identifier:o}=r.condition;if(!gn(r.condition,Y(n,o)))continue}Object.assign(e,r.getErrors(n))}else{if(!(r instanceof q))throw new Error("Invalid field type");const o=r.getId(),a=r.getError(Y(n,o),n);a&&Ct(e,o,a)}if(fe(e))return e},Jo=[null,void 0],vt=(t,n)=>t.reduce((e,r)=>r instanceof H?{...e,...vt(r.fields,n)}:(Jo.includes(Y(e,r.getId()))&&Ct(e,r.getId(),""),e),Zr(n)),Zo=()=>{throw new Error("onSubmit must be provided if form is not readonly.")},Vr=d.memo(d.forwardRef((t,n)=>{const{schema:e,values:r={},onSubmit:o=Zo,submitText:a="Submit",cancelText:l,onCancel:s,onDirty:p,onDirtyChange:c,hideTitle:f=!e.title,hideDescription:h,className:m,buttonProps:y}=t,{readonly:x}=e.meta,g=d.useMemo(()=>crypto.randomUUID(),[]),b=j.useFormik({initialValues:vt(e.fields,r),onSubmit:o,validate:F=>gt(e,F),validateOnBlur:!1,validateOnChange:!1}),{dirty:E}=b,w=d.useMemo(()=>typeof e.title=="string"?i.jsx(u.Heading,{size:"lg",children:e.title}):e.title,[e.title]),S=d.useMemo(()=>typeof e.description=="string"?i.jsx(u.Text,{accentColor:"base",children:e.description}):e.description,[e.description]),I=$e(e.fields,{formId:g,disabled:x});return d.useEffect(()=>{E&&p&&p(),c&&c(E)},[E,p,c]),i.jsx(j.FormikProvider,{value:b,children:i.jsxs("form",{id:g,ref:n,className:we(m,"flex flex-col gap-2"),onSubmit:b.handleSubmit,children:[!f&&i.jsx(u.Card,{children:i.jsxs("div",{className:"flex flex-col gap-1",children:[w,!h&&S]})}),I,!x&&i.jsxs("div",{className:"flex items-center justify-end gap-2",children:[l&&i.jsxs(u.Button,{accentColor:$.danger,...y,type:"button",onClick:s,children:[i.jsx(u.RiIcon,{icon:"RiCloseLine"}),l]}),i.jsxs(u.Button,{...y,type:"submit",disabled:!b.isValid,accentColor:"success",children:[i.jsx(u.RiIcon,{icon:"RiCheckLine"}),a]})]})]})})})),he=d.memo(t=>{const{name:n,render:e}=t,{submitForm:r}=j.useFormikContext(),[o,a,l]=j.useField(n),s=d.useMemo(()=>{const p=c=>{l.setValue(c,!1)};return e({value:o.value,meta:a,setValue:p,patchValue:()=>{r()}})},[e,o.value,a,r,l]);return i.jsx(i.Fragment,{children:s})});he.displayName="PatchField";const Ro=d.memo(d.forwardRef((t,n)=>{const{children:e,schema:r,values:o,onPatch:a,onError:l,requiresDiff:s=!0,onDirtyChange:p,...c}=t,f=d.useMemo(()=>vt(r.fields,o),[r.fields,o]),h=d.useCallback(w=>{const S={};for(const I in w){const F=w[I];F!==f[I]&&F!==void 0&&(S[I]=F)}return S},[f]),m=d.useCallback(w=>{const S=h(w);s&&!fe(S)||a(S)},[h,a,s]),y=d.useCallback(w=>{const S=gt(r,w);if(S&&l(S),p){const I=h(w);p(fe(I))}return S},[r,p,l,h]),x=j.useFormik({initialValues:f,onSubmit:m,validate:y,validateOnBlur:!1,validateOnChange:!1}),g=d.useCallback(()=>{if(p){const w=h(x.values);fe(w)&&p(!0)}},[x.values,h,p]),{errors:b,resetForm:E}=x;return d.useEffect(()=>{fe(b)&&E({values:f,errors:{}})},[b,f,E]),i.jsx(j.FormikProvider,{value:x,children:i.jsx("form",{...c,ref:n,onSubmit:x.handleSubmit,onChange:g,children:e})})})),yt="form-builder",ea=[["string","text"],["select","multi-select","upload","qr"],["boolean","date","number","multi-string"]],vn={...hn,section:H},ta=(t,n)=>{var r;const e={...t};switch(n.type){case"release":for(const o in e)e[o].disabled=!1;return e;case"hold":for(const o in e)(r=e[o])!=null&&r.conditionFields.has(n.fieldId)&&(e[o].disabled=!0);return e;case"update":return n.state}},na=(t,n)=>{if(n)for(let e=0;e<t.length;e++){const r=t[e];if(r){for(const o of r.fields)if(o.identifier===n)return e}}},jr=t=>{var e,r,o;const n={};for(let a=0;a<t.length;a++){const l=t[a];if(!l)throw new Error("Field is undefined.");const s=a>0?(e=n[t[a-1].identifier])==null?void 0:e.conditionFields:void 0,p=new Set(s);(r=l.condition)!=null&&r.identifier&&p.add(l.condition.identifier),n[l.identifier]={disabled:!1,conditionFields:p,conditionIndex:na(t,(o=l.condition)==null?void 0:o.identifier),index:a,label:l.label}}return n},yn=d.memo(t=>{const{index:n,type:e,sectionIndex:r,remove:o,duplicate:a,move:l,upload:s}=t;if(e!=="section"&&!s)throw new Error("Upload function prop must be defined for non-section fields.");const{values:p}=j.useFormikContext(),c=d.useRef(null),f=d.useMemo(()=>{const h=[{Icon:W.RiFileCopyLine,key:"duplicate",text:"Duplicate",buttonProps:{onClick:a}}];return n!==0&&h.push({Icon:W.RiDeleteBin2Line,key:"delete",text:"Delete",buttonProps:{onClick:o}}),e!=="section"&&h.unshift({Icon:W.RiImageLine,key:"upload",text:"Upload image",buttonProps:{onClick:()=>{var m;(m=c.current)==null||m.click()}}}),(r===void 0&&n!==p.fields.length-1||r!==void 0&&(r<p.fields.length-1||n!==p.fields[r].fields.length-1))&&h.unshift({Icon:W.RiArrowDownLine,key:"moveDown",text:"Move down",buttonProps:{onClick:()=>{l("down")}}}),(r===void 0&&n!==0||r!==void 0&&(r!==0||n!==0))&&h.unshift({Icon:W.RiArrowUpLine,key:"moveUp",text:"Move up",buttonProps:{onClick:()=>{l("up")}}}),h},[a,n,l,o,r,e,p.fields]);return i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"mx-2 flex hidden flex-col gap-5 sm:block",children:f.map(h=>{const m=h.Icon;return i.jsx(u.IconButton,{type:"button",variant:"ghost",accentColor:h.key.startsWith("move")?"base":void 0,"aria-label":h.text,...h.buttonProps,children:i.jsx(m,{})},h.key)})}),i.jsx("div",{className:"sm:hidden",children:i.jsxs(u.Menu.Root,{children:[i.jsx(u.Menu.ClickTrigger,{children:i.jsx(u.IconButton,{variant:"ghost","aria-label":"Actions menu",children:i.jsx(u.RiIcon,{icon:"RiMore2Line"})})}),i.jsx(u.Menu.Content,{children:f.map(h=>{var y;const m=h.Icon;return i.jsxs(u.Menu.Item,{onClick:(y=h.buttonProps)==null?void 0:y.onClick,children:[i.jsx(m,{}),h.text]},h.key)})})]})}),e!=="section"&&i.jsx("input",{style:{display:"none"},ref:c,type:"file",accept:"image/*",onChange:s})]})});yn.displayName="FieldActions";const Ur=(t=()=>null)=>d.useMemo(()=>ea.map(n=>n.map(e=>{const r=hn[e],o=r.Icon;return{children:r.fieldTypeName,leftSlot:i.jsx(o,{}),value:e,onSelect:()=>{t(e)}}})),[t]),pe=t=>t.type==="section",wn=d.memo(t=>{const{popoverInputs:n,hasError:e}=t;return i.jsxs(u.Popover.Root,{children:[i.jsx(u.Popover.Trigger,{children:i.jsxs(u.Button,{variant:"soft",size:"sm","aria-label":"settings",...e&&{color:$.danger},children:[i.jsx(u.RiIcon,{icon:"RiSettings2Line"}),i.jsx("span",{children:"Settings"})]},"settings")}),i.jsx(u.Popover.Content,{size:"sm",children:i.jsx("div",{className:"flex max-w-[240px] flex-col",children:n})})]})});wn.displayName="FieldSettingsPopover";const bn=d.memo(t=>{var re,wt,Cn,Kr,Qr,Yr;const{parentPath:n,index:e,initial:r,conditionalSourceFields:o}=t,{values:a,setFieldValue:l,errors:s}=j.useFormikContext(),p=Ur(),c=d.useRef(null),f=576,[h,m]=d.useState(c.current&&c.current.getBoundingClientRect().width>=f);d.useEffect(()=>{const P=c.current;if(P){const O=new ResizeObserver(G=>{G[0]&&m(G[0].contentRect.width>=f)});return O.observe(P),()=>{O.disconnect()}}},[]);const[y,x]=d.useState(void 0),[g,b]=d.useState(!1);d.useEffect(()=>{pe(r)?x(void 0):r.image instanceof Promise?r.image.then(x).catch(console.error):x(r.image)},[r]);const E=y?URL.createObjectURL(y):void 0,w=d.useCallback(P=>{P.stopPropagation();const{image:O,...G}=r;l(`${n}.${e}`,G).then()},[e,r,n,l]);d.useEffect(()=>{pe(r)&&!r.conditional&&l(`${n}.${e}.condition`,null).then()},[e,r,n,l]);const S=d.useMemo(()=>{var P,O;return pe(r)?(O=Ir(a.fields,(P=r.condition)==null?void 0:P.identifier))==null?void 0:O.label:void 0},[r,a.fields]),I=pe(r)?Array.isArray((re=r.condition)==null?void 0:re.value)?"contains all of":"equals":void 0;let F;if(pe(r)){if(mt((wt=r.condition)==null?void 0:wt.value))throw new Error("File values are not supported for conditions.");F=Array.isArray((Cn=r.condition)==null?void 0:Cn.value)?r.condition.value.map(P=>typeof P=="string"?P:P.label).join(", "):(Qr=(Kr=r.condition)==null?void 0:Kr.value)==null?void 0:Qr.toString()}const L=d.useCallback(P=>{P.target.parentNode instanceof HTMLElement&&(P.target.parentNode.dataset.replicatedValue=P.target.value)},[]),T=d.useCallback(P=>{P.target.parentNode instanceof HTMLElement&&(P.target.parentNode.dataset.replicatedValue=P.target.value)},[]),D=r.type,A=vn[D],[B,X]=d.useMemo(()=>{let P=[],O=[];if(A===H){if(o===void 0)throw new Error("Conditional source fields must be provided when changing sections.");const G=A.getFieldCreationSchema(o,`${n}.${e}`);P=P.concat(G.filter(V=>V.showDirectly).map(V=>V.field)),O=O.concat(G.filter(V=>!V.showDirectly).map(V=>V.field))}else{if(!(A.prototype instanceof q))throw new Error(`Field must be an instance of BaseField. Got ${A.toString()}.`);const G=A.getFieldCreationSchema(`${n}.${e}`);h?(P=[...P,...G.filter(V=>V.showDirectly).map(V=>V.field)],O=[...O,...G.filter(V=>!V.showDirectly).map(V=>V.field)]):O=[...O,...G.map(V=>V.field)]}return[P,O]},[A,o,n,e,h]),Q=$e(B,{formId:yt,disabled:!1,internal:!0,...A===H&&{size:"sm"}}),z=$e(X,{formId:yt,disabled:!1});let M=X.length>0;pe(r)&&X.length>0&&(M=r.conditional);const k=X.some(P=>{const O=Y(s,A===H?`${n}.${e}.condition`:P.getId());return O&&(typeof O!="object"||fe(O))}),se=k?$.danger:void 0,Ue=d.useMemo(()=>pt(r),[r]),We=Rt(Ue,{formId:yt,showInputOnly:!1});return i.jsx("div",{className:"flex grow items-center w-full",ref:c,children:i.jsxs("div",{className:"flex w-full flex-col gap-4",children:[A===H&&i.jsxs("div",{className:"flex flex-col gap-2",children:[B.length>0&&Q,i.jsxs("div",{className:"flex items-center gap-4",children:[M&&i.jsx(wn,{popoverInputs:z,hasError:k}),pe(r)&&r.conditional&&i.jsx("span",{className:"text-sm text-(--accent-a11)","data-accent-color":se,children:i.jsxs("em",{children:["Display only if ",i.jsx("strong",{children:S})," ",I," ",i.jsx("strong",{children:F})]})})]})]}),A!==H&&i.jsxs("div",{className:"flex gap-2 w-full justify-between",children:[i.jsxs("div",{className:"flex gap-2 items-center",children:[i.jsx(u.Badge,{className:"w-fit",accentColor:"base",variant:"soft",children:(Yr=p.flat().find(P=>P.value===D))==null?void 0:Yr.children}),i.jsx(he,{name:`${n}.${e}.required`,render:({setValue:P,value:O})=>i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(u.Checkbox.Root,{checked:O,onCheckedChange:P,variant:"soft",children:i.jsx(u.Checkbox.Indicator,{children:i.jsx(u.RiIcon,{icon:"RiCheckLine"})})}),i.jsx(u.Text,{size:"sm",accentColor:"base",children:"Required field"})]})})]}),M&&i.jsx(wn,{popoverInputs:z,hasError:k})]}),y&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"group relative inline-block w-full min-w-[300px]",children:[i.jsx("img",{className:"h-[100px] w-full min-w-[300px] cursor-pointer rounded-md object-cover",src:E,alt:y.name,onClick:()=>{b(!0)}}),i.jsx(u.IconButton,{className:"absolute top-2 right-2 hidden group-hover:not-disabled:flex",variant:"solid",accentColor:$.danger,"aria-label":"delete",onClick:w,children:i.jsx(u.RiIcon,{icon:"RiDeleteBin2Line"})})]}),g&&i.jsx(Qt,{file:y,url:E,name:y.name,setShowPreview:b})]}),i.jsx(he,{name:`${n}.${e}.label`,render:({setValue:P,value:O})=>i.jsx(u.Input.Root,{size:"md",variant:"outline",children:i.jsx(u.Input.Field,{placeholder:D==="section"?"Enter a section label (optional)":"Enter your question",value:O,onChange:G=>{P(G.target.value)},onInput:L,maxLength:200})})}),i.jsx(he,{name:`${n}.${e}.description`,render:({setValue:P,value:O})=>i.jsx(u.TextArea,{className:"field-sizing-content grow",placeholder:`Enter a ${D==="section"?"section":"field"} description (optional)`,value:O,onChange:G=>{P(G.target.value)},onInput:T,resize:"none",maxLength:1e3,variant:"outline"})}),A!==H&&B.length>0&&i.jsx("div",{className:"w-full",children:Q}),A!==H&&i.jsxs(i.Fragment,{children:[i.jsx(u.Separator,{size:"full"}),i.jsxs("div",{className:"flex flex-col gap-2",children:[i.jsx(u.Text,{accentColor:"base",children:"Field preview"}),i.jsx("div",{children:We})]})]})]})})});bn.displayName="FieldBuilder";const Wr=d.memo(t=>{const{field:n,index:e,sectionIndex:r,remove:o}=t,{setFieldValue:a,values:l}=j.useFormikContext(),{reorderField:s}=nn(),{showError:p}=u.useToast(),c=`fields.${r}.fields`,f=d.useMemo(()=>({index:e,parentPath:c,initial:n}),[n,e,c]),h=d.useCallback(()=>{const x=n.label??"Unlabelled field",g={...n,label:x};st(c,e+1,g,l,a)},[n,c,e,l,a]),m=d.useCallback(x=>{const g=r,b=l.fields[g];let E=r,w=x==="up"?e-1:e+1;x==="up"&&e===0?(E=r-1,w=l.fields[E].fields.length):x==="down"&&e===b.fields.length-1&&(E=r+1,w=0);const S=l.fields[E];s(b,g,e,S,E,w,a)},[r,l.fields,e,s,a]),y=d.useCallback(x=>{const{files:g}=x.target;if(!g||g.length!==1)return;const b=g.item(0);if(b){if(b.size>Ko){p({title:"File upload error",description:`The file ${b.name} exceeded the maximum file size`});return}a(`${c}.${e}`,{...n,image:b}).then()}},[n,e,c,a,p]);return i.jsx(ie.Draggable,{draggableId:n.identifier,index:e,children:x=>i.jsx(u.Card,{ref:x.innerRef,...x.draggableProps,...x.dragHandleProps,className:"mb-4",children:i.jsxs("div",{className:"flex items-center justify-between gap-4 w-full",children:[i.jsx(bn,{...f}),i.jsx(yn,{index:e,type:n.type,sectionIndex:r,remove:o,duplicate:h,move:m,upload:y})]})})})});Wr.displayName="FieldWithActions";const qr=d.memo(t=>{var S;const{field:n,index:e,dropState:r,fieldsOnly:o}=t,a=(S=r[n.identifier])==null?void 0:S.disabled,{setFieldValue:l,values:s}=j.useFormikContext(),p=u.useAlertDialog(),{reorderSection:c}=nn(),f=d.useCallback((I,F)=>{for(const L of I){const T=F.indexOf(L);l(`fields.${T}.condition`,null).then(),l(`fields.${T}.conditional`,!1).then()}},[l]),h=d.useCallback(I=>{var T;const F=n.fields[I];if(!F)throw new Error("Could not find field to remove.");const L=[];for(const D of s.fields)((T=D.condition)==null?void 0:T.identifier)===F.identifier&&L.push(D);return{removing:F,affectedSections:L,action:()=>l(`fields.${e}.fields`,lt(n.fields,I))}},[n.fields,s.fields,l,e]),m=d.useCallback(I=>{const{affectedSections:F,action:L,removing:T}=h(I),D=()=>{L().then(),f(F,s.fields)};if(F.length>0){const A=F.map(B=>B.label).join(", ");p({title:"Remove condition?",description:`${T.label} is being used as a condition, deleting it will remove the condition from the ${A} section(s).`,action:"Remove",onAction:D});return}D()},[h,f,s.fields,p]),y=d.useCallback(()=>{const F=n.fields.map((Q,z)=>h(z)).flatMap(Q=>Q.affectedSections),L=F.length?"Remove fields and conditions?":"Remove fields?",T=n.fields.length,D=F.map(Q=>Q.label).join(", "),A=F.length?`Deleting this section will remove the ${T} field(s) it contains and will remove the conditions from following sections: ${D}`:`Deleting this section will remove the ${T} field(s) it contains.`,B=lt(s.fields,e),X=()=>l("fields",B);if(F.length>0){p({title:L,description:A,action:"Remove",onAction:()=>{X().then(()=>{f(F,B)})}});return}X().then()},[n.fields,s.fields,e,h,l,p,f]),x=d.useCallback(I=>{const F=I==="up"?e-1:e+1;c(r,n.identifier,e,F,s,l)},[e,c,r,n.identifier,s,l]),g=d.useMemo(()=>({index:e,parentPath:"fields",initial:n,conditionalSourceFields:Er(s.fields,e)}),[n,e,s.fields]),b=d.useCallback(()=>{const I=n.label??"Untitled section",F=n.fields.map(T=>({...T,identifier:tn(null,T.label)})),L={...n,label:I,fields:F};st("fields",e+1,L,s,l)},[n,e,s,l]),E=d.useCallback(I=>{st(`fields.${e}.fields`,n.fields.length,Xo[I],s,l)},[e,n.fields.length,s,l]),w=Ur(E);return i.jsx(ie.Draggable,{draggableId:n.identifier,index:e,children:I=>i.jsx(u.Card,{ref:I.innerRef,...I.draggableProps,...I.dragHandleProps,variant:"outline",className:"mb-4 w-full",children:i.jsxs("div",{className:"flex items-center justify-between gap-3 w-full",children:[i.jsxs("div",{className:"flex grow flex-col gap-2 w-full",children:[!o&&i.jsx(bn,{...g}),i.jsx(ie.Droppable,{droppableId:n.identifier,type:"SECTION",isDropDisabled:a,children:F=>i.jsxs("div",{className:"flex flex-col gap-0 w-full",ref:F.innerRef,...F.droppableProps,children:[n.fields.map((L,T)=>i.jsx(Wr,{field:L,index:T,sectionIndex:e,remove:()=>{m(T)}},L.identifier)),F.placeholder,i.jsxs(u.Menu.Root,{children:[i.jsx(u.Menu.ClickTrigger,{children:i.jsxs(u.Button,{type:"button",variant:"solid",children:[i.jsx(u.RiIcon,{icon:"RiAddLine"})," Add field"]})}),i.jsx(u.Menu.Content,{children:w.flat().map(L=>i.jsxs(u.Menu.Item,{onSelect:L.onSelect,children:[L.leftSlot,L.children]},L.value))})]})]})})]}),!o&&i.jsx(yn,{index:e,type:n.type,remove:y,duplicate:b,move:x})]})})})});qr.displayName="FieldSectionWithActions";const Hr=(t,n)=>{for(const[e,r]of Object.entries(t))if(r.identifier===n)return[r,e]},Gr=d.memo(t=>{const{fieldsOnly:n}=t,{values:e,setFieldValue:r}=j.useFormikContext(),[o,a]=d.useReducer(ta,e.fields,jr),{reorderSection:l,reorderField:s}=nn();d.useEffect(()=>{a({type:"update",state:jr(e.fields)})},[a,e.fields]);const p=d.useCallback(h=>{h.type==="SECTION"&&a({type:"hold",fieldId:h.draggableId})},[]),c=d.useCallback(h=>{const{source:m,destination:y,type:x,reason:g,draggableId:b}=h;if(a({type:"release"}),!y||g==="CANCEL")return;if(x==="ROOT"){l(o,b,m.index,y.index,e,r);return}if(x!=="SECTION")throw new Error("Unexpected droppable type.");const[E,w]=Hr(e.fields,m.droppableId)??[],[S,I]=Hr(e.fields,y.droppableId)??[];s(E,w,m.index,S,I,y.index,r)},[e,s,r,l,o]),f=d.useCallback(h=>{Wo(h+1,e,r)},[e,r]);return i.jsx(ie.DragDropContext,{onDragStart:p,onDragEnd:c,children:i.jsx(ie.Droppable,{droppableId:"droppable",type:"ROOT",children:h=>i.jsxs("div",{className:"flex flex-col gap-0",ref:h.innerRef,...h.droppableProps,children:[e.fields.map((m,y)=>i.jsxs(d.Fragment,{children:[i.jsx(qr,{field:m,index:y,dropState:o,fieldsOnly:n}),!n&&i.jsxs(u.Button,{className:"mb-4",type:"button",variant:"soft",accentColor:"base",onClick:()=>{f(y)},children:[i.jsx(u.RiIcon,{icon:"RiAddLine"})," Add section"]})]},m.identifier)),h.placeholder]})})})});Gr.displayName="FieldsEditor";const ra=()=>{alert("This is a form preview, your data will not be saved.")},ia=d.memo(d.forwardRef((t,n)=>{const{onCancel:e,onSave:r,revision:o,initialTitle:a,showExplainerText:l=!0,showFormTitle:s=!0,fieldsOnly:p=!1,showTabs:c=!0,tabsListClassName:f,hydrateRevisionWithImages:h}=t,{showError:m}=u.useToast(),y=d.useCallback(w=>{const S={};w.title||(S.title="Title is required."),(!w.fields||w.fields.length===0)&&(S.fields="At least one field is required.");let I=[];for(const[L,T]of w.fields.entries()){const A=vn.section.getFieldCreationSchema(Er(w.fields,L),`fields.${L}`).map(B=>B.field);I=[...I,...A];for(const[B,X]of T.fields.entries()){const z=vn[X.type].getFieldCreationSchema(`fields.${L}.fields.${B}`).map(M=>M.field);I=[...I,...z]}}const F=gt({fields:I},w);if(F&&(S.fields=F.fields),fe(S))return m({title:"Some form settings are invalid",description:"Please check settings highlighted in red."}),S},[m]),x=d.useMemo(()=>({title:a??"",description:"",fields:[{...at(tn(null,"")),label:""}]}),[a]),g=o?h(o):void 0,b=j.useFormik({initialValues:Uo(g)??x,validate:y,onSubmit:r,validateOnChange:!1,validateOnBlur:!1}),E=d.useMemo(()=>$r(b.values),[b.values]);return i.jsx(u.Tabs.Root,{ref:n,defaultValue:"edit",children:i.jsxs("div",{className:"flex flex-col gap-2",children:[c&&i.jsxs(u.Tabs.List,{className:we("sticky top-0 z-[2000] flex bg-(--color-background)",f),children:[i.jsx(u.Tabs.Trigger,{className:"grow",value:"edit",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(u.RiIcon,{icon:"RiPencilLine"}),"Edit form"]})}),i.jsx(u.Tabs.Trigger,{className:"grow",value:"preview",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(u.RiIcon,{icon:"RiEyeLine"}),"Preview form"]})})]}),i.jsxs(u.Tabs.Content,{value:"edit",children:[l&&i.jsxs("span",{children:["Create your form using various field types. Sections can be"," ",i.jsx("strong",{children:"conditionally rendered"})," based on"," ",i.jsx("strong",{children:"answers to fields in preceding sections. "})]}),i.jsxs("form",{className:"mt-3 flex flex-col gap-2",id:yt,onSubmit:b.handleSubmit,children:[i.jsxs(j.FormikProvider,{value:b,children:[s&&i.jsxs(i.Fragment,{children:[i.jsx(he,{name:"title",render:({setValue:w,value:S,meta:I})=>i.jsx(Yt,{severity:"danger",helpText:I.error??null,children:i.jsx(u.Input.Root,{variant:"outline",size:"lg",accentColor:I.error?$.danger:"primary",children:i.jsx(u.Input.Field,{placeholder:"Form title",value:S,onChange:F=>{w(F.target.value)},maxLength:100})})})}),i.jsx(he,{name:"description",render:({setValue:w,value:S})=>i.jsx(u.TextArea,{className:"field-sizing-content",placeholder:"Explain the purpose of this form",value:S,onChange:I=>{w(I.target.value)},resize:"vertical",maxLength:1e3})})]}),i.jsx(Gr,{fieldsOnly:p}),i.jsx("span",{"data-accent-color":$.danger,className:"text-xs text-(--accent-a11)",children:typeof b.errors.fields=="string"&&b.errors.fields})]}),i.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e&&i.jsx(u.Button,{type:"button",variant:"solid",accentColor:"base",onClick:e,children:"Cancel"}),i.jsx(u.Button,{type:"submit",children:"Save form"})]})]})]}),i.jsx(u.Tabs.Content,{value:"preview",children:i.jsx(Vr,{schema:E,onSubmit:ra,hideTitle:!s})})]})})})),oa=Object.values(U.Colors),aa=1;async function la(t,n,e,r){const o=t.getContext("2d",{}),a=new Image(r.width,r.height),l=new Image(r.width,r.height),s=new U.DeferredPromise;return a.onload=function(){o.drawImage(a,0,0,r.width,r.height),l.src=URL.createObjectURL(e),l.onload=async function(){o.drawImage(l,0,0,r.width,r.height);const p=t.toDataURL("image/jpeg",aa),c=await U.fileToBlob(p),f=new File([c],n.name,{type:"image/jpeg"});s.resolve(f)}},a.src=URL.createObjectURL(n),s}const Xr=d.memo(t=>{const{file:n,onClose:e,onSave:r,onDelete:o,dirty:a,onDirty:l}=t;n.objectURL||(n.objectURL=URL.createObjectURL(n));const s=d.useRef(null),p=d.useRef(null),[c,f]=d.useState(U.Colors.red),[h,m]=d.useState(null),[y,x]=d.useState(!1),[g,b]=d.useState(!1),E=d.useRef(null),w=u.useSize(E);d.useEffect(()=>{const z=new Image;z.onload=function(){m({width:z.naturalWidth,height:z.naturalHeight})},z.src=URL.createObjectURL(n)},[n]),d.useEffect(()=>{!g&&(w!=null&&w.width)&&w.height&&b(!0)},[w,g]);const S=d.useCallback(async()=>{a||e();const z=s.current;if(!z)return;if(!h)throw new Error("Original image size not loaded yet");const M=await z.exportImage("png"),k=new Image(h.width,h.height);k.onload=async function(){const se=await U.fileToBlob(M),Ue=new File([se],n.name,{type:n.type}),We=p.current,re=await la(We,n,Ue,h);re.objectURL=URL.createObjectURL(re);const wt=await U.hashFile(n);await U.hashFile(re)!==wt&&r(re),x(!1),e()},x(!0),k.src=M},[a,n,e,r,h]),I=d.useCallback(()=>{o(n)},[n,o]),F=d.useCallback(()=>{e()},[e]),L=d.useCallback(()=>{l(!0)},[l]),T=d.useCallback(()=>{s.current&&s.current.redo()},[]),D=d.useCallback(()=>{s.current&&s.current.undo()},[]),A=d.useCallback(()=>{s.current&&(l(!1),s.current.clearCanvas())},[l]),B=d.useCallback(z=>{s.current&&s.current.eraseMode(z)},[]),X=d.useCallback(()=>{S()},[S]),Q=d.useCallback(()=>{U.downloadFile(n)},[n]);return i.jsx(Me,{open:!0,onOpenChange:e,children:i.jsxs(Ae,{children:[i.jsx(Oe,{className:"light:bg-(--black-a6) fixed inset-0 dark:bg-(--black-a8)","data-floating-content":""}),i.jsx(Be,{className:"fixed inset-0","data-floating-content":"",children:i.jsxs(i.Fragment,{children:[h&&i.jsx("canvas",{style:{display:"none"},id:"attachment-markup-canvas",ref:p,width:h.width,height:h.height}),i.jsxs("div",{className:"relative flex h-full w-full flex-col",children:[i.jsx("div",{className:"flex h-8 w-full items-center bg-(--color-background) px-2",children:i.jsx(u.ButtonGroup,{accentColor:"base",size:"md",variant:"soft",children:i.jsxs("div",{className:"grid w-full grid-cols-3",children:[i.jsxs("div",{className:"flex gap-2",children:[i.jsx(u.IconButton,{"aria-label":"close",onClick:F,children:i.jsx(u.RiIcon,{icon:"RiCloseLine"})}),i.jsx(u.IconButton,{"aria-label":`Download ${n.name}`,onClick:Q,children:i.jsx(u.RiIcon,{icon:"RiDownload2Line"})})]}),i.jsxs("div",{className:"flex items-center justify-center gap-2",children:[i.jsx(It,{selectedColor:c,allColors:oa,onFinish:f,trigger:i.jsx(u.IconButton,{"aria-label":"Markup color picker",type:"button",variant:"solid",style:{backgroundColor:c},children:" "})}),i.jsx(u.IconToggleButton,{defaultPressed:!1,"aria-label":"erase",onPressedChange:B,children:i.jsx(u.RiIcon,{icon:"RiEraserFill"})}),i.jsx(u.Separator,{orientation:"vertical",size:"full"}),i.jsx(u.IconButton,{"aria-label":"undo",onClick:D,children:i.jsx(u.RiIcon,{icon:"RiArrowGoBackLine"})}),i.jsx(u.IconButton,{"aria-label":"undo",onClick:T,children:i.jsx(u.RiIcon,{icon:"RiArrowGoForwardLine"})}),i.jsx(u.IconButton,{"aria-label":"undo all",onClick:A,children:i.jsx(u.RiIcon,{icon:"RiLoopLeftLine"})})]}),i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(u.IconButton,{"aria-label":"Save markup",accentColor:"primary",onClick:X,children:i.jsx(u.RiIcon,{icon:"RiSaveLine"})}),i.jsx(u.IconButton,{"aria-label":"Delete attachment",onClick:I,children:i.jsx(u.RiIcon,{icon:"RiDeleteBin2Line"})})]})]})})}),i.jsxs("div",{className:"relative flex w-full grow items-center justify-center p-4",children:[i.jsx("img",{className:"translate-xmax-h-[calc(100%-130px)] pointer-events-none invisible absolute top-[50%] left-[50%] max-w-svw translate-x-[-50%] translate-y-[-50%] object-contain",alt:"Photo attachment",ref:E,src:n.objectURL}),y?i.jsx(u.Spinner,{}):i.jsx(Rr.ReactSketchCanvas,{backgroundImage:n.objectURL,ref:s,width:`${(w==null?void 0:w.width)||0}px`,height:`${(w==null?void 0:w.height)||0}px`,onStroke:L,strokeColor:c},g?"1":"0")]})]})]})})]})})});Xr.displayName="AttachmentEditor",C.BaseField=q,C.BaseFormElement=Kt,C.BooleanField=Ce,C.BooleanInput=Jt,C.ColorPicker=It,C.DateField=it,C.DateInput=Zt,C.FieldSection=H,C.FileBadge=ze,C.FileCard=Gt,C.FileIcon=_e,C.FileViewerContext=Xt,C.FileViewerProvider=gr,C.FormBuilder=ia,C.FormRenderer=Vr,C.ImageCard=Br,C.ImageMarkup=Xr,C.ImageViewer=jt,C.InputWithHelpText=Yt,C.InputWithLabel=Z,C.InputWithLabelAndHelpText=R,C.MultiSelectField=Ve,C.MultiSelectInput=sn,C.MultiStringField=ke,C.MultiStringInput=rn,C.NumberField=le,C.NumberInput=on,C.PDFViewer=Wt,C.PatchField=he,C.PatchFormProvider=Ro,C.QrField=ct,C.QrInput=an,C.QrScanner=ln,C.SUPPORTED_IMAGE_FILE_TYPES=Et,C.SUPPORTED_PDF_FILE_TYPES=Ut,C.SUPPORTED_SPREADSHEET_FILE_EXTENSIONS=qt,C.SelectField=je,C.SelectInput=cn,C.SpreadsheetViewer=Ht,C.StringField=ut,C.StringInput=dn,C.TextField=ft,C.TextInput=un,C.decodeFormValues=Qo,C.deserialize=pt,C.deserializeField=pn,C.emptyBaseField=K,C.emptyBooleanField=wr,C.emptyDateField=br,C.emptyMultiSelectField=Dr,C.emptyMultiStringField=Sr,C.emptyNumberField=Nr,C.emptyQrField=Tr,C.emptySelectField=Pr,C.emptyStringField=Ar,C.emptyTextField=Or,C.encodeFormValues=Yo,C.flattenFields=mn,C.formRevisionToSchema=$r,C.initialFormValues=vt,C.isConditionMet=gn,C.useFieldInput=Rt,C.useFieldInputs=$e,C.useFileViewer=mr,C.useFormikInput=_,C.validateForm=gt,C.valueIsFile=mt,Object.defineProperty(C,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@overmap-ai/forms",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.0.17-master.
|
|
4
|
+
"version": "1.0.17-master.4",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"main": "dist/forms.umd.cjs",
|
|
7
7
|
"module": "dist/forms.js",
|
|
8
8
|
"types": "dist/index.d.ts",
|
|
9
9
|
"type": "module",
|
|
10
|
+
"files": [
|
|
11
|
+
"dist"
|
|
12
|
+
],
|
|
10
13
|
"scripts": {
|
|
11
14
|
"dev": "vite",
|
|
12
15
|
"build": "tsc && vite build",
|
|
@@ -28,7 +31,7 @@
|
|
|
28
31
|
"@chromatic-com/storybook": "^3.2.4",
|
|
29
32
|
"@eslint/js": "^9.19.0",
|
|
30
33
|
"@overmap-ai/blocks": "1.0.31-tailwind-components.25",
|
|
31
|
-
"@overmap-ai/core": "1.0.60-forms-removal.
|
|
34
|
+
"@overmap-ai/core": "1.0.60-forms-removal.9",
|
|
32
35
|
"@radix-ui/colors": "^3.0.0",
|
|
33
36
|
"@storybook/addon-a11y": "^8.5.3",
|
|
34
37
|
"@storybook/addon-essentials": "^8.5.3",
|
package/.husky/pre-commit
DELETED
package/.prettierrc.json
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Provider, ToastProvider } from "@overmap-ai/blocks"
|
|
2
|
-
import { ReactRenderer } from "@storybook/react"
|
|
3
|
-
import type { DecoratorFunction } from "@storybook/types"
|
|
4
|
-
import { FC } from "react"
|
|
5
|
-
|
|
6
|
-
import { FileViewerProvider } from "../src"
|
|
7
|
-
|
|
8
|
-
export const StoryDecorator: DecoratorFunction<ReactRenderer> = (Story) => {
|
|
9
|
-
const StoryComponent = Story as FC
|
|
10
|
-
return (
|
|
11
|
-
// <Provider store={storyStore}>
|
|
12
|
-
<Provider accentColor="primary">
|
|
13
|
-
<FileViewerProvider>
|
|
14
|
-
<ToastProvider>
|
|
15
|
-
<div className="h-full w-full p-5">
|
|
16
|
-
<StoryComponent />
|
|
17
|
-
</div>
|
|
18
|
-
</ToastProvider>
|
|
19
|
-
</FileViewerProvider>
|
|
20
|
-
</Provider>
|
|
21
|
-
)
|
|
22
|
-
}
|
package/.storybook/main.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { StorybookConfig } from "@storybook/react-vite"
|
|
2
|
-
|
|
3
|
-
const config: StorybookConfig = {
|
|
4
|
-
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
|
|
5
|
-
addons: [
|
|
6
|
-
"@storybook/addon-essentials",
|
|
7
|
-
"@chromatic-com/storybook",
|
|
8
|
-
"@storybook/addon-interactions",
|
|
9
|
-
"@storybook/addon-themes",
|
|
10
|
-
"@storybook/addon-viewport",
|
|
11
|
-
"@storybook/addon-a11y",
|
|
12
|
-
],
|
|
13
|
-
framework: {
|
|
14
|
-
name: "@storybook/react-vite",
|
|
15
|
-
options: {
|
|
16
|
-
strictMode: true,
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
}
|
|
20
|
-
export default config
|