@overmap-ai/forms 1.0.17-file-viewer-updates.8 → 1.0.17-file-viewer-updates.10

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.js CHANGED
@@ -1991,6 +1991,8 @@ const fn = (t, n) => {
1991
1991
  B,
1992
1992
  {
1993
1993
  size: "sm",
1994
+ accentColor: "base",
1995
+ variant: "soft",
1994
1996
  type: "button",
1995
1997
  "aria-label": "Add option",
1996
1998
  disabled: !!E || m,
@@ -4052,7 +4054,7 @@ const tr = O((t) => {
4052
4054
  )),
4053
4055
  I.placeholder,
4054
4056
  /* @__PURE__ */ y(M.Root, { children: [
4055
- /* @__PURE__ */ a(M.ClickTrigger, { children: /* @__PURE__ */ y(X, { type: "button", variant: "soft", children: [
4057
+ /* @__PURE__ */ a(M.ClickTrigger, { children: /* @__PURE__ */ y(X, { type: "button", variant: "soft", size: "sm", children: [
4056
4058
  /* @__PURE__ */ a(T, { icon: "RiAddLine" }),
4057
4059
  " Add field"
4058
4060
  ] }) }),
@@ -4142,6 +4144,7 @@ const Vn = (t, n) => {
4142
4144
  className: "mb-4",
4143
4145
  type: "button",
4144
4146
  variant: "soft",
4147
+ size: "sm",
4145
4148
  accentColor: "base",
4146
4149
  onClick: () => {
4147
4150
  d(g);
@@ -4160,6 +4163,7 @@ const Vn = (t, n) => {
4160
4163
  type: "button",
4161
4164
  variant: "soft",
4162
4165
  accentColor: "base",
4166
+ size: "sm",
4163
4167
  onClick: () => {
4164
4168
  d(e.fields.length);
4165
4169
  },
@@ -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},xo="DialogDescriptionWarning",Eo=({contentRef:t,descriptionId:n})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${lr(xo).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},zt=Jn,Bt=er,_t=tr,$t=nr,So=ar;const Vt=f.memo(t=>{const{file:n,onClose:e}=t,r=f.useRef(null),o=f.useCallback(()=>{var l;if(!r.current)return;const s=document.createElement("canvas");s.width=r.current.width,s.height=r.current.height,(l=s.getContext("2d"))==null||l.drawImage(r.current,0,0,r.current.width,r.current.height),s.toBlob(p=>{p&&navigator.clipboard.write([new ClipboardItem({"image/png":p})])},"image/png")},[]),a=f.useCallback(()=>{H.downloadFile(n)},[n]);return i.jsx(zt,{open:!0,onOpenChange:e,children:i.jsx(Bt,{children:i.jsx(_t,{className:"bg-(--color-background) fixed inset-0 data-[state='open']:fade-in-0 data-[state='open']:zoom-in-95 data-[state='closed']:animate-out data-[state='closed']:fade-out-0 data-[state='closed']:zoom-out-95 data-[state='open']:animate-in","data-floating-content":"",children:i.jsxs($t,{className:"absolute inset-0 py-12","data-floating-content":"",onOpenAutoFocus:s=>s.preventDefault(),children:[i.jsxs(d.ButtonGroup,{className:"flex gap-2 items-center top-0 absolute right-0 p-2",accentColor:"base",variant:"ghost",children:[i.jsxs(d.Tooltip.Root,{children:[i.jsx(d.Tooltip.Trigger,{children:i.jsx(d.IconButton,{onClick:o,"aria-label":"copy to clipboard",children:i.jsx(d.RiIcon,{icon:"RiFileCopyLine"})})}),i.jsx(d.Tooltip.Content,{size:"sm",children:"Copy"})]}),i.jsxs(d.Tooltip.Root,{children:[i.jsx(d.Tooltip.Trigger,{children:i.jsx(d.IconButton,{onClick:a,"aria-label":"download",children:i.jsx(d.RiIcon,{icon:"RiDownload2Line"})})}),i.jsx(d.Tooltip.Content,{size:"sm",children:"Download"})]}),i.jsx(d.Separator,{orientation:"vertical",size:"sm"}),i.jsx(So,{asChild:!0,children:i.jsx(d.IconButton,{onClick:e,"aria-label":"close",children:i.jsx(d.RiIcon,{icon:"RiCloseLine"})})})]}),i.jsx("figure",{className:"size-full overflow-hidden p-4 flex justify-center items-center",children:i.jsx("img",{ref:r,className:"max-w-full max-h-full",src:URL.createObjectURL(n),alt:n.name})})]})})})})});Vt.displayName="ImageViewer";const cr=f.memo(t=>{const{children:n}=t,[e,r]=f.useState(null),o=f.useCallback(()=>{r(null)},[]),a=f.useCallback(p=>{r(p(o))},[o]),s=f.useCallback(()=>{e&&(e.onClose&&e.onClose(),o())},[o,e]),l=f.useMemo(()=>a,[a]);return i.jsxs(bn.Provider,{value:l,children:[n,e&&i.jsx(Vt,{file:e.file,onClose:s})]})});cr.displayName="FileViewerProvider";const Q=t=>{const{className:n,label:e,children:r,severity:o,inputId:a,labelId:s,image:l}=t,[p,c]=f.useState(void 0),u=Ve(),h=o?ne[o]:"base";f.useEffect(()=>{l instanceof Promise?l.then(c).catch(console.error):c(l)},[l]);const g=p?URL.createObjectURL(p):void 0,y=f.useCallback(()=>{p&&u(()=>({file:p}))},[u,p]);return i.jsxs("div",{className:"flex flex-col gap-2",children:[p&&i.jsx("img",{className:"h-[100px] w-full min-w-[300px] cursor-pointer rounded-md object-cover",src:g,alt:p.name,onClick:y}),i.jsxs("label",{className:he(n,"flex flex-col gap-1"),htmlFor:a,children:[i.jsx(d.Text,{accentColor:h,size:"sm",id:s,weight:"medium",children:e}),r]})]})},Ut=t=>{const{helpText:n,children:e,severity:r}=t,o=r?ne[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(d.Text,{accentColor:o,size:"xs",children:n})})]})},Y=t=>{const{children:n,...e}=t;return i.jsx(Ut,{...e,children:n})},Fo=[!0,"true"],jt=f.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,fieldProps:l},p]=_(t);let[{helpText:c,label:u}]=_(t);c=a?null:c,u=a?"":u;const h=Fo.includes(l.value);return i.jsx(Y,{helpText:c,severity:o,children:i.jsx(Q,{size:r,severity:o,inputId:n,labelId:e,label:u,image:a?void 0:s.image,className:"items-center flex-row-reverse justify-end gap-2",children:i.jsx(d.Checkbox.Root,{...p,...l,id:n,size:"sm",accentColor:"primary",value:h.toString(),checked:h,onCheckedChange:l.onChange,onChange:void 0,onBlur:void 0,variant:"surface",children:i.jsx(d.Checkbox.Indicator,{children:i.jsx(d.RiIcon,{icon:"RiCheckLine"})})})})})});jt.displayName="BooleanInput";const dr={...G,type:"boolean"},be=class be extends k{constructor(e){super({...e,type:"boolean"});I(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 be(e)}getInput(e){return i.jsx(jt,{...e,field:this})}};I(be,"fieldTypeName","Checkbox"),I(be,"fieldTypeDescription","Perfect for both optional and required yes/no questions."),I(be,"Icon",j.RiCheckboxCircleLine);let Ce=be;const kt=f.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,fieldProps:l},p]=_(t);let[{helpText:c,label:u}]=_(t);c=a?null:c,u=a?"":u;const h=l.value?new Date(l.value):void 0,g=f.useCallback(y=>{l.onChange({target:{value:y?y.toISOString():null}})},[l]);return i.jsx(Y,{helpText:c,severity:o,children:i.jsx(Q,{size:r,severity:o,inputId:n,labelId:e,label:u,image:a?void 0:s.image,children:i.jsxs(d.Popover.Root,{children:[i.jsx(d.Popover.Trigger,{asChild:!0,children:i.jsxs(d.Button,{...p,className:"!justify-between",type:"button",accentColor:"base",variant:"surface",size:"sm",id:n,children:[h?h.toLocaleString(void 0,{year:"numeric",month:"2-digit",day:"2-digit"}):"yyyy-mm-dd",i.jsx(d.RiIcon,{icon:"RiArrowDownSLine"})]})}),i.jsx(d.Popover.Content,{children:i.jsx(d.DayPicker,{required:!1,mode:"single",variant:"solid",selected:h,onSelect:g})})]})})})});kt.displayName="DateInput";const ur={...G,type:"date"},we=class we extends k{constructor(e){super({...e,type:"date"});I(this,"onlyValidateAfterTouched",!1)}serialize(){return super._serialize()}getValueFromChangeEvent(e){return e.target.value}static deserialize(e){if(e.type!=="date")throw new Error("Type mismatch.");return new we(e)}getInput(e){return i.jsx(kt,{field:this,...e})}};I(we,"fieldTypeName","Date"),I(we,"fieldTypeDescription","Allows specifying a date."),I(we,"Icon",j.RiCalendarLine);let Je=we;const fr=f.memo(t=>{const{field:n,...e}=t,[{value:r}]=U.useField(n.options.clonedFieldIdentifier),o=f.useMemo(()=>{const a=n.options.getFieldToClone(r);return a?ct(a):null},[n.options,r]);return Wt(o,e)});fr.displayName="FieldInputCloner";const No={...G,type:"custom"};class Ze extends k{constructor(e,r){super({...e,type:"custom"});I(this,"Component");I(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})}}I(Ze,"fieldTypeName","Custom"),I(Ze,"fieldTypeDescription","Allows re-rendering of field already in the form");class To extends Ze{constructor(n){super(n,fr)}}const Wt=(t,n)=>f.useMemo(()=>!n||!t?null:t.getInput(n),[t,n]),Pe=(t,n)=>{const e=f.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})},Re=(t="",n=[])=>({type:"section",fields:n,identifier:t,label:null,condition:null,conditional:!1}),Lo=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(Re(`AUTO_section-${n.indexOf(o)}`,e)),e=[]),r.push(o)):e.push(o);return e.length>0&&r.push(Re("AUTO_section-last",e)),{...t,fields:r,description:t.description??""}};function qt(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 hr(t,n,e){const r=Array.from(t??[]);return r.splice(n,0,e),r}function et(t,n){const e=Array.from(t);return e.splice(n,1),e}const Ht=(t,n)=>{const e=new Date;return`${H.slugify(n)}-${e.getTime()}`},pr=(t,n)=>{if(!n)return null;for(const e of t)if(e.type==="section"){const r=pr(e.fields,n);if(r)return r}else if(e.identifier===n)return e;return null},mr=(t,n)=>t.filter((e,r)=>r<n).flatMap(e=>e.fields),tt=(t,n,e,r,o)=>{const{label:a}=e,s={...e,identifier:Ht(null,a)},l=X(r,t);if(l===void 0)throw new Error("Parent path must point to an existing field.");if(!Array.isArray(l))throw new Error("Parent path must point to an array.");const p=hr(l,n,s);o(t,p).then()},Do=(t,n,e)=>{const r={...Re(),label:""};tt("fields",t,r,n,e)},Gt=()=>{const{showError:t}=d.useToast(),n=f.useCallback((r,o,a,s,l,p)=>{const c=r[o];if(!c)throw new Error("Could not find section context.");let u=typeof c.conditionIndex<"u"?Math.max(c.conditionIndex+1,s):s;for(const h of Object.values(r))h.conditionIndex===a&&(u=Math.min(u,h.index-1));if(u!==s){t({title:"Could not reorder sections",description:"Sections with conditions must be below the fields they reference."});return}p("fields",qt(l.fields,a,u))},[t]),e=f.useCallback((r,o,a,s,l,p,c)=>{var u;if(!(r!=null&&r.fields)||!s)throw new Error("Could not find section with fields.");if(r.identifier===s.identifier)c(`fields.${o}.fields`,qt(r.fields,a,p)).then();else{const h=r.fields[a];if(!h)throw new Error("Could not find field to reorder.");if(((u=s.condition)==null?void 0:u.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`,et(r.fields,a)).then(),c(`fields.${l}.fields`,hr(s.fields,p,h)).then()}},[t]);return{reorderSection:n,reorderField:e}},Xt=f.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,fieldProps:l},p]=_(t);let[{helpText:c,label:u}]=_(t);c=a?null:c,u=a?"":u;const h=f.useMemo(()=>Array.isArray(l.value)?l.value:[],[l.value]),{onChange:g,onBlur:y}=l,w=`${n}-droppable`,{disabled:m}=p,[C,E]=f.useState(""),[S,N]=f.useState(""),x=S||c,F=f.useCallback(A=>{g(A),y(A)},[g,y]),L=f.useCallback(A=>{h.findIndex(B=>B===A.target.value.trim())>=0?N("All options must be unique"):A.target.value?N(""):N("Option cannot be empty"),E(A.target.value)},[E,h]),T=f.useCallback(()=>{if(S)return;if(!C.trim()){N("Option cannot be empty");return}const A=C.trim();F([...h,A]),E("")},[C,S,F,h]),D=f.useCallback(A=>{A.key==="Enter"&&(A.preventDefault(),T())},[T]),$=f.useCallback(A=>{F(et(h,A))},[h,F]),z=f.useCallback(A=>{if(!A.destination)return;const B=A.source.index,O=A.destination.index;F(qt(h,B,O))},[F,h]);return i.jsx(te.DragDropContext,{onDragEnd:z,children:i.jsxs("div",{className:"flex flex-col gap-2",children:[i.jsx(Y,{helpText:x,severity:o,children:i.jsx(Q,{size:r,severity:o,inputId:n,labelId:e,label:u,image:a?void 0:s.image,children:(!m||h.length===0)&&i.jsxs("div",{className:"flex gap-2",children:[i.jsx("div",{className:"grow",children:i.jsx(d.Input.Root,{accentColor:"base",variant:"surface",size:"sm",children:i.jsx(d.Input.Field,{...p,...l,value:C,onChange:L,onKeyDown:D,id:n,placeholder:s.placeholder,onBlur:void 0})})}),i.jsx(d.IconButton,{size:"sm",type:"button","aria-label":"Add option",disabled:!!S||m,onClick:T,children:i.jsx(d.RiIcon,{icon:"RiAddLine"})})]})})}),i.jsx(te.Droppable,{droppableId:w,children:A=>i.jsxs("div",{className:"flex flex-col",...A.droppableProps,ref:A.innerRef,children:[h.map((B,O)=>i.jsx(te.Draggable,{draggableId:`${B}-draggable`,index:O,isDragDisabled:m,children:({draggableProps:R,dragHandleProps:De,innerRef:_e})=>i.jsxs(d.Badge,{...De,...R,ref:_e,className:"mb-1 flex items-center justify-between gap-2",accentColor:"base",size:"sm",variant:"soft",children:[i.jsx("span",{children:typeof B=="object"&&"label"in B?B.label:B}),i.jsx(d.IconButton,{size:"xs",variant:"ghost",type:"button","aria-label":"Delete option",accentColor:"base",disabled:m,onClick:()=>{$(O)},children:i.jsx(d.RiIcon,{icon:"RiCloseLargeLine"})})]})},B)),A.placeholder]})})]})})});Xt.displayName="MultiStringInput";const gr={...G,type:"multi-string",minimum_length:0,maximum_length:null},Ie=class Ie extends k{constructor(e){const{minimum_length:r,maximum_length:o,placeholder:a,...s}=e;super({...s,type:"multi-string"});I(this,"minLength");I(this,"maxLength");I(this,"onlyValidateAfterTouched",!1);I(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(Xt,{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 Ie(e)}};I(Ie,"fieldTypeName","Multi-string"),I(Ie,"fieldTypeDescription","Allows the user to provide multiple unique strings."),I(Ie,"Icon",j.RiListCheck);let Oe=Ie;const Kt=f.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,fieldProps:l},p]=_(t);let[{helpText:c,label:u}]=_(t);return c=a?null:c,u=a?"":u,i.jsx(Y,{helpText:c,severity:o,children:i.jsx(Q,{size:r,severity:o,inputId:n,labelId:e,label:u,image:a?void 0:s.image,children:i.jsx(d.Input.Root,{accentColor:"base",variant:"surface",size:"sm",children:i.jsx(d.Input.Field,{...p,...l,type:"number",id:n,placeholder:s.placeholder,min:s.minimum,max:s.maximum,step:s.integers?1:.1})})})})});Kt.displayName="NumberInput";const vr={...G,type:"number",minimum:Number.MIN_SAFE_INTEGER,maximum:Number.MAX_SAFE_INTEGER,integers:!1},yr=t=>"fields"in t,Z=class Z extends k{constructor(e){const{minimum:r=Number.MIN_SAFE_INTEGER,maximum:o=Number.MAX_SAFE_INTEGER,integers:a=!1,placeholder:s="Enter a number",...l}=e;super({...l,type:"number"});I(this,"minimum");I(this,"maximum");I(this,"integers");I(this,"placeholder");this.minimum=r,this.maximum=o,this.integers=a,this.placeholder=s}getValueFromChangeEvent(e){const r=Number.parseFloat(e.target.value);return Number.isNaN(r)?"":r}static getFieldCreationSchema(e=""){const r=e&&`${e}.`;return[{field:new Z({label:"Minimum",description:"Minimum value",integers:!0,required:!1,identifier:`${r}minimum`,formValidators:[this._validateMin(e)]}),showDirectly:!1},{field:new Z({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 Z(e)}getInput(e){return i.jsx(Kt,{field:this,...e})}};I(Z,"fieldTypeName","Number"),I(Z,"fieldTypeDescription","Allows specifying a number within a given range."),I(Z,"Icon",j.RiHashtag),I(Z,"_validateMin",e=>(r,o)=>{const a=yr(o)?X(o,e):o;return typeof a.maximum=="number"&&typeof r=="number"&&a.maximum<r?"Minimum cannot be greater than minimum.":null}),I(Z,"_validateMax",e=>(r,o)=>{const a=yr(o)?X(o,e):o;return typeof a.minimum=="number"&&typeof r=="number"&&a.minimum>r?"Maximum cannot be less than minimum.":null});let oe=Z;const Qt=f.memo(t=>{const[{inputId:n,labelId:e,label:r,helpText:o,size:a,severity:s,showInputOnly:l,field:p,fieldProps:c},u]=_(t),[h,g]=f.useState(!1),y=c.value,w=f.useCallback(S=>{c.onChange({target:{value:S}}),g(!1)},[c]),m=f.useCallback(()=>{c.onChange({target:{value:""}})},[c]),C=f.useCallback(()=>{g(!0)},[]),E=f.useCallback(()=>{g(!1)},[]);return i.jsx(Y,{helpText:o,severity:s,children:i.jsxs(Q,{size:a,severity:s,inputId:n,labelId:e,label:r,image:l?void 0:p.image,className:"flex-col items-start justify-start gap-1",children:[i.jsx(zt,{open:h,onOpenChange:g,children:i.jsxs(Bt,{children:[i.jsx(_t,{className:"light:bg-(--black-a6) fixed inset-0 dark:bg-(--black-a8)"}),i.jsx($t,{className:"fixed inset-0",children:i.jsx(Yt,{onQrScan:w,onClose:E})})]})}),i.jsxs("div",{className:"flex w-max items-center gap-1",children:[i.jsxs(d.Button,{...u,variant:"soft",onClick:C,type:"button",size:"sm",accentColor:"base",children:[i.jsx(d.RiIcon,{icon:"RiQrCodeLine"}),"Scan"]}),y&&i.jsx("span",{className:"text-xs text-(--accent-a11)","data-accent-color":"primary",children:i.jsx(d.RiIcon,{icon:"RiCheckLine",style:{verticalAlign:"bottom"}})})]}),!!y&&i.jsx(d.Card,{children:i.jsxs("div",{className:"w-max items-center gap-2",children:[i.jsx("code",{className:"bg-(--base-a3)",children:y}),i.jsx(d.IconButton,{accentColor:"base",variant:"ghost","aria-label":"delete",size:"sm",onClick:m,children:i.jsx(d.RiIcon,{icon:"RiCloseLine"})})]})})]})})});Qt.displayName="QrInput";const Yt=f.memo(t=>{const{onQrScan:n,onClose:e}=t,r=f.useRef(null),[o,a]=f.useState(!1);return f.useEffect(()=>{if(!r.current)return;const s=new Wr(r.current,l=>{const p=l.data;n(p),s.destroy()},{highlightCodeOutline:!0,highlightScanRegion:!0,maxScansPerSecond:1});a(!0),s.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(d.IconButton,{"aria-label":"close",variant:"soft",accentColor:"base",onClick:e,children:i.jsx(d.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(d.Spinner,{})})]})]})});Yt.displayName="QrScanner";const Cr={...G,type:"qr"},xe=class xe extends k{constructor(e){super({...e,type:"qr"});I(this,"onlyValidateAfterTouched",!1)}serialize(){return super._serialize()}static deserialize(e){if(e.type!=="qr")throw new Error("Type mismatch.");return new xe(e)}getInput(e){return i.jsx(Qt,{...e,field:this})}};I(xe,"fieldTypeName","QR"),I(xe,"fieldTypeDescription","Used for scanning/reading QR codes."),I(xe,"Icon",j.RiQrCodeLine);let nt=xe;class br extends k{constructor(e){const{placeholder:r="",...o}=e;super(o);I(this,"options");I(this,"onlyValidateAfterTouched",!1);I(this,"placeholder");this.placeholder=r;const a=new Set;this.options=e.options.map(s=>(typeof s=="string"&&(s={label:s,value:s}),a.add(s.label),s)),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 Oe({label:"Options",description:"List possible options for the user to select from.",required:!0,identifier:`${r}options`,minimum_length:2}),showDirectly:!0}]}}const Mo=t=>t?Array.isArray(t)?t:[t]:[],Jt=f.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,fieldProps:l},p]=_(t),{onChange:c,onBlur:u}=l;let[{helpText:h,label:g}]=_(t);h=a?null:h,g=a?"":g;const y=f.useMemo(()=>Mo(l.value),[l.value]),w=f.useCallback(m=>{c(m),u(m)},[c,u]);return i.jsx(Y,{helpText:h,severity:o,children:i.jsx(Q,{size:r,severity:o,inputId:n,labelId:e,label:g,image:a?void 0:s.image,children:i.jsxs(d.Menu.Root,{children:[i.jsx(d.Menu.ClickTrigger,{children:i.jsxs(d.Button,{id:n,className:"!justify-between",name:l.name,variant:"surface",type:"button",size:"sm",accentColor:"base",...p,children:[y.length>0?y.join(", "):s.placeholder,i.jsx(d.RiIcon,{icon:"RiArrowDownSLine"})]})}),i.jsx(d.Menu.Content,{children:i.jsx(d.Menu.Scroll,{children:i.jsxs(d.Menu.MultiSelectGroup,{values:y,onValuesChange:w,children:[i.jsxs(d.Menu.SelectAllItem,{allValues:s.options.map(({value:m})=>m),children:[i.jsx(d.Menu.SelectAllIndicator,{children:m=>m?i.jsx(d.RiIcon,{icon:"RiSubtractLine"}):i.jsx(d.RiIcon,{icon:"RiCheckLine"})}),"Select all"]}),s.options.map(m=>i.jsxs(d.Menu.MultiSelectItem,{value:m.value,children:[i.jsx(d.Menu.SelectedIndicator,{children:i.jsx(d.RiIcon,{icon:"RiCheckLine"})}),m.label]},m.value))]})})})]})})})});Jt.displayName="MultiSelectInput";const wr={...G,type:"multi-select",options:[]},Ee=class Ee extends br{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 Ee(n)}getInput(n){return i.jsx(Jt,{field:this,...n})}};I(Ee,"fieldTypeName","Multi-select"),I(Ee,"fieldTypeDescription","Allows the user to select a multiple options from a list of options."),I(Ee,"Icon",j.RiCheckboxLine);let ze=Ee;const Zt=f.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,fieldProps:l},p]=_(t),{onChange:c,onBlur:u}=l;let[{helpText:h,label:g}]=_(t);h=a?null:h,g=a?"":g;const y=f.useCallback(m=>{c(m),u(m)},[c,u]),w=f.useMemo(()=>s.options.find(m=>m.value===l.value),[s.options,l.value]);return i.jsx(Y,{helpText:h,severity:o,children:i.jsx(Q,{size:r,severity:o,inputId:n,labelId:e,label:g,image:a?void 0:s.image,children:i.jsxs(d.Menu.Root,{children:[i.jsx(d.Menu.ClickTrigger,{children:i.jsxs(d.Button,{...l,className:"!justify-between",id:n,name:l.name,accentColor:"base",variant:"surface",type:"button",size:"sm",...p,children:[w?w.label:s.placeholder,i.jsx(d.RiIcon,{icon:"RiArrowDownSLine"})]})}),i.jsx(d.Menu.Content,{children:i.jsx(d.Menu.Scroll,{children:i.jsx(d.Menu.SelectGroup,{value:l.value,onValueChange:y,children:s.options.map(m=>i.jsxs(d.Menu.SelectItem,{value:m.value,children:[i.jsx(d.Menu.SelectedIndicator,{children:i.jsx(d.RiIcon,{icon:"RiCheckLine"})}),m.label]},m.value))})})})]})})})});Zt.displayName="SelectInput";const Ir={...G,type:"select",options:[]},Se=class Se extends br{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 Se(n)}getInput(n){return i.jsx(Zt,{field:this,...n})}};I(Se,"fieldTypeName","Dropdown"),I(Se,"fieldTypeDescription","Allows the user to select a single option from a list of options."),I(Se,"Icon",j.RiMenuFoldLine);let Be=Se;const xr=t=>"fields"in t;class rt extends k{constructor(e){const{minLength:r,maxLength:o,placeholder:a="",...s}=e;super(s);I(this,"minLength");I(this,"maxLength");I(this,"placeholder");this.minLength=r?Math.max(r,0):void 0,this.maxLength=o?Math.max(o,0):pe,this.placeholder=a}static getFieldCreationSchema(e=""){const r=e&&`${e}.`;return[{field:new oe({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 oe({label:"Maximum length",description:"Maximum number of characters",required:!1,identifier:`${r}maximum_length`,minimum:1,maximum:pe,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}}}I(rt,"_validateMin",e=>(r,o)=>{const a=xr(o)?X(o,e):o;return typeof a.maximum_length=="number"&&typeof r=="number"&&a.maximum_length<r?"Minimum cannot be greater than maximum.":null}),I(rt,"_validateMax",e=>(r,o)=>{if(typeof r!="number")return null;const{minimum_length:a}=xr(o)?X(o,e):o;return typeof a!="number"?null:a>r?"Maximum cannot be less than minimum.":null});const Rt=f.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,fieldProps:l},p]=_(t);let[{helpText:c,label:u}]=_(t);return c=a?null:c,u=a?"":u,i.jsx(Y,{helpText:c,severity:o,children:i.jsx(Q,{size:r,severity:o,inputId:n,labelId:e,label:u,image:a?void 0:s.image,children:i.jsx(d.Input.Root,{accentColor:"base",variant:"surface",size:"sm",children:i.jsx(d.Input.Field,{...p,...l,type:s.inputType,id:n,placeholder:s.placeholder})})})})});Rt.displayName="StringInput";const Er={...G,type:"string",maximum_length:$e,input_type:"text"},Fe=class Fe extends rt{constructor(e){const{inputType:r="text",...o}=e,a=e.maxLength?Math.min($e,e.maxLength):$e,s=e.minLength?Math.min(e.minLength,a):void 0;super({...o,maxLength:a,minLength:s,type:"string"});I(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,...s}=e;return new Fe({...s,maxLength:r,minLength:o,inputType:a,placeholder:"Enter a short description"})}getInput(e){return i.jsx(Rt,{field:this,...e})}};I(Fe,"fieldTypeName","Short Text"),I(Fe,"fieldTypeDescription",`Short text fields can hold up to ${$e} characters on a single line.`),I(Fe,"Icon",j.RiInputField);let it=Fe;const en=f.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,fieldProps:l},p]=_(t);let[{helpText:c,label:u}]=_(t);return c=a?null:c,u=a?"":u,i.jsx(Y,{helpText:c,severity:o,children:i.jsx(Q,{size:r,severity:o,inputId:n,labelId:e,label:u,image:a?void 0:s.image,children:i.jsx(d.TextArea,{...p,...l,className:"field-sizing-content",resize:"vertical",id:n,placeholder:s.placeholder,accentColor:"base",variant:"surface",size:"sm"})})})});en.displayName="TextInput";const Sr={...G,type:"text",maximum_length:pe},Ne=class Ne extends rt{constructor(n){const e=n.maxLength?Math.min(pe,n.maxLength):pe,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 Ne({...o,maxLength:e,minLength:r,placeholder:"Enter a description"})}getInput(n){return i.jsx(en,{field:this,...n})}};I(Ne,"fieldTypeName","Paragraph"),I(Ne,"fieldTypeDescription",`Paragraph fields can hold up to ${pe} characters and can have multiple lines.`),I(Ne,"Icon",j.RiAlignJustify);let ot=Ne;var at=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},st={exports:{}},Ao=st.exports,Fr;function Po(){return Fr||(Fr=1,function(t,n){(function(e,r){r()})(Ao,function(){function e(c,u){return typeof u>"u"?u={autoBom:!1}:typeof u!="object"&&(console.warn("Deprecated: Expected third argument to be a object"),u={autoBom:!u}),u.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,u,h){var g=new XMLHttpRequest;g.open("GET",c),g.responseType="blob",g.onload=function(){p(g.response,u,h)},g.onerror=function(){console.error("could not download file")},g.send()}function o(c){var u=new XMLHttpRequest;u.open("HEAD",c,!1);try{u.send()}catch{}return 200<=u.status&&299>=u.status}function a(c){try{c.dispatchEvent(new MouseEvent("click"))}catch{var u=document.createEvent("MouseEvents");u.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),c.dispatchEvent(u)}}var s=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof at=="object"&&at.global===at?at:void 0,l=s.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),p=s.saveAs||(typeof window!="object"||window!==s?function(){}:"download"in HTMLAnchorElement.prototype&&!l?function(c,u,h){var g=s.URL||s.webkitURL,y=document.createElement("a");u=u||c.name||"download",y.download=u,y.rel="noopener",typeof c=="string"?(y.href=c,y.origin===location.origin?a(y):o(y.href)?r(c,u,h):a(y,y.target="_blank")):(y.href=g.createObjectURL(c),setTimeout(function(){g.revokeObjectURL(y.href)},4e4),setTimeout(function(){a(y)},0))}:"msSaveOrOpenBlob"in navigator?function(c,u,h){if(u=u||c.name||"download",typeof c!="string")navigator.msSaveOrOpenBlob(e(c,h),u);else if(o(c))r(c,u,h);else{var g=document.createElement("a");g.href=c,g.target="_blank",setTimeout(function(){a(g)})}}:function(c,u,h,g){if(g=g||open("","_blank"),g&&(g.document.title=g.document.body.innerText="downloading..."),typeof c=="string")return r(c,u,h);var y=c.type==="application/octet-stream",w=/constructor/i.test(s.HTMLElement)||s.safari,m=/CriOS\/[\d]+/.test(navigator.userAgent);if((m||y&&w||l)&&typeof FileReader<"u"){var C=new FileReader;C.onloadend=function(){var N=C.result;N=m?N:N.replace(/^data:[^;]*;/,"data:attachment/file;"),g?g.location.href=N:location=N,g=null},C.readAsDataURL(c)}else{var E=s.URL||s.webkitURL,S=E.createObjectURL(c);g?g.location=S:location.href=S,g=null,setTimeout(function(){E.revokeObjectURL(S)},4e4)}});s.saveAs=p.saveAs=p,t.exports=p})}(st)),st.exports}var Oo=Po();const Nr=f.memo(f.forwardRef((t,n)=>{const{file:e,alt:r,error:o,rightSlot:a,className:s,truncateLength:l,...p}=t,c=f.useRef(null),u=f.useRef(null),h=d.useSize(c);f.useLayoutEffect(()=>{!u.current||!h||(u.current.style.height=`${h.height*4}px`)},[h]);const g=f.useMemo(()=>{if(e)return l!==void 0?H.truncate(e.name,l):e.name},[e,l]);return i.jsxs("div",{className:he(s,"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(d.Spinner,{})}),i.jsx("div",{ref:u,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:he("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(d.RiIcon,{icon:"RiFileWarningLine"}):e&&i.jsx(Ae,{fileType:e.type}),i.jsx(d.Text,{className:"truncate",size:"sm",children:o??g}),a]})]})})),zo=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)},Tr=f.memo(t=>{var F;const[{inputId:n,labelId:e,size:r,severity:o,helpText:a,showInputOnly:s,field:l,fieldProps:p},c]=_(t),{onChange:u}=p;let[{label:h}]=_(t);h=s?"":h;const g=o?ne[o]:void 0,y=f.useRef(null),{value:w}=p,m=f.useMemo(()=>s?null:a||(l.maxFileSize?`Maximum file size: ${l.maxFileSize}MB`:null),[l.maxFileSize,a,s]),C=f.useCallback(()=>{var L;(L=y.current)==null||L.click()},[]),E=f.useCallback(L=>{const T=[...w];T.splice(L,1),u({target:{files:T}})},[w,u]),S=w?"Select new files":"Select files",N=w?"Select new file":"Select a file",x=l.maxFiles>1?S:N;return i.jsxs("div",{className:"flex flex-col gap-2",children:[i.jsx(Y,{helpText:m,severity:o,children:i.jsxs(Q,{size:r,severity:o,inputId:n,labelId:e,label:h,image:s?void 0:l.image,children:[i.jsx("div",{className:"flex gap-2",children:i.jsxs(d.Button,{...c,className:"w-max",size:"sm",variant:"soft",accentColor:"base",onClick:C,id:"upload-input-upload-button",type:"button",children:[i.jsx(d.RiIcon,{icon:"RiUpload2Line"})," ",x]})}),i.jsx("input",{...c,type:"file",ref:y,id:n,accept:(F=l.extensions)==null?void 0:F.join(","),multiple:l.maxFiles>1,color:g,style:{display:"none"},...p,value:""})]})}),Array.isArray(w)&&w.length>0&&i.jsx("div",{className:"flex h-max flex-col gap-2",children:w.map((L,T)=>i.jsx(Lr,{field:l,file:L,onRemove:()=>{E(T)},disabled:c.disabled},T))})]})});Tr.displayName="UploadInput";const Lr=f.memo(t=>{const{file:n,field:e,onRemove:r,disabled:o}=t,[a,s]=f.useState(null),l=Ve(),p=f.useMemo(()=>a&&e.getError([a]),[e,a]),{url:c,name:u}=f.useMemo(()=>{let m=null,C,E;return a!=null&&a.type.startsWith("image/")&&(m=URL.createObjectURL(a)),a?(C=a.name,E=zo(a.size)):(C="Downloading...",E="..."),{url:m,name:C,size:E}},[a]);f.useEffect(()=>{n instanceof Promise?n.then(s).catch(console.error):s(n)},[n]);const h=f.useCallback(m=>{if(m.stopPropagation(),!a)throw new Error("Cannot download a file that is not resolved.");const C=new Blob([a]);Oo.saveAs(C,u)},[u,a]),g=f.useCallback(m=>{m.stopPropagation(),r()},[r]),y=f.useCallback(()=>{a&&l(m=>({file:a,onDelete:o?void 0:()=>{r(),m()}}))},[o,r,l,a]),w=f.useMemo(()=>i.jsxs(d.ButtonGroup,{className:"flex grow justify-end",variant:"ghost",accentColor:"base",size:"sm",children:[i.jsx(d.IconButton,{"aria-label":`Download ${u}`,onClick:h,disabled:!a,children:i.jsx(d.RiIcon,{icon:"RiDownload2Line"})}),!o&&i.jsx(d.IconButton,{"aria-label":`Remove ${u}`,disabled:o,onClick:g,children:i.jsx(d.RiIcon,{icon:"RiDeleteBin7Fill"})})]}),[o,g,h,u,a]);return c?i.jsx(Nr,{className:"cursor-pointer",onClick:y,file:a,error:p??void 0,rightSlot:w}):i.jsx(vt,{file:a,error:p??void 0,rightSlot:w})});Lr.displayName="DisplayFile";const Bo={...G,type:"upload",extensions:[],maximum_size:void 0,maximum_files:1},Te=class Te extends k{constructor(e){const{extensions:r,maximum_files:o,maximum_size:a,...s}=e;super({...s,type:"upload"});I(this,"extensions");I(this,"maxFileSize");I(this,"maxFiles");I(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 oe({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 oe({label:"What is the maximum size of each file?",description:`Maximum file size in megabytes (between 1MB–${lt}MB).`,required:!1,identifier:`${r}maximum_size`,minimum:1,maximum:lt,integers:!0}),showDirectly:!1},{field:new ze({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??lt,o=r*1e3*1e3,a=this.maxFiles||1;return e.push(s=>{if(s&&s.some(l=>l.size>o))return`Files must be at most ${r}MB.`}),e.push(s=>{if(s&&s.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 Te(e)}getInput(e){return i.jsx(Tr,{field:this,...e})}};I(Te,"fieldTypeName","Upload"),I(Te,"fieldTypeDescription","Allows a file to be uploaded."),I(Te,"Icon",j.RiUpload2Line);let tn=Te;const nn={date:Je,number:oe,boolean:Ce,select:Be,string:it,text:ot,custom:Ze,upload:tn,qr:nt,"multi-string":Oe,"multi-select":ze},_o={date:ur,number:vr,boolean:dr,select:Ir,string:Er,text:Sr,custom:No,upload:Bo,qr:Cr,"multi-string":gr,"multi-select":wr},lt=50,$o=lt*1e3*1e3,rn=t=>{const n=t.type;return nn[n].deserialize(t)},ct=t=>t.type==="section"?W.deserialize(t):rn(t);function Dr(t,n={}){const{readonly:e=!1}=n;return{title:t.title,description:t.description,fields:t.fields.map(r=>ct(r)),meta:{readonly:e}}}function on(t){const n=[];for(const e of t.fields)if(e instanceof W)for(const r of e.fields)n.push(r);else{if(!(e instanceof k))throw new Error(`Invalid field type: ${e.type}`);n.push(e)}return n}function Vo(t,n){const e=on(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 Uo(t,n){const e=on(t),r={};for(const o of e){const a=n[o.identifier];r[o.identifier]=o.encodeValueToJson(a)}return r}function dt(t){return Array.isArray(t)&&t.some(n=>n instanceof File||n instanceof Promise)}function an(t,n){if(!t)return!0;if(dt(n)||dt(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 Mr=f.memo(t=>{const{field:n,...e}=t,{label:r,description:o,fields:a,condition:s}=n,{values:l,setFieldValue:p}=U.useFormikContext(),c=s!=null&&s.identifier?X(l,s.identifier):void 0,u=f.useMemo(()=>c===void 0||an(s,c),[s,c]);f.useEffect(()=>{if(!u)for(const g of a)p(g.getId(),"").then()},[u,a,p]);const h=Pe(a,e);return u?i.jsx(d.Card,{children:i.jsxs("div",{className:"flex flex-col gap-4",children:[(r||o)&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex flex-col",children:[i.jsx(d.Heading,{size:"lg",children:r}),i.jsx(d.Text,{accentColor:"base",children:o})]}),i.jsx(d.Separator,{size:"full"})]}),h]})}):null});Mr.displayName="FieldSectionLayout";const Le=class Le extends yt{constructor(e){const{label:r=null,fields:o,condition:a=null,conditional:s,...l}=e;super({...l,type:"section"});I(this,"label");I(this,"fields");I(this,"condition");this.fields=o,this.condition=a,this.label=r,s===!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 Le({label:"Conditional settings",identifier:`${o}conditional-settings`,condition:{identifier:`${o}conditional`,value:!0},fields:[new Be({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 To({label:"Value",identifier:`${o}condition.value`,required:!0,clonedFieldIdentifier:`${o}condition.identifier`,getFieldToClone(a){if(!a)return null;const s=e.find(l=>l.identifier===a);return s?{...s,label:"Value",identifier:`${o}condition.value`,description:"The value to compare against.",required:s.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(rn);return new Le({...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(),s=o.getError(X(e,a),e);s&&mt(r,o.getId(),s)}return r}getInput(e){return i.jsx(Mr,{field:this,...e})}};I(Le,"fieldTypeName","Section"),I(Le,"fieldTypeDescription","Sections can be useful for grouping fields together. They can also be conditionally shown or hidden.");let W=Le;const de=t=>Object.keys(t).length>0,ut=(t,n)=>{const e={};for(const r of t.fields)if(r instanceof W){if(r.condition){const{identifier:o}=r.condition;if(!an(r.condition,X(n,o)))continue}Object.assign(e,r.getErrors(n))}else{if(!(r instanceof k))throw new Error("Invalid field type");const o=r.getId(),a=r.getError(X(n,o),n);a&&mt(e,o,a)}if(de(e))return e},jo=[null,void 0],ft=(t,n)=>t.reduce((e,r)=>r instanceof W?{...e,...ft(r.fields,n)}:(jo.includes(X(e,r.getId()))&&mt(e,r.getId(),""),e),qr(n)),ko=()=>{throw new Error("onSubmit must be provided if form is not readonly.")},Ar=f.memo(f.forwardRef((t,n)=>{const{schema:e,values:r={},onSubmit:o=ko,submitText:a="Submit",cancelText:s,onCancel:l,onDirty:p,onDirtyChange:c,hideTitle:u=!e.title,hideDescription:h,className:g,buttonProps:y}=t,{readonly:w}=e.meta,m=f.useMemo(()=>crypto.randomUUID(),[]),C=U.useFormik({initialValues:ft(e.fields,r),onSubmit:o,validate:F=>ut(e,F),validateOnBlur:!1,validateOnChange:!1}),{dirty:E}=C,S=f.useMemo(()=>typeof e.title=="string"?i.jsx(d.Heading,{size:"md",children:e.title}):e.title,[e.title]),N=f.useMemo(()=>typeof e.description=="string"?i.jsx(d.Text,{accentColor:"base",children:e.description}):e.description,[e.description]),x=Pe(e.fields,{formId:m,disabled:w});return f.useEffect(()=>{E&&p&&p(),c&&c(E)},[E,p,c]),i.jsx(U.FormikProvider,{value:C,children:i.jsxs("form",{id:m,ref:n,className:he(g,"flex flex-col gap-2"),onSubmit:C.handleSubmit,children:[!u&&i.jsx(d.Card,{children:i.jsxs("div",{className:"flex flex-col gap-1",children:[S,!h&&N]})}),x,!w&&i.jsxs("div",{className:"flex items-center justify-end gap-2",children:[s&&i.jsxs(d.Button,{accentColor:ne.danger,...y,type:"button",onClick:l,children:[i.jsx(d.RiIcon,{icon:"RiCloseLine"}),s]}),i.jsxs(d.Button,{...y,type:"submit",disabled:!C.isValid,accentColor:"success",children:[i.jsx(d.RiIcon,{icon:"RiCheckLine"}),a]})]})]})})})),ue=f.memo(t=>{const{name:n,render:e}=t,{submitForm:r}=U.useFormikContext(),[o,a,s]=U.useField(n),l=f.useMemo(()=>{const p=c=>{s.setValue(c,!1)};return e({value:o.value,meta:a,setValue:p,patchValue:()=>{r()}})},[e,o.value,a,r,s]);return i.jsx(i.Fragment,{children:l})});ue.displayName="PatchField";const Wo=f.memo(f.forwardRef((t,n)=>{const{children:e,schema:r,values:o,onPatch:a,onError:s,requiresDiff:l=!0,onDirtyChange:p,...c}=t,u=f.useMemo(()=>ft(r.fields,o),[r.fields,o]),h=f.useCallback(S=>{const N={};for(const x in S){const F=S[x];F!==u[x]&&F!==void 0&&(N[x]=F)}return N},[u]),g=f.useCallback(S=>{const N=h(S);l&&!de(N)||a(N)},[h,a,l]),y=f.useCallback(S=>{const N=ut(r,S);if(N&&s(N),p){const x=h(S);p(de(x))}return N},[r,p,s,h]),w=U.useFormik({initialValues:u,onSubmit:g,validate:y,validateOnBlur:!1,validateOnChange:!1}),m=f.useCallback(()=>{if(p){const S=h(w.values);de(S)&&p(!0)}},[w.values,h,p]),{errors:C,resetForm:E}=w;return f.useEffect(()=>{de(C)&&E({values:u,errors:{}})},[C,u,E]),i.jsx(U.FormikProvider,{value:w,children:i.jsx("form",{...c,ref:n,onSubmit:w.handleSubmit,onChange:m,children:e})})})),ht="form-builder",qo=[["string","text"],["select","multi-select","upload","qr"],["boolean","date","number","multi-string"]],sn={...nn,section:W},Ho=(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}},Go=(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}}},Pr=t=>{var e,r,o;const n={};for(let a=0;a<t.length;a++){const s=t[a];if(!s)throw new Error("Field is undefined.");const l=a>0?(e=n[t[a-1].identifier])==null?void 0:e.conditionFields:void 0,p=new Set(l);(r=s.condition)!=null&&r.identifier&&p.add(s.condition.identifier),n[s.identifier]={disabled:!1,conditionFields:p,conditionIndex:Go(t,(o=s.condition)==null?void 0:o.identifier),index:a,label:s.label}}return n},ln=f.memo(t=>{const{index:n,type:e,sectionIndex:r,remove:o,duplicate:a,move:s,upload:l}=t;if(e!=="section"&&!l)throw new Error("Upload function prop must be defined for non-section fields.");const{values:p}=U.useFormikContext(),c=f.useRef(null),u=f.useMemo(()=>{const h=[{Icon:j.RiFileCopyLine,key:"duplicate",text:"Duplicate",buttonProps:{onClick:a}}];return h.push({Icon:j.RiDeleteBin7Fill,key:"delete",text:"Delete",buttonProps:{onClick:o}}),e!=="section"&&h.unshift({Icon:j.RiImageLine,key:"upload",text:"Upload image",buttonProps:{onClick:()=>{var g;(g=c.current)==null||g.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:j.RiArrowDownLine,key:"moveDown",text:"Move down",buttonProps:{onClick:()=>{s("down")}}}),(r===void 0&&n!==0||r!==void 0&&(r!==0||n!==0))&&h.unshift({Icon:j.RiArrowUpLine,key:"moveUp",text:"Move up",buttonProps:{onClick:()=>{s("up")}}}),h},[a,n,s,o,r,e,p.fields]);return i.jsxs(i.Fragment,{children:[i.jsx(d.ButtonGroup,{className:"mx-2 hidden flex-col gap-0.5 sm:flex",variant:"ghost",accentColor:"base",size:"sm",children:u.map(h=>i.jsx(d.IconButton,{type:"button","aria-label":h.text,...h.buttonProps,children:i.jsx(h.Icon,{})},h.key))}),i.jsx("div",{className:"sm:hidden",children:i.jsxs(d.Menu.Root,{children:[i.jsx(d.Menu.ClickTrigger,{children:i.jsx(d.IconButton,{variant:"ghost",accentColor:"base","aria-label":"Actions menu",size:"sm",children:i.jsx(d.RiIcon,{icon:"RiMore2Line"})})}),i.jsx(d.Menu.Content,{children:u.map(h=>{var g;return i.jsxs(d.Menu.Item,{onClick:(g=h.buttonProps)==null?void 0:g.onClick,children:[i.jsx(h.Icon,{}),h.text]},h.key)})})]})}),e!=="section"&&i.jsx("input",{style:{display:"none"},ref:c,type:"file",accept:"image/*",onChange:l})]})});ln.displayName="FieldActions";const Or=(t=()=>null)=>f.useMemo(()=>qo.map(n=>n.map(e=>{const r=nn[e],o=r.Icon;return{children:r.fieldTypeName,icon:i.jsx(o,{}),value:e,onSelect:()=>{t(e)}}})),[t]),fe=t=>t.type==="section",cn=f.memo(t=>{const{popoverInputs:n,hasError:e}=t;return i.jsxs(d.Popover.Root,{children:[i.jsx(d.Popover.Trigger,{asChild:!0,children:i.jsxs(d.Button,{variant:"soft",type:"button",size:"sm","aria-label":"settings",accentColor:"base",...e&&{color:ne.danger},children:[i.jsx(d.RiIcon,{icon:"RiSettings2Line"}),i.jsx("span",{children:"Settings"})]},"settings")}),i.jsx(d.Popover.Content,{size:"sm",children:i.jsx("div",{className:"flex max-w-[240px] flex-col",children:n})})]})});cn.displayName="FieldSettingsPopover";const dn=f.memo(t=>{var pt,fn,Ur,jr,kr;const{parentPath:n,index:e,initial:r,conditionalSourceFields:o}=t,{values:a,setFieldValue:s,errors:l}=U.useFormikContext(),p=Or(),c=Ve(),u=f.useRef(null),h=576,[g,y]=f.useState(u.current&&u.current.getBoundingClientRect().width>=h);f.useEffect(()=>{const M=u.current;if(M){const P=new ResizeObserver(q=>{q[0]&&y(q[0].contentRect.width>=h)});return P.observe(M),()=>{P.disconnect()}}},[]);const[w,m]=f.useState(void 0);f.useEffect(()=>{fe(r)?m(void 0):r.image instanceof Promise?r.image.then(m).catch(console.error):m(r.image)},[r]);const C=w?URL.createObjectURL(w):void 0,E=f.useCallback(M=>{M.stopPropagation();const{image:P,...q}=r;s(`${n}.${e}`,q).then()},[e,r,n,s]);f.useEffect(()=>{fe(r)&&!r.conditional&&s(`${n}.${e}.condition`,null).then()},[e,r,n,s]);const S=f.useMemo(()=>{var M,P;return fe(r)?(P=pr(a.fields,(M=r.condition)==null?void 0:M.identifier))==null?void 0:P.label:void 0},[r,a.fields]),N=fe(r)?Array.isArray((pt=r.condition)==null?void 0:pt.value)?"contains all of":"equals":void 0;let x;if(fe(r)){if(dt((fn=r.condition)==null?void 0:fn.value))throw new Error("File values are not supported for conditions.");x=Array.isArray((Ur=r.condition)==null?void 0:Ur.value)?r.condition.value.map(M=>typeof M=="string"?M:M.label).join(", "):(kr=(jr=r.condition)==null?void 0:jr.value)==null?void 0:kr.toString()}const F=f.useCallback(M=>{M.target.parentNode instanceof HTMLElement&&(M.target.parentNode.dataset.replicatedValue=M.target.value)},[]),L=f.useCallback(M=>{M.target.parentNode instanceof HTMLElement&&(M.target.parentNode.dataset.replicatedValue=M.target.value)},[]),T=r.type,D=sn[T],[$,z]=f.useMemo(()=>{let M=[],P=[];if(D===W){if(o===void 0)throw new Error("Conditional source fields must be provided when changing sections.");const q=D.getFieldCreationSchema(o,`${n}.${e}`);M=M.concat(q.filter(V=>V.showDirectly).map(V=>V.field)),P=P.concat(q.filter(V=>!V.showDirectly).map(V=>V.field))}else{if(!(D.prototype instanceof k))throw new Error(`Field must be an instance of BaseField. Got ${D.toString()}.`);const q=D.getFieldCreationSchema(`${n}.${e}`);g?(M=[...M,...q.filter(V=>V.showDirectly).map(V=>V.field)],P=[...P,...q.filter(V=>!V.showDirectly).map(V=>V.field)]):P=[...P,...q.map(V=>V.field)]}return[M,P]},[D,o,n,e,g]),A=Pe($,{formId:ht,disabled:!1,internal:!0,...D===W&&{size:"sm"}}),B=Pe(z,{formId:ht,disabled:!1});let O=z.length>0;fe(r)&&z.length>0&&(O=r.conditional);const R=z.some(M=>{const P=X(l,D===W?`${n}.${e}.condition`:M.getId());return P&&(typeof P!="object"||de(P))}),De=R?ne.danger:void 0,_e=f.useMemo(()=>ct(r),[r]),un=Wt(_e,{formId:ht,showInputOnly:!1}),ae=f.useMemo(()=>p.flat().find(M=>M.value===T),[p,T]),Me=f.useCallback(()=>{w&&c(()=>({file:w}))},[c,w]);return i.jsx("div",{className:"flex grow items-center w-full",ref:u,children:i.jsxs("div",{className:"flex w-full flex-col gap-2",children:[D===W&&($.length>0||O)&&i.jsxs("div",{className:"flex flex-col gap-2",children:[A,O&&i.jsxs("div",{className:"flex items-center gap-4",children:[i.jsx(cn,{popoverInputs:B,hasError:R}),fe(r)&&r.conditional&&i.jsx("span",{className:"text-sm text-(--accent-a11)","data-accent-color":De,children:i.jsxs("em",{children:["Display only if ",i.jsx("strong",{children:S})," ",N," ",i.jsx("strong",{children:x})]})})]})]}),D!==W&&i.jsxs("div",{className:"flex gap-2 w-full justify-between",children:[i.jsxs("div",{className:"flex gap-2 items-center",children:[i.jsxs(d.Badge,{accentColor:"base",variant:"soft",size:"sm",children:[ae==null?void 0:ae.icon,ae==null?void 0:ae.children]}),i.jsx(ue,{name:`${n}.${e}.required`,render:({setValue:M,value:P})=>i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(d.Checkbox.Root,{checked:P,onCheckedChange:M,size:"sm",children:i.jsx(d.Checkbox.Indicator,{children:i.jsx(d.RiIcon,{icon:"RiCheckLine"})})}),i.jsx(d.Text,{size:"sm",accentColor:"base",children:"Required"})]})})]}),O&&i.jsx(cn,{popoverInputs:B,hasError:R})]}),w&&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:C,alt:w.name,onClick:Me}),i.jsx(d.IconButton,{className:"absolute top-2 right-2 hidden group-hover:not-disabled:flex",variant:"solid",accentColor:"base","aria-label":"delete",onClick:E,size:"sm",children:i.jsx(d.RiIcon,{icon:"RiDeleteBin7Fill"})})]}),i.jsx(ue,{name:`${n}.${e}.label`,render:({setValue:M,value:P})=>i.jsx("input",{className:"bg-transparent outline-none text-sm",placeholder:T==="section"?"Enter a section label (optional)":"Enter your question",value:P,onChange:q=>{M(q.target.value)},onInput:F,maxLength:200})}),i.jsx(ue,{name:`${n}.${e}.description`,render:({setValue:M,value:P})=>i.jsx("textarea",{className:"bg-transparent outline-none text-sm field-sizing-content grow",placeholder:`Enter a ${T==="section"?"section":"field"} description (optional)`,value:P,onChange:q=>{M(q.target.value)},onInput:L,maxLength:1e3})}),D!==W&&$.length>0&&i.jsx("div",{className:"w-full",children:A}),D!==W&&i.jsxs(d.Card,{className:"flex gap-4 bg-(--accent-a2) items-center",children:[i.jsxs(d.HoverCard.Root,{children:[i.jsx(d.HoverCard.Trigger,{asChild:!0,children:i.jsx(d.Badge,{icon:!0,size:"sm",variant:"soft",accentColor:"base",children:i.jsx(d.RiIcon,{icon:"RiEyeLine"})})}),i.jsx(d.HoverCard.Content,{className:"w-[225px]",size:"sm",align:"start",children:"This is a preview of the field as it will be rendered in the form."})]}),i.jsx("div",{className:"grow",children:un})]})]})})});dn.displayName="FieldBuilder";const zr=f.memo(t=>{const{field:n,index:e,sectionIndex:r,remove:o}=t,{setFieldValue:a,values:s}=U.useFormikContext(),{reorderField:l}=Gt(),{showError:p}=d.useToast(),c=`fields.${r}.fields`,u=f.useMemo(()=>({index:e,parentPath:c,initial:n}),[n,e,c]),h=f.useCallback(()=>{const w=n.label??"Unlabelled field",m={...n,label:w};tt(c,e+1,m,s,a)},[n,c,e,s,a]),g=f.useCallback(w=>{const m=r,C=s.fields[m];let E=r,S=w==="up"?e-1:e+1;w==="up"&&e===0?(E=r-1,S=s.fields[E].fields.length):w==="down"&&e===C.fields.length-1&&(E=r+1,S=0);const N=s.fields[E];l(C,m,e,N,E,S,a)},[r,s.fields,e,l,a]),y=f.useCallback(w=>{const{files:m}=w.target;if(!m||m.length!==1)return;const C=m.item(0);if(C){if(C.size>$o){p({title:"File upload error",description:`The file ${C.name} exceeded the maximum file size`});return}a(`${c}.${e}`,{...n,image:C}).then()}},[n,e,c,a,p]);return i.jsx(te.Draggable,{draggableId:n.identifier,index:e,children:w=>i.jsx(d.Card,{ref:w.innerRef,...w.draggableProps,...w.dragHandleProps,className:"mb-4",children:i.jsxs("div",{className:"flex items-center justify-between gap-4 w-full",children:[i.jsx(dn,{...u}),i.jsx(ln,{index:e,type:n.type,sectionIndex:r,remove:o,duplicate:h,move:g,upload:y})]})})})});zr.displayName="FieldWithActions";const Br=f.memo(t=>{var N;const{field:n,index:e,dropState:r,fieldsOnly:o}=t,a=(N=r[n.identifier])==null?void 0:N.disabled,{setFieldValue:s,values:l}=U.useFormikContext(),p=d.useAlertDialog(),{reorderSection:c}=Gt(),u=f.useCallback((x,F)=>{for(const L of x){const T=F.indexOf(L);s(`fields.${T}.condition`,null).then(),s(`fields.${T}.conditional`,!1).then()}},[s]),h=f.useCallback(x=>{var T;const F=n.fields[x];if(!F)throw new Error("Could not find field to remove.");const L=[];for(const D of l.fields)((T=D.condition)==null?void 0:T.identifier)===F.identifier&&L.push(D);return{removing:F,affectedSections:L,action:()=>s(`fields.${e}.fields`,et(n.fields,x))}},[n.fields,l.fields,s,e]),g=f.useCallback(x=>{const{affectedSections:F,action:L,removing:T}=h(x),D=()=>{L().then(),u(F,l.fields)};if(F.length>0){const $=F.map(z=>z.label).join(", ");p({title:"Remove condition?",description:`${T.label} is being used as a condition, deleting it will remove the condition from the ${$} section(s).`,action:"Remove",onAction:D});return}D()},[h,u,l.fields,p]),y=f.useCallback(()=>{const F=n.fields.map((B,O)=>h(O)).flatMap(B=>B.affectedSections),L=F.length?"Remove fields and conditions?":"Remove fields?",T=n.fields.length,D=F.map(B=>B.label).join(", "),$=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.`,z=et(l.fields,e),A=()=>s("fields",z);if(F.length>0){p({title:L,description:$,action:"Remove",onAction:()=>{A().then(()=>{u(F,z)})}});return}A().then()},[n.fields,l.fields,e,h,s,p,u]),w=f.useCallback(x=>{const F=x==="up"?e-1:e+1;c(r,n.identifier,e,F,l,s)},[e,c,r,n.identifier,l,s]),m=f.useMemo(()=>({index:e,parentPath:"fields",initial:n,conditionalSourceFields:mr(l.fields,e)}),[n,e,l.fields]),C=f.useCallback(()=>{const x=n.label??"Untitled section",F=n.fields.map(T=>({...T,identifier:Ht(null,T.label)})),L={...n,label:x,fields:F};tt("fields",e+1,L,l,s)},[n,e,l,s]),E=f.useCallback(x=>{tt(`fields.${e}.fields`,n.fields.length,_o[x],l,s)},[e,n.fields.length,l,s]),S=Or(E);return i.jsx(te.Draggable,{draggableId:n.identifier,index:e,children:x=>i.jsx(d.Card,{ref:x.innerRef,...x.draggableProps,...x.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(dn,{...m}),i.jsx(te.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(zr,{field:L,index:T,sectionIndex:e,remove:()=>{g(T)}},L.identifier)),F.placeholder,i.jsxs(d.Menu.Root,{children:[i.jsx(d.Menu.ClickTrigger,{children:i.jsxs(d.Button,{type:"button",variant:"soft",children:[i.jsx(d.RiIcon,{icon:"RiAddLine"})," Add field"]})}),i.jsx(d.Menu.Content,{children:S.flat().map(L=>i.jsxs(d.Menu.Item,{onSelect:L.onSelect,children:[L.icon,L.children]},L.value))})]})]})})]}),!o&&i.jsx(ln,{index:e,type:n.type,remove:y,duplicate:C,move:w})]})})})});Br.displayName="FieldSectionWithActions";const _r=(t,n)=>{for(const[e,r]of Object.entries(t))if(r.identifier===n)return[r,e]},$r=f.memo(t=>{const{fieldsOnly:n}=t,{values:e,setFieldValue:r}=U.useFormikContext(),[o,a]=f.useReducer(Ho,e.fields,Pr),{reorderSection:s,reorderField:l}=Gt();f.useEffect(()=>{a({type:"update",state:Pr(e.fields)})},[a,e.fields]);const p=f.useCallback(h=>{h.type==="SECTION"&&a({type:"hold",fieldId:h.draggableId})},[]),c=f.useCallback(h=>{const{source:g,destination:y,type:w,reason:m,draggableId:C}=h;if(a({type:"release"}),!y||m==="CANCEL")return;if(w==="ROOT"){s(o,C,g.index,y.index,e,r);return}if(w!=="SECTION")throw new Error("Unexpected droppable type.");const[E,S]=_r(e.fields,g.droppableId)??[],[N,x]=_r(e.fields,y.droppableId)??[];l(E,S,g.index,N,x,y.index,r)},[e,l,r,s,o]),u=f.useCallback(h=>{Do(h+1,e,r)},[e,r]);return i.jsx(te.DragDropContext,{onDragStart:p,onDragEnd:c,children:i.jsx(te.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((g,y)=>i.jsxs(f.Fragment,{children:[i.jsx(Br,{field:g,index:y,dropState:o,fieldsOnly:n}),!n&&y!==e.fields.length-1&&i.jsxs(d.Button,{className:"mb-4",type:"button",variant:"soft",accentColor:"base",onClick:()=>{u(y)},children:[i.jsx(d.RiIcon,{icon:"RiAddLine"})," Add section"]})]},g.identifier)),i.jsxs(d.Button,{className:"mb-4",type:"button",variant:"soft",accentColor:"base",onClick:()=>{u(e.fields.length)},children:[i.jsx(d.RiIcon,{icon:"RiAddLine"})," Add section"]}),h.placeholder]})})})});$r.displayName="FieldsEditor";const Xo=()=>{alert("This is a form preview, your data will not be saved.")},Ko=f.memo(f.forwardRef((t,n)=>{const{onCancel:e,onSave:r,revision:o,initialTitle:a,showExplainerText:s=!0,showFormTitle:l=!0,fieldsOnly:p=!1,showTabs:c=!0,tabsListClassName:u,hydrateRevisionWithImages:h}=t,{showError:g}=d.useToast(),y=f.useCallback(S=>{const N={};S.title||(N.title="Title is required."),(!S.fields||S.fields.length===0)&&(N.fields="At least one field is required.");let x=[];for(const[L,T]of S.fields.entries()){const $=sn.section.getFieldCreationSchema(mr(S.fields,L),`fields.${L}`).map(z=>z.field);x=[...x,...$];for(const[z,A]of T.fields.entries()){const O=sn[A.type].getFieldCreationSchema(`fields.${L}.fields.${z}`).map(R=>R.field);x=[...x,...O]}}const F=ut({fields:x},S);if(F&&(N.fields=F.fields),de(N))return g({title:"Some form settings are invalid",description:"Please check settings highlighted in red."}),N},[g]),w=f.useMemo(()=>({title:a??"",description:"",fields:[{...Re(Ht(null,"")),label:""}]}),[a]),m=o?h(o):void 0,C=U.useFormik({initialValues:Lo(m)??w,validate:y,onSubmit:r,validateOnChange:!1,validateOnBlur:!1}),E=f.useMemo(()=>Dr(C.values),[C.values]);return i.jsx(d.Tabs.Root,{ref:n,defaultValue:"edit",children:i.jsxs("div",{className:"flex flex-col gap-2",children:[c&&i.jsxs(d.Tabs.List,{className:he("sticky top-0 z-[2000] flex bg-(--color-background)",u),children:[i.jsx(d.Tabs.Trigger,{className:"grow",value:"edit",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(d.RiIcon,{icon:"RiPencilLine"}),"Edit form"]})}),i.jsx(d.Tabs.Trigger,{className:"grow",value:"preview",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(d.RiIcon,{icon:"RiEyeLine"}),"Preview form"]})})]}),i.jsxs(d.Tabs.Content,{value:"edit",children:[s&&i.jsxs(d.Text,{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:ht,onSubmit:C.handleSubmit,children:[i.jsxs(U.FormikProvider,{value:C,children:[l&&i.jsxs(i.Fragment,{children:[i.jsx(ue,{name:"title",render:({setValue:S,value:N,meta:x})=>i.jsx(Ut,{severity:"danger",helpText:x.error??null,children:i.jsx(d.Input.Root,{variant:"outline",size:"md",accentColor:x.error?ne.danger:"primary",children:i.jsx(d.Input.Field,{placeholder:"Form title",value:N,onChange:F=>{S(F.target.value)},maxLength:100})})})}),i.jsx(ue,{name:"description",render:({setValue:S,value:N})=>i.jsx(d.TextArea,{className:"field-sizing-content",placeholder:"Explain the purpose of this form",value:N,onChange:x=>{S(x.target.value)},resize:"vertical",maxLength:1e3,size:"md"})})]}),i.jsx($r,{fieldsOnly:p}),i.jsx("span",{"data-accent-color":ne.danger,className:"text-xs text-(--accent-a11)",children:typeof C.errors.fields=="string"&&C.errors.fields})]}),i.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e&&i.jsx(d.Button,{type:"button",variant:"solid",accentColor:"base",onClick:e,children:"Cancel"}),i.jsx(d.Button,{type:"submit",children:"Save form"})]})]})]}),i.jsx(d.Tabs.Content,{value:"preview",children:i.jsx(Ar,{schema:E,onSubmit:Xo,hideTitle:!l})})]})})})),Qo=Object.values(H.Colors),Yo=1;async function Jo(t,n,e,r){const o=t.getContext("2d",{}),a=new Image(r.width,r.height),s=new Image(r.width,r.height),l=new H.DeferredPromise;return a.onload=function(){o.drawImage(a,0,0,r.width,r.height),s.src=URL.createObjectURL(e),s.onload=async function(){o.drawImage(s,0,0,r.width,r.height);const p=t.toDataURL("image/jpeg",Yo),c=await H.fileToBlob(p),u=new File([c],n.name,{type:"image/jpeg"});l.resolve(u)}},a.src=URL.createObjectURL(n),l}const Vr=f.memo(t=>{const{file:n,onClose:e,onSave:r,onDelete:o,dirty:a,onDirty:s}=t;n.objectURL||(n.objectURL=URL.createObjectURL(n));const l=f.useRef(null),p=f.useRef(null),[c,u]=f.useState(H.Colors.red),[h,g]=f.useState(null),[y,w]=f.useState(!1),[m,C]=f.useState(!1),E=f.useRef(null),S=d.useSize(E);f.useEffect(()=>{const O=new Image;O.onload=function(){g({width:O.naturalWidth,height:O.naturalHeight})},O.src=URL.createObjectURL(n)},[n]),f.useEffect(()=>{!m&&(S!=null&&S.width)&&S.height&&C(!0)},[S,m]);const N=f.useCallback(async()=>{a||e();const O=l.current;if(!O)return;if(!h)throw new Error("Original image size not loaded yet");const R=await O.exportImage("png"),De=new Image(h.width,h.height);De.onload=async function(){const _e=await H.fileToBlob(R),un=new File([_e],n.name,{type:n.type}),ae=p.current,Me=await Jo(ae,n,un,h);Me.objectURL=URL.createObjectURL(Me);const pt=await H.hashFile(n);await H.hashFile(Me)!==pt&&r(Me),w(!1),e()},w(!0),De.src=R},[a,n,e,r,h]),x=f.useCallback(()=>{o(n)},[n,o]),F=f.useCallback(()=>{e()},[e]),L=f.useCallback(()=>{s(!0)},[s]),T=f.useCallback(()=>{l.current&&l.current.redo()},[]),D=f.useCallback(()=>{l.current&&l.current.undo()},[]),$=f.useCallback(()=>{l.current&&(s(!1),l.current.clearCanvas())},[s]),z=f.useCallback(O=>{l.current&&l.current.eraseMode(O)},[]),A=f.useCallback(()=>{N()},[N]),B=f.useCallback(()=>{H.downloadFile(n)},[n]);return i.jsx(zt,{open:!0,onOpenChange:e,children:i.jsxs(Bt,{children:[i.jsx(_t,{className:"bg-(--color-background) fixed inset-0 data-[state='open']:fade-in-0 data-[state='open']:zoom-in-95 data-[state='closed']:animate-out data-[state='closed']:fade-out-0 data-[state='closed']:zoom-out-95 data-[state='open']:animate-in","data-floating-content":""}),i.jsxs($t,{className:"absolute inset-0 py-12","data-floating-content":"",children:[i.jsx(d.ButtonGroup,{className:"flex w-full gap-2 items-center top-0 absolute right-0 p-2",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(d.IconButton,{"aria-label":"close",onClick:F,children:i.jsx(d.RiIcon,{icon:"RiCloseLine"})}),i.jsx(d.IconButton,{"aria-label":`Download ${n.name}`,onClick:B,children:i.jsx(d.RiIcon,{icon:"RiDownload2Line"})})]}),i.jsxs("div",{className:"flex items-center justify-center gap-2",children:[i.jsx(gt,{selectedColor:c,allColors:Qo,onFinish:u,trigger:i.jsx(d.IconButton,{"aria-label":"Markup color picker",type:"button",variant:"solid",style:{backgroundColor:c},children:" "})}),i.jsx(d.IconToggleButton,{defaultPressed:!1,"aria-label":"erase",onPressedChange:z,children:i.jsx(d.RiIcon,{icon:"RiEraserFill"})}),i.jsx(d.Separator,{orientation:"vertical",size:"full"}),i.jsx(d.IconButton,{"aria-label":"undo",onClick:D,children:i.jsx(d.RiIcon,{icon:"RiArrowGoBackLine"})}),i.jsx(d.IconButton,{"aria-label":"undo",onClick:T,children:i.jsx(d.RiIcon,{icon:"RiArrowGoForwardLine"})}),i.jsx(d.IconButton,{"aria-label":"undo all",onClick:$,children:i.jsx(d.RiIcon,{icon:"RiLoopLeftLine"})})]}),i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(d.IconButton,{"aria-label":"Save markup",accentColor:"primary",onClick:A,children:i.jsx(d.RiIcon,{icon:"RiSaveLine"})}),i.jsx(d.IconButton,{"aria-label":"Delete attachment",onClick:x,children:i.jsx(d.RiIcon,{icon:"RiDeleteBin2Line"})})]})]})}),h&&i.jsx("canvas",{id:"attachment-markup-canvas",className:"hidden",ref:p,width:h.width,height:h.height}),i.jsxs("div",{className:"relative size-full flex items-center justify-center p-4 overflow-hidden",children:[i.jsx("img",{className:"max-w-full max-h-full invisible absolute",alt:"Photo attachment",ref:E,src:n.objectURL}),y?i.jsx(d.Spinner,{}):i.jsx(Hr.ReactSketchCanvas,{className:"max-w-full max-h-full aspect-square",backgroundImage:n.objectURL,ref:l,onStroke:L,strokeColor:c},m?"1":"0")]})]})]})})});Vr.displayName="AttachmentEditor",b.BaseField=k,b.BaseFormElement=yt,b.BooleanField=Ce,b.BooleanInput=jt,b.ColorPicker=gt,b.DateField=Je,b.DateInput=kt,b.FieldSection=W,b.FileBadge=yn,b.FileCard=vt,b.FileIcon=Ae,b.FormBuilder=Ko,b.FormRenderer=Ar,b.ImageCard=Nr,b.ImageMarkup=Vr,b.ImageViewer=Vt,b.ImageViewerProvider=cr,b.InputWithHelpText=Ut,b.InputWithLabel=Q,b.InputWithLabelAndHelpText=Y,b.MultiSelectField=ze,b.MultiSelectInput=Jt,b.MultiStringField=Oe,b.MultiStringInput=Xt,b.NumberField=oe,b.NumberInput=Kt,b.PatchField=ue,b.PatchFormProvider=Wo,b.QrField=nt,b.QrInput=Qt,b.QrScanner=Yt,b.SUPPORTED_IMAGE_FILE_TYPES=mn,b.SUPPORTED_PDF_FILE_TYPES=vn,b.SUPPORTED_SPREADSHEET_FILE_EXTENSIONS=gn,b.SelectField=Be,b.SelectInput=Zt,b.StringField=it,b.StringInput=Rt,b.TextField=ot,b.TextInput=en,b.decodeFormValues=Vo,b.deserialize=ct,b.deserializeField=rn,b.emptyBaseField=G,b.emptyBooleanField=dr,b.emptyDateField=ur,b.emptyMultiSelectField=wr,b.emptyMultiStringField=gr,b.emptyNumberField=vr,b.emptyQrField=Cr,b.emptySelectField=Ir,b.emptyStringField=Er,b.emptyTextField=Sr,b.encodeFormValues=Uo,b.flattenFields=on,b.formRevisionToSchema=Dr,b.initialFormValues=ft,b.isConditionMet=an,b.useFieldInput=Wt,b.useFieldInputs=Pe,b.useFormikInput=_,b.useImageViewer=Ve,b.validateForm=ut,b.valueIsFile=dt,Object.defineProperty(b,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},xo="DialogDescriptionWarning",Eo=({contentRef:t,descriptionId:n})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${lr(xo).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},zt=Jn,Bt=er,_t=tr,$t=nr,So=ar;const Vt=f.memo(t=>{const{file:n,onClose:e}=t,r=f.useRef(null),o=f.useCallback(()=>{var l;if(!r.current)return;const s=document.createElement("canvas");s.width=r.current.width,s.height=r.current.height,(l=s.getContext("2d"))==null||l.drawImage(r.current,0,0,r.current.width,r.current.height),s.toBlob(p=>{p&&navigator.clipboard.write([new ClipboardItem({"image/png":p})])},"image/png")},[]),a=f.useCallback(()=>{H.downloadFile(n)},[n]);return i.jsx(zt,{open:!0,onOpenChange:e,children:i.jsx(Bt,{children:i.jsx(_t,{className:"bg-(--color-background) fixed inset-0 data-[state='open']:fade-in-0 data-[state='open']:zoom-in-95 data-[state='closed']:animate-out data-[state='closed']:fade-out-0 data-[state='closed']:zoom-out-95 data-[state='open']:animate-in","data-floating-content":"",children:i.jsxs($t,{className:"absolute inset-0 py-12","data-floating-content":"",onOpenAutoFocus:s=>s.preventDefault(),children:[i.jsxs(d.ButtonGroup,{className:"flex gap-2 items-center top-0 absolute right-0 p-2",accentColor:"base",variant:"ghost",children:[i.jsxs(d.Tooltip.Root,{children:[i.jsx(d.Tooltip.Trigger,{children:i.jsx(d.IconButton,{onClick:o,"aria-label":"copy to clipboard",children:i.jsx(d.RiIcon,{icon:"RiFileCopyLine"})})}),i.jsx(d.Tooltip.Content,{size:"sm",children:"Copy"})]}),i.jsxs(d.Tooltip.Root,{children:[i.jsx(d.Tooltip.Trigger,{children:i.jsx(d.IconButton,{onClick:a,"aria-label":"download",children:i.jsx(d.RiIcon,{icon:"RiDownload2Line"})})}),i.jsx(d.Tooltip.Content,{size:"sm",children:"Download"})]}),i.jsx(d.Separator,{orientation:"vertical",size:"sm"}),i.jsx(So,{asChild:!0,children:i.jsx(d.IconButton,{onClick:e,"aria-label":"close",children:i.jsx(d.RiIcon,{icon:"RiCloseLine"})})})]}),i.jsx("figure",{className:"size-full overflow-hidden p-4 flex justify-center items-center",children:i.jsx("img",{ref:r,className:"max-w-full max-h-full",src:URL.createObjectURL(n),alt:n.name})})]})})})})});Vt.displayName="ImageViewer";const cr=f.memo(t=>{const{children:n}=t,[e,r]=f.useState(null),o=f.useCallback(()=>{r(null)},[]),a=f.useCallback(p=>{r(p(o))},[o]),s=f.useCallback(()=>{e&&(e.onClose&&e.onClose(),o())},[o,e]),l=f.useMemo(()=>a,[a]);return i.jsxs(bn.Provider,{value:l,children:[n,e&&i.jsx(Vt,{file:e.file,onClose:s})]})});cr.displayName="FileViewerProvider";const Q=t=>{const{className:n,label:e,children:r,severity:o,inputId:a,labelId:s,image:l}=t,[p,c]=f.useState(void 0),u=Ve(),h=o?ne[o]:"base";f.useEffect(()=>{l instanceof Promise?l.then(c).catch(console.error):c(l)},[l]);const g=p?URL.createObjectURL(p):void 0,y=f.useCallback(()=>{p&&u(()=>({file:p}))},[u,p]);return i.jsxs("div",{className:"flex flex-col gap-2",children:[p&&i.jsx("img",{className:"h-[100px] w-full min-w-[300px] cursor-pointer rounded-md object-cover",src:g,alt:p.name,onClick:y}),i.jsxs("label",{className:he(n,"flex flex-col gap-1"),htmlFor:a,children:[i.jsx(d.Text,{accentColor:h,size:"sm",id:s,weight:"medium",children:e}),r]})]})},Ut=t=>{const{helpText:n,children:e,severity:r}=t,o=r?ne[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(d.Text,{accentColor:o,size:"xs",children:n})})]})},Y=t=>{const{children:n,...e}=t;return i.jsx(Ut,{...e,children:n})},Fo=[!0,"true"],jt=f.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,fieldProps:l},p]=_(t);let[{helpText:c,label:u}]=_(t);c=a?null:c,u=a?"":u;const h=Fo.includes(l.value);return i.jsx(Y,{helpText:c,severity:o,children:i.jsx(Q,{size:r,severity:o,inputId:n,labelId:e,label:u,image:a?void 0:s.image,className:"items-center flex-row-reverse justify-end gap-2",children:i.jsx(d.Checkbox.Root,{...p,...l,id:n,size:"sm",accentColor:"primary",value:h.toString(),checked:h,onCheckedChange:l.onChange,onChange:void 0,onBlur:void 0,variant:"surface",children:i.jsx(d.Checkbox.Indicator,{children:i.jsx(d.RiIcon,{icon:"RiCheckLine"})})})})})});jt.displayName="BooleanInput";const dr={...G,type:"boolean"},be=class be extends k{constructor(e){super({...e,type:"boolean"});I(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 be(e)}getInput(e){return i.jsx(jt,{...e,field:this})}};I(be,"fieldTypeName","Checkbox"),I(be,"fieldTypeDescription","Perfect for both optional and required yes/no questions."),I(be,"Icon",j.RiCheckboxCircleLine);let Ce=be;const kt=f.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,fieldProps:l},p]=_(t);let[{helpText:c,label:u}]=_(t);c=a?null:c,u=a?"":u;const h=l.value?new Date(l.value):void 0,g=f.useCallback(y=>{l.onChange({target:{value:y?y.toISOString():null}})},[l]);return i.jsx(Y,{helpText:c,severity:o,children:i.jsx(Q,{size:r,severity:o,inputId:n,labelId:e,label:u,image:a?void 0:s.image,children:i.jsxs(d.Popover.Root,{children:[i.jsx(d.Popover.Trigger,{asChild:!0,children:i.jsxs(d.Button,{...p,className:"!justify-between",type:"button",accentColor:"base",variant:"surface",size:"sm",id:n,children:[h?h.toLocaleString(void 0,{year:"numeric",month:"2-digit",day:"2-digit"}):"yyyy-mm-dd",i.jsx(d.RiIcon,{icon:"RiArrowDownSLine"})]})}),i.jsx(d.Popover.Content,{children:i.jsx(d.DayPicker,{required:!1,mode:"single",variant:"solid",selected:h,onSelect:g})})]})})})});kt.displayName="DateInput";const ur={...G,type:"date"},we=class we extends k{constructor(e){super({...e,type:"date"});I(this,"onlyValidateAfterTouched",!1)}serialize(){return super._serialize()}getValueFromChangeEvent(e){return e.target.value}static deserialize(e){if(e.type!=="date")throw new Error("Type mismatch.");return new we(e)}getInput(e){return i.jsx(kt,{field:this,...e})}};I(we,"fieldTypeName","Date"),I(we,"fieldTypeDescription","Allows specifying a date."),I(we,"Icon",j.RiCalendarLine);let Je=we;const fr=f.memo(t=>{const{field:n,...e}=t,[{value:r}]=U.useField(n.options.clonedFieldIdentifier),o=f.useMemo(()=>{const a=n.options.getFieldToClone(r);return a?ct(a):null},[n.options,r]);return Wt(o,e)});fr.displayName="FieldInputCloner";const No={...G,type:"custom"};class Ze extends k{constructor(e,r){super({...e,type:"custom"});I(this,"Component");I(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})}}I(Ze,"fieldTypeName","Custom"),I(Ze,"fieldTypeDescription","Allows re-rendering of field already in the form");class To extends Ze{constructor(n){super(n,fr)}}const Wt=(t,n)=>f.useMemo(()=>!n||!t?null:t.getInput(n),[t,n]),Pe=(t,n)=>{const e=f.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})},Re=(t="",n=[])=>({type:"section",fields:n,identifier:t,label:null,condition:null,conditional:!1}),Lo=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(Re(`AUTO_section-${n.indexOf(o)}`,e)),e=[]),r.push(o)):e.push(o);return e.length>0&&r.push(Re("AUTO_section-last",e)),{...t,fields:r,description:t.description??""}};function qt(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 hr(t,n,e){const r=Array.from(t??[]);return r.splice(n,0,e),r}function et(t,n){const e=Array.from(t);return e.splice(n,1),e}const Ht=(t,n)=>{const e=new Date;return`${H.slugify(n)}-${e.getTime()}`},pr=(t,n)=>{if(!n)return null;for(const e of t)if(e.type==="section"){const r=pr(e.fields,n);if(r)return r}else if(e.identifier===n)return e;return null},mr=(t,n)=>t.filter((e,r)=>r<n).flatMap(e=>e.fields),tt=(t,n,e,r,o)=>{const{label:a}=e,s={...e,identifier:Ht(null,a)},l=X(r,t);if(l===void 0)throw new Error("Parent path must point to an existing field.");if(!Array.isArray(l))throw new Error("Parent path must point to an array.");const p=hr(l,n,s);o(t,p).then()},Do=(t,n,e)=>{const r={...Re(),label:""};tt("fields",t,r,n,e)},Gt=()=>{const{showError:t}=d.useToast(),n=f.useCallback((r,o,a,s,l,p)=>{const c=r[o];if(!c)throw new Error("Could not find section context.");let u=typeof c.conditionIndex<"u"?Math.max(c.conditionIndex+1,s):s;for(const h of Object.values(r))h.conditionIndex===a&&(u=Math.min(u,h.index-1));if(u!==s){t({title:"Could not reorder sections",description:"Sections with conditions must be below the fields they reference."});return}p("fields",qt(l.fields,a,u))},[t]),e=f.useCallback((r,o,a,s,l,p,c)=>{var u;if(!(r!=null&&r.fields)||!s)throw new Error("Could not find section with fields.");if(r.identifier===s.identifier)c(`fields.${o}.fields`,qt(r.fields,a,p)).then();else{const h=r.fields[a];if(!h)throw new Error("Could not find field to reorder.");if(((u=s.condition)==null?void 0:u.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`,et(r.fields,a)).then(),c(`fields.${l}.fields`,hr(s.fields,p,h)).then()}},[t]);return{reorderSection:n,reorderField:e}},Xt=f.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,fieldProps:l},p]=_(t);let[{helpText:c,label:u}]=_(t);c=a?null:c,u=a?"":u;const h=f.useMemo(()=>Array.isArray(l.value)?l.value:[],[l.value]),{onChange:g,onBlur:y}=l,w=`${n}-droppable`,{disabled:m}=p,[C,E]=f.useState(""),[S,N]=f.useState(""),x=S||c,F=f.useCallback(A=>{g(A),y(A)},[g,y]),L=f.useCallback(A=>{h.findIndex(B=>B===A.target.value.trim())>=0?N("All options must be unique"):A.target.value?N(""):N("Option cannot be empty"),E(A.target.value)},[E,h]),T=f.useCallback(()=>{if(S)return;if(!C.trim()){N("Option cannot be empty");return}const A=C.trim();F([...h,A]),E("")},[C,S,F,h]),D=f.useCallback(A=>{A.key==="Enter"&&(A.preventDefault(),T())},[T]),$=f.useCallback(A=>{F(et(h,A))},[h,F]),z=f.useCallback(A=>{if(!A.destination)return;const B=A.source.index,O=A.destination.index;F(qt(h,B,O))},[F,h]);return i.jsx(te.DragDropContext,{onDragEnd:z,children:i.jsxs("div",{className:"flex flex-col gap-2",children:[i.jsx(Y,{helpText:x,severity:o,children:i.jsx(Q,{size:r,severity:o,inputId:n,labelId:e,label:u,image:a?void 0:s.image,children:(!m||h.length===0)&&i.jsxs("div",{className:"flex gap-2",children:[i.jsx("div",{className:"grow",children:i.jsx(d.Input.Root,{accentColor:"base",variant:"surface",size:"sm",children:i.jsx(d.Input.Field,{...p,...l,value:C,onChange:L,onKeyDown:D,id:n,placeholder:s.placeholder,onBlur:void 0})})}),i.jsx(d.IconButton,{size:"sm",accentColor:"base",variant:"soft",type:"button","aria-label":"Add option",disabled:!!S||m,onClick:T,children:i.jsx(d.RiIcon,{icon:"RiAddLine"})})]})})}),i.jsx(te.Droppable,{droppableId:w,children:A=>i.jsxs("div",{className:"flex flex-col",...A.droppableProps,ref:A.innerRef,children:[h.map((B,O)=>i.jsx(te.Draggable,{draggableId:`${B}-draggable`,index:O,isDragDisabled:m,children:({draggableProps:R,dragHandleProps:De,innerRef:_e})=>i.jsxs(d.Badge,{...De,...R,ref:_e,className:"mb-1 flex items-center justify-between gap-2",accentColor:"base",size:"sm",variant:"soft",children:[i.jsx("span",{children:typeof B=="object"&&"label"in B?B.label:B}),i.jsx(d.IconButton,{size:"xs",variant:"ghost",type:"button","aria-label":"Delete option",accentColor:"base",disabled:m,onClick:()=>{$(O)},children:i.jsx(d.RiIcon,{icon:"RiCloseLargeLine"})})]})},B)),A.placeholder]})})]})})});Xt.displayName="MultiStringInput";const gr={...G,type:"multi-string",minimum_length:0,maximum_length:null},Ie=class Ie extends k{constructor(e){const{minimum_length:r,maximum_length:o,placeholder:a,...s}=e;super({...s,type:"multi-string"});I(this,"minLength");I(this,"maxLength");I(this,"onlyValidateAfterTouched",!1);I(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(Xt,{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 Ie(e)}};I(Ie,"fieldTypeName","Multi-string"),I(Ie,"fieldTypeDescription","Allows the user to provide multiple unique strings."),I(Ie,"Icon",j.RiListCheck);let Oe=Ie;const Kt=f.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,fieldProps:l},p]=_(t);let[{helpText:c,label:u}]=_(t);return c=a?null:c,u=a?"":u,i.jsx(Y,{helpText:c,severity:o,children:i.jsx(Q,{size:r,severity:o,inputId:n,labelId:e,label:u,image:a?void 0:s.image,children:i.jsx(d.Input.Root,{accentColor:"base",variant:"surface",size:"sm",children:i.jsx(d.Input.Field,{...p,...l,type:"number",id:n,placeholder:s.placeholder,min:s.minimum,max:s.maximum,step:s.integers?1:.1})})})})});Kt.displayName="NumberInput";const vr={...G,type:"number",minimum:Number.MIN_SAFE_INTEGER,maximum:Number.MAX_SAFE_INTEGER,integers:!1},yr=t=>"fields"in t,Z=class Z extends k{constructor(e){const{minimum:r=Number.MIN_SAFE_INTEGER,maximum:o=Number.MAX_SAFE_INTEGER,integers:a=!1,placeholder:s="Enter a number",...l}=e;super({...l,type:"number"});I(this,"minimum");I(this,"maximum");I(this,"integers");I(this,"placeholder");this.minimum=r,this.maximum=o,this.integers=a,this.placeholder=s}getValueFromChangeEvent(e){const r=Number.parseFloat(e.target.value);return Number.isNaN(r)?"":r}static getFieldCreationSchema(e=""){const r=e&&`${e}.`;return[{field:new Z({label:"Minimum",description:"Minimum value",integers:!0,required:!1,identifier:`${r}minimum`,formValidators:[this._validateMin(e)]}),showDirectly:!1},{field:new Z({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 Z(e)}getInput(e){return i.jsx(Kt,{field:this,...e})}};I(Z,"fieldTypeName","Number"),I(Z,"fieldTypeDescription","Allows specifying a number within a given range."),I(Z,"Icon",j.RiHashtag),I(Z,"_validateMin",e=>(r,o)=>{const a=yr(o)?X(o,e):o;return typeof a.maximum=="number"&&typeof r=="number"&&a.maximum<r?"Minimum cannot be greater than minimum.":null}),I(Z,"_validateMax",e=>(r,o)=>{const a=yr(o)?X(o,e):o;return typeof a.minimum=="number"&&typeof r=="number"&&a.minimum>r?"Maximum cannot be less than minimum.":null});let oe=Z;const Qt=f.memo(t=>{const[{inputId:n,labelId:e,label:r,helpText:o,size:a,severity:s,showInputOnly:l,field:p,fieldProps:c},u]=_(t),[h,g]=f.useState(!1),y=c.value,w=f.useCallback(S=>{c.onChange({target:{value:S}}),g(!1)},[c]),m=f.useCallback(()=>{c.onChange({target:{value:""}})},[c]),C=f.useCallback(()=>{g(!0)},[]),E=f.useCallback(()=>{g(!1)},[]);return i.jsx(Y,{helpText:o,severity:s,children:i.jsxs(Q,{size:a,severity:s,inputId:n,labelId:e,label:r,image:l?void 0:p.image,className:"flex-col items-start justify-start gap-1",children:[i.jsx(zt,{open:h,onOpenChange:g,children:i.jsxs(Bt,{children:[i.jsx(_t,{className:"light:bg-(--black-a6) fixed inset-0 dark:bg-(--black-a8)"}),i.jsx($t,{className:"fixed inset-0",children:i.jsx(Yt,{onQrScan:w,onClose:E})})]})}),i.jsxs("div",{className:"flex w-max items-center gap-1",children:[i.jsxs(d.Button,{...u,variant:"soft",onClick:C,type:"button",size:"sm",accentColor:"base",children:[i.jsx(d.RiIcon,{icon:"RiQrCodeLine"}),"Scan"]}),y&&i.jsx("span",{className:"text-xs text-(--accent-a11)","data-accent-color":"primary",children:i.jsx(d.RiIcon,{icon:"RiCheckLine",style:{verticalAlign:"bottom"}})})]}),!!y&&i.jsx(d.Card,{children:i.jsxs("div",{className:"w-max items-center gap-2",children:[i.jsx("code",{className:"bg-(--base-a3)",children:y}),i.jsx(d.IconButton,{accentColor:"base",variant:"ghost","aria-label":"delete",size:"sm",onClick:m,children:i.jsx(d.RiIcon,{icon:"RiCloseLine"})})]})})]})})});Qt.displayName="QrInput";const Yt=f.memo(t=>{const{onQrScan:n,onClose:e}=t,r=f.useRef(null),[o,a]=f.useState(!1);return f.useEffect(()=>{if(!r.current)return;const s=new Wr(r.current,l=>{const p=l.data;n(p),s.destroy()},{highlightCodeOutline:!0,highlightScanRegion:!0,maxScansPerSecond:1});a(!0),s.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(d.IconButton,{"aria-label":"close",variant:"soft",accentColor:"base",onClick:e,children:i.jsx(d.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(d.Spinner,{})})]})]})});Yt.displayName="QrScanner";const Cr={...G,type:"qr"},xe=class xe extends k{constructor(e){super({...e,type:"qr"});I(this,"onlyValidateAfterTouched",!1)}serialize(){return super._serialize()}static deserialize(e){if(e.type!=="qr")throw new Error("Type mismatch.");return new xe(e)}getInput(e){return i.jsx(Qt,{...e,field:this})}};I(xe,"fieldTypeName","QR"),I(xe,"fieldTypeDescription","Used for scanning/reading QR codes."),I(xe,"Icon",j.RiQrCodeLine);let nt=xe;class br extends k{constructor(e){const{placeholder:r="",...o}=e;super(o);I(this,"options");I(this,"onlyValidateAfterTouched",!1);I(this,"placeholder");this.placeholder=r;const a=new Set;this.options=e.options.map(s=>(typeof s=="string"&&(s={label:s,value:s}),a.add(s.label),s)),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 Oe({label:"Options",description:"List possible options for the user to select from.",required:!0,identifier:`${r}options`,minimum_length:2}),showDirectly:!0}]}}const Mo=t=>t?Array.isArray(t)?t:[t]:[],Jt=f.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,fieldProps:l},p]=_(t),{onChange:c,onBlur:u}=l;let[{helpText:h,label:g}]=_(t);h=a?null:h,g=a?"":g;const y=f.useMemo(()=>Mo(l.value),[l.value]),w=f.useCallback(m=>{c(m),u(m)},[c,u]);return i.jsx(Y,{helpText:h,severity:o,children:i.jsx(Q,{size:r,severity:o,inputId:n,labelId:e,label:g,image:a?void 0:s.image,children:i.jsxs(d.Menu.Root,{children:[i.jsx(d.Menu.ClickTrigger,{children:i.jsxs(d.Button,{id:n,className:"!justify-between",name:l.name,variant:"surface",type:"button",size:"sm",accentColor:"base",...p,children:[y.length>0?y.join(", "):s.placeholder,i.jsx(d.RiIcon,{icon:"RiArrowDownSLine"})]})}),i.jsx(d.Menu.Content,{children:i.jsx(d.Menu.Scroll,{children:i.jsxs(d.Menu.MultiSelectGroup,{values:y,onValuesChange:w,children:[i.jsxs(d.Menu.SelectAllItem,{allValues:s.options.map(({value:m})=>m),children:[i.jsx(d.Menu.SelectAllIndicator,{children:m=>m?i.jsx(d.RiIcon,{icon:"RiSubtractLine"}):i.jsx(d.RiIcon,{icon:"RiCheckLine"})}),"Select all"]}),s.options.map(m=>i.jsxs(d.Menu.MultiSelectItem,{value:m.value,children:[i.jsx(d.Menu.SelectedIndicator,{children:i.jsx(d.RiIcon,{icon:"RiCheckLine"})}),m.label]},m.value))]})})})]})})})});Jt.displayName="MultiSelectInput";const wr={...G,type:"multi-select",options:[]},Ee=class Ee extends br{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 Ee(n)}getInput(n){return i.jsx(Jt,{field:this,...n})}};I(Ee,"fieldTypeName","Multi-select"),I(Ee,"fieldTypeDescription","Allows the user to select a multiple options from a list of options."),I(Ee,"Icon",j.RiCheckboxLine);let ze=Ee;const Zt=f.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,fieldProps:l},p]=_(t),{onChange:c,onBlur:u}=l;let[{helpText:h,label:g}]=_(t);h=a?null:h,g=a?"":g;const y=f.useCallback(m=>{c(m),u(m)},[c,u]),w=f.useMemo(()=>s.options.find(m=>m.value===l.value),[s.options,l.value]);return i.jsx(Y,{helpText:h,severity:o,children:i.jsx(Q,{size:r,severity:o,inputId:n,labelId:e,label:g,image:a?void 0:s.image,children:i.jsxs(d.Menu.Root,{children:[i.jsx(d.Menu.ClickTrigger,{children:i.jsxs(d.Button,{...l,className:"!justify-between",id:n,name:l.name,accentColor:"base",variant:"surface",type:"button",size:"sm",...p,children:[w?w.label:s.placeholder,i.jsx(d.RiIcon,{icon:"RiArrowDownSLine"})]})}),i.jsx(d.Menu.Content,{children:i.jsx(d.Menu.Scroll,{children:i.jsx(d.Menu.SelectGroup,{value:l.value,onValueChange:y,children:s.options.map(m=>i.jsxs(d.Menu.SelectItem,{value:m.value,children:[i.jsx(d.Menu.SelectedIndicator,{children:i.jsx(d.RiIcon,{icon:"RiCheckLine"})}),m.label]},m.value))})})})]})})})});Zt.displayName="SelectInput";const Ir={...G,type:"select",options:[]},Se=class Se extends br{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 Se(n)}getInput(n){return i.jsx(Zt,{field:this,...n})}};I(Se,"fieldTypeName","Dropdown"),I(Se,"fieldTypeDescription","Allows the user to select a single option from a list of options."),I(Se,"Icon",j.RiMenuFoldLine);let Be=Se;const xr=t=>"fields"in t;class rt extends k{constructor(e){const{minLength:r,maxLength:o,placeholder:a="",...s}=e;super(s);I(this,"minLength");I(this,"maxLength");I(this,"placeholder");this.minLength=r?Math.max(r,0):void 0,this.maxLength=o?Math.max(o,0):pe,this.placeholder=a}static getFieldCreationSchema(e=""){const r=e&&`${e}.`;return[{field:new oe({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 oe({label:"Maximum length",description:"Maximum number of characters",required:!1,identifier:`${r}maximum_length`,minimum:1,maximum:pe,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}}}I(rt,"_validateMin",e=>(r,o)=>{const a=xr(o)?X(o,e):o;return typeof a.maximum_length=="number"&&typeof r=="number"&&a.maximum_length<r?"Minimum cannot be greater than maximum.":null}),I(rt,"_validateMax",e=>(r,o)=>{if(typeof r!="number")return null;const{minimum_length:a}=xr(o)?X(o,e):o;return typeof a!="number"?null:a>r?"Maximum cannot be less than minimum.":null});const Rt=f.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,fieldProps:l},p]=_(t);let[{helpText:c,label:u}]=_(t);return c=a?null:c,u=a?"":u,i.jsx(Y,{helpText:c,severity:o,children:i.jsx(Q,{size:r,severity:o,inputId:n,labelId:e,label:u,image:a?void 0:s.image,children:i.jsx(d.Input.Root,{accentColor:"base",variant:"surface",size:"sm",children:i.jsx(d.Input.Field,{...p,...l,type:s.inputType,id:n,placeholder:s.placeholder})})})})});Rt.displayName="StringInput";const Er={...G,type:"string",maximum_length:$e,input_type:"text"},Fe=class Fe extends rt{constructor(e){const{inputType:r="text",...o}=e,a=e.maxLength?Math.min($e,e.maxLength):$e,s=e.minLength?Math.min(e.minLength,a):void 0;super({...o,maxLength:a,minLength:s,type:"string"});I(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,...s}=e;return new Fe({...s,maxLength:r,minLength:o,inputType:a,placeholder:"Enter a short description"})}getInput(e){return i.jsx(Rt,{field:this,...e})}};I(Fe,"fieldTypeName","Short Text"),I(Fe,"fieldTypeDescription",`Short text fields can hold up to ${$e} characters on a single line.`),I(Fe,"Icon",j.RiInputField);let it=Fe;const en=f.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,fieldProps:l},p]=_(t);let[{helpText:c,label:u}]=_(t);return c=a?null:c,u=a?"":u,i.jsx(Y,{helpText:c,severity:o,children:i.jsx(Q,{size:r,severity:o,inputId:n,labelId:e,label:u,image:a?void 0:s.image,children:i.jsx(d.TextArea,{...p,...l,className:"field-sizing-content",resize:"vertical",id:n,placeholder:s.placeholder,accentColor:"base",variant:"surface",size:"sm"})})})});en.displayName="TextInput";const Sr={...G,type:"text",maximum_length:pe},Ne=class Ne extends rt{constructor(n){const e=n.maxLength?Math.min(pe,n.maxLength):pe,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 Ne({...o,maxLength:e,minLength:r,placeholder:"Enter a description"})}getInput(n){return i.jsx(en,{field:this,...n})}};I(Ne,"fieldTypeName","Paragraph"),I(Ne,"fieldTypeDescription",`Paragraph fields can hold up to ${pe} characters and can have multiple lines.`),I(Ne,"Icon",j.RiAlignJustify);let ot=Ne;var at=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},st={exports:{}},Ao=st.exports,Fr;function Po(){return Fr||(Fr=1,function(t,n){(function(e,r){r()})(Ao,function(){function e(c,u){return typeof u>"u"?u={autoBom:!1}:typeof u!="object"&&(console.warn("Deprecated: Expected third argument to be a object"),u={autoBom:!u}),u.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,u,h){var g=new XMLHttpRequest;g.open("GET",c),g.responseType="blob",g.onload=function(){p(g.response,u,h)},g.onerror=function(){console.error("could not download file")},g.send()}function o(c){var u=new XMLHttpRequest;u.open("HEAD",c,!1);try{u.send()}catch{}return 200<=u.status&&299>=u.status}function a(c){try{c.dispatchEvent(new MouseEvent("click"))}catch{var u=document.createEvent("MouseEvents");u.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),c.dispatchEvent(u)}}var s=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof at=="object"&&at.global===at?at:void 0,l=s.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),p=s.saveAs||(typeof window!="object"||window!==s?function(){}:"download"in HTMLAnchorElement.prototype&&!l?function(c,u,h){var g=s.URL||s.webkitURL,y=document.createElement("a");u=u||c.name||"download",y.download=u,y.rel="noopener",typeof c=="string"?(y.href=c,y.origin===location.origin?a(y):o(y.href)?r(c,u,h):a(y,y.target="_blank")):(y.href=g.createObjectURL(c),setTimeout(function(){g.revokeObjectURL(y.href)},4e4),setTimeout(function(){a(y)},0))}:"msSaveOrOpenBlob"in navigator?function(c,u,h){if(u=u||c.name||"download",typeof c!="string")navigator.msSaveOrOpenBlob(e(c,h),u);else if(o(c))r(c,u,h);else{var g=document.createElement("a");g.href=c,g.target="_blank",setTimeout(function(){a(g)})}}:function(c,u,h,g){if(g=g||open("","_blank"),g&&(g.document.title=g.document.body.innerText="downloading..."),typeof c=="string")return r(c,u,h);var y=c.type==="application/octet-stream",w=/constructor/i.test(s.HTMLElement)||s.safari,m=/CriOS\/[\d]+/.test(navigator.userAgent);if((m||y&&w||l)&&typeof FileReader<"u"){var C=new FileReader;C.onloadend=function(){var N=C.result;N=m?N:N.replace(/^data:[^;]*;/,"data:attachment/file;"),g?g.location.href=N:location=N,g=null},C.readAsDataURL(c)}else{var E=s.URL||s.webkitURL,S=E.createObjectURL(c);g?g.location=S:location.href=S,g=null,setTimeout(function(){E.revokeObjectURL(S)},4e4)}});s.saveAs=p.saveAs=p,t.exports=p})}(st)),st.exports}var Oo=Po();const Nr=f.memo(f.forwardRef((t,n)=>{const{file:e,alt:r,error:o,rightSlot:a,className:s,truncateLength:l,...p}=t,c=f.useRef(null),u=f.useRef(null),h=d.useSize(c);f.useLayoutEffect(()=>{!u.current||!h||(u.current.style.height=`${h.height*4}px`)},[h]);const g=f.useMemo(()=>{if(e)return l!==void 0?H.truncate(e.name,l):e.name},[e,l]);return i.jsxs("div",{className:he(s,"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(d.Spinner,{})}),i.jsx("div",{ref:u,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:he("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(d.RiIcon,{icon:"RiFileWarningLine"}):e&&i.jsx(Ae,{fileType:e.type}),i.jsx(d.Text,{className:"truncate",size:"sm",children:o??g}),a]})]})})),zo=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)},Tr=f.memo(t=>{var F;const[{inputId:n,labelId:e,size:r,severity:o,helpText:a,showInputOnly:s,field:l,fieldProps:p},c]=_(t),{onChange:u}=p;let[{label:h}]=_(t);h=s?"":h;const g=o?ne[o]:void 0,y=f.useRef(null),{value:w}=p,m=f.useMemo(()=>s?null:a||(l.maxFileSize?`Maximum file size: ${l.maxFileSize}MB`:null),[l.maxFileSize,a,s]),C=f.useCallback(()=>{var L;(L=y.current)==null||L.click()},[]),E=f.useCallback(L=>{const T=[...w];T.splice(L,1),u({target:{files:T}})},[w,u]),S=w?"Select new files":"Select files",N=w?"Select new file":"Select a file",x=l.maxFiles>1?S:N;return i.jsxs("div",{className:"flex flex-col gap-2",children:[i.jsx(Y,{helpText:m,severity:o,children:i.jsxs(Q,{size:r,severity:o,inputId:n,labelId:e,label:h,image:s?void 0:l.image,children:[i.jsx("div",{className:"flex gap-2",children:i.jsxs(d.Button,{...c,className:"w-max",size:"sm",variant:"soft",accentColor:"base",onClick:C,id:"upload-input-upload-button",type:"button",children:[i.jsx(d.RiIcon,{icon:"RiUpload2Line"})," ",x]})}),i.jsx("input",{...c,type:"file",ref:y,id:n,accept:(F=l.extensions)==null?void 0:F.join(","),multiple:l.maxFiles>1,color:g,style:{display:"none"},...p,value:""})]})}),Array.isArray(w)&&w.length>0&&i.jsx("div",{className:"flex h-max flex-col gap-2",children:w.map((L,T)=>i.jsx(Lr,{field:l,file:L,onRemove:()=>{E(T)},disabled:c.disabled},T))})]})});Tr.displayName="UploadInput";const Lr=f.memo(t=>{const{file:n,field:e,onRemove:r,disabled:o}=t,[a,s]=f.useState(null),l=Ve(),p=f.useMemo(()=>a&&e.getError([a]),[e,a]),{url:c,name:u}=f.useMemo(()=>{let m=null,C,E;return a!=null&&a.type.startsWith("image/")&&(m=URL.createObjectURL(a)),a?(C=a.name,E=zo(a.size)):(C="Downloading...",E="..."),{url:m,name:C,size:E}},[a]);f.useEffect(()=>{n instanceof Promise?n.then(s).catch(console.error):s(n)},[n]);const h=f.useCallback(m=>{if(m.stopPropagation(),!a)throw new Error("Cannot download a file that is not resolved.");const C=new Blob([a]);Oo.saveAs(C,u)},[u,a]),g=f.useCallback(m=>{m.stopPropagation(),r()},[r]),y=f.useCallback(()=>{a&&l(m=>({file:a,onDelete:o?void 0:()=>{r(),m()}}))},[o,r,l,a]),w=f.useMemo(()=>i.jsxs(d.ButtonGroup,{className:"flex grow justify-end",variant:"ghost",accentColor:"base",size:"sm",children:[i.jsx(d.IconButton,{"aria-label":`Download ${u}`,onClick:h,disabled:!a,children:i.jsx(d.RiIcon,{icon:"RiDownload2Line"})}),!o&&i.jsx(d.IconButton,{"aria-label":`Remove ${u}`,disabled:o,onClick:g,children:i.jsx(d.RiIcon,{icon:"RiDeleteBin7Fill"})})]}),[o,g,h,u,a]);return c?i.jsx(Nr,{className:"cursor-pointer",onClick:y,file:a,error:p??void 0,rightSlot:w}):i.jsx(vt,{file:a,error:p??void 0,rightSlot:w})});Lr.displayName="DisplayFile";const Bo={...G,type:"upload",extensions:[],maximum_size:void 0,maximum_files:1},Te=class Te extends k{constructor(e){const{extensions:r,maximum_files:o,maximum_size:a,...s}=e;super({...s,type:"upload"});I(this,"extensions");I(this,"maxFileSize");I(this,"maxFiles");I(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 oe({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 oe({label:"What is the maximum size of each file?",description:`Maximum file size in megabytes (between 1MB–${lt}MB).`,required:!1,identifier:`${r}maximum_size`,minimum:1,maximum:lt,integers:!0}),showDirectly:!1},{field:new ze({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??lt,o=r*1e3*1e3,a=this.maxFiles||1;return e.push(s=>{if(s&&s.some(l=>l.size>o))return`Files must be at most ${r}MB.`}),e.push(s=>{if(s&&s.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 Te(e)}getInput(e){return i.jsx(Tr,{field:this,...e})}};I(Te,"fieldTypeName","Upload"),I(Te,"fieldTypeDescription","Allows a file to be uploaded."),I(Te,"Icon",j.RiUpload2Line);let tn=Te;const nn={date:Je,number:oe,boolean:Ce,select:Be,string:it,text:ot,custom:Ze,upload:tn,qr:nt,"multi-string":Oe,"multi-select":ze},_o={date:ur,number:vr,boolean:dr,select:Ir,string:Er,text:Sr,custom:No,upload:Bo,qr:Cr,"multi-string":gr,"multi-select":wr},lt=50,$o=lt*1e3*1e3,rn=t=>{const n=t.type;return nn[n].deserialize(t)},ct=t=>t.type==="section"?W.deserialize(t):rn(t);function Dr(t,n={}){const{readonly:e=!1}=n;return{title:t.title,description:t.description,fields:t.fields.map(r=>ct(r)),meta:{readonly:e}}}function on(t){const n=[];for(const e of t.fields)if(e instanceof W)for(const r of e.fields)n.push(r);else{if(!(e instanceof k))throw new Error(`Invalid field type: ${e.type}`);n.push(e)}return n}function Vo(t,n){const e=on(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 Uo(t,n){const e=on(t),r={};for(const o of e){const a=n[o.identifier];r[o.identifier]=o.encodeValueToJson(a)}return r}function dt(t){return Array.isArray(t)&&t.some(n=>n instanceof File||n instanceof Promise)}function an(t,n){if(!t)return!0;if(dt(n)||dt(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 Mr=f.memo(t=>{const{field:n,...e}=t,{label:r,description:o,fields:a,condition:s}=n,{values:l,setFieldValue:p}=U.useFormikContext(),c=s!=null&&s.identifier?X(l,s.identifier):void 0,u=f.useMemo(()=>c===void 0||an(s,c),[s,c]);f.useEffect(()=>{if(!u)for(const g of a)p(g.getId(),"").then()},[u,a,p]);const h=Pe(a,e);return u?i.jsx(d.Card,{children:i.jsxs("div",{className:"flex flex-col gap-4",children:[(r||o)&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex flex-col",children:[i.jsx(d.Heading,{size:"lg",children:r}),i.jsx(d.Text,{accentColor:"base",children:o})]}),i.jsx(d.Separator,{size:"full"})]}),h]})}):null});Mr.displayName="FieldSectionLayout";const Le=class Le extends yt{constructor(e){const{label:r=null,fields:o,condition:a=null,conditional:s,...l}=e;super({...l,type:"section"});I(this,"label");I(this,"fields");I(this,"condition");this.fields=o,this.condition=a,this.label=r,s===!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 Le({label:"Conditional settings",identifier:`${o}conditional-settings`,condition:{identifier:`${o}conditional`,value:!0},fields:[new Be({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 To({label:"Value",identifier:`${o}condition.value`,required:!0,clonedFieldIdentifier:`${o}condition.identifier`,getFieldToClone(a){if(!a)return null;const s=e.find(l=>l.identifier===a);return s?{...s,label:"Value",identifier:`${o}condition.value`,description:"The value to compare against.",required:s.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(rn);return new Le({...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(),s=o.getError(X(e,a),e);s&&mt(r,o.getId(),s)}return r}getInput(e){return i.jsx(Mr,{field:this,...e})}};I(Le,"fieldTypeName","Section"),I(Le,"fieldTypeDescription","Sections can be useful for grouping fields together. They can also be conditionally shown or hidden.");let W=Le;const de=t=>Object.keys(t).length>0,ut=(t,n)=>{const e={};for(const r of t.fields)if(r instanceof W){if(r.condition){const{identifier:o}=r.condition;if(!an(r.condition,X(n,o)))continue}Object.assign(e,r.getErrors(n))}else{if(!(r instanceof k))throw new Error("Invalid field type");const o=r.getId(),a=r.getError(X(n,o),n);a&&mt(e,o,a)}if(de(e))return e},jo=[null,void 0],ft=(t,n)=>t.reduce((e,r)=>r instanceof W?{...e,...ft(r.fields,n)}:(jo.includes(X(e,r.getId()))&&mt(e,r.getId(),""),e),qr(n)),ko=()=>{throw new Error("onSubmit must be provided if form is not readonly.")},Ar=f.memo(f.forwardRef((t,n)=>{const{schema:e,values:r={},onSubmit:o=ko,submitText:a="Submit",cancelText:s,onCancel:l,onDirty:p,onDirtyChange:c,hideTitle:u=!e.title,hideDescription:h,className:g,buttonProps:y}=t,{readonly:w}=e.meta,m=f.useMemo(()=>crypto.randomUUID(),[]),C=U.useFormik({initialValues:ft(e.fields,r),onSubmit:o,validate:F=>ut(e,F),validateOnBlur:!1,validateOnChange:!1}),{dirty:E}=C,S=f.useMemo(()=>typeof e.title=="string"?i.jsx(d.Heading,{size:"md",children:e.title}):e.title,[e.title]),N=f.useMemo(()=>typeof e.description=="string"?i.jsx(d.Text,{accentColor:"base",children:e.description}):e.description,[e.description]),x=Pe(e.fields,{formId:m,disabled:w});return f.useEffect(()=>{E&&p&&p(),c&&c(E)},[E,p,c]),i.jsx(U.FormikProvider,{value:C,children:i.jsxs("form",{id:m,ref:n,className:he(g,"flex flex-col gap-2"),onSubmit:C.handleSubmit,children:[!u&&i.jsx(d.Card,{children:i.jsxs("div",{className:"flex flex-col gap-1",children:[S,!h&&N]})}),x,!w&&i.jsxs("div",{className:"flex items-center justify-end gap-2",children:[s&&i.jsxs(d.Button,{accentColor:ne.danger,...y,type:"button",onClick:l,children:[i.jsx(d.RiIcon,{icon:"RiCloseLine"}),s]}),i.jsxs(d.Button,{...y,type:"submit",disabled:!C.isValid,accentColor:"success",children:[i.jsx(d.RiIcon,{icon:"RiCheckLine"}),a]})]})]})})})),ue=f.memo(t=>{const{name:n,render:e}=t,{submitForm:r}=U.useFormikContext(),[o,a,s]=U.useField(n),l=f.useMemo(()=>{const p=c=>{s.setValue(c,!1)};return e({value:o.value,meta:a,setValue:p,patchValue:()=>{r()}})},[e,o.value,a,r,s]);return i.jsx(i.Fragment,{children:l})});ue.displayName="PatchField";const Wo=f.memo(f.forwardRef((t,n)=>{const{children:e,schema:r,values:o,onPatch:a,onError:s,requiresDiff:l=!0,onDirtyChange:p,...c}=t,u=f.useMemo(()=>ft(r.fields,o),[r.fields,o]),h=f.useCallback(S=>{const N={};for(const x in S){const F=S[x];F!==u[x]&&F!==void 0&&(N[x]=F)}return N},[u]),g=f.useCallback(S=>{const N=h(S);l&&!de(N)||a(N)},[h,a,l]),y=f.useCallback(S=>{const N=ut(r,S);if(N&&s(N),p){const x=h(S);p(de(x))}return N},[r,p,s,h]),w=U.useFormik({initialValues:u,onSubmit:g,validate:y,validateOnBlur:!1,validateOnChange:!1}),m=f.useCallback(()=>{if(p){const S=h(w.values);de(S)&&p(!0)}},[w.values,h,p]),{errors:C,resetForm:E}=w;return f.useEffect(()=>{de(C)&&E({values:u,errors:{}})},[C,u,E]),i.jsx(U.FormikProvider,{value:w,children:i.jsx("form",{...c,ref:n,onSubmit:w.handleSubmit,onChange:m,children:e})})})),ht="form-builder",qo=[["string","text"],["select","multi-select","upload","qr"],["boolean","date","number","multi-string"]],sn={...nn,section:W},Ho=(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}},Go=(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}}},Pr=t=>{var e,r,o;const n={};for(let a=0;a<t.length;a++){const s=t[a];if(!s)throw new Error("Field is undefined.");const l=a>0?(e=n[t[a-1].identifier])==null?void 0:e.conditionFields:void 0,p=new Set(l);(r=s.condition)!=null&&r.identifier&&p.add(s.condition.identifier),n[s.identifier]={disabled:!1,conditionFields:p,conditionIndex:Go(t,(o=s.condition)==null?void 0:o.identifier),index:a,label:s.label}}return n},ln=f.memo(t=>{const{index:n,type:e,sectionIndex:r,remove:o,duplicate:a,move:s,upload:l}=t;if(e!=="section"&&!l)throw new Error("Upload function prop must be defined for non-section fields.");const{values:p}=U.useFormikContext(),c=f.useRef(null),u=f.useMemo(()=>{const h=[{Icon:j.RiFileCopyLine,key:"duplicate",text:"Duplicate",buttonProps:{onClick:a}}];return h.push({Icon:j.RiDeleteBin7Fill,key:"delete",text:"Delete",buttonProps:{onClick:o}}),e!=="section"&&h.unshift({Icon:j.RiImageLine,key:"upload",text:"Upload image",buttonProps:{onClick:()=>{var g;(g=c.current)==null||g.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:j.RiArrowDownLine,key:"moveDown",text:"Move down",buttonProps:{onClick:()=>{s("down")}}}),(r===void 0&&n!==0||r!==void 0&&(r!==0||n!==0))&&h.unshift({Icon:j.RiArrowUpLine,key:"moveUp",text:"Move up",buttonProps:{onClick:()=>{s("up")}}}),h},[a,n,s,o,r,e,p.fields]);return i.jsxs(i.Fragment,{children:[i.jsx(d.ButtonGroup,{className:"mx-2 hidden flex-col gap-0.5 sm:flex",variant:"ghost",accentColor:"base",size:"sm",children:u.map(h=>i.jsx(d.IconButton,{type:"button","aria-label":h.text,...h.buttonProps,children:i.jsx(h.Icon,{})},h.key))}),i.jsx("div",{className:"sm:hidden",children:i.jsxs(d.Menu.Root,{children:[i.jsx(d.Menu.ClickTrigger,{children:i.jsx(d.IconButton,{variant:"ghost",accentColor:"base","aria-label":"Actions menu",size:"sm",children:i.jsx(d.RiIcon,{icon:"RiMore2Line"})})}),i.jsx(d.Menu.Content,{children:u.map(h=>{var g;return i.jsxs(d.Menu.Item,{onClick:(g=h.buttonProps)==null?void 0:g.onClick,children:[i.jsx(h.Icon,{}),h.text]},h.key)})})]})}),e!=="section"&&i.jsx("input",{style:{display:"none"},ref:c,type:"file",accept:"image/*",onChange:l})]})});ln.displayName="FieldActions";const Or=(t=()=>null)=>f.useMemo(()=>qo.map(n=>n.map(e=>{const r=nn[e],o=r.Icon;return{children:r.fieldTypeName,icon:i.jsx(o,{}),value:e,onSelect:()=>{t(e)}}})),[t]),fe=t=>t.type==="section",cn=f.memo(t=>{const{popoverInputs:n,hasError:e}=t;return i.jsxs(d.Popover.Root,{children:[i.jsx(d.Popover.Trigger,{asChild:!0,children:i.jsxs(d.Button,{variant:"soft",type:"button",size:"sm","aria-label":"settings",accentColor:"base",...e&&{color:ne.danger},children:[i.jsx(d.RiIcon,{icon:"RiSettings2Line"}),i.jsx("span",{children:"Settings"})]},"settings")}),i.jsx(d.Popover.Content,{size:"sm",children:i.jsx("div",{className:"flex max-w-[240px] flex-col",children:n})})]})});cn.displayName="FieldSettingsPopover";const dn=f.memo(t=>{var pt,fn,Ur,jr,kr;const{parentPath:n,index:e,initial:r,conditionalSourceFields:o}=t,{values:a,setFieldValue:s,errors:l}=U.useFormikContext(),p=Or(),c=Ve(),u=f.useRef(null),h=576,[g,y]=f.useState(u.current&&u.current.getBoundingClientRect().width>=h);f.useEffect(()=>{const M=u.current;if(M){const P=new ResizeObserver(q=>{q[0]&&y(q[0].contentRect.width>=h)});return P.observe(M),()=>{P.disconnect()}}},[]);const[w,m]=f.useState(void 0);f.useEffect(()=>{fe(r)?m(void 0):r.image instanceof Promise?r.image.then(m).catch(console.error):m(r.image)},[r]);const C=w?URL.createObjectURL(w):void 0,E=f.useCallback(M=>{M.stopPropagation();const{image:P,...q}=r;s(`${n}.${e}`,q).then()},[e,r,n,s]);f.useEffect(()=>{fe(r)&&!r.conditional&&s(`${n}.${e}.condition`,null).then()},[e,r,n,s]);const S=f.useMemo(()=>{var M,P;return fe(r)?(P=pr(a.fields,(M=r.condition)==null?void 0:M.identifier))==null?void 0:P.label:void 0},[r,a.fields]),N=fe(r)?Array.isArray((pt=r.condition)==null?void 0:pt.value)?"contains all of":"equals":void 0;let x;if(fe(r)){if(dt((fn=r.condition)==null?void 0:fn.value))throw new Error("File values are not supported for conditions.");x=Array.isArray((Ur=r.condition)==null?void 0:Ur.value)?r.condition.value.map(M=>typeof M=="string"?M:M.label).join(", "):(kr=(jr=r.condition)==null?void 0:jr.value)==null?void 0:kr.toString()}const F=f.useCallback(M=>{M.target.parentNode instanceof HTMLElement&&(M.target.parentNode.dataset.replicatedValue=M.target.value)},[]),L=f.useCallback(M=>{M.target.parentNode instanceof HTMLElement&&(M.target.parentNode.dataset.replicatedValue=M.target.value)},[]),T=r.type,D=sn[T],[$,z]=f.useMemo(()=>{let M=[],P=[];if(D===W){if(o===void 0)throw new Error("Conditional source fields must be provided when changing sections.");const q=D.getFieldCreationSchema(o,`${n}.${e}`);M=M.concat(q.filter(V=>V.showDirectly).map(V=>V.field)),P=P.concat(q.filter(V=>!V.showDirectly).map(V=>V.field))}else{if(!(D.prototype instanceof k))throw new Error(`Field must be an instance of BaseField. Got ${D.toString()}.`);const q=D.getFieldCreationSchema(`${n}.${e}`);g?(M=[...M,...q.filter(V=>V.showDirectly).map(V=>V.field)],P=[...P,...q.filter(V=>!V.showDirectly).map(V=>V.field)]):P=[...P,...q.map(V=>V.field)]}return[M,P]},[D,o,n,e,g]),A=Pe($,{formId:ht,disabled:!1,internal:!0,...D===W&&{size:"sm"}}),B=Pe(z,{formId:ht,disabled:!1});let O=z.length>0;fe(r)&&z.length>0&&(O=r.conditional);const R=z.some(M=>{const P=X(l,D===W?`${n}.${e}.condition`:M.getId());return P&&(typeof P!="object"||de(P))}),De=R?ne.danger:void 0,_e=f.useMemo(()=>ct(r),[r]),un=Wt(_e,{formId:ht,showInputOnly:!1}),ae=f.useMemo(()=>p.flat().find(M=>M.value===T),[p,T]),Me=f.useCallback(()=>{w&&c(()=>({file:w}))},[c,w]);return i.jsx("div",{className:"flex grow items-center w-full",ref:u,children:i.jsxs("div",{className:"flex w-full flex-col gap-2",children:[D===W&&($.length>0||O)&&i.jsxs("div",{className:"flex flex-col gap-2",children:[A,O&&i.jsxs("div",{className:"flex items-center gap-4",children:[i.jsx(cn,{popoverInputs:B,hasError:R}),fe(r)&&r.conditional&&i.jsx("span",{className:"text-sm text-(--accent-a11)","data-accent-color":De,children:i.jsxs("em",{children:["Display only if ",i.jsx("strong",{children:S})," ",N," ",i.jsx("strong",{children:x})]})})]})]}),D!==W&&i.jsxs("div",{className:"flex gap-2 w-full justify-between",children:[i.jsxs("div",{className:"flex gap-2 items-center",children:[i.jsxs(d.Badge,{accentColor:"base",variant:"soft",size:"sm",children:[ae==null?void 0:ae.icon,ae==null?void 0:ae.children]}),i.jsx(ue,{name:`${n}.${e}.required`,render:({setValue:M,value:P})=>i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(d.Checkbox.Root,{checked:P,onCheckedChange:M,size:"sm",children:i.jsx(d.Checkbox.Indicator,{children:i.jsx(d.RiIcon,{icon:"RiCheckLine"})})}),i.jsx(d.Text,{size:"sm",accentColor:"base",children:"Required"})]})})]}),O&&i.jsx(cn,{popoverInputs:B,hasError:R})]}),w&&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:C,alt:w.name,onClick:Me}),i.jsx(d.IconButton,{className:"absolute top-2 right-2 hidden group-hover:not-disabled:flex",variant:"solid",accentColor:"base","aria-label":"delete",onClick:E,size:"sm",children:i.jsx(d.RiIcon,{icon:"RiDeleteBin7Fill"})})]}),i.jsx(ue,{name:`${n}.${e}.label`,render:({setValue:M,value:P})=>i.jsx("input",{className:"bg-transparent outline-none text-sm",placeholder:T==="section"?"Enter a section label (optional)":"Enter your question",value:P,onChange:q=>{M(q.target.value)},onInput:F,maxLength:200})}),i.jsx(ue,{name:`${n}.${e}.description`,render:({setValue:M,value:P})=>i.jsx("textarea",{className:"bg-transparent outline-none text-sm field-sizing-content grow",placeholder:`Enter a ${T==="section"?"section":"field"} description (optional)`,value:P,onChange:q=>{M(q.target.value)},onInput:L,maxLength:1e3})}),D!==W&&$.length>0&&i.jsx("div",{className:"w-full",children:A}),D!==W&&i.jsxs(d.Card,{className:"flex gap-4 bg-(--accent-a2) items-center",children:[i.jsxs(d.HoverCard.Root,{children:[i.jsx(d.HoverCard.Trigger,{asChild:!0,children:i.jsx(d.Badge,{icon:!0,size:"sm",variant:"soft",accentColor:"base",children:i.jsx(d.RiIcon,{icon:"RiEyeLine"})})}),i.jsx(d.HoverCard.Content,{className:"w-[225px]",size:"sm",align:"start",children:"This is a preview of the field as it will be rendered in the form."})]}),i.jsx("div",{className:"grow",children:un})]})]})})});dn.displayName="FieldBuilder";const zr=f.memo(t=>{const{field:n,index:e,sectionIndex:r,remove:o}=t,{setFieldValue:a,values:s}=U.useFormikContext(),{reorderField:l}=Gt(),{showError:p}=d.useToast(),c=`fields.${r}.fields`,u=f.useMemo(()=>({index:e,parentPath:c,initial:n}),[n,e,c]),h=f.useCallback(()=>{const w=n.label??"Unlabelled field",m={...n,label:w};tt(c,e+1,m,s,a)},[n,c,e,s,a]),g=f.useCallback(w=>{const m=r,C=s.fields[m];let E=r,S=w==="up"?e-1:e+1;w==="up"&&e===0?(E=r-1,S=s.fields[E].fields.length):w==="down"&&e===C.fields.length-1&&(E=r+1,S=0);const N=s.fields[E];l(C,m,e,N,E,S,a)},[r,s.fields,e,l,a]),y=f.useCallback(w=>{const{files:m}=w.target;if(!m||m.length!==1)return;const C=m.item(0);if(C){if(C.size>$o){p({title:"File upload error",description:`The file ${C.name} exceeded the maximum file size`});return}a(`${c}.${e}`,{...n,image:C}).then()}},[n,e,c,a,p]);return i.jsx(te.Draggable,{draggableId:n.identifier,index:e,children:w=>i.jsx(d.Card,{ref:w.innerRef,...w.draggableProps,...w.dragHandleProps,className:"mb-4",children:i.jsxs("div",{className:"flex items-center justify-between gap-4 w-full",children:[i.jsx(dn,{...u}),i.jsx(ln,{index:e,type:n.type,sectionIndex:r,remove:o,duplicate:h,move:g,upload:y})]})})})});zr.displayName="FieldWithActions";const Br=f.memo(t=>{var N;const{field:n,index:e,dropState:r,fieldsOnly:o}=t,a=(N=r[n.identifier])==null?void 0:N.disabled,{setFieldValue:s,values:l}=U.useFormikContext(),p=d.useAlertDialog(),{reorderSection:c}=Gt(),u=f.useCallback((x,F)=>{for(const L of x){const T=F.indexOf(L);s(`fields.${T}.condition`,null).then(),s(`fields.${T}.conditional`,!1).then()}},[s]),h=f.useCallback(x=>{var T;const F=n.fields[x];if(!F)throw new Error("Could not find field to remove.");const L=[];for(const D of l.fields)((T=D.condition)==null?void 0:T.identifier)===F.identifier&&L.push(D);return{removing:F,affectedSections:L,action:()=>s(`fields.${e}.fields`,et(n.fields,x))}},[n.fields,l.fields,s,e]),g=f.useCallback(x=>{const{affectedSections:F,action:L,removing:T}=h(x),D=()=>{L().then(),u(F,l.fields)};if(F.length>0){const $=F.map(z=>z.label).join(", ");p({title:"Remove condition?",description:`${T.label} is being used as a condition, deleting it will remove the condition from the ${$} section(s).`,action:"Remove",onAction:D});return}D()},[h,u,l.fields,p]),y=f.useCallback(()=>{const F=n.fields.map((B,O)=>h(O)).flatMap(B=>B.affectedSections),L=F.length?"Remove fields and conditions?":"Remove fields?",T=n.fields.length,D=F.map(B=>B.label).join(", "),$=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.`,z=et(l.fields,e),A=()=>s("fields",z);if(F.length>0){p({title:L,description:$,action:"Remove",onAction:()=>{A().then(()=>{u(F,z)})}});return}A().then()},[n.fields,l.fields,e,h,s,p,u]),w=f.useCallback(x=>{const F=x==="up"?e-1:e+1;c(r,n.identifier,e,F,l,s)},[e,c,r,n.identifier,l,s]),m=f.useMemo(()=>({index:e,parentPath:"fields",initial:n,conditionalSourceFields:mr(l.fields,e)}),[n,e,l.fields]),C=f.useCallback(()=>{const x=n.label??"Untitled section",F=n.fields.map(T=>({...T,identifier:Ht(null,T.label)})),L={...n,label:x,fields:F};tt("fields",e+1,L,l,s)},[n,e,l,s]),E=f.useCallback(x=>{tt(`fields.${e}.fields`,n.fields.length,_o[x],l,s)},[e,n.fields.length,l,s]),S=Or(E);return i.jsx(te.Draggable,{draggableId:n.identifier,index:e,children:x=>i.jsx(d.Card,{ref:x.innerRef,...x.draggableProps,...x.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(dn,{...m}),i.jsx(te.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(zr,{field:L,index:T,sectionIndex:e,remove:()=>{g(T)}},L.identifier)),F.placeholder,i.jsxs(d.Menu.Root,{children:[i.jsx(d.Menu.ClickTrigger,{children:i.jsxs(d.Button,{type:"button",variant:"soft",size:"sm",children:[i.jsx(d.RiIcon,{icon:"RiAddLine"})," Add field"]})}),i.jsx(d.Menu.Content,{children:S.flat().map(L=>i.jsxs(d.Menu.Item,{onSelect:L.onSelect,children:[L.icon,L.children]},L.value))})]})]})})]}),!o&&i.jsx(ln,{index:e,type:n.type,remove:y,duplicate:C,move:w})]})})})});Br.displayName="FieldSectionWithActions";const _r=(t,n)=>{for(const[e,r]of Object.entries(t))if(r.identifier===n)return[r,e]},$r=f.memo(t=>{const{fieldsOnly:n}=t,{values:e,setFieldValue:r}=U.useFormikContext(),[o,a]=f.useReducer(Ho,e.fields,Pr),{reorderSection:s,reorderField:l}=Gt();f.useEffect(()=>{a({type:"update",state:Pr(e.fields)})},[a,e.fields]);const p=f.useCallback(h=>{h.type==="SECTION"&&a({type:"hold",fieldId:h.draggableId})},[]),c=f.useCallback(h=>{const{source:g,destination:y,type:w,reason:m,draggableId:C}=h;if(a({type:"release"}),!y||m==="CANCEL")return;if(w==="ROOT"){s(o,C,g.index,y.index,e,r);return}if(w!=="SECTION")throw new Error("Unexpected droppable type.");const[E,S]=_r(e.fields,g.droppableId)??[],[N,x]=_r(e.fields,y.droppableId)??[];l(E,S,g.index,N,x,y.index,r)},[e,l,r,s,o]),u=f.useCallback(h=>{Do(h+1,e,r)},[e,r]);return i.jsx(te.DragDropContext,{onDragStart:p,onDragEnd:c,children:i.jsx(te.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((g,y)=>i.jsxs(f.Fragment,{children:[i.jsx(Br,{field:g,index:y,dropState:o,fieldsOnly:n}),!n&&y!==e.fields.length-1&&i.jsxs(d.Button,{className:"mb-4",type:"button",variant:"soft",size:"sm",accentColor:"base",onClick:()=>{u(y)},children:[i.jsx(d.RiIcon,{icon:"RiAddLine"})," Add section"]})]},g.identifier)),i.jsxs(d.Button,{className:"mb-4",type:"button",variant:"soft",accentColor:"base",size:"sm",onClick:()=>{u(e.fields.length)},children:[i.jsx(d.RiIcon,{icon:"RiAddLine"})," Add section"]}),h.placeholder]})})})});$r.displayName="FieldsEditor";const Xo=()=>{alert("This is a form preview, your data will not be saved.")},Ko=f.memo(f.forwardRef((t,n)=>{const{onCancel:e,onSave:r,revision:o,initialTitle:a,showExplainerText:s=!0,showFormTitle:l=!0,fieldsOnly:p=!1,showTabs:c=!0,tabsListClassName:u,hydrateRevisionWithImages:h}=t,{showError:g}=d.useToast(),y=f.useCallback(S=>{const N={};S.title||(N.title="Title is required."),(!S.fields||S.fields.length===0)&&(N.fields="At least one field is required.");let x=[];for(const[L,T]of S.fields.entries()){const $=sn.section.getFieldCreationSchema(mr(S.fields,L),`fields.${L}`).map(z=>z.field);x=[...x,...$];for(const[z,A]of T.fields.entries()){const O=sn[A.type].getFieldCreationSchema(`fields.${L}.fields.${z}`).map(R=>R.field);x=[...x,...O]}}const F=ut({fields:x},S);if(F&&(N.fields=F.fields),de(N))return g({title:"Some form settings are invalid",description:"Please check settings highlighted in red."}),N},[g]),w=f.useMemo(()=>({title:a??"",description:"",fields:[{...Re(Ht(null,"")),label:""}]}),[a]),m=o?h(o):void 0,C=U.useFormik({initialValues:Lo(m)??w,validate:y,onSubmit:r,validateOnChange:!1,validateOnBlur:!1}),E=f.useMemo(()=>Dr(C.values),[C.values]);return i.jsx(d.Tabs.Root,{ref:n,defaultValue:"edit",children:i.jsxs("div",{className:"flex flex-col gap-2",children:[c&&i.jsxs(d.Tabs.List,{className:he("sticky top-0 z-[2000] flex bg-(--color-background)",u),children:[i.jsx(d.Tabs.Trigger,{className:"grow",value:"edit",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(d.RiIcon,{icon:"RiPencilLine"}),"Edit form"]})}),i.jsx(d.Tabs.Trigger,{className:"grow",value:"preview",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(d.RiIcon,{icon:"RiEyeLine"}),"Preview form"]})})]}),i.jsxs(d.Tabs.Content,{value:"edit",children:[s&&i.jsxs(d.Text,{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:ht,onSubmit:C.handleSubmit,children:[i.jsxs(U.FormikProvider,{value:C,children:[l&&i.jsxs(i.Fragment,{children:[i.jsx(ue,{name:"title",render:({setValue:S,value:N,meta:x})=>i.jsx(Ut,{severity:"danger",helpText:x.error??null,children:i.jsx(d.Input.Root,{variant:"outline",size:"md",accentColor:x.error?ne.danger:"primary",children:i.jsx(d.Input.Field,{placeholder:"Form title",value:N,onChange:F=>{S(F.target.value)},maxLength:100})})})}),i.jsx(ue,{name:"description",render:({setValue:S,value:N})=>i.jsx(d.TextArea,{className:"field-sizing-content",placeholder:"Explain the purpose of this form",value:N,onChange:x=>{S(x.target.value)},resize:"vertical",maxLength:1e3,size:"md"})})]}),i.jsx($r,{fieldsOnly:p}),i.jsx("span",{"data-accent-color":ne.danger,className:"text-xs text-(--accent-a11)",children:typeof C.errors.fields=="string"&&C.errors.fields})]}),i.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e&&i.jsx(d.Button,{type:"button",variant:"solid",accentColor:"base",onClick:e,children:"Cancel"}),i.jsx(d.Button,{type:"submit",children:"Save form"})]})]})]}),i.jsx(d.Tabs.Content,{value:"preview",children:i.jsx(Ar,{schema:E,onSubmit:Xo,hideTitle:!l})})]})})})),Qo=Object.values(H.Colors),Yo=1;async function Jo(t,n,e,r){const o=t.getContext("2d",{}),a=new Image(r.width,r.height),s=new Image(r.width,r.height),l=new H.DeferredPromise;return a.onload=function(){o.drawImage(a,0,0,r.width,r.height),s.src=URL.createObjectURL(e),s.onload=async function(){o.drawImage(s,0,0,r.width,r.height);const p=t.toDataURL("image/jpeg",Yo),c=await H.fileToBlob(p),u=new File([c],n.name,{type:"image/jpeg"});l.resolve(u)}},a.src=URL.createObjectURL(n),l}const Vr=f.memo(t=>{const{file:n,onClose:e,onSave:r,onDelete:o,dirty:a,onDirty:s}=t;n.objectURL||(n.objectURL=URL.createObjectURL(n));const l=f.useRef(null),p=f.useRef(null),[c,u]=f.useState(H.Colors.red),[h,g]=f.useState(null),[y,w]=f.useState(!1),[m,C]=f.useState(!1),E=f.useRef(null),S=d.useSize(E);f.useEffect(()=>{const O=new Image;O.onload=function(){g({width:O.naturalWidth,height:O.naturalHeight})},O.src=URL.createObjectURL(n)},[n]),f.useEffect(()=>{!m&&(S!=null&&S.width)&&S.height&&C(!0)},[S,m]);const N=f.useCallback(async()=>{a||e();const O=l.current;if(!O)return;if(!h)throw new Error("Original image size not loaded yet");const R=await O.exportImage("png"),De=new Image(h.width,h.height);De.onload=async function(){const _e=await H.fileToBlob(R),un=new File([_e],n.name,{type:n.type}),ae=p.current,Me=await Jo(ae,n,un,h);Me.objectURL=URL.createObjectURL(Me);const pt=await H.hashFile(n);await H.hashFile(Me)!==pt&&r(Me),w(!1),e()},w(!0),De.src=R},[a,n,e,r,h]),x=f.useCallback(()=>{o(n)},[n,o]),F=f.useCallback(()=>{e()},[e]),L=f.useCallback(()=>{s(!0)},[s]),T=f.useCallback(()=>{l.current&&l.current.redo()},[]),D=f.useCallback(()=>{l.current&&l.current.undo()},[]),$=f.useCallback(()=>{l.current&&(s(!1),l.current.clearCanvas())},[s]),z=f.useCallback(O=>{l.current&&l.current.eraseMode(O)},[]),A=f.useCallback(()=>{N()},[N]),B=f.useCallback(()=>{H.downloadFile(n)},[n]);return i.jsx(zt,{open:!0,onOpenChange:e,children:i.jsxs(Bt,{children:[i.jsx(_t,{className:"bg-(--color-background) fixed inset-0 data-[state='open']:fade-in-0 data-[state='open']:zoom-in-95 data-[state='closed']:animate-out data-[state='closed']:fade-out-0 data-[state='closed']:zoom-out-95 data-[state='open']:animate-in","data-floating-content":""}),i.jsxs($t,{className:"absolute inset-0 py-12","data-floating-content":"",children:[i.jsx(d.ButtonGroup,{className:"flex w-full gap-2 items-center top-0 absolute right-0 p-2",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(d.IconButton,{"aria-label":"close",onClick:F,children:i.jsx(d.RiIcon,{icon:"RiCloseLine"})}),i.jsx(d.IconButton,{"aria-label":`Download ${n.name}`,onClick:B,children:i.jsx(d.RiIcon,{icon:"RiDownload2Line"})})]}),i.jsxs("div",{className:"flex items-center justify-center gap-2",children:[i.jsx(gt,{selectedColor:c,allColors:Qo,onFinish:u,trigger:i.jsx(d.IconButton,{"aria-label":"Markup color picker",type:"button",variant:"solid",style:{backgroundColor:c},children:" "})}),i.jsx(d.IconToggleButton,{defaultPressed:!1,"aria-label":"erase",onPressedChange:z,children:i.jsx(d.RiIcon,{icon:"RiEraserFill"})}),i.jsx(d.Separator,{orientation:"vertical",size:"full"}),i.jsx(d.IconButton,{"aria-label":"undo",onClick:D,children:i.jsx(d.RiIcon,{icon:"RiArrowGoBackLine"})}),i.jsx(d.IconButton,{"aria-label":"undo",onClick:T,children:i.jsx(d.RiIcon,{icon:"RiArrowGoForwardLine"})}),i.jsx(d.IconButton,{"aria-label":"undo all",onClick:$,children:i.jsx(d.RiIcon,{icon:"RiLoopLeftLine"})})]}),i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(d.IconButton,{"aria-label":"Save markup",accentColor:"primary",onClick:A,children:i.jsx(d.RiIcon,{icon:"RiSaveLine"})}),i.jsx(d.IconButton,{"aria-label":"Delete attachment",onClick:x,children:i.jsx(d.RiIcon,{icon:"RiDeleteBin2Line"})})]})]})}),h&&i.jsx("canvas",{id:"attachment-markup-canvas",className:"hidden",ref:p,width:h.width,height:h.height}),i.jsxs("div",{className:"relative size-full flex items-center justify-center p-4 overflow-hidden",children:[i.jsx("img",{className:"max-w-full max-h-full invisible absolute",alt:"Photo attachment",ref:E,src:n.objectURL}),y?i.jsx(d.Spinner,{}):i.jsx(Hr.ReactSketchCanvas,{className:"max-w-full max-h-full aspect-square",backgroundImage:n.objectURL,ref:l,onStroke:L,strokeColor:c},m?"1":"0")]})]})]})})});Vr.displayName="AttachmentEditor",b.BaseField=k,b.BaseFormElement=yt,b.BooleanField=Ce,b.BooleanInput=jt,b.ColorPicker=gt,b.DateField=Je,b.DateInput=kt,b.FieldSection=W,b.FileBadge=yn,b.FileCard=vt,b.FileIcon=Ae,b.FormBuilder=Ko,b.FormRenderer=Ar,b.ImageCard=Nr,b.ImageMarkup=Vr,b.ImageViewer=Vt,b.ImageViewerProvider=cr,b.InputWithHelpText=Ut,b.InputWithLabel=Q,b.InputWithLabelAndHelpText=Y,b.MultiSelectField=ze,b.MultiSelectInput=Jt,b.MultiStringField=Oe,b.MultiStringInput=Xt,b.NumberField=oe,b.NumberInput=Kt,b.PatchField=ue,b.PatchFormProvider=Wo,b.QrField=nt,b.QrInput=Qt,b.QrScanner=Yt,b.SUPPORTED_IMAGE_FILE_TYPES=mn,b.SUPPORTED_PDF_FILE_TYPES=vn,b.SUPPORTED_SPREADSHEET_FILE_EXTENSIONS=gn,b.SelectField=Be,b.SelectInput=Zt,b.StringField=it,b.StringInput=Rt,b.TextField=ot,b.TextInput=en,b.decodeFormValues=Vo,b.deserialize=ct,b.deserializeField=rn,b.emptyBaseField=G,b.emptyBooleanField=dr,b.emptyDateField=ur,b.emptyMultiSelectField=wr,b.emptyMultiStringField=gr,b.emptyNumberField=vr,b.emptyQrField=Cr,b.emptySelectField=Ir,b.emptyStringField=Er,b.emptyTextField=Sr,b.encodeFormValues=Uo,b.flattenFields=on,b.formRevisionToSchema=Dr,b.initialFormValues=ft,b.isConditionMet=an,b.useFieldInput=Wt,b.useFieldInputs=Pe,b.useFormikInput=_,b.useImageViewer=Ve,b.validateForm=ut,b.valueIsFile=dt,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@overmap-ai/forms",
3
3
  "private": false,
4
- "version": "1.0.17-file-viewer-updates.8",
4
+ "version": "1.0.17-file-viewer-updates.10",
5
5
  "license": "UNLICENSED",
6
6
  "main": "dist/forms.umd.cjs",
7
7
  "module": "dist/forms.js",