@overmap-ai/forms 1.0.40-file-component-improvements.3 → 1.0.40-file-component-improvements.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/forms.js +2 -2
- package/dist/forms.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/forms.js
CHANGED
|
@@ -2167,7 +2167,7 @@ const _o = L((r) => {
|
|
|
2167
2167
|
...s,
|
|
2168
2168
|
children: [
|
|
2169
2169
|
!t && !n && /* @__PURE__ */ p("div", { className: "absolute inset-0 flex grow items-center justify-center", children: /* @__PURE__ */ p(ti, {}) }),
|
|
2170
|
-
!!t && !n && /* @__PURE__ */ p("div", { className: "flex
|
|
2170
|
+
!!t && !n && /* @__PURE__ */ p("div", { className: "flex min-h-0 flex-1 items-center justify-center overflow-hidden p-3", children: /* @__PURE__ */ p(br, { className: "size-full max-w-full object-cover", file: t }) }),
|
|
2171
2171
|
(!!t || !!n) && /* @__PURE__ */ _(Ie, { children: [
|
|
2172
2172
|
/* @__PURE__ */ p(Vt, { size: "full" }),
|
|
2173
2173
|
/* @__PURE__ */ _("div", { className: "flex w-full shrink-0 items-center gap-2 self-end p-3", children: [
|
|
@@ -2197,7 +2197,7 @@ const Eo = L((r) => {
|
|
|
2197
2197
|
...s,
|
|
2198
2198
|
children: [
|
|
2199
2199
|
!t && !i && /* @__PURE__ */ p("div", { className: "absolute inset-0 flex grow items-center justify-center", children: /* @__PURE__ */ p(ti, {}) }),
|
|
2200
|
-
!!t && !i && /* @__PURE__ */ p("div", { className: "flex
|
|
2200
|
+
!!t && !i && /* @__PURE__ */ p("div", { className: "flex min-h-0 flex-1 items-center justify-center overflow-hidden p-3", children: /* @__PURE__ */ p(Ao, { className: "size-full max-w-full object-cover", file: t, controls: !0 }) }),
|
|
2201
2201
|
(!!t || !!i) && /* @__PURE__ */ _(Ie, { children: [
|
|
2202
2202
|
/* @__PURE__ */ p(Vt, { size: "full" }),
|
|
2203
2203
|
/* @__PURE__ */ _("div", { className: "flex w-full shrink-0 items-center gap-2 self-end p-3", children: [
|
package/dist/forms.umd.cjs
CHANGED
|
@@ -253,7 +253,7 @@
|
|
|
253
253
|
*
|
|
254
254
|
* This source code is licensed under the ISC license.
|
|
255
255
|
* See the LICENSE file in the root directory of this source tree.
|
|
256
|
-
*/const at=R("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),Cn=y.memo(r=>{const{ref:e,file:t,className:n,error:i,rightSlot:a,size:o,...s}=r,l=()=>i?d.jsxs(d.Fragment,{children:[d.jsx(v.LuIcon,{icon:El,color:"var(--base-a11)"}),d.jsx(v.Text,{accentColor:"base",className:"truncate",size:o,children:i})]}):t?d.jsxs(d.Fragment,{children:[d.jsx(v.LuIcon,{icon:Fl,color:"var(--base-a11)"}),d.jsx(v.Text,{className:"truncate",size:o,children:t.name})]}):d.jsx(d.Fragment,{children:d.jsx("div",{className:"flex w-full justify-center",children:d.jsx(v.Spinner,{size:o})})});return d.jsxs(v.Card,{className:et.cx(n,"flex w-full items-center gap-2"),ref:e,size:"xs",...s,children:[l(),a]})});Cn.displayName="FileCard";function Jt(r){return Array.isArray(r)?r.every(e=>typeof e=="string"):!1}class er{constructor(){M(this,"observers",new Set)}notify(e){for(const t of this.observers)t(e)}observe(e){return this.observers.add(e),()=>{this.observers.delete(e)}}}class mn extends er{constructor(t){const{identifier:n}=t;super();M(this,"identifier");this.identifier=n}getOptions(){return{identifier:this.identifier}}setOptions(t){this.identifier=t.identifier??this.identifier,this.notify(this)}serialize(){return{type:this.type,identifier:this.identifier}}}class Ve extends mn{constructor(t){const{label:n,description:i=null,required:a,image:o,...s}=t;super(s);M(this,"label");M(this,"description");M(this,"required");M(this,"image");this.label=n,this.description=i,this.required=a,this.image=o}getError(t){if(!(!this.required&&this.isValueBlank(t))){if(this.required&&this.isValueBlank(t))return"This field is required.";for(const n of this.getFieldValidators()){const i=n(t);if(i)return i}}}serialize(){return{...super.serialize(),label:this.label,description:this.description,required:this.required,image:this.image}}getOptions(){return{...super.getOptions(),label:this.label,description:this.description,required:this.required,image:this.image}}setOptions(t){const{label:n,description:i=null,required:a,image:o,...s}=t;this.label=n??this.label,this.description=i??this.description,this.required=a??this.required,this.image=o??this.image,super.setOptions(s)}isValueBlank(t){return this.areValuesEqual(t,this.blankValue())}cleanValue(t){return t}isValueClean(t){return this.areValuesEqual(t,this.cleanValue(t))}cleanSerializedValue(t){return t}isSerializedValueClean(t){return this.areSerializedValuesEqual(t,this.cleanSerializedValue(t))}isSerializedValueBlank(t){return this.areSerializedValuesEqual(t,this.blankSerializedValue())}getFieldValidators(){return[]}}const ce=y.createContext({}),wn=r=>{const[e,t]=y.useState(null);return y.useEffect(()=>{const n=URL.createObjectURL(r);return t(n),()=>{URL.revokeObjectURL(n)}},[r]),e},Lt=y.memo(r=>{const{file:e,...t}=r,n=wn(e);return n?d.jsx("img",{src:n,alt:e.name,...t}):null});Lt.displayName="ImageFile";const ya=y.createContext(()=>{throw new Error("No ImageViewerProvider found")}),Pr=()=>y.useContext(ya),_n=y.memo(r=>{const{file:e,onClose:t}=r,n=y.useCallback(()=>{ta.saveAs(e,e.name)},[e]);return d.jsx(v.Overlay.Root,{open:!0,onOpenChange:t,children:d.jsxs(v.Overlay.Content,{onOpenAutoFocus:v.preventDefault,children:[d.jsxs(v.ButtonGroup,{className:"absolute right-0 top-0 flex items-center gap-2 p-2",accentColor:"base",variant:"ghost",children:[d.jsxs(v.Tooltip.Root,{children:[d.jsx(v.Tooltip.Trigger,{asChild:!0,children:d.jsx(v.IconButton,{onClick:n,"aria-label":"download",children:d.jsx(v.LuIcon,{icon:ca})})}),d.jsx(v.Tooltip.Content,{size:"sm",children:"Download"})]}),d.jsx(v.Separator,{orientation:"vertical",size:"sm"}),d.jsx(v.Overlay.Close,{asChild:!0,children:d.jsx(v.IconButton,{onClick:t,"aria-label":"close",children:d.jsx(v.LuIcon,{icon:at})})})]}),d.jsx("figure",{className:"flex size-full items-center justify-center overflow-hidden p-4",children:d.jsx(Lt,{className:"max-h-full max-w-full",file:e})})]})})});_n.displayName="ImageViewer";const Ca=y.memo(r=>{const{children:e}=r,[t,n]=y.useState(null),i=y.useCallback(()=>{n(null)},[]),a=y.useCallback(s=>{n(s(i))},[i]),o=y.useCallback(()=>{t&&(t.onClose&&t.onClose(),i())},[i,t]);return d.jsxs(ya.Provider,{value:a,children:[e,t&&d.jsx(_n,{file:t.file,onClose:o})]})});Ca.displayName="FileViewerProvider";const de=y.memo(r=>{const{label:e,error:t,description:n,required:i,children:a,inputId:o,image:s,size:l}=r,[u,c]=y.useState(void 0),f=Pr();y.useEffect(()=>{s instanceof Promise?s.then(c).catch(console.error):c(s)},[s]);const h=y.useCallback(()=>{u&&f(()=>({file:u}))},[f,u]),p=i?`${e} *`:e;return d.jsxs("div",{className:"flex flex-col gap-1",children:[u&&d.jsx(Lt,{className:"h-[100px] w-full min-w-[300px] cursor-pointer rounded-md object-cover",file:u,onClick:h}),(!!e||!!n)&&d.jsxs("div",{className:"flex flex-col",children:[d.jsx("label",{className:"w-max max-w-full",htmlFor:o,children:d.jsx(v.Text,{size:l,className:"text-wrap",children:p})}),!!n&&d.jsx(v.Text,{accentColor:"base",size:l,children:n})]}),a,!!t&&d.jsx(v.Text,{accentColor:"danger",size:l,children:t})]})});de.displayName="InputWithLabel";const ma=r=>r.map(e=>d.jsx(y.Fragment,{children:e.render()},e.identifier)),Br=r=>r.map(e=>d.jsx(y.Fragment,{children:e.render()},e.identifier)),me=r=>{const{field:e}=r,{field:{value:t,name:n,onChange:i,onBlur:a,disabled:o},fieldState:{isTouched:s,error:l}}=je.useController({name:e.identifier});return{value:t,name:n,disabled:o,isTouched:s,error:(l==null?void 0:l.message)??"",onChange:i,onBlur:a}},An=y.memo(r=>{const{field:e}=r,{size:t}=y.use(ce),{value:n,name:i,onBlur:a,onChange:o,error:s,disabled:l}=me({field:e}),[u,c]=y.useState(""),[f,h]=y.useState(""),p=y.useCallback(S=>{o(S),a()},[o,a]),g=y.useCallback(S=>{n&&n.findIndex(O=>O===S.target.value.trim())>=0?h("All options must be unique"):S.target.value?h(""):h("Option cannot be empty"),c(S.target.value)},[c,n]),x=y.useCallback(()=>{if(f)return;if(!u.trim()){h("Option cannot be empty");return}const S=u.trim();p([...n,S]),c("")},[u,f,p,n]),m=y.useCallback(S=>{S.key==="Enter"&&(S.preventDefault(),x())},[x]),w=y.useCallback(S=>{const O=Array.from(n);O.splice(S,1),p(O)},[n,p]),_=y.useCallback(S=>{if(!S.destination)return;const O=S.source.index,N=S.destination.index,T=Array.from(n),[V]=T.splice(O,1);T.splice(N,0,V),p(T)},[p,n]),E=y.useCallback(()=>{a()},[a]);return d.jsx(gn.DragDropContext,{onDragEnd:_,children:d.jsxs(de,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:f||s,image:e.image,children:[(!l||n.length===0)&&d.jsxs("div",{className:"flex gap-2",children:[d.jsx(v.Input.Root,{className:"grow",accentColor:"base",variant:"surface",size:t,children:d.jsx(v.Input.Field,{value:u,onChange:g,onKeyDown:m,id:e.identifier,placeholder:e.placeholder,onBlur:E,name:i,disabled:l})}),d.jsx(v.IconButton,{size:t,accentColor:"base",variant:"soft",type:"button","aria-label":"Add option",disabled:!!f||l,onClick:x,children:d.jsx(v.LuIcon,{icon:Ye})})]}),n.length!==0&&d.jsx(gn.Droppable,{droppableId:`${e.identifier}-droppable`,children:S=>d.jsxs("div",{className:"flex flex-col gap-1",...S.droppableProps,ref:S.innerRef,children:[n.map((O,N)=>d.jsx(gn.Draggable,{draggableId:`${O}-draggable`,index:N,isDragDisabled:l,children:({draggableProps:T,dragHandleProps:V,innerRef:L})=>d.jsxs(v.Badge,{...V,...T,ref:L,className:"flex items-center justify-between gap-2",accentColor:"base",size:t,variant:"soft",children:[d.jsx(v.Text,{className:"truncate",highContrast:!0,children:typeof O=="object"&&"label"in O?O.label:O}),d.jsx(v.IconButton,{className:"bg-transparent!",size:t,variant:"ghost",type:"button","aria-label":"Delete option",accentColor:"base",disabled:l,onClick:()=>{w(N)},children:d.jsx(v.LuIcon,{icon:at})})]})},`${e.identifier}-${O}-${N}`)),S.placeholder]})})]})})});An.displayName="MultiStringFieldInput";class xt extends Ve{constructor(t){const{minimum_length:n,maximum_length:i,placeholder:a,...o}=t;super(o);M(this,"type","multi-string");M(this,"minLength");M(this,"maxLength");M(this,"placeholder");this.minLength=n??0,this.maxLength=i??1/0,this.placeholder=a??"Press enter to add a new option"}render(){return d.jsx(An,{field:this})}serialize(){return{...super.serialize(),minimum_length:this.minLength,maximum_length:this.maxLength,placeholder:this.placeholder}}getOptions(){return{...super.getOptions(),minimum_length:this.minLength,maximum_length:this.maxLength,placeholder:this.placeholder}}duplicate(t){return new xt({...this.getOptions(),identifier:t})}setOptions(t){const{minimum_length:n,maximum_length:i,placeholder:a,...o}=t;this.minLength=n??this.minLength,this.maxLength=i??this.maxLength,this.placeholder=a??this.placeholder,super.setOptions(o)}serializeValue(t){return t}deserializeValue(t){return t}getFieldValidators(){const t=super.getFieldValidators();return t.push(n=>{if(n.length<this.minLength)return`Must have at least ${this.minLength} options.`}),t.push(n=>{if(n.length>this.maxLength)return`Must have at most ${this.maxLength} options.`}),t}static deserialize(t){return new xt(t)}isSerializedValue(t){return Jt(t)}isValue(t){return Jt(t)}blankValue(){return[]}areValuesEqual(t,n){const i=new Set(t),a=new Set(n);return i.size===a.size&&i.isSubsetOf(a)}blankSerializedValue(){return[]}areSerializedValuesEqual(t,n){const i=new Set(t),a=new Set(n);return i.size===a.size&&i.isSubsetOf(a)}}class tr extends Ve{constructor(t){const{options:n,...i}=t;super(i);M(this,"options");this.options=n.map(a=>(typeof a=="string"&&(a={label:a,value:a}),a))}serialize(){return{...super.serialize(),options:this.options}}getOptions(){return{...super.getOptions(),options:this.options}}setOptions(t){const{options:n,...i}=t;this.options=(n==null?void 0:n.map(a=>(typeof a=="string"&&(a={label:a,value:a}),a)))??this.options,super.setOptions(i)}static getFieldCreationSchema(t=""){const n=t&&`${t}.`;return[{field:new xt({label:"Options",description:"List possible options for the user to select from.",required:!0,identifier:`${n}options`,minimum_length:2}),showDirectly:!0}]}}const Sn=y.memo(r=>{const{field:e}=r,{size:t}=y.use(ce),{value:n,name:i,onBlur:a,onChange:o,error:s,disabled:l}=me({field:e}),u=y.useCallback(f=>{o(!!f),a()},[a,o]),c=y.useCallback(()=>{a()},[a]);return d.jsx(de,{size:t,inputId:e.identifier,label:e.label,description:e.description,error:s,image:e.image,required:e.required,children:d.jsx(v.Checkbox.Root,{id:e.identifier,name:i,checked:n??!1,onCheckedChange:u,onBlur:c,size:t,accentColor:"base",variant:"surface",disabled:l,children:d.jsx(v.Checkbox.Indicator,{children:d.jsx(v.LuIcon,{icon:ke})})})})});Sn.displayName="BooleanFieldInput";class yt extends Ve{constructor(t){super(t);M(this,"type","boolean")}serialize(){return super.serialize()}getOptions(){return super.getOptions()}setOptions(t){super.setOptions(t)}duplicate(t){return new yt({...this.getOptions(),identifier:t})}static deserialize(t){return new yt(t)}serializeValue(t){return t}deserializeValue(t){return t}render(){return d.jsx(Sn,{field:this})}isSerializedValue(t){return typeof t=="boolean"}isValue(t){return typeof t=="boolean"}blankValue(){return!1}blankSerializedValue(){return!1}areSerializedValuesEqual(t,n){return t===n}areValuesEqual(t,n){return t===n}}const En=y.memo(r=>{const{field:e}=r,{size:t}=y.use(ce),{value:n,name:i,onBlur:a,onChange:o,error:s,disabled:l}=me({field:e}),u=y.useCallback(h=>{const p=h.target.valueAsNumber,g=isNaN(p)?null:p;o(g)},[o]),c=y.useCallback(()=>{a()},[a]),f=y.useCallback(h=>{h.key==="Enter"&&h.preventDefault()},[]);return d.jsx(de,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:s,image:e.image,children:d.jsx(v.Input.Root,{accentColor:"base",variant:"surface",size:t,children:d.jsx(v.Input.Field,{id:e.identifier,name:i,onChange:u,onBlur:c,value:n??"",type:"number",min:e.minimum,max:e.maximum,step:e.integers?1:"any",placeholder:e.placeholder??"Enter a number",disabled:l,onKeyDown:f})})})});En.displayName="NumberFieldInput";class Pe extends Ve{constructor(t){const{minimum:n=Number.MIN_SAFE_INTEGER,maximum:i=Number.MAX_SAFE_INTEGER,integers:a=!1,placeholder:o,...s}=t;super(s);M(this,"type","number");M(this,"minimum");M(this,"maximum");M(this,"integers");M(this,"placeholder");this.minimum=n,this.maximum=i,this.integers=a,this.placeholder=o}static getFieldCreationSchema(t=""){const n=t&&`${t}.`;return[{field:new Pe({label:"Minimum",description:"Minimum value",integers:!0,required:!1,identifier:`${n}minimum`}),showDirectly:!1},{field:new Pe({label:"Maximum",description:"Maximum value",integers:!0,required:!1,identifier:`${n}maximum`}),showDirectly:!1},{field:new yt({label:"Integers",description:"Whole numbers only",required:!1,identifier:`${n}integers`}),showDirectly:!1}]}getFieldValidators(){const t=super.getFieldValidators(),n=this.minimum,i=this.maximum;return typeof n=="number"&&t.push(a=>{if(typeof a=="number"&&a<n)return`Must be at least ${this.minimum}.`}),typeof i=="number"&&t.push(a=>{if(typeof a=="number"&&a>i)return`Must be at most ${this.maximum}.`}),this.integers&&t.push(a=>{if(typeof a=="number"&&!Number.isInteger(a))return"Must be a whole number."}),t}serialize(){return{...super.serialize(),minimum:this.minimum,maximum:this.maximum,integers:this.integers,placeholder:this.placeholder}}getOptions(){return{...super.getOptions(),minimum:this.minimum,maximum:this.maximum,integers:this.integers,placeholder:this.placeholder}}duplicate(t){return new Pe({...this.getOptions(),identifier:t})}setOptions(t){const{minimum:n,maximum:i,integers:a,placeholder:o,...s}=t;this.minimum=n??this.minimum,this.maximum=i??this.maximum,this.integers=a??this.integers,this.placeholder=o??this.placeholder,super.setOptions(s)}static deserialize(t){return new Pe(t)}serializeValue(t){return t}deserializeValue(t){return t}render(){return d.jsx(En,{field:this})}isSerializedValue(t){return this.isValue(t)}isValue(t){return typeof t=="number"&&!isNaN(t)||t===null}areValuesEqual(t,n){return t===n}blankValue(){return null}blankSerializedValue(){return null}areSerializedValuesEqual(t,n){return t===n}}const rr=1e4;class In extends Ve{constructor(t){const{minLength:n,maxLength:i,placeholder:a="",...o}=t;super(o);M(this,"minLength");M(this,"maxLength");M(this,"placeholder");this.minLength=n?Math.max(n,0):void 0,this.maxLength=i?Math.max(i,0):rr,this.placeholder=a}static getFieldCreationSchema(t=""){const n=t&&`${t}.`;return[{field:new Pe({label:"Minimum length",description:"Minimum number of characters",required:!1,identifier:`${n}minimum_length`,minimum:0,maximum:100,integers:!0}),showDirectly:!1},{field:new Pe({label:"Maximum length",description:"Maximum number of characters",required:!1,identifier:`${n}maximum_length`,minimum:1,maximum:rr,integers:!0}),showDirectly:!1}]}getFieldValidators(){const t=super.getFieldValidators();return this.minLength&&t.push(n=>{if(this.minLength&&(!n||n.length<this.minLength))return!this.required&&!n?void 0:`Minimum ${this.minLength} character(s).`}),this.maxLength&&t.push(n=>{if(typeof n=="string"&&this.maxLength&&n.length>this.maxLength)return`Maximum ${this.maxLength} character(s).`}),t}serialize(){return{...super.serialize(),minimum_length:this.minLength,maximum_length:this.maxLength,placeholder:this.placeholder}}getOptions(){return{...super.getOptions(),minLength:this.minLength,maxLength:this.maxLength,placeholder:this.placeholder}}setOptions(t){const{minLength:n,maxLength:i,placeholder:a,...o}=t;this.minLength=n,this.maxLength=i??this.maxLength,this.placeholder=a,super.setOptions(o)}serializeValue(t){return t}deserializeValue(t){return t}isSerializedValue(t){return typeof t=="string"}isValue(t){return typeof t=="string"}blankValue(){return""}blankSerializedValue(){return""}areSerializedValuesEqual(t,n){return t===n}areValuesEqual(t,n){return t===n}}const On=y.memo(r=>{const{field:e}=r,{size:t}=y.use(ce),{value:n,name:i,onBlur:a,onChange:o,error:s,disabled:l}=me({field:e}),u=y.useCallback(f=>{o(f),a()},[a,o]),c=y.useCallback(()=>{a()},[a]);return d.jsx(de,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:s,image:e.image,children:d.jsx(v.CheckboxGroup.Root,{id:e.identifier,name:i,className:"flex flex-col gap-1",accentColor:"base",variant:"surface",size:t,values:n,onValuesChange:u,disabled:l,children:e.options.map((f,h)=>d.jsxs("label",{className:"flex min-w-0 items-center gap-2",children:[d.jsx(v.CheckboxGroup.Item,{value:f.value,onBlur:c,children:d.jsx(v.CheckboxGroup.ItemIndicator,{children:d.jsx(v.LuIcon,{icon:ke})})}),d.jsx(v.Text,{size:t,accentColor:"base",className:"truncate",children:f.label})]},`${e.identifier}-${f.value}-${h}`))})})});On.displayName="CheckboxListFieldInput";class Ct extends tr{constructor(t){super(t);M(this,"type","checkbox-list")}serialize(){return super.serialize()}getOptions(){return super.getOptions()}duplicate(t){return new Ct({...this.getOptions(),identifier:t})}static deserialize(t){return new Ct(t)}serializeValue(t){return t}deserializeValue(t){return t}render(){return d.jsx(On,{field:this})}isSerializedValue(t){if(!Jt(t))return!1;const n=new Set(this.options.map(({value:i})=>i));return t.every(i=>n.has(i))}isValue(t){return this.isSerializedValue(t)}blankValue(){return[]}blankSerializedValue(){return[]}areSerializedValuesEqual(t,n){const i=new Set(t),a=new Set(n);return i.size===a.size&&i.isSubsetOf(a)}areValuesEqual(t,n){const i=new Set(t),a=new Set(n);return i.size===a.size&&i.isSubsetOf(a)}}const bn=y.memo(r=>{const{field:e}=r,{size:t}=y.use(ce),{value:n,name:i,onBlur:a,onChange:o,error:s,disabled:l}=me({field:e}),[u,c]=y.useState(!1),f=y.useCallback(p=>{o(p??null),a(),c(!1)},[o,a]),h=y.useCallback(p=>{c(p),p||a()},[a]);return d.jsx(de,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:s,image:e.image,children:d.jsxs(v.Popover.Root,{open:u,onOpenChange:h,children:[d.jsx(v.Popover.Trigger,{asChild:!0,children:d.jsxs(v.Button,{id:e.identifier,name:i,type:"button",className:"!justify-between",accentColor:"base",variant:"surface",size:t,disabled:l,children:[d.jsx(v.Text,{className:"truncate",highContrast:!!n,children:n?n.toLocaleString(void 0,{year:"numeric",month:"2-digit",day:"2-digit"}):"yyyy-mm-dd"}),d.jsx(v.LuIcon,{icon:Fr})]})}),d.jsx(v.Popover.Content,{align:"start",size:t,children:d.jsx(v.DayPicker,{size:t,required:!1,mode:"single",variant:"solid",selected:n??void 0,onSelect:f})})]})})});bn.displayName="DateFieldInput";class zt extends Ve{constructor(t){super(t);M(this,"type","date")}serialize(){return super.serialize()}getOptions(){return super.getOptions()}duplicate(t){return new zt({...this.getOptions(),identifier:t})}static deserialize(t){return new zt(t)}setOptions(t){super.setOptions(t)}serializeValue(t){return t?t.toISOString():null}deserializeValue(t){return t?new Date(t):null}render(){return d.jsx(bn,{field:this})}isSerializedValue(t){return typeof t!="string"&&t!==null?!1:this.isValue(this.deserializeValue(t))}isValue(t){return!(!(t instanceof Date)&&t!==null||t instanceof Date&&isNaN(t.getTime()))}blankValue(){return null}blankSerializedValue(){return null}areSerializedValuesEqual(t,n){return t===n}areValuesEqual(t,n){return!t&&!n?!0:!t||!n?!1:t.getTime()===n.getTime()}}var W=(r=>(r.Text="text",r.Selection="selection",r.Numeric="numeric",r.Temporal="temporal",r.Capture="capture",r.Assessment="assessment",r.Verification="verification",r))(W||{});const Nn=y.memo(r=>{const{field:e}=r,{size:t}=y.use(ce),{value:n,name:i,onBlur:a,onChange:o,error:s,disabled:l}=me({field:e}),u=y.useCallback(f=>{o(f),a()},[a,o]),c=y.useCallback(f=>{f||a()},[a]);return d.jsx(de,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:s,image:e.image,children:d.jsxs(v.Menu.Root,{onOpenChange:c,align:"start",children:[d.jsx(v.Menu.ClickTrigger,{children:d.jsxs(v.Button,{id:e.identifier,name:i,className:"!justify-between",variant:"surface",type:"button",size:t,accentColor:"base",disabled:l,children:[d.jsx(v.Text,{className:"truncate",highContrast:n&&n.length>0,children:n&&n.length>0?n.join(", "):e.placeholder??"Select one or more..."}),d.jsx(v.LuIcon,{icon:Fr})]})}),d.jsx(v.Menu.Content,{size:t,children:d.jsx(v.Menu.Scroll,{children:d.jsxs(v.Menu.MultiSelectGroup,{values:n,onValuesChange:u,children:[d.jsxs(v.Menu.SelectAllItem,{children:[d.jsx(v.Menu.CheckboxItemIndicator,{children:f=>f?d.jsx(v.LuIcon,{icon:Vr}):d.jsx(v.LuIcon,{icon:ke})}),"Select all"]}),e.options.map((f,h)=>d.jsxs(v.Menu.MultiSelectItem,{value:f.value,children:[d.jsx(v.Menu.SelectedIndicator,{children:d.jsx(v.LuIcon,{icon:ke})}),f.label]},`${e.identifier}-${f.value}-${h}`))]})})})]})})});Nn.displayName="MultiSelectFieldInput";class it extends tr{constructor(t){const{placeholder:n,...i}=t;super(i);M(this,"type","multi-select");M(this,"placeholder");this.placeholder=n}serialize(){return super.serialize()}getOptions(){return{...super.getOptions(),placeholder:this.placeholder}}duplicate(t){return new it({...this.getOptions(),identifier:t})}setOptions(t){const{placeholder:n}=t;this.placeholder=n,super.setOptions(t)}static deserialize(t){return new it(t)}serializeValue(t){return t}deserializeValue(t){return t}render(){return d.jsx(Nn,{field:this})}isSerializedValue(t){if(!Jt(t))return!1;const n=new Set(this.options.map(({value:i})=>i));return t.every(i=>n.has(i))}isValue(t){return this.isSerializedValue(t)}blankValue(){return[]}areValuesEqual(t,n){const i=new Set(t),a=new Set(n);return i.size===a.size&&i.isSubsetOf(a)}blankSerializedValue(){return[]}areSerializedValuesEqual(t,n){const i=new Set(t),a=new Set(n);return i.size===a.size&&i.isSubsetOf(a)}}const Tn=y.memo(r=>{const{field:e}=r,{size:t}=y.use(ce),{value:n,name:i,onBlur:a,onChange:o,error:s,disabled:l}=me({field:e}),u=y.useCallback(h=>{o(h??null),a()},[a,o]),c=y.useCallback(h=>{h||a()},[a]),f=y.useMemo(()=>e.options.find(h=>h.value===n),[e.options,n]);return d.jsx(de,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:s,image:e.image,children:d.jsxs(v.Menu.Root,{onOpenChange:c,align:"start",children:[d.jsx(v.Menu.ClickTrigger,{children:d.jsxs(v.Button,{id:e.identifier,name:i,className:"!justify-between",accentColor:"base",variant:"surface",type:"button",size:t,disabled:l,children:[d.jsx(v.Text,{className:"truncate",highContrast:!!f,children:f?f.label:e.placeholder??"Select one..."}),d.jsx(v.LuIcon,{icon:Fr})]})}),d.jsx(v.Menu.Content,{size:t,children:d.jsx(v.Menu.Scroll,{children:d.jsx(v.Menu.SelectGroup,{required:!1,value:n??void 0,onValueChange:u,children:e.options.map((h,p)=>d.jsxs(v.Menu.SelectItem,{value:h.value,children:[d.jsx(v.Menu.SelectedIndicator,{children:d.jsx(v.LuIcon,{icon:ke})}),h.label]},`${e.identifier}-${h.value}-${p}`))})})})]})})});Tn.displayName="SelectFieldInput";class ot extends tr{constructor(t){const{placeholder:n,...i}=t;super(i);M(this,"type","select");M(this,"placeholder");this.placeholder=n}serialize(){return super.serialize()}getOptions(){return{...super.getOptions(),placeholder:this.placeholder}}duplicate(t){return new ot({...this.getOptions(),identifier:t})}setOptions(t){const{placeholder:n}=t;this.placeholder=n,super.setOptions(t)}static deserialize(t){return new ot(t)}serializeValue(t){return t}deserializeValue(t){return t}render(){return d.jsx(Tn,{field:this})}isSerializedValue(t){return typeof t!="string"&&t!==null?!1:new Set([null,...this.options.map(({value:i})=>i)]).has(t)}isValue(t){return this.isSerializedValue(t)}blankValue(){return null}areValuesEqual(t,n){return t===n}blankSerializedValue(){return null}areSerializedValuesEqual(t,n){return t===n}}const Mn=y.memo(r=>{const{field:e}=r,{size:t}=y.use(ce),{value:n,name:i,onBlur:a,onChange:o,error:s,disabled:l}=me({field:e}),u=y.useCallback(h=>{o(h)},[o]),c=y.useCallback(()=>{a()},[a]),f=y.useMemo(()=>Array.from({length:e.length},()=>U.v4()),[e.length]);return d.jsx(de,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:s,image:e.image,children:d.jsxs(v.OneTimePasswordField.Root,{id:e.identifier,name:i,value:n,onValueChange:u,validationType:e.validationType,disabled:l,orientation:"horizontal",dir:"ltr",type:"text",autoComplete:"off",autoFocus:!1,autoSubmit:!1,className:"p-0.25 flex h-max w-full gap-1 overflow-x-auto",accentColor:"base",variant:"surface",size:t,onBlur:c,children:[f.map(h=>d.jsx(v.OneTimePasswordField.Input,{id:h},h)),d.jsx(v.OneTimePasswordField.HiddenInput,{})]})})});Mn.displayName="OTPFieldInput";class mt extends Ve{constructor(t){const{length:n,validationType:i,...a}=t;super(a);M(this,"type","otp");M(this,"length");M(this,"validationType");this.length=n,this.validationType=i}static getFieldCreationSchema(t=""){const n=t&&`${t}.`;return[{field:new Pe({label:"Length",integers:!0,required:!1,minimum:1,maximum:16,identifier:`${n}length`}),showDirectly:!1},{field:new ot({label:"Type",required:!1,identifier:`${n}validationType`,options:[{value:"none",label:"Any"},{value:"numeric",label:"Numeric"},{value:"alpha",label:"Alpha"},{value:"alphanumeric",label:"Alphanumeric"}]}),showDirectly:!1}]}getFieldValidators(){const t=super.getFieldValidators(),n=this.length;return t.push(i=>{if(i.length!=n)return`Must be ${n} characters.`}),t}serialize(){return{...super.serialize(),length:this.length,validationType:this.validationType}}getOptions(){return{...super.getOptions(),length:this.length,validationType:this.validationType}}duplicate(t){return new mt({...this.getOptions(),identifier:t})}setOptions(t){const{length:n,validationType:i,...a}=t;this.length=n??this.length,this.validationType=i??this.validationType,super.setOptions(a)}static deserialize(t){return new mt(t)}serializeValue(t){return t}deserializeValue(t){return t}render(){return d.jsx(Mn,{field:this})}isSerializedValue(t){return typeof t=="string"}isValue(t){return typeof t=="string"}blankValue(){return""}areValuesEqual(t,n){return t===n}blankSerializedValue(){return""}areSerializedValuesEqual(t,n){return t===n}}const wt={pass:{label:"Pass",icon:Il},fail:{label:"Fail",icon:Nl},na:{label:"N/A",icon:bl}},kt=Object.keys(wt);class st extends File{constructor(t,...n){super(...n);M(this,"uuid");this.uuid=t}static from(t,n){return new st(t,[n],n.name,{lastModified:n.lastModified,type:n.type})}}class _t extends Promise{constructor(t,n){super(t);M(this,"_uuid");this._uuid=n}get uuid(){return this._uuid}set uuid(t){this._uuid=t}static from(t,n){return new _t((i,a)=>{Promise.resolve(t).then(i).catch(a)},n)}then(t,n){const i=super.then(t,n);return i.uuid=this.uuid,i}catch(t){const n=super.catch(t);return n.uuid=this.uuid,n}finally(t){const n=super.finally(t);return n.uuid=this.uuid,n}}function wa(r){return Array.isArray(r)?r.every(e=>e instanceof _t||e instanceof st):!1}function Lr(r,e){const t=new Set(r.map(({uuid:i})=>i)),n=new Set(e.map(({uuid:i})=>i));return t.size===n.size&&t.isSubsetOf(n)}const Dn=y.memo(r=>{const{ref:e,file:t,error:n,rightSlot:i,className:a,size:o,...s}=r;return d.jsxs(v.Card,{className:et.cx(a,"p-0! relative flex h-48 w-full flex-col overflow-hidden"),ref:e,size:"xs",...s,children:[!t&&!n&&d.jsx("div",{className:"absolute inset-0 flex grow items-center justify-center",children:d.jsx(v.Spinner,{})}),!!t&&!n&&d.jsx("div",{className:"flex grow items-center justify-center overflow-hidden p-3",children:d.jsx(Lt,{className:"size-full max-w-full object-cover",file:t})}),(!!t||!!n)&&d.jsxs(d.Fragment,{children:[d.jsx(v.Separator,{size:"full"}),d.jsxs("div",{className:"flex w-full shrink-0 items-center gap-2 self-end p-3",children:[n?d.jsx(v.LuIcon,{color:"var(--base-11)",icon:fa}):t&&d.jsx(v.LuIcon,{color:"var(--base-11)",icon:ha}),d.jsx(v.Text,{className:"truncate",size:o,children:n??(t==null?void 0:t.name)}),i]})]})]})});Dn.displayName="ImageCard";const Fn=y.memo(r=>{const{file:e,...t}=r,n=wn(e);return n?d.jsx("video",{src:n,...t}):null});Fn.displayName="VideoFile";const Vn=y.memo(r=>{const{ref:e,file:t,className:n,error:i,rightSlot:a,size:o,...s}=r;return d.jsxs(v.Card,{className:et.cx(n,"p-0! relative flex h-48 w-full flex-col overflow-hidden"),ref:e,size:"xs",...s,children:[!t&&!i&&d.jsx("div",{className:"absolute inset-0 flex grow items-center justify-center",children:d.jsx(v.Spinner,{})}),!!t&&!i&&d.jsx("div",{className:"flex grow items-center justify-center overflow-hidden p-3",children:d.jsx(Fn,{className:"size-full max-w-full object-cover",file:t,controls:!0})}),(!!t||!!i)&&d.jsxs(d.Fragment,{children:[d.jsx(v.Separator,{size:"full"}),d.jsxs("div",{className:"flex w-full shrink-0 items-center gap-2 self-end p-3",children:[i?d.jsx(v.LuIcon,{color:"var(--base-11)",icon:fa}):t&&d.jsx(v.LuIcon,{color:"var(--base-11)",icon:jl}),d.jsx(v.Text,{className:"truncate",size:o,children:i??(t==null?void 0:t.name)}),a]})]})]})});Vn.displayName="VideoCard";const Pn=y.memo(r=>{const{fileOrPromise:e,onRemove:t,disabled:n,size:i}=r,[a,o]=y.useState(e instanceof _t?null:e),[s,l]=y.useState(null),u=Pr();y.useEffect(()=>{if(l(null),!(e instanceof _t)){o(e);return}o(null);let w=!0;return e.then(_=>{w&&o(_)}).catch(_=>{w&&l(_ instanceof Error?_.message:"Unknown error")}),()=>{w=!1}},[e]);const c=y.useCallback(()=>{if(!a)return;const w=new Blob([a]);ta.saveAs(w,a.name)},[a]),f=y.useCallback(()=>{t(e)},[t,e]),h=y.useCallback(()=>{if(!a)return;const w=URL.createObjectURL(a);window.open(w,"_blank"),URL.revokeObjectURL(w)},[a]),p=y.useCallback(()=>{a&&u(w=>({file:a,onDelete:n?void 0:()=>{f(),w()}}))},[n,f,u,a]),g=y.useMemo(()=>d.jsx("div",{className:"flex grow justify-end",children:d.jsxs(v.Menu.Root,{modal:!0,children:[d.jsx(v.Menu.ClickTrigger,{children:d.jsx(v.IconButton,{onClick:v.stopPropagation,type:"button",variant:"ghost",accentColor:"base",size:i,children:d.jsx(v.LuIcon,{icon:da})})}),d.jsxs(v.Menu.Content,{size:i,children:[d.jsxs(v.Menu.Item,{onSelect:c,disabled:!a,children:[d.jsx(v.LuIcon,{icon:ca})," Download"]}),n?null:d.jsxs(d.Fragment,{children:[d.jsx(v.Menu.Separator,{}),d.jsxs(v.Menu.Item,{onSelect:f,children:[d.jsx(v.LuIcon,{icon:gt})," Delete"]})]})]})]})}),[n,f,c,a,i]),x=!!(a!=null&&a.type.startsWith("image/")),m=!!(a!=null&&a.type.startsWith("video/"));return x?d.jsx(Dn,{className:"cursor-pointer",onClick:p,file:a,error:s??void 0,rightSlot:g,size:i}):m?d.jsx(Vn,{className:"cursor-pointer",onClick:p,file:a,error:s??void 0,rightSlot:g,size:i}):d.jsx(Cn,{className:"cursor-pointer",file:a,error:s??void 0,onClick:h,rightSlot:g,size:i})});Pn.displayName="DisplayFile";const Bn=y.memo(r=>{const{field:e}=r,{size:t}=y.use(ce),{value:n,name:i,onBlur:a,onChange:o,error:s,disabled:l}=me({field:e}),u=y.useRef(null),c=y.useCallback(S=>{const O=e.cleanValue({...n,status:S});o(O),a()},[e,a,o,n]),f=y.useCallback(S=>{const O=S.target.value,N={...n,notes:O};o(N)},[n,o]),h=y.useCallback(()=>{a()},[a]),p=y.useCallback(S=>{const O=n.files.filter(({uuid:N})=>N!==S.uuid);o({...n,files:O}),a()},[o,a,n]),g=y.useCallback(()=>{var S;(S=u.current)==null||S.click()},[]),x=y.useCallback(S=>{const O=Array.from(S.target.files??[]).map(T=>st.from(U.v4(),T)),N={...n,files:[...n.files,...O]};o(N),a()},[a,o,n]);y.useEffect(()=>{if(!u.current)return;const S=new AbortController;return u.current.addEventListener("cancel",()=>{a()},{signal:S.signal}),()=>{S.abort()}},[a,n]);const m=n.status&&e.showNotesAndFilesOn.includes(n.status),w=`${e.identifier}-status`,_=`${e.identifier}-notes`,E=`${e.identifier}-files`;return d.jsx(de,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:s,image:e.image,children:d.jsxs("div",{className:"flex flex-col gap-2",children:[d.jsx(v.RadioGroup.Root,{id:w,className:"flex gap-2",name:i,value:n.status,disabled:l,accentColor:"base",variant:"surface",size:t,onValueChange:c,children:kt.map(S=>{const{label:O}=wt[S];return d.jsxs("label",{className:"flex min-w-0 items-center gap-2",children:[d.jsx(v.RadioGroup.Item,{value:S,children:d.jsx(v.RadioGroup.Indicator,{children:d.jsx(v.LuIcon,{icon:sa,className:"fill-current"})})}),d.jsx(v.Text,{size:t,accentColor:"base",className:"truncate",children:O})]},`${e.identifier}-${S}`)})}),m&&d.jsxs(d.Fragment,{children:[d.jsx("div",{children:d.jsx(v.TextArea,{id:_,value:n.notes??"",name:i,onChange:f,onBlur:h,className:"field-sizing-content min-h-12 w-full",placeholder:"Notes",resize:"vertical",accentColor:"base",variant:"surface",size:t,disabled:l})}),d.jsxs("div",{className:"flex flex-col gap-2",children:[d.jsxs(v.Button,{className:"w-max",size:t,variant:"soft",accentColor:"base",onClick:g,type:"button",disabled:l,children:[d.jsx(v.LuIcon,{icon:yn}),"Select files"]}),d.jsx("input",{id:E,name:i,type:"file",ref:u,multiple:!0,className:"hidden",onChange:x,value:""}),n.files.length>0&&d.jsx("div",{className:"flex h-max flex-wrap gap-2",children:n.files.map(S=>d.jsx(Pn,{size:t,fileOrPromise:S,onRemove:p,disabled:l},S.uuid))})]})]})]})})});Bn.displayName="PassFailFieldInput";const Ln=r=>typeof r=="string"&&kt.includes(r),_a=r=>!(r===null||typeof r!="object"||!("status"in r)||!Ln(r.status)||!("notes"in r)||typeof r.notes!="string"||!("files"in r)||!(Array.isArray(r.files)&&r.files.length===0)),Aa=r=>!(r===null||typeof r!="object"||!("status"in r)||!Ln(r.status)||!("notes"in r)||typeof r.notes!="string"||!("files"in r)||!wa(r.files)),Sa=r=>({status:r.status,notes:r.notes,files:[]}),Ea=r=>({status:r.status,notes:r.notes,files:[]}),Ia=(r,e)=>!(r.status!==e.status||r.notes!==e.notes||!Lr(r.files,e.files)),Oa=(r,e)=>!(r.status!==e.status||r.notes!==e.notes||r.files.length!==e.files.length);class At extends Ve{constructor(t){const{showNotesAndFilesOn:n,...i}=t;super(i);M(this,"type","pass-fail");M(this,"showNotesAndFilesOn");this.showNotesAndFilesOn=n}static getFieldCreationSchema(t=""){const n=t&&`${t}.`;return[{field:new it({identifier:`${n}showNotesAndFilesOn`,label:"Show notes and files on",description:"Show the notes and files on desired statuses.",options:kt.map(i=>{const{label:a}=wt[i];return{value:i,label:a}}),required:!1}),showDirectly:!1}]}serialize(){return{...super.serialize(),showNotesAndFilesOn:this.showNotesAndFilesOn}}getOptions(){return{...super.getOptions(),showNotesAndFilesOn:this.showNotesAndFilesOn}}duplicate(t){return new At({...this.getOptions(),identifier:t})}setOptions(t){const{showNotesAndFilesOn:n,...i}=t;this.showNotesAndFilesOn=n??this.showNotesAndFilesOn,super.setOptions(i)}getFieldValidators(){const t=super.getFieldValidators(),n=this.showNotesAndFilesOn,i=this.blankValue();return n.length>0&&(t.push(a=>{if(!(!a.status||!n.includes(a.status))&&i.notes===a.notes)return"Notes is required."}),t.push(a=>{if(!(!a.status||!n.includes(a.status))&&Lr(i.files,a.files))return"Files is required."})),t}static deserialize(t){return new At({...t,showNotesAndFilesOn:t.showNotesAndFilesOn??!1})}serializeValue(t){return Sa(t)}deserializeValue(t){return Ea(t)}render(){return d.jsx(Bn,{field:this})}isSerializedValue(t){return _a(t)}isValue(t){return Aa(t)}areValuesEqual(t,n){return Ia(t,n)}blankValue(){return{status:null,notes:"",files:[]}}cleanValue(t){return t.status&&this.showNotesAndFilesOn.includes(t.status)?t:{status:t.status,notes:"",files:[]}}cleanSerializedValue(t){return super.cleanSerializedValue(t)}blankSerializedValue(){return{status:null,notes:"",files:[]}}areSerializedValuesEqual(t,n){return Oa(t,n)}}const zn=y.memo(r=>{const{field:e}=r,{size:t}=y.use(ce),{value:n,name:i,onBlur:a,onChange:o,error:s,disabled:l}=me({field:e}),u=y.useCallback(h=>{o(h),a()},[a,o]),c=y.useCallback(()=>{a()},[a]),f=y.useCallback(()=>{o(null),a()},[a,o]);return d.jsx(de,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:s,image:e.image,children:d.jsxs(v.RadioGroup.Root,{id:e.identifier,name:i,className:"flex flex-col gap-1",accentColor:"base",variant:"surface",size:t,value:n??"",onValueChange:u,disabled:l,children:[e.options.map((h,p)=>d.jsxs("label",{className:"flex min-w-0 items-center gap-2",children:[d.jsx(v.RadioGroup.Item,{value:h.value,onBlur:c,children:d.jsx(v.RadioGroup.Indicator,{children:d.jsx(v.LuIcon,{icon:sa,className:"fill-current"})})}),d.jsx(v.Text,{size:t,accentColor:"base",className:"truncate",children:h.label})]},`${e.identifier}-${h.value}-${p}`)),!!n&&d.jsxs(v.Button,{onClick:f,className:"-mx-2 w-max",type:"button",variant:"ghost",accentColor:"base",size:t,children:[d.jsx(v.LuIcon,{icon:at}),"Clear"]})]})})});zn.displayName="RadioFieldInput";class St extends tr{constructor(t){super(t);M(this,"type","radio")}serialize(){return super.serialize()}getOptions(){return super.getOptions()}duplicate(t){return new St({...this.getOptions(),identifier:t})}setOptions(t){super.setOptions(t)}static deserialize(t){return new St(t)}serializeValue(t){return t}deserializeValue(t){return t}render(){return d.jsx(zn,{field:this})}isSerializedValue(t){return typeof t!="string"&&t!==null?!1:new Set([null,...this.options.map(({value:i})=>i)]).has(t)}isValue(t){return this.isSerializedValue(t)}blankValue(){return null}areValuesEqual(t,n){return t===n}blankSerializedValue(){return null}areSerializedValuesEqual(t,n){return t===n}}const Yl=et.cva(["group flex cursor-pointer items-center justify-center text-yellow-500 transition-colors disabled:pointer-events-none disabled:opacity-50"],{variants:{size:{xs:["size-5"],sm:["size-6"],md:["size-7"],lg:["size-8"],xl:["size-9"]}}}),kn=y.memo(r=>{const{field:e}=r,{size:t}=y.use(ce),{value:n,name:i,onBlur:a,onChange:o,error:s,disabled:l}=me({field:e}),u=y.useCallback(h=>{o(h),a()},[a,o]),c=y.useCallback(()=>{o(null),a()},[a,o]),f=Array.from({length:e.maxRating},(h,p)=>p+1);return d.jsx(de,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:s,image:e.image,children:d.jsxs("div",{className:"flex flex-row items-center gap-1",children:[d.jsx(v.Rating.Root,{id:e.identifier,name:i,className:"flex items-center gap-0.5",value:n,onValueChange:u,disabled:l,children:f.map(h=>d.jsx(v.Rating.Item,{value:h,className:Yl({size:t}),children:d.jsx(v.LuIcon,{icon:xa,className:"size-full group-data-[active=true]:fill-current"})},`${e.identifier}-${h}`))}),!l&&n!==null&&d.jsx(v.IconButton,{onClick:c,type:"button",variant:"ghost",accentColor:"base",size:t,children:d.jsx(v.LuIcon,{icon:at})})]})})});kn.displayName="RatingFieldInput";class Et extends Ve{constructor(t){const{maxRating:n,...i}=t;super(i);M(this,"type","rating");M(this,"maxRating");this.maxRating=n}static getFieldCreationSchema(t=""){const n=t&&`${t}.`;return[{field:new Pe({label:"Max Rating",description:"Maximum rating value",integers:!0,required:!1,minimum:1,maximum:10,identifier:`${n}maxRating`}),showDirectly:!1}]}getFieldValidators(){const t=super.getFieldValidators(),n=this.maxRating;return t.push(i=>{if(typeof i=="number"&&(i<1||i>n))return`Rating must be between 1 and ${n}.`}),t}serialize(){return{...super.serialize(),maxRating:this.maxRating}}getOptions(){return{...super.getOptions(),maxRating:this.maxRating}}duplicate(t){return new Et({...this.getOptions(),identifier:t})}setOptions(t){const{maxRating:n,...i}=t;this.maxRating=n??this.maxRating,super.setOptions(i)}static deserialize(t){return new Et(t)}serializeValue(t){return t}deserializeValue(t){return t}render(){return d.jsx(kn,{field:this})}isSerializedValue(t){return this.isValue(t)}isValue(t){return typeof t=="number"&&!isNaN(t)||t===null}areValuesEqual(t,n){return t===n}blankValue(){return null}blankSerializedValue(){return null}areSerializedValuesEqual(t,n){return t===n}}const ba=y.createContext(()=>{throw new Error("No ScannerProvider found")}),Zl=()=>y.use(ba);function Kl(r,e){var t=Object.setPrototypeOf;t?t(r,e):r.__proto__=e}function Ql(r,e){e===void 0&&(e=r.constructor);var t=Error.captureStackTrace;t&&t(r,e)}var Jl=function(){var r=function(t,n){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,a){i.__proto__=a}||function(i,a){for(var o in a)Object.prototype.hasOwnProperty.call(a,o)&&(i[o]=a[o])},r(t,n)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),eu=function(r){Jl(e,r);function e(t,n){var i=this.constructor,a=r.call(this,t,n)||this;return Object.defineProperty(a,"name",{value:i.name,enumerable:!1,configurable:!0}),Kl(a,i.prototype),Ql(a),a}return e}(Error),tu=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),Ue=function(r){tu(e,r);function e(t){t===void 0&&(t=void 0);var n=r.call(this,t)||this;return n.message=t,n}return e.prototype.getKind=function(){var t=this.constructor;return t.kind},e.kind="Exception",e}(eu),ru=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),Ze=function(r){ru(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e.kind="ArgumentException",e}(Ue),nu=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),k=function(r){nu(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e.kind="IllegalArgumentException",e}(Ue),iu=function(){function r(e){if(this.binarizer=e,e===null)throw new k("Binarizer must be non-null.")}return r.prototype.getWidth=function(){return this.binarizer.getWidth()},r.prototype.getHeight=function(){return this.binarizer.getHeight()},r.prototype.getBlackRow=function(e,t){return this.binarizer.getBlackRow(e,t)},r.prototype.getBlackMatrix=function(){return(this.matrix===null||this.matrix===void 0)&&(this.matrix=this.binarizer.getBlackMatrix()),this.matrix},r.prototype.isCropSupported=function(){return this.binarizer.getLuminanceSource().isCropSupported()},r.prototype.crop=function(e,t,n,i){var a=this.binarizer.getLuminanceSource().crop(e,t,n,i);return new r(this.binarizer.createBinarizer(a))},r.prototype.isRotateSupported=function(){return this.binarizer.getLuminanceSource().isRotateSupported()},r.prototype.rotateCounterClockwise=function(){var e=this.binarizer.getLuminanceSource().rotateCounterClockwise();return new r(this.binarizer.createBinarizer(e))},r.prototype.rotateCounterClockwise45=function(){var e=this.binarizer.getLuminanceSource().rotateCounterClockwise45();return new r(this.binarizer.createBinarizer(e))},r.prototype.toString=function(){try{return this.getBlackMatrix().toString()}catch{return""}},r}(),au=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),we=function(r){au(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e.getChecksumInstance=function(){return new e},e.kind="ChecksumException",e}(Ue),ou=function(){function r(e){this.source=e}return r.prototype.getLuminanceSource=function(){return this.source},r.prototype.getWidth=function(){return this.source.getWidth()},r.prototype.getHeight=function(){return this.source.getHeight()},r}(),ie=function(){function r(){}return r.arraycopy=function(e,t,n,i,a){for(;a--;)n[i++]=e[t++]},r.currentTimeMillis=function(){return Date.now()},r}(),su=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),Un=function(r){su(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e.kind="IndexOutOfBoundsException",e}(Ue),lu=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),Na=function(r){lu(e,r);function e(t,n){t===void 0&&(t=void 0),n===void 0&&(n=void 0);var i=r.call(this,n)||this;return i.index=t,i.message=n,i}return e.kind="ArrayIndexOutOfBoundsException",e}(Un),uu=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},fe=function(){function r(){}return r.fill=function(e,t){for(var n=0,i=e.length;n<i;n++)e[n]=t},r.fillWithin=function(e,t,n,i){r.rangeCheck(e.length,t,n);for(var a=t;a<n;a++)e[a]=i},r.rangeCheck=function(e,t,n){if(t>n)throw new k("fromIndex("+t+") > toIndex("+n+")");if(t<0)throw new Na(t);if(n>e)throw new Na(n)},r.asList=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return e},r.create=function(e,t,n){var i=Array.from({length:e});return i.map(function(a){return Array.from({length:t}).fill(n)})},r.createInt32Array=function(e,t,n){var i=Array.from({length:e});return i.map(function(a){return Int32Array.from({length:t}).fill(n)})},r.equals=function(e,t){if(!e||!t||!e.length||!t.length||e.length!==t.length)return!1;for(var n=0,i=e.length;n<i;n++)if(e[n]!==t[n])return!1;return!0},r.hashCode=function(e){var t,n;if(e===null)return 0;var i=1;try{for(var a=uu(e),o=a.next();!o.done;o=a.next()){var s=o.value;i=31*i+s}}catch(l){t={error:l}}finally{try{o&&!o.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}return i},r.fillUint8Array=function(e,t){for(var n=0;n!==e.length;n++)e[n]=t},r.copyOf=function(e,t){return e.slice(0,t)},r.copyOfUint8Array=function(e,t){if(e.length<=t){var n=new Uint8Array(t);return n.set(e),n}return e.slice(0,t)},r.copyOfRange=function(e,t,n){var i=n-t,a=new Int32Array(i);return ie.arraycopy(e,t,a,0,i),a},r.binarySearch=function(e,t,n){n===void 0&&(n=r.numberComparator);for(var i=0,a=e.length-1;i<=a;){var o=a+i>>1,s=n(t,e[o]);if(s>0)i=o+1;else if(s<0)a=o-1;else return o}return-i-1},r.numberComparator=function(e,t){return e-t},r}(),$=function(){function r(){}return r.numberOfTrailingZeros=function(e){var t;if(e===0)return 32;var n=31;return t=e<<16,t!==0&&(n-=16,e=t),t=e<<8,t!==0&&(n-=8,e=t),t=e<<4,t!==0&&(n-=4,e=t),t=e<<2,t!==0&&(n-=2,e=t),n-(e<<1>>>31)},r.numberOfLeadingZeros=function(e){if(e===0)return 32;var t=1;return e>>>16||(t+=16,e<<=16),e>>>24||(t+=8,e<<=8),e>>>28||(t+=4,e<<=4),e>>>30||(t+=2,e<<=2),t-=e>>>31,t},r.toHexString=function(e){return e.toString(16)},r.toBinaryString=function(e){return String(parseInt(String(e),2))},r.bitCount=function(e){return e=e-(e>>>1&1431655765),e=(e&858993459)+(e>>>2&858993459),e=e+(e>>>4)&252645135,e=e+(e>>>8),e=e+(e>>>16),e&63},r.truncDivision=function(e,t){return Math.trunc(e/t)},r.parseInt=function(e,t){return t===void 0&&(t=void 0),parseInt(e,t)},r.MIN_VALUE_32_BITS=-2147483648,r.MAX_VALUE=Number.MAX_SAFE_INTEGER,r}(),_e=function(){function r(e,t){e===void 0?(this.size=0,this.bits=new Int32Array(1)):(this.size=e,t==null?this.bits=r.makeArray(e):this.bits=t)}return r.prototype.getSize=function(){return this.size},r.prototype.getSizeInBytes=function(){return Math.floor((this.size+7)/8)},r.prototype.ensureCapacity=function(e){if(e>this.bits.length*32){var t=r.makeArray(e);ie.arraycopy(this.bits,0,t,0,this.bits.length),this.bits=t}},r.prototype.get=function(e){return(this.bits[Math.floor(e/32)]&1<<(e&31))!==0},r.prototype.set=function(e){this.bits[Math.floor(e/32)]|=1<<(e&31)},r.prototype.flip=function(e){this.bits[Math.floor(e/32)]^=1<<(e&31)},r.prototype.getNextSet=function(e){var t=this.size;if(e>=t)return t;var n=this.bits,i=Math.floor(e/32),a=n[i];a&=~((1<<(e&31))-1);for(var o=n.length;a===0;){if(++i===o)return t;a=n[i]}var s=i*32+$.numberOfTrailingZeros(a);return s>t?t:s},r.prototype.getNextUnset=function(e){var t=this.size;if(e>=t)return t;var n=this.bits,i=Math.floor(e/32),a=~n[i];a&=~((1<<(e&31))-1);for(var o=n.length;a===0;){if(++i===o)return t;a=~n[i]}var s=i*32+$.numberOfTrailingZeros(a);return s>t?t:s},r.prototype.setBulk=function(e,t){this.bits[Math.floor(e/32)]=t},r.prototype.setRange=function(e,t){if(t<e||e<0||t>this.size)throw new k;if(t!==e){t--;for(var n=Math.floor(e/32),i=Math.floor(t/32),a=this.bits,o=n;o<=i;o++){var s=o>n?0:e&31,l=o<i?31:t&31,u=(2<<l)-(1<<s);a[o]|=u}}},r.prototype.clear=function(){for(var e=this.bits.length,t=this.bits,n=0;n<e;n++)t[n]=0},r.prototype.isRange=function(e,t,n){if(t<e||e<0||t>this.size)throw new k;if(t===e)return!0;t--;for(var i=Math.floor(e/32),a=Math.floor(t/32),o=this.bits,s=i;s<=a;s++){var l=s>i?0:e&31,u=s<a?31:t&31,c=(2<<u)-(1<<l)&4294967295;if((o[s]&c)!==(n?c:0))return!1}return!0},r.prototype.appendBit=function(e){this.ensureCapacity(this.size+1),e&&(this.bits[Math.floor(this.size/32)]|=1<<(this.size&31)),this.size++},r.prototype.appendBits=function(e,t){if(t<0||t>32)throw new k("Num bits must be between 0 and 32");this.ensureCapacity(this.size+t);for(var n=t;n>0;n--)this.appendBit((e>>n-1&1)===1)},r.prototype.appendBitArray=function(e){var t=e.size;this.ensureCapacity(this.size+t);for(var n=0;n<t;n++)this.appendBit(e.get(n))},r.prototype.xor=function(e){if(this.size!==e.size)throw new k("Sizes don't match");for(var t=this.bits,n=0,i=t.length;n<i;n++)t[n]^=e.bits[n]},r.prototype.toBytes=function(e,t,n,i){for(var a=0;a<i;a++){for(var o=0,s=0;s<8;s++)this.get(e)&&(o|=1<<7-s),e++;t[n+a]=o}},r.prototype.getBitArray=function(){return this.bits},r.prototype.reverse=function(){for(var e=new Int32Array(this.bits.length),t=Math.floor((this.size-1)/32),n=t+1,i=this.bits,a=0;a<n;a++){var o=i[a];o=o>>1&1431655765|(o&1431655765)<<1,o=o>>2&858993459|(o&858993459)<<2,o=o>>4&252645135|(o&252645135)<<4,o=o>>8&16711935|(o&16711935)<<8,o=o>>16&65535|(o&65535)<<16,e[t-a]=o}if(this.size!==n*32){for(var s=n*32-this.size,l=e[0]>>>s,a=1;a<n;a++){var u=e[a];l|=u<<32-s,e[a-1]=l,l=u>>>s}e[n-1]=l}this.bits=e},r.makeArray=function(e){return new Int32Array(Math.floor((e+31)/32))},r.prototype.equals=function(e){if(!(e instanceof r))return!1;var t=e;return this.size===t.size&&fe.equals(this.bits,t.bits)},r.prototype.hashCode=function(){return 31*this.size+fe.hashCode(this.bits)},r.prototype.toString=function(){for(var e="",t=0,n=this.size;t<n;t++)(t&7)===0&&(e+=" "),e+=this.get(t)?"X":".";return e},r.prototype.clone=function(){return new r(this.size,this.bits.slice())},r.prototype.toArray=function(){for(var e=[],t=0,n=this.size;t<n;t++)e.push(this.get(t));return e},r}(),Rn;(function(r){r[r.OTHER=0]="OTHER",r[r.PURE_BARCODE=1]="PURE_BARCODE",r[r.POSSIBLE_FORMATS=2]="POSSIBLE_FORMATS",r[r.TRY_HARDER=3]="TRY_HARDER",r[r.CHARACTER_SET=4]="CHARACTER_SET",r[r.ALLOWED_LENGTHS=5]="ALLOWED_LENGTHS",r[r.ASSUME_CODE_39_CHECK_DIGIT=6]="ASSUME_CODE_39_CHECK_DIGIT",r[r.ASSUME_GS1=7]="ASSUME_GS1",r[r.RETURN_CODABAR_START_END=8]="RETURN_CODABAR_START_END",r[r.NEED_RESULT_POINT_CALLBACK=9]="NEED_RESULT_POINT_CALLBACK",r[r.ALLOWED_EAN_EXTENSIONS=10]="ALLOWED_EAN_EXTENSIONS"})(Rn||(Rn={}));const se=Rn;var cu=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),D=function(r){cu(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e.getFormatInstance=function(){return new e},e.kind="FormatException",e}(Ue),du=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},te;(function(r){r[r.Cp437=0]="Cp437",r[r.ISO8859_1=1]="ISO8859_1",r[r.ISO8859_2=2]="ISO8859_2",r[r.ISO8859_3=3]="ISO8859_3",r[r.ISO8859_4=4]="ISO8859_4",r[r.ISO8859_5=5]="ISO8859_5",r[r.ISO8859_6=6]="ISO8859_6",r[r.ISO8859_7=7]="ISO8859_7",r[r.ISO8859_8=8]="ISO8859_8",r[r.ISO8859_9=9]="ISO8859_9",r[r.ISO8859_10=10]="ISO8859_10",r[r.ISO8859_11=11]="ISO8859_11",r[r.ISO8859_13=12]="ISO8859_13",r[r.ISO8859_14=13]="ISO8859_14",r[r.ISO8859_15=14]="ISO8859_15",r[r.ISO8859_16=15]="ISO8859_16",r[r.SJIS=16]="SJIS",r[r.Cp1250=17]="Cp1250",r[r.Cp1251=18]="Cp1251",r[r.Cp1252=19]="Cp1252",r[r.Cp1256=20]="Cp1256",r[r.UnicodeBigUnmarked=21]="UnicodeBigUnmarked",r[r.UTF8=22]="UTF8",r[r.ASCII=23]="ASCII",r[r.Big5=24]="Big5",r[r.GB18030=25]="GB18030",r[r.EUC_KR=26]="EUC_KR"})(te||(te={}));var he=function(){function r(e,t,n){for(var i,a,o=[],s=3;s<arguments.length;s++)o[s-3]=arguments[s];this.valueIdentifier=e,this.name=n,typeof t=="number"?this.values=Int32Array.from([t]):this.values=t,this.otherEncodingNames=o,r.VALUE_IDENTIFIER_TO_ECI.set(e,this),r.NAME_TO_ECI.set(n,this);for(var l=this.values,u=0,c=l.length;u!==c;u++){var f=l[u];r.VALUES_TO_ECI.set(f,this)}try{for(var h=du(o),p=h.next();!p.done;p=h.next()){var g=p.value;r.NAME_TO_ECI.set(g,this)}}catch(x){i={error:x}}finally{try{p&&!p.done&&(a=h.return)&&a.call(h)}finally{if(i)throw i.error}}}return r.prototype.getValueIdentifier=function(){return this.valueIdentifier},r.prototype.getName=function(){return this.name},r.prototype.getValue=function(){return this.values[0]},r.getCharacterSetECIByValue=function(e){if(e<0||e>=900)throw new D("incorect value");var t=r.VALUES_TO_ECI.get(e);if(t===void 0)throw new D("incorect value");return t},r.getCharacterSetECIByName=function(e){var t=r.NAME_TO_ECI.get(e);if(t===void 0)throw new D("incorect value");return t},r.prototype.equals=function(e){if(!(e instanceof r))return!1;var t=e;return this.getName()===t.getName()},r.VALUE_IDENTIFIER_TO_ECI=new Map,r.VALUES_TO_ECI=new Map,r.NAME_TO_ECI=new Map,r.Cp437=new r(te.Cp437,Int32Array.from([0,2]),"Cp437"),r.ISO8859_1=new r(te.ISO8859_1,Int32Array.from([1,3]),"ISO-8859-1","ISO88591","ISO8859_1"),r.ISO8859_2=new r(te.ISO8859_2,4,"ISO-8859-2","ISO88592","ISO8859_2"),r.ISO8859_3=new r(te.ISO8859_3,5,"ISO-8859-3","ISO88593","ISO8859_3"),r.ISO8859_4=new r(te.ISO8859_4,6,"ISO-8859-4","ISO88594","ISO8859_4"),r.ISO8859_5=new r(te.ISO8859_5,7,"ISO-8859-5","ISO88595","ISO8859_5"),r.ISO8859_6=new r(te.ISO8859_6,8,"ISO-8859-6","ISO88596","ISO8859_6"),r.ISO8859_7=new r(te.ISO8859_7,9,"ISO-8859-7","ISO88597","ISO8859_7"),r.ISO8859_8=new r(te.ISO8859_8,10,"ISO-8859-8","ISO88598","ISO8859_8"),r.ISO8859_9=new r(te.ISO8859_9,11,"ISO-8859-9","ISO88599","ISO8859_9"),r.ISO8859_10=new r(te.ISO8859_10,12,"ISO-8859-10","ISO885910","ISO8859_10"),r.ISO8859_11=new r(te.ISO8859_11,13,"ISO-8859-11","ISO885911","ISO8859_11"),r.ISO8859_13=new r(te.ISO8859_13,15,"ISO-8859-13","ISO885913","ISO8859_13"),r.ISO8859_14=new r(te.ISO8859_14,16,"ISO-8859-14","ISO885914","ISO8859_14"),r.ISO8859_15=new r(te.ISO8859_15,17,"ISO-8859-15","ISO885915","ISO8859_15"),r.ISO8859_16=new r(te.ISO8859_16,18,"ISO-8859-16","ISO885916","ISO8859_16"),r.SJIS=new r(te.SJIS,20,"SJIS","Shift_JIS"),r.Cp1250=new r(te.Cp1250,21,"Cp1250","windows-1250"),r.Cp1251=new r(te.Cp1251,22,"Cp1251","windows-1251"),r.Cp1252=new r(te.Cp1252,23,"Cp1252","windows-1252"),r.Cp1256=new r(te.Cp1256,24,"Cp1256","windows-1256"),r.UnicodeBigUnmarked=new r(te.UnicodeBigUnmarked,25,"UnicodeBigUnmarked","UTF-16BE","UnicodeBig"),r.UTF8=new r(te.UTF8,26,"UTF8","UTF-8"),r.ASCII=new r(te.ASCII,Int32Array.from([27,170]),"ASCII","US-ASCII"),r.Big5=new r(te.Big5,28,"Big5"),r.GB18030=new r(te.GB18030,29,"GB18030","GB2312","EUC_CN","GBK"),r.EUC_KR=new r(te.EUC_KR,30,"EUC_KR","EUC-KR"),r}(),fu=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),zr=function(r){fu(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e.kind="UnsupportedOperationException",e}(Ue),$e=function(){function r(){}return r.decode=function(e,t){var n=this.encodingName(t);return this.customDecoder?this.customDecoder(e,n):typeof TextDecoder>"u"||this.shouldDecodeOnFallback(n)?this.decodeFallback(e,n):new TextDecoder(n).decode(e)},r.shouldDecodeOnFallback=function(e){return!r.isBrowser()&&e==="ISO-8859-1"},r.encode=function(e,t){var n=this.encodingName(t);return this.customEncoder?this.customEncoder(e,n):typeof TextEncoder>"u"?this.encodeFallback(e):new TextEncoder().encode(e)},r.isBrowser=function(){return typeof window<"u"&&{}.toString.call(window)==="[object Window]"},r.encodingName=function(e){return typeof e=="string"?e:e.getName()},r.encodingCharacterSet=function(e){return e instanceof he?e:he.getCharacterSetECIByName(e)},r.decodeFallback=function(e,t){var n=this.encodingCharacterSet(t);if(r.isDecodeFallbackSupported(n)){for(var i="",a=0,o=e.length;a<o;a++){var s=e[a].toString(16);s.length<2&&(s="0"+s),i+="%"+s}return decodeURIComponent(i)}if(n.equals(he.UnicodeBigUnmarked))return String.fromCharCode.apply(null,new Uint16Array(e.buffer));throw new zr("Encoding "+this.encodingName(t)+" not supported by fallback.")},r.isDecodeFallbackSupported=function(e){return e.equals(he.UTF8)||e.equals(he.ISO8859_1)||e.equals(he.ASCII)},r.encodeFallback=function(e){for(var t=btoa(unescape(encodeURIComponent(e))),n=t.split(""),i=[],a=0;a<n.length;a++)i.push(n[a].charCodeAt(0));return new Uint8Array(i)},r}(),X=function(){function r(){}return r.castAsNonUtf8Char=function(e,t){t===void 0&&(t=null);var n=t?t.getName():this.ISO88591;return $e.decode(new Uint8Array([e]),n)},r.guessEncoding=function(e,t){if(t!=null&&t.get(se.CHARACTER_SET)!==void 0)return t.get(se.CHARACTER_SET).toString();for(var n=e.length,i=!0,a=!0,o=!0,s=0,l=0,u=0,c=0,f=0,h=0,p=0,g=0,x=0,m=0,w=0,_=e.length>3&&e[0]===239&&e[1]===187&&e[2]===191,E=0;E<n&&(i||a||o);E++){var S=e[E]&255;o&&(s>0?(S&128)===0?o=!1:s--:(S&128)!==0&&((S&64)===0?o=!1:(s++,(S&32)===0?l++:(s++,(S&16)===0?u++:(s++,(S&8)===0?c++:o=!1))))),i&&(S>127&&S<160?i=!1:S>159&&(S<192||S===215||S===247)&&w++),a&&(f>0?S<64||S===127||S>252?a=!1:f--:S===128||S===160||S>239?a=!1:S>160&&S<224?(h++,g=0,p++,p>x&&(x=p)):S>127?(f++,p=0,g++,g>m&&(m=g)):(p=0,g=0))}return o&&s>0&&(o=!1),a&&f>0&&(a=!1),o&&(_||l+u+c>0)?r.UTF8:a&&(r.ASSUME_SHIFT_JIS||x>=3||m>=3)?r.SHIFT_JIS:i&&a?x===2&&h===2||w*10>=n?r.SHIFT_JIS:r.ISO88591:i?r.ISO88591:a?r.SHIFT_JIS:o?r.UTF8:r.PLATFORM_DEFAULT_ENCODING},r.format=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var i=-1;function a(s,l,u,c,f,h){if(s==="%%")return"%";if(t[++i]!==void 0){s=c?parseInt(c.substr(1)):void 0;var p=f?parseInt(f.substr(1)):void 0,g;switch(h){case"s":g=t[i];break;case"c":g=t[i][0];break;case"f":g=parseFloat(t[i]).toFixed(s);break;case"p":g=parseFloat(t[i]).toPrecision(s);break;case"e":g=parseFloat(t[i]).toExponential(s);break;case"x":g=parseInt(t[i]).toString(p||16);break;case"d":g=parseFloat(parseInt(t[i],p||10).toPrecision(s)).toFixed(0);break}g=typeof g=="object"?JSON.stringify(g):(+g).toString(p);for(var x=parseInt(u),m=u&&u[0]+""=="0"?"0":" ";g.length<x;)g=l!==void 0?g+m:m+g;return g}}var o=/%(-)?(0?[0-9]+)?([.][0-9]+)?([#][0-9]+)?([scfpexd%])/g;return e.replace(o,a)},r.getBytes=function(e,t){return $e.encode(e,t)},r.getCharCode=function(e,t){return t===void 0&&(t=0),e.charCodeAt(t)},r.getCharAt=function(e){return String.fromCharCode(e)},r.SHIFT_JIS=he.SJIS.getName(),r.GB2312="GB2312",r.ISO88591=he.ISO8859_1.getName(),r.EUC_JP="EUC_JP",r.UTF8=he.UTF8.getName(),r.PLATFORM_DEFAULT_ENCODING=r.UTF8,r.ASSUME_SHIFT_JIS=!1,r}(),q=function(){function r(e){e===void 0&&(e=""),this.value=e}return r.prototype.enableDecoding=function(e){return this.encoding=e,this},r.prototype.append=function(e){return typeof e=="string"?this.value+=e.toString():this.encoding?this.value+=X.castAsNonUtf8Char(e,this.encoding):this.value+=String.fromCharCode(e),this},r.prototype.appendChars=function(e,t,n){for(var i=t;t<t+n;i++)this.append(e[i]);return this},r.prototype.length=function(){return this.value.length},r.prototype.charAt=function(e){return this.value.charAt(e)},r.prototype.deleteCharAt=function(e){this.value=this.value.substr(0,e)+this.value.substring(e+1)},r.prototype.setCharAt=function(e,t){this.value=this.value.substr(0,e)+t+this.value.substr(e+1)},r.prototype.substring=function(e,t){return this.value.substring(e,t)},r.prototype.setLengthToZero=function(){this.value=""},r.prototype.toString=function(){return this.value},r.prototype.insert=function(e,t){this.value=this.value.substring(0,e)+t+this.value.substring(e)},r}(),tt=function(){function r(e,t,n,i){if(this.width=e,this.height=t,this.rowSize=n,this.bits=i,t==null&&(t=e),this.height=t,e<1||t<1)throw new k("Both dimensions must be greater than 0");n==null&&(n=Math.floor((e+31)/32)),this.rowSize=n,i==null&&(this.bits=new Int32Array(this.rowSize*this.height))}return r.parseFromBooleanArray=function(e){for(var t=e.length,n=e[0].length,i=new r(n,t),a=0;a<t;a++)for(var o=e[a],s=0;s<n;s++)o[s]&&i.set(s,a);return i},r.parseFromString=function(e,t,n){if(e===null)throw new k("stringRepresentation cannot be null");for(var i=new Array(e.length),a=0,o=0,s=-1,l=0,u=0;u<e.length;)if(e.charAt(u)===`
|
|
256
|
+
*/const at=R("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),Cn=y.memo(r=>{const{ref:e,file:t,className:n,error:i,rightSlot:a,size:o,...s}=r,l=()=>i?d.jsxs(d.Fragment,{children:[d.jsx(v.LuIcon,{icon:El,color:"var(--base-a11)"}),d.jsx(v.Text,{accentColor:"base",className:"truncate",size:o,children:i})]}):t?d.jsxs(d.Fragment,{children:[d.jsx(v.LuIcon,{icon:Fl,color:"var(--base-a11)"}),d.jsx(v.Text,{className:"truncate",size:o,children:t.name})]}):d.jsx(d.Fragment,{children:d.jsx("div",{className:"flex w-full justify-center",children:d.jsx(v.Spinner,{size:o})})});return d.jsxs(v.Card,{className:et.cx(n,"flex w-full items-center gap-2"),ref:e,size:"xs",...s,children:[l(),a]})});Cn.displayName="FileCard";function Jt(r){return Array.isArray(r)?r.every(e=>typeof e=="string"):!1}class er{constructor(){M(this,"observers",new Set)}notify(e){for(const t of this.observers)t(e)}observe(e){return this.observers.add(e),()=>{this.observers.delete(e)}}}class mn extends er{constructor(t){const{identifier:n}=t;super();M(this,"identifier");this.identifier=n}getOptions(){return{identifier:this.identifier}}setOptions(t){this.identifier=t.identifier??this.identifier,this.notify(this)}serialize(){return{type:this.type,identifier:this.identifier}}}class Ve extends mn{constructor(t){const{label:n,description:i=null,required:a,image:o,...s}=t;super(s);M(this,"label");M(this,"description");M(this,"required");M(this,"image");this.label=n,this.description=i,this.required=a,this.image=o}getError(t){if(!(!this.required&&this.isValueBlank(t))){if(this.required&&this.isValueBlank(t))return"This field is required.";for(const n of this.getFieldValidators()){const i=n(t);if(i)return i}}}serialize(){return{...super.serialize(),label:this.label,description:this.description,required:this.required,image:this.image}}getOptions(){return{...super.getOptions(),label:this.label,description:this.description,required:this.required,image:this.image}}setOptions(t){const{label:n,description:i=null,required:a,image:o,...s}=t;this.label=n??this.label,this.description=i??this.description,this.required=a??this.required,this.image=o??this.image,super.setOptions(s)}isValueBlank(t){return this.areValuesEqual(t,this.blankValue())}cleanValue(t){return t}isValueClean(t){return this.areValuesEqual(t,this.cleanValue(t))}cleanSerializedValue(t){return t}isSerializedValueClean(t){return this.areSerializedValuesEqual(t,this.cleanSerializedValue(t))}isSerializedValueBlank(t){return this.areSerializedValuesEqual(t,this.blankSerializedValue())}getFieldValidators(){return[]}}const ce=y.createContext({}),wn=r=>{const[e,t]=y.useState(null);return y.useEffect(()=>{const n=URL.createObjectURL(r);return t(n),()=>{URL.revokeObjectURL(n)}},[r]),e},Lt=y.memo(r=>{const{file:e,...t}=r,n=wn(e);return n?d.jsx("img",{src:n,alt:e.name,...t}):null});Lt.displayName="ImageFile";const ya=y.createContext(()=>{throw new Error("No ImageViewerProvider found")}),Pr=()=>y.useContext(ya),_n=y.memo(r=>{const{file:e,onClose:t}=r,n=y.useCallback(()=>{ta.saveAs(e,e.name)},[e]);return d.jsx(v.Overlay.Root,{open:!0,onOpenChange:t,children:d.jsxs(v.Overlay.Content,{onOpenAutoFocus:v.preventDefault,children:[d.jsxs(v.ButtonGroup,{className:"absolute right-0 top-0 flex items-center gap-2 p-2",accentColor:"base",variant:"ghost",children:[d.jsxs(v.Tooltip.Root,{children:[d.jsx(v.Tooltip.Trigger,{asChild:!0,children:d.jsx(v.IconButton,{onClick:n,"aria-label":"download",children:d.jsx(v.LuIcon,{icon:ca})})}),d.jsx(v.Tooltip.Content,{size:"sm",children:"Download"})]}),d.jsx(v.Separator,{orientation:"vertical",size:"sm"}),d.jsx(v.Overlay.Close,{asChild:!0,children:d.jsx(v.IconButton,{onClick:t,"aria-label":"close",children:d.jsx(v.LuIcon,{icon:at})})})]}),d.jsx("figure",{className:"flex size-full items-center justify-center overflow-hidden p-4",children:d.jsx(Lt,{className:"max-h-full max-w-full",file:e})})]})})});_n.displayName="ImageViewer";const Ca=y.memo(r=>{const{children:e}=r,[t,n]=y.useState(null),i=y.useCallback(()=>{n(null)},[]),a=y.useCallback(s=>{n(s(i))},[i]),o=y.useCallback(()=>{t&&(t.onClose&&t.onClose(),i())},[i,t]);return d.jsxs(ya.Provider,{value:a,children:[e,t&&d.jsx(_n,{file:t.file,onClose:o})]})});Ca.displayName="FileViewerProvider";const de=y.memo(r=>{const{label:e,error:t,description:n,required:i,children:a,inputId:o,image:s,size:l}=r,[u,c]=y.useState(void 0),f=Pr();y.useEffect(()=>{s instanceof Promise?s.then(c).catch(console.error):c(s)},[s]);const h=y.useCallback(()=>{u&&f(()=>({file:u}))},[f,u]),p=i?`${e} *`:e;return d.jsxs("div",{className:"flex flex-col gap-1",children:[u&&d.jsx(Lt,{className:"h-[100px] w-full min-w-[300px] cursor-pointer rounded-md object-cover",file:u,onClick:h}),(!!e||!!n)&&d.jsxs("div",{className:"flex flex-col",children:[d.jsx("label",{className:"w-max max-w-full",htmlFor:o,children:d.jsx(v.Text,{size:l,className:"text-wrap",children:p})}),!!n&&d.jsx(v.Text,{accentColor:"base",size:l,children:n})]}),a,!!t&&d.jsx(v.Text,{accentColor:"danger",size:l,children:t})]})});de.displayName="InputWithLabel";const ma=r=>r.map(e=>d.jsx(y.Fragment,{children:e.render()},e.identifier)),Br=r=>r.map(e=>d.jsx(y.Fragment,{children:e.render()},e.identifier)),me=r=>{const{field:e}=r,{field:{value:t,name:n,onChange:i,onBlur:a,disabled:o},fieldState:{isTouched:s,error:l}}=je.useController({name:e.identifier});return{value:t,name:n,disabled:o,isTouched:s,error:(l==null?void 0:l.message)??"",onChange:i,onBlur:a}},An=y.memo(r=>{const{field:e}=r,{size:t}=y.use(ce),{value:n,name:i,onBlur:a,onChange:o,error:s,disabled:l}=me({field:e}),[u,c]=y.useState(""),[f,h]=y.useState(""),p=y.useCallback(S=>{o(S),a()},[o,a]),g=y.useCallback(S=>{n&&n.findIndex(O=>O===S.target.value.trim())>=0?h("All options must be unique"):S.target.value?h(""):h("Option cannot be empty"),c(S.target.value)},[c,n]),x=y.useCallback(()=>{if(f)return;if(!u.trim()){h("Option cannot be empty");return}const S=u.trim();p([...n,S]),c("")},[u,f,p,n]),m=y.useCallback(S=>{S.key==="Enter"&&(S.preventDefault(),x())},[x]),w=y.useCallback(S=>{const O=Array.from(n);O.splice(S,1),p(O)},[n,p]),_=y.useCallback(S=>{if(!S.destination)return;const O=S.source.index,N=S.destination.index,T=Array.from(n),[V]=T.splice(O,1);T.splice(N,0,V),p(T)},[p,n]),E=y.useCallback(()=>{a()},[a]);return d.jsx(gn.DragDropContext,{onDragEnd:_,children:d.jsxs(de,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:f||s,image:e.image,children:[(!l||n.length===0)&&d.jsxs("div",{className:"flex gap-2",children:[d.jsx(v.Input.Root,{className:"grow",accentColor:"base",variant:"surface",size:t,children:d.jsx(v.Input.Field,{value:u,onChange:g,onKeyDown:m,id:e.identifier,placeholder:e.placeholder,onBlur:E,name:i,disabled:l})}),d.jsx(v.IconButton,{size:t,accentColor:"base",variant:"soft",type:"button","aria-label":"Add option",disabled:!!f||l,onClick:x,children:d.jsx(v.LuIcon,{icon:Ye})})]}),n.length!==0&&d.jsx(gn.Droppable,{droppableId:`${e.identifier}-droppable`,children:S=>d.jsxs("div",{className:"flex flex-col gap-1",...S.droppableProps,ref:S.innerRef,children:[n.map((O,N)=>d.jsx(gn.Draggable,{draggableId:`${O}-draggable`,index:N,isDragDisabled:l,children:({draggableProps:T,dragHandleProps:V,innerRef:L})=>d.jsxs(v.Badge,{...V,...T,ref:L,className:"flex items-center justify-between gap-2",accentColor:"base",size:t,variant:"soft",children:[d.jsx(v.Text,{className:"truncate",highContrast:!0,children:typeof O=="object"&&"label"in O?O.label:O}),d.jsx(v.IconButton,{className:"bg-transparent!",size:t,variant:"ghost",type:"button","aria-label":"Delete option",accentColor:"base",disabled:l,onClick:()=>{w(N)},children:d.jsx(v.LuIcon,{icon:at})})]})},`${e.identifier}-${O}-${N}`)),S.placeholder]})})]})})});An.displayName="MultiStringFieldInput";class xt extends Ve{constructor(t){const{minimum_length:n,maximum_length:i,placeholder:a,...o}=t;super(o);M(this,"type","multi-string");M(this,"minLength");M(this,"maxLength");M(this,"placeholder");this.minLength=n??0,this.maxLength=i??1/0,this.placeholder=a??"Press enter to add a new option"}render(){return d.jsx(An,{field:this})}serialize(){return{...super.serialize(),minimum_length:this.minLength,maximum_length:this.maxLength,placeholder:this.placeholder}}getOptions(){return{...super.getOptions(),minimum_length:this.minLength,maximum_length:this.maxLength,placeholder:this.placeholder}}duplicate(t){return new xt({...this.getOptions(),identifier:t})}setOptions(t){const{minimum_length:n,maximum_length:i,placeholder:a,...o}=t;this.minLength=n??this.minLength,this.maxLength=i??this.maxLength,this.placeholder=a??this.placeholder,super.setOptions(o)}serializeValue(t){return t}deserializeValue(t){return t}getFieldValidators(){const t=super.getFieldValidators();return t.push(n=>{if(n.length<this.minLength)return`Must have at least ${this.minLength} options.`}),t.push(n=>{if(n.length>this.maxLength)return`Must have at most ${this.maxLength} options.`}),t}static deserialize(t){return new xt(t)}isSerializedValue(t){return Jt(t)}isValue(t){return Jt(t)}blankValue(){return[]}areValuesEqual(t,n){const i=new Set(t),a=new Set(n);return i.size===a.size&&i.isSubsetOf(a)}blankSerializedValue(){return[]}areSerializedValuesEqual(t,n){const i=new Set(t),a=new Set(n);return i.size===a.size&&i.isSubsetOf(a)}}class tr extends Ve{constructor(t){const{options:n,...i}=t;super(i);M(this,"options");this.options=n.map(a=>(typeof a=="string"&&(a={label:a,value:a}),a))}serialize(){return{...super.serialize(),options:this.options}}getOptions(){return{...super.getOptions(),options:this.options}}setOptions(t){const{options:n,...i}=t;this.options=(n==null?void 0:n.map(a=>(typeof a=="string"&&(a={label:a,value:a}),a)))??this.options,super.setOptions(i)}static getFieldCreationSchema(t=""){const n=t&&`${t}.`;return[{field:new xt({label:"Options",description:"List possible options for the user to select from.",required:!0,identifier:`${n}options`,minimum_length:2}),showDirectly:!0}]}}const Sn=y.memo(r=>{const{field:e}=r,{size:t}=y.use(ce),{value:n,name:i,onBlur:a,onChange:o,error:s,disabled:l}=me({field:e}),u=y.useCallback(f=>{o(!!f),a()},[a,o]),c=y.useCallback(()=>{a()},[a]);return d.jsx(de,{size:t,inputId:e.identifier,label:e.label,description:e.description,error:s,image:e.image,required:e.required,children:d.jsx(v.Checkbox.Root,{id:e.identifier,name:i,checked:n??!1,onCheckedChange:u,onBlur:c,size:t,accentColor:"base",variant:"surface",disabled:l,children:d.jsx(v.Checkbox.Indicator,{children:d.jsx(v.LuIcon,{icon:ke})})})})});Sn.displayName="BooleanFieldInput";class yt extends Ve{constructor(t){super(t);M(this,"type","boolean")}serialize(){return super.serialize()}getOptions(){return super.getOptions()}setOptions(t){super.setOptions(t)}duplicate(t){return new yt({...this.getOptions(),identifier:t})}static deserialize(t){return new yt(t)}serializeValue(t){return t}deserializeValue(t){return t}render(){return d.jsx(Sn,{field:this})}isSerializedValue(t){return typeof t=="boolean"}isValue(t){return typeof t=="boolean"}blankValue(){return!1}blankSerializedValue(){return!1}areSerializedValuesEqual(t,n){return t===n}areValuesEqual(t,n){return t===n}}const En=y.memo(r=>{const{field:e}=r,{size:t}=y.use(ce),{value:n,name:i,onBlur:a,onChange:o,error:s,disabled:l}=me({field:e}),u=y.useCallback(h=>{const p=h.target.valueAsNumber,g=isNaN(p)?null:p;o(g)},[o]),c=y.useCallback(()=>{a()},[a]),f=y.useCallback(h=>{h.key==="Enter"&&h.preventDefault()},[]);return d.jsx(de,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:s,image:e.image,children:d.jsx(v.Input.Root,{accentColor:"base",variant:"surface",size:t,children:d.jsx(v.Input.Field,{id:e.identifier,name:i,onChange:u,onBlur:c,value:n??"",type:"number",min:e.minimum,max:e.maximum,step:e.integers?1:"any",placeholder:e.placeholder??"Enter a number",disabled:l,onKeyDown:f})})})});En.displayName="NumberFieldInput";class Pe extends Ve{constructor(t){const{minimum:n=Number.MIN_SAFE_INTEGER,maximum:i=Number.MAX_SAFE_INTEGER,integers:a=!1,placeholder:o,...s}=t;super(s);M(this,"type","number");M(this,"minimum");M(this,"maximum");M(this,"integers");M(this,"placeholder");this.minimum=n,this.maximum=i,this.integers=a,this.placeholder=o}static getFieldCreationSchema(t=""){const n=t&&`${t}.`;return[{field:new Pe({label:"Minimum",description:"Minimum value",integers:!0,required:!1,identifier:`${n}minimum`}),showDirectly:!1},{field:new Pe({label:"Maximum",description:"Maximum value",integers:!0,required:!1,identifier:`${n}maximum`}),showDirectly:!1},{field:new yt({label:"Integers",description:"Whole numbers only",required:!1,identifier:`${n}integers`}),showDirectly:!1}]}getFieldValidators(){const t=super.getFieldValidators(),n=this.minimum,i=this.maximum;return typeof n=="number"&&t.push(a=>{if(typeof a=="number"&&a<n)return`Must be at least ${this.minimum}.`}),typeof i=="number"&&t.push(a=>{if(typeof a=="number"&&a>i)return`Must be at most ${this.maximum}.`}),this.integers&&t.push(a=>{if(typeof a=="number"&&!Number.isInteger(a))return"Must be a whole number."}),t}serialize(){return{...super.serialize(),minimum:this.minimum,maximum:this.maximum,integers:this.integers,placeholder:this.placeholder}}getOptions(){return{...super.getOptions(),minimum:this.minimum,maximum:this.maximum,integers:this.integers,placeholder:this.placeholder}}duplicate(t){return new Pe({...this.getOptions(),identifier:t})}setOptions(t){const{minimum:n,maximum:i,integers:a,placeholder:o,...s}=t;this.minimum=n??this.minimum,this.maximum=i??this.maximum,this.integers=a??this.integers,this.placeholder=o??this.placeholder,super.setOptions(s)}static deserialize(t){return new Pe(t)}serializeValue(t){return t}deserializeValue(t){return t}render(){return d.jsx(En,{field:this})}isSerializedValue(t){return this.isValue(t)}isValue(t){return typeof t=="number"&&!isNaN(t)||t===null}areValuesEqual(t,n){return t===n}blankValue(){return null}blankSerializedValue(){return null}areSerializedValuesEqual(t,n){return t===n}}const rr=1e4;class In extends Ve{constructor(t){const{minLength:n,maxLength:i,placeholder:a="",...o}=t;super(o);M(this,"minLength");M(this,"maxLength");M(this,"placeholder");this.minLength=n?Math.max(n,0):void 0,this.maxLength=i?Math.max(i,0):rr,this.placeholder=a}static getFieldCreationSchema(t=""){const n=t&&`${t}.`;return[{field:new Pe({label:"Minimum length",description:"Minimum number of characters",required:!1,identifier:`${n}minimum_length`,minimum:0,maximum:100,integers:!0}),showDirectly:!1},{field:new Pe({label:"Maximum length",description:"Maximum number of characters",required:!1,identifier:`${n}maximum_length`,minimum:1,maximum:rr,integers:!0}),showDirectly:!1}]}getFieldValidators(){const t=super.getFieldValidators();return this.minLength&&t.push(n=>{if(this.minLength&&(!n||n.length<this.minLength))return!this.required&&!n?void 0:`Minimum ${this.minLength} character(s).`}),this.maxLength&&t.push(n=>{if(typeof n=="string"&&this.maxLength&&n.length>this.maxLength)return`Maximum ${this.maxLength} character(s).`}),t}serialize(){return{...super.serialize(),minimum_length:this.minLength,maximum_length:this.maxLength,placeholder:this.placeholder}}getOptions(){return{...super.getOptions(),minLength:this.minLength,maxLength:this.maxLength,placeholder:this.placeholder}}setOptions(t){const{minLength:n,maxLength:i,placeholder:a,...o}=t;this.minLength=n,this.maxLength=i??this.maxLength,this.placeholder=a,super.setOptions(o)}serializeValue(t){return t}deserializeValue(t){return t}isSerializedValue(t){return typeof t=="string"}isValue(t){return typeof t=="string"}blankValue(){return""}blankSerializedValue(){return""}areSerializedValuesEqual(t,n){return t===n}areValuesEqual(t,n){return t===n}}const On=y.memo(r=>{const{field:e}=r,{size:t}=y.use(ce),{value:n,name:i,onBlur:a,onChange:o,error:s,disabled:l}=me({field:e}),u=y.useCallback(f=>{o(f),a()},[a,o]),c=y.useCallback(()=>{a()},[a]);return d.jsx(de,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:s,image:e.image,children:d.jsx(v.CheckboxGroup.Root,{id:e.identifier,name:i,className:"flex flex-col gap-1",accentColor:"base",variant:"surface",size:t,values:n,onValuesChange:u,disabled:l,children:e.options.map((f,h)=>d.jsxs("label",{className:"flex min-w-0 items-center gap-2",children:[d.jsx(v.CheckboxGroup.Item,{value:f.value,onBlur:c,children:d.jsx(v.CheckboxGroup.ItemIndicator,{children:d.jsx(v.LuIcon,{icon:ke})})}),d.jsx(v.Text,{size:t,accentColor:"base",className:"truncate",children:f.label})]},`${e.identifier}-${f.value}-${h}`))})})});On.displayName="CheckboxListFieldInput";class Ct extends tr{constructor(t){super(t);M(this,"type","checkbox-list")}serialize(){return super.serialize()}getOptions(){return super.getOptions()}duplicate(t){return new Ct({...this.getOptions(),identifier:t})}static deserialize(t){return new Ct(t)}serializeValue(t){return t}deserializeValue(t){return t}render(){return d.jsx(On,{field:this})}isSerializedValue(t){if(!Jt(t))return!1;const n=new Set(this.options.map(({value:i})=>i));return t.every(i=>n.has(i))}isValue(t){return this.isSerializedValue(t)}blankValue(){return[]}blankSerializedValue(){return[]}areSerializedValuesEqual(t,n){const i=new Set(t),a=new Set(n);return i.size===a.size&&i.isSubsetOf(a)}areValuesEqual(t,n){const i=new Set(t),a=new Set(n);return i.size===a.size&&i.isSubsetOf(a)}}const bn=y.memo(r=>{const{field:e}=r,{size:t}=y.use(ce),{value:n,name:i,onBlur:a,onChange:o,error:s,disabled:l}=me({field:e}),[u,c]=y.useState(!1),f=y.useCallback(p=>{o(p??null),a(),c(!1)},[o,a]),h=y.useCallback(p=>{c(p),p||a()},[a]);return d.jsx(de,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:s,image:e.image,children:d.jsxs(v.Popover.Root,{open:u,onOpenChange:h,children:[d.jsx(v.Popover.Trigger,{asChild:!0,children:d.jsxs(v.Button,{id:e.identifier,name:i,type:"button",className:"!justify-between",accentColor:"base",variant:"surface",size:t,disabled:l,children:[d.jsx(v.Text,{className:"truncate",highContrast:!!n,children:n?n.toLocaleString(void 0,{year:"numeric",month:"2-digit",day:"2-digit"}):"yyyy-mm-dd"}),d.jsx(v.LuIcon,{icon:Fr})]})}),d.jsx(v.Popover.Content,{align:"start",size:t,children:d.jsx(v.DayPicker,{size:t,required:!1,mode:"single",variant:"solid",selected:n??void 0,onSelect:f})})]})})});bn.displayName="DateFieldInput";class zt extends Ve{constructor(t){super(t);M(this,"type","date")}serialize(){return super.serialize()}getOptions(){return super.getOptions()}duplicate(t){return new zt({...this.getOptions(),identifier:t})}static deserialize(t){return new zt(t)}setOptions(t){super.setOptions(t)}serializeValue(t){return t?t.toISOString():null}deserializeValue(t){return t?new Date(t):null}render(){return d.jsx(bn,{field:this})}isSerializedValue(t){return typeof t!="string"&&t!==null?!1:this.isValue(this.deserializeValue(t))}isValue(t){return!(!(t instanceof Date)&&t!==null||t instanceof Date&&isNaN(t.getTime()))}blankValue(){return null}blankSerializedValue(){return null}areSerializedValuesEqual(t,n){return t===n}areValuesEqual(t,n){return!t&&!n?!0:!t||!n?!1:t.getTime()===n.getTime()}}var W=(r=>(r.Text="text",r.Selection="selection",r.Numeric="numeric",r.Temporal="temporal",r.Capture="capture",r.Assessment="assessment",r.Verification="verification",r))(W||{});const Nn=y.memo(r=>{const{field:e}=r,{size:t}=y.use(ce),{value:n,name:i,onBlur:a,onChange:o,error:s,disabled:l}=me({field:e}),u=y.useCallback(f=>{o(f),a()},[a,o]),c=y.useCallback(f=>{f||a()},[a]);return d.jsx(de,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:s,image:e.image,children:d.jsxs(v.Menu.Root,{onOpenChange:c,align:"start",children:[d.jsx(v.Menu.ClickTrigger,{children:d.jsxs(v.Button,{id:e.identifier,name:i,className:"!justify-between",variant:"surface",type:"button",size:t,accentColor:"base",disabled:l,children:[d.jsx(v.Text,{className:"truncate",highContrast:n&&n.length>0,children:n&&n.length>0?n.join(", "):e.placeholder??"Select one or more..."}),d.jsx(v.LuIcon,{icon:Fr})]})}),d.jsx(v.Menu.Content,{size:t,children:d.jsx(v.Menu.Scroll,{children:d.jsxs(v.Menu.MultiSelectGroup,{values:n,onValuesChange:u,children:[d.jsxs(v.Menu.SelectAllItem,{children:[d.jsx(v.Menu.CheckboxItemIndicator,{children:f=>f?d.jsx(v.LuIcon,{icon:Vr}):d.jsx(v.LuIcon,{icon:ke})}),"Select all"]}),e.options.map((f,h)=>d.jsxs(v.Menu.MultiSelectItem,{value:f.value,children:[d.jsx(v.Menu.SelectedIndicator,{children:d.jsx(v.LuIcon,{icon:ke})}),f.label]},`${e.identifier}-${f.value}-${h}`))]})})})]})})});Nn.displayName="MultiSelectFieldInput";class it extends tr{constructor(t){const{placeholder:n,...i}=t;super(i);M(this,"type","multi-select");M(this,"placeholder");this.placeholder=n}serialize(){return super.serialize()}getOptions(){return{...super.getOptions(),placeholder:this.placeholder}}duplicate(t){return new it({...this.getOptions(),identifier:t})}setOptions(t){const{placeholder:n}=t;this.placeholder=n,super.setOptions(t)}static deserialize(t){return new it(t)}serializeValue(t){return t}deserializeValue(t){return t}render(){return d.jsx(Nn,{field:this})}isSerializedValue(t){if(!Jt(t))return!1;const n=new Set(this.options.map(({value:i})=>i));return t.every(i=>n.has(i))}isValue(t){return this.isSerializedValue(t)}blankValue(){return[]}areValuesEqual(t,n){const i=new Set(t),a=new Set(n);return i.size===a.size&&i.isSubsetOf(a)}blankSerializedValue(){return[]}areSerializedValuesEqual(t,n){const i=new Set(t),a=new Set(n);return i.size===a.size&&i.isSubsetOf(a)}}const Tn=y.memo(r=>{const{field:e}=r,{size:t}=y.use(ce),{value:n,name:i,onBlur:a,onChange:o,error:s,disabled:l}=me({field:e}),u=y.useCallback(h=>{o(h??null),a()},[a,o]),c=y.useCallback(h=>{h||a()},[a]),f=y.useMemo(()=>e.options.find(h=>h.value===n),[e.options,n]);return d.jsx(de,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:s,image:e.image,children:d.jsxs(v.Menu.Root,{onOpenChange:c,align:"start",children:[d.jsx(v.Menu.ClickTrigger,{children:d.jsxs(v.Button,{id:e.identifier,name:i,className:"!justify-between",accentColor:"base",variant:"surface",type:"button",size:t,disabled:l,children:[d.jsx(v.Text,{className:"truncate",highContrast:!!f,children:f?f.label:e.placeholder??"Select one..."}),d.jsx(v.LuIcon,{icon:Fr})]})}),d.jsx(v.Menu.Content,{size:t,children:d.jsx(v.Menu.Scroll,{children:d.jsx(v.Menu.SelectGroup,{required:!1,value:n??void 0,onValueChange:u,children:e.options.map((h,p)=>d.jsxs(v.Menu.SelectItem,{value:h.value,children:[d.jsx(v.Menu.SelectedIndicator,{children:d.jsx(v.LuIcon,{icon:ke})}),h.label]},`${e.identifier}-${h.value}-${p}`))})})})]})})});Tn.displayName="SelectFieldInput";class ot extends tr{constructor(t){const{placeholder:n,...i}=t;super(i);M(this,"type","select");M(this,"placeholder");this.placeholder=n}serialize(){return super.serialize()}getOptions(){return{...super.getOptions(),placeholder:this.placeholder}}duplicate(t){return new ot({...this.getOptions(),identifier:t})}setOptions(t){const{placeholder:n}=t;this.placeholder=n,super.setOptions(t)}static deserialize(t){return new ot(t)}serializeValue(t){return t}deserializeValue(t){return t}render(){return d.jsx(Tn,{field:this})}isSerializedValue(t){return typeof t!="string"&&t!==null?!1:new Set([null,...this.options.map(({value:i})=>i)]).has(t)}isValue(t){return this.isSerializedValue(t)}blankValue(){return null}areValuesEqual(t,n){return t===n}blankSerializedValue(){return null}areSerializedValuesEqual(t,n){return t===n}}const Mn=y.memo(r=>{const{field:e}=r,{size:t}=y.use(ce),{value:n,name:i,onBlur:a,onChange:o,error:s,disabled:l}=me({field:e}),u=y.useCallback(h=>{o(h)},[o]),c=y.useCallback(()=>{a()},[a]),f=y.useMemo(()=>Array.from({length:e.length},()=>U.v4()),[e.length]);return d.jsx(de,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:s,image:e.image,children:d.jsxs(v.OneTimePasswordField.Root,{id:e.identifier,name:i,value:n,onValueChange:u,validationType:e.validationType,disabled:l,orientation:"horizontal",dir:"ltr",type:"text",autoComplete:"off",autoFocus:!1,autoSubmit:!1,className:"p-0.25 flex h-max w-full gap-1 overflow-x-auto",accentColor:"base",variant:"surface",size:t,onBlur:c,children:[f.map(h=>d.jsx(v.OneTimePasswordField.Input,{id:h},h)),d.jsx(v.OneTimePasswordField.HiddenInput,{})]})})});Mn.displayName="OTPFieldInput";class mt extends Ve{constructor(t){const{length:n,validationType:i,...a}=t;super(a);M(this,"type","otp");M(this,"length");M(this,"validationType");this.length=n,this.validationType=i}static getFieldCreationSchema(t=""){const n=t&&`${t}.`;return[{field:new Pe({label:"Length",integers:!0,required:!1,minimum:1,maximum:16,identifier:`${n}length`}),showDirectly:!1},{field:new ot({label:"Type",required:!1,identifier:`${n}validationType`,options:[{value:"none",label:"Any"},{value:"numeric",label:"Numeric"},{value:"alpha",label:"Alpha"},{value:"alphanumeric",label:"Alphanumeric"}]}),showDirectly:!1}]}getFieldValidators(){const t=super.getFieldValidators(),n=this.length;return t.push(i=>{if(i.length!=n)return`Must be ${n} characters.`}),t}serialize(){return{...super.serialize(),length:this.length,validationType:this.validationType}}getOptions(){return{...super.getOptions(),length:this.length,validationType:this.validationType}}duplicate(t){return new mt({...this.getOptions(),identifier:t})}setOptions(t){const{length:n,validationType:i,...a}=t;this.length=n??this.length,this.validationType=i??this.validationType,super.setOptions(a)}static deserialize(t){return new mt(t)}serializeValue(t){return t}deserializeValue(t){return t}render(){return d.jsx(Mn,{field:this})}isSerializedValue(t){return typeof t=="string"}isValue(t){return typeof t=="string"}blankValue(){return""}areValuesEqual(t,n){return t===n}blankSerializedValue(){return""}areSerializedValuesEqual(t,n){return t===n}}const wt={pass:{label:"Pass",icon:Il},fail:{label:"Fail",icon:Nl},na:{label:"N/A",icon:bl}},kt=Object.keys(wt);class st extends File{constructor(t,...n){super(...n);M(this,"uuid");this.uuid=t}static from(t,n){return new st(t,[n],n.name,{lastModified:n.lastModified,type:n.type})}}class _t extends Promise{constructor(t,n){super(t);M(this,"_uuid");this._uuid=n}get uuid(){return this._uuid}set uuid(t){this._uuid=t}static from(t,n){return new _t((i,a)=>{Promise.resolve(t).then(i).catch(a)},n)}then(t,n){const i=super.then(t,n);return i.uuid=this.uuid,i}catch(t){const n=super.catch(t);return n.uuid=this.uuid,n}finally(t){const n=super.finally(t);return n.uuid=this.uuid,n}}function wa(r){return Array.isArray(r)?r.every(e=>e instanceof _t||e instanceof st):!1}function Lr(r,e){const t=new Set(r.map(({uuid:i})=>i)),n=new Set(e.map(({uuid:i})=>i));return t.size===n.size&&t.isSubsetOf(n)}const Dn=y.memo(r=>{const{ref:e,file:t,error:n,rightSlot:i,className:a,size:o,...s}=r;return d.jsxs(v.Card,{className:et.cx(a,"p-0! relative flex h-48 w-full flex-col overflow-hidden"),ref:e,size:"xs",...s,children:[!t&&!n&&d.jsx("div",{className:"absolute inset-0 flex grow items-center justify-center",children:d.jsx(v.Spinner,{})}),!!t&&!n&&d.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-hidden p-3",children:d.jsx(Lt,{className:"size-full max-w-full object-cover",file:t})}),(!!t||!!n)&&d.jsxs(d.Fragment,{children:[d.jsx(v.Separator,{size:"full"}),d.jsxs("div",{className:"flex w-full shrink-0 items-center gap-2 self-end p-3",children:[n?d.jsx(v.LuIcon,{color:"var(--base-11)",icon:fa}):t&&d.jsx(v.LuIcon,{color:"var(--base-11)",icon:ha}),d.jsx(v.Text,{className:"truncate",size:o,children:n??(t==null?void 0:t.name)}),i]})]})]})});Dn.displayName="ImageCard";const Fn=y.memo(r=>{const{file:e,...t}=r,n=wn(e);return n?d.jsx("video",{src:n,...t}):null});Fn.displayName="VideoFile";const Vn=y.memo(r=>{const{ref:e,file:t,className:n,error:i,rightSlot:a,size:o,...s}=r;return d.jsxs(v.Card,{className:et.cx(n,"p-0! relative flex h-48 w-full flex-col overflow-hidden"),ref:e,size:"xs",...s,children:[!t&&!i&&d.jsx("div",{className:"absolute inset-0 flex grow items-center justify-center",children:d.jsx(v.Spinner,{})}),!!t&&!i&&d.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-hidden p-3",children:d.jsx(Fn,{className:"size-full max-w-full object-cover",file:t,controls:!0})}),(!!t||!!i)&&d.jsxs(d.Fragment,{children:[d.jsx(v.Separator,{size:"full"}),d.jsxs("div",{className:"flex w-full shrink-0 items-center gap-2 self-end p-3",children:[i?d.jsx(v.LuIcon,{color:"var(--base-11)",icon:fa}):t&&d.jsx(v.LuIcon,{color:"var(--base-11)",icon:jl}),d.jsx(v.Text,{className:"truncate",size:o,children:i??(t==null?void 0:t.name)}),a]})]})]})});Vn.displayName="VideoCard";const Pn=y.memo(r=>{const{fileOrPromise:e,onRemove:t,disabled:n,size:i}=r,[a,o]=y.useState(e instanceof _t?null:e),[s,l]=y.useState(null),u=Pr();y.useEffect(()=>{if(l(null),!(e instanceof _t)){o(e);return}o(null);let w=!0;return e.then(_=>{w&&o(_)}).catch(_=>{w&&l(_ instanceof Error?_.message:"Unknown error")}),()=>{w=!1}},[e]);const c=y.useCallback(()=>{if(!a)return;const w=new Blob([a]);ta.saveAs(w,a.name)},[a]),f=y.useCallback(()=>{t(e)},[t,e]),h=y.useCallback(()=>{if(!a)return;const w=URL.createObjectURL(a);window.open(w,"_blank"),URL.revokeObjectURL(w)},[a]),p=y.useCallback(()=>{a&&u(w=>({file:a,onDelete:n?void 0:()=>{f(),w()}}))},[n,f,u,a]),g=y.useMemo(()=>d.jsx("div",{className:"flex grow justify-end",children:d.jsxs(v.Menu.Root,{modal:!0,children:[d.jsx(v.Menu.ClickTrigger,{children:d.jsx(v.IconButton,{onClick:v.stopPropagation,type:"button",variant:"ghost",accentColor:"base",size:i,children:d.jsx(v.LuIcon,{icon:da})})}),d.jsxs(v.Menu.Content,{size:i,children:[d.jsxs(v.Menu.Item,{onSelect:c,disabled:!a,children:[d.jsx(v.LuIcon,{icon:ca})," Download"]}),n?null:d.jsxs(d.Fragment,{children:[d.jsx(v.Menu.Separator,{}),d.jsxs(v.Menu.Item,{onSelect:f,children:[d.jsx(v.LuIcon,{icon:gt})," Delete"]})]})]})]})}),[n,f,c,a,i]),x=!!(a!=null&&a.type.startsWith("image/")),m=!!(a!=null&&a.type.startsWith("video/"));return x?d.jsx(Dn,{className:"cursor-pointer",onClick:p,file:a,error:s??void 0,rightSlot:g,size:i}):m?d.jsx(Vn,{className:"cursor-pointer",onClick:p,file:a,error:s??void 0,rightSlot:g,size:i}):d.jsx(Cn,{className:"cursor-pointer",file:a,error:s??void 0,onClick:h,rightSlot:g,size:i})});Pn.displayName="DisplayFile";const Bn=y.memo(r=>{const{field:e}=r,{size:t}=y.use(ce),{value:n,name:i,onBlur:a,onChange:o,error:s,disabled:l}=me({field:e}),u=y.useRef(null),c=y.useCallback(S=>{const O=e.cleanValue({...n,status:S});o(O),a()},[e,a,o,n]),f=y.useCallback(S=>{const O=S.target.value,N={...n,notes:O};o(N)},[n,o]),h=y.useCallback(()=>{a()},[a]),p=y.useCallback(S=>{const O=n.files.filter(({uuid:N})=>N!==S.uuid);o({...n,files:O}),a()},[o,a,n]),g=y.useCallback(()=>{var S;(S=u.current)==null||S.click()},[]),x=y.useCallback(S=>{const O=Array.from(S.target.files??[]).map(T=>st.from(U.v4(),T)),N={...n,files:[...n.files,...O]};o(N),a()},[a,o,n]);y.useEffect(()=>{if(!u.current)return;const S=new AbortController;return u.current.addEventListener("cancel",()=>{a()},{signal:S.signal}),()=>{S.abort()}},[a,n]);const m=n.status&&e.showNotesAndFilesOn.includes(n.status),w=`${e.identifier}-status`,_=`${e.identifier}-notes`,E=`${e.identifier}-files`;return d.jsx(de,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:s,image:e.image,children:d.jsxs("div",{className:"flex flex-col gap-2",children:[d.jsx(v.RadioGroup.Root,{id:w,className:"flex gap-2",name:i,value:n.status,disabled:l,accentColor:"base",variant:"surface",size:t,onValueChange:c,children:kt.map(S=>{const{label:O}=wt[S];return d.jsxs("label",{className:"flex min-w-0 items-center gap-2",children:[d.jsx(v.RadioGroup.Item,{value:S,children:d.jsx(v.RadioGroup.Indicator,{children:d.jsx(v.LuIcon,{icon:sa,className:"fill-current"})})}),d.jsx(v.Text,{size:t,accentColor:"base",className:"truncate",children:O})]},`${e.identifier}-${S}`)})}),m&&d.jsxs(d.Fragment,{children:[d.jsx("div",{children:d.jsx(v.TextArea,{id:_,value:n.notes??"",name:i,onChange:f,onBlur:h,className:"field-sizing-content min-h-12 w-full",placeholder:"Notes",resize:"vertical",accentColor:"base",variant:"surface",size:t,disabled:l})}),d.jsxs("div",{className:"flex flex-col gap-2",children:[d.jsxs(v.Button,{className:"w-max",size:t,variant:"soft",accentColor:"base",onClick:g,type:"button",disabled:l,children:[d.jsx(v.LuIcon,{icon:yn}),"Select files"]}),d.jsx("input",{id:E,name:i,type:"file",ref:u,multiple:!0,className:"hidden",onChange:x,value:""}),n.files.length>0&&d.jsx("div",{className:"flex h-max flex-wrap gap-2",children:n.files.map(S=>d.jsx(Pn,{size:t,fileOrPromise:S,onRemove:p,disabled:l},S.uuid))})]})]})]})})});Bn.displayName="PassFailFieldInput";const Ln=r=>typeof r=="string"&&kt.includes(r),_a=r=>!(r===null||typeof r!="object"||!("status"in r)||!Ln(r.status)||!("notes"in r)||typeof r.notes!="string"||!("files"in r)||!(Array.isArray(r.files)&&r.files.length===0)),Aa=r=>!(r===null||typeof r!="object"||!("status"in r)||!Ln(r.status)||!("notes"in r)||typeof r.notes!="string"||!("files"in r)||!wa(r.files)),Sa=r=>({status:r.status,notes:r.notes,files:[]}),Ea=r=>({status:r.status,notes:r.notes,files:[]}),Ia=(r,e)=>!(r.status!==e.status||r.notes!==e.notes||!Lr(r.files,e.files)),Oa=(r,e)=>!(r.status!==e.status||r.notes!==e.notes||r.files.length!==e.files.length);class At extends Ve{constructor(t){const{showNotesAndFilesOn:n,...i}=t;super(i);M(this,"type","pass-fail");M(this,"showNotesAndFilesOn");this.showNotesAndFilesOn=n}static getFieldCreationSchema(t=""){const n=t&&`${t}.`;return[{field:new it({identifier:`${n}showNotesAndFilesOn`,label:"Show notes and files on",description:"Show the notes and files on desired statuses.",options:kt.map(i=>{const{label:a}=wt[i];return{value:i,label:a}}),required:!1}),showDirectly:!1}]}serialize(){return{...super.serialize(),showNotesAndFilesOn:this.showNotesAndFilesOn}}getOptions(){return{...super.getOptions(),showNotesAndFilesOn:this.showNotesAndFilesOn}}duplicate(t){return new At({...this.getOptions(),identifier:t})}setOptions(t){const{showNotesAndFilesOn:n,...i}=t;this.showNotesAndFilesOn=n??this.showNotesAndFilesOn,super.setOptions(i)}getFieldValidators(){const t=super.getFieldValidators(),n=this.showNotesAndFilesOn,i=this.blankValue();return n.length>0&&(t.push(a=>{if(!(!a.status||!n.includes(a.status))&&i.notes===a.notes)return"Notes is required."}),t.push(a=>{if(!(!a.status||!n.includes(a.status))&&Lr(i.files,a.files))return"Files is required."})),t}static deserialize(t){return new At({...t,showNotesAndFilesOn:t.showNotesAndFilesOn??!1})}serializeValue(t){return Sa(t)}deserializeValue(t){return Ea(t)}render(){return d.jsx(Bn,{field:this})}isSerializedValue(t){return _a(t)}isValue(t){return Aa(t)}areValuesEqual(t,n){return Ia(t,n)}blankValue(){return{status:null,notes:"",files:[]}}cleanValue(t){return t.status&&this.showNotesAndFilesOn.includes(t.status)?t:{status:t.status,notes:"",files:[]}}cleanSerializedValue(t){return super.cleanSerializedValue(t)}blankSerializedValue(){return{status:null,notes:"",files:[]}}areSerializedValuesEqual(t,n){return Oa(t,n)}}const zn=y.memo(r=>{const{field:e}=r,{size:t}=y.use(ce),{value:n,name:i,onBlur:a,onChange:o,error:s,disabled:l}=me({field:e}),u=y.useCallback(h=>{o(h),a()},[a,o]),c=y.useCallback(()=>{a()},[a]),f=y.useCallback(()=>{o(null),a()},[a,o]);return d.jsx(de,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:s,image:e.image,children:d.jsxs(v.RadioGroup.Root,{id:e.identifier,name:i,className:"flex flex-col gap-1",accentColor:"base",variant:"surface",size:t,value:n??"",onValueChange:u,disabled:l,children:[e.options.map((h,p)=>d.jsxs("label",{className:"flex min-w-0 items-center gap-2",children:[d.jsx(v.RadioGroup.Item,{value:h.value,onBlur:c,children:d.jsx(v.RadioGroup.Indicator,{children:d.jsx(v.LuIcon,{icon:sa,className:"fill-current"})})}),d.jsx(v.Text,{size:t,accentColor:"base",className:"truncate",children:h.label})]},`${e.identifier}-${h.value}-${p}`)),!!n&&d.jsxs(v.Button,{onClick:f,className:"-mx-2 w-max",type:"button",variant:"ghost",accentColor:"base",size:t,children:[d.jsx(v.LuIcon,{icon:at}),"Clear"]})]})})});zn.displayName="RadioFieldInput";class St extends tr{constructor(t){super(t);M(this,"type","radio")}serialize(){return super.serialize()}getOptions(){return super.getOptions()}duplicate(t){return new St({...this.getOptions(),identifier:t})}setOptions(t){super.setOptions(t)}static deserialize(t){return new St(t)}serializeValue(t){return t}deserializeValue(t){return t}render(){return d.jsx(zn,{field:this})}isSerializedValue(t){return typeof t!="string"&&t!==null?!1:new Set([null,...this.options.map(({value:i})=>i)]).has(t)}isValue(t){return this.isSerializedValue(t)}blankValue(){return null}areValuesEqual(t,n){return t===n}blankSerializedValue(){return null}areSerializedValuesEqual(t,n){return t===n}}const Yl=et.cva(["group flex cursor-pointer items-center justify-center text-yellow-500 transition-colors disabled:pointer-events-none disabled:opacity-50"],{variants:{size:{xs:["size-5"],sm:["size-6"],md:["size-7"],lg:["size-8"],xl:["size-9"]}}}),kn=y.memo(r=>{const{field:e}=r,{size:t}=y.use(ce),{value:n,name:i,onBlur:a,onChange:o,error:s,disabled:l}=me({field:e}),u=y.useCallback(h=>{o(h),a()},[a,o]),c=y.useCallback(()=>{o(null),a()},[a,o]),f=Array.from({length:e.maxRating},(h,p)=>p+1);return d.jsx(de,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:s,image:e.image,children:d.jsxs("div",{className:"flex flex-row items-center gap-1",children:[d.jsx(v.Rating.Root,{id:e.identifier,name:i,className:"flex items-center gap-0.5",value:n,onValueChange:u,disabled:l,children:f.map(h=>d.jsx(v.Rating.Item,{value:h,className:Yl({size:t}),children:d.jsx(v.LuIcon,{icon:xa,className:"size-full group-data-[active=true]:fill-current"})},`${e.identifier}-${h}`))}),!l&&n!==null&&d.jsx(v.IconButton,{onClick:c,type:"button",variant:"ghost",accentColor:"base",size:t,children:d.jsx(v.LuIcon,{icon:at})})]})})});kn.displayName="RatingFieldInput";class Et extends Ve{constructor(t){const{maxRating:n,...i}=t;super(i);M(this,"type","rating");M(this,"maxRating");this.maxRating=n}static getFieldCreationSchema(t=""){const n=t&&`${t}.`;return[{field:new Pe({label:"Max Rating",description:"Maximum rating value",integers:!0,required:!1,minimum:1,maximum:10,identifier:`${n}maxRating`}),showDirectly:!1}]}getFieldValidators(){const t=super.getFieldValidators(),n=this.maxRating;return t.push(i=>{if(typeof i=="number"&&(i<1||i>n))return`Rating must be between 1 and ${n}.`}),t}serialize(){return{...super.serialize(),maxRating:this.maxRating}}getOptions(){return{...super.getOptions(),maxRating:this.maxRating}}duplicate(t){return new Et({...this.getOptions(),identifier:t})}setOptions(t){const{maxRating:n,...i}=t;this.maxRating=n??this.maxRating,super.setOptions(i)}static deserialize(t){return new Et(t)}serializeValue(t){return t}deserializeValue(t){return t}render(){return d.jsx(kn,{field:this})}isSerializedValue(t){return this.isValue(t)}isValue(t){return typeof t=="number"&&!isNaN(t)||t===null}areValuesEqual(t,n){return t===n}blankValue(){return null}blankSerializedValue(){return null}areSerializedValuesEqual(t,n){return t===n}}const ba=y.createContext(()=>{throw new Error("No ScannerProvider found")}),Zl=()=>y.use(ba);function Kl(r,e){var t=Object.setPrototypeOf;t?t(r,e):r.__proto__=e}function Ql(r,e){e===void 0&&(e=r.constructor);var t=Error.captureStackTrace;t&&t(r,e)}var Jl=function(){var r=function(t,n){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,a){i.__proto__=a}||function(i,a){for(var o in a)Object.prototype.hasOwnProperty.call(a,o)&&(i[o]=a[o])},r(t,n)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),eu=function(r){Jl(e,r);function e(t,n){var i=this.constructor,a=r.call(this,t,n)||this;return Object.defineProperty(a,"name",{value:i.name,enumerable:!1,configurable:!0}),Kl(a,i.prototype),Ql(a),a}return e}(Error),tu=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),Ue=function(r){tu(e,r);function e(t){t===void 0&&(t=void 0);var n=r.call(this,t)||this;return n.message=t,n}return e.prototype.getKind=function(){var t=this.constructor;return t.kind},e.kind="Exception",e}(eu),ru=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),Ze=function(r){ru(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e.kind="ArgumentException",e}(Ue),nu=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),k=function(r){nu(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e.kind="IllegalArgumentException",e}(Ue),iu=function(){function r(e){if(this.binarizer=e,e===null)throw new k("Binarizer must be non-null.")}return r.prototype.getWidth=function(){return this.binarizer.getWidth()},r.prototype.getHeight=function(){return this.binarizer.getHeight()},r.prototype.getBlackRow=function(e,t){return this.binarizer.getBlackRow(e,t)},r.prototype.getBlackMatrix=function(){return(this.matrix===null||this.matrix===void 0)&&(this.matrix=this.binarizer.getBlackMatrix()),this.matrix},r.prototype.isCropSupported=function(){return this.binarizer.getLuminanceSource().isCropSupported()},r.prototype.crop=function(e,t,n,i){var a=this.binarizer.getLuminanceSource().crop(e,t,n,i);return new r(this.binarizer.createBinarizer(a))},r.prototype.isRotateSupported=function(){return this.binarizer.getLuminanceSource().isRotateSupported()},r.prototype.rotateCounterClockwise=function(){var e=this.binarizer.getLuminanceSource().rotateCounterClockwise();return new r(this.binarizer.createBinarizer(e))},r.prototype.rotateCounterClockwise45=function(){var e=this.binarizer.getLuminanceSource().rotateCounterClockwise45();return new r(this.binarizer.createBinarizer(e))},r.prototype.toString=function(){try{return this.getBlackMatrix().toString()}catch{return""}},r}(),au=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),we=function(r){au(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e.getChecksumInstance=function(){return new e},e.kind="ChecksumException",e}(Ue),ou=function(){function r(e){this.source=e}return r.prototype.getLuminanceSource=function(){return this.source},r.prototype.getWidth=function(){return this.source.getWidth()},r.prototype.getHeight=function(){return this.source.getHeight()},r}(),ie=function(){function r(){}return r.arraycopy=function(e,t,n,i,a){for(;a--;)n[i++]=e[t++]},r.currentTimeMillis=function(){return Date.now()},r}(),su=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),Un=function(r){su(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e.kind="IndexOutOfBoundsException",e}(Ue),lu=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),Na=function(r){lu(e,r);function e(t,n){t===void 0&&(t=void 0),n===void 0&&(n=void 0);var i=r.call(this,n)||this;return i.index=t,i.message=n,i}return e.kind="ArrayIndexOutOfBoundsException",e}(Un),uu=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},fe=function(){function r(){}return r.fill=function(e,t){for(var n=0,i=e.length;n<i;n++)e[n]=t},r.fillWithin=function(e,t,n,i){r.rangeCheck(e.length,t,n);for(var a=t;a<n;a++)e[a]=i},r.rangeCheck=function(e,t,n){if(t>n)throw new k("fromIndex("+t+") > toIndex("+n+")");if(t<0)throw new Na(t);if(n>e)throw new Na(n)},r.asList=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return e},r.create=function(e,t,n){var i=Array.from({length:e});return i.map(function(a){return Array.from({length:t}).fill(n)})},r.createInt32Array=function(e,t,n){var i=Array.from({length:e});return i.map(function(a){return Int32Array.from({length:t}).fill(n)})},r.equals=function(e,t){if(!e||!t||!e.length||!t.length||e.length!==t.length)return!1;for(var n=0,i=e.length;n<i;n++)if(e[n]!==t[n])return!1;return!0},r.hashCode=function(e){var t,n;if(e===null)return 0;var i=1;try{for(var a=uu(e),o=a.next();!o.done;o=a.next()){var s=o.value;i=31*i+s}}catch(l){t={error:l}}finally{try{o&&!o.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}return i},r.fillUint8Array=function(e,t){for(var n=0;n!==e.length;n++)e[n]=t},r.copyOf=function(e,t){return e.slice(0,t)},r.copyOfUint8Array=function(e,t){if(e.length<=t){var n=new Uint8Array(t);return n.set(e),n}return e.slice(0,t)},r.copyOfRange=function(e,t,n){var i=n-t,a=new Int32Array(i);return ie.arraycopy(e,t,a,0,i),a},r.binarySearch=function(e,t,n){n===void 0&&(n=r.numberComparator);for(var i=0,a=e.length-1;i<=a;){var o=a+i>>1,s=n(t,e[o]);if(s>0)i=o+1;else if(s<0)a=o-1;else return o}return-i-1},r.numberComparator=function(e,t){return e-t},r}(),$=function(){function r(){}return r.numberOfTrailingZeros=function(e){var t;if(e===0)return 32;var n=31;return t=e<<16,t!==0&&(n-=16,e=t),t=e<<8,t!==0&&(n-=8,e=t),t=e<<4,t!==0&&(n-=4,e=t),t=e<<2,t!==0&&(n-=2,e=t),n-(e<<1>>>31)},r.numberOfLeadingZeros=function(e){if(e===0)return 32;var t=1;return e>>>16||(t+=16,e<<=16),e>>>24||(t+=8,e<<=8),e>>>28||(t+=4,e<<=4),e>>>30||(t+=2,e<<=2),t-=e>>>31,t},r.toHexString=function(e){return e.toString(16)},r.toBinaryString=function(e){return String(parseInt(String(e),2))},r.bitCount=function(e){return e=e-(e>>>1&1431655765),e=(e&858993459)+(e>>>2&858993459),e=e+(e>>>4)&252645135,e=e+(e>>>8),e=e+(e>>>16),e&63},r.truncDivision=function(e,t){return Math.trunc(e/t)},r.parseInt=function(e,t){return t===void 0&&(t=void 0),parseInt(e,t)},r.MIN_VALUE_32_BITS=-2147483648,r.MAX_VALUE=Number.MAX_SAFE_INTEGER,r}(),_e=function(){function r(e,t){e===void 0?(this.size=0,this.bits=new Int32Array(1)):(this.size=e,t==null?this.bits=r.makeArray(e):this.bits=t)}return r.prototype.getSize=function(){return this.size},r.prototype.getSizeInBytes=function(){return Math.floor((this.size+7)/8)},r.prototype.ensureCapacity=function(e){if(e>this.bits.length*32){var t=r.makeArray(e);ie.arraycopy(this.bits,0,t,0,this.bits.length),this.bits=t}},r.prototype.get=function(e){return(this.bits[Math.floor(e/32)]&1<<(e&31))!==0},r.prototype.set=function(e){this.bits[Math.floor(e/32)]|=1<<(e&31)},r.prototype.flip=function(e){this.bits[Math.floor(e/32)]^=1<<(e&31)},r.prototype.getNextSet=function(e){var t=this.size;if(e>=t)return t;var n=this.bits,i=Math.floor(e/32),a=n[i];a&=~((1<<(e&31))-1);for(var o=n.length;a===0;){if(++i===o)return t;a=n[i]}var s=i*32+$.numberOfTrailingZeros(a);return s>t?t:s},r.prototype.getNextUnset=function(e){var t=this.size;if(e>=t)return t;var n=this.bits,i=Math.floor(e/32),a=~n[i];a&=~((1<<(e&31))-1);for(var o=n.length;a===0;){if(++i===o)return t;a=~n[i]}var s=i*32+$.numberOfTrailingZeros(a);return s>t?t:s},r.prototype.setBulk=function(e,t){this.bits[Math.floor(e/32)]=t},r.prototype.setRange=function(e,t){if(t<e||e<0||t>this.size)throw new k;if(t!==e){t--;for(var n=Math.floor(e/32),i=Math.floor(t/32),a=this.bits,o=n;o<=i;o++){var s=o>n?0:e&31,l=o<i?31:t&31,u=(2<<l)-(1<<s);a[o]|=u}}},r.prototype.clear=function(){for(var e=this.bits.length,t=this.bits,n=0;n<e;n++)t[n]=0},r.prototype.isRange=function(e,t,n){if(t<e||e<0||t>this.size)throw new k;if(t===e)return!0;t--;for(var i=Math.floor(e/32),a=Math.floor(t/32),o=this.bits,s=i;s<=a;s++){var l=s>i?0:e&31,u=s<a?31:t&31,c=(2<<u)-(1<<l)&4294967295;if((o[s]&c)!==(n?c:0))return!1}return!0},r.prototype.appendBit=function(e){this.ensureCapacity(this.size+1),e&&(this.bits[Math.floor(this.size/32)]|=1<<(this.size&31)),this.size++},r.prototype.appendBits=function(e,t){if(t<0||t>32)throw new k("Num bits must be between 0 and 32");this.ensureCapacity(this.size+t);for(var n=t;n>0;n--)this.appendBit((e>>n-1&1)===1)},r.prototype.appendBitArray=function(e){var t=e.size;this.ensureCapacity(this.size+t);for(var n=0;n<t;n++)this.appendBit(e.get(n))},r.prototype.xor=function(e){if(this.size!==e.size)throw new k("Sizes don't match");for(var t=this.bits,n=0,i=t.length;n<i;n++)t[n]^=e.bits[n]},r.prototype.toBytes=function(e,t,n,i){for(var a=0;a<i;a++){for(var o=0,s=0;s<8;s++)this.get(e)&&(o|=1<<7-s),e++;t[n+a]=o}},r.prototype.getBitArray=function(){return this.bits},r.prototype.reverse=function(){for(var e=new Int32Array(this.bits.length),t=Math.floor((this.size-1)/32),n=t+1,i=this.bits,a=0;a<n;a++){var o=i[a];o=o>>1&1431655765|(o&1431655765)<<1,o=o>>2&858993459|(o&858993459)<<2,o=o>>4&252645135|(o&252645135)<<4,o=o>>8&16711935|(o&16711935)<<8,o=o>>16&65535|(o&65535)<<16,e[t-a]=o}if(this.size!==n*32){for(var s=n*32-this.size,l=e[0]>>>s,a=1;a<n;a++){var u=e[a];l|=u<<32-s,e[a-1]=l,l=u>>>s}e[n-1]=l}this.bits=e},r.makeArray=function(e){return new Int32Array(Math.floor((e+31)/32))},r.prototype.equals=function(e){if(!(e instanceof r))return!1;var t=e;return this.size===t.size&&fe.equals(this.bits,t.bits)},r.prototype.hashCode=function(){return 31*this.size+fe.hashCode(this.bits)},r.prototype.toString=function(){for(var e="",t=0,n=this.size;t<n;t++)(t&7)===0&&(e+=" "),e+=this.get(t)?"X":".";return e},r.prototype.clone=function(){return new r(this.size,this.bits.slice())},r.prototype.toArray=function(){for(var e=[],t=0,n=this.size;t<n;t++)e.push(this.get(t));return e},r}(),Rn;(function(r){r[r.OTHER=0]="OTHER",r[r.PURE_BARCODE=1]="PURE_BARCODE",r[r.POSSIBLE_FORMATS=2]="POSSIBLE_FORMATS",r[r.TRY_HARDER=3]="TRY_HARDER",r[r.CHARACTER_SET=4]="CHARACTER_SET",r[r.ALLOWED_LENGTHS=5]="ALLOWED_LENGTHS",r[r.ASSUME_CODE_39_CHECK_DIGIT=6]="ASSUME_CODE_39_CHECK_DIGIT",r[r.ASSUME_GS1=7]="ASSUME_GS1",r[r.RETURN_CODABAR_START_END=8]="RETURN_CODABAR_START_END",r[r.NEED_RESULT_POINT_CALLBACK=9]="NEED_RESULT_POINT_CALLBACK",r[r.ALLOWED_EAN_EXTENSIONS=10]="ALLOWED_EAN_EXTENSIONS"})(Rn||(Rn={}));const se=Rn;var cu=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),D=function(r){cu(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e.getFormatInstance=function(){return new e},e.kind="FormatException",e}(Ue),du=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},te;(function(r){r[r.Cp437=0]="Cp437",r[r.ISO8859_1=1]="ISO8859_1",r[r.ISO8859_2=2]="ISO8859_2",r[r.ISO8859_3=3]="ISO8859_3",r[r.ISO8859_4=4]="ISO8859_4",r[r.ISO8859_5=5]="ISO8859_5",r[r.ISO8859_6=6]="ISO8859_6",r[r.ISO8859_7=7]="ISO8859_7",r[r.ISO8859_8=8]="ISO8859_8",r[r.ISO8859_9=9]="ISO8859_9",r[r.ISO8859_10=10]="ISO8859_10",r[r.ISO8859_11=11]="ISO8859_11",r[r.ISO8859_13=12]="ISO8859_13",r[r.ISO8859_14=13]="ISO8859_14",r[r.ISO8859_15=14]="ISO8859_15",r[r.ISO8859_16=15]="ISO8859_16",r[r.SJIS=16]="SJIS",r[r.Cp1250=17]="Cp1250",r[r.Cp1251=18]="Cp1251",r[r.Cp1252=19]="Cp1252",r[r.Cp1256=20]="Cp1256",r[r.UnicodeBigUnmarked=21]="UnicodeBigUnmarked",r[r.UTF8=22]="UTF8",r[r.ASCII=23]="ASCII",r[r.Big5=24]="Big5",r[r.GB18030=25]="GB18030",r[r.EUC_KR=26]="EUC_KR"})(te||(te={}));var he=function(){function r(e,t,n){for(var i,a,o=[],s=3;s<arguments.length;s++)o[s-3]=arguments[s];this.valueIdentifier=e,this.name=n,typeof t=="number"?this.values=Int32Array.from([t]):this.values=t,this.otherEncodingNames=o,r.VALUE_IDENTIFIER_TO_ECI.set(e,this),r.NAME_TO_ECI.set(n,this);for(var l=this.values,u=0,c=l.length;u!==c;u++){var f=l[u];r.VALUES_TO_ECI.set(f,this)}try{for(var h=du(o),p=h.next();!p.done;p=h.next()){var g=p.value;r.NAME_TO_ECI.set(g,this)}}catch(x){i={error:x}}finally{try{p&&!p.done&&(a=h.return)&&a.call(h)}finally{if(i)throw i.error}}}return r.prototype.getValueIdentifier=function(){return this.valueIdentifier},r.prototype.getName=function(){return this.name},r.prototype.getValue=function(){return this.values[0]},r.getCharacterSetECIByValue=function(e){if(e<0||e>=900)throw new D("incorect value");var t=r.VALUES_TO_ECI.get(e);if(t===void 0)throw new D("incorect value");return t},r.getCharacterSetECIByName=function(e){var t=r.NAME_TO_ECI.get(e);if(t===void 0)throw new D("incorect value");return t},r.prototype.equals=function(e){if(!(e instanceof r))return!1;var t=e;return this.getName()===t.getName()},r.VALUE_IDENTIFIER_TO_ECI=new Map,r.VALUES_TO_ECI=new Map,r.NAME_TO_ECI=new Map,r.Cp437=new r(te.Cp437,Int32Array.from([0,2]),"Cp437"),r.ISO8859_1=new r(te.ISO8859_1,Int32Array.from([1,3]),"ISO-8859-1","ISO88591","ISO8859_1"),r.ISO8859_2=new r(te.ISO8859_2,4,"ISO-8859-2","ISO88592","ISO8859_2"),r.ISO8859_3=new r(te.ISO8859_3,5,"ISO-8859-3","ISO88593","ISO8859_3"),r.ISO8859_4=new r(te.ISO8859_4,6,"ISO-8859-4","ISO88594","ISO8859_4"),r.ISO8859_5=new r(te.ISO8859_5,7,"ISO-8859-5","ISO88595","ISO8859_5"),r.ISO8859_6=new r(te.ISO8859_6,8,"ISO-8859-6","ISO88596","ISO8859_6"),r.ISO8859_7=new r(te.ISO8859_7,9,"ISO-8859-7","ISO88597","ISO8859_7"),r.ISO8859_8=new r(te.ISO8859_8,10,"ISO-8859-8","ISO88598","ISO8859_8"),r.ISO8859_9=new r(te.ISO8859_9,11,"ISO-8859-9","ISO88599","ISO8859_9"),r.ISO8859_10=new r(te.ISO8859_10,12,"ISO-8859-10","ISO885910","ISO8859_10"),r.ISO8859_11=new r(te.ISO8859_11,13,"ISO-8859-11","ISO885911","ISO8859_11"),r.ISO8859_13=new r(te.ISO8859_13,15,"ISO-8859-13","ISO885913","ISO8859_13"),r.ISO8859_14=new r(te.ISO8859_14,16,"ISO-8859-14","ISO885914","ISO8859_14"),r.ISO8859_15=new r(te.ISO8859_15,17,"ISO-8859-15","ISO885915","ISO8859_15"),r.ISO8859_16=new r(te.ISO8859_16,18,"ISO-8859-16","ISO885916","ISO8859_16"),r.SJIS=new r(te.SJIS,20,"SJIS","Shift_JIS"),r.Cp1250=new r(te.Cp1250,21,"Cp1250","windows-1250"),r.Cp1251=new r(te.Cp1251,22,"Cp1251","windows-1251"),r.Cp1252=new r(te.Cp1252,23,"Cp1252","windows-1252"),r.Cp1256=new r(te.Cp1256,24,"Cp1256","windows-1256"),r.UnicodeBigUnmarked=new r(te.UnicodeBigUnmarked,25,"UnicodeBigUnmarked","UTF-16BE","UnicodeBig"),r.UTF8=new r(te.UTF8,26,"UTF8","UTF-8"),r.ASCII=new r(te.ASCII,Int32Array.from([27,170]),"ASCII","US-ASCII"),r.Big5=new r(te.Big5,28,"Big5"),r.GB18030=new r(te.GB18030,29,"GB18030","GB2312","EUC_CN","GBK"),r.EUC_KR=new r(te.EUC_KR,30,"EUC_KR","EUC-KR"),r}(),fu=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),zr=function(r){fu(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e.kind="UnsupportedOperationException",e}(Ue),$e=function(){function r(){}return r.decode=function(e,t){var n=this.encodingName(t);return this.customDecoder?this.customDecoder(e,n):typeof TextDecoder>"u"||this.shouldDecodeOnFallback(n)?this.decodeFallback(e,n):new TextDecoder(n).decode(e)},r.shouldDecodeOnFallback=function(e){return!r.isBrowser()&&e==="ISO-8859-1"},r.encode=function(e,t){var n=this.encodingName(t);return this.customEncoder?this.customEncoder(e,n):typeof TextEncoder>"u"?this.encodeFallback(e):new TextEncoder().encode(e)},r.isBrowser=function(){return typeof window<"u"&&{}.toString.call(window)==="[object Window]"},r.encodingName=function(e){return typeof e=="string"?e:e.getName()},r.encodingCharacterSet=function(e){return e instanceof he?e:he.getCharacterSetECIByName(e)},r.decodeFallback=function(e,t){var n=this.encodingCharacterSet(t);if(r.isDecodeFallbackSupported(n)){for(var i="",a=0,o=e.length;a<o;a++){var s=e[a].toString(16);s.length<2&&(s="0"+s),i+="%"+s}return decodeURIComponent(i)}if(n.equals(he.UnicodeBigUnmarked))return String.fromCharCode.apply(null,new Uint16Array(e.buffer));throw new zr("Encoding "+this.encodingName(t)+" not supported by fallback.")},r.isDecodeFallbackSupported=function(e){return e.equals(he.UTF8)||e.equals(he.ISO8859_1)||e.equals(he.ASCII)},r.encodeFallback=function(e){for(var t=btoa(unescape(encodeURIComponent(e))),n=t.split(""),i=[],a=0;a<n.length;a++)i.push(n[a].charCodeAt(0));return new Uint8Array(i)},r}(),X=function(){function r(){}return r.castAsNonUtf8Char=function(e,t){t===void 0&&(t=null);var n=t?t.getName():this.ISO88591;return $e.decode(new Uint8Array([e]),n)},r.guessEncoding=function(e,t){if(t!=null&&t.get(se.CHARACTER_SET)!==void 0)return t.get(se.CHARACTER_SET).toString();for(var n=e.length,i=!0,a=!0,o=!0,s=0,l=0,u=0,c=0,f=0,h=0,p=0,g=0,x=0,m=0,w=0,_=e.length>3&&e[0]===239&&e[1]===187&&e[2]===191,E=0;E<n&&(i||a||o);E++){var S=e[E]&255;o&&(s>0?(S&128)===0?o=!1:s--:(S&128)!==0&&((S&64)===0?o=!1:(s++,(S&32)===0?l++:(s++,(S&16)===0?u++:(s++,(S&8)===0?c++:o=!1))))),i&&(S>127&&S<160?i=!1:S>159&&(S<192||S===215||S===247)&&w++),a&&(f>0?S<64||S===127||S>252?a=!1:f--:S===128||S===160||S>239?a=!1:S>160&&S<224?(h++,g=0,p++,p>x&&(x=p)):S>127?(f++,p=0,g++,g>m&&(m=g)):(p=0,g=0))}return o&&s>0&&(o=!1),a&&f>0&&(a=!1),o&&(_||l+u+c>0)?r.UTF8:a&&(r.ASSUME_SHIFT_JIS||x>=3||m>=3)?r.SHIFT_JIS:i&&a?x===2&&h===2||w*10>=n?r.SHIFT_JIS:r.ISO88591:i?r.ISO88591:a?r.SHIFT_JIS:o?r.UTF8:r.PLATFORM_DEFAULT_ENCODING},r.format=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var i=-1;function a(s,l,u,c,f,h){if(s==="%%")return"%";if(t[++i]!==void 0){s=c?parseInt(c.substr(1)):void 0;var p=f?parseInt(f.substr(1)):void 0,g;switch(h){case"s":g=t[i];break;case"c":g=t[i][0];break;case"f":g=parseFloat(t[i]).toFixed(s);break;case"p":g=parseFloat(t[i]).toPrecision(s);break;case"e":g=parseFloat(t[i]).toExponential(s);break;case"x":g=parseInt(t[i]).toString(p||16);break;case"d":g=parseFloat(parseInt(t[i],p||10).toPrecision(s)).toFixed(0);break}g=typeof g=="object"?JSON.stringify(g):(+g).toString(p);for(var x=parseInt(u),m=u&&u[0]+""=="0"?"0":" ";g.length<x;)g=l!==void 0?g+m:m+g;return g}}var o=/%(-)?(0?[0-9]+)?([.][0-9]+)?([#][0-9]+)?([scfpexd%])/g;return e.replace(o,a)},r.getBytes=function(e,t){return $e.encode(e,t)},r.getCharCode=function(e,t){return t===void 0&&(t=0),e.charCodeAt(t)},r.getCharAt=function(e){return String.fromCharCode(e)},r.SHIFT_JIS=he.SJIS.getName(),r.GB2312="GB2312",r.ISO88591=he.ISO8859_1.getName(),r.EUC_JP="EUC_JP",r.UTF8=he.UTF8.getName(),r.PLATFORM_DEFAULT_ENCODING=r.UTF8,r.ASSUME_SHIFT_JIS=!1,r}(),q=function(){function r(e){e===void 0&&(e=""),this.value=e}return r.prototype.enableDecoding=function(e){return this.encoding=e,this},r.prototype.append=function(e){return typeof e=="string"?this.value+=e.toString():this.encoding?this.value+=X.castAsNonUtf8Char(e,this.encoding):this.value+=String.fromCharCode(e),this},r.prototype.appendChars=function(e,t,n){for(var i=t;t<t+n;i++)this.append(e[i]);return this},r.prototype.length=function(){return this.value.length},r.prototype.charAt=function(e){return this.value.charAt(e)},r.prototype.deleteCharAt=function(e){this.value=this.value.substr(0,e)+this.value.substring(e+1)},r.prototype.setCharAt=function(e,t){this.value=this.value.substr(0,e)+t+this.value.substr(e+1)},r.prototype.substring=function(e,t){return this.value.substring(e,t)},r.prototype.setLengthToZero=function(){this.value=""},r.prototype.toString=function(){return this.value},r.prototype.insert=function(e,t){this.value=this.value.substring(0,e)+t+this.value.substring(e)},r}(),tt=function(){function r(e,t,n,i){if(this.width=e,this.height=t,this.rowSize=n,this.bits=i,t==null&&(t=e),this.height=t,e<1||t<1)throw new k("Both dimensions must be greater than 0");n==null&&(n=Math.floor((e+31)/32)),this.rowSize=n,i==null&&(this.bits=new Int32Array(this.rowSize*this.height))}return r.parseFromBooleanArray=function(e){for(var t=e.length,n=e[0].length,i=new r(n,t),a=0;a<t;a++)for(var o=e[a],s=0;s<n;s++)o[s]&&i.set(s,a);return i},r.parseFromString=function(e,t,n){if(e===null)throw new k("stringRepresentation cannot be null");for(var i=new Array(e.length),a=0,o=0,s=-1,l=0,u=0;u<e.length;)if(e.charAt(u)===`
|
|
257
257
|
`||e.charAt(u)==="\r"){if(a>o){if(s===-1)s=a-o;else if(a-o!==s)throw new k("row lengths do not match");o=a,l++}u++}else if(e.substring(u,u+t.length)===t)u+=t.length,i[a]=!0,a++;else if(e.substring(u,u+n.length)===n)u+=n.length,i[a]=!1,a++;else throw new k("illegal character encountered: "+e.substring(u));if(a>o){if(s===-1)s=a-o;else if(a-o!==s)throw new k("row lengths do not match");l++}for(var c=new r(s,l),f=0;f<a;f++)i[f]&&c.set(Math.floor(f%s),Math.floor(f/s));return c},r.prototype.get=function(e,t){var n=t*this.rowSize+Math.floor(e/32);return(this.bits[n]>>>(e&31)&1)!==0},r.prototype.set=function(e,t){var n=t*this.rowSize+Math.floor(e/32);this.bits[n]|=1<<(e&31)&4294967295},r.prototype.unset=function(e,t){var n=t*this.rowSize+Math.floor(e/32);this.bits[n]&=~(1<<(e&31)&4294967295)},r.prototype.flip=function(e,t){var n=t*this.rowSize+Math.floor(e/32);this.bits[n]^=1<<(e&31)&4294967295},r.prototype.xor=function(e){if(this.width!==e.getWidth()||this.height!==e.getHeight()||this.rowSize!==e.getRowSize())throw new k("input matrix dimensions do not match");for(var t=new _e(Math.floor(this.width/32)+1),n=this.rowSize,i=this.bits,a=0,o=this.height;a<o;a++)for(var s=a*n,l=e.getRow(a,t).getBitArray(),u=0;u<n;u++)i[s+u]^=l[u]},r.prototype.clear=function(){for(var e=this.bits,t=e.length,n=0;n<t;n++)e[n]=0},r.prototype.setRegion=function(e,t,n,i){if(t<0||e<0)throw new k("Left and top must be nonnegative");if(i<1||n<1)throw new k("Height and width must be at least 1");var a=e+n,o=t+i;if(o>this.height||a>this.width)throw new k("The region must fit inside the matrix");for(var s=this.rowSize,l=this.bits,u=t;u<o;u++)for(var c=u*s,f=e;f<a;f++)l[c+Math.floor(f/32)]|=1<<(f&31)&4294967295},r.prototype.getRow=function(e,t){t==null||t.getSize()<this.width?t=new _e(this.width):t.clear();for(var n=this.rowSize,i=this.bits,a=e*n,o=0;o<n;o++)t.setBulk(o*32,i[a+o]);return t},r.prototype.setRow=function(e,t){ie.arraycopy(t.getBitArray(),0,this.bits,e*this.rowSize,this.rowSize)},r.prototype.rotate180=function(){for(var e=this.getWidth(),t=this.getHeight(),n=new _e(e),i=new _e(e),a=0,o=Math.floor((t+1)/2);a<o;a++)n=this.getRow(a,n),i=this.getRow(t-1-a,i),n.reverse(),i.reverse(),this.setRow(a,i),this.setRow(t-1-a,n)},r.prototype.getEnclosingRectangle=function(){for(var e=this.width,t=this.height,n=this.rowSize,i=this.bits,a=e,o=t,s=-1,l=-1,u=0;u<t;u++)for(var c=0;c<n;c++){var f=i[u*n+c];if(f!==0){if(u<o&&(o=u),u>l&&(l=u),c*32<a){for(var h=0;(f<<31-h&4294967295)===0;)h++;c*32+h<a&&(a=c*32+h)}if(c*32+31>s){for(var h=31;!(f>>>h);)h--;c*32+h>s&&(s=c*32+h)}}}return s<a||l<o?null:Int32Array.from([a,o,s-a+1,l-o+1])},r.prototype.getTopLeftOnBit=function(){for(var e=this.rowSize,t=this.bits,n=0;n<t.length&&t[n]===0;)n++;if(n===t.length)return null;for(var i=n/e,a=n%e*32,o=t[n],s=0;(o<<31-s&4294967295)===0;)s++;return a+=s,Int32Array.from([a,i])},r.prototype.getBottomRightOnBit=function(){for(var e=this.rowSize,t=this.bits,n=t.length-1;n>=0&&t[n]===0;)n--;if(n<0)return null;for(var i=Math.floor(n/e),a=Math.floor(n%e)*32,o=t[n],s=31;!(o>>>s);)s--;return a+=s,Int32Array.from([a,i])},r.prototype.getWidth=function(){return this.width},r.prototype.getHeight=function(){return this.height},r.prototype.getRowSize=function(){return this.rowSize},r.prototype.equals=function(e){if(!(e instanceof r))return!1;var t=e;return this.width===t.width&&this.height===t.height&&this.rowSize===t.rowSize&&fe.equals(this.bits,t.bits)},r.prototype.hashCode=function(){var e=this.width;return e=31*e+this.width,e=31*e+this.height,e=31*e+this.rowSize,e=31*e+fe.hashCode(this.bits),e},r.prototype.toString=function(e,t,n){return e===void 0&&(e="X "),t===void 0&&(t=" "),n===void 0&&(n=`
|
|
258
258
|
`),this.buildToString(e,t,n)},r.prototype.buildToString=function(e,t,n){for(var i=new q,a=0,o=this.height;a<o;a++){for(var s=0,l=this.width;s<l;s++)i.append(this.get(s,a)?e:t);i.append(n)}return i.toString()},r.prototype.clone=function(){return new r(this.width,this.height,this.rowSize,this.bits.slice())},r}(),hu=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),b=function(r){hu(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e.getNotFoundInstance=function(){return new e},e.kind="NotFoundException",e}(Ue),pu=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),vu=function(r){pu(e,r);function e(t){var n=r.call(this,t)||this;return n.luminances=e.EMPTY,n.buckets=new Int32Array(e.LUMINANCE_BUCKETS),n}return e.prototype.getBlackRow=function(t,n){var i=this.getLuminanceSource(),a=i.getWidth();n==null||n.getSize()<a?n=new _e(a):n.clear(),this.initArrays(a);for(var o=i.getRow(t,this.luminances),s=this.buckets,l=0;l<a;l++)s[(o[l]&255)>>e.LUMINANCE_SHIFT]++;var u=e.estimateBlackPoint(s);if(a<3)for(var l=0;l<a;l++)(o[l]&255)<u&&n.set(l);else for(var c=o[0]&255,f=o[1]&255,l=1;l<a-1;l++){var h=o[l+1]&255;(f*4-c-h)/2<u&&n.set(l),c=f,f=h}return n},e.prototype.getBlackMatrix=function(){var t=this.getLuminanceSource(),n=t.getWidth(),i=t.getHeight(),a=new tt(n,i);this.initArrays(n);for(var o=this.buckets,s=1;s<5;s++)for(var l=Math.floor(i*s/5),u=t.getRow(l,this.luminances),c=Math.floor(n*4/5),f=Math.floor(n/5);f<c;f++){var h=u[f]&255;o[h>>e.LUMINANCE_SHIFT]++}for(var p=e.estimateBlackPoint(o),g=t.getMatrix(),s=0;s<i;s++)for(var x=s*n,f=0;f<n;f++){var h=g[x+f]&255;h<p&&a.set(f,s)}return a},e.prototype.createBinarizer=function(t){return new e(t)},e.prototype.initArrays=function(t){this.luminances.length<t&&(this.luminances=new Uint8ClampedArray(t));for(var n=this.buckets,i=0;i<e.LUMINANCE_BUCKETS;i++)n[i]=0},e.estimateBlackPoint=function(t){for(var n=t.length,i=0,a=0,o=0,s=0;s<n;s++)t[s]>o&&(a=s,o=t[s]),t[s]>i&&(i=t[s]);for(var l=0,u=0,s=0;s<n;s++){var c=s-a,f=t[s]*c*c;f>u&&(l=s,u=f)}if(a>l){var h=a;a=l,l=h}if(l-a<=n/16)throw new b;for(var p=l-1,g=-1,s=l-1;s>a;s--){var x=s-a,f=x*x*(l-s)*(i-t[s]);f>g&&(p=s,g=f)}return p<<e.LUMINANCE_SHIFT},e.LUMINANCE_BITS=5,e.LUMINANCE_SHIFT=8-e.LUMINANCE_BITS,e.LUMINANCE_BUCKETS=1<<e.LUMINANCE_BITS,e.EMPTY=Uint8ClampedArray.from([0]),e}(ou),gu=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),xu=function(r){gu(e,r);function e(t){var n=r.call(this,t)||this;return n.matrix=null,n}return e.prototype.getBlackMatrix=function(){if(this.matrix!==null)return this.matrix;var t=this.getLuminanceSource(),n=t.getWidth(),i=t.getHeight();if(n>=e.MINIMUM_DIMENSION&&i>=e.MINIMUM_DIMENSION){var a=t.getMatrix(),o=n>>e.BLOCK_SIZE_POWER;(n&e.BLOCK_SIZE_MASK)!==0&&o++;var s=i>>e.BLOCK_SIZE_POWER;(i&e.BLOCK_SIZE_MASK)!==0&&s++;var l=e.calculateBlackPoints(a,o,s,n,i),u=new tt(n,i);e.calculateThresholdForBlock(a,o,s,n,i,l,u),this.matrix=u}else this.matrix=r.prototype.getBlackMatrix.call(this);return this.matrix},e.prototype.createBinarizer=function(t){return new e(t)},e.calculateThresholdForBlock=function(t,n,i,a,o,s,l){for(var u=o-e.BLOCK_SIZE,c=a-e.BLOCK_SIZE,f=0;f<i;f++){var h=f<<e.BLOCK_SIZE_POWER;h>u&&(h=u);for(var p=e.cap(f,2,i-3),g=0;g<n;g++){var x=g<<e.BLOCK_SIZE_POWER;x>c&&(x=c);for(var m=e.cap(g,2,n-3),w=0,_=-2;_<=2;_++){var E=s[p+_];w+=E[m-2]+E[m-1]+E[m]+E[m+1]+E[m+2]}var S=w/25;e.thresholdBlock(t,x,h,S,a,l)}}},e.cap=function(t,n,i){return t<n?n:t>i?i:t},e.thresholdBlock=function(t,n,i,a,o,s){for(var l=0,u=i*o+n;l<e.BLOCK_SIZE;l++,u+=o)for(var c=0;c<e.BLOCK_SIZE;c++)(t[u+c]&255)<=a&&s.set(n+c,i+l)},e.calculateBlackPoints=function(t,n,i,a,o){for(var s=o-e.BLOCK_SIZE,l=a-e.BLOCK_SIZE,u=new Array(i),c=0;c<i;c++){u[c]=new Int32Array(n);var f=c<<e.BLOCK_SIZE_POWER;f>s&&(f=s);for(var h=0;h<n;h++){var p=h<<e.BLOCK_SIZE_POWER;p>l&&(p=l);for(var g=0,x=255,m=0,w=0,_=f*a+p;w<e.BLOCK_SIZE;w++,_+=a){for(var E=0;E<e.BLOCK_SIZE;E++){var S=t[_+E]&255;g+=S,S<x&&(x=S),S>m&&(m=S)}if(m-x>e.MIN_DYNAMIC_RANGE)for(w++,_+=a;w<e.BLOCK_SIZE;w++,_+=a)for(var E=0;E<e.BLOCK_SIZE;E++)g+=t[_+E]&255}var O=g>>e.BLOCK_SIZE_POWER*2;if(m-x<=e.MIN_DYNAMIC_RANGE&&(O=x/2,c>0&&h>0)){var N=(u[c-1][h]+2*u[c][h-1]+u[c-1][h-1])/4;x<N&&(O=N)}u[c][h]=O}}return u},e.BLOCK_SIZE_POWER=3,e.BLOCK_SIZE=1<<e.BLOCK_SIZE_POWER,e.BLOCK_SIZE_MASK=e.BLOCK_SIZE-1,e.MINIMUM_DIMENSION=e.BLOCK_SIZE*5,e.MIN_DYNAMIC_RANGE=24,e}(vu),kr=function(){function r(e,t){this.width=e,this.height=t}return r.prototype.getWidth=function(){return this.width},r.prototype.getHeight=function(){return this.height},r.prototype.isCropSupported=function(){return!1},r.prototype.crop=function(e,t,n,i){throw new zr("This luminance source does not support cropping.")},r.prototype.isRotateSupported=function(){return!1},r.prototype.rotateCounterClockwise=function(){throw new zr("This luminance source does not support rotation by 90 degrees.")},r.prototype.rotateCounterClockwise45=function(){throw new zr("This luminance source does not support rotation by 45 degrees.")},r.prototype.toString=function(){for(var e=new Uint8ClampedArray(this.width),t=new q,n=0;n<this.height;n++){for(var i=this.getRow(n,e),a=0;a<this.width;a++){var o=i[a]&255,s=void 0;o<64?s="#":o<128?s="+":o<192?s=".":s=" ",t.append(s)}t.append(`
|
|
259
259
|
`)}return t.toString()},r}(),yu=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),Gn=function(r){yu(e,r);function e(t){var n=r.call(this,t.getWidth(),t.getHeight())||this;return n.delegate=t,n}return e.prototype.getRow=function(t,n){for(var i=this.delegate.getRow(t,n),a=this.getWidth(),o=0;o<a;o++)i[o]=255-(i[o]&255);return i},e.prototype.getMatrix=function(){for(var t=this.delegate.getMatrix(),n=this.getWidth()*this.getHeight(),i=new Uint8ClampedArray(n),a=0;a<n;a++)i[a]=255-(t[a]&255);return i},e.prototype.isCropSupported=function(){return this.delegate.isCropSupported()},e.prototype.crop=function(t,n,i,a){return new e(this.delegate.crop(t,n,i,a))},e.prototype.isRotateSupported=function(){return this.delegate.isRotateSupported()},e.prototype.invert=function(){return this.delegate},e.prototype.rotateCounterClockwise=function(){return new e(this.delegate.rotateCounterClockwise())},e.prototype.rotateCounterClockwise45=function(){return new e(this.delegate.rotateCounterClockwise45())},e}(kr),Cu=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),mu=function(r){Cu(e,r);function e(t){var n=r.call(this,t.width,t.height)||this;return n.canvas=t,n.tempCanvasElement=null,n.buffer=e.makeBufferFromCanvasImageData(t),n}return e.makeBufferFromCanvasImageData=function(t){var n=t.getContext("2d").getImageData(0,0,t.width,t.height);return e.toGrayscaleBuffer(n.data,t.width,t.height)},e.toGrayscaleBuffer=function(t,n,i){var a=new Uint8ClampedArray(n*i);if(e.FRAME_INDEX=!e.FRAME_INDEX,e.FRAME_INDEX)for(var o=0,s=0,l=t.length;o<l;o+=4,s++){var u=void 0,c=t[o+3];if(c===0)u=255;else{var f=t[o],h=t[o+1],p=t[o+2];u=306*f+601*h+117*p+512>>10}a[s]=u}else for(var o=0,s=0,g=t.length;o<g;o+=4,s++){var u=void 0,c=t[o+3];if(c===0)u=255;else{var f=t[o],h=t[o+1],p=t[o+2];u=306*f+601*h+117*p+512>>10}a[s]=255-u}return a},e.prototype.getRow=function(t,n){if(t<0||t>=this.getHeight())throw new k("Requested row is outside the image: "+t);var i=this.getWidth(),a=t*i;return n===null?n=this.buffer.slice(a,a+i):(n.length<i&&(n=new Uint8ClampedArray(i)),n.set(this.buffer.slice(a,a+i))),n},e.prototype.getMatrix=function(){return this.buffer},e.prototype.isCropSupported=function(){return!0},e.prototype.crop=function(t,n,i,a){return r.prototype.crop.call(this,t,n,i,a),this},e.prototype.isRotateSupported=function(){return!0},e.prototype.rotateCounterClockwise=function(){return this.rotate(-90),this},e.prototype.rotateCounterClockwise45=function(){return this.rotate(-45),this},e.prototype.getTempCanvasElement=function(){if(this.tempCanvasElement===null){var t=this.canvas.ownerDocument.createElement("canvas");t.width=this.canvas.width,t.height=this.canvas.height,this.tempCanvasElement=t}return this.tempCanvasElement},e.prototype.rotate=function(t){var n=this.getTempCanvasElement(),i=n.getContext("2d"),a=t*e.DEGREE_TO_RADIANS,o=this.canvas.width,s=this.canvas.height,l=Math.ceil(Math.abs(Math.cos(a))*o+Math.abs(Math.sin(a))*s),u=Math.ceil(Math.abs(Math.sin(a))*o+Math.abs(Math.cos(a))*s);return n.width=l,n.height=u,i.translate(l/2,u/2),i.rotate(a),i.drawImage(this.canvas,o/-2,s/-2),this.buffer=e.makeBufferFromCanvasImageData(n),this},e.prototype.invert=function(){return new Gn(this)},e.DEGREE_TO_RADIANS=Math.PI/180,e.FRAME_INDEX=!0,e}(kr),wu=function(){function r(e,t,n){this.deviceId=e,this.label=t,this.kind="videoinput",this.groupId=n||void 0}return r.prototype.toJSON=function(){return{kind:this.kind,groupId:this.groupId,deviceId:this.deviceId,label:this.label}},r}(),Be=function(r,e,t,n){function i(a){return a instanceof t?a:new t(function(o){o(a)})}return new(t||(t=Promise))(function(a,o){function s(c){try{u(n.next(c))}catch(f){o(f)}}function l(c){try{u(n.throw(c))}catch(f){o(f)}}function u(c){c.done?a(c.value):i(c.value).then(s,l)}u((n=n.apply(r,e||[])).next())})},Le=function(r,e){var t={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},n,i,a,o;return o={next:s(0),throw:s(1),return:s(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function s(u){return function(c){return l([u,c])}}function l(u){if(n)throw new TypeError("Generator is already executing.");for(;t;)try{if(n=1,i&&(a=u[0]&2?i.return:u[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,u[1])).done)return a;switch(i=0,a&&(u=[u[0]&2,a.value]),u[0]){case 0:case 1:a=u;break;case 4:return t.label++,{value:u[1],done:!1};case 5:t.label++,i=u[1],u=[0];continue;case 7:u=t.ops.pop(),t.trys.pop();continue;default:if(a=t.trys,!(a=a.length>0&&a[a.length-1])&&(u[0]===6||u[0]===2)){t=0;continue}if(u[0]===3&&(!a||u[1]>a[0]&&u[1]<a[3])){t.label=u[1];break}if(u[0]===6&&t.label<a[1]){t.label=a[1],a=u;break}if(a&&t.label<a[2]){t.label=a[2],t.ops.push(u);break}a[2]&&t.ops.pop(),t.trys.pop();continue}u=e.call(r,t)}catch(c){u=[6,c],i=0}finally{n=a=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}},_u=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Ut=function(){function r(e,t,n){t===void 0&&(t=500),this.reader=e,this.timeBetweenScansMillis=t,this._hints=n,this._stopContinuousDecode=!1,this._stopAsyncDecode=!1,this._timeBetweenDecodingAttempts=0}return Object.defineProperty(r.prototype,"hasNavigator",{get:function(){return typeof navigator<"u"},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isMediaDevicesSuported",{get:function(){return this.hasNavigator&&!!navigator.mediaDevices},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"canEnumerateDevices",{get:function(){return!!(this.isMediaDevicesSuported&&navigator.mediaDevices.enumerateDevices)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"timeBetweenDecodingAttempts",{get:function(){return this._timeBetweenDecodingAttempts},set:function(e){this._timeBetweenDecodingAttempts=e<0?0:e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"hints",{get:function(){return this._hints},set:function(e){this._hints=e||null},enumerable:!1,configurable:!0}),r.prototype.listVideoInputDevices=function(){return Be(this,void 0,void 0,function(){var e,t,n,i,a,o,s,l,u,c,f,h;return Le(this,function(p){switch(p.label){case 0:if(!this.hasNavigator)throw new Error("Can't enumerate devices, navigator is not present.");if(!this.canEnumerateDevices)throw new Error("Can't enumerate devices, method not supported.");return[4,navigator.mediaDevices.enumerateDevices()];case 1:e=p.sent(),t=[];try{for(n=_u(e),i=n.next();!i.done;i=n.next())a=i.value,o=a.kind==="video"?"videoinput":a.kind,o==="videoinput"&&(s=a.deviceId||a.id,l=a.label||"Video device "+(t.length+1),u=a.groupId,c={deviceId:s,label:l,kind:o,groupId:u},t.push(c))}catch(g){f={error:g}}finally{try{i&&!i.done&&(h=n.return)&&h.call(n)}finally{if(f)throw f.error}}return[2,t]}})})},r.prototype.getVideoInputDevices=function(){return Be(this,void 0,void 0,function(){var e;return Le(this,function(t){switch(t.label){case 0:return[4,this.listVideoInputDevices()];case 1:return e=t.sent(),[2,e.map(function(n){return new wu(n.deviceId,n.label)})]}})})},r.prototype.findDeviceById=function(e){return Be(this,void 0,void 0,function(){var t;return Le(this,function(n){switch(n.label){case 0:return[4,this.listVideoInputDevices()];case 1:return t=n.sent(),t?[2,t.find(function(i){return i.deviceId===e})]:[2,null]}})})},r.prototype.decodeFromInputVideoDevice=function(e,t){return Be(this,void 0,void 0,function(){return Le(this,function(n){switch(n.label){case 0:return[4,this.decodeOnceFromVideoDevice(e,t)];case 1:return[2,n.sent()]}})})},r.prototype.decodeOnceFromVideoDevice=function(e,t){return Be(this,void 0,void 0,function(){var n,i;return Le(this,function(a){switch(a.label){case 0:return this.reset(),e?n={deviceId:{exact:e}}:n={facingMode:"environment"},i={video:n},[4,this.decodeOnceFromConstraints(i,t)];case 1:return[2,a.sent()]}})})},r.prototype.decodeOnceFromConstraints=function(e,t){return Be(this,void 0,void 0,function(){var n;return Le(this,function(i){switch(i.label){case 0:return[4,navigator.mediaDevices.getUserMedia(e)];case 1:return n=i.sent(),[4,this.decodeOnceFromStream(n,t)];case 2:return[2,i.sent()]}})})},r.prototype.decodeOnceFromStream=function(e,t){return Be(this,void 0,void 0,function(){var n,i;return Le(this,function(a){switch(a.label){case 0:return this.reset(),[4,this.attachStreamToVideo(e,t)];case 1:return n=a.sent(),[4,this.decodeOnce(n)];case 2:return i=a.sent(),[2,i]}})})},r.prototype.decodeFromInputVideoDeviceContinuously=function(e,t,n){return Be(this,void 0,void 0,function(){return Le(this,function(i){switch(i.label){case 0:return[4,this.decodeFromVideoDevice(e,t,n)];case 1:return[2,i.sent()]}})})},r.prototype.decodeFromVideoDevice=function(e,t,n){return Be(this,void 0,void 0,function(){var i,a;return Le(this,function(o){switch(o.label){case 0:return e?i={deviceId:{exact:e}}:i={facingMode:"environment"},a={video:i},[4,this.decodeFromConstraints(a,t,n)];case 1:return[2,o.sent()]}})})},r.prototype.decodeFromConstraints=function(e,t,n){return Be(this,void 0,void 0,function(){var i;return Le(this,function(a){switch(a.label){case 0:return[4,navigator.mediaDevices.getUserMedia(e)];case 1:return i=a.sent(),[4,this.decodeFromStream(i,t,n)];case 2:return[2,a.sent()]}})})},r.prototype.decodeFromStream=function(e,t,n){return Be(this,void 0,void 0,function(){var i;return Le(this,function(a){switch(a.label){case 0:return this.reset(),[4,this.attachStreamToVideo(e,t)];case 1:return i=a.sent(),[4,this.decodeContinuously(i,n)];case 2:return[2,a.sent()]}})})},r.prototype.stopAsyncDecode=function(){this._stopAsyncDecode=!0},r.prototype.stopContinuousDecode=function(){this._stopContinuousDecode=!0},r.prototype.attachStreamToVideo=function(e,t){return Be(this,void 0,void 0,function(){var n;return Le(this,function(i){switch(i.label){case 0:return n=this.prepareVideoElement(t),this.addVideoSource(n,e),this.videoElement=n,this.stream=e,[4,this.playVideoOnLoadAsync(n)];case 1:return i.sent(),[2,n]}})})},r.prototype.playVideoOnLoadAsync=function(e){var t=this;return new Promise(function(n,i){return t.playVideoOnLoad(e,function(){return n()})})},r.prototype.playVideoOnLoad=function(e,t){var n=this;this.videoEndedListener=function(){return n.stopStreams()},this.videoCanPlayListener=function(){return n.tryPlayVideo(e)},e.addEventListener("ended",this.videoEndedListener),e.addEventListener("canplay",this.videoCanPlayListener),e.addEventListener("playing",t),this.tryPlayVideo(e)},r.prototype.isVideoPlaying=function(e){return e.currentTime>0&&!e.paused&&!e.ended&&e.readyState>2},r.prototype.tryPlayVideo=function(e){return Be(this,void 0,void 0,function(){return Le(this,function(t){switch(t.label){case 0:if(this.isVideoPlaying(e))return console.warn("Trying to play video that is already playing."),[2];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,e.play()];case 2:return t.sent(),[3,4];case 3:return t.sent(),console.warn("It was not possible to play the video."),[3,4];case 4:return[2]}})})},r.prototype.getMediaElement=function(e,t){var n=document.getElementById(e);if(!n)throw new Ze("element with id '"+e+"' not found");if(n.nodeName.toLowerCase()!==t.toLowerCase())throw new Ze("element with id '"+e+"' must be an "+t+" element");return n},r.prototype.decodeFromImage=function(e,t){if(!e&&!t)throw new Ze("either imageElement with a src set or an url must be provided");return t&&!e?this.decodeFromImageUrl(t):this.decodeFromImageElement(e)},r.prototype.decodeFromVideo=function(e,t){if(!e&&!t)throw new Ze("Either an element with a src set or an URL must be provided");return t&&!e?this.decodeFromVideoUrl(t):this.decodeFromVideoElement(e)},r.prototype.decodeFromVideoContinuously=function(e,t,n){if(e===void 0&&t===void 0)throw new Ze("Either an element with a src set or an URL must be provided");return t&&!e?this.decodeFromVideoUrlContinuously(t,n):this.decodeFromVideoElementContinuously(e,n)},r.prototype.decodeFromImageElement=function(e){if(!e)throw new Ze("An image element must be provided.");this.reset();var t=this.prepareImageElement(e);this.imageElement=t;var n;return this.isImageLoaded(t)?n=this.decodeOnce(t,!1,!0):n=this._decodeOnLoadImage(t),n},r.prototype.decodeFromVideoElement=function(e){var t=this._decodeFromVideoElementSetup(e);return this._decodeOnLoadVideo(t)},r.prototype.decodeFromVideoElementContinuously=function(e,t){var n=this._decodeFromVideoElementSetup(e);return this._decodeOnLoadVideoContinuously(n,t)},r.prototype._decodeFromVideoElementSetup=function(e){if(!e)throw new Ze("A video element must be provided.");this.reset();var t=this.prepareVideoElement(e);return this.videoElement=t,t},r.prototype.decodeFromImageUrl=function(e){if(!e)throw new Ze("An URL must be provided.");this.reset();var t=this.prepareImageElement();this.imageElement=t;var n=this._decodeOnLoadImage(t);return t.src=e,n},r.prototype.decodeFromVideoUrl=function(e){if(!e)throw new Ze("An URL must be provided.");this.reset();var t=this.prepareVideoElement(),n=this.decodeFromVideoElement(t);return t.src=e,n},r.prototype.decodeFromVideoUrlContinuously=function(e,t){if(!e)throw new Ze("An URL must be provided.");this.reset();var n=this.prepareVideoElement(),i=this.decodeFromVideoElementContinuously(n,t);return n.src=e,i},r.prototype._decodeOnLoadImage=function(e){var t=this;return new Promise(function(n,i){t.imageLoadedListener=function(){return t.decodeOnce(e,!1,!0).then(n,i)},e.addEventListener("load",t.imageLoadedListener)})},r.prototype._decodeOnLoadVideo=function(e){return Be(this,void 0,void 0,function(){return Le(this,function(t){switch(t.label){case 0:return[4,this.playVideoOnLoadAsync(e)];case 1:return t.sent(),[4,this.decodeOnce(e)];case 2:return[2,t.sent()]}})})},r.prototype._decodeOnLoadVideoContinuously=function(e,t){return Be(this,void 0,void 0,function(){return Le(this,function(n){switch(n.label){case 0:return[4,this.playVideoOnLoadAsync(e)];case 1:return n.sent(),this.decodeContinuously(e,t),[2]}})})},r.prototype.isImageLoaded=function(e){return!(!e.complete||e.naturalWidth===0)},r.prototype.prepareImageElement=function(e){var t;return typeof e>"u"&&(t=document.createElement("img"),t.width=200,t.height=200),typeof e=="string"&&(t=this.getMediaElement(e,"img")),e instanceof HTMLImageElement&&(t=e),t},r.prototype.prepareVideoElement=function(e){var t;return!e&&typeof document<"u"&&(t=document.createElement("video"),t.width=200,t.height=200),typeof e=="string"&&(t=this.getMediaElement(e,"video")),e instanceof HTMLVideoElement&&(t=e),t.setAttribute("autoplay","true"),t.setAttribute("muted","true"),t.setAttribute("playsinline","true"),t},r.prototype.decodeOnce=function(e,t,n){var i=this;t===void 0&&(t=!0),n===void 0&&(n=!0),this._stopAsyncDecode=!1;var a=function(o,s){if(i._stopAsyncDecode){s(new b("Video stream has ended before any code could be detected.")),i._stopAsyncDecode=void 0;return}try{var l=i.decode(e);o(l)}catch(h){var u=t&&h instanceof b,c=h instanceof we||h instanceof D,f=c&&n;if(u||f)return setTimeout(a,i._timeBetweenDecodingAttempts,o,s);s(h)}};return new Promise(function(o,s){return a(o,s)})},r.prototype.decodeContinuously=function(e,t){var n=this;this._stopContinuousDecode=!1;var i=function(){if(n._stopContinuousDecode){n._stopContinuousDecode=void 0;return}try{var a=n.decode(e);t(a,null),setTimeout(i,n.timeBetweenScansMillis)}catch(l){t(null,l);var o=l instanceof we||l instanceof D,s=l instanceof b;(o||s)&&setTimeout(i,n._timeBetweenDecodingAttempts)}};i()},r.prototype.decode=function(e){var t=this.createBinaryBitmap(e);return this.decodeBitmap(t)},r.prototype.createBinaryBitmap=function(e){this.getCaptureCanvasContext(e),e instanceof HTMLVideoElement?this.drawFrameOnCanvas(e):this.drawImageOnCanvas(e);var t=this.getCaptureCanvas(e),n=new mu(t),i=new xu(n);return new iu(i)},r.prototype.getCaptureCanvasContext=function(e){if(!this.captureCanvasContext){var t=this.getCaptureCanvas(e),n=void 0;try{n=t.getContext("2d",{willReadFrequently:!0})}catch{n=t.getContext("2d")}this.captureCanvasContext=n}return this.captureCanvasContext},r.prototype.getCaptureCanvas=function(e){if(!this.captureCanvas){var t=this.createCaptureCanvas(e);this.captureCanvas=t}return this.captureCanvas},r.prototype.drawFrameOnCanvas=function(e,t,n){t===void 0&&(t={sx:0,sy:0,sWidth:e.videoWidth,sHeight:e.videoHeight,dx:0,dy:0,dWidth:e.videoWidth,dHeight:e.videoHeight}),n===void 0&&(n=this.captureCanvasContext),n.drawImage(e,t.sx,t.sy,t.sWidth,t.sHeight,t.dx,t.dy,t.dWidth,t.dHeight)},r.prototype.drawImageOnCanvas=function(e,t,n){t===void 0&&(t={sx:0,sy:0,sWidth:e.naturalWidth,sHeight:e.naturalHeight,dx:0,dy:0,dWidth:e.naturalWidth,dHeight:e.naturalHeight}),n===void 0&&(n=this.captureCanvasContext),n.drawImage(e,t.sx,t.sy,t.sWidth,t.sHeight,t.dx,t.dy,t.dWidth,t.dHeight)},r.prototype.decodeBitmap=function(e){return this.reader.decode(e,this._hints)},r.prototype.createCaptureCanvas=function(e){if(typeof document>"u")return this._destroyCaptureCanvas(),null;var t=document.createElement("canvas"),n,i;return typeof e<"u"&&(e instanceof HTMLVideoElement?(n=e.videoWidth,i=e.videoHeight):e instanceof HTMLImageElement&&(n=e.naturalWidth||e.width,i=e.naturalHeight||e.height)),t.style.width=n+"px",t.style.height=i+"px",t.width=n,t.height=i,t},r.prototype.stopStreams=function(){this.stream&&(this.stream.getVideoTracks().forEach(function(e){return e.stop()}),this.stream=void 0),this._stopAsyncDecode===!1&&this.stopAsyncDecode(),this._stopContinuousDecode===!1&&this.stopContinuousDecode()},r.prototype.reset=function(){this.stopStreams(),this._destroyVideoElement(),this._destroyImageElement(),this._destroyCaptureCanvas()},r.prototype._destroyVideoElement=function(){this.videoElement&&(typeof this.videoEndedListener<"u"&&this.videoElement.removeEventListener("ended",this.videoEndedListener),typeof this.videoPlayingEventListener<"u"&&this.videoElement.removeEventListener("playing",this.videoPlayingEventListener),typeof this.videoCanPlayListener<"u"&&this.videoElement.removeEventListener("loadedmetadata",this.videoCanPlayListener),this.cleanVideoSource(this.videoElement),this.videoElement=void 0)},r.prototype._destroyImageElement=function(){this.imageElement&&(this.imageLoadedListener!==void 0&&this.imageElement.removeEventListener("load",this.imageLoadedListener),this.imageElement.src=void 0,this.imageElement.removeAttribute("src"),this.imageElement=void 0)},r.prototype._destroyCaptureCanvas=function(){this.captureCanvasContext=void 0,this.captureCanvas=void 0},r.prototype.addVideoSource=function(e,t){try{e.srcObject=t}catch{e.src=URL.createObjectURL(t)}},r.prototype.cleanVideoSource=function(e){try{e.srcObject=null}catch{e.src=""}this.videoElement.removeAttribute("src")},r}(),De=function(){function r(e,t,n,i,a,o){n===void 0&&(n=t==null?0:8*t.length),o===void 0&&(o=ie.currentTimeMillis()),this.text=e,this.rawBytes=t,this.numBits=n,this.resultPoints=i,this.format=a,this.timestamp=o,this.text=e,this.rawBytes=t,n==null?this.numBits=t==null?0:8*t.length:this.numBits=n,this.resultPoints=i,this.format=a,this.resultMetadata=null,o==null?this.timestamp=ie.currentTimeMillis():this.timestamp=o}return r.prototype.getText=function(){return this.text},r.prototype.getRawBytes=function(){return this.rawBytes},r.prototype.getNumBits=function(){return this.numBits},r.prototype.getResultPoints=function(){return this.resultPoints},r.prototype.getBarcodeFormat=function(){return this.format},r.prototype.getResultMetadata=function(){return this.resultMetadata},r.prototype.putMetadata=function(e,t){this.resultMetadata===null&&(this.resultMetadata=new Map),this.resultMetadata.set(e,t)},r.prototype.putAllMetadata=function(e){e!==null&&(this.resultMetadata===null?this.resultMetadata=e:this.resultMetadata=new Map(e))},r.prototype.addResultPoints=function(e){var t=this.resultPoints;if(t===null)this.resultPoints=e;else if(e!==null&&e.length>0){var n=new Array(t.length+e.length);ie.arraycopy(t,0,n,0,t.length),ie.arraycopy(e,0,n,t.length,e.length),this.resultPoints=n}},r.prototype.getTimestamp=function(){return this.timestamp},r.prototype.toString=function(){return this.text},r}(),Hn;(function(r){r[r.AZTEC=0]="AZTEC",r[r.CODABAR=1]="CODABAR",r[r.CODE_39=2]="CODE_39",r[r.CODE_93=3]="CODE_93",r[r.CODE_128=4]="CODE_128",r[r.DATA_MATRIX=5]="DATA_MATRIX",r[r.EAN_8=6]="EAN_8",r[r.EAN_13=7]="EAN_13",r[r.ITF=8]="ITF",r[r.MAXICODE=9]="MAXICODE",r[r.PDF_417=10]="PDF_417",r[r.QR_CODE=11]="QR_CODE",r[r.RSS_14=12]="RSS_14",r[r.RSS_EXPANDED=13]="RSS_EXPANDED",r[r.UPC_A=14]="UPC_A",r[r.UPC_E=15]="UPC_E",r[r.UPC_EAN_EXTENSION=16]="UPC_EAN_EXTENSION"})(Hn||(Hn={}));const P=Hn;var qn;(function(r){r[r.OTHER=0]="OTHER",r[r.ORIENTATION=1]="ORIENTATION",r[r.BYTE_SEGMENTS=2]="BYTE_SEGMENTS",r[r.ERROR_CORRECTION_LEVEL=3]="ERROR_CORRECTION_LEVEL",r[r.ISSUE_NUMBER=4]="ISSUE_NUMBER",r[r.SUGGESTED_PRICE=5]="SUGGESTED_PRICE",r[r.POSSIBLE_COUNTRY=6]="POSSIBLE_COUNTRY",r[r.UPC_EAN_EXTENSION=7]="UPC_EAN_EXTENSION",r[r.PDF417_EXTRA_METADATA=8]="PDF417_EXTRA_METADATA",r[r.STRUCTURED_APPEND_SEQUENCE=9]="STRUCTURED_APPEND_SEQUENCE",r[r.STRUCTURED_APPEND_PARITY=10]="STRUCTURED_APPEND_PARITY"})(qn||(qn={}));const Oe=qn;var Ur=function(){function r(e,t,n,i,a,o){a===void 0&&(a=-1),o===void 0&&(o=-1),this.rawBytes=e,this.text=t,this.byteSegments=n,this.ecLevel=i,this.structuredAppendSequenceNumber=a,this.structuredAppendParity=o,this.numBits=e==null?0:8*e.length}return r.prototype.getRawBytes=function(){return this.rawBytes},r.prototype.getNumBits=function(){return this.numBits},r.prototype.setNumBits=function(e){this.numBits=e},r.prototype.getText=function(){return this.text},r.prototype.getByteSegments=function(){return this.byteSegments},r.prototype.getECLevel=function(){return this.ecLevel},r.prototype.getErrorsCorrected=function(){return this.errorsCorrected},r.prototype.setErrorsCorrected=function(e){this.errorsCorrected=e},r.prototype.getErasures=function(){return this.erasures},r.prototype.setErasures=function(e){this.erasures=e},r.prototype.getOther=function(){return this.other},r.prototype.setOther=function(e){this.other=e},r.prototype.hasStructuredAppend=function(){return this.structuredAppendParity>=0&&this.structuredAppendSequenceNumber>=0},r.prototype.getStructuredAppendParity=function(){return this.structuredAppendParity},r.prototype.getStructuredAppendSequenceNumber=function(){return this.structuredAppendSequenceNumber},r}(),nr=function(){function r(){}return r.prototype.exp=function(e){return this.expTable[e]},r.prototype.log=function(e){if(e===0)throw new k;return this.logTable[e]},r.addOrSubtract=function(e,t){return e^t},r}(),lt=function(){function r(e,t){if(t.length===0)throw new k;this.field=e;var n=t.length;if(n>1&&t[0]===0){for(var i=1;i<n&&t[i]===0;)i++;i===n?this.coefficients=Int32Array.from([0]):(this.coefficients=new Int32Array(n-i),ie.arraycopy(t,i,this.coefficients,0,this.coefficients.length))}else this.coefficients=t}return r.prototype.getCoefficients=function(){return this.coefficients},r.prototype.getDegree=function(){return this.coefficients.length-1},r.prototype.isZero=function(){return this.coefficients[0]===0},r.prototype.getCoefficient=function(e){return this.coefficients[this.coefficients.length-1-e]},r.prototype.evaluateAt=function(e){if(e===0)return this.getCoefficient(0);var t=this.coefficients,n;if(e===1){n=0;for(var i=0,a=t.length;i!==a;i++){var o=t[i];n=nr.addOrSubtract(n,o)}return n}n=t[0];for(var s=t.length,l=this.field,i=1;i<s;i++)n=nr.addOrSubtract(l.multiply(e,n),t[i]);return n},r.prototype.addOrSubtract=function(e){if(!this.field.equals(e.field))throw new k("GenericGFPolys do not have same GenericGF field");if(this.isZero())return e;if(e.isZero())return this;var t=this.coefficients,n=e.coefficients;if(t.length>n.length){var i=t;t=n,n=i}var a=new Int32Array(n.length),o=n.length-t.length;ie.arraycopy(n,0,a,0,o);for(var s=o;s<n.length;s++)a[s]=nr.addOrSubtract(t[s-o],n[s]);return new r(this.field,a)},r.prototype.multiply=function(e){if(!this.field.equals(e.field))throw new k("GenericGFPolys do not have same GenericGF field");if(this.isZero()||e.isZero())return this.field.getZero();for(var t=this.coefficients,n=t.length,i=e.coefficients,a=i.length,o=new Int32Array(n+a-1),s=this.field,l=0;l<n;l++)for(var u=t[l],c=0;c<a;c++)o[l+c]=nr.addOrSubtract(o[l+c],s.multiply(u,i[c]));return new r(s,o)},r.prototype.multiplyScalar=function(e){if(e===0)return this.field.getZero();if(e===1)return this;for(var t=this.coefficients.length,n=this.field,i=new Int32Array(t),a=this.coefficients,o=0;o<t;o++)i[o]=n.multiply(a[o],e);return new r(n,i)},r.prototype.multiplyByMonomial=function(e,t){if(e<0)throw new k;if(t===0)return this.field.getZero();for(var n=this.coefficients,i=n.length,a=new Int32Array(i+e),o=this.field,s=0;s<i;s++)a[s]=o.multiply(n[s],t);return new r(o,a)},r.prototype.divide=function(e){if(!this.field.equals(e.field))throw new k("GenericGFPolys do not have same GenericGF field");if(e.isZero())throw new k("Divide by 0");for(var t=this.field,n=t.getZero(),i=this,a=e.getCoefficient(e.getDegree()),o=t.inverse(a);i.getDegree()>=e.getDegree()&&!i.isZero();){var s=i.getDegree()-e.getDegree(),l=t.multiply(i.getCoefficient(i.getDegree()),o),u=e.multiplyByMonomial(s,l),c=t.buildMonomial(s,l);n=n.addOrSubtract(c),i=i.addOrSubtract(u)}return[n,i]},r.prototype.toString=function(){for(var e="",t=this.getDegree();t>=0;t--){var n=this.getCoefficient(t);if(n!==0){if(n<0?(e+=" - ",n=-n):e.length>0&&(e+=" + "),t===0||n!==1){var i=this.field.log(n);i===0?e+="1":i===1?e+="a":(e+="a^",e+=i)}t!==0&&(t===1?e+="x":(e+="x^",e+=t))}}return e},r}(),Au=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),Ta=function(r){Au(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e.kind="ArithmeticException",e}(Ue),Su=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),Re=function(r){Su(e,r);function e(t,n,i){var a=r.call(this)||this;a.primitive=t,a.size=n,a.generatorBase=i;for(var o=new Int32Array(n),s=1,l=0;l<n;l++)o[l]=s,s*=2,s>=n&&(s^=t,s&=n-1);a.expTable=o;for(var u=new Int32Array(n),l=0;l<n-1;l++)u[o[l]]=l;return a.logTable=u,a.zero=new lt(a,Int32Array.from([0])),a.one=new lt(a,Int32Array.from([1])),a}return e.prototype.getZero=function(){return this.zero},e.prototype.getOne=function(){return this.one},e.prototype.buildMonomial=function(t,n){if(t<0)throw new k;if(n===0)return this.zero;var i=new Int32Array(t+1);return i[0]=n,new lt(this,i)},e.prototype.inverse=function(t){if(t===0)throw new Ta;return this.expTable[this.size-this.logTable[t]-1]},e.prototype.multiply=function(t,n){return t===0||n===0?0:this.expTable[(this.logTable[t]+this.logTable[n])%(this.size-1)]},e.prototype.getSize=function(){return this.size},e.prototype.getGeneratorBase=function(){return this.generatorBase},e.prototype.toString=function(){return"GF(0x"+$.toHexString(this.primitive)+","+this.size+")"},e.prototype.equals=function(t){return t===this},e.AZTEC_DATA_12=new e(4201,4096,1),e.AZTEC_DATA_10=new e(1033,1024,1),e.AZTEC_DATA_6=new e(67,64,1),e.AZTEC_PARAM=new e(19,16,1),e.QR_CODE_FIELD_256=new e(285,256,0),e.DATA_MATRIX_FIELD_256=new e(301,256,1),e.AZTEC_DATA_8=e.DATA_MATRIX_FIELD_256,e.MAXICODE_FIELD_64=e.AZTEC_DATA_6,e}(nr),Eu=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),Rr=function(r){Eu(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e.kind="ReedSolomonException",e}(Ue),Iu=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),ir=function(r){Iu(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e.kind="IllegalStateException",e}(Ue),Gr=function(){function r(e){this.field=e}return r.prototype.decode=function(e,t){for(var n=this.field,i=new lt(n,e),a=new Int32Array(t),o=!0,s=0;s<t;s++){var l=i.evaluateAt(n.exp(s+n.getGeneratorBase()));a[a.length-1-s]=l,l!==0&&(o=!1)}if(!o)for(var u=new lt(n,a),c=this.runEuclideanAlgorithm(n.buildMonomial(t,1),u,t),f=c[0],h=c[1],p=this.findErrorLocations(f),g=this.findErrorMagnitudes(h,p),s=0;s<p.length;s++){var x=e.length-1-n.log(p[s]);if(x<0)throw new Rr("Bad error location");e[x]=Re.addOrSubtract(e[x],g[s])}},r.prototype.runEuclideanAlgorithm=function(e,t,n){if(e.getDegree()<t.getDegree()){var i=e;e=t,t=i}for(var a=this.field,o=e,s=t,l=a.getZero(),u=a.getOne();s.getDegree()>=(n/2|0);){var c=o,f=l;if(o=s,l=u,o.isZero())throw new Rr("r_{i-1} was zero");s=c;for(var h=a.getZero(),p=o.getCoefficient(o.getDegree()),g=a.inverse(p);s.getDegree()>=o.getDegree()&&!s.isZero();){var x=s.getDegree()-o.getDegree(),m=a.multiply(s.getCoefficient(s.getDegree()),g);h=h.addOrSubtract(a.buildMonomial(x,m)),s=s.addOrSubtract(o.multiplyByMonomial(x,m))}if(u=h.multiply(l).addOrSubtract(f),s.getDegree()>=o.getDegree())throw new ir("Division algorithm failed to reduce polynomial?")}var w=u.getCoefficient(0);if(w===0)throw new Rr("sigmaTilde(0) was zero");var _=a.inverse(w),E=u.multiplyScalar(_),S=s.multiplyScalar(_);return[E,S]},r.prototype.findErrorLocations=function(e){var t=e.getDegree();if(t===1)return Int32Array.from([e.getCoefficient(1)]);for(var n=new Int32Array(t),i=0,a=this.field,o=1;o<a.getSize()&&i<t;o++)e.evaluateAt(o)===0&&(n[i]=a.inverse(o),i++);if(i!==t)throw new Rr("Error locator degree does not match number of roots");return n},r.prototype.findErrorMagnitudes=function(e,t){for(var n=t.length,i=new Int32Array(n),a=this.field,o=0;o<n;o++){for(var s=a.inverse(t[o]),l=1,u=0;u<n;u++)if(o!==u){var c=a.multiply(t[u],s),f=(c&1)===0?c|1:c&-2;l=a.multiply(l,f)}i[o]=a.multiply(e.evaluateAt(s),a.inverse(l)),a.getGeneratorBase()!==0&&(i[o]=a.multiply(i[o],s))}return i},r}(),be;(function(r){r[r.UPPER=0]="UPPER",r[r.LOWER=1]="LOWER",r[r.MIXED=2]="MIXED",r[r.DIGIT=3]="DIGIT",r[r.PUNCT=4]="PUNCT",r[r.BINARY=5]="BINARY"})(be||(be={}));var Ma=function(){function r(){}return r.prototype.decode=function(e){this.ddata=e;var t=e.getBits(),n=this.extractBits(t),i=this.correctBits(n),a=r.convertBoolArrayToByteArray(i),o=r.getEncodedData(i),s=new Ur(a,o,null,null);return s.setNumBits(i.length),s},r.highLevelDecode=function(e){return this.getEncodedData(e)},r.getEncodedData=function(e){for(var t=e.length,n=be.UPPER,i=be.UPPER,a="",o=0;o<t;)if(i===be.BINARY){if(t-o<5)break;var s=r.readCode(e,o,5);if(o+=5,s===0){if(t-o<11)break;s=r.readCode(e,o,11)+31,o+=11}for(var l=0;l<s;l++){if(t-o<8){o=t;break}var u=r.readCode(e,o,8);a+=X.castAsNonUtf8Char(u),o+=8}i=n}else{var c=i===be.DIGIT?4:5;if(t-o<c)break;var u=r.readCode(e,o,c);o+=c;var f=r.getCharacter(i,u);f.startsWith("CTRL_")?(n=i,i=r.getTable(f.charAt(5)),f.charAt(6)==="L"&&(n=i)):(a+=f,i=n)}return a},r.getTable=function(e){switch(e){case"L":return be.LOWER;case"P":return be.PUNCT;case"M":return be.MIXED;case"D":return be.DIGIT;case"B":return be.BINARY;case"U":default:return be.UPPER}},r.getCharacter=function(e,t){switch(e){case be.UPPER:return r.UPPER_TABLE[t];case be.LOWER:return r.LOWER_TABLE[t];case be.MIXED:return r.MIXED_TABLE[t];case be.PUNCT:return r.PUNCT_TABLE[t];case be.DIGIT:return r.DIGIT_TABLE[t];default:throw new ir("Bad table")}},r.prototype.correctBits=function(e){var t,n;this.ddata.getNbLayers()<=2?(n=6,t=Re.AZTEC_DATA_6):this.ddata.getNbLayers()<=8?(n=8,t=Re.AZTEC_DATA_8):this.ddata.getNbLayers()<=22?(n=10,t=Re.AZTEC_DATA_10):(n=12,t=Re.AZTEC_DATA_12);var i=this.ddata.getNbDatablocks(),a=e.length/n;if(a<i)throw new D;for(var o=e.length%n,s=new Int32Array(a),l=0;l<a;l++,o+=n)s[l]=r.readCode(e,o,n);try{var u=new Gr(t);u.decode(s,a-i)}catch(m){throw new D(m)}for(var c=(1<<n)-1,f=0,l=0;l<i;l++){var h=s[l];if(h===0||h===c)throw new D;(h===1||h===c-1)&&f++}for(var p=new Array(i*n-f),g=0,l=0;l<i;l++){var h=s[l];if(h===1||h===c-1)p.fill(h>1,g,g+n-1),g+=n-1;else for(var x=n-1;x>=0;--x)p[g++]=(h&1<<x)!==0}return p},r.prototype.extractBits=function(e){var t=this.ddata.isCompact(),n=this.ddata.getNbLayers(),i=(t?11:14)+n*4,a=new Int32Array(i),o=new Array(this.totalBitsInLayer(n,t));if(t)for(var s=0;s<a.length;s++)a[s]=s;else for(var l=i+1+2*$.truncDivision($.truncDivision(i,2)-1,15),u=i/2,c=$.truncDivision(l,2),s=0;s<u;s++){var f=s+$.truncDivision(s,15);a[u-s-1]=c-f-1,a[u+s]=c+f+1}for(var s=0,h=0;s<n;s++){for(var p=(n-s)*4+(t?9:12),g=s*2,x=i-1-g,m=0;m<p;m++)for(var w=m*2,_=0;_<2;_++)o[h+w+_]=e.get(a[g+_],a[g+m]),o[h+2*p+w+_]=e.get(a[g+m],a[x-_]),o[h+4*p+w+_]=e.get(a[x-_],a[x-m]),o[h+6*p+w+_]=e.get(a[x-m],a[g+_]);h+=p*8}return o},r.readCode=function(e,t,n){for(var i=0,a=t;a<t+n;a++)i<<=1,e[a]&&(i|=1);return i},r.readByte=function(e,t){var n=e.length-t;return n>=8?r.readCode(e,t,8):r.readCode(e,t,n)<<8-n},r.convertBoolArrayToByteArray=function(e){for(var t=new Uint8Array((e.length+7)/8),n=0;n<t.length;n++)t[n]=r.readByte(e,8*n);return t},r.prototype.totalBitsInLayer=function(e,t){return((t?88:112)+16*e)*e},r.UPPER_TABLE=["CTRL_PS"," ","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","CTRL_LL","CTRL_ML","CTRL_DL","CTRL_BS"],r.LOWER_TABLE=["CTRL_PS"," ","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","CTRL_US","CTRL_ML","CTRL_DL","CTRL_BS"],r.MIXED_TABLE=["CTRL_PS"," ","\\1","\\2","\\3","\\4","\\5","\\6","\\7","\b"," ",`
|