{"version":3,"names":["createContext","useContext","NOOP","NOOP_OTP_FIELD_ROOT_CONTEXT","activeIndex","autoComplete","undefined","disabled","form","focusInput","queueFocusInput","getInputId","handleInputBlur","handleInputFocus","inputMode","inputAriaLabelledBy","invalid","length","mask","pattern","reportValueInvalid","readOnly","required","sanitizeValue","setValue","state","valid","touched","dirty","filled","focused","complete","value","validationType","present","OTPFieldRootContext","useOTPFieldRootContext","context","Error","getOTPFieldInputState","index"],"sources":["otp-field-root-context.ts"],"sourcesContent":["import type { JSX } from \"@solidjs/web\";\nimport { type Accessor, createContext, useContext } from \"solid-js\";\nimport type {\n\tOTPFieldInputState,\n\tOTPFieldRootChangeEventDetails,\n\tOTPFieldRootInvalidEventDetails,\n\tOTPFieldRootState,\n\tOTPFieldValidationType,\n} from \"./otp-field-root-types.ts\";\n\n/**\n * Context published by `<OTPField.Root>` to its descendant slot `<Input>`s.\n *\n * Solid 2 adaptation from Base UI React's `OTPFieldRootContext`:\n *\n * - Every reactive entry is exposed as `Accessor<T>` so descendants pull live\n *   values on demand without tripping the top-level reactive-read rule\n *   (RFC 01). The React version ships snapshots; here we ship getters.\n * - Callbacks (`setValue`, `focusInput`, `queueFocusInput`, `handleInputBlur`,\n *   `handleInputFocus`, `reportValueInvalid`, `getInputId`) are plain stable\n *   functions owned by the root — slot inputs capture them into event\n *   closures.\n * - `state` is an accessor returning the full `OTPFieldRootState` object so\n *   each slot can derive its own `OTPFieldInputState` via the helper below.\n */\nexport interface OTPFieldRootContextValue {\n\tactiveIndex: Accessor<number>;\n\tautoComplete: Accessor<string | undefined>;\n\tdisabled: Accessor<boolean>;\n\tform: Accessor<string | undefined>;\n\tfocusInput: (index: number) => void;\n\tqueueFocusInput: (index: number, value: string) => void;\n\tgetInputId: (index: number) => string | undefined;\n\thandleInputBlur: (\n\t\tevent: FocusEvent & { currentTarget: HTMLInputElement },\n\t) => void;\n\thandleInputFocus: (\n\t\tindex: number,\n\t\tevent: FocusEvent & { currentTarget: HTMLInputElement },\n\t) => void;\n\tinputMode: Accessor<JSX.InputHTMLAttributes<HTMLInputElement>[\"inputmode\"]>;\n\tinputAriaLabelledBy: Accessor<string | undefined>;\n\tinvalid: Accessor<boolean>;\n\tlength: Accessor<number>;\n\tmask: Accessor<boolean>;\n\tpattern: Accessor<string | undefined>;\n\treportValueInvalid: (\n\t\tvalue: string,\n\t\tdetails: OTPFieldRootInvalidEventDetails,\n\t) => void;\n\treadOnly: Accessor<boolean>;\n\trequired: Accessor<boolean>;\n\tsanitizeValue: Accessor<((value: string) => string) | undefined>;\n\tsetValue: (\n\t\tvalue: string,\n\t\tdetails: OTPFieldRootChangeEventDetails,\n\t) => string | null;\n\tstate: Accessor<OTPFieldRootState>;\n\tvalidationType: Accessor<OTPFieldValidationType>;\n\tvalue: Accessor<string>;\n\t/** Marker — `true` when provided by a real `<OTPField.Root>`. */\n\treadonly present: boolean;\n}\n\nconst NOOP = (): void => {};\n\nexport const NOOP_OTP_FIELD_ROOT_CONTEXT: OTPFieldRootContextValue = {\n\tactiveIndex: () => 0,\n\tautoComplete: () => undefined,\n\tdisabled: () => false,\n\tform: () => undefined,\n\tfocusInput: NOOP,\n\tqueueFocusInput: NOOP,\n\tgetInputId: () => undefined,\n\thandleInputBlur: NOOP,\n\thandleInputFocus: NOOP,\n\tinputMode: () => undefined,\n\tinputAriaLabelledBy: () => undefined,\n\tinvalid: () => false,\n\tlength: () => 0,\n\tmask: () => false,\n\tpattern: () => undefined,\n\treportValueInvalid: NOOP,\n\treadOnly: () => false,\n\trequired: () => false,\n\tsanitizeValue: () => undefined,\n\tsetValue: () => null,\n\tstate: () => ({\n\t\tdisabled: false,\n\t\tvalid: null,\n\t\ttouched: false,\n\t\tdirty: false,\n\t\tfilled: false,\n\t\tfocused: false,\n\t\tcomplete: false,\n\t\tlength: 0,\n\t\treadOnly: false,\n\t\trequired: false,\n\t\tvalue: \"\",\n\t}),\n\tvalidationType: () => \"numeric\",\n\tvalue: () => \"\",\n\tpresent: false,\n};\n\nexport const OTPFieldRootContext = createContext<OTPFieldRootContextValue>(\n\tNOOP_OTP_FIELD_ROOT_CONTEXT,\n);\n\n/**\n * Read the nearest `<OTPField.Root>` context. Throws when no real root is an\n * ancestor — slot `<Input>`s are meaningless without their root.\n */\nexport function useOTPFieldRootContext(): OTPFieldRootContextValue {\n\tconst context = useContext(OTPFieldRootContext);\n\tif (!context.present) {\n\t\tthrow new Error(\n\t\t\t\"Base UI: OTPFieldRootContext is missing. OTPField parts must be placed within <OTPField.Root>.\",\n\t\t);\n\t}\n\treturn context;\n}\n\n/**\n * Derive per-slot state from the root state + this slot's value and index.\n * Pure helper — call it from a memo if you want reactive updates.\n */\nexport function getOTPFieldInputState(\n\tstate: OTPFieldRootState,\n\tvalue: string,\n\tindex: number,\n): OTPFieldInputState {\n\treturn {\n\t\t...state,\n\t\tvalue,\n\t\tindex,\n\t\tfilled: value !== \"\",\n\t};\n}\n"],"mappings":"AACA,SAAwBA,aAAa,EAAEC,UAAU,QAAQ,UAAU;;AASnE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAwCA,MAAMC,IAAI,GAAGA,CAAA,KAAY,CAAC,CAAC;AAE3B,OAAO,MAAMC,2BAAqD,GAAG;EACpEC,WAAW,EAAEA,CAAA,KAAM,CAAC;EACpBC,YAAY,EAAEA,CAAA,KAAMC,SAAS;EAC7BC,QAAQ,EAAEA,CAAA,KAAM,KAAK;EACrBC,IAAI,EAAEA,CAAA,KAAMF,SAAS;EACrBG,UAAU,EAAEP,IAAI;EAChBQ,eAAe,EAAER,IAAI;EACrBS,UAAU,EAAEA,CAAA,KAAML,SAAS;EAC3BM,eAAe,EAAEV,IAAI;EACrBW,gBAAgB,EAAEX,IAAI;EACtBY,SAAS,EAAEA,CAAA,KAAMR,SAAS;EAC1BS,mBAAmB,EAAEA,CAAA,KAAMT,SAAS;EACpCU,OAAO,EAAEA,CAAA,KAAM,KAAK;EACpBC,MAAM,EAAEA,CAA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